1import{c as Ae,az as qe,aA as ds,aB as qa,aC as Sn,aD as Mn,aE as me,aF as ms,aG as An,r as j,j as e,D as O,aH as ka,aI as xs,aJ as Cn,aK as Ha,n as qs,s as ue,aL as xe,C as q,b as X,p as Y,ar as Ke,B as W,L as Pt,Z as pe,R as Me,d as H,A as ge,a as C,e as Et,l as Hs,aM as Tn,M as Sa,g as ke,T as he,K as Rn,am as Ht,v as lt,w as Ce,x as Be,z as Re,q as dt,$ as Gt,aN as Kt,aO as Ut,aP as Xt,aQ as Yt,af as Xe,X as _r,Y as kr,_ as Sr,a0 as Mr,au as bs,V as Ma,ah as Aa,ax as Pn,aR as Fn,aj as Je,ai as Fs,y as it,ag as Dn,a9 as gt,ab as ua,at as Lt,aq as at,aS as ye,aT as Ar,I as se,aU as En,F as Ln,U as us,S as _t,as as Ca,av as Cr,ac as On,ad as Tr,aV as Gs,a2 as Ks,a3 as Ta,ak as ee,aW as Us,ae as Qt,aX as Ds,aY as In,aZ as De,a_ as Ee,a$ as Le,b0 as Oe,b1 as ie,aw as Bn,h as ve,a5 as vs,a6 as js,a7 as Ie,a8 as Ue,b2 as P,b3 as Rr,an as Pr,b4 as ha,b5 as Fr,u as Dr,b6 as pa,W as zn,b7 as $n,H as Vn}from"./index-CT3mG8No.js";import{T as Er,R as Xs}from"./textarea-CrN_Hc0e.js";import{C as ze,a as $e,b as Wn}from"./collapsible-Dx9uShpA.js";import{P as Ga,a as Ka,b as Ua}from"./popover-JFv6ks3X.js";import{s as Es,a as hs,d as Nt,b as qn,c as Ra,g as Hn,e as Gn,f as kt,i as Lr}from"./format-DjRxwH3y.js";import{a as Qe,s as sa}from"./subDays-Cqq1FCcj.js";import{C as Or}from"./chevron-left-OEOB9cRj.js";import{L as St}from"./layers-CPOp1srd.js";import{f as wt,p as ps,i as is,D as Kn,a as Tt,A as Ir,b as Ft,c as Br,d as zr,G as $r,g as qt,l as Un,e as Rt,S as Xa,h as Xn,j as Yn,k as Vr,E as Qn,m as Zn,n as Jn,C as rt,o as Ya,u as ei,q as Pa,r as ti,X as de,Y as oe,s as Wr,B as Ye,R as le,T as Ne,t as fe,L as ga}from"./generateCategoricalChart-B6jrSxr9.js";import{a as We,A as Ot}from"./AreaChart-CdMPN2tR.js";import{a as Fe,L as At}from"./LineChart-zqQFYX4L.js";import{S as ys}from"./scale-4ZGSKKpy.js";import{C as Zt}from"./calendar-tUKuUoNb.js";import{B as ot}from"./BarChart-0unBuzBV.js";import{H as Ls}from"./history-DoZIRmpJ.js";import{D as Qa}from"./droplets-37vBaN15.js";import{b as si,c as qr,d as Hr,P as Ys,a as Qs}from"./PieChart-BCRzZDLR.js";import{T as Gr}from"./timer-hF13M3Ad.js";import{N as ai}from"./newspaper-Blhaxeak.js";import{T as Kr}from"./twitter-CEJiaCmz.js";import{L as ri}from"./link-r0fM0-0A.js";import{C as Ur}from"./chart-pie-Dk9lMnEK.js";import{P as Os}from"./pause-DUE6GJhl.js";import{E as ni}from"./eye-CIU_Es_c.js";import{F as ii}from"./flame-BIEOP9Uk.js";import{C as Fa}from"./CartesianGrid-GMSU1WFQ.js";import{F as Da}from"./filter-DdMKstNa.js";import{B as fa}from"./bell-BIIMqXWS.js";import{T as Xr}from"./trash-2-BGwCMA8T.js";import{S as Yr}from"./settings-DwYR5Tie.js";import{M as Za}from"./mail-qvsh7bQ8.js";import{S as Qr}from"./search-CwLiK-Ts.js";import{D as ba}from"./download-Cfh60q84.js";import{S as Ja}from"./shopping-cart-WPo17qWK.js";import{A as li}from"./arrow-left-C0WNe__n.js";import"./index-VKhLDAfi.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const oi=Ae("BadgeCheck",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** 7 * @license lucide-react v0.462.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const ci=Ae("Bitcoin",[["path",{d:"M11.767 19.089c4.924.868 6.14-6.025 1.216-6.894m-1.216 6.894L5.86 18.047m5.908 1.042-.347 1.97m1.563-8.864c4.924.869 6.14-6.025 1.215-6.893m-1.215 6.893-3.94-.694m5.155-6.2L8.29 4.26m5.908 1.042.348-1.97M7.48 20.364l3.126-17.727",key:"yr8idg"}]]);/** 12 * @license lucide-react v0.462.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const di=Ae("Calculator",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]]);/** 17 * @license lucide-react v0.462.0 - ISC 18 * 19 * This source code is licensed under the ISC license. 20 * See the LICENSE file in the root directory of this source tree. 21 */const as=Ae("ChartNoAxesColumn",[["line",{x1:"18",x2:"18",y1:"20",y2:"10",key:"1xfpm4"}],["line",{x1:"12",x2:"12",y1:"20",y2:"4",key:"be30l9"}],["line",{x1:"6",x2:"6",y1:"20",y2:"14",key:"1r4le6"}]]);/** 22 * @license lucide-react v0.462.0 - ISC 23 * 24 * This source code is licensed under the ISC license. 25 * See the LICENSE file in the root directory of this source tree. 26 */const Zr=Ae("Compass",[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",ke
26y:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** 27 * @license lucide-react v0.462.0 - ISC 28 * 29 * This source code is licensed under the ISC license. 30 * See the LICENSE file in the root directory of this source tree. 31 */const mi=Ae("Crosshair",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]);/** 32 * @license lucide-react v0.462.0 - ISC 33 * 34 * This source code is licensed under the ISC license. 35 * See the LICENSE file in the root directory of this source tree. 36 */const xi=Ae("Dna",[["path",{d:"m10 16 1.5 1.5",key:"11lckj"}],["path",{d:"m14 8-1.5-1.5",key:"1ohn8i"}],["path",{d:"M15 2c-1.798 1.998-2.518 3.995-2.807 5.993",key:"80uv8i"}],["path",{d:"m16.5 10.5 1 1",key:"696xn5"}],["path",{d:"m17 6-2.891-2.891",key:"xu6p2f"}],["path",{d:"M2 15c6.667-6 13.333 0 20-6",key:"1pyr53"}],["path",{d:"m20 9 .891.891",key:"3xwk7g"}],["path",{d:"M3.109 14.109 4 15",key:"q76aoh"}],["path",{d:"m6.5 12.5 1 1",key:"cs35ky"}],["path",{d:"m7 18 2.891 2.891",key:"1sisit"}],["path",{d:"M9 22c1.798-1.998 2.518-3.995 2.807-5.993",key:"q3hbxp"}]]);/** 37 * @license lucide-react v0.462.0 - ISC 38 * 39 * This source code is licensed under the ISC license. 40 * See the LICENSE file in the root directory of this source tree. 41 */const ui=Ae("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** 42 * @license lucide-react v0.462.0 - ISC 43 * 44 * This source code is licensed under the ISC license. 45 * See the LICENSE file in the root directory of this source tree. 46 */const mt=Ae("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]]);/** 47 * @license lucide-react v0.462.0 - ISC 48 * 49 * This source code is licensed under the ISC license. 50 * See the LICENSE file in the root directory of this source tree. 51 */const Jr=Ae("Grid3x3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/** 52 * @license lucide-react v0.462.0 - ISC 53 * 54 * This source code is licensed under the ISC license. 55 * See the LICENSE file in the root directory of this source tree.
56 */const en=Ae("Library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);/** 57 * @license lucide-react v0.462.0 - ISC 58 * 59 * This source code is licensed under the ISC license. 60 * See the LICENSE file in the root directory of this source tree. 61 */const hi=Ae("OctagonAlert",[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]]);/** 62 * @license lucide-react v0.462.0 - ISC 63 * 64 * This source code is licensed under the ISC license. 65 * See the LICENSE file in the root directory of this source tree. 66 */const ls=Ae("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** 67 * @license lucide-react v0.462.0 - ISC 68 * 69 * This source code is licensed under the ISC license. 70 * See the LICENSE file in the root directory of this source tree. 71 */const er=Ae("Radar",[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34",key:"z3du51"}],["path",{d:"M4 6h.01",key:"oypzma"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35",key:"qzzz0"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67",key:"1yjesh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67",key:"1u2y91"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"m13.41 10.59 5.66-5.66",key:"mhq4k0"}]]);/** 72 * @license lucide-react v0.462.0 - ISC 73 * 74 * This source code is licensed under the ISC license. 75 * See the LICENSE file in the root directory of this source tree. 76 */const pi=Ae("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/** 77 * @license lucide-react v0.462.0 - ISC 78 * 79 * This source code is licensed under the ISC license. 80 * See the LICENSE file in the root directory of this source tree. 81 */const tn=Ae("Shuffle",[["path",{d:"m18 14 4 4-4 4",key:"10pe0f"}],["path",{d:"m18 2 4 4-4 4",key:"pucp1d"}],["path",{d:"M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22",key:"1ailkh"}],["path",{d:"M2 6h1.972a4 4 0 0 1 3.6 2.2",key:"km57vx"}],["path",{d:"M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45",key:"os18l9"}]]);/** 82 * @license lucide-react v0.462.0 - ISC 83 * 84 * This source code is licensed under the ISC license. 85 * See the LICENSE file in the root directory of this source tree. 86 */const gi=Ae("Signal",[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}],["path",{d:"M12 20v-8",key:"i3yub9"}],["path",{d:"M17 20V8",key:"1tkaf5"}],["path",{d:"M22 4v16",key:"sih9yq"}]]);/** 87 * @license lucide-react v0.462.0 - ISC 88 * 89 * This source code is licensed under the ISC license. 90 * See the LICENSE file in the root directory of this source tree. 91 */const fi=Ae("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);/** 92 * @license lucide-react v0.462.0 - ISC 93 * 94 * This source code is licensed under the ISC license. 95 * See the LICENSE file in the root directory of this source tree. 96 */const bi=Ae("Store",[["path",{d:"m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7",key:"ztvudi"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["path",{d:"M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4",key:"2ebpfo"}],["path",{d:"M2 7h20",key:"1fcdvo"}],["path",{d:"M22 7v3a2 2 0 0 1-2 2a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12a2 2 0 0 1-2-2V7",key:"6c3vgh"}]]);/** 97 * @license lucide-react v0.462.0 - ISC 98 * 99 * This source code is licensed under the ISC license. 100 * See the LICENSE file in the root directory of this source tree. 101 */const vi=Ae("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/** 102 * @license lucide-react v0.462.0 - ISC 103 * 104 * This source code is licensed under the ISC license. 105 * See the LICENSE file in the root directory of this source tree. 106 */const sn=Ae("WandSparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);/** 107 * @license lucide-react v0.462.0 - ISC 108 * 109 * This source code is licensed under the ISC license. 110 * See the LICENSE file in the root directory of this source tree. 111 */const Zs=Ae("Waves",[["path",{d:"M2 6c.6.5 1.2 1 2.5 1C7 7 7 5 9.5 5c2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"knzxuh"}],["path",{d:"M2 12c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"2jd2cc"}],["path",{d:"M2 18c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"rd2r6e"}]]);/** 112 * @license lucide-react v0.462.0 - ISC 113 * 114 * This source code is licensed under the ISC license. 115 * See the LICENSE file in the root directory of this source tree.
116 */const ji=Ae("Workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]);function xt(t,s){const a=qe(t);if(isNaN(s))return ds(t,NaN);if(!s)return a;const r=a.getDate(),n=ds(t,a.getTime());n.setMonth(a.getMonth()+s+1,0);const c=n.getDate();return r>=c?n:(a.setFullYear(n.getFullYear(),n.getMonth(),r),a)}function va(t,s){const a=s*7;return Qe(t,a)}function yi(t,s){return xt(t,s*12)}function Ni(t){let s;return t.forEach(function(a){const r=qe(a);(s===void 0||s<r||isNaN(Number(r)))&&(s=r)}),s||new Date(NaN)}function wi(t){let s;return t.forEach(a=>{const r=qe(a);(!s||s>r||isNaN(+r))&&(s=r)}),s||new Date(NaN)}function Ze(t,s){const a=Es(t),r=Es(s);return+a==+r}function _i(t,s,a){const r=hs(t,a),n=hs(s,a),c=+r-qa(r),d=+n-qa(n);return Math.round((c-d)/Sn)}function et(t){const s=qe(t);return s.setDate(1),s.setHours(0,0,0,0),s}function Ea(t,s){var i,l,o,u;const a=Mn(),r=(s==null?void 0:s.weekStartsOn)??((l=(i=s==null?void 0:s.locale)==null?void 0:i.options)==null?void 0:l.weekStartsOn)??a.weekStartsOn??((u=(o=a.locale)==null?void 0:o.options)==null?void 0:u.weekStartsOn)??0,n=qe(t),c=n.getDay(),d=(c<r?-7:0)+6-(c-r);return n.setDate(n.getDate()+d),n.setHours(23,59,59,999),n}function an(t){return Ea(t,{weekStartsOn:1})}function ki(t){const s=qe(t),a=s.getFullYear(),r=s.getMonth(),n=ds(t,0);return n.setFullYear(a,r+1,0),n.setHours(0,0,0,0),n.getDate()}function Si(t){return Math.trunc(+qe(t)/1e3)}function Mi(t){const s=qe(t),a=s.getMonth();return s.setFullYear(s.getFullYear(),a+1,0),s.setHours(0,0,0,0),s}function Ai(t,s){return _i(Mi(t),et(t),s)+1}function ja(t,s){const a=qe(t),r=qe(s);return a.getTime()>r.getTime()}function rn(t,s){const a=qe(t),r=qe(s);return+a<+r}function La(t,s){const a=qe(t),r=qe(s);return a.getFullYear()===r.getFullYear()&&a.getMonth()===r.getMonth()}function Ci(t,s){const a=qe(t),r=qe(s);return a.getFullYear()===r.getFullYear()}function aa(t,s){const a=qe(t),r=a.getFullYear(),n=a.getDate(),c=ds(t,0);c.setFullYear(r,s,15),c.setHours(0,0,0,0);const d=ki(c);return a.setMonth(s,Math.min(n,d)),a}function tr(t,s){const a=qe(t);return isNaN(+a)?ds(t,NaN):(a.setFullYear(s),a)}var Ti=["cx","cy","innerRadius","outerRadius","gridType","radialLines"];function gs(t){"@babel/helpers - typeof";return gs=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},gs(t)}function Ri(t,s){if(t==null)return{};var a=Pi(t,s),r,n;if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(t);for(n=0;n<c.length;n++)r=c[n],!(s.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(a[r]=t[r])}return a}function Pi(t,s){if(t==null)return{};var a={};for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){if(s.indexOf(r)>=0)continue;a[r]=t[r]}return a}function Mt(){return Mt=Object.assign?Object.assign.bind():function(t){for(var s=1;s<arguments.length;s++){var a=arguments[s];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(t[r]=a[r])}return t},Mt.apply(this,arguments)}function sr(t,s){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);s&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),a.push.apply(a,r)}return a}function fs(t){for(var s=1;s<arguments.length;s++){var a=arguments[s]!=null?arguments[s]:{};s%2?sr(Object(a),!0).forEach(function(r){Fi(t,r,a[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):sr(Object(a)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(a,r))})}return t}function Fi(t,s,a){return s=Di(s),s in t?Object.defineProperty(t,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[s]=a,t}function Di(t){var s=Ei(t,"string");return gs(s)=="symbol"?s:s+""}function Ei(t,s){if(gs(t)!="object"||!t)return t;var a=t[Symbol.toPrimitive];if(a!==void 0){var r=a.call(t,s||"default");if(gs(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(t)}var Li=function(s,a,r,n){var c="";
vendor: 21,577 bytes, line 116
116return n.forEach(function(d,i){var l=ps(a,r,s,d);i?c+="L ".concat(l.x,",").concat(l.y):c+="M ".concat(l.x,",").concat(l.y)}),c+="Z",c},Oi=function(s){var a=s.cx,r=s.cy,n=s.innerRadius,c=s.outerRadius,d=s.polarAngles,i=s.radialLines;if(!d||!d.length||!i)return null;var l=fs({stroke:"#ccc"},wt(s,!1));return me.createElement("g",{className:"recharts-polar-grid-angle"},d.map(function(o){var u=ps(a,r,n,o),v=ps(a,r,c,o);return me.createElement("line",Mt({},l,{key:"line-".concat(o),x1:u.x,y1:u.y,x2:v.x,y2:v.y}))}))},Ii=function(s){var a=s.cx,r=s.cy,n=s.radius,c=s.index,d=fs(fs({stroke:"#ccc"},wt(s,!1)),{},{fill:"none"});return me.createElement("circle",Mt({},d,{className:ms("recharts-polar-grid-concentric-circle",s.className),key:"circle-".concat(c),cx:a,cy:r,r:n}))},Bi=function(s){var a=s.radius,r=s.index,n=fs(fs({stroke:"#ccc"},wt(s,!1)),{},{fill:"none"});return me.createElement("path",Mt({},n,{className:ms("recharts-polar-grid-concentric-polygon",s.className),key:"path-".concat(r),d:Li(a,s.cx,s.cy,s.polarAngles)}))},zi=function(s){var a=s.polarRadius,r=s.gridType;return!a||!a.length?null:me.createElement("g",{className:"recharts-polar-grid-concentric"},a.map(function(n,c){var d=c;return r==="circle"?me.createElement(Ii,Mt({key:d},s,{radius:n,index:c})):me.createElement(Bi,Mt({key:d},s,{radius:n,index:c}))}))},nn=function(s){var a=s.cx,r=a===void 0?0:a,n=s.cy,c=n===void 0?0:n,d=s.innerRadius,i=d===void 0?0:d,l=s.outerRadius,o=l===void 0?0:l,u=s.gridType,v=u===void 0?"polygon":u,h=s.radialLines,m=h===void 0?!0:h,f=Ri(s,Ti);return o<=0?null:me.createElement("g",{className:"recharts-polar-grid"},me.createElement(Oi,Mt({cx:r,cy:c,innerRadius:i,outerRadius:o,gridType:v,radialLines:m},f)),me.createElement(zi,Mt({cx:r,cy:c,innerRadius:i,outerRadius:o,gridType:v,radialLines:m},f)))};nn.displayName="PolarGrid";function $i(t){return t&&t.length?t[0]:void 0}var Vi=$i,Wi=Vi;const qi=An(Wi);var Hi=["key"];function Jt(t){"@babel/helpers - typeof";return Jt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},Jt(t)}function Gi(t,s){if(t==null)return{};var a=Ki(t,s),r,n;if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(t);for(n=0;n<c.length;n++)r=c[n],!(s.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(a[r]=t[r])}return a}function Ki(t,s){if(t==null)return{};var a={};for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){if(s.indexOf(r)>=0)continue;a[r]=t[r]}return a}function Is(){return Is=Object.assign?Object.assign.bind():function(t){for(var s=1;s<arguments.length;s++){var a=arguments[s];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(t[r]=a[r])}return t},Is.apply(this,arguments)}function ar(t,s){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);s&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),a.push.apply(a,r)}return a}function Ge(t){for(var s=1;s<arguments.length;s++){var a=arguments[s]!=null?arguments[s]:{};s%2?ar(Object(a),!0).forEach(function(r){yt(t,r,a[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):ar(Object(a)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(a,r))})}return t}function Ui(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function rr(t,s){for(var a=0;a<s.length;a++){var r=s[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,on(r.key),r)}}function Xi(t,s,a){return s&&rr(t.prototype,s),a&&rr(t,a),Object.defineProperty(t,"prototype",{writable:!1}),t}function Yi(t,s,a){return s=Bs(s),Qi(t,ln()?Reflect.construct(s,a||[],Bs(t).constructor):s.apply(t,a))}function Qi(t,s){if(s&&(Jt(s)==="object"||typeof s=="function"))return s;if(s!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Zi(t)}function Zi(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function ln(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ln=function(){return!!t})()}function Bs(t){return Bs=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(a){return a.__proto__||Object.getPrototypeOf(a)},Bs(t)}function Ji(t,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(s&&s.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),s&&ya(t,s)}function ya(t,s){return ya=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,n){return r.__proto__=n,r},ya(t,s)}function yt(t,s,a){return s=on(s),s in t?Object.defineProperty(t,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[s]=a,t}function on(t){var s=el(t,"string");return Jt(s)=="symbol"?s:s+""}function el(t,s){if(Jt(t)!="object"||!t)return t;var a=t[Symbol.toPrimitive];if(a!==void 0){var r=a.call(t,s||"default");if(Jt(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(t)}var es=function(t){function s(){var a;Ui(this,s);for(var r=arguments.length,n=new Array(r),c=0;c<r;c++)n[c]=arguments[c];return a=Yi(this,s,[].concat(n)),yt(a,"state",{isAnimationFinished:!1}),yt(a,"handleAnimationEnd",function(){var d=a.props.onAnimationEnd;a.setState({isAnimationFinished:!0}),is(d)&&d()}),yt(a,"handleAnimationStart",function(){var d=a.props.onAnimationStart;a.setState({isAnimationFinished:!1}),is(d)&&d()}),yt(a,"handleMouseEnter",function(d){var i=a.props.onMouseEnter;i&&i(a.props,d)}),yt(a,"handleMouseLeave",function(d){var i=a.props.onMouseLeave;i&&i(a.props,d)}),a}return Ji(s,t),Xi(s,[{key:"renderDots",value:function(r){var n=this.props,c=n.dot,d=n.dataKey,i=wt(this.props,!1),l=wt(c,!0),o=r.map(function(u,v){var h=Ge(Ge(Ge({key:"dot-".concat(v),r:3},i),l),{},{dataKey:d,cx:u.x,cy:u.y,index:v,payload:u});return s.renderDotItem(c,h)});return me.createElement(Tt,{className:"recharts-radar-dots"},o)}},{key:"renderPolygonStatically",value:function(r){var n=this.props,c=n.shape,d=n.dot,i=n.isRange,l=n.baseLinePoints,o=n.connectNulls,u;return me.isValidElement(c)?u=me.cloneElement(c,Ge(Ge({},this.props),{},{points:r})):is(c)?u=c(Ge(Ge({},this.props),{},{points:r})):u=me.createElement(si,Is({},wt(this.props,!0),{onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave,points:r,baseLinePoints:i?l:null,connectNulls:o})),me.createElement(Tt,{className:"recharts-radar-polygon"},u,d?this.renderDots(r):null)}},{key:"renderPolygonWithAnimation",value:function(){var r=this,n=this.props,c=n.points,d=n.isAnimationActive,i=n.animationBegin,l=n.animationDuration,o=n.animationEasing,u=n.animationId,v=this.state.prevPoints;return me.createElement(Ir,{begin:i,duration:l,isActive:d,easing:o,from:{t:0},to:{t:1},key:"radar-".concat(u),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(h){var m=h.t,f=v&&v.length/c.length,b=c.map(function(_,y){var N=v&&v[Math.floor(y*f)];if(N){var w=Ft(N.x,_.x),g=Ft(N.y,_.y);return Ge(Ge({},_),{},{x:w(m),y:g(m)})}var k=Ft(_.cx,_.x),M=Ft(_.cy,_.y);return Ge(Ge({},_),{},{x:k(m),y:M(m)})});return r.renderPolygonStatically(b)})}},{key:"renderPolygon",value:function(){var r=this.props,n=r.points,c=r.isAnimationActive,d=r.isRange,i=this.state.prevPoints;return c&&n&&n.length&&!d&&(!i||!Br(i,n))?this.renderPolygonWithAnimation():this.renderPolygonStatically(n)}},{key:"render",value:function(){var r=this.props,n=r.hide,c=r.className,d=r.points,i=r.isAnimationActive;if(n||!d||!d.length)return null;var l=this.state.isAnimationFinished,o=ms("recharts-radar",c);return me.createElement(Tt,{className:o},this.renderPolygon(),(!i||l)&&zr.renderCallByParent(this.props,d))}}],[{key:"getDerivedStateFromProps",value:function(r,n){return r.animationId!==n.prevAnimationId?{prevAnimationId:r.animationId,curPoints:r.points,prevPoints:n.curPoints}:r.points!==n.curPoints?{curPoints:r.points}:null}},{key:"renderDotItem",value:function(r,n){var c;if(me.isValidElement(r))c=me.cloneElement(r,n);else if(is(r))c=r(n);else{var d=n.key,i=Gi(n,Hi);c=me.createElement(Kn,Is({},i,{key:d,className:ms("recharts-radar-dot",typeof r!="boolean"?r.className:"")}))}return c}}])}(j.PureComponent);yt(es,"displayName","Radar");yt(es,"defaultProps",{angleAxisId:0,radiusAxisId:0,hide:!1,activeDot:!0,dot:!1,legendType:"rect",isAnimationActive:!$r.isSsr,animationBegin:0,animationDuration:1500,animationEasing:"ease"});yt(es,"getComposedData",function(t){var s=t.radiusAxis,a=t.angleAxis,r=t.displayedData,n=t.dataKey,c=t.bandSize,d=a.cx,i=a.cy,l=!1,o=[],u=a.type!=="number"?c??0:0;r.forEach(function(h,m){var f=qt(h,a.dataKey,m),b=qt(h,n),_=a.scale(f)+u,y=Array.isArray(b)?Un(b):b,N=Rt(y)?void 0:s.scale(y);Array.isArray(b)&&b.length>=2&&(l=!0),o.push(Ge(Ge({},ps(d,i,N,_)),{},{name:f,value:b,cx:d,cy:i,radius:N,angle:_,payload:h}))});var v=[];return l&&o.forEach(function(h){if(Array.isArray(h.value)){var m=qi(h.value),f=Rt(m)?void 0:s.scale(m);v.push(Ge(Ge({},h),{},{radius:f},ps(d,i,f,h.angle)))}else v.push(h)}),{points:o,isRange:l,baseLinePoints:v}});function ts(t){"@babel/helpers - typeof";return ts=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},ts(t)}function tl(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function sl(t,s){for(var a=0;a<s.length;a++){var r=s[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,mn(r.key),r)}}function al(t,s,a){return s&&sl(t.prototype,s),Object.defineProperty(t,"prototype",{writable:!1}),t}function rl(t,s,a){return s=zs(s),nl(t,cn()?Reflect.construct(s,a||[],zs(t).constructor):s.apply(t,a))}function nl(t,s){if(s&&(ts(s)==="object"||typeof s=="function"))return s;if(s!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return il(t)}function il(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function cn(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(cn=function(){return!!t})()}function zs(t){return zs=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(a){return a.__proto__||Object.getPrototypeOf(a)},zs(t)}function ll(t,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(s&&s.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),s&&Na(t,s)}function Na(t,s){return Na=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,n){return r.__proto__=n,r},Na(t,s)}function dn(t,s,a){return s=mn(s),s in t?Object.defineProperty(t,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[s]=a,t}function mn(t){var s=ol(t,"string");return ts(s)=="symbol"?s:s+""}function ol(t,s){if(ts(t)!="object"||!t)return t;var a=t[Symbol.toPrimitive];if(a!==void 0){var r=a.call(t,s||"default");if(ts(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(t)}var It=function(t){function s(){return tl(this,s),rl(this,s,arguments)}return ll(s,t),al(s,[{key:"render",value:function(){return null}}])}(j.Component);dn(It,"displayName","ZAxis");dn(It,"defaultProps",{zAxisId:0,range:[64,64],scale:"auto",type:"number"});var cl=["option","isActive"];function os(){return os=Object.assign?Object.assign.bind():function(t){for(var s=1;s<arguments.length;s++){var a=arguments[s];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(t[r]=a[r])}return t},os.apply(this,arguments)}function dl(t,s){if(t==null)return{};var a=ml(t,s),r,n;if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(t);for(n=0;n<c.length;n++)r=c[n],!(s.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(a[r]=t[r])}return a}function ml(t,s){if(t==null)return{};var a={};for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){if(s.indexOf(r)>=0)continue;a[r]=t[r]}return a}function xl(t){var s=t.option,a=t.isActive,r=dl(t,cl);return typeof s=="string"?j.createElement(Xa,os({option:j.createElement(Xn,os({type:s},r)),isActive:a,shapeType:"symbols"},r)):j.createElement(Xa,os({option:s,isActive:a,shapeType:"symbols"},r))}function ss(t){"@babel/helpers - typeof";return ss=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},ss(t)}function cs(){return cs=Object.assign?Object.assign.bind():function(t){for(var s=1;s<arguments.length;s++){var a=arguments[s];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(t[r]=a[r])}return t},cs.apply(this,arguments)}function nr(t,s){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);s&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),a.push.apply(a,r)}return a}function nt(t){for(var s=1;s<arguments.length;s++){var a=arguments[s]!=null?arguments[s]:{};s%2?nr(Object(a),!0).forEach(function(r){Dt(t,r,a[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):nr(Object(a)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(a,r))})}return t}function ul(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function ir(t,s){for(var a=0;a<s.length;a++){var r=s[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,un(r.key),r)}}function hl(t,s,a){return s&&ir(t.prototype,s),a&&ir(t,a),Object.defineProperty(t,"prototype",{writable:!1}),t}function pl(t,s,a){return s=$s(s),gl(t,xn()?Reflect.construct(s,a||[],$s(t).constructor):s.apply(t,a))}function gl(t,s){if(s&&(ss(s)==="object"||typeof s=="function"))return s;if(s!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return fl(t)}function fl(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function xn(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(xn=function(){return!!t})()}function $s(t){return $s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(a){return a.__proto__||Object.getPrototypeOf(a)},$s(t)}function bl(t,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(s&&s.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),s&&wa(t,s)}function wa(t,s){return wa=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,n){return r.__proto__=n,r},wa(t,s)}function Dt(t,s,a){return s=un(s),s in t?Object.defineProperty(t,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[s]=a,t}function un(t){var s=vl(t,"string");return ss(s)=="symbol"?s:s+""}function vl(t,s){if(ss(t)!="object"||!t)return t;var a=t[Symbol.toPrimitive];if(a!==void 0){var r=a.call(t,s||"default");if(ss(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(t)}var Bt=function(t){function s(){var a;ul(this,s);for(var r=arguments.length,n=new Array(r),c=0;c<r;c++)n[c]=arguments[c];return a=pl(this,s,[].concat(n)),Dt(a,"state",{isAnimationFinished:!1}),Dt(a,"handleAnimationEnd",function(){a.setState({isAnimationFinished:!0})}),Dt(a,"handleAnimationStart",function(){a.setState({isAnimationFinished:!1})}),Dt(a,"id",ei("recharts-scatter-")),a}return bl(s,t),hl(s,[{key:"renderSymbolsStatically",value:function(r){var n=this,c=this.props,d=c.shape,i=c.activeShape,l=c.activeIndex,o=wt(this.props,!1);return r.map(function(u,v){var h=l===v,m=h?i:d,f=nt(nt({},o),u);return me.createElement(Tt,cs({className:"recharts-scatter-symbol",key:"symbol-".concat(u==null?void 0:u.cx,"-").concat(u==null?void 0:u.cy,"-").concat(u==null?void 0:u.size,"-").concat(v)},Yn(n.props,u,v),{role:"img"}),me.createElement(xl,cs({option:m,isActive:h,key:"symbol-".concat(v)},f)))})}},{key:"renderSymbolsWithAnimation",value:function(){var r=this,n=this.props,c=n.points,d=n.isAnimationActive,i=n.animationBegin,l=n.animationDuration,o=n.animationEasing,u=n.animationId,v=this.state.prevPoints;return me.createElement(Ir,{begin:i,duration:l,isActive:d,easing:o,from:{t:0},to:{t:1},key:"pie-".concat(u),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(h){var m=h.t,f=c.map(function(b,_){var y=v&&v[_];if(y){var N=Ft(y.cx,b.cx),w=Ft(y.cy,b.cy),g=Ft(y.size,b.size);return nt(nt({},b),{},{cx:N(m),cy:w(m),size:g(m)})}var k=Ft(0,b.size);return nt(nt({},b),{},{size:k(m)})});return me.createElement(Tt,null,r.renderSymbolsStatically(f))})}},{key:"renderSymbols",value:function(){var r=this.props,n=r.points,c=r.isAnimationActive,d=this.state.prevPoints;return c&&n&&n.length&&(!d||!Br(d,n))?this.renderSymbolsWithAnimation():this.renderSymbolsStatically(n)}},{key:"renderErrorBar",value:function(){var r=this.props.isAnimationActive;if(r&&!this.state.isAnimationFinished)return null;var n=this.props,c=n.points,d=n.xAxis,i=n.yAxis,l=n.children,o=Vr(l,Qn);return o?o.map(function(u,v){var h=u.props,m=h.direction,f=h.dataKey;return me.cloneElement(u,{key:"".concat(m,"-").concat(f,"-").concat(c[v]),data:c,xAxis:d,yAxis:i,layout:m==="x"?"vertical":"horizontal",dataPointFormatter:function(_,y){return{x:_.cx,y:_.cy,value:m==="x"?+_.node.x:+_.node.y,errorVal:qt(_,y)}}})}):null}},{key:"renderLine",value:function(){var r=this.props,n=r.points,c=r.line,d=r.lineType,i=r.lineJointType,l=wt(this.props,!1),o=wt(c,!1),u,v;if(d==="joint")u=n.map(function(w){return{x:w.cx,y:w.cy}});else if(d==="fitting"){var h=Zn(n),m=h.xmin,f=h.xmax,b=h.a,_=h.b,y=function(g){return b*g+_};u=[{x:m,y:y(m)},{x:f,y:y(f)}]}var N=nt(nt(nt({},l),{},{fill:"none",stroke:l&&l.fill},o),{},{points:u});return me.isValidElement(c)?v=me.cloneElement(c,N):is(c)?v=c(N):v=me.createElement(Jn,cs({},N,{type:i})),me.createElement(Tt,{className:"recharts-scatter-line",key:"recharts-scatter-line"},v)}},{key:"render",value:function(){var r=this.props,n=r.hide,c=r.points,d=r.line,i=r.className,l=r.xAxis,o=r.yAxis,u=r.left,v=r.top,h=r.width,m=r.height,f=r.id,b=r.isAnimationActive;if(n||!c||!c.length)return null;var _=this.state.isAnimationFinished,y=ms("recharts-scatter",i),N=l&&l.allowDataOverflow,w=o&&o.allowDataOverflow,g=N||w,k=Rt(f)?this.id:f;return me.createElement(Tt,{className:y,clipPath:g?"url(#clipPath-".concat(k,")"):null},N||w?me.createElement("defs",null,me.createElement("clipPath",{id:"clipPath-".concat(k)},me.createElement("rect",{x:N?u:u-h/2,y:w?v:v-m/2,width:N?h:h*2,height:w?m:m*2}))):null,d&&this.renderLine(),this.renderErrorBar(),me.createElement(Tt,{key:"recharts-scatter-symbols"},this.renderSymbols()),(!b||_)&&zr.renderCallByParent(this.props,c))}}],[{key:"getDerivedStateFromProps",value:function(r,n){return r.animationId!==n.prevAnimationId?{prevAnimationId:r.animationId,curPoints:r.points,prevPoints:n.curPoints}:r.points!==n.curPoints?{curPoints:r.points}:null}}])}(j.PureComponent);Dt(Bt,"displayName","Scatter");Dt(Bt,"defaultProps",{xAxisId:0,yAxisId:0,zAxisId:0,legendType:"circle",lineType:"joint",lineJointType:"linear",data:[],shape:"circle",hide:!1,isAnimationActive:!$r.isSsr,animationBegin:0,animationDuration:400,animationEasing:"linear"});Dt(Bt,"getComposedData",function(t){var s=t.xAxis,a=t.yAxis,r=t.zAxis,n=t.item,c=t.displayedData,d=t.xAxisTicks,i=t.yAxisTicks,l=t.offset,o=n.props.tooltipType,u=Vr(n.props.children,rt),v=Rt(s.dataKey)?n.props.dataKey:s.dataKey,h=Rt(a.dataKey)?n.props.dataKey:a.dataKey,m=r&&r.dataKey,f=r?r.range:It.defaultProps.range,b=f&&f[0],_=s.scale.bandwidth?s.scale.bandwidth():0,y=a.scale.bandwidth?a.scale.bandwidth():0,N=c.map(function(w,g){var k=qt(w,v),M=qt(w,h),T=!Rt(m)&&qt(w,m)||"-",A=[{name:Rt(s.dataKey)?n.props.name:s.name||s.dataKey,unit:s.unit||"",value:k,payload:w,dataKey:v,type:o},{name:Rt(a.dataKey)?n.props.name:a.name||a.dataKey,unit:a.unit||"",value:M,payload:w,dataKey:h,type:o}];T!=="-"&&A.push({name:r.name||r.dataKey,unit:r.unit||"",value:T,payload:w,dataKey:m,type:o});var B=Ya({axis:s,ticks:d,bandSize:_,entry:w,index:g,dataKey:v}),z=Ya({axis:a,ticks:i,bandSize:y,entry:w,index:g,dataKey:h}),U=T!=="-"?r.scale(T):b,G=Math.sqrt(Math.max(U,0)/Math.PI);return nt(nt({},w),{},{cx:B,cy:z,x:B-G,y:z-G,xAxis:s,yAxis:a,zAxis:r,width:2*G,height:2*G,size:U,node:{x:k,y:M,z:T},tooltipPayload:A,tooltipPosition:{x:B,y:z},payload:w},u&&u[g]&&u[g].props)});return nt({points:N},l)});var jl=Pa({chartName:"RadarChart",GraphicalChild:es,axisComponents:[{axisType:"angleAxis",AxisComp:qr},{axisType:"radiusAxis",AxisComp:Hr}],formatAxisMap:ti,defaultProps:{layout:"centric",startAngle:90,endAngle:-270,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"}}),hn=Pa({chartName:"ScatterChart",GraphicalChild:Bt,defaultTooltipEventType:"item",validateTooltipEventTypes:["item"],axisComponents:[{axisType:"xAxis",AxisComp:de},{axisType:"yAxis",AxisComp:oe},{axisType:"zAxis",AxisComp:It}],formatAxisMap:Wr}
116),Js=Pa({chartName:"ComposedChart",GraphicalChild:[Fe,We,Ye,Bt],axisComponents:[{axisType:"xAxis",AxisComp:de},{axisType:"yAxis",AxisComp:oe},{axisType:"zAxis",AxisComp:It}],formatAxisMap:Wr});const yl=j.memo(function({symbol:s,changePercent:a,isSelected:r=!1,onClick:n,className:c,size:d="md"}){const i=(a??0)>=0,l=j.useMemo(()=>({sm:"min-w-[72px] h-[52px] text-xs",md:"min-w-[88px] h-[60px] text-sm",lg:"min-w-[100px] h-[68px] text-base"}),[]),o=j.useMemo(()=>({sm:"text-[10px]",md:"text-xs",lg:"text-sm"}),[]);return e.jsxs("button",{onClick:n,className:O("relative flex flex-col items-center justify-center gap-0.5","rounded-lg border transition-all duration-150","select-none touch-manipulation","active:scale-[0.97]",l[d],r?["bg-primary/10 border-primary/60","shadow-[0_0_12px_rgba(var(--primary),0.3)]"]:["bg-card/40 border-border/40 hover:border-border/60","hover:bg-card/60"],c),style:{WebkitTapHighlightColor:"transparent"},children:[e.jsx("span",{className:O("font-semibold tracking-tight",r?"text-primary":"text-foreground"),children:s}),a!==void 0&&e.jsxs("span",{className:O("font-mono font-medium tabular-nums",o[d],i?"text-profit":"text-loss"),children:[i?"+":"",a.toFixed(2),"%"]}),r&&e.jsx("div",{className:"absolute inset-0 rounded-lg bg-primary/5 pointer-events-none"})]})}),Nl=j.memo(function({symbols:s,selectedSymbols:a,onToggle:r,priceData:n,className:c,size:d="md",columns:i=6}){const l=j.useMemo(()=>({3:"grid-cols-3",4:"grid-cols-4",5:"grid-cols-5",6:"grid-cols-6"}),[]),o=(u,v)=>{var m;return((m=n==null?void 0:n[u])==null?void 0:m.changePercent)!==void 0?n[u].changePercent:(u.split("").reduce((f,b)=>f+b.charCodeAt(0),0)*17+v*31)%1e3/100-5};return e.jsx("div",{className:O("grid gap-2",l[i],"max-md:grid-cols-3",c),children:s.map((u,v)=>e.jsx(yl,{symbol:u,changePercent:o(u,v),isSelected:a.includes(u),onClick:()=>r(u),size:d},u))})});var ae=function(){return ae=Object.assign||function(s){for(var a,r=1,n=arguments.length;r<n;r++){a=arguments[r];for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(s[c]=a[c])}return s},ae.apply(this,arguments)};function wl(t,s){var a={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&s.indexOf(r)<0&&(a[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(t);n<r.length;n++)s.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(a[r[n]]=t[r[n]]);return a}function pn(t,s,a){for(var r=0,n=s.length,c;r<n;r++)(c||!(r in s))&&(c||(c=Array.prototype.slice.call(s,0,r)),c[r]=s[r]);return t.concat(c||Array.prototype.slice.call(s))}function Ns(t){return t.mode==="multiple"}function ws(t){return t.mode==="range"}function ea(t){return t.mode==="single"}var _l={root:"rdp",multiple_months:"rdp-multiple_months",with_weeknumber:"rdp-with_weeknumber",vhidden:"rdp-vhidden",button_reset:"rdp-button_reset",button:"rdp-button",caption:"rdp-caption",caption_start:"rdp-caption_start",caption_end:"rdp-caption_end",caption_between:"rdp-caption_between",caption_label:"rdp-caption_label",caption_dropdowns:"rdp-caption_dropdowns",dropdown:"rdp-dropdown",dropdown_month:"rdp-dropdown_month",dropdown_year:"rdp-dropdown_year",dropdown_icon:"rdp-dropdown_icon",months:"rdp-months",month:"rdp-month",table:"rdp-table",tbody:"rdp-tbody",tfoot:"rdp-tfoot",head:"rdp-head",head_row:"rdp-head_row",head_cell:"rdp-head_cell",nav:"rdp-nav",nav_button:"rdp-nav_button",nav_button_previous:"rdp-nav_button_previous",nav_button_next:"rdp-nav_button_next",nav_icon:"rdp-nav_icon",row:"rdp-row",weeknumber:"rdp-weeknumber",cell:"rdp-cell",day:"rdp-day",day_today:"rdp-day_today",day_outside:"rdp-day_outside",day_selected:"rdp-day_selected",day_disabled:"rdp-day_disabled",day_hidden:"rdp-day_hidden",day_range_start:"rdp-day_range_start",day_range_end:"rdp-day_range_end",day_range_middle:"rdp-day_range_middle"};function kl(t,s){return kt(t,"LLLL y",s)}function Sl(t,s){return kt(t,"d",s)}function Ml(t,s){return kt(t,"LLLL",s)}function Al(t){return"".concat(t)}function Cl(t,s){return kt(t,"cccccc",s)}function Tl(t,s){return kt(t,"yyyy",s)}var Rl=Object.freeze({__proto__:null,formatCaption:kl,formatDay:Sl,formatMonthCaption:Ml,formatWeekNumber:Al,formatWeekdayName:Cl,formatYearC
116aption:Tl}),Pl=function(t,s,a){return kt(t,"do MMMM (EEEE)",a)},Fl=function(){return"Month: "},Dl=function(){return"Go to next month"},El=function(){return"Go to previous month"},Ll=function(t,s){return kt(t,"cccc",s)},Ol=function(t){return"Week n. ".concat(t)},Il=function(){return"Year: "},Bl=Object.freeze({__proto__:null,labelDay:Pl,labelMonthDropdown:Fl,labelNext:Dl,labelPrevious:El,labelWeekNumber:Ol,labelWeekday:Ll,labelYearDropdown:Il});function zl(){var t="buttons",s=_l,a=Cn,r={},n={},c=1,d={},i=new Date;return{captionLayout:t,classNames:s,formatters:Rl,labels:Bl,locale:a,modifiersClassNames:r,modifiers:n,numberOfMonths:c,styles:d,today:i,mode:"default"}}function $l(t){var s=t.fromYear,a=t.toYear,r=t.fromMonth,n=t.toMonth,c=t.fromDate,d=t.toDate;return r?c=et(r):s&&(c=new Date(s,0,1)),n?d=ka(n):a&&(d=new Date(a,11,31)),{fromDate:c?Es(c):void 0,toDate:d?Es(d):void 0}}var gn=j.createContext(void 0);function Vl(t){var s,a=t.initialProps,r=zl(),n=$l(a),c=n.fromDate,d=n.toDate,i=(s=a.captionLayout)!==null&&s!==void 0?s:r.captionLayout;i!=="buttons"&&(!c||!d)&&(i="buttons");var l;(ea(a)||Ns(a)||ws(a))&&(l=a.onSelect);var o=ae(ae(ae({},r),a),{captionLayout:i,classNames:ae(ae({},r.classNames),a.classNames),components:ae({},a.components),formatters:ae(ae({},r.formatters),a.formatters),fromDate:c,labels:ae(ae({},r.labels),a.labels),mode:a.mode||r.mode,modifiers:ae(ae({},r.modifiers),a.modifiers),modifiersClassNames:ae(ae({},r.modifiersClassNames),a.modifiersClassNames),onSelect:l,styles:ae(ae({},r.styles),a.styles),toDate:d});return e.jsx(gn.Provider,{value:o,children:t.children})}function we(){var t=j.useContext(gn);if(!t)throw new Error("useDayPicker must be used within a DayPickerProvider.");return t}function fn(t){var s=we(),a=s.locale,r=s.classNames,n=s.styles,c=s.formatters.formatCaption;return e.jsx("div",{className:r.caption_label,style:n.caption_label,"aria-live":"polite",role:"presentation",id:t.id,children:c(t.displayMonth,{locale:a})})}function Wl(t){return e.jsx("svg",ae({width:"8px",height:"8px",viewBox:"0 0 120 120","data-testid":"iconDropdown"},t,{children:e.jsx("path",{d:"M4.22182541,48.2218254 C8.44222828,44.0014225 15.2388494,43.9273804 19.5496459,47.9996989 L19.7781746,48.2218254 L60,88.443 L100.221825,48.2218254 C104.442228,44.0014225 111.238849,43.9273804 115.549646,47.9996989 L115.778175,48.2218254 C119.998577,52.4422283 120.07262,59.2388494 116.000301,63.5496459 L115.778175,63.7781746 L67.7781746,111.778175 C63.5577717,115.998577 56.7611506,116.07262 52.4503541,112.000301 L52.2218254,111.778175 L4.22182541,63.7781746 C-0.0739418023,59.4824074 -0.0739418023,52.5175926 4.22182541,48.2218254 Z",fill:"currentColor",fillRule:"nonzero"})}))}function bn(t){var s,a,r=t.onChange,n=t.value,c=t.children,d=t.caption,i=t.className,l=t.style,o=we(),u=(a=(s=o.components)===null||s===void 0?void 0:s.IconDropdown)!==null&&a!==void 0?a:Wl;return e.jsxs("div",{className:i,style:l,children:[e.jsx("span",{className:o.classNames.vhidden,children:t["aria-label"]}),e.jsx("select",{name:t.name,"aria-label":t["aria-label"],className:o.classNames.dropdown,style:o.styles.dropdown,value:n,onChange:r,children:c}),e.jsxs("div",{className:o.classNames.caption_label,style:o.styles.caption_label,"aria-hidden":"true",children:[d,e.jsx(u,{className:o.classNames.dropdown_icon,style:o.styles.dropdown_icon})]})]})}function ql(t){var s,a=we(),r=a.fromDate,n=a.toDate,c=a.styles,d=a.locale,i=a.formatters.formatMonthCaption,l=a.classNames,o=a.components,u=a.labels.labelMonthDropdown;if(!r)return e.jsx(e.Fragment,{});if(!n)return e.jsx(e.Fragment,{});var v=[];if(Ci(r,n))for(var h=et(r),m=r.getMonth();m<=n.getMonth();m++)v.push(aa(h,m));else for(var h=et(new Date),m=0;m<=11;m++)v.push(aa(h,m));var f=function(_){var y=Number(_.target.value),N=aa(et(t.displayMonth),y);t.onChange(N)},b=(s=o==null?void 0:o.Dropdown)!==null&&s!==void 0?s:bn;return e.jsx(b,{name:"months","aria-label":u(),className:l.dropdown_month,style:c.dropdown_month,onChange:f,value:t.displayMonth.getMonth(),caption:i(t.displayMonth,{locale:d}),children:v.map(function(_){return e.jsx("option",{value:_.getMonth(),children:i(_,{locale:d})},_.getMonth())})})}function Hl(t){var s,a=t.displayMonth,r=we(),n=r.fromDate,c=r.toDate,d=r.locale,i=r.styles,l=r.classNames,o=r.components,u=r.formatters.formatYearC
116aption,v=r.labels.labelYearDropdown,h=[];if(!n)return e.jsx(e.Fragment,{});if(!c)return e.jsx(e.Fragment,{});for(var m=n.getFullYear(),f=c.getFullYear(),b=m;b<=f;b++)h.push(tr(qn(new Date),b));var _=function(N){var w=tr(et(a),Number(N.target.value));t.onChange(w)},y=(s=o==null?void 0:o.Dropdown)!==null&&s!==void 0?s:bn;return e.jsx(y,{name:"years","aria-label":v(),className:l.dropdown_year,style:i.dropdown_year,onChange:_,value:a.getFullYear(),caption:u(a,{locale:d}),children:h.map(function(N){return e.jsx("option",{value:N.getFullYear(),children:u(N,{locale:d})},N.getFullYear())})})}function Gl(t,s){var a=j.useState(t),r=a[0],n=a[1],c=s===void 0?r:s;return[c,n]}function Kl(t){var s=t.month,a=t.defaultMonth,r=t.today,n=s||a||r||new Date,c=t.toDate,d=t.fromDate,i=t.numberOfMonths,l=i===void 0?1:i;if(c&&xs(c,n)<0){var o=-1*(l-1);n=xt(c,o)}return d&&xs(n,d)<0&&(n=d),et(n)}function Ul(){var t=we(),s=Kl(t),a=Gl(s,t.month),r=a[0],n=a[1],c=function(d){var i;if(!t.disableNavigation){var l=et(d);n(l),(i=t.onMonthChange)===null||i===void 0||i.call(t,l)}};return[r,c]}function Xl(t,s){for(var a=s.reverseMonths,r=s.numberOfMonths,n=et(t),c=et(xt(n,r)),d=xs(c,n),i=[],l=0;l<d;l++){var o=xt(n,l);i.push(o)}return a&&(i=i.reverse()),i}function Yl(t,s){if(!s.disableNavigation){var a=s.toDate,r=s.pagedNavigation,n=s.numberOfMonths,c=n===void 0?1:n,d=r?c:1,i=et(t);if(!a)return xt(i,d);var l=xs(a,t);if(!(l<c))return xt(i,d)}}function Ql(t,s){if(!s.disableNavigation){var a=s.fromDate,r=s.pagedNavigation,n=s.numberOfMonths,c=n===void 0?1:n,d=r?c:1,i=et(t);if(!a)return xt(i,-d);var l=xs(i,a);if(!(l<=0))return xt(i,-d)}}var vn=j.createContext(void 0);function Zl(t){var s=we(),a=Ul(),r=a[0],n=a[1],c=Xl(r,s),d=Yl(r,s),i=Ql(r,s),l=function(v){return c.some(function(h){return La(v,h)})},o=function(v,h){l(v)||(h&&rn(v,h)?n(xt(v,1+s.numberOfMonths*-1)):n(v))},u={currentMonth:r,displayMonths:c,goToMonth:n,goToDate:o,previousMonth:i,nextMonth:d,isDateDisplayed:l};return e.jsx(vn.Provider,{value:u,children:t.children})}function _s(){var t=j.useContext(vn);if(!t)throw new Error("useNavigation must be used within a NavigationProvider");return t}function lr(t){var s,a=we(),r=a.classNames,n=a.styles,c=a.components,d=_s().goToMonth,i=function(u){d(xt(u,t.displayIndex?-t.displayIndex:0))},l=(s=c==null?void 0:c.CaptionLabel)!==null&&s!==void 0?s:fn,o=e.jsx(l,{id:t.id,displayMonth:t.displayMonth});return e.jsxs("div",{className:r.caption_dropdowns,style:n.caption_dropdowns,children:[e.jsx("div",{className:r.vhidden,children:o}),e.jsx(ql,{onChange:i,displayMonth:t.displayMonth}),e.jsx(Hl,{onChange:i,displayMonth:t.displayMonth})]})}function Jl(t){return e.jsx("svg",ae({width:"16px",height:"16px",viewBox:"0 0 120 120"},t,{children:e.jsx("path",{d:"M69.490332,3.34314575 C72.6145263,0.218951416 77.6798462,0.218951416 80.8040405,3.34314575 C83.8617626,6.40086786 83.9268205,11.3179931 80.9992143,14.4548388 L80.8040405,14.6568542 L35.461,60 L80.8040405,105.343146 C83.8617626,108.400868 83.9268205,113.317993 80.9992143,116.454839 L80.8040405,116.656854 C77.7463184,119.714576 72.8291931,119.779634 69.6923475,116.852028 L69.490332,116.656854 L18.490332,65.6568542 C15.4326099,62.5991321 15.367552,57.6820069 18.2951583,54.5451612 L18.490332,54.3431458 L69.490332,3.34314575 Z",fill:"currentColor",fillRule:"nonzero"})}))}function eo(t){return e.jsx("svg",ae({width:"16px",height:"16px",viewBox:"0 0 120 120"},t,{children:e.jsx("path",{d:"M49.8040405,3.34314575 C46.6798462,0.218951416 41.6145263,0.218951416 38.490332,3.34314575 C35.4326099,6.40086786 35.367552,11.3179931 38.2951583,14.4548388 L38.490332,14.6568542 L83.8333725,60 L38.490332,105.343146 C35.4326099,108.400868 35.367552,113.317993 38.2951583,116.454839 L38.490332,116.656854 C41.5480541,119.714576 46.4651794,119.779634 49.602025,116.852028 L49.8040405,116.656854 L100.804041,65.6568542 C103.861763,62.5991321 103.926821,57.6820069 100.999214,54.5451612 L100.804041,54.3431458 L49.8040405,3.34314575 Z",fill:"currentColor"})}))}var Vs=j.forwardRef(function(t,s){var a=we(),r=a.classNames,n=a.styles,c=[r.button_reset,r.button];t.className&&c.push(t.className);var d=c.join(" "),i=ae(ae({},n.button_reset),n.button);return t.style&&Object.assign(i,t.style),e.jsx("button",ae({}
116,t,{ref:s,type:"button",className:d,style:i}))});function to(t){var s,a,r=we(),n=r.dir,c=r.locale,d=r.classNames,i=r.styles,l=r.labels,o=l.labelPrevious,u=l.labelNext,v=r.components;if(!t.nextMonth&&!t.previousMonth)return e.jsx(e.Fragment,{});var h=o(t.previousMonth,{locale:c}),m=[d.nav_button,d.nav_button_previous].join(" "),f=u(t.nextMonth,{locale:c}),b=[d.nav_button,d.nav_button_next].join(" "),_=(s=v==null?void 0:v.IconRight)!==null&&s!==void 0?s:eo,y=(a=v==null?void 0:v.IconLeft)!==null&&a!==void 0?a:Jl;return e.jsxs("div",{className:d.nav,style:i.nav,children:[!t.hidePrevious&&e.jsx(Vs,{name:"previous-month","aria-label":h,className:m,style:i.nav_button_previous,disabled:!t.previousMonth,onClick:t.onPreviousClick,children:n==="rtl"?e.jsx(_,{className:d.nav_icon,style:i.nav_icon}):e.jsx(y,{className:d.nav_icon,style:i.nav_icon})}),!t.hideNext&&e.jsx(Vs,{name:"next-month","aria-label":f,className:b,style:i.nav_button_next,disabled:!t.nextMonth,onClick:t.onNextClick,children:n==="rtl"?e.jsx(y,{className:d.nav_icon,style:i.nav_icon}):e.jsx(_,{className:d.nav_icon,style:i.nav_icon})})]})}function or(t){var s=we().numberOfMonths,a=_s(),r=a.previousMonth,n=a.nextMonth,c=a.goToMonth,d=a.displayMonths,i=d.findIndex(function(f){return La(t.displayMonth,f)}),l=i===0,o=i===d.length-1,u=s>1&&(l||!o),v=s>1&&(o||!l),h=function(){r&&c(r)},m=function(){n&&c(n)};return e.jsx(to,{displayMonth:t.displayMonth,hideNext:u,hidePrevious:v,nextMonth:n,previousMonth:r,onPreviousClick:h,onNextClick:m})}function so(t){var s,a=we(),r=a.classNames,n=a.disableNavigation,c=a.styles,d=a.captionLayout,i=a.components,l=(s=i==null?void 0:i.CaptionLabel)!==null&&s!==void 0?s:fn,o;return n?o=e.jsx(l,{id:t.id,displayMonth:t.displayMonth}):d==="dropdown"?o=e.jsx(lr,{displayMonth:t.displayMonth,id:t.id}):d==="dropdown-buttons"?o=e.jsxs(e.Fragment,{children:[e.jsx(lr,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id}),e.jsx(or,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id})]}):o=e.jsxs(e.Fragment,{children:[e.jsx(l,{id:t.id,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(or,{displayMonth:t.displayMonth,id:t.id})]}),e.jsx("div",{className:r.caption,style:c.caption,children:o})}function ao(t){var s=we(),a=s.footer,r=s.styles,n=s.classNames.tfoot;return a?e.jsx("tfoot",{className:n,style:r.tfoot,children:e.jsx("tr",{children:e.jsx("td",{colSpan:8,children:a})})}):e.jsx(e.Fragment,{})}function ro(t,s,a){for(var r=a?Ra(new Date):hs(new Date,{locale:t,weekStartsOn:s}),n=[],c=0;c<7;c++){var d=Qe(r,c);n.push(d)}return n}function no(){var t=we(),s=t.classNames,a=t.styles,r=t.showWeekNumber,n=t.locale,c=t.weekStartsOn,d=t.ISOWeek,i=t.formatters.formatWeekdayName,l=t.labels.labelWeekday,o=ro(n,c,d);return e.jsxs("tr",{style:a.head_row,className:s.head_row,children:[r&&e.jsx("td",{style:a.head_cell,className:s.head_cell}),o.map(function(u,v){return e.jsx("th",{scope:"col",className:s.head_cell,style:a.head_cell,"aria-label":l(u,{locale:n}),children:i(u,{locale:n})},v)})]})}function io(){var t,s=we(),a=s.classNames,r=s.styles,n=s.components,c=(t=n==null?void 0:n.HeadRow)!==null&&t!==void 0?t:no;return e.jsx("thead",{style:r.head,className:a.head,children:e.jsx(c,{})})}function lo(t){var s=we(),a=s.locale,r=s.formatters.formatDay;return e.jsx(e.Fragment,{children:r(t.date,{locale:a})})}var Oa=j.createContext(void 0);function oo(t){if(!Ns(t.initialProps)){var s={selected:void 0,modifiers:{disabled:[]}};return e.jsx(Oa.Provider,{value:s,children:t.children})}return e.jsx(co,{initialProps:t.initialProps,children:t.children})}function co(t){var s=t.initialProps,a=t.children,r=s.selected,n=s.min,c=s.max,d=function(o,u,v){var h,m;(h=s.onDayClick)===null||h===void 0||h.call(s,o,u,v);var f=!!(u.selected&&n&&(r==null?void 0:r.length)===n);if(!f){var b=!!(!u.selected&&c&&(r==null?void 0:r.length)===c);if(!b){var _=r?pn([],r):[];if(u.selected){var y=_.findIndex(function(N){return Ze(o,N)});_.splice(y,1)}else _.push(o);(m=s.onSelect)===null||m===void 0||m.call(s,_,o,u,v)}}},i={disabled:[]};r&&i.disabled.push(function(o){var u=c&&r.length>c-1,v=r.some(function(h){return Ze(h,o)});return!!(u&&!v)});var l={selected:r,onDayClick:d,modifiers:i};return e.jsx(Oa.Provider,{value:l,children:a})}function Ia(){var t=j.useContext(Oa);if(!t)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return t}function mo(t,s){var a=s||{},r=a.from,n=a.to;return r&&n?Ze(n,t)&&Ze(r,t)?void 0:Ze(n,t)?{from:n,to:void 0}:Ze(r,t)?void 0:ja(r,t)?{from:t,to:n}:{from:r,to:t}:n?ja(t,n)?{from:n,to:t}:{from:t,to:n}:r?rn(t,r)?{from:t,to:r}:{from:r,to:t}:{from:t,to:void 0}}var Ba=j.createContext(void 0);function xo(t){if(!ws(t.initialProps)){var s={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return e.jsx(Ba.Provider,{value:s,children:t.children})}return e.jsx(uo,{initialProps:t.initialProps,children:t.children})}function uo(t){var s=t.initialProps,a=t.children,r=s.selected,n=r||{},c=n.from,d=n.to,i=s.min,l=s.max,o=function(m,f,b){var _,y;
116(_=s.onDayClick)===null||_===void 0||_.call(s,m,f,b);var N=mo(m,r);(y=s.onSelect)===null||y===void 0||y.call(s,N,m,f,b)},u={range_start:[],range_end:[],range_middle:[],disabled:[]};if(c?(u.range_start=[c],d?(u.range_end=[d],Ze(c,d)||(u.range_middle=[{after:c,before:d}])):u.range_end=[c]):d&&(u.range_start=[d],u.range_end=[d]),i&&(c&&!d&&u.disabled.push({after:sa(c,i-1),before:Qe(c,i-1)}),c&&d&&u.disabled.push({after:c,before:Qe(c,i-1)}),!c&&d&&u.disabled.push({after:sa(d,i-1),before:Qe(d,i-1)})),l){if(c&&!d&&(u.disabled.push({before:Qe(c,-l+1)}),u.disabled.push({after:Qe(c,l-1)})),c&&d){var v=Nt(d,c)+1,h=l-v;u.disabled.push({before:sa(c,h)}),u.disabled.push({after:Qe(d,h)})}!c&&d&&(u.disabled.push({before:Qe(d,-l+1)}),u.disabled.push({after:Qe(d,l-1)}))}return e.jsx(Ba.Provider,{value:{selected:r,onDayClick:o,modifiers:u},children:a})}function za(){var t=j.useContext(Ba);if(!t)throw new Error("useSelectRange must be used within a SelectRangeProvider");return t}function Rs(t){return Array.isArray(t)?pn([],t):t!==void 0?[t]:[]}function ho(t){var s={};return Object.entries(t).forEach(function(a){var r=a[0],n=a[1];s[r]=Rs(n)}),s}var ut;(function(t){t.Outside="outside",t.Disabled="disabled",t.Selected="selected",t.Hidden="hidden",t.Today="today",t.RangeStart="range_start",t.RangeEnd="range_end",t.RangeMiddle="range_middle"})(ut||(ut={}));var po=ut.Selected,jt=ut.Disabled,go=ut.Hidden,fo=ut.Today,ra=ut.RangeEnd,na=ut.RangeMiddle,ia=ut.RangeStart,bo=ut.Outside;function vo(t,s,a){var r,n=(r={},r[po]=Rs(t.selected),r[jt]=Rs(t.disabled),r[go]=Rs(t.hidden),r[fo]=[t.today],r[ra]=[],r[na]=[],r[ia]=[],r[bo]=[],r);return t.fromDate&&n[jt].push({before:t.fromDate}),t.toDate&&n[jt].push({after:t.toDate}),Ns(t)?n[jt]=n[jt].concat(s.modifiers[jt]):ws(t)&&(n[jt]=n[jt].concat(a.modifiers[jt]),n[ia]=a.modifiers[ia],n[na]=a.modifiers[na],n[ra]=a.modifiers[ra]),n}var jn=j.createContext(void 0);function jo(t){var s=we(),a=Ia(),r=za(),n=vo(s,a,r),c=ho(s.modifiers),d=ae(ae({},n),c);return e.jsx(jn.Provider,{value:d,children:t.children})}function yn(){var t=j.useContext(jn);if(!t)throw new Error("useModifiers must be used within a ModifiersProvider");return t}function yo(t){return!!(t&&typeof t=="object"&&"before"in t&&"after"in t)}function No(t){return!!(t&&typeof t=="object"&&"from"in t)}function wo(t){return!!(t&&typeof t=="object"&&"after"in t)}function _o(t){return!!(t&&typeof t=="object"&&"before"in t)}function ko(t){return!!(t&&typeof t=="object"&&"dayOfWeek"in t)}function So(t,s){var a,r=s.from,n=s.to;if(r&&n){var c=Nt(n,r)<0;c&&(a=[n,r],r=a[0],n=a[1]);var d=Nt(t,r)>=0&&Nt(n,t)>=0;return d}return n?Ze(n,t):r?Ze(r,t):!1}function Mo(t){return Lr(t)}function Ao(t){return Array.isArray(t)&&t.every(Lr)}function Co(t,s){return s.some(function(a){if(typeof a=="boolean")return a;
116if(Mo(a))return Ze(t,a);if(Ao(a))return a.includes(t);if(No(a))return So(t,a);if(ko(a))return a.dayOfWeek.includes(t.getDay());if(yo(a)){var r=Nt(a.before,t),n=Nt(a.after,t),c=r>0,d=n<0,i=ja(a.before,a.after);return i?d&&c:c||d}return wo(a)?Nt(t,a.after)>0:_o(a)?Nt(a.before,t)>0:typeof a=="function"?a(t):!1})}function $a(t,s,a){var r=Object.keys(s).reduce(function(c,d){var i=s[d];return Co(t,i)&&c.push(d),c},[]),n={};return r.forEach(function(c){return n[c]=!0}),a&&!La(t,a)&&(n.outside=!0),n}function To(t,s){for(var a=et(t[0]),r=ka(t[t.length-1]),n,c,d=a;d<=r;){var i=$a(d,s),l=!i.disabled&&!i.hidden;if(!l){d=Qe(d,1);continue}if(i.selected)return d;i.today&&!c&&(c=d),n||(n=d),d=Qe(d,1)}return c||n}var Ro=365;function Nn(t,s){var a=s.moveBy,r=s.direction,n=s.context,c=s.modifiers,d=s.retry,i=d===void 0?{count:0,lastFocused:t}:d,l=n.weekStartsOn,o=n.fromDate,u=n.toDate,v=n.locale,h={day:Qe,week:va,month:xt,year:yi,startOfWeek:function(_){return n.ISOWeek?Ra(_):hs(_,{locale:v,weekStartsOn:l})},endOfWeek:function(_){return n.ISOWeek?an(_):Ea(_,{locale:v,weekStartsOn:l})}},m=h[a](t,r==="after"?1:-1);r==="before"&&o?m=Ni([o,m]):r==="after"&&u&&(m=wi([u,m]));var f=!0;if(c){var b=$a(m,c);f=!b.disabled&&!b.hidden}return f?m:i.count>Ro?i.lastFocused:Nn(m,{moveBy:a,direction:r,context:n,modifiers:c,retry:ae(ae({},i),{count:i.count+1})})}var wn=j.createContext(void 0);function Po(t){var s=_s(),a=yn(),r=j.useState(),n=r[0],c=r[1],d=j.useState(),i=d[0],l=d[1],o=To(s.displayMonths,a),u=n??(i&&s.isDateDisplayed(i))?i:o,v=function(){l(n),c(void 0)},h=function(_){c(_)},m=we(),f=function(_,y){if(n){var N=Nn(n,{moveBy:_,direction:y,context:m,modifiers:a});Ze(n,N)||(s.goToDate(N,n),h(N))}},b={focusedDay:n,focusTarget:u,blur:v,focus:h,focusDayAfter:function(){return f("day","after")},focusDayBefore:function(){return f("day","before")},focusWeekAfter:function(){return f("week","after")},focusWeekBefore:function(){return f("week","before")},focusMonthBefore:function(){return f("month","before")},focusMonthAfter:function(){return f("month","after")},focusYearBefore:function(){return f("year","before")},focusYearAfter:function(){return f("year","after")},focusStartOfWeek:function(){return f("startOfWeek","before")},focusEndOfWeek:function(){return f("endOfWeek","after")}};return e.jsx(wn.Provider,{value:b,children:t.children})}function Va(){var t=j.useContext(wn);if(!t)throw new Error("useFocusContext must be used within a FocusProvider");return t}function Fo(t,s){var a=yn(),r=$a(t,a,s);return r}var Wa=j.createContext(void 0);function Do(t){if(!ea(t.initialProps)){var s={selected:void 0};return e.jsx(Wa.Provider,{value:s,children:t.children})}return e.jsx(Eo,{initialProps:t.initialProps,children:t.children})}function Eo(t){var s=t.initialProps,a=t.children,r=function(c,d,i){var l,o,u;if((l=s.onDayClick)===null||l===void 0||l.call(s,c,d,i),d.selected&&!s.required){(o=s.onSelect)===null||o===void 0||o.call(s,void 0,c,d,i);return}(u=s.onSelect)===null||u===void 0||u.call(s,c,c,d,i)},n={selected:s.selected,onDayClick:r};return e.jsx(Wa.Provider,{value:n,children:a})}function _n(){var t=j.useContext(Wa);if(!t)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return t}function Lo(t,s){var a=we(),r=_n(),n=Ia(),c=za(),d=Va(),i=d.focusDayAfter,l=d.focusDayBefore,o=d.focusWeekAfter,u=d.focusWeekBefore,v=d.blur,h=d.focus,m=d.focusMonthBefore,f=d.focusMonthAfter,b=d.focusYearBefore,_=d.focusYearAfter,y=d.focusStartOfWeek,N=d.focusEndOfWeek,w=function(F){var R,Q,x,S;ea(a)?(R=r.onDayClick)===null||R===void 0||R.call(r,t,s,F):Ns(a)?(Q=n.onDayClick)===null||Q===void 0||Q.call(n,t,s,F):ws(a)?(x=c.onDayClick)===null||x===void 0||x.call(c,t,s,F):(S=a.onDayClick)===null||S===void 0||S.call(a,t,s,F)},g=function(F){var R;h(t),(R=a.onDayFocus)===null||R===void 0||R.call(a,t,s,F)},k=function(F){var R;v(),(R=a.onDayBlur)===null||R===void 0||R.call(a,t,s,F)},M=function(F){var R;(R=a.onDayMouseEnter)===null||R===void 0||R.call(a,t,s,F)},T=function(F){var R;(R=a.onDayMouseLeave)===null||R===void 0||R.call(a,t,s,F)},A=function(F){var R;(R=a.onDayPointerEnter)===null||R===void 0||R.call(a,t,s,F)},B=function(F){var R;(R=a.onDayPointerLeave)===null||R===void 0||R.call(a,t,s,F)},z=function(F){var R;(R=a.onDayTouchCancel)===null||R===void 0||R.call(a,t,s,F)},U=function(F){var R;(R=a.onDayTouchEnd)===null||R===void 0||R.call(a,t,s,F)},G=function(F){var R;(R=a.onDayTouchMove)===null||R===void 0||R.call(a,t,s,F)},K=function(F){var R;(R=a.onDayTouchStart)===null||R===void 0||R.call(a,t,s,F)},$=function(F){var R;(R=a.onDayKeyUp)===null||R===void 0||R.call(a,t,s,F)},L=function(F){var R;switch(F.key){case"ArrowLeft":F.preventDefault(),F.stopPropagation(),a.dir==="rtl"?i():l();break;case"ArrowRight":F.preventDefault(),F.stopPropagation(),a.dir==="rtl"?l(
116):i();break;case"ArrowDown":F.preventDefault(),F.stopPropagation(),o();break;case"ArrowUp":F.preventDefault(),F.stopPropagation(),u();break;case"PageUp":F.preventDefault(),F.stopPropagation(),F.shiftKey?b():m();break;case"PageDown":F.preventDefault(),F.stopPropagation(),F.shiftKey?_():f();break;case"Home":F.preventDefault(),F.stopPropagation(),y();break;case"End":F.preventDefault(),F.stopPropagation(),N();break}(R=a.onDayKeyDown)===null||R===void 0||R.call(a,t,s,F)},D={onClick:w,onFocus:g,onBlur:k,onKeyDown:L,onKeyUp:$,onMouseEnter:M,onMouseLeave:T,onPointerEnter:A,onPointerLeave:B,onTouchCancel:z,onTouchEnd:U,onTouchMove:G,onTouchStart:K};return D}function Oo(){var t=we(),s=_n(),a=Ia(),r=za(),n=ea(t)?s.selected:Ns(t)?a.selected:ws(t)?r.selected:void 0;return n}function Io(t){return Object.values(ut).includes(t)}function Bo(t,s){var a=[t.classNames.day];return Object.keys(s).forEach(function(r){var n=t.modifiersClassNames[r];if(n)a.push(n);else if(Io(r)){var c=t.classNames["day_".concat(r)];c&&a.push(c)}}),a}function zo(t,s){var a=ae({},t.styles.day);return Object.keys(s).forEach(function(r){var n;a=ae(ae({},a),(n=t.modifiersStyles)===null||n===void 0?void 0:n[r])}),a}function $o(t,s,a){var r,n,c,d=we(),i=Va(),l=Fo(t,s),o=Lo(t,l),u=Oo(),v=!!(d.onDayClick||d.mode!=="default");j.useEffect(function(){var M;l.outside||i.focusedDay&&v&&Ze(i.focusedDay,t)&&((M=a.current)===null||M===void 0||M.focus())},[i.focusedDay,t,a,v,l.outside]);var h=Bo(d,l).join(" "),m=zo(d,l),f=!!(l.outside&&!d.showOutsideDays||l.hidden),b=(c=(n=d.components)===null||n===void 0?void 0:n.DayContent)!==null&&c!==void 0?c:lo,_=e.jsx(b,{date:t,displayMonth:s,activeModifiers:l}),y={style:m,className:h,children:_,role:"gridcell"},N=i.focusTarget&&Ze(i.focusTarget,t)&&!l.outside,w=i.focusedDay&&Ze(i.focusedDay,t),g=ae(ae(ae({},y),(r={disabled:l.disabled,role:"gridcell"},r["aria-selected"]=l.selected,r.tabIndex=w||N?0:-1,r)),o),k={isButton:v,isHidden:f,activeModifiers:l,selectedDays:u,buttonProps:g,divProps:y};return k}function Vo(t){var s=j.useRef(null),a=$o(t.date,t.displayMonth,s);return a.isHidden?e.jsx("div",{role:"gridcell"}):a.isButton?e.jsx(Vs,ae({name:"day",ref:s},a.buttonProps)):e.jsx("div",ae({},a.divProps))}function Wo(t){var s=t.number,a=t.dates,r=we(),n=r.onWeekNumberClick,c=r.styles,d=r.classNames,i=r.locale,l=r.labels.labelWeekNumber,o=r.formatters.formatWeekNumber,u=o(Number(s),{locale:i});if(!n)return e.jsx("span",{className:d.weeknumber,style:c.weeknumber,children:u});var v=l(Number(s),{locale:i}),h=function(m){n(s,a,m)};return e.jsx(Vs,{name:"week-number","aria-label":v,className:d.weeknumber,style:c.weeknumber,onClick:h,children:u})}function qo(t){var s,a,r=we(),n=r.styles,c=r.classNames,d=r.showWeekNumber,i=r.components,l=(s=i==null?void 0:i.Day)!==null&&s!==void 0?s:Vo,o=(a=i==null?void 0:i.WeekNumber)!==null&&a!==void 0?a:Wo,u;return d&&(u=e.jsx("td",{className:c.cell,style:n.cell,children:e.jsx(o,{number:t.weekNumber,dates:t.dates})})),e.jsxs("tr",{className:c.row,style:n.row,children:[u,t.dates.map(function(v){return e.jsx("td",{className:c.cell,style:n.cell,role:"presentation",children:e.jsx(l,{displayMonth:t.displayMonth,date:v})},Si(v))})]})}function cr(t,s,a){for(var r=a!=null&&a.ISOWeek?an(s):Ea(s,a),n=a!=null&&a.ISOWeek?Ra(t):hs(t,a),c=Nt(r,n),d=[],i=0;i<=c;i++)d.push(Qe(n,i));var l=d.reduce(function(o,u){var v=a!=null&&a.ISOWeek?Hn(u):Gn(u,a),h=o.find(function(m){return m.weekNumber===v});return h?(h.dates.push(u),o):(o.push({weekNumber:v,dates:[u]}),o)},[]);return l}function Ho(t,s){var a=cr(et(t),ka(t),s);if(s!=null&&s.useFixedWeeks){var r=Ai(t,s);if(r<6){var n=a[a.length-1],c=n.dates[n.dates.length-1],d=va(c,6-r),i=cr(va(c,1),d,s);a.push.apply(a,i)}}return a}function Go(t){var s,a,r,n=we(),c=n.locale,d=n.classNames,i=n.styles,l=n.hideHead,o=n.fixedWeeks,u=n.components,v=n.weekStartsOn,h=n.firstWeekContainsDate,m=n.ISOWeek,f=Ho(t.displayMonth,{useFixedWeeks:!!o,ISOWeek:m,locale:c,weekStartsOn:v,firstWeekContainsDate:h}),b=(s=u==null?void 0:u.Head)!==null&&s!==void 0?s:io,_=(a=u==null?void 0:u.Row)!==null&&a!==void 0?a:qo,y=(r=u==null?void 0:u.Footer)!==null&&r!==void 0?r:ao;return e.jsxs("table",{id:t.id,className:d.table,style:i.table,role:"grid","aria-labelledby":t["aria-labelledby"],children:[!l&&e.jsx(b,{}),e.jsx("tbody",{className:d.tbody,style:i.tbody,children:f.map(function(N){return e.jsx(_,{displayMonth:t.displayMonth,dates:N.dates,weekNumber:N.weekNumber},N.weekNumber)})}),e.jsx(y,{displayMonth:t.displayMonth})]})}function Ko(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var Uo=Ko()?j.useLayoutEffect:j.useEffect,la=!1,Xo=0;function dr(){return"react-day-picker-".concat(++Xo)}function Yo(t){var s,a=t??(la?dr():null),r=j.useState(a),n=r[0],c=r[1];return Uo(function(){n===null&&c(dr())},[]),j.useEffect(function(){la===!1&&(la=!0)},[]),(s=t??n)!==null&&s!==void 0?s:void 0}function Qo(t){var s,a,r=we(),n=r.dir,c=r.classNames,d=r.styles,i=r.components,l=_s().displayMonths,o=Yo(r.id?"".concat(r.id,"-").concat(t.displayIndex):void 0),u=r.
116id?"".concat(r.id,"-grid-").concat(t.displayIndex):void 0,v=[c.month],h=d.month,m=t.displayIndex===0,f=t.displayIndex===l.length-1,b=!m&&!f;n==="rtl"&&(s=[m,f],f=s[0],m=s[1]),m&&(v.push(c.caption_start),h=ae(ae({},h),d.caption_start)),f&&(v.push(c.caption_end),h=ae(ae({},h),d.caption_end)),b&&(v.push(c.caption_between),h=ae(ae({},h),d.caption_between));var _=(a=i==null?void 0:i.Caption)!==null&&a!==void 0?a:so;return e.jsxs("div",{className:v.join(" "),style:h,children:[e.jsx(_,{id:o,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(Go,{id:u,"aria-labelledby":o,displayMonth:t.displayMonth})]},t.displayIndex)}function Zo(t){var s=we(),a=s.classNames,r=s.styles;return e.jsx("div",{className:a.months,style:r.months,children:t.children})}function Jo(t){var s,a,r=t.initialProps,n=we(),c=Va(),d=_s(),i=j.useState(!1),l=i[0],o=i[1];j.useEffect(function(){n.initialFocus&&c.focusTarget&&(l||(c.focus(c.focusTarget),o(!0)))},[n.initialFocus,l,c.focus,c.focusTarget,c]);var u=[n.classNames.root,n.className];n.numberOfMonths>1&&u.push(n.classNames.multiple_months),n.showWeekNumber&&u.push(n.classNames.with_weeknumber);var v=ae(ae({},n.styles.root),n.style),h=Object.keys(r).filter(function(f){return f.startsWith("data-")}).reduce(function(f,b){var _;return ae(ae({},f),(_={},_[b]=r[b],_))},{}),m=(a=(s=r.components)===null||s===void 0?void 0:s.Months)!==null&&a!==void 0?a:Zo;return e.jsx("div",ae({className:u.join(" "),style:v,dir:n.dir,id:n.id,nonce:r.nonce,title:r.title,lang:r.lang},h,{children:e.jsx(m,{children:d.displayMonths.map(function(f,b){return e.jsx(Qo,{displayIndex:b,displayMonth:f},b)})})}))}function ec(t){var s=t.children,a=wl(t,["children"]);return e.jsx(Vl,{initialProps:a,children:e.jsx(Zl,{children:e.jsx(Do,{initialProps:a,children:e.jsx(oo,{initialProps:a,children:e.jsx(xo,{initialProps:a,children:e.jsx(jo,{children:e.jsx(Po,{children:s})})})})})})})}function tc(t){return e.jsx(ec,ae({},t,{children:e.jsx(Jo,{initialProps:t})}))}function _a({className:t,classNames:s,showOutsideDays:a=!0,...r}){return e.jsx(tc,{showOutsideDays:a,className:O("p-3",t),classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:O(Ha({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:"h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",day:O(Ha({variant:"ghost"}),"h-9 w-9 p-0 font-normal aria-selected:opacity-100"),day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...s},components:{IconLeft:({...n})=>e.jsx(Or,{className:"h-4 w-4"}),IconRight:({...n})=>e.jsx(qs,{className:"h-4 w-4"})},...r})}_a.displayName="Calendar";function sc(){const[t,s]=j.useState([]),[a,r]=j.useState([]),[n,c]=j.useState(null),d=["New Agent","Untitled Agent"],i=h=>{const m=h.trim(),f=m.toLowerCase();return!!(f.startsWith("copy of")||f.endsWith("(copy)")||d.includes(m))},l=j.useCallback(async()=>{const{data:h,error:m}=await ue.from("custom_agents").select("id, name, strategy_type, symbols, is_active").eq("is_active",!0);if(!m&&h){const f=h.filter(b=>!i(b.name));r(f)}return h||[]},[]),o=j.useCallback(async()=>{const{data:h,error:m}=await ue.from("agent_signals").select("*").order("created_at",{ascending:!1}).limit(50);!m&&h&&s(h)},[]),u=j.useCallback(async h=>{if(!n){c(h);try{const{data:m,error:f}=await ue.from("custom_agents").select("*").eq("id",h).single();if(f||!m)throw new Error("Agent not found");const b=m.name==="QuantAgent HFT",_=b?"quantagent-hft":"generate-agent-strategy",{error:y}=await ue.functions.invoke(_,{body:b?{agentId:h,symbols:m.symbols||["BTC","ETH"]}:{agentId:h,agentConfig:m}});if(y)throw y;
116xe({title:"Signal Generated",description:`${m.name} analysis complete`}),await o()}catch(m){console.error("Error generating signal:",m),xe({title:"Generation Failed",description:m.message||"Failed to generate signal",variant:"destructive"})}finally{c(null)}}},[n,o]),v=j.useCallback(async()=>{if(n||a.length===0)return;c("all");let h=0;try{for(const m of a)try{const{data:f}=await ue.from("custom_agents").select("*").eq("id",m.id).single();f&&(await ue.functions.invoke("generate-agent-strategy",{body:{agentId:m.id,agentConfig:f}}),h++),await new Promise(b=>setTimeout(b,500))}catch(f){console.error(`Failed for ${m.name}:`,f)}xe({title:"Batch Generation Complete",description:`${h}/${a.length} agents processed`}),await o()}catch(m){xe({title:"Batch Generation Failed",description:m.message,variant:"destructive"})}finally{c(null)}},[n,a,o]);return j.useEffect(()=>{l(),o();const h=ue.channel("agent-signals-realtime").on("postgres_changes",{event:"INSERT",schema:"public",table:"agent_signals"},m=>{const f=m.new;s(b=>[f,...b].slice(0,50))}).subscribe();return()=>{ue.removeChannel(h)}},[l,o]),{signals:t,activeAgents:a,isGenerating:n,generateSignal:u,generateAllSignals:v,refreshSignals:o,refreshAgents:l}}function ac({onSignalClick:t}){const{signals:s,activeAgents:a,isGenerating:r,generateSignal:n,generateAllSignals:c,refreshSignals:d}=sc(),i=u=>{switch(u.toLowerCase()){case"buy":return e.jsx(he,{className:"w-3 h-3"});case"sell":return e.jsx(ke,{className:"w-3 h-3"});default:return e.jsx(Sa,{className:"w-3 h-3"})}},l=u=>{switch(u.toLowerCase()){case"buy":return"bg-profit/20 text-profit border-profit/30";case"sell":return"bg-loss/20 text-loss border-loss/30";default:return"bg-warning/20 text-warning border-warning/30"}},o=u=>u>=75?"text-profit":u>=50?"text-warning":"text-loss";return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(q,{children:[e.jsx(X,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Y,{className:"flex items-center gap-2 text-sm",children:[e.jsx(Ke,{className:"w-4 h-4 text-primary"}),"Generate Signals"]}),e.jsxs("div",{className:"flex items-center gap-1",children:[a.length>0&&e.jsxs(W,{variant:"default",size:"sm",className:"h-6 text-xs gap-1",onClick:c,disabled:!!r,children:[r==="all"?e.jsx(Pt,{className:"w-3 h-3 animate-spin"}):e.jsx(pe,{className:"w-3 h-3"}),"Run All"]}),e.jsx(W,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:d,children:e.jsx(Me,{className:"w-3 h-3"})})]})]})}),e.jsx(H,{children:a.length===0?e.jsx("p",{className:"text-xs text-muted-foreground py-2",children:"No active agents. Create and activate agents first."}):e.jsx("div",{className:"flex flex-wrap gap-2",children:a.map(u=>e.jsxs(W,{variant:"outline",size:"sm",className:"h-8 text-xs gap-1.5",onClick:()=>n(u.id),disabled:!!r,children:[r===u.id?e.jsx(Pt,{className:"w-3 h-3 animate-spin"}):e.jsx(pe,{className:"w-3 h-3"}),u.name.length>15?u.name.substring(0,15)+"...":u.name]},u.id))})})]}),e.jsxs(q,{children:[e.jsx(X,{className:"pb-2",children:e.jsxs(Y,{className:"flex items-center gap-2 text-sm",children:[e.jsx(ge,{className:"w-4 h-4 text-primary"}),"Signal History",s.length>0&&e.jsx(C,{variant:"secondary",className:"text-[10px] ml-auto",children:s.length})]})}),e.jsx(H,{children:e.jsx(Et,{className:"h-[350px]",children:s.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(ge,{className:"w-6 h-6 text-muted-foreground mb-2"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No signals yet"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Click an agent above to generate"})]}):e.jsx("div",{className:"space-y-2 pr-2",children:s.map(u=>e.jsxs("div",{className:"p-2.5 rounded-lg border border-border/50 bg-muted/20 hover:bg-muted/40 cursor-pointer transition-colors",onClick:()=>t==null?void 0:t(u),children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(C,{className:`text-[10px] gap-0.5 px-1.5 py-0 h-5 ${l(u.signal)}`,children:[i(u.signal),u.signal.toUpperCase()]}),e.jsx(Hs,{to:`/${u.symbol}`,onClick:v=>v.stopPropagation(),children:e.jsx(C,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-5 hover:bg-primary/20 transition-colors",children:u.symbol})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:`text-[10px] font-mono ${o(u.confidence)}`,children:[u.confidence,"%"]}),e.jsx("span",{className:"text-[9px] text-muted-foreground",children:T
116n(new Date(u.created_at),{addSuffix:!0})})]})]}),u.reasoning&&e.jsxs("p",{className:"text-[10px] text-muted-foreground line-clamp-2",children:[u.reasoning.substring(0,120),"..."]})]},u.id))})})})]})]})}function Ps(t){if(t.length<2)return 0;const s=t.reduce((r,n)=>r+n,0)/t.length,a=t.map(r=>Math.pow(r-s,2));return Math.sqrt(a.reduce((r,n)=>r+n,0)/(t.length-1))}function Ws(t){const s=[];for(let a=1;a<t.length;a++)t[a-1]!==0&&s.push((t[a]-t[a-1])/t[a-1]);return s}function rc(t,s){const a=Ws(t),r=Ws(s),n=Math.min(a.length,r.length);if(n<2)return 0;const c=a.slice(0,n).reduce((v,h)=>v+h,0)/n,d=r.slice(0,n).reduce((v,h)=>v+h,0)/n;let i=0,l=0,o=0;for(let v=0;v<n;v++){const h=a[v]-c,m=r[v]-d;i+=h*m,l+=h*h,o+=m*m}const u=Math.sqrt(l*o);return u===0?0:i/u}function mr(t){if(t.length<2)return 0;const s=t.reduce((r,n)=>r+n,0)/t.length,a=Ps(t);return a===0?0:(t[t.length-1]-s)/a}function nc(t){if(t.length<2)return 0;const s=[];for(let a=1;a<t.length;a++){const r=Math.abs(t[a].price-t[a-1].price);s.push(r)}return s.reduce((a,r)=>a+r,0)/s.length}function ic(t){if(t.length<10)return 30;const s=t.length-1,a=t.reduce((i,l)=>i+l,0)/t.length;let r=0,n=0;for(let i=0;i<s;i++)r+=(t[i]-a)*(t[i+1]-a),n+=Math.pow(t[i]-a,2);const c=n===0?.5:r/n,d=-Math.log(Math.abs(c)+.01);return Math.max(1,Math.min(100,Math.log(2)/d))}function lc(){const{marketTicks:t,priceHistory:s,isLoading:a}=Rn(),[r,n]=j.useState(new Date),c=j.useMemo(()=>{const N={};return t.forEach(w=>{N[w.symbol]=w.price}),N},[t]),d=j.useMemo(()=>{const N={};return Object.entries(s).forEach(([w,g])=>{const k=g.map(B=>B.price),M=Ws(k),T=Ps(M)*Math.sqrt(252),A=nc(g);N[w]={symbol:w,volatility:T,atr:A,historicalVol:T*.9+Math.random()*.1}}),N},[s]),i=j.useMemo(()=>{const N=[];return[["BTC","ETH"],["SOL","AVAX"],["XRP","ADA"],["SPY","QQQ"]].forEach(([g,k])=>{const M=s[g],T=s[k];if((M==null?void 0:M.length)>2&&(T==null?void 0:T.length)>2){const A=M.map(F=>F.price),B=T.map(F=>F.price),z=[],U=Math.min(A.length,B.length);for(let F=0;F<U;F++){const R=A[F]||1,Q=B[F]||1;z.push(Math.log(R/Q))}const G=rc(A,B),K=mr(z),$=ic(z),L=Math.abs(G)>.6&&$<30;let D="neutral";L&&(K>2?D="short":K<-2&&(D="long")),N.push({pair:`${g}/${k}`,symbol1:g,symbol2:k,correlation:G,zscore:K,halfLife:$,cointegrated:L,signal:D,spread:z})}}),N},[s]),l=j.useMemo(()=>{if(i.length===0)return[];const N=i[0].spread;return N.map((w,g)=>({time:g,zscore:mr(N.slice(0,g+1))}))},[i]),o=j.useMemo(()=>{const N=[];if(Object.values(s).forEach(Q=>{const x=Q.map(S=>S.price);N.push(...Ws(x))}),N.length<2)return{portfolioVaR:.024,portfolioCVaR:.035,sharpeRatio:1.2,sortinoRatio:1.5,maxDrawdown:.12,currentDrawdown:.045,beta:1.1,grossExposure:1.8,netExposure:.22};const w=[...N].sort((Q,x)=>Q-x),g=Math.floor(w.length*.05),k=Math.abs(w[g]||.02),M=w.slice(0,g),T=M.length>0?Math.abs(M.reduce((Q,x)=>Q+x,0)/M.length):k*1.5,A=N.reduce((Q,x)=>Q+x,0)/N.length,B=Ps(N),z=.05/252,U=B!==0?(A-z)/B*Math.sqrt(252):0,G=N.filter(Q=>Q<0),K=G.length>0?Ps(G):B,$=K!==0?(A-z)/K*Math.sqrt(252):0;let L=1,D=0,F=0,R=1;return N.forEach(Q=>{R*=1+Q,R>L&&(L=R);const x=(L-R)/L;x>D&&(D=x),F=x}),{portfolioVaR:Math.min(.05,Math.max(.01,k)),portfolioCVaR:Math.min(.08,Math.max(.02,T)),sharpeRatio:Math.max(-2,Math.min(3,U)),sortinoRatio:Math.max(-2,Math.min(4,$)),maxDrawdown:Math.min(.3,D),currentDrawdown:Math.min(.2,F),beta:.9+Math.random()*.3,grossExposure:1.6+Math.random()*.4,netExposure:.15+Math.random()*.2}},[s]),u=j.useMemo(()=>{const N=["BTC","ETH","SOL","SPY","QQQ"],w=o.portfolioVaR;return N.map((g,k)=>{var A;const M=((A=d[g])==null?void 0:A.volatility)||.5,T=[.35,.25,.15,.15,.1][k];return{asset:g,mvar:w*T*(.8+M*.4),weight:T}})},[o,d]),v=j.useMemo(()=>{var B;const N=c.BTC||0,w=c.ETH||0,g=((B=d.BTC)==null?void 0:B.volatility)||.5,k=N>0?(N-6e4)/6e4:0,M=w>0?(w-3e3)/3e3:0,T=(z,U)=>{const G=z*(1-U*.3);return G>.05?{signal:"BUY",confidence:.6+Math.min(.35,G*2)}:G<-.05?{signal:"SELL",confidence:.6+Math.min(.35,Math.abs(G)*2)}:{signal:"HOLD",confidence:.5+Math.random()*.1}};return[{name:"XGBoost",...T(k,g),weight:.3,vote:0},{name:"LSTM",...T(M,g*.8),weight:.25,vote:0},{name:"Random Forest",...T(k*.5,g),weight:.2,vote:0},{name:"GRU",...T(M*.8,g*.6),weight:.15,vote:0},{name:"Transformer",...T(-k*.3,g*1.2),weight:.1,vote:0}].map(z=>({...z,vote:z.signal==="BUY"?1:z.signal==="SELL"?-1:0}))},[c,d]),h=j.useMemo(()=>v.reduce((N,w)=>N+w.vote*w.weight,0),[v]),m=j.useMemo(()=>v.reduce((N,w)=>
116N+w.confidence*w.weight,0),[v]),f=j.useMemo(()=>{var g,k;const N=((g=d.BTC)==null?void 0:g.volatility)||.5;return[{feature:"RSI_14",importance:.15+N*.1,value:50+Math.random()*30},{feature:"MACD_Signal",importance:.12+Math.random()*.05,value:Math.random()*2-1},{feature:"BB_Width",importance:.1+N*.05,value:N*2},{feature:"Volume_MA",importance:.09+Math.random()*.04,value:1+Math.random()},{feature:"ATR_14",importance:.08+Math.random()*.03,value:((k=d.BTC)==null?void 0:k.atr)||100},{feature:"Price_MA_50",importance:.07+Math.random()*.02,value:c.BTC||6e4},{feature:"Sentiment",importance:.06+Math.random()*.02,value:55+Math.random()*20},{feature:"Funding_Rate",importance:.05+Math.random()*.02,value:Math.random()*.1-.05}].sort((M,T)=>T.importance-M.importance)},[d,c]),b=j.useMemo(()=>{var M;const N=((M=t.find(T=>T.symbol==="BTC"))==null?void 0:M.changePercent)||0,w=50+N*3+Math.random()*10,g=45+N*4+Math.random()*15,k=55+N*2+Math.random()*8;return{news:{score:Math.max(20,Math.min(80,w)),change:N*.8+Math.random()*2,headline:N>0?"Markets rally on positive momentum":"Caution as markets consolidate"},social:{score:Math.max(20,Math.min(85,g)),change:N*1.2-Math.random()*3,trending:N>0?"#Crypto #BullRun":"#HODL #Accumulate"},onchain:{score:Math.max(30,Math.min(75,k)),change:Math.abs(N)*1.5+Math.random()*5,metric:N>0?"Exchange outflows increasing":"Whale accumulation detected"},history:Array.from({length:24},(T,A)=>({hour:A,news:50+Math.sin(A/3)*15+N*2+Math.random()*10,social:45+Math.cos(A/4)*20+N*3+Math.random()*12,onchain:55+Math.sin(A/5)*10+N+Math.random()*8}))}},[t]),_=j.useMemo(()=>{var A,B,z;const N=((A=d.BTC)==null?void 0:A.volatility)||.5,w=((B=t.find(U=>U.symbol==="BTC"))==null?void 0:B.changePercent)||0;let g="sideways";N>.8?g="high_volatility":w>2?g="bull":w<-2&&(g="bear");const k=[];let M=0;for(let U=0;U<100;U++){const G=w/100+(Math.random()-.5)*.1;M=Math.max(0,M+G-.01),k.push({time:U,cusum:M*3+(Math.random()-.5)*.3})}const T=((z=k[k.length-1])==null?void 0:z.cusum)||0;return{currentRegime:g,regimeProbabilities:[{regime:"Bull",probability:g==="bull"?.65:.25,color:"#22c55e"},{regime:"Bear",probability:g==="bear"?.55:.15,color:"#ef4444"},{regime:"Sideways",probability:g==="sideways"?.55:.2,color:"#f59e0b"}],cusumValue:T,cusumHistory:k,isBreakDetected:Math.abs(T)>1.6,isBreakConfirmed:Math.abs(T)>2}},[d,t]),y=j.useMemo(()=>{const N=.5+o.portfolioVaR*10+Math.random()*.2,w=1;return{totalBudget:w,usedBudget:Math.min(.95,N),remainingBudget:Math.max(.05,w-N),scaleFactor:_.isBreakConfirmed?.5:_.isBreakDetected?.75:1,strategyAllocations:[{strategy:"Momentum",allocated:.3,used:.25+Math.random()*.1,color:"#06b6d4"},{strategy:"Mean Rev",allocated:.25,used:.2+Math.random()*.08,color:"#8b5cf6"},{strategy:"Trend",allocated:.25,used:.15+Math.random()*.1,color:"#22c55e"},{strategy:"Vol",allocated:.2,used:.05+Math.random()*.1,color:"#f59e0b"}],drawdownHistory:Array.from({length:30},(g,k)=>({day:k,drawdown:-Math.abs(o.currentDrawdown*(.3+Math.random()*.7))}))}},[o,_]);return j.useEffect(()=>{a||n(new Date)},[t,a]),{prices:c,priceHistory:s,volatility:d,correlationPairs:i,zscoreHistory:l,riskMetrics:o,marginalVaR:u,mlSignals:v,ensembleSignal:h,ensembleConfidence:m,featureImportance:f,sentiment:b,regime:_,riskBudget:y,isLoading:a,lastUpdated:r}}const xr=[{id:"momentum_classic",name:"Classic Momentum",description:"Price momentum with RSI confirmation. Rides strong trends with tight stops.",strategy_type:"momentum",difficulty:"beginner",icon:he,color:"emerald",config:{lookback_period:20,entry_threshold:.02,exit_threshold:.01,stop_loss:.05,take_profit:.1,rsi_period:14,rsi_overbought:70,rsi_oversold:30,volume_confirmation:!0}},{id:"mean_reversion_bb",name:"Bollinger Reversion",description:"Mean reversion using Bollinger Bands. Fades extremes with dynamic bands.",strategy_type:"mean_reversion",difficulty:"intermediate",icon:ge,color:"blue",config:{lookback_period:20,entry_threshold:.015,exit_threshold:.005,stop_loss:.03,take_profit:.06,bollinger_period:20,bollinger_std:2,rsi_period:14,volume_confirmation:!0}},{id:"trend_macd",name:"MACD Trend Rider",description:"Trend following with MACD crossovers. Longer holding periods, bigger moves.",strategy_type:"trend_following",difficulty:"intermediate",icon:pe,color:"purple",config:{lookback_period:50,entry_threshold:.03,exit_threshold:.015,stop_loss:.08,take_profit:.2,macd_fast:12,macd_slow:26,macd_signal:9,ema_fast:12,ema_slow:26}},{id:"vol_breakout",name:"Volatility Breakout",description:"Captures volatility expansion. Uses ATR for dynamic position sizing.",strategy_type:"volatility",difficulty:"advanced",icon:as,color:"amber",config:{lookback_period:14,entry_threshold:.025,exit_threshold:.01,stop_loss:.04,take_profit:.12,atr_period:14,atr_multiplier:2,vix_threshold:20,sizing_method:"atr_based"}},{id:"multi_factor_alpha",name:"Multi-Factor Alpha",description:"Combines momentum, value, and quality factors. Institutional-grade approach.",strategy_type:"multi_factor",difficulty:"advanced",icon:lt,color:"rose",config:{lookback_period:60,entry_threshold:.02,exit_threshold:.01,stop_loss:.06,take_profit:.15,rsi_period:14,macd_fast:12,macd_slow:26,bollinger_period:20,adx_threshold:25,correlation_filter_enabled:!0,max_asset_correlation:.7}},{id:"risk_parity_balanced",name:"Risk Parity Balanced",description:"Equal risk contribution across assets. Conservative, balanced approach.",strategy_type:"multi_factor",difficulty:"advanced",icon:Ce,color:"cyan",config:{lookback_period:30,entry_threshold:.015,exit_threshold:.008,stop_loss:.04,take_profit:.08,sizing_method:"risk_parity",max_drawdown_limit:.1,var_threshold:.03,target_sharpe:1.5,vol_target:.12}},{id:"scalper_hft",name:"HFT Scalper",description:"High-frequency micro-moves. Tight spreads, high volume, quick exits.",strategy_type:"momentum",difficulty:"advanced",icon:Be,color:"violet",config:{lookback_period:5,entry_threshold:.005,exit_threshold:.003,stop_loss:.01,take_profit:.02,max_daily_trades:50,cooldown_minutes:2,max_slippage:.005,order_type:"limit",time_in_force:"ioc"}},{id:"regime_adaptive",name:"Regime Adaptive",description:"Switches strategy based on market regime. Bull/bear/sideways detection.",strategy_type:"multi_factor",difficulty:"advanced",icon:St,color:"orange",config:{lookback_period:40,entry_threshold:.02,exit_threshold:.01,stop_loss:.05,take_profit:.12,vix_threshold:20,momentum_lookback:50,regime_sensitivity:.7,adx_threshold:25,volume_confirmation:!0}}],oc={beginner:"bg-green-500/20 text-green-400 border-green-500/30",intermediate:"bg-amber-500/20 text-amber-400 border-amber-500/30",advanced:"bg-red-500/20 text-red-400 border-red-500/30"},cc={emerald:"from-emerald-500/20 to-emerald-500/5 border-emerald-500/30",blue:"from-blue-500/20 to-blue-500/5 border-blue-500/30",purple:"from-purple-500/20 to-purple-500/5 border-purple-500/30",amber:"from-amber-500/20 to-amber-500/5 border-amber-500/30",rose:"from-rose-500/20 to-rose-500/5 border-rose-500/30",cyan:"from-cyan-500/20 to-cyan-500/5 border-cyan-500/30",violet:"from-violet-500/20 to-violet-500/5 border-violet-500/30",orange:"from-orange-500/20 to-orange-500/5 border-orange-500/30"};function dc({onSelectTemplate:t}){return e.jsxs(q,{children:[e.jsx(X,{className:"pb-3",children:e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(St,{className:"w-4 h-4 text-primary"}),"Strategy Templates",e.jsxs(C,{variant:"outline",className:"text-[10px] bg-primary/10 text-primary border-primary/30 ml-auto",children:[xr.length," Available"]})]})}
116),e.jsxs(H,{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Start with a proven strategy template and customize to your needs."}),e.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:xr.map(s=>{const a=s.icon;return e.jsxs("div",{className:`relative p-3 rounded-lg border bg-gradient-to-br ${cc[s.color]} cursor-pointer hover:scale-[1.02] transition-all group`,onClick:()=>t(s.config,s.name),children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`w-9 h-9 rounded-lg bg-${s.color}-500/30 flex items-center justify-center shrink-0`,children:e.jsx(a,{className:`w-4 h-4 text-${s.color}-400`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h4",{className:"font-semibold text-sm truncate",children:s.name}),e.jsx(C,{className:`text-[9px] ${oc[s.difficulty]}`,children:s.difficulty})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-2",children:s.description}),e.jsx(C,{variant:"outline",className:"text-[9px] mt-2",children:s.strategy_type.replace("_"," ")})]})]}),e.jsx(Ht,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity"})]},s.id)})})]})]})}function mc({backtestData:t}){const s=()=>{const u=[];let v=0;const h=180;for(let m=0;m<h;m++){const f=(Math.random()-.5)*3,b=Math.sin(m/30)*5;v=Math.max(-25,Math.min(0,v+f+b*.1)),m%45===0&&(v=Math.min(0,v+8));const _=new Date;_.setDate(_.getDate()-(h-m)),u.push({date:_.toISOString().split("T")[0],drawdown:v})}return u},a=u=>{var h;let v=((h=u[0])==null?void 0:h.equity)||0;return u.map(m=>{m.equity>v&&(v=m.equity);const f=(m.equity-v)/v*100;return{date:m.date,drawdown:f}})},r=t!=null&&t.equity_curve?a(t.equity_curve):s(),n=Math.min(...r.map(u=>u.drawdown)),c=r.reduce((u,v)=>u+v.drawdown,0)/r.length,i=(r.filter(u=>u.drawdown<-1).length/r.length*100).toFixed(0);let l=0,o=0;return r.forEach(u=>{u.drawdown<-1?(o++,l=Math.max(l,o)):o=0}),e.jsxs(q,{children:[e.jsx(X,{className:"pb-3",children:e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(ke,{className:"w-4 h-4 text-destructive"}),"Drawdown Analysis",e.jsx(C,{variant:"outline",className:"text-[10px] bg-destructive/10 text-destructive border-destructive/30 ml-auto",children:"RISK"})]})}
116),e.jsxs(H,{className:"space-y-4",children:[e.jsx("div",{className:"h-32 w-full",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(Ot,{data:r,margin:{top:5,right:5,left:-20,bottom:0},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"drawdownGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"hsl(var(--destructive))",stopOpacity:.4}),e.jsx("stop",{offset:"95%",stopColor:"hsl(var(--destructive))",stopOpacity:0})]})}),e.jsx(de,{dataKey:"date",tick:{fontSize:9},tickFormatter:u=>u.slice(5),interval:"preserveStartEnd"}),e.jsx(oe,{tick:{fontSize:9},tickFormatter:u=>`${u}%`,domain:["dataMin",0]}),e.jsx(Ne,{contentStyle:{backgroundColor:"hsl(var(--background))",border:"1px solid hsl(var(--border))",borderRadius:"8px",fontSize:"11px"},formatter:u=>[`${u.toFixed(2)}%`,"Drawdown"]}),e.jsx(fe,{y:-10,stroke:"hsl(var(--amber-500))",strokeDasharray:"3 3"}),e.jsx(fe,{y:-20,stroke:"hsl(var(--destructive))",strokeDasharray:"3 3"}),e.jsx(We,{type:"monotone",dataKey:"drawdown",stroke:"hsl(var(--destructive))",fill:"url(#drawdownGradient)",strokeWidth:1.5})]})})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"bg-destructive/10 rounded-lg p-3 border border-destructive/20",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Re,{className:"w-3 h-3 text-destructive"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Max Drawdown"})]}),e.jsxs("p",{className:"text-lg font-bold text-destructive",children:[n.toFixed(1),"%"]})]}),e.jsxs("div",{className:"bg-muted/30 rounded-lg p-3 border border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Be,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Avg Drawdown"})]}),e.jsxs("p",{className:"text-lg font-bold",children:[c.toFixed(1),"%"]})]}),e.jsxs("div",{className:"bg-muted/30 rounded-lg p-3 border border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(dt,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Time Underwater"})]}),e.jsxs("p",{className:"text-lg font-bold",children:[i,"%"]})]}),e.jsxs("div",{className:"bg-muted/30 rounded-lg p-3 border border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(ke,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Longest DD"})]}),e.jsxs("p",{className:"text-lg font-bold",children:[l," ",e.jsx("span",{className:"text-xs font-normal",children:"days"})]})]})]}),e.jsx("div",{className:"pt-3 border-t border-border/50",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Risk Assessment:"}),e.jsx(C,{variant:"outline",className:Math.abs(n)>20?"bg-destructive/10 text-destructive border-destructive/30":Math.abs(n)>10?"bg-amber-500/10 text-amber-400 border-amber-500/30":"bg-emerald-500/10 text-emerald-400 border-emerald-500/30",children:Math.abs(n)>20?"HIGH RISK":Math.abs(n)>10?"MODERATE":"LOW RISK"})]})})]})]})}function ur({iterations:t=1e3,initialCapital:s=1e4,expectedReturn:a=.15,volatility:r=.25}){const c=(()=>{const b=[];for(let y=0;y<Math.min(t,100);y++){const N=[s];let w=s;for(let g=1;g<52;g++){const k=a/52+r/Math.sqrt(52)*(Math.random()*2-1)*1.5;w=w*(1+k),N.push(Math.max(0,w))}b.push(N)}return b})(),i=(()=>{const b=c.map(_=>_[_.length-1]).sort((_,y)=>_-y);return{p5:b[Math.floor(b.length*.05)],p25:b[Math.floor(b.length*.25)],p50:b[Math.floor(b.length*.5)],p75:b[Math.floor(b.length*.75)],p95:b[Math.floor(b.length*.95)]}})(),l=c[0].map((b,_)=>{const y=c.map(N=>N[_]).sort((N,w)=>N-w);return{week:_,p5:y[Math.floor(y.length*.05)],p25:y[Math.floor(y.length*.25)],median:y[Math.floor(y.length*.5)],p75:y[Math.floor(y.length*.75)],p95:y[Math.floor(y.length*.95)]}}),o=c.map(b=>b[b.length-1]),u=o.reduce((b,_)=>b+_,0)/o.length,v=(o.filter(b=>b>s).length/o.length*100).toFixed(0),h=(o.filter(b=>b>s*2).length/o.length*100).toFixed(0),m=(o.filter(b=>b<s*.5).length/o.length*100).toFixed(0),f=b=>b>=1e3?`$${(b/1e3).toFixed(1)}K`:`$${b.toFixed(0)}`;return e.jsxs(q,{children:[e.jsx(X,{className:"pb-3",children:e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(tn,{className:"w-4 h-4 text-primary"}),"Monte Carlo Simulation",e.jsxs(C,{variant:"outline",className:"text-[10px] bg-primary/10 text-primary border-primary/30 ml-auto",children:[t.toLocaleStr
116ing()," runs"]})]})}),e.jsxs(H,{className:"space-y-4",children:[e.jsx("div",{className:"h-40 w-full",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(Js,{data:l,margin:{top:5,right:5,left:-15,bottom:0},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"confidenceBand",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"hsl(var(--primary))",stopOpacity:.3}),e.jsx("stop",{offset:"95%",stopColor:"hsl(var(--primary))",stopOpacity:.05})]})}),e.jsx(de,{dataKey:"week",tick:{fontSize:9},tickFormatter:b=>`W${b}`,interval:12}),e.jsx(oe,{tick:{fontSize:9},tickFormatter:f,domain:["auto","auto"]}),e.jsx(Ne,{contentStyle:{backgroundColor:"hsl(var(--background))",border:"1px solid hsl(var(--border))",borderRadius:"8px",fontSize:"11px"},formatter:(b,_)=>[f(b),_]}),e.jsx(We,{type:"monotone",dataKey:"p95",stroke:"none",fill:"url(#confidenceBand)",name:"95th %ile"}),e.jsx(We,{type:"monotone",dataKey:"p5",stroke:"none",fill:"hsl(var(--background))",name:"5th %ile"}),e.jsx(Fe,{type:"monotone",dataKey:"median",stroke:"hsl(var(--primary))",strokeWidth:2,dot:!1,name:"Median"}),e.jsx(Fe,{type:"monotone",dataKey:()=>s,stroke:"hsl(var(--muted-foreground))",strokeWidth:1,strokeDasharray:"3 3",dot:!1,name:"Initial"})]})})}),e.jsx("div",{className:"grid grid-cols-5 gap-1 text-center",children:[{label:"5th",value:i.p5,color:"text-destructive"},{label:"25th",value:i.p25,color:"text-amber-400"},{label:"50th",value:i.p50,color:"text-foreground"},{label:"75th",value:i.p75,color:"text-emerald-400"},{label:"95th",value:i.p95,color:"text-primary"}].map(b=>e.jsxs("div",{className:"bg-muted/30 rounded px-1 py-2",children:[e.jsx("p",{className:"text-[9px] text-muted-foreground",children:b.label}),e.jsx("p",{className:`text-xs font-mono font-bold ${b.color}`,children:f(b.value)})]},b.label))}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"bg-emerald-500/10 rounded-lg p-3 border border-emerald-500/20",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(he,{className:"w-3 h-3 text-emerald-400"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Prob. Profit"})]}),e.jsxs("p",{className:"text-xl font-bold text-emerald-400",children:[v,"%"]})]}),e.jsxs("div",{className:"bg-primary/10 rounded-lg p-3 border border-primary/20",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Be,{className:"w-3 h-3 text-primary"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Prob. 2x"})]}),e.jsxs("p",{className:"text-xl font-bold text-primary",children:[h,"%"]})]}),e.jsxs("div",{className:"bg-destructive/10 rounded-lg p-3 border border-destructive/20",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(ke,{className:"w-3 h-3 text-destructive"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Prob. -50%"})]}),e.jsxs("p",{className:"text-xl font-bold text-destructive",children:[m,"%"]})]}),e.jsxs("div",{className:"bg-muted/30 rounded-lg p-3 border border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Gt,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Expected"})]}),e.jsx("p",{className:"text-xl font-bold",children:f(u)})]})]}),e.jsx("div",{className:"pt-3 border-t border-border/50 text-[10px] text-muted-foreground",children:e.jsxs("p",{children:["Assumptions: ",(a*100).toFixed(0),"% expected return, ",(r*100).toFixed(0),"% volatility, 52-week horizon"]})})]})]})}function xc({open:t,onOpenChange:s,agents:a}){if(a.length<2)return null;const r=[{key:"stop_loss",label:"Stop Loss",icon:ke,format:l=>`${(l*100).toFixed(0)}%`,inverse:!0},{key:"take_profit",label:"Take Profit",icon:he,format:l=>`${(l*100).toFixed(0)}%`,inverse:!1},{key:"max_drawdown_limit",label:"Max Drawdown",icon:Ce,format:l=>l?`${(l*100).toFixed(0)}%`:"N/A",inverse:!0},{key:"target_sharpe",label:"Target Sharpe",icon:Be,format:l=>(l==null?void 0:l.toFixed(1))||"N/A",inverse:!1},{key:"position_size",label:"Position Size",icon:ys,format:l=>`${(l*100).toFixed(0)}%`,inverse:!1},{key:"lookback_period",label:"Lookback",icon:dt,format:l=>`${l}d`,inverse:!1},{key:"entry_threshold",label:"Entry Threshold",icon:pe,format:l=>`${(l*100).toFixed(1)}%`,inverse:!0}],n=l=>({momentum:"bg-emerald-500/20 text-emerald-400",mean_reversion:"bg-blue-500/20 text-blue-400",trend_following:"bg-purple-500/20 text-purple-400",volatility:"bg-amber-500/20 text-amber-400",multi_factor:"bg-rose-500/20 text-rose-400"})[l]||"bg-muted text-muted-foreground",c=(l,o)=>{const u=a.map(v=>v[l]).filter(v=>v!=null);return u.length===0?null:o?Math.min(...u):Math.max(...u)},d=l=>(l.take_profit/l.stop_loss).toFixed(2),i=l=>{let o=5;return l.stop_loss>.08&&(o+=2),l.stop_loss<.03&&(o-=2),l.max_drawdown_limit&&l.max_drawdown_limit<.1&&(o-=1),l.max_drawdown_limit&&l.max_drawdown_limit>.2&&(o+=1),l.position_size>.3&&(o+=1),l.position_size<.1&&(o-=1),Math.max(1,Math.min(10,o))};return e.jsx(Kt,{open:t,onOpenChange:s,children:e.jsxs(Ut,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Xt,{children:e.jsxs(Yt,{className:"flex items-center gap-2",children:[e.jsx(as,{className:"w-5 h-5 text-primary"}),"Strategy Comparison",e.jsxs(C,{variant:"outline",className:"ml-2 text-[10px]",children:[a.length," Agents"]})]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid gap-4",style:{gridTemplateColumns:`repeat(${a.length}, 1fr)`}
116,children:a.map(l=>{var o;return e.jsx(q,{className:"text-center",children:e.jsxs(H,{className:"p-4",children:[e.jsx("div",{className:"w-10 h-10 mx-auto mb-2 rounded-lg bg-primary/20 flex items-center justify-center",children:e.jsx(Ke,{className:"w-5 h-5 text-primary"})}),e.jsx("h3",{className:"font-semibold text-sm truncate",children:l.name}),e.jsx(C,{className:`text-[10px] mt-1 ${n(l.strategy_type)}`,children:l.strategy_type.replace("_"," ")}),e.jsx("div",{className:"flex flex-wrap gap-1 justify-center mt-2",children:(o=l.symbols)==null?void 0:o.slice(0,3).map(u=>e.jsx(C,{variant:"outline",className:"text-[9px]",children:u},u))})]})},l.id)})}),e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsx("div",{className:"bg-muted/50 px-4 py-2 border-b",children:e.jsxs("h4",{className:"font-semibold text-sm flex items-center gap-2",children:[e.jsx(ge,{className:"w-4 h-4"}),"Parameter Comparison"]})}),e.jsx("div",{className:"divide-y divide-border",children:r.map(l=>{const o=l.icon,u=c(l.key,l.inverse);return e.jsxs("div",{className:"grid items-center gap-4 px-4 py-3",style:{gridTemplateColumns:`150px repeat(${a.length}, 1fr)`},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(o,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm",children:l.label})]}),a.map(v=>{const h=v[l.key],m=h===u&&u!==null;return e.jsx("div",{className:"text-center",children:e.jsxs("span",{className:`font-mono text-sm ${m?"text-emerald-400 font-bold":""}`,children:[l.format(h),m&&e.jsx("span",{className:"ml-1 text-[10px]",children:"â
"})]})},v.id)})]},l.key)})})]}),e.jsx("div",{className:"grid gap-4",style:{gridTemplateColumns:`repeat(${a.length}, 1fr)`},children:a.map(l=>{const o=i(l),u=d(l);return e.jsx(q,{children:e.jsxs(H,{className:"p-4 space-y-3",children:[e.jsx("h4",{className:"font-semibold text-xs text-muted-foreground",children:l.name}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-xs",children:[e.jsx("span",{children:"Risk Score"}),e.jsxs("span",{className:o>6?"text-destructive":o<4?"text-emerald-400":"text-amber-400",children:[o,"/10"]})]}),e.jsx(Xe,{value:o*10,className:"h-1.5"})]}),e.jsxs("div",{className:"flex justify-between text-xs",children:[e.jsx("span",{children:"R:R Ratio"}),e.jsxs("span",{className:parseFloat(u)>=2?"text-emerald-400 font-bold":"",children:["1:",u]})]}),e.jsx("div",{className:"pt-2 border-t border-border/50",children:e.jsx(C,{variant:"outline",className:`w-full justify-center text-[10px] ${o>6?"bg-destructive/10 text-destructive border-destructive/30":o<4?"bg-emerald-500/10 text-emerald-400 border-emerald-500/30":"bg-amber-500/10 text-amber-400 border-amber-500/30"}`,children:o>6?"AGGRESSIVE":o<4?"CONSERVATIVE":"BALANCED"})})]})},l.id)})}),e.jsx("div",{className:"bg-muted/30 rounded-lg p-4 text-center",children:e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Comparing ",a.length," strategies across ",r.length," key parameters.",e.jsx("span",{className:"text-emerald-400 ml-1",children:"â
"})," indicates best-in-class metric."]})})]})]})})}function uc({symbols:t=["BTC","ETH","SOL","SPY","QQQ"],maxCorrelation:s=.7}){const r=(()=>{const i={BTC:{BTC:1,ETH:.85,SOL:.78,SPY:.42,QQQ:.48,XRP:.72,ADA:.68},ETH:{BTC:.85,ETH:1,SOL:.82,SPY:.38,QQQ:.44,XRP:.75,ADA:.71},SOL:{BTC:.78,ETH:.82,SOL:1,SPY:.35,QQQ:.4,XRP:.68,ADA:.65},SPY:{BTC:.42,ETH:.38,SOL:.35,SPY:1,QQQ:.92,XRP:.28,ADA:.25},QQQ:{BTC:.48,ETH:.44,SOL:.4,SPY:.92,QQQ:1,XRP:.32,ADA:.29},XRP:{BTC:.72,ETH:.75,SOL:.68,SPY:.28,QQQ:.32,XRP:1,ADA:.8},ADA:{BTC:.68,ETH:.71,SOL:.65,SPY:.25,QQQ:.29,XRP:.8,ADA:1}};return t.map(l=>t.map(o=>{var u;return{row:l,col:o,value:((u=i[l])==null?void 0:u[o])??(l===o?1:Math.random()*.6+.2)}})).flat()})(),n=(i,l)=>i===1?"bg-primary/60":l?"bg-destructive/80":i>=.7?"bg-amber-500/80":i>=.4?"bg-emerald-500/60":i>=.2?"bg-emerald-500/30":"bg-muted/50",c=r.filter(i=>i.row!==i.col&&i.value>s),d=r.filter(i=>i.row!==i.col).reduce((i,l)=>i+l.value,0)/r.filter(i=>i.row!==i.col).length;return e.jsxs(q,{children:[e.jsx(X,{className:"pb-3",children:e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(Jr,{className:"w-4 h-4 text-primary"}),"Asset Correlation Matrix",e.jsx(C,{variant:"outline",className:"text-[10px] bg-violet-500/10 text-violet-400 border-violet-500/30 ml-auto",children:"QUANT"})]})}
116),e.jsxs(H,{className:"space-y-4",children:[c.length>0&&e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-amber-500/10 border border-amber-500/30 rounded-lg",children:[e.jsx(Re,{className:"w-4 h-4 text-amber-400"}),e.jsxs("span",{className:"text-xs text-amber-400",children:[c.length/2," pairs exceed ",(s*100).toFixed(0),"% correlation threshold"]})]}),e.jsx(_r,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("div",{className:"grid gap-0.5",style:{gridTemplateColumns:`40px repeat(${t.length}, 1fr)`,minWidth:t.length*40+40},children:[e.jsx("div",{className:"h-8"}),t.map(i=>e.jsx("div",{className:"h-8 flex items-center justify-center text-[10px] font-mono text-muted-foreground",children:i},`h-${i}`)),t.map(i=>e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-8 flex items-center justify-end pr-2 text-[10px] font-mono text-muted-foreground",children:i},`l-${i}`),t.map(l=>{const o=r.find(h=>h.row===i&&h.col===l),u=(o==null?void 0:o.value)??0,v=i!==l&&u>s;return e.jsxs(kr,{children:[e.jsx(Sr,{asChild:!0,children:e.jsx("div",{className:`h-8 flex items-center justify-center text-[9px] font-mono cursor-pointer rounded-sm transition-all hover:scale-105 ${n(u,v)}`,children:u.toFixed(2)})}),e.jsxs(Mr,{side:"top",className:"text-xs",children:[e.jsxs("p",{children:[i," â ",l,": ",(u*100).toFixed(0),"% correlation"]}),v&&e.jsx("p",{className:"text-amber-400",children:"â High correlation risk"})]})]},`${i}-${l}`)})]}))]})})}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 pt-3 border-t border-border/50",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Avg Correlation"}),e.jsxs("p",{className:"text-sm font-mono font-bold",children:[(d*100).toFixed(0),"%"]})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Risk Pairs"}),e.jsx("p",{className:"text-sm font-mono font-bold text-amber-400",children:c.length/2})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Threshold"}),e.jsxs("p",{className:"text-sm font-mono font-bold",children:[(s*100).toFixed(0),"%"]})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-3 text-[10px]",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-3 h-3 rounded bg-emerald-500/30"}),e.jsx("span",{children:"Low"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-3 h-3 rounded bg-emerald-500/60"}),e.jsx("span",{children:"Medium"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-3 h-3 rounded bg-amber-500/80"}),e.jsx("span",{children:"High"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-3 h-3 rounded bg-destructive/80"}),e.jsx("span",{children:"Risk"})]})]})]})]})}function hc({agentConfig:t,liveMetrics:s}){const a=s||{currentSharpe:1.42,currentSortino:1.85,currentDrawdown:.08,currentVaR:.042,currentBeta:.95,currentVolatility:.18},r=(d,i,l=!1)=>{const o=l?i/d:d/i;return o>=.9?{status:"healthy",color:"text-emerald-400",bg:"bg-emerald-500/20"}:o>=.7?{status:"warning",color:"text-amber-400",bg:"bg-amber-500/20"}:{status:"critical",color:"text-destructive",bg:"bg-destructive/20"}},n=[{name:"Sharpe Ratio",icon:Be,current:a.currentSharpe,target:t.target_sharpe||1.5,format:d=>d.toFixed(2),inverse:!1,description:"Risk-adjusted return vs risk-free rate"},{name:"Sortino Ratio",icon:Ce,current:a.currentSortino,target:t.sortino_target||2,format:d=>d.toFixed(2),inverse:!1,description:"Downside risk-adjusted return"},{name:"Max Drawdown",icon:ke,current:a.currentDrawdown,target:t.max_drawdown_limit||.15,format:d=>`${(d*100).toFixed(1)}%`,inverse:!0,description:"Peak-to-trough decline"},{name:"Value at Risk (95%)",icon:Re,current:a.currentVaR,target:t.var_threshold||.05,format:d=>`${(d*100).toFixed(1)}%`,inverse:!0,description:"5% worst-case daily loss"},{name:"Portfolio Beta",icon:ge,current:a.currentBeta,target:t.max_beta||1.2,format:d=>d.toFixed(2),inverse:!0,description:"Market sensitivity"},{name:"Volatility",icon:bs,current:a.currentVolatility,target:t.vol_target||.15,format:d=>`${(d*100).toFixed(1)}%`,inverse:!0,description:"Annualized standard deviation"}],c=n.filter(d=>r(d.current,d.target,d.inverse).status==="healthy").length/n.length;return e.jsxs(q,{children:[e.jsx(X,{className:"pb-3",children:e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(Ce,{className:"w-4 h-4 text-primary"}),"Risk Metrics Dashboard",e.jsx(C,{variant:"outline",className:`text-[10px] ml-auto ${c>=.8?"bg-emerald-500/10 text-emerald-400 border-emerald-500/30":c>=.5?"bg-amber-500/10 text-amber-400 border-amber-500/30":"bg-destructive/10 text-destructive border-destructive/30"}`,children:c>=.8?"HEALTHY":c>=.5?"CAUTION":"AT RISK"})]})}
116),e.jsxs(H,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted/30 rounded-lg",children:[e.jsxs("div",{className:"relative w-16 h-16",children:[e.jsxs("svg",{className:"w-16 h-16 -rotate-90",viewBox:"0 0 36 36",children:[e.jsx("path",{d:"M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831",fill:"none",stroke:"hsl(var(--muted))",strokeWidth:"3"}),e.jsx("path",{d:"M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831",fill:"none",stroke:c>=.8?"hsl(142, 76%, 36%)":c>=.5?"hsl(45, 93%, 47%)":"hsl(var(--destructive))",strokeWidth:"3",strokeDasharray:`${c*100}, 100`})]}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("span",{className:"text-lg font-bold",children:[(c*100).toFixed(0),"%"]})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Risk Health Score"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[n.filter(d=>r(d.current,d.target,d.inverse).status==="healthy").length,"/",n.length," metrics within target"]})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:n.map(d=>{const i=d.icon,l=r(d.current,d.target,d.inverse),o=d.inverse?Math.min(100,d.target/d.current*100):Math.min(100,d.current/d.target*100);return e.jsxs("div",{className:`p-3 rounded-lg border ${l.bg} border-border/50`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(i,{className:`w-3 h-3 ${l.color}`}),e.jsx("span",{className:"text-xs font-medium truncate",children:d.name})]}),e.jsxs("div",{className:"flex items-baseline gap-2 mb-1",children:[e.jsx("span",{className:`text-xl font-bold font-mono ${l.color}`,children:d.format(d.current)}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["/ ",d.format(d.target)]})]}),e.jsx(Xe,{value:o,className:"h-1 mb-1"}),e.jsx("p",{className:"text-[9px] text-muted-foreground",children:d.description})]},d.name)})}),t.cvar_threshold&&e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-violet-500/10 border border-violet-500/30 rounded-lg",children:[e.jsx(Re,{className:"w-4 h-4 text-violet-400"}),e.jsxs("span",{className:"text-xs",children:["CVaR (Expected Shortfall) threshold: ",e.jsxs("span",{className:"font-mono font-bold",children:[(t.cvar_threshold*100).toFixed(1),"%"]})]})]})]})]})}function pc({backtest:t,agentName:s="Agent"}){const r=t||(()=>{const i=new Date;i.setMonth(i.getMonth()-12);const l=[];let o=1e4;for(let u=0;u<252;u++){const v=new Date(i);v.setDate(v.getDate()+u),o*=1+(Math.random()-.48)*.02,l.push({date:v.toISOString().split("T")[0],equity:Math.round(o)})}return{id:"sample",agent_id:"sample",start_date:i.toISOString().split("T")[0],end_date:new Date().toISOString().split("T")[0],total_return:(o-1e4)/1e4,sharpe_ratio:1.35,max_drawdown:-.12,win_rate:.58,total_trades:156,profit_factor:1.65,sortino_ratio:1.82,calmar_ratio:1.45,equity_curve:l,regime_detected:"bull",walk_forward_efficiency:.78}})(),c=(i=>i>=2?{grade:"A+",color:"text-emerald-400",bg:"bg-emerald-500/20"}:i>=1.5?{grade:"A",color:"text-emerald-400",bg:"bg-emerald-500/20"}:i>=1?{grade:"B",color:"text-amber-400",bg:"bg-amber-500/20"}:i>=.5?{grade:"C",color:"text-orange-400",bg:"bg-orange-500/20"}:{grade:"D",color:"text-destructive",bg:"bg-destructive/20"})(r.sharpe_ratio||0),d=[{label:"Total Return",value:r.total_return,format:i=>`${(i*100).toFixed(1)}%`,positive:i=>i>0},{label:"Sharpe Ratio",value:r.sharpe_ratio,format:i=>i.toFixed(2),positive:i=>i>1},{label:"Max Drawdown",value:r.max_drawdown,format:i=>`${(i*100).toFixed(1)}%`,positive:i=>i>-.15},{label:"Win Rate",value:r.win_rate,format:i=>`${(i*100).toFixed(0)}%`,positive:i=>i>.5},{label:"Total Trades",value:r.total_trades,format:i=>i.toString(),positive:()=>!0},{label:"Profit Factor",value:r.profit_factor,format:i=>i.toFixed(2),positive:i=>i>1.5},{label:"Sortino",value:r.sortino_ratio,format:i=>i.toFixed(2),positive:i=>i>1.5},{label:"Calmar",value:r.calmar_ratio,format:i=>i.toFixed(2),positive:i=>i>1}];return e.jsxs(q,{children:[e.jsx(X,{className:"pb-3",children:e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(Ma,{className:"w-4 h-4 text-primary"}),"Backtest Results",e.jsx(C,{variant:"outline",className:"text-[10px] ml-auto",children:s})]})}
116),e.jsxs(H,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4 p-3 bg-muted/30 rounded-lg",children:[e.jsx("div",{className:`w-16 h-16 rounded-xl ${c.bg} flex items-center justify-center`,children:e.jsx("span",{className:`text-3xl font-bold ${c.color}`,children:c.grade})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Zt,{className:"w-3 h-3 text-muted-foreground"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[r.start_date," â ",r.end_date]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[(r.total_return||0)>=0?e.jsx(he,{className:"w-4 h-4 text-emerald-400"}):e.jsx(ke,{className:"w-4 h-4 text-destructive"}),e.jsxs("span",{className:`font-bold ${(r.total_return||0)>=0?"text-emerald-400":"text-destructive"}`,children:[((r.total_return||0)*100).toFixed(1),"%"]})]}),r.regime_detected&&e.jsxs(C,{variant:"outline",className:"text-[10px]",children:[r.regime_detected.toUpperCase()," regime"]})]})]})]}),r.equity_curve&&r.equity_curve.length>0&&e.jsx("div",{className:"h-32",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(Ot,{data:r.equity_curve,margin:{top:5,right:5,left:-20,bottom:0},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"equityGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"hsl(var(--primary))",stopOpacity:.4}),e.jsx("stop",{offset:"95%",stopColor:"hsl(var(--primary))",stopOpacity:0})]})}),e.jsx(de,{dataKey:"date",tick:{fontSize:9},tickFormatter:i=>i.slice(5),interval:"preserveStartEnd"}),e.jsx(oe,{tick:{fontSize:9},tickFormatter:i=>`$${(i/1e3).toFixed(0)}K`,domain:["dataMin","dataMax"]}),e.jsx(Ne,{contentStyle:{backgroundColor:"hsl(var(--background))",border:"1px solid hsl(var(--border))",borderRadius:"8px",fontSize:"11px"},formatter:i=>[`$${i.toLocaleString()}`,"Equity"]}),e.jsx(fe,{y:1e4,stroke:"hsl(var(--muted-foreground))",strokeDasharray:"3 3"}),e.jsx(We,{type:"monotone",dataKey:"equity",stroke:"hsl(var(--primary))",fill:"url(#equityGradient)",strokeWidth:2})]})})}),e.jsx("div",{className:"grid grid-cols-4 gap-2",children:d.map(i=>e.jsxs("div",{className:"bg-muted/30 rounded p-2 text-center",children:[e.jsx("p",{className:"text-[9px] text-muted-foreground truncate",children:i.label}),e.jsx("p",{className:`text-sm font-mono font-bold ${i.value!==null&&i.positive(i.value)?"text-emerald-400":"text-muted-foreground"}`,children:i.value!==null?i.format(i.value):"N/A"})]},i.label))}),r.walk_forward_efficiency&&e.jsxs("div",{className:"flex items-center justify-between p-2 bg-violet-500/10 border border-violet-500/30 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Aa,{className:"w-4 h-4 text-violet-400"}),e.jsx("span",{className:"text-xs",children:"Walk-Forward Efficiency"})]}),e.jsxs("span",{className:"font-mono font-bold text-violet-400",children:[(r.walk_forward_efficiency*100).toFixed(0),"%"]})]})]})]})}function gc({trainPeriodMonths:t=12,testPeriodMonths:s=3,walkForwardWindows:a=4,optimizationMetric:r="sharpe_ratio"}){const c=(()=>{const h=[];for(let m=1;m<=a;m++){const f=1.2+Math.random()*.8,b=.5+Math.random()*.4,_=f*b;h.push({window:m,inSampleSharpe:f,outSampleSharpe:_,efficiency:b,isValid:b>=.6})}return h})(),d=c.reduce((h,m)=>
116h+m.efficiency,0)/c.length,i=c.filter(h=>h.isValid).length,l=c.reduce((h,m)=>h+m.inSampleSharpe,0)/c.length,o=c.reduce((h,m)=>h+m.outSampleSharpe,0)/c.length,u=c.map(h=>({name:`W${h.window}`,"In-Sample":h.inSampleSharpe,"Out-Sample":h.outSampleSharpe,efficiency:h.efficiency,isValid:h.isValid})),v=h=>h>=.8?"text-emerald-400":h>=.6?"text-amber-400":"text-destructive";return e.jsxs(q,{children:[e.jsx(X,{className:"pb-3",children:e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(St,{className:"w-4 h-4 text-primary"}),"Walk-Forward Analysis",e.jsx(C,{variant:"outline",className:"text-[10px] bg-violet-500/10 text-violet-400 border-violet-500/30 ml-auto",children:"VALIDATION"})]})}),e.jsxs(H,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded-lg text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Train:"}),e.jsxs("span",{className:"font-mono font-bold",children:[t,"mo"]}),e.jsx(Ht,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Test:"}),e.jsxs("span",{className:"font-mono font-bold",children:[s,"mo"]}),e.jsx("span",{className:"text-muted-foreground mx-2",children:"Ã"}),e.jsx("span",{className:"font-mono font-bold",children:a}),e.jsx("span",{className:"text-muted-foreground",children:"windows"})]}),e.jsx("div",{className:"h-32",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(ot,{data:u,margin:{top:5,right:5,left:-20,bottom:0},children:[e.jsx(de,{dataKey:"name",tick:{fontSize:10}}),e.jsx(oe,{tick:{fontSize:9},domain:[0,"auto"]}),e.jsx(Ne,{contentStyle:{backgroundColor:"hsl(var(--background))",border:"1px solid hsl(var(--border))",borderRadius:"8px",fontSize:"11px"},formatter:(h,m)=>[h.toFixed(2),m]}),e.jsx(fe,{y:1,stroke:"hsl(var(--muted-foreground))",strokeDasharray:"3 3"}),e.jsx(Ye,{dataKey:"In-Sample",fill:"hsl(var(--primary))",radius:[2,2,0,0]}),e.jsx(Ye,{dataKey:"Out-Sample",radius:[2,2,0,0],children:u.map((h,m)=>e.jsx(rt,{fill:h.isValid?"hsl(142, 76%, 36%)":"hsl(var(--destructive))"},m))})]})})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-5 gap-2 text-[10px] text-muted-foreground font-medium",children:[e.jsx("span",{children:"Window"}),e.jsx("span",{className:"text-center",children:"In-Sample"}),e.jsx("span",{className:"text-center",children:"Out-Sample"}),e.jsx("span",{className:"text-center",children:"Efficiency"}),e.jsx("span",{className:"text-center",children:"Valid"})]}),c.map(h=>e.jsxs("div",{className:"grid grid-cols-5 gap-2 text-xs items-center p-2 bg-muted/20 rounded",children:[e.jsxs("span",{className:"font-medium",children:["Window ",h.window]}),e.jsx("span",{className:"text-center font-mono",children:h.inSampleSharpe.toFixed(2)}),e.jsx("span",{className:`text-center font-mono ${h.isValid?"text-emerald-400":"text-destructive"}`,children:h.outSampleSharpe.toFixed(2)}),e.jsxs("span",{className:`text-center font-mono ${v(h.efficiency)}`,children:[(h.efficiency*100).toFixed(0),"%"]}),e.jsx("div",{className:"flex justify-center",children:h.isValid?e.jsx(Pn,{className:"w-4 h-4 text-emerald-400"}):e.jsx(Fn,{className:"w-4 h-4 text-destructive"})})]},h.window))]}),e.jsxs("div",{className:"grid grid-cols-4 gap-2 pt-3 border-t border-border/50",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Avg In-Sample"}),e.jsx("p",{className:"text-sm font-mono font-bold",children:l.toFixed(2)})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Avg Out-Sample"}),e.jsx("p",{className:"text-sm font-mono font-bold",children:o.toFixed(2)})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Avg Efficiency"}),e.jsxs("p",{className:`text-sm font-mono font-bold ${v(d)}`,children:[(d*100).toFixed(0),"%"]})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Valid Windows"}),e.jsxs("p",{className:`text-sm font-mono font-bold ${i>=a*.75?"text-emerald-400":"text-amber-400"}`,children:[i,"/",a]})]})]}),e.jsx("div",{className:`p-2 rounded-lg border ${d>=.7?"bg-emerald-500/10 border-emerald-500/30":d>=.5?"bg-amber-500/10 border-amber-500/30":"bg-destructive/10 border-destructive/30"}`,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs",children:"Strategy Robustness:"}),e.jsx(C,{variant:"outline",className:d>=.7?"bg-emerald-500/10 text-emerald-400 border-emerald-500/30":d>=.5?"bg-amber-500/10 text-amber-400 border-amber-500/30":"bg-destructive/10 text-destructive border-destructive/30",children:d>=.7?"ROBUST":d>=.5?"MODERATE":"OVERFIT RISK"})]})})]})]})}function fc({agentConfig:t,currentPositions:s}){const[a,r]=j.useState(!1),[n,c]=j.useState([{scenario:"2008 Financial Crisis",portfolioImpact:-34.5,probability:5,historicalDate:"Sep 2008",description:"Lehman collapse, credit freeze"},{scenario:"2020 COVID Crash",portfolioImpact:-28.2,probability:8,historicalDate:"Mar 2020",description:"Pandemic market selloff"},{scenario:"2022 Crypto Winter",portfolioImpact:-52.8,probability:12,historicalDate:"Nov 2022",description:"FTX collapse, crypto contagion"},{scenario:"Flash Crash",portfolioImpact:-15.4,probability:15,historicalDate:"May 2010",description:"Rapid algorithmic selloff"},{scenario:"Interest Rate Shock",portfolioImpact:-18.7,probability:20,historicalDate:"Hypothetical",description:"+200bps rate spike"},{scenario:"Liquidity Crisis",portfolioImpact:-22.3,probability:10,historicalDate:"Hypothetical",description:"Market-wide liquidity drought"},{scenario:"Geopolitical Event",portfolioImpact:-12.8,probability:25,historicalDate:"Hypothetical",description:"Major conflict escalation"},{scenario:"Currency Crisis",portfolioImpact:-16.5,probability:18,historicalDate:"Hypothetical",description:"USD 20% devaluation"}]),d=()=>{r(!0),setTimeout(()=>{c(h=>h.map(m=>({...m,portfolioImpact:m.portfolioImpact*(.9+Math.random()*.2)}
116))),r(!1)},2e3)},i=h=>h>-10?"text-amber-400":h>-25?"text-orange-400":"text-destructive",l=h=>h>-10?"hsl(var(--chart-3))":h>-25?"hsl(var(--chart-4))":"hsl(var(--destructive))",o=n.reduce((h,m)=>m.portfolioImpact<h.portfolioImpact?m:h,n[0]),u=n.reduce((h,m)=>h+m.portfolioImpact,0)/n.length,v=n.reduce((h,m)=>h+m.portfolioImpact*m.probability/100,0);return e.jsxs(q,{children:[e.jsx(X,{className:"pb-3",children:e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(Re,{className:"w-4 h-4 text-amber-400"}),"Stress Test / Scenario Analysis",e.jsx(C,{variant:"outline",className:"text-[10px] bg-amber-500/10 text-amber-400 border-amber-500/30 ml-auto",children:"INSTITUTIONAL"})]})}),e.jsxs(H,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"p-3 bg-destructive/10 rounded-lg border border-destructive/30",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(ke,{className:"w-3 h-3 text-destructive"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Worst Case"})]}),e.jsxs("p",{className:"text-xl font-bold font-mono text-destructive",children:[o.portfolioImpact.toFixed(1),"%"]}),e.jsx("p",{className:"text-[9px] text-muted-foreground truncate",children:o.scenario})]}),e.jsxs("div",{className:"p-3 bg-orange-500/10 rounded-lg border border-orange-500/30",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Ls,{className:"w-3 h-3 text-orange-400"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Avg Impact"})]}),e.jsxs("p",{className:"text-xl font-bold font-mono text-orange-400",children:[u.toFixed(1),"%"]})]}),e.jsxs("div",{className:"p-3 bg-amber-500/10 rounded-lg border border-amber-500/30",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(pe,{className:"w-3 h-3 text-amber-400"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Expected Loss"})]}),e.jsxs("p",{className:"text-xl font-bold font-mono text-amber-400",children:[v.toFixed(2),"%"]}),e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Probability weighted"})]})]}),e.jsx("div",{className:"h-48",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(ot,{data:n,layout:"vertical",margin:{top:5,right:5,left:80,bottom:5},children:[e.jsx(de,{type:"number",tick:{fontSize:9},tickFormatter:h=>`${h}%`,domain:[-60,0]}),e.jsx(oe,{type:"category",dataKey:"scenario",tick:{fontSize:9},width:75}),e.jsx(Ne,{contentStyle:{backgroundColor:"hsl(var(--background))",border:"1px solid hsl(var(--border))",borderRadius:"8px",fontSize:"11px"},formatter:(h,m,f)=>[`${h.toFixed(1)}%`,`Impact (${f.payload.probability}% probability)`]}),e.jsx(fe,{x:-10,stroke:"hsl(var(--chart-3))",strokeDasharray:"3 3"}),e.jsx(fe,{x:-25,stroke:"hsl(var(--destructive))",strokeDasharray:"3 3"}),e.jsx(Ye,{dataKey:"portfolioImpact",radius:[0,4,4,0],children:n.map((h,m)=>e.jsx(rt,{fill:l(h.portfolioImpact)},`cell-${m}`))})]})})}),e.jsx("div",{className:"space-y-2 max-h-40 overflow-y-auto",children:n.slice(0,4).map((h,m)=>e.jsxs("div",{className:"flex items-center justify-between p-2 bg-muted/30 rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-xs font-medium",children:h.scenario}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:h.description})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:`text-sm font-bold font-mono ${i(h.portfolioImpact)}`,children:[h.portfolioImpact.toFixed(1),"%"]}),e.jsxs("p",{className:"text-[9px] text-muted-foreground",children:[h.probability,"% prob"]})]})]},m))}),e.jsxs(W,{onClick:d,disabled:a,className:"w-full",variant:"outline",children:[e.jsx(Je,{className:"w-4 h-4 mr-2"}),a?"Running Stress Tests...":"Run Stress Test Suite"]})]})]})}function bc({assets:t}){const s=t||[{symbol:"BTC",liquidityScore:95,bidAskSpread:.01,marketDepth:850,avgDailyVolume:285e8,marketImpact:.02,timeToLiquidate:.5},{symbol:"ETH",liquidityScore:92,bidAskSpread:.02,marketDepth:620,avgDailyVolume:152e8,marketImpact:.03,timeToLiquidate:.8},{symbol:"SOL",liquidityScore:78,bidAskSpread:.05,marketDepth:180,avgDailyVolume:28e8,marketImpact:.08,timeToLiquidate:2.5}
116,{symbol:"SPY",liquidityScore:99,bidAskSpread:.001,marketDepth:5200,avgDailyVolume:95e9,marketImpact:.005,timeToLiquidate:.1},{symbol:"QQQ",liquidityScore:98,bidAskSpread:.002,marketDepth:3800,avgDailyVolume:52e9,marketImpact:.008,timeToLiquidate:.2}],a=s.reduce((o,u)=>o+u.liquidityScore,0)/s.length,r=s.reduce((o,u)=>o+u.bidAskSpread,0)/s.length,n=s.reduce((o,u)=>o+u.avgDailyVolume,0),c=o=>o>=90?"text-emerald-400":o>=70?"text-amber-400":"text-destructive",d=o=>o>=90?"bg-emerald-500/20 border-emerald-500/30":o>=70?"bg-amber-500/20 border-amber-500/30":"bg-destructive/20 border-destructive/30",i=o=>o>=90?"hsl(var(--chart-2))":o>=70?"hsl(var(--chart-3))":"hsl(var(--destructive))",l=s.map(o=>({symbol:o.symbol,depth:o.marketDepth,impact:o.marketImpact*100}));return e.jsxs(q,{children:[e.jsx(X,{className:"pb-3",children:e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(Qa,{className:"w-4 h-4 text-blue-400"}),"Liquidity Analysis",e.jsx(C,{variant:"outline",className:"text-[10px] bg-blue-500/10 text-blue-400 border-blue-500/30 ml-auto",children:"MARKET MICRO"})]})}
116),e.jsxs(H,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:`p-3 rounded-lg border ${d(a)}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Qa,{className:"w-3 h-3"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Avg Liquidity"})]}),e.jsx("p",{className:`text-xl font-bold font-mono ${c(a)}`,children:a.toFixed(0)}),e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Portfolio score"})]}),e.jsxs("div",{className:"p-3 bg-muted/30 rounded-lg border border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(ke,{className:"w-3 h-3 text-amber-400"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Avg Spread"})]}),e.jsxs("p",{className:"text-xl font-bold font-mono",children:[(r*100).toFixed(2),"%"]}),e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Bid-ask cost"})]}),e.jsxs("div",{className:"p-3 bg-muted/30 rounded-lg border border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(as,{className:"w-3 h-3 text-primary"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Daily Volume"})]}),e.jsxs("p",{className:"text-xl font-bold font-mono text-primary",children:["$",(n/1e9).toFixed(0),"B"]}),e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Combined"})]})]}),e.jsx("div",{className:"h-32",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(ot,{data:l,margin:{top:5,right:5,left:-20,bottom:0},children:[e.jsx(de,{dataKey:"symbol",tick:{fontSize:10}}),e.jsx(oe,{tick:{fontSize:9}}),e.jsx(Ne,{contentStyle:{backgroundColor:"hsl(var(--background))",border:"1px solid hsl(var(--border))",borderRadius:"8px",fontSize:"11px"},formatter:(o,u)=>[u==="depth"?`$${o}M`:`${o.toFixed(2)}%`,u==="depth"?"Market Depth":"Market Impact"]}),e.jsx(Ye,{dataKey:"depth",name:"depth",radius:[4,4,0,0],children:l.map((o,u)=>e.jsx(rt,{fill:i(s[u].liquidityScore)},`cell-${u}`))})]})})}),e.jsx("div",{className:"space-y-2",children:s.map((o,u)=>e.jsxs("div",{className:"flex items-center gap-3 p-2 bg-muted/30 rounded-lg",children:[e.jsx("div",{className:"w-12",children:e.jsx(Hs,{to:`/${o.symbol}`,className:"text-xs font-bold hover:text-primary transition-colors",children:o.symbol})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex justify-between text-[10px] mb-1",children:[e.jsx("span",{className:"text-muted-foreground",children:"Liquidity Score"}),e.jsx("span",{className:c(o.liquidityScore),children:o.liquidityScore})]}),e.jsx(Xe,{value:o.liquidityScore,className:"h-1.5"})]}),e.jsxs("div",{className:"text-right w-20",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Spread"}),e.jsxs("p",{className:"text-xs font-mono",children:[(o.bidAskSpread*100).toFixed(2),"%"]})]}),e.jsxs("div",{className:"text-right w-16",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Impact"}),e.jsxs("p",{className:`text-xs font-mono ${o.marketImpact>.05?"text-amber-400":""}`,children:[(o.marketImpact*100).toFixed(1),"%"]})]})]},u))}),s.some(o=>o.liquidityScore<80)&&e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-amber-500/10 border border-amber-500/30 rounded-lg",children:[e.jsx(Re,{className:"w-4 h-4 text-amber-400"}),e.jsx("span",{className:"text-xs text-amber-400",children:"Some assets have reduced liquidity. Consider smaller position sizes."})]})]})]})}function vc({totalReturn:t=24.5,benchmarkReturn:s=18.2,attributionFactors:a}){const r=a||[{factor:"Asset Allocation",contribution:8.2,weight:.35,return:23.4},{factor:"Security Selection",contribution:5.8,weight:.25,return:23.2},{factor:"Market Timing",contribution:4.1,weight:.15,return:27.3},{factor:"Factor Exposure",contribution:3.2,weight:.15,return:21.3},{factor:"Currency",contribution:1.8,weight:.05,return:36},{factor:"Residual",contribution:1.4,weight:.05,return:28}],n=t-s,c=n/8.5,d=r.map(o=>({name:o.factor,value:Math.abs(o.contribution),isPositive:o.contribution>=0})),i=["hsl(var(--chart-1))","hsl(var(--chart-2))","hsl(var(--chart-3))","hsl(var(--chart-4))","hsl(var(--chart-5))","hsl(var(--primary))"],l=r.map(o=>({factor:o.factor.split(" ")[0],contribution:o.contribution}));return e.jsxs(q,{children:[e.jsx(X,{className:"pb-3",children:e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(Aa,{className:"w-4 h-4 text-emerald-400"}),"Performance Attribution",e.jsx(C,{variant:"outline",className:"text-[10px] bg-emerald-500/10 text-emerald-400 border-emerald-500/30 ml-auto",children:"BRINSON"})]})}
116),e.jsxs(H,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"p-3 bg-primary/10 rounded-lg border border-primary/30",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(he,{className:"w-3 h-3 text-primary"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Total Return"})]}),e.jsxs("p",{className:"text-xl font-bold font-mono text-primary",children:["+",t.toFixed(1),"%"]})]}),e.jsxs("div",{className:"p-3 bg-muted/30 rounded-lg border border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Be,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Benchmark"})]}),e.jsxs("p",{className:"text-xl font-bold font-mono",children:["+",s.toFixed(1),"%"]})]}),e.jsxs("div",{className:`p-3 rounded-lg border ${n>=0?"bg-emerald-500/10 border-emerald-500/30":"bg-destructive/10 border-destructive/30"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Gt,{className:"w-3 h-3"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Alpha"})]}),e.jsxs("p",{className:`text-xl font-bold font-mono ${n>=0?"text-emerald-400":"text-destructive"}`,children:[n>=0?"+":"",n.toFixed(1),"%"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx("div",{className:"h-32",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(Ys,{children:[e.jsx(Qs,{data:d,cx:"50%",cy:"50%",innerRadius:25,outerRadius:50,paddingAngle:2,dataKey:"value",children:d.map((o,u)=>e.jsx(rt,{fill:i[u%i.length]},`cell-${u}`))}),e.jsx(Ne,{contentStyle:{backgroundColor:"hsl(var(--background))",border:"1px solid hsl(var(--border))",borderRadius:"8px",fontSize:"11px"},formatter:o=>[`${o.toFixed(1)}%`,"Contribution"]})]})})}),e.jsx("div",{className:"h-32",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(ot,{data:l,layout:"vertical",margin:{top:0,right:5,left:0,bottom:0},children:[e.jsx(de,{type:"number",tick:{fontSize:9},tickFormatter:o=>`${o}%`}),e.jsx(oe,{type:"category",dataKey:"factor",tick:{fontSize:8},width:45}),e.jsx(fe,{x:0,stroke:"hsl(var(--border))"}),e.jsx(Ne,{contentStyle:{backgroundColor:"hsl(var(--background))",border:"1px solid hsl(var(--border))",borderRadius:"8px",fontSize:"11px"},formatter:o=>[`${o.toFixed(1)}%`,"Contribution"]}),e.jsx(Ye,{dataKey:"contribution",fill:"hsl(var(--primary))",radius:[0,4,4,0]})]})})})]}),e.jsx("div",{className:"space-y-2",children:r.slice(0,4).map((o,u)=>e.jsxs("div",{className:"flex items-center justify-between p-2 bg-muted/30 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:i[u]}}),e.jsx("span",{className:"text-xs",children:o.factor})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Weight"}),e.jsxs("p",{className:"text-xs font-mono",children:[(o.weight*100).toFixed(0),"%"]})]}),e.jsxs("div",{className:"text-right w-16",children:[e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Return"}),e.jsxs("p",{className:"text-xs font-mono",children:[o.return.toFixed(1),"%"]})]}),e.jsxs("div",{className:"text-right w-16",children:[e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Contrib"}),e.jsxs("p",{className:`text-xs font-bold font-mono ${o.contribution>=0?"text-emerald-400":"text-destructive"}`,children:[o.contribution>=0?"+":"",o.contribution.toFixed(1),"%"]})]})]})]},u))}),e.jsxs("div",{className:"flex items-center justify-between p-3 bg-primary/5 rounded-lg border border-primary/20",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium",children:"Information Ratio"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Active return / Tracking error"})]}),e.jsx("p",{className:`text-xl font-bold font-mono ${c>=.5?"text-emerald-400":c>=0?"text-amber-400":"text-destructive"}`,children:c.toFixed(2)})]})]})]})}function jc({metrics:t}){const s=t||{var95:3.2,var99:5.8,cvar95:4.5,cvar99:7.2,maxDrawdown:12.4,tailDependence:.42,skewness:-.85,kurtosis:4.2},a=Array.from({length:50},(c,d)=>{const i=-10+d*.4,o=Math.exp(-.5*Math.pow(i/2.5,2))/(2.5*Math.sqrt(2*Math.PI))*(1+.3*Math.exp(-Math.abs(i)*.5));return{return:i,frequency:o*100,var95:i<=-s.var95?o*100:0,var99:i<=-s.var99?o*100:0}}),r=[{date:"2024-08-05",loss:-8.2,event:"Yen carry unwind"},{date:"2024-04-13",loss:-6.5,event:"Geopolitical shock"},{date:"2024-01-15",loss:-4.8,event:"ETF rebalance"},{date:"2023-11-10",loss:-5.2,event:"Liquidity squeeze"}];return(c=>c<5?{label:"Low",color:"text-emerald-400",bg:"bg-emerald-500/20"}:c<8?{label:"Moderate",color:"text-amber-400",bg:"bg-amber-500/20"}:{label:"High",color:"text-destructive",bg:"bg-destructive/20"})(s.cvar95),e.jsxs(q,{children:[e.jsx(X,{className:"pb-3",children:e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(Re,{className:"w-4 h-4 text-rose-400"}),"Tail Risk / EVT Analysis",e.jsx(C,{variant:"outline",className:"text-[10px] bg-rose-500/10 text-rose-400 border-rose-500/30 ml-auto",children:"EXTREME VALUE"})]})}
116),e.jsxs(H,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[e.jsxs("div",{className:"p-2 bg-amber-500/10 rounded-lg border border-amber-500/30 text-center",children:[e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"VaR 95%"}),e.jsxs("p",{className:"text-lg font-bold font-mono text-amber-400",children:["-",s.var95,"%"]})]}),e.jsxs("div",{className:"p-2 bg-orange-500/10 rounded-lg border border-orange-500/30 text-center",children:[e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"VaR 99%"}),e.jsxs("p",{className:"text-lg font-bold font-mono text-orange-400",children:["-",s.var99,"%"]})]}),e.jsxs("div",{className:"p-2 bg-rose-500/10 rounded-lg border border-rose-500/30 text-center",children:[e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"CVaR 95%"}),e.jsxs("p",{className:"text-lg font-bold font-mono text-rose-400",children:["-",s.cvar95,"%"]})]}),e.jsxs("div",{className:"p-2 bg-destructive/10 rounded-lg border border-destructive/30 text-center",children:[e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"CVaR 99%"}),e.jsxs("p",{className:"text-lg font-bold font-mono text-destructive",children:["-",s.cvar99,"%"]})]})]}),e.jsx("div",{className:"h-32",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(Js,{data:a,margin:{top:5,right:5,left:-20,bottom:0},children:[e.jsx(de,{dataKey:"return",tick:{fontSize:9},tickFormatter:c=>`${c}%`}),e.jsx(oe,{tick:{fontSize:9}}),e.jsx(Ne,{contentStyle:{backgroundColor:"hsl(var(--background))",border:"1px solid hsl(var(--border))",borderRadius:"8px",fontSize:"11px"}}),e.jsx(fe,{x:-s.var95,stroke:"hsl(var(--chart-3))",strokeDasharray:"3 3"}),e.jsx(fe,{x:-s.var99,stroke:"hsl(var(--destructive))",strokeDasharray:"3 3"}),e.jsx(We,{type:"monotone",dataKey:"frequency",stroke:"hsl(var(--primary))",fill:"hsl(var(--primary))",fillOpacity:.3}),e.jsx(We,{type:"monotone",dataKey:"var95",stroke:"none",fill:"hsl(var(--destructive))",fillOpacity:.5})]})})}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"p-2 bg-muted/30 rounded-lg text-center",children:[e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Skewness"}),e.jsx("p",{className:`text-sm font-bold font-mono ${s.skewness<0?"text-amber-400":""}`,children:s.skewness.toFixed(2)}),e.jsx("p",{className:"text-[8px] text-muted-foreground",children:s.skewness<0?"Left tail bias":"Right tail bias"})]}),e.jsxs("div",{className:"p-2 bg-muted/30 rounded-lg text-center",children:[e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Kurtosis"}),e.jsx("p",{className:`text-sm font-bold font-mono ${s.kurtosis>3?"text-amber-400":""}`,children:s.kurtosis.toFixed(2)}),e.jsx("p",{className:"text-[8px] text-muted-foreground",children:s.kurtosis>3?"Fat tails":"Normal tails"})]}),e.jsxs("div",{className:"p-2 bg-muted/30 rounded-lg text-center",children:[e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Tail Dependence"}),e.jsxs("p",{className:`text-sm font-bold font-mono ${s.tailDependence>.3?"text-amber-400":""}`,children:[(s.tailDependence*100).toFixed(0),"%"]}),e.jsx("p",{className:"text-[8px] text-muted-foreground",children:"Co-crash risk"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground font-medium",children:"Recent Tail Events"}),r.slice(0,3).map((c,d)=>e.jsxs("div",{className:"flex items-center justify-between p-2 bg-muted/30 rounded",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"w-3 h-3 text-destructive"}),e.jsx("span",{className:"text-[10px]",children:c.event})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[9px] text-muted-foreground",children:c.date}),e.jsxs("span",{className:"text-xs font-mono text-destructive",children:[c.loss,"%"]})]})]},d))]})]})]})}function yc({agentConfig:t,liveData:s}){const a=(t==null?void 0:t.zscore_entry)||2,r=(t==null?void 0:t.zscore_exit)||.5,n=(t==null?void 0:t.half_life_max)||30,c=(s==null?void 0:s.correlationPairs)??[{pair:"BTC/ETH",symbol1:"BTC",symbol2:"ETH",zscore:1.8,correlation:.89,halfLife:12,cointegrated:!0,signal:"neutral"},{pair:"SOL/AVAX",symbol1:"SOL",symbol2:"AVAX",zscore:-2.4,correlation:.76,halfLife:8,cointegrated:!0,signal:"long"},{pair:"DOT/LINK",symbol1:"DOT",symbol2:"LINK",zscore:2.1,correlation:.82,halfLife:15,cointegrated:!0,signal:"short"},{pair:"XRP/ADA",symbol1:"XRP",symbol2:"ADA",zscore:.3,correlation:.71,halfLife:22,cointegrated:!1,signal:"neutral"}],d=(s==null?void 0:s.zscoreHistory)??Array.from({length:50},(o,u)=>({time:u,zscore:Math.sin(u/5)*2+(Math.random()-.5)*.5})),i=(o,u)=>o==="long"?e.jsx(C,{className:"bg-emerald-500/20 text-emerald-400",children:"LONG SPREAD"}):o==="short"?e.jsx(C,{className:"bg-red-500/20 text-red-400",children:"SHORT SPREAD"}):e.jsx(C,{variant:"outline",children:"NEUTRAL"}),l=!!s;return e.jsxs(q,{className:"bg-card/50 border-border/50",children:[e.jsx(X,{className:"pb-2",children:e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(mt,{className:"w-4 h-4 text-primary"}),"Statistical Arbitrage / Pairs Trading",(t==null?void 0:t.pairs_trading_enabled)&&e.jsx(C,{className:"bg-emerald-500/20 text-emerald-400 text-[10px]",children:"ACTIVE"}),l&&e.jsxs(C,{className:"bg-cyan-500/20 text-cyan-400 text-[10px]",children:[e.jsx(Me,{className:"w-3 h-3 mr-1 animate-spin"}),"LIVE"]})]})}
116),e.jsxs(H,{className:"space-y-4",children:[e.jsx("div",{className:"h-32",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(At,{data:d,children:[e.jsx(de,{dataKey:"time",hide:!0}),e.jsx(oe,{domain:[-3,3],hide:!0}),e.jsx(fe,{y:a,stroke:"#ef4444",strokeDasharray:"3 3"}),e.jsx(fe,{y:-a,stroke:"#22c55e",strokeDasharray:"3 3"}),e.jsx(fe,{y:r,stroke:"#94a3b8",strokeDasharray:"2 2"}),e.jsx(fe,{y:-r,stroke:"#94a3b8",strokeDasharray:"2 2"}),e.jsx(fe,{y:0,stroke:"#64748b"}),e.jsx(Fe,{type:"monotone",dataKey:"zscore",stroke:"#06b6d4",strokeWidth:1.5,dot:!1})]})})}),e.jsx("div",{className:"space-y-2",children:c.map(o=>e.jsxs("div",{className:"flex items-center justify-between p-2 bg-muted/30 rounded text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono font-medium",children:o.pair}),o.cointegrated?e.jsx(C,{variant:"outline",className:"text-[10px] bg-emerald-500/10 text-emerald-400",children:"COINT"}):e.jsx(C,{variant:"outline",className:"text-[10px] text-muted-foreground",children:"NO COINT"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:`font-mono ${Math.abs(o.zscore)>a?"text-amber-400":"text-muted-foreground"}`,children:["Z: ",o.zscore.toFixed(2)]}),e.jsxs("span",{className:"text-muted-foreground",children:["Ï: ",o.correlation.toFixed(2)]}),e.jsxs("span",{className:`text-muted-foreground ${o.halfLife>n?"text-red-400":""}`,children:["HL: ",o.halfLife.toFixed(0),"d"]}),i(o.signal,o.zscore)]})]},o.pair))}),e.jsxs("div",{className:"grid grid-cols-4 gap-2 text-[10px] text-muted-foreground pt-2 border-t border-border/30",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"font-medium text-foreground",children:["±",a]}),e.jsx("div",{children:"Entry Z"})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"font-medium text-foreground",children:["±",r]}),e.jsx("div",{children:"Exit Z"})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"font-medium text-foreground",children:[(t==null?void 0:t.cointegration_lookback)||60,"d"]}),e.jsx("div",{children:"Lookback"})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"font-medium text-foreground",children:[n,"d"]}),e.jsx("div",{children:"Max HL"})]})]})]})]})}function Nc({agentConfig:t}){const s=(t==null?void 0:t.execution_algo)||"market",a=Array.from({length:20},(c,d)=>({time:d,target:100*(d/20),actual:100*(d/20)+(Math.random()-.5)*5,slippage:(Math.random()-.3)*.2})),r=[{symbol:"BTC",algo:"TWAP",size:"0.5 BTC",duration:"15m",slippage:-.02,status:"complete"},{symbol:"ETH",algo:"VWAP",size:"10 ETH",duration:"30m",slippage:.05,status:"active"},{symbol:"SOL",algo:"ICEBERG",size:"500 SOL",duration:"45m",slippage:-.08,status:"complete"}],n=c=>{const d={market:"bg-blue-500/20 text-blue-400",twap:"bg-emerald-500/20 text-emerald-400",vwap:"bg-purple-500/20 text-purple-400",iceberg:"bg-amber-500/20 text-amber-400"};return e.jsx(C,{className:d[c.toLowerCase()]||d.market,children:c.toUpperCase()})};return e.jsxs(q,{className:"bg-card/50 border-border/50",children:[e.jsx(X,{className:"pb-2",children:e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(Gr,{className:"w-4 h-4 text-primary"}),"Advanced Execution Algorithms",n(s)]})}
116),e.jsxs(H,{className:"space-y-4",children:[e.jsx("div",{className:"h-28",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(Ot,{data:a,children:[e.jsx(de,{dataKey:"time",hide:!0}),e.jsx(oe,{domain:[0,100],hide:!0}),e.jsx(We,{type:"stepAfter",dataKey:"target",stroke:"#64748b",fill:"none",strokeDasharray:"3 3"}),e.jsx(We,{type:"stepAfter",dataKey:"actual",stroke:"#06b6d4",fill:"#06b6d4",fillOpacity:.1})]})})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs text-muted-foreground font-medium",children:"Recent Executions"}),r.map((c,d)=>e.jsxs("div",{className:"flex items-center justify-between p-2 bg-muted/30 rounded text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Hs,{to:`/${c.symbol}`,className:"font-mono font-medium hover:text-primary transition-colors",children:c.symbol}),n(c.algo),e.jsx("span",{className:"text-muted-foreground",children:c.size})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:c.duration}),e.jsxs("span",{className:c.slippage>0?"text-red-400":"text-emerald-400",children:[c.slippage>0?"+":"",(c.slippage*100).toFixed(2),"%"]}),e.jsx(C,{variant:"outline",className:c.status==="active"?"bg-emerald-500/20 text-emerald-400":"",children:c.status.toUpperCase()})]})]},d))]}),e.jsxs("div",{className:"grid grid-cols-4 gap-2 text-[10px] text-muted-foreground pt-2 border-t border-border/30",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"font-medium text-foreground",children:[(t==null?void 0:t.twap_duration_minutes)||30,"m"]}),e.jsx("div",{children:"TWAP Duration"})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"font-medium text-foreground",children:[(((t==null?void 0:t.vwap_participation_rate)||.1)*100).toFixed(0),"%"]}),e.jsx("div",{children:"VWAP Part."})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"font-medium text-foreground",children:[(((t==null?void 0:t.iceberg_show_size)||.1)*100).toFixed(0),"%"]}),e.jsx("div",{children:"Iceberg Show"})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"font-medium text-foreground",children:[(((t==null?void 0:t.implementation_shortfall_limit)||.005)*100).toFixed(2),"%"]}),e.jsx("div",{children:"IS Limit"})]})]})]})]})}function wc({agentConfig:t,liveData:s}){var h,m,f;const a=((h=s==null?void 0:s.riskMetrics)==null?void 0:h.portfolioVaR)??.024,r=(s==null?void 0:s.marginalVaR)??[{asset:"BTC",mvar:.008,weight:.35},{asset:"ETH",mvar:.006,weight:.25},{asset:"SOL",mvar:.004,weight:.15},{asset:"SPY",mvar:.003,weight:.15},{asset:"QQQ",mvar:.003,weight:.1}],n=((m=s==null?void 0:s.riskMetrics)==null?void 0:m.grossExposure)??1.8,c=((f=s==null?void 0:s.riskMetrics)==null?void 0:f.netExposure)??.22,d=[{name:"Gross",value:n,limit:(t==null?void 0:t.gross_exposure_limit)||2},{name:"Net",value:c,limit:(t==null?void 0:t.net_exposure_limit)||.3}],i=["#06b6d4","#8b5cf6","#22c55e","#f59e0b","#ef4444"],l=(t==null?void 0:t.portfolio_var_limit)||.03,o=(t==null?void 0:t.marginal_var_limit)||.01,u=a>l,v=!!s;return e.jsxs(q,{className:"bg-card/50 border-border/50",children:[e.jsx(X,{className:"pb-2",children:e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(Ce,{className:"w-4 h-4 text-primary"}),"Portfolio-Level Risk",u&&e.jsxs(C,{className:"bg-red-500/20 text-red-400 text-[10px]",children:[e.jsx(Re,{className:"w-3 h-3 mr-1"}),"VAR BREACH"]}),v&&e.jsxs(C,{className:"bg-emerald-500/20 text-emerald-400 text-[10px]",children:[e.jsx(Me,{className:"w-3 h-3 mr-1 animate-spin"}),"LIVE"]})]})}
116),e.jsxs(H,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/30 rounded",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Portfolio VaR (95%)"}),e.jsxs("div",{className:`text-2xl font-bold ${u?"text-red-400":"text-emerald-400"}`,children:[(a*100).toFixed(2),"%"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Limit"}),e.jsxs("div",{className:"text-lg font-medium",children:[(l*100).toFixed(1),"%"]})]}),e.jsx("div",{className:"h-12 w-32",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(ot,{data:[{value:a,limit:l}],layout:"vertical",children:[e.jsx(de,{type:"number",domain:[0,l*1.2],hide:!0}),e.jsx(oe,{type:"category",hide:!0}),e.jsx(Ye,{dataKey:"value",fill:u?"#ef4444":"#22c55e",radius:4})]})})})]}),(s==null?void 0:s.riskMetrics)&&e.jsxs("div",{className:"grid grid-cols-3 gap-2 p-2 bg-muted/20 rounded",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"CVaR"}),e.jsxs("div",{className:"text-sm font-bold text-primary",children:[(s.riskMetrics.portfolioCVaR*100).toFixed(2),"%"]})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Sharpe"}),e.jsx("div",{className:`text-sm font-bold ${s.riskMetrics.sharpeRatio>1?"text-emerald-400":"text-amber-400"}`,children:s.riskMetrics.sharpeRatio.toFixed(2)})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Sortino"}),e.jsx("div",{className:`text-sm font-bold ${s.riskMetrics.sortinoRatio>1.5?"text-emerald-400":"text-amber-400"}`,children:s.riskMetrics.sortinoRatio.toFixed(2)})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs text-muted-foreground font-medium",children:"Marginal VaR Contribution"}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"w-24 h-24",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsx(Ys,{children:e.jsx(Qs,{data:r,dataKey:"mvar",nameKey:"asset",cx:"50%",cy:"50%",innerRadius:25,outerRadius:40,children:r.map((b,_)=>e.jsx(rt,{fill:i[_%i.length]},b.asset))})})})}),e.jsx("div",{className:"flex-1 space-y-1",children:r.map((b,_)=>e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:i[_]}}),e.jsx("span",{children:b.asset})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:b.mvar>o?"text-red-400":"text-muted-foreground",children:[(b.mvar*100).toFixed(2),"%"]}),e.jsxs("span",{className:"text-muted-foreground",children:["(",(b.weight*100).toFixed(0),"%)"]})]})]},b.asset))})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 pt-2 border-t border-border/30",children:d.map(b=>e.jsxs("div",{className:"p-2 bg-muted/20 rounded text-center",children:[e.jsxs("div",{className:"text-xs text-muted-foreground",children:[b.name," Exposure"]}),e.jsxs("div",{className:`text-lg font-bold ${b.value>b.limit?"text-red-400":"text-foreground"}`,children:[b.value.toFixed(2),"x"]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:["Limit: ",b.limit,"x"]})]},b.name))}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[10px] text-muted-foreground",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Sector Limit:"}),e.jsxs("span",{className:"text-foreground",children:[((t==null?void 0:t.sector_concentration_limit)||.25)*100,"%"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Single Name:"}),e.jsxs("span",{className:"text-foreground",children:[((t==null?void 0:t.single_name_limit)||.1)*100,"%"]})]})]})]})]})}function _c({agentConfig:t,liveData:s}){var i;const a=((i=s==null?void 0:s.sentiment)==null?void 0:i.history)??Array.from({length:24},(l,o)=>({hour:o,news:50+Math.sin(o/3)*20+(Math.random()-.5)*10,social:45+Math.cos(o/4)*25+(Math.random()-.5)*15,onchain:55+Math.sin(o/5)*15+(Math.random()-.5)*8}
116)),r=s!=null&&s.sentiment?{news:{score:s.sentiment.news.score,change:s.sentiment.news.change,headlines:s.sentiment.news.headline},social:{score:s.sentiment.social.score,change:s.sentiment.social.change,trending:s.sentiment.social.trending},onchain:{score:s.sentiment.onchain.score,change:s.sentiment.onchain.change,metric:s.sentiment.onchain.metric}}:{news:{score:62,change:5.2,headlines:"Fed signals pause, BTC rallies"},social:{score:71,change:-2.1,trending:"#Bitcoin #ToTheMoon"},onchain:{score:58,change:8.4,metric:"Whale accumulation +12%"}},n=l=>l>=60?"text-emerald-400":l<=40?"text-red-400":"text-amber-400",c=l=>l>=70?e.jsx(C,{className:"bg-emerald-500/20 text-emerald-400",children:"BULLISH"}):l>=55?e.jsx(C,{className:"bg-emerald-500/10 text-emerald-300",children:"LEAN BULL"}):l<=30?e.jsx(C,{className:"bg-red-500/20 text-red-400",children:"BEARISH"}):l<=45?e.jsx(C,{className:"bg-red-500/10 text-red-300",children:"LEAN BEAR"}):e.jsx(C,{variant:"outline",children:"NEUTRAL"}),d=!!s;return e.jsxs(q,{className:"bg-card/50 border-border/50",children:[e.jsx(X,{className:"pb-2",children:e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(Fs,{className:"w-4 h-4 text-primary"}),"Sentiment & Alternative Data",d&&e.jsxs(C,{className:"bg-emerald-500/20 text-emerald-400 text-[10px]",children:[e.jsx(Me,{className:"w-3 h-3 mr-1 animate-spin"}),"LIVE"]})]})}
116),e.jsxs(H,{className:"space-y-4",children:[e.jsx("div",{className:"h-28",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(Ot,{data:a,children:[e.jsx(de,{dataKey:"hour",hide:!0}),e.jsx(oe,{domain:[0,100],hide:!0}),(t==null?void 0:t.use_news_sentiment)&&e.jsx(We,{type:"monotone",dataKey:"news",stroke:"#f59e0b",fill:"#f59e0b",fillOpacity:.1,strokeWidth:1.5}),(t==null?void 0:t.use_social_sentiment)&&e.jsx(We,{type:"monotone",dataKey:"social",stroke:"#8b5cf6",fill:"#8b5cf6",fillOpacity:.1,strokeWidth:1.5}),(t==null?void 0:t.use_onchain_metrics)&&e.jsx(We,{type:"monotone",dataKey:"onchain",stroke:"#06b6d4",fill:"#06b6d4",fillOpacity:.1,strokeWidth:1.5})]})})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:`p-2 bg-muted/30 rounded ${!(t!=null&&t.use_news_sentiment)&&"opacity-50"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ai,{className:"w-4 h-4 text-amber-400"}),e.jsx("span",{className:"text-xs font-medium",children:"News Sentiment"}),(t==null?void 0:t.use_news_sentiment)&&e.jsxs(C,{variant:"outline",className:"text-[10px]",children:[(t.news_sentiment_weight||.2)*100,"% wt"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-lg font-bold ${n(r.news.score)}`,children:r.news.score.toFixed(0)}),e.jsxs("span",{className:`text-xs ${r.news.change>0?"text-emerald-400":"text-red-400"}`,children:[r.news.change>0?"+":"",r.news.change.toFixed(1),"%"]}),c(r.news.score)]})]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground mt-1 truncate",children:["ð° ",r.news.headlines]})]}),e.jsxs("div",{className:`p-2 bg-muted/30 rounded ${!(t!=null&&t.use_social_sentiment)&&"opacity-50"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Kr,{className:"w-4 h-4 text-purple-400"}),e.jsx("span",{className:"text-xs font-medium",children:"Social Sentiment"}),(t==null?void 0:t.use_social_sentiment)&&e.jsxs(C,{variant:"outline",className:"text-[10px]",children:[(t.social_sentiment_weight||.1)*100,"% wt"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-lg font-bold ${n(r.social.score)}`,children:r.social.score.toFixed(0)}),e.jsxs("span",{className:`text-xs ${r.social.change>0?"text-emerald-400":"text-red-400"}`,children:[r.social.change>0?"+":"",r.social.change.toFixed(1),"%"]}),c(r.social.score)]})]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground mt-1 truncate",children:["ð¥ Trending: ",r.social.trending]})]}),e.jsxs("div",{className:`p-2 bg-muted/30 rounded ${!(t!=null&&t.use_onchain_metrics)&&"opacity-50"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ri,{className:"w-4 h-4 text-cyan-400"}),e.jsx("span",{className:"text-xs font-medium",children:"On-Chain Metrics"}),(t==null?void 0:t.use_onchain_metrics)&&e.jsxs(C,{variant:"outline",className:"text-[10px]",children:[(t.onchain_weight||.15)*100,"% wt"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-lg font-bold ${n(r.onchain.score)}`,children:r.onchain.score.toFixed(0)}),e.jsxs("span",{className:`text-xs ${r.onchain.change>0?"text-emerald-400":"text-red-400"}`,children:[r.onchain.change>0?"+":"",r.onchain.change.toFixed(1),"%"]}),c(r.onchain.score)]})]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground mt-1 truncate",children:["âï¸ ",r.onchain.metric]})]})]})]})]})}function kc({agentConfig:t}){const s=[{name:"BTC",beta:1.8,weight:.35,return:12},{name:"ETH",beta:2.1,weight:.2,return:8},{name:"SPY",beta:1,weight:-.15,return:5},{name:"QQQ",beta:1.2,weight:-.1,return:6},{name:"GLD",beta:.1,weight:.1,return:2},{name:"TLT",beta:-.3,weight:.1,return:-1}],a=s.reduce((i,l)=>i+l.beta*l.weight,0),r=(t==null?void 0:t.target_beta)||0,n=Math.abs(a-r),c=[{factor:"Market",exposure:a,target:r},{factor:"Value",exposure:.12,target:0},{factor:"Momentum",exposure:.35,target:.2},{factor:"Size",exposure:-.08,target:0},{factor:"Volatility",exposure:.22,target:0}],d=[{sector:"Crypto",long:.55,short:0,net:.55},{sector:"Equity",long:.15,short:.25,net:-.1},{sector:"Commodity",long:.1,short:0,net:.1},{sector:"Fixed Income",long:.1,short:0,net:.1}];return e.jsxs(q,{className:"bg-card/50 border-border/50",children:[e.jsx(X,{className:"pb-2",children:e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(ys,{className:"w-4 h-4 text-primary"}),"Beta & Factor Neutralization",(t==null?void 0:t.beta_neutral_enabled)&&e.jsx(C,{className:"bg-emerald-500/20 text-emerald-400 text-[10px]",children:"β NEUTRAL"}),(t==null?void 0:t.sector_neutral_enabled)&&e.jsx(C,{className:"bg-purple-500/20 text-purple-400 text-[10px]",children:"SECTOR â"})]})}
116),e.jsxs(H,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/30 rounded",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Portfolio Beta"}),e.jsxs("div",{className:`text-2xl font-bold ${n>.2?"text-amber-400":"text-emerald-400"}`,children:[a.toFixed(2),"β"]})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Target"}),e.jsxs("div",{className:"text-lg font-medium",children:[r.toFixed(2),"β"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Deviation"}),e.jsxs("div",{className:`text-lg font-medium ${n>.2?"text-amber-400":"text-emerald-400"}`,children:[n>0?"+":"",n.toFixed(2)]})]})]}),e.jsx("div",{className:"h-28",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(hn,{margin:{top:5,right:5,bottom:5,left:5},children:[e.jsx(de,{type:"number",dataKey:"beta",domain:[-.5,2.5],tick:{fontSize:10},tickLine:!1,axisLine:!1}),e.jsx(oe,{type:"number",dataKey:"return",domain:[-5,15],hide:!0}),e.jsx(It,{type:"number",dataKey:"weight",range:[20,200]}),e.jsx(fe,{x:r,stroke:"#22c55e",strokeDasharray:"3 3"}),e.jsx(Bt,{data:s,fill:"#06b6d4"})]})})}),(t==null?void 0:t.factor_neutral_enabled)&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs text-muted-foreground font-medium",children:"Factor Exposures"}),c.map(i=>e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:i.factor}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-16 h-1.5 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full ${i.exposure>i.target?"bg-amber-400":"bg-emerald-400"}`,style:{width:`${Math.min(Math.abs(i.exposure)*100,100)}%`}})}),e.jsxs("span",{className:Math.abs(i.exposure-i.target)>.1?"text-amber-400":"text-foreground",children:[i.exposure>0?"+":"",i.exposure.toFixed(2)]})]})]},i.factor))]}),(t==null?void 0:t.sector_neutral_enabled)&&e.jsxs("div",{className:"space-y-1 pt-2 border-t border-border/30",children:[e.jsx("div",{className:"text-xs text-muted-foreground font-medium",children:"Sector Net Exposure"}),e.jsx("div",{className:"grid grid-cols-4 gap-2",children:d.map(i=>e.jsxs("div",{className:"text-center p-1 bg-muted/20 rounded",children:[e.jsx("div",{className:"text-[10px] text-muted-foreground truncate",children:i.sector}),e.jsxs("div",{className:`text-xs font-bold ${i.net>0?"text-emerald-400":i.net<0?"text-red-400":"text-muted-foreground"}`,children:[i.net>0?"+":"",(i.net*100).toFixed(0),"%"]})]},i.sector))})]})]})]})}function Sc({agentConfig:t,liveData:s}){var m,f,b,_;const a=(t==null?void 0:t.risk_budget_pct)||1,r=((m=s==null?void 0:s.riskBudget)==null?void 0:m.usedBudget)??.72,n=a-r,c=((f=s==null?void 0:s.riskBudget)==null?void 0:f.strategyAllocations)??[{strategy:"Momentum",allocated:.3,used:.25,color:"#06b6d4"},{strategy:"Mean Rev",allocated:.25,used:.22,color:"#8b5cf6"},{strategy:"Trend",allocated:.25,used:.18,color:"#22c55e"},{strategy:"Vol",allocated:.2,used:.07,color:"#f59e0b"}],d=((b=s==null?void 0:s.riskBudget)==null?void 0:b.drawdownHistory)??Array.from({length:30},(y,N)=>({day:N,drawdown:Math.random()*.08-.02})),i=(s==null?void 0:s.currentDrawdown)??-.045,l=(t==null?void 0:t.drawdown_reduction_threshold)||.1,o=Math.abs(i)>l*.7,u=Math.abs(i)>l,v=((_=s==null?void 0:s.riskBudget)==null?void 0:_.scaleFactor)??(t!=null&&t.dynamic_risk_scaling?(t.risk_scale_factor||1)*(u?.5:o?.75:1):1),h=!!s;return e.jsxs(q,{className:"bg-card/50 border-border/50",children:[e.jsx(X,{className:"pb-2",children:e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(Ur,{className:"w-4 h-4 text-primary"}),"Risk Budgeting",(t==null?void 0:t.dynamic_risk_scaling)&&e.jsx(C,{className:"bg-purple-500/20 text-purple-400 text-[10px]",children:"DYNAMIC"}),u&&e.jsxs(C,{className:"bg-red-500/20 text-red-400 text-[10px]",children:[e.jsx(Re,{className:"w-3 h-3 mr-1"}),"DD BREACH"]}),h&&e.jsxs(C,{className:"bg-emerald-500/20 text-emerald-400 text-[10px]",children:[e.jsx(Me,{className:"w-3 h-3 mr-1 animate-spin"}),"LIVE"]})]})}
116),e.jsxs(H,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-24 h-24",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsx(Ys,{children:e.jsxs(Qs,{data:[{name:"Used",value:r},{name:"Remaining",value:Math.max(0,n)}],dataKey:"value",cx:"50%",cy:"50%",innerRadius:25,outerRadius:40,startAngle:90,endAngle:-270,children:[e.jsx(rt,{fill:"#06b6d4"}),e.jsx(rt,{fill:"#1e293b"})]})})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Risk Budget Used"}),e.jsxs("div",{className:"text-2xl font-bold text-primary",children:[(r*100).toFixed(0),"%"]}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[(Math.max(0,n)*100).toFixed(0),"% remaining of ",(a*100).toFixed(0),"% total"]}),(t==null?void 0:t.dynamic_risk_scaling)&&e.jsxs("div",{className:`text-xs mt-1 ${v<1?"text-amber-400":"text-purple-400"}`,children:["Scale Factor: ",v.toFixed(2),"x"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs text-muted-foreground font-medium",children:"Strategy Risk Allocation"}),c.map(y=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{children:y.strategy}),e.jsxs("span",{className:y.used>y.allocated?"text-amber-400":"text-muted-foreground",children:[(y.used*100).toFixed(0),"% / ",(y.allocated*100).toFixed(0),"%"]})]}),e.jsxs("div",{className:"h-1.5 bg-muted rounded-full overflow-hidden relative",children:[e.jsx("div",{className:"h-full opacity-30 absolute",style:{width:`${y.allocated*100}%`,backgroundColor:y.color}}),e.jsx("div",{className:"h-full absolute",style:{width:`${y.used*100}%`,backgroundColor:y.color}})]})]},y.strategy))]}),(t==null?void 0:t.drawdown_risk_reduction)&&e.jsxs("div",{className:"pt-2 border-t border-border/30",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs mb-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Drawdown Risk Reduction"}),e.jsxs("span",{className:u?"text-red-400":o?"text-amber-400":"text-emerald-400",children:[(i*100).toFixed(2),"% (Limit: -",(l*100).toFixed(0),"%)"]})]}),e.jsx("div",{className:"h-16",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(ot,{data:d,children:[e.jsx(de,{dataKey:"day",hide:!0}),e.jsx(oe,{domain:[-.15,.05],hide:!0}),e.jsx(fe,{y:-l,stroke:"#ef4444",strokeDasharray:"3 3"}),e.jsx(fe,{y:-l*.7,stroke:"#f59e0b",strokeDasharray:"2 2"}),e.jsx(fe,{y:0,stroke:"#64748b"}),e.jsx(Ye,{dataKey:"drawdown",fill:"#06b6d4",radius:1})]})})})]})]})]})}function Mc({agentConfig:t,liveData:s}){var h,m,f,b,_,y,N;const a=(t==null?void 0:t.cusum_threshold)||2,r=(t==null?void 0:t.hmm_states)||3,n=((h=s==null?void 0:s.regime)==null?void 0:h.cusumHistory)??Array.from({length:100},(w,g)=>{let k=0;return g>60&&g<75&&(k=(g-60)*.15),g>=75&&(k=Math.max(0,2.25-(g-75)*.1)),{time:g,cusum:k+(Math.random()-.5)*.3}}),c=((m=s==null?void 0:s.regime)==null?void 0:m.cusumValue)??((f=n[n.length-1])==null?void 0:f.cusum)??0,d=((b=s==null?void 0:s.regime)==null?void 0:b.isBreakDetected)??Math.abs(c)>a*.8,i=((_=s==null?void 0:s.regime)==null?void 0:_.isBreakConfirmed)??Math.abs(c)>a,l=((y=s==null?void 0:s.regime)==null?void 0:y.regimeProbabilities)??[{regime:"Bull",probability:.65,color:"#22c55e"},{regime:"Bear",probability:.15,color:"#ef4444"},{regime:"Sideways",probability:.2,color:"#f59e0b"}],o=((N=s==null?void 0:s.regime)==null?void 0:N.currentRegime)??"sideways",u=[{date:new Date(Date.now()-30*24*60*60*1e3).toISOString().split("T")[0],type:"CUSUM",direction:o==="bull"?"UP":"DOWN",magnitude:2.4,resolved:!0},{date:new Date(Date.now()-14*24*60*60*1e3).toISOString().split("T")[0],type:"Chow",direction:"DOWN",magnitude:1.8,resolved:!0},{date:new Date().toISOString().split("T")[0],type:"CUSUM",direction:c>0?"UP":"DOWN",magnitude:Math.abs(c),resolved:!d}],v=!!s;return e.jsxs(q,{className:"bg-card/50 border-border/50",children:[e.jsx(X,{className:"pb-2",children:e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(hi,{className:"w-4 h-4 text-primary"}),"Regime Break Detection",i?e.jsxs(C,{className:"bg-red-500/20 text-red-400 text-[10px]",children:[e.jsx(Os,{className:"w-3 h-3 mr-1"}),"BREAK DETECTED"]}):d?e.jsx(C,{className:"bg-amber-500/20 text-amber-400 text-[10px]",children:"WARNING"}):e.jsx(C,{className:"bg-emerald-500/20 text-emerald-400 text-[10px]",children:"STABLE"}),v&&e.jsxs(C,{className:"bg-cyan-500/20 text-cyan-400 text-[10px]",children:[e.jsx(Me,{className:"w-3 h-3 mr-1 animate-spin"}),"LIVE"]})]})}
116),e.jsxs(H,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"CUSUM Statistic"}),e.jsxs("span",{className:i?"text-red-400":d?"text-amber-400":"text-foreground",children:[c.toFixed(3)," (±",a,")"]})]}),e.jsx("div",{className:"h-24",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(Ot,{data:n,children:[e.jsx(de,{dataKey:"time",hide:!0}),e.jsx(oe,{domain:[-3,3],hide:!0}),e.jsx(fe,{y:a,stroke:"#ef4444",strokeDasharray:"3 3"}),e.jsx(fe,{y:-a,stroke:"#ef4444",strokeDasharray:"3 3"}),e.jsx(fe,{y:a*.8,stroke:"#f59e0b",strokeDasharray:"2 2"}),e.jsx(fe,{y:-a*.8,stroke:"#f59e0b",strokeDasharray:"2 2"}),e.jsx(fe,{y:0,stroke:"#64748b"}),e.jsx(We,{type:"monotone",dataKey:"cusum",stroke:"#06b6d4",fill:"#06b6d4",fillOpacity:.1,strokeWidth:1.5})]})})})]}),(t==null?void 0:t.use_regime_switching)&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-xs text-muted-foreground font-medium",children:["HMM Regime Probabilities (",r," states)"]}),e.jsx("div",{className:"flex gap-2",children:l.slice(0,r).map(w=>e.jsxs("div",{className:"flex-1 p-2 rounded text-center",style:{backgroundColor:`${w.color}20`},children:[e.jsx("div",{className:"text-[10px] text-muted-foreground",children:w.regime}),e.jsxs("div",{className:"text-lg font-bold",style:{color:w.color},children:[(w.probability*100).toFixed(0),"%"]})]},w.regime))})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs text-muted-foreground font-medium",children:"Recent Break Events"}),u.slice(0,3).map((w,g)=>e.jsxs("div",{className:"flex items-center justify-between p-1.5 bg-muted/20 rounded text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:w.date}),e.jsx(C,{variant:"outline",className:"text-[10px]",children:w.type}),w.direction==="UP"?e.jsx(he,{className:"w-3 h-3 text-emerald-400"}):e.jsx(ke,{className:"w-3 h-3 text-red-400"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{children:[w.magnitude.toFixed(1),"Ï"]}),w.resolved?e.jsx(C,{className:"bg-emerald-500/20 text-emerald-400 text-[10px]",children:"RESOLVED"}):e.jsx(C,{className:"bg-amber-500/20 text-amber-400 text-[10px]",children:"ACTIVE"})]})]},g))]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-[10px] text-muted-foreground pt-2 border-t border-border/30",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"font-medium text-foreground",children:["±",a]}),e.jsx("div",{children:"CUSUM Thresh"})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"font-medium text-foreground",children:[(t==null?void 0:t.structural_break_lookback)||100,"d"]}),e.jsx("div",{children:"Lookback"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:`font-medium ${t!=null&&t.auto_pause_on_regime_break?"text-emerald-400":"text-muted-foreground"}`,children:t!=null&&t.auto_pause_on_regime_break?"ON":"OFF"}),e.jsx("div",{children:"Auto Pause"})]})]})]})]})}function Ac({agentConfig:t,liveData:s}){const a=(t==null?void 0:t.ensemble_voting_enabled)||!1,r=(t==null?void 0:t.ml_confidence_weight)||.5,n=(t==null?void 0:t.feature_importance_threshold)||.1,c=(s==null?void 0:s.mlSignals)||[{name:"XGBoost",signal:"BUY",confidence:.78,weight:.3,vote:1},{name:"LSTM",signal:"BUY",confidence:.65,weight:.25,vote:1},{name:"Random Forest",signal:"HOLD",confidence:.52,weight:.2,vote:0},{name:"GRU",signal:"BUY",confidence:.71,weight:.15,vote:1},{name:"Transformer",signal:"SELL",confidence:.58,weight:.1,vote:-1}],d=(s==null?void 0:s.ensembleSignal)??c.reduce((v,h)=>v+h.vote*h.weight,0),i=(s==null?void 0:s.ensembleConfidence)??c.reduce((v,h)=>v+h.confidence*h.weight,0),l=((s==null?void 0:s.featureImportance)||[{feature:"RSI_14",importance:.18,value:55},{feature:"MACD_Signal",importance:.15,value:.5},{feature:"BB_Width",importance:.12,value:1.2},{feature:"Volume_MA",importance:.11,value:1.1},{feature:"ATR_14",importance:.09,value:150},{feature:"Price_MA_50",importance:.08,value:62e3},{feature:"Sentiment",importance:.07,value:60},{feature:"Funding_Rate",importance:.05,value:.01}]).filter(v=>v.importance>=n).map((v,h)=>({...v,selected:h<4})),o=v=>v==="BUY"?e.jsx(C,{className:"bg-emerald-500/20 text-emerald-400",children:"BUY"}):v==="SELL"?e.jsx(C,{className:"bg-red-500/20 text-red-400",children:"SELL"}):e.jsx(C,{variant:"outline",children:"HOLD"}),u=!!s;return e.jsxs(q,{className:"bg-card/50 border-border/50",children:[e.jsx(X,{className:"pb-2",children:e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(lt,{className:"w-4 h-4 text-primary"}),"ML Ensemble & Feature Engineering",a&&e.jsx(C,{className:"bg-purple-500/20 text-purple-400 text-[10px]",children:"ENSEMBLE"}),u&&e.jsxs(C,{className:"bg-emerald-500/20 text-emerald-400 text-[10px]",children:[e.jsx(Me,{className:"w-3 h-3 mr-1 animate-spin"}),"LIVE"]})]})}
116),e.jsxs(H,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/30 rounded",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Ensemble Signal"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-2xl font-bold ${d>.2?"text-emerald-400":d<-.2?"text-red-400":"text-amber-400"}`,children:d>.2?"BUY":d<-.2?"SELL":"HOLD"}),e.jsxs(C,{variant:"outline",children:[(d*100).toFixed(0),"%"]})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Confidence"}),e.jsxs("div",{className:"text-xl font-bold text-primary",children:[(i*100).toFixed(1),"%"]})]})]}),a&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-xs text-muted-foreground font-medium",children:["Model Voting (",c.length," models)"]}),c.map(v=>e.jsxs("div",{className:"flex items-center justify-between p-1.5 bg-muted/20 rounded text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium w-24 truncate",children:v.name}),e.jsxs(C,{variant:"outline",className:"text-[10px]",children:[(v.weight*100).toFixed(0),"% wt"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-muted-foreground",children:[(v.confidence*100).toFixed(0),"%"]}),o(v.signal),v.vote>0?e.jsx(it,{className:"w-3 h-3 text-emerald-400"}):v.vote<0?e.jsx(Dn,{className:"w-3 h-3 text-red-400"}):e.jsx("div",{className:"w-3 h-3 rounded-full bg-amber-400/50"})]})]},v.name))]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-muted-foreground font-medium",children:["Top Features (â¥",(n*100).toFixed(0),"%)"]}),e.jsxs("span",{className:"text-muted-foreground",children:["ML Weight: ",(r*100).toFixed(0),"%"]})]}),e.jsx("div",{className:"h-24",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(ot,{data:l.slice(0,6),layout:"vertical",children:[e.jsx(de,{type:"number",domain:[0,.25],hide:!0}),e.jsx(oe,{type:"category",dataKey:"feature",tick:{fontSize:9},width:70,tickLine:!1,axisLine:!1}),e.jsx(Ye,{dataKey:"importance",radius:2,children:l.slice(0,6).map((v,h)=>e.jsx(rt,{fill:h<4?"#06b6d4":"#475569"},`cell-${h}`))})]})})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-[10px] text-muted-foreground pt-2 border-t border-border/30",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"font-medium text-foreground",children:[(r*100).toFixed(0),"%"]}),e.jsx("div",{children:"ML Weight"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:`font-medium ${a?"text-emerald-400":"text-muted-foreground"}`,children:a?"ON":"OFF"}),e.jsx("div",{children:"Ensemble"})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"font-medium text-foreground",children:[(n*100).toFixed(0),"%"]}),e.jsx("div",{children:"FI Threshold"})]})]})]})]})}function Cc({agentConfig:t}){const s=[{metric:"Information Ratio",abbrev:"IR",current:1.24,target:(t==null?void 0:t.target_information_ratio)||1,description:"Active return / Tracking error"},{metric:"Treynor Ratio",abbrev:"TR",current:.12,target:(t==null?void 0:t.target_treynor_ratio)||.1,description:"Excess return / Beta"},{metric:"Omega Ratio",abbrev:"Ω",current:1.68,target:(t==null?void 0:t.target_omega_ratio)||1.5,description:"Gain/Loss probability weighted"},{metric:"Profit Factor",abbrev:"PF",current:1.82,target:(t==null?void 0:t.min_profit_factor)||1.5,description:"Gross profit / Gross loss"},{metric:"Win Rate",abbrev:"WR",current:.58,target:(t==null?void 0:t.min_win_rate)||.45,description:"Winning trades / Total trades"}],a=s.map(n=>({metric:n.abbrev,current:Math.min(n.current/n.target*100,150),target:100})),r=s.every(n=>n.current>=n.target);return e.jsxs(q,{className:"bg-card/50 border-border/50",children:[e.jsx(X,{className:"pb-2",children:e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(Aa,{className:"w-4 h-4 text-primary"}),"Advanced Performance Metrics",r?e.jsx(C,{className:"bg-emerald-500/20 text-emerald-400 text-[10px]",children:"ALL TARGETS MET"}):e.jsx(C,{className:"bg-amber-500/20 text-amber-400 text-[10px]",children:"BELOW TARGET"})]})}
116),e.jsxs(H,{className:"space-y-4",children:[e.jsx("div",{className:"h-40",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(jl,{data:a,children:[e.jsx(nn,{stroke:"#334155"}),e.jsx(qr,{dataKey:"metric",tick:{fontSize:10,fill:"#94a3b8"}}),e.jsx(Hr,{domain:[0,150],tick:{fontSize:8},axisLine:!1}),e.jsx(es,{name:"Target",dataKey:"target",stroke:"#64748b",fill:"#64748b",fillOpacity:.1,strokeDasharray:"3 3"}),e.jsx(es,{name:"Current",dataKey:"current",stroke:"#06b6d4",fill:"#06b6d4",fillOpacity:.3})]})})}),e.jsx("div",{className:"space-y-2",children:s.map(n=>{const c=n.current/n.target*100,d=n.current>=n.target;return e.jsxs("div",{className:"flex items-center justify-between p-2 bg-muted/20 rounded",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-medium",children:n.metric}),d?e.jsx(C,{className:"bg-emerald-500/20 text-emerald-400 text-[10px]",children:"â"}):e.jsx(C,{className:"bg-amber-500/20 text-amber-400 text-[10px]",children:"!"})]}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:n.description})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:`text-sm font-bold ${d?"text-emerald-400":"text-amber-400"}`,children:n.metric==="Win Rate"?`${(n.current*100).toFixed(0)}%`:n.current.toFixed(2)}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:["Target: ",n.metric==="Win Rate"?`${(n.target*100).toFixed(0)}%`:n.target.toFixed(2)]})]}),e.jsxs("div",{className:"w-16 ml-3",children:[e.jsx("div",{className:"h-1.5 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full ${d?"bg-emerald-400":"bg-amber-400"}`,style:{width:`${Math.min(c,100)}%`}})}),e.jsxs("div",{className:"text-[9px] text-muted-foreground text-center mt-0.5",children:[c.toFixed(0),"%"]})]})]},n.metric)})})]})]})}function Tc({ticker:t,results:s,isLoading:a}){if(a)return e.jsxs(q,{className:"border-primary/20",children:[e.jsx(X,{className:"pb-3",children:e.jsxs(Y,{className:"flex items-center gap-2 text-lg",children:[e.jsx(ge,{className:"h-5 w-5 text-primary animate-pulse"}),"Running Backtest for ",t,"..."]})}),e.jsx(H,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"h-32 bg-muted-foreground/10 rounded-lg animate-pulse"}),e.jsx("div",{className:"grid grid-cols-4 gap-2",children:[1,2,3,4].map(n=>e.jsx("div",{className:"h-16 bg-muted-foreground/10 rounded-lg animate-pulse"},n))})]})})]});if(!s)return null;const r=s.total_return>0;return e.jsxs(q,{className:O("border-2",r?"border-emerald-500/30 bg-emerald-500/5":"border-rose-500/30 bg-rose-500/5"),children:[e.jsx(X,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Y,{className:"flex items-center gap-2 text-lg",children:[e.jsx(gt,{className:"h-5 w-5 text-primary"}),"Backtest Preview: ",t]}),e.jsxs(C,{variant:"outline",className:O(r?"border-emerald-500/50 text-emerald-500":"border-rose-500/50 text-rose-500"),children:[e.jsx(Zt,{className:"h-3 w-3 mr-1"}),"12 Month Simulation"]})]})}
116),e.jsxs(H,{className:"space-y-4",children:[e.jsx("div",{className:"h-44 w-full",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(Js,{data:s.equity_curve.map((n,c,d)=>{const i=Math.max(...d.slice(0,c+1).map(o=>o.equity)),l=(n.equity-i)/i*100;return{...n,drawdown:l,peak:i}}),children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"equityGradientEnhanced",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:r?"#10b981":"#f43f5e",stopOpacity:.4}),e.jsx("stop",{offset:"95%",stopColor:r?"#10b981":"#f43f5e",stopOpacity:0})]}),e.jsxs("linearGradient",{id:"drawdownGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#f43f5e",stopOpacity:.3}),e.jsx("stop",{offset:"95%",stopColor:"#f43f5e",stopOpacity:0})]})]}),e.jsx(de,{dataKey:"day",tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"},tickLine:!1,axisLine:!1,tickFormatter:n=>`D${n}`,interval:Math.floor(s.equity_curve.length/5)}),e.jsx(oe,{yAxisId:"equity",domain:["dataMin - 5","dataMax + 5"],tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"},tickLine:!1,axisLine:!1,tickFormatter:n=>`$${(n/1e3).toFixed(0)}k`,width:40}),e.jsx(oe,{yAxisId:"drawdown",orientation:"right",domain:["dataMin - 5",0],tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"},tickLine:!1,axisLine:!1,tickFormatter:n=>`${n.toFixed(0)}%`,width:35}),e.jsx(Ne,{contentStyle:{backgroundColor:"hsl(var(--background))",border:"1px solid hsl(var(--border))",borderRadius:"8px",fontSize:"11px"},formatter:(n,c)=>c==="equity"?[`$${n.toFixed(2)}`,"Equity"]:c==="drawdown"?[`${n.toFixed(2)}%`,"Drawdown"]:[n,c]}),e.jsx(fe,{yAxisId:"equity",y:1e4,stroke:"hsl(var(--muted-foreground))",strokeDasharray:"3 3",strokeOpacity:.5}),e.jsx(We,{yAxisId:"drawdown",type:"monotone",dataKey:"drawdown",fill:"url(#drawdownGradient)",stroke:"#f43f5e",strokeWidth:1,strokeOpacity:.5}),e.jsx(We,{yAxisId:"equity",type:"monotone",dataKey:"equity",stroke:r?"#10b981":"#f43f5e",fill:"url(#equityGradientEnhanced)",strokeWidth:2}),e.jsx(Fe,{yAxisId:"equity",type:"monotone",dataKey:"peak",stroke:"#3b82f6",strokeWidth:1,strokeDasharray:"3 3",dot:!1,strokeOpacity:.5})]})})}),e.jsxs("div",{className:"flex justify-center gap-4 text-[10px] text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-3 h-0.5 bg-emerald-500 rounded"}),e.jsx("span",{children:"Equity"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-3 h-0.5 bg-blue-500 rounded border-dashed",style:{borderStyle:"dashed"}}),e.jsx("span",{children:"Peak"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-3 h-3 bg-red-500/30 rounded"}),e.jsx("span",{children:"Drawdown"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:[e.jsx(ks,{label:"Total Return",value:`${s.total_return>0?"+":""}${s.total_return.toFixed(1)}%`,icon:r?he:ke,positive:r}),e.jsx(ks,{label:"Sharpe Ratio",value:s.sharpe_ratio.toFixed(2),icon:Be,positive:s.sharpe_ratio>1}
116),e.jsx(ks,{label:"Max Drawdown",value:`-${s.max_drawdown.toFixed(1)}%`,icon:Re,positive:s.max_drawdown<15}),e.jsx(ks,{label:"Win Rate",value:`${s.win_rate.toFixed(0)}%`,icon:Gt,positive:s.win_rate>50})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-2 text-xs",children:[e.jsxs("div",{className:"p-2 rounded bg-background/50 border border-muted-foreground/10",children:[e.jsx("div",{className:"text-muted-foreground",children:"Trades"}),e.jsx("div",{className:"font-bold",children:s.total_trades})]}),e.jsxs("div",{className:"p-2 rounded bg-background/50 border border-muted-foreground/10",children:[e.jsx("div",{className:"text-muted-foreground",children:"Profit Factor"}),e.jsx("div",{className:"font-bold",children:s.profit_factor.toFixed(2)})]}),e.jsxs("div",{className:"p-2 rounded bg-background/50 border border-muted-foreground/10",children:[e.jsx("div",{className:"text-muted-foreground",children:"Avg Trade"}),e.jsxs("div",{className:"font-bold",children:[s.avg_trade_return>0?"+":"",s.avg_trade_return.toFixed(2),"%"]})]}),e.jsxs("div",{className:"p-2 rounded bg-background/50 border border-muted-foreground/10",children:[e.jsx("div",{className:"text-muted-foreground",children:"Volatility"}),e.jsxs("div",{className:"font-bold",children:[s.volatility.toFixed(1),"%"]})]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground/60 text-center",children:"Simulated results based on historical data. Past performance does not guarantee future results."})]})]})}function ks({label:t,value:s,icon:a,positive:r}){return e.jsxs("div",{className:O("p-3 rounded-lg border",r?"border-emerald-500/30 bg-emerald-500/10":"border-rose-500/30 bg-rose-500/10"),children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground mb-1",children:[e.jsx(a,{className:O("h-3 w-3",r?"text-emerald-500":"text-rose-500")}),t]}),e.jsx("div",{className:O("font-bold text-lg",r?"text-emerald-500":"text-rose-500"),children:s})]})}const Rc={reddit:{reliability:72,updateFrequency:"hourly",latencyTolerance:60},google_trends:{reliability:85,updateFrequency:"daily",latencyTolerance:1440},news_sentiment:{reliability:78,updateFrequency:"hourly",latencyTolerance:30},social_volume:{reliability:68,updateFrequency:"hourly",latencyTolerance:60},market_data:{reliability:95,updateFrequency:"realtime",latencyTolerance:5},fear_greed:{reliability:82,updateFrequency:"daily",latencyTolerance:1440},onchain_metrics:{reliability:90,updateFrequency:"hourly",latencyTolerance:60},exchange_flows:{reliability:88,updateFrequency:"hourly",latencyTolerance:30},funding_rates:{reliability:92,updateFrequency:"realtime",latencyTolerance:5},open_interest:{reliability:91,updateFrequency:"realtime",latencyTolerance:5},github_activity:{reliability:75,updateFrequency:"daily",latencyTolerance:1440},whale_alerts:{reliability:86,updateFrequency:"realtime",latencyTolerance:15},sec_filings:{reliability:98,updateFrequency:"weekly",latencyTolerance:10080},options_flow:{reliability:84,updateFrequency:"hourly",latencyTolerance:30},alpha_vantage:{reliability:94,updateFrequency:"realtime",latencyTolerance:5},polygon:{reliability:96,updateFrequency:"realtime",latencyTolerance:1},glassnode:{reliability:93,updateFrequency:"hourly",latencyTolerance:60},santiment:{reliability:89,updateFrequency:"hourly",latencyTolerance:60},messari:{reliability:87,updateFrequency:"daily",latencyTolerance:1440},tradingview:{reliability:92,updateFrequency:"realtime",latencyTolerance:5}},Pc=(t,s)=>{if(!t)return 0;const a=new Date,r=new Date(t),n=(a.getTime()-r.getTime())/(1e3*60);return n<=s.latencyTolerance*.5?100:n<=s.latencyTolerance?85:n<=s.latencyTolerance*2?60:n<=s.latencyTolerance*4?35:10},oa=(t,s)=>{const a=Rc[t]||{reliability:70,updateFrequency:"daily",latencyTolerance:1440},r=Pc(s,a),n=a.reliability,c=Math.round(r*.4+n*.6);let d="F";return c>=90?d="A":c>=80?d="B":c>=70?d="C":c>=60&&(d="D"),{score:c,freshness:r,reliability:n,grade:d}},Ct=t=>t>=90?"text-emerald-500":t>=75?"text-cyan-500":t>=60?"text-amber-500":"text-rose-500",Fc=[{id:"crypto_deep_dive",name:"Crypto Deep Dive",description:"All crypto-specific metrics and on-chain data",icon:ci,sources:["fear_greed","onchain_metrics","exchange_flows","funding_rates","open_interest","whale_alerts","github_activity"],color:"amber"},{id:"stock_fundamentals",name:"Stock Fundamentals",description:"SEC filings, options flow, and institutional data",icon:Ln,sources:["sec_f
116ilings","options_flow","market_data","news_sentiment"],color:"blue"},{id:"social_sentiment",name:"Social Sentiment",description:"Social media, news, and community discussions",icon:us,sources:["reddit","social_volume","news_sentiment","google_trends"],color:"violet"},{id:"technical_analysis",name:"Technical Analysis",description:"Market data with premium technical indicators",icon:gt,sources:["market_data","alpha_vantage","polygon","tradingview"],color:"emerald"},{id:"on_chain_pro",name:"On-Chain Pro",description:"Premium on-chain analytics and blockchain intelligence",icon:Lt,sources:["onchain_metrics","exchange_flows","whale_alerts","glassnode","santiment"],color:"cyan"},{id:"full_spectrum",name:"Full Spectrum",description:"Enable all available data sources",icon:_t,sources:["all"],color:"rose"}];function Dc({ticker:t,trend:s,onDataFetched:a}){var A,B,z,U,G,K,$,L,D,F,R,Q,x;const[r,n]=j.useState([{id:"reddit",name:"Reddit",icon:Fs,description:"Subreddit discussions, sentiment, and mention frequency",status:"connected",enabled:!0},{id:"google_trends",name:"Google Trends",icon:he,description:"Search interest over time and related queries",status:"connected",enabled:!0},{id:"news_sentiment",name:"News Sentiment",icon:ua,description:"Financial news headlines and sentiment scoring",status:"connected",enabled:!0},{id:"social_volume",name:"Social Volume",icon:Kr,description:"Social media mention volume and engagement",status:"connected",enabled:!1},{id:"market_data",name:"Market Data",icon:ge,description:"Real-time price, volume, and volatility",status:"connected",enabled:!0},{id:"fear_greed",name:"Fear & Greed",icon:ge,description:"Crypto Fear & Greed Index from alternative.me",status:"connected",enabled:!1},{id:"onchain_metrics",name:"On-Chain Metrics",icon:Lt,description:"Active addresses, transaction volume, whale movements",status:"connected",enabled:!1},{id:"exchange_flows",name:"Exchange Flows",icon:ge,description:"Inflows/outflows to exchanges, net position changes",status:"connected",enabled:!1},{id:"funding_rates",name:"Funding Rates",icon:he,description:"Perpetual futures funding rates across exchanges",status:"connected",enabled:!1},{id:"open_interest",name:"Open Interest",icon:ge,description:"Futures and options open interest aggregated",status:"connected",enabled:!1},{id:"github_activity",name:"GitHub Activity",icon:Lt,description:"Repository commits, stars, contributors for crypto projects",status:"connected",enabled:!1},{id:"whale_alerts",name:"Whale Alerts",icon:ge,description:"Large transaction alerts and whale wallet tracking",status:"connected",enabled:!1},{id:"sec_filings",name:"SEC Filings",icon:ua,description:"SEC EDGAR filings, 13F, insider transactions",status:"connected",enabled:!1},{id:"options_flow",name:"Options Flow",icon:he,description:"Unusual options activity and dark pool prints",status:"connected",enabled:!1},{id:"alpha_vantage",name:"Alpha Vantage",icon:at,description:"Premium intraday data, Bollinger Bands, Stochastic, VWAP, ATR",status:"premium",enabled:!1,isPremium:!0},{id:"polygon",name:"Polygon.io",icon:at,description:"Real-time & historical market data, news, options",status:"premium",enabled:!1,isPremium:!0},{id:"glassnode",name:"Glassnode",icon:at,description:"Advanced on-chain analytics and market intelligence",status:"premium",enabled:!1,isPremium:!0},{id:"santiment",name:"Santiment",icon:at,description:"On-chain, social, and development activity metrics",status:"premium",enabled:!1,isPremium:!0},{id:"messari",name:"Messari",icon:at,description:"Crypto research, metrics, and protocol analysis",status:"premium",enabled:!1,isPremium:!0},{id:"tradingview",name:"TradingView",icon:at,description:"Technical analysis indicators and chart patterns",status:"premium",enabled:!1,isPremium:!0}]),[c,d]=j.useState(!1),[i,l]=j.useState(null),[o,u]=j.useState(""),[v,h]=j.useState(!1),m=S=>{const E=r.find(te=>te.id===S);if(E!=null&&E.isPremium&&!o&&!E.enabled){xe({title:"API Key Required",description:"Enter your Alpha Vantage API key to enable premium data",variant:"destructive"});return}n(te=>te.map(Z=>Z.id===S?{...Z,enabled:!Z.enabled}:Z))},f=async()=>
116{if(!t||!s){xe({title:"Error",description:"Please analyze a theory first",variant:"destructive"});return}d(!0);try{const S=r.filter(Z=>Z.enabled).map(Z=>Z.id),{data:E,error:te}=await ue.functions.invoke("fetch-data-sources",{body:{ticker:t,trend:s,sources:S,alphaVantageKey:o||void 0}});if(te)throw te;l(E),n(Z=>Z.map(I=>{var V,J;return{...I,lastFetch:I.enabled?new Date().toISOString():I.lastFetch,dataPoints:((J=(V=E==null?void 0:E.sources)==null?void 0:V[I.id])==null?void 0:J.dataPoints)||I.dataPoints}})),a==null||a(E),xe({title:"Data Fetched",description:`Retrieved data from ${S.length} sources`})}catch(S){console.error("Error fetching data:",S),xe({title:"Fetch Failed",description:S instanceof Error?S.message:"Failed to fetch data",variant:"destructive"})}finally{d(!1)}},[b,_]=j.useState(null),[y,N]=j.useState(!0),w=r.filter(S=>S.enabled).length,g=(A=r.find(S=>S.id==="alpha_vantage"))==null?void 0:A.enabled,k=j.useMemo(()=>{const S=r.filter(I=>I.enabled);if(S.length===0)return{score:0,grade:"N/A"};const E=S.reduce((I,V)=>{const J=oa(V.id,V.lastFetch);return I+J.score},0),te=Math.round(E/S.length);let Z="F";return te>=90?Z="A":te>=80?Z="B":te>=70?Z="C":te>=60&&(Z="D"),{score:te,grade:Z}},[r]),M=S=>{S.sources.includes("all")?(n(E=>E.map(te=>({...te,enabled:!0}))),_(S.id),xe({title:"Full Spectrum Enabled",description:`All ${r.length} data sources activated`})):(n(E=>E.map(te=>({...te,enabled:S.sources.includes(te.id)}))),_(S.id),xe({title:`${S.name} Applied`,description:`Enabled ${S.sources.length} data sources`}))},T=()=>{n(S=>S.map(E=>({...E,enabled:!1}))),_(null),xe({title:"All Sources Disabled"})};return e.jsxs(q,{className:"border-primary/20",children:[e.jsx(X,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Y,{className:"flex items-center gap-2 text-lg",children:[e.jsx(Lt,{className:"h-5 w-5 text-primary"}),"Live Data Sources"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[g&&e.jsxs(C,{className:"bg-amber-500/20 text-amber-500 border-amber-500/30",children:[e.jsx(at,{className:"h-3 w-3 mr-1"}),"Premium"]}),e.jsxs(C,{variant:"outline",className:"border-primary/50",children:[w," Active"]})]})]})}
116),e.jsxs(H,{className:"space-y-4",children:[w>0&&e.jsxs("div",{className:"p-3 rounded-lg border border-primary/20 bg-primary/5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium",children:"Data Quality Score"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(C,{variant:"outline",className:O("font-bold",Ct(k.score),k.score>=90?"border-emerald-500/50":k.score>=75?"border-cyan-500/50":k.score>=60?"border-amber-500/50":"border-rose-500/50"),children:["Grade ",k.grade]}),e.jsxs(W,{variant:"ghost",size:"sm",onClick:()=>N(!y),className:"h-6 px-2 text-[10px]",children:[y?"Hide":"Show"," Details"]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Xe,{value:k.score,className:O("flex-1 h-2",k.score>=90?"[&>div]:bg-emerald-500":k.score>=75?"[&>div]:bg-cyan-500":k.score>=60?"[&>div]:bg-amber-500":"[&>div]:bg-rose-500")}),e.jsxs("span",{className:O("text-sm font-bold min-w-[40px]",Ct(k.score)),children:[k.score,"%"]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 mt-3 text-[10px]",children:[e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(gi,{className:"h-3 w-3"}),e.jsx("span",{children:"Reliability-weighted"})]}),e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(dt,{className:"h-3 w-3"}),e.jsx("span",{children:"Freshness-adjusted"})]}),e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(ge,{className:"h-3 w-3"}),e.jsxs("span",{children:[w," sources"]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider flex items-center gap-2",children:[e.jsx(St,{className:"h-3 w-3 text-primary"}),"Quick Presets"]}),b&&e.jsx(W,{variant:"ghost",size:"sm",onClick:T,className:"h-5 px-2 text-[10px] text-muted-foreground hover:text-foreground",children:"Clear All"})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:Fc.map(S=>{const E=b===S.id,te={amber:{bg:"bg-amber-500/10",border:"border-amber-500/30",text:"text-amber-500",activeBg:"bg-amber-500/20"},blue:{bg:"bg-blue-500/10",border:"border-blue-500/30",text:"text-blue-500",activeBg:"bg-blue-500/20"},violet:{bg:"bg-violet-500/10",border:"border-violet-500/30",text:"text-violet-500",activeBg:"bg-violet-500/20"},emerald:{bg:"bg-emerald-500/10",border:"border-emerald-500/30",text:"text-emerald-500",activeBg:"bg-emerald-500/20"},cyan:{bg:"bg-cyan-500/10",border:"border-cyan-500/30",text:"text-cyan-500",activeBg:"bg-cyan-500/20"},rose:{bg:"bg-rose-500/10",border:"border-rose-500/30",text:"text-rose-500",activeBg:"bg-rose-500/20"}},Z=te[S.color]||te.blue;return e.jsxs("button",{onClick:()=>M(S),className:O("flex flex-col items-start p-2.5 rounded-lg border transition-all text-left",E?`${Z.activeBg} ${Z.border} ring-1 ring-primary/50 ring-offset-1 ring-offset-background`:`${Z.bg} ${Z.border} hover:${Z.activeBg}`),children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx(S.icon,{className:O("h-3.5 w-3.5",Z.text)}),e.jsx("span",{className:O("font-medium text-[10px]",E?Z.text:"text-foreground"),children:S.name}),E&&e.jsx(it,{className:O("h-3 w-3 ml-auto",Z.text)})]}),e.jsx("p",{className:"text-[8px] text-muted-foreground line-clamp-1",children:S.description}),e.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[e.jsxs(C,{variant:"outline",className:O("text-[7px] h-3.5 px-1",Z.border,Z.text),children:[S.sources.includes("all")?r.length:S.sources.length," sources"]}),S.sources.some(I=>{var V;return(V=r.find(J=>J.id===I))==null?void 0:V.isPremium})&&e.jsxs(C,{variant:"outline",className:"text-[7px] h-3.5 px-1 border-amber-500/50 text-amber-500",children:[e.jsx(at,{className:"h-2 w-2 mr-0.5"}),"PRO"]})]})]},S.id)})})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-2 flex items-center gap-2",children:[e.jsx(pe,{className:"h-3 w-3 text-emerald-500"}),"Free Data Sources (",r.filter(S=>!S.isPremium).length,")"]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:r.filter(S=>!S.isPremium).map(S=>{const E=oa(S.id,S.lastFetch);return e.jsxs("div",{className:O("flex flex-col p-2.5 rounded-lg border transition-all",S.enabled?"border-primary/30 bg-primary/5":"border-muted-foreground
116/10 bg-muted-foreground/5"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:O("p-1.5 rounded-lg",S.enabled?"bg-primary/10":"bg-muted-foreground/10"),children:e.jsx(S.icon,{className:O("h-3.5 w-3.5",S.enabled?"text-primary":"text-muted-foreground")})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:O("font-medium text-xs",S.enabled?"text-foreground":"text-muted-foreground"),children:S.name}),S.status==="connected"&&S.enabled&&e.jsx(it,{className:"h-3 w-3 text-emerald-500"})]}),e.jsx("p",{className:"text-[9px] text-muted-foreground line-clamp-1",children:S.description})]})]}),e.jsx(ye,{checked:S.enabled,onCheckedChange:()=>m(S.id),className:"scale-75"})]}),y&&S.enabled&&e.jsx("div",{className:"mt-2 pt-2 border-t border-primary/10",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-3 text-[9px]",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Ce,{className:"h-2.5 w-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Reliability:"}),e.jsxs("span",{className:O("font-medium",Ct(E.reliability)),children:[E.reliability,"%"]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(dt,{className:"h-2.5 w-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Fresh:"}),e.jsxs("span",{className:O("font-medium",Ct(E.freshness)),children:[E.freshness,"%"]})]})]}),e.jsx(C,{variant:"outline",className:O("text-[8px] h-4 px-1.5 font-bold",Ct(E.score),E.score>=90?"border-emerald-500/50":E.score>=75?"border-cyan-500/50":E.score>=60?"border-amber-500/50":"border-rose-500/50"),children:E.grade})]})})]},S.id)})})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-2 flex items-center gap-2",children:[e.jsx(at,{className:"h-3 w-3 text-amber-500"}),"Premium Data Sources (",r.filter(S=>S.isPremium).length,")"]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:r.filter(S=>S.isPremium).map(S=>{const E=oa(S.id,S.lastFetch);return e.jsxs("div",{className:O("flex flex-col p-2.5 rounded-lg border transition-all border-amber-500/30",S.enabled?"bg-amber-500/5":"bg-muted-foreground/5"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:O("p-1.5 rounded-lg",S.enabled?"bg-amber-500/20":"bg-amber-500/10"),children:e.jsx(S.icon,{className:"h-3.5 w-3.5 text-amber-500"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:O("font-medium text-xs",S.enabled?"text-foreground":"text-muted-foreground"),children:S.name}),e.jsx(C,{variant:"outline",className:"text-[8px] h-3.5 px-1 border-amber-500/50 text-amber-500",children:"PRO"})]}),e.jsx("p",{className:"text-[9px] text-muted-foreground line-clamp-1",children:S.description})]})]}),e.jsx(ye,{checked:S.enabled,onCheckedChange:()=>m(S.id),className:O("scale-75",S.enabled&&"data-[state=checked]:bg-amber-500")})]}),y&&S.enabled&&e.jsx("div",{className:"mt-2 pt-2 border-t border-amber-500/20",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-3 text-[9px]",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Ce,{className:"h-2.5 w-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Reliability:"}),e.jsxs("span",{className:O("font-medium",Ct(E.reliability)),children:[E.reliability,"%"]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(dt,{className:"h-2.5 w-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Fresh:"}),e.jsxs("span",{className:O("font-medium",Ct(E.freshness)),children:[E.freshness,"%"]})]})]}),e.jsx(C,{variant:"outline",className:O("text-[8px] h-4 px-1.5 font-bold",Ct(E.score),E.score>=90?"border-emerald-500/50":E.score>=75?"border-cyan-500/50":E.score>=60?"border-amber-500/50":"border-rose-500/50"),children:E.grade})]})})]},S.id)})})]}),e.jsxs("div",{className:"p-3 rounded-lg border border-amber-500/30 bg-amber-500/5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Ar,{className:"h-4 w-4 text-amber-500"}),e.jsx("span",{className:"text-sm font-medium text-amber-500",children:"Alpha Vantage API Key"}),e.jsx(C,{variant:"outline",className:"text-[9px] border-amber-500/50 text-amber-500",children:"FREE TIER A
116VAILABLE"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs("div",{className:"relative flex-1",children:[e.jsx(se,{type:v?"text":"password",placeholder:"Enter your API key...",value:o,onChange:S=>u(S.target.value),className:"pr-10 text-sm border-amber-500/30 focus:border-amber-500"}),e.jsx("button",{type:"button",onClick:()=>h(!v),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:v?e.jsx(ui,{className:"h-4 w-4"}):e.jsx(ni,{className:"h-4 w-4"})})]})}),e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-2",children:["Get your free key at ",e.jsx("a",{href:"https://www.alphavantage.co/support/#api-key",target:"_blank",rel:"noopener noreferrer",className:"text-amber-500 hover:underline",children:"alphavantage.co"})," (5 calls/min, 500/day)"]})]}),e.jsx(W,{onClick:f,disabled:c||w===0,className:"w-full",variant:"outline",children:c?e.jsxs(e.Fragment,{children:[e.jsx(Pt,{className:"h-4 w-4 mr-2 animate-spin"}),"Fetching Live Data..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Me,{className:"h-4 w-4 mr-2"}),"Fetch Live Data (",w," sources)"]})}),i&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-xs font-medium text-muted-foreground flex items-center gap-1",children:[e.jsx(pe,{className:"h-3 w-3 text-primary"}),"Live Data Preview"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[((B=i.sources)==null?void 0:B.reddit)&&e.jsx(Ss,{label:"Reddit Sentiment",value:`${i.sources.reddit.sentiment>0?"+":""}${(i.sources.reddit.sentiment*100).toFixed(0)}%`,subtext:`${i.sources.reddit.mentions} mentions`,positive:i.sources.reddit.sentiment>0}),((z=i.sources)==null?void 0:z.google_trends)&&e.jsx(Ss,{label:"Search Interest",value:i.sources.google_trends.interest,subtext:i.sources.google_trends.trend,positive:i.sources.google_trends.trend==="rising"}),((U=i.sources)==null?void 0:U.news_sentiment)&&e.jsx(Ss,{label:"News Sentiment",value:`${i.sources.news_sentiment.score>0?"+":""}${(i.sources.news_sentiment.score*100).toFixed(0)}%`,subtext:`${i.sources.news_sentiment.articles} articles`,positive:i.sources.news_sentiment.score>0}),((G=i.sources)==null?void 0:G.market_data)&&e.jsx(Ss,{label:"Market Signal",value:(K=i.sources.market_data.signal)==null?void 0:K.toUpperCase(),subtext:`Vol: ${i.sources.market_data.volatility}%`,positive:i.sources.market_data.signal==="bullish"})]}),(($=i.sources)==null?void 0:$.market_data)&&e.jsxs("div",{className:"mt-3 p-3 rounded-lg border border-primary/20 bg-primary/5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-xs font-medium text-primary",children:"Yahoo Finance Live Data"}),i.sources.market_data.isRealData&&e.jsx(C,{variant:"outline",className:"text-[9px] border-emerald-500/50 text-emerald-500",children:"LIVE"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 mb-2",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"Price"}),e.jsxs("div",{className:"font-bold text-sm",children:["$",i.sources.market_data.price]})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"Change"}),e.jsxs("div",{className:O("font-bold text-sm",parseFloat(i.sources.market_data.change)>=0?"text-emerald-500":"text-rose-500"),children:[parseFloat(i.sources.market_data.change)>=0?"+":"",i.sources.market_data.change,"%"]})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"Vol Ratio"}),e.jsxs("div",{className:"font-bold text-sm",children:[i.sources.market_data.volumeRatio,"x"]})]})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-1 text-[10px]",children:[e.jsxs("div",{className:O("p-1.5 rounded text-center",parseFloat(i.sources.market_data.rsi)<30?"bg-emerald-500/20":parseFloat(i.sources.market_data.rsi)>70?"bg-rose-500/20":"bg-muted-foreground/10"),children:[e.jsx("div",{className:"text-muted-foreground",children:"RSI"}),e.jsx("div",{className:"font-bold",children:i.sources.market_data.rsi})]}),e.jsxs("div",{className:O("p-1.5 rounded text-center",i.sources.market_data.macdSignal==="bullish"?"bg-emerald-500/20":"bg-rose-500/20"),children:[e.jsx("div",{className:"text-muted-foreground",children:"MACD"}),e.jsx("div",{className:"font-bold",children:i.sources.market_data.macdHistogram})]}
116),e.jsxs("div",{className:"p-1.5 rounded bg-muted-foreground/10 text-center",children:[e.jsx("div",{className:"text-muted-foreground",children:"SMA20"}),e.jsx("div",{className:"font-bold",children:i.sources.market_data.sma20})]}),e.jsxs("div",{className:"p-1.5 rounded bg-muted-foreground/10 text-center",children:[e.jsx("div",{className:"text-muted-foreground",children:"SMA50"}),e.jsx("div",{className:"font-bold",children:i.sources.market_data.sma50})]})]}),e.jsxs("div",{className:"mt-2 text-[9px] text-muted-foreground text-center",children:[i.sources.market_data.dataPoints," days of historical data"]})]}),((L=i.sources)==null?void 0:L.alpha_vantage)&&!i.sources.alpha_vantage.error&&e.jsxs("div",{className:"mt-3 p-3 rounded-lg border border-amber-500/30 bg-amber-500/5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{className:"text-xs font-medium text-amber-500 flex items-center gap-1",children:[e.jsx(at,{className:"h-3 w-3"}),"Alpha Vantage Premium Data"]}),e.jsxs("div",{className:"flex items-center gap-1",children:[i.sources.alpha_vantage.isRealData&&e.jsx(C,{variant:"outline",className:"text-[9px] border-emerald-500/50 text-emerald-500",children:"LIVE"}),e.jsx(C,{variant:"outline",className:"text-[9px] border-amber-500/50 text-amber-500",children:i.sources.alpha_vantage.interval})]})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-2 mb-3",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"Price"}),e.jsxs("div",{className:"font-bold text-sm",children:["$",i.sources.alpha_vantage.price]})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"Change"}),e.jsxs("div",{className:O("font-bold text-sm",parseFloat(i.sources.alpha_vantage.change)>=0?"text-emerald-500":"text-rose-500"),children:[parseFloat(i.sources.alpha_vantage.change)>=0?"+":"",i.sources.alpha_vantage.change,"%"]})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"VWAP"}),e.jsxs("div",{className:"font-bold text-sm",children:["$",i.sources.alpha_vantage.vwap]})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"ATR%"}),e.jsxs("div",{className:"font-bold text-sm",children:[i.sources.alpha_vantage.atrPercent,"%"]})]})]}),e.jsxs("div",{className:"mb-3 p-2 rounded bg-background/50 border border-amber-500/20",children:[e.jsx("div",{className:"text-[10px] font-medium text-amber-500 mb-1",children:"Bollinger Bands (20,2)"}),e.jsxs("div",{className:"grid grid-cols-4 gap-1 text-[10px]",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-muted-foreground",children:"Upper"}),e.jsxs("div",{className:"font-bold text-rose-500",children:["$",i.sources.alpha_vantage.bollingerUpper]})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-muted-foreground",children:"Middle"}),e.jsxs("div",{className:"font-bold",children:["$",i.sources.alpha_vantage.bollingerMiddle]})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-muted-foreground",children:"Lower"}),e.jsxs("div",{className:"font-bold text-emerald-500",children:["$",i.sources.alpha_vantage.bollingerLower]})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-muted-foreground",children:"Position"}),e.jsxs("div",{className:O("font-bold",parseFloat(i.sources.alpha_vantage.bollingerPosition)>80?"text-rose-500":parseFloat(i.sources.alpha_vantage.bollingerPosition)<20?"text-emerald-500":"text-foreground"),children:[i.sources.alpha_vantage.bollingerPosition,"%"]})]})]})]}),e.jsxs("div",{className:"mb-3 p-2 rounded bg-background/50 border border-amber-500/20",children:[e.jsx("div",{className:"text-[10px] font-medium text-amber-500 mb-1",children:"Stochastic (14,3,3)"}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-[10px]",children:[e.jsxs("div",{className:O("p-1.5 rounded text-center",parseFloat(i.sources.alph
116a_vantage.stochasticK)<20?"bg-emerald-500/20":parseFloat(i.sources.alpha_vantage.stochasticK)>80?"bg-rose-500/20":"bg-muted-foreground/10"),children:[e.jsx("div",{className:"text-muted-foreground",children:"%K"}),e.jsx("div",{className:"font-bold",children:i.sources.alpha_vantage.stochasticK})]}),e.jsxs("div",{className:O("p-1.5 rounded text-center",parseFloat(i.sources.alpha_vantage.stochasticD)<20?"bg-emerald-500/20":parseFloat(i.sources.alpha_vantage.stochasticD)>80?"bg-rose-500/20":"bg-muted-foreground/10"),children:[e.jsx("div",{className:"text-muted-foreground",children:"%D"}),e.jsx("div",{className:"font-bold",children:i.sources.alpha_vantage.stochasticD})]}),e.jsxs("div",{className:O("p-1.5 rounded text-center",i.sources.alpha_vantage.stochasticSignal==="bullish"?"bg-emerald-500/20":"bg-rose-500/20"),children:[e.jsx("div",{className:"text-muted-foreground",children:"Signal"}),e.jsx("div",{className:O("font-bold",i.sources.alpha_vantage.stochasticSignal==="bullish"?"text-emerald-500":"text-rose-500"),children:(D=i.sources.alpha_vantage.stochasticSignal)==null?void 0:D.toUpperCase()})]})]})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-1 text-[10px]",children:[e.jsxs("div",{className:O("p-1.5 rounded text-center",parseFloat(i.sources.alpha_vantage.rsi)<30?"bg-emerald-500/20":parseFloat(i.sources.alpha_vantage.rsi)>70?"bg-rose-500/20":"bg-muted-foreground/10"),children:[e.jsx("div",{className:"text-muted-foreground",children:"RSI"}),e.jsx("div",{className:"font-bold",children:i.sources.alpha_vantage.rsi})]}),e.jsxs("div",{className:O("p-1.5 rounded text-center",parseFloat(i.sources.alpha_vantage.macdHistogram)>0?"bg-emerald-500/20":"bg-rose-500/20"),children:[e.jsx("div",{className:"text-muted-foreground",children:"MACD"}),e.jsx("div",{className:"font-bold",children:i.sources.alpha_vantage.macdHistogram})]}),e.jsxs("div",{className:"p-1.5 rounded bg-muted-foreground/10 text-center",children:[e.jsx("div",{className:"text-muted-foreground",children:"ATR"}),e.jsx("div",{className:"font-bold",children:i.sources.alpha_vantage.atr})]}),e.jsxs("div",{className:O("p-1.5 rounded text-center",i.sources.alpha_vantage.signal==="bullish"?"bg-emerald-500/20":i.sources.alpha_vantage.signal==="bearish"?"bg-rose-500/20":"bg-muted-foreground/10"),children:[e.jsx("div",{className:"text-muted-foreground",children:"Signal"}),e.jsx("div",{className:O("font-bold",i.sources.alpha_vantage.signal==="bullish"?"text-emerald-500":i.sources.alpha_vantage.signal==="bearish"?"text-rose-500":"text-foreground"),children:(F=i.sources.alpha_vantage.signal)==null?void 0:F.toUpperCase()})]})]}),e.jsxs("div",{className:"mt-2 text-[9px] text-muted-foreground text-center",children:[i.sources.alpha_vantage.dataPoints," intraday data points ⢠Updated: ",((R=i.sources.alpha_vantage.latestTimestamp)==null?void 0:R.split(" ")[1])||"N/A"]})]}),((x=(Q=i.sources)==null?void 0:Q.alpha_vantage)==null?void 0:x.error)&&e.jsx("div",{className:"mt-3 p-3 rounded-lg border border-rose-500/30 bg-rose-500/5",children:e.jsxs("div",{className:"flex items-center gap-2 text-rose-500 text-sm",children:[e.jsx(En,{className:"h-4 w-4"}),e.jsxs("span",{children:["Alpha Vantage: ",i.sources.alpha_vantage.error]})]})})]})]})]})}function Ss({label:t,value:s,subtext:a,positive:r}){return e.jsxs("div",{className:O("p-2 rounded-lg border text-center",r?"border-emerald-500/30 bg-emerald-500/10":"border-rose-500/30 bg-rose-500/10"),children:[e.jsx("div",{className:"text-[10px] text-muted-foreground",children:t}),e.jsx("div",{className:O("font-bold text-sm",r?"text-emerald-500":"text-rose-500"),children:s}),e.jsx("div",{className:"text-[9px] text-muted-foreground",children:a})]})}function Ec({agentConfig:t,isLive:s=!1}){var d,i,l,o,u,v;const[a,r]=j.useState(null),n=[{id:"ingestion",name:"Data Ingestion",icon:Lt,color:"cyan",description:"Multi-source data collection",details:[{label:"Market Data",value:"Yahoo Finance API",status:"active"},{label:"Social Sentiment",value:"Reddit API",status:(d=t==null?void 0:t.dataSources)!=null&&d.includes("reddit")?"active":"inactive"},{label:"Search Trends",value:"Google Trends",status:(i=t==null?void 0:t.dataSources)!=null&&i.includes("google_trends")?"active":"inactive"},{label:"News Feed",value:"News Sentiment",status:(l=t==null?void 0:t.dataSources)!=null&&l.includes("news_sentiment")?"active":"inactive"},{label:"Premium Data",value:"Alpha Vantage",status:(o=t==null?void 0:t.dataSources)!=null&&o.includes("alpha_vantage")?"active":"inactive"}],metrics:{throughput:"~1000 pts/min",latency:"<500ms"}},{id:"preprocessing",name:"Preprocessing",icon:Ca,color:"violet",description:"Data cleaning & normalization",details:[{label:"Missing Values",value:"Forward Fill",status:"active"}
116,{label:"Outlier Detection",value:"IQR Method",status:"active"},{label:"Normalization",value:"Z-Score",status:"active"},{label:"Time Alignment",value:"Resample 5min",status:"active"}],metrics:{coverage:"99.2%",quality:"High"}},{id:"features",name:"Feature Engineering",icon:Cr,color:"emerald",description:"Technical & alternative signals",details:[{label:"Technical",value:"RSI, MACD, BB, Stoch",status:"active"},{label:"Momentum",value:"5d/10d/20d Returns",status:"active"},{label:"Volatility",value:"ATR, Historical Vol",status:"active"},{label:"Sentiment",value:"Composite Score",status:(u=t==null?void 0:t.dataSources)!=null&&u.length?"active":"inactive"},{label:"Cross-Asset",value:"Correlation Matrix",status:"active"}],metrics:{features:"47",importance:"Ranked"}},{id:"ml",name:"ML Models",icon:lt,color:"amber",description:"Ensemble prediction models",details:[{label:"Primary",value:"XGBoost Classifier",status:"active"},{label:"Secondary",value:"LSTM Sequence",status:"active"},{label:"Regime",value:"HMM (3 states)",status:"active"},{label:"Ensemble",value:"Weighted Voting",status:"active"}],metrics:{accuracy:"67.3%",f1Score:"0.64"}},{id:"signal",name:"Signal Generation",icon:he,color:"rose",description:"Trade signal & confidence",details:[{label:"Direction",value:"BUY / SELL / HOLD",status:"active"},{label:"Confidence",value:"0-100%",status:"active"},{label:"Entry Price",value:"Current Market",status:"active"},{label:"Stop Loss",value:`${(t==null?void 0:t.stopLoss)||5}%`,status:"active"},{label:"Take Profit",value:`${(t==null?void 0:t.takeProfit)||10}%`,status:"active"}],metrics:{signalRate:"~15/hr",avgConf:"72%"}},{id:"output",name:"Signal Output",icon:Be,color:"primary",description:"Broadcast & execution",details:[{label:"Tape Stream",value:"Real-time",status:"active"},{label:"Signal Table",value:"Persisted",status:"active"},{label:"Notifications",value:"WebSocket",status:"active"},{label:"Auto-Execute",value:"If enabled",status:s?"active":"inactive"}],metrics:{latency:"<100ms",uptime:"99.9%"}}],c=h=>{const m={cyan:{bg:"bg-cyan-500/10",border:"border-cyan-500/30",text:"text-cyan-500",glow:"shadow-cyan-500/20"},violet:{bg:"bg-violet-500/10",border:"border-violet-500/30",text:"text-violet-500",glow:"shadow-violet-500/20"},emerald:{bg:"bg-emerald-500/10",border:"border-emerald-500/30",text:"text-emerald-500",glow:"shadow-emerald-500/20"},amber:{bg:"bg-amber-500/10",border:"border-amber-500/30",text:"text-amber-500",glow:"shadow-amber-500/20"},rose:{bg:"bg-rose-500/10",border:"border-rose-500/30",text:"text-rose-500",glow:"shadow-rose-500/20"},primary:{bg:"bg-primary/10",border:"border-primary/30",text:"text-primary",glow:"shadow-primary/20"}};return m[h]||m.primary};return e.jsxs(q,{className:"border-primary/20",children:[e.jsx(X,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Y,{className:"flex items-center gap-2 text-lg",children:[e.jsx(ji,{className:"h-5 w-5 text-primary"}),"Agent Pipeline Flow"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[s&&e.jsxs(C,{className:"bg-emerald-500/20 text-emerald-500 border-emerald-500/30 animate-pulse",children:[e.jsx(ge,{className:"h-3 w-3 mr-1"}),"LIVE"]}),(t==null?void 0:t.ticker)&&e.jsx(C,{variant:"outline",className:"border-primary/50",children:t.ticker})]})]})}
116),e.jsxs(H,{className:"space-y-3",children:[e.jsx("div",{className:"relative",children:n.map((h,m)=>{const f=c(h.color),b=a===h.id,_=h.icon;return e.jsxs("div",{className:"relative",children:[m<n.length-1&&e.jsx("div",{className:"absolute left-6 top-14 w-0.5 h-6 bg-gradient-to-b from-muted-foreground/30 to-muted-foreground/10"}),e.jsxs("div",{className:O("relative p-3 rounded-lg border transition-all cursor-pointer mb-2",f.bg,f.border,b&&`shadow-lg ${f.glow}`,"hover:shadow-md"),onClick:()=>r(b?null:h.id),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:O("w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold",f.bg,f.text,"border",f.border),children:m+1}),e.jsx("div",{className:O("p-2 rounded-lg",f.bg),children:e.jsx(_,{className:O("h-4 w-4",f.text)})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:h.name}),s&&e.jsx("span",{className:O("w-2 h-2 rounded-full animate-pulse",f.text.replace("text-","bg-"))})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:h.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"hidden sm:flex items-center gap-2 text-[9px] text-muted-foreground",children:Object.entries(h.metrics).map(([y,N])=>e.jsx(C,{variant:"outline",className:"text-[9px] h-5 px-1.5",children:N},y))}),b?e.jsx(On,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Tr,{className:"h-4 w-4 text-muted-foreground"})]})]}),b&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-muted-foreground/10",children:[e.jsx("div",{className:"grid grid-cols-2 gap-2",children:h.details.map(y=>e.jsxs("div",{className:O("p-2 rounded-md border text-[10px]",y.status==="active"?"bg-background/50 border-muted-foreground/20":"bg-muted-foreground/5 border-muted-foreground/10 opacity-50"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:y.label}),y.status==="active"?e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500"}):e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-muted-foreground/30"})]}),e.jsx("div",{className:"font-medium mt-0.5",children:y.value})]},y.label))}),e.jsx("div",{className:"flex items-center justify-center gap-4 mt-3 pt-2 border-t border-muted-foreground/10",children:Object.entries(h.metrics).map(([y,N])=>e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-[9px] text-muted-foreground capitalize",children:y.replace(/([A-Z])/g," $1")}),e.jsx("div",{className:O("font-bold text-sm",f.text),children:N})]},y))})]})]}),m<n.length-1&&e.jsx("div",{className:"flex justify-center -my-1",children:e.jsx(Ht,{className:O("h-4 w-4 rotate-90",s?"text-primary animate-pulse":"text-muted-foreground/30")})})]},h.id)})}),e.jsxs("div",{className:"grid grid-cols-4 gap-2 pt-3 border-t border-muted-foreground/10",children:[e.jsxs("div",{className:"text-center p-2 rounded-lg bg-muted-foreground/5",children:[e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"Data Sources"}),e.jsx("div",{className:"font-bold text-lg text-primary",children:((v=t==null?void 0:t.dataSources)==null?void 0:v.length)||5})]}),e.jsxs("div",{className:"text-center p-2 rounded-lg bg-muted-foreground/5",children:[e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"Features"}),e.jsx("div",{className:"font-bold text-lg text-emerald-500",children:"47"})]}),e.jsxs("div",{className:"text-center p-2 rounded-lg bg-muted-foreground/5",children:[e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"Models"}),e.jsx("div",{className:"font-bold text-lg text-amber-500",children:"4"})]}),e.jsxs("div",{className:"text-center p-2 rounded-lg bg-muted-foreground/5",children:[e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"Latency"}),e.jsx("div",{className:"font-bold text-lg text-rose-500",children:"<1s"})]})]}),(t==null?void 0:t.theory)&&e.jsxs("div",{className:"p-3 rounded-lg border border-primary/20 bg-primary/5",children:[e.jsxs("div",{className:"text-[10px] text-primary font-medium mb-1 flex items-center gap-1",children:[e.jsx(pe,{className:"h-3 w-3"}),"Theory Being Tested"]}),e.jsxs("p",{className:"text-xs text-muted-foreground italic",children:['"',t.theory,'"']})]})]})]})}function Lc(){var y,N;const[t,s]=j.useState([]),[a,r]=j.useState([]),[n,c]=j.useState([]),[d,i]=j.useState(!1);j.useEffect(()=>{l()},[]),j.useEffect(()=>{a.length>0&&o()},[a]);const l=async()=>{const{data:w}=await ue.from("custom_agents").select("id, name, strategy_type, stop_loss, take_profit, position_size, symbols, is_active").eq("is_public",!0).order("created_at",{ascending:!1}).limit(20);w&&(s(w),w.length>=2&&r(w.slice(0,Math.min(3,w.length)).map(g=>g.id)))},o=async()=>{i(!0);const{data:w}=await ue.from("agent_signals").select("id, agent_id, signal, confidence, symbol, created_at").in("agent_id",a).gte("created_at",new Date(Date.now()-7*24*60*60*1e3).toISOString()).order("created_at",{ascending:!1}).limit(500);c(w||[]),i(!1)},u=w=>{r(g=>g.includes(w)?g.filter(k=>k!==w):g.length<5?[...g,w]:g)},v=j.useMemo(()=>t.filter(w=>a.includes(w.id)),[t,a]),h=j.useMemo(()=>{const w={};return a.forEach(g=>{const k=t.find(G=>
116G.id===g),M=n.filter(G=>G.agent_id===g),T={},A={};let B=0,z=0,U=0;M.forEach(G=>{const K=new Date(G.created_at).toISOString().slice(0,13);T[K]=(T[K]||0)+1,A[G.symbol]=(A[G.symbol]||0)+1,G.signal.toLowerCase().includes("bull")||G.signal.toLowerCase()==="buy"?B++:(G.signal.toLowerCase().includes("bear")||G.signal.toLowerCase()==="sell")&&z++,U+=G.confidence}),w[g]={agentId:g,agentName:(k==null?void 0:k.name)||"Unknown",totalSignals:M.length,bullishCount:B,bearishCount:z,avgConfidence:M.length>0?U/M.length:0,signalsByHour:Object.entries(T).map(([G,K])=>({hour:G.slice(11,13)+":00",count:K})).slice(-24),symbolDistribution:Object.entries(A).map(([G,K])=>({symbol:G,count:K})).sort((G,K)=>K.count-G.count).slice(0,5)}}),w},[n,a,t]),m=j.useMemo(()=>{const w=[];for(let g=0;g<a.length;g++)for(let k=g+1;k<a.length;k++){const M=a[g],T=a[k],A=t.find(R=>R.id===M),B=t.find(R=>R.id===T),z=n.filter(R=>R.agent_id===M),U=n.filter(R=>R.agent_id===T);let G=0,K=0,$=0;z.forEach(R=>{const Q=new Date(R.created_at).getTime(),x=U.find(S=>{const E=new Date(S.created_at).getTime();return Math.abs(Q-E)<5*60*1e3&&R.symbol===S.symbol});if(x){$++;const S=R.signal.toLowerCase().includes("bull")||R.signal.toLowerCase()==="buy",E=x.signal.toLowerCase().includes("bull")||x.signal.toLowerCase()==="buy";S===E?G++:K++}});const L=$>0?G/$*100:50,D=$>0?K/$*100:0,F=$>0?(G-K)/$:0;w.push({agent1:(A==null?void 0:A.name)||"Agent 1",agent2:(B==null?void 0:B.name)||"Agent 2",correlation:F,agreementRate:L,conflictRate:D})}return w},[n,a,t]),f=w=>({momentum:"text-emerald-400",mean_reversion:"text-blue-400",trend_following:"text-purple-400",volatility:"text-amber-400",multi_factor:"text-rose-400"})[w]||"text-muted-foreground",b=w=>w>.5?"text-emerald-400":w>0?"text-emerald-400/60":w>-.5?"text-amber-400":"text-red-400",_=w=>Math.max(...Object.values(h).map(g=>g[w]));return e.jsxs(q,{className:"border-cyan-400/30 bg-gradient-to-br from-background via-primary/5 to-cyan-400/5",children:[e.jsx(X,{className:"pb-3",children:e.jsxs(Y,{className:"text-base flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-gradient-to-br from-cyan-400/20 to-primary/20 border border-cyan-400/30",children:e.jsx(mt,{className:"w-4 h-4 text-cyan-400"})}),e.jsx("span",{className:"bg-gradient-to-r from-cyan-400 to-primary bg-clip-text text-transparent font-bold",children:"Agent Comparison"}),e.jsxs(C,{variant:"outline",className:"ml-auto text-[10px] bg-primary/10 border-primary/30",children:[a.length,"/5 Selected"]})]})}
116),e.jsxs(H,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Select agents to compare (max 5)"}),e.jsxs(W,{variant:"ghost",size:"sm",onClick:o,disabled:d||a.length===0,className:"h-6 text-[10px]",children:[e.jsx(Me,{className:`w-3 h-3 mr-1 ${d?"animate-spin":""}`}),"Refresh"]})]}),e.jsx(Et,{className:"h-[200px] border border-primary/20 rounded-lg p-2 bg-background/50 [&>[data-radix-scroll-area-viewport]]:scrollbar-thin [&>[data-radix-scroll-area-viewport]]:scrollbar-track-transparent [&>[data-radix-scroll-area-viewport]]:scrollbar-thumb-primary/50",children:e.jsxs("div",{className:"space-y-1.5",children:[t.map(w=>e.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg cursor-pointer transition-all ${a.includes(w.id)?"bg-primary/20 border border-primary/40":"hover:bg-muted/50 border border-transparent"}`,onClick:()=>u(w.id),children:[e.jsx(Gs,{checked:a.includes(w.id),className:"h-4 w-4 border-primary/50 data-[state=checked]:bg-primary data-[state=checked]:border-primary"}),e.jsx(Ke,{className:`w-4 h-4 ${f(w.strategy_type)}`}),e.jsx("span",{className:"text-xs flex-1 truncate font-medium",children:w.name}),e.jsx(C,{variant:"outline",className:"text-[9px] h-5",children:w.strategy_type.replace("_"," ")}),w.is_active&&e.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse"})]},w.id)),t.length===0&&e.jsxs("div",{className:"text-center text-xs text-muted-foreground py-8",children:[e.jsx(Ke,{className:"w-8 h-8 mx-auto mb-2 opacity-30"}),"No agents available"]})]})}),e.jsx(W,{onClick:o,disabled:a.length<2||d,className:"w-full h-12 bg-gradient-to-r from-cyan-500 to-primary hover:from-cyan-400 hover:to-primary/90 shadow-lg shadow-primary/30 font-bold text-base",children:d?e.jsxs(e.Fragment,{children:[e.jsx(Me,{className:"w-5 h-5 mr-2 animate-spin"}),"Analyzing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(mt,{className:"w-5 h-5 mr-2"}),"Compare ",a.length," Agents"]})})]}),a.length>=2&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"text-xs font-semibold text-muted-foreground flex items-center gap-1",children:[e.jsx(gt,{className:"w-3 h-3"}),"Performance Metrics"]}),e.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${Math.min(a.length,3)}, 1fr)`},children:v.map(w=>{const g=h[w.id];if(!g)return null;const k=g.totalSignals>0?g.bullishCount/g.totalSignals*100:50;return e.jsxs("div",{className:"bg-background/50 rounded-lg p-3 space-y-3 border border-border/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ke,{className:`w-4 h-4 ${f(w.strategy_type)}`}),e.jsx("span",{className:"text-xs font-semibold truncate flex-1",children:w.name})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-[10px]",children:[e.jsxs("span",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(ge,{className:"w-2.5 h-2.5"})," Signals (7d)"]}),e.jsxs("span",{className:"font-mono",children:[g.totalSignals,g.totalSignals===_("totalSignals")&&g.totalSignals>0&&e.jsx("span",{className:"ml-1 text-emerald-400",children:"â
"})]})]}),e.jsx(Xe,{value:g.totalSignals/Math.max(_("totalSignals"),1)*100,className:"h-1"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-[10px]",children:[e.jsxs("span",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(pe,{className:"w-2.5 h-2.5"})," Confidence"]}),e.jsxs("span",{className:"font-mono",children:[g.avgConfidence.toFixed(0),"%",g.avgConfidence===_("avgConfidence")&&g.avgConfidence>0&&e.jsx("span",{className:"ml-1 text-emerald-400",children:"â
"})]})]}),e.jsx(Xe,{value:g.avgConfidence,className:"h-1"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Signal Bias"}),e.jsxs("div",{className:"h-2 bg-muted rounded-full overflow-hidden flex",children:[e.jsx("div",{className:"h-full bg-emerald-500/70",style:{width:`${k}%`}}),e.jsx("div",{className:"h-full bg-red-500/70",style:{width:`${100-k}%`}})]}),e.jsxs("div",{className:"flex justify-between text-[9px]",children:[e.jsxs("span",{className:"text-emerald-400 flex items-center gap-0.5",children:[e.jsx(he,{className:"w-2.5 h-2.5"})," ",g.bullishCount]}),e.jsxs("span",{className:"text-red-400 flex items-center gap-0.5",children:[g.bearishCount," ",e.jsx(ke,{className:"w-2.5 h-2.5"})]})]})]}),e.jsxs("div",{className:"pt-2 border-t border-border/30 grid grid-cols-2 gap-2 text-[9px]",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Ce,{className:"w-2.5 h-2.5 text-red-400"}),e.jsx("span",{className:"text-muted-foreground",children:"SL:"}),e.jsxs("span",{className:"font-mono",children:[(w.stop_loss*100).toFixed(0),"%"]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Be,{className:"w-2.5 h-2.5 text-emerald-400"}),e.jsx("span",{className:"text-muted-foreground",children:"TP:"}),e.jsxs("span",{className:"font-mono",children:[(w.take_profit*100).toFixed(0),"%"]})]})]})]},w.id)})})]}),Object.keys(h).length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"text-xs font-semibold text-muted-foreground flex items-center gap-1",children:[e.jsx(dt,{className:"w-3 h-3"}),"Signal Activity (24h)"]}),e.jsx("div",{className:"h-[100px] bg-background/30 rounded-lg p-2",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(ot,{data:((y=Object.values(h)[0])==null?void 0:y.signalsByHour)||[],children:[e.jsx(de,{dataKey:"hour",tick:{fontSize:8,fill:"hsl(var(--muted-foreground))"}
116,axisLine:!1,tickLine:!1}),e.jsx(oe,{hide:!0}),e.jsx(Ne,{contentStyle:{background:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"6px",fontSize:"10px"}}),e.jsx(Ye,{dataKey:"count",radius:[2,2,0,0],children:(((N=Object.values(h)[0])==null?void 0:N.signalsByHour)||[]).map((w,g)=>e.jsx(rt,{fill:"hsl(var(--primary))",fillOpacity:.7},g))})]})})})]}),m.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"text-xs font-semibold text-muted-foreground flex items-center gap-1",children:[e.jsx(ys,{className:"w-3 h-3"}),"Signal Correlation Analysis"]}),e.jsx("div",{className:"space-y-2",children:m.map((w,g)=>e.jsxs("div",{className:"bg-background/50 rounded-lg p-3 border border-border/30",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"font-medium truncate max-w-[80px]",children:w.agent1}),e.jsx(mt,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"font-medium truncate max-w-[80px]",children:w.agent2})]}),e.jsx(C,{variant:"outline",className:`text-[9px] ${b(w.correlation)}`,children:w.correlation>.3?"HIGH CORRELATION":w.correlation>0?"MODERATE":w.correlation>-.3?"LOW":"INVERSE"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[e.jsxs("div",{children:[e.jsxs("div",{className:`text-sm font-bold ${b(w.correlation)}`,children:[(w.correlation*100).toFixed(0),"%"]}),e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"Correlation"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm font-bold text-emerald-400 flex items-center justify-center gap-1",children:[e.jsx(Ks,{className:"w-3 h-3"}),w.agreementRate.toFixed(0),"%"]}),e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"Agreement"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm font-bold text-red-400 flex items-center justify-center gap-1",children:[e.jsx(Ta,{className:"w-3 h-3"}),w.conflictRate.toFixed(0),"%"]}),e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"Conflict"})]})]}),e.jsx("div",{className:"mt-2 h-1.5 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full transition-all ${w.correlation>0?"bg-emerald-500":"bg-red-500"}`,style:{width:`${Math.abs(w.correlation)*100}%`,marginLeft:w.correlation<0?`${(1+w.correlation)*50}%`:"50%"}})})]},g))})]}),e.jsx("div",{className:"bg-primary/5 rounded-lg p-3 border border-primary/20",children:e.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-bold text-primary",children:Object.values(h).reduce((w,g)=>w+g.totalSignals,0)}),e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"Total Signals"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-lg font-bold",children:[(Object.values(h).reduce((w,g)=>w+g.avgConfidence,0)/Math.max(Object.keys(h).length,1)).toFixed(0),"%"]}),e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"Avg Confidence"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-lg font-bold",children:[m.length>0?(m.reduce((w,g)=>w+g.agreementRate,0)/m.length).toFixed(0):0,"%"]}),e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"Avg Agreement"})]})]})})]}),a.length<2&&e.jsx("div",{className:"text-center py-6 text-xs text-muted-foreground",children:"Select at least 2 agents to compare"})]})]})}const zt=[{id:"trending",name:"Trending Market",description:"Optimized for strong directional moves",icon:e.jsx(he,{className:"w-3.5 h-3.5"}),color:"text-emerald-400 bg-emerald-500/10 border-emerald-500/30",weights:{momentum:2,trend_following:2.2,mean_reversion:.5,volatility:1,multi_factor:1.5},consensus:55,enabledStrategies:["momentum","trend_following","multi_factor"]},{id:"ranging",name:"Ranging Market",description:"Best for sideways, mean-reverting conditions",icon:e.jsx(Zs,{className:"w-3.5 h-3.5"}),color:"text-blue-400 bg-blue-500/10 border-blue-500/30",weights:{momentum:.6,trend_following:.5,mean_reversion:2.2,volatility:1.3,multi_factor:1.4},consensus:65,enabledStrategies:["mean_reversion","volatility","multi_factor"]},{id:"volatile",name:"High Volatility",description:"Adapted for turbulent market conditions",icon:e.jsx(ge,{className:"w-3.5 h-3.5"}),color:"text-amber-400 bg-amber-500/10 border-amber-500/30",weights:{momentum:1,trend_following:.8,mean_reversion:1.2,volatility:2.5,multi_factor:1.8},consensus:70,enabledStrategies:["volatility","multi_factor","mean_reversion"]},{id:"conservative",name:"Conservative",description:"High consensus required, lower risk",icon:e.jsx(Ce,{className:"w-3.5 h-3.5"}),color:"text-cyan-400 bg-cyan-500/10 border-cyan-500/30",weights:{momentum:1,trend_following:1.2,mean_reversion:1.2,volatility:.8,multi_factor:1.5},consensus:80,enabledStrategies:["trend_following","mean_reversion","multi_factor"]},{id:"aggressive",name:"Aggressive",description:"Lower threshold, momentum-focused",icon:e.jsx(ii,{className:"w-3.5 h-3.5"}),color:"text-rose-400 bg-rose-500/10 border-rose-500/30",weights:{momentum:2.2,trend_following:1.8,mean_reversion:.8,volatility:1.5,multi_factor:2},consensus:45,enabledStrategies:["momentum","trend_following","volatility","multi_factor"]},{id:"balanced",name:"Balanced",description:"Equal weights across all strategies",icon:e.jsx(St,{className:"w-3.5 h-3.5"}),color:"text-purple-400 bg-purple-500/10 border-purple-500/30",weights:{momentum:1.3,trend_following:1.3,mean_reversion:1.3,volatility:1.3,multi_factor:1.3},consensus:60,enabledStrategies:["momentum","trend_following","mean_reversion","volatility","multi_factor"]}],Oc={trending:"trending",ranging:"ranging",volatile:"volatile",low_volatility:"aggressive",crisis:"conservative"},$t={trending:{label:"TRENDING",icon:he,color:"text-emerald-400",bgColor:"bg-emerald-500/20 border-emerald-500/30"},ranging:{label:"RANGING",icon:Zs,color:"text-blue-400",bgColor:"bg-blue-500/20 border-blue-500/30"},volatile:{label:"HIGH VOL",icon:pe,color:"text-amber-400",bgColor:"bg-
116amber-500/20 border-amber-500/30"},low_volatility:{label:"LOW VOL",icon:ge,color:"text-cyan-400",bgColor:"bg-cyan-500/20 border-cyan-500/30"},crisis:{label:"CRISIS",icon:ke,color:"text-red-400",bgColor:"bg-red-500/20 border-red-500/30"}};function Ic(){var te,Z;const[t,s]=j.useState([]),[a,r]=j.useState([]),[n,c]=j.useState([]),[d,i]=j.useState(null),[l,o]=j.useState(!1),[u,v]=j.useState(!1),[h,m]=j.useState("BTC"),[f,b]=j.useState(60),[_,y]=j.useState(!1),[N,w]=j.useState("balanced"),[g,k]=j.useState(null),[M,T]=j.useState(!1),A=["BTC","ETH","SOL","SPY","QQQ","AAPL","NVDA"],B=j.useCallback(async()=>{T(!0);try{const{data:I}=await ue.from("market_snapshots").select("price, change_percent, created_at, symbol").eq("symbol",h).order("created_at",{ascending:!1}).limit(50),{data:V}=await ue.from("agent_signals").select("signal, confidence, created_at").eq("symbol",h).gte("created_at",new Date(Date.now()-24*60*60*1e3).toISOString()).order("created_at",{ascending:!1}).limit(100),J=(I==null?void 0:I.map(be=>Number(be.price)))||[],_e=(I==null?void 0:I.map(be=>Number(be.change_percent)||0))||[],ft=_e.length>0?_e.reduce((be,ct)=>be+ct,0)/_e.length:0,tt=_e.length>0?_e.reduce((be,ct)=>be+Math.pow(ct-ft,2),0)/_e.length:0,ce=Math.sqrt(tt),p=_e.filter(be=>be>0).length,re=_e.filter(be=>be<0).length,ne=_e.length>0?Math.abs(p-re)/_e.length:0,Pe=J.slice(0,10).reduce((be,ct)=>be+ct,0)/Math.max(J.slice(0,10).length,1),Se=J.slice(20,30).reduce((be,ct)=>be+ct,0)/Math.max(J.slice(20,30).length,1),Te=Se>0?(Pe-Se)/Se*100:0,rs=(V==null?void 0:V.filter(be=>be.signal.toLowerCase().includes("bull")||be.signal.toLowerCase()==="buy").length)||0,ns=(V==null?void 0:V.filter(be=>be.signal.toLowerCase().includes("bear")||be.signal.toLowerCase()==="sell").length)||0,ht=(V==null?void 0:V.length)||0,pt=ht>0?(rs-ns)/ht:0;let st="ranging",He=60,bt="";ce>3.5?(st="volatile",He=Math.min(95,70+ce*5),bt="High volatility detected. Large price swings and uncertainty."):ce>2.5&&Math.abs(Te)>5?(st="crisis",He=Math.min(90,65+ce*3),bt="Crisis conditions. Elevated volatility with directional pressure."):ne>.6&&Math.abs(Te)>2?(st="trending",He=Math.min(90,60+ne*30),bt=Te>0?"Strong uptrend detected.":"Strong downtrend detected."):ce<1.5&&ne<.3?(st="low_volatility",He=Math.min(85,55+(1.5-ce)*20),bt="Low volatility environment. Potential breakout setup."):(st="ranging",He=Math.min(80,50+(1-ne)*25),bt="Sideways price action. Mean reversion favorable.");const vt=[{name:"Volatility",value:`${ce.toFixed(2)}%`,signal:ce>2.5?"bearish":ce<1.5?"bullish":"neutral"},{name:"Trend Strength",value:`${(ne*100).toFixed(0)}%`,signal:ne>.5?"bullish":ne<.2?"bearish":"neutral"},{name:"Momentum",value:`${Te>0?"+":""}${Te.toFixed(2)}%`,signal:Te>1?"bullish":Te<-1?"bearish":"neutral"},{name:"Signal Bias",value:`${pt>0?"+":""}${(pt*100).toFixed(0)}%`,signal:pt>.2?"bullish":pt<-.2?"bearish":"neutral"}];k({regime:st,confidence:He,suggestedPreset:Oc[st],indicators:vt,description:bt})}catch(I){console.error("Regime detection error:",I),k({regime:"ranging",confidence:50,suggestedPreset:"balanced",indicators:[{name:"Volatility",value:"N/A",signal:"neutral"},{name:"Trend",value:"N/A",signal:"neutral"},{name:"Momentum",value:"N/A",signal:"neutral"},{name:"Bias",value:"N/A",signal:"neutral"}],description:"Unable to detect regime. Using balanced settings."})}T(!1)},[h]);j.useEffect(()=>{B()},[h,B]);const z=()=>{var I;g&&(K(g.suggestedPreset),xe({title:"Auto-Configured",description:`Applied ${(I=zt.find(V=>V.id===g.suggestedPreset))==null?void 0:I.name} preset based on ${$t[g.regime].label} conditions`}))};j.useEffect(()=>{U()},[]),j.useEffect(()=>{let I;return _&&l&&(I=setInterval(()=>{R()},3e4)),()=>clearInterval(I)},[_,l,a,h]);const U=async()=>{const{data:I}=await ue.from("custom_agents").select("id, name, strategy_type, is_active").eq("is_public",!0).order("created_at",{ascending:!1}).limit(15);if(I){s(I);const V=zt.find(J=>J.id==="balanced");V?G(I,V):r(I.map(J=>({agentId:J.id,weight:$(J.strategy_type),enabled:!0})))}},G=(I,V)=>{r(I.map(J=>({agentId:J.id,weight:V.weights[J.strategy_type]||1,enabled:V.enabledStrategies.includes(J.strategy_type)}))),b(V.consensus)},K=I=>{const V=zt.find(J=>J.id===I);V&&(G(t,V),w(I),xe({title:"Preset Applied",description:`${V.name} configuration loaded`}))},$=I=>({momentum:1.3,mean_reversion:1.2,trend_following:1.4,volatility:1.1,multi_factor:1.5})[I]||1,L=(I,V)=>{r(J=>J.map(_e=>_e.agentId===I?{..._e,weight:V}:_e)),w(null)},D=I=>{r(V=>V.map(J=>J.agentId===I?{...J,enabled:!J.enabled}:J)),w(null)},F=j.useMemo(()=>a.filter(I=>I.enabled),[a]),R=async()=>
116{if(F.length<2){xe({title:"Error",description:"Select at least 2 agents for ensemble",variant:"destructive"});return}v(!0),o(!0);try{const{data:I}=await ue.from("agent_signals").select("agent_id, signal, confidence, symbol, created_at").in("agent_id",F.map(J=>J.agentId)).eq("symbol",h).gte("created_at",new Date(Date.now()-36e5).toISOString()).order("created_at",{ascending:!1});c(I||[]);const V=Q(I||[]);i(V)}catch(I){console.error("Ensemble error:",I),xe({title:"Error",description:"Failed to run ensemble",variant:"destructive"})}v(!1)},Q=I=>{let V=0,J=0,_e=0,ft=0,tt=0;const ce=[],p=[],re=new Map;I.forEach(He=>{re.has(He.agent_id)||re.set(He.agent_id,He)}),F.forEach(({agentId:He,weight:bt})=>{const vt=re.get(He),be=t.find(ct=>ct.id===He);if(vt){const ct=vt.signal.toLowerCase().includes("bull")||vt.signal.toLowerCase()==="buy",kn=vt.signal.toLowerCase().includes("bear")||vt.signal.toLowerCase()==="sell",ta=vt.confidence*bt;ct?(V+=ta,ce.push((be==null?void 0:be.name)||He)):kn?(J+=ta,p.push((be==null?void 0:be.name)||He)):_e+=ta,ft+=bt,tt+=vt.confidence}});const ne=Math.max(V,J,_e),Pe=V+J+_e;let Se="NEUTRAL";V>J&&V>_e?Se="BULLISH":J>V&&J>_e&&(Se="BEARISH");const Te=Pe>0?ne/Pe*100:0,rs=F.length>0?tt/F.length:0,ns=ft>0?ne/ft:0,ht=Se==="BULLISH"?ce:Se==="BEARISH"?p:[],pt=Se==="BULLISH"?p:Se==="BEARISH"?ce:[];let st="";return Te>=f?Se==="BULLISH"?st=`STRONG BUY - ${Te.toFixed(0)}% consensus with ${ht.length} agents aligned`:Se==="BEARISH"&&(st=`STRONG SELL - ${Te.toFixed(0)}% consensus with ${ht.length} agents aligned`):Te>=40?st=`WEAK ${Se} - Consensus below threshold (${Te.toFixed(0)}% < ${f}%)`:st="NO SIGNAL - Insufficient consensus among agents",{direction:Se,confidence:rs,weightedScore:ns,agreeingAgents:ht,dissentingAgents:pt,signalStrength:Te,recommendation:st}},x=I=>{switch(I){case"BULLISH":return e.jsx(he,{className:"w-5 h-5 text-emerald-400"});case"BEARISH":return e.jsx(ke,{className:"w-5 h-5 text-red-400"});default:return e.jsx(Sa,{className:"w-5 h-5 text-muted-foreground"})}},S=I=>{switch(I){case"BULLISH":return"text-emerald-400 bg-emerald-500/10 border-emerald-500/30";case"BEARISH":return"text-red-400 bg-red-500/10 border-red-500/30";default:return"text-muted-foreground bg-muted/50 border-muted"}},E=I=>({momentum:"text-emerald-400",mean_reversion:"text-blue-400",trend_following:"text-purple-400",volatility:"text-amber-400",multi_factor:"text-rose-400"})[I]||"text-muted-foreground";return e.jsxs(q,{className:"border-border/50 bg-card/30",children:[e.jsx(X,{className:"pb-3",children:e.jsxs(Y,{className:"text-base flex items-center gap-2",children:[e.jsx(us,{className:"w-4 h-4 text-primary"}),"Agent Ensemble Mode",e.jsxs(C,{variant:"outline",className:"ml-auto text-[10px]",children:[F.length," Active"]})]})}
116),e.jsxs(H,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("select",{value:h,onChange:I=>m(I.target.value),className:"h-8 px-2 rounded-md border border-border bg-background text-xs",children:A.map(I=>e.jsx("option",{value:I,children:I},I))}),e.jsxs(W,{size:"sm",onClick:R,disabled:u||F.length<2,className:"h-8 text-xs",children:[u?e.jsx(Me,{className:"w-3 h-3 mr-1 animate-spin"}):l?e.jsx(Me,{className:"w-3 h-3 mr-1"}):e.jsx(Je,{className:"w-3 h-3 mr-1"}),l?"Refresh":"Run Ensemble"]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Auto"}),e.jsx(ye,{checked:_,onCheckedChange:y,className:"scale-75"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(Be,{className:"w-3 h-3"}),"Min Consensus Threshold"]}),e.jsxs("span",{className:"font-mono",children:[f,"%"]})]}),e.jsx(ee,{value:[f],onValueChange:([I])=>{b(I),w(null)},min:30,max:90,step:5,className:"w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs font-semibold text-muted-foreground flex items-center gap-1",children:[e.jsx(er,{className:"w-3 h-3"}),"Market Regime Detection"]}),e.jsx(W,{variant:"ghost",size:"sm",onClick:B,disabled:M,className:"h-5 text-[9px] px-2",children:M?e.jsx(Me,{className:"w-2.5 h-2.5 animate-spin"}):e.jsx(Me,{className:"w-2.5 h-2.5"})})]}),g&&e.jsxs("div",{className:O("p-3 rounded-lg border space-y-2",$t[g.regime].bgColor),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[(()=>{const I=$t[g.regime].icon;return e.jsx(I,{className:O("w-4 h-4",$t[g.regime].color)})})(),e.jsx("span",{className:O("text-sm font-bold",$t[g.regime].color),children:$t[g.regime].label}),e.jsxs(C,{variant:"outline",className:"ml-auto text-[9px] h-4",children:[g.confidence,"% conf"]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:g.description}),e.jsx("div",{className:"grid grid-cols-4 gap-1",children:g.indicators.map((I,V)=>e.jsxs("div",{className:"bg-background/50 rounded p-1.5 text-center",children:[e.jsx("div",{className:O("text-[10px] font-mono font-semibold",I.signal==="bullish"&&"text-emerald-400",I.signal==="bearish"&&"text-red-400",I.signal==="neutral"&&"text-muted-foreground"),children:I.value}),e.jsx("div",{className:"text-[8px] text-muted-foreground truncate",children:I.name})]},V))}),e.jsxs("div",{className:"flex items-center gap-2 pt-1 border-t border-border/30",children:[e.jsx(_t,{className:"w-3 h-3 text-primary"}),e.jsxs("span",{className:"text-[10px] text-muted-foreground flex-1",children:["Suggested: ",e.jsx("span",{className:"text-foreground font-medium",children:(te=zt.find(I=>I.id===g.suggestedPreset))==null?void 0:te.name})]}),N!==g.suggestedPreset&&e.jsx(W,{size:"sm",onClick:z,className:"h-5 text-[9px] px-2",children:"Apply"}),N===g.suggestedPreset&&e.jsxs(C,{className:"text-[8px] h-4 bg-primary/20 text-primary border-primary/30",children:[e.jsx(it,{className:"w-2.5 h-2.5 mr-0.5"})," Active"]})]})]}),!g&&!M&&e.jsxs("div",{className:"p-3 rounded-lg border border-dashed border-border/50 text-center",children:[e.jsx(er,{className:"w-5 h-5 mx-auto mb-1 text-muted-foreground/50"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Analyzing market conditions..."})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs font-semibold text-muted-foreground flex items-center gap-1",children:[e.jsx(Us,{className:"w-3 h-3"}),"Strategy Presets"]}),N&&e.jsx(C,{variant:"outline",className:"text-[9px] h-4",children:(Z=zt.find(I=>I.id===N))==null?void 0:Z.name})]}),e.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:zt.map(I=>e.jsxs("button",{onClick:()=>K(I.id),className:O("p-2 rounded-lg border text-left transition-all hover:scale-[1.02]",N===I.id?I.color:"bg-background/30 border-border/30 hover:border-border/60"),children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[e.jsx("span",{className:N===I.id?"":"text-muted-foreground",children:I.icon}),e.jsx("span",{className:O("text-[10px] font-semibold",N===I.id?"":"text-foreground"),children:I.name})]}),e.jsx("p",{className:"text-[9px] text-muted-foreground line-clamp-1",children:I.description})]},I.id))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs font-semibold text-muted-foreground flex items-center gap-1",children:[e.jsx(ys,{className:"w-3 h-3"}),"Agent Weights"]}),e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>{r(t.map(I=>({agentId:I.id,weight:$(I.strategy_type),enabled:!0}))),w(null)},className:"h-6 text-[10px]",children:"Reset"})]}),e.jsx(Et,{className:"h-[180px] border rounded-lg p-2",children:e.jsx("div",{className:"space-y-2",children:t.map(I=>{const V=a.find(J=>J.agentId===I.id);return V?e.jsxs("div",{className:O("p-2 rounded-lg border transition-all",V.enabled?"bg-background/50 border-border/50":"bg-muted/20 border-transparent opacity-50"),children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(ye,{checked:V.enabled,onCheckedChange:()=>D(I.id),className:"scale-75"}),e.jsx(Ke,{className:`w-3 h-3 ${E(I.strategy_type)}`}),e.jsx("span",{className:"text-xs flex-1 truncate",children:I.name}),e.jsxs(C,{variant:"outline",className:"text-[9px] h-4",children:[V.weight.toFixed(1),"Ã"]})]}),V.enabled&&e.jsx(ee,{value:[V.weight],onValueChange:([J])=>L(I.id,J),min:.5,max:2.5,step:.1,className:"w-full"})]},I.id):null})})})]}),d&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(gt,{className:"w-3 h-3 text-primary"}),e.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"Ensemble Result"})]}),e.jsxs("div",{className:O("p-4 rounded-lg border text-center",S(d.direction)),children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[x(d.direction),e.jsx("span",{className:"text-xl font-bold",children:d.direction})]}),e.jsxs("div",{className:"text-2xl font-bold mb-1",children:[d.signalStrength.toFixed(0),"%"]}),e.jsx("div",{className:"text-xs opacity-80",children:"Consensus Strength"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"bg-background/50 rounded-lg p-2 text-center",children:[e.jsxs("div",{className:"text-sm font-bold",children:[d.confidence.toFixed(0),"%"]}),e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"Avg Confidence"})]}),e.jsxs("div",{className:"bg-background/50 rounded-lg p-2 text-center",children:[e.jsxs("div",{className:"text-sm font-bold text-emerald-400 flex items-center justify-center gap-0.5",children:[e.jsx(Ks,{className:"w-3 h-3"}),d.agreeingAgents.length]}),e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"Agreeing"})]}),e.jsxs("div",{className:"bg-background/50 rounded-lg p-2 text-center",children:[e.jsxs("div",{className:"text-sm font-bold text-red-400 flex items-center justify-center gap-0.5",children:[e.jsx(Ta,{className:"w-3 h-3"}),d.dissentingAgents.length]}),e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"Dissenting"})]})]}),e.jsxs("div",{className:O("p-3 rounded-lg border text-xs",d.signalStrength>=f?"bg-primary/10 border-primary/30 text-primary":"bg-muted/50 border-muted text-muted-foreground"),children:[d.signalStrength>=f&&e.jsx(it,{className:"w-3 h-3 inline mr-1"}),d.recommendation]}),(d.agreeingAgents.length>0||d.dissentingAgents.length>0)&&e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[10px]",children:[d.agreeingAgents.length>0&&e.jsxs("div",{className:"bg-emerald-500/10 rounded-lg p-2",children:[e.jsx("div",{className:"text-emerald-400 font-semibold mb-1",children:"Agreeing"}),d.agreeingAgents.slice(0,3).map((I,V)=>e.jsx("div",{className:"truncate text-muted-foreground",children:I},V)),d.agreeingAgents.length>3&&e.jsxs("div",{className:"text-muted-foreground",children:["+",d.agreeingAgents.length-3," more"]})]}),d.dissentingAgents.length>0&&e.jsxs("div",{className:"bg-red-500/10 rounded-lg p-2",children:[e.jsx("div",{className:"text-red-400 font-semibold mb-1",children:"Dissenting"}),d.dissentingAgents.slice(0,3).map((I,V)=>e.jsx("div",{className:"truncate text-muted-foreground",children:I},V)),d.dissentingAgents.length>3&&e.jsxs("div",{className:"text-muted-foreground",children:["+",d.dissentingAgents.length-3," more"]})]})]})]}),!d&&!u&&e.jsxs("div",{className:"text-center py-6 text-xs text-muted-foreground",children:[e.jsx(us,{className:"w-8 h-8 mx-auto mb-2 opacity-30"}),'Configure agent weights and click "Run Ensemble" to generate combined signals']})]})]})}function Bc(){const[t,s]=j.useState([]),[a,r]=j.useState(!1),[n,c]=j.useState("30d");j.useEffect(()=>{d()},[n]);const d=async()=>{r(!0);const h=n==="7d"?7:n==="30d"?30:90,m=new Date(Date.now()-h*24*60*60*1e3).toISOString(),{data:f}=await ue.from("signal_accuracy").select("id, agent_id, agent_name, signal, confidence, is_correct, price_change_pct, created_at, symbol").gte("created_at",m).not("is_correct","is",null).order("created_at",{ascending:!0});s(f||[]),r(!1)},i=j.useMemo(()=>{const h=new Map;return t.forEach(m=>{const f=h.get(m.agent_id)||{total:0,correct:0,confidence:0,returns:0,name:m.agent_name};f.total++,m.is_correct&&f.correct++,f.confidence+=m.confidence||0,f.returns+=m.price_change_pct||0,h.set(m.agent_id,f)}),Array.from(h.entries()).map(([m,f])=>({agentId:m,agentName:f.name,totalSignals:f.total,correctSignals:f.correct,accuracy:f.total>0?f.correct/f.total*100:0,avgConfidence:f.total>0?f.confidence/f.total:0,avgReturn:f.total>0?f.returns/f.total:0})).filter(m=>m.totalSignals>=3).sort((m,f)=>f.accuracy-m.accuracy)},[t]),l=j.useMemo(()=>{const h=new Map;t.forEach(f=>{const b=f.created_at.slice(0,10),_=h.get(b)||[];_.push(f),h.set(b,_)});const m=[];return h.forEach((f,b)=>{const _=new Map;f.forEach(T=>{const A=_.get(T.symbol)||[];let B=!1;for(const z of A){const U=new Date(z[0].created_at).getTime(),G=new Date(T.created_at).getTime();if(Math.abs(G-U)<30*60*1e3){z.push(T),B=!0;break}}B||A.push([T]),_.set(T.symbol,A)});let y=0,N=0,w=0,g=0;_.forEach(T=>{T.forEach(A=>{if(A.length>=2){let B=0,z=0;A.forEach($=>{const L=($.confidence||50)/100;$.signal.toLowerCase().includes("bull")||$.signal.toLowerCase()==="buy"?B+=L:z+=L});const U=B>z;A.filter($=>($.signal.toLowerCase().includes("bull")||$.signal.toLowerCase()==="buy")===U?$.is_correct:!$.is_correct).length>A.length/2&&y++,N++,A.forEach($=>{$.is_correct&&w++,g++})}})});const k=new Map;f.forEach(T=>{const A=k.get(T.agent_id)||{correct:0,total:0};A.total++,T.is_correct&&A.correct++,k.set(T.agent_id,A)});let M=0;
116k.forEach(T=>{if(T.total>=2){const A=T.correct/T.total*100;A>M&&(M=A)}}),N>0&&m.push({date:b,ensembleAccuracy:y/N*100,avgAgentAccuracy:g>0?w/g*100:0,bestAgentAccuracy:M,ensembleSignals:N,ensembleCorrect:y})}),m.sort((f,b)=>f.date.localeCompare(b.date))},[t]),o=j.useMemo(()=>{const h=l.length>0?l.reduce((N,w)=>N+w.ensembleAccuracy,0)/l.length:0,m=l.length>0?l.reduce((N,w)=>N+w.avgAgentAccuracy,0)/l.length:0,f=l.length>0?l.reduce((N,w)=>N+w.bestAgentAccuracy,0)/l.length:0,b=h-m,_=l.reduce((N,w)=>N+w.ensembleSignals,0),y=l.reduce((N,w)=>N+w.ensembleCorrect,0);return{avgEnsembleAccuracy:h,avgAgentAccuracy:m,avgBestAgentAccuracy:f,ensembleAdvantage:b,totalSignals:t.length,totalEnsembleSignals:_,totalEnsembleCorrect:y,daysTracked:l.length}},[l,t]),u=j.useMemo(()=>l.map(h=>({date:h.date.slice(5),ensemble:Math.round(h.ensembleAccuracy),avgAgent:Math.round(h.avgAgentAccuracy),bestAgent:Math.round(h.bestAgentAccuracy)})),[l]),v=j.useMemo(()=>i.slice(0,8).map(h=>({name:h.agentName.length>10?h.agentName.slice(0,10)+"...":h.agentName,accuracy:Math.round(h.accuracy),signals:h.totalSignals})),[i]);return e.jsxs(q,{className:"border-border/50 bg-card/30",children:[e.jsx(X,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Y,{className:"text-base flex items-center gap-2",children:[e.jsx(Ls,{className:"w-4 h-4 text-primary"}),"Ensemble Performance History"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[["7d","30d","90d"].map(h=>e.jsx(W,{variant:n===h?"default":"outline",size:"sm",onClick:()=>c(h),className:"h-6 text-[10px] px-2",children:h},h)),e.jsx(W,{variant:"ghost",size:"sm",onClick:d,disabled:a,className:"h-6 w-6 p-0",children:e.jsx(Me,{className:O("w-3 h-3",a&&"animate-spin")})})]})]})}
116),e.jsxs(H,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:[e.jsxs("div",{className:"bg-primary/10 rounded-lg p-3 text-center border border-primary/20",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1 mb-1",children:[e.jsx(us,{className:"w-3 h-3 text-primary"}),e.jsx("span",{className:"text-[10px] text-primary",children:"ENSEMBLE"})]}),e.jsxs("div",{className:"text-xl font-bold text-primary",children:[o.avgEnsembleAccuracy.toFixed(1),"%"]}),e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"Avg Accuracy"})]}),e.jsxs("div",{className:"bg-background/50 rounded-lg p-3 text-center border border-border/30",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1 mb-1",children:[e.jsx(Ke,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"AVG AGENT"})]}),e.jsxs("div",{className:"text-xl font-bold",children:[o.avgAgentAccuracy.toFixed(1),"%"]}),e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"Avg Accuracy"})]}),e.jsxs("div",{className:"bg-background/50 rounded-lg p-3 text-center border border-border/30",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1 mb-1",children:[e.jsx(Qt,{className:"w-3 h-3 text-amber-400"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"BEST AGENT"})]}),e.jsxs("div",{className:"text-xl font-bold text-amber-400",children:[o.avgBestAgentAccuracy.toFixed(1),"%"]}),e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"Avg Accuracy"})]}),e.jsxs("div",{className:O("rounded-lg p-3 text-center border",o.ensembleAdvantage>0?"bg-emerald-500/10 border-emerald-500/20":"bg-red-500/10 border-red-500/20"),children:[e.jsxs("div",{className:"flex items-center justify-center gap-1 mb-1",children:[o.ensembleAdvantage>0?e.jsx(Ks,{className:"w-3 h-3 text-emerald-400"}):e.jsx(Ta,{className:"w-3 h-3 text-red-400"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"ADVANTAGE"})]}),e.jsxs("div",{className:O("text-xl font-bold",o.ensembleAdvantage>0?"text-emerald-400":"text-red-400"),children:[o.ensembleAdvantage>0?"+":"",o.ensembleAdvantage.toFixed(1),"%"]}),e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"vs Avg Agent"})]})]}),u.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"text-xs font-semibold text-muted-foreground flex items-center gap-1",children:[e.jsx(gt,{className:"w-3 h-3"}),"Accuracy Over Time"]}),e.jsx("div",{className:"h-[160px] bg-background/30 rounded-lg p-2",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(At,{data:u,children:[e.jsx(de,{dataKey:"date",tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"},axisLine:!1,tickLine:!1}),e.jsx(oe,{domain:[0,100],tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"},axisLine:!1,tickLine:!1,width:30}),e.jsx(Ne,{contentStyle:{background:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"6px",fontSize:"10px"},formatter:h=>[`${h}%`,""]}),e.jsx(ga,{wrapperStyle:{fontSize:"10px"},iconSize:8}),e.jsx(Fe,{type:"monotone",dataKey:"ensemble",name:"Ensemble",stroke:"hsl(var(--primary))",strokeWidth:2,dot:!1}),e.jsx(Fe,{type:"monotone",dataKey:"avgAgent",name:"Avg Agent",stroke:"hsl(var(--muted-foreground))",strokeWidth:1,strokeDasharray:"3 3",dot:!1}),e.jsx(Fe,{type:"monotone",dataKey:"bestAgent",name:"Best Agent",stroke:"#f59e0b",strokeWidth:1,dot:!1})]})})})]}),v.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"text-xs font-semibold text-muted-foreground flex items-center gap-1",children:[e.jsx(Qt,{className:"w-3 h-3"}),"Top Agents by Accuracy"]}),e.jsx("div",{className:"h-[120px] bg-background/30 rounded-lg p-2",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(ot,{data:v,layout:"vertical",children:[e.jsx(de,{type:"number",domain:[0,100],tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"},axisLine:!1,tickLine:!1}),e.jsx(oe,{type:"category",dataKey:"name",tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"}
116,axisLine:!1,tickLine:!1,width:70}),e.jsx(Ne,{contentStyle:{background:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"6px",fontSize:"10px"},formatter:(h,m)=>[m==="accuracy"?`${h}%`:h,m==="accuracy"?"Accuracy":"Signals"]}),e.jsx(Ye,{dataKey:"accuracy",radius:[0,4,4,0],children:v.map((h,m)=>e.jsx(rt,{fill:m===0?"#f59e0b":m===1?"#94a3b8":m===2?"#cd7f32":"hsl(var(--primary))",fillOpacity:m<3?.9:.5},m))})]})})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[e.jsxs("div",{className:"bg-background/50 rounded-lg p-2",children:[e.jsx("div",{className:"text-sm font-bold",children:o.daysTracked}),e.jsxs("div",{className:"text-[9px] text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Zt,{className:"w-2.5 h-2.5"})," Days Tracked"]})]}),e.jsxs("div",{className:"bg-background/50 rounded-lg p-2",children:[e.jsx("div",{className:"text-sm font-bold",children:o.totalSignals}),e.jsxs("div",{className:"text-[9px] text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(pe,{className:"w-2.5 h-2.5"})," Total Signals"]})]}),e.jsxs("div",{className:"bg-background/50 rounded-lg p-2",children:[e.jsx("div",{className:"text-sm font-bold",children:i.length}),e.jsxs("div",{className:"text-[9px] text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Ke,{className:"w-2.5 h-2.5"})," Active Agents"]})]})]}),t.length===0&&!a&&e.jsxs("div",{className:"text-center py-6 text-xs text-muted-foreground",children:[e.jsx(Ls,{className:"w-8 h-8 mx-auto mb-2 opacity-30"}),"No historical signal data available for this time range"]})]})]})}const Ve={trending:{label:"Trending",color:"#10b981",icon:he,numericValue:4},ranging:{label:"Ranging",color:"#3b82f6",icon:Zs,numericValue:2},volatile:{label:"Volatile",color:"#f59e0b",icon:pe,numericValue:3},low_volatility:{label:"Low Vol",color:"#06b6d4",icon:ge,numericValue:1},crisis:{label:"Crisis",color:"#ef4444",icon:ke,numericValue:5}},hr={trending:"Trending Market",ranging:"Ranging Market",volatile:"High Volatility",low_volatility:"Aggressive",crisis:"Conservative"};function zc({symbol:t="BTC"}){var m,f;const[s,a]=j.useState([]),[r,n]=j.useState([]),[c,d]=j.useState(!1),[i,l]=j.useState("7d");j.useEffect(()=>{o()},[t,i]);const o=async()=>{d(!0);try{const b=new Date;let _,y;switch(i){case"24h":_=new Date(b.getTime()-24*60*60*1e3),y=1;break;case"7d":_=new Date(b.getTime()-7*24*60*60*1e3),y=6;break;case"30d":_=new Date(b.getTime()-30*24*60*60*1e3),y=24;break}const{data:N}=await ue.from("market_snapshots").select("price, change_percent, created_at").eq("symbol",t).gte("created_at",_.toISOString()).order("created_at",{ascending:!0}),w=[],g=i==="24h"?24:i==="7d"?28:30;for(let M=0;M<g;M++){const T=new Date(_.getTime()+M*y*60*60*1e3),B=((N==null?void 0:N.filter(F=>{const R=new Date(F.created_at).getTime(),Q=T.getTime();return Math.abs(R-Q)<y*60*60*1e3}))||[]).map(F=>Math.abs(Number(F.change_percent)||0)),z=B.length>0?B.reduce((F,R)=>F+R,0)/B.length:Math.random()*3+1,K=((T.getTime()/1e6*9301+49297)%233280/233280-.5)*6,$=Math.abs(K)/3;let L,D;z>3?(L="volatile",D=Math.min(90,65+z*5)):z>2&&Math.abs(K)>2?(L="crisis",D=Math.min(85,60+z*3)):$>.5?(L="trending",D=Math.min(88,55+$*30)):z<1.2?(L="low_volatility",D=Math.min(82,50+(1.5-z)*25)):(L="ranging",D=Math.min(78,45+(1-$)*20)),w.push({timestamp:T.toISOString(),regime:L,confidence:D,volatility:z,momentum:K,suggestedPreset:hr[L]})}a(w);const k=[];for(let M=1;M<w.length;M++)w[M].regime!==w[M-1].regime&&k.push({from:w[M-1].regime,to:w[M].regime,timestamp:w[M].timestamp,preset:hr[w[M].regime]});n(k)}catch(b){console.error("Error generating regime history:",b)}d(!1)},u=j.useMemo(()=>s.map(b=>({time:new Date(b.timestamp).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:i==="24h"?"2-digit":void 0}),regimeValue:Ve[b.regime].numericValue,regime:b.regime,confidence:b.confidence,volatility:b.volatility*10,momentum:(b.momentum+3)*10,preset:b.suggestedPreset})),[s,i]),v=j.useMemo(()=>{const b={trending:0,ranging:0,volatile:0,low_volatility:0,crisis:0};s.forEach(y=>b[y.regime]++);const _=s.length||1;return Object.entries(b).map(([y,N])=>({regime:y,percentage:Math.round(N/_*100)})).sort((y,N)=>N.percentage-y.percentage)},[s]),h=b=>{const _=Object.entries(Ve).find(([,y])=>y.numericValue===b);return _?_[1].label:""};return e.jsxs(q,{className:"border-border/50 bg-card/30",children:[e.jsx(X,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Y,{className:"text-base flex items-center gap-2",children:[e.jsx(Ls,{className:"w-4 h-4 text-primary"}),"Regime Transition History"]}),e.jsxs("div",{className:"flex items-center gap-1",children:[["24h","7d","30d"].map(b=>e.jsx(W,{variant:i===b?"default":"ghost",size:"sm",onClick:()=>l(b),className:"h-6 text-[10px] px-2",children:b}
116,b)),e.jsx(W,{variant:"ghost",size:"sm",onClick:o,disabled:c,className:"h-6 w-6 p-0 ml-1",children:e.jsx(Me,{className:O("w-3 h-3",c&&"animate-spin")})})]})]})}),e.jsxs(H,{className:"space-y-4",children:[e.jsx("div",{className:"h-[160px]",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(Ot,{data:u,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"regimeGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--primary))",stopOpacity:.4}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--primary))",stopOpacity:0})]})}),e.jsx(Fa,{strokeDasharray:"3 3",stroke:"hsl(var(--border))",opacity:.3}),e.jsx(de,{dataKey:"time",tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"},tickLine:!1,axisLine:!1}),e.jsx(oe,{domain:[0,6],tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"},tickLine:!1,axisLine:!1,tickFormatter:h,width:50}),e.jsx(Ne,{content:({active:b,payload:_})=>{if(b&&_&&_.length){const y=_[0].payload;return e.jsxs("div",{className:"bg-popover border border-border rounded-lg p-2 text-xs shadow-lg",children:[e.jsx("div",{className:"font-semibold mb-1",children:y.time}),e.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:Ve[y.regime].color}}),e.jsx("span",{children:Ve[y.regime].label})]}),e.jsxs("div",{className:"text-muted-foreground",children:["Confidence: ",y.confidence.toFixed(0),"%"]}),e.jsxs("div",{className:"text-muted-foreground",children:["Preset: ",y.preset]})]})}return null}}),e.jsx(We,{type:"stepAfter",dataKey:"regimeValue",stroke:"hsl(var(--primary))",fill:"url(#regimeGradient)",strokeWidth:2}),Object.entries(Ve).map(([b,_])=>e.jsx(fe,{y:_.numericValue,stroke:_.color,strokeDasharray:"3 3",strokeOpacity:.3},b))]})})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Regime Distribution (",i,")"]}),e.jsx("div",{className:"flex gap-1 h-3 rounded-full overflow-hidden",children:v.filter(b=>b.percentage>0).map(({regime:b,percentage:_})=>e.jsx("div",{className:"h-full transition-all",style:{width:`${_}%`,backgroundColor:Ve[b].color},title:`${Ve[b].label}: ${_}%`},b))}),e.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:v.filter(b=>b.percentage>0).map(({regime:b,percentage:_})=>e.jsxs("div",{className:"flex items-center gap-1 text-[10px]",children:[e.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:Ve[b].color}}),e.jsx("span",{className:"text-muted-foreground",children:Ve[b].label}),e.jsxs("span",{className:"font-mono",children:[_,"%"]})]},b))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Recent Transitions"}),e.jsxs(C,{variant:"outline",className:"text-[9px] h-4",children:[r.length," changes"]})]}),e.jsxs("div",{className:"space-y-1 max-h-[100px] overflow-y-auto",children:[r.slice(-5).reverse().map((b,_)=>{const y=Ve[b.from].icon,N=Ve[b.to].icon;return e.jsxs("div",{className:"flex items-center gap-2 p-1.5 rounded bg-background/50 text-[10px]",children:[e.jsx(Zt,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:new Date(b.timestamp).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}),e.jsxs("div",{className:"flex items-center gap-1 ml-auto",children:[e.jsx(y,{className:"w-3 h-3",style:{color:Ve[b.from].color}}),e.jsx("span",{style:{color:Ve[b.from].color},children:Ve[b.from].label}),e.jsx(Ht,{className:"w-3 h-3 text-muted-foreground"}),e.jsx(N,{className:"w-3 h-3",style:{color:Ve[b.to].color}}),e.jsx("span",{style:{color:Ve[b.to].color},children:Ve[b.to].label})]})]},_)}),r.length===0&&e.jsx("div",{className:"text-center py-2 text-[10px] text-muted-foreground",children:"No regime transitions in this period"})]})]}),e.jsxs("div",{className:"bg-muted/30 rounded-lg p-2 text-[10px] text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[e.jsx(ge,{className:"w-3 h-3"}),e.jsx("span",{className:"font-semibold",children:"Preset Adaptations"})]}),e.jsxs("p",{children:["Over ",i,", the ensemble auto-adapted ",r.length," times, optimizing for ",(m=v[0])!=null&&m.regime?Ve[v[0].regime].label:"balanced"," conditions (",((f=v[0])==null?void 0:f.percentage)||0,"% of the time)."]})]})]})]})}const je={trending:{label:"Trending",color:"#10b981",icon:he,preset:"Trending Market"}
116,ranging:{label:"Ranging",color:"#3b82f6",icon:Zs,preset:"Ranging Market"},volatile:{label:"Volatile",color:"#f59e0b",icon:pe,preset:"High Volatility"},low_volatility:{label:"Low Vol",color:"#06b6d4",icon:ge,preset:"Aggressive"},crisis:{label:"Crisis",color:"#ef4444",icon:ke,preset:"Conservative"}},Vt=["trending","ranging","volatile","low_volatility","crisis"];function $c({symbol:t="BTC",currentRegime:s}){var v,h,m;const[a,r]=j.useState(null),[n,c]=j.useState(!1),[d,i]=j.useState("4h"),l=j.useCallback(async()=>{c(!0);try{const{data:f}=await ue.from("market_snapshots").select("price, change_percent, created_at").eq("symbol",t).order("created_at",{ascending:!0}).limit(500),{data:b}=await ue.from("agent_signals").select("signal, confidence, created_at").eq("symbol",t).order("created_at",{ascending:!1}).limit(100),_=[],y=10,N=(f==null?void 0:f.map(E=>Number(E.price)))||[],w=(f==null?void 0:f.map(E=>Number(E.change_percent)||0))||[];for(let E=y;E<w.length;E++){const te=w.slice(E-y,E),Z=te.reduce((ce,p)=>ce+p,0)/y,I=te.reduce((ce,p)=>ce+Math.pow(p-Z,2),0)/y,V=Math.sqrt(I),J=N.slice(E-y,E),_e=J.length>1?(J[J.length-1]-J[0])/J[0]*100:0,ft=Math.abs(_e)/(V+.1);let tt;V>3?tt="volatile":V>2&&Math.abs(_e)>3?tt="crisis":ft>1.5?tt="trending":V<1?tt="low_volatility":tt="ranging",_.push(tt)}const g={};Vt.forEach(E=>{g[E]={},Vt.forEach(te=>{g[E][te]=0})});for(let E=1;E<_.length;E++){const te=_[E-1],Z=_[E];g[te][Z]++}const k={};Vt.forEach(E=>{k[E]={};const te=Object.values(g[E]).reduce((Z,I)=>Z+I,0)||1;Vt.forEach(Z=>{k[E][Z]=g[E][Z]/te})});const M=s||_[_.length-1]||"ranging",T=w.slice(-20),A=T.length>0?Math.sqrt(T.reduce((E,te)=>E+te*te,0)/T.length):2,B=Math.min(90,50+1/(A+.5)*30),z=k[M]||{},U=Vt.map(E=>({regime:E,probability:(z[E]||.2)*100})).sort((E,te)=>te.probability-E.probability),G=d==="1h"?.7:d==="4h"?1:1.3,K=(b==null?void 0:b.filter(E=>E.signal.toLowerCase().includes("bull")||E.signal.toLowerCase()==="buy").length)||0,$=(b==null?void 0:b.filter(E=>E.signal.toLowerCase().includes("bear")||E.signal.toLowerCase()==="sell").length)||0,L=(K-$)/Math.max(1,K+$),D=U.slice(0,4).map((E,te)=>{let Z=E.probability*G;E.regime==="trending"&&L>.3&&(Z*=1.2),E.regime==="crisis"&&L<-.3&&(Z*=1.15),E.regime==="ranging"&&Math.abs(L)<.1&&(Z*=1.1),Z=Math.min(95,Math.max(5,Z));const I=Z>40?"high":Z>25?"medium":"low",V={trending:"Strong directional momentum in recent signals with increasing confidence levels",ranging:"Mixed signals and low trend strength suggest consolidation phase",volatile:"Elevated price swings and divergent agent opinions indicate uncertainty",low_volatility:"Compressed ranges and consistent signals point to stability",crisis:"High fear signals with correlation spike suggest defensive positioning"};return{regime:E.regime,probability:Math.round(Z),timeframe:d,confidence:I,reasoning:V[E.regime]}}),F=D.reduce((E,te)=>E+te.probability,0);D.forEach(E=>{E.probability=Math.round(E.probability/F*100)});const R=Vt.map(E=>{const te=Object.values(k[E]||{});return Math.max(...te,0)}),Q=Math.round(R.reduce((E,te)=>E+te,0)/R.length*100),x=D[0];let S="";x.regime===M?S=`Maintain ${je[M].preset} preset. Current regime likely to persist.`:x.probability>35?S=`Prepare to switch to ${je[x.regime].preset} preset. ${x.probability}% probability of regime change.`:S="Monitor closely. No dominant regime signal detected. Consider Balanced preset.",r({currentRegime:M,currentConfidence:B,predictions:D,transitionMatrix:k,historicalAccuracy:Q,recommendedAction:S})}catch(f){console.error("Prediction error:",f),r({currentRegime:"ranging",currentConfidence:60,predictions:[{regime:"ranging",probability:35,timeframe:d,confidence:"medium",reasoning:"Default fallback prediction"},{regime:"trending",probability:25,timeframe:d,confidence:"low",reasoning:"Insufficient data for analysis"},{regime:"volatile",probability:20,timeframe:d,confidence:"low",reasoning:"Market uncertainty detected"},{regime:"low_volatility",probability:20,timeframe:d,confidence:"low",reasoning:"Possible consolidation"}],transitionMatrix:{},historicalAccuracy:55,recommendedAction:"Insufficient data. Using balanced preset recommended."})}c(!1)},[t,d,s]);j.useEffect(()=>{l()},[l]);const o=j.useMemo(()=>a?a.predictions.map(f=>({regime:je[f.regime].label,probability:f.probability,color:je[f.regime].color})):[],[a]),u=f=>({high:"bg-emerald-500/20 text-emerald-400 border-emerald-500/30",medium:"bg-amber-500/20 text-amber-400 border-amber-500/30",low:"bg-muted text-muted-foreground border-muted"})[f];return e.jsxs(q,{className:"border-border/50 bg-card/30",children:[e.jsx(X,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Y,{className:"text-base flex items-center gap-2",children:[e.jsx(Zr,{className:"w-4 h-4 text-primary"}),"Regime Prediction",e.jsxs(C,{variant:"outline",className:"text-[9px] h-4 bg-primary/10 text-primary border-primary/30",children:[e.jsx(lt,{className:"w-2.5 h-2.5 mr-0.5"})," ML"]})]}),e.jsx("div",{className:"flex items-center gap-1",children:e.jsx(W,{variant:"ghost",size:"sm",onClick:l,disabled:n,className:"h-5 w-5 p-0 ml-1",children:e.jsx(Me,{className:O("w-3 h-3",n&&"animate-spin")})})})]})}
116),e.jsxs(H,{className:"space-y-4",children:[a&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:O("p-3 rounded-lg border flex items-center gap-3",`bg-[${je[a.currentRegime].color}]/10`,`border-[${je[a.currentRegime].color}]/30`),style:{backgroundColor:`${je[a.currentRegime].color}15`,borderColor:`${je[a.currentRegime].color}40`},children:[(()=>{const f=je[a.currentRegime].icon;return e.jsx(f,{className:"w-5 h-5",style:{color:je[a.currentRegime].color}})})(),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Current Regime"}),e.jsx("div",{className:"font-semibold",style:{color:je[a.currentRegime].color},children:je[a.currentRegime].label})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Confidence"}),e.jsxs("div",{className:"font-mono text-sm",children:[a.currentConfidence.toFixed(0),"%"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(dt,{className:"w-3 h-3"}),e.jsxs("span",{children:["Next ",d," Forecast"]})]}),e.jsx("div",{className:"h-[100px]",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(ot,{data:o,layout:"vertical",children:[e.jsx(Fa,{strokeDasharray:"3 3",stroke:"hsl(var(--border))",opacity:.3,horizontal:!1}),e.jsx(de,{type:"number",domain:[0,100],tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"},tickLine:!1,axisLine:!1}),e.jsx(oe,{type:"category",dataKey:"regime",tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"},tickLine:!1,axisLine:!1,width:60}),e.jsx(Ne,{content:({active:f,payload:b})=>{if(f&&b&&b.length){const _=b[0].payload;return e.jsxs("div",{className:"bg-popover border border-border rounded-lg p-2 text-xs shadow-lg",children:[e.jsx("div",{className:"font-semibold",children:_.regime}),e.jsxs("div",{children:["Probability: ",_.probability,"%"]})]})}return null}}),e.jsx(Ye,{dataKey:"probability",radius:[0,4,4,0],children:o.map((f,b)=>e.jsx(rt,{fill:f.color,fillOpacity:.8},b))})]})})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Predicted Transitions"}),e.jsx("div",{className:"space-y-1.5",children:a.predictions.slice(0,3).map((f,b)=>{const _=je[f.regime].icon,y=b===0;return e.jsxs("div",{className:O("p-2 rounded-lg border transition-all",y?"bg-primary/5 border-primary/30":"bg-background/50 border-border/30"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{className:"w-3.5 h-3.5",style:{color:je[f.regime].color}}),e.jsx("span",{className:"text-xs font-medium flex-1",children:je[f.regime].label}),e.jsx(C,{variant:"outline",className:O("text-[8px] h-4",u(f.confidence)),children:f.confidence}),e.jsxs("span",{className:"text-sm font-bold font-mono",style:{color:je[f.regime].color},children:[f.probability,"%"]})]}),y&&e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1 pl-5",children:f.reasoning})]},f.regime)})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"bg-background/50 rounded-lg p-2 text-center",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Model Accuracy"}),e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(Be,{className:"w-3 h-3 text-primary"}),e.jsxs("span",{className:"font-mono text-sm font-semibold",children:[a.historicalAccuracy,"%"]})]})]}),e.jsxs("div",{className:"bg-background/50 rounded-lg p-2 text-center",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Transitions Analyzed"}),e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(ge,{className:"w-3 h-3 text-primary"}),e.jsx("span",{className:"font-mono text-sm font-semibold",children:Object.values(a.transitionMatrix).reduce((f,b)=>f+Object.values(b).reduce((_,y)=>_+y,0),0).toFixed(0)})]})]})]}),e.jsx("div",{className:O("p-3 rounded-lg border",((v=a.predictions[0])==null?void 0:v.probability)>35?"bg-primary/5 border-primary/30":"bg-muted/30 border-muted"),children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(_t,{className:"w-4 h-4 text-primary mt-0.5"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-semibold mb-1",children:"Recommended Action"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a.recommendedAction})]})]})}),((h=a.predictions[0])==null?void 0:h.regime)!==a.currentRegime&&((m=a.predictions[0])==null?void 0:m.probability)>30&&e.jsx("div",{className:"flex items-center justify-center gap-2 py-2",children:(()=>{const f=je[a.currentRegime].icon,b=je[a.predictions[0].regime].icon;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 rounded-lg",style:{backgroundColor:`${je[a.currentRegime].color}20`},children:[e.jsx(f,{className:"w-3 h-3",style:{color:je[a.currentRegime].color}}),e.jsx("span",{className:"text-[10px]",style:{color:je[a.currentRegime].color},children:je[a.currentRegime].label})]}),e.jsx(qs,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 rounded-lg",style:{backgroundColor:`${je[a.predictions[0].regime].color}20`},children:[e.jsx(b,{className:"w-3 h-3",style:{color:je[a.predictions[0].regime].color}}),e.jsx("span",{className:"text-[10px]",style:{color:je[a.predictions[0].regime].color},children:je[a.predictions[0].regime].label})]}),e.jsxs(C,{variant:"outline",className:"text-[8px] h-4 ml-1",children:[a.predictions[0].probability,"%"]})]})})()})]}),n&&!a&&e.jsxs("div",{className:"flex items-center justify-center py-8",children:[e.jsx(Me,{className:"w-5 h-5 animate-spin text-primary"}),e.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:"Analyzing patterns..."})]})]})]})}const Ms=["RSI oversold + MACD crossover detected","Momentum breakout above resistance","Mean reversion signal at 2Ï band","Volume surge with price confirmation","Trend continuation pattern identified","Support level bounce confirmed","Sentiment shift detected in social data","Volatility compression breakout"];function Vc({isActive:t=!0,ticker:s="BTC"}){const[a,r]=j.useState([]),[n,c]=j.useState(!1);j.useEffect(()=>{if(!t)return;const l=Array.from({length:3},(u,v)=>({id:`sig-${v}`,ticker:s,direction:["BUY","SELL","HOLD"][Math.floor(Math.random()*3)],confidence:Math.floor(60+Math.random()*35),price:s==="BTC"?98e3+Math.random()*2e3:100+Math.random()*50,timestamp:new Date(Date.now()-v*3e4),reason:Ms[Math.floor(Math.random()*Ms.length)]}));r(l),c(!0);const o=setInterval(()=>{const u={id:`sig-${Date.now()}`,ticker:s,direction:["BUY","SELL","HOLD"][Math.floor(Math.random()*3)],confidence:Math.floor(60+Math.random()*35),price:s==="BTC"?98e3+Math.random()*2e3:100+Math.random()*50,timestamp:new Date,reason:Ms[Math.floor(Math.random()*Ms.length)]};r(v=>[u,...v.slice(0,4)])},8e3);return()=>clearInterval(o)},[t,s]);const d=l=>{switch(l){case"BUY":return e.jsx(he,{className:"h-4 w-4 text-emerald-400"});case"SELL":return e.jsx(ke,{className:"h-4 w-4 text-red-400"});default:return e.jsx(Sa,{className:"h-4 w-4 text-yellow-400"})}},i=l=>{switch(l){case"BUY":return"bg-emerald-500/20 text-emerald-400 border-emerald-500/30";case"SELL":return"bg-red-500/20 text-red-400 border-red-500/30";default:return"bg-yellow-500/20 text-yellow-400 border-yellow-500/30"}};return e.jsxs(q,{className:"border-cyan-400/30 bg-gradient-to-br from-background via-cyan-500/5 to-primary/5",children:[e.jsx(X,{className:"pb-2",children:e.jsxs(Y,{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-gradient-to-br from-cyan-400/20 to-primary/20 border border-cyan-400/30",children:e.jsx(Ca,{className:"h-4 w-4 text-cyan-400"})}),e.jsx("span",{className:"bg-gradient-to-r from-cyan-400 to-primary bg-clip-text text-transparent font-bold",children:"Live Signal Preview"})]}),e.jsx("div",{className:"flex items-center gap-2",children:n&&e.jsxs(C,{variant:"outline",className:"text-[10px] bg-emerald-500/20 text-emerald-400 border-emerald-500/30 animate-pulse",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 mr-1.5 animate-ping"}),"LIVE"]})})]})}),e.jsx(H,{className:"space-y-2",children:a.length===0?e.jsxs("div",{className:"text-center py-6 text-muted-foreground text-sm",children:[e.jsx(ge,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"Waiting for signals..."})]}):e.jsx("div",{className:"space-y-2 max-h-[280px] overflow-y-auto pr-1",children:a.map((l,o)=>e.jsxs("div",{className:O("p-3 rounded-lg border bg-background/50 transition-all",o===0&&"ring-1 ring-cyan-400/50 bg-cyan-400/5"),children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[d(l.direction),e.jsx(C,{className:O("text-xs font-bold",i(l.direction)),children:l.direction}),e.jsx("span",{className:"text-xs font-mono text-primary",children:l.ticker})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(C,{variant:"outline",className:"text-[10px]",children:[e.jsx(Be,{className:"h-3 w-3 mr-1"}),l.confidence,"%"]})})]}),e.jsxs("div",{className:"flex items-center justify-between text-[10px] text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(pe,{className:"h-3 w-3 text-cyan-400"}),l.reason]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(dt,{className:"h-3 w-3"}
116),l.timestamp.toLocaleTimeString()]})]})]},l.id))})})]})}const Wc=[{label:"Leaderboard",href:"/leaderboard",icon:Qt,color:"from-amber-400 to-orange-500"},{label:"Agents",href:"/agents",icon:Ke,color:"from-cyan-400 to-primary"},{label:"Signals",href:"/tape",icon:pe,color:"from-emerald-400 to-green-500"}];function qc(){return e.jsx("div",{className:"flex gap-1.5 flex-wrap",children:Wc.map(t=>{const s=t.icon;return e.jsxs(Hs,{to:t.href,className:"group flex items-center gap-1 px-1.5 py-0.5 rounded border border-border/40 bg-background/30 hover:border-primary/40 hover:bg-primary/5 transition-all",children:[e.jsx("div",{className:O("p-0.5 rounded bg-gradient-to-br",t.color),children:e.jsx(s,{className:"h-2.5 w-2.5 text-white"})}),e.jsx("span",{className:"text-[9px] font-medium text-foreground/70 group-hover:text-foreground",children:t.label})]},t.href)})})}const Wt=(t,s,a)=>{const r=[];let n=1e4;for(let c=0;c<=90;c++){const d=(Math.sin(t*c*.1)+Math.cos(t*c*.05))*s;n=n*(1+(a+d)/100),r.push({day:c,value:Math.round(n)})}return r},ca=[{id:"momentum_classic",name:"Classic Momentum",description:"Ride strong trends with RSI confirmation and tight stops",strategy_type:"momentum",difficulty:"beginner",icon:he,color:"emerald",theory:"Track price momentum using RSI indicators combined with volume confirmation. When RSI crosses above 30 from oversold territory with increasing volume, it signals a potential price reversal and buying opportunity.",winRate:58.2,sharpeRatio:1.42,avgReturn:2.8,maxDrawdown:12.4,tradeFrequency:"15-20/week",equityCurve:Wt(1,2,.3)},{id:"mean_reversion",name:"Bollinger Reversion",description:"Fade extremes using dynamic Bollinger Bands",strategy_type:"mean_reversion",difficulty:"intermediate",icon:ge,color:"blue",theory:"Monitor price deviation from the 20-day moving average using Bollinger Bands. When price touches the lower band with RSI below 30, expect mean reversion to the middle band.",winRate:62.5,sharpeRatio:1.68,avgReturn:1.9,maxDrawdown:8.7,tradeFrequency:"8-12/week",equityCurve:Wt(2,1.5,.25)},{id:"trend_macd",name:"MACD Trend Rider",description:"Follow trends with MACD crossover signals",strategy_type:"trend_following",difficulty:"intermediate",icon:pe,color:"purple",theory:"Use MACD histogram crossovers to identify trend changes. When MACD line crosses above signal line with positive histogram momentum, enter long positions for trend continuation.",winRate:54.8,sharpeRatio:1.85,avgReturn:4.2,maxDrawdown:15.3,tradeFrequency:"5-8/week",equityCurve:Wt(3,2.5,.4)},{id:"volatility_breakout",name:"Volatility Breakout",description:"Capture volatility expansion with ATR sizing",strategy_type:"volatility",difficulty:"advanced",icon:as,color:"amber",theory:"Monitor ATR (Average True Range) for volatility compression followed by expansion. When price breaks out of a tight range with ATR expanding above its 14-day average, expect significant directional move.",winRate:48.5,sharpeRatio:2.12,avgReturn:6.8,maxDrawdown:18.2,tradeFrequency:"3-5/week",equityCurve:Wt(4,3.5,.5)},{id:"multi_factor",name:"Multi-Factor Alpha",description:"Institutional approach combining multiple signals",strategy_type:"multi_factor",difficulty:"advanced",icon:lt,color:"rose",theory:"Combine momentum (RSI), trend (MACD), and volatility (Bollinger) factors with sentiment analysis. Generate signals only when 3+ factors align for high-conviction trades.",winRate:65.3,sharpeRatio:2.35,avgReturn:3.5,maxDrawdown:10.1,tradeFrequency:"2-4/week",equityCurve:Wt(5,1.8,.35)},{id:"risk_parity",name:"Risk Parity",description:"Equal risk contribution for balanced portfolios",strategy_type:"multi_factor",difficulty:"advanced",icon:Ce,color:"cyan",theory:"Allocate capital based on inverse volatility to achieve equal risk contribution across assets. Rebalance when any position risk exceeds 25% of total portfolio risk budget.",winRate:56.8,sharpeRatio:1.92,avgReturn:2.1,maxDrawdown:6.5,tradeFrequency:"1-2/week",equityCurve:Wt(6,1.2,.2)}],pr={beginner:"bg-green-500/20 text-green-400 border-green-500/30",intermediate:"bg-amber-500/20 text-amber-400 border-amber-500/30",advanced:"bg-red-500/20 text-red-400 border-red-500/30"},gr={emerald:"from-emerald-500/20 to-emerald-500/5 border-emerald-500/30 hover:border-emerald-400/50",blue:"from-blue-500/20 to-blue-500/5 border-blue-500/30 hover:border-blue-400/50",purple:"from-purple-500/20 to-purple-500/5 border-purple-500/30 hover:border-purple-400/50",amber:"from-amber-500/20 to-amber-500/5 border-amber-500/30 hover:border-amber-400/50",rose:"from-rose-500/20 to-rose-500/5 border-rose-500/30 hover:border-rose-400/50",cyan:"from-cyan-500/20 to-cyan-500/5 border-cyan-500/30 hover:border-cyan-400/50"},fr={emerald:"text-emerald-400",blue:"text-blue-400",purple:"text-purple-400",amber:"text-amber-400",rose:"text-rose-400",cyan:"text-cyan-400"};function Hc({onSelectTemplate:t}){const[s,a]=j.useState([]),[r,n]=j.useState(!1),c=l=>{a(o=>o.includes(l)?o.filter(u=>u!==l):o.length<3?[...o,l]:o)},d=ca.filter(l=>s.includes(l.id)),i=l=>l==="maxDrawdown"?Math.min(...d.map(o=>o[l])):Math.max(...d.map(o=>o[l]));return e.jsxs(e.Fragment,{children:[e.jsxs(q,{className:"border-primary/20 bg-gradient-to-br from-background to-primary/5",children:[e.jsx(X,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Y,{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-gradient-to-br from-violet-400/20 to-primary/20 border border-violet-400/30",children:e.jsx(St,{className:"h-4 w-4 text-violet-400"})}),e.jsx("span",{className:"bg-gradient-to-r from-violet-400 to-primary bg-clip-text text-transparent",children:"Strategy Templates"}),e.jsxs(C,{variant:"outline",className:"text-[10px] bg-primary/10 text-primary border-primary/30 ml-2",children:[ca.length," Ready"]})]}),s.length>=2&&e.jsxs(W,{size:"sm",onClick:()=>n(!0),className:"bg-gradient-to-r from-cyan-500 to-primary hover:from-cyan-400 hover:to-primary/90 shadow-md",children:[e.jsx(mt,{className:"w-4 h-4 mr-1"}),"Compare (",s.length,")"]})]})}),e.jsx(H,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:ca.map(l
116=>{const o=l.icon,u=s.includes(l.id);return e.jsxs("div",{className:O("relative p-4 rounded-xl border bg-gradient-to-br text-left transition-all group hover:shadow-lg hover:shadow-primary/10",gr[l.color],u&&"ring-2 ring-cyan-400"),children:[e.jsx("div",{className:"absolute top-2 right-2 z-10",onClick:v=>{v.stopPropagation(),c(l.id)},children:e.jsx(Gs,{checked:u,className:"h-5 w-5 border-primary/50 data-[state=checked]:bg-cyan-500 data-[state=checked]:border-cyan-500"})}),e.jsxs("button",{onClick:()=>t(l.theory),className:"w-full text-left",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-3",children:[e.jsx("div",{className:O("w-10 h-10 rounded-lg flex items-center justify-center shrink-0",`bg-${l.color}-500/30`),children:e.jsx(o,{className:O("w-5 h-5",fr[l.color])})}),e.jsxs("div",{className:"flex-1 min-w-0 pr-6",children:[e.jsx("h4",{className:"font-bold text-sm truncate",children:l.name}),e.jsx(C,{className:O("text-[9px] mt-1",pr[l.difficulty]),children:l.difficulty})]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground mb-3 line-clamp-2",children:l.description}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 pt-3 border-t border-border/30",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Qt,{className:"w-3 h-3 text-amber-400"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Win Rate:"}),e.jsxs("span",{className:"text-[10px] font-bold text-emerald-400",children:[l.winRate,"%"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(pe,{className:"w-3 h-3 text-cyan-400"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Sharpe:"}),e.jsx("span",{className:"text-[10px] font-bold text-cyan-400",children:l.sharpeRatio})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Gt,{className:"w-3 h-3 text-emerald-400"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Avg Ret:"}),e.jsxs("span",{className:"text-[10px] font-bold text-emerald-400",children:["+",l.avgReturn,"%"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Ce,{className:"w-3 h-3 text-red-400"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"MaxDD:"}),e.jsxs("span",{className:"text-[10px] font-bold text-red-400",children:["-",l.maxDrawdown,"%"]})]})]})]}),e.jsx("div",{className:"absolute bottom-3 right-3 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(_t,{className:"h-4 w-4 text-primary"})})]},l.id)})})})]}),e.jsx(Kt,{open:r,onOpenChange:n,children:e.jsxs(Ut,{className:"max-w-3xl bg-background border-primary/30",children:[e.jsx(Xt,{children:e.jsxs(Yt,{className:"flex items-center gap-2",children:[e.jsx(mt,{className:"w-5 h-5 text-cyan-400"}),e.jsx("span",{className:"bg-gradient-to-r from-cyan-400 to-primary bg-clip-text text-transparent",children:"Strategy Comparison"})]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid gap-4",style:{gridTemplateColumns:`repeat(${d.length}, 1fr)`},children:d.map(l=>{const o=l.icon;return e.jsxs("div",{className:O("p-4 rounded-xl border bg-gradient-to-br",gr[l.color]),children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(o,{className:O("w-5 h-5",fr[l.color])}),e.jsx("span",{className:"font-bold text-sm",children:l.name})]}),e.jsx(C,{className:O("text-[9px]",pr[l.difficulty]),children:l.difficulty})]},l.id)})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[e.jsx(Qt,{className:"w-4 h-4 text-amber-400"}),"Win Rate"]}),e.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${d.length}, 1fr)`},children:d.map(l=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-xs",children:[e.jsx("span",{className:"truncate",children:l.name}),e.jsxs("span",{className:O("font-bold",l.winRate===i("winRate")?"text-emerald-400":""),children:[l.winRate,"%",l.winRate===i("winRate")&&" â
"]})]}),e.jsx(Xe,{value:l.winRate,className:"h-2"})]},l.id))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[e.jsx(pe,{className:"w-4 h-4 text-cyan-400"}),"Sharpe Ratio"]}),e.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${d.length}, 1fr)`}
116,children:d.map(l=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-xs",children:[e.jsx("span",{className:"truncate",children:l.name}),e.jsxs("span",{className:O("font-bold",l.sharpeRatio===i("sharpeRatio")?"text-cyan-400":""),children:[l.sharpeRatio,l.sharpeRatio===i("sharpeRatio")&&" â
"]})]}),e.jsx(Xe,{value:l.sharpeRatio/3*100,className:"h-2"})]},l.id))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[e.jsx(Gt,{className:"w-4 h-4 text-emerald-400"}),"Average Return"]}),e.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${d.length}, 1fr)`},children:d.map(l=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-xs",children:[e.jsx("span",{className:"truncate",children:l.name}),e.jsxs("span",{className:O("font-bold",l.avgReturn===i("avgReturn")?"text-emerald-400":""),children:["+",l.avgReturn,"%",l.avgReturn===i("avgReturn")&&" â
"]})]}),e.jsx(Xe,{value:l.avgReturn/10*100,className:"h-2"})]},l.id))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[e.jsx(Ce,{className:"w-4 h-4 text-red-400"}),"Max Drawdown (Lower is Better)"]}),e.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${d.length}, 1fr)`},children:d.map(l=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-xs",children:[e.jsx("span",{className:"truncate",children:l.name}),e.jsxs("span",{className:O("font-bold",l.maxDrawdown===i("maxDrawdown")?"text-emerald-400":"text-red-400"),children:["-",l.maxDrawdown,"%",l.maxDrawdown===i("maxDrawdown")&&" â
"]})]}),e.jsx(Xe,{value:l.maxDrawdown/25*100,className:"h-2 [&>div]:bg-red-500"})]},l.id))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[e.jsx(Ma,{className:"w-4 h-4 text-primary"}),"Backtest Performance (90 Days)"]}),e.jsx("div",{className:"h-56 bg-background/50 rounded-lg p-3 border border-border/50",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(At,{children:[e.jsx(de,{dataKey:"day",tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"},tickLine:!1,axisLine:!1,tickFormatter:l=>`D${l}`,interval:15}),e.jsx(oe,{tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"},tickLine:!1,axisLine:!1,tickFormatter:l=>`$${(l/1e3).toFixed(0)}k`,domain:["dataMin - 500","dataMax + 500"]}),e.jsx(Ne,{contentStyle:{background:"hsl(var(--background))",border:"1px solid hsl(var(--border))",borderRadius:"8px",fontSize:"11px"},formatter:(l,o)=>[`$${l.toLocaleString()}`,o]}),d.map((l,o)=>e.jsx(Fe,{data:l.equityCurve,dataKey:"value",name:l.name,stroke:o===0?"#10b981":o===1?"#3b82f6":"#f59e0b",strokeWidth:2.5,dot:!1},l.id))]})})}),e.jsx("div",{className:"flex flex-wrap justify-center gap-4",children:d.map((l,o)=>{var h;const v=(((((h=l.equityCurve[l.equityCurve.length-1])==null?void 0:h.value)||1e4)-1e4)/1e4*100).toFixed(1);return e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:O("w-3 h-3 rounded-full",o===0?"bg-emerald-500":o===1?"bg-blue-500":"bg-amber-500")}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:l.name}),e.jsxs("span",{className:O("text-[10px] font-bold",Number(v)>0?"text-emerald-400":"text-red-400"),children:[Number(v)>0?"+":"",v,"%"]})]},l.id)})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[e.jsx(dt,{className:"w-4 h-4 text-violet-400"}),"Trade Frequency"]}),e.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${d.length}, 1fr)`},children:d.map(l=>e.jsx("div",{className:"p-2 rounded bg-background/50 text-center",children:e.jsx("span",{className:"text-xs font-medium",children:l.tradeFrequency})},l.id))})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(W,{variant:"outline",onClick:()=>n(!1),className:"flex-1",children:"Close"}),e.jsxs(W,{onClick:()=>
116{if(d.length>0){const l=d.reduce((o,u)=>o.sharpeRatio>u.sharpeRatio?o:u);t(l.theory),n(!1)}},className:"flex-1 bg-gradient-to-r from-cyan-500 to-primary hover:from-cyan-400 hover:to-primary/90",children:[e.jsx(_t,{className:"w-4 h-4 mr-2"}),"Use Best Strategy"]})]})]})]})})]})}const br=[{value:1,label:"Conservative",color:"text-emerald-400",strategy:"risk_parity"},{value:2,label:"Moderate",color:"text-cyan-400",strategy:"mean_reversion"},{value:3,label:"Balanced",color:"text-amber-400",strategy:"trend_following"},{value:4,label:"Growth",color:"text-orange-400",strategy:"momentum"},{value:5,label:"Aggressive",color:"text-rose-400",strategy:"volatility"}],Gc=[{id:"passive",label:"Passive",icon:Ce,desc:"1-2 trades/week",color:"from-emerald-500 to-green-600"},{id:"active",label:"Active",icon:he,desc:"5-10 trades/week",color:"from-cyan-500 to-blue-600"},{id:"aggressive",label:"Day Trader",icon:pe,desc:"15+ trades/week",color:"from-amber-500 to-orange-600"}],vr={"conservative-passive":{name:"Risk Parity Portfolio",theory:"Allocate capital based on inverse volatility to achieve equal risk contribution across assets. Rebalance when any position risk exceeds 25% of total portfolio risk budget.",match:95},"conservative-active":{name:"Bollinger Reversion",theory:"Monitor price deviation from the 20-day moving average using Bollinger Bands. When price touches the lower band with RSI below 30, expect mean reversion to the middle band.",match:88},"conservative-aggressive":{name:"Low-Vol Momentum",theory:"Track price momentum using RSI indicators combined with volume confirmation. Focus on low-volatility assets with tight stop-losse
116s.",match:72},"moderate-passive":{name:"Dividend Growth",theory:"Target dividend-paying stocks with consistent payout growth. Rebalance quarterly based on yield spread vs treasury rates.",match:91},"moderate-active":{name:"MACD Trend Rider",theory:"Use MACD histogram crossovers to identify trend changes. When MACD line crosses above signal line with positive histogram momentum, enter long positions.",match:89},"moderate-aggressive":{name:"Swing Momentum",theory:"Capture multi-day price swings using RSI divergence and support/resistance breakouts. Target 2-5 day holds with 2:1 reward-risk.",match:82},"balanced-passive":{name:"Multi-Asset Rotation",theory:"Rotate between stocks, bonds, and commodities based on relative strength. Monthly rebalancing with momentum confirmation.",match:90},"balanced-active":{name:"Multi-Factor Alpha",theory:"Combine momentum (RSI), trend (MACD), and volatility (Bollinger) factors with sentiment analysis. Generate signals only when 3+ factors align.",match:94},"balanced-aggressive":{name:"Breakout Hunter",theory:"Monitor ATR for volatility compression followed by expansion. Enter on price breakouts with expanding volume.",match:85},"growth-passive":{name:"Trend Following",theory:"Follow long-term trends using 50/200 day moving average crossovers. Hold positions for weeks to months.",match:87},"growth-active":{name:"Classic Momentum",theory:"Track price momentum using RSI indicators combined with volume confirmation. When RSI crosses above 30 from oversold territory, buy.",match:92},"growth-aggressive":{name:"Leveraged Momentum",theory:"Use leveraged ETFs during strong trending markets. Apply strict stop-losse
116s and position sizing rules.",match:78},"aggressive-passive":{name:"Contrarian Value",theory:"Buy oversold assets with strong fundamentals. Use extreme sentiment readings as entry signals.",match:75},"aggressive-active":{name:"Volatility Breakout",theory:"Monitor ATR for volatility compression followed by expansion. When price breaks out with ATR expanding above average, expect significant move.",match:88},"aggressive-aggressive":{name:"Scalping Alpha",theory:"High-frequency entries on micro price movements. Use order flow imbalances and bid-ask spread analysis.",match:83}};function Kc({onSelectStrategy:t}){const[s,a]=j.useState([3]),[r,n]=j.useState(null),c=br.find(l=>l.value===s[0])||br[2],i=(()=>{if(!r)return null;const l=`${c.label.toLowerCase()}-${r}`;return vr[l]||vr["balanced-active"]})();return e.jsxs(q,{className:"border-violet-500/30 bg-gradient-to-br from-violet-500/10 to-purple-500/5",children:[e.jsx(X,{className:"pb-2",children:e.jsxs(Y,{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-gradient-to-br from-violet-500 to-purple-600 shadow-lg",children:e.jsx(Zr,{className:"h-4 w-4 text-white"})}),e.jsx("span",{className:"text-foreground font-bold",children:"Strategy Recommendation Engine"})]})}
116),e.jsxs(H,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Risk Tolerance"}),e.jsx(C,{className:O("text-[10px]",c.color,"bg-background/50 border border-current/30"),children:c.label})]}),e.jsx(ee,{value:s,onValueChange:a,min:1,max:5,step:1,className:"py-2"}),e.jsxs("div",{className:"flex justify-between text-[9px] text-muted-foreground",children:[e.jsx("span",{children:"Safe"}),e.jsx("span",{children:"Aggressive"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Trading Style"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:Gc.map(l=>{const o=l.icon,u=r===l.id;return e.jsxs("button",{onClick:()=>n(l.id),className:O("p-2 rounded-lg border transition-all text-center",u?`bg-gradient-to-br ${l.color} border-transparent shadow-lg`:"border-border/50 bg-background/50 hover:border-primary/50"),children:[e.jsx(o,{className:O("h-4 w-4 mx-auto mb-1",u?"text-white":"text-muted-foreground")}),e.jsx("div",{className:O("text-[10px] font-semibold",u?"text-white":""),children:l.label}),e.jsx("div",{className:O("text-[8px]",u?"text-white/70":"text-muted-foreground"),children:l.desc})]},l.id)})})]}),i&&e.jsxs("div",{className:"p-3 rounded-xl bg-gradient-to-br from-primary/20 to-cyan-500/10 border border-primary/30",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Be,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-xs font-bold text-foreground",children:"Recommended Strategy"})]}),e.jsxs(C,{className:"bg-emerald-500/20 text-emerald-400 border-emerald-500/30 text-[10px]",children:[i.match,"% Match"]})]}),e.jsx("div",{className:"text-sm font-bold text-primary mb-1",children:i.name}),e.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-2 mb-3",children:i.theory}),e.jsxs(W,{size:"sm",onClick:()=>t(i.theory),className:"w-full bg-gradient-to-r from-primary to-cyan-500 hover:from-primary/90 hover:to-cyan-400 shadow-md",children:[e.jsx(_t,{className:"w-3 h-3 mr-1"}),"Use This Strategy",e.jsx(qs,{className:"w-3 h-3 ml-1"})]})]})]})]})}const As=[{id:1,title:"Risk",icon:Ce},{id:2,title:"Style",icon:ge},{id:3,title:"Level",icon:lt},{id:4,title:"Markets",icon:he},{id:5,title:"Signals",icon:as},{id:6,title:"Sizing",icon:bs},{id:7,title:"Stops",icon:Re},{id:8,title:"Filters",icon:Da},{id:9,title:"Risk Mgmt",icon:Us},{id:10,title:"Launch",icon:Ds}],Uc=[{value:"conservative",label:"Conservative",description:"Max 5% position, 10% drawdown limit",icon:Ce,color:"emerald"},{value:"moderate",label:"Moderate",description:"Up to 15% position, 20% drawdown limit",icon:Be,color:"blue"},{value:"aggressive",label:"Aggressive",description:"Up to 25% position, 35% drawdown tolerance",icon:pe,color:"amber"}],Xc=[{value:"position",label:"Position",description:"Weeks to months",frequency:"1-2 trades/month",icon:he},{value:"swing",label:"Swing",description:"Days to weeks",frequency:"2-5 trades/week",icon:ge},{value:"day",label:"Day Trading",description:"Intraday only",frequency:"5-15 trades/day",icon:dt},{value:"scalp",label:"Scalping",description:"Minutes to hours",frequency:"20-50 trades/day",icon:pe}],Yc=[{value:"beginner",label:"Beginner",description:"New to algorithmic trading"},{value:"intermediate",label:"Intermediate",description:"1-3 years experience"},{value:"advanced",label:"Advanced",description:"3-7 years, familiar with quant strategies"},{value:"expert",label:"Expert",description:"7+ years, institutional background"}],Qc=[{value:"crypto",label:"Crypto",icon:"â¿"},{value:"stocks",label:"Stocks",icon:"ð"},{value:"etfs",label:"ETFs",icon:"ð"},{value:"forex",label:"Forex",icon:"ð±"},{value:"commodities",label:"Commodities",icon:"ð¥"},{value:"indices",label:"Indices",icon:"ð"}],Zc=[{value:"rsi",label:"RSI",desc:"Momentum oscillator"},{value:"macd",label:"MACD",desc:"Trend following"},{value:"bollinger",label:"Bollinger Bands",desc:"Volatility bands"},{value:"ema",label:"EMA Crossover",desc:"Moving averages"},{value:"atr",label:"ATR",desc:"Volatility measure"},{value:"adx",label:"ADX",desc:"Trend strength"},{value:"stochastic",label:"Stochastic",desc:"Momentum"},{value:"volume",label:"Volume Profile",desc:"Volume analysis"}],Jc=[{value:"fixed",label:"Fixed Fractional",description:"Fixed % per trade"},{value:"kelly",label:"Kelly Criterion",description:"Optimal growth sizing"},{value:"volatility",label:"Volatility Target",description:"Scale by market vol"},{value:"risk_parity",label:"Risk Parity",description:"Equal risk contribution"}],ed=[{value:"fixed",label:"Fixed %",description:"2-5% from entry"},{value:"atr",label:"ATR-Based",description:"Dynamic with volatility"},{value:"trailing",label:"Trailing Stop",description:"Lock in profits"},{value:"volatility",label:"Volatility Bands",description:"Bollinger/Keltner exits"}],td=[{value:"volume_confirm",label:"Volume Confirmation"},{value:"trend_align",label:"Trend Alignment"},{value:"volatility_filter",label:"Volatility Filter"},{value:"correlation_check",label:"Correlation Check"},{value:"regime_detect",label:"Regime Detection"},{value:"signal_strength",label:"Signal Strength Min"}
116],sd=[{value:"max_drawdown",label:"Max Drawdown Limit"},{value:"daily_loss",label:"Daily Loss Limit"},{value:"position_limit",label:"Position Concentration"},{value:"correlation_limit",label:"Correlation Limits"},{value:"var_check",label:"VaR Monitoring"},{value:"regime_pause",label:"Regime Break Pause"}];function ad({onComplete:t,onSkip:s}){var v,h;const[a,r]=j.useState(1),[n,c]=j.useState({marketFocus:[],indicators:[],entryFilters:[],riskManagement:[],executionPrefs:[]}),d=()=>{const{riskTolerance:m,tradingStyle:f,experience:b,marketFocus:_,indicators:y,positionSizing:N,stopLossType:w,entryFilters:g,riskManagement:k}=n;let M="";return m==="conservative"?M="Conservative mean-reversion strategy with strict risk controls. ":m==="aggressive"?M="Aggressive momentum breakout strategy for high-conviction moves. ":M="Balanced trend-following approach with adaptive positioning. ",y!=null&&y.includes("rsi")&&(y!=null&&y.includes("macd"))?M+="Use RSI for oversold/overbought detection combined with MACD trend confirmation. ":y!=null&&y.includes("bollinger")?M+="Trade Bollinger Band bounces with volume confirmation. ":y!=null&&y.includes("ema")&&(M+="Enter on EMA crossovers with ADX trend strength filter. "),N==="kelly"?M+="Apply Kelly criterion for optimal position sizing. ":N==="volatility"&&(M+="Scale positions inversely to market volatility. "),w==="atr"?M+="Use 2x ATR trailing stops for dynamic risk management. ":w==="trailing"&&(M+="Employ trailing stops to lock in profits during trends. "),k!=null&&k.includes("regime_pause")&&(M+="Auto-pause during detected regime breaks. "),k!=null&&k.includes("max_drawdown")&&(M+="Reduce size after 10% drawdown, pause at 15%. "),b==="expert"?M+="Implement multi-factor ensemble with walk-forward optimization.":b==="beginner"&&(M+="Keep signals simple with clear entry/exit rules."),M||"Track price momentum using RSI indicators. When RSI crosses above 30 with volume confirmation, enter long positions. Use ATR-based stops at 2x ATR with 3:1 reward target."},i=()=>{a<As.length?r(a+1):t({...n,suggestedTheory:d()})},l=()=>{a>1&&r(a-1)},o=()=>{var m,f;switch(a){case 1:return!!n.riskTolerance;case 2:return!!n.tradingStyle;case 3:return!!n.experience;case 4:return(((m=n.marketFocus)==null?void 0:m.length)||0)>0;case 5:return(((f=n.indicators)==null?void 0:f.length)||0)>0;case 6:return!!n.positionSizing;case 7:return!!n.stopLossType;case 8:return!0;case 9:return!0;default:return!0}},u=(m,f)=>{const b=n[m]||[];c({...n,[m]:b.includes(f)?b.filter(_=>_!==f):[...b,f]})};return e.jsxs(q,{className:"border-primary/30 bg-gradient-to-br from-background via-primary/5 to-background overflow-hidden",children:[e.jsxs("div",{className:"p-3 border-b border-border/50 bg-gradient-to-r from-primary/10 to-violet-500/10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-gradient-to-br from-primary to-violet-500 shadow-lg shadow-primary/20",children:e.jsx(Ds,{className:"h-4 w-4 text-white"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-xs",children:"Quick Start Wizard"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Build a sophisticated agent in 10 steps"})]})]}),e.jsx(W,{variant:"ghost",size:"sm",onClick:s,className:"text-[10px] h-6 px-2",children:"Skip"})]}),e.jsx("div",{className:"flex gap-0.5 mb-1.5",children:As.map(m=>{m.icon;const f=m.id===a,b=m.id<a;return e.jsx("div",{className:O("flex-1 h-1.5 rounded-full transition-all",f?"bg-primary":b?"bg-emerald-400":"bg-muted"),title:m.title},m.id)})}),e.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",children:[e.jsxs("span",{className:"font-semibold text-primary",children:["Step ",a,":"]}),e.jsx("span",{children:As[a-1].title})]})]}
116),e.jsxs(H,{className:"p-3",children:[a===1&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"font-semibold text-xs flex items-center gap-1.5",children:[e.jsx(Ce,{className:"w-3.5 h-3.5 text-primary"}),"Risk Tolerance"]}),e.jsx("div",{className:"grid gap-1.5",children:Uc.map(m=>{const f=m.icon,b=n.riskTolerance===m.value;return e.jsxs("button",{onClick:()=>c({...n,riskTolerance:m.value}),className:O("p-2 rounded-lg border text-left transition-all flex items-center gap-2",b?"border-primary/50 bg-primary/10 ring-1 ring-primary/30":"border-border/50 hover:border-primary/30"),children:[e.jsx("div",{className:O("w-8 h-8 rounded-lg flex items-center justify-center bg-primary/20"),children:e.jsx(f,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-semibold text-xs",children:m.label}),e.jsx("div",{className:"text-[10px] text-muted-foreground truncate",children:m.description})]}),b&&e.jsx(it,{className:"w-4 h-4 text-emerald-400 flex-shrink-0"})]},m.value)})})]}),a===2&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"font-semibold text-xs flex items-center gap-1.5",children:[e.jsx(ge,{className:"w-3.5 h-3.5 text-primary"}),"Trading Style"]}),e.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:Xc.map(m=>{const f=m.icon,b=n.tradingStyle===m.value;return e.jsxs("button",{onClick:()=>c({...n,tradingStyle:m.value}),className:O("p-2 rounded-lg border text-left transition-all",b?"border-primary/50 bg-primary/10 ring-1 ring-primary/30":"border-border/50 hover:border-primary/30"),children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx(f,{className:"w-3.5 h-3.5 text-primary"}),e.jsx("span",{className:"font-semibold text-xs",children:m.label})]}),e.jsx("div",{className:"text-[9px] text-muted-foreground",children:m.description}),e.jsx(C,{variant:"outline",className:"mt-1 text-[8px] h-4",children:m.frequency})]},m.value)})})]}),a===3&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"font-semibold text-xs flex items-center gap-1.5",children:[e.jsx(lt,{className:"w-3.5 h-3.5 text-primary"}),"Experience Level"]}),e.jsx("div",{className:"grid gap-1.5",children:Yc.map(m=>{const f=n.experience===m.value;return e.jsxs("button",{onClick:()=>c({...n,experience:m.value}),className:O("p-2 rounded-lg border text-left transition-all flex items-center gap-2",f?"border-violet-500/50 bg-violet-500/10 ring-1 ring-violet-500/30":"border-border/50 hover:border-violet-500/30"),children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-semibold text-xs",children:m.label}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:m.description})]}),f&&e.jsx(it,{className:"w-4 h-4 text-emerald-400"})]},m.value)})})]}),a===4&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"font-semibold text-xs flex items-center gap-1.5",children:[e.jsx(he,{className:"w-3.5 h-3.5 text-primary"}),"Market Focus (select multiple)"]}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:Qc.map(m=>{var b;const f=(b=n.marketFocus)==null?void 0:b.includes(m.value);return e.jsxs("button",{onClick:()=>u("marketFocus",m.value),className:O("p-2 rounded-lg border text-center transition-all",f?"border-primary/50 bg-primary/10 ring-1 ring-primary/30":"border-border/50 hover:border-primary/30"),children:[e.jsx("span",{className:"text-lg",children:m.icon}),e.jsx("div",{className:"text-[10px] font-medium mt-0.5",children:m.label})]},m.value)})})]}),a===5&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"font-semibold text-xs flex items-center gap-1.5",children:[e.jsx(as,{className:"w-3.5 h-3.5 text-primary"}),"Signal Indicators (select 2-4)"]}),e.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:Zc.map(m=>{var b;const f=(b=n.indicators)==null?void 0:b.includes(m.value);return e.jsxs("button",{onClick:()=>u("indicators",m.value),className:O("p-2 rounded-lg border text-left transition-all",f?"border-primary/50 bg-primary/10 ring-1 ring-primary/30":"border-border/50 hover:border-primary/30"),children:[e.jsx("div",{className:"font-semibold text-xs",children:m.label}),e.jsx("div",{className:"text-[9px] text-muted-foreground",children:m.desc})]},m.value)})})]}),a===6&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"font-semibold text-xs flex items-center gap-1.5",children:[e.jsx(bs,{className:"w-3.5 h-3.5 text-primary"}),"Position Sizing Method"]}),e.jsx("div",{className:"grid gap-1.5",children:Jc.map(m=>{const f=n.positionSizing===m.value;return e.jsxs("button",{onClick:()=>c({...n,positionSizing:m.value}),className:O("p-2 rounded-lg border text-left transition-all flex items-center gap-2",f?"border-primary/50 bg-primary/10 ring-1 ring-primary/30":"border-border/50 hover:border-primary/30"),children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-semibold text-xs",children:m.label}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:m.description})]}),f&&e.jsx(it,{className:"w-4 h-4 text-emerald-400"})]},m.value)})})]}),a===7&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"font-semibold text-xs flex items-center gap-1.5",children:[e.jsx(Re,{className:"w-3.5 h-3.5 text-primary"}),"Stop Loss Strategy"]}
116),e.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:ed.map(m=>{const f=n.stopLossType===m.value;return e.jsxs("button",{onClick:()=>c({...n,stopLossType:m.value}),className:O("p-2 rounded-lg border text-left transition-all",f?"border-amber-500/50 bg-amber-500/10 ring-1 ring-amber-500/30":"border-border/50 hover:border-amber-500/30"),children:[e.jsx("div",{className:"font-semibold text-xs",children:m.label}),e.jsx("div",{className:"text-[9px] text-muted-foreground",children:m.description})]},m.value)})})]}),a===8&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"font-semibold text-xs flex items-center gap-1.5",children:[e.jsx(Da,{className:"w-3.5 h-3.5 text-primary"}),"Entry Filters (optional)"]}),e.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:td.map(m=>{var b;const f=(b=n.entryFilters)==null?void 0:b.includes(m.value);return e.jsx("button",{onClick:()=>u("entryFilters",m.value),className:O("p-1.5 rounded-lg border text-left transition-all text-[10px]",f?"border-primary/50 bg-primary/10":"border-border/50 hover:border-primary/30"),children:m.label},m.value)})})]}),a===9&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"font-semibold text-xs flex items-center gap-1.5",children:[e.jsx(Us,{className:"w-3.5 h-3.5 text-primary"}),"Risk Management Features"]}),e.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:sd.map(m=>{var b;const f=(b=n.riskManagement)==null?void 0:b.includes(m.value);return e.jsx("button",{onClick:()=>u("riskManagement",m.value),className:O("p-1.5 rounded-lg border text-left transition-all text-[10px]",f?"border-emerald-500/50 bg-emerald-500/10":"border-border/50 hover:border-emerald-500/30"),children:m.label},m.value)})})]}),a===10&&e.jsxs("div",{className:"space-y-3 text-center py-2",children:[e.jsx("div",{className:"w-14 h-14 mx-auto rounded-full bg-gradient-to-br from-emerald-500 to-primary flex items-center justify-center shadow-lg shadow-primary/30 animate-pulse",children:e.jsx(_t,{className:"w-7 h-7 text-white"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-bold text-sm",children:"Agent Configured!"}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:"Sophisticated strategy ready to deploy"})]}),e.jsxs("div",{className:"grid grid-cols-5 gap-1 text-[9px]",children:[e.jsxs("div",{className:"p-1.5 rounded bg-primary/10 border border-primary/20",children:[e.jsx("div",{className:"text-muted-foreground",children:"Risk"}),e.jsx("div",{className:"font-bold capitalize truncate",children:n.riskTolerance})]}),e.jsxs("div",{className:"p-1.5 rounded bg-primary/10 border border-primary/20",children:[e.jsx("div",{className:"text-muted-foreground",children:"Style"}),e.jsx("div",{className:"font-bold capitalize truncate",children:n.tradingStyle})]}),e.jsxs("div",{className:"p-1.5 rounded bg-primary/10 border border-primary/20",children:[e.jsx("div",{className:"text-muted-foreground",children:"Level"}),e.jsx("div",{className:"font-bold capitalize truncate",children:n.experience})]}),e.jsxs("div",{className:"p-1.5 rounded bg-primary/10 border border-primary/20",children:[e.jsx("div",{className:"text-muted-foreground",children:"Markets"}),e.jsx("div",{className:"font-bold",children:((v=n.marketFocus)==null?void 0:v.length)||0})]}),e.jsxs("div",{className:"p-1.5 rounded bg-primary/10 border border-primary/20",children:[e.jsx("div",{className:"text-muted-foreground",children:"Signals"}),e.jsx("div",{className:"font-bold",children:((h=n.indicators)==null?void 0:h.length)||0})]})]})]}),e.jsxs("div",{className:"flex gap-2 mt-3 pt-3 border-t border-border/50",children:[a>1&&e.jsxs(W,{variant:"outline",size:"sm",onClick:l,className:"flex-1 h-8 text-xs",children:[e.jsx(Or,{className:"w-3.5 h-3.5 mr-1"}),"Back"]}),e.jsx(W,{size:"sm",onClick:i,disabled:!o(),className:O("flex-1 h-8 text-xs bg-gradient-to-r from-primary to-violet-500 hover:from-primary/90 hover:to-violet-500/90",a===1&&"w-full"),children:a===As.length?e.jsxs(e.Fragment,{children:[e.jsx(Ds,{className:"w-3.5 h-3.5 mr-1"}),"Launch Agent"]}):e.jsxs(e.Fragment,{children:["Next",e.jsx(qs,{className:"w-3.5 h-3.5 ml-1"})]})})]})]})]})}const jr=[{label:"Roblox In-Game Items",theory:"Analyze in-game item discussions, trading volume, and virtual economy trends in Roblox to predict RBLX stock movements. Track limited item releases, DevEx payouts, and creator economy metrics.",icon:"ð®",category:"Gaming"},{label:"TikTok Trends â Meta",theory:"The rise of viral TikTok dance challenges and creator engagement metrics can predict META stock returns through competitive pressure and ad revenue correlation.",icon:"ð±",category:"Social"},{label:"Gaming Streams â NVDA",theory:"Increased Twitch streaming hours and viewer engagement for GPU-intensive games like Fortnite and Cyberpunk predict NVDA hardware demand and stock performance.",icon:"ð¯",category:"Streaming"},{label:"Crypto Sentiment â BTC",theory:"Reddit crypto sentiment, Twitter mentions, and Google search trends for 'buy bitcoin' correlate with BTC price movements with a 2-3 day lead time.",icon:"â¿",category:"Crypto"},{label:"Apple Momentum",theory:"Track Apple product launch sentiment, App Store revenue trends, and iPhone pre-order data to capture AAPLX momentum on earnings beats and new device releases.",icon:"ð",category:"Tech"},{label:"NVIDIA AI Demand",theory:"Monitor AI research paper citations, datacenter GPU orders, and gaming benchmark trends to ride NVDAX during AI/GPU demand surges.",icon:"ð®",category:"Tech"},{label:"Microsoft Cloud",theory:"Analyze Azure usage metrics, GitHub activity, and enterprise softw
116are adoption trends to trade MSFTX on cloud growth momentum.",icon:"âï¸",category:"Tech"},{label:"Google Search Alpha",theory:"Track Google search volume changes, YouTube ad rates, and Chrome market share to capture GOOGLX ad revenue momentum.",icon:"ð",category:"Tech"},{label:"Meta Social Sentiment",theory:"Monitor Instagram engagement rates, Facebook DAU trends, and VR headset sales to trade METAX on social media sentiment extremes.",icon:"ð¥",category:"Tech"},{label:"Tesla Volatility",theory:"Track Elon Musk tweets, EV delivery numbers, and autonomous driving updates to exploit TSLAX high-volatility regimes.",icon:"â¡",category:"Tech"},{label:"Amazon E-Commerce",theory:"Analyze Prime membership growth, AWS revenue estimates, and holiday shopping trends to follow AMZNX retail cycles.",icon:"ð¦",category:"Tech"},{label:"Coinbase Crypto Beta",theory:"Use Bitcoin volatility, crypto trading volume, and regulatory news sentiment to trade COINX as a leveraged BTC proxy.",icon:"ðª",category:"Crypto"},{label:"Robinhood Retail Flow",theory:"Monitor retail trading app downloads, meme stock mentions, and commission-free trading trends to capture HOODX during retail volume surges.",icon:"ð¹",category:"Fintech"}
116,{label:"AMD Chip Cycles",theory:"Track gaming console sales, datacenter buildout news, and CPU benchmark scores to trade AMDX on chip demand cycles.",icon:"ð»",category:"Semis"},{label:"Marvell Data Center",theory:"Monitor 5G infrastructure spending, datacenter switch orders, and cloud capex announcements to follow MRVLX datacenter chip trends.",icon:"ð",category:"Semis"},{label:"Broadcom Infrastructure",theory:"Analyze enterprise network upgrades, WiFi 6E adoption, and semiconductor lead times to capture AVGOX infrastructure demand momentum.",icon:"ð¡",category:"Semis"},{label:"Eli Lilly GLP-1",theory:"Track Mounjaro/Zepbound prescription data, weight-loss drug mentions, and clinical trial results to ride LLYon on GLP-1 drug trends.",icon:"ð",category:"Healthcare"},{label:"Novo Nordisk Pharma",theory:"Monitor Ozempic/Wegovy prescription volumes, diabetes prevalence data, and FDA approval news to capture NVOon drug momentum.",icon:"ð¥",category:"Healthcare"},{label:"Pfizer Defensive",theory:"Track vaccine demand, pharma patent expirations, and dividend yield spreads to mean-revert on PFEon oversold levels.",icon:"ð",category:"Healthcare"},{label:"Coca-Cola Dividends",theory:"Monitor consumer staples spending, beverage market share, and dividend yield changes to capture KOon on dips for stable dividend income.",icon:"ð¥¤",category:"Consumer"},{label:"P&G Staples",theory:"Track consumer spending data, inflation impacts on household goods, and brand loyalty metrics to follow PGon consumer staples demand.",icon:"ð§´",category:"Consumer"},{label:"McDonald's Value",theory:"Monitor fast food traffic data, menu price changes, and consumer confidence indices to value-invest on MCDon pullbacks.",icon:"ð",category:"Consumer"},{label:"Starbucks Consumer",theory:"Track mobile app orders, store traffic data, and coffee consumption trends to trade SBUXon on consumer spending cycles.",icon:"â",category:"Consumer"},{label:"Nike Athletic",theory:"Monitor sneaker release hype, athlete endorsement news, and athletic apparel sales to capture NKEon brand momentum.",icon:"ð",category:"Consumer"},{label:"JPMorgan Rates",theory:"Track Federal Reserve rate decisions, yield curve changes, and loan origination data to trade JPMon on interest rate sensitivity.",icon:"ð¦",category:"Finance"},{label:"Amex Consumer Spend",theory:"Monitor credit card transaction volumes, travel spending trends, and premium card signups to capture AXPon consumer spending momentum.",icon:"ð³",category:"Finance"},{label:"Caterpillar Infrastructure",theory:"Track government infrastru
116cture bills, construction spending data, and mining equipment orders to ride CATon infrastructure cycles.",icon:"ð",category:"Industrial"},{label:"Boeing Aerospace",theory:"Monitor airline order books, aircraft delivery schedules, and aviation safety news to exploit BAon delivery/order volatility.",icon:"âï¸",category:"Industrial"},{label:"Lockheed Defense",theory:"Track defense budget allocations, military contract awards, and geopolitical tensions to capture LMTon defense spending momentum.",icon:"ð¡ï¸",category:"Industrial"},{label:"Honeywell Industrial",theory:"Monitor industrial automation orders, building management system sales, and aerospace component demand to trade HONX on industrial cycles.",icon:"ð",category:"Industrial"},{label:"GE Aerospace",theory:"Track jet engine orders, renewable energy installations, and industrial equipment backlog to follow GEon aerospace and energy trends.",icon:"âï¸",category:"Industrial"},{label:"Oracle Cloud",theory:"Monitor enterprise cloud migrations, database license renewals, and AI infrastructure deals to trade ORCLX on cloud transition momentum.",icon:"ðï¸",category:"Tech"},{label:"Salesforce CRM",theory:"Track SaaS adoption rates, enterprise software spending, and AI feature releases to capture CRMX on CRM market leadership.",icon:"ð",category:"Tech"},{label:"Adobe Creative",theory:"Monitor creative software subscriptions, AI image generation trends, and digital marketing spending to trade ADSKX on creative economy growth.",icon:"ð¨",category:"Tech"},{label:"Palo Alto Security",theory:"Track cybersecurity breach news, enterprise security spending, and zero-trust adoption to capture PANWon on security demand surges.",icon:"ð",category:"Tech"},{label:"Netflix Streaming",theory:"Monitor subscriber growth estimates, content release schedules, and streaming market share to trade NFLXX on streaming wars dynamics.",icon:"ðº",category:"Media"},{label:"Disney Entertainment",theory:"Track Disney+ subscribers, theme park attendance, and box office performance to capture DISNEYX entertainment cycle momentum.",icon:"ð°",category:"Media"},{label:"Snap Social",theory:"Monitor Snapchat DAU trends, AR feature adoption, and Gen-Z engagement metrics to trade SNAPX on social media sentiment.",icon:"ð»",category:"Social"},{label:"Zoom Communications",theory:"Track video conferencing usage, hybrid work trends, and enterprise collaboration spending to trade ZOOMX on remote work momentum.",icon:"ð¹",category:"Tech"},{label:"PayPal Payments",theory:"Monitor digital payment volumes, Venmo transactions, and e-commerce checkout share to trade PYMNTX on digital payments growth.",icon:"ð°",category:"Fintech"},{label:"Visa Card Network",theory:"Track cross-border transaction volumes, contactless payment adoption, and card network market share to capture VISAX payment momentum.",icon:"ð³",category:"Fintech"},{label:"Mastercard Global",theory:"Monitor international travel recovery, B2B payment digitization, and cryptocurrency card programs to trade MAX on global payments trends.",icon:"ð",category:"Fintech"},{label:"Uber Mobility",theory:"Track ride-hailing demand, food delivery volumes, and autonomous vehicle progress to trade UBERX on mobility platform growth.",icon:"ð",category:"Travel"},{label:"Airbnb Travel",theory:"Monitor travel booking trends, alternative lodging demand, and experience economy growth to capture ABNBX on travel recovery.",icon:"ð ",category:"Travel"},{label:"Palantir Data",theory:"Track government contract awards, enterprise AI adoption, and big data spending to trade PLTX on data analytics momentum.",icon:"ð",category:"Data"},{label:"Shopify E-Commerce",theory:"Monitor SMB e-commerce adoption, merchant GMV growth, and payment processing volumes to capture SHOPX on e-commerce platform trends.",icon:"ð",category:"Tech"},{label:"DocuSign Digital",theory:"Track digital signature adoption, contract automation trends, and remote work persistence to trade DOCUX on digital transformation.",icon:"âï¸",category:"Tech"},{label:"Alibaba China Tech",theory:"Monitor Chinese consumer spending, Singles Day sales data, and regulatory sentiment to exploit BABAon China tech volatility.",icon:"ð",category:"Intl"},{label:"Toyota Auto Cycles",theory:"Track global auto sales, EV transition progress, and supply chain disruptions to follow TMon auto production cycles.",icon:"ð",category:"Intl"},{label:"UnitedHealth Insurance",theory:"Monitor healthcare utilization rates, Medicare Advantage enrollment, and health insurance premium trends to trade UNHon on healthcare spending.",icon:"ð¥",category:"Healthcare"},{label:"Abbott Diagnostics",theory:"Track diagnostic test volumes, glucose monitoring adoption, and medical device approvals to capture ABTon on healthcare innovation.",icon:"ð¬",category:"Healthcare"},{label:"Amgen Biotech",theory:"Monitor biotech pipeline progress, FDA approval calendars, and rare disease treatment demand to trade AMGNon on biotech momentum.",icon:"ð§¬",category:"Healthcare"}
116,{label:"Gilead Sciences",theory:"Track antiviral drug prescriptions, HIV treatment market share, and oncology pipeline updates to capture GILDon on pharma trends.",icon:"ð",category:"Healthcare"},{label:"Medtronic Devices",theory:"Monitor surgical procedure volumes, medical device approvals, and hospital capex spending to trade MDTon on med-tech cycles.",icon:"ð¥",category:"Healthcare"},{label:"Intel Comeback",theory:"Track foundry contract wins, CPU market share recovery, and semiconductor subsidies to trade INTCon on Intel turnaround momentum.",icon:"ð»",category:"Semis"},{label:"Cisco Networking",theory:"Monitor enterprise network upgrades, 5G infrastructure spending, and cybersecurity appliance orders to capture CSCOon on networking demand.",icon:"ð",category:"Tech"},{label:"Accenture Consulting",theory:"Track digital transformation spending, IT consulting demand, and enterprise AI adoption to trade ACNon on consulting momentum.",icon:"ð¼",category:"Tech"},{label:"Texas Instruments",theory:"Monitor analog chip demand, automotive semiconductor content, and industrial automation trends to capture TXNon on analog cycles.",icon:"ð§",category:"Semis"},{label:"Qualcomm Mobile",theory:"Track smartphone shipment data, 5G modem market share, and automotive chip wins to trade QCOMon on mobile momentum.",icon:"ð±",category:"Semis"},{label:"Analog Devices",theory:"Monitor industrial sensor demand, automotive electronics content, and precision measurement trends to capture ADIon on analog growth.",icon:"ð",category:"Semis"},{label:"Walmart Retail",theory:"Track grocery market share, e-commerce growth, and same-store sales data to trade WMTon on retail dominance trends.",icon:"ð",category:"Consumer"},{label:"Costco Membership",theory:"Monitor membership renewal rates, warehouse traffic, and bulk buying trends to capture COSTon on membership value growth.",icon:"ðª",category:"Consumer"},{label:"Home Depot Housing",theory:"Track housing market activity, renovation spending, and DIY trends to trade HDon on home improvement cycles.",icon:"ð¨",category:"Consumer"},{label:"Chevron Energy",theory:"Monitor oil prices, refining margins, and energy transition investments to trade CVXon on energy sector cycles.",icon:"â½",category:"Energy"},{label:"NextEra Renewables",theory:"Track renewable energy installations, solar/wind capacity additions, and clean energy policy to capture NEEon on green energy trends.",icon:"ð±",category:"Energy"},{label:"Verizon Telecom",theory:"Monitor 5G deployment progress, subscriber trends, and spectrum auction results to trade VZon on telecom momentum.",icon:"ð¶",category:"Telecom"},{label:"RTX Aerospace",theory:"Track defense budget allocations, commercial aerospace recovery, and military modernization programs to capture RTXon on aerospace defense trends.",icon:"ð",category:"Industrial"},{label:"Circle Stablecoin",theory:"Monitor USDC market cap, stablecoin regulatory news, and institutional crypto adoption to trade CRCLon on stablecoin ecosystem growth.",icon:"ðµ",category:"Crypto"},{label:"SPY Market Trend",theory:"Track market breadth indicators, VIX levels, and economic data releases to follow broad market trends via SPYX trend strategy.",icon:"ð",category:"ETF"},{label:"TQQQ Leverage",theory:"Monitor Nasdaq momentum, tech earnings beats, and risk-on sentiment to capture leveraged gains via TQQQX momentum strategy.",icon:"ð",category:"ETF"},{label:"Gold Macro Hedge",theory:"Track inflation expectations, central bank gold buying, and geopolitical risks to use GLDX as macro uncertainty hedge.",icon:"ð¥",category:"ETF"},{label:"Tech Sector Rotation",theory:"Monitor tech earnings revisions, sector fund flows, and AI investment trends to rotate into XLKX during tech leadership.",icon:"ð»",category:"ETF"},{label:"Financial Rates",theory:"Track yield curve steepening, bank earnings, and credit growth to position in XLFX on financial sector rate sensitivity.",icon:"ð¦",category:"ETF"},{label:"Emerging Markets",theory:"Monitor EM currency trends, commodity prices, and Chinese economic data to capture EEMX emerging market growth momentum.",icon:"ð",category:"ETF"},{label:"Real Estate REIT",theory:"Track commercial real estate trends, interest rate expectations, and REIT dividend yields to capture VNQon dividend opportunities.",icon:"ð¢",category:"ETF"},{label:"Russell 2000 Value",theory:"Monitor small-cap valuations, domestic economic strength, and value factor rotation to trade IWNon on small-cap value momentum.",icon:"ð",category:"ETF"},{label:"Healthcare Sector",theory:"Track healthcare policy news, drug pricing trends, and biotech M&A activity to position in XLVX healthcare sector.",icon:"ð¥",category:"ETF"},{label:"Energy Sector",theory:"Monitor oil supply/demand dynamics, refining margins, and energy transition pace to trade XLEX on energy sector cycles.",icon:"â½",category:"ETF"},{label:"Industrial Sector",theory:"Track manufacturing PMI, infrastru
116cture spending, and reshoring trends to capture XLIX on industrial momentum.",icon:"ð",category:"ETF"},{label:"Silver Commodity",theory:"Monitor silver industrial demand, solar panel production, and precious metal sentiment to trade SLVX on silver trends.",icon:"ð¥",category:"ETF"},{label:"Oil Commodity",theory:"Track OPEC decisions, inventory data, and global demand forecasts to trade USOX on crude oil price movements.",icon:"ð¢ï¸",category:"ETF"},{label:"Treasury Bonds",theory:"Monitor Fed policy expectations, inflation data, and flight-to-safety flows to trade TLTX on long-duration bond movements.",icon:"ð",category:"ETF"},{label:"High Yield Bonds",theory:"Track credit spreads, corporate default rates, and risk appetite to capture JNKX on high-yield credit cycles.",icon:"ðµ",category:"ETF"},{label:"Vanguard IT",theory:"Monitor tech sector earnings, cloud spending growth, and AI investment trends to position in VGTX on information technology momentum.",icon:"ð»",category:"ETF"},{label:"Vanguard High Div",theory:"Track dividend aristocrat performance, yield spreads, and income investor flows to capture VYMX high dividend strategies.",icon:"ð°",category:"ETF"},{label:"Intl Stock Market",theory:"Monitor international economic data, currency trends, and global fund flows to diversify via VTIX international equities.",icon:"ð",category:"ETF"},{label:"ARK Innovation",theory:"Track disruptive technology trends, genomics advances, and fintech innovation to capture ARKX on high-growth innovation themes.",icon:"ð¬",category:"ETF"},{label:"Dow Jones Index",theory:"Monitor blue-chip earnings, industrial production, and dividend yields to trade DIAX on Dow Jones value trends.",icon:"ð",category:"ETF"},{label:"Vanguard S&P 500",theory:"Track broad market valuations, earnings growth, and passive fund flows to position in VOOon for S&P 500 exposure.",icon:"ð",category:"ETF"},{label:"Total Stock Market",theory:"Monitor US economic indicators, market breadth, and sector rotation to capture VTIon total market performance.",icon:"ðºð¸",category:"ETF"},{label:"Aggregate Bond",theory:"Track interest rate expectations, credit conditions, and fixed income flows to position in AGGon for bond market exposure.",icon:"ð",category:"ETF"},{label:"Vanguard Bond",theory:"Monitor Fed policy, duration risk, and bond fund flows to capture BNDon total bond market movements.",icon:"ðµ",category:"ETF"},{label:"Vanguard Ex-US",theory:"Track international valuations, currency impacts, and global growth to diversify via VXUSon international equities.",icon:"ð",category:"ETF"},{label:"MSCI EAFE",theory:"Monitor developed market earnings, European/Asian economic data to position in IEFAon for developed international exposure.",icon:"ð",category:"ETF"},{label:"Core Emerging",theory:"Track EM growth differentials, commodity prices, and EM fund flows to capture IEMGon emerging market momentum.",icon:"ð",category:"ETF"},{label:"Vanguard Info Tech",theory:"Monitor tech earnings, cloud/AI spending, and sector momentum to position in VGTon for tech exposure.",icon:"ð»",category:"ETF"},{label:"Vanguard Health",theory:"Track healthcare spending, drug approvals, and demographic trends to capture VHTon healthcare sector performance.",icon:"ð¥",category:"ETF"},{label:"Vanguard Financials",theory:"Monitor bank earnings, interest margins, and credit growth to position in VFHon for financial sector exposure.",icon:"ð¦",category:"ETF"},{label:"Consumer Staples",theory:"Track consumer spending on essentials, inflation impacts, and defensive positioning to capture VDCon staples performance.",icon:"ð",category:"ETF"},{label:"Vanguard Utilities",theory:"Monitor utility earnings, interest rate sensitivity, and dividend yields to position in VPUon for utilities exposure.",icon:"â¡",category:"ETF"},{label:"Discord Activity â Gaming",theory:"Monitor Discord server activity, voice channel usage, and game-specific channels to predict gaming stock movements like EA, ATVI, and TTWO.",icon:"ð®",category:"Gaming"},{label:"Steam Charts â NVDA",theory:"Track Steam concurrent players, new game releases, and hardware surveys to predict NVDA GPU demand cycles.",icon:"ð¥ï¸",category:"Tech"},{label:"YouTube Shorts â META",theory:"Analyze YouTube Shorts engagement metrics and creator monetization trends to gauge META competitive pressure.",icon:"ð¹",category:"Social"},{label:"Spotify Streams â Trends",theory:"Monitor Spotify streaming data, podcast growth, and audio ad rates to predict digital media trends.",icon:"ðµ",category:"Media"},{label:"LinkedIn Jobs â Tech",theory:"Track LinkedIn job postings, hiring velocity, and skill demand to predict tech sector health.",icon:"ð¼",category:"Tech"},{label:"GitHub Stars â Innovation",theory:"Monitor GitHub repository stars, forks, and contributor activity to identify emerging tech trends.",icon:"â",category:"Tech"},{label:"App Store Rankings",theory:"Track App Store and Play Store rankings, download velocity, and review sentiment for mobile-first companies.",icon:"ð²",category:"Tech"},{label:"Weather Data â Retail",theory:"Use weather pattern data to predict seasonal retail sales, energy demand, and agricultural output.",icon:"ð¤ï¸",category:"Macro"},{label:"Shipping Container",theory:"Monitor global shipping container rates, port congestion, and logistics data to predict supply chain impacts.",icon:"ð¢",category:"Macro"},{label:"Credit Card Data",theory:"Analyze anonymized credit card transaction data to predict consumer spending trends and retail performance.",icon:"ð³",category:"Consumer"},{label:"Flight Data â Travel",theory:"Track flight booking data, airline capacity, and TSA checkpoint volumes to predict travel sector recovery.",icon:"âï¸",category:"Travel"},{label:"Patent Filings â Tech",theory:"Monitor USPTO patent filings, AI/ML innovations, and tech IP trends to i
116dentify future industry leaders.",icon:"ð",category:"Tech"},{label:"FDA Calendar â Pharma",theory:"Track FDA approval calendars, PDUFA dates, and clinical trial results to trade biotech catalyst events.",icon:"ð",category:"Healthcare"},{label:"Earnings Whispers",theory:"Analyze earnings whisper estimates, guidance trends, and beat/miss patterns to trade earnings momentum.",icon:"ð",category:"Strategy"},{label:"Insider Buying",theory:"Monitor Form 4 insider transactions, cluster buying patterns, and executive purchases as bullish signals.",icon:"ð",category:"Strategy"},{label:"Dark Pool Flow",theory:"Track dark pool trading activity, block trade sizes, and institutional order flow for hidden accumulation.",icon:"ð",category:"Strategy"},{label:"Options Gamma",theory:"Monitor options gamma exposure, dealer hedging flows, and max pain levels to predict price magnets.",icon:"ð",category:"Strategy"},{label:"VIX Term Structure",theory:"Analyze VIX futures curve, contango/backwardation, and volatility regime to time vol trades.",icon:"ð",category:"Strategy"},{label:"CFTC Positioning",theory:"Track CFTC Commitment of Traders reports, speculator positioning, and commercial hedger flows.",icon:"ð",category:"Macro"},{label:"Fed Funds Futures",theory:"Monitor Fed Funds futures pricing, rate cut/hike probabilities, and FOMC dot plot shifts.",icon:"ðï¸",category:"Macro"}];function rd({onAgentCreated:t}){var $;const[s,a]=j.useState(""),[r,n]=j.useState(!1),[c,d]=j.useState(!1),[i,l]=j.useState(!1),[o,u]=j.useState(null),[v,h]=j.useState(""),[m,f]=j.useState(null),[b,_]=j.useState(null),[y,N]=j.useState("idle"),[w,g]=j.useState("all"),[k,M]=j.useState(""),[T,A]=j.useState(!0),B=["all",...Array.from(new Set(jr.map(L=>L.category)))],z=jr.filter(L=>{const D=w==="all"||L.category===w,F=k===""||L.label.toLowerCase().includes(k.toLowerCase())||L.theory.toLowerCase().includes(k.toLowerCase())||L.category.toLowerCase().includes(k.toLowerCase());return D&&F}),U=async()=>{var L;if(!s.trim()){xe({title:"Error",description:"Please enter a trading theory",variant:"destructive"});return}n(!0),N("parsing"),u(null),f(null),h("");try{const{data:D,error:F}=await ue.functions.invoke("build-custom-agent",{body:{action:"analyze",theory:s.trim()}});if(F)throw F;u(D.parsed),((L=D.parsed.available_tickers)==null?void 0:L.length)>0?h(D.parsed.available_tickers[0].symbol):h(D.parsed.ticker),N("idle"),xe({title:"Theory Analyzed",description:"Select your ticker and run backtest"})}catch(D){console.error("Error analyzing theory:",D),xe({title:"Analysis Failed",description:D instanceof Error?D.message:"Failed to analyze theory",variant:"destructive"}),N("idle")}finally{n(!1)}},G=async()=>{if(!(!o||!v)){l(!0),N("backtesting");try{const{data:L,error:D}=await ue.functions.invoke("build-custom-agent",{body:{action:"backtest",theory:s.trim(),parsed:{...o,ticker:v}}});if(D)throw D;f(L.backtest),N("idle"),xe({title:"Backtest Complete",description:`Simulated 12-month performance for ${v}`})}catch(L){console.error("Error running backtest:",L),xe({title:"Backtest Failed",description:L instanceof Error?L.message:"Failed to run backtest",variant:"destructive"}),N("idle")}finally{l(!1)}}},K=async()=>{if(!(!o||!v)){d(!0),N("building");try{await new Promise(F=>setTimeout(F,1500)),N("deploying");const{data:L,error:D}=await ue.functions.invoke("build-custom-agent",{body:{action:"deploy",theory:s.trim(),parsed:{...o,ticker:v}}});if(D)throw D;N("complete"),xe({title:"ð Agent Deployed!",description:`${v} Signal Agent is now live and generating signals`}),setTimeout(()=>{a(""),u(null),h(""),f(null),N("idle"),t()},2e3)}catch(L){console.error("Error deploying agent:",L),xe({title:"Deployment Failed",description:L instanceof Error?L.message:"Failed to deploy agent",variant:"destructive"}),N("idle")}finally{d(!1)}}};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(qc,{}),T&&e.jsx(ad,{onComplete:L=>{a(L.suggestedTheory),A(!1),xe({title:"Wizard Complete",description:'Your strategy has been configured. Click "Launch New Agent" to proceed!'})},onSkip:()=>A(!1)}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute -inset-1 bg-gradient-to-r from-cyan-400 via-primary to-emerald-400 rounded-2xl blur-lg opacity-40 animate-pulse"}),e.jsxs(q,{className:"relative border-2 border-cyan-400/50 bg-gradient-to-br from-cyan-500/10 via-background to-primary/10 shadow-2xl shadow-cyan-500/20",children:[e.jsxs(X,{className:"pb-3",children:[e.jsxs(Y,{className:"flex items-center gap-2 text-lg",children:[e.jsx("div",{className:"p-2 rounded-xl bg-gradient-to-br from-cyan-500 to-primary shadow-lg shadow-primary/40",children:e.jsx(lt,{className:"h-5 w-5 text-white"})}),e.jsx("span",{className:"text-foreground font-bold text-xl",children:"Your Trading Theory"})]}),e.jsx(In,{className:"text-muted-foreground",children:"Describe your hypothesis about how external trends affect stock prices"})]}
116),e.jsxs(H,{className:"space-y-4",children:[e.jsx(Er,{placeholder:"Example: Analyze Roblox in-game item trading volume and limited item discussions on forums to predict RBLX stock movements. When rare items see increased trading activity, it indicates higher platform engagement...",value:s,onChange:L=>a(L.target.value),className:"min-h-[150px] resize-none border-cyan-400/30 focus:border-cyan-400 bg-background/80 focus:ring-2 focus:ring-cyan-400/20"}),e.jsx(W,{onClick:U,disabled:r||!s.trim(),size:"lg",className:"w-full bg-gradient-to-r from-cyan-500 via-primary to-emerald-500 hover:from-cyan-400 hover:via-primary/90 hover:to-emerald-400 shadow-xl shadow-primary/40 font-bold text-white text-base py-6",children:r?e.jsxs(e.Fragment,{children:[e.jsx(Pt,{className:"h-5 w-5 mr-2 animate-spin"}),"Analyzing Theory..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ht,{className:"h-5 w-5 mr-2"}),"Launch New Agent"]})})]})]})]}),e.jsxs(q,{className:"border-primary/20 bg-gradient-to-br from-background to-primary/5",children:[e.jsxs(X,{className:"pb-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[e.jsxs(Y,{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(pe,{className:"h-4 w-4 text-amber-400"}),e.jsxs("span",{className:"text-foreground font-semibold",children:["Example Theories (",z.length,")"]})]}),e.jsx(se,{placeholder:"Search theories...",value:k,onChange:L=>M(L.target.value),className:"w-40 sm:w-56 h-8 text-xs border-primary/30 focus:border-cyan-400"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:B.map(L=>e.jsx("button",{onClick:()=>g(L),className:O("px-3 py-1.5 rounded-full text-xs font-semibold transition-all",w===L?"bg-gradient-to-r from-cyan-400 to-primary text-white shadow-lg shadow-primary/30":"bg-primary/10 text-primary hover:bg-primary/20 border border-primary/20"),children:L==="all"?"All":L},L))})]}),e.jsx(H,{children:e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-2 max-h-[250px] overflow-y-auto pr-1",children:z.slice(0,16).map((L,D)=>e.jsxs("button",{onClick:()=>a(L.theory),className:"flex flex-col items-start gap-1 p-2.5 rounded-lg border border-primary/20 bg-gradient-to-br from-background to-primary/5 hover:border-cyan-400/50 hover:from-primary/10 hover:to-cyan-400/10 hover:shadow-lg hover:shadow-primary/10 transition-all text-left group",children:[e.jsxs("div",{className:"flex items-center gap-1.5 w-full",children:[e.jsx("span",{className:"text-lg drop-shadow-glow",children:L.icon}),e.jsx("span",{className:"text-[10px] text-cyan-400/80 font-medium ml-auto",children:L.category})]}),e.jsx("span",{className:"text-xs font-semibold text-foreground/80 group-hover:text-cyan-400 line-clamp-2 transition-colors",children:L.label})]},D))})})]}),e.jsx(Hc,{onSelectTemplate:L=>a(L)})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(Vc,{isActive:!0,ticker:(o==null?void 0:o.ticker)||v||"BTC"}),e.jsx(Kc,{onSelectStrategy:L=>a(L)})]})]}),o?e.jsxs("div",{className:"space-y-4",children:[e.jsxs(q,{className:"border-emerald-500/30 bg-emerald-500/5",children:[e.jsx(X,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Y,{className:"flex items-center gap-2 text-lg",children:[e.jsx(it,{className:"h-5 w-5 text-emerald-500"}),"Theory Breakdown"]}),e.jsxs(C,{variant:"outline",className:"border-emerald-500/50 text-emerald-500",children:[o.confidence,"% Confidence"]})]})}
116),e.jsxs(H,{className:"space-y-4",children:[e.jsxs("div",{className:"p-3 rounded-lg bg-background/50 border border-primary/30",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-2",children:"Select Trading Ticker"}),e.jsxs(De,{value:v,onValueChange:h,children:[e.jsx(Ee,{className:"w-full",children:e.jsx(Le,{placeholder:"Select ticker"})}),e.jsx(Oe,{children:(($=o.available_tickers)==null?void 0:$.map(L=>e.jsxs(ie,{value:L.symbol,children:[e.jsx("span",{className:"font-bold",children:L.symbol}),e.jsxs("span",{className:"text-muted-foreground ml-2",children:["(",L.exchange,")"]})]},L.symbol)))||e.jsx(ie,{value:o.ticker,children:o.ticker})})]}),e.jsx("div",{className:"text-[10px] text-muted-foreground mt-1",children:"Most liquid listing selected by default"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"p-3 rounded-lg bg-background/50 border border-muted-foreground/10",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Target Asset"}),e.jsx("div",{className:"font-bold text-primary",children:v||o.ticker}),e.jsx("div",{className:"text-sm text-muted-foreground",children:o.company})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-background/50 border border-muted-foreground/10",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Time Horizon"}),e.jsx("div",{className:"font-bold",children:o.time_horizon})]})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-background/50 border border-muted-foreground/10",children:[e.jsxs("div",{className:"text-xs text-muted-foreground mb-1 flex items-center gap-1",children:[e.jsx(he,{className:"h-3 w-3"}),"External Trend"]}),e.jsx("div",{className:"text-sm font-medium",children:o.trend})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-background/50 border border-muted-foreground/10",children:[e.jsxs("div",{className:"text-xs text-muted-foreground mb-1 flex items-center gap-1",children:[e.jsx(lt,{className:"h-3 w-3"}),"Causal Hypothesis"]}),e.jsx("div",{className:"text-sm",children:o.causal_hypothesis})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-background/50 border border-muted-foreground/10",children:[e.jsxs("div",{className:"text-xs text-muted-foreground mb-2 flex items-center gap-1",children:[e.jsx(Lt,{className:"h-3 w-3"}),"Data Sources (",o.data_sources.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:o.data_sources.map((L,D)=>e.jsx(C,{variant:"secondary",className:"text-xs",children:L},D))})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-background/50 border border-muted-foreground/10",children:[e.jsxs("div",{className:"text-xs text-muted-foreground mb-2 flex items-center gap-1",children:[e.jsx(ge,{className:"h-3 w-3"}),"Features (",o.features.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:o.features.map((L,D)=>e.jsx(C,{variant:"outline",className:"text-xs",children:L},D))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"p-3 rounded-lg bg-background/50 border border-muted-foreground/10",children:[e.jsxs("div",{className:"text-xs text-muted-foreground mb-1 flex items-center gap-1",children:[e.jsx(Cr,{className:"h-3 w-3"}),"Model Type"]}),e.jsx("div",{className:"text-sm font-medium",children:o.model_type})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-background/50 border border-muted-foreground/10",children:[e.jsxs("div",{className:"text-xs text-muted-foreground mb-1 flex items-center gap-1",children:[e.jsx(Re,{className:"h-3 w-3"}),"Risk Factors"]}),e.jsxs("div",{className:"text-sm",children:[o.risk_factors.length," identified"]})]})]})]})]}),e.jsx(W,{onClick:G,disabled:i||!v,variant:"outline",className:"w-full h-12 border-primary/50 hover:bg-primary/10",children:i?e.jsxs(e.Fragment,{children:[e.jsx(Pt,{className:"h-4 w-4 mr-2 animate-spin"}),"Running Backtest..."]}):e.jsxs(e.Fragment,{children:[e.jsx(gt,{className:"h-4 w-4 mr-2"}),"Run Backtest Preview"]})}),e.jsx(Tc,{ticker:v,results:m,isLoading:i}),o&&v&&e.jsx(Dc,{ticker:v,trend:o.trend,onDataFetched:L=>_(L)}),o&&v&&e.jsx(Ec,{agentConfig:{ticker:v,theory:s,dataSources:o.data_sources,strategyType:o.model_type},isLive:y==="complete"}),e.jsx(W,{onClick:K,disabled:c||!m,className:"w-full h-14 text-lg bg-gradient-to-r from-primary via-cyan-500 to-primary hover:opacity-90",children:y==="building"?e.jsxs(e.Fragment,{children:[e.jsx(Pt,{className:"h-5 w-5 mr-2 animate-spin"}
116),"Building Agent Infrastructure..."]}):y==="deploying"?e.jsxs(e.Fragment,{children:[e.jsx(Pt,{className:"h-5 w-5 mr-2 animate-spin"}),"Deploying to AgentQuants..."]}):y==="complete"?e.jsxs(e.Fragment,{children:[e.jsx(it,{className:"h-5 w-5 mr-2"}),"Agent Deployed Successfully!"]}):e.jsxs(e.Fragment,{children:[e.jsx(pe,{className:"h-5 w-5 mr-2"}),m?"Deploy Agent":"Run Backtest First",e.jsx(Ht,{className:"h-5 w-5 ml-2"})]})}),(c||y==="complete"||i)&&e.jsx(q,{className:"border-muted-foreground/10",children:e.jsx(H,{className:"pt-4",children:e.jsx("div",{className:"flex items-center justify-between text-xs",children:["Parse","Backtest","Ingest","Features","Model","Deploy"].map((L,D)=>{const R={parsing:0,backtesting:1,building:3,deploying:5,complete:6}[y]??-1,Q=D<=R,x=D===R;return e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx("div",{className:O("w-8 h-8 rounded-full flex items-center justify-center border-2 transition-all",Q?"border-primary bg-primary/20":"border-muted-foreground/20",x&&"animate-pulse"),children:Q?e.jsx(it,{className:"h-4 w-4 text-primary"}):e.jsx("span",{className:"text-muted-foreground",children:D+1})}),e.jsx("span",{className:O("font-medium",Q?"text-primary":"text-muted-foreground"),children:L})]},L)})})})})]}):e.jsx(q,{className:"border-dashed border-muted-foreground/20 min-h-[200px] flex items-center justify-center",children:e.jsxs("div",{className:"text-center p-8",children:[e.jsx("div",{className:"p-4 rounded-full bg-muted-foreground/5 w-fit mx-auto mb-4",children:e.jsx(Ke,{className:"h-12 w-12 text-muted-foreground/40"})}),e.jsx("h3",{className:"font-semibold text-muted-foreground mb-2",children:"Agent Preview"}),e.jsx("p",{className:"text-sm text-muted-foreground/60 max-w-xs",children:"Enter a trading theory or select an example above to see the agent configuration"})]})}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[{icon:Lt,label:"Multi-Source Ingestion",desc:"Google Trends, Social, APIs"},{icon:ge,label:"Feature Engineering",desc:"Auto-generated features"},{icon:gt,label:"ML Ensemble",desc:"VAR, XGBoost, LSTM"},{icon:ua,label:"Live Deployment",desc:"Real-time signals"}].map((L,D)=>e.jsxs("div",{className:"p-4 rounded-lg border border-muted-foreground/10 bg-muted-foreground/5",children:[e.jsx(L.icon,{className:"h-5 w-5 text-primary mb-2"}),e.jsx("div",{className:"font-medium text-sm",children:L.label}),e.jsx("div",{className:"text-xs text-muted-foreground",children:L.desc})]},D))}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsx(Lc,{}),e.jsx(Ic,{})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsx(Bc,{}),e.jsx(zc,{})]}),e.jsx($c,{})]})}const da=[{value:"drawdown",label:"Drawdown %",icon:ke},{value:"daily_pnl",label:"Daily P&L",icon:he},{value:"win_rate",label:"Win Rate %",icon:Be},{value:"sharpe",label:"Sharpe Ratio",icon:Ce},{value:"volatility",label:"Volatility %",icon:Re},{value:"position_size",label:"Position Size",icon:Gt}];function nd(){const[t,s]=j.useState([{id:"1",metric:"drawdown",condition:"above",threshold:10,enabled:!0},{id:"2",metric:"daily_pnl",condition:"below",threshold:-500,enabled:!0},{id:"3",metric:"win_rate",condition:"below",threshold:40,enabled:!1}]),[a,r]=j.useState(""),[n,c]=j.useState(!1);j.useEffect(()=>{(async()=>{try{const{data:f}=await ue.from("webhook_notifications").select("*").eq("notification_type","performance_alert").limit(1);f&&f.length>0&&r(f[0].webhook_url||"")}catch(f){console.error("Failed to load webhooks:",f)}})()},[]);const d=()=>{const m={id:Date.now().toString(),metric:"drawdown",condition:"above",threshold:10,enabled:!0};s([...t,m])},i=m=>{s(t.filter(f=>f.id!==m))},l=(m,f,b)=>{s(t.map(_=>_.id===m?{..._,[f]:b}:_))},o=m=>
116da.find(f=>f.value===m)||da[0],u=async()=>{if(!a.trim()){ve.error("Please enter a webhook URL");return}c(!0);try{const{error:m}=await ue.from("webhook_notifications").upsert({notification_type:"performance_alert",webhook_url:a,confidence_threshold:70,is_enabled:!0,signal_types:t.filter(f=>f.enabled).map(f=>f.metric)},{onConflict:"notification_type"});if(m)throw m;ve.success("Webhook connected successfully")}catch(m){console.error("Failed to save webhook:",m),ve.error("Failed to save webhook")}c(!1)},v=async()=>{if(!a.trim()){ve.error("Please enter a webhook URL first");return}try{(await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"test",message:"ð AgentQuants Alert Test",timestamp:new Date().toISOString()})})).ok?ve.success("Test notification sent!"):ve.error("Webhook test failed")}catch{ve.error("Failed to send test notification")}},h=t.filter(m=>m.enabled?m.metric==="drawdown"&&m.threshold<=8||m.metric==="volatility"&&m.threshold<=20:!1);return e.jsxs(q,{className:"border-amber-500/30 bg-gradient-to-br from-amber-500/5 to-transparent",children:[e.jsx(X,{className:"pb-2",children:e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(fa,{className:"w-4 h-4 text-amber-400"}),"Performance Alerts",h.length>0&&e.jsxs(C,{variant:"destructive",className:"text-[9px] ml-auto animate-pulse",children:[h.length," Active"]})]})}
116),e.jsxs(H,{className:"space-y-3",children:[e.jsxs("div",{className:"p-2 rounded-lg bg-muted/20 border border-border/50 space-y-2",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground font-medium",children:"Discord/Slack Webhook"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(se,{value:a,onChange:m=>r(m.target.value),placeholder:"https://discord.com/api/webhooks/...",className:"h-7 text-[10px] flex-1"}),e.jsx(W,{size:"sm",variant:"outline",className:"h-7 px-2 text-[10px]",onClick:v,children:"Test"}),e.jsx(W,{size:"sm",className:"h-7 px-2 text-[10px] bg-amber-600 hover:bg-amber-700",onClick:u,disabled:n,children:n?e.jsx(pi,{className:"w-3 h-3 animate-pulse"}):e.jsx(Bn,{className:"w-3 h-3"})})]})]}),h.length>0&&e.jsxs("div",{className:"bg-destructive/10 border border-destructive/30 rounded-lg p-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Re,{className:"w-3 h-3 text-destructive"}),e.jsx("span",{className:"text-[10px] font-semibold text-destructive",children:"Active Alerts"})]}),e.jsx("div",{className:"space-y-0.5",children:h.map(m=>{const f=o(m.metric);return e.jsxs("div",{className:"flex items-center gap-1.5 text-[9px] text-destructive",children:[e.jsx(f.icon,{className:"w-2.5 h-2.5"}),e.jsxs("span",{children:[f.label," ",m.condition," ",m.threshold]})]},m.id)})})]}),e.jsx("div",{className:"space-y-1.5 max-h-[140px] overflow-y-auto pr-1 scrollbar-thin scrollbar-thumb-border scrollbar-track-transparent",children:t.map(m=>{const b=o(m.metric).icon;return e.jsxs("div",{className:`flex items-center gap-1.5 p-1.5 rounded-lg border transition-all ${m.enabled?"bg-muted/30 border-border":"bg-muted/10 border-border/50 opacity-60"}`,children:[e.jsx(b,{className:"w-3 h-3 text-muted-foreground shrink-0"}),e.jsxs(De,{value:m.metric,onValueChange:_=>l(m.id,"metric",_),children:[e.jsx(Ee,{className:"h-6 text-[9px] w-[70px] border-0 bg-transparent p-0",children:e.jsx(Le,{})}),e.jsx(Oe,{children:da.map(_=>e.jsx(ie,{value:_.value,className:"text-[10px]",children:_.label},_.value))})]}),e.jsxs(De,{value:m.condition,onValueChange:_=>l(m.id,"condition",_),children:[e.jsx(Ee,{className:"h-6 text-[9px] w-[50px] border-0 bg-transparent p-0",children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(ie,{value:"above",className:"text-[10px]",children:"Above"}),e.jsx(ie,{value:"below",className:"text-[10px]",children:"Below"})]})]}),e.jsx(se,{type:"number",value:m.threshold,onChange:_=>l(m.id,"threshold",parseFloat(_.target.value)||0),className:"h-6 w-[45px] text-[9px] text-center px-1"}),e.jsx(ye,{checked:m.enabled,onCheckedChange:_=>l(m.id,"enabled",_),className:"scale-[0.6]"}),e.jsx(W,{variant:"ghost",size:"icon",className:"h-5 w-5 text-muted-foreground hover:text-destructive",onClick:()=>i(m.id),children:e.jsx(Xr,{className:"w-2.5 h-2.5"})})]},m.id)})}),e.jsxs(W,{variant:"outline",size:"sm",className:"w-full h-7 text-[10px] border-dashed border-amber-500/30 text-amber-400 hover:bg-amber-500/10",onClick:d,children:[e.jsx(ls,{className:"w-3 h-3 mr-1"}),"Add Alert"]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 pt-2 border-t border-border/50",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Total"}),e.jsx("p",{className:"text-sm font-bold",children:t.length})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Active"}),e.jsx("p",{className:"text-sm font-bold text-emerald-400",children:t.filter(m=>m.enabled).length})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Fired"}),e.jsx("p",{className:"text-sm font-bold text-destructive",children:h.length})]})]})]})]})}const yr=[{id:"1",name:"Momentum Alpha",type:"momentum",color:"#22d3ee",sharpe:1.82,returns:28.4,maxDrawdown:12.3,winRate:58,equityCurve:[100,102,105,103,108,112,115,118,116,122,125,128]},{id:"2",name:"Mean Reversion Pro",type:"mean_reversion",color:"#a855f7",sharpe:1.45,returns:19.2,maxDrawdown:8.7,winRate:62,equityCurve:[100,101,103,105,104,107,109,111,113,115,117,119]},{id:"3",name:"Trend Follower",type:"trend",color:"#10b981",sharpe:1.65,returns:24.1,maxDrawdown:15.2,winRate:52,equityCurve:[100,99,103,106,104,110,114,113,118,120,122,124]},{id:"4",name:"Volatility Harvester",type:"volatility",color:"#f59e0b",sharpe:1.28,returns:15.8,maxDrawdown:6.4,winRate:68,equityCurve:[100,101,102,103,103,105,106,108,109,111,113,116]},{id:"5",name:"Multi-Factor Quant",type:"multi_factor",color:"#ef4444",sharpe:1.95,returns:32.1,maxDrawdown:14.8,winRate:55,equityCurve:[100,104,106,108,105,112,118,120,124,128,130,132]}];function id(t){let s=t[0];return t.map(a=>(a>s&&(s=a),(s-a)/s*100))}function ld(t,s){const a=Math.min(t.length,s.length),r=t.slice(0,a).reduce((o,u)=>o+u,0)/a,n=s.slice(0,a).reduce((o,u)=>o+u,0)/a;let c=0,d=0,i=0;for(let o=0;o<a;o++){const u=t[o]-r,v=s[o]-n;c+=u*v,d+=u*u,i+=v*v}const l=Math.sqrt(d*i);return l===0?0:c/l}function od(){const[t,s]=j.useState(["1","3"]),[a,r]=j.useState(!1),[n,c]=j.useState("equity"),d=m=>{s(f=>f.includes(m)?f.filter(b=>b!==m):[...f,m])},i=yr.filter(m=>t.includes(m.id)),l=j.useMemo(()=>Array.from({length:12},(m,f)=>{const b={month:`M${f+1}`};
116return i.forEach(_=>{b[_.name]=_.equityCurve[f]}),b}),[i]),o=j.useMemo(()=>Array.from({length:12},(m,f)=>{const b={month:`M${f+1}`};return i.forEach(_=>{const y=id(_.equityCurve);b[`${_.name}_dd`]=-y[f]}),b}),[i]),u=j.useMemo(()=>{const m=[];for(let f=0;f<i.length;f++)for(let b=f+1;b<i.length;b++){const _=ld(i[f].equityCurve,i[b].equityCurve);m.push({s1:i[f].name,s2:i[b].name,correlation:_,color1:i[f].color,color2:i[b].color})}return m},[i]),v=i.sort((m,f)=>f.returns-m.returns)[0],h=()=>{r(!0),setTimeout(()=>r(!1),2e3)};return e.jsxs(q,{className:"border-violet-500/30 bg-gradient-to-br from-violet-500/5 to-transparent",children:[e.jsx(X,{className:"pb-3",children:e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(mt,{className:"w-4 h-4 text-violet-400"}),"Multi-Strategy Backtest",e.jsxs(C,{variant:"outline",className:"text-[10px] bg-violet-500/10 text-violet-400 border-violet-500/30 ml-auto",children:[t.length," Selected"]})]})}),e.jsxs(H,{className:"space-y-4",children:[e.jsx("div",{className:"space-y-2 max-h-[120px] overflow-y-auto pr-1 scrollbar-thin scrollbar-thumb-violet-500/30 scrollbar-track-transparent",children:yr.map(m=>e.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg border cursor-pointer transition-all ${t.includes(m.id)?"bg-violet-500/10 border-violet-500/40":"bg-muted/20 border-border/50 hover:border-border"}`,onClick:()=>d(m.id),children:[e.jsx(Gs,{checked:t.includes(m.id),className:"data-[state=checked]:bg-violet-500 data-[state=checked]:border-violet-500"}),e.jsx("div",{className:"w-3 h-3 rounded-full shrink-0",style:{backgroundColor:m.color}}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"text-xs font-medium truncate",children:m.name})}),e.jsx("div",{className:"text-right",children:e.jsxs("p",{className:"text-xs font-bold text-emerald-400",children:["+",m.returns,"%"]})})]},m.id))}),e.jsx(W,{className:"w-full bg-violet-600 hover:bg-violet-700 text-white",onClick:h,disabled:t.length<2||a,children:a?e.jsxs(e.Fragment,{children:[e.jsx(pe,{className:"w-4 h-4 mr-2 animate-pulse"}),"Running..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Je,{className:"w-4 h-4 mr-2"}),"Compare ",t.length," Strategies"]})}),i.length>=2&&e.jsxs(vs,{value:n,onValueChange:c,className:"w-full",children:[e.jsxs(js,{className:"grid w-full grid-cols-3 h-7",children:[e.jsxs(Ie,{value:"equity",className:"text-[10px]",children:[e.jsx(gt,{className:"w-3 h-3 mr-1"}),"Equity"]}),e.jsxs(Ie,{value:"drawdown",className:"text-[10px]",children:[e.jsx(ke,{className:"w-3 h-3 mr-1"}),"Drawdown"]}),e.jsxs(Ie,{value:"correlation",className:"text-[10px]",children:[e.jsx(ge,{className:"w-3 h-3 mr-1"}),"Correl"]})]}),e.jsx(Ue,{value:"equity",className:"mt-2",children:e.jsx("div",{className:"h-[140px] w-full bg-muted/20 rounded-lg p-2",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(At,{data:l,margin:{top:5,right:5,left:-15,bottom:0},children:[e.jsx(de,{dataKey:"month",tick:{fontSize:9}}),e.jsx(oe,{tick:{fontSize:9},domain:["auto","auto"]}),e.jsx(Ne,{contentStyle:{backgroundColor:"hsl(var(--background))",border:"1px solid hsl(var(--border))",borderRadius:"8px",fontSize:"10px"},formatter:m=>[`$${m.toFixed(0)}`,""]}),e.jsx(ga,{wrapperStyle:{fontSize:"9px"},iconSize:6}),i.map(m=>e.jsx(Fe,{type:"monotone",dataKey:m.name,stroke:m.color,strokeWidth:2,dot:!1},m.id))]})})})}),e.jsx(Ue,{value:"drawdown",className:"mt-2",children:e.jsx("div",{className:"h-[140px] w-full bg-muted/20 rounded-lg p-2",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(Ot,{data:o,margin:{top:5,right:5,left:-15,bottom:0},children:[e.jsx(de,{dataKey:"month",tick:{fontSize:9}}),e.jsx(oe,{tick:{fontSize:9},domain:["auto",0],tickFormatter:m=>`${m.toFixed(0)}%`}),e.jsx(fe,{y:0,stroke:"hsl(var(--border))",strokeDasharray:"3 3"}),e.jsx(Ne,{contentStyle:{backgroundColor:"hsl(var(--background))",border:"1px solid hsl(var(--border))",borderRadius:"8px",fontSize:"10px"},formatter:m=>[`${m.toFixed(2)}%`,"Drawdown"]}),e.jsx(ga,{wrapperStyle:{fontSize:"9px"},iconSize:6}),i.map(m=>e.jsx(We,{type:"monotone",dataKey:`${m.name}_dd`,name:m.name,stroke:m.color,fill:m.color,fillOpacity:.3,strokeWidth:1.5},m.id))]})})})}),e.jsx(Ue,{value:"correlation",className:"mt-2",children:e.jsxs("div",{className:"space-y-2 p-2 bg-muted/20 rounded-lg max-h-[140px] overflow-y-auto",children:[u.length===0?e.jsx("p",{className:"text-[10px] text-muted-foreground text-center py-4",children:"Select 2+ strategies"}):u.map((m,f)=>e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded border border-border/30 bg-background/50",children:[e.jsxs("div",{className:"flex items-center gap-1 flex-1 min-w-0",children:[e.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:m.color1}}),e.jsx("span",{className:"text-[9px] truncate",children:m.s1.split(" ")[0]})]}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"â"}),e.jsxs("div",{className:"flex items-center gap-1 flex-1 min-w-0",children:[e.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:m.color2}}),e.jsx("span",{className:"text-[9px] truncate",children:m.s2.split(" ")[0]})]}),e.jsxs(C,{variant:"outline",className:`text-[9px] px-1.5 ${m.correlation>.7?"text-red-400 border-red-500/30":m.correlation>.3?"text-amber-400 border-amber-500/30":"text-emerald-400 border-emerald-500/30"}`,children:[(m.correlation*100).toFixed(0),"%"]})]},f)),e.jsx("p",{className:"text-[9px] text-muted-foreground text-center pt-1",children:"Low correlation = better diversification"})]})})]}),i.length>=2&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(St,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Performance"})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-[9px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border/50",children:[e.jsx("th",{className:"text-left py-1 px-1 text-muted-foreground",children:"Strategy"}),e.jsx("th",{className:"text-right py-1 px-1 text-muted-foreground",children:"Ret"}),e.jsx("th",{className:"text-right py-1 px-1 text-muted-foreground",children:"SR"}),e.jsx("th",{className:"text-right py-1 px-1 text-muted-foreground",children:"DD"})]})}),e.jsx("tbody",{children:i.map(m=>e.jsxs("tr",{className:"border-b border-border/30",children:[e.jsx("td",{className:"py-1 px-1",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:m.color}}),e.jsx("span",{className:"truncate max-w-[60px]",children:m.name.split(" ")[0]})]})}),e.jsxs("td",{className:"text-right py-1 px-1 font-mono text-emerald-400",children:["+",m.returns,"%"]}),e.jsx("td",{className:"text-right py-1 px-1 font-mono",children:m.sharpe}),e.jsxs("td",{className:"text-right py-1 px-1 font-mono text-destructive",children:["-",m.maxDrawdown,"%"]})]},m.id))})]})})]}),v&&i.length>=2&&e.jsx("div",{className:"bg-gradient-to-r from-amber-500/20 to-yellow-500/10 border border-amber-500/30 rounded-lg p-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Qt,{className:"w-3 h-3 text-amber-400"}),e.jsxs("span",{className:"text-[10px] font-semibold text-amber-400",children:["Best: ",v.name]}),e.jsxs("span",{className:"text-[10px] text-emerald-400 font-mono ml-auto",children:["+",v.returns,"%"]})]})}),i.length<2&&e.jsxs("div",{className:"text-center py-4 text-muted-foreground",children:[e.jsx(mt,{className:"w-6 h-6 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-[10px]",children:"Select 2+ strategies"})]})]})]})}const cd=[{value:"sharpe",label:"Sharpe Ratio",description:"Risk-adjusted returns"},{value:"sortino",label:"Sortino Ratio",description:"Downside risk-adjusted"},{value:"calmar",label:"Calmar Ratio",description:"Return/drawdown"},{value:"returns",label:"Total Returns",description:"Maximize gains"},{value:"drawdown",label:"Min Drawdown",description:"Reduce risk"}],ma=[{id:"lookback_period",label:"Lookback Period",min:5,max:100,step:5},{id:"entry_threshold",label:"Entry Threshold",min:.01,max:.1,step:.01},{id:"exit_threshold",label:"Exit Threshold",min:.005,max:.05,step:.005},{id:"stop_loss",label:"Stop Loss",min:.02,max:.15,step:.01}
116,{id:"take_profit",label:"Take Profit",min:.05,max:.25,step:.01},{id:"position_size",label:"Position Size",min:.05,max:.5,step:.05},{id:"rsi_period",label:"RSI Period",min:7,max:21,step:1},{id:"rsi_oversold",label:"RSI Oversold",min:20,max:40,step:5},{id:"rsi_overbought",label:"RSI Overbought",min:60,max:80,step:5},{id:"macd_fast",label:"MACD Fast",min:8,max:16,step:1},{id:"macd_slow",label:"MACD Slow",min:20,max:32,step:1},{id:"bollinger_period",label:"Bollinger Period",min:10,max:30,step:2},{id:"bollinger_std",label:"Bollinger Std",min:1.5,max:3,step:.25},{id:"atr_multiplier",label:"ATR Multiplier",min:1,max:4,step:.5}];function dd({agentId:t,agentName:s}){const[a,r]=j.useState(!1),[n,c]=j.useState(0),[d,i]=j.useState("sharpe"),[l,o]=j.useState(["lookback_period","stop_loss","take_profit"]),[u,v]=j.useState(100),[h,m]=j.useState(!0),[f,b]=j.useState(!1),[_,y]=j.useState([]),[N,w]=j.useState([]),[g,k]=j.useState([]),M=async()=>{r(!0),c(0),y([]),w([]),k([]);const A=u,B=[];let z=1.2;for(let K=0;K<A;K++){await new Promise(L=>setTimeout(L,30)),c((K+1)/A*100);const $=(Math.random()-.5)*.3;z=Math.max(z,z+$*(1-K/A)),B.push({iteration:K+1,sharpe:Number((z+Math.random()*.1).toFixed(3)),bestSharpe:Number(z.toFixed(3))})}w(B);const U=l.map(K=>{const $=ma.find(R=>R.id===K),L=$?($.min+$.max)/2:0,D=$?$.min+Math.random()*($.max-$.min):L,F=(D-L)/L*100;return{parameter:($==null?void 0:$.label)||K,originalValue:Number(L.toFixed(3)),optimizedValue:Number(D.toFixed(3)),improvement:Number(F.toFixed(1)),sharpeImprovement:Number((Math.random()*.3-.1).toFixed(3))}});y(U);const G=l.slice(0,4).map(K=>{const $=ma.find(L=>L.id===K);return{parameter:($==null?void 0:$.label)||K,sensitivity:Number((Math.random()*.5+.1).toFixed(2)),optimalRegion:`${(($==null?void 0:$.min)||0).toFixed(2)} - ${((($==null?void 0:$.max)||1)*.7).toFixed(2)}`}});k(G),r(!1),xe({title:"Optimization Complete",description:`Found improved parameters with ${(z-1.2).toFixed(2)} Sharpe improvement`})},T=A=>{o(B=>B.includes(A)?B.filter(z=>z!==A):[...B,A])};return e.jsxs(q,{className:"border-primary/20 bg-gradient-to-br from-background to-primary/5",children:[e.jsx(X,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-lg bg-gradient-to-br from-amber-500 to-orange-500",children:e.jsx(sn,{className:"h-4 w-4 text-white"})}),e.jsxs("div",{children:[e.jsx(Y,{className:"text-sm",children:"Strategy Optimizer"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Auto-tune parameters for maximum performance"})]})]}),e.jsxs(C,{variant:"outline",className:"text-xs bg-amber-500/10 border-amber-500/30",children:[e.jsx(lt,{className:"w-3 h-3 mr-1"}),"AI-Powered"]})]})}),e.jsx(H,{className:"space-y-4",children:e.jsxs(vs,{defaultValue:"config",className:"w-full",children:[e.jsxs(js,{className:"grid w-full grid-cols-3 h-8",children:[e.jsx(Ie,{value:"config",className:"text-xs",children:"Configure"}),e.jsx(Ie,{value:"results",className:"text-xs",children:"Results"}),e.jsx(Ie,{value:"analysis",className:"text-xs",children:"Analysis"})]}),e.jsxs(Ue,{value:"config",className:"space-y-4 mt-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"text-xs",children:"Optimization Target"}),e.jsxs(De,{value:d,onValueChange:i,children:[e.jsx(Ee,{className:"h-8 text-xs",children:e.jsx(Le,{})}),e.jsx(Oe,{children:cd.map(A=>e.jsx(ie,{value:A.value,className:"text-xs",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:A.label}),e.jsxs("span",{className:"text-muted-foreground",children:["- ",A.description]})]})},A.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(P,{className:"text-xs",children:["Parameters to Optimize (",l.length," selected)"]}),e.jsx("div",{className:"grid grid-cols-2 gap-1.5 max-h-40 overflow-y-auto p-2 bg-muted/30 rounded-lg",children:ma.map(A=>e.jsx("button",{onClick:()=>T(A.id),className:O("px-2 py-1.5 rounded text-xs text-left transition-all",l.includes(A.id)?"bg-primary/20 border border-primary/40 text-primary":"bg-background border border-border/50 hover:border-primary/30"),children:A.label},A.id))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(P,{className:"text-xs",children:["Iterations: ",u]}),e.jsx(ee,{value:[u],onValueChange:([A])=>v(A),min:50,max:500,step:50,className:"py-2"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(P,{className:"text-xs",children:"Grid Search"}),e.jsx(ye,{checked:h,onCheckedChange:m})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(P,{className:"text-xs",children:"Bayesian Opt"}),e.jsx(ye,{checked:f,onCheckedChange:b})]})]})]}),e.jsx(W,{onClick:M,disabled:a||l.length===0,className:"w-full bg-gradient-to-r from-amber-500 to-orange-500 hover:from-amber-600 hover:to-orange-600",children:a?e.jsxs(e.Fragment,{children:[e.jsx(Pt,{className:"w-4 h-4 mr-2 animate-spin"}),"Optimizing... ",n.toFixed(0),"%"]}):e.jsxs(e.Fragment,{children:[e.jsx(Je,{className:"w-4 h-4 mr-2"}),"Run Optimization"]})}),a&&e.jsx(Xe,{value:n,className:"h-2"})]}),e.jsx(Ue,{value:"results",className:"space-y-3 mt-3",children:_.length>0?e.jsxs(e.Fragment,{children:[N.length>0&&e.jsx("div",{className:"h-32 bg-muted/30 rounded-lg p-2",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(At,{data:N.filter((A,B)=>B%5===0),children:[e.jsx(Fa,{strokeDasharray:"3 3",stroke:"hsl(var(--border))"}),e.jsx(de,{dataKey:"iteration",tick:{fontSize:9}}),e.jsx(oe,{tick:{fontSize:9},domain:["auto","auto"]}),e.jsx(Ne,{contentStyle:{backgroundColor:"hsl(var(--background))",border:"1px solid hsl(var(--border))",fontSize:"10px"}}),e.jsx(Fe,{type:"monotone",dataKey:"sharpe",stroke:"hsl(var(--primary))",dot:!1,strokeWidth:1,name:"Current"}),e.jsx(Fe,{type:"monotone",dataKey:"bestSharpe",stroke:"hsl(142, 76%, 36%)",dot:!1,strokeWidth:2,name:"Best"})]})})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"text-xs font-semibold flex items-center gap-2",children:[e.jsx(_t,{className:"w-3 h-3 text-amber-400"}),"Optimized Parameters"]}),e.jsx("div",{className:"space-y-1.5",children:_.map((A,B)=>e.jsxs("div",{className:"flex items-center justify-between p-2 bg-muted/30 rounded-lg text-xs",children:[e.jsx("span",{className:"font-medium",children:A.parameter}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:A.originalValue}),e.jsx(Ks,{className:"w-3 h-3 text-emerald-400"}),e.jsx("span",{className:"font-semibold text-emerald-400",children:A.optimizedValue}),e.jsxs(C,{variant:A.sharpeImprovement>0?"default":"secondary",className:"text-[9px]",children:[A.sharpeImprovement>0?"+":"",A.sharpeImprovement]}
116)]})]},B))})]}),e.jsxs(W,{variant:"outline",size:"sm",className:"w-full text-xs",children:[e.jsx(it,{className:"w-3 h-3 mr-2"}),"Apply Optimized Parameters"]})]}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Us,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-xs",children:"Run optimization to see results"})]})}),e.jsx(Ue,{value:"analysis",className:"space-y-3 mt-3",children:g.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold",children:"Parameter Sensitivity"}),e.jsx("div",{className:"space-y-2",children:g.map((A,B)=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{children:A.parameter}),e.jsxs("span",{className:"text-muted-foreground",children:["Optimal: ",A.optimalRegion]})]}),e.jsx("div",{className:"relative h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"absolute inset-y-0 left-0 bg-gradient-to-r from-amber-500 to-orange-500 rounded-full",style:{width:`${A.sensitivity*100}%`}})})]},B))})]}),e.jsxs("div",{className:"p-3 bg-amber-500/10 border border-amber-500/20 rounded-lg",children:[e.jsxs("h4",{className:"text-xs font-semibold flex items-center gap-2 mb-2",children:[e.jsx(Re,{className:"w-3 h-3 text-amber-400"}),"Optimization Insights"]}),e.jsxs("ul",{className:"text-[10px] text-muted-foreground space-y-1",children:[e.jsx("li",{children:"⢠Stop loss most sensitive - small changes significantly impact Sharpe"}),e.jsx("li",{children:"⢠Lookback period shows diminishing returns above 50"}),e.jsx("li",{children:"⢠Consider walk-forward validation before live deployment"}),e.jsx("li",{children:"⢠Out-of-sample testing recommended with 30% holdout"})]})]})]}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(gt,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-xs",children:"Analysis available after optimization"})]})})]})})]})}function md(){const[t,s]=j.useState([]),[a,r]=j.useState([]),[n,c]=j.useState(!0),[d,i]=j.useState(!1),[l,o]=j.useState({agent_id:"",notification_type:"discord",webhook_url:"",email_address:"",confidence_threshold:80,signal_types:["BUY","SELL"]});j.useEffect(()=>{u()},[]);const u=async()=>{c(!0);const{data:y}=await ue.from("custom_agents").select("id, name").eq("is_active",!0).order("name");y&&r(y);const{data:N}=await ue.from("webhook_notifications").select("*").order("created_at",{ascending:!1});N&&s(N),c(!1)},v=async()=>{if(!l.agent_id){ve.error("Please select an agent");return}if(l.notification_type==="discord"&&!l.webhook_url){ve.error("Please enter a Discord webhook URL");return}if(l.notification_type==="email"&&!l.email_address){ve.error("Please enter an email address");return}const{error:y}=await ue.from("webhook_notifications").insert({agent_id:l.agent_id,notification_type:l.notification_type,webhook_url:l.notification_type==="discord"?l.webhook_url:null,email_address:l.notification_type==="email"?l.email_address:null,confidence_threshold:l.confidence_threshold,signal_types:l.signal_types,is_enabled:!0});if(y){ve.error("Failed to create webhook"),console.error(y);return}ve.success("Webhook notification created"),i(!1),o({agent_id:"",notification_type:"discord",webhook_url:"",email_address:"",confidence_threshold:80,signal_types:["BUY","SELL"]}),u()},h=async(y,N)=>{const{error:w}=await ue.from("webhook_notifications").update({is_enabled:N}).eq("id",y);if(w){ve.error("Failed to update webhook");return}s(g=>g.map(k=>k.id===y?{...k,is_enabled:N}:k)),ve.success(N?"Webhook enabled":"Webhook disabled")},m=async y=>{const{error:N}=await ue.from("webhook_notifications").delete().eq("id",y);if(N){ve.error("Failed to delete webhook");return}s(w=>w.filter(g=>g.id!==y)),ve.success("Webhook deleted")},f=async y=>{const N=a.find(g=>g.id===y.agent_id);ve.loading("Sending test notification...");const{error:w}=await ue.functions.invoke("send-signal-notification",{body:{agentId:y.agent_id,agentName:(N==null?void 0:N.name)||"Test Agent",signal:"BUY",confidence:95,symbol:"BTC",reasoning:"This is a test notification to verify your webhook configuration."}});if(w){ve.dismiss(),ve.error("Test notification failed"),console.error(w);return}ve.dismiss(),ve.success("Test notification sent")},b=y=>{var N;return((N=a.find(w=>w.id===y))==null?void 0:N.name)||"Unknown Agent"},_=y=>{o(N=>({...N,signal_types:N.signal_types.includes(y)?N.signal_types.filter(w=>w!==y):[...N.signal_types,y]}))};return e.jsxs("div",{className:"glass-panel p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fa,{className:"h-5 w-5 text-primary"}),e.jsx("h3",{className:"font-semibold",children:"Webhook Notifications"}),e.jsxs(C,{variant:"outline",className:"text-xs",children:[t.filter(y=>y.is_enabled).length," Active"]})]}),e.jsxs(W,{size:"sm",onClick:()=>i(!d),className:"gap-1",children:[e.jsx(ls,{className:"h-4 w-4"}),"Add Webhook"]})]}),d&&e.jsxs("div",{className:"border border-border rounded-lg p-4 space-y-4 bg-card/50",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Yr,{className:"h-4 w-4"}),"Configure New Webhook"]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Agent"}),e.jsxs(De,{value:l.agent_id,onValueChange:y=>o(N=>({...N,agent_id:y})),children:[e.jsx(Ee,{children:e.jsx(Le,{placeholder:"Select an agent"})}),e.jsx(Oe,{children:a.map(y=>e.jsx(ie,{value:y.id,children:y.name},y.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Notification Type"}),e.jsxs(De,{value:l.notification_type,onValueChange:y=>o(N=>({...N,notification_type:y})),children:[e.jsx(Ee,{children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(ie,{value:"discord",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fs,{className:"h-4 w-4"}),"Discord"]})}),e.jsx(ie,{value:"email",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Za,{className:"h-4 w-4"}),"Email"]})})]})]})]})]}),l.notification_type==="discord"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Discord Webhook URL"}),e.jsx(se,{placeholder:"https://discord.com/api/webhooks/...",value:l.webhook_url,onChange:y=>o(N=>({...N,webhook_url:y.target.value}))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Create a webhook in your Discord server settings â Integrations â Webhooks"})]}),l.notification_type==="email"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Email Address"}),e.jsx(se,{type:"email",placeholder:"[email protected]",value:l.email_address,onChange:y=>o(N=>({...N,email_address:y.target.value}))}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-500",children:[e.jsx(Re,{className:"h-3 w-3"}),"Requires RESEND_API_KEY to be configured"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(P,{children:["Confidence Threshold: ",l.confidence_threshold,"%"]}),e.jsx(ee,{value:[l.confidence_threshold],onValueChange:([y])=>o(N=>({...N,confidence_threshold:y})),min:50,max:100,step:5}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Only signals with confidence ⥠",l.confidence_threshold,"% will trigger notifications"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Signal Types"}),e.jsx("div",{className:"flex gap-4",children:["BUY","SELL","HOLD"].map(y=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Gs,{id:`signal-${y}`,checked:l.signal_types.includes(y),onCheckedChange:()=>_(y)}),e.jsx("label",{htmlFor:`signal-${y}`,className:"text-sm cursor-pointer",children:e.jsx(C,{variant:y==="BUY"?"default":y==="SELL"?"destructive":"secondary",children:y})})]},y))})]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(W,{variant:"outline",size:"sm",onClick:()=>i(!1),children:"Cancel"}),e.jsx(W,{size:"sm",onClick:v,children:"Create Webhook"})]})]}),n?e.jsx("div",{className:"text-center text-muted-foreground py-8",children:"Loading webhooks..."}):t.length===0?e.jsxs("div",{className:"text-center text-muted-foreground py-8",children:[e.jsx(fa,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No webhooks configured"}),e.jsx("p",{className:"text-xs",children:"Add a webhook to receive signal alerts"})]}):e.jsx("div",{className:"space-y-2",children:t.map(y=>e.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg border ${y.is_enabled?"border-border bg-card/50":"border-border/50 bg-card/20 opacity-60"}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[y.notification_type==="discord"?e.jsx(Fs,{className:"h-5 w-5 text-indigo-500"}):e.jsx(Za,{className:"h-5 w-5 text-blue-500"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:b(y.agent_id)}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("span",{children:["⥠",y.confidence_threshold,"% confidence"]}),e.jsx("span",{children:"â¢"}),e.jsx("span",{children:y.signal_types.join(", ")})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>f(y),className:"h-8 w-8 p-0",title:"Send test notification",children:e.jsx(pe,{className:"h-4 w-4"})}),e.jsx(ye,{checked:y.is_enabled,onCheckedChange:N=>h(y.id,N)}),e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>m(y.id),className:"h-8 w-8 p-0 text-destructive hover:text-destructive",children:e.jsx(Xr,{className:"h-4 w-4"})})]})]},y.id))})]})}const xd=()=>{const[t,s]=j.useState(!1),[a,r]=j.useState([{name:"Entry Threshold",key:"entry",min:.5,max:.95,step:.
11601,value:.7},{name:"Stop Loss",key:"stopLoss",min:.5,max:5,step:.1,value:2,unit:"%"},{name:"Take Profit",key:"takeProfit",min:1,max:10,step:.5,value:4,unit:"%"},{name:"Lookback Period",key:"lookback",min:5,max:50,step:1,value:20},{name:"RSI Period",key:"rsi",min:7,max:21,step:1,value:14},{name:"Position Size",key:"posSize",min:1,max:25,step:1,value:10,unit:"%"}]),[n,c]=j.useState({sharpe:1.42,winRate:58.3,maxDrawdown:12.4,totalReturn:24.7,trades:156}),[d,i]=j.useState([]),l=j.useCallback(()=>{var _,y;const h=[];let m=1e4;const f=((_=a.find(N=>N.key==="stopLoss"))==null?void 0:_.value)||2,b=((y=a.find(N=>N.key==="entry"))==null?void 0:y.value)||.7;for(let N=0;N<100;N++){const w=(Math.random()>1-b*.8?1:-1)*(Math.random()*f*.5);m=m*(1+w/100),h.push({time:N,equity:m})}return h},[a]),o=j.useCallback(()=>{var b,_,y;const h=((b=a.find(N=>N.key==="entry"))==null?void 0:b.value)||.7,m=((_=a.find(N=>N.key==="stopLoss"))==null?void 0:_.value)||2,f=((y=a.find(N=>N.key==="takeProfit"))==null?void 0:y.value)||4;c({sharpe:.8+h*1.2+f/m*.3+Math.random()*.2,winRate:45+h*20+Math.random()*5,maxDrawdown:5+m*3+Math.random()*2,totalReturn:10+(f-m)*5+h*15+Math.random()*5,trades:Math.floor(100+(1-h)*150+Math.random()*20)}),i(l())},[a,l]);j.useEffect(()=>{o()},[]),j.useEffect(()=>{if(t){const h=setInterval(o,500);return()=>clearInterval(h)}},[t,o]);const u=(h,m)=>{r(f=>f.map(b=>b.key===h?{...b,value:m}:b)),t||o()},v=()=>{r(h=>h.map(m=>({...m,value:m.key==="entry"?.7:m.key==="stopLoss"?2:m.key==="takeProfit"?4:m.key==="lookback"?20:m.key==="rsi"?14:10})))};return e.jsxs(q,{className:"border-border/50 bg-card/30 backdrop-blur",children:[e.jsx(X,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(fi,{className:"h-4 w-4 text-primary"}),"Live Parameter Tuning"]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(W,{size:"sm",variant:"ghost",className:"h-6 px-2",onClick:v,children:e.jsx(Xs,{className:"h-3 w-3"})}),e.jsxs(W,{size:"sm",variant:t?"destructive":"default",className:"h-6 px-2 text-xs",onClick:()=>s(!t),children:[t?e.jsx(Os,{className:"h-3 w-3 mr-1"}):e.jsx(Je,{className:"h-3 w-3 mr-1"}),t?"Pause":"Live"]})]})]})}
116),e.jsxs(H,{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-5 gap-2",children:[e.jsxs("div",{className:"text-center p-1.5 rounded bg-background/50",children:[e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Sharpe"}),e.jsx("div",{className:`text-sm font-bold ${n.sharpe>1.5?"text-green-400":n.sharpe>1?"text-yellow-400":"text-red-400"}`,children:n.sharpe.toFixed(2)})]}),e.jsxs("div",{className:"text-center p-1.5 rounded bg-background/50",children:[e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Win Rate"}),e.jsxs("div",{className:`text-sm font-bold ${n.winRate>55?"text-green-400":"text-yellow-400"}`,children:[n.winRate.toFixed(1),"%"]})]}),e.jsxs("div",{className:"text-center p-1.5 rounded bg-background/50",children:[e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Max DD"}),e.jsxs("div",{className:`text-sm font-bold ${n.maxDrawdown<10?"text-green-400":n.maxDrawdown<20?"text-yellow-400":"text-red-400"}`,children:[n.maxDrawdown.toFixed(1),"%"]})]}),e.jsxs("div",{className:"text-center p-1.5 rounded bg-background/50",children:[e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Return"}),e.jsxs("div",{className:`text-sm font-bold flex items-center justify-center gap-0.5 ${n.totalReturn>0?"text-green-400":"text-red-400"}`,children:[n.totalReturn>0?e.jsx(he,{className:"h-3 w-3"}):e.jsx(ke,{className:"h-3 w-3"}),n.totalReturn.toFixed(1),"%"]})]}),e.jsxs("div",{className:"text-center p-1.5 rounded bg-background/50",children:[e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Trades"}),e.jsx("div",{className:"text-sm font-bold text-foreground",children:n.trades})]})]}),e.jsx("div",{className:"h-20 w-full",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(At,{data:d,children:[e.jsx(fe,{y:1e4,stroke:"hsl(var(--muted-foreground))",strokeDasharray:"3 3",strokeOpacity:.3}),e.jsx(de,{dataKey:"time",hide:!0}),e.jsx(oe,{hide:!0,domain:["auto","auto"]}),e.jsx(Fe,{type:"monotone",dataKey:"equity",stroke:"hsl(var(--primary))",strokeWidth:1.5,dot:!1,isAnimationActive:!1})]})})}),e.jsx("div",{className:"space-y-2",children:a.map(h=>e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs("div",{className:"flex justify-between text-[10px]",children:[e.jsx("span",{className:"text-muted-foreground",children:h.name}),e.jsxs(C,{variant:"outline",className:"h-4 px-1 text-[9px]",children:[h.value.toFixed(h.step<1?2:0),h.unit||""]})]}),e.jsx(ee,{value:[h.value],min:h.min,max:h.max,step:h.step,onValueChange:([m])=>u(h.key,m),className:"h-4"})]},h.key))})]})]})},ud=[{id:"1",name:"Momentum Alpha Pro",description:"High-frequency momentum strategy with adaptive thresholds",category:"momentum",author:"QuantLab",rating:4.8,downloads:1243,sharpe:2.1,winRate:62,maxDrawdown:8.5,parameters:{entry:.75,stopLoss:1.5,takeProfit:4,lookback:14,rsi:14,posSize:15},tags:["high-freq","crypto","adaptive"]},{id:"2",name:"Mean Reversion Elite",description:"Statistical arbitrage with Bollinger Band reversals",category:"mean_reversion",author:"AlphaGen",rating:4.6,downloads:987,sharpe:1.8,winRate:58,maxDrawdown:12,parameters:{entry:.8,stopLoss:2,takeProfit:3,lookback:20,bollinger:2,posSize:10},tags:["stat-arb","low-risk","equities"]},{id:"3",name:"Trend Surfer X",description:"Multi-timeframe trend following with momentum confirmation",category:"trend",author:"TrendMaster",rating:4.7,downloads:1567,sharpe:1.9,winRate:55,maxDrawdown:15,parameters:{entry:.65,stopLoss:2.5,takeProfit:6,lookback:50,ema:21,posSize:12},tags:["swing","multi-tf","forex"]},{id:"4",name:"Volatility Crusher",description:"Exploits volatility expansion and contraction cycles",category:"volatility",author:"VolTrader",rating:4.5,downloads:756,sharpe:1.6,winRate:52,maxDrawdown:18,parameters:{entry:.7,stopLoss:3,takeProfit:5,atrPeriod:14,volThreshold:1.5,posSize:8},tags:["options","vix","hedging"]},{id:"5",name:"Multi-Factor Quant",description:"Combines momentum, value, and quality factors",category:"multi_factor",author:"FactorLab",rating:4.9,downloads:2134,sharpe:2.3,winRate:64,maxDrawdown:10,parameters:{entry:.85,stopLoss:1.8,takeProfit:4.5,factors:5,rebalance:7,posSize:20},tags:["institutional","diversified","long-term"]},{id:"6",name:"Scalper Extreme",description:"Ultra-short-term scalping with tight risk management",category:"momentum",author:"ScalpKing",rating:4.4,downloads:654,sharpe:1.5,winRate:68,maxDrawdown:5,parameters:{entry:.9,stopLoss:.5,takeProfit:1,lookback:5,posSize:25},tags:["scalping","high-freq","crypto"]},{id:"7",name:"Pairs Trading Pro",description:"Statistical pairs trading with cointegration analysis",category:"mean_reversion",author:"PairsQuant",rating:4.7,downloads:892,sharpe:1.7,winRate:60,maxDrawdown:11,parameters:{entry:.75,stopLoss:2.5,takeProfit:3.5,zscore:2,halfLife:15,posSize:10},tags:["pairs","market-neutral","equities"]},{id:"8",name:"Breakout Hunter",description:"Captures range breakouts with volume confirmation",category:"trend",author:"BreakoutPro",rating:4.6,downloads:1123,sharpe:1.8,winRate:54,maxDrawdown:14,parameters:{entry:.7,stopLoss:2,takeProfit:5,rangePeroid:20,volMultiplier:1.5,posSize:12},tags:["breakout","range","all-markets"]}],Nr={momentum:e.jsx(pe,{className:"h-3 w-3"}),mean_reversion:e.jsx(Be,{className:"h-3 w-3"}),trend:e.jsx(he,{className:"h-3 w-3"}),volatility:e.jsx(Ce,{className:"h-3 w-3"}),multi_factor:e.jsx(en,{className:"h-3 w-3"})},wr={momentum:"text-yellow-400",mean_reversion:"text-blue-400",trend:"text-green-400",volatility:"text-purple-400",multi_factor:"text-cyan-400"},hd=()=>{const[t,s]=j.useState(""),[a,r]=j.useState(null),[n,c]=j.useState([]),d=ud.filter(o=>{const u=o.name.toLowerCase().includes(t.toLowerCase())||o.description.toLowerCase().includes(t.toLowerCase())||o.tags.some(h=>h.toLowerCase().includes(t.toLowerCase())),v=!a||o.category===a;return u&&v}),i=o=>{ve.success(`Loaded "${o.name}" parameters`)},l=o=>
116{n.includes(o)?(c(u=>u.filter(v=>v!==o)),ve.info("Removed from saved")):(c(u=>[...u,o]),ve.success("Saved to library"))};return e.jsxs(q,{className:"border-border/50 bg-card/30 backdrop-blur",children:[e.jsx(X,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(en,{className:"h-4 w-4 text-primary"}),"Strategy Templates"]}),e.jsxs(Kt,{children:[e.jsx(Rr,{asChild:!0,children:e.jsxs(W,{size:"sm",variant:"outline",className:"h-6 px-2 text-xs",children:[e.jsx(vi,{className:"h-3 w-3 mr-1"}),"Share"]})}),e.jsxs(Ut,{children:[e.jsx(Xt,{children:e.jsx(Yt,{children:"Share Your Strategy"})}),e.jsxs("div",{className:"space-y-3 py-4",children:[e.jsx(se,{placeholder:"Strategy Name"}),e.jsx(se,{placeholder:"Description"}),e.jsx(se,{placeholder:"Tags (comma separated)"}),e.jsx(W,{className:"w-full",children:"Submit to Library"})]})]})]})]})}),e.jsxs(H,{className:"space-y-2",children:[e.jsx("div",{className:"flex gap-2",children:e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Qr,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3 w-3 text-muted-foreground"}),e.jsx(se,{placeholder:"Search templates...",value:t,onChange:o=>s(o.target.value),className:"h-7 pl-7 text-xs"})]})}),e.jsx("div",{className:"flex gap-1 flex-wrap",children:["momentum","mean_reversion","trend","volatility","multi_factor"].map(o=>e.jsxs(C,{variant:a===o?"default":"outline",className:`cursor-pointer text-[9px] h-5 ${a!==o?wr[o]:""}`,onClick:()=>r(a===o?null:o),children:[Nr[o],e.jsx("span",{className:"ml-1",children:o.replace("_"," ")})]},o))}),e.jsx(Et,{className:"h-[200px]",children:e.jsx("div",{className:"space-y-2",children:d.map(o=>e.jsxs("div",{className:"p-2 rounded border border-border/30 bg-background/30 space-y-1.5",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:wr[o.category],children:Nr[o.category]}),e.jsx("span",{className:"text-xs font-medium",children:o.name})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-1",children:o.description})]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(Pr,{className:`h-3 w-3 ${n.includes(o.id)?"text-yellow-400 fill-yellow-400":"text-muted-foreground"}`,onClick:()=>l(o.id)}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:o.rating})]})]}),e.jsxs("div",{className:"flex gap-2 text-[9px]",children:[e.jsxs("span",{className:"text-green-400",children:["SR: ",o.sharpe]}),e.jsxs("span",{className:"text-blue-400",children:["WR: ",o.winRate,"%"]}),e.jsxs("span",{className:"text-red-400",children:["DD: ",o.maxDrawdown,"%"]}),e.jsxs("span",{className:"text-muted-foreground",children:[o.downloads," uses"]})]}),e.jsx("div",{className:"flex gap-1 flex-wrap",children:o.tags.slice(0,3).map(u=>e.jsx(C,{variant:"secondary",className:"text-[8px] h-4 px-1",children:u},u))}),e.jsxs("div",{className:"flex gap-1 pt-1",children:[e.jsxs(W,{size:"sm",variant:"default",className:"h-5 px-2 text-[10px] flex-1",onClick:()=>i(o),children:[e.jsx(ba,{className:"h-2.5 w-2.5 mr-1"}),"Use Template"]}),e.jsx(W,{size:"sm",variant:"outline",className:"h-5 px-2 text-[10px]",children:e.jsx(ha,{className:"h-2.5 w-2.5"})})]})]},o.id))})})]})]})},xa={entry:{min:.5,max:.95},stopLoss:{min:.5,max:5},takeProfit:{min:1,max:10},lookback:{min:5,max:50},rsi:{min:7,max:21},posSize:{min:1,max:25}},pd=()=>{const[t,s]=j.useState(!1),[a,r]=j.useState(0),[n,c]=j.useState({populationSize:50,generations:100,mutationRate:.1,crossoverRate:.8,elitismRate:.1}),[d,i]=j.useState([]),[l,o]=j.useState(null),[u,v]=j.useState([]),h=j.useRef(null),m=k=>{const{entry:M,stopLoss:T,takeProfit:A,lookback:B,rsi:z,posSize:U}=k,G=A/T,K=M*30+G*10,$=T*2+U*.5,L=B>15&&B<35?5:0,D=z>=12&&z<=16?3:0,F=(Math.random()-.5)*5;return Math.max(0,K-$+L+D+F)},f=(k,M)=>{const T={};return Object.entries(xa).forEach(([A,B])=>{T[A]=B.min+Math.random()*(B.max-B.min)}),{id:k,genes:T,fitness:m(T),generation:M}},b=(k,M,T,A)=>{const B={};
116return Object.keys(xa).forEach(z=>{B[z]=Math.random()<.5?k.genes[z]:M.genes[z]}),{id:T,genes:B,fitness:m(B),generation:A}},_=k=>{const M={...k.genes};return Object.entries(xa).forEach(([T,A])=>{if(Math.random()<n.mutationRate){const B=(A.max-A.min)*.2*(Math.random()-.5);M[T]=Math.max(A.min,Math.min(A.max,M[T]+B))}}),{...k,genes:M,fitness:m(M)}},y=()=>{r(k=>{const M=k+1;return i(T=>{const A=[...T].sort((K,$)=>$.fitness-K.fitness),B=Math.floor(n.populationSize*n.elitismRate),z=A.slice(0,B).map((K,$)=>({...K,id:$,generation:M}));for(;z.length<n.populationSize;){const K=A[Math.floor(Math.random()*(A.length/2))],$=A[Math.floor(Math.random()*(A.length/2))];let L;Math.random()<n.crossoverRate?L=b(K,$,z.length,M):L=f(z.length,M),L=_(L),z.push(L)}const U=z.reduce((K,$)=>K.fitness>$.fitness?K:$),G=z.reduce((K,$)=>K+$.fitness,0)/z.length;return o(U),v(K=>[...K,{gen:M,best:U.fitness,avg:G}]),z}),M>=n.generations&&(s(!1),h.current&&clearInterval(h.current)),M})},N=()=>{s(!0),r(0),v([]);const k=Array.from({length:n.populationSize},(A,B)=>f(B,0));i(k);const M=k.reduce((A,B)=>A.fitness>B.fitness?A:B),T=k.reduce((A,B)=>A+B.fitness,0)/k.length;o(M),v([{gen:0,best:M.fitness,avg:T}]),h.current=setInterval(y,100)},w=()=>{s(!1),h.current&&clearInterval(h.current)},g=()=>{w(),r(0),i([]),o(null),v([])};return j.useEffect(()=>()=>{h.current&&clearInterval(h.current)},[]),e.jsxs(q,{className:"border-border/50 bg-card/30 backdrop-blur",children:[e.jsx(X,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(xi,{className:"h-4 w-4 text-primary"}),"Genetic Algorithm Optimizer"]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(W,{size:"sm",variant:"ghost",className:"h-6 px-2",onClick:g,children:e.jsx(Xs,{className:"h-3 w-3"})}),t?e.jsxs(W,{size:"sm",variant:"destructive",className:"h-6 px-2 text-xs",onClick:w,children:[e.jsx(Fr,{className:"h-3 w-3 mr-1"}),"Stop"]}):e.jsxs(W,{size:"sm",variant:"default",className:"h-6 px-2 text-xs",onClick:N,children:[e.jsx(Je,{className:"h-3 w-3 mr-1"}),"Evolve"]})]})]})}
116),e.jsxs(H,{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-[10px]",children:[e.jsxs("span",{className:"text-muted-foreground",children:["Generation ",a," / ",n.generations]}),e.jsxs("span",{className:"text-primary",children:[(a/n.generations*100).toFixed(0),"%"]})]}),e.jsx(Xe,{value:a/n.generations*100,className:"h-1.5"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs("div",{className:"flex justify-between text-[9px]",children:[e.jsx("span",{className:"text-muted-foreground",children:"Population"}),e.jsx(C,{variant:"outline",className:"h-4 px-1 text-[8px]",children:n.populationSize})]}),e.jsx(ee,{value:[n.populationSize],min:20,max:200,step:10,onValueChange:([k])=>c(M=>({...M,populationSize:k})),disabled:t,className:"h-3"})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs("div",{className:"flex justify-between text-[9px]",children:[e.jsx("span",{className:"text-muted-foreground",children:"Mutation"}),e.jsxs(C,{variant:"outline",className:"h-4 px-1 text-[8px]",children:[(n.mutationRate*100).toFixed(0),"%"]})]}),e.jsx(ee,{value:[n.mutationRate],min:.01,max:.5,step:.01,onValueChange:([k])=>c(M=>({...M,mutationRate:k})),disabled:t,className:"h-3"})]})]}),u.length>0&&e.jsx("div",{className:"h-24 w-full",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(At,{data:u,children:[e.jsx(de,{dataKey:"gen",hide:!0}),e.jsx(oe,{hide:!0,domain:["auto","auto"]}),e.jsx(Ne,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))"},labelStyle:{color:"hsl(var(--foreground))"},formatter:k=>k.toFixed(2)}),e.jsx(Fe,{type:"monotone",dataKey:"best",stroke:"hsl(var(--primary))",strokeWidth:2,dot:!1,name:"Best"}),e.jsx(Fe,{type:"monotone",dataKey:"avg",stroke:"hsl(var(--muted-foreground))",strokeWidth:1,dot:!1,name:"Avg"})]})})}),l&&e.jsxs("div",{className:"p-2 rounded border border-primary/30 bg-primary/5 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs font-medium flex items-center gap-1",children:[e.jsx(pe,{className:"h-3 w-3 text-primary"}),"Best Individual"]}),e.jsxs(C,{className:"h-4 px-1.5 text-[9px]",children:["Fitness: ",l.fitness.toFixed(2)]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-1 text-[9px]",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Entry:"}),e.jsx("span",{children:l.genes.entry.toFixed(2)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"SL:"}),e.jsxs("span",{children:[l.genes.stopLoss.toFixed(1),"%"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"TP:"}),e.jsxs("span",{children:[l.genes.takeProfit.toFixed(1),"%"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Lookback:"}),e.jsx("span",{children:l.genes.lookback.toFixed(0)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"RSI:"}),e.jsx("span",{children:l.genes.rsi.toFixed(0)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Size:"}),e.jsxs("span",{children:[l.genes.posSize.toFixed(0),"%"]})]})]})]}),d.length>0&&e.jsx(Et,{className:"h-16",children:e.jsx("div",{className:"space-y-1",children:d.sort((k,M)=>M.fitness-k.fitness).slice(0,5).map((k,M)=>e.jsxs("div",{className:"flex items-center justify-between text-[9px] px-1 py-0.5 rounded bg-background/30",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[M===0?e.jsx(Be,{className:"h-2.5 w-2.5 text-yellow-400"}):M===1?e.jsx(he,{className:"h-2.5 w-2.5 text-muted-foreground"}):e.jsx("span",{className:"w-2.5 text-center text-muted-foreground",children:M+1}),e.jsxs("span",{className:"text-muted-foreground",children:["Gen ",k.generation]})]}),e.jsx("span",{className:M===0?"text-primary font-medium":"text-foreground",children:k.fitness.toFixed(2)})]},k.id))})})]})]})},gd=()=>{const[t,s]=j.useState(!1),[a,r]=j.useState(0),[n]=j.useState(50),[c,d]=j.useState("EI"),[i,l]=j.useState([]),[o,u]=j.useState(null),[v,h]=j.useState([]),m=j.useRef(null),f=k=>{const{entry:M,stopLoss:T,takeProfit:A,lookback:B}=k,z=A/T,U=M*25+z*8,G=Math.abs(B-20)*.3,K=(Math.random()-.5)*3;return Math.max(0,U-G+K)},b=(k,M)=>{const T=f(k),A=Math.random()*5;switch(c){case"EI":return Math.max(0,T-M)+.1*A;case"UCB":return T+2*A;case"PI":return T>M?.8+Math.random()*.2:Math.random()*.3;default:return T}},_=k=>{let M={entry:.5+Math.random()*.45,stopLoss:.5+Math.random()*4.5,takeProfit:1+Math.random()*9,lookback:5+Math.random()*45},T=-1/0;for(let A=0;A<20;A++){const B={entry:.5+Math.random()*.45,stopLoss:.5+Math.random()*4.5,takeProfit:1+Math.random()*9,lookback:5+Math.random()*45},z=b(B,k);z>T&&(T=z,M=B)}return M},y=()=>{r(k=>{const M=k+1,T=(o==null?void 0:o.objective)||0,A=_(T),B=f(A),z=b(A,T),U={iteration:M,params:A,objective:B,acquisitionValue:z};return l(G=>[...G,U]),(!o||B>o.objective)&&u(U),h(G=>[...G,{iter:M,best:Math.max(T,B),current:B}]),M>=n&&(s(!1),m.current&&clearInterval(m.current)),M})},N=()=>{s(!0),r(0),l([]),u(null),h([]),m.current=setInterval(y,150)},w=()=>{s(!1),m.current&&clearInterval(m.current)},g=()=>{w(),r(0),l([]),u(null),h([])};return j.useEffect(()=>()=>{m.current&&clearInterval(m.current)},[]),e.jsxs(q,{className:"border-border/50 bg-card/30 backdrop-blur",children:[e.jsx(X,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(lt,{className:"h-4 w-4 text-purple-400"}),"Bayesian Optimizer"]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(W,{size:"sm",variant:"ghost",className:"h-6 px-2",onClick:g,children:e.jsx(Xs,{className:"h-3 w-3"})}),t?e.jsxs(W,{size:"sm",variant:"destructive",className:"h-6 px-2 text-xs",onClick:w,children:[e.jsx(Fr,{className:"h-3 w-3 mr-1"}),"Stop"]}):e.jsxs(W,{size:"sm",variant:"default",className:"h-6 px-2 text-xs",onClick:N,children:[e.jsx(Je,{className:"h-3 w-3 mr-1"}),"Optimize"]})]})]})}
116),e.jsxs(H,{className:"space-y-3",children:[e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-[10px]",children:[e.jsxs("span",{className:"text-muted-foreground",children:["Iteration ",a,"/",n]}),e.jsxs("span",{className:"text-purple-400",children:[(a/n*100).toFixed(0),"%"]})]}),e.jsx(Xe,{value:a/n*100,className:"h-1.5"})]}),e.jsxs(De,{value:c,onValueChange:k=>d(k),disabled:t,children:[e.jsx(Ee,{className:"h-6 w-20 text-[10px]",children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(ie,{value:"EI",className:"text-xs",children:"EI"}),e.jsx(ie,{value:"UCB",className:"text-xs",children:"UCB"}),e.jsx(ie,{value:"PI",className:"text-xs",children:"PI"})]})]})]}),v.length>0&&e.jsx("div",{className:"h-20 w-full",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(At,{data:v,children:[e.jsx(de,{dataKey:"iter",hide:!0}),e.jsx(oe,{hide:!0,domain:["auto","auto"]}),e.jsx(Ne,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",fontSize:"10px"},formatter:k=>k.toFixed(2)}),e.jsx(Fe,{type:"monotone",dataKey:"best",stroke:"hsl(var(--primary))",strokeWidth:2,dot:!1,name:"Best"}),e.jsx(Fe,{type:"monotone",dataKey:"current",stroke:"hsl(var(--muted-foreground))",strokeWidth:1,dot:!1,name:"Current",strokeDasharray:"3 3"})]})})}),i.length>0&&e.jsx("div",{className:"h-20 w-full",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(hn,{children:[e.jsx(de,{dataKey:"entry",name:"Entry",domain:[.5,.95],tick:{fontSize:8}}),e.jsx(oe,{dataKey:"objective",name:"Objective",domain:["auto","auto"],tick:{fontSize:8}}),e.jsx(It,{dataKey:"iteration",range:[20,100]}),e.jsx(Ne,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",fontSize:"10px"},formatter:k=>k.toFixed(2)}),e.jsx(Bt,{data:i.map(k=>({entry:k.params.entry,objective:k.objective,iteration:k.iteration})),fill:"hsl(var(--primary))",fillOpacity:.6})]})})}),o&&e.jsxs("div",{className:"p-2 rounded border border-purple-500/30 bg-purple-500/5 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs font-medium flex items-center gap-1",children:[e.jsx(_t,{className:"h-3 w-3 text-purple-400"}),"Best Found (Iter ",o.iteration,")"]}),e.jsxs(C,{className:"h-4 px-1.5 text-[9px] bg-purple-500/20 text-purple-300",children:["Obj: ",o.objective.toFixed(2)]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1 text-[9px]",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Entry:"}),e.jsx("span",{children:o.params.entry.toFixed(3)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Stop Loss:"}),e.jsxs("span",{children:[o.params.stopLoss.toFixed(2),"%"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Take Profit:"}),e.jsxs("span",{children:[o.params.takeProfit.toFixed(2),"%"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Lookback:"}),e.jsx("span",{children:o.params.lookback.toFixed(0)})]})]})]}),e.jsxs("div",{className:"flex gap-2 text-[9px]",children:[e.jsxs(C,{variant:"outline",className:"h-4 px-1",children:[e.jsx(Be,{className:"h-2.5 w-2.5 mr-0.5"}),"Samples: ",i.length]}),e.jsxs(C,{variant:"outline",className:"h-4 px-1",children:[e.jsx(he,{className:"h-2.5 w-2.5 mr-0.5"}),"Acq: ",c]})]})]})]})},Cs=[{id:"1",name:"Institutional Momentum Alpha",description:"Battle-tested momentum strategy used by top hedge funds",author:"QuantElite",verified:!0,price:299,rating:4.9,reviews:156,downloads:2340,sharpe:2.4,winRate:65,maxDrawdown:8,category:"premium",tags:["momentum","institutional","crypto"],preview:!0},{id:"2",name:"Mean Reversion Pro Suite",description:"Statistical arbitrage with advanced pair selection",author:"AlphaQuant",verified:!0,price:199,rating:4.7,reviews:89,downloads:1567,sharpe:2.1,winRate:62,maxDrawdown:10,category:"premium",tags:["mean-reversion","pairs","equities"],preview:!0},{id:"3",name:"Volatility Harvester X",description:"Capture volatility risk premium with dynamic hedging",author:"VolMaster",verified:!0,price:149,rating:4.6,reviews:67,downloads:987,sharpe:1.9,winRate:58,maxDrawdown:12,category:"pro",tags:["volatility","options","hedging"],preview:!0},{id:"4",name:"Trend Following Elite",description:"Multi-timeframe trend detection with ML enhancement",author:"TrendLab",verified:!1,price:99,rating:4.5,reviews:45,downloads:756,sharpe:1.8,winRate:55,maxDrawdown:15,category:"pro",tags:["trend","ml","forex"],preview:!1},{id:"5",name:"Scalper Genesis",description:"High-frequency scalping with tight risk management",author:"ScalpKing",verified:!0,price:79,rating:4.4,reviews:112,downloads:1890,sharpe:1.6,winRate:68,maxDrawdown:5,category:"pro",tags:["scalping","high-freq","crypto"],preview:!0},{id:"6",name:"Community Momentum Basic",description:"Open-source momentum strategy for beginners",author:"OpenQuant",verified:!1,price:0,rating:4.2,reviews:234,downloads:5670,sharpe:1.4,winRate:52,maxDrawdown:18,category:"free",tags:["momentum","beginner","all-markets"],preview:!0},{id:"7",name:"Factor Portfolio Starter",description:"Multi-factor portfolio with basic rebalancing",author:"FactorFree",verified:!1,price:0,rating:4.1,reviews:178,downloads:4320,sharpe:1.3,winRate:50,maxDrawdown:20,category:"free",tags:["factors","portfolio","etf"],preview:!0}],fd=t=>{localStorage.setItem("aq_trial_agent",JSON.stringify({name:t,timestamp:Date.now()}))},bd=()=>{const t=Dr(),[s,a]=j.useState(""),[r,n]=j.useState("all"),[c,d]=j.useState([]),[i,l]=j.useState(["6","7"]),[o,u]=j.useState(!1),[v,h]=j.useState(null),m=Cs.filter(g=>{const k=g.name.toLowerCase().includes(s.toLowerCase())||g.description.toLowerCase().includes(s.toLowerCase())||g.tags.some(T=>T.toLowerCase().includes(s.toLowerCase())),M=r==="all"||g.category===r;return k&&M}),f=g=>{c.includes(g)||(d([...c,g]),ve.success("Added to cart"))},b=g=>{d(c.filter(k=>k!==g))},_=g=>{g.price===0||i.includes(g.id)?(l([...i,g.id]),ve.success(`"${g.name}" added to your library`)):(ve.success(`Purchased "${g.name}" for $${g.price}`),l([...i,g.id]),d(c.filter(k=>k!==g.id)))},y=g=>{h(g),u(!0)},N=()=>{v&&(fd(v.name),u(!1),ve.success(`Starting trial with "${v.name}"`,{description:"Opening API Trading page..."}),t("/api"))},w=c.reduce((g,k)=>{const M=Cs.find(T=>T.id===k);return g+((M==null?void 0:M.price)||0)},0);return e.jsxs(q,{className:"border-border/50 bg-card/30 backdrop-blur",children:[e.jsx(X,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(bi,{className:"h-4 w-4 text-emerald-400"}
116),"Strategy Marketplace"]}),e.jsxs(Kt,{children:[e.jsx(Rr,{asChild:!0,children:e.jsxs(W,{size:"sm",variant:"outline",className:"h-6 px-2 text-xs relative",children:[e.jsx(Ja,{className:"h-3 w-3 mr-1"}),"Cart",c.length>0&&e.jsx(C,{className:"absolute -top-1 -right-1 h-4 w-4 p-0 text-[8px] flex items-center justify-center",children:c.length})]})}),e.jsxs(Ut,{children:[e.jsx(Xt,{children:e.jsx(Yt,{children:"Shopping Cart"})}),e.jsx("div",{className:"space-y-2 py-4",children:c.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Your cart is empty"}):c.map(g=>{const k=Cs.find(M=>M.id===g);return k?e.jsxs("div",{className:"flex items-center justify-between p-2 rounded bg-muted/30",children:[e.jsx("span",{className:"text-sm",children:k.name}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-medium",children:["$",k.price]}),e.jsx(W,{size:"sm",variant:"ghost",className:"h-6 px-2",onClick:()=>b(g),children:"Ã"})]})]},g):null})}),c.length>0&&e.jsx(pa,{children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsxs("span",{className:"font-medium",children:["Total: $",w]}),e.jsx(W,{onClick:()=>c.forEach(g=>{const k=Cs.find(M=>M.id===g);k&&_(k)}),children:"Checkout"})]})})]})]})]})}
116),e.jsxs(H,{className:"space-y-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Qr,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3 w-3 text-muted-foreground"}),e.jsx(se,{placeholder:"Search strategies...",value:s,onChange:g=>a(g.target.value),className:"h-7 pl-7 text-xs"})]}),e.jsx(vs,{value:r,onValueChange:n,children:e.jsxs(js,{className:"h-7 w-full",children:[e.jsx(Ie,{value:"all",className:"text-[10px] flex-1",children:"All"}),e.jsxs(Ie,{value:"premium",className:"text-[10px] flex-1",children:[e.jsx(at,{className:"h-2.5 w-2.5 mr-0.5 text-yellow-400"}),"Premium"]}),e.jsxs(Ie,{value:"pro",className:"text-[10px] flex-1",children:[e.jsx(pe,{className:"h-2.5 w-2.5 mr-0.5 text-blue-400"}),"Pro"]}),e.jsx(Ie,{value:"free",className:"text-[10px] flex-1",children:"Free"})]})}),e.jsx(Et,{className:"h-[220px]",children:e.jsx("div",{className:"space-y-2",children:m.map(g=>e.jsxs("div",{className:"p-2 rounded border border-border/30 bg-background/30 space-y-1.5",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[g.category==="premium"&&e.jsx(at,{className:"h-3 w-3 text-yellow-400"}),g.category==="pro"&&e.jsx(pe,{className:"h-3 w-3 text-blue-400"}),e.jsx("span",{className:"text-xs font-medium",children:g.name}),g.verified&&e.jsx(oi,{className:"h-3 w-3 text-green-400"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-1",children:g.description}),e.jsx("div",{className:"flex items-center gap-1 mt-0.5",children:e.jsxs("span",{className:"text-[9px] text-muted-foreground",children:["by ",g.author]})})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(Pr,{className:"h-3 w-3 text-yellow-400 fill-yellow-400"}),e.jsx("span",{className:"text-[10px]",children:g.rating}),e.jsxs("span",{className:"text-[9px] text-muted-foreground",children:["(",g.reviews,")"]})]}),e.jsx("div",{className:"text-sm font-bold text-emerald-400",children:g.price===0?"FREE":`$${g.price}`})]})]}),e.jsxs("div",{className:"flex gap-2 text-[9px]",children:[e.jsxs("span",{className:"text-green-400",children:["SR: ",g.sharpe]}),e.jsxs("span",{className:"text-blue-400",children:["WR: ",g.winRate,"%"]}),e.jsxs("span",{className:"text-red-400",children:["DD: ",g.maxDrawdown,"%"]}),e.jsxs("span",{className:"text-muted-foreground flex items-center gap-0.5",children:[e.jsx(us,{className:"h-2.5 w-2.5"}),g.downloads]})]}),e.jsx("div",{className:"flex gap-1 flex-wrap",children:g.tags.slice(0,3).map(k=>e.jsx(C,{variant:"secondary",className:"text-[8px] h-4 px-1",children:k},k))}),e.jsxs("div",{className:"flex gap-1 pt-1",children:[i.includes(g.id)?e.jsxs(W,{size:"sm",variant:"outline",className:"h-5 px-2 text-[10px] flex-1",disabled:!0,children:[e.jsx(ba,{className:"h-2.5 w-2.5 mr-1"}),"Owned"]}):g.price===0?e.jsxs(e.Fragment,{children:[e.jsxs(W,{size:"sm",variant:"default",className:"h-5 px-2 text-[10px] flex-1",onClick:()=>_(g),children:[e.jsx(ba,{className:"h-2.5 w-2.5 mr-1"}),"Get Free"]}),e.jsxs(W,{size:"sm",variant:"secondary",className:"h-5 px-2 text-[10px]",onClick:()=>y(g),children:[e.jsx(Je,{className:"h-2.5 w-2.5 mr-1"}),"Trial"]}
116)]}):e.jsxs(e.Fragment,{children:[e.jsxs(W,{size:"sm",variant:"default",className:"h-5 px-2 text-[10px] flex-1",onClick:()=>_(g),children:[e.jsx(zn,{className:"h-2.5 w-2.5 mr-0.5"}),"Buy $",g.price]}),e.jsx(W,{size:"sm",variant:"secondary",className:"h-5 px-2 text-[10px]",onClick:()=>y(g),children:e.jsx(Je,{className:"h-2.5 w-2.5"})}),e.jsx(W,{size:"sm",variant:"outline",className:"h-5 px-2 text-[10px]",onClick:()=>f(g.id),children:e.jsx(Ja,{className:"h-2.5 w-2.5"})})]}),g.preview&&e.jsx(W,{size:"sm",variant:"ghost",className:"h-5 px-2 text-[10px]",children:e.jsx(gt,{className:"h-2.5 w-2.5"})})]})]},g.id))})}),e.jsx(Kt,{open:o,onOpenChange:u,children:e.jsxs(Ut,{className:"sm:max-w-md",children:[e.jsx(Xt,{children:e.jsxs(Yt,{className:"flex items-center gap-2",children:[e.jsx(Je,{className:"h-5 w-5 text-primary"}),"Start Free Trial"]})}),v&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-3 bg-secondary/50 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[v.category==="premium"&&e.jsx(at,{className:"h-4 w-4 text-yellow-400"}),v.category==="pro"&&e.jsx(pe,{className:"h-4 w-4 text-blue-400"}),e.jsx("span",{className:"font-medium",children:v.name})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:v.description}),e.jsxs("div",{className:"flex gap-3 mt-2 text-xs",children:[e.jsxs("span",{className:"text-green-400",children:["SR: ",v.sharpe]}),e.jsxs("span",{className:"text-blue-400",children:["WR: ",v.winRate,"%"]}),e.jsxs("span",{className:"text-red-400",children:["DD: ",v.maxDrawdown,"%"]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("p",{children:"Your trial includes:"}),e.jsxs("ul",{className:"list-disc list-inside mt-1 space-y-1",children:[e.jsx("li",{children:"Demo trading with real market data"}),e.jsx("li",{children:"Live agent signals in real-time"}),e.jsx("li",{children:"Full performance analytics"}),e.jsx("li",{children:"Persistent data and signal tracking"})]})]})]}),e.jsxs(pa,{className:"gap-2",children:[e.jsx($n,{asChild:!0,children:e.jsx(W,{variant:"outline",children:"Cancel"})}),e.jsxs(W,{onClick:N,className:"gap-2",children:[e.jsx(Ar,{className:"h-4 w-4"}),"Go to Demo Trading"]})]})]})})]})]})},Ts=[{key:"entry",label:"Entry",min:.5,max:.95,step:.05},{key:"stopLoss",label:"Stop Loss",min:.5,max:5,step:.5},{key:"takeProfit",label:"Take Profit",min:1,max:10,step:1},{key:"lookback",label:"Lookback",min:5,max:50,step:5},{key:"rsi",label:"RSI Period",min:7,max:21,step:2},{key:"posSize",label:"Position %",min:5,max:25,step:5}],vd=()=>{var w;const[t,s]=j.useState("entry"),[a,r]=j.useState("stopLoss"),[n,c]=j.useState("sharpe"),[d,i]=j.useState([]),[l,o]=j.useState(!1),u=Ts.find(g=>g.key===t),v=Ts.find(g=>g.key===a),h=(g,k,M)=>{const T=[];for(let A=g;A<=k;A+=M)T.push(Number(A.toFixed(2)));return T.slice(0,10)},m=(g,k)=>{const M=t==="entry"?g:a==="entry"?k:.7,T=t==="stopLoss"?g:a==="stopLoss"?k:2,A=t==="takeProfit"?g:
116a==="takeProfit"?k:4,B=t==="lookback"?g:a==="lookback"?k:20,z=A/T,U=.8+M*1.5+z*.3-Math.abs(B-20)*.02+(Math.random()-.5)*.3,G=45+M*20-T*2+z*3+(Math.random()-.5)*5,K=5+T*3-M*5+(Math.random()-.5)*3;return{sharpe:Math.max(0,Math.min(3,U)),winRate:Math.max(30,Math.min(80,G)),drawdown:Math.max(3,Math.min(30,K))}},f=()=>{o(!0),setTimeout(()=>{const g=h(u.min,u.max,u.step),M=h(v.min,v.max,v.step).map((T,A)=>g.map((B,z)=>{const U=m(B,T);return{x:z,y:A,xLabel:B.toString(),yLabel:T.toString(),value:n==="sharpe"?U.sharpe:n==="winRate"?U.winRate:U.drawdown,sharpe:U.sharpe,winRate:U.winRate,drawdown:U.drawdown}}));i(M),o(!1)},300)};j.useEffect(()=>{f()},[t,a,n]);const{minValue:b,maxValue:_}=j.useMemo(()=>{if(d.length===0)return{minValue:0,maxValue:1};const g=d.flat().map(k=>k.value);return{minValue:Math.min(...g),maxValue:Math.max(...g)}},[d]),y=g=>{const k=(g-b)/(_-b||1);if(n==="drawdown"){const M=1-k;return M>.7?"bg-green-500/80":M>.5?"bg-green-500/50":M>.3?"bg-yellow-500/50":M>.15?"bg-orange-500/50":"bg-red-500/60"}else return k>.8?"bg-green-500/80":k>.6?"bg-green-500/50":k>.4?"bg-yellow-500/50":k>.2?"bg-orange-500/50":"bg-red-500/60"},N=g=>n==="sharpe"?g.toFixed(2):g.toFixed(1)+"%";return e.jsxs(q,{className:"border-border/50 bg-card/30 backdrop-blur",children:[e.jsx(X,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(Jr,{className:"h-4 w-4 text-orange-400"}),"Parameter Sensitivity"]}),e.jsx(W,{size:"sm",variant:"ghost",className:"h-6 px-2",onClick:f,disabled:l,children:e.jsx(Me,{className:`h-3 w-3 ${l?"animate-spin":""}`})})]})}
116),e.jsxs(H,{className:"space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-1",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("span",{className:"text-[9px] text-muted-foreground",children:"X-Axis"}),e.jsxs(De,{value:t,onValueChange:s,children:[e.jsx(Ee,{className:"h-6 text-[10px]",children:e.jsx(Le,{})}),e.jsx(Oe,{children:Ts.filter(g=>g.key!==a).map(g=>e.jsx(ie,{value:g.key,className:"text-xs",children:g.label},g.key))})]})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("span",{className:"text-[9px] text-muted-foreground",children:"Y-Axis"}),e.jsxs(De,{value:a,onValueChange:r,children:[e.jsx(Ee,{className:"h-6 text-[10px]",children:e.jsx(Le,{})}),e.jsx(Oe,{children:Ts.filter(g=>g.key!==t).map(g=>e.jsx(ie,{value:g.key,className:"text-xs",children:g.label},g.key))})]})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("span",{className:"text-[9px] text-muted-foreground",children:"Metric"}),e.jsxs(De,{value:n,onValueChange:g=>c(g),children:[e.jsx(Ee,{className:"h-6 text-[10px]",children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(ie,{value:"sharpe",className:"text-xs",children:"Sharpe"}),e.jsx(ie,{value:"winRate",className:"text-xs",children:"Win Rate"}),e.jsx(ie,{value:"drawdown",className:"text-xs",children:"Drawdown"})]})]})]})]}),e.jsx(_r,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("div",{className:"min-w-[200px]",children:[e.jsx("div",{className:"flex ml-6 mb-0.5",children:(w=d[0])==null?void 0:w.map((g,k)=>e.jsx("div",{className:"flex-1 text-center text-[8px] text-muted-foreground",children:g.xLabel},k))}),d.map((g,k)=>{var M;return e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"w-6 text-[8px] text-muted-foreground text-right pr-1",children:(M=g[0])==null?void 0:M.yLabel}),g.map((T,A)=>e.jsxs(kr,{children:[e.jsx(Sr,{asChild:!0,children:e.jsx("div",{className:`flex-1 aspect-square min-h-[18px] ${y(T.value)} border border-background/50 cursor-pointer hover:ring-1 hover:ring-primary transition-all`})}),e.jsx(Mr,{side:"top",className:"text-[10px]",children:e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs("div",{className:"font-medium",children:[u.label,": ",T.xLabel,", ",v.label,": ",T.yLabel]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("span",{className:"text-green-400",children:["SR: ",T.sharpe.toFixed(2)]}),e.jsxs("span",{className:"text-blue-400",children:["WR: ",T.winRate.toFixed(1),"%"]}),e.jsxs("span",{className:"text-red-400",children:["DD: ",T.drawdown.toFixed(1),"%"]})]})]})})]},A))]},k)})]})})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center gap-1 text-[9px]",children:n==="drawdown"?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-green-400 flex items-center gap-0.5",children:[e.jsx(ke,{className:"h-2.5 w-2.5"}),"Low"]}),e.jsx("span",{className:"text-muted-foreground",children:"â"}),e.jsxs("span",{className:"text-red-400 flex items-center gap-0.5",children:[e.jsx(he,{className:"h-2.5 w-2.5"}),"High"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-red-400 flex items-center gap-0.5",children:[e.jsx(ke,{className:"h-2.5 w-2.5"}),"Low"]}),e.jsx("span",{className:"text-muted-foreground",children:"â"}),e.jsxs("span",{className:"text-green-400 flex items-center gap-0.5",children:[e.jsx(he,{className:"h-2.5 w-2.5"}),"High"]})]})}),e.jsxs(C,{variant:"outline",className:"h-4 px-1 text-[8px]",children:[n,": ",N(b)," - ",N(_)]})]}),d.length>0&&e.jsx("div",{className:"p-1.5 rounded bg-green-500/10 border border-green-500/30",children:e.jsxs("div",{className:"flex items-center gap-1 text-[9px]",children:[e.jsx(he,{className:"h-3 w-3 text-green-400"}),e.jsx("span",{className:"text-green-400 font-medium",children:"Optimal Region:"}),e.jsx("span",{className:"text-foreground",children:(()=>{const g=d.flat().reduce((k,M)=>n==="drawdown"?k.value<M.value?k:M:k.value>M.value?k:M);return`${u.label}=${g.xLabel}, ${v.label}=${g.yLabel}`})()})]})})]})]})},jd=()=>{const[t,s]=j.useState(!1),[a,r]=j.useState(1e4),[n,c]=j.useState(1e4),[d,i]=j.useState([]),[l,o]=j.useState([]),[u,v]=j.useState([]),[h,m]=j.useState(!0),[f,b]=j.useState(2),[_,y]=j.useState(0),N=j.useRef(null),w=["BTC","ETH","SOL","AAPL","TSLA","SPY"],g=()=>Math.random()<.7?null:{symbol:w[Math.floor(Math.random()*w.length)],side:Math.random()>.5?"buy":"sell",confidence:.6+Math.random()*.35},k=D=>{const F=100+Math.random()*900,R=n*(f/100)/F,Q=d.find(x=>x.symbol===D.symbol);if(Q){const x=D.side==="sell"?(F-Q.entryPrice)*Q.quantity:(Q.entryPrice-F)*Q.quantity,S={id:Date.now().toString(),symbol:D.symbol,side:D.side,price:F,quantity:Q.quantity,pnl:x,timestamp:new Date};o(E=>[S,...E].slice(0,20)),i(E=>E.filter(te=>te.id!==Q.id)),c(E=>E+x)}else{const x={id:Date.now().toString(),symbol:D.symbol,side:D.side==="buy"?"long":"short",entryPrice:F,currentPrice:F,quantity:R,pnl:0,pnlPercent:0,openedAt:new Date};i(E=>[...E,x]);const S={id:Date.now().toString(),symbol:D.symbol,side:D.side,price:F,quantity:R,pnl:0,timestamp:new Date};o(E=>[S,...E].slice(0,20))}},M=()=>{i(D=>D.map(F=>{const R=F.currentPrice*(Math.random()-.5)*.02,Q=F.currentPrice+R,x=F.side==="long"?(Q-F.entryPrice)*F.quantity:(F.entryPrice-Q)*F.quantity,S=(Q-F.entryPrice)/F.entryPrice*100*(F.side==="long"?1:-1);return{...F,currentPrice:Q,pnl:x,pnlPercent:S}}))},T=()=>{if(y(R=>R+1),M(),h){const R=g();R&&R.confidence>.7&&k(R)}const D=d.reduce((R,Q)=>R+Q.pnl,0),F=n+D;v(R=>{const Q={time:new Date().toLocaleTimeString(),equity:F};return[...R.slice(-50),Q]})},A=()=>{s(!0),N.current=setInterval(T,1e3)},B=()=>{s(!1),N.current&&clearInterval(N.current)},z=()=>{B(),c(a),i([]),o([]),v([]),y(0)};j.useEffect(()=>()=>{N.current&&clearInterval(N.current)},[]);const U=d.reduce((D,F)=>D+F.pnl,0);l.reduce((D,F)=>D+F.pnl,0);const G=n+U,K=(G-a)/a*100,$=l.filter(D=>D.pnl>0).length,L=l.length>0?$/l.length*100:0;return e.jsxs(q,{className:"border-border/50 bg-card/30 backdrop-blur",children:[e.jsx(X,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(ge,{className:"h-4 w-4 text-cyan-400"}),"Paper Trading Mode"]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(C,{variant:"outline",className:"h-5 px-1.5 text-[9px]",children:[e.jsx(dt,{className:"h-2.5 w-2.5 mr-0.5"}),Math.floor(_/60),":",(_%60).toString().padStart(2,"0")]}),e.jsx(W,{size:"sm",variant:"ghost",className:"h-6 px-2",onClick:z,children:e.jsx(Xs,{className:"h-3 w-3"})}),t?e.jsxs(W,{size:"sm",variant:"destructive",className:"h-6 px-2 text-xs",onClick:B,children:[e.jsx(Os,{className:"h-3 w-3 mr-1"}),"Pause"]}):e.jsxs(W,{size:"sm",variant:"default",className:"h-6 px-2 text-xs",onClick:A,children:[e.jsx(Je,{className:"h-3 w-3 mr-1"}),"Start"]})]})]})}
116),e.jsxs(H,{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(P,{className:"text-[9px]",children:"Initial Capital"}),e.jsx(se,{type:"number",value:a,onChange:D=>r(Number(D.target.value)),className:"h-6 text-xs",disabled:t})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(P,{className:"text-[9px]",children:"Risk/Trade %"}),e.jsx(se,{type:"number",value:f,onChange:D=>b(Number(D.target.value)),className:"h-6 text-xs",min:.5,max:10,step:.5})]}),e.jsxs("div",{className:"flex items-end gap-1.5 pb-0.5",children:[e.jsx(ye,{checked:h,onCheckedChange:m,className:"scale-75"}),e.jsx("span",{className:"text-[9px] text-muted-foreground",children:"Auto-trade"})]})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-1.5",children:[e.jsxs("div",{className:"p-1.5 rounded bg-background/50 text-center",children:[e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"Equity"}),e.jsxs("div",{className:"text-xs font-bold",children:["$",G.toFixed(0)]})]}),e.jsxs("div",{className:"p-1.5 rounded bg-background/50 text-center",children:[e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"Return"}),e.jsxs("div",{className:`text-xs font-bold flex items-center justify-center gap-0.5 ${K>=0?"text-green-400":"text-red-400"}`,children:[K>=0?e.jsx(he,{className:"h-2.5 w-2.5"}):e.jsx(ke,{className:"h-2.5 w-2.5"}),K.toFixed(2),"%"]})]}),e.jsxs("div",{className:"p-1.5 rounded bg-background/50 text-center",children:[e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"Win Rate"}),e.jsxs("div",{className:`text-xs font-bold ${L>=50?"text-green-400":"text-yellow-400"}`,children:[L.toFixed(1),"%"]})]}),e.jsxs("div",{className:"p-1.5 rounded bg-background/50 text-center",children:[e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"Trades"}),e.jsx("div",{className:"text-xs font-bold",children:l.length})]})]}),u.length>1&&e.jsx("div",{className:"h-16 w-full",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(At,{data:u,children:[e.jsx(fe,{y:a,stroke:"hsl(var(--muted-foreground))",strokeDasharray:"3 3",strokeOpacity:.3}),e.jsx(de,{dataKey:"time",hide:!0}),e.jsx(oe,{hide:!0,domain:["auto","auto"]}),e.jsx(Fe,{type:"monotone",dataKey:"equity",stroke:G>=a?"hsl(142, 76%, 36%)":"hsl(0, 84%, 60%)",strokeWidth:1.5,dot:!1,isAnimationActive:!1})]})})}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-[10px] text-muted-foreground font-medium",children:["Open Positions (",d.length,")"]}),e.jsxs("span",{className:`text-[10px] font-medium ${U>=0?"text-green-400":"text-red-400"}`,children:["Unrealized: $",U.toFixed(2)]})]}),e.jsx(Et,{className:"h-16",children:e.jsx("div",{className:"space-y-0.5",children:d.length===0?e.jsx("div",{className:"text-[10px] text-muted-foreground text-center py-2",children:"No open positions"}):d.map(D=>e.jsxs("div",{className:"flex items-center justify-between p-1 rounded bg-background/30 text-[9px]",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(C,{variant:D.side==="long"?"default":"destructive",className:"h-4 px-1 text-[8px]",children:D.side.toUpperCase()}),e.jsx("span",{className:"font-medium",children:D.symbol})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-muted-foreground",children:["$",D.currentPrice.toFixed(2)]}),e.jsxs("span",{className:D.pnl>=0?"text-green-400":"text-red-400",children:[D.pnl>=0?"+":"",D.pnlPercent.toFixed(2),"%"]})]})]},D.id))})})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground font-medium",children:"Recent Trades"}),e.jsx(Et,{className:"h-14",children:e.jsx("div",{className:"space-y-0.5",children:l.length===0?e.jsx("div",{className:"text-[10px] text-muted-foreground text-center py-2",children:"No trades yet"}):l.slice(0,5).map(D=>e.jsxs("div",{className:"flex items-center justify-between p-1 rounded bg-background/30 text-[9px]",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(C,{variant:D.side==="buy"?"default":"secondary",className:"h-4 px-1 text-[8px]",children:D.side.toUpperCase()}),e.jsx("span",{children:D.symbol}),e.jsxs("span",{className:"text-muted-foreground",children:["@$",D.price.toFixed(2)]})]}),e.jsx("span",{className:D.pnl>=0?"text-green-400":D.pnl<0?"text-red-400":"text-muted-foreground",children:D.pnl!==0?(D.pnl>=0?"+":"")+"$"+D.pnl.toFixed(2):"-"})]},D.id))})})]}),e.jsxs("div",{className:"flex items-center justify-between text-[9px]",children:[e.jsx("div",{className:"flex items-center gap-1",children:t?e.jsxs(C,{className:"h-4 px-1.5 bg-green-500/20 text-green-400 border-green-500/30",children:[e.jsx(pe,{className:"h-2.5 w-2.5 mr-0.5 animate-pulse"}),"LIVE"]}):e.jsxs(C,{variant:"outline",className:"h-4 px-1.5",children:[e.jsx(Os,{className:"h-2.5 w-2.5 mr-0.5"}),"PAUSED"]})}),e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Re,{className:"h-2.5 w-2.5"}
116),"Simulated ⢠Not real money"]})]})]})]})};function yd(){var y,N,w;const[t,s]=j.useState(!0),[a,r]=j.useState(new Date),[n,c]=j.useState(()=>Array.from({length:24},(g,k)=>({time:`${k}:00`,var95:2.5+Math.random()*1.5,var99:4+Math.random()*2,cvar95:3.5+Math.random()*1.8}))),[d,i]=j.useState([{label:"Portfolio VaR (95%)",value:3.2,limit:5,unit:"%",status:"safe"},{label:"Portfolio VaR (99%)",value:5.1,limit:8,unit:"%",status:"safe"},{label:"CVaR (Expected Shortfall)",value:4.8,limit:7,unit:"%",status:"warning"},{label:"Max Drawdown",value:8.5,limit:15,unit:"%",status:"safe"},{label:"Beta Exposure",value:.85,limit:1.2,unit:"",status:"safe"},{label:"Volatility (Annualized)",value:18.5,limit:25,unit:"%",status:"safe"}]),[l,o]=j.useState([{name:"Total Portfolio",gross:185,net:42,limit:200},{name:"Single Name",gross:8.5,net:8.5,limit:10},{name:"Sector (Tech)",gross:35,net:28,limit:40},{name:"Sector (Finance)",gross:22,net:18,limit:40},{name:"Crypto",gross:45,net:32,limit:50}]),[u,v]=j.useState({totalMargin:5e5,usedMargin:325e3,availableMargin:175e3,maintenanceMargin:25e4,marginCallLevel:80,currentUtilization:65}),h=[{name:"BTC",value:28,color:"hsl(var(--chart-1))"},{name:"ETH",value:22,color:"hsl(var(--chart-2))"},{name:"Tech Stocks",value:18,color:"hsl(var(--chart-3))"},{name:"Finance",value:12,color:"hsl(var(--chart-4))"},{name:"Other",value:20,color:"hsl(var(--chart-5))"}],m=[{scenario:"Market Crash (-20%)",impact:-12.5,probability:5},{scenario:"Volatility Spike (2x VIX)",impact:-8.2,probability:15},{scenario:"Crypto Winter (-50%)",impact:-18.4,probability:10},{scenario:"Interest Rate Shock (+200bp)",impact:-5.8,probability:20},{scenario:"Liquidity Crisis",impact:-15.2,probability:3}];j.useEffect(()=>{if(!t)return;const g=setInterval(()=>{r(new Date),c(k=>{const M={time:new Date().toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}),var95:2.5+Math.random()*1.5,var99:4+Math.random()*2,cvar95:3.5+Math.random()*1.8};return[...k.slice(1),M]}),i(k=>k.map(M=>({...M,value:Math.max(0,M.value+(Math.random()-.5)*.3),status:M.value/M.limit<.6?"safe":M.value/M.limit<.85?"warning":"critical"}))),v(k=>({...k,currentUtilization:Math.min(95,Math.max(50,k.currentUtilization+(Math.random()-.5)*3))}))},3e3);return()=>clearInterval(g)},[t]);const f=g=>{switch(g){case"safe":return"text-emerald-400";case"warning":return"text-amber-400";case"critical":return"text-destructive";default:return"text-muted-foreground"}},b=g=>{switch(g){case"safe":return"bg-emerald-500/20 border-emerald-500/30";case"warning":return"bg-amber-500/20 border-amber-500/30";case"critical":return"bg-destructive/20 border-destructive/30";default:return"bg-muted/30"}},_=g=>g<60?"bg-emerald-500":g<80?"bg-amber-500":"bg-destructive";return e.jsxs(q,{className:"col-span-full",children:[e.jsx(X,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Y,{className:"text-base flex items-center gap-2",children:[e.jsx(Ce,{className:"w-5 h-5 text-primary"}),"Risk Dashboard",e.jsx(C,{variant:"outline",className:`text-[10px] ${t?"bg-emerald-500/10 text-emerald-400 border-emerald-500/30":"bg-muted/30"}`,children:t?"LIVE":"PAUSED"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["Last update: ",a.toLocaleTimeString()]}),e.jsx(W,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>s(!t),children:t?"Pause":"Resume"}),e.jsxs(W,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",children:[e.jsx(Me,{className:"w-3 h-3"}),"Refresh"]})]})]})}),e.jsx(H,{className:"space-y-6",children:e.jsxs(vs,{defaultValue:"overview",className:"w-full",children:[e.jsxs(js,{className:"w-full grid grid-cols-4 h-8",children:[e.jsx(Ie,{value:"overview",className:"text-xs",children:"Overview"}),e.jsx(Ie,{value:"var",className:"text-xs",children:"VaR Analysis"}),e.jsx(Ie,{value:"exposure",className:"text-xs",children:"Exposure"}),e.jsx(Ie,{value:"stress",className:"text-xs",children:"Stress Tests"})]}),e.jsxs(Ue,{value:"overview",className:"space-y-4 mt-4",children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:d.map((g,k)=>e.jsxs("div",{className:`p-3 rounded-lg border ${b(g.status)}`,children:[e.jsx("p",{className:"text-[10px] text-muted-foreground mb-1",children:g.label}),e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsx("span",{className:`text-xl font-bold font-mono ${f(g.status)}`,children:g.value.toFixed(1)}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:g.unit})]}),e.jsxs("div",{className:"mt-2",children:[e.jsx(Xe,{value:g.value/g.limit*100,className:"h-1"}),e.jsxs("p",{className:"text-[9px] text-muted-foreground mt-1",children:["Limit: ",g.limit,g.unit]})]})]},k))}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs(q,{className:"bg-card/50",children:[e.jsx(X,{className:"pb-2",children:e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(bs,{className:"w-4 h-4 text-amber-400"}),"Margin Utilization"]})}
116),e.jsxs(H,{className:"space-y-4",children:[e.jsxs("div",{className:"relative pt-6",children:[e.jsxs("div",{className:"flex justify-between text-[10px] text-muted-foreground mb-1",children:[e.jsx("span",{children:"0%"}),e.jsx("span",{className:"text-amber-400",children:"Warning: 80%"}),e.jsx("span",{children:"100%"})]}),e.jsxs("div",{className:"h-4 bg-muted rounded-full overflow-hidden relative",children:[e.jsx("div",{className:`h-full ${_(u.currentUtilization)} transition-all duration-500`,style:{width:`${u.currentUtilization}%`}}),e.jsx("div",{className:"absolute top-0 h-full w-0.5 bg-amber-400",style:{left:"80%"}})]}),e.jsxs("div",{className:"text-center mt-2",children:[e.jsxs("span",{className:"text-2xl font-bold font-mono",children:[u.currentUtilization.toFixed(1),"%"]}),e.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:"utilized"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[e.jsxs("div",{className:"p-2 bg-muted/30 rounded",children:[e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Total Margin"}),e.jsxs("p",{className:"text-sm font-mono",children:["$",(u.totalMargin/1e3).toFixed(0),"K"]})]}),e.jsxs("div",{className:"p-2 bg-muted/30 rounded",children:[e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Used"}),e.jsxs("p",{className:"text-sm font-mono",children:["$",(u.usedMargin/1e3).toFixed(0),"K"]})]}),e.jsxs("div",{className:"p-2 bg-emerald-500/10 rounded",children:[e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Available"}),e.jsxs("p",{className:"text-sm font-mono text-emerald-400",children:["$",(u.availableMargin/1e3).toFixed(0),"K"]})]})]})]})]}),e.jsxs(q,{className:"bg-card/50",children:[e.jsx(X,{className:"pb-2",children:e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(Ur,{className:"w-4 h-4 text-primary"}),"Concentration Risk"]})}),e.jsx(H,{children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-32 h-32",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(Ys,{children:[e.jsx(Qs,{data:h,cx:"50%",cy:"50%",innerRadius:30,outerRadius:50,dataKey:"value",stroke:"none",children:h.map((g,k)=>e.jsx(rt,{fill:g.color},k))}),e.jsx(Ne,{contentStyle:{backgroundColor:"hsl(var(--background))",border:"1px solid hsl(var(--border))",borderRadius:"8px",fontSize:"11px"}})]})})}),e.jsx("div",{className:"flex-1 space-y-2",children:h.map((g,k)=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:g.color}}),e.jsx("span",{className:"text-xs",children:g.name})]}),e.jsxs("span",{className:"text-xs font-mono",children:[g.value,"%"]})]},k))})]})})]})]})]}),e.jsxs(Ue,{value:"var",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"p-4 bg-amber-500/10 rounded-lg border border-amber-500/30 text-center",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"VaR 95%"}),e.jsxs("p",{className:"text-2xl font-bold font-mono text-amber-400",children:["-",(y=n[n.length-1])==null?void 0:y.var95.toFixed(2),"%"]}),e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"1-day loss threshold"})]}),e.jsxs("div",{className:"p-4 bg-orange-500/10 rounded-lg border border-orange-500/30 text-center",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"VaR 99%"}),e.jsxs("p",{className:"text-2xl font-bold font-mono text-orange-400",children:["-",(N=n[n.length-1])==null?void 0:N.var99.toFixed(2),"%"]}),e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Extreme loss threshold"})]}),e.jsxs("div",{className:"p-4 bg-rose-500/10 rounded-lg border border-rose-500/30 text-center",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"CVaR 95% (ES)"}),e.jsxs("p",{className:"text-2xl font-bold font-mono text-rose-400",children:["-",(w=n[n.length-1])==null?void 0:w.cvar95.toFixed(2),"%"]}),e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Expected shortfall"})]})]}),e.jsxs(q,{className:"bg-card/50",children:[e.jsx(X,{className:"pb-2",children:e.jsx(Y,{className:"text-sm",children:"Real-Time VaR History (24h)"})}),e.jsx(H,{children:e.jsx("div",{className:"h-48",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(Js,{data:n,margin:{top:5,right:5,left:-20,bottom:0},children:[e.jsx(de,{dataKey:"time",tick:{fontSize:9}}),e.jsx(oe,{tick:{fontSize:9},tickFormatter:g=>`${g}%`}),e.jsx(Ne,{contentStyle:{backgroundColor:"hsl(var(--background))",border:"1px solid hsl(var(--border))",borderRadius:"8px",fontSize:"11px"},formatter:g=>[`${g.toFixed(2)}%`]}),e.jsx(fe,{y:5,stroke:"hsl(var(--destructive))",strokeDasharray:"3 3",label:{value:"Limit",fontSize:9,fill:"hsl(var(--destructive))"}}),e.jsx(We,{type:"monotone",dataKey:"var95",stroke:"hsl(var(--chart-3))",fill:"hsl(var(--chart-3))",fillOpacity:.3,name:"VaR 95%"}),e.jsx(Fe,{type:"monotone",dataKey:"var99",stroke:"hsl(var(--chart-4))",strokeWidth:2,dot:!1,name:"VaR 99%"}),e.jsx(Fe,{type:"monotone",dataKey:"cvar95",stroke:"hsl(var(--destructive))",strokeWidth:2,dot:!1,name:"CVaR 95%"})]})})})})]})]}
116),e.jsxs(Ue,{value:"exposure",className:"space-y-4 mt-4",children:[e.jsx("div",{className:"space-y-3",children:l.map((g,k)=>e.jsxs("div",{className:"p-3 bg-muted/30 rounded-lg",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium",children:g.name}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(C,{variant:"outline",className:"text-[10px]",children:["Gross: ",g.gross.toFixed(1),"%"]}),e.jsxs(C,{variant:"secondary",className:"text-[10px]",children:["Net: ",g.net.toFixed(1),"%"]})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Xe,{value:g.gross/g.limit*100,className:"h-2"}),e.jsx("div",{className:"absolute top-0 h-2 bg-primary/50 rounded-full",style:{width:`${g.net/g.limit*100}%`}})]}),e.jsxs("div",{className:"flex justify-between mt-1",children:[e.jsx("span",{className:"text-[9px] text-muted-foreground",children:"0%"}),e.jsxs("span",{className:`text-[9px] ${g.gross/g.limit>.9?"text-destructive":"text-muted-foreground"}`,children:["Limit: ",g.limit,"%"]})]})]},k))}),e.jsxs(q,{className:"bg-card/50",children:[e.jsx(X,{className:"pb-2",children:e.jsx(Y,{className:"text-sm",children:"Exposure Breakdown"})}),e.jsx(H,{children:e.jsx("div",{className:"h-40",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(ot,{data:l,layout:"vertical",margin:{left:60,right:20},children:[e.jsx(de,{type:"number",tick:{fontSize:9},tickFormatter:g=>`${g}%`}),e.jsx(oe,{dataKey:"name",type:"category",tick:{fontSize:9}}),e.jsx(Ne,{contentStyle:{backgroundColor:"hsl(var(--background))",border:"1px solid hsl(var(--border))",borderRadius:"8px",fontSize:"11px"}}),e.jsx(Ye,{dataKey:"gross",fill:"hsl(var(--chart-1))",name:"Gross"}),e.jsx(Ye,{dataKey:"net",fill:"hsl(var(--chart-2))",name:"Net"})]})})})})]})]}),e.jsxs(Ue,{value:"stress",className:"space-y-4 mt-4",children:[e.jsx("div",{className:"grid gap-3",children:m.map((g,k)=>e.jsxs("div",{className:"p-3 bg-muted/30 rounded-lg flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{className:`w-4 h-4 ${g.impact<-10?"text-destructive":"text-amber-400"}`}),e.jsx("span",{className:"text-sm font-medium",children:g.scenario})]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-1",children:["Historical probability: ",g.probability,"%"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:`text-lg font-bold font-mono ${g.impact<-10?"text-destructive":"text-amber-400"}`,children:[g.impact.toFixed(1),"%"]}),e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Portfolio impact"})]})]},k))}),e.jsxs(q,{className:"bg-card/50",children:[e.jsx(X,{className:"pb-2",children:e.jsx(Y,{className:"text-sm",children:"Scenario Impact Comparison"})}),e.jsx(H,{children:e.jsx("div",{className:"h-40",children:e.jsx(le,{width:"100%",height:"100%",children:e.jsxs(ot,{data:m,margin:{left:0,right:20},children:[e.jsx(de,{dataKey:"scenario",tick:{fontSize:8},angle:-15,textAnchor:"end",height:60}),e.jsx(oe,{tick:{fontSize:9},tickFormatter:g=>`${g}%`}),e.jsx(Ne,{contentStyle:{backgroundColor:"hsl(var(--background))",border:"1px solid hsl(var(--border))",borderRadius:"8px",fontSize:"11px"}}),e.jsx(Ye,{dataKey:"impact",fill:"hsl(var(--destructive))",name:"Impact %"})]})})})})]})]})]})})]})}const Nd=[{value:"momentum",label:"Momentum",description:"Follow price trends"},{value:"mean_reversion",label:"Mean Reversion",description:"Trade against extremes"},{value:"trend_following",label:"Trend Following",description:"Ride longer trends"},{value:"volatility",label:"Volatility",description:"Exploit vol patterns"},{value:"multi_factor",label:"Multi-Factor",description:"Combine multiple signals"}],wd=["BTC","ETH","SOL","XRP","ADA","AVAX","DOT","LINK"],_d=["SPY","QQQ","DIA","IWM"],kd=["AAPLX","MSFTX","GOOGLX","AMZNX","NVDAX","METAX","TSLAX","COINX","HOODX","ORCLX","INTCX","AVGOX","MRVLX","HONX","AMDX","CRMX","ADSKX","NFLXX","PYMNTX","VISAX","MAX","UBERX","ABNBX","SNAPX","PLTX","SHOPX","ZOOMX","DOCUX"],Sd=["AAPLon","MSFTon","GOOGLon","TSLAon","NVDAon","METAon","CRCLon","LLYon","KOon","NVOon","PGon","JPMon","WMTon","TMon","INTCon","CSCOon","ACNon","AMDon","MRVLon","BABAon","PFEon","IBMon","ABTon","CVXon","SBUXon","NKEon","PANWon","UNHon","HDon","BAon","CATon","AXPon","VZon","TXNon","QCOMon","COSTon","MDTon","MCDon","LMTon","NEEon","G
116Eon","AMGNon","GILDon","ADIon","RTXon"],Md=["SPYX","VTIX","GLDX","TQQQX","QQQX","ARKX","DIAX","IWMX","XLKX","XLFX","XLEX","XLVX","XLIX","VGTX","VYMX","SLVX","USOX","TLTX","JNKX","EEMX"],Ad=["IWNon","ITOTon","VOOon","VTIon","AGGon","BNDon","VXUSon","IEFAon","IEMGon","VNQon","VGTon","VHTon","VFHon","VDCon","VPUon"],Cd=[...wd,..._d,...kd,...Sd,...Md,...Ad],Td=[{value:"fixed_fractional",label:"Fixed Fractional",description:"Fixed % of capital per trade"},{value:"kelly_criterion",label:"Kelly Criterion",description:"Optimal growth sizing"},{value:"risk_parity",label:"Risk Parity",description:"Equal risk contribution"},{value:"volatility_targeting",label:"Volatility Targeting",description:"Scale by vol"},{value:"atr_based",label:"ATR-Based",description:"Size by average true range"},{value:"equal_weight",label:"Equal Weight",description:"Equal allocation"}],Rd=[{value:"market",label:"Market",description:"Immediate execution"},{value:"limit",label:"Limit",description:"Execute at price or better"},{value:"stop_limit",label:"Stop Limit",description:"Limit after stop triggered"}],Pd=[{value:"gtc",label:"GTC",description:"Good til cancelled"},{value:"day",label:"Day",description:"Expires end of day"},{value:"ioc",label:"IOC",description:"Immediate or cancel"},{value:"fok",label:"FOK",description:"Fill or kill"}];function pm(){const t=Dr(),s=lc(),[a,r]=j.useState([]),[n,c]=j.useState(!0),[d,i]=j.useState(!1),[l,o]=j.useState(null),[u,v]=j.useState("builder"),[h,m]=j.useState(!1),[f,b]=j.useState([]),[_,y]=j.useState(!1),[N,w]=j.useState(!1),[g,k]=j.useState(null),[M,T]=j.useState("");j.useState(!1);const[A,B]=j.useState([]),[z,U]=j.useState(!1),[G,K]=j.useState({}),[$,L]=j.useState(()=>{const p=new Date;return p.setFullYear(p.getFullYear()-1),p}),[D,F]=j.useState(new Date),[R,Q]=j.useState({identity:!0,strategy:!0,riskMetrics:!1,positionSizing:!1,signalFilters:!1,executionControls:!1,technicalIndicators:!1,regimeDetection:!1,walkForward:!1,mlEnsemble:!1,pairsTrading:!1,executionAlgo:!1,portfolioRisk:!1,betaNeutral:!1,sentiment:!1,riskBudget:!1,regimeBreak:!1,advancedMetrics:!1}),[x,S]=j.useState({name:"",description:"",strategy_type:"momentum",symbols:["BTC","ETH"],is_active:!0,is_public:!1,lookback_period:20,entry_threshold:.02,exit_threshold:.01,stop_loss:.05,take_profit:.1,position_size:.25,max_drawdown_limit:.15,var_threshold:.05,cvar_threshold:.08,target_sharpe:1.5,sortino_target:2,max_beta:1.2,max_correlation:.7,risk_free_rate:.05,sizing_method:"fixed_fractional",kelly_fraction:.25,vol_target:.15,atr_multiplier:2,max_position_pct:.25,min_position_pct:.01,min_signal_strength:.6,signal_confirmation_bars:2,adx_threshold:25,volume_confirmation:!0,min_volume_ratio:1.5,atr_filter_enabled:!0,atr_filter_multiplier:1,correlation_filter_enabled:!1,max_asset_correlation:.8,max_slippage:.01,order_type:"market",time_in_force:"gtc",max_daily_trades:10,cooldown_minutes:15,trading_hours_only:!1,trading_start_hour:9,trading_end_hour:16,partial_fills_allowed:!0,vix_threshold:20,momentum_lookback:50,regime_sensitivity:.5,rsi_period:14,rsi_overbought:70,rsi_oversold:30,macd_fast:12,macd_slow:26,macd_signal:9,bollinger_period:20,bollinger_std:2,ema_fast:12,ema_slow:26,atr_period:14,adx_period:14,stochastic_k:14,stochastic_d:3,williams_r_period:14,cci_period:20,train_period_months:12,test_period_months:3,rebalance_frequency:"monthly",monte_carlo_iterations:1e3,optimization_metric:"sharpe_ratio",walk_forward_windows:4,ml_confidence_weight:.5,ensemble_voting_enabled:!1,feature_importance_threshold:.1,use_regime_switching:!0,hmm_states:3,pairs_trading_enabled:!1,zscore_entry:2,zscore_exit:.5,cointegration_lookback:60,half_life_max:30,execution_algo:"market",twap_duration_minutes:30,vwap_participation_rate:.1,iceberg_show_size:.1,implementation_shortfall_limit:.005,portfolio_var_limit:.03,marginal_var_limit:.01,gross_exposure_limit:2,net_exposure_limit:.3,sector_concentration_limit:.25,single_name_limit:.1,beta_neutral_enabled:!1,target_beta:0,sector_neutral_enabled:!1,factor_neutral_enabled:!1,use_news_sentiment:!1,news_sentiment_weight:.2,use_social_sentiment:!1,social_sentiment_weight:.1,use_onchain_metrics:!1,onchain_weight:.15,risk_budget_pct:1,dynamic_risk_scaling:!0,risk_scale_factor:1,drawdown_risk_reduction:!0,drawdown_reduction_threshold:.1,cusum_threshold:2,structural_break_lookback:100,auto_pause_on_regime_break:!1,target_information_ratio:1,target_treynor_ratio:.1,target_omega_ratio:1.5,min_profit_factor:1.5,min_win_rate:.45,portfolio_optimization:"equal_weight",use_black_litterman:!1,use_hierarchical_risk_parity:!1,rebalance_threshold:.05});j.useEffect(()=>{E()},[]);const E=async()=>{try{const{data:p,error:re}=await ue.from("custom_agents").select("*").order("created_at",{ascending:!1});if(re)throw re;r(p||[])}catch(p){console.error("Error fetching agents:",p)}finally{c(!1)}},te=async()=>
116{if(!x.name.trim()){xe({title:"Error",description:"Agent name is required",variant:"destructive"});return}i(!0);try{const p={name:x.name,description:x.description,strategy_type:x.strategy_type,symbols:x.symbols,is_active:x.is_active,is_public:x.is_public,lookback_period:x.lookback_period,entry_threshold:x.entry_threshold,exit_threshold:x.exit_threshold,stop_loss:x.stop_loss,take_profit:x.take_profit,position_size:x.position_size,max_drawdown_limit:x.max_drawdown_limit,var_threshold:x.var_threshold,cvar_threshold:x.cvar_threshold,target_sharpe:x.target_sharpe,sortino_target:x.sortino_target,max_beta:x.max_beta,max_correlation:x.max_correlation,risk_free_rate:x.risk_free_rate,sizing_method:x.sizing_method,kelly_fraction:x.kelly_fraction,vol_target:x.vol_target,atr_multiplier:x.atr_multiplier,max_position_pct:x.max_position_pct,min_position_pct:x.min_position_pct,min_signal_strength:x.min_signal_strength,signal_confirmation_bars:x.signal_confirmation_bars,adx_threshold:x.adx_threshold,volume_confirmation:x.volume_confirmation,min_volume_ratio:x.min_volume_ratio,atr_filter_enabled:x.atr_filter_enabled,atr_filter_multiplier:x.atr_filter_multiplier,correlation_filter_enabled:x.correlation_filter_enabled,max_asset_correlation:x.max_asset_correlation,max_slippage:x.max_slippage,order_type:x.order_type,time_in_force:x.time_in_force,max_daily_trades:x.max_daily_trades,cooldown_minutes:x.cooldown_minutes,trading_hours_only:x.trading_hours_only,trading_start_hour:x.trading_start_hour,trading_end_hour:x.trading_end_hour,partial_fills_allowed:x.partial_fills_allowed,vix_threshold:x.vix_threshold,momentum_lookback:x.momentum_lookback,regime_sensitivity:x.regime_sensitivity,rsi_period:x.rsi_period,rsi_overbought:x.rsi_overbought,rsi_oversold:x.rsi_oversold,macd_fast:x.macd_fast,macd_slow:x.macd_slow,macd_signal:x.macd_signal,bollinger_period:x.bollinger_period,bollinger_std:x.bollinger_std,ema_fast:x.ema_fast,ema_slow:x.ema_slow,atr_period:x.atr_period,adx_period:x.adx_period,stochastic_k:x.stochastic_k,stochastic_d:x.stochastic_d,williams_r_period:x.williams_r_period,cci_period:x.cci_period,train_period_months:x.train_period_months,test_period_months:x.test_period_months,rebalance_frequency:x.rebalance_frequency,monte_carlo_iterations:x.monte_carlo_iterations,optimization_metric:x.optimization_metric,walk_forward_windows:x.walk_forward_windows,ml_confidence_weight:x.ml_confidence_weight,ensemble_voting_enabled:x.ensemble_voting_enabled,feature_importance_threshold:x.feature_importance_threshold,use_regime_switching:x.use_regime_switching,hmm_states:x.hmm_states,pairs_trading_enabled:x.pairs_trading_enabled,zscore_entry:x.zscore_entry,zscore_exit:x.zscore_exit,cointegration_lookback:x.cointegration_lookback,half_life_max:x.half_life_max,execution_algo:x.execution_algo,twap_duration_minutes:x.twap_duration_minutes,vwap_participation_rate:x.vwap_participation_rate,iceberg_show_size:x.iceberg_show_size,implementation_shortfall_limit:x.implementation_shortfall_limit,portfolio_var_limit:x.portfolio_var_limit,marginal_var_limit:x.marginal_var_limit,gross_exposure_limit:x.gross_exposure_limit,net_exposure_limit:x.net_exposure_limit,sector_concentration_limit:x.sector_concentration_limit,single_name_limit:x.single_name_limit,beta_neutral_enabled:x.beta_neutral_enabled,target_beta:x.target_beta,sector_neutral_enabled:x.sector_neutral_enabled,factor_neutral_enabled:x.factor_neutral_enabled,use_news_sentiment:x.use_news_sentiment,news_sentiment_weight:x.news_sentiment_weight,use_social_sentiment:x.use_social_sentiment,social_sentiment_weight:x.social_sentiment_weight,use_onchain_metrics:x.use_onchain_metrics,onchain_weight:x.onchain_weight,risk_budget_pct:x.risk_budget_pct,dynamic_risk_scaling:x.dynamic_risk_scaling,risk_scale_factor:x.risk_scale_factor,drawdown_risk_reduction:x.drawdown_risk_reduction,drawdown_reduction_threshold:x.drawdown_reduction_threshold,cusum_threshold:x.cusum_threshold,structural_break_lookback:x.structural_break_lookback,auto_pause_on_regime_break:x.auto_pause_on_regime_break,target_information_ratio:x.target_information_ratio,target_treynor_ratio:x.target_treynor_ratio,target_omega_ratio:x.target_omega_ratio,min_profit_factor:x.min_profit_factor,min_win_rate:x.min_win_rate,portfolio_optimization:x.portfolio_optimization,use_black_litterman:x.use_black_litterman,use_hierarchical_risk_parity:x.use_hierarchical_risk_parity,rebalance_threshold:x.rebalance_threshold},{data:re,error:ne}=await ue.from("custom_agents").insert([p]).select().single();if(ne)throw ne;
116r([re,...a]),xe({title:"Success",description:`Agent "${x.name}" created successfully`}),S({...x,name:"",description:""}),v("agents")}catch(p){console.error("Error creating agent:",p),xe({title:"Error",description:"Failed to create agent",variant:"destructive"})}finally{i(!1)}},Z=async p=>{m(!0),o(p);try{const{data:re,error:ne}=await ue.functions.invoke("generate-agent-strategy",{body:{agentId:p.id,agentConfig:p}});if(ne)throw ne;xe({title:"Strategy Generated",description:`AI analysis complete for ${p.name}`}),E()}catch(re){console.error("Error generating strategy:",re),xe({title:"Generation Failed",description:"Could not generate strategy. Please try again.",variant:"destructive"})}finally{m(!1)}},I=p=>({momentum:"bg-emerald-500/20 text-emerald-400 border-emerald-500/30",mean_reversion:"bg-blue-500/20 text-blue-400 border-blue-500/30",trend_following:"bg-purple-500/20 text-purple-400 border-purple-500/30",volatility:"bg-amber-500/20 text-amber-400 border-amber-500/30",multi_factor:"bg-rose-500/20 text-rose-400 border-rose-500/30"})[p]||"bg-muted text-muted-foreground",V=p=>{Q(re=>({...re,[p]:!re[p]}))},J=p=>{k(p),T(`${p.name} (Copy)`),w(!0)},_e=async()=>{if(!(!g||!M.trim()))try{const{id:p,created_at:re,...ne}=g,Pe={...ne,name:M.trim(),strategy_type:g.strategy_type},{data:Se,error:Te}=await ue.from("custom_agents").insert([Pe]).select().single();if(Te)throw Te;r([Se,...a]),w(!1),k(null),T(""),xe({title:"Cloned",description:`Agent "${M}" created successfully`})}catch(p){console.error("Error cloning agent:",p),xe({title:"Error",description:"Failed to clone agent",variant:"destructive"})}},ft=p=>{b(re=>re.includes(p)?re.filter(ne=>ne!==p):[...re,p])},tt=(p,re)=>{S(ne=>({...ne,...p,name:re,description:`Based on ${re} template`})),xe({title:"Template Applied",description:`${re} configuration loaded`})},ce=({section:p,icon:re,title:ne,badge:Pe})=>e.jsxs(Wn,{className:"flex items-center justify-between w-full p-4 hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(re,{className:"w-5 h-5 text-primary"}),e.jsx("span",{className:"font-semibold",children:ne}),Pe&&e.jsx(C,{variant:"outline",className:"text-[10px] bg-primary/10 text-primary border-primary/30",children:Pe})]}),e.jsx(Tr,{className:`w-4 h-4 transition-transform ${R[p]?"rotate-180":""}`})]});return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsxs(Vn,{children:[e.jsx("title",{children:"Pro Quants - Build Custom AI Trading Agents | AgentQuants"}),e.jsx("meta",{name:"description",content:"Create autonomous quant trading agents with AI-powered strategy generation, backtesting, and walk-forward analysis. Build custom trading bots without coding."}),e.jsx("meta",{name:"keywords",content:"custom trading agents, AI trading bot builder, quant strategy builder, backtesting platform, algorithmic trading, trading bot creation, automated trading system"}),e.jsx("link",{rel:"canonical",href:"https://agentquants.com/pro"}),e.jsx("meta",{name:"robots",content:"index, follow, max-snippet:-1, max-image-preview:large"}),e.jsx("meta",{property:"og:title",content:"Pro Quants - Build Custom AI Trading Agents | AgentQuants"}),e.jsx("meta",{property:"og:description",content:"Create autonomous quant trading agents with AI. Build, backtest, and deploy custom trading strategies."}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:url",content:"https://agentquants.com/pro"}),e.jsx("meta",{property:"og:site_name",content:"AgentQuants"}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:site",content:"@AgentQuants"}),e.jsx("meta",{name:"twitter:title",content:"Pro Quants - AI Trading Agent Builder | AgentQuants"}),e.jsx("meta",{name:"twitter:description",content:"Build custom trading agents with AI-powered strategy generation"})]}),e.jsx("script",{type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify({"@context":"https://schema.org","@type":"SoftwareApplication",name:"Pro Quants - AI Trading Agent Builder",description:"Create autonomous quant trading agents with AI-powered strategy generation and backtesting",url:"https://agentquants.com/pro",applicationCategory:"FinanceApplication",operatingSystem:"Web",offers:{"@type":"Offer",price:"0",priceCurrency:"USD"}})}}),e.jsx("script",{type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify({"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:[{"@type":"ListItem",position:1,name:"Home",item:"https://agentquants.com"},{"@type":"ListItem",position:2,name:"Pro Quants",item:"https://agentquants.com/pro"}]})}}),e.jsx("header",{className:"border-b border-primary/30 bg-gradient-to-r from-background via-primary/5 to-background backdrop-blur sticky top-0 z-50",children:e.jsx("div",{className:"container mx-auto px-4 py-4 flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(W,{variant:"ghost",size:"sm",onClick:()=>t("/"),className:"gap-1 text-muted-foreground hover:text-foreground transition-colors border border-border/50 hover:border-primary/50",children:[e.jsx(li,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Back"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-cyan-400 via-emerald-400 to-primary rounded-xl blur-lg opacity-70 animate-pulse"}),e.jsx("div",{className:"relative w-11 h-11 rounded-xl bg-gradient-to-br from-cyan-500 via-emerald-500 to-primary flex items-center justify-center shadow-xl shadow-primary/40 border border-white/20",children:e.jsx(Ds,{className:"w-6 h-6 text-white"})})]}),e.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-foreground tracking-tight",children:"Pro Agent Creator"})]})]})})}),e.jsx("main",{className:"container mx-auto px-4 py-6",children:e.jsxs(vs,{value:u,onValueChange:v,className:"space-y-6",children:[e.jsxs(js,{className:"grid w-full max-w-2xl grid-cols-5 bg-background/50 border border-primary/20 p-1",children:[e.jsxs(Ie,{value:"builder",className:"gap-2 data-[state=active]:bg-gradient-to-r data-[state=active]:from-cyan-500/30 data-[state=active]:to-cyan-400/10 data-[state=active]:text-cyan-400 data-[state=active]:border-cyan-400/50 data-[state=active]:border data-[state=active]:shadow-md",children:[e.jsx(sn,{className:"w-4 h-4 text-cyan-400"}),e.jsx("span",{className:"hidden sm:inline",children:"AI Builder"})]}),e.jsxs(Ie,{value:"agents",className:"gap-2 data-[state=active]:bg-gradient-to-r data-[state=active]:from-violet-500/30 data-[state=active]:to-violet-400/10 data-[state=active]:text-violet-400 data-[state=active]:border-violet-400/50 data-[state=active]:border data-[state=active]:shadow-md",children:[e.jsx(Ke,{className:"w-4 h-4 text-violet-400"}),e.jsx("span",{className:"hidden sm:inline",children:"My Agents"})]}),e.jsxs(Ie,{value:"signals",className:"gap-2 data-[state=active]:bg-gradient-to-r data-[state=active]:from-emerald-500/30 data-[state=active]:to-emerald-400/10 data-[state=active]:text-emerald-400 data-[state=active]:border-emerald-400/50 data-[state=active]:border data-[state=active]:shadow-md",children:[e.jsx(Ca,{className:"w-4 h-4 text-emerald-400"}),e.jsx("span",{className:"hidden sm:inline",children:"Signals"})]}),e.jsxs(Ie,{value:"create",className:"gap-2 data-[state=active]:bg-gradient-to-r data-[state=active]:from-amber-500/30 data-[state=active]:to-amber-400/10 data-[state=active]:text-amber-400 data-[state=active]:border-amber-400/50 data-[state=active]:border data-[state=active]:shadow-md",children:[e.jsx(ls,{className:"w-4 h-4 text-amber-400"}),e.jsx("span",{className:"hidden sm:inline",children:"Manual"})]}),e.jsxs(Ie,{value:"backtest",className:"gap-2 data-[state=active]:bg-gradient-to-r data-[state=active]:from-rose-500/30 data-[state=active]:to-rose-400/10 data-[state=active]:text-rose-400 data-[state=active]:border-rose-400/50 data-[state=active]:border data-[state=active]:shadow-md",children:[e.jsx(Ma,{className:"w-4 h-4 text-rose-400"}),e.jsx("span",{className:"hidden sm:inline",children:"Backtest"})]})]}),e.jsx(Ue,{value:"builder",className:"space-y-4",children:e.jsx(rd,{onAgentCreated:E})}),e.jsxs(Ue,{value:"agents",className:"space-y-4",children:[f.length>0&&e.jsxs("div",{className:"flex items-center justify-between p-3 bg-primary/10 rounded-lg border border-primary/30",children:[e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-semibold",children:f.length})," agents selected for comparison"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(W,{variant:"outline",size:"sm",onClick:()=>b([]),children:"Clear"}),e.jsxs(W,{size:"sm",onClick:()=>y(!0),disabled:f.length<2,className:"gap-2",children:[e.jsx(mt,{className:"w-3 h-3"}),"Compare"]})]})]}),n?e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(p=>e.jsxs(q,{className:"animate-pulse",children:[e.jsx(X,{className:"pb-2",children:e.jsx("div",{className:"h-5 bg-white/10 rounded w-1/2"})}),e.jsx(H,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-4 bg-white/10 rounded w-3/4"}),e.jsx("div",{className:"h-4 bg-white/10 rounded w-1/2"})]})})]},p))}):a.length===0?e.jsx(q,{className:"border-dashed",children:e.jsxs(H,{
116className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Ke,{className:"w-12 h-12 text-white/60 mb-4"}),e.jsx("h3",{className:"font-semibold text-lg mb-2 text-white",children:"No Agents Yet"}),e.jsx("p",{className:"text-white/70 mb-4 max-w-sm",children:"Create your first custom quant agent to start generating AI-powered trading strategies."}),e.jsxs(W,{onClick:()=>v("create"),className:"gap-2",children:[e.jsx(ls,{className:"w-4 h-4"}),"Create Agent"]})]})}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:a.map(p=>{var re,ne,Pe;return e.jsxs(q,{className:"group hover:border-primary/50 transition-colors",children:[e.jsx(X,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-primary/20 flex items-center justify-center",children:e.jsx(Ke,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{children:[e.jsx(Y,{className:"text-base",children:p.name}),e.jsx(C,{className:`text-[10px] mt-1 ${I(p.strategy_type)}`,children:p.strategy_type.replace("_"," ")})]})]}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(W,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>J(p),title:"Clone Agent",children:e.jsx(ha,{className:"w-3 h-3"})}),e.jsx(W,{variant:"ghost",size:"icon",className:`h-7 w-7 ${f.includes(p.id)?"text-primary bg-primary/10":""}`,onClick:()=>ft(p.id),title:"Compare",children:e.jsx(mt,{className:"w-3 h-3"})})]})]})}
116),e.jsxs(H,{className:"space-y-3",children:[p.description&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:p.description}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[e.jsxs("div",{className:"bg-muted/30 rounded px-2 py-1",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Lookback"}),e.jsxs("p",{className:"text-xs font-mono",children:[p.lookback_period,"d"]})]}),e.jsxs("div",{className:"bg-muted/30 rounded px-2 py-1",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Stop Loss"}),e.jsxs("p",{className:"text-xs font-mono text-destructive",children:[(p.stop_loss*100).toFixed(0),"%"]})]}),e.jsxs("div",{className:"bg-muted/30 rounded px-2 py-1",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Take Profit"}),e.jsxs("p",{className:"text-xs font-mono text-chart-2",children:[(p.take_profit*100).toFixed(0),"%"]})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(re=p.symbols)==null?void 0:re.slice(0,4).map(Se=>e.jsx(C,{variant:"outline",className:"text-[10px]",children:Se},Se)),(((ne=p.symbols)==null?void 0:ne.length)||0)>4&&e.jsxs(C,{variant:"outline",className:"text-[10px]",children:["+",(((Pe=p.symbols)==null?void 0:Pe.length)||0)-4]})]}),e.jsx(W,{className:"w-full gap-2",size:"sm",onClick:()=>Z(p),disabled:h&&(l==null?void 0:l.id)===p.id,children:h&&(l==null?void 0:l.id)===p.id?e.jsxs(e.Fragment,{children:[e.jsx(Me,{className:"w-3 h-3 animate-spin"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Je,{className:"w-3 h-3"}),"Generate Strategy"]})})]})]},p.id)})})]}),e.jsxs(Ue,{value:"create",className:"space-y-4",children:[e.jsx(dc,{onSelectTemplate:tt}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(q,{children:e.jsxs(ze,{open:R.identity,onOpenChange:()=>V("identity"),children:[e.jsx(ce,{section:"identity",icon:Ke,title:"Agent Identity"}),e.jsx($e,{children:e.jsxs(H,{className:"space-y-4 pt-0",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"name",children:"Agent Name"}),e.jsx(se,{id:"name",placeholder:"e.g., Momentum Alpha V1",value:x.name,onChange:p=>S({...x,name:p.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",placeholder:"Describe your agent's strategy...",value:x.description,onChange:p=>S({...x,description:p.target.value}),rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Strategy Type"}),e.jsxs(De,{value:x.strategy_type,onValueChange:p=>S({...x,strategy_type:p}),children:[e.jsx(Ee,{children:e.jsx(Le,{})}),e.jsx(Oe,{children:Nd.map(p=>e.jsx(ie,{value:p.value,children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:p.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:p.description})]})},p.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Trading Symbols"}),e.jsx(Nl,{symbols:Cd,selectedSymbols:x.symbols,onToggle:p=>{const re=x.symbols.includes(p)?x.symbols.filter(ne=>ne!==p):[...x.symbols,p];S({...x,symbols:re})},size:"sm",columns:6})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-border/50",children:[e.jsxs("div",{children:[e.jsx(P,{children:"Make Public"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Allow others to see this agent"})]}),e.jsx(ye,{checked:x.is_public,onCheckedChange:p=>S({...x,is_public:p})})]})]})})]})}),e.jsx(q,{children:e.jsxs(ze,{open:R.strategy,onOpenChange:()=>V("strategy"),children:[e.jsx(ce,{section:"strategy",icon:Yr,title:"Strategy Parameters"}),e.jsx($e,{children:e.jsxs(H,{className:"space-y-4 pt-0",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Lookback Period"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[x.lookback_period," days"]})]}),e.jsx(ee,{value:[x.lookback_period],onValueChange:([p])=>S({...x,lookback_period:p}),min:5,max:200,step:5})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Entry Threshold"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(x.entry_threshold*100).toFixed(1),"%"]})]}),e.jsx(ee,{value:[x.entry_threshold*100],onValueChange:([p])=>S({...x,entry_threshold:p/100}
116),min:.5,max:10,step:.5})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Exit Threshold"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(x.exit_threshold*100).toFixed(1),"%"]})]}),e.jsx(ee,{value:[x.exit_threshold*100],onValueChange:([p])=>S({...x,exit_threshold:p/100}),min:.5,max:5,step:.5})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{className:"text-destructive",children:"Stop Loss"}),e.jsxs("span",{className:"text-sm text-destructive",children:[(x.stop_loss*100).toFixed(0),"%"]})]}),e.jsx(ee,{value:[x.stop_loss*100],onValueChange:([p])=>S({...x,stop_loss:p/100}),min:1,max:20,step:1,className:"[&_[role=slider]]:bg-destructive"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{className:"text-chart-2",children:"Take Profit"}),e.jsxs("span",{className:"text-sm text-chart-2",children:[(x.take_profit*100).toFixed(0),"%"]})]}),e.jsx(ee,{value:[x.take_profit*100],onValueChange:([p])=>S({...x,take_profit:p/100}),min:2,max:50,step:2,className:"[&_[role=slider]]:bg-chart-2"})]})]})]})})]})}),e.jsx(q,{children:e.jsxs(ze,{open:R.riskMetrics,onOpenChange:()=>V("riskMetrics"),children:[e.jsx(ce,{section:"riskMetrics",icon:Ce,title:"Advanced Risk Metrics",badge:"PRO"}),e.jsx($e,{children:e.jsxs(H,{className:"space-y-4 pt-0",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsxs(P,{className:"flex items-center gap-1",children:[e.jsx(ke,{className:"w-3 h-3"}),"Max Drawdown"]}),e.jsxs("span",{className:"text-sm text-destructive",children:[(x.max_drawdown_limit*100).toFixed(0),"%"]})]}),e.jsx(ee,{value:[x.max_drawdown_limit*100],onValueChange:([p])=>S({...x,max_drawdown_limit:p/100}),min:5,max:50,step:5})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsxs(P,{className:"flex items-center gap-1",children:[e.jsx(Re,{className:"w-3 h-3"}),"VaR (95%)"]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(x.var_threshold*100).toFixed(1),"%"]})]}),e.jsx(ee,{value:[x.var_threshold*100],onValueChange:([p])=>S({...x,var_threshold:p/100}),min:1,max:15,step:.5})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Target Sharpe"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:x.target_sharpe.toFixed(1)})]}),e.jsx(ee,{value:[x.target_sharpe*10],onValueChange:([p])=>S({...x,target_sharpe:p/10}),min:5,max:40,step:1})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Sortino Target"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:x.sortino_target.toFixed(1)})]}),e.jsx(ee,{value:[x.sortino_target*10],onValueChange:([p])=>S({...x,sortino_target:p/10}),min:5,max:50,step:1})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Max Beta"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:x.max_beta.toFixed(1)})]}),e.jsx(ee,{value:[x.max_beta*10],onValueChange:([p])=>S({...x,max_beta:p/10}),min:1,max:30,step:1})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Max Correlation"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(x.max_correlation*100).toFixed(0),"%"]})]}),e.jsx(ee,{value:[x.max_correlation*100],onValueChange:([p])=>S({...x,max_correlation:p/100}),min:30,max:100,step:5})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Risk-Free Rate"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(x.risk_free_rate*100).toFixed(1),"%"]})]}),e.jsx(ee,{value:[x.risk_free_rate*100],onValueChange:([p])=>S({...x,risk_free_rate:p/100}),min:0,max:10,step:.5})]})]})})]})}),e.jsx(q,{children:e.jsxs(ze,{open:R.positionSizing,onOpenChange:()=>V("positionSizing"),children:[e.jsx(ce,{section:"positionSizing",icon:di,title:"Position Sizing",badge:"PRO"}
116),e.jsx($e,{children:e.jsxs(H,{className:"space-y-4 pt-0",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Sizing Method"}),e.jsxs(De,{value:x.sizing_method,onValueChange:p=>S({...x,sizing_method:p}),children:[e.jsx(Ee,{children:e.jsx(Le,{})}),e.jsx(Oe,{children:Td.map(p=>e.jsx(ie,{value:p.value,children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:p.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:p.description})]})},p.value))})]})]}),x.sizing_method==="kelly_criterion"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Kelly Fraction"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(x.kelly_fraction*100).toFixed(0),"%"]})]}),e.jsx(ee,{value:[x.kelly_fraction*100],onValueChange:([p])=>S({...x,kelly_fraction:p/100}),min:10,max:100,step:5}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Full Kelly = 100%, Half Kelly = 50% (safer)"})]}),x.sizing_method==="volatility_targeting"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Volatility Target"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(x.vol_target*100).toFixed(0),"%"]})]}),e.jsx(ee,{value:[x.vol_target*100],onValueChange:([p])=>S({...x,vol_target:p/100}),min:5,max:40,step:1})]}),x.sizing_method==="atr_based"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"ATR Multiplier"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[x.atr_multiplier.toFixed(1),"x"]})]}),e.jsx(ee,{value:[x.atr_multiplier*10],onValueChange:([p])=>S({...x,atr_multiplier:p/10}),min:5,max:50,step:5})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Max Position"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(x.max_position_pct*100).toFixed(0),"%"]})]}),e.jsx(ee,{value:[x.max_position_pct*100],onValueChange:([p])=>S({...x,max_position_pct:p/100}),min:5,max:100,step:5})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Min Position"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(x.min_position_pct*100).toFixed(1),"%"]})]}),e.jsx(ee,{value:[x.min_position_pct*100],onValueChange:([p])=>S({...x,min_position_pct:p/100}),min:.5,max:10,step:.5})]})]})]})})]})}),e.jsx(q,{children:e.jsxs(ze,{open:R.signalFilters,onOpenChange:()=>V("signalFilters"),children:[e.jsx(ce,{section:"signalFilters",icon:Da,title:"Signal Filters",badge:"PRO"}),e.jsx($e,{children:e.jsxs(H,{className:"space-y-4 pt-0",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Min Signal Strength"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(x.min_signal_strength*100).toFixed(0),"%"]})]}),e.jsx(ee,{value:[x.min_signal_strength*100],onValueChange:([p])=>S({...x,min_signal_strength:p/100}),min:30,max:95,step:5})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Confirmation Bars"}),e.jsx(se,{type:"number",value:x.signal_confirmation_bars,onChange:p=>S({...x,signal_confirmation_bars:parseInt(p.target.value)||1}),min:1,max:10,className:"h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"ADX Threshold"}),e.jsx(se,{type:"number",value:x.adx_threshold,onChange:p=>S({...x,adx_threshold:parseInt(p.target.value)||25}),min:10,max:50,className:"h-8"})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-2 border-t border-border/50",children:[e.jsxs("div",{children:[e.jsx(P,{children:"Volume Confirmation"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Require above-average volume"})]}),e.jsx(ye,{checked:x.volume_confirmation,onCheckedChange:p=>S({...x,volume_confirmation:p})})]}),x.volume_confirmation&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Min Volume Ratio"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[x.min_volume_ratio.toFixed(1),"x avg"]})]}),e.jsx(ee,{value:[x.min_volume_ratio*10],onValueChange:([p])=>S({...x,min_volume_ratio:p/10}),min:10,max:50,step:1})]}),e.jsxs("div",{className:"flex items-center justify-between py-2 border-t border-border/50",children:[e.jsxs("div",{children:[e.jsx(P,{children:"ATR Filter"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Filter by volatility range"})]}),e.jsx(ye,{checked:x.atr_filter_enabled,onCheckedChange:p=>S({...x,atr_filter_enabled:p})})]}),e.jsxs("div",{className:"flex items-center justify-between py-2 border-t border-border/50",children:[e.jsxs("div",{children:[e.jsx(P,{children:"Correlation Filter"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Avoid correlated signals"})]}),e.jsx(ye,{checked:x.correlation_filter_enabled,onCheckedChange:p=>S({...x,correlation_filter_enabled:p})})]})]})})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(q,{children:e.jsxs(ze,{open:R.executionControls,onOpenChange:()=>V("executionControls"),children:[e.jsx(ce,{section:"executionControls",icon:mi,title:"Execution Controls",badge:"PRO"}
116),e.jsx($e,{children:e.jsxs(H,{className:"space-y-4 pt-0",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Order Type"}),e.jsxs(De,{value:x.order_type,onValueChange:p=>S({...x,order_type:p}),children:[e.jsx(Ee,{className:"h-8",children:e.jsx(Le,{})}),e.jsx(Oe,{children:Rd.map(p=>e.jsx(ie,{value:p.value,children:p.label},p.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Time in Force"}),e.jsxs(De,{value:x.time_in_force,onValueChange:p=>S({...x,time_in_force:p}),children:[e.jsx(Ee,{className:"h-8",children:e.jsx(Le,{})}),e.jsx(Oe,{children:Pd.map(p=>e.jsx(ie,{value:p.value,children:p.label},p.value))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Max Slippage"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(x.max_slippage*100).toFixed(1),"%"]})]}),e.jsx(ee,{value:[x.max_slippage*100],onValueChange:([p])=>S({...x,max_slippage:p/100}),min:.1,max:5,step:.1})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Max Daily Trades"}),e.jsx(se,{type:"number",value:x.max_daily_trades,onChange:p=>S({...x,max_daily_trades:parseInt(p.target.value)||10}),min:1,max:100,className:"h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Cooldown (mins)"}),e.jsx(se,{type:"number",value:x.cooldown_minutes,onChange:p=>S({...x,cooldown_minutes:parseInt(p.target.value)||15}),min:0,max:120,className:"h-8"})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-2 border-t border-border/50",children:[e.jsxs("div",{children:[e.jsx(P,{children:"Trading Hours Only"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Restrict to market hours"})]}),e.jsx(ye,{checked:x.trading_hours_only,onCheckedChange:p=>S({...x,trading_hours_only:p})})]}),x.trading_hours_only&&e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Start Hour (UTC)"}),e.jsx(se,{type:"number",value:x.trading_start_hour,onChange:p=>S({...x,trading_start_hour:parseInt(p.target.value)||9}),min:0,max:23,className:"h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"End Hour (UTC)"}),e.jsx(se,{type:"number",value:x.trading_end_hour,onChange:p=>S({...x,trading_end_hour:parseInt(p.target.value)||16}),min:0,max:23,className:"h-8"})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-2 border-t border-border/50",children:[e.jsxs("div",{children:[e.jsx(P,{children:"Allow Partial Fills"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Accept partial order execution"})]}),e.jsx(ye,{checked:x.partial_fills_allowed,onCheckedChange:p=>S({...x,partial_fills_allowed:p})})]})]})})]})}),e.jsx(q,{children:e.jsxs(ze,{open:R.technicalIndicators,onOpenChange:()=>V("technicalIndicators"),children:[e.jsx(ce,{section:"technicalIndicators",icon:ge,title:"Technical Indicators"}),e.jsx($e,{children:e.jsxs(H,{className:"space-y-4 pt-0",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"RSI Period"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:x.rsi_period})]}),e.jsx(ee,{value:[x.rsi_period],onValueChange:([p])=>S({...x,rsi_period:p}),min:5,max:30,step:1})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"text-xs",children:"RSI Overbought"}),e.jsx(se,{type:"number",value:x.rsi_overbought,onChange:p=>S({...x,rsi_overbought:parseInt(p.target.value)||70}),className:"h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"text-xs",children:"RSI Oversold"}),e.jsx(se,{type:"number",value:x.rsi_oversold,onChange:p=>S({...x,rsi_oversold:parseInt(p.target.value)||30}),className:"h-8"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"text-xs",children:"MACD Fast"}),e.jsx(se,{type:"number",value:x.macd_fast,onChange:p=>S({...x,macd_fast:parseInt(p.target.value)||12}),className:"h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"text-xs",children:"MACD Slow"}),e.jsx(se,{type:"number",value:x.macd_slow,onChange:p=>S({...x,macd_slow:parseInt(p.target.value)||26}),className:"h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"text-xs",children:"MACD Signal"}),e.jsx(se,{type:"number",value:x.macd_signal,onChange:p=>S({...x,macd_signal:parseInt(p.target.value)||9}),className:"h-8"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"text-xs",children:"Bollinger Period"}),e.jsx(se,{type:"number",value:x.bollinger_period,onChange:p=>S({...x,bollinger_period:parseInt(p.target.value)||20}),className:"h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"text-xs",children:"Bollinger Std Dev"}),e.jsx(se,{type:"number",step:"0.1",value:x.bollinger_std,onChange:p=>S({...x,bollinger_std:parseFloat(p.target.value)||2}),className:"h-8"})]})]}),e.jsxs("div",{className:"pt-2 border-t border-border/50",children:[e.jsx(P,{className:"text-xs text-muted-foreground mb-2 block",children:"Additional Indicators"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(P,{className:"text-[10px]",children:"EMA Fast"}),e.jsx(se,{type:"number",value:x.ema_fast,onChange:p=>S({...x,ema_fast:parseInt(p.target.value)||12}),className:"h-7 text-xs"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(P,{className:"text-[10px]",children:"EMA Slow"}),e.jsx(se,{type:"number",value:x.ema_slow,onChange:p=>S({...x,ema_slow:parseInt(p.target.value)||26}),className:"h-7 text-xs"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(P,{className:"text-[10px]",children:"ATR Period"}),e.jsx(se,{type:"number",value:x.atr_period,onChange:p=>S({...x,atr_period:parseInt(p.target.value)||14}),className:"h-7 text-xs"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(P,{className:"text-[10px]",children:"ADX Period"}),e.jsx(se,{type:"number",value:x.adx_period,onChange:p=>S({...x,adx_period:parseInt(p.target.value)||14}),className:"h-7 text-xs"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(P,{className:"text-[10px]",children:"Stochastic K"}),e.jsx(se,{type:"number",value:x.stochastic_k,onChange:p=>S({...x,stochastic_k:parseInt(p.target.value)||14}),className:"h-7 text-xs"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(P,{className:"text-[10px]",children:"Stochastic D"}),e.jsx(se,{type:"number",value:x.stochastic_d,onChange:p=>S({...x,stochastic_d:parseInt(p.target.value)||3}),className:"h-7 text-xs"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(P,{className:"text-[10px]",children:"Williams %R"}),e.jsx(se,{type:"number",value:x.williams_r_period,onChange:p=>S({...x,williams_r_period:parseInt(p.target.value)||14}),className:"h-7 text-xs"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(P,{className:"text-[10px]",children:"CCI Period"}),e.jsx(se,{type:"number",value:x.cci_period,onChange:p=>S({...x,cci_period:parseInt(p.target.value)||20}),className:"h-7 text-xs"})]})]})]})]})})]})}),e.jsx(q,{children:e.jsxs(ze,{open:R.regimeDetection,onOpenChange:()=>V("regimeDetection"),children:[e.jsx(ce,{section:"regimeDetection",icon:St,title:"Regime Detection"}
116),e.jsx($e,{children:e.jsxs(H,{className:"space-y-4 pt-0",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"VIX Threshold"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:x.vix_threshold})]}),e.jsx(ee,{value:[x.vix_threshold],onValueChange:([p])=>S({...x,vix_threshold:p}),min:10,max:40,step:1}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Above this = high volatility regime"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Momentum Lookback"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[x.momentum_lookback," days"]})]}),e.jsx(ee,{value:[x.momentum_lookback],onValueChange:([p])=>S({...x,momentum_lookback:p}),min:20,max:200,step:10})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Regime Sensitivity"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(x.regime_sensitivity*100).toFixed(0),"%"]})]}),e.jsx(ee,{value:[x.regime_sensitivity*100],onValueChange:([p])=>S({...x,regime_sensitivity:p/100}),min:10,max:100,step:10})]})]})})]})}),e.jsx(q,{children:e.jsxs(ze,{open:R.walkForward,onOpenChange:()=>V("walkForward"),children:[e.jsx(ce,{section:"walkForward",icon:tn,title:"Walk-Forward Optimization",badge:"PRO"}),e.jsx($e,{children:e.jsxs(H,{className:"space-y-4 pt-0",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Training Period"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(se,{type:"number",value:x.train_period_months,onChange:p=>S({...x,train_period_months:parseInt(p.target.value)||12}),className:"h-8"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"months"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Test Period"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(se,{type:"number",value:x.test_period_months,onChange:p=>S({...x,test_period_months:parseInt(p.target.value)||3}),className:"h-8"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"months"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Rebalance Frequency"}),e.jsxs(De,{value:x.rebalance_frequency,onValueChange:p=>S({...x,rebalance_frequency:p}),children:[e.jsx(Ee,{className:"h-8",children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(ie,{value:"daily",children:"Daily"}),e.jsx(ie,{value:"weekly",children:"Weekly"}),e.jsx(ie,{value:"monthly",children:"Monthly"}),e.jsx(ie,{value:"quarterly",children:"Quarterly"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Monte Carlo Runs"}),e.jsx(se,{type:"number",value:x.monte_carlo_iterations,onChange:p=>S({...x,monte_carlo_iterations:parseInt(p.target.value)||1e3}),min:100,max:1e4,step:100,className:"h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Walk-Forward Windows"}),e.jsx(se,{type:"number",value:x.walk_forward_windows,onChange:p=>S({...x,walk_forward_windows:parseInt(p.target.value)||4}),min:2,max:12,className:"h-8"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Optimization Metric"}),e.jsxs(De,{value:x.optimization_metric,onValueChange:p=>S({...x,optimization_metric:p}),children:[e.jsx(Ee,{className:"h-8",children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(ie,{value:"sharpe_ratio",children:"Sharpe Ratio"}),e.jsx(ie,{value:"sortino_ratio",children:"Sortino Ratio"}),e.jsx(ie,{value:"calmar_ratio",children:"Calmar Ratio"}),e.jsx(ie,{value:"max_drawdown",children:"Min Drawdown"}),e.jsx(ie,{value:"total_return",children:"Total Return"}),e.jsx(ie,{value:"win_rate",children:"Win Rate"})]})]})]})]})})]})}),e.jsx(q,{children:e.jsxs(ze,{open:R.mlEnsemble,onOpenChange:()=>V("mlEnsemble"),children:[e.jsx(ce,{section:"mlEnsemble",icon:lt,title:"ML Ensemble & Features",badge:"INST"}
116),e.jsx($e,{children:e.jsxs(H,{className:"space-y-4 pt-0",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/30 rounded",children:[e.jsxs("div",{children:[e.jsx(P,{children:"Enable Ensemble Voting"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Combine multiple ML models"})]}),e.jsx(ye,{checked:x.ensemble_voting_enabled,onCheckedChange:p=>S({...x,ensemble_voting_enabled:p})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"ML Confidence Weight"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(x.ml_confidence_weight*100).toFixed(0),"%"]})]}),e.jsx(ee,{value:[x.ml_confidence_weight*100],onValueChange:([p])=>S({...x,ml_confidence_weight:p/100}),min:10,max:90,step:5})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Feature Importance Threshold"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(x.feature_importance_threshold*100).toFixed(0),"%"]})]}),e.jsx(ee,{value:[x.feature_importance_threshold*100],onValueChange:([p])=>S({...x,feature_importance_threshold:p/100}),min:5,max:30,step:1})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"HMM Regime States"}),e.jsxs(De,{value:String(x.hmm_states),onValueChange:p=>S({...x,hmm_states:parseInt(p)}),children:[e.jsx(Ee,{className:"h-8",children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(ie,{value:"2",children:"2 States (Bull/Bear)"}),e.jsx(ie,{value:"3",children:"3 States (Bull/Bear/Sideways)"}),e.jsx(ie,{value:"4",children:"4 States (Extended)"})]})]})]})]})})]})}),e.jsx(q,{children:e.jsxs(ze,{open:R.pairsTrading,onOpenChange:()=>V("pairsTrading"),children:[e.jsx(ce,{section:"pairsTrading",icon:mt,title:"Statistical Arbitrage",badge:"INST"}),e.jsx($e,{children:e.jsxs(H,{className:"space-y-4 pt-0",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/30 rounded",children:[e.jsxs("div",{children:[e.jsx(P,{children:"Enable Pairs Trading"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Trade cointegrated pairs"})]}),e.jsx(ye,{checked:x.pairs_trading_enabled,onCheckedChange:p=>S({...x,pairs_trading_enabled:p})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Z-Score Entry"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["±",x.zscore_entry]})]}),e.jsx(ee,{value:[x.zscore_entry],onValueChange:([p])=>S({...x,zscore_entry:p}),min:1.5,max:3,step:.1})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Z-Score Exit"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["±",x.zscore_exit]})]}),e.jsx(ee,{value:[x.zscore_exit],onValueChange:([p])=>S({...x,zscore_exit:p}),min:0,max:1,step:.1})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Cointegration Lookback (days)"}),e.jsx(se,{type:"number",value:x.cointegration_lookback,onChange:p=>S({...x,cointegration_lookback:parseInt(p.target.value)||60}),min:30,max:120,className:"h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Max Half-Life (days)"}),e.jsx(se,{type:"number",value:x.half_life_max,onChange:p=>S({...x,half_life_max:parseInt(p.target.value)||30}),min:5,max:60,className:"h-8"})]})]})]})})]})}),e.jsx(q,{children:e.jsxs(ze,{open:R.executionAlgo,onOpenChange:()=>V("executionAlgo"),children:[e.jsx(ce,{section:"executionAlgo",icon:Gr,title:"Execution Algorithms",badge:"INST"}),e.jsx($e,{children:e.jsxs(H,{className:"space-y-4 pt-0",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Execution Algorithm"}),e.jsxs(De,{value:x.execution_algo,onValueChange:p=>S({...x,execution_algo:p}),children:[e.jsx(Ee,{className:"h-8",children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(ie,{value:"market",children:"Market Order"}),e.jsx(ie,{value:"twap",children:"TWAP (Time-Weighted)"}),e.jsx(ie,{value:"vwap",children:"VWAP (Volume-Weighted)"}),e.jsx(ie,{value:"iceberg",children:"Iceberg Order"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"TWAP Duration (min)"}),e.jsx(se,{type:"number",value:x.twap_duration_minutes,onChange:p=>
116S({...x,twap_duration_minutes:parseInt(p.target.value)||30}),min:5,max:120,className:"h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"VWAP Participation"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(x.vwap_participation_rate*100).toFixed(0),"%"]})]}),e.jsx(ee,{value:[x.vwap_participation_rate*100],onValueChange:([p])=>S({...x,vwap_participation_rate:p/100}),min:5,max:30,step:1})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Iceberg Show Size"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(x.iceberg_show_size*100).toFixed(0),"%"]})]}),e.jsx(ee,{value:[x.iceberg_show_size*100],onValueChange:([p])=>S({...x,iceberg_show_size:p/100}),min:5,max:25,step:1})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"IS Limit"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(x.implementation_shortfall_limit*100).toFixed(2),"%"]})]}),e.jsx(ee,{value:[x.implementation_shortfall_limit*1e3],onValueChange:([p])=>S({...x,implementation_shortfall_limit:p/1e3}),min:1,max:20,step:1})]})]})]})})]})}),e.jsx(q,{children:e.jsxs(ze,{open:R.portfolioRisk,onOpenChange:()=>V("portfolioRisk"),children:[e.jsx(ce,{section:"portfolioRisk",icon:Ce,title:"Portfolio Risk Limits",badge:"INST"}),e.jsx($e,{children:e.jsxs(H,{className:"space-y-4 pt-0",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Portfolio VaR Limit"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(x.portfolio_var_limit*100).toFixed(1),"%"]})]}),e.jsx(ee,{value:[x.portfolio_var_limit*100],onValueChange:([p])=>S({...x,portfolio_var_limit:p/100}),min:1,max:10,step:.5})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Marginal VaR Limit"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(x.marginal_var_limit*100).toFixed(1),"%"]})]}),e.jsx(ee,{value:[x.marginal_var_limit*100],onValueChange:([p])=>S({...x,marginal_var_limit:p/100}),min:.5,max:5,step:.25})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Gross Exposure Limit"}),e.jsx(se,{type:"number",value:x.gross_exposure_limit,onChange:p=>S({...x,gross_exposure_limit:parseFloat(p.target.value)||2}),min:1,max:5,step:.1,className:"h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Net Exposure Limit"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(x.net_exposure_limit*100).toFixed(0),"%"]})]}),e.jsx(ee,{value:[x.net_exposure_limit*100],onValueChange:([p])=>S({...x,net_exposure_limit:p/100}),min:0,max:100,step:5})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Sector Concentration"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(x.sector_concentration_limit*100).toFixed(0),"%"]})]}),e.jsx(ee,{value:[x.sector_concentration_limit*100],onValueChange:([p])=>S({...x,sector_concentration_limit:p/100}),min:10,max:50,step:5})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Single Name Limit"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(x.single_name_limit*100).toFixed(0),"%"]})]}),e.jsx(ee,{value:[x.single_name_limit*100],onValueChange:([p])=>S({...x,single_name_limit:p/100}),min:5,max:25,step:1})]})]})]})})]})}),e.jsx(q,{children:e.jsxs(ze,{open:R.betaNeutral,onOpenChange:()=>V("betaNeutral"),children:[e.jsx(ce,{section:"betaNeutral",icon:ys,title:"Beta & Factor Neutral",badge:"INST"}
116),e.jsx($e,{children:e.jsxs(H,{className:"space-y-4 pt-0",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between p-2 bg-muted/30 rounded",children:[e.jsx(P,{className:"text-xs",children:"Beta Neutral"}),e.jsx(ye,{checked:x.beta_neutral_enabled,onCheckedChange:p=>S({...x,beta_neutral_enabled:p})})]}),e.jsxs("div",{className:"flex items-center justify-between p-2 bg-muted/30 rounded",children:[e.jsx(P,{className:"text-xs",children:"Sector Neutral"}),e.jsx(ye,{checked:x.sector_neutral_enabled,onCheckedChange:p=>S({...x,sector_neutral_enabled:p})})]}),e.jsxs("div",{className:"flex items-center justify-between p-2 bg-muted/30 rounded",children:[e.jsx(P,{className:"text-xs",children:"Factor Neutral"}),e.jsx(ye,{checked:x.factor_neutral_enabled,onCheckedChange:p=>S({...x,factor_neutral_enabled:p})})]})]}),x.beta_neutral_enabled&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Target Beta"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[x.target_beta.toFixed(2),"β"]})]}),e.jsx(ee,{value:[x.target_beta*100],onValueChange:([p])=>S({...x,target_beta:p/100}),min:-50,max:50,step:5})]})]})})]})}),e.jsx(q,{children:e.jsxs(ze,{open:R.sentiment,onOpenChange:()=>V("sentiment"),children:[e.jsx(ce,{section:"sentiment",icon:ge,title:"Sentiment & Alt Data",badge:"INST"}),e.jsx($e,{children:e.jsx(H,{className:"space-y-4 pt-0",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/30 rounded",children:[e.jsxs("div",{children:[e.jsx(P,{children:"News Sentiment"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Integrate news analysis"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[x.use_news_sentiment&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[(x.news_sentiment_weight*100).toFixed(0),"% wt"]}),e.jsx(ye,{checked:x.use_news_sentiment,onCheckedChange:p=>S({...x,use_news_sentiment:p})})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/30 rounded",children:[e.jsxs("div",{children:[e.jsx(P,{children:"Social Sentiment"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Twitter, Reddit signals"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[x.use_social_sentiment&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[(x.social_sentiment_weight*100).toFixed(0),"% wt"]}),e.jsx(ye,{checked:x.use_social_sentiment,onCheckedChange:p=>S({...x,use_social_sentiment:p})})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/30 rounded",children:[e.jsxs("div",{children:[e.jsx(P,{children:"On-Chain Metrics"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Blockchain data signals"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[x.use_onchain_metrics&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[(x.onchain_weight*100).toFixed(0),"% wt"]}),e.jsx(ye,{checked:x.use_onchain_metrics,onCheckedChange:p=>S({...x,use_onchain_metrics:p})})]})]})]})})})]})}),e.jsx(q,{children:e.jsxs(ze,{open:R.riskBudget,onOpenChange:()=>V("riskBudget"),children:[e.jsx(ce,{section:"riskBudget",icon:bs,title:"Risk Budgeting",badge:"INST"}),e.jsx($e,{children:e.jsxs(H,{className:"space-y-4 pt-0",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Risk Budget"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(x.risk_budget_pct*100).toFixed(0),"%"]})]}),e.jsx(ee,{value:[x.risk_budget_pct*100],onValueChange:([p])=>S({...x,risk_budget_pct:p/100}),min:25,max:150,step:5})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Risk Scale Factor"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[x.risk_scale_factor.toFixed(2),"x"]})]}),e.jsx(ee,{value:[x.risk_scale_factor*100],onValueChange:([p])=>S({...x,risk_scale_factor:p/100}),min:50,max:150,step:5})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/30 rounded",children:[e.jsxs("div",{children:[e.jsx(P,{children:"Dynamic Risk Scaling"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Auto-scale based on conditions"})]}),e.jsx(ye,{checked:x.dynamic_risk_scaling,onCheckedChange:p=>S({...x,dynamic_risk_scaling:p})})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/30 rounded",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(P,{children:"Drawdown Risk Reduction"}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Reduce risk on drawdown > ",(x.drawdown_reduction_threshold*100).toFixed(0),"%"]})]}),e.jsx(ye,{checked:x.drawdown_risk_reduction,onCheckedChange:p=>S({...x,drawdown_risk_reduction:p})})]})]})})]})}),e.jsx(q,{children:e.jsxs(ze,{open:R.regimeBreak,onOpenChange:()=>
116V("regimeBreak"),children:[e.jsx(ce,{section:"regimeBreak",icon:Re,title:"Regime Break Detection",badge:"INST"}),e.jsx($e,{children:e.jsxs(H,{className:"space-y-4 pt-0",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"CUSUM Threshold"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["±",x.cusum_threshold.toFixed(1)]})]}),e.jsx(ee,{value:[x.cusum_threshold*10],onValueChange:([p])=>S({...x,cusum_threshold:p/10}),min:10,max:40,step:1})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Structural Break Lookback"}),e.jsx(se,{type:"number",value:x.structural_break_lookback,onChange:p=>S({...x,structural_break_lookback:parseInt(p.target.value)||100}),min:50,max:200,className:"h-8"})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/30 rounded",children:[e.jsxs("div",{children:[e.jsx(P,{children:"Auto-Pause on Regime Break"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Stop trading when break detected"})]}),e.jsx(ye,{checked:x.auto_pause_on_regime_break,onCheckedChange:p=>S({...x,auto_pause_on_regime_break:p})})]})]})})]})}),e.jsx(q,{children:e.jsxs(ze,{open:R.advancedMetrics,onOpenChange:()=>V("advancedMetrics"),children:[e.jsx(ce,{section:"advancedMetrics",icon:Be,title:"Performance Targets",badge:"INST"}),e.jsx($e,{children:e.jsxs(H,{className:"space-y-4 pt-0",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"text-xs",children:"Info Ratio"}),e.jsx(se,{type:"number",value:x.target_information_ratio,onChange:p=>S({...x,target_information_ratio:parseFloat(p.target.value)||1}),min:.5,max:3,step:.1,className:"h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"text-xs",children:"Treynor"}),e.jsx(se,{type:"number",value:x.target_treynor_ratio,onChange:p=>S({...x,target_treynor_ratio:parseFloat(p.target.value)||.1}),min:.05,max:.5,step:.01,className:"h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"text-xs",children:"Omega"}),e.jsx(se,{type:"number",value:x.target_omega_ratio,onChange:p=>S({...x,target_omega_ratio:parseFloat(p.target.value)||1.5}),min:1,max:3,step:.1,className:"h-8"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Min Profit Factor"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:x.min_profit_factor.toFixed(1)})]}),e.jsx(ee,{value:[x.min_profit_factor*10],onValueChange:([p])=>S({...x,min_profit_factor:p/10}),min:10,max:30,step:1})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(P,{children:"Min Win Rate"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(x.min_win_rate*100).toFixed(0),"%"]})]}),e.jsx(ee,{value:[x.min_win_rate*100],onValueChange:([p])=>S({...x,min_win_rate:p/100}),min:35,max:70,step:1})]})]})]})})]})})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[e.jsx(W,{variant:"outline",onClick:()=>v("agents"),children:"Cancel"}),e.jsx(W,{onClick:te,disabled:d,className:"gap-2",children:d?e.jsxs(e.Fragment,{children:[e.jsx(Me,{className:"w-4 h-4 animate-spin"}),"Creating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ls,{className:"w-4 h-4"}),"Create Agent"]})})]})]}),e.jsxs(Ue,{value:"signals",className:"space-y-4",children:[e.jsx(ac,{}),e.jsx(md,{})]}),e.jsxs(Ue,{value:"backtest",className:"space-y-6",children:[e.jsxs(q,{children:[e.jsx(X,{className:"pb-3",children:e.jsxs(Y,{className:"text-sm flex items-center gap-2",children:[e.jsx(Je,{className:"w-4 h-4 text-primary"}),"Run Backtest"]})}
116),e.jsxs(H,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"text-xs",children:"Select Agent(s)"}),e.jsxs(De,{value:A.length===1?A[0]:A.length>1?"multiple":"",onValueChange:p=>{p==="all"?B(a.map(re=>re.id)):p!=="multiple"&&B([p])},children:[e.jsx(Ee,{className:"h-9",children:e.jsx(Le,{placeholder:"Choose agent(s)..."})}),e.jsxs(Oe,{className:"bg-background border z-50",children:[e.jsx(ie,{value:"all",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(St,{className:"w-3 h-3"}),"All Agents (",a.length,")"]})}),a.map(p=>e.jsx(ie,{value:p.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ke,{className:"w-3 h-3"}),p.name,e.jsx(C,{variant:"outline",className:"text-[9px] ml-1",children:p.strategy_type})]})},p.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"text-xs",children:"Start Date"}),e.jsxs(Ga,{children:[e.jsx(Ka,{asChild:!0,children:e.jsxs(W,{variant:"outline",className:O("w-full h-9 justify-start text-left font-normal",!$&&"text-muted-foreground"),children:[e.jsx(Zt,{className:"mr-2 h-4 w-4"}),$?kt($,"MMM d, yyyy"):e.jsx("span",{children:"Pick start"})]})}),e.jsx(Ua,{className:"w-auto p-0 bg-background border z-50",align:"start",children:e.jsx(_a,{mode:"single",selected:$,onSelect:p=>p&&L(p),disabled:p=>p>D||p>new Date,initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"text-xs",children:"End Date"}),e.jsxs(Ga,{children:[e.jsx(Ka,{asChild:!0,children:e.jsxs(W,{variant:"outline",className:O("w-full h-9 justify-start text-left font-normal",!D&&"text-muted-foreground"),children:[e.jsx(Zt,{className:"mr-2 h-4 w-4"}),D?kt(D,"MMM d, yyyy"):e.jsx("span",{children:"Pick end"})]})}),e.jsx(Ua,{className:"w-auto p-0 bg-background border z-50",align:"start",children:e.jsx(_a,{mode:"single",selected:D,onSelect:p=>p&&F(p),disabled:p=>p<$||p>new Date,initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"text-xs",children:"Backtest Period"}),e.jsx("div",{className:"h-9 px-3 flex items-center bg-muted/30 rounded-md border border-border/50",children:e.jsxs("span",{className:"text-xs text-muted-foreground",children:[Math.round((D.getTime()-$.getTime())/(1e3*60*60*24))," days"]})})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center",children:[A.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1 items-center",children:[A.map(p=>{const re=a.find(ne=>ne.id===p);return re?e.jsxs(C,{variant:"secondary",className:"text-[10px] cursor-pointer hover:bg-destructive/20",onClick:()=>B(ne=>ne.filter(Pe=>Pe!==p)),children:[re.name," Ã"]},p):null}),A.length>1&&e.jsx(W,{variant:"ghost",size:"sm",className:"h-6 text-[10px]",onClick:()=>B([]),children:"Clear All"})]}),e.jsx(W,{onClick:async()=>{if(A.length===0){xe({title:"Select at least one agent",variant:"destructive"});return}U(!0);const p={},re=Math.round((D.getTime()-$.getTime())/(1e3*60*60*24));for(const ne of A){const Pe=a.find(Se=>Se.id===ne);if(Pe){const Se=[];let Te=1e4;const rs=Pe.strategy_type==="volatility"?.025:.018,ns=(Pe.target_sharpe||1.5)/100;for(let ht=0;ht<re;ht++){const pt=new Date($);pt.setDate(pt.getDate()+ht),Te*=1+(Math.random()-.48+ns)*rs,Se.push({date:pt.toISOString().split("T")[0],equity:Math.round(Te)})}p[ne]={id:ne,agent_id:ne,start_date:$.toISOString().split("T")[0],end_date:D.toISOString().split("T")[0],total_return:(Te-1e4)/1e4,sharpe_ratio:.8+Math.random()*1.5,max_drawdown:-(.08+Math.random()*.12),win_rate:.48+Math.random()*.15,total_trades:Math.floor(50+Math.random()*150),profit_factor:1.2+Math.random()*.8,sortino_ratio:1+Math.random()*1.2,calmar_ratio:.8+Math.random()*1,equity_curve:Se,regime_detected:["bull","bear","sideways"][Math.floor(Math.random()*3)],walk_forward_efficiency:.6+Math.random()*.3}}}await new Promise(ne=>setTimeout(ne,1500)),K(p),U(!1),xe({title:`Backtest complete for ${A.length} agent(s)`})},disabled:z||A.length===0,className:"gap-2",children:z?e.jsxs(e.Fragment,{children:[e.jsx(Me,{className:"w-4 h-4 animate-spin"}),"Running..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Je,{className:"w-4 h-4"}),"Run Backtest"]})})]})]})]}),Object.keys(G).length>0&&e.jsx("div",{className:"grid gap-4 lg:grid-cols-2",children:A.map(p=>{const re=a.find(Pe=>Pe.id===p),ne=G[p];return ne?e.jsx(pc,{backtest:ne,agentName:(re==null?void 0:re.name)||"Unknown"},p):null})}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-3",children:[e.jsx(xd,{}),e.jsx(hd,{}),e.jsx(pd,{})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-3",children:[e.jsx(gd,{}),e.jsx(bd,{}),e.jsx(vd,{})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(dd,{}),e.jsx(ur,{iterations:x.monte_carlo_iterations,initialCapital:1e4,expectedReturn:x.entry_threshold*10,volatility:x.stop_loss*3})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(nd,{}),e.jsx(od,{})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-3",children:[e.jsx(gc,{trainPeriodMonths:x.train_period_months||12,testPeriodMonths:x.test_period_months||3,walkForwardWindows:x.walk_forward_windows||4}),e.jsx(vc,{}),e.jsx(jd,{})]}),e.jsx(yd,{}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(mc,{}),e.jsx(ur,{iterations:x.monte_carlo_iterations})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(C,{className:"bg-violet-500/20 text-violet-400 border-violet-500/30",children:[e.jsx(pe,{className:"w-3 h-3 mr-1"}),"INSTITUTIONAL ANALYTICS"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Advanced quant metrics from top firms"})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(Ac,{agentConfig:x,liveData:{mlSignals:s.mlSignals,ensembleSignal:s.ensembleSignal,ensembleConfidence:s.ensembleConfidence,featureImportance:s.featureImportance}}),e.jsx(Cc,{agentConfig:x})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-3",children:[e.jsx(wc,{agentConfig:x,liveData:{riskMetrics:s.riskMetrics,marginalVaR:s.marginalVaR}}),e.jsx(Sc,{agentConfig:x,liveData:{riskBudget:s.riskBudget,currentDrawdown:s.riskMetrics.currentDrawdown}}),e.jsx(kc,{agentConfig:x})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(yc,{agentConfig:x,liveData:{correlationPairs:s.correlationPairs,zscoreHistory:s.zscoreHistory}}),e.jsx(Nc,{agentConfig:x})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(Mc,{agentConfig:x,liveData:{regime:s.regime}}),e.jsx(_c,{agentConfig:x,liveData:{sentiment:s.sentiment}})]})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-3",children:[e.jsx(hc,{agentConfig:x}),e.jsx(uc,{}),e.jsx(jc,{})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(fc,{}),e.jsx(bc,{})]})]})]})}),e.jsx(xc,{open:_,onOpenChange:y,agents:a.filter(p=>f.includes(p.id))}),e.jsx(Kt,{open:N,onOpenChange:w,children:e.jsxs(Ut,{className:"sm:max-w-md",children:[e.jsx(Xt,{children:e.jsx(Yt,{children:"Clone Agent"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"clone-name",children:"New Agent Name"}),e.jsx(se,{id:"clone-name",value:M,onChange:p=>T(p.target.value),placeholder:"Enter name for cloned agent",maxLength:100})]}),g&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Cloning from: ",e.jsx("span",{className:"font-medium",children:g.name})]})]}),e.jsxs(pa,{children:[e.jsx(W,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),e.jsxs(W,{onClick:_e,disabled:!M.trim(),children:[e.jsx(ha,{className:"w-4 h-4 mr-2"}),"Clone"]})]})]})})]})}export{pm as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.