@axhub/genie 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/App-BWSqiXAT.js +220 -0
- package/dist/assets/App-DrlLKa8f.css +1 -0
- package/dist/assets/ReviewApp-nz3mbArg.js +1 -0
- package/dist/assets/{_basePickBy-DkiHsp3X.js → _basePickBy-C19AekOu.js} +1 -1
- package/dist/assets/{_baseUniq-7ElXb2sX.js → _baseUniq-JsnevLw_.js} +1 -1
- package/dist/assets/{arc-CEsS3MdK.js → arc-BLpcuBlf.js} +1 -1
- package/dist/assets/architectureDiagram-2XIMDMQ5-CarjBOOv.js +36 -0
- package/dist/assets/{blockDiagram-WCTKOSBZ-Cza6M6Ht.js → blockDiagram-WCTKOSBZ-DQBLwsUS.js} +3 -3
- package/dist/assets/c4Diagram-IC4MRINW-CGobwBIj.js +10 -0
- package/dist/assets/channel-DkFNxV_H.js +1 -0
- package/dist/assets/{chunk-4BX2VUAB--HkodwbY.js → chunk-4BX2VUAB-De63kbgc.js} +1 -1
- package/dist/assets/{chunk-55IACEB6-CyBuez4e.js → chunk-55IACEB6-DtTDDdM9.js} +1 -1
- package/dist/assets/{chunk-FMBD7UC4-CuzG4iAl.js → chunk-FMBD7UC4-DHuwd8tw.js} +1 -1
- package/dist/assets/{chunk-JSJVCQXG-BNi8S861.js → chunk-JSJVCQXG-BgytFtmO.js} +1 -1
- package/dist/assets/{chunk-KX2RTZJC-D817O-GT.js → chunk-KX2RTZJC-nZdp86aN.js} +1 -1
- package/dist/assets/chunk-NQ4KR5QH-CMH6EDP2.js +220 -0
- package/dist/assets/{chunk-QZHKN3VN-VMEn-zxh.js → chunk-QZHKN3VN-DvUQ3mnO.js} +1 -1
- package/dist/assets/chunk-WL4C6EOR-Dn7db_6t.js +189 -0
- package/dist/assets/classDiagram-VBA2DB6C-DtwCEe8S.js +1 -0
- package/dist/assets/classDiagram-v2-RAHNMMFH-DtwCEe8S.js +1 -0
- package/dist/assets/clone-C0lCEIEO.js +1 -0
- package/dist/assets/cose-bilkent-S5V4N54A-DD_nzqsz.js +1 -0
- package/dist/assets/cytoscape.esm-5J0xJHOV.js +321 -0
- package/dist/assets/{dagre-KLK3FWXG-Bqp7DjEa.js → dagre-KLK3FWXG-CHYIvW47.js} +1 -1
- package/dist/assets/diagram-E7M64L7V-TVdvHtGc.js +24 -0
- package/dist/assets/{diagram-IFDJBPK2--fHfW6V2.js → diagram-IFDJBPK2-Dzsiln_C.js} +1 -1
- package/dist/assets/{diagram-P4PSJMXO-D1kQI5RB.js → diagram-P4PSJMXO-DKnGbUpE.js} +1 -1
- package/dist/assets/erDiagram-INFDFZHY-5Kw0bByo.js +70 -0
- package/dist/assets/{flowDiagram-PKNHOUZH-DWeNr4yg.js → flowDiagram-PKNHOUZH-BAZ2-jKp.js} +4 -4
- package/dist/assets/ganttDiagram-A5KZAMGK-CsADFkcq.js +292 -0
- package/dist/assets/{gitGraphDiagram-K3NZZRJ6-B5a8UWjN.js → gitGraphDiagram-K3NZZRJ6-BflpyjGy.js} +1 -1
- package/dist/assets/{graph-Cw1rYoD9.js → graph-suelaXFh.js} +1 -1
- package/dist/assets/highlighted-body-OFNGDK62-CZrBMazC.js +1 -0
- package/dist/assets/index-B01NxbUv.css +1 -0
- package/dist/assets/index-DW5pGgQ_.js +2 -0
- package/dist/assets/{infoDiagram-LFFYTUFH-D2u70rhN.js → infoDiagram-LFFYTUFH-pfD1FA3p.js} +1 -1
- package/dist/assets/ishikawaDiagram-PHBUUO56-ndm9snwO.js +70 -0
- package/dist/assets/journeyDiagram-4ABVD52K-HgF2t7z5.js +139 -0
- package/dist/assets/{kanban-definition-K7BYSVSG-DbVt0v29.js → kanban-definition-K7BYSVSG-FWinmur1.js} +5 -5
- package/dist/assets/{layout-W_tRx4UV.js → layout-vcz43XvZ.js} +1 -1
- package/dist/assets/{linear-CcMb2ay-.js → linear-le4gc0vx.js} +1 -1
- package/dist/assets/mermaid-GHXKKRXX-CK8m3lad.js +870 -0
- package/dist/assets/mindmap-definition-YRQLILUH-CNq9SKj4.js +68 -0
- package/dist/assets/{pieDiagram-SKSYHLDU-CDyJaACv.js → pieDiagram-SKSYHLDU-C7PKDh3b.js} +2 -2
- package/dist/assets/quadrantDiagram-337W2JSQ-B7FnztNO.js +7 -0
- package/dist/assets/requirementDiagram-Z7DCOOCP-Bl_BM2Th.js +73 -0
- package/dist/assets/{sankeyDiagram-WA2Y5GQK-Di1ShaMF.js → sankeyDiagram-WA2Y5GQK-4gulcOP4.js} +3 -3
- package/dist/assets/sequenceDiagram-2WXFIKYE-VEuJDwyJ.js +145 -0
- package/dist/assets/{stateDiagram-RAJIS63D-CVZYMqyW.js → stateDiagram-RAJIS63D-CB4Vl7qM.js} +1 -1
- package/dist/assets/stateDiagram-v2-FVOUBMTO-C85ucl39.js +1 -0
- package/dist/assets/timeline-definition-YZTLITO2-BPGKhi7f.js +61 -0
- package/dist/assets/{treemap-KZPCXAKY-CGG4gx3C.js → treemap-KZPCXAKY-DZSEE6Hz.js} +58 -58
- package/dist/assets/vendor-codemirror-CyOKkaQZ.js +31 -0
- package/dist/assets/vendor-react-CP4yFTs7.js +8 -0
- package/dist/assets/vendor-xterm-DfcmCpbH.js +66 -0
- package/dist/assets/{vennDiagram-LZ73GAT5-Dds37L2k.js → vennDiagram-LZ73GAT5-8E_G06fI.js} +4 -4
- package/dist/assets/xychartDiagram-JWTSCODW-CbBk50-O.js +7 -0
- package/dist/index.html +4 -4
- package/package.json +2 -1
- package/server/_legacy-providers/README.md +30 -0
- package/server/_legacy-providers/claude-sdk.js +956 -0
- package/server/_legacy-providers/gemini-cli.js +368 -0
- package/server/_legacy-providers/openai-codex.js +705 -0
- package/server/_legacy-providers/opencode-cli.js +674 -0
- package/server/acp-runtime/client.js +1805 -0
- package/server/acp-runtime/client.test.js +688 -0
- package/server/acp-runtime/index.js +419 -0
- package/server/acp-runtime/registry.js +45 -0
- package/server/acp-runtime/session-store.js +254 -0
- package/server/acp-runtime/session-store.test.js +89 -0
- package/server/channels/runtime/AgentRuntimeAdapter.js +21 -70
- package/server/claude-sdk.js +24 -944
- package/server/cli.js +4 -2
- package/server/external-agent/service.js +52 -63
- package/server/gemini-cli.js +23 -360
- package/server/index.js +47 -44
- package/server/openai-codex.js +24 -698
- package/server/opencode-cli.js +70 -640
- package/server/routes/agent.js +2 -0
- package/server/routes/git.js +3 -20
- package/server/routes/session-core.js +44 -10
- package/server/session-core/abortSession.js +2 -18
- package/server/session-core/eventStore.js +5 -1
- package/server/session-core/providerAdapters.js +98 -10
- package/server/session-core/runtimeState.js +16 -17
- package/server/session-core/runtimeWriter.js +19 -12
- package/shared/conversationEvents.js +347 -10
- package/shared/conversationEvents.test.js +403 -0
- package/dist/assets/App-CYTE30Cf.js +0 -484
- package/dist/assets/App-qxJ8_QYu.css +0 -32
- package/dist/assets/ReviewApp-BEicSBzW.js +0 -1
- package/dist/assets/architectureDiagram-2XIMDMQ5-BubZ7T3U.js +0 -36
- package/dist/assets/c4Diagram-IC4MRINW-jhjtOQ12.js +0 -10
- package/dist/assets/channel-RmqTALN0.js +0 -1
- package/dist/assets/chunk-NQ4KR5QH-DyujyOvx.js +0 -220
- package/dist/assets/chunk-WL4C6EOR-CQHHFLvx.js +0 -189
- package/dist/assets/classDiagram-VBA2DB6C-wvVV1ggz.js +0 -1
- package/dist/assets/classDiagram-v2-RAHNMMFH-wvVV1ggz.js +0 -1
- package/dist/assets/clone-oT5aWXpf.js +0 -1
- package/dist/assets/cose-bilkent-S5V4N54A-qykDd54p.js +0 -1
- package/dist/assets/cytoscape.esm-2ZfV8NB5.js +0 -331
- package/dist/assets/diagram-E7M64L7V-BKtx468K.js +0 -24
- package/dist/assets/erDiagram-INFDFZHY-DT9YzdNw.js +0 -70
- package/dist/assets/ganttDiagram-A5KZAMGK--IgwcUhI.js +0 -292
- package/dist/assets/highlighted-body-TPN3WLV5-BCxJHuqY.js +0 -1
- package/dist/assets/index-CBuAXA5S.js +0 -2
- package/dist/assets/index-CyLWKyxy.css +0 -1
- package/dist/assets/ishikawaDiagram-PHBUUO56-Cl8yrezU.js +0 -70
- package/dist/assets/journeyDiagram-4ABVD52K-ddP0AMU9.js +0 -139
- package/dist/assets/mermaid-O7DHMXV3-BBJqt8pT.js +0 -988
- package/dist/assets/mindmap-definition-YRQLILUH-BGhZa7Na.js +0 -68
- package/dist/assets/quadrantDiagram-337W2JSQ-BSYuqf0Q.js +0 -7
- package/dist/assets/requirementDiagram-Z7DCOOCP-Cfi9YX9H.js +0 -73
- package/dist/assets/sequenceDiagram-2WXFIKYE-CYTTG38e.js +0 -145
- package/dist/assets/stateDiagram-v2-FVOUBMTO-Bbl0b4-i.js +0 -1
- package/dist/assets/timeline-definition-YZTLITO2-B1sdb5mK.js +0 -61
- package/dist/assets/vendor-codemirror-Dz7_EqNA.js +0 -39
- package/dist/assets/vendor-react-Cpt6D04s.js +0 -59
- package/dist/assets/vendor-xterm-DfaPXD3y.js +0 -66
- package/dist/assets/xychartDiagram-JWTSCODW-C8QKSyRR.js +0 -7
|
@@ -1,484 +0,0 @@
|
|
|
1
|
-
import{j as r,S as Vn,F as Js,T as jc,P as Sc,E as ur,V as Ys,a as Wa,g as Up,D as Dr,R as Ls,G as Ha,W as qa,l as Nc,h as ma,b as Cc,C as Wp,c as Hp,d as qp,e as kn,f as Vp,i as Kp,u as Gp,k as el,s as Jp,m as Yp,n as Xp,o as Qp,p as Zp,q as em,r as tm,t as rm,v as nm,w as sm,x as om,y as am}from"./vendor-codemirror-Dz7_EqNA.js";import{a as l,c as im,R as Tn,d as qo,g as Ec,B as lm,e as cm,f as Vo,u as dm,h as um,i as pm}from"./vendor-react-Cpt6D04s.js";import{bJ as _e,bK as Xt,bL as fa,bM as on,bN as Os,bO as Ic,bP as Le,bQ as Xs,bR as Va,bS as xr,bT as Ac,bU as mm,bV as fm,bW as hm,bX as gm,bY as xm,bZ as vm,b_ as ym,b$ as bm,c0 as wm,c1 as km,c2 as jm,c3 as st,c4 as Ka,c5 as Mt,c6 as vr,c7 as Sm,c8 as Pe,c9 as Un,ca as yn,cb as Ar,cc as an,cd as Ga,ce as Tc,cf as Nm,cg as Cm,ch as Em,ci as Im,cj as Am,ck as tl,cl as rl,cm as nl,cn as Ko,co as Tm,cp as _m,cq as Mm,cr as Dm,cs as Rm,ct as Pm,cu as Lm,cv as Om,cw as Fm,cx as $m,cy as _c,cz as Ja,cA as Bm,cB as zm,I as Um,T as Wm,U as Hm}from"./mermaid-O7DHMXV3-BBJqt8pT.js";import{r as qm,a as Vm,b as Km}from"./vendor-xterm-DfaPXD3y.js";import{l as sl,i as Gm}from"./index-CBuAXA5S.js";/**
|
|
2
|
-
* @license lucide-react v0.515.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const Jm=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Ym=_e("arrow-down",Jm);/**
|
|
7
|
-
* @license lucide-react v0.515.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const Xm=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Mc=_e("chevron-left",Xm);/**
|
|
12
|
-
* @license lucide-react v0.515.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const Qm=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],ha=_e("download",Qm);/**
|
|
17
|
-
* @license lucide-react v0.515.0 - ISC
|
|
18
|
-
*
|
|
19
|
-
* This source code is licensed under the ISC license.
|
|
20
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const Zm=[["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"}]],gs=_e("ellipsis",Zm);/**
|
|
22
|
-
* @license lucide-react v0.515.0 - ISC
|
|
23
|
-
*
|
|
24
|
-
* This source code is licensed under the ISC license.
|
|
25
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const ef=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],ga=_e("external-link",ef);/**
|
|
27
|
-
* @license lucide-react v0.515.0 - ISC
|
|
28
|
-
*
|
|
29
|
-
* This source code is licensed under the ISC license.
|
|
30
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const tf=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Dc=_e("eye",tf);/**
|
|
32
|
-
* @license lucide-react v0.515.0 - ISC
|
|
33
|
-
*
|
|
34
|
-
* This source code is licensed under the ISC license.
|
|
35
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const rf=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],nf=_e("eye-off",rf);/**
|
|
37
|
-
* @license lucide-react v0.515.0 - ISC
|
|
38
|
-
*
|
|
39
|
-
* This source code is licensed under the ISC license.
|
|
40
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/const sf=[["path",{d:"m18 5-2.414-2.414A2 2 0 0 0 14.172 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2",key:"142zxg"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}],["path",{d:"M8 18h1",key:"13wk12"}]],of=_e("file-pen-line",sf);/**
|
|
42
|
-
* @license lucide-react v0.515.0 - ISC
|
|
43
|
-
*
|
|
44
|
-
* This source code is licensed under the ISC license.
|
|
45
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/const af=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]],lf=_e("file-plus-2",af);/**
|
|
47
|
-
* @license lucide-react v0.515.0 - ISC
|
|
48
|
-
*
|
|
49
|
-
* This source code is licensed under the ISC license.
|
|
50
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
-
*/const cf=[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4.268 21a2 2 0 0 0 1.727 1H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"ms7g94"}],["path",{d:"m9 18-1.5-1.5",key:"1j6qii"}],["circle",{cx:"5",cy:"14",r:"3",key:"ufru5t"}]],df=_e("file-search",cf);/**
|
|
52
|
-
* @license lucide-react v0.515.0 - ISC
|
|
53
|
-
*
|
|
54
|
-
* This source code is licensed under the ISC license.
|
|
55
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
-
*/const uf=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Ya=_e("file-text",uf);/**
|
|
57
|
-
* @license lucide-react v0.515.0 - ISC
|
|
58
|
-
*
|
|
59
|
-
* This source code is licensed under the ISC license.
|
|
60
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
-
*/const pf=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],rn=_e("folder-open",pf);/**
|
|
62
|
-
* @license lucide-react v0.515.0 - ISC
|
|
63
|
-
*
|
|
64
|
-
* This source code is licensed under the ISC license.
|
|
65
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
-
*/const mf=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],tn=_e("folder-plus",mf);/**
|
|
67
|
-
* @license lucide-react v0.515.0 - ISC
|
|
68
|
-
*
|
|
69
|
-
* This source code is licensed under the ISC license.
|
|
70
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
-
*/const ff=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Go=_e("folder",ff);/**
|
|
72
|
-
* @license lucide-react v0.515.0 - ISC
|
|
73
|
-
*
|
|
74
|
-
* This source code is licensed under the ISC license.
|
|
75
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
76
|
-
*/const hf=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],Jo=_e("git-branch",hf);/**
|
|
77
|
-
* @license lucide-react v0.515.0 - ISC
|
|
78
|
-
*
|
|
79
|
-
* This source code is licensed under the ISC license.
|
|
80
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
81
|
-
*/const gf=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]],Yo=_e("git-commit-horizontal",gf);/**
|
|
82
|
-
* @license lucide-react v0.515.0 - ISC
|
|
83
|
-
*
|
|
84
|
-
* This source code is licensed under the ISC license.
|
|
85
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
86
|
-
*/const xf=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],ol=_e("globe",xf);/**
|
|
87
|
-
* @license lucide-react v0.515.0 - ISC
|
|
88
|
-
*
|
|
89
|
-
* This source code is licensed under the ISC license.
|
|
90
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
91
|
-
*/const vf=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],yf=_e("grip-vertical",vf);/**
|
|
92
|
-
* @license lucide-react v0.515.0 - ISC
|
|
93
|
-
*
|
|
94
|
-
* This source code is licensed under the ISC license.
|
|
95
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
96
|
-
*/const bf=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],al=_e("history",bf);/**
|
|
97
|
-
* @license lucide-react v0.515.0 - ISC
|
|
98
|
-
*
|
|
99
|
-
* This source code is licensed under the ISC license.
|
|
100
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
101
|
-
*/const wf=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],kf=_e("info",wf);/**
|
|
102
|
-
* @license lucide-react v0.515.0 - ISC
|
|
103
|
-
*
|
|
104
|
-
* This source code is licensed under the ISC license.
|
|
105
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
106
|
-
*/const jf=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],Rc=_e("key",jf);/**
|
|
107
|
-
* @license lucide-react v0.515.0 - ISC
|
|
108
|
-
*
|
|
109
|
-
* This source code is licensed under the ISC license.
|
|
110
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
111
|
-
*/const Sf=[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]],Pc=_e("languages",Sf);/**
|
|
112
|
-
* @license lucide-react v0.515.0 - ISC
|
|
113
|
-
*
|
|
114
|
-
* This source code is licensed under the ISC license.
|
|
115
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
116
|
-
*/const Nf=[["rect",{x:"3",y:"5",width:"6",height:"6",rx:"1",key:"1defrl"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]],il=_e("list-todo",Nf);/**
|
|
117
|
-
* @license lucide-react v0.515.0 - ISC
|
|
118
|
-
*
|
|
119
|
-
* This source code is licensed under the ISC license.
|
|
120
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
121
|
-
*/const Cf=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],Lc=_e("maximize-2",Cf);/**
|
|
122
|
-
* @license lucide-react v0.515.0 - ISC
|
|
123
|
-
*
|
|
124
|
-
* This source code is licensed under the ISC license.
|
|
125
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
126
|
-
*/const Ef=[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]],If=_e("message-square-plus",Ef);/**
|
|
127
|
-
* @license lucide-react v0.515.0 - ISC
|
|
128
|
-
*
|
|
129
|
-
* This source code is licensed under the ISC license.
|
|
130
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
131
|
-
*/const Af=[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]],Tf=_e("message-square",Af);/**
|
|
132
|
-
* @license lucide-react v0.515.0 - ISC
|
|
133
|
-
*
|
|
134
|
-
* This source code is licensed under the ISC license.
|
|
135
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
136
|
-
*/const _f=[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]],Ps=_e("mic",_f);/**
|
|
137
|
-
* @license lucide-react v0.515.0 - ISC
|
|
138
|
-
*
|
|
139
|
-
* This source code is licensed under the ISC license.
|
|
140
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
141
|
-
*/const Mf=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],Df=_e("minimize-2",Mf);/**
|
|
142
|
-
* @license lucide-react v0.515.0 - ISC
|
|
143
|
-
*
|
|
144
|
-
* This source code is licensed under the ISC license.
|
|
145
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
146
|
-
*/const Rf=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],xa=_e("moon",Rf);/**
|
|
147
|
-
* @license lucide-react v0.515.0 - ISC
|
|
148
|
-
*
|
|
149
|
-
* This source code is licensed under the ISC license.
|
|
150
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
151
|
-
*/const Pf=[["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"}]],ll=_e("pen-line",Pf);/**
|
|
152
|
-
* @license lucide-react v0.515.0 - ISC
|
|
153
|
-
*
|
|
154
|
-
* This source code is licensed under the ISC license.
|
|
155
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
156
|
-
*/const Lf=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],cl=_e("pen",Lf);/**
|
|
157
|
-
* @license lucide-react v0.515.0 - ISC
|
|
158
|
-
*
|
|
159
|
-
* This source code is licensed under the ISC license.
|
|
160
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
161
|
-
*/const Of=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],jn=_e("plus",Of);/**
|
|
162
|
-
* @license lucide-react v0.515.0 - ISC
|
|
163
|
-
*
|
|
164
|
-
* This source code is licensed under the ISC license.
|
|
165
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
166
|
-
*/const Ff=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Ir=_e("refresh-cw",Ff);/**
|
|
167
|
-
* @license lucide-react v0.515.0 - ISC
|
|
168
|
-
*
|
|
169
|
-
* This source code is licensed under the ISC license.
|
|
170
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
171
|
-
*/const $f=[["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"}]],Bf=_e("save",$f);/**
|
|
172
|
-
* @license lucide-react v0.515.0 - ISC
|
|
173
|
-
*
|
|
174
|
-
* This source code is licensed under the ISC license.
|
|
175
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
176
|
-
*/const zf=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],va=_e("search",zf);/**
|
|
177
|
-
* @license lucide-react v0.515.0 - ISC
|
|
178
|
-
*
|
|
179
|
-
* This source code is licensed under the ISC license.
|
|
180
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
181
|
-
*/const Uf=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],Wf=_e("server",Uf);/**
|
|
182
|
-
* @license lucide-react v0.515.0 - ISC
|
|
183
|
-
*
|
|
184
|
-
* This source code is licensed under the ISC license.
|
|
185
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
186
|
-
*/const Hf=[["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"}]],Oc=_e("settings",Hf);/**
|
|
187
|
-
* @license lucide-react v0.515.0 - ISC
|
|
188
|
-
*
|
|
189
|
-
* This source code is licensed under the ISC license.
|
|
190
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
191
|
-
*/const qf=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Vf=_e("settings-2",qf);/**
|
|
192
|
-
* @license lucide-react v0.515.0 - ISC
|
|
193
|
-
*
|
|
194
|
-
* This source code is licensed under the ISC license.
|
|
195
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
196
|
-
*/const Kf=[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],Gf=_e("square-terminal",Kf);/**
|
|
197
|
-
* @license lucide-react v0.515.0 - ISC
|
|
198
|
-
*
|
|
199
|
-
* This source code is licensed under the ISC license.
|
|
200
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
201
|
-
*/const Jf=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],dl=_e("star",Jf);/**
|
|
202
|
-
* @license lucide-react v0.515.0 - ISC
|
|
203
|
-
*
|
|
204
|
-
* This source code is licensed under the ISC license.
|
|
205
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
206
|
-
*/const Yf=[["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"}]],ya=_e("sun",Yf);/**
|
|
207
|
-
* @license lucide-react v0.515.0 - ISC
|
|
208
|
-
*
|
|
209
|
-
* This source code is licensed under the ISC license.
|
|
210
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
211
|
-
*/const Xf=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],dr=_e("trash-2",Xf);/**
|
|
212
|
-
* @license lucide-react v0.515.0 - ISC
|
|
213
|
-
*
|
|
214
|
-
* This source code is licensed under the ISC license.
|
|
215
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
216
|
-
*/const Qf=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],ba=_e("triangle-alert",Qf);/**
|
|
217
|
-
* @license lucide-react v0.515.0 - ISC
|
|
218
|
-
*
|
|
219
|
-
* This source code is licensed under the ISC license.
|
|
220
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
221
|
-
*/const Zf=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],xs=_e("upload",Zf);/**
|
|
222
|
-
* @license lucide-react v0.515.0 - ISC
|
|
223
|
-
*
|
|
224
|
-
* This source code is licensed under the ISC license.
|
|
225
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
226
|
-
*/const eh=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]],th=_e("wrench",eh);/**
|
|
227
|
-
* @license lucide-react v0.515.0 - ISC
|
|
228
|
-
*
|
|
229
|
-
* This source code is licensed under the ISC license.
|
|
230
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
231
|
-
*/const rh=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],sr=_e("x",rh);function nh(e,t){return l.useReducer((n,s)=>t[n][s]??n,e)}var wr=e=>{const{present:t,children:n}=e,s=sh(t),o=typeof n=="function"?n({present:s.isPresent}):l.Children.only(n),a=Xt(s.ref,oh(o));return typeof n=="function"||s.isPresent?l.cloneElement(o,{ref:a}):null};wr.displayName="Presence";function sh(e){const[t,n]=l.useState(),s=l.useRef(null),o=l.useRef(e),a=l.useRef("none"),i=e?"mounted":"unmounted",[c,d]=nh(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return l.useEffect(()=>{const u=vs(s.current);a.current=c==="mounted"?u:"none"},[c]),fa(()=>{const u=s.current,p=o.current;if(p!==e){const h=a.current,g=vs(u);e?d("MOUNT"):g==="none"||u?.display==="none"?d("UNMOUNT"):d(p&&h!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,d]),fa(()=>{if(t){let u;const p=t.ownerDocument.defaultView??window,m=g=>{const S=vs(s.current).includes(CSS.escape(g.animationName));if(g.target===t&&S&&(d("ANIMATION_END"),!o.current)){const k=t.style.animationFillMode;t.style.animationFillMode="forwards",u=p.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=k)})}},h=g=>{g.target===t&&(a.current=vs(s.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",m),t.addEventListener("animationend",m),()=>{p.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",m),t.removeEventListener("animationend",m)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:l.useCallback(u=>{s.current=u?getComputedStyle(u):null,n(u)},[])}}function vs(e){return e?.animationName||"none"}function oh(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function ah(e,t=[]){let n=[];function s(a,i){const c=l.createContext(i),d=n.length;n=[...n,i];const u=m=>{const{scope:h,children:g,...x}=m,S=h?.[e]?.[d]||c,k=l.useMemo(()=>x,Object.values(x));return r.jsx(S.Provider,{value:k,children:g})};u.displayName=a+"Provider";function p(m,h){const g=h?.[e]?.[d]||c,x=l.useContext(g);if(x)return x;if(i!==void 0)return i;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[u,p]}const o=()=>{const a=n.map(i=>l.createContext(i));return function(c){const d=c?.[e]||a;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[s,ih(o,...t)]}function ih(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const i=s.reduce((c,{useScope:d,scopeName:u})=>{const m=d(a)[`__scope${u}`];return{...c,...m}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function Fc(e){const t=lh(e),n=l.forwardRef((s,o)=>{const{children:a,...i}=s,c=l.Children.toArray(a),d=c.find(dh);if(d){const u=d.props.children,p=c.map(m=>m===d?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:m);return r.jsx(t,{...i,ref:o,children:l.isValidElement(u)?l.cloneElement(u,void 0,p):null})}return r.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function lh(e){const t=l.forwardRef((n,s)=>{const{children:o,...a}=n;if(l.isValidElement(o)){const i=ph(o),c=uh(a,o.props);return o.type!==l.Fragment&&(c.ref=s?on(s,i):i),l.cloneElement(o,c)}return l.Children.count(o)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var ch=Symbol("radix.slottable");function dh(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===ch}function uh(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...c)=>{const d=a(...c);return o(...c),d}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function ph(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var mh=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Kn=mh.reduce((e,t)=>{const n=Fc(`Primitive.${t}`),s=l.forwardRef((o,a)=>{const{asChild:i,...c}=o,d=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{});function fh(e,t){e&&im.flushSync(()=>e.dispatchEvent(t))}function hh(e,t=[]){let n=[];function s(a,i){const c=l.createContext(i),d=n.length;n=[...n,i];const u=m=>{const{scope:h,children:g,...x}=m,S=h?.[e]?.[d]||c,k=l.useMemo(()=>x,Object.values(x));return r.jsx(S.Provider,{value:k,children:g})};u.displayName=a+"Provider";function p(m,h){const g=h?.[e]?.[d]||c,x=l.useContext(g);if(x)return x;if(i!==void 0)return i;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[u,p]}const o=()=>{const a=n.map(i=>l.createContext(i));return function(c){const d=c?.[e]||a;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[s,gh(o,...t)]}function gh(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const i=s.reduce((c,{useScope:d,scopeName:u})=>{const m=d(a)[`__scope${u}`];return{...c,...m}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function xh(e){const t=vh(e),n=l.forwardRef((s,o)=>{const{children:a,...i}=s,c=l.Children.toArray(a),d=c.find(bh);if(d){const u=d.props.children,p=c.map(m=>m===d?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:m);return r.jsx(t,{...i,ref:o,children:l.isValidElement(u)?l.cloneElement(u,void 0,p):null})}return r.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function vh(e){const t=l.forwardRef((n,s)=>{const{children:o,...a}=n;if(l.isValidElement(o)){const i=kh(o),c=wh(a,o.props);return o.type!==l.Fragment&&(c.ref=s?on(s,i):i),l.cloneElement(o,c)}return l.Children.count(o)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var yh=Symbol("radix.slottable");function bh(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===yh}function wh(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...c)=>{const d=a(...c);return o(...c),d}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function kh(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var jh=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],$c=jh.reduce((e,t)=>{const n=xh(`Primitive.${t}`),s=l.forwardRef((o,a)=>{const{asChild:i,...c}=o,d=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),Xo="rovingFocusGroup.onEntryFocus",Sh={bubbles:!1,cancelable:!0},Gn="RovingFocusGroup",[wa,Bc,Nh]=Ic(Gn),[Ch,Qs]=hh(Gn,[Nh]),[Eh,Ih]=Ch(Gn),zc=l.forwardRef((e,t)=>r.jsx(wa.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(wa.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Ah,{...e,ref:t})})}));zc.displayName=Gn;var Ah=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:o=!1,dir:a,currentTabStopId:i,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:u,preventScrollOnEntryFocus:p=!1,...m}=e,h=l.useRef(null),g=Xt(t,h),x=Xs(a),[S,k]=Va({prop:i,defaultProp:c??null,onChange:d,caller:Gn}),[I,A]=l.useState(!1),w=xr(u),M=Bc(n),C=l.useRef(!1),[b,R]=l.useState(0);return l.useEffect(()=>{const B=h.current;if(B)return B.addEventListener(Xo,w),()=>B.removeEventListener(Xo,w)},[w]),r.jsx(Eh,{scope:n,orientation:s,dir:x,loop:o,currentTabStopId:S,onItemFocus:l.useCallback(B=>k(B),[k]),onItemShiftTab:l.useCallback(()=>A(!0),[]),onFocusableItemAdd:l.useCallback(()=>R(B=>B+1),[]),onFocusableItemRemove:l.useCallback(()=>R(B=>B-1),[]),children:r.jsx($c.div,{tabIndex:I||b===0?-1:0,"data-orientation":s,...m,ref:g,style:{outline:"none",...e.style},onMouseDown:Le(e.onMouseDown,()=>{C.current=!0}),onFocus:Le(e.onFocus,B=>{const D=!C.current;if(B.target===B.currentTarget&&D&&!I){const Z=new CustomEvent(Xo,Sh);if(B.currentTarget.dispatchEvent(Z),!Z.defaultPrevented){const z=M().filter(Ce=>Ce.focusable),X=z.find(Ce=>Ce.active),q=z.find(Ce=>Ce.id===S),Se=[X,q,...z].filter(Boolean).map(Ce=>Ce.ref.current);Hc(Se,p)}}C.current=!1}),onBlur:Le(e.onBlur,()=>A(!1))})})}),Uc="RovingFocusGroupItem",Wc=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:o=!1,tabStopId:a,children:i,...c}=e,d=Os(),u=a||d,p=Ih(Uc,n),m=p.currentTabStopId===u,h=Bc(n),{onFocusableItemAdd:g,onFocusableItemRemove:x,currentTabStopId:S}=p;return l.useEffect(()=>{if(s)return g(),()=>x()},[s,g,x]),r.jsx(wa.ItemSlot,{scope:n,id:u,focusable:s,active:o,children:r.jsx($c.span,{tabIndex:m?0:-1,"data-orientation":p.orientation,...c,ref:t,onMouseDown:Le(e.onMouseDown,k=>{s?p.onItemFocus(u):k.preventDefault()}),onFocus:Le(e.onFocus,()=>p.onItemFocus(u)),onKeyDown:Le(e.onKeyDown,k=>{if(k.key==="Tab"&&k.shiftKey){p.onItemShiftTab();return}if(k.target!==k.currentTarget)return;const I=Mh(k,p.orientation,p.dir);if(I!==void 0){if(k.metaKey||k.ctrlKey||k.altKey||k.shiftKey)return;k.preventDefault();let w=h().filter(M=>M.focusable).map(M=>M.ref.current);if(I==="last")w.reverse();else if(I==="prev"||I==="next"){I==="prev"&&w.reverse();const M=w.indexOf(k.currentTarget);w=p.loop?Dh(w,M+1):w.slice(M+1)}setTimeout(()=>Hc(w))}}),children:typeof i=="function"?i({isCurrentTabStop:m,hasTabStop:S!=null}):i})})});Wc.displayName=Uc;var Th={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function _h(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Mh(e,t,n){const s=_h(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return Th[s]}function Hc(e,t=!1){const n=document.activeElement;for(const s of e)if(s===n||(s.focus({preventScroll:t}),document.activeElement!==n))return}function Dh(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var qc=zc,Vc=Wc,ka=["Enter"," "],Rh=["ArrowDown","PageUp","Home"],Kc=["ArrowUp","PageDown","End"],Ph=[...Rh,...Kc],Lh={ltr:[...ka,"ArrowRight"],rtl:[...ka,"ArrowLeft"]},Oh={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Jn="Menu",[Wn,Fh,$h]=Ic(Jn),[ln,Gc]=ah(Jn,[$h,Ac,Qs]),Zs=Ac(),Jc=Qs(),[Bh,cn]=ln(Jn),[zh,Yn]=ln(Jn),Yc=e=>{const{__scopeMenu:t,open:n=!1,children:s,dir:o,onOpenChange:a,modal:i=!0}=e,c=Zs(t),[d,u]=l.useState(null),p=l.useRef(!1),m=xr(a),h=Xs(o);return l.useEffect(()=>{const g=()=>{p.current=!0,document.addEventListener("pointerdown",x,{capture:!0,once:!0}),document.addEventListener("pointermove",x,{capture:!0,once:!0})},x=()=>p.current=!1;return document.addEventListener("keydown",g,{capture:!0}),()=>{document.removeEventListener("keydown",g,{capture:!0}),document.removeEventListener("pointerdown",x,{capture:!0}),document.removeEventListener("pointermove",x,{capture:!0})}},[]),r.jsx(mm,{...c,children:r.jsx(Bh,{scope:t,open:n,onOpenChange:m,content:d,onContentChange:u,children:r.jsx(zh,{scope:t,onClose:l.useCallback(()=>m(!1),[m]),isUsingKeyboardRef:p,dir:h,modal:i,children:s})})})};Yc.displayName=Jn;var Uh="MenuAnchor",Xa=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e,o=Zs(n);return r.jsx(fm,{...o,...s,ref:t})});Xa.displayName=Uh;var Qa="MenuPortal",[Wh,Xc]=ln(Qa,{forceMount:void 0}),Qc=e=>{const{__scopeMenu:t,forceMount:n,children:s,container:o}=e,a=cn(Qa,t);return r.jsx(Wh,{scope:t,forceMount:n,children:r.jsx(wr,{present:n||a.open,children:r.jsx(hm,{asChild:!0,container:o,children:s})})})};Qc.displayName=Qa;var or="MenuContent",[Hh,Za]=ln(or),Zc=l.forwardRef((e,t)=>{const n=Xc(or,e.__scopeMenu),{forceMount:s=n.forceMount,...o}=e,a=cn(or,e.__scopeMenu),i=Yn(or,e.__scopeMenu);return r.jsx(Wn.Provider,{scope:e.__scopeMenu,children:r.jsx(wr,{present:s||a.open,children:r.jsx(Wn.Slot,{scope:e.__scopeMenu,children:i.modal?r.jsx(qh,{...o,ref:t}):r.jsx(Vh,{...o,ref:t})})})})}),qh=l.forwardRef((e,t)=>{const n=cn(or,e.__scopeMenu),s=l.useRef(null),o=Xt(t,s);return l.useEffect(()=>{const a=s.current;if(a)return gm(a)},[]),r.jsx(ei,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Le(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Vh=l.forwardRef((e,t)=>{const n=cn(or,e.__scopeMenu);return r.jsx(ei,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Kh=Fc("MenuContent.ScrollLock"),ei=l.forwardRef((e,t)=>{const{__scopeMenu:n,loop:s=!1,trapFocus:o,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:c,onEntryFocus:d,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:m,onInteractOutside:h,onDismiss:g,disableOutsideScroll:x,...S}=e,k=cn(or,n),I=Yn(or,n),A=Zs(n),w=Jc(n),M=Fh(n),[C,b]=l.useState(null),R=l.useRef(null),B=Xt(t,R,k.onContentChange),D=l.useRef(0),Z=l.useRef(""),z=l.useRef(0),X=l.useRef(null),q=l.useRef("right"),re=l.useRef(0),Se=x?vm:l.Fragment,Ce=x?{as:Kh,allowPinchZoom:!0}:void 0,ye=H=>{const Oe=Z.current+H,$=M().filter(P=>!P.disabled),N=document.activeElement,O=$.find(P=>P.ref.current===N)?.textValue,ne=$.map(P=>P.textValue),ke=og(ne,Oe,O),ge=$.find(P=>P.textValue===ke)?.ref.current;(function P(ie){Z.current=ie,window.clearTimeout(D.current),ie!==""&&(D.current=window.setTimeout(()=>P(""),1e3))})(Oe),ge&&setTimeout(()=>ge.focus())};l.useEffect(()=>()=>window.clearTimeout(D.current),[]),xm();const de=l.useCallback(H=>q.current===X.current?.side&&ig(H,X.current?.area),[]);return r.jsx(Hh,{scope:n,searchRef:Z,onItemEnter:l.useCallback(H=>{de(H)&&H.preventDefault()},[de]),onItemLeave:l.useCallback(H=>{de(H)||(R.current?.focus(),b(null))},[de]),onTriggerLeave:l.useCallback(H=>{de(H)&&H.preventDefault()},[de]),pointerGraceTimerRef:z,onPointerGraceIntentChange:l.useCallback(H=>{X.current=H},[]),children:r.jsx(Se,{...Ce,children:r.jsx(ym,{asChild:!0,trapped:o,onMountAutoFocus:Le(a,H=>{H.preventDefault(),R.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:r.jsx(bm,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:m,onInteractOutside:h,onDismiss:g,children:r.jsx(qc,{asChild:!0,...w,dir:I.dir,orientation:"vertical",loop:s,currentTabStopId:C,onCurrentTabStopIdChange:b,onEntryFocus:Le(d,H=>{I.isUsingKeyboardRef.current||H.preventDefault()}),preventScrollOnEntryFocus:!0,children:r.jsx(wm,{role:"menu","aria-orientation":"vertical","data-state":hd(k.open),"data-radix-menu-content":"",dir:I.dir,...A,...S,ref:B,style:{outline:"none",...S.style},onKeyDown:Le(S.onKeyDown,H=>{const $=H.target.closest("[data-radix-menu-content]")===H.currentTarget,N=H.ctrlKey||H.altKey||H.metaKey,O=H.key.length===1;$&&(H.key==="Tab"&&H.preventDefault(),!N&&O&&ye(H.key));const ne=R.current;if(H.target!==ne||!Ph.includes(H.key))return;H.preventDefault();const ge=M().filter(P=>!P.disabled).map(P=>P.ref.current);Kc.includes(H.key)&&ge.reverse(),ng(ge)}),onBlur:Le(e.onBlur,H=>{H.currentTarget.contains(H.target)||(window.clearTimeout(D.current),Z.current="")}),onPointerMove:Le(e.onPointerMove,Hn(H=>{const Oe=H.target,$=re.current!==H.clientX;if(H.currentTarget.contains(Oe)&&$){const N=H.clientX>re.current?"right":"left";q.current=N,re.current=H.clientX}}))})})})})})})});Zc.displayName=or;var Gh="MenuGroup",ti=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return r.jsx(Kn.div,{role:"group",...s,ref:t})});ti.displayName=Gh;var Jh="MenuLabel",ed=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return r.jsx(Kn.div,{...s,ref:t})});ed.displayName=Jh;var Fs="MenuItem",ul="menu.itemSelect",eo=l.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:s,...o}=e,a=l.useRef(null),i=Yn(Fs,e.__scopeMenu),c=Za(Fs,e.__scopeMenu),d=Xt(t,a),u=l.useRef(!1),p=()=>{const m=a.current;if(!n&&m){const h=new CustomEvent(ul,{bubbles:!0,cancelable:!0});m.addEventListener(ul,g=>s?.(g),{once:!0}),fh(m,h),h.defaultPrevented?u.current=!1:i.onClose()}};return r.jsx(td,{...o,ref:d,disabled:n,onClick:Le(e.onClick,p),onPointerDown:m=>{e.onPointerDown?.(m),u.current=!0},onPointerUp:Le(e.onPointerUp,m=>{u.current||m.currentTarget?.click()}),onKeyDown:Le(e.onKeyDown,m=>{const h=c.searchRef.current!=="";n||h&&m.key===" "||ka.includes(m.key)&&(m.currentTarget.click(),m.preventDefault())})})});eo.displayName=Fs;var td=l.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:s=!1,textValue:o,...a}=e,i=Za(Fs,n),c=Jc(n),d=l.useRef(null),u=Xt(t,d),[p,m]=l.useState(!1),[h,g]=l.useState("");return l.useEffect(()=>{const x=d.current;x&&g((x.textContent??"").trim())},[a.children]),r.jsx(Wn.ItemSlot,{scope:n,disabled:s,textValue:o??h,children:r.jsx(Vc,{asChild:!0,...c,focusable:!s,children:r.jsx(Kn.div,{role:"menuitem","data-highlighted":p?"":void 0,"aria-disabled":s||void 0,"data-disabled":s?"":void 0,...a,ref:u,onPointerMove:Le(e.onPointerMove,Hn(x=>{s?i.onItemLeave(x):(i.onItemEnter(x),x.defaultPrevented||x.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Le(e.onPointerLeave,Hn(x=>i.onItemLeave(x))),onFocus:Le(e.onFocus,()=>m(!0)),onBlur:Le(e.onBlur,()=>m(!1))})})})}),Yh="MenuCheckboxItem",rd=l.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:s,...o}=e;return r.jsx(id,{scope:e.__scopeMenu,checked:n,children:r.jsx(eo,{role:"menuitemcheckbox","aria-checked":$s(n)?"mixed":n,...o,ref:t,"data-state":ni(n),onSelect:Le(o.onSelect,()=>s?.($s(n)?!0:!n),{checkForDefaultPrevented:!1})})})});rd.displayName=Yh;var nd="MenuRadioGroup",[Xh,Qh]=ln(nd,{value:void 0,onValueChange:()=>{}}),sd=l.forwardRef((e,t)=>{const{value:n,onValueChange:s,...o}=e,a=xr(s);return r.jsx(Xh,{scope:e.__scopeMenu,value:n,onValueChange:a,children:r.jsx(ti,{...o,ref:t})})});sd.displayName=nd;var od="MenuRadioItem",ad=l.forwardRef((e,t)=>{const{value:n,...s}=e,o=Qh(od,e.__scopeMenu),a=n===o.value;return r.jsx(id,{scope:e.__scopeMenu,checked:a,children:r.jsx(eo,{role:"menuitemradio","aria-checked":a,...s,ref:t,"data-state":ni(a),onSelect:Le(s.onSelect,()=>o.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});ad.displayName=od;var ri="MenuItemIndicator",[id,Zh]=ln(ri,{checked:!1}),ld=l.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:s,...o}=e,a=Zh(ri,n);return r.jsx(wr,{present:s||$s(a.checked)||a.checked===!0,children:r.jsx(Kn.span,{...o,ref:t,"data-state":ni(a.checked)})})});ld.displayName=ri;var eg="MenuSeparator",cd=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return r.jsx(Kn.div,{role:"separator","aria-orientation":"horizontal",...s,ref:t})});cd.displayName=eg;var tg="MenuArrow",dd=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e,o=Zs(n);return r.jsx(km,{...o,...s,ref:t})});dd.displayName=tg;var rg="MenuSub",[gw,ud]=ln(rg),Fn="MenuSubTrigger",pd=l.forwardRef((e,t)=>{const n=cn(Fn,e.__scopeMenu),s=Yn(Fn,e.__scopeMenu),o=ud(Fn,e.__scopeMenu),a=Za(Fn,e.__scopeMenu),i=l.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:d}=a,u={__scopeMenu:e.__scopeMenu},p=l.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return l.useEffect(()=>p,[p]),l.useEffect(()=>{const m=c.current;return()=>{window.clearTimeout(m),d(null)}},[c,d]),r.jsx(Xa,{asChild:!0,...u,children:r.jsx(td,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":hd(n.open),...e,ref:on(t,o.onTriggerChange),onClick:m=>{e.onClick?.(m),!(e.disabled||m.defaultPrevented)&&(m.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Le(e.onPointerMove,Hn(m=>{a.onItemEnter(m),!m.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(a.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),p()},100))})),onPointerLeave:Le(e.onPointerLeave,Hn(m=>{p();const h=n.content?.getBoundingClientRect();if(h){const g=n.content?.dataset.side,x=g==="right",S=x?-5:5,k=h[x?"left":"right"],I=h[x?"right":"left"];a.onPointerGraceIntentChange({area:[{x:m.clientX+S,y:m.clientY},{x:k,y:h.top},{x:I,y:h.top},{x:I,y:h.bottom},{x:k,y:h.bottom}],side:g}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(m),m.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:Le(e.onKeyDown,m=>{const h=a.searchRef.current!=="";e.disabled||h&&m.key===" "||Lh[s.dir].includes(m.key)&&(n.onOpenChange(!0),n.content?.focus(),m.preventDefault())})})})});pd.displayName=Fn;var md="MenuSubContent",fd=l.forwardRef((e,t)=>{const n=Xc(or,e.__scopeMenu),{forceMount:s=n.forceMount,...o}=e,a=cn(or,e.__scopeMenu),i=Yn(or,e.__scopeMenu),c=ud(md,e.__scopeMenu),d=l.useRef(null),u=Xt(t,d);return r.jsx(Wn.Provider,{scope:e.__scopeMenu,children:r.jsx(wr,{present:s||a.open,children:r.jsx(Wn.Slot,{scope:e.__scopeMenu,children:r.jsx(ei,{id:c.contentId,"aria-labelledby":c.triggerId,...o,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:p=>{i.isUsingKeyboardRef.current&&d.current?.focus(),p.preventDefault()},onCloseAutoFocus:p=>p.preventDefault(),onFocusOutside:Le(e.onFocusOutside,p=>{p.target!==c.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:Le(e.onEscapeKeyDown,p=>{i.onClose(),p.preventDefault()}),onKeyDown:Le(e.onKeyDown,p=>{const m=p.currentTarget.contains(p.target),h=Oh[i.dir].includes(p.key);m&&h&&(a.onOpenChange(!1),c.trigger?.focus(),p.preventDefault())})})})})})});fd.displayName=md;function hd(e){return e?"open":"closed"}function $s(e){return e==="indeterminate"}function ni(e){return $s(e)?"indeterminate":e?"checked":"unchecked"}function ng(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function sg(e,t){return e.map((n,s)=>e[(t+s)%e.length])}function og(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let i=sg(e,Math.max(a,0));o.length===1&&(i=i.filter(u=>u!==n));const d=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return d!==n?d:void 0}function ag(e,t){const{x:n,y:s}=e;let o=!1;for(let a=0,i=t.length-1;a<t.length;i=a++){const c=t[a],d=t[i],u=c.x,p=c.y,m=d.x,h=d.y;p>s!=h>s&&n<(m-u)*(s-p)/(h-p)+u&&(o=!o)}return o}function ig(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return ag(n,t)}function Hn(e){return t=>t.pointerType==="mouse"?e(t):void 0}var lg=Yc,cg=Xa,dg=Qc,ug=Zc,pg=ti,mg=ed,fg=eo,hg=rd,gg=sd,xg=ad,vg=ld,yg=cd,bg=dd,wg=pd,kg=fd;function jg(e,t=[]){let n=[];function s(a,i){const c=l.createContext(i),d=n.length;n=[...n,i];const u=m=>{const{scope:h,children:g,...x}=m,S=h?.[e]?.[d]||c,k=l.useMemo(()=>x,Object.values(x));return r.jsx(S.Provider,{value:k,children:g})};u.displayName=a+"Provider";function p(m,h){const g=h?.[e]?.[d]||c,x=l.useContext(g);if(x)return x;if(i!==void 0)return i;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[u,p]}const o=()=>{const a=n.map(i=>l.createContext(i));return function(c){const d=c?.[e]||a;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[s,Sg(o,...t)]}function Sg(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const i=s.reduce((c,{useScope:d,scopeName:u})=>{const m=d(a)[`__scope${u}`];return{...c,...m}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function Ng(e){const t=Cg(e),n=l.forwardRef((s,o)=>{const{children:a,...i}=s,c=l.Children.toArray(a),d=c.find(Ig);if(d){const u=d.props.children,p=c.map(m=>m===d?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:m);return r.jsx(t,{...i,ref:o,children:l.isValidElement(u)?l.cloneElement(u,void 0,p):null})}return r.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function Cg(e){const t=l.forwardRef((n,s)=>{const{children:o,...a}=n;if(l.isValidElement(o)){const i=Tg(o),c=Ag(a,o.props);return o.type!==l.Fragment&&(c.ref=s?on(s,i):i),l.cloneElement(o,c)}return l.Children.count(o)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Eg=Symbol("radix.slottable");function Ig(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Eg}function Ag(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...c)=>{const d=a(...c);return o(...c),d}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function Tg(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var _g=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Mg=_g.reduce((e,t)=>{const n=Ng(`Primitive.${t}`),s=l.forwardRef((o,a)=>{const{asChild:i,...c}=o,d=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),to="DropdownMenu",[Dg,xw]=jg(to,[Gc]),Wt=Gc(),[Rg,gd]=Dg(to),xd=e=>{const{__scopeDropdownMenu:t,children:n,dir:s,open:o,defaultOpen:a,onOpenChange:i,modal:c=!0}=e,d=Wt(t),u=l.useRef(null),[p,m]=Va({prop:o,defaultProp:a??!1,onChange:i,caller:to});return r.jsx(Rg,{scope:t,triggerId:Os(),triggerRef:u,contentId:Os(),open:p,onOpenChange:m,onOpenToggle:l.useCallback(()=>m(h=>!h),[m]),modal:c,children:r.jsx(lg,{...d,open:p,onOpenChange:m,dir:s,modal:c,children:n})})};xd.displayName=to;var vd="DropdownMenuTrigger",yd=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:s=!1,...o}=e,a=gd(vd,n),i=Wt(n);return r.jsx(cg,{asChild:!0,...i,children:r.jsx(Mg.button,{type:"button",id:a.triggerId,"aria-haspopup":"menu","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?"open":"closed","data-disabled":s?"":void 0,disabled:s,...o,ref:on(t,a.triggerRef),onPointerDown:Le(e.onPointerDown,c=>{!s&&c.button===0&&c.ctrlKey===!1&&(a.onOpenToggle(),a.open||c.preventDefault())}),onKeyDown:Le(e.onKeyDown,c=>{s||(["Enter"," "].includes(c.key)&&a.onOpenToggle(),c.key==="ArrowDown"&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});yd.displayName=vd;var Pg="DropdownMenuPortal",bd=e=>{const{__scopeDropdownMenu:t,...n}=e,s=Wt(t);return r.jsx(dg,{...s,...n})};bd.displayName=Pg;var wd="DropdownMenuContent",kd=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=gd(wd,n),a=Wt(n),i=l.useRef(!1);return r.jsx(ug,{id:o.contentId,"aria-labelledby":o.triggerId,...a,...s,ref:t,onCloseAutoFocus:Le(e.onCloseAutoFocus,c=>{i.current||o.triggerRef.current?.focus(),i.current=!1,c.preventDefault()}),onInteractOutside:Le(e.onInteractOutside,c=>{const d=c.detail.originalEvent,u=d.button===0&&d.ctrlKey===!0,p=d.button===2||u;(!o.modal||p)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});kd.displayName=wd;var Lg="DropdownMenuGroup",Og=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Wt(n);return r.jsx(pg,{...o,...s,ref:t})});Og.displayName=Lg;var Fg="DropdownMenuLabel",$g=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Wt(n);return r.jsx(mg,{...o,...s,ref:t})});$g.displayName=Fg;var Bg="DropdownMenuItem",jd=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Wt(n);return r.jsx(fg,{...o,...s,ref:t})});jd.displayName=Bg;var zg="DropdownMenuCheckboxItem",Ug=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Wt(n);return r.jsx(hg,{...o,...s,ref:t})});Ug.displayName=zg;var Wg="DropdownMenuRadioGroup",Hg=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Wt(n);return r.jsx(gg,{...o,...s,ref:t})});Hg.displayName=Wg;var qg="DropdownMenuRadioItem",Vg=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Wt(n);return r.jsx(xg,{...o,...s,ref:t})});Vg.displayName=qg;var Kg="DropdownMenuItemIndicator",Gg=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Wt(n);return r.jsx(vg,{...o,...s,ref:t})});Gg.displayName=Kg;var Jg="DropdownMenuSeparator",Sd=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Wt(n);return r.jsx(yg,{...o,...s,ref:t})});Sd.displayName=Jg;var Yg="DropdownMenuArrow",Xg=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Wt(n);return r.jsx(bg,{...o,...s,ref:t})});Xg.displayName=Yg;var Qg="DropdownMenuSubTrigger",Zg=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Wt(n);return r.jsx(wg,{...o,...s,ref:t})});Zg.displayName=Qg;var ex="DropdownMenuSubContent",tx=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Wt(n);return r.jsx(kg,{...o,...s,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});tx.displayName=ex;var ys=xd,bs=yd,ws=bd,ks=kd,hr=jd,pl=Sd;function rx(e){const t=nx(e),n=l.forwardRef((s,o)=>{const{children:a,...i}=s,c=l.Children.toArray(a),d=c.find(ox);if(d){const u=d.props.children,p=c.map(m=>m===d?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:m);return r.jsx(t,{...i,ref:o,children:l.isValidElement(u)?l.cloneElement(u,void 0,p):null})}return r.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function nx(e){const t=l.forwardRef((n,s)=>{const{children:o,...a}=n;if(l.isValidElement(o)){const i=ix(o),c=ax(a,o.props);return o.type!==l.Fragment&&(c.ref=s?on(s,i):i),l.cloneElement(o,c)}return l.Children.count(o)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var sx=Symbol("radix.slottable");function ox(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===sx}function ax(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...c)=>{const d=a(...c);return o(...c),d}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function ix(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var lx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Xn=lx.reduce((e,t)=>{const n=rx(`Primitive.${t}`),s=l.forwardRef((o,a)=>{const{asChild:i,...c}=o,d=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{});function cx(e,t=[]){let n=[];function s(a,i){const c=l.createContext(i),d=n.length;n=[...n,i];const u=m=>{const{scope:h,children:g,...x}=m,S=h?.[e]?.[d]||c,k=l.useMemo(()=>x,Object.values(x));return r.jsx(S.Provider,{value:k,children:g})};u.displayName=a+"Provider";function p(m,h){const g=h?.[e]?.[d]||c,x=l.useContext(g);if(x)return x;if(i!==void 0)return i;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[u,p]}const o=()=>{const a=n.map(i=>l.createContext(i));return function(c){const d=c?.[e]||a;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[s,dx(o,...t)]}function dx(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const i=s.reduce((c,{useScope:d,scopeName:u})=>{const m=d(a)[`__scope${u}`];return{...c,...m}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function ux(e,t){return l.useReducer((n,s)=>t[n][s]??n,e)}var si="ScrollArea",[Nd,vw]=cx(si),[px,ir]=Nd(si),Cd=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:s="hover",dir:o,scrollHideDelay:a=600,...i}=e,[c,d]=l.useState(null),[u,p]=l.useState(null),[m,h]=l.useState(null),[g,x]=l.useState(null),[S,k]=l.useState(null),[I,A]=l.useState(0),[w,M]=l.useState(0),[C,b]=l.useState(!1),[R,B]=l.useState(!1),D=Xt(t,z=>d(z)),Z=Xs(o);return r.jsx(px,{scope:n,type:s,dir:Z,scrollHideDelay:a,scrollArea:c,viewport:u,onViewportChange:p,content:m,onContentChange:h,scrollbarX:g,onScrollbarXChange:x,scrollbarXEnabled:C,onScrollbarXEnabledChange:b,scrollbarY:S,onScrollbarYChange:k,scrollbarYEnabled:R,onScrollbarYEnabledChange:B,onCornerWidthChange:A,onCornerHeightChange:M,children:r.jsx(Xn.div,{dir:Z,...i,ref:D,style:{position:"relative","--radix-scroll-area-corner-width":I+"px","--radix-scroll-area-corner-height":w+"px",...e.style}})})});Cd.displayName=si;var Ed="ScrollAreaViewport",Id=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:s,nonce:o,...a}=e,i=ir(Ed,n),c=l.useRef(null),d=Xt(t,c,i.onViewportChange);return r.jsxs(r.Fragment,{children:[r.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),r.jsx(Xn.div,{"data-radix-scroll-area-viewport":"",...a,ref:d,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:r.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:s})})]})});Id.displayName=Ed;var kr="ScrollAreaScrollbar",Ad=l.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=ir(kr,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:i}=o,c=e.orientation==="horizontal";return l.useEffect(()=>(c?a(!0):i(!0),()=>{c?a(!1):i(!1)}),[c,a,i]),o.type==="hover"?r.jsx(mx,{...s,ref:t,forceMount:n}):o.type==="scroll"?r.jsx(fx,{...s,ref:t,forceMount:n}):o.type==="auto"?r.jsx(Td,{...s,ref:t,forceMount:n}):o.type==="always"?r.jsx(oi,{...s,ref:t}):null});Ad.displayName=kr;var mx=l.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=ir(kr,e.__scopeScrollArea),[a,i]=l.useState(!1);return l.useEffect(()=>{const c=o.scrollArea;let d=0;if(c){const u=()=>{window.clearTimeout(d),i(!0)},p=()=>{d=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return c.addEventListener("pointerenter",u),c.addEventListener("pointerleave",p),()=>{window.clearTimeout(d),c.removeEventListener("pointerenter",u),c.removeEventListener("pointerleave",p)}}},[o.scrollArea,o.scrollHideDelay]),r.jsx(wr,{present:n||a,children:r.jsx(Td,{"data-state":a?"visible":"hidden",...s,ref:t})})}),fx=l.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=ir(kr,e.__scopeScrollArea),a=e.orientation==="horizontal",i=no(()=>d("SCROLL_END"),100),[c,d]=ux("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return l.useEffect(()=>{if(c==="idle"){const u=window.setTimeout(()=>d("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[c,o.scrollHideDelay,d]),l.useEffect(()=>{const u=o.viewport,p=a?"scrollLeft":"scrollTop";if(u){let m=u[p];const h=()=>{const g=u[p];m!==g&&(d("SCROLL"),i()),m=g};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,a,d,i]),r.jsx(wr,{present:n||c!=="hidden",children:r.jsx(oi,{"data-state":c==="hidden"?"hidden":"visible",...s,ref:t,onPointerEnter:Le(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:Le(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),Td=l.forwardRef((e,t)=>{const n=ir(kr,e.__scopeScrollArea),{forceMount:s,...o}=e,[a,i]=l.useState(!1),c=e.orientation==="horizontal",d=no(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,p=n.viewport.offsetHeight<n.viewport.scrollHeight;i(c?u:p)}},10);return Sn(n.viewport,d),Sn(n.content,d),r.jsx(wr,{present:s||a,children:r.jsx(oi,{"data-state":a?"visible":"hidden",...o,ref:t})})}),oi=l.forwardRef((e,t)=>{const{orientation:n="vertical",...s}=e,o=ir(kr,e.__scopeScrollArea),a=l.useRef(null),i=l.useRef(0),[c,d]=l.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=Pd(c.viewport,c.content),p={...s,sizes:c,onSizesChange:d,hasThumb:u>0&&u<1,onThumbChange:h=>a.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function m(h,g){return bx(h,i.current,c,g)}return n==="horizontal"?r.jsx(hx,{...p,ref:t,onThumbPositionChange:()=>{if(o.viewport&&a.current){const h=o.viewport.scrollLeft,g=ml(h,c,o.dir);a.current.style.transform=`translate3d(${g}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=m(h,o.dir))}}):n==="vertical"?r.jsx(gx,{...p,ref:t,onThumbPositionChange:()=>{if(o.viewport&&a.current){const h=o.viewport.scrollTop,g=ml(h,c);a.current.style.transform=`translate3d(0, ${g}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=m(h))}}):null}),hx=l.forwardRef((e,t)=>{const{sizes:n,onSizesChange:s,...o}=e,a=ir(kr,e.__scopeScrollArea),[i,c]=l.useState(),d=l.useRef(null),u=Xt(t,d,a.onScrollbarXChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),r.jsx(Md,{"data-orientation":"horizontal",...o,ref:u,sizes:n,style:{bottom:0,left:a.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:a.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":ro(n)+"px",...e.style},onThumbPointerDown:p=>e.onThumbPointerDown(p.x),onDragScroll:p=>e.onDragScroll(p.x),onWheelScroll:(p,m)=>{if(a.viewport){const h=a.viewport.scrollLeft+p.deltaX;e.onWheelScroll(h),Od(h,m)&&p.preventDefault()}},onResize:()=>{d.current&&a.viewport&&i&&s({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:zs(i.paddingLeft),paddingEnd:zs(i.paddingRight)}})}})}),gx=l.forwardRef((e,t)=>{const{sizes:n,onSizesChange:s,...o}=e,a=ir(kr,e.__scopeScrollArea),[i,c]=l.useState(),d=l.useRef(null),u=Xt(t,d,a.onScrollbarYChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),r.jsx(Md,{"data-orientation":"vertical",...o,ref:u,sizes:n,style:{top:0,right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":ro(n)+"px",...e.style},onThumbPointerDown:p=>e.onThumbPointerDown(p.y),onDragScroll:p=>e.onDragScroll(p.y),onWheelScroll:(p,m)=>{if(a.viewport){const h=a.viewport.scrollTop+p.deltaY;e.onWheelScroll(h),Od(h,m)&&p.preventDefault()}},onResize:()=>{d.current&&a.viewport&&i&&s({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:zs(i.paddingTop),paddingEnd:zs(i.paddingBottom)}})}})}),[xx,_d]=Nd(kr),Md=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:s,hasThumb:o,onThumbChange:a,onThumbPointerUp:i,onThumbPointerDown:c,onThumbPositionChange:d,onDragScroll:u,onWheelScroll:p,onResize:m,...h}=e,g=ir(kr,n),[x,S]=l.useState(null),k=Xt(t,D=>S(D)),I=l.useRef(null),A=l.useRef(""),w=g.viewport,M=s.content-s.viewport,C=xr(p),b=xr(d),R=no(m,10);function B(D){if(I.current){const Z=D.clientX-I.current.left,z=D.clientY-I.current.top;u({x:Z,y:z})}}return l.useEffect(()=>{const D=Z=>{const z=Z.target;x?.contains(z)&&C(Z,M)};return document.addEventListener("wheel",D,{passive:!1}),()=>document.removeEventListener("wheel",D,{passive:!1})},[w,x,M,C]),l.useEffect(b,[s,b]),Sn(x,R),Sn(g.content,R),r.jsx(xx,{scope:n,scrollbar:x,hasThumb:o,onThumbChange:xr(a),onThumbPointerUp:xr(i),onThumbPositionChange:b,onThumbPointerDown:xr(c),children:r.jsx(Xn.div,{...h,ref:k,style:{position:"absolute",...h.style},onPointerDown:Le(e.onPointerDown,D=>{D.button===0&&(D.target.setPointerCapture(D.pointerId),I.current=x.getBoundingClientRect(),A.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",g.viewport&&(g.viewport.style.scrollBehavior="auto"),B(D))}),onPointerMove:Le(e.onPointerMove,B),onPointerUp:Le(e.onPointerUp,D=>{const Z=D.target;Z.hasPointerCapture(D.pointerId)&&Z.releasePointerCapture(D.pointerId),document.body.style.webkitUserSelect=A.current,g.viewport&&(g.viewport.style.scrollBehavior=""),I.current=null})})})}),Bs="ScrollAreaThumb",Dd=l.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=_d(Bs,e.__scopeScrollArea);return r.jsx(wr,{present:n||o.hasThumb,children:r.jsx(vx,{ref:t,...s})})}),vx=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:s,...o}=e,a=ir(Bs,n),i=_d(Bs,n),{onThumbPositionChange:c}=i,d=Xt(t,m=>i.onThumbChange(m)),u=l.useRef(void 0),p=no(()=>{u.current&&(u.current(),u.current=void 0)},100);return l.useEffect(()=>{const m=a.viewport;if(m){const h=()=>{if(p(),!u.current){const g=wx(m,c);u.current=g,c()}};return c(),m.addEventListener("scroll",h),()=>m.removeEventListener("scroll",h)}},[a.viewport,p,c]),r.jsx(Xn.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...s},onPointerDownCapture:Le(e.onPointerDownCapture,m=>{const g=m.target.getBoundingClientRect(),x=m.clientX-g.left,S=m.clientY-g.top;i.onThumbPointerDown({x,y:S})}),onPointerUp:Le(e.onPointerUp,i.onThumbPointerUp)})});Dd.displayName=Bs;var ai="ScrollAreaCorner",Rd=l.forwardRef((e,t)=>{const n=ir(ai,e.__scopeScrollArea),s=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&s?r.jsx(yx,{...e,ref:t}):null});Rd.displayName=ai;var yx=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,...s}=e,o=ir(ai,n),[a,i]=l.useState(0),[c,d]=l.useState(0),u=!!(a&&c);return Sn(o.scrollbarX,()=>{const p=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(p),d(p)}),Sn(o.scrollbarY,()=>{const p=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(p),i(p)}),u?r.jsx(Xn.div,{...s,ref:t,style:{width:a,height:c,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function zs(e){return e?parseInt(e,10):0}function Pd(e,t){const n=e/t;return isNaN(n)?0:n}function ro(e){const t=Pd(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,s=(e.scrollbar.size-n)*t;return Math.max(s,18)}function bx(e,t,n,s="ltr"){const o=ro(n),a=o/2,i=t||a,c=o-i,d=n.scrollbar.paddingStart+i,u=n.scrollbar.size-n.scrollbar.paddingEnd-c,p=n.content-n.viewport,m=s==="ltr"?[0,p]:[p*-1,0];return Ld([d,u],m)(e)}function ml(e,t,n="ltr"){const s=ro(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-o,i=t.content-t.viewport,c=a-s,d=n==="ltr"?[0,i]:[i*-1,0],u=jm(e,d);return Ld([0,i],[0,c])(u)}function Ld(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const s=(t[1]-t[0])/(e[1]-e[0]);return t[0]+s*(n-e[0])}}function Od(e,t){return e>0&&e<t}var wx=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},s=0;return function o(){const a={left:e.scrollLeft,top:e.scrollTop},i=n.left!==a.left,c=n.top!==a.top;(i||c)&&t(),n=a,s=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(s)};function no(e,t){const n=xr(e),s=l.useRef(0);return l.useEffect(()=>()=>window.clearTimeout(s.current),[]),l.useCallback(()=>{window.clearTimeout(s.current),s.current=window.setTimeout(n,t)},[n,t])}function Sn(e,t){const n=xr(t);fa(()=>{let s=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(s),s=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(s),o.unobserve(e)}}},[e,n])}var Fd=Cd,kx=Id,$d=Ad,jx=Dd,Sx=Rd;function Nx(e,t=[]){let n=[];function s(a,i){const c=l.createContext(i),d=n.length;n=[...n,i];const u=m=>{const{scope:h,children:g,...x}=m,S=h?.[e]?.[d]||c,k=l.useMemo(()=>x,Object.values(x));return r.jsx(S.Provider,{value:k,children:g})};u.displayName=a+"Provider";function p(m,h){const g=h?.[e]?.[d]||c,x=l.useContext(g);if(x)return x;if(i!==void 0)return i;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[u,p]}const o=()=>{const a=n.map(i=>l.createContext(i));return function(c){const d=c?.[e]||a;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[s,Cx(o,...t)]}function Cx(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const i=s.reduce((c,{useScope:d,scopeName:u})=>{const m=d(a)[`__scope${u}`];return{...c,...m}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function Ex(e){const t=Ix(e),n=l.forwardRef((s,o)=>{const{children:a,...i}=s,c=l.Children.toArray(a),d=c.find(Tx);if(d){const u=d.props.children,p=c.map(m=>m===d?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:m);return r.jsx(t,{...i,ref:o,children:l.isValidElement(u)?l.cloneElement(u,void 0,p):null})}return r.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function Ix(e){const t=l.forwardRef((n,s)=>{const{children:o,...a}=n;if(l.isValidElement(o)){const i=Mx(o),c=_x(a,o.props);return o.type!==l.Fragment&&(c.ref=s?on(s,i):i),l.cloneElement(o,c)}return l.Children.count(o)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Ax=Symbol("radix.slottable");function Tx(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Ax}function _x(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...c)=>{const d=a(...c);return o(...c),d}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function Mx(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Dx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],so=Dx.reduce((e,t)=>{const n=Ex(`Primitive.${t}`),s=l.forwardRef((o,a)=>{const{asChild:i,...c}=o,d=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),oo="Tabs",[Rx,yw]=Nx(oo,[Qs]),Bd=Qs(),[Px,ii]=Rx(oo),Lx=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,onValueChange:o,defaultValue:a,orientation:i="horizontal",dir:c,activationMode:d="automatic",...u}=e,p=Xs(c),[m,h]=Va({prop:s,onChange:o,defaultProp:a??"",caller:oo});return r.jsx(Px,{scope:n,baseId:Os(),value:m,onValueChange:h,orientation:i,dir:p,activationMode:d,children:r.jsx(so.div,{dir:p,"data-orientation":i,...u,ref:t})})});Lx.displayName=oo;var zd="TabsList",Ud=l.forwardRef((e,t)=>{const{__scopeTabs:n,loop:s=!0,...o}=e,a=ii(zd,n),i=Bd(n);return r.jsx(qc,{asChild:!0,...i,orientation:a.orientation,dir:a.dir,loop:s,children:r.jsx(so.div,{role:"tablist","aria-orientation":a.orientation,...o,ref:t})})});Ud.displayName=zd;var Wd="TabsTrigger",Hd=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,disabled:o=!1,...a}=e,i=ii(Wd,n),c=Bd(n),d=Kd(i.baseId,s),u=Gd(i.baseId,s),p=s===i.value;return r.jsx(Vc,{asChild:!0,...c,focusable:!o,active:p,children:r.jsx(so.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":u,"data-state":p?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:d,...a,ref:t,onMouseDown:Le(e.onMouseDown,m=>{!o&&m.button===0&&m.ctrlKey===!1?i.onValueChange(s):m.preventDefault()}),onKeyDown:Le(e.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&i.onValueChange(s)}),onFocus:Le(e.onFocus,()=>{const m=i.activationMode!=="manual";!p&&!o&&m&&i.onValueChange(s)})})})});Hd.displayName=Wd;var qd="TabsContent",Vd=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,forceMount:o,children:a,...i}=e,c=ii(qd,n),d=Kd(c.baseId,s),u=Gd(c.baseId,s),p=s===c.value,m=l.useRef(p);return l.useEffect(()=>{const h=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(h)},[]),r.jsx(wr,{present:o||p,children:({present:h})=>r.jsx(so.div,{"data-state":p?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":d,hidden:!h,id:u,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:m.current?"0s":void 0},children:h&&a})})});Vd.displayName=qd;function Kd(e,t){return`${e}-trigger-${t}`}function Gd(e,t){return`${e}-content-${t}`}var Jd=Ud,Yd=Hd,Xd=Vd;const Qd=l.forwardRef(({className:e,orientation:t="vertical",...n},s)=>r.jsx($d,{ref:s,orientation:t,className:st("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:r.jsx(jx,{className:"relative flex-1 rounded-full bg-border/80"})}));Qd.displayName=$d.displayName;const Zd=l.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(Fd,{ref:s,className:st("relative overflow-hidden",e),...n,children:[r.jsx(kx,{className:"h-full w-full rounded-[inherit]",children:t}),r.jsx(Qd,{}),r.jsx(Sx,{})]}));Zd.displayName=Fd.displayName;const Pt=l.forwardRef(({className:e,type:t,...n},s)=>r.jsx("input",{type:t,className:st("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),ref:s,...n}));Pt.displayName="Input";const Qn=({className:e="w-5 h-5"})=>r.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:e}),ao=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=Ka();return r.jsx("img",{src:t?"/icons/codex-white.svg":"/icons/codex.svg",alt:"Codex",className:e})},io=({className:e="w-5 h-5"})=>{const t=l.useId(),n=l.useId(),s=l.useId();return r.jsxs("svg",{"aria-label":"Gemini",className:e,role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:[r.jsx("title",{children:"Gemini"}),r.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"#3186FF"}),r.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:`url(#${t})`}),r.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:`url(#${n})`}),r.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:`url(#${s})`}),r.jsxs("defs",{children:[r.jsxs("linearGradient",{id:t,x1:"7",x2:"11",y1:"15.5",y2:"12",gradientUnits:"userSpaceOnUse",children:[r.jsx("stop",{stopColor:"#08B962"}),r.jsx("stop",{offset:"1",stopColor:"#08B962",stopOpacity:"0"})]}),r.jsxs("linearGradient",{id:n,x1:"8",x2:"11.5",y1:"5.5",y2:"11",gradientUnits:"userSpaceOnUse",children:[r.jsx("stop",{stopColor:"#F94543"}),r.jsx("stop",{offset:"1",stopColor:"#F94543",stopOpacity:"0"})]}),r.jsxs("linearGradient",{id:s,x1:"3.5",x2:"17.5",y1:"13.5",y2:"12",gradientUnits:"userSpaceOnUse",children:[r.jsx("stop",{stopColor:"#FABC12"}),r.jsx("stop",{offset:".46",stopColor:"#FABC12",stopOpacity:"0"})]})]})]})},lo=({className:e="h-5 w-auto",style:t,...n})=>r.jsxs("svg",{"aria-label":"OpenCode",className:e,role:"img",style:{width:"auto",maxWidth:"100%",...t},viewBox:"0 0 32 24",preserveAspectRatio:"xMidYMid meet",xmlns:"http://www.w3.org/2000/svg",...n,children:[r.jsx("title",{children:"OpenCode"}),r.jsx("rect",{x:"6",y:"2",width:"20",height:"20",rx:"5",fill:"currentColor"}),r.jsx("path",{d:"M20 6h-8v12h8V6zm4 16H8V2h16v20z",fill:"white"})]}),Ox=!1,ce=(e,t={})=>{const n=localStorage.getItem("auth-token"),s={};return t.body instanceof FormData||(s["Content-Type"]="application/json"),n&&(s.Authorization=`Bearer ${n}`),fetch(e,{...t,headers:{...s,...t.headers}})},mt={auth:{status:()=>fetch("/api/auth/status"),login:(e,t)=>fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t})}),register:(e,t)=>fetch("/api/auth/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t})}),user:()=>ce("/api/auth/user"),logout:()=>ce("/api/auth/logout",{method:"POST"})},projects:()=>ce("/api/projects"),sessions:(e,t=5,n=0)=>ce(`/api/projects/${e}/sessions?limit=${t}&offset=${n}`),historyIndex:e=>ce(`/api/session-core/projects/${e}/history-index`),providerDiscovery:(e,t=null)=>{const n=new URLSearchParams;return t&&n.append("projectPath",t),ce(`/api/session-core/providers/${e}${n.toString()?`?${n.toString()}`:""}`)},providersDiscovery:(e=null)=>{const t=new URLSearchParams;return e&&t.append("projectPath",e),ce(`/api/session-core/providers${t.toString()?`?${t.toString()}`:""}`)},sessionEvents:(e,t,n=null,s=null,o=null,a=0)=>{const i=new URLSearchParams;return n&&i.append("projectName",n),s&&i.append("projectPath",s),o!==null&&(i.append("limit",o),i.append("offset",a)),ce(`/api/session-core/sessions/${e}/${t}/events${i.toString()?`?${i.toString()}`:""}`)},sessionMessages:(e,t,n=null,s=0,o="claude")=>{const a=new URLSearchParams;return e&&a.append("projectName",e),n!==null&&(a.append("limit",n),a.append("offset",s)),ce(`/api/session-core/sessions/${o}/${t}/events${a.toString()?`?${a.toString()}`:""}`)},resolveSession:(e,t=null)=>{const n=new URLSearchParams;return t&&n.append("provider",t),ce(`/api/session-core/sessions/${e}/resolve${n.toString()?`?${n.toString()}`:""}`)},renameProject:(e,t)=>ce(`/api/projects/${e}/rename`,{method:"PUT",body:JSON.stringify({displayName:t})}),deleteSession:(e,t)=>ce(`/api/projects/${e}/sessions/${t}`,{method:"DELETE"}),deleteCodexSession:e=>ce(`/api/codex/sessions/${e}`,{method:"DELETE"}),deleteOpencodeSession:e=>ce(`/api/opencode/sessions/${e}`,{method:"DELETE"}),deleteProject:(e,t=!1)=>ce(`/api/projects/${e}${t?"?force=true":""}`,{method:"DELETE"}),createProject:e=>ce("/api/projects/create",{method:"POST",body:JSON.stringify({path:e})}),createWorkspace:e=>ce("/api/projects/create-workspace",{method:"POST",body:JSON.stringify(e)}),readFile:(e,t)=>ce(`/api/projects/${e}/file?filePath=${encodeURIComponent(t)}`),saveFile:(e,t,n)=>ce(`/api/projects/${e}/file`,{method:"PUT",body:JSON.stringify({filePath:t,content:n})}),getFiles:e=>ce(`/api/projects/${e}/files`),transcribe:e=>ce("/api/transcribe",{method:"POST",body:e,headers:{}}),browseFilesystem:(e=null)=>{const t=new URLSearchParams;return e&&t.append("path",e),ce(`/api/browse-filesystem?${t}`)},createFolder:e=>ce("/api/create-folder",{method:"POST",body:JSON.stringify({path:e})}),get:e=>ce(`/api${e}`)},Fx=({onClose:e,onProjectCreated:t})=>{const{t:n}=Mt(),[s,o]=l.useState(1),[a,i]=l.useState("existing"),[c,d]=l.useState(""),[u,p]=l.useState(!1),[m,h]=l.useState(null),[g,x]=l.useState([]),[S,k]=l.useState(!1),[I,A]=l.useState(!1),[w,M]=l.useState("~"),[C,b]=l.useState([]),[R,B]=l.useState(!1),[D,Z]=l.useState(!1),[z,X]=l.useState(!1),[q,re]=l.useState(""),[Se,Ce]=l.useState(!1);l.useEffect(()=>{c.length>2?ye(c):(x([]),k(!1))},[c]);const ye=async P=>{try{const ie=P.lastIndexOf("/"),ee=ie>0?P.substring(0,ie):"~",it=await(await mt.browseFilesystem(ee)).json();if(it.suggestions){const Ke=it.suggestions.filter(Ge=>Ge.path.toLowerCase().startsWith(P.toLowerCase())&&Ge.path.toLowerCase()!==P.toLowerCase());x(Ke.slice(0,5)),k(Ke.length>0)}}catch(ie){console.error("Error loading path suggestions:",ie)}},de=()=>{if(h(null),s===1){if(!a){h(n("projectWizard.errors.selectType"));return}o(2)}else if(s===2){if(!c.trim()){h(n("projectWizard.errors.providePath"));return}o(3)}},H=()=>{h(null),o(s-1)},Oe=async()=>{p(!0),h(null);try{const P={workspaceType:a,path:c.trim()},ie=await mt.createWorkspace(P),ee=await ie.json();if(!ie.ok)throw new Error(ee.details||ee.error||n("projectWizard.errors.failedToCreate"));t&&t(ee.project),e()}catch(P){console.error("Error creating workspace:",P),h(P.message||n("projectWizard.errors.failedToCreate"))}finally{p(!1)}},$=P=>{d(P.path),k(!1)},N=async()=>{A(!0),await O("~")},O=async P=>{try{B(!0);const ee=await(await mt.browseFilesystem(P)).json();M(ee.path||P),b(ee.suggestions||[])}catch(ie){console.error("Error loading folders:",ie)}finally{B(!1)}},ne=(P,ie=!1)=>{d(P),A(!1),ie&&o(3)},ke=async P=>{await O(P)},ge=async()=>{if(q.trim()){Ce(!0),h(null);try{const P=w.includes("\\")?"\\":"/",ie=`${w}${P}${q.trim()}`,ee=await mt.createFolder(ie),Ne=await ee.json();if(!ee.ok)throw new Error(Ne.error||n("projectWizard.errors.failedToCreateFolder","Failed to create folder"));re(""),X(!1),await O(Ne.path||ie)}catch(P){console.error("Error creating folder:",P),h(P.message||n("projectWizard.errors.failedToCreateFolder","Failed to create folder"))}finally{Ce(!1)}}};return r.jsxs("div",{className:"fixed top-0 left-0 right-0 bottom-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[60] p-0 sm:p-4",children:[r.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-none sm:rounded-lg shadow-xl w-full h-full sm:h-auto sm:max-w-2xl border-0 sm:border border-gray-200 dark:border-gray-700 overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-8 h-8 bg-primary/15 dark:bg-primary/30 rounded-lg flex items-center justify-center",children:r.jsx(tn,{className:"w-4 h-4 text-primary"})}),r.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:n("projectWizard.title")})]}),r.jsx("button",{onClick:e,className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",disabled:u,children:r.jsx(sr,{className:"w-5 h-5"})})]}),r.jsx("div",{className:"px-6 pt-4 pb-2",children:r.jsx("div",{className:"flex items-center justify-between",children:[1,2,3].map(P=>r.jsxs(Tn.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center font-medium text-sm ${P<s?"bg-green-500 text-white":P===s?"bg-primary text-white":"bg-gray-200 dark:bg-gray-700 text-gray-500"}`,children:P<s?r.jsx(vr,{className:"w-4 h-4"}):P}),r.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 hidden sm:inline",children:n(P===1?"projectWizard.steps.type":P===2?"projectWizard.steps.configure":"projectWizard.steps.confirm")})]}),P<3&&r.jsx("div",{className:`flex-1 h-1 mx-2 rounded ${P<s?"bg-green-500":"bg-gray-200 dark:bg-gray-700"}`})]},P))})}),r.jsxs("div",{className:"p-6 space-y-6 min-h-[300px]",children:[m&&r.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 flex items-start gap-3",children:[r.jsx(Sm,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),r.jsx("div",{className:"flex-1",children:r.jsx("p",{className:"text-sm text-red-800 dark:text-red-200",children:m})})]}),s===1&&r.jsx("div",{className:"space-y-4",children:r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:n("projectWizard.step1.question")}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsx("button",{onClick:()=>i("existing"),className:`p-4 border-2 rounded-lg text-left transition-all ${a==="existing"?"border-primary bg-primary/10 dark:bg-primary/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"w-10 h-10 bg-green-100 dark:bg-green-900/50 rounded-lg flex items-center justify-center flex-shrink-0",children:r.jsx(tn,{className:"w-5 h-5 text-green-600 dark:text-green-400"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:n("projectWizard.step1.existing.title")}),r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:n("projectWizard.step1.existing.description")})]})]})}),r.jsx("button",{onClick:()=>i("new"),className:`p-4 border-2 rounded-lg text-left transition-all ${a==="new"?"border-primary bg-primary/10 dark:bg-primary/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"w-10 h-10 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center flex-shrink-0",children:r.jsx(tn,{className:"w-5 h-5 text-purple-600 dark:text-purple-400"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:n("projectWizard.step1.new.title")}),r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:n("projectWizard.step1.new.description")})]})]})})]})]})}),s===2&&r.jsx("div",{className:"space-y-4",children:r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:n(a==="existing"?"projectWizard.step2.existingPath":"projectWizard.step2.newPath")}),r.jsxs("div",{className:"relative flex gap-2",children:[r.jsxs("div",{className:"flex-1 relative",children:[r.jsx(Pt,{type:"text",value:c,onChange:P=>d(P.target.value),placeholder:a==="existing"?"/path/to/existing/workspace":"/path/to/new/workspace",className:"w-full"}),S&&g.length>0&&r.jsx("div",{className:"absolute z-10 w-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg max-h-60 overflow-y-auto",children:g.map((P,ie)=>r.jsxs("button",{onClick:()=>$(P),className:"w-full px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-700 text-sm",children:[r.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:P.name}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:P.path})]},ie))})]}),r.jsx(Pe,{type:"button",variant:"outline",onClick:N,className:"px-3",title:"Browse folders",children:r.jsx(rn,{className:"w-4 h-4"})})]}),r.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:n(a==="existing"?"projectWizard.step2.existingHelp":"projectWizard.step2.newHelp")})]})}),s===3&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:[r.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-white mb-3",children:n("projectWizard.step3.reviewConfig")}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex justify-between text-sm",children:[r.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:n("projectWizard.step3.workspaceType")}),r.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:n(a==="existing"?"projectWizard.step3.existingWorkspace":"projectWizard.step3.newWorkspace")})]}),r.jsxs("div",{className:"flex justify-between text-sm",children:[r.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:n("projectWizard.step3.path")}),r.jsx("span",{className:"font-mono text-xs text-gray-900 dark:text-white break-all",children:c})]})]})]}),r.jsx("div",{className:"bg-primary/10 dark:bg-primary/20 rounded-lg p-4 border border-primary/30 dark:border-primary/60",children:r.jsx("p",{className:"text-sm text-primary",children:n(a==="existing"?"projectWizard.step3.existingInfo":"projectWizard.step3.newEmpty")})})]})]}),r.jsxs("div",{className:"flex items-center justify-between p-6 border-t border-gray-200 dark:border-gray-700",children:[r.jsx(Pe,{variant:"outline",onClick:s===1?e:H,disabled:u,children:s===1?n("projectWizard.buttons.cancel"):r.jsxs(r.Fragment,{children:[r.jsx(Mc,{className:"w-4 h-4 mr-1"}),n("projectWizard.buttons.back")]})}),r.jsx(Pe,{onClick:s===3?Oe:de,disabled:u||s===1&&!a,children:u?r.jsxs(r.Fragment,{children:[r.jsx(Un,{className:"w-4 h-4 mr-2 animate-spin"}),n("projectWizard.buttons.creating")]}):s===3?r.jsxs(r.Fragment,{children:[r.jsx(vr,{className:"w-4 h-4 mr-1"}),n("projectWizard.buttons.createProject")]}):r.jsxs(r.Fragment,{children:[n("projectWizard.buttons.next"),r.jsx(yn,{className:"w-4 h-4 ml-1"})]})})]})]}),I&&r.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[70] p-4",children:r.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-2xl max-h-[80vh] border border-gray-200 dark:border-gray-700 flex flex-col",children:[r.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-8 h-8 bg-primary/15 dark:bg-primary/30 rounded-lg flex items-center justify-center",children:r.jsx(rn,{className:"w-4 h-4 text-primary"})}),r.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Select Folder"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:()=>Z(!D),className:`p-2 rounded-md transition-colors ${D?"text-primary bg-primary/10 dark:bg-primary/25":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,title:D?"Hide hidden folders":"Show hidden folders",children:D?r.jsx(Dc,{className:"w-5 h-5"}):r.jsx(nf,{className:"w-5 h-5"})}),r.jsx("button",{onClick:()=>X(!z),className:`p-2 rounded-md transition-colors ${z?"text-primary bg-primary/10 dark:bg-primary/25":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,title:"Create new folder",children:r.jsx(jn,{className:"w-5 h-5"})}),r.jsx("button",{onClick:()=>A(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",children:r.jsx(sr,{className:"w-5 h-5"})})]})]}),z&&r.jsx("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700 bg-primary/10 dark:bg-primary/20",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Pt,{type:"text",value:q,onChange:P=>re(P.target.value),placeholder:"New folder name",className:"flex-1",onKeyDown:P=>{P.key==="Enter"&&ge(),P.key==="Escape"&&(X(!1),re(""))},autoFocus:!0}),r.jsx(Pe,{size:"sm",onClick:ge,disabled:!q.trim()||Se,children:Se?r.jsx(Un,{className:"w-4 h-4 animate-spin"}):"Create"}),r.jsx(Pe,{size:"sm",variant:"ghost",onClick:()=>{X(!1),re("")},children:"Cancel"})]})}),r.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:R?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(Un,{className:"w-6 h-6 animate-spin text-gray-400"})}):r.jsxs("div",{className:"space-y-1",children:[w!=="~"&&w!=="/"&&!/^[A-Za-z]:\\?$/.test(w)&&r.jsxs("button",{onClick:()=>{const P=Math.max(w.lastIndexOf("/"),w.lastIndexOf("\\"));let ie;P<=0?ie="/":P===2&&/^[A-Za-z]:/.test(w)?ie=w.substring(0,3):ie=w.substring(0,P),ke(ie)},className:"w-full px-4 py-3 text-left hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg flex items-center gap-3",children:[r.jsx(rn,{className:"w-5 h-5 text-gray-400"}),r.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:".."})]}),C.length===0?r.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"No subfolders found"}):C.filter(P=>D||!P.name.startsWith(".")).sort((P,ie)=>P.name.toLowerCase().localeCompare(ie.name.toLowerCase())).map((P,ie)=>r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("button",{onClick:()=>ke(P.path),className:"flex-1 px-4 py-3 text-left hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg flex items-center gap-3",children:[r.jsx(tn,{className:"w-5 h-5 text-primary"}),r.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:P.name})]}),r.jsx(Pe,{variant:"ghost",size:"sm",onClick:()=>ne(P.path,a==="existing"),className:"text-xs px-3",children:"Select"})]},ie))]})}),r.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700",children:[r.jsxs("div",{className:"px-4 py-3 bg-gray-50 dark:bg-gray-900/50 flex items-center gap-2",children:[r.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Path:"}),r.jsx("code",{className:"text-sm font-mono text-gray-900 dark:text-white flex-1 truncate",children:w})]}),r.jsxs("div",{className:"flex items-center justify-end gap-2 p-4",children:[r.jsx(Pe,{variant:"outline",onClick:()=>{A(!1),X(!1),re("")},children:"Cancel"}),r.jsx(Pe,{variant:"outline",onClick:()=>ne(w,a==="existing"),children:"Use this folder"})]})]})]})})]})},$x=(e,t,n)=>{const s=new Date(e),o=t;if(isNaN(s.getTime()))return n?n("status.unknown"):"Unknown";const a=o-s,i=Math.floor(a/1e3),c=Math.floor(a/(1e3*60)),d=Math.floor(a/(1e3*60*60)),u=Math.floor(a/(1e3*60*60*24));return i<60?n?n("time.justNow"):"Just now":c===1?n?n("time.oneMinuteAgo"):"1 min ago":c<60?n?n("time.minutesAgo",{count:c}):`${c} mins ago`:d===1?n?n("time.oneHourAgo"):"1 hour ago":d<24?n?n("time.hoursAgo",{count:d}):`${d} hours ago`:u===1?n?n("time.oneDayAgo"):"1 day ago":u<7?n?n("time.daysAgo",{count:u}):`${u} days ago`:s.toLocaleDateString(void 0,{month:"numeric",day:"numeric"})},Bx=(e,t)=>{if(typeof e!="string")return"";const n=e.trim();return n.length<=t?n:`${n.slice(0,Math.max(0,t-1))}…`},gn="flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-foreground outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground",js="flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-red-600 outline-none transition-colors hover:bg-red-50 hover:text-red-600 focus:bg-red-50 focus:text-red-600 dark:hover:bg-red-900/20 dark:focus:bg-red-900/20",Qo="block min-w-0 w-full max-w-full overflow-hidden text-ellipsis whitespace-nowrap text-sm font-medium text-foreground",fl=({provider:e,className:t="h-3.5 w-3.5"})=>e==="codex"||e==="openai"?r.jsx(ao,{className:t}):e==="gemini"?r.jsx(io,{className:t}):e==="opencode"?r.jsx(lo,{className:"h-3.5 w-auto max-w-full"}):r.jsx(Qn,{className:t});function hl({projects:e,selectedProject:t,selectedSession:n,onProjectSelect:s,onSessionSelect:o,onNewSession:a,onSessionDelete:i,onProjectDelete:c,isLoading:d,loadingProgress:u,onRefresh:p,updateAvailable:m,latestVersion:h,currentVersion:g,releaseInfo:x,onShowVersionModal:S,isPWA:k,isMobile:I,onToggleSidebar:A,lockedProjectName:w,showNewProject:M,setShowNewProject:C}){const{t:b}=Mt("sidebar"),[R,B]=l.useState(new Set),[D,Z]=l.useState(null),[z,X]=l.useState(""),[q,re]=l.useState({}),[Se,Ce]=l.useState({}),[ye,de]=l.useState(new Set),[H,Oe]=l.useState(new Date),[$,N]=l.useState("name"),[O,ne]=l.useState(!1),[ke,ge]=l.useState(null),[P,ie]=l.useState(""),[ee,Ne]=l.useState(null),[it,Ke]=l.useState(null),[Ge,qe]=l.useState({}),[lt,It]=l.useState(""),[Xe,kt]=l.useState(new Set),[je,Ve]=l.useState(null),[jt,St]=l.useState(null),[Dt,Y]=l.useState(()=>{try{const T=localStorage.getItem("starredProjects");return T?new Set(JSON.parse(T)):new Set}catch(T){return console.error("Error loading starred projects:",T),new Set}}),oe=T=>G=>{G.target.closest(".overflow-y-auto")||G.target.closest("[data-scroll-container]")||(G.preventDefault(),G.stopPropagation(),T())};l.useEffect(()=>{const T=setInterval(()=>{Oe(new Date)},6e4);return()=>clearInterval(T)},[]),l.useEffect(()=>{Ce({}),de(new Set)},[e]),l.useEffect(()=>{n&&t&&B(T=>new Set([...T,t.name]))},[n,t]),l.useEffect(()=>{w&&B(new Set([w]))},[w,e.length]),l.useEffect(()=>{if(e.length>0&&!d){const T=new Set;e.forEach(G=>{G.sessions&&G.sessions.length>=0&&T.add(G.name)}),de(T)}},[e,d]),l.useEffect(()=>{const T=()=>{try{const fe=localStorage.getItem("claude-settings");if(fe){const j=JSON.parse(fe);N(j.projectSortOrder||"name")}}catch(fe){console.error("Error loading sort order:",fe)}};T();const G=fe=>{fe.key==="claude-settings"&&T()};window.addEventListener("storage",G);const Me=setInterval(()=>{document.hasFocus()&&T()},1e3);return()=>{window.removeEventListener("storage",G),clearInterval(Me)}},[]);const Ee=T=>{const G=new Set;R.has(T)||G.add(T),B(G)},Te=(T,G)=>{o({...T,__projectName:G})},Fe=T=>{const G=new Set(Dt);G.has(T)?G.delete(T):G.add(T),Y(G);try{localStorage.setItem("starredProjects",JSON.stringify([...G]))}catch(Me){console.error("Error saving starred projects:",Me)}},tt=T=>Dt.has(T),ue=T=>{let G={};try{G=JSON.parse(localStorage.getItem("session-provider-map")||"{}")}catch{}const Me=[...T.sessions||[],...Se[T.name]||[]].map(ve=>({...ve,__provider:G[ve.id]||"claude"})),fe=(T.codexSessions||[]).map(ve=>({...ve,__provider:"codex"})),j=(T.geminiSessions||[]).map(ve=>({...ve,__provider:"gemini"})),F=(T.opencodeSessions||[]).map(ve=>({...ve,__provider:"opencode"})),xe=ve=>ve.__provider==="codex"?new Date(ve.createdAt||ve.lastActivity):ve.__provider==="gemini"?new Date(ve.createdAt||ve.lastActivity):ve.__provider==="opencode"?new Date(ve.createdAt||ve.lastActivity):new Date(ve.lastActivity);return[...Me,...fe,...j,...F].sort((ve,ut)=>xe(ut)-xe(ve))},dt=T=>{const G=ue(T);return G.length===0?new Date(0):G.reduce((fe,j)=>{const F=new Date(j.lastActivity);return F>fe?F:fe},new Date(0))},Ye=[...e].sort((T,G)=>{const Me=tt(T.name),fe=tt(G.name);if(Me&&!fe)return-1;if(!Me&&fe)return 1;if($==="date")return dt(G)-dt(T);{const j=T.displayName||T.name,F=G.displayName||G.name;return j.localeCompare(F)}}),Qe=T=>{Z(T.name),X(T.displayName)},ze=()=>{Z(null),X("")},Lt=async T=>{try{(await mt.renameProject(T,z)).ok?window.refreshProjects?window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(G){console.error("Error renaming project:",G)}Z(null),X("")},Nt=(T,G,Me,fe="claude")=>{St({projectName:T,sessionId:G,sessionTitle:Me,provider:fe})},xt=async()=>{if(!jt)return;const{projectName:T,sessionId:G,provider:Me}=jt;St(null);try{console.log("[Sidebar] Deleting session:",{projectName:T,sessionId:G,provider:Me});let fe;if(Me==="codex"?fe=await mt.deleteCodexSession(G):Me==="opencode"?fe=await mt.deleteOpencodeSession(G):fe=await mt.deleteSession(T,G),console.log("[Sidebar] Delete response:",{ok:fe.ok,status:fe.status}),fe.ok)console.log("[Sidebar] Session deleted successfully, calling callback"),i?i(G):console.warn("[Sidebar] No onSessionDelete callback provided");else{const j=await fe.text();console.error("[Sidebar] Failed to delete session:",{status:fe.status,error:j}),alert(b("messages.deleteSessionFailed"))}}catch(fe){console.error("[Sidebar] Error deleting session:",fe),alert(b("messages.deleteSessionError"))}},$t=T=>{const G=ue(T).length;Ve({project:T,sessionCount:G})},rt=async()=>{if(!je)return;const{project:T,sessionCount:G}=je,Me=G===0;Ve(null),kt(fe=>new Set([...fe,T.name]));try{const fe=await mt.deleteProject(T.name,!Me);if(fe.ok)c&&c(T.name);else{const j=await fe.json();console.error("Failed to delete project"),alert(j.error||b("messages.deleteProjectFailed"))}}catch(fe){console.error("Error deleting project:",fe),alert(b("messages.deleteProjectError"))}finally{kt(fe=>{const j=new Set(fe);return j.delete(T.name),j})}},ft=async T=>{if(!(!(T.sessionMeta?.hasMore!==!1)||q[T.name])){re(Me=>({...Me,[T.name]:!0}));try{const Me=(T.sessions?.length||0)+(Se[T.name]?.length||0),fe=await mt.sessions(T.name,5,Me);if(fe.ok){const j=await fe.json();Ce(F=>({...F,[T.name]:[...F[T.name]||[],...j.sessions]})),j.hasMore===!1&&(T.sessionMeta={...T.sessionMeta,hasMore:!1})}}catch(Me){console.error("Error loading more sessions:",Me)}finally{re(Me=>({...Me,[T.name]:!1}))}}},qt=Ye.filter(T=>{if(!lt.trim())return!0;const G=lt.toLowerCase(),Me=(T.displayName||T.name).toLowerCase(),fe=T.name.toLowerCase();return Me.includes(G)||fe.includes(G)}),At=!!w,ht=At?Ye.filter(T=>T.name===w):qt,Qt=t||ht[0]||null,Vt=I?"bottom":"right",Zt=I?"end":"start",Rt=I?4:8;return r.jsxs(r.Fragment,{children:[M&&qo.createPortal(r.jsx(Fx,{onClose:()=>C(!1),onProjectCreated:T=>{window.refreshProjects?window.refreshProjects():window.location.reload()}}),document.body),je&&qo.createPortal(r.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:r.jsxs("div",{className:"bg-card border border-border rounded-xl shadow-2xl max-w-md w-full overflow-hidden",children:[r.jsx("div",{className:"p-6",children:r.jsxs("div",{className:"flex items-start gap-4",children:[r.jsx("div",{className:"w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center flex-shrink-0",children:r.jsx(ba,{className:"w-6 h-6 text-red-600 dark:text-red-400"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:b("deleteConfirmation.deleteProject")}),r.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:[b("deleteConfirmation.confirmDelete")," ",r.jsx("span",{className:"font-medium text-foreground",children:je.project.displayName||je.project.name}),"?"]}),je.sessionCount>0&&r.jsxs("div",{className:"mt-3 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:[r.jsx("p",{className:"text-sm text-red-700 dark:text-red-300 font-medium",children:b("deleteConfirmation.sessionCount",{count:je.sessionCount})}),r.jsx("p",{className:"text-xs text-red-600 dark:text-red-400 mt-1",children:b("deleteConfirmation.allConversationsDeleted")})]}),r.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:b("deleteConfirmation.cannotUndo")})]})]})}),r.jsxs("div",{className:"flex gap-3 p-4 bg-muted/30 border-t border-border",children:[r.jsx(Pe,{variant:"outline",className:"flex-1",onClick:()=>Ve(null),children:b("actions.cancel")}),r.jsxs(Pe,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:rt,children:[r.jsx(dr,{className:"w-4 h-4 mr-2"}),b("actions.delete")]})]})]})}),document.body),jt&&qo.createPortal(r.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:r.jsxs("div",{className:"bg-card border border-border rounded-xl shadow-2xl max-w-md w-full overflow-hidden",children:[r.jsx("div",{className:"p-6",children:r.jsxs("div",{className:"flex items-start gap-4",children:[r.jsx("div",{className:"w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center flex-shrink-0",children:r.jsx(ba,{className:"w-6 h-6 text-red-600 dark:text-red-400"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:b("deleteConfirmation.deleteSession")}),r.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:[b("deleteConfirmation.confirmDelete")," ",r.jsx("span",{className:"font-medium text-foreground",children:jt.sessionTitle||b("sessions.unnamed")}),"?"]}),r.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:b("deleteConfirmation.cannotUndo")})]})]})}),r.jsxs("div",{className:"flex gap-3 p-4 bg-muted/30 border-t border-border",children:[r.jsx(Pe,{variant:"outline",className:"flex-1",onClick:()=>St(null),children:b("actions.cancel")}),r.jsxs(Pe,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:xt,children:[r.jsx(dr,{className:"w-4 h-4 mr-2"}),b("actions.delete")]})]})]})}),document.body),r.jsxs("div",{className:"h-full flex flex-col bg-muted/10 border-r border-border/60 md:select-none",style:k&&I?{paddingTop:"44px"}:{},children:[r.jsxs("div",{className:"md:flex-shrink-0 md:px-3 md:pt-3",children:[r.jsxs("div",{className:"hidden h-[60px] items-center justify-between gap-3 border-b border-border/60 bg-muted/10 px-4 md:flex",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("img",{src:"/logo-64.png",alt:"Logo",className:"w-8 h-8 rounded-lg flex-shrink-0"}),r.jsx("div",{className:"min-w-0",children:r.jsx("h1",{className:"text-base font-semibold leading-none text-foreground truncate",children:b("app.title")})})]}),A&&r.jsx(Pe,{variant:"ghost",size:"sm",className:"h-8 w-8 flex-shrink-0 rounded-xl bg-muted/70 px-0 text-muted-foreground transition-colors duration-200 hover:bg-muted hover:text-foreground",onClick:A,title:b("tooltips.hideSidebar"),children:r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})})]}),r.jsx("div",{className:"chat-header border-b border-border/60 bg-white p-3 dark:bg-background md:hidden",style:k&&I?{paddingTop:"16px"}:{},children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("img",{src:"/logo-64.png",alt:"Logo",className:"w-8 h-8 rounded-lg flex-shrink-0"}),r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-foreground",children:b("app.title")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:b("projects.title")})]})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{className:"flex h-9 w-9 items-center justify-center rounded-xl bg-muted/70 text-foreground transition-all duration-150 active:scale-95",onClick:async()=>{ne(!0);try{await p()}finally{ne(!1)}},disabled:O,children:r.jsx(Ir,{className:`w-4 h-4 text-foreground ${O?"animate-spin":""}`})}),!At&&r.jsx("button",{className:"flex h-9 w-9 items-center justify-center rounded-xl bg-foreground text-background transition-all duration-150 active:scale-95",onClick:()=>C(!0),children:r.jsx(tn,{className:"w-4 h-4"})})]})]})})]}),!d&&!I&&!At&&r.jsx("div",{className:"hidden"}),e.length>0&&!d&&!At&&r.jsx("div",{className:"px-3 py-3 md:px-3",children:r.jsxs("div",{className:"relative",children:[r.jsx(va,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),r.jsx(Pt,{type:"text",placeholder:b("projects.searchPlaceholder"),value:lt,onChange:T=>It(T.target.value),className:"h-10 rounded-xl border-0 bg-background/80 pl-9 text-sm shadow-none focus:bg-background focus:ring-2 focus:ring-primary/20"}),lt&&r.jsx("button",{onClick:()=>It(""),className:"absolute right-2 top-1/2 transform -translate-y-1/2 p-1 hover:bg-accent rounded",children:r.jsx(sr,{className:"w-3 h-3 text-muted-foreground"})})]})}),e.length>0&&!d&&Qt&&r.jsx("div",{className:"px-3 pb-2",children:r.jsxs(Pe,{variant:"subtle",className:"h-9 w-full justify-start gap-2 rounded-lg px-3 text-sm",onClick:()=>a(Qt),children:[r.jsx(jn,{className:"h-4 w-4"}),b("sessions.newSession")]})}),r.jsx(Zd,{className:"flex-1 overflow-x-hidden overflow-y-auto overscroll-contain px-2 py-2 md:px-3 md:py-2",children:r.jsx("div",{className:"space-y-1 overflow-x-hidden pb-safe-area-inset-bottom",children:d?r.jsx("div",{className:"flex min-h-[240px] items-start justify-center px-4 pt-10 md:min-h-[280px] md:px-6 md:pt-12",children:r.jsx("div",{className:"w-full max-w-[320px] text-center space-y-4",children:r.jsxs("div",{className:"space-y-2.5",children:[r.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-muted",children:u&&u.total>0?r.jsx("div",{className:"h-full bg-primary transition-all duration-300 ease-out",style:{width:`${u.current/u.total*100}%`}}):r.jsx("div",{className:"h-full w-1/3 rounded-full bg-primary animate-pulse"})}),u?.currentProject&&r.jsx("p",{className:"mx-auto max-w-[260px] break-words text-base font-medium leading-6 text-foreground",title:u.currentProject,children:u.currentProject.split("-").slice(-2).join("/")}),u&&u.total>0?r.jsxs("p",{className:"text-sm text-muted-foreground",children:[u.current,"/",u.total,r.jsx("span",{className:"ml-1 text-sm text-muted-foreground",children:b("projects.projects")})]}):r.jsx("p",{className:"text-sm text-muted-foreground",children:b("projects.loadingProjects")})]})})}):e.length===0?r.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[r.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:r.jsx(Go,{className:"w-6 h-6 text-muted-foreground"})}),r.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:b("projects.noProjects")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:b("projects.runClaudeCli")})]}):ht.length===0?r.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[r.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:r.jsx(va,{className:"w-6 h-6 text-muted-foreground"})}),r.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:b("projects.noMatchingProjects")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:b("projects.tryDifferentSearch")})]}):ht.map(T=>{const G=R.has(T.name),Me=t?.name===T.name,fe=tt(T.name),j=Xe.has(T.name),F=At&&T.name===w,xe=F||G,ve=T.displayName||T.name,ut=Bx(ve,I?22:28);return r.jsxs("div",{className:st("space-y-2",j&&"pointer-events-none opacity-50"),children:[!F&&r.jsxs("div",{className:"group md:group",children:[r.jsx("div",{className:"md:hidden",children:r.jsxs("div",{className:st("mx-1 flex min-h-10 items-center gap-2 px-2 py-2 text-muted-foreground transition-colors active:scale-[0.98]",Me?"text-foreground":"hover:text-foreground"),onClick:()=>{t?.name!==T.name&&s(T),Ee(T.name)},onTouchEnd:oe(()=>{t?.name!==T.name&&s(T),Ee(T.name)}),children:[r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[r.jsx("div",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:G?r.jsx(rn,{className:st("h-4 w-4",fe?"text-yellow-600 dark:text-yellow-400":"text-foreground")}):r.jsx(Go,{className:st("h-4 w-4",fe?"text-yellow-600 dark:text-yellow-400":Me?"text-foreground":"text-muted-foreground")})}),r.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:D===T.name?r.jsx("input",{type:"text",value:z,onChange:U=>X(U.target.value),className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm text-foreground focus:outline-none focus:ring-1 focus:ring-primary",placeholder:b("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:U=>U.stopPropagation(),onKeyDown:U=>{U.key==="Enter"&&Lt(T.name),U.key==="Escape"&&ze()},style:{fontSize:"16px"}}):r.jsx("div",{className:st(Qo,Me&&"font-semibold"),children:ut})})]}),r.jsx("div",{className:"flex shrink-0 items-center justify-end gap-1",children:D===T.name?r.jsxs(r.Fragment,{children:[r.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-md text-green-600 transition-colors hover:bg-green-50 hover:text-green-700 dark:hover:bg-green-900/20",onClick:U=>{U.stopPropagation(),Lt(T.name)},title:b("tooltips.save"),children:r.jsx(vr,{className:"h-3.5 w-3.5"})}),r.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",onClick:U=>{U.stopPropagation(),ze()},title:b("tooltips.cancel"),children:r.jsx(sr,{className:"h-3.5 w-3.5"})})]}):r.jsxs(ys,{children:[r.jsx(bs,{asChild:!0,children:r.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-md p-0 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground data-[state=open]:bg-accent data-[state=open]:text-foreground",onClick:U=>U.stopPropagation(),"aria-label":b("actions.settings"),children:r.jsx(gs,{className:"h-4 w-4"})})}),r.jsx(ws,{children:r.jsxs(ks,{side:Vt,align:Zt,sideOffset:Rt,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:U=>U.stopPropagation(),children:[r.jsxs(hr,{className:gn,onSelect:U=>{U.preventDefault(),Qe(T)},children:[r.jsx(ll,{className:"h-4 w-4"}),b("tooltips.renameProject")]}),r.jsxs(hr,{className:gn,onSelect:U=>{U.preventDefault(),Fe(T.name)},children:[r.jsx(dl,{className:st("h-4 w-4",fe&&"fill-yellow-400 text-yellow-500")}),b(fe?"tooltips.removeFromFavorites":"tooltips.addToFavorites")]}),r.jsx(pl,{className:"my-1 h-px bg-border"}),r.jsxs(hr,{className:js,onSelect:U=>{U.preventDefault(),$t(T)},children:[r.jsx(dr,{className:"h-4 w-4"}),b("tooltips.deleteProject")]})]})})]})})]})}),r.jsxs("div",{role:"button",tabIndex:0,className:st("group relative hidden w-full items-center justify-start gap-2 px-2 py-2 text-left font-normal text-muted-foreground transition-colors md:flex",D===T.name?"h-auto":"h-9",Me?"text-foreground":"hover:text-foreground"),onClick:()=>{t?.name!==T.name&&s(T),Ee(T.name)},onTouchEnd:oe(()=>{t?.name!==T.name&&s(T),Ee(T.name)}),onKeyDown:U=>{(U.key==="Enter"||U.key===" ")&&(U.preventDefault(),t?.name!==T.name&&s(T),Ee(T.name))},title:T.fullPath||ve,children:[r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[r.jsx("div",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:G?r.jsx(rn,{className:st("h-4 w-4",fe?"text-yellow-600 dark:text-yellow-400":"text-foreground")}):r.jsx(Go,{className:st("h-4 w-4",fe?"text-yellow-600 dark:text-yellow-400":Me?"text-foreground":"text-muted-foreground")})}),r.jsx("div",{className:"min-w-0 flex-1 overflow-hidden text-left",children:D===T.name?r.jsx("input",{type:"text",value:z,onChange:U=>X(U.target.value),className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm text-foreground focus:outline-none focus:ring-1 focus:ring-primary",placeholder:b("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:U=>{U.key==="Enter"&&Lt(T.name),U.key==="Escape"&&ze()},onClick:U=>U.stopPropagation()}):r.jsx("div",{className:st(Qo,Me&&"font-semibold"),children:ut})})]}),r.jsx("div",{className:"flex shrink-0 items-center gap-1 pl-1",children:D===T.name?r.jsxs(r.Fragment,{children:[r.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-md text-green-600 transition-colors hover:bg-green-50 hover:text-green-700 dark:hover:bg-green-900/20",onClick:U=>{U.stopPropagation(),Lt(T.name)},title:b("tooltips.save"),children:r.jsx(vr,{className:"h-3.5 w-3.5"})}),r.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",onClick:U=>{U.stopPropagation(),ze()},title:b("tooltips.cancel"),children:r.jsx(sr,{className:"h-3.5 w-3.5"})})]}):r.jsxs(ys,{children:[r.jsx(bs,{asChild:!0,children:r.jsx("button",{className:st("flex h-7 w-7 items-center justify-center rounded-md p-0 text-muted-foreground transition-all hover:bg-accent hover:text-foreground data-[state=open]:bg-accent data-[state=open]:text-foreground"),onClick:U=>U.stopPropagation(),"aria-label":b("actions.settings"),children:r.jsx(gs,{className:"h-4 w-4"})})}),r.jsx(ws,{children:r.jsxs(ks,{side:Vt,align:Zt,sideOffset:Rt,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:U=>U.stopPropagation(),children:[r.jsxs(hr,{className:gn,onSelect:U=>{U.preventDefault(),Qe(T)},children:[r.jsx(ll,{className:"h-4 w-4"}),b("tooltips.renameProject")]}),r.jsxs(hr,{className:gn,onSelect:U=>{U.preventDefault(),Fe(T.name)},children:[r.jsx(dl,{className:st("h-4 w-4",fe&&"fill-yellow-400 text-yellow-500")}),b(fe?"tooltips.removeFromFavorites":"tooltips.addToFavorites")]}),r.jsx(pl,{className:"my-1 h-px bg-border"}),r.jsxs(hr,{className:js,onSelect:U=>{U.preventDefault(),$t(T)},children:[r.jsx(dr,{className:"h-4 w-4"}),b("tooltips.deleteProject")]})]})})]})})]})]}),xe&&r.jsxs("div",{className:st("space-y-1",F?"px-1 md:px-0":"px-0"),children:[ye.has(T.name)?ue(T).length===0&&!q[T.name]?r.jsx("div",{className:"px-3 py-2 text-left",children:r.jsx("p",{className:"text-xs text-muted-foreground",children:b("sessions.noSessions")})}):ue(T).map(U=>{const ot=U.__provider==="codex",L=U.__provider==="gemini",W=U.__provider==="opencode",se=ot||L||W,E=ke===U.id&&!ot,J=n?.id===U.id,Q=ot?U.summary||U.name||b("projects.codexSession"):W?U.summary||U.name||b("projects.opencodeSession"):U.summary||U.name||b("projects.newSession"),he=se&&U.createdAt||U.lastActivity,we=ee===U.id||it===U.id;return r.jsxs("div",{className:"group/session relative w-full min-w-0 max-w-full",onMouseEnter:()=>Ne(U.id),onMouseLeave:()=>Ne(te=>te===U.id?null:te),children:[r.jsx("div",{className:"w-full min-w-0 max-w-full md:hidden",children:r.jsxs("div",{className:st("mx-1 grid min-h-9 min-w-0 grid-cols-[auto,minmax(0,1fr),auto] items-center gap-2 overflow-hidden rounded-2xl px-3 py-2 transition-all duration-200",J?"chat-sidebar-item-active":"chat-sidebar-item hover:bg-muted/10"),onClick:()=>{s(T),Te(U,T.name)},onTouchEnd:oe(()=>{s(T),Te(U,T.name)}),children:[r.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground",children:r.jsx(fl,{provider:U.__provider})}),r.jsx("div",{className:"min-w-0 flex-1 basis-0 overflow-hidden",children:E?r.jsx("input",{type:"text",value:P,onChange:te=>ie(te.target.value),onKeyDown:te=>{te.stopPropagation(),te.key==="Enter"?updateSessionSummary(T.name,U.id,P):te.key==="Escape"&&(ge(null),ie(""))},onClick:te=>te.stopPropagation(),className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0}):r.jsx("div",{className:Qo,title:Q,children:Q})}),r.jsx("div",{className:"flex shrink-0 items-center justify-end gap-1",children:E?r.jsxs(r.Fragment,{children:[r.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-md text-green-600 transition-colors hover:bg-green-50 hover:text-green-700 dark:hover:bg-green-900/20",onClick:te=>{te.stopPropagation(),updateSessionSummary(T.name,U.id,P)},title:b("tooltips.save"),children:r.jsx(vr,{className:"h-3.5 w-3.5"})}),r.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",onClick:te=>{te.stopPropagation(),ge(null),ie("")},title:b("tooltips.cancel"),children:r.jsx(sr,{className:"h-3.5 w-3.5"})})]}):r.jsx(r.Fragment,{children:r.jsxs(ys,{children:[r.jsx(bs,{asChild:!0,children:r.jsx("button",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md p-0 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground data-[state=open]:bg-accent data-[state=open]:text-foreground",onClick:te=>te.stopPropagation(),"aria-label":b("actions.settings"),children:r.jsx(gs,{className:"h-4 w-4"})})}),r.jsx(ws,{children:r.jsxs(ks,{side:Vt,align:Zt,sideOffset:Rt,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:te=>te.stopPropagation(),children:[!ot&&r.jsxs(hr,{className:gn,onSelect:te=>{te.preventDefault(),ge(U.id),ie(U.summary||U.name||b("projects.newSession"))},children:[r.jsx(cl,{className:"h-4 w-4"}),b("tooltips.editSessionName")]}),r.jsxs(hr,{className:js,onSelect:te=>{te.preventDefault(),Nt(T.name,U.id,Q,U.__provider)},children:[r.jsx(dr,{className:"h-4 w-4"}),b("tooltips.deleteSession")]})]})})]})})})]})}),r.jsx("div",{className:"hidden w-full min-w-0 max-w-full md:block",children:r.jsxs("div",{className:st("grid min-h-9 min-w-0 grid-cols-[minmax(0,1fr),auto] items-center gap-2 overflow-hidden rounded-2xl px-2 py-1.5 transition-all duration-200",J?"chat-sidebar-item-active":"chat-sidebar-item hover:bg-muted/10"),children:[r.jsxs("button",{className:"flex w-full min-w-0 items-center gap-2 overflow-hidden text-left",onClick:()=>Te(U,T.name),onTouchEnd:oe(()=>Te(U,T.name)),children:[r.jsx("span",{className:st("flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground transition-opacity",J||E?"opacity-100":"opacity-0 group-hover/session:opacity-100"),children:r.jsx(fl,{provider:U.__provider})}),E?r.jsx("input",{type:"text",value:P,onChange:te=>ie(te.target.value),onKeyDown:te=>{te.stopPropagation(),te.key==="Enter"?updateSessionSummary(T.name,U.id,P):te.key==="Escape"&&(ge(null),ie(""))},onClick:te=>te.stopPropagation(),className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0}):r.jsx("span",{className:"block min-w-0 w-full flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-sm text-foreground",title:Q,children:Q})]}),r.jsx("div",{className:"relative flex shrink-0 items-center justify-end pl-1 min-w-[28px]",children:E?r.jsxs(r.Fragment,{children:[r.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-md text-green-600 transition-colors hover:bg-green-50 hover:text-green-700 dark:hover:bg-green-900/20",onClick:te=>{te.stopPropagation(),updateSessionSummary(T.name,U.id,P)},title:b("tooltips.save"),children:r.jsx(vr,{className:"h-3.5 w-3.5"})}),r.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",onClick:te=>{te.stopPropagation(),ge(null),ie("")},title:b("tooltips.cancel"),children:r.jsx(sr,{className:"h-3.5 w-3.5"})})]}):r.jsxs(r.Fragment,{children:[r.jsx("span",{className:st("text-[11px] text-muted-foreground whitespace-nowrap transition-opacity duration-200",we?"opacity-0":"opacity-100"),children:$x(he,H,b)}),we&&r.jsx("div",{className:"absolute right-0 top-1/2 -translate-y-1/2 flex items-center justify-end",children:r.jsxs(ys,{onOpenChange:te=>Ke(te?U.id:null),children:[r.jsx(bs,{asChild:!0,children:r.jsx("button",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md p-0 text-muted-foreground transition-all hover:bg-accent hover:text-foreground data-[state=open]:bg-accent data-[state=open]:text-foreground",onClick:te=>te.stopPropagation(),onFocus:()=>Ne(U.id),"aria-label":b("actions.settings"),children:r.jsx(gs,{className:"h-4 w-4"})})}),r.jsx(ws,{children:r.jsxs(ks,{side:Vt,align:Zt,sideOffset:Rt,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:te=>te.stopPropagation(),children:[!ot&&r.jsxs(hr,{className:gn,onSelect:te=>{te.preventDefault(),ge(U.id),ie(U.summary||U.name||b("projects.newSession"))},children:[r.jsx(cl,{className:"h-4 w-4"}),b("tooltips.editSessionName")]}),r.jsxs(hr,{className:js,onSelect:te=>{te.preventDefault(),Nt(T.name,U.id,Q,U.__provider)},children:[r.jsx(dr,{className:"h-4 w-4"}),b("tooltips.deleteSession")]})]})})]})})]})})]})})]},U.id)}):Array.from({length:3}).map((U,ot)=>r.jsx("div",{className:"flex h-9 items-center rounded-lg px-3",children:r.jsx("div",{className:"h-3 w-full animate-pulse rounded bg-muted",style:{width:`${60+ot*15}%`}})},ot)),ue(T).length>0&&T.sessionMeta?.hasMore!==!1&&r.jsx(Pe,{variant:"subtle",size:"sm",className:"mt-2 w-full justify-center gap-2 rounded-xl text-muted-foreground hover:text-foreground",onClick:()=>ft(T),disabled:q[T.name],children:q[T.name]?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"w-3 h-3 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),b("sessions.loading")]}):r.jsxs(r.Fragment,{children:[r.jsx(Ar,{className:"w-3 h-3"}),b("sessions.showMore")]})})]})]},T.name)})})}),m&&r.jsxs("div",{className:"px-3 py-3 flex-shrink-0",children:[r.jsx("div",{className:"hidden md:block",children:r.jsxs(Pe,{variant:"ghost",className:"mb-2 h-auto w-full justify-start gap-3 rounded-lg bg-blue-50/90 p-3 text-left font-normal transition-colors duration-200 hover:bg-blue-100 dark:bg-blue-900/20 dark:hover:bg-blue-900/30",onClick:S,children:[r.jsxs("div",{className:"relative",children:[r.jsx("svg",{className:"w-4 h-4 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M9 19l3 3m0 0l3-3m-3 3V10"})}),r.jsx("div",{className:"absolute -top-1 -right-1 w-2 h-2 bg-blue-500 rounded-full animate-pulse"})]}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"text-sm font-medium text-blue-700 dark:text-blue-300",children:x?.title||`Version ${h}`}),r.jsx("div",{className:"text-xs text-blue-600 dark:text-blue-400",children:b("version.updateAvailable")})]})]})}),r.jsx("div",{className:"md:hidden p-3 pb-2",children:r.jsxs("button",{className:"flex h-12 w-full items-center justify-start gap-3 rounded-xl bg-blue-50 dark:bg-blue-900/20 px-4 transition-all duration-150 active:scale-[0.98]",onClick:S,children:[r.jsxs("div",{className:"relative",children:[r.jsx("svg",{className:"w-5 h-5 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M9 19l3 3m0 0l3-3m-3 3V10"})}),r.jsx("div",{className:"absolute -top-1 -right-1 w-2 h-2 bg-blue-500 rounded-full animate-pulse"})]}),r.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[r.jsx("div",{className:"text-sm font-medium text-blue-700 dark:text-blue-300",children:x?.title||`Version ${h}`}),r.jsx("div",{className:"text-xs text-blue-600 dark:text-blue-400",children:b("version.updateAvailable")})]})]})})]}),r.jsx("div",{className:"md:p-2 flex-shrink-0",children:r.jsxs("div",{className:"hidden md:flex items-center justify-between gap-2",children:[!At&&r.jsxs(Pe,{variant:"ghost",className:"flex h-10 flex-1 items-center justify-center gap-2 rounded-xl bg-background/80 px-3 font-normal text-muted-foreground transition-colors duration-200 hover:bg-background hover:text-foreground",onClick:()=>C(!0),title:b("tooltips.createProject"),children:[r.jsx(tn,{className:"w-4 h-4"}),r.jsx("span",{className:"text-xs leading-none",children:b("projects.newProject").includes("Project")?"New":b("projects.newProject").substring(0,2)})]}),r.jsxs(Pe,{variant:"ghost",className:"flex h-10 flex-1 items-center justify-center gap-2 rounded-xl bg-background/80 px-3 font-normal text-muted-foreground transition-colors duration-200 hover:bg-background hover:text-foreground",onClick:async()=>{ne(!0);try{await p()}finally{ne(!1)}},disabled:O,title:b("tooltips.refresh"),children:[r.jsx(Ir,{className:`w-4 h-4 ${O?"animate-spin":""}`}),r.jsx("span",{className:"text-xs leading-none",children:b("actions.refresh")||"Sync"})]})]})})]})]})}var Zo={exports:{}},ea,gl;function zx(){if(gl)return ea;gl=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return ea=e,ea}var ta,xl;function Ux(){if(xl)return ta;xl=1;var e=zx();function t(){}function n(){}return n.resetWarningCache=t,ta=function(){function s(i,c,d,u,p,m){if(m!==e){var h=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw h.name="Invariant Violation",h}}s.isRequired=s;function o(){return s}var a={array:s,bigint:s,bool:s,func:s,number:s,object:s,string:s,symbol:s,any:s,arrayOf:o,element:s,elementType:s,instanceOf:o,node:s,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:n,resetWarningCache:t};return a.PropTypes=a,a},ta}var vl;function Wx(){return vl||(vl=1,Zo.exports=Ux()()),Zo.exports}var Hx=Wx();const at=Ec(Hx),qx=new Map([["1km","application/vnd.1000minds.decision-model+xml"],["3dml","text/vnd.in3d.3dml"],["3ds","image/x-3ds"],["3g2","video/3gpp2"],["3gp","video/3gp"],["3gpp","video/3gpp"],["3mf","model/3mf"],["7z","application/x-7z-compressed"],["7zip","application/x-7z-compressed"],["123","application/vnd.lotus-1-2-3"],["aab","application/x-authorware-bin"],["aac","audio/x-acc"],["aam","application/x-authorware-map"],["aas","application/x-authorware-seg"],["abw","application/x-abiword"],["ac","application/vnd.nokia.n-gage.ac+xml"],["ac3","audio/ac3"],["acc","application/vnd.americandynamics.acc"],["ace","application/x-ace-compressed"],["acu","application/vnd.acucobol"],["acutc","application/vnd.acucorp"],["adp","audio/adpcm"],["aep","application/vnd.audiograph"],["afm","application/x-font-type1"],["afp","application/vnd.ibm.modcap"],["ahead","application/vnd.ahead.space"],["ai","application/pdf"],["aif","audio/x-aiff"],["aifc","audio/x-aiff"],["aiff","audio/x-aiff"],["air","application/vnd.adobe.air-application-installer-package+zip"],["ait","application/vnd.dvb.ait"],["ami","application/vnd.amiga.ami"],["amr","audio/amr"],["apk","application/vnd.android.package-archive"],["apng","image/apng"],["appcache","text/cache-manifest"],["application","application/x-ms-application"],["apr","application/vnd.lotus-approach"],["arc","application/x-freearc"],["arj","application/x-arj"],["asc","application/pgp-signature"],["asf","video/x-ms-asf"],["asm","text/x-asm"],["aso","application/vnd.accpac.simply.aso"],["asx","video/x-ms-asf"],["atc","application/vnd.acucorp"],["atom","application/atom+xml"],["atomcat","application/atomcat+xml"],["atomdeleted","application/atomdeleted+xml"],["atomsvc","application/atomsvc+xml"],["atx","application/vnd.antix.game-component"],["au","audio/x-au"],["avi","video/x-msvideo"],["avif","image/avif"],["aw","application/applixware"],["azf","application/vnd.airzip.filesecure.azf"],["azs","application/vnd.airzip.filesecure.azs"],["azv","image/vnd.airzip.accelerator.azv"],["azw","application/vnd.amazon.ebook"],["b16","image/vnd.pco.b16"],["bat","application/x-msdownload"],["bcpio","application/x-bcpio"],["bdf","application/x-font-bdf"],["bdm","application/vnd.syncml.dm+wbxml"],["bdoc","application/x-bdoc"],["bed","application/vnd.realvnc.bed"],["bh2","application/vnd.fujitsu.oasysprs"],["bin","application/octet-stream"],["blb","application/x-blorb"],["blorb","application/x-blorb"],["bmi","application/vnd.bmi"],["bmml","application/vnd.balsamiq.bmml+xml"],["bmp","image/bmp"],["book","application/vnd.framemaker"],["box","application/vnd.previewsystems.box"],["boz","application/x-bzip2"],["bpk","application/octet-stream"],["bpmn","application/octet-stream"],["bsp","model/vnd.valve.source.compiled-map"],["btif","image/prs.btif"],["buffer","application/octet-stream"],["bz","application/x-bzip"],["bz2","application/x-bzip2"],["c","text/x-c"],["c4d","application/vnd.clonk.c4group"],["c4f","application/vnd.clonk.c4group"],["c4g","application/vnd.clonk.c4group"],["c4p","application/vnd.clonk.c4group"],["c4u","application/vnd.clonk.c4group"],["c11amc","application/vnd.cluetrust.cartomobile-config"],["c11amz","application/vnd.cluetrust.cartomobile-config-pkg"],["cab","application/vnd.ms-cab-compressed"],["caf","audio/x-caf"],["cap","application/vnd.tcpdump.pcap"],["car","application/vnd.curl.car"],["cat","application/vnd.ms-pki.seccat"],["cb7","application/x-cbr"],["cba","application/x-cbr"],["cbr","application/x-cbr"],["cbt","application/x-cbr"],["cbz","application/x-cbr"],["cc","text/x-c"],["cco","application/x-cocoa"],["cct","application/x-director"],["ccxml","application/ccxml+xml"],["cdbcmsg","application/vnd.contact.cmsg"],["cda","application/x-cdf"],["cdf","application/x-netcdf"],["cdfx","application/cdfx+xml"],["cdkey","application/vnd.mediastation.cdkey"],["cdmia","application/cdmi-capability"],["cdmic","application/cdmi-container"],["cdmid","application/cdmi-domain"],["cdmio","application/cdmi-object"],["cdmiq","application/cdmi-queue"],["cdr","application/cdr"],["cdx","chemical/x-cdx"],["cdxml","application/vnd.chemdraw+xml"],["cdy","application/vnd.cinderella"],["cer","application/pkix-cert"],["cfs","application/x-cfs-compressed"],["cgm","image/cgm"],["chat","application/x-chat"],["chm","application/vnd.ms-htmlhelp"],["chrt","application/vnd.kde.kchart"],["cif","chemical/x-cif"],["cii","application/vnd.anser-web-certificate-issue-initiation"],["cil","application/vnd.ms-artgalry"],["cjs","application/node"],["cla","application/vnd.claymore"],["class","application/octet-stream"],["clkk","application/vnd.crick.clicker.keyboard"],["clkp","application/vnd.crick.clicker.palette"],["clkt","application/vnd.crick.clicker.template"],["clkw","application/vnd.crick.clicker.wordbank"],["clkx","application/vnd.crick.clicker"],["clp","application/x-msclip"],["cmc","application/vnd.cosmocaller"],["cmdf","chemical/x-cmdf"],["cml","chemical/x-cml"],["cmp","application/vnd.yellowriver-custom-menu"],["cmx","image/x-cmx"],["cod","application/vnd.rim.cod"],["coffee","text/coffeescript"],["com","application/x-msdownload"],["conf","text/plain"],["cpio","application/x-cpio"],["cpp","text/x-c"],["cpt","application/mac-compactpro"],["crd","application/x-mscardfile"],["crl","application/pkix-crl"],["crt","application/x-x509-ca-cert"],["crx","application/x-chrome-extension"],["cryptonote","application/vnd.rig.cryptonote"],["csh","application/x-csh"],["csl","application/vnd.citationstyles.style+xml"],["csml","chemical/x-csml"],["csp","application/vnd.commonspace"],["csr","application/octet-stream"],["css","text/css"],["cst","application/x-director"],["csv","text/csv"],["cu","application/cu-seeme"],["curl","text/vnd.curl"],["cww","application/prs.cww"],["cxt","application/x-director"],["cxx","text/x-c"],["dae","model/vnd.collada+xml"],["daf","application/vnd.mobius.daf"],["dart","application/vnd.dart"],["dataless","application/vnd.fdsn.seed"],["davmount","application/davmount+xml"],["dbf","application/vnd.dbf"],["dbk","application/docbook+xml"],["dcr","application/x-director"],["dcurl","text/vnd.curl.dcurl"],["dd2","application/vnd.oma.dd2+xml"],["ddd","application/vnd.fujixerox.ddd"],["ddf","application/vnd.syncml.dmddf+xml"],["dds","image/vnd.ms-dds"],["deb","application/x-debian-package"],["def","text/plain"],["deploy","application/octet-stream"],["der","application/x-x509-ca-cert"],["dfac","application/vnd.dreamfactory"],["dgc","application/x-dgc-compressed"],["dic","text/x-c"],["dir","application/x-director"],["dis","application/vnd.mobius.dis"],["disposition-notification","message/disposition-notification"],["dist","application/octet-stream"],["distz","application/octet-stream"],["djv","image/vnd.djvu"],["djvu","image/vnd.djvu"],["dll","application/octet-stream"],["dmg","application/x-apple-diskimage"],["dmn","application/octet-stream"],["dmp","application/vnd.tcpdump.pcap"],["dms","application/octet-stream"],["dna","application/vnd.dna"],["doc","application/msword"],["docm","application/vnd.ms-word.template.macroEnabled.12"],["docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],["dot","application/msword"],["dotm","application/vnd.ms-word.template.macroEnabled.12"],["dotx","application/vnd.openxmlformats-officedocument.wordprocessingml.template"],["dp","application/vnd.osgi.dp"],["dpg","application/vnd.dpgraph"],["dra","audio/vnd.dra"],["drle","image/dicom-rle"],["dsc","text/prs.lines.tag"],["dssc","application/dssc+der"],["dtb","application/x-dtbook+xml"],["dtd","application/xml-dtd"],["dts","audio/vnd.dts"],["dtshd","audio/vnd.dts.hd"],["dump","application/octet-stream"],["dvb","video/vnd.dvb.file"],["dvi","application/x-dvi"],["dwd","application/atsc-dwd+xml"],["dwf","model/vnd.dwf"],["dwg","image/vnd.dwg"],["dxf","image/vnd.dxf"],["dxp","application/vnd.spotfire.dxp"],["dxr","application/x-director"],["ear","application/java-archive"],["ecelp4800","audio/vnd.nuera.ecelp4800"],["ecelp7470","audio/vnd.nuera.ecelp7470"],["ecelp9600","audio/vnd.nuera.ecelp9600"],["ecma","application/ecmascript"],["edm","application/vnd.novadigm.edm"],["edx","application/vnd.novadigm.edx"],["efif","application/vnd.picsel"],["ei6","application/vnd.pg.osasli"],["elc","application/octet-stream"],["emf","image/emf"],["eml","message/rfc822"],["emma","application/emma+xml"],["emotionml","application/emotionml+xml"],["emz","application/x-msmetafile"],["eol","audio/vnd.digital-winds"],["eot","application/vnd.ms-fontobject"],["eps","application/postscript"],["epub","application/epub+zip"],["es","application/ecmascript"],["es3","application/vnd.eszigno3+xml"],["esa","application/vnd.osgi.subsystem"],["esf","application/vnd.epson.esf"],["et3","application/vnd.eszigno3+xml"],["etx","text/x-setext"],["eva","application/x-eva"],["evy","application/x-envoy"],["exe","application/octet-stream"],["exi","application/exi"],["exp","application/express"],["exr","image/aces"],["ext","application/vnd.novadigm.ext"],["ez","application/andrew-inset"],["ez2","application/vnd.ezpix-album"],["ez3","application/vnd.ezpix-package"],["f","text/x-fortran"],["f4v","video/mp4"],["f77","text/x-fortran"],["f90","text/x-fortran"],["fbs","image/vnd.fastbidsheet"],["fcdt","application/vnd.adobe.formscentral.fcdt"],["fcs","application/vnd.isac.fcs"],["fdf","application/vnd.fdf"],["fdt","application/fdt+xml"],["fe_launch","application/vnd.denovo.fcselayout-link"],["fg5","application/vnd.fujitsu.oasysgp"],["fgd","application/x-director"],["fh","image/x-freehand"],["fh4","image/x-freehand"],["fh5","image/x-freehand"],["fh7","image/x-freehand"],["fhc","image/x-freehand"],["fig","application/x-xfig"],["fits","image/fits"],["flac","audio/x-flac"],["fli","video/x-fli"],["flo","application/vnd.micrografx.flo"],["flv","video/x-flv"],["flw","application/vnd.kde.kivio"],["flx","text/vnd.fmi.flexstor"],["fly","text/vnd.fly"],["fm","application/vnd.framemaker"],["fnc","application/vnd.frogans.fnc"],["fo","application/vnd.software602.filler.form+xml"],["for","text/x-fortran"],["fpx","image/vnd.fpx"],["frame","application/vnd.framemaker"],["fsc","application/vnd.fsc.weblaunch"],["fst","image/vnd.fst"],["ftc","application/vnd.fluxtime.clip"],["fti","application/vnd.anser-web-funds-transfer-initiation"],["fvt","video/vnd.fvt"],["fxp","application/vnd.adobe.fxp"],["fxpl","application/vnd.adobe.fxp"],["fzs","application/vnd.fuzzysheet"],["g2w","application/vnd.geoplan"],["g3","image/g3fax"],["g3w","application/vnd.geospace"],["gac","application/vnd.groove-account"],["gam","application/x-tads"],["gbr","application/rpki-ghostbusters"],["gca","application/x-gca-compressed"],["gdl","model/vnd.gdl"],["gdoc","application/vnd.google-apps.document"],["geo","application/vnd.dynageo"],["geojson","application/geo+json"],["gex","application/vnd.geometry-explorer"],["ggb","application/vnd.geogebra.file"],["ggt","application/vnd.geogebra.tool"],["ghf","application/vnd.groove-help"],["gif","image/gif"],["gim","application/vnd.groove-identity-message"],["glb","model/gltf-binary"],["gltf","model/gltf+json"],["gml","application/gml+xml"],["gmx","application/vnd.gmx"],["gnumeric","application/x-gnumeric"],["gpg","application/gpg-keys"],["gph","application/vnd.flographit"],["gpx","application/gpx+xml"],["gqf","application/vnd.grafeq"],["gqs","application/vnd.grafeq"],["gram","application/srgs"],["gramps","application/x-gramps-xml"],["gre","application/vnd.geometry-explorer"],["grv","application/vnd.groove-injector"],["grxml","application/srgs+xml"],["gsf","application/x-font-ghostscript"],["gsheet","application/vnd.google-apps.spreadsheet"],["gslides","application/vnd.google-apps.presentation"],["gtar","application/x-gtar"],["gtm","application/vnd.groove-tool-message"],["gtw","model/vnd.gtw"],["gv","text/vnd.graphviz"],["gxf","application/gxf"],["gxt","application/vnd.geonext"],["gz","application/gzip"],["gzip","application/gzip"],["h","text/x-c"],["h261","video/h261"],["h263","video/h263"],["h264","video/h264"],["hal","application/vnd.hal+xml"],["hbci","application/vnd.hbci"],["hbs","text/x-handlebars-template"],["hdd","application/x-virtualbox-hdd"],["hdf","application/x-hdf"],["heic","image/heic"],["heics","image/heic-sequence"],["heif","image/heif"],["heifs","image/heif-sequence"],["hej2","image/hej2k"],["held","application/atsc-held+xml"],["hh","text/x-c"],["hjson","application/hjson"],["hlp","application/winhlp"],["hpgl","application/vnd.hp-hpgl"],["hpid","application/vnd.hp-hpid"],["hps","application/vnd.hp-hps"],["hqx","application/mac-binhex40"],["hsj2","image/hsj2"],["htc","text/x-component"],["htke","application/vnd.kenameaapp"],["htm","text/html"],["html","text/html"],["hvd","application/vnd.yamaha.hv-dic"],["hvp","application/vnd.yamaha.hv-voice"],["hvs","application/vnd.yamaha.hv-script"],["i2g","application/vnd.intergeo"],["icc","application/vnd.iccprofile"],["ice","x-conference/x-cooltalk"],["icm","application/vnd.iccprofile"],["ico","image/x-icon"],["ics","text/calendar"],["ief","image/ief"],["ifb","text/calendar"],["ifm","application/vnd.shana.informed.formdata"],["iges","model/iges"],["igl","application/vnd.igloader"],["igm","application/vnd.insors.igm"],["igs","model/iges"],["igx","application/vnd.micrografx.igx"],["iif","application/vnd.shana.informed.interchange"],["img","application/octet-stream"],["imp","application/vnd.accpac.simply.imp"],["ims","application/vnd.ms-ims"],["in","text/plain"],["ini","text/plain"],["ink","application/inkml+xml"],["inkml","application/inkml+xml"],["install","application/x-install-instructions"],["iota","application/vnd.astraea-software.iota"],["ipfix","application/ipfix"],["ipk","application/vnd.shana.informed.package"],["irm","application/vnd.ibm.rights-management"],["irp","application/vnd.irepository.package+xml"],["iso","application/x-iso9660-image"],["itp","application/vnd.shana.informed.formtemplate"],["its","application/its+xml"],["ivp","application/vnd.immervision-ivp"],["ivu","application/vnd.immervision-ivu"],["jad","text/vnd.sun.j2me.app-descriptor"],["jade","text/jade"],["jam","application/vnd.jam"],["jar","application/java-archive"],["jardiff","application/x-java-archive-diff"],["java","text/x-java-source"],["jhc","image/jphc"],["jisp","application/vnd.jisp"],["jls","image/jls"],["jlt","application/vnd.hp-jlyt"],["jng","image/x-jng"],["jnlp","application/x-java-jnlp-file"],["joda","application/vnd.joost.joda-archive"],["jp2","image/jp2"],["jpe","image/jpeg"],["jpeg","image/jpeg"],["jpf","image/jpx"],["jpg","image/jpeg"],["jpg2","image/jp2"],["jpgm","video/jpm"],["jpgv","video/jpeg"],["jph","image/jph"],["jpm","video/jpm"],["jpx","image/jpx"],["js","application/javascript"],["json","application/json"],["json5","application/json5"],["jsonld","application/ld+json"],["jsonl","application/jsonl"],["jsonml","application/jsonml+json"],["jsx","text/jsx"],["jxr","image/jxr"],["jxra","image/jxra"],["jxrs","image/jxrs"],["jxs","image/jxs"],["jxsc","image/jxsc"],["jxsi","image/jxsi"],["jxss","image/jxss"],["kar","audio/midi"],["karbon","application/vnd.kde.karbon"],["kdb","application/octet-stream"],["kdbx","application/x-keepass2"],["key","application/x-iwork-keynote-sffkey"],["kfo","application/vnd.kde.kformula"],["kia","application/vnd.kidspiration"],["kml","application/vnd.google-earth.kml+xml"],["kmz","application/vnd.google-earth.kmz"],["kne","application/vnd.kinar"],["knp","application/vnd.kinar"],["kon","application/vnd.kde.kontour"],["kpr","application/vnd.kde.kpresenter"],["kpt","application/vnd.kde.kpresenter"],["kpxx","application/vnd.ds-keypoint"],["ksp","application/vnd.kde.kspread"],["ktr","application/vnd.kahootz"],["ktx","image/ktx"],["ktx2","image/ktx2"],["ktz","application/vnd.kahootz"],["kwd","application/vnd.kde.kword"],["kwt","application/vnd.kde.kword"],["lasxml","application/vnd.las.las+xml"],["latex","application/x-latex"],["lbd","application/vnd.llamagraphics.life-balance.desktop"],["lbe","application/vnd.llamagraphics.life-balance.exchange+xml"],["les","application/vnd.hhe.lesson-player"],["less","text/less"],["lgr","application/lgr+xml"],["lha","application/octet-stream"],["link66","application/vnd.route66.link66+xml"],["list","text/plain"],["list3820","application/vnd.ibm.modcap"],["listafp","application/vnd.ibm.modcap"],["litcoffee","text/coffeescript"],["lnk","application/x-ms-shortcut"],["log","text/plain"],["lostxml","application/lost+xml"],["lrf","application/octet-stream"],["lrm","application/vnd.ms-lrm"],["ltf","application/vnd.frogans.ltf"],["lua","text/x-lua"],["luac","application/x-lua-bytecode"],["lvp","audio/vnd.lucent.voice"],["lwp","application/vnd.lotus-wordpro"],["lzh","application/octet-stream"],["m1v","video/mpeg"],["m2a","audio/mpeg"],["m2v","video/mpeg"],["m3a","audio/mpeg"],["m3u","text/plain"],["m3u8","application/vnd.apple.mpegurl"],["m4a","audio/x-m4a"],["m4p","application/mp4"],["m4s","video/iso.segment"],["m4u","application/vnd.mpegurl"],["m4v","video/x-m4v"],["m13","application/x-msmediaview"],["m14","application/x-msmediaview"],["m21","application/mp21"],["ma","application/mathematica"],["mads","application/mads+xml"],["maei","application/mmt-aei+xml"],["mag","application/vnd.ecowin.chart"],["maker","application/vnd.framemaker"],["man","text/troff"],["manifest","text/cache-manifest"],["map","application/json"],["mar","application/octet-stream"],["markdown","text/markdown"],["mathml","application/mathml+xml"],["mb","application/mathematica"],["mbk","application/vnd.mobius.mbk"],["mbox","application/mbox"],["mc1","application/vnd.medcalcdata"],["mcd","application/vnd.mcd"],["mcurl","text/vnd.curl.mcurl"],["md","text/markdown"],["mdb","application/x-msaccess"],["mdi","image/vnd.ms-modi"],["mdx","text/mdx"],["me","text/troff"],["mesh","model/mesh"],["meta4","application/metalink4+xml"],["metalink","application/metalink+xml"],["mets","application/mets+xml"],["mfm","application/vnd.mfmp"],["mft","application/rpki-manifest"],["mgp","application/vnd.osgeo.mapguide.package"],["mgz","application/vnd.proteus.magazine"],["mid","audio/midi"],["midi","audio/midi"],["mie","application/x-mie"],["mif","application/vnd.mif"],["mime","message/rfc822"],["mj2","video/mj2"],["mjp2","video/mj2"],["mjs","application/javascript"],["mk3d","video/x-matroska"],["mka","audio/x-matroska"],["mkd","text/x-markdown"],["mks","video/x-matroska"],["mkv","video/x-matroska"],["mlp","application/vnd.dolby.mlp"],["mmd","application/vnd.chipnuts.karaoke-mmd"],["mmf","application/vnd.smaf"],["mml","text/mathml"],["mmr","image/vnd.fujixerox.edmics-mmr"],["mng","video/x-mng"],["mny","application/x-msmoney"],["mobi","application/x-mobipocket-ebook"],["mods","application/mods+xml"],["mov","video/quicktime"],["movie","video/x-sgi-movie"],["mp2","audio/mpeg"],["mp2a","audio/mpeg"],["mp3","audio/mpeg"],["mp4","video/mp4"],["mp4a","audio/mp4"],["mp4s","application/mp4"],["mp4v","video/mp4"],["mp21","application/mp21"],["mpc","application/vnd.mophun.certificate"],["mpd","application/dash+xml"],["mpe","video/mpeg"],["mpeg","video/mpeg"],["mpg","video/mpeg"],["mpg4","video/mp4"],["mpga","audio/mpeg"],["mpkg","application/vnd.apple.installer+xml"],["mpm","application/vnd.blueice.multipass"],["mpn","application/vnd.mophun.application"],["mpp","application/vnd.ms-project"],["mpt","application/vnd.ms-project"],["mpy","application/vnd.ibm.minipay"],["mqy","application/vnd.mobius.mqy"],["mrc","application/marc"],["mrcx","application/marcxml+xml"],["ms","text/troff"],["mscml","application/mediaservercontrol+xml"],["mseed","application/vnd.fdsn.mseed"],["mseq","application/vnd.mseq"],["msf","application/vnd.epson.msf"],["msg","application/vnd.ms-outlook"],["msh","model/mesh"],["msi","application/x-msdownload"],["msl","application/vnd.mobius.msl"],["msm","application/octet-stream"],["msp","application/octet-stream"],["msty","application/vnd.muvee.style"],["mtl","model/mtl"],["mts","model/vnd.mts"],["mus","application/vnd.musician"],["musd","application/mmt-usd+xml"],["musicxml","application/vnd.recordare.musicxml+xml"],["mvb","application/x-msmediaview"],["mvt","application/vnd.mapbox-vector-tile"],["mwf","application/vnd.mfer"],["mxf","application/mxf"],["mxl","application/vnd.recordare.musicxml"],["mxmf","audio/mobile-xmf"],["mxml","application/xv+xml"],["mxs","application/vnd.triscape.mxs"],["mxu","video/vnd.mpegurl"],["n-gage","application/vnd.nokia.n-gage.symbian.install"],["n3","text/n3"],["nb","application/mathematica"],["nbp","application/vnd.wolfram.player"],["nc","application/x-netcdf"],["ncx","application/x-dtbncx+xml"],["nfo","text/x-nfo"],["ngdat","application/vnd.nokia.n-gage.data"],["nitf","application/vnd.nitf"],["nlu","application/vnd.neurolanguage.nlu"],["nml","application/vnd.enliven"],["nnd","application/vnd.noblenet-directory"],["nns","application/vnd.noblenet-sealer"],["nnw","application/vnd.noblenet-web"],["npx","image/vnd.net-fpx"],["nq","application/n-quads"],["nsc","application/x-conference"],["nsf","application/vnd.lotus-notes"],["nt","application/n-triples"],["ntf","application/vnd.nitf"],["numbers","application/x-iwork-numbers-sffnumbers"],["nzb","application/x-nzb"],["oa2","application/vnd.fujitsu.oasys2"],["oa3","application/vnd.fujitsu.oasys3"],["oas","application/vnd.fujitsu.oasys"],["obd","application/x-msbinder"],["obgx","application/vnd.openblox.game+xml"],["obj","model/obj"],["oda","application/oda"],["odb","application/vnd.oasis.opendocument.database"],["odc","application/vnd.oasis.opendocument.chart"],["odf","application/vnd.oasis.opendocument.formula"],["odft","application/vnd.oasis.opendocument.formula-template"],["odg","application/vnd.oasis.opendocument.graphics"],["odi","application/vnd.oasis.opendocument.image"],["odm","application/vnd.oasis.opendocument.text-master"],["odp","application/vnd.oasis.opendocument.presentation"],["ods","application/vnd.oasis.opendocument.spreadsheet"],["odt","application/vnd.oasis.opendocument.text"],["oga","audio/ogg"],["ogex","model/vnd.opengex"],["ogg","audio/ogg"],["ogv","video/ogg"],["ogx","application/ogg"],["omdoc","application/omdoc+xml"],["onepkg","application/onenote"],["onetmp","application/onenote"],["onetoc","application/onenote"],["onetoc2","application/onenote"],["opf","application/oebps-package+xml"],["opml","text/x-opml"],["oprc","application/vnd.palm"],["opus","audio/ogg"],["org","text/x-org"],["osf","application/vnd.yamaha.openscoreformat"],["osfpvg","application/vnd.yamaha.openscoreformat.osfpvg+xml"],["osm","application/vnd.openstreetmap.data+xml"],["otc","application/vnd.oasis.opendocument.chart-template"],["otf","font/otf"],["otg","application/vnd.oasis.opendocument.graphics-template"],["oth","application/vnd.oasis.opendocument.text-web"],["oti","application/vnd.oasis.opendocument.image-template"],["otp","application/vnd.oasis.opendocument.presentation-template"],["ots","application/vnd.oasis.opendocument.spreadsheet-template"],["ott","application/vnd.oasis.opendocument.text-template"],["ova","application/x-virtualbox-ova"],["ovf","application/x-virtualbox-ovf"],["owl","application/rdf+xml"],["oxps","application/oxps"],["oxt","application/vnd.openofficeorg.extension"],["p","text/x-pascal"],["p7a","application/x-pkcs7-signature"],["p7b","application/x-pkcs7-certificates"],["p7c","application/pkcs7-mime"],["p7m","application/pkcs7-mime"],["p7r","application/x-pkcs7-certreqresp"],["p7s","application/pkcs7-signature"],["p8","application/pkcs8"],["p10","application/x-pkcs10"],["p12","application/x-pkcs12"],["pac","application/x-ns-proxy-autoconfig"],["pages","application/x-iwork-pages-sffpages"],["pas","text/x-pascal"],["paw","application/vnd.pawaafile"],["pbd","application/vnd.powerbuilder6"],["pbm","image/x-portable-bitmap"],["pcap","application/vnd.tcpdump.pcap"],["pcf","application/x-font-pcf"],["pcl","application/vnd.hp-pcl"],["pclxl","application/vnd.hp-pclxl"],["pct","image/x-pict"],["pcurl","application/vnd.curl.pcurl"],["pcx","image/x-pcx"],["pdb","application/x-pilot"],["pde","text/x-processing"],["pdf","application/pdf"],["pem","application/x-x509-user-cert"],["pfa","application/x-font-type1"],["pfb","application/x-font-type1"],["pfm","application/x-font-type1"],["pfr","application/font-tdpfr"],["pfx","application/x-pkcs12"],["pgm","image/x-portable-graymap"],["pgn","application/x-chess-pgn"],["pgp","application/pgp"],["php","application/x-httpd-php"],["php3","application/x-httpd-php"],["php4","application/x-httpd-php"],["phps","application/x-httpd-php-source"],["phtml","application/x-httpd-php"],["pic","image/x-pict"],["pkg","application/octet-stream"],["pki","application/pkixcmp"],["pkipath","application/pkix-pkipath"],["pkpass","application/vnd.apple.pkpass"],["pl","application/x-perl"],["plb","application/vnd.3gpp.pic-bw-large"],["plc","application/vnd.mobius.plc"],["plf","application/vnd.pocketlearn"],["pls","application/pls+xml"],["pm","application/x-perl"],["pml","application/vnd.ctc-posml"],["png","image/png"],["pnm","image/x-portable-anymap"],["portpkg","application/vnd.macports.portpkg"],["pot","application/vnd.ms-powerpoint"],["potm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["potx","application/vnd.openxmlformats-officedocument.presentationml.template"],["ppa","application/vnd.ms-powerpoint"],["ppam","application/vnd.ms-powerpoint.addin.macroEnabled.12"],["ppd","application/vnd.cups-ppd"],["ppm","image/x-portable-pixmap"],["pps","application/vnd.ms-powerpoint"],["ppsm","application/vnd.ms-powerpoint.slideshow.macroEnabled.12"],["ppsx","application/vnd.openxmlformats-officedocument.presentationml.slideshow"],["ppt","application/powerpoint"],["pptm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"],["pqa","application/vnd.palm"],["prc","application/x-pilot"],["pre","application/vnd.lotus-freelance"],["prf","application/pics-rules"],["provx","application/provenance+xml"],["ps","application/postscript"],["psb","application/vnd.3gpp.pic-bw-small"],["psd","application/x-photoshop"],["psf","application/x-font-linux-psf"],["pskcxml","application/pskc+xml"],["pti","image/prs.pti"],["ptid","application/vnd.pvi.ptid1"],["pub","application/x-mspublisher"],["pvb","application/vnd.3gpp.pic-bw-var"],["pwn","application/vnd.3m.post-it-notes"],["pya","audio/vnd.ms-playready.media.pya"],["pyv","video/vnd.ms-playready.media.pyv"],["qam","application/vnd.epson.quickanime"],["qbo","application/vnd.intu.qbo"],["qfx","application/vnd.intu.qfx"],["qps","application/vnd.publishare-delta-tree"],["qt","video/quicktime"],["qwd","application/vnd.quark.quarkxpress"],["qwt","application/vnd.quark.quarkxpress"],["qxb","application/vnd.quark.quarkxpress"],["qxd","application/vnd.quark.quarkxpress"],["qxl","application/vnd.quark.quarkxpress"],["qxt","application/vnd.quark.quarkxpress"],["ra","audio/x-realaudio"],["ram","audio/x-pn-realaudio"],["raml","application/raml+yaml"],["rapd","application/route-apd+xml"],["rar","application/x-rar"],["ras","image/x-cmu-raster"],["rcprofile","application/vnd.ipunplugged.rcprofile"],["rdf","application/rdf+xml"],["rdz","application/vnd.data-vision.rdz"],["relo","application/p2p-overlay+xml"],["rep","application/vnd.businessobjects"],["res","application/x-dtbresource+xml"],["rgb","image/x-rgb"],["rif","application/reginfo+xml"],["rip","audio/vnd.rip"],["ris","application/x-research-info-systems"],["rl","application/resource-lists+xml"],["rlc","image/vnd.fujixerox.edmics-rlc"],["rld","application/resource-lists-diff+xml"],["rm","audio/x-pn-realaudio"],["rmi","audio/midi"],["rmp","audio/x-pn-realaudio-plugin"],["rms","application/vnd.jcp.javame.midlet-rms"],["rmvb","application/vnd.rn-realmedia-vbr"],["rnc","application/relax-ng-compact-syntax"],["rng","application/xml"],["roa","application/rpki-roa"],["roff","text/troff"],["rp9","application/vnd.cloanto.rp9"],["rpm","audio/x-pn-realaudio-plugin"],["rpss","application/vnd.nokia.radio-presets"],["rpst","application/vnd.nokia.radio-preset"],["rq","application/sparql-query"],["rs","application/rls-services+xml"],["rsa","application/x-pkcs7"],["rsat","application/atsc-rsat+xml"],["rsd","application/rsd+xml"],["rsheet","application/urc-ressheet+xml"],["rss","application/rss+xml"],["rtf","text/rtf"],["rtx","text/richtext"],["run","application/x-makeself"],["rusd","application/route-usd+xml"],["rv","video/vnd.rn-realvideo"],["s","text/x-asm"],["s3m","audio/s3m"],["saf","application/vnd.yamaha.smaf-audio"],["sass","text/x-sass"],["sbml","application/sbml+xml"],["sc","application/vnd.ibm.secure-container"],["scd","application/x-msschedule"],["scm","application/vnd.lotus-screencam"],["scq","application/scvp-cv-request"],["scs","application/scvp-cv-response"],["scss","text/x-scss"],["scurl","text/vnd.curl.scurl"],["sda","application/vnd.stardivision.draw"],["sdc","application/vnd.stardivision.calc"],["sdd","application/vnd.stardivision.impress"],["sdkd","application/vnd.solent.sdkm+xml"],["sdkm","application/vnd.solent.sdkm+xml"],["sdp","application/sdp"],["sdw","application/vnd.stardivision.writer"],["sea","application/octet-stream"],["see","application/vnd.seemail"],["seed","application/vnd.fdsn.seed"],["sema","application/vnd.sema"],["semd","application/vnd.semd"],["semf","application/vnd.semf"],["senmlx","application/senml+xml"],["sensmlx","application/sensml+xml"],["ser","application/java-serialized-object"],["setpay","application/set-payment-initiation"],["setreg","application/set-registration-initiation"],["sfd-hdstx","application/vnd.hydrostatix.sof-data"],["sfs","application/vnd.spotfire.sfs"],["sfv","text/x-sfv"],["sgi","image/sgi"],["sgl","application/vnd.stardivision.writer-global"],["sgm","text/sgml"],["sgml","text/sgml"],["sh","application/x-sh"],["shar","application/x-shar"],["shex","text/shex"],["shf","application/shf+xml"],["shtml","text/html"],["sid","image/x-mrsid-image"],["sieve","application/sieve"],["sig","application/pgp-signature"],["sil","audio/silk"],["silo","model/mesh"],["sis","application/vnd.symbian.install"],["sisx","application/vnd.symbian.install"],["sit","application/x-stuffit"],["sitx","application/x-stuffitx"],["siv","application/sieve"],["skd","application/vnd.koan"],["skm","application/vnd.koan"],["skp","application/vnd.koan"],["skt","application/vnd.koan"],["sldm","application/vnd.ms-powerpoint.slide.macroenabled.12"],["sldx","application/vnd.openxmlformats-officedocument.presentationml.slide"],["slim","text/slim"],["slm","text/slim"],["sls","application/route-s-tsid+xml"],["slt","application/vnd.epson.salt"],["sm","application/vnd.stepmania.stepchart"],["smf","application/vnd.stardivision.math"],["smi","application/smil"],["smil","application/smil"],["smv","video/x-smv"],["smzip","application/vnd.stepmania.package"],["snd","audio/basic"],["snf","application/x-font-snf"],["so","application/octet-stream"],["spc","application/x-pkcs7-certificates"],["spdx","text/spdx"],["spf","application/vnd.yamaha.smaf-phrase"],["spl","application/x-futuresplash"],["spot","text/vnd.in3d.spot"],["spp","application/scvp-vp-response"],["spq","application/scvp-vp-request"],["spx","audio/ogg"],["sql","application/x-sql"],["src","application/x-wais-source"],["srt","application/x-subrip"],["sru","application/sru+xml"],["srx","application/sparql-results+xml"],["ssdl","application/ssdl+xml"],["sse","application/vnd.kodak-descriptor"],["ssf","application/vnd.epson.ssf"],["ssml","application/ssml+xml"],["sst","application/octet-stream"],["st","application/vnd.sailingtracker.track"],["stc","application/vnd.sun.xml.calc.template"],["std","application/vnd.sun.xml.draw.template"],["stf","application/vnd.wt.stf"],["sti","application/vnd.sun.xml.impress.template"],["stk","application/hyperstudio"],["stl","model/stl"],["stpx","model/step+xml"],["stpxz","model/step-xml+zip"],["stpz","model/step+zip"],["str","application/vnd.pg.format"],["stw","application/vnd.sun.xml.writer.template"],["styl","text/stylus"],["stylus","text/stylus"],["sub","text/vnd.dvb.subtitle"],["sus","application/vnd.sus-calendar"],["susp","application/vnd.sus-calendar"],["sv4cpio","application/x-sv4cpio"],["sv4crc","application/x-sv4crc"],["svc","application/vnd.dvb.service"],["svd","application/vnd.svd"],["svg","image/svg+xml"],["svgz","image/svg+xml"],["swa","application/x-director"],["swf","application/x-shockwave-flash"],["swi","application/vnd.aristanetworks.swi"],["swidtag","application/swid+xml"],["sxc","application/vnd.sun.xml.calc"],["sxd","application/vnd.sun.xml.draw"],["sxg","application/vnd.sun.xml.writer.global"],["sxi","application/vnd.sun.xml.impress"],["sxm","application/vnd.sun.xml.math"],["sxw","application/vnd.sun.xml.writer"],["t","text/troff"],["t3","application/x-t3vm-image"],["t38","image/t38"],["taglet","application/vnd.mynfc"],["tao","application/vnd.tao.intent-module-archive"],["tap","image/vnd.tencent.tap"],["tar","application/x-tar"],["tcap","application/vnd.3gpp2.tcap"],["tcl","application/x-tcl"],["td","application/urc-targetdesc+xml"],["teacher","application/vnd.smart.teacher"],["tei","application/tei+xml"],["teicorpus","application/tei+xml"],["tex","application/x-tex"],["texi","application/x-texinfo"],["texinfo","application/x-texinfo"],["text","text/plain"],["tfi","application/thraud+xml"],["tfm","application/x-tex-tfm"],["tfx","image/tiff-fx"],["tga","image/x-tga"],["tgz","application/x-tar"],["thmx","application/vnd.ms-officetheme"],["tif","image/tiff"],["tiff","image/tiff"],["tk","application/x-tcl"],["tmo","application/vnd.tmobile-livetv"],["toml","application/toml"],["torrent","application/x-bittorrent"],["tpl","application/vnd.groove-tool-template"],["tpt","application/vnd.trid.tpt"],["tr","text/troff"],["tra","application/vnd.trueapp"],["trig","application/trig"],["trm","application/x-msterminal"],["ts","video/mp2t"],["tsd","application/timestamped-data"],["tsv","text/tab-separated-values"],["ttc","font/collection"],["ttf","font/ttf"],["ttl","text/turtle"],["ttml","application/ttml+xml"],["twd","application/vnd.simtech-mindmapper"],["twds","application/vnd.simtech-mindmapper"],["txd","application/vnd.genomatix.tuxedo"],["txf","application/vnd.mobius.txf"],["txt","text/plain"],["u8dsn","message/global-delivery-status"],["u8hdr","message/global-headers"],["u8mdn","message/global-disposition-notification"],["u8msg","message/global"],["u32","application/x-authorware-bin"],["ubj","application/ubjson"],["udeb","application/x-debian-package"],["ufd","application/vnd.ufdl"],["ufdl","application/vnd.ufdl"],["ulx","application/x-glulx"],["umj","application/vnd.umajin"],["unityweb","application/vnd.unity"],["uoml","application/vnd.uoml+xml"],["uri","text/uri-list"],["uris","text/uri-list"],["urls","text/uri-list"],["usdz","model/vnd.usdz+zip"],["ustar","application/x-ustar"],["utz","application/vnd.uiq.theme"],["uu","text/x-uuencode"],["uva","audio/vnd.dece.audio"],["uvd","application/vnd.dece.data"],["uvf","application/vnd.dece.data"],["uvg","image/vnd.dece.graphic"],["uvh","video/vnd.dece.hd"],["uvi","image/vnd.dece.graphic"],["uvm","video/vnd.dece.mobile"],["uvp","video/vnd.dece.pd"],["uvs","video/vnd.dece.sd"],["uvt","application/vnd.dece.ttml+xml"],["uvu","video/vnd.uvvu.mp4"],["uvv","video/vnd.dece.video"],["uvva","audio/vnd.dece.audio"],["uvvd","application/vnd.dece.data"],["uvvf","application/vnd.dece.data"],["uvvg","image/vnd.dece.graphic"],["uvvh","video/vnd.dece.hd"],["uvvi","image/vnd.dece.graphic"],["uvvm","video/vnd.dece.mobile"],["uvvp","video/vnd.dece.pd"],["uvvs","video/vnd.dece.sd"],["uvvt","application/vnd.dece.ttml+xml"],["uvvu","video/vnd.uvvu.mp4"],["uvvv","video/vnd.dece.video"],["uvvx","application/vnd.dece.unspecified"],["uvvz","application/vnd.dece.zip"],["uvx","application/vnd.dece.unspecified"],["uvz","application/vnd.dece.zip"],["vbox","application/x-virtualbox-vbox"],["vbox-extpack","application/x-virtualbox-vbox-extpack"],["vcard","text/vcard"],["vcd","application/x-cdlink"],["vcf","text/x-vcard"],["vcg","application/vnd.groove-vcard"],["vcs","text/x-vcalendar"],["vcx","application/vnd.vcx"],["vdi","application/x-virtualbox-vdi"],["vds","model/vnd.sap.vds"],["vhd","application/x-virtualbox-vhd"],["vis","application/vnd.visionary"],["viv","video/vnd.vivo"],["vlc","application/videolan"],["vmdk","application/x-virtualbox-vmdk"],["vob","video/x-ms-vob"],["vor","application/vnd.stardivision.writer"],["vox","application/x-authorware-bin"],["vrml","model/vrml"],["vsd","application/vnd.visio"],["vsf","application/vnd.vsf"],["vss","application/vnd.visio"],["vst","application/vnd.visio"],["vsw","application/vnd.visio"],["vtf","image/vnd.valve.source.texture"],["vtt","text/vtt"],["vtu","model/vnd.vtu"],["vxml","application/voicexml+xml"],["w3d","application/x-director"],["wad","application/x-doom"],["wadl","application/vnd.sun.wadl+xml"],["war","application/java-archive"],["wasm","application/wasm"],["wav","audio/x-wav"],["wax","audio/x-ms-wax"],["wbmp","image/vnd.wap.wbmp"],["wbs","application/vnd.criticaltools.wbs+xml"],["wbxml","application/wbxml"],["wcm","application/vnd.ms-works"],["wdb","application/vnd.ms-works"],["wdp","image/vnd.ms-photo"],["weba","audio/webm"],["webapp","application/x-web-app-manifest+json"],["webm","video/webm"],["webmanifest","application/manifest+json"],["webp","image/webp"],["wg","application/vnd.pmi.widget"],["wgt","application/widget"],["wks","application/vnd.ms-works"],["wm","video/x-ms-wm"],["wma","audio/x-ms-wma"],["wmd","application/x-ms-wmd"],["wmf","image/wmf"],["wml","text/vnd.wap.wml"],["wmlc","application/wmlc"],["wmls","text/vnd.wap.wmlscript"],["wmlsc","application/vnd.wap.wmlscriptc"],["wmv","video/x-ms-wmv"],["wmx","video/x-ms-wmx"],["wmz","application/x-msmetafile"],["woff","font/woff"],["woff2","font/woff2"],["word","application/msword"],["wpd","application/vnd.wordperfect"],["wpl","application/vnd.ms-wpl"],["wps","application/vnd.ms-works"],["wqd","application/vnd.wqd"],["wri","application/x-mswrite"],["wrl","model/vrml"],["wsc","message/vnd.wfa.wsc"],["wsdl","application/wsdl+xml"],["wspolicy","application/wspolicy+xml"],["wtb","application/vnd.webturbo"],["wvx","video/x-ms-wvx"],["x3d","model/x3d+xml"],["x3db","model/x3d+fastinfoset"],["x3dbz","model/x3d+binary"],["x3dv","model/x3d-vrml"],["x3dvz","model/x3d+vrml"],["x3dz","model/x3d+xml"],["x32","application/x-authorware-bin"],["x_b","model/vnd.parasolid.transmit.binary"],["x_t","model/vnd.parasolid.transmit.text"],["xaml","application/xaml+xml"],["xap","application/x-silverlight-app"],["xar","application/vnd.xara"],["xav","application/xcap-att+xml"],["xbap","application/x-ms-xbap"],["xbd","application/vnd.fujixerox.docuworks.binder"],["xbm","image/x-xbitmap"],["xca","application/xcap-caps+xml"],["xcs","application/calendar+xml"],["xdf","application/xcap-diff+xml"],["xdm","application/vnd.syncml.dm+xml"],["xdp","application/vnd.adobe.xdp+xml"],["xdssc","application/dssc+xml"],["xdw","application/vnd.fujixerox.docuworks"],["xel","application/xcap-el+xml"],["xenc","application/xenc+xml"],["xer","application/patch-ops-error+xml"],["xfdf","application/vnd.adobe.xfdf"],["xfdl","application/vnd.xfdl"],["xht","application/xhtml+xml"],["xhtml","application/xhtml+xml"],["xhvml","application/xv+xml"],["xif","image/vnd.xiff"],["xl","application/excel"],["xla","application/vnd.ms-excel"],["xlam","application/vnd.ms-excel.addin.macroEnabled.12"],["xlc","application/vnd.ms-excel"],["xlf","application/xliff+xml"],["xlm","application/vnd.ms-excel"],["xls","application/vnd.ms-excel"],["xlsb","application/vnd.ms-excel.sheet.binary.macroEnabled.12"],["xlsm","application/vnd.ms-excel.sheet.macroEnabled.12"],["xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],["xlt","application/vnd.ms-excel"],["xltm","application/vnd.ms-excel.template.macroEnabled.12"],["xltx","application/vnd.openxmlformats-officedocument.spreadsheetml.template"],["xlw","application/vnd.ms-excel"],["xm","audio/xm"],["xml","application/xml"],["xns","application/xcap-ns+xml"],["xo","application/vnd.olpc-sugar"],["xop","application/xop+xml"],["xpi","application/x-xpinstall"],["xpl","application/xproc+xml"],["xpm","image/x-xpixmap"],["xpr","application/vnd.is-xpr"],["xps","application/vnd.ms-xpsdocument"],["xpw","application/vnd.intercon.formnet"],["xpx","application/vnd.intercon.formnet"],["xsd","application/xml"],["xsl","application/xml"],["xslt","application/xslt+xml"],["xsm","application/vnd.syncml+xml"],["xspf","application/xspf+xml"],["xul","application/vnd.mozilla.xul+xml"],["xvm","application/xv+xml"],["xvml","application/xv+xml"],["xwd","image/x-xwindowdump"],["xyz","chemical/x-xyz"],["xz","application/x-xz"],["yaml","text/yaml"],["yang","application/yang"],["yin","application/yin+xml"],["yml","text/yaml"],["ymp","text/x-suse-ymp"],["z","application/x-compress"],["z1","application/x-zmachine"],["z2","application/x-zmachine"],["z3","application/x-zmachine"],["z4","application/x-zmachine"],["z5","application/x-zmachine"],["z6","application/x-zmachine"],["z7","application/x-zmachine"],["z8","application/x-zmachine"],["zaz","application/vnd.zzazz.deck+xml"],["zip","application/zip"],["zir","application/vnd.zul"],["zirz","application/vnd.zul"],["zmm","application/vnd.handheld-entertainment+xml"],["zsh","text/x-scriptzsh"]]);function Nn(e,t,n){const s=Vx(e),{webkitRelativePath:o}=e,a=typeof t=="string"?t:typeof o=="string"&&o.length>0?o:`./${e.name}`;return typeof s.path!="string"&&yl(s,"path",a),yl(s,"relativePath",a),s}function Vx(e){const{name:t}=e;if(t&&t.lastIndexOf(".")!==-1&&!e.type){const s=t.split(".").pop().toLowerCase(),o=qx.get(s);o&&Object.defineProperty(e,"type",{value:o,writable:!1,configurable:!1,enumerable:!0})}return e}function yl(e,t,n){Object.defineProperty(e,t,{value:n,writable:!1,configurable:!1,enumerable:!0})}const Kx=[".DS_Store","Thumbs.db"];function Gx(e){return an(this,void 0,void 0,function*(){return Us(e)&&Jx(e.dataTransfer)?Zx(e.dataTransfer,e.type):Yx(e)?Xx(e):Array.isArray(e)&&e.every(t=>"getFile"in t&&typeof t.getFile=="function")?Qx(e):[]})}function Jx(e){return Us(e)}function Yx(e){return Us(e)&&Us(e.target)}function Us(e){return typeof e=="object"&&e!==null}function Xx(e){return ja(e.target.files).map(t=>Nn(t))}function Qx(e){return an(this,void 0,void 0,function*(){return(yield Promise.all(e.map(n=>n.getFile()))).map(n=>Nn(n))})}function Zx(e,t){return an(this,void 0,void 0,function*(){if(e.items){const n=ja(e.items).filter(o=>o.kind==="file");if(t!=="drop")return n;const s=yield Promise.all(n.map(e0));return bl(eu(s))}return bl(ja(e.files).map(n=>Nn(n)))})}function bl(e){return e.filter(t=>Kx.indexOf(t.name)===-1)}function ja(e){if(e===null)return[];const t=[];for(let n=0;n<e.length;n++){const s=e[n];t.push(s)}return t}function e0(e){if(typeof e.webkitGetAsEntry!="function")return wl(e);const t=e.webkitGetAsEntry();return t&&t.isDirectory?tu(t):wl(e,t)}function eu(e){return e.reduce((t,n)=>[...t,...Array.isArray(n)?eu(n):[n]],[])}function wl(e,t){return an(this,void 0,void 0,function*(){var n;if(globalThis.isSecureContext&&typeof e.getAsFileSystemHandle=="function"){const a=yield e.getAsFileSystemHandle();if(a===null)throw new Error(`${e} is not a File`);if(a!==void 0){const i=yield a.getFile();return i.handle=a,Nn(i)}}const s=e.getAsFile();if(!s)throw new Error(`${e} is not a File`);return Nn(s,(n=t?.fullPath)!==null&&n!==void 0?n:void 0)})}function t0(e){return an(this,void 0,void 0,function*(){return e.isDirectory?tu(e):r0(e)})}function tu(e){const t=e.createReader();return new Promise((n,s)=>{const o=[];function a(){t.readEntries(i=>an(this,void 0,void 0,function*(){if(i.length){const c=Promise.all(i.map(t0));o.push(c),a()}else try{const c=yield Promise.all(o);n(c)}catch(c){s(c)}}),i=>{s(i)})}a()})}function r0(e){return an(this,void 0,void 0,function*(){return new Promise((t,n)=>{e.file(s=>{const o=Nn(s,e.fullPath);t(o)},s=>{n(s)})})})}var Ss={},kl;function n0(){return kl||(kl=1,Ss.__esModule=!0,Ss.default=function(e,t){if(e&&t){var n=Array.isArray(t)?t:t.split(",");if(n.length===0)return!0;var s=e.name||"",o=(e.type||"").toLowerCase(),a=o.replace(/\/.*$/,"");return n.some(function(i){var c=i.trim().toLowerCase();return c.charAt(0)==="."?s.toLowerCase().endsWith(c):c.endsWith("/*")?a===c.replace(/\/.*$/,""):o===c})}return!0}),Ss}var s0=n0();const ra=Ec(s0);function jl(e){return i0(e)||a0(e)||nu(e)||o0()}function o0(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
232
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function a0(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function i0(e){if(Array.isArray(e))return Sa(e)}function Sl(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,s)}return n}function Nl(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Sl(Object(n),!0).forEach(function(s){ru(e,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Sl(Object(n)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(n,s))})}return e}function ru(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function qn(e,t){return d0(e)||c0(e,t)||nu(e,t)||l0()}function l0(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
233
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function nu(e,t){if(e){if(typeof e=="string")return Sa(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Sa(e,t)}}function Sa(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,s=new Array(t);n<t;n++)s[n]=e[n];return s}function c0(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var s=[],o=!0,a=!1,i,c;try{for(n=n.call(e);!(o=(i=n.next()).done)&&(s.push(i.value),!(t&&s.length===t));o=!0);}catch(d){a=!0,c=d}finally{try{!o&&n.return!=null&&n.return()}finally{if(a)throw c}}return s}}function d0(e){if(Array.isArray(e))return e}var u0=typeof ra=="function"?ra:ra.default,p0="file-invalid-type",m0="file-too-large",f0="file-too-small",h0="too-many-files",g0=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",n=t.split(","),s=n.length>1?"one of ".concat(n.join(", ")):n[0];return{code:p0,message:"File type must be ".concat(s)}},Cl=function(t){return{code:m0,message:"File is larger than ".concat(t," ").concat(t===1?"byte":"bytes")}},El=function(t){return{code:f0,message:"File is smaller than ".concat(t," ").concat(t===1?"byte":"bytes")}},x0={code:h0,message:"Too many files"};function su(e,t){var n=e.type==="application/x-moz-file"||u0(e,t);return[n,n?null:g0(t)]}function ou(e,t,n){if(Zr(e.size))if(Zr(t)&&Zr(n)){if(e.size>n)return[!1,Cl(n)];if(e.size<t)return[!1,El(t)]}else{if(Zr(t)&&e.size<t)return[!1,El(t)];if(Zr(n)&&e.size>n)return[!1,Cl(n)]}return[!0,null]}function Zr(e){return e!=null}function v0(e){var t=e.files,n=e.accept,s=e.minSize,o=e.maxSize,a=e.multiple,i=e.maxFiles,c=e.validator;return!a&&t.length>1||a&&i>=1&&t.length>i?!1:t.every(function(d){var u=su(d,n),p=qn(u,1),m=p[0],h=ou(d,s,o),g=qn(h,1),x=g[0],S=c?c(d):null;return m&&x&&!S})}function Ws(e){return typeof e.isPropagationStopped=="function"?e.isPropagationStopped():typeof e.cancelBubble<"u"?e.cancelBubble:!1}function Ns(e){return e.dataTransfer?Array.prototype.some.call(e.dataTransfer.types,function(t){return t==="Files"||t==="application/x-moz-file"}):!!e.target&&!!e.target.files}function Il(e){e.preventDefault()}function y0(e){return e.indexOf("MSIE")!==-1||e.indexOf("Trident/")!==-1}function b0(e){return e.indexOf("Edge/")!==-1}function w0(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return y0(e)||b0(e)}function gr(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(s){for(var o=arguments.length,a=new Array(o>1?o-1:0),i=1;i<o;i++)a[i-1]=arguments[i];return t.some(function(c){return!Ws(s)&&c&&c.apply(void 0,[s].concat(a)),Ws(s)})}}function k0(){return"showOpenFilePicker"in window}function j0(e){if(Zr(e)){var t=Object.entries(e).filter(function(n){var s=qn(n,2),o=s[0],a=s[1],i=!0;return au(o)||(console.warn('Skipped "'.concat(o,'" because it is not a valid MIME type. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types for a list of valid MIME types.')),i=!1),(!Array.isArray(a)||!a.every(iu))&&(console.warn('Skipped "'.concat(o,'" because an invalid file extension was provided.')),i=!1),i}).reduce(function(n,s){var o=qn(s,2),a=o[0],i=o[1];return Nl(Nl({},n),{},ru({},a,i))},{});return[{description:"Files",accept:t}]}return e}function S0(e){if(Zr(e))return Object.entries(e).reduce(function(t,n){var s=qn(n,2),o=s[0],a=s[1];return[].concat(jl(t),[o],jl(a))},[]).filter(function(t){return au(t)||iu(t)}).join(",")}function N0(e){return e instanceof DOMException&&(e.name==="AbortError"||e.code===e.ABORT_ERR)}function C0(e){return e instanceof DOMException&&(e.name==="SecurityError"||e.code===e.SECURITY_ERR)}function au(e){return e==="audio/*"||e==="video/*"||e==="image/*"||e==="text/*"||e==="application/*"||/\w+\/[-+.\w]+/g.test(e)}function iu(e){return/^.*\.[\w]+$/.test(e)}var E0=["children"],I0=["open"],A0=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],T0=["refKey","onChange","onClick"];function _0(e){return R0(e)||D0(e)||lu(e)||M0()}function M0(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
234
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function D0(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function R0(e){if(Array.isArray(e))return Na(e)}function na(e,t){return O0(e)||L0(e,t)||lu(e,t)||P0()}function P0(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
235
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function lu(e,t){if(e){if(typeof e=="string")return Na(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Na(e,t)}}function Na(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,s=new Array(t);n<t;n++)s[n]=e[n];return s}function L0(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var s=[],o=!0,a=!1,i,c;try{for(n=n.call(e);!(o=(i=n.next()).done)&&(s.push(i.value),!(t&&s.length===t));o=!0);}catch(d){a=!0,c=d}finally{try{!o&&n.return!=null&&n.return()}finally{if(a)throw c}}return s}}function O0(e){if(Array.isArray(e))return e}function Al(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,s)}return n}function wt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Al(Object(n),!0).forEach(function(s){Ca(e,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Al(Object(n)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(n,s))})}return e}function Ca(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Hs(e,t){if(e==null)return{};var n=F0(e,t),s,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)s=a[o],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(n[s]=e[s])}return n}function F0(e,t){if(e==null)return{};var n={},s=Object.keys(e),o,a;for(a=0;a<s.length;a++)o=s[a],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}var li=l.forwardRef(function(e,t){var n=e.children,s=Hs(e,E0),o=du(s),a=o.open,i=Hs(o,I0);return l.useImperativeHandle(t,function(){return{open:a}},[a]),Tn.createElement(l.Fragment,null,n(wt(wt({},i),{},{open:a})))});li.displayName="Dropzone";var cu={disabled:!1,getFilesFromEvent:Gx,maxSize:1/0,minSize:0,multiple:!0,maxFiles:0,preventDropOnDocument:!0,noClick:!1,noKeyboard:!1,noDrag:!1,noDragEventsBubbling:!1,validator:null,useFsAccessApi:!1,autoFocus:!1};li.defaultProps=cu;li.propTypes={children:at.func,accept:at.objectOf(at.arrayOf(at.string)),multiple:at.bool,preventDropOnDocument:at.bool,noClick:at.bool,noKeyboard:at.bool,noDrag:at.bool,noDragEventsBubbling:at.bool,minSize:at.number,maxSize:at.number,maxFiles:at.number,disabled:at.bool,getFilesFromEvent:at.func,onFileDialogCancel:at.func,onFileDialogOpen:at.func,useFsAccessApi:at.bool,autoFocus:at.bool,onDragEnter:at.func,onDragLeave:at.func,onDragOver:at.func,onDrop:at.func,onDropAccepted:at.func,onDropRejected:at.func,onError:at.func,validator:at.func};var Ea={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,acceptedFiles:[],fileRejections:[]};function du(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=wt(wt({},cu),e),n=t.accept,s=t.disabled,o=t.getFilesFromEvent,a=t.maxSize,i=t.minSize,c=t.multiple,d=t.maxFiles,u=t.onDragEnter,p=t.onDragLeave,m=t.onDragOver,h=t.onDrop,g=t.onDropAccepted,x=t.onDropRejected,S=t.onFileDialogCancel,k=t.onFileDialogOpen,I=t.useFsAccessApi,A=t.autoFocus,w=t.preventDropOnDocument,M=t.noClick,C=t.noKeyboard,b=t.noDrag,R=t.noDragEventsBubbling,B=t.onError,D=t.validator,Z=l.useMemo(function(){return S0(n)},[n]),z=l.useMemo(function(){return j0(n)},[n]),X=l.useMemo(function(){return typeof k=="function"?k:Tl},[k]),q=l.useMemo(function(){return typeof S=="function"?S:Tl},[S]),re=l.useRef(null),Se=l.useRef(null),Ce=l.useReducer($0,Ea),ye=na(Ce,2),de=ye[0],H=ye[1],Oe=de.isFocused,$=de.isFileDialogActive,N=l.useRef(typeof window<"u"&&window.isSecureContext&&I&&k0()),O=function(){!N.current&&$&&setTimeout(function(){if(Se.current){var oe=Se.current.files;oe.length||(H({type:"closeDialog"}),q())}},300)};l.useEffect(function(){return window.addEventListener("focus",O,!1),function(){window.removeEventListener("focus",O,!1)}},[Se,$,q,N]);var ne=l.useRef([]),ke=function(oe){re.current&&re.current.contains(oe.target)||(oe.preventDefault(),ne.current=[])};l.useEffect(function(){return w&&(document.addEventListener("dragover",Il,!1),document.addEventListener("drop",ke,!1)),function(){w&&(document.removeEventListener("dragover",Il),document.removeEventListener("drop",ke))}},[re,w]),l.useEffect(function(){return!s&&A&&re.current&&re.current.focus(),function(){}},[re,A,s]);var ge=l.useCallback(function(Y){B?B(Y):console.error(Y)},[B]),P=l.useCallback(function(Y){Y.preventDefault(),Y.persist(),Ve(Y),ne.current=[].concat(_0(ne.current),[Y.target]),Ns(Y)&&Promise.resolve(o(Y)).then(function(oe){if(!(Ws(Y)&&!R)){var Ee=oe.length,Te=Ee>0&&v0({files:oe,accept:Z,minSize:i,maxSize:a,multiple:c,maxFiles:d,validator:D}),Fe=Ee>0&&!Te;H({isDragAccept:Te,isDragReject:Fe,isDragActive:!0,type:"setDraggedFiles"}),u&&u(Y)}}).catch(function(oe){return ge(oe)})},[o,u,ge,R,Z,i,a,c,d,D]),ie=l.useCallback(function(Y){Y.preventDefault(),Y.persist(),Ve(Y);var oe=Ns(Y);if(oe&&Y.dataTransfer)try{Y.dataTransfer.dropEffect="copy"}catch{}return oe&&m&&m(Y),!1},[m,R]),ee=l.useCallback(function(Y){Y.preventDefault(),Y.persist(),Ve(Y);var oe=ne.current.filter(function(Te){return re.current&&re.current.contains(Te)}),Ee=oe.indexOf(Y.target);Ee!==-1&&oe.splice(Ee,1),ne.current=oe,!(oe.length>0)&&(H({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),Ns(Y)&&p&&p(Y))},[re,p,R]),Ne=l.useCallback(function(Y,oe){var Ee=[],Te=[];Y.forEach(function(Fe){var tt=su(Fe,Z),ue=na(tt,2),dt=ue[0],Ye=ue[1],Qe=ou(Fe,i,a),ze=na(Qe,2),Lt=ze[0],Nt=ze[1],xt=D?D(Fe):null;if(dt&&Lt&&!xt)Ee.push(Fe);else{var $t=[Ye,Nt];xt&&($t=$t.concat(xt)),Te.push({file:Fe,errors:$t.filter(function(rt){return rt})})}}),(!c&&Ee.length>1||c&&d>=1&&Ee.length>d)&&(Ee.forEach(function(Fe){Te.push({file:Fe,errors:[x0]})}),Ee.splice(0)),H({acceptedFiles:Ee,fileRejections:Te,isDragReject:Te.length>0,type:"setFiles"}),h&&h(Ee,Te,oe),Te.length>0&&x&&x(Te,oe),Ee.length>0&&g&&g(Ee,oe)},[H,c,Z,i,a,d,h,g,x,D]),it=l.useCallback(function(Y){Y.preventDefault(),Y.persist(),Ve(Y),ne.current=[],Ns(Y)&&Promise.resolve(o(Y)).then(function(oe){Ws(Y)&&!R||Ne(oe,Y)}).catch(function(oe){return ge(oe)}),H({type:"reset"})},[o,Ne,ge,R]),Ke=l.useCallback(function(){if(N.current){H({type:"openDialog"}),X();var Y={multiple:c,types:z};window.showOpenFilePicker(Y).then(function(oe){return o(oe)}).then(function(oe){Ne(oe,null),H({type:"closeDialog"})}).catch(function(oe){N0(oe)?(q(oe),H({type:"closeDialog"})):C0(oe)?(N.current=!1,Se.current?(Se.current.value=null,Se.current.click()):ge(new Error("Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided."))):ge(oe)});return}Se.current&&(H({type:"openDialog"}),X(),Se.current.value=null,Se.current.click())},[H,X,q,I,Ne,ge,z,c]),Ge=l.useCallback(function(Y){!re.current||!re.current.isEqualNode(Y.target)||(Y.key===" "||Y.key==="Enter"||Y.keyCode===32||Y.keyCode===13)&&(Y.preventDefault(),Ke())},[re,Ke]),qe=l.useCallback(function(){H({type:"focus"})},[]),lt=l.useCallback(function(){H({type:"blur"})},[]),It=l.useCallback(function(){M||(w0()?setTimeout(Ke,0):Ke())},[M,Ke]),Xe=function(oe){return s?null:oe},kt=function(oe){return C?null:Xe(oe)},je=function(oe){return b?null:Xe(oe)},Ve=function(oe){R&&oe.stopPropagation()},jt=l.useMemo(function(){return function(){var Y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},oe=Y.refKey,Ee=oe===void 0?"ref":oe,Te=Y.role,Fe=Y.onKeyDown,tt=Y.onFocus,ue=Y.onBlur,dt=Y.onClick,Ye=Y.onDragEnter,Qe=Y.onDragOver,ze=Y.onDragLeave,Lt=Y.onDrop,Nt=Hs(Y,A0);return wt(wt(Ca({onKeyDown:kt(gr(Fe,Ge)),onFocus:kt(gr(tt,qe)),onBlur:kt(gr(ue,lt)),onClick:Xe(gr(dt,It)),onDragEnter:je(gr(Ye,P)),onDragOver:je(gr(Qe,ie)),onDragLeave:je(gr(ze,ee)),onDrop:je(gr(Lt,it)),role:typeof Te=="string"&&Te!==""?Te:"presentation"},Ee,re),!s&&!C?{tabIndex:0}:{}),Nt)}},[re,Ge,qe,lt,It,P,ie,ee,it,C,b,s]),St=l.useCallback(function(Y){Y.stopPropagation()},[]),Dt=l.useMemo(function(){return function(){var Y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},oe=Y.refKey,Ee=oe===void 0?"ref":oe,Te=Y.onChange,Fe=Y.onClick,tt=Hs(Y,T0),ue=Ca({accept:Z,multiple:c,type:"file",style:{border:0,clip:"rect(0, 0, 0, 0)",clipPath:"inset(50%)",height:"1px",margin:"0 -1px -1px 0",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap"},onChange:Xe(gr(Te,it)),onClick:Xe(gr(Fe,St)),tabIndex:-1},Ee,Se);return wt(wt({},ue),tt)}},[Se,n,c,it,s]);return wt(wt({},de),{},{isFocused:Oe&&!s,getRootProps:jt,getInputProps:Dt,rootRef:re,inputRef:Se,open:Xe(Ke)})}function $0(e,t){switch(t.type){case"focus":return wt(wt({},e),{},{isFocused:!0});case"blur":return wt(wt({},e),{},{isFocused:!1});case"openDialog":return wt(wt({},Ea),{},{isFileDialogActive:!0});case"closeDialog":return wt(wt({},e),{},{isFileDialogActive:!1});case"setDraggedFiles":return wt(wt({},e),{},{isDragActive:t.isDragActive,isDragAccept:t.isDragAccept,isDragReject:t.isDragReject});case"setFiles":return wt(wt({},e),{},{acceptedFiles:t.acceptedFiles,fileRejections:t.fileRejections,isDragReject:t.isDragReject});case"reset":return wt({},Ea);default:return e}}function Tl(){}const Cs=({children:e,content:t,position:n="top",className:s="",delay:o=500})=>{const[a,i]=l.useState(!1),[c,d]=l.useState(null),u=()=>{const g=setTimeout(()=>{i(!0)},o);d(g)},p=()=>{c&&(clearTimeout(c),d(null)),i(!1)},m=()=>{switch(n){case"top":return"bottom-full left-1/2 transform -translate-x-1/2 mb-2";case"bottom":return"top-full left-1/2 transform -translate-x-1/2 mt-2";case"left":return"right-full top-1/2 transform -translate-y-1/2 mr-2";case"right":return"left-full top-1/2 transform -translate-y-1/2 ml-2";default:return"bottom-full left-1/2 transform -translate-x-1/2 mb-2"}},h=()=>{switch(n){case"top":return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100";case"bottom":return"bottom-full left-1/2 transform -translate-x-1/2 border-b-gray-900 dark:border-b-gray-100";case"left":return"left-full top-1/2 transform -translate-y-1/2 border-l-gray-900 dark:border-l-gray-100";case"right":return"right-full top-1/2 transform -translate-y-1/2 border-r-gray-900 dark:border-r-gray-100";default:return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100"}};return t?r.jsxs("div",{className:"relative inline-block",onMouseEnter:u,onMouseLeave:p,children:[e,a&&r.jsxs("div",{className:st("absolute z-50 w-max max-w-[min(32rem,calc(100vw-2rem))] px-2 py-1 text-xs font-medium text-white bg-gray-900 dark:bg-gray-100 dark:text-gray-900 rounded shadow-lg whitespace-normal break-words pointer-events-none","animate-in fade-in-0 zoom-in-95 duration-200",m(),s),children:[t,r.jsx("div",{className:st("absolute w-0 h-0 border-4 border-transparent",h())})]})]}):e};function B0(e){if(typeof e=="string")return e;if(e==null)return"";try{return JSON.stringify(e,null,2)}catch{return String(e)}}function _l(e){return e==null?null:typeof e=="string"?{content:e,isError:!1,toolUseResult:null}:{content:B0(e.content??e.output??e.result??""),isError:!!e.isError,toolUseResult:e.toolUseResult||null,exitCode:e.exitCode??e.exit_code}}function Ml(e,t){return e||""}function z0(e){const t=String(e||"").replace(/\\\s*\n\s*/g," ").trim();if(!t)return"";const s=t.split(/\s*(?:&&|\|\||;|\|)\s*/).map(o=>o.trim()).filter(Boolean).map(o=>o.split(/\s+/)[0]).filter(Boolean);return s.length===0?t:s.slice(0,4).join(" · ")+(s.length>4?"…":"")}function U0(e,t,n){return t?.file_path?t.file_path:t?.path?t.path:e==="Read"&&typeof n=="string"?n:""}function W0(e,t,n,s){const o=U0(e,t,t),a=Ml(o);if(e==="Bash"){const i=t?.command||"";return{activityKind:"command",title:s("activity.actions.runCommand"),summary:z0(i)||s("activity.actions.commandPending"),filePath:o,icon:Gf,heavy:!0}}if(e==="Grep"||e==="Glob"){const i=t?.pattern||t?.glob||"",c=Ml(t?.path||""),d=[];return i&&d.push(i),c&&d.push(c),{activityKind:"search",title:s("activity.actions.searchContent"),summary:d.join(" · ")||s("activity.actions.searchPending"),filePath:t?.path||"",icon:va,heavy:!1}}return e==="Read"?{activityKind:"read",title:s("activity.actions.readFile"),summary:a||s("activity.actions.readPending"),filePath:o,icon:df,heavy:!1}:e==="Edit"||e==="ApplyPatch"?{activityKind:"edit",title:s("activity.actions.updateFile"),summary:a||s("activity.actions.filePending"),filePath:o,icon:of,heavy:!0}:e==="Write"?{activityKind:"write",title:s("activity.actions.createFile"),summary:a||s("activity.actions.filePending"),filePath:o,icon:lf,heavy:!0}:e==="TodoWrite"?{activityKind:"todo-write",title:s("activity.actions.updateTodo"),summary:s("activity.actions.todoSummary"),filePath:"",icon:il,heavy:!0}:e==="TodoRead"?{activityKind:"todo-read",title:s("activity.actions.readTodo"),summary:s("activity.actions.todoSummary"),filePath:"",icon:il,heavy:!1}:e==="exit_plan_mode"?{activityKind:"plan",title:s("activity.actions.generatePlan"),summary:s("activity.actions.planSummary"),filePath:"",icon:Ya,heavy:!0}:{activityKind:"tool",title:s("activity.actions.runTool"),summary:e,filePath:o,icon:th,heavy:!0}}function H0({children:e,tone:t="default"}){const n=t==="danger"?"border-red-200/70 bg-red-50/80 text-red-900 dark:border-red-900/70 dark:bg-red-950/20 dark:text-red-100":"border-border/70 bg-muted/40 text-foreground";return r.jsx("pre",{className:st("overflow-x-auto rounded-lg border px-3 py-2 text-xs whitespace-pre-wrap break-words font-mono",n),children:e})}function q0({status:e,messages:t=[],pendingPermissionRequests:n=[],t:s}){if(n.length>0){const a=n[0];return{phaseText:s("activity.stage.waitingPermission"),detailText:s("activity.requestTool",{tool:a.toolName||s("messageTypes.tool")}),canAbort:!0,startedAt:e?.startedAt||Date.now()}}const o=[...t].reverse().find(a=>a?.isToolUse);if(o&&!_l(o.toolResult)){const a=Ga(o.toolInput)||{},i=_l(o.toolResult),c=W0(o.toolName,a,null,s);return{phaseText:i?.isError?s("activity.stage.toolFailed"):c.activityKind==="search"?s("activity.stage.searching"):c.activityKind==="command"?s("activity.stage.runningCommand"):c.activityKind==="edit"||c.activityKind==="write"?s("activity.stage.editingFile"):c.activityKind==="read"?s("activity.stage.readingFile"):c.activityKind.startsWith("todo")?s("activity.stage.updatingTodo"):s("activity.stage.working"),detailText:c.summary,canAbort:e?.canAbort??!0,startedAt:e?.startedAt||Date.now()}}return e||null}function V0({request:e,permissionEntry:t,alreadyAllowed:n,rawInput:s,onAllowOnce:o,onAllowRemember:a,onDeny:i,className:c}){const{t:d}=Mt("chat"),u=d(n?"activity.permission.rememberSaved":"activity.permission.remember"),p=Tc(e.toolName);return r.jsx("div",{className:st("rounded-2xl border border-amber-200/80 bg-amber-50/85 p-4 shadow-sm dark:border-amber-900/70 dark:bg-amber-950/20",c),children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-200",children:r.jsx(Nm,{className:"h-4 w-4"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsx("div",{className:"text-sm font-semibold text-amber-950 dark:text-amber-100",children:d("activity.permission.title")}),r.jsx("span",{className:"rounded-full border border-amber-300/70 px-2 py-0.5 text-[11px] text-amber-700 dark:border-amber-800 dark:text-amber-200",children:p})]}),r.jsx("div",{className:"mt-1 text-xs text-amber-800 dark:text-amber-200",children:d("activity.requestTool",{tool:p||d("messageTypes.tool")})}),t?r.jsxs("div",{className:"mt-2 text-xs text-amber-700/90 dark:text-amber-300/80",children:[d("activity.permission.rule")," ",r.jsx("span",{className:"font-mono",children:t})]}):null,s?r.jsxs("details",{className:"mt-3 group",children:[r.jsxs("summary",{className:"flex cursor-pointer items-center gap-2 text-xs font-medium text-amber-800 transition-colors hover:text-amber-900 dark:text-amber-200 dark:hover:text-amber-100",children:[r.jsx(Ar,{className:"h-3.5 w-3.5 transition-transform group-open:rotate-180"}),d("activity.permission.viewInput")]}),r.jsx(H0,{tone:"default",children:s})]}):null,r.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[r.jsx("button",{type:"button",onClick:o,className:"inline-flex items-center gap-2 rounded-md bg-amber-600 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-amber-700",children:d("activity.permission.allowOnce")}),r.jsx("button",{type:"button",onClick:a,disabled:!t,className:st("inline-flex items-center gap-2 rounded-md border px-3 py-1.5 text-xs font-medium transition-colors",t?"border-amber-300 text-amber-800 hover:bg-amber-100 dark:border-amber-800 dark:text-amber-100 dark:hover:bg-amber-900/30":"cursor-not-allowed border-border text-muted-foreground opacity-60"),children:u}),r.jsx("button",{type:"button",onClick:i,className:"inline-flex items-center gap-2 rounded-md border border-red-300 px-3 py-1.5 text-xs font-medium text-red-700 transition-colors hover:bg-red-50 dark:border-red-900 dark:text-red-200 dark:hover:bg-red-950/20",children:d("activity.permission.deny")})]})]})]})})}function _r(e){return Array.isArray?Array.isArray(e):mu(e)==="[object Array]"}function K0(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function G0(e){return e==null?"":K0(e)}function yr(e){return typeof e=="string"}function uu(e){return typeof e=="number"}function J0(e){return e===!0||e===!1||Y0(e)&&mu(e)=="[object Boolean]"}function pu(e){return typeof e=="object"}function Y0(e){return pu(e)&&e!==null}function Yt(e){return e!=null}function sa(e){return!e.trim().length}function mu(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const X0="Incorrect 'index' type",Q0=e=>`Invalid value for key ${e}`,Z0=e=>`Pattern length exceeds max of ${e}.`,ev=e=>`Missing ${e} property in key`,tv=e=>`Property 'weight' in key '${e}' must be a positive integer`,Dl=Object.prototype.hasOwnProperty;class rv{constructor(t){this._keys=[],this._keyMap={};let n=0;t.forEach(s=>{let o=fu(s);this._keys.push(o),this._keyMap[o.id]=o,n+=o.weight}),this._keys.forEach(s=>{s.weight/=n})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function fu(e){let t=null,n=null,s=null,o=1,a=null;if(yr(e)||_r(e))s=e,t=Rl(e),n=Ia(e);else{if(!Dl.call(e,"name"))throw new Error(ev("name"));const i=e.name;if(s=i,Dl.call(e,"weight")&&(o=e.weight,o<=0))throw new Error(tv(i));t=Rl(i),n=Ia(i),a=e.getFn}return{path:t,id:n,weight:o,src:s,getFn:a}}function Rl(e){return _r(e)?e:e.split(".")}function Ia(e){return _r(e)?e.join("."):e}function nv(e,t){let n=[],s=!1;const o=(a,i,c)=>{if(Yt(a))if(!i[c])n.push(a);else{let d=i[c];const u=a[d];if(!Yt(u))return;if(c===i.length-1&&(yr(u)||uu(u)||J0(u)))n.push(G0(u));else if(_r(u)){s=!0;for(let p=0,m=u.length;p<m;p+=1)o(u[p],i,c+1)}else i.length&&o(u,i,c+1)}};return o(e,yr(t)?t.split("."):t,0),s?n:n[0]}const sv={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},ov={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1},av={location:0,threshold:.6,distance:100},iv={useExtendedSearch:!1,getFn:nv,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var Ae={...ov,...sv,...av,...iv};const lv=/[^ ]+/g;function cv(e=1,t=3){const n=new Map,s=Math.pow(10,t);return{get(o){const a=o.match(lv).length;if(n.has(a))return n.get(a);const i=1/Math.pow(a,.5*e),c=parseFloat(Math.round(i*s)/s);return n.set(a,c),c},clear(){n.clear()}}}class ci{constructor({getFn:t=Ae.getFn,fieldNormWeight:n=Ae.fieldNormWeight}={}){this.norm=cv(n,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((n,s)=>{this._keysMap[n.id]=s})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,yr(this.docs[0])?this.docs.forEach((t,n)=>{this._addString(t,n)}):this.docs.forEach((t,n)=>{this._addObject(t,n)}),this.norm.clear())}add(t){const n=this.size();yr(t)?this._addString(t,n):this._addObject(t,n)}removeAt(t){this.records.splice(t,1);for(let n=t,s=this.size();n<s;n+=1)this.records[n].i-=1}getValueForItemAtKeyId(t,n){return t[this._keysMap[n]]}size(){return this.records.length}_addString(t,n){if(!Yt(t)||sa(t))return;let s={v:t,i:n,n:this.norm.get(t)};this.records.push(s)}_addObject(t,n){let s={i:n,$:{}};this.keys.forEach((o,a)=>{let i=o.getFn?o.getFn(t):this.getFn(t,o.path);if(Yt(i)){if(_r(i)){let c=[];const d=[{nestedArrIndex:-1,value:i}];for(;d.length;){const{nestedArrIndex:u,value:p}=d.pop();if(Yt(p))if(yr(p)&&!sa(p)){let m={v:p,i:u,n:this.norm.get(p)};c.push(m)}else _r(p)&&p.forEach((m,h)=>{d.push({nestedArrIndex:h,value:m})})}s.$[a]=c}else if(yr(i)&&!sa(i)){let c={v:i,n:this.norm.get(i)};s.$[a]=c}}}),this.records.push(s)}toJSON(){return{keys:this.keys,records:this.records}}}function hu(e,t,{getFn:n=Ae.getFn,fieldNormWeight:s=Ae.fieldNormWeight}={}){const o=new ci({getFn:n,fieldNormWeight:s});return o.setKeys(e.map(fu)),o.setSources(t),o.create(),o}function dv(e,{getFn:t=Ae.getFn,fieldNormWeight:n=Ae.fieldNormWeight}={}){const{keys:s,records:o}=e,a=new ci({getFn:t,fieldNormWeight:n});return a.setKeys(s),a.setIndexRecords(o),a}function Es(e,{errors:t=0,currentLocation:n=0,expectedLocation:s=0,distance:o=Ae.distance,ignoreLocation:a=Ae.ignoreLocation}={}){const i=t/e.length;if(a)return i;const c=Math.abs(s-n);return o?i+c/o:c?1:i}function uv(e=[],t=Ae.minMatchCharLength){let n=[],s=-1,o=-1,a=0;for(let i=e.length;a<i;a+=1){let c=e[a];c&&s===-1?s=a:!c&&s!==-1&&(o=a-1,o-s+1>=t&&n.push([s,o]),s=-1)}return e[a-1]&&a-s>=t&&n.push([s,a-1]),n}const en=32;function pv(e,t,n,{location:s=Ae.location,distance:o=Ae.distance,threshold:a=Ae.threshold,findAllMatches:i=Ae.findAllMatches,minMatchCharLength:c=Ae.minMatchCharLength,includeMatches:d=Ae.includeMatches,ignoreLocation:u=Ae.ignoreLocation}={}){if(t.length>en)throw new Error(Z0(en));const p=t.length,m=e.length,h=Math.max(0,Math.min(s,m));let g=a,x=h;const S=c>1||d,k=S?Array(m):[];let I;for(;(I=e.indexOf(t,x))>-1;){let R=Es(t,{currentLocation:I,expectedLocation:h,distance:o,ignoreLocation:u});if(g=Math.min(R,g),x=I+p,S){let B=0;for(;B<p;)k[I+B]=1,B+=1}}x=-1;let A=[],w=1,M=p+m;const C=1<<p-1;for(let R=0;R<p;R+=1){let B=0,D=M;for(;B<D;)Es(t,{errors:R,currentLocation:h+D,expectedLocation:h,distance:o,ignoreLocation:u})<=g?B=D:M=D,D=Math.floor((M-B)/2+B);M=D;let Z=Math.max(1,h-D+1),z=i?m:Math.min(h+D,m)+p,X=Array(z+2);X[z+1]=(1<<R)-1;for(let re=z;re>=Z;re-=1){let Se=re-1,Ce=n[e.charAt(Se)];if(S&&(k[Se]=+!!Ce),X[re]=(X[re+1]<<1|1)&Ce,R&&(X[re]|=(A[re+1]|A[re])<<1|1|A[re+1]),X[re]&C&&(w=Es(t,{errors:R,currentLocation:Se,expectedLocation:h,distance:o,ignoreLocation:u}),w<=g)){if(g=w,x=Se,x<=h)break;Z=Math.max(1,2*h-x)}}if(Es(t,{errors:R+1,currentLocation:h,expectedLocation:h,distance:o,ignoreLocation:u})>g)break;A=X}const b={isMatch:x>=0,score:Math.max(.001,w)};if(S){const R=uv(k,c);R.length?d&&(b.indices=R):b.isMatch=!1}return b}function mv(e){let t={};for(let n=0,s=e.length;n<s;n+=1){const o=e.charAt(n);t[o]=(t[o]||0)|1<<s-n-1}return t}const qs=String.prototype.normalize?e=>e.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,""):e=>e;class gu{constructor(t,{location:n=Ae.location,threshold:s=Ae.threshold,distance:o=Ae.distance,includeMatches:a=Ae.includeMatches,findAllMatches:i=Ae.findAllMatches,minMatchCharLength:c=Ae.minMatchCharLength,isCaseSensitive:d=Ae.isCaseSensitive,ignoreDiacritics:u=Ae.ignoreDiacritics,ignoreLocation:p=Ae.ignoreLocation}={}){if(this.options={location:n,threshold:s,distance:o,includeMatches:a,findAllMatches:i,minMatchCharLength:c,isCaseSensitive:d,ignoreDiacritics:u,ignoreLocation:p},t=d?t:t.toLowerCase(),t=u?qs(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const m=(g,x)=>{this.chunks.push({pattern:g,alphabet:mv(g),startIndex:x})},h=this.pattern.length;if(h>en){let g=0;const x=h%en,S=h-x;for(;g<S;)m(this.pattern.substr(g,en),g),g+=en;if(x){const k=h-en;m(this.pattern.substr(k),k)}}else m(this.pattern,0)}searchIn(t){const{isCaseSensitive:n,ignoreDiacritics:s,includeMatches:o}=this.options;if(t=n?t:t.toLowerCase(),t=s?qs(t):t,this.pattern===t){let S={isMatch:!0,score:0};return o&&(S.indices=[[0,t.length-1]]),S}const{location:a,distance:i,threshold:c,findAllMatches:d,minMatchCharLength:u,ignoreLocation:p}=this.options;let m=[],h=0,g=!1;this.chunks.forEach(({pattern:S,alphabet:k,startIndex:I})=>{const{isMatch:A,score:w,indices:M}=pv(t,S,k,{location:a+I,distance:i,threshold:c,findAllMatches:d,minMatchCharLength:u,includeMatches:o,ignoreLocation:p});A&&(g=!0),h+=w,A&&M&&(m=[...m,...M])});let x={isMatch:g,score:g?h/this.chunks.length:1};return g&&o&&(x.indices=m),x}}class Hr{constructor(t){this.pattern=t}static isMultiMatch(t){return Pl(t,this.multiRegex)}static isSingleMatch(t){return Pl(t,this.singleRegex)}search(){}}function Pl(e,t){const n=e.match(t);return n?n[1]:null}class fv extends Hr{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const n=t===this.pattern;return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class hv extends Hr{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const s=t.indexOf(this.pattern)===-1;return{isMatch:s,score:s?0:1,indices:[0,t.length-1]}}}class gv extends Hr{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const n=t.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class xv extends Hr{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const n=!t.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}}class vv extends Hr{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const n=t.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class yv extends Hr{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const n=!t.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}}class xu extends Hr{constructor(t,{location:n=Ae.location,threshold:s=Ae.threshold,distance:o=Ae.distance,includeMatches:a=Ae.includeMatches,findAllMatches:i=Ae.findAllMatches,minMatchCharLength:c=Ae.minMatchCharLength,isCaseSensitive:d=Ae.isCaseSensitive,ignoreDiacritics:u=Ae.ignoreDiacritics,ignoreLocation:p=Ae.ignoreLocation}={}){super(t),this._bitapSearch=new gu(t,{location:n,threshold:s,distance:o,includeMatches:a,findAllMatches:i,minMatchCharLength:c,isCaseSensitive:d,ignoreDiacritics:u,ignoreLocation:p})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class vu extends Hr{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let n=0,s;const o=[],a=this.pattern.length;for(;(s=t.indexOf(this.pattern,n))>-1;)n=s+a,o.push([s,n-1]);const i=!!o.length;return{isMatch:i,score:i?0:1,indices:o}}}const Aa=[fv,vu,gv,xv,yv,vv,hv,xu],Ll=Aa.length,bv=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,wv="|";function kv(e,t={}){return e.split(wv).map(n=>{let s=n.trim().split(bv).filter(a=>a&&!!a.trim()),o=[];for(let a=0,i=s.length;a<i;a+=1){const c=s[a];let d=!1,u=-1;for(;!d&&++u<Ll;){const p=Aa[u];let m=p.isMultiMatch(c);m&&(o.push(new p(m,t)),d=!0)}if(!d)for(u=-1;++u<Ll;){const p=Aa[u];let m=p.isSingleMatch(c);if(m){o.push(new p(m,t));break}}}return o})}const jv=new Set([xu.type,vu.type]);class Sv{constructor(t,{isCaseSensitive:n=Ae.isCaseSensitive,ignoreDiacritics:s=Ae.ignoreDiacritics,includeMatches:o=Ae.includeMatches,minMatchCharLength:a=Ae.minMatchCharLength,ignoreLocation:i=Ae.ignoreLocation,findAllMatches:c=Ae.findAllMatches,location:d=Ae.location,threshold:u=Ae.threshold,distance:p=Ae.distance}={}){this.query=null,this.options={isCaseSensitive:n,ignoreDiacritics:s,includeMatches:o,minMatchCharLength:a,findAllMatches:c,ignoreLocation:i,location:d,threshold:u,distance:p},t=n?t:t.toLowerCase(),t=s?qs(t):t,this.pattern=t,this.query=kv(this.pattern,this.options)}static condition(t,n){return n.useExtendedSearch}searchIn(t){const n=this.query;if(!n)return{isMatch:!1,score:1};const{includeMatches:s,isCaseSensitive:o,ignoreDiacritics:a}=this.options;t=o?t:t.toLowerCase(),t=a?qs(t):t;let i=0,c=[],d=0;for(let u=0,p=n.length;u<p;u+=1){const m=n[u];c.length=0,i=0;for(let h=0,g=m.length;h<g;h+=1){const x=m[h],{isMatch:S,indices:k,score:I}=x.search(t);if(S){if(i+=1,d+=I,s){const A=x.constructor.type;jv.has(A)?c=[...c,...k]:c.push(k)}}else{d=0,i=0,c.length=0;break}}if(i){let h={isMatch:!0,score:d/i};return s&&(h.indices=c),h}}return{isMatch:!1,score:1}}}const Ta=[];function Nv(...e){Ta.push(...e)}function _a(e,t){for(let n=0,s=Ta.length;n<s;n+=1){let o=Ta[n];if(o.condition(e,t))return new o(e,t)}return new gu(e,t)}const Vs={AND:"$and",OR:"$or"},Ma={PATH:"$path",PATTERN:"$val"},Da=e=>!!(e[Vs.AND]||e[Vs.OR]),Cv=e=>!!e[Ma.PATH],Ev=e=>!_r(e)&&pu(e)&&!Da(e),Ol=e=>({[Vs.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function yu(e,t,{auto:n=!0}={}){const s=o=>{let a=Object.keys(o);const i=Cv(o);if(!i&&a.length>1&&!Da(o))return s(Ol(o));if(Ev(o)){const d=i?o[Ma.PATH]:a[0],u=i?o[Ma.PATTERN]:o[d];if(!yr(u))throw new Error(Q0(d));const p={keyId:Ia(d),pattern:u};return n&&(p.searcher=_a(u,t)),p}let c={children:[],operator:a[0]};return a.forEach(d=>{const u=o[d];_r(u)&&u.forEach(p=>{c.children.push(s(p))})}),c};return Da(e)||(e=Ol(e)),s(e)}function Iv(e,{ignoreFieldNorm:t=Ae.ignoreFieldNorm}){e.forEach(n=>{let s=1;n.matches.forEach(({key:o,norm:a,score:i})=>{const c=o?o.weight:null;s*=Math.pow(i===0&&c?Number.EPSILON:i,(c||1)*(t?1:a))}),n.score=s})}function Av(e,t){const n=e.matches;t.matches=[],Yt(n)&&n.forEach(s=>{if(!Yt(s.indices)||!s.indices.length)return;const{indices:o,value:a}=s;let i={indices:o,value:a};s.key&&(i.key=s.key.src),s.idx>-1&&(i.refIndex=s.idx),t.matches.push(i)})}function Tv(e,t){t.score=e.score}function _v(e,t,{includeMatches:n=Ae.includeMatches,includeScore:s=Ae.includeScore}={}){const o=[];return n&&o.push(Av),s&&o.push(Tv),e.map(a=>{const{idx:i}=a,c={item:t[i],refIndex:i};return o.length&&o.forEach(d=>{d(a,c)}),c})}class _n{constructor(t,n={},s){this.options={...Ae,...n},this.options.useExtendedSearch,this._keyStore=new rv(this.options.keys),this.setCollection(t,s)}setCollection(t,n){if(this._docs=t,n&&!(n instanceof ci))throw new Error(X0);this._myIndex=n||hu(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){Yt(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const n=[];for(let s=0,o=this._docs.length;s<o;s+=1){const a=this._docs[s];t(a,s)&&(this.removeAt(s),s-=1,o-=1,n.push(a))}return n}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:n=-1}={}){const{includeMatches:s,includeScore:o,shouldSort:a,sortFn:i,ignoreFieldNorm:c}=this.options;let d=yr(t)?yr(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return Iv(d,{ignoreFieldNorm:c}),a&&d.sort(i),uu(n)&&n>-1&&(d=d.slice(0,n)),_v(d,this._docs,{includeMatches:s,includeScore:o})}_searchStringList(t){const n=_a(t,this.options),{records:s}=this._myIndex,o=[];return s.forEach(({v:a,i,n:c})=>{if(!Yt(a))return;const{isMatch:d,score:u,indices:p}=n.searchIn(a);d&&o.push({item:a,idx:i,matches:[{score:u,value:a,norm:c,indices:p}]})}),o}_searchLogical(t){const n=yu(t,this.options),s=(c,d,u)=>{if(!c.children){const{keyId:m,searcher:h}=c,g=this._findMatches({key:this._keyStore.get(m),value:this._myIndex.getValueForItemAtKeyId(d,m),searcher:h});return g&&g.length?[{idx:u,item:d,matches:g}]:[]}const p=[];for(let m=0,h=c.children.length;m<h;m+=1){const g=c.children[m],x=s(g,d,u);if(x.length)p.push(...x);else if(c.operator===Vs.AND)return[]}return p},o=this._myIndex.records,a={},i=[];return o.forEach(({$:c,i:d})=>{if(Yt(c)){let u=s(n,c,d);u.length&&(a[d]||(a[d]={idx:d,item:c,matches:[]},i.push(a[d])),u.forEach(({matches:p})=>{a[d].matches.push(...p)}))}}),i}_searchObjectList(t){const n=_a(t,this.options),{keys:s,records:o}=this._myIndex,a=[];return o.forEach(({$:i,i:c})=>{if(!Yt(i))return;let d=[];s.forEach((u,p)=>{d.push(...this._findMatches({key:u,value:i[p],searcher:n}))}),d.length&&a.push({idx:c,item:i,matches:d})}),a}_findMatches({key:t,value:n,searcher:s}){if(!Yt(n))return[];let o=[];if(_r(n))n.forEach(({v:a,i,n:c})=>{if(!Yt(a))return;const{isMatch:d,score:u,indices:p}=s.searchIn(a);d&&o.push({score:u,key:t,value:a,idx:i,norm:c,indices:p})});else{const{v:a,n:i}=n,{isMatch:c,score:d,indices:u}=s.searchIn(a);c&&o.push({score:d,key:t,value:a,norm:i,indices:u})}return o}}_n.version="7.1.0";_n.createIndex=hu;_n.parseIndex=dv;_n.config=Ae;_n.parseQuery=yu;Nv(Sv);const Mv=({commands:e=[],selectedIndex:t=-1,onSelect:n,onClose:s,position:o={top:0,left:0},isOpen:a=!1,frequentCommands:i=[]})=>{const c=l.useRef(null),d=l.useRef(null),p=(()=>{const A=window.innerWidth<640,w=window.innerHeight;return A?{position:"fixed",bottom:`${o.bottom||90}px`,left:"16px",right:"16px",width:"auto",maxWidth:"calc(100vw - 32px)",maxHeight:"min(50vh, 300px)"}:{position:"fixed",top:`${Math.max(16,Math.min(o.top,w-316))}px`,left:`${o.left}px`,width:"min(400px, calc(100vw - 32px))",maxWidth:"calc(100vw - 32px)",maxHeight:"300px"}})();if(l.useEffect(()=>{const A=w=>{c.current&&!c.current.contains(w.target)&&a&&s()};if(a)return document.addEventListener("mousedown",A),()=>{document.removeEventListener("mousedown",A)}},[a,s]),l.useEffect(()=>{if(d.current&&c.current){const A=c.current.getBoundingClientRect(),w=d.current.getBoundingClientRect();w.bottom>A.bottom?d.current.scrollIntoView({block:"nearest",behavior:"smooth"}):w.top<A.top&&d.current.scrollIntoView({block:"nearest",behavior:"smooth"})}},[t]),!a)return null;if(e.length===0)return r.jsx("div",{ref:c,className:"command-menu command-menu-empty",style:{...p,maxHeight:"300px",borderRadius:"8px",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",zIndex:1e3,padding:"20px",opacity:1,transform:"translateY(0)",transition:"opacity 150ms ease-in-out, transform 150ms ease-in-out",textAlign:"center"},children:"No commands available"});const m=i.length>0,h=e.reduce((A,w)=>{const M=w.namespace||w.type||"other";return A[M]||(A[M]=[]),A[M].push(w),A},{});m&&(h.frequent=i);const x=(m?["frequent","builtin","project","user","other"]:["builtin","project","user","other"]).filter(A=>h[A]),S={frequent:"⭐ Frequently Used",builtin:"Built-in Commands",project:"Project Commands",user:"User Commands",other:"Other Commands"};let k=0;const I=[];return x.forEach(A=>{h[A].forEach(w=>{I.push({...w,globalIndex:k++,namespace:A})})}),r.jsxs("div",{ref:c,role:"listbox","aria-label":"Available commands",className:"command-menu",style:{...p,maxHeight:"300px",overflowY:"auto",borderRadius:"8px",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",zIndex:1e3,padding:"8px",opacity:a?1:0,transform:a?"translateY(0)":"translateY(-10px)",transition:"opacity 150ms ease-in-out, transform 150ms ease-in-out"},children:[x.map(A=>r.jsxs("div",{className:"command-group",children:[x.length>1&&r.jsx("div",{style:{fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:"#6b7280",padding:"8px 12px 4px",letterSpacing:"0.05em"},children:S[A]||A}),h[A].map(w=>{const M=I.find(b=>b.name===w.name&&b.namespace===A),C=M&&M.globalIndex===t;return r.jsxs("div",{ref:C?d:null,role:"option","aria-selected":C,className:"command-item",onMouseEnter:()=>n&&n(w,M.globalIndex,!0),onClick:()=>n&&n(w,M.globalIndex,!1),style:{display:"flex",alignItems:"flex-start",padding:"10px 12px",borderRadius:"6px",cursor:"pointer",backgroundColor:C?"#eff6ff":"transparent",transition:"background-color 100ms ease-in-out",marginBottom:"2px"},onMouseDown:b=>b.preventDefault(),children:[r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:w.description?"4px":0},children:[r.jsxs("span",{style:{fontSize:"16px",flexShrink:0},children:[A==="builtin"&&"⚡",A==="project"&&"📁",A==="user"&&"👤",A==="other"&&"📝"]}),r.jsx("span",{style:{fontWeight:600,fontSize:"14px",color:"#111827",fontFamily:"monospace"},children:w.name}),w.metadata?.type&&r.jsx("span",{className:"command-metadata-badge",style:{fontSize:"10px",padding:"2px 6px",borderRadius:"4px",backgroundColor:"#f3f4f6",color:"#6b7280",fontWeight:500},children:w.metadata.type})]}),w.description&&r.jsx("div",{style:{fontSize:"13px",color:"#6b7280",marginLeft:"24px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:w.description})]}),C&&r.jsx("span",{style:{marginLeft:"8px",color:"#3b82f6",fontSize:"12px",fontWeight:600},children:"↵"})]},`${A}-${w.name}`)})]},A)),r.jsx("style",{children:`
|
|
236
|
-
.command-menu {
|
|
237
|
-
background-color: white;
|
|
238
|
-
border: 1px solid #e5e7eb;
|
|
239
|
-
}
|
|
240
|
-
.command-menu-empty {
|
|
241
|
-
color: #6b7280;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
@media (prefers-color-scheme: dark) {
|
|
245
|
-
.command-menu {
|
|
246
|
-
background-color: #1f2937 !important;
|
|
247
|
-
border: 1px solid #374151 !important;
|
|
248
|
-
}
|
|
249
|
-
.command-menu-empty {
|
|
250
|
-
color: #9ca3af !important;
|
|
251
|
-
}
|
|
252
|
-
.command-item[aria-selected="true"] {
|
|
253
|
-
background-color: #1e40af !important;
|
|
254
|
-
}
|
|
255
|
-
.command-item span:not(.command-metadata-badge) {
|
|
256
|
-
color: #f3f4f6 !important;
|
|
257
|
-
}
|
|
258
|
-
.command-metadata-badge {
|
|
259
|
-
background-color: #f3f4f6 !important;
|
|
260
|
-
color: #6b7280 !important;
|
|
261
|
-
}
|
|
262
|
-
.command-item div {
|
|
263
|
-
color: #d1d5db !important;
|
|
264
|
-
}
|
|
265
|
-
.command-group > div:first-child {
|
|
266
|
-
color: #9ca3af !important;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
`})]})},Dv={OPTIONS:[{value:"sonnet",label:"Sonnet"},{value:"opus",label:"Opus"},{value:"haiku",label:"Haiku"},{value:"opusplan",label:"Opus Plan"},{value:"sonnet[1m]",label:"Sonnet [1M]"}],DEFAULT:"sonnet"},bu={OPTIONS:[{value:"gpt-5",label:"GPT-5"},{value:"gpt-5-codex",label:"GPT-5 Codex"},{value:"gpt-5-codex-mini",label:"GPT-5 Codex Mini"},{value:"gpt-5.1",label:"GPT-5.1"},{value:"gpt-5.1-codex",label:"GPT-5.1 Codex"},{value:"gpt-5.1-codex-max",label:"GPT-5.1 Codex Max"},{value:"gpt-5.1-codex-mini",label:"GPT-5.1 Codex Mini"},{value:"gpt-5.2",label:"GPT-5.2"},{value:"gpt-5.2-codex",label:"GPT-5.2 Codex"},{value:"gpt-5.2-high",label:"GPT-5.2 High"},{value:"gpt-5.2-low",label:"GPT-5.2 Low"},{value:"gpt-5.2-medium",label:"GPT-5.2 Medium"},{value:"gpt-5.2-xhigh",label:"GPT-5.2 XHigh"},{value:"gpt-5.3-codex",label:"GPT-5.3 Codex"},{value:"gpt-5.3-codex-high",label:"GPT-5.3 Codex High"},{value:"gpt-5.3-codex-low",label:"GPT-5.3 Codex Low"},{value:"gpt-5.3-codex-medium",label:"GPT-5.3 Codex Medium"},{value:"gpt-5.3-codex-xhigh",label:"GPT-5.3 Codex XHigh"}],DEFAULT:"gpt-5.2-codex"},Rv={OPTIONS:[{value:"gemini-2.5-pro",label:"Gemini 2.5 Pro"},{value:"gemini-2.5-flash",label:"Gemini 2.5 Flash"},{value:"gemini-3-pro-preview",label:"Gemini 3 Pro Preview"},{value:"gemini-3-flash-preview",label:"Gemini 3 Flash Preview"}],DEFAULT:"gemini-3-pro-preview"},Pv={OPTIONS:[{value:"kimi-k2.5",label:"Kimi K2.5"}],DEFAULT:"kimi-k2.5"},Re={USER_MESSAGE:"user_message",ASSISTANT_TEXT_START:"assistant_text_start",ASSISTANT_TEXT_DELTA:"assistant_text_delta",ASSISTANT_TEXT_END:"assistant_text_end",REASONING_START:"reasoning_start",REASONING_DELTA:"reasoning_delta",REASONING_END:"reasoning_end",TOOL_CALL_START:"tool_call_start",TOOL_CALL_INPUT:"tool_call_input",TOOL_CALL_END:"tool_call_end",TOOL_RESULT:"tool_result",APPROVAL_REQUEST:"approval_request",APPROVAL_RESOLVED:"approval_resolved",SESSION_STATE_CHANGED:"session_state_changed",SYSTEM_NOTICE:"system_notice",ERROR:"error"};function cr(e="evt"){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${e}:${crypto.randomUUID()}`:`${e}:${Date.now()}:${Math.random().toString(36).slice(2,10)}`}function wu(e){if(!e)return new Date().toISOString();if(e instanceof Date)return e.toISOString();const t=new Date(e);return Number.isNaN(t.getTime())?new Date().toISOString():t.toISOString()}function zt({kind:e,provider:t="claude",sessionId:n=null,timestamp:s,payload:o={},extensions:a={},rawRef:i=null,eventId:c=null}){return{eventId:c||cr(e),kind:e,provider:t,sessionId:n,timestamp:wu(s),payload:o,extensions:a,rawRef:i}}function ku(e){return!!(e&&typeof e=="object"&&typeof e.kind=="string"&&typeof e.eventId=="string")}function oa({kindPrefix:e="assistant_text",text:t,provider:n,sessionId:s,timestamp:o,messageId:a,extensions:i={},rawRef:c=null}){if(typeof t!="string"||!t.trim())return[];const d=a||cr(e),u={...i,messageId:d};return[zt({kind:`${e}_start`,provider:n,sessionId:s,timestamp:o,payload:{messageId:d},extensions:u,rawRef:c}),zt({kind:`${e}_delta`,provider:n,sessionId:s,timestamp:o,payload:{messageId:d,text:t},extensions:u,rawRef:c}),zt({kind:`${e}_end`,provider:n,sessionId:s,timestamp:o,payload:{messageId:d},extensions:u,rawRef:c})]}function Lv(e){const t=String(e||"").trim();if(!t||t.startsWith("# AGENTS.md instructions for ")||t.includes("<environment_context>"))return"";if(t.startsWith("[DYNAMIC CONTEXT V1]")){const s=`
|
|
270
|
-
|
|
271
|
-
[USER MESSAGE]
|
|
272
|
-
`,o=t.indexOf(s);return o>=0?t.slice(o+s.length).trim():""}const n=t.match(/^<dynamic_context(?:\s[^>]*)?>[\s\S]*?<\/dynamic_context>\s*<user_message>\s*([\s\S]*?)\s*<\/user_message>$/i);return n?String(n[1]||"").trim():t}function aa(e){const t=String(e||"").trim();return!t||t.startsWith("[System Context]")||t.startsWith("[Attached Context]")||t.startsWith("[Dynamic Context]")||t.startsWith("[Hidden Context]")||t.startsWith("# AGENTS.md instructions for ")||t.startsWith("[DYNAMIC CONTEXT V1]")?!0:/^<dynamic_context(?:\s|>)/i.test(t)||t.includes("<environment_context>")}function vn(e){if(typeof e=="string")return e;if(e==null)return"";try{return JSON.stringify(e)}catch{return String(e)}}function Ov(e){const t=new Map;for(const n of e||[])if(!(n?.message?.role!=="user"||!Array.isArray(n?.message?.content)))for(const s of n.message.content)s?.type==="tool_result"&&s.tool_use_id&&t.set(s.tool_use_id,{content:s.content,isError:!!s.is_error,timestamp:n.timestamp,toolUseResult:n.toolUseResult||null});return t}function Ks(e,t){for(let n=e.length-1;n>=0;n-=1)if(t(e[n],n))return n;return-1}function Fl(e="",t=""){return t?e?e.endsWith(t)?e:`${e}${t}`:t:e}function Is(e,{messageId:t,timestamp:n,provider:s,isThinking:o=!1,kind:a="assistant"}){const i=Ks(e,d=>d?.eventMessageId===t&&!!d?.isStreaming&&!d.isToolUse&&!!d.isThinking==!!o);if(i>=0){const d={...e[i]};return d.isStreaming=!0,s&&(d.provider=s),n&&(d.timestamp=d.timestamp||n),e[i]=d,{messages:e,index:i}}const c={type:a,content:"",timestamp:n,provider:s,isStreaming:!0,eventMessageId:t};return o&&(c.isThinking=!0),e.push(c),{messages:e,index:e.length-1}}function As(e,{toolCallId:t,toolName:n,timestamp:s,provider:o}){const a=Ks(e,i=>i?.isToolUse&&(i.toolId===t||i.toolCallId===t));if(a>=0){const i={...e[a]};return n&&(i.toolName=n),o&&(i.provider=o),s&&!i.timestamp&&(i.timestamp=s),e[a]=i,{messages:e,index:a}}return e.push({type:"assistant",content:"",timestamp:s,provider:o,isToolUse:!0,toolName:n||"Unknown Tool",toolId:t,toolCallId:t}),{messages:e,index:e.length-1}}function Fv(e=[],t="claude",n=null){if(!Array.isArray(e))return[];const s=[],o=Ov(e);for(const a of e){const i=wu(a?.timestamp),c={provider:t,timestamp:i,type:a?.type||a?.message?.role||"unknown"};if(a?.message?.role==="user"&&a?.message?.content){let d="";Array.isArray(a.message.content)?d=a.message.content.filter(p=>p?.type==="text").map(p=>p?.text||"").join(`
|
|
273
|
-
`):d=typeof a.message.content=="string"?a.message.content:String(a.message.content||"");const u=Lv(d);u&&(!aa(d)||u!==d)&&s.push(zt({kind:Re.USER_MESSAGE,provider:t,sessionId:n,timestamp:i,payload:{text:u},rawRef:c}));continue}if(a?.type==="thinking"&&a?.message?.content){s.push(...oa({kindPrefix:"reasoning",text:a.message.content,provider:t,sessionId:n,timestamp:i,rawRef:c}));continue}if(a?.type==="tool_use"&&a?.toolName){const d=a.toolCallId||cr("tool"),u=a.toolResult||null;s.push(zt({kind:Re.TOOL_CALL_START,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:d,toolName:a.toolName},rawRef:c})),s.push(zt({kind:Re.TOOL_CALL_INPUT,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:d,input:a.toolInput||""},rawRef:c})),s.push(zt({kind:Re.TOOL_CALL_END,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:d,toolName:a.toolName},rawRef:c})),u&&s.push(zt({kind:Re.TOOL_RESULT,provider:t,sessionId:n,timestamp:u.timestamp||i,payload:{toolCallId:d,content:vn(u.content),isError:!!u.isError,toolUseResult:u.toolUseResult||null},rawRef:c}));continue}if(a?.type==="tool_result"){s.push(zt({kind:Re.TOOL_RESULT,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:a.toolCallId||null,content:vn(a.output||""),isError:!1},rawRef:c}));continue}if(a?.message?.role==="assistant"&&a?.message?.content){if(Array.isArray(a.message.content)){for(const d of a.message.content)if(d?.type==="text"&&!aa(d.text))s.push(...oa({text:d.text,provider:t,sessionId:n,timestamp:i,rawRef:c}));else if(d?.type==="tool_use"){const u=d.id||cr("tool"),p=o.get(d.id);s.push(zt({kind:Re.TOOL_CALL_START,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:u,toolName:d.name},rawRef:c})),s.push(zt({kind:Re.TOOL_CALL_INPUT,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:u,input:vn(d.input||{})},rawRef:c})),s.push(zt({kind:Re.TOOL_CALL_END,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:u,toolName:d.name},rawRef:c})),p&&s.push(zt({kind:Re.TOOL_RESULT,provider:t,sessionId:n,timestamp:p.timestamp||i,payload:{toolCallId:u,content:vn(p.content),isError:!!p.isError,toolUseResult:p.toolUseResult||null},rawRef:c}))}}else aa(a.message.content)||s.push(...oa({text:a.message.content,provider:t,sessionId:n,timestamp:i,rawRef:c}));continue}a?.type&&/error/i.test(a.type)&&s.push(zt({kind:Re.ERROR,provider:t,sessionId:n,timestamp:i,payload:{message:a.error||a.message||"Provider error"},rawRef:c}))}return s.sort((a,i)=>new Date(a.timestamp)-new Date(i.timestamp))}function ju(e=[],t,n="claude"){const s=Array.isArray(e)?[...e]:[];if(!ku(t))return s;const o=t.provider||n,a=t.timestamp||new Date().toISOString(),i=t.payload||{};switch(t.kind){case Re.USER_MESSAGE:s.push({type:"user",content:i.text||"",timestamp:a,provider:o});break;case Re.ASSISTANT_TEXT_START:{const c=i.messageId||t.extensions?.messageId||cr("assistant_text");Is(s,{messageId:c,timestamp:a,provider:o,isThinking:!1});break}case Re.ASSISTANT_TEXT_DELTA:{const c=i.messageId||t.extensions?.messageId||cr("assistant_text"),{index:d}=Is(s,{messageId:c,timestamp:a,provider:o,isThinking:!1}),u={...s[d]};u.content=Fl(u.content||"",i.text||""),u.timestamp=u.timestamp||a,u.provider=u.provider||o,s[d]=u;break}case Re.ASSISTANT_TEXT_END:{const c=i.messageId||t.extensions?.messageId;if(!c)break;const d=Ks(s,u=>u?.eventMessageId===c&&!u.isToolUse&&!u.isThinking);d>=0&&(s[d]={...s[d],isStreaming:!1});break}case Re.REASONING_START:{const c=i.messageId||t.extensions?.messageId||cr("reasoning");Is(s,{messageId:c,timestamp:a,provider:o,isThinking:!0});break}case Re.REASONING_DELTA:{const c=i.messageId||t.extensions?.messageId||cr("reasoning"),{index:d}=Is(s,{messageId:c,timestamp:a,provider:o,isThinking:!0}),u={...s[d]};u.content=Fl(u.content||"",i.text||""),u.timestamp=u.timestamp||a,u.provider=u.provider||o,u.isThinking=!0,s[d]=u;break}case Re.REASONING_END:{const c=i.messageId||t.extensions?.messageId;if(!c)break;const d=Ks(s,u=>u?.eventMessageId===c&&!!u.isThinking);d>=0&&(s[d]={...s[d],isStreaming:!1,isThinking:!0});break}case Re.TOOL_CALL_START:{const c=i.toolCallId||cr("tool"),{index:d}=As(s,{toolCallId:c,toolName:i.toolName,timestamp:a,provider:o});s[d]={...s[d],toolName:i.toolName||s[d].toolName};break}case Re.TOOL_CALL_INPUT:{const c=i.toolCallId||cr("tool"),{index:d}=As(s,{toolCallId:c,toolName:i.toolName,timestamp:a,provider:o});s[d]={...s[d],toolInput:vn(i.input||""),provider:s[d].provider||o};break}case Re.TOOL_CALL_END:{const c=i.toolCallId||t.extensions?.toolCallId;if(!c)break;const{index:d}=As(s,{toolCallId:c,toolName:i.toolName,timestamp:a,provider:o});s[d]={...s[d],toolName:i.toolName||s[d].toolName};break}case Re.TOOL_RESULT:{const c=i.toolCallId||t.extensions?.toolCallId||cr("tool"),{index:d}=As(s,{toolCallId:c,toolName:i.toolName,timestamp:a,provider:o});s[d]={...s[d],toolResult:{content:vn(i.content||""),isError:!!i.isError,toolUseResult:i.toolUseResult||null,timestamp:a},toolError:!!i.isError,provider:s[d].provider||o};break}case Re.APPROVAL_REQUEST:i.message&&s.push({type:"assistant",content:i.message,timestamp:a,provider:o,isApprovalRequest:!0,approvalRequest:i});break;case Re.APPROVAL_RESOLVED:i.message&&s.push({type:"assistant",content:i.message,timestamp:a,provider:o,approvalResolution:i});break;case Re.SYSTEM_NOTICE:if(i.message){const c=s[s.length-1];c&&c.type==="assistant"&&!c.isToolUse&&(c.content||"").trim()===String(i.message).trim()||s.push({type:"assistant",content:i.message,timestamp:a,provider:o,isSystemNotice:!0})}break;case Re.ERROR:s.push({type:"error",content:i.message||"Provider error",timestamp:a,provider:o,rawRef:t.rawRef||null,extensions:t.extensions||{}});break}return s}function Su(e=[],t="claude"){return Array.isArray(e)?e.length>0&&!ku(e[0])?Su(Fv(e,t),t):e.reduce((n,s)=>ju(n,s,t),[]):[]}const $l={claude:{defaultMode:"bypassPermissions",modes:["default","acceptEdits","bypassPermissions","plan"]},codex:{defaultMode:"bypassPermissions",modes:["default","acceptEdits","bypassPermissions"]},gemini:{defaultMode:"bypassPermissions",modes:["default","acceptEdits","bypassPermissions"]},opencode:{defaultMode:"bypassPermissions",modes:["default","acceptEdits","bypassPermissions","plan"]}},Bl={claude:{enabled:!0,defaultMode:"none",strategy:"prompt-prefix",modes:["none","think","think-hard","think-harder","ultrathink"]},codex:{enabled:!1,defaultMode:"none",strategy:"native-effort",modes:["none"]},gemini:{enabled:!1,defaultMode:"none",strategy:"model-or-api-param",modes:["none"]},opencode:{enabled:!1,defaultMode:"none",strategy:"provider-pass-through",modes:["none"]}};function zl(e){return $l[e]||$l.claude}function Ul(e){return Bl[e]||Bl.claude}function $v(e){return e==="claude"||e==="codex"}function Bv(e){if(e==="think")return"low";if(e==="think-hard")return"medium";if(e==="think-harder")return"high";if(e==="ultrathink")return"xhigh"}const le={IDLE:"idle",CONNECTING:"connecting",QUEUED:"queued",STREAMING:"streaming",AWAITING_APPROVAL:"awaiting_approval",COMPLETED:"completed",ABORTED:"aborted",ERRORED:"errored"},Gs=new Set([le.CONNECTING,le.QUEUED,le.STREAMING,le.AWAITING_APPROVAL]);function Er(e){return e==null?"":String(e).replace(/\r\n/g,`
|
|
274
|
-
`).trim()}function Wl(e){return!e||typeof e!="object"?{content:"",isError:!1}:{content:Er(e.content),isError:!!e.isError}}function zv(e,t){if(!e||!t)return!1;const n=String(e.type||""),s=String(t.type||"");if(n!==s)return!1;const o=!!e.isToolUse,a=!!t.isToolUse;if(o!==a)return!1;if(o&&a){const i=Wl(e.toolResult),c=Wl(t.toolResult);return Er(e.toolName)===Er(t.toolName)&&Er(e.toolInput)===Er(t.toolInput)&&i.content===c.content&&i.isError===c.isError}return!!e.isThinking!=!!t.isThinking?!1:Er(e.content)===Er(t.content)}function Uv(e,t){const n=Math.min(e.length,t.length);let s=0;for(;s<n&&zv(e[s],t[s]);)s+=1;return s}function Wv(e=[],t=[],n={}){const s=Array.isArray(e)?e:[],o=Array.isArray(t)?t:[],a=!!n.preserveLocalTail;if(s.length===0)return o;if(o.length===0)return a?s:o;const i=Uv(s,o);return i===s.length&&i===o.length?o:a&&i===o.length&&s.length>o.length?s:o}function Ts(e,t){return typeof t=="function"?t(e):t}function Hl(e,t={}){const n=Gs.has(e),s=Gs.has(e);return{isLoading:n,canAbortSession:s,...t}}function Ra(e,t=le.IDLE){const n=String(e||"").trim().toLowerCase();return Object.values(le).includes(n)?n:t}function Hv(e,t){return!e||typeof e!="object"?t:e.kind===Re.SESSION_STATE_CHANGED?Ra(e.payload?.state,t):e.kind===Re.APPROVAL_REQUEST?le.AWAITING_APPROVAL:e.kind===Re.APPROVAL_RESOLVED?le.STREAMING:e.kind===Re.ERROR?le.ERRORED:e.kind===Re.ASSISTANT_TEXT_START||e.kind===Re.ASSISTANT_TEXT_DELTA||e.kind===Re.REASONING_START||e.kind===Re.REASONING_DELTA||e.kind===Re.TOOL_CALL_START||e.kind===Re.TOOL_CALL_INPUT||e.kind===Re.TOOL_CALL_END||e.kind===Re.TOOL_RESULT||e.kind===Re.SYSTEM_NOTICE?le.STREAMING:t}function qv(e,t){const n=t?.payload||{},s=n.requestId||t?.extensions?.requestId||null;return!s||e.some(o=>o?.requestId===s)?e:[...e,{requestId:s,toolName:n.toolName||"UnknownTool",input:n.input,context:n.context,sessionId:t?.sessionId||n.sessionId||null,receivedAt:t?.timestamp||new Date().toISOString()}]}function Vv(e,t){const s=(t?.payload||{}).requestId||t?.extensions?.requestId||null;return s?e.filter(o=>o?.requestId!==s):e}function Kv(e,t){return t?e===le.AWAITING_APPROVAL||Gs.has(e)?e:le.STREAMING:e===le.COMPLETED||e===le.ABORTED||e===le.ERRORED?e:le.IDLE}function Gv(e=[]){return{messages:e,pendingPermissionRequests:[],phase:le.IDLE,isLoading:!1,canAbortSession:!1}}function Jv(e,t){switch(t.type){case"replace_messages":return{...e,messages:Ts(e.messages,t.value)};case"replace_permissions":return{...e,pendingPermissionRequests:Ts(e.pendingPermissionRequests,t.value)};case"set_phase":{const n=Ra(t.phase,e.phase);return{...e,phase:n,...Hl(n,t.overrides)}}case"set_loading":{const n=!!Ts(e.isLoading,t.value),s=Kv(e.phase,n);return{...e,phase:s,isLoading:n,canAbortSession:n?e.canAbortSession||Gs.has(s):!1}}case"set_can_abort":return{...e,canAbortSession:!!Ts(e.canAbortSession,t.value)};case"apply_conversation_event":{const n=ju(e.messages,t.event,t.provider),s=Hv(t.event,e.phase);let o=e.pendingPermissionRequests;if(t.event?.kind===Re.APPROVAL_REQUEST)o=qv(o,t.event);else if(t.event?.kind===Re.APPROVAL_RESOLVED)o=Vv(o,t.event);else if(t.event?.kind===Re.SESSION_STATE_CHANGED){const a=Ra(t.event?.payload?.state,"");(a===le.COMPLETED||a===le.ABORTED||a===le.ERRORED||a===le.IDLE)&&(o=[])}return{...e,messages:n,pendingPermissionRequests:o,phase:s,...Hl(s)}}default:return e}}const Yv=["claude","codex","gemini","opencode"];function nr(e){const t=String(e||"").trim().toLowerCase();return Yv.includes(t)?t:"claude"}function Xv(e){return new Promise((t,n)=>{if(!(e instanceof Blob)){n(new Error("无效的图片文件"));return}const s=new FileReader;s.onload=()=>t(typeof s.result=="string"?s.result:""),s.onerror=()=>n(s.error||new Error("读取图片失败")),s.readAsDataURL(e)})}async function Qv(e=[]){const t=Array.isArray(e)?e:[];return Promise.all(t.map(async(n,s)=>{const o=await Xv(n);if(!o)throw new Error("图片编码失败");return{name:n?.name||`image-${s+1}.png`,data:o,size:Number(n?.size)||0,mimeType:n?.type||"application/octet-stream"}}))}function Zv(e){switch(e){case"codex":return bu;case"gemini":return Rv;case"opencode":return Pv;case"claude":default:return Dv}}function co(e){return`${nr(e)}-model`}function di(e){return`${co(e)}-selection-source`}function _s(e){const t=nr(e),n=co(t),s=di(t);return localStorage.getItem(s)!=="manual"?"":localStorage.getItem(n)||""}function ey(e,t){const n=nr(e);localStorage.setItem(co(n),t),localStorage.setItem(di(n),"manual")}function ty(e){const t=nr(e);localStorage.removeItem(co(t)),localStorage.removeItem(di(t))}function ry(e,t){return!e||!t?!1:e.eventId&&t.eventId?e.eventId===t.eventId:e.kind===t.kind&&e.provider===t.provider&&e.sessionId===t.sessionId&&e.timestamp===t.timestamp&&JSON.stringify(e.payload||{})===JSON.stringify(t.payload||{})}function Qr(e){return e&&e.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&")}function ny(e){if(!e||typeof e!="string")return e;try{return e.replace(/```\s*([^\n\r]+?)\s*```/g,"`$1`")}catch{return e}}function sy(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Pa(e){if(typeof e!="string")return"";try{return decodeURIComponent(e).trim()}catch{return e.trim()}}const ql=new WeakMap;let oy=0;function ay(e,t){if(e?.__threadMessageId)return String(e.__threadMessageId);const n=e?.id||e?.eventMessageId||e?.messageId||e?.toolCallId||e?.toolId||e?.requestId;if(n)return String(n);const s=(()=>{const i=e?.timestamp instanceof Date?e.timestamp.getTime():new Date(e?.timestamp||Date.now()).getTime();return Number.isNaN(i)?Date.now():i})(),o=String(e?.role||e?.type||"assistant"),a=String(e?.provider||e?.__provider||"");if(e&&typeof e=="object"){const i=ql.get(e);if(i)return i;const c=`${o}:${a}:${s}:runtime-${oy++}`;return ql.set(e,c),c}return`${o}:${a}:${s}:${t}`}const Cn="1",Vl=5,Kl="replace",La="append",Ms="unknown",iy="installed",ia="not_installed",ly="checking",cy=["claude","codex","gemini","opencode"],dy=300*1e3,uy=15e3;function Tr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function br(e){return typeof e=="string"&&e.trim().length>0}function Nu(e){if(typeof e!="string")return!1;const t=e.trim().toLowerCase();return t.length>0&&t!=="custom"&&t!=="default"}const py=new Set(bu.OPTIONS.map(e=>String(e?.value||"").trim().toLowerCase()).filter(Boolean));function my(e){if(!Nu(e))return!1;const t=e.trim().toLowerCase();return py.has(t)?!0:/^(gpt-\d|o[1345](?:$|[-.])|codex(?:$|[-.]))/i.test(t)}function fy(e,t){return nr(e)==="codex"?my(t):Nu(t)}function Ds(e){return typeof e=="string"&&/^codex-\d+$/.test(e.trim())}function hy(e){if(typeof e!="string")return"";const n=e.replace(/\\/g,"/").split("/").filter(Boolean);return n[n.length-1]||e}function uo(e,{allowEmptyPath:t=!0}={}){return typeof e=="string"?!t&&!e.trim()?null:{path:e,displayName:""}:!Tr(e)||typeof e.path!="string"||!t&&!e.path.trim()||e.displayName!==void 0&&typeof e.displayName!="string"?null:{path:e.path,displayName:e.displayName||""}}function bn(e){return uo(e)?.path||""}function gy(e){const t=uo(e);return t?br(t.displayName)?t.displayName:hy(t.path):""}function xy(e,t=72){if(typeof e!="string")return"";const n=e.trim().replace(/\s+/g," ");if(n.length<=t)return n;const s=n.split(/\s*>\s*/).filter(Boolean);if(s.length<=1)return`...${n.slice(-(t-3))}`;const o=[];let a=3;for(let c=s.length-1;c>=0;c-=1){const d=s[c],u=a+d.length+(o.length>0?3:0);if(o.length>0&&u>t)break;o.unshift(d),a=u}const i=`... > ${o.join(" > ")}`;return i.length<=t?i:`...${i.slice(-(t-3))}`}function Gl(e){if(!e)return"";const t=[];br(e.label)&&t.push(e.label.trim());const n=xy(e.selector);return n&&t.push(n),t.join(" · ")}function vy(e){return e?br(e.systemContext)||br(bn(e.currentFile))||Array.isArray(e.selectedElements)&&e.selectedElements.length>0?!0:Tr(e.extensions)&&Object.keys(e.extensions).length>0:!1}function yy(e){return e?br(e.systemContext)||br(bn(e.currentFile))?!0:Array.isArray(e.selectedElements)&&e.selectedElements.length>0:!1}function Cu(e){if(!Tr(e)||e.version!==Cn||typeof e.systemContext!="string")return null;const t=uo(e.currentFile);if(!t||!Array.isArray(e.selectedElements))return null;const n=[];for(const o of e.selectedElements){if(!Tr(o)||typeof o.tag!="string"||typeof o.selector!="string"||typeof o.label!="string")return null;n.push({tag:o.tag,selector:o.selector,label:o.label})}if(e.extensions!==void 0&&!Tr(e.extensions))return null;const s={version:Cn,systemContext:e.systemContext,currentFile:t,selectedElements:n};return e.extensions!==void 0&&(s.extensions={...e.extensions}),s}function by(e){if(!Tr(e)||e.version!==void 0&&e.version!==Cn||e.systemContext!==void 0&&typeof e.systemContext!="string"||e.selectedElements!==void 0&&!Array.isArray(e.selectedElements))return null;const t={};if(e.systemContext!==void 0&&(t.systemContext=e.systemContext),e.currentFile!==void 0){const n=uo(e.currentFile);if(!n)return null;t.currentFile=n}if(e.selectedElements!==void 0){const n=[];for(const s of e.selectedElements){if(!Tr(s)||typeof s.tag!="string"||typeof s.selector!="string"||typeof s.label!="string")return null;n.push({tag:s.tag,selector:s.selector,label:s.label})}t.selectedElements=n}if(e.extensions!==void 0){if(!Tr(e.extensions))return null;t.extensions={...e.extensions}}return t}function wy(e){return`${e.tag}::${e.selector}::${e.label}`}function ky(e){if(!Array.isArray(e)||e.length===0)return[];const t=new Set,n=[];for(const s of e){const o=wy(s);t.has(o)||(t.add(o),n.push(s))}return n}function jy(){return{version:Cn,systemContext:"",currentFile:{path:"",displayName:""},selectedElements:[]}}function Sy(e,t){const n=Cu(e)||jy(),s=by(t);if(!s)return null;const o={...n};return s.systemContext!==void 0&&(o.systemContext=s.systemContext),s.currentFile!==void 0&&(o.currentFile=s.currentFile),s.selectedElements!==void 0&&(o.selectedElements=ky([...Array.isArray(n.selectedElements)?n.selectedElements:[],...s.selectedElements])),s.extensions!==void 0&&(o.extensions=s.extensions),o}function Ny(e){return typeof e!="string"?Kl:e.trim().toLowerCase()===La?La:Kl}function Jl(e){if(e==null||e==="")return null;let t=e;if(typeof e=="string"){const s=Pa(e);if(!s)return null;try{t=JSON.parse(s)}catch{return console.warn("[DynamicContext] Ignored invalid context JSON string."),null}}const n=Cu(t);return n||(console.warn("[DynamicContext] Ignored invalid context payload."),null)}function Cy(e){if(!e)return null;const t={version:Cn,systemContext:e.systemContext||"",currentFile:bn(e.currentFile),selectedElements:Array.isArray(e.selectedElements)?e.selectedElements:[]};return e.extensions!==void 0&&(t.extensions=e.extensions),t}function Ey(e,t){return`<dynamic_context version="${Cn}">
|
|
275
|
-
${JSON.stringify(e,null,2)}
|
|
276
|
-
</dynamic_context>
|
|
277
|
-
|
|
278
|
-
<user_message>
|
|
279
|
-
${t}
|
|
280
|
-
</user_message>`}let Yl=!1;function Iy(e){const t=String(e||"").trim();if(!t||t.startsWith("# AGENTS.md instructions for ")||t.includes("<environment_context>"))return"";if(t.startsWith("[DYNAMIC CONTEXT V1]")){const s=`
|
|
281
|
-
|
|
282
|
-
[USER MESSAGE]
|
|
283
|
-
`,o=t.indexOf(s);return o>=0?t.slice(o+s.length).trim():""}const n=t.match(/^<dynamic_context(?:\s[^>]*)?>[\s\S]*?<\/dynamic_context>\s*<user_message>\s*([\s\S]*?)\s*<\/user_message>$/i);return n?String(n[1]||"").trim():t}function ui(e=[]){return Array.isArray(e)?e.flatMap(t=>{if(!t||typeof t!="object")return[];if(typeof t.content!="string")return[t];const n=Iy(t.content);return n?n===t.content?[t]:[{...t,content:n}]:[]}):[]}function Ay(e=[],t=[]){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const s=e[n],o=t[n];if(s?.type!==o?.type||s?.role!==o?.role||s?.content!==o?.content||s?.timestamp!==o?.timestamp||!!s?.isToolUse!=!!o?.isToolUse)return!1}return!0}const Oa=({children:e,className:t})=>{const n=ny(String(e??"")),s=l.useMemo(()=>[Dm,Rm],[]),o=l.useMemo(()=>[Pm],[]);return r.jsx("div",{className:t,children:r.jsx(Lm,{remarkPlugins:s,rehypePlugins:o,components:Py,children:n})})};function Fa(e){try{return typeof e!="string"?e:e.replace(/Claude AI usage limit reached\|(\d{10,13})/g,(t,n)=>{let s=parseInt(n,10);if(!Number.isFinite(s))return t;s<1e12&&(s*=1e3);const o=new Date(s),a=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}).format(o),i=-o.getTimezoneOffset(),c=i>=0?"+":"-",d=Math.abs(i),u=Math.floor(d/60),p=d%60,m=`GMT${c}${u}${p?":"+String(p).padStart(2,"0"):""}`,x=((Intl.DateTimeFormat().resolvedOptions().timeZone||"").split("/").pop()||"").replace(/_/g," ").toLowerCase().replace(/\b\w/g,A=>A.toUpperCase()),S=x?`${m} (${x})`:m,k=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],I=`${o.getDate()} ${k[o.getMonth()]} ${o.getFullYear()}`;return`Claude usage limit reached. Your limit will reset at **${a} ${S}** - ${I}`})}catch{return e}}const Et={setItem:(e,t)=>{try{if(e.startsWith("chat_messages_")&&typeof t=="string")try{const n=JSON.parse(t);if(Array.isArray(n)&&n.length>50){console.warn(`Truncating chat history for ${e} from ${n.length} to 50 messages`);const s=n.slice(-50);t=JSON.stringify(s)}}catch(n){console.warn("Could not parse chat messages for truncation:",n)}localStorage.setItem(e,t)}catch(n){if(n.name==="QuotaExceededError"){console.warn("localStorage quota exceeded, clearing old data");const s=Object.keys(localStorage),o=s.filter(i=>i.startsWith("chat_messages_")).sort();o.length>3&&o.slice(0,o.length-3).forEach(i=>{localStorage.removeItem(i),console.log(`Removed old chat data: ${i}`)}),s.filter(i=>i.startsWith("draft_input_")).forEach(i=>{localStorage.removeItem(i)});try{localStorage.setItem(e,t)}catch(i){if(console.error("Failed to save to localStorage even after cleanup:",i),e.startsWith("chat_messages_")&&typeof t=="string")try{const c=JSON.parse(t);if(Array.isArray(c)&&c.length>10){const d=c.slice(-10);localStorage.setItem(e,JSON.stringify(d)),console.warn("Saved only last 10 messages due to quota constraints")}}catch(c){console.error("Final save attempt failed:",c)}}}else console.error("localStorage error:",n)}},getItem:e=>{try{return localStorage.getItem(e)}catch(t){return console.error("localStorage getItem error:",t),null}},removeItem:e=>{try{localStorage.removeItem(e)}catch(t){console.error("localStorage removeItem error:",t)}}};function Eu(e){return e?`chat_messages_${e}`:""}function Iu(e,t=null){return e?t?`chat_messages_${e}__session_${t}`:Eu(e):""}function Ty(e,t=null){const n=Iu(e,t);if(!n)return[];const s=Et.getItem(n);if(!s)return[];try{return ui(JSON.parse(s))}catch(o){return console.warn("Failed to parse cached chat messages:",o),[]}}function Xl(e,t=null,n=[]){const s=Iu(e,t);if(!s)return;const o=ui(n);if(o.length===0){Et.removeItem(s);return}Et.setItem(s,JSON.stringify(o)),t&&Et.removeItem(Eu(e))}const Au="claude-settings";function pi(){const e=Et.getItem(Au);if(!e)return{allowedTools:[],disallowedTools:[],skipPermissions:!1,projectSortOrder:"name"};try{const t=JSON.parse(e);return{...t,allowedTools:Array.isArray(t.allowedTools)?t.allowedTools:[],disallowedTools:Array.isArray(t.disallowedTools)?t.disallowedTools:[],skipPermissions:!!t.skipPermissions,projectSortOrder:t.projectSortOrder||"name"}}catch{return{allowedTools:[],disallowedTools:[],skipPermissions:!1,projectSortOrder:"name"}}}function $a(e,t){if(!e)return null;if(e!=="Bash")return e;const n=Ga(t),s=typeof n?.command=="string"?n.command.trim():"";if(!s)return e;const o=s.split(/\s+/);return o.length===0?e:o[0]==="git"&&o[1]?`Bash(${o[0]} ${o[1]}:*)`:`Bash(${o[0]}:*)`}function Ql(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function _y(e,t){if(t!=="claude"||!e?.toolResult?.isError)return null;const n=e?.toolName,s=$a(n,e.toolInput);if(!s)return null;const a=pi().allowedTools.includes(s);return{toolName:n,entry:s,isAllowed:a}}function My(e){if(!e)return{success:!1};const t=pi(),n=t.allowedTools.includes(e),s=n?t.allowedTools:[...t.allowedTools,e],o=t.disallowedTools.filter(i=>i!==e),a={...t,allowedTools:s,disallowedTools:o,lastUpdated:new Date().toISOString()};return Et.setItem(Au,JSON.stringify(a)),{success:!0,alreadyAllowed:n,updatedSettings:a}}function Ba({phaseText:e,detailText:t="",canAbort:n=!0,startedAt:s=Date.now(),elapsedSeconds:o}={}){return{phaseText:e,detailText:t,canAbort:n,startedAt:s,elapsedSeconds:o}}function Dy(e,t,n=null){const s=n?.startedAt||Date.now(),o=typeof e=="string"?e:e?.message||e?.status||e?.text||"",a=String(o||"").trim(),i=a.toLowerCase();let c=t("activity.stage.working");return i.includes("permission")?c=t("activity.stage.waitingPermission"):i.includes("think")?c=t("activity.stage.thinking"):i.includes("search")||i.includes("grep")||i.includes("glob")?c=t("activity.stage.searching"):i.includes("command")||i.includes("bash")?c=t("activity.stage.runningCommand"):i.includes("read")?c=t("activity.stage.readingFile"):i.includes("write")||i.includes("edit")||i.includes("patch")?c=t("activity.stage.editingFile"):i.includes("todo")?c=t("activity.stage.updatingTodo"):(i.includes("respond")||i.includes("reply"))&&(c=t("activity.stage.generatingReply")),Ba({phaseText:c,detailText:a,canAbort:e?.can_interrupt!==!1,startedAt:s,elapsedSeconds:e?.elapsedSeconds})}const Ry=({node:e,inline:t,className:n,children:s,...o})=>{const{t:a}=Mt("chat"),[i,c]=Tn.useState(!1),d=Array.isArray(s)?s.join(""):String(s??""),u=/[\r\n]/.test(d);if(t||e&&e.type==="inlineCode"||!u)return r.jsx("code",{className:`font-mono text-[0.9em] px-1.5 py-0.5 rounded-md bg-gray-100 text-gray-900 border border-gray-200 dark:bg-gray-800/60 dark:text-gray-100 dark:border-gray-700 whitespace-pre-wrap break-words ${n||""}`,...o,children:s});const h=/language-(\w+)/.exec(n||""),g=h?h[1]:"text",x=d,S=()=>{const k=()=>{c(!0),setTimeout(()=>c(!1),1500)};try{if(navigator&&navigator.clipboard&&navigator.clipboard.writeText)navigator.clipboard.writeText(x).then(k).catch(()=>{const I=document.createElement("textarea");I.value=x,I.style.position="fixed",I.style.opacity="0",document.body.appendChild(I),I.select();try{document.execCommand("copy")}catch{}document.body.removeChild(I),k()});else{const I=document.createElement("textarea");I.value=x,I.style.position="fixed",I.style.opacity="0",document.body.appendChild(I),I.select();try{document.execCommand("copy")}catch{}document.body.removeChild(I),k()}}catch{}};return r.jsxs("div",{className:"relative group my-2",children:[g&&g!=="text"&&r.jsx("div",{className:"absolute top-2 left-3 z-10 text-xs text-gray-400 font-medium uppercase",children:g}),r.jsx("button",{type:"button",onClick:S,className:"absolute top-2 right-2 z-10 opacity-0 group-hover:opacity-100 focus:opacity-100 active:opacity-100 transition-opacity text-xs px-2 py-1 rounded-md bg-gray-700/80 hover:bg-gray-700 text-white border border-gray-600",title:a(i?"codeBlock.copied":"codeBlock.copyCode"),"aria-label":a(i?"codeBlock.copied":"codeBlock.copyCode"),children:i?r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:r.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),a("codeBlock.copied")]}):r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),r.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),a("codeBlock.copy")]})}),r.jsx(Om,{language:g,style:Fm,customStyle:{margin:0,borderRadius:"0.5rem",fontSize:"0.875rem",padding:g&&g!=="text"?"2rem 1rem 1rem 1rem":"1rem"},codeTagProps:{style:{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'}},children:d})]})},Py={code:Ry,blockquote:({children:e})=>r.jsx("blockquote",{className:"border-l-4 border-gray-300 dark:border-gray-600 pl-4 italic text-gray-600 dark:text-gray-400 my-2",children:e}),a:({href:e,children:t})=>r.jsx("a",{href:e,className:"text-primary hover:underline",target:"_blank",rel:"noopener noreferrer",children:t}),p:({children:e})=>r.jsx("div",{className:"mb-2 last:mb-0",children:e}),table:({children:e})=>r.jsx("div",{className:"overflow-x-auto my-2",children:r.jsx("table",{className:"min-w-full border-collapse border border-gray-200 dark:border-gray-700",children:e})}),thead:({children:e})=>r.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800",children:e}),th:({children:e})=>r.jsx("th",{className:"px-3 py-2 text-left text-sm font-semibold border border-gray-200 dark:border-gray-700",children:e}),td:({children:e})=>r.jsx("td",{className:"px-3 py-2 align-top text-sm border border-gray-200 dark:border-gray-700",children:e})};l.memo(({message:e,index:t,prevMessage:n,createDiff:s,onFileOpen:o,onShowSettings:a,onGrantToolPermission:i,autoExpandTools:c,showRawParameters:d,showThinking:u,selectedProject:p,provider:m,isActiveStreamingCard:h})=>{const{t:g}=Mt("chat"),x=e.provider||e.__provider||m||"claude",S=x==="codex",k=x==="gemini",I=x==="opencode",A=n&&n.type===e.type&&(n.type==="assistant"||n.type==="user"||n.type==="tool"||n.type==="error");return _y(e,m),r.jsx("div",{className:`chat-message ${e.type} ${A?"grouped":""} ${e.type==="user"?"flex justify-end px-3 sm:px-0":"px-3 sm:px-0"}`,children:e.type==="user"?r.jsxs("div",{className:"flex items-end space-x-0 sm:space-x-3 w-full sm:w-auto sm:max-w-[85%] md:max-w-md lg:max-w-lg xl:max-w-xl",children:[r.jsxs("div",{className:"bg-primary text-white rounded-2xl rounded-br-md px-3 sm:px-4 py-2 shadow-sm flex-1 sm:flex-initial",children:[r.jsx("div",{className:"text-sm whitespace-pre-wrap break-words",children:e.content}),e.images&&e.images.length>0&&r.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:e.images.map((w,M)=>r.jsx("img",{src:w.data,alt:w.name,className:"rounded-lg max-w-full h-auto cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>window.open(w.data,"_blank")},M))}),r.jsx("div",{className:"text-xs text-primary-foreground/80 mt-1 text-right",children:new Date(e.timestamp).toLocaleTimeString()})]}),!A&&r.jsx("div",{className:"hidden sm:flex w-8 h-8 bg-primary rounded-full items-center justify-center text-white text-sm flex-shrink-0",children:"U"})]}):r.jsxs("div",{className:"w-full",children:[!A&&r.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[e.type==="error"?r.jsx("div",{className:"w-8 h-8 bg-red-600 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0",children:"!"}):e.type==="tool"?r.jsx("div",{className:"w-8 h-8 bg-gray-600 dark:bg-gray-700 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0",children:"🔧"}):r.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0 p-1",children:S?r.jsx(ao,{className:"w-full h-full"}):k?r.jsx(io,{className:"w-full h-full"}):I?r.jsx(lo,{className:"h-full w-auto max-w-full text-gray-900 dark:text-white"}):r.jsx(Qn,{className:"w-full h-full"})}),r.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:e.type==="error"?g("messageTypes.error"):e.type==="tool"?g("messageTypes.tool"):S?g("messageTypes.codex"):k?g("messageTypes.gemini"):I?"OpenCode":g("messageTypes.claude")})]}),r.jsxs("div",{className:"w-full",children:[e.isToolUse?r.jsx($m,{toolName:e.toolName||"Tool",argsText:typeof e.toolInput=="string"?e.toolInput:JSON.stringify(e.toolInput??{},null,2),result:e.toolResult,isError:!!(e.toolResult?.isError||e.isError),status:e.isStreaming||e.toolResult==null?{type:"running"}:e.toolResult?.isError||e.isError?{type:"incomplete",reason:"error"}:{type:"complete"}}):e.isThinking?r.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:r.jsxs("details",{className:"group",open:h,children:[r.jsxs("summary",{className:"cursor-pointer text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 font-medium flex items-center gap-2",children:[r.jsx("svg",{className:"w-3 h-3 transition-transform group-open:rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),r.jsx("span",{children:g("thinking.emoji")})]}),r.jsx("div",{className:"mt-2 pl-4 border-l-2 border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 text-sm",children:r.jsx(Oa,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:e.content})})]})}):r.jsxs("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:[u&&e.reasoning&&r.jsxs("details",{className:"mb-3",open:h,children:[r.jsx("summary",{className:"cursor-pointer text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 font-medium",children:g("thinking.emoji")}),r.jsx("div",{className:"mt-2 pl-4 border-l-2 border-gray-300 dark:border-gray-600 italic text-gray-600 dark:text-gray-400 text-sm",children:r.jsx("div",{className:"whitespace-pre-wrap",children:e.reasoning})})]}),(()=>{const w=Fa(String(e.content||"")),M=w.trim();if((M.startsWith("{")||M.startsWith("["))&&(M.endsWith("}")||M.endsWith("]")))try{const C=JSON.parse(M),b=JSON.stringify(C,null,2);return r.jsxs("div",{className:"my-2",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm text-gray-600 dark:text-gray-400",children:[r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})}),r.jsx("span",{className:"font-medium",children:"JSON Response"})]}),r.jsx("div",{className:"bg-gray-800 dark:bg-gray-900 border border-gray-600/30 dark:border-gray-700 rounded-lg overflow-hidden",children:r.jsx("pre",{className:"p-4 overflow-x-auto",children:r.jsx("code",{className:"text-gray-100 dark:text-gray-200 text-sm font-mono block whitespace-pre",children:b})})})]})}catch{}return e.type==="assistant"?r.jsx(Oa,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:w}):r.jsx("div",{className:"whitespace-pre-wrap",children:w})})()]}),r.jsx("div",{className:`text-xs text-gray-500 dark:text-gray-400 mt-1 ${A?"opacity-0 group-hover:opacity-100":""}`,children:new Date(e.timestamp).toLocaleTimeString()})]})]})})});const Ly=({file:e,onRemove:t,uploadProgress:n,error:s})=>{const[o,a]=l.useState(null);return l.useEffect(()=>{const i=URL.createObjectURL(e);return a(i),()=>URL.revokeObjectURL(i)},[e]),r.jsxs("div",{className:"relative group",children:[r.jsx("img",{src:o,alt:e.name,className:"w-20 h-20 object-cover rounded"}),n!==void 0&&n<100&&r.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:r.jsxs("div",{className:"text-white text-xs",children:[n,"%"]})}),s&&r.jsx("div",{className:"absolute inset-0 bg-red-500/50 flex items-center justify-center",children:r.jsx("svg",{className:"w-6 h-6 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),r.jsx("button",{onClick:t,className:"absolute -top-2 -right-2 bg-red-500 text-white rounded-full p-1 opacity-0 group-hover:opacity-100",children:r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})};function Oy({selectedProject:e,selectedSession:t,ws:n,sendMessage:s,latestMessage:o,onFileOpen:a,onInputFocusChange:i,onSessionActive:c,onSessionInactive:d,onSessionProcessing:u,onSessionNotProcessing:p,processingSessions:m,onReplaceTemporarySession:h,onNavigateToSession:g,onShowSettings:x,autoExpandTools:S,showRawParameters:k,showThinking:I,autoScrollToBottom:A,sendByCtrlEnter:w,externalMessageUpdate:M,urlContext:C,urlPrompt:b,integrationClientId:R,latestIntegrationMessage:B,sendIntegrationMessage:D,newSessionResetNonce:Z=0}){const{t:z}=Mt("chat"),[X,q]=l.useState(()=>typeof window<"u"&&e?.name&&Et.getItem(`draft_input_${e.name}`)||""),re=l.useMemo(()=>typeof window<"u"&&e?.name?Ty(e.name,t?.id||null):[],[e?.name,t?.id]),[Se,Ce]=l.useReducer(Jv,re,Gv),ye=Se.messages,de=Se.phase,H=Se.isLoading,Oe=Se.canAbortSession,$=Se.pendingPermissionRequests,N=e?.fullPath||e?.path||null,O=l.useRef(!1),ne=l.useRef(ye),ke=l.useRef(e),ge=l.useRef(!1),P=l.useRef(Z),ie=l.useRef(Yl),[ee,Ne]=l.useState(t?.id||null),[it,Ke]=l.useState(!1),[Ge,qe]=l.useState([]),[lt,It]=l.useState(!1),[Xe,kt]=l.useState(!1),[je,Ve]=l.useState(0),[jt,St]=l.useState(!1),[Dt,Y]=l.useState(0),oe=100,[Ee,Te]=l.useState(!1),[Fe,tt]=l.useState(()=>{const f=nr(localStorage.getItem("selected-provider"));return zl(f).defaultMode}),ue=l.useCallback(f=>{Ce({type:"replace_messages",value:f})},[]),dt=l.useCallback(f=>{Ce({type:"replace_permissions",value:f})},[]),Ye=l.useCallback(f=>{Ce({type:"set_loading",value:f})},[]),Qe=l.useCallback(f=>{Ce({type:"set_can_abort",value:f})},[]),ze=l.useCallback((f,v)=>{Ce({type:"set_phase",phase:f,overrides:v})},[]),Lt=l.useCallback((f,v)=>{Ce({type:"apply_conversation_event",event:f,provider:v})},[]),Nt=l.useCallback(f=>{!f||typeof f!="object"||qe(v=>{const y=Array.isArray(v)?v:[];return y.some(_=>ry(_,f))?y:[...y,f]})},[]),xt=l.useRef({sessionId:null,startedAt:0}),$t=l.useCallback(f=>{xt.current={sessionId:f||null,startedAt:Date.now()}},[]),rt=l.useCallback(f=>{!f||!xt.current.startedAt||(xt.current={...xt.current,sessionId:f})},[]),ft=l.useCallback((f=null)=>{const v=xt.current;v.startedAt&&(f&&v.sessionId&&v.sessionId!==f||(xt.current={sessionId:null,startedAt:0}))},[]),qt=l.useCallback((f,v=null)=>{if(v&&v!=="session-status")return!1;const y=xt.current;return!!(y.startedAt&&f&&y.sessionId===f&&Date.now()-y.startedAt<uy&&(de===le.CONNECTING||de===le.QUEUED||de===le.STREAMING||de===le.AWAITING_APPROVAL||de===le.COMPLETED||de===le.ABORTED||de===le.ERRORED))},[de]),[At,ht]=l.useState([]),[Qt,Vt]=l.useState(new Map),[Zt,Rt]=l.useState(new Map),T=l.useRef(null),G=l.useRef(null),Me=l.useRef(null),fe=l.useRef(null),j=l.useRef(null),F=l.useRef(!1),xe=l.useRef(!1),ve=l.useRef(0),ut=l.useRef(!1),U=l.useRef(null),ot=l.useRef(""),L=l.useRef(null),W=l.useCallback(()=>{L.current&&(clearTimeout(L.current),L.current=null),ot.current=""},[]),se=l.useRef(null),E=l.useRef(new Set),J=l.useRef(new Map),Q=l.useRef(M),he=l.useRef(null),[we,te]=l.useState(""),[Je,vt]=l.useState(!1),[yt,ct]=l.useState([]),[He,Ot]=l.useState([]),[Ct,qr]=l.useState([]),[pr,Ft]=l.useState(-1),[Mn,Zn]=l.useState(0),[vi,es]=l.useState(-1),[fo,Dn]=l.useState(!1),ho=l.useRef({height:0,top:0}),[go,Rr]=l.useState(!1),[Pr,xo]=l.useState([]),[Vr,vo]=l.useState([]),[ts,Lr]=l.useState(""),[tp,Kr]=l.useState(!1),[mr,Or]=l.useState(null),[yo,Fr]=l.useState(-1),[yi,$r]=l.useState(-1),[Rn,rp]=l.useState(100),[bo,bt]=l.useState(null),bi=l.useRef(null),[Gr,rs]=l.useState("none"),[wo,np]=l.useState(!1),[wi,sp]=l.useState(!1),ko=l.useRef(null),jo=l.useRef(null),[me,ki]=l.useState(()=>nr(localStorage.getItem("selected-provider"))),Br=l.useMemo(()=>zl(me),[me]),Jr=l.useMemo(()=>Ul(me),[me]),So=l.useCallback((f,{short:v=!1}={})=>{let y=z("codex.modes.default");return f==="acceptEdits"?y=z("codex.modes.acceptEdits"):f==="bypassPermissions"?y=z("codex.modes.bypassPermissions"):f==="plan"&&(y=z("codex.modes.plan")),v?y.replace(/\s*模式$/,"").replace(/\s*Mode$/,""):y},[z]),op=l.useMemo(()=>So(Fe,{short:!0}),[So,Fe]),ji=l.useMemo(()=>z("codex.permissionMode").replace(/^权限/,"").replace(/^Permission\s+/i,""),[z]),[No,Co]=l.useState({});l.useEffect(()=>{bi.current=bo},[bo]),l.useEffect(()=>()=>{J.current.forEach(f=>clearTimeout(f)),J.current.clear()},[]);const[ap,Si]=l.useState({}),[ip,Ni]=l.useState({}),Eo=l.useCallback(async(f,{force:v=!1}={})=>{if(!cy.includes(f))return null;Si(y=>({...y,[f]:!0})),Ni(y=>({...y,[f]:null})),Co(y=>({...y,[f]:{status:ly}}));try{const _=await ce(`/api/cli/providers/${f}/installation-status${v?"?force=true":""}`),V=await _.json().catch(()=>({}));if(!_.ok||V?.success!==!0)throw new Error(V?.error||`Failed to check ${f} installation`);const ae=V.installed?iy:ia;return Co(be=>({...be,[f]:{status:ae,command:V.command||null,resolvedPath:V.resolvedPath||null,reason:V.reason||null,installHint:V.installHint||null,checkedAt:V.checkedAt||null,cacheHit:!!V.cacheHit}})),ae}catch(y){return Co(_=>({..._,[f]:{status:Ms}})),Ni(_=>({..._,[f]:y.message})),Ms}finally{Si(y=>({...y,[f]:!1}))}},[]),[Io,Ci]=l.useState(()=>_s("claude")),[Ao,Ei]=l.useState(()=>_s("codex")),[To,Ii]=l.useState(()=>_s("gemini")),[_o,Ai]=l.useState(()=>_s("opencode")),[Ti,Mo]=l.useState({}),[lw,_i]=l.useState({}),[lp,Mi]=l.useState({}),ns=me==="claude"?Io:me==="codex"?Ao:me==="gemini"?To:_o,Di=l.useMemo(()=>Zv(me).OPTIONS,[me]),Do=l.useMemo(()=>(Ti[me]||[]).map(f=>({value:f,label:f})),[Ti,me]),Yr=t?.__provider===me&&fy(me,t?.model)?t.model.trim():"",Kt=Yr||ns,ss=l.useMemo(()=>{const f=Do.length>0?Do:Di;return!Yr||f.some(v=>v.value===Yr)?f:[{value:Yr,label:Yr},...f]},[Do,Di,Yr]),cp=ss.find(f=>f.value===Kt)?.label||Kt||z("providerSelection.selectModel"),dp=!!Yr,os=me==="opencode"&&!!lp.opencode,as=l.useCallback(f=>{if(!f)return;const v=nr(f);ki(v),localStorage.setItem("selected-provider",v),Eo(v)},[Eo]),dn=l.useMemo(()=>Jl(C),[C]),[cw,Ro]=l.useState(dn),[jr,un]=l.useState(dn),[is,ls]=l.useState(!1),Ri=l.useRef(dn),Pi=l.useRef(me);l.useEffect(()=>{const f=ss.map(v=>v.value);ns&&(f.includes(ns)||(me==="claude"?Ci(""):me==="codex"?Ei(""):me==="gemini"?Ii(""):me==="opencode"&&Ai(""),ty(me)))},[me,ns,ss]),l.useEffect(()=>{if(!e)return;const f=e.fullPath||e.path;if(!f)return;const v=`runtime-models:v2:${me}:${f}`,y=Ga(Et.getItem(v)),_=Array.isArray(y?.models)?y.models:[],V=typeof y?.currentModel=="string"?y.currentModel.trim():"",ae=Number(y?.timestamp||0);if(_.length>0&&Date.now()-ae<dy){Mo($e=>({...$e,[me]:_})),V&&_i($e=>({...$e,[me]:{...$e?.[me]||{},currentModel:V}}));return}let Ue=!1;return Mi($e=>({...$e,[me]:!0})),mt.providerDiscovery(me,f).then(async $e=>{if(!$e.ok)throw new Error(`HTTP ${$e.status}`);return $e.json()}).then($e=>{if(Ue)return;const gt=Array.isArray($e?.models)?$e.models.map(Ze=>Ze.id):[],_t=typeof $e?.currentModel=="string"?$e.currentModel.trim():"";_i(Ze=>({...Ze,[me]:$e})),Mo(Ze=>({...Ze,[me]:gt})),gt.length>0&&Et.setItem(v,JSON.stringify({models:gt,currentModel:_t||"",timestamp:Date.now()}))}).catch(()=>{Ue||Mo($e=>({...$e,[me]:_}))}).finally(()=>{Ue||Mi($e=>({...$e,[me]:!1}))}),()=>{Ue=!0}},[me,e,wo]),l.useEffect(()=>{if(!wo)return;const f=v=>{ko.current&&!ko.current.contains(v.target)&&np(!1)};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[wo]),l.useEffect(()=>{if(!wi)return;const f=v=>{jo.current&&!jo.current.contains(v.target)&&sp(!1)};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[wi]),l.useEffect(()=>{O.current=H},[H]),l.useEffect(()=>{ne.current=ye},[ye]),l.useEffect(()=>{ke.current=e},[e]);const cs=l.useCallback((f=null)=>{const v=ke.current?.name||e?.name||"";v&&Xl(v,f,ne.current)},[e?.name]);l.useEffect(()=>{P.current!==Z&&(P.current=Z,!t&&(W(),ft(),se.current=null,sessionStorage.removeItem("pendingSessionId"),Ne(null),qe([]),ue([]),dt([]),Te(!1),ze(le.IDLE),bt(null),Qe(!1),q(""),Or(null),Dn(!1),e?.name&&(Et.removeItem(`chat_messages_${e.name}`),Et.removeItem(`draft_input_${e.name}`))))},[ft,Z,W,e?.name,t,Qe,ue,dt,ze]),l.useEffect(()=>{Ri.current=jr},[jr]),l.useEffect(()=>{if(ie.current)return;const f=Pa(b);f&&(q(f),ge.current=!0,ie.current=!0,Yl=!0)},[b]),l.useEffect(()=>{Ro(dn),un(dn),ls(!1)},[dn]);const lr=l.useCallback((f,v,y={})=>{!v||typeof D!="function"||D({type:f,requestId:v,payload:{...y,clientId:R||null}})},[R,D]),Li=l.useCallback((f,v=null)=>{if(!Tr(f?.context)){console.warn("[DynamicContext] Ignored integration.context.update because context is not an object."),lr("integration.error",v,{code:"INVALID_PAYLOAD",message:"context must be an object"});return}if(Ny(f.mode)===La){const V=Sy(Ri.current,f.context);if(!V){console.warn("[DynamicContext] Ignored invalid append context payload."),lr("integration.error",v,{code:"INVALID_PAYLOAD",message:"append context payload is invalid"});return}Ro(V),un(V),ls(!1),lr("integration.ack",v,{accepted:!0,applied:!0});return}const _=Jl(f.context);if(!_){lr("integration.error",v,{code:"INVALID_PAYLOAD",message:"context payload does not satisfy contextV1"});return}Ro(_),un(_),ls(!1),lr("integration.ack",v,{accepted:!0,applied:!0})},[lr]),Oi=l.useCallback((f,v=null)=>{if(typeof f?.prompt!="string"){lr("integration.error",v,{code:"INVALID_PAYLOAD",message:"prompt must be a string"});return}const y=Pa(f.prompt);if(q(y),ge.current=!0,f.autoSend===!0&&y&&ke.current&&!O.current&&Pn.current){const _={preventDefault:()=>{}};Pn.current(_,y)}lr("integration.ack",v,{accepted:!0,applied:!0})},[lr]),Fi=l.useCallback((f=null)=>{lr("integration.ack",f,{accepted:!0,available:!0,pageUrl:typeof window<"u"?window.location.href:null,sessionId:t?.id||null})},[t?.id,lr]);l.useEffect(()=>{if(!B?.__messageSeq)return;const v=B?.type;if(v==="integration.context.update"){Li(B.payload||{},B.requestId||null);return}if(v==="integration.prompt.update"){Oi(B.payload||{},B.requestId||null);return}v==="integration.ping"&&Fi(B.requestId||null)},[Li,Oi,B,Fi]);const er=l.useMemo(()=>is||!jr||!yy(jr)?null:jr,[is,jr]),up=l.useMemo(()=>er?.selectedElements?.length?er.selectedElements.slice(0,Vl):[],[er]),Po=l.useMemo(()=>er?.selectedElements?.length?er.selectedElements.slice(Vl):[],[er]),pp=l.useCallback(()=>{un(f=>!f||!br(f.systemContext)?f:{...f,systemContext:""})},[]),mp=l.useCallback(()=>{un(f=>!f||!br(bn(f.currentFile))?f:{...f,currentFile:{path:"",displayName:""}})},[]),fp=l.useCallback(f=>{un(v=>{if(!v||!Array.isArray(v.selectedElements)||v.selectedElements.length===0)return v;const y=v.selectedElements.findIndex(_=>_.tag===f.tag&&_.selector===f.selector&&_.label===f.label);return y<0?v:{...v,selectedElements:v.selectedElements.filter((_,V)=>V!==y)}})},[]);l.useEffect(()=>{if(t?.id){const f=localStorage.getItem(`permissionMode-${t.id}`);f&&Br.modes.includes(f)?tt(f):tt(Br.defaultMode)}},[t?.id,Br]),l.useEffect(()=>{Br.modes.includes(Fe)||tt(Br.defaultMode)},[Fe,Br]),l.useEffect(()=>{if(!Jr.enabled){Gr!==Jr.defaultMode&&rs(Jr.defaultMode);return}Jr.modes.includes(Gr)||rs(Jr.defaultMode)},[Jr,Gr]),l.useEffect(()=>{if(t&&t.__provider&&t.__provider!==me){const f=nr(t.__provider);ki(f),localStorage.setItem("selected-provider",f)}if(t?.id&&t?.__provider)try{const f=localStorage.getItem("session-provider-map"),v=f?JSON.parse(f):{};v[t.id]!==t.__provider&&(v[t.id]=t.__provider,localStorage.setItem("session-provider-map",JSON.stringify(v)))}catch{}},[t]),l.useEffect(()=>{Pi.current!==me&&(dt([]),Pi.current=me)},[me]),l.useEffect(()=>{dt(f=>f.filter(v=>!v.sessionId||v.sessionId===t?.id))},[t?.id]),l.useEffect(()=>{(async()=>{if(e)try{const v=await ce("/api/commands/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPath:e.path})});if(!v.ok)throw new Error("Failed to fetch commands");const y=await v.json(),_=[...(y.builtIn||[]).map(be=>({...be,type:"built-in"})),...(y.custom||[]).map(be=>({...be,type:"custom"}))];xo(_);const V=`command_history_${e.name}`,ae=Et.getItem(V);if(ae)try{const be=JSON.parse(ae),Ue=_.sort(($e,gt)=>{const _t=be[$e.name]||0;return(be[gt.name]||0)-_t});xo(Ue)}catch(be){console.error("Error parsing command history:",be)}}catch(v){console.error("Error fetching slash commands:",v),xo([])}})()},[e]);const Lo=l.useMemo(()=>Pr.length?new _n(Pr,{keys:[{name:"name",weight:2},{name:"description",weight:1}],threshold:.4,includeScore:!0,minMatchCharLength:1}):null,[Pr]);l.useEffect(()=>{if(!ts){vo(Pr);return}if(!Lo){vo([]);return}const f=Lo.search(ts);vo(f.map(v=>v.item))},[ts,Pr,Lo]);const hp=l.useMemo(()=>{if(!e||Pr.length===0)return[];const f=`command_history_${e.name}`,v=Et.getItem(f);if(!v)return[];try{const y=JSON.parse(v);return Pr.map(V=>({...V,usageCount:y[V.name]||0})).filter(V=>V.usageCount>0).sort((V,ae)=>ae.usageCount-V.usageCount).slice(0,5)}catch(y){return console.error("Error parsing command history:",y),[]}},[e,Pr]),gp=l.useCallback((f,v,y)=>{if(!f||!e)return;if(y){Fr(v);return}const _=`command_history_${e.name}`,V=Et.getItem(_);let ae={};try{ae=V?JSON.parse(V):{}}catch(be){console.error("Error parsing command history:",be)}ae[f.name]=(ae[f.name]||0)+1,Et.setItem(_,JSON.stringify(ae)),$i(f)},[e]),xp=l.useCallback(f=>{const{action:v,data:y}=f;switch(v){case"clear":ue([]),qe([]);break;case"help":ue(_=>[..._,{role:"assistant",content:y.content,timestamp:Date.now()}]);break;case"model":{const _=Object.entries(y.available||{}).filter(([,ae])=>Array.isArray(ae)&&ae.length>0).map(([ae,be])=>`**${ae.charAt(0).toUpperCase()+ae.slice(1)}**: ${be.join(", ")}`).join(`
|
|
284
|
-
|
|
285
|
-
`),V=y.current.provider==="opencode"?y.opencodeDiscovery?"_OpenCode source: runtime provider registry._":"_OpenCode source: local fallback list._":"";ue(ae=>[...ae,{role:"assistant",content:`**Current Model**: ${y.current.model}
|
|
286
|
-
|
|
287
|
-
**Available Models**:
|
|
288
|
-
|
|
289
|
-
${_}${V?`
|
|
290
|
-
|
|
291
|
-
${V}`:""}`,timestamp:Date.now()}])}break;case"cost":{const _=`**Token Usage**: ${y.tokenUsage.used.toLocaleString()} / ${y.tokenUsage.total.toLocaleString()} (${y.tokenUsage.percentage}%)
|
|
292
|
-
|
|
293
|
-
**Estimated Cost**:
|
|
294
|
-
- Input: $${y.cost.input}
|
|
295
|
-
- Output: $${y.cost.output}
|
|
296
|
-
- **Total**: $${y.cost.total}
|
|
297
|
-
|
|
298
|
-
**Model**: ${y.model}`;ue(V=>[...V,{role:"assistant",content:_,timestamp:Date.now()}]);break}case"status":{const _=`**System Status**
|
|
299
|
-
|
|
300
|
-
- Version: ${y.version}
|
|
301
|
-
- Uptime: ${y.uptime}
|
|
302
|
-
- Model: ${y.model}
|
|
303
|
-
- Provider: ${y.provider}
|
|
304
|
-
- Node.js: ${y.nodeVersion}
|
|
305
|
-
- Platform: ${y.platform}`;ue(V=>[...V,{role:"assistant",content:_,timestamp:Date.now()}]);break}case"memory":y.error?ue(_=>[..._,{role:"assistant",content:`⚠️ ${y.message}`,timestamp:Date.now()}]):(ue(_=>[..._,{role:"assistant",content:`📝 ${y.message}
|
|
306
|
-
|
|
307
|
-
Path: \`${y.path}\``,timestamp:Date.now()}]),y.exists&&a&&a(y.path));break;case"config":x&&x();break;case"rewind":y.error?ue(_=>[..._,{role:"assistant",content:`⚠️ ${y.message}`,timestamp:Date.now()}]):(ue(_=>_.slice(0,-y.steps*2)),ue(_=>[..._,{role:"assistant",content:`⏪ ${y.message}`,timestamp:Date.now()}]));break;default:console.warn("Unknown built-in command action:",v)}},[a,x]),Pn=l.useRef(null),vp=l.useCallback(async(f,v)=>{const{content:y,hasBashCommands:_,hasFileIncludes:V}=f;if(_&&!window.confirm("这条命令包含将要执行的 Bash 命令,是否继续?")){ue(be=>[...be,{role:"assistant",content:"❌ 已取消命令执行",timestamp:Date.now()}]);return}q(y),setTimeout(()=>{if(Pn.current){const ae={preventDefault:()=>{}};Pn.current(ae)}},50)},[]),$i=l.useCallback(async f=>{if(!(!f||!e))try{const v=X.match(new RegExp(`${f.name}\\s*(.*)`)),y=v&&v[1]?v[1].trim().split(/\s+/):[],_={projectPath:e.path,projectName:e.name,sessionId:ee,provider:me,...Kt?{model:Kt}:{},tokenUsage:mr},V=await ce("/api/commands/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandName:f.name,commandPath:f.path,args:y,context:_})});if(!V.ok)throw new Error("Failed to execute command");const ae=await V.json();ae.type==="builtin"?xp(ae):ae.type==="custom"&&await vp(ae,y),q(""),Rr(!1),$r(-1),Lr(""),Fr(-1)}catch(v){console.error("Error executing command:",v),ue(y=>[...y,{role:"assistant",content:`Error executing command: ${v.message}`,timestamp:Date.now()}])}},[X,e,ee,me,Ao,To,_o,Io,mr]),yp=l.useMemo(()=>{const f=new Map;return(v,y)=>{const _=`${v.length}-${y.length}-${v.slice(0,50)}`;if(f.has(_))return f.get(_);const V=bp(v,y);if(f.set(_,V),f.size>100){const ae=f.keys().next().value;f.delete(ae)}return V}},[]),Sr=l.useCallback(async(f,v,y=!1,_="claude",V=null)=>{if(!f||!v)return[];const ae=!y;ae?It(!0):kt(!0);try{const be=V??(y?ve.current:0),Ue=N,$e=await mt.sessionEvents(_,v,f,Ue,oe,be);if(!$e.ok)throw new Error("Failed to load session messages");const gt=await $e.json();if(ae&>.tokenUsage&&Or(gt.tokenUsage),gt.hasMore!==void 0){St(gt.hasMore),Y(gt.total);const _t=be+(gt.events?.length||0);return ve.current=_t,Ve(_t),gt.events||[]}else{const _t=gt.events||gt.messages||[];return St(!1),Y(_t.length),ve.current=_t.length,Ve(_t.length),_t}}catch(be){return console.error("Error loading session messages:",be),[]}finally{ae?It(!1):kt(!1)}},[N]),bp=(f,v)=>{const y=f.split(`
|
|
308
|
-
`),_=v.split(`
|
|
309
|
-
`),V=[];let ae=0,be=0;for(;ae<y.length||be<_.length;){const Ue=y[ae],$e=_[be];ae>=y.length?(V.push({type:"added",content:$e,lineNum:be+1}),be++):be>=_.length?(V.push({type:"removed",content:Ue,lineNum:ae+1}),ae++):Ue===$e?(ae++,be++):(V.push({type:"removed",content:Ue,lineNum:ae+1}),V.push({type:"added",content:$e,lineNum:be+1}),ae++,be++)}return V},wp=(f,v="claude")=>Su(f,v).map(y=>({...y,provider:y.provider||v})),Bt=t?.__provider||me||"claude",Bi=l.useMemo(()=>wp(Ge,Bt),[Ge,Bt]),zr=l.useCallback((f=[])=>{let v=null;for(const y of f)if(!(!y||typeof y!="object")){if(y.kind==="error"){v=le.ERRORED;continue}if(y.kind==="session_state_changed"){const _=String(y.payload?.state||"").trim().toLowerCase();Object.values(le).includes(_)&&(v=_);continue}if(y.kind==="approval_request"){v=le.AWAITING_APPROVAL;continue}if(y.kind==="approval_resolved"){v=le.STREAMING;continue}(y.kind==="assistant_text_start"||y.kind==="assistant_text_delta"||y.kind==="reasoning_start"||y.kind==="reasoning_delta"||y.kind==="tool_call_start"||y.kind==="tool_call_input"||y.kind==="tool_call_end"||y.kind==="tool_result"||y.kind==="system_notice")&&(v=le.STREAMING)}return v},[]),ds=l.useCallback((f=[])=>{const v=zr(f);return v===le.COMPLETED||v===le.ABORTED||v===le.ERRORED?v:null},[zr]),zi=l.useCallback(f=>!(f===le.COMPLETED||f===le.ABORTED||f===le.ERRORED),[]),pn=l.useCallback((f,v)=>v&&(ze(v),(v===le.COMPLETED||v===le.ABORTED||v===le.ERRORED)&&(ft(f),bt(null),f&&(d&&d(f),p&&p(f))),v),[ft,d,p,ze]),Ui=l.useCallback(async(f,v)=>{const y=ke.current;if(!y?.name||!f)return null;const _=await Sr(y.name,f,!1,v||Bt);return Array.isArray(_)&&_.length>0&&qe(_),zr(_)},[Bt,zr,Sr]),Ur=l.useCallback(async(f,v)=>{const y=await Ui(f,v);return pn(f,y)},[Ui,pn]),Wi=l.useCallback((f,v=[])=>{const y=zr(v);return pn(f,y),y},[zr,pn]),Hi=l.useCallback((f,v)=>v===le.COMPLETED||v===le.ABORTED||v===le.ERRORED?(pn(f,v),v):null,[pn]),Oo=l.useCallback((f,v)=>{if(!f)return;const y=J.current.get(f);y&&clearTimeout(y);const _=setTimeout(()=>{J.current.delete(f);const V=t?.id||ee||null;!V||V!==f||(Ur(f,v),s&&s({type:"check-session-status",sessionId:f,provider:v||Bt}))},1200);J.current.set(f,_)},[Bt,ee,Ur,t?.id,s]),Nr=l.useCallback(()=>{j.current&&(j.current.scrollTop=j.current.scrollHeight)},[]),us=l.useCallback(()=>{if(!j.current)return!1;const{scrollTop:f,scrollHeight:v,clientHeight:y}=j.current;return v-f-y<50},[]),ps=l.useCallback(async(f=null)=>{const v=f||j.current;if(!v||xe.current||Xe||!jt||!t||!e)return!1;const y=t.__provider||me||"claude";xe.current=!0;const _=v.scrollHeight,V=v.scrollTop,ae=ve.current;try{const be=await Sr(e.name,t.id,!0,y,ae);return be.length>0&&(U.current={height:_,top:V},qe(Ue=>[...be,...Ue])),!0}finally{xe.current=!1}},[jt,Xe,t,e,Sr,me]),ms=l.useCallback(async()=>{if(j.current){const f=j.current,v=us();Dn(!v),f.scrollTop<100?ut.current||await ps(f)&&(ut.current=!0):ut.current=!1}},[us,ps]);l.useLayoutEffect(()=>{if(!U.current||!j.current)return;const{height:f,top:v}=U.current,y=j.current,V=y.scrollHeight-f;y.scrollTop=v+Math.max(V,0),U.current=null},[ye.length]),l.useEffect(()=>{let f=!1,v=null;return(async()=>{if(t&&e){const _=t.__provider||nr(localStorage.getItem("selected-provider"));F.current=!0,sessionStorage.removeItem("pendingSessionId");const V=ee!==null&&ee!==t.id;let ae=null;if(V?(Ee||(W(),ft(),se.current=null,ue([]),qe([]),bt(null),Qe(!1)),ve.current=0,Ve(0),St(!1),Y(0),Or(null),Ye(!1)):ee===null&&(ve.current=0,Ve(0),St(!1),Y(0)),Ne(t.id),Ee)f||Te(!1);else{const be=await Sr(e.name,t.id,!1,t.__provider||_||"claude");if(f)return;qe(be),ae=Wi(t.id,be),ae||ze(le.IDLE),n&&s&&zi(ae)&&s({type:"check-session-status",sessionId:t.id,provider:_})}}else{const V=se.current?.sessionId||null||O.current&&(ee||xt.current.sessionId)||null,ae=!!(V||O.current);Ee||ae||(W(),ft(),se.current=null,ue([]),qe([]),bt(null),Qe(!1),Ye(!1)),Ne(V),ve.current=0,Ve(0),St(!1),Y(0),Or(null)}v=setTimeout(()=>{f||(F.current=!1)},250)})(),()=>{f=!0,v&&clearTimeout(v)}},[t?.id,t?.__provider,e?.name,e?.fullPath,e?.path,Sr,Nr,Ee,W,ft,Wi,s,ze,zi,n]),l.useEffect(()=>{const f=Q.current;if(M<=f||(Q.current=M,!t||!e))return;(async()=>{try{const y=t.__provider||nr(localStorage.getItem("selected-provider")),_=await Sr(e.name,t.id,!1,t.__provider||y||"claude");qe(_),A&&us()&&setTimeout(()=>Nr(),200)}catch(y){console.error("Error reloading messages from external update:",y)}})()},[M,t,e,Sr,us,A,Nr]),l.useEffect(()=>{Q.current=M},[M,e?.name,t?.id]),l.useEffect(()=>{t?.id&&(se.current=null)},[t?.id]),l.useEffect(()=>{const f=t?.id||ee||null,v=xt.current,y=!!(v.startedAt&&(!v.sessionId||!f||v.sessionId===f)&&de!==le.IDLE);ue(_=>Wv(_,Bi,{preserveLocalTail:y}))},[Bi,ee,de,t?.id,ue]),l.useEffect(()=>{i&&i(it)},[it,i]),l.useEffect(()=>{e&&X!==""?Et.setItem(`draft_input_${e.name}`,X):e&&X===""&&Et.removeItem(`draft_input_${e.name}`)},[X,e]),l.useEffect(()=>{e?.name&&Xl(e.name,t?.id||null,ye)},[ye,e?.name,t?.id]),l.useEffect(()=>{const f=ui(ye);Ay(ye,f)||ue(f)},[ye,ue]),l.useEffect(()=>{if(e){if(ge.current){ge.current=!1;return}const f=Et.getItem(`draft_input_${e.name}`)||"";f!==X&&q(f)}},[e?.name]),l.useEffect(()=>{ee&&H&&u&&u(ee)},[H,ee,u]),l.useEffect(()=>{if(ee&&m){const f=m.has(ee),v=ds(Ge);if(f&&v){p&&p(ee);return}f&&!H&&de!==le.COMPLETED&&de!==le.ABORTED&&de!==le.ERRORED&&ze(le.STREAMING,{canAbortSession:!0})}},[ee,ds,H,p,m,de,Ge]),l.useEffect(()=>{if(o){const f=o.data?.message||o.data,y=["projects_updated","session-created"].includes(o.type),_=new Set(["claude-complete","codex-complete","session-aborted","claude-error","codex-error"]),ae=o.type==="claude-response"&&f&&f.type==="system"&&f.subtype==="init"?f?.session_id:null,be=sessionStorage.getItem("pendingSessionId");let Ue=t?.id||ee||se.current?.sessionId||null;const $e=ae&&(!Ue||ae===Ue),gt=y||$e,_t=!o.sessionId&&se.current&&!se.current.sessionId&&(/error/i.test(o.type||"")||o.type==="conversation-event"&&o.event?.kind==="error"),Ze=We=>{We&&(d&&d(We),p&&p(We))};if(!gt){if(!Ue&&o.sessionId&&!Ds(o.sessionId)&&se.current&&!se.current.sessionId&&(Ue=o.sessionId,se.current.sessionId=o.sessionId,Ne(o.sessionId)),!Ue&&(o.sessionId&&_.has(o.type)&&Ze(o.sessionId),!_t)||!o.sessionId&&!_t)return;if(!_t&&o.sessionId!==Ue){const We=Ds(Ue),pt=!!(o.sessionId&&be&&o.sessionId===be);if(We&&(pt||!Ds(o.sessionId||"")))Ne(o.sessionId),se.current&&(se.current.sessionId=o.sessionId);else{o.sessionId&&_.has(o.type)&&Ze(o.sessionId),console.log("??-?,? Skipping message for different session:",o.sessionId,"current:",Ue);return}}}const hs=o?.event?.sessionId||o.sessionId||Ue||null,tr=!!(hs&&E.current.has(hs));if(o.type==="conversation-event"&&o.event){const We=o.event.sessionId||o.sessionId||Ue||null,pt=o.event.rawRef?.type||null,rr=o.event.kind==="session_state_changed"?String(o.event.payload?.state||"").trim().toLowerCase():"";if(We&&E.current.add(We),rr==="idle"&&qt(We,pt)){Oo(We,o.event.provider||Bt);return}if(!!(We&&(We===(t?.id||null)||We===(ee||null)||We===(se.current?.sessionId||null)))&&Nt(o.event),Lt(o.event,o.event.provider||Bt),o.event.kind==="approval_request"&&ze(le.AWAITING_APPROVAL),o.event.kind==="approval_resolved"&&ze(le.STREAMING),(o.event.kind==="assistant_text_start"||o.event.kind==="assistant_text_delta"||o.event.kind==="reasoning_start"||o.event.kind==="reasoning_delta"||o.event.kind==="tool_call_start"||o.event.kind==="tool_call_input"||o.event.kind==="tool_call_end"||o.event.kind==="tool_result")&&ze(le.STREAMING),(o.event.kind==="error"||o.event.payload?.state==="errored")&&(ft(We),ze(le.ERRORED),bt(null),We&&(Ze(We),Ur(We,o.event.provider||Bt))),o.event.kind==="session_state_changed"){const Gt=rr;Gt==="streaming"?(ze(le.STREAMING),We&&u&&u(We)):Gt==="awaiting_approval"?(ze(le.AWAITING_APPROVAL),We&&u&&u(We)):Gt==="completed"?(ft(We),ze(le.COMPLETED),bt(null),We&&(Ze(We),Ur(We,o.event.provider||Bt))):Gt==="aborted"?(ft(We),ze(le.ABORTED),bt(null),We&&(Ze(We),Ur(We,o.event.provider||Bt))):Gt==="errored"&&(ft(We),ze(le.ERRORED),bt(null),We&&(Ze(We),Ur(We,o.event.provider||Bt)))}return}switch(o.type){case"ws-connection-state":o.state==="connecting"&&(de===le.QUEUED||H)?ze(le.CONNECTING,{canAbortSession:!1}):o.state==="connected"&&de===le.CONNECTING&&ze(le.QUEUED);break;case"connection-error":ze(le.ERRORED),bt(null),ue(K=>[...K,{type:"error",content:o.error||"Unable to reach the chat server. Message was not sent.",timestamp:new Date}]);break;case"error":ze(le.ERRORED),Qe(!1),bt(null),ue(K=>[...K,{type:"error",content:o.error||"The chat server reported an unexpected error.",timestamp:new Date}]);break;case"session-created":if(o.sessionId){const K=nr(o.provider||Bt),pe=se.current?.sessionId||ee||null,Ie=Ds(o.sessionId);if(!(!ee||K==="codex"&&o.sessionId!==ee)||Ie)break;sessionStorage.setItem("pendingSessionId",o.sessionId);try{const et=localStorage.getItem("session-provider-map"),nt=et?JSON.parse(et):{};nt[o.sessionId]=K,localStorage.setItem("session-provider-map",JSON.stringify(nt))}catch{}cs(o.sessionId),se.current&&(se.current.sessionId=o.sessionId),Ne(o.sessionId),rt(o.sessionId),u&&u(o.sessionId),Te(!0),h&&h(o.sessionId,pe),dt(et=>et.map(nt=>nt.sessionId?nt:{...nt,sessionId:o.sessionId})),g&&g(o.sessionId),typeof window<"u"&&typeof window.refreshProjects=="function"&&window.refreshProjects()}break;case"token-budget":o.data&&Or(o.data);break;case"claude-response":const We=tr&&!(o.data?.type==="system"&&o.data?.subtype==="init");if(!We&&f&&typeof f=="object"&&f.type){if(f.type==="content_block_delta"&&f.delta?.text){const K=Qr(f.delta.text);ot.current+=K,L.current||(L.current=setTimeout(()=>{const pe=ot.current;ot.current="",L.current=null,pe&&ue(Ie=>{const De=[...Ie],et=De[De.length-1];return et&&et.type==="assistant"&&!et.isToolUse&&et.isStreaming?De[De.length-1]={...et,content:(et.content||"")+pe}:De.push({type:"assistant",content:pe,timestamp:new Date,isStreaming:!0}),De})},100));return}if(f.type==="content_block_stop"){L.current&&(clearTimeout(L.current),L.current=null);const K=ot.current;ot.current="",K&&ue(pe=>{const Ie=[...pe],De=Ie[Ie.length-1];return De&&De.type==="assistant"&&!De.isToolUse&&De.isStreaming?Ie[Ie.length-1]={...De,content:(De.content||"")+K}:Ie.push({type:"assistant",content:K,timestamp:new Date,isStreaming:!0}),Ie}),ue(pe=>{const Ie=[...pe],De=Ie[Ie.length-1];return De&&De.type==="assistant"&&De.isStreaming&&(Ie[Ie.length-1]={...De,isStreaming:!1}),Ie});return}}if(o.data.type==="system"&&o.data.subtype==="init"&&o.data.session_id&&ee&&o.data.session_id!==ee&&$e){console.log("🔄 Claude CLI session duplication detected:",{originalSession:ee,newSession:o.data.session_id}),Te(!0),cs(o.data.session_id),g&&g(o.data.session_id);return}if(o.data.type==="system"&&o.data.subtype==="init"&&o.data.session_id&&!ee&&$e){console.log("🔄 New session init detected:",{newSession:o.data.session_id}),Te(!0),cs(o.data.session_id),g&&g(o.data.session_id);return}if(o.data.type==="system"&&o.data.subtype==="init"&&o.data.session_id&&ee&&o.data.session_id===ee&&$e){console.log("🔄 System init message for current session, ignoring");return}if(We)break;if(Array.isArray(f.content)){for(const K of f.content)if(K.type==="tool_use"){const pe=K.input?JSON.stringify(K.input,null,2):"";ue(Ie=>[...Ie,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:K.name,toolInput:pe,toolId:K.id,toolResult:null}])}else if(K.type==="text"&&K.text?.trim()){let pe=Qr(K.text);pe=Fa(pe),ue(Ie=>[...Ie,{type:"assistant",content:pe,timestamp:new Date}])}}else if(typeof f.content=="string"&&f.content.trim()){let K=Qr(f.content);K=Fa(K),ue(pe=>[...pe,{type:"assistant",content:K,timestamp:new Date}])}if(f.role==="user"&&Array.isArray(f.content))for(const K of f.content)K.type==="tool_result"&&ue(pe=>pe.map(Ie=>Ie.isToolUse&&Ie.toolId===K.tool_use_id?{...Ie,toolResult:{content:K.content,isError:K.is_error,timestamp:new Date}}:Ie));break;case"claude-output":if(tr)break;{const K=String(o.data||"");K.trim()&&(ot.current+=ot.current?`
|
|
310
|
-
${K}`:K,L.current||(L.current=setTimeout(()=>{const pe=ot.current;ot.current="",L.current=null,pe&&ue(Ie=>{const De=[...Ie],et=De[De.length-1];return et&&et.type==="assistant"&&!et.isToolUse&&et.isStreaming?De[De.length-1]={...et,content:et.content?`${et.content}
|
|
311
|
-
${pe}`:pe}:De.push({type:"assistant",content:pe,timestamp:new Date,isStreaming:!0}),De})},100)))}break;case"claude-interactive-prompt":ue(K=>[...K,{type:"assistant",content:o.data,timestamp:new Date,isInteractivePrompt:!0}]);break;case"claude-permission-request":{if(tr||me!=="claude"||!o.requestId)break;dt(K=>K.some(pe=>pe.requestId===o.requestId)?K:[...K,{requestId:o.requestId,toolName:o.toolName||"UnknownTool",input:o.input,context:o.context,sessionId:o.sessionId||null,receivedAt:new Date}]),Ye(!0),Qe(!0),bt(Ba({phaseText:z("activity.stage.waitingPermission"),detailText:o.toolName?z("activity.requestTool",{tool:Tc(o.toolName)}):z("activity.permission.title"),canAbort:!0}));break}case"claude-permission-cancelled":{if(tr||!o.requestId)break;dt(K=>{const pe=K.filter(Ie=>Ie.requestId!==o.requestId);return pe.length===0&&bt(null),pe});break}case"claude-error":if(tr)break;ft(o.sessionId||ee||null),Ye(!1),Qe(!1),bt(null),ue(K=>[...K,{type:"error",content:`出错了:${o.error}`,timestamp:new Date}]);break;case"claude-complete":if(tr)break;const pt=o.sessionId||ee||sessionStorage.getItem("pendingSessionId");ft(pt),(pt===ee||!ee)&&(Ye(!1),Qe(!1),bt(null)),pt&&(d&&d(pt),p&&p(pt));const rr=sessionStorage.getItem("pendingSessionId");rr&&!ee&&o.exitCode===0&&(Ne(rr),sessionStorage.removeItem("pendingSessionId"),console.log("✅ New session complete, ID set to:",rr)),e&&o.exitCode===0&&Et.removeItem(`chat_messages_${e.name}`),dt([]);break;case"codex-response":const Be=o.data;if(Be){if(tr)break;if(Be.type==="item_delta"&&Be.delta){const K=Qr(String(Be.delta));if(K){const pe=`codex:${Be.itemType||"item"}:${Be.itemId||"unknown"}`;ue(Ie=>{const De=[...Ie];let et=-1;for(let nt=De.length-1;nt>=0;nt--){const fr=De[nt];if(fr?.codexItemKey===pe&&fr.type==="assistant"&&!fr.isToolUse){et=nt;break}}if(et===-1)De.push({type:"assistant",content:K,timestamp:new Date,isStreaming:!0,isThinking:!!Be.isReasoning,codexItemKey:pe});else{const nt=De[et],fr=nt.content||"";fr.endsWith(K)||(nt.content=fr+K),nt.isStreaming=!0}return De})}break}if(Be.type==="item_done"){const K=`codex:${Be.itemType||"item"}:${Be.itemId||"unknown"}`,pe=typeof Be.content=="string"?Qr(Be.content):"";ue(Ie=>{const De=[...Ie];let et=-1;for(let nt=De.length-1;nt>=0;nt--){const fr=De[nt];if(fr?.codexItemKey===K&&fr.type==="assistant"&&!fr.isToolUse){et=nt;break}}if(et!==-1){const nt=De[et];pe&&pe!==(nt.content||"")&&(nt.content=pe),nt.isStreaming=!1}else pe.trim()&&De.push({type:"assistant",content:pe,timestamp:new Date,isStreaming:!1,isThinking:!!Be.isReasoning});return De});break}if(Be.type==="item")switch(Be.itemType){case"agent_message":if(Be.message?.content?.trim()){const K=Qr(Be.message.content);ue(pe=>{const Ie=pe[pe.length-1];return Ie&&Ie.type==="assistant"&&!Ie.isToolUse&&!Ie.isThinking&&(Ie.content||"").trim()===K.trim()?pe:[...pe,{type:"assistant",content:K,timestamp:new Date}]})}break;case"reasoning":if(Be.message?.content?.trim()){const K=Qr(Be.message.content);ue(pe=>{const Ie=pe[pe.length-1];return Ie&&Ie.type==="assistant"&&!Ie.isToolUse&&Ie.isThinking&&(Ie.content||"").trim()===K.trim()?pe:[...pe,{type:"assistant",content:K,timestamp:new Date,isThinking:!0}]})}break;case"command_execution":Be.command&&ue(K=>[...K,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:"Bash",toolInput:Be.command,toolResult:Be.output||null,exitCode:Be.exitCode}]);break;case"file_change":if(Be.changes?.length>0){const K=Be.changes.map(pe=>`${pe.kind}: ${pe.path}`).join(`
|
|
312
|
-
`);ue(pe=>[...pe,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:"FileChanges",toolInput:K,toolResult:`Status: ${Be.status}`}])}break;case"mcp_tool_call":ue(K=>[...K,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:`${Be.server}:${Be.tool}`,toolInput:JSON.stringify(Be.arguments,null,2),toolResult:Be.result?JSON.stringify(Be.result,null,2):Be.error?.message||null}]);break;case"error":Be.message?.content&&ue(K=>[...K,{type:"error",content:Be.message.content,timestamp:new Date}]);break;default:console.log("[Codex] Unhandled item type:",Be.itemType,Be)}Be.type==="turn_complete"&&Ye(!1),Be.type==="turn_failed"&&(Ye(!1),ue(K=>[...K,{type:"error",content:Be.error?.message||"Turn failed",timestamp:new Date}]))}break;case"codex-complete":if(tr)break;const Gt=o.sessionId||ee||sessionStorage.getItem("pendingSessionId");ft(Gt),(Gt===ee||!ee)&&(Ye(!1),Qe(!1),bt(null),ue(K=>K.map(pe=>pe?.codexItemKey&&pe.isStreaming?{...pe,isStreaming:!1}:pe))),Gt&&(d&&d(Gt),p&&p(Gt));const Ho=sessionStorage.getItem("pendingSessionId"),Zi=o.actualSessionId||Ho;Ho&&!ee&&(Ne(Zi),Te(!0),g&&g(Zi),sessionStorage.removeItem("pendingSessionId"),console.log("Codex session complete, ID set to:",Ho)),e&&Gt&&Sr(e.name,Gt,!1,"codex").then(K=>{Array.isArray(K)&&K.length>0&&qe(K)}).catch(K=>{console.error("Error reloading Codex session after completion:",K)}),e&&Et.removeItem(`chat_messages_${e.name}`);break;case"codex-error":if(tr)break;ft(o.sessionId||ee||null),Ye(!1),Qe(!1),ue(K=>K.map(pe=>pe?.codexItemKey&&pe.isStreaming?{...pe,isStreaming:!1}:pe)),ue(K=>[...K,{type:"error",content:o.error||"An error occurred with Codex",timestamp:new Date}]);break;case"session-aborted":{if(tr)break;const K=o.sessionId||ee;ft(K),K===ee&&(Ye(!1),Qe(!1),bt(null)),K&&(d&&d(K),p&&p(K)),dt([]),ue(pe=>[...pe,{type:"assistant",content:"Session interrupted by user.",timestamp:new Date}]);break}case"session-status":{if(tr)break;const K=o.sessionId,pe=o.provider||t?.__provider||Bt,Ie=K===ee||t&&K===t.id,De=zr(Ge),et=ds(Ge);if(Ie&&o.isProcessing){if(et){Hi(K,et);break}Ye(!0),Qe(!0),u&&u(K)}else if(Ie&&o.isProcessing===!1){if(qt(K,"session-status")){Oo(K,pe);break}Ur(K,pe).then(nt=>{if(!(nt===le.COMPLETED||nt===le.ABORTED||nt===le.ERRORED)){if(De===le.STREAMING||De===le.AWAITING_APPROVAL){ze(De);return}Ye(!1),Qe(!1),bt(null)}})}break}case"claude-status":const Ht=o.data;if(Ht){let K={text:"Working...",tokens:0,can_interrupt:!0};Ht.message?K.text=Ht.message:Ht.status?K.text=Ht.status:typeof Ht=="string"&&(K.text=Ht),Ht.tokens?K.tokens=Ht.tokens:Ht.token_count&&(K.tokens=Ht.token_count),Ht.can_interrupt!==void 0&&(K.can_interrupt=Ht.can_interrupt),bt(Dy(Ht,z,bi.current)),Ye(!0),Qe(K.can_interrupt)}break}}},[Bt,Nt,ft,ee,zr,ds,H,o,cs,Ur,Hi,de,Oo,t,qt,rt,z]),l.useEffect(()=>{e&&kp()},[e]);const kp=async()=>{try{const f=await mt.getFiles(e.name);if(f.ok){const v=await f.json(),y=qi(v);ct(y)}}catch(f){console.error("Error fetching files:",f)}},qi=(f,v="")=>{let y=[];for(const _ of f){const V=v?`${v}/${_.name}`:_.name;_.type==="directory"&&_.children?y=y.concat(qi(_.children,V)):_.type==="file"&&y.push({name:_.name,path:V,relativePath:_.path})}return y};l.useEffect(()=>{const f=X.slice(0,Mn),v=f.lastIndexOf("@");if(v!==-1){const y=f.slice(v+1);if(y.includes(" "))vt(!1),es(-1);else{es(v),vt(!0);const _=yt.filter(V=>V.name.toLowerCase().includes(y.toLowerCase())||V.path.toLowerCase().includes(y.toLowerCase())).slice(0,10);qr(_),Ft(-1)}}else vt(!1),es(-1)},[X,Mn,yt]);const Fo=l.useMemo(()=>!X||He.length===0?[]:He.filter(f=>X.includes(f)),[He,X]),Ln=l.useMemo(()=>Fo.length===0?[]:Array.from(new Set(Fo)).sort((v,y)=>y.length-v.length),[Fo]),$o=l.useMemo(()=>{if(Ln.length===0)return null;const f=Ln.map(sy).join("|");return new RegExp(`(${f})`,"g")},[Ln]),Vi=l.useMemo(()=>new Set(Ln),[Ln]),jp=l.useCallback(f=>f?$o?f.split($o).map((y,_)=>Vi.has(y)?r.jsx("span",{className:"bg-primary/20 -ml-0.5 dark:bg-primary/25 px-0.5 rounded-md box-decoration-clone text-transparent",children:y},`mention-${_}`):r.jsx("span",{children:y},`text-${_}`)):f:"",[$o,Vi]);l.useEffect(()=>{const f=setTimeout(()=>{te(X)},150);return()=>clearTimeout(f)},[X]);const mn=l.useMemo(()=>t||ye.length<=Rn?ye:ye.slice(-Rn),[ye,Rn,t]),Sp=l.useMemo(()=>{const f=mn.map((y,_)=>({...y,__threadMessageId:ay(y,_)}));return f.length===0||!H||f.some(y=>y?.type!=="assistant"?!1:!!(y.isStreaming||y.isToolUse||y.isThinking||y.reasoning))?f:[...f,{id:"__assistant-loading-indicator__",type:"assistant",content:"",timestamp:new Date,isLoadingIndicator:!0,__provider:t?.__provider||me||"claude"}]},[mn,H,t?.__provider,me]);l.useMemo(()=>{if(!H||mn.length===0)return-1;for(let f=mn.length-1;f>=0;f--){const v=mn[f];if(v.type==="assistant"&&(v.isStreaming||v.isToolUse||v.isThinking||v.reasoning))return f}return-1},[mn,H]),l.useEffect(()=>{if(!A&&j.current){const f=j.current;ho.current={height:f.scrollHeight,top:f.scrollTop}}}),l.useEffect(()=>{if(j.current&&ye.length>0)if(A)fo||setTimeout(()=>Nr(),50);else{const f=j.current,v=ho.current.height,y=ho.current.top,V=f.scrollHeight-v;V>0&&y>0&&(f.scrollTop=y+V)}},[ye.length,fo,Nr,A]),l.useEffect(()=>{j.current&&ye.length>0&&!F.current&&(Dn(!1),setTimeout(()=>{Nr()},200))},[t?.id,e?.name]),l.useEffect(()=>{const f=j.current;if(f)return f.addEventListener("scroll",ms),()=>f.removeEventListener("scroll",ms)},[ms]),l.useEffect(()=>{if(G.current){G.current.style.height="auto",G.current.style.height=G.current.scrollHeight+"px";const f=parseInt(window.getComputedStyle(G.current).lineHeight),v=G.current.scrollHeight>f*2;Kr(v)}},[]),l.useEffect(()=>{G.current&&!X.trim()&&(G.current.style.height="auto",Kr(!1))},[X]),l.useEffect(()=>{if(!e||!t?.id||t.id.startsWith("new-session-")){Or(null);return}if((t.__provider||me||"claude")!=="claude")return;(async()=>{try{const y=`/api/projects/${e.name}/sessions/${t.id}/token-usage`,_=await ce(y);if(_.ok){const V=await _.json();Or(V)}else Or(null)}catch(y){console.error("Failed to fetch initial token usage:",y)}})()},[t?.id,t?.__provider,e?.path]),l.useCallback(f=>{f.trim()&&q(v=>{const y=v.trim()?`${v} ${f}`:f;return setTimeout(()=>{if(G.current){G.current.style.height="auto",G.current.style.height=G.current.scrollHeight+"px";const _=parseInt(window.getComputedStyle(G.current).lineHeight),V=G.current.scrollHeight>_*2;Kr(V)}},0),y})},[]);const Np=l.useCallback(()=>{rp(f=>f+100)},[]),Cp=l.useCallback(()=>{ps()},[ps]),fs=l.useCallback(f=>{const v=f.filter(y=>{try{if(!y||typeof y!="object")return console.warn("Invalid file object:",y),!1;if(!y.type||!y.type.startsWith("image/"))return!1;if(!y.size||y.size>5242880){const _=y.name||"Unknown file";return Rt(V=>{const ae=new Map(V);return ae.set(_,"File too large (max 5MB)"),ae}),!1}return!0}catch(_){return console.error("Error validating file:",_,y),!1}});v.length>0&&ht(y=>[...y,...v].slice(0,5))},[]),Ep=l.useCallback(async f=>{const v=Array.from(f.clipboardData.items);for(const y of v)if(y.type.startsWith("image/")){const _=y.getAsFile();_&&fs([_])}if(v.length===0&&f.clipboardData.files.length>0){const _=Array.from(f.clipboardData.files).filter(V=>V.type.startsWith("image/"));_.length>0&&fs(_)}},[fs]),{getRootProps:Ip,getInputProps:Ap,isDragActive:Tp,open:_p}=du({accept:{"image/*":[".png",".jpg",".jpeg",".gif",".webp",".svg"]},maxSize:5*1024*1024,maxFiles:5,onDrop:fs,noClick:!0,noKeyboard:!0}),Xr=l.useCallback(async(f,v=null)=>{f.preventDefault();const y=typeof v=="string"?v:X,_=t?.__provider||me||"claude";if((No[_]?.status||Ms)===ia||!y.trim()||H||!e)return;let ae=y;const be=Ul(_),Ue=be.enabled?Cm.find(pt=>pt.id===Gr):null;be.strategy==="prompt-prefix"&&Ue&&Ue.prefix&&(ae=`${Ue.prefix}: ${y}`);const $e=!is&&vy(jr)?Cy(jr):null;$e&&(ae=Ey($e,ae)),ze(le.QUEUED),bt(Ba({phaseText:z("activity.stage.generatingReply"),detailText:z("activity.detail.preparingReply"),canAbort:!0}));let gt=[];if(At.length>0){if(!$v(_)){ze(le.IDLE),Qe(!1),bt(null),ue(pt=>[...pt,{type:"error",content:`${_} 当前不支持图片输入`,timestamp:new Date}]);return}try{gt=await Qv(At)}catch(pt){console.error("Image preparation failed:",pt),ze(le.IDLE),Qe(!1),bt(null),ue(rr=>[...rr,{type:"error",content:`图片处理失败:${pt.message}`,timestamp:new Date}]);return}}const _t={type:"user",content:y,images:gt,timestamp:new Date};ue(pt=>[...pt,_t]),Dn(!1),setTimeout(()=>Nr(),100);const Ze=ee||t?.id;$t(Ze||t?.id||null),Ze&&Nt(zt({kind:"user_message",provider:_,sessionId:Ze,timestamp:_t.timestamp,payload:{text:y}}));const hs=Ze||`new-session-${Date.now()}`;!Ze&&!t?.id&&(se.current={sessionId:null,startedAt:Date.now()}),c&&c(hs);const We=(()=>{try{const pt=me==="codex"?"codex-settings":"claude-settings",rr=Et.getItem(pt);if(rr)return JSON.parse(rr)}catch(pt){console.error("Error loading tools settings:",pt)}return{allowedTools:[],disallowedTools:[],skipPermissions:!1}})();if(_==="codex"){const pt=be.enabled&&be.strategy==="native-effort"?Bv(Gr):void 0;s({type:"codex-command",command:ae,sessionId:Ze,options:{cwd:e.fullPath||e.path,projectPath:e.fullPath||e.path,sessionId:Ze,resume:!!Ze,permissionMode:Fe==="plan"?"default":Fe,...Kt?{model:Kt}:{},...pt?{modelReasoningEffort:pt}:{},images:gt}})}else s(_==="gemini"?{type:"gemini-command",command:ae,sessionId:Ze,options:{cwd:e.fullPath||e.path,projectPath:e.fullPath||e.path,sessionId:Ze,resume:!!Ze,permissionMode:Fe==="plan"?"default":Fe,...Kt?{model:Kt}:{}}}:_==="opencode"?{type:"opencode-command",command:ae,sessionId:Ze,options:{cwd:e.fullPath||e.path,projectPath:e.fullPath||e.path,sessionId:Ze,resume:!!Ze,permissionMode:Fe==="plan"?"default":Fe,...Kt?{model:Kt}:{}}}:{type:"claude-command",command:ae,options:{projectPath:e.path,cwd:e.fullPath,sessionId:Ze,resume:!!Ze,toolsSettings:We,permissionMode:Fe,...Kt?{model:Kt}:{},images:gt}});$e&&ls(!0),q(""),ht([]),Vt(new Map),Rt(new Map),Kr(!1),rs("none"),G.current&&(G.current.style.height="auto"),e&&Et.removeItem(`draft_input_${e.name}`)},[X,H,e,At,ee,t,me,No,Fe,c,Io,Ao,To,_o,s,q,ht,Vt,Rt,Kr,G,ue,Ye,Qe,bt,Dn,Nr,Gr,jr,is,$t,Nt]),Ki=l.useCallback(f=>!f||me!=="claude"?{success:!1}:My(f.entry),[me]),Bo=l.useCallback((f,v)=>{const _=(Array.isArray(f)?f:[f]).filter(Boolean);_.length!==0&&(_.forEach(V=>{s({type:"claude-permission-response",requestId:V,allow:!!v?.allow,updatedInput:v?.updatedInput,message:v?.message,rememberEntry:v?.rememberEntry})}),dt(V=>{const ae=V.filter(be=>!_.includes(be.requestId));return ae.length===0&&bt(null),ae}))},[s]);l.useEffect(()=>{Pn.current=Xr},[Xr]);const Gi=f=>{if(!f)return;const v=X.slice(0,yi),y=X.slice(yi),_=y.indexOf(" "),V=_!==-1?y.slice(_):"",ae=v+f.name+" "+V;q(ae),Rr(!1),$r(-1),Lr(""),Fr(-1),he.current&&clearTimeout(he.current),$i(f)},Mp=f=>{if(go&&Vr.length>0){if(f.key==="ArrowDown"){f.preventDefault(),Fr(v=>v<Vr.length-1?v+1:0);return}if(f.key==="ArrowUp"){f.preventDefault(),Fr(v=>v>0?v-1:Vr.length-1);return}if(f.key==="Tab"||f.key==="Enter"){f.preventDefault(),yo>=0?Gi(Vr[yo]):Vr.length>0&&Gi(Vr[0]);return}if(f.key==="Escape"){f.preventDefault(),Rr(!1),$r(-1),Lr(""),Fr(-1),he.current&&clearTimeout(he.current);return}}if(Je&&Ct.length>0){if(f.key==="ArrowDown"){f.preventDefault(),Ft(v=>v<Ct.length-1?v+1:0);return}if(f.key==="ArrowUp"){f.preventDefault(),Ft(v=>v>0?v-1:Ct.length-1);return}if(f.key==="Tab"||f.key==="Enter"){f.preventDefault(),pr>=0?zo(Ct[pr]):Ct.length>0&&zo(Ct[0]);return}if(f.key==="Escape"){f.preventDefault(),vt(!1);return}}if(f.key==="Tab"&&!Je&&!go){f.preventDefault();const v=Br.modes,_=(v.indexOf(Fe)+1)%v.length,V=v[_];tt(V),t?.id&&localStorage.setItem(`permissionMode-${t.id}`,V);return}if(f.key==="Enter"){if(f.nativeEvent.isComposing)return;(f.ctrlKey||f.metaKey)&&!f.shiftKey?(f.preventDefault(),Xr(f)):!f.shiftKey&&!f.ctrlKey&&!f.metaKey&&(w||(f.preventDefault(),Xr(f)))}},zo=f=>{const v=X.slice(0,vi),y=X.slice(vi),_=y.indexOf(" "),V=_!==-1?y.slice(_):"",ae=v+f.path+" "+V,be=v.length+f.path.length+1;G.current&&!G.current.matches(":focus")&&G.current.focus(),q(ae),Zn(be),Ot(Ue=>Ue.includes(f.path)?Ue:[...Ue,f.path]),vt(!1),es(-1),G.current&&requestAnimationFrame(()=>{G.current&&(G.current.setSelectionRange(be,be),G.current.matches(":focus")||G.current.focus())})},Dp=f=>{const v=f.target.value,y=f.target.selectionStart;if(!ee&&v.trim(),q(v),Zn(y),!v.trim()){f.target.style.height="auto",Kr(!1),Rr(!1),$r(-1),Lr("");return}const _=v.slice(0,y);if((_.match(/```/g)||[]).length%2===1){Rr(!1),$r(-1),Lr("");return}const be=/(^|\s)\/(\S*)$/,Ue=_.match(be);if(Ue){const $e=Ue.index+Ue[1].length,gt=Ue[2];$r($e),Rr(!0),Fr(-1),he.current&&clearTimeout(he.current),he.current=setTimeout(()=>{Lr(gt)},150)}else Rr(!1),$r(-1),Lr(""),he.current&&clearTimeout(he.current)},Ji=l.useCallback(f=>{!fe.current||!f||(fe.current.scrollTop=f.scrollTop,fe.current.scrollLeft=f.scrollLeft)},[]),Rp=f=>{Zn(f.target.selectionStart)},Pp=()=>{ee&&Oe&&s({type:"abort-session",sessionId:ee,provider:me})};if(!e)return r.jsx("div",{className:"flex h-full items-center justify-center px-4 py-8 sm:px-6",children:r.jsxs("div",{className:"max-w-lg px-8 py-10 text-center text-muted-foreground",children:[r.jsx("div",{className:"mx-auto mb-5 flex h-14 w-14 items-center justify-center rounded-3xl bg-primary/10 text-primary",children:r.jsx(Tf,{className:"h-7 w-7"})}),r.jsx("p",{className:"text-base font-medium text-foreground",children:"Select a project to start chatting"})]})});const Cr=t?.__provider||me||"claude",Uo=No[Cr],Wo=(Uo?.status||Ms)===ia,Lp=Uo?.reason||ip[Cr]||null,Yi=Uo?.installHint||null,Xi=!!ap[Cr],fn=H||Wo,hn=q0({status:bo,messages:ye,pendingPermissionRequests:$,t:z}),Op=H&&!!hn,Fp=Cr==="opencode"?"OpenCode":z(`messageTypes.${Cr}`),Qi=z("input.providerNotInstalledWithName",{provider:Fp}),$p=me==="codex"?"Codex":me==="gemini"?"Gemini":me==="opencode"?"OpenCode":"Claude",Bp=ye.length===0?null:r.jsxs(r.Fragment,{children:[Xe&&r.jsx("div",{className:"pb-3 text-center text-gray-500 dark:text-gray-400",children:r.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[r.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),r.jsx("p",{className:"text-sm",children:z("session.loading.olderMessages")})]})}),jt&&!Xe&&r.jsx("div",{className:"mb-3 text-center text-gray-500 dark:text-gray-400 text-sm",children:Dt>0&&r.jsxs("span",{children:[z("session.messages.showingOf",{shown:Ge.length,total:Dt})," •",r.jsx("button",{className:"ml-1 text-primary hover:text-primary underline",onClick:Cp,children:z("session.messages.loadEarlier")}),r.jsx("span",{className:"ml-1 text-xs",children:z("session.messages.scrollToLoad")})]})}),!t&&!jt&&ye.length>Rn&&r.jsxs("div",{className:"mb-3 text-center text-gray-500 dark:text-gray-400 text-sm",children:[z("session.messages.showingLast",{count:Rn,total:ye.length})," •",r.jsx("button",{className:"ml-1 text-primary hover:text-primary underline",onClick:Np,children:z("session.messages.loadEarlier")})]})]}),zp=ye.length===0?null:r.jsx(r.Fragment,{children:$.map(f=>{const v=Ql(f.input),y=$a(f.toolName,v),_=pi(),V=y?_.allowedTools.includes(y):!1,ae=y?$.filter(be=>$a(be.toolName,Ql(be.input))===y).map(be=>be.requestId):[f.requestId];return r.jsx(V0,{request:f,permissionEntry:y,alreadyAllowed:V,rawInput:v,className:"mx-1 my-3 sm:mx-0",onAllowOnce:()=>Bo(f.requestId,{allow:!0}),onAllowRemember:()=>{y&&!V&&Ki({entry:y,toolName:f.toolName}),Bo(ae,{allow:!0,rememberEntry:y})},onDeny:()=>Bo(f.requestId,{allow:!1,message:z("activity.permission.deniedMessage")})},f.requestId)})});return r.jsxs(r.Fragment,{children:[r.jsx("style",{children:`
|
|
313
|
-
details[open] .details-chevron {
|
|
314
|
-
transform: rotate(180deg);
|
|
315
|
-
}
|
|
316
|
-
`}),r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsx("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:lt&&ye.length===0?r.jsx("div",{className:"px-3 py-4 text-center text-gray-500 dark:text-gray-400 sm:px-6 sm:py-5 mt-8",children:r.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[r.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),r.jsx("p",{children:z("session.loading.sessionMessages")})]})}):ye.length===0?r.jsxs("div",{className:"flex h-full items-center justify-center overflow-y-auto px-4 py-8 sm:px-6",children:[!t&&!ee&&r.jsxs("div",{className:"w-full max-w-3xl text-center",children:[r.jsx("h2",{className:"mb-2 text-3xl font-semibold tracking-tight text-foreground sm:text-4xl",children:z("providerSelection.title")}),r.jsx("p",{className:"mx-auto mb-8 max-w-xl text-base text-muted-foreground",children:z("providerSelection.description")}),r.jsxs("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-2",children:[r.jsxs("button",{onMouseDown:f=>f.preventDefault(),onClick:()=>{as("claude")},className:`group relative w-full flex items-center gap-3 rounded-2xl border px-4 py-3 text-left transition-all duration-200 ${me==="claude"?"border-primary/50 bg-primary/5 text-foreground shadow-sm":"border-border/60 bg-muted/10 text-muted-foreground hover:bg-muted/20 hover:text-foreground"}`,children:[r.jsx(Qn,{className:"h-10 w-10 flex-shrink-0"}),r.jsx("div",{className:"text-left font-medium text-[14px] leading-6",children:"Claude Code"})]}),r.jsxs("button",{onMouseDown:f=>f.preventDefault(),onClick:()=>{as("codex")},className:`group relative w-full flex items-center gap-3 rounded-2xl border px-4 py-3 text-left transition-all duration-200 ${me==="codex"?"border-primary/50 bg-primary/5 text-foreground shadow-sm":"border-border/60 bg-muted/10 text-muted-foreground hover:bg-muted/20 hover:text-foreground"}`,children:[r.jsx(ao,{className:"h-10 w-10 flex-shrink-0"}),r.jsx("div",{className:"text-left font-medium text-[14px] leading-6",children:"Codex"})]}),r.jsxs("button",{onMouseDown:f=>f.preventDefault(),onClick:()=>{as("gemini")},className:`group relative w-full flex items-center gap-3 rounded-2xl border px-4 py-3 text-left transition-all duration-200 ${me==="gemini"?"border-primary/50 bg-primary/5 text-foreground shadow-sm":"border-border/60 bg-muted/10 text-muted-foreground hover:bg-muted/20 hover:text-foreground"}`,children:[r.jsx(io,{className:"h-10 w-10 flex-shrink-0"}),r.jsx("div",{className:"text-left font-medium text-[14px] leading-6",children:"Gemini"})]}),r.jsxs("button",{onMouseDown:f=>f.preventDefault(),onClick:()=>{as("opencode")},className:`group relative w-full flex items-center gap-3 rounded-2xl border px-4 py-3 text-left transition-all duration-200 ${me==="opencode"?"border-primary/50 bg-primary/5 text-foreground shadow-sm":"border-border/60 bg-muted/10 text-muted-foreground hover:bg-muted/20 hover:text-foreground"}`,children:[r.jsx(lo,{className:"h-10 w-auto max-w-full flex-shrink-0 text-foreground"}),r.jsx("div",{className:"text-left font-medium text-[14px] leading-6",children:"OpenCode"})]})]})]}),t&&r.jsxs("div",{className:"px-6 text-center text-muted-foreground sm:px-4",children:[r.jsx("p",{className:"mb-3 text-2xl font-semibold text-foreground",children:z("session.continue.title")}),r.jsx("p",{className:"text-sm sm:text-base leading-relaxed",children:z("session.continue.description")})]})]}):r.jsx(Em,{messages:Sp,convertMessage:Im,isRunning:H,scrollContainerRef:j,onScroll:ms,messagesEndRef:T,provider:me,providerLabel:$p,createDiff:yp,onFileOpen:a,onShowSettings:x,onGrantToolPermission:Ki,showRawParameters:k,autoExpandTools:S,selectedProject:e,markdownRenderer:Oa,topContent:Bp,bottomContent:zp})}),r.jsxs("div",{className:"flex-shrink-0 bg-background px-3 py-3 sm:px-4 sm:py-4 pb-2 sm:pb-4 md:pb-6",children:[r.jsx("div",{className:"flex-1",children:r.jsx(Am,{phaseText:hn?.phaseText,detailText:hn?.detailText,elapsedSeconds:hn?.elapsedSeconds,startedAt:hn?.startedAt,canAbort:hn?.canAbort,isLoading:Op,onAbort:Pp,provider:me})}),r.jsx("div",{ref:Me,className:"mx-auto mb-3 w-full max-w-4xl"}),r.jsxs("form",{onSubmit:Xr,className:"relative mx-auto w-full max-w-4xl",children:[fo&&ye.length>0&&r.jsx("button",{type:"button",onClick:Nr,className:"absolute -top-12 right-0 z-10 flex h-8 w-8 items-center justify-center rounded-full bg-muted/80 text-muted-foreground transition-all duration-200 hover:bg-muted hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring",title:"滚动到底部",children:r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 14l-7 7m0 0l-7-7m7 7V3"})})}),Tp&&r.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center rounded-2xl border border-dashed border-primary bg-primary/5",children:r.jsxs("div",{className:"rounded-xl border border-border/70 bg-background p-4",children:[r.jsx("svg",{className:"w-8 h-8 text-primary mx-auto mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"})}),r.jsx("p",{className:"text-sm font-medium",children:"将图片拖到这里"})]})}),At.length>0&&r.jsx("div",{className:"chat-subtle-surface mb-2 rounded-xl p-2.5",children:r.jsx("div",{className:"flex flex-wrap gap-2",children:At.map((f,v)=>r.jsx(Ly,{file:f,onRemove:()=>{ht(y=>y.filter((_,V)=>V!==v))},uploadProgress:Qt.get(f.name),error:Zt.get(f.name)},v))})}),er&&r.jsx("div",{className:"chat-subtle-surface mb-2 rounded-xl p-2.5",children:r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[br(er.systemContext)&&r.jsx(Cs,{content:er.systemContext,className:"whitespace-normal break-words max-w-sm",delay:200,children:r.jsxs("div",{className:"inline-flex max-w-[260px] items-center gap-1.5 rounded-lg border border-border/70 bg-background px-2 py-1 text-xs text-foreground",children:[r.jsx("svg",{className:"w-3.5 h-3.5 text-gray-500 dark:text-gray-300 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 5h16M4 12h16M4 19h16"})}),r.jsx("span",{className:"truncate",children:z("input.dynamicContext.systemChip")}),r.jsx("button",{type:"button",onClick:pp,className:"ml-0.5 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors",title:z("input.dynamicContext.removeSystem"),"aria-label":z("input.dynamicContext.removeSystem"),children:r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),br(bn(er.currentFile))&&r.jsx(Cs,{content:bn(er.currentFile),className:"whitespace-normal break-words max-w-sm",delay:200,children:r.jsxs("div",{className:"inline-flex max-w-[260px] items-center gap-1.5 rounded-lg border border-border/70 bg-background px-2 py-1 text-xs text-foreground",children:[r.jsx("svg",{className:"w-3.5 h-3.5 text-emerald-500 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l4.414 4.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),r.jsx("span",{className:"truncate",children:gy(er.currentFile)}),r.jsx("button",{type:"button",onClick:mp,className:"ml-0.5 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors",title:z("input.dynamicContext.removeCurrentFile"),"aria-label":z("input.dynamicContext.removeCurrentFile"),children:r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),up.map((f,v)=>r.jsx(Cs,{content:Gl(f),className:"max-w-[min(28rem,calc(100vw-2rem))] whitespace-normal break-words",delay:200,children:r.jsxs("div",{className:"inline-flex max-w-[min(22rem,calc(100vw-4rem))] items-center gap-1.5 rounded-lg border border-border/70 bg-background px-2 py-1 text-xs text-foreground",title:f.selector,children:[r.jsx("svg",{className:"w-3.5 h-3.5 text-primary flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 15l2 5L7 17l3-10 10 3-5 2z"})}),r.jsx("span",{className:"truncate",children:f.tag||z("input.dynamicContext.elementFallback")}),r.jsx("button",{type:"button",onClick:()=>fp(f),className:"ml-0.5 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors",title:z("input.dynamicContext.removeElement"),"aria-label":z("input.dynamicContext.removeElement"),children:r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})},`${f.selector}-${v}`)),Po.length>0&&r.jsx(Cs,{content:Po.map(Gl).join(`
|
|
317
|
-
`),className:"max-w-[min(28rem,calc(100vw-2rem))] whitespace-pre-wrap break-words",delay:200,children:r.jsxs("div",{className:"inline-flex items-center gap-1 rounded-lg border border-border/70 bg-background px-2 py-1 text-xs text-muted-foreground",children:["+",Po.length]})})]})}),Je&&Ct.length>0&&r.jsx("div",{className:"chat-floating-panel absolute bottom-full left-0 right-0 z-50 mb-2 max-h-48 overflow-y-auto rounded-2xl",children:Ct.map((f,v)=>r.jsxs("div",{className:`px-4 py-3 cursor-pointer border-b border-gray-100 dark:border-gray-700 last:border-b-0 touch-manipulation ${v===pr?"bg-primary/10 dark:bg-primary/20 text-primary":"hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300"}`,onMouseDown:y=>{y.preventDefault(),y.stopPropagation()},onClick:y=>{y.preventDefault(),y.stopPropagation(),zo(f)},children:[r.jsx("div",{className:"font-medium text-sm",children:f.name}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono",children:f.path})]},f.path))}),r.jsx(Mv,{commands:Vr,selectedIndex:yo,onSelect:gp,onClose:()=>{Rr(!1),$r(-1),Lr(""),Fr(-1)},position:{top:G.current?Math.max(16,G.current.getBoundingClientRect().top-316):0,left:G.current?G.current.getBoundingClientRect().left:16,bottom:G.current?window.innerHeight-G.current.getBoundingClientRect().top+8:90},isOpen:go,frequentCommands:ts?[]:hp}),r.jsxs("div",{...Ip(),className:`chat-composer-shell relative overflow-visible rounded-[20px] transition-all duration-200 ${tp?"chat-input-expanded":""} ${it?"border-primary/40 ring-2 ring-primary/10":"hover:border-border hover:shadow-md"}`,children:[r.jsx("input",{...Ap()}),r.jsx("div",{ref:fe,"aria-hidden":"true",className:"absolute inset-0 pointer-events-none overflow-hidden rounded-[24px]",children:r.jsx("div",{className:"chat-input-placeholder block w-full px-4 pt-4 pb-14 text-xs leading-5 text-transparent whitespace-pre-wrap break-words sm:text-base sm:leading-6",children:jp(X)})}),r.jsxs("div",{className:"relative z-10 flex flex-col",children:[r.jsx("div",{className:"relative px-4 pt-4",children:r.jsx("textarea",{ref:G,value:X,onChange:Dp,onClick:Rp,onKeyDown:Mp,onPaste:Ep,onScroll:f=>Ji(f.target),onFocus:()=>Ke(!0),onBlur:()=>Ke(!1),onInput:f=>{f.target.style.height="auto",f.target.style.height=f.target.scrollHeight+"px",Zn(f.target.selectionStart),Ji(f.target);const v=parseInt(window.getComputedStyle(f.target).lineHeight),y=f.target.scrollHeight>v*2;Kr(y)},placeholder:Wo?Qi:z("input.placeholder",{provider:Cr==="codex"?z("messageTypes.codex"):Cr==="gemini"?z("messageTypes.gemini"):Cr==="opencode"?"OpenCode":z("messageTypes.claude")}),disabled:fn,className:"chat-input-placeholder block w-full bg-transparent resize-none focus:outline-none text-gray-900 dark:text-gray-100 placeholder-gray-400 dark:placeholder-gray-500 disabled:opacity-50 min-h-[50px] sm:min-h-[60px] max-h-[40vh] sm:max-h-[300px] overflow-y-auto text-xs leading-5 sm:text-base sm:leading-6 transition-all duration-200",style:{height:"50px"}})}),Wo&&r.jsxs("div",{className:"mx-3 mt-2 rounded-xl border border-amber-200 bg-amber-50/80 px-3 py-2 text-xs text-amber-900 dark:border-amber-800 dark:bg-amber-900/20 dark:text-amber-100",children:[r.jsx("div",{children:Lp||Qi}),Yi&&r.jsx("div",{className:"mt-1 font-mono text-[11px] opacity-90 break-all",children:Yi}),r.jsx("div",{className:"mt-2",children:r.jsx("button",{type:"button",onClick:()=>Eo(Cr,{force:!0}),className:"rounded-md border border-amber-300 px-2 py-1 text-[11px] font-medium hover:bg-amber-100 dark:border-amber-700 dark:hover:bg-amber-900/40",disabled:Xi,children:z(Xi?"input.checkingInstallation":"input.recheckInstallation")})})]}),r.jsxs("div",{className:"flex items-end justify-between gap-2 px-3 pb-3 pt-2 sm:items-center",children:[r.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 sm:flex-nowrap sm:gap-2",children:[r.jsxs("button",{type:"button",onClick:()=>{fn||_p()},disabled:fn,className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground sm:h-9 sm:w-9 sm:rounded-lg",title:z("input.attachImages"),children:[r.jsx(jn,{className:"h-4 w-4 sm:hidden"}),r.jsx("svg",{className:"hidden h-5 w-5 sm:block",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})]}),r.jsx("div",{ref:ko,className:"relative min-w-0 max-w-full flex-[0_1_auto]",children:r.jsxs(tl,{value:Kt||void 0,onValueChange:f=>{me==="claude"?Ci(f):me==="codex"?Ei(f):me==="gemini"?Ii(f):me==="opencode"&&Ai(f),ey(me,f)},disabled:fn||os||dp,children:[r.jsx(rl,{className:"h-8 w-auto !min-w-0 max-w-full shrink justify-start gap-1 rounded-full border-0 bg-transparent px-1.5 text-xs font-normal text-muted-foreground shadow-none hover:bg-accent/60 hover:text-muted-foreground focus:ring-0 sm:h-8 sm:px-1.5 sm:text-xs",children:r.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[os&&r.jsx(Un,{className:"h-3.5 w-3.5 flex-shrink-0 animate-spin text-muted-foreground"}),r.jsx("span",{className:"truncate text-xs font-normal text-muted-foreground",children:os?z("input.loadingModels"):cp}),r.jsx(Ar,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground sm:hidden"})]})}),r.jsx(nl,{children:os?r.jsx(Ko,{value:"__loading",disabled:!0,children:z("input.loadingModels")}):ss.map(({value:f,label:v})=>r.jsx(Ko,{value:f,children:v},f))})]})}),r.jsx("div",{className:"relative min-w-0 max-w-full flex-[0_1_auto]",ref:jo,children:r.jsxs(tl,{value:Fe,onValueChange:f=>{tt(f),t&&localStorage.setItem(`permissionMode-${t.id}`,f)},disabled:fn,children:[r.jsx(rl,{className:"h-8 w-auto !min-w-0 max-w-full shrink justify-start gap-1 rounded-full border-0 bg-transparent px-1.5 text-xs font-normal text-muted-foreground shadow-none hover:bg-accent/60 hover:text-muted-foreground focus:ring-0 sm:h-8 sm:px-1.5 sm:text-xs",children:r.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[r.jsx("span",{className:"truncate text-xs font-normal text-muted-foreground",children:op||ji||z("input.clickToChangeMode")}),r.jsx(Ar,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground sm:hidden"})]})}),r.jsx(nl,{children:r.jsxs(Tm,{children:[r.jsx(_m,{children:ji}),Br.modes.map(f=>r.jsx(Ko,{value:f,children:So(f,{short:!0})},f))]})})]})}),Jr.enabled&&r.jsx(Mm,{selectedMode:Gr,onModeChange:rs,className:"sm:flex-none"}),mr!==null&&r.jsxs("div",{className:"hidden cursor-help items-center gap-1.5 px-2 py-1.5 text-xs text-muted-foreground sm:flex",title:"Token Budget",children:[r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4m0 5c0 2.21-3.582 4-8 4s-8-1.79-8-4"})}),r.jsx("span",{children:(()=>{if(typeof mr?.percentage=="number")return`${Math.min(100,Math.max(0,mr.percentage))}%`;if(typeof mr?.used=="number"&&typeof mr?.total=="number"&&mr.total>0){const f=Math.round(mr.used/mr.total*100);return`${Math.min(100,Math.max(0,f))}%`}return"0%"})()})]}),r.jsx("div",{className:"w-px h-4 bg-gray-200 dark:bg-gray-700 mx-1 hidden sm:block"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("div",{className:"relative group hidden sm:block",children:[r.jsx("button",{type:"button",className:"rounded-lg p-1.5 text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",title:z("input.commands"),children:r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),r.jsx("div",{className:"chat-floating-panel absolute bottom-full right-0 z-50 mb-2 hidden w-64 rounded-lg p-3 text-xs text-muted-foreground group-hover:block",children:r.jsx("p",{children:z(w?"input.hintText.ctrlEnter":"input.hintText.enter")})})]}),r.jsx("button",{type:"submit",disabled:!X.trim()||fn,onMouseDown:f=>{f.preventDefault(),Xr(f)},onTouchStart:f=>{f.preventDefault(),Xr(f)},className:"flex h-9 w-9 items-center justify-center rounded-full bg-foreground text-background transition-colors hover:opacity-90 disabled:cursor-not-allowed disabled:bg-muted disabled:text-muted-foreground",children:r.jsx("svg",{className:"w-5 h-5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 12h12m-5-5 5 5-5 5"})})})]})]})]})]})]})]})]})]})}const Fy=Tn.memo(Oy);class Tt{constructor(t,n,s,o){this.fromA=t,this.toA=n,this.fromB=s,this.toB=o}offset(t,n=t){return new Tt(this.fromA+t,this.toA+t,this.fromB+n,this.toB+n)}}function sn(e,t,n,s,o,a){if(e==s)return[];let i=fi(e,t,n,s,o,a),c=hi(e,t+i,n,s,o+i,a);t+=i,n-=c,o+=i,a-=c;let d=n-t,u=a-o;if(!d||!u)return[new Tt(t,n,o,a)];if(d>u){let m=e.slice(t,n).indexOf(s.slice(o,a));if(m>-1)return[new Tt(t,t+m,o,o),new Tt(t+m+u,n,a,a)]}else if(u>d){let m=s.slice(o,a).indexOf(e.slice(t,n));if(m>-1)return[new Tt(t,t,o,o+m),new Tt(n,n,o+m+d,a)]}if(d==1||u==1)return[new Tt(t,n,o,a)];let p=Mu(e,t,n,s,o,a);if(p){let[m,h,g]=p;return sn(e,t,m,s,o,h).concat(sn(e,m+g,n,s,h+g,a))}return $y(e,t,n,s,o,a)}let $n=1e9,Bn=0,mi=!1;function $y(e,t,n,s,o,a){let i=n-t,c=a-o;if($n<1e9&&Math.min(i,c)>$n*16||Bn>0&&Date.now()>Bn)return Math.min(i,c)>$n*64?[new Tt(t,n,o,a)]:Zl(e,t,n,s,o,a);let d=Math.ceil((i+c)/2);la.reset(d),ca.reset(d);let u=(g,x)=>e.charCodeAt(t+g)==s.charCodeAt(o+x),p=(g,x)=>e.charCodeAt(n-g-1)==s.charCodeAt(a-x-1),m=(i-c)%2!=0?ca:null,h=m?null:la;for(let g=0;g<d;g++){if(g>$n||Bn>0&&!(g&63)&&Date.now()>Bn)return Zl(e,t,n,s,o,a);let x=la.advance(g,i,c,d,m,!1,u)||ca.advance(g,i,c,d,h,!0,p);if(x)return By(e,t,n,t+x[0],s,o,a,o+x[1])}return[new Tt(t,n,o,a)]}class Tu{constructor(){this.vec=[]}reset(t){this.len=t<<1;for(let n=0;n<this.len;n++)this.vec[n]=-1;this.vec[t+1]=0,this.start=this.end=0}advance(t,n,s,o,a,i,c){for(let d=-t+this.start;d<=t-this.end;d+=2){let u=o+d,p=d==-t||d!=t&&this.vec[u-1]<this.vec[u+1]?this.vec[u+1]:this.vec[u-1]+1,m=p-d;for(;p<n&&m<s&&c(p,m);)p++,m++;if(this.vec[u]=p,p>n)this.end+=2;else if(m>s)this.start+=2;else if(a){let h=o+(n-s)-d;if(h>=0&&h<this.len&&a.vec[h]!=-1)if(i){let g=a.vec[h];if(g>=n-p)return[g,o+g-h]}else{let g=n-a.vec[h];if(p>=g)return[p,m]}}}return null}}const la=new Tu,ca=new Tu;function By(e,t,n,s,o,a,i,c){let d=!1;return!En(e,s)&&++s==n&&(d=!0),!En(o,c)&&++c==i&&(d=!0),d?[new Tt(t,n,a,i)]:sn(e,t,s,o,a,c).concat(sn(e,s,n,o,c,i))}function _u(e,t){let n=1,s=Math.min(e,t);for(;n<s;)n=n<<1;return n}function fi(e,t,n,s,o,a){if(t==n||t==a||e.charCodeAt(t)!=s.charCodeAt(o))return 0;let i=_u(n-t,a-o);for(let c=t,d=o;;){let u=c+i,p=d+i;if(u>n||p>a||e.slice(c,u)!=s.slice(d,p)){if(i==1)return c-t-(En(e,c)?0:1);i=i>>1}else{if(u==n||p==a)return u-t;c=u,d=p}}}function hi(e,t,n,s,o,a){if(t==n||o==a||e.charCodeAt(n-1)!=s.charCodeAt(a-1))return 0;let i=_u(n-t,a-o);for(let c=n,d=a;;){let u=c-i,p=d-i;if(u<t||p<o||e.slice(u,c)!=s.slice(p,d)){if(i==1)return n-c-(En(e,c)?0:1);i=i>>1}else{if(u==t||p==o)return n-u;c=u,d=p}}}function za(e,t,n,s,o,a,i,c){let d=s.slice(o,a),u=null;for(;;){if(u||i<c)return u;for(let p=t+i;;){En(e,p)||p++;let m=p+i;if(En(e,m)||(m+=m==p+1?1:-1),m>=n)break;let h=e.slice(p,m),g=-1;for(;(g=d.indexOf(h,g+1))!=-1;){let x=fi(e,m,n,s,o+g+h.length,a),S=hi(e,t,p,s,o,o+g),k=h.length+x+S;(!u||u[2]<k)&&(u=[p-S,o+g-S,k])}p=m}if(c<0)return u;i=i>>1}}function Mu(e,t,n,s,o,a){let i=n-t,c=a-o;if(i<c){let d=Mu(s,o,a,e,t,n);return d&&[d[1],d[0],d[2]]}return i<4||c*2<i?null:za(e,t,n,s,o,a,Math.floor(i/4),-1)}function Zl(e,t,n,s,o,a){mi=!0;let i=n-t,c=a-o,d;if(i<c){let h=za(s,o,a,e,t,n,Math.floor(i/6),50);d=h&&[h[1],h[0],h[2]]}else d=za(e,t,n,s,o,a,Math.floor(c/6),50);if(!d)return[new Tt(t,n,o,a)];let[u,p,m]=d;return sn(e,t,u,s,o,p).concat(sn(e,u+m,n,s,p+m,a))}function Du(e,t){for(let n=1;n<e.length;n++){let s=e[n-1],o=e[n];s.toA>o.fromA-t&&s.toB>o.fromB-t&&(e[n-1]=new Tt(s.fromA,o.toA,s.fromB,o.toB),e.splice(n--,1))}}function zy(e,t,n){for(;;){Du(n,1);let s=!1;for(let o=0;o<n.length;o++){let a=n[o],i,c;(i=fi(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[o]=new Tt(a.fromA+i,a.toA,a.fromB+i,a.toB)),(c=hi(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[o]=new Tt(a.fromA,a.toA-c,a.fromB,a.toB-c));let d=a.toA-a.fromA,u=a.toB-a.fromB;if(d&&u)continue;let p=a.fromA-(o?n[o-1].toA:0),m=(o<n.length-1?n[o+1].fromA:e.length)-a.toA;if(!p||!m)continue;let h=d?e.slice(a.fromA,a.toA):t.slice(a.fromB,a.toB);p<=h.length&&e.slice(a.fromA-p,a.fromA)==h.slice(h.length-p)?(n[o]=new Tt(a.fromA-p,a.toA-p,a.fromB-p,a.toB-p),s=!0):m<=h.length&&e.slice(a.toA,a.toA+m)==h.slice(0,m)&&(n[o]=new Tt(a.fromA+m,a.toA+m,a.fromB+m,a.toB+m),s=!0)}if(!s)break}return n}function Uy(e,t,n){for(let s=0,o=0;o<e.length;o++){let a=e[o],i=a.toA-a.fromA,c=a.toB-a.fromB;if(i&&c||i>3||c>3){let d=o==e.length-1?t.length:e[o+1].fromA,u=a.fromA-s,p=d-a.toA,m=tc(t,a.fromA,u),h=ec(t,a.toA,p),g=a.fromA-m,x=h-a.toA;if((!i||!c)&&g&&x){let S=Math.max(i,c),[k,I,A]=i?[t,a.fromA,a.toA]:[n,a.fromB,a.toB];S>g&&t.slice(m,a.fromA)==k.slice(A-g,A)?(a=e[o]=new Tt(m,m+i,a.fromB-g,a.toB-g),m=a.fromA,h=ec(t,a.toA,d-a.toA)):S>x&&t.slice(a.toA,h)==k.slice(I,I+x)&&(a=e[o]=new Tt(h-i,h,a.fromB+x,a.toB+x),h=a.toA,m=tc(t,a.fromA,a.fromA-s)),g=a.fromA-m,x=h-a.toA}if(g||x)a=e[o]=new Tt(a.fromA-g,a.toA+x,a.fromB-g,a.toB+x);else if(i){if(!c){let S=nc(t,a.fromA,a.toA),k,I=S<0?-1:rc(t,a.toA,a.fromA);S>-1&&(k=S-a.fromA)<=p&&t.slice(a.fromA,S)==t.slice(a.toA,a.toA+k)?a=e[o]=a.offset(k):I>-1&&(k=a.toA-I)<=u&&t.slice(a.fromA-k,a.fromA)==t.slice(I,a.toA)&&(a=e[o]=a.offset(-k))}}else{let S=nc(n,a.fromB,a.toB),k,I=S<0?-1:rc(n,a.toB,a.fromB);S>-1&&(k=S-a.fromB)<=p&&n.slice(a.fromB,S)==n.slice(a.toB,a.toB+k)?a=e[o]=a.offset(k):I>-1&&(k=a.toB-I)<=u&&n.slice(a.fromB-k,a.fromB)==n.slice(I,a.toB)&&(a=e[o]=a.offset(-k))}}s=a.toA}return Du(e,3),e}let nn;try{nn=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch{}function Ru(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function Pu(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?Ru(n)?1:0:nn?!Fu(n)||t==e.length-1?nn.test(String.fromCharCode(n))?1:0:nn.test(e.slice(t,t+2))?2:0:0}function Lu(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?Ru(n)?1:0:nn?!$u(n)||t==1?nn.test(String.fromCharCode(n))?1:0:nn.test(e.slice(t-2,t))?2:0:0}const Ou=8;function ec(e,t,n){if(t==e.length||!Lu(e,t))return t;for(let s=t,o=t+n,a=0;a<Ou;a++){let i=Pu(e,s);if(!i||s+i>o)return s;s+=i}return t}function tc(e,t,n){if(!t||!Pu(e,t))return t;for(let s=t,o=t-n,a=0;a<Ou;a++){let i=Lu(e,s);if(!i||s-i<o)return s;s-=i}return t}function rc(e,t,n){for(;t!=n;t--)if(e.charCodeAt(t-1)==10)return t;return-1}function nc(e,t,n){for(;t!=n;t++)if(e.charCodeAt(t)==10)return t;return-1}const Fu=e=>e>=55296&&e<=56319,$u=e=>e>=56320&&e<=57343;function En(e,t){return!t||t==e.length||!Fu(e.charCodeAt(t-1))||!$u(e.charCodeAt(t))}function Wy(e,t,n){var s;return $n=((s=n?.scanLimit)!==null&&s!==void 0?s:1e9)>>1,Bn=n?.timeout?Date.now()+n.timeout:0,mi=!1,zy(e,t,sn(e,0,e.length,t,0,t.length))}function Bu(){return!mi}function zu(e,t,n){return Uy(Wy(e,t,n),e,t)}const Mr=Js.define({combine:e=>e[0]}),Hy=Wa.define(),Uu=Js.define(),ar=Vn.define({create(e){return null},update(e,t){for(let n of t.effects)n.is(Hy)&&(e=n.value);for(let n of t.state.facet(Uu))e=n(e,t);return e}});function da(e){let t=e.field(ar,!1);if(!t)return null;let n=e.facet(Mr);return{chunks:t,side:n?n.side:null}}class wn{constructor(t,n,s,o,a,i=!0){this.changes=t,this.fromA=n,this.toA=s,this.fromB=o,this.toB=a,this.precise=i}offset(t,n){return t||n?new wn(this.changes,this.fromA+t,this.toA+t,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(t,n,s){let o=zu(t.toString(),n.toString(),s);return Wu(o,t,n,0,0,Bu())}static updateA(t,n,s,o,a){return lc(ic(t,o,!0,s.length),t,n,s,a)}static updateB(t,n,s,o,a){return lc(ic(t,o,!1,n.length),t,n,s,a)}}function sc(e,t,n,s){let o=n.lineAt(e),a=s.lineAt(t);return o.to==e&&a.to==t&&e<n.length&&t<s.length?[e+1,t+1]:[o.from,a.from]}function oc(e,t,n,s){let o=n.lineAt(e),a=s.lineAt(t);return o.from==e&&a.from==t?[e,t]:[o.to+1,a.to+1]}function Wu(e,t,n,s,o,a){let i=[];for(let c=0;c<e.length;c++){let d=e[c],[u,p]=sc(d.fromA+s,d.fromB+o,t,n),[m,h]=oc(d.toA+s,d.toB+o,t,n),g=[d.offset(-u+s,-p+o)];for(;c<e.length-1;){let x=e[c+1],[S,k]=sc(x.fromA+s,x.fromB+o,t,n);if(S>m+1&&k>h+1)break;g.push(x.offset(-u+s,-p+o)),[m,h]=oc(x.toA+s,x.toB+o,t,n),c++}i.push(new wn(g,u,Math.max(u,m),p,Math.max(p,h),a))}return i}const Rs=1e3;function ac(e,t,n,s){let o=0,a=e.length;for(;;){if(o==a){let p=0,m=0;o&&({toA:p,toB:m}=e[o-1]);let h=t-(n?p:m);return[p+h,m+h]}let i=o+a>>1,c=e[i],[d,u]=n?[c.fromA,c.toA]:[c.fromB,c.toB];if(d>t)a=i;else if(u<=t)o=i+1;else return s?[c.fromA,c.fromB]:[c.toA,c.toB]}}function ic(e,t,n,s){let o=[];return t.iterChangedRanges((a,i,c,d)=>{let u=0,p=n?t.length:s,m=0,h=n?s:t.length;a>Rs&&([u,m]=ac(e,a-Rs,n,!0)),i<t.length-Rs&&([p,h]=ac(e,i+Rs,n,!1));let g=d-c-(i-a),x,[S,k]=n?[g,0]:[0,g];o.length&&(x=o[o.length-1]).toA>=u?o[o.length-1]={fromA:x.fromA,fromB:x.fromB,toA:p,toB:h,diffA:x.diffA+S,diffB:x.diffB+k}:o.push({fromA:u,toA:p,fromB:m,toB:h,diffA:S,diffB:k})}),o}function lc(e,t,n,s,o){if(!e.length)return t;let a=[];for(let i=0,c=0,d=0,u=0;;i++){let p=i==e.length?null:e[i],m=p?p.fromA+c:n.length,h=p?p.fromB+d:s.length;for(;u<t.length;){let k=t[u];if(k.toA+c>m||k.toB+d>h)break;a.push(k.offset(c,d)),u++}if(!p)break;let g=p.toA+c+p.diffA,x=p.toB+d+p.diffB,S=zu(n.sliceString(m,g),s.sliceString(h,x),o);for(let k of Wu(S,n,s,m,h,Bu()))a.push(k);for(c+=p.diffA,d+=p.diffB;u<t.length;){let k=t[u];if(k.fromA+c>g&&k.fromB+d>x)break;u++}}return a}const qy={scanLimit:500},Hu=Ys.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=uc(e))}update(e){(e.docChanged||e.viewportChanged||Vy(e.startState,e.state)||Ky(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=uc(e.view))}},{decorations:e=>e.deco});function Vy(e,t){return e.field(ar,!1)!=t.field(ar,!1)}function Ky(e,t){return e.facet(Mr)!=t.facet(Mr)}const cc=Dr.line({class:"cm-changedLine"}),qu=Dr.mark({class:"cm-changedText"}),Gy=Dr.mark({tagName:"ins",class:"cm-insertedLine"}),Jy=Dr.mark({tagName:"del",class:"cm-deletedLine"}),dc=new class extends Ha{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function Yy(e,t,n,s,o,a){let i=n?e.fromA:e.fromB,c=n?e.toA:e.toB,d=0;if(i!=c){o.add(i,i,cc),o.add(i,c,n?Jy:Gy),a&&a.add(i,i,dc);for(let u=t.iterRange(i,c-1),p=i;!u.next().done;){if(u.lineBreak){p++,o.add(p,p,cc),a&&a.add(p,p,dc);continue}let m=p+u.value.length;if(s)for(;d<e.changes.length;){let h=e.changes[d],g=i+(n?h.fromA:h.fromB),x=i+(n?h.toA:h.toB),S=Math.max(p,g),k=Math.min(m,x);if(S<k&&o.add(S,k,qu),x<m)d++;else break}p=m}}}function uc(e){let t=e.state.field(ar),{side:n,highlightChanges:s,markGutter:o,overrideChunk:a}=e.state.facet(Mr),i=n=="a",c=new Ls,d=o?new Ls:null,{from:u,to:p}=e.viewport;for(let m of t){if((i?m.fromA:m.fromB)>=p)break;(i?m.toA:m.toB)>u&&(!a||!a(e.state,m,c,d))&&Yy(m,e.state.doc,i,s,c,d)}return{deco:c.finish(),gutter:d&&d.finish()}}const Ua=Wa.define({map:(e,t)=>t.mapPos(e)});class Xy extends qa{constructor(t){super(),this.lines=t}eq(t){return this.lines==t.lines}toDOM(t){let n=document.createElement("div");return n.className="cm-collapsedLines",n.textContent=t.state.phrase("$ unchanged lines",this.lines),n.addEventListener("click",s=>{let o=t.posAtDOM(s.target);t.dispatch({effects:Ua.of(o)});let{side:a,sibling:i}=t.state.facet(Mr);i&&i().dispatch({effects:Ua.of(Qy(o,t.state.field(ar),a=="a"))})}),n}ignoreEvent(t){return t instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return"collapsed-unchanged-code"}}function Qy(e,t,n){let s=0,o=0;for(let a=0;;a++){let i=a<t.length?t[a]:null;if(!i||(n?i.fromA:i.fromB)>=e)return o+(e-s);[s,o]=n?[i.toA,i.toB]:[i.toB,i.toA]}}const Zy=Vn.define({create(e){return Dr.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(Ua)&&(e=e.update({filter:s=>s!=n.value}));return e},provide:e=>ur.decorations.from(e)});function eb({margin:e=3,minSize:t=4}){return Zy.init(n=>tb(n,e,t))}function tb(e,t,n){let s=new Ls,o=e.facet(Mr).side=="a",a=e.field(ar),i=1;for(let c=0;;c++){let d=c<a.length?a[c]:null,u=c?i+t:1,p=d?e.doc.lineAt(o?d.fromA:d.fromB).number-1-t:e.doc.lines,m=p-u+1;if(m>=n&&s.add(e.doc.line(u).from,e.doc.line(p).to,Dr.replace({widget:new Xy(m),block:!0})),!d)break;i=e.doc.lineAt(Math.min(e.doc.length,o?d.toA:d.toB)).number}return s.finish()}const rb=ur.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:"auto !important",overflowY:"visible !important"},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:"rgba(160, 128, 100, .08)"},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:"rgba(100, 160, 128, .08)"},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat"},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat"},"&light.cm-merge-b .cm-changedText":{background:"linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat"},"&.cm-merge-b .cm-deletedText":{background:"#ff000033"},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:"none"},".cm-deletedChunk":{paddingLeft:"6px","& .cm-chunkButtons":{position:"absolute",insetInlineEnd:"5px"},"& button":{border:"none",cursor:"pointer",color:"white",margin:"0 2px",borderRadius:"3px","&[name=accept]":{background:"#2a2"},"&[name=reject]":{background:"#d43"}}},".cm-collapsedLines":{padding:"5px 5px 5px 10px",cursor:"pointer","&:before":{content:'"⦚"',marginInlineEnd:"7px"},"&:after":{content:'"⦚"',marginInlineStart:"7px"}},"&light .cm-collapsedLines":{color:"#444",background:"linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)"},"&dark .cm-collapsedLines":{color:"#ddd",background:"linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)"},".cm-changeGutter":{width:"3px",paddingLeft:"1px"},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:"#e43"},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:"#fa9"},"&light.cm-merge-b .cm-changedLineGutter":{background:"#2b2"},"&dark.cm-merge-b .cm-changedLineGutter":{background:"#8f8"},".cm-inlineChangedLineGutter":{background:"#75d"}}),nb=new class extends Ha{constructor(){super(...arguments),this.elementClass="cm-deletedLineGutter"}},sb=Sc.low(Up({class:"cm-changeGutter",markers:e=>{var t;return((t=e.plugin(Hu))===null||t===void 0?void 0:t.gutter)||Hp.empty},widgetMarker:(e,t)=>t instanceof Vu?nb:null}));function ob(e){var t;let n=typeof e.original=="string"?jc.of(e.original.split(/\r?\n/)):e.original,s=e.diffConfig||qy;return[Sc.low(Hu),cb,rb,ur.editorAttributes.of({class:"cm-merge-b"}),Uu.of((o,a)=>{let i=a.effects.find(c=>c.is(gi));return i&&(o=wn.updateA(o,i.value.doc,a.startState.doc,i.value.changes,s)),a.docChanged&&(o=wn.updateB(o,a.state.field(In),a.newDoc,a.changes,s)),o}),Mr.of({highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1,syntaxHighlightDeletions:e.syntaxHighlightDeletions!==!1,syntaxHighlightDeletionsMaxLength:3e3,mergeControls:(t=e.mergeControls)!==null&&t!==void 0?t:!0,overrideChunk:e.allowInlineDiffs?mb:void 0,side:"b"}),In.init(()=>n),e.gutter!==!1?sb:[],e.collapseUnchanged?eb(e.collapseUnchanged):[],ar.init(o=>wn.build(n,o.doc,s))]}const gi=Wa.define(),In=Vn.define({create:()=>jc.empty,update(e,t){for(let n of t.effects)n.is(gi)&&(e=n.value.doc);return e}}),pc=new WeakMap;class Vu extends qa{constructor(t){super(),this.buildDOM=t,this.dom=null}eq(t){return this.dom==t.dom}toDOM(t){return this.dom||(this.dom=this.buildDOM(t))}}function ab(e,t,n){let s=pc.get(t.changes);if(s)return s;let o=i=>{let{highlightChanges:c,syntaxHighlightDeletions:d,syntaxHighlightDeletionsMaxLength:u,mergeControls:p}=e.facet(Mr),m=document.createElement("div");if(m.className="cm-deletedChunk",p){let M=m.appendChild(document.createElement("div"));M.className="cm-chunkButtons";let C=R=>{R.preventDefault(),ib(i,i.posAtDOM(m))},b=R=>{R.preventDefault(),lb(i,i.posAtDOM(m))};if(typeof p=="function")M.appendChild(p("accept",C)),M.appendChild(p("reject",b));else{let R=M.appendChild(document.createElement("button"));R.name="accept",R.textContent=e.phrase("Accept"),R.onmousedown=C;let B=M.appendChild(document.createElement("button"));B.name="reject",B.textContent=e.phrase("Reject"),B.onmousedown=b}}if(n||t.fromA>=t.toA)return m;let h=i.state.field(In).sliceString(t.fromA,t.endA),g=d&&e.facet(Nc),x=A(),S=t.changes,k=0,I=!1;function A(){let M=m.appendChild(document.createElement("div"));return M.className="cm-deletedLine",M.appendChild(document.createElement("del"))}function w(M,C,b){for(let R=M;R<C;){if(h.charAt(R)==`
|
|
318
|
-
`){x.firstChild||x.appendChild(document.createElement("br")),x=A(),R++;continue}let B=C,D=b+(I?" cm-deletedText":""),Z=!1,z=h.indexOf(`
|
|
319
|
-
`,R);if(z>-1&&z<C&&(B=z),c&&k<S.length){let X=Math.max(0,I?S[k].toA:S[k].fromA);X<=B&&(B=X,I&&k++,Z=!0)}if(B>R){let X=document.createTextNode(h.slice(R,B));if(D){let q=x.appendChild(document.createElement("span"));q.className=D,q.appendChild(X)}else x.appendChild(X);R=B}Z&&(I=!I)}}if(g&&t.toA-t.fromA<=u){let M=g.parser.parse(h),C=0;ma(M,{style:b=>Cc(e,b)},(b,R,B)=>{b>C&&w(C,b,""),w(b,R,B),C=R}),w(C,h.length,"")}else w(0,h.length,"");return x.firstChild||x.appendChild(document.createElement("br")),m},a=Dr.widget({block:!0,side:-1,widget:new Vu(o)});return pc.set(t.changes,a),a}function ib(e,t){let{state:n}=e,s=t??n.selection.main.head,o=e.state.field(ar).find(d=>d.fromB<=s&&d.endB>=s);if(!o)return!1;let a=e.state.sliceDoc(o.fromB,Math.max(o.fromB,o.toB-1)),i=e.state.field(In);o.fromB!=o.toB&&o.toA<=i.length&&(a+=e.state.lineBreak);let c=Wp.of({from:o.fromA,to:Math.min(i.length,o.toA),insert:a},i.length);return e.dispatch({effects:gi.of({doc:c.apply(i),changes:c}),userEvent:"accept"}),!0}function lb(e,t){let{state:n}=e,s=t??n.selection.main.head,o=n.field(ar).find(c=>c.fromB<=s&&c.endB>=s);if(!o)return!1;let i=n.field(In).sliceString(o.fromA,Math.max(o.fromA,o.toA-1));return o.fromA!=o.toA&&o.toB<=n.doc.length&&(i+=n.lineBreak),e.dispatch({changes:{from:o.fromB,to:Math.min(n.doc.length,o.toB),insert:i},userEvent:"revert"}),!0}function mc(e){let t=new Ls;for(let n of e.field(ar)){let s=e.facet(Mr).overrideChunk&&Ku(e,n);t.add(n.fromB,n.fromB,ab(e,n,!!s))}return t.finish()}const cb=Vn.define({create:e=>mc(e),update(e,t){return t.state.field(ar,!1)!=t.startState.field(ar,!1)?mc(t.state):e},provide:e=>ur.decorations.from(e)}),fc=new WeakMap;function Ku(e,t){let n=fc.get(t);if(n!==void 0)return n;n=null;let s=e.field(In),o=e.doc,a=s.lineAt(t.endA).number-s.lineAt(t.fromA).number+1,i=o.lineAt(t.endB).number-o.lineAt(t.fromB).number+1;e:if(a==i&&a<10){let c=[],d=0,u=t.fromA,p=t.fromB;for(let m of t.changes){if(m.fromA<m.toA){d+=m.toA-m.fromA;let h=s.sliceString(u+m.fromA,u+m.toA);if(/\n/.test(h))break e;c.push(Dr.widget({widget:new db(h),side:-1}).range(p+m.fromB))}m.fromB<m.toB&&c.push(qu.range(p+m.fromB,p+m.toB))}d<t.endA-t.fromA-a*2&&(n=c)}return fc.set(t,n),n}class db extends qa{constructor(t){super(),this.text=t}eq(t){return this.text==t.text}toDOM(t){let n=document.createElement("del");return n.className="cm-deletedText",n.textContent=this.text,n}}const ub=new class extends Ha{constructor(){super(...arguments),this.elementClass="cm-inlineChangedLineGutter"}},pb=Dr.line({class:"cm-inlineChangedLine"});function mb(e,t,n,s){let o=Ku(e,t),a=0;if(!o)return!1;for(let i=e.doc.lineAt(t.fromB);;){for(s&&s.add(i.from,i.from,ub),n.add(i.from,i.from,pb);a<o.length&&o[a].to<=i.to;){let c=o[a++];n.add(c.from,c.to,c.value)}if(i.to>=t.endB)break;i=e.doc.lineAt(i.to+1)}return!0}var fb=function(e,t){var n={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,s=Object.getOwnPropertySymbols(e);o<s.length;o++)t.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(e,s[o])&&(n[s[o]]=e[s[o]]);return n};const Ut=Js.define({combine:e=>{const t=[];for(let n of e){if(!n)continue;const{create:s,gutters:o}=n,a=fb(n,["create","gutters"]);t.push(Object.assign(Object.assign({},a),{enabled:!0,gutters:o?o.filter(i=>Object.keys(i).length>0):void 0}))}return qp(t,{enabled:t.length>0,displayText:"characters",eventHandlers:{},showOverlay:"always",gutters:[]})}}),Jt={PixelMultiplier:2,SizeRatio:4,MaxWidth:120},hb=ur.theme({".cm-minimap-overlay-container":{position:"absolute",top:0,height:"100%",width:"100%","&.cm-minimap-overlay-mouse-over":{opacity:0,transition:"visibility 0s linear 300ms, opacity 300ms"},"&.cm-minimap-overlay-mouse-over:hover":{opacity:1,transition:"visibility 0s linear 0ms, opacity 300ms"},"&.cm-minimap-overlay-off":{display:"none"},"& .cm-minimap-overlay":{background:"rgb(121, 121, 121)",opacity:"0.2",position:"absolute",right:0,top:0,width:"100%",transition:"top 0s ease-in 0ms","&:hover":{opacity:"0.3"}},"&.cm-minimap-overlay-active":{opacity:1,visibility:"visible",transition:"visibility 0s linear 0ms, opacity 300ms","& .cm-minimap-overlay":{opacity:"0.4"}}}}),Wr=Jt.PixelMultiplier*Jt.SizeRatio,gb=Ys.fromClass(class{constructor(e){this.view=e,this._isDragging=!1,e.state.facet(Ut).enabled&&this.create(e)}create(e){this.container=kn("div",{class:"cm-minimap-overlay-container"}),this.dom=kn("div",{class:"cm-minimap-overlay"}),this.container.appendChild(this.dom),this.container.addEventListener("mousedown",this.onMouseDown.bind(this)),window.addEventListener("mouseup",this.onMouseUp.bind(this)),window.addEventListener("mousemove",this.onMouseMove.bind(this));const t=e.dom.querySelector(".cm-minimap-inner");t&&t.appendChild(this.container),this.computeShowOverlay(),this.computeHeight(),this.computeTop()}remove(){this.container&&(this.container.removeEventListener("mousedown",this.onMouseDown),window.removeEventListener("mouseup",this.onMouseUp),window.removeEventListener("mousemove",this.onMouseMove),this.container.remove())}update(e){const t=e.startState.facet(Ut).enabled,n=e.state.facet(Ut).enabled;if(t&&!n){this.remove();return}!t&&n&&this.create(e.view),n&&(this.computeShowOverlay(),e.geometryChanged&&(this.computeHeight(),this.computeTop()))}computeHeight(){if(!this.dom)return;const e=this.view.dom.clientHeight/Wr;this.dom.style.height=e+"px"}computeTop(){if(!this._isDragging&&this.dom){const{clientHeight:e,scrollHeight:t,scrollTop:n}=this.view.scrollDOM,s=t-e,o=n/Wr,a=e/Wr,i=e-a;let c=n/s;isNaN(c)&&(c=0);const d=i*c,u=Math.min(d,o);this.dom.style.top=u+"px"}}computeShowOverlay(){if(!this.container)return;const{showOverlay:e}=this.view.state.facet(Ut);e==="mouse-over"?this.container.classList.add("cm-minimap-overlay-mouse-over"):this.container.classList.remove("cm-minimap-overlay-mouse-over");const{clientHeight:t,scrollHeight:n}=this.view.scrollDOM;t===n?this.container.classList.add("cm-minimap-overlay-off"):this.container.classList.remove("cm-minimap-overlay-off")}onMouseDown(e){if(!this.container||e.button===2)return;const{clientY:t,target:n}=e;if(n===this.dom){this._dragStartY=e.clientY,this._isDragging=!0,this.container.classList.add("cm-minimap-overlay-active");return}const{clientHeight:s,scrollHeight:o,scrollTop:a}=this.view.scrollDOM,i=n.getBoundingClientRect().top,c=(t-i)*Wr,d=a/(o-s),p=(s*Wr-s)*d,m=Math.max(0,a-p);this.view.scrollDOM.scrollTop=m+c-s/2}onMouseUp(e){this._isDragging&&this.container&&(this._dragStartY=void 0,this._isDragging=!1,this.container.classList.remove("cm-minimap-overlay-active"))}onMouseMove(e){if(!this._isDragging||!this.dom)return;if(e.preventDefault(),e.stopPropagation(),!this._dragStartY){this._dragStartY=e.clientY;return}const t=e.clientY-this._dragStartY,n=t<0,s=t>0;this._dragStartY=e.clientY;const o=this.dom.getBoundingClientRect().height,a=this.dom.getBoundingClientRect().y,i=a+o,c=parseFloat(this.dom.style.top),d=this.view.scrollDOM.scrollTop,u=this.view.scrollDOM.clientHeight,p=this.view.scrollDOM.scrollHeight,m=d===0,h=Math.round(d)>=Math.round(p-u);if(m&&n||m&&e.clientY<a||h&&s||h&&e.clientY>i)return;const g=this.view.scrollDOM.scrollHeight,x=this.view.scrollDOM.clientHeight,S=(g-x)/Wr,k=x-x/Wr,I=c+t,A=I/k,w=(g-x)*A,M=I*Wr;this.view.scrollDOM.scrollTop=Math.max(w,M);const C=Math.min(Math.max(0,I),Math.min(k,S));this.dom.style.top=C+"px"}destroy(){this.remove()}},{eventHandlers:{scroll(){requestAnimationFrame(()=>this.computeTop())}}}),xb=[hb,gb];class xi{constructor(t){this.map=new Map,this.view=t}get(t){return this.map.get(t)}set(t,n){this.map.set(t,n)}}function hc(e){var t;if(!e.facet(Ut).enabled)return[];const n=[],s=e.doc.iterLines(),o=Vp(e).iter();let a=0;for(s.next();!s.done;){const i=s.value;let c=a,d=c+i.length;for(;o.value&&o.to<c;)o.next();const{from:u,to:p}=o,m=c>=u&&c<p,h=d>u&&d<=p;if(m){let g=(t=n.pop())!==null&&t!==void 0?t:[],x=g.pop();x&&x.folded&&(x.to=p),x&&g.push(x),(!x||!x.folded)&&g.push({from:u,to:p,folded:!0}),h||g.push({from:p,to:d,folded:!1}),n.push(g)}else h?n.push([{from:c,to:u,folded:!1},{from:u,to:p,folded:!0}]):n.push([{from:c,to:d,folded:!1}]);a=d+1,s.next()}return n}const An=Vn.define({create:e=>hc(e),update:(e,t)=>po([t])||t.docChanged?hc(t.state):e});function po(e){return e.find(t=>t.effects.find(n=>n.is(Kp)||n.is(Gp)))}class vb extends xi{constructor(t){super(t),this.count=void 0}shouldUpdate(t){if(!t.state.facet(Ut).enabled)return!1;if(t.docChanged)return!0;for(const n of t.transactions)for(const s of n.effects)if(s.is(Jp))return!0;return!!(po(t.transactions)||this.count===void 0)}update(t){if(!this.shouldUpdate(t))return;this.map.clear();const n=t.state.field(An);this.count=Yp(t.state),Xp(t.state,(s,o,a)=>{const i=this.findLine(o,n),c=this.findLine(a,n);let d=s.severity;for(let u=i;u<=c;u++){const p=this.get(u);p&&(d=[d,p].sort(this.sort.bind(this)).slice(0,1)[0]),this.set(u,d)}})}drawLine(t,n){const{context:s,lineHeight:o,offsetX:a,offsetY:i}=t,c=this.get(n);c&&(s.globalAlpha=.65,s.beginPath(),s.rect(a,i,s.canvas.width-a,o),s.fillStyle=this.color(c),s.fill())}findLine(t,n){return n.findIndex(o=>{const a=o.slice(0,1)[0],i=o.slice(-1)[0];return!a||!i?!1:a.from<=t&&t<=i.to})+1}color(t){return t==="error"?"#d11":t==="warning"?"orange":"#999"}sort(t,n){return this.score(n)-this.score(t)}score(t){switch(t){case"error":return 3;case"warning":return 2;default:return 1}}}function yb(e){return new vb(e)}class bb extends xi{constructor(t){super(t),this.getDrawInfo(),this._themeClasses=t.dom.classList.value}shouldUpdate(t){return t.state.facet(Ut).enabled?!!(t.docChanged||t.selectionSet||this._themeClasses!==this.view.dom.classList.value||po(t.transactions)):!1}update(t){if(!this.shouldUpdate(t))return;this.map.clear(),this._themeClasses!==this.view.dom.classList.value&&(this._drawInfo=void 0,this._themeClasses=this.view.dom.classList.value);const{ranges:n}=t.state.selection;let s=0;for(const[o,a]of t.state.field(An).entries()){const i=[];let c=0;for(const u of a){do{if(s>=n.length||u.to<n[s].from)continue;if(n[s].from===n[s].to){s++;continue}const p=n[s],m={from:c+Math.max(u.from,p.from)-u.from,to:c+Math.min(u.to,p.to)-u.from,extends:p.to>u.to},h=i.slice(-1)[0];if(h&&h.to===m.from){let{to:g}=m;u.folded&&m.extends?g=m.from+1:u.folded&&!m.extends&&(g=h.to),i[i.length-1]=Object.assign(Object.assign({},h),{to:g,extends:m.extends})}else u.folded||i.push(m);if(m.extends)break;s++}while(s<n.length&&u.to>=n[s].from);c+=u.folded?1:u.to-u.from}if(i.length===0)continue;const d=o+1;this.map.set(d,i)}}drawLine(t,n){let{context:s,lineHeight:o,charWidth:a,offsetX:i,offsetY:c}=t;const d=this.get(n);if(d)for(const u of d){const p=i+u.from*a,m=(u.to-u.from)*a,h=s.canvas.width-p;u.extends&&(s.globalAlpha=.65,s.beginPath(),s.rect(p,c,h,o),s.fillStyle=this.getDrawInfo().backgroundColor,s.fill()),s.globalAlpha=1,s.beginPath(),s.rect(p,c,m,o),s.fillStyle=this.getDrawInfo().backgroundColor,s.fill()}}getDrawInfo(){if(this._drawInfo)return this._drawInfo;const t=document.createElement("span");t.setAttribute("class","cm-selectionBackground"),this.view.dom.appendChild(t);const s={backgroundColor:window.getComputedStyle(t).backgroundColor};return this._drawInfo=s,this.view.dom.removeChild(t),s}}function wb(e){return new bb(e)}class kb extends xi{constructor(t){super(t),this._fontInfoMap=new Map,this._themeClasses=new Set(t.dom.classList.values()),t.state.facet(Ut).enabled&&this.updateImpl(t.state)}shouldUpdate(t){return!!(t.docChanged||t.state.facet(Ut)!==t.startState.facet(Ut)||this.themeChanged()||po(t.transactions))}update(t){this.shouldUpdate(t)&&(this._highlightingCallbackId&&(typeof window.requestIdleCallback<"u"?cancelIdleCallback(this._highlightingCallbackId):clearTimeout(this._highlightingCallbackId)),this.updateImpl(t.state,t.changes))}updateImpl(t,n){var s;this.map.clear(),this._displayText=t.facet(Ut).displayText,this.themeChanged()&&this._fontInfoMap.clear();let o;if(this._previousTree&&n){const m=el.addTree(this._previousTree),h=[];n.iterChangedRanges((g,x,S,k)=>h.push({fromA:g,toA:x,fromB:S,toB:k})),o=el.applyChanges(m,h)}const a=t.doc.toString(),i=(s=t.facet(Nc))===null||s===void 0?void 0:s.parser,c=i?i.parse(a,o):void 0;this._previousTree=c;const d={style:m=>Cc(t,m)};let u=[];if(c){const m=t.doc.lineAt(this.view.viewport.from).number,h=t.doc.lineAt(this.view.viewport.to).number,g=h-m,x=m/(t.doc.lines-g),{SizeRatio:S,PixelMultiplier:k}=Jt,I=g*S*k,A=x*I,w=Math.max(1,Math.floor(m-A)),M=Math.min(h+Math.floor(I-A),t.doc.lines);ma(c,d,(C,b,R)=>{u.push({from:C,to:b,tags:R})},t.doc.line(w).from,t.doc.line(M).to)}this.updateMapImpl(t,u),u=[];const p=()=>{c&&(ma(c,d,(m,h,g)=>{u.push({from:m,to:h,tags:g})}),this.updateMapImpl(t,u),this._highlightingCallbackId=void 0)};this._highlightingCallbackId=typeof window.requestIdleCallback<"u"?requestIdleCallback(p):setTimeout(p)}updateMapImpl(t,n){this.map.clear();const s=t.doc.toString(),o=n.values();let a=o.next();for(const[i,c]of t.field(An).entries()){const d=[];for(const p of c){if(p.from===p.to)continue;if(p.folded){d.push({text:"…",tags:""});continue}let m=p.from;for(;!a.done&&a.value.from<p.to;){const{from:h,to:g,tags:x}=a.value;if(g<m){a=o.next();continue}h>m&&d.push({text:s.slice(m,h),tags:""});const S=Math.max(h,p.from),k=Math.min(g,p.to);if(d.push({text:s.slice(S,k),tags:x}),m=k,g>k)break;a=o.next()}m!==p.to&&d.push({text:s.slice(m,p.to),tags:""})}const u=i+1;this.map.set(u,d)}}measure(t){const{color:n,font:s,lineHeight:o}=this.getFontInfo("");return t.textBaseline="ideographic",t.fillStyle=n,t.font=s,{charWidth:t.measureText("_").width,lineHeight:o}}beforeDraw(){this._fontInfoMap.clear()}drawLine(t,n){const s=this.get(n);if(!s)return;let{context:o,charWidth:a,lineHeight:i,offsetX:c,offsetY:d}=t,u;o.textBaseline="ideographic";for(const p of s){const m=this.getFontInfo(p.tags);switch((!u||u.color!==m.color)&&(o.fillStyle=m.color),(!u||u.font!==m.font)&&(o.font=m.font),u=m,i=Math.max(i,m.lineHeight),this._displayText){case"characters":{o.fillText(p.text,c,d+i),c+=p.text.length*a;break}case"blocks":{const h=/\S+/g;let g;for(;(g=h.exec(p.text))!==null;){const x=c+g.index*a;let S=(h.lastIndex-g.index)*a;if(x>o.canvas.width)break;x+S>o.canvas.width&&(S=o.canvas.width-x);const k=2/Jt.SizeRatio,I=i-k;o.fillStyle=m.color,o.globalAlpha=.65,o.beginPath(),o.rect(x,d,S,I),o.fill()}c+=p.text.length*a;break}}}}getFontInfo(t){const n=this._fontInfoMap.get(t);if(n)return n;const s=kn("span",{class:t}),o=kn("div",{class:"cm-line",style:"display: none"},s);this.view.contentDOM.appendChild(o);const a=window.getComputedStyle(s),i=parseFloat(a.lineHeight)/Jt.SizeRatio,c={color:a.color,font:`${a.fontStyle} ${a.fontWeight} ${i}px ${a.fontFamily}`,lineHeight:i};return this._fontInfoMap.set(t,c),this.view.contentDOM.removeChild(o),c}themeChanged(){const t=this._themeClasses,n=new Set(this.view.dom.classList.values());if(this._themeClasses=n,!t||(t.delete("cm-focused"),n.delete("cm-focused"),t.size!==n.size))return!0;let s=!0;return t.forEach(o=>{n.has(o)||(s=!1)}),!s}}function jb(e){return new kb(e)}const Gu=4;function Sb(e,t,n){const s=e[n];s&&(t.context.fillStyle=s,t.context.globalAlpha=1,t.context.beginPath(),t.context.rect(t.offsetX,t.offsetY,Gu,t.lineHeight),t.context.fill())}const Nb=ur.theme({"&":{height:"100%",overflowY:"auto"},"& .cm-minimap-gutter":{borderRight:0,flexShrink:0,left:"unset",position:"sticky",right:0,top:0},"& .cm-minimap-inner":{height:"100%",position:"absolute",right:0,top:0,overflowY:"hidden","& canvas":{display:"block"}},"& .cm-minimap-box-shadow":{boxShadow:"12px 0px 20px 5px #6c6c6c"}}),gc=6,Cb=Ys.fromClass(class{constructor(e){this.view=e,this.text=jb(e),this.selection=wb(e),this.diagnostic=yb(e),e.state.facet(zn)&&this.create(e)}create(e){const t=e.state.facet(zn);if(!t)throw Error("Expected nonnull");this.inner=kn("div",{class:"cm-minimap-inner"}),this.canvas=kn("canvas"),this.dom=t.create(e).dom,this.dom.classList.add("cm-gutters"),this.dom.classList.add("cm-minimap-gutter"),this.inner.appendChild(this.canvas),this.dom.appendChild(this.inner),this.view.scrollDOM.insertBefore(this.dom,this.view.contentDOM.nextSibling);for(const n in this.view.state.facet(Ut).eventHandlers){const s=this.view.state.facet(Ut).eventHandlers[n];s&&this.dom.addEventListener(n,o=>s(o,this.view))}}remove(){this.dom&&this.dom.remove()}update(e){const t=e.startState.facet(zn),n=e.state.facet(zn);if(t&&!n){this.remove();return}!t&&n&&this.create(e.view),n&&(this.text.update(e),this.selection.update(e),this.diagnostic.update(e),this.render())}getWidth(){const e=this.view.dom.clientWidth;if(e<=Jt.MaxWidth*gc){const t=e/(Jt.MaxWidth*gc);return Jt.MaxWidth*t}return Jt.MaxWidth}render(){if(!this.dom||!this.canvas||!this.inner)return;this.text.beforeDraw(),this.updateBoxShadow(),this.dom.style.width=this.getWidth()+"px",this.canvas.style.maxWidth=this.getWidth()+"px",this.canvas.width=this.getWidth()*Jt.PixelMultiplier;const e=this.view.dom.getBoundingClientRect().height;this.inner.style.minHeight=e+"px",this.canvas.height=e*Jt.PixelMultiplier,this.canvas.style.height=e+"px";const t=this.canvas.getContext("2d");if(!t)return;t.clearRect(0,0,this.canvas.width,this.canvas.height);const{charWidth:n,lineHeight:s}=this.text.measure(t);let{startIndex:o,endIndex:a,offsetY:i}=this.canvasStartAndEndIndex(t,s);const c=this.view.state.facet(Ut).gutters;for(let d=o;d<a;d++){const u=this.view.state.field(An);if(d>=u.length)break;const p={offsetX:0,offsetY:i,context:t,lineHeight:s,charWidth:n};if(c.length){p.offsetX+=2;for(let m of c)Sb(m,p,d+1),p.offsetX+=Gu;p.offsetX+=2}this.text.drawLine(p,d+1),this.selection.drawLine(p,d+1),this.diagnostic.drawLine(p,d+1),i+=s}t.restore()}canvasStartAndEndIndex(e,t){let{top:n,bottom:s}=this.view.documentPadding;n/=Jt.SizeRatio,s/=Jt.SizeRatio;const o=e.canvas.height,{clientHeight:a,scrollHeight:i,scrollTop:c}=this.view.scrollDOM;let d=c/(i-a);isNaN(d)&&(d=0);const u=this.view.state.field(An).length,p=n+s+u*t,m=Math.max(0,d*(p-o)),h=Math.max(0,n-m),g=Math.round(Math.max(0,m-n)/t),x=Math.round((o-h)/t);return{startIndex:g,endIndex:g+x,offsetY:h}}updateBoxShadow(){if(!this.canvas)return;const{clientWidth:e,scrollWidth:t,scrollLeft:n}=this.view.scrollDOM;e+n<t?this.canvas.classList.add("cm-minimap-box-shadow"):this.canvas.classList.remove("cm-minimap-box-shadow")}destroy(){this.remove()}},{eventHandlers:{scroll(){requestAnimationFrame(()=>this.render())}},provide:e=>ur.scrollMargins.of(t=>{var n;const s=(n=t.plugin(e))===null||n===void 0?void 0:n.getWidth();return s?{right:s}:null})}),zn=Js.define({combine:e=>{var t;return(t=e.find(n=>n!==null))!==null&&t!==void 0?t:null},enables:e=>[[Ut.compute([e],t=>t.facet(e)),Nb,An,Cb,xb]]});function xc({file:e,onClose:t,projectPath:n,isSidebar:s=!1,isExpanded:o=!1,onToggleExpand:a=null}){const{t:i}=Mt("codeEditor"),[c,d]=l.useState(""),[u,p]=l.useState(!0),[m,h]=l.useState(!1),[g,x]=l.useState(!1),[S,k]=l.useState(()=>{const $=localStorage.getItem("codeEditorTheme");return $?$==="dark":!0}),[I,A]=l.useState(!1),[w,M]=l.useState(!!e.diffInfo),[C,b]=l.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[R,B]=l.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[D,Z]=l.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[z,X]=l.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),q=l.useRef(null),re=l.useMemo(()=>{if(!e.diffInfo||!w||!R)return[];const $={};return[zn.compute(["doc"],N=>{const ne=da(N)?.chunks||[];return Object.keys($).forEach(ke=>delete $[ke]),ne.forEach(ke=>{const ge=N.doc.lineAt(ke.fromB).number,P=N.doc.lineAt(Math.min(ke.toB,N.doc.length)).number;for(let ie=ge;ie<=P;ie++)$[ie]=S?"rgba(34, 197, 94, 0.8)":"rgba(34, 197, 94, 1)"}),{create:()=>({dom:document.createElement("div")}),displayText:"blocks",showOverlay:"always",gutters:[$]}})]},[e.diffInfo,w,R,S]),Se=l.useMemo(()=>!e.diffInfo||!w?[]:[Ys.fromClass(class{constructor($){setTimeout(()=>{const O=da($.state)?.chunks||[];if(O.length>0){const ne=O[0];$.dispatch({effects:ur.scrollIntoView(ne.fromB,{y:"center"})})}},100)}update(){}destroy(){}})],[e.diffInfo,w]),Ce=l.useMemo(()=>{const $=N=>{const O=document.createElement("div");O.className="cm-editor-toolbar-panel";let ne=0;const ke=()=>{const ge=e.diffInfo&&w,ie=(ge?da(N.state):null)?.chunks||[],ee=ie.length;let Ne='<div style="display: flex; align-items: center; justify-content: space-between; width: 100%;">';if(Ne+='<div style="display: flex; align-items: center; gap: 8px;">',ge&&(Ne+=`
|
|
320
|
-
<span style="font-weight: 500;">${ee>0?`${ne+1}/${ee}`:"0"} ${i("toolbar.changes")}</span>
|
|
321
|
-
<button class="cm-diff-nav-btn cm-diff-nav-prev" title="${i("toolbar.previousChange")}" ${ee===0?"disabled":""}>
|
|
322
|
-
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
323
|
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 15l7-7 7 7" />
|
|
324
|
-
</svg>
|
|
325
|
-
</button>
|
|
326
|
-
<button class="cm-diff-nav-btn cm-diff-nav-next" title="${i("toolbar.nextChange")}" ${ee===0?"disabled":""}>
|
|
327
|
-
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
328
|
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
|
|
329
|
-
</svg>
|
|
330
|
-
</button>
|
|
331
|
-
`),Ne+="</div>",Ne+='<div style="display: flex; align-items: center; gap: 4px;">',e.diffInfo&&(Ne+=`
|
|
332
|
-
<button class="cm-toolbar-btn cm-toggle-diff-btn" title="${i(w?"toolbar.hideDiff":"toolbar.showDiff")}">
|
|
333
|
-
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
334
|
-
${w?'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21" />':'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" /><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />'}
|
|
335
|
-
</svg>
|
|
336
|
-
</button>
|
|
337
|
-
`),Ne+=`
|
|
338
|
-
<button class="cm-toolbar-btn cm-settings-btn" title="${i("toolbar.settings")}">
|
|
339
|
-
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
340
|
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" /><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
|
341
|
-
</svg>
|
|
342
|
-
</button>
|
|
343
|
-
`,s&&a&&(Ne+=`
|
|
344
|
-
<button class="cm-toolbar-btn cm-expand-btn" title="${i(o?"toolbar.collapse":"toolbar.expand")}">
|
|
345
|
-
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
346
|
-
${o?'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 9V4.5M9 9H4.5M9 9L3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5l5.25 5.25" />':'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4" />'}
|
|
347
|
-
</svg>
|
|
348
|
-
</button>
|
|
349
|
-
`),Ne+="</div>",Ne+="</div>",O.innerHTML=Ne,ge){const Ke=O.querySelector(".cm-diff-nav-prev"),Ge=O.querySelector(".cm-diff-nav-next");Ke?.addEventListener("click",()=>{if(ie.length===0)return;ne=ne>0?ne-1:ie.length-1;const qe=ie[ne];qe&&N.dispatch({effects:ur.scrollIntoView(qe.fromB,{y:"center"})}),ke()}),Ge?.addEventListener("click",()=>{if(ie.length===0)return;ne=ne<ie.length-1?ne+1:0;const qe=ie[ne];qe&&N.dispatch({effects:ur.scrollIntoView(qe.fromB,{y:"center"})}),ke()})}e.diffInfo&&O.querySelector(".cm-toggle-diff-btn")?.addEventListener("click",()=>{M(!w)}),O.querySelector(".cm-settings-btn")?.addEventListener("click",()=>{window.openSettings&&window.openSettings("appearance")}),s&&a&&O.querySelector(".cm-expand-btn")?.addEventListener("click",()=>{a()})};return ke(),{top:!0,dom:O,update:ke}};return[Qp.of($)]},[e.diffInfo,w,s,o,a]),ye=$=>{const N=$.split(".").pop()?.toLowerCase();switch(N){case"js":case"jsx":case"ts":case"tsx":return[am({jsx:!0,typescript:N.includes("ts")})];case"py":return[om()];case"html":case"htm":return[sm()];case"css":case"scss":case"less":return[nm()];case"json":return[rm()];case"md":case"markdown":return[tm()];default:return[]}};l.useEffect(()=>{(async()=>{try{if(p(!0),e.diffInfo&&e.diffInfo.new_string!==void 0&&e.diffInfo.old_string!==void 0){d(e.diffInfo.new_string),p(!1);return}const N=await mt.readFile(e.projectName,e.path);if(!N.ok)throw new Error(`Failed to load file: ${N.status} ${N.statusText}`);const O=await N.json();d(O.content)}catch(N){console.error("Error loading file:",N),d(`// Error loading file: ${N.message}
|
|
350
|
-
// File: ${e.name}
|
|
351
|
-
// Path: ${e.path}`)}finally{p(!1)}})()},[e,n]);const de=async()=>{h(!0);try{console.log("Saving file:",{projectName:e.projectName,path:e.path,contentLength:c?.length});const $=await mt.saveFile(e.projectName,e.path,c);if(console.log("Save response:",{status:$.status,ok:$.ok,contentType:$.headers.get("content-type")}),!$.ok){const O=$.headers.get("content-type");if(O&&O.includes("application/json")){const ne=await $.json();throw new Error(ne.error||`Save failed: ${$.status}`)}else{const ne=await $.text();throw console.error("Non-JSON error response:",ne),new Error(`Save failed: ${$.status} ${$.statusText}`)}}const N=await $.json();console.log("Save successful:",N),A(!0),setTimeout(()=>A(!1),2e3)}catch($){console.error("Error saving file:",$),alert(`Error saving file: ${$.message}`)}finally{h(!1)}},H=()=>{const $=new Blob([c],{type:"text/plain"}),N=URL.createObjectURL($),O=document.createElement("a");O.href=N,O.download=e.name,document.body.appendChild(O),O.click(),document.body.removeChild(O),URL.revokeObjectURL(N)},Oe=()=>{x(!g)};return l.useEffect(()=>{localStorage.setItem("codeEditorTheme",S?"dark":"light")},[S]),l.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",C.toString())},[C]),l.useEffect(()=>{const $=()=>{const N=localStorage.getItem("codeEditorTheme");N&&k(N==="dark");const O=localStorage.getItem("codeEditorWordWrap");O!==null&&b(O==="true");const ne=localStorage.getItem("codeEditorShowMinimap");ne!==null&&B(ne!=="false");const ke=localStorage.getItem("codeEditorLineNumbers");ke!==null&&Z(ke!=="false");const ge=localStorage.getItem("codeEditorFontSize");ge&&X(ge)};return window.addEventListener("storage",$),window.addEventListener("codeEditorSettingsChanged",$),()=>{window.removeEventListener("storage",$),window.removeEventListener("codeEditorSettingsChanged",$)}},[]),l.useEffect(()=>{const $=N=>{(N.ctrlKey||N.metaKey)&&(N.key==="s"?(N.preventDefault(),de()):N.key==="Escape"&&(N.preventDefault(),t()))};return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[c]),u?r.jsxs(r.Fragment,{children:[r.jsx("style",{children:`
|
|
352
|
-
.code-editor-loading {
|
|
353
|
-
background-color: ${S?"#111827":"#ffffff"} !important;
|
|
354
|
-
}
|
|
355
|
-
.code-editor-loading:hover {
|
|
356
|
-
background-color: ${S?"#111827":"#ffffff"} !important;
|
|
357
|
-
}
|
|
358
|
-
`}),s?r.jsx("div",{className:"w-full h-full flex items-center justify-center bg-background",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-primary"}),r.jsx("span",{className:"text-gray-900 dark:text-white",children:i("loading",{fileName:e.name})})]})}):r.jsx("div",{className:"fixed inset-0 z-40 md:bg-black/50 md:flex md:items-center md:justify-center",children:r.jsx("div",{className:"code-editor-loading w-full h-full md:rounded-lg md:w-auto md:h-auto p-8 flex items-center justify-center",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-primary"}),r.jsx("span",{className:"text-gray-900 dark:text-white",children:i("loading",{fileName:e.name})})]})})})]}):r.jsxs(r.Fragment,{children:[r.jsx("style",{children:`
|
|
359
|
-
/* Light background for full line changes */
|
|
360
|
-
.cm-deletedChunk {
|
|
361
|
-
background-color: ${S?"rgba(239, 68, 68, 0.15)":"rgba(255, 235, 235, 1)"} !important;
|
|
362
|
-
border-left: 3px solid ${S?"rgba(239, 68, 68, 0.6)":"rgb(239, 68, 68)"} !important;
|
|
363
|
-
padding-left: 4px !important;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
.cm-insertedChunk {
|
|
367
|
-
background-color: ${S?"rgba(34, 197, 94, 0.15)":"rgba(230, 255, 237, 1)"} !important;
|
|
368
|
-
border-left: 3px solid ${S?"rgba(34, 197, 94, 0.6)":"rgb(34, 197, 94)"} !important;
|
|
369
|
-
padding-left: 4px !important;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
/* Override linear-gradient underline and use solid darker background for partial changes */
|
|
373
|
-
.cm-editor.cm-merge-b .cm-changedText {
|
|
374
|
-
background: ${S?"rgba(34, 197, 94, 0.4)":"rgba(34, 197, 94, 0.3)"} !important;
|
|
375
|
-
padding-top: 2px !important;
|
|
376
|
-
padding-bottom: 2px !important;
|
|
377
|
-
margin-top: -2px !important;
|
|
378
|
-
margin-bottom: -2px !important;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
.cm-editor .cm-deletedChunk .cm-changedText {
|
|
382
|
-
background: ${S?"rgba(239, 68, 68, 0.4)":"rgba(239, 68, 68, 0.3)"} !important;
|
|
383
|
-
padding-top: 2px !important;
|
|
384
|
-
padding-bottom: 2px !important;
|
|
385
|
-
margin-top: -2px !important;
|
|
386
|
-
margin-bottom: -2px !important;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
/* Minimap gutter styling */
|
|
390
|
-
.cm-gutter.cm-gutter-minimap {
|
|
391
|
-
background-color: ${S?"#1e1e1e":"#f5f5f5"};
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
/* Editor toolbar panel styling */
|
|
395
|
-
.cm-editor-toolbar-panel {
|
|
396
|
-
padding: 8px 12px;
|
|
397
|
-
background-color: ${S?"#1f2937":"#ffffff"};
|
|
398
|
-
border-bottom: 1px solid ${S?"#374151":"#e5e7eb"};
|
|
399
|
-
color: ${S?"#d1d5db":"#374151"};
|
|
400
|
-
font-size: 14px;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
.cm-diff-nav-btn,
|
|
404
|
-
.cm-toolbar-btn {
|
|
405
|
-
padding: 4px;
|
|
406
|
-
background: transparent;
|
|
407
|
-
border: none;
|
|
408
|
-
cursor: pointer;
|
|
409
|
-
border-radius: 4px;
|
|
410
|
-
display: inline-flex;
|
|
411
|
-
align-items: center;
|
|
412
|
-
justify-content: center;
|
|
413
|
-
color: inherit;
|
|
414
|
-
transition: background-color 0.2s;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
.cm-diff-nav-btn:hover,
|
|
418
|
-
.cm-toolbar-btn:hover {
|
|
419
|
-
background-color: ${S?"#374151":"#f3f4f6"};
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
.cm-diff-nav-btn:disabled {
|
|
423
|
-
opacity: 0.5;
|
|
424
|
-
cursor: not-allowed;
|
|
425
|
-
}
|
|
426
|
-
`}),r.jsx("div",{className:s?"w-full h-full flex flex-col":`fixed inset-0 z-40 md:bg-black/50 md:flex md:items-center md:justify-center md:p-4 ${g?"md:p-0":""}`,children:r.jsxs("div",{className:s?"bg-background flex flex-col w-full h-full":`bg-background shadow-2xl flex flex-col ${"w-full h-full md:rounded-lg md:shadow-2xl"+(g?" md:w-full md:h-full md:rounded-none":" md:w-full md:max-w-6xl md:h-[80vh] md:max-h-[80vh]")}`,children:[r.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border flex-shrink-0 min-w-0",children:[r.jsx("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx("h3",{className:"font-medium text-gray-900 dark:text-white truncate",children:e.name}),e.diffInfo&&r.jsx("span",{className:"text-xs bg-primary/15 dark:bg-primary/30 text-primary dark:text-primary/80 px-2 py-1 rounded whitespace-nowrap",children:i("header.showingChanges")})]}),r.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 truncate",children:e.path})]})}),r.jsxs("div",{className:"flex items-center gap-1 md:gap-2 flex-shrink-0",children:[r.jsx("button",{onClick:H,className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:i("actions.download"),children:r.jsx(ha,{className:"w-5 h-5 md:w-4 md:h-4"})}),r.jsx("button",{onClick:de,disabled:m,className:`px-3 py-2 text-white rounded-md disabled:opacity-50 flex items-center gap-2 transition-colors min-h-[44px] md:min-h-0 ${I?"bg-green-600 hover:bg-green-700":"bg-primary hover:bg-primary/90"}`,children:I?r.jsxs(r.Fragment,{children:[r.jsx("svg",{className:"w-5 h-5 md:w-4 md:h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),r.jsx("span",{className:"hidden sm:inline",children:i("actions.saved")})]}):r.jsxs(r.Fragment,{children:[r.jsx(Bf,{className:"w-5 h-5 md:w-4 md:h-4"}),r.jsx("span",{className:"hidden sm:inline",children:i(m?"actions.saving":"actions.save")})]})}),!s&&r.jsx("button",{onClick:Oe,className:"hidden md:flex p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 items-center justify-center",title:i(g?"actions.exitFullscreen":"actions.fullscreen"),children:g?r.jsx(Df,{className:"w-4 h-4"}):r.jsx(Lc,{className:"w-4 h-4"})}),r.jsx("button",{onClick:t,className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:i("actions.close"),children:r.jsx(sr,{className:"w-6 h-6 md:w-4 md:h-4"})})]})]}),r.jsx("div",{className:"flex-1 overflow-hidden",children:r.jsx(Zp,{ref:q,value:c,onChange:d,extensions:[...ye(e.name),...Ce,...e.diffInfo&&w&&e.diffInfo.old_string!==void 0?[ob({original:e.diffInfo.old_string,mergeControls:!1,highlightChanges:!0,syntaxHighlightDeletions:!1,gutter:!0}),...re,...Se]:[],...C?[ur.lineWrapping]:[]],theme:S?em:void 0,height:"100%",style:{fontSize:`${z}px`,height:"100%"},basicSetup:{lineNumbers:D,foldGutter:!0,dropCursor:!1,allowMultipleSelections:!1,indentOnInput:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!0,highlightSelectionMatches:!0,searchKeymap:!0}})}),r.jsxs("div",{className:"flex items-center justify-between p-3 border-t border-border bg-muted flex-shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-600 dark:text-gray-400",children:[r.jsxs("span",{children:[i("footer.lines")," ",c.split(`
|
|
427
|
-
`).length]}),r.jsxs("span",{children:[i("footer.characters")," ",c.length]})]}),r.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:i("footer.shortcuts")})]})]})})]})}var Eb=qm(),Ib=Vm(),Ab=Km(),ua={exports:{}},vc;function Tb(){return vc||(vc=1,function(e,t){(function(n,s){e.exports=s()})(self,()=>(()=>{var n={6:(i,c)=>{function d(p){try{const m=new URL(p),h=m.password&&m.username?`${m.protocol}//${m.username}:${m.password}@${m.host}`:m.username?`${m.protocol}//${m.username}@${m.host}`:`${m.protocol}//${m.host}`;return p.toLocaleLowerCase().startsWith(h.toLocaleLowerCase())}catch{return!1}}Object.defineProperty(c,"__esModule",{value:!0}),c.LinkComputer=c.WebLinkProvider=void 0,c.WebLinkProvider=class{constructor(p,m,h,g={}){this._terminal=p,this._regex=m,this._handler=h,this._options=g}provideLinks(p,m){const h=u.computeLink(p,this._regex,this._terminal,this._handler);m(this._addCallbacks(h))}_addCallbacks(p){return p.map(m=>(m.leave=this._options.leave,m.hover=(h,g)=>{if(this._options.hover){const{range:x}=m;this._options.hover(h,g,x)}},m))}};class u{static computeLink(m,h,g,x){const S=new RegExp(h.source,(h.flags||"")+"g"),[k,I]=u._getWindowedLineStrings(m-1,g),A=k.join("");let w;const M=[];for(;w=S.exec(A);){const C=w[0];if(!d(C))continue;const[b,R]=u._mapStrIdx(g,I,0,w.index),[B,D]=u._mapStrIdx(g,b,R,C.length);if(b===-1||R===-1||B===-1||D===-1)continue;const Z={start:{x:R+1,y:b+1},end:{x:D,y:B+1}};M.push({range:Z,text:C,activate:x})}return M}static _getWindowedLineStrings(m,h){let g,x=m,S=m,k=0,I="";const A=[];if(g=h.buffer.active.getLine(m)){const w=g.translateToString(!0);if(g.isWrapped&&w[0]!==" "){for(k=0;(g=h.buffer.active.getLine(--x))&&k<2048&&(I=g.translateToString(!0),k+=I.length,A.push(I),g.isWrapped&&I.indexOf(" ")===-1););A.reverse()}for(A.push(w),k=0;(g=h.buffer.active.getLine(++S))&&g.isWrapped&&k<2048&&(I=g.translateToString(!0),k+=I.length,A.push(I),I.indexOf(" ")===-1););}return[A,x]}static _mapStrIdx(m,h,g,x){const S=m.buffer.active,k=S.getNullCell();let I=g;for(;x;){const A=S.getLine(h);if(!A)return[-1,-1];for(let w=I;w<A.length;++w){A.getCell(w,k);const M=k.getChars();if(k.getWidth()&&(x-=M.length||1,w===A.length-1&&M==="")){const C=S.getLine(h+1);C&&C.isWrapped&&(C.getCell(0,k),k.getWidth()===2&&(x+=1))}if(x<0)return[h,w]}h++,I=0}return[h,I]}}c.LinkComputer=u}},s={};function o(i){var c=s[i];if(c!==void 0)return c.exports;var d=s[i]={exports:{}};return n[i](d,d.exports,o),d.exports}var a={};return(()=>{var i=a;Object.defineProperty(i,"__esModule",{value:!0}),i.WebLinksAddon=void 0;const c=o(6),d=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function u(p,m){const h=window.open();if(h){try{h.opener=null}catch{}h.location.href=m}else console.warn("Opening link blocked as opener could not be cleared")}i.WebLinksAddon=class{constructor(p=u,m={}){this._handler=p,this._options=m}activate(p){this._terminal=p;const m=this._options,h=m.urlRegex||d;this._linkProvider=this._terminal.registerLinkProvider(new c.WebLinkProvider(this._terminal,h,this._handler,m))}dispose(){this._linkProvider?.dispose()}}})(),a})())}(ua)),ua.exports}var _b=Tb();const Mb=`
|
|
428
|
-
.xterm .xterm-screen {
|
|
429
|
-
outline: none !important;
|
|
430
|
-
}
|
|
431
|
-
.xterm:focus .xterm-screen {
|
|
432
|
-
outline: none !important;
|
|
433
|
-
}
|
|
434
|
-
.xterm-screen:focus {
|
|
435
|
-
outline: none !important;
|
|
436
|
-
}
|
|
437
|
-
`;if(typeof document<"u"){const e=document.createElement("style");e.type="text/css",e.innerText=Mb,document.head.appendChild(e)}function Db({selectedProject:e,selectedSession:t,initialCommand:n,isPlainShell:s=!1,onProcessComplete:o,minimal:a=!1,autoConnect:i=!1}){const{t:c}=Mt("chat"),d=l.useRef(null),u=l.useRef(null),p=l.useRef(null),m=l.useRef(null),[h,g]=l.useState(!1),[x,S]=l.useState(!1),[k,I]=l.useState(!1),[A,w]=l.useState(null),[M,C]=l.useState(!1),b=l.useRef(e),R=l.useRef(t),B=l.useRef(n),D=l.useRef(s),Z=l.useRef(o);l.useEffect(()=>{b.current=e,R.current=t,B.current=n,D.current=s,Z.current=o});const z=l.useCallback(async()=>{if(!(M||h))try{let de;if(!Ox){const H=localStorage.getItem("auth-token");if(!H){console.error("No authentication token found for Shell WebSocket connection");return}de=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/shell?token=${encodeURIComponent(H)}`}m.current=new WebSocket(de),m.current.onopen=()=>{g(!0),C(!1),setTimeout(()=>{p.current&&u.current&&(p.current.fit(),m.current.send(JSON.stringify({type:"init",projectPath:b.current.fullPath||b.current.path,sessionId:D.current?null:R.current?.id,hasSession:D.current?!1:!!R.current,provider:D.current?"plain-shell":R.current?.__provider||"claude",cols:u.current.cols,rows:u.current.rows,initialCommand:B.current,isPlainShell:D.current})))},100)},m.current.onmessage=H=>{try{const Oe=JSON.parse(H.data);if(Oe.type==="output"){let $=Oe.data;if(D.current&&Z.current){const N=$.replace(/\x1b\[[0-9;]*m/g,"");if(N.includes("Process exited with code 0"))Z.current(0);else if(N.match(/Process exited with code (\d+)/)){const O=parseInt(N.match(/Process exited with code (\d+)/)[1]);O!==0&&Z.current(O)}}u.current&&u.current.write($)}else Oe.type==="url_open"&&window.open(Oe.url,"_blank")}catch(Oe){console.error("[Shell] Error handling WebSocket message:",Oe,H.data)}},m.current.onclose=H=>{g(!1),C(!1),u.current&&(u.current.clear(),u.current.write("\x1B[2J\x1B[H"))},m.current.onerror=H=>{g(!1),C(!1)}}catch{g(!1),C(!1)}},[M,h]),X=l.useCallback(()=>{!x||h||M||(C(!0),z())},[x,h,M,z]),q=l.useCallback(()=>{m.current&&(m.current.close(),m.current=null),u.current&&(u.current.clear(),u.current.write("\x1B[2J\x1B[H")),g(!1),C(!1)},[]),re=l.useMemo(()=>t?t.summary||t.name||"New Session":null,[t]),Se=l.useMemo(()=>re?re.slice(0,30):null,[re]),Ce=l.useMemo(()=>re?re.slice(0,50):null,[re]),ye=()=>{I(!0),m.current&&(m.current.close(),m.current=null),u.current&&(u.current.dispose(),u.current=null,p.current=null),g(!1),S(!1),setTimeout(()=>{I(!1)},200)};return l.useEffect(()=>{const de=t?.id||null;A!==null&&A!==de&&x&&q(),w(de)},[t?.id,x,q]),l.useEffect(()=>{if(!d.current||!e||k||u.current)return;u.current=new Eb.Terminal({cursorBlink:!0,fontSize:14,fontFamily:'Menlo, Monaco, "Courier New", monospace',allowProposedApi:!0,allowTransparency:!1,convertEol:!0,scrollback:1e4,tabStopWidth:4,windowsMode:!1,macOptionIsMeta:!0,macOptionClickForcesSelection:!0,theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#ffffff",cursorAccent:"#1e1e1e",selection:"#264f78",selectionForeground:"#ffffff",black:"#000000",red:"#cd3131",green:"#0dbc79",yellow:"#e5e510",blue:"#2472c8",magenta:"#bc3fbc",cyan:"#11a8cd",white:"#e5e5e5",brightBlack:"#666666",brightRed:"#f14c4c",brightGreen:"#23d18b",brightYellow:"#f5f543",brightBlue:"#3b8eea",brightMagenta:"#d670d6",brightCyan:"#29b8db",brightWhite:"#ffffff",extendedAnsi:["#000000","#800000","#008000","#808000","#000080","#800080","#008080","#c0c0c0","#808080","#ff0000","#00ff00","#ffff00","#0000ff","#ff00ff","#00ffff","#ffffff"]}}),p.current=new Ib.FitAddon;const de=new Ab.WebglAddon,H=new _b.WebLinksAddon;u.current.loadAddon(p.current),u.current.loadAddon(H);try{u.current.loadAddon(de)}catch{console.warn("[Shell] WebGL renderer unavailable, using Canvas fallback")}u.current.open(d.current),u.current.attachCustomKeyEventHandler($=>($.ctrlKey||$.metaKey)&&$.key==="c"&&u.current.hasSelection()?(document.execCommand("copy"),!1):($.ctrlKey||$.metaKey)&&$.key==="v"?(navigator.clipboard.readText().then(N=>{m.current&&m.current.readyState===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"input",data:N}))}).catch(()=>{}),!1):!0),setTimeout(()=>{p.current&&(p.current.fit(),u.current&&m.current&&m.current.readyState===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"resize",cols:u.current.cols,rows:u.current.rows})))},100),S(!0),u.current.onData($=>{m.current&&m.current.readyState===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"input",data:$}))});const Oe=new ResizeObserver(()=>{p.current&&u.current&&setTimeout(()=>{p.current.fit(),m.current&&m.current.readyState===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"resize",cols:u.current.cols,rows:u.current.rows}))},50)});return d.current&&Oe.observe(d.current),()=>{Oe.disconnect(),m.current&&(m.current.readyState===WebSocket.OPEN||m.current.readyState===WebSocket.CONNECTING)&&m.current.close(),m.current=null,u.current&&(u.current.dispose(),u.current=null)}},[e?.path||e?.fullPath,k]),l.useEffect(()=>{!i||!x||M||h||X()},[i,x,M,h,X]),e?a?r.jsx("div",{className:"h-full w-full bg-gray-900",children:r.jsx("div",{ref:d,className:"h-full w-full focus:outline-none",style:{outline:"none"}})}):r.jsxs("div",{className:"h-full flex flex-col bg-gray-900 w-full",children:[r.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx("div",{className:`w-2 h-2 rounded-full ${h?"bg-green-500":"bg-red-500"}`}),t&&r.jsxs("span",{className:"text-xs text-primary/80",children:["(",Se,"...)"]}),!t&&r.jsx("span",{className:"text-xs text-gray-400",children:c("shell.status.newSession")}),!x&&r.jsx("span",{className:"text-xs text-yellow-400",children:c("shell.status.initializing")}),k&&r.jsx("span",{className:"text-xs text-primary",children:c("shell.status.restarting")})]}),r.jsxs("div",{className:"flex items-center space-x-3",children:[h&&r.jsxs("button",{onClick:q,className:"px-3 py-1 text-xs bg-red-600 text-white rounded hover:bg-red-700 flex items-center space-x-1",title:c("shell.actions.disconnectTitle"),children:[r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),r.jsx("span",{children:c("shell.actions.disconnect")})]}),r.jsxs("button",{onClick:ye,disabled:k||h,className:"text-xs text-gray-400 hover:text-white disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-1",title:c("shell.actions.restartTitle"),children:[r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),r.jsx("span",{children:c("shell.actions.restart")})]})]})]})}),r.jsxs("div",{className:"flex-1 p-2 overflow-hidden relative",children:[r.jsx("div",{ref:d,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),!x&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90",children:r.jsx("div",{className:"text-white",children:c("shell.loading")})}),x&&!h&&!M&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:r.jsxs("div",{className:"text-center max-w-sm w-full",children:[r.jsxs("button",{onClick:X,className:"px-6 py-3 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors flex items-center justify-center space-x-2 text-base font-medium w-full sm:w-auto",title:c("shell.actions.connectTitle"),children:[r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),r.jsx("span",{children:c("shell.actions.connect")})]}),r.jsx("p",{className:"text-gray-400 text-sm mt-3 px-2",children:s?c("shell.runCommand",{command:n||c("shell.defaultCommand"),projectName:e.displayName}):t?c("shell.resumeSession",{displayName:Ce}):c("shell.startSession")})]})}),M&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:r.jsxs("div",{className:"text-center max-w-sm w-full",children:[r.jsxs("div",{className:"flex items-center justify-center space-x-3 text-yellow-400",children:[r.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-yellow-400 border-t-transparent"}),r.jsx("span",{className:"text-base font-medium",children:c("shell.connecting")})]}),r.jsx("p",{className:"text-gray-400 text-sm mt-3 px-2",children:s?c("shell.runCommand",{command:n||c("shell.defaultCommand"),projectName:e.displayName}):c("shell.startCli",{projectName:e.displayName})})]})})]})]}):r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[r.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:r.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2z"})})}),r.jsx("h3",{className:"text-lg font-semibold mb-2",children:c("shell.selectProject.title")}),r.jsx("p",{children:c("shell.selectProject.description")})]})})}function Ju({project:e,session:t=null,command:n=null,isPlainShell:s=null,autoConnect:o=!0,onComplete:a=null,onClose:i=null,title:c=null,className:d="",showHeader:u=!0,compact:p=!1,minimal:m=!1}){const[h,g]=l.useState(!1),x=s!==null?s:n!==null,S=l.useCallback(k=>{g(!0),a&&a(k)},[a]);return e?r.jsxs("div",{className:`h-full w-full flex flex-col ${d}`,children:[!m&&u&&c&&r.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-200",children:c}),h&&r.jsx("span",{className:"text-xs text-green-400",children:"(Completed)"})]}),i&&r.jsx("button",{onClick:i,className:"text-gray-400 hover:text-white",title:"Close",children:r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),r.jsx("div",{className:"flex-1 w-full min-h-0",children:r.jsx(Db,{selectedProject:e,selectedSession:t,initialCommand:n,isPlainShell:x,onProcessComplete:S,minimal:m,autoConnect:m?!0:o})})]}):r.jsx("div",{className:`h-full flex items-center justify-center ${d}`,children:r.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[r.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:r.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 002 2z"})})}),r.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Project Selected"}),r.jsx("p",{children:"A project is required to open a shell"})]})})}async function Rb(e,t){const n=new FormData,s=`recording_${Date.now()}.webm`,o=new File([e],s,{type:e.type});n.append("audio",o);const a=window.localStorage.getItem("whisperMode")||"default";n.append("mode",a);try{const i=await mt.transcribe(n);if(!i.ok){const d=await i.json().catch(()=>({}));throw new Error(d.error||`Transcription error: ${i.status} ${i.statusText}`)}return(await i.json()).text||""}catch(i){throw i.name==="TypeError"&&i.message.includes("fetch")?new Error("Cannot connect to server. Please ensure the backend is running."):i}}function Pb({onTranscript:e,className:t=""}){const[n,s]=l.useState("idle"),[o,a]=l.useState(null),[i,c]=l.useState(!0),d=l.useRef(null),u=l.useRef(null),p=l.useRef([]),m=l.useRef(0);l.useEffect(()=>{(()=>{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia){c(!1),a("Microphone not supported. Please use HTTPS or a modern browser.");return}if(location.protocol!=="https:"&&location.hostname!=="localhost"){c(!1),a("Microphone requires HTTPS. Please use a secure connection.");return}c(!0),a(null)})()},[]);const h=async()=>{try{if(console.log("Starting recording..."),a(null),p.current=[],!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new Error("Microphone access not available. Please use HTTPS or a supported browser.");const w=await navigator.mediaDevices.getUserMedia({audio:!0});u.current=w;const M=MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4",C=new MediaRecorder(w,{mimeType:M});d.current=C,C.ondataavailable=b=>{b.data.size>0&&p.current.push(b.data)},C.onstop=async()=>{console.log("Recording stopped, creating blob...");const b=new Blob(p.current,{type:M});u.current&&(u.current.getTracks().forEach(Z=>Z.stop()),u.current=null),s("transcribing");const R=window.localStorage.getItem("whisperMode")||"default",B=R==="prompt"||R==="vibe"||R==="instructions"||R==="architect";let D;B&&(D=setTimeout(()=>{s("processing")},2e3));try{const Z=await Rb(b);Z&&e&&e(Z)}catch(Z){console.error("Transcription error:",Z),a(Z.message)}finally{D&&clearTimeout(D),s("idle")}},C.start(),s("recording"),console.log("Recording started successfully")}catch(w){console.error("Failed to start recording:",w);let M="Microphone access failed";w.name==="NotAllowedError"?M="Microphone access denied. Please allow microphone permissions.":w.name==="NotFoundError"?M="No microphone found. Please check your audio devices.":w.name==="NotSupportedError"?M="Microphone not supported by this browser.":w.name==="NotReadableError"?M="Microphone is being used by another application.":w.message.includes("HTTPS")&&(M=w.message),a(M),s("idle")}},g=()=>{console.log("Stopping recording..."),d.current&&d.current.state==="recording"?d.current.stop():(console.log("Recorder not in recording state, forcing cleanup"),u.current&&(u.current.getTracks().forEach(w=>w.stop()),u.current=null),s("idle"))},x=w=>{if(w&&(w.preventDefault(),w.stopPropagation()),!i)return;const M=Date.now();if(M-m.current<300){console.log("Ignoring rapid tap");return}m.current=M,console.log("Button clicked, current state:",n),n==="idle"?h():n==="recording"&&g()};l.useEffect(()=>()=>{u.current&&u.current.getTracks().forEach(w=>w.stop())},[]);const S=()=>{if(!i)return{icon:r.jsx(Ps,{className:"w-5 h-5"}),className:"bg-gray-400 cursor-not-allowed",disabled:!0};switch(n){case"recording":return{icon:r.jsx(Ps,{className:"w-5 h-5 text-white"}),className:"bg-red-500 hover:bg-red-600 animate-pulse",disabled:!1};case"transcribing":return{icon:r.jsx(Un,{className:"w-5 h-5 animate-spin"}),className:"bg-primary hover:bg-primary/90",disabled:!0};case"processing":return{icon:r.jsx(_c,{className:"w-5 h-5 animate-pulse"}),className:"bg-purple-500 hover:bg-purple-600",disabled:!0};default:return{icon:r.jsx(Ps,{className:"w-5 h-5"}),className:"bg-gray-700 hover:bg-gray-600",disabled:!1}}},{icon:k,className:I,disabled:A}=S();return r.jsxs("div",{className:"relative",children:[r.jsx("button",{type:"button",style:{backgroundColor:n==="recording"?"#ef4444":n==="transcribing"?"#3b82f6":n==="processing"?"#a855f7":"#374151"},className:`
|
|
438
|
-
flex items-center justify-center
|
|
439
|
-
w-12 h-12 rounded-full
|
|
440
|
-
text-white transition-all duration-200
|
|
441
|
-
focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-ring
|
|
442
|
-
dark:ring-offset-gray-800
|
|
443
|
-
touch-action-manipulation
|
|
444
|
-
${A?"cursor-not-allowed opacity-75":"cursor-pointer"}
|
|
445
|
-
${n==="recording"?"animate-pulse":""}
|
|
446
|
-
hover:opacity-90
|
|
447
|
-
${t}
|
|
448
|
-
`,onClick:x,disabled:A,children:k}),o&&r.jsx("div",{className:`absolute top-full mt-2 left-1/2 transform -translate-x-1/2
|
|
449
|
-
bg-red-500 text-white text-xs px-2 py-1 rounded whitespace-nowrap z-10
|
|
450
|
-
animate-fade-in`,children:o}),n==="recording"&&r.jsx("div",{className:"absolute -inset-1 rounded-full border-2 border-red-500 animate-ping pointer-events-none"}),n==="processing"&&r.jsx("div",{className:"absolute -inset-1 rounded-full border-2 border-purple-500 animate-ping pointer-events-none"})]})}function yc({diff:e,fileName:t,isMobile:n,wrapText:s}){if(!e)return r.jsx("div",{className:"p-4 text-center text-gray-500 dark:text-gray-400 text-sm",children:"No diff available"});const o=(a,i)=>{const c=a.startsWith("+")&&!a.startsWith("+++"),d=a.startsWith("-")&&!a.startsWith("---"),u=a.startsWith("@@");return r.jsx("div",{className:`font-mono text-xs p-2 ${n&&s?"whitespace-pre-wrap break-all":"whitespace-pre overflow-x-auto"} ${c?"bg-green-50 dark:bg-green-950 text-green-700 dark:text-green-300":d?"bg-red-50 dark:bg-red-950 text-red-700 dark:text-red-300":u?"bg-primary/10 dark:bg-primary/20 text-primary":"text-gray-600 dark:text-gray-400"}`,children:a},i)};return r.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-background/95 shadow-sm",children:[t&&r.jsx("div",{className:"border-b border-border/70 px-3 py-2 text-xs font-medium text-muted-foreground",children:t}),e.split(`
|
|
451
|
-
`).map((a,i)=>o(a,i))]})}function Lb({selectedProject:e,isMobile:t,onFileOpen:n}){const[s,o]=l.useState(null),[a,i]=l.useState({}),[c,d]=l.useState(!1),[u,p]=l.useState(""),[m,h]=l.useState(new Set),[g,x]=l.useState(new Set),[S,k]=l.useState(!1),[I,A]=l.useState(""),[w,M]=l.useState([]),[C,b]=l.useState(!0),[R,B]=l.useState(!1),[D,Z]=l.useState(!1),[z,X]=l.useState(!1),[q,re]=l.useState(""),[Se,Ce]=l.useState(!1),[ye,de]=l.useState("changes"),[H,Oe]=l.useState([]),[$,N]=l.useState(new Set),[O,ne]=l.useState({}),[ke,ge]=l.useState(!1),[P,ie]=l.useState(null),[ee,Ne]=l.useState(!1),[it,Ke]=l.useState(!1),[Ge,qe]=l.useState(!1),[lt,It]=l.useState(!1),[Xe,kt]=l.useState(t),[je,Ve]=l.useState(null),[jt,St]=l.useState(!1),Dt=l.useRef(null),Y=l.useRef(null),[oe,Ee]=l.useState(()=>localStorage.getItem("selected-provider")||"claude");l.useEffect(()=>{const j=()=>{const F=localStorage.getItem("selected-provider")||"claude";Ee(F)};return window.addEventListener("storage",j),()=>window.removeEventListener("storage",j)},[]),l.useEffect(()=>{e&&(Te(),Fe(),tt(),ye==="history"&&qt())},[e,ye]),l.useEffect(()=>{const j=F=>{Y.current&&!Y.current.contains(F.target)&&Z(!1)};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[]);const Te=async()=>{if(e){d(!0);try{const F=await(await ce(`/api/git/status?project=${encodeURIComponent(e.name)}`)).json();if(F.error)console.error("Git status error:",F.error),o({error:F.error,details:F.details});else{o(F),A(F.branch||"main");const xe=new Set([...F.modified||[],...F.added||[],...F.deleted||[],...F.untracked||[]]);x(xe);for(const ve of F.modified||[])rt(ve);for(const ve of F.added||[])rt(ve);for(const ve of F.deleted||[])rt(ve);for(const ve of F.untracked||[])rt(ve)}}catch(j){console.error("Error fetching git status:",j)}finally{d(!1)}}},Fe=async()=>{try{const F=await(await ce(`/api/git/branches?project=${encodeURIComponent(e.name)}`)).json();!F.error&&F.branches&&M(F.branches)}catch(j){console.error("Error fetching branches:",j)}},tt=async()=>{if(e)try{const F=await(await ce(`/api/git/remote-status?project=${encodeURIComponent(e.name)}`)).json();F.error?ie(null):ie(F)}catch(j){console.error("Error fetching remote status:",j),ie(null)}},ue=async j=>{try{const xe=await(await ce("/api/git/checkout",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,branch:j})})).json();xe.success?(A(j),Z(!1),Te()):console.error("Failed to switch branch:",xe.error)}catch(F){console.error("Error switching branch:",F)}},dt=async()=>{if(q.trim()){Ce(!0);try{const F=await(await ce("/api/git/create-branch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,branch:q.trim()})})).json();F.success?(A(q.trim()),X(!1),Z(!1),re(""),Fe(),Te()):console.error("Failed to create branch:",F.error)}catch(j){console.error("Error creating branch:",j)}finally{Ce(!1)}}},Ye=async()=>{Ne(!0);try{const F=await(await ce("/api/git/fetch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();F.success?(Te(),tt()):console.error("Fetch failed:",F.error)}catch(j){console.error("Error fetching from remote:",j)}finally{Ne(!1)}},Qe=async()=>{Ke(!0);try{const F=await(await ce("/api/git/pull",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();F.success?(Te(),tt()):console.error("Pull failed:",F.error)}catch(j){console.error("Error pulling from remote:",j)}finally{Ke(!1)}},ze=async()=>{qe(!0);try{const F=await(await ce("/api/git/push",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();F.success?(Te(),tt()):console.error("Push failed:",F.error)}catch(j){console.error("Error pushing to remote:",j)}finally{qe(!1)}},Lt=async()=>{It(!0);try{const F=await(await ce("/api/git/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,branch:I})})).json();F.success?(Te(),tt()):console.error("Publish failed:",F.error)}catch(j){console.error("Error publishing branch:",j)}finally{It(!1)}},Nt=async j=>{try{const xe=await(await ce("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,file:j})})).json();xe.success?(x(ve=>{const ut=new Set(ve);return ut.delete(j),ut}),Te()):console.error("Discard failed:",xe.error)}catch(F){console.error("Error discarding changes:",F)}},xt=async j=>{try{const xe=await(await ce("/api/git/delete-untracked",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,file:j})})).json();xe.success?(x(ve=>{const ut=new Set(ve);return ut.delete(j),ut}),Te()):console.error("Delete failed:",xe.error)}catch(F){console.error("Error deleting untracked file:",F)}},$t=async()=>{if(!je)return;const{type:j,file:F,message:xe}=je;Ve(null);try{switch(j){case"discard":await Nt(F);break;case"delete":await xt(F);break;case"commit":await Rt();break;case"pull":await Qe();break;case"push":await ze();break;case"publish":await Lt();break}}catch(ve){console.error(`Error executing ${j}:`,ve)}},rt=async j=>{try{const xe=await(await ce(`/api/git/diff?project=${encodeURIComponent(e.name)}&file=${encodeURIComponent(j)}`)).json();!xe.error&&xe.diff&&i(ve=>({...ve,[j]:xe.diff}))}catch(F){console.error("Error fetching file diff:",F)}},ft=async j=>{if(n)try{const xe=await(await ce(`/api/git/file-with-diff?project=${encodeURIComponent(e.name)}&file=${encodeURIComponent(j)}`)).json();if(xe.error){console.error("Error fetching file with diff:",xe.error),n(j);return}const ve={old_string:xe.oldContent||"",new_string:xe.currentContent||""};n(j,ve)}catch(F){console.error("Error opening file:",F),n(j)}},qt=async()=>{try{const F=await(await ce(`/api/git/commits?project=${encodeURIComponent(e.name)}&limit=10`)).json();!F.error&&F.commits&&Oe(F.commits)}catch(j){console.error("Error fetching commits:",j)}},At=async j=>{try{const xe=await(await ce(`/api/git/commit-diff?project=${encodeURIComponent(e.name)}&commit=${j}`)).json();!xe.error&&xe.diff&&ne(ve=>({...ve,[j]:xe.diff}))}catch(F){console.error("Error fetching commit diff:",F)}},ht=async()=>{ge(!0);try{const F=await(await ce("/api/git/generate-commit-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,files:Array.from(g),provider:oe})})).json();F.message?p(F.message):console.error("Failed to generate commit message:",F.error)}catch(j){console.error("Error generating commit message:",j)}finally{ge(!1)}},Qt=j=>{h(F=>{const xe=new Set(F);return xe.has(j)?xe.delete(j):xe.add(j),xe})},Vt=j=>{N(F=>{const xe=new Set(F);return xe.has(j)?xe.delete(j):(xe.add(j),O[j]||At(j)),xe})},Zt=j=>{x(F=>{const xe=new Set(F);return xe.has(j)?xe.delete(j):xe.add(j),xe})},Rt=async()=>{if(!(!u.trim()||g.size===0)){k(!0);try{const F=await(await ce("/api/git/commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,message:u,files:Array.from(g)})})).json();F.success?(p(""),x(new Set),Te(),tt()):console.error("Commit failed:",F.error)}catch(j){console.error("Error committing changes:",j)}finally{k(!1)}}},T=async()=>{St(!0);try{const F=await(await ce("/api/git/initial-commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();F.success?(Te(),tt()):(console.error("Initial commit failed:",F.error),alert(F.error||"Failed to create initial commit"))}catch(j){console.error("Error creating initial commit:",j),alert("Failed to create initial commit")}finally{St(!1)}},G=j=>{switch(j){case"M":return"Modified";case"A":return"Added";case"D":return"Deleted";case"U":return"Untracked";default:return j}},Me=j=>{const F=$.has(j.hash),xe=O[j.hash];return r.jsxs("div",{className:"border-b border-gray-200 dark:border-gray-700 last:border-0",children:[r.jsxs("div",{className:"flex items-start p-3 hover:bg-gray-50 dark:hover:bg-gray-800 cursor-pointer",onClick:()=>Vt(j.hash),children:[r.jsx("div",{className:"mr-2 mt-1 p-0.5 hover:bg-gray-200 dark:hover:bg-gray-700 rounded",children:F?r.jsx(Ar,{className:"w-3 h-3"}):r.jsx(yn,{className:"w-3 h-3"})}),r.jsx("div",{className:"flex-1 min-w-0",children:r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:j.message}),r.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:[j.author," • ",j.date]})]}),r.jsx("span",{className:"text-xs font-mono text-gray-400 dark:text-gray-500 flex-shrink-0",children:j.hash.substring(0,7)})]})})]}),F&&xe&&r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900",children:r.jsxs("div",{className:"max-h-96 overflow-y-auto p-2",children:[r.jsx("div",{className:"text-xs font-mono text-gray-600 dark:text-gray-400 mb-2",children:j.stats}),r.jsx(yc,{diff:xe,fileName:"commit",isMobile:t,wrapText:C})]})})]},j.hash)},fe=(j,F)=>{const xe=m.has(j),ve=g.has(j),ut=a[j];return r.jsxs("div",{className:"border-b border-gray-200 dark:border-gray-700 last:border-0",children:[r.jsxs("div",{className:`flex items-center hover:bg-gray-50 dark:hover:bg-gray-800 ${t?"px-2 py-1.5":"px-3 py-2"}`,children:[r.jsx("input",{type:"checkbox",checked:ve,onChange:()=>Zt(j),onClick:U=>U.stopPropagation(),className:`rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-ring dark:focus:ring-ring dark:bg-gray-800 dark:checked:bg-primary ${t?"mr-1.5":"mr-2"}`}),r.jsxs("div",{className:"flex items-center flex-1",children:[r.jsx("div",{className:`p-0.5 hover:bg-gray-200 dark:hover:bg-gray-700 rounded cursor-pointer ${t?"mr-1":"mr-2"}`,onClick:U=>{U.stopPropagation(),Qt(j)},children:r.jsx(yn,{className:`w-3 h-3 transition-transform duration-200 ease-in-out ${xe?"rotate-90":"rotate-0"}`})}),r.jsx("span",{className:`flex-1 truncate ${t?"text-xs":"text-sm"} cursor-pointer hover:text-primary hover:underline`,onClick:U=>{U.stopPropagation(),ft(j)},title:"Click to open file",children:j}),r.jsxs("div",{className:"flex items-center gap-1",children:[(F==="M"||F==="D")&&r.jsxs("button",{onClick:U=>{U.stopPropagation(),Ve({type:"discard",file:j,message:`Discard all changes to "${j}"? This action cannot be undone.`})},className:`${t?"px-2 py-1 text-xs":"p-1"} hover:bg-red-100 dark:hover:bg-red-900 rounded text-red-600 dark:text-red-400 font-medium flex items-center gap-1`,title:"Discard changes",children:[r.jsx(dr,{className:"w-3 h-3"}),t&&r.jsx("span",{children:"Discard"})]}),F==="U"&&r.jsxs("button",{onClick:U=>{U.stopPropagation(),Ve({type:"delete",file:j,message:`Delete untracked file "${j}"? This action cannot be undone.`})},className:`${t?"px-2 py-1 text-xs":"p-1"} hover:bg-red-100 dark:hover:bg-red-900 rounded text-red-600 dark:text-red-400 font-medium flex items-center gap-1`,title:"Delete untracked file",children:[r.jsx(dr,{className:"w-3 h-3"}),t&&r.jsx("span",{children:"Delete"})]}),r.jsx("span",{className:`inline-flex items-center justify-center w-5 h-5 rounded text-xs font-bold border ${F==="M"?"bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800":F==="A"?"bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300 border-green-200 dark:border-green-800":F==="D"?"bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300 border-red-200 dark:border-red-800":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300 border-gray-300 dark:border-gray-600"}`,title:G(F),children:F})]})]})]}),r.jsxs("div",{className:`bg-gray-50 dark:bg-gray-900 transition-all duration-400 ease-in-out overflow-hidden ${xe&&ut?"max-h-[600px] opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-1"}`,children:[r.jsxs("div",{className:"flex items-center justify-between p-2 border-b border-gray-200 dark:border-gray-700",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:`inline-flex items-center justify-center w-5 h-5 rounded text-xs font-bold border ${F==="M"?"bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800":F==="A"?"bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300 border-green-200 dark:border-green-800":F==="D"?"bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300 border-red-200 dark:border-red-800":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300 border-gray-300 dark:border-gray-600"}`,children:F}),r.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:G(F)})]}),t&&r.jsx("button",{onClick:U=>{U.stopPropagation(),b(!C)},className:"text-xs text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white",title:C?"Switch to horizontal scroll":"Switch to text wrap",children:C?"↔️ Scroll":"↩️ Wrap"})]}),r.jsx("div",{className:"max-h-96 overflow-y-auto",children:ut&&r.jsx(yc,{diff:ut,fileName:j,isMobile:t,wrapText:C})})]})]},j)};return e?r.jsxs("div",{className:"h-full flex flex-col bg-background",children:[r.jsxs("div",{className:`flex items-center justify-between border-b border-gray-200 dark:border-gray-700 ${t?"px-3 py-2":"px-4 py-3"}`,children:[r.jsxs("div",{className:"relative",ref:Y,children:[r.jsxs("button",{onClick:()=>Z(!D),className:`flex items-center hover:bg-gray-100 dark:hover:bg-gray-800 rounded-md transition-colors ${t?"space-x-1 px-2 py-1":"space-x-2 px-3 py-1.5"}`,children:[r.jsx(Jo,{className:`text-gray-600 dark:text-gray-400 ${t?"w-3 h-3":"w-4 h-4"}`}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:`font-medium ${t?"text-xs":"text-sm"}`,children:I}),P?.hasRemote&&r.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[P.ahead>0&&r.jsxs("span",{className:"text-green-600 dark:text-green-400",title:`${P.ahead} commit${P.ahead!==1?"s":""} ahead`,children:["↑",P.ahead]}),P.behind>0&&r.jsxs("span",{className:"text-primary",title:`${P.behind} commit${P.behind!==1?"s":""} behind`,children:["↓",P.behind]}),P.isUpToDate&&r.jsx("span",{className:"text-gray-500 dark:text-gray-400",title:"Up to date with remote",children:"✓"})]})]}),r.jsx(Ar,{className:`w-3 h-3 text-gray-500 transition-transform ${D?"rotate-180":""}`})]}),D&&r.jsxs("div",{className:"absolute top-full left-0 mt-1 w-64 bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 z-50",children:[r.jsx("div",{className:"py-1 max-h-64 overflow-y-auto",children:w.map(j=>r.jsx("button",{onClick:()=>ue(j),className:`w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 ${j===I?"bg-gray-50 dark:bg-gray-700 text-gray-900 dark:text-gray-100":"text-gray-700 dark:text-gray-300"}`,children:r.jsxs("div",{className:"flex items-center space-x-2",children:[j===I&&r.jsx(vr,{className:"w-3 h-3 text-green-600 dark:text-green-400"}),r.jsx("span",{className:j===I?"font-medium":"",children:j})]})},j))}),r.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 py-1",children:r.jsxs("button",{onClick:()=>{X(!0),Z(!1)},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center space-x-2",children:[r.jsx(jn,{className:"w-3 h-3"}),r.jsx("span",{children:"Create new branch"})]})})]})]}),r.jsxs("div",{className:`flex items-center ${t?"gap-1":"gap-2"}`,children:[P?.hasRemote&&r.jsxs(r.Fragment,{children:[!P?.hasUpstream&&r.jsxs("button",{onClick:()=>Ve({type:"publish",message:`Publish branch "${I}" to ${P.remoteName}?`}),disabled:lt,className:"px-2 py-1 text-xs bg-purple-600 text-white rounded hover:bg-purple-700 disabled:opacity-50 flex items-center gap-1",title:`Publish branch "${I}" to ${P.remoteName}`,children:[r.jsx(xs,{className:`w-3 h-3 ${lt?"animate-pulse":""}`}),r.jsx("span",{children:lt?"Publishing...":"Publish"})]}),P?.hasUpstream&&!P?.isUpToDate&&r.jsxs(r.Fragment,{children:[P.behind>0&&r.jsxs("button",{onClick:()=>Ve({type:"pull",message:`Pull ${P.behind} commit${P.behind!==1?"s":""} from ${P.remoteName}?`}),disabled:it,className:"px-2 py-1 text-xs bg-green-600 text-white rounded hover:bg-green-700 disabled:opacity-50 flex items-center gap-1",title:`Pull ${P.behind} commit${P.behind!==1?"s":""} from ${P.remoteName}`,children:[r.jsx(ha,{className:`w-3 h-3 ${it?"animate-pulse":""}`}),r.jsx("span",{children:it?"Pulling...":`Pull ${P.behind}`})]}),P.ahead>0&&r.jsxs("button",{onClick:()=>Ve({type:"push",message:`Push ${P.ahead} commit${P.ahead!==1?"s":""} to ${P.remoteName}?`}),disabled:Ge,className:"px-2 py-1 text-xs bg-orange-600 text-white rounded hover:bg-orange-700 disabled:opacity-50 flex items-center gap-1",title:`Push ${P.ahead} commit${P.ahead!==1?"s":""} to ${P.remoteName}`,children:[r.jsx(xs,{className:`w-3 h-3 ${Ge?"animate-pulse":""}`}),r.jsx("span",{children:Ge?"Pushing...":`Push ${P.ahead}`})]}),(P.ahead>0||P.behind>0&&P.ahead>0)&&r.jsxs("button",{onClick:Ye,disabled:ee,className:"px-2 py-1 text-xs bg-primary text-white rounded hover:bg-primary/80 disabled:opacity-50 flex items-center gap-1",title:`Fetch from ${P.remoteName}`,children:[r.jsx(Ir,{className:`w-3 h-3 ${ee?"animate-spin":""}`}),r.jsx("span",{children:ee?"Fetching...":"Fetch"})]})]})]}),r.jsx("button",{onClick:()=>{Te(),Fe(),tt()},disabled:c,className:`hover:bg-gray-100 dark:hover:bg-gray-800 rounded ${t?"p-1":"p-1.5"}`,children:r.jsx(Ir,{className:`${c?"animate-spin":""} ${t?"w-3 h-3":"w-4 h-4"}`})})]})]}),s?.error?r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-gray-500 dark:text-gray-400 px-6 py-12",children:[r.jsx(Jo,{className:"w-20 h-20 mb-6 opacity-30"}),r.jsx("h3",{className:"text-xl font-medium mb-3 text-center",children:s.error}),s.details&&r.jsx("p",{className:"text-sm text-center leading-relaxed mb-6 max-w-md",children:s.details}),r.jsx("div",{className:"p-4 bg-primary/10 dark:bg-primary/20 rounded-lg border border-primary/30 dark:border-primary/60 max-w-md",children:r.jsxs("p",{className:"text-sm text-primary text-center",children:[r.jsx("strong",{children:"Tip:"})," Run ",r.jsx("code",{className:"bg-primary/15 dark:bg-primary/30 px-2 py-1 rounded font-mono text-xs",children:"git init"})," in your project directory to initialize git source control."]})})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:`flex border-b border-gray-200 dark:border-gray-700 transition-all duration-300 ease-in-out ${m.size===0?"max-h-16 opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2 overflow-hidden"}`,children:[r.jsx("button",{onClick:()=>de("changes"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${ye==="changes"?"text-primary border-b-2 border-primary dark:border-primary":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,children:r.jsxs("div",{className:"flex items-center justify-center gap-2",children:[r.jsx(Ya,{className:"w-4 h-4"}),r.jsx("span",{children:"Changes"})]})}),r.jsx("button",{onClick:()=>de("history"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${ye==="history"?"text-primary border-b-2 border-primary dark:border-primary":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,children:r.jsxs("div",{className:"flex items-center justify-center gap-2",children:[r.jsx(al,{className:"w-4 h-4"}),r.jsx("span",{children:"History"})]})})]}),ye==="changes"&&r.jsx(r.Fragment,{children:r.jsx("div",{className:`transition-all duration-300 ease-in-out ${m.size===0?"max-h-96 opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2 overflow-hidden"}`,children:t&&Xe?r.jsx("div",{className:"px-4 py-2 border-b border-gray-200 dark:border-gray-700",children:r.jsxs("button",{onClick:()=>kt(!1),className:"w-full flex items-center justify-center gap-2 px-3 py-2 text-sm bg-primary text-white rounded-md hover:bg-primary/80",children:[r.jsx(Yo,{className:"w-4 h-4"}),r.jsxs("span",{children:["Commit ",g.size," file",g.size!==1?"s":""]}),r.jsx(Ar,{className:"w-3 h-3"})]})}):r.jsx(r.Fragment,{children:r.jsxs("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700",children:[t&&r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("span",{className:"text-sm font-medium",children:"Commit Changes"}),r.jsx("button",{onClick:()=>kt(!0),className:"p-1 hover:bg-gray-100 dark:hover:bg-gray-800 rounded",children:r.jsx(Ar,{className:"w-4 h-4 rotate-180"})})]}),r.jsxs("div",{className:"relative",children:[r.jsx("textarea",{ref:Dt,value:u,onChange:j=>p(j.target.value),placeholder:"Message (Ctrl+Enter to commit)",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 resize-none pr-20",rows:"3",onKeyDown:j=>{j.key==="Enter"&&(j.ctrlKey||j.metaKey)&&Rt()}}),r.jsxs("div",{className:"absolute right-2 top-2 flex gap-1",children:[r.jsx("button",{onClick:ht,disabled:g.size===0||ke,className:"p-1.5 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 disabled:opacity-50 disabled:cursor-not-allowed",title:"Generate commit message",children:ke?r.jsx(Ir,{className:"w-4 h-4 animate-spin"}):r.jsx(Ja,{className:"w-4 h-4"})}),r.jsx("div",{style:{display:"none"},children:r.jsx(Pb,{onTranscript:j=>p(j),mode:"default",className:"p-1.5"})})]})]}),r.jsxs("div",{className:"flex items-center justify-between mt-2",children:[r.jsxs("span",{className:"text-xs text-gray-500",children:[g.size," file",g.size!==1?"s":""," selected"]}),r.jsxs("button",{onClick:()=>Ve({type:"commit",message:`Commit ${g.size} file${g.size!==1?"s":""} with message: "${u.trim()}"?`}),disabled:!u.trim()||g.size===0||S,className:"px-3 py-1 text-sm bg-primary text-white rounded-md hover:bg-primary/80 disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-1",children:[r.jsx(vr,{className:"w-3 h-3"}),r.jsx("span",{children:S?"Committing...":"Commit"})]})]})]})})})}),ye==="changes"&&s&&!s.error&&r.jsxs("div",{className:`border-b border-gray-200 dark:border-gray-700 flex items-center justify-between transition-all duration-300 ease-in-out ${t?"px-3 py-1.5":"px-4 py-2"} ${m.size===0?"max-h-16 opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2 overflow-hidden"}`,children:[r.jsxs("span",{className:"text-gray-600 dark:text-gray-400 text-xs",children:[g.size," of ",(s?.modified?.length||0)+(s?.added?.length||0)+(s?.deleted?.length||0)+(s?.untracked?.length||0)," ",t?"":"files"," selected"]}),r.jsxs("div",{className:`flex ${t?"gap-1":"gap-2"}`,children:[r.jsx("button",{onClick:()=>{const j=new Set([...s?.modified||[],...s?.added||[],...s?.deleted||[],...s?.untracked||[]]);x(j)},className:"text-primary hover:text-primary text-xs",children:t?"All":"Select All"}),r.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),r.jsx("button",{onClick:()=>x(new Set),className:"text-primary hover:text-primary text-xs",children:t?"None":"Deselect All"})]})]}),!s?.error&&!t&&r.jsxs("div",{className:"border-b border-gray-200 dark:border-gray-700",children:[r.jsxs("button",{onClick:()=>B(!R),className:"w-full px-4 py-2 bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-750 text-xs text-gray-600 dark:text-gray-400 flex items-center justify-center gap-1",children:[r.jsx(kf,{className:"w-3 h-3"}),r.jsx("span",{children:"File Status Guide"}),R?r.jsx(Ar,{className:"w-3 h-3"}):r.jsx(yn,{className:"w-3 h-3"})]}),R&&r.jsx("div",{className:"px-4 py-3 bg-gray-50 dark:bg-gray-800 text-xs",children:r.jsxs("div",{className:`${t?"grid grid-cols-2 gap-3 justify-items-center":"flex justify-center gap-6"}`,children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300 rounded border border-yellow-200 dark:border-yellow-800 font-bold text-xs",children:"M"}),r.jsx("span",{className:"text-gray-600 dark:text-gray-400 italic",children:"Modified"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300 rounded border border-green-200 dark:border-green-800 font-bold text-xs",children:"A"}),r.jsx("span",{className:"text-gray-600 dark:text-gray-400 italic",children:"Added"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300 rounded border border-red-200 dark:border-red-800 font-bold text-xs",children:"D"}),r.jsx("span",{className:"text-gray-600 dark:text-gray-400 italic",children:"Deleted"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300 rounded border border-gray-300 dark:border-gray-600 font-bold text-xs",children:"U"}),r.jsx("span",{className:"text-gray-600 dark:text-gray-400 italic",children:"Untracked"})]})]})})]})]}),ye==="changes"&&!s?.error&&r.jsx("div",{className:`flex-1 overflow-y-auto ${t?"pb-mobile-nav":""}`,children:c?r.jsx("div",{className:"flex items-center justify-center h-32",children:r.jsx(Ir,{className:"w-6 h-6 animate-spin text-gray-400"})}):s?.hasCommits===!1?r.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[r.jsx(Jo,{className:"w-16 h-16 mb-4 opacity-30 text-gray-400 dark:text-gray-500"}),r.jsx("h3",{className:"text-lg font-medium mb-2 text-gray-900 dark:text-white",children:"No commits yet"}),r.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mb-6 max-w-md",children:"This repository doesn't have any commits yet. Create your first commit to start tracking changes."}),r.jsx("button",{onClick:T,disabled:jt,className:"px-4 py-2 bg-primary text-white rounded-md hover:bg-primary/80 disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:jt?r.jsxs(r.Fragment,{children:[r.jsx(Ir,{className:"w-4 h-4 animate-spin"}),r.jsx("span",{children:"Creating Initial Commit..."})]}):r.jsxs(r.Fragment,{children:[r.jsx(Yo,{className:"w-4 h-4"}),r.jsx("span",{children:"Create Initial Commit"})]})})]}):!s||!s.modified?.length&&!s.added?.length&&!s.deleted?.length&&!s.untracked?.length?r.jsxs("div",{className:"flex flex-col items-center justify-center h-32 text-gray-500 dark:text-gray-400",children:[r.jsx(Yo,{className:"w-12 h-12 mb-2 opacity-50"}),r.jsx("p",{className:"text-sm",children:"No changes detected"})]}):r.jsxs("div",{className:t?"pb-4":"",children:[s.modified?.map(j=>fe(j,"M")),s.added?.map(j=>fe(j,"A")),s.deleted?.map(j=>fe(j,"D")),s.untracked?.map(j=>fe(j,"U"))]})}),ye==="history"&&!s?.error&&r.jsx("div",{className:`flex-1 overflow-y-auto ${t?"pb-mobile-nav":""}`,children:c?r.jsx("div",{className:"flex items-center justify-center h-32",children:r.jsx(Ir,{className:"w-6 h-6 animate-spin text-gray-400"})}):H.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center h-32 text-gray-500 dark:text-gray-400",children:[r.jsx(al,{className:"w-12 h-12 mb-2 opacity-50"}),r.jsx("p",{className:"text-sm",children:"No commits found"})]}):r.jsx("div",{className:t?"pb-4":"",children:H.map(j=>Me(j))})}),z&&r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[r.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50",onClick:()=>X(!1)}),r.jsx("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full",children:r.jsxs("div",{className:"p-6",children:[r.jsx("h3",{className:"text-lg font-semibold mb-4",children:"Create New Branch"}),r.jsxs("div",{className:"mb-4",children:[r.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Branch Name"}),r.jsx("input",{type:"text",value:q,onChange:j=>re(j.target.value),onKeyDown:j=>{j.key==="Enter"&&!Se&&dt()},placeholder:"feature/new-feature",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-ring",autoFocus:!0})]}),r.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-4",children:["This will create a new branch from the current branch (",I,")"]}),r.jsxs("div",{className:"flex justify-end space-x-3",children:[r.jsx("button",{onClick:()=>{X(!1),re("")},className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md",children:"Cancel"}),r.jsx("button",{onClick:dt,disabled:!q.trim()||Se,className:"px-4 py-2 text-sm bg-primary text-white rounded-md hover:bg-primary/80 disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-2",children:Se?r.jsxs(r.Fragment,{children:[r.jsx(Ir,{className:"w-3 h-3 animate-spin"}),r.jsx("span",{children:"Creating..."})]}):r.jsxs(r.Fragment,{children:[r.jsx(jn,{className:"w-3 h-3"}),r.jsx("span",{children:"Create Branch"})]})})]})]})})]}),je&&r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[r.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50",onClick:()=>Ve(null)}),r.jsx("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full",children:r.jsxs("div",{className:"p-6",children:[r.jsxs("div",{className:"flex items-center mb-4",children:[r.jsx("div",{className:`p-2 rounded-full mr-3 ${je.type==="discard"||je.type==="delete"?"bg-red-100 dark:bg-red-900":"bg-yellow-100 dark:bg-yellow-900"}`,children:r.jsx(ba,{className:`w-5 h-5 ${je.type==="discard"||je.type==="delete"?"text-red-600 dark:text-red-400":"text-yellow-600 dark:text-yellow-400"}`})}),r.jsx("h3",{className:"text-lg font-semibold",children:je.type==="discard"?"Discard Changes":je.type==="delete"?"Delete File":je.type==="commit"?"Confirm Commit":je.type==="pull"?"Confirm Pull":je.type==="publish"?"Publish Branch":"Confirm Push"})]}),r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:je.message}),r.jsxs("div",{className:"flex justify-end space-x-3",children:[r.jsx("button",{onClick:()=>Ve(null),className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md",children:"Cancel"}),r.jsx("button",{onClick:$t,className:`px-4 py-2 text-sm text-white rounded-md ${je.type==="discard"||je.type==="delete"?"bg-red-600 hover:bg-red-700":je.type==="commit"?"bg-primary hover:bg-primary/90":je.type==="pull"?"bg-green-600 hover:bg-green-700":je.type==="publish"?"bg-purple-600 hover:bg-purple-700":"bg-orange-600 hover:bg-orange-700"} flex items-center space-x-2`,children:je.type==="discard"?r.jsxs(r.Fragment,{children:[r.jsx(dr,{className:"w-4 h-4"}),r.jsx("span",{children:"Discard"})]}):je.type==="delete"?r.jsxs(r.Fragment,{children:[r.jsx(dr,{className:"w-4 h-4"}),r.jsx("span",{children:"Delete"})]}):je.type==="commit"?r.jsxs(r.Fragment,{children:[r.jsx(vr,{className:"w-4 h-4"}),r.jsx("span",{children:"Commit"})]}):je.type==="pull"?r.jsxs(r.Fragment,{children:[r.jsx(ha,{className:"w-4 h-4"}),r.jsx("span",{children:"Pull"})]}):je.type==="publish"?r.jsxs(r.Fragment,{children:[r.jsx(xs,{className:"w-4 h-4"}),r.jsx("span",{children:"Publish"})]}):r.jsxs(r.Fragment,{children:[r.jsx(xs,{className:"w-4 h-4"}),r.jsx("span",{children:"Push"})]})})]})]})})]})]}):r.jsx("div",{className:"h-full flex items-center justify-center text-gray-500 dark:text-gray-400",children:r.jsx("p",{children:"Select a project to view source control"})})}class Ob extends Tn.Component{constructor(t){super(t),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(t){return{hasError:!0}}componentDidCatch(t,n){console.error("ErrorBoundary caught an error:",t,n),this.setState({error:t,errorInfo:n})}render(){return this.state.hasError?r.jsx("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:r.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-6 max-w-md",children:[r.jsxs("div",{className:"flex items-center mb-4",children:[r.jsx("div",{className:"flex-shrink-0",children:r.jsx("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:r.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),r.jsx("h3",{className:"ml-3 text-sm font-medium text-red-800",children:"Something went wrong"})]}),r.jsxs("div",{className:"text-sm text-red-700",children:[r.jsx("p",{className:"mb-2",children:"An error occurred while loading the chat interface."}),this.props.showDetails&&this.state.error&&r.jsxs("details",{className:"mt-4",children:[r.jsx("summary",{className:"cursor-pointer text-xs font-mono",children:"Error Details"}),r.jsxs("pre",{className:"mt-2 text-xs bg-red-100 p-2 rounded overflow-auto max-h-40",children:[this.state.error.toString(),this.state.errorInfo&&this.state.errorInfo.componentStack]})]})]}),r.jsx("div",{className:"mt-4",children:r.jsx("button",{onClick:()=>{this.setState({hasError:!1,error:null,errorInfo:null}),this.props.onRetry&&this.props.onRetry()},className:"bg-red-600 text-white px-4 py-2 rounded text-sm hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500",children:"Try Again"})})]})}):this.props.children}}const Fb=l.forwardRef(({className:e,...t},n)=>r.jsx(Jd,{ref:n,className:st("inline-flex h-10 items-center justify-center rounded-xl bg-muted/60 p-1 text-muted-foreground",e),...t}));Fb.displayName=Jd.displayName;const $b=l.forwardRef(({className:e,...t},n)=>r.jsx(Yd,{ref:n,className:st("inline-flex items-center justify-center whitespace-nowrap rounded-lg px-3 py-2 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/20 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...t}));$b.displayName=Yd.displayName;const Bb=l.forwardRef(({className:e,...t},n)=>r.jsx(Xd,{ref:n,className:st("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/20",e),...t}));Bb.displayName=Xd.displayName;function zb({selectedProject:e,selectedSession:t,activeTab:n,setActiveTab:s,ws:o,sendMessage:a,latestMessage:i,isMobile:c,isPWA:d,onMenuClick:u,isLoading:p,onInputFocusChange:m,onSessionActive:h,onSessionInactive:g,onSessionProcessing:x,onSessionNotProcessing:S,processingSessions:k,onReplaceTemporarySession:I,onNavigateToSession:A,onShowSettings:w,autoExpandTools:M,showRawParameters:C,showThinking:b,autoScrollToBottom:R,sendByCtrlEnter:B,externalMessageUpdate:D,urlContext:Z,urlPrompt:z,integrationClientId:X,latestIntegrationMessage:q,sendIntegrationMessage:re,onShowNewProject:Se,onNewSession:Ce,newSessionResetNonce:ye}){const{t:de}=Mt(),[H,Oe]=l.useState(null),[$,N]=l.useState(600),[O,ne]=l.useState(!1),[ke,ge]=l.useState(!1),P=l.useRef(null),ie=(Xe,kt=null)=>{const je={name:Xe.split("/").pop(),path:Xe,projectName:e?.name,diffInfo:kt};Oe(je)},ee=()=>{Oe(null),ge(!1)},Ne=()=>{ge(!ke)},it=Xe=>{c||(ne(!0),Xe.preventDefault())};if(l.useEffect(()=>{n==="files"&&s("chat")},[n,s]),l.useEffect(()=>{const Xe=je=>{if(!O)return;const Ve=P.current?.parentElement;if(!Ve)return;const jt=Ve.getBoundingClientRect(),St=jt.right-je.clientX,Dt=300,Y=jt.width*.8;St>=Dt&&St<=Y&&N(St)},kt=()=>{ne(!1)};return O&&(document.addEventListener("mousemove",Xe),document.addEventListener("mouseup",kt),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",Xe),document.removeEventListener("mouseup",kt),document.body.style.cursor="",document.body.style.userSelect=""}},[O]),p)return r.jsxs("div",{className:"h-full flex flex-col",children:[c&&r.jsx("div",{className:"bg-background/90 p-2 sm:p-3 pwa-header-safe flex-shrink-0 backdrop-blur",children:r.jsx("button",{onClick:u,className:"p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 pwa-menu-button",children:r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[r.jsx("div",{className:"w-12 h-12 mx-auto mb-4",children:r.jsx("div",{className:"w-full h-full rounded-full border-4 border-gray-200 border-t-primary",style:{animation:"spin 1s linear infinite",WebkitAnimation:"spin 1s linear infinite",MozAnimation:"spin 1s linear infinite"}})}),r.jsx("h2",{className:"text-xl font-semibold",children:de("mainContent.loading")})]})})]});if(!e)return r.jsxs("div",{className:"chat-shell h-full flex flex-col bg-background",children:[c&&r.jsx("div",{className:"bg-background/90 p-2 sm:p-3 pwa-header-safe flex-shrink-0 backdrop-blur",children:r.jsx("button",{onClick:u,className:"p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 pwa-menu-button",children:r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),r.jsx("div",{className:"flex flex-1 items-center justify-center px-4 py-8 sm:px-6",children:r.jsxs("div",{className:"w-full max-w-xl px-8 py-10 text-center text-muted-foreground",children:[r.jsx("div",{className:"mx-auto mb-6 flex h-16 w-16 items-center justify-center rounded-3xl bg-primary/10 text-primary",children:r.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-5l-2-2H5a2 2 0 00-2 2z"})})}),r.jsx("h2",{className:"text-2xl font-semibold mb-3 text-gray-900 dark:text-white",children:de("mainContent.chooseProject")}),r.jsx("p",{className:"text-gray-600 dark:text-gray-300 mb-6 leading-relaxed",children:de("mainContent.selectProjectDescription")}),r.jsx("div",{className:"mx-auto flex w-fit items-center",children:r.jsxs("button",{onClick:Se,className:"inline-flex items-center gap-2 rounded-xl bg-foreground px-4 py-2 text-sm font-medium text-background transition hover:opacity-90",title:de("tooltips.createProject")||"New Chat",children:[r.jsx(tn,{className:"w-5 h-5"}),r.jsx("span",{children:de("tooltips.createProject")||"New Chat"})]})})]})})]});const Ke=t?.__provider||t?.provider||"claude",Ge=Ke==="openai"?"codex":Ke,qe=Ge==="codex"&&typeof t?.id=="string"?t.id.trim():"",lt=qe?`codex://threads/${encodeURIComponent(qe)}`:"",It=()=>{lt&&(window.location.href=lt)};return r.jsxs("div",{className:"chat-shell h-full flex flex-col bg-background",children:[r.jsx("div",{className:"chat-header flex-shrink-0 px-3 py-3 sm:px-4 sm:py-3 pwa-header-safe",children:r.jsxs("div",{className:"relative flex items-center justify-between gap-3",children:[r.jsxs("div",{className:"flex min-w-0 flex-1 items-center space-x-2",children:[c&&r.jsx("button",{onClick:u,onTouchStart:Xe=>{Xe.preventDefault(),u()},className:"pwa-menu-button flex-shrink-0 rounded-xl bg-muted/60 p-2 text-muted-foreground transition hover:bg-muted hover:text-foreground touch-manipulation active:scale-95",children:r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),r.jsxs("div",{className:"flex flex-1 items-center gap-3 overflow-x-auto scrollbar-hide min-w-0",children:[n==="chat"&&t&&r.jsx("div",{className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-xl bg-muted/60",children:Ge==="codex"?r.jsx(ao,{className:"w-4 h-4"}):Ge==="gemini"?r.jsx(io,{className:"w-4 h-4"}):Ge==="opencode"?r.jsx(lo,{className:"h-4 w-auto max-w-full"}):r.jsx(Qn,{className:"w-4 h-4"})}),r.jsx("div",{className:"min-w-0 flex-1",children:n==="chat"&&t?r.jsxs("div",{className:"min-w-0",children:[r.jsx("h2",{className:"overflow-x-auto whitespace-nowrap scrollbar-hide text-sm font-semibold text-gray-900 dark:text-white sm:text-base",children:Ge==="codex"?t.summary||t.name||"Codex Session":Ge==="gemini"?t.summary||t.name||"Gemini Session":Ge==="opencode"?t.summary||t.name||"OpenCode Session":t.summary||"New Session"}),r.jsx("div",{className:"truncate text-xs text-gray-500 dark:text-gray-400",children:e.displayName})]}):n==="chat"&&!t?r.jsxs("div",{className:"min-w-0",children:[r.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:de("mainContent.newSession")}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.displayName})]}):r.jsxs("div",{className:"min-w-0",children:[r.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:n==="git"?de("tabs.git"):"Project"}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.displayName})]})})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[n==="chat"&&Ge==="codex"&<&&!c&&r.jsx("button",{onClick:It,className:"rounded-xl bg-muted/60 p-2 text-muted-foreground transition hover:bg-muted hover:text-foreground",title:de("mainContent.openInCodexClient"),"aria-label":de("mainContent.openInCodexClient"),children:r.jsx(ga,{className:"w-5 h-5"})}),r.jsx("button",{onClick:()=>Ce&&Ce(e),className:"rounded-xl bg-muted/60 p-2 text-muted-foreground transition hover:bg-muted hover:text-foreground",title:de("tooltips.newChat","New Chat"),children:r.jsx(If,{className:"w-5 h-5"})})]})]})}),r.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[r.jsxs("div",{className:`flex-1 flex flex-col min-h-0 overflow-hidden ${H?"mr-0":""} ${ke?"hidden":""}`,children:[r.jsx("div",{className:`h-full ${n==="chat"?"block":"hidden"}`,children:r.jsx(Ob,{showDetails:!0,children:r.jsx(Fy,{selectedProject:e,selectedSession:t,ws:o,sendMessage:a,latestMessage:i,onFileOpen:ie,onInputFocusChange:m,onSessionActive:h,onSessionInactive:g,onSessionProcessing:x,onSessionNotProcessing:S,processingSessions:k,onReplaceTemporarySession:I,onNavigateToSession:A,onShowSettings:w,autoExpandTools:M,showRawParameters:C,showThinking:b,autoScrollToBottom:R,sendByCtrlEnter:B,externalMessageUpdate:D,urlContext:Z,urlPrompt:z,integrationClientId:X,latestIntegrationMessage:q,sendIntegrationMessage:re,newSessionResetNonce:ye},`${e?.name||"no-project"}:${t?.id||`new-${ye}`}`)})}),n==="shell"&&r.jsx("div",{className:"h-full w-full overflow-hidden",children:r.jsx(Ju,{project:e,session:t,showHeader:!1})}),n==="git"&&r.jsx("div",{className:"chat-surface h-full overflow-hidden",children:r.jsx(Lb,{selectedProject:e,isMobile:c,onFileOpen:ie})}),r.jsx("div",{className:`h-full overflow-hidden ${n==="preview"?"block":"hidden"}`})]}),H&&!c&&r.jsxs(r.Fragment,{children:[!ke&&r.jsx("div",{ref:P,onMouseDown:it,className:"group relative w-1 flex-shrink-0 cursor-col-resize bg-border/70 transition-colors hover:bg-primary",title:"Drag to resize",children:r.jsx("div",{className:"absolute inset-y-0 left-1/2 -translate-x-1/2 w-1 bg-primary dark:bg-primary opacity-0 group-hover:opacity-100 transition-opacity"})}),r.jsx("div",{className:`chat-surface h-full flex-shrink-0 overflow-hidden bg-muted/20 ${ke?"flex-1":""}`,style:ke?{}:{width:`${$}px`},children:r.jsx(xc,{file:H,onClose:ee,projectPath:e?.path,isSidebar:!0,isExpanded:ke,onToggleExpand:Ne})})]})]}),H&&c&&r.jsx(xc,{file:H,onClose:ee,projectPath:e?.path,isSidebar:!1})]})}const Ub=Tn.memo(zb),Yu="0.2.6",Xu=()=>{const[e,t]=l.useState(!1),[n,s]=l.useState(null),[o,a]=l.useState(null);return l.useEffect(()=>{(async()=>{try{const c=await ce("/api/system/version");if(!c.ok)throw new Error(`Version API failed: ${c.status}`);const d=await c.json();if(!d?.success)throw new Error(d?.error||"Version API returned unsuccessful result");if(d.latestVersion){const u=String(d.latestVersion).replace(/^v/,"");s(u),t(!!d.updateAvailable),a({title:d.releaseInfo?.title||`v${u}`,body:d.releaseInfo?.body||"",htmlUrl:d.releaseInfo?.htmlUrl||`https://www.npmjs.com/package/${d.packageName||"@axhub/genie"}`,publishedAt:d.releaseInfo?.publishedAt||null})}else t(!1),s(null),a(null)}catch(c){console.error("Version check failed:",c.message||c),t(!1),s(null),a(null)}})()},[]),{updateAvailable:e,latestVersion:n,currentVersion:Yu,releaseInfo:o}};function Wb(){const{t:e}=Mt("settings"),[t,n]=l.useState([]),[s,o]=l.useState(!0),[a,i]=l.useState(!1),[c,d]=l.useState(""),[u,p]=l.useState(null),[m,h]=l.useState(null),{updateAvailable:g,latestVersion:x,releaseInfo:S}=Xu();l.useEffect(()=>{k()},[]);const k=async()=>{try{o(!0);const b=await(await ce("/api/settings/api-keys")).json();n(b.apiKeys||[])}catch(C){console.error("Error fetching settings:",C)}finally{o(!1)}},I=async()=>{if(c.trim())try{const b=await(await ce("/api/settings/api-keys",{method:"POST",body:JSON.stringify({keyName:c})})).json();b.success&&(h(b.apiKey),d(""),i(!1),k())}catch(C){console.error("Error creating API key:",C)}},A=async C=>{if(confirm(e("apiKeys.confirmDelete")))try{await ce(`/api/settings/api-keys/${C}`,{method:"DELETE"}),k()}catch(b){console.error("Error deleting API key:",b)}},w=async(C,b)=>{try{await ce(`/api/settings/api-keys/${C}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!b})}),k()}catch(R){console.error("Error toggling API key:",R)}},M=(C,b)=>{navigator.clipboard.writeText(C),p(b),setTimeout(()=>p(null),2e3)};return s?r.jsx("div",{className:"text-muted-foreground",children:e("apiKeys.loading")}):r.jsxs("div",{className:"space-y-8",children:[m&&r.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/20 rounded-lg",children:[r.jsx("h4",{className:"font-semibold text-yellow-500 mb-2",children:e("apiKeys.newKey.alertTitle")}),r.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:e("apiKeys.newKey.alertMessage")}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("code",{className:"flex-1 px-3 py-2 bg-background/50 rounded font-mono text-sm break-all",children:m.apiKey}),r.jsx(Pe,{size:"sm",variant:"outline",onClick:()=>M(m.apiKey,"new"),children:u==="new"?r.jsx(vr,{className:"h-4 w-4"}):r.jsx(Bm,{className:"h-4 w-4"})})]}),r.jsx(Pe,{size:"sm",variant:"ghost",className:"mt-3",onClick:()=>h(null),children:e("apiKeys.newKey.iveSavedIt")})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Rc,{className:"h-5 w-5"}),r.jsx("h3",{className:"text-lg font-semibold",children:e("apiKeys.title")})]}),r.jsxs(Pe,{size:"sm",onClick:()=>i(!a),children:[r.jsx(jn,{className:"h-4 w-4 mr-1"}),e("apiKeys.newButton")]})]}),r.jsxs("div",{className:"mb-4",children:[r.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:e("apiKeys.description")}),r.jsxs("a",{href:"/api-docs.html",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline inline-flex items-center gap-1",children:[e("apiKeys.apiDocsLink"),r.jsx(ga,{className:"h-3 w-3"})]})]}),a&&r.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card",children:[r.jsx(Pt,{placeholder:e("apiKeys.form.placeholder"),value:c,onChange:C=>d(C.target.value),className:"mb-2"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Pe,{onClick:I,children:e("apiKeys.form.createButton")}),r.jsx(Pe,{variant:"outline",onClick:()=>i(!1),children:e("apiKeys.form.cancelButton")})]})]}),r.jsx("div",{className:"space-y-2",children:t.length===0?r.jsx("p",{className:"text-sm text-muted-foreground italic",children:e("apiKeys.empty")}):t.map(C=>r.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"font-medium",children:C.key_name}),r.jsx("code",{className:"text-xs text-muted-foreground",children:C.api_key}),r.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[e("apiKeys.list.created")," ",new Date(C.created_at).toLocaleDateString(),C.last_used&&` • ${e("apiKeys.list.lastUsed")} ${new Date(C.last_used).toLocaleDateString()}`]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Pe,{size:"sm",variant:C.is_active?"outline":"secondary",onClick:()=>w(C.id,C.is_active),children:C.is_active?e("apiKeys.status.active"):e("apiKeys.status.inactive")}),r.jsx(Pe,{size:"sm",variant:"ghost",onClick:()=>A(C.id),children:r.jsx(dr,{className:"h-4 w-4"})})]})]},C.id))})]}),r.jsx("div",{className:"pt-6 border-t border-border/50",children:r.jsxs("div",{className:"flex items-center justify-between text-xs italic text-muted-foreground/60",children:[r.jsxs("a",{href:S?.htmlUrl||"https://github.com/siteboon/claudecodeui/releases",target:"_blank",rel:"noopener noreferrer",className:"hover:text-muted-foreground transition-colors",children:["v",Yu]}),g&&x&&r.jsxs("a",{href:S?.htmlUrl||"https://github.com/siteboon/claudecodeui/releases",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-2 py-0.5 bg-green-500/10 text-green-600 dark:text-green-400 rounded-full hover:bg-green-500/20 transition-colors not-italic font-medium",children:[r.jsx("span",{className:"text-[10px]",children:e("apiKeys.version.updateAvailable",{version:x})}),r.jsx(ga,{className:"h-2.5 w-2.5"})]})]})})]})}const Hb=["claude","cursor","codex","gemini","opencode"],bc=["lark","dingtalk"],wc={lark:{appId:"",appSecret:"",hasAppSecret:!1,encryptKey:"",verificationToken:"",hasEncryptKey:!1,hasVerificationToken:!1,defaultBackend:"codex",defaultModel:"",defaultProjectPath:""},dingtalk:{clientId:"",clientSecret:"",hasClientSecret:!1,defaultBackend:"codex",defaultModel:"",defaultProjectPath:""}},pa={running:!1,status:"stopped",error:null};function qb({projects:e=[]}){const{t}=Mt("settings"),[n,s]=l.useState("lark"),[o,a]=l.useState(wc),[i,c]=l.useState({lark:{...pa},dingtalk:{...pa}}),[d,u]=l.useState({lark:[],dingtalk:[]}),[p,m]=l.useState(!1),[h,g]=l.useState(!1),[x,S]=l.useState(!1),[k,I]=l.useState(!1),[A,w]=l.useState(null),[M,C]=l.useState(null),[b,R]=l.useState({userId:"",displayName:"",note:""}),B=l.useMemo(()=>e.map(N=>({label:N.displayName||N.name||N.path||N.fullPath,value:N.path||N.fullPath||""})).filter(N=>N.value),[e]),D=o[n]||wc[n],Z=i[n]||pa,z=d[n]||[],X=async(N,O=!1)=>{O||C(null);const[ne,ke,ge]=await Promise.all([ce(`/api/channels/${N}/config`),ce(`/api/channels/${N}/status`),ce(`/api/channels/${N}/allowed-users`)]),P=await ne.json(),ie=await ke.json(),ee=await ge.json();P?.success&&P?.config&&a(Ne=>({...Ne,[N]:{...Ne[N],...P.config}})),ie?.success&&ie?.status&&c(Ne=>({...Ne,[N]:ie.status})),ee?.success&&u(Ne=>({...Ne,[N]:ee.users||[]}))},q=async(N=!1)=>{m(!0);try{await Promise.all(bc.map(O=>X(O,N)))}catch(O){C(O.message||t("channels.errors.loadFailed","加载渠道设置失败"))}finally{m(!1)}};l.useEffect(()=>{q()},[]);const re=N=>{a(O=>({...O,[n]:{...O[n],...N}}))},Se=async()=>{m(!0),w(null),C(null);try{const N=n==="dingtalk"?{clientId:D.clientId,clientSecret:D.clientSecret,defaultBackend:D.defaultBackend,defaultModel:D.defaultModel,defaultProjectPath:D.defaultProjectPath}:{appId:D.appId,appSecret:D.appSecret,encryptKey:D.encryptKey,verificationToken:D.verificationToken,defaultBackend:D.defaultBackend,defaultModel:D.defaultModel,defaultProjectPath:D.defaultProjectPath},O=await ce(`/api/channels/${n}/config`,{method:"PUT",body:JSON.stringify(N)}),ne=await O.json();if(!O.ok||!ne.success)throw new Error(ne.error||t("channels.errors.saveFailed","保存失败"));re(n==="dingtalk"?{...ne.config,clientSecret:""}:{...ne.config,appSecret:"",encryptKey:"",verificationToken:""}),w(t(`channels.messages.${n}.configSaved`,n==="dingtalk"?"DingTalk 配置已保存":"Lark 配置已保存")),await X(n,!0)}catch(N){C(N.message||t("channels.errors.saveFailed","保存失败"))}finally{m(!1)}},Ce=async()=>{if(n==="dingtalk"){const N=String(D.clientId||"").trim(),O=String(D.clientSecret||"").trim();if(!N||!O&&!D.hasClientSecret){C(t("channels.errors.testNeedCredentialsDingTalk","测试连接需要填写 Client ID 和 Client Secret"));return}}else{const N=String(D.appId||"").trim(),O=String(D.appSecret||"").trim();if(!N||!O&&!D.hasAppSecret){C(t("channels.errors.testNeedCredentials","测试连接需要填写 App ID 和 App Secret"));return}}g(!0),C(null),w(null);try{const N=await ce(`/api/channels/${n}/test`,{method:"POST",body:JSON.stringify(n==="dingtalk"?{clientId:D.clientId,clientSecret:D.clientSecret}:{appId:D.appId,appSecret:D.appSecret})}),O=await N.json();if(!N.ok||!O.success)throw new Error(O.error||t("channels.errors.testFailed","连接测试失败"));w(t(`channels.messages.${n}.testSuccess`,n==="dingtalk"?"DingTalk 连接测试成功":"Lark 连接测试成功"))}catch(N){C(N.message||t("channels.errors.testFailed","连接测试失败"))}finally{g(!1)}},ye=async()=>{S(!0),C(null),w(null);try{const N=await ce(`/api/channels/${n}/start`,{method:"POST"}),O=await N.json();if(!N.ok||!O.success)throw new Error(O.error||t("channels.errors.startFailed","启动失败"));c(ne=>({...ne,[n]:O.status||ne[n]})),w(t(`channels.messages.${n}.started`,n==="dingtalk"?"DingTalk 已启动":"Lark 已启动")),await X(n,!0)}catch(N){C(N.message||t("channels.errors.startFailed","启动失败"))}finally{S(!1)}},de=async()=>{I(!0),C(null),w(null);try{const N=await ce(`/api/channels/${n}/stop`,{method:"POST"}),O=await N.json();if(!N.ok||!O.success)throw new Error(O.error||t("channels.errors.stopFailed","停止失败"));c(ne=>({...ne,[n]:O.status||ne[n]})),w(t(`channels.messages.${n}.stopped`,n==="dingtalk"?"DingTalk 已停止":"Lark 已停止")),await X(n,!0)}catch(N){C(N.message||t("channels.errors.stopFailed","停止失败"))}finally{I(!1)}},H=async()=>{if(!b.userId.trim()){C(t("channels.errors.userIdRequired","请输入用户ID"));return}m(!0),C(null),w(null);try{const O=await ce(`/api/channels/${n}/allowed-users`,{method:"POST",body:JSON.stringify(b)}),ne=await O.json();if(!O.ok||!ne.success)throw new Error(ne.error||t("channels.errors.addUserFailed","新增用户失败"));R({userId:"",displayName:"",note:""}),w(t("channels.messages.userAdded","用户已添加")),await X(n,!0)}catch(O){C(O.message||t("channels.errors.addUserFailed","新增用户失败"))}finally{m(!1)}},Oe=async N=>{m(!0),C(null);try{const O=await ce(`/api/channels/${n}/allowed-users/${N.id}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!N.isActive})}),ne=await O.json();if(!O.ok||!ne.success)throw new Error(ne.error||t("channels.errors.toggleUserFailed","更新用户状态失败"));await X(n,!0)}catch(O){C(O.message||t("channels.errors.toggleUserFailed","更新用户状态失败"))}finally{m(!1)}},$=async N=>{if(window.confirm(t("channels.confirmDeleteUser","确定要删除这个用户ID吗?"))){m(!0),C(null);try{const O=await ce(`/api/channels/${n}/allowed-users/${N}`,{method:"DELETE"}),ne=await O.json();if(!O.ok||!ne.success)throw new Error(ne.error||t("channels.errors.deleteUserFailed","删除用户失败"));await X(n,!0)}catch(O){C(O.message||t("channels.errors.deleteUserFailed","删除用户失败"))}finally{m(!1)}}};return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"text-lg font-semibold text-foreground",children:t("channels.title","第三方 IM")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:t(`channels.platformDescriptions.${n}`,n==="dingtalk"?"配置 DingTalk 机器人连接、默认执行环境,并通过用户ID白名单控制访问。":"配置飞书机器人连接、默认执行环境,并通过用户ID白名单控制访问。")})]}),r.jsx("div",{className:"border-b border-border",children:r.jsx("div",{className:"flex items-end gap-1 -mb-px",role:"tablist","aria-label":t("channels.title","第三方 IM"),children:bc.map(N=>{const O=N===n;return r.jsx("button",{type:"button",role:"tab","aria-selected":O,className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors rounded-t-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 ${O?"border-primary text-primary bg-primary/5":"border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,onClick:()=>{s(N),w(null),C(null)},children:t(`channels.platforms.${N}`,N==="dingtalk"?"DingTalk / 钉钉":"Lark / 飞书")},N)})})}),(A||M)&&r.jsx("div",{className:`rounded-lg border p-3 text-sm ${M?"border-red-300 bg-red-50 text-red-700 dark:border-red-800 dark:bg-red-900/20 dark:text-red-300":"border-green-300 bg-green-50 text-green-700 dark:border-green-800 dark:bg-green-900/20 dark:text-green-300"}`,children:M||A}),r.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-4",children:[r.jsx("h4",{className:"font-medium text-foreground",children:t("channels.connection.title","连接配置")}),n==="dingtalk"?r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm mb-1 text-foreground",children:"Client ID"}),r.jsx(Pt,{value:D.clientId,onChange:N=>re({clientId:N.target.value}),placeholder:"dingxxxxxxxx"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm mb-1 text-foreground",children:"Client Secret"}),r.jsx(Pt,{type:"password",value:D.clientSecret,onChange:N=>re({clientSecret:N.target.value}),placeholder:D.hasClientSecret?"••••••••(已保存)":"输入 Client Secret"})]})]}):r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm mb-1 text-foreground",children:"App ID"}),r.jsx(Pt,{value:D.appId,onChange:N=>re({appId:N.target.value}),placeholder:"cli_xxx"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm mb-1 text-foreground",children:"App Secret"}),r.jsx(Pt,{type:"password",value:D.appSecret,onChange:N=>re({appSecret:N.target.value}),placeholder:D.hasAppSecret?"••••••••(已保存)":"输入 App Secret"})]})]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm mb-1 text-foreground",children:t("channels.defaults.backend","默认后端")}),r.jsx("select",{value:D.defaultBackend,onChange:N=>re({defaultBackend:N.target.value}),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg",children:Hb.map(N=>r.jsx("option",{value:N,children:N},N))})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm mb-1 text-foreground",children:t("channels.defaults.project","默认项目")}),r.jsxs("select",{value:D.defaultProjectPath,onChange:N=>re({defaultProjectPath:N.target.value}),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg",children:[r.jsx("option",{value:"",children:t("channels.defaults.projectPlaceholder","请选择项目")}),B.map(N=>r.jsx("option",{value:N.value,children:N.label},N.value))]})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Pe,{onClick:Se,disabled:p,children:t("channels.actions.saveConfig","保存配置")}),r.jsx(Pe,{variant:"outline",onClick:Ce,disabled:h,children:h?t("channels.actions.testing","测试中..."):t("channels.actions.test","测试连接")})]})]}),r.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-3",children:[r.jsx("h4",{className:"font-medium text-foreground",children:t("channels.runtime.title","运行状态")}),r.jsxs("div",{className:"text-sm text-muted-foreground",children:[t("channels.runtime.currentStatus","当前状态"),": ",r.jsx("span",{className:"font-medium text-foreground",children:Z.status||"stopped"}),Z.error?r.jsx("span",{className:"text-red-500 ml-2",children:Z.error}):null]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Pe,{onClick:ye,disabled:x||Z.running,children:x?t("channels.actions.starting","启动中..."):t("channels.actions.start","启动")}),r.jsx(Pe,{variant:"outline",onClick:de,disabled:k||!Z.running,children:k?t("channels.actions.stopping","停止中..."):t("channels.actions.stop","停止")}),r.jsx(Pe,{variant:"ghost",onClick:()=>void X(n),disabled:p,children:t("channels.actions.refresh","刷新")})]})]}),r.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-4",children:[r.jsx("h4",{className:"font-medium text-foreground",children:t("channels.allowedUsers.title","允许用户ID(白名单)")}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-2",children:[r.jsx(Pt,{placeholder:t("channels.allowedUsers.userId","用户ID"),value:b.userId,onChange:N=>R(O=>({...O,userId:N.target.value}))}),r.jsx(Pt,{placeholder:t("channels.allowedUsers.displayName","显示名(可选)"),value:b.displayName,onChange:N=>R(O=>({...O,displayName:N.target.value}))}),r.jsx(Pt,{placeholder:t("channels.allowedUsers.note","备注(可选)"),value:b.note,onChange:N=>R(O=>({...O,note:N.target.value}))}),r.jsx(Pe,{onClick:H,disabled:p,children:t("channels.allowedUsers.add","新增")})]}),r.jsx("div",{className:"space-y-2",children:z.length===0?r.jsx("p",{className:"text-sm text-muted-foreground",children:t("channels.allowedUsers.empty","暂无白名单用户")}):z.map(N=>r.jsxs("div",{className:"border border-border rounded-lg p-3 flex flex-col md:flex-row md:items-center md:justify-between gap-2",children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-foreground",children:N.userId}),r.jsxs("div",{className:"text-sm text-muted-foreground",children:[N.displayName||"-",N.note?` · ${N.note}`:""]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:`text-xs px-2 py-1 rounded ${N.isActive?"bg-green-100 text-green-700 dark:bg-green-900/20 dark:text-green-300":"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400"}`,children:N.isActive?t("channels.allowedUsers.active","启用"):t("channels.allowedUsers.inactive","停用")}),r.jsx(Pe,{size:"sm",variant:"outline",onClick:()=>void Oe(N),children:N.isActive?t("channels.allowedUsers.disable","停用"):t("channels.allowedUsers.enable","启用")}),r.jsx(Pe,{size:"sm",variant:"ghost",onClick:()=>void $(N.id),children:t("channels.allowedUsers.delete","删除")})]})]},N.id))})]}),r.jsxs("div",{className:"rounded-lg border border-primary/30 bg-primary/10 dark:border-primary/40 dark:bg-primary/15 p-4",children:[r.jsx("h5",{className:"font-medium text-foreground mb-2",children:t("channels.help.title","使用说明")}),r.jsxs("ul",{className:"text-sm text-muted-foreground list-disc pl-5 space-y-1",children:[r.jsx("li",{children:t(`channels.help.${n}.step1`,n==="dingtalk"?"未绑定用户给机器人发消息时,机器人会返回该用户的钉钉用户ID。":"未绑定用户给机器人发消息时,机器人会返回该用户的飞书用户ID。")}),r.jsx("li",{children:t(`channels.help.${n}.step2`,"管理员将该ID加入白名单后,用户即可正常对话。")}),r.jsx("li",{children:t(`channels.help.${n}.step3`,"请先配置默认项目,否则机器人不会执行任务。")})]})]})]})}function Vb({isOpen:e,onClose:t,provider:n="claude",project:s,onComplete:o,customCommand:a,isAuthenticated:i=!1}){if(!e)return null;const c=()=>{if(a)return a;switch(n){case"claude":return i?"claude setup-token --dangerously-skip-permissions":"claude /exit --dangerously-skip-permissions";case"codex":return"codex login";case"gemini":return"npx -y @google/gemini-cli";case"opencode":return"npx -y opencode-ai@latest login";default:return i?"claude setup-token --dangerously-skip-permissions":"claude /exit --dangerously-skip-permissions"}},d=()=>{switch(n){case"claude":return"Claude CLI Login";case"codex":return"Codex CLI Login";case"gemini":return"Gemini CLI Login";case"opencode":return"OpenCode CLI Login";default:return"CLI Login"}},u=p=>{o?.(p),p===0&&t()};return r.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[9999] max-md:items-stretch max-md:justify-stretch",children:r.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-4xl h-3/4 flex flex-col md:max-w-4xl md:h-3/4 md:rounded-lg md:m-4 max-md:max-w-none max-md:h-full max-md:rounded-none max-md:m-0",children:[r.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[r.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:d()}),r.jsx("button",{onClick:t,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors","aria-label":"Close login modal",children:r.jsx(sr,{className:"w-6 h-6"})})]}),r.jsx("div",{className:"flex-1 overflow-hidden",children:r.jsx(Ju,{project:s,command:c(),onComplete:u,minimal:!0})})]})})}function Qu({compact:e=!1}){const{i18n:t,t:n}=Mt("settings"),s=o=>{const a=o.target.value;t.changeLanguage(a)};return e?r.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[r.jsx(Pc,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),n("account.language")]}),r.jsx("select",{value:t.language,onChange:s,className:"w-[100px] text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary p-2 focus:outline-none focus:ring-2",children:sl.map(o=>r.jsx("option",{value:o.value,children:o.nativeName},o.value))})]}):r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100 mb-1",children:n("account.languageLabel")}),r.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:n("account.languageDescription")})]}),r.jsx("select",{value:t.language,onChange:s,className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary p-2 w-36",children:sl.map(o=>r.jsx("option",{value:o.value,children:o.nativeName},o.value))})]})})}function Kb({isOpen:e,onClose:t,projects:n=[],initialTab:s="appearance"}){const{isDarkMode:o,toggleDarkMode:a}=Ka(),{t:i}=Mt("settings"),[c,d]=l.useState([]),[u,p]=l.useState([]),[m,h]=l.useState(""),[g,x]=l.useState(""),[S,k]=l.useState(!1),[I,A]=l.useState(!1),[w,M]=l.useState(null),[C,b]=l.useState("name"),[R,B]=l.useState([]),[D,Z]=l.useState(!1),[z,X]=l.useState(null),[q,re]=l.useState({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),[Se,Ce]=l.useState(!1),[ye,de]=l.useState({}),[H,Oe]=l.useState({}),[$,N]=l.useState({}),[O,ne]=l.useState(s),[ke,ge]=l.useState(""),P=["appearance","api","channels"],[ie,ee]=l.useState(()=>localStorage.getItem("codeEditorTheme")||"dark"),[Ne,it]=l.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[Ke,Ge]=l.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[qe,lt]=l.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[It,Xe]=l.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),[kt,je]=l.useState([]),[Ve,jt]=l.useState("default"),[St,Dt]=l.useState(!1),[Y,oe]=l.useState({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),[Ee,Te]=l.useState(null),[Fe,tt]=l.useState(!1),[ue,dt]=l.useState(!1),[Ye,Qe]=l.useState(""),[ze,Lt]=l.useState(null),[Nt,xt]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),[$t,rt]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),[ft,qt]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),At=async()=>{try{const L=await ce("/api/codex/mcp/config/read");if(L.ok){const se=await L.json();if(se.success&&se.servers){je(se.servers);return}}const W=await ce("/api/codex/mcp/cli/list");if(W.ok){const se=await W.json();if(se.success&&se.servers){const E=se.servers.map(J=>({id:J.name,name:J.name,type:J.type||"stdio",scope:"user",config:{command:J.command||"",args:J.args||[],env:J.env||{}}}));je(E)}}}catch(L){console.error("Error fetching Codex MCP servers:",L)}},ht=async()=>{try{const L=await ce("/api/mcp/config/read");if(L.ok){const E=await L.json();if(E.success&&E.servers){B(E.servers);return}}const W=await ce("/api/mcp/cli/list");if(W.ok){const E=await W.json();if(E.success&&E.servers){const J=E.servers.map(Q=>({id:Q.name,name:Q.name,type:Q.type,scope:"user",config:{command:Q.command||"",args:Q.args||[],env:Q.env||{},url:Q.url||"",headers:Q.headers||{},timeout:3e4},created:new Date().toISOString(),updated:new Date().toISOString()}));B(J);return}}const se=await ce("/api/mcp/servers?scope=user");if(se.ok){const E=await se.json();B(E.servers||[])}else console.error("Failed to fetch MCP servers")}catch(L){console.error("Error fetching MCP servers:",L)}},Qt=async L=>{try{z&&await Vt(z.id,"user");const W=await ce("/api/mcp/cli/add",{method:"POST",body:JSON.stringify({name:L.name,type:L.type,scope:L.scope,projectPath:L.projectPath,command:L.config?.command,args:L.config?.args||[],url:L.config?.url,headers:L.config?.headers||{},env:L.config?.env||{}})});if(W.ok){const se=await W.json();if(se.success)return await ht(),!0;throw new Error(se.error||"Failed to save server via Claude CLI")}else{const se=await W.json();throw new Error(se.error||"Failed to save server")}}catch(W){throw console.error("Error saving MCP server:",W),W}},Vt=async(L,W="user")=>{try{const se=await ce(`/api/mcp/cli/remove/${L}?scope=${W}`,{method:"DELETE"});if(se.ok){const E=await se.json();if(E.success)return await ht(),!0;throw new Error(E.error||"Failed to delete server via Claude CLI")}else{const E=await se.json();throw new Error(E.error||"Failed to delete server")}}catch(se){throw console.error("Error deleting MCP server:",se),se}},Zt=async L=>{try{Ee&&await Rt(Ee.id);const W=await ce("/api/codex/mcp/cli/add",{method:"POST",body:JSON.stringify({name:L.name,command:L.config?.command,args:L.config?.args||[],env:L.config?.env||{}})});if(W.ok){const se=await W.json();if(se.success)return await At(),!0;throw new Error(se.error||"Failed to save Codex MCP server")}else{const se=await W.json();throw new Error(se.error||"Failed to save server")}}catch(W){throw console.error("Error saving Codex MCP server:",W),W}},Rt=async L=>{try{const W=await ce(`/api/codex/mcp/cli/remove/${L}`,{method:"DELETE"});if(W.ok){const se=await W.json();if(se.success)return await At(),!0;throw new Error(se.error||"Failed to delete Codex MCP server")}else{const se=await W.json();throw new Error(se.error||"Failed to delete server")}}catch(W){throw console.error("Error deleting Codex MCP server:",W),W}},T=()=>{oe({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),Te(null),Dt(!1)},G=async L=>{L.preventDefault(),tt(!0);try{Ee&&await Rt(Ee.name),await Zt(Y),T(),M("success")}catch(W){alert(`Error: ${W.message}`),M("error")}finally{tt(!1)}};l.useEffect(()=>{e&&(Me(),fe(),j(),F(),ne(P.includes(s)?s:"appearance"))},[e,s]),l.useEffect(()=>{localStorage.setItem("codeEditorTheme",ie),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[ie]),l.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",Ne.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Ne]),l.useEffect(()=>{localStorage.setItem("codeEditorShowMinimap",Ke.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Ke]),l.useEffect(()=>{localStorage.setItem("codeEditorLineNumbers",qe.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[qe]),l.useEffect(()=>{localStorage.setItem("codeEditorFontSize",It),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[It]);const Me=async()=>{try{const L=localStorage.getItem("claude-settings");if(L){const se=JSON.parse(L);d(se.allowedTools||[]),p(se.disallowedTools||[]),k(se.skipPermissions||!1),b(se.projectSortOrder||"name")}else d([]),p([]),k(!1),b("name");const W=localStorage.getItem("codex-settings");if(W){const se=JSON.parse(W);jt(se.permissionMode||"default")}else jt("default");await ht(),await At()}catch(L){console.error("Error loading tool settings:",L),d([]),p([]),k(!1),b("name")}},fe=async()=>{try{const L=await ce("/api/cli/claude/status");if(L.ok){const W=await L.json();xt({authenticated:W.authenticated,email:W.email,loading:!1,error:W.error||null})}else xt({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(L){console.error("Error checking Claude auth status:",L),xt({authenticated:!1,email:null,loading:!1,error:L.message})}},j=async()=>{try{const L=await ce("/api/cli/codex/status");if(L.ok){const W=await L.json();rt({authenticated:W.authenticated,email:W.email,loading:!1,error:W.error||null})}else rt({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(L){console.error("Error checking Codex auth status:",L),rt({authenticated:!1,email:null,loading:!1,error:L.message})}},F=async()=>{try{const L=await ce("/api/cli/gemini/status");if(L.ok){const W=await L.json();qt({authenticated:W.authenticated,email:W.email,loading:!1,error:W.error||null})}else qt({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(L){console.error("Error checking Gemini auth status:",L),qt({authenticated:!1,email:null,loading:!1,error:L.message})}},xe=L=>{L===0&&(M("success"),Ye==="claude"?fe():Ye==="codex"?j():Ye==="gemini"&&F())},ve=()=>{A(!0),M(null);try{const L={allowedTools:c,disallowedTools:u,skipPermissions:S,projectSortOrder:C,lastUpdated:new Date().toISOString()},W={permissionMode:Ve,lastUpdated:new Date().toISOString()};localStorage.setItem("claude-settings",JSON.stringify(L)),localStorage.setItem("codex-settings",JSON.stringify(W)),M("success"),setTimeout(()=>{t()},1e3)}catch(L){console.error("Error saving tool settings:",L),M("error")}finally{A(!1)}},ut=()=>{re({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),X(null),Z(!1),ge("")},U=async L=>{L.preventDefault(),Ce(!0);try{if(q.importMode==="json"){const W=await ce("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:q.name,jsonConfig:q.jsonInput,scope:q.scope,projectPath:q.projectPath})});if(W.ok){const se=await W.json();if(se.success)await ht(),ut(),M("success");else throw new Error(se.error||"Failed to add server via JSON")}else{const se=await W.json();throw new Error(se.error||"Failed to add server")}}else await Qt(q),ut(),M("success")}catch(W){alert(`Error: ${W.message}`),M("error")}finally{Ce(!1)}},ot=(L,W)=>{re(se=>({...se,config:{...se.config,[L]:W}}))};return e?r.jsxs("div",{className:"modal-backdrop fixed inset-0 flex items-center justify-center z-[9999] md:p-4 bg-background/95",children:[r.jsxs("div",{className:"bg-background border border-border md:rounded-lg shadow-xl w-full md:max-w-4xl h-full md:h-[90vh] flex flex-col",children:[r.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-border flex-shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Oc,{className:"w-5 h-5 md:w-6 md:h-6 text-primary"}),r.jsx("h2",{className:"text-lg md:text-xl font-semibold text-foreground",children:i("title")})]}),r.jsx(Pe,{variant:"ghost",size:"sm",onClick:t,className:"text-muted-foreground hover:text-foreground touch-manipulation",children:r.jsx(sr,{className:"w-5 h-5"})})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto",children:[r.jsx("div",{className:"border-b border-border",children:r.jsxs("div",{className:"flex px-4 md:px-6",children:[r.jsx("button",{onClick:()=>ne("appearance"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${O==="appearance"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("mainTabs.appearance")}),r.jsxs("button",{onClick:()=>ne("api"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${O==="api"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[r.jsx(Rc,{className:"w-4 h-4 inline mr-2"}),i("mainTabs.apiTokens")]}),r.jsxs("button",{onClick:()=>ne("channels"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${O==="channels"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[r.jsx(Wf,{className:"w-4 h-4 inline mr-2"}),i("mainTabs.channels","Channels")]})]})}),r.jsxs("div",{className:"p-4 md:p-6 space-y-6 md:space-y-8 pb-safe-area-inset-bottom",children:[O==="appearance"&&r.jsx("div",{className:"space-y-6 md:space-y-8",children:O==="appearance"&&r.jsxs("div",{className:"space-y-6 md:space-y-8",children:[r.jsx("div",{className:"space-y-4",children:r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.darkMode.label")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.darkMode.description")})]}),r.jsxs("button",{onClick:a,className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":o,"aria-label":"Toggle dark mode",children:[r.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),r.jsx("span",{className:`${o?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:o?r.jsx(xa,{className:"w-3.5 h-3.5 text-gray-700"}):r.jsx(ya,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})})}),r.jsx("div",{className:"space-y-4",children:r.jsx(Qu,{})}),r.jsx("div",{className:"space-y-4",children:r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.projectSorting.label")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.projectSorting.description")})]}),r.jsxs("select",{value:C,onChange:L=>b(L.target.value),className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary p-2 w-32",children:[r.jsx("option",{value:"name",children:i("appearanceSettings.projectSorting.alphabetical")}),r.jsx("option",{value:"date",children:i("appearanceSettings.projectSorting.recentActivity")})]})]})})}),r.jsxs("div",{className:"space-y-4",children:[r.jsx("h3",{className:"text-lg font-semibold text-foreground",children:i("appearanceSettings.codeEditor.title")}),r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.theme.label")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.theme.description")})]}),r.jsxs("button",{onClick:()=>ee(ie==="dark"?"light":"dark"),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":ie==="dark","aria-label":"Toggle editor theme",children:[r.jsx("span",{className:"sr-only",children:"Toggle editor theme"}),r.jsx("span",{className:`${ie==="dark"?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:ie==="dark"?r.jsx(xa,{className:"w-3.5 h-3.5 text-gray-700"}):r.jsx(ya,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})}),r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.wordWrap.label")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.wordWrap.description")})]}),r.jsxs("button",{onClick:()=>it(!Ne),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":Ne,"aria-label":"Toggle word wrap",children:[r.jsx("span",{className:"sr-only",children:"Toggle word wrap"}),r.jsx("span",{className:`${Ne?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.showMinimap.label")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.showMinimap.description")})]}),r.jsxs("button",{onClick:()=>Ge(!Ke),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":Ke,"aria-label":"Toggle minimap",children:[r.jsx("span",{className:"sr-only",children:"Toggle minimap"}),r.jsx("span",{className:`${Ke?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.lineNumbers.label")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.lineNumbers.description")})]}),r.jsxs("button",{onClick:()=>lt(!qe),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":qe,"aria-label":"Toggle line numbers",children:[r.jsx("span",{className:"sr-only",children:"Toggle line numbers"}),r.jsx("span",{className:`${qe?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.fontSize.label")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.fontSize.description")})]}),r.jsxs("select",{value:It,onChange:L=>Xe(L.target.value),className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary p-2 w-24",children:[r.jsx("option",{value:"10",children:"10px"}),r.jsx("option",{value:"11",children:"11px"}),r.jsx("option",{value:"12",children:"12px"}),r.jsx("option",{value:"13",children:"13px"}),r.jsx("option",{value:"14",children:"14px"}),r.jsx("option",{value:"15",children:"15px"}),r.jsx("option",{value:"16",children:"16px"}),r.jsx("option",{value:"18",children:"18px"}),r.jsx("option",{value:"20",children:"20px"})]})]})})]})]})}),D&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[110] p-4",children:r.jsxs("div",{className:"bg-background border border-border rounded-lg w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[r.jsx("h3",{className:"text-lg font-medium text-foreground",children:i(z?"mcpForm.title.edit":"mcpForm.title.add")}),r.jsx(Pe,{variant:"ghost",size:"sm",onClick:ut,children:r.jsx(sr,{className:"w-4 h-4"})})]}),r.jsxs("form",{onSubmit:U,className:"p-4 space-y-4",children:[!z&&r.jsxs("div",{className:"flex gap-2 mb-4",children:[r.jsx("button",{type:"button",onClick:()=>re(L=>({...L,importMode:"form"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${q.importMode==="form"?"bg-primary text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:i("mcpForm.importMode.form")}),r.jsx("button",{type:"button",onClick:()=>re(L=>({...L,importMode:"json"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${q.importMode==="json"?"bg-primary text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:i("mcpForm.importMode.json")})]}),q.importMode==="form"&&z&&r.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-3",children:[r.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.scope.label")}),r.jsxs("div",{className:"flex items-center gap-2",children:[q.scope==="user"?r.jsx(ol,{className:"w-4 h-4"}):r.jsx(rn,{className:"w-4 h-4"}),r.jsx("span",{className:"text-sm",children:q.scope==="user"?i("mcpForm.scope.userGlobal"):i("mcpForm.scope.projectLocal")}),q.scope==="local"&&q.projectPath&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",q.projectPath]})]}),r.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:i("mcpForm.scope.cannotChange")})]}),q.importMode==="form"&&!z&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.scope.label")," *"]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{type:"button",onClick:()=>re(L=>({...L,scope:"user",projectPath:""})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${q.scope==="user"?"bg-primary text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:r.jsxs("div",{className:"flex items-center justify-center gap-2",children:[r.jsx(ol,{className:"w-4 h-4"}),r.jsx("span",{children:i("mcpForm.scope.userGlobal")})]})}),r.jsx("button",{type:"button",onClick:()=>re(L=>({...L,scope:"local"})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${q.scope==="local"?"bg-primary text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:r.jsxs("div",{className:"flex items-center justify-center gap-2",children:[r.jsx(rn,{className:"w-4 h-4"}),r.jsx("span",{children:i("mcpForm.scope.projectLocal")})]})})]}),r.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:q.scope==="user"?i("mcpForm.scope.userDescription"):i("mcpForm.scope.projectDescription")})]}),q.scope==="local"&&!z&&r.jsxs("div",{children:[r.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.selectProject")," *"]}),r.jsxs("select",{value:q.projectPath,onChange:L=>re(W=>({...W,projectPath:L.target.value})),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary",required:q.scope==="local",children:[r.jsxs("option",{value:"",children:[i("mcpForm.fields.selectProject"),"..."]}),n.map(L=>r.jsx("option",{value:L.path||L.fullPath,children:L.displayName||L.name},L.name))]}),q.projectPath&&r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:i("mcpForm.projectPath",{path:q.projectPath})})]})]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("div",{className:q.importMode==="json"?"md:col-span-2":"",children:[r.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.serverName")," *"]}),r.jsx(Pt,{value:q.name,onChange:L=>{re(W=>({...W,name:L.target.value}))},placeholder:i("mcpForm.placeholders.serverName"),required:!0})]}),q.importMode==="form"&&r.jsxs("div",{children:[r.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.transportType")," *"]}),r.jsxs("select",{value:q.type,onChange:L=>{re(W=>({...W,type:L.target.value}))},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary",children:[r.jsx("option",{value:"stdio",children:"stdio"}),r.jsx("option",{value:"sse",children:"SSE"}),r.jsx("option",{value:"http",children:"HTTP"})]})]})]}),z&&q.raw&&q.importMode==="form"&&r.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[r.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:i("mcpForm.configDetails",{configFile:z.scope==="global"?"~/.claude.json":"project config"})}),r.jsx("pre",{className:"text-xs bg-gray-100 dark:bg-gray-800 p-3 rounded overflow-x-auto",children:JSON.stringify(q.raw,null,2)})]}),q.importMode==="json"&&r.jsx("div",{className:"space-y-4",children:r.jsxs("div",{children:[r.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.jsonConfig")," *"]}),r.jsx("textarea",{value:q.jsonInput,onChange:L=>{re(W=>({...W,jsonInput:L.target.value}));try{if(L.target.value.trim()){const W=JSON.parse(L.target.value);W.type?W.type==="stdio"&&!W.command?ge(i("mcpForm.validation.stdioRequiresCommand")):(W.type==="http"||W.type==="sse")&&!W.url?ge(i("mcpForm.validation.httpRequiresUrl",{type:W.type})):ge(""):ge(i("mcpForm.validation.missingType"))}}catch{L.target.value.trim()?ge(i("mcpForm.validation.invalidJson")):ge("")}},className:`w-full px-3 py-2 border ${ke?"border-red-500":"border-gray-300 dark:border-gray-600"} bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary font-mono text-sm`,rows:"8",placeholder:`{
|
|
452
|
-
"type": "stdio",
|
|
453
|
-
"command": "/path/to/server",
|
|
454
|
-
"args": ["--api-key", "abc123"],
|
|
455
|
-
"env": {
|
|
456
|
-
"CACHE_DIR": "/tmp"
|
|
457
|
-
}
|
|
458
|
-
}`,required:!0}),ke&&r.jsx("p",{className:"text-xs text-red-500 mt-1",children:ke}),r.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[i("mcpForm.validation.jsonHelp"),r.jsx("br",{}),"• stdio: ",'{"type":"stdio","command":"npx","args":["@upstash/context7-mcp"]}',r.jsx("br",{}),"• http/sse: ",'{"type":"http","url":"https://api.example.com/mcp"}']})]})}),q.importMode==="form"&&q.type==="stdio"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.command")," *"]}),r.jsx(Pt,{value:q.config.command,onChange:L=>ot("command",L.target.value),placeholder:"/path/to/mcp-server",required:!0})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.arguments")}),r.jsx("textarea",{value:Array.isArray(q.config.args)?q.config.args.join(`
|
|
459
|
-
`):"",onChange:L=>ot("args",L.target.value.split(`
|
|
460
|
-
`).filter(W=>W.trim())),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary",rows:"3",placeholder:`--api-key
|
|
461
|
-
abc123`})]})]}),q.importMode==="form"&&(q.type==="sse"||q.type==="http")&&r.jsxs("div",{children:[r.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.url")," *"]}),r.jsx(Pt,{value:q.config.url,onChange:L=>ot("url",L.target.value),placeholder:"https://api.example.com/mcp",type:"url",required:!0})]}),q.importMode==="form"&&r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.envVars")}),r.jsx("textarea",{value:Object.entries(q.config.env||{}).map(([L,W])=>`${L}=${W}`).join(`
|
|
462
|
-
`),onChange:L=>{const W={};L.target.value.split(`
|
|
463
|
-
`).forEach(se=>{const[E,...J]=se.split("=");E&&E.trim()&&(W[E.trim()]=J.join("=").trim())}),ot("env",W)},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary",rows:"3",placeholder:`API_KEY=your-key
|
|
464
|
-
DEBUG=true`})]}),q.importMode==="form"&&(q.type==="sse"||q.type==="http")&&r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.headers")}),r.jsx("textarea",{value:Object.entries(q.config.headers||{}).map(([L,W])=>`${L}=${W}`).join(`
|
|
465
|
-
`),onChange:L=>{const W={};L.target.value.split(`
|
|
466
|
-
`).forEach(se=>{const[E,...J]=se.split("=");E&&E.trim()&&(W[E.trim()]=J.join("=").trim())}),ot("headers",W)},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary",rows:"3",placeholder:`Authorization=Bearer token
|
|
467
|
-
X-API-Key=your-key`})]}),r.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[r.jsx(Pe,{type:"button",variant:"outline",onClick:ut,children:i("mcpForm.actions.cancel")}),r.jsx(Pe,{type:"submit",disabled:Se,className:"bg-purple-600 hover:bg-purple-700 disabled:opacity-50",children:i(Se?"mcpForm.actions.saving":z?"mcpForm.actions.updateServer":"mcpForm.actions.addServer")})]})]})]})}),St&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[110] p-4",children:r.jsxs("div",{className:"bg-background border border-border rounded-lg w-full max-w-lg max-h-[90vh] overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[r.jsx("h3",{className:"text-lg font-medium text-foreground",children:i(Ee?"mcpForm.title.edit":"mcpForm.title.add")}),r.jsx(Pe,{variant:"ghost",size:"sm",onClick:T,children:r.jsx(sr,{className:"w-4 h-4"})})]}),r.jsxs("form",{onSubmit:G,className:"p-4 space-y-4",children:[r.jsxs("div",{children:[r.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.serverName")," *"]}),r.jsx(Pt,{value:Y.name,onChange:L=>oe(W=>({...W,name:L.target.value})),placeholder:i("mcpForm.placeholders.serverName"),required:!0})]}),r.jsxs("div",{children:[r.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.command")," *"]}),r.jsx(Pt,{value:Y.config?.command||"",onChange:L=>oe(W=>({...W,config:{...W.config,command:L.target.value}})),placeholder:"npx @my-org/mcp-server",required:!0})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.arguments")}),r.jsx("textarea",{value:(Y.config?.args||[]).join(`
|
|
468
|
-
`),onChange:L=>oe(W=>({...W,config:{...W.config,args:L.target.value.split(`
|
|
469
|
-
`).filter(se=>se.trim())}})),placeholder:`--port
|
|
470
|
-
3000`,rows:3,className:"w-full px-3 py-2 text-sm bg-background border border-input rounded-md focus:outline-none focus:ring-2 focus:ring-ring"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.envVars")}),r.jsx("textarea",{value:Object.entries(Y.config?.env||{}).map(([L,W])=>`${L}=${W}`).join(`
|
|
471
|
-
`),onChange:L=>{const W={};L.target.value.split(`
|
|
472
|
-
`).forEach(se=>{const[E,...J]=se.split("=");E&&J.length>0&&(W[E.trim()]=J.join("=").trim())}),oe(se=>({...se,config:{...se.config,env:W}}))},placeholder:`API_KEY=xxx
|
|
473
|
-
DEBUG=true`,rows:3,className:"w-full px-3 py-2 text-sm bg-background border border-input rounded-md focus:outline-none focus:ring-2 focus:ring-ring"})]}),r.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t border-border",children:[r.jsx(Pe,{type:"button",variant:"outline",onClick:T,children:i("mcpForm.actions.cancel")}),r.jsx(Pe,{type:"submit",disabled:Fe||!Y.name||!Y.config?.command,className:"bg-green-600 hover:bg-green-700 text-white",children:i(Fe?"mcpForm.actions.saving":Ee?"mcpForm.actions.updateServer":"mcpForm.actions.addServer")})]})]})]})}),O==="api"&&r.jsx("div",{className:"space-y-6 md:space-y-8",children:r.jsx(Wb,{})}),O==="channels"&&r.jsx("div",{className:"space-y-6 md:space-y-8",children:r.jsx(qb,{projects:n})})]})]}),r.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between p-4 md:p-6 border-t border-border flex-shrink-0 gap-3 pb-safe-area-inset-bottom",children:[r.jsxs("div",{className:"flex items-center justify-center sm:justify-start gap-2 order-2 sm:order-1",children:[w==="success"&&r.jsxs("div",{className:"text-green-600 dark:text-green-400 text-sm flex items-center gap-1",children:[r.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:r.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),i("saveStatus.success")]}),w==="error"&&r.jsxs("div",{className:"text-red-600 dark:text-red-400 text-sm flex items-center gap-1",children:[r.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:r.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),i("saveStatus.error")]})]}),r.jsxs("div",{className:"flex items-center gap-3 order-1 sm:order-2",children:[r.jsx(Pe,{variant:"outline",onClick:t,disabled:I,className:"flex-1 sm:flex-none h-10 touch-manipulation",children:i("footerActions.cancel")}),O!=="channels"&&r.jsx(Pe,{onClick:ve,disabled:I,className:"flex-1 sm:flex-none h-10 bg-primary hover:bg-primary/90 disabled:opacity-50 touch-manipulation",children:I?r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-4 h-4 animate-spin rounded-full border-2 border-white border-t-transparent"}),i("saveStatus.saving")]}):i("footerActions.save")})]})]})]}),r.jsx(Vb,{isOpen:ue,onClose:()=>dt(!1),provider:Ye,project:ze,onComplete:xe,isAuthenticated:Ye==="claude"?Nt.authenticated:Ye==="codex"?$t.authenticated:!1},Ye)]}):null}const Gb=({isOpen:e,onToggle:t,autoExpandTools:n,onAutoExpandChange:s,showRawParameters:o,onShowRawParametersChange:a,showThinking:i,onShowThinkingChange:c,autoScrollToBottom:d,onAutoScrollChange:u,sendByCtrlEnter:p,onSendByCtrlEnterChange:m,isMobile:h})=>{const{t:g}=Mt("settings"),[x,S]=l.useState(e),[k,I]=l.useState(()=>localStorage.getItem("whisperMode")||"default"),{isDarkMode:A}=Ka(),[w,M]=l.useState(()=>{const $=localStorage.getItem("quickSettingsHandlePosition");if($)try{return JSON.parse($).y??50}catch{return localStorage.removeItem("quickSettingsHandlePosition"),50}return 50}),[C,b]=l.useState(!1),[R,B]=l.useState(0),[D,Z]=l.useState(0),[z,X]=l.useState(!1),q=l.useRef(null),re=l.useRef({min:10,max:90}),Se=5;l.useEffect(()=>{S(e)},[e]),l.useEffect(()=>{localStorage.setItem("quickSettingsHandlePosition",JSON.stringify({y:w}))},[w]);const Ce=l.useCallback(()=>h?{bottom:`${window.innerHeight*w/100}px`}:{top:`${w}%`,transform:"translateY(-50%)"},[w,h]),ye=l.useCallback($=>{$.stopPropagation();const N=$.type.includes("touch")?$.touches[0].clientY:$.clientY;B(N),Z(w),X(!1),b(!1)},[w]),de=l.useCallback($=>{if(R===0)return;const N=$.type.includes("touch")?$.touches[0].clientY:$.clientY,O=Math.abs(N-R);if(!C&&O>Se&&(b(!0),X(!0),document.body.style.cursor="grabbing",document.body.style.userSelect="none",$.type.includes("touch")&&(document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%")),!C)return;$.type.includes("touch")&&$.preventDefault();const ne=N-R;let ke;h?ke=-(ne/window.innerHeight)*100:ke=ne/window.innerHeight*100;let ge=D+ke;ge=Math.max(re.current.min,Math.min(re.current.max,ge)),M(ge)},[C,R,D,h,Se]),H=l.useCallback(()=>{b(!1),B(0),document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]);l.useEffect(()=>()=>{document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]),l.useEffect(()=>{if(R!==0){const $=ke=>de(ke),N=()=>H(),O=ke=>de(ke),ne=()=>H();return document.addEventListener("mousemove",$),document.addEventListener("mouseup",N),document.addEventListener("touchmove",O,{passive:!1}),document.addEventListener("touchend",ne),()=>{document.removeEventListener("mousemove",$),document.removeEventListener("mouseup",N),document.removeEventListener("touchmove",O),document.removeEventListener("touchend",ne)}}},[R,de,H]);const Oe=$=>{if(z){$.preventDefault(),X(!1);return}const N=!x;S(N),t(N)};return r.jsxs(r.Fragment,{children:[r.jsx("button",{ref:q,onClick:Oe,onMouseDown:$=>{ye($)},onTouchStart:$=>{ye($)},className:`fixed ${x?"right-64":"right-0"} z-50 ${C?"":"transition-all duration-150 ease-out"} bg-white dark:bg-gray-800 border ${C?"border-primary":"border-gray-200 dark:border-gray-700"} rounded-l-md p-2 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors shadow-lg ${C?"cursor-grabbing":"cursor-pointer"} touch-none`,style:{...Ce(),touchAction:"none",WebkitTouchCallout:"none",WebkitUserSelect:"none"},"aria-label":g(C?"quickSettings.dragHandle.dragging":x?"quickSettings.dragHandle.closePanel":"quickSettings.dragHandle.openPanel"),title:g(C?"quickSettings.dragHandle.draggingStatus":"quickSettings.dragHandle.toggleAndMove"),children:C?r.jsx(yf,{className:"h-5 w-5 text-primary"}):x?r.jsx(yn,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}):r.jsx(Mc,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"})}),r.jsx("div",{className:`fixed top-0 right-0 h-full w-64 bg-background border-l border-border shadow-xl transform transition-transform duration-150 ease-out z-40 ${x?"translate-x-0":"translate-x-full"} ${h?"h-screen":""}`,children:r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",children:r.jsxs("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2",children:[r.jsx(Vf,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}),g("quickSettings.title")]})}),r.jsxs("div",{className:`flex-1 overflow-y-auto overflow-x-hidden p-4 space-y-6 bg-background ${h?"pb-mobile-nav":""}`,children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:g("quickSettings.sections.appearance")}),r.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[A?r.jsx(xa,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}):r.jsx(ya,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.darkMode")]}),r.jsx(zm,{})]}),r.jsx("div",{children:r.jsx(Qu,{compact:!0})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:g("quickSettings.sections.toolDisplay")}),r.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[r.jsx(Lc,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.autoExpandTools")]}),r.jsx("input",{type:"checkbox",checked:n,onChange:$=>s($.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-ring focus:ring-2 bg-gray-100 dark:bg-gray-800 checked:bg-primary"})]}),r.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[r.jsx(Dc,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.showRawParameters")]}),r.jsx("input",{type:"checkbox",checked:o,onChange:$=>a($.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-ring focus:ring-2 bg-gray-100 dark:bg-gray-800 checked:bg-primary"})]}),r.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[r.jsx(_c,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.showThinking")]}),r.jsx("input",{type:"checkbox",checked:i,onChange:$=>c($.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-ring focus:ring-2 bg-gray-100 dark:bg-gray-800 checked:bg-primary"})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:g("quickSettings.sections.viewOptions")}),r.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[r.jsx(Ym,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.autoScrollToBottom")]}),r.jsx("input",{type:"checkbox",checked:d,onChange:$=>u($.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-ring focus:ring-2 bg-gray-100 dark:bg-gray-800 checked:bg-primary"})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:g("quickSettings.sections.inputSettings")}),r.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[r.jsx(Pc,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.sendByCtrlEnter")]}),r.jsx("input",{type:"checkbox",checked:p,onChange:$=>m($.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-ring focus:ring-2 bg-gray-100 dark:bg-gray-800 checked:bg-primary"})]}),r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 ml-3",children:g("quickSettings.sendByCtrlEnterDescription")})]}),r.jsxs("div",{className:"space-y-2",style:{display:"none"},children:[r.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:g("quickSettings.sections.whisperDictation")}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsx("input",{type:"radio",name:"whisperMode",value:"default",checked:k==="default",onChange:()=>{I("default"),localStorage.setItem("whisperMode","default"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-primary focus:ring-ring dark:bg-gray-800 checked:bg-primary"}),r.jsxs("div",{className:"ml-3 flex-1",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[r.jsx(Ps,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.whisper.modes.default")]}),r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:g("quickSettings.whisper.modes.defaultDescription")})]})]}),r.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsx("input",{type:"radio",name:"whisperMode",value:"prompt",checked:k==="prompt",onChange:()=>{I("prompt"),localStorage.setItem("whisperMode","prompt"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-primary focus:ring-ring dark:bg-gray-800 checked:bg-primary"}),r.jsxs("div",{className:"ml-3 flex-1",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[r.jsx(Ja,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.whisper.modes.prompt")]}),r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:g("quickSettings.whisper.modes.promptDescription")})]})]}),r.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsx("input",{type:"radio",name:"whisperMode",value:"vibe",checked:k==="vibe"||k==="instructions"||k==="architect",onChange:()=>{I("vibe"),localStorage.setItem("whisperMode","vibe"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-primary focus:ring-ring dark:bg-gray-800 checked:bg-primary"}),r.jsxs("div",{className:"ml-3 flex-1",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[r.jsx(Ya,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.whisper.modes.vibe")]}),r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:g("quickSettings.whisper.modes.vibeDescription")})]})]})]})]})]})]})}),x&&r.jsx("div",{className:"fixed inset-0 bg-background/80 backdrop-blur-sm z-30 transition-opacity duration-150 ease-out",onClick:Oe})]})},Zu=l.createContext({user:null,token:null,login:()=>{},register:()=>{},logout:()=>{},isLoading:!0,needsSetup:!1,error:null}),mo=()=>{const e=l.useContext(Zu);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e},Jb=({children:e})=>{const[t,n]=l.useState(null),[s,o]=l.useState(localStorage.getItem("auth-token")),[a,i]=l.useState(!0),[c,d]=l.useState(!1),[u,p]=l.useState(null);l.useEffect(()=>{m()},[]);const m=async()=>{try{if(i(!0),p(null),(await(await mt.auth.status()).json()).needsSetup){d(!0),i(!1);return}if(s)try{const A=await mt.auth.user();if(A.ok){const w=await A.json();n(w.user),d(!1)}else localStorage.removeItem("auth-token"),o(null),n(null)}catch(A){console.error("Token verification failed:",A),localStorage.removeItem("auth-token"),o(null),n(null)}}catch(k){console.error("[AuthContext] Auth status check failed:",k),p("Failed to check authentication status")}finally{i(!1)}},S={user:t,token:s,login:async(k,I)=>{try{p(null);const A=await mt.auth.login(k,I),w=await A.json();return A.ok?(o(w.token),n(w.user),localStorage.setItem("auth-token",w.token),{success:!0}):(p(w.error||"Login failed"),{success:!1,error:w.error||"Login failed"})}catch(A){console.error("Login error:",A);const w="Network error. Please try again.";return p(w),{success:!1,error:w}}},register:async(k,I)=>{try{p(null);const A=await mt.auth.register(k,I),w=await A.json();return A.ok?(o(w.token),n(w.user),d(!1),localStorage.setItem("auth-token",w.token),{success:!0}):(p(w.error||"Registration failed"),{success:!1,error:w.error||"Registration failed"})}catch(A){console.error("Registration error:",A);const w="Network error. Please try again.";return p(w),{success:!1,error:w}}},logout:()=>{o(null),n(null),localStorage.removeItem("auth-token"),s&&mt.auth.logout().catch(k=>{console.error("Logout endpoint error:",k)})},isLoading:a,needsSetup:c,error:u};return r.jsx(Zu.Provider,{value:S,children:e})},ep=l.createContext(null),Yb=()=>{const e=l.useContext(ep);if(!e)throw new Error("useWebSocket must be used within a WebSocketProvider");return e},Xb=e=>{const t=window.location.protocol==="https:"?"wss:":"ws:";return e?`${t}//${window.location.host}/ws?token=${encodeURIComponent(e)}`:null},Qb=()=>{const e=l.useRef(null),t=l.useRef(!1),[n,s]=l.useState(null),[o,a]=l.useState(!1),i=l.useRef(null),c=l.useRef(!1),d=l.useRef([]),u=l.useRef([]),p=l.useRef(null),m=l.useRef(0),{token:h}=mo(),g=l.useCallback(()=>{if(p.current||t.current)return;const b=()=>{if(p.current=null,t.current){u.current=[];return}const R=u.current.shift();R&&(m.current+=1,s({...R,__messageSeq:m.current}),u.current.length>0&&(p.current=setTimeout(b,0)))};p.current=setTimeout(b,0)},[]),x=l.useCallback(b=>{u.current.push(b),g()},[g]),S=l.useCallback((b,R)=>{x({type:"connection-error",error:R,provider:b?.provider||(typeof b?.type=="string"?b.type.replace(/-command$/,""):"claude"),sessionId:b?.sessionId||b?.options?.sessionId||null,clientRequestId:b?.clientRequestId||null})},[x]),k=l.useCallback(b=>{b.timeoutId&&(clearTimeout(b.timeoutId),b.timeoutId=null)},[]),I=l.useCallback(b=>{if(b.readyState!==WebSocket.OPEN)return;d.current.splice(0,d.current.length).forEach(B=>{k(B),b.send(JSON.stringify(B.payload))})},[k]),A=l.useCallback(b=>{if(!b||typeof b!="object"||b.clientRequestId)return b;const R=typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`client-${Date.now()}-${Math.random().toString(36).slice(2,10)}`;return{...b,clientRequestId:R}},[]),w=l.useCallback(()=>{if(t.current||c.current)return;const b=e.current;if(!(b&&(b.readyState===WebSocket.OPEN||b.readyState===WebSocket.CONNECTING)))try{const R=Xb(h);if(!R){d.current.splice(0,d.current.length).forEach(Z=>{k(Z),S(Z.payload,"No authentication token found for WebSocket connection")});return}c.current=!0;const B=new WebSocket(R);e.current=B,B.onopen=()=>{c.current=!1,a(!0),e.current=B,x({type:"ws-connection-state",state:"connected"}),I(B)},B.onmessage=D=>{try{const Z=JSON.parse(D.data);x(Z)}catch(Z){console.error("Error parsing WebSocket message:",Z)}},B.onclose=()=>{c.current=!1,a(!1),e.current===B&&(e.current=null),x({type:"ws-connection-state",state:"disconnected"}),i.current=setTimeout(()=>{t.current||w()},3e3)},B.onerror=D=>{console.error("WebSocket error:",D)}}catch(R){c.current=!1,console.error("Error creating WebSocket connection:",R)}},[k,S,I,h]);l.useEffect(()=>(t.current=!1,w(),()=>{c.current=!1,i.current&&clearTimeout(i.current),p.current&&(clearTimeout(p.current),p.current=null),u.current=[],e.current&&(e.current.close(),e.current=null)}),[w,h]),l.useEffect(()=>()=>{t.current=!0,c.current=!1,i.current&&clearTimeout(i.current),p.current&&(clearTimeout(p.current),p.current=null),u.current=[],d.current.splice(0,d.current.length).forEach(R=>k(R)),e.current&&(e.current.close(),e.current=null)},[k]);const M=l.useCallback(b=>{const R=A(b),B=e.current;if(B&&B.readyState===WebSocket.OPEN){try{B.send(JSON.stringify(R))}catch(Z){throw Z}return}x({type:"ws-connection-state",state:"connecting",sessionId:R?.sessionId||R?.options?.sessionId||null,clientRequestId:R?.clientRequestId||null});const D={payload:R,timeoutId:setTimeout(()=>{d.current=d.current.filter(Z=>Z!==D),S(R,"Unable to reach the chat server. Message was not sent.")},1e4)};d.current.push(D),w()},[w,S,x,A]);return l.useMemo(()=>({ws:e.current,sendMessage:M,latestMessage:n,isConnected:o}),[M,n,o])},Zb=({children:e})=>{const t=Qb();return r.jsx(ep.Provider,{value:t,children:e})},ew=()=>{const{t:e}=Mt("auth"),[t,n]=l.useState(""),[s,o]=l.useState(""),[a,i]=l.useState(""),[c,d]=l.useState(!1),[u,p]=l.useState(""),{register:m}=mo(),h=async g=>{if(g.preventDefault(),p(""),s!==a){p(e("register.errors.passwordMismatch"));return}if(t.length<3){p(e("register.errors.usernameTooShort"));return}if(s.length<6){p(e("register.errors.passwordTooShort"));return}d(!0);const x=await m(t,s);x.success||p(x.error),d(!1)};return r.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:r.jsx("div",{className:"w-full max-w-md",children:r.jsxs("div",{className:"bg-card rounded-lg shadow-lg border border-border p-8 space-y-6",children:[r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"flex justify-center mb-4",children:r.jsx(Qn,{size:64})}),r.jsx("h1",{className:"text-2xl font-bold text-foreground",children:e("register.welcomeTitle")}),r.jsx("p",{className:"text-muted-foreground mt-2",children:e("register.description")})]}),r.jsxs("form",{onSubmit:h,className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-foreground mb-1",children:e("register.username")}),r.jsx("input",{type:"text",id:"username",value:t,onChange:g=>n(g.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",placeholder:e("register.placeholders.username"),required:!0,disabled:c})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-foreground mb-1",children:e("register.password")}),r.jsx("input",{type:"password",id:"password",value:s,onChange:g=>o(g.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",placeholder:e("register.placeholders.password"),required:!0,disabled:c})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"confirmPassword",className:"block text-sm font-medium text-foreground mb-1",children:e("register.confirmPassword")}),r.jsx("input",{type:"password",id:"confirmPassword",value:a,onChange:g=>i(g.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",placeholder:e("register.placeholders.confirmPassword"),required:!0,disabled:c})]}),u&&r.jsx("div",{className:"p-3 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-md",children:r.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:u})}),r.jsx("button",{type:"submit",disabled:c,className:"w-full bg-primary hover:bg-primary/90 disabled:bg-primary/60 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200",children:e(c?"register.loading":"register.submit")})]}),r.jsx("div",{className:"text-center",children:r.jsx("p",{className:"text-sm text-muted-foreground",children:e("register.singleUserHint")})})]})})})},tw=()=>{const{t:e}=Mt("auth"),[t,n]=l.useState(""),[s,o]=l.useState(""),[a,i]=l.useState(!1),[c,d]=l.useState(""),{login:u}=mo(),p=async m=>{if(m.preventDefault(),d(""),!t||!s){d(e("login.errors.requiredFields"));return}i(!0);const h=await u(t,s);h.success||d(h.error),i(!1)};return r.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:r.jsx("div",{className:"w-full max-w-md",children:r.jsxs("div",{className:"bg-card rounded-lg shadow-lg border border-border p-8 space-y-6",children:[r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"flex justify-center mb-4",children:r.jsx("img",{src:"/logo-128.png",alt:"Logo",className:"w-16 h-16 rounded-lg shadow-sm"})}),r.jsx("h1",{className:"text-2xl font-bold text-foreground",children:e("login.title")}),r.jsx("p",{className:"text-muted-foreground mt-2",children:e("login.description")})]}),r.jsxs("form",{onSubmit:p,className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-foreground mb-1",children:e("login.username")}),r.jsx("input",{type:"text",id:"username",value:t,onChange:m=>n(m.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",placeholder:e("login.placeholders.username"),required:!0,disabled:a})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-foreground mb-1",children:e("login.password")}),r.jsx("input",{type:"password",id:"password",value:s,onChange:m=>o(m.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",placeholder:e("login.placeholders.password"),required:!0,disabled:a})]}),c&&r.jsx("div",{className:"p-3 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-md",children:r.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:c})}),r.jsx("button",{type:"submit",disabled:a,className:"w-full bg-primary hover:bg-primary/90 disabled:bg-primary/60 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200",children:e(a?"login.loading":"login.submit")})]}),r.jsx("div",{className:"text-center",children:r.jsx("p",{className:"text-sm text-muted-foreground",children:e("login.footer")})})]})})})},rw=()=>r.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"flex justify-center mb-4",children:r.jsx("img",{src:"/logo-128.png",alt:"Logo",className:"w-16 h-16 rounded-lg shadow-sm"})}),r.jsx("h1",{className:"text-2xl font-bold text-foreground mb-2",children:"Axhub Genie"}),r.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[r.jsx("div",{className:"w-2 h-2 bg-primary rounded-full animate-bounce"}),r.jsx("div",{className:"w-2 h-2 bg-primary rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),r.jsx("div",{className:"w-2 h-2 bg-primary rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]}),r.jsx("p",{className:"text-muted-foreground mt-2",children:"Loading..."})]})}),nw=({children:e})=>{const{user:t,isLoading:n,needsSetup:s}=mo();return n?r.jsx(rw,{}):s?r.jsx(ew,{}):t?e:r.jsx(tw,{})};function xn(e,t){const[n,s]=l.useState(()=>{if(typeof window>"u")return t;try{const a=window.localStorage.getItem(e);return a?JSON.parse(a):t}catch(a){return console.log(a),t}});return[n,a=>{if(!(typeof window>"u"))try{const i=a instanceof Function?a(n):a;window.localStorage.setItem(e,JSON.stringify(i)),s(i)}catch(i){console.log(i)}}]}const sw=3e3;function On(e){return typeof e=="string"&&e.trim().length>0}function ow(e="integration"){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${e}_${crypto.randomUUID()}`:`${e}_${Date.now()}_${Math.random().toString(36).slice(2,10)}`}function aw(){return typeof window>"u"?null:`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/agent/ws`}function iw({enabled:e,channel:t,clientId:n,sessionId:s}){const o=l.useRef(null),a=l.useRef(null),i=l.useRef(!1),c=l.useRef(!1),d=l.useRef(0),u=l.useRef(On(s)?s.trim():null),[p,m]=l.useState(null),[h,g]=l.useState(!1),x=l.useMemo(()=>e===!0&&On(t)&&On(n),[e,t,n]);l.useEffect(()=>{u.current=On(s)?s.trim():null},[s]);const S=l.useCallback(C=>{d.current+=1,m({...C,__messageSeq:d.current})},[]),k=l.useCallback(()=>{const C=o.current;C&&(C.close(),o.current=null),g(!1),i.current=!1},[]),I=l.useCallback((C,b=o.current)=>!C||!b||b.readyState!==WebSocket.OPEN?!1:(b.send(JSON.stringify({type:"integration.ack",requestId:C,payload:{accepted:!0,available:!0,pageUrl:typeof window<"u"?window.location.href:null,sessionId:u.current}})),!0),[]),A=l.useCallback((C=o.current)=>{!x||!C||C.readyState!==WebSocket.OPEN||C.send(JSON.stringify({type:"integration.connect",requestId:ow("integration_connect"),payload:{role:"frontend-page",channel:t.trim(),clientId:n.trim(),pageUrl:typeof window<"u"?window.location.href:null,sessionId:On(s)?s.trim():null,capabilities:["context.update","prompt.update","presence.report"]}}))},[t,n,x,s]),w=l.useCallback(()=>{if(!x||c.current||i.current)return;const C=o.current;if(C&&(C.readyState===WebSocket.OPEN||C.readyState===WebSocket.CONNECTING))return;const b=aw();if(!b)return;i.current=!0;const R=new WebSocket(b);o.current=R,R.onopen=()=>{i.current=!1,o.current=R,g(!0),A(R)},R.onmessage=B=>{try{const D=JSON.parse(B.data);D&&typeof D.type=="string"&&D.type.startsWith("integration.")&&(D.type==="integration.ping"&&I(D.requestId||null,R),S(D))}catch(D){console.error("Error parsing integration WebSocket message:",D)}},R.onclose=()=>{o.current===R&&(o.current=null),i.current=!1,g(!1),!c.current&&x&&(a.current=setTimeout(()=>{a.current=null,w()},sw))},R.onerror=B=>{console.error("Integration WebSocket error:",B)}},[A,S,x,I]);l.useEffect(()=>{if(c.current=!1,!x){a.current&&(clearTimeout(a.current),a.current=null),k();return}return w(),()=>{a.current&&(clearTimeout(a.current),a.current=null),k()}},[k,w,x]),l.useEffect(()=>()=>{c.current=!0,a.current&&(clearTimeout(a.current),a.current=null),k()},[k]),l.useEffect(()=>{x&&A()},[A,x,s]);const M=l.useCallback(C=>{const b=o.current;return!b||b.readyState!==WebSocket.OPEN?!1:(b.send(JSON.stringify(C)),!0)},[]);return{integrationWs:o.current,latestIntegrationMessage:p,sendIntegrationMessage:M,isIntegrationConnected:h,isIntegrationEnabled:x}}function kc(){const e=dm(),{sessionId:t}=um(),[n]=pm(),{t:s}=Mt("common");l.useRef(0);const{updateAvailable:o,latestVersion:a,currentVersion:i,releaseInfo:c}=Xu(),[d,u]=l.useState(!1),[p,m]=l.useState([]),[h,g]=l.useState(null),[x,S]=l.useState(null),[k,I]=l.useState(0),[A,w]=l.useState("chat"),[M,C]=l.useState(!1),b=M&&!1,[R,B]=l.useState(!1),[D,Z]=l.useState(!0),[z,X]=l.useState(null),[q,re]=l.useState(!1),[Se,Ce]=l.useState(!1),[ye,de]=l.useState("appearance"),[H,Oe]=l.useState(!1),[$,N]=xn("autoExpandTools",!1),[O,ne]=xn("showRawParameters",!1),[ke,ge]=xn("showThinking",!0),[P,ie]=xn("autoScrollToBottom",!0),[ee,Ne]=xn("sendByCtrlEnter",!1),[it,Ke]=xn("sidebarVisible",!0),[Ge,qe]=l.useState(!1),[lt,It]=l.useState(new Set),[Xe,kt]=l.useState(new Set),je=l.useRef({sessionId:null,status:"idle"}),Ve=l.useCallback((E,J="claude")=>{if(!E)return J;try{const Q=localStorage.getItem("session-provider-map");if(!Q)return J;const we=JSON.parse(Q)?.[E];return typeof we=="string"&&we?we:J}catch{return J}},[]),[jt,St]=l.useState(0),Dt=l.useRef({selectionKey:null}),Y=l.useRef({attemptedKeys:new Set}),oe=n.get("cwd")||n.get("workdir"),Ee=n.get("project")||n.get("projectName"),Te=n.get("provider")||n.get("tool")||n.get("cli");n.get("model");const Fe=n.get("context"),tt=n.get("prompt"),ue=n.get("integrationWs"),dt=n.get("integrationClientId"),Ye=n.get("integrationChannel"),Qe=n.toString(),Lt=p.find(E=>!!(oe&&(E.fullPath===oe||E.path===oe)||Ee&&(E.fullPath===Ee||E.path===Ee)))?.name||null,Nt=l.useCallback((E,J)=>{const Q=n.toString(),he=Q?`${E}?${Q}`:E;e(he,J)},[e,n]),{ws:xt,sendMessage:$t,latestMessage:rt}=Yb(),{latestIntegrationMessage:ft,sendIntegrationMessage:qt}=iw({enabled:ue==="1",clientId:dt,channel:Ye,sessionId:x?.id||t||null}),At=l.useCallback(E=>typeof E!="string"?!1:/^new-session-\d+$/i.test(E)||/^codex-\d+$/i.test(E),[]),ht=l.useRef(null),[Qt,Vt]=l.useState(!1);l.useEffect(()=>{A==="files"&&w("chat")},[A]),l.useEffect(()=>{const E=()=>{const J=window.matchMedia("(display-mode: standalone)").matches||window.navigator.standalone||document.referrer.includes("android-app://");Vt(J),document.addEventListener("touchstart",{}),J?(document.documentElement.classList.add("pwa-mode"),document.body.classList.add("pwa-mode")):(document.documentElement.classList.remove("pwa-mode"),document.body.classList.remove("pwa-mode"))};return E(),window.matchMedia("(display-mode: standalone)").addEventListener("change",E),()=>{window.matchMedia("(display-mode: standalone)").removeEventListener("change",E)}},[]),l.useEffect(()=>{const E=()=>{C(window.innerWidth<768)};return E(),window.addEventListener("resize",E),()=>window.removeEventListener("resize",E)},[]),l.useEffect(()=>{G()},[]),l.useEffect(()=>{if(!oe&&!Ee||p.length===0)return;const E=`${oe||""}::${Ee||""}`;if(Dt.current.selectionKey===E)return;if(x){Dt.current.selectionKey=E;return}let J=null;if(oe&&(J=p.find(Q=>Q.fullPath===oe||Q.path===oe)),!J&&Ee){const Q=Ee.trim().toLowerCase();J=p.find(he=>[he.name,he.displayName,he.path,he.fullPath].some(te=>typeof te=="string"&&te.toLowerCase()===Q))}J&&g(J),Dt.current.selectionKey=E},[oe,Ee,p,x]),l.useEffect(()=>{if(!oe||!oe.trim()||D||x)return;const E=oe.trim();if(p.some(te=>te.fullPath===E||te.path===E))return;const Q=`cwd:${E}`;if(Y.current.attemptedKeys.has(Q))return;Y.current.attemptedKeys.add(Q);let he=!1;return(async()=>{try{const te=await mt.createProject(E),Je=await te.json().catch(()=>({}));if(!te.ok){const vt=Je?.error||"Unknown error";if(vt.includes("Project already configured")){await G();return}console.warn(`[URL] Failed to auto-create project for cwd "${E}": ${vt}`);return}if(he)return;Je?.project&&g(Je.project),await G()}catch(te){console.error(`[URL] Error auto-creating project for cwd "${E}":`,te)}})(),()=>{he=!0}},[oe,p,D,x]);const Zt=(E,J,Q,he)=>{if(!Q||!he)return!0;const we=E?.find(He=>He.name===Q.name),te=J?.find(He=>He.name===Q.name);if(!we||!te)return!1;const Je=He=>[...He.sessions||[],...He.codexSessions||[],...He.geminiSessions||[],...He.opencodeSessions||[]].find(Ct=>Ct.id===he.id),vt=Je(we),yt=Je(te);return!vt||!yt?!1:vt.id===yt.id&&vt.title===yt.title&&vt.created_at===yt.created_at&&vt.updated_at===yt.updated_at},Rt=(E,J)=>!E||!J?E!==J:E.name!==J.name||E.displayName!==J.displayName||E.fullPath!==J.fullPath||E.path!==J.path,T=E=>{if(!E)return!1;if(t===E)return!0;const J=je.current;return J?.sessionId===E&&J?.status!=="missing"&&J?.status!=="error"?!0:lt.has(E)||Xe.has(E)};l.useEffect(()=>{if(rt){if(rt.type==="loading_progress"){ht.current&&(clearTimeout(ht.current),ht.current=null),X(rt),rt.phase==="complete"&&(ht.current=setTimeout(()=>{X(null),ht.current=null},500));return}if(rt.type==="projects_updated"){if(rt.changedFile&&x&&h){const he=rt.changedFile.replace(/\\/g,"/").split("/"),we=he[he.length-1]||"",te=we.replace(".jsonl","").match(/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/i)?.[1]||we.replace(".jsonl","");(rt.changedSessionId||te)===x.id&&(lt.has(x.id)||St(yt=>yt+1))}if(x&<.has(x.id)||lt.size>0&&Array.from(lt).some(Q=>Q.startsWith("new-session-"))){const Q=rt.projects;if(!Zt(p,Q,h,x))return}const J=rt.projects;if(m(J),h){const Q=J.find(he=>he.name===h.name);if(Q&&(Rt(h,Q)&&g(Q),x)){const we=[...Q.sessions||[],...Q.codexSessions||[],...Q.geminiSessions||[],...Q.opencodeSessions||[]].find(te=>te.id===x.id);if(!we)T(x.id)||S(null);else{const te={...we,__provider:x.__provider||Ve(we.id,"claude"),__projectName:x.__projectName||Q.name};(te.title!==x.title||te.updated_at!==x.updated_at||te.__provider!==x.__provider||te.__projectName!==x.__projectName)&&S(te)}}}}}return()=>{ht.current&&(clearTimeout(ht.current),ht.current=null)}},[lt,rt,Xe,Ve,h,x,t]);const G=async(E={})=>{const{background:J=!1}=E;try{J||Z(!0);const he=await(await mt.projects()).json();m(we=>we.length===0||he.some((Je,vt)=>{const yt=we[vt];return yt?Je.name!==yt.name||Je.displayName!==yt.displayName||Je.fullPath!==yt.fullPath||JSON.stringify(Je.sessionMeta)!==JSON.stringify(yt.sessionMeta)||JSON.stringify(Je.sessions)!==JSON.stringify(yt.sessions)||JSON.stringify(Je.codexSessions)!==JSON.stringify(yt.codexSessions)||JSON.stringify(Je.geminiSessions)!==JSON.stringify(yt.geminiSessions)||JSON.stringify(Je.opencodeSessions)!==JSON.stringify(yt.opencodeSessions):!0})||he.length!==we.length?he:we)}catch(Q){console.error("Error fetching projects:",Q)}finally{J||Z(!1)}};window.refreshProjects=(E={})=>G({background:!0,...E}),window.openSettings=l.useCallback((E="appearance")=>{de(E),Ce(!0)},[]),l.useEffect(()=>{if(!t||p.length===0)return;const E=x?.id||null;h?.name;const J=E!==t,Q=Te||x?.__provider||localStorage.getItem("selected-provider")||"claude",he=Ve(t,Q),we=`${t}::${Qe}`,te=At(t),Je=(ct,He,Ot)=>{if(!ct||!He)return!1;const Ct=p.find(Ft=>Ft.name===ct.name)||ct,pr={...He,__provider:Ot||he,__projectName:Ct.name};return g(Ft=>Ft?.name===Ct.name?Ft:Ct),S(Ft=>Ft?.id===pr.id&&Ft?.__provider===pr.__provider&&Ft?.__projectName===pr.__projectName?Ft:pr),J&&w("chat"),je.current={sessionId:t,status:"resolved",resolutionKey:we},!0};for(const ct of p){const He=[{items:ct.sessions,provider:Ve(t,Q)},{items:ct.codexSessions,provider:"codex"},{items:ct.geminiSessions,provider:"gemini"},{items:ct.opencodeSessions,provider:"opencode"}];for(const Ot of He){const Ct=Ot.items?.find(qr=>qr.id===t);if(Ct){Je(ct,Ct,Ot.provider);return}}}if(h&&(S({id:t,title:"New Session",created_at:new Date().toISOString(),updated_at:new Date().toISOString(),__provider:he,__projectName:h.name}),J&&w("chat"),je.current={sessionId:t,status:"placeholder",resolutionKey:we}),te||je.current.sessionId===t&&je.current.status==="resolving"&&je.current.resolutionKey===we)return;je.current={sessionId:t,status:"resolving",resolutionKey:we};let vt=!1;return(async()=>{try{const ct=await mt.resolveSession(t,he),He=await ct.json().catch(()=>({}));if(vt)return;if(!ct.ok||!He?.found||!He?.project||!He?.session){je.current={sessionId:t,status:"missing",resolutionKey:we};return}if(He?.provider)try{const Ft=localStorage.getItem("session-provider-map"),Mn=Ft?JSON.parse(Ft):{};Mn[t]=He.provider,localStorage.setItem("session-provider-map",JSON.stringify(Mn))}catch{}if(!Je(He.project,He.session,He.provider||he))return;const Ct=new URLSearchParams(Qe);(He.project.fullPath||He.project.path)&&Ct.set("project",He.project.fullPath||He.project.path),He.provider&&Ct.set("provider",He.provider);const qr=`/session/${t}${Ct.toString()?`?${Ct.toString()}`:""}`,pr=`${window.location.pathname}${window.location.search}`;qr!==pr&&e(qr,{replace:!0})}catch(ct){vt||(console.error("Error resolving session route:",ct),je.current={sessionId:t,status:"error",resolutionKey:we})}})(),()=>{vt=!0}},[At,e,p,Ve,Qe,h?.name,x?.id,t]);const Me=E=>{g(E),S(null),Nt("/"),M&&B(!1)},fe=E=>{if(S(E),A!=="git"&&A!=="preview"&&w("chat"),M){const J=E.__projectName,Q=h?.name;J!==Q&&B(!1)}Nt(`/session/${E.id}`)},j=E=>{if(E?.name&&typeof window<"u")try{localStorage.removeItem(`chat_messages_${E.name}`),localStorage.removeItem(`draft_input_${E.name}`)}catch(J){console.warn("Failed to clear local chat cache for new session:",J)}g(E),S(null),I(J=>J+1),w("chat"),Nt("/"),M&&B(!1)},F=E=>{x?.id===E&&(S(null),Nt("/")),m(J=>J.map(Q=>({...Q,sessions:Q.sessions?.filter(he=>he.id!==E)||[],sessionMeta:{...Q.sessionMeta,total:Math.max(0,(Q.sessionMeta?.total||0)-1)}})))},xe=async()=>{try{const J=await(await mt.projects()).json();if(m(Q=>J.some((we,te)=>{const Je=Q[te];return Je?we.name!==Je.name||we.displayName!==Je.displayName||we.fullPath!==Je.fullPath||JSON.stringify(we.sessionMeta)!==JSON.stringify(Je.sessionMeta)||JSON.stringify(we.sessions)!==JSON.stringify(Je.sessions):!0})||J.length!==Q.length?J:Q),h){const Q=J.find(he=>he.name===h.name);if(Q&&(Rt(h,Q)&&g(Q),x)){const we=[...Q.sessions||[],...Q.codexSessions||[],...Q.geminiSessions||[],...Q.opencodeSessions||[]].find(te=>te.id===x.id);if(!we)T(x.id)||S(null);else{const te={...we,__provider:x.__provider||Ve(we.id,"claude"),__projectName:x.__projectName||Q.name};(te.title!==x.title||te.updated_at!==x.updated_at||te.__provider!==x.__provider||te.__projectName!==x.__projectName)&&S(te)}}}}catch(E){console.error("Error refreshing sidebar:",E)}},ve=E=>{h?.name===E&&(g(null),S(null),Nt("/")),m(J=>J.filter(Q=>Q.name!==E))},ut=l.useCallback(E=>{E&&It(J=>new Set([...J,E]))},[]),U=l.useCallback(E=>{E&&It(J=>{const Q=new Set(J);return Q.delete(E),Q})},[]),ot=l.useCallback(E=>{E&&kt(J=>new Set([...J,E]))},[]),L=l.useCallback(E=>{E&&kt(J=>{const Q=new Set(J);return Q.delete(E),Q})},[]),W=l.useCallback((E,J=null)=>{E&&(It(Q=>{const he=new Set;for(const we of Q)J&&we===J||we.startsWith("new-session-")||he.add(we);return he.add(E),he}),kt(Q=>{const he=new Set;for(const we of Q)J&&we===J||we.startsWith("new-session-")||he.add(we);return he.add(E),he}))},[]),se=()=>{const{t:E}=Mt("common"),[J,Q]=l.useState(!1),[he,we]=l.useState(""),[te,Je]=l.useState("");if(!d)return null;const vt=ct=>ct?ct.replace(/\b[0-9a-f]{40}\b/gi,"").replace(/(?:^|\s|-)([0-9a-f]{7,10})\b/gi,"").replace(/\*\*Full Changelog\*\*:.*$/gim,"").replace(/https?:\/\/github\.com\/[^\/]+\/[^\/]+\/compare\/[^\s)]+/gi,"").replace(/\n\s*\n\s*\n/g,`
|
|
474
|
-
|
|
475
|
-
`).trim():"",yt=async()=>{Q(!0),we(`Starting update...
|
|
476
|
-
`),Je("");try{const ct=await ce("/api/system/update",{method:"POST"}),He=await ct.json();ct.ok?(we(Ot=>Ot+He.output+`
|
|
477
|
-
`),we(Ot=>Ot+`
|
|
478
|
-
✅ Update completed successfully!
|
|
479
|
-
`),we(Ot=>Ot+`Please restart the server to apply changes.
|
|
480
|
-
`)):(Je(He.error||"Update failed"),we(Ot=>Ot+`
|
|
481
|
-
❌ Update failed: `+(He.error||"Unknown error")+`
|
|
482
|
-
`))}catch(ct){Je(ct.message),we(He=>He+`
|
|
483
|
-
❌ Update failed: `+ct.message+`
|
|
484
|
-
`)}finally{Q(!1)}};return r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[r.jsx("button",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>u(!1),"aria-label":E("versionUpdate.ariaLabels.closeModal")}),r.jsxs("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 w-full max-w-2xl mx-4 p-6 space-y-4 max-h-[90vh] overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-10 h-10 bg-primary/15 dark:bg-primary/25 rounded-lg flex items-center justify-center",children:r.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M9 19l3 3m0 0l3-3m-3 3V10"})})}),r.jsxs("div",{children:[r.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:E("versionUpdate.title")}),r.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:c?.title||E("versionUpdate.newVersionReady")})]})]}),r.jsx("button",{onClick:()=>u(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",children:r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex justify-between items-center p-3 bg-gray-50 dark:bg-gray-700/50 rounded-lg",children:[r.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:E("versionUpdate.currentVersion")}),r.jsx("span",{className:"text-sm text-gray-900 dark:text-white font-mono",children:i})]}),r.jsxs("div",{className:"flex justify-between items-center p-3 bg-primary/10 dark:bg-primary/20 rounded-lg border border-primary/30 dark:border-primary/50",children:[r.jsx("span",{className:"text-sm font-medium text-primary",children:E("versionUpdate.latestVersion")}),r.jsx("span",{className:"text-sm text-primary font-mono",children:a})]})]}),c?.body&&r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:E("versionUpdate.whatsNew")}),c?.htmlUrl&&r.jsxs("a",{href:c.htmlUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:text-primary hover:underline flex items-center gap-1",children:[E("versionUpdate.viewFullRelease"),r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})]}),r.jsx("div",{className:"bg-gray-50 dark:bg-gray-700/50 rounded-lg p-4 border border-gray-200 dark:border-gray-600 max-h-64 overflow-y-auto",children:r.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300 whitespace-pre-wrap prose prose-sm dark:prose-invert max-w-none",children:vt(c.body)})})]}),he&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:E("versionUpdate.updateProgress")}),r.jsx("div",{className:"bg-gray-900 dark:bg-gray-950 rounded-lg p-4 border border-gray-700 max-h-48 overflow-y-auto",children:r.jsx("pre",{className:"text-xs text-green-400 font-mono whitespace-pre-wrap",children:he})})]}),!J&&!he&&r.jsxs("div",{className:"space-y-3",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:E("versionUpdate.manualUpgrade")}),r.jsx("div",{className:"bg-gray-100 dark:bg-gray-800 rounded-lg p-3 border",children:r.jsx("code",{className:"text-sm text-gray-800 dark:text-gray-200 font-mono",children:"npm install -g @axhub/genie@latest"})}),r.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:E("versionUpdate.manualUpgradeHint")})]}),r.jsxs("div",{className:"flex gap-2 pt-2",children:[r.jsx("button",{onClick:()=>u(!1),className:"flex-1 px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-md transition-colors",children:E(he?"versionUpdate.buttons.close":"versionUpdate.buttons.later")}),!he&&r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:()=>{navigator.clipboard.writeText("npm install -g @axhub/genie@latest")},className:"flex-1 px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-md transition-colors",children:E("versionUpdate.buttons.copyCommand")}),r.jsx("button",{onClick:yt,disabled:J,className:"flex-1 px-4 py-2 text-sm font-medium text-white bg-primary hover:bg-primary/90 disabled:bg-primary/60 disabled:cursor-not-allowed rounded-md transition-colors flex items-center justify-center gap-2",children:J?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),E("versionUpdate.buttons.updating")]}):E("versionUpdate.buttons.updateNow")})]})]})]})]})};return r.jsxs("div",{className:"chat-app-shell fixed inset-0 flex overflow-hidden bg-background",style:{"--mobile-nav-total":"0px"},children:[!M&&r.jsx("div",{className:`chat-sidebar h-full flex-shrink-0 overflow-hidden transition-all duration-300 ${it?"w-[22rem]":"w-[4.25rem]"}`,children:r.jsx("div",{className:"h-full overflow-hidden",children:it?r.jsx(hl,{projects:p,selectedProject:h,selectedSession:x,onProjectSelect:Me,onSessionSelect:fe,onNewSession:j,onSessionDelete:F,onProjectDelete:ve,isLoading:D,loadingProgress:z,onRefresh:xe,onShowSettings:()=>Ce(!0),updateAvailable:o,latestVersion:a,currentVersion:i,releaseInfo:c,onShowVersionModal:()=>u(!0),isPWA:Qt,isMobile:M,onToggleSidebar:()=>Ke(!1),lockedProjectName:Lt,showNewProject:Ge,setShowNewProject:qe}):r.jsxs("div",{className:"h-full flex flex-col items-center gap-3 py-4",children:[r.jsx("button",{onClick:()=>Ke(!0),className:"flex h-10 w-10 items-center justify-center rounded-xl bg-background/80 text-foreground shadow-sm transition-colors duration-200 hover:bg-background","aria-label":s("versionUpdate.ariaLabels.showSidebar"),title:s("versionUpdate.ariaLabels.showSidebar"),children:r.jsx(yn,{className:"w-4 h-4 text-foreground"})}),r.jsx("button",{onClick:()=>Ce(!0),className:"rounded-xl bg-background/80 p-2 text-muted-foreground shadow-sm transition-colors duration-200 hover:bg-background hover:text-foreground","aria-label":s("versionUpdate.ariaLabels.settings"),title:s("versionUpdate.ariaLabels.settings"),children:r.jsx(Oc,{className:"w-5 h-5 text-muted-foreground hover:text-foreground transition-colors"})}),o&&r.jsxs("button",{onClick:()=>u(!0),className:"relative rounded-xl bg-background/80 p-2 text-muted-foreground shadow-sm transition-colors duration-200 hover:bg-background hover:text-foreground","aria-label":s("versionUpdate.ariaLabels.updateAvailable"),title:s("versionUpdate.ariaLabels.updateAvailable"),children:[r.jsx(Ja,{className:"w-5 h-5 text-primary"}),r.jsx("span",{className:"absolute top-1 right-1 w-2 h-2 bg-primary rounded-full animate-pulse"})]})]})})}),M&&r.jsxs("div",{className:`fixed inset-0 z-50 flex transition-all duration-150 ease-out ${R?"opacity-100 visible":"opacity-0 invisible"}`,children:[r.jsx("button",{className:"fixed inset-0 bg-black/40 transition-opacity duration-150 ease-out",onClick:E=>{E.stopPropagation(),B(!1)},onTouchStart:E=>{E.preventDefault(),E.stopPropagation(),B(!1)},"aria-label":s("versionUpdate.ariaLabels.closeSidebar")}),r.jsx("div",{className:`chat-sidebar relative h-full w-[85vw] max-w-sm bg-white shadow-xl transform dark:bg-background sm:w-80 ${R?"translate-x-0":"-translate-x-full"}`,onClick:E=>E.stopPropagation(),onTouchStart:E=>E.stopPropagation(),children:r.jsx(hl,{projects:p,selectedProject:h,selectedSession:x,onProjectSelect:Me,onSessionSelect:fe,onNewSession:j,onSessionDelete:F,onProjectDelete:ve,isLoading:D,loadingProgress:z,onRefresh:xe,onShowSettings:()=>Ce(!0),updateAvailable:o,latestVersion:a,currentVersion:i,releaseInfo:c,onShowVersionModal:()=>u(!0),isPWA:Qt,isMobile:M,onToggleSidebar:()=>Ke(!1),lockedProjectName:Lt,showNewProject:Ge,setShowNewProject:qe})})]}),r.jsx("div",{className:"chat-shell flex-1 flex min-w-0 flex-col overflow-hidden ",children:r.jsx(Ub,{selectedProject:h,selectedSession:x,activeTab:A,setActiveTab:w,ws:xt,sendMessage:$t,latestMessage:rt,isMobile:M,isPWA:Qt,onMenuClick:()=>B(!0),isLoading:D,onInputFocusChange:re,onSessionActive:ut,onSessionInactive:U,onSessionProcessing:ot,onSessionNotProcessing:L,processingSessions:Xe,onReplaceTemporarySession:W,onNavigateToSession:E=>Nt(`/session/${E}`),onShowSettings:()=>Ce(!0),autoExpandTools:$,showRawParameters:O,showThinking:ke,autoScrollToBottom:P,sendByCtrlEnter:ee,externalMessageUpdate:jt,urlContext:Fe,urlPrompt:tt,integrationClientId:dt,latestIntegrationMessage:ft,sendIntegrationMessage:qt,onShowNewProject:()=>qe(!0),onNewSession:j,newSessionResetNonce:k})}),b,A==="chat"&&r.jsx(Gb,{isOpen:H,onToggle:Oe,autoExpandTools:$,onAutoExpandChange:N,showRawParameters:O,onShowRawParametersChange:ne,showThinking:ke,onShowThinkingChange:ge,autoScrollToBottom:P,onAutoScrollChange:ie,sendByCtrlEnter:ee,onSendByCtrlEnterChange:Ne,isMobile:M}),r.jsx(Kb,{isOpen:Se,onClose:()=>Ce(!1),projects:p,initialTab:ye}),r.jsx(se,{})]})}function bw(){return r.jsx(Um,{i18n:Gm,children:r.jsx(Wm,{children:r.jsx(Jb,{children:r.jsx(Zb,{children:r.jsx(nw,{children:r.jsx(lm,{basename:window.__ROUTER_BASENAME__||"",children:r.jsxs(cm,{children:[r.jsx(Vo,{path:"/",element:r.jsx(kc,{})}),r.jsx(Vo,{path:"/session/:sessionId",element:r.jsx(kc,{})}),r.jsx(Vo,{path:"/review",element:r.jsx(Hm,{})})]})})})})})})})}export{bw as default};
|