PageSourceSearch

https://alfaprediction.com/assets/CRM-B9zyNKo4.js

js alfaprediction.com collected 2026-10-03 20:07:31 UTC 337,584 bytes, 147 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PerformanceView-ukxaWJQt.js","assets/radix-D8AG2QRe.js","assets/react-vendor-C5GjfL7N.js","assets/index-oUMDEH4U.js","assets/index-DGpX4IoQ.css","assets/charts-D9siLhqO.js","assets/patchAxisTouch-Cfba7lVZ.js","assets/createLucideIcon-DQCgnU1v.js","assets/trash-2-CHvgRDLM.js","assets/rotate-ccw-azgu2I3C.js","assets/utils-DQGxTgoy.js","assets/shield-check-BkQ1r-Qq.js","assets/PerformanceView-v-f-yNj8.css","assets/BacktestingView-wJUHolhr.js","assets/index-oddUVmxP.js","assets/triangle-alert-DDv6fia1.js","assets/attachHoverTab-Cjpxg_9l.js","assets/NetworkWorkspace-jN2dE6Qu.js","assets/deviceCompanionApi-JkP319ra.js","assets/NetworkWorkspace-CGgrhlwe.css","assets/TradeStationMovementChart-Z8eYp8Tj.js","assets/TradingViewAdvancedChartWidget-BEC69yJN.js","assets/index-h3aeLNcf.js","assets/index-H4YhSQIS.js"])))=>i.map(i=>d[i]);
2import{Q as $e,R as kn,u as ru,P as S,X as _f,Y as Df,Z as Ff,$ as Bf,a0 as Uf,a1 as Vf,a2 as Hf,a3 as qf,C as iu,r as jl,h as zf,U as Qf,a4 as bt,a5 as lu,_ as us,a6 as Wf,a as Kf,j as gd,b as Zi,a7 as el,g as tl,k as yd,d as Gf,a8 as wd,i as ur,a9 as vd,aa as Xf,ab as Yf,ac as Jf,ad as Zf,ae as ex,af as tx,ag as Nd,ah as sx,ai as nx,aj as ax}from"./index-oUMDEH4U.js";import{j as t,u as _s,a as rx,P as An,b as kl,d as ix,f as ou,m as lx,n as ox,c as fr,o as cx,s as dx,p as ux,q as mx,r as hx,t as fx,v as xx,w as bx,x as px,e as gx,g as yx,h as wx,k as vx,R as Nx,i as jx,F as kx}from"./radix-D8AG2QRe.js";import{a as g,e as x,b as xr,u as Ax,d as Sx}from"./react-vendor-C5GjfL7N.js";import{b as jd,c as m,a as cu,R as Bt,L as du,B as Al,A as Cx,C as ta}from"./utils-DQGxTgoy.js";import{c as ue}from"./createLucideIcon-DQCgnU1v.js";import{S as uu}from"./shield-check-BkQ1r-Qq.js";import"./charts-D9siLhqO.js";/**
3 * @license lucide-react v0.475.0 - ISC
4 *
5 * This source code is licensed under the ISC license.
6 * See the LICENSE file in the root directory of this source tree.
7 */const Ex=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Tx=ue("ArrowLeft",Ex);/**
8 * @license lucide-react v0.475.0 - ISC
9 *
10 * This source code is licensed under the ISC license.
11 * See the LICENSE file in the root directory of this source tree.
12 */const Px=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],kd=ue("ArrowUp",Px);/**
13 * @license lucide-react v0.475.0 - ISC
14 *
15 * This source code is licensed under the ISC license.
16 * See the LICENSE file in the root directory of this source tree.
17 */const Ix=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],sa=ue("ChartLine",Ix);/**
18 * @license lucide-react v0.475.0 - ISC
19 *
20 * This source code is licensed under the ISC license.
21 * See the LICENSE file in the root directory of this source tree.
22 */const $x=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Lx=ue("ChevronDown",$x);/**
23 * @license lucide-react v0.475.0 - ISC
24 *
25 * This source code is licensed under the ISC license.
26 * See the LICENSE file in the root directory of this source tree.
27 */const Rx=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],mu=ue("ChevronLeft",Rx);/**
28 * @license lucide-react v0.475.0 - ISC
29 *
30 * This source code is licensed under the ISC license.
31 * See the LICENSE file in the root directory of this source tree.
32 */const Mx=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],pr=ue("ChevronRight",Mx);/**
33 * @license lucide-react v0.475.0 - ISC
34 *
35 * This source code is licensed under the ISC license.
36 * See the LICENSE file in the root directory of this source tree.
37 */const Ox=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]],_x=ue("ClipboardCopy",Ox);/**
38 * @license lucide-react v0.475.0 - ISC
39 *
40 * This source code is licensed under the ISC license.
41 * See the LICENSE file in the root directory of this source tree.
42 */const Dx=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]],yn=ue("Download",Dx);/**
43 * @license lucide-react v0.475.0 - ISC
44 *
45 * This source code is licensed under the ISC license.
46 * See the LICENSE file in the root directory of this source tree.
47 */const Fx=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],Bx=ue("Ellipsis",Fx);/**
48 * @license lucide-react v0.475.0 - ISC
49 *
50 * This source code is licensed under the ISC license.
51 * See the LICENSE file in the root directory of this source tree.
52 */const Ux=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],hu=ue("LayoutGrid",Ux);/**
53 * @license lucide-react v0.475.0 - ISC
54 *
55 * This source code is licensed under the ISC license.
56 * See the LICENSE file in the root directory of this source tree.
57 */const Vx=[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]],fu=ue("LogOut",Vx);/**
58 * @license lucide-react v0.475.0 - ISC
59 *
60 * This source code is licensed under the ISC license.
61 * See the LICENSE file in the root directory of this source tree.
62 */const Hx=[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]],xu=ue("Menu",Hx);/**
63 * @license lucide-react v0.475.0 - ISC
64 *
65 * This source code is licensed under the ISC license.
66 * See the LICENSE file in the root directory of this source tree.
67 */const qx=[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]],dl=ue("MessageCircle",qx);/**
68 * @license lucide-react v0.475.0 - ISC
69 *
70 * This source code is licensed under the ISC license.
71 * See the LICENSE file in the root directory of this source tree.
72 */const zx=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],Sl=ue("Moon",zx);/**
73 * @license lucide-react v0.475.0 - ISC
74 *
75 * This source code is licensed under the ISC license.
76 * See the LICENSE file in the root directory of this source tree.
77 */const Qx=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],Wx=ue("PanelLeftClose",Qx);/**
78 * @license lucide-react v0.475.0 - ISC
79 *
80 * This source code is licensed under the ISC license.
81 * See the LICENSE file in the root directory of this source tree.
82 */const Kx=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],Gx=ue("PanelRightClose",Kx);/**
83 * @license lucide-react v0.475.0 - ISC
84 *
85 * This source code is licensed under the ISC license.
86 * See the LICENSE file in the root directory of this source tree.
87 */const Xx=[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]],Yx=ue("PenLine",Xx);/**
88 * @license lucide-react v0.475.0 - ISC
89 *
90 * This source code is licensed under the ISC license.
91 * See the LICENSE file in the root directory of this source tree.
92 */const Jx=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Zx=ue("Plus",Jx);/**
93 * @license lucide-react v0.475.0 - ISC
94 *
95 * This source code is licensed under the ISC license.
96 * See the LICENSE file in the root directory of this source tree.
97 */const eb=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],tb=ue("Power",eb);/**
98 * @license lucide-react v0.475.0 - ISC
99 *
100 * This source code is licensed under the ISC license.
101 * See the LICENSE file in the root directory of this source tree.
102 */const sb=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],nb=ue("Save",sb);/**
103 * @license lucide-react v0.475.0 - ISC
104 *
105 * This source code is licensed under the ISC license.
106 * See the LICENSE file in the root directory of this source tree.
107 */const ab=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],bu=ue("Search",ab);/**
108 * @license lucide-react v0.475.0 - ISC
109 *
110 * This source code is licensed under the ISC license.
111 * See the LICENSE file in the root directory of this source tree.
112 */const rb=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],ul=ue("Settings",rb);/**
113 * @license lucide-react v0.475.0 - ISC
114 *
115 * This source code is licensed under the ISC license.
116 * See the LICENSE file in the root directory of this source tree.
117 */const ib=[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]],Ad=ue("Sparkles",ib);/**
118 * @license lucide-react v0.475.0 - ISC
119 *
120 * This source code is licensed under the ISC license.
121 * See the LICENSE file in the root directory of this source tree.
122 */const lb=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],pu=ue("Sun",lb);/**
123 * @license lucide-react v0.475.0 - ISC
124 *
125 * This source code is licensed under the ISC license.
126 * See the LICENSE file in the root directory of this source tree.
127 */const ob=[["path",{d:"M12 3v18",key:"108xh3"}],["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"}]],cb=ue("Table",ob);
127/**
128 * @license lucide-react v0.475.0 - ISC
129 *
130 * This source code is licensed under the ISC license.
131 * See the LICENSE file in the root directory of this source tree.
132 */const db=[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]],gu=ue("TrendingUp",db);/**
133 * @license lucide-react v0.475.0 - ISC
134 *
135 * This source code is licensed under the ISC license.
136 * See the LICENSE file in the root directory of this source tree.
137 */const ub=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],ml=ue("User",ub);/**
138 * @license lucide-react v0.475.0 - ISC
139 *
140 * This source code is licensed under the ISC license.
141 * See the LICENSE file in the root directory of this source tree.
142 */const mb=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2",key:"4125el"}],["path",{d:"M3 11h3c.8 0 1.6.3 2.1.9l1.1.9c1.6 1.6 4.1 1.6 5.7 0l1.1-.9c.5-.5 1.3-.9 2.1-.9H21",key:"1dpki6"}]],yu=ue("WalletCards",mb);/**
143 * @license lucide-react v0.475.0 - ISC
144 *
145 * This source code is licensed under the ISC license.
146 * See the LICENSE file in the root directory of this source tree.
147 */const hb=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ms=ue("X",hb),fb="http://localhost";function xb(s){var r;return typeof window<"u"&&typeof((r=window.location)==null?void 0:r.origin)=="string"&&window.location.origin?window.location.origin:fb}function bb(s,r,i){!Array.isArray(i)||!i.length||i.forEach(d=>{if(d==null)return;const f=String(d).trim();f&&s.append(r,f)})}function Sd(s){if(!s&&s!==0)return null;if(s instanceof Date)return Number.isNaN(s.getTime())?null:s.toISOString().slice(0,10);const r=String(s).trim();if(!r)return null;const i=new Date(r);return Number.isNaN(i.getTime())?null:i.toISOString().slice(0,10)}function pb(s,r){if(!Array.isArray(r)||!r.length)return;const i=new Set;r.forEach(d=>{if(!d||typeof d!="object")return;const f=typeof d.strategy=="string"?d.strategy.trim():"",n=typeof d.returnType=="string"?d.returnType.trim():"",w=Number(d.multiplier);if(!f||!n||!Number.isFinite(w))return;const y=`${f}|${n}|${w}`;i.has(y)||(i.add(y),s.append("selection",y))})}function gb(s,{strategies:r,multipliers:i,selections:d,from:f,to:n}={},w){const y=new URL(s,xb());if(pb(y.searchParams,d),bb(y.searchParams,"strategy",Array.isArray(r)?r:r?[r]:[]),Array.isArray(i)&&i.length)i.forEach(T=>{const I=Number(T);Number.isFinite(I)&&y.searchParams.append("multiplier",String(I))});else if(i!=null){const T=Number(i);Number.isFinite(T)&&y.searchParams.append("multiplier",String(T))}const j=Sd(f);j&&y.searchParams.set("from",j);const k=Sd(n);return k&&y.searchParams.set("to",k),y.toString()}const hl=300*1e3,fl=30*1e3,Cd=60*1e3,yb=2,wb=Object.freeze(["alfa.performance.catalog.v2","alfa.performance.daily-returns.v2"]);function vb(s){let r=s;if(r===void 0)try{r=typeof window<"u"?window.localStorage:null}catch{r=null}r!=null&&r.removeItem&&wb.forEach(i=>{try{r.removeItem(i)}catch{}})}function Ed(s=Date.now(),r=hl,i=fl){const d=Number.isFinite(r)&&r>0?Math.floor(r):hl,f=Number.isFinite(i)?Math.max(0,Math.min(Math.floor(i),d-1)):fl,w=((Number.isFinite(s)?s:Date.now())%d+d)%d;return w<f?f-w:d-w+f}function Td(s=Date.now(),r=0,i=Cd){if((Number.isInteger(r)?Math.max(0,r):0)===0)return Ed(s);const f=Number.isFinite(i)&&i>0?Math.floor(i):Cd;return Math.min(f,Ed(s))}function Nb(s){return!Number.isInteger(s)||s<0?0:s<yb?s+1:0}const jb=$e("/performance/catalog"),kb=$e("/performance/daily-returns");vb();function Ab(s={},r){const i=typeof r=="string"?r.trim():"";return i?{...s,Authorization:`Bearer ${i}`}:kn(s)}async function Cl(s,{signal:r,accessToken:i,method:d="GET"}={}){const f=await fetch(s,{method:d,signal:r,cache:"no-store",headers:Ab({},i)});if(!f.ok){const n=await f.text(),w=new Error(`Request failed (${f.status}): ${n||f.statusText}`);throw w.status=f.status,w}return f.json()}async function Pd({signal:s,accessToken:r}={}){return Cl(jb,{signal:s,accessToken:r})}async function Sb({signal:s,accessToken:r}={}){return Cl($e("/forecast/run"),{signal:s,accessToken:r,method:"POST"})}
147async function Cb({strategies:s,multipliers:r,selections:i,from:d,to:f,signal:n,accessToken:w}={}){const y=gb(kb,{strategies:s,multipliers:r,selections:i,from:d,to:f});return Cl(y,{signal:n,accessToken:w})}function Eb({refresh:s,enabled:r,now:i=Date.now}){let d=null,f=null;return{run({force:n=!1}={}){if(!r)return Promise.resolve(null);if(d)return d;const w=Math.floor((i()-fl)/hl);if(!n&&f===w)return Promise.resolve(null);const y=(async()=>{var T;let k;try{k=await s()}catch(I){if(I.status!==409)throw I;k=await s()}if((T=k==null?void 0:k.errors)!=null&&T.length)throw new Error(k.errors.join("; "));return f=w,k})();d=y;const j=()=>{d===y&&(d=null)};return y.then(j,j),y}}}const xl={dark:{container:"bg-slate-900/95 border border-emerald-500/40 ring-1 ring-emerald-500/25 shadow-[0_18px_42px_rgba(16,185,129,0.2)] backdrop-blur-md",active:"bg-emerald-500 text-white shadow-[inset_0_1px_0_rgba(255,255,255,0.25)]",inactive:"text-slate-200 hover:bg-emerald-500/15"},light:{container:"bg-white border border-emerald-400/40 ring-1 ring-emerald-300/30 shadow-[0_16px_32px_rgba(16,185,129,0.15)] backdrop-blur-sm",active:"bg-emerald-500 text-white shadow-[inset_0_1px_0_rgba(255,255,255,0.25)]",inactive:"text-gray-700 hover:bg-emerald-100"},crmDark:{container:"bg-[#1C1F22] border border-white/10",active:"bg-white/10 text-white shadow-[inset_0_1px_0_rgba(255,255,255,0.08)]",inactive:"text-white/70 hover:bg-white/5"},crmLight:{container:"bg-white border border-gray-200 shadow-[0_12px_26px_rgba(15,23,42,0.12)]",active:"bg-gray-100 text-gray-900 shadow-[inset_0_1px_0_rgba(255,255,255,0.45)]",inactive:"text-gray-700 hover:bg-gray-50"},settingsDark:{container:"border border-white/10 bg-[#14171A]",active:"bg-white/10 text-white",inactive:"text-white/70 hover:bg-white/[0.07] hover:text-white"},settingsLight:{container:"border border-slate-200 bg-white",active:"bg-slate-100 text-slate-950",inactive:"text-slate-600 hover:bg-slate-50 hover:text-slate-950"}},bl={sm:"px-3 py-1.5 text-xs",md:"px-4 py-2 text-sm",lg:"px-5 py-2.5 text-base"};function wu({theme:s="dark",size:r="md",className:i="",labelVariant:d="native",orientation:f="horizontal",layout:n="segmented",direction:w,onSelect:y}){const{language:j,languages:k,setLanguage:T}=ru(),I=xl[s]||xl.dark,p=bl[r]||bl.md,N=n==="responsive",M=n==="grid",$=!N&&!M,_=$&&f==="vertical";return t.jsx("div",{className:jd($?_?"flex flex-col min-w-[160px] rounded-xl overflow-hidden border transition-colors motion-reduce:transition-none":"inline-flex rounded-lg overflow-hidden border transition-colors motion-reduce:transition-none":M?"grid grid-cols-2 gap-2 rounded-xl border p-2 transition-colors motion-reduce:transition-none":"grid grid-cols-2 gap-2 rounded-xl border p-2 transition-colors motion-reduce:transition-none sm:inline-flex sm:gap-0 sm:p-0 sm:rounded-lg sm:overflow-hidden",I.container,i),dir:w,children:k.map(({code:Q,nativeLabel:G,label:ie})=>{const ne=Q===j;return t.jsx("button",{type:"button","aria-pressed":ne,onClick:()=>{T(Q),typeof y=="function"&&y(Q)},className:jd("relative font-medium transition-colors motion-reduce:transition-none focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-emerald-400/70",p,_?"w-full text-start px-4":null,M||N?"w-full text-center rounded-lg":null,N?"sm:w-auto sm:rounded-none":null,ne?I.active:I.inactive),children:d==="native"?G:ie},Q)})})}wu.propTypes={theme:S.oneOf(Object.keys(xl)),size:S.oneOf(Object.keys(bl)),className:S.string,labelVariant:S.oneOf(["native","english"]),orientation:S.oneOf(["horizontal","vertical"]),layout:S.oneOf(["segmented","grid","responsive"]),direction:S.oneOf(["ltr","rtl"]),onSelect:S.func};const Id={positions:"idle",orders:"idle",historical:"idle",stream:"idle"},$d={positions:null,orders:null,historical:null,stream:null};function sl(s){if(!s)return null;if(s instanceof Date){const r=s.getTime();return Number.isNaN(r)?null:r}if(typeof s=="number"){if(!Number.isFinite(s))return null;const i=Math.abs(s)<1e12?s*1e3:s;return Number.isFinite(i)?i:null}if(typeof s=="string"){const r=Date.parse(s);return Number.isNaN(r)?null:r}return null}function bn(s){return!s||typeof s!="object"?Date.now():sl(s.timestamp)??sl(s.updatedAt)??sl(s.generatedAt)??Date.now()}function vu(s){if(!s||typeof s!="object")return null;const r=[s.id,s.accountId,s.AccountId,s.account];for(const i of r)if(typeof i=="string"){const d=i.trim();if(d)return d}return null}function Tb(s){if(!s||typeof s!="object")return null;const r=vu(s);if(!r)return null;const i=typeof s.name=="string"&&s.name.trim()?s.name.trim():r,f=[s.currency,s.accountCurrency,s.Currency].map(y=>typeof y=="string"?y.trim():"").find(y=>y)||void 0,n=Array.isArray(s.assignedEmails)?s.assignedEmails:Array.isArray(s.AssignedEmails)?s.AssignedEmails:[],w=typeof s.isActive=="boolean"?s.isActive:typeof s.IsActive=="boolean"?s.IsActive:typeof s.active=="boolean"?s.active:null;return{...s,id:r,name:i,currency:f??s.currency,assignedEmails:n,isActive:w??!0,raw:s.raw??s}}function pl(s){return Array.isArray(s)?s.map(Tb).filter(r=>r&&r.id):[]}function Pb({enabled:s=!0}={}){const[r,i]=g.useState([]),[d,f]=g.useState("idle"),[n,w]=g.useState(null),[y,j]=g.useState(null),[k,T]=g.useState(0),I=g.useCallback(()=>{T(p=>p+1)},[]);return g.useEffect(()=>{if(!s){i([]),f("idle"),w(null),j(null);return}const p=new AbortController;return f(N=>N==="idle"?"loading":"refreshing"),w(null),_f({signal:p.signal}).then(N=>{if(p.signal.aborted)return;const M=pl(N==null?void 0:N.accounts);i(M),j(typeof(N==null?void 0:N.timestamp)=="number"?N.timestamp:Date.now()),f("ready")}
147).catch(N=>{p.signal.aborted||(w(N),f("error"))}),()=>p.abort()},[s,k]),{accounts:r,status:d,error:n,timestamp:y,reload:I,isLoading:d==="loading",isRefreshing:d==="refreshing",isReady:d==="ready"}}function Ib({accountIds:s=[],enabled:r=!0}={}){const i=g.useMemo(()=>Array.from(new Set((s||[]).filter(Ae=>typeof Ae=="string"&&Ae.trim()!==""))),[s]),d=g.useMemo(()=>i.slice().sort().join("|"),[i]),[f,n]=g.useState([]),[w,y]=g.useState([]),[j,k]=g.useState([]),[T,I]=g.useState([]),[p,N]=g.useState([]),[M,$]=g.useState(Id),[_,Q]=g.useState($d),[G,ie]=g.useState(null),[ne,V]=g.useState(null),H=g.useRef(null),W=g.useRef([]),U=g.useRef(0),pe=g.useRef(0),Y=g.useRef(0),K=g.useRef(new Set),Le=g.useCallback(async(Ae="refresh")=>{var Ct,Et,pt;if(!r)return;const O=i;H.current&&H.current.abort();const D=new AbortController;H.current=D;const Z=Ae==="initial"||Ae==="manual";$(R=>({...R,positions:Ae==="initial"||R.positions==="loading"?"loading":"refreshing",orders:Ae==="initial"||R.orders==="loading"?"loading":"refreshing",historical:Z?Ae==="initial"||R.historical==="loading"?"loading":"refreshing":R.historical})),Ae==="initial"?Q(R=>({...R,positions:null,orders:null,historical:null})):Z&&Q(R=>({...R,historical:null}));const J=[Ff({accountIds:O,signal:D.signal}),Bf({accountIds:O,signal:D.signal})];Z&&J.push(Uf({accountIds:O,signal:D.signal}));const He=await Promise.allSettled(J),z=He[0],oe=He[1],xe=Z?He[2]:null;if(D.signal.aborted)return;let ge=[];if(z.status==="fulfilled"){const R=z.value||{},ke=bn(R);if(ke>=(U.current||0)){if(U.current=ke,n(Array.isArray(R.positions)?R.positions:[]),Array.isArray(R.accounts)&&R.accounts.length){const P=pl(R.accounts);P.length&&(N(P),ge=P)}ie(P=>Math.max(P??0,ke))}Q(P=>({...P,positions:Array.isArray(R.errors)&&R.errors.length?R.errors:null})),$(P=>({...P,positions:"ready"}))}else((Ct=z.reason)==null?void 0:Ct.name)!=="AbortError"&&(Q(R=>({...R,positions:z.reason})),$(R=>({...R,positions:"error"})));if(oe.status==="fulfilled"){const R=oe.value||{},ke=bn(R);if(ke>=(pe.current||0)){if(pe.current=ke,y(Array.isArray(R.orders)?R.orders:[]),!ge.length&&Array.isArray(R.accounts)&&R.accounts.length){const P=pl(R.accounts);P.length&&N(P)}ie(P=>Math.max(P??0,ke))}Q(P=>({...P,orders:Array.isArray(R.errors)&&R.errors.length?R.errors:null})),$(P=>({...P,orders:"ready"}))}else((Et=oe.reason)==null?void 0:Et.name)!=="AbortError"&&(Q(R=>({...R,orders:oe.reason})),$(R=>({...R,orders:"error"})));if(xe)if(xe.status==="fulfilled"){const R=xe.value||{},ke=bn(R);ke>=(Y.current||0)&&(Y.current=ke,k(Array.isArray(R.orders)?R.orders:[]),V(ke)),Q(P=>({...P,historical:Array.isArray(R.errors)&&R.errors.length?R.errors:null})),$(P=>({...P,historical:"ready"}))}else((pt=xe.reason)==null?void 0:pt.name)!=="AbortError"&&(Q(R=>({...R,historical:xe.reason})),$(R=>({...R,historical:"error"})));const Ze=[];z.status==="fulfilled"&&Ze.push(bn(z.value)),oe.status==="fulfilled"&&Ze.push(bn(oe.value)),xe&&xe.status==="fulfilled"&&Ze.push(bn(xe.value)),Ze.length&&ie(R=>Math.max(R??0,Math.max(...Ze)))},[r,i]);g.useEffect(()=>{var Ae;if((Ae=H.current)==null||Ae.abort(),W.current.forEach(O=>{try{O()}catch{}}),W.current=[],U.current=0,pe.current=0,Y.current=0,K.current=new Set,n([]),y([]),k([]),I([]),N([]),ie(null),V(null),!r){$(Id),Q($d);return}$(O=>({...O,stream:"loading"})),Q(O=>({...O,stream:null})),Le("initial");{$(Z=>({...Z,stream:"ready"}));let O=0;const D=window.setInterval(()=>{document.visibilityState==="visible"&&(O+=1,Le(O%10===0?"manual":"poll"))},3e4);return()=>{var Z;window.clearInterval(D),(Z=H.current)==null||Z.abort()}}},[d,r,Le,i]);const Je=g.useCallback(()=>Le("manual"),[Le]);return{positions:f,orders:w,historicalOrders:j,realtimeFilledOrders:T,accountSummaries:p,status:M,errors:_,lastUpdated:G,historicalUpdated:ne,reload:Je}}function $b(s){if(!s||typeof s!="object")return null;const r=vu(s);if(!r)return null;const i=s.extendedData||s.ExtendedData||{},f=[s.currency,s.accountCurrency,s.Currency,i.Currency].map(w=>typeof w=="string"?w.trim():"").find(w=>w)||"USD",n=w=>{if(typeof w=="number"&&Number.isFinite(w))return w;if(typeof w=="string"){const y=Number(w);return Number.isFinite(y)?y:null}return null};return{accountId:r,accountName:s.accountName??s.name??i.AccountName??r,currency:f,cashBalance:n(s.cashBalance??s.CashBalance??i.CashBalance??i.Cash),buyingPower:n(s.buyingPower??s.BuyingPower??i.BuyingPower??i.OptionBuyingPower),equity:n(s.equity??s.Equity??i.Equity??i.RealTimeAccountBalance??i.AccountValue??i.MarketValue),dayTradingBuyingPower:n(s.dayTradingBuyingPower??s.DayTradingBuyingPower??i.DayTradingBuyingPower??i.DayTradeBuyingPower),realizedPnl:n(s.realizedProfitLoss??s.RealizedProfitLoss??i.RealizedProfitLoss??i.TodayRealTimeTradeEquity),unrealizedPnl:n(s.unrealizedProfitLoss??s.UnrealizedProfitLoss??i.UnrealizedProfitLoss??i.OpenPL),raw:s}}
147function Lb(s){return Array.isArray(s)?s.map($b).filter(Boolean):[]}function Rb({accountIds:s=[],enabled:r=!0}={}){const i=g.useMemo(()=>Array.from(new Set((s||[]).filter($=>typeof $=="string"&&$.trim()!==""))),[s]),d=g.useMemo(()=>i.slice().sort().join("|"),[i]),[f,n]=g.useState([]),[w,y]=g.useState("idle"),[j,k]=g.useState(null),[T,I]=g.useState(null),p=g.useRef(null),N=g.useCallback(async($="refresh")=>{if(!r)return;const _=i;if(!_.length){n([]),y("ready"),k(null),I(Date.now());return}p.current&&p.current.abort();const Q=new AbortController;p.current=Q,y($==="initial"?"loading":"refreshing"),$==="initial"&&k(null);try{const G=await Df({accountIds:_,signal:Q.signal});if(Q.signal.aborted)return;const ie=Lb((G==null?void 0:G.balances)??(G==null?void 0:G.accounts)??[]);n(ie),k(null),y("ready"),I(typeof(G==null?void 0:G.timestamp)=="number"?G.timestamp:Date.now())}catch(G){if((G==null?void 0:G.name)==="AbortError")return;k(G),y("error")}},[r,i]);g.useEffect(()=>{var $;if(($=p.current)==null||$.abort(),!r){y("idle"),k(null);return}return N("initial"),()=>{var _;(_=p.current)==null||_.abort()}},[d,r,N]),g.useEffect(()=>{if(r){const $=window.setInterval(()=>{document.visibilityState==="visible"&&N("poll")},3e4);return()=>window.clearInterval($)}},[r,i,N]);const M=g.useCallback(()=>N("manual"),[N]);return{balances:f,status:w,error:j,lastUpdated:T,reload:M,isLoading:w==="loading",isRefreshing:w==="refreshing",isReady:w==="ready"}}async function Mb(s={}){const r=$e("/streaming/premium/config"),i=await fetch(r,{method:"GET",signal:s.signal,headers:kn({Accept:"application/json"})});if(!i.ok){let d=null;try{const f=await i.clone().json();f&&typeof f=="object"&&(typeof f.detail=="string"?d=f.detail:typeof f.error=="string"&&(d=f.error))}catch{}throw new Error(d??`Failed to load premium configuration (status ${i.status})`)}try{return await i.json()}catch(d){throw new Error(d instanceof Error?d.message:"Invalid premium configuration payload")}}const cs=Object.freeze({GENERAL:"General",ACCOUNTS:"Accounts",GRAPH:"Graph Settings",ALERTS:"Alerts",LANGUAGE:"Language",THEME:"Theme",DOWNLOADS:"Downloads",SYSTEM:"System"}),Ob=Object.freeze([cs.GENERAL,cs.ACCOUNTS,cs.GRAPH,cs.ALERTS,cs.LANGUAGE,cs.THEME]);function _b({isAdmin:s=!1,isNative:r=!1}={}){const i=[...Ob];return r||i.push(cs.DOWNLOADS),s&&i.push(cs.SYSTEM),i}const Gt="transition-colors duration-200 ease-out motion-reduce:transition-none";function gr(s){const r=s?"border-white/10":"border-slate-200",i=s?"bg-[#1C1F22]":"bg-white";return{motion:Gt,overlay:s?"bg-black/60 backdrop-blur-sm":"bg-slate-950/30 backdrop-blur-sm",shell:s?"border-white/10 bg-[#181B1F] text-gray-100 shadow-[0_24px_64px_rgba(0,0,0,0.35)]":"border-slate-200 bg-white text-slate-900 shadow-[0_24px_64px_rgba(15,23,42,0.15)]",header:s?"border-white/10 bg-[#181B1F]":"border-slate-200 bg-white",sidebar:s?"border-white/10 bg-[#15181B]":"border-slate-200 bg-slate-50",content:s?"bg-[#181B1F]":"bg-white",card:`alfa-fx-card ${Gt} rounded-xl border ${r} ${i}`,row:`${Gt} min-h-11 rounded-lg border ${r} ${i}`,interactiveRow:s?"hover:bg-white/[0.04]":"hover:bg-slate-50",overviewRow:`${Gt} min-h-11 border-b ${r} ${s?"text-gray-200 hover:bg-white/[0.035] hover:text-white":"text-slate-700 hover:bg-slate-50 hover:text-slate-950"}`,iconWell:s?"text-white/60":"text-slate-500",searchField:`${Gt} rounded-lg ${s?"border-white/10 bg-white/[0.025] text-white placeholder:text-white/40 focus:border-white/25 focus:ring-2 focus:ring-white/10":"border-slate-200 bg-slate-50 text-slate-900 placeholder:text-slate-400 focus:border-slate-400 focus:ring-2 focus:ring-slate-200"}`,searchResults:s?"border-white/10 bg-[#1C1F22] shadow-[0_8px_24px_rgba(0,0,0,0.25)]":"border-slate-200 bg-white shadow-[0_8px_24px_rgba(15,23,42,0.1)]",control:`${Gt} min-h-11 rounded-lg border outline-none ${s?"border-white/10 bg-[#14171A] text-white focus:border-emerald-400/50 focus:ring-2 focus:ring-emerald-400/15":"border-slate-200 bg-white text-slate-800 focus:border-emerald-600/50 focus:ring-2 focus:ring-emerald-500/15"}`,primaryAction:`${Gt} bg-emerald-600 text-white hover:bg-emerald-700`,secondaryAction:`${Gt} border ${s?"border-white/10 bg-transparent text-gray-200 hover:bg-white/[0.06] hover:text-white":"border-slate-200 bg-white text-slate-700 hover:bg-slate-50 hover:text-slate-950"}`,dangerAction:`${Gt} border ${s?"border-rose-400/20 bg-transparent text-rose-300 hover:bg-rose-400/10":"border-rose-200 bg-white text-rose-700 hover:bg-rose-50"}`,mutedText:s?"text-white/55":"text-slate-500"}}function Nu(s){const r=typeof(s==null?void 0:s.executionEnabled)=="boolean"?s.executionEnabled:!!(s!=null&&s.executionEnabled),i=typeof(s==null?void 0:s.updatedAtUtc)=="string"?s.updatedAtUtc:null;return{executionEnabled:r,updatedAtUtc:i}}
147class ju extends Error{constructor(r,i){super(r),this.name="ProgramControlRequestError",this.status=i}}function ku(s,r){const i=kn(s),d=typeof r=="string"?r.trim():"";return d&&(i.Authorization=`Bearer ${d}`),i}async function Db(s={}){const r=await fetch($e("/program-control/strategy-execution"),{method:"GET",signal:s.signal,headers:ku({Accept:"application/json"},s.token)});if(!r.ok){const d=await Au(r);throw new ju(d??`Failed to load program control state (status ${r.status})`,r.status)}const i=await El(r);return Nu(i)}async function Fb(s,r={}){const i=await fetch($e("/program-control/strategy-execution"),{method:"PUT",signal:r.signal,headers:ku({Accept:"application/json","Content-Type":"application/json"},r.token),body:JSON.stringify({executionEnabled:s})});if(!i.ok){const f=await Au(i);throw new ju(f??`Failed to update program control state (status ${i.status})`,i.status)}const d=await El(i);return Nu(d)}async function Au(s){const r=await El(s);if(r&&typeof r=="object"){if(typeof r.detail=="string"&&r.detail.trim())return r.detail.trim();if(typeof r.title=="string"&&r.title.trim())return r.title.trim();if(typeof r.message=="string"&&r.message.trim())return r.message.trim()}return null}async function El(s){try{return await s.clone().json()}catch{return null}}function Su(s){if(!s||typeof s!="object")return null;const r=typeof s.timestamp=="string"?s.timestamp:s.Timestamp,i=s.level??s.Level??"Info",d=s.message??s.Message,f=s.context??s.Context??null;return typeof d!="string"||!d.trim()?null:{timestamp:typeof r=="string"&&r?r:new Date().toISOString(),level:typeof i=="string"&&i?i:"Info",message:d.trim(),context:typeof f=="string"?f:null}}async function Bb(s={}){const r=Math.max(1,Math.min(200,s.limit??50)),i=await fetch($e(`/system/logs?limit=${encodeURIComponent(r)}`),{method:"GET",signal:s.signal,headers:kn({Accept:"application/json"})});if(!i.ok){const f=await Vb(i);throw new Error(f??`Failed to load system logs (status ${i.status})`)}const d=await Cu(i);return Array.isArray(d)?d.map(f=>Su(f)).filter(f=>!!f):[]}function Ub(s,r={}){return Vf("SystemLogEntry",d=>{const f=Su(d);f&&s(f)},r)}async function Vb(s){const r=await Cu(s);if(r&&typeof r=="object"){if(typeof r.detail=="string"&&r.detail.trim())return r.detail.trim();if(typeof r.message=="string"&&r.message.trim())return r.message.trim();if(typeof r.title=="string"&&r.title.trim())return r.title.trim()}return null}async function Cu(s){try{return await s.clone().json()}catch{return null}}function Ft({className:s,...r}){return t.jsx("div",{className:m("relative overflow-hidden rounded-md bg-muted",s),...r,children:t.jsx("div",{className:"absolute inset-0 -translate-x-full animate-shimmer bg-gradient-to-r from-transparent via-white/10 to-transparent pointer-events-none"})})}function hs(s,r,{checkForDefaultPrevented:i=!0}={}){return function(f){if(s==null||s(f),i===!1||!f.defaultPrevented)return r==null?void 0:r(f)}}var Hb="DismissableLayer",gl="dismissableLayer.update",qb="dismissableLayer.pointerDownOutside",zb="dismissableLayer.focusOutside",Ld,Eu=g.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Tu=g.forwardRef((s,r)=>{const{disableOutsidePointerEvents:i=!1,onEscapeKeyDown:d,onPointerDownOutside:f,onFocusOutside:n,onInteractOutside:w,onDismiss:y,...j}=s,k=g.useContext(Eu),[T,I]=g.useState(null),p=(T==null?void 0:T.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,N]=g.useState({}),M=_s(r,W=>I(W)),$=Array.from(k.layers),[_]=[...k.layersWithOutsidePointerEventsDisabled].slice(-1),Q=$.indexOf(_),G=T?$.indexOf(T):-1,ie=k.layersWithOutsidePointerEventsDisabled.size>0,ne=G>=Q,V=Kb(W=>{const U=W.target,pe=[...k.branches].some(Y=>Y.contains(U));!ne||pe||(f==null||f(W),w==null||w(W),W.defaultPrevented||y==null||y())},p),H=Gb(W=>{const U=W.target;[...k.branches].some(Y=>Y.contains(U))||(n==null||n(W),w==null||w(W),W.defaultPrevented||y==null||y())},p);return rx(W=>{G===k.layers.size-1&&(d==null||d(W),!W.defaultPrevented&&y&&(W.preventDefault(),y()))},p),g.useEffect(()=>{if(T)return i&&(k.layersWithOutsidePointerEventsDisabled.size===0&&(Ld=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),k.layersWithOutsidePointerEventsDisabled.add(T)),
vendor: 14,131 bytes, line 147
147k.layers.add(T),Rd(),()=>{i&&k.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=Ld)}},[T,p,i,k]),g.useEffect(()=>()=>{T&&(k.layers.delete(T),k.layersWithOutsidePointerEventsDisabled.delete(T),Rd())},[T,k]),g.useEffect(()=>{const W=()=>N({});return document.addEventListener(gl,W),()=>document.removeEventListener(gl,W)},[]),t.jsx(An.div,{...j,ref:M,style:{pointerEvents:ie?ne?"auto":"none":void 0,...s.style},onFocusCapture:hs(s.onFocusCapture,H.onFocusCapture),onBlurCapture:hs(s.onBlurCapture,H.onBlurCapture),onPointerDownCapture:hs(s.onPointerDownCapture,V.onPointerDownCapture)})});Tu.displayName=Hb;var Qb="DismissableLayerBranch",Wb=g.forwardRef((s,r)=>{const i=g.useContext(Eu),d=g.useRef(null),f=_s(r,d);return g.useEffect(()=>{const n=d.current;if(n)return i.branches.add(n),()=>{i.branches.delete(n)}},[i.branches]),t.jsx(An.div,{...s,ref:f})});Wb.displayName=Qb;function Kb(s,r=globalThis==null?void 0:globalThis.document){const i=kl(s),d=g.useRef(!1),f=g.useRef(()=>{});return g.useEffect(()=>{const n=y=>{if(y.target&&!d.current){let j=function(){Pu(qb,i,k,{discrete:!0})};const k={originalEvent:y};y.pointerType==="touch"?(r.removeEventListener("click",f.current),f.current=j,r.addEventListener("click",f.current,{once:!0})):j()}else r.removeEventListener("click",f.current);d.current=!1},w=window.setTimeout(()=>{r.addEventListener("pointerdown",n)},0);return()=>{window.clearTimeout(w),r.removeEventListener("pointerdown",n),r.removeEventListener("click",f.current)}},[r,i]),{onPointerDownCapture:()=>d.current=!0}}function Gb(s,r=globalThis==null?void 0:globalThis.document){const i=kl(s),d=g.useRef(!1);return g.useEffect(()=>{const f=n=>{n.target&&!d.current&&Pu(zb,i,{originalEvent:n},{discrete:!1})};return r.addEventListener("focusin",f),()=>r.removeEventListener("focusin",f)},[r,i]),{onFocusCapture:()=>d.current=!0,onBlurCapture:()=>d.current=!1}}function Rd(){const s=new CustomEvent(gl);document.dispatchEvent(s)}function Pu(s,r,i,{discrete:d}){const f=i.originalEvent.target,n=new CustomEvent(s,{bubbles:!1,cancelable:!0,detail:i});r&&f.addEventListener(s,r,{once:!0}),d?ix(f,n):f.dispatchEvent(n)}var nl=0;function Xb(){g.useEffect(()=>{const s=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",s[0]??Md()),document.body.insertAdjacentElement("beforeend",s[1]??Md()),nl++,()=>{nl===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(r=>r.remove()),nl--}},[])}function Md(){const s=document.createElement("span");return s.setAttribute("data-radix-focus-guard",""),s.tabIndex=0,s.style.outline="none",s.style.opacity="0",s.style.position="fixed",s.style.pointerEvents="none",s}var Tl="Popper",[Iu,$u]=ou(Tl),[Yb,Lu]=Iu(Tl),Ru=s=>{const{__scopePopper:r,children:i}=s,[d,f]=g.useState(null);return t.jsx(Yb,{scope:r,anchor:d,onAnchorChange:f,children:i})};Ru.displayName=Tl;var Mu="PopperAnchor",Ou=g.forwardRef((s,r)=>{const{__scopePopper:i,virtualRef:d,...f}=s,n=Lu(Mu,i),w=g.useRef(null),y=_s(r,w),j=g.useRef(null);return g.useEffect(()=>{const k=j.current;j.current=(d==null?void 0:d.current)||w.current,k!==j.current&&n.onAnchorChange(j.current)}),d?null:t.jsx(An.div,{...f,ref:y})});Ou.displayName=Mu;var Pl="PopperContent",[Jb,Zb]=Iu(Pl),_u=g.forwardRef((s,r)=>{var pt,R,ke,Fe,P,aa;const{__scopePopper:i,side:d="bottom",sideOffset:f=0,align:n="center",alignOffset:w=0,arrowPadding:y=0,avoidCollisions:j=!0,collisionBoundary:k=[],collisionPadding:T=0,sticky:I="partial",hideWhenDetached:p=!1,updatePositionStrategy:N="optimized",onPlaced:M,...$}=s,_=Lu(Pl,i),[Q,G]=g.useState(null),ie=_s(r,Ut=>G(Ut)),[ne,V]=g.useState(null),H=lx(ne),W=(H==null?void 0:H.width)??0,U=(H==null?void 0:H.height)??0,pe=d+(n!=="center"?"-"+n:""),Y=typeof T=="number"?T:{top:0,right:0,bottom:0,left:0,...T},K=Array.isArray(k)?k:[k],Le=K.length>0,Je={padding:Y,boundary:K.filter(tp),altBoundary:Le},{refs:Ae,floatingStyles:O,placement:D,isPositioned:Z,middlewareData:J}=ox({strategy:"fixed",placement:pe,whileElementsMounted:(...Ut)=>bx(...Ut,{animationFrame:N==="always"}),elements:{reference:_.anchor},middleware:[cx({mainAxis:f+U,alignmentAxis:w}),j&&dx({mainAxis:!0,crossAxis:!1,limiter:I==="partial"?xx():void 0,...Je}),j&&ux({...Je}),mx({...Je,apply:({elements:Ut,rects:Sn,availableWidth:vr,availableHeight:Cn})=>{const{width:ct,height:ra}=Sn.reference,Vt=Ut.floating.style;Vt.setProperty("--radix-popper-available-width",`${vr}px`),Vt.setProperty("--radix-popper-available-height",`${Cn}px`),Vt.setProperty("--radix-popper-anchor-width",`${ct}px`),Vt.setProperty("--radix-popper-anchor-height",`${ra}px`)}}),ne&&hx({element:ne,padding:y}),sp({arrowWidth:W,arrowHeight:U}),p&&fx({strategy:"referenceHidden",...Je})]}),[He,z]=Bu(D),oe=kl(M);fr(()=>{Z&&(oe==null||oe())},[Z,oe]);const xe=(pt=J.arrow)==null?void 0:pt.x,ge=(R=J.arrow)==null?void 0:R.y,Ze=((ke=J.arrow)==null?void 0:ke.centerOffset)!==0,[Ct,Et]=g.useState();return fr(()=>{Q&&Et(window.getComputedStyle(Q).zIndex)},[Q]),t.jsx("div",{ref:Ae.setFloating,"data-radix-popper-content-wrapper":"",style:{...O,transform:Z?O.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Ct,"--radix-popper-transform-origin":[(Fe=J.transformOrigin)==null?void 0:Fe.x,(P=J.transformOrigin)==null?void 0:P.y].join(" "),...((aa=J.hide)==null?void 0:aa.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:s.dir,children:t.jsx(Jb,{scope:i,placedSide:He,onArrowChange:V,arrowX:xe,arrowY:ge,shouldHideArrow:Ze,children:t.jsx(An.div,{"data-side":He,"data-align":z,...$,ref:ie,style:{...$.style,animation:Z?void 0:"none"}})})})});_u.displayName=Pl;var Du="PopperArrow",ep={top:"bottom",right:"left",bottom:"top",left:"right"},Fu=g.forwardRef(function(r,i){const{__scopePopper:d,...f}=r,n=Zb(Du,d),w=ep[n.placedSide];return t.jsx("span",{ref:n.onArrowChange,style:{position:"absolute",left:n.arrowX,top:n.arrowY,[w]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[n.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[n.placedSide],visibility:n.shouldHideArrow?"hidden":void 0},children:t.jsx(px,{...f,ref:i,style:{...f.style,display:"block"}})})});Fu.displayName=Du;function tp(s){return s!==null}var sp=s=>({name:"transformOrigin",options:s,fn(r){var _,Q,G;const{placement:i,rects:d,middlewareData:f}=r,w=((_=f.arrow)==null?void 0:_.centerOffset)!==0,y=w?0:s.arrowWidth,j=w?0:s.arrowHeight,[k,T]=Bu(i),I={start:"0%",center:"50%",end:"100%"}[T],p=(((Q=f.arrow)==null?void 0:Q.x)??0)+y/2,N=(((G=f.arrow)==null?void 0:G.y)??0)+j/2;let M="",$="";return k==="bottom"?(M=w?I:`${p}px`,$=`${-j}px`):k==="top"?(M=w?I:`${p}px`,$=`${d.floating.height+j}px`):k==="right"?(M=`${-j}px`,$=w?I:`${N}px`):k==="left"&&(M=`${d.floating.width+j}px`,$=w?I:`${N}px`),{data:{x:M,y:$}}}});function Bu(s){const[r,i="center"]=s.split("-");return[r,i]}var np=Ru,Uu=Ou,ap=_u,rp=Fu;function ip(s,r){return g.useReducer((i,d)=>r[i][d]??i,s)}var Il=s=>{const{present:r,children:i}=s,d=lp(r),f=typeof i=="function"?i({present:d.isPresent}):g.Children.only(i),n=_s(d.ref,op(f));return typeof i=="function"||d.isPresent?g.cloneElement(f,{ref:n}):null};Il.displayName="Presence";function lp(s){const[r,i]=g.useState(),d=g.useRef(null),f=g.useRef(s),n=g.useRef("none"),w=s?"mounted":"unmounted",[y,j]=ip(w,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return g.useEffect(()=>{const k=ir(d.current);n.current=y==="mounted"?k:"none"},[y]),fr(()=>{const k=d.current,T=f.current;if(T!==s){const p=n.current,N=ir(k);s?j("MOUNT"):N==="none"||(k==null?void 0:k.display)==="none"?j("UNMOUNT"):j(T&&p!==N?"ANIMATION_OUT":"UNMOUNT"),f.current=s}},[s,j]),fr(()=>{if(r){let k;const T=r.ownerDocument.defaultView??window,I=N=>{const $=ir(d.current).includes(CSS.escape(N.animationName));if(N.target===r&&$&&(j("ANIMATION_END"),!f.current)){const _=r.style.animationFillMode;r.style.animationFillMode="forwards",k=T.setTimeout(()=>{r.style.animationFillMode==="forwards"&&(r.style.animationFillMode=_)})}},p=N=>{N.target===r&&(n.current=ir(d.current))};return r.addEventListener("animationstart",p),r.addEventListener("animationcancel",I),r.addEventListener("animationend",I),()=>{T.clearTimeout(k),r.removeEventListener("animationstart",p),r.removeEventListener("animationcancel",I),r.removeEventListener("animationend",I)}}else j("ANIMATION_END")},[r,j]),{isPresent:["mounted","unmountSuspended"].includes(y),ref:g.useCallback(k=>{d.current=k?getComputedStyle(k):null,i(k)},[])}}function ir(s){return(s==null?void 0:s.animationName)||"none"}function op(s){var d,f;let r=(d=Object.getOwnPropertyDescriptor(s.props,"ref"))==null?void 0:d.get,i=r&&"isReactWarning"in r&&r.isReactWarning;return i?s.ref:(r=(f=Object.getOwnPropertyDescriptor(s,"ref"))==null?void 0:f.get,i=r&&"isReactWarning"in r&&r.isReactWarning,i?s.props.ref:s.props.ref||s.ref)}var yr="Popover",[Vu,W0]=ou(yr,[$u]),na=$u(),[cp,fs]=Vu(yr),Hu=s=>{const{__scopePopover:r,children:i,open:d,defaultOpen:f,onOpenChange:n,modal:w=!1}=s,y=na(r),j=g.useRef(null),[k,T]=g.useState(!1),[I,p]=gx({prop:d,defaultProp:f??!1,onChange:n,caller:yr});return t.jsx(np,{...y,children:t.jsx(cp,{scope:r,contentId:yx(),triggerRef:j,open:I,onOpenChange:p,onOpenToggle:g.useCallback(()=>p(N=>!N),[p]),hasCustomAnchor:k,onCustomAnchorAdd:g.useCallback(()=>T(!0),[]),onCustomAnchorRemove:g.useCallback(()=>T(!1),[]),modal:w,children:i})})};Hu.displayName=yr;var qu="PopoverAnchor",dp=g.forwardRef((s,r)=>{const{__scopePopover:i,...d}=s,f=fs(qu,i),n=na(i),{onCustomAnchorAdd:w,onCustomAnchorRemove:y}=f;return g.useEffect(()=>(w(),()=>y()),[w,y]),t.jsx(Uu,{...n,...d,ref:r})});dp.displayName=qu;var zu="PopoverTrigger",Qu=g.forwardRef((s,r)=>{const{__scopePopover:i,...d}=s,f=fs(zu,i),n=na(i),w=_s(r,f.triggerRef),y=t.jsx(An.button,{type:"button","aria-haspopup":"dialog","aria-expanded":f.open,"aria-controls":f.contentId,"data-state":Ju(f.open),...d,ref:w,onClick:hs(s.onClick,f.onOpenToggle)});return f.hasCustomAnchor?y:t.jsx(Uu,{asChild:!0,...n,children:y})});Qu.displayName=zu;var $l="PopoverPortal",[up,mp]=Vu($l,{forceMount:void 0}),Wu=s=>{const{__scopePopover:r,forceMount:i,children:d,container:f}=s,n=fs($l,r);return t.jsx(up,{scope:r,forceMount:i,children:t.jsx(Il,{present:i||n.open,children:t.jsx(wx,{asChild:!0,container:f,children:d})})})};Wu.displayName=$l;var jn="PopoverContent",Ku=g.forwardRef((s,r)=>{const i=mp(jn,s.__scopePopover),{forceMount:d=i.forceMount,...f}=s,n=fs(jn,s.__scopePopover);return t.jsx(Il,{present:d||n.open,children:n.modal?t.jsx(fp,{...f,ref:r}):t.jsx(xp,{...f,ref:r})})});Ku.displayName=jn;var hp=jx("PopoverContent.RemoveScroll"),fp=g.forwardRef((s,r)=>{const i=fs(jn,s.__scopePopover),d=g.useRef(null),f=_s(r,d),n=g.useRef(!1);return g.useEffect(()=>{const w=d.current;if(w)return vx(w)},[]),t.jsx(Nx,{as:hp,allowPinchZoom:!0,children:t.jsx(Gu,{...s,ref:f,trapFocus:i.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:hs(s.onCloseAutoFocus,w=>{var y;w.preventDefault(),n.current||(y=i.triggerRef.current)==null||y.focus()}),onPointerDownOutside:hs(s.onPointerDownOutside,w=>{const y=w.detail.originalEvent,j=y.button===0&&y.ctrlKey===!0,k=y.button===2||j;n.current=k},{checkForDefaultPrevented:!1}),onFocusOutside:hs(s.onFocusOutside,w=>w.preventDefault(),{checkForDefaultPrevented:!1})})})}),xp=g.forwardRef((s,r)=>{const i=fs(jn,s.__scopePopover),d=g.useRef(!1),f=g.useRef(!1);return t.jsx(Gu,{...s,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:n=>{var w,y;(w=s.onCloseAutoFocus)==null||w.call(s,n),n.defaultPrevented||(d.current||(y=i.triggerRef.current)==null||y.focus(),n.preventDefault()),d.current=!1,f.current=!1},onInteractOutside:n=>{var j,k;(j=s.onInteractOutside)==null||j.call(s,n),n.defaultPrevented||(d.current=!0,n.detail.originalEvent.type==="pointerdown"&&(f.current=!0));const w=n.target;((k=i.triggerRef.current)==null?void 0:k.contains(w))&&n.preventDefault(),n.detail.originalEvent.type==="focusin"&&f.current&&n.preventDefault()}})}),Gu=g.forwardRef((s,r)=>{const{__scopePopover:i,trapFocus:d,onOpenAutoFocus:f,onCloseAutoFocus:n,disableOutsidePointerEvents:w,onEscapeKeyDown:y,onPointerDownOutside:j,onFocusOutside:k,onInteractOutside:T,...I}=s,p=fs(jn,i),N=na(i);return Xb(),t.jsx(kx,{asChild:!0,loop:!0,trapped:d,onMountAutoFocus:f,onUnmountAutoFocus:n,children:t.jsx(Tu,{asChild:!0,disableOutsidePointerEvents:w,onInteractOutside:T,onEscapeKeyDown:y,onPointerDownOutside:j,onFocusOutside:k,onDismiss:()=>p.onOpenChange(!1),children:t.jsx(ap,{"data-state":Ju(p.open),role:"dialog",id:p.contentId,...N,...I,ref:r,style:{...I.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),Xu="PopoverClose",Yu=g.forwardRef((s,r)=>{const{__scopePopover:i,...d}=s,f=fs(Xu,i);return t.jsx(An.button,{type:"button",...d,ref:r,onClick:hs(s.onClick,()=>f.onOpenChange(!1))})});Yu.displayName=Xu;var bp="PopoverArrow",pp=g.forwardRef((s,r)=>{const{__scopePopover:i,...d}=s,f=na(i);return t.jsx(rp,{...f,...d,ref:r})});pp.displayName=bp;function Ju(s){return s?"open":"closed"}var gp=Hu,yp=Qu,wp=Wu,vp=Ku,Np=Yu;function Zu({enabled:s,loading:r,saving:i,error:d,toggleId:f,onToggle:n,onRetry:w,isDark:y,tr:j}){const k=r||i,T=k||!!d,I=k?j("טוען","Loading"):d?j("לא זמין","Unavailable"):s?j("פעילה","Running"):j("מושהית","Stopped");return t.jsxs("div",{className:m("flex min-h-11 items-center gap-3 rounded-xl px-3 py-2 text-sm font-medium",y?"text-white/80":"text-slate-700"),"aria-live":"polite",children:[t.jsx("span",{className:m("grid h-8 w-8 shrink-0 place-items-center rounded-lg ring-1 ring-inset",y?"bg-white/[0.045] text-amber-100/75 ring-white/[0.06]":"bg-
147amber-50 text-amber-800 ring-amber-900/[0.07]"),"aria-hidden":"true",children:t.jsx(tb,{className:"h-[1.05rem] w-[1.05rem]"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate",children:j("תוכנית","Program")}),t.jsx("span",{className:m("block text-[0.68rem] font-medium",y?"text-white/55":"text-slate-500"),children:I})]}),d?t.jsxs("button",{type:"button",onClick:w,className:m("inline-flex min-h-11 items-center gap-1.5 rounded-lg px-2.5 text-xs font-semibold transition-colors motion-reduce:transition-none","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400/70",y?"bg-white/[0.06] text-white/70 hover:bg-white/[0.1] hover:text-white":"bg-slate-100 text-slate-600 hover:bg-slate-200 hover:text-slate-900"),"aria-label":j("נסה שוב לטעון את מצב התוכנית","Retry loading program status"),children:[t.jsx(Bt,{className:"h-3.5 w-3.5","aria-hidden":"true"}),j("נסה שוב","Retry")]}):t.jsxs("label",{className:m("relative inline-flex h-11 w-14 shrink-0 items-center justify-center rounded-xl",T?"cursor-wait opacity-60":"cursor-pointer"),dir:"ltr",title:s?j("הפסק תוכנית","Stop Program"):j("הפעל תוכנית","Start Program"),children:[t.jsx("input",{id:f,type:"checkbox",className:"peer sr-only",checked:!!s,onChange:n,disabled:T,"aria-label":s?j("הפסק תוכנית","Stop Program"):j("הפעל תוכנית","Start Program"),"aria-busy":k}),t.jsx("span",{className:m("pointer-events-none absolute left-1.5 top-2.5 h-6 w-11 rounded-full transition-colors motion-reduce:transition-none","peer-focus-visible:ring-2 peer-focus-visible:ring-emerald-400/70 peer-focus-visible:ring-offset-2",y?"peer-focus-visible:ring-offset-[#1C1F22]":"peer-focus-visible:ring-offset-white",s?"bg-emerald-500":y?"bg-white/15":"bg-slate-300"),"aria-hidden":"true"}),t.jsx("span",{className:m("pointer-events-none absolute left-2.5 top-3.5 h-4 w-4 rounded-full bg-white shadow-sm transition-transform motion-reduce:transition-none",s&&"translate-x-5"),"aria-hidden":"true"}),k?t.jsx(Bt,{className:"pointer-events-none absolute left-1/2 top-1/2 h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 animate-spin text-white motion-reduce:animate-none","aria-hidden":"true"}):null]})]})}
147Zu.propTypes={enabled:S.bool.isRequired,loading:S.bool.isRequired,saving:S.bool.isRequired,error:S.oneOfType([S.instanceOf(Error),S.object,S.string]),toggleId:S.string.isRequired,onToggle:S.func.isRequired,onRetry:S.func.isRequired,isDark:S.bool.isRequired,tr:S.func.isRequired};function em({open:s,onOpenChange:r,user:i,userDisplayName:d,userAvatarUrl:f,language:n,isDark:w,t:y,tr:j,onOpenSettings:k,onLogout:T,triggerRef:I}){const p=n==="HE",N=m("group flex min-h-12 w-full items-center gap-3 rounded-xl px-3 py-2.5 text-start text-sm font-semibold transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-200/70"),M=m("grid h-9 w-9 shrink-0 place-items-center rounded-lg ring-1 ring-inset transition-colors",w?"bg-white/[0.045] text-amber-100/75 ring-white/[0.06] group-hover:bg-white/[0.08] group-hover:text-amber-100":"bg-amber-50 text-amber-800 ring-amber-900/[0.07] group-hover:bg-amber-100");return t.jsxs(gp,{open:s,onOpenChange:r,children:[t.jsx(yp,{asChild:!0,children:t.jsx("button",{ref:I,type:"button",className:m("h-16 w-16 rounded-full border-0 bg-transparent p-0 shadow-md transition-transform duration-200 ease-out hover:scale-[1.02]","focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2",w?"focus-visible:outline-amber-100/80":"focus-visible:outline-amber-900/55"),style:{backgroundImage:`url(${cu})`,backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundSize:"132% 132%"},title:j("אלפא","ALFA"),"aria-label":j("אלפא","ALFA"),children:t.jsx("span",{className:"sr-only",children:j("אלפא","ALFA")})})}),t.jsx(wp,{children:t.jsxs(vp,{side:"bottom",align:p?"start":"end",sideOffset:12,collisionPadding:16,"aria-label":j("תפריט משתמש","User menu"),className:m("z-[80] w-[min(22rem,calc(100vw-2rem))] overflow-hidden rounded-2xl border backdrop-blur-xl","shadow-[0_28px_80px_rgba(0,0,0,0.5)] outline-none","data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95","data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",w?"border-white/10 bg-[#181B1F]/[0.98] text-gray-100":"border-slate-200 bg-white/[0.98] text-slate-900 shadow-[0_28px_80px_rgba(15,23,42,0.18)]"),dir:p?"rtl":"ltr",children:[t.jsxs("div",{className:m("relative flex items-center gap-3 border-b px-4 py-3 pe-14",w?"border-white/[0.08] bg-white/[0.018]":"border-slate-200 bg-slate-50/80"),children:[t.jsx(Np,{asChild:!0,children:t.jsx("button",{type:"button",className:m("absolute end-2 top-2 grid h-11 w-11 place-items-center rounded-full transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-200/70",w?"text-white/45 hover:bg-white/[0.07] hover:text-white":"text-slate-400 hover:bg-slate-200/70 hover:text-slate-800"),"aria-label":j("סגור","Close"),children:t.jsx(ms,{className:"h-4 w-4","aria-hidden":"true"})})}),t.jsx("div",{className:m("flex h-12 w-12 shrink-0 items-center justify-center overflow-hidden rounded-full border shadow-sm",w?"border-amber-100/25 bg-white/[0.05]":"border-amber-700/20 bg-amber-50"),children:f?t.jsx("img",{src:f,alt:"",className:"h-full w-full object-cover"}):t.jsx(ml,{className:m("h-5 w-5",w?"text-white/55":"text-slate-500"),"aria-hidden":"true"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"truncate text-[0.95rem] font-semibold",dir:"auto",children:d}),i!=null&&i.isAdmin?t.jsx("span",{className:m("shrink-0 rounded-full px-2 py-0.5 text-[0.62rem] font-semibold uppercase tracking-wide",w?"bg-amber-200/10 text-amber-100/70":"bg-amber-100 text-amber-800"),children:j("מנהל","Admin")}):null]}),t.jsx("div",{className:m("mt-0.5 truncate text-xs font-medium",w?"text-white/42":"text-slate-500"),dir:"ltr",children:(i==null?void 0:i.email)||""})]})]}),t.jsxs("div",{className:"p-2",children:[t.jsxs("button",{type:"button",onClick:k,className:m(N,w?"text-white/80 hover:bg-white/[0.065] hover:text-white":"text-slate-700 hover:bg-slate-100 hover:text-slate-950"),"aria-label":y("Settings"),children:[t.jsx("span",{className:M,"aria-hidden":"true",children:t.jsx(ul,{className:"h-[1.05rem] w-[1.05rem]"})}),t.jsx("span",{className:"min-w-0 flex-1",children:y("Settings")}),t.jsx(pr,{className:m("h-4 w-4 shrink-0 opacity-35 transition-transform group-hover:translate-x-0.5 group-hover:opacity-65",p&&"rotate-180 group-hover:-translate-x-0.5"),"aria-hidden":"true"})]}),t.jsx("div",{className:m("mx-3 my-1 border-t",w?"border-white/[0.06]":"border-slate-200/80")}),t.jsxs("button",{type:"button",onClick:T,className:m(N,w?"text-rose-200/80 hover:bg-rose-400/[0.09] hover:text-rose-100":"text-rose-600 hover:bg-rose-50 hover:text-rose-700"),"aria-label":y("Logout"),children:[t.jsx("span",{className:m("grid h-9 w-9 shrink-0 place-items-center rounded-lg",w?"bg-rose-400/[0.08]":"bg-rose-100"),"aria-hidden":"true",children:t.jsx(fu,{className:"h-[1.05rem] w-[1.05rem]"})}),t.jsx("span",{className:"min-w-0 flex-1",children:y("Logout")})]})]})]})})]})}em.propTypes={open:S.bool.isRequired,onOpenChange:S.func.isRequired,user:S.shape({email:S.string,isAdmin:S.bool}),userDisplayName:S.string.isRequired,userAvatarUrl:S.string,language:S.string.isRequired,isDark:S.bool.isRequired,t:S.func.isRequired,tr:S.func.isRequired,onOpenSettings:S.func.isRequired,onLogout:S.func.isRequired,triggerRef:S.oneOfType([S.func,S.shape({current:S.any})])};const tm={General:{Icon:hu,group:"account"},Accounts:{Icon:yu,group:"account"},"Graph Settings":{Icon:sa,group:"trading"},Alerts:{Icon:Al,group:"trading"},Language:{Icon:du,group:"preferences"},Theme:{Icon:Sl,group:"preferences"},Downloads:{Icon:yn,group:"system"},System:{Icon:uu,group:"system"}},jp=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not
147([tabindex="-1"])'].join(",");function mr({item:s,active:r,compact:i,isDark:d,isRtl:f,onSelect:n,visuals:w}){var k;const y=((k=tm[s.tab])==null?void 0:k.Icon)??hu,j=f?mu:pr;return t.jsxs("button",{type:"button",onClick:()=>n(s),className:m("group flex w-full items-center gap-3 rounded-lg px-3 text-start",w.motion,"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400/60",i?"min-h-[64px] py-2.5":"min-h-10 py-2",r?d?"bg-white/[0.07] text-white":"bg-slate-200/70 text-slate-950":d?"text-white/60 hover:bg-white/[0.035] hover:text-white":"text-slate-600 hover:bg-slate-100 hover:text-slate-950"),"aria-current":r?"page":void 0,children:[t.jsx("span",{className:m("grid h-6 w-6 shrink-0 place-items-center",w.iconWell,w.motion,r?d?"text-amber-100/85":"text-amber-800":d?"text-white/45 group-hover:text-white/70":"text-slate-400 group-hover:text-slate-600"),"aria-hidden":"true",children:t.jsx(y,{className:"h-[1.05rem] w-[1.05rem]"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium",children:s.label}),i&&s.description?t.jsx("span",{className:m("mt-0.5 block truncate text-xs font-medium",d?"text-white/[0.52]":"text-slate-500"),children:s.description}):null]}),i?t.jsx(j,{className:m("h-4 w-4 shrink-0",w.motion,r?"opacity-65":"opacity-25 group-hover:opacity-55"),"aria-hidden":"true"}):null]})}mr.propTypes={item:S.shape({tab:S.string.isRequired,label:S.string.isRequired,description:S.string}).isRequired,active:S.bool.isRequired,compact:S.bool,isDark:S.bool.isRequired,isRtl:S.bool.isRequired,onSelect:S.func.isRequired,visuals:S.object.isRequired};function sm({isCompact:s,isDark:r,language:i,title:d,searchValue:f,searchMatches:n,items:w,activeTab:y,onSearchChange:j,onMatchSelect:k,onTabSelect:T,onClose:I,tr:p,contentStyle:N,error:M,children:$}){const _=i==="HE",Q=g.useRef(null),G=g.useRef(null),[ie,ne]=g.useState(!!s),V=w.find(O=>O.tab===y)??w[0],H=g.useMemo(()=>gr(r),[r]),W=g.useMemo(()=>[{key:"account",label:p("חשבון","Account")},{key:"trading",label:p("מסחר","Trading")},{key:"preferences",label:p("העדפות","Preferences")},{key:"system",label:p("מערכת","System")}].map(O=>({...O,items:w.filter(D=>{var Z;return(((Z=tm[D.tab])==null?void 0:Z.group)??"account")===O.key})})).filter(O=>O.items.length>0),[w,p]),U=f.trim()?n:w,pe={...N,scrollbarWidth:"thin",scrollbarColor:r?"rgba(148, 163, 184, 0.28) transparent":"rgba(100, 116, 139, 0.32) transparent"};g.useEffect(()=>{G.current=document.activeElement;const O=document.body.style.overflow;document.body.style.overflow="hidden";const D=window.requestAnimationFrame(()=>{var Z;return(Z=Q.current)==null?void 0:Z.focus()});return()=>{var Z,J;window.cancelAnimationFrame(D),document.body.style.overflow=O,(J=(Z=G.current)==null?void 0:Z.focus)==null||J.call(Z)}},[]);const Y=O=>{var He;if(O.key==="Escape"){O.preventDefault(),I();return}if(O.key!=="Tab")return;const D=Array.from(((He=Q.current)==null?void 0:He.querySelectorAll(jp))??[]).filter(z=>!z.hasAttribute("hidden")&&z.getAttribute("aria-hidden")!=="true");if(!D.length){O.preventDefault();return}const Z=D[0],J=D[D.length-1];O.shiftKey&&document.activeElement===Z?(O.preventDefault(),J.focus()):!O.shiftKey&&document.activeElement===J&&(O.preventDefault(),Z.focus())},K=O=>{T(O),s&&ne(!1)},Le=O=>{k(O),s&&ne(!1)},Je=(O=!1)=>t.jsxs("div",{className:m("relative",O?"w-full":"w-full max-w-[18rem]"),children:[t.jsx("label",{htmlFor:O?"crm-settings-search-mobile":"crm-settings-search",className:"sr-only",children:p("חיפוש בהגדרות","Search settings")}),t.jsx(bu,{className:m("pointer-events-none absolute top-1/2 h-4 w-4 -translate-y-1/2",_?"right-3.5":"left-3.5",r?"text-white/[0.38]":"text-slate-400"),"aria-hidden":"true"}),t.jsx("input",{id:O?"crm-settings-search-mobile":"crm-settings-search",type:"search",role:"combobox","aria-autocomplete":"list","aria-expanded":!!f.trim(),"aria-controls":O?"crm-settings-mobile-results":"crm-settings-search-results",value:f,onChange:j,placeholder:p("חיפוש בהגדרות...","Search settings..."),className:m("h-10 w-full border text-sm outline-none",_?"pr-10 pl-4 text-right":"pl-10 pr-4 text-left",H.searchField)}),!O&&f.trim()?t.jsx("div",{id:"crm-settings-search-results",role:"listbox",className:m("absolute top-full z-40 mt-2 max-h-72 w-full overflow-y-auto rounded-lg border p-1",H.searchResults),children:n.length?n.map(D=>t.jsxs("button",{type:"button",role:"option","aria-selected":D.tab===y,onClick:()=>Le(D),className:m("flex min-h-12 w-full items-center gap-3 rounded-xl px-3 py-2 text-start",H.motion,"focu
147s-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400/55",r?"hover:bg-white/[0.06]":"hover:bg-slate-50"),children:[t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-semibold",children:D.label}),D.description?t.jsx("span",{className:m("mt-0.5 block truncate text-xs",r?"text-white/[0.52]":"text-slate-500"),children:D.description}):null]}),_?t.jsx(mu,{className:"h-4 w-4 opacity-35"}):t.jsx(pr,{className:"h-4 w-4 opacity-35"})]},`${D.tab}-${D.targetId}`)):t.jsx("div",{className:m("px-3 py-4 text-center text-sm",r?"text-white/[0.52]":"text-slate-500"),children:p("לא נמצאו הגדרות מתאימות","No matching settings")})}):null]}),Ae=_?Cx:Tx;return t.jsx("div",{className:m("fixed inset-0 z-[90] flex items-center justify-center",s?"p-0":m("px-4 py-6 sm:px-6 lg:py-8","motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-200 motion-reduce:animate-none",H.overlay)),onMouseDown:O=>{O.target===O.currentTarget&&!s&&I()},children:t.jsxs("section",{ref:Q,role:"dialog","aria-modal":"true","aria-labelledby":"crm-settings-title","aria-describedby":"crm-settings-description",tabIndex:-1,dir:_?"rtl":"ltr",onKeyDown:Y,className:m("flex w-full flex-col overflow-hidden border outline-none","motion-safe:animate-in motion-safe:fade-in-0 motion-safe:zoom-in-95 motion-safe:duration-200 motion-reduce:animate-none",s?"h-[100dvh] rounded-none border-0":"h-[min(88dvh,46rem)] max-w-[64rem] rounded-2xl",H.shell),children:[t.jsxs("header",{className:m("relative z-30 shrink-0 border-b",H.header),children:[t.jsxs("div",{className:m("flex items-center gap-4",s?"min-h-16 px-4":"min-h-[4.5rem] px-6"),children:[s&&!ie?t.jsx("button",{type:"button",onClick:()=>ne(!0),className:m("grid h-11 w-11 shrink-0 place-items-center rounded-full",H.motion,"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400/60",r?"text-white/[0.65] hover:bg-white/[0.07] hover:text-white":"text-slate-500 hover:bg-slate-100 hover:text-slate-900"),"aria-label":p("חזרה לכל ההגדרות","Back to all settings"),children:t.jsx(Ae,{className:"h-[1.1rem] w-[1.1rem]","aria-hidden":"true"})}):null,t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h2",{id:"crm-settings-title",className:"truncate text-lg font-semibold",children:s&&!ie?V==null?void 0:V.label:d}),t.jsx("p",{id:"crm-settings-description",className:"sr-only",children:s&&ie?p("כל ההעדפות במקום אחד","All preferences in one place"):(V==null?void 0:V.description)??(V==null?void 0:V.label)})]}),s?null:Je(),t.jsx("button",{type:"button",onClick:I,className:m("grid h-11 w-11 shrink-0 place-items-center rounded-full",H.motion,"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400/60",r?"text-white/[0.62] hover:bg-white/[0.07] hover:text-white":"text-slate-500 hover:bg-slate-100 hover:text-slate-900"),"aria-label":p("סגור הגדרות","Close settings"),children:t.jsx(ms,{className:"h-[1.05rem] w-[1.05rem]","aria-hidden":"true"})})]}),s&&ie?t.jsx("div",{className:"px-4 pb-3",children:Je(!0)}):null]}),s&&ie?t.jsx("main",{id:"crm-settings-mobile-results",className:m("min-h-0 flex-1 overflow-y-auto px-4 py-5",H.content),style:pe,children:t.jsx("div",{className:"mx-auto max-w-xl space-y-5",children:f.trim()?t.jsxs("div",{children:[t.jsx("p",{className:m("mb-2 px-1 text-xs font-semibold",r?"text-white/[0.52]":"text-slate-500"),children:p("תוצאות חיפוש","Search results")}),U.length?t.jsx("div",{className:"space-y-1",children:U.map(O=>t.jsx(mr,{item:O,active:O.tab===y,compact:!0,isDark:r,isRtl:_,onSelect:Le,visuals:H},`mobile-search-${O.tab}`))}):t.jsx("div",{className:m("rounded-xl border px-4 py-8 text-center text-sm",r?"border-white/[0.07] text-white/[0.52]":"border-slate-200 text-slate-500"),children:p("לא נמצאו הגדרות מתאימות","No matching settings")})]}):W.map(O=>t.jsxs("div",{children:[t.jsx("p",{className:m("mb-2 px-1 text-xs font-semibold",r?"text-white/[0.52]":"text-slate-500"),children:O.label}),t.jsx("div",{className:"space-y-1",children:O.items.map(D=>t.jsx(mr,{item:D,active:D.tab===y,compact:!0,isDark:r,isRtl:_,onSelect:K,visual
147s:H},`mobile-${D.tab}`))})]},`mobile-group-${O.key}`))})}):t.jsxs("div",{className:"flex min-h-0 flex-1",children:[s?null:t.jsx("aside",{className:m("w-[13.5rem] shrink-0 overflow-y-auto border-r px-3 py-5",_&&"border-r-0 border-l",H.sidebar),style:pe,"aria-label":p("קטגוריות הגדרות","Settings categories"),children:t.jsx("div",{className:"space-y-5",children:W.map(O=>t.jsxs("div",{children:[t.jsx("p",{className:m("mb-2 px-3 text-xs font-medium",H.mutedText),children:O.label}),t.jsx("div",{className:"space-y-1",children:O.items.map(D=>t.jsx(mr,{item:D,active:D.tab===y,isDark:r,isRtl:_,onSelect:K,visuals:H},D.tab))})]},O.key))})}),t.jsx("main",{className:m("min-w-0 flex-1 overflow-y-auto",s?"px-4 py-5":"px-6 py-6 lg:px-8",H.content),style:pe,children:t.jsxs("div",{className:"mx-auto w-full max-w-[50rem]",children:[s?null:t.jsx("div",{className:"mb-6",children:t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{className:"truncate text-lg font-semibold",children:V==null?void 0:V.label}),t.jsx("p",{className:m("mt-0.5 truncate text-sm",r?"text-white/[0.52]":"text-slate-500"),children:V==null?void 0:V.description})]})}),M?t.jsx("div",{className:m("mb-4 rounded-xl border px-4 py-3 text-sm",r?"border-rose-300/15 bg-rose-300/[0.07] text-rose-100":"border-rose-200 bg-rose-50 text-rose-700"),role:"alert",children:M}):null,$]})})]})]})})}sm.propTypes={isCompact:S.bool.isRequired,isDark:S.bool.isRequired,language:S.string.isRequired,title:S.string.isRequired,searchValue:S.string.isRequired,searchMatches:S.arrayOf(S.shape({tab:S.string.isRequired,targetId:S.string.isRequired,label:S.string.isRequired,description:S.string})).isRequired,items:S.arrayOf(S.shape({tab:S.string.isRequired,targetId:S.string.isRequired,label:S.string.isRequired,description:S.string})).isRequired,activeTab:S.string.isRequired,onSearchChange:S.func.isRequired,onMatchSelect:S.func.isRequired,onTabSelect:S.func.isRequired,onClose:S.func.isRequired,tr:S.func.isRequired,contentStyle:S.object,error:S.oneOfType([S.string,S.node]),children:S.node.isRequired};function nm({tr:s,isDark:r=!1}){const i=Hf(),d=g.useId(),[f,n]=g.useState(!1),w=[["smooth",s("סמן חלק","Smooth cursor"),s("הסמן הקיים באתר","The existing site cursor")],["system",s("סמן רגיל","System cursor"),s("ברירת המחדל של המכשיר","Your device’s default cursor")],["target","Target Cursor",s("סמן מסגרת שמתמקד בכפתורים","Corners that frame interactive controls")]];return t.jsxs("section",{className:"alfa-fx-cursor-settings alfa-fx-card","data-dark":r,"aria-labelledby":`${d}-title`,children:[t.jsx("h4",{id:`${d}-title`,children:s("סמן העכבר","Mouse cursor")}),t.jsx("p",{children:s("בחירה אישית ל־CRM בלבד. השינוי מיידי ונשמר במכשיר הזה.","A personal CRM-only preference. Changes apply immediately and are saved on this device.")}),t.jsxs("fieldset",{className:"alfa-fx-cursor-options",children:[t.jsx("legend",{className:"alfa-fx-sr-only",children:s("בחירת סמן","Choose a cursor")}),w.map(([y,j,k])=>t.jsxs("label",{"data-selected":i===y,children:[t.jsx("input",{type:"radio",name:`cursor-${d}`,value:y,checked:i===y,onChange:()=>n(!qf(y).persisted)}),t.jsxs("span",{children:[t.jsx("strong",{children:j}),t.jsx("small",{children:k})]})]},y))]}),t.jsx("p",{className:"alfa-fx-cursor-note",children:s("במסכי מגע, בהפחתת תנועה, בשדות כתיבה ובגרירה נשמרת התנהגות הסמן הרגילה.","Touch devices, reduced motion, text editing and dragging retain native pointer behavior.")}),f?t.jsx("p",{role:"status",children:s("ההעדפה חלה כעת, אך הדפדפן חסם את שמירתה.","The preference is active, but the browser blocked saving it.")}):null]})}nm.propTypes={tr:S.func.isRequired,isDark:S.bool};function am({themeMode:s,onThemeModeChange:r,onSaveDefault:i,saving:d,saved:f,error:n,isDark:w,tr:y}){const j=gr(w),k=[{value:"dark",label:y("כהה","Dark"),description:y("ניגודיות רגועה לעבודה ממושכת","Comfortable contrast for longer sessions"),Icon:Sl},{value:"light",label:y("בהירה","Light"),description:y("מראה נקי ובהיר לסביבה מוארת","A clean look for brighter environments"),Icon:pu}],T=(I,p)=>{var $,_,Q;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(I.key))return;I.preventDefault();const N=I.key==="ArrowLeft"||I.key==="ArrowUp"?-1:1,M=(p+N+k.length)%k.length;r(k[M].value),(Q=(_=($=I.currentTarget.parentElement)==null?void 0:$.querySelectorAll('[role="radio"]'))==null?void 0:_[M])==null||Q.focus()};return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("section",{className:m("overflow-hidden",j.card),children:[t.jsxs("div",{className:"px-5 py-5 sm:px-6",children:[t.jsx("h4",{className:"text-base font-semibold",children:y("מראה הממשק","Interface appearance")}),t.jsx("p",{className:m("mt-1.5 max-w-2xl text-sm leading-6",j.mutedText),children:y("בחרו את המראה שנוח לכם. השינוי חל מיד ונשמר במכשיר הזה.","Choose the appearance that feels right. Changes apply immediately and are saved on this device.")})]}),t.jsx("div",{role:"radiogroup","aria-label":y("בחירת ערכת נושא","Theme selection"),className:m("grid gap-3 border-t p-4 sm:grid-cols-2 sm:p-5",w?"border-white/10":"border-slate-200"),children:k.map(({value:I,label:p,description:N,Icon:M},$)=>{const _=s===I;return t.jsxs("button",{type:"button",role:"radio","aria-checked":_,tabIndex:_?0:-1,onClick:()=>r(I),onKeyDown:Q=>T(Q,$),className:m("group flex min-h-[82px] items-center gap-3 px-4 py-3.5 text-start",j.row,j.interactiveRow,"focu
147s-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400/60",_?w?"border-emerald-400/50 bg-emerald-400/[0.05] text-white":"border-emerald-600/50 bg-emerald-50/50 text-slate-950":w?"text-white/[0.74] hover:text-white":"text-slate-700 hover:text-slate-950"),children:[t.jsx("span",{className:m("grid h-7 w-7 shrink-0 place-items-center",j.iconWell,j.motion,_?w?"text-emerald-300":"text-emerald-700":null),"aria-hidden":"true",children:t.jsx(M,{className:"h-[1.15rem] w-[1.15rem]"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block text-sm font-semibold",children:p}),t.jsx("span",{className:m("mt-1 block text-xs leading-5",j.mutedText),children:N})]}),t.jsx("span",{className:m("grid h-5 w-5 shrink-0 place-items-center rounded-full border",j.motion,_?"border-emerald-600 bg-emerald-600 text-white":w?"border-white/20 text-transparent":"border-slate-300 text-transparent"),"aria-hidden":"true",children:t.jsx(ta,{className:"h-3.5 w-3.5"})})]},I)})})]}),t.jsx(nm,{tr:y,isDark:w}),t.jsxs("section",{className:m("flex flex-col gap-4 px-5 py-4 sm:flex-row sm:items-center sm:justify-between sm:px-6 sm:py-5",j.card),children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h4",{className:"text-sm font-semibold",children:y("העדפת החשבון","Account preference")}),t.jsx("p",{className:m("mt-1 text-xs leading-5",j.mutedText),children:y("שמרו את הבחירה כדי להשתמש בה כברירת המחדל בכל כניסה.","Save this choice as the default for future sign-ins.")}),t.jsx("div",{className:"mt-2 min-h-5 text-xs font-semibold","aria-live":"polite",children:d?t.jsx("span",{className:j.mutedText,children:y("שומר...","Saving...")}):f?t.jsxs("span",{className:m("inline-flex items-center gap-1.5",w?"text-emerald-300":"text-emerald-700"),children:[t.jsx(ta,{className:"h-3.5 w-3.5","aria-hidden":"true"}),y("נשמר","Saved")]}):null})]}),t.jsxs("button",{type:"button",onClick:i,disabled:d,className:m("inline-flex min-h-11 shrink-0 items-center justify-center gap-2 rounded-lg px-4 text-sm font-medium",j.primaryAction,"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400/65 focu
147s-visible:ring-offset-2",w?"focus-visible:ring-offset-[#171A1D]":"focus-visible:ring-offset-white",d&&"cursor-wait opacity-60"),children:[t.jsx(nb,{className:"h-4 w-4","aria-hidden":"true"}),d?y("שומר...","Saving..."):y("שמור כברירת מחדל","Save as default")]})]}),n?t.jsx("div",{className:m("rounded-lg border px-4 py-3 text-sm",j.motion,w?"border-rose-400/20 bg-rose-400/[0.05] text-rose-300":"border-rose-200 bg-rose-50 text-rose-700"),role:"alert",children:n}):null]})}am.propTypes={themeMode:S.oneOf(["dark","light"]).isRequired,onThemeModeChange:S.func.isRequired,onSaveDefault:S.func.isRequired,saving:S.bool.isRequired,saved:S.bool.isRequired,error:S.oneOfType([S.string,S.node]),isDark:S.bool.isRequired,tr:S.func.isRequired};const ae=Object.freeze({CLOSED:"closed",COMPACT:"compact",EXPANDED:"expanded",DOCKED:"docked"});function kp(s){return s===ae.DOCKED||s===ae.CLOSED?s:ae.COMPACT}function Ap(s){return s===ae.COMPACT||s===ae.DOCKED||s===ae.CLOSED}function Sp(s){return s===ae.DOCKED||s===ae.COMPACT}function Cp(s){return s===ae.EXPANDED?ae.COMPACT:ae.DOCKED}const al="crm-chat-conversation",Od="crm-chat-title",_d="crm-chat-compact-menu";function yl({count:s=0,label:r}){return s?t.jsx("span",{className:"absolute -end-1 -top-1 grid min-h-5 min-w-5 place-items-center rounded-full bg-rose-500 px-1 text-[10px] font-bold leading-none text-white shadow-sm","aria-label":`${s} ${r}`,children:s>9?"9+":s}):null}yl.propTypes={count:S.number,label:S.string.isRequired};function rm({mode:s,onModeChange:r,isCompact:i,isDark:d,language:f,draft:n,onDraftChange:w,onSend:y,onDraftKeyDown:j,messages:k,formatTimestamp:T,canSend:I,unreadCount:p=0,tr:N}){const M=x.useRef(null),$=x.useRef(null),_=x.useRef(null),Q=x.useRef(null),G=x.useRef(null),ie=x.useRef(null),ne=x.useRef(s),[V,H]=x.useState(!1),W=f==="HE",U=W?Wx:Gx,pe=i?"calc(6.5rem + env(safe-area-inset-bottom, 0px))":"1.5rem",Y=(z,oe)=>d?z:oe,K=x.useMemo(()=>({title:N("הצ׳אט של ALFA","ALFA Chat"),available:N("זמין","Available"),placeholder:N("כתבו הודעה...","Write a message..."),openConversation:N("פתח את השיחה","Open conversation"),minimizeConversation:N("מזער לשורת כתיבה","Minimize to composer"),dockToSide:N("מזער לצד","Dock to side"),openFromSide:N("פתח את הצ׳אט","Open chat"),hideCompletely:N("הסתר לגמרי","Hide completely"),options:N("אפשרויות צ׳אט","Chat options"),send:N("שלח","Send"),composer:N("הודעה לצ׳אט","Chat message"),conversation:N("שיחת צ׳אט","Chat conversation"),enterHint:N("Enter לשליחה, Shift+Enter לשורה חדשה","Enter to send, Shift+Enter for a new line"),unread:N("הודעות שלא נקראו","Unread messages")}),[N]),Le=x.useCallback(()=>{const z=M.current;z&&(z.style.height="auto",z.style.height=`${Math.min(z.scrollHeight,96)}px`)},[]);x.useLayoutEffect(()=>{Le()},[n,s,Le]),x.useEffect(()=>{if(s!==ae.EXPANDED)return;const z=$.current;z&&(z.scrollTop=z.scrollHeight)},[k,s]),x.useEffect(()=>{const z=ne.current;if(ne.current=s,z===s)return;const oe=window.requestAnimationFrame(()=>{var xe,ge;s===ae.COMPACT||s===ae.EXPANDED?(xe=M.current)==null||xe.focus({preventScroll:!0}):s===ae.DOCKED&&((ge=_.current)==null||ge.focus({preventScroll:!0}))});return()=>window.cancelAnimationFrame(oe)},[s]),x.useEffect(()=>{s!==ae.COMPACT&&H(!1)},[s]),x.useEffect(()=>{if(!V)return;const z=window.requestAnimationFrame(()=>{var xe;(xe=ie.current)==null||xe.focus({preventScroll:!0})}),oe=xe=>{var ge;(ge=Q.current)!=null&&ge.contains(xe.target)||H(!1)};return document.addEventListener("pointerdown",oe),()=>{window.cancelAnimationFrame(z),document.removeEventListener("pointerdown",oe)}},[V]);const Je=z=>{z.preventDefault(),y()},Ae=z=>{if(!(z.key!=="Escape"||z.defaultPrevented)){if(z.preventDefault(),z.stopPropagation(),V){H(!1),window.requestAnimationFrame(()=>{var oe;(oe=G.current)==null||oe.focus({preventScroll:!0})});return}r(Cp(s))}},O=z=>{H(!1),r(z)},D=z=>{w(z.target.value)},Z=Y("focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-300/80 focus-visible:ring-offset-2 focus-visible:ring-offset-[#202224]","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-600/60 focus-visible:ring-offset-2 focus-visible:ring-offset-white"),J=m("relative grid h-11 w-11 shrink-0 place-items-center rounded-full transition-colors",Z,Y("text-white/[0.65] hover:bg-white/10 hover:text-white","text-slate-500 hover:bg-slate-100 hover:text-slate-900")),He=m("min-h-11 min-w-0 flex-1 resize-none overflow-y-auto bg-transparent px-2 py-3 text-[15px] leading-5 outline-none",W?"text-right":"text-left",Y("text-white placeholder:text-white/60","text-slate-900 placeholder:text-slate-500"));return s===ae.CLOSED?null:s===ae.DOCKED?t.jsx("div",{className:"fixed z-[45] motion-safe:animate-in motion-safe:fade-in motion-safe:duration-200",style:{insetInlineEnd:0,bottom:pe},dir:W?"rtl":"ltr",children:t.jsxs("button",{ref:_,type:"button",onClick:()=>r(ae.COMPACT),className:m("group relative grid h-14 w-12 place-items-center border shadow-[-8px_8px_24px_rgba(0,0,0,0.22)] backdrop-blur-xl transition-[width,background-color] hover:w-14",W?"rounded-r-2xl border-l-0":"rounded-l-2xl border-r-0",Z,Y("border-white/10 bg-[#202224]/95 text-white hover:bg-[#2a2d30]","border-slate-200 bg-white/95 text-slate-800 hover:bg-slate-50")),"aria-label":K.openFromSide,title:K.openFromSide,children:[t.jsx(dl,{className:"h-5 w-5 transition-transform group-hover:scale-110","aria-hidden":"true"}),t.jsx(Ad,{className:"absolute bottom-2 end-2 h-2.5 w-2.5 text-emerald-300","aria-hidden":"true"}),t.jsx(yl,{count:p,label:K.unread})]})}):s===ae.COMPACT?t.jsxs("section",{ref:Q,className:"fixed left-1/2 z-[45] -translate-x-1/2 motion-safe:animate-in motion-safe:fade-in motion-safe:slide-in-from-bottom-3 motion-safe:duration-200",style:{bottom:pe,width:i?"calc(100vw - 1rem)":"min(860px, calc(100vw - 3rem))"},dir:W?"rtl":"ltr","aria-label":K.title,onKeyDown:Ae,children:[V&&t.jsxs("div",{id:_d,role:"menu",className:m("absolute bottom-[calc(100%+0.5rem)] end-2 z-10 w-48 overflow-hidden rounded-2xl border p-1.5 shadow-xl backdrop-blur-xl motion-safe:animate-in motion-safe:fade-in motion-safe:slide-in-from-bottom-1 motion-safe:duration-150 min-[381px]:hidden",Y("border-white/10 bg-[#202224]/95 text-white","border-slate-200 bg-white/95 text-slate-900")),children:[t.jsxs("button",{ref:ie,type:"button",role:"menuitem",onClick:()=>O(ae.DOCKED),className:m("flex min-h-11 w-full items-center gap-3 rounded-xl px-3 text-sm transition-colors",Z,Y("hover:bg-white/10","hover:bg-slate-100")),children:[t.jsx(U,{className:"h-4 w-4","aria-hidden":"true"}),t.jsx("span",{children:K.dockToSide})]}),t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>O(ae.CLOSED),className:m("flex min-h-11 w-full items-center gap-3 rounded-xl px-3 text-sm transition-colors",Z,Y("hover:bg-white/10","hover:bg-slate-100")),children:[t.jsx(ms,{className:"h-4 w-4","aria-hidden":"true"}),t.jsx("span",{children:K.hideCompletely})]})]}),t.jsxs("form",{onSubmit:Je,className:m("flex min-h-16 w-full items-end gap-1.5 rounded-[2rem] border p-2 shadow-[0_12px_36px_rgba(0,0,0,0.24)] backdrop-blur-xl",Y("border-white/10 bg-[#202224]/95 text-white","border-slate-200 bg-white/95 text-slate-900 shadow-[0_12px_36px_rgba(15,23,42,0.12)]")),children:[t.jsxs("button",{type:"button",onClick:()=>r(ae.EXPANDED),className:J,"aria-expanded":"false","aria-controls":al,"aria-label":K.openConversation,title:K.openConversation,children:[t.jsx(dl,{className:"h-5 w-5","aria-hidden":"true"}),t.jsx(yl,{count:p,label:K.unread})]}),t.jsx("label",{className:"sr-only",htmlFor:"crm-chat-compact-input",children:K.composer}),t.jsx("textarea",{ref:M,id:"crm-chat-compact-input",value:n,onChange:D,onKeyDown:j,rows:1,placeholder:K.placeholder,className:He,dir:W?"rtl":"ltr"}),t.jsxs("div",{className:"hidden shrink-0 items-center gap-2 self
147-center px-2 md:flex","aria-label":K.available,children:[t.jsx("span",{className:"h-2 w-2 rounded-full bg-emerald-400 shadow-[0_0_0_3px_rgba(52,211,153,0.12)]","aria-hidden":"true"}),t.jsx("bdi",{dir:"ltr",className:m("text-xs font-semibold",Y("text-white/[0.65]","text-slate-500")),children:"ALFA Chat"})]}),t.jsx("button",{type:"button",onClick:()=>r(ae.DOCKED),className:m(J,"max-[380px]:hidden"),"aria-label":K.dockToSide,title:K.dockToSide,children:t.jsx(U,{className:"h-5 w-5","aria-hidden":"true"})}),t.jsx("button",{type:"button",onClick:()=>r(ae.CLOSED),className:m(J,"max-[380px]:hidden"),"aria-label":K.hideCompletely,title:K.hideCompletely,children:t.jsx(ms,{className:"h-5 w-5","aria-hidden":"true"})}),t.jsx("button",{ref:G,type:"button",onClick:()=>H(z=>!z),className:m(J,"min-[381px]:hidden"),"aria-label":K.options,title:K.options,"aria-haspopup":"menu","aria-expanded":V,"aria-controls":_d,children:t.jsx(Bx,{className:"h-5 w-5","aria-hidden":"true"})}),t.jsx("button",{type:"submit",disabled:!I,className:m("grid h-12 w-12 shrink-0 place-items-center rounded-full transition-all",Z,I?Y("bg-white text-slate-950 shadow-sm hover:scale-[1.03] hover:bg-slate-100 active:scale-95","bg-slate-900 text-white shadow-sm hover:scale-[1.03] hover:bg-slate-800 active:scale-95"):Y("cursor-not-allowed bg-white/[0.09] text-white/[0.28]","cursor-not-allowed bg-slate-100 text-slate-300")),"aria-label":K.send,title:K.send,children:t.jsx(kd,{className:"h-5 w-5",strokeWidth:2.3,"aria-hidden":"true"})})]})]}):t.jsx("section",{id:al,role:"dialog","aria-modal":"false","aria-labelledby":Od,className:m("fixed z-[45] flex overflow-hidden rounded-[1.75rem] border shadow-[0_18px_54px_rgba(0,0,0,0.30)] backdrop-blur-xl motion-safe:animate-in motion-safe:fade-in motion-safe:slide-in-from-bottom-3 motion-safe:duration-200",Y("border-white/10 bg-[#191b1d]/[0.96] text-white","border-slate-200 bg-white/[0.97] text-slate-900 shadow-[0_18px_54px_rgba(15,23,42,0.14)]")),style:{insetInlineEnd:i?"0.5rem":"1.5rem",bottom:pe,width:i?"calc(100vw - 1rem)":"min(430px, calc(100vw - 3rem))",height:i?"min(68dvh, 36rem)":"min(72vh, 38rem)"},dir:W?"rtl":"ltr",onKeyDown:Ae,children:t.jsxs("div",{className:"flex min-h-0 w-full flex-col",children:[t.jsxs("header",{className:m("flex min-h-16 items-center gap-3 border-b px-4",Y("border-white/[0.08]","border-slate-200")),children:[t.jsx("span",{className:m("grid h-10 w-10 shrink-0 place-items-center rounded-full",Y("bg-white/[0.09] text-emerald-300","bg-emerald-50 text-emerald-700")),"aria-hidden":"true",children:t.jsx(Ad,{className:"h-5 w-5"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h2",{id:Od,className:"truncate text-sm font-semibold",children:K.title}),t.jsxs("p",{className:m("mt-0.5 flex items-center gap-1.5 text-xs",Y("text-white/60","text-slate-500")),children:[t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-400","aria-hidden":"true"}),K.available]})]}),t.jsx("button",{type:"button",onClick:()=>r(ae.COMPACT),className:J,"aria-expanded":"true","aria-controls":al,"aria-label":K.minimizeConversation,title:K.minimizeConversation,children:t.jsx(Lx,{className:"h-5 w-5","aria-hidden":"true"})}),t.jsx("button",{type:"button",onClick:()=>r(ae.DOCKED),className:m(J,"max-[380px]:hidden"),"aria-label":K.dockToSide,title:K.dockToSide,children:t.jsx(U,{className:"h-5 w-5","aria-hidden":"true"})}),t.jsx("button",{type:"button",onClick:()=>r(ae.CLOSED),className:J,"aria-label":K.hideCompletely,title:K.hideCompletely,children:t.jsx(ms,{className:"h-5 w-5","aria-hidden":"true"})})]}),t.jsx("div",{ref:$,className:m("flex-1 space-y-3 overflow-y-auto px-4 py-5",W?"text-right":"text-left"),dir:W?"rtl":"ltr","aria-label":K.conversation,"aria-live":"polite",children:k.map(z=>{const oe=z.direction==="outgoing",xe=oe?m("bg-emerald-600 text-white","rounded-br-md"):m(Y("bg-white/[0.08] text-white","bg-slate-100 text-slate-900"),"rounded-bl-md");return t.jsx("div",{dir:"ltr",className:m("flex",oe?"justify-end":"justify-start"),children:t.jsxs("div",{className:m("flex max-w-[86%] flex-col gap-1",oe?"items-end":"items-start"),children:[t.jsx("div",{dir:W?"rtl":"ltr",className:m("whitespace-pre-wrap break-words rounded-2xl px-4 py-2.5 text-sm leading-6 shadow-sm",xe),children:z.text}),t.jsx("span",{className:m("px-1 text-[11px]",Y("text-white/50","text-slate-500")),children:T(z.timestamp)})]})},z.id)})}),t.jsxs("form",{onSubmit:Je,className:m("border-t p-3",Y("border-white/[0.08]","border-slate-200")),children:[t.jsxs("div",{className:m("flex min-h-14 items-end gap-1.5 rounded-[1.6rem] border p-1.5",Y("border-white/10 bg-white/[0.055]","border-slate-200 bg-slate-50")),children:[t.jsx("label",{className:"sr-only",htmlFor:"crm-chat-expanded-input",children:K.composer}),t.jsx("textarea",{ref:M,id:"crm-chat-expanded-input",value:n,onChange:D,onKeyDown:j,rows:1,placeholder:K.placeholder,className:He,dir:W?"rtl":"ltr"}),t.jsx("button",{type:"submit",disabled:!I,className:m("grid h-11 w-11 shrink-0 place-items-center rounded-full transition-all",Z,I?Y("bg-white text-slate-950 shadow-sm hover:scale-[1.03] hover:bg-slate-100 active:scale-95","bg-slate-900 text-white shadow-sm hover:scale-[1.03] hover:bg-slate-800 active:scale-95"):Y("cursor-not-allowed bg-white/[0.09] text-white/[0.28]","cursor-not-allowed bg-slate-200 text-slate-400")),"aria-label":K.send,title:K.send,children:t.jsx(kd,{className:"h-5 w-5",strokeWidth:2.3,"aria-hidden":"true"})})]}),t.jsx("p",{className:m("mt-2 px-2 text-[11px]",Y("text-white/50","text-slate-500")),children:K.enterHint})]})]})})}rm.propTypes={mode:S.oneOf(Object.values(ae)).isRequired,onModeChange:S.func.isRequired,isCompact:S.bool.isRequired,isDark:S.bool.isRequired,language:S.string.isRequired,draft:S.string.isRequired,onDraftChange:S.func.isRequired,onSend:S.func.isRequired,onDraftKeyDown:S.func.isRequired,messages:S.arrayOf(S.shape({id:S.oneOfType([S.string,S.number]).isRequired,direction:S.oneOf(["incoming","outgoing"]).isRequired,text:S.node.isRequired,timestamp:S.oneOfType([S.string,S.number,S.instanceOf(Date)]).isRequired})).isRequired,formatTimestamp:S.func.isRequired,canSend:S.bool.isRequired,unreadCount:S.number,tr:S.func.isRequired};const Ep="23:00",Tp="09:30",Pp=new Set(["order.submitted","order.acknowledged","order.partially_filled"]),Ip=new Set(["order.filled","order.rejected","order.failed","order.risk_blocked"]),$p=["order.submitted","order.acknowledged","order.partially_filled","order.filled","order.rejected","order.failed","order.risk_blocked","order.canceled","order.expired"],Os={"order.submitted":{feed:!0,toast:!0,system:!1},"order.acknowledged":{feed:!0,toast:!0,system:!1},"order.partially_filled":{feed:!0,toast:!0,system:!1},"order.filled":{feed:!0,toast:!0,system:!0},"order.rejected":{feed:!0,toast:!0,system:!0},"order.failed":{feed:!0,toast:!0,system:!0},"order.risk_blocked":{feed:!0,toast:!0,system:!0},"order.canceled":{feed:!0,toast:!1,system:!1},"order.expired":{feed:!0,toast:!1,system:!1}};function im(){return{enabled:!0,systemNotifications:!0,inAppToasts:!0,badge:!0,sound:{enabled:!0,name:"Bell"},routingMode:"smart",privacyMode:"full",quietHours:{enabled:!0,startTime:Ep,endTime:Tp},events:{...Os}}}function Lp(s={}){const r={};return $p.forEach(i=>
147{const d=s==null?void 0:s[i],f=Os[i];r[i]={feed:typeof(d==null?void 0:d.feed)=="boolean"?d.feed:f.feed,toast:typeof(d==null?void 0:d.toast)=="boolean"?d.toast:f.toast,system:typeof(d==null?void 0:d.system)=="boolean"?d.system:f.system}}),r}function wl(s={}){var n,w;const r=im(),i=s!=null&&s.triggers&&typeof s.triggers=="object"?s.triggers:{},d=s!=null&&s.quietHours&&typeof s.quietHours=="object"?s.quietHours:{enabled:typeof(s==null?void 0:s.startTime)=="string"||typeof(s==null?void 0:s.endTime)=="string",startTime:s==null?void 0:s.endTime,endTime:s==null?void 0:s.startTime},f={enabled:typeof(s==null?void 0:s.enabled)=="boolean"?s.enabled:r.enabled,systemNotifications:typeof(s==null?void 0:s.systemNotifications)=="boolean"?s.systemNotifications:r.systemNotifications,inAppToasts:typeof(s==null?void 0:s.inAppToasts)=="boolean"?s.inAppToasts:r.inAppToasts,badge:typeof(s==null?void 0:s.badge)=="boolean"?s.badge:r.badge,sound:{enabled:typeof((n=s==null?void 0:s.sound)==null?void 0:n.enabled)=="boolean"?s.sound.enabled:typeof(s==null?void 0:s.muted)=="boolean"?!s.muted:r.sound.enabled,name:typeof((w=s==null?void 0:s.sound)==null?void 0:w.name)=="string"&&s.sound.name.trim()?s.sound.name.trim():typeof(s==null?void 0:s.sound)=="string"&&s.sound.trim()?s.sound.trim():r.sound.name},routingMode:typeof(s==null?void 0:s.routingMode)=="string"&&s.routingMode.trim()?s.routingMode.trim():r.routingMode,privacyMode:(s==null?void 0:s.privacyMode)==="generic"||(s==null?void 0:s.privacyMode)==="full"?s.privacyMode:r.privacyMode,quietHours:{enabled:typeof(d==null?void 0:d.enabled)=="boolean"?d.enabled:r.quietHours.enabled,startTime:typeof(d==null?void 0:d.startTime)=="string"&&d.startTime.trim()?d.startTime.trim():r.quietHours.startTime,endTime:typeof(d==null?void 0:d.endTime)=="string"&&d.endTime.trim()?d.endTime.trim():r.quietHours.endTime},events:Lp(s==null?void 0:s.events)};return!(s!=null&&s.events)&&typeof i=="object"&&(typeof(i==null?void 0:i.orders)=="boolean"&&(f.events["order.submitted"].toast=i.orders,f.events["order.acknowledged"].toast=i.orders,f.events["order.partially_filled"].toast=i.orders),typeof(i==null?void 0:i.entries)=="boolean"&&(f.events["order.filled"].toast=i.entries,f.events["order.filled"].system=i.entries)),f}function Dd(s){if(typeof s!="string")return null;const r=s.split(":");if(r.length<2)return null;const i=Number(r[0]),d=Number(r[1]);return!Number.isFinite(i)||!Number.isFinite(d)||i<0||i>23||d<0||d>59?null:i*60+d}function Rp(s,r=Date.now()){var w,y,j;if(!((w=s==null?void 0:s.quietHours)!=null&&w.enabled))return!1;const i=Dd((y=s==null?void 0:s.quietHours)==null?void 0:y.startTime),d=Dd((j=s==null?void 0:s.quietHours)==null?void 0:j.endTime);if(i==null||d==null||i===d)return!1;const f=r instanceof Date?r:new Date(r),n=f.getHours()*60+f.getMinutes();return i<d?n>=i&&n<d:n>=i||n<d}function Ms(s){if(typeof s=="number")return Number.isFinite(s)?s:null;if(typeof s=="string"&&s.trim()){const r=Number(s);return Number.isFinite(r)?r:null}return null}function lm(s){var i,d,f;if(!s||typeof s!="object")return null;const r=[s.orderId,s.OrderId,s.id,s.orderID,s.OrderID,(i=s.raw)==null?void 0:i.orderId,(d=s.raw)==null?void 0:d.OrderId,(f=s.raw)==null?void 0:f.id];for(const n of r){if(n==null)continue;const w=String(n).trim();if(w)return w}return null}function Mp(s){return typeof s!="string"?"":s.toUpperCase().replace(/[^A-Z0-9]/g,"")}function Op(s){var r;return Ms((s==null?void 0:s.filledQuantity)??(s==null?void 0:s.filledQuantityValue)??(s==null?void 0:s.FilledQuantity)??(s==null?void 0:s.rawFilledQuantity)??((r=s==null?void 0:s.raw)==null?void 0:r.FilledQuantity)??(s==null?void 0:s.filled)??(s==null?void 0:s.ExecQuantity))}function _p(s){var r;return Ms((s==null?void 0:s.remainingQuantity)??(s==null?void 0:s.remainingQuantityValue)??(s==null?void 0:s.QuantityRemaining)??(s==null?void 0:s.quantityLeft)??(s==null?void 0:s.rawRemainingQuantity)??((r=s==null?void 0:s.raw)==null?void 0:r.QuantityRemaining))}function om(s){var r;return Ms((s==null?void 0:s.quantityValue)??(s==null?void 0:s.quantity)??(s==null?void 0:s.QuantityOrdered)??(s==null?void 0:s.Quantity)??(s==null?void 0:s.rawQuantity)??((r=s==null?void 0:s.raw)==null?void 0:r.Quantity)??(s==null?void 0:s.manualQuantity))}function cm(s){var r,i;return(s==null?void 0:s.status)??(s==null?void 0:s.Status)??((r=s==null?void 0:s.raw)==null?void 0:r.status)??((i=s==null?void 0:s.raw)==null?void 0:i.Status)??""}function Dp(s,r){const i=lm(s)??"unknown",d=Mp(cm(s)),f=Op(s),n=_p(s),w=om(s);return[i,r||"event",d||"status",f??"filled",n??"remaining",w??"quantity"].join(":")}function Fp({eventType:s,order:r,timestamp:i=Date.now(),source:d="stream"}={}){if(!s||!r)return null;const f=lm(r);return f?{eventType:s,orderId:f,order:r,timestamp:typeof i=="number"?i:Date.now(),source:d,fingerprint:Dp(r,s)}:null}function Bp(s){return s==="order.filled"?"success":s==="order.rejected"||s==="order.failed"||s==="order.risk_blocked"?"error":s==="order.canceled"||s==="order.expired"?"warning":s==="order.partially_filled"?"notice":"info"}
147function Ye(s,r,i){return typeof s=="function"?s(r,i):i}function Up(s,r){const i=(s==null?void 0:s.action)??(s==null?void 0:s.Action)??(s==null?void 0:s.side)??(s==null?void 0:s.Side)??(s==null?void 0:s.buyOrSell)??(s==null?void 0:s.BuyOrSell)??null;return i?Ye(r,i,i):null}function Vp(s,r){const i=om(s);if(i==null){const f=(s==null?void 0:s.quantityOrdered)??(s==null?void 0:s.QuantityOrdered)??(s==null?void 0:s.quantity)??(s==null?void 0:s.Quantity)??null;return typeof f=="string"&&f.trim()?f.trim():null}const d=Math.abs(i);return typeof r=="function"?r(d):String(d)}function Hp(s){var i,d;const r=(s==null?void 0:s.symbol)??(s==null?void 0:s.Symbol)??((i=s==null?void 0:s.raw)==null?void 0:i.symbol)??((d=s==null?void 0:s.raw)==null?void 0:d.Symbol)??null;return typeof r=="string"&&r.trim()?r.trim():null}function qp(s){const r=cm(s);return typeof r=="string"&&r.trim()?r.trim():null}function zp(s,r){const i=(s==null?void 0:s.currency)??(s==null?void 0:s.Currency)??"USD",d=Ms((s==null?void 0:s.averagePrice)??(s==null?void 0:s.AveragePrice))??Ms((s==null?void 0:s.limitPrice)??(s==null?void 0:s.LimitPrice))??Ms(s==null?void 0:s.priceValue)??Ms(s==null?void 0:s.price);return d==null?null:typeof r=="function"?r(d,i):`${d}`}function Qp(s,{tr:r,formatQuantity:i,formatCurrency:d,privacyMode:f="full"}={}){const n=s==null?void 0:s.eventType,w=(s==null?void 0:s.order)??{},y=Hp(w),j=Up(w,r),k=Vp(w,i),T=qp(w),I=zp(w,d),p={"order.submitted":Ye(r,"הזמנה נשלחה","Order sent"),"order.acknowledged":Ye(r,"הזמנה התקבלה","Order acknowledged"),"order.partially_filled":Ye(r,"מילוי חלקי","Partial fill"),"order.filled":Ye(r,"הזמנה בוצעה","Order filled"),"order.rejected":Ye(r,"הזמנה נדחתה","Order rejected"),"order.failed":Ye(r,"הזמנה נכשלה","Order failed"),"order.risk_blocked":Ye(r,"הזמנה נחסמה","Order blocked"),"order.canceled":Ye(r,"הזמנה בוטלה","Order canceled"),"order.expired":Ye(r,"הזמנה פקעה","Order expired")};if(f==="generic")return{title:p[n]??Ye(r,"עדכון הזמנה","Order update"),body:Ye(r,"יש עדכון חדש לאחת ההזמנות שלך.","There is a new update for one of your orders.")};let M=[j,k,y].filter(Boolean).join(" ");return I&&(M=M?`${M} @ ${I}`:I),T&&(M=M?`${M} - ${T}`:T),{title:p[n]??Ye(r,"עדכון הזמנה","Order update"),body:M||y||Ye(r,"עדכון הזמנה","Order update")}}function Wp(s){return Ip.has(s)}function Kp(s){return Pp.has(s)}function Gp(s,r){return!r||!s?!1:s instanceof Set?s.has(r):Array.isArray(s)?s.includes(r):!1}function Xp({event:s,settings:r,context:i={},now:d=Date.now()}={}){var ie;if(!s)return null;const f=wl(r),n=f.events[s.eventType]??Os[s.eventType],w=[],y=(i==null?void 0:i.recentEvent)??null,j=(i==null?void 0:i.processedKeys)instanceof Set?i.processedKeys:null,k=`${s.orderId}:${s.eventType}:${s.fingerprint}`,T=Wp(s.eventType),I=Kp(s.eventType),p=Rp(f,d);(j!=null&&j.has(k)||(y==null?void 0:y.dedupeKey)===k||(y==null?void 0:y.fingerprint)===s.fingerprint)&&w.push("DUPLICATE_STATE");let N=!!(f.enabled&&(n!=null&&n.feed)),M=!!(f.enabled&&f.inAppToasts&&(n!=null&&n.toast)),$=!!(f.enabled&&f.systemNotifications&&(n!=null&&n.system)),_=!!(f.enabled&&((ie=f.sound)!=null&&ie.enabled)&&$),Q=!!(f.enabled&&f.badge),G="append";if(w.includes("DUPLICATE_STATE")&&(N=!1,M=!1,$=!1,_=!1,Q=!1),f.enabled||(w.push("USER_PREF_OFF"),N=!1,M=!1,$=!1,_=!1),!(n!=null&&n.feed)&&!(n!=null&&n.toast)&&!(n!=null&&n.system)&&w.push("EVENT_PREF_OFF"),I&&p&&(w.push("QUIET_HOURS"),M=!1,$=!1,_=!1),I&&(i!=null&&i.originatedLocally)&&(w.push("ORIGIN_DEVICE"),M=!1,$=!1,_=!1),I&&Gp(i==null?void 0:i.activeOrderIds,s.orderId)&&(w.push("ACTIVE_ORDER_SCREEN"),M=!1,$=!1,_=!1),I){const ne=(i==null?void 0:i.platform)==="mobile"||(i==null?void 0:i.platform)==="desktop"?i.platform:null;f.routingMode==="desktop_preferred"&&ne==="mobile"?(w.push("ROUTED_TO_DESKTOP"),$=!1,_=!1):f.routingMode==="mobile_preferred"&&ne==="desktop"&&(w.push("ROUTED_TO_MOBILE"),$=!1,_=!1)}return $&&(i!=null&&i.supportsSystemNotifications?i!=null&&i.systemPermission&&i.systemPermission!=="granted"&&i.systemPermission!=="ready"&&(w.push("PERMISSION_DENIED"),$=!1,_=!1):(w.push("SYSTEM_UNSUPPORTED"),$=!1,_=!1)),s.eventType==="order.acknowledged"&&(y==null?void 0:y.eventType)==="order.submitted"&&typeof(y==null?void 0:y.occurredAt)=="number"&&d-y.occurredAt<=3e3?(w.push("COLLAPSED_ROUTINE_EVENT"),G="replace-previous"):s.eventType==="order.partially_filled"&&(y==null?void 0:y.eventType)==="order.partially_filled"&&typeof(y==null?void 0:y.occurredAt)=="number"&&d-y.occurredAt<=3e4&&(w.push("PARTIAL_FILL_AGGREGATED"),G="aggregate-latest",T||(M=!1,$=!1,_=!1)),{dedupeKey:k,orderId:s.orderId,eventType:s.eventType,fingerprint:s.fingerprint,severity:Bp(s.eventType),occurredAt:s.timestamp??d,feed:N,toast:M,system:$,sound:_,badge:Q,mergeMode:G,quietHoursActive:p,reasons:w,critical:T}}function Yp(s,r){const i=Array.isArray(s)?[...s]:[];if(!(r!=null&&r.feed))return i;if(r.mergeMode==="replace-previous")for(let d=i.length-1;d>=0;d-=1){const f=i[d];if((f==null?void 0:f.orderId)===r.orderId&&(f==null?void 0:f.eventType)==="order.submitted")return i[d]={...f,...r,id:f.id,updatedAt:r.occurredAt},i}if(r.mergeMode==="aggregate-latest")for(let d=i.length-1;d>=0;d-=1){const f=i[d];if((f==null?void 0:f.orderId)===r.orderId&&(f==null?void 0:f.eventType)==="order.partially_filled")return i[d]={...f,...r,id:f.id,count:(f.count??1)+1,updatedAt:r.occurredAt},i}return i.unshift({...r,count:r.count??1,createdAt:r.occurredAt,updatedAt:r.occurredAt}),i.slice(0,50)}const pn=jl("PushNotifications"),rl=jl("LocalNotifications"),Xn=jl("FirebaseConfig"),dm="notifications.pushToken";function wr(){var s,r;try{return!!((r=(s=iu)==null?void 0:s.isNativePlatform)!=null&&r.call(s))}catch{return!1}}function gn(){if(!wr())return"web";try{return iu.getPlatform()}catch{return"native"}}async function Jp(){var s;if(!wr()||gn()!=="android")return!0;try{const r=await((s=Xn==null?void 0:Xn.isConfigured)==null?void 0:s.call(Xn));return(r==null?void 0:r.configured)===!0}catch{return!1}}function wn(){return typeof window<"u"&&"Notification"in window}function Zp(){var i,d,f,n;if(typeof window>"u")return!1;if(window.isSecureContext)return!0;const s=(i=window.location)==null?void 0:i.protocol,r=(d=window.location)==null?void 0:d.hostname;
147return!!(s==="http:"&&(r==="localhost"||r==="127.0.0.1"||r==="[::1]")||typeof navigator<"u"&&(((n=(f=navigator.userAgent)==null?void 0:f.toLowerCase)==null?void 0:n.call(f))??"").includes("electron"))}function e0(){if(typeof document>"u")return!0;const s=document.permissionsPolicy??document.featurePolicy;if(!s)return!0;const r="notifications",i=typeof s.allowedFeatures=="function"?s.allowedFeatures.bind(s):typeof s.features=="function"?s.features.bind(s):null;if(i)try{const d=i();if(Array.isArray(d)&&d.length>0&&!d.includes(r))return!0}catch{return!0}if(typeof s.allowsFeature=="function")try{if(!s.allowsFeature(r))return!1}catch{return!0}return!0}function il(){return wn()?Notification.permission:"unsupported"}async function lr(){if(!wn())return"unsupported";try{return await Notification.requestPermission()}catch{return Notification.permission}}function $s({title:s,body:r,icon:i,tag:d,data:f}={}){if(!wn())return{ok:!1,reason:"unsupported"};if(!Zp())return{ok:!1,reason:"insecure-context"};if(!e0())return{ok:!1,reason:"blocked-policy"};if(Notification.permission!=="granted")return{ok:!1,reason:"permission"};try{return{ok:!0,notification:new Notification(s||"Notification",{body:r||"",icon:i,tag:d,data:f})}}catch(n){return{ok:!1,reason:"error",error:n}}}let or=null;const Fd={Bell:{type:"sine",tones:[{frequency:880,duration:.2,gap:.04},{frequency:660,duration:.22}]},Chime:{type:"sine",tones:[{frequency:523.25,duration:.18,gap:.03},{frequency:659.25,duration:.18,gap:.03},{frequency:783.99,duration:.22}]},Radar:{type:"triangle",tones:[{frequency:740,duration:.1,gap:.08},{frequency:740,duration:.1,gap:.08},{frequency:740,duration:.1,gap:.08},{frequency:740,duration:.1}]},Pulse:{type:"sine",tones:[{frequency:560,duration:.12,gap:.1},{frequency:560,duration:.12}]},Wood:{type:"triangle",tones:[{frequency:260,duration:.16,gap:.05},{frequency:220,duration:.18}]},Digital:{type:"square",tones:[{frequency:880,duration:.08,gap:.03},{frequency:660,duration:.08,gap:.03},{frequency:990,duration:.08}]}};function t0(){if(typeof window>"u")return null;const s=window.AudioContext||window.webkitAudioContext;return s?((!or||or.state==="closed")&&(or=new s),or):null}function s0(s,{frequency:r,duration:i,type:d,volume:f,startTime:n}){const w=s.createOscillator(),y=s.createGain();w.type=d,w.frequency.setValueAtTime(r,n),y.gain.setValueAtTime(1e-4,n),y.gain.exponentialRampToValueAtTime(f,n+.02),y.gain.exponentialRampToValueAtTime(1e-4,n+i),w.connect(y).connect(s.destination),w.start(n),w.stop(n+i+.02)}function n0(s,r,i){const d=Array.isArray(r==null?void 0:r.tones)?r.tones:[];if(!d.length)return;let f=s.currentTime+.01;const n=(r==null?void 0:r.type)||"sine",w=Math.max(.02,Math.min(i,1));d.forEach(y=>{const j=typeof y.duration=="number"?y.duration:.15,k=typeof y.gap=="number"?y.gap:.04,T=typeof y.frequency=="number"?y.frequency:440,I=w*(typeof y.volume=="number"?y.volume:1);s0(s,{frequency:T,duration:j,type:y.type||n,volume:I,startTime:f}),f+=j+k})}async function Ls({sound:s="Bell",muted:r=!1,volume:i=.25,onlyWhenVisible:d=!1}={}){if(r)return{ok:!1,reason:"muted"};if(d&&typeof document<"u"&&document.visibilityState!=="visible")return{ok:!1,reason:"hidden"};const f=t0();if(!f)return{ok:!1,reason:"unsupported"};try{await f.resume()}catch{return{ok:!1,reason:"blocked"}}const n=Fd[s]||Fd.Bell;return n0(f,n,i),{ok:!0}}let ea=0,vn=null,Nn=null,Bd=!1;function a0(){if(Bd||typeof window>"u"||typeof document>"u")return;Bd=!0;const s=()=>{document.hidden||um()};window.addEventListener("focus",s),document.addEventListener("visibilitychange",s)}function Rs({count:s=1,durationMs:r=4e3}={}){if(typeof document>"u")return{ok:!1,reason:"unsupported"};a0();const i=typeof s=="number"&&Number.isFinite(s)?Math.max(1,Math.floor(s)):1;if(Nn||(Nn=document.title||"ALFA"),ea=Math.min(99,ea+i),document.title=`[${ea}] ${Nn}`,typeof navigator<"u"&&typeof navigator.setAppBadge=="function")try{navigator.setAppBadge(ea)}catch{}return vn&&window.clearTimeout(vn),vn=window.setTimeout(()=>{um()},Math.max(500,r)),{ok:!0}}function um(){if(typeof document>"u")return{ok:!1,reason:"unsupported"};if(vn&&(window.clearTimeout(vn),vn=null),ea=0,Nn&&(document.title=Nn,Nn=null),typeof navigator<"u"&&typeof navigator.clearAppBadge=="function")try{navigator.clearAppBadge()}catch{}return{ok:!0}}function cr(){if(typeof window>"u")return null;try{const s=window.localStorage.getItem(dm);return s?s.trim():null}catch{return null}}function Ud(s){if(!(typeof window>"u"))try{s&&typeof s=="string"&&window.localStorage.setItem(dm,s)}catch{}}let Vd=!1,ll=null;async function mm({title:s,body:r}={}){try{return(await rl.checkPermissions()).display!=="granted"&&(
147await rl.requestPermissions()).display!=="granted"?!1:(await rl.schedule({notifications:[{title:s||"Notification",body:r||"",id:Date.now()%2147483647,schedule:{at:new Date(Date.now()+100)}}]}),!0)}catch{return!1}}async function Hd({title:s,body:r}={}){return wr()?await mm({title:s,body:r})?{ok:!0}:{ok:!1,reason:"permission"}:{ok:!1,reason:"unsupported"}}function r0({onNotification:s}={}){typeof s=="function"&&(ll=s),!Vd&&(Vd=!0,pn.addListener("pushNotificationReceived",r=>{var i;if(typeof ll=="function")try{ll(r)}catch{}mm({title:r==null?void 0:r.title,body:(r==null?void 0:r.body)??((i=r==null?void 0:r.data)==null?void 0:i.body)})}))}async function qd({onNotification:s,allowPrompt:r=!0}={}){if(!wr())return{status:"unsupported",token:null};if(!await Jp())return{status:"misconfigured",token:null};r0({onNotification:s});let d=await pn.checkPermissions();if(d.receive!=="granted"){if(!r)return{status:d.receive||"denied",token:null};if(d=await pn.requestPermissions(),d.receive!=="granted")return{status:d.receive||"denied",token:null}}return{status:"granted",token:await new Promise((n,w)=>{let y,j;const k=()=>{try{y==null||y.remove(),j==null||j.remove()}catch{}};y=pn.addListener("registration",T=>{k(),n((T==null?void 0:T.value)??(T==null?void 0:T.token)??null)}),j=pn.addListener("registrationError",T=>{k(),w(T)}),pn.register().catch(T=>{k(),w(T)})})}}async function hm(s,r){try{const i=await s.clone().json();if(i&&typeof i=="object"){if(typeof i.detail=="string")return i.detail;if(typeof i.error=="string")return i.error}}catch{}return r}async function Yn({token:s,platform:r,deviceId:i}={}){if(!s)throw new Error("Push token is required");const d=$e("/notifications/push/register"),f=await fetch(d,{method:"POST",headers:kn({"Content-Type":"application/json",Accept:"application/json"}),body:JSON.stringify({token:s,platform:r,deviceId:i})});if(!f.ok){const n=await hm(f,`Failed to register push token (status ${f.status})`);throw new Error(n)}try{return await f.json()}catch{return{}}}async function zd({title:s,body:r}={}){const i=$e("/notifications/push/test"),d=await fetch(i,{method:"POST",headers:kn({"Content-Type":"application/json",Accept:"application/json"}),body:JSON.stringify({title:s,body:r})});if(!d.ok){const f=await hm(d,`Failed to send test notification (status ${d.status})`);throw new Error(f)}try{return await d.json()}catch{return{}}}const fm=Object.freeze(["backtest","forecast","movement"]),i0=Object.freeze([...fm,"menu"]);function l0({canAccessCalculations:s=!1,isCompact:r=!1}={}){return(r?i0:fm).filter(d=>s||d!=="backtest")}const vl="vehicleCenter",xm="tesla",K0="alfaTeslaVehicleCenterOverlay";function G0(s=""){return new URLSearchParams(s).get(vl)===xm}function o0(s,r){const i=new URLSearchParams((s==null?void 0:s.search)??"");r?i.set(vl,xm):i.delete(vl);const d=i.toString();return{pathname:(s==null?void 0:s.pathname)||"/Backtest",search:d?`?${d}`:"",hash:(s==null?void 0:s.hash)??""}}const c0="(prefers-reduced-motion: reduce)",bm="networkViewTransition";let os=null,hr=0;function d0(){var s,r;return typeof window<"u"&&!!((r=(s=window.matchMedia)==null?void 0:s.call(window,c0))!=null&&r.matches)}function Qd(s,r){r===hr&&(delete s.dataset[bm],os=null)}function u0(s,r){var w;if(typeof r!="function")return null;if(typeof document>"u"||typeof document.startViewTransition!="function"||d0())return r(),null;try{(w=os==null?void 0:os.skipTransition)==null||w.call(os)}catch{os=null}const i=document.documentElement,d=hr+1;hr=d,i.dataset[bm]=s;let f=!1;const n=()=>{f||d!==hr||(f=!0,xr.flushSync(r))};try{const y=document.startViewTransition(n);return os=y,Promise.resolve(y.finished).catch(()=>{}).finally(()=>Qd(i,d)),y}catch{return f||r(),Qd(i,d),null}}const Ll=()=>us(()=>import("./PerformanceView-ukxaWJQt.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])),Rl=()=>us(()=>import("./BacktestingView-wJUHolhr.js"),__vite__mapDeps([13,1,2,5,6,10,7,14,3,4,15,9,16,11])),br=()=>us(()=>import("./NetworkWorkspace-jN2dE6Qu.js"),__vite__mapDeps([17,1,2,3,4,10,7,18,5,6,14,8,9,15,11,19])),pm=()=>us(()=>import("./TradeStationMovementChart-Z8eYp8Tj.js"),__vite__mapDeps([20,1,2,3,4,5,16,6])),gm=()=>us(()=>
147import("./TradingViewAdvancedChartWidget-BEC69yJN.js"),__vite__mapDeps([21,1,2,3,4,10,7])),m0=x.lazy(Ll),h0=x.lazy(Rl),Wd=x.lazy(br),f0=x.lazy(pm),x0=x.lazy(gm);var su,nu,au;if(typeof window<"u"){const s=((nu=(su=window.location)==null?void 0:su.pathname)==null?void 0:nu.toLowerCase())??"";s.endsWith("/forecast")&&Ll(),s.endsWith("/backtest")&&(lu((au=window.location)==null?void 0:au.search)===bt.NETWORK?br():Rl()),(s.endsWith("/crm")||s==="/")&&(pm(),gm())}const b0=[{key:"backtest",label:"חישובים",labelEn:"Calculations",Icon:sa},{key:"forecast",label:"תחזית",labelEn:"Forecast",Icon:pu},{key:"movement",label:"תנועה",labelEn:"Movement",Icon:gu}],ls=ur(),p0=b0,g0={Accounts:yu,"Graph Settings":sa,Alerts:Al,Language:du,Theme:Sl,Downloads:yn,System:uu},ym=[...p0,{key:"menu",label:"תפריט",labelEn:"Menu",Icon:xu}],y0=new Set(ym.map(s=>s.key)),w0=(s,r="movement")=>{var i;return(i=s==null?void 0:s.has)!=null&&i.call(s,r)?r:s!=null&&s.size?s.values().next().value??r:r},Kd="graph",Gd={buy:"#2563eb",sell:"#ef4444"},Xd="alerts",Yd="system",Jd="notifications.deviceId",wm="crm.chatDockMode.v2",Jn=1e4,v0=()=>{if(typeof window>"u")return ae.COMPACT;try{return kp(window.localStorage.getItem(wm))}catch{return ae.COMPACT}},Nl=(s=Os)=>{const r={};return Object.entries(s).forEach(([i,d])=>{r[i]={feed:!!(d!=null&&d.feed),toast:!!(d!=null&&d.toast),system:!!(d!=null&&d.system)}}),r},N0=[{key:"order.submitted",label:"Submitted"},{key:"order.acknowledged",label:"Acknowledged"},{key:"order.partially_filled",label:"Partial fill"},{key:"order.filled",label:"Filled"},{key:"order.rejected",label:"Rejected"},{key:"order.failed",label:"Failed"},{key:"order.risk_blocked",label:"Risk blocked"},{key:"order.canceled",label:"Canceled"},{key:"order.expired",label:"Expired"}],j0=[{value:"smart",label:"Smart routing"},{value:"all_enabled_devices",label:"All enabled devices"},{value:"desktop_preferred",label:"Desktop preferred"},{value:"mobile_preferred",label:"Mobile preferred"}],k0=[{value:"full",label:"Full details"},{value:"generic",label:"Generic message"}],Zd=({enabled:s,systemNotifications:r,inAppToasts:i,badge:d,routingMode:f,privacyMode:n,quietStartTime:w,quietEndTime:y,soundName:j,soundMuted:k,eventRules:T})=>({enabled:!!s,systemNotifications:!!r,inAppToasts:!!i,badge:!!d,routingMode:f,privacyMode:n,quietHours:{enabled:!0,startTime:w,endTime:y},sound:{enabled:!k,name:j},events:Nl(T)}),A0=()=>{if(typeof window>"u")return"web";try{const s=window.localStorage.getItem(Jd);if(s&&s.trim())return s.trim();const r=typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`device-${Date.now()}-${Math.round(Math.random()*1e6)}`;return window.localStorage.setItem(Jd,r),r}catch{return`device-${Date.now()}`}},ds=[{symbol:"AMEX:SPY",label:"SPY",name:"SPDR S&P 500 ETF",market:"US ETF"},{symbol:"AMEX:RSP",label:"RSP",name:"S&P 500 Equal Weight",market:"US ETF"},{symbol:"NASDAQ:QQQ",label:"QQQ",name:"Invesco Nasdaq 100",market:"US ETF"},{symbol:"NASDAQ:NVDA",label:"NVDA",name:"NVIDIA",market:"NASDAQ"},{symbol:"NASDAQ:AAPL",label:"AAPL",name:"Apple",market:"NASDAQ"},{symbol:"NASDAQ:MSFT",label:"MSFT",name:"Microsoft",market:"NASDAQ"},{symbol:"NASDAQ:TSLA",label:"TSLA",name:"Tesla",market:"NASDAQ"},{symbol:"NASDAQ:META",label:"META",name:"Meta Platforms",market:"NASDAQ"},{symbol:"CBOE:VIX",label:"VIX",name:"CBOE Volatility Index",market:"Index"},{symbol:"OANDA:SPX500USD",label:"USA500",name:"S&P 500 CFD",market:"Index"},{symbol:"BITSTAMP:BTCUSD",label:"BTCUSD",name:"Bitcoin / US Dollar",market:"Crypto"},{symbol:"NASDAQ:GOOGL",label:"GOOGL",name:"Alphabet",market:"NASDAQ"},{symbol:"NASDAQ:SOXX",label:"SOXX",name:"iShares Semiconductor ETF",market:"US ETF"}],ol=ds[0].symbol,vm="crm.secondaryTradingViewSymbol",S0=()=>{if(typeof window>"u"||!window.localStorage)return ol;try{const s=window.localStorage.getItem(vm);return ds.some(r=>r.symbol===s)?s:ol}catch{return ol}},C0=s=>{if(!s||!s.config)return{unit:"Minute",interval:5};const r=Number.isFinite(s.config.interval)?Math.max(1,s.config.interval):5;return{unit:typeof s.config.unit=="string"&&s.config.unit.trim()?s.config.unit:"Minute",interval:r}},E0=s=>{if(!s)return null;const{unit:r,interval:i}=s,d=Math.max(1,Number(i)||1),f=typeof r=="string"?r.toLowerCase():"";return f.startsWith("min")?d:f.startsWith("hour")?d*60:f.startsWith("day")?d*24*60:f.startsWith("week")?d*7*24*60:f.startsWith("month")?d*30*24*60:d},T0=s=>s?Number.isFinite(s.minutes)?Math.max(1,s.minutes):Number.isFinite(s.days)?Math.max(1,s.days*24*60):Number.isFinite(s.weeks)?Math.max(1,s.weeks*7*24*60):Number.isFinite(s.months)?Math.max(1,s.months*30*24*60):Number.isFinite(s.years)?Math.max(1,s.years*365*24*60):null:null,P0=s=>{const r=(s==null?void 0:s.config)??s,i=Number(r==null?void 0:r.interval);if(!Number.isFinite(i)||i<=0)return"60";
147const d=typeof(r==null?void 0:r.unit)=="string"?r.unit.trim().toLowerCase():"";return d.startsWith("hour")?String(i*60):d.startsWith("day")?"D":d.startsWith("week")?"W":d.startsWith("month")?"M":String(i)},I0=(s,r)=>{if(!r)return Jn;if(r.mode==="max")return Number.isFinite(r.maxBarsBack)?Math.max(1,r.maxBarsBack):Jn;if(Number.isFinite(r.barsBack)){const w=Math.max(1,Math.floor(r.barsBack)),y=Number.isFinite(r.maxBarsBack)?Math.max(1,r.maxBarsBack):Jn;return Math.min(w,y)}const i=E0(s)||1,d=T0(r),f=d?Math.ceil(d/Math.max(i,1)):Jn,n=Number.isFinite(r.maxBarsBack)?Math.max(1,r.maxBarsBack):Jn;return Math.max(1,Math.min(f,n))},$0=(s,r)=>{const i=(s==null?void 0:s.interval)??0,d=(s==null?void 0:s.unit)??"",f=(r==null?void 0:r.barsback)??0;return`${i}:${d}:${f}`},Ie=({resolutionId:s=null,spanId:r=null,indicatorEnabled:i=!1,bollingerUpperEnabled:d=!0,bollingerLowerEnabled:f=!1,showLastPriceLabel:n=!0,showBidAskLabels:w=!1,showIndicatorLabels:y=!0}={})=>({resolutionId:s,spanId:r,indicatorEnabled:i,bollingerUpperEnabled:d,bollingerLowerEnabled:f,showLastPriceLabel:n,showBidAskLabels:w,showIndicatorLabels:y}),Zn=(s,r={})=>{const i=s&&typeof s=="object"?s:{},d=Ie(r);return typeof i.resolutionId=="string"&&i.resolutionId.trim()&&(d.resolutionId=i.resolutionId),typeof i.spanId=="string"&&i.spanId.trim()&&(d.spanId=i.spanId),typeof i.indicatorEnabled=="boolean"&&(d.indicatorEnabled=i.indicatorEnabled),typeof i.bollingerUpperEnabled=="boolean"?d.bollingerUpperEnabled=i.bollingerUpperEnabled:typeof i.bollingerEnabled=="boolean"&&(d.bollingerUpperEnabled=i.bollingerEnabled),typeof i.bollingerLowerEnabled=="boolean"&&(d.bollingerLowerEnabled=i.bollingerLowerEnabled),typeof i.showLastPriceLabel=="boolean"&&(d.showLastPriceLabel=i.showLastPriceLabel),typeof i.showBidAskLabels=="boolean"&&(d.showBidAskLabels=i.showBidAskLabels),typeof i.showIndicatorLabels=="boolean"&&(d.showIndicatorLabels=i.showIndicatorLabels),d},eu=s=>({resolutionId:(s==null?void 0:s.resolutionId)??null,spanId:(s==null?void 0:s.spanId)??null,indicatorEnabled:!!(s!=null&&s.indicatorEnabled),bollingerUpperEnabled:!!(s!=null&&s.bollingerUpperEnabled),bollingerLowerEnabled:!!(s!=null&&s.bollingerLowerEnabled),showLastPriceLabel:!!(s!=null&&s.showLastPriceLabel),showBidAskLabels:!!(s!=null&&s.showBidAskLabels),showIndicatorLabels:!!(s!=null&&s.showIndicatorLabels)}),L0=(s,r={})=>{const i=Zn(r.primary),d=Zn(r.secondary,i),f=Zn(s,i);if(!s||typeof s!="object")return{primary:f,secondary:Ie(f)};if(!!!(s.primary||s.secondary))return{primary:f,secondary:Ie(f)};const w=Zn(s.primary,i),y=s.secondary?w:d,j=Zn(s.secondary,y);return{primary:w,secondary:j}},tu=(s,r,i)=>{var d;return!Array.isArray(r)||r.length===0?s??null:s&&r.some(f=>f.id===s)?s:i??((d=r[0])==null?void 0:d.id)??null},dr=(s,{resolutions:r=[],spans:i=[],defaultResolutionId:d=null,defaultSpanId:f=null}={})=>{const n=tu(s==null?void 0:s.resolutionId,r,d),w=tu(s==null?void 0:s.spanId,i,f);return n===(s==null?void 0:s.resolutionId)&&w===(s==null?void 0:s.spanId)?s:{...s,resolutionId:n,spanId:w}};function cl(s,r,i=y0){var y;const d=(s||"").toLowerCase(),f=d.endsWith("/")&&d.length>1?d.replace(/\/+$/,""):d,n=w0(i),w=j=>{var k;return(k=i==null?void 0:i.has)!=null&&k.call(i,j)?j:n};return f.endsWith("/forecast")?w("forecast"):f.endsWith("/backtest")?w("backtest"):f.endsWith("/menu")?w("menu"):f.endsWith("/crm")?w("movement"):(y=i==null?void 0:i.has)!=null&&y.call(i,r)?r:n}function Nm({label:s}){return t.jsx("span",{children:s})}Nm.propTypes={label:S.node.isRequired};function jm({children:s,enabled:r,target:i}){return r?i?xr.createPortal(s,i):null:s}jm.propTypes={children:S.node.isRequired,enabled:S.bool.isRequired,target:S.object};function R0({title:s,description:r,tr:i,isDark:d,draftSettings:f,resolutions:n,spans:w,draftResolution:y,draftSpan:j,onResolutionChange:k,onSpanChange:T,onToggle:I,showIndicatorToggle:p,showSpanControl:N=!0,showAxisLabels:M=!0,showIndicatorControls:$=!0}){var H,W;const _=gr(d),Q=_.card,G=_.control,ie=m(_.row,_.interactiveRow),ne=_.mutedText,V=d?"text-white":"text-gray-700";return t.jsxs("div",{className:m("p-5 space-y-4",Q),children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx("h3",{className:"text-base font-semibold",children:s}),r&&t.jsx("p",{className:m("text-xs leading-5",ne),children:r})]}),t.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[t.jsx("span",{className:m("font-medium",V),children:i("מסגרת זמן","Time frame")}),t.jsx("select",{className:m("px-3 py-2 text-sm",G),value:f.resolutionId??((H=n[0])==null?void 0:H.id)??"",onChange:U=>k(U.target.value),children:n.map(U=>t.jsx("option",{value:U.id,title:U.description||U.label,children:U.label},U.id))}),(y==null?void 0:y.description)&&t.jsx("span",{className:m("text-xs",ne),children:y.description})]}),N&&t.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[t.jsx("span",{className:m("font-medium",V),children:i("טווח עמודות","Bar span")}),t.jsx("select",{className:m("px-3 py-2 text-sm",G),value:f.spanId??((W=w[0])==null?void 0:W.id)??"",onChange:U=>T(U.target.value),children:w.map(U=>t.jsx("option",{value:U.id,title:U.description||U.label,children:U.label},U.id))}),(j==null?void 0:j.description)&&t.jsx("span",{className:m("text-xs",ne),children:j.description})]}),M&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:m("text-sm font-medium",V),children:i("תוויות ציר Y","Y-axis labels")}),t.jsxs("label",{className:m("flex items-center justify-between px-3 py-2 text-sm",ie),children:[t.jsx("span",{children:i("מחיר אחרון","Last price")}
147),t.jsx("input",{type:"checkbox",checked:f.showLastPriceLabel,onChange:U=>I("showLastPriceLabel",U.target.checked),className:"accent-emerald-500"})]}),t.jsxs("label",{className:m("flex items-center justify-between px-3 py-2 text-sm",ie),children:[t.jsx("span",{children:i("ביד ואסק","Bid & Ask")}),t.jsx("input",{type:"checkbox",checked:f.showBidAskLabels,onChange:U=>I("showBidAskLabels",U.target.checked),className:"accent-emerald-500"})]}),t.jsxs("label",{className:m("flex items-center justify-between px-3 py-2 text-sm",ie),children:[t.jsx("span",{children:i("תוויות אינדיקטורים","Indicator labels")}),t.jsx("input",{type:"checkbox",checked:f.showIndicatorLabels,onChange:U=>I("showIndicatorLabels",U.target.checked),className:"accent-emerald-500"})]})]}),$&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:m("text-sm font-medium",V),children:i("אינדיקטורים","Indicators")}),p&&t.jsxs("label",{className:m("flex items-center justify-between px-3 py-2 text-sm",ie),children:[t.jsx("span",{children:i("אינדיקטור Alfa","Alfa indicator")}),t.jsx("input",{type:"checkbox",checked:f.indicatorEnabled,onChange:U=>I("indicatorEnabled",U.target.checked),className:"accent-emerald-500"})]}),t.jsxs("label",{className:m("flex items-center justify-between px-3 py-2 text-sm",ie),children:[t.jsx("span",{children:i("Bollinger Upper","Bollinger Upper")}),t.jsx("input",{type:"checkbox",checked:f.bollingerUpperEnabled,onChange:U=>I("bollingerUpperEnabled",U.target.checked),className:"accent-emerald-500"})]}),t.jsxs("label",{className:m("flex items-center justify-between px-3 py-2 text-sm",ie),children:[t.jsx("span",{children:i("Bollinger Lower","Bollinger Lower")}),t.jsx("input",{type:"checkbox",checked:f.bollingerLowerEnabled,onChange:U=>I("bollingerLowerEnabled",U.target.checked),className:"accent-emerald-500"})]})]})]})}function M0({initialView:s="movement"}){var ed,td,sd,nd,ad,rd,id,ld,od,cd,dd,ud,md;const{language:r,t:i}=ru(),d=r==="HE",f=r==="HE"?"he-IL":"en-US",n=x.useCallback((e,a)=>{const l=typeof a=="string",o=typeof e=="string"&&(!l||e!==a),u=l?a:e;if(!u)return"";const c=i(u);if(r==="HE"){if(o)return e;if(c&&c!==u)return c}return r==="EN"&&l?a:c&&c!==u?c:l?a:o?e:u},[r,i]),w=Ax(),y=Sx(),j=cl(y==null?void 0:y.pathname,s),k=j==="movement",T=j==="forecast",{logout:I,user:p,token:N}=zf(),M=Qf(p),$=M&&!ls,[_,Q]=g.useState(null),[G,ie]=g.useState(null),ne=x.useMemo(()=>ls&&M?bt.NETWORK:lu(y==null?void 0:y.search),[M,y==null?void 0:y.search]);g.useEffect(()=>{$&&Promise.allSettled([br(),Ll(),Rl()])},[$]);const[V,H]=x.useState(!1),W=x.useMemo(()=>{const e=typeof(p==null?void 0:p.name)=="string"?p.name.trim():"";return e||(typeof(p==null?void 0:p.email)=="string"?p.email.trim():"")||n("משתמש","User")},[p,n]),U=typeof(p==null?void 0:p.picture)=="string"?p.picture:"",{accounts:pe,reload:Y}=Pb({enabled:k||V}),K=x.useMemo(()=>Array.isArray(pe)?pe.map(e=>e.id||e.accountId||e.AccountId).filter(Boolean):[],[pe]),{balances:Le}=Rb({accountIds:K,enabled:k&&K.length>0}),O=r==="HE"?["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],[D,Z]=x.useState([]),[J,He]=x.useState([]),z=x.useMemo(()=>{const e=D.find(a=>a.default)||D[0];return(e==null?void 0:e.id)??null},[D]),oe=x.useMemo(()=>{const e=J.find(a=>a.default)||J[0];return(e==null?void 0:e.id)??null},[J]),xe=x.useMemo(()=>Ie({resolutionId:z??null,spanId:oe??null,indicatorEnabled:!!(p!=null&&p.isAdmin)}),[z,oe,p==null?void 0:p.isAdmin]),[ge,Ze]=x.useState(()=>Ie(xe)),[Ct,Et]=x.useState(()=>Ie(xe)),[pt,R]=x.useState(()=>Ie(xe)),[ke,Fe]=x.useState(()=>Ie(xe)),[P,aa]=x.useState(null),[Ut,Sn]=x.useState(null),[vr,Cn]=x.useState(!1),[ct,ra]=x.useState(!1),[Vt,Ml]=x.useState(!1),[En,ia]=x.useState(!1),[Nr,jr]=x.useState({executionEnabled:null,updatedAtUtc:null}),[Ol,la]=x.useState(!1),[_l,Dl]=x.useState(!1),[km,Am]=x.useState(0),{resolutionId:Fl,spanId:Bl,indicatorEnabled:Sm}=ge,{resolutionId:Ul}=Ct,{resolutionId:kr,spanId:Ar,indicatorEnabled:Cm,bollingerUpperEnabled:Em,bollingerLowerEnabled:Tm,showLastPrice
147Label:Pm,showBidAskLabels:Im,showIndicatorLabels:$m}=pt,{resolutionId:Vl}=ke,[Hl,Ds]=x.useState(null),Lm=x.useId(),Sr=Nr.executionEnabled??!1,[Fs,ql]=x.useState(!1),[Bs,zl]=x.useState(!1),[Ql,Us]=x.useState(null),[Wl,Kl]=x.useState(null),[Vs,Gl]=x.useState(!1),[oa,Cr]=x.useState([]),[Rm,Er]=x.useState(!1),[Xl,Tr]=x.useState(null),[ca,Mm]=x.useState("all"),[da,Yl]=x.useState("essential"),[ua,Om]=x.useState("all"),[Pr,_m]=x.useState(""),[dt,Jl]=x.useState({status:"all",health:"all",credentials:"all",search:""}),[Zl,Dm]=x.useState(0),[q,Ir]=x.useState(null),[ma,ha]=x.useState(!1),[fa,xa]=x.useState(null),[gt,eo]=x.useState(null),[$r,Lr]=x.useState(!1),[to,Rr]=x.useState(null),[de,Mr]=x.useState(null),[so,Or]=x.useState(!1),[no,ba]=x.useState(null),[ye,ao]=x.useState(null),[we,ro]=x.useState(null),[yt,Fm]=x.useState(null),[Tt,Bm]=x.useState(S0),[pa,io]=x.useState("");x.useEffect(()=>{if(!(typeof window>"u"||!window.localStorage)&&ds.some(e=>e.symbol===Tt))try{window.localStorage.setItem(vm,Tt)}catch{}},[Tt]),x.useEffect(()=>{if(!k&&!V){Cn(!1);return}let e=!0;const a=new AbortController;return(async()=>{var o;try{Cn(!0),Sn(null);const u=await Mb({signal:a.signal});if(!e)return;aa(u),Z(Array.isArray(u==null?void 0:u.resolutions)?u.resolutions:[]),He(Array.isArray(u==null?void 0:u.historySpans)?u.historySpans:[]);const c=((o=u==null?void 0:u.indicator)==null?void 0:o.mainSymbol)??(Array.isArray(u==null?void 0:u.symbols)&&u.symbols.length>0?u.symbols[0]:null);c&&(sx(c),Fm(c))}catch(u){if(a.signal.aborted||!e)return;Sn((u==null?void 0:u.message)??n("לא ניתן לטעון את תצורת התרשים","Unable to load chart configuration"))}finally{!a.signal.aborted&&e&&Cn(!1)}})(),()=>{e=!1,a.abort()}},[k,V,n]),x.useEffect(()=>{const e={resolutions:D,spans:J,defaultResolutionId:z,defaultSpanId:oe};Ze(a=>dr(a,e)),Et(a=>dr(a,e)),R(a=>dr(a,e)),Fe(a=>dr(a,e))},[D,J,z,oe]),x.useEffect(()=>{V&&(R(Ie(ge)),Fe(Ie(Ct)),ia(!!Vt))},[V,ge,Ct,Vt]),x.useEffect(()=>{if(!(p!=null&&p.isAdmin)){jr({executionEnabled:null,updatedAtUtc:null}),Ds(null),la(!1);return}const e=new AbortController;return la(!0),Db({signal:e.signal,token:N}).then(a=>{jr(a),Ds(null)}).catch(a=>{e.signal.aborted||Ds(a)}).finally(()=>{e.signal.aborted||la(!1)}),()=>e.abort()},[km,N,p==null?void 0:p.isAdmin]),x.useEffect(()=>{const e=(a,l)=>a.indicatorEnabled===l?a:{...a,indicatorEnabled:l};p!=null&&p.isAdmin?ct||(Ze(a=>e(a,!0)),Et(a=>e(a,!0)),R(a=>e(a,!0)),Fe(a=>e(a,!0))):(Ze(a=>e(a,!1)),Et(a=>e(a,!1)),R(a=>e(a,!1)),Fe(a=>e(a,!1)))},[p==null?void 0:p.isAdmin,ct]),x.useEffect(()=>{if(!(p!=null&&p.isAdmin)||!V){Cr([]),Tr(null),Er(!1);return}let e=!0;const a=new AbortController;return Er(!0),Bb({limit:50,signal:a.signal}).then(l=>{e&&(Cr(l),Tr(null))}).catch(l=>{!a.signal.aborted&&e&&Tr((l==null?void 0:l.message)??n("לא ניתן לטעון את יומן המערכת","Unable to load system logs"))}).finally(()=>{!a.signal.aborted&&e&&Er(!1)}),()=>{e=!1,a.abort()}},[V,N,n,p==null?void 0:p.isAdmin]),x.useEffect(()=>{if(!(p!=null&&p.isAdmin)||!V)return;const e=Ub(a=>{Cr(l=>{const o=[a,...l];return o.length<=200?o:o.slice(0,200)})},N?{}:{});return()=>{typeof e=="function"&&e()}},[V,N,p==null?void 0:p.isAdmin]),x.useEffect(()=>{if(!(p!=null&&p.isAdmin)||!V){Ir(null),xa(null),ha(!1);return}if(!N){Ir(null),xa(n("נדרשת התחברות","Authentication required")),ha(!1);return}let e=!0,a,l;const o=async u=>{if(e){u&&ha(!0),xa(null),l&&l.abort(),l=new AbortController;try{const c=await fetch($e("/admin/system/status"),{method:"GET",signal:l.signal,headers:{Authorization:`Bearer ${N}`}});if(!c.ok){let v=`Failed to load system status (${c.status})`;try{const A=await c.json();v=(A==null?void 0:A.error)||(A==null?void 0:A.Error)||(A==null?void 0:A.message)||v}catch{}throw new Error(v)}const b=await c.json();if(!e)return;Ir(b)}catch(c){!l.signal.aborted&&e&&xa((c==null?void 0:c.message)??n("לא ניתן לטעון את מצב המערכת","Unable to load system status"))}finally{!l.signal.aborted&&e&&u&&ha(!1)}e&&(a=window.setTimeout(()=>o(!1),15e3))}};return o(!0),()=>{e=!1,l&&l.abort(),a&&window.clearTimeout(a)}},[Zl,V,N,n,p==null?void 0:p.isAdmin]),x.useEffect(()=>{if(!(p!=null&&p.isAdmin)||!V){eo(null),Rr(null),Lr(!1);return}let e=!0,a,l;const o=async u=>
147{if(e){u&&Lr(!0),Rr(null),l&&l.abort(),l=new AbortController;try{const c=await fetch($e("/health"),{method:"GET",signal:l.signal,headers:{Accept:"application/json"}});if(!c.ok)throw new Error(`Failed to load health status (${c.status})`);const b=await c.json();if(!e)return;eo(b)}catch(c){!l.signal.aborted&&e&&Rr((c==null?void 0:c.message)??n("לא ניתן לטעון את מצב הבריאות","Unable to load health status"))}finally{!l.signal.aborted&&e&&u&&Lr(!1)}e&&(a=window.setTimeout(()=>o(!1),3e4))}};return o(!0),()=>{e=!1,l&&l.abort(),a&&window.clearTimeout(a)}},[Zl,V,n,p==null?void 0:p.isAdmin]),x.useEffect(()=>{if(!(p!=null&&p.isAdmin)||!V){Mr(null),ba(null),Or(!1);return}let e=!0;const a=new AbortController;Or(!0),Wf({signal:a.signal}).then(o=>{e&&(Mr(o),ba(null))}).catch(o=>{!a.signal.aborted&&e&&ba((o==null?void 0:o.message)??n("לא ניתן לטעון את מצב הסטרימינג","Unable to load streaming snapshot"))}).finally(()=>{!a.signal.aborted&&e&&Or(!1)});const l=Kf(o=>{Mr(o),ba(null)},N?{accessToken:N}:{});return()=>{e=!1,a.abort(),typeof l=="function"&&l()}},[V,N,n,p==null?void 0:p.isAdmin]),x.useEffect(()=>{var o,u;const e=(o=P==null?void 0:P.indicator)==null?void 0:o.mainSymbol,a=(u=P==null?void 0:P.indicator)==null?void 0:u.referenceSymbol;if(!e&&!a)return;if(e){const c=gd(e);c&&ao(c)}if(a){const c=gd(a);c&&ro(c)}const l=Zi(c=>{if(!(c!=null&&c.symbol))return;const b=c.symbol.toUpperCase();e&&b===e.toUpperCase()&&ao(c),a&&b===a.toUpperCase()&&ro(c)},{accessToken:N||void 0,symbols:[e,a].filter(Boolean)});return()=>{typeof l=="function"&&l()}},[(ed=P==null?void 0:P.indicator)==null?void 0:ed.mainSymbol,(td=P==null?void 0:P.indicator)==null?void 0:td.referenceSymbol,N]);const Um=x.useMemo(()=>{const e=new Set;
147return oa.forEach(a=>{a!=null&&a.context&&e.add(a.context)}),Array.from(e).sort((a,l)=>a.localeCompare(l))},[oa]),lo=x.useMemo(()=>{const e=new Set(["program-control","strategy","sites-core-data"]),a=/(disabled|idle|failed|error|warning|paused|resumed|reconnect|restart|goaway|unauthorized|backfill|fallback|stale|degraded)/i,l=Pr.trim().toLowerCase();return oa.filter(o=>{if(!o)return!1;const u=typeof o.level=="string"?o.level.toLowerCase():"info",c=typeof o.context=="string"?o.context.toLowerCase():"",b=typeof o.message=="string"?o.message:"";if(da==="essential"&&!(u==="error"||u==="warning")){if(!e.has(c)){if(!(c==="streaming"&&a.test(b)))return!1}}return!(ca!=="all"&&u!==ca||ua!=="all"&&c!==ua.toLowerCase()||l&&!`${b} ${o.context??""} ${o.level??""}`.toLowerCase().includes(l))})},[ua,ca,da,Pr,oa]),wt=x.useMemo(()=>D.find(e=>e.id===Fl),[D,Fl]),Hs=x.useMemo(()=>J.find(e=>e.id===Bl),[J,Bl]),oo=x.useMemo(()=>D.find(e=>e.id===Ul),[D,Ul]),co=x.useMemo(()=>P0(oo),[oo]),Re=x.useMemo(()=>ds.find(e=>e.symbol===Tt)??ds[0],[Tt]),_r=x.useMemo(()=>{const e=pa.trim().toLowerCase();return e?ds.filter(a=>[a.label,a.name,a.market,a.symbol].some(l=>String(l||"").toLowerCase().includes(e))):ds},[pa]),Vm=x.useCallback(e=>{Bm(e)},[]),uo=x.useMemo(()=>{const e=new Set;
147return[[wt==null?void 0:wt.id,Hs==null?void 0:Hs.id]].forEach(([a,l])=>{a&&l&&e.add(`${a}:${l}`)}),e},[wt==null?void 0:wt.id,Hs==null?void 0:Hs.id]),Hm=x.useMemo(()=>{if(!D.length||!J.length)return[];const e=D.map(u=>({id:u.id,config:C0(u)})),a=[];for(const u of e)for(const c of J){const b=I0(u.config,c),v=b?{barsback:b}:void 0,A=$0(u.config,v),C=uo.has(`${u.id}:${c.id}`);a.push({resolution:u.config,history:v,key:A,isActive:C})}a.sort((u,c)=>u.isActive===c.isActive?0:u.isActive?-1:1);const l=[],o=new Set;for(const u of a)o.has(u.key)||(o.add(u.key),l.push({resolution:u.resolution,history:u.history}));return l},[D,J,uo]),Dr=x.useRef(null);g.useEffect(()=>{Dr.current&&(Dr.current(),Dr.current=null)},[P==null?void 0:P.indicator,k,Hm,Sm,yt,N]);const ga=x.useMemo(()=>D.find(e=>e.id===kr),[D,kr]),ya=x.useMemo(()=>J.find(e=>e.id===Ar),[J,Ar]),qm=x.useMemo(()=>D.find(e=>e.id===Vl),[D,Vl]),wa=x.useMemo(()=>{const e=(wt==null?void 0:wt.config)??wt,a=Number(e==null?void 0:e.interval);if(!Number.isFinite(a)||a<=0)return null;const l=typeof(e==null?void 0:e.unit)=="string"?e.unit.trim().toLowerCase():"";let o=a;l.startsWith("hour")?o=a*60:l.startsWith("day")?o=a*60*24:l.startsWith("week")?o=a*60*24*7:l.startsWith("month")&&(o=a*60*24*30);const u=o*60*1e3;return Number.isFinite(u)&&u>0?u:null},[wt]),mo=x.useCallback(e=>!Number.isFinite(e)||!Number.isFinite(wa)||wa<=0?null:String(Math.floor(e/wa)),[wa]),Fr=x.useCallback(()=>{Ze(Ie(pt)),Et(Ie(ke)),Ml(!!En)},[pt,ke,En]),zm=x.useCallback(()=>{R(Ie(ge)),Fe(Ie(Ct)),ia(!!Vt)},[ge,Ct,Vt]),Qm=x.useCallback(async()=>{Fr(),sc(!0),ac(null),hi(!1);const e={primary:eu(pt),secondary:eu(ke),icebergEnabled:!!En};try{await el(Kd,e),hi(!0),setTimeout(()=>hi(!1),1200)}catch(a){ac((a==null?void 0:a.message)??n("לא ניתן לשמור את ההגדרות","Unable to save default settings"))}finally{sc(!1)}},[Fr,En,pt,ke,n]),[ho,Br]=x.useState(null),[Wm,va]=x.useState(null),[et,fo]=x.useState(null),[Km,Xt]=x.useState(!0),[Gm,Tn]=x.useState(null),[Xm,Na]=x.useState(null),[xo,bo]=x.useState(0),ja=x.useMemo(()=>Eb({enabled:!!(N&&(p!=null&&p.isAdmin)),refresh:()=>Sb({accessToken:N})}),[N,p==null?void 0:p.isAdmin]),ka=x.useRef(null),xs=x.useRef(null),Aa=x.useRef(!1),Sa=x.useMemo(()=>et?JSON.stringify(et):"",[et]),Ym=x.useCallback(e=>{const a=e&&Array.isArray(e.selections)&&e.selections.length?e:null;fo(l=>{const o=l?JSON.stringify(l):"",u=a?JSON.stringify(a):"";return o===u?l:a})},[]);g.useEffect(()=>{let e=!0;if(!N)return va(null),Br(null),fo(null),Tn(null),Xt(!1),()=>{e=!1};if(!T||Sa)return Xt(!1),()=>{e=!1};const a=new AbortController,l=u=>{if(!e)return;const c=Array.isArray(u==null?void 0:u.strategies)&&u.strategies.length>0;va(c?u:null),c||(Br(null),Xt(!1))};return(async()=>{try{Aa.current||Xt(!0);const u=await Pd({signal:a.signal,accessToken:N});if(a.signal.aborted||!e)return;l(u)}catch(u){!a.signal.aborted&&e&&(va(null),Tn(u),Xt(!1))}})(),()=>{e=!1,a.abort()}},[T,N,xo,Sa]),g.useEffect(()=>{if(Na(null),!N||!(p!=null&&p.isAdmin)||!T)return;let e=!0,a=null,l=!1;const o=()=>{a!==null&&window.clearTimeout(a),a=null},u=async()=>{var b;if(o(),!(!e||l||document.visibilityState!=="visible")){l=!0;try{const v=await ja.run();if(!e||!v)return;Na((b=v.warnings)!=null&&b.length?{partial:!0,message:v.warnings.join("; ")}:null),bo(A=>A+1)}catch(v){e&&Na(v)}finally{l=!1,e&&document.visibilityState==="visible"&&(a=window.setTimeout(u,Td(Date.now())))}}},c=()=>{document.visibilityState==="visible"?u():o()};return u(),document.addEventListener("visibilitychange",c),()=>{e=!1,o(),document.removeEventListener("visibilitychange",c)}},[N,p==null?void 0:p.isAdmin,T,ja]),g.useEffect(()=>{let e=!0;if(!N||!T||!Sa)return Xt(!1),()=>{e=!1};const a=()=>{ka.current!==null&&(window.clearTimeout(ka.current),ka.current=null)},l=(c=0)=>{a(),ka.current=window.setTimeout(()=>{if(typeof document<"u"&&document.visibilityState!=="visible"){a();return}o({background:!0,refreshAttempt:c})},Td(Date.now(),c))},o=async({background:c=!1,refreshAttempt:b=null}={})=>{var L;const v=!c&&!Aa.current;(L=xs.current)==null||L.abort();const A=new AbortController;xs.current=A;const C=()=>e&&!A.signal.aborted&&xs.current===A,E=B=>{if(!C())return;const te=Array.isArray(B==null?void 0:B.strategies)&&B.strategies.length>0;Br(te?B:null),Tn(null),Aa.current=!0};try{v&&Xt(!0),c||Tn(null);const B=await Pd({signal:A.signal,accessToken:N});if(!C())return;va(B);const te=await Cb({signal:A.signal,selections:et==null?void 0:et.selections,from:et==null?void 0:et.from,to:et==null?void 0:et.to,accessToken:N});E(te)}catch(B){C()&&Tn(B)}finally{const B=C();xs.current===A&&(xs.current=null),B&&(Xt(!1),l(Nb(b)))}},u=()=>{if(typeof document<"u"&&document.visibilityState!=="visible"){a();return}a(),o({background:Aa.current})};return o(),typeof document<"u"&&document.addEventListener("visibilitychange",u),()=>{var c;e=!1,a(),typeof document<"u"&&document.removeEventListener("visibilitychange",u),(c=xs.current)==null||c.abort(),xs.current=null}},[et,Sa,T,N,xo]);const[,Ur]=g.useState(null),[,Vr]=g.useState(null),[,Hr]=g.useState(null),[Jm,qs]=g.useState(!1),qr=x.useRef(null),zr=x.useRef(null),[Yt,Qr]=g.useState(v0),[Zm,po]=g.useState(0),[Ca,go]=g.useState(""),[eh,th]=g.useState(()=>[{id:"welcome",author:"system",direction:"incoming",text:n("ברוכים הבאים לצ'אט! איך אפשר לעזור?","Welcome to the chat! How can we help?"),timestamp:Date.now()}]),[bs,Jt]=g.useState(!1),[qe,Wr]=g.useState(""),[ut,Ea]=g.useState("1"),[vt,zs]=g.useState("0"),[Qs,Kr]=g.useState(null),[Ws,Gr]=g.useState(null),[tt,yo]=g.useState(!1),[w
147o,Pn]=g.useState(null),Xr=x.useRef(new Map),[ce,Ks]=g.useState(null),[In,Gs]=g.useState(!1),[Ht,ps]=g.useState(""),[ze,vo]=g.useState(!1),[O0,No]=g.useState({current:0,total:0}),[$n,jo]=g.useState({}),[ko,sh]=g.useState(new Set),[Pt,Xs]=g.useState(null),Me=x.useRef(null);g.useEffect(()=>()=>{Me.current&&(window.clearTimeout(Me.current),Me.current=null)},[]),g.useEffect(()=>{if(!Pt||typeof document>"u")return;const e=a=>{const l=a==null?void 0:a.target;if(!(l instanceof Element)){Xs(null);return}l.closest(`[data-cancel-order-id="${Pt}"]`)||(Xs(null),Me.current&&(window.clearTimeout(Me.current),Me.current=null))};return document.addEventListener("pointerdown",e,!0),()=>document.removeEventListener("pointerdown",e,!0)},[Pt]),g.useEffect(()=>{if(bs||In){const e=qe||yt||tl();!ce&&bs&&(Wr(e),Ea("1"),zs("0")),Kr(null),Gr(null);const a=new AbortController;return yd({symbols:[e],signal:a.signal}).then(l=>{if(console.log("Quote snapshot:",l),l&&(l.Quotes||l.quotes)&&(l.Quotes||l.quotes).length>0){const u=(l.Quotes||l.quotes)[0];Kr(u.Bid??u.bid),Gr(u.Ask??u.ask);const c=u.Last??u.last??u.LastPrice??u.lastPrice??u.Close??u.close??0;!ce&&bs&&zs(String(c))}}).catch(l=>{l.name!=="AbortError"&&console.error("Failed to fetch quotes",l)}),()=>a.abort()}},[bs,In,yt,ce,qe]),g.useEffect(()=>{if(!bs&&!In)return;const e=qe||yt||tl();if(!e)return;console.log("[Quote Streaming] Subscribing to quote updates for symbol:",e);const a=Zi(l=>{console.log("[Quote Streaming] Received quote update:",l.symbol,"Bid:",l.bid,"Ask:",l.ask),l.symbol&&l.symbol.toUpperCase()===e.toUpperCase()&&(console.log("[Quote Streaming] Quote matches our symbol, updating Bid/Ask"),l.bid!==null&&Kr(l.bid),l.ask!==null&&Gr(l.ask))},{symbols:[e]});return()=>{console.log("[Quote Streaming] Unsubscribing from quote updates"),a()}},[bs,In,qe,yt]),g.useEffect(()=>{const e=Gf(yt||tl()),a=typeof e=="string"?e.trim().toUpperCase():"";if(!N||!a){Ur(null),Vr(null),Hr(null);return}const l=new AbortController;yd({symbols:[e],signal:l.signal}).then(u=>{const c=(u==null?void 0:u.Quotes)||(u==null?void 0:u.quotes)||[];if(!Array.isArray(c)||c.length===0)return;const b=c[0],v=(b==null?void 0:b.Last)??(b==null?void 0:b.last)??(b==null?void 0:b.LastPrice)??(b==null?void 0:b.lastPrice)??(b==null?void 0:b.Close)??(b==null?void 0:b.close),A=(b==null?void 0:b.Bid)??(b==null?void 0:b.bid),C=(b==null?void 0:b.Ask)??(b==null?void 0:b.ask);Number.isFinite(v)&&Ur(Number(v)),Number.isFinite(A)&&Vr(Number(A)),Number.isFinite(C)&&Hr(Number(C))}).catch(u=>{(u==null?void 0:u.name)!=="AbortError"&&console.warn("[movement-quote] Failed to fetch quote snapshot",u)});const o=Zi(u=>{if(!(u!=null&&u.symbol)||u.symbol.toUpperCase()!==a)return;const c=Number.isFinite(u.last)?u.last:Number.isFinite(u.close)?u.close:null;Number.isFinite(c)&&Ur(c),Number.isFinite(u.bid)&&Vr(u.bid),Number.isFinite(u.ask)&&Hr(u.ask)},{symbols:[e],accessToken:N});return()=>{l.abort(),o()}},[yt,N]);const[Ln,Ys]=g.useState(null),[Rn,Ta]=g.useState("positions"),[Ao,gs]=g.useState(null),[So,nh]=g.useState(!1),[Nt,Zt]=g.useState(!1),[ys,ah]=g.useState({VX:!1,ES:!1,Other:!1,Cash:!1}),[rh,Co]=g.useState({VX:!1,ES:!1,Other:!1,Historical:!1}),[Eo,To]=g.useState([]),[Yr,Jr]=g.useState(!1),jt=x.useMemo(()=>new Set(Eo),[Eo]),Qe=x.useCallback(()=>n("כל החשבונות","All Accounts"),[n]),[ve,es]=g.useState(()=>Qe());g.useEffect(()=>{const e=Qe();(ve==="כל החשבונות"||ve==="All Accounts")&&ve!==e&&es(e)},[r,Qe,ve]);const Zr=x.useRef(null),Po=x.useRef(null),Io=x.useRef(null),$o=x.useRef(null),Lo=x.useRef(null),[Ro,ih]=g.useState(null),[lh,oh]=g.useState(0),[st,ts]=g.useState("General"),[ch,Pa]=g.useState(""),[dh,ss]=g.useState([]),[ei,qt]=g.useState(null),[Js,Zs]=g.useState(!1),[Mn,ti]=g.useState(!1),[uh,Mo]=g.useState(!1),[Oo,en]=g.useState(null),[mh,tn]=g.useState(!1),[It,si]=g.useState(!1),[_o,sn]=g.useState(null),[F,We]=g.useState({name:"",number:"",broker:"TRADESTATION",m1Prefix:"VX",apiKey:"",apiSecret:"",refreshToken:"",percent:"1",enabled:!0,avatar:"",userEmail:"",assignedEmails:[]}),[Do,ni]=g.useState({}),[Fo,ws]=g.useState(null),nn=x.useRef(null),[Bo,an]=g.useState(null),rn=x.useRef(null),[ai,On]=g.useState(!1),[ee,nt]=g.useState({accountId:"",name:"",userEmail:"",broker:"TRADESTATION",m1Prefix:"VX",apiKey:"",apiSecret:"",refreshToken:"",percent:"1",enabled:!0,avatar:""}),[ri,Uo]=g.useState(!1),[Vo,Ia]=g.useState(null),[$a,Ho]=g.useState(!1),[ii,_n]=g.useState(null),kt=x.useMemo(()=>im(),[]),[vs,qo]=g.useState(kt.enabled),[Ns,La]=g.useState(kt.systemNotifications),[Dn,zo]=g.useState(kt.inAppToasts),[Fn,Qo]=g.useState(kt.badge),[Bn,Wo]=g.useState(kt.routingMode),[js,Ko]=g.useState(kt.privacyMode),[ks,Go]=g.useState(kt.quietHours.endTime),[As,Xo]=g.useState(kt.quietHours.startTime),[Ss,li]=g.useState(()=>Nl(kt.events)),mt=x.useMemo(()=>({orders:!1,entries:!1}),[]),[ht,Yo]=g.useState(kt.sound.name),[Ke,Jo]=g.useState(!kt.sound.enabled),Zo=x.useId(),[ln,oi]=g.useState(()=>il()),[hh,fh]=g.useState(()=>wn()),[Cs,zt]=g.useState("idle"),[Ra,on]=g.useState(null),[Ma,cn]=g.useState(null),[Oa,ci]=g.useState([]),[Un,ec]=g.useState([]),[di,ui]=g.useState(!1),[xh,tc]=g.useState(null),[mi,sc]=g.useState(!1),[bh,hi]=g.useState(!1),[nc,ac]=g.useState(null),[dn,rc]=g.useState(!1),[ph,fi]=g.useState(!1),[ic,lc]=g.useState(null),[gh,oc]=g.useState(!1),[yh,cc]=g.useState(null),dc=x.useRef(null),Es=x.useRef(null),xi=x.useRef(new Set),uc=x.useRef(new Map),_a=x.useRef(new Map),bi=x.useRef(A0()),[$t,mc]=g.useState(()=>{var e;if(typeof window<"u"){try{const a=localStorage.getItem("crm_theme");if(a==="dark"||a==="light")return a}catch{}if((e=window.matchMedia)!=null&&e.call(window,"(prefers-color-scheme: dark)").matches)return"dark"}return"light"}),[wh,pi]=g.useState(!1),hc=x.useMemo(()=>wl(Zd({enabled:vs,systemNotifications:Ns,inAppToasts:Dn,badge:Fn,routingMode:Bn,privacyMode:js,quietStartTime:As,quietEndTime:ks,soundName:ht,soundMuted:Ke,eventRules:Ss})),[As,ht,Ke,ks,Dn,Fn,Ss,js,Bn,vs,Ns]),Vn=x.useMemo(()=>Oa.filter(e=>!e.readAt).length,[Oa]),gi=x.useCallback(async()=>{rc(!0),lc(null),fi(!1);const e=Zd({enabled:vs,systemNotifications:Ns,inAppToasts:Dn,badge:Fn,routingMode:Bn,privacyMode:js,quietStartTime:As,quietEndTime:ks,soundName:ht,soundMuted:Ke,eventRules:Ss});try{return await el(Xd,e),fi(!0),setTimeout(()=>fi(!1),1200),!0}catch(a){return lc((a==null?void 0:a.message)??n("לא ניתן לשמור את ההגדרות","Unable to save default settings")),!1}finally{rc(!1)}},[As,ht,Ke,ks,Dn,Fn,Ss,js,Bn,vs,Ns,n]),vh=x.useCallback(async()=>{await gi()&&H(!1)},[gi,H]),yi=x.useCallback(async e=>{const a=e==="dark"||e==="light"?e:$t;oc(!0),cc(null),pi(!1);const l={themeMode:a};try{await el(Yd,l),pi(!0),setTimeout(()=>pi(!1),1200)}catch(o){cc((o==null?void 0:o.message)??n("לא ניתן לשמור את ההגדרות","Unable to save default settings"))}finally{oc(!1)}},[$t,n]),Nh=x.useCallback(e=>
147{e!==$t&&(mc(e),wd(e),yi(e))},[yi,$t]),un=x.useMemo(()=>{var a;if(typeof window>"u")return!1;const e=window.Capacitor;return!!((a=e==null?void 0:e.isNativePlatform)!=null&&a.call(e))},[]),At=!un&&hh,at=un;g.useEffect(()=>{fh(wn()),oi(il())},[il,wn]),g.useEffect(()=>{if(!at||!N||!ct||!vs||!Ns||Cs!=="idle")return;const e=cr();if(!e)return;(async()=>{zt("registering");try{await Yn({token:e,platform:gn(),deviceId:bi.current}),zt("ready")}catch{zt("error")}})()},[gn,ct,vs,Ns,Cs,cr,Yn,at,N]);const mn=x.useCallback(e=>{var l;const a=e==null?void 0:e.reason;return a==="unsupported"?n("הדפדפן לא תומך בהתראות.","This browser does not support notifications."):a==="insecure-context"?n("התראות דפדפן זמינות רק ב-HTTPS (או localhost).","Browser notifications require HTTPS (or localhost)."):a==="blocked-policy"?n('ההתראות נחסמו ע"י מדיניות הרשאות (Permissions-Policy).',"Notifications are blocked by Permissions Policy."):a==="permission"?n("יש לאשר הרשאות התראות בדפדפן.","Allow notification permission in the browser."):a==="error"&&((l=e==null?void 0:e.error)!=null&&l.message)?n(`ההתראה נחסמה: ${e.error.message}`,`Notification blocked: ${e.error.message}`):n("הדפדפן חסם את ההתראה. בדוק הרשאות דפדפן/מערכת.","Browser blocked the notification. Check browser/OS settings.")},[n]),Da=x.useCallback(async()=>{if(!at)return{status:"unsupported",token:null};const e=cr();if(zt("registering"),e)try{return await Yn({token:e,platform:gn(),deviceId:bi.current}),zt("ready"),{status:"granted",token:e}}catch{zt("error")}try{const a=await qd({allowPrompt:!0});return(a==null?void 0:a.status)!=="granted"||!(a!=null&&a.token)?(zt((a==null?void 0:a.status)==="denied"?"denied":"error"),{status:(a==null?void 0:a.status)??"error",token:null}):(Ud(a.token),await Yn({token:a.token,platform:gn(),deviceId:bi.current}),zt("ready"),{status:"granted",token:a.token})}catch{return zt("error"),{status:"error",token:null}}},[gn,cr,qd,Yn,at,Ud]),jh=x.useCallback(async e=>{if(La(e),cn(null),!!e){if(At){const a=ln==="granted"?"granted":await lr();oi(a),a!=="granted"&&(La(!1),cn(mn({reason:"permission"})));return}if(at){const a=await Da();(a==null?void 0:a.status)!=="granted"&&(La(!1),cn(n("לא ניתן להפעיל התראות פוש","Unable to enable push notifications")))}}},[ln,Da,lr,mn,At,at,n]),kh=x.useCallback(async()=>{cn(null),on(null);const e=n("התראת אלפא","ALFA Alert"),a=n("זוהי התראת בדיקה.","This is a test alert.");let l=!1,o=null,u=null;if(At)if(ln==="granted"){const c=$s({title:e,body:a});c!=null&&c.ok?(l=!0,on(n("נשלחה התראת דפדפן","Browser notification sent")),Rs({count:1}),Ls({sound:ht,muted:Ke,onlyWhenVisible:!0})):o=mn(c)}else{const c=await lr();if(oi(c),c==="granted"){const b=$s({title:e,body:a});b!=null&&b.ok?(l=!0,on(n("נשלחה התראת דפדפן","Browser notification sent")),Rs({count:1}),Ls({sound:ht,muted:Ke,onlyWhenVisible:!0})):o=mn(b)}else c!=="default"&&(o=mn({reason:"permission"}))}if(at){let c=Cs;if(c!=="ready"){const b=await Da();c=(b==null?void 0:b.status)==="granted"?"ready":(b==null?void 0:b.status)??Cs}if(c!=="ready")l||(u=c==="denied"?n("נדחה - אפשר להפעיל בהגדרות המכשיר","Denied - enable in device settings"):c==="registering"?n("נרשם...","Registering..."):n("לא ניתן להפעיל התראות פוש","Unable to enable push notifications"));else try{const b=await zd({title:e,body:a});l=!0,typeof(b==null?void 0:b.succeeded)=="number"?on(n(`נשלחו ${b.succeeded} התראות`,`Sent ${b.succeeded} notifications`)):on(n("נשלחה התראת פוש","Push notification sent"))}catch(b){l||(u=(b==null?void 0:b.message)??n("שליחת הפוש נכשלה","Push notification failed"))}}l||cn(u??o??n("יש להפעיל התראות כדי לבדוק.","Enable notifications to run the test."))},[ln,ht,Ke,Da,Cs,Ls,lr,mn,zd,Rs,At,at,$s,n]),[X,Ah]=g.useState(()=>typeof window>"u"?un:un||window.innerWidth<1024),[Sh,Fa]=g.useState(null);x.useLayoutEffect(()=>{if(!(p!=null&&p.isAdmin)||!Zr.current)return;const e=Qe();if(ve!==e)return;const a=Zr.current.getBoundingClientRect().width;if(!a)return;const l=Math.ceil(a);ih(o=>
147o===l?o:l)},[Qe,ve,p==null?void 0:p.isAdmin]),x.useLayoutEffect(()=>{const e=Po.current;if(!e)return;const a=()=>{const o=Math.ceil(e.getBoundingClientRect().height);oh(u=>u===o?u:o)};if(a(),typeof ResizeObserver>"u")return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a);const l=new ResizeObserver(()=>a());return l.observe(e),()=>l.disconnect()},[]),x.useLayoutEffect(()=>{const e=Io.current,a=$o.current,l=Lo.current;if(!e||!a||!l)return;const o=()=>{const c=l.offsetTop>a.offsetTop+2;nh(b=>b===c?b:c)};o();let u;return typeof ResizeObserver<"u"?(u=new ResizeObserver(()=>{o()}),u.observe(e)):window.addEventListener("resize",o),()=>{u?u.disconnect():window.removeEventListener("resize",o)}},[]);const[Ch,Eh]=g.useState(64),Ba=x.useRef(!1),wi=x.useRef(null);x.useEffect(()=>{const e=l=>{if(!Ba.current||!wi.current)return;const u=wi.current.getBoundingClientRect(),c=l.clientX-u.left,A=u.width-24;let C=c/A*100;C=Math.max(30,Math.min(70,C)),Eh(C)},a=()=>{Ba.current&&(Ba.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",a),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",a)}},[]);const Th=x.useCallback(e=>{e.preventDefault(),Ba.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]),Ph=x.useCallback(()=>{var e;(e=nn.current)==null||e.click()},[]),Ih=x.useCallback(()=>{var e;(e=rn.current)==null||e.click()},[]),hn=x.useRef(null),fc=x.useRef(Yt),vi=x.useCallback(e=>{th(a=>[...a,e])},[]),Ni=x.useCallback(()=>{const e=Ca.trim();if(!e)return;const a={id:`user-${Date.now()}`,author:"user",direction:"outgoing",text:e,timestamp:Date.now()};vi(a),go(""),Qr(ae.EXPANDED),hn.current&&clearTimeout(hn.current),hn.current=setTimeout(()=>{vi({id:`bot-${Date.now()}`,author:"system",direction:"incoming",text:n("תודה שפנית אלינו! נחזור אליך בהקדם.","Thanks for reaching out! We'll get back to you shortly."),timestamp:Date.now()}),Sp(fc.current)&&po(l=>l+1),hn.current=null},900)},[vi,Ca,n]),xc=x.useMemo(()=>new Intl.DateTimeFormat(f,{hour:"2-digit",minute:"2-digit"}),[f]),$h=x.useCallback(e=>{try{return xc.format(new Date(e))}catch{return""}},[xc]),Lh=x.useCallback(e=>{var a;(a=e.nativeEvent)!=null&&a.isComposing||e.isComposing||e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),Ni())},[Ni]);g.useEffect(()=>{if(fc.current=Yt,Yt===ae.EXPANDED&&po(0),!!Ap(Yt))try{window.localStorage.setItem(wm,Yt)}catch{}},[Yt]),x.useEffect(()=>()=>{hn.current&&clearTimeout(hn.current)},[]);const Rh=Ca.trim().length>0,Mh=x.useCallback(e=>{const a=e.target,l=a.files&&a.files[0];if(!l)return;if(l.size>2*1024*1024){ws(n("הקובץ גדול מדי (מקסימום 2MB)","File is too large (max 2MB)")),a.value="";return}const o=new FileReader;o.onload=()=>{typeof o.result=="string"&&(We(u=>({...u,avatar:o.result})),ws(null))},o.onerror=()=>{ws(n("נכשל בטעינת התמונה","Failed to load image"))},o.readAsDataURL(l),a.value=""},[n]),Oh=x.useCallback(()=>{We(e=>({...e,avatar:""})),ws(null),nn.current&&(nn.current.value="")},[]),_h=x.useCallback(e=>{const a=e.target,l=a.files&&a.files[0];if(!l)return;if(l.size>2*1024*1024){an(n("הקובץ גדול מדי (מקסימום 2MB)","File is too large (max 2MB)")),a.value="";return}const o=new FileReader;o.onload=()=>{typeof o.result=="string"&&(nt(u=>({...u,avatar:o.result})),an(null))},o.onerror=()=>{an(n("נכשל בטעינת התמונה","Failed to load image"))},o.readAsDataURL(l),a.value=""},[n]),Dh=x.useCallback(()=>{nt(e=>({...e,avatar:""})),an(null),rn.current&&(rn.current.value="")},[]);g.useEffect(()=>{!Js&&nn.current&&(nn.current.value="",ws(null))},[Js]),g.useEffect(()=>{!ai&&rn.current&&(rn.current.value="",an(null))},[ai]),g.useEffect(()=>{Js||(tn(!1),sn(null),si(!1))},[Js]);const Fh=x.useCallback(async e=>{e.preventDefault();const a=(ee.accountId||"").trim(),l=(ee.name||"").trim();if(!a||!l){Ia(n("נא למלא את כל השדות","Please fill in all fields"));return}if(!N){Ia(n("נדרשת התחברות","Authentication required"));return}Uo(!0),Ia(null);try{const o=parseFloat(ee.percent),u=(ee.userEmail||"").trim(),c=await fetch($e("/admin/accounts"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${N}`},body:JSON.stringify({accountId:a,name:l,userEmail:u||null,broker:ee.broker||null,apiKey:ee.apiKey||null,apiSecret:ee.apiSecret||null,refreshToken:ee.refreshToken||null,isActive:!!ee.enabled,percentToTrade:isNaN(o)?null:o,m1Prefix:ee.m1Prefix||null})});if(!c.ok){const b=await c.json();throw new Error(b.Error||"Failed to add account")}ni(b=>{const v=(a||l||"").trim();return!v||!ee.avatar?b:{...b,[v]:ee.avatar}}),On(!1),nt({accountId:"",name:"",userEmail:"",broker:"TRADESTATION",m1Prefix:"VX",apiKey:"",apiSecret:"",refreshToken:"",percent:"1",enabled:!0,avatar:""}),an(null),Y()}catch(o){Ia(o.message)}finally{Uo(!1)}},[ee,n,N,Y]),Bh=x.useCallback(async()=>
147{if(!N){_n({type:"error",text:n("נדרשת התחברות","Authentication required")});return}Ho(!0),_n(null);try{const e=await fetch($e("/admin/streaming/reload"),{method:"POST",headers:{Authorization:`Bearer ${N}`}});if(!e.ok){let l=`Failed to reload streaming (${e.status})`;try{const o=await e.json();l=(o==null?void 0:o.error)||(o==null?void 0:o.Error)||l}catch{}throw new Error(l)}const a=await e.json();_n({type:"success",text:a.message||n("הסטרימינג נטען מחדש בהצלחה","Streaming reloaded successfully")}),setTimeout(()=>_n(null),5e3)}catch(e){_n({type:"error",text:(e==null?void 0:e.message)||n("נכשל לטעון מחדש את הסטרימינג","Failed to reload streaming")})}finally{Ho(!1)}},[N,n]),bc=x.useCallback(async(e,a,l,o)=>{if(!N)return{name:a||"",number:e,broker:"TRADESTATION",m1Prefix:"VX",apiKey:"",apiSecret:"",refreshToken:"",percent:"1",enabled:l,avatar:o||"",userEmail:"",assignedEmails:[]};Mo(!0);try{console.log("[fetchAccountDetails] Fetching account:",e,"encoded:",encodeURIComponent(e));const u=await fetch($e(`/admin/accounts/${encodeURIComponent(e)}`),{method:"GET",headers:{Authorization:`Bearer ${N}`}});if(!u.ok){let v=`Failed to fetch account details (${u.status})`;try{const A=await u.json();v=(A==null?void 0:A.error)||(A==null?void 0:A.Error)||(A==null?void 0:A.message)||v,console.error("[fetchAccountDetails] Server error:",A)}catch{}throw new Error(v)}const c=await u.json(),b=Array.isArray(c==null?void 0:c.assignedEmails)?c.assignedEmails:Array.isArray(c==null?void 0:c.AssignedEmails)?c.AssignedEmails:[];return{name:c.name||a||"",number:c.accountId||e,broker:c.broker||"TRADESTATION",m1Prefix:c.m1Prefix||"VX",apiKey:c.hasApiKey?"••••••••":"",apiSecret:c.hasApiSecret?"••••••••":"",refreshToken:c.hasRefreshToken?"••••••••":"",percent:String(c.percentToTrade??1),enabled:c.isActive,avatar:o||"",userEmail:b[0]||"",assignedEmails:b}}catch(u){return console.error("Failed to fetch account details:",u),{name:a||"",number:e,broker:"TRADESTATION",m1Prefix:"VX",apiKey:"",apiSecret:"",refreshToken:"",percent:"1",enabled:l,avatar:o||"",userEmail:"",assignedEmails:[]}}finally{Mo(!1)}},[N]),pc=x.useCallback(async(e,a,l,o)=>{ws(null),en(null),ti(!1),Zs(!0),We({name:a||"",number:e,broker:"TRADESTATION",m1Prefix:"VX",apiKey:"",apiSecret:"",refreshToken:"",percent:"1",enabled:l,avatar:o||"",userEmail:"",assignedEmails:[]});const u=await bc(e,a,l,o);We(u)},[bc]),Uh=x.useCallback(async()=>{const e=(F.number||"").trim();if(!e){en(n("נדרש מזהה חשבון","Account ID is required"));return}if(!N){en(n("נדרשת התחברות","Authentication required"));return}ti(!0),en(null);try{const a=parseFloat(F.percent),l=(F.userEmail||"").trim(),o=c=>c==="••••••••"||!c,u=await fetch($e(`/admin/accounts/${encodeURIComponent(e)}`),{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${N}`},body:JSON.stringify({name:F.name||null,broker:F.broker||null,apiKey:o(F.apiKey)?null:F.apiKey,apiSecret:o(F.apiSecret)?null:F.apiSecret,refreshToken:o(F.refreshToken)?null:F.refreshToken,isActive:!!F.enabled,percentToTrade:isNaN(a)?null:a,m1Prefix:F.m1Prefix||null,userEmail:l||null})});if(!u.ok){let c="Failed to update account";try{const b=await u.json();c=(b==null?void 0:b.Error)||(b==null?void 0:b.error)||c}catch{}throw new Error(c)}ni(c=>{const b=(F.number||F.name||"").trim();if(!b)return c;const v={...c};return F.avatar?v[b]=F.avatar:delete v[b],v}),ws(null),Zs(!1),Y()}catch(a){en((a==null?void 0:a.message)||n("שמירת החשבון נכשלה","Failed to save account"))}finally{ti(!1)}},[F,Y,N,n]),Vh=x.useCallback(async()=>{const e=(F.number||"").trim();if(!e){sn(n("נדרש מזהה חשבון","Account ID is required"));return}if(!N){sn(n("נדרשת התחברות","Authentication required"));return}si(!0),sn(null);try{const a=await fetch($e(`/admin/accounts/${encodeURIComponent(e)}`),{method:"DELETE",headers:{Authorization:`Bearer ${N}`}});if(!a.ok){let l="Failed to delete account";try{const o=await a.json();l=(o==null?void 0:o.Error)||(o==null?void 0:o.error)||l}catch{}throw new Error(l)}ni(l=>{const o=(F.number||F.name||"").trim();if(!o)return l;const u={...l};return delete u[o],u}),tn(!1),Zs(!1),Y()}catch(a){sn((a==null?void 0:a.message)||n("מחיקת החשבון נכשלה","Failed to delete account"))}finally{si(!1)}},[F.name,F.number,Y,N,n]);g.useEffect(()=>{Nt&&Ln==="blotter"&&Zt(!1)},[Nt,Ln]),g.useEffect(()=>{if(!Yr||typeof window>"u")return;const e=window.setTimeout(()=>Jr(!1),1500);return()=>window.clearTimeout(e)},[Yr]),g.useEffect(()=>{if(!Ra&&!Ma||typeof window>"u")return;const e=window.setTimeout(()=>{on(null),cn(null)},4500);return()=>window.clearTimeout(e)},[Ra,Ma]),g.useEffect(()=>{if(typeof window>"u")return;const e=()=>{Ah(un||window.innerWidth<1024)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[un]);const ji=x.useMemo(()=>{const e=new Map(ym.map(a=>[a.key,a]));return l0({canAccessCalculations:M,isCompact:X}).map(a=>
147e.get(a)).filter(Boolean)},[M,X,$]),ki=x.useMemo(()=>new Set(ji.map(e=>e.key)),[ji]),[he,gc]=g.useState(()=>cl(y==null?void 0:y.pathname,s,ki)),[Hh,qh]=g.useState(()=>he==="backtest"&&($||ne===bt.BACKTEST)),[zh,Qh]=g.useState(()=>he==="backtest"&&ne===bt.NETWORK);g.useEffect(()=>{const e=cl(y==null?void 0:y.pathname,s,ki);gc(a=>a===e?a:e)},[y==null?void 0:y.pathname,s,ki]),g.useEffect(()=>{he==="backtest"&&($||ne===bt.BACKTEST)&&qh(!0),he==="backtest"&&ne===bt.NETWORK&&Qh(!0)},[he,ne,$]),g.useEffect(()=>{Nt&&he!=="movement"&&Zt(!1)},[he,Nt]),g.useEffect(()=>{if(!Nt||typeof window>"u")return;const e=a=>{a.key==="Escape"&&Zt(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[Nt]),g.useEffect(()=>{Nt&&he!=="movement"&&Zt(!1)},[he,Nt]),g.useEffect(()=>{if(!Nt||typeof window>"u")return;const e=a=>{a.key==="Escape"&&Zt(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[Nt]);const Se=$t==="dark";g.useEffect(()=>{const e=document.documentElement;Se?(e.classList.add("dark"),e.style.colorScheme="dark"):(e.classList.remove("dark"),e.style.colorScheme="light"),wd($t);try{localStorage.setItem("crm_theme",$t)}catch{}ur()&&us(async()=>{const{Preferences:a}=await import("./index-h3aeLNcf.js");return{Preferences:a}},__vite__mapDeps([22,3,1,2,4])).then(({Preferences:a})=>a.set({key:"crm_theme",value:$t})).catch(()=>{})},[$t,Se]);const h=(e,a)=>Se?e:a,ft=gr(Se),yc=m("border-t",h("border-white/10 bg-[#181B1F]","border-slate-200 bg-white")),Te=ft.card,Lt=ft.mutedText,Rt=m("inline-flex min-h-11 items-center justify-center gap-2 rounded-lg px-4 py-2 text-sm font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400/60",ft.secondaryAction),Ua=m("inline-flex min-h-11 items-center justify-center gap-2 rounded-lg px-4 py-2 text-sm font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400/65 disabled:cursor-wait disabled:opacity-60",ft.primaryAction),Ai=Ua,ns=ft.row,rt=m(ft.row,ft.interactiveRow),Oe=ft.control,Si=X&&he==="menu",Wh=X?{paddingBottom:"max(1rem, env(safe-area-inset-bottom, 0px))"}:void 0,Hn=m("flex w-full items-center justify-between gap-3 rounded-xl border px-4 py-3 text-sm font-semibold transition",h("bg-white/5 border-white/10 text-white hover:bg-white/10","bg-white border-gray-200 text-gray-900 hover:bg-gray-50")),qn=m("flex items-center gap-3",r==="HE"?"flex-row-reverse":""),Va=m("text-xs font-semibold opacity-60",h("text-white/60","text-gray-400")),Ha=r==="HE"?"<":">",Kh=()=>{qs(!1),H(!1),w("/Menu")},wc=(e="General")=>{ts(e),Pa(""),ss([]),qt(null),qs(!1),H(!0)},Gh=x.useCallback(e=>{Qr(e),e===ae.CLOSED&&window.requestAnimationFrame(()=>{var o;const a=X?zr.current:qr.current,l=X?qr.current:zr.current;(o=a||l)==null||o.focus({preventScroll:!0})})},[X]),Xh=()=>{qs(!1),Qr(ae.COMPACT)},vc=Ke?n("הפעל צליל התראות","Enable alert sound"):n("השתק צליל התראות","Mute alert sound"),Nc=Ol||_l||!!Hl||Nr.executionEnabled==null,Yh=x.useCallback(async()=>{if(Nc||!(p!=null&&p.isAdmin))return;const e=!Sr;Dl(!0),Ds(null);try{const a=await Fb(e,{token:N});jr(a)}catch(a){Ds(a)}finally{Dl(!1)}},[Nc,Sr,N,p==null?void 0:p.isAdmin]),Jh=x.useCallback(()=>{Ds(null),la(!0),Am(e=>e+1)},[]),jc=x.useMemo(()=>{const e=(F.number||"").trim(),a=(F.name||"").trim();return a&&e?`${a} (${e})`:a||e},[F.name,F.number]),Ci=x.useCallback(()=>{Dm(e=>e+1)},[]),Zh=x.useCallback(async()=>{if(!(Fs||!(p!=null&&p.isAdmin))){ql(!0),Us(null);try{const e=$e("/forecast/export?format=xlsx"),a=await fetch(e,{method:"GET",headers:{Authorization:`Bearer ${N}`}});if(!a.ok){const v=await a.json().catch(()=>({}));throw new Error(v.error||`HTTP ${a.status}`)}const l=await a.blob(),o=window.URL.createObjectURL(l),u=document.createElement("a");u.href=o;const c=a.headers.get("Content-Disposition"),b=c==null?void 0:c.match(/filename="?([^";\n]+)"?/);u.download=(b==null?void 0:b[1])||`forecast_data_${new Date().toISOString().slice(0,10)}.xlsx`,document.body.appendChild(u),u.click(),document.body.removeChild(u),window.URL.revokeObjectURL(o)}catch(e){Us((e==null?void 0:e.message)??n("שגיאה בייצוא נתונים","Error exporting data"))}finally{ql(!1)}}},[Fs,N,n,p==null?void 0:p.isAdmin]),ef=x.useCallback(async()=>{var e,a;if(!(Bs||!(p!=null&&p.isAdmin))){zl(!0),Us(null),Kl(null);try{const l=await ja.run({force:!0});if(!l)return;Na((e=l.warnings)!=null&&e.length?{partial:!0,message:l.warnings.join("; ")}:null),bo(o=>o+1),Kl((a=l.warnings)!=null&&a.length?n("התחזיות עודכנו. היסטוריית S1/S2 נשמרה כי כיסוי הנתונים אינו מלא.","Forecasts refreshed. S1/S2 history was preserved because source coverage is incomplete."):n("התחזיות עודכנו בהצלחה.","Forecasts refreshed successfully.")),Ci()}catch(l){Us((l==null?void 0:l.message)||n("רענון התחזיות נכשל.","Forecast refresh failed."))}
147finally{zl(!1)}}},[Bs,ja,n,p==null?void 0:p.isAdmin,Ci]),tf=x.useCallback(async()=>{if(!(Vs||!(p!=null&&p.isAdmin))){Gl(!0),Us(null);try{const e=$e("/forecast/v1-comparison"),a=await fetch(e,{method:"GET",headers:{Authorization:`Bearer ${N}`}});if(!a.ok){const v=await a.json().catch(()=>({}));throw new Error(v.error||`HTTP ${a.status}`)}const l=await a.blob(),o=window.URL.createObjectURL(l),u=document.createElement("a");u.href=o;const c=a.headers.get("Content-Disposition"),b=c==null?void 0:c.match(/filename="?([^";\n]+)"?/);u.download=(b==null?void 0:b[1])||`v1_comparison_${new Date().toISOString().slice(0,10)}.xlsx`,document.body.appendChild(u),u.click(),document.body.removeChild(u),window.URL.revokeObjectURL(o)}catch(e){Us((e==null?void 0:e.message)??n("שגיאה בייצוא נתוני השוואה","Error exporting comparison data"))}finally{Gl(!1)}}},[Vs,N,n,p==null?void 0:p.isAdmin]),qa=x.useCallback(e=>{Jl(a=>({...a,...e}))},[]),sf=x.useCallback(()=>{Jl({status:"all",health:"all",credentials:"all",search:""})},[]),Ei=x.useMemo(()=>{try{return new Intl.DateTimeFormat(r==="HE"?"he-IL":"en-US",{dateStyle:"short",timeStyle:"medium"})}catch{return null}},[r]),Qt=x.useMemo(()=>{try{return new Intl.RelativeTimeFormat(r==="HE"?"he-IL":"en-US",{numeric:"auto"})}catch{return null}},[r]),as=x.useCallback(e=>{if(!e)return"--";const a=new Date(e);return Number.isNaN(a.getTime())?e:Ei?Ei.format(a):a.toLocaleString()},[Ei]),Mt=x.useCallback(e=>{if(!e)return"--";const a=new Date(e);if(Number.isNaN(a.getTime()))return"--";const l=Math.round((a.getTime()-Date.now())/1e3),o=Math.abs(l),u=(A,C)=>`${Math.abs(A)}${C}${A<0?" ago":""}`;if(o<60)return Qt?Qt.format(l,"second"):u(l,"s");const c=Math.round(l/60);if(Math.abs(c)<60)return Qt?Qt.format(c,"minute"):u(c,"m");const b=Math.round(c/60);if(Math.abs(b)<24)return Qt?Qt.format(b,"hour"):u(b,"h");const v=Math.round(b/24);return Qt?Qt.format(v,"day"):u(v,"d")},[Qt]),Wt=x.useCallback(e=>{switch(e){case"good":return h("bg-emerald-500/20 text-emerald-300","bg-emerald-100 text-emerald-700");case"warn":return h("bg-amber-500/20 text-amber-300","bg-amber-100 text-amber-700");case"bad":return h("bg-rose-500/20 text-rose-300","bg-rose-100 text-rose-700");default:return h("bg-white/10 text-white/70","bg-gray-100 text-gray-600")}},[h]),za=x.useCallback(e=>{switch(e){case"good":return"bg-emerald-400";case"warn":return"bg-amber-400";case"bad":return"bg-rose-400";default:return h("bg-white/40","bg-gray-400")}},[h]),Ts=x.useMemo(()=>Array.isArray(q==null?void 0:q.accounts)?q.accounts:[],[q]),St=x.useMemo(()=>{const e={total:Ts.length,active:0,inactive:0,eligible:0,missingCredentials:0,staleOrders:0,stalePositions:0};return Ts.forEach(a=>{a&&(a.isActive?e.active+=1:e.inactive+=1,a.hasCredentials||(e.missingCredentials+=1),a.isStreamingEligible&&(e.eligible+=1,a.isOrderStreamStale&&(e.staleOrders+=1),a.isPositionStreamStale&&(e.stalePositions+=1)))}),e},[Ts]),Ti=x.useMemo(()=>{const e=!!(q!=null&&q.streamingEnabled&&(q!=null&&q.accountStreamsEnabled)),a=dt.search.trim().toLowerCase();return Ts.filter(l=>{if(!l)return!1;const o=String(l.accountId??"").trim(),u=String(l.name??"").trim(),c=!!l.isActive,b=!!l.hasCredentials,v=!!l.isStreamingEligible&&e,A=l.orderStreamLastSeenAt,C=l.positionStreamLastSeenAt,E=!!(l.isOrderStreamStale||l.isPositionStreamStale),L=!!(A&&C),le=c&&!b||e&&(E||v&&!L),re=e&&v&&!E&&L;return!(dt.status==="active"&&!c||dt.status==="inactive"&&c||dt.credentials==="missing"&&b||dt.credentials==="ok"&&!b||dt.health==="healthy"&&!re||dt.health==="attention"&&!le||a&&!`${u} ${o}`.toLowerCase().includes(a))})},[dt,Ts,q==null?void 0:q.accountStreamsEnabled,q==null?void 0:q.streamingEnabled]),Pi=x.useMemo(()=>{if($r&&!gt)return{label:n("טוען...","Loading..."),tone:"muted"};if(to)return{label:n("לא זמין","Unavailable"),tone:"bad"};if(!gt)return{label:n("לא ידוע","Unknown"),tone:"muted"};const a=(typeof gt.status=="string"?gt.status.toLowerCase():"")==="ok";return{label:a?n("תקין","Healthy"):n("מדרדר","Degraded"),tone:a?"good":"warn"}},[gt,to,$r,n]),Ii=x.useMemo(()=>{if(so&&!de)return{label:n("טוען...","Loading..."),tone:"muted"};if(no)return{label:n("לא זמין","Unavailable"),tone:"bad"};if(!de)return{label:n("ממתין לזרם","Waiting"),tone:"muted"};const e=de.timestamp??de.generatedAt;if(!e)return{label:n("ממתין לזרם","Waiting"),tone:"muted"};const l=Math.max(1,Number((P==null?void 0:P.premiumBarMinutes)??5))*60*1e3*2.5;return Date.now()-e.getTime()>l?{label:n("מתעכב","Stale"),tone:"warn"}:{label:n("חי","Live"),tone:"good"}},[de,no,so,P,n]),$i=x.useMemo(()=>ma&&!q?{label:n("טוען...","Loading..."),tone:"muted"}:fa?{label:n("לא זמין","Unavailable"),tone:"bad"}:q?!q.streamingEnabled||!q.accountStreamsEnabled?{label:n("מושבת","Disabled"),tone:"muted"}:q.isRunning?St.staleOrders>0||St.stalePositions>0?{label:n("מדרדר","Degraded"),tone:"warn"}:{label:n("תקין","Healthy"),tone:"good"}:{label:n("מושהה","Stopped"),tone:"bad"}:{label:n("לא ידוע","Unknown"),tone:"muted"}
147,[St.staleOrders,St.stalePositions,fa,ma,q,n]),nf=x.useMemo(()=>{var a;if(Array.isArray(de==null?void 0:de.symbols)&&de.symbols.length>0)return de.symbols.join(", ");if(Array.isArray(P==null?void 0:P.symbols)&&P.symbols.length>0)return P.symbols.join(", ");const e=(a=P==null?void 0:P.indicator)==null?void 0:a.mainSymbol;return e?String(e):n("לא הוגדר","Not configured")},[P,de,n]),Li=x.useMemo(()=>{var A,C;const e=(A=P==null?void 0:P.indicator)==null?void 0:A.mainSymbol,a=(C=P==null?void 0:P.indicator)==null?void 0:C.referenceSymbol;if(!e&&!a)return{label:n("לא הוגדר","Not configured"),tone:"muted"};if(!ye&&!we)return{label:n("ממתין לזרם","Waiting"),tone:"muted"};const l=Date.now(),o=9e4,u=ye!=null&&ye.timestamp?l-new Date(ye.timestamp).getTime():1/0,c=we!=null&&we.timestamp?l-new Date(we.timestamp).getTime():1/0,b=u>o,v=c>o;return b&&v?{label:n("מתעכב","Stale"),tone:"bad"}:b||v?{label:n("חלקית","Partial"),tone:"warn"}:{label:n("חי","Live"),tone:"good"}},[(sd=P==null?void 0:P.indicator)==null?void 0:sd.mainSymbol,(nd=P==null?void 0:P.indicator)==null?void 0:nd.referenceSymbol,ye,we,n]),kc=x.useCallback((e,a)=>{const l=!!(e!=null&&e.isStreamingEligible),o=!!(e!=null&&e.hasCredentials),u=!!(e!=null&&e.isActive);if(!!!(q!=null&&q.accountStreamsEnabled&&(q!=null&&q.streamingEnabled)))return{label:n("מושבת","Disabled"),tone:"muted",detail:n("זרמי החשבונות מושבתים","Account streams are disabled")};if(!o)return{label:n("חסר אימות","Missing credentials"),tone:"muted",detail:n("חסרים מפתחות API","Credentials missing")};if(!u)return{label:n("לא פעיל","Inactive"),tone:"muted",detail:n("החשבון לא פעיל","Account inactive")};if(!l)return{label:n("מושבת","Disabled"),tone:"muted",detail:n("לא עומד בתנאים לזרימה","Not eligible for streaming")};const b=a==="orders"?e==null?void 0:e.orderStreamLastSeenAt:e==null?void 0:e.positionStreamLastSeenAt,v=a==="orders"?e==null?void 0:e.isOrderStreamStale:e==null?void 0:e.isPositionStreamStale;return b?v?{label:n("מתעכב","Stale"),tone:"warn",detail:`${as(b)} • ${Mt(b)}`}
147:{label:n("חי","Live"),tone:"good",detail:`${as(b)} • ${Mt(b)}`}:{label:n("ממתין","Awaiting"),tone:"warn",detail:n("אין פעימות לב עדיין","No heartbeat yet")}},[q==null?void 0:q.accountStreamsEnabled,q==null?void 0:q.streamingEnabled,Mt,as,n]),Ri=ji.filter(e=>e.key!=="menu"),Mi=Ri.length,Ac=Ri.findIndex(e=>e.key===he),af=Ac>=0?Ac:0,rf=`calc(100% / ${Mi})`,Oi=Sh??af,lf=r==="HE"?Mi-1-Oi:Oi,of=(lh||0)+10,Qa=X?void 0:`calc(100vh - ${of*2}px)`,Wa=2,Ka=typeof Ao=="number"?Ao:Rn==="orders"?1:0,cf=r==="HE"?Wa-1-Ka:Ka,df=`calc(100% / ${Wa})`,Sc=X?"px-4 py-1.5 text-sm":"px-5 py-2 text-sm",Cc=Ka===0,Ec=Ka===1,uf=X?"clamp(240px, 38dvh, 300px)":"100%",mf=X?"clamp(240px, 38dvh, 300px)":540,hf=d?"he_IL":"en",it=`sm:hidden text-[11px] font-semibold uppercase tracking-wide text-start ${h("text-white/60","text-gray-500")}`,lt="flex flex-col sm:block text-start",fe=()=>"",ff=e=>{switch(e){case"forecast":return"/Forecast";case"backtest":return ax(bt.BACKTEST);case"menu":return"/Menu";default:return"/CRM"}},zn=e=>{if(V&&H(!1),e===he)return;const a=()=>{gc(e),w(ff(e),$?{state:Nd(y.state)}:void 0)};if($){u0("owner-mode",a);return}a()},Ga=()=>{qs(!1)},_i=ls&&M,Di=_i?he==="backtest"&&ne===bt.NETWORK:he==="movement",xf=_i?n("רשת","Network"):n("תנועה","Movement"),bf=()=>{if(Ga(),_i){br(),w(nx(p,{isNative:!0}));return}zn("movement")},Ps={label:n("תחזית","Forecast"),Icon:sa,isActive:he==="forecast",onClick:()=>{Ga(),zn("forecast")}},Is={label:n("תפריט","Menu"),Icon:xu,isActive:he==="menu",onClick:()=>{Kh()}},Fi=e=>m("flex min-w-0 flex-col items-center justify-center gap-1 rounded-lg px-1 py-1 text-xs font-semibold focus-visible:outline focus-visible:outline-2",e?h("text-white","text-gray-900"):h("text-white/60 hover:text-white","text-gray-500 hover:text-gray-900")),Bi=e=>m("grid h-7 w-7 place-items-center rounded-lg",e?h("bg-sky-400/20","bg-sky-100"):""),Tc=(e,{widthClass:a="w-72",maxHeightClass:l="max-h-80",itemPadding:o="px-4 py-3"}={})=>{if(Ln!==e)return null;const u="end-0",c=e==="blotter",b=l==="max-h-80"?"max-h-[60vh]":l;if(c){const v=`crm-account-menu-${e}-title`,A=t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[t.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:()=>Ys(null),"aria-hidden":"true"}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":v,className:`relative flex max-h-[80vh] w-[min(90vw,24rem)] flex-col overflow-hidden rounded-2xl border shadow-2xl ${h("bg-[#1C1F22] border-white/10 text-white","bg-white border-black/10 text-gray-900")}`,children:[t.jsxs("div",{className:`flex items-center justify-between border-b px-4 py-3 ${h("border-white/10","border-black/10")}`,children:[t.jsx("span",{id:v,className:"text-base font-semibold",children:n("בחר חשבון","Select account")}),t.jsx("button",{type:"button",onClick:()=>Ys(null),className:`w-8 h-8 grid place-items-center rounded-full ${h("bg-white/10 hover:bg-white/15 text-white","bg-gray-100 hover:bg-gray-200 text-gray-800")}`,"aria-label":n("סגור","Close"),children:t.jsx("span",{className:"text-lg leading-none",children:"×"})})]}),t.jsx("div",{className:`flex-1 overflow-auto px-1 py-2 ${b}`,children:t.jsx("div",{role:"listbox","aria-labelledby":v,children:Qn.map(C=>t.jsx("button",{type:"button",onClick:()=>{es(C),Ys(null)},role:"option","aria-selected":ve===C,className:`w-full text-start ${o} transition-colors ${h("hover:bg-white/10 text-white","hover:bg-gray-100 text-gray-900")} ${ve===C?h("bg-white/10","bg-gray-100"):""}`,children:C},C))})})]})]});return typeof document<"u"?xr.createPortal(A,document.body):A}return t.jsx("div",{id:`crm-account-menu-${e}`,className:`absolute top-full mt-1 ${a} ${l} overflow-auto rounded-xl shadow-xl border z-50 ${u} ${h("bg-[#1C1F22] border-white/10","bg-white border-black/10")}`,role:"listbox",children:Qn.map(v=>t.jsx("button",{type:"button",onClick:()=>{es(v),Ys(null)},role:"option","aria-selected":ve===v,className:`w-full text-start ${o} transition-colors ${h("hover:bg-white/10 text-white","hover:bg-gray-100 text-gray-900")} ${ve===v?h("bg-white/10","bg-gray-100"):""}`,children:v},v))})},Be=x.useMemo(()=>
147{if(Array.isArray(pe)&&pe.length){const e=new Map;return Array.isArray(Le)&&Le.forEach(a=>{a!=null&&a.accountId&&e.set(a.accountId,a)}),pe.map(a=>{const l=a.raw??a,o=c=>{if(typeof c=="number"&&Number.isFinite(c))return c;if(typeof c=="string"){const b=Number(c);return Number.isFinite(b)?b:null}return null},u=e.get(a.id)||{};return{en:a.name||a.id,id:a.id,lastSeen:(l==null?void 0:l.lastSeen)??a.lastSeen??null,online:!!((l==null?void 0:l.online)??a.online),currency:u.currency||a.currency||(l==null?void 0:l.currency)||"USD",isActive:a.isActive??(l==null?void 0:l.isActive)??!0,percentToTrade:a.percentToTrade??(l==null?void 0:l.percentToTrade)??null,cashBalance:o(u.cashBalance)??o((l==null?void 0:l.cashBalance)??(l==null?void 0:l.CashBalance)??(l==null?void 0:l.cash)??(l==null?void 0:l.Cash)),buyingPower:o(u.buyingPower)??o((l==null?void 0:l.buyingPower)??(l==null?void 0:l.BuyingPower)),equity:o(u.equity)??o((l==null?void 0:l.equity)??(l==null?void 0:l.Equity)??(l==null?void 0:l.accountValue)??(l==null?void 0:l.AccountValue)),realizedPnl:o(u.realizedPnl)??o((l==null?void 0:l.realizedProfitLoss)??(l==null?void 0:l.RealizedProfitLoss)??(l==null?void 0:l.realizedPnl)),unrealizedPnl:o(u.unrealizedPnl)??o((l==null?void 0:l.unrealizedProfitLoss)??(l==null?void 0:l.UnrealizedProfitLoss)??(l==null?void 0:l.unrealizedPnl)),raw:a}})}return[]},[pe,Le]),Qn=x.useMemo(()=>{const e=Be.map(a=>`${a.en} (${a.id})`);return[Qe(),...e]},[Qe,Be]),Ot=x.useMemo(()=>{const e=new Map;return Be.forEach(a=>{e.set(a.id,a),e.set(a.en,a),e.set(`${a.en} (${a.id})`,a)}),e},[Be]),Pc=x.useCallback(e=>{if(!e)return;const a=Ot.get(e);if(a){es(`${a.en} (${a.id})`);return}es(e)},[Ot,es]),Xa=x.useCallback(e=>{if(!e||e===Qe())return null;const a=Be.find(o=>o.id===e||o.en===e);if(a)return a.id;const l=e.match(/\(([^()]+)\)\s*$/);if(l){const o=l[1];if(Be.some(u=>u.id===o))return o}return null},[Qe,Be]),Ic=x.useCallback(e=>i(e?"Active":"Inactive"),[i]);g.useEffect(()=>{if(!Be.length)return;const e=Xa(ve);ve!==Qe()&&e==null&&es(Qe())},[Xa,Qe,Be,ve]);const Ue=x.useMemo(()=>Xa(ve),[Xa,ve]),pf=x.useMemo(()=>Ue?[Ue]:[],[Ue]),{positions:Ui,orders:Ge,historicalOrders:Vi,realtimeFilledOrders:$c,accountSummaries:Lc,status:ot,lastUpdated:Hi,reload:me}=Ib({accountIds:pf,enabled:!!N&&he==="movement"}),qi=x.useCallback((e=[])=>{const a=Date.now()+9e4;e.forEach(l=>{l&&_a.current.set(String(l),a)})},[]),rs=x.useCallback((e,a)=>{const l=`${e}:${JSON.stringify(a)}`;let o=Xr.current.get(l);return o||(o=globalThis.crypto.randomUUID(),Xr.current.set(l,o)),{key:l,id:o}},[]),Kt=x.useCallback(e=>Xr.current.delete(e),[]),zi=x.useCallback(async e=>{var u;if(tt)return;const a=ce?n(`לאשר שינוי פקודה ${ce.orderId} בחשבון ${ce.accountId}?`,`Confirm changing order ${ce.orderId} in account ${ce.accountId}?`):n(`לאשר שליחת פקודת ${e} עבור ${qe} בחשבון ${Ue||"כל החשבונות"}, כמות ${ut}, מחיר הגבלה ${vt}?`,`Confirm ${e} order for ${qe} in ${Ue||"all accounts"}, quantity ${ut}, limit ${vt}?`);if(typeof window.confirm!="function"||!window.confirm(a))return;Pn(null),yo(!0);let l=null,o=null;try{if(ce){const C=Number(ut),E=Number(vt),L=rs("replace",{orderId:ce.orderId,accountId:ce.accountId,quantity:C,limitPrice:E});l=L.id,o=L.key,await vd({orderId:ce.orderId,accountId:ce.accountId,quantity:Number.isFinite(C)?C:void 0,limitPrice:Number.isFinite(E)?E:void 0,intentId:L.id,confirmed:!0}),Kt(L.key),me==null||me(),Ks(null),Jt(!1);return}if(!e)throw new Error("action is required to place a new order");const c=ut==="All",b=!Ue,v=e==="Sell"||e==="SellShort",A=e==="Buy"||e==="BuyToCover";if(b||c){const C=rs("bulk-create",{accountId:Ue,symbol:qe,action:e,quantityMode:c?"All":"Manual",manualQuantity:c?null:Number(ut),limitPrice:Number(vt),timeInForce:"Day"});l=C.id,o=C.key;const E=await Xf({accountId:Ue,symbol:qe,action:e,quantityMode:c?"All":"Manual",manualQuantity:c?null:Number(ut),limitPrice:vt,timeInForce:"Day",intentId:C.id,confirmed:!0});if(E.failureCount===0&&Kt(C.key),console.log(`Bulk order result: ${E.successCount}/${E.totalAccounts} succeeded`,E),E.failureCount>
1470){const L=E.results.filter(B=>!B.success);console.warn("Some orders failed:",L),Pn(n(`${E.successCount} מתוך ${E.totalAccounts} פקודות נשלחו. בדוק אילו חשבונות נכשלו לפני שליחה חדשה.`,`${E.successCount} of ${E.totalAccounts} orders were submitted. Check the failed accounts before sending another order.`)),me==null||me();return}qi(Array.isArray(E==null?void 0:E.results)?E.results.filter(L=>(L==null?void 0:L.success)&&(L==null?void 0:L.orderId)).map(L=>L.orderId):[]),Array.isArray(E==null?void 0:E.results)&&E.results.filter(L=>(L==null?void 0:L.success)&&(L==null?void 0:L.orderId)).forEach(L=>{var B;(B=Es.current)==null||B.call(Es,{eventType:"order.submitted",order:{orderId:L.orderId,accountId:L.accountId,accountName:L.accountName,symbol:qe,action:e,quantityValue:L.quantity??(c?null:Number(ut)),priceValue:Number(vt),status:"Submitted"},timestamp:new Date,source:"local"})})}else{const C=rs("single-create",{accountId:Ue,symbol:qe,action:e,quantity:Number(ut),limitPrice:Number(vt),timeInForce:"Day"});l=C.id,o=C.key;const E=await Yf({accountId:Ue,symbol:qe,quantity:Number(ut),action:e,limitPrice:vt,timeInForce:"Day",intentId:C.id,confirmed:!0});Kt(C.key),qi([(E==null?void 0:E.orderId)??(E==null?void 0:E.OrderId)]),(u=Es.current)==null||u.call(Es,{eventType:"order.submitted",order:{...E,orderId:(E==null?void 0:E.orderId)??(E==null?void 0:E.OrderId),symbol:qe,action:e,quantityValue:Number(ut),priceValue:Number(vt),status:(E==null?void 0:E.status)??(E==null?void 0:E.Status)??"Submitted"},timestamp:new Date,source:"local"})}Jt(!1),me==null||me()}catch(c){console.error("Order placement failed",c);let b=null;if(l)try{b=await Jf(l)}catch{}(b==null?void 0:b.state)==="confirmed"?(o&&Kt(o),Jt(!1),Ks(null),me==null||me()):b&&["sending","uncertain","reserved"].includes(b.state)?Pn(n(`תוצאת הפקודה אינה ודאית. בדוק ב־TradeStation לפני שליחה חדשה. מזהה בדיקה: ${l}`,`Order outcome is uncertain. Check TradeStation before sending a new order. Intent: ${l}`)):(c==null?void 0:c.status)===503?Pn(n("המסחר עדיין לא הופעל ב־Sites.","Trading is not enabled on Sites yet.")):Pn(n("שליחת הפקודה נכשלה. בדוק את מצב הפקודה ב־TradeStation.","The order request failed. Check its status in TradeStation."))}finally{yo(!1)}},[ce,tt,ut,qe,vt,qi,Ue,me,n,rs,Kt]),is=x.useMemo(()=>{const e=new Map;return(Lc||[]).forEach(a=>{a!=null&&a.id&&e.set(a.id,a.currency||"USD")}),e},[Lc]),gf=x.useCallback(async e=>{var a;if(!(!(e!=null&&e.orderId)||!(e!=null&&e.accountId))){jo(l=>({...l,[e.orderId]:"cancel"}));try{const l=rs("cancel",{orderId:e.orderId,accountId:e.accountId});await Zf({orderId:e.orderId,accountId:e.accountId,intentId:l.id,confirmed:!0}),Kt(l.key),sh(o=>{const u=new Set(o);return u.add(e.orderId),u}),me==null||me()}catch(l){console.error("Order cancellation failed",l),(a=window.alert)==null||a.call(window,n("תוצאת ביטול הפקודה אינה ודאית. בדוק ב־TradeStation לפני ניסיון נוסף.","Cancellation outcome is uncertain. Check TradeStation before trying again."))}finally{jo(l=>{const o={...l};return delete o[e.orderId],o})}}},[me,rs,Kt,n]),yf=x.useCallback(e=>{if(!(e!=null&&e.orderId)||!(e!=null&&e.accountId))return;Xs(null),Me.current&&(window.clearTimeout(Me.current),Me.current=null),Pc(e.accountId);const a=Number.isFinite(e.quantityValue)?e.quantityValue:null,l=Number.isFinite(e.priceValue)?e.priceValue:Number.isFinite(e.averagePriceValue)?e.averagePriceValue:null;Wr(e.symbol||""),a!==null&&Ea(String(Math.abs(a))),l!==null&&zs(String(l)),Ks({orderId:e.orderId,accountId:e.accountId}),Jt(!0)},[Pc]),wf=x.useCallback(async()=>{var u;if(ze)return;const e=Number(Ht);if(!Number.isFinite(e)||e<=0)return;const a=(Ge||[]).filter(c=>c.orderId&&c.accountId);if(a.length===0){Gs(!1);return}if(typeof window.confirm!="function"||!window.confirm(n(`לאשר שינוי מחיר הגבלה ל־${Ht} עבור ${a.length} פקודות?`,`Confirm changing the limit price to ${Ht} for ${a.length} orders?`)))return;vo(!0),No({current:0,total:a.length});const l=await Promise.allSettled(a.map(c=>(()=>{const b=rs("bulk-replace",{orderId:c.orderId,accountId:c.accountId,limitPrice:e});return vd({orderId:c.orderId,accountId:c.accountId,limitPrice:e,intentId:b.id,confirmed:!0}).then(v=>(Kt(b.key),v))})()));l.forEach((c,b)=>{c.status==="rejected"&&console.error(`Failed to update order ${a[b].orderId}:`,c.reason)});const o=l.filter(c=>c.status==="fulfilled").length;console.log(`Bulk edit complete: ${o}/${a.length} orders updated successfully`),o<a.length&&((u=window.alert)==null||u.call(window,n(`${o} מתוך ${a.length} פקודות עודכנו. בדוק את השאר ב־TradeStation.`,`${o} of ${a.length} orders were updated. Check the rest in TradeStation.`))),me==null||me(),vo(!1),Gs(!1),ps(""),No({current:0,total:0})},[ze,Ht,Ge,me,n,rs,Kt]),Ee=x.useCallback(e=>{if(typeof e!="number"||Number.isNaN(e))return"-";try{const a=Math.abs(e)<1?2:0,l=Math.abs(e)<1?4:2;return new Intl.NumberFormat(f,{minimumFractionDigits:a,maximumFractionDigits:l}).format(e)}catch{return e.toString()}},[f]),Ne=x.useCallback((e,a="USD")=>{if(typeof e!="number"||Number.isNaN(e))return"-";try{return new Intl.NumberFormat(f,{style:"currency",currency:a,maximumFractionDigits:2}).format(e)}catch{return`${e.toFixed(2)} ${a}`}},[f]),Xe=x.useCallback(e=>{if(!e)return n("Unavailable","Unavailable");const a=typeof e=="number"?new Date(e):new Date(e);if(Number.isNaN(a.getTime()))return n("Unavailable","Unavailable");
147try{return a.toLocaleString(f,{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return a.toISOString()}},[f,n]),Qi=x.useCallback(e=>{if(!e)return n("Unavailable","Unavailable");const a=typeof e=="number"?new Date(e):new Date(e);if(Number.isNaN(a.getTime()))return n("Unavailable","Unavailable");try{const l=new Intl.DateTimeFormat(f,{hour:"2-digit",minute:"2-digit"}).format(a),o=new Intl.DateTimeFormat(f,{weekday:"short",day:"numeric",month:"short"}).format(a);return`${l} ${o}`}catch{return a.toLocaleString(f)}},[f,n]),Wn=x.useCallback(e=>{if(typeof e!="number"||Number.isNaN(e))return"-";try{return new Intl.NumberFormat(f,{minimumFractionDigits:2,maximumFractionDigits:2}).format(e)}catch{return e.toFixed(2)}},[f]),je=x.useCallback(e=>{if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()!==""){const a=Number(e);return Number.isFinite(a)?a:null}return null},[]),Rc=x.useCallback(e=>{if(!e)return null;if(e instanceof Date){const a=e.getTime();return Number.isNaN(a)?null:a}if(typeof e=="number"){if(!Number.isFinite(e))return null;const a=Math.abs(e)<1e12?e*1e3:e;return Number.isFinite(a)?a:null}if(typeof e=="string"&&e.trim()){const a=Date.parse(e);return Number.isNaN(a)?null:a}return null},[]),_e=x.useCallback(e=>typeof e!="string"?"":e.trim().toUpperCase(),[]),Mc=x.useCallback(e=>{if(!e)return"";const a=String(e).trim().toLowerCase();return a?a.includes("buy")&&a.includes("cover")?"buytocover":a.includes("sell")&&a.includes("short")?"sellshort":a.includes("buy")?"buy":a.includes("sell")?"sell":a:""},[]),Oc=x.useCallback(e=>{var o,u,c;if(!e)return null;const a=e.action??e.side??e.buyOrSell??((o=e.raw)==null?void 0:o.action)??((u=e.raw)==null?void 0:u.Action)??((c=e.raw)==null?void 0:c.BuyOrSell),l=Mc(a);return l?l.includes("buy")?"buy":l.includes("sell")?"sell":null:null},[Mc]),Ya=x.useCallback(e=>{var l,o,u,c,b,v,A;if(!e)return null;const a=[e.closedAt,e.closedDateTime,e.closed,e.timestampValue,e.timestamp,e.openedAt,e.openedDateTime,e.opened,e.createdAt,(l=e.raw)==null?void 0:l.ClosedDateTime,(o=e.raw)==null?void 0:o.Closed,(u=e.raw)==null?void 0:u.OpenedDateTime,(c=e.raw)==null?void 0:c.Opened,(b=e.raw)==null?void 0:b.timestampValue,(v=e.raw)==null?void 0:v.TimestampValue,(A=e.raw)==null?void 0:A.TimeStamp];for(const C of a){const E=Rc(C);if(E!=null)return E}return null},[Rc]),Wi=x.useCallback(e=>{if(typeof e!="string")return null;const a=e.split(":");if(a.length<2)return null;const l=Number(a[0]),o=Number(a[1]);return!Number.isFinite(l)||!Number.isFinite(o)||l<0||l>23||o<0||o>59?null:l*60+o},[]),Kn=x.useCallback(e=>{ec(a=>a.filter(l=>l.id!==e))},[]),_c=x.useCallback(e=>{e&&ci(a=>a.map(l=>l.id===e?{...l,readAt:l.readAt??Date.now()}:l))},[]),Dc=x.useCallback(()=>{const e=Wi(ks),a=Wi(As);if(e===null||a===null||e===a)return!0;const l=new Date,o=l.getHours()*60+l.getMinutes();return e<a?o>=e&&o<=a:o>=e||o<=a},[As,ks,Wi]),Ki=x.useCallback(e=>{var b,v,A,C,E,L,B,te,le,re,se,be,De;if(!e)return null;const a=(e==null?void 0:e.orderId)??((b=e==null?void 0:e.raw)==null?void 0:b.orderId)??((v=e==null?void 0:e.raw)==null?void 0:v.OrderId)??((A=e==null?void 0:e.raw)==null?void 0:A.id)??null;if(a)return`order:${a}`;const l=_e((e==null?void 0:e.symbol)??((C=e==null?void 0:e.raw)==null?void 0:C.symbol)??((E=e==null?void 0:e.raw)==null?void 0:E.Symbol)??""),o=(e==null?void 0:e.accountId)??((L=e==null?void 0:e.raw)==null?void 0:L.accountId)??((B=e==null?void 0:e.raw)==null?void 0:B.AccountId)??"account",u=(e==null?void 0:e.status)??((te=e==null?void 0:e.raw)==null?void 0:te.status)??((le=e==null?void 0:e.raw)==null?void 0:le.Status)??"status",c=(e==null?void 0:e.timeMs)??((re=e==null?void 0:e.raw)==null?void 0:re.time)??((se=e==null?void 0:e.raw)==null?void 0:se.Time)??((be=e==null?void 0:e.raw)==null?void 0:be.OpenedDateTime)??((De=e==null?void 0:e.raw)==null?void 0:De.ClosedDateTime)??"time";return`order:${o}:${l||"symbol"}:${u}:${c}`},[_e]),Fc=x.useCallback(e=>{var E,L,B,te,le,re;const a=(e==null?void 0:e.symbol)??((E=e==null?void 0:e.raw)==null?void 0:E.symbol)??((L=e==null?void 0:e.raw)==null?void 0:L.Symbol)??"",l=e==null?void 0:e.quantityValue,o=typeof(e==null?void 0:e.qtyOrdered)=="string"&&e.qtyOrdered.trim()?e.qtyOrdered:l!=null?Ee(Math.abs(l)):null,u=(e==null?void 0:e.action)??(e==null?void 0:e.side)??(e==null?void 0:e.buyOrSell)??((B=e==null?void 0:e.raw)==null?void 0:B.action)??((te=e==null?void 0:e.raw)==null?void 0:te.Action)??((le=e==null?void 0:e.raw)==null?void 0:le.BuyOrSell)??((re=e==null?void 0:e.raw)==null?void 0:re.Side)??null,c=u?n(u,u):null,b=(e==null?void 0:e.status)??null,A=[c,o,a].filter(se=>se&&String(se).trim()).join(" "),C=b?`${A||a} • ${b}`:A||a||n("Order update","Order update");return{title:n("הזמנה נשלחה","Order sent"),body:C}},[Ee,n]),Gi=x.useCallback(e=>{if(!e)return null;const a=e.id??e.orderId??null;if(a)return`entry:${a}`;const l=_e(e.symbol??""),o=e.accountId??"account",u=e.timeMs??"time",c=e.side??"",b=e.quantityValue??"";return`entry:${o}:${l||"symbol"}:${u}:${c}:${b}`},[_e]),Bc=x.useCallback(e=>{const a=(e==null?void 0:e.symbol)??"",l=e==null?void 0:e.quantityValue,o=typeof l=="number"?Ee(Math.abs(l)):null,u=e!=null&&e.side?n(e.side,e.side):null,c=is.get(e==null?void 0:e.accountId)||"USD",b=typeof(e==null?void 0:e.priceValue)=="number"?Ne(e.priceValue,c):null;let A=[u,o,a].filter(C=>C&&String(C).trim()).join(" ");return b&&(A=A?`${A} @ ${b}`:b),{title:n("הזמנה בוצעה","Order filled"),body:A||a||n("Order filled","Order filled")}},[is,Ne,Ee,n]),Ja=x.useCallback(({title:e,body:a})=>{if(!Dc())return{ok:!1,reason:"outside-window"};const l=e||n("התראה","Alert");return At&&$s({title:l,body:a||""}),Rs({count:1}),Ls({sound:ht,muted:Ke,onlyWhenVisible:!0}),{ok:!0}},[ht,Ke,Dc,Ls,At,$s,Rs,n]),Uc=x.useCallback(e=>{e&&(_c(e.id),Kn(e.id),ui(!1),Ta("orders"),e.orderId&&To([String(e.orderId)]))},[Kn,_c]),Za=x.useCallback(async e=>{var b;const a=Fp({eventType:e==null?void 0:e.eventType,order:e==null?void 0:e.order,timestamp:(e==null?void 0:e.timestamp)instanceof Date?e.t
147imestamp.getTime():Date.now(),source:(e==null?void 0:e.source)??"stream"});if(!a)return;const l=Date.now();for(const[v,A]of Array.from(_a.current.entries()))A<=l&&_a.current.delete(v);const o=Xp({event:a,settings:hc,context:{recentEvent:uc.current.get(a.orderId)??null,processedKeys:xi.current,originatedLocally:_a.current.has(a.orderId),activeOrderIds:[ce==null?void 0:ce.orderId,Pt,...Array.from(jt)].filter(Boolean),platform:at?"mobile":"desktop",supportsSystemNotifications:At||at,systemPermission:At?ln:Cs},now:l});if(!o||(b=o.reasons)!=null&&b.includes("DUPLICATE_STATE")||xi.current.has(o.dedupeKey))return;xi.current.add(o.dedupeKey),uc.current.set(a.orderId,{dedupeKey:o.dedupeKey,eventType:a.eventType,fingerprint:a.fingerprint,occurredAt:o.occurredAt});const u=Qp(a,{tr:n,formatQuantity:Ee,formatCurrency:Ne,privacyMode:js}),c={id:`${o.dedupeKey}:${o.occurredAt}`,orderId:a.orderId,eventType:a.eventType,occurredAt:o.occurredAt,readAt:null,reasons:o.reasons,severity:o.severity,mergeMode:o.mergeMode,...o,...u};ci(v=>Yp(v,c)),o.toast&&ec(v=>[c,...v].slice(0,4)),o.badge&&Rs({count:Vn+1}),o.system&&(At?$s({title:u.title,body:u.body,tag:a.orderId}):at&&await Hd({title:u.title,body:u.body})),(o.system||o.toast)&&o.sound&&Ls({sound:ht,muted:Ke,onlyWhenVisible:!0})},[ht,Ke,ln,Pt,ce==null?void 0:ce.orderId,Ne,Ee,jt,js,hc,Ls,Cs,At,at,$s,Rs,Hd,n,Vn]);x.useEffect(()=>{Es.current=Za},[Za]);const Vc=x.useCallback(e=>{if(!e)return!1;const a=String(e).toUpperCase().replace(/[^A-Z]/g,"");return!a||a.includes("CANCEL")||a.includes("CXL")||a.includes("REJECT")?!1:!!(a.includes("FILL")||a.includes("FLL")||a.includes("CLOSE")||a.includes("COMP")||a.includes("DONE"))},[]),Hc=x.useCallback(e=>{var o,u,c,b;if(!e)return!1;const a=je(e.filledQuantity??e.filledQuantityValue??e.execQuantity??e.filled??((o=e.raw)==null?void 0:o.FilledQuantity)??((u=e.raw)==null?void 0:u.ExecQuantity));if(a!==null&&a!==0)return!0;const l=e.status??((c=e.raw)==null?void 0:c.Status)??((b=e.raw)==null?void 0:b.status);return Vc(l)},[Vc,je]),er=x.useCallback(e=>{const a=_e(e);return a.startsWith("VX")?"VX":a.startsWith("ES")?"ES":"Other"},[_e]),_t=x.useMemo(()=>Array.isArray(Ui)?Ui.map(e=>{var De;const a=is.get(e.accountId)||"USD",l=e.symbol??e.rawSymbol??((De=e.raw)==null?void 0:De.symbol),o=_e(l),u=je(e.quantity??e.rawQuantity),c=u!==null?Ee(u):e.rawQuantity??"-",b=je(e.unrealizedProfitLoss??e.unrealizedPnl??e.rawUnrealizedProfitLoss??e.rawUnrealizedPnl),v=b!==null?Ne(b,a):"-",A=e.timestamp??e.lastUpdated??e.updatedAt??e.updated??e.openDate??e.rawTimestamp,C=Xe(A),E=(()=>{if(!A)return null;const Ce=(typeof A=="number"?new Date(A):new Date(A)).getTime();return Number.isNaN(Ce)?null:Ce})();let L="Open";u!==null&&(u>0?L="Long":u<0?L="Short":L="Flat");const B=e.side??e.direction??null,te=B?n(B,B):n(L,L),le=[],re=je(e.averagePrice??e.rawAveragePrice),se=je(e.marketValue??e.rawMarketValue),be=je(e.initialRequirement??e.rawInitialRequirement);return A&&C&&le.push(`${n("Updated","Updated")}: ${C}`),re!==null&&le.push(`${n("Avg Price","Avg Price")}: ${Ne(re,a)}`),se!==null&&le.push(`${n("Market Value","Market Value")}: ${Ne(se,a)}`),be!==null&&le.push(`${n("Initial Requirement","Initial Requirement")}: ${Ne(be,a)}`),{id:e.id||`${e.accountId||"account"}-${e.symbol||"symbol"}-position`,accountId:e.accountId,name:e.accountName||e.symbol||e.accountId||n("Position","Position"),symbol:l||"-",quantity:c,pnl:v,status:te,time:C,timeUpdates:le,timeValue:E,averagePriceLabel:re!==null?Ne(re,a):"-",marketValueLabel:se!==null?Ne(se,a):"-",quantityValue:u,pnlValue:b,averagePriceValue:re,marketValueValue:se,initialRequirementValue:be,normalizedSymbol:o,currency:a,raw:e}}):[],[is,Ne,Ee,Xe,Ui,_e,je,n]),Ve=x.useMemo(()=>Array.isArray(Ge)?Ge.filter(e=>{var l,o,u;const a=e.orderId??e.id??e.rawOrderId??((l=e.raw)==null?void 0:l.orderId)??((o=e.raw)==null?void 0:o.OrderId)??((u=e.raw)==null?void 0:u.id);return a?!ko.has(a):!0}).map(e=>{var hd,fd,xd,bd;const a=e.orderId??e.id??e.rawOrderId??((hd=e.raw)==null?void 0:hd.orderId)??((fd=e.raw)==null?void 0:fd.OrderId)??((xd=e.raw)==null?void 0:xd.id),l=is.get(e.accountId)||"USD",o=e.symbol??e.rawSymbol??((bd=e.raw)==null?void 0:bd.symbol),u=_e(o),c=je(e.quantity??e.rawQuantity),b=c!==null?Ee(c):e.rawQuantity??"-",v=je(e.remainingQuantity??e.rawRemainingQuantity),A=v!==null?Ee(Math.max(v,0)):null,C=je(e.filledQuantity??e.rawFilledQuantity),E=C!==null?Ee(C):null,L=je(e.limitPrice??e.price??e.rawLim
147itPrice),B=je(e.averagePrice??e.price??e.rawAveragePrice);let te=L,le=L!==null?n("Limit","Limit"):null;te===null&&B!==null&&(te=B,le=n("Avg Fill","Avg Fill"));const re=te!==null?Ne(te,l):"-",se=e.timestamp??e.updated??e.updatedAt??e.createdAt??e.created??e.rawTimestamp,be=Xe(se),De=(()=>{if(!se)return null;const pd=(typeof se=="number"?new Date(se):new Date(se)).getTime();return Number.isNaN(pd)?null:pd})(),xt=e.status?n(e.status,e.status):n("Pending","Pending"),Ce=[],Dt=e.side??e.action;Dt&&Ce.push(`${n("Side","Side")}: ${n(Dt,Dt)}`);const Pe=e.type??e.orderType;Pe&&Ce.push(`${n("Type","Type")}: ${n(Pe,Pe)}`);const xn=e.duration??e.timeInForce;return xn&&Ce.push(`${n("Duration","Duration")}: ${n(xn,xn)}`),E&&Ce.push(`${n("Filled","Filled")}: ${E}`),A&&Ce.push(`${n("Remaining","Remaining")}: ${A}`),le&&re&&re!=="-"&&Ce.push(`${le}: ${re}`),se&&be&&Ce.push(`${n("Updated","Updated")}: ${be}`),{id:a||`${e.accountId||"account"}-${e.symbol||"symbol"}-order`,orderId:a,accountId:e.accountId,name:e.accountName||e.symbol||e.accountId||n("Order","Order"),symbol:o||"-",status:xt,qtyOrdered:b,qtyLeft:A,price:re,priceType:le,filledLabel:E,time:be,timeValue:De,timeUpdates:Ce,quantityValue:c,priceValue:te,averagePriceValue:B,normalizedSymbol:u,currency:l,rawOrder:e,raw:e}}):[],[is,Ne,Ee,Xe,ko,Ge,_e,je,n]),Gn=x.useMemo(()=>Array.isArray(Vi)?Vi.map(e=>{var E,L,B,te,le,re,se,be,De,xt;const a=e.orderId??e.OrderId??e.id??((E=e.raw)==null?void 0:E.orderId)??((L=e.raw)==null?void 0:L.OrderId),l=e.accountId??e.AccountId??e.account??((B=e.raw)==null?void 0:B.AccountID)??((te=e.raw)==null?void 0:te.AccountId)??null,o=e.symbol??e.Symbol??((le=e.raw)==null?void 0:le.symbol)??((re=e.raw)==null?void 0:re.Symbol),u=_e(o),c=je(e.filledQuantity??e.FilledQuantity??e.execQuantity??e.ExecQuantity??e.quantity??e.Quantity),b=je(e.filledPrice??e.FilledPrice??e.price??e.Price??((se=e.raw)==null?void 0:se.FilledPrice)??((be=e.raw)==null?void 0:be.LimitPrice)),v=Ya(e),A=e.action??e.Action??e.buyOrSell??e.BuyOrSell??e.side??e.Side,C=e.status??e.Status??((De=e.raw)==null?void 0:De.Status)??((xt=e.raw)==null?void 0:xt.status);return{id:a||`${l||"account"}-${o||"symbol"}-${v||"time"}
147`,orderId:a,accountId:l,symbol:o||"-",action:A,status:C,quantityValue:c,priceValue:b,timeValue:v,normalizedSymbol:u,raw:e}}).filter(e=>e.timeValue!==null):[],[Vi,_e,je,Ya]),Xi=x.useMemo(()=>{if(!Array.isArray(Gn))return[];const e=Date.now()-1440*60*1e3,a=jt.size>0,l=b=>{const v=b.id!=null?String(b.id):null,A=b.orderId!=null?String(b.orderId):null;return v&&jt.has(v)||A&&jt.has(A)},o=Gn.filter(b=>{const v=typeof b.timeValue=="number"?b.timeValue:null;return!!(v!==null&&Number.isFinite(v)&&v>=e||a&&l(b))}).map(b=>{var be;const v=is.get(b.accountId)||"USD",A=b.accountId?(be=Ot.get(b.accountId))==null?void 0:be.en:null,C=typeof b.quantityValue=="number"?b.quantityValue:null,E=C!==null?Math.abs(C):null,L=E!==null?Ee(E):"-",B=typeof b.priceValue=="number"?b.priceValue:null,te=B!==null?Ne(B,v):"-",le=b.timeValue!=null?Xe(b.timeValue):n("Unavailable","Unavailable"),re=b.status?n(b.status,b.status):n("Filled","Filled"),se=[];return b.action&&se.push(`${n("Side","Side")}: ${n(b.action,b.action)}`),b.status&&se.push(`${n("Status","Status")}: ${re}`),te&&te!=="-"&&se.push(`${n("Price","Price")}: ${te}`),b.timeValue!=null&&se.push(`${n("Updated","Updated")}: ${le}`),{id:b.id,orderId:b.orderId,accountId:b.accountId,name:A||b.symbol||b.accountId||n("Order","Order"),symbol:b.symbol||"-",status:re,qtyOrdered:L,price:te,priceValue:B,time:le,timeValue:b.timeValue,timeUpdates:se,quantityValue:C,normalizedSymbol:b.normalizedSymbol,currency:v,rawOrder:b.raw,raw:b.raw}});if(!a)return o;const u=[],c=[];return o.forEach(b=>{const v=b.id!=null?String(b.id):null,A=b.orderId!=null?String(b.orderId):null;v&&jt.has(v)||A&&jt.has(A)?u.push(b):c.push(b)}),[...u,...c]},[is,Ot,Ne,Ee,Xe,jt,Gn,n]),tr=x.useRef({initialized:!1,seen:new Set}),sr=x.useRef({initialized:!1,seen:new Set});x.useEffect(()=>{if(!ct){tr.current.initialized=!1,tr.current.seen.clear();return}if(!(mt!=null&&mt.orders)){tr.current.initialized=!1;return}if(ot.orders!=="ready"&&ot.orders!=="error")return;const e=Array.isArray(Ve)?Ve:[],a=tr.current;if(!a.initialized){e.forEach(l=>{const o=Ki(l);o&&a.seen.add(o)}),a.initialized=!0;return}e.forEach(l=>{const o=Ki(l);!o||a.seen.has(o)||(a.seen.add(o),Ja(Fc(l)))})},[mt==null?void 0:mt.orders,ot.orders,Ki,Fc,Ja,ct,Ve]);const[vf,Nf]=x.useState([]),nr=x.useRef(new Map),[qc,jf]=x.useState(0);x.useEffect(()=>{const e=new Map(nr.current);let a=!1;[...Gn,...Ve,...$c||[]].forEach(o=>{var L,B,te,le,re,se,be,De,xt,Ce,Dt,Pe,xn;if(!Hc(o))return;const u=o.timeValue??Ya(o);if(u==null||!Number.isFinite(u))return;const c=Oc(o);if(!c)return;const b=o.symbol??((L=o.raw)==null?void 0:L.symbol)??((B=o.raw)==null?void 0:B.Symbol),v=_e(b);if(!v)return;const A=je(o.filledQuantity??o.filledQuantityValue??o.execQuantity??o.quantityValue??o.quantity??((te=o.raw)==null?void 0:te.FilledQuantity)??((le=o.raw)==null?void 0:le.ExecQuantity)??((re=o.raw)==null?void 0:re.QuantityOrdered)),C=o.orderId??o.id??((se=o.raw)==null?void 0:se.orderId)??((be=o.raw)==null?void 0:be.OrderId),E=C||`${o.accountId||"account"}-${v}-${u}-${c}-${A??""}`;e.has(E)||(e.set(E,{id:E,orderId:C,accountId:o.accountId??o.account??((De=o.raw)==null?void 0:De.AccountID)??((xt=o.raw)==null?void 0:xt.AccountId)??null,symbol:b,normalizedSymbol:v,side:c,timeMs:u,quantityValue:A,priceValue:o.priceValue??o.price??((Ce=o.raw)==null?void 0:Ce.FilledPrice)??((Dt=o.raw)==null?void 0:Dt.LimitPrice)??null,action:o.action??((Pe=o.raw)==null?void 0:Pe.Action)??((xn=o.raw)==null?void 0:xn.BuyOrSell)}),a=!0)}),a&&(nr.current=e,jf(o=>o+1))},[Gn,Hc,_e,Ve,$c,je,Oc,Ya]),x.useEffect(()=>{if(!ct){sr.current.initialized=!1,sr.current.seen.clear();return}if(!(mt!=null&&mt.entries)){sr.current.initialized=!1;return}const e=ot.orders==="ready"||ot.orders==="error",a=ot.historical==="ready"||ot.historical==="error";if(!e||!a)return;const l=sr.current,o=Array.from(nr.current.values());if(!l.initialized){o.forEach(u=>{const c=Gi(u);c&&l.seen.add(c)}),l.initialized=!0;return}o.forEach(u=>{const c=Gi(u);!c||l.seen.has(c)||(l.seen.add(c),Ja(Bc(u)))})},[mt==null?void 0:mt.entries,Gi,Bc,Ja,qc,ct]),x.useEffect(()=>{if(!N||!ct)return;const e=ex(a=>{Za(a)});return()=>{e()}},[Za,ct,N]),x.useEffect(()=>{if(!Un.length||typeof window>"u")return;const e=Un.map(a=>window.setTimeout(()=>{Kn(a.id)},4500));return()=>{e.forEach(a=>window.clearTimeout(a))}},[Kn,Un]),x.useEffect(()=>{if(!di||typeof document>"u")return;const e=a=>{var l;(l=dc.current)!=null&&l.contains(a.target)||ui(!1)};return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e)},[di]);const zc=x.useMemo(()=>{const e=_e(yt);if(!e)return[];const a=Array.from(nr.current.values());if(!a.length)return[];const l=!!(p!=null&&p.isAdmin&&!Ue),o=[],u=new Map;return a.forEach(c=>{if(c.normalizedSymbol!==e||Ue&&c.accountId!==Ue)return;const b=c.side==="buy"?"long":"short",v=c.side==="buy"?Gd.buy:Gd.sell,A=c.timeMs;
147if(!Number.isFinite(A))return;const C=typeof c.id=="string"?c.id:c.id!=null?String(c.id):null,E=je(c.quantityValue),L=je(c.priceValue);if(l){const Ce=mo(A),Dt=Ce?`${b}:${Ce}`:`${b}:${A}`,Pe=u.get(Dt)||{id:`fill:${e}:${Dt}`,timeMs:A,side:b,markerColor:v,count:0,totalQty:0,hasQty:!1,minPrice:null,maxPrice:null,orderIds:new Set};Pe.count+=1,Number.isFinite(E)&&(Pe.totalQty+=Math.abs(E),Pe.hasQty=!0),Number.isFinite(L)&&(Pe.minPrice=Pe.minPrice===null?L:Math.min(Pe.minPrice,L),Pe.maxPrice=Pe.maxPrice===null?L:Math.max(Pe.maxPrice,L)),C&&Pe.orderIds.add(C),u.set(Dt,Pe);return}const B=Ee(E!==null?Math.abs(E):E),te=L!==null?Wn(L):"-",le=te&&te!=="-"?te:null,re=B&&B!=="-"?B:null,se=le&&re?`${le} @ ${re}`:le||re,be=Qi(A),xt={title:c.side==="buy"?n("קנייה","Buy"):n("מכירה","Sell"),...be?{timestamp:be}:{},...se?{priceQuantity:se}:{},badgeText:"1"};o.push({id:`fill:${c.id}`,timeMs:A,side:b,markerColor:v,details:xt,orderIds:C?[C]:void 0})}),l&&u.forEach(c=>{const b=c.hasQty?Ee(c.totalQty):"-";let v="-";c.minPrice!==null&&(c.maxPrice!==null&&c.maxPrice!==c.minPrice?v=`${Wn(c.minPrice)}-${Wn(c.maxPrice)}`:v=Wn(c.minPrice));const A=v&&v!=="-"?v:null,C=b&&b!=="-"?b:null,E=A&&C?`${A} @ ${C}`:A||C,L=Qi(c.timeMs),te={title:c.side==="long"?n("קנייה","Buy"):n("מכירה","Sell"),...L?{timestamp:L}:{},...E?{priceQuantity:E}:{},badgeText:String(c.count)};o.push({id:c.id,timeMs:c.timeMs,side:c.side,markerColor:c.markerColor,details:te,orderIds:c.orderIds.size?Array.from(c.orderIds):void 0})}),o},[Wn,Qi,Ee,_e,je,mo,Ue,yt,n,p==null?void 0:p.isAdmin,qc]);x.useEffect(()=>{Nf(zc)},[zc]);const kf=x.useMemo(()=>{const e=()=>({count:0,sumQty:0,sumAbsQty:0,sumPnl:0,weightedPrice:0,weightedQty:0,totalMarketValue:0,totalMargin:0,latestTime:null}),a=new Map([["VX",{key:"VX",label:"VX · TradeStation",rows:[],stats:e()}],["ES",{key:"ES",label:"ES · TradeStation",rows:[],stats:e()}]]);return _t.forEach(o=>{const u=er(o.normalizedSymbol);a.has(u)||a.set(u,{key:u,label:u==="Other"?n("Other","Other"):u,rows:[],stats:e()});const c=a.get(u);if(c.rows.push(o),c.stats.count+=1,typeof o.quantityValue=="number"&&Number.isFinite(o.quantityValue)&&(c.stats.sumQty+=o.quantityValue,c.stats.sumAbsQty+=Math.abs(o.quantityValue),typeof o.averagePriceValue=="number"&&Number.isFinite(o.averagePriceValue))){const b=Math.abs(o.quantityValue);b>0&&(c.stats.weightedPrice+=o.averagePriceValue*b,c.stats.weightedQty+=b)}typeof o.pnlValue=="number"&&Number.isFinite(o.pnlValue)&&(c.stats.sumPnl+=o.pnlValue),typeof o.marketValueValue=="number"&&Number.isFinite(o.marketValueValue)&&(c.stats.totalMarketValue+=o.marketValueValue),typeof o.initialRequirementValue=="number"&&Number.isFinite(o.initialRequirementValue)&&(c.stats.totalMargin+=o.initialRequirementValue),typeof o.timeValue=="number"&&(c.stats.latestTime=c.stats.latestTime===null?o.timeValue:Math.max(c.stats.latestTime,o.timeValue))}),["VX","ES",...Array.from(a.keys()).filter(o=>o!=="VX"&&o!=="ES")].map(o=>{const u=a.get(o)??{key:o,label:o==="Other"?n("Other","Other"):o,rows:[],stats:e()},{stats:c}=u,b=c.count?c.sumQty/c.count:0,v=c.weightedQty>0?c.weightedPrice/c.weightedQty:null,A=c.latestTime!==null?Xe(c.latestTime):n("Unavailable","Unavailable");return{...u,stats:{...c,avgQty:b,avgPrice:v,latestTimeLabel:A}}})},[Xe,er,_t,n]),Af=x.useMemo(()=>{const e=()=>({count:0,sumQty:0,sumAbsQty:0,sumPnl:0,weightedPrice:0,weightedQty:0,latestTime:null}),a=new Map([["VX",{key:"VX",label:"VX · TradeStation",rows:[],stats:e()}],["ES",{key:"ES",label:"ES · TradeStation",rows:[],stats:e()}]]);return Ve.forEach(o=>{const u=er(o.normalizedSymbol);a.has(u)||a.set(u,{key:u,label:u==="Other"?n("Other","Other"):u,rows:[],stats:e()});const c=a.get(u);if(c.rows.push(o),c.stats.count+=1,typeof o.quantityValue=="number"&&Number.isFinite(o.quantityValue)&&(c.stats.sumQty+=o.quantityValue,c.stats.sumAbsQty+=Math.abs(o.quantityValue),typeof o.priceValue=="number"&&Number.isFinite(o.priceValue))){const b=Math.abs(o.quantityValue);b>0&&(c.stats.weightedPrice+=o.priceValue*b,c.stats.weightedQty+=b)}typeof o.timeValue=="number"&&(c.stats.latestTime=c.stats.latestTime===null?o.timeValue:Math.max(c.stats.latestTime,o.timeValue))}),["VX","ES",...Array.from(a.keys()).filter(o=>o!=="VX"&&o!=="ES")].map(o=>{const u=a.get(o)??{key:o,label:o==="Other"?n("Other","Other"):o,rows:[],stats:e()},{stats:c}=u,b=c.count?c.sumQty/c.count:0,v=c.weightedQty>0?c.weightedPrice/c.weightedQty:null,A=c.latestTime!==null?Xe(c.latestTime):n("Unavailable","Unavailable");return{...u,stats:{...c,avgQty:b,avgPrice:v,latestTimeLabel:A}}})},[Xe,er,Ve,n]),Sf=x.useMemo(()=>{const a={count:0,sumQty:0,sumAbsQty:0,sumPnl:0,weightedPrice:0,weightedQty:0,latestTime:null};Xi.forEach(c=>{if(a.count+=1,typeof c.quantityValue=="number"&&Number.isFinite(c.quantityValue)&&(a.sumQty+=c.quantityValue,a.sumAbsQty+=Math.abs(c.quantityValue),typeof c.priceValue=="number"&&Number.isFinite(c.priceValue))){const b=Math.abs(c.quantityValue);b>0&&(a.weightedPrice+=c.priceValue*b,a.weightedQty+=b)}typeof c.timeValue=="number"&&(a.latestTime=a.latestTime===null?c.timeValue:Math.max(a.latestTime,c.timeValue))});const l=a.count?a.sumQty/a.count:0,o=a.weightedQty>0?a.weightedPrice/a.weightedQty:null,u=a.latestTime!==null?Xe(a.latestTime):n("Unavailable","Unavailable");return{key:"Historical",label:n("היסטוריות","Historical"),rows:Xi,stats:{...a,avgQty:l,avgPrice:o,latestTimeLabel:u}}},[Xe,Xi,n]),Qc=x.useCallback(e=>{ah(a=>({...a,[e]:!a[e]}))},[]),Cf=x.useCallback(e=>{Co(a=>({...a,[e]:!a[e]}))},[]),Ef=x.useCallback(e=>{const a=Array.isArray(e==null?void 0:e.orderIds)?e.orderIds:[],l=Array.from(new Set(a.filter(o=>
147typeof o=="string"&&o.trim())));To(l),Ta("orders"),Co(o=>({...o,Historical:!0}))},[]),ar=ot.positions==="loading"||ot.positions==="refreshing",rr=ot.orders==="loading"||ot.orders==="refreshing",Tf=ot.historical==="loading"||ot.historical==="refreshing",Yi=x.useMemo(()=>Hi?Xe(Hi):n("Unavailable","Unavailable"),[Hi,Xe,n]),Pf=x.useMemo(()=>{const e=[],a=()=>{e.push({key:`gap-${e.length}`,kind:"gap"})};return e.push({key:"command",kind:"command",text:`> ${n("Live blotter snapshot","Live blotter snapshot")}`}),e.push({key:"account",kind:"info",text:`${n("Account","Account")}: ${ve}`}),e.push({key:"updated",kind:"muted",text:`${n("Updated","Updated")}: ${Yi}`}),a(),e.push({key:"positions-heading",kind:"info",text:`${n("Positions","Positions")} (${_t.length})`}),ar&&e.push({key:"positions-loading",kind:"muted",text:n("Loading positions...","Loading positions...")}),!ar&&_t.length===0&&e.push({key:"positions-empty",kind:"warn",text:n("No positions available","No positions available")}),_t.length>0&&_t.forEach(l=>{e.push({key:`pos-${l.id}`,kind:"success",indent:!0,text:`✔ ${l.symbol} • ${n("Qty","Qty")}: ${l.quantity} • ${n("P&L","P&L")}: ${l.pnl}`,details:[`${n("Status","Status")}: ${l.status}`,`${n("Updated","Updated")}: ${l.time}`,...Array.isArray(l.timeUpdates)?l.timeUpdates:[]]})}),a(),e.push({key:"orders-heading",kind:"info",text:`${n("Orders","Orders")} (${Ve.length})`}),rr&&e.push({key:"orders-loading",kind:"muted",text:n("Loading orders...","Loading orders...")}),!rr&&Ve.length===0&&e.push({key:"orders-empty",kind:"warn",text:n("No orders available","No orders available")}),Ve.length>0&&Ve.forEach(l=>{const o=(l.status||"").toLowerCase();let u="info";o.includes("filled")?u="success":o.includes("rejected")?u="error":o.includes("cancel")&&(u="warn");const c=[`${n("Updated","Updated")}: ${l.time}`];l.priceType&&l.price&&c.push(`${l.priceType}: ${l.price}`),l.qtyLeft&&c.push(`${n("Remaining","Remaining")}: ${l.qtyLeft}`),l.filledLabel&&c.push(`${n("Filled","Filled")}: ${l.filledLabel}`),Array.isArray(l.timeUpdates)&&l.timeUpdates.length&&c.push(...l.timeUpdates),e.push({key:`order-${l.id}`,kind:u,indent:!0,text:`${u==="success"?"✔":u==="error"?"✖":"•"} ${l.symbol} • ${n("Ordered","Ordered")}: ${l.qtyOrdered} • ${n("Status","Status")}: ${l.status}`,details:c})}),a(),e.push({key:"raw-hint",kind:"muted",text:n("Use refresh to pull the latest data or copy the JSON payload for debugging.","Use refresh to pull the latest data or copy the JSON payload for debugging.")}),e},[Yi,rr,ar,r,Ve,_t,ve,n]),Wc=x.useMemo(()=>({positions:_t.map(e=>e.raw??e),orders:Ve.map(e=>e.raw??e)}),[_t,Ve]),Kc=x.useMemo(()=>JSON.stringify(Wc,null,2),[Wc]),If=()=>{if(!Nt)return null;const e="crm-blotter-terminal-title",a={command:h("text-white","text-slate-100"),info:h("text-sky-300","text-sky-500"),success:h("text-emerald-400","text-emerald-500"),warn:h("text-amber-300","text-amber-500"),muted:h("text-white/55","text-slate-400"),error:h("text-rose-400","text-rose-500")},l=async()=>{try{typeof navigator<"u"&&(navigator!=null&&navigator.clipboard)&&(await navigator.clipboard.writeText(Kc),Jr(!0))}catch(u){console.warn("[crm] Unable to copy blotter payload",u),Jr(!1)}},o=t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[t.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:()=>Zt(!1),"aria-hidden":"true"}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":e,className:`relative flex max-h-[85vh] w-[min(92vw,40rem)] flex-col overflow-hidden rounded-2xl border shadow-[0_25px_70px_rgba(0,0,0,0.65)] ${h("bg-white/[0.02] border-white/10 text-white","bg-slate-950 border-slate-800 text-slate-100")}`,children:[t.jsxs("div",{className:`flex items-center justify-between px-5 py-4 ${h("border-white/10","border-slate-800")} border-b`,children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"h-3 w-3 rounded-full bg-rose-500"}),t.jsx("span",{className:"h-3 w-3 rounded-full bg-amber-400"}),t.jsx("span",{className:"h-3 w-3 rounded-full bg-emerald-500"})]}),t.jsx("div",{className:"text-sm font-semibold",id:e,children:n("Live blotter terminal","Live blotter terminal")})]}),t.jsxs("div",{className:`flex items-center gap-2 ${r==="HE"?"flex-row-reverse":""}`,children:[t.jsx("button",{type:"button",onClick:l,className:`w-9 h-9 grid place-items-center rounded-full transition-colors ${h("bg-white/10 hover:bg-white/15 text-white","bg-slate-800 hover:bg-slate-700 text-slate-100")}`,title:n("Copy JSON payload","Copy JSON payload"),"aria-label":n("Copy JSON payload","Copy JSON payload"),children:Yr?t.jsx(ta,{className:"w-4 h-4"}):t.jsx(_x,{className:"w-4 h-4"})}),t.jsx("button",{type:"button",onClick:()=>me==null?void 0:me(),className:`w-9 h-9 grid place-items-center rounded-full transition-colors ${h("bg-white/10 hover:bg-white/15 text-white","bg-slate-800 hover:bg-slate-700 text-slate-100")}`,title:n("Refresh data","Refresh data"),"aria-label":n("Refresh data","Refresh data"),children:t.jsx(Bt,{className:"w-4 h-4"})}),t.jsx("button",{type:"button",onClick:()=>Zt(!1),className:`w-9 h-9 grid place-items-center rounded-full transition-colors ${h("bg-white/10 hover:bg-white/15 text-white","bg-slate-800 hover:bg-slate-700 text-slate-100")}`,"aria-label":n("Close","Close"),children:t.jsx("span",{className:"text-lg leading-none",children:"×"})})]})]}),t.jsxs("div",{className:`flex-1 overflow-auto px-6 py-6 font-mono text-sm leading-relaxed ${h("bg-black/30","bg-slate-900/60")}`,dir:"ltr",children:[t.jsx("div",{className:"space-y-3",children:Pf.map(u=>{if(u.kind==="gap")return t.jsx("div",{className:"h-2","aria-hidden":!0},u.key);const c=a[u.kind]??a.info,b=u.indent?r==="HE"?"pr-6":"pl-6":"";return t.jsxs("div",{className:m("whitespace-pre-wrap break-words transition-all duration-200",c,b),children:[t.jsx("div",{children:u.text}),Array.isArray(u.details)&&u.details.length>0&&t.jsx("div",{className:m("mt-1 text-xs",h("text-white/45","text-slate-400"),u.indent?r==="HE"?"pr-2":"pl-2":"",r==="HE"?"text-right":"text-left"),children:u.details.join(" | ")})]},u.key)})}),t.jsxs("div",{className:`mt-6 rounded-xl border shadow-lg px-4 py-3 text-xs ${h("border-white/10 bg-black/40 text-white/80","border-slate-700 bg-slate-900/80 text-slate-200")}`,children:[t.jsx("div",{className:"font-semibold uppercase tracking-wide text-[11px]",children:n("Raw payload","Raw payload")}),t.jsx("div",{className:"mt-2 max-h-48 overflow-auto",children:t.jsx("pre",{className:"whitespace-pre text-xs leading-relaxed",children:Kc})})]})]})]})]});return typeof document<"u"?xr.createPortal(o,document.body):o},$f=_t.length,Lf=Ve.length;p!=null&&p.isAdmin;const Gc=({group:e,type:a,isOpen:l,onToggle:o,children:u})=>{var Ce;const c=((Ce=e.rows[0])==null?void 0:Ce.currency)||"USD",b=e.stats||{},v=Number.isFinite(b.sumQty)?b.sumQty:0,A=Number.isFinite(b.sumAbsQty)?b.sumAbsQty:0,C=Number.isFinite(b.avgPrice)?Ne(b.avgPrice,c):"-",
147E=Number.isFinite(b.sumPnl)?Ne(b.sumPnl,c):"-",L=Number.isFinite(b.totalMarketValue)&&b.totalMarketValue!==0?Ne(b.totalMarketValue,c):null,B=Number.isFinite(b.totalMargin)&&b.totalMargin!==0?Ne(b.totalMargin,c):null,te=b.latestTimeLabel??n("Unavailable","Unavailable"),le=typeof b.count=="number"?b.count:e.rows.length,re=r==="HE"?`${n("No","No")} ${a==="positions"?n("Positions","Positions"):n("Orders","Orders")} ${e.label}`:`${n("No","No")} ${e.label} ${a==="positions"?n("Positions","Positions"):n("Orders","Orders")}`,se=h("text-white/70","text-gray-600"),be=e.key==="Historical",De=e.key!=="V1"&&e.key!=="S1"&&!be,xt=be?n("הזמנות היסטוריות","Historical Orders"):De?`${e.label} ${n("Group","Group")}`:e.label;return t.jsxs("div",{className:m("rounded-xl border shadow-lg",h("bg-white/5 border-white/10","bg-gray-100 border-black/5")),children:[t.jsxs("div",{className:m("flex items-center justify-between gap-3 px-4 py-3"),children:[t.jsxs("div",{dir:r==="HE"?"rtl":"ltr",className:m("flex flex-1 min-w-0 flex-col gap-1",r==="HE"&&"items-end text-right"),children:[t.jsxs("div",{className:m("flex items-center gap-2",r==="HE"&&"w-full"),children:[t.jsx("span",{className:"text-sm font-semibold",children:`${xt} (${le})`}),t.jsxs("span",{className:`text-[11px] px-2 py-0.5 rounded-full ${h("bg-white/10 text-white/80","bg-gray-200 text-gray-700")}`,children:[n("Abs qty","Abs qty"),": ",Ee(A)]})]}),t.jsxs("div",{className:m("flex flex-wrap gap-4 text-xs",se,r==="HE"&&"w-full"),children:[t.jsx("span",{children:`${n("Total qty","Total qty")}: ${Ee(v)}`}),t.jsx("span",{children:`${n("Avg Price","Avg Price")}: ${C}`}),a==="positions"&&t.jsx("span",{children:`${n("P&L","P&L")}: ${E}`}),a==="positions"&&L&&t.jsx("span",{children:`${n("Market Value","Market Value")}: ${L}`}),a==="positions"&&B&&t.jsx("span",{children:`${n("Margin","Margin")}: ${B}`}),t.jsx("span",{children:`${n("Updated","Updated")}: ${te}`})]}),e.rows.length===0&&t.jsx("div",{className:m("text-xs w-full",se,r==="HE"&&"text-right"),children:re})]}),t.jsx("button",{type:"button",onClick:o,className:m("w-10 h-10 grid place-items-center rounded-full border transition-colors",h(l?"bg-amber-200/10 border-amber-300/70 text-amber-100 hover:bg-amber-200/20":"bg-white/10 border-white/20 text-white hover:bg-white/15",l?"bg-amber-100 border-amber-300 text-amber-700 hover:bg-amber-200":"bg-gray-200 border-gray-300 text-gray-800 hover:bg-gray-300")),"aria-expanded":l,"aria-label":l?n("Collapse group","Collapse group"):n("Expand group","Expand group"),children:l?t.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M5 12h14"})}):t.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5 12h14"}),t.jsx("path",{d:"M12 5v14"})]})})]}),l&&t.jsx("div",{className:m("border-t px-3 py-3 space-y-3",h("border-white/10 bg-white/5","border-black/10 bg-gray-50")),children:e.rows.length>0?u:t.jsx("div",{dir:r==="HE"?"rtl":"ltr",className:m("w-full rounded-lg border shadow-sm px-4 py-3 text-sm",h("border-white/10 bg-white/5 text-white/70","border-black/10 bg-gray-50 text-gray-600"),r==="HE"&&"text-right"),children:re})})]})},Xc=({group:e,showActions:a=!1})=>{const l=!!a,o=l?"grid-cols-7":"grid-cols-6",u=l?"sm:grid-cols-7":"sm:grid-cols-6";return t.jsxs(Gc,{group:e,type:"orders",isOpen:!!rh[e.key],onToggle:()=>Cf(e.key),children:[e.rows.length>0&&t.jsxs("div",{className:`hidden sm:grid ${o} ${h("text-white/60","text-gray-600")} text-xs px-3`,children:[t.jsx("div",{className:fe(),children:n("Time","Time")}),t.jsx("div",{className:fe(),children:n("Name","Name")}),t.jsx("div",{className:fe(),children:n("Status","Status")}),t.jsx("div",{className:fe(),children:n("Quantity","Quantity")}),t.jsx("div",{className:fe(),children:n("Price","Price")}),t.jsx("div",{className:fe(),children:n("Symbol","Symbol")}),l&&t.jsx("div",{className:m("text-end",fe()),children:n("Actions","Actions")})]}),e.rows.map((c,b)=>
147{const v=c.id!=null?String(c.id):null,A=c.orderId!=null?String(c.orderId):null,E=e.key==="Historical"&&jt.size>0&&(v&&jt.has(v)||A&&jt.has(A))?h("bg-emerald-500/10 border-emerald-400/40","bg-emerald-50 border-emerald-200"):h("bg-white/5 border-white/10","bg-gray-100 border-black/5");return t.jsxs("div",{className:m("grid gap-y-4 sm:items-center rounded-lg border shadow-sm px-3 py-3",u,E),children:[t.jsxs("div",{className:m(lt,fe()),children:[t.jsx("span",{className:it,children:n("Time","Time")}),t.jsxs("div",{className:m("group relative mt-1 flex items-center gap-2 sm:mt-0"),children:[t.jsxs("span",{className:"relative flex h-2.5 w-2.5",children:[t.jsx("span",{className:"absolute inline-flex h-full w-full rounded-full bg-emerald-500 opacity-75 animate-ping"}),t.jsx("span",{className:"relative inline-flex h-2.5 w-2.5 rounded-full bg-emerald-400"})]}),t.jsx("span",{children:c.time}),Array.isArray(c.timeUpdates)&&c.timeUpdates.length>0&&t.jsx("div",{className:h("pointer-events-none absolute -top-10 left-1/2 -translate-x-1/2 whitespace-nowrap rounded-full border border-emerald-400/60 bg-emerald-500/90 px-3 py-1 text-[11px] font-medium text-white shadow-[0_10px_30px_rgba(16,185,129,0.35)] opacity-0 transition-opacity duration-150 group-hover:opacity-100","pointer-events-none absolute -top-10 left-1/2 -translate-x-1/2 whitespace-nowrap rounded-full border border-emerald-400/30 bg-emerald-500/85 px-3 py-1 text-[11px] font-medium text-white shadow-[0_10px_24px_rgba(16,185,129,0.25)] opacity-0 transition-opacity duration-150 group-hover:opacity-100"),children:c.timeUpdates.join(" • ")})]})]}),t.jsxs("div",{className:m(lt,fe()),children:[t.jsx("span",{className:it,children:n("Name","Name")}),t.jsx("div",{className:"mt-1 sm:mt-0",children:c.name})]}),t.jsxs("div",{className:m(lt,fe()),children:[t.jsx("span",{className:it,children:n("Status","Status")}),t.jsx("div",{className:m("mt-1 text-sm sm:mt-0",h("text-white/40","text-gray-500")),children:c.status})]}),t.jsxs("div",{className:m(lt,fe()),children:[t.jsx("span",{className:it,children:n("Quantity","Quantity")}),t.jsxs("div",{className:"group relative mt-1 flex items-center sm:mt-0",children:[t.jsx("span",{children:c.qtyOrdered}),t.jsx("div",{className:h("pointer-events-none absolute -top-10 left-1/2 -translate-x-1/2 whitespace-nowrap rounded-full border border-emerald-400/60 bg-emerald-500/90 px-3 py-1 text-[11px] font-medium text-white shadow-[0_10px_30px_rgba(16,185,129,0.35)] opacity-0 transition-opacity duration-150 group-hover:opacity-100","pointer-events-none absolute -top-10 left-1/2 -translate-x-1/2 whitespace-nowrap rounded-full border border-emerald-400/30 bg-emerald-500/85 px-3 py-1 text-[11px] font-medium text-white shadow-[0_10px_24px_rgba(16,185,129,0.25)] opacity-0 transition-opacity duration-150 group-hover:opacity-100"),children:t.jsxs("div",{className:"flex flex-col items-center gap-0.5",children:[t.jsx("span",{children:n("שווי כספי 200,000$","Cash Value $200,000")}),t.jsx("span",{className:"text-[10px] font-normal opacity-90",children:n("מאגין 15,700$","Margin $15,700")})]})})]})]}),t.jsxs("div",{className:m(lt,fe()),children:[t.jsx("span",{className:it,children:n("Price","Price")}),t.jsx("div",{className:"mt-1 font-medium sm:mt-0",children:c.price})]}),t.jsxs("div",{className:m(lt,fe()),children:[t.jsx("span",{className:it,children:n("Symbol","Symbol")}),t.jsx("div",{className:m("mt-1 min-w-0 sm:mt-0 truncate",r==="HE"?"text-right":"text-left"),title:c.symbol,children:c.symbol})]}),l&&t.jsxs("div",{className:m(lt,fe()),children:[t.jsx("span",{className:it,children:n("Actions","Actions")}),t.jsxs("div",{className:m("mt-1 flex items-center gap-2 sm:mt-0 justify-end"),children:[t.jsx("button",{type:"button",onClick:()=>yf(c),disabled:!c.orderId||$n[c.orderId],className:`w-8 h-8 grid place-items-center rounded-full ${h("bg-white/10 hover:bg-white/15 text-white","bg-gray-100 hover:bg-gray-200 text-gray-800")} ${$n[c.orderId]?"opacity-50 cursor-not-allowed":""}`,"aria-label":n("Edit order","Edit order"),title:n("Edit order","Edit order"),children:t.jsx(Yx,{className:"w-4 h-4"})}),t.jsx("button",{type:"button","data-cancel-order-id":c.orderId||void 0,onClick:L=>{if(L.stopPropagation(),!(!(c!=null&&c.orderId)||$n[c.orderId])){if(Pt===c.orderId){Xs(null),Me.current&&(window.clearTimeout(
147Me.current),Me.current=null),gf(c);return}Xs(c.orderId),Me.current&&window.clearTimeout(Me.current),Me.current=window.setTimeout(()=>{Xs(null),Me.current=null},6e3)}},disabled:!c.orderId||$n[c.orderId],className:`w-8 h-8 grid place-items-center rounded-full ${Pt===c.orderId?h("bg-emerald-500/80 hover:bg-emerald-500 text-white","bg-emerald-100 hover:bg-emerald-200 text-emerald-700"):h("bg-rose-500/80 hover:bg-rose-500 text-white","bg-rose-100 hover:bg-rose-200 text-rose-700")} ${$n[c.orderId]?"opacity-50 cursor-not-allowed":""}`,"aria-label":Pt===c.orderId?n("Confirm cancel","Confirm cancel"):n("Cancel","Cancel"),title:Pt===c.orderId?n("Confirm cancel","Confirm cancel"):n("Cancel","Cancel"),children:Pt===c.orderId?t.jsx(ta,{className:"w-4 h-4"}):t.jsx(ms,{className:"w-4 h-4"})})]})]})]},c.id||`${c.symbol}-${b}`)})]})},Ji=x.useCallback((e,a)=>{if(a<=1)return"rounded-full";const l="rounded-none";return r==="HE"?e===0?`${l} rounded-r-full`:e===a-1?`${l} rounded-l-full`:l:e===0?`${l} rounded-l-full`:e===a-1?`${l} rounded-r-full`:l},[r]),fn=x.useMemo(()=>{const e={General:{tab:"General",label:i("General"),description:n("סקירה מהירה וגישה לכל ההעדפות","Overview and shortcuts to every preference"),targetId:"settings-general",keywords:[i("General"),i("Settings"),"overview","profile","account","preferences"]},Accounts:{tab:"Accounts",label:i("Accounts"),description:n("חיבורים, הרשאות וחשבונות מסחר","Connections, permissions, and trading accounts"),targetId:"settings-accounts",keywords:[i("Accounts"),n("Account","Account"),n("Customers","Customers"),"accounts","users","positions"]},"Graph Settings":{tab:"Graph Settings",label:i("Graph Settings"),description:n("תצוגה, אינדיקטורים וברירות מחדל","Display, indicators, and chart defaults"),targetId:"settings-graph",keywords:[i("Graph Settings"),n("Graph","Graph"),n("Chart","Chart"),n("Indicators","Indicators"),"chart","graph","appearance"]},Alerts:{tab:"Alerts",label:i("Alerts"),description:n("ערוצים, שעות שקטות וכללי אירועים","Channels, quiet hours, and event rules"),targetId:"settings-alerts",keywords:[i("Alerts"),n("Notifications","Notifications"),n("Sound","Sound"),n("Trading alerts","Trading alerts"),"alerts","notifications","sound"]},Language:{tab:"Language",label:i("Language"),description:n("שפת הממשק וכיוון התצוגה","Interface language and reading direction"),targetId:"settings-language",keywords:[i("Language"),"language","locale","hebrew","english"]},Theme:{tab:"Theme",label:i("Theme"),description:n("המראה, הניגודיות והעדפת החשבון","Appearance, contrast, and account preference"),targetId:"settings-theme",keywords:[i("Theme"),i("Dark"),i("Light"),"theme","appearance","mode"]},Downloads:{tab:"Downloads",label:i("Downloads"),description:n("יישומים, חבילות וייצוא","Apps, packages, and exports"),targetId:"settings-downloads",keywords:[i("Downloads"),"downloads","export","files"]},System:{tab:"System",label:i("System"),description:n("בקרה, יציבות ויומן פעילות","Control, stability, and activity logs"),targetId:"settings-system",keywords:[i("System"),i("Program Control"),n("יומן מערכת","System Logs"),n("סקירת מערכת","System Overview"),n("בריאות זרמי חשבון","Account Stream Health"),"monitor","logs","status","settings","program","control"]}};return _b({isAdmin:!!(p!=null&&p.isAdmin),isNative:ls}).map(a=>e[a])},[i,n,p==null?void 0:p.isAdmin]);g.useEffect(()=>{fn.some(e=>e.tab===st)||(ts("General"),ss([]),qt("settings-general"))},[fn,st]);const Yc=x.useCallback(e=>{const a=e.trim().toLowerCase();if(Pa(e),!a){ss([]),qt(null);return}const l=fn.map(o=>{const u=o.keywords.reduce((c,b)=>{const v=b.toLowerCase();return v===a?Math.min(c,0):v.startsWith(a)?Math.min(c,1):v.includes(a)?Math.min(c,2):c},3);return{...o,score:u}}).filter(o=>o.score<3).sort((o,u)=>o.score-u.score||o.tab.localeCompare(u.tab));if(ss(l.slice(0,5)),l.length){const o=l[0];o.tab!==st&&ts(o.tab),qt(o.targetId)}},[fn,st,ts,ss,qt]),Rf=x.useCallback(e=>{Yc(e.target.value)},[Yc]),Mf=x.useCallback(e=>{ts(e.tab),ss([]),e!=null&&e.label&&Pa(e.label),qt(e.targetId)},[ts,ss,Pa]);g.useEffect(()=>{if(!ei)return;const e=ei,a=window.requestAnimationFrame(()=>{const l=document.getElementById(e);if(l)try{l.scrollIntoView({behavior:"smooth",block:"start"})}catch{l.scrollIntoView()}qt(null)});return()=>window.cancelAnimationFrame(a)},[ei]),g.useEffect(()=>{es(e=>{const a=Qe();return e==="All Accounts"||e===a?a:e})},[Qe]),g.useEffect(()=>{if(ra(!1),tc(null),!N)return;let e=!0;const a=new AbortController;return tx({signal:a.signal}).then(l=>{if(!e)return;const o=(l==null?void 0:l.settings)??{},u=o==null?void 0:o[Kd];if(u&&typeof u=="object"){const v={primary:Ie({indicatorEnabled:!!(p!=null&&p.isAdmin)}),secondary:Ie({indicatorEnabled:!!(p!=null&&p.isAdmin)})},A=L0(u,v),C=p!=null&&p.isAdmin?A.primary:{...A.primary,indicatorEnabled:!1},E=p!=null&&p.isAdmin?A.secondary:{...A.secondary,indicatorEnabled:!1};Ze(C),Et(E),R(Ie(C)),Fe(Ie(E)),typeof u.icebergEnabled=="boolean"&&(Ml(u.icebergEnabled),ia(u.icebergEnabled))}const c=o==null?void 0:o[Xd];if(c&&typeof c=="object"){const v=wl(c);qo(v.enabled),La(v.systemNotifications),zo(v.inAppToasts),Qo(v.badge),Wo(v.routingMode),Ko(v.privacyMode),Go(v.quietHours.endTime),Xo(v.quietHours.startTime),li(Nl(v.events)),Yo(v.sound.name),Jo(!v.sound.enabled)}const b=o==null?void 0:o[Yd];if(b&&typeof b=="object")if(b.themeMode==="dark"||b.themeMode==="light")mc(b.themeMode);else{try{localStorage.removeItem("crm_theme")}catch{}ur()&&us(async()=>{const{Preferences:v}=await import("./index-h3aeLNcf.js");return{Preferences:v}},__vite__mapDeps([22,3,1,2,4])).then(({Preferences:v})=>v.remove({key:"crm_theme"})).catch(()=>{})}}).catch(l=>{e&&tc((l==null?void 0:l.message)??n("לא ניתן לטעון את ההגדרות","Unable to load settings"))}).finally(()=>{e&&ra(!0),ur()&&requestAnimationFrame(async()=>{try{const{SplashScreen:l}=await us(async()=>{const{SplashScreen:o}=await import("./index-H4YhSQIS.js");return{SplashScreen:o}},__vite__mapDeps([23,3,1,2,4]));await l.hide()}catch{}})}),()=>{e=!1,a.abort()}},[N,n,p==null?void 0:p.isAdmin]);const Jc=!1,Zc=t.jsxs("div",{className:`relative flex w-full items-center overflow-hidden rounded-full shadow-md ${h("bg-white/[0.03]","bg-slate-200/70")}`,onPointerLeave:()=>Fa(null),children:[t.jsxs("div",{className:`alfa-segment-indicator-motion pointer-events-none absolute inset-y-0 left-0 rounded-full transition-transform motion-reduce:transition-none ${h("bg-gradient-to-b from-white via-white to-[#ededed] shadow-[0_10px_28px_rgba(0,0,0,0.45)] border border-white/40","bg-white shadow-[0_8px_18px_rgba(15,23,42,0.12)] ring-1 ring-slate-200/70")}`,style:{width:rf,transform:`translateX(${lf*100}%)`}
147,"aria-hidden":!0,children:[t.jsx("span",{className:"absolute inset-0 rounded-full shadow-[inset_0_1px_0_rgba(255,255,255,0.8)]"}),t.jsx("span",{className:`absolute inset-x-3 bottom-[6px] h-2 rounded-full blur-sm ${h("bg-black/25","bg-slate-300/30")}`})]}),Ri.map((e,a)=>{const l=he===e.key,u=Oi===a?h("text-gray-900","text-gray-900"):h("text-white/80 hover:bg-white/20 hover:text-white","text-slate-600 hover:text-slate-900 hover:bg-white/60");return t.jsx("button",{onClick:()=>zn(e.key),className:m("alfa-segment-button-motion relative z-10 flex-1 whitespace-nowrap font-semibold transition-[color,background-color,transform] motion-safe:active:scale-[0.985] motion-reduce:transition-none focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2",Ji(a,Mi),X?"px-5 py-2 text-sm":"px-8 py-3 text-base",h("focus-visible:outline-white/70","focus-visible:outline-gray-900/40"),u),type:"button","aria-pressed":l,onPointerEnter:()=>Fa(a),onFocus:()=>Fa(a),onBlur:c=>{var b;(b=c.currentTarget.parentElement)!=null&&b.contains(c.relatedTarget)||Fa(null)},children:t.jsx("span",{className:`${r==="HE"?"text-right":""}`,children:t.jsx(Nm,{label:i(e.label)})})},e.key)})]}),Of=t.jsx("nav",{className:"mx-auto w-full max-w-2xl px-1","aria-label":n("מצבי עבודה לאובייקט הנבחר","Selected object work modes"),children:Zc});return t.jsxs("div",{dir:r==="HE"?"rtl":"ltr",className:m("w-full max-w-full overflow-x-hidden",X?"flex flex-col h-[100dvh] overflow-hidden pt-0":"min-h-screen pt-6",h("bg-[#14171A] text-gray-200","bg-white text-gray-900"),Se?"crm-theme--dark":"crm-theme--light"),children:[!X&&t.jsxs("header",{ref:Po,className:m("relative flex min-h-24 items-center gap-4 px-4 sm:px-8 lg:px-[4.5rem] py-4",r==="HE"&&"flex-row-reverse",X&&`sticky top-0 z-40 justify-between gap-3 px-4 py-3 border-b ${h("bg-white/[0.02] border-white/10","bg-white/95 border-gray-200")} shadow-sm`),style:X?{paddingTop:"calc(0.75rem + env(safe-area-inset-top, 0px))",minHeight:"calc(3rem + env(safe-area-inset-top, 0px))"}:void 0,children:[t.jsx("div",{className:m("flex-1",X&&"hidden")}),t.jsx("div",{className:"flex flex-1 min-w-0 justify-center px-1",children:!$&&t.jsx("div",{className:"w-full max-w-2xl",children:Zc})}),$&&t.jsx("div",{ref:Q,className:"pointer-events-auto absolute left-[4.5rem] right-[9.5rem] top-1/2 z-20 min-w-0 -translate-y-1/2","data-owner-material-navigation-slot":"true"}),t.jsx("div",{className:m("flex-1 flex",r==="HE"?"justify-start":"justify-end",X&&"flex-none ml-auto"),children:t.jsx("div",{className:m("relative z-30 flex items-center gap-3",r==="HE"&&"flex-row-reverse"),children:t.jsx(em,{open:Jm,onOpenChange:qs,user:p,userDisplayName:W,userAvatarUrl:U,language:r,isDark:Se,t:i,tr:n,onOpenSettings:()=>wc("General"),triggerRef:qr,onLogout:()=>{I(),qs(!1),w("/Login",{replace:!0})}})})})]}),t.jsx("div",{className:X?"native-scroll-frame flex-1 flex flex-col gap-3 px-3 overflow-y-auto overflow-x-hidden":"flex w-full min-w-0 overflow-x-hidden",children:t.jsxs("main",{dir:r==="HE"?"rtl":"ltr",className:m("flex-1 w-full min-w-0",r==="HE"?"text-right":"text-left",X?"px-1 pt-3 pb-4 space-y-3":"px-4 sm:px-8 lg:px-[4.5rem] py-5 space-y-6",!X&&Yt===ae.COMPACT&&"pb-28"),children:[Si&&t.jsxs("section",{className:"space-y-4",children:[t.jsx("div",{className:m("rounded-2xl border p-4",h("bg-white/[0.03] border-white/10 text-white","bg-white border-gray-200 text-gray-900")),children:t.jsx("div",{className:m("flex items-center justify-between gap-3",r==="HE"?"flex-row-reverse text-right":"text-left"),children:t.jsxs("div",{className:m("flex items-center gap-3 min-w-0",r==="HE"?"flex-row-reverse":""),children:[t.jsx("div",{className:m("h-12 w-12 rounded-full border overflow-hidden flex items-center justify-center shadow-sm",h("border-white/10 bg-white/5","border-gray-200 bg-gray-100")),children:U?t.jsx("img",{src:U,alt:W,className:"h-full w-full object-cover"}):t.jsx(ml,{className:m("h-6 w-6",h("text-white/60","text-gray-500"))})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-sm font-semibold truncate",children:W}),t.jsx("div",{className:m("text-xs opacity-70",h("text-white/60","text-gray-500")),children:n("תפריט ראשי","Main menu")})]})]})})}),t.jsxs("div",{className:"space-y-2",dir:r==="HE"?"rtl":"ltr",children:[ls&&M&&t.jsxs("button",{type:"button",onClick:()=>{Ga(),zn("movement")},className:Hn,"aria-label":n("גרף בזמן אמת","Real-time chart"),title:n("גרף בזמן אמת","Real-time chart"),children:[t.jsxs("span",{className:qn,children:[t.jsx(gu,{className:"h-5 w-5"}),t.jsx("span",{children:n("גרף בזמן אמת","Real-time chart")})]}),t.jsx("span",{className:Va,"aria-hidden":"true",children:Ha})]}),!ls&&M&&t.jsxs("button",{type:"button",onClick:()=>{Ga(),zn("backtest")},className:Hn,"aria-label":i("חישובים"),title:i("חישובים"),children:[t.jsxs("span",{className:qn,children:[t.jsx(sa,{className:"h-5 w-5"}),t.jsx("span",{children:i("חישובים")})]}),t.jsx("span",{className:Va,"aria-hidden":"true",children:Ha})]}),t.jsxs("button",{ref:zr,type:"button",onClick:Xh,className:Hn,"aria-label":i("Chat"),title:i("Chat"),children:[t.jsxs("span",{className:qn,children:[t.jsx(dl,{className:"h-5 w-5"}),t.jsx("span",{children:i("Chat")})]}),t.jsx("span",{className:Va,"aria-hidden":"true",children:Ha})]}),t.jsxs("button",{type:"button",onClick:()=>wc("General"),className:Hn,"aria-label":i("Settings"),title:i("Settings"),children:[t.jsxs("span",{className:qn,children:[t.jsx(ul,{className:"h-5 w-5"}),t.jsx("span",{children:i("Settings")})]}),t.jsx("span",{className:Va,"aria-hidden":"true",children:Ha})]})]}),t.jsx("div",{className:"space-y-2",children:t.jsx("button",{type:"button",onClick:()=>{I(),w("/Login",{replace:!0})},className:m(Hn,h("border-rose-500/30 bg-rose-500/10 text-rose-100 hover:bg-rose-500/20","border-rose-200 bg-rose-50 text-rose-600 hover:bg-rose-100")),"aria-label":i("Logout"),title:i("Logout"),children:t.jsx("span",{className:qn,children:t.jsx("span",{children:i("Logout")})})})})]}),t.jsxs(jm,{enabled:$,target:G,children:[he==="movement"&&t.jsx(x.Suspense,{fallback:t.jsx(Ft,{className:"min-h-[28rem] w-full rounded-2xl"}),children:t.jsxs("section",{dir:"ltr",className:X?"space-y-4":"flex flex-col gap-4",children:[t.jsxs("div",{ref:X?null:wi,className:m(!X&&"flex gap-4 xl:gap-6 items-start"),children:[t.jsxs("div",{dir:r==="HE"?"rtl":"ltr",className:m("flex flex-col",!X&&"gap-4"),style:X?void 0:{width:`${Ch}%`,flexShrink:0},children:[t.jsx("section",{className:m(`${h("bg-white/[0.03] border-white/10","bg-white border-black/10")} border rounded-xl shadow-lg overflow-hidden flex flex-col`,!X&&"min-h-0"),style:X?void 0:{height:Qa,flexShrink:0},children:t.jsxs("div",{className:"flex-1 min-h-0",children:[Ut&&t.jsx("div",{className:"p-6 text-sm text-rose-500",children:Ut}),vr&&!P&&!Ut&&t.jsx("div",{className:"h-full p-4",children:t.jsx(Ft,{className:m("h-full min-h-[240px] w-full rounded-lg",h("bg-white/10","bg-gray-200"))})}),(P==null?void 0:P.indicator)&&yt&&t.jsx(f0,{symbol:yt,indicatorConfig:P.indicator,height:uf,theme:Se?"dark":"light",locale:f,resolutions:D,spans:J,activeResolutionId:ge.resolutionId,activeSpanId:ge.spanId,indicatorEnabled:p!=null&&p.isAdmin?ge.indicatorEnabled:!1,bollingerUpperEnabled:ge.bollingerUpperEnabled,bollingerLowerEnabled:ge.bollingerLowerEnabled,showLastPrice
147Label:ge.showLastPriceLabel,showBidAskLabels:ge.showBidAskLabels,showIndicatorLabels:ge.showIndicatorLabels,entryMarkers:vf,onEntryMarkerSelect:Ef,visible:he==="movement",translate:i,getDirection:()=>d?"rtl":"ltr"})]})}),Jc]}),!X&&t.jsxs("div",{className:m("relative flex-shrink-0 w-1 cursor-col-resize group"),style:{height:Qa},onMouseDown:Th,children:[t.jsx("div",{className:m("absolute inset-y-0 -left-1 -right-1 transition-colors",h("hover:bg-white/10","hover:bg-black/5"),"group-active:bg-blue-500/30")}),t.jsxs("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 flex flex-col gap-1",children:[t.jsx("div",{className:m("w-1 h-1 rounded-full",h("bg-white/30 group-hover:bg-white/60","bg-black/20 group-hover:bg-black/40"))}),t.jsx("div",{className:m("w-1 h-1 rounded-full",h("bg-white/30 group-hover:bg-white/60","bg-black/20 group-hover:bg-black/40"))}),t.jsx("div",{className:m("w-1 h-1 rounded-full",h("bg-white/30 group-hover:bg-white/60","bg-black/20 group-hover:bg-black/40"))})]})]}),t.jsx("div",{dir:r==="HE"?"rtl":"ltr",className:`flex flex-col gap-4 ${X?"":"lg:sticky lg:top-4"}`,style:X?void 0:{flex:1,minWidth:0,height:Qa},children:t.jsxs("section",{className:`${h("bg-white/[0.03] border-white/10","bg-white border-black/10")} border rounded-xl shadow-lg flex flex-col ${X?"":"flex-1 min-h-0 overflow-hidden"}`,children:[t.jsxs("header",{ref:Io,className:m("flex flex-wrap items-center justify-between gap-3 p-4 border-b shrink-0",h("border-white/10","border-black/10"),r==="HE"?"text-right":"text-left"),children:[t.jsx("div",{ref:$o,className:m("flex flex-col gap-1",So?"items-center text-center":r==="HE"&&"items-end",(X||So)&&"mx-auto"),children:t.jsx("div",{className:m("flex flex-wrap items-center gap-2",X&&"w-full justify-center"),children:t.jsxs("div",{className:m("relative flex w-full max-w-[300px] items-center overflow-hidden rounded-full shadow-md",h("bg-white/[0.03]","bg-slate-200/70")),onPointerLeave:()=>gs(null),children:[t.jsxs("div",{className:m("pointer-events-none absolute inset-y-0 left-0 rounded-full transition-transform duration-300 ease-out",h("bg-gradient-to-b from-white via-white to-[#ededed] shadow-[0_10px_28px_rgba(0,0,0,0.45)] border border-white/40","bg-white shadow-[0_8px_18px_rgba(15,23,42,0.12)] ring-1 ring-slate-200/70")),style:{width:df,transform:`translateX(${cf*100}%)`},"aria-hidden":!0,children:[t.jsx("span",{className:"absolute inset-0 rounded-full shadow-[inset_0_1px_0_rgba(255,255,255,0.8)]"}),t.jsx("span",{className:m("absolute inset-x-3 bottom-[6px] h-2 rounded-full blur-sm",h("bg-black/25","bg-slate-300/30"))})]}),t.jsxs("button",{type:"button",onClick:()=>Ta("positions"),onPointerEnter:()=>gs(0),onFocus:()=>gs(0),onBlur:e=>{var a;(a=e.currentTarget.parentElement)!=null&&a.contains(e.relatedTarget)||gs(null)},"aria-pressed":Rn==="positions",className:m("relative z-10 flex-1 whitespace-nowrap font-semibold transition-colors duration-200 ease-out focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 flex items-center justify-center gap-2",Ji(0,Wa),Sc,h("focus-visible:outline-white/70","focus-visible:outline-gray-900/40"),Cc?h("text-gray-900","text-gray-900"):h("text-white/80 hover:bg-white/20 hover:text-white","text-slate-600 hover:text-slate-900 hover:bg-white/60")),children:[n("Positions","Positions"),t.jsx("span",{className:m("text-xs px-1.5 py-0.5 rounded-full",Cc?h("bg-black/10 text-gray-900","bg-slate-900/10 text-gray-900"):h("bg-white/10 text-white/70","bg-slate-200/80 text-slate-600")),children:$f})]}),t.jsxs("button",{type:"button",onClick:()=>Ta("orders"),onPointerEnter:()=>gs(1),onFocus:()=>gs(1),onBlur:e=>{var a;(a=e.currentTarget.parentElement)!=null&&a.contains(e.relatedTarget)||gs(null)},"aria-pressed":Rn==="orders",className:m("relative z-10 flex-1 whitespace-nowrap font-semibold transition-colors duration-200 ease-out focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 flex items-center justify-center gap-2",Ji(1,Wa),Sc,h("focus-visible:outline-white/70","focus-visible:outline-gray-900/40"),Ec?h("text-gray-900","text-gray-900"):h("text-white/80 hover:bg-white/20 hover:text-white","text-slate-600 hover:text-slate-900 hover:bg-white/60")),children:[n("Orders","Orders"),t.jsx("span",{className:m("text-xs px-1.5 py-0.5 rounded-full",Ec?h("bg-black/10 text-gray-900","bg-slate-900/10 text-gray-900"):h("bg-white/10 text-white/70","bg-slate-200/80 text-slate-600")),children:Lf})]})]})})}),t.jsxs("div",{ref:Lo,className:m("relative flex min-w-0 flex-wrap items-center gap-2"),children:[(p==null?void 0:p.isAdmin)&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>{Gs(!0)},disabled:!(Ge!=null&&Ge.length),className:`w-10 h-10 grid place-items-center rounded-full ${h("bg-white/10 text-white hover:bg-white/15","bg-gray-100 text-gray-800 hover:bg-gray-200")} ${Ge!=null&&Ge.length?"":"opacity-50 cursor-not-allowed"}`,title:n("Edit All Orders","Edit All Orders"),"aria-label":n("Edit All Orders","Edit All Orders"),children:t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",className:"w-4 h-4",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),t.jsx("button",{type:"button",onClick:()=>{Jt(!0)},className:`w-10 h-10 grid place-items-center rounded-full ${h("bg-white/10 text-white hover:bg-white/15","bg-gray-100 text-gray-800 hover:bg-gray-200")}`,title:n("New Order","New Order"),"aria-label":n("New Order","New Order"),children:t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",className:"w-4 h-4",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),t.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]}),t.jsxs("div",{className:"relative",ref:dc,children:[t.jsxs("button",{type:"button",onClick:()=>ui(e=>!e),className:`relative w-10 h-10 grid place-items-center rounded-full ${h("bg-white/10 text-white hover:bg-white/15","bg-gray-100 text-gray-800 hover:bg-gray-200")}`,title:n("התראות","Notifications"),"aria-label":n("התראות","Notifications"),children:[t.jsx(Al,{className:"w-4 h-4"}),Vn>0&&t.jsx("span",{className:"absolute -top-1 -right-1 min-w-[18px] h-[18px] px-1 rounded-full bg-rose-500 text-white text-[10px] leading-[18px] font-semibold",children:Math.min(Vn,99)})]}),di&&t.jsxs("div",{className:m("absolute top-12 right-0 z-20 w-[320px] max-w-[calc(100vw-2rem)] rounded-lg border shadow-xl overflow-hidden",h("border-white/10 bg-[#14181d] text-white","border-black/10 bg-white text-gray-900")),children:[t.jsxs("div",{className:m("flex items-center justify-between px-4 py-3 border-b",h("border-white/10","border-black/10")),children:[t.jsx("div",{className:"text-sm font-semibold",children:n("התראות","Notifications")}),Vn>0&&t.jsx("button",{type:"button",onClick:()=>ci(e=>e.map(a=>({...a,readAt:a.readAt??Date.now()}))),className:m("text-xs",h("text-white/70 hover:text-white","text-gray-500 hover:text-gray-800")),children:n("סמן הכל כנקרא","Mark all read")})]}),t.jsx("div",{className:"max-h-[360px] overflow-y-auto",children:Oa.length===0?t.jsx("div",{className:m("px-4 py-6 text-sm",h("text-white/60","text-gray-500")),children:n("אין עדיין התראות חדשות.","No notifications yet.")}):Oa.map(e=>t.jsx("button",{type:"button",onClick:()=>Uc(e),className:m("w-full px-4 py-3 text-left border-b transition-colors",h("border-white/10 hover:bg-white/5","border-black/10 hover:bg-gray-50"),!e.readAt&&h("bg-white/[0.04]","bg-sky-50/60")),children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-sm font-medium truncate",children:e.title}),t.jsx("div",{className:m("mt-1 text-xs leading-5",h("text-white/65","text-gray-600")),children:e.body}),Array.isArray(e.reasons)&&e.reasons.length>0&&t.jsx("div",{className:m("mt-2 text-[10px] uppercase tracking-wide",h("text-white/35","text-gray-400")),children:e.reasons.join(" · ")})]}),!e.readAt&&t.jsx("span",{className:"mt-1 w-2 h-2 rounded-full bg-sky-500 flex-shrink-0","aria-hidden":"true"})]})},e.id))})]})]}),t.jsx("button",{type:"button",onClick:()=>{me==null||me(),Zt(!0)},className:`w-10 h-10 grid place-items-center rounded-full ${h("bg-white/10 text-white hover:bg-white/15","bg-gray-100 text-gray-800 hover:bg-gray-200")}
147`,title:n("View data","View data"),"aria-label":n("View data","View data"),children:t.jsx(cb,{className:"w-4 h-4"})}),(p==null?void 0:p.isAdmin)&&t.jsx("div",{className:"relative min-w-0",children:t.jsxs("button",{type:"button",onClick:()=>Ys(e=>e==="blotter"?null:"blotter"),ref:Zr,className:m("flex min-w-0 max-w-full items-center gap-2 px-3 py-2 rounded-lg border shadow-sm text-sm font-medium transition-colors",h("bg-white/5 border-white/10 text-white hover:bg-white/10","bg-white border-gray-200 text-gray-800 hover:bg-gray-50")),style:Ro?{width:`${Ro}px`}:void 0,title:n("Select account","Select account"),children:[t.jsx("span",{className:"truncate min-w-0 max-w-[120px]",children:ve}),t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:`w-4 h-4 flex-shrink-0 transition-transform ${Ln==="blotter"?"rotate-180":""}`,children:t.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]})})]})]}),Tc("blotter"),t.jsxs("div",{className:`p-4 text-sm ${h("text-white/50","text-gray-600")} space-y-6 overflow-y-auto`,children:[Rn==="positions"&&t.jsxs("div",{className:"space-y-3",children:[ar&&t.jsx("div",{className:`${h("border-white/10 bg-white/5 text-white/70","border-black/10 bg-gray-50 text-gray-600")} rounded-lg border shadow-sm px-4 py-3 text-sm`,children:n("Loading positions...","Loading positions...")}),kf.map(e=>t.jsxs(Gc,{group:e,type:"positions",isOpen:!!ys[e.key],onToggle:()=>Qc(e.key),children:[e.rows.length>0&&t.jsxs("div",{className:`hidden sm:grid grid-cols-6 ${h("text-white/60","text-gray-600")} text-xs px-3`,children:[t.jsx("div",{className:fe(),children:n("Time","Time")}),t.jsx("div",{className:fe(),children:n("Name","Name")}),t.jsx("div",{className:fe(),children:n("Status","Status")}),t.jsx("div",{className:fe(),children:n("Quantity","Quantity")}),t.jsx("div",{className:fe(),children:n("P&L","P&L")}),t.jsx("div",{className:fe(),children:n("Symbol","Symbol")})]}),e.rows.map(a=>t.jsxs("div",{className:m("grid gap-y-4 sm:grid-cols-6 sm:items-center rounded-lg border shadow-sm px-3 py-3",h("bg-white/5 border-white/10","bg-gray-100 border-black/5")),children:[t.jsxs("div",{className:m(lt,fe()),children:[t.jsx("span",{className:it,children:n("Time","Time")}),t.jsxs("div",{className:m("group relative mt-1 flex items-center gap-2 sm:mt-0"),children:[t.jsxs("span",{className:"relative flex h-2.5 w-2.5",children:[t.jsx("span",{className:"absolute inline-flex h-full w-full rounded-full bg-emerald-500 opacity-75 animate-ping"}),t.jsx("span",{className:"relative inline-flex h-2.5 w-2.5 rounded-full bg-emerald-400"})]}),t.jsx("span",{children:a.time}),Array.isArray(a.timeUpdates)&&a.timeUpdates.length>0&&t.jsx("div",{className:h("pointer-events-none absolute -top-10 left-1/2 -translate-x-1/2 whitespace-nowrap rounded-full border border-emerald-400/60 bg-emerald-500/90 px-3 py-1 text-[11px] font-medium text-white shadow-[0_10px_30px_rgba(16,185,129,0.35)] opacity-0 transition-opacity duration-150 group-hover:opacity-100","pointer-events-none absolute -top-10 left-1/2 -translate-x-1/2 whitespace-nowrap rounded-full border border-emerald-400/30 bg-emerald-500/85 px-3 py-1 text-[11px] font-medium text-white shadow-[0_10px_24px_rgba(16,185,129,0.25)] opacity-0 transition-opacity duration-150 group-hover:opacity-100"),children:a.timeUpdates.join(" • ")})]})]}),t.jsxs("div",{className:m(lt,fe()),children:[t.jsx("span",{className:it,children:n("Name","Name")}),t.jsx("div",{className:"mt-1 sm:mt-0",children:a.name})]}),t.jsxs("div",{className:m(lt,fe()),children:[t.jsx("span",{className:it,children:n("Status","Status")}),t.jsx("div",{className:m("mt-1 text-sm sm:mt-0",h("text-white/40","text-gray-500")),children:a.status})]}),t.jsxs("div",{className:m(lt,fe()),children:[t.jsx("span",{className:it,children:n("Quantity","Quantity")}),t.jsxs("div",{className:"group relative mt-1 flex items-center sm:mt-0",children:[t.jsx("span",{children:a.quantity}),t.jsx("div",{className:h("pointer-events-none absolute -top-10 left-1/2 -translate-x-1/2 whitespace-nowrap rounded-full border border-emerald-400/60 bg-emerald-500/90 px-3 py-1 text-[11px] font-medium text-white shadow-[0_10px_30px_rgba(16,185,129,0.35)] opacity-0 transition-opacity duration-150 group-hover:opacity-100","pointer-events-none absolute -top-10 left-1/2 -translate-x-1/2 whitespace-nowrap rounded-full border border-emerald-400/30 bg-emerald-500/85 px-3 py-1 text-[11px] font-medium text-white shadow-[0_10px_24px_rgba(16,185,129,0.25)] opacity-0 transition-opacity duration-150 group-hover:opacity-100"),children:t.jsxs("div",{className:"flex flex-col items-center gap-0.5",children:[t.jsx("span",{children:n("שווי כספי 200,000$","Cash Value $200,000")}),t.jsx("span",{className:"text-[10px] font-normal opacity-90",children:n("מאגין 15,700$","Margin $15,700")})]})})]})]}),t.jsxs("div",{className:m(lt,fe()),children:[t.jsx("span",{className:it,children:n("P&L","P&L")}),t.jsx("div",{className:"mt-1 font-medium sm:mt-0",children:a.pnl})]}),t.jsxs("div",{className:m(lt,fe()),children:[t.jsx("span",{className:it,children:n("Symbol","Symbol")}),t.jsx("div",{className:m("mt-1 flex items-center gap-2 sm:mt-0"),children:t.jsx("span",{children:a.symbol})})]})]},a.id))]},e.key)),t.jsxs("div",{className:m("rounded-xl border shadow-lg",h("bg-white/5 border-white/10","bg-gray-100 border-black/5")),children:[t.jsxs("div",{className:m("flex items-center justify-between gap-3 px-4 py-3"),children:[t.jsxs("div",{className:m("flex flex-col gap-1",r==="HE"&&"items-end text-right"),children:[t.jsxs("div",{className:m("flex items-center gap-2"),children:[t.jsxs("span",{className:"text-sm font-semibold",children:[n("Cash","Cash")," (",Be.length,")"]}),t.jsxs("span",{className:`text-[11px] px-2 py-0.5 rounded-full ${h("bg-emerald-500/20 text-emerald-300","bg-emerald-100 text-emerald-700")}`,children:[Be.length," ",n("Accounts","Accounts")]})]}),t.jsx("div",{className:m("flex flex-wrap gap-4 text-xs",h("text-white/70","text-gray-600")),children:t.jsx("span",{children:`${n("Updated","Updated")}: ${Yi}`})})]}),t.jsx("button",{type:"button",onClick:()=>Qc("Cash"),className:m("w-10 h-10 grid place-items-center rounded-full border transition-colors",h(ys.Cash?"bg-amber-200/10 border-amber-300/70 text-amber-100 hover:bg-amber-200/20":"bg-white/10 border-white/20 text-white hover:bg-white/15",ys.Cash?"bg-amber-100 border-amber-300 text-amber-700 hover:bg-amber-200":"bg-gray-200 border-gray-300 text-gray-800 hover:bg-gray-300")),"aria-expanded":ys.C
147ash,"aria-label":ys.Cash?n("Collapse group","Collapse group"):n("Expand group","Expand group"),children:ys.Cash?t.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M5 12h14"})}):t.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5 12h14"}),t.jsx("path",{d:"M12 5v14"})]})})]}),ys.Cash&&t.jsx("div",{className:m("border-t px-3 py-3 space-y-3",h("border-white/10 bg-white/5","border-black/10 bg-gray-50")),children:Be.length===0?t.jsx("div",{className:`rounded-lg border shadow-sm px-4 py-3 text-sm ${h("border-white/10 bg-white/5 text-white/70","border-black/10 bg-gray-50 text-gray-600")}`,children:n("No accounts available","No accounts available")}):Be.map(e=>t.jsxs("div",{className:m("grid gap-y-4 sm:grid-cols-4 sm:items-center rounded-lg border shadow-sm px-3 py-3",h("bg-white/5 border-white/10","bg-gray-100 border-black/5")),children:[t.jsxs("div",{className:m("flex flex-col",r==="HE"?"items-end text-right":""),children:[t.jsx("span",{className:m("text-xs sm:hidden",h("text-white/50","text-gray-500")),children:n("Account","Account")}),t.jsx("span",{className:"font-medium",children:e.en})]}),t.jsxs("div",{className:m("flex flex-col",r==="HE"?"items-end text-right":""),children:[t.jsx("span",{className:m("text-xs",h("text-white/50","text-gray-500")),children:n("Cash Balance","Cash Balance")}),t.jsx("span",{className:m("font-medium",e.cashBalance!=null?e.cashBalance>=0?"text-emerald-400":"text-red-400":""),children:e.cashBalance!=null?Ne(e.cashBalance,e.currency||"USD"):"-"})]}),t.jsxs("div",{className:m("flex flex-col",r==="HE"?"items-end text-right":""),children:[t.jsx("span",{className:m("text-xs",h("text-white/50","text-gray-500")),children:n("Buying Power","Buying Power")}),t.jsx("span",{className:"font-medium",children:e.buyingPower!=null?Ne(e.buyingPower,e.currency||"USD"):"-"})]}),t.jsxs("div",{className:m("flex flex-col",r==="HE"?"items-end text-right":""),children:[t.jsx("span",{className:m("text-xs",h("text-white/50","text-gray-500")),children:n("Equity","Equity")}),t.jsx("span",{className:"font-medium",children:e.equity!=null?Ne(e.equity,e.currency||"USD"):"-"})]})]},e.id))})]})]}),Rn==="orders"&&t.jsxs("div",{className:"space-y-3",children:[rr&&t.jsx("div",{className:`${h("border-white/10 bg-white/5 text-white/70","border-black/10 bg-gray-50 text-gray-600")} rounded-lg border shadow-sm px-4 py-3 text-sm`,children:n("Loading orders...","Loading orders...")}),Af.map(e=>t.jsx(Xc,{group:e,showActions:!!(p!=null&&p.isAdmin)},e.key)),Tf&&t.jsx("div",{className:`${h("border-white/10 bg-white/5 text-white/70","border-black/10 bg-gray-50 text-gray-600")} rounded-lg border shadow-sm px-4 py-3 text-sm`,children:n("Loading historical orders...","Loading historical orders...")}),t.jsx(Xc,{group:Sf})]})]})]})})]}),!X&&t.jsxs("section",{className:m(`${h("bg-white/[0.03] border-white/10","bg-white border-black/10")} border rounded-xl shadow-lg overflow-hidden flex flex-col`,"min-h-0"),style:{height:Qa,flexShrink:0},children:[t.jsxs("header",{className:m("flex flex-wrap items-center justify-between gap-3 border-b px-4 py-3 shrink-0",h("border-white/10 bg-white/[0.02]","border-black/10 bg-slate-50")),children:[t.jsxs("div",{className:"min-w-0 space-y-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("h3",{className:"text-sm font-semibold",children:n("Lower chart","Lower chart")}),t.jsx("span",{className:m("rounded-full border px-2.5 py-1 text-[11px] font-semibold",h("border-sky-400/30 bg-sky-400/10 text-sky-100","border-sky-200 bg-sky-50 text-sky-700")),children:(Re==null?void 0:Re.label)??"TradingView"})]}),t.jsxs("p",{className:m("truncate text-xs",h("text-white/55","text-slate-500")),children:[(Re==null?void 0:Re.name)??n("Market chart","Market chart"),Re!=null&&Re.market?` - ${Re.market}`:""]})]}),t.jsxs("span",{className:m("rounded-full px-3 py-1 text-[11px] font-semibold",h("bg-white/8 text-white/65","bg-slate-100 text-slate-600")),children:[_r.length,"/",ds.length," ",n("Assets","Assets")]})]}),t.jsxs("div",{className:"grid flex-1 min-h-0 grid-cols-[18rem_minmax(0,1fr)] xl:grid-cols-[20rem_minmax(0,1fr)]",children:[t.jsxs("aside",{className:m("flex min-h-0 flex-col border-e",h("border-white/10 bg-[#121417]","border-black/10 bg-slate-50/80")),children:[t.jsxs("div",{className:m("border-b p-3",h("border-white/10 bg-[#14171a]","border-slate-200 bg-white")),children:[t.jsx("label",{htmlFor:"tradingview-watchlist-search",className:"sr-only",children:n("Search assets","Search assets")}),t.jsxs("div",{className:"relative",children:[t.jsx(bu,{className:m("pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2",h("text-white/40","text-slate-400"))}),t.jsx("input",{id:"tradingview-watchlist-search",type:"search",value:pa,onChange:e=>io(e.target.value),placeholder:n("Search assets...","Search assets..."),className:m("h-10 w-full rounded-xl border pl-9 pr-9 text-sm outline-none transition",h("border-white/10 bg-white/[0.04] text-white placeholder:text-white/35 focus:border-sky-400/60","border-slate-200 bg-white text-slate-900 placeholder:text-slate-400 focus:border-sky-400"))}),pa&&t.jsx("button",{type:"button",onClick:()=>io(""),className:m("absolute right-2 top-1/2 grid h-6 w-6 -translate-y-1/2 place-items-center rounded-full transition",h("text-white/45 hover:bg-white/10 hover:text-white","text-slate-400 hover:bg-slate-100 hover:text-slate-700")),"aria-label":n("Clear search","Clear search"),children:t.jsx(ms,{className:"h-3.5 w-3.5"})})]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:t.jsxs("div",{className:"space-y-2",children:[_r.map(e=>{const a=e.symbol===Tt;return t.jsx("button",{type:"button",onClick:()=>Vm(e.symbol),"aria-pressed":a,className:m("group w-full rounded-xl border px-3 py-3 text-start transition focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2",a?h("border-sky-400/50 bg-sky-4
14700/12 text-white shadow-[0_10px_26px_rgba(14,165,233,0.12)] focus-visible:outline-sky-300","border-sky-300 bg-sky-50 text-slate-950 shadow-sm focus-visible:outline-sky-500"):h("border-white/8 bg-white/[0.025] text-white/80 hover:bg-white/[0.07] focus-visible:outline-white/60","border-slate-200 bg-white text-slate-700 hover:bg-slate-50 focus-visible:outline-slate-500")),children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"truncate text-sm font-semibold",children:e.label}),a&&t.jsx(ta,{className:"h-3.5 w-3.5 shrink-0 text-sky-300"})]}),t.jsx("div",{className:m("mt-1 truncate text-xs leading-5",a?h("text-sky-100/80","text-slate-600"):h("text-white/45","text-slate-500")),children:e.name}),t.jsx("div",{className:m("mt-1 truncate text-[11px]",h("text-white/35","text-slate-400")),children:e.symbol.replace(":"," - ")})]}),t.jsx("span",{className:m("rounded-full px-2 py-1 text-[10px] font-semibold shrink-0",a?h("bg-white/10 text-sky-100","bg-white text-sky-600"):h("bg-white/8 text-white/60","bg-slate-100 text-slate-500")),children:e.market})]})},e.symbol)}),_r.length===0&&t.jsx("div",{className:m("rounded-xl border px-3 py-5 text-center text-sm",h("border-white/10 bg-white/[0.025] text-white/50","border-slate-200 bg-white text-slate-500")),children:n("No assets found","No assets found")})]})})]}),t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[t.jsxs("div",{className:m("flex min-h-[3.5rem] items-center justify-between gap-3 border-b px-4 py-2",h("border-white/10 bg-black/20","border-slate-200 bg-white")),children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:m("text-[11px] font-semibold uppercase tracking-wide",h("text-white/40","text-slate-400")),children:n("Active symbol","Active symbol")}),t.jsxs("div",{className:"mt-0.5 flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"text-base font-semibold",children:(Re==null?void 0:Re.label)??Tt}),t.jsx("span",{className:m("truncate text-xs",h("text-white/45","text-slate-500")),children:(Re==null?void 0:Re.name)??Tt})]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx("span",{className:m("rounded-full px-2.5 py-1 text-[11px] font-semibold",h("bg-white/8 text-white/60","bg-slate-100 text-slate-600")),children:co}),t.jsx("a",{href:`https://www.tradingview.com/chart/?symbol=${encodeURIComponent(Tt)}`,target:"_blank",rel:"noopener noreferrer",className:m("rounded-full border px-3 py-1.5 text-xs font-semibold transition",h("border-white/10 text-sky-200 hover:bg-white/8","border-slate-200 text-sky-700 hover:bg-sky-50")),children:"TradingView"})]})]}),t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(x0,{allowSymbolChange:!1,symbol:Tt,interval:co,theme:Se?"dark":"light",locale:hf,height:"100%",backgroundColor:Se?"#14171a":"#ffffff"})})]})]})]}),Jc]})}),he==="forecast"&&t.jsx(x.Suspense,{fallback:t.jsx(Ft,{className:"min-h-[28rem] w-full rounded-2xl"}),children:t.jsx(m0,{tr:n,language:r,isDark:Se,isCompact:X,monthsOrder:O,chartHeight:mf,catalog:Wm,data:ho,isLoading:Km,error:Xm||Gm,onQueryChange:Ym,visible:!0},"forecast")}),!ls&&M&&Hh&&t.jsx(x.Suspense,{fallback:he==="backtest"&&($||ne===bt.BACKTEST)?t.jsx(Ft,{className:"min-h-[28rem] w-full rounded-2xl"}):null,children:t.jsx("div",{"data-owner-backtest":$?"true":void 0,children:t.jsx(h0,{tr:n,language:r,isDark:Se,isCompact:X,visible:he==="backtest"&&($||ne===bt.BACKTEST)})})})]}),$&&t.jsx(x.Suspense,{fallback:t.jsx(Ft,{className:"min-h-[36rem] w-full rounded-2xl"}),children:t.jsx("div",{className:Si?"hidden":void 0,"aria-hidden":Si||void 0,children:t.jsx(Wd,{tr:n,language:r,isDark:Se,isCompact:X,visible:!0,initialMaterialMovementId:"capital",initialCapitalDocumentId:"insurance",materialNavigationTarget:_,ownerNavigation:Of,onOwnerOperationTargetChange:ie})})}),!$&&M&&zh&&t.jsx(x.Suspense,{fallback:he==="backtest"&&ne===bt.NETWORK?t.jsx(Ft,{className:"min-h-[28rem] w-full rounded-2xl"}):null,children:t.jsx(Wd,{tr:n,language:r,isDark:Se,isCompact:X,visible:he==="backtest"&&ne===bt.NETWORK})})]})}),bs&&t.jsxs("div",{className:"fixed inset-0 z-50",children:[t.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:()=>{Jt(!1),Ks(null)}}),t.jsx("div",{className:"relative z-10 flex min-h-full items-center justify-center px-4 py-6 sm:px-6 sm:py-10",children:t.jsxs("div",{className:`w-full max-w-4xl ${h("bg-[#1C1F22] text-gray-200 border-white/10","bg-white text-gray-900 border-black/10")} rounded-2xl border shadow-2xl overflow-visible`,children:[t.jsxs("header",{className:`h-14 flex items-center justify-between px-5 border-b ${r==="HE"?"flex-row-reverse":""} ${h("border-white/10","border-black/10")}`,children:[t.jsxs("div",{className:`flex items-center gap-3 ${r==="HE"?"flex-row-reverse":""}`,children:[t.jsx("h3",{className:"text-lg font-semibold",children:ce?n("Edit Order","Edit Order"):n("New Order","New Order")}
147),(ce==null?void 0:ce.orderId)&&t.jsxs("span",{className:`text-xs px-2 py-1 rounded-full border ${h("border-white/10 bg-white/5 text-white/70","border-black/10 bg-gray-100 text-gray-700")}`,children:["#",ce.orderId]})]}),t.jsx("button",{onClick:()=>{Jt(!1),Ks(null)},className:`w-8 h-8 grid place-items-center rounded-md ${h("hover:bg-white/10","hover:bg-gray-100")}`,children:"X"})]}),t.jsxs("div",{className:"p-6",dir:r==="HE"?"rtl":"ltr",children:[wo&&t.jsx("div",{role:"alert",className:"mb-4 rounded-lg border border-amber-400/40 bg-amber-500/10 px-4 py-3 text-sm text-amber-700 dark:text-amber-200",children:wo}),t.jsxs("div",{className:`grid grid-cols-1 md:grid-cols-2 gap-6 ${r==="HE"?"text-right":""}`,children:[t.jsx("div",{children:t.jsx("div",{className:"relative",children:ce?t.jsxs("div",{className:`w-full inline-flex items-center justify-between border rounded-lg shadow-sm px-3 py-2 ${h("bg-white/5 border-white/10 text-white/80","bg-gray-50 border-gray-300 text-gray-800")}`,children:[t.jsx("span",{children:ve}),t.jsx("span",{className:`${h("text-white/40","text-gray-500")}`,children:n("Locked","Locked")})]}):t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:()=>Ys(e=>e==="order"?null:"order"),"aria-expanded":Ln==="order","aria-controls":"crm-account-menu-order",className:`w-full inline-flex items-center justify-between border rounded-lg shadow-sm px-3 py-2 transition-colors ${h("bg-white/5 border-white/10 text-white hover:bg-white/5","bg-white border-gray-300 text-gray-900 hover:bg-gray-50")}`,children:[t.jsx("span",{children:ve}),t.jsx("span",{className:`${h("text-white/60","text-gray-500")}`,children:"All"})]}),Tc("order",{widthClass:"w-full",maxHeightClass:"max-h-60",itemPadding:"px-3 py-2"})]})})}),t.jsx("div",{children:t.jsx("input",{value:qe,onChange:e=>Wr(e.target.value),disabled:!!ce,className:`w-full ${h("bg-white/5 border-white/10 text-white","bg-white border-black/10 text-gray-900")} border rounded-lg shadow-sm px-3 py-2 outline-none ${ce?"opacity-70 cursor-not-allowed":""}`})}),t.jsxs("div",{children:[t.jsx("input",{value:ut,onChange:e=>Ea(e.target.value),type:"text",className:`w-full ${h("bg-white/5 border-white/10 text-white","bg-white border-black/10 text-gray-900")} border rounded-lg shadow-sm px-3 py-2 outline-none`}),!ce&&t.jsx("div",{className:"mt-2 text-xs text-emerald-600 cursor-pointer underline",onClick:()=>Ea("All"),children:n("All","All")})]}),t.jsxs("div",{children:[t.jsx("input",{value:vt,onChange:e=>zs(e.target.value),type:"number",step:"0.01",className:`w-full ${h("bg-white/5 border-white/10 text-white","bg-white border-black/10 text-gray-900")} border rounded-lg shadow-sm px-3 py-2 outline-none`}),t.jsxs("div",{className:`mt-2 text-xs ${h("text-white/70","text-gray-600")}`,children:["Bid: ",t.jsx("span",{className:"text-sky-400 underline cursor-pointer",onClick:()=>Qs&&zs(String(Qs)),children:Qs??"Last"}),"   Ask: ",t.jsx("span",{className:"text-sky-400 underline cursor-pointer",onClick:()=>Ws&&zs(String(Ws)),children:Ws??"Last"})]})]})]}),ce?t.jsxs("div",{className:`mt-6 flex items-center justify-between gap-3 ${r==="HE"?"flex-row-reverse":""}`,children:[t.jsx("button",{onClick:()=>{Jt(!1),Ks(null)},disabled:tt,className:`px-6 py-2 rounded-lg font-semibold ${h("bg-white/10 hover:bg-white/15 text-white","bg-gray-100 hover:bg-gray-200 text-gray-900")} ${tt?"opacity-50 cursor-not-allowed":""}`,children:n("Discard","Discard")}),t.jsx("button",{onClick:()=>zi(),disabled:tt,className:`bg-sky-600 hover:bg-sky-700 text-white font-semibold px-6 py-2 rounded-lg ${tt?"opacity-50 cursor-not-allowed":""}`,children:tt?"...":n("Save changes","Save changes")})]}):t.jsxs("div",{className:"mt-6 flex items-center gap-3",children:[t.jsx("button",{onClick:()=>zi("Buy"),disabled:tt,className:`bg-emerald-600 hover:bg-emerald-700 text-white font-semibold px-6 py-2 rounded-lg ${tt?"opacity-50 cursor-not-allowed":""}`,children:tt?"...":n("Buy","Buy")}),t.jsx("button",{onClick:()=>zi("Sell"),disabled:tt,className:`bg-rose-500 hover:bg-rose-600 text-white font-semibold px-6 py-2 rounded-lg ${tt?"opacity-50 cursor-not-allowed":""}`,children:tt?"...":n("Sell","Sell")})]})]})]})})]}),In&&t.jsxs("div",{className:"fixed inset-0 z-50",children:[t.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:()=>{ze||(Gs(!1),ps(""))}}),t.jsx("div",{className:"relative z-10 flex min-h-full items-center justify-center px-4 py-6 sm:px-6 sm:py-10",children:t.jsxs("div",{className:`w-full max-w-md ${h("bg-[#1C1F22] text-gray-200 border-white/10","bg-white text-gray-900 border-black/10")} rounded-2xl border shadow-2xl overflow-visible`,children:[t.jsxs("header",{className:`h-14 flex items-center justify-between px-5 border-b ${r==="HE"?"flex-row-reverse":""} ${h("border-white/10","border-black/10")}`,children:[t.jsxs("div",{className:`flex items-center gap-3 ${r==="HE"?"flex-row-reverse":""}`,children:[t.jsx("h3",{className:"text-lg font-semibold",children:n("Edit All Orders","Edit All Orders")}),t.jsxs("span",{className:`text-xs px-2 py-1 rounded-full border ${h("border-white/10 bg-white/5 text-white/70","border-black/10 bg-gray-100 text-gray-700")}`,children:[(Ge==null?void 0:Ge.filter(e=>e.orderId&&e.accountId).length)||0," ",n("Orders","Orders")]})]}),t.jsx("button",{onClick:()=>{ze||(Gs(!1),ps(""))},disabled:ze,className:`w-8 h-8 grid place-items-center rounded-md ${h("hover:bg-white/10","hover:bg-gray-100")} ${ze?"opacity-50 cursor-not-allowed":""}`,children:"X"})]}),t.jsxs("div",{className:"p-6",dir:r==="HE"?"rtl":"ltr",children:[t.jsx("div",{className:`mb-4 text-sm ${h("text-white/70","text-gray-600")}`,children:n("Set a new price for all open orders. This will update the limit price of all orders simultaneously.","Set a new price for all open orders. This will update the limit price of all orders simultaneously.")}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:`block text-sm font-medium mb-1.5 ${h("text-white/80","text-gray-700")}`,children:n("New Price","New Price")}),t.jsx("input",{type:"number",step:"0.01",min:"0",value:Ht,onChange:e=>ps(e.target.value),disabled:ze,placeholder:n("Enter new price","Enter new price"),className:`w-full ${h("bg-white/5 border-white/10 text-white placeholder:text-white/40","bg-white border-black/10 text-gray-900 placeholder:text-gray-400")} border rounded-lg shadow-sm px-3 py-2 outline-none ${ze?"opacity-50 cursor-not-allowed":""}`}),t.jsxs("div",{className:`mt-2 text-xs ${h("text-white/70","text-gray-600")}`,children:["Bid: ",t.jsx("span",{className:"text-sky-400 underline cursor-pointer",onClick:()=>Qs&&ps(String(Qs)),children:Qs??"Last"}),"   Ask: ",t.jsx("span",{className:"text-sky-400 underline cursor-pointer",onClick:()=>Ws&&ps(String(Ws)),children:Ws??"Last"})]})]}),ze&&t.jsxs("div",{className:`flex items-center gap-3 text-sm ${h("text-white/60","text-gray-500")}`,children:[t.jsxs("svg",{className:"animate-spin h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),t.jsx("span",{children:n("Updating all orders simultaneously...","Updating all orders simultaneously...")})]})]}),t.jsxs("div",{className:`mt-6 flex items-center justify-between gap-3 ${r==="HE"?"flex-row-reverse":""}`,children:[t.jsx("button",{onClick:()=>{Gs(!1),ps("")},disabled:ze,className:`px-6 py-2 rounded-lg font-semibold ${h("bg-white/10 hover:bg-white/15 text-white","bg-gray-100 hover:bg-gray-200 text-gray-900")} ${ze?"opacity-50 cursor-not-allowed":""}`,children:n("Cancel","Cancel")}
147),t.jsx("button",{onClick:wf,disabled:ze||!Ht||Number(Ht)<=0,className:`bg-sky-600 hover:bg-sky-700 text-white font-semibold px-6 py-2 rounded-lg ${ze||!Ht||Number(Ht)<=0?"opacity-50 cursor-not-allowed":""}`,children:ze?n("Updating...","Updating..."):n("Update All","Update All")})]})]})]})})]}),Js&&t.jsxs("div",{className:"fixed inset-0 z-[60]",children:[t.jsx("div",{className:"absolute inset-0 bg-black/70",onClick:()=>Zs(!1)}),t.jsx("div",{className:"relative z-10 flex min-h-full items-center justify-center px-4 py-6 sm:px-6 sm:py-10",children:t.jsxs("div",{className:`w-full max-w-3xl ${h("bg-[#1C1F22] text-gray-200 border-white/10","bg-white text-gray-900 border-black/10")} rounded-2xl border shadow-2xl overflow-hidden`,children:[t.jsxs("header",{className:`h-14 flex items-center justify-between px-5 border-b ${h("border-white/10","border-black/10")}`,children:[t.jsx("h3",{className:"text-lg font-semibold",children:"Edit Account"}),t.jsx("button",{onClick:()=>Zs(!1),className:`w-8 h-8 grid place-items-center rounded-md ${h("hover:bg-white/10","hover:bg-gray-100")}`,children:"X"})]}),t.jsxs("div",{className:"p-6 max-h-[70vh] overflow-y-auto relative",children:[uh&&t.jsxs("div",{className:"absolute inset-0 z-10 rounded-lg p-6 space-y-4",style:{backgroundColor:Se?"rgba(20,23,26,0.85)":"rgba(255,255,255,0.85)"},children:[t.jsx(Ft,{className:m("h-16 w-16 rounded-full mx-auto",h("bg-white/10","bg-gray-200"))}),t.jsx(Ft,{className:m("h-8 w-full rounded-lg",h("bg-white/10","bg-gray-200"))}),t.jsx(Ft,{className:m("h-8 w-full rounded-lg",h("bg-white/10","bg-gray-200"))}),t.jsx(Ft,{className:m("h-8 w-3/4 rounded-lg",h("bg-white/10","bg-gray-200"))})]}),t.jsxs("div",{className:"space-y-5",children:[t.jsx("input",{ref:nn,type:"file",accept:"image/*",className:"hidden",onChange:Mh}),t.jsxs("div",{className:"flex flex-wrap items-center gap-5",children:[t.jsx("div",{className:`h-20 w-20 rounded-full overflow-hidden border ${h("border-white/10","border-black/10")}`,children:F.avatar?t.jsx("img",{src:F.avatar,alt:n("Profile Picture","Profile Picture"),className:"h-full w-full object-cover"}):t.jsx("div",{className:`h-full w-full flex items-center justify-center text-xl font-semibold ${h("bg-white/10 text-white","bg-gray-200 text-gray-700")}`,children:(((ad=F.name)==null?void 0:ad[0])||"A").toUpperCase()})}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("div",{className:`text-sm ${h("text-white/70","text-gray-700")}`,children:n("Profile Picture","Profile Picture")}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx("button",{type:"button",onClick:Ph,className:`px-4 py-2 rounded-lg text-sm font-medium ${h("bg-white/10 hover:bg-white/20 text-white","bg-gray-100 hover:bg-gray-200 text-gray-800")}`,children:n("Upload Photo","Upload Photo")}),F.avatar&&t.jsx("button",{type:"button",onClick:Oh,className:`px-4 py-2 rounded-lg text-sm ${h("bg-white/10 hover:bg-white/15 text-white","bg-gray-200 hover:bg-gray-300 text-gray-800")}`,children:n("Remove","Remove")})]}),t.jsx("span",{className:`text-xs ${h("text-white/40","text-gray-500")}`,children:n("Supports PNG or JPG up to 2MB","Supports PNG or JPG up to 2MB")}),Fo&&t.jsx("span",{className:"text-xs text-rose-400",children:Fo})]})]}),t.jsxs("div",{children:[t.jsx("div",{className:`text-sm ${h("text-white/70","text-gray-700")} mb-2`,children:"Name"}),t.jsx("input",{value:F.name,onChange:e=>We({...F,name:e.target.value}),className:`w-full ${h("bg-white/5 border-white/10 text-white","bg-white border-black/10 text-gray-900")} border rounded-lg shadow-sm px-3 py-2 outline-none`})]}),t.jsxs("div",{children:[t.jsx("div",{className:`text-sm ${h("text-white/70","text-gray-700")} mb-2`,children:"Broker"}),t.jsx("input",{value:F.broker,onChange:e=>We({...F,broker:e.target.value}),className:`w-full ${h("bg-white/5 border-white/10 text-white","bg-white border-black/10 text-gray-900")} border rounded-lg shadow-sm px-3 py-2 outline-none`})]}),t.jsxs("div",{children:[t.jsx("div",{className:`text-sm ${h("text-white/70","text-gray-700")} mb-2`,children:"Account ID (TradeStation)"}),t.jsx("input",{value:F.number,onChange:e=>We({...F,number:e.target.value}),className:`w-full ${h("bg-white/5 border-white/10 text-white","bg-white border-black/10 text-gray-900")} border rounded-lg shadow-sm px-3 py-2 outline-none`})]}),t.jsxs("div",{children:[t.jsx("div",{className:`text-sm ${h("text-white/70","text-gray-700")} mb-2`,children:"M1 Prefix"}),t.jsx("input",{value:F.m1Prefix,onChange:e=>We({...F,m1Prefix:e.target.value}),className:`w-full ${h("bg-white/5 border-white/10 text-white","bg-white border-black/10 text-gray-900")} border rounded-lg shadow-sm px-3 py-2 outline-none`})]}),t.jsxs("div",{children:[t.jsx("div",{className:`text-sm ${h("text-white/70","text-gray-700")} mb-2`,children:"API Key"}),t.jsx("input",{value:F.apiKey,onChange:e=>We({...F,apiKey:e.target.value}),type:"password",className:`w-full ${h("bg-white/5 border-white/10 text-white","bg-white border-black/10 text-gray-900")} border rounded-lg shadow-sm px-3 py-2 outline-none`})]}),t.jsxs("div",{children:[t.jsx("div",{className:`text-sm ${h("text-white/70","text-gray-700")} mb-2`,children:"API Secret"}),t.jsx("input",{value:F.apiSecret,onChange:e=>We({...F,apiSecret:e.target.value}),type:"password",className:`w-full ${h("bg-white/5 border-white/10 text-white","bg-white border-black/10 text-gray-900")} border rounded-lg shadow-sm px-3 py-2 outline-none`})]}),t.jsxs("div",{children:[t.jsx("div",{className:`text-sm ${h("text-white/70","text-gray-700")} mb-2`,children:"Refresh Token"}),t.jsx("input",{value:F.refreshToken,onChange:e=>We({...F,refreshToken:e.target.value}),type:"password",className:`w-full ${h("bg-white/5 border-white/10 text-white","bg-white border-black/10 text-gray-900")} border rounded-lg shadow-sm px-3 py-2 outline-none`})]}),t.jsxs("div",{children:[t.jsx("div",{className:`text-sm ${h("text-white/70","text-gray-700")} mb-2`,children:"Percent to Trade (0-1)"}),t.jsx("input",{value:F.percent,onChange:e=>We({...F,percent:e.target.value}),className:`w-full ${h("bg-white/5 border-white/10 text-white","bg-white border-black/10 text-gray-900")} border rounded-lg shadow-sm px-3 py-2 outline-none`})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:`text-sm ${h("text-white/70","text-gray-700")}`,children:"Enabled"}),t.jsx("input",{type:"checkbox",checked:F.enabled,onChange:e=>We({...F,enabled:e.target.checked})})]}),t.jsxs("div",{children:[t.jsx("div",{className:`text-sm ${h("text-white/70","text-gray-700")} mb-2`,children:"Assign to User (Email)"}),t.jsx("input",{type:"email",value:F.userEmail,onChange:e=>We({...F,userEmail:e.target.value}),className:`w-full ${h("bg-white/5 border-white/10 text-white","bg-white border-black/10 text-gray-900")} border rounded-lg shadow-sm px-3 py-2 outline-none`,placeholder:"Optional - will create user if not exists"}),t.jsx("p",{className:`mt-1 text-xs ${h("text-white/50","text-gray-500")}`,children:"If the user does not exist, a new user will be created with this email."}),Array.isArray(F.assignedEmails)&&F.assignedEmails.length>0&&t.jsxs("p",{className:`mt-2 text-xs ${h("text-white/60","text-gray-600")}
147`,children:["Assigned: ",F.assignedEmails.join(", ")]})]}),Oo&&t.jsx("div",{className:"text-rose-500 text-sm",children:Oo}),t.jsxs("div",{className:"flex items-center justify-between pt-2",children:[t.jsx("button",{onClick:()=>{en(null),Zs(!1)},className:`px-4 py-2 rounded-lg ${h("bg-white/10 hover:bg-white/15 text-white","bg-gray-100 hover:bg-gray-200 text-gray-800")}`,children:"Cancel"}),t.jsxs("div",{className:"space-x-2",children:[t.jsx("button",{type:"button",onClick:()=>{sn(null),tn(!0)},disabled:Mn||It,className:`px-4 py-2 rounded-lg bg-rose-600 hover:bg-rose-700 text-white ${Mn||It?"opacity-50 cursor-not-allowed":""}`,children:n("מחק","Delete")}),t.jsx("button",{onClick:()=>void Uh(),disabled:Mn,className:`px-4 py-2 rounded-lg bg-sky-600 hover:bg-sky-700 text-white ${Mn?"opacity-50 cursor-not-allowed":""}`,children:Mn?"Saving...":"Save Changes"})]})]})]})]})]})})]}),Js&&mh&&t.jsxs("div",{className:"fixed inset-0 z-[70]",children:[t.jsx("div",{className:"absolute inset-0 bg-black/70",onClick:()=>{It||tn(!1)}}),t.jsx("div",{className:"relative z-10 flex min-h-full items-center justify-center px-4 py-6 sm:px-6 sm:py-10",children:t.jsxs("div",{className:`w-full max-w-md ${h("bg-[#1C1F22] text-gray-200 border-white/10","bg-white text-gray-900 border-black/10")} rounded-2xl border shadow-2xl overflow-hidden`,children:[t.jsxs("header",{className:`h-14 flex items-center justify-between px-5 border-b ${r==="HE"?"flex-row-reverse":""} ${h("border-white/10","border-black/10")}`,children:[t.jsx("h3",{className:"text-lg font-semibold",children:n("אישור מחיקה","Confirm Delete")}),t.jsx("button",{type:"button",onClick:()=>tn(!1),disabled:It,className:`w-8 h-8 grid place-items-center rounded-md ${h("hover:bg-white/10","hover:bg-gray-100")} ${It?"opacity-50 cursor-not-allowed":""}`,children:"X"})]}),t.jsxs("div",{className:"p-6",dir:r==="HE"?"rtl":"ltr",children:[t.jsx("p",{className:`text-sm ${h("text-white/70","text-gray-600")}`,children:n("האם למחוק לצמיתות את החשבון הזה?","Are you sure you want to permanently delete this account?")}),jc&&t.jsxs("div",{className:`mt-3 text-sm ${h("text-white/60","text-gray-500")}`,children:[n("חשבון","Account"),": ",t.jsx("span",{className:"font-medium",children:jc})]}),_o&&t.jsx("div",{className:"mt-3 text-sm text-rose-500",children:_o}),t.jsxs("div",{className:`mt-6 flex items-center justify-end gap-3 ${r==="HE"?"flex-row-reverse":""}`,children:[t.jsx("button",{type:"button",onClick:()=>tn(!1),disabled:It,className:`px-4 py-2 rounded-lg ${h("bg-white/10 hover:bg-white/15 text-white","bg-gray-100 hover:bg-gray-200 text-gray-800")} ${It?"opacity-50 cursor-not-allowed":""}`,children:n("ביטול","Cancel")}),t.jsx("button",{type:"button",onClick:()=>void Vh(),disabled:It,className:`px-4 py-2 rounded-lg bg-rose-600 hover:bg-rose-700 text-white ${It?"opacity-50 cursor-not-allowed":""}`,children:It?n("מוחק...","Deleting..."):n("מחק חשבון","Delete Account")})]})]})]})})]}),ai&&t.jsxs("div",{className:"fixed inset-0 z-[60]",children:[t.jsx("div",{className:"absolute inset-0 bg-black/70",onClick:()=>On(!1)}),t.jsx("div",{className:"relative z-10 flex min-h-full items-center justify-center px-4 py-6 sm:px-6 sm:py-10",children:t.jsxs("div",{className:`w-full max-w-3xl ${h("bg-[#1C1F22] text-gray-200 border-white/10","bg-white text-gray-900 border-black/10")} rounded-2xl border shadow-2xl overflow-hidden`,children:[t.jsxs("header",{className:`h-14 flex items-center justify-between px-5 border-b ${h("border-white/10","border-black/10")}`,children:[t.jsx("h3",{className:"text-lg font-semibold",children:"Add Account"}),t.jsx("button",{onClick:()=>On(!1),className:`w-8 h-8 grid place-items-center rounded-md ${h("hover:bg-white/10","hover:bg-gray-100")}`,children:"X"})]}),t.jsx("form",{onSubmit:Fh,className:"p-6 max-h-[70vh] overflow-y-auto",children:t.jsxs("div",{className:"space-y-5",children:[t.jsx("input",{ref:rn,type:"file",accept:"image/*",className:"hidden",onChange:_h}),t.jsxs("div",{className:"flex flex-wrap items-center gap-5",children:[t.jsx("div",{className:`h-20 w-20 rounded-full overflow-hidden border ${h("border-white/10","border-black/10")}`,children:ee.avatar?t.jsx("img",{src:ee.avatar,alt:n("Profile Picture","Profile Picture"),className:"h-full w-full object-cover"}):t.jsx("div",{className:`h-full w-full flex items-center justify-center text-xl font-semibold ${h("bg-white/10 text-white","bg-gray-200 text-gray-700")}`,children:(((rd=ee.name)==null?void 0:rd[0])||"A").toUpperCase()})}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("div",{className:`text-sm ${h("text-white/70","text-gray-700")}`,children:n("Profile Picture","Profile Picture")}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx("button",{type:"button",onClick:Ih,className:`px-4 py-2 rounded-lg text-sm font-medium ${h("bg-white/10 hover:bg-white/20 text-white","bg-gray-100 hover:bg-gray-200 text-gray-800")}`,children:n("Upload Photo","Upload Photo")}),ee.avatar&&t.jsx("button",{type:"button",onClick:Dh,className:`px-4 py-2 rounded-lg text-sm ${h("bg-white/10 hover:bg-white/15 text-white","bg-gray-200 hover:bg-gray-300 text-gray-800")}`,children:n("Remove","Remove")})]}),t.jsx("span",{className:`text-xs ${h("text-white/40","text-gray-500")}`,children:n("Supports PNG or JPG up to 2MB","Supports PNG or JPG up to 2MB")}),Bo&&t.jsx("span",{className:"text-xs text-rose-400",children:Bo})]})]}),t.jsxs("div",{children:[t.jsx("div",{className:`text-sm ${h("text-white/70","text-gray-700")} mb-2`,children:"Display Name"}),t.jsx("input",{value:ee.name,onChange:e=>nt({...ee,name:e.target.value}),className:`w-full ${h("bg-white/5 border-white/10 text-white","bg-white border-black/10 text-gray-900")} border rounded-lg shadow-sm px-3 py-2 outline-none`,required:!0})]}),t.jsxs("div",{children:[t.jsx("div",{className:`text-sm ${h("text-white/70","text-gray-700")} mb-2`,children:"Broker"}),t.jsx("input",{value:ee.broker,onChange:e=>nt({...ee,broker:e.target.value}),className:`w-full ${h("bg-white/5 border-white/10 text-white","bg-white border-black/10 text-gray-900")} border rounded-lg shadow-sm px-3 py-2 outline-none`})]}),t.jsxs("div",{children:[t.jsx("div",{className:`text-sm ${h("text-white/70","text-gray-700")} mb-2`,children:"Account ID (TradeStation)"}),t.jsx("input",{value:ee.accountId,onChange:e=>nt({...ee,accountId:e.target.value}),className:`w-full ${h("bg-white/5 border-white/10 text-white","bg-white border-black/10 text-gray-900")} border rounded-lg shadow-sm px-3 py-2 outline-none`,required:!0})]}),t.jsxs("div",{children:[t.jsx("div",{className:`text-sm ${h("text-white/70","text-gray-700")} mb-2`,children:"M1 Prefix"}),t.jsx("input",{value:ee.m1Prefix,onChange:e=>nt({...ee,m1Prefix:e.target.value}),className:`w-full ${h("bg-white/5 border-white/10 text-white","bg-white border-black/10 text-gray-900")} border rounded-lg shadow-sm px-3 py-2 outline-none`})]}),t.jsxs("div",{children:[t.jsx("div",{className:`text-sm ${h("text-white/70","text-gray-700")} mb-2`,children:"API Key"}),t.jsx("input",{value:ee.apiKey,onChange:e=>nt({...ee,apiKey:e.target.value}),type:"password",className:`w-full ${h("bg-white/5 border-white/10 text-white","bg-white border-black/10 text-gray-900")} border rounded-lg shadow-sm px-3 py-2 outline-none`})]}),t.jsxs("div",{children:[t.jsx("div",{className:`text-sm ${h("text-white/70","text-gray-700")} mb-2`,children:"API Secret"}),t.jsx("input",{value:ee.apiSecret,onChange:e=>nt({...ee,apiSecret:e.target.value}),type:"password",className:`w-full ${h("bg-white/5 border-white/10 text-white","bg-white border-black/10 text-gray-900")} border rounded-lg shadow-sm px-3 py-2 outline-none`})]}),t.jsxs("div",{children:[t.jsx("div",{className:`text-sm ${h("text-white/70","text-gray-700")} mb-2`,children:"Refresh Token"}),t.jsx("input",{value:ee.refreshToken,onChange:e=>nt({...ee,refreshToken:e.target.value}),type:"password",className:`w-full ${h("bg-white/5 border-white/10 text-white","bg-white border-black/10 text-gray-900")} border rounded-lg shadow-sm px-3 py-2 outline-none`})]}),t.jsxs("div",{children:[t.jsx("div",{className:`text-sm ${h("text-white/70","text-gray-700")} mb-2`,children:"Percent to Trade (0-1)"}),t.jsx("input",{value:ee.percent,onChange:e=>nt({...ee,percent:e.target.value}),className:`w-full ${h("bg-white/5 border-white/10 text-white","bg-white border-black/10 text-gray-900")} border rounded-lg shadow-sm px-3 py-2 outline-none`})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:`text-sm ${h("text-white/70","text-gray-700")}`,children:"Enabled"}),t.jsx("input",{type:"checkbox",checked:ee.enabled,onChange:e=>nt({...ee,enabled:e.target.checked})})]}),t.jsxs("div",{children:[t.jsx("div",{className:`text-sm ${h("text-white/70","text-gray-700")} mb-2`,children:"Assign to User (Email)"}),t.jsx("input",{type:"email",value:ee.userEmail,onChange:e=>nt({...ee,userEmail:e.target.value}),className:`w-full ${h("bg-white/5 border-white/10 text-white","bg-white border-black/10 text-gray-900")} border rounded-lg shadow-sm px-3 py-2 outline-none`,placeholder:"Optional - will create user if not exists"}),t.jsx("p",{className:`mt-1 text-xs ${h("text-white/50","text-gray-500")}`,children:"If the user does not exist, a new user will be created with this email."})]}),Vo&&t.jsx("div",{className:"text-rose-500 text-sm",children:Vo}),t.jsxs("div",{className:"flex items-center justify-end pt-2 gap-3",children:[t.jsx("button",{type:"button",onClick:()=>On(!1),className:`px-4 py-2 rounded-lg ${h("bg-white/10 hover:bg-white/15 text-white","bg-gray-100 hover:bg-gray-200 text-gray-800")}`,children:"Cancel"}),t.jsx("button",{type:"submit",disabled:ri,className:`px-4 py-2 rounded-lg bg-sky-600 hover:bg-sky-700 text-white ${ri?"opacity-50 cursor-not-allowed":""}`,children:ri?"Adding...":"Add Account"})]})]})})]})})]}),t.jsx(rm,{mode:Yt,onModeChange:Gh,isCompact:X,isDark:Se,language:r,draft:Ca,onDraftChange:go,onSend:Ni,onDraftKeyDown:Lh,messages:eh,formatTimestamp:$h,canSend:Rh,unreadCount:Zm,tr:n}),Un.length>0&&t.jsx("div",{className:m("pointer-events-none fixed top-4 z-[60] flex w-[min(360px,calc(100vw-1rem))] flex-col gap-2",r==="HE"?"left-4":"right-4"),children:Un.map(e=>t.jsx("div",{className:m("pointer-events-auto rounded-lg border shadow-xl overflow-hidden",h("border-white/10 bg-[#14181d] text-white","border-black/10 bg-white text-gray-900")),children:t.jsxs("div",{className:"flex items-start gap-2 p-3",children:[t.jsxs("button",{type:"button",onClick:()=>Uc(e),className:m("min-w-0 flex-1 text-left",r==="HE"&&"text-right"),children:[t.jsx("div",{className:"text-sm font-semibold truncate",children:e.title}),t.jsx("div",{className:m("mt-1 text-xs leading-5",h("text-white/65","text-gray-600")),children:e.body})]}),t.jsx("button",{type:"button",onClick:()=>Kn(e.id),className:m("mt-0.5 rounded p-1 transition-colors",h("text-white/45 hover:text-white hover:bg-white/10","text-gray-400 hover:text-gray-700 hover:bg-gray-100")),"aria-label":n("סגור התראה","Dismiss notification"),children:t.jsx(ms,{className:"w-4 h-4"})})]})},e.id))}),V&&t.jsxs(sm,{isCompact:X,isDark:Se,language:r,title:i("Settings"),searchValue:ch,searchMatches:dh,items:fn,activeTab:st,onSearchChange:Rf,onMatchSelect:Mf,onTabSelect:e=>{ts(e.tab),ss([]),qt(e.targetId)},onClose:()=>H(!1),tr:n,contentStyle:Wh,error:xh,children:[st==="General"&&t.jsxs("div",{id:"settings-general",className:"space-y-6",children:[t.jsxs("div",{className:m("flex items-center gap-3 border-b pb-5",h("border-white/10","border-slate-200")),children:[t.jsx("div",{className:m("flex h-12 w-12 shrink-0 items-center justify-center overflow-hidden rounded-full border",h("border-white/10 bg-white/[0.04]","border-slate-200 bg-slate-50")),children:U?t.jsx("img",{src:U,alt:"",className:"h-full w-full object-cover"}):t.jsx(ml,{className:m("h-6 w-6",Lt),"aria-hidden":"true"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("h3",{className:"truncate text-base font-medium",dir:"auto",children:W}),t.jsx("span",{className:m("rounded px-2 py-0.5 text-xs font-medium",h("bg-white/[0.06] text-white/60","bg-slate-100 text-slate-600")),children:p!=null&&p.isAdmin?n("מנהל","Admin"):n("משתמש","User")})]}),t.jsx("p",{className:m("mt-1 w-fit max-w-full truncate text-sm",Lt),dir:"ltr",children:(p==null?void 0:p.email)||""})]})]}),t.jsxs("div",{children:[t.jsx("h3",{className:"mb-2 text-sm font-medium",children:n("מרכז ההגדרות","Settings center")}),t.jsx("div",{className:"grid gap-x-6 sm:grid-cols-2",children:fn.filter(e=>e.tab!=="General").map(e=>{const a=g0[e.tab]??ul;return t.jsxs("button",{type:"button",onClick:()=>{ts(e.tab),qt(e.targetId)},className:m("group flex min-h-[4.5rem] items-center gap-3 px-1 py-3 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400/60",ft.overviewRow),children:[t.jsx("span",{className:m("grid h-6 w-6 shrink-0 place-items-center",ft.iconWell),"aria-hidden":"true",children:t.jsx(a,{className:"h-[1.05rem] w-[1.05rem]"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block text-sm font-medium",children:e.label}),t.jsx("span",{className:m("mt-0.5 block text-xs leading-5",Lt),children:e.description})]}),t.jsx(pr,{className:m("h-4 w-4 shrink-0 opacity-35 transition duration-200 group-hover:opacity-75 motion-reduce:transition-none",r==="HE"&&"rotate-180"),"aria-hidden":"true"})]},`overview-${e.tab}`)})})]}),t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-sm font-medium",children:n("גישה ואבטחה","Access & security")}),t.jsx("p",{className:m("mt-1 text-sm",Lt),children:n("יציאה מהחשבון במכשיר הזה.","Sign out of your account on this device.")})]}),t.jsxs("button",{type:"button",onClick:()=>{I(),H(!1),w("/Login",{replace:!0})},className:m("inline-flex min-h-11 shrink-0 items-center justify-center gap-2 rounded-lg px-4 text-sm font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-rose-300/45",ft.dangerAction),children:[t.jsx(fu,{className:"h-4 w-4","aria-hidden":"true"}),i("Logout")]})]})]}),st==="Accounts"&&t.jsxs("div",{id:"settings-accounts",className:"space-y-5",children:[t.jsxs("div",{className:m("flex flex-col gap-3 p-4 sm:flex-row sm:items-center sm:justify-between sm:p-5",Te),
147children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-base font-semibold",children:i("Accounts")}),t.jsxs("div",{className:m("mt-1 text-xs",Lt),children:[Qn.filter(e=>e!=="All Accounts").length," ",i("Accounts")]})]}),(p==null?void 0:p.isAdmin)&&t.jsxs("div",{className:"flex w-full flex-wrap items-center gap-2 sm:w-auto sm:justify-end",children:[t.jsxs("button",{type:"button",onClick:()=>On(!0),className:Ai,children:[t.jsx(Zx,{className:"h-4 w-4"}),t.jsx("span",{children:"Add Account"})]}),t.jsxs("button",{type:"button",onClick:Bh,disabled:$a,className:m(Rt,$a&&"cursor-not-allowed opacity-60"),title:"Reload account streaming to pick up newly added accounts",children:[t.jsx(Bt,{className:`h-4 w-4 ${$a?"animate-spin":""}`}),t.jsx("span",{children:$a?"Reloading...":"Reload Streaming"})]})]})]}),ii&&t.jsx("div",{className:`text-sm px-3 py-2 rounded-lg ${ii.type==="success"?"bg-emerald-500/20 text-emerald-400":"bg-rose-500/20 text-rose-400"}`,children:ii.text}),t.jsxs("div",{className:m("relative overflow-hidden",Te),children:[t.jsx("div",{className:"space-y-3 p-3 sm:hidden",children:Qn.filter(e=>e!=="All Accounts").map(e=>{const a=e.match(/^(.*) \((.*)\)$/),l=a?a[1]:e,o=a?a[2]:"--",u=o&&o!=="--"?o:l,c=typeof u=="string"?u.trim():"",b=c?Do[c]:void 0,v=typeof l=="string"?l.trim():"",A=v?v.charAt(0).toUpperCase():"A",C=Ot.get(e)||Ot.get(o)||Ot.get(l),E=(C==null?void 0:C.isActive)!==!1,L=Ic(E),B=E?"bg-emerald-400":h("bg-white/25","bg-gray-300/70");return t.jsxs("div",{className:m("p-3",ns),children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[t.jsx("div",{className:`h-10 w-10 shrink-0 overflow-hidden rounded-full border ${h("border-white/10","border-black/10")}`,children:b?t.jsx("img",{src:b,alt:`${l} avatar`,className:"h-full w-full object-cover"}):t.jsx("div",{className:`flex h-full w-full items-center justify-center text-sm font-semibold ${h("bg-white/10 text-white","bg-gray-200 text-gray-700")}`,children:A})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"truncate text-sm font-semibold",children:l}),t.jsx("div",{className:m("mt-0.5 text-xs",Lt),children:o})]})]}),t.jsxs("div",{className:`flex shrink-0 items-center gap-2 ${r==="HE"?"flex-row-reverse text-right":""}`,children:[t.jsx("span",{className:`inline-flex h-2.5 w-2.5 rounded-full ${B}`}),t.jsx("span",{className:`text-xs ${h("text-white/60","text-gray-500")}`,children:L})]})]}),t.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-xs",children:[t.jsxs("div",{className:m("rounded-lg px-3 py-2",h("bg-white/5","bg-slate-50")),children:[t.jsx("div",{className:Lt,children:"Broker"}),t.jsx("div",{className:"mt-1 font-semibold",children:"TRADESTATION"})]}),t.jsxs("div",{className:m("rounded-lg px-3 py-2",h("bg-white/5","bg-slate-50")),children:[t.jsx("div",{className:Lt,children:"% to Trade"}),t.jsx("div",{className:"mt-1 font-semibold",children:(C==null?void 0:C.percentToTrade)!=null?`${Math.round(C.percentToTrade*100)}%`:"100%"})]})]}),(p==null?void 0:p.isAdmin)&&t.jsx("button",{type:"button",onClick:()=>pc(o,l,E,b),className:m("mt-3 w-full justify-center",Rt),children:"Edit"})]},`mobile-${e}`)})}),t.jsx("div",{className:"hidden max-h-[min(52vh,34rem)] overflow-auto sm:block",children:t.jsxs("div",{className:"min-w-[720px]",children:[t.jsxs("div",{className:m("sticky top-0 z-10 grid grid-cols-6 gap-4 border-b px-4 py-3 text-xs font-semibold uppercase tracking-wide",h("border-white/10 bg-[#1f2327] text-white/55","border-slate-200 bg-slate-50 text-slate-500")),children:[t.jsx("div",{children:"Name"}),t.jsx("div",{children:"Account #"}),t.jsx("div",{children:"Broker"}),t.jsx("div",{children:"% to Trade"}),t.jsx("div",{children:n("פעילות אחרונה","Last Active")}),t.jsx("div",{className:"text-right pr-2",children:"Actions"})]}),t.jsx("div",{className:`divide-y ${h("divide-white/10","divide-gray-200")}`,children:Qn.filter(e=>e!=="All Accounts").map(e=>{const a=e.match(/^(.*) \((.*)\)$/),l=a?a[1]:e,o=a?a[2]:"--",u=o&&o!=="--"?o:l,c=typeof u=="string"?u.trim():"",b=c?Do[c]:void 0,v=typeof l=="string"?l.trim():"",A=v?v.charAt(0).toUpperCase():"A",C=Ot.get(e)||Ot.get(o)||Ot.get(l),E=(C==null?void 0:C.isActive)!==!1,L=Ic(E),B=E?"bg-emerald-400":h("bg-white/25","bg-gray-300/70");return t.jsxs("div",{className:m("grid grid-cols-6 gap-4 px-4 py-3 text-sm items-center transition",h("hover:bg-white/[0.035]","hover:bg-slate-50")),children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:`h-9 w-9 rounded-full overflow-hidden border ${h("border-white/10","border-black/10")}`,children:b?t.jsx("img",{src:b,alt:`${l} avatar`,className:"h-full w-full object-cover"}):t.jsx("div",{className:`h-full w-full flex items-center justify-center text-sm font-semibold ${h("bg-white/10 text-white","bg-gray-200 text-gray-700")}`,children:A})}),t.jsx("span",{children:l})]}),t.jsx("div",{children:o}),t.jsx("div",{children:"TRADESTATION"}),t.jsx("div",{children:(C==null?void 0:C.percentToTrade)!=null?`${Math.round(C.percentToTrade*100)}%`:"100%"}),t.jsxs("div",{className:`flex items-center gap-2 ${r==="HE"?"flex-row-reverse text-right":""}`,children:[t.jsx("span",{className:`inline-flex h-2.5 w-2.5 rounded-full ${B}`}),t.jsx("span",{className:`text-xs ${h("text-white/60","text-gray-500")}`,children:L})]}),t.jsx("div",{className:"text-right space-x-2",children:(p==null?void 0:p.isAdmin)&&t.jsx("button",{onClick:()=>pc(o,l,E,b),className:`min-h-11 px-3 py-1 rounded-xl text-xs ${h("bg-white/10 hover:bg-white/15 text-white","bg-gray-100 hover:bg-gray-200 text-gray-800")}`,children:"Edit"})})]},e)})})]})})]})]}),st==="Graph Settings"&&t.jsxs("div",{id:"settings-graph",className:"space-y-5",children:[t.jsxs("div",{className:`grid grid-cols-1 gap-4 lg:grid-cols-[minmax(0,1fr)_20rem] ${h("text-white","text-gray-800")}
147`,children:[t.jsxs("div",{className:m("space-y-4 p-5",Te),children:[t.jsx("h3",{className:"text-base font-semibold",children:n("גרף עליון","Top Chart")}),t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:`text-sm ${h("text-white/60","text-gray-500")}`,children:n("הסימבול שנבחר ב-CRM משותף לגרף העליון ולגרף התחתון.","The symbol selected in CRM is shared by the top and bottom charts.")}),t.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[t.jsx("span",{className:`font-medium ${h("text-white","text-gray-700")}`,children:n("Displayed asset","Displayed asset")}),t.jsx("select",{className:m("px-3 py-2 text-sm",Oe),defaultValue:(id=Be[0])==null?void 0:id.id,children:Be.map(e=>t.jsx("option",{value:e.id,children:e.en},e.id))})]}),t.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[t.jsx("span",{className:`font-medium ${h("text-white","text-gray-700")}`,children:n("Chart type","Chart type")}),t.jsx("select",{className:m("px-3 py-2 text-sm",Oe),children:[{value:"candles",label:n("Japanese candles","Japanese candles")},{value:"line",label:n("Line","Line")},{value:"area",label:n("Area","Area")},{value:"bars",label:n("Bars","Bars")}].map(e=>t.jsx("option",{value:e.value,children:e.label},e.value))})]}),t.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[t.jsx("span",{className:`font-medium ${h("text-white","text-gray-700")}`,children:n("Time frame","Time frame")}),t.jsx("select",{className:m("px-3 py-2 text-sm",Oe),value:kr??((ld=D[0])==null?void 0:ld.id)??"",onChange:e=>R(a=>({...a,resolutionId:e.target.value})),children:D.map(e=>t.jsx("option",{value:e.id,title:e.description||e.label,children:e.label},e.id))}),(ga==null?void 0:ga.description)&&t.jsx("span",{className:`text-xs ${h("text-white/50","text-gray-500")}`,children:ga.description})]}),t.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[t.jsx("span",{className:`font-medium ${h("text-white","text-gray-700")}`,children:n("Bar span","Bar span")}),t.jsx("select",{className:m("px-3 py-2 text-sm",Oe),value:Ar??((od=J[0])==null?void 0:od.id)??"",onChange:e=>R(a=>({...a,spanId:e.target.value})),children:J.map(e=>t.jsx("option",{value:e.id,title:e.description||e.label,children:e.label},e.id))}),(ya==null?void 0:ya.description)&&t.jsx("span",{className:`text-xs ${h("text-white/50","text-gray-500")}`,children:ya.description})]}),t.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[t.jsx("span",{className:`font-medium ${h("text-white","text-gray-700")}`,children:n("Change display","Change display")}),t.jsxs("select",{className:m("px-3 py-2 text-sm",Oe),children:[t.jsx("option",{value:"price",children:n("Price","Price")}),t.jsx("option",{value:"percent",children:n("Percent","Percent")})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:`text-sm font-medium ${h("text-white","text-gray-700")}`,children:n("תוויות ציר Y","Y-axis labels")}),t.jsxs("label",{className:m("flex items-center justify-between px-3 py-2 text-sm",rt),children:[t.jsx("span",{children:n("מחיר אחרון","Last price")}),t.jsx("input",{type:"checkbox",checked:Pm,onChange:e=>R(a=>({...a,showLastPriceLabel:e.target.checked})),className:"accent-emerald-500"})]}),t.jsxs("label",{className:m("flex items-center justify-between px-3 py-2 text-sm",rt),children:[t.jsx("span",{children:n("ביד ואסק","Bid & Ask")}),t.jsx("input",{type:"checkbox",checked:Im,onChange:e=>R(a=>({...a,showBidAskLabels:e.target.checked})),className:"accent-emerald-500"})]}),t.jsxs("label",{className:m("flex items-center justify-between px-3 py-2 text-sm",rt),children:[t.jsx("span",{children:n("תוויות אינדיקטורים","Indicator labels")}),t.jsx("input",{type:"checkbox",checked:$m,onChange:e=>R(a=>({...a,showIndicatorLabels:e.target.checked})),className:"accent-emerald-500"})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:`text-sm font-medium ${h("text-white","text-gray-700")}`,children:n("Indicators","Indicators")}),(p==null?void 0:p.isAdmin)&&t.jsxs("label",{className:m("flex items-center justify-between px-3 py-2 text-sm",rt),children:[t.jsx("span",{children:n("Alfa indicator","Alfa indicator")}
147),t.jsx("input",{type:"checkbox",checked:Cm,onChange:e=>R(a=>({...a,indicatorEnabled:e.target.checked})),className:"accent-emerald-500"})]}),t.jsxs("label",{className:m("flex items-center justify-between px-3 py-2 text-sm",rt),children:[t.jsx("span",{children:n("Bollinger Upper","Bollinger Upper")}),t.jsx("input",{type:"checkbox",checked:Em,onChange:e=>R(a=>({...a,bollingerUpperEnabled:e.target.checked})),className:"accent-emerald-500"})]}),t.jsxs("label",{className:m("flex items-center justify-between px-3 py-2 text-sm",rt),children:[t.jsx("span",{children:n("Bollinger Lower","Bollinger Lower")}),t.jsx("input",{type:"checkbox",checked:Tm,onChange:e=>R(a=>({...a,bollingerLowerEnabled:e.target.checked})),className:"accent-emerald-500"})]})]})]}),t.jsxs("div",{className:m("self-start p-5",Te),children:[t.jsx("h3",{className:"text-base font-semibold mb-3",children:n("Color palette","Color palette")}),t.jsx("div",{className:"grid grid-cols-4 gap-3",children:["#38bdf8","#22d3ee","#34d399","#f97316","#facc15","#ef4444","#f472b6","#a855f7","#6366f1","#14b8a6","#fbbf24","#0ea5e9","#fb7185","#1d4ed8","#8b5cf6","#10b981"].map(e=>t.jsx("button",{type:"button",className:m("h-11 w-11 rounded-full border motion-safe:hover:scale-105",ft.motion,h("border-white/20 hover:border-white","border-gray-200 hover:border-gray-400")),style:{backgroundColor:e},"aria-label":n("Graph color","Graph color"),title:e},e))})]})]}),t.jsx(R0,{title:n("גרף תחתון","Bottom Chart"),description:n("בחירת הנכס מתבצעת מתוך רשימת המעקב של TradingView ליד הגרף. מסגרת הזמן נשמרת גם כאן.","Asset selection happens directly from the TradingView watchlist beside the chart. The saved time frame still applies here."),tr:n,isDark:Se,draftSettings:ke,resolutions:D,spans:J,draftResolution:qm,draftSpan:null,onResolutionChange:e=>Fe(a=>({...a,resolutionId:e})),onSpanChange:e=>Fe(a=>({...a,spanId:e})),onToggle:(e,a)=>Fe(l=>({...l,[e]:a})),showIndicatorToggle:!!(p!=null&&p.isAdmin),showSpanControl:!1,showAxisLabels:!1,showIndicatorControls:!1}),t.jsxs("div",{className:m("p-5",Te),children:[t.jsx("div",{className:`text-sm font-medium mb-3 ${h("text-white","text-gray-700")}`,children:n("ביצוע","Execution")}),t.jsxs("label",{className:m("flex items-center justify-between px-3 py-2 text-sm",rt),children:[t.jsx("span",{children:n("פקודת אייסברג","Iceberg order")}),t.jsx("input",{type:"checkbox",checked:En,onChange:e=>ia(e.target.checked),className:"accent-emerald-500"})]})]}),t.jsxs("div",{className:m("sticky bottom-0 z-20 -mx-4 -mb-4 mt-6 flex flex-col items-end gap-2 px-4 py-3 sm:-mx-5 sm:-mb-5 sm:px-5",yc),children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-3",children:[t.jsx("button",{type:"button",onClick:zm,className:Rt,children:n("Reset","Reset")}),t.jsx("button",{type:"button",onClick:Qm,disabled:mi,className:m(Ai,mi&&"cursor-not-allowed opacity-60"),children:mi?n("Saving...","Saving..."):n("Set as default","Set as default")}),t.jsx("button",{type:"button",onClick:()=>{Fr(),H(!1)},className:Ua,children:n("Save Graph Settings","Save Graph Settings")}),bh&&t.jsx("span",{className:"text-xs text-emerald-500",children:n("Saved","Saved")})]}),nc&&t.jsx("div",{className:"text-xs text-rose-500",children:nc})]})]}),st==="Alerts"&&t.jsxs("div",{id:"settings-alerts",className:"space-y-5",children:[t.jsxs("div",{className:m("space-y-4 p-5",Te),children:[t.jsx("h3",{className:"text-base font-semibold",children:i("Active hours")}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[t.jsx("span",{className:`font-medium ${h("text-white","text-gray-700")}`,children:i("Start time")}),t.jsx("input",{type:"time",value:ks,onChange:e=>Go(e.target.value),className:m("px-3 py-2 text-sm",Oe)})]}),t.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[t.jsx("span",{className:`font-medium ${h("text-white","text-gray-700")}`,children:n("שעת סיום","End time")}),t.jsx("input",{type:"time",value:As,onChange:e=>Xo(e.target.value),className:m("px-3 py-2 text-sm",Oe)})]})]})]}
147),t.jsxs("div",{className:m("space-y-4 p-5",Te),children:[t.jsx("h3",{className:"text-base font-semibold",children:i("Notification delivery")}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[t.jsxs("label",{className:m("flex items-center justify-between gap-3 px-3 py-2 text-sm",rt),children:[t.jsx("span",{children:i("Enable all notifications")}),t.jsx("input",{type:"checkbox",checked:vs,onChange:e=>qo(e.target.checked),className:"accent-emerald-500"})]}),t.jsxs("label",{className:m("flex items-center justify-between gap-3 px-3 py-2 text-sm",rt),children:[t.jsx("span",{children:i("System notifications")}),t.jsx("input",{type:"checkbox",checked:Ns,onChange:e=>{jh(e.target.checked)},className:"accent-emerald-500"})]}),t.jsxs("label",{className:m("flex items-center justify-between gap-3 px-3 py-2 text-sm",rt),children:[t.jsx("span",{children:i("In-app toasts")}),t.jsx("input",{type:"checkbox",checked:Dn,onChange:e=>zo(e.target.checked),className:"accent-emerald-500"})]}),t.jsxs("label",{className:m("flex items-center justify-between gap-3 px-3 py-2 text-sm",rt),children:[t.jsx("span",{children:i("Badge count")}),t.jsx("input",{type:"checkbox",checked:Fn,onChange:e=>Qo(e.target.checked),className:"accent-emerald-500"})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[t.jsx("span",{className:`font-medium ${h("text-white","text-gray-700")}`,children:i("Routing mode")}),t.jsx("select",{value:Bn,onChange:e=>Wo(e.target.value),className:m("px-3 py-2 text-sm",Oe),children:j0.map(e=>t.jsx("option",{value:e.value,children:i(e.label)},e.value))})]}),t.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[t.jsx("span",{className:`font-medium ${h("text-white","text-gray-700")}`,children:i("Privacy mode")}),t.jsx("select",{value:js,onChange:e=>Ko(e.target.value),className:m("px-3 py-2 text-sm",Oe),children:k0.map(e=>t.jsx("option",{value:e.value,children:i(e.label)},e.value))})]})]}),t.jsx("div",{className:`text-xs ${h("text-white/60","text-gray-500")}`,children:i(At?"Desktop notifications use the browser permission flow.":at?"Native notifications use the device push permission.":"System notifications are unavailable on this device.")})]}),t.jsxs("div",{className:m("space-y-3 p-5",Te),children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("h3",{className:"text-base font-semibold",children:i("Event rules")}),t.jsx("span",{className:`text-xs ${h("text-white/50","text-gray-500")}`,children:i("Feed items are always saved")})]}),t.jsx("div",{className:"space-y-2",children:N0.map(({key:e,label:a})=>{const l=(Ss==null?void 0:Ss[e])??Os[e]??{toast:!1,system:!1};return t.jsxs("div",{className:m("grid grid-cols-[minmax(0,1fr),auto,auto] items-center gap-3 px-3 py-3 text-sm",ns),children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"font-medium",children:i(a)}),t.jsx("div",{className:`text-[11px] ${h("text-white/50","text-gray-500")}`,children:e})]}),t.jsxs("label",{className:"flex min-h-11 items-center gap-2 rounded-xl px-2 text-xs",children:[t.jsx("span",{children:i("Toast")}),t.jsx("input",{type:"checkbox",checked:!!l.toast,onChange:o=>li(u=>({...u,[e]:{...(u==null?void 0:u[e])??Os[e],toast:o.target.checked}})),className:"accent-emerald-500"})]}),t.jsxs("label",{className:"flex min-h-11 items-center gap-2 rounded-xl px-2 text-xs",children:[t.jsx("span",{children:i("System")}),t.jsx("input",{type:"checkbox",checked:!!l.system,onChange:o=>li(u=>({...u,[e]:{...(u==null?void 0:u[e])??Os[e],system:o.target.checked}})),className:"accent-emerald-500"})]})]},e)})})]}),t.jsxs("div",{className:m("p-5",Te),children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 mb-3",children:[t.jsx("h3",{className:"text-base font-semibold",children:i("Alert sound")}),t.jsxs("div",{className:"relative",children:[t.jsx("input",{id:Zo,type:"checkbox",className:"notification-sound-input",checked:Ke,onChange:e=>Jo(e.target.checked),"aria-label":vc}),t.jsxs("label",{htmlFor:Zo,className:"notification-sound-toggle",title:vc,children:[t.jsx("span",{className:"notification-sound-icon notification-sound-icon--sound",children:t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 75 75","aria-hidden":"true",children:[t.jsx("path",{d:"M39.389,13.769 L22.235,28.606 L6,28.606 L6,47.699 L21.989,47.699 L39.389,62.75 L39.389,13.769z",fill:"
147currentColor",stroke:"currentColor",strokeWidth:"5",strokeLinejoin:"round"}),t.jsx("path",{d:"M48,27.6a19.5,19.5 0 0 1 0,21.4M55.1,20.5a30,30 0 0 1 0,35.6M61.6,14a38.8,38.8 0 0 1 0,48.6",fill:"none",stroke:"currentColor",strokeWidth:"5",strokeLinecap:"round"})]})}),t.jsx("span",{className:"notification-sound-icon notification-sound-icon--mute",children:t.jsxs("svg",{viewBox:"0 0 75 75","aria-hidden":"true",children:[t.jsx("path",{d:"m39,14-17,15H6V48H22l17,15z",fill:"currentColor",stroke:"currentColor",strokeWidth:"5",strokeLinejoin:"round"}),t.jsx("path",{d:"m49,26 20,24m0-24-20,24",fill:"none",stroke:"currentColor",strokeWidth:"5",strokeLinecap:"round"})]})})]})]})]}),t.jsx("div",{className:m("grid grid-cols-2 md:grid-cols-3 gap-3",Ke&&"opacity-60"),children:["Bell","Chime","Radar","Pulse","Wood","Digital"].map(e=>t.jsxs("label",{className:m("flex cursor-pointer items-center justify-between px-3 py-2 text-sm",rt),children:[t.jsx("span",{children:i(e)}),t.jsx("input",{type:"radio",name:"alert_sound",checked:ht===e,onChange:()=>Yo(e),className:"accent-emerald-500"})]},e))})]}),t.jsxs("div",{className:m("sticky bottom-0 z-20 -mx-4 -mb-4 mt-6 flex flex-col items-end gap-2 px-4 py-3 sm:-mx-5 sm:-mb-5 sm:px-5",yc),children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-3",children:[t.jsx("button",{type:"button",onClick:kh,className:Rt,children:i("Test alert")}),t.jsx("button",{type:"button",onClick:gi,disabled:dn,className:m(Ai,dn&&"cursor-not-allowed opacity-60"),children:i(dn?"Saving...":"Set as default")}),t.jsx("button",{type:"button",onClick:vh,disabled:dn,className:m(Ua,dn&&"cursor-not-allowed opacity-60"),children:i(dn?"Saving...":"Save alert settings")}),ph&&t.jsx("span",{className:"text-xs text-emerald-500",children:i("Saved")})]}),ic&&t.jsx("div",{className:"text-xs text-rose-500",children:ic}),Ra&&t.jsx("div",{className:"text-xs text-emerald-500",children:Ra}),Ma&&t.jsx("div",{className:"text-xs text-rose-500",children:Ma})]})]}),st==="Language"&&t.jsx("div",{id:"settings-language",className:"space-y-5",children:t.jsx("div",{className:m("p-6",Te,h("text-white/[0.78]","text-gray-700")),children:t.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("div",{className:r==="HE"?"text-right":"text-left",children:[t.jsx("div",{className:"text-base font-medium mb-1",children:n("Language","Language")}),t.jsx("div",{className:"text-sm opacity-70",children:n("Choose interface language","Choose interface language")})]}),t.jsx(wu,{theme:Se?"settingsDark":"settingsLight",size:"sm",layout:"responsive",className:"w-full sm:w-auto [&>button]:min-h-11",direction:"ltr"})]})})}),st==="Theme"&&t.jsx("div",{id:"settings-theme",children:t.jsx(am,{themeMode:$t,onThemeModeChange:Nh,onSaveDefault:yi,saving:gh,saved:wh,error:yh,isDark:Se,tr:n})}),!ls&&st==="Downloads"&&t.jsxs("div",{id:"settings-downloads",className:"space-y-5",children:[t.jsxs("div",{className:m("p-6 text-sm",Te,h("text-white/[0.78]","text-gray-700")),children:[t.jsx("h3",{className:"text-base font-semibold mb-3",children:i("Downloads")}),t.jsx("p",{className:"leading-6",children:i("Download the latest ALFA apps for your devices below.")})]}),t.jsx("div",{className:m("p-6",Te),children:t.jsxs("div",{className:"space-y-3",children:[[{key:"windows",href:"#",label:i("Download for Windows"),details:i("Windows installer (.exe)")},{key:"android",href:"#",label:i("Download for Android"),details:i("Android package (.apk)")}].map(({key:e,href:a,label:l,details:o})=>t.jsxs("a",{href:a,download:!0,className:m("flex min-h-14 items-center justify-between px-4 py-3",r==="HE"?"flex-row-reverse text-right":"text-left",rt),"aria-label":l,children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-semibold",children:l}),t.jsx("div",{className:`text-xs ${h("text-white/50","text-gray-500")}`,children:o})]}),t.jsx(yn,{className:"w-4 h-4"})]},e)),t.jsxs("div",{className:m("flex min-h-14 items-center justify-between px-4 py-3",r==="HE"?"flex-row-reverse text-right":"text-left",ns),children:[t.jsx("span",{className:"font-semibold",children:n("Download Reports","Download Reports")}),t.jsx("button",{type:"button",onClick:()=>{const e={account:ve,timestamp:new Date().toISOString(),portfolio_value:245380,positions:[],orders:[],performance:he==="movement"?ho??{}:{}},a=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),l=URL.createObjectURL(a),o=document.createElement("a");o.href=l,o.download=`alfa-report-${ve.replace(/[^a-zA-Z0-9]/g,"_")}-${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(l)},className:m("inline-flex min-h-11 items-center gap-2 px-4 py-2 text-sm font-semibold",Ua,r==="HE"&&"flex-row-reverse"),title:n("Download Reports","Download Reports"),"aria-label":n("Download Reports","Download Reports"),children:t.jsx(yn,{className:"w-4 h-4"})})]})]})})]}),st==="System"&&t.jsxs("div",{id:"settings-system",className:"space-y-5",children:[M&&t.jsxs("div",{"data-tesla-owner
147-settings":"true",className:m("flex flex-col gap-3 p-5 sm:flex-row sm:items-center sm:justify-between",Te),children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold",children:n("מרכז הרכב של Tesla","Tesla vehicle center")}),t.jsx("p",{className:m("mt-1 text-sm",Lt),children:n("חיבור החשבון ופרטי הרכב השמורים.","Account connection and saved vehicle details.")})]}),t.jsx("button",{type:"button",onClick:()=>{H(!1),w(o0({pathname:"/Backtest",search:"?view=network&material=vehicle"},!0),{state:Nd(y.state)})},className:m("inline-flex min-h-11 shrink-0 items-center justify-center px-4 text-sm font-semibold",Rt),children:n("פתח את מרכז הרכב","Open vehicle center")})]}),(p==null?void 0:p.isAdmin)&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:m("p-5",Te),children:[t.jsxs("div",{className:"mb-2",children:[t.jsx("h3",{className:"text-base font-semibold",children:i("Program Control")}),t.jsx("p",{className:m("mt-1 text-sm",Lt),children:n("הפעל או השהה את התוכנית ממסך המערכת.","Start or pause the program from System settings.")})]}),t.jsx(Zu,{enabled:Sr,loading:Ol||Nr.executionEnabled==null,saving:_l,error:Hl,toggleId:Lm,onToggle:Yh,onRetry:Jh,isDark:Se,tr:n})]}),t.jsxs("div",{className:m("p-6",Te,h("text-white/[0.78]","text-gray-700")),children:[t.jsxs("div",{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between ${r==="HE"?"sm:flex-row-reverse":""}`,children:[t.jsxs("div",{className:r==="HE"?"text-right":"text-left",children:[t.jsx("div",{className:"text-base font-medium mb-1",children:n("סקירת מערכת","System Overview")}),t.jsx("div",{className:"text-sm opacity-70",children:n("תצוגת יציבות חיה לשירותי הליבה","Live stability view for core services")})]}),t.jsxs("button",{type:"button",onClick:Ci,className:m("inline-flex min-h-11 items-center gap-2 px-3 py-2 text-sm",Rt),children:[t.jsx(Bt,{className:`w-4 h-4 ${ma||$r?"animate-spin":""}`}),n("רענן","Refresh")]})]}),t.jsxs("div",{className:"mt-5 grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[t.jsxs("div",{className:m("p-4",ns),children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("div",{className:"text-sm font-semibold",children:n("בריאות שרת","Backend Health")}),t.jsxs("span",{className:`inline-flex items-center gap-2 px-2 py-0.5 rounded-full text-xs ${Wt(Pi.tone)}`,children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${za(Pi.tone)}`}),Pi.label]})]}),t.jsxs("div",{className:`mt-3 space-y-1 text-xs ${h("text-white/60","text-gray-600")}`,children:[t.jsxs("div",{children:[n("גרסה","Version"),": ",(gt==null?void 0:gt.version)??"--"]}),t.jsxs("div",{children:[n("זמן שרת","Server time"),": ",as(gt==null?void 0:gt.timestamp)]})]})]}),t.jsxs("div",{className:m("p-4",ns),children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("div",{className:"text-sm font-semibold",children:n("זרם נתוני שוק","Market Data Stream")}),t.jsxs("span",{className:`inline-flex items-center gap-2 px-2 py-0.5 rounded-full text-xs ${Wt(Ii.tone)}`,children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${za(Ii.tone)}`}),Ii.label]})]}),t.jsxs("div",{className:`mt-3 space-y-1 text-xs ${h("text-white/60","text-gray-600")}`,children:[t.jsxs("div",{children:[n("סימולים","Symbols"),": ",nf]}),t.jsxs("div",{children:[n("עדכון אחרון","Last update"),":"," ",de!=null&&de.timestamp||de!=null&&de.generatedAt?`${as((de==null?void 0:de.timestamp)??(de==null?void 0:de.generatedAt))} • ${Mt((de==null?void 0:de.timestamp)??(de==null?void 0:de.generatedAt))}`:"--"]}),t.jsxs("div",{children:[n("מרווח ברים","Bar interval"),": ",P!=null&&P.premiumBarMinutes?`${P.premiumBarMinutes}m`:"--"]})]})]}),t.jsxs("div",{className:m("p-4",ns),children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("div",{className:"text-sm font-semibold",children:n("זרמי תיק","Portfolio Streams")}),t.jsxs("span",{className:`inline-flex items-center gap-2 px-2 py-0.5 rounded-full text-xs ${Wt($i.tone)}`,children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${za($i.tone)}`}),$i.label]})]}),t.jsxs("div",{className:`mt-3 space-y-1 text-xs ${h("text-white/60","text-gray-600")}`,children:[t.jsxs("div",{children:[n("חשבונות","Accounts"),": ",St.eligible,"/",St.total]}),t.jsxs("div",{children:[n("אסטרטגיה","Strategy"),": ",q?q.strategyEnabled?n("פעיל","Enabled"):n("מושבת","Disabled"):"--"," • ",n("ציטוטים","Quotes"),": ",q?q.quoteStreamsEnabled?n("פעיל","Enabled"):n("מושבת","Disabled"):"--"]}),t.jsxs("div",{children:[n("הזמנות מתעכבות","Stale orders"),": ",St.staleOrders," • ",n("פוזיציות מתעכבות","Stale positions"),": ",St.stalePositions]}),t.jsxs("div",{children:[n("בדיקה אחרונה","Last check"),":"," ",q!=null&&q.generatedAt?`${as(q.generatedAt)} • ${Mt(q.generatedAt)}`:"--"]})]})]}),t.jsxs("div",{className:m("p-4",ns),children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("div",{className:"text-sm font-semibold",children:n("נתוני VIX","VIX Data")}),t.jsxs("span",{className:`inline-flex items-center gap-2 px-2 py-0.5 rounded-full text-xs ${Wt(Li.tone)}`,children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${za(Li.tone)}`}),Li.label]})]}),t.jsxs("div",{className:`mt-3 space-y-1 text-xs ${h("text-white/60","text-gray-600")}`,children:[t.jsxs("div",{children:[n("סימול","Symbol"),": ",((cd=P==null?void 0:P.indicator)==null?void 0:cd.mainSymbol)??"--"]}),t.jsxs("div",{children:[n("פקיעה","Expiry"),":"," ",(dd=P==null?void 0:P.indicator)!=null&&dd.expiryTimestamp?as(new Date(P.indicator.expiryTimestamp)):"--"]}),t.jsxs("div",{className:`mt-2 pt-2 border-t ${h("border-white/10","border-black/10")}`,children:[t.jsx("div",{className:"font-medium mb-1",children:((ud=P==null?void 0:P.indicator)==null?void 0:ud.mainSymbol)??"Main"}),t.jsxs("div",{children:["Bid: ",(ye==null?void 0:ye.bid)!=null?ye.bid.toFixed(2):"--"," • Ask: ",(ye==null?void 0:ye.ask)!=null?ye.ask.toFixed(2):"--"," • Last: ",(ye==null?void 0:ye.last)!=null?ye.last.toFixed(2):"--"]}),t.jsxs("div",{children:[n("עדכון","Updated"),":"," ",ye!=null&&ye.timestamp?Mt(new Date(ye.timestamp)):"--"]})]}),t.jsxs("div",{className:`mt-2 pt-2 border-t ${h("border-white/10","border-black/10")}`,children:[t.jsx("div",{className:"font-medium mb-1",children:((md=P==null?void 0:P.indicator)==null?void 0:md.referenceSymbol)??"Reference"}),t.jsxs("div",{children:["Bid: ",(we==null?void 0:we.bid)!=null?we.bid.toFixed(2):"--"," • Ask: ",(we==null?void 0:we.ask)!=null?we.ask.toFixed(2):"--"," • Last: ",(we==null?void 0:we.last)!=null?we.last.toFixed(2):"--"]}),t.jsxs("div",{children:[n("עדכון","Updated"),":"," ",we!=null&&we.timestamp?Mt(new Date(we.timestamp)):"--"]})]})]})]})]})]}),t.jsxs("div",{className:m("p-6",Te,h("text-white/[0.78]","text-gray-700")),children:[t.jsxs("div",{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between ${r==="HE"?"sm:flex-row-reverse":""}`,children:[t.jsxs("div",{className:r==="HE"?"text-right":"text-left",children:[t.jsx("div",{className:"text-base font-medium mb-1",children:n("בריאות זרמי חשבון","Account Stream Health")}),t.jsx("div",{className:"text-sm opacity-70",children:n("ניטור זרמי הזמנות ופוזיציות לכל חשבון","Monitor order and position feeds per account")}
147)]}),t.jsxs("div",{className:`text-xs ${h("text-white/60","text-gray-600")}`,children:[n("פעילים","Active"),": ",St.active," • ",n("כשירים","Eligible"),": ",St.eligible," • ",n("חסרים פרטי אימות","Missing credentials"),": ",St.missingCredentials]})]}),t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[t.jsxs("select",{value:dt.status,onChange:e=>qa({status:e.target.value}),className:m("px-3 py-2 text-xs",Oe),children:[t.jsx("option",{value:"all",children:n("כל החשבונות","All accounts")}),t.jsx("option",{value:"active",children:n("פעילים בלבד","Active only")}),t.jsx("option",{value:"inactive",children:n("לא פעילים בלבד","Inactive only")})]}),t.jsxs("select",{value:dt.health,onChange:e=>qa({health:e.target.value}),className:m("px-3 py-2 text-xs",Oe),children:[t.jsx("option",{value:"all",children:n("כל המצבים","All health")}),t.jsx("option",{value:"healthy",children:n("בריאים בלבד","Healthy only")}),t.jsx("option",{value:"attention",children:n("דורש תשומת לב","Needs attention")})]}),t.jsxs("select",{value:dt.credentials,onChange:e=>qa({credentials:e.target.value}),className:m("px-3 py-2 text-xs",Oe),children:[t.jsx("option",{value:"all",children:n("כל האימותים","All credentials")}),t.jsx("option",{value:"missing",children:n("חסרים פרטי אימות","Missing credentials")}),t.jsx("option",{value:"ok",children:n("אימות תקין","Credentials OK")})]}),t.jsx("input",{type:"search",value:dt.search,onChange:e=>qa({search:e.target.value}),placeholder:n("חיפוש חשבון...","Search account..."),className:m("w-44 px-3 py-2 text-xs",Oe)}),t.jsx("button",{type:"button",onClick:sf,className:m("min-h-11 px-3 py-2 text-xs",Rt),children:n("איפוס","Reset")}),t.jsxs("div",{className:`text-xs ${h("text-white/50","text-gray-500")}`,children:[n("מציג","Showing")," ",Ti.length," ",n("מתוך","of")," ",Ts.length]})]}),(!(q!=null&&q.accountStreamsEnabled)||!(q!=null&&q.streamingEnabled))&&t.jsx("div",{className:"mt-3 text-xs text-amber-400",children:n("זרמי החשבונות מושבתים בהגדרות המערכת.","Account streams are disabled in system configuration.")}),t.jsx("div",{className:"mt-4",children:ma?t.jsxs("div",{className:"flex items-center justify-center py-8 text-sm opacity-80",children:[t.jsx(Bt,{className:"w-4 h-4 mr-2 animate-spin"}),n("Loading...","Loading...")]}):fa?t.jsx("div",{className:"px-4 py-4 text-sm text-rose-400",children:fa}):Ti.length===0?t.jsx("div",{className:"px-4 py-6 text-sm opacity-70 text-center",children:Ts.length===0?n("לא נמצאו חשבונות לניטור","No accounts available for monitoring"):n("אין חשבונות שמתאימים למסננים","No accounts match the filters")}):t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("div",{className:"min-w-[880px]",children:[t.jsxs("div",{className:`grid grid-cols-4 gap-4 text-xs ${h("text-white/60","text-gray-600")} px-4 py-3 border-b ${h("border-white/10","border-black/10")}`,children:[t.jsx("span",{className:r==="HE"?"text-right":"",children:n("חשבון","Account")}),t.jsx("span",{className:r==="HE"?"text-right":"",children:n("זרם הזמנות","Orders Stream")}),t.jsx("span",{className:r==="HE"?"text-right":"",children:n("זרם פוזיציות","Positions Stream")}),t.jsx("span",{className:r==="HE"?"text-right":"",children:n("עדכון נתונים","Data Updated")})]}),t.jsx("div",{className:`divide-y ${h("divide-white/10","divide-gray-200")}`,children:Ti.map(e=>{const a=(e==null?void 0:e.accountId)??"",l=(e==null?void 0:e.name)||a,o=kc(e,"orders"),u=kc(e,"positions"),c=e!=null&&e.isActive?"good":"muted",b=e!=null&&e.hasCredentials?"good":"warn";return t.jsxs("div",{className:`grid grid-cols-4 gap-4 px-4 py-4 text-sm ${h("text-white/80","text-gray-800")}`,children:[t.jsxs("div",{className:r==="HE"?"text-right":"",children:[t.jsx("div",{className:"font-semibold",children:l}),t.jsx("div",{className:`text-xs ${h("text-white/50","text-gray-500")}`,children:a||"--"}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-2 text-[11px]",children:[t.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full ${Wt(c)}`,children:e!=null&&e.isActive?n("פעיל","Active"):n("לא פעיל","Inactive")}),t.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full ${Wt(b)}
147`,children:e!=null&&e.hasCredentials?n("אימות תקין","Credentials OK"):n("חסרים פרטי אימות","Missing credentials")})]})]}),t.jsxs("div",{className:r==="HE"?"text-right":"",children:[t.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs ${Wt(o.tone)}`,children:o.label}),t.jsx("div",{className:`mt-2 text-xs ${h("text-white/50","text-gray-500")}`,children:o.detail})]}),t.jsxs("div",{className:r==="HE"?"text-right":"",children:[t.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs ${Wt(u.tone)}`,children:u.label}),t.jsx("div",{className:`mt-2 text-xs ${h("text-white/50","text-gray-500")}`,children:u.detail})]}),t.jsx("div",{className:r==="HE"?"text-right":"",children:t.jsxs("div",{className:`text-xs ${h("text-white/50","text-gray-500")}`,children:[t.jsxs("div",{children:[n("הזמנות","Orders"),": ",Mt(e==null?void 0:e.ordersUpdatedAt)]}),t.jsxs("div",{children:[n("פוזיציות","Positions"),": ",Mt(e==null?void 0:e.positionsUpdatedAt)]}),t.jsxs("div",{children:[n("יתרות","Balances"),": ",Mt(e==null?void 0:e.balancesUpdatedAt)]})]})})]},a)})})]})})})]}),t.jsxs("div",{className:m("p-6",Te,h("text-white/[0.78]","text-gray-700")),children:[t.jsxs("div",{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between ${r==="HE"?"lg:flex-row-reverse":""}`,children:[t.jsxs("div",{className:r==="HE"?"text-right":"text-left",children:[t.jsx("div",{className:"text-base font-medium mb-1",children:n("יומן מערכת","System Logs")}),t.jsx("div",{className:"text-sm opacity-70",children:n("סקירת פעילות מערכת חיונית","Review essential system activity")})]}),t.jsxs("div",{className:`flex flex-wrap items-center gap-2 ${r==="HE"?"justify-end":""}`,children:[t.jsxs("div",{className:`inline-flex rounded-lg border shadow-sm ${h("border-white/10 bg-white/5","border-black/10 bg-white")}`,children:[t.jsx("button",{type:"button",onClick:()=>Yl("essential"),className:`min-h-11 px-3 py-1.5 text-xs focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-emerald-400/60 ${da==="essential"?"bg-emerald-600 text-white":h("text-white/70 hover:bg-white/10","text-gray-600 hover:bg-gray-100")}`,children:n("חיוני","Essential")}),t.jsx("button",{type:"button",onClick:()=>Yl("all"),className:`min-h-11 px-3 py-1.5 text-xs focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-emerald-400/60 ${da==="all"?"bg-emerald-600 text-white":h("text-white/70 hover:bg-white/10","text-gray-600 hover:bg-gray-100")}`,children:n("כל היומנים","All Logs")})]}),t.jsxs("select",{value:ca,onChange:e=>Mm(e.target.value),className:m("px-3 py-2 text-xs",Oe),children:[t.jsx("option",{value:"all",children:n("All Levels","All Levels")}),t.jsx("option",{value:"info",children:"Info"}),t.jsx("option",{value:"warning",children:"Warning"}),t.jsx("option",{value:"error",children:"Error"})]}),t.jsxs("select",{value:ua,onChange:e=>Om(e.target.value),className:m("px-3 py-2 text-xs",Oe),children:[t.jsx("option",{value:"all",children:n("כל ההקשרים","All Contexts")}),Um.map(e=>t.jsx("option",{value:e,children:e},e))]}),t.jsx("input",{type:"search",value:Pr,onChange:e=>_m(e.target.value),placeholder:n("חיפוש ביומנים...","Search logs..."),className:m("w-40 px-3 py-2 text-xs",Oe)})]})]}),t.jsx("div",{className:m("mt-4 overflow-hidden",ns),children:Rm?t.jsxs("div",{className:"flex items-center justify-center py-8 text-sm opacity-80",children:[t.jsx(Bt,{className:"w-4 h-4 mr-2 animate-spin"}),n("Loading...","Loading...")]}):Xl?t.jsx("div",{className:"px-4 py-4 text-sm text-rose-400",children:Xl}):lo.length===0?t.jsx("div",{className:"px-4 py-6 text-sm opacity-70 text-center",children:n("אין רשומות ביומן המערכת עדיין","No system logs yet")}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`grid grid-cols-4 gap-4 text-xs ${h("text-white/60","text-gray-600")} px-4 py-3 border-b ${h("border-white/10","border-black/10")}`,children:[t.jsx("span",{className:r==="HE"?"text-right":"",children:n("Time","Time")}),t.jsx("span",{className:r==="HE"?"text-right":"",children:n("Level","Level")}),t.jsx("span",{className:r==="HE"?"text-right":"",children:n("הקשר","Context")}),t.jsx("span",{className:r==="HE"?"text-right":"",children:n("Message","Message")})]}
147),t.jsx("div",{className:`divide-y ${h("divide-white/10","divide-gray-200")}`,children:lo.map((e,a)=>{const l=typeof e.level=="string"?e.level:"Info",o=l.toLowerCase(),u=o==="error"?"bad":o==="warning"?"warn":"good";return t.jsxs("div",{className:`grid grid-cols-4 gap-4 px-4 py-4 text-sm ${h("text-white/80","text-gray-800")}`,children:[t.jsx("div",{className:`${r==="HE"?"text-right":""}`,children:as(e.timestamp)}),t.jsx("div",{className:`${r==="HE"?"text-right":""}`,children:t.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-md text-xs ${Wt(u)}`,children:l})}),t.jsx("div",{className:`${r==="HE"?"text-right":""}`,children:e.context??"-"}),t.jsx("div",{className:`${r==="HE"?"text-right":""}`,children:e.message})]},`${e.timestamp}-${a}`)})})]})})]}),t.jsx("div",{className:m("p-6",Te,h("text-white/[0.78]","text-gray-700")),children:t.jsxs("div",{className:`flex flex-col gap-4 ${r==="HE"?"text-right":"text-left"}`,children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-base font-medium mb-1",children:n("אוטומציית חיזוי","Forecast Automation")}),t.jsx("div",{className:"text-sm opacity-70",children:n("הפעל חיזוי יומי ידני או הורד נתוני ביצועים","Run manual daily forecast or download performance data")})]}),t.jsxs("div",{className:`flex flex-wrap gap-3 ${r==="HE"?"flex-row-reverse":""}`,children:[t.jsxs("button",{type:"button",onClick:ef,disabled:Bs,className:m("inline-flex min-h-11 items-center gap-2 px-4 py-2.5 text-sm font-medium",Rt,Bs&&"cursor-not-allowed opacity-55"),children:[t.jsx(Bt,{className:m("h-4 w-4",Bs&&"animate-spin")}),Bs?n("מרענן...","Refreshing..."):n("רענן תחזיות","Refresh Forecasts")]}),t.jsxs("button",{type:"button",onClick:Zh,disabled:Fs,className:m("inline-flex min-h-11 items-center gap-2 px-4 py-2.5 text-sm font-medium",Rt,Fs&&"cursor-not-allowed opacity-55"),children:[Fs&&t.jsx(Bt,{className:"h-4 w-4 animate-spin"}),t.jsx(yn,{className:"h-4 w-4"}),Fs?n("מייצא...","Exporting..."):n("הורד נתוני חיזוי","Download Forecast Data")]}),t.jsxs("button",{type:"button",onClick:tf,disabled:Vs,className:m("inline-flex min-h-11 items-center gap-2 px-4 py-2.5 text-sm font-medium",Rt,Vs&&"cursor-not-allowed opacity-55"),children:[Vs&&t.jsx(Bt,{className:"h-4 w-4 animate-spin"}),t.jsx(yn,{className:"h-4 w-4"}),Vs?n("מייצא...","Exporting..."):n("השוואת V1","V1 Comparison")]})]}),Ql&&t.jsx("div",{role:"alert",className:"text-sm text-red-500",children:Ql}),Wl&&t.jsx("div",{role:"status",className:"text-sm",children:Wl})]})})]})]})]}),X&&t.jsx("nav",{"data-crm-mobile-dock":"true",className:m("fixed inset-x-0 bottom-0 z-40 border-t px-2 pt-1.5",h("border-white/10 bg-[#191c20] text-white","border-slate-200 bg-white text-slate-900")),style:{paddingBottom:"env(safe-area-inset-bottom, 0px)"},"aria-label":n("ניווט ראשי","Main navigation"),children:t.jsxs("div",{className:"grid h-[62px] grid-cols-3 gap-1",dir:r==="HE"?"rtl":"ltr",children:[t.jsxs("button",{type:"button",onClick:Ps.onClick,className:Fi(Ps.isActive),"aria-current":Ps.isActive?"page":void 0,"aria-label":Ps.label,children:[t.jsx("span",{className:Bi(Ps.isActive),children:t.jsx(Ps.Icon,{className:"h-5 w-5","aria-hidden":"true"})}),t.jsx("span",{children:Ps.label})]}),t.jsxs("button",{type:"button",onClick:bf,className:Fi(Di),"aria-current":Di?"page":void 0,"aria-label":xf,children:[t.jsx("span",{className:Bi(Di),children:t.jsx("img",{src:cu,alt:"",className:"h-6 w-6 object-contain"})}),t.jsx("span",{children:"ALFA"})]}),t.jsxs("button",{type:"button",onClick:Is.onClick,className:Fi(Is.isActive),"aria-current":Is.isActive?"page":void 0,"aria-label":Is.label,children:[t.jsx("span",{className:Bi(Is.isActive),children:t.jsx(Is.Icon,{className:"h-5 w-5","aria-hidden":"true"})}),t.jsx("span",{children:Is.label})]})]})}),If()]})}const X0=Object.freeze(Object.defineProperty({__proto__:null,default:M0},Symbol.toStringTag,{value:"Module"}));export{Tx as A,vp as C,yn as D,Bx as E,fu as L,dl as M,Zx as P,gp as R,Ad as S,yp as T,yu as W,ms as X,wp as a,Np as b,Lx as c,mu as d,pr as e,bu as f,pu as g,Sl as h,Ft as i,G0 as j,o0 as k,K0 as l,X0 as m,u0 as r};

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.