1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6140],{7677:(e,t,a)=>{a.d(t,{x:()=>O});var s=a(95155),n=a(12115),r=a(20063),l=a(25016),i=a(15239),o=a(80647),c=a(21786),d=a(11010),u=a(35299),m=a(90368),p=a(27937),x=a(1524),h=a(30814),g=a(97003),f=a(54679),b=a(40254),v=a(1495),_=a(32450),j=a(18720),y=a(87849),N=a(95752);function k(){return{ticker:"",optionType:void 0,entryPrice:void 0,exitPrice:void 0,positionSize:void 0,entryAt:void 0,exitAt:void 0,direction:void 0,outcome:void 0,pnl:void 0,title:"",description:"",notes:"",date:new Date().toISOString().split("T")[0]}}function w(e){return"long"===e?"call":"short"===e?"put":void 0}function A(e,t){if(!e)return;let a=new Date(e);if(!Number.isFinite(a.getTime()))return void console.warn("[log-trade-panel] invalid_saved_datetime",{tradeId:t,raw:e});let s=a.getFullYear(),n=String(a.getMonth()+1).padStart(2,"0"),r=String(a.getDate()).padStart(2,"0"),l=String(a.getHours()).padStart(2,"0"),i=String(a.getMinutes()).padStart(2,"0");return"".concat(s,"-").concat(n,"-").concat(r,"T").concat(l,":").concat(i)}function S(e){var t,a,S,T;let{onSaveSuccess:C,initialMethod:M="manual",editTrade:E,subscription:D,hideMethodSelector:P=!1,lockedMethod:R,embedded:L=!1}=e,{user:I}=(0,b.J)(),F=(0,r.useRouter)(),z=(0,v.n_)(_.FH.trades.create),W=(0,v.n_)(_.FH.trades.update),[B,O]=(0,n.useState)(null!=R?R:E?"manual":M),U=(null==D?void 0:D.plan)==="pro"&&((null==D?void 0:D.status)==="active"||(null==D?void 0:D.status)==="trialing"),[q,$]=(0,n.useState)(k()),V=(0,n.useRef)(null),[H,K]=(0,n.useState)(!1),[J,G]=(0,n.useState)(null),[Y,Z]=(0,n.useState)(!1),[X,Q]=(0,n.useState)([]),[ee,et]=(0,n.useState)(0),[ea,es]=(0,n.useState)(!1),[en,er]=(0,n.useState)(new Map),[el,ei]=(0,n.useState)(!1),[eo,ec]=(0,n.useState)(!1),[ed,eu]=(0,n.use
1State)(!1),[em,ep]=(0,n.useState)(null),[ex,eh]=(0,n.useState)(null),[eg,ef]=(0,n.useState)(!1),[eb,ev]=(0,n.useState)(null),[e_,ej]=(0,n.useState)(null),[ey,eN]=(0,n.useState)(!1),ek=(0,n.useRef)(null),[ew,eA]=(0,n.useState)([]),[eS,eT]=(0,n.useState)(!1),[eC,eM]=(0,n.useState)(null);(0,n.useEffect)(()=>{if(E){var e,t,a,s,n,r;$({id:E.id,ticker:null!=(e=E.ticker)?e:"",optionType:null!=(t=E.optionType)?t:w(E.direction),direction:E.direction,entryPrice:E.entryPrice,exitPrice:E.exitPrice,positionSize:E.positionSize,pnl:E.pnl,entryAt:A(E.entryAt,E.id),exitAt:A(E.exitAt,E.id),title:null!=(a=E.title)?a:"",description:null!=(s=E.description)?s:"",notes:null!=(n=E.notes)?n:"",date:null!=(r=E.date)?r:new Date().toISOString().split("T")[0]}),O("manual")}},[null==E?void 0:E.id]),(0,n.useEffect)(()=>{R&&O(R)},[R]),(0,n.useEffect)(()=>{"broker"===B&&e();async function e(){eT(!0);try{let e=await fetch("/api/brokerages");if(e.ok){let t=(await e.json()).map(e=>({id:e.id,slug:e.slug||"",display_name:e.display_name,aws_s3_square_logo_url:e.aws_s3_square_logo_url,maintenance_mode:e.maintenance_mode}));eA((0,N.B)(t))}else eA([])}catch(e){eA([])}finally{eT(!1)}}},[B]);let eE=async e=>{if(!I)return void j.o.error("Please log in to connect a broker");try{eM(e);let t=await fetch("/api/snaptrade/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:I.id})});if(!t.ok){let e=await t.json().catch(()=>null);if(402===t.status){j.o.error((null==e?void 0:e.error)||"Broker connections require a Pro subscription."),(0,y.f)()&&F.push("/?tab=pricing&next=%2F%3Ftab%3Dprofile%26section%3Dbroker");return}throw Error((null==e?void 0:e.error)||"Failed to register with SnapTrade")}let a=await fetch("/api/snaptrade/authorize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({brokerSlug:e})});if(!a.ok){let e=await a.json().catch(()=>null);if(402===a.status){j.o.error((null==e?void 0:e.error)||"Broker connections require a Pro subscription."),(0,y.f)()&&F.push("/?tab=pricing&next=%2F%3Ftab%3Dprofile%26section%3Dbroker");return}throw Error((null==e?void 0:e.error)||"Failed to get authorization URL")}let{redirectUrl:s}=await a.json();window.location.href=s}catch(t){console.error("Failed to initiate broker connection:",t);let e=t instanceof Error?t.message:"";/invalid broker|not supported|unsupported|unavailable/i.test(e)?j.o.error("This broker is currently unavailable for your region/account type in SnapTrade."):j.o.error("Failed to connect broker. Please try again.")}finally{eM(null)}},eD=e=>{let t=e.name.toLowerCase(),a=t.endsWith(".csv")||t.endsWith(".xls")||t.endsWith(".xlsx")||t.endsWith(".pdf")||t.endsWith(".png")||t.endsWith(".jpg")||t.endsWith(".jpeg");return["image/png","image/jpeg","image/jpg","application/pdf","text/csv","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"].includes(e.type)||a?e.size>0xa00000?void ej("File size must be less than 10MB"):void(ej(null),ep(e),e.type.startsWith("image/")&&eh(URL.createObjectURL(e))):void ej("Please upload a PNG, JPEG, PDF, CSV, or XLSX file")},eP=async()=>{if(em){ef(!0),ej(null);try{let e=new FormData;e.append("file",em);let t=await fetch("/api/analyze-trades",{method:"POST",body:e});if(!t.ok){let e=await t.json();throw Error(e.error||"Analysis failed")}let a=await t.json();if(ex&&(a.imageUrl=ex),a.trades&&a.trades.length>0){let e=a.trades[0],t={total:a.trades.length,withEntryAt:a.trades.filter(e=>!!e.entryAt).length,withExitAt:a.trades.filter(e=>!!e.exitAt).length,withBoth:a.trades.filter(e=>!!(e.entryAt&&e.exitAt)).length};console.log("[log-trade-panel] analysis_result_received",{analysisId:a.id,parseSource:a.parseSource,timeCoverage:t,firstTradeRawTimes:{symbol:null==e?void 0:e.symbol,entryAt:null==e?void 0:e.entryAt,exitAt:null==e?void 0:e.exitAt},sampleMissingTimes:a.trades.filter(e=>!e.entryAt||!e.exitAt).slice(0,3).map(e=>({symbol:e.symbol,entry:e.entry,exit:e.exit,entryAt:e.entryAt,exitAt:e.exitAt}))}),Q(a.trades),et(0),er(new Map),eO(a.trades[0],0),O("manual"),eR()}else console.log("No trades found in analysis result"),ej("No trades found in the uploaded file")}catch(e){ej(e instanceof Error?e.message:"Failed to analyze trades")}finally{ef(!1)}}},eR=()=>{ep(null),eh(null),ev(null),ej(null),ek.current&&(ek.current.value="")};function eL(e){let t=e.replace(/[\u200E\u200F\u202A-\u202E]/g,"").replace(/[,]/g," ").replace(/\s+/g," ").trim().match(/^(\d{1,2})\s+([A-Za-z]{3,9})\.?\s+(\d{4})\s+(\d{1,2})[:.](\d{2})(?::(\d{2}))?\s*(AM|PM)$/i);if(!t)return null;let[,a,s,n,r,l,i,o]=t,c={jan:0,january:0,feb:1,february:1,mar:2,march:2,apr:3,april:3,may:4,jun:5,june:5,jul:6,july:6,aug:7,august:7,sep:8,sept:8,september:8,oct:9,october:9,nov:10,november:10,dec:11,december:11}[s.toLowerCase()];if(null==c)return null;let d=Number(a),u=Number(n),m=Number(r),p=Number(l),x=Number(null!=i?i:"0"),h=o.toUpperCase();return[d,u,m,p,x].some(e=>!Number.isFinite(e))?null:("PM"===h&&12!==m&&(m+=12),"AM"===h&&12===m&&(m=0),new Date(u,c,d,m,p,x))}let eI=(e,t)=>{if(e)try{let a=e.replace(/[\u00A0\u202F]/g," ").replace(/\s+/g," ").trim().replace(/\s+(ET|EST|EDT|CT|CST|CDT|MT|MST|MDT|PT|PST|PDT|UTC|GMT)$/i,""),s=a.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::\d{2})?$/);if(s){let[,e,t,a,n,r]=s;return"".concat(e,"-").concat(t,"-").concat(a,"T").concat(n,":").concat(r)}let n=new Date(a);if(isNaN(n.getTime())){let e=function(e){let t=e.replace(/[\u00A0\u202F]/g," ").replace(/\s+(ET|EST|EDT|CT|CST|CDT|MT|MST|MDT|PT|PST|PDT|UTC|GMT)$/i,"").replace(/\s+/g," ").trim(),a=eL(t);if(a)return a;let s=function(e){let t=e.replace(/[\u200E\u200F\u202A-\u202E]/g,"").replace(/[,]/g," ").replace(/\s+/g," ").trim().match(/^(\d{4})[-/](\d{1,2})[-/](\d{1,2})\s+(\d{1,2})[:.](\d{2})(?::(\d{2}))?\s*(AM|PM)?$/i);if(!t)return null;let[,a,s,n,r,l,i,o]=t,c=Number(a),d=Number(s)-1,u=Number(n),m=Number(r),p=Number(l),x=Number(null!=i?i:"0");if([c,d,u,m,p,x].some(e=>!Number.isFinite(e)))return null;if(o){let e=o.toUpperCase();"PM"===e&&12!==m&&(m+=12),"AM"===e&&12===m&&(m=0)}return new Date(c,d,u,m,p,x)}(t);if(s)return s;let n=t.match(/(\d{1,2})\s+([A-Za-z]{3,9})\.?\s+(\d{4}).*?(\d{1,2})[:.](\d{2})(?::(\d{2}))?\s*(AM|PM)/i);if(n){let[,e,t,a,s,r,l,i]=n;return eL("".concat(e," ").concat(t," ").concat(a," ").concat(s,":").concat(r,":").concat(null!=l?l:"00"," ").concat(i))}return null}(a);e&&(n=e)}if(isNaN(n.getTime())){let e=function(e,t){if(!t)return null;let a=eF(t),s=e.replace(/[\u00A0\u202F]/g," ").replace(/\s+/g," ").trim().match(/^(\d{1,2})[:.](\d{2})(?::(\d{2}))?\s*(AM|PM)$/i);if(!s)return null;let[,n,r,l,i]=s,o=Number(n),c=Number(r),d=Number(null!=l?l:"0"),u=i.toUpperCase();if([o,c,d].some(e=>!Number.isFinite(e)))return null;"PM"===u&&12!==o&&(o+=12),"AM"===u&&12===o&&(o=0);let m=a.match(/^(\d{4})-(\d{2})-(\d{2})$/);if(!m)return null;let[,p,x,h]=m,g=Number(p),f=Number(x)-1;return new Date(g,f,Number(h),o,c,d)}(a,t);e&&(n=e)}if(isNaN(n.getTime()))return void console.warn("[log-trade-panel] safeParseDateTime_unparsed",{raw:e,normalized:a,fallbackDate:t});let r=n.getFullYear(),l=String(n.getMonth()+1).padStart(2,"0"),i=String(n.getDate()).padStart(2,"0"),o=String(n.getHours()).padStart(2,"0"),c=String(n.getMinutes()).padStart(2,"0");return"".concat(r,"-").concat(l,"-").concat(i,"T").concat(o,":").concat(c)}catch(t){console.warn("[log-trade-panel] safeParseDateTime_failed",{raw:e,error:t});return}},eF=e=>{if(!e)return new Date().toISOString().split("T")[0];let t=e.trim();if(t.match(/^(\d{4})-(\d{2})-(\d{2})$/))return t;let a=t.match(/^(\d{4})-(\d{2})-(\d{2})T/);if(a)return"".concat(a[1],"-").concat(a[2],"-").concat(a[3]);try{let t=new Date(e);if(isNaN(t.getTime()))return console.warn("Invalid date format, using today:",e),new Date().toISOString().split("T")[0];return t.toISOString().split("T")[0]}catch(t){return console.warn("Error parsing date, using today:",e,t),new Date().toISOString().split("T")[0]}},ez=e=>{var t,a,s;let n=eI(e.entryAt,e.date),r=eI(e.exitAt,e.date);return{ticker:e.symbol||"",entryPrice:e.entryPrice||e.entry,exitPrice:e.exitPrice||e.exit,positionSize:null!=(t=e.shares)?t:1,optionType:null!=(s=null!=(a=e.optionType)?a:function(e){if(e){if(/\bput\b/i.test(e))return"put";if(/\bcall\b/i.test(e))return"call"}}(e.symbol))?s:w(e.direction),entryAt:n,exitAt:r,date:eF(e.date)}},eW=e=>{let t=(e=>{var t;let a=(null==(t=e.ticker)?void 0:t.trim().toUpperCase())||"",s=e.optionType,n=e.entryPrice,r=e.exitPrice,l=e.entryAt,i=e.exitAt,o=e.positionSize;if(!a||!s||null==n||null==r||!l||!i)return{valid:!1,error:"Ticker, entry price, sell price, option type, entry time, and exit time are required."};if(!Number.isFinite(n)||n<=0||!Number.isFinite(r)||r<=0)return{valid:!1,error:"Entry and sell prices must be valid numbers greater than 0."};if(null!=o&&(!Number.isFinite(o)||o<=0))return{valid:!1,error:"Contracts must be a valid number greater than 0."};let c=new Date(l).getTime(),d=new Date(i).getTime();
1return Number.isFinite(c)&&Number.isFinite(d)&&!(d<c)?{valid:!0,normalized:{ticker:a,optionType:s,entryPrice:n,exitPrice:r,positionSize:null!=o?o:1,entryAt:l,exitAt:i}}:{valid:!1,error:"Exit time must be the same as or after entry time."}})(e);if(!t.valid)return t;let{ticker:a,optionType:s,entryPrice:n,exitPrice:r,positionSize:l,entryAt:i,exitAt:o}=t.normalized,c="call"===s?"long":"short",d=(r-n)*l,u=i.split("T")[0],m="".concat(a," ").concat(s.toUpperCase());return{valid:!0,payload:{...e,ticker:a,optionType:s,entryPrice:n,exitPrice:r,positionSize:l,entryAt:i,exitAt:o,direction:c,pnl:d,outcome:d>0?"win":d<0?"loss":"breakeven",date:u,title:m,description:"Manual options trade",notes:e.notes||"â"}}},eB=(e,t,a)=>{let s=a.get(t)||{};return{...k(),title:"",description:"",notes:"",...ez(e),...s}},eO=(e,t,a)=>{let s=ez(e);console.log("[log-trade-panel] autofill_trade",{symbol:e.symbol,rawEntryAt:e.entryAt,rawExitAt:e.exitAt,parsedEntryAt:s.entryAt,parsedExitAt:s.exitAt});let n=(null!=a?a:en).get(t)||{};$({...k(),title:"",description:"",notes:"",...s,...n}),es(!0)},eU=e=>{$(k()),Q([]),et(0),es(!1),er(new Map),Z(!0),j.o.success(e),null==C||C(),setTimeout(()=>Z(!1),3e3)},eq=async()=>{if(eo||0===X.length)return;ec(!0),G(null),Z(!1);let e=new Map(en);e.set(ee,q);let t=[],a=[],s=0;try{for(let n=0;n<X.length;n+=1){let r=eB(X[n],n,e),l=eW(r);if(!l.valid){t.push(n);continue}try{let e=l.payload;await z({date:e.date,title:e.title,ticker:e.ticker,direction:e.direction,optionType:e.optionType,entryPrice:e.entryPrice,exitPrice:e.exitPrice,outcome:e.outcome,pnl:e.pnl,notes:e.notes||"â",emotions:e.emotions,lessonsLearned:e.lessonsLearned,plannedRisk:e.plannedRisk,followedRules:e.followedRules,entryAt:e.entryAt,exitAt:e.exitAt,tradeType:e.tradeType,strategy:e.strategy,tags:e.tags,emotionalStateScore:e.emotionalStateScore,positionSize:e.positionSize,description:e.description}),s+=1}catch(e){a.push(n)}}let n=[...t,...a].sort((e,t)=>e-t);if(s>0&&window.dispatchEvent(new CustomEvent("trades:updated")),n.length>0){let r=new Map,l=n.map((e,t)=>(r.set(e,t),X[e])),i=new Map;e.forEach((e,t)=>{let a=r.get(t);null!=a&&i.set(a,e)}),Q(l),er(i),et(0),eO(l[0],0,i);let o=[];s>0&&o.push("Saved ".concat(s," trade").concat(1===s?"":"s",".")),t.length>0&&o.push("".concat(t.length," need required fields.")),a.length>0&&o.push("".concat(a.length," failed to save.")),j.o.warning(o.join(" "))}else eU("Saved ".concat(s," trades."))}finally{ec(!1),ei(!1)}},e$=async e=>{e.preventDefault();let t=!!(null==E?void 0:E.id);if(!t&&ea&&X.length>1&&!ed)return void ei(!0);let a=eW(q);if(!a.valid){G(a.error),eu(!1);return}K(!0),G(null),Z(!1),eu(!1);try{let e=a.payload;if(t?await W({tradeId:E.id,date:e.date,title:e.title,ticker:e.ticker,direction:e.direction,optionType:e.optionType,entryPrice:e.entryPrice,exitPrice:e.exitPrice,outcome:e.outcome,pnl:e.pnl,notes:e.notes||"â",emotions:e.emotions,lessonsLearned:e.lessonsLearned,plannedRisk:e.plannedRisk,followedRules:e.followedRules,entryAt:e.entryAt,exitAt:e.exitAt,tradeType:e.tradeType,strategy:e.strategy,tags:e.tags,emotionalStateScore:e.emotionalStateScore,positionSize:e.positionSize,description:e.description}):await z({date:e.date,title:e.title,ticker:e.ticker,direction:e.direction,optionType:e.optionType,entryPrice:e.entryPrice,exitPrice:e.exitPrice,outcome:e.outcome,pnl:e.pnl,notes:e.notes||"â",emotions:e.emotions,lessonsLearned:e.lessonsLearned,plannedRisk:e.plannedRisk,followedRules:e.followedRules,entryAt:e.entryAt,exitAt:e.exitAt,tradeType:e.tradeType,strategy:e.strategy,tags:e.tags,emotionalStateScore:e.emotionalStateScore,positionSize:e.positionSize,description:e.description}),Z(!0),!t&&X.length>0){let e=X.filter((e,t)=>t!==ee),t=new Map;if(en.forEach((e,a)=>{a<ee&&t.set(a,e),a>ee&&t.set(a-1,e)}),er(t),e.length>0){let a=Math.min(ee,e.length-1);Q(e),et(a),eO(e[a],a,t),Z(!1);return}}eU(t?"Trade updated!":"Trade saved! View it on your dashboard.")}catch(e){G(e instanceof Error?e.message:"Failed to save trade")}finally{K(!1)}},eV={ticker:!(null==(t=q.ticker)?void 0:t.trim()),entryPrice:null==q.entryPrice||!Number.isFinite(q.entryPrice)||q.entryPrice<=0,exitPrice:null==q.exitPrice||!Number.isFinite(q.exitPrice)||q.exitPrice<=0,optionType:"call"!==q.optionType&&"put"!==q.optionType,entryAt
1:!q.entryAt,exitAt:!q.exitAt},eH=Object.values(eV).some(Boolean),eK=function(e,t,a,s){if("number"==typeof e&&Number.isFinite(e)&&"number"==typeof t&&Number.isFinite(t)&&("call"===a||"put"===a))return(t-e)*("number"==typeof s&&Number.isFinite(s)&&s>0?s:1)}(q.entryPrice,q.exitPrice,q.optionType,q.positionSize);return console.log("Form validation details:",{"formData.ticker":q.ticker,"formData.entryPrice":q.entryPrice,"formData.exitPrice":q.exitPrice,"formData.optionType":q.optionType,"formData.entryAt":q.entryAt,"formData.exitAt":q.exitAt,requiredMissing:eV,hasMissingRequired:eH,"entryAt type":typeof q.entryAt,"exitAt type":typeof q.exitAt}),(0,s.jsx)("div",{className:(0,l.cn)("flex-1 flex flex-col min-h-0 bg-[#f7f7f7] dark:bg-background",L&&"mtp-log-trade--embedded","mtp-log-trade"),children:(0,s.jsxs)("div",{className:(0,l.cn)("flex-1 flex flex-col lg:flex-row max-w-[1200px] mx-auto w-full py-4 px-4 sm:py-6 sm:px-6 lg:py-8 lg:px-6 gap-4 lg:gap-8",L&&"mtp-log-trade__layout--embedded","mtp-log-trade__layout"),children:[P?null:(0,s.jsxs)("div",{className:"mtp-log-trade__mobile-tabs lg:hidden flex rounded-lg border border-border bg-white dark:bg-card p-1.5 gap-1",children:[(0,s.jsxs)("button",{onClick:()=>O("broker"),className:"mtp-log-trade__mode-btn flex-1 flex items-center justify-center gap-1.5 py-2.5 px-3 rounded-md text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 min-h-[44px] ".concat("broker"===B?"mtp-log-trade__mode-btn--active bg-[var(--orange)] text-[var(--orange-foreground)]":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),children:[(0,s.jsx)(o.A,{className:"h-4 w-4 shrink-0"}),"Broker"]}),(0,s.jsxs)("button",{onClick:()=>O("file"),className:"mtp-log-trade__mode-btn flex-1 flex items-center justify-center gap-1.5 py-2.5 px-3 rounded-md text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 min-h-[44px] ".concat("file"===B?"mtp-log-trade__mode-btn--active bg-[var(--orange)] text-[var(--orange-foreground)]":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),children:[(0,s.jsx)(c.A,{className:"h-4 w-4 shrink-0"}),"File"]}),(0,s.jsxs)("button",{onClick:()=>O("manual"),className:"mtp-log-trade__mode-btn flex-1 flex items-center justify-center gap-1.5 py-2.5 px-3 rounded-md text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 min-h-[44px] ".concat("manual"===B?"mtp-log-trade__mode-btn--active bg-[var(--orange)] text-[var(--orange-foreground)]":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),children:[(0,s.jsx)(d.A,{className:"h-4 w-4 shrink-0"}),"Manual"]})]}),P?null:(0,s.jsx)("aside",{className:"mtp-log-trade__rail hidden lg:block w-[240px] shrink-0",children:(0,s.jsxs)("div",{className:"bg-white dark:bg-card border border-border rounded-lg",children:[(0,s.jsx)("h2",{className:"mtp-log-trade__rail-title text-lg font-bold text-foreground px-6 py-4 border-b border-border",children:"Log a Trade"}),(0,s.jsxs)("nav",{className:"mtp-log-trade__rail-nav p-2",children:[(0,s.jsxs)("button",{onClick:()=>O("broker"),className:"mtp-log-trade__rail-btn relative w-full flex items-center gap-2 px-2 py-3 rounded-lg text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ".concat("broker"===B?"mtp-log-trade__rail-btn--active bg-muted/80 text-foreground":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),children:[(0,s.jsx)(o.A,{className:"h-5 w-5"}),"Broker","broker"===B&&(0,s.jsx)("div",{className:"absolute left-0 top-0 bottom-0 w-1 bg-[var(--orange)] rounded-r"})]}),(0,s.jsxs)("button",{onClick:()=>O("file"),className:"mtp-log-trade__rail-btn relative w-full flex items-center gap-2 px-2 py-3 rounded-lg text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ".concat("file"===B?"mtp-log-trade__rail-btn--active bg-muted/80 text-foreground":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),children:[(0,s.jsx)(c.A,{className:"h-5 w-5"}),"File","file"===B&&(0,s.jsx)("div",{className:"absolute left-0 top-0 bottom-0 w-1 bg-[var(--orange)] rounded-r"})]}),(0,s.jsxs)("button",{onClick:()=>O("manual"),className:"mtp-log-trade__rail-btn relative w-full flex items-center gap-2 px-2 py-3 rounded-lg text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ".concat("manual"===B?"mtp-log-trade__rail-btn--active bg-muted/80 text-foreground":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),children:[(0,s.jsx)(d.A,{className:"h-5 w-5"}),"Manual","manual"===B&&(0,s.jsx)("div",{className:"absolute left-0 top-0 bottom-0 w-1 bg-[var(--orange)] rounded-r"})]})]}),(0,s.jsx)("p",{className:"mtp-log-trade__rail-note",children:"Choose how you want to add trades."})]})}),(0,s.jsxs)("main",{className:"flex-1 min-w-0",children:["manual"===B&&(0,s.jsxs)("div",{className:"mtp-log-trade__panel mtp-log-trade__panel--manual bg-white dark:bg-card border border-border rounded-lg p-4 sm:p-6 lg:p-8",children:[(0,s.jsxs)("form",{ref:V,onSubmit:e$,className:"space-y-6",children:[(0,s.jsxs)("div",{className:"mtp-log-trade__panel-head",children:[(0,s.jsxs)("div",{className:"mtp-log-trade__panel-head-copy",children:[(0,s.jsx)("span",{className:"mtp-log-trade__panel-kicker",children:"Trade Entry"}),(0,s.jsx)("h1",{className:"text-2xl font-bold text-foreground",children:"Manual Entry"}),(0,s.jsx)("p",{className:"mtp-log-trade__panel-subtitle",children:"Type one trade by hand."})]}),(0,s.jsx)("span",{className:"mtp-log-trade__panel-status",children:"Manual"})]}),(0,s.jsx)("div",{className:"mb-2 flex flex-col gap-3 sm:mb-4 sm:flex-row sm:items-center sm:justify-between",children:(0,s.jsxs)("div",{className:"flex flex-col-reverse gap-3 sm:flex-row sm:justify-end",children:[(0,s.jsx)("button",{type:"button",onClick:()=>{$(k()),es(!1),Q([]),G(null)},disabled:H,className:"min-h-[44px] px-6 py-2.5 rounded-lg border border-input text-foreground text-sm font-medium hover:bg-muted/50 transition-colors disabled:opacity-50 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:"Clear Form"}),(0,s.jsxs)("button",{type:"submit",disabled:H||eH,className:"min-h-[44px] px-6 py-2.5 rounded-lg bg-[var(--orange)] text-[var(--orange-foreground)] text-sm font-semibold hover:opacity-90 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:[H&&(0,s.jsx)(u.A,{className:"h-4 w-4 animate-spin"}),H?"Saving...":"Save Trade"]})]})}),ea&&X.length>0&&(0,s.jsx)("div",{className:"mb-6 p-4 bg-blue-50 dark:bg-blue-950/20 border border-blue-200 dark:border-blue-800 rounded-lg",children:(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(c.A,{className:"h-4 w-4 text-blue-600 shrink-0"}),(0,s.jsx)("span",{className:"text-sm font-medium text-blue-900 dark:text-blue-100",children:"Auto-filled from ledger analysis"})]}
1),(0,s.jsxs)("div",{className:"flex items-center gap-2 self-stretch sm:self-auto",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>{if(ee>0){let e=new Map(en);e.set(ee,q),er(e);let t=ee-1;et(t),eO(X[t],t)}},disabled:0===ee,className:"min-h-[44px] flex-1 sm:flex-initial px-3 py-2 text-sm rounded-md border border-blue-300 dark:border-blue-700 text-blue-700 dark:text-blue-300 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-blue-100 dark:hover:bg-blue-900/30 transition-colors flex items-center justify-center gap-1 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:[(0,s.jsx)(m.A,{className:"h-4 w-4"}),"Prev"]}),(0,s.jsxs)("span",{className:"text-sm text-blue-700 dark:text-blue-300 font-medium tabular-nums flex items-center justify-center px-2",children:["Trade ",ee+1," of ",X.length]}),(0,s.jsxs)("button",{type:"button",onClick:()=>{if(ee<X.length-1){let e=new Map(en);e.set(ee,q),er(e);let t=ee+1;et(t),eO(X[t],t)}},disabled:ee>=X.length-1,className:"min-h-[44px] flex-1 sm:flex-initial px-3 py-2 text-sm rounded-md border border-blue-300 dark:border-blue-700 text-blue-700 dark:text-blue-300 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-blue-100 dark:hover:bg-blue-900/30 transition-colors flex items-center justify-center gap-1 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:["Next",(0,s.jsx)(p.A,{className:"h-4 w-4"})]})]})]})}),Y&&(0,s.jsx)("div",{className:"mb-6 p-4 bg-green-50 dark:bg-green-950/20 border border-green-200 dark:border-green-800 rounded-lg text-sm text-green-900 dark:text-green-100",children:"Trade saved successfully!"}),J&&(0,s.jsx)("div",{className:"mb-6 p-4 bg-destructive/10 border border-destructive/30 rounded-lg text-sm text-destructive",children:J}),(0,s.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 sm:gap-6",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Ticker Symbol"}),(0,s.jsx)("input",{type:"text",required:!0,placeholder:"e.g. AAPL",value:q.ticker||"",onChange:e=>$({...q,ticker:e.target.value.toUpperCase()}),className:"w-full px-3 py-2 rounded-md border border-input bg-background text-foreground text-sm focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 min-h-[44px]"}),eV.ticker&&(0,s.jsx)("p",{className:"mt-1 text-xs text-destructive",children:"Missing required for save"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Option Type"}),(0,s.jsxs)("select",{required:!0,value:q.optionType||"",onChange:e=>$({...q,optionType:e.target.value}),className:"w-full px-3 py-2 rounded-md border border-input bg-background text-foreground text-sm focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 min-h-[44px]",children:[(0,s.jsx)("option",{value:"",children:"Select Call or Put"}),(0,s.jsx)("option",{value:"call",children:"Call"}),(0,s.jsx)("option",{value:"put",children:"Put"})]}),eV.optionType&&(0,s.jsx)("p",{className:"mt-1 text-xs text-destructive",children:"Missing required for save"})]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4 sm:gap-6",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Entry Price"}),(0,s.jsx)("input",{type:"number",required:!0,step:"0.01",min:"0.01",placeholder:"0.00",value:null!=(a=q.entryPrice)?a:"",onChange:e=>$({...q,entryPrice:e.target.value?parseFloat(e.target.value):void 0}),className:"w-full px-3 py-2 rounded-md border border-input bg-background text-foreground text-sm focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 min-h-[44px]"}),eV.entryPrice&&(0,s.jsx)("p",{className:"mt-1 text-xs text-destructive",children:"Missing required for save"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Sell Price"}),(0,s.jsx)("input",{type:"number",required:!0,step:"0.01",min:"0.01",placeholder:"0.00",value:null!=(S=q.exitPrice)?S:"",onCh
1ange:e=>$({...q,exitPrice:e.target.value?parseFloat(e.target.value):void 0}),className:"w-full px-3 py-2 rounded-md border border-input bg-background text-foreground text-sm focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 min-h-[44px]"}),eV.exitPrice&&(0,s.jsx)("p",{className:"mt-1 text-xs text-destructive",children:"Missing required for save"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Contracts"}),(0,s.jsx)("input",{type:"number",step:"1",min:"1",placeholder:"1",value:null!=(T=q.positionSize)?T:"",onChange:e=>$({...q,positionSize:e.target.value?parseFloat(e.target.value):void 0}),className:"w-full px-3 py-2 rounded-md border border-input bg-background text-foreground text-sm focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 min-h-[44px]"}),(0,s.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"If left blank, defaults to 1."})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:"P&L ($)"}),(0,s.jsx)("input",{type:"text",value:"number"==typeof eK&&Number.isFinite(eK)?0===eK?"$0.00":"".concat(eK>0?"+":"-","$").concat(Math.abs(eK).toFixed(2)):"â",readOnly:!0,tabIndex:-1,"aria-readonly":"true",className:"w-full px-3 py-2 rounded-md border border-input bg-muted/40 text-foreground text-sm cursor-not-allowed min-h-[44px]"}),(0,s.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Calculated automatically from entry, sell, and contract quantity."})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 sm:gap-6",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Time of Entry"}),(0,s.jsx)("input",{type:"datetime-local",required:!0,value:q.entryAt||"",onChange:e=>$({...q,entryAt:e.target.value}),className:"w-full px-3 py-2 rounded-md border border-input bg-background text-foreground text-sm focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 min-h-[44px]"}),eV.entryAt&&(0,s.jsx)("p",{className:"mt-1 text-xs text-destructive",children:"Missing required for save"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Time of Exit"}),(0,s.jsx)("input",{type:"datetime-local",required:!0,value:q.exitAt||"",onChange:e=>$({...q,exitAt:e.target.value}),className:"w-full px-3 py-2 rounded-md border border-input bg-background text-foreground text-sm focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 min-h-[44px]"}),eV.exitAt&&(0,s.jsx)("p",{className:"mt-1 text-xs text-destructive",children:"Missing required for save"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Comment"}),(0,s.jsx)("textarea",{value:q.notes||"",onChange:e=>$({...q,notes:e.target.value}),placeholder:"Add context about why you took this trade...",className:"w-full px-3 py-2 rounded-md border border-input bg-background text-foreground text-sm focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 min-h-[100px] resize-y"})]}),eH&&ea&&(0,s.jsx)("div",{className:"rounded-lg border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-800 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-300",children:"This imported trade is missing required fields. Fill all six fields to save."})]}),(0,s.jsx)(f.lG,{open:el,onOpenChange:e=>!eo&&ei(e),children:(0,s.jsxs)(f.Cf,{className:"p-6",children:[(0,s.jsxs)(f.c7,{children:[(0,s.jsx)(f.L3,{children:"Save all uploaded trades?"}),(0,s.jsx)(f.rr,{children:"Save all valid trades in this batch right now. Trades missing required fields will be skipped and left for you to edit."})]}),(0,s.jsxs)(f.Es,{className:"gap-2 pt-2",children:[(0,s.jsx)(g.$,{type:"button",variant:"outline",onClick:()=>ei(!1),disabled:eo,className:"min-h-[44px]",children:"Cancel"}),(0,s.jsx)(g.$,{type:"button",variant:"outline",disabled:eo,className:"min-h-[44px]",onClick:()=>{ei(!1),eu(!0),queueMicrotask(()=>{var e;return null==(e=V.current)?void 0:e.requestSubmit()})},children:"Save this trade only"}),(0,s.jsxs)(g.$,{type:"button",disabled:eo,className:"min-h-[44px]",onClick:eq,children:[eo?(0,s.jsx)(u.A,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save all"]})]})]})})]}),"file"===B&&(0,s.jsxs)("div",{className:"mtp-log-trade__panel mtp-log-trade__panel--file bg-white dark:bg-card border border-border rounded-lg p-4 sm:p-6 lg:p-8",children:[(0,s.jsxs)("div",{className:"mtp-log-trade__panel-head",children:[(0,s.jsxs)("div",{className:"mtp-log-trade__panel-head-copy",children:[(0,s.jsx)("span",{className:"mtp-log-trade__panel-kicker",children:"File Import"}),(0,s.jsx)("h1",{className:"text-2xl font-bold text-foreground",children:"Upload Trade File"}),(0,s.jsx)("p",{className:"mtp-log-trade__panel-subtitle",children:"Upload a file to pull trade data."})]}),(0,s.jsx)("span",{className:"mtp-log-trade__panel-status",children:"File"})]}),!eb&&(0,s.jsxs)("section",{className:"space-y-4",children:[(0,s.jsx)("div",{role:"button",tabIndex:0,onDragOver:e=>{e.preventDefault(),eN(!0)},onDragLeave:e=>{e.preventDefault(),eN(!1)},onDrop:e=>{e.preventDefault(),eN(!1);let t=e.dataTransfer.files[0];t&&eD(t)},onKeyDown:e=>{if("Enter"===e.key||" "===e.key){var t;e.preventDefault(),null==(t=ek.current)||t.click()}},className:"mtp-log-trade__dropzone\n border-2 border-dashed rounded-lg p-6 sm:p-10 lg:p-12 text-center transition-colors cursor-pointer focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2\n ".concat(ey?"border-[var(--orange)]/50 bg-muted/50":"border-border hover:border-[var(--orange)]/50","\n "),children:em?(0,s.jsxs)("div",{className:"space-y-6 max-w-md mx-auto",children:[ex&&(0,s.jsx)("div",{className:"rounded-md border border-border overflow-hidden bg-muted/30",children:(0,s.jsx)("img",{src:ex,alt:"Trade ledger preview",className:"w-full h-auto max-h-64 object-contain"})}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("p",{className:"text-foreground font-medium truncate px-4",children:em.name}),(0,s.jsxs)("p",{className:"text-sm text-muted-foreground",children:[(em.size/1024/1024).toFixed(2)," MB"]})]}),(0,s.jsxs)("div",{className:"flex flex-col-reverse sm:flex-row gap-3 justify-center",children:[(0,s.jsx)("button",{type:"button",onClick:eR,disabled:eg,className:"min-h-[44px] px-6 py-2.5 rounded-lg border border-input text-foreground text-sm font-medium hover:bg-muted/50 transition-colors disabled:opacity-50 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:"Cancel"}),(0,s.jsx)("button",{type:"button",onClick:eP,disabled:eg,className:"min-h-[44px] px-6 py-2.5 rounded-lg bg-[var(--orange)] text-[var(--orange-foreground)] text-sm font-semibold hover:opacity-90 transition-opacity disabled:opacity-50 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 flex items-center justify-center gap-2",children:eg?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(u.A,{className:"h-4 w-4 animate-spin"}),"Reading..."]}):"Read File"})]})]}):(0,s.jsxs)("div",{className:"space-y-5",children:[(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)("div",{className:"rounded-full bg-muted p-5",children:(0,s.jsx)(c.A,{className:"h-9 w-9 text-muted-foreground"})})}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("p",{className:"text-base font-medium text-foreground",children:"Drop your file here"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"or click to upload. PNG, JPEG, PDF, CSV, XLSX. Max 10MB."})]}),(0,s.jsx)("input",{ref:ek,type:"file",accept:"image/png,image/jpeg,image/jpg,application/pdf,text/csv,.csv,.xls,.xlsx,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",onChange:e=>{var t;let a=null==(t=e.target.files)?void 0:t[0];a&&eD(a)},className:"hidden"}),(0,s.jsx)("button",{type:"button",onClick:()=>{var e;return null==(e=ek.current)?void 0:e.click()},className:"min-h-[44px] px-6 py-2.5 rounded-lg bg-[var(--orange)] text-[var(--orange-foreground)] text-sm font-semibold hover:opacity-90 transition-opacity focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:"Select File"})]})}),e_&&(0,s.jsx)("div",{className:"p-4 bg-destructive/10 border border-destructive/30 rounded-xl text-sm text-destructive",children:e_}),eg&&(0,s.jsxs)("div",{role:"status","aria-live":"polite",className:"rounded-xl border border-border bg-muted/40 p-4",children:[(0,s.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Reading file"}),(0,s.jsx)(u.A,{className:"h-4 w-4 animate-spin text-muted-foreground","aria-hidden":"true"})]}),(0,s.jsx)("div",{className:"h-2 w-full overflow-hidden rounded-full bg-muted",children:(0,s.jsx)("div",{className:"animate-progress-slide h-full w-1/3 rounded-full bg-[var(--orange)]"})})]})]}),eb&&(0,s.jsxs)("section",{className:"space-y-6",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[ex&&(0,s.jsx)("div",{className:"w-16 h-16 sm:w-20 sm:h-20 rounded-xl border border-border overflow-hidden bg-muted/30 shrink-0",children:(0,s.jsx)("img",{src:ex,alt:"",className:"w-full h-full object-cover"})}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"File Results"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground mt-0.5",children:new Date(eb.timestamp).toLocaleStr
1ing(void 0,{dateStyle:"medium",timeStyle:"short"})})]})]}),(0,s.jsx)("button",{type:"button",onClick:eR,className:"min-h-[44px] w-full sm:w-auto px-6 py-2.5 rounded-lg border border-input text-foreground text-sm font-medium hover:bg-muted/50 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:"New Analysis"})]}),(0,s.jsxs)("div",{className:"bg-muted/30 rounded-xl p-6",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-muted-foreground text-center mb-3",children:"Trade Score"}),(0,s.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,s.jsxs)("div",{className:"flex items-baseline gap-1",children:[(0,s.jsx)("span",{className:"text-4xl font-bold tabular-nums text-foreground",children:eb.overallScore.toFixed(1)}),(0,s.jsx)("span",{className:"text-xl text-muted-foreground font-medium",children:"/10"})]}),(0,s.jsx)("div",{className:"w-full max-w-xs bg-muted rounded-full h-2.5 overflow-hidden",children:(0,s.jsx)("div",{className:"h-full bg-[var(--orange)] rounded-full transition-all duration-300",style:{width:"".concat(Math.min(100,eb.overallScore/10*100),"%")}})})]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,s.jsxs)("div",{className:"bg-muted/30 rounded-xl p-5",children:[(0,s.jsx)("p",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground mb-2",children:"Win Rate"}),(0,s.jsxs)("p",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[eb.metrics.winRate.toFixed(1),"%"]})]}),(0,s.jsxs)("div",{className:"bg-muted/30 rounded-xl p-5",children:[(0,s.jsx)("p",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground mb-2",children:"Avg R"}),(0,s.jsxs)("p",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[eb.metrics.avgRMultiple.toFixed(2),"R"]})]}),(0,s.jsxs)("div",{className:"bg-muted/30 rounded-xl p-5",children:[(0,s.jsx)("p",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground mb-2",children:"Risk"}),(0,s.jsxs)("p",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[eb.metrics.riskScore.toFixed(1),(0,s.jsx)("span",{className:"text-base font-normal text-muted-foreground",children:"/10"})]})]}),(0,s.jsxs)("div",{className:"bg-muted/30 rounded-xl p-5",children:[(0,s.jsx)("p",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground mb-2",children:"Consistency"}),(0,s.jsxs)("p",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[eb.metrics.consistencyScore.toFixed(1),(0,s.jsx)("span",{className:"text-base font-normal text-muted-foreground",children:"/10"})]})]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-6",children:[(0,s.jsxs)("div",{className:"bg-muted/30 rounded-xl p-6",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,s.jsx)("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-gain/15",children:(0,s.jsx)(x.A,{className:"h-5 w-5 text-gain"})}),(0,s.jsx)("h3",{className:"text-base font-semibold text-foreground",children:"What Went Well"})]}),eb.strengths.length>0?(0,s.jsx)("ul",{className:"space-y-3",children:eb.strengths.map((e,t)=>(0,s.jsxs)("li",{className:"text-sm text-foreground flex items-start gap-3",children:[(0,s.jsx)("span",{className:"text-gain mt-0.5 shrink-0",children:"â"}),(0,s.jsx)("span",{className:"leading-relaxed",children:e})]},t))}):(0,s.jsx)("p",{className:"text-sm text-muted-foreground italic",children:"No strengths identified."})]}),(0,s.jsxs)("div",{className:"bg-muted/30 rounded-xl p-6",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,s.jsx)("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-loss/15",children:(0,s.jsx)(h.A,{className:"h-5 w-5 text-loss"})}),(0,s.jsx)("h3",{className:"text-base font-semibold text-foreground",children:"What To Fix"})]}),eb.improvements.length>0?(0,s.jsx)("ul",{className:"space-y-3",children:eb.improvements.map((e,t)=>(0,s.jsxs)("li",{className:"text-sm text-foreground flex items-start gap-3",children:[(0,s.jsx)("span",{className:"text-loss mt-0.5 shrink-0",children:"â¢"}),(0,s.jsx)("span",{className:"leading-relaxed",children:e})]},t))}):(0,s.jsx)("p",{className:"text-sm text-muted-foreground italic",children:"No areas identified."})]})]}),(0,s.jsxs)("div",{className:"bg-muted/30 rounded-xl p-6",children:[(0,s.jsx)("h3",{className:"text-base font-semibold text-foreground mb-4",children:"Next Steps"}),eb.recommendations.length>0?(0,s.jsx)("ol",{className:"space-y-3 list-none pl-0",children:eb.recommendations.map((e,t)=>(0,s.jsxs)("li",{className:"text-sm text-foreground flex gap-4",children:[(0,s.jsx)("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground font-semibold text-xs tabular-nums",children:t+1}),(0,s.jsx)("span",{className:"leading-relaxed pt-0.5",children:e})]},t))}):(0,s.jsx)("p",{className:"text-sm text-muted-foreground italic",children:"No recommendations."})]}),eb.trades&&eb.trades.length>0&&(0,s.jsxs)("div",{className:"bg-muted/30 rounded-xl overflow-hidden",children:[(0,s.jsx)("div",{className:"px-6 py-4 border-b border-border",children:(0,s.jsx)("h3",{className:"text-base font-semibold text-foreground",children:"Extracted Trades"})}),(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full text-sm",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{className:"bg-muted/80 border-b border-border",children:[(0,s.jsx)("th",{className:"text-left py-3 px-4 text-muted-foreground font-medium",children:"Date"}),(0,s.jsx)("th",{className:"text-left py-3 px-4 text-muted-foreground font-medium",children:"Symbol"}),(0,s.jsx)("th",{className:"text-right py-3 px-4 text-muted-foreground font-medium",children:"Entry"}),(0,s.jsx)("th",{className:"text-right py-3 px-4 text-muted-foreground font-medium",children:"Exit"}),(0,s.jsx)("th",{className:"text-right py-3 px-4 text-muted-foreground font-medium",children:"P&L ($)"}),null!=eb.trades[0].rMultiple&&(0,s.jsx)("th",{className:"text-right py-3 px-4 text-muted-foreground font-medium",children:"R"})]})}),(0,s.jsx)("tbody",{children:eb.trades.map((e,t)=>(0,s.jsxs)("tr",{className:"border-b border-border last:border-0 hover:bg-muted/30 transition-colors",children:[(0,s.jsx)("td",{className:"py-3 px-4 text-foreground",children:e.date}),(0,s.jsx)("td",{className:"py-3 px-4 font-medium text-foreground",children:e.symbol}),(0,s.jsxs)("td",{className:"py-3 px-4 text-right tabular-nums text-foreground",children:["$",e.entry.toFixed(2)]}),(0,s.jsxs)("td",{className:"py-3 px-4 text-right tabular-nums text-foreground",children:["$",e.exit.toFixed(2)]}),(0,s.jsxs)("td",{className:"py-3 px-4 text-right font-medium tabular-nums ".concat(e.pnl>=0?"text-gain":"text-loss"),children:[e.pnl>=0?"+":"","$",e.pnl.toFixed(2)]}),null!=e.rMultiple&&(0,s.jsxs)("td",{className:"py-3 px-4 text-right tabular-nums ".concat(e.rMultiple>=0?"text-gain":"text-loss"),children:[e.rMultiple.toFixed(2),"R"]})]},t))})]})})]})]})]}),"broker"===B&&(0,s.jsxs)("div",{className:"mtp-log-trade__panel mtp-log-trade__panel--broker bg-white dark:bg-card border border-border rounded-lg p-4 sm:p-6 lg:p-8",children:[(0,s.jsxs)("div",{className:"mtp-log-trade__panel-head",children:[(0,s.jsxs)("div",{className:"mtp-log-trade__panel-head-copy",children:[(0,s.jsx)("span",{className:"mtp-log-trade__panel-kicker",children:"Broker Sync"}),(0,s.jsx)("h1",{className:"text-2xl font-bold text-foreground",children:"Connect Broker"}),(0,s.jsx)("p",{className:"mtp-log-trade__panel-subtitle",children:"Link your broker to sync trades. Use Schwab for thinkorswim."})]}),(0,s.jsx)("span",{className:"mtp-log-trade__panel-status",children:"Broker"})]}),!U&&(0,y.f)()?(0,s.jsx)("p",{className:"text-xs text-muted-foreground mb-4",children:"Pro plan required for broker connections."}):null,eS?(0,s.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,s.jsx)(u.A,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,s.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 ga
1p-4 sm:gap-6",children:ew.map(e=>(()=>{var t;let a=null==(t=e.slug)?void 0:t.trim().toUpperCase().replace(/[\s-]+/g,"_");return(0,s.jsxs)("div",{className:"mtp-log-trade__broker-card flex flex-col items-center gap-3 p-4 rounded-xl border border-border bg-muted/20",children:[(0,s.jsx)("div",{className:"mtp-log-trade__broker-logo w-16 h-16 rounded-lg bg-white dark:bg-muted flex items-center justify-center overflow-hidden shrink-0",children:e.aws_s3_square_logo_url?(0,s.jsx)(i.default,{src:e.aws_s3_square_logo_url,alt:e.display_name,width:64,height:64,className:"object-contain w-12 h-12"}):(0,s.jsx)(o.A,{className:"h-8 w-8 text-muted-foreground"})}),(0,s.jsx)("span",{className:"text-sm font-medium text-foreground text-center line-clamp-1",children:"SCHWAB"===a?"Shwab":e.display_name}),(0,s.jsx)("button",{type:"button",disabled:e.maintenance_mode||eC===e.slug,className:"w-full min-h-[44px] px-4 py-2.5 rounded-lg border border-border bg-white dark:bg-card text-foreground font-semibold text-sm whitespace-nowrap transition-all duration-200 hover:bg-muted/50 hover:scale-[1.02] active:scale-[0.98] disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:scale-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",onClick:()=>eE(e.slug),children:e.maintenance_mode?"Maintenance":eC===e.slug?(0,s.jsxs)("span",{className:"flex items-center justify-center gap-2",children:[(0,s.jsx)(u.A,{className:"h-4 w-4 animate-spin"}),"Connecting..."]}):"Get Started"})]},e.id)})())}),!eS&&0===ew.length&&(0,s.jsx)("p",{className:"text-sm text-muted-foreground py-8 text-center",children:"No brokerages available at the moment. Please try again later."})]})]})]})})}function T(e){let{id:t,name:a,type:n,description:r,iconUrl:i,iconNode:o,comingSoon:c=!1,connected:d=!1,actionLabel:u,disabled:m=!1,onConnect:p,onCardClick:x,className:h}=e,g=c||m,f=null!=u?u:c?"Coming soon":d?"Manage":"Connect",b=/\bschwab\b/i.test(a);return(0,s.jsxs)("article",{className:(0,l.cn)("avail-card",d&&"avail-card--connected",c&&"avail-card--coming-soon",x&&!g&&"avail-card--interactive",h),"aria-label":"".concat(a," - ").concat(n).concat(c?" (Coming Soon)":""),onClick:()=>{!g&&x&&x()},children:[(0,s.jsx)("div",{className:"avail-card__icon-wrap",children:null!=o?o:i?(0,s.jsx)("img",{src:i,alt:"".concat(a," logo"),className:"avail-card__icon-img",width:44,height:44,loading:"telegram"===t?"eager":"lazy"}):null}),(0,s.jsxs)("div",{className:"avail-card__identity",children:[(0,s.jsx)("div",{className:"avail-card__identity-row",children:(0,s.jsxs)("span",{className:"avail-card__name",children:[a,b?(0,s.jsx)("em",{className:"avail-card__name-suffix",children:" (thinkorswim)"}):null]})}),r&&(0,s.jsx)("span",{className:"avail-card__description",children:r})]}),(0,s.jsx)("div",{className:"avail-card__cta",children:(0,s.jsx)("button",{className:(0,l.cn)("avail-card__connect-btn",d&&"avail-card__connect-btn--connected"),onClick:e=>{e.stopPropagation(),!g&&p&&p()},"aria-label":"".concat(f," ").concat(a),disabled:g||!p,children:f})})]})}var C=a(55275);function M(e){let{onConnectBroker:t,className:a}=e;return(0,s.jsxs)("div",{className:(0,l.cn)("connections-empty",a),role:"status","aria-label":"No broker connections",children:[(0,s.jsx)("div",{className:"connections-empty__icon-wrap","aria-hidden":"true",children:(0,s.jsx)(C.A,{size:48,strokeWidth:1.2})}),(0,s.jsx)("h2",{className:"connections-empty__title",children:"No broker access yet"}),(0,s.jsx)("p",{className:"connections-empty__description",children:"Connect your broker so Coach can review real account activity."}),t&&(0,s.jsx)("button",{className:"connections-empty__cta",onClick:t,"aria-label":"Connect your broker",children:"Connect broker"})]})}var E=a(86651);function D(e){let{search:t,activeTab:a,onSearchChange:n,onTabChange:r,tabs:i=["All","Brokers","Channels","Data"],className:o,trailingActions:c}=e;return(0,s.jsxs)("div",{className:(0,l.cn)("integration-filters",o),children:[(0,s.jsxs)("div",{className:"integration-filters__search-wrap",children:[(0,s.jsx)(E.A,{className:"integration-filters__search-icon",size:15,"aria-hidden":"true"}),(0,s.jsx)("input",{type:"search",className:"integration-filters__search",placeholder:"Search broker access",value:t,onChange:e=>n(e.target.value),"aria-label":"Search broker access options"})]}),(0,s.jsxs)("div",{className:"integration-filters__tab-row",children:[(0,s.jsx)("div",{className:"integration-filters__tabs",role:"tablist","aria-label":"Broker access categories",children:i.map(e=>(0,s.jsx)("button",{className:(0,l.cn)("integration-filters__tab",e===a&&"integration-filters__tab--active"),role:"tab","aria-selected":e===a,onClick:()=>r(e),children:e},e))}),c?(0,s.jsx)("div",{className:"integration-filters__actions","aria-label":"Journal entry actions",children:c}):null]})]})}var P=a(65229),R=a(5917),L=a(93499),I=a(80021),F=a(861);function z(e){let{open:t,integration:a,onOpenChange:n,onContinue:r}=e;if(!a)return null;let l=a.websiteUrl,i=a.supportUrl?a.supportUrl:"Broker"===a.category?"https://snaptrade.com/support":void 0;return(0,s.jsx)(f.lG,{open:t,onOpenChange:n,children:(0,s.jsxs)(f.Cf,{className:"connections-detail-modal","aria-describedby":void 0,children:[(0,s.jsx)(F.s,{children:(0,s.jsx)(f.L3,{children:a.name})}),(0,s.jsx)("button",{type:"button",className:"connections-detail-modal__close",onClick:()=>n(!1),"aria-label":"Close broker details",children:(0,s.jsx)(P.A,{size:22})}),(0,s.jsxs)("header",{className:"connections-detail-modal__header",children:[(0,s.jsxs)("div",{className:"connections-detail-modal__identity",children:[(0,s.jsx)("div",{className:"connections-detail-modal__icon-wrap",children:a.iconUrl?(0,s.jsx)("img",{src:a.iconUrl,alt:"".concat(a.name," logo"),className:"connections-detail-modal__icon-img",width:56,height:56}):null}),(0,s.jsxs)("div",{className:"connections-detail-modal__title-wrap",children:[(0,s.jsx)("h2",{className:"connections-detail-modal__title",children:a.name}),a.description?(0,s.jsx)("p",{className:"connections-detail-modal__description",children:a.description}):null]})]}),(0,s.jsx)("button",{type:"button",className:"connections-detail-modal__primary",onClick:r,children:"Connect broker"})]}),(0,s.jsxs)("section",{className:"connections-detail-modal__section",children:[(0,s.jsx)("h3",{className:"connections-detail-modal__section-title",children:"What Coach gets"}),(0,s.jsx)("div",{className:"connections-detail-modal__feature-list",children:[{title:"Secure broker authorization",description:"Authenticate directly with your broker using their official login flow."},{title:"Automatic trade sync",description:"Keep executions and positions flowing into your journal for cleaner review."}].map(e=>(0,s.jsxs)("div",{className:"connections-detail-modal__feature-row",children:[(0,s.jsxs)("div",{className:"connections-detail-modal__feature-copy",children:[(0,s.jsx)("p",{className:"connections-detail-modal__feature-title",children:e.title}),(0,s.jsx)("p",{className:"connections-detail-modal__feature-description",children:e.description})]}),(0,s.jsx)(R.A,{className:"connections-detail-modal__feature-check",size:18,"aria-hidden":"true"})]},e.title))})]}),(0,s.jsxs)("section",{className:"connections-detail-modal__section",children:[(0,s.jsx)("h3",{className:"connections-detail-modal__section-title",children:"Why it matters"}),(0,s.jsx)("ul",{className:"connections-detail-modal__overview",children:["Securely authorize access through your broker.","Import filled orders and account activity into your journal.","Keep Coach current with fresh trading activity."].map(e=>(0,s.jsx)("li",{children:e},e))})]}),l||i?(0,s.jsxs)("section",{className:"connections-detail-modal__section",children:[(0,s.jsx)("h3",{className:"connections-detail-modal__section-title",children:"Helpful links"}),(0,s.jsxs)("div",{className:"connections-detail-modal__links",children:[l?(0,s.jsxs)("a",{className:"connections-detail-modal__link",href:l,target:"_blank",rel:"noreferrer",children:[(0,s.jsx)(L.A,{size:15,"aria-hidden":"true"}),"Website"]}):null,i?(0,s.jsxs)("a",{className:"connections-detail-modal__link",href:i,target:"_blank",rel:"noreferrer",children:[(0,s.jsx)(I.A,{size:15,"aria-hidden":"true"}),"Support"]}):null]})]}):null]})})}let W={Broker:"Brokers",Channel:"Channels","Data Source":"Data",Data:"Data"},B=["All","Brokers","Channels","Data"];
1function O(e){let{connectedServices:t=[],availableIntegrations:a=[],initialTab:i="All",initialWorkspaceMode:o="catalog",onConnectIntegration:c,onWorkspaceModeChange:d,onTradeSaved:u,editTrade:m,subscription:p,title:x="Broker Access",subhead:h="Connect your broker so Coach can review real trading activity and keep your journal current.",showWorkspaceModeActions:g=!1,onSelectIntegration:f,className:b}=e,v=(0,r.useRouter)(),[_,j]=(0,n.useState)(""),[y,N]=(0,n.useState)(i),[k,w]=(0,n.useState)(o),[A,C]=(0,n.useState)(!1),[E,P]=(0,n.useState)(null),R=(0,n.useMemo)(()=>{let e=new Set;for(let t of a){let a=W[t.category];a&&e.add(a)}return B.filter(t=>"All"===t||e.has(t))},[a]),L=(0,n.useMemo)(()=>{let e=_.toLowerCase().trim();return a.filter(t=>{var a,s;let n=!e||t.name.toLowerCase().includes(e)||t.type.toLowerCase().includes(e)||null!=(s=null==(a=t.description)?void 0:a.toLowerCase().includes(e))&&s,r="All"===y||W[t.category]===y;return n&&r})},[a,_,y]),I=(0,n.useMemo)(()=>{let e=new Map;for(let a of t)for(let t of[a.integrationKey||"",a.id,"name:".concat(a.name.toLowerCase())].map(e=>e.trim().toLowerCase()).filter(Boolean))e.has(t)||e.set(t,a);return e},[t]);(0,n.useEffect)(()=>{N(i)},[i]),(0,n.useEffect)(()=>{R.includes(y)||N("All")},[y,R]),(0,n.useEffect)(()=>{w(o)},[o]);let F=e=>{w(e),null==d||d(e)};return(0,s.jsx)("div",{className:"connections-terminal",children:(0,s.jsxs)("div",{className:(0,l.cn)("connections-page",b),children:[(0,s.jsxs)("header",{className:"connections-page__header",children:[(0,s.jsx)("h1",{className:"connections-page__headline",children:x}),(0,s.jsx)("p",{className:"connections-page__subhead",children:h})]}),0===a.length?(0,s.jsx)(M,{onConnectBroker:void 0}):(0,s.jsxs)("section",{className:"connections-page__available-section","aria-label":"Broker access options",children:[(0,s.jsx)("div",{className:"connections-page__filters-sticky",children:(0,s.jsx)(D,{search:_,activeTab:y,tabs:R,onSearchChange:j,onTabChange:e=>{N(e),F("catalog")},trailingActions:g?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{type:"button",className:(0,l.cn)("integration-filters__action","manual"===k&&"integration-filters__action--active"),onClick:()=>F("manual"),children:"Journal"}),(0,s.jsx)("button",{type:"button",className:(0,l.cn)("integration-filters__action","file"===k&&"integration-filters__action--active"),onClick:()=>F("file"),children:"Import file"})]}):void 0})}),"manual"===k?(0,s.jsx)("div",{className:"connections-page__trade-panel",children:(0,s.jsx)(S,{initialMethod:"manual",lockedMethod:"manual",hideMethodSelector:!0,embedded:!0,editTrade:null!=m?m:void 0,subscription:p,onSaveSuccess:u})}):"file"===k?(0,s.jsx)("div",{className:"connections-page__trade-panel",children:(0,s.jsx)(S,{initialMethod:"file",lockedMethod:"file",hideMethodSelector:!0,embedded:!0,subscription:p,onSaveSuccess:u})}):L.length>0?(0,s.jsx)("div",{className:"connections-page__available-grid",children:L.map(e=>(()=>{let t=!!(e=>{for(let t of[e.integrationKey||e.id,"name:".concat(e.name.toLowerCase())].map(e=>e.trim().toLowerCase()).filter(Boolean)){let e=I.get(t);if(e)return e}return null})(e);return(0,s.jsx)(T,{...e,connected:t,actionLabel:e.comingSoon?"Coming Soon":t?"Connected":"Connect",disabled:e.disabled||t,onConnect:()=>{if(f&&!t&&!e.comingSoon&&!e.disabled)return void f(e);t||e.comingSoon||e.disabled||(P(e),C(!0))}},e.id)})())}):(0,s.jsx)("div",{className:"connections-page__no-results",children:(0,s.jsx)("p",{children:"No integrations match your search."})})]}),(0,s.jsx)(z,{open:A,integration:E,onOpenChange:e=>{C(e),e||P(null)},onContinue:()=>{var e;if(!E)return;let t=new URLSearchParams;t.set("broker",null!=(e=E.brokerSlug)?e:E.id),t.set("name",E.name),E.iconUrl&&t.set("iconUrl",E.iconUrl),v.push("/broker-connect?".concat(t.toString()))}})]})})}},12566:(e,t,a)=>{a.d(t,{c:()=>_});var s=a(95155),n=a(12115),r=a(15239),l=a(25016),i=a(42196),o=a(89715),c=a(14285),d=a(6504),u=a(5459),m=a(40254),p=a(55100),x=a(35102),h=a(40875);let g=(0,n.memo)(function(e){let{displayedContent:t,assetProxySurface:a}=e;return(0,s.jsx)("div",{className:"chat-markdown",children:(0,s.jsx)(d.oz,{remarkPlugins:[u.A],components:{h1:e=>{let{children:t}=e;return(0,s.jsx)("h2",{className:"text-lg font-bold mt-2 mb-1 text-foreground",children:t})},h2:e=>{let{children:t}=e;return(0,s.jsx)("h3",{className:"text-base font-bold mt-2 mb-1 text-foreground",children:t})},h3:e=>{let{children:t}=e;return(0,s.jsx)("h4",{className:"text-sm font-semibold mt-2 mb-1 text-foreground",children:t})},p:e=>{let{children:t}=e;return(0,s.jsx)("p",{className:"mb-3 last:mb-0 leading-relaxed text-foreground",children:t})},ul:e=>{let{children:t}=e;return(0,s.jsx)("ul",{className:"list-disc list-inside mb-3 space-y-1 text-foreground",children:t})},ol:e=>{let{children:t}=e;return(0,s.jsx)("ol",{className:"list-decimal list-inside mb-3 space-y-1 text-foreground",children:t})},li:e=>{let{children:t}=e;return(0,s.jsx)("li",{className:"leading-relaxed",children:t})},strong:e=>{let{children:t}=e;return(0,s.jsx)("strong",{className:"font-semibold",children:t})},em:e=>{let{children:t}=e;return(0,s.jsx)("em",{className:"italic",children:t})},code:e=>{let{children:t,className:a}=e;return a?(0,s.jsx)("pre",{className:"bg-muted p-3 rounded-md overflow-x-auto text-xs font-mono my-2 text-foreground",children:(0,s.jsx)("code",{children:t})}):(0,s.jsx)("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs font-mono",children:t})},pre:e=>{let{children:t}=e;return(0,s.jsx)("pre",{className:"bg-muted p-3 rounded-md overflow-x-auto text-xs font-mono my-2 text-foreground",children:t})},a:e=>{let{href:t,children:a}=e,n=(0,h.S0)(t);if(!n)return(0,s.jsx)("span",{children:a});let r=n.startsWith("http://")||n.startsWith("https://");return(0,s.jsx)("a",{href:n,target:r?"_blank":void 0,rel:r?"noopener noreferrer":void 0,className:"text-primary hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 rounded",children:a})},img:e=>{let{src:t,alt:n}=e,r=(0,h.$C)(t,{surface:a});return r?(0,s.jsx)("img",{src:r,alt:n||"Assistant image",loading:"eager",decoding:"async",draggable:!1,
1className:"chat-markdown__image",style:{display:"block",width:"75%",maxWidth:"75%",height:"auto"}}):(0,s.jsx)("span",{className:"text-xs italic text-muted-foreground",children:"Image unavailable. Ask me to retry."})},blockquote:e=>{let{children:t}=e;return(0,s.jsx)("blockquote",{className:"border-l-4 border-border pl-4 italic text-muted-foreground my-3",children:t})},hr:()=>(0,s.jsx)("hr",{className:"my-3 border-border"})},children:t})})});function f(e){var t,a;return(null==(t=e.type)?void 0:t.startsWith("image/"))?i.A:"application/pdf"===e.type||(null==(a=e.name)?void 0:a.toLowerCase().endsWith(".pdf"))?o.A:c.A}function b(e){return e?e>=1048576?"".concat((e/1048576).toFixed(1)," MB"):e>=1024?"".concat(Math.round(e/1024)," KB"):"".concat(e," B"):""}function v(e){var t,a;if(null==(t=e.type)?void 0:t.startsWith("image/"))return e.type.replace("image/","").toUpperCase();if(e.type){let[,t]=e.type.split("/");if(t)return t.toUpperCase()}let s=(null==(a=e.name)?void 0:a.toLowerCase())||"";return s.endsWith(".pdf")?"PDF":s.endsWith(".docx")?"DOCX":s.endsWith(".doc")?"DOC":s.endsWith(".txt")?"TXT":"FILE"}function _(e){var t;let{role:a,content:i,isStreaming:o=!1,attachments:c,variant:d="coach",assetProxySurface:u="chat",hideAssistantAvatar:_=!1,onOpenSubAgentJob:j,onCancelSubAgentJob:y}=e,N="user"===a,{user:k}
1=(0,m.J)(),[w,A]=(0,n.useState)(""),S=N?i:function(e,t){let a=e.replace(/<small>[\s\S]*?<\/small>/gi,"").replace(/\n{3,}/g,"\n\n").trim();return a?(0,h.po)(a,{surface:t}):""}(i,u);(0,n.useEffect)(()=>{if(N||!o){let e=window.setTimeout(()=>{A(S)},0);return()=>window.clearTimeout(e)}let e=w.length;if(e>=S.length)return;let t=setInterval(()=>{if(e<S.length){let t=Math.min(3,S.length-e);A(S.slice(0,e+t)),e+=t}},10);return()=>clearInterval(t)},[S,o,N,w.length]);let T=(0,s.jsx)("div",{className:"h-8 w-8 shrink-0 rounded-full overflow-hidden flex items-center justify-center bg-muted",children:N?(null==k?void 0:k.avatarUrl)?(0,s.jsx)(r.default,{src:k.avatarUrl,alt:k.name||"User",width:32,height:32,className:"w-full h-full object-cover"}):(0,s.jsx)("span",{className:"text-sm font-medium text-foreground",children:(null==k||null==(t=k.name)?void 0:t.charAt(0).toUpperCase())||"U"}):(0,s.jsx)(r.default,{src:"/blue-logo-pfp.png",alt:"Trading Coach",width:32,height:32,className:"w-full h-full object-cover"})});if("agent"===d){let e=!N&&!_,t=(null!=c?c:[]).filter(e=>"subagent_task"===e.kind&&e.subAgentTask),a=(null!=c?c:[]).filter(e=>"scheduled_task"===e.kind&&e.scheduledTask),n=(null!=c?c:[]).filter(e=>("subagent_task"!==e.kind||!e.subAgentTask)&&("scheduled_task"!==e.kind||!e.scheduledTask)),r=(0,s.jsx)("div",{className:"chat-msg__avatar","aria-hidden":"true",children:(0,s.jsx)("div",{className:"chat-msg__avatar-inner",children:(0,s.jsx)("span",{className:"chat-msg__avatar-initial",children:"AI"})})});return(0,s.jsxs)("div",{className:(0,l.cn)("chat-msg",e?"chat-msg--has-avatar":"chat-msg--no-avatar"),children:[e?r:null,(0,s.jsx)("div",{className:(0,l.cn)("chat-msg__body",N?"chat-msg__body--user":"chat-msg__body--assistant"),children:(0,s.jsxs)("div",{className:(0,l.cn)("chat-msg__bubble",N?"chat-msg__bubble--user":"chat-msg__bubble--assistant"),children:[(0,s.jsx)("div",{className:"chat-msg__meta",children:(0,s.jsx)("span",{className:(0,l.cn)("chat-msg__role-tag",N?"chat-msg__role-tag--user":"chat-msg__role-tag--assistant",!N&&o&&"chat-msg__role-tag--stream"),children:N?"USER":o?"AGENT // LIVE":"AGENT"})}),N?(0,s.jsx)("p",{className:"chat-msg__plain",children:i}):(0,s.jsx)(g,{displayedContent:w,assetProxySurface:u}),t.length>0&&(0,s.jsx)("div",{className:"chat-msg__attachments",children:t.map(e=>{let t=e.subAgentTask;return(0,s.jsx)(p.L,{taskId:t.jobId,title:t.title,type:t.kind.replace(/_/g," "),status:t.status,steps:t.steps,startedAt:new Date(t.startedAt),estimatedMinutes:t.estimatedMinutes,progressPercent:t.progressPercent,note:t.note,summary:t.summary,onViewInJobs:()=>null==j?void 0:j(t.jobId),onCancel:"queued"===t.status||"running"===t.status?()=>null==y?void 0:y(t.jobId):void 0},t.jobId)})}),a.length>0&&(0,s.jsx)("div",{className:"chat-msg__attachments",children:a.map(e=>{let t=e.scheduledTask;return(0,s.jsx)(x.b,{taskId:t.jobId,title:t.title,type:t.kind.replace(/_/g," "),status:t.status,schedule:t.schedule,deliveryTarget:t.deliveryTarget,note:t.note,onViewInJobs:()=>null==j?void 0:j(t.jobId)},t.jobId)})}),n.length>0&&(0,s.jsx)("div",{className:"chat-msg__attachments",children:n.map((e,t)=>{let a=f(e);return(0,s.jsxs)("div",{className:"chat-msg__attachment-item",children:[(0,s.jsx)(a,{className:"chat-msg__attachment-icon"}),(0,s.jsxs)("div",{className:"chat-msg__attachment-meta",children:[(0,s.jsx)("p",{className:"chat-msg__attachment-name",children:e.name}),(0,s.jsxs)("p",{className:"chat-msg__attachment-type",children:[v(e),e.size?" ⢠".concat(b(e.size)):""]})]})]},"".concat(e.name,"-").concat(t))})})]})}),(0,s.jsx)("div",{className:"chat-msg__avatar","aria-hidden":"true"})]})}return(0,s.jsxs)("div",{className:"grid grid-cols-[auto_1fr_auto] gap-3 items-start w-full max-w-full",children:[(0,s.jsx)("div",{className:"w-8 shrink-0",children:N?null:T}),(0,s.jsx)("div",{className:(0,l.cn)("min-w-0 flex flex-col items-start",N&&"flex-col items-end"),children:(0,s.jsxs)("div",{className:(0,l.cn)("rounded-2xl px-4 py-3 text-[15px] leading-relaxed max-w-[90%] sm:max-w-[85%]",N?"bg-muted text-foreground whitespace-pre-wrap break-words":"text-foreground"),style:{overflowWrap:"break-word",wordBreak:"normal"},children:[N?i:(0,s.jsx)(g,{displayedContent:w,assetProxySurface:u}),c&&c.length>0&&(0,s.jsx)("div",{className:"mt-3 space-y-2",children:c.map((e,t)=>{var a;let n=f(e),r=(null==(a=e.type)?void 0:a.startsWith("image/"))?(0,h.$C)(e.storageUrl,{surface:u}):null;return(0,s.jsx)("div",{className:(0,l.cn)("rounded-xl px-3 py-2 text-xs",N?"bg-primary/10 border border-primary/20 text-foreground":"bg-muted text-foreground"),children:r?(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("img",{src:r,alt:e.name,loading:"lazy",decoding:"async",draggable:!1,
1className:"block h-auto max-h-[28rem] w-full rounded-lg border border-border object-contain"}),(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(n,{className:(0,l.cn)("h-4 w-4 shrink-0",N?"text-primary":"text-muted-foreground")}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"font-medium truncate",children:e.name}),(0,s.jsxs)("p",{className:"text-[11px] opacity-80",children:[v(e),e.size?" ⢠".concat(b(e.size)):""]})]})]})]}):(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(n,{className:(0,l.cn)("h-4 w-4 shrink-0",N?"text-primary":"text-muted-foreground")}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"font-medium truncate",children:e.name}),(0,s.jsxs)("p",{className:"text-[11px] opacity-80",children:[v(e),e.size?" ⢠".concat(b(e.size)):""]})]})]})},"".concat(e.name,"-").concat(t))})})]})}),(0,s.jsx)("div",{className:"w-8 shrink-0",children:N?T:null})]})}},20332:(e,t,a)=>{a.d(t,{f:()=>_});var s=a(95155),n=a(12115),r=a(15239),l=a(5937),i=a(75882),o=a(80534),c=a(37772),d=a(29633),u=a(43465),m=a(78519),p=a(23664),x=a(25016),h=a(49654);function g(e){return"menu"===e.kind}function f(e){let{onTabChange:t}=e;return(0,s.jsx)("div",{className:"mtp-legacy-nav__brand",children:(0,s.jsxs)("button",{type:"button",onClick:()=>t("agent"),className:"mtp-legacy-nav__brand-btn","aria-label":"Go to Coach",children:[(0,s.jsx)(r.default,{src:"/big-logo.png",alt:"MyTradingPal",width:34,height:34,className:"mtp-legacy-nav__brand-logo"}),(0,s.jsxs)("div",{className:"mtp-legacy-nav__brand-copy",children:[(0,s.jsx)("span",{className:"mtp-legacy-nav__brand-name",children:"MyTradingPal"}),(0,s.jsx)("span",{className:"mtp-legacy-nav__brand-meta",children:"Trading Coach"})]})]})})}function b(e){let{item:t,active:a,onSelect:n,onMouseEnter:r,onMouseLeave:l,visualTone:i="default",buttonRef:o,ariaHasPopup:c,ariaExpanded:d,ariaControls:u}=e,m=t.icon,p="tab"===t.kind&&Number(t.badge)>0;return(0,s.jsxs)("button",{ref:o,type:"button",onClick:n,onMouseEnter:r,onMouseLeave:l,className:(0,x.cn)("mtp-legacy-nav__item",a?"mtp-legacy-nav__item--active":"mtp-legacy-nav__item--idle","subtle"===i&&"mtp-legacy-nav__item--subtle","menu"===t.kind&&"mtp-legacy-nav__item--menu"),"aria-current":"tab"===t.kind&&a?"page":void 0,"aria-label":t.label,"aria-haspopup":c,"aria-expanded":d,"aria-controls":u,children:[(0,s.jsx)("span",{className:"mtp-legacy-nav__item-icon",children:(0,s.jsx)(m,{className:"h-[16px] w-[16px]"})}),(0,s.jsx)("span",{className:"mtp-legacy-nav__item-label",children:t.label}),(0,s.jsx)("span",{className:"mtp-legacy-nav__item-code mtp-tabular-nums",children:t.code}),p?(0,s.jsx)("span",{className:"mtp-legacy-nav__item-badge",children:t.badge&&t.badge>99?"99+":t.badge}):null]})}function v(e){let{icon:t,label:a,code:n,onSelect:r}=e;return(0,s.jsxs)("button",{type:"button",role:"menuitem",className:"mtp-legacy-nav__subitem",onClick:r,"aria-label":a,children:[(0,s.jsx)("span",{className:"mtp-legacy-nav__subitem-icon",children:(0,s.jsx)(t,{className:"h-[14px] w-[14px]"})}),(0,s.jsx)("span",{className:"mtp-legacy-nav__subitem-label",children:a}),(0,s.jsx)("span",{className:"mtp-legacy-nav__subitem-code mtp-tabular-nums",children:n})]})}function _(e){let{activeTab:t,onTabChange:a,agentUnreadCount:r=0,inboxEnabled:_=!0,inboxUnreadCount:j=0,showMoreMenu:y=!0,showJobsItem:N=!0}=e,[k,w]=(0,n.useState)(!1),A=(0,n.useRef)(null),S=(0,n.useRef)(null),T=(0,n.useRef)(null),C="app-sidebar-more-submenu",M=(0,n.useCallback)(()=>{T.current&&(clearTimeout(T.current),T.current=null)},[]),E=(0,n.useCallback)(()=>{M(),w(!0)},[M]),D=(0,n.useCallback)(()=>{M(),T.current=setTimeout(()=>{w(!1)},130)},[M]);(0,n.useEffect)(()=>()=>{M()},[M]),(0,n.useEffect)(()=>{if(!k)return;let e=e=>{var t;"Escape"===e.key&&(w(!1),null==(t=S.current)||t.focus())};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[k]),(0,n.useEffect)(()=>{if(!k)return;let e=e=>{var t;let a=e.target;null!=(t=A.current)&&t.contains(a)||w(!1)};return document.addEventListener("pointerdown",e),()=>{document.removeEventListener("pointerdown",e)}},[k]);let P=(0,n.useMemo)(()=>{let e=[{kind:"tab",key:"agent",label:h.ks.agent,code:h.ls.agent,icon:l.A,badge:r},{kind:"tab",key:"my-trades",label:h.ks["my-trades"],code:h.ls["my-trades"],icon:i.A},{kind:"tab",key:"analytics",label:h.ks.analytics,code:h.ls.analytics,icon:o.A}];return y&&e.push({kind:"menu",id:"more",label:"More",code:"MRE",icon:c.A}),e},[r,y]),R=(0,n.useMemo)(()=>{let e=[];return N&&e.push({kind:"tab",key:"jobs",label:h.ks.jobs,code:h.ls.jobs,icon:d.A}),_&&e.push({kind:"tab",key:"inbox",label:h.ks.inbox,code:h.ls.inbox,icon:u.A,badge:j}),e},[_,j,N]),L=(0,n.useCallback)(e=>{a(e)},[a]);return(0,s.jsxs)("aside",{className:"mtp-legacy-nav hidden md:flex","aria-label":"Primary",children:[(0,s.jsx)(f,{onTabChange:a}),(0,s.jsxs)("div",{className:"mtp-legacy-nav__status",children:[(0,s.jsx)("span",{className:"mtp-legacy-nav__status-label",children:"COACH ONLINE"}),(0,s.jsx)("span",{className:"mtp-legacy-nav__status-value",children:"v2"})]}),(0,s.jsxs)("nav",{className:"mtp-legacy-nav__body","aria-label":"App sections",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>{L("connections"),w(!1)},className:(0,x.cn)("mtp-legacy-nav__log-btn","connections"===t&&"mtp-legacy-nav__log-btn--active"),"aria-current":"connections"===t?"page":void 0,"aria-label":h.ks.connections,children:[(0,s.jsx)("span",{children:h.ks.connections.toUpperCase()}),(0,s.jsx)("span",{className:"mtp-legacy-nav__log-btn-code mtp-tabular-nums",children:h.ls.connections})]}),(0,s.jsx)("div",{className:"mtp-legacy-nav__items",children:P.map(e=>
1{let n=g(e)?e.id:e.key,r=g(e)?k:t===e.key;return g(e)?(0,s.jsxs)("div",{ref:A,className:"mtp-legacy-nav__subtabs-wrap",onMouseEnter:E,onMouseLeave:D,children:[(0,s.jsx)(b,{item:e,active:r,onSelect:()=>{w(e=>!e)},buttonRef:S,ariaHasPopup:"menu",ariaExpanded:k,ariaControls:C}),k?(0,s.jsxs)("div",{id:C,role:"menu","aria-label":"More actions",className:"mtp-legacy-nav__subtabs",children:[(0,s.jsx)(v,{icon:l.A,label:"Profile",code:"PRF",onSelect:()=>{a("profile")}}),(0,s.jsx)(v,{icon:m.A,label:"Pricing",code:"PRC",onSelect:()=>{a("pricing")}}),(0,s.jsx)(v,{icon:p.A,label:"Contact",code:"CNT",onSelect:()=>{a("contact")}})]}):null]},n):(0,s.jsx)(b,{item:e,active:r,onSelect:()=>{L(e.key),w(!1)}},n)})}),(0,s.jsx)("div",{className:"mtp-legacy-nav__items mtp-legacy-nav__items--utility",children:R.map(e=>{let a=e.key,n=t===e.key;return(0,s.jsx)(b,{item:e,active:n,visualTone:"subtle",onSelect:()=>{L(e.key),w(!1)}},a)})})]})]})}},25016:(e,t,a)=>{a.d(t,{cn:()=>r});var s=a(2821),n=a(75889);function r(){for(var e=arguments.length,t=Array(e),a=0;a<e;a++)t[a]=arguments[a];return(0,n.QP)((0,s.$)(t))}},27298:(e,t,a)=>{a.d(t,{A:()=>j});var s=a(95155),n=a(12115),r=a(40254),l=a(35299),i=a(24033),o=a(25016),c=a(56299),d=a(33520),u=a(87849),m=a(76648);let p="Not enough data";function x(e){return"â"===e?p:e}function h(e){let t=new Date("".concat(e,"T00:00:00"));return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function g(e,t,a){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;
1if(0===e.length)return"";let n=Math.min(...e),r=Math.max(...e)-n||1,l=t-2*s,i=a-2*s;return e.map((t,a)=>{let o=s+a/Math.max(e.length-1,1)*l;return"".concat(0===a?"M":"L"," ").concat(o.toFixed(2)," ").concat((s+(1-(t-n)/r)*i).toFixed(2))}).join(" ")}function f(e,t,a){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(0===e.length)return[];let n=Math.min(...e),r=Math.max(...e)-n||1,l=t-2*s,i=a-2*s;return e.map((t,a)=>{let o=s+a/Math.max(e.length-1,1)*l;return{index:a,value:t,x:o,y:s+(1-(t-n)/r)*i}})}function b(e){let{children:t,className:a}=e;return(0,s.jsx)("section",{className:(0,o.cn)("mtp-analytics__surface",a),children:t})}function v(e){let{label:t,value:a,tone:n="neutral",extra:r}=e;return(0,s.jsxs)("div",{className:"mtp-analytics__metric",children:[(0,s.jsx)("p",{className:"mtp-analytics__metric-label",children:t}),(0,s.jsx)("p",{className:(0,o.cn)("mtp-analytics__metric-value","gain"===n?"mtp-analytics__metric-value--gain":"loss"===n?"mtp-analytics__metric-value--loss":void 0),children:a}),r]})}function _(e){let{label:t,value:a,tone:n="neutral"}=e;return(0,s.jsxs)("div",{className:"mtp-analytics__metric mtp-analytics__metric--dense",children:[(0,s.jsx)("p",{className:"mtp-analytics__metric-label",children:t}),(0,s.jsx)("p",{className:(0,o.cn)("mtp-analytics__metric-value mtp-analytics__metric-value--compact","gain"===n?"mtp-analytics__metric-value--gain":"loss"===n?"mtp-analytics__metric-value--loss":void 0),children:a})]})}function j(e){var t,a,j,y,N,k,w,A,S,T,C;let{onNavigateToLogTrade:M,onNavigateToPricing:E,subscription:D,statsOverride:P,tradesThisWeekOverride:R,loadingOverride:L,insights:I=[]}=e,{user:F}=(0,r.J)(),{stats:z,isLoading:W}=(0,c.v)(null==F?void 0:F.id),{tradesThisWeek:B,isLoading:O}=(0,d.l)(null==F?void 0:F.id),U=null!=P?P:z,q=null!=L?L:W,$=null!=R?R:B,V=null==R&&O,[H,K]=(0,n.useState)(!1),[J,G]=(0,n.useState)(null),[Y,Z]=(0,n.useState)(null),[X,Q]=(0,n.useState)(!1),[ee,et]=(0,n.useState)(!1),[ea,es]=(0,n.useState)(!1),en=(0,n.useRef)(null),er=(0,n.useRef)(null);(0,n.useEffect)(()=>{let e=setTimeout(()=>K(!0),60);return()=>clearTimeout(e)},[null==U?void 0:U.updated_at]),(0,n.useEffect)(()=>{let e=window.matchMedia("(max-width: 767px)"),t=()=>es(e.matches);return t(),e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[]);let el=U&&null!=U.gross_profits&&null!=U.gross_losses?U.gross_profits-U.gross_losses:null,ei=(0,n.useMemo)(()=>{if((null==U?void 0:U.pnl_series)&&U.pnl_series.length>=2){let e=U.pnl_series.slice(-36),t=0;return e.map(e=>t+=e)}return[]},[null==U?void 0:U.pnl_series]),eo=(0,n.useMemo)(()=>g(ei,620,220,14),[ei]),ec=(0,n.useMemo)(()=>f(ei,620,220,14),[ei]),ed=(0,n.useMemo)(()=>eo?"".concat(eo," L ").concat(606," ").concat(206," L ").concat(14," ").concat(206," Z"):"",[eo]),eu=(0,n.useMemo)(()=>{var e;return(null!=(e=null==U?void 0:U.daily_pnl_series)?e:[]).slice(-45)},[null==U?void 0:U.daily_pnl_series]),em=(0,n.useMemo)(()=>eu.map(e=>e.total),[eu]),ep=(0,n.useMemo)(()=>g(em,620,152,12),[em]),ex=(0,n.useMemo)(()=>ep?"".concat(ep," L ").concat(608," ").concat(140," L ").concat(12," ").concat(140," Z"):"",[ep]),eh=(0,n.useMemo)(()=>f(em,620,152,12),[em]),eg=null!=(t=null==U?void 0:U.best_day_pnl)?t:null,ef=null!=(a=null==U?void 0:U.worst_day_pnl)?a:null,eb=(0,n.useMemo)(()=>null==eg?-1:eu.findIndex(e=>1e-5>Math.abs(e.total-eg)),[eu,eg]),ev=(0,n.useMemo)(()=>null==ef?-1:eu.findIndex(e=>1e-5>Math.abs(e.total-ef)),[eu,ef]),e_=(null==U?void 0:U.max_drawdown_pct)==null?0:Math.max(0,Math.min(100,U.max_drawdown_pct)),ej=Math.max(0,null!=(j=null==U?void 0:U.avg_win)?j:0),ey=ej+Math.abs(null!=(y=null==U?void 0:U.avg_loss)?y:0),eN=Math.max(0,null!=(N=null==U?void 0:U.gross_profits)?N:0),ek=eN+Math.abs(null!=(k=null==U?void 0:U.gross_losses)?k:0),ew=null!=(w=null==U?void 0:U.avg_hold_win_minutes)?w:null,eA=null!=(A=null==U?void 0:U.avg_hold_loss_minutes)?A:null,eS=Math.max(0,null!=ew?ew:0),eT=Math.max(0,null!=eA?eA:0),eC=Math.max(eS,eT,1),eM=(0,n.useMemo)(()=>null==ew||null==eA||ew<=0||eA<=0?p:ew===eA?"You hold winners and losers for the same amount of time.":eA>ew?"You hold losers ".concat((eA/ew).toFixed(1),"x longer than winners."):"You hold winners ".concat((ew/eA).toFixed(1),"x longer than losers."),[ew,eA]),[eE,eD]=(0,n.use
1State)(!1),eP=!q&&(null!=(S=null==U?void 0:U.total_trades)?S:0)===0,eR=(null==D?void 0:D.plan)==="pro"&&((null==D?void 0:D.status)==="active"||(null==D?void 0:D.status)==="trialing"),eL=(0,u.f)()&&!eR,eI=ea?220:170,eF=ea?210:176,ez=null!=J&&null!=(T=ec[J])?T:null,eW=null!=Y&&null!=(C=eh[Y])?C:null,eB=ez?Math.max(14,Math.min(ez.x-eI/2,606-eI)):14,eO=eW?Math.max(12,Math.min(eW.x-eF/2,608-eF)):12,eU=(null==U?void 0:U.green_days_pct)==null?0:Math.max(0,Math.min(100,U.green_days_pct)),eq=(null==U?void 0:U.first_trade_win_rate_pct)==null?0:Math.max(0,Math.min(100,U.first_trade_win_rate_pct)),e$=e=>{if(ec.length<2||!en.current)return;let t=en.current.getBoundingClientRect(),a=(e-t.left)/t.width*620,s=0,n=1/0;for(let e=0;e<ec.length;e+=1){let t=Math.abs(ec[e].x-a);t<n&&(n=t,s=e)}G(s)},eV=e=>{e$(e.clientX)},eH=()=>{X||G(null)},eK=()=>{Q(!1),G(null)},eJ=e=>{if(eh.length<2||!er.current)return;let t=er.current.getBoundingClientRect(),a=(e-t.left)/t.width*620,s=0,n=1/0;for(let e=0;e<eh.length;e+=1){let t=Math.abs(eh[e].x-a);t<n&&(n=t,s=e)}Z(s)},eG=e=>{eJ(e.clientX)},eY=()=>{ee||Z(null)},eZ=()=>{et(!1),Z(null)};return(0,s.jsx)("div",{className:"mtp-analytics flex-1 min-h-full overflow-y-auto p-5 md:p-6",children:(0,s.jsxs)("div",{className:"mtp-analytics__inner mx-auto space-y-4 md:space-y-5",children:[(0,s.jsxs)("header",{className:"mtp-analytics__header flex flex-col gap-2 sm:flex-row sm:items-end sm:justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mtp-analytics__eyebrow text-xs uppercase tracking-wide text-muted-foreground",children:"Performance"}),(0,s.jsx)("h1",{className:"mtp-analytics__title mt-1 text-2xl font-bold text-foreground sm:text-3xl",children:"Performance Review"})]}),(0,s.jsxs)("p",{className:"mtp-analytics__updated text-xs text-muted-foreground",children:["Last updated: ",function(e){if(!e)return p;let t=new Date(e);return Number.isNaN(t.getTime())?p:t.toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}(null==U?void 0:U.updated_at)]})]}),q?(0,s.jsx)(b,{className:"flex min-h-[320px] items-center justify-center",children:(0,s.jsx)(l.A,{className:"h-7 w-7 animate-spin text-muted-foreground"})}):(0,s.jsxs)(s.Fragment,{children:[eP?(0,s.jsxs)(b,{className:"space-y-3",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"Performance review starts when your journal does"}),(0,s.jsx)("p",{className:"max-w-2xl text-sm leading-relaxed text-muted-foreground",children:"Connect a broker or log a trade so Coach has real activity to review."}),M?(0,s.jsx)("button",{type:"button",onClick:()=>M("broker"),className:"mtp-analytics__cta mt-2 w-full sm:w-auto px-4 py-2 text-sm font-semibold transition-colors",children:"Connect Broker"}):null]}):null,(0,s.jsx)("div",{children:(0,s.jsxs)("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,1fr)_minmax(0,1.6fr)]",children:[(0,s.jsxs)(b,{className:"grid gap-4",children:[(0,s.jsx)(v,{label:"Net P&L ($)",value:x((0,m.jT)(el,{showSign:!0})),tone:null==el?"neutral":el>=0?"gain":"loss"}),(0,s.jsx)(v,{label:"Win Rate",value:x((0,m.hz)(null==U?void 0:U.win_rate_pct))}),(0,s.jsx)(v,{label:"Profit Factor",value:x((0,m.dd)(null==U?void 0:U.profit_factor))}),(0,s.jsx)(v,{label:"Max Drawdown",value:x((0,m.hz)(null==U?void 0:U.max_drawdown_pct)),tone:"neutral",extra:(0,s.jsx)("div",{className:"mt-3",children:(0,s.jsx)("div",{className:"mtp-analytics__progress-track",children:(0,s.jsx)("div",{className:"mtp-analytics__progress-fill transition-all duration-500 ease-out motion-reduce:transition-none",style:{width:"".concat(H?e_:0,"%")}})})})})]}),(0,s.jsxs)(b,{children:[(0,s.jsxs)("div",{className:"mb-3 flex items-center justify-between",children:[(0,s.jsx)("h2",{className:"mtp-analytics__section-title text-sm font-semibold text-foreground",children:"Equity Curve"}),(0,s.jsxs)("span",{className:"text-xs text-muted-foreground",children:["Last ",ei.length||0," trades"]})]}),ei.length<2?(0,s.jsx)("div",{className:"flex h-[250px] items-center justify-center font-mono text-sm text-muted-foreground",children:p}):(0,s.jsxs)("svg",{ref:en,viewBox:"0 0 ".concat(620," ").concat(220),className:"h-[250px] w-full",role:"img","aria-label":"Cumulative dollar equity curve over recent trades",tabIndex:0,style:{touchAction:"none"},onMouseMove:eV,onMouseEnter:eV,onMouseLeave:eH,onBlur:eH,onPointerDown:e=>{if(!(ec.length<2)&&(e$(e.clientX),"touch"===e.pointerType||"pen"===e.pointerType)){var t,a;e.preventDefault(),Q(!0),null==(t=(a=e.currentTarget).setPointerCapture)||t.call(a,e.pointerId)}},onPointerMove:e=>{X&&(("touch"===e.pointerType||"pen"===e.pointerType)&&e.preventDefault(),e$(e.clientX))},onPointerUp:eK,onPointerCancel:eK,children:[(0,s.jsx)("defs",{children:(0,s.jsxs)("linearGradient",{id:"analyticsAreaFillPolished",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,s.jsx)("stop",{offset:"0%",stopColor:"var(--orange)",stopOpacity:"0.22"}),(0,s.jsx)("stop",{offset:"100%",stopColor:"var(--orange)",stopOpacity:"0.03"})]})}),(0,s.jsx)("g",{className:"text-border/45",children:[0,1,2,3,4].map(e=>(0,s.jsx)("line",{x1:14,y1:14+48*e,x2:606,y2:14+48*e,stroke:"currentColor",strokeWidth:"1"},"h-".concat(e)))}),(0,s.jsx)("path",{d:ed,fill:"url(#analyticsAreaFillPolished)"}),(0,s.jsx)("path",{d:eo,fill:"none",stroke:"var(--orange)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",pathLength:1,strokeDasharray:1,strokeDashoffset:+!H,className:"transition-all duration-500 ease-out motion-reduce:transition-none"}),ez&&(0,s.jsxs)("g",{children:[(0,s.jsx)("line",{x1:ez.x,y1:14,x2:ez.x,y2:206,stroke:"var(--orange)",strokeOpacity:"0.35",strokeWidth:"1.5",strokeDasharray:"3 4"}),(0,s.jsx)("circle",{cx:ez.x,cy:ez.y,r:"4",fill:"var(--orange)",stroke:"var(--term-line-strong)",strokeWidth:"1.5"}),(0,s.jsxs)("g",{transform:"translate(".concat(eB,", ").concat(18,")"),children:[(0,s.jsx)("rect",{width:eI,height:ea?50:38,rx:1,className:"mtp-analytics__tooltip-box",strokeWidth:"1"}),(0,s.jsx)("text",{x:10,y:ea?20:16,className:(0,o.cn)("mtp-analytics__tooltip-title",ea?"text-[11px]":"text-[10px]"),children:"Trade ".concat(ez.index+1," of ").concat(ei.length)}),(0,s.jsx)("text",{x:10,y:ea?37:30,className:(0,o.cn)("mtp-analytics__tooltip-value",ea?"text-xs":"text-[10px]"),children:"Cumulative: ".concat((0,m.jT)(ez.value,{showSign:!0}))})]})]}),(0,s.jsx)("text",{x:14,y:218,className:"fill-muted-foreground text-[11px]",children:"Start"}),(0,s.jsx)("text",{x:606,y:218,textAnchor:"end",className:"fill-muted-foreground text-[11px]",children:"Now"})]}),ei.length>=2&&(0,s.jsx)("p",{className:"mt-2 text-[11px] text-muted-foreground md:hidden",children:"Press and drag to inspect values."})]})]})}),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsxs)("div",{className:eL?"pointer-events-none select-none blur-[3px] opacity-65":void 0,children:[(0,s.jsxs)(b,{className:"space-y-3 md:hidden",children:[(0,s.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:"Today's snapshot"}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,s.jsx)(_,{label:"Net P&L ($)",value:x((0,m.jT)(el,{showSign:!0}))}),(0,s.jsx)(_,{label:"Win Rate",value:x((0,m.hz)(null==U?void 0:U.win_rate_pct))}),(0,s.jsx)(_,{label:"Trades This Week",value:V?"â¦":String($)}),(0,s.jsx)(_,{label:"Expectancy ($)",value:x((0,m.jT)(null==U?void 0:U.expectancy_dollars,{showSign:!0}))})]}),(0,s.jsxs)("button",{type:"button",onClick:()=>eD(e=>!e),"aria-expanded":eE,"aria-controls":"mobile-advanced-analytics",className:"mtp-analytics__toggle w-full min-h-[38px] px-3 text-sm font-medium text-foreground transition-colors flex items-center justify-between",children:["Deeper metrics",(0,s.jsx)(i.A,{className:(0,o.cn)("h-4 w-4 transition-transform",eE?"rotate-180":"")})]})]}),eE&&(0,s.jsx)("div",{id:"mobile-advanced-analytics",className:"md:hidden space-y-4",children:(0,s.jsxs)(b,{className:"space-y-2",children:[(0,s.jsx)("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"Deeper metrics"}),(0,s.jsxs)("div",{className:"grid gap-3",children:[(0,s.jsx)(_,{label:"Profit Factor",value:x((0,m.dd)(null==U?void 0:U.profit_factor))}),(0,s.jsx)(_,{label:"Max Drawdown",value:x((0,m.hz)(null==U?void 0:U.max_drawdown_pct))}),(0,s.jsx)(_,{label:"Trades / Session",value:x((0,m.dd)(null==U?void 0:U.trades_per_session))}),(0,s.jsx)(_,{label:"Gross Profits",value:x((0,m.jT)(null==U?void 0:U.gross_profits,{showSign:!0})),tone:(null==U?void 0:U.gross_profits)!=null&&U.gross_profits>0?"gain":"neutral"}),(0,s.jsx)(_,{label:"Gross Losses",value:x((0,m.jT)((null==U?void 0:U.gross_losses)!=null?-Math.abs(U.gross_losses):null,{showSign:!0})),tone:(null==U?void 0:U.gross_losses)!=null&&U.gross_losses>0?"loss":"neutral"}
1),(0,s.jsx)(_,{label:"Avg Hold (Wins)",value:x((0,m.ih)(null==U?void 0:U.avg_hold_win_minutes))}),(0,s.jsx)(_,{label:"Avg Hold (Losses)",value:x((0,m.ih)(null==U?void 0:U.avg_hold_loss_minutes))})]})]})}),(0,s.jsx)("p",{className:"hidden md:block text-xs uppercase tracking-wide text-muted-foreground",children:"Deeper metrics"}),(0,s.jsxs)("div",{className:"hidden md:grid gap-4 xl:grid-cols-2",children:[(0,s.jsxs)(b,{children:[(0,s.jsx)("h2",{className:"mtp-analytics__section-title text-sm font-semibold text-foreground",children:"Win / Loss Payoff Ratio"}),(0,s.jsx)("div",{className:"mtp-analytics__progress-track mt-3",children:(0,s.jsx)("div",{className:"mtp-analytics__progress-fill transition-all duration-500 ease-out motion-reduce:transition-none",style:{width:"".concat(H?ey>0?ej/ey*100:50:0,"%")}})}),(0,s.jsxs)("div",{className:"mt-2 flex items-center justify-between text-xs",children:[(0,s.jsxs)("span",{className:"text-foreground",children:["Avg Win ",x((0,m.jT)(null==U?void 0:U.avg_win,{showSign:!0}))]}),(0,s.jsxs)("span",{className:"text-muted-foreground",children:["Avg Loss"," ",x((0,m.jT)((null==U?void 0:U.avg_loss)!=null?-Math.abs(U.avg_loss):null,{showSign:!0}))]})]})]}),(0,s.jsxs)(b,{children:[(0,s.jsx)("h2",{className:"mtp-analytics__section-title text-sm font-semibold text-foreground",children:"Gross Profit vs Loss"}),(0,s.jsx)("div",{className:"mtp-analytics__progress-track mt-3",children:(0,s.jsx)("div",{className:"mtp-analytics__progress-fill transition-all duration-500 ease-out motion-reduce:transition-none",style:{width:"".concat(H?ek>0?eN/ek*100:50:0,"%")}})}),(0,s.jsxs)("div",{className:"mt-2 flex items-center justify-between text-xs",children:[(0,s.jsx)("span",{className:"text-foreground",children:x((0,m.jT)(null==U?void 0:U.gross_profits,{showSign:!0}))}),(0,s.jsx)("span",{className:"text-muted-foreground",children:x((0,m.jT)((null==U?void 0:U.gross_losses)!=null?-Math.abs(U.gross_losses):null,{showSign:!0}))})]})]})]}),(0,s.jsxs)(b,{className:"hidden md:grid gap-4 sm:grid-cols-2 xl:grid-cols-4",children:[(0,s.jsx)(_,{label:"Trades This Week",value:V?"â¦":String($)}),(0,s.jsx)(_,{label:"Expectancy ($)",value:x((0,m.jT)(null==U?void 0:U.expectancy_dollars,{showSign:!0})),tone:(null==U?void 0:U.expectancy_dollars)==null?"neutral":U.expectancy_dollars>=0?"gain":"loss"}),(0,s.jsx)(_,{label:"Gross Profits",value:x((0,m.jT)(null==U?void 0:U.gross_profits,{showSign:!0})),tone:(null==U?void 0:U.gross_profits)!=null&&U.gross_profits>0?"gain":"neutral"}),(0,s.jsx)(_,{label:"Gross Losses",value:x((0,m.jT)((null==U?void 0:U.gross_losses)!=null?-Math.abs(U.gross_losses):null,{showSign:!0})),tone:(null==U?void 0:U.gross_losses)!=null&&U.gross_losses>0?"loss":"neutral"}),(0,s.jsx)(_,{label:"Trades / Session",value:x((0,m.dd)(null==U?void 0:U.trades_per_session))}),(0,s.jsx)(_,{label:"Avg Hold (Wins)",value:x((0,m.ih)(null==U?void 0:U.avg_hold_win_minutes))}),(0,s.jsx)(_,{label:"Avg Hold (Losses)",value:x((0,m.ih)(null==U?void 0:U.avg_hold_loss_minutes))}),(0,s.jsxs)("div",{className:"mtp-analytics__metric mtp-analytics__metric--dense xl:col-span-4",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Hold Time Comparison"}),(0,s.jsxs)("div",{className:"mt-3 space-y-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"mb-1.5 flex items-center justify-between text-[11px]",children:[(0,s.jsx)("span",{className:"font-medium text-foreground",children:"Wins"}),(0,s.jsx)("span",{className:"text-muted-foreground",children:x((0,m.ih)(ew))})]}),(0,s.jsx)("div",{className:"mtp-analytics__progress-track mt-1.5",children:(0,s.jsx)("div",{className:"mtp-analytics__progress-fill transition-all duration-500 ease-out motion-reduce:transition-none",style:{width:"".concat(H?eS/eC*100:0,"%")}})})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"mb-1.5 flex items-center justify-between text-[11px]",children:[(0,s.jsx)("span",{className:"font-medium text-foreground",children:"Losses"}),(0,s.jsx)("span",{className:"text-muted-foreground",children:x((0,m.ih)(eA))})]}),(0,s.jsx)("div",{className:"mtp-analytics__progress-track mt-1.5",children:(0,s.jsx)("div",{className:"mtp-analytics__progress-fill mtp-analytics__progress-fill--dim transition-all duration-500 ease-out motion-reduce:transition-none",style:{width:"".concat(H?eT/eC*100:0,"%")}})})]})]}),(0,s.jsx)("p",{className:"mt-3 text-[11px] text-muted-foreground",children:eM})]})]}),(0,s.jsxs)(b,{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex items-end justify-between gap-3",children:[(0,s.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:"Behavior review"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"All-time"})]}),(0,s.jsxs)("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.5fr)_minmax(0,1fr)]",children:[(0,s.jsxs)("div",{className:"mtp-analytics__metric mtp-analytics__metric--dense",children:[(0,s.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,s.jsx)("p",{className:"text-xs font-medium text-foreground",children:"Daily P&L Extremes"}),(0,s.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:[eu.length," days"]})]}),em.length<2?(0,s.jsx)("div",{className:"flex h-[170px] items-center justify-center font-mono text-sm text-muted-foreground",children:p}):(0,s.jsxs)("svg",{ref:er,viewBox:"0 0 ".concat(620," ").concat(152),className:"h-[170px] w-full",role:"img","aria-label":"Daily cumulative profit and loss extremes",tabIndex:0,style:{touchAction:"none"},onMouseMove:eG,onMouseEnter:eG,onMouseLeave:eY,onBlur:eY,onPointerDown:e=>{if(!(eh.length<2)&&(eJ(e.clientX),"touch"===e.pointerType||"pen"===e.pointerType)){var t,a;e.preventDefault(),et(!0),null==(t=(a=e.currentTarget).setPointerCapture)||t.call(a,e.pointerId)}},onPointerMove:e=>{ee&&(("touch"===e.pointerType||"pen"===e.pointerType)&&e.preventDefault(),eJ(e.clientX))},onPointerUp:eZ,onPointerCancel:eZ,children:[(0,s.jsx)("defs",{children:(0,s.jsxs)("linearGradient",{id:"analyticsBehaviorAreaFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,s.jsx)("stop",{offset:"0%",stopColor:"var(--orange)",stopOpacity:"0.2"}),(0,s.jsx)("stop",{offset:"100%",stopColor:"var(--orange)",stopOpacity:"0.02"})]})}),(0,s.jsx)("g",{className:"text-border/45",children:[0,1,2,3].map(e=>(0,s.jsx)("line",{x1:12,y1:12+42.666666666666664*e,x2:608,y2:12+42.666666666666664*e,stroke:"currentColor",strokeWidth:"1"},"mini-h-".concat(e)))}),(0,s.jsx)("path",{d:ex,fill:"url(#analyticsBehaviorAreaFill)"}),(0,s.jsx)("path",{d:ep,fill:"none",stroke:"var(--orange)",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",pathLength:1,strokeDasharray:1,strokeDashoffset:+!H,className:"transition-all duration-500 ease-out motion-reduce:transition-none"}),eb>=0&&eh[eb]&&(0,s.jsx)("circle",{cx:eh[eb].x,cy:eh[eb].y,r:"3.5",fill:"var(--orange)",stroke:"var(--term-line-strong)",strokeWidth:"1.25"}),ev>=0&&eh[ev]&&(0,s.jsx)("circle",{cx:eh[ev].x,cy:eh[ev].y,r:"3.5",fill:"var(--orange)",fillOpacity:"0.65",stroke:"var(--term-line-strong)",strokeWidth:"1.25"}),eW&&(0,s.jsxs)("g",{children:[(0,s.jsx)("line",{x1:eW.x,y1:12,x2:eW.x,y2:140,stroke:"var(--orange)",strokeOpacity:"0.35",strokeWidth:"1.5",strokeDasharray:"3 4"}),(0,s.jsx)("circle",{cx:eW.x,cy:eW.y,r:"4",fill:"var(--orange)",stroke:"var(--term-line-strong)",strokeWidth:"1.5"}),(0,s.jsxs)("g",{transform:"translate(".concat(eO,", ").concat(16,")"),children:[(0,s.jsx)("rect",{width:eF,height:ea?48:36,rx:1,className:"mtp-analytics__tooltip-box",strokeWidth:"1"}),(0,s.jsx)("text",{x:10,y:ea?19:15,className:(0,o.cn)("mtp-analytics__tooltip-title",ea?"text-[11px]":"text-[10px]"),children:null!=Y&&eu[Y]?h(eu[Y].date):"Daily P&L"}),(0,s.jsx)("text",{x:10,y:ea?35:29,className:(0,o.cn)("mtp-analytics__tooltip-value",ea?"text-[11px]":"text-[10px]"),children:"Daily: ".concat((0,m.jT)(eW.value,{showSign:!0}))})]})]}),(0,s.jsx)("text",{x:12,y:150,className:"fill-muted-foreground text-[11px]",children:eu[0]?h(eu[0].date):"Start"}),(0,s.jsx)("text",{x:608,y:150,textAnchor:"end",className:"fill-muted-foreground text-[11px]",children:eu[eu.length-1]?h(eu[eu.length-1].date):"Now"})]})]}),(0,s.jsxs)("div",{className:"grid gap-3",children:[(0,s.jsxs)("div",{className:"mtp-analytics__metric mtp-analytics__metric--dense",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"% Green Days"}),(0,s.jsx)("p",{className:"mt-1 text-base font-semibold text-foreground",children:x((0,m.hz)(null==U?void 0:U.green_days_pct))}),(0,s.jsx)("div",{className:"mtp-analytics__progress-track mt-2",children:(0,s.jsx)("div",{className:"mtp-analytics__progress-fill transition-all duration-500 ease-out motion-reduce:transition-none",style:{width:"".concat(H?eU:0,"%")}})})]}),(0,s.jsxs)("div",{className:"mtp-analytics__metric mtp-analytics__metric--dense",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"First Trade Win Rate"}),(0,s.jsx)("p",{className:"mt-1 text-base font-semibold text-foreground",children:x((0,m.hz)(null==U?void 0:U.first_trade_win_rate_pct))}),(0,s.jsx)("div",{className:"mtp-analytics__progress-track mt-2",children:(0,s.jsx)("div",{className:"mtp-analytics__progress-fill transition-all duration-500 ease-out motion-reduce:transition-none",style:{width:"".concat(H?eq:0,"%")}})})]})]})]}),(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-3",children:[(0,s.jsx)(_,{label:"Longest Loss Streak",value:x((0,m.dd)(null==U?void 0:U.consecutive_losses_max))}),(0,s.jsx)(_,{label:"Post-Loss Next Trade Avg P&L",value:x((0,m.jT)(null==U?void 0:U.post_loss_trade_pnl_avg,{showSign:!0}))}),(0,s.jsx)(_,{label:"Largest Loss",value:x((0,m.jT)(null==U?void 0:U.largest_loss,{showSign:!0})),tone:"loss"}),(0,s.jsx)(_,{label:"Best Day P&L",value:x((0,m.jT)(null==U?void 0:U.best_day_pnl,{showSign:!0})),tone:"gain"}),(0,s.jsx)(_,{label:"Worst Day P&L",value:x((0,m.jT)(null==U?void 0:U.worst_day_pnl,{showSign:!0})),tone:"loss"}),(0,s.jsx)(_,{label:"Breakeven Rate",value:x((0,m.hz)(null==U?void 0:U.breakeven_rate_pct))})]})]})]}),eL&&!eP&&(0,s.jsx)("div",{role:"region","aria-label":"Pro performance review locked",className:"mtp-analytics__lock-overlay absolute inset-0 z-10 flex items-start justify-center p-4 pt-8 md:pt-10",children:(0,s.jsxs)("div",{className:"mtp-analytics__lock-card w-full max-w-md p-6 text-center",children:[(0,s.jsx)("p",{className:"text-lg font-semibold text-foreground",children:"Deeper performance review is a Pro feature"}),(0,s.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Upgrade to Pro to unlock the deeper metrics and behavior review below your core scorecard."}),(0,s.jsx)("button",{type:"button",onClick:()=>
1{if(E)return void E();window.location.assign("/?tab=pricing&next=%2F%3Ftab%3Danalytics")},className:"mtp-analytics__cta mt-4 w-full sm:w-auto px-4 py-2 text-sm font-semibold transition-colors",children:"Upgrade to Pro"})]})})]}),I.length>0?(0,s.jsxs)(b,{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"Behavior review"}),(0,s.jsx)("h2",{className:"mt-1 text-sm font-semibold text-foreground",children:"Trade review highlights"})]}),(0,s.jsxs)("span",{className:"text-xs text-muted-foreground",children:[I.length," surfaced"]})]}),(0,s.jsx)("div",{className:"grid gap-3 xl:grid-cols-2",children:I.map(e=>(0,s.jsxs)("article",{className:"rounded-2xl border border-border bg-background/70 p-4 shadow-sm",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:e.title}),(0,s.jsx)("p",{className:"mt-2 text-sm leading-relaxed text-muted-foreground",children:e.description}),e.examples&&e.examples.length>0?(0,s.jsx)("ul",{className:"mt-3 space-y-2 text-xs text-muted-foreground",children:e.examples.map(e=>(0,s.jsx)("li",{className:"rounded-xl border border-border/70 bg-muted/30 px-3 py-2",children:e},e))}):null]},e.id))})]}):null]})]})})}},32450:(e,t,a)=>{a.d(t,{FH:()=>n});var s=a(25991);let n=s.dp;(0,s.Op)()},33520:(e,t,a)=>{a.d(t,{l:()=>i});var s=a(12115),n=a(1495),r=a(32450),l=a(40254);function i(e){let{isAuthenticated:t}=(0,l.J)(),a=(0,n.IT)(r.FH.trades.list,t?{}:"skip"),i=function(){let e=new Date,t=e.getDay(),a=new Date(e);return a.setDate(e.getDate()+(0===t?-6:1-t)),a.setHours(0,0,0,0),a.toISOString()}();return{tradesThisWeek:(0,s.useMemo)(()=>a?a.filter(e=>new Date(e._creationTime).toISOString()>=i).length:0,[a,i]),isLoading:t&&void 0===a,refetch:()=>{}}}},35102:(e,t,a)=>{a.d(t,{b:()=>_});var s=a(95155),n=a(12115),r=a(35299),l=a(43465),i=a(61362),o=a(52056),c=a(65506),d=a(29502),u=a(95740),m=a(93499),p=a(25016),x=a(99331);function h(e,t){var a,s,n;let r=new Intl.DateTimeFormat("en-US",{timeZone:t,weekday:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(e),l=e=>{var t,a;return Number(null!=(a=null==(t=r.find(t=>t.type===e))?void 0:t.value)?a:"0")},i=null!=(s=null==(a=r.find(e=>"weekday"===e.type))?void 0:a.value)?s:"Sun";return{year:l("year"),month:l("month"),day:l("day"),hour:l("hour"),minute:l("minute"),second:l("second"),weekday:null!=(n=({Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6})[i])?n:0}}function g(e,t,a,s,n,r){let l=new Date(Date.UTC(t,a-1,s,n,r,0)),i=h(l,e),o=Date.UTC(i.year,i.month-1,i.day,i.hour,i.minute,i.second),c=Date.UTC(t,a-1,s,n,r,0);return new Date(l.getTime()-(o-c))}function f(e){let t="string"==typeof e.timeZone&&e.timeZone.trim()?e.timeZone.trim():"America/Ne
1w_York",a=Array.isArray(e.daysOfWeek)?e.daysOfWeek.map(e=>Number(e)).filter(e=>Number.isInteger(e)&&e>=0&&e<=6):[],s=Number(e.hour),n=Number(e.minute);if(a.length>0&&Number.isInteger(s)&&s>=0&&s<=23&&Number.isInteger(n)&&n>=0&&n<=59)return{timeZone:t,daysOfWeek:a,hour:s,minute:n};let r=("string"==typeof e.expression?e.expression.trim():"").match(/^(\d{1,2})\s+(\d{1,2})\s+\*\s+\*\s+([\d,*-]+)$/);if(!r)return null;let l=Number(r[1]),i=Number(r[2]),o=r[3],c="*"===o?[0,1,2,3,4,5,6]:"1-5"===o?[1,2,3,4,5]:o.split(",").map(e=>Number(e)).filter(e=>Number.isInteger(e)&&e>=0&&e<=6);return 0===c.length?null:{timeZone:t,daysOfWeek:c,hour:i,minute:l}}function b(e){if(!e)return null;let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?null:t}function v(e){let{status:t}=e,a="running"===t?{label:"Running",icon:(0,s.jsx)(r.A,{size:10,className:"task-card__spin","aria-hidden":"true"}),className:"task-card__status-badge--running"}:"delivering"===t?{label:"Delivering to Inbox",icon:(0,s.jsx)(l.A,{size:10,"aria-hidden":"true"}),className:"recurring-card__status-badge--delivering"}:"completed"===t?{label:"Completed",icon:(0,s.jsx)(i.A,{size:10,"aria-hidden":"true"}),className:"task-card__status-badge--complete"}:"error"===t?{label:"Last Run Failed",icon:(0,s.jsx)(o.A,{size:10,"aria-hidden":"true"}),className:"task-card__status-badge--error"}:"paused"===t?{label:"Paused",icon:(0,s.jsx)(c.A,{size:10,"aria-hidden":"true"}),className:"task-card__status-badge--cancelled"}:{label:"Scheduled",icon:(0,s.jsx)(d.A,{size:10,"aria-hidden":"true"}),className:"recurring-card__status-badge--scheduled"};return(0,s.jsxs)("span",{className:(0,p.cn)("task-card__status-badge",a.className),role:"status",children:[a.icon,a.label]})}function _(e){let{title:t,type:a,status:r,schedule:l,deliveryTarget:i,note:o,onViewInJobs:c,className:d}=e,[_,j]=(0,n.useState)(()=>Date.now());(0,n.useEffect)(()=>{let e=window.setInterval(()=>j(Date.now()),1e3);return()=>window.clearInterval(e)},[]);let y=b(l.nextRun),N=b(l.lastRun),k=(0,n.useMemo)(()=>N||(y?function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Date,a=f(e);if(!a)return null;for(let e=0;e<14;e+=1){let s=h(new Date(t.getTime()-24*e*36e5),a.timeZone);if(!a.daysOfWeek.includes(s.weekday))continue;let n=g(a.timeZone,s.year,s.month,s.day,a.hour,a.minute);if(n.getTime()<t.getTime())return n}return null}(l,y):null),[N,y,l]),w=(0,n.useMemo)(()=>y?function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Date,a=f(e);if(!a)return null;for(let e=0;e<14;e+=1){let s=h(new Date(t.getTime()+24*e*36e5),a.timeZone);if(!a.daysOfWeek.includes(s.weekday))continue;let n=g(a.timeZone,s.year,s.month,s.day,a.hour,a.minute);if(n.getTime()>t.getTime())return n}return null}(l,y):null,[y,l]),A=y?Math.max(0,y.getTime()-_):0,S=k&&y?Math.max(1,y.getTime()-k.getTime()):1,T=k&&y?Math.min(S,Math.max(0,_-k.getTime())):0,C="running"===r||"delivering"===r?100:Math.max(0,Math.min(100,Math.round(T/S*100))),M="running"===r?"Run in progress":"delivering"===r?"Delivering to Inbox":y?"Next run in ".concat(function(e){let t=Math.max(0,Math.floor(e/1e3));return[Math.floor(t/3600),Math.floor(t%3600/60),t%60].map(e=>String(e).padStart(2,"0")).join(":")}(A)):"Awaiting schedule";return(0,s.jsxs)("article",{className:(0,p.cn)("task-card recurring-card","running"===r&&"task-card--running recurring-card--running","delivering"===r&&"recurring-card--delivering","completed"===r&&"task-card--complete recurring-card--complete","error"===r&&"task-card--error recurring-card--error","paused"===r&&"task-card--cancelled recurring-card--paused",d),"aria-label":"Recurring task: ".concat(t),children:[(0,s.jsx)("div",{className:(0,p.cn)("task-card__accent","completed"===r?"task-card__accent--complete":"recurring-card__accent"),"aria-hidden":"true"}),(0,s.jsxs)("div",{className:"task-card__inner recurring-card__inner",children:[(0,s.jsxs)("div",{className:"task-card__header",children:[(0,s.jsxs)("div",{className:"task-card__header-left",children:[(0,s.jsx)(u.A,{size:14,className:"task-card__lightning recurring-card__spark","aria-hidden":"true"}),(0,s.jsx)("span",{className:"task-card__label",children:"Recurring Task Scheduled"})]}),(0,s.jsx)(v,{status:r})]}),(0,s.jsxs)("div",{className:"task-card__title-row",children:[(0,s.jsx)("h3",{className:"task-card__title",children:t}),(0,s.jsx)("span",{className:"task-card__type-badge",children:a})]}),(0,s.jsxs)("div",{className:"task-card__meta recurring-card__meta",children:[(0,s.jsx)("span",{children:l.humanReadable}),(0,s.jsxs)("span",{children:["Results delivered to ",i]})]}),(0,s.jsxs)("div",{className:"recurring-card__timeline","aria-label":"Recurring timeline",children:[(0,s.jsx)("div",{className:"recurring-card__timeline-line","aria-hidden":"true"}),[{label:"Last run",time:N},{label:"Next run",time:y},{label:"Following run",time:w}].map((e,t)=>{var a;return(0,s.jsxs)("div",{className:"recurring-card__timeline-item",children:[(0,s.jsx)("span",{className:(0,p.cn)("recurring-card__timeline-dot","Next run"===e.label&&"recurring-card__timeline-dot--active"),"aria-hidden":"true"}),(0,s.jsx)("span",{className:"recurring-card__timeline-label",children:e.label}),(0,s.jsx)("span",{className:"recurring-card__timeline-time",children:(a=e.time)?a.toLocaleStr
1ing("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):"Waiting for first run"})]},"".concat(e.label,"-").concat(t))})]}),(0,s.jsxs)("div",{className:"task-card__progress recurring-card__progress","aria-label":"Time until next run",children:[(0,s.jsx)(x.f,{value:C,label:"".concat(C,"%")}),(0,s.jsx)("div",{className:"recurring-card__countdown",children:M})]}),o?(0,s.jsx)("div",{className:"task-card__note recurring-card__note",role:"note",children:o}):null,(0,s.jsx)("div",{className:"task-card__footer",children:(0,s.jsx)("div",{className:"task-card__footer-links",children:c?(0,s.jsxs)("button",{type:"button",className:"task-card__link",onClick:e=>{e.preventDefault(),e.stopPropagation(),c()},"aria-label":"View scheduled task in Jobs",children:["View in Jobs",(0,s.jsx)(m.A,{size:11,"aria-hidden":"true"})]}):null})})]})]})}},40254:(e,t,a)=>{a.d(t,{J:()=>r});var s=a(1495),n=a(32450);function r(){let{isAuthenticated:e,isLoading:t}=(0,s.Z)(),a=(0,s.IT)(n.FH.profile.currentUser,e?{}:"skip"),r=t||e&&void 0===a,l=e&&!!a;return{user:null!=a?a:null,isAuthenticated:l,isLoading:r,status:r?"loading":l?"authenticated":"unauthenticated"}}},40875:(e,t,a)=>{a.d(t,{$C:()=>u,S0:()=>p,TG:()=>c,po:()=>m,tX:()=>o});let s=new Set(["","null","undefined"]),n=/\.(png|jpe?g|webp|gif|bmp|svg)(?:[?#].*)?$/i,r=/^(?:\/|\.\/*)?browser\/[0-9a-f-]{36}\.(png|jpe?g|webp|gif|bmp|svg)(?:[?#].*)?$/i,l=/\/api\/(?:landing\/)?chat\/assets\/(?:proxy|s3)\?k=([^)\s\]]+)/gi;function i(e){return"landing"===e?"/api/landing/chat/assets/proxy":"/api/chat/assets/proxy"}function o(e,t){var a;return"".concat(i(null!=(a=null==t?void 0:t.surface)?a:"chat"),"?k=").concat(encodeURIComponent(e))}function c(e){if(!e)return[];let t=[],a=new Set;for(let s of e.matchAll(l)){let e,n=s[1];if(n){try{e=decodeURIComponent(n).trim()}catch(e){continue}!e||a.has(e)||(a.add(e),t.push(e))}}return t}function d(e){if("string"!=typeof e)return null;let t=e.trim();return!t||s.has(t.toLowerCase())?null:t}function u(e,t){var a,s;let l=d(e);return l?function(e){if(e.startsWith("data:image/")||e.startsWith("/api/chat/assets/proxy?")||e.startsWith("/api/chat/assets/s3?")||e.startsWith("/api/landing/chat/assets/proxy?")||e.startsWith("http://")||e.startsWith("https://"))return!0;try{let t=new URL(e);return"http:"===t.protocol||"https:"===t.protocol}catch(e){return!1}}(l)?l:/^MEDIA:\s*/i.test(l)||/^sandbox:/i.test(l)||(l.startsWith("/root/.openclaw/media/")||l.startsWith("/.openclaw/media/")?n.test(l):!!r.test(l))?(s=null!=(a=null==t?void 0:t.surface)?a:"chat","".concat(i(s),"?u=").concat(encodeURIComponent(l))):null:null}function m(e,t){return e.trim()?e.replace(/\{\s*"images"\s*:\s*\[[\s\S]*?\]\s*\}/g,e=>(function(e,t){try{let a=JSON.parse(e);if(!Array.isArray(a.images))return e;let s=a.images.map(e=>u(e,t)).filter(e=>!!e);if(0===s.length)return e;return s.map((e,t)=>".concat(e,")")).join("\n\n")}catch(t){return e}})(e,t)).split("\n").map(e=>{let a=e.trim();if(!a)return e;let s=u(a,t);return s?""):e}).join("\n"):e}function p(e){let t=d(e);if(!t)return null;if(t.startsWith("/")||t.startsWith("#")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("mailto:")||t.startsWith("tel:"))return t;try{let e=new URL(t).protocol.toLowerCase();if("http:"===e||"https:"===e||"mailto:"===e||"tel:"===e)return t;return null}catch(e){return null}}},49654:(e,t,a)=>{a.d(t,{ks:()=>s,ls:()=>n,sE:()=>r});let s={agent:"Coach","my-trades":"Journal",analytics:"Performance",jobs:"Analyst Work",connections:"Broker Acce
1ss",inbox:"Briefings"},n={agent:"CCH","my-trades":"JRN",analytics:"PRF",jobs:"WRK",connections:"BRK",inbox:"BRF"},r={productName:"MyTradingPal",appTagline:"Your trading coach",coachIntro:"Coach is in your corner, reviewing your trades and helping you improve.",auth:{signInToCoach:"Sign in to keep your coaching progress, past sessions, and broker access in one place.",signInToJournal:"Sign in to save your journal and let Coach review what you actually did.",signInToPerformance:"Sign in to unlock your performance review and let Coach track the patterns affecting profitability.",signInToBrokerAccess:"Sign in to connect your broker so Coach can review real account activity instead of memory.",signInToBriefings:"Sign in to save briefings, findings, and updates Coach sends back to you.",signInToAnalystWork:"Sign in to save research runs and recurring review work Coach sets up for you."}}},54679:(e,t,a)=>{a.d(t,{Cf:()=>d,Es:()=>m,L3:()=>p,c7:()=>u,lG:()=>i,rr:()=>x});var s=a(95155),n=a(12115),r=a(89631),l=a(25016);let i=r.bL;r.l9;let o=r.ZL;r.bm;let c=n.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(r.hJ,{ref:t,className:(0,l.cn)("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...n})});c.displayName=r.hJ.displayName;let d=n.forwardRef((e,t)=>{let{className:a,children:n,...i}=e;return(0,s.jsxs)(o,{children:[(0,s.jsx)(c,{}),(0,s.jsx)(r.UC,{ref:t,className:(0,l.cn)("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 rounded-xl border bg-background p-0 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",a),...i,children:n})]})});d.displayName=r.UC.displayName;let u=e=>{let{className:t,...a}=e;return(0,s.jsx)("div",{className:(0,l.cn)("flex flex-col space-y-1.5 text-center sm:text-left",t),...a})};u.displayName="DialogHeader";let m=e=>{let{className:t,...a}=e;return(0,s.jsx)("div",{className:(0,l.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...a})};m.displayName="DialogFooter";let p=n.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(r.hE,{ref:t,className:(0,l.cn)("text-lg font-semibold leading-none tracking-tight",a),...n})});p.displayName=r.hE.displayName;let x=n.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(r.VY,{ref:t,className:(0,l.cn)("text-sm text-muted-foreground",a),...n})});x.displayName=r.VY.displayName},55100:(e,t,a)=>{a.d(t,{L:()=>v});var s=a(95155),n=a(12115),r=a(61362),l=a(35299),i=a(78874),o=a(99051),c=a(56154),d=a(93499),u=a(65229),m=a(6504),p=a(5459),x=a(25016),h=a(99331);function g(e){if(e<60)return"".concat(e,"s");let t=Math.floor(e/60),a=e%60;return 0===a?"".concat(t,"m"):"".concat(t,"m ").concat(a,"s")}function f(e){let{status:t}=e;switch(t){case"done":return(0,s.jsx)(r.A,{size:13,className:"task-card__step-icon task-card__step-icon--done","aria-label":"Done"});case"active":return(0,s.jsx)(l.A,{size:13,className:"task-card__step-icon task-card__step-icon--active task-card__spin","aria-label":"In progress"});case"error":return(0,s.jsx)(i.A,{size:13,className:"task-card__step-icon task-card__step-icon--error","aria-label":"Error"});default:return(0,s.jsx)(o.A,{size:13,className:"task-card__step-icon task-card__step-icon--pending","aria-label":"Pending"})}}function b(e){let{status:t}=e;return(0,s.jsxs)("span",{className:(0,x.cn)("task-card__status-badge",("queued"===t||"running"===t)&&"task-card__status-badge--running","complete"===t&&"task-card__status-badge--complete","error"===t&&"task-card__status-badge--error","cancelled"===t&&"task-card__status-badge--cancelled"),role:"status",children:[("queued"===t||"running"===t)&&(0,s.jsx)(l.A,{size:10,className:"task-card__spin","aria-hidden":"true"}),"complete"===t&&(0,s.jsx)(r.A,{size:10,"aria-hidden":"true"}),"queued"===t?"Queued":"running"===t?"In Progress":"complete"===t?"Complete":"error"===t?"Failed":"Cancelled"]})}function v(e){let{title:t,type:a,status:r,steps:l,startedAt:i,estimatedMinutes:o,progressPercent:v,note:_,summary:j,onViewInJobs:y,onViewReport:N,onCancel:k,className:w}
1=e,[A,S]=(0,n.useState)("complete"===r);(0,n.useEffect)(()=>{if("complete"===r&&!A){let e=setTimeout(()=>S(!0),50);return()=>clearTimeout(e)}},[r,A]);let T="queued"===r||"running"===r,C="complete"===r,M="error"===r,E="number"==typeof v?Math.max(0,Math.min(100,Math.round(v))):C?100:void 0;return(0,s.jsxs)("article",{className:(0,x.cn)("task-card",T&&"task-card--running",C&&"task-card--complete",M&&"task-card--error","cancelled"===r&&"task-card--cancelled",w),"aria-label":"Task: ".concat(t),children:[(0,s.jsx)("div",{className:(0,x.cn)("task-card__accent",C?"task-card__accent--complete":"task-card__accent--running"),"aria-hidden":"true"}),(0,s.jsxs)("div",{className:"task-card__inner",children:[(0,s.jsxs)("div",{className:"task-card__header",children:[(0,s.jsxs)("div",{className:"task-card__header-left",children:[(0,s.jsx)(c.A,{size:14,className:"task-card__lightning","aria-hidden":"true"}),(0,s.jsx)("span",{className:"task-card__label",children:"Research Task Spawned"})]}),(0,s.jsx)(b,{status:r})]}),(0,s.jsxs)("div",{className:"task-card__title-row",children:[(0,s.jsx)("h3",{className:"task-card__title",children:t}),(0,s.jsx)("span",{className:"task-card__type-badge",children:a})]}),(0,s.jsxs)("div",{className:"task-card__meta",children:[(0,s.jsxs)("span",{children:["Started: ",i.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})]}),o&&T&&(0,s.jsxs)("span",{children:["Est. ",o,"â",o+2," min"]})]}),(0,s.jsx)("div",{className:"task-card__progress","aria-label":"Task progress",children:(0,s.jsx)(h.f,{value:"queued"===r?void 0:E,indeterminate:"queued"===r,label:"queued"!==r&&"number"==typeof E?"".concat(E,"%"):void 0})}),_&&(0,s.jsx)("div",{className:"task-card__note",role:"note",children:_}),l.length>0&&(0,s.jsx)("ol",{className:"task-card__steps","aria-label":"Task steps",children:l.map(e=>(0,s.jsxs)("li",{className:(0,x.cn)("task-card__step","active"===e.status&&"task-card__step--active"),children:[(0,s.jsx)(f,{status:e.status}),(0,s.jsx)("span",{className:"task-card__step-label",children:e.label}),void 0!==e.elapsed&&(0,s.jsx)("span",{className:"task-card__step-elapsed","aria-label":"Elapsed: ".concat(g(e.elapsed)),children:g(e.elapsed)})]},e.id))}),C&&j&&(0,s.jsx)("div",{className:"task-card__summary",role:"note","aria-label":"Task summary",children:(0,s.jsx)("div",{className:"task-card__markdown",children:(0,s.jsx)(m.oz,{remarkPlugins:[p.A],components:{h1:e=>{let{children:t}=e;return(0,s.jsx)("h4",{children:t})},h2:e=>{let{children:t}=e;return(0,s.jsx)("h4",{children:t})},h3:e=>{let{children:t}=e;return(0,s.jsx)("h5",{children:t})},p:e=>{let{children:t}=e;return(0,s.jsx)("p",{children:t})},ul:e=>{let{children:t}=e;return(0,s.jsx)("ul",{children:t})},ol:e=>{let{children:t}=e;return(0,s.jsx)("ol",{children:t})},li:e=>{let{children:t}=e;return(0,s.jsx)("li",{children:t})},strong:e=>{let{children:t}=e;return(0,s.jsx)("strong",{children:t})},em:e=>{let{children:t}=e;return(0,s.jsx)("em",{children:t})},code:e=>{let{children:t,className:a}=e;return a?(0,s.jsx)("pre",{className:"task-card__markdown-pre",children:(0,s.jsx)("code",{children:t})}):(0,s.jsx)("code",{className:"task-card__markdown-code",children:t})},pre:e=>{let{children:t}=e;return(0,s.jsx)("pre",{className:"task-card__markdown-pre",children:t})},blockquote:e=>{let{children:t}=e;return(0,s.jsx)("blockquote",{children:t})},a:e=>{let{href:t,children:a}=e;return(0,s.jsx)("a",{href:t,target:"_blank",rel:"noreferrer",children:a})}},children:j})})}),(0,s.jsxs)("div",{className:"task-card__footer",children:[(0,s.jsx)("div",{className:"task-card__footer-links",children:C&&N?(0,s.jsxs)("button",{type:"button",className:"task-card__link",onClick:e=>{e.preventDefault(),e.stopPropagation(),N()},"aria-label":"View full briefing",children:["View briefing",(0,s.jsx)(d.A,{size:11,"aria-hidden":"true"})]}):y?(0,s.jsxs)("button",{type:"button",className:"task-card__link",onClick:e=>{e.preventDefault(),e.stopPropagation(),y()},"aria-label":"View in Analyst Work",children:["View in Analyst Work",(0,s.jsx)(d.A,{size:11,"aria-hidden":"true"})]}):null}),T&&k&&(0,s.jsxs)("button",{type:"button",className:"task-card__cancel",onClick:e=>{e.preventDefault(),e.stopPropagation(),k()},"aria-label":"Cancel task",children:[(0,s.jsx)(u.A,{size:12,"aria-hidden":"true"}),"Cancel"]})]})]})]})}},56299:(e,t,a)=>{a.d(t,{v:()=>i});var s=a(12115),n=a(1495),r=a(32450),l=a(40254);function i(e){let{isAuthenticated:t}=(0,l.J)(),a=(0,n.IT)(r.FH.tradingStats.getLatest,t&&e?{}:"skip");return{stats:(0,s.useMemo)(()=>{var e,t,s,n,r,l,i,o,c,d,u,m,p,x,h,g;return a?{id:a._id,user_id:a.userId,period_start:a.periodStart,expectancy_r:null!=(e=a.expectancyR)?e:null,expectancy_dollars:null!=(t=a.expectancyDollars)?t:null,rule_adherence_pct:null!=(s=a.ruleAdherencePct)?s:null,max_drawdown_pct:null!=(n=a.maxDrawdownPct)?n:null,avg_win:null!=(r=a.avgWin)?r:null,avg_loss:null!=(l=a.avgLoss)?l:null,payoff_ratio:null!=(i=a.payoffRatio)?i:null,win_rate_pct:null!=(o=a.winRatePct)?o:null,profit_factor:null!=(c=a.profitFactor)?c:null,avg_hold_win_minutes:null!=(d=a.avgHoldWinMinutes)?d:null,avg_hold_loss_minutes:null!=(u=a.avgHoldLossMinutes)?u:null,trades_per_session:null!=(m=a.tradesPerSession)?m:null,total_trades:null!=(p=a.totalTrades)?p:0,gross_profits:null!=(x=a.grossProfits)?x:null,gross_losses:null!=(h=a.grossLosses)?h:null,r_multiples:null!=(g=a.rMultiples)?g:null,consecutive_losses_max:null,post_loss_trade_pnl_avg:null,green_days_pct:null,first_trade_win_rate_pct:null,largest_loss:null,best_day_pnl:null,worst_day_pnl:null,breakeven_rate_pct:null,updated_at:new Date(a._creationTime).toISOString()}:null},[a]),isLoading:void 0===a&&t&&!!e,isUpdating:!1,refresh:()=>{},refetch:()=>{}}}},62532:(e,t,a)=>{a.d(t,{e:()=>G});
1var s=a(95155),n=a(12115),r=a(86651),l=a(65229),i=a(35299),o=a(6132),c=a(99051),d=a(24033),u=a(99331);function m(e){return e.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}function p(e){switch(e){case"research":return"Research";case"analysis":return"Analysis";case"alert":return"Alert";case"scan":return"Scan";case"report":return"Briefing";case"custom":return"Custom";default:return e}}function x(e){let{status:t}=e;return"running"===t?(0,s.jsx)(i.A,{size:16,strokeWidth:2,className:"job-card__status-icon job-card__status-icon--spinning","aria-label":"Running"}):"error"===t?(0,s.jsx)(o.A,{size:16,strokeWidth:2,className:"job-card__status-icon job-card__status-icon--error","aria-label":"Error"}):(0,s.jsx)(c.A,{size:16,strokeWidth:1.5,className:"job-card__status-icon job-card__status-icon--queued","aria-label":"queued"===t?"Queued":"Cancelled"})}function h(e){var t;let{job:a,onExpand:n,onCancel:r,className:i=""}=e,o="running"===a.status||"queued"===a.status,c=null!=(t=a.steps[a.currentStepIndex])?t:null,h=c?"Step ".concat(a.currentStepIndex+1," of ").concat(a.steps.length," â ").concat("active"===c.status?"Est. ".concat(function(e){if(null===e)return"Estimating...";if(e<60)return"".concat(e,"s remaining");let t=Math.floor(e/60),a=e%60;return a>0?"".concat(t,"m ").concat(a,"s remaining"):"".concat(t," min remaining")}(null!==a.estimatedDuration?Math.round(a.estimatedDuration*(1-a.progressPercent/100)):null)):c.label):"".concat(a.steps.length," steps");return(0,s.jsxs)("article",{className:"job-card ".concat(function(e){switch(e){case"running":default:return"job-card--running";case"queued":return"job-card--queued";case"error":return"job-card--error";case"cancelled":return"job-card--cancelled"}}(a.status)," ").concat(i),role:"listitem","aria-label":"Analyst work: ".concat(a.title),children:[(0,s.jsxs)("div",{className:"job-card__row job-card__row--header",children:[(0,s.jsx)(x,{status:a.status}),(0,s.jsx)("span",{className:"job-card__title",children:a.title}),(0,s.jsx)("span",{className:"job-card__type-badge",children:p(a.type)})]}),(0,s.jsxs)("div",{className:"job-card__row job-card__row--meta",children:[(0,s.jsx)("span",{className:"job-card__meta-type",children:"report"===a.type?"Briefing":p(a.type)}),a.startedAt&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"job-card__meta-sep","aria-hidden":"true",children:"\xb7"}),(0,s.jsxs)("span",{className:"job-card__meta-time",children:["Started ",m(a.startedAt)]})]}),!a.startedAt&&a.createdAt&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"job-card__meta-sep","aria-hidden":"true",children:"\xb7"}),(0,s.jsxs)("span",{className:"job-card__meta-time",children:["Queued ",m(a.createdAt)]})]})]}),(0,s.jsx)("div",{className:"job-card__row job-card__row--steps",children:(0,s.jsx)("span",{className:"job-card__step-text",children:h})}),(0,s.jsx)("div",{className:"job-card__row job-card__row--progress",children:(0,s.jsx)(u.f,{value:"queued"===a.status?void 0:a.progressPercent,indeterminate:"queued"===a.status,label:"queued"!==a.status?"".concat(a.progressPercent,"%"):void 0})}),(0,s.jsxs)("div",{className:"job-card__footer",children:[(0,s.jsxs)("button",{type:"button",className:"job-card__expand-btn",onClick:()=>null==n?void 0:n(a.id),"aria-label":"Expand details for ".concat(a.title),children:[(0,s.jsx)(d.A,{size:14,strokeWidth:2,"aria-hidden":"true"}),"View details"]}),o&&(0,s.jsxs)("button",{type:"button",className:"job-card__cancel-btn",onClick:()=>null==r?void 0:r(a.id),"aria-label":"Cancel analyst work: ".concat(a.title),children:[(0,s.jsx)(l.A,{size:12,strokeWidth:2,"aria-hidden":"true"}),"Cancel"]})]})]})}var g=a(5917),f=a(78874),b=a(12108),v=a(37586);function _(e){if(!e)return"0s";let t=Math.floor((Date.now()-e.getTime())/1e3);if(t<60)return"".concat(t,"s");let a=Math.floor(t/60),s=t%60;return s>0?"".concat(a,"m ").concat(s,"s"):"".concat(a,"m")}function j(e){let{status:t}=e;switch(t){case"done":return(0,s.jsx)("span",{className:"expanded-step__icon expanded-step__icon--done","aria-label":"Done",children:(0,s.jsx)(g.A,{size:12,strokeWidth:2.5})});case"active":return(0,s.jsx)("span",{className:"expanded-step__icon expanded-step__icon--active","aria-label":"In progress",children:(0,s.jsx)(i.A,{size:12,strokeWidth:2,className:"job-card__status-icon--spinning"})});case"error":return(0,s.jsx)("span",{className:"expanded-step__icon expanded-step__icon--error","aria-label":"Error",children:(0,s.jsx)(f.A,{size:12,strokeWidth:2})});default:return(0,s.jsx)("span",{className:"expanded-step__icon expanded-step__icon--pending","aria-label":"Pending",children:(0,s.jsx)(c.A,{size:12,strokeWidth:1.5})})}}function y(e){let{job:t,onCollapse:a,onCancel:n,onViewConversation:r,className:o=""}=e,c="running"===t.status||"queued"===t.status,d=_(t.startedAt),u=function(e){if(null===e.estimatedDuration||!e.startedAt)return"Estimating...";let t=Math.floor((Date.now()-e.startedAt.getTime())/1e3),a=Math.max(0,e.estimatedDuration-t);if(0===a)return"Wrapping up...";if(a<60)return"~".concat(a,"s");let s=Math.ceil(a/60);return"~".concat(s," min")}(t),m=function(e){var t,a,s,n,r,l,i;let o=null!=(i=e.metadata)?i:{},c=(null==(a=e.artifact)||null==(t=a.metadata)?void 0:t.resolvedModel)||("string"==typeof o.resolvedModel?o.resolvedModel:null),d="number"==typeof o.retryCount?o.retryCount:null==(n=e.artifact)||null==(s=n.metadata)?void 0:s.retryCount,u="boolean"==typeof o.usedFallback?o.usedFallback:!!(null==(l=e.artifact)||null==(r=l.metadata)?void 0:r.usedF
1allback),m="string"==typeof o.nextRetryAt&&o.nextRetryAt.trim()?o.nextRetryAt:null,p=[];return u&&p.push("Continued on fallback lane"),"number"==typeof d&&d>0&&p.push("".concat(d," retr").concat(1===d?"y":"ies")),c&&p.push("Model ".concat(c)),m&&p.push("Retry scheduled"),p.length>0?p.join(" \xb7 "):null}(t);return(0,s.jsxs)("article",{className:"expanded-job-card expanded-job-card--".concat(t.status," ").concat(o),role:"listitem","aria-label":"Expanded details for analyst work: ".concat(t.title),children:[(0,s.jsxs)("div",{className:"expanded-job-card__header",children:[(0,s.jsxs)("div",{className:"expanded-job-card__title-group",children:["running"===t.status&&(0,s.jsx)(i.A,{size:16,strokeWidth:2,className:"job-card__status-icon--spinning expanded-job-card__spinner","aria-hidden":"true"}),(0,s.jsx)("span",{className:"expanded-job-card__title",children:t.title})]}),(0,s.jsxs)("button",{type:"button",className:"expanded-job-card__collapse-btn",onClick:()=>a(t.id),"aria-label":"Collapse details",children:[(0,s.jsx)(b.A,{size:14,strokeWidth:2,"aria-hidden":"true"}),"Collapse"]})]}),(0,s.jsxs)("div",{className:"expanded-job-card__meta",children:[(0,s.jsx)("span",{children:"report"===t.type?"Briefing":t.type.charAt(0).toUpperCase()+t.type.slice(1)}),t.startedAt&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{"aria-hidden":"true",children:"\xb7"}),(0,s.jsxs)("span",{children:["Started ",t.startedAt.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})]})]}),(0,s.jsx)("span",{"aria-hidden":"true",children:"\xb7"}),(0,s.jsx)("span",{className:"expanded-job-card__id",children:t.id})]}),(0,s.jsx)("div",{className:"expanded-job-card__divider",role:"separator"}),(0,s.jsx)("ol",{className:"expanded-step-list","aria-label":"Review steps",children:t.steps.map((e,a)=>(0,s.jsxs)("li",{className:"expanded-step expanded-step--".concat(e.status),children:[a<t.steps.length-1&&(0,s.jsx)("div",{className:"expanded-step__connector expanded-step__connector--".concat("done"===e.status?"done":"pending"),"aria-hidden":"true"}),(0,s.jsx)(j,{status:e.status}),(0,s.jsx)("span",{className:"expanded-step__label",children:e.label}),(0,s.jsx)("span",{className:"expanded-step__timing",children:"active"===e.status?_(e.startedAt):"done"===e.status?function(e){if(null===e)return"â";if(e<60)return"".concat(e,"s");let t=Math.floor(e/60),a=e%60;return a>0?"".concat(t,"m ").concat(a,"s"):"".concat(t,"m")}(e.duration):""})]},a))}),(0,s.jsxs)("div",{className:"expanded-job-card__timing",children:[(0,s.jsxs)("span",{className:"expanded-job-card__timing-item",children:["Total elapsed: ",(0,s.jsx)("strong",{children:d})]}),"running"===t.status&&(0,s.jsxs)("span",{className:"expanded-job-card__timing-item",children:["Estimated remaining: ",(0,s.jsx)("strong",{children:u})]})]}),m&&(0,s.jsx)("div",{className:"expanded-job-card__timing",children:m}),(0,s.jsxs)("div",{className:"expanded-job-card__actions",children:[(0,s.jsxs)("button",{type:"button",className:"expanded-job-card__btn expanded-job-card__btn--secondary",onClick:()=>null==r?void 0:r(t.conversationId),"aria-label":"View source conversation",children:[(0,s.jsx)(v.A,{size:14,strokeWidth:2,"aria-hidden":"true"}),"View conversation"]}),c&&(0,s.jsxs)("button",{type:"button",className:"expanded-job-card__btn expanded-job-card__btn--danger",onClick:()=>null==n?void 0:n(t.id),"aria-label":"Cancel analyst work: ".concat(t.title),children:[(0,s.jsx)(l.A,{size:14,strokeWidth:2,"aria-hidden":"true"}),"Cancel"]})]})]})}var N=a(26983),k=a(18514),w=a(85921),A=a(53511),S=a(71360);function T(e){let t="string"==typeof e?new Date(e):e,a=new Date,s=new Date(a.getFullYear(),a.getMonth(),a.getDate()),n=new Date(s.getTime()+864e5),r=new Date(t.getFullYear(),t.getMonth(),t.getDate()),l=t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0,timeZoneName:"short"});return r.getTime()===s.getTime()?"Today, ".concat(l):r.getTime()===n.getTime()?"Tomorrow, ".concat(l):t.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0})}function C(e){let{message:t,onConfirm:a,onCancel:n,confirmLabel:r="Confirm",isDanger:l=!1}=e;return(0,s.jsxs)("div",{className:"scheduled-card__confirm",role:"dialog","aria-modal":"true","aria-label":"Confirm action",children:[(0,s.jsx)("p",{className:"scheduled-card__confirm-msg",children:t}),(0,s.jsxs)("div",{className:"scheduled-card__confirm-actions",children:[(0,s.jsx)("button",{type:"button",className:"scheduled-card__confirm-cancel",onClick:n,children:"Cancel"}),(0,s.jsx)("button",{type:"button",className:"scheduled-card__confirm-ok ".concat(l?"scheduled-card__confirm-ok--danger":""),onClick:a,children:r})]})]})}function M(e){let{job:t,onEdit:a,onPause:r,onResume:i,onDelete:o,className:c=""}=e,[d,u]=n.useState(null),m=t.schedule;if(!m)return null;let p=m.isPaused;return(0,s.jsxs)("article",{className:"scheduled-card ".concat(p?"scheduled-card--paused":"scheduled-card--active"," ").concat(c),role:"listitem","aria-label":"Scheduled review: ".concat(t.title),children:[(0,s.jsxs)("div",{className:"scheduled-card__header",children:[(0,s.jsx)(N.A,{size:16,strokeWidth:1.75,className:"scheduled-card__clock-icon ".concat(p?"scheduled-card__clock-icon--paused":""),"aria-hidden":"true"}),(0,s.jsx)("span",{className:"scheduled-card__title",children:t.title}),(0,s.jsx)("span",{className:"scheduled-card__badge ".concat(p?"scheduled-card__badge--paused":"scheduled-card__badge--active"),children:p?"Paused":"Active"})]}),(0,s.jsxs)("p",{className:"scheduled-card__schedule",children:["Runs ",m.humanReadable]}),(0,s.jsxs)("p",{className:"scheduled-card__next",children:[(0,s.jsx)("span",{className:"scheduled-card__field-label",children:"Next:"})," ",T(m.nextRun)]}),m.lastRun&&(0,s.jsxs)("p",{className:"scheduled-card__last",children:[(0,s.jsx)("span",{className:"scheduled-card__field-label",children:"Last:"})," ",T(m.lastRun)," ","success"===m.lastRunStatus?(0,s.jsx)("span",{className:"scheduled-card__last-icon scheduled-card__last-icon--success","aria-label":"Success",children:(0,s.jsx)(g.A,{size:12,strokeWidth:2.5})}):"error"===m.lastRunStatus?(0,s.jsx)("span",{className:"scheduled-card__last-icon scheduled-card__last-icon--error","aria-label":"Error",children:(0,s.jsx)(l.A,{size:12,strokeWidth:2.5})}):null]}),m.deliveryChannels.length>0&&(0,s.jsxs)("div",{className:"scheduled-card__channels",children:[(0,s.jsx)("span",{className:"scheduled-card__field-label",children:"Delivered to:"}),m.deliveryChannels.map(e=>(0,s.jsx)("span",{className:"scheduled-card__channel-badge",children:function(e){switch(e){case"chat":return"Chat";case"telegram":return"Telegram";case"email":return"Email";case"inbox":return"Inbox"}}(e)},e))]}),"pause"===d&&(0,s.jsx)(C,{message:p?"Resume this scheduled review?":"Pause this scheduled review? It won't run again until resumed.",onConfirm:()=>{u(null),p?null==i||i(t.id):null==r||r(t.id)},onCancel:()=>u(null),confirmLabel:p?"Resume":"Pause"}),"delete"===d&&(0,s.jsx)(C,{message:"Permanently delete this scheduled review? This cannot be undone.",onConfirm:()=>{u(null),null==o||o(t.id)},onCancel:()=>u(null),confirmLabel:"Delete",isDanger:!0}),null===d&&(0,s.jsxs)("div",{className:"scheduled-card__actions",children:[(0,s.jsxs)("button",{type:"button",className:"scheduled-card__action-btn",onClick:()=>null==a?void 0:a(t.id),"aria-label":"Edit scheduled review",children:[(0,s.jsx)(k.A,{size:13,strokeWidth:2,"aria-hidden":"true"}),"Edit"]}),(0,s.jsxs)("button",{type:"button",className:"scheduled-card__action-btn",onClick:()=>u("pause"),"aria-label":p?"Resume scheduled review":"Pause scheduled review",children:[p?(0,s.jsx)(w.A,{size:13,strokeWidth:2,"aria-hidden":"true"}):(0,s.jsx)(A.A,{size:13,strokeWidth:2,"aria-hidden":"true"}),p?"Resume":"Pause"]}),(0,s.jsxs)("button",{type:"button",className:"scheduled-card__action-btn scheduled-card__action-btn--danger",onClick:()=>u("delete"),"aria-label":"Delete scheduled review",children:[(0,s.jsx)(S.A,{size:13,strokeWidth:2,"aria-hidden":"true"}),"Delete"]})]})]})}var E=a(20063),D=a(37772),P=a(48314),R=a(42529),L=a(93499),I=a(77676),F=a(17181);function z(e){let{open:t,onToggle:a,onDelete:r,onRerun:l}=e,i=n.useRef(null);return r||l?(n.useEffect(()=>{if(!t)return;let e=e=>{i.current&&!i.current.contains(e.target)&&a()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[t,a]),(0,s.jsxs)("div",{className:"completed-card__overflow-wrapper",ref:i,children:[(0,s.jsx)("button",{type:"button",className:"completed-card__overflow-btn",onClick:a,"aria-label":"More options","aria-haspopup":"true","aria-expanded":t,children:(0,s.jsx)(D.A,{size:15,strokeWidth:2,"aria-hidden":"true"})}),t&&(0,s.jsxs)("div",{className:"completed-card__overflow-menu",role:"menu",children:[l&&(0,s.jsxs)("button",{type:"button",className:"completed-card__overflow-item",role:"menuitem",onClick:()=>{l(),a()},children:[(0,s.jsx)(P.A,{size:13,strokeWidth:2,"aria-hidden":"true"}),"Run again"]}),l&&r&&(0,s.jsx)("div",{className:"completed-card__overflow-divider",role:"separator"}),r&&(0,s.jsxs)("button",{type:"button",className:"completed-card__overflow-item completed-card__overflow-item--danger",role:"menuitem",onClick:()=>{r(),a()},children:[(0,s.jsx)(S.A,{size:13,strokeWidth:2,"aria-hidden":"true"}),"Delete"]})]})]})):null}let W=[{value:"all",label:"All"},{value:"reports",label:"Briefings"},{value:"analysis",label:"Analysis"},{value:"alerts",label:"Alerts"},{value:"data",label:"Data"}];function B(e){let{active:t,onChange:a}=e;return(0,s.jsx)("div",{className:"artifact-filter-chips",role:"group","aria-label":"Filter delivered findings",children:W.map(e=>{let{value:n,label:r}=e;return(0,s.jsx)("button",{type:"button",role:"radio","aria-checked":t===n,className:"artifact-filter-chip ".concat(t===n?"artifact-filter-chip--active":""),onClick:()=>a(n),children:r},n)})})}function O(e){var t,a;let{job:r,onOpen:l,onExportPdf:i,onShare:o,onDelete:c,onRerun:d,className:u=""}=e,m=(0,E.useRouter)(),[p,x]=n.useState(!1),h=r.artifact,g="string"==typeof(null==(t=r.metadata)?void 0:t.inboxItemId)&&r.metadata.inboxItemId.length>0?r.metadata.inboxItemId:null,f=function(e,t){if(!e||!t)return"";let a=Math.floor((t.getTime()-e.getTime())/1e3);if(a<60)return"".concat(a,"s");let s=Math.floor(a/60);return"".concat(s,"m")}(r.startedAt,r.completedAt),b=r.completedAt?r.completedAt.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0}):"",v=function(e){var t,a,s,n,r,l,i;let o=null!=(i=e.metadata)?i:{},c=(null==(a=e.artifact)||null==(t=a.metadata)?void 0:t.resolvedModel)||("string"==typeof o.resolvedModel?o.resolvedModel:null),d="number"==typeof o.retryCount?o.retryCount:null==(n=e.artifact)||null==(s=n.metadata)?void 0:s.retryCount,u="boolean"==typeof o.usedFallback?o.usedFallback:!!(null==(l=e.artifact)||null==(r=l.metadata)?void 0:r.usedF
1allback),m=[];return u&&m.push("Continued on fallback lane"),"number"==typeof d&&d>0&&m.push("".concat(d," retr").concat(1===d?"y":"ies")),c&&m.push("Model ".concat(c)),m.length>0?m.join(" \xb7 "):null}(r);return(0,s.jsxs)("article",{className:"completed-card ".concat(u),role:"listitem","aria-label":"Delivered finding: ".concat(r.title),children:[(0,s.jsxs)("div",{className:"completed-card__header",children:[(0,s.jsx)(R.A,{size:16,strokeWidth:2,className:"completed-card__check-icon","aria-hidden":"true"}),(0,s.jsx)("span",{className:"completed-card__title",children:r.title})]}),(0,s.jsxs)("div",{className:"completed-card__meta",children:[(0,s.jsx)("span",{children:"report"===r.type?"Briefing":"Review"}),b&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{"aria-hidden":"true",children:"\xb7"}),(0,s.jsxs)("span",{children:["Delivered ",b]})]}),f&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{"aria-hidden":"true",children:"\xb7"}),(0,s.jsx)("span",{children:f})]}),(null==h?void 0:h.size)!=null&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{"aria-hidden":"true",children:"\xb7"}),(0,s.jsx)("span",{children:(a=h.size)<1024?"".concat(a," B"):a<1048576?"".concat((a/1024).toFixed(1)," KB"):"".concat((a/1048576).toFixed(1)," MB")})]})]}),(null==h?void 0:h.summary)&&(0,s.jsx)("blockquote",{className:"completed-card__preview","aria-label":"Brief preview",children:h.summary}),v&&(0,s.jsx)("div",{className:"completed-card__preview",children:v}),(0,s.jsxs)("div",{className:"completed-card__actions",children:[h&&(l||g)&&(0,s.jsxs)("button",{type:"button",className:"completed-card__btn completed-card__btn--primary",onClick:()=>{if(l)return void l(h);g&&m.push("/?tab=inbox&itemId=".concat(encodeURIComponent(g)))},"aria-label":"Open ".concat(r.title),children:[(0,s.jsx)(L.A,{size:13,strokeWidth:2,"aria-hidden":"true"}),"Open briefing"]}),h&&i&&(0,s.jsxs)("button",{type:"button",className:"completed-card__btn completed-card__btn--ghost",onClick:()=>i(h),"aria-label":"Export as PDF",children:[(0,s.jsx)(I.A,{size:13,strokeWidth:2,"aria-hidden":"true"}),"Export PDF"]}),h&&o&&(0,s.jsxs)("button",{type:"button",className:"completed-card__btn completed-card__btn--ghost",onClick:()=>o(h),"aria-label":"Share this briefing",children:[(0,s.jsx)(F.A,{size:13,strokeWidth:2,"aria-hidden":"true"}),"Share"]}),(c||d)&&(0,s.jsx)(z,{open:p,onToggle:()=>x(e=>!e),onDelete:c?()=>c(r.id):void 0,onRerun:d?()=>d(r.id):void 0})]})]})}var U=a(79397),q=a(29502),$=a(61194);let V={active:{Icon:e=>{let{size:t,strokeWidth:a}=e;return(0,s.jsx)(U.A,{size:t,strokeWidth:a,"aria-hidden":"true"})},title:"No analyst work in progress",description:"Ask Coach for research or a deeper review and the work will show up here."},scheduled:{Icon:e=>{let{size:t,strokeWidth:a}=e;return(0,s.jsx)(q.A,{size:t,strokeWidth:a,"aria-hidden":"true"})},title:"No scheduled reviews yet",description:"Ask Coach to set up recurring briefings, reviews, or alerts."},completed:{Icon:e=>{let{size:t,strokeWidth:a}=e;return(0,s.jsx)($.A,{size:t,strokeWidth:a,"aria-hidden":"true"})},title:"No completed findings yet",description:"Finished research runs and delivered findings will show up here."}};function H(e){let{tab:t,className:a=""}=e,{Icon:n,title:r,description:l}=V[t];return(0,s.jsxs)("div",{className:"jobs-empty-state ".concat(a),role:"status","aria-label":r,children:[(0,s.jsx)("div",{className:"jobs-empty-state__icon",children:(0,s.jsx)(n,{size:48,strokeWidth:1.25})}),(0,s.jsx)("p",{className:"jobs-empty-state__title",children:r}),(0,s.jsx)("p",{className:"jobs-empty-state__description",children:l})]})}let K=[{id:"active",label:"In Progress"},{id:"scheduled",label:"Scheduled"},{id:"completed",label:"Delivered"}];function J(e){let{activeTab:t,onTabChange:a,searchOpen:i,searchValue:o,onSearchToggle:c,onSearchChange:d,onSearchClose:u,tabIndicatorStyle:m,tabRefs:p}=e,x=n.useRef(null);return n.useEffect(()=>{var e;i&&(null==(e=x.current)||e.focus())},[i]),(0,s.jsxs)("div",{className:"jobs-tab-bar",role:"navigation","aria-label":"Analyst Work tabs",onKeyDown:e=>{if("ArrowRight"===e.key||"ArrowLeft"===e.key){var s,n;e.preventDefault();let r=K.findIndex(e=>e.id===t),l="ArrowRight"===e.key?(r+1)%K.length:(r-1+K.length)%K.length;a(K[l].id),null==(n=p.current)||null==(s=n[K[l].id])||s.focus()}"Escape"===e.key&&u()},children:[(0,s.jsxs)("div",{className:"jobs-tab-bar__tabs",role:"tablist",children:[K.map(e=>(0,s.jsx)("button",{ref:t=>{p.current&&(p.current[e.id]=t)},id:"jobs-tab-".concat(e.id),role:"tab","aria-selected":t===e.id,"aria-controls":"jobs-panel-".concat(e.id),type:"button",className:"jobs-tab-bar__tab ".concat(t===e.id?"jobs-tab-bar__tab--active":""),onClick:()=>a(e.id),children:e.label},e.id)),(0,s.jsx)("div",{className:"jobs-tab-bar__indicator",style:m,"aria-hidden":"true"})]}),(0,s.jsx)("div",{className:"jobs-tab-bar__search-area",children:i?(0,s.jsxs)("div",{className:"jobs-tab-bar__search-expanded",children:[(0,s.jsx)(r.A,{size:14,strokeWidth:2,className:"jobs-tab-bar__search-icon","aria-hidden":"true"}),(0,s.jsx)("input",{ref:x,type:"search",className:"jobs-tab-bar__search-input",placeholder:"Search analyst workâ¦",value:o,onChange:e=>d(e.target.value),"aria-label":"Search analyst work",onKeyDown:e=>{"Escape"===e.key&&u()}}),(0,s.jsx)("button",{type:"button",className:"jobs-tab-bar__search-close",onClick:u,"aria-label":"Close search",children:(0,s.jsx)(l.A,{size:14,strokeWidth:2,"aria-hidden":"true"})})]}):(0,s.jsx)("button",{type:"button",className:"jobs-tab-bar__search-btn",onClick:c,"aria-label":"Open search",children:(0,s.jsx)(r.A,{size:16,strokeWidth:1.75,"aria-hidden":"true"})})})]})}function G(e){let{jobs:t=[],initialTab:a="active",focusJobId:r,onCancelJob:l,onDeleteJob:i,onRerunJob:o,onEditSchedule:c,onPauseSchedule:d,onResumeSchedule:u,onOpenArtifact:m,onExportPdf:p,onShareArtifact:x,onViewConversation:g,onTabChange:f,className:b=""}=e,[v,_]=n.useState(a),[j,N]=n.useState(null),[k,w]=n.useState(null),[A,S]=n.useState(null!=r?r:null),[T,C]=n.useState(!1),[E,D]=n.useState(""),[P,R]=n.useState("all"),L=n.useRef({active:null,scheduled:null,completed:null}),[I,F]=n.useState({}),z=n.useCallback(e=>{var t;let a=null==(t=L.current)?void 0:t[e];a&&F({left:"".concat(a.offsetLeft,"px"),width:"".concat(a.offsetWidth,"px")}
1)},[]);n.useLayoutEffect(()=>{z(v)},[v,z]),n.useEffect(()=>{let e=()=>z(v);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[v,z]);let W=t.filter(e=>!e.schedule&&("running"===e.status||"queued"===e.status||"error"===e.status||"cancelled"===e.status)),U=t.filter(e=>null!==e.schedule&&"complete"!==e.status),q=t.filter(e=>"complete"===e.status),$=e=>E.trim()?e.filter(e=>e.title.toLowerCase().includes(E.toLowerCase())):e,V=$(W),K=$(U),G=$("all"===P?q:q.filter(e=>{var t;let a=null==(t=e.artifact)?void 0:t.type;return"reports"===P?"report"===a:"analysis"===P?"analysis"===a:"alerts"===P?"alert_config"===a:"data"!==P||"data_export"===a}));return n.useEffect(()=>{let e=e=>{"Escape"===e.key&&N(null)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]),n.useEffect(()=>{_(a),N(null)},[a]),n.useEffect(()=>{S(null!=r?r:null)},[r]),n.useEffect(()=>{if(!A)return;let e=t.find(e=>e.id===A);if(!e)return;let a="complete"===e.status?"completed":e.schedule?"scheduled":"active";_(e=>e===a?e:a),"active"===a?N(e.id):N(null),w(e.id),S(null)},[t,A]),n.useEffect(()=>{if(!k)return;let e=window.requestAnimationFrame(()=>{let e=document.querySelector('[data-job-id="'.concat(CSS.escape(k),'"]'));e&&e.scrollIntoView({behavior:"smooth",block:"center"})}),t=window.setTimeout(()=>{w(e=>e===k?null:e)},2200);return()=>{window.cancelAnimationFrame(e),window.clearTimeout(t)}},[k,v]),(0,s.jsx)("div",{className:"jobs-terminal",children:(0,s.jsxs)("main",{className:"jobs-page ".concat(b),"aria-label":"Analyst Work and Findings",children:[(0,s.jsx)("h1",{className:"jobs-page__heading",children:"Analyst Work"}),(0,s.jsx)(J,{activeTab:v,onTabChange:e=>{_(e),N(null),D(""),null==f||f(e)},searchOpen:T,searchValue:E,onSearchToggle:()=>C(!0),onSearchChange:D,onSearchClose:()=>{C(!1),D("")},tabIndicatorStyle:I,tabRefs:L}),(0,s.jsx)("div",{className:"jobs-page__divider",role:"separator","aria-hidden":"true"}),(0,s.jsxs)("div",{className:"jobs-page__content jobs-page__content--fade",children:["active"===v&&(0,s.jsx)("div",{id:"jobs-panel-active",role:"tabpanel","aria-labelledby":"jobs-tab-active",className:"jobs-tab-panel",children:0===V.length?(0,s.jsx)(H,{tab:"active"}):(0,s.jsx)("ul",{className:"jobs-list",role:"list","aria-label":"Analyst work in progress","aria-live":"polite","aria-atomic":"false",children:V.map(e=>j===e.id?(0,s.jsx)("li",{"data-job-id":e.id,className:j===e.id||k===e.id?"jobs-list__item jobs-list__item--focused":"jobs-list__item",children:(0,s.jsx)(y,{job:e,onCollapse:e=>N(null),onCancel:l,onViewConversation:g})},e.id):(0,s.jsx)("li",{"data-job-id":e.id,className:k===e.id?"jobs-list__item jobs-list__item--focused":"jobs-list__item",children:(0,s.jsx)(h,{job:e,onExpand:e=>N(e),onCancel:l})},e.id))})}),"scheduled"===v&&(0,s.jsx)("div",{id:"jobs-panel-scheduled",role:"tabpanel","aria-labelledby":"jobs-tab-scheduled",className:"jobs-tab-panel",children:0===K.length?(0,s.jsx)(H,{tab:"scheduled"}):(0,s.jsx)("ul",{className:"jobs-list",role:"list","aria-label":"Scheduled analyst work",children:K.map(e=>(0,s.jsx)("li",{"data-job-id":e.id,className:k===e.id?"jobs-list__item jobs-list__item--focused":"jobs-list__item",children:(0,s.jsx)(M,{job:e,onEdit:c,onPause:d,onResume:u,onDelete:i})},e.id))})}),"completed"===v&&(0,s.jsxs)("div",{id:"jobs-panel-completed",role:"tabpanel","aria-labelledby":"jobs-tab-completed",className:"jobs-tab-panel",children:[(0,s.jsx)(B,{active:P,onChange:R}),0===G.length?(0,s.jsx)(H,{tab:"completed"}):(0,s.jsx)("ul",{className:"jobs-list",role:"list","aria-label":"Delivered findings",children:G.map(e=>(0,s.jsx)("li",{"data-job-id":e.id,className:k===e.id?"jobs-list__item jobs-list__item--focused":"jobs-list__item",children:(0,s.jsx)(O,{job:e,onOpen:m,onExportPdf:p,onShare:x,onDelete:i,onRerun:o})},e.id))})]})]},v)]})})}},64864:(e,t,a)=>{a.d(t,{Z:()=>p});var s=a(20063),n=a(12115),r=a(18720),l=a(95752);let i={"INTERACTIVE-BROKERS":"INTERACTIVE_BROKERS","INTERACTIVE BROKERS":"INTERACTIVE_BROKERS",IBKR:"INTERACTIVE_BROKERS"};function o(e){var t;let a=e.trim().toUpperCase();return(null!=(t=i[a])?t:a).replace(/[\s-]+/g,"_")}var c=a(40254);
1let d={ROBINHOOD:"https://logo.clearbit.com/robinhood.com",WEBULL:"https://logo.clearbit.com/webull.com",FIDELITY:"https://logo.clearbit.com/fidelity.com",COINBASE:"https://logo.clearbit.com/coinbase.com",ALPACA:"https://logo.clearbit.com/alpaca.markets",TRADIER:"https://logo.clearbit.com/tradier.com",TD:"https://logo.clearbit.com/tdameritrade.com",ETRADE:"https://logo.clearbit.com/etrade.com",SCHWAB:"https://logo.clearbit.com/schwab.com",INTERACTIVE_BROKERS:"https://logo.clearbit.com/interactivebrokers.com",TASTYTRADE:"https://logo.clearbit.com/tastytrade.com",TRADESTATION:"https://logo.clearbit.com/tradestation.com",FIRSTRADE:"https://logo.clearbit.com/firstrade.com",VANGUARD:"https://logo.clearbit.com/vanguard.com",MERRILL:"https://logo.clearbit.com/merrilledge.com"},u=[],m={ROBINHOOD:"Auto-import filled orders so Coach can review the real trade history.",WEBULL:"Sync executions and positions into your journal automatically.",FIDELITY:"Pull account activity into a cleaner trade journal and review flow.",COINBASE:"Capture crypto fills and keep Coach current on your activity.",ALPACA:"Track API-driven orders with automatic fill and position sync.",TRADIER:"Import options and equity activity for clearer performance review.",TD:"Sync order history and positions to keep your journal current.",ETRADE:"Bring executions and account activity into one performance review.",SCHWAB:"Keep fills, positions, and trade context synced in real time.",INTERACTIVE_BROKERS:"Consolidate multi-asset executions into one journal flow.",TASTYTRADE:"Import options activity for faster post-trade review.",TRADESTATION:"Sync platform executions so Coach can review them cleanly.",FIRSTRADE:"Auto-log stock and options trades for steady review.",VANGUARD:"Capture investment activity and keep long-term review up to date.",MERRILL:"Sync account trade events into your coaching timeline."};function p(){let e=(0,s.useRouter)(),{user:t}=(0,c.J)(),a=null==t?void 0:t.id,[i,p]=(0,n.useState)([]),[x,h]=(0,n.useState)([]),[g,f]=(0,n.useState)(!0),b=(0,n.useRef)(!0),v=(0,n.useCallback)(async()=>{try{let e=await fetch("/api/brokerages",{cache:"no-store"});if(!e.ok){b.current&&h(u);return}let t=await e.json(),a=(0,l.B)((Array.isArray(t)?t:[]).filter(e=>!!(e.slug||"").trim()).map(e=>({...e,slug:e.slug||"",display_name:e.display_name||e.slug}))).map(e=>{let t=o(e.slug),a=function(e){let t=o(e.slug||"");return e.aws_s3_square_logo_url||e.aws_s3_logo_url||d[t]||void 0}(e);return{id:"broker:".concat(t),integrationKey:"broker:".concat(t),name:e.display_name,type:"Broker",description:m[t]||"Import and sync your trades automatically.",iconUrl:a,brokerSlug:e.slug,websiteUrl:e.url||void 0,supportUrl:"https://snaptrade.com/support",category:"Broker",disabled:!!e.maintenance_mode}});b.current&&h([...a,...u])}catch(e){b.current&&h(u)}},[]),_=(0,n.useCallback)(async()=>{if(!a){p([]),f(!1);return}try{let e=await fetch("/api/snaptrade/accounts",{cache:"no-store"});if(!e.ok){b.current&&(p([]),f(!1));return}let t=await e.json(),a=(Array.isArray(t.connections)?t.connections:[]).map(e=>{var t,a,s,n,r,l,i;return{id:e.id,brokerage_name:null!=(t=e.brokerName)?t:"",brokerage_slug:null!=(a=e.brokerSlug)?a:"",status:null!=(s=e.status)?s:"active",last_synced_at:null!=(n=e.lastSyncedAt)?n:null,account_id:null!=(r=e.accountNumber)?r:"",institution_name:null!=(l=e.brokerName)?l:"",display_name:null!=(i=e.brokerName)?i:""}}),s=new Map;for(let e of x){let t=(e.integrationKey||e.id).trim().toLowerCase();s.set(t,e)}let n=a.map(e=>{var t,a,n,r;let l=o(null!=(r=null!=(n=null!=(a=e.brokerage_slug)?a:e.brokerage_name)?n:e.institution_name)?r:""),i="broker:".concat(l).toLowerCase(),c=null==(t=s.get(i))?void 0:t.iconUrl;return function(e,t){var a,s,n,r,l,i,c;let d=function(e){let t=(e||"active").toLowerCase();return"syncing"===t?"syncing":"error"===t||"failed"===t?"error":"disconnected"===t||"inactive"===t?"disconnected":"active"}(e.status),u=o(null!=(n=null!=(s=null!=(a=e.brokerage_slug)?a:e.brokerage_name)?s:e.institution_name)?n:"");return{id:e.id,name:null!=(i=null!=(l=null!=(r=e.institution_name)?r:e.brokerage_name)?l:e.display_name)?i:"Broker",type:"Broker",integrationKey:u?"broker:".concat(u):void 0,iconUrl:t,lastSync:null!=(c=e.last_synced_at)?c:void 0,metadata:[{label:"Status",value:"active"===d?"Connected":d},{label:"Sync freshness",value:function(e){if(!e)return"Never synced";let t=new Date(e);if(Number.isNaN(t.getTime()))return"Unknown";let a=Date.now()-t.getTime();return a<6e4?"Synced just now":a<36e5?"Synced ".concat(Math.floor(a/6e4),"m ago"):a<864e5?"Synced ".concat(Math.floor(a/36e5),"h ago"):"Synced ".concat(Math.floor(a/864e5),"d ago")}(e.last_synced_at)},...e.account_id?[{label:"Account",value:e.account_id}]:[],{label:"Encryption",value:"TLS 1.2+"}],category:"Broker"}}(e,c)});b.current&&(p(n.filter(e=>{var t,a;return(null==(a=e.metadata)||null==(t=a[0])?void 0:t.value)!=="disconnected"})),f(!1))}catch(e){b.current&&(p([]),f(!1))}},[x,a]);(0,n.useEffect)(()=>(b.current=!0,()=>{b.current=!1}),[]),(0,n.useEffect)(()=>{v()},[v]),(0,n.useEffect)(()=>{_()},[_]);let j=(0,n.useCallback)(e=>{console.info("[useConnections] manageService:",e)},[]),y=(0,n.useCallback)(async e=>{if(a){p(t=>t.filter(t=>t.id!==e));try{await fetch("/api/snaptrade/disconnect",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({connectionId:e})})}catch(e){_()}}},[_,a]),N=(0,n.useCallback)(async t=>{let s=x.find(e=>e.id===t),n=null==s?void 0:s.brokerSlug;if(!n||(null==s?void 0:s.disabled))return void r.o.info("This broker
1connection is coming soon.");if(!a)return void r.o.error("Sign in to connect your broker.");try{let t=await fetch("/api/snaptrade/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:a})});if(!t.ok){let a=await t.json().catch(()=>null);if(402===t.status){r.o.error((null==a?void 0:a.error)||"Broker access is part of Pro."),e.push("/?tab=pricing&next=%2F%3Ftab%3Dprofile%26section%3Dbroker");return}throw Error((null==a?void 0:a.error)||"Failed to register with SnapTrade")}let s=await fetch("/api/snaptrade/authorize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({brokerSlug:n})});if(!s.ok){let t=await s.json().catch(()=>null);if(402===s.status){r.o.error((null==t?void 0:t.error)||"Broker access is part of Pro."),e.push("/?tab=pricing&next=%2F%3Ftab%3Dprofile%26section%3Dbroker");return}throw Error((null==t?void 0:t.error)||"Failed to initiate broker connection")}let l=await s.json();if(!l.redirectUrl)throw Error("Failed to initiate broker connection");window.location.href=l.redirectUrl}catch(t){let e=t instanceof Error?t.message:"";if(/invalid broker|not supported|unsupported|unavailable/i.test(e))return void r.o.error("This broker is unavailable for your region or account type right now.");r.o.error("Couldn't connect this broker. Try again.")}},[x,e,a]);return{connectedServices:i,availableIntegrations:x,isLoading:g,manageService:j,disconnectService:y,connectIntegration:N,refetch:_}}},76648:(e,t,a)=>{function s(e){return null==e?"â":"".concat(e.toFixed(1),"%")}function n(e){return null==e?"â":Number.isInteger(e)?String(e):e.toFixed(2)}function r(e,t){var a;if(null==e)return"â";let s=null!=(a=null==t?void 0:t.precision)?a:2,n=Math.abs(e).toFixed(s);return(null==t?void 0:t.showSign)?e>=0?"+$".concat(n):"-$".concat(n):"$".concat(n)}function l(e){if(null==e)return"â";if(e<60)return"".concat(Math.round(e),"m");let t=Math.floor(e/60),a=Math.round(e%60);return a>0?"".concat(t,"h ").concat(a,"m"):"".concat(t,"h")}a.d(t,{dd:()=>n,hz:()=>s,ih:()=>l,jT:()=>r})},87849:(e,t,a)=>{a.d(t,{f:()=>s});function s(){return!1}},95752:(e,t,a)=>{a.d(t,{B:()=>n});let s=["WEBULL","ROBINHOOD","FIDELITY","COINBASE","KRAKEN","INTERACTIVE-BROKERS","TRADESTATION","TRADESTATION-SIM","ETRADE","SCHWAB","TASTYTRADE","ALPACA","ALPACA-PAPER","PUBLIC","TRADIER","ZERODHA","MOOMOO","STAKEAUS","TRADING212","QUESTRADE","WEALTHSIMPLETRADE","BINANCE"];function n(e){return[...e].sort((e,t)=>{let a=s.indexOf(e.slug),n=s.indexOf(t.slug);return a>=0&&n>=0?a-n:a>=0?-1:n>=0?1:e.display_name.localeCompare(t.display_name)})}},97003:(e,t,a)=>{a.d(t,{$:()=>o});var s=a(95155);a(12115);var n=a(32467),r=a(83101),l=a(25016);let i=(0,r.F)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium cursor-pointer transition-colors disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",xs:"h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-xs":"size-6 rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function o(e){let{className:t,variant:a="default",size:r="default",asChild:o=!1,...c}=e,d=o?n.DX:"button";return(0,s.jsx)(d,{"data-slot":"button","data-variant":a,"data-size":r,className:(0,l.cn)(i({variant:a,size:r,className:t})),...c})}},99331:(e,t,a)=>{a.d(t,{f:()=>n});var s=a(95155);function n(e){let{value:t,label:a,indeterminate:n=!1,className:r=""}=e,l=n||void 0===t;return(0,s.jsxs)("div",{className:"job-progress ".concat(r),role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":l?void 0:t,children:[(0,s.jsx)("div",{className:"job-progress__track",children:l?(0,s.jsx)("div",{className:"job-progress__fill job-progress__fill--shimmer"}):(0,s.jsx)("div",{className:"job-progress__fill",style:{width:"".concat(Math.min(100,Math.max(0,null!=t?t:0)),"%")}
1})}),a&&(0,s.jsx)("span",{className:"job-progress__label",children:a})]})}a(12115)}}]);
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.