PageSourceSearch

https://tradeintelx.com/assets/PostTradeRecommendations-DgZnQTtL.js

js tradeintelx.com collected 2026-10-02 01:49:22 UTC 11,792 bytes, 1 lines download raw bytes

1import{o as F}from"./rolldown-runtime-ChpBd9eV.js";import{An as x,Ka as z,Pa as V,St as N,Tn as P,Tr as I,Va as O,Yt as h,_n as M,ba as w,rn as U,tt as W,wa as q}from"./chat-page-C-flp553.js";import{lo as B,uo as G}from"./market-core-B8Bfud51.js";import{Gn as H}from"./community-page-dub7UFXa.js";import{A as K,D as Y}from"./icons-vendor-DpKLKbbD.js";var n=F(z(),1),e=V(),ee=({tradeId:l,isVisible:d,onClose:o,onVideoSelect:v,trade:m})=>{const{user:p}=I(),k=O(),[i,R]=(0,n.useState)(null),[_,u]=(0,n.useState)(!1),[g,f]=(0,n.useState)(null),[j,A]=(0,n.useState)("cloud"),[c,C]=(0,n.useState)([]),S=s=>{const t=s.educationHubLink;t&&(o(),k(t.path,{state:t.state}))},L=s=>{window.open(s,"_blank","noopener,noreferrer")},T=s=>{const t=[];return s.ruleViolations?.forEach(a=>{t.push({type:a.type.replace(/_/g," "),priority:a.severity,reason:a.message,immediateAction:$(a.type)})}),s.insights?.forEach(a=>{t.push({type:a.title,priority:a.priority,reason:a.message,immediateAction:a.actionable?"Review recommended learning materials":null})}),{signals:t,recommendations:s.recommendations||[],analyzedAt:{seconds:Date.now()/1e3},method:"offline",insights:s.insights||[],riskAssessment:s.riskAssessment,actionSteps:s.actionSteps}},$=s=>({risk_percentage_violated:"Reduce position size to 1-2% of account",no_stop_loss:"Always set stop loss before entering trades",poor_risk_reward:"Target minimum 2:1 risk-reward ratio",fomo_trade:"Use a trading checklist to avoid impulsive decisions",revenge_trade:"Take a break after losses to reset emotions",poor_entry_timing:"Wait for clear confirmation signals",weak_setup:"Only trade high-probability setups"})[s]||"Review trading plan and rules",b=async()=>{try{u(!0),f(null),l&&console.log("⚠️ Cloud Functions disabled, using offline analysis"),console.log("🔧 Using offline analysis engine with dynamic video recommendations..."),A("offline");const s=m||{id:l},t=await G.analyzeTrade(s,[],[]);R(T(t)),console.log("✅ Offline analysis completed with dynamic video recommendations");try{const a=await B.getRecommendedContent({noStopLoss:t.ruleViolations?.some(r=>r.type==="no_stop_loss"),stopLossIssue:t.ruleViolations?.some(r=>r.type.includes("stop")),overtrading:t.insights?.some(r=>r.title?.toLowerCase().includes("overtrad")),emotionalTrade:t.insights?.some(r=>r.title?.toLowerCase().includes("emotion")),revengeTrade:t.ruleViolations?.some(r=>r.type==="revenge_trade"),poorRiskReward:t.ruleViolations?.some(r=>r.type==="poor_risk_reward"),riskRewardIssue:t.insights?.some(r=>r.title?.toLowerCase().includes("risk")),entryIssue:t.ruleViolations?.some(r=>r.type==="poor_entry_timing"),exitIssue:t.insights?.some(r=>r.title?.toLowerCase().includes("exit")),setup:s.setup||s.notes});C(a),console.log("📚 Learning content fetched:",a.length,"topics")}catch(a){console.warn("Could not fetch learning content:",a)}}catch(s){console.error("❌ Analysis failed:",s),f(`Analysis failed: ${s.message}`)}finally{u(!1)}};(0,n.useEffect)(()=>{d&&(l||m)&&p?.uid&&b()},[d,l,m,p?.uid]);const y=s=>{switch(s){case"critical":return"from-red-600 to-red-700";case"high":return"from-orange-600 to-orange-700";case"medium":return"from-yellow-600 to-yellow-700";default:return"from-blue-600 to-blue-700"}},E=s=>{switch(s){case"critical":return h;case"high":return h;default:return H}};return d?(0,e.jsx)(q,{children:(0,e.jsx)(w.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-50 flex items-center justify-center p-4",onClick:o,children:(0,e.jsxs)(w.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},className:"bg-slate-900 rounded-2xl border border-slate-700 shadow-2xl max-w-2xl w-full max-h-[80vh] overflow-hidden",onClick:s=>s.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between p-6 border-b border-slate-700",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)("div",{className:"p-2 bg-gradient-to-r from-purple-600 to-blue-600 rounded-xl",children:(0,e.jsx)(x,{className:"w-6 h-6 text-white"})}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("h2",{className:"text-xl font-bold text-white",children:"Learning Recommendations"}),j==="offline"&&(0,e.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-blue-600/20 rounded-full",children:[(0,e.jsx)(Y,{className:"w-3 h-3 text-blue-400"}),(0,e.jsx)("span",{className:"text-xs text-blue-400 font-medium",children:"Offline"})]}),j==="cloud"&&(0,e.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-green-600/20 rounded-full",children:[(0,e.jsx)(K,{className:"w-3 h-3 text-green-400"}),(0,e.jsx)("span",{className:"text-xs text-green-400 font-medium",children:"Cloud AI"})]})]}),(0,e.jsx)("p",{className:"text-slate-400 text-sm",children:"Based on your recent trade"})]})]}),(0,e.jsx)("button",{onClick:o,className:"p-2 text-slate-400 hover:text-white hover:bg-slate-800 rounded-lg transition-colors",children:(0,e.jsx)(W,{className:"w-5 h-5"})})]}),(0,e.jsxs)("div",{className:"p-6 overflow-y-auto max-h-[60vh]",children:[_&&(0,e.jsxs)("div",{className:"flex items-center justify-center py-8",children:[(0,e.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-purple-600"}),(0,e.jsx)("span",{className:"ml-3 text-slate-400",children:"Analyzing your trade..."})]}),g&&(0,e.jsxs)("div",{className:"bg-red-900/20 border border-red-700/50 rounded-xl p-4 mb-6",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 text-red-400 mb-2",children:[(0,e.jsx)(h,{className:"w-5 h-5"}),(0,e.jsx)("span",{className:"font-medium",children:"Analysis Error"})]}),(0,e.jsx)("p",{className:"text-red-300 text-sm",children:g}),(0,e.jsx)("button",{onClick:b,className:"mt-3 px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-sm transition-colors",children:"Retry Analysis"})]}),i&&(0,e.jsxs)("div",{className:"space-y-6",children:[i.signals&&i.signals.length>0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-lg font-semibold text-white mb-4",children:"Key Learning Opportunities"}),(0,e.jsx)("div",{className:"space-y-3",children:i.signals.map((s,t)=>{const a=E(s.priority);return(0,e.jsx)("div",{className:`bg-gradient-to-r ${y(s.priority)}/10 border border-slate-600/50 rounded-xl p-4`,children:(0,e.jsxs)("div",{className:"flex items-start gap-3",children:[(0,e.jsx)("div",{className:`p-2 bg-gradient-to-r ${y(s.priority)} rounded-lg flex-shrink-0`,children:(0,e.jsx)(a,{className:"w-4 h-4 text-white"})}),(0,e.jsxs)("div",{className:"flex-1",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,e.jsx)("span",{className:"text-white font-medium capitalize",children:s.type}),(0,e.jsx)("span",{className:`px-2 py-1 text-xs rounded-full ${s.priority==="critical"?"bg-red-600 text-white":s.priority==="high"?"bg-orange-600 text-white":s.priority==="medium"?"bg-yellow-600 text-black":"bg-blue-600 text-white"}`,children:s.priority})]}),(0,e.jsx)("p",{className:"text-slate-300 text-sm mb-2",children:s.reason}),s.immediateAction&&(0,e.jsxs)("p",{className:"text-purple-400 text-sm font-medium",children:["→ ",s.immediateAction]})]})]})},t)})})]}),i.recommendations&&i.recommendations.length>0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-lg font-semibold text-white mb-4",children:"Recommended Videos"}),(0,e.jsx)("div",{className:"grid gap-4",children:i.recommendations.map(s=>(0,e.jsx)("div",{className:"bg-slate-800/50 rounded-xl p-4 border border-slate-700/50 hover:border-purple-500/50 transition-colors cursor-pointer group",onClick:()=>v?.(s),children:(0,e.jsxs)("div",{className:"flex items-start gap-4",children:[(0,e.jsxs)("div",{className:"relative flex-shrink-0",children:[s.thumbnail?(0,e.jsx)("img",{src:s.thumbnail,alt:s.title,className:"w-20 h-12 rounded-lg object-cover"}):(0,e.jsx)("div",{className:"w-20 h-12 bg-slate-700 rounded-lg flex items-center justify-center",children:(0,e.jsx)(N,{className:"w-6 h-6 text-slate-400"})}),(0,e.jsx)("div",{className:"absolute inset-0 bg-black/40 rounded-lg flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:(0,e.jsx)(N,{className:"w-6 h-6 text-white"})})]}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsx)("h4",{className:"text-white font-medium mb-1 line-clamp-2 group-hover:text-purple-400 transition-colors",children:s.title||"Untitled Video"}),(0,e.jsx)("p",{className:"text-slate-400 text-sm mb-2 line-clamp-2",children:s.description||""}),(0,e.jsxs)("div",{className:"flex items-center gap-4 text-xs text-slate-500 mb-2",children:[s.duration&&(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)(U,{className:"w-3 h-3"}),(0,e.jsx)("span",{children:s.duration})]}),(0,e.jsx)("span",{className:"capitalize",children:s.difficulty||"beginner"}),s.relevanceScore&&(0,e.jsxs)("span",{className:"text-purple-400",children:[Math.round(s.relevanceScore),"% match"]})]}),s.matchingReasons&&s.matchingReasons.length>0&&(0,e.jsxs)("div",{className:"text-xs text-slate-400",children:[(0,e.jsx)("span",{className:"font-medium text-slate-300",children:"Why recommended: "}),s.matchingReasons.slice(0,2).join(", "),s.matchingReasons.length>2&&"..."]})]})]})},s.id))})]}),c&&c.length>0&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("h3",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[(0,e.jsx)(M,{className:"w-5 h-5 text-purple-400"}),"Explore in Education Hub"]}),(0,e.jsx)("div",{className:"grid gap-3",children:c.map(s=>(0,e.jsx)("div",{className:"bg-slate-800/50 rounded-xl p-4 border border-slate-700/50 hover:border-purple-500/50 transition-colors",children:(0,e.jsxs)("div",{className:"flex items-start gap-3",children:[(0,e.jsx)("div",{className:"text-2xl flex-shrink-0",children:s.icon}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsx)("h4",{className:"text-white font-medium mb-1",children:s.displayName}),(0,e.jsx)("p",{className:"text-slate-400 text-sm mb-3",children:s.description}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,e.jsxs)("button",{onClick:()=>S(s),className:"flex items-center gap-1.5 px-3 py-1.5 bg-purple-600 hover:bg-purple-500 text-white text-sm rounded-lg transition-colors",children:[(0,e.jsx)(x,{className:"w-4 h-4"}),s.hasContent?"Watch Videos":"Browse Topic"]}),!s.hasContent&&s.fallbackResources?.map((t,a)=>(0,e.jsxs)("button",{onClick:()=>L(t.url),className:"flex items-center gap-1.5 px-3 py-1.5 bg-slate-700 hover:bg-slate-600 text-white text-sm rounded-lg transition-colors",children:[(0,e.jsx)(P,{className:"w-4 h-4"}),t.title]},a))]}),s.videos&&s.videos.length>0&&(0,e.jsxs)("div",{className:"mt-2 text-xs text-green-400",children:["✓ ",s.videos.length," video",s.videos.length!==1?"s":""," available"]})]})]})},s.topicId))})]}),i&&!i.signals?.length&&!i.recommendations?.length&&!c?.length&&(0,e.jsxs)("div",{className:"text-center py-8",children:[(0,e.jsx)(x,{className:"w-12 h-12 text-slate-600 mx-auto mb-3"}),(0,e.jsx)("h3",{className:"text-white font-medium mb-2",children:"Great Trade!"}),(0,e.jsx)("p",{className:"text-slate-400 text-sm",children:"No immediate learning opportunities identified from this trade."})]})]})]}),(0,e.jsx)("div",{className:"border-t border-slate-700 p-6",children:(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("div",{className:"text-xs text-slate-500",children:["Analysis completed at ",i?.analyzedAt?new Date(i.analyzedAt.seconds*1e3).toLocaleTimeString():"Unknown time"]}),(0,e.jsx)("button",{onClick:o,className:"px-4 py-2 bg-slate-700 hover:bg-slate-600 text-white rounded-lg transition-colors",children:"Close"})]})})]})})}):null};export{ee as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.