@axhub/genie 0.2.8 → 0.2.9

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.
Files changed (83) hide show
  1. package/LICENSE +21 -675
  2. package/dist/api-docs.html +2 -2
  3. package/dist/assets/App-GBcTeeUS.js +460 -0
  4. package/dist/assets/ReviewApp-C9K--AQE.js +1 -0
  5. package/dist/assets/{_basePickBy-CqJbRZ9y.js → _basePickBy-DR_8uFCo.js} +1 -1
  6. package/dist/assets/{_baseUniq-BS8YH8jO.js → _baseUniq-D0njlQ_7.js} +1 -1
  7. package/dist/assets/{arc-BBmKEN-S.js → arc-CKlr_Rec.js} +1 -1
  8. package/dist/assets/{architectureDiagram-2XIMDMQ5-N5lcb82R.js → architectureDiagram-2XIMDMQ5-BmO_uLUH.js} +1 -1
  9. package/dist/assets/{blockDiagram-WCTKOSBZ-DTMwHuLn.js → blockDiagram-WCTKOSBZ-DhAeO-56.js} +1 -1
  10. package/dist/assets/{c4Diagram-IC4MRINW-BTKlkXI9.js → c4Diagram-IC4MRINW-C67kFoXx.js} +1 -1
  11. package/dist/assets/channel-V3MBjKys.js +1 -0
  12. package/dist/assets/{chunk-4BX2VUAB-DUdoTxAc.js → chunk-4BX2VUAB-mLLagvJi.js} +1 -1
  13. package/dist/assets/{chunk-55IACEB6-Bm_92xe4.js → chunk-55IACEB6-Lx-hOjlM.js} +1 -1
  14. package/dist/assets/{chunk-FMBD7UC4-CGW0g62g.js → chunk-FMBD7UC4-Bt-XmVUV.js} +1 -1
  15. package/dist/assets/{chunk-JSJVCQXG-DYkTH3w1.js → chunk-JSJVCQXG-Cya6gaDV.js} +1 -1
  16. package/dist/assets/{chunk-KX2RTZJC-C9oTlISU.js → chunk-KX2RTZJC-Bd7Ig6tF.js} +1 -1
  17. package/dist/assets/{chunk-NQ4KR5QH-CM50ygWP.js → chunk-NQ4KR5QH-5UAE0Vg-.js} +1 -1
  18. package/dist/assets/{chunk-QZHKN3VN-7dzpYeNJ.js → chunk-QZHKN3VN-BAxZ8m7w.js} +1 -1
  19. package/dist/assets/{chunk-WL4C6EOR-Cm9nQrsr.js → chunk-WL4C6EOR-DjDPvUUP.js} +1 -1
  20. package/dist/assets/classDiagram-VBA2DB6C-C790yYiY.js +1 -0
  21. package/dist/assets/classDiagram-v2-RAHNMMFH-C790yYiY.js +1 -0
  22. package/dist/assets/clone-BbMGfZwt.js +1 -0
  23. package/dist/assets/{cose-bilkent-S5V4N54A-Ccp_p0JZ.js → cose-bilkent-S5V4N54A-D-60XrkJ.js} +1 -1
  24. package/dist/assets/{dagre-KLK3FWXG-fBwTLUp9.js → dagre-KLK3FWXG-bqu3ZS4K.js} +1 -1
  25. package/dist/assets/{diagram-E7M64L7V-CeNVmFUp.js → diagram-E7M64L7V-BueeqoYm.js} +1 -1
  26. package/dist/assets/{diagram-IFDJBPK2-CtavyLGa.js → diagram-IFDJBPK2-D4fDv2E7.js} +1 -1
  27. package/dist/assets/{diagram-P4PSJMXO-CpQTjQwc.js → diagram-P4PSJMXO-WqipY3fN.js} +1 -1
  28. package/dist/assets/{erDiagram-INFDFZHY-B8R5vwhd.js → erDiagram-INFDFZHY-D0oVnO-x.js} +1 -1
  29. package/dist/assets/{flowDiagram-PKNHOUZH-BvkVVwIQ.js → flowDiagram-PKNHOUZH-DzbGyxrr.js} +1 -1
  30. package/dist/assets/{ganttDiagram-A5KZAMGK-DOu3hSNa.js → ganttDiagram-A5KZAMGK-BwhbbgCP.js} +1 -1
  31. package/dist/assets/{gitGraphDiagram-K3NZZRJ6-C7zT67YE.js → gitGraphDiagram-K3NZZRJ6-DZgAh_KM.js} +1 -1
  32. package/dist/assets/{graph-D11wiwHo.js → graph-DzKos-N0.js} +1 -1
  33. package/dist/assets/{highlighted-body-TPN3WLV5-Babpthg-.js → highlighted-body-TPN3WLV5-CKDMgz3X.js} +1 -1
  34. package/dist/assets/{index-DFxzgWoO.js → index-DiQlHzGj.js} +2 -2
  35. package/dist/assets/index-Drat2nB9.css +1 -0
  36. package/dist/assets/{infoDiagram-LFFYTUFH-BmA7IpQG.js → infoDiagram-LFFYTUFH-BFicZbTf.js} +1 -1
  37. package/dist/assets/{ishikawaDiagram-PHBUUO56-BEquZd3E.js → ishikawaDiagram-PHBUUO56-CtihxDxl.js} +1 -1
  38. package/dist/assets/{journeyDiagram-4ABVD52K-BfemGz7f.js → journeyDiagram-4ABVD52K-Du00J8_d.js} +1 -1
  39. package/dist/assets/{kanban-definition-K7BYSVSG-CWja3mln.js → kanban-definition-K7BYSVSG-BJi9S0iQ.js} +1 -1
  40. package/dist/assets/{layout-BLUNf-PJ.js → layout-B80Sityu.js} +1 -1
  41. package/dist/assets/{linear-DukIV_Xv.js → linear-sRQLOf5H.js} +1 -1
  42. package/dist/assets/{mermaid-O7DHMXV3-SgtM28qI.js → mermaid-O7DHMXV3-CBuVs4eJ.js} +6 -6
  43. package/dist/assets/{mindmap-definition-YRQLILUH-4UjqXITU.js → mindmap-definition-YRQLILUH-C5IL_xi-.js} +1 -1
  44. package/dist/assets/{pieDiagram-SKSYHLDU-8AxqJd0M.js → pieDiagram-SKSYHLDU-CeTwlJ8z.js} +1 -1
  45. package/dist/assets/{quadrantDiagram-337W2JSQ-D60m8V8r.js → quadrantDiagram-337W2JSQ-COfUcLWt.js} +1 -1
  46. package/dist/assets/{requirementDiagram-Z7DCOOCP-zqh9jBVf.js → requirementDiagram-Z7DCOOCP-DSb-CJ5B.js} +1 -1
  47. package/dist/assets/{sankeyDiagram-WA2Y5GQK-CDZILTLI.js → sankeyDiagram-WA2Y5GQK-8jtuVb45.js} +1 -1
  48. package/dist/assets/{sequenceDiagram-2WXFIKYE-7BReFd0L.js → sequenceDiagram-2WXFIKYE-C2VpkMwA.js} +1 -1
  49. package/dist/assets/{stateDiagram-RAJIS63D-HPTVdIG4.js → stateDiagram-RAJIS63D-fmwMqxxc.js} +1 -1
  50. package/dist/assets/stateDiagram-v2-FVOUBMTO-9GGXVWrR.js +1 -0
  51. package/dist/assets/{timeline-definition-YZTLITO2-CTVllFgr.js → timeline-definition-YZTLITO2-Dx1hP5lg.js} +1 -1
  52. package/dist/assets/{treemap-KZPCXAKY-BtyxboJZ.js → treemap-KZPCXAKY-CkLOdYCZ.js} +1 -1
  53. package/dist/assets/{vendor-codemirror-Dz7_EqNA.js → vendor-codemirror-BxPY6emf.js} +1 -1
  54. package/dist/assets/{vendor-react-Cpt6D04s.js → vendor-react-xmA_f8ig.js} +1 -1
  55. package/dist/assets/{vennDiagram-LZ73GAT5-D96ZI6Mg.js → vennDiagram-LZ73GAT5-D6KWcnln.js} +1 -1
  56. package/dist/assets/{xychartDiagram-JWTSCODW-eRk-39YO.js → xychartDiagram-JWTSCODW-6fh6qmzN.js} +1 -1
  57. package/dist/index.html +5 -5
  58. package/package.json +3 -3
  59. package/server/acp-runtime/client.js +9 -2
  60. package/server/acp-runtime/session-store.js +4 -4
  61. package/server/cli.js +23 -2
  62. package/server/external-agent/service.js +24 -6
  63. package/server/external-agent/ws.js +63 -3
  64. package/server/index.js +34 -5
  65. package/server/projects.js +536 -161
  66. package/server/routes/session-core.js +149 -86
  67. package/server/session-core/eventStore.js +45 -18
  68. package/server/session-core/providerAdapters.js +50 -13
  69. package/server/session-core/runtimeState.js +8 -0
  70. package/shared/conversationEvents.js +78 -14
  71. package/dist/assets/App-CTKZtqB1.js +0 -460
  72. package/dist/assets/ReviewApp-DM6BNAzR.js +0 -1
  73. package/dist/assets/channel-1oJBvF-0.js +0 -1
  74. package/dist/assets/classDiagram-VBA2DB6C-d5TeKFM4.js +0 -1
  75. package/dist/assets/classDiagram-v2-RAHNMMFH-d5TeKFM4.js +0 -1
  76. package/dist/assets/clone-CinxIlEu.js +0 -1
  77. package/dist/assets/index-YCFGDVKw.css +0 -1
  78. package/dist/assets/stateDiagram-v2-FVOUBMTO-DTUf5_gC.js +0 -1
  79. package/server/_legacy-providers/README.md +0 -30
  80. package/server/_legacy-providers/claude-sdk.js +0 -956
  81. package/server/_legacy-providers/gemini-cli.js +0 -368
  82. package/server/_legacy-providers/openai-codex.js +0 -705
  83. package/server/_legacy-providers/opencode-cli.js +0 -674
@@ -0,0 +1,460 @@
1
+ import{j as r,S as En,F as jo,T as ul,P as pl,E as lr,V as So,a as Ks,g as Ou,D as Cr,R as uo,G as Vs,W as Gs,l as ml,h as ms,b as fl,C as Fu,c as $u,d as Bu,e as rn,f as zu,i as Wu,u as Uu,k as Da,s as Hu,m as qu,n as Ku,o as Vu,p as Gu,q as Ju,r as Yu,t as Xu,v as Qu,w as Zu,x as ep,y as tp}from"./vendor-codemirror-BxPY6emf.js";import{a as l,c as rp,R as jt,d as io,g as hl,B as np,e as op,f as qo,u as sp,h as ap,i as ip,j as lp}from"./vendor-react-xmA_f8ig.js";import{bJ as He,bK as Ur,bL as po,bM as gl,bN as Ze,bO as rr,bP as No,bQ as Js,bR as mr,bS as xl,bT as cp,bU as dp,bV as Er,bW as up,bX as pp,bY as mp,bZ as fp,b_ as hp,b$ as gp,c0 as xp,c1 as yp,c2 as vp,c3 as bp,c4 as xt,c5 as Ys,c6 as St,c7 as hr,c8 as wp,c9 as Je,ca as $t,cb as Ko,cc as fs,cd as hs,ce as gs,cf as lo,cg as xs,ch as Tr,ci as yl,cj as Xs,ck as kp,cl as jp,cm as Sp,cn as Np,co as Cp,cp as Ep,cq as Ap,cr as _p,cs as Ip,ct as Tp,cu as Mp,cv as Pp,cw as Dp,cx as Rp,cy as Lp,cz as Op,cA as Fp,cB as $p,cC as Bp,cD as Hr,cE as zp,cF as vl,cG as Qs,cH as Wp,cI as Ra,cJ as Up,I as Hp,T as qp,U as Kp}from"./mermaid-O7DHMXV3-CBuVs4eJ.js";import{r as Vp,a as Gp,b as Jp}from"./vendor-xterm-DfaPXD3y.js";import{l as La,i as Yp}from"./index-DiQlHzGj.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 Xp=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Qp=He("arrow-down",Xp);/**
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 Zp=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],em=He("arrow-left",Zp);/**
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 tm=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],bl=He("chevron-left",tm);/**
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 rm=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],en=He("chevron-right",rm);/**
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 nm=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Oa=He("circle-check-big",nm);/**
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 om=[["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"}]],ys=He("download",om);/**
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 sm=[["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"}]],zn=He("ellipsis",sm);/**
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 am=[["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"}]],vs=He("external-link",am);/**
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 im=[["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"}]],wl=He("eye",im);/**
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 lm=[["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"}]],cm=He("eye-off",lm);/**
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 dm=[["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"}]],um=He("file-pen-line",dm);/**
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 pm=[["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"}]],mm=He("file-plus-2",pm);/**
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 fm=[["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"}]],hm=He("file-search",fm);/**
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 gm=[["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"}]],Fr=He("folder-open",gm);/**
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 xm=[["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"}]],Lr=He("folder-plus",xm);/**
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 ym=[["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"}]],Vo=He("folder",ym);/**
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 vm=[["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"}]],Go=He("git-branch",vm);/**
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 bm=[["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"}]],Jo=He("git-commit-horizontal",bm);/**
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 wm=[["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"}]],km=He("grip-vertical",wm);/**
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 jm=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],Sm=He("hard-drive",jm);/**
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 Nm=[["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"}]],Fa=He("history",Nm);/**
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 Cm=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Em=He("info",Cm);/**
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 Am=[["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"}]],kl=He("key",Am);/**
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 _m=[["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"}]],jl=He("languages",_m);/**
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 Im=[["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"}]],$a=He("list-todo",Im);/**
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 Tm=[["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"}]],Sl=He("maximize-2",Tm);/**
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 Mm=[["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"}]],Pm=He("message-square-plus",Mm);/**
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 Dm=[["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"}]],bs=He("message-square",Dm);/**
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 Rm=[["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"}]],co=He("mic",Rm);/**
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 Lm=[["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"}]],Om=He("minimize-2",Lm);/**
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 Fm=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],ws=He("moon",Fm);/**
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 $m=[["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"}]],Ba=He("pen-line",$m);/**
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 Bm=[["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"}]],za=He("pen",Bm);/**
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 zm=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],nn=He("plus",zm);/**
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 Wm=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],Wa=He("qr-code",Wm);/**
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 Um=[["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"}]],ar=He("refresh-cw",Um);/**
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 Hm=[["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"}]],qm=He("save",Hm);/**
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 Km=[["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"}]],Vm=He("settings",Km);/**
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 Gm=[["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"}]],Jm=He("settings-2",Gm);/**
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 Ym=[["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"}]],Xm=He("square-terminal",Ym);/**
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 Qm=[["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"}]],Ua=He("star",Qm);/**
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 Zm=[["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"}]],ks=He("sun",Zm);/**
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 ef=[["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"}]],ir=He("trash-2",ef);/**
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 tf=[["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"}]],js=He("triangle-alert",tf);/**
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 rf=[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]],nf=He("unlink",rf);/**
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 of=[["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"}]],Wn=He("upload",of);/**
232
+ * @license lucide-react v0.515.0 - ISC
233
+ *
234
+ * This source code is licensed under the ISC license.
235
+ * See the LICENSE file in the root directory of this source tree.
236
+ */const sf=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],af=He("wifi",sf);/**
237
+ * @license lucide-react v0.515.0 - ISC
238
+ *
239
+ * This source code is licensed under the ISC license.
240
+ * See the LICENSE file in the root directory of this source tree.
241
+ */const lf=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ht=He("x",lf);function cf(e,t=[]){let n=[];function o(a,i){const c=l.createContext(i),d=n.length;n=[...n,i];const u=p=>{const{scope:f,children:h,...g}=p,b=f?.[e]?.[d]||c,y=l.useMemo(()=>g,Object.values(g));return r.jsx(b.Provider,{value:y,children:h})};u.displayName=a+"Provider";function m(p,f){const h=f?.[e]?.[d]||c,g=l.useContext(h);if(g)return g;if(i!==void 0)return i;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[u,m]}const s=()=>{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 s.scopeName=e,[o,df(s,...t)]}function df(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const i=o.reduce((c,{useScope:d,scopeName:u})=>{const p=d(a)[`__scope${u}`];return{...c,...p}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function Nl(e){const t=uf(e),n=l.forwardRef((o,s)=>{const{children:a,...i}=o,c=l.Children.toArray(a),d=c.find(mf);if(d){const u=d.props.children,m=c.map(p=>p===d?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:p);return r.jsx(t,{...i,ref:s,children:l.isValidElement(u)?l.cloneElement(u,void 0,m):null})}return r.jsx(t,{...i,ref:s,children:a})});return n.displayName=`${e}.Slot`,n}function uf(e){const t=l.forwardRef((n,o)=>{const{children:s,...a}=n;if(l.isValidElement(s)){const i=hf(s),c=ff(a,s.props);return s.type!==l.Fragment&&(c.ref=o?Ur(o,i):i),l.cloneElement(s,c)}return l.Children.count(s)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var pf=Symbol("radix.slottable");function mf(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===pf}function ff(e,t){const n={...t};for(const o in t){const s=e[o],a=t[o];/^on[A-Z]/.test(o)?s&&a?n[o]=(...c)=>{const d=a(...c);return s(...c),d}:s&&(n[o]=s):o==="style"?n[o]={...s,...a}:o==="className"&&(n[o]=[s,a].filter(Boolean).join(" "))}return{...e,...n}}function hf(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 gf=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],An=gf.reduce((e,t)=>{const n=Nl(`Primitive.${t}`),o=l.forwardRef((s,a)=>{const{asChild:i,...c}=s,d=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function xf(e,t){e&&rp.flushSync(()=>e.dispatchEvent(t))}function yf(e,t=[]){let n=[];function o(a,i){const c=l.createContext(i),d=n.length;n=[...n,i];const u=p=>{const{scope:f,children:h,...g}=p,b=f?.[e]?.[d]||c,y=l.useMemo(()=>g,Object.values(g));return r.jsx(b.Provider,{value:y,children:h})};u.displayName=a+"Provider";function m(p,f){const h=f?.[e]?.[d]||c,g=l.useContext(h);if(g)return g;if(i!==void 0)return i;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[u,m]}const s=()=>{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 s.scopeName=e,[o,vf(s,...t)]}function vf(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const i=o.reduce((c,{useScope:d,scopeName:u})=>{const p=d(a)[`__scope${u}`];return{...c,...p}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function bf(e){const t=wf(e),n=l.forwardRef((o,s)=>{const{children:a,...i}=o,c=l.Children.toArray(a),d=c.find(jf);if(d){const u=d.props.children,m=c.map(p=>p===d?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:p);return r.jsx(t,{...i,ref:s,children:l.isValidElement(u)?l.cloneElement(u,void 0,m):null})}return r.jsx(t,{...i,ref:s,children:a})});return n.displayName=`${e}.Slot`,n}function wf(e){const t=l.forwardRef((n,o)=>{const{children:s,...a}=n;if(l.isValidElement(s)){const i=Nf(s),c=Sf(a,s.props);return s.type!==l.Fragment&&(c.ref=o?Ur(o,i):i),l.cloneElement(s,c)}return l.Children.count(s)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var kf=Symbol("radix.slottable");function jf(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===kf}function Sf(e,t){const n={...t};for(const o in t){const s=e[o],a=t[o];/^on[A-Z]/.test(o)?s&&a?n[o]=(...c)=>{const d=a(...c);return s(...c),d}:s&&(n[o]=s):o==="style"?n[o]={...s,...a}:o==="className"&&(n[o]=[s,a].filter(Boolean).join(" "))}return{...e,...n}}function Nf(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 Cf=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Cl=Cf.reduce((e,t)=>{const n=bf(`Primitive.${t}`),o=l.forwardRef((s,a)=>{const{asChild:i,...c}=s,d=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{}),Yo="rovingFocusGroup.onEntryFocus",Ef={bubbles:!1,cancelable:!0},_n="RovingFocusGroup",[Ss,El,Af]=gl(_n),[_f,Co]=yf(_n,[Af]),[If,Tf]=_f(_n),Al=l.forwardRef((e,t)=>r.jsx(Ss.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Ss.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Mf,{...e,ref:t})})}));Al.displayName=_n;var Mf=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:o,loop:s=!1,dir:a,currentTabStopId:i,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:u,preventScrollOnEntryFocus:m=!1,...p}=e,f=l.useRef(null),h=rr(t,f),g=No(a),[b,y]=Js({prop:i,defaultProp:c??null,onChange:d,caller:_n}),[k,F]=l.useState(!1),E=mr(u),L=El(n),T=l.useRef(!1),[P,I]=l.useState(0);return l.useEffect(()=>{const z=f.current;if(z)return z.addEventListener(Yo,E),()=>z.removeEventListener(Yo,E)},[E]),r.jsx(If,{scope:n,orientation:o,dir:g,loop:s,currentTabStopId:b,onItemFocus:l.useCallback(z=>y(z),[y]),onItemShiftTab:l.useCallback(()=>F(!0),[]),onFocusableItemAdd:l.useCallback(()=>I(z=>z+1),[]),onFocusableItemRemove:l.useCallback(()=>I(z=>z-1),[]),children:r.jsx(Cl.div,{tabIndex:k||P===0?-1:0,"data-orientation":o,...p,ref:h,style:{outline:"none",...e.style},onMouseDown:Ze(e.onMouseDown,()=>{T.current=!0}),onFocus:Ze(e.onFocus,z=>{const K=!T.current;if(z.target===z.currentTarget&&K&&!k){const S=new CustomEvent(Yo,Ef);if(z.currentTarget.dispatchEvent(S),!S.defaultPrevented){const se=L().filter(le=>le.focusable),ie=se.find(le=>le.active),U=se.find(le=>le.id===b),V=[ie,U,...se].filter(Boolean).map(le=>le.ref.current);Tl(V,m)}}T.current=!1}),onBlur:Ze(e.onBlur,()=>F(!1))})})}),_l="RovingFocusGroupItem",Il=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:o=!0,active:s=!1,tabStopId:a,children:i,...c}=e,d=po(),u=a||d,m=Tf(_l,n),p=m.currentTabStopId===u,f=El(n),{onFocusableItemAdd:h,onFocusableItemRemove:g,currentTabStopId:b}=m;return l.useEffect(()=>{if(o)return h(),()=>g()},[o,h,g]),r.jsx(Ss.ItemSlot,{scope:n,id:u,focusable:o,active:s,children:r.jsx(Cl.span,{tabIndex:p?0:-1,"data-orientation":m.orientation,...c,ref:t,onMouseDown:Ze(e.onMouseDown,y=>{o?m.onItemFocus(u):y.preventDefault()}),onFocus:Ze(e.onFocus,()=>m.onItemFocus(u)),onKeyDown:Ze(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){m.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const k=Rf(y,m.orientation,m.dir);if(k!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let E=f().filter(L=>L.focusable).map(L=>L.ref.current);if(k==="last")E.reverse();else if(k==="prev"||k==="next"){k==="prev"&&E.reverse();const L=E.indexOf(y.currentTarget);E=m.loop?Lf(E,L+1):E.slice(L+1)}setTimeout(()=>Tl(E))}}),children:typeof i=="function"?i({isCurrentTabStop:p,hasTabStop:b!=null}):i})})});Il.displayName=_l;var Pf={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Df(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Rf(e,t,n){const o=Df(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return Pf[o]}function Tl(e,t=!1){const n=document.activeElement;for(const o of e)if(o===n||(o.focus({preventScroll:t}),document.activeElement!==n))return}function Lf(e,t){return e.map((n,o)=>e[(t+o)%e.length])}var Ml=Al,Pl=Il,Ns=["Enter"," "],Of=["ArrowDown","PageUp","Home"],Dl=["ArrowUp","PageDown","End"],Ff=[...Of,...Dl],$f={ltr:[...Ns,"ArrowRight"],rtl:[...Ns,"ArrowLeft"]},Bf={ltr:["ArrowLeft"],rtl:["ArrowRight"]},In="Menu",[jn,zf,Wf]=gl(In),[qr,Rl]=cf(In,[Wf,xl,Co]),Eo=xl(),Ll=Co(),[Uf,Kr]=qr(In),[Hf,Tn]=qr(In),Ol=e=>{const{__scopeMenu:t,open:n=!1,children:o,dir:s,onOpenChange:a,modal:i=!0}=e,c=Eo(t),[d,u]=l.useState(null),m=l.useRef(!1),p=mr(a),f=No(s);return l.useEffect(()=>{const h=()=>{m.current=!0,document.addEventListener("pointerdown",g,{capture:!0,once:!0}),document.addEventListener("pointermove",g,{capture:!0,once:!0})},g=()=>m.current=!1;return document.addEventListener("keydown",h,{capture:!0}),()=>{document.removeEventListener("keydown",h,{capture:!0}),document.removeEventListener("pointerdown",g,{capture:!0}),document.removeEventListener("pointermove",g,{capture:!0})}},[]),r.jsx(cp,{...c,children:r.jsx(Uf,{scope:t,open:n,onOpenChange:p,content:d,onContentChange:u,children:r.jsx(Hf,{scope:t,onClose:l.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:m,dir:f,modal:i,children:o})})})};Ol.displayName=In;var qf="MenuAnchor",Zs=l.forwardRef((e,t)=>{const{__scopeMenu:n,...o}=e,s=Eo(n);return r.jsx(dp,{...s,...o,ref:t})});Zs.displayName=qf;var ea="MenuPortal",[Kf,Fl]=qr(ea,{forceMount:void 0}),$l=e=>{const{__scopeMenu:t,forceMount:n,children:o,container:s}=e,a=Kr(ea,t);return r.jsx(Kf,{scope:t,forceMount:n,children:r.jsx(Er,{present:n||a.open,children:r.jsx(up,{asChild:!0,container:s,children:o})})})};$l.displayName=ea;var er="MenuContent",[Vf,ta]=qr(er),Bl=l.forwardRef((e,t)=>{const n=Fl(er,e.__scopeMenu),{forceMount:o=n.forceMount,...s}=e,a=Kr(er,e.__scopeMenu),i=Tn(er,e.__scopeMenu);return r.jsx(jn.Provider,{scope:e.__scopeMenu,children:r.jsx(Er,{present:o||a.open,children:r.jsx(jn.Slot,{scope:e.__scopeMenu,children:i.modal?r.jsx(Gf,{...s,ref:t}):r.jsx(Jf,{...s,ref:t})})})})}),Gf=l.forwardRef((e,t)=>{const n=Kr(er,e.__scopeMenu),o=l.useRef(null),s=rr(t,o);return l.useEffect(()=>{const a=o.current;if(a)return pp(a)},[]),r.jsx(ra,{...e,ref:s,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Ze(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Jf=l.forwardRef((e,t)=>{const n=Kr(er,e.__scopeMenu);return r.jsx(ra,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Yf=Nl("MenuContent.ScrollLock"),ra=l.forwardRef((e,t)=>{const{__scopeMenu:n,loop:o=!1,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:c,onEntryFocus:d,onEscapeKeyDown:u,onPointerDownOutside:m,onFocusOutside:p,onInteractOutside:f,onDismiss:h,disableOutsideScroll:g,...b}=e,y=Kr(er,n),k=Tn(er,n),F=Eo(n),E=Ll(n),L=zf(n),[T,P]=l.useState(null),I=l.useRef(null),z=rr(t,I,y.onContentChange),K=l.useRef(0),S=l.useRef(""),se=l.useRef(0),ie=l.useRef(null),U=l.useRef("right"),Q=l.useRef(0),V=g?fp:l.Fragment,le=g?{as:Yf,allowPinchZoom:!0}:void 0,ce=G=>{const Ae=S.current+G,O=L().filter(ne=>!ne.disabled),Z=document.activeElement,ae=O.find(ne=>ne.ref.current===Z)?.textValue,be=O.map(ne=>ne.textValue),ye=lh(be,Ae,ae),ke=O.find(ne=>ne.textValue===ye)?.ref.current;(function ne(Se){S.current=Se,window.clearTimeout(K.current),Se!==""&&(K.current=window.setTimeout(()=>ne(""),1e3))})(Ae),ke&&setTimeout(()=>ke.focus())};l.useEffect(()=>()=>window.clearTimeout(K.current),[]),mp();const ue=l.useCallback(G=>U.current===ie.current?.side&&dh(G,ie.current?.area),[]);return r.jsx(Vf,{scope:n,searchRef:S,onItemEnter:l.useCallback(G=>{ue(G)&&G.preventDefault()},[ue]),onItemLeave:l.useCallback(G=>{ue(G)||(I.current?.focus(),P(null))},[ue]),onTriggerLeave:l.useCallback(G=>{ue(G)&&G.preventDefault()},[ue]),pointerGraceTimerRef:se,onPointerGraceIntentChange:l.useCallback(G=>{ie.current=G},[]),children:r.jsx(V,{...le,children:r.jsx(hp,{asChild:!0,trapped:s,onMountAutoFocus:Ze(a,G=>{G.preventDefault(),I.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:r.jsx(gp,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:u,onPointerDownOutside:m,onFocusOutside:p,onInteractOutside:f,onDismiss:h,children:r.jsx(Ml,{asChild:!0,...E,dir:k.dir,orientation:"vertical",loop:o,currentTabStopId:T,onCurrentTabStopIdChange:P,onEntryFocus:Ze(d,G=>{k.isUsingKeyboardRef.current||G.preventDefault()}),preventScrollOnEntryFocus:!0,children:r.jsx(xp,{role:"menu","aria-orientation":"vertical","data-state":rc(y.open),"data-radix-menu-content":"",dir:k.dir,...F,...b,ref:z,style:{outline:"none",...b.style},onKeyDown:Ze(b.onKeyDown,G=>{const O=G.target.closest("[data-radix-menu-content]")===G.currentTarget,Z=G.ctrlKey||G.altKey||G.metaKey,ae=G.key.length===1;O&&(G.key==="Tab"&&G.preventDefault(),!Z&&ae&&ce(G.key));const be=I.current;if(G.target!==be||!Ff.includes(G.key))return;G.preventDefault();const ke=L().filter(ne=>!ne.disabled).map(ne=>ne.ref.current);Dl.includes(G.key)&&ke.reverse(),ah(ke)}),onBlur:Ze(e.onBlur,G=>{G.currentTarget.contains(G.target)||(window.clearTimeout(K.current),S.current="")}),onPointerMove:Ze(e.onPointerMove,Sn(G=>{const Ae=G.target,O=Q.current!==G.clientX;if(G.currentTarget.contains(Ae)&&O){const Z=G.clientX>Q.current?"right":"left";U.current=Z,Q.current=G.clientX}}))})})})})})})});Bl.displayName=er;var Xf="MenuGroup",na=l.forwardRef((e,t)=>{const{__scopeMenu:n,...o}=e;return r.jsx(An.div,{role:"group",...o,ref:t})});na.displayName=Xf;var Qf="MenuLabel",zl=l.forwardRef((e,t)=>{const{__scopeMenu:n,...o}=e;return r.jsx(An.div,{...o,ref:t})});zl.displayName=Qf;var mo="MenuItem",Ha="menu.itemSelect",Ao=l.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:o,...s}=e,a=l.useRef(null),i=Tn(mo,e.__scopeMenu),c=ta(mo,e.__scopeMenu),d=rr(t,a),u=l.useRef(!1),m=()=>{const p=a.current;if(!n&&p){const f=new CustomEvent(Ha,{bubbles:!0,cancelable:!0});p.addEventListener(Ha,h=>o?.(h),{once:!0}),xf(p,f),f.defaultPrevented?u.current=!1:i.onClose()}};return r.jsx(Wl,{...s,ref:d,disabled:n,onClick:Ze(e.onClick,m),onPointerDown:p=>{e.onPointerDown?.(p),u.current=!0},onPointerUp:Ze(e.onPointerUp,p=>{u.current||p.currentTarget?.click()}),onKeyDown:Ze(e.onKeyDown,p=>{const f=c.searchRef.current!=="";n||f&&p.key===" "||Ns.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});Ao.displayName=mo;var Wl=l.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:o=!1,textValue:s,...a}=e,i=ta(mo,n),c=Ll(n),d=l.useRef(null),u=rr(t,d),[m,p]=l.useState(!1),[f,h]=l.useState("");return l.useEffect(()=>{const g=d.current;g&&h((g.textContent??"").trim())},[a.children]),r.jsx(jn.ItemSlot,{scope:n,disabled:o,textValue:s??f,children:r.jsx(Pl,{asChild:!0,...c,focusable:!o,children:r.jsx(An.div,{role:"menuitem","data-highlighted":m?"":void 0,"aria-disabled":o||void 0,"data-disabled":o?"":void 0,...a,ref:u,onPointerMove:Ze(e.onPointerMove,Sn(g=>{o?i.onItemLeave(g):(i.onItemEnter(g),g.defaultPrevented||g.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ze(e.onPointerLeave,Sn(g=>i.onItemLeave(g))),onFocus:Ze(e.onFocus,()=>p(!0)),onBlur:Ze(e.onBlur,()=>p(!1))})})})}),Zf="MenuCheckboxItem",Ul=l.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:o,...s}=e;return r.jsx(Gl,{scope:e.__scopeMenu,checked:n,children:r.jsx(Ao,{role:"menuitemcheckbox","aria-checked":fo(n)?"mixed":n,...s,ref:t,"data-state":sa(n),onSelect:Ze(s.onSelect,()=>o?.(fo(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Ul.displayName=Zf;var Hl="MenuRadioGroup",[eh,th]=qr(Hl,{value:void 0,onValueChange:()=>{}}),ql=l.forwardRef((e,t)=>{const{value:n,onValueChange:o,...s}=e,a=mr(o);return r.jsx(eh,{scope:e.__scopeMenu,value:n,onValueChange:a,children:r.jsx(na,{...s,ref:t})})});ql.displayName=Hl;var Kl="MenuRadioItem",Vl=l.forwardRef((e,t)=>{const{value:n,...o}=e,s=th(Kl,e.__scopeMenu),a=n===s.value;return r.jsx(Gl,{scope:e.__scopeMenu,checked:a,children:r.jsx(Ao,{role:"menuitemradio","aria-checked":a,...o,ref:t,"data-state":sa(a),onSelect:Ze(o.onSelect,()=>s.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});Vl.displayName=Kl;var oa="MenuItemIndicator",[Gl,rh]=qr(oa,{checked:!1}),Jl=l.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:o,...s}=e,a=rh(oa,n);return r.jsx(Er,{present:o||fo(a.checked)||a.checked===!0,children:r.jsx(An.span,{...s,ref:t,"data-state":sa(a.checked)})})});Jl.displayName=oa;var nh="MenuSeparator",Yl=l.forwardRef((e,t)=>{const{__scopeMenu:n,...o}=e;return r.jsx(An.div,{role:"separator","aria-orientation":"horizontal",...o,ref:t})});Yl.displayName=nh;var oh="MenuArrow",Xl=l.forwardRef((e,t)=>{const{__scopeMenu:n,...o}=e,s=Eo(n);return r.jsx(yp,{...s,...o,ref:t})});Xl.displayName=oh;var sh="MenuSub",[bw,Ql]=qr(sh),yn="MenuSubTrigger",Zl=l.forwardRef((e,t)=>{const n=Kr(yn,e.__scopeMenu),o=Tn(yn,e.__scopeMenu),s=Ql(yn,e.__scopeMenu),a=ta(yn,e.__scopeMenu),i=l.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:d}=a,u={__scopeMenu:e.__scopeMenu},m=l.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return l.useEffect(()=>m,[m]),l.useEffect(()=>{const p=c.current;return()=>{window.clearTimeout(p),d(null)}},[c,d]),r.jsx(Zs,{asChild:!0,...u,children:r.jsx(Wl,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":s.contentId,"data-state":rc(n.open),...e,ref:Ur(t,s.onTriggerChange),onClick:p=>{e.onClick?.(p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Ze(e.onPointerMove,Sn(p=>{a.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(a.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),m()},100))})),onPointerLeave:Ze(e.onPointerLeave,Sn(p=>{m();const f=n.content?.getBoundingClientRect();if(f){const h=n.content?.dataset.side,g=h==="right",b=g?-5:5,y=f[g?"left":"right"],k=f[g?"right":"left"];a.onPointerGraceIntentChange({area:[{x:p.clientX+b,y:p.clientY},{x:y,y:f.top},{x:k,y:f.top},{x:k,y:f.bottom},{x:y,y:f.bottom}],side:h}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(p),p.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:Ze(e.onKeyDown,p=>{const f=a.searchRef.current!=="";e.disabled||f&&p.key===" "||$f[o.dir].includes(p.key)&&(n.onOpenChange(!0),n.content?.focus(),p.preventDefault())})})})});Zl.displayName=yn;var ec="MenuSubContent",tc=l.forwardRef((e,t)=>{const n=Fl(er,e.__scopeMenu),{forceMount:o=n.forceMount,...s}=e,a=Kr(er,e.__scopeMenu),i=Tn(er,e.__scopeMenu),c=Ql(ec,e.__scopeMenu),d=l.useRef(null),u=rr(t,d);return r.jsx(jn.Provider,{scope:e.__scopeMenu,children:r.jsx(Er,{present:o||a.open,children:r.jsx(jn.Slot,{scope:e.__scopeMenu,children:r.jsx(ra,{id:c.contentId,"aria-labelledby":c.triggerId,...s,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:m=>{i.isUsingKeyboardRef.current&&d.current?.focus(),m.preventDefault()},onCloseAutoFocus:m=>m.preventDefault(),onFocusOutside:Ze(e.onFocusOutside,m=>{m.target!==c.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:Ze(e.onEscapeKeyDown,m=>{i.onClose(),m.preventDefault()}),onKeyDown:Ze(e.onKeyDown,m=>{const p=m.currentTarget.contains(m.target),f=Bf[i.dir].includes(m.key);p&&f&&(a.onOpenChange(!1),c.trigger?.focus(),m.preventDefault())})})})})})});tc.displayName=ec;function rc(e){return e?"open":"closed"}function fo(e){return e==="indeterminate"}function sa(e){return fo(e)?"indeterminate":e?"checked":"unchecked"}function ah(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function ih(e,t){return e.map((n,o)=>e[(t+o)%e.length])}function lh(e,t,n){const s=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let i=ih(e,Math.max(a,0));s.length===1&&(i=i.filter(u=>u!==n));const d=i.find(u=>u.toLowerCase().startsWith(s.toLowerCase()));return d!==n?d:void 0}function ch(e,t){const{x:n,y:o}=e;let s=!1;for(let a=0,i=t.length-1;a<t.length;i=a++){const c=t[a],d=t[i],u=c.x,m=c.y,p=d.x,f=d.y;m>o!=f>o&&n<(p-u)*(o-m)/(f-m)+u&&(s=!s)}return s}function dh(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return ch(n,t)}function Sn(e){return t=>t.pointerType==="mouse"?e(t):void 0}var uh=Ol,ph=Zs,mh=$l,fh=Bl,hh=na,gh=zl,xh=Ao,yh=Ul,vh=ql,bh=Vl,wh=Jl,kh=Yl,jh=Xl,Sh=Zl,Nh=tc;function Ch(e,t=[]){let n=[];function o(a,i){const c=l.createContext(i),d=n.length;n=[...n,i];const u=p=>{const{scope:f,children:h,...g}=p,b=f?.[e]?.[d]||c,y=l.useMemo(()=>g,Object.values(g));return r.jsx(b.Provider,{value:y,children:h})};u.displayName=a+"Provider";function m(p,f){const h=f?.[e]?.[d]||c,g=l.useContext(h);if(g)return g;if(i!==void 0)return i;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[u,m]}const s=()=>{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 s.scopeName=e,[o,Eh(s,...t)]}function Eh(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const i=o.reduce((c,{useScope:d,scopeName:u})=>{const p=d(a)[`__scope${u}`];return{...c,...p}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function Ah(e){const t=_h(e),n=l.forwardRef((o,s)=>{const{children:a,...i}=o,c=l.Children.toArray(a),d=c.find(Th);if(d){const u=d.props.children,m=c.map(p=>p===d?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:p);return r.jsx(t,{...i,ref:s,children:l.isValidElement(u)?l.cloneElement(u,void 0,m):null})}return r.jsx(t,{...i,ref:s,children:a})});return n.displayName=`${e}.Slot`,n}function _h(e){const t=l.forwardRef((n,o)=>{const{children:s,...a}=n;if(l.isValidElement(s)){const i=Ph(s),c=Mh(a,s.props);return s.type!==l.Fragment&&(c.ref=o?Ur(o,i):i),l.cloneElement(s,c)}return l.Children.count(s)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Ih=Symbol("radix.slottable");function Th(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Ih}function Mh(e,t){const n={...t};for(const o in t){const s=e[o],a=t[o];/^on[A-Z]/.test(o)?s&&a?n[o]=(...c)=>{const d=a(...c);return s(...c),d}:s&&(n[o]=s):o==="style"?n[o]={...s,...a}:o==="className"&&(n[o]=[s,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 Dh=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Rh=Dh.reduce((e,t)=>{const n=Ah(`Primitive.${t}`),o=l.forwardRef((s,a)=>{const{asChild:i,...c}=s,d=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{}),_o="DropdownMenu",[Lh,ww]=Ch(_o,[Rl]),zt=Rl(),[Oh,nc]=Lh(_o),oc=e=>{const{__scopeDropdownMenu:t,children:n,dir:o,open:s,defaultOpen:a,onOpenChange:i,modal:c=!0}=e,d=zt(t),u=l.useRef(null),[m,p]=Js({prop:s,defaultProp:a??!1,onChange:i,caller:_o});return r.jsx(Oh,{scope:t,triggerId:po(),triggerRef:u,contentId:po(),open:m,onOpenChange:p,onOpenToggle:l.useCallback(()=>p(f=>!f),[p]),modal:c,children:r.jsx(uh,{...d,open:m,onOpenChange:p,dir:o,modal:c,children:n})})};oc.displayName=_o;var sc="DropdownMenuTrigger",ac=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:o=!1,...s}=e,a=nc(sc,n),i=zt(n);return r.jsx(ph,{asChild:!0,...i,children:r.jsx(Rh.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":o?"":void 0,disabled:o,...s,ref:Ur(t,a.triggerRef),onPointerDown:Ze(e.onPointerDown,c=>{!o&&c.button===0&&c.ctrlKey===!1&&(a.onOpenToggle(),a.open||c.preventDefault())}),onKeyDown:Ze(e.onKeyDown,c=>{o||(["Enter"," "].includes(c.key)&&a.onOpenToggle(),c.key==="ArrowDown"&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});ac.displayName=sc;var Fh="DropdownMenuPortal",ic=e=>{const{__scopeDropdownMenu:t,...n}=e,o=zt(t);return r.jsx(mh,{...o,...n})};ic.displayName=Fh;var lc="DropdownMenuContent",cc=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=nc(lc,n),a=zt(n),i=l.useRef(!1);return r.jsx(fh,{id:s.contentId,"aria-labelledby":s.triggerId,...a,...o,ref:t,onCloseAutoFocus:Ze(e.onCloseAutoFocus,c=>{i.current||s.triggerRef.current?.focus(),i.current=!1,c.preventDefault()}),onInteractOutside:Ze(e.onInteractOutside,c=>{const d=c.detail.originalEvent,u=d.button===0&&d.ctrlKey===!0,m=d.button===2||u;(!s.modal||m)&&(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)"}})});cc.displayName=lc;var $h="DropdownMenuGroup",Bh=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=zt(n);return r.jsx(hh,{...s,...o,ref:t})});Bh.displayName=$h;var zh="DropdownMenuLabel",Wh=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=zt(n);return r.jsx(gh,{...s,...o,ref:t})});Wh.displayName=zh;var Uh="DropdownMenuItem",dc=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=zt(n);return r.jsx(xh,{...s,...o,ref:t})});dc.displayName=Uh;var Hh="DropdownMenuCheckboxItem",qh=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=zt(n);return r.jsx(yh,{...s,...o,ref:t})});qh.displayName=Hh;var Kh="DropdownMenuRadioGroup",Vh=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=zt(n);return r.jsx(vh,{...s,...o,ref:t})});Vh.displayName=Kh;var Gh="DropdownMenuRadioItem",Jh=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=zt(n);return r.jsx(bh,{...s,...o,ref:t})});Jh.displayName=Gh;var Yh="DropdownMenuItemIndicator",Xh=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=zt(n);return r.jsx(wh,{...s,...o,ref:t})});Xh.displayName=Yh;var Qh="DropdownMenuSeparator",uc=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=zt(n);return r.jsx(kh,{...s,...o,ref:t})});uc.displayName=Qh;var Zh="DropdownMenuArrow",eg=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=zt(n);return r.jsx(jh,{...s,...o,ref:t})});eg.displayName=Zh;var tg="DropdownMenuSubTrigger",rg=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=zt(n);return r.jsx(Sh,{...s,...o,ref:t})});rg.displayName=tg;var ng="DropdownMenuSubContent",og=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=zt(n);return r.jsx(Nh,{...s,...o,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)"}})});og.displayName=ng;var Un=oc,Hn=ac,qn=ic,Kn=cc,ur=dc,qa=uc;function sg(e){const t=ag(e),n=l.forwardRef((o,s)=>{const{children:a,...i}=o,c=l.Children.toArray(a),d=c.find(lg);if(d){const u=d.props.children,m=c.map(p=>p===d?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:p);return r.jsx(t,{...i,ref:s,children:l.isValidElement(u)?l.cloneElement(u,void 0,m):null})}return r.jsx(t,{...i,ref:s,children:a})});return n.displayName=`${e}.Slot`,n}function ag(e){const t=l.forwardRef((n,o)=>{const{children:s,...a}=n;if(l.isValidElement(s)){const i=dg(s),c=cg(a,s.props);return s.type!==l.Fragment&&(c.ref=o?Ur(o,i):i),l.cloneElement(s,c)}return l.Children.count(s)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var ig=Symbol("radix.slottable");function lg(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===ig}function cg(e,t){const n={...t};for(const o in t){const s=e[o],a=t[o];/^on[A-Z]/.test(o)?s&&a?n[o]=(...c)=>{const d=a(...c);return s(...c),d}:s&&(n[o]=s):o==="style"?n[o]={...s,...a}:o==="className"&&(n[o]=[s,a].filter(Boolean).join(" "))}return{...e,...n}}function dg(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 ug=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Mn=ug.reduce((e,t)=>{const n=sg(`Primitive.${t}`),o=l.forwardRef((s,a)=>{const{asChild:i,...c}=s,d=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function pg(e,t=[]){let n=[];function o(a,i){const c=l.createContext(i),d=n.length;n=[...n,i];const u=p=>{const{scope:f,children:h,...g}=p,b=f?.[e]?.[d]||c,y=l.useMemo(()=>g,Object.values(g));return r.jsx(b.Provider,{value:y,children:h})};u.displayName=a+"Provider";function m(p,f){const h=f?.[e]?.[d]||c,g=l.useContext(h);if(g)return g;if(i!==void 0)return i;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[u,m]}const s=()=>{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 s.scopeName=e,[o,mg(s,...t)]}function mg(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const i=o.reduce((c,{useScope:d,scopeName:u})=>{const p=d(a)[`__scope${u}`];return{...c,...p}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function fg(e,t){return l.useReducer((n,o)=>t[n][o]??n,e)}var aa="ScrollArea",[pc,kw]=pg(aa),[hg,nr]=pc(aa),mc=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:o="hover",dir:s,scrollHideDelay:a=600,...i}=e,[c,d]=l.useState(null),[u,m]=l.useState(null),[p,f]=l.useState(null),[h,g]=l.useState(null),[b,y]=l.useState(null),[k,F]=l.useState(0),[E,L]=l.useState(0),[T,P]=l.useState(!1),[I,z]=l.useState(!1),K=rr(t,se=>d(se)),S=No(s);return r.jsx(hg,{scope:n,type:o,dir:S,scrollHideDelay:a,scrollArea:c,viewport:u,onViewportChange:m,content:p,onContentChange:f,scrollbarX:h,onScrollbarXChange:g,scrollbarXEnabled:T,onScrollbarXEnabledChange:P,scrollbarY:b,onScrollbarYChange:y,scrollbarYEnabled:I,onScrollbarYEnabledChange:z,onCornerWidthChange:F,onCornerHeightChange:L,children:r.jsx(Mn.div,{dir:S,...i,ref:K,style:{position:"relative","--radix-scroll-area-corner-width":k+"px","--radix-scroll-area-corner-height":E+"px",...e.style}})})});mc.displayName=aa;var fc="ScrollAreaViewport",hc=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:o,nonce:s,...a}=e,i=nr(fc,n),c=l.useRef(null),d=rr(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:s}),r.jsx(Mn.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:o})})]})});hc.displayName=fc;var yr="ScrollAreaScrollbar",gc=l.forwardRef((e,t)=>{const{forceMount:n,...o}=e,s=nr(yr,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:i}=s,c=e.orientation==="horizontal";return l.useEffect(()=>(c?a(!0):i(!0),()=>{c?a(!1):i(!1)}),[c,a,i]),s.type==="hover"?r.jsx(gg,{...o,ref:t,forceMount:n}):s.type==="scroll"?r.jsx(xg,{...o,ref:t,forceMount:n}):s.type==="auto"?r.jsx(xc,{...o,ref:t,forceMount:n}):s.type==="always"?r.jsx(ia,{...o,ref:t}):null});gc.displayName=yr;var gg=l.forwardRef((e,t)=>{const{forceMount:n,...o}=e,s=nr(yr,e.__scopeScrollArea),[a,i]=l.useState(!1);return l.useEffect(()=>{const c=s.scrollArea;let d=0;if(c){const u=()=>{window.clearTimeout(d),i(!0)},m=()=>{d=window.setTimeout(()=>i(!1),s.scrollHideDelay)};return c.addEventListener("pointerenter",u),c.addEventListener("pointerleave",m),()=>{window.clearTimeout(d),c.removeEventListener("pointerenter",u),c.removeEventListener("pointerleave",m)}}},[s.scrollArea,s.scrollHideDelay]),r.jsx(Er,{present:n||a,children:r.jsx(xc,{"data-state":a?"visible":"hidden",...o,ref:t})})}),xg=l.forwardRef((e,t)=>{const{forceMount:n,...o}=e,s=nr(yr,e.__scopeScrollArea),a=e.orientation==="horizontal",i=To(()=>d("SCROLL_END"),100),[c,d]=fg("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"),s.scrollHideDelay);return()=>window.clearTimeout(u)}},[c,s.scrollHideDelay,d]),l.useEffect(()=>{const u=s.viewport,m=a?"scrollLeft":"scrollTop";if(u){let p=u[m];const f=()=>{const h=u[m];p!==h&&(d("SCROLL"),i()),p=h};return u.addEventListener("scroll",f),()=>u.removeEventListener("scroll",f)}},[s.viewport,a,d,i]),r.jsx(Er,{present:n||c!=="hidden",children:r.jsx(ia,{"data-state":c==="hidden"?"hidden":"visible",...o,ref:t,onPointerEnter:Ze(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:Ze(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),xc=l.forwardRef((e,t)=>{const n=nr(yr,e.__scopeScrollArea),{forceMount:o,...s}=e,[a,i]=l.useState(!1),c=e.orientation==="horizontal",d=To(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,m=n.viewport.offsetHeight<n.viewport.scrollHeight;i(c?u:m)}},10);return on(n.viewport,d),on(n.content,d),r.jsx(Er,{present:o||a,children:r.jsx(ia,{"data-state":a?"visible":"hidden",...s,ref:t})})}),ia=l.forwardRef((e,t)=>{const{orientation:n="vertical",...o}=e,s=nr(yr,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=kc(c.viewport,c.content),m={...o,sizes:c,onSizesChange:d,hasThumb:u>0&&u<1,onThumbChange:f=>a.current=f,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:f=>i.current=f};function p(f,h){return jg(f,i.current,c,h)}return n==="horizontal"?r.jsx(yg,{...m,ref:t,onThumbPositionChange:()=>{if(s.viewport&&a.current){const f=s.viewport.scrollLeft,h=Ka(f,c,s.dir);a.current.style.transform=`translate3d(${h}px, 0, 0)`}},onWheelScroll:f=>{s.viewport&&(s.viewport.scrollLeft=f)},onDragScroll:f=>{s.viewport&&(s.viewport.scrollLeft=p(f,s.dir))}}):n==="vertical"?r.jsx(vg,{...m,ref:t,onThumbPositionChange:()=>{if(s.viewport&&a.current){const f=s.viewport.scrollTop,h=Ka(f,c);a.current.style.transform=`translate3d(0, ${h}px, 0)`}},onWheelScroll:f=>{s.viewport&&(s.viewport.scrollTop=f)},onDragScroll:f=>{s.viewport&&(s.viewport.scrollTop=p(f))}}):null}),yg=l.forwardRef((e,t)=>{const{sizes:n,onSizesChange:o,...s}=e,a=nr(yr,e.__scopeScrollArea),[i,c]=l.useState(),d=l.useRef(null),u=rr(t,d,a.onScrollbarXChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),r.jsx(vc,{"data-orientation":"horizontal",...s,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":Io(n)+"px",...e.style},onThumbPointerDown:m=>e.onThumbPointerDown(m.x),onDragScroll:m=>e.onDragScroll(m.x),onWheelScroll:(m,p)=>{if(a.viewport){const f=a.viewport.scrollLeft+m.deltaX;e.onWheelScroll(f),Sc(f,p)&&m.preventDefault()}},onResize:()=>{d.current&&a.viewport&&i&&o({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:go(i.paddingLeft),paddingEnd:go(i.paddingRight)}})}})}),vg=l.forwardRef((e,t)=>{const{sizes:n,onSizesChange:o,...s}=e,a=nr(yr,e.__scopeScrollArea),[i,c]=l.useState(),d=l.useRef(null),u=rr(t,d,a.onScrollbarYChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),r.jsx(vc,{"data-orientation":"vertical",...s,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":Io(n)+"px",...e.style},onThumbPointerDown:m=>e.onThumbPointerDown(m.y),onDragScroll:m=>e.onDragScroll(m.y),onWheelScroll:(m,p)=>{if(a.viewport){const f=a.viewport.scrollTop+m.deltaY;e.onWheelScroll(f),Sc(f,p)&&m.preventDefault()}},onResize:()=>{d.current&&a.viewport&&i&&o({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:go(i.paddingTop),paddingEnd:go(i.paddingBottom)}})}})}),[bg,yc]=pc(yr),vc=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:o,hasThumb:s,onThumbChange:a,onThumbPointerUp:i,onThumbPointerDown:c,onThumbPositionChange:d,onDragScroll:u,onWheelScroll:m,onResize:p,...f}=e,h=nr(yr,n),[g,b]=l.useState(null),y=rr(t,K=>b(K)),k=l.useRef(null),F=l.useRef(""),E=h.viewport,L=o.content-o.viewport,T=mr(m),P=mr(d),I=To(p,10);function z(K){if(k.current){const S=K.clientX-k.current.left,se=K.clientY-k.current.top;u({x:S,y:se})}}return l.useEffect(()=>{const K=S=>{const se=S.target;g?.contains(se)&&T(S,L)};return document.addEventListener("wheel",K,{passive:!1}),()=>document.removeEventListener("wheel",K,{passive:!1})},[E,g,L,T]),l.useEffect(P,[o,P]),on(g,I),on(h.content,I),r.jsx(bg,{scope:n,scrollbar:g,hasThumb:s,onThumbChange:mr(a),onThumbPointerUp:mr(i),onThumbPositionChange:P,onThumbPointerDown:mr(c),children:r.jsx(Mn.div,{...f,ref:y,style:{position:"absolute",...f.style},onPointerDown:Ze(e.onPointerDown,K=>{K.button===0&&(K.target.setPointerCapture(K.pointerId),k.current=g.getBoundingClientRect(),F.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",h.viewport&&(h.viewport.style.scrollBehavior="auto"),z(K))}),onPointerMove:Ze(e.onPointerMove,z),onPointerUp:Ze(e.onPointerUp,K=>{const S=K.target;S.hasPointerCapture(K.pointerId)&&S.releasePointerCapture(K.pointerId),document.body.style.webkitUserSelect=F.current,h.viewport&&(h.viewport.style.scrollBehavior=""),k.current=null})})})}),ho="ScrollAreaThumb",bc=l.forwardRef((e,t)=>{const{forceMount:n,...o}=e,s=yc(ho,e.__scopeScrollArea);return r.jsx(Er,{present:n||s.hasThumb,children:r.jsx(wg,{ref:t,...o})})}),wg=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:o,...s}=e,a=nr(ho,n),i=yc(ho,n),{onThumbPositionChange:c}=i,d=rr(t,p=>i.onThumbChange(p)),u=l.useRef(void 0),m=To(()=>{u.current&&(u.current(),u.current=void 0)},100);return l.useEffect(()=>{const p=a.viewport;if(p){const f=()=>{if(m(),!u.current){const h=Sg(p,c);u.current=h,c()}};return c(),p.addEventListener("scroll",f),()=>p.removeEventListener("scroll",f)}},[a.viewport,m,c]),r.jsx(Mn.div,{"data-state":i.hasThumb?"visible":"hidden",...s,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...o},onPointerDownCapture:Ze(e.onPointerDownCapture,p=>{const h=p.target.getBoundingClientRect(),g=p.clientX-h.left,b=p.clientY-h.top;i.onThumbPointerDown({x:g,y:b})}),onPointerUp:Ze(e.onPointerUp,i.onThumbPointerUp)})});bc.displayName=ho;var la="ScrollAreaCorner",wc=l.forwardRef((e,t)=>{const n=nr(la,e.__scopeScrollArea),o=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&o?r.jsx(kg,{...e,ref:t}):null});wc.displayName=la;var kg=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,...o}=e,s=nr(la,n),[a,i]=l.useState(0),[c,d]=l.useState(0),u=!!(a&&c);return on(s.scrollbarX,()=>{const m=s.scrollbarX?.offsetHeight||0;s.onCornerHeightChange(m),d(m)}),on(s.scrollbarY,()=>{const m=s.scrollbarY?.offsetWidth||0;s.onCornerWidthChange(m),i(m)}),u?r.jsx(Mn.div,{...o,ref:t,style:{width:a,height:c,position:"absolute",right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function go(e){return e?parseInt(e,10):0}function kc(e,t){const n=e/t;return isNaN(n)?0:n}function Io(e){const t=kc(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,o=(e.scrollbar.size-n)*t;return Math.max(o,18)}function jg(e,t,n,o="ltr"){const s=Io(n),a=s/2,i=t||a,c=s-i,d=n.scrollbar.paddingStart+i,u=n.scrollbar.size-n.scrollbar.paddingEnd-c,m=n.content-n.viewport,p=o==="ltr"?[0,m]:[m*-1,0];return jc([d,u],p)(e)}function Ka(e,t,n="ltr"){const o=Io(t),s=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-s,i=t.content-t.viewport,c=a-o,d=n==="ltr"?[0,i]:[i*-1,0],u=bp(e,d);return jc([0,i],[0,c])(u)}function jc(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const o=(t[1]-t[0])/(e[1]-e[0]);return t[0]+o*(n-e[0])}}function Sc(e,t){return e>0&&e<t}var Sg=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},o=0;return function s(){const a={left:e.scrollLeft,top:e.scrollTop},i=n.left!==a.left,c=n.top!==a.top;(i||c)&&t(),n=a,o=window.requestAnimationFrame(s)}(),()=>window.cancelAnimationFrame(o)};function To(e,t){const n=mr(e),o=l.useRef(0);return l.useEffect(()=>()=>window.clearTimeout(o.current),[]),l.useCallback(()=>{window.clearTimeout(o.current),o.current=window.setTimeout(n,t)},[n,t])}function on(e,t){const n=mr(t);vp(()=>{let o=0;if(e){const s=new ResizeObserver(()=>{cancelAnimationFrame(o),o=window.requestAnimationFrame(n)});return s.observe(e),()=>{window.cancelAnimationFrame(o),s.unobserve(e)}}},[e,n])}var Nc=mc,Ng=hc,Cc=gc,Cg=bc,Eg=wc;function Ag(e,t=[]){let n=[];function o(a,i){const c=l.createContext(i),d=n.length;n=[...n,i];const u=p=>{const{scope:f,children:h,...g}=p,b=f?.[e]?.[d]||c,y=l.useMemo(()=>g,Object.values(g));return r.jsx(b.Provider,{value:y,children:h})};u.displayName=a+"Provider";function m(p,f){const h=f?.[e]?.[d]||c,g=l.useContext(h);if(g)return g;if(i!==void 0)return i;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[u,m]}const s=()=>{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 s.scopeName=e,[o,_g(s,...t)]}function _g(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const i=o.reduce((c,{useScope:d,scopeName:u})=>{const p=d(a)[`__scope${u}`];return{...c,...p}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function Ig(e){const t=Tg(e),n=l.forwardRef((o,s)=>{const{children:a,...i}=o,c=l.Children.toArray(a),d=c.find(Pg);if(d){const u=d.props.children,m=c.map(p=>p===d?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:p);return r.jsx(t,{...i,ref:s,children:l.isValidElement(u)?l.cloneElement(u,void 0,m):null})}return r.jsx(t,{...i,ref:s,children:a})});return n.displayName=`${e}.Slot`,n}function Tg(e){const t=l.forwardRef((n,o)=>{const{children:s,...a}=n;if(l.isValidElement(s)){const i=Rg(s),c=Dg(a,s.props);return s.type!==l.Fragment&&(c.ref=o?Ur(o,i):i),l.cloneElement(s,c)}return l.Children.count(s)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Mg=Symbol("radix.slottable");function Pg(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Mg}function Dg(e,t){const n={...t};for(const o in t){const s=e[o],a=t[o];/^on[A-Z]/.test(o)?s&&a?n[o]=(...c)=>{const d=a(...c);return s(...c),d}:s&&(n[o]=s):o==="style"?n[o]={...s,...a}:o==="className"&&(n[o]=[s,a].filter(Boolean).join(" "))}return{...e,...n}}function Rg(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 Lg=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Mo=Lg.reduce((e,t)=>{const n=Ig(`Primitive.${t}`),o=l.forwardRef((s,a)=>{const{asChild:i,...c}=s,d=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{}),Po="Tabs",[Og,jw]=Ag(Po,[Co]),Ec=Co(),[Fg,ca]=Og(Po),$g=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:o,onValueChange:s,defaultValue:a,orientation:i="horizontal",dir:c,activationMode:d="automatic",...u}=e,m=No(c),[p,f]=Js({prop:o,onChange:s,defaultProp:a??"",caller:Po});return r.jsx(Fg,{scope:n,baseId:po(),value:p,onValueChange:f,orientation:i,dir:m,activationMode:d,children:r.jsx(Mo.div,{dir:m,"data-orientation":i,...u,ref:t})})});$g.displayName=Po;var Ac="TabsList",_c=l.forwardRef((e,t)=>{const{__scopeTabs:n,loop:o=!0,...s}=e,a=ca(Ac,n),i=Ec(n);return r.jsx(Ml,{asChild:!0,...i,orientation:a.orientation,dir:a.dir,loop:o,children:r.jsx(Mo.div,{role:"tablist","aria-orientation":a.orientation,...s,ref:t})})});_c.displayName=Ac;var Ic="TabsTrigger",Tc=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:o,disabled:s=!1,...a}=e,i=ca(Ic,n),c=Ec(n),d=Dc(i.baseId,o),u=Rc(i.baseId,o),m=o===i.value;return r.jsx(Pl,{asChild:!0,...c,focusable:!s,active:m,children:r.jsx(Mo.button,{type:"button",role:"tab","aria-selected":m,"aria-controls":u,"data-state":m?"active":"inactive","data-disabled":s?"":void 0,disabled:s,id:d,...a,ref:t,onMouseDown:Ze(e.onMouseDown,p=>{!s&&p.button===0&&p.ctrlKey===!1?i.onValueChange(o):p.preventDefault()}),onKeyDown:Ze(e.onKeyDown,p=>{[" ","Enter"].includes(p.key)&&i.onValueChange(o)}),onFocus:Ze(e.onFocus,()=>{const p=i.activationMode!=="manual";!m&&!s&&p&&i.onValueChange(o)})})})});Tc.displayName=Ic;var Mc="TabsContent",Pc=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:o,forceMount:s,children:a,...i}=e,c=ca(Mc,n),d=Dc(c.baseId,o),u=Rc(c.baseId,o),m=o===c.value,p=l.useRef(m);return l.useEffect(()=>{const f=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(f)},[]),r.jsx(Er,{present:s||m,children:({present:f})=>r.jsx(Mo.div,{"data-state":m?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":d,hidden:!f,id:u,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:p.current?"0s":void 0},children:f&&a})})});Pc.displayName=Mc;function Dc(e,t){return`${e}-trigger-${t}`}function Rc(e,t){return`${e}-content-${t}`}var Lc=_c,Oc=Tc,Fc=Pc;const $c=l.forwardRef(({className:e,orientation:t="vertical",...n},o)=>r.jsx(Cc,{ref:o,orientation:t,className:xt("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(Cg,{className:"relative flex-1 rounded-full bg-border/80"})}));$c.displayName=Cc.displayName;const Bc=l.forwardRef(({className:e,children:t,...n},o)=>r.jsxs(Nc,{ref:o,className:xt("relative overflow-hidden",e),...n,children:[r.jsx(Ng,{className:"h-full w-full rounded-[inherit]",children:t}),r.jsx($c,{}),r.jsx(Eg,{})]}));Bc.displayName=Nc.displayName;const fr=l.forwardRef(({className:e,type:t,...n},o)=>r.jsx("input",{type:t,className:xt("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:o,...n}));fr.displayName="Input";const pn=({className:e="w-5 h-5"})=>r.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:e}),Pn=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=Ys();return r.jsx("img",{src:t?"/icons/codex-white.svg":"/icons/codex.svg",alt:"Codex",className:e})},Dn=({className:e="w-5 h-5"})=>{const t=l.useId(),n=l.useId(),o=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(#${o})`}),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:o,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"})]})]})]})},Rn=({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"})]}),Bg=!1;function zg(e,t,n={}){const{timeoutMs:o=null,signal:s,...a}=n,i=typeof AbortController=="function"?new AbortController:null;let c=null;i&&s&&(s.aborted?i.abort(s.reason):s.addEventListener("abort",()=>i.abort(s.reason),{once:!0})),i&&Number.isFinite(o)&&o>0&&(c=setTimeout(()=>{const u=new Error(`Request timed out after ${o}ms`);u.name="AbortError",i.abort(u)},o));const d=e(t,{...a,signal:i?.signal||s});return c?d.finally(()=>{clearTimeout(c)}):d}function Va(e){return e==="resolve"||e==="events"?2e4:null}const fe=(e,t={})=>{const n=localStorage.getItem("auth-token"),{timeoutMs:o=null,signal:s,...a}=t,i={};return t.body instanceof FormData||(i["Content-Type"]="application/json"),n&&(i.Authorization=`Bearer ${n}`),zg(fetch,e,{...a,headers:{...i,...a.headers},signal:s,timeoutMs:o})},st={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:()=>fe("/api/auth/user"),logout:()=>fe("/api/auth/logout",{method:"POST"})},projects:()=>fe("/api/projects"),projectsList:()=>fe("/api/projects/list"),projectDetails:e=>fe(`/api/projects/${e}/details`),sessions:(e,t=5,n=0)=>fe(`/api/projects/${e}/sessions?limit=${t}&offset=${n}`),historyIndex:e=>fe(`/api/session-core/projects/${e}/history-index`),providerDiscovery:(e,t=null)=>{const n=new URLSearchParams;return t&&n.append("projectPath",t),fe(`/api/session-core/providers/${e}${n.toString()?`?${n.toString()}`:""}`)},providersDiscovery:(e=null)=>{const t=new URLSearchParams;return e&&t.append("projectPath",e),fe(`/api/session-core/providers${t.toString()?`?${t.toString()}`:""}`)},sessionEvents:(e,t,n=null,o=null,s=null,a=0)=>{const i=new URLSearchParams;return n&&i.append("projectName",n),o&&i.append("projectPath",o),s!==null&&(i.append("limit",s),i.append("offset",a)),fe(`/api/session-core/sessions/${e}/${t}/events${i.toString()?`?${i.toString()}`:""}`,{timeoutMs:Va("events")})},sessionMessages:(e,t,n=null,o=0,s="claude")=>{const a=new URLSearchParams;return e&&a.append("projectName",e),n!==null&&(a.append("limit",n),a.append("offset",o)),fe(`/api/session-core/sessions/${s}/${t}/events${a.toString()?`?${a.toString()}`:""}`)},resolveSession:(e,t)=>fe(`/api/session-core/sessions/${e}/${t}/resolve`,{timeoutMs:Va("resolve")}),renameProject:(e,t)=>fe(`/api/projects/${e}/rename`,{method:"PUT",body:JSON.stringify({displayName:t})}),deleteSession:(e,t)=>fe(`/api/projects/${e}/sessions/${t}`,{method:"DELETE"}),deleteCodexSession:e=>fe(`/api/codex/sessions/${e}`,{method:"DELETE"}),deleteOpencodeSession:e=>fe(`/api/opencode/sessions/${e}`,{method:"DELETE"}),deleteProject:(e,t=!1)=>fe(`/api/projects/${e}${t?"?force=true":""}`,{method:"DELETE"}),createProject:e=>fe("/api/projects/create",{method:"POST",body:JSON.stringify({path:e})}),createWorkspace:e=>fe("/api/projects/create-workspace",{method:"POST",body:JSON.stringify(e)}),readFile:(e,t)=>fe(`/api/projects/${e}/file?filePath=${encodeURIComponent(t)}`),saveFile:(e,t,n)=>fe(`/api/projects/${e}/file`,{method:"PUT",body:JSON.stringify({filePath:t,content:n})}),getFiles:e=>fe(`/api/projects/${e}/files`),transcribe:e=>fe("/api/transcribe",{method:"POST",body:e,headers:{}}),browseFilesystem:(e=null)=>{const t=new URLSearchParams;return e&&t.append("path",e),fe(`/api/browse-filesystem?${t}`)},createFolder:e=>fe("/api/create-folder",{method:"POST",body:JSON.stringify({path:e})}),ccConnect:{status:()=>fe("/api/cc-connect/status"),providers:()=>fe("/api/cc-connect/providers"),platforms:()=>fe("/api/cc-connect/platforms"),install:()=>fe("/api/cc-connect/install",{method:"POST"}),setup:(e,t)=>fe(`/api/cc-connect/${e}/setup`,{method:"POST",body:JSON.stringify(t)}),sessionStatus:(e,t)=>fe(`/api/cc-connect/${e}/status?sessionId=${encodeURIComponent(t)}`),refresh:(e,t)=>fe(`/api/cc-connect/${e}/refresh`,{method:"POST",body:JSON.stringify({sessionId:t})}),cleanupSession:(e,t)=>fe(`/api/cc-connect/${e}/session?sessionId=${encodeURIComponent(t)}`,{method:"DELETE"}),activeProvider:e=>fe(`/api/cc-connect/${e}/active-provider`),switchProvider:(e,t)=>fe(`/api/cc-connect/${e}/switch-provider`,{method:"POST",body:JSON.stringify({provider:t})}),updateProject:(e,t)=>fe(`/api/cc-connect/${e}/project`,{method:"POST",body:JSON.stringify(t)}),unbind:e=>fe(`/api/cc-connect/${e}/unbind`,{method:"POST"})},get:e=>fe(`/api${e}`)},Ga="__windows_drives__",Wg="__workspace_roots__",Ug=/^[A-Za-z]:\\?$/,Hg=({onClose:e,onProjectCreated:t})=>{const{t:n}=St(),[o,s]=l.useState(1),[a,i]=l.useState("existing"),[c,d]=l.useState(""),[u,m]=l.useState(!1),[p,f]=l.useState(null),[h,g]=l.useState([]),[b,y]=l.useState(!1),[k,F]=l.useState(!1),[E,L]=l.useState("~"),[T,P]=l.useState("~"),[I,z]=l.useState([]),[K,S]=l.useState(!1),[se,ie]=l.useState(!1),[U,Q]=l.useState(!1),[V,le]=l.useState(""),[ce,ue]=l.useState(!1),[G,Ae]=l.useState(null),[O,Z]=l.useState(null),[ae,be]=l.useState(!1),ye=A=>{const q=A.trim();if(!q)return"~";if(q.endsWith("/")||q.endsWith("\\"))return q;if(/^[A-Za-z]:$/.test(q))return`${q}\\`;const v=Math.max(q.lastIndexOf("/"),q.lastIndexOf("\\"));return v>0?v===2&&/^[A-Za-z]:/.test(q)?q.substring(0,3):q.substring(0,v):"~"},ke=O==="windows-drives",ne=O==="workspace-roots",Se=!!O,ve=G==="win32"&&!ae,tt=ae,$e=!Se,je=!Se;l.useEffect(()=>{c.length>2?Te(c):(g([]),y(!1))},[c]);const Te=async A=>{try{const q=ye(A),x=await(await st.browseFilesystem(q)).json();if(x.suggestions){const C=x.suggestions.filter($=>$.path.toLowerCase().startsWith(A.toLowerCase())&&$.path.toLowerCase()!==A.toLowerCase());g(C.slice(0,5)),y(C.length>0)}}catch(q){console.error("Error loading path suggestions:",q)}},qe=()=>{if(f(null),o===1){if(!a){f(n("projectWizard.errors.selectType"));return}s(2)}else if(o===2){if(!c.trim()){f(n("projectWizard.errors.providePath"));return}s(3)}},et=()=>{f(null),s(o-1)},Ke=async()=>{m(!0),f(null);try{const A={workspaceType:a,path:c.trim()},q=await st.createWorkspace(A),v=await q.json();if(!q.ok)throw new Error(v.details||v.error||n("projectWizard.errors.failedToCreate"));t&&t(v.project),e()}catch(A){console.error("Error creating workspace:",A),f(A.message||n("projectWizard.errors.failedToCreate"))}finally{m(!1)}},Xe=A=>{d(A.path),y(!1)},ge=async()=>{F(!0),await Le()},Le=async A=>{try{S(!0);const v=await(await st.browseFilesystem(A)).json();L(v.path||A),P(v.displayPath||v.path||A),z(v.suggestions||[]),Ae(v.platform||null),Z(v.virtualRoot||null),be(!!v.hasWorkspaceRootRestriction)}catch(q){console.error("Error loading folders:",q)}finally{S(!1)}},rt=(A,q=!1)=>{!A||A===Ga||(d(A),F(!1),q&&s(3))},Re=async A=>{await Le(A)},Oe=async()=>{if(!(!V.trim()||!je)){ue(!0),f(null);try{const A=E.includes("\\")?"\\":"/",q=E.endsWith(A)?`${E}${V.trim()}`:`${E}${A}${V.trim()}`,v=await st.createFolder(q),x=await v.json();if(!v.ok)throw new Error(x.error||n("projectWizard.errors.failedToCreateFolder"));le(""),Q(!1),await Le(x.path||q)}catch(A){console.error("Error creating folder:",A),f(A.message||n("projectWizard.errors.failedToCreateFolder"))}finally{ue(!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(Lr,{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(Ht,{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(A=>r.jsxs(jt.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 ${A<o?"bg-green-500 text-white":A===o?"bg-primary text-white":"bg-gray-200 dark:bg-gray-700 text-gray-500"}`,children:A<o?r.jsx(hr,{className:"w-4 h-4"}):A}),r.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 hidden sm:inline",children:n(A===1?"projectWizard.steps.type":A===2?"projectWizard.steps.configure":"projectWizard.steps.confirm")})]}),A<3&&r.jsx("div",{className:`flex-1 h-1 mx-2 rounded ${A<o?"bg-green-500":"bg-gray-200 dark:bg-gray-700"}`})]},A))})}),r.jsxs("div",{className:"p-6 space-y-6 min-h-[300px]",children:[p&&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(wp,{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:p})})]}),o===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(Lr,{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(Lr,{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")})]})]})})]})]})}),o===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(fr,{type:"text",value:c,onChange:A=>d(A.target.value),placeholder:n(a==="existing"?"projectWizard.step2.existingPlaceholder":"projectWizard.step2.newPlaceholder"),className:"w-full"}),b&&h.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:h.map((A,q)=>r.jsxs("button",{onClick:()=>Xe(A),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:A.name}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:A.path})]},q))})]}),r.jsx(Je,{type:"button",variant:"outline",onClick:ge,className:"px-3",title:n("projectWizard.folderBrowser.browseFolders"),children:r.jsx(Fr,{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")})]})}),o===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(Je,{variant:"outline",onClick:o===1?e:et,disabled:u,children:o===1?n("projectWizard.buttons.cancel"):r.jsxs(r.Fragment,{children:[r.jsx(bl,{className:"w-4 h-4 mr-1"}),n("projectWizard.buttons.back")]})}),r.jsx(Je,{onClick:o===3?Ke:qe,disabled:u||o===1&&!a,children:u?r.jsxs(r.Fragment,{children:[r.jsx($t,{className:"w-4 h-4 mr-2 animate-spin"}),n("projectWizard.buttons.creating")]}):o===3?r.jsxs(r.Fragment,{children:[r.jsx(hr,{className:"w-4 h-4 mr-1"}),n("projectWizard.buttons.createProject")]}):r.jsxs(r.Fragment,{children:[n("projectWizard.buttons.next"),r.jsx(en,{className:"w-4 h-4 ml-1"})]})})]})]}),k&&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(Fr,{className:"w-4 h-4 text-primary"})}),r.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:n("projectWizard.folderBrowser.title")})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:()=>Re(ve?Ga:Wg),className:`p-2 rounded-md transition-colors ${Se?"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"} ${ve||tt?"":"hidden"}`,title:n(ve?"projectWizard.folderBrowser.browseDrives":"projectWizard.folderBrowser.browseRoots"),children:r.jsx(Sm,{className:"w-5 h-5"})}),r.jsx("button",{onClick:()=>ie(!se),className:`p-2 rounded-md transition-colors ${se?"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:n(se?"projectWizard.folderBrowser.hideHiddenFolders":"projectWizard.folderBrowser.showHiddenFolders"),children:se?r.jsx(wl,{className:"w-5 h-5"}):r.jsx(cm,{className:"w-5 h-5"})}),r.jsx("button",{onClick:()=>Q(!U),className:`p-2 rounded-md transition-colors ${U?"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:n("projectWizard.folderBrowser.createFolder"),disabled:!je,children:r.jsx(nn,{className:"w-5 h-5"})}),r.jsx("button",{onClick:()=>F(!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(Ht,{className:"w-5 h-5"})})]})]}),U&&je&&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(fr,{type:"text",value:V,onChange:A=>le(A.target.value),placeholder:n("projectWizard.folderBrowser.newFolderPlaceholder"),className:"flex-1",onKeyDown:A=>{A.key==="Enter"&&Oe(),A.key==="Escape"&&(Q(!1),le(""))},autoFocus:!0}),r.jsx(Je,{size:"sm",onClick:Oe,disabled:!V.trim()||ce,children:ce?r.jsx($t,{className:"w-4 h-4 animate-spin"}):n("buttons.create")}),r.jsx(Je,{size:"sm",variant:"ghost",onClick:()=>{Q(!1),le("")},children:n("buttons.cancel")})]})}),r.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:K?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx($t,{className:"w-6 h-6 animate-spin text-gray-400"})}):r.jsxs("div",{className:"space-y-1",children:[E!=="~"&&E!=="/"&&!Ug.test(E)&&!Se&&r.jsxs("button",{onClick:()=>{const A=Math.max(E.lastIndexOf("/"),E.lastIndexOf("\\"));let q;A<=0?q="/":A===2&&/^[A-Za-z]:/.test(E)?q=E.substring(0,3):q=E.substring(0,A),Re(q)},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(Fr,{className:"w-5 h-5 text-gray-400"}),r.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:".."})]}),I.length===0?r.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:n("projectWizard.folderBrowser.noSubfolders")}):I.filter(A=>se||!A.name.startsWith(".")).sort((A,q)=>A.name.toLowerCase().localeCompare(q.name.toLowerCase())).map((A,q)=>r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("button",{onClick:()=>Re(A.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(Lr,{className:"w-5 h-5 text-primary"}),r.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:A.name})]}),r.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>rt(A.path,a==="existing"),className:"text-xs px-3",children:n("buttons.select")})]},q))]})}),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:n("projectWizard.folderBrowser.currentPath")}),r.jsx("code",{className:"text-sm font-mono text-gray-900 dark:text-white flex-1 truncate",children:ke?n("projectWizard.folderBrowser.drivesRoot"):ne?n("projectWizard.folderBrowser.workspaceRoots"):T})]}),r.jsxs("div",{className:"flex items-center justify-end gap-2 p-4",children:[r.jsx(Je,{variant:"outline",onClick:()=>{F(!1),Q(!1),le("")},children:n("buttons.cancel")}),r.jsx(Je,{variant:"outline",onClick:()=>rt(E,a==="existing"),disabled:!$e,children:n("projectWizard.folderBrowser.useCurrentFolder")})]})]})]})})]})};var qg=["size","strokeWidth","strokeLinecap","strokeLinejoin","theme","fill","className","spin"];function Ja(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,o)}return n}function Ya(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Ja(Object(n),!0).forEach(function(o){Kg(e,o,n[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ja(Object(n)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(n,o))})}return e}function Kg(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Vg(e,t){if(e==null)return{};var n=Gg(e,t),o,s;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(s=0;s<a.length;s++)o=a[s],!(t.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(e,o)&&(n[o]=e[o])}return n}function Gg(e,t){if(e==null)return{};var n={},o=Object.keys(e),s,a;for(a=0;a<o.length;a++)s=o[a],!(t.indexOf(s)>=0)&&(n[s]=e[s]);return n}var Jg={size:"1em",strokeWidth:4,strokeLinecap:"round",strokeLinejoin:"round",rtl:!1,theme:"outline",colors:{outline:{fill:"#333",background:"transparent"},filled:{fill:"#333",background:"#FFF"},twoTone:{fill:"#333",twoTone:"#2F88FF"},multiColor:{outStrokeColor:"#333",outFillColor:"#2F88FF",innerStrokeColor:"#FFF",innerFillColor:"#43CCF8"}},prefix:"i"};function Yg(){return"icon-"+((1+Math.random())*4294967296|0).toString(16).substring(1)}function Xg(e,t,n){var o=typeof t.fill=="string"?[t.fill]:t.fill||[],s=[],a=t.theme||n.theme;switch(a){case"outline":s.push(typeof o[0]=="string"?o[0]:"currentColor"),s.push("none"),s.push(typeof o[0]=="string"?o[0]:"currentColor"),s.push("none");break;case"filled":s.push(typeof o[0]=="string"?o[0]:"currentColor"),s.push(typeof o[0]=="string"?o[0]:"currentColor"),s.push("#FFF"),s.push("#FFF");break;case"two-tone":s.push(typeof o[0]=="string"?o[0]:"currentColor"),s.push(typeof o[1]=="string"?o[1]:n.colors.twoTone.twoTone),s.push(typeof o[0]=="string"?o[0]:"currentColor"),s.push(typeof o[1]=="string"?o[1]:n.colors.twoTone.twoTone);break;case"multi-color":s.push(typeof o[0]=="string"?o[0]:"currentColor"),s.push(typeof o[1]=="string"?o[1]:n.colors.multiColor.outFillColor),s.push(typeof o[2]=="string"?o[2]:n.colors.multiColor.innerStrokeColor),s.push(typeof o[3]=="string"?o[3]:n.colors.multiColor.innerFillColor);break}return{size:t.size||n.size,strokeWidth:t.strokeWidth||n.strokeWidth,strokeLinecap:t.strokeLinecap||n.strokeLinecap,strokeLinejoin:t.strokeLinejoin||n.strokeLinejoin,colors:s,id:e}}var zc=l.createContext(Jg);zc.Provider;function Wc(e,t,n){return function(o){var s=o.size,a=o.strokeWidth,i=o.strokeLinecap,c=o.strokeLinejoin,d=o.theme,u=o.fill,m=o.className,p=o.spin,f=Vg(o,qg),h=l.useContext(zc),g=l.useMemo(Yg,[]),b=Xg(g,{size:s,strokeWidth:a,strokeLinecap:i,strokeLinejoin:c,theme:d,fill:u},h),y=[h.prefix+"-icon"];return y.push(h.prefix+"-icon-"+e),h.rtl&&y.push(h.prefix+"-icon-rtl"),p&&y.push(h.prefix+"-icon-spin"),m&&y.push(m),jt.createElement("span",Ya(Ya({},f),{},{className:y.join(" ")}),n(b))}}const Qg=Wc("new-lark",!0,function(e){return jt.createElement("svg",{width:e.size,height:e.size,viewBox:"0 0 48 48",fill:"none"},jt.createElement("path",{d:"M17 29C21 29 25 26.9339 28 23.4065C36 14 41.4242 16.8166 44 17.9998C38.5 20.9998 40.5 29.6233 33 35.9998C28.382 39.9259 23.4945 41.014 19 41C12.5231 40.9799 6.86226 37.7637 4 35.4063V16.9998",stroke:e.colors[0],strokeWidth:e.strokeWidth,strokeLinecap:e.strokeLinecap,strokeLinejoin:e.strokeLinejoin}),jt.createElement("path",{d:"M5.64808 15.8669C5.02231 14.9567 3.77715 14.7261 2.86694 15.3519C1.95673 15.9777 1.72615 17.2228 2.35192 18.1331L5.64808 15.8669ZM36.0021 35.7309C36.958 35.1774 37.2843 33.9539 36.7309 32.9979C36.1774 32.042 34.9539 31.7157 33.9979 32.2691L36.0021 35.7309ZM2.35192 18.1331C5.2435 22.339 10.7992 28.144 16.8865 32.2239C19.9345 34.2667 23.217 35.946 26.449 36.7324C29.6946 37.522 33.0451 37.4428 36.0021 35.7309L33.9979 32.2691C32.2049 33.3072 29.9929 33.478 27.3947 32.8458C24.783 32.2103 21.9405 30.7958 19.1135 28.9011C13.4508 25.106 8.2565 19.661 5.64808 15.8669L2.35192 18.1331Z",fill:e.colors[0]}),jt.createElement("path",{d:"M33.5947 17C32.84 14.7027 30.8551 9.94054 27.5947 7H11.5947C15.2174 10.6757 23.0002 16 27.0002 24",stroke:e.colors[0],strokeWidth:e.strokeWidth,strokeLinecap:e.strokeLinecap,strokeLinejoin:e.strokeLinejoin}))}),Zg=Wc("wechat",!0,function(e){return jt.createElement("svg",{width:e.size,height:e.size,viewBox:"0 0 48 48",fill:"none"},jt.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M36.9974 21.7112C36.8434 13.0079 29.7401 6 21 6C12.1634 6 5 13.1634 5 22C5 26.1701 6.59531 29.9676 9.20892 32.8154L8.01043 40.0257L15.125 36.9699C18.2597 38.0122 21.218 38.2728 24 37.7516",fill:e.colors[1]}),jt.createElement("path",{d:"M36.9974 21.7112C36.8434 13.0079 29.7401 6 21 6C12.1634 6 5 13.1634 5 22C5 26.1701 6.59531 29.9676 9.20892 32.8154L8.01043 40.0257L15.125 36.9699C18.2597 38.0122 21.218 38.2728 24 37.7516",stroke:e.colors[0],strokeWidth:e.strokeWidth,strokeLinecap:e.strokeLinecap,strokeLinejoin:e.strokeLinejoin}),jt.createElement("path",{d:"M15.125 20.4667C16.3676 20.4667 17.375 19.4519 17.375 18.2C17.375 16.9482 16.3676 15.9333 15.125 15.9333C13.8824 15.9333 12.875 16.9482 12.875 18.2C12.875 19.4519 13.8824 20.4667 15.125 20.4667Z",fill:e.colors[2]}),jt.createElement("path",{d:"M24.125 20.4667C25.3676 20.4667 26.375 19.4519 26.375 18.2C26.375 16.9482 25.3676 15.9333 24.125 15.9333C22.8824 15.9333 21.875 16.9482 21.875 18.2C21.875 19.4519 22.8824 20.4667 24.125 20.4667Z",fill:e.colors[2]}),jt.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M38.7618 39.9293C37.0135 41.2302 34.8467 42 32.5 42C26.701 42 22 37.299 22 31.5C22 25.701 26.701 21 32.5 21C38.299 21 43 25.701 43 31.5C43 33.0997 42.6423 34.6159 42.0024 35.9728",fill:e.colors[1]}),jt.createElement("path",{d:"M38.7618 39.9293C37.0135 41.2302 34.8467 42 32.5 42C26.701 42 22 37.299 22 31.5C22 25.701 26.701 21 32.5 21C38.299 21 43 25.701 43 31.5C43 33.0997 42.6423 34.6159 42.0024 35.9728",stroke:e.colors[0],strokeWidth:e.strokeWidth,strokeLinecap:e.strokeLinecap,strokeLinejoin:e.strokeLinejoin}),jt.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M42.0024 35.9728L43 42L38.7618 39.9293",fill:e.colors[1]}),jt.createElement("path",{d:"M42.0024 35.9728L43 42L38.7618 39.9293",stroke:e.colors[0],strokeWidth:e.strokeWidth,strokeLinecap:e.strokeLinecap,strokeLinejoin:e.strokeLinejoin}),jt.createElement("path",{d:"M35.6875 30.7999C34.7555 30.7999 34 30.0388 34 29.0999C34 28.161 34.7555 27.3999 35.6875 27.3999C36.6195 27.3999 37.375 28.161 37.375 29.0999C37.375 30.0388 36.6195 30.7999 35.6875 30.7999Z",fill:e.colors[2]}),jt.createElement("path",{d:"M28.9375 30.7999C28.0055 30.7999 27.25 30.0388 27.25 29.0999C27.25 28.161 28.0055 27.3999 28.9375 27.3999C29.8695 27.3999 30.625 28.161 30.625 29.0999C30.625 30.0388 29.8695 30.7999 28.9375 30.7999Z",fill:e.colors[2]}))}),ex=2e3,tx={claude:"Claude",codex:"Codex",gemini:"Gemini",opencode:"OpenCode"};function rx({provider:e,className:t="h-4 w-4"}){return e==="codex"?r.jsx(Pn,{className:t}):e==="gemini"?r.jsx(Dn,{className:t}):e==="opencode"?r.jsx(Rn,{className:"h-4 w-auto"}):r.jsx(pn,{className:t})}function Vn({platform:e,size:t=20}){return e==="weixin"?r.jsx(Zg,{size:t,theme:"filled",fill:"#07C160"}):r.jsx(Qg,{size:t,theme:"filled",fill:"#3370FF"})}function nx(e){return tx[e]||e}function ox(e){if(!e)return"0:00";const t=e-Date.now();if(t<=0)return"0:00";const n=Math.ceil(t/1e3),o=Math.floor(n/60),s=n%60;return`${o}:${String(s).padStart(2,"0")}`}function Cs(e){return e?.fullPath||e?.path||""}function Xo(e){const t=Cs(e),n=typeof e?.displayName=="string"?e.displayName.trim():"",o=typeof e?.name=="string"?e.name.trim():"";if(n)return n;if(o)return o;if(!t)return"";const a=t.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean);return a[a.length-1]||t}function Xa(e){return e&&(e.title||e.label||e.value)||""}function sx({open:e,onOpenChange:t,selectedProject:n,projects:o=[],onConnectionChange:s}){const{t:a}=St("sidebar"),[i,c]=l.useState(null),[d,u]=l.useState(!1),[m,p]=l.useState(null),[f,h]=l.useState(null),[g,b]=l.useState(""),[y,k]=l.useState(""),[F,E]=l.useState(!1),[L,T]=l.useState(""),[P,I]=l.useState({}),[z,K]=l.useState({}),S=l.useRef(null),se=l.useRef(null),ie=Cs(n),U=i?.ccConnect?.installed===!0,Q=l.useMemo(()=>i?.platforms?.find(v=>v.id===m)||null,[i,m]),V=f&&f.platform===m?f:null,le=l.useMemo(()=>(i?.providers||[]).filter(v=>v.installed).map(v=>v.id),[i]),ce=l.useMemo(()=>{const v=new Map,x=(C,$)=>{const D=String(C||"").trim();!D||v.has(D)||v.set(D,{value:D,title:String($||D).trim()||D,subtitle:D})};for(const C of o){const $=Cs(C);x($,Xo(C))}ie&&x(ie,Xo(n));for(const C of i?.platforms||[])C?.projectPath&&x(C.projectPath,Xo({path:C.projectPath}));return Array.from(v.values())},[o,n,ie,i]),ue=l.useMemo(()=>new Map(ce.map(v=>[v.value,v])),[ce]),G=()=>{S.current&&(clearInterval(S.current),S.current=null)},Ae=async({silent:v=!1}={})=>{v||u(!0);try{const x=await st.ccConnect.platforms(),C=await x.json();if(!x.ok)throw new Error(C?.error||"Failed to load connection summary.");return c(C),s?.(C),C}catch(x){return b(x.message),null}finally{v||u(!1)}},O=async()=>{const v=se.current;if(G(),!(!v?.sessionId||!v?.platform||new Set(["confirmed","error","expired"]).has(v.status)))try{await st.ccConnect.cleanupSession(v.platform,v.sessionId)}catch{}};l.useEffect(()=>{se.current=f},[f]),l.useEffect(()=>{if(!e){O(),c(null),p(null),h(null),b(""),k(""),T(""),I({}),K({});return}return Ae(),()=>{G()}},[e]),l.useEffect(()=>{if(!V?.sessionId){G();return}const v=async()=>{try{const x=await st.ccConnect.sessionStatus(V.platform,V.sessionId),C=await x.json();if(!x.ok)throw new Error(C?.error||"Failed to read setup status.");h(C),C.status==="confirmed"?(G(),k(C.message||a("ccConnect.messages.connected")),T(""),h(null),await Ae({silent:!0})):(C.status==="error"||C.status==="expired")&&(G(),T(""))}catch(x){G(),T(""),b(x.message)}};return v(),S.current=setInterval(()=>{v()},ex),()=>G()},[V?.platform,V?.sessionId,a]),l.useEffect(()=>{e&&I(v=>{const x={...v};let C=!1;const $=i?.platforms||[];for(const D of $){if(typeof v[D.id]=="string"?v[D.id].trim():"")continue;const pe=D.projectPath||ie||ce[0]?.value||"";pe&&(x[D.id]=pe,C=!0)}return C?x:v})},[e,ce,ie,i]),l.useEffect(()=>{e&&K(v=>{const x={...v};let C=!1;for(const $ of i?.platforms||[]){const D=Array.isArray($.configuredProviders)&&$.configuredProviders.length>0?$.configuredProviders:le,J=typeof v[$.id]=="string"?v[$.id].trim():"";if(J&&D.includes(J))continue;const pe=D.includes($.activeProvider)?$.activeProvider:D[0]||"";pe&&(x[$.id]=pe,C=!0)}return C?x:v})},[le,e,i]);const Z=v=>{const x=typeof P[v]=="string"?P[v].trim():"";return x||i?.platforms?.find($=>$.id===v)?.projectPath||ie||ce[0]?.value||""},ae=v=>Array.isArray(v?.configuredProviders)&&v.configuredProviders.length>0?v.configuredProviders:le,be=v=>{const x=ae(v),C=typeof z[v?.id]=="string"?z[v.id].trim():"";return C&&x.includes(C)?C:v?.activeProvider&&x.includes(v.activeProvider)?v.activeProvider:x[0]||null},ye=async(v,x)=>{if(I(C=>({...C,[v.id]:x})),b(""),k(""),v.connected&&x&&x!==v.projectPath)try{await We(v.id,x)}catch{}},ke=async(v,x,{persist:C=!1}={})=>{K($=>({...$,[v.id]:x})),C&&(b(""),k(""),await $e(v.id,x))},ne=()=>{t(!1)},Se=async(v,x)=>{const C=Z(v);if(!C){b(a("ccConnect.messages.selectProjectFirst"));return}b(""),k(""),T(`setup:${v}:${x}`);const $={projectPath:C,mode:x},D=be(i?.platforms?.find(J=>J.id===v));D&&($.provider=D);try{const J=await st.ccConnect.setup(v,$),pe=await J.json();if(!J.ok)throw new Error(pe?.error||a("ccConnect.messages.setupFailed"));h(pe),T(""),p(v)}catch(J){T(""),b(J.message)}},We=async(v,x=null)=>{const C=x||Z(v);if(!C){b(a("ccConnect.messages.selectProjectFirst"));return}b(""),k(""),T(`project:${v}`);try{const $=await st.ccConnect.updateProject(v,{projectPath:C}),D=await $.json();if(!$.ok)throw new Error(D?.error||a("ccConnect.messages.projectUpdateFailed"));k(D.message||a("ccConnect.messages.projectUpdateSuccess")),await Ae({silent:!0})}catch($){throw b($.message),$}finally{T("")}},ve=async()=>{if(!(!V?.platform||!V?.sessionId)){b(""),T(`refresh:${V.platform}`);try{const v=await st.ccConnect.refresh(V.platform,V.sessionId),x=await v.json();if(!v.ok)throw new Error(x?.error||a("ccConnect.messages.refreshFailed"));h(x),T("")}catch(v){T(""),b(v.message)}}},tt=async()=>{b(""),k(""),E(!0);try{const v=await st.ccConnect.install(),x=await v.json();if(!v.ok)throw new Error(x?.error||a("ccConnect.messages.installFailed"));k(x.message||a("ccConnect.messages.installSuccess")),await Ae({silent:!0})}catch(v){b(v.message)}finally{E(!1)}},$e=async(v,x)=>{b(""),k(""),T(`switch:${v}:${x}`);try{const C=await st.ccConnect.switchProvider(v,x),$=await C.json();if(!C.ok)throw new Error($?.error||a("ccConnect.messages.switchFailed"));k($.message||a("ccConnect.messages.switchSuccess")),await Ae({silent:!0})}catch(C){b(C.message)}finally{T("")}},je=async v=>{b(""),k(""),T(`unbind:${v}`);try{const x=await st.ccConnect.unbind(v),C=await x.json();if(!x.ok)throw new Error(C?.error||a("ccConnect.messages.unbindFailed"));k(C.message||a("ccConnect.messages.unbindSuccess")),await Ae({silent:!0}),h(null)}catch(x){b(x.message)}finally{T("")}},Te=async()=>{V?.sessionId&&(await O(),h(null)),b(""),k(""),p(null)};if(!e)return null;const qe=(v,x)=>{if(!x)return null;const C=v==="error"?"border-red-200 bg-red-50 text-red-700 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-300":"border-green-200 bg-green-50 text-green-700 dark:border-green-900/40 dark:bg-green-950/30 dark:text-green-300";return r.jsx("div",{className:`rounded-xl border px-3 py-2 text-sm ${C}`,children:x})},et=()=>r.jsxs("div",{className:"space-y-4 rounded-2xl border border-dashed border-border bg-muted/20 p-4",children:[r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-amber-100 text-amber-600 dark:bg-amber-900/30 dark:text-amber-300",children:r.jsx(Ko,{className:"h-5 w-5"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-sm font-medium text-foreground",children:a("ccConnect.install.title")}),r.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a("ccConnect.install.description")})]})]}),r.jsx("div",{className:"rounded-lg bg-background px-3 py-2 font-mono text-xs text-foreground shadow-sm",children:"npm install -g cc-connect@beta"}),r.jsxs(Je,{onClick:tt,disabled:F,children:[F?r.jsx($t,{className:"h-4 w-4 animate-spin"}):r.jsx(Ko,{className:"h-4 w-4"}),a(F?"ccConnect.install.installing":"ccConnect.install.action")]})]}),Ke=v=>{const x=Z(v.id),C=L===`project:${v.id}`,$=ue.get(x)||null,D=ce.length>0;return r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("p",{className:"text-sm font-medium text-foreground",children:a("ccConnect.project.label")}),C&&r.jsx($t,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"})]}),r.jsxs(fs,{value:x||void 0,onValueChange:J=>{ye(v,J)},disabled:!D||!!L||!!V,children:[r.jsx(hs,{className:"h-auto min-h-12 w-full items-start py-3",children:$?r.jsxs("div",{className:"min-w-0 text-left",children:[r.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:Xa($)}),r.jsx("div",{className:"truncate text-xs text-muted-foreground",children:$.subtitle})]}):r.jsx("div",{className:"text-sm text-muted-foreground",children:a("ccConnect.project.placeholder")})}),r.jsx(gs,{children:ce.map(J=>r.jsx(lo,{value:J.value,children:r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"truncate font-medium text-foreground",children:Xa(J)}),r.jsx("div",{className:"truncate text-xs text-muted-foreground",children:J.subtitle})]})},J.value))})]}),!x&&r.jsx("p",{className:"text-sm text-muted-foreground",children:a("ccConnect.project.empty")})]})},Xe=({platform:v,providers:x,selectedProvider:C,onSelect:$,disabled:D=!1,disableSelected:J=!1,busyActionForProvider:pe=null})=>x?.length?r.jsxs("div",{className:"space-y-2",children:[r.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:a("ccConnect.labels.providerSwitcher")}),r.jsx("div",{className:"flex flex-wrap gap-2",children:x.map(Ie=>{const Me=Ie===C,it=typeof pe=="function"?pe(Ie):!1;return r.jsxs("button",{type:"button",className:`inline-flex items-center gap-2 rounded-full border px-3 py-1.5 text-xs font-medium transition-colors ${Me?"border-primary/30 bg-primary/5 text-primary":"border-border/70 bg-background text-foreground hover:bg-muted/40"} disabled:cursor-not-allowed disabled:opacity-70`,disabled:D||J&&Me&&!it,onClick:()=>{$(Ie)},children:[r.jsx(rx,{provider:Ie,className:"h-3.5 w-3.5"}),r.jsx("span",{children:nx(Ie)}),it?r.jsx($t,{className:"h-3.5 w-3.5 animate-spin"}):Me?r.jsx(Oa,{className:"h-3.5 w-3.5"}):null]},`${v.id}:${Ie}`)})})]}):null,ge=()=>r.jsxs("div",{className:"space-y-4",children:[qe("success",y),qe("error",g),r.jsx("div",{className:"grid gap-3",children:(i?.platforms||[]).map(v=>r.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-card",children:[r.jsx("button",{className:"w-full px-4 py-4 text-left transition-colors hover:bg-muted/20",onClick:()=>{p(v.id),b(""),k("")},children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary",children:r.jsx(Vn,{platform:v.id,size:20})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("p",{className:"text-sm font-semibold text-foreground",children:a(`ccConnect.platforms.${v.id}.title`)}),v.connected&&r.jsx("span",{className:"inline-flex items-center rounded-full bg-green-100 px-2 py-0.5 text-[11px] font-medium text-green-700 dark:bg-green-900/30 dark:text-green-300",children:a("ccConnect.status.connected")})]}),r.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a(`ccConnect.platforms.${v.id}.description`)}),v.projectPath?r.jsx("p",{className:"mt-3 break-all text-xs text-muted-foreground",children:v.projectPath}):r.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:a("ccConnect.status.notConnected")})]})]})}),v.connected&&v.configuredProviders?.length>0&&r.jsx("div",{className:"border-t border-border/60 bg-muted/10 px-4 py-3",children:Xe({platform:v,providers:v.configuredProviders,selectedProvider:v.activeProvider,disabled:!!L,disableSelected:!0,busyActionForProvider:x=>L===`switch:${v.id}:${x}`,onSelect:async x=>{await ke(v,x,{persist:!0})}})})]},v.id))})]}),Le=v=>Xe({platform:v,providers:ae(v),selectedProvider:v.activeProvider,disabled:!!L,disableSelected:!0,busyActionForProvider:x=>L===`switch:${v.id}:${x}`,onSelect:async x=>{await ke(v,x,{persist:!0})}}),rt=v=>r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"rounded-2xl border border-green-200 bg-green-50 px-4 py-4 dark:border-green-900/40 dark:bg-green-950/30",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300",children:r.jsx(af,{className:"h-5 w-5"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-sm font-semibold text-green-700 dark:text-green-300",children:a("ccConnect.labels.connectedTitle",{platform:a(`ccConnect.platforms.${v.id}.title`)})}),r.jsx("p",{className:"mt-1 text-sm text-green-700/80 dark:text-green-300/80",children:a("ccConnect.labels.connectedHint")})]})]})}),Ke(v),Le(v),r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs(Je,{variant:"outline",onClick:()=>{je(v.id)},disabled:!!L,className:"text-red-600 hover:text-red-600",children:[L===`unbind:${v.id}`?r.jsx($t,{className:"h-4 w-4 animate-spin"}):r.jsx(nf,{className:"h-4 w-4"}),a("ccConnect.actions.unbind")]}),r.jsx(Je,{variant:"ghost",onClick:Te,children:a("ccConnect.actions.back")})]})]}),Re=()=>{if(!V)return null;const v=V.mode==="qr",x=V.status==="pending"&&(V.qrImageBase64||V.qrUrl);return r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"rounded-2xl border border-border/70 bg-muted/20 p-4",children:r.jsxs("div",{className:"flex min-h-[220px] flex-col items-center justify-center gap-3",children:[(V.status==="starting"||L.startsWith("setup:"))&&r.jsxs(r.Fragment,{children:[r.jsx($t,{className:"h-8 w-8 animate-spin text-primary"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:a("ccConnect.status.starting")})]}),x&&r.jsxs(r.Fragment,{children:[V.qrImageBase64?r.jsx("img",{src:`data:image/png;base64,${V.qrImageBase64}`,alt:a("ccConnect.labels.qrAlt"),className:"h-48 w-48 rounded-xl border border-border bg-white object-contain p-2"}):r.jsx("img",{src:V.qrUrl,alt:a("ccConnect.labels.qrAlt"),className:"h-48 w-48 rounded-xl border border-border bg-white object-contain p-2"}),r.jsx("p",{className:"text-sm font-medium text-foreground",children:a("ccConnect.status.awaitingScan")}),r.jsx("p",{className:"text-xs text-muted-foreground",children:a("ccConnect.labels.countdown",{time:ox(V.expiresAt)})})]}),V.status==="scanned"&&r.jsxs(r.Fragment,{children:[r.jsx(Oa,{className:"h-10 w-10 text-primary"}),r.jsx("p",{className:"text-sm font-medium text-foreground",children:a("ccConnect.status.scanned")}),r.jsx("p",{className:"text-xs text-muted-foreground",children:a("ccConnect.status.confirmOnDevice")})]}),V.status==="error"&&r.jsxs(r.Fragment,{children:[r.jsx(Ko,{className:"h-8 w-8 text-red-500"}),r.jsx("p",{className:"text-sm font-medium text-red-600 dark:text-red-300",children:V.message})]}),V.status==="expired"&&r.jsxs(r.Fragment,{children:[r.jsx(ar,{className:"h-8 w-8 text-muted-foreground"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:a("ccConnect.status.expired")})]})]})}),v&&(V.status==="pending"||V.status==="error"||V.status==="expired")&&r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs(Je,{variant:"outline",onClick:()=>{ve()},disabled:!!L,children:[L.startsWith("refresh:")?r.jsx($t,{className:"h-4 w-4 animate-spin"}):r.jsx(ar,{className:"h-4 w-4"}),a("ccConnect.actions.refreshQr")]}),r.jsx(Je,{variant:"ghost",onClick:Te,children:a("ccConnect.actions.cancel")})]})]})},Oe=v=>r.jsxs("div",{className:"space-y-4",children:[Ke(v),Xe({platform:v,providers:ae(v),selectedProvider:be(v),disabled:!!V||!!L,onSelect:async x=>{await ke(v,x)}}),r.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-4",children:[r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary",children:r.jsx(Wa,{className:"h-5 w-5"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-sm font-semibold text-foreground",children:a("ccConnect.platforms.weixin.qrTitle")}),r.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a("ccConnect.platforms.weixin.qrDescription")})]})]}),!V&&r.jsxs(Je,{className:"mt-4",onClick:()=>{Se(v.id,"qr")},disabled:!Z(v.id)||!be(v)||!!L,children:[L==="setup:weixin:qr"?r.jsx($t,{className:"h-4 w-4 animate-spin"}):r.jsx(Vn,{platform:v.id,size:16}),a("ccConnect.actions.connectWeixin")]})]}),Re(),!V&&r.jsx(Je,{variant:"ghost",onClick:Te,children:a("ccConnect.actions.back")})]}),A=v=>r.jsxs("div",{className:"space-y-4",children:[Ke(v),Xe({platform:v,providers:ae(v),selectedProvider:be(v),disabled:!!V||!!L,onSelect:async x=>{await ke(v,x)}}),!V&&r.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-4",children:[r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary",children:r.jsx(Wa,{className:"h-5 w-5"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-sm font-semibold text-foreground",children:a("ccConnect.platforms.feishu.qrTitle")}),r.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a("ccConnect.platforms.feishu.qrDescription")})]})]}),r.jsxs(Je,{className:"mt-4",onClick:()=>{Se(v.id,"qr")},disabled:!Z(v.id)||!be(v)||!!L,children:[L==="setup:feishu:qr"?r.jsx($t,{className:"h-4 w-4 animate-spin"}):r.jsx(Vn,{platform:v.id,size:16}),a("ccConnect.actions.startQrSetup")]})]}),Re(),!V&&r.jsx(Je,{variant:"ghost",onClick:Te,children:a("ccConnect.actions.back")})]}),q=v=>v?r.jsxs("div",{className:"space-y-4",children:[qe("success",y),qe("error",g),!U&&!v.connected?r.jsxs("div",{className:"space-y-4",children:[et(),r.jsx(Je,{variant:"ghost",onClick:Te,children:a("ccConnect.actions.back")})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("button",{className:"inline-flex items-center gap-2 rounded-lg px-2 py-1 text-sm font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",onClick:()=>{Te()},children:[r.jsx(em,{className:"h-4 w-4"}),a("ccConnect.actions.back")]}),r.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-primary/10 px-3 py-1 text-xs font-medium text-primary",children:[r.jsx(Vn,{platform:v.id,size:16}),a(`ccConnect.platforms.${v.id}.title`)]})]}),v.connected&&!V?rt(v):v.id==="weixin"?Oe(v):A(v)]})]}):null;return io.createPortal(r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm",children:r.jsxs("div",{className:"w-full max-w-2xl overflow-hidden rounded-[28px] border border-border/70 bg-background shadow-2xl",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-border/60 px-6 py-4",children:[r.jsx("div",{className:"min-w-0",children:r.jsxs("div",{children:[r.jsx("h2",{className:"text-lg font-semibold text-foreground",children:a("ccConnect.title")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:a("ccConnect.subtitle")})]})}),r.jsxs("div",{className:"flex items-center gap-3",children:[d&&r.jsx($t,{className:"h-4 w-4 animate-spin text-muted-foreground"}),r.jsx(Je,{variant:"ghost",size:"icon",onClick:ne,"aria-label":a("actions.cancel"),children:r.jsx(Ht,{className:"h-4 w-4"})})]})]}),r.jsxs("div",{className:"max-h-[80vh] overflow-y-auto px-6 py-5",children:[i?Q?q(Q):ge():r.jsxs("div",{className:"flex min-h-[240px] flex-col items-center justify-center gap-3",children:[r.jsx($t,{className:"h-8 w-8 animate-spin text-primary"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:a("ccConnect.loading")})]}),!U&&i&&!Q&&et()]})]})}),document.body)}const ax=(e,t,n)=>{const o=new Date(e),s=t;if(isNaN(o.getTime()))return n?n("status.unknown"):"Unknown";const a=s-o,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`:o.toLocaleDateString(void 0,{month:"numeric",day:"numeric"})},ix=(e,t)=>{if(typeof e!="string")return"";const n=e.trim();return n.length<=t?n:`${n.slice(0,Math.max(0,t-1))}…`},Qr="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",Gn="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",Qa=({provider:e,className:t="h-3.5 w-3.5"})=>e==="codex"||e==="openai"?r.jsx(Pn,{className:t}):e==="gemini"?r.jsx(Dn,{className:t}):e==="opencode"?r.jsx(Rn,{className:"h-3.5 w-auto max-w-full"}):r.jsx(pn,{className:t});function Za({projects:e,selectedProject:t,selectedSession:n,onProjectSelect:o,onProjectRename:s,onSessionSelect:a,onNewSession:i,onSessionDelete:c,onProjectDelete:d,isLoading:u,projectDetailsLoading:m,loadingProgress:p,onProjectExpand:f,onRefresh:h,updateAvailable:g,latestVersion:b,currentVersion:y,releaseInfo:k,onShowVersionModal:F,isPWA:E,isMobile:L,onToggleSidebar:T,onShowSettings:P,lockedProjectName:I,showNewProject:z,setShowNewProject:K}){const{t:S}=St("sidebar"),[se,ie]=l.useState(new Set),[U,Q]=l.useState(null),[V,le]=l.useState(""),[ce,ue]=l.useState({}),[G,Ae]=l.useState({}),[O,Z]=l.useState(new Date),[ae,be]=l.useState("name"),[ye,ke]=l.useState(!1),[ne,Se]=l.useState(null),[We,ve]=l.useState(null),[tt,$e]=l.useState(""),[je,Te]=l.useState(null),[qe,et]=l.useState(null),[Ke,Xe]=l.useState({}),[ge,Le]=l.useState(""),[rt,Re]=l.useState(new Set),[Oe,A]=l.useState(null),[q,v]=l.useState(null),[x,C]=l.useState(null),[$,D]=l.useState(!1),[J,pe]=l.useState(()=>{try{const N=localStorage.getItem("starredProjects");return N?new Set(JSON.parse(N)):new Set}catch(N){return console.error("Error loading starred projects:",N),new Set}}),Ie=N=>Ee=>{Ee.target.closest(".overflow-y-auto")||Ee.target.closest("[data-scroll-container]")||(Ee.preventDefault(),Ee.stopPropagation(),N())};l.useEffect(()=>{const N=setInterval(()=>{Z(new Date)},6e4);return()=>clearInterval(N)},[]),l.useEffect(()=>{Ae({})},[e]),l.useEffect(()=>{n&&t&&ie(N=>new Set([...N,t.name]))},[n,t]),l.useEffect(()=>{I&&ie(new Set([I]))},[I,e.length]),l.useEffect(()=>{const N=()=>{try{const R=localStorage.getItem("claude-settings");if(R){const te=JSON.parse(R);be(te.projectSortOrder||"name")}}catch(R){console.error("Error loading sort order:",R)}};N();const Ee=R=>{R.key==="claude-settings"&&N()};window.addEventListener("storage",Ee);const M=setInterval(()=>{document.hasFocus()&&N()},1e3);return()=>{window.removeEventListener("storage",Ee),clearInterval(M)}},[]);const Me=l.useCallback(async()=>{try{const N=await st.ccConnect.platforms();if(!N.ok)return;const Ee=await N.json();C(Ee)}catch{}},[]);l.useEffect(()=>{Me()},[Me]);const it=async N=>{const Ee=new Set,M=!se.has(N.name);M&&Ee.add(N.name),ie(Ee),M&&typeof f=="function"&&await f(N.name,{background:!0})},me=(N,Ee)=>{a({...N,__projectName:Ee})},_e=N=>{const Ee=new Set(J);Ee.has(N)?Ee.delete(N):Ee.add(N),pe(Ee);try{localStorage.setItem("starredProjects",JSON.stringify([...Ee]))}catch(M){console.error("Error saving starred projects:",M)}},Qe=N=>J.has(N),ft=N=>{let Ee={};try{Ee=JSON.parse(localStorage.getItem("session-provider-map")||"{}")}catch{}const M=[...N.sessions||[],...G[N.name]||[]].map(nt=>({...nt,__provider:Ee[nt.id]||"claude"})),R=(N.codexSessions||[]).map(nt=>({...nt,__provider:"codex"})),te=(N.geminiSessions||[]).map(nt=>({...nt,__provider:"gemini"})),Ge=(N.opencodeSessions||[]).map(nt=>({...nt,__provider:"opencode"})),dt=nt=>nt.__provider==="codex"?new Date(nt.createdAt||nt.lastActivity):nt.__provider==="gemini"?new Date(nt.createdAt||nt.lastActivity):nt.__provider==="opencode"?new Date(nt.createdAt||nt.lastActivity):new Date(nt.lastActivity);return[...M,...R,...te,...Ge].sort((nt,or)=>dt(or)-dt(nt))},Et=N=>{const Ee=ft(N);return Ee.length===0?new Date(0):Ee.reduce((R,te)=>{const Ge=new Date(te.lastActivity);return Ge>R?Ge:R},new Date(0))},Nt=[...e].sort((N,Ee)=>{const M=Qe(N.name),R=Qe(Ee.name);if(M&&!R)return-1;if(!M&&R)return 1;if(ae==="date")return Et(Ee)-Et(N);{const te=N.displayName||N.name,Ge=Ee.displayName||Ee.name;return te.localeCompare(Ge)}}),yt=N=>{Q(N.name),le(N.displayName||N.name||"")},vt=()=>{Q(null),le("")},we=async N=>{const Ee=V.trim();if(ne!==N)try{if(Se(N),(await st.renameProject(N,Ee)).ok)if(Ee&&typeof s=="function"&&s(N,Ee),typeof h=="function")await h();else if(window.refreshProjects)await window.refreshProjects();else{window.location.reload();return}else console.error("Failed to rename project")}catch(M){console.error("Error renaming project:",M)}finally{Se(null),Q(null),le("")}},Tt=(N,Ee,M,R="claude")=>{v({projectName:N,sessionId:Ee,sessionTitle:M,provider:R})},Rt=async()=>{if(!q)return;const{projectName:N,sessionId:Ee,provider:M}=q;v(null);try{console.log("[Sidebar] Deleting session:",{projectName:N,sessionId:Ee,provider:M});let R;if(M==="codex"?R=await st.deleteCodexSession(Ee):M==="opencode"?R=await st.deleteOpencodeSession(Ee):R=await st.deleteSession(N,Ee),console.log("[Sidebar] Delete response:",{ok:R.ok,status:R.status}),R.ok)console.log("[Sidebar] Session deleted successfully, calling callback"),c?c(Ee):console.warn("[Sidebar] No onSessionDelete callback provided");else{const te=await R.text();console.error("[Sidebar] Failed to delete session:",{status:R.status,error:te}),alert(S("messages.deleteSessionFailed"))}}catch(R){console.error("[Sidebar] Error deleting session:",R),alert(S("messages.deleteSessionError"))}},X=N=>{const Ee=ft(N).length;A({project:N,sessionCount:Ee})},xe=async()=>{if(!Oe)return;const{project:N,sessionCount:Ee}=Oe,M=Ee===0;A(null),Re(R=>new Set([...R,N.name]));try{const R=await st.deleteProject(N.name,!M);if(R.ok)d&&d(N.name);else{const te=await R.json();console.error("Failed to delete project"),alert(te.error||S("messages.deleteProjectFailed"))}}catch(R){console.error("Error deleting project:",R),alert(S("messages.deleteProjectError"))}finally{Re(R=>{const te=new Set(R);return te.delete(N.name),te})}},Ce=async N=>{if(!N.detailsLoaded&&typeof f=="function"){await f(N.name,{background:!0,force:!0});return}if(!(!(N.sessionMeta?.hasMore!==!1)||ce[N.name])){ue(M=>({...M,[N.name]:!0}));try{const M=(N.sessions?.length||0)+(G[N.name]?.length||0),R=await st.sessions(N.name,5,M);if(R.ok){const te=await R.json();Ae(Ge=>({...Ge,[N.name]:[...Ge[N.name]||[],...te.sessions]})),te.hasMore===!1&&(N.sessionMeta={...N.sessionMeta,hasMore:!1})}}catch(M){console.error("Error loading more sessions:",M)}finally{ue(M=>({...M,[N.name]:!1}))}}},ze=Nt.filter(N=>{if(!ge.trim())return!0;const Ee=ge.toLowerCase(),M=(N.displayName||N.name).toLowerCase(),R=N.name.toLowerCase();return M.includes(Ee)||R.includes(Ee)}),Ve=!!I,_=Ve?Nt.filter(N=>N.name===I):ze,H=t||_[0]||null,oe=L?"bottom":"right",Be=L?"end":"start",ot=L?4:8;return r.jsxs(r.Fragment,{children:[z&&io.createPortal(r.jsx(Hg,{onClose:()=>K(!1),onProjectCreated:N=>{window.refreshProjects?window.refreshProjects():window.location.reload()}}),document.body),Oe&&io.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(js,{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:S("deleteConfirmation.deleteProject")}),r.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:[S("deleteConfirmation.confirmDelete")," ",r.jsx("span",{className:"font-medium text-foreground",children:Oe.project.displayName||Oe.project.name}),"?"]}),Oe.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:S("deleteConfirmation.sessionCount",{count:Oe.sessionCount})}),r.jsx("p",{className:"text-xs text-red-600 dark:text-red-400 mt-1",children:S("deleteConfirmation.allConversationsDeleted")})]}),r.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:S("deleteConfirmation.cannotUndo")})]})]})}),r.jsxs("div",{className:"flex gap-3 p-4 bg-muted/30 border-t border-border",children:[r.jsx(Je,{variant:"outline",className:"flex-1",onClick:()=>A(null),children:S("actions.cancel")}),r.jsxs(Je,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:xe,children:[r.jsx(ir,{className:"w-4 h-4 mr-2"}),S("actions.delete")]})]})]})}),document.body),q&&io.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(js,{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:S("deleteConfirmation.deleteSession")}),r.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:[S("deleteConfirmation.confirmDelete")," ",r.jsx("span",{className:"font-medium text-foreground",children:q.sessionTitle||S("sessions.unnamed")}),"?"]}),r.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:S("deleteConfirmation.cannotUndo")})]})]})}),r.jsxs("div",{className:"flex gap-3 p-4 bg-muted/30 border-t border-border",children:[r.jsx(Je,{variant:"outline",className:"flex-1",onClick:()=>v(null),children:S("actions.cancel")}),r.jsxs(Je,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:Rt,children:[r.jsx(ir,{className:"w-4 h-4 mr-2"}),S("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:E&&L?{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:S("app.title")})})]}),T&&r.jsx(Je,{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:T,title:S("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:E&&L?{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:S("app.title")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:S("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:()=>D(!0),title:S("ccConnect.actions.open"),"aria-label":S("ccConnect.actions.open"),children:r.jsx(bs,{className:"h-4 w-4"})}),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()=>{ke(!0);try{await h()}finally{ke(!1)}},disabled:ye,children:r.jsx(ar,{className:`w-4 h-4 text-foreground ${ye?"animate-spin":""}`})}),!Ve&&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:()=>K(!0),children:r.jsx(Lr,{className:"w-4 h-4"})})]})]})})]}),!u&&!L&&!Ve&&r.jsx("div",{className:"hidden"}),e.length>0&&!u&&!Ve&&r.jsx("div",{className:"px-3 py-3 md:px-3",children:r.jsxs("div",{className:"relative",children:[r.jsx(xs,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),r.jsx(fr,{type:"text",placeholder:S("projects.searchPlaceholder"),value:ge,onChange:N=>Le(N.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"}),ge&&r.jsx("button",{onClick:()=>Le(""),className:"absolute right-2 top-1/2 transform -translate-y-1/2 p-1 hover:bg-accent rounded",children:r.jsx(Ht,{className:"w-3 h-3 text-muted-foreground"})})]})}),e.length>0&&!u&&H&&r.jsx("div",{className:"px-3 pb-2",children:r.jsxs(Je,{variant:"subtle",className:"h-9 w-full justify-start gap-2 rounded-lg px-3 text-sm",onClick:()=>i(H),children:[r.jsx(nn,{className:"h-4 w-4"}),S("sessions.newSession")]})}),r.jsx(Bc,{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:u?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:p&&p.total>0?r.jsx("div",{className:"h-full bg-primary transition-all duration-300 ease-out",style:{width:`${p.current/p.total*100}%`}}):r.jsx("div",{className:"h-full w-1/3 rounded-full bg-primary animate-pulse"})}),p?.currentProject&&r.jsx("p",{className:"mx-auto max-w-[260px] break-words text-base font-medium leading-6 text-foreground",title:p.currentProject,children:p.currentProject.split("-").slice(-2).join("/")}),p&&p.total>0?r.jsxs("p",{className:"text-sm text-muted-foreground",children:[p.current,"/",p.total,r.jsx("span",{className:"ml-1 text-sm text-muted-foreground",children:S("projects.projects")})]}):r.jsx("p",{className:"text-sm text-muted-foreground",children:S("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(Vo,{className:"w-6 h-6 text-muted-foreground"})}),r.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:S("projects.noProjects")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:S("projects.runClaudeCli")})]}):_.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(xs,{className:"w-6 h-6 text-muted-foreground"})}),r.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:S("projects.noMatchingProjects")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:S("projects.tryDifferentSearch")})]}):_.map(N=>{const Ee=se.has(N.name),M=t?.name===N.name,R=!!m?.[N.name],te=Qe(N.name),Ge=rt.has(N.name),dt=Ve&&N.name===I,nt=dt||Ee,or=N.displayName||N.name,qt=ix(or,L?22:28);return r.jsxs("div",{className:xt("space-y-2",Ge&&"pointer-events-none opacity-50"),children:[!dt&&r.jsxs("div",{className:"group md:group",children:[r.jsx("div",{className:"md:hidden",children:r.jsxs("div",{className:xt("mx-1 flex min-h-10 items-center gap-2 px-2 py-2 text-muted-foreground transition-colors active:scale-[0.98]",M?"text-foreground":"hover:text-foreground"),onClick:()=>{t?.name!==N.name&&o(N),it(N)},onTouchEnd:Ie(()=>{t?.name!==N.name&&o(N),it(N)}),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:Ee?r.jsx(Fr,{className:xt("h-4 w-4",te?"text-yellow-600 dark:text-yellow-400":"text-foreground")}):r.jsx(Vo,{className:xt("h-4 w-4",te?"text-yellow-600 dark:text-yellow-400":M?"text-foreground":"text-muted-foreground")})}),r.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:U===N.name?r.jsx("input",{type:"text",value:V,onChange:ee=>le(ee.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:S("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:ee=>ee.stopPropagation(),onKeyDown:ee=>{ee.key==="Enter"&&(ee.preventDefault(),ee.stopPropagation(),we(N.name)),ee.key==="Escape"&&(ee.preventDefault(),ee.stopPropagation(),vt())},style:{fontSize:"16px"}}):r.jsx("div",{className:xt(Qo,M&&"font-semibold"),children:qt})})]}),r.jsx("div",{className:"flex shrink-0 items-center justify-end gap-1",children:U===N.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:ee=>{ee.stopPropagation(),we(N.name)},title:S("tooltips.save"),disabled:ne===N.name,children:r.jsx(hr,{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:ee=>{ee.stopPropagation(),vt()},title:S("tooltips.cancel"),children:r.jsx(Ht,{className:"h-3.5 w-3.5"})})]}):r.jsxs(Un,{children:[r.jsx(Hn,{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:ee=>ee.stopPropagation(),"aria-label":S("actions.settings"),children:r.jsx(zn,{className:"h-4 w-4"})})}),r.jsx(qn,{children:r.jsxs(Kn,{side:oe,align:Be,sideOffset:ot,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:ee=>ee.stopPropagation(),children:[r.jsxs(ur,{className:Qr,onSelect:ee=>{ee.preventDefault(),yt(N)},children:[r.jsx(Ba,{className:"h-4 w-4"}),S("tooltips.renameProject")]}),r.jsxs(ur,{className:Qr,onSelect:ee=>{ee.preventDefault(),_e(N.name)},children:[r.jsx(Ua,{className:xt("h-4 w-4",te&&"fill-yellow-400 text-yellow-500")}),S(te?"tooltips.removeFromFavorites":"tooltips.addToFavorites")]}),r.jsx(qa,{className:"my-1 h-px bg-border"}),r.jsxs(ur,{className:Gn,onSelect:ee=>{ee.preventDefault(),X(N)},children:[r.jsx(ir,{className:"h-4 w-4"}),S("tooltips.deleteProject")]})]})})]})})]})}),r.jsxs("div",{role:"button",tabIndex:0,className:xt("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",U===N.name?"h-auto":"h-9",M?"text-foreground":"hover:text-foreground"),onClick:()=>{t?.name!==N.name&&o(N),it(N)},onTouchEnd:Ie(()=>{t?.name!==N.name&&o(N),it(N)}),onKeyDown:ee=>{(ee.key==="Enter"||ee.key===" ")&&(ee.preventDefault(),t?.name!==N.name&&o(N),it(N))},title:N.fullPath||or,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:Ee?r.jsx(Fr,{className:xt("h-4 w-4",te?"text-yellow-600 dark:text-yellow-400":"text-foreground")}):r.jsx(Vo,{className:xt("h-4 w-4",te?"text-yellow-600 dark:text-yellow-400":M?"text-foreground":"text-muted-foreground")})}),r.jsx("div",{className:"min-w-0 flex-1 overflow-hidden text-left",children:U===N.name?r.jsx("input",{type:"text",value:V,onChange:ee=>le(ee.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:S("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:ee=>{ee.key==="Enter"&&(ee.preventDefault(),ee.stopPropagation(),we(N.name)),ee.key==="Escape"&&(ee.preventDefault(),ee.stopPropagation(),vt())},onClick:ee=>ee.stopPropagation()}):r.jsx("div",{className:xt(Qo,M&&"font-semibold"),children:qt})})]}),r.jsx("div",{className:"flex shrink-0 items-center gap-1 pl-1",children:U===N.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:ee=>{ee.stopPropagation(),we(N.name)},title:S("tooltips.save"),disabled:ne===N.name,children:r.jsx(hr,{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:ee=>{ee.stopPropagation(),vt()},title:S("tooltips.cancel"),children:r.jsx(Ht,{className:"h-3.5 w-3.5"})})]}):r.jsxs(Un,{children:[r.jsx(Hn,{asChild:!0,children:r.jsx("button",{className:xt("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:ee=>ee.stopPropagation(),"aria-label":S("actions.settings"),children:r.jsx(zn,{className:"h-4 w-4"})})}),r.jsx(qn,{children:r.jsxs(Kn,{side:oe,align:Be,sideOffset:ot,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:ee=>ee.stopPropagation(),children:[r.jsxs(ur,{className:Qr,onSelect:ee=>{ee.preventDefault(),yt(N)},children:[r.jsx(Ba,{className:"h-4 w-4"}),S("tooltips.renameProject")]}),r.jsxs(ur,{className:Qr,onSelect:ee=>{ee.preventDefault(),_e(N.name)},children:[r.jsx(Ua,{className:xt("h-4 w-4",te&&"fill-yellow-400 text-yellow-500")}),S(te?"tooltips.removeFromFavorites":"tooltips.addToFavorites")]}),r.jsx(qa,{className:"my-1 h-px bg-border"}),r.jsxs(ur,{className:Gn,onSelect:ee=>{ee.preventDefault(),X(N)},children:[r.jsx(ir,{className:"h-4 w-4"}),S("tooltips.deleteProject")]})]})})]})})]})]}),nt&&r.jsxs("div",{className:xt("space-y-1",dt?"px-1 md:px-0":"px-0"),children:[!N.detailsLoaded||R?Array.from({length:3}).map((ee,Lt)=>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+Lt*15}%`}})},Lt)):ft(N).length===0&&!ce[N.name]?r.jsx("div",{className:"px-3 py-2 text-left",children:r.jsx("p",{className:"text-xs text-muted-foreground",children:S("sessions.noSessions")})}):ft(N).map(ee=>{const Lt=ee.__provider==="codex",Ot=ee.__provider==="gemini",Kt=ee.__provider==="opencode",vr=Lt||Ot||Kt,Vt=We===ee.id&&!Lt,gt=n?.id===ee.id,cr=Lt?ee.summary||ee.name||S("projects.codexSession"):Kt?ee.summary||ee.name||S("projects.opencodeSession"):ee.summary||ee.name||S("projects.newSession"),Ar=vr&&ee.createdAt||ee.lastActivity,Vr=je===ee.id||qe===ee.id;return r.jsxs("div",{className:"group/session relative w-full min-w-0 max-w-full",onMouseEnter:()=>Te(ee.id),onMouseLeave:()=>Te(j=>j===ee.id?null:j),children:[r.jsx("div",{className:"w-full min-w-0 max-w-full md:hidden",children:r.jsxs("div",{className:xt("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",gt?"chat-sidebar-item-active":"chat-sidebar-item hover:bg-muted/10"),onClick:()=>{o(N),me(ee,N.name)},onTouchEnd:Ie(()=>{o(N),me(ee,N.name)}),children:[r.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground",children:r.jsx(Qa,{provider:ee.__provider})}),r.jsx("div",{className:"min-w-0 flex-1 basis-0 overflow-hidden",children:Vt?r.jsx("input",{type:"text",value:tt,onChange:j=>$e(j.target.value),onKeyDown:j=>{j.stopPropagation(),j.key==="Enter"?updateSessionSummary(N.name,ee.id,tt):j.key==="Escape"&&(ve(null),$e(""))},onClick:j=>j.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:cr,children:cr})}),r.jsx("div",{className:"flex shrink-0 items-center justify-end gap-1",children:Vt?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:j=>{j.stopPropagation(),updateSessionSummary(N.name,ee.id,tt)},title:S("tooltips.save"),children:r.jsx(hr,{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:j=>{j.stopPropagation(),ve(null),$e("")},title:S("tooltips.cancel"),children:r.jsx(Ht,{className:"h-3.5 w-3.5"})})]}):r.jsx(r.Fragment,{children:r.jsxs(Un,{children:[r.jsx(Hn,{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:j=>j.stopPropagation(),"aria-label":S("actions.settings"),children:r.jsx(zn,{className:"h-4 w-4"})})}),r.jsx(qn,{children:r.jsxs(Kn,{side:oe,align:Be,sideOffset:ot,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:j=>j.stopPropagation(),children:[!Lt&&r.jsxs(ur,{className:Qr,onSelect:j=>{j.preventDefault(),ve(ee.id),$e(ee.summary||ee.name||S("projects.newSession"))},children:[r.jsx(za,{className:"h-4 w-4"}),S("tooltips.editSessionName")]}),r.jsxs(ur,{className:Gn,onSelect:j=>{j.preventDefault(),Tt(N.name,ee.id,cr,ee.__provider)},children:[r.jsx(ir,{className:"h-4 w-4"}),S("tooltips.deleteSession")]})]})})]})})})]})}),r.jsx("div",{className:"hidden w-full min-w-0 max-w-full md:block",children:r.jsxs("div",{className:xt("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",gt?"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:()=>me(ee,N.name),onTouchEnd:Ie(()=>me(ee,N.name)),children:[r.jsx("span",{className:xt("flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground transition-opacity",gt||Vt?"opacity-100":"opacity-0 group-hover/session:opacity-100"),children:r.jsx(Qa,{provider:ee.__provider})}),Vt?r.jsx("input",{type:"text",value:tt,onChange:j=>$e(j.target.value),onKeyDown:j=>{j.stopPropagation(),j.key==="Enter"?updateSessionSummary(N.name,ee.id,tt):j.key==="Escape"&&(ve(null),$e(""))},onClick:j=>j.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:cr,children:cr})]}),r.jsx("div",{className:"relative flex shrink-0 items-center justify-end pl-1 min-w-[28px]",children:Vt?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:j=>{j.stopPropagation(),updateSessionSummary(N.name,ee.id,tt)},title:S("tooltips.save"),children:r.jsx(hr,{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:j=>{j.stopPropagation(),ve(null),$e("")},title:S("tooltips.cancel"),children:r.jsx(Ht,{className:"h-3.5 w-3.5"})})]}):r.jsxs(r.Fragment,{children:[r.jsx("span",{className:xt("text-[11px] text-muted-foreground whitespace-nowrap transition-opacity duration-200",Vr?"opacity-0":"opacity-100"),children:ax(Ar,O,S)}),Vr&&r.jsx("div",{className:"absolute right-0 top-1/2 -translate-y-1/2 flex items-center justify-end",children:r.jsxs(Un,{onOpenChange:j=>et(j?ee.id:null),children:[r.jsx(Hn,{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:j=>j.stopPropagation(),onFocus:()=>Te(ee.id),"aria-label":S("actions.settings"),children:r.jsx(zn,{className:"h-4 w-4"})})}),r.jsx(qn,{children:r.jsxs(Kn,{side:oe,align:Be,sideOffset:ot,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:j=>j.stopPropagation(),children:[!Lt&&r.jsxs(ur,{className:Qr,onSelect:j=>{j.preventDefault(),ve(ee.id),$e(ee.summary||ee.name||S("projects.newSession"))},children:[r.jsx(za,{className:"h-4 w-4"}),S("tooltips.editSessionName")]}),r.jsxs(ur,{className:Gn,onSelect:j=>{j.preventDefault(),Tt(N.name,ee.id,cr,ee.__provider)},children:[r.jsx(ir,{className:"h-4 w-4"}),S("tooltips.deleteSession")]})]})})]})})]})})]})})]},ee.id)}),N.detailsLoaded&&ft(N).length>0&&N.sessionMeta?.hasMore!==!1&&r.jsx(Je,{variant:"subtle",size:"sm",className:"mt-2 w-full justify-center gap-2 rounded-xl text-muted-foreground hover:text-foreground",onClick:()=>Ce(N),disabled:ce[N.name],children:ce[N.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"}),S("sessions.loading")]}):r.jsxs(r.Fragment,{children:[r.jsx(Tr,{className:"w-3 h-3"}),S("sessions.showMore")]})})]})]},N.name)})})}),g&&r.jsxs("div",{className:"px-3 py-3 flex-shrink-0",children:[r.jsx("div",{className:"hidden md:block",children:r.jsxs(Je,{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:F,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:k?.title||`Version ${b}`}),r.jsx("div",{className:"text-xs text-blue-600 dark:text-blue-400",children:S("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:F,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:k?.title||`Version ${b}`}),r.jsx("div",{className:"text-xs text-blue-600 dark:text-blue-400",children:S("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:[!Ve&&r.jsxs(Je,{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:()=>K(!0),title:S("tooltips.createProject"),children:[r.jsx(Lr,{className:"w-4 h-4"}),r.jsx("span",{className:"text-xs leading-none",children:S("projects.newProject").includes("Project")?"New":S("projects.newProject").substring(0,2)})]}),r.jsxs(Je,{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:()=>D(!0),title:S("ccConnect.actions.open"),children:[r.jsx(bs,{className:"w-4 h-4"}),r.jsx("span",{className:"text-xs leading-none",children:S("ccConnect.actions.shortOpen")})]}),r.jsxs(Je,{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()=>{ke(!0);try{await h()}finally{ke(!1)}},disabled:ye,title:S("tooltips.refresh"),children:[r.jsx(ar,{className:`w-4 h-4 ${ye?"animate-spin":""}`}),r.jsx("span",{className:"text-xs leading-none",children:S("actions.refresh")||"Sync"})]})]})})]}),r.jsx(sx,{open:$,onOpenChange:D,selectedProject:t,projects:e,onConnectionChange:C})]})}function lx(e){if(typeof e=="string")return e;if(e==null)return"";try{return JSON.stringify(e,null,2)}catch{return String(e)}}function ei(e){return e==null?null:typeof e=="string"?{content:e,isError:!1,toolUseResult:null}:{content:lx(e.content??e.output??e.result??""),isError:!!e.isError,toolUseResult:e.toolUseResult||null,exitCode:e.exitCode??e.exit_code}}function ti(e,t){return e||""}function cx(e){const t=String(e||"").replace(/\\\s*\n\s*/g," ").trim();if(!t)return"";const o=t.split(/\s*(?:&&|\|\||;|\|)\s*/).map(s=>s.trim()).filter(Boolean).map(s=>s.split(/\s+/)[0]).filter(Boolean);return o.length===0?t:o.slice(0,4).join(" · ")+(o.length>4?"…":"")}function dx(e,t,n){return t?.file_path?t.file_path:t?.path?t.path:e==="Read"&&typeof n=="string"?n:""}function ux(e,t,n,o){const s=dx(e,t,t),a=ti(s);if(e==="Bash"){const i=t?.command||"";return{activityKind:"command",title:o("activity.actions.runCommand"),summary:cx(i)||o("activity.actions.commandPending"),filePath:s,icon:Xm,heavy:!0}}if(e==="Grep"||e==="Glob"){const i=t?.pattern||t?.glob||"",c=ti(t?.path||""),d=[];return i&&d.push(i),c&&d.push(c),{activityKind:"search",title:o("activity.actions.searchContent"),summary:d.join(" · ")||o("activity.actions.searchPending"),filePath:t?.path||"",icon:xs,heavy:!1}}return e==="Read"?{activityKind:"read",title:o("activity.actions.readFile"),summary:a||o("activity.actions.readPending"),filePath:s,icon:hm,heavy:!1}:e==="Edit"||e==="ApplyPatch"?{activityKind:"edit",title:o("activity.actions.updateFile"),summary:a||o("activity.actions.filePending"),filePath:s,icon:um,heavy:!0}:e==="Write"?{activityKind:"write",title:o("activity.actions.createFile"),summary:a||o("activity.actions.filePending"),filePath:s,icon:mm,heavy:!0}:e==="TodoWrite"?{activityKind:"todo-write",title:o("activity.actions.updateTodo"),summary:o("activity.actions.todoSummary"),filePath:"",icon:$a,heavy:!0}:e==="TodoRead"?{activityKind:"todo-read",title:o("activity.actions.readTodo"),summary:o("activity.actions.todoSummary"),filePath:"",icon:$a,heavy:!1}:e==="exit_plan_mode"?{activityKind:"plan",title:o("activity.actions.generatePlan"),summary:o("activity.actions.planSummary"),filePath:"",icon:Xs,heavy:!0}:{activityKind:"tool",title:o("activity.actions.runTool"),summary:e,filePath:s,icon:kp,heavy:!0}}function px({status:e,messages:t=[],pendingPermissionRequests:n=[],t:o}){if(n.length>0){const a=n[0];return{phaseText:o("activity.stage.waitingPermission"),detailText:o("activity.requestTool",{tool:a.toolName||o("messageTypes.tool")}),canAbort:!0,startedAt:e?.startedAt||Date.now()}}const s=[...t].reverse().find(a=>a?.isToolUse);if(s&&!ei(s.toolResult)&&!s.toolEndedAt){const a=yl(s.toolInput)||{},i=ei(s.toolResult),c=ux(s.toolName,a,null,o);return{phaseText:i?.isError?o("activity.stage.toolFailed"):c.activityKind==="search"?o("activity.stage.searching"):c.activityKind==="command"?o("activity.stage.runningCommand"):c.activityKind==="edit"||c.activityKind==="write"?o("activity.stage.editingFile"):c.activityKind==="read"?o("activity.stage.readingFile"):c.activityKind.startsWith("todo")?o("activity.stage.updatingTodo"):o("activity.stage.working"),detailText:c.summary,canAbort:e?.canAbort??!0,startedAt:e?.startedAt||Date.now()}}return e||null}const Ne={USER_MESSAGE:"user_message",ASSISTANT_TEXT_START:"assistant_text_start",ASSISTANT_TEXT_DELTA:"assistant_text_delta",ASSISTANT_TEXT_END:"assistant_text_end",ASSISTANT_CONTENT_BLOCK:"assistant_content_block",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",PLAN_UPDATE:"plan_update",MODE_UPDATE:"mode_update",AVAILABLE_COMMANDS_UPDATE:"available_commands_update",APPROVAL_REQUEST:"approval_request",APPROVAL_RESOLVED:"approval_resolved",SESSION_STATE_CHANGED:"session_state_changed",SYSTEM_NOTICE:"system_notice",ERROR:"error"};function Qt(e="evt"){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${e}:${crypto.randomUUID()}`:`${e}:${Date.now()}:${Math.random().toString(36).slice(2,10)}`}function Uc(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 Ft({kind:e,provider:t="claude",sessionId:n=null,timestamp:o,payload:s={},extensions:a={},rawRef:i=null,eventId:c=null}){return{eventId:c||Qt(e),kind:e,provider:t,sessionId:n,timestamp:Uc(o),payload:s,extensions:a,rawRef:i}}function da(e){return!!(e&&typeof e=="object"&&typeof e.kind=="string"&&typeof e.eventId=="string")}function Zo({kindPrefix:e="assistant_text",text:t,provider:n,sessionId:o,timestamp:s,messageId:a,extensions:i={},rawRef:c=null}){if(typeof t!="string"||!t.trim())return[];const d=a||Qt(e),u={...i,messageId:d};return[Ft({kind:`${e}_start`,provider:n,sessionId:o,timestamp:s,payload:{messageId:d},extensions:u,rawRef:c}),Ft({kind:`${e}_delta`,provider:n,sessionId:o,timestamp:s,payload:{messageId:d,text:t},extensions:u,rawRef:c}),Ft({kind:`${e}_end`,provider:n,sessionId:o,timestamp:s,payload:{messageId:d},extensions:u,rawRef:c})]}function Hc(e){const t=String(e||"").trim();if(!t)return null;const n=t.match(/<dynamic_context(?:\s[^>]*)?>[\s\S]*?<\/dynamic_context>\s*<user_message(?:\s[^>]*)?>\s*([\s\S]*?)\s*<\/user_message>/i);return n?String(n[1]||"").trim():null}function mx(e){return/<\/?(?:subagent_notification|environment_context|dynamic_context|user_message)(?:\s[^>]*)?>/i.test(String(e||""))}function Es(e){if(typeof e!="string")return e;const t=Hc(e);if(t!=null)return t;const n=mx(e);let o=e;return o=o.replace(/<subagent_notification(?:\s[^>]*)?>[\s\S]*?<\/subagent_notification>/gi,""),o=o.replace(/<environment_context(?:\s[^>]*)?>[\s\S]*?<\/environment_context>/gi,""),o=o.replace(/<dynamic_context(?:\s[^>]*)?>[\s\S]*?<\/dynamic_context>/gi,""),o=o.replace(/<\/?(?:subagent_notification|environment_context|dynamic_context|user_message)(?:\s[^>]*)?>/gi,""),n&&(o=o.replace(/["']?\s*\}\s*\}\s*$/g,"")),o.trim()}function qc(e){const t=String(e||"").trim();if(!t||t.startsWith("# AGENTS.md instructions for ")||t.includes("<environment_context>")||t.startsWith("<subagent_notification>")||t.startsWith("</subagent_notification>"))return"";if(t.startsWith("[DYNAMIC CONTEXT V1]")){const o=`
242
+
243
+ [USER MESSAGE]
244
+ `,s=t.indexOf(o);return s>=0?t.slice(s+o.length).trim():""}const n=Hc(t);return n??t}function es(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]")||t.startsWith("<subagent_notification>")||t.startsWith("</subagent_notification>")?!0:/^<dynamic_context(?:\s|>)/i.test(t)||t.includes("<environment_context>")||/<subagent_notification(?:\s|>)/i.test(t)}function Or(e){if(typeof e=="string")return e;if(e==null)return"";try{return JSON.stringify(e)}catch{return String(e)}}function kr(e){if(e==null)return e;try{return JSON.parse(JSON.stringify(e))}catch{return e}}function ua(e){return Array.isArray(e)?e.filter(t=>t&&typeof t=="object").map(t=>kr(t)):[]}function Kc(e){const t=e?.extensions?.clientRequestId||e?.payload?.clientRequestId||null;return typeof t=="string"&&t.trim()?t.trim():null}function fx(e){const t=e?.clientRequestId||e?.extensions?.clientRequestId||null;return typeof t=="string"&&t.trim()?t.trim():null}function hx(e={}){return[...Array.isArray(e?.images)?e.images.map(n=>({type:"image",data:n?.data||n?.image||"",mimeType:n?.mimeType||"application/octet-stream",name:n?.name||n?.filename||""})):[],...ua(e?.contentBlocks)]}function gx(e,t,n={}){const o=Kc(t);if(!o)return-1;const s=JSON.stringify(ua(n.contentBlocks));return $r(e,a=>String(a?.type||"").trim().toLowerCase()!=="user"||fx(a)!==o||String(a?.content||"")!==String(n.text||"")?!1:JSON.stringify(hx(a))===s)}function xx(e){if(!e||typeof e!="object")return null;const t=Array.isArray(e.availableModes)?e.availableModes.filter(o=>o&&typeof o=="object"&&String(o.id||"").trim()).map(o=>({id:String(o.id).trim(),name:String(o.name||o.id||"").trim()||String(o.id).trim(),description:o.description==null?null:String(o.description)})):[],n=typeof e.currentModeId=="string"&&e.currentModeId.trim()?e.currentModeId.trim():null;return!t.length&&!n?null:{availableModes:t,currentModeId:n||t[0]?.id||null}}function yx(e){return(Array.isArray(e?.availableCommands)?e.availableCommands:Array.isArray(e)?e:[]).filter(n=>n&&typeof n=="object"&&String(n.name||"").trim()).map(n=>({name:String(n.name).trim(),description:n.description==null?"":String(n.description),input:n.input&&typeof n.input=="object"?kr(n.input):null,source:"acp",namespace:"acp",type:"acp"}))}function Jn(e=null,t={}){const n=e&&typeof e=="object"?{...e}:{};return t.title!=null&&(n.title=String(t.title)),t.kind!=null&&(n.kind=String(t.kind)),t.status!=null&&(n.status=String(t.status)),t.rawInput!==void 0&&(n.rawInput=kr(t.rawInput)),t.rawOutput!==void 0&&(n.rawOutput=kr(t.rawOutput)),Array.isArray(t.contentBlocks)&&(n.content=kr(t.contentBlocks)),Array.isArray(t.locations)&&(n.locations=kr(t.locations)),Object.keys(n).length>0?n:null}function vx(e){const t=new Map;for(const n of e||[])if(!(n?.message?.role!=="user"||!Array.isArray(n?.message?.content)))for(const o of n.message.content)o?.type==="tool_result"&&o.tool_use_id&&t.set(o.tool_use_id,{content:o.content,isError:!!o.is_error,timestamp:n.timestamp,toolUseResult:n.toolUseResult||null});return t}function $r(e,t){for(let n=e.length-1;n>=0;n-=1)if(t(e[n],n))return n;return-1}function ri(e="",t=""){return t?e?e.endsWith(t)?e:`${e}${t}`:t:e}function Yn(e,{messageId:t,timestamp:n,provider:o,isThinking:s=!1,kind:a="assistant"}){const i=$r(e,d=>d?.eventMessageId===t&&!d.isToolUse&&!!d.isThinking==!!s);if(i>=0){const d={...e[i]};return d.isStreaming=!0,o&&(d.provider=o),n&&(d.timestamp=d.timestamp||n),e[i]=d,{messages:e,index:i}}const c={type:a,content:"",timestamp:n,provider:o,isStreaming:!0,eventMessageId:t};return s&&(c.isThinking=!0),e.push(c),{messages:e,index:e.length-1}}function bx(e,{messageId:t,timestamp:n,provider:o,role:s="assistant"}){const a=$r(e,i=>i?.eventMessageId===t&&!i.isToolUse&&!i.isThinking&&String(i?.type||"").trim().toLowerCase()===String(s||"assistant").trim().toLowerCase());if(a>=0){const i={...e[a]};return o&&(i.provider=o),n&&!i.timestamp&&(i.timestamp=n),e[a]=i,{messages:e,index:a}}return e.push({type:s,content:"",timestamp:n,provider:o,isStreaming:!1,eventMessageId:t,contentBlocks:[]}),{messages:e,index:e.length-1}}function Xn(e,{toolCallId:t,toolName:n,timestamp:o,provider:s}){const a=$r(e,i=>i?.isToolUse&&(i.toolId===t||i.toolCallId===t));if(a>=0){const i={...e[a]};return n&&(i.toolName=n),s&&(i.provider=s),o&&!i.timestamp&&(i.timestamp=o),e[a]=i,{messages:e,index:a}}return e.push({type:"assistant",content:"",timestamp:o,provider:s,isToolUse:!0,toolName:n||"Unknown Tool",toolId:t,toolCallId:t}),{messages:e,index:e.length-1}}function wx(e=[],t="claude",n=null){if(!Array.isArray(e))return[];const o=[],s=vx(e);for(const a of e){const i=Uc(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(m=>m?.type==="text").map(m=>m?.text||"").join(`
245
+ `):d=typeof a.message.content=="string"?a.message.content:String(a.message.content||"");const u=qc(d);u&&(!es(d)||u!==d)&&o.push(Ft({kind:Ne.USER_MESSAGE,provider:t,sessionId:n,timestamp:i,payload:{text:u},rawRef:c}));continue}if(a?.type==="thinking"&&a?.message?.content){o.push(...Zo({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||Qt("tool"),u=a.toolResult||null;o.push(Ft({kind:Ne.TOOL_CALL_START,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:d,toolName:a.toolName},rawRef:c})),o.push(Ft({kind:Ne.TOOL_CALL_INPUT,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:d,input:a.toolInput||""},rawRef:c})),o.push(Ft({kind:Ne.TOOL_CALL_END,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:d,toolName:a.toolName},rawRef:c})),u&&o.push(Ft({kind:Ne.TOOL_RESULT,provider:t,sessionId:n,timestamp:u.timestamp||i,payload:{toolCallId:d,content:Or(u.content),isError:!!u.isError,toolUseResult:u.toolUseResult||null},rawRef:c}));continue}if(a?.type==="tool_result"){o.push(Ft({kind:Ne.TOOL_RESULT,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:a.toolCallId||null,content:Or(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"){const u=Es(d.text);u&&!es(u)&&o.push(...Zo({text:u,provider:t,sessionId:n,timestamp:i,rawRef:c}))}else if(d?.type==="tool_use"){const u=d.id||Qt("tool"),m=s.get(d.id);o.push(Ft({kind:Ne.TOOL_CALL_START,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:u,toolName:d.name},rawRef:c})),o.push(Ft({kind:Ne.TOOL_CALL_INPUT,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:u,input:Or(d.input||{})},rawRef:c})),o.push(Ft({kind:Ne.TOOL_CALL_END,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:u,toolName:d.name},rawRef:c})),m&&o.push(Ft({kind:Ne.TOOL_RESULT,provider:t,sessionId:n,timestamp:m.timestamp||i,payload:{toolCallId:u,content:Or(m.content),isError:!!m.isError,toolUseResult:m.toolUseResult||null},rawRef:c}))}}else{const d=Es(a.message.content);d&&!es(d)&&o.push(...Zo({text:d,provider:t,sessionId:n,timestamp:i,rawRef:c}))}continue}a?.type&&/error/i.test(a.type)&&o.push(Ft({kind:Ne.ERROR,provider:t,sessionId:n,timestamp:i,payload:{message:a.error||a.message||"Provider error"},rawRef:c}))}return o.sort((a,i)=>new Date(a.timestamp)-new Date(i.timestamp))}function Vc(e=[],t,n="claude"){const o=Array.isArray(e)?[...e]:[];if(!da(t))return o;const s=t.provider||n,a=t.timestamp||new Date().toISOString(),i=t.payload||{};switch(t.kind){case Ne.USER_MESSAGE:{const c=Kc(t),d=gx(o,t,i),u=ua(i.contentBlocks),m=typeof i.text=="string"?i.text:"",p=m?qc(m):"";if(m.trim()&&!p&&u.length===0)break;if(d>=0){const f=o[d]||{},h=Array.isArray(f.images)&&f.images.length>0?u.filter(g=>g?.type!=="image"):u;o[d]={...f,type:"user",content:p||f.content||"",timestamp:f.timestamp||a,provider:s,contentBlocks:h,clientRequestId:c||f.clientRequestId||null,eventId:t.eventId||f.eventId,id:f.id||t.eventId||f.id};break}o.push({type:"user",content:p,timestamp:a,provider:s,contentBlocks:u,clientRequestId:c});break}case Ne.ASSISTANT_TEXT_START:{const c=i.messageId||t.extensions?.messageId||Qt("assistant_text");Yn(o,{messageId:c,timestamp:a,provider:s,isThinking:!1});break}case Ne.ASSISTANT_TEXT_DELTA:{const c=i.messageId||t.extensions?.messageId||Qt("assistant_text"),{index:d}=Yn(o,{messageId:c,timestamp:a,provider:s,isThinking:!1}),u={...o[d]};u.content=ri(u.content||"",i.text||""),u.timestamp=u.timestamp||a,u.provider=u.provider||s,o[d]=u;break}case Ne.ASSISTANT_TEXT_END:{const c=i.messageId||t.extensions?.messageId;if(!c)break;const d=$r(o,u=>u?.eventMessageId===c&&!u.isToolUse&&!u.isThinking);d>=0&&(o[d]={...o[d],isStreaming:!1});break}case Ne.ASSISTANT_CONTENT_BLOCK:{const c=i.messageId||t.extensions?.messageId||Qt("assistant_content"),{index:d}=bx(o,{messageId:c,timestamp:a,provider:s,role:"assistant"}),u={...o[d]},m=Array.isArray(u.contentBlocks)?[...u.contentBlocks]:[];i.contentBlock&&typeof i.contentBlock=="object"&&m.push(kr(i.contentBlock)),u.contentBlocks=m,u.provider=u.provider||s,u.timestamp=u.timestamp||a,o[d]=u;break}case Ne.REASONING_START:{const c=i.messageId||t.extensions?.messageId||Qt("reasoning");Yn(o,{messageId:c,timestamp:a,provider:s,isThinking:!0});break}case Ne.REASONING_DELTA:{const c=i.messageId||t.extensions?.messageId||Qt("reasoning"),{index:d}=Yn(o,{messageId:c,timestamp:a,provider:s,isThinking:!0}),u={...o[d]};u.content=ri(u.content||"",i.text||""),u.timestamp=u.timestamp||a,u.provider=u.provider||s,u.isThinking=!0,o[d]=u;break}case Ne.REASONING_END:{const c=i.messageId||t.extensions?.messageId;if(!c)break;const d=$r(o,u=>u?.eventMessageId===c&&!!u.isThinking);d>=0&&(o[d]={...o[d],isStreaming:!1,isThinking:!0});break}case Ne.TOOL_CALL_START:{const c=i.toolCallId||Qt("tool"),{index:d}=Xn(o,{toolCallId:c,toolName:i.toolName,timestamp:a,provider:s});o[d]={...o[d],toolName:i.toolName||o[d].toolName,acpToolCall:Jn(o[d].acpToolCall,i)};break}case Ne.TOOL_CALL_INPUT:{const c=i.toolCallId||Qt("tool"),{index:d}=Xn(o,{toolCallId:c,toolName:i.toolName,timestamp:a,provider:s});o[d]={...o[d],toolInput:i.input!==void 0?Or(i.input):i.rawInput!==void 0?Or(i.rawInput):o[d].toolInput,provider:o[d].provider||s,acpToolCall:Jn(o[d].acpToolCall,i)};break}case Ne.TOOL_CALL_END:{const c=i.toolCallId||t.extensions?.toolCallId;if(!c)break;const{index:d}=Xn(o,{toolCallId:c,toolName:i.toolName,timestamp:a,provider:s});o[d]={...o[d],toolName:i.toolName||o[d].toolName,toolEndedAt:a,acpToolCall:Jn(o[d].acpToolCall,i)};break}case Ne.TOOL_RESULT:{const c=i.toolCallId||t.extensions?.toolCallId||Qt("tool"),{index:d}=Xn(o,{toolCallId:c,toolName:i.toolName,timestamp:a,provider:s});o[d]={...o[d],toolResult:{content:Or(i.content??""),isError:!!i.isError,toolUseResult:i.toolUseResult||null,rawOutput:i.rawOutput,contentBlocks:Array.isArray(i.contentBlocks)?kr(i.contentBlocks):null,status:i.status||null,timestamp:a},toolError:!!i.isError,toolEndedAt:o[d].toolEndedAt||a,provider:o[d].provider||s,acpToolCall:Jn(o[d].acpToolCall,i)};break}case Ne.PLAN_UPDATE:{const c=Array.isArray(i.entries)?kr(i.entries):[],d=$r(o,m=>!!m?.isPlanUpdate),u={...d>=0?o[d]:{},id:(d>=0?o[d]?.id:null)||`plan:${t.sessionId||s}`,type:"assistant",content:String(i.message||"Plan updated"),timestamp:a,provider:s,isPlanUpdate:!0,planEntries:c};d>=0?o[d]=u:o.push(u);break}case Ne.APPROVAL_REQUEST:i.message&&o.push({type:"assistant",content:i.message,timestamp:a,provider:s,isApprovalRequest:!0,approvalRequest:i});break;case Ne.APPROVAL_RESOLVED:i.message&&o.push({type:"assistant",content:i.message,timestamp:a,provider:s,approvalResolution:i});break;case Ne.SYSTEM_NOTICE:if(i.message){const c=o[o.length-1];c&&c.type==="assistant"&&!c.isToolUse&&(c.content||"").trim()===String(i.message).trim()||o.push({type:"assistant",content:i.message,timestamp:a,provider:s,isSystemNotice:!0})}break;case Ne.ERROR:o.push({type:"error",content:i.message||"Provider error",timestamp:a,provider:s,rawRef:t.rawRef||null,extensions:t.extensions||{}});break}return o}function Gc(e=[],t="claude"){return Array.isArray(e)?e.length>0&&!da(e[0])?Gc(wx(e,t),t):e.reduce((n,o)=>Vc(n,o,t),[]):[]}function kx(e=[]){const t={modeState:null,availableCommands:[]};for(const n of Array.isArray(e)?e:[])if(da(n)){if(n.kind===Ne.MODE_UPDATE){const o=xx(n.payload||{});o&&(t.modeState=t.modeState?{availableModes:o.availableModes.length>0?o.availableModes:t.modeState.availableModes,currentModeId:o.currentModeId||t.modeState.currentModeId||null}:o)}n.kind===Ne.AVAILABLE_COMMANDS_UPDATE&&(t.availableCommands=yx(n.payload||{}))}return t}const he={IDLE:"idle",CONNECTING:"connecting",QUEUED:"queued",STREAMING:"streaming",AWAITING_APPROVAL:"awaiting_approval",COMPLETED:"completed",ABORTED:"aborted",ERRORED:"errored"},xo=new Set([he.CONNECTING,he.QUEUED,he.STREAMING,he.AWAITING_APPROVAL]),Jc=new Set([he.COMPLETED,he.ABORTED,he.ERRORED]);function wr(e){return e==null?"":String(e).replace(/\r\n/g,`
246
+ `).trim()}function ni(e){return!e||typeof e!="object"?{content:"",isError:!1}:{content:wr(e.content),isError:!!e.isError}}function jx(e,t){if(!e||!t)return!1;const n=String(e.type||""),o=String(t.type||"");if(n!==o)return!1;const s=!!e.isToolUse,a=!!t.isToolUse;if(s!==a)return!1;if(s&&a){const i=ni(e.toolResult),c=ni(t.toolResult);return wr(e.toolName)===wr(t.toolName)&&wr(e.toolInput)===wr(t.toolInput)&&i.content===c.content&&i.isError===c.isError}return!!e.isThinking!=!!t.isThinking?!1:wr(e.content)===wr(t.content)}function Sx(e,t){const n=Math.min(e.length,t.length);let o=0;for(;o<n&&jx(e[o],t[o]);)o+=1;return o}function Nx(e=[],t=[],n={}){const o=Array.isArray(e)?e:[],s=Array.isArray(t)?t:[],a=!!n.preserveLocalTail;if(o.length===0)return s;if(s.length===0)return a?o:s;const i=Sx(o,s);return i===o.length&&i===s.length?s:a&&i===s.length&&o.length>s.length?o:s}function Qn(e,t){return typeof t=="function"?t(e):t}function oi(e,t={}){const n=xo.has(e),o=xo.has(e);return{isLoading:n,canAbortSession:o,...t}}function Nn(e,t=he.IDLE){const n=String(e||"").trim().toLowerCase();return Object.values(he).includes(n)?n:t}function As(e){return String(e?.rawRef?.type||"").trim().toLowerCase()==="session-status"}function Yc(e){return e===Ne.APPROVAL_REQUEST||e===Ne.APPROVAL_RESOLVED||e===Ne.ASSISTANT_TEXT_START||e===Ne.ASSISTANT_TEXT_DELTA||e===Ne.ASSISTANT_CONTENT_BLOCK||e===Ne.REASONING_START||e===Ne.REASONING_DELTA||e===Ne.TOOL_CALL_START||e===Ne.TOOL_CALL_INPUT||e===Ne.TOOL_CALL_END||e===Ne.TOOL_RESULT||e===Ne.PLAN_UPDATE||e===Ne.SYSTEM_NOTICE}function Cx(e=[]){let t=!1;for(let n=e.length-1;n>=0;n-=1){const o=e[n];if(!(!o||typeof o!="object")){if(o.kind===Ne.ERROR)return he.ERRORED;if(o.kind===Ne.SESSION_STATE_CHANGED){const s=Nn(o.payload?.state,null);if(!s)continue;if(s===he.IDLE){As(o)&&(t=!0);continue}if(Jc.has(s))return s;if(As(o))continue;return t?he.IDLE:s}if(o.kind===Ne.APPROVAL_REQUEST)return t?he.IDLE:he.AWAITING_APPROVAL;if(o.kind===Ne.APPROVAL_RESOLVED||Yc(o.kind))return t?he.IDLE:he.STREAMING}}return t?he.IDLE:null}function Ex(e=[]){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(!(!n||typeof n!="object")){if(n.kind===Ne.ERROR)return he.ERRORED;if(n.kind===Ne.SESSION_STATE_CHANGED){const o=Nn(n.payload?.state,null);if(!o||o===he.IDLE||As(n))continue;return Jc.has(o)?o:null}if(Yc(n.kind))return null}}return null}function Ax(e,t){return!e||typeof e!="object"?t:e.kind===Ne.SESSION_STATE_CHANGED?Nn(e.payload?.state,t):e.kind===Ne.APPROVAL_REQUEST?he.AWAITING_APPROVAL:e.kind===Ne.APPROVAL_RESOLVED?he.STREAMING:e.kind===Ne.ERROR?he.ERRORED:e.kind===Ne.ASSISTANT_TEXT_START||e.kind===Ne.ASSISTANT_TEXT_DELTA||e.kind===Ne.ASSISTANT_CONTENT_BLOCK||e.kind===Ne.REASONING_START||e.kind===Ne.REASONING_DELTA||e.kind===Ne.TOOL_CALL_START||e.kind===Ne.TOOL_CALL_INPUT||e.kind===Ne.TOOL_CALL_END||e.kind===Ne.TOOL_RESULT||e.kind===Ne.PLAN_UPDATE||e.kind===Ne.SYSTEM_NOTICE?he.STREAMING:t}function _x(e,t){const n=t?.payload||{},o=n.requestId||t?.extensions?.requestId||null,s=n.toolCall&&typeof n.toolCall=="object"?n.toolCall:null,a=Array.isArray(n.options)?n.options:Array.isArray(n.context?.options)?n.context.options:[];return!o||e.some(i=>i?.requestId===o)?e:[...e,{requestId:o,toolName:s?.title||n.toolName||"UnknownTool",input:s?.rawInput??n.input,context:{...n.context||{},kind:s?.kind||n.context?.kind||null,options:a},toolCall:s,options:a,message:n.message||null,sessionId:t?.sessionId||n.sessionId||null,receivedAt:t?.timestamp||new Date().toISOString()}]}function Ix(e,t){const o=(t?.payload||{}).requestId||t?.extensions?.requestId||null;return o?e.filter(s=>s?.requestId!==o):e}function Tx(e,t){return t?e===he.AWAITING_APPROVAL||xo.has(e)?e:he.STREAMING:e===he.COMPLETED||e===he.ABORTED||e===he.ERRORED?e:he.IDLE}function Mx(e=[]){return{messages:e,pendingPermissionRequests:[],phase:he.IDLE,isLoading:!1,canAbortSession:!1}}function Px(e,t){switch(t.type){case"replace_messages":return{...e,messages:Qn(e.messages,t.value)};case"replace_permissions":return{...e,pendingPermissionRequests:Qn(e.pendingPermissionRequests,t.value)};case"set_phase":{const n=Nn(t.phase,e.phase);return{...e,phase:n,...oi(n,t.overrides)}}case"set_loading":{const n=!!Qn(e.isLoading,t.value),o=Tx(e.phase,n);return{...e,phase:o,isLoading:n,canAbortSession:n?e.canAbortSession||xo.has(o):!1}}case"set_can_abort":return{...e,canAbortSession:!!Qn(e.canAbortSession,t.value)};case"apply_conversation_event":{const n=Vc(e.messages,t.event,t.provider),o=Ax(t.event,e.phase);let s=e.pendingPermissionRequests;if(t.event?.kind===Ne.APPROVAL_REQUEST)s=_x(s,t.event);else if(t.event?.kind===Ne.APPROVAL_RESOLVED)s=Ix(s,t.event);else if(t.event?.kind===Ne.SESSION_STATE_CHANGED){const a=Nn(t.event?.payload?.state,"");(a===he.COMPLETED||a===he.ABORTED||a===he.ERRORED||a===he.IDLE)&&(s=[])}return{...e,messages:n,pendingPermissionRequests:s,phase:o,...oi(o)}}default:return e}}function Pr(e){return e&&e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&amp;/g,"&")}function Dx(e){if(!e||typeof e!="string")return e;try{return e.replace(/```\s*([^\n\r]+?)\s*```/g,"`$1`")}catch{return e}}function _s(e){try{return typeof e!="string"?e:e.replace(/Claude AI usage limit reached\|(\d{10,13})/g,(t,n)=>{let o=parseInt(n,10);if(!Number.isFinite(o))return t;o<1e12&&(o*=1e3);const s=new Date(o),a=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}).format(s),i=-s.getTimezoneOffset(),c=i>=0?"+":"-",d=Math.abs(i),u=Math.floor(d/60),m=d%60,p=`GMT${c}${u}${m?`:${String(m).padStart(2,"0")}`:""}`,g=((Intl.DateTimeFormat().resolvedOptions().timeZone||"").split("/").pop()||"").replace(/_/g," ").toLowerCase().replace(/\b\w/g,F=>F.toUpperCase()),b=g?`${p} (${g})`:p,y=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],k=`${s.getDate()} ${y[s.getMonth()]} ${s.getFullYear()}`;return`Claude usage limit reached. Your limit will reset at **${a} ${b}** - ${k}`})}catch{return e}}function Xc(e){return Es(e)}function Rx(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 o=`
247
+
248
+ [USER MESSAGE]
249
+ `,s=t.indexOf(o);return s>=0?t.slice(s+o.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 pa(e=[]){return Array.isArray(e)?e.flatMap(t=>{if(!t||typeof t!="object")return[];if(t.isToolUse||t.isPlanUpdate||t.approvalRequest||t.approvalResolution)return[t];if(typeof t.content!="string")return[t];if(t.type==="assistant"||t.role==="assistant"){const s=Xc(t.content);return s?s===t.content?[t]:[{...t,content:s}]:[]}const o=Rx(t.content);return o?o===t.content?[t]:[{...t,content:o}]:[]}):[]}function Lx(e=[],t=[]){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const o=e[n],s=t[n];if(o?.type!==s?.type||o?.role!==s?.role||o?.content!==s?.content||o?.timestamp!==s?.timestamp||!!o?.isToolUse!=!!s?.isToolUse)return!1}return!0}function ma({phaseText:e,detailText:t="",canAbort:n=!0,startedAt:o=Date.now(),elapsedSeconds:s}={}){return{phaseText:e,detailText:t,canAbort:n,startedAt:o,elapsedSeconds:s}}function Ox(e,t,n=null){const o=n?.startedAt||Date.now(),s=typeof e=="string"?e:e?.message||e?.status||e?.text||"",a=String(s||"").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")),ma({phaseText:c,detailText:a,canAbort:e?.can_interrupt!==!1,startedAt:o,elapsedSeconds:e?.elapsedSeconds})}const Fx=({node:e,inline:t,className:n,children:o,...s})=>{const{t:a}=St("chat"),[i,c]=l.useState(!1),d=Array.isArray(o)?o.join(""):String(o??""),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||""}`,...s,children:o});const f=/language-(\w+)/.exec(n||""),h=f?f[1]:"text",g=d,b=()=>{const y=()=>{c(!0),setTimeout(()=>c(!1),1500)};try{if(navigator?.clipboard?.writeText)navigator.clipboard.writeText(g).then(y).catch(()=>{const k=document.createElement("textarea");k.value=g,k.style.position="fixed",k.style.opacity="0",document.body.appendChild(k),k.select();try{document.execCommand("copy")}catch{}document.body.removeChild(k),y()});else{const k=document.createElement("textarea");k.value=g,k.style.position="fixed",k.style.opacity="0",document.body.appendChild(k),k.select();try{document.execCommand("copy")}catch{}document.body.removeChild(k),y()}}catch{}};return r.jsxs("div",{className:"relative group my-2",children:[h&&h!=="text"&&r.jsx("div",{className:"absolute top-2 left-3 z-10 text-xs text-gray-400 font-medium uppercase",children:h}),r.jsx("button",{type:"button",onClick:b,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(Ep,{language:h,style:Ap,customStyle:{margin:0,borderRadius:"0.5rem",fontSize:"0.875rem",padding:h&&h!=="text"?"2rem 1rem 1rem 1rem":"1rem"},codeTagProps:{style:{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'}},children:d})]})},$x={code:Fx,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})},Is=({children:e,className:t})=>{const n=Dx(String(e??"")),o=l.useMemo(()=>[jp,Sp],[]),s=l.useMemo(()=>[Np],[]);return r.jsx("div",{className:t,children:r.jsx(Cp,{remarkPlugins:o,rehypePlugins:s,components:$x,children:n})})};l.memo(({message:e,prevMessage:t,provider:n,showThinking:o,isActiveStreamingCard:s})=>{const{t:a}=St("chat"),i=e.provider||e.__provider||n||"claude",c=i==="codex",d=i==="gemini",u=i==="opencode",m=t&&t.type===e.type&&(t.type==="assistant"||t.type==="user"||t.type==="tool"||t.type==="error");return r.jsx("div",{className:`chat-message ${e.type} ${m?"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((p,f)=>r.jsx("img",{src:p.data,alt:p.name,className:"rounded-lg max-w-full h-auto cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>window.open(p.data,"_blank")},f))}),r.jsx("div",{className:"text-xs text-primary-foreground/80 mt-1 text-right",children:new Date(e.timestamp).toLocaleTimeString()})]}),!m&&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:[!m&&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:c?r.jsx(Pn,{className:"w-full h-full"}):d?r.jsx(Dn,{className:"w-full h-full"}):u?r.jsx(Rn,{className:"h-full w-auto max-w-full text-gray-900 dark:text-white"}):r.jsx(pn,{className:"w-full h-full"})}),r.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:e.type==="error"?a("messageTypes.error"):e.type==="tool"?a("messageTypes.tool"):c?a("messageTypes.codex"):d?a("messageTypes.gemini"):u?"OpenCode":a("messageTypes.claude")})]}),r.jsxs("div",{className:"w-full",children:[e.isToolUse?r.jsx(_p,{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:s,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:a("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(Is,{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:[o&&e.reasoning&&r.jsxs("details",{className:"mb-3",open:s,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:a("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 p=Xc(_s(String(e.content||""))),f=p.trim();if((f.startsWith("{")||f.startsWith("["))&&(f.endsWith("}")||f.endsWith("]")))try{const h=JSON.parse(f),g=JSON.stringify(h,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:g})})})]})}catch{}return e.type==="assistant"?r.jsx(Is,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:p}):r.jsx("div",{className:"whitespace-pre-wrap",children:p})})()]}),r.jsx("div",{className:`text-xs text-gray-500 dark:text-gray-400 mt-1 ${m?"opacity-0 group-hover:opacity-100":""}`,children:new Date(e.timestamp).toLocaleTimeString()})]})]})})});function Bx({hasSelectedProject:e=!1,hasMessages:t=!1,hasSessionContext:n=!1,isLoading:o=!1,isLoadingSessionMessages:s=!1}={}){return e?s?"loading-session-messages":t?"messages":n?o?"running-empty":"continue":"provider-selection":"no-project"}function zx({canAbortSession:e=!1,hasInput:t=!1,isInputDisabled:n=!1,isLoading:o=!1}={}){return e&&o?{kind:"abort",disabled:!1}:{kind:"submit",disabled:!t||n}}function Wx({modes:e=[],disabled:t=!1}={}){return(Array.isArray(e)?e.filter(o=>o?.id):[]).length>1&&!t}function Qc(e,t){return Number.isInteger(e)&&e>=0&&e<t?e:-1}function Ux(e=[],t=-1){const n=Array.isArray(e)?e:[],o=Qc(t,n.length),s=o>=0?n[o]:null;return{activeImage:s,activeIndex:o,isOpen:s!==null}}const Hx=[{id:"claude",label:"Claude Code",Logo:pn},{id:"codex",label:"Codex",Logo:Pn},{id:"gemini",label:"Gemini",Logo:Dn},{id:"opencode",label:"OpenCode",Logo:Rn}];function qx({provider:e,onSelect:t}){return r.jsx("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-2",children:Hx.map(({id:n,label:o,Logo:s})=>r.jsxs("button",{onMouseDown:a=>a.preventDefault(),onClick:()=>t(n),className:`group relative w-full flex items-center gap-3 rounded-2xl border px-4 py-3 text-left transition-all duration-200 ${e===n?"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:[n==="opencode"?r.jsx(s,{className:"h-10 w-auto max-w-full flex-shrink-0 text-foreground"}):r.jsx(s,{className:"h-10 w-10 flex-shrink-0"}),r.jsx("div",{className:"text-left font-medium text-[14px] leading-6",children:o})]},n))})}function Kx(e,t){const n=e.split(`
250
+ `),o=t.split(`
251
+ `),s=[];let a=0,i=0;for(;a<n.length||i<o.length;){const c=n[a],d=o[i];a>=n.length?(s.push({type:"added",content:d,lineNum:i+1}),i+=1):i>=o.length?(s.push({type:"removed",content:c,lineNum:a+1}),a+=1):c===d?(a+=1,i+=1):(s.push({type:"removed",content:c,lineNum:a+1}),s.push({type:"added",content:d,lineNum:i+1}),a+=1,i+=1)}return s}function Vx({selectedProject:e,selectedSession:t,currentSessionId:n,provider:o,chatMessages:s,threadMessages:a,isLoading:i,isLoadingSessionMessages:c,isLoadingMoreMessages:d,hasMoreMessages:u,totalMessages:m,sessionMessages:p,visibleMessageCount:f,pendingPermissionRequests:h,scrollContainerRef:g,messagesEndRef:b,onScroll:y,onLoadEarlierSessionMessages:k,onLoadEarlierMessages:F,onProviderSelection:E,onFileOpen:L,onShowSettings:T,onGrantToolPermission:P,onPermissionDecision:I,autoExpandTools:z,showRawParameters:K}){const{t:S}=St("chat"),se=o==="codex"?"Codex":o==="gemini"?"Gemini":o==="opencode"?"OpenCode":"Claude",ie=l.useMemo(()=>{const le=new Map;return(ce,ue)=>{const G=`${ce.length}-${ue.length}-${ce.slice(0,50)}`;if(le.has(G))return le.get(G);const Ae=Kx(ce,ue);if(le.set(G,Ae),le.size>100){const O=le.keys().next().value;le.delete(O)}return Ae}},[]),U=s.length===0?null:r.jsxs(r.Fragment,{children:[d&&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:S("session.loading.olderMessages")})]})}),u&&!d&&r.jsx("div",{className:"mb-3 text-center text-gray-500 dark:text-gray-400 text-sm",children:m>0&&r.jsxs("span",{children:[S("session.messages.showingOf",{shown:p.length,total:m})," •",r.jsx("button",{className:"ml-1 text-primary hover:text-primary underline",onClick:k,children:S("session.messages.loadEarlier")}),r.jsx("span",{className:"ml-1 text-xs",children:S("session.messages.scrollToLoad")})]})}),!t&&!u&&s.length>f&&r.jsxs("div",{className:"mb-3 text-center text-gray-500 dark:text-gray-400 text-sm",children:[S("session.messages.showingLast",{count:f,total:s.length})," •",r.jsx("button",{className:"ml-1 text-primary hover:text-primary underline",onClick:F,children:S("session.messages.loadEarlier")})]})]}),Q=s.length===0?null:r.jsx(r.Fragment,{children:h.map(le=>r.jsx(Ip,{request:le,className:"mx-1 my-3 sm:mx-0",onSelectOption:ce=>I(le.requestId,{optionId:ce,outcome:{outcome:"selected",optionId:ce}}),onCancel:()=>I(le.requestId,{cancelled:!0,outcome:{outcome:"cancelled"}})},le.requestId))}),V=Bx({hasSelectedProject:!!e,hasMessages:s.length>0,hasSessionContext:!!(t||n),isLoading:i,isLoadingSessionMessages:c});return e?r.jsx("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:V==="loading-session-messages"?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:S("session.loading.sessionMessages")})]})}):V==="provider-selection"?r.jsx("div",{className:"flex h-full items-center justify-center overflow-y-auto px-4 py-8 sm:px-6",children: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:S("providerSelection.title")}),r.jsx("p",{className:"mx-auto mb-8 max-w-xl text-base text-muted-foreground",children:S("providerSelection.description")}),r.jsx(qx,{provider:o,onSelect:E})]})}):V==="continue"?r.jsx("div",{className:"flex h-full items-center justify-center overflow-y-auto px-4 py-8 sm:px-6",children: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:S("session.continue.title")}),r.jsx("p",{className:"text-sm sm:text-base leading-relaxed",children:S("session.continue.description")})]})}):V==="running-empty"?r.jsx("div",{className:"flex h-full items-center justify-center overflow-y-auto px-4 py-8 sm:px-6",children:r.jsx("div",{className:"px-6 text-center text-muted-foreground sm:px-4",children:r.jsxs("div",{className:"mb-3 flex items-center justify-center gap-2",children:[r.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-b-2 border-gray-400"}),r.jsx("p",{className:"text-sm sm:text-base",children:S("session.loading.waitingForFirstReply")})]})})}):r.jsx(Tp,{messages:a,convertMessage:Mp,isRunning:i,scrollContainerRef:g,onScroll:y,messagesEndRef:b,provider:o,providerLabel:se,createDiff:ie,onFileOpen:L,onShowSettings:T,onGrantToolPermission:P,showRawParameters:K,autoExpandTools:z,selectedProject:e,markdownRenderer:Is,topContent:U,bottomContent:Q})}):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(bs,{className:"h-7 w-7"})}),r.jsx("p",{className:"text-base font-medium text-foreground",children:"Select a project to start chatting"})]})})}const Zn=({children:e,content:t,position:n="top",className:o="",delay:s=500})=>{const[a,i]=l.useState(!1),[c,d]=l.useState(null),u=()=>{const h=setTimeout(()=>{i(!0)},s);d(h)},m=()=>{c&&(clearTimeout(c),d(null)),i(!1)},p=()=>{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"}},f=()=>{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:m,children:[e,a&&r.jsxs("div",{className:xt("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",p(),o),children:[t,r.jsx("div",{className:xt("absolute w-0 h-0 border-4 border-transparent",f())})]})]}):e};function Gx(e){return String(e||"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Jx(e){if(typeof e!="string")return"";const n=e.replace(/\\/g,"/").split("/").filter(Boolean);return n[n.length-1]||e}function Zc(e,t=""){let n=[];for(const o of Array.isArray(e)?e:[]){const s=t?`${t}/${o.name}`:o.name;o.type==="directory"&&o.children?n=n.concat(Zc(o.children,s)):o.type==="file"&&n.push({name:o.name,path:s,relativePath:o.path})}return n}const sn="1",si=5,ai="replace",Ts="append";function jr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function xr(e){return typeof e=="string"&&e.trim().length>0}function Ms(e){if(typeof e!="string")return"";try{return decodeURIComponent(e).trim()}catch{return e.trim()}}function Do(e,{allowEmptyPath:t=!0}={}){return typeof e=="string"?!t&&!e.trim()?null:{path:e,displayName:""}:!jr(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 an(e){return Do(e)?.path||""}function Yx(e){const t=Do(e);return t?xr(t.displayName)?t.displayName:Jx(t.path):""}function Xx(e,t=72){if(typeof e!="string")return"";const n=e.trim().replace(/\s+/g," ");if(n.length<=t)return n;const o=n.split(/\s*>\s*/).filter(Boolean);if(o.length<=1)return`...${n.slice(-(t-3))}`;const s=[];let a=3;for(let c=o.length-1;c>=0;c-=1){const d=o[c],u=a+d.length+(s.length>0?3:0);if(s.length>0&&u>t)break;s.unshift(d),a=u}const i=`... > ${s.join(" > ")}`;return i.length<=t?i:`...${i.slice(-(t-3))}`}function ii(e){if(!e)return"";const t=[];xr(e.label)&&t.push(e.label.trim());const n=Xx(e.selector);return n&&t.push(n),t.join(" · ")}function Qx(e){return e?xr(e.systemContext)||xr(an(e.currentFile))||Array.isArray(e.selectedElements)&&e.selectedElements.length>0?!0:jr(e.extensions)&&Object.keys(e.extensions).length>0:!1}function Zx(e){return e?xr(e.systemContext)||xr(an(e.currentFile))?!0:Array.isArray(e.selectedElements)&&e.selectedElements.length>0:!1}function ed(e){if(!jr(e)||e.version!==sn||typeof e.systemContext!="string")return null;const t=Do(e.currentFile);if(!t||!Array.isArray(e.selectedElements))return null;const n=[];for(const s of e.selectedElements){if(!jr(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})}if(e.extensions!==void 0&&!jr(e.extensions))return null;const o={version:sn,systemContext:e.systemContext,currentFile:t,selectedElements:n};return e.extensions!==void 0&&(o.extensions={...e.extensions}),o}function e0(e){if(!jr(e)||e.version!==void 0&&e.version!==sn||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=Do(e.currentFile);if(!n)return null;t.currentFile=n}if(e.selectedElements!==void 0){const n=[];for(const o of e.selectedElements){if(!jr(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})}t.selectedElements=n}if(e.extensions!==void 0){if(!jr(e.extensions))return null;t.extensions={...e.extensions}}return t}function t0(e){return`${e.tag}::${e.selector}::${e.label}`}function r0(e){if(!Array.isArray(e)||e.length===0)return[];const t=new Set,n=[];for(const o of e){const s=t0(o);t.has(s)||(t.add(s),n.push(o))}return n}function n0(){return{version:sn,systemContext:"",currentFile:{path:"",displayName:""},selectedElements:[]}}function o0(e,t){const n=ed(e)||n0(),o=e0(t);if(!o)return null;const s={...n};return o.systemContext!==void 0&&(s.systemContext=o.systemContext),o.currentFile!==void 0&&(s.currentFile=o.currentFile),o.selectedElements!==void 0&&(s.selectedElements=r0([...Array.isArray(n.selectedElements)?n.selectedElements:[],...o.selectedElements])),o.extensions!==void 0&&(s.extensions={...jr(n.extensions)?n.extensions:{},...o.extensions}),s}function s0(e){return typeof e!="string"?ai:e.trim().toLowerCase()===Ts?Ts:ai}function li(e){if(e==null||e==="")return null;let t=e;if(typeof e=="string"){const o=Ms(e);if(!o)return null;try{t=JSON.parse(o)}catch{return console.warn("[DynamicContext] Ignored invalid context JSON string."),null}}const n=ed(t);return n||(console.warn("[DynamicContext] Ignored invalid context payload."),null)}function a0(e){if(!e)return null;const t={version:sn,systemContext:e.systemContext||"",currentFile:an(e.currentFile),selectedElements:Array.isArray(e.selectedElements)?e.selectedElements:[]};return e.extensions!==void 0&&(t.extensions=e.extensions),t}function i0(e,t){return`<dynamic_context version="${sn}">
252
+ ${JSON.stringify(e,null,2)}
253
+ </dynamic_context>
254
+
255
+ <user_message>
256
+ ${t}
257
+ </user_message>`}function l0({visibleDynamicContext:e,visibleSelectedElements:t,hiddenSelectedElements:n,onDismissSystemContext:o,onDismissCurrentFile:s,onDismissSelectedElement:a}){const{t:i}=St("chat");return e?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:[xr(e.systemContext)&&r.jsx(Zn,{content:e.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:i("input.dynamicContext.systemChip")}),r.jsx("button",{type:"button",onClick:o,className:"ml-0.5 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors",title:i("input.dynamicContext.removeSystem"),"aria-label":i("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"})})})]})}),xr(an(e.currentFile))&&r.jsx(Zn,{content:an(e.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:Yx(e.currentFile)}),r.jsx("button",{type:"button",onClick:s,className:"ml-0.5 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors",title:i("input.dynamicContext.removeCurrentFile"),"aria-label":i("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"})})})]})}),t.map((c,d)=>r.jsx(Zn,{content:ii(c),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:c.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:c.tag||i("input.dynamicContext.elementFallback")}),r.jsx("button",{type:"button",onClick:()=>a(c),className:"ml-0.5 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors",title:i("input.dynamicContext.removeElement"),"aria-label":i("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"})})})]})},`${c.selector}-${d}`)),n.length>0&&r.jsx(Zn,{content:n.map(ii).join(`
258
+ `),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:["+",n.length]})})]})}):null}function c0({file:e,index:t,onPreview:n,onRemove:o,uploadProgress:s,error:a}){const[i,c]=l.useState(null);return l.useEffect(()=>{const d=URL.createObjectURL(e);return c(d),()=>URL.revokeObjectURL(d)},[e]),r.jsxs("div",{className:"relative group",children:[r.jsx("button",{type:"button",onClick:()=>n(t),disabled:!i,className:"block touch-manipulation overflow-hidden rounded-lg focus:outline-none focus:ring-2 focus:ring-primary/40 disabled:cursor-default",children:r.jsx("img",{src:i,alt:e.name,className:"h-20 w-20 object-cover rounded-lg"})}),s!==void 0&&s<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:[s,"%"]})}),a&&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",{type:"button",onClick:o,onMouseDown:d=>d.stopPropagation(),onTouchStart:d=>d.stopPropagation(),className:"absolute -right-2 -top-2 rounded-full bg-red-500 p-1 text-white opacity-100 shadow-sm transition-opacity sm:opacity-0 sm: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 d0({attachedImages:e,uploadingImages:t,imageErrors:n,onRemove:o}){const[s,a]=l.useState(-1),[i,c]=l.useState(null),d=l.useMemo(()=>Ux(e,s),[e,s]);return l.useEffect(()=>{if(!d.isOpen)return;const u=p=>{p.key==="Escape"&&a(-1)},m=document.body.style.overflow;return document.body.style.overflow="hidden",window.addEventListener("keydown",u),()=>{document.body.style.overflow=m,window.removeEventListener("keydown",u)}},[d.isOpen]),l.useEffect(()=>{const u=Qc(s,e.length);u!==s&&a(u)},[e.length,s]),l.useEffect(()=>{if(!d.activeImage){c(null);return}const u=URL.createObjectURL(d.activeImage);return c(u),()=>URL.revokeObjectURL(u)},[d.activeImage]),e.length?r.jsxs(r.Fragment,{children:[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:e.map((u,m)=>r.jsx(c0,{file:u,index:m,onPreview:a,onRemove:()=>o(m),uploadProgress:t.get(u.name),error:n.get(u.name)},`${u.name}-${m}`))})}),d.isOpen&&i&&r.jsxs("div",{className:"fixed inset-0 z-[70] flex items-center justify-center bg-black/85 p-3 sm:p-6",onClick:()=>a(-1),role:"dialog","aria-modal":"true","aria-label":d.activeImage?.name||"Image preview",children:[r.jsx("button",{type:"button",onClick:()=>a(-1),className:"absolute right-3 top-3 rounded-full bg-white/10 p-2 text-white backdrop-blur-sm transition-colors hover:bg-white/20 sm:right-5 sm:top-5","aria-label":"Close image preview",children:r.jsx(Ht,{className:"h-5 w-5"})}),r.jsxs("div",{className:"flex max-h-full w-full max-w-5xl flex-col items-center gap-3",onClick:u=>u.stopPropagation(),children:[r.jsx("img",{src:i,alt:d.activeImage?.name||"Preview",className:"max-h-[82vh] w-auto max-w-full rounded-2xl object-contain shadow-2xl"}),r.jsx("div",{className:"max-w-full truncate px-4 text-center text-sm text-white/80",children:d.activeImage?.name})]})]})]}):null}function u0(e){if(typeof e?.percentage=="number")return`${Math.min(100,Math.max(0,e.percentage))}%`;if(typeof e?.used=="number"&&typeof e?.total=="number"&&e.total>0){const t=Math.round(e.used/e.total*100);return`${Math.min(100,Math.max(0,t))}%`}return"0%"}function p0({composer:e,statusPresentation:t,shouldShowClaudeStatus:n,isLoading:o,chatMessages:s,sendByCtrlEnter:a}){const{t:i}=St("chat"),{provider:c,currentModel:d,modelOptions:u,selectedModelLabel:m,isModelSelectionLocked:p,isOpencodeModelLoading:f,permissionMode:h,acpModes:g,acpModeId:b,handleAcpModeChange:y,selectedPermissionShortLabel:k,permissionDropdownTitle:F,providerModeConfig:E,getPermissionModeLabel:L,providerThinkingConfig:T,thinkingMode:P,setThinkingMode:I,tokenBudget:z,input:K,isInputFocused:S,setIsInputFocused:se,textareaRef:ie,inputContainerRef:U,inputHighlightRef:Q,showFileDropdown:V,filteredFiles:le,selectedFileIndex:ce,selectFile:ue,showCommandMenu:G,filteredCommands:Ae,selectedCommandIndex:O,handleCommandSelect:Z,commandQuery:ae,frequentCommands:be,slashPosition:ye,setShowCommandMenu:ke,setSelectedCommandIndex:ne,setSlashPosition:Se,setCommandQuery:We,getRootProps:ve,getInputProps:tt,isDragActive:$e,openImagePicker:je,attachedImages:Te,uploadingImages:qe,imageErrors:et,removeAttachedImage:Ke,visibleDynamicContext:Xe,visibleSelectedElements:ge,hiddenSelectedElements:Le,handleDismissSystemContext:rt,handleDismissCurrentFile:Re,handleDismissSelectedElement:Oe,renderInputWithMentions:A,handleInputChange:q,handleTextareaClick:v,handleKeyDown:x,handlePaste:C,syncInputOverlayScroll:$,handleTextareaInput:D,activeInputProvider:J,isActiveProviderNotInstalled:pe,unavailablePlaceholder:Ie,isInputDisabled:Me,activeProviderInstallReason:it,activeProviderInstallHint:me,isCheckingProviderInstallation:_e,checkProviderInstallation:Qe,providerCheckLoadingByName:ft,handleSubmit:Et,isUserScrolledUp:Nt,scrollToBottom:yt,setProviderModel:vt,setPermissionMode:we,selectedSession:Tt,handleAbortSession:Rt,canAbortSession:X,modelSelectorRef:xe,permissionSelectorRef:Ce,activeProviderInstallState:ze,activeInputProviderLabel:Ve}=e,_=zx({canAbortSession:X,hasInput:!!K.trim(),isInputDisabled:Me,isLoading:o}),H=Wx({disabled:Me||!Tt?.id,modes:g});return 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(Pp,{phaseText:t?.phaseText,detailText:t?.detailText,elapsedSeconds:t?.elapsedSeconds,startedAt:t?.startedAt,canAbort:t?.canAbort,isLoading:n,onAbort:Rt,provider:c})}),r.jsx("div",{ref:U,className:"mx-auto mb-3 w-full max-w-4xl"}),r.jsxs("form",{onSubmit:Et,className:"relative mx-auto w-full max-w-4xl",children:[Nt&&s.length>0&&r.jsx("button",{type:"button",onClick:yt,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"})})}),$e&&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:"将图片拖到这里"})]})}),r.jsx(d0,{attachedImages:Te,uploadingImages:qe,imageErrors:et,onRemove:Ke}),r.jsx(l0,{visibleDynamicContext:Xe,visibleSelectedElements:ge,hiddenSelectedElements:Le,onDismissSystemContext:rt,onDismissCurrentFile:Re,onDismissSelectedElement:Oe}),V&&le.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:le.map((oe,Be)=>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 ${Be===ce?"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:ot=>{ot.preventDefault(),ot.stopPropagation()},onClick:ot=>{ot.preventDefault(),ot.stopPropagation(),ue(oe)},children:[r.jsx("div",{className:"font-medium text-sm",children:oe.name}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono",children:oe.path})]},oe.path))}),r.jsx(Dp,{commands:Ae,selectedIndex:O,onSelect:Z,onClose:()=>{ke(!1),Se(-1),We(""),ne(-1)},position:{top:ie.current?Math.max(16,ie.current.getBoundingClientRect().top-316):0,left:ie.current?ie.current.getBoundingClientRect().left:16,bottom:ie.current?window.innerHeight-ie.current.getBoundingClientRect().top+8:90},isOpen:G,frequentCommands:ae?[]:be}),r.jsxs("div",{...ve(),className:`chat-composer-shell relative overflow-visible rounded-[20px] transition-all duration-200 ${e.isTextareaExpanded?"chat-input-expanded":""} ${S?"border-primary/40 ring-2 ring-primary/10":"hover:border-border hover:shadow-md"}`,children:[r.jsx("input",{...tt()}),r.jsx("div",{ref:Q,"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:A(K)})}),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:ie,value:K,onChange:q,onClick:v,onKeyDown:x,onPaste:C,onScroll:oe=>$(oe.target),onFocus:()=>se(!0),onBlur:()=>se(!1),onInput:D,placeholder:pe?Ie:i("input.placeholder",{provider:J==="codex"?i("messageTypes.codex"):J==="gemini"?i("messageTypes.gemini"):J==="opencode"?"OpenCode":i("messageTypes.claude")}),disabled:Me,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"}})}),pe&&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:it||Ie}),me&&r.jsx("div",{className:"mt-1 font-mono text-[11px] opacity-90 break-all",children:me}),r.jsx("div",{className:"mt-2",children:r.jsx("button",{type:"button",onClick:()=>Qe(J,{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:_e,children:i(_e?"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:()=>{Me||je()},disabled:Me,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:i("input.attachImages"),children:[r.jsx(nn,{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:xe,className:"relative min-w-0 max-w-full flex-[0_1_auto]",children:r.jsxs(fs,{value:d||void 0,onValueChange:vt,disabled:Me||f||p,children:[r.jsx(hs,{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:[f&&r.jsx($t,{className:"h-3.5 w-3.5 flex-shrink-0 animate-spin text-muted-foreground"}),r.jsx("span",{className:"truncate max-w-[120px] sm:max-w-[240px] md:max-w-[300px] text-xs font-normal text-muted-foreground",children:f?i("input.loadingModels"):m}),r.jsx(Tr,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground sm:hidden"})]})}),r.jsx(gs,{children:f?r.jsx(lo,{value:"__loading",disabled:!0,children:i("input.loadingModels")}):u.map(({value:oe,label:Be})=>r.jsx(lo,{value:oe,children:Be},oe))})]})}),r.jsx("div",{className:"relative min-w-0 max-w-full flex-[0_1_auto]",ref:Ce,children:r.jsxs(fs,{value:h,onValueChange:oe=>{we(oe),Tt&&localStorage.setItem(`permissionMode-${Tt.id}`,oe)},disabled:Me,children:[r.jsx(hs,{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:k||F||i("input.clickToChangeMode")}),r.jsx(Tr,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground sm:hidden"})]})}),r.jsx(gs,{children:r.jsxs(Rp,{children:[r.jsx(Lp,{children:F}),E.modes.map(oe=>r.jsx(lo,{value:oe,children:L(oe,{short:!0})},oe))]})})]})}),H?r.jsx(Op,{modes:g,value:b,onValueChange:y,disabled:Me||!Tt?.id,label:"智能体模式"}):null,T.enabled&&r.jsx(Fp,{selectedMode:P,onModeChange:I,className:"sm:flex-none"}),z!==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:u0(z)})]}),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:i("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:i(a?"input.hintText.ctrlEnter":"input.hintText.enter")})})]}),_.kind==="abort"?r.jsx("button",{type:"button",onClick:Rt,className:"flex h-9 w-9 items-center justify-center rounded-full bg-red-600 text-white transition-colors hover:bg-red-500",title:i("input.stop"),"aria-label":i("input.stop"),children:r.jsx($p,{className:"h-4 w-4 fill-current"})}):r.jsx("button",{type:"submit",disabled:_.disabled,onMouseDown:oe=>{oe.preventDefault(),Et(oe)},onTouchStart:oe=>{oe.preventDefault(),Et(oe)},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 m0={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"},td={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"},f0={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"},h0={OPTIONS:[{value:"kimi-k2.5",label:"Kimi K2.5"}],DEFAULT:"kimi-k2.5"},g0=["claude","codex","gemini","opencode"],eo="unknown",x0="installed",ts="not_installed",y0="checking",v0=["claude","codex","gemini","opencode"],b0=300*1e3;function Zt(e){const t=String(e||"").trim().toLowerCase();return g0.includes(t)?t:"claude"}function w0(e){switch(e){case"codex":return td;case"gemini":return f0;case"opencode":return h0;case"claude":default:return m0}}function Ro(e){return`${Zt(e)}-model`}function fa(e){return`${Ro(e)}-selection-source`}function to(e){const t=Zt(e),n=Ro(t),o=fa(t);return localStorage.getItem(o)!=="manual"?"":localStorage.getItem(n)||""}function k0(e,t){const n=Zt(e);localStorage.setItem(Ro(n),t),localStorage.setItem(fa(n),"manual")}function j0(e){const t=Zt(e);localStorage.removeItem(Ro(t)),localStorage.removeItem(fa(t))}function rd(e){if(typeof e!="string")return!1;const t=e.trim().toLowerCase();return t.length>0&&t!=="custom"&&t!=="default"}const S0=new Set(td.OPTIONS.map(e=>String(e?.value||"").trim().toLowerCase()).filter(Boolean));function N0(e){if(!rd(e))return!1;const t=e.trim().toLowerCase();return S0.has(t)?!0:/^(gpt-\d|o[1345](?:$|[-.])|codex(?:$|[-.]))/i.test(t)}function C0(e,t){return Zt(e)==="codex"?N0(t):rd(t)}function ro(e){return typeof e=="string"&&/^codex-\d+$/.test(e.trim())}const ci=new WeakMap;let E0=0;function A0(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 o=(()=>{const i=e?.timestamp instanceof Date?e.timestamp.getTime():new Date(e?.timestamp||Date.now()).getTime();return Number.isNaN(i)?Date.now():i})(),s=String(e?.role||e?.type||"assistant"),a=String(e?.provider||e?.__provider||"");if(e&&typeof e=="object"){const i=ci.get(e);if(i)return i;const c=`${s}:${a}:${o}:runtime-${E0++}`;return ci.set(e,c),c}return`${s}:${a}:${o}:${t}`}const bt={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){const o=n.slice(-50);t=JSON.stringify(o)}}catch(n){console.warn("Could not parse chat messages for truncation:",n)}localStorage.setItem(e,t)}catch(n){if(n.name==="QuotaExceededError"){const o=Object.keys(localStorage),s=o.filter(i=>i.startsWith("chat_messages_")).sort();s.length>3&&s.slice(0,s.length-3).forEach(i=>{localStorage.removeItem(i)}),o.filter(i=>i.startsWith("draft_input_")).forEach(i=>{localStorage.removeItem(i)});try{localStorage.setItem(e,t)}catch(i){if(e.startsWith("chat_messages_")&&typeof t=="string")try{const c=JSON.parse(t);Array.isArray(c)&&c.length>10&&localStorage.setItem(e,JSON.stringify(c.slice(-10)))}catch(c){console.error("Final save attempt failed:",c)}else console.error("Failed to save to localStorage even after cleanup:",i)}}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 nd(e){return e?`chat_messages_${e}`:""}function od(e,t=null){return e?t?`chat_messages_${e}__session_${t}`:nd(e):""}function _0(e,t=null){const n=od(e,t);if(!n)return[];const o=bt.getItem(n);if(!o)return[];try{return pa(JSON.parse(o))}catch(s){return console.warn("Failed to parse cached chat messages:",s),[]}}function sd(e,t=null,n=[]){const o=od(e,t);if(!o)return;const s=pa(n);if(s.length===0){bt.removeItem(o);return}bt.setItem(o,JSON.stringify(s)),t&&bt.removeItem(nd(e))}const ad="claude-settings";function I0(){const e=bt.getItem(ad);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 T0(e){if(!e)return{success:!1};const t=I0(),n=t.allowedTools.includes(e),o=n?t.allowedTools:[...t.allowedTools,e],s=t.disallowedTools.filter(i=>i!==e),a={...t,allowedTools:o,disallowedTools:s,lastUpdated:new Date().toISOString()};return bt.setItem(ad,JSON.stringify(a)),{success:!0,alreadyAllowed:n,updatedSettings:a}}const M0=100;function di(e){const t=e?.extensions?.clientRequestId||e?.payload?.clientRequestId||null;return typeof t=="string"&&t.trim()?t.trim():null}function P0(e,t){if(!e||!t)return!1;const n=di(e),o=di(t);return n&&o&&n===o?e.kind===t.kind&&e.provider===t.provider&&e.sessionId===t.sessionId:e.eventId&&t.eventId&&e.eventId===t.eventId?!0: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 D0({selectedProject:e,selectedProjectRef:t,selectedSession:n,currentSessionId:o,setCurrentSessionId:s,provider:a,runtimePhase:i,isLoading:c,isLoadingRef:d,processingSessions:u,autoScrollToBottom:m,externalMessageUpdate:p,ws:f,sendMessage:h,chatMessages:g,setChatMessages:b,setIsLoading:y,setCanAbortSession:k,setRuntimePhase:F,setClaudeStatus:E,setPendingPermissionRequests:L,resetStreamingState:T,clearLocalRunGuard:P,localRunGuardRef:I,pendingViewSessionRef:z,isSystemSessionChange:K,setIsSystemSessionChange:S,onSessionInactive:se,onSessionNotProcessing:ie,onSessionProcessing:U}){const[Q,V]=l.useState([]),[le,ce]=l.useState(!1),[ue,G]=l.useState(!1),[Ae,O]=l.useState(0),[Z,ae]=l.useState(!1),[be,ye]=l.useState(0),[ke,ne]=l.useState(null),[Se,We]=l.useState(!1),[ve,tt]=l.useState(100),$e=l.useRef(null),je=l.useRef(null),Te=l.useRef(!1),qe=l.useRef(!1),et=l.useRef(0),Ke=l.useRef(!1),Xe=l.useRef(null),ge=l.useRef({height:0,top:0}),Le=l.useRef(new Map),rt=l.useRef(p),Re=l.useRef(null),Oe=l.useRef(n),A=e?.fullPath||e?.path||null;l.useEffect(()=>()=>{Le.current.forEach(X=>clearTimeout(X)),Le.current.clear(),Re.current&&(clearTimeout(Re.current),Re.current=null)},[]),l.useEffect(()=>{Oe.current=n},[n]);const q=l.useCallback(async(X,xe,Ce=!1,ze="claude",Ve=null)=>{if(!X||!xe)return[];const _=!Ce;_?ce(!0):G(!0);try{const H=Ve??(Ce?et.current:0),oe=await st.sessionEvents(ze,xe,X,A,M0,H);if(!oe.ok)throw new Error("Failed to load session messages");const Be=await oe.json();if(_&&Be.tokenUsage&&ne(Be.tokenUsage),Be.hasMore!==void 0){ae(Be.hasMore),ye(Be.total);const N=H+(Be.events?.length||0);return et.current=N,O(N),Be.events||[]}const ot=Be.events||Be.messages||[];return ae(!1),ye(ot.length),et.current=ot.length,O(ot.length),ot}catch(H){return console.error("Error loading session messages:",H),[]}finally{_?ce(!1):G(!1)}},[A]),v=l.useCallback((X,xe="claude")=>Gc(X,xe).map(Ce=>({...Ce,provider:Ce.provider||xe})),[]),x=n?.__provider||a||"claude",C=l.useMemo(()=>v(Q,x),[x,v,Q]),$=l.useCallback((X=[])=>Cx(X),[]),D=l.useCallback((X=[])=>Ex(X),[]),J=l.useCallback(X=>!(X===he.COMPLETED||X===he.ABORTED||X===he.ERRORED),[]),pe=l.useCallback((X,xe)=>xe&&(F(xe),(xe===he.COMPLETED||xe===he.ABORTED||xe===he.ERRORED)&&(P(X),E(null),X&&(se?.(X),ie?.(X))),xe),[P,se,ie,E,F]),Ie=l.useCallback(async(X,xe)=>{const Ce=t.current;if(!Ce?.name||!X)return null;const ze=await q(Ce.name,X,!1,xe||x);return Array.isArray(ze)&&ze.length>0&&V(ze),$(ze)},[x,$,q,t]),Me=l.useCallback(async(X,xe)=>{const Ce=await Ie(X,xe);return pe(X,Ce)},[Ie,pe]),it=l.useCallback((X,xe=[])=>{const Ce=$(xe);return pe(X,Ce),Ce},[$,pe]),me=l.useCallback((X,xe)=>xe===he.COMPLETED||xe===he.ABORTED||xe===he.ERRORED?(pe(X,xe),xe):null,[pe]),_e=l.useCallback((X,xe)=>{if(!X)return;const Ce=Le.current.get(X);Ce&&clearTimeout(Ce);const ze=setTimeout(()=>{Le.current.delete(X);const Ve=n?.id||o||null;!Ve||Ve!==X||(Me(X,xe),h&&h({type:"check-session-status",sessionId:X,provider:xe||x}))},1200);Le.current.set(X,ze)},[x,o,Me,n?.id,h]),Qe=l.useCallback(()=>{je.current&&(je.current.scrollTop=je.current.scrollHeight)},[]),ft=l.useCallback(()=>{if(!je.current)return!1;const{scrollTop:X,scrollHeight:xe,clientHeight:Ce}=je.current;return xe-X-Ce<50},[]),Et=l.useCallback(async(X=null)=>{const xe=X||je.current;if(!xe||qe.current||ue||!Z||!n||!e)return!1;const Ce=n.__provider||a||"claude";qe.current=!0;const ze=xe.scrollHeight,Ve=xe.scrollTop,_=et.current;try{const H=await q(e.name,n.id,!0,Ce,_);return H.length>0&&(Xe.current={height:ze,top:Ve},V(oe=>[...H,...oe])),!0}finally{qe.current=!1}},[Z,ue,q,a,e,n]),Nt=l.useCallback(async()=>{if(je.current){const X=je.current,xe=ft();We(!xe),X.scrollTop<100?Ke.current||await Et(X)&&(Ke.current=!0):Ke.current=!1}},[ft,Et]);l.useLayoutEffect(()=>{if(!Xe.current||!je.current)return;const{height:X,top:xe}=Xe.current,Ce=je.current,Ve=Ce.scrollHeight-X;Ce.scrollTop=xe+Math.max(Ve,0),Xe.current=null},[g.length]),l.useEffect(()=>{let X=!1,xe=null;return(async()=>{if(n&&e){const ze=n.__provider||Zt(localStorage.getItem("selected-provider"));Te.current=!0,sessionStorage.removeItem("pendingSessionId");const Ve=o!==null&&o!==n.id;let _=null;if(Ve?(K||(T(),P(),z.current=null,b([]),V([]),E(null),k(!1)),et.current=0,O(0),ae(!1),ye(0),ne(null),y(!1)):o===null&&(et.current=0,O(0),ae(!1),ye(0)),s(n.id),K)X||S(!1);else{const H=await q(e.name,n.id,!1,n.__provider||ze||"claude");if(X)return;V(H),_=it(n.id,H),_||F(he.IDLE),f&&h&&J(_)&&h({type:"check-session-status",sessionId:n.id,provider:ze})}}else{const Ve=z.current?.sessionId||null||d.current&&(o||I.current.sessionId)||null,_=!!(Ve||d.current);K||_||(T(),P(),z.current=null,b([]),V([]),E(null),k(!1),y(!1)),s(Ve),et.current=0,O(0),ae(!1),ye(0),ne(null)}xe=setTimeout(()=>{X||(Te.current=!1)},250)})(),()=>{X=!0,xe&&clearTimeout(xe)}},[n?.id,n?.__provider,e?.name,e?.fullPath,e?.path,q,K,T,P,it,h,F,J,f]),l.useEffect(()=>{const X=rt.current;if(p<=X||(rt.current=p,!n||!e))return;const xe=n.id,Ce=e.name,ze=e.fullPath||e.path||null,Ve=async()=>{try{const _=n.__provider||Zt(localStorage.getItem("selected-provider")),H=await q(Ce,xe,!1,n.__provider||_||"claude"),oe=t.current,Be=Oe.current,ot=oe?.fullPath||oe?.path||null;if(Be?.id!==xe||oe?.name!==Ce||ot!==ze)return;V(H),m&&ft()&&setTimeout(()=>Qe(),200)}catch(_){console.error("Error reloading messages from external update:",_)}};return Re.current&&clearTimeout(Re.current),Re.current=setTimeout(()=>{Re.current=null,Ve()},500),()=>{Re.current&&(clearTimeout(Re.current),Re.current=null)}},[m,p,ft,q,Qe,e,t,n]),l.useEffect(()=>{rt.current=p},[p,e?.name,n?.id]),l.useEffect(()=>{n?.id&&(z.current=null)},[z,n?.id]),l.useEffect(()=>{const X=n?.id||o||null,xe=I.current,Ce=!!(xe.startedAt&&(!xe.sessionId||!X||xe.sessionId===X)&&i!==he.IDLE);b(ze=>Nx(ze,C,{preserveLocalTail:Ce}))},[C,o,I,i,n?.id,b]),l.useEffect(()=>{e?.name&&sd(e.name,n?.id||null,g)},[g,e?.name,n?.id]),l.useEffect(()=>{const X=pa(g);Lx(g,X)||b(X)},[g,b]),l.useEffect(()=>{o&&c&&U&&U(o)},[o,c,U]),l.useEffect(()=>{if(o&&u){const X=u.has(o),xe=D(Q);if(X&&xe){ie?.(o);return}X&&!c&&i!==he.COMPLETED&&i!==he.ABORTED&&i!==he.ERRORED&&F(he.STREAMING,{canAbortSession:!0})}},[o,D,c,ie,u,i,Q,F]);const yt=l.useMemo(()=>n||g.length<=ve?g:g.slice(-ve),[g,n,ve]),vt=l.useMemo(()=>{const X=yt.map((Ce,ze)=>({...Ce,__threadMessageId:A0(Ce,ze)}));return X.length===0||!c||X.some(Ce=>Ce?.type==="assistant"&&!!(Ce.isStreaming||Ce.isToolUse||Ce.isThinking||Ce.reasoning))?X:[...X,{id:"__assistant-loading-indicator__",type:"assistant",content:"",timestamp:new Date,isLoadingIndicator:!0,__provider:n?.__provider||a||"claude"}]},[c,a,n?.__provider,yt]);l.useEffect(()=>{if(!m&&je.current){const X=je.current;ge.current={height:X.scrollHeight,top:X.scrollTop}}}),l.useEffect(()=>{if(je.current&&g.length>0)if(m)Se||setTimeout(()=>Qe(),50);else{const X=je.current,xe=ge.current.height,Ce=ge.current.top,Ve=X.scrollHeight-xe;Ve>0&&Ce>0&&(X.scrollTop=Ce+Ve)}},[m,g.length,Se,Qe]),l.useEffect(()=>{je.current&&g.length>0&&!Te.current&&(We(!1),setTimeout(()=>{Qe()},200))},[g.length,Qe,e?.name,n?.id]),l.useEffect(()=>{const X=je.current;if(X)return X.addEventListener("scroll",Nt),()=>X.removeEventListener("scroll",Nt)},[Nt]),l.useEffect(()=>{if(!e||!n?.id||n.id.startsWith("new-session-")){ne(null);return}if((n.__provider||a||"claude")!=="claude")return;(async()=>{try{const Ce=`/api/projects/${e.name}/sessions/${n.id}/token-usage`,ze=await fe(Ce);if(ze.ok){const Ve=await ze.json();ne(Ve)}else ne(null)}catch(Ce){console.error("Failed to fetch initial token usage:",Ce)}})()},[a,e,n?.__provider,n?.id]);const we=l.useCallback(()=>{tt(X=>X+100)},[]),Tt=l.useCallback(X=>{!X||typeof X!="object"||V(xe=>{const Ce=Array.isArray(xe)?xe:[];return Ce.some(ze=>P0(ze,X))?Ce:[...Ce,X]})},[]),Rt=l.useCallback(()=>{z.current=null,sessionStorage.removeItem("pendingSessionId"),s(null),V([]),b([]),L([]),S(!1),F(he.IDLE),E(null),k(!1),ne(null),We(!1),e?.name&&(bt.removeItem(`chat_messages_${e.name}`),bt.removeItem(`draft_input_${e.name}`))},[z,e?.name,k,b,E,s,S,L,F]);return{sessionMessages:Q,setSessionMessages:V,isLoadingSessionMessages:le,isLoadingMoreMessages:ue,messagesOffset:Ae,hasMoreMessages:Z,totalMessages:be,tokenBudget:ke,setTokenBudget:ne,scrollContainerRef:je,messagesEndRef:$e,isUserScrolledUp:Se,setIsUserScrolledUp:We,visibleMessageCount:ve,threadMessages:vt,scrollToBottom:Qe,handleScroll:Nt,loadOlderMessages:Et,loadEarlierMessages:we,loadSessionMessages:q,appendSessionConversationEvent:Tt,inferRuntimePhaseFromSessionEvents:$,inferTerminalPhaseFromSessionEvents:D,recoverAndSettleSessionRuntime:Me,recoverTerminalSessionPhase:me,scheduleSessionStatusRecovery:_e,resetSessionHistoryForNewChat:Rt}}function ui(e,t={}){const n=Array.isArray(t?.availableModes)?t.availableModes.filter(s=>s&&typeof s=="object"&&String(s.id||"").trim()).map(s=>({id:String(s.id).trim(),name:String(s.name||s.id||"").trim()||String(s.id).trim(),description:typeof s.description=="string"?s.description:""})):[],o=typeof t?.currentModeId=="string"&&t.currentModeId.trim()?t.currentModeId.trim():null;return!o&&n.length===0?e||null:{availableModes:n.length>0?n:Array.isArray(e?.availableModes)?e.availableModes:[],currentModeId:o||e?.currentModeId||null}}function R0(e={}){return Array.isArray(e?.availableCommands)?e.availableCommands.filter(t=>t&&typeof t=="object"&&String(t.name||"").trim()).map(t=>({name:String(t.name).trim(),description:typeof t.description=="string"?t.description:"",input:t.input&&typeof t.input=="object"?t.input:null,type:"acp",source:"acp",namespace:"acp"})):[]}function L0({latestMessage:e,provider:t,claudeStatus:n,selectedProject:o,selectedSession:s,currentSessionId:a,setCurrentSessionId:i,isLoading:c,runtimePhase:d,sendMessage:u,persistCurrentChatCache:m,setRuntimePhase:p,setIsSystemSessionChange:f,setPendingPermissionRequests:h,setIsLoading:g,setCanAbortSession:b,setClaudeStatus:y,setChatMessages:k,setTokenBudget:F,setAcpSessionModeState:E,setAcpAvailableCommands:L,applyRealtimeConversationEvent:T,streamBufferRef:P,streamTimerRef:I,clearLocalRunGuard:z,syncLocalRunGuardSession:K,shouldIgnoreStaleIdleSignal:S,pendingViewSessionRef:se,appendSessionConversationEvent:ie,recoverAndSettleSessionRuntime:U,recoverTerminalSessionPhase:Q,inferRuntimePhaseFromSessionEvents:V,inferTerminalPhaseFromSessionEvents:le,scheduleSessionStatusRecovery:ce,sessionMessages:ue,setSessionMessages:G,loadSessionMessages:Ae,onSessionInactive:O,onSessionNotProcessing:Z,onSessionProcessing:ae,onReplaceTemporarySession:be,onNavigateToSession:ye,t:ke}){const ne=l.useRef(null),Se=l.useRef(new Set),We=s?.__provider||t||"claude";l.useEffect(()=>()=>{I.current&&(clearTimeout(I.current),I.current=null),P.current=""},[P,I]),l.useEffect(()=>{ne.current=n},[n]),l.useEffect(()=>{if(!e)return;const ve=e.data?.message||e.data,$e=["projects_updated","session-created"].includes(e.type),je=new Set(["claude-complete","codex-complete","session-aborted","claude-error","codex-error"]),Te=e.type==="conversation-event"?String(e.event?.payload?.state||"").trim().toLowerCase():"",qe=e.type==="conversation-event"&&(e.event?.kind==="error"||e.event?.kind==="session_state_changed"&&["streaming","awaiting_approval","completed","aborted","errored"].includes(Te)),Ke=e.type==="claude-response"&&ve&&ve.type==="system"&&ve.subtype==="init"?ve?.session_id:null,Xe=sessionStorage.getItem("pendingSessionId");let ge=s?.id||a||se.current?.sessionId||null;const Le=Ke&&(!ge||Ke===ge),rt=$e||Le,Re=!e.sessionId&&se.current&&!se.current.sessionId&&(/error/i.test(e.type||"")||e.type==="conversation-event"&&e.event?.kind==="error"),Oe=x=>{x&&(O?.(x),Z?.(x))},A=x=>{x&&ae?.(x)};if(!rt){if(!ge&&e.sessionId&&!ro(e.sessionId)&&se.current&&!se.current.sessionId&&(ge=e.sessionId,se.current.sessionId=e.sessionId,i(e.sessionId)),!ge&&(e.sessionId&&(je.has(e.type)||qe)&&(Te==="streaming"||Te==="awaiting_approval"?A(e.sessionId):Oe(e.sessionId)),!Re)||!e.sessionId&&!Re)return;if(!Re&&e.sessionId!==ge){const x=ro(ge),C=!!(e.sessionId&&Xe&&e.sessionId===Xe);if(x&&(C||!ro(e.sessionId||"")))i(e.sessionId),se.current&&(se.current.sessionId=e.sessionId);else{e.sessionId&&(je.has(e.type)||qe)&&(Te==="streaming"||Te==="awaiting_approval"?A(e.sessionId):Oe(e.sessionId)),console.log("Skipping message for different session:",e.sessionId,"current:",ge);return}}}const q=e?.event?.sessionId||e.sessionId||ge||null,v=!!(q&&Se.current.has(q));if(e.type==="conversation-event"&&e.event){const x=e.event.sessionId||e.sessionId||ge||null,C=e.event.rawRef?.type||null,$=e.event.kind==="session_state_changed"?String(e.event.payload?.state||"").trim().toLowerCase():"";if(x&&Se.current.add(x),$==="idle"&&S(x,C)){ce(x,e.event.provider||We);return}if(!!(x&&(x===(s?.id||null)||x===(a||null)||x===(se.current?.sessionId||null)))&&ie(e.event),T(e.event,e.event.provider||We),e.event.kind==="mode_update"&&E(J=>ui(J,e.event.payload)),e.event.kind==="available_commands_update"&&L(R0(e.event.payload)),e.event.kind==="approval_request"&&p(he.AWAITING_APPROVAL),e.event.kind==="approval_resolved"&&p(he.STREAMING),(e.event.kind==="assistant_text_start"||e.event.kind==="assistant_text_delta"||e.event.kind==="assistant_content_block"||e.event.kind==="reasoning_start"||e.event.kind==="reasoning_delta"||e.event.kind==="tool_call_start"||e.event.kind==="tool_call_input"||e.event.kind==="tool_call_end"||e.event.kind==="tool_result"||e.event.kind==="plan_update")&&p(he.STREAMING),(e.event.kind==="error"||e.event.payload?.state==="errored")&&(z(x),p(he.ERRORED),y(null),x&&(Oe(x),U(x,e.event.provider||We))),e.event.kind==="session_state_changed"){const J=$;J==="streaming"?(p(he.STREAMING),x&&ae&&ae(x)):J==="awaiting_approval"?(p(he.AWAITING_APPROVAL),x&&ae&&ae(x)):J==="completed"?(z(x),p(he.COMPLETED),y(null),x&&(Oe(x),U(x,e.event.provider||We))):J==="aborted"?(z(x),p(he.ABORTED),y(null),x&&(Oe(x),U(x,e.event.provider||We))):J==="errored"&&(z(x),p(he.ERRORED),y(null),x&&(Oe(x),U(x,e.event.provider||We)))}return}switch(e.type){case"ws-connection-state":e.state==="connecting"&&(d===he.QUEUED||c)?p(he.CONNECTING,{canAbortSession:!1}):e.state==="connected"&&d===he.CONNECTING&&p(he.QUEUED);break;case"connection-error":p(he.ERRORED),y(null),k(x=>[...x,{type:"error",content:e.error||"Unable to reach the chat server. Message was not sent.",timestamp:new Date}]);break;case"error":p(he.ERRORED),b(!1),y(null),k(x=>[...x,{type:"error",content:e.error||"The chat server reported an unexpected error.",timestamp:new Date}]);break;case"session-created":if(e.sessionId){const x=Zt(e.provider||We||t||"claude"),C=se.current?.sessionId||a||null,$=ro(e.sessionId);if(!(!a||x==="codex"&&e.sessionId!==a)||$)break;sessionStorage.setItem("pendingSessionId",e.sessionId);try{const J=localStorage.getItem("session-provider-map"),pe=J?JSON.parse(J):{};pe[e.sessionId]=x,localStorage.setItem("session-provider-map",JSON.stringify(pe))}catch{}m(e.sessionId),e.modes&&E(J=>ui(J,e.modes)),se.current&&(se.current.sessionId=e.sessionId),i(e.sessionId),K(e.sessionId),ae?.(e.sessionId),f(!0),be&&be(e.sessionId,C),h(J=>J.map(pe=>pe.sessionId?pe:{...pe,sessionId:e.sessionId})),ye&&ye(e.sessionId,x,o?.fullPath||o?.path||null),typeof window<"u"&&typeof window.refreshProjects=="function"&&window.refreshProjects()}break;case"token-budget":e.data&&F(e.data);break;case"claude-response":{const x=v&&!(e.data?.type==="system"&&e.data?.subtype==="init");if(!x&&ve&&typeof ve=="object"&&ve.type){if(ve.type==="content_block_delta"&&ve.delta?.text){const C=Pr(ve.delta.text);P.current+=C,I.current||(I.current=setTimeout(()=>{const $=P.current;P.current="",I.current=null,$&&k(D=>{const J=[...D],pe=J[J.length-1];return pe&&pe.type==="assistant"&&!pe.isToolUse&&pe.isStreaming?J[J.length-1]={...pe,content:(pe.content||"")+$}:J.push({type:"assistant",content:$,timestamp:new Date,isStreaming:!0}),J})},100));return}if(ve.type==="content_block_stop"){I.current&&(clearTimeout(I.current),I.current=null);const C=P.current;P.current="",C&&k($=>{const D=[...$],J=D[D.length-1];return J&&J.type==="assistant"&&!J.isToolUse&&J.isStreaming?D[D.length-1]={...J,content:(J.content||"")+C}:D.push({type:"assistant",content:C,timestamp:new Date,isStreaming:!0}),D}),k($=>{const D=[...$],J=D[D.length-1];return J&&J.type==="assistant"&&J.isStreaming&&(D[D.length-1]={...J,isStreaming:!1}),D});return}}if(e.data.type==="system"&&e.data.subtype==="init"&&e.data.session_id&&a&&e.data.session_id!==a&&Le){f(!0),m(e.data.session_id),ye?.(e.data.session_id,"claude",o?.fullPath||o?.path||null);return}if(e.data.type==="system"&&e.data.subtype==="init"&&e.data.session_id&&!a&&Le){f(!0),m(e.data.session_id),ye?.(e.data.session_id,"claude",o?.fullPath||o?.path||null);return}if(e.data.type==="system"&&e.data.subtype==="init"&&e.data.session_id&&a&&e.data.session_id===a&&Le)return;if(x)break;if(Array.isArray(ve.content)){for(const C of ve.content)if(C.type==="tool_use"){const $=C.input?JSON.stringify(C.input,null,2):"";k(D=>[...D,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:C.name,toolInput:$,toolId:C.id,toolResult:null}])}else if(C.type==="text"&&C.text?.trim()){let $=Pr(C.text);$=_s($),k(D=>[...D,{type:"assistant",content:$,timestamp:new Date}])}}else if(typeof ve.content=="string"&&ve.content.trim()){let C=Pr(ve.content);C=_s(C),k($=>[...$,{type:"assistant",content:C,timestamp:new Date}])}if(ve.role==="user"&&Array.isArray(ve.content))for(const C of ve.content)C.type==="tool_result"&&k($=>$.map(D=>D.isToolUse&&D.toolId===C.tool_use_id?{...D,toolResult:{content:C.content,isError:C.is_error,timestamp:new Date}}:D));break}case"claude-output":if(v)break;{const x=String(e.data||"");x.trim()&&(P.current+=P.current?`
259
+ ${x}`:x,I.current||(I.current=setTimeout(()=>{const C=P.current;P.current="",I.current=null,C&&k($=>{const D=[...$],J=D[D.length-1];return J&&J.type==="assistant"&&!J.isToolUse&&J.isStreaming?D[D.length-1]={...J,content:J.content?`${J.content}
260
+ ${C}`:C}:D.push({type:"assistant",content:C,timestamp:new Date,isStreaming:!0}),D})},100)))}break;case"claude-interactive-prompt":k(x=>[...x,{type:"assistant",content:e.data,timestamp:new Date,isInteractivePrompt:!0}]);break;case"claude-permission-request":if(v||t!=="claude"||!e.requestId)break;h(x=>x.some(C=>C.requestId===e.requestId)?x:[...x,{requestId:e.requestId,toolName:e.toolName||"UnknownTool",input:e.input,context:e.context,toolCall:e.toolCall||null,options:Array.isArray(e.options)?e.options:Array.isArray(e.context?.options)?e.context.options:[],message:e.message||null,sessionId:e.sessionId||null,receivedAt:new Date}]),g(!0),b(!0),y(ma({phaseText:ke("activity.stage.waitingPermission"),detailText:e.toolName?ke("activity.requestTool",{tool:Bp(e.toolName)}):ke("activity.permission.title"),canAbort:!0}));break;case"claude-permission-cancelled":if(v||!e.requestId)break;h(x=>{const C=x.filter($=>$.requestId!==e.requestId);return C.length===0&&y(null),C});break;case"claude-error":if(v)break;z(e.sessionId||a||null),g(!1),b(!1),y(null),k(x=>[...x,{type:"error",content:`出错了:${e.error}`,timestamp:new Date}]);break;case"claude-complete":{if(v)break;const x=e.sessionId||a||sessionStorage.getItem("pendingSessionId");z(x),(x===a||!a)&&(g(!1),b(!1),y(null)),x&&(O?.(x),Z?.(x));const C=sessionStorage.getItem("pendingSessionId");C&&!a&&e.exitCode===0&&(i(C),sessionStorage.removeItem("pendingSessionId")),o&&e.exitCode===0&&bt.removeItem(`chat_messages_${o.name}`),h([]);break}case"codex-response":{const x=e.data;if(!x||v)break;if(x.type==="item_delta"&&x.delta){const C=Pr(String(x.delta));if(C){const $=`codex:${x.itemType||"item"}:${x.itemId||"unknown"}`;k(D=>{const J=[...D];let pe=-1;for(let Ie=J.length-1;Ie>=0;Ie-=1){const Me=J[Ie];if(Me?.codexItemKey===$&&Me.type==="assistant"&&!Me.isToolUse){pe=Ie;break}}if(pe===-1)J.push({type:"assistant",content:C,timestamp:new Date,isStreaming:!0,isThinking:!!x.isReasoning,codexItemKey:$});else{const Ie=J[pe],Me=Ie.content||"";Me.endsWith(C)||(Ie.content=Me+C),Ie.isStreaming=!0}return J})}break}if(x.type==="item_done"){const C=`codex:${x.itemType||"item"}:${x.itemId||"unknown"}`,$=typeof x.content=="string"?Pr(x.content):"";k(D=>{const J=[...D];let pe=-1;for(let Ie=J.length-1;Ie>=0;Ie-=1){const Me=J[Ie];if(Me?.codexItemKey===C&&Me.type==="assistant"&&!Me.isToolUse){pe=Ie;break}}if(pe!==-1){const Ie=J[pe];$&&$!==(Ie.content||"")&&(Ie.content=$),Ie.isStreaming=!1}else $.trim()&&J.push({type:"assistant",content:$,timestamp:new Date,isStreaming:!1,isThinking:!!x.isReasoning});return J});break}if(x.type==="item")switch(x.itemType){case"agent_message":if(x.message?.content?.trim()){const C=Pr(x.message.content);k($=>{const D=$[$.length-1];return D&&D.type==="assistant"&&!D.isToolUse&&!D.isThinking&&(D.content||"").trim()===C.trim()?$:[...$,{type:"assistant",content:C,timestamp:new Date}]})}break;case"reasoning":if(x.message?.content?.trim()){const C=Pr(x.message.content);k($=>{const D=$[$.length-1];return D&&D.type==="assistant"&&!D.isToolUse&&D.isThinking&&(D.content||"").trim()===C.trim()?$:[...$,{type:"assistant",content:C,timestamp:new Date,isThinking:!0}]})}break;case"command_execution":x.command&&k(C=>[...C,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:"Bash",toolInput:x.command,toolResult:x.output||null,exitCode:x.exitCode}]);break;case"file_change":if(x.changes?.length>0){const C=x.changes.map($=>`${$.kind}: ${$.path}`).join(`
261
+ `);k($=>[...$,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:"FileChanges",toolInput:C,toolResult:`Status: ${x.status}`}])}break;case"mcp_tool_call":k(C=>[...C,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:`${x.server}:${x.tool}`,toolInput:JSON.stringify(x.arguments,null,2),toolResult:x.result?JSON.stringify(x.result,null,2):x.error?.message||null}]);break;case"error":x.message?.content&&k(C=>[...C,{type:"error",content:x.message.content,timestamp:new Date}]);break;default:console.log("[Codex] Unhandled item type:",x.itemType,x)}x.type==="turn_complete"&&g(!1),x.type==="turn_failed"&&(g(!1),k(C=>[...C,{type:"error",content:x.error?.message||"Turn failed",timestamp:new Date}]));break}case"codex-complete":{if(v)break;const x=e.sessionId||a||sessionStorage.getItem("pendingSessionId");z(x),(x===a||!a)&&(g(!1),b(!1),y(null),k(D=>D.map(J=>J?.codexItemKey&&J.isStreaming?{...J,isStreaming:!1}:J))),x&&(O?.(x),Z?.(x));const C=sessionStorage.getItem("pendingSessionId"),$=e.actualSessionId||C;C&&!a&&(i($),f(!0),ye?.($,"codex",o?.fullPath||o?.path||null),sessionStorage.removeItem("pendingSessionId")),o&&x&&Ae(o.name,x,!1,"codex").then(D=>{Array.isArray(D)&&D.length>0&&G(D)}).catch(D=>{console.error("Error reloading Codex session after completion:",D)}),o&&bt.removeItem(`chat_messages_${o.name}`);break}case"codex-error":if(v)break;z(e.sessionId||a||null),g(!1),b(!1),k(x=>x.map(C=>C?.codexItemKey&&C.isStreaming?{...C,isStreaming:!1}:C)),k(x=>[...x,{type:"error",content:e.error||"An error occurred with Codex",timestamp:new Date}]);break;case"session-aborted":{if(v)break;const x=e.sessionId||a;z(x),x===a&&(g(!1),b(!1),y(null)),x&&(O?.(x),Z?.(x)),h([]),k(C=>[...C,{type:"assistant",content:"Session interrupted by user.",timestamp:new Date}]);break}case"session-status":{if(v)break;const x=e.sessionId,C=e.provider||s?.__provider||We,$=x===a||s&&x===s.id,D=V(ue),J=le(ue);if($&&e.isProcessing){if(J){Q(x,J);break}g(!0),b(!0),ae?.(x)}else if($&&e.isProcessing===!1){if(S(x,"session-status")){ce(x,C);break}U(x,C).then(pe=>{if(!(pe===he.COMPLETED||pe===he.ABORTED||pe===he.ERRORED)){if(D===he.STREAMING||D===he.AWAITING_APPROVAL){p(D);return}g(!1),b(!1),y(null)}})}break}case"claude-status":{const x=e.data;if(x){let C={text:"Working...",tokens:0,can_interrupt:!0};x.message?C.text=x.message:x.status?C.text=x.status:typeof x=="string"&&(C.text=x),x.tokens?C.tokens=x.tokens:x.token_count&&(C.tokens=x.token_count),x.can_interrupt!==void 0&&(C.can_interrupt=x.can_interrupt);const $=Ox(x,ke,ne.current);ne.current=$,y($),g(!0),b(C.can_interrupt)}break}}},[We,ie,T,z,a,V,le,c,e,Ae,ye,be,O,Z,ae,se,m,t,U,Q,d,ce,o,s,ue,L,E,b,k,y,i,g,f,h,G,F,S,K,ke])}function Sr(e){return Array.isArray?Array.isArray(e):cd(e)==="[object Array]"}function O0(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function F0(e){return e==null?"":O0(e)}function gr(e){return typeof e=="string"}function id(e){return typeof e=="number"}function $0(e){return e===!0||e===!1||B0(e)&&cd(e)=="[object Boolean]"}function ld(e){return typeof e=="object"}function B0(e){return ld(e)&&e!==null}function Yt(e){return e!=null}function rs(e){return!e.trim().length}function cd(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const z0="Incorrect 'index' type",W0=e=>`Invalid value for key ${e}`,U0=e=>`Pattern length exceeds max of ${e}.`,H0=e=>`Missing ${e} property in key`,q0=e=>`Property 'weight' in key '${e}' must be a positive integer`,pi=Object.prototype.hasOwnProperty;class K0{constructor(t){this._keys=[],this._keyMap={};let n=0;t.forEach(o=>{let s=dd(o);this._keys.push(s),this._keyMap[s.id]=s,n+=s.weight}),this._keys.forEach(o=>{o.weight/=n})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function dd(e){let t=null,n=null,o=null,s=1,a=null;if(gr(e)||Sr(e))o=e,t=mi(e),n=Ps(e);else{if(!pi.call(e,"name"))throw new Error(H0("name"));const i=e.name;if(o=i,pi.call(e,"weight")&&(s=e.weight,s<=0))throw new Error(q0(i));t=mi(i),n=Ps(i),a=e.getFn}return{path:t,id:n,weight:s,src:o,getFn:a}}function mi(e){return Sr(e)?e:e.split(".")}function Ps(e){return Sr(e)?e.join("."):e}function V0(e,t){let n=[],o=!1;const s=(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&&(gr(u)||id(u)||$0(u)))n.push(F0(u));else if(Sr(u)){o=!0;for(let m=0,p=u.length;m<p;m+=1)s(u[m],i,c+1)}else i.length&&s(u,i,c+1)}};return s(e,gr(t)?t.split("."):t,0),o?n:n[0]}const G0={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},J0={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},Y0={location:0,threshold:.6,distance:100},X0={useExtendedSearch:!1,getFn:V0,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var Ue={...J0,...G0,...Y0,...X0};const Q0=/[^ ]+/g;function Z0(e=1,t=3){const n=new Map,o=Math.pow(10,t);return{get(s){const a=s.match(Q0).length;if(n.has(a))return n.get(a);const i=1/Math.pow(a,.5*e),c=parseFloat(Math.round(i*o)/o);return n.set(a,c),c},clear(){n.clear()}}}class ha{constructor({getFn:t=Ue.getFn,fieldNormWeight:n=Ue.fieldNormWeight}={}){this.norm=Z0(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,o)=>{this._keysMap[n.id]=o})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,gr(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();gr(t)?this._addString(t,n):this._addObject(t,n)}removeAt(t){this.records.splice(t,1);for(let n=t,o=this.size();n<o;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)||rs(t))return;let o={v:t,i:n,n:this.norm.get(t)};this.records.push(o)}_addObject(t,n){let o={i:n,$:{}};this.keys.forEach((s,a)=>{let i=s.getFn?s.getFn(t):this.getFn(t,s.path);if(Yt(i)){if(Sr(i)){let c=[];const d=[{nestedArrIndex:-1,value:i}];for(;d.length;){const{nestedArrIndex:u,value:m}=d.pop();if(Yt(m))if(gr(m)&&!rs(m)){let p={v:m,i:u,n:this.norm.get(m)};c.push(p)}else Sr(m)&&m.forEach((p,f)=>{d.push({nestedArrIndex:f,value:p})})}o.$[a]=c}else if(gr(i)&&!rs(i)){let c={v:i,n:this.norm.get(i)};o.$[a]=c}}}),this.records.push(o)}toJSON(){return{keys:this.keys,records:this.records}}}function ud(e,t,{getFn:n=Ue.getFn,fieldNormWeight:o=Ue.fieldNormWeight}={}){const s=new ha({getFn:n,fieldNormWeight:o});return s.setKeys(e.map(dd)),s.setSources(t),s.create(),s}function ey(e,{getFn:t=Ue.getFn,fieldNormWeight:n=Ue.fieldNormWeight}={}){const{keys:o,records:s}=e,a=new ha({getFn:t,fieldNormWeight:n});return a.setKeys(o),a.setIndexRecords(s),a}function no(e,{errors:t=0,currentLocation:n=0,expectedLocation:o=0,distance:s=Ue.distance,ignoreLocation:a=Ue.ignoreLocation}={}){const i=t/e.length;if(a)return i;const c=Math.abs(o-n);return s?i+c/s:c?1:i}function ty(e=[],t=Ue.minMatchCharLength){let n=[],o=-1,s=-1,a=0;for(let i=e.length;a<i;a+=1){let c=e[a];c&&o===-1?o=a:!c&&o!==-1&&(s=a-1,s-o+1>=t&&n.push([o,s]),o=-1)}return e[a-1]&&a-o>=t&&n.push([o,a-1]),n}const Dr=32;function ry(e,t,n,{location:o=Ue.location,distance:s=Ue.distance,threshold:a=Ue.threshold,findAllMatches:i=Ue.findAllMatches,minMatchCharLength:c=Ue.minMatchCharLength,includeMatches:d=Ue.includeMatches,ignoreLocation:u=Ue.ignoreLocation}={}){if(t.length>Dr)throw new Error(U0(Dr));const m=t.length,p=e.length,f=Math.max(0,Math.min(o,p));let h=a,g=f;const b=c>1||d,y=b?Array(p):[];let k;for(;(k=e.indexOf(t,g))>-1;){let I=no(t,{currentLocation:k,expectedLocation:f,distance:s,ignoreLocation:u});if(h=Math.min(I,h),g=k+m,b){let z=0;for(;z<m;)y[k+z]=1,z+=1}}g=-1;let F=[],E=1,L=m+p;const T=1<<m-1;for(let I=0;I<m;I+=1){let z=0,K=L;for(;z<K;)no(t,{errors:I,currentLocation:f+K,expectedLocation:f,distance:s,ignoreLocation:u})<=h?z=K:L=K,K=Math.floor((L-z)/2+z);L=K;let S=Math.max(1,f-K+1),se=i?p:Math.min(f+K,p)+m,ie=Array(se+2);ie[se+1]=(1<<I)-1;for(let Q=se;Q>=S;Q-=1){let V=Q-1,le=n[e.charAt(V)];if(b&&(y[V]=+!!le),ie[Q]=(ie[Q+1]<<1|1)&le,I&&(ie[Q]|=(F[Q+1]|F[Q])<<1|1|F[Q+1]),ie[Q]&T&&(E=no(t,{errors:I,currentLocation:V,expectedLocation:f,distance:s,ignoreLocation:u}),E<=h)){if(h=E,g=V,g<=f)break;S=Math.max(1,2*f-g)}}if(no(t,{errors:I+1,currentLocation:f,expectedLocation:f,distance:s,ignoreLocation:u})>h)break;F=ie}const P={isMatch:g>=0,score:Math.max(.001,E)};if(b){const I=ty(y,c);I.length?d&&(P.indices=I):P.isMatch=!1}return P}function ny(e){let t={};for(let n=0,o=e.length;n<o;n+=1){const s=e.charAt(n);t[s]=(t[s]||0)|1<<o-n-1}return t}const yo=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 pd{constructor(t,{location:n=Ue.location,threshold:o=Ue.threshold,distance:s=Ue.distance,includeMatches:a=Ue.includeMatches,findAllMatches:i=Ue.findAllMatches,minMatchCharLength:c=Ue.minMatchCharLength,isCaseSensitive:d=Ue.isCaseSensitive,ignoreDiacritics:u=Ue.ignoreDiacritics,ignoreLocation:m=Ue.ignoreLocation}={}){if(this.options={location:n,threshold:o,distance:s,includeMatches:a,findAllMatches:i,minMatchCharLength:c,isCaseSensitive:d,ignoreDiacritics:u,ignoreLocation:m},t=d?t:t.toLowerCase(),t=u?yo(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const p=(h,g)=>{this.chunks.push({pattern:h,alphabet:ny(h),startIndex:g})},f=this.pattern.length;if(f>Dr){let h=0;const g=f%Dr,b=f-g;for(;h<b;)p(this.pattern.substr(h,Dr),h),h+=Dr;if(g){const y=f-Dr;p(this.pattern.substr(y),y)}}else p(this.pattern,0)}searchIn(t){const{isCaseSensitive:n,ignoreDiacritics:o,includeMatches:s}=this.options;if(t=n?t:t.toLowerCase(),t=o?yo(t):t,this.pattern===t){let b={isMatch:!0,score:0};return s&&(b.indices=[[0,t.length-1]]),b}const{location:a,distance:i,threshold:c,findAllMatches:d,minMatchCharLength:u,ignoreLocation:m}=this.options;let p=[],f=0,h=!1;this.chunks.forEach(({pattern:b,alphabet:y,startIndex:k})=>{const{isMatch:F,score:E,indices:L}=ry(t,b,y,{location:a+k,distance:i,threshold:c,findAllMatches:d,minMatchCharLength:u,includeMatches:s,ignoreLocation:m});F&&(h=!0),f+=E,F&&L&&(p=[...p,...L])});let g={isMatch:h,score:h?f/this.chunks.length:1};return h&&s&&(g.indices=p),g}}class Mr{constructor(t){this.pattern=t}static isMultiMatch(t){return fi(t,this.multiRegex)}static isSingleMatch(t){return fi(t,this.singleRegex)}search(){}}function fi(e,t){const n=e.match(t);return n?n[1]:null}class oy extends Mr{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 sy extends Mr{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const o=t.indexOf(this.pattern)===-1;return{isMatch:o,score:o?0:1,indices:[0,t.length-1]}}}class ay extends Mr{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 iy extends Mr{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 ly extends Mr{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 cy extends Mr{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 md extends Mr{constructor(t,{location:n=Ue.location,threshold:o=Ue.threshold,distance:s=Ue.distance,includeMatches:a=Ue.includeMatches,findAllMatches:i=Ue.findAllMatches,minMatchCharLength:c=Ue.minMatchCharLength,isCaseSensitive:d=Ue.isCaseSensitive,ignoreDiacritics:u=Ue.ignoreDiacritics,ignoreLocation:m=Ue.ignoreLocation}={}){super(t),this._bitapSearch=new pd(t,{location:n,threshold:o,distance:s,includeMatches:a,findAllMatches:i,minMatchCharLength:c,isCaseSensitive:d,ignoreDiacritics:u,ignoreLocation:m})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class fd extends Mr{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let n=0,o;const s=[],a=this.pattern.length;for(;(o=t.indexOf(this.pattern,n))>-1;)n=o+a,s.push([o,n-1]);const i=!!s.length;return{isMatch:i,score:i?0:1,indices:s}}}const Ds=[oy,fd,ay,iy,cy,ly,sy,md],hi=Ds.length,dy=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,uy="|";function py(e,t={}){return e.split(uy).map(n=>{let o=n.trim().split(dy).filter(a=>a&&!!a.trim()),s=[];for(let a=0,i=o.length;a<i;a+=1){const c=o[a];let d=!1,u=-1;for(;!d&&++u<hi;){const m=Ds[u];let p=m.isMultiMatch(c);p&&(s.push(new m(p,t)),d=!0)}if(!d)for(u=-1;++u<hi;){const m=Ds[u];let p=m.isSingleMatch(c);if(p){s.push(new m(p,t));break}}}return s})}const my=new Set([md.type,fd.type]);class fy{constructor(t,{isCaseSensitive:n=Ue.isCaseSensitive,ignoreDiacritics:o=Ue.ignoreDiacritics,includeMatches:s=Ue.includeMatches,minMatchCharLength:a=Ue.minMatchCharLength,ignoreLocation:i=Ue.ignoreLocation,findAllMatches:c=Ue.findAllMatches,location:d=Ue.location,threshold:u=Ue.threshold,distance:m=Ue.distance}={}){this.query=null,this.options={isCaseSensitive:n,ignoreDiacritics:o,includeMatches:s,minMatchCharLength:a,findAllMatches:c,ignoreLocation:i,location:d,threshold:u,distance:m},t=n?t:t.toLowerCase(),t=o?yo(t):t,this.pattern=t,this.query=py(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:o,isCaseSensitive:s,ignoreDiacritics:a}=this.options;t=s?t:t.toLowerCase(),t=a?yo(t):t;let i=0,c=[],d=0;for(let u=0,m=n.length;u<m;u+=1){const p=n[u];c.length=0,i=0;for(let f=0,h=p.length;f<h;f+=1){const g=p[f],{isMatch:b,indices:y,score:k}=g.search(t);if(b){if(i+=1,d+=k,o){const F=g.constructor.type;my.has(F)?c=[...c,...y]:c.push(y)}}else{d=0,i=0,c.length=0;break}}if(i){let f={isMatch:!0,score:d/i};return o&&(f.indices=c),f}}return{isMatch:!1,score:1}}}const Rs=[];function hy(...e){Rs.push(...e)}function Ls(e,t){for(let n=0,o=Rs.length;n<o;n+=1){let s=Rs[n];if(s.condition(e,t))return new s(e,t)}return new pd(e,t)}const vo={AND:"$and",OR:"$or"},Os={PATH:"$path",PATTERN:"$val"},Fs=e=>!!(e[vo.AND]||e[vo.OR]),gy=e=>!!e[Os.PATH],xy=e=>!Sr(e)&&ld(e)&&!Fs(e),gi=e=>({[vo.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function hd(e,t,{auto:n=!0}={}){const o=s=>{let a=Object.keys(s);const i=gy(s);if(!i&&a.length>1&&!Fs(s))return o(gi(s));if(xy(s)){const d=i?s[Os.PATH]:a[0],u=i?s[Os.PATTERN]:s[d];if(!gr(u))throw new Error(W0(d));const m={keyId:Ps(d),pattern:u};return n&&(m.searcher=Ls(u,t)),m}let c={children:[],operator:a[0]};return a.forEach(d=>{const u=s[d];Sr(u)&&u.forEach(m=>{c.children.push(o(m))})}),c};return Fs(e)||(e=gi(e)),o(e)}function yy(e,{ignoreFieldNorm:t=Ue.ignoreFieldNorm}){e.forEach(n=>{let o=1;n.matches.forEach(({key:s,norm:a,score:i})=>{const c=s?s.weight:null;o*=Math.pow(i===0&&c?Number.EPSILON:i,(c||1)*(t?1:a))}),n.score=o})}function vy(e,t){const n=e.matches;t.matches=[],Yt(n)&&n.forEach(o=>{if(!Yt(o.indices)||!o.indices.length)return;const{indices:s,value:a}=o;let i={indices:s,value:a};o.key&&(i.key=o.key.src),o.idx>-1&&(i.refIndex=o.idx),t.matches.push(i)})}function by(e,t){t.score=e.score}function wy(e,t,{includeMatches:n=Ue.includeMatches,includeScore:o=Ue.includeScore}={}){const s=[];return n&&s.push(vy),o&&s.push(by),e.map(a=>{const{idx:i}=a,c={item:t[i],refIndex:i};return s.length&&s.forEach(d=>{d(a,c)}),c})}class mn{constructor(t,n={},o){this.options={...Ue,...n},this.options.useExtendedSearch,this._keyStore=new K0(this.options.keys),this.setCollection(t,o)}setCollection(t,n){if(this._docs=t,n&&!(n instanceof ha))throw new Error(z0);this._myIndex=n||ud(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 o=0,s=this._docs.length;o<s;o+=1){const a=this._docs[o];t(a,o)&&(this.removeAt(o),o-=1,s-=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:o,includeScore:s,shouldSort:a,sortFn:i,ignoreFieldNorm:c}=this.options;let d=gr(t)?gr(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return yy(d,{ignoreFieldNorm:c}),a&&d.sort(i),id(n)&&n>-1&&(d=d.slice(0,n)),wy(d,this._docs,{includeMatches:o,includeScore:s})}_searchStringList(t){const n=Ls(t,this.options),{records:o}=this._myIndex,s=[];return o.forEach(({v:a,i,n:c})=>{if(!Yt(a))return;const{isMatch:d,score:u,indices:m}=n.searchIn(a);d&&s.push({item:a,idx:i,matches:[{score:u,value:a,norm:c,indices:m}]})}),s}_searchLogical(t){const n=hd(t,this.options),o=(c,d,u)=>{if(!c.children){const{keyId:p,searcher:f}=c,h=this._findMatches({key:this._keyStore.get(p),value:this._myIndex.getValueForItemAtKeyId(d,p),searcher:f});return h&&h.length?[{idx:u,item:d,matches:h}]:[]}const m=[];for(let p=0,f=c.children.length;p<f;p+=1){const h=c.children[p],g=o(h,d,u);if(g.length)m.push(...g);else if(c.operator===vo.AND)return[]}return m},s=this._myIndex.records,a={},i=[];return s.forEach(({$:c,i:d})=>{if(Yt(c)){let u=o(n,c,d);u.length&&(a[d]||(a[d]={idx:d,item:c,matches:[]},i.push(a[d])),u.forEach(({matches:m})=>{a[d].matches.push(...m)}))}}),i}_searchObjectList(t){const n=Ls(t,this.options),{keys:o,records:s}=this._myIndex,a=[];return s.forEach(({$:i,i:c})=>{if(!Yt(i))return;let d=[];o.forEach((u,m)=>{d.push(...this._findMatches({key:u,value:i[m],searcher:n}))}),d.length&&a.push({idx:c,item:i,matches:d})}),a}_findMatches({key:t,value:n,searcher:o}){if(!Yt(n))return[];let s=[];if(Sr(n))n.forEach(({v:a,i,n:c})=>{if(!Yt(a))return;const{isMatch:d,score:u,indices:m}=o.searchIn(a);d&&s.push({score:u,key:t,value:a,idx:i,norm:c,indices:m})});else{const{v:a,n:i}=n,{isMatch:c,score:d,indices:u}=o.searchIn(a);c&&s.push({score:d,key:t,value:a,norm:i,indices:u})}return s}}mn.version="7.1.0";mn.createIndex=ud;mn.parseIndex=ey;mn.config=Ue;mn.parseQuery=hd;hy(fy);var ns={exports:{}},os,xi;function ky(){if(xi)return os;xi=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return os=e,os}var ss,yi;function jy(){if(yi)return ss;yi=1;var e=ky();function t(){}function n(){}return n.resetWarningCache=t,ss=function(){function o(i,c,d,u,m,p){if(p!==e){var f=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 f.name="Invariant Violation",f}}o.isRequired=o;function s(){return o}var a={array:o,bigint:o,bool:o,func:o,number:o,object:o,string:o,symbol:o,any:o,arrayOf:s,element:o,elementType:o,instanceOf:s,node:o,objectOf:s,oneOf:s,oneOfType:s,shape:s,exact:s,checkPropTypes:n,resetWarningCache:t};return a.PropTypes=a,a},ss}var vi;function Sy(){return vi||(vi=1,ns.exports=jy()()),ns.exports}var Ny=Sy();const mt=hl(Ny),Cy=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 ln(e,t,n){const o=Ey(e),{webkitRelativePath:s}=e,a=typeof t=="string"?t:typeof s=="string"&&s.length>0?s:`./${e.name}`;return typeof o.path!="string"&&bi(o,"path",a),bi(o,"relativePath",a),o}function Ey(e){const{name:t}=e;if(t&&t.lastIndexOf(".")!==-1&&!e.type){const o=t.split(".").pop().toLowerCase(),s=Cy.get(o);s&&Object.defineProperty(e,"type",{value:s,writable:!1,configurable:!1,enumerable:!0})}return e}function bi(e,t,n){Object.defineProperty(e,t,{value:n,writable:!1,configurable:!1,enumerable:!0})}const Ay=[".DS_Store","Thumbs.db"];function _y(e){return Hr(this,void 0,void 0,function*(){return bo(e)&&Iy(e.dataTransfer)?Dy(e.dataTransfer,e.type):Ty(e)?My(e):Array.isArray(e)&&e.every(t=>"getFile"in t&&typeof t.getFile=="function")?Py(e):[]})}function Iy(e){return bo(e)}function Ty(e){return bo(e)&&bo(e.target)}function bo(e){return typeof e=="object"&&e!==null}function My(e){return $s(e.target.files).map(t=>ln(t))}function Py(e){return Hr(this,void 0,void 0,function*(){return(yield Promise.all(e.map(n=>n.getFile()))).map(n=>ln(n))})}function Dy(e,t){return Hr(this,void 0,void 0,function*(){if(e.items){const n=$s(e.items).filter(s=>s.kind==="file");if(t!=="drop")return n;const o=yield Promise.all(n.map(Ry));return wi(gd(o))}return wi($s(e.files).map(n=>ln(n)))})}function wi(e){return e.filter(t=>Ay.indexOf(t.name)===-1)}function $s(e){if(e===null)return[];const t=[];for(let n=0;n<e.length;n++){const o=e[n];t.push(o)}return t}function Ry(e){if(typeof e.webkitGetAsEntry!="function")return ki(e);const t=e.webkitGetAsEntry();return t&&t.isDirectory?xd(t):ki(e,t)}function gd(e){return e.reduce((t,n)=>[...t,...Array.isArray(n)?gd(n):[n]],[])}function ki(e,t){return Hr(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,ln(i)}}const o=e.getAsFile();if(!o)throw new Error(`${e} is not a File`);return ln(o,(n=t?.fullPath)!==null&&n!==void 0?n:void 0)})}function Ly(e){return Hr(this,void 0,void 0,function*(){return e.isDirectory?xd(e):Oy(e)})}function xd(e){const t=e.createReader();return new Promise((n,o)=>{const s=[];function a(){t.readEntries(i=>Hr(this,void 0,void 0,function*(){if(i.length){const c=Promise.all(i.map(Ly));s.push(c),a()}else try{const c=yield Promise.all(s);n(c)}catch(c){o(c)}}),i=>{o(i)})}a()})}function Oy(e){return Hr(this,void 0,void 0,function*(){return new Promise((t,n)=>{e.file(o=>{const s=ln(o,e.fullPath);t(s)},o=>{n(o)})})})}var oo={},ji;function Fy(){return ji||(ji=1,oo.__esModule=!0,oo.default=function(e,t){if(e&&t){var n=Array.isArray(t)?t:t.split(",");if(n.length===0)return!0;var o=e.name||"",s=(e.type||"").toLowerCase(),a=s.replace(/\/.*$/,"");return n.some(function(i){var c=i.trim().toLowerCase();return c.charAt(0)==="."?o.toLowerCase().endsWith(c):c.endsWith("/*")?a===c.replace(/\/.*$/,""):s===c})}return!0}),oo}var $y=Fy();const as=hl($y);function Si(e){return Wy(e)||zy(e)||vd(e)||By()}function By(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
262
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function zy(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Wy(e){if(Array.isArray(e))return Bs(e)}function Ni(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,o)}return n}function Ci(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Ni(Object(n),!0).forEach(function(o){yd(e,o,n[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ni(Object(n)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(n,o))})}return e}function yd(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Cn(e,t){return qy(e)||Hy(e,t)||vd(e,t)||Uy()}function Uy(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
263
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function vd(e,t){if(e){if(typeof e=="string")return Bs(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 Bs(e,t)}}function Bs(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function Hy(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var o=[],s=!0,a=!1,i,c;try{for(n=n.call(e);!(s=(i=n.next()).done)&&(o.push(i.value),!(t&&o.length===t));s=!0);}catch(d){a=!0,c=d}finally{try{!s&&n.return!=null&&n.return()}finally{if(a)throw c}}return o}}function qy(e){if(Array.isArray(e))return e}var Ky=typeof as=="function"?as:as.default,Vy="file-invalid-type",Gy="file-too-large",Jy="file-too-small",Yy="too-many-files",Xy=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",n=t.split(","),o=n.length>1?"one of ".concat(n.join(", ")):n[0];return{code:Vy,message:"File type must be ".concat(o)}},Ei=function(t){return{code:Gy,message:"File is larger than ".concat(t," ").concat(t===1?"byte":"bytes")}},Ai=function(t){return{code:Jy,message:"File is smaller than ".concat(t," ").concat(t===1?"byte":"bytes")}},Qy={code:Yy,message:"Too many files"};function bd(e,t){var n=e.type==="application/x-moz-file"||Ky(e,t);return[n,n?null:Xy(t)]}function wd(e,t,n){if(Rr(e.size))if(Rr(t)&&Rr(n)){if(e.size>n)return[!1,Ei(n)];if(e.size<t)return[!1,Ai(t)]}else{if(Rr(t)&&e.size<t)return[!1,Ai(t)];if(Rr(n)&&e.size>n)return[!1,Ei(n)]}return[!0,null]}function Rr(e){return e!=null}function Zy(e){var t=e.files,n=e.accept,o=e.minSize,s=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=bd(d,n),m=Cn(u,1),p=m[0],f=wd(d,o,s),h=Cn(f,1),g=h[0],b=c?c(d):null;return p&&g&&!b})}function wo(e){return typeof e.isPropagationStopped=="function"?e.isPropagationStopped():typeof e.cancelBubble<"u"?e.cancelBubble:!1}function so(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 _i(e){e.preventDefault()}function ev(e){return e.indexOf("MSIE")!==-1||e.indexOf("Trident/")!==-1}function tv(e){return e.indexOf("Edge/")!==-1}function rv(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return ev(e)||tv(e)}function pr(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(o){for(var s=arguments.length,a=new Array(s>1?s-1:0),i=1;i<s;i++)a[i-1]=arguments[i];return t.some(function(c){return!wo(o)&&c&&c.apply(void 0,[o].concat(a)),wo(o)})}}function nv(){return"showOpenFilePicker"in window}function ov(e){if(Rr(e)){var t=Object.entries(e).filter(function(n){var o=Cn(n,2),s=o[0],a=o[1],i=!0;return kd(s)||(console.warn('Skipped "'.concat(s,'" 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(jd))&&(console.warn('Skipped "'.concat(s,'" because an invalid file extension was provided.')),i=!1),i}).reduce(function(n,o){var s=Cn(o,2),a=s[0],i=s[1];return Ci(Ci({},n),{},yd({},a,i))},{});return[{description:"Files",accept:t}]}return e}function sv(e){if(Rr(e))return Object.entries(e).reduce(function(t,n){var o=Cn(n,2),s=o[0],a=o[1];return[].concat(Si(t),[s],Si(a))},[]).filter(function(t){return kd(t)||jd(t)}).join(",")}function av(e){return e instanceof DOMException&&(e.name==="AbortError"||e.code===e.ABORT_ERR)}function iv(e){return e instanceof DOMException&&(e.name==="SecurityError"||e.code===e.SECURITY_ERR)}function kd(e){return e==="audio/*"||e==="video/*"||e==="image/*"||e==="text/*"||e==="application/*"||/\w+\/[-+.\w]+/g.test(e)}function jd(e){return/^.*\.[\w]+$/.test(e)}var lv=["children"],cv=["open"],dv=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],uv=["refKey","onChange","onClick"];function pv(e){return hv(e)||fv(e)||Sd(e)||mv()}function mv(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
264
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function fv(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function hv(e){if(Array.isArray(e))return zs(e)}function is(e,t){return yv(e)||xv(e,t)||Sd(e,t)||gv()}function gv(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
265
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Sd(e,t){if(e){if(typeof e=="string")return zs(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 zs(e,t)}}function zs(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function xv(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var o=[],s=!0,a=!1,i,c;try{for(n=n.call(e);!(s=(i=n.next()).done)&&(o.push(i.value),!(t&&o.length===t));s=!0);}catch(d){a=!0,c=d}finally{try{!s&&n.return!=null&&n.return()}finally{if(a)throw c}}return o}}function yv(e){if(Array.isArray(e))return e}function Ii(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,o)}return n}function wt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Ii(Object(n),!0).forEach(function(o){Ws(e,o,n[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ii(Object(n)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(n,o))})}return e}function Ws(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ko(e,t){if(e==null)return{};var n=vv(e,t),o,s;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(s=0;s<a.length;s++)o=a[s],!(t.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(e,o)&&(n[o]=e[o])}return n}function vv(e,t){if(e==null)return{};var n={},o=Object.keys(e),s,a;for(a=0;a<o.length;a++)s=o[a],!(t.indexOf(s)>=0)&&(n[s]=e[s]);return n}var ga=l.forwardRef(function(e,t){var n=e.children,o=ko(e,lv),s=Cd(o),a=s.open,i=ko(s,cv);return l.useImperativeHandle(t,function(){return{open:a}},[a]),jt.createElement(l.Fragment,null,n(wt(wt({},i),{},{open:a})))});ga.displayName="Dropzone";var Nd={disabled:!1,getFilesFromEvent:_y,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};ga.defaultProps=Nd;ga.propTypes={children:mt.func,accept:mt.objectOf(mt.arrayOf(mt.string)),multiple:mt.bool,preventDropOnDocument:mt.bool,noClick:mt.bool,noKeyboard:mt.bool,noDrag:mt.bool,noDragEventsBubbling:mt.bool,minSize:mt.number,maxSize:mt.number,maxFiles:mt.number,disabled:mt.bool,getFilesFromEvent:mt.func,onFileDialogCancel:mt.func,onFileDialogOpen:mt.func,useFsAccessApi:mt.bool,autoFocus:mt.bool,onDragEnter:mt.func,onDragLeave:mt.func,onDragOver:mt.func,onDrop:mt.func,onDropAccepted:mt.func,onDropRejected:mt.func,onError:mt.func,validator:mt.func};var Us={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,acceptedFiles:[],fileRejections:[]};function Cd(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=wt(wt({},Nd),e),n=t.accept,o=t.disabled,s=t.getFilesFromEvent,a=t.maxSize,i=t.minSize,c=t.multiple,d=t.maxFiles,u=t.onDragEnter,m=t.onDragLeave,p=t.onDragOver,f=t.onDrop,h=t.onDropAccepted,g=t.onDropRejected,b=t.onFileDialogCancel,y=t.onFileDialogOpen,k=t.useFsAccessApi,F=t.autoFocus,E=t.preventDropOnDocument,L=t.noClick,T=t.noKeyboard,P=t.noDrag,I=t.noDragEventsBubbling,z=t.onError,K=t.validator,S=l.useMemo(function(){return sv(n)},[n]),se=l.useMemo(function(){return ov(n)},[n]),ie=l.useMemo(function(){return typeof y=="function"?y:Ti},[y]),U=l.useMemo(function(){return typeof b=="function"?b:Ti},[b]),Q=l.useRef(null),V=l.useRef(null),le=l.useReducer(bv,Us),ce=is(le,2),ue=ce[0],G=ce[1],Ae=ue.isFocused,O=ue.isFileDialogActive,Z=l.useRef(typeof window<"u"&&window.isSecureContext&&k&&nv()),ae=function(){!Z.current&&O&&setTimeout(function(){if(V.current){var q=V.current.files;q.length||(G({type:"closeDialog"}),U())}},300)};l.useEffect(function(){return window.addEventListener("focus",ae,!1),function(){window.removeEventListener("focus",ae,!1)}},[V,O,U,Z]);var be=l.useRef([]),ye=function(q){Q.current&&Q.current.contains(q.target)||(q.preventDefault(),be.current=[])};l.useEffect(function(){return E&&(document.addEventListener("dragover",_i,!1),document.addEventListener("drop",ye,!1)),function(){E&&(document.removeEventListener("dragover",_i),document.removeEventListener("drop",ye))}},[Q,E]),l.useEffect(function(){return!o&&F&&Q.current&&Q.current.focus(),function(){}},[Q,F,o]);var ke=l.useCallback(function(A){z?z(A):console.error(A)},[z]),ne=l.useCallback(function(A){A.preventDefault(),A.persist(),Le(A),be.current=[].concat(pv(be.current),[A.target]),so(A)&&Promise.resolve(s(A)).then(function(q){if(!(wo(A)&&!I)){var v=q.length,x=v>0&&Zy({files:q,accept:S,minSize:i,maxSize:a,multiple:c,maxFiles:d,validator:K}),C=v>0&&!x;G({isDragAccept:x,isDragReject:C,isDragActive:!0,type:"setDraggedFiles"}),u&&u(A)}}).catch(function(q){return ke(q)})},[s,u,ke,I,S,i,a,c,d,K]),Se=l.useCallback(function(A){A.preventDefault(),A.persist(),Le(A);var q=so(A);if(q&&A.dataTransfer)try{A.dataTransfer.dropEffect="copy"}catch{}return q&&p&&p(A),!1},[p,I]),We=l.useCallback(function(A){A.preventDefault(),A.persist(),Le(A);var q=be.current.filter(function(x){return Q.current&&Q.current.contains(x)}),v=q.indexOf(A.target);v!==-1&&q.splice(v,1),be.current=q,!(q.length>0)&&(G({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),so(A)&&m&&m(A))},[Q,m,I]),ve=l.useCallback(function(A,q){var v=[],x=[];A.forEach(function(C){var $=bd(C,S),D=is($,2),J=D[0],pe=D[1],Ie=wd(C,i,a),Me=is(Ie,2),it=Me[0],me=Me[1],_e=K?K(C):null;if(J&&it&&!_e)v.push(C);else{var Qe=[pe,me];_e&&(Qe=Qe.concat(_e)),x.push({file:C,errors:Qe.filter(function(ft){return ft})})}}),(!c&&v.length>1||c&&d>=1&&v.length>d)&&(v.forEach(function(C){x.push({file:C,errors:[Qy]})}),v.splice(0)),G({acceptedFiles:v,fileRejections:x,isDragReject:x.length>0,type:"setFiles"}),f&&f(v,x,q),x.length>0&&g&&g(x,q),v.length>0&&h&&h(v,q)},[G,c,S,i,a,d,f,h,g,K]),tt=l.useCallback(function(A){A.preventDefault(),A.persist(),Le(A),be.current=[],so(A)&&Promise.resolve(s(A)).then(function(q){wo(A)&&!I||ve(q,A)}).catch(function(q){return ke(q)}),G({type:"reset"})},[s,ve,ke,I]),$e=l.useCallback(function(){if(Z.current){G({type:"openDialog"}),ie();var A={multiple:c,types:se};window.showOpenFilePicker(A).then(function(q){return s(q)}).then(function(q){ve(q,null),G({type:"closeDialog"})}).catch(function(q){av(q)?(U(q),G({type:"closeDialog"})):iv(q)?(Z.current=!1,V.current?(V.current.value=null,V.current.click()):ke(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."))):ke(q)});return}V.current&&(G({type:"openDialog"}),ie(),V.current.value=null,V.current.click())},[G,ie,U,k,ve,ke,se,c]),je=l.useCallback(function(A){!Q.current||!Q.current.isEqualNode(A.target)||(A.key===" "||A.key==="Enter"||A.keyCode===32||A.keyCode===13)&&(A.preventDefault(),$e())},[Q,$e]),Te=l.useCallback(function(){G({type:"focus"})},[]),qe=l.useCallback(function(){G({type:"blur"})},[]),et=l.useCallback(function(){L||(rv()?setTimeout($e,0):$e())},[L,$e]),Ke=function(q){return o?null:q},Xe=function(q){return T?null:Ke(q)},ge=function(q){return P?null:Ke(q)},Le=function(q){I&&q.stopPropagation()},rt=l.useMemo(function(){return function(){var A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},q=A.refKey,v=q===void 0?"ref":q,x=A.role,C=A.onKeyDown,$=A.onFocus,D=A.onBlur,J=A.onClick,pe=A.onDragEnter,Ie=A.onDragOver,Me=A.onDragLeave,it=A.onDrop,me=ko(A,dv);return wt(wt(Ws({onKeyDown:Xe(pr(C,je)),onFocus:Xe(pr($,Te)),onBlur:Xe(pr(D,qe)),onClick:Ke(pr(J,et)),onDragEnter:ge(pr(pe,ne)),onDragOver:ge(pr(Ie,Se)),onDragLeave:ge(pr(Me,We)),onDrop:ge(pr(it,tt)),role:typeof x=="string"&&x!==""?x:"presentation"},v,Q),!o&&!T?{tabIndex:0}:{}),me)}},[Q,je,Te,qe,et,ne,Se,We,tt,T,P,o]),Re=l.useCallback(function(A){A.stopPropagation()},[]),Oe=l.useMemo(function(){return function(){var A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},q=A.refKey,v=q===void 0?"ref":q,x=A.onChange,C=A.onClick,$=ko(A,uv),D=Ws({accept:S,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:Ke(pr(x,tt)),onClick:Ke(pr(C,Re)),tabIndex:-1},v,V);return wt(wt({},D),$)}},[V,n,c,tt,o]);return wt(wt({},ue),{},{isFocused:Ae&&!o,getRootProps:rt,getInputProps:Oe,rootRef:Q,inputRef:V,open:Ke($e)})}function bv(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({},Us),{},{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({},Us);default:return e}}function Ti(){}const Mi={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"]}},Pi={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 Di(e){return Mi[e]||Mi.claude}function Ri(e){return Pi[e]||Pi.claude}function wv(e){return e==="claude"||e==="codex"}function kv(e){if(e==="think")return"low";if(e==="think-hard")return"medium";if(e==="think-harder")return"high";if(e==="ultrathink")return"xhigh"}let Li=!1;function jv(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`client-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function Sv(e){return new Promise((t,n)=>{if(!(e instanceof Blob)){n(new Error("无效的图片文件"));return}const o=new FileReader;o.onload=()=>t(typeof o.result=="string"?o.result:""),o.onerror=()=>n(o.error||new Error("读取图片失败")),o.readAsDataURL(e)})}async function Nv(e=[]){const t=Array.isArray(e)?e:[];return Promise.all(t.map(async(n,o)=>{const s=await Sv(n);if(!s)throw new Error("图片编码失败");return{name:n?.name||`image-${o+1}.png`,data:s,size:Number(n?.size)||0,mimeType:n?.type||"application/octet-stream"}}))}function Cv(e){const t=String(e||"").trim();if(!t)return"";const n=t.split(/[\\/]/);return n[n.length-1]||t}function Ev(e=[]){return Array.from(new Set(Array.isArray(e)?e.filter(Boolean):[])).map(t=>{const n=String(t||"").trim();return n?{type:"resource_link",uri:n,name:Cv(n)}:null}).filter(Boolean)}function Av(e,t=0){if(!e||typeof e!="object")return null;const n=String(e.modeId||e.id||e.value||"").trim();if(!n)return null;const o=`Mode ${t+1}`;return{id:n,name:String(e.name||e.label||n||o).trim()||o,description:typeof e.description=="string"?e.description:""}}function ls(e=null){const t=e?.acpModes?.availableModes||e?.modes?.availableModes||e?.availableModes||[],n=Array.isArray(t)?t.map((s,a)=>Av(s,a)).filter(Boolean):[],o=String(e?.acpModes?.currentModeId||e?.acpModes?.currentMode?.modeId||e?.modes?.currentModeId||e?.modes?.currentMode?.modeId||e?.currentModeId||e?.currentMode?.modeId||"").trim();return{availableModes:n,currentModeId:o}}function Oi(e){return String(e||"").trim().replace(/^\//,"").toLowerCase()}function _v(e,t=0){if(!e||typeof e!="object")return null;const n=String(e.name||e.command||e.id||"").trim();if(!n)return null;const o=n.startsWith("/")?n:`/${n}`;return{...e,id:String(e.id||o||`acp-${t}`).trim(),name:o,description:typeof e.description=="string"?e.description:"",type:"acp",source:"acp"}}function Iv(e=null){const t=e?.acpAvailableCommands||e?.availableCommands||e?.acpCommands||[];return Array.isArray(t)?t.map((n,o)=>_v(n,o)).filter(Boolean):[]}function Tv(e=[],t=[]){const n=Array.isArray(t)?t:[],o=Array.isArray(e)?e:[],s=new Set(n.map(i=>Oi(i?.name)).filter(Boolean)),a=o.filter(i=>!s.has(Oi(i?.name)));return[...n,...a]}function Mv({selectedProject:e,selectedSession:t,selectedProjectRef:n,currentSessionId:o,canAbortSession:s,isLoading:a,setChatMessages:i,setCanAbortSession:c,setRuntimePhase:d,setClaudeStatus:u,pendingPermissionRequests:m,setPendingPermissionRequests:p,sendMessage:f,onSessionActive:h,onInputFocusChange:g,onShowSettings:b,onFileOpen:y,appendSessionConversationEvent:k,startLocalRunGuard:F,pendingViewSessionRef:E,scrollToBottom:L,setIsUserScrolledUp:T,tokenBudget:P,chatMessages:I,setSessionMessages:z,resetRuntimeForNewChat:K,urlContext:S,urlPrompt:se,integrationClientId:ie,latestIntegrationMessage:U,sendIntegrationMessage:Q,sendByCtrlEnter:V}){const{t:le}=St("chat"),[ce,ue]=l.useState(()=>typeof window<"u"&&e?.name&&bt.getItem(`draft_input_${e.name}`)||""),[G,Ae]=l.useState(!1),[O,Z]=l.useState([]),[ae,be]=l.useState(new Map),[ye,ke]=l.useState(new Map),[ne,Se]=l.useState(!1),[We,ve]=l.useState([]),[tt,$e]=l.useState([]),[je,Te]=l.useState([]),[qe,et]=l.useState(-1),[Ke,Xe]=l.useState(0),[ge,Le]=l.useState(-1),[rt,Re]=l.useState(!1),[Oe,A]=l.useState([]),[q,v]=l.useState([]),[x,C]=l.useState([]),[$,D]=l.useState(""),[J,pe]=l.useState(!1),[Ie,Me]=l.useState(-1),[it,me]=l.useState(-1),[_e,Qe]=l.useState(()=>{const w=Zt(localStorage.getItem("selected-provider"));return Di(w).defaultMode}),ft=l.useMemo(()=>ls(t),[t]),[Et,Nt]=l.useState(()=>ft.currentModeId),[yt,vt]=l.useState("none"),[we,Tt]=l.useState(()=>Zt(localStorage.getItem("selected-provider"))),[Rt,X]=l.useState(()=>to("claude")),[xe,Ce]=l.useState(()=>to("codex")),[ze,Ve]=l.useState(()=>to("gemini")),[_,H]=l.useState(()=>to("opencode")),[oe,Be]=l.useState({}),[ot,N]=l.useState({}),[Ee,M]=l.useState({}),[R,te]=l.useState({}),[Ge,dt]=l.useState({}),[nt,or]=l.useState({}),qt=l.useMemo(()=>li(S),[S]),[ee,Lt]=l.useState(qt),[Ot,Kt]=l.useState(qt),[vr,Vt]=l.useState(!1),gt=l.useRef(null),cr=l.useRef(null),Ar=l.useRef(null),Vr=l.useRef(null),j=l.useRef(null),re=l.useRef(null),de=l.useRef(qt),Fe=l.useRef(!1),De=l.useRef(null),at=l.useRef(we),ut=l.useMemo(()=>Di(we),[we]),At=l.useMemo(()=>Tv(Oe,q),[q,Oe]),Mt=l.useMemo(()=>Ri(we),[we]),lt=we==="claude"?Rt:we==="codex"?xe:we==="gemini"?ze:_,Xt=l.useMemo(()=>w0(we).OPTIONS,[we]),ht=l.useMemo(()=>(oe[we]||[]).map(w=>({value:w,label:w})),[oe,we]),kt=t?.__provider===we&&C0(we,t?.model)?t.model.trim():"",_t=kt||lt,Wt=l.useMemo(()=>{const w=ht.length>0?ht:Xt;return!kt||w.some(B=>B.value===kt)?w:[{value:kt,label:kt},...w]},[ht,Xt,kt]),Gr=Wt.find(w=>w.value===_t)?.label||_t||le("providerSelection.selectModel"),br=!!kt,Ut=we==="opencode"&&!!Ee.opencode,Fo=l.useCallback((w,{short:B=!1}={})=>{let W=le("codex.modes.default");return w==="acceptEdits"?W=le("codex.modes.acceptEdits"):w==="bypassPermissions"?W=le("codex.modes.bypassPermissions"):w==="plan"&&(W=le("codex.modes.plan")),B?W.replace(/\s*模式$/,"").replace(/\s*Mode$/,""):W},[le]),ru=l.useMemo(()=>Fo(_e,{short:!0}),[Fo,_e]),nu=l.useMemo(()=>le("codex.permissionMode").replace(/^权限/,"").replace(/^Permission\s+/i,""),[le]),$o=l.useCallback(async(w,{force:B=!1}={})=>{if(!v0.includes(w))return null;dt(W=>({...W,[w]:!0})),or(W=>({...W,[w]:null})),te(W=>({...W,[w]:{status:y0}}));try{const Y=await fe(`/api/cli/providers/${w}/installation-status${B?"?force=true":""}`),Pe=await Y.json().catch(()=>({}));if(!Y.ok||Pe?.success!==!0)throw new Error(Pe?.error||`Failed to check ${w} installation`);const Ye=Pe.installed?x0:ts;return te(ct=>({...ct,[w]:{status:Ye,command:Pe.command||null,resolvedPath:Pe.resolvedPath||null,reason:Pe.reason||null,installHint:Pe.installHint||null,checkedAt:Pe.checkedAt||null,cacheHit:!!Pe.cacheHit}})),Ye}catch(W){return te(Y=>({...Y,[w]:{status:eo}})),or(Y=>({...Y,[w]:W.message})),eo}finally{dt(W=>({...W,[w]:!1}))}},[or,dt,te]),ou=l.useCallback(w=>{if(!w)return;const B=Zt(w);Tt(B),localStorage.setItem("selected-provider",B),$o(B)},[$o]);l.useEffect(()=>{const w=Wt.map(B=>B.value);!lt||w.includes(lt)||(we==="claude"?X(""):we==="codex"?Ce(""):we==="gemini"?Ve(""):we==="opencode"&&H(""),j0(we))},[we,lt,Wt]),l.useEffect(()=>{if(!e)return;const w=e.fullPath||e.path;if(!w)return;const B=`runtime-models:v2:${we}:${w}`,W=yl(bt.getItem(B)),Y=Array.isArray(W?.models)?W.models:[],Pe=typeof W?.currentModel=="string"?W.currentModel.trim():"",Ye=Number(W?.timestamp||0);if(Y.length>0&&Date.now()-Ye<b0){Be(pt=>({...pt,[we]:Y})),Pe&&N(pt=>({...pt,[we]:{...pt?.[we]||{},currentModel:Pe}}));return}let Pt=!1;return M(pt=>({...pt,[we]:!0})),st.providerDiscovery(we,w).then(async pt=>{if(!pt.ok)throw new Error(`HTTP ${pt.status}`);return pt.json()}).then(pt=>{if(Pt)return;const Gt=Array.isArray(pt?.models)?pt.models.map(_r=>_r.id):[],dr=typeof pt?.currentModel=="string"?pt.currentModel.trim():"";N(_r=>({..._r,[we]:pt})),Be(_r=>({..._r,[we]:Gt})),Gt.length>0&&bt.setItem(B,JSON.stringify({models:Gt,currentModel:dr||"",timestamp:Date.now()}))}).catch(()=>{Pt||Be(pt=>({...pt,[we]:Y}))}).finally(()=>{Pt||M(pt=>({...pt,[we]:!1}))}),()=>{Pt=!0}},[we,e]),l.useEffect(()=>{de.current=Ot},[Ot]);const ja=l.useRef(Li);l.useEffect(()=>{if(ja.current)return;const w=Ms(se);w&&(ue(w),Fe.current=!0,ja.current=!0,Li=!0)},[se]),l.useEffect(()=>{Lt(qt),Kt(qt),Vt(!1)},[qt]);const sr=l.useCallback((w,B,W={})=>{!B||typeof Q!="function"||Q({type:w,requestId:B,payload:{...W,clientId:ie||null}})},[ie,Q]),Sa=l.useCallback((w,B=null)=>{if(typeof w?.context!="object"||w.context==null||Array.isArray(w.context)){console.warn("[DynamicContext] Ignored integration.context.update because context is not an object."),sr("integration.error",B,{code:"INVALID_PAYLOAD",message:"context must be an object"});return}if(s0(w.mode)===Ts){const Pe=o0(de.current,w.context);if(!Pe){console.warn("[DynamicContext] Ignored invalid append context payload."),sr("integration.error",B,{code:"INVALID_PAYLOAD",message:"append context payload is invalid"});return}Lt(Pe),Kt(Pe),Vt(!1),sr("integration.ack",B,{accepted:!0,applied:!0});return}const Y=li(w.context);if(!Y){sr("integration.error",B,{code:"INVALID_PAYLOAD",message:"context payload does not satisfy contextV1"});return}Lt(Y),Kt(Y),Vt(!1),sr("integration.ack",B,{accepted:!0,applied:!0})},[sr]),Na=l.useCallback((w,B=null)=>{if(typeof w?.prompt!="string"){sr("integration.error",B,{code:"INVALID_PAYLOAD",message:"prompt must be a string"});return}const W=Ms(w.prompt);if(ue(W),Fe.current=!0,w.autoSend===!0&&W&&n.current&&!a&&re.current){const Y={preventDefault:()=>{}};re.current(Y,W)}sr("integration.ack",B,{accepted:!0,applied:!0})},[a,n,sr]),Ca=l.useCallback((w=null)=>{sr("integration.ack",w,{accepted:!0,available:!0,pageUrl:typeof window<"u"?window.location.href:null,sessionId:t?.id||null})},[t?.id,sr]);l.useEffect(()=>{if(!U?.__messageSeq)return;const B=U?.type;if(B==="integration.context.update"){Sa(U.payload||{},U.requestId||null);return}if(B==="integration.prompt.update"){Na(U.payload||{},U.requestId||null);return}B==="integration.ping"&&Ca(U.requestId||null)},[Sa,Na,U,Ca]);const fn=l.useMemo(()=>vr||!Ot||!Zx(Ot)?null:Ot,[vr,Ot]),su=l.useMemo(()=>fn?.selectedElements?.slice(0,si)||[],[fn]),au=l.useMemo(()=>fn?.selectedElements?.slice(si)||[],[fn]),iu=l.useCallback(()=>{Kt(w=>!w||!xr(w.systemContext)?w:{...w,systemContext:""})},[]),lu=l.useCallback(()=>{Kt(w=>!w||!xr(an(w.currentFile))?w:{...w,currentFile:{path:"",displayName:""}})},[]),cu=l.useCallback(w=>{Kt(B=>{if(!B||!Array.isArray(B.selectedElements)||B.selectedElements.length===0)return B;const W=B.selectedElements.findIndex(Y=>Y.tag===w.tag&&Y.selector===w.selector&&Y.label===w.label);return W<0?B:{...B,selectedElements:B.selectedElements.filter((Y,Pe)=>Pe!==W)}})},[]);l.useEffect(()=>{if(t?.id){const w=localStorage.getItem(`permissionMode-${t.id}`);w&&ut.modes.includes(w)?Qe(w):Qe(ut.defaultMode)}},[t?.id,ut]),l.useEffect(()=>{ut.modes.includes(_e)||Qe(ut.defaultMode)},[_e,ut]),l.useEffect(()=>{if(!Mt.enabled){yt!==Mt.defaultMode&&vt(Mt.defaultMode);return}Mt.modes.includes(yt)||vt(Mt.defaultMode)},[Mt,yt]),l.useEffect(()=>{if(t&&t.__provider&&t.__provider!==we){const w=Zt(t.__provider);Tt(w),localStorage.setItem("selected-provider",w)}if(t?.id&&t?.__provider)try{const w=localStorage.getItem("session-provider-map"),B=w?JSON.parse(w):{};B[t.id]!==t.__provider&&(B[t.id]=t.__provider,localStorage.setItem("session-provider-map",JSON.stringify(B)))}catch{}},[we,t]),l.useEffect(()=>{at.current!==we&&(p([]),at.current=we)},[we,p]),l.useEffect(()=>{p(w=>w.filter(B=>!B.sessionId||B.sessionId===t?.id))},[t?.id,p]),l.useEffect(()=>{const w=ls(t),B=new Set(w.availableModes.map(W=>W.id));Nt(W=>w.currentModeId&&B.has(w.currentModeId)?w.currentModeId:W&&B.has(W)?W:"")},[t]),l.useEffect(()=>{v(Iv(t))},[t]),l.useEffect(()=>{(async()=>{if(e)try{const B=await fe("/api/commands/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPath:e.path})});if(!B.ok)throw new Error("Failed to fetch commands");const W=await B.json(),Y=[...(W.builtIn||[]).map(ct=>({...ct,type:"built-in"})),...(W.custom||[]).map(ct=>({...ct,type:"custom"}))];A(Y);const Pe=`command_history_${e.name}`,Ye=bt.getItem(Pe);if(Ye)try{const ct=JSON.parse(Ye),Pt=[...Y].sort((pt,Gt)=>{const dr=ct[pt.name]||0;return(ct[Gt.name]||0)-dr});A(Pt)}catch(ct){console.error("Error parsing command history:",ct)}}catch(B){console.error("Error fetching slash commands:",B),A([])}})()},[e]);const Bo=l.useMemo(()=>At.length?new mn(At,{keys:[{name:"name",weight:2},{name:"description",weight:1}],threshold:.4,includeScore:!0,minMatchCharLength:1}):null,[At]);l.useEffect(()=>{if(!$){C(At);return}if(!Bo){C([]);return}const w=Bo.search($);C(w.map(B=>B.item))},[$,At,Bo]);const du=l.useMemo(()=>{if(!e||At.length===0)return[];const w=`command_history_${e.name}`,B=bt.getItem(w);if(!B)return[];try{const W=JSON.parse(B);return At.map(Y=>({...Y,usageCount:W[Y.name]||0})).filter(Y=>Y.usageCount>0).sort((Y,Pe)=>Pe.usageCount-Y.usageCount).slice(0,5)}catch(W){return console.error("Error parsing command history:",W),[]}},[At,e]),Ea=l.useCallback(w=>{const{action:B,data:W}=w;switch(B){case"clear":i([]),z([]);break;case"help":i(Y=>[...Y,{role:"assistant",content:W.content,timestamp:Date.now()}]);break;case"model":{const Y=Object.entries(W.available||{}).filter(([,Ye])=>Array.isArray(Ye)&&Ye.length>0).map(([Ye,ct])=>`**${Ye.charAt(0).toUpperCase()+Ye.slice(1)}**: ${ct.join(", ")}`).join(`
266
+
267
+ `),Pe=W.current.provider==="opencode"?W.opencodeDiscovery?"_OpenCode source: runtime provider registry._":"_OpenCode source: local fallback list._":"";i(Ye=>[...Ye,{role:"assistant",content:`**Current Model**: ${W.current.model}
268
+
269
+ **Available Models**:
270
+
271
+ ${Y}${Pe?`
272
+
273
+ ${Pe}`:""}`,timestamp:Date.now()}]);break}case"cost":{const Y=`**Token Usage**: ${W.tokenUsage.used.toLocaleString()} / ${W.tokenUsage.total.toLocaleString()} (${W.tokenUsage.percentage}%)
274
+
275
+ **Estimated Cost**:
276
+ - Input: $${W.cost.input}
277
+ - Output: $${W.cost.output}
278
+ - **Total**: $${W.cost.total}
279
+
280
+ **Model**: ${W.model}`;i(Pe=>[...Pe,{role:"assistant",content:Y,timestamp:Date.now()}]);break}case"status":{const Y=`**System Status**
281
+
282
+ - Version: ${W.version}
283
+ - Uptime: ${W.uptime}
284
+ - Model: ${W.model}
285
+ - Provider: ${W.provider}
286
+ - Node.js: ${W.nodeVersion}
287
+ - Platform: ${W.platform}`;i(Pe=>[...Pe,{role:"assistant",content:Y,timestamp:Date.now()}]);break}case"memory":W.error?i(Y=>[...Y,{role:"assistant",content:`⚠️ ${W.message}`,timestamp:Date.now()}]):(i(Y=>[...Y,{role:"assistant",content:`📝 ${W.message}
288
+
289
+ Path: \`${W.path}\``,timestamp:Date.now()}]),W.exists&&y&&y(W.path));break;case"config":b&&b();break;case"rewind":W.error?i(Y=>[...Y,{role:"assistant",content:`⚠️ ${W.message}`,timestamp:Date.now()}]):(i(Y=>Y.slice(0,-W.steps*2)),i(Y=>[...Y,{role:"assistant",content:`⏪ ${W.message}`,timestamp:Date.now()}]));break;default:console.warn("Unknown built-in command action:",B)}},[y,b,i,z]),Aa=l.useCallback(async w=>{const{content:B,hasBashCommands:W}=w;if(W&&!window.confirm("这条命令包含将要执行的 Bash 命令,是否继续?")){i(Pe=>[...Pe,{role:"assistant",content:"❌ 已取消命令执行",timestamp:Date.now()}]);return}ue(B),setTimeout(()=>{if(re.current){const Y={preventDefault:()=>{}};re.current(Y)}},50)},[i]),Ln=l.useCallback(async w=>{if(!(!w||!e))try{const B=ce.match(new RegExp(`${w.name}\\s*(.*)`)),W=B&&B[1]?B[1].trim().split(/\s+/):[],Y={projectPath:e.path,projectName:e.name,sessionId:o,provider:we,..._t?{model:_t}:{},tokenUsage:P},Pe=await fe("/api/commands/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandName:w.name,commandPath:w.path,args:W,context:Y})});if(!Pe.ok)throw new Error("Failed to execute command");const Ye=await Pe.json();Ye.type==="builtin"?Ea(Ye):Ye.type==="custom"&&await Aa(Ye,W),ue(""),Re(!1),me(-1),D(""),Me(-1)}catch(B){console.error("Error executing command:",B),i(W=>[...W,{role:"assistant",content:`Error executing command: ${B.message}`,timestamp:Date.now()}])}},[_t,o,Ea,Aa,ce,we,e,i,P]),uu=l.useCallback(w=>{const B=String(w||"").trim();if(!B||B===Et)return;Nt(B);const W=t?.id||o;if(!W)return;const Y=t?.__provider||we||"claude";f({type:"set-session-mode",provider:Y,sessionId:W,modeId:B})},[Et,o,we,t?.__provider,t?.id,f]),On=l.useCallback(w=>{if(!w||!e?.name)return;const B=`command_history_${e.name}`,W=bt.getItem(B);let Y={};try{Y=W?JSON.parse(W):{}}catch(Pe){console.error("Error parsing command history:",Pe)}Y[w.name]=(Y[w.name]||0)+1,bt.setItem(B,JSON.stringify(Y))},[e?.name]),pu=l.useCallback((w,B,W)=>{if(!(!w||!e)){if(W){Me(B);return}if(On(w),w?.source==="acp"){const Y=String(w.name||"").trim(),Pe=Y.startsWith("/")?`${Y} `:`/${Y} `;ue(Pe),Re(!1),me(-1),D(""),Me(-1);return}Ln(w)}},[Ln,On,e]),zo=l.useCallback(w=>{if(!w)return;const B=w?.source==="acp",W=String(w.name||"").trim(),Y=B&&W&&!W.startsWith("/")?`/${W}`:W,Pe=ce.slice(0,it),Ye=ce.slice(it),ct=Ye.indexOf(" "),Pt=ct!==-1?Ye.slice(ct):"",pt=`${Pe}${Y} ${Pt}`;ue(pt),Re(!1),me(-1),D(""),Me(-1),De.current&&clearTimeout(De.current),On(w),B||Ln(w)},[Ln,On,ce,it]);l.useEffect(()=>{e&&st.getFiles(e.name).then(async w=>w.ok?w.json():[]).then(w=>{ve(Zc(w))}).catch(w=>{console.error("Error fetching files:",w)})},[e]),l.useEffect(()=>{const w=ce.slice(0,Ke),B=w.lastIndexOf("@");if(B!==-1){const W=w.slice(B+1);if(W.includes(" "))Se(!1),Le(-1);else{Le(B),Se(!0);const Y=We.filter(Pe=>Pe.name.toLowerCase().includes(W.toLowerCase())||Pe.path.toLowerCase().includes(W.toLowerCase())).slice(0,10);Te(Y),et(-1)}}else Se(!1),Le(-1)},[ce,Ke,We]);const hn=l.useMemo(()=>!ce||tt.length===0?[]:tt.filter(w=>ce.includes(w)),[tt,ce]),gn=l.useMemo(()=>hn.length===0?[]:Array.from(new Set(hn)).sort((w,B)=>B.length-w.length),[hn]),Wo=l.useMemo(()=>gn.length===0?null:new RegExp(`(${gn.map(Gx).join("|")})`,"g"),[gn]),_a=l.useMemo(()=>new Set(gn),[gn]),mu=l.useCallback(w=>w?Wo?w.split(Wo).map((W,Y)=>_a.has(W)?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:W},`mention-${Y}`):r.jsx("span",{children:W},`text-${Y}`)):w:"",[Wo,_a]),Fn=l.useCallback(w=>{const B=w.filter(W=>{try{if(!W||typeof W!="object"||!W.type||!W.type.startsWith("image/"))return!1;if(!W.size||W.size>5242880){const Y=W.name||"Unknown file";return ke(Pe=>{const Ye=new Map(Pe);return Ye.set(Y,"File too large (max 5MB)"),Ye}),!1}return!0}catch(Y){return console.error("Error validating file:",Y,W),!1}});B.length>0&&Z(W=>[...W,...B].slice(0,5))},[]),fu=l.useCallback(w=>{const B=Array.from(w.clipboardData.items);for(const W of B)if(W.type.startsWith("image/")){const Y=W.getAsFile();Y&&Fn([Y])}if(B.length===0&&w.clipboardData.files.length>0){const Y=Array.from(w.clipboardData.files).filter(Pe=>Pe.type.startsWith("image/"));Y.length>0&&Fn(Y)}},[Fn]),{getRootProps:hu,getInputProps:gu,isDragActive:xu,open:yu}=Cd({accept:{"image/*":[".png",".jpg",".jpeg",".gif",".webp",".svg"]},maxSize:5*1024*1024,maxFiles:5,onDrop:Fn,noClick:!0,noKeyboard:!0}),Jr=l.useCallback(async(w,B=null)=>{w.preventDefault();const W=typeof B=="string"?B:ce,Y=t?.__provider||we||"claude";if((R[Y]?.status||eo)===ts||!W.trim()||a||!e)return;let Ye=W;const ct=Ri(Y),Pt=ct.enabled?zp.find(It=>It.id===yt):null;ct.strategy==="prompt-prefix"&&Pt?.prefix&&(Ye=`${Pt.prefix}: ${W}`);const pt=!vr&&Qx(Ot)?a0(Ot):null;pt&&(Ye=i0(pt,Ye)),d("queued"),u(ma({phaseText:le("activity.stage.generatingReply"),detailText:le("activity.detail.preparingReply"),canAbort:!0}));let Gt=[];if(O.length>0){if(!wv(Y)){d("idle"),c(!1),u(null),i(It=>[...It,{type:"error",content:`${Y} 当前不支持图片输入`,timestamp:new Date}]);return}try{Gt=await Nv(O)}catch(It){console.error("Image preparation failed:",It),d("idle"),c(!1),u(null),i(Bn=>[...Bn,{type:"error",content:`图片处理失败:${It.message}`,timestamp:new Date}]);return}}const dr=Ev(hn),_r=[...Gt.map(It=>({type:"image",data:It.data,mimeType:It.mimeType,name:It.name})),...dr],Xr=jv(),Pa={type:"user",content:W,provider:Y,images:Gt,contentBlocks:dr,timestamp:new Date,clientRequestId:Xr};i(It=>[...It,Pa]),T(!1),setTimeout(()=>L(),100);const Dt=o||t?.id;F(Dt||t?.id||null),Dt&&k(Ft({kind:"user_message",provider:Y,sessionId:Dt,timestamp:Pa.timestamp,payload:{text:W,contentBlocks:_r},extensions:{clientRequestId:Xr,optimistic:!0}}));const Ru=Dt||`new-session-${Date.now()}`;!Dt&&!t?.id&&(E.current={sessionId:null,startedAt:Date.now()}),h&&h(Ru);const Lu=(()=>{try{const It=we==="codex"?"codex-settings":"claude-settings",Bn=bt.getItem(It);if(Bn)return JSON.parse(Bn)}catch(It){console.error("Error loading tools settings:",It)}return{allowedTools:[],disallowedTools:[],skipPermissions:!1}})();if(Y==="codex"){const It=ct.enabled&&ct.strategy==="native-effort"?kv(yt):void 0;f({type:"codex-command",clientRequestId:Xr,command:Ye,sessionId:Dt,options:{cwd:e.fullPath||e.path,projectPath:e.fullPath||e.path,sessionId:Dt,resume:!!Dt,permissionMode:_e==="plan"?"default":_e,..._t?{model:_t}:{},...It?{modelReasoningEffort:It}:{},images:Gt,resourceLinks:dr}})}else f(Y==="gemini"?{type:"gemini-command",clientRequestId:Xr,command:Ye,sessionId:Dt,options:{cwd:e.fullPath||e.path,projectPath:e.fullPath||e.path,sessionId:Dt,resume:!!Dt,permissionMode:_e==="plan"?"default":_e,..._t?{model:_t}:{},images:Gt,resourceLinks:dr}}:Y==="opencode"?{type:"opencode-command",clientRequestId:Xr,command:Ye,sessionId:Dt,options:{cwd:e.fullPath||e.path,projectPath:e.fullPath||e.path,sessionId:Dt,resume:!!Dt,permissionMode:_e==="plan"?"default":_e,..._t?{model:_t}:{},images:Gt,resourceLinks:dr}}:{type:"claude-command",clientRequestId:Xr,command:Ye,options:{projectPath:e.path,cwd:e.fullPath,sessionId:Dt,resume:!!Dt,toolsSettings:Lu,permissionMode:_e,..._t?{model:_t}:{},images:Gt,resourceLinks:dr}});pt&&Vt(!0),ue(""),Z([]),be(new Map),ke(new Map),pe(!1),vt("none"),gt.current&&(gt.current.style.height="auto"),e&&bt.removeItem(`draft_input_${e.name}`)},[hn,k,O,_t,o,vr,ce,a,h,Ot,E,_e,we,R,L,e,t,f,c,i,u,T,d,F,le,yt]);l.useEffect(()=>{re.current=Jr},[Jr]);const vu=l.useCallback(w=>!w||we!=="claude"?{success:!1}:T0(w.entry),[we]),bu=l.useCallback((w,B)=>{const Y=(Array.isArray(w)?w:[w]).filter(Boolean);Y.length!==0&&(Y.forEach(Pe=>{f({type:"permission-response",requestId:Pe,optionId:B?.optionId,outcome:B?.outcome,cancelled:!!B?.cancelled,allow:!!B?.allow,updatedInput:B?.updatedInput,message:B?.message,rememberEntry:B?.rememberEntry})}),p(Pe=>{const Ye=Pe.filter(ct=>!Y.includes(ct.requestId));return Ye.length===0&&u(null),Ye}))},[f,u,p]),$n=l.useCallback(w=>{const B=ce.slice(0,ge),W=ce.slice(ge),Y=W.indexOf(" "),Pe=Y!==-1?W.slice(Y):"",Ye=`${B}${w.path} ${Pe}`,ct=B.length+w.path.length+1;gt.current&&!gt.current.matches(":focus")&&gt.current.focus(),ue(Ye),Xe(ct),$e(Pt=>Pt.includes(w.path)?Pt:[...Pt,w.path]),Se(!1),Le(-1),gt.current&&requestAnimationFrame(()=>{gt.current&&(gt.current.setSelectionRange(ct,ct),gt.current.matches(":focus")||gt.current.focus())})},[ge,ce]),wu=l.useCallback(w=>{const B=w.target.value,W=w.target.selectionStart;if(ue(B),Xe(W),!B.trim()){w.target.style.height="auto",pe(!1),Re(!1),me(-1),D("");return}const Y=B.slice(0,W);if((Y.match(/```/g)||[]).length%2===1){Re(!1),me(-1),D("");return}const Ye=Y.match(/(^|\s)\/(\S*)$/);if(Ye){const ct=Ye.index+Ye[1].length,Pt=Ye[2];me(ct),Re(!0),Me(-1),De.current&&clearTimeout(De.current),De.current=setTimeout(()=>{D(Pt)},150)}else Re(!1),me(-1),D(""),De.current&&clearTimeout(De.current)},[]),Uo=l.useCallback(w=>{!Ar.current||!w||(Ar.current.scrollTop=w.scrollTop,Ar.current.scrollLeft=w.scrollLeft)},[]),ku=l.useCallback(w=>{Xe(w.target.selectionStart)},[]),ju=l.useCallback(w=>{w.target.style.height="auto",w.target.style.height=`${w.target.scrollHeight}px`,Xe(w.target.selectionStart),Uo(w.target);const B=parseInt(window.getComputedStyle(w.target).lineHeight,10),W=w.target.scrollHeight>B*2;pe(W)},[Uo]),Su=l.useCallback(w=>{if(rt&&x.length>0){if(w.key==="ArrowDown"){w.preventDefault(),Me(B=>B<x.length-1?B+1:0);return}if(w.key==="ArrowUp"){w.preventDefault(),Me(B=>B>0?B-1:x.length-1);return}if(w.key==="Tab"||w.key==="Enter"){w.preventDefault(),Ie>=0?zo(x[Ie]):x.length>0&&zo(x[0]);return}if(w.key==="Escape"){w.preventDefault(),Re(!1),me(-1),D(""),Me(-1),De.current&&clearTimeout(De.current);return}}if(ne&&je.length>0){if(w.key==="ArrowDown"){w.preventDefault(),et(B=>B<je.length-1?B+1:0);return}if(w.key==="ArrowUp"){w.preventDefault(),et(B=>B>0?B-1:je.length-1);return}if(w.key==="Tab"||w.key==="Enter"){w.preventDefault(),qe>=0?$n(je[qe]):je.length>0&&$n(je[0]);return}if(w.key==="Escape"){w.preventDefault(),Se(!1);return}}if(w.key==="Tab"&&!ne&&!rt){w.preventDefault();const B=ut.modes,Y=(B.indexOf(_e)+1)%B.length,Pe=B[Y];Qe(Pe),t?.id&&localStorage.setItem(`permissionMode-${t.id}`,Pe);return}if(w.key==="Enter"){if(w.nativeEvent.isComposing)return;(w.ctrlKey||w.metaKey)&&!w.shiftKey?(w.preventDefault(),Jr(w)):!w.shiftKey&&!w.ctrlKey&&!w.metaKey&&(V||(w.preventDefault(),Jr(w)))}},[x,je,Jr,_e,ut.modes,zo,$n,Ie,qe,t?.id,V,rt,ne]),Yr=t?.__provider||we||"claude",Ho=R[Yr],Ia=Ho?.status||eo,Ta=Ia===ts,Nu=Ho?.reason||nt[Yr]||null,Cu=Ho?.installHint||null,Eu=!!Ge[Yr],Au=a||Ta,Ma=Yr==="opencode"?"OpenCode":le(`messageTypes.${Yr}`),_u=le("input.providerNotInstalledWithName",{provider:Ma}),Iu=l.useMemo(()=>ls(t),[t]);l.useEffect(()=>{e&&ce!==""?bt.setItem(`draft_input_${e.name}`,ce):e&&ce===""&&bt.removeItem(`draft_input_${e.name}`)},[ce,e]),l.useEffect(()=>{if(e){if(Fe.current){Fe.current=!1;return}const w=bt.getItem(`draft_input_${e.name}`)||"";w!==ce&&ue(w)}},[ce,e?.name]),l.useEffect(()=>{g&&g(G)},[G,g]),l.useEffect(()=>{if(gt.current){gt.current.style.height="auto",gt.current.style.height=`${gt.current.scrollHeight}px`;const w=parseInt(window.getComputedStyle(gt.current).lineHeight,10);pe(gt.current.scrollHeight>w*2)}},[]),l.useEffect(()=>{gt.current&&!ce.trim()&&(gt.current.style.height="auto",pe(!1))},[ce]);const Tu=l.useCallback(w=>{Z(B=>B.filter((W,Y)=>Y!==w))},[]),Mu=l.useCallback(w=>{we==="claude"?X(w):we==="codex"?Ce(w):we==="gemini"?Ve(w):we==="opencode"&&H(w),k0(we,w)},[we]),Pu=l.useCallback(()=>{const w=o||t?.id,B=t?.__provider||we;w&&s&&f({type:"abort-session",sessionId:w,provider:B})},[s,o,we,t?.__provider,t?.id,f]),Du=l.useCallback(()=>{ue(""),Z([]),be(new Map),ke(new Map),pe(!1),vt("none"),Re(!1),Se(!1),D(""),me(-1),Me(-1),et(-1),e?.name&&bt.removeItem(`draft_input_${e.name}`),typeof K=="function"&&K()},[K,e?.name]);return{input:ce,setInput:ue,provider:we,setProvider:Tt,handleProviderSelection:ou,permissionMode:_e,setPermissionMode:Qe,acpModes:Iu.availableModes,acpModeId:Et,handleAcpModeChange:uu,selectedPermissionShortLabel:ru,permissionDropdownTitle:nu,providerModeConfig:ut,getPermissionModeLabel:Fo,providerThinkingConfig:Mt,thinkingMode:yt,setThinkingMode:vt,currentModel:_t,modelOptions:Wt,selectedModelLabel:Gr,isModelSelectionLocked:br,isOpencodeModelLoading:Ut,setProviderModel:Mu,textareaRef:gt,inputContainerRef:cr,inputHighlightRef:Ar,modelSelectorRef:Vr,permissionSelectorRef:j,showFileDropdown:ne,filteredFiles:je,selectedFileIndex:qe,selectFile:$n,showCommandMenu:rt,filteredCommands:x,selectedCommandIndex:Ie,handleCommandSelect:pu,commandQuery:$,frequentCommands:du,slashPosition:it,setShowCommandMenu:Re,setSelectedCommandIndex:Me,setSlashPosition:me,setCommandQuery:D,getRootProps:hu,getInputProps:gu,isDragActive:xu,openImagePicker:yu,attachedImages:O,uploadingImages:ae,imageErrors:ye,removeAttachedImage:Tu,visibleDynamicContext:fn,visibleSelectedElements:su,hiddenSelectedElements:au,handleDismissSystemContext:iu,handleDismissCurrentFile:lu,handleDismissSelectedElement:cu,renderInputWithMentions:mu,handleInputChange:wu,handleTextareaClick:ku,handleKeyDown:Su,handlePaste:fu,syncInputOverlayScroll:Uo,handleTextareaInput:ju,activeInputProvider:Yr,activeInputProviderLabel:Ma,activeProviderInstallState:Ia,isActiveProviderNotInstalled:Ta,unavailablePlaceholder:_u,isInputDisabled:Au,activeProviderInstallReason:Nu,activeProviderInstallHint:Cu,isCheckingProviderInstallation:Eu,checkProviderInstallation:$o,providerCheckLoadingByName:Ge,isInputFocused:G,setIsInputFocused:Ae,isTextareaExpanded:J,tokenBudget:P,handleSubmit:Jr,canAbortSession:s,handleAbortSession:Pu,handleSubmitRef:re,handleGrantToolPermission:vu,handlePermissionDecision:bu,dynamicContext:ee,pendingDynamicContext:Ot,setPendingDynamicContext:Kt,dynamicContextSent:vr,setDynamicContextSent:Vt,resetComposerForNewChat:Du}}function Pv({selectedProject:e,selectedSession:t,ws:n,sendMessage:o,latestMessage:s,onFileOpen:a,onInputFocusChange:i,onSessionActive:c,onSessionInactive:d,onSessionProcessing:u,onSessionNotProcessing:m,processingSessions:p,onReplaceTemporarySession:f,onNavigateToSession:h,onShowSettings:g,autoExpandTools:b,showRawParameters:y,showThinking:k,autoScrollToBottom:F,sendByCtrlEnter:E,externalMessageUpdate:L,urlContext:T,urlPrompt:P,integrationClientId:I,latestIntegrationMessage:z,sendIntegrationMessage:K,newSessionResetNonce:S=0}){const{t:se}=St("chat"),ie=l.useMemo(()=>typeof window<"u"&&e?.name?_0(e.name,t?.id||null):[],[e?.name,t?.id]),[U,Q]=l.useReducer(Px,ie,Mx),[V,le]=l.useState(t?.id||null),[ce,ue]=l.useState(!1),[G,Ae]=l.useState(null),[O,Z]=l.useState(null),[ae,be]=l.useState([]),ye=l.useRef(e),ke=l.useRef(U.messages),ne=l.useRef(U.isLoading),Se=l.useRef({sessionId:null,startedAt:0}),We=l.useRef(null),ve=l.useRef(S),tt=l.useRef(""),$e=l.useRef(null),je=U.messages,Te=U.phase,qe=U.isLoading,et=U.canAbortSession,Ke=U.pendingPermissionRequests;l.useEffect(()=>{ye.current=e},[e]),l.useEffect(()=>{ke.current=je},[je]),l.useEffect(()=>{ne.current=qe},[qe]);const Xe=l.useCallback(me=>{Q({type:"replace_messages",value:me})},[]),ge=l.useCallback(me=>{Q({type:"replace_permissions",value:me})},[]),Le=l.useCallback(me=>{Q({type:"set_loading",value:me})},[]),rt=l.useCallback(me=>{Q({type:"set_can_abort",value:me})},[]),Re=l.useCallback((me,_e)=>{Q({type:"set_phase",phase:me,overrides:_e})},[]),Oe=l.useCallback((me,_e)=>{Q({type:"apply_conversation_event",event:me,provider:_e})},[]),A=l.useCallback(me=>{Se.current={sessionId:me||null,startedAt:Date.now()}},[]),q=l.useCallback(me=>{!me||!Se.current.startedAt||(Se.current={...Se.current,sessionId:me})},[]),v=l.useCallback((me=null)=>{const _e=Se.current;_e.startedAt&&(me&&_e.sessionId&&_e.sessionId!==me||(Se.current={sessionId:null,startedAt:0}))},[]),x=l.useCallback(()=>{$e.current&&(clearTimeout($e.current),$e.current=null),tt.current=""},[]),C=l.useCallback((me,_e=null)=>{if(_e&&_e!=="session-status")return!1;const Qe=Se.current;return!!(Qe.startedAt&&me&&Qe.sessionId===me&&Date.now()-Qe.startedAt<15e3&&(Te===he.CONNECTING||Te===he.QUEUED||Te===he.STREAMING||Te===he.AWAITING_APPROVAL||Te===he.COMPLETED||Te===he.ABORTED||Te===he.ERRORED))},[Te]),$=l.useCallback((me=null)=>{const _e=ye.current?.name||e?.name||"";_e&&sd(_e,me,ke.current)},[e?.name]),D=D0({selectedProject:e,selectedProjectRef:ye,selectedSession:t,currentSessionId:V,setCurrentSessionId:le,provider:t?.__provider||null,runtimePhase:Te,isLoading:qe,isLoadingRef:ne,processingSessions:p,autoScrollToBottom:F,externalMessageUpdate:L,ws:n,sendMessage:o,chatMessages:je,setChatMessages:Xe,setIsLoading:Le,setCanAbortSession:rt,setRuntimePhase:Re,setClaudeStatus:Ae,setPendingPermissionRequests:ge,resetStreamingState:x,clearLocalRunGuard:v,localRunGuardRef:Se,pendingViewSessionRef:We,isSystemSessionChange:ce,setIsSystemSessionChange:ue,onSessionInactive:d,onSessionNotProcessing:m,onSessionProcessing:u}),J=l.useMemo(()=>kx(D.sessionMessages),[D.sessionMessages]);l.useEffect(()=>{Z(J.modeState||null),be(Array.isArray(J.availableCommands)?J.availableCommands:[])},[J.availableCommands,J.modeState]);const pe=l.useMemo(()=>{if(!t&&!V)return t;const me=t?{...t}:{};return!me.id&&V&&(me.id=V),me.acpModes=O,me.acpAvailableCommands=ae,me},[ae,O,V,t]),Ie=Mv({selectedProject:e,selectedSession:pe,selectedProjectRef:ye,currentSessionId:V,canAbortSession:et,isLoading:qe,setChatMessages:Xe,setCanAbortSession:rt,setRuntimePhase:Re,setClaudeStatus:Ae,pendingPermissionRequests:Ke,setPendingPermissionRequests:ge,sendMessage:o,onSessionActive:c,onInputFocusChange:i,onShowSettings:g,onFileOpen:a,appendSessionConversationEvent:D.appendSessionConversationEvent,startLocalRunGuard:A,pendingViewSessionRef:We,scrollToBottom:D.scrollToBottom,setIsUserScrolledUp:D.setIsUserScrolledUp,tokenBudget:D.tokenBudget,chatMessages:je,setSessionMessages:D.setSessionMessages,resetRuntimeForNewChat:D.resetSessionHistoryForNewChat,urlContext:T,urlPrompt:P,integrationClientId:I,latestIntegrationMessage:z,sendIntegrationMessage:K,sendByCtrlEnter:E});L0({latestMessage:s,provider:Ie.provider,claudeStatus:G,selectedProject:e,selectedSession:t,currentSessionId:V,setCurrentSessionId:le,isLoading:qe,runtimePhase:Te,sendMessage:o,persistCurrentChatCache:$,setIsSystemSessionChange:ue,setPendingPermissionRequests:ge,setIsLoading:Le,setCanAbortSession:rt,setClaudeStatus:Ae,setChatMessages:Xe,setTokenBudget:D.setTokenBudget,setAcpSessionModeState:Z,setAcpAvailableCommands:be,applyRealtimeConversationEvent:Oe,streamBufferRef:tt,streamTimerRef:$e,clearLocalRunGuard:v,syncLocalRunGuardSession:q,shouldIgnoreStaleIdleSignal:C,pendingViewSessionRef:We,appendSessionConversationEvent:D.appendSessionConversationEvent,recoverAndSettleSessionRuntime:D.recoverAndSettleSessionRuntime,recoverTerminalSessionPhase:D.recoverTerminalSessionPhase,inferRuntimePhaseFromSessionEvents:D.inferRuntimePhaseFromSessionEvents,inferTerminalPhaseFromSessionEvents:D.inferTerminalPhaseFromSessionEvents,scheduleSessionStatusRecovery:D.scheduleSessionStatusRecovery,sessionMessages:D.sessionMessages,setSessionMessages:D.setSessionMessages,loadSessionMessages:D.loadSessionMessages,onSessionInactive:d,onSessionNotProcessing:m,onSessionProcessing:u,onReplaceTemporarySession:f,onNavigateToSession:h,t:se,setRuntimePhase:Re}),l.useEffect(()=>{ve.current!==S&&(ve.current=S,!t&&(x(),v(),Ie.resetComposerForNewChat()))},[v,Ie.resetComposerForNewChat,S,x,t]);const Me=px({status:G,messages:je,pendingPermissionRequests:Ke,t:se}),it=qe&&!!Me;return r.jsxs(r.Fragment,{children:[r.jsx("style",{children:`
290
+ details[open] .details-chevron {
291
+ transform: rotate(180deg);
292
+ }
293
+ `}),r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsx(Vx,{selectedProject:e,selectedSession:t,currentSessionId:V,provider:Ie.provider,chatMessages:je,threadMessages:D.threadMessages,isLoading:qe,isLoadingSessionMessages:D.isLoadingSessionMessages,isLoadingMoreMessages:D.isLoadingMoreMessages,hasMoreMessages:D.hasMoreMessages,totalMessages:D.totalMessages,sessionMessages:D.sessionMessages,visibleMessageCount:D.visibleMessageCount,pendingPermissionRequests:Ke,scrollContainerRef:D.scrollContainerRef,messagesEndRef:D.messagesEndRef,onScroll:D.handleScroll,onLoadEarlierSessionMessages:()=>D.loadOlderMessages(),onLoadEarlierMessages:D.loadEarlierMessages,onProviderSelection:Ie.handleProviderSelection,onFileOpen:a,onShowSettings:g,onGrantToolPermission:Ie.handleGrantToolPermission,onPermissionDecision:Ie.handlePermissionDecision,autoExpandTools:b,showRawParameters:y}),r.jsx(p0,{composer:Ie,statusPresentation:Me,shouldShowClaudeStatus:it,isLoading:qe,chatMessages:je,sendByCtrlEnter:E})]})]})}const Dv=jt.memo(Pv);class Ct{constructor(t,n,o,s){this.fromA=t,this.toA=n,this.fromB=o,this.toB=s}offset(t,n=t){return new Ct(this.fromA+t,this.toA+t,this.fromB+n,this.toB+n)}}function Wr(e,t,n,o,s,a){if(e==o)return[];let i=ya(e,t,n,o,s,a),c=va(e,t+i,n,o,s+i,a);t+=i,n-=c,s+=i,a-=c;let d=n-t,u=a-s;if(!d||!u)return[new Ct(t,n,s,a)];if(d>u){let p=e.slice(t,n).indexOf(o.slice(s,a));if(p>-1)return[new Ct(t,t+p,s,s),new Ct(t+p+u,n,a,a)]}else if(u>d){let p=o.slice(s,a).indexOf(e.slice(t,n));if(p>-1)return[new Ct(t,t,s,s+p),new Ct(n,n,s+p+d,a)]}if(d==1||u==1)return[new Ct(t,n,s,a)];let m=_d(e,t,n,o,s,a);if(m){let[p,f,h]=m;return Wr(e,t,p,o,s,f).concat(Wr(e,p+h,n,o,f+h,a))}return Rv(e,t,n,o,s,a)}let vn=1e9,bn=0,xa=!1;function Rv(e,t,n,o,s,a){let i=n-t,c=a-s;if(vn<1e9&&Math.min(i,c)>vn*16||bn>0&&Date.now()>bn)return Math.min(i,c)>vn*64?[new Ct(t,n,s,a)]:Fi(e,t,n,o,s,a);let d=Math.ceil((i+c)/2);cs.reset(d),ds.reset(d);let u=(h,g)=>e.charCodeAt(t+h)==o.charCodeAt(s+g),m=(h,g)=>e.charCodeAt(n-h-1)==o.charCodeAt(a-g-1),p=(i-c)%2!=0?ds:null,f=p?null:cs;for(let h=0;h<d;h++){if(h>vn||bn>0&&!(h&63)&&Date.now()>bn)return Fi(e,t,n,o,s,a);let g=cs.advance(h,i,c,d,p,!1,u)||ds.advance(h,i,c,d,f,!0,m);if(g)return Lv(e,t,n,t+g[0],o,s,a,s+g[1])}return[new Ct(t,n,s,a)]}class Ed{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,o,s,a,i,c){for(let d=-t+this.start;d<=t-this.end;d+=2){let u=s+d,m=d==-t||d!=t&&this.vec[u-1]<this.vec[u+1]?this.vec[u+1]:this.vec[u-1]+1,p=m-d;for(;m<n&&p<o&&c(m,p);)m++,p++;if(this.vec[u]=m,m>n)this.end+=2;else if(p>o)this.start+=2;else if(a){let f=s+(n-o)-d;if(f>=0&&f<this.len&&a.vec[f]!=-1)if(i){let h=a.vec[f];if(h>=n-m)return[h,s+h-f]}else{let h=n-a.vec[f];if(m>=h)return[m,p]}}}return null}}const cs=new Ed,ds=new Ed;function Lv(e,t,n,o,s,a,i,c){let d=!1;return!cn(e,o)&&++o==n&&(d=!0),!cn(s,c)&&++c==i&&(d=!0),d?[new Ct(t,n,a,i)]:Wr(e,t,o,s,a,c).concat(Wr(e,o,n,s,c,i))}function Ad(e,t){let n=1,o=Math.min(e,t);for(;n<o;)n=n<<1;return n}function ya(e,t,n,o,s,a){if(t==n||t==a||e.charCodeAt(t)!=o.charCodeAt(s))return 0;let i=Ad(n-t,a-s);for(let c=t,d=s;;){let u=c+i,m=d+i;if(u>n||m>a||e.slice(c,u)!=o.slice(d,m)){if(i==1)return c-t-(cn(e,c)?0:1);i=i>>1}else{if(u==n||m==a)return u-t;c=u,d=m}}}function va(e,t,n,o,s,a){if(t==n||s==a||e.charCodeAt(n-1)!=o.charCodeAt(a-1))return 0;let i=Ad(n-t,a-s);for(let c=n,d=a;;){let u=c-i,m=d-i;if(u<t||m<s||e.slice(u,c)!=o.slice(m,d)){if(i==1)return n-c-(cn(e,c)?0:1);i=i>>1}else{if(u==t||m==s)return n-u;c=u,d=m}}}function Hs(e,t,n,o,s,a,i,c){let d=o.slice(s,a),u=null;for(;;){if(u||i<c)return u;for(let m=t+i;;){cn(e,m)||m++;let p=m+i;if(cn(e,p)||(p+=p==m+1?1:-1),p>=n)break;let f=e.slice(m,p),h=-1;for(;(h=d.indexOf(f,h+1))!=-1;){let g=ya(e,p,n,o,s+h+f.length,a),b=va(e,t,m,o,s,s+h),y=f.length+g+b;(!u||u[2]<y)&&(u=[m-b,s+h-b,y])}m=p}if(c<0)return u;i=i>>1}}function _d(e,t,n,o,s,a){let i=n-t,c=a-s;if(i<c){let d=_d(o,s,a,e,t,n);return d&&[d[1],d[0],d[2]]}return i<4||c*2<i?null:Hs(e,t,n,o,s,a,Math.floor(i/4),-1)}function Fi(e,t,n,o,s,a){xa=!0;let i=n-t,c=a-s,d;if(i<c){let f=Hs(o,s,a,e,t,n,Math.floor(i/6),50);d=f&&[f[1],f[0],f[2]]}else d=Hs(e,t,n,o,s,a,Math.floor(c/6),50);if(!d)return[new Ct(t,n,s,a)];let[u,m,p]=d;return Wr(e,t,u,o,s,m).concat(Wr(e,u+p,n,o,m+p,a))}function Id(e,t){for(let n=1;n<e.length;n++){let o=e[n-1],s=e[n];o.toA>s.fromA-t&&o.toB>s.fromB-t&&(e[n-1]=new Ct(o.fromA,s.toA,o.fromB,s.toB),e.splice(n--,1))}}function Ov(e,t,n){for(;;){Id(n,1);let o=!1;for(let s=0;s<n.length;s++){let a=n[s],i,c;(i=ya(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[s]=new Ct(a.fromA+i,a.toA,a.fromB+i,a.toB)),(c=va(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[s]=new Ct(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 m=a.fromA-(s?n[s-1].toA:0),p=(s<n.length-1?n[s+1].fromA:e.length)-a.toA;if(!m||!p)continue;let f=d?e.slice(a.fromA,a.toA):t.slice(a.fromB,a.toB);m<=f.length&&e.slice(a.fromA-m,a.fromA)==f.slice(f.length-m)?(n[s]=new Ct(a.fromA-m,a.toA-m,a.fromB-m,a.toB-m),o=!0):p<=f.length&&e.slice(a.toA,a.toA+p)==f.slice(0,p)&&(n[s]=new Ct(a.fromA+p,a.toA+p,a.fromB+p,a.toB+p),o=!0)}if(!o)break}return n}function Fv(e,t,n){for(let o=0,s=0;s<e.length;s++){let a=e[s],i=a.toA-a.fromA,c=a.toB-a.fromB;if(i&&c||i>3||c>3){let d=s==e.length-1?t.length:e[s+1].fromA,u=a.fromA-o,m=d-a.toA,p=Bi(t,a.fromA,u),f=$i(t,a.toA,m),h=a.fromA-p,g=f-a.toA;if((!i||!c)&&h&&g){let b=Math.max(i,c),[y,k,F]=i?[t,a.fromA,a.toA]:[n,a.fromB,a.toB];b>h&&t.slice(p,a.fromA)==y.slice(F-h,F)?(a=e[s]=new Ct(p,p+i,a.fromB-h,a.toB-h),p=a.fromA,f=$i(t,a.toA,d-a.toA)):b>g&&t.slice(a.toA,f)==y.slice(k,k+g)&&(a=e[s]=new Ct(f-i,f,a.fromB+g,a.toB+g),f=a.toA,p=Bi(t,a.fromA,a.fromA-o)),h=a.fromA-p,g=f-a.toA}if(h||g)a=e[s]=new Ct(a.fromA-h,a.toA+g,a.fromB-h,a.toB+g);else if(i){if(!c){let b=Wi(t,a.fromA,a.toA),y,k=b<0?-1:zi(t,a.toA,a.fromA);b>-1&&(y=b-a.fromA)<=m&&t.slice(a.fromA,b)==t.slice(a.toA,a.toA+y)?a=e[s]=a.offset(y):k>-1&&(y=a.toA-k)<=u&&t.slice(a.fromA-y,a.fromA)==t.slice(k,a.toA)&&(a=e[s]=a.offset(-y))}}else{let b=Wi(n,a.fromB,a.toB),y,k=b<0?-1:zi(n,a.toB,a.fromB);b>-1&&(y=b-a.fromB)<=m&&n.slice(a.fromB,b)==n.slice(a.toB,a.toB+y)?a=e[s]=a.offset(y):k>-1&&(y=a.toB-k)<=u&&n.slice(a.fromB-y,a.fromB)==n.slice(k,a.toB)&&(a=e[s]=a.offset(-y))}}o=a.toA}return Id(e,3),e}let Br;try{Br=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch{}function Td(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function Md(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?Td(n)?1:0:Br?!Rd(n)||t==e.length-1?Br.test(String.fromCharCode(n))?1:0:Br.test(e.slice(t,t+2))?2:0:0}function Pd(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?Td(n)?1:0:Br?!Ld(n)||t==1?Br.test(String.fromCharCode(n))?1:0:Br.test(e.slice(t-2,t))?2:0:0}const Dd=8;function $i(e,t,n){if(t==e.length||!Pd(e,t))return t;for(let o=t,s=t+n,a=0;a<Dd;a++){let i=Md(e,o);if(!i||o+i>s)return o;o+=i}return t}function Bi(e,t,n){if(!t||!Md(e,t))return t;for(let o=t,s=t-n,a=0;a<Dd;a++){let i=Pd(e,o);if(!i||o-i<s)return o;o-=i}return t}function zi(e,t,n){for(;t!=n;t--)if(e.charCodeAt(t-1)==10)return t;return-1}function Wi(e,t,n){for(;t!=n;t++)if(e.charCodeAt(t)==10)return t;return-1}const Rd=e=>e>=55296&&e<=56319,Ld=e=>e>=56320&&e<=57343;function cn(e,t){return!t||t==e.length||!Rd(e.charCodeAt(t-1))||!Ld(e.charCodeAt(t))}function $v(e,t,n){var o;return vn=((o=n?.scanLimit)!==null&&o!==void 0?o:1e9)>>1,bn=n?.timeout?Date.now()+n.timeout:0,xa=!1,Ov(e,t,Wr(e,0,e.length,t,0,t.length))}function Od(){return!xa}function Fd(e,t,n){return Fv($v(e,t,n),e,t)}const Nr=jo.define({combine:e=>e[0]}),Bv=Ks.define(),$d=jo.define(),tr=En.define({create(e){return null},update(e,t){for(let n of t.effects)n.is(Bv)&&(e=n.value);for(let n of t.state.facet($d))e=n(e,t);return e}});function us(e){let t=e.field(tr,!1);if(!t)return null;let n=e.facet(Nr);return{chunks:t,side:n?n.side:null}}class tn{constructor(t,n,o,s,a,i=!0){this.changes=t,this.fromA=n,this.toA=o,this.fromB=s,this.toB=a,this.precise=i}offset(t,n){return t||n?new tn(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,o){let s=Fd(t.toString(),n.toString(),o);return Bd(s,t,n,0,0,Od())}static updateA(t,n,o,s,a){return Vi(Ki(t,s,!0,o.length),t,n,o,a)}static updateB(t,n,o,s,a){return Vi(Ki(t,s,!1,n.length),t,n,o,a)}}function Ui(e,t,n,o){let s=n.lineAt(e),a=o.lineAt(t);return s.to==e&&a.to==t&&e<n.length&&t<o.length?[e+1,t+1]:[s.from,a.from]}function Hi(e,t,n,o){let s=n.lineAt(e),a=o.lineAt(t);return s.from==e&&a.from==t?[e,t]:[s.to+1,a.to+1]}function Bd(e,t,n,o,s,a){let i=[];for(let c=0;c<e.length;c++){let d=e[c],[u,m]=Ui(d.fromA+o,d.fromB+s,t,n),[p,f]=Hi(d.toA+o,d.toB+s,t,n),h=[d.offset(-u+o,-m+s)];for(;c<e.length-1;){let g=e[c+1],[b,y]=Ui(g.fromA+o,g.fromB+s,t,n);if(b>p+1&&y>f+1)break;h.push(g.offset(-u+o,-m+s)),[p,f]=Hi(g.toA+o,g.toB+s,t,n),c++}i.push(new tn(h,u,Math.max(u,p),m,Math.max(m,f),a))}return i}const ao=1e3;function qi(e,t,n,o){let s=0,a=e.length;for(;;){if(s==a){let m=0,p=0;s&&({toA:m,toB:p}=e[s-1]);let f=t-(n?m:p);return[m+f,p+f]}let i=s+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)s=i+1;else return o?[c.fromA,c.fromB]:[c.toA,c.toB]}}function Ki(e,t,n,o){let s=[];return t.iterChangedRanges((a,i,c,d)=>{let u=0,m=n?t.length:o,p=0,f=n?o:t.length;a>ao&&([u,p]=qi(e,a-ao,n,!0)),i<t.length-ao&&([m,f]=qi(e,i+ao,n,!1));let h=d-c-(i-a),g,[b,y]=n?[h,0]:[0,h];s.length&&(g=s[s.length-1]).toA>=u?s[s.length-1]={fromA:g.fromA,fromB:g.fromB,toA:m,toB:f,diffA:g.diffA+b,diffB:g.diffB+y}:s.push({fromA:u,toA:m,fromB:p,toB:f,diffA:b,diffB:y})}),s}function Vi(e,t,n,o,s){if(!e.length)return t;let a=[];for(let i=0,c=0,d=0,u=0;;i++){let m=i==e.length?null:e[i],p=m?m.fromA+c:n.length,f=m?m.fromB+d:o.length;for(;u<t.length;){let y=t[u];if(y.toA+c>p||y.toB+d>f)break;a.push(y.offset(c,d)),u++}if(!m)break;let h=m.toA+c+m.diffA,g=m.toB+d+m.diffB,b=Fd(n.sliceString(p,h),o.sliceString(f,g),s);for(let y of Bd(b,n,o,p,f,Od()))a.push(y);for(c+=m.diffA,d+=m.diffB;u<t.length;){let y=t[u];if(y.fromA+c>h&&y.fromB+d>g)break;u++}}return a}const zv={scanLimit:500},zd=So.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=Yi(e))}update(e){(e.docChanged||e.viewportChanged||Wv(e.startState,e.state)||Uv(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=Yi(e.view))}},{decorations:e=>e.deco});function Wv(e,t){return e.field(tr,!1)!=t.field(tr,!1)}function Uv(e,t){return e.facet(Nr)!=t.facet(Nr)}const Gi=Cr.line({class:"cm-changedLine"}),Wd=Cr.mark({class:"cm-changedText"}),Hv=Cr.mark({tagName:"ins",class:"cm-insertedLine"}),qv=Cr.mark({tagName:"del",class:"cm-deletedLine"}),Ji=new class extends Vs{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function Kv(e,t,n,o,s,a){let i=n?e.fromA:e.fromB,c=n?e.toA:e.toB,d=0;if(i!=c){s.add(i,i,Gi),s.add(i,c,n?qv:Hv),a&&a.add(i,i,Ji);for(let u=t.iterRange(i,c-1),m=i;!u.next().done;){if(u.lineBreak){m++,s.add(m,m,Gi),a&&a.add(m,m,Ji);continue}let p=m+u.value.length;if(o)for(;d<e.changes.length;){let f=e.changes[d],h=i+(n?f.fromA:f.fromB),g=i+(n?f.toA:f.toB),b=Math.max(m,h),y=Math.min(p,g);if(b<y&&s.add(b,y,Wd),g<p)d++;else break}m=p}}}function Yi(e){let t=e.state.field(tr),{side:n,highlightChanges:o,markGutter:s,overrideChunk:a}=e.state.facet(Nr),i=n=="a",c=new uo,d=s?new uo:null,{from:u,to:m}=e.viewport;for(let p of t){if((i?p.fromA:p.fromB)>=m)break;(i?p.toA:p.toB)>u&&(!a||!a(e.state,p,c,d))&&Kv(p,e.state.doc,i,o,c,d)}return{deco:c.finish(),gutter:d&&d.finish()}}const qs=Ks.define({map:(e,t)=>t.mapPos(e)});class Vv extends Gs{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",o=>{let s=t.posAtDOM(o.target);t.dispatch({effects:qs.of(s)});let{side:a,sibling:i}=t.state.facet(Nr);i&&i().dispatch({effects:qs.of(Gv(s,t.state.field(tr),a=="a"))})}),n}ignoreEvent(t){return t instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return"collapsed-unchanged-code"}}function Gv(e,t,n){let o=0,s=0;for(let a=0;;a++){let i=a<t.length?t[a]:null;if(!i||(n?i.fromA:i.fromB)>=e)return s+(e-o);[o,s]=n?[i.toA,i.toB]:[i.toB,i.toA]}}const Jv=En.define({create(e){return Cr.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(qs)&&(e=e.update({filter:o=>o!=n.value}));return e},provide:e=>lr.decorations.from(e)});function Yv({margin:e=3,minSize:t=4}){return Jv.init(n=>Xv(n,e,t))}function Xv(e,t,n){let o=new uo,s=e.facet(Nr).side=="a",a=e.field(tr),i=1;for(let c=0;;c++){let d=c<a.length?a[c]:null,u=c?i+t:1,m=d?e.doc.lineAt(s?d.fromA:d.fromB).number-1-t:e.doc.lines,p=m-u+1;if(p>=n&&o.add(e.doc.line(u).from,e.doc.line(m).to,Cr.replace({widget:new Vv(p),block:!0})),!d)break;i=e.doc.lineAt(Math.min(e.doc.length,s?d.toA:d.toB)).number}return o.finish()}const Qv=lr.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"}}),Zv=new class extends Vs{constructor(){super(...arguments),this.elementClass="cm-deletedLineGutter"}},eb=pl.low(Ou({class:"cm-changeGutter",markers:e=>{var t;return((t=e.plugin(zd))===null||t===void 0?void 0:t.gutter)||$u.empty},widgetMarker:(e,t)=>t instanceof Ud?Zv:null}));function tb(e){var t;let n=typeof e.original=="string"?ul.of(e.original.split(/\r?\n/)):e.original,o=e.diffConfig||zv;return[pl.low(zd),sb,Qv,lr.editorAttributes.of({class:"cm-merge-b"}),$d.of((s,a)=>{let i=a.effects.find(c=>c.is(ba));return i&&(s=tn.updateA(s,i.value.doc,a.startState.doc,i.value.changes,o)),a.docChanged&&(s=tn.updateB(s,a.state.field(dn),a.newDoc,a.changes,o)),s}),Nr.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?cb:void 0,side:"b"}),dn.init(()=>n),e.gutter!==!1?eb:[],e.collapseUnchanged?Yv(e.collapseUnchanged):[],tr.init(s=>tn.build(n,s.doc,o))]}const ba=Ks.define(),dn=En.define({create:()=>ul.empty,update(e,t){for(let n of t.effects)n.is(ba)&&(e=n.value.doc);return e}}),Xi=new WeakMap;class Ud extends Gs{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 rb(e,t,n){let o=Xi.get(t.changes);if(o)return o;let s=i=>{let{highlightChanges:c,syntaxHighlightDeletions:d,syntaxHighlightDeletionsMaxLength:u,mergeControls:m}=e.facet(Nr),p=document.createElement("div");if(p.className="cm-deletedChunk",m){let L=p.appendChild(document.createElement("div"));L.className="cm-chunkButtons";let T=I=>{I.preventDefault(),nb(i,i.posAtDOM(p))},P=I=>{I.preventDefault(),ob(i,i.posAtDOM(p))};if(typeof m=="function")L.appendChild(m("accept",T)),L.appendChild(m("reject",P));else{let I=L.appendChild(document.createElement("button"));I.name="accept",I.textContent=e.phrase("Accept"),I.onmousedown=T;let z=L.appendChild(document.createElement("button"));z.name="reject",z.textContent=e.phrase("Reject"),z.onmousedown=P}}if(n||t.fromA>=t.toA)return p;let f=i.state.field(dn).sliceString(t.fromA,t.endA),h=d&&e.facet(ml),g=F(),b=t.changes,y=0,k=!1;function F(){let L=p.appendChild(document.createElement("div"));return L.className="cm-deletedLine",L.appendChild(document.createElement("del"))}function E(L,T,P){for(let I=L;I<T;){if(f.charAt(I)==`
294
+ `){g.firstChild||g.appendChild(document.createElement("br")),g=F(),I++;continue}let z=T,K=P+(k?" cm-deletedText":""),S=!1,se=f.indexOf(`
295
+ `,I);if(se>-1&&se<T&&(z=se),c&&y<b.length){let ie=Math.max(0,k?b[y].toA:b[y].fromA);ie<=z&&(z=ie,k&&y++,S=!0)}if(z>I){let ie=document.createTextNode(f.slice(I,z));if(K){let U=g.appendChild(document.createElement("span"));U.className=K,U.appendChild(ie)}else g.appendChild(ie);I=z}S&&(k=!k)}}if(h&&t.toA-t.fromA<=u){let L=h.parser.parse(f),T=0;ms(L,{style:P=>fl(e,P)},(P,I,z)=>{P>T&&E(T,P,""),E(P,I,z),T=I}),E(T,f.length,"")}else E(0,f.length,"");return g.firstChild||g.appendChild(document.createElement("br")),p},a=Cr.widget({block:!0,side:-1,widget:new Ud(s)});return Xi.set(t.changes,a),a}function nb(e,t){let{state:n}=e,o=t??n.selection.main.head,s=e.state.field(tr).find(d=>d.fromB<=o&&d.endB>=o);if(!s)return!1;let a=e.state.sliceDoc(s.fromB,Math.max(s.fromB,s.toB-1)),i=e.state.field(dn);s.fromB!=s.toB&&s.toA<=i.length&&(a+=e.state.lineBreak);let c=Fu.of({from:s.fromA,to:Math.min(i.length,s.toA),insert:a},i.length);return e.dispatch({effects:ba.of({doc:c.apply(i),changes:c}),userEvent:"accept"}),!0}function ob(e,t){let{state:n}=e,o=t??n.selection.main.head,s=n.field(tr).find(c=>c.fromB<=o&&c.endB>=o);if(!s)return!1;let i=n.field(dn).sliceString(s.fromA,Math.max(s.fromA,s.toA-1));return s.fromA!=s.toA&&s.toB<=n.doc.length&&(i+=n.lineBreak),e.dispatch({changes:{from:s.fromB,to:Math.min(n.doc.length,s.toB),insert:i},userEvent:"revert"}),!0}function Qi(e){let t=new uo;for(let n of e.field(tr)){let o=e.facet(Nr).overrideChunk&&Hd(e,n);t.add(n.fromB,n.fromB,rb(e,n,!!o))}return t.finish()}const sb=En.define({create:e=>Qi(e),update(e,t){return t.state.field(tr,!1)!=t.startState.field(tr,!1)?Qi(t.state):e},provide:e=>lr.decorations.from(e)}),Zi=new WeakMap;function Hd(e,t){let n=Zi.get(t);if(n!==void 0)return n;n=null;let o=e.field(dn),s=e.doc,a=o.lineAt(t.endA).number-o.lineAt(t.fromA).number+1,i=s.lineAt(t.endB).number-s.lineAt(t.fromB).number+1;e:if(a==i&&a<10){let c=[],d=0,u=t.fromA,m=t.fromB;for(let p of t.changes){if(p.fromA<p.toA){d+=p.toA-p.fromA;let f=o.sliceString(u+p.fromA,u+p.toA);if(/\n/.test(f))break e;c.push(Cr.widget({widget:new ab(f),side:-1}).range(m+p.fromB))}p.fromB<p.toB&&c.push(Wd.range(m+p.fromB,m+p.toB))}d<t.endA-t.fromA-a*2&&(n=c)}return Zi.set(t,n),n}class ab extends Gs{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 ib=new class extends Vs{constructor(){super(...arguments),this.elementClass="cm-inlineChangedLineGutter"}},lb=Cr.line({class:"cm-inlineChangedLine"});function cb(e,t,n,o){let s=Hd(e,t),a=0;if(!s)return!1;for(let i=e.doc.lineAt(t.fromB);;){for(o&&o.add(i.from,i.from,ib),n.add(i.from,i.from,lb);a<s.length&&s[a].to<=i.to;){let c=s[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 db=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,o=Object.getOwnPropertySymbols(e);s<o.length;s++)t.indexOf(o[s])<0&&Object.prototype.propertyIsEnumerable.call(e,o[s])&&(n[o[s]]=e[o[s]]);return n};const Bt=jo.define({combine:e=>{const t=[];for(let n of e){if(!n)continue;const{create:o,gutters:s}=n,a=db(n,["create","gutters"]);t.push(Object.assign(Object.assign({},a),{enabled:!0,gutters:s?s.filter(i=>Object.keys(i).length>0):void 0}))}return Bu(t,{enabled:t.length>0,displayText:"characters",eventHandlers:{},showOverlay:"always",gutters:[]})}}),Jt={PixelMultiplier:2,SizeRatio:4,MaxWidth:120},ub=lr.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"}}}}),Ir=Jt.PixelMultiplier*Jt.SizeRatio,pb=So.fromClass(class{constructor(e){this.view=e,this._isDragging=!1,e.state.facet(Bt).enabled&&this.create(e)}create(e){this.container=rn("div",{class:"cm-minimap-overlay-container"}),this.dom=rn("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(Bt).enabled,n=e.state.facet(Bt).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/Ir;this.dom.style.height=e+"px"}computeTop(){if(!this._isDragging&&this.dom){const{clientHeight:e,scrollHeight:t,scrollTop:n}=this.view.scrollDOM,o=t-e,s=n/Ir,a=e/Ir,i=e-a;let c=n/o;isNaN(c)&&(c=0);const d=i*c,u=Math.min(d,s);this.dom.style.top=u+"px"}}computeShowOverlay(){if(!this.container)return;const{showOverlay:e}=this.view.state.facet(Bt);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:o,scrollHeight:s,scrollTop:a}=this.view.scrollDOM,i=n.getBoundingClientRect().top,c=(t-i)*Ir,d=a/(s-o),m=(o*Ir-o)*d,p=Math.max(0,a-m);this.view.scrollDOM.scrollTop=p+c-o/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,o=t>0;this._dragStartY=e.clientY;const s=this.dom.getBoundingClientRect().height,a=this.dom.getBoundingClientRect().y,i=a+s,c=parseFloat(this.dom.style.top),d=this.view.scrollDOM.scrollTop,u=this.view.scrollDOM.clientHeight,m=this.view.scrollDOM.scrollHeight,p=d===0,f=Math.round(d)>=Math.round(m-u);if(p&&n||p&&e.clientY<a||f&&o||f&&e.clientY>i)return;const h=this.view.scrollDOM.scrollHeight,g=this.view.scrollDOM.clientHeight,b=(h-g)/Ir,y=g-g/Ir,k=c+t,F=k/y,E=(h-g)*F,L=k*Ir;this.view.scrollDOM.scrollTop=Math.max(E,L);const T=Math.min(Math.max(0,k),Math.min(y,b));this.dom.style.top=T+"px"}destroy(){this.remove()}},{eventHandlers:{scroll(){requestAnimationFrame(()=>this.computeTop())}}}),mb=[ub,pb];class wa{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 el(e){var t;if(!e.facet(Bt).enabled)return[];const n=[],o=e.doc.iterLines(),s=zu(e).iter();let a=0;for(o.next();!o.done;){const i=o.value;let c=a,d=c+i.length;for(;s.value&&s.to<c;)s.next();const{from:u,to:m}=s,p=c>=u&&c<m,f=d>u&&d<=m;if(p){let h=(t=n.pop())!==null&&t!==void 0?t:[],g=h.pop();g&&g.folded&&(g.to=m),g&&h.push(g),(!g||!g.folded)&&h.push({from:u,to:m,folded:!0}),f||h.push({from:m,to:d,folded:!1}),n.push(h)}else f?n.push([{from:c,to:u,folded:!1},{from:u,to:m,folded:!0}]):n.push([{from:c,to:d,folded:!1}]);a=d+1,o.next()}return n}const un=En.define({create:e=>el(e),update:(e,t)=>Lo([t])||t.docChanged?el(t.state):e});function Lo(e){return e.find(t=>t.effects.find(n=>n.is(Wu)||n.is(Uu)))}class fb extends wa{constructor(t){super(t),this.count=void 0}shouldUpdate(t){if(!t.state.facet(Bt).enabled)return!1;if(t.docChanged)return!0;for(const n of t.transactions)for(const o of n.effects)if(o.is(Hu))return!0;return!!(Lo(t.transactions)||this.count===void 0)}update(t){if(!this.shouldUpdate(t))return;this.map.clear();const n=t.state.field(un);this.count=qu(t.state),Ku(t.state,(o,s,a)=>{const i=this.findLine(s,n),c=this.findLine(a,n);let d=o.severity;for(let u=i;u<=c;u++){const m=this.get(u);m&&(d=[d,m].sort(this.sort.bind(this)).slice(0,1)[0]),this.set(u,d)}})}drawLine(t,n){const{context:o,lineHeight:s,offsetX:a,offsetY:i}=t,c=this.get(n);c&&(o.globalAlpha=.65,o.beginPath(),o.rect(a,i,o.canvas.width-a,s),o.fillStyle=this.color(c),o.fill())}findLine(t,n){return n.findIndex(s=>{const a=s.slice(0,1)[0],i=s.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 hb(e){return new fb(e)}class gb extends wa{constructor(t){super(t),this.getDrawInfo(),this._themeClasses=t.dom.classList.value}shouldUpdate(t){return t.state.facet(Bt).enabled?!!(t.docChanged||t.selectionSet||this._themeClasses!==this.view.dom.classList.value||Lo(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 o=0;for(const[s,a]of t.state.field(un).entries()){const i=[];let c=0;for(const u of a){do{if(o>=n.length||u.to<n[o].from)continue;if(n[o].from===n[o].to){o++;continue}const m=n[o],p={from:c+Math.max(u.from,m.from)-u.from,to:c+Math.min(u.to,m.to)-u.from,extends:m.to>u.to},f=i.slice(-1)[0];if(f&&f.to===p.from){let{to:h}=p;u.folded&&p.extends?h=p.from+1:u.folded&&!p.extends&&(h=f.to),i[i.length-1]=Object.assign(Object.assign({},f),{to:h,extends:p.extends})}else u.folded||i.push(p);if(p.extends)break;o++}while(o<n.length&&u.to>=n[o].from);c+=u.folded?1:u.to-u.from}if(i.length===0)continue;const d=s+1;this.map.set(d,i)}}drawLine(t,n){let{context:o,lineHeight:s,charWidth:a,offsetX:i,offsetY:c}=t;const d=this.get(n);if(d)for(const u of d){const m=i+u.from*a,p=(u.to-u.from)*a,f=o.canvas.width-m;u.extends&&(o.globalAlpha=.65,o.beginPath(),o.rect(m,c,f,s),o.fillStyle=this.getDrawInfo().backgroundColor,o.fill()),o.globalAlpha=1,o.beginPath(),o.rect(m,c,p,s),o.fillStyle=this.getDrawInfo().backgroundColor,o.fill()}}getDrawInfo(){if(this._drawInfo)return this._drawInfo;const t=document.createElement("span");t.setAttribute("class","cm-selectionBackground"),this.view.dom.appendChild(t);const o={backgroundColor:window.getComputedStyle(t).backgroundColor};return this._drawInfo=o,this.view.dom.removeChild(t),o}}function xb(e){return new gb(e)}class yb extends wa{constructor(t){super(t),this._fontInfoMap=new Map,this._themeClasses=new Set(t.dom.classList.values()),t.state.facet(Bt).enabled&&this.updateImpl(t.state)}shouldUpdate(t){return!!(t.docChanged||t.state.facet(Bt)!==t.startState.facet(Bt)||this.themeChanged()||Lo(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 o;this.map.clear(),this._displayText=t.facet(Bt).displayText,this.themeChanged()&&this._fontInfoMap.clear();let s;if(this._previousTree&&n){const p=Da.addTree(this._previousTree),f=[];n.iterChangedRanges((h,g,b,y)=>f.push({fromA:h,toA:g,fromB:b,toB:y})),s=Da.applyChanges(p,f)}const a=t.doc.toString(),i=(o=t.facet(ml))===null||o===void 0?void 0:o.parser,c=i?i.parse(a,s):void 0;this._previousTree=c;const d={style:p=>fl(t,p)};let u=[];if(c){const p=t.doc.lineAt(this.view.viewport.from).number,f=t.doc.lineAt(this.view.viewport.to).number,h=f-p,g=p/(t.doc.lines-h),{SizeRatio:b,PixelMultiplier:y}=Jt,k=h*b*y,F=g*k,E=Math.max(1,Math.floor(p-F)),L=Math.min(f+Math.floor(k-F),t.doc.lines);ms(c,d,(T,P,I)=>{u.push({from:T,to:P,tags:I})},t.doc.line(E).from,t.doc.line(L).to)}this.updateMapImpl(t,u),u=[];const m=()=>{c&&(ms(c,d,(p,f,h)=>{u.push({from:p,to:f,tags:h})}),this.updateMapImpl(t,u),this._highlightingCallbackId=void 0)};this._highlightingCallbackId=typeof window.requestIdleCallback<"u"?requestIdleCallback(m):setTimeout(m)}updateMapImpl(t,n){this.map.clear();const o=t.doc.toString(),s=n.values();let a=s.next();for(const[i,c]of t.field(un).entries()){const d=[];for(const m of c){if(m.from===m.to)continue;if(m.folded){d.push({text:"…",tags:""});continue}let p=m.from;for(;!a.done&&a.value.from<m.to;){const{from:f,to:h,tags:g}=a.value;if(h<p){a=s.next();continue}f>p&&d.push({text:o.slice(p,f),tags:""});const b=Math.max(f,m.from),y=Math.min(h,m.to);if(d.push({text:o.slice(b,y),tags:g}),p=y,h>y)break;a=s.next()}p!==m.to&&d.push({text:o.slice(p,m.to),tags:""})}const u=i+1;this.map.set(u,d)}}measure(t){const{color:n,font:o,lineHeight:s}=this.getFontInfo("");return t.textBaseline="ideographic",t.fillStyle=n,t.font=o,{charWidth:t.measureText("_").width,lineHeight:s}}beforeDraw(){this._fontInfoMap.clear()}drawLine(t,n){const o=this.get(n);if(!o)return;let{context:s,charWidth:a,lineHeight:i,offsetX:c,offsetY:d}=t,u;s.textBaseline="ideographic";for(const m of o){const p=this.getFontInfo(m.tags);switch((!u||u.color!==p.color)&&(s.fillStyle=p.color),(!u||u.font!==p.font)&&(s.font=p.font),u=p,i=Math.max(i,p.lineHeight),this._displayText){case"characters":{s.fillText(m.text,c,d+i),c+=m.text.length*a;break}case"blocks":{const f=/\S+/g;let h;for(;(h=f.exec(m.text))!==null;){const g=c+h.index*a;let b=(f.lastIndex-h.index)*a;if(g>s.canvas.width)break;g+b>s.canvas.width&&(b=s.canvas.width-g);const y=2/Jt.SizeRatio,k=i-y;s.fillStyle=p.color,s.globalAlpha=.65,s.beginPath(),s.rect(g,d,b,k),s.fill()}c+=m.text.length*a;break}}}}getFontInfo(t){const n=this._fontInfoMap.get(t);if(n)return n;const o=rn("span",{class:t}),s=rn("div",{class:"cm-line",style:"display: none"},o);this.view.contentDOM.appendChild(s);const a=window.getComputedStyle(o),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(s),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 o=!0;return t.forEach(s=>{n.has(s)||(o=!1)}),!o}}function vb(e){return new yb(e)}const qd=4;function bb(e,t,n){const o=e[n];o&&(t.context.fillStyle=o,t.context.globalAlpha=1,t.context.beginPath(),t.context.rect(t.offsetX,t.offsetY,qd,t.lineHeight),t.context.fill())}const wb=lr.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"}}),tl=6,kb=So.fromClass(class{constructor(e){this.view=e,this.text=vb(e),this.selection=xb(e),this.diagnostic=hb(e),e.state.facet(wn)&&this.create(e)}create(e){const t=e.state.facet(wn);if(!t)throw Error("Expected nonnull");this.inner=rn("div",{class:"cm-minimap-inner"}),this.canvas=rn("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(Bt).eventHandlers){const o=this.view.state.facet(Bt).eventHandlers[n];o&&this.dom.addEventListener(n,s=>o(s,this.view))}}remove(){this.dom&&this.dom.remove()}update(e){const t=e.startState.facet(wn),n=e.state.facet(wn);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*tl){const t=e/(Jt.MaxWidth*tl);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:o}=this.text.measure(t);let{startIndex:s,endIndex:a,offsetY:i}=this.canvasStartAndEndIndex(t,o);const c=this.view.state.facet(Bt).gutters;for(let d=s;d<a;d++){const u=this.view.state.field(un);if(d>=u.length)break;const m={offsetX:0,offsetY:i,context:t,lineHeight:o,charWidth:n};if(c.length){m.offsetX+=2;for(let p of c)bb(p,m,d+1),m.offsetX+=qd;m.offsetX+=2}this.text.drawLine(m,d+1),this.selection.drawLine(m,d+1),this.diagnostic.drawLine(m,d+1),i+=o}t.restore()}canvasStartAndEndIndex(e,t){let{top:n,bottom:o}=this.view.documentPadding;n/=Jt.SizeRatio,o/=Jt.SizeRatio;const s=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(un).length,m=n+o+u*t,p=Math.max(0,d*(m-s)),f=Math.max(0,n-p),h=Math.round(Math.max(0,p-n)/t),g=Math.round((s-f)/t);return{startIndex:h,endIndex:h+g,offsetY:f}}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=>lr.scrollMargins.of(t=>{var n;const o=(n=t.plugin(e))===null||n===void 0?void 0:n.getWidth();return o?{right:o}:null})}),wn=jo.define({combine:e=>{var t;return(t=e.find(n=>n!==null))!==null&&t!==void 0?t:null},enables:e=>[[Bt.compute([e],t=>t.facet(e)),wb,un,kb,mb]]});function rl({file:e,onClose:t,projectPath:n,isSidebar:o=!1,isExpanded:s=!1,onToggleExpand:a=null}){const{t:i}=St("codeEditor"),[c,d]=l.useState(""),[u,m]=l.useState(!0),[p,f]=l.useState(!1),[h,g]=l.useState(!1),[b,y]=l.useState(()=>{const O=localStorage.getItem("codeEditorTheme");return O?O==="dark":!0}),[k,F]=l.useState(!1),[E,L]=l.useState(!!e.diffInfo),[T,P]=l.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[I,z]=l.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[K,S]=l.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[se,ie]=l.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),U=l.useRef(null),Q=l.useMemo(()=>{if(!e.diffInfo||!E||!I)return[];const O={};return[wn.compute(["doc"],Z=>{const be=us(Z)?.chunks||[];return Object.keys(O).forEach(ye=>delete O[ye]),be.forEach(ye=>{const ke=Z.doc.lineAt(ye.fromB).number,ne=Z.doc.lineAt(Math.min(ye.toB,Z.doc.length)).number;for(let Se=ke;Se<=ne;Se++)O[Se]=b?"rgba(34, 197, 94, 0.8)":"rgba(34, 197, 94, 1)"}),{create:()=>({dom:document.createElement("div")}),displayText:"blocks",showOverlay:"always",gutters:[O]}})]},[e.diffInfo,E,I,b]),V=l.useMemo(()=>!e.diffInfo||!E?[]:[So.fromClass(class{constructor(O){setTimeout(()=>{const ae=us(O.state)?.chunks||[];if(ae.length>0){const be=ae[0];O.dispatch({effects:lr.scrollIntoView(be.fromB,{y:"center"})})}},100)}update(){}destroy(){}})],[e.diffInfo,E]),le=l.useMemo(()=>{const O=Z=>{const ae=document.createElement("div");ae.className="cm-editor-toolbar-panel";let be=0;const ye=()=>{const ke=e.diffInfo&&E,Se=(ke?us(Z.state):null)?.chunks||[],We=Se.length;let ve='<div style="display: flex; align-items: center; justify-content: space-between; width: 100%;">';if(ve+='<div style="display: flex; align-items: center; gap: 8px;">',ke&&(ve+=`
296
+ <span style="font-weight: 500;">${We>0?`${be+1}/${We}`:"0"} ${i("toolbar.changes")}</span>
297
+ <button class="cm-diff-nav-btn cm-diff-nav-prev" title="${i("toolbar.previousChange")}" ${We===0?"disabled":""}>
298
+ <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
299
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 15l7-7 7 7" />
300
+ </svg>
301
+ </button>
302
+ <button class="cm-diff-nav-btn cm-diff-nav-next" title="${i("toolbar.nextChange")}" ${We===0?"disabled":""}>
303
+ <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
304
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
305
+ </svg>
306
+ </button>
307
+ `),ve+="</div>",ve+='<div style="display: flex; align-items: center; gap: 4px;">',e.diffInfo&&(ve+=`
308
+ <button class="cm-toolbar-btn cm-toggle-diff-btn" title="${i(E?"toolbar.hideDiff":"toolbar.showDiff")}">
309
+ <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
310
+ ${E?'<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" />'}
311
+ </svg>
312
+ </button>
313
+ `),ve+=`
314
+ <button class="cm-toolbar-btn cm-settings-btn" title="${i("toolbar.settings")}">
315
+ <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
316
+ <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" />
317
+ </svg>
318
+ </button>
319
+ `,o&&a&&(ve+=`
320
+ <button class="cm-toolbar-btn cm-expand-btn" title="${i(s?"toolbar.collapse":"toolbar.expand")}">
321
+ <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
322
+ ${s?'<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" />'}
323
+ </svg>
324
+ </button>
325
+ `),ve+="</div>",ve+="</div>",ae.innerHTML=ve,ke){const $e=ae.querySelector(".cm-diff-nav-prev"),je=ae.querySelector(".cm-diff-nav-next");$e?.addEventListener("click",()=>{if(Se.length===0)return;be=be>0?be-1:Se.length-1;const Te=Se[be];Te&&Z.dispatch({effects:lr.scrollIntoView(Te.fromB,{y:"center"})}),ye()}),je?.addEventListener("click",()=>{if(Se.length===0)return;be=be<Se.length-1?be+1:0;const Te=Se[be];Te&&Z.dispatch({effects:lr.scrollIntoView(Te.fromB,{y:"center"})}),ye()})}e.diffInfo&&ae.querySelector(".cm-toggle-diff-btn")?.addEventListener("click",()=>{L(!E)}),ae.querySelector(".cm-settings-btn")?.addEventListener("click",()=>{window.openSettings&&window.openSettings("appearance")}),o&&a&&ae.querySelector(".cm-expand-btn")?.addEventListener("click",()=>{a()})};return ye(),{top:!0,dom:ae,update:ye}};return[Vu.of(O)]},[e.diffInfo,E,o,s,a]),ce=O=>{const Z=O.split(".").pop()?.toLowerCase();switch(Z){case"js":case"jsx":case"ts":case"tsx":return[tp({jsx:!0,typescript:Z.includes("ts")})];case"py":return[ep()];case"html":case"htm":return[Zu()];case"css":case"scss":case"less":return[Qu()];case"json":return[Xu()];case"md":case"markdown":return[Yu()];default:return[]}};l.useEffect(()=>{(async()=>{try{if(m(!0),e.diffInfo&&e.diffInfo.new_string!==void 0&&e.diffInfo.old_string!==void 0){d(e.diffInfo.new_string),m(!1);return}const Z=await st.readFile(e.projectName,e.path);if(!Z.ok)throw new Error(`Failed to load file: ${Z.status} ${Z.statusText}`);const ae=await Z.json();d(ae.content)}catch(Z){console.error("Error loading file:",Z),d(`// Error loading file: ${Z.message}
326
+ // File: ${e.name}
327
+ // Path: ${e.path}`)}finally{m(!1)}})()},[e,n]);const ue=async()=>{f(!0);try{console.log("Saving file:",{projectName:e.projectName,path:e.path,contentLength:c?.length});const O=await st.saveFile(e.projectName,e.path,c);if(console.log("Save response:",{status:O.status,ok:O.ok,contentType:O.headers.get("content-type")}),!O.ok){const ae=O.headers.get("content-type");if(ae&&ae.includes("application/json")){const be=await O.json();throw new Error(be.error||`Save failed: ${O.status}`)}else{const be=await O.text();throw console.error("Non-JSON error response:",be),new Error(`Save failed: ${O.status} ${O.statusText}`)}}const Z=await O.json();console.log("Save successful:",Z),F(!0),setTimeout(()=>F(!1),2e3)}catch(O){console.error("Error saving file:",O),alert(`Error saving file: ${O.message}`)}finally{f(!1)}},G=()=>{const O=new Blob([c],{type:"text/plain"}),Z=URL.createObjectURL(O),ae=document.createElement("a");ae.href=Z,ae.download=e.name,document.body.appendChild(ae),ae.click(),document.body.removeChild(ae),URL.revokeObjectURL(Z)},Ae=()=>{g(!h)};return l.useEffect(()=>{localStorage.setItem("codeEditorTheme",b?"dark":"light")},[b]),l.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",T.toString())},[T]),l.useEffect(()=>{const O=()=>{const Z=localStorage.getItem("codeEditorTheme");Z&&y(Z==="dark");const ae=localStorage.getItem("codeEditorWordWrap");ae!==null&&P(ae==="true");const be=localStorage.getItem("codeEditorShowMinimap");be!==null&&z(be!=="false");const ye=localStorage.getItem("codeEditorLineNumbers");ye!==null&&S(ye!=="false");const ke=localStorage.getItem("codeEditorFontSize");ke&&ie(ke)};return window.addEventListener("storage",O),window.addEventListener("codeEditorSettingsChanged",O),()=>{window.removeEventListener("storage",O),window.removeEventListener("codeEditorSettingsChanged",O)}},[]),l.useEffect(()=>{const O=Z=>{(Z.ctrlKey||Z.metaKey)&&(Z.key==="s"?(Z.preventDefault(),ue()):Z.key==="Escape"&&(Z.preventDefault(),t()))};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[c]),u?r.jsxs(r.Fragment,{children:[r.jsx("style",{children:`
328
+ .code-editor-loading {
329
+ background-color: ${b?"#111827":"#ffffff"} !important;
330
+ }
331
+ .code-editor-loading:hover {
332
+ background-color: ${b?"#111827":"#ffffff"} !important;
333
+ }
334
+ `}),o?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:`
335
+ /* Light background for full line changes */
336
+ .cm-deletedChunk {
337
+ background-color: ${b?"rgba(239, 68, 68, 0.15)":"rgba(255, 235, 235, 1)"} !important;
338
+ border-left: 3px solid ${b?"rgba(239, 68, 68, 0.6)":"rgb(239, 68, 68)"} !important;
339
+ padding-left: 4px !important;
340
+ }
341
+
342
+ .cm-insertedChunk {
343
+ background-color: ${b?"rgba(34, 197, 94, 0.15)":"rgba(230, 255, 237, 1)"} !important;
344
+ border-left: 3px solid ${b?"rgba(34, 197, 94, 0.6)":"rgb(34, 197, 94)"} !important;
345
+ padding-left: 4px !important;
346
+ }
347
+
348
+ /* Override linear-gradient underline and use solid darker background for partial changes */
349
+ .cm-editor.cm-merge-b .cm-changedText {
350
+ background: ${b?"rgba(34, 197, 94, 0.4)":"rgba(34, 197, 94, 0.3)"} !important;
351
+ padding-top: 2px !important;
352
+ padding-bottom: 2px !important;
353
+ margin-top: -2px !important;
354
+ margin-bottom: -2px !important;
355
+ }
356
+
357
+ .cm-editor .cm-deletedChunk .cm-changedText {
358
+ background: ${b?"rgba(239, 68, 68, 0.4)":"rgba(239, 68, 68, 0.3)"} !important;
359
+ padding-top: 2px !important;
360
+ padding-bottom: 2px !important;
361
+ margin-top: -2px !important;
362
+ margin-bottom: -2px !important;
363
+ }
364
+
365
+ /* Minimap gutter styling */
366
+ .cm-gutter.cm-gutter-minimap {
367
+ background-color: ${b?"#1e1e1e":"#f5f5f5"};
368
+ }
369
+
370
+ /* Editor toolbar panel styling */
371
+ .cm-editor-toolbar-panel {
372
+ padding: 8px 12px;
373
+ background-color: ${b?"#1f2937":"#ffffff"};
374
+ border-bottom: 1px solid ${b?"#374151":"#e5e7eb"};
375
+ color: ${b?"#d1d5db":"#374151"};
376
+ font-size: 14px;
377
+ }
378
+
379
+ .cm-diff-nav-btn,
380
+ .cm-toolbar-btn {
381
+ padding: 4px;
382
+ background: transparent;
383
+ border: none;
384
+ cursor: pointer;
385
+ border-radius: 4px;
386
+ display: inline-flex;
387
+ align-items: center;
388
+ justify-content: center;
389
+ color: inherit;
390
+ transition: background-color 0.2s;
391
+ }
392
+
393
+ .cm-diff-nav-btn:hover,
394
+ .cm-toolbar-btn:hover {
395
+ background-color: ${b?"#374151":"#f3f4f6"};
396
+ }
397
+
398
+ .cm-diff-nav-btn:disabled {
399
+ opacity: 0.5;
400
+ cursor: not-allowed;
401
+ }
402
+ `}),r.jsx("div",{className:o?"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 ${h?"md:p-0":""}`,children:r.jsxs("div",{className:o?"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"+(h?" 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:G,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(ys,{className:"w-5 h-5 md:w-4 md:h-4"})}),r.jsx("button",{onClick:ue,disabled:p,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 ${k?"bg-green-600 hover:bg-green-700":"bg-primary hover:bg-primary/90"}`,children:k?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(qm,{className:"w-5 h-5 md:w-4 md:h-4"}),r.jsx("span",{className:"hidden sm:inline",children:i(p?"actions.saving":"actions.save")})]})}),!o&&r.jsx("button",{onClick:Ae,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(h?"actions.exitFullscreen":"actions.fullscreen"),children:h?r.jsx(Om,{className:"w-4 h-4"}):r.jsx(Sl,{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(Ht,{className:"w-6 h-6 md:w-4 md:h-4"})})]})]}),r.jsx("div",{className:"flex-1 overflow-hidden",children:r.jsx(Gu,{ref:U,value:c,onChange:d,extensions:[...ce(e.name),...le,...e.diffInfo&&E&&e.diffInfo.old_string!==void 0?[tb({original:e.diffInfo.old_string,mergeControls:!1,highlightChanges:!0,syntaxHighlightDeletions:!1,gutter:!0}),...Q,...V]:[],...T?[lr.lineWrapping]:[]],theme:b?Ju:void 0,height:"100%",style:{fontSize:`${se}px`,height:"100%"},basicSetup:{lineNumbers:K,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(`
403
+ `).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 jb=Vp(),Sb=Gp(),Nb=Jp(),ps={exports:{}},nl;function Cb(){return nl||(nl=1,function(e,t){(function(n,o){e.exports=o()})(self,()=>(()=>{var n={6:(i,c)=>{function d(m){try{const p=new URL(m),f=p.password&&p.username?`${p.protocol}//${p.username}:${p.password}@${p.host}`:p.username?`${p.protocol}//${p.username}@${p.host}`:`${p.protocol}//${p.host}`;return m.toLocaleLowerCase().startsWith(f.toLocaleLowerCase())}catch{return!1}}Object.defineProperty(c,"__esModule",{value:!0}),c.LinkComputer=c.WebLinkProvider=void 0,c.WebLinkProvider=class{constructor(m,p,f,h={}){this._terminal=m,this._regex=p,this._handler=f,this._options=h}provideLinks(m,p){const f=u.computeLink(m,this._regex,this._terminal,this._handler);p(this._addCallbacks(f))}_addCallbacks(m){return m.map(p=>(p.leave=this._options.leave,p.hover=(f,h)=>{if(this._options.hover){const{range:g}=p;this._options.hover(f,h,g)}},p))}};class u{static computeLink(p,f,h,g){const b=new RegExp(f.source,(f.flags||"")+"g"),[y,k]=u._getWindowedLineStrings(p-1,h),F=y.join("");let E;const L=[];for(;E=b.exec(F);){const T=E[0];if(!d(T))continue;const[P,I]=u._mapStrIdx(h,k,0,E.index),[z,K]=u._mapStrIdx(h,P,I,T.length);if(P===-1||I===-1||z===-1||K===-1)continue;const S={start:{x:I+1,y:P+1},end:{x:K,y:z+1}};L.push({range:S,text:T,activate:g})}return L}static _getWindowedLineStrings(p,f){let h,g=p,b=p,y=0,k="";const F=[];if(h=f.buffer.active.getLine(p)){const E=h.translateToString(!0);if(h.isWrapped&&E[0]!==" "){for(y=0;(h=f.buffer.active.getLine(--g))&&y<2048&&(k=h.translateToString(!0),y+=k.length,F.push(k),h.isWrapped&&k.indexOf(" ")===-1););F.reverse()}for(F.push(E),y=0;(h=f.buffer.active.getLine(++b))&&h.isWrapped&&y<2048&&(k=h.translateToString(!0),y+=k.length,F.push(k),k.indexOf(" ")===-1););}return[F,g]}static _mapStrIdx(p,f,h,g){const b=p.buffer.active,y=b.getNullCell();let k=h;for(;g;){const F=b.getLine(f);if(!F)return[-1,-1];for(let E=k;E<F.length;++E){F.getCell(E,y);const L=y.getChars();if(y.getWidth()&&(g-=L.length||1,E===F.length-1&&L==="")){const T=b.getLine(f+1);T&&T.isWrapped&&(T.getCell(0,y),y.getWidth()===2&&(g+=1))}if(g<0)return[f,E]}f++,k=0}return[f,k]}}c.LinkComputer=u}},o={};function s(i){var c=o[i];if(c!==void 0)return c.exports;var d=o[i]={exports:{}};return n[i](d,d.exports,s),d.exports}var a={};return(()=>{var i=a;Object.defineProperty(i,"__esModule",{value:!0}),i.WebLinksAddon=void 0;const c=s(6),d=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function u(m,p){const f=window.open();if(f){try{f.opener=null}catch{}f.location.href=p}else console.warn("Opening link blocked as opener could not be cleared")}i.WebLinksAddon=class{constructor(m=u,p={}){this._handler=m,this._options=p}activate(m){this._terminal=m;const p=this._options,f=p.urlRegex||d;this._linkProvider=this._terminal.registerLinkProvider(new c.WebLinkProvider(this._terminal,f,this._handler,p))}dispose(){this._linkProvider?.dispose()}}})(),a})())}(ps)),ps.exports}var Eb=Cb();const Ab=`
404
+ .xterm .xterm-screen {
405
+ outline: none !important;
406
+ }
407
+ .xterm:focus .xterm-screen {
408
+ outline: none !important;
409
+ }
410
+ .xterm-screen:focus {
411
+ outline: none !important;
412
+ }
413
+ `;if(typeof document<"u"){const e=document.createElement("style");e.type="text/css",e.innerText=Ab,document.head.appendChild(e)}function _b({selectedProject:e,selectedSession:t,initialCommand:n,isPlainShell:o=!1,onProcessComplete:s,minimal:a=!1,autoConnect:i=!1}){const{t:c}=St("chat"),d=l.useRef(null),u=l.useRef(null),m=l.useRef(null),p=l.useRef(null),[f,h]=l.useState(!1),[g,b]=l.useState(!1),[y,k]=l.useState(!1),[F,E]=l.useState(null),[L,T]=l.useState(!1),P=l.useRef(e),I=l.useRef(t),z=l.useRef(n),K=l.useRef(o),S=l.useRef(s);l.useEffect(()=>{P.current=e,I.current=t,z.current=n,K.current=o,S.current=s});const se=l.useCallback(async()=>{if(!(L||f))try{let ue;if(!Bg){const G=localStorage.getItem("auth-token");if(!G){console.error("No authentication token found for Shell WebSocket connection");return}ue=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/shell?token=${encodeURIComponent(G)}`}p.current=new WebSocket(ue),p.current.onopen=()=>{h(!0),T(!1),setTimeout(()=>{m.current&&u.current&&(m.current.fit(),p.current.send(JSON.stringify({type:"init",projectPath:P.current.fullPath||P.current.path,sessionId:K.current?null:I.current?.id,hasSession:K.current?!1:!!I.current,provider:K.current?"plain-shell":I.current?.__provider||"claude",cols:u.current.cols,rows:u.current.rows,initialCommand:z.current,isPlainShell:K.current})))},100)},p.current.onmessage=G=>{try{const Ae=JSON.parse(G.data);if(Ae.type==="output"){let O=Ae.data;if(K.current&&S.current){const Z=O.replace(/\x1b\[[0-9;]*m/g,"");if(Z.includes("Process exited with code 0"))S.current(0);else if(Z.match(/Process exited with code (\d+)/)){const ae=parseInt(Z.match(/Process exited with code (\d+)/)[1]);ae!==0&&S.current(ae)}}u.current&&u.current.write(O)}else Ae.type==="url_open"&&window.open(Ae.url,"_blank")}catch(Ae){console.error("[Shell] Error handling WebSocket message:",Ae,G.data)}},p.current.onclose=G=>{h(!1),T(!1),u.current&&(u.current.clear(),u.current.write("\x1B[2J\x1B[H"))},p.current.onerror=G=>{h(!1),T(!1)}}catch{h(!1),T(!1)}},[L,f]),ie=l.useCallback(()=>{!g||f||L||(T(!0),se())},[g,f,L,se]),U=l.useCallback(()=>{p.current&&(p.current.close(),p.current=null),u.current&&(u.current.clear(),u.current.write("\x1B[2J\x1B[H")),h(!1),T(!1)},[]),Q=l.useMemo(()=>t?t.summary||t.name||"New Session":null,[t]),V=l.useMemo(()=>Q?Q.slice(0,30):null,[Q]),le=l.useMemo(()=>Q?Q.slice(0,50):null,[Q]),ce=()=>{k(!0),p.current&&(p.current.close(),p.current=null),u.current&&(u.current.dispose(),u.current=null,m.current=null),h(!1),b(!1),setTimeout(()=>{k(!1)},200)};return l.useEffect(()=>{const ue=t?.id||null;F!==null&&F!==ue&&g&&U(),E(ue)},[t?.id,g,U]),l.useEffect(()=>{if(!d.current||!e||y||u.current)return;u.current=new jb.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"]}}),m.current=new Sb.FitAddon;const ue=new Nb.WebglAddon,G=new Eb.WebLinksAddon;u.current.loadAddon(m.current),u.current.loadAddon(G);try{u.current.loadAddon(ue)}catch{console.warn("[Shell] WebGL renderer unavailable, using Canvas fallback")}u.current.open(d.current),u.current.attachCustomKeyEventHandler(O=>(O.ctrlKey||O.metaKey)&&O.key==="c"&&u.current.hasSelection()?(document.execCommand("copy"),!1):(O.ctrlKey||O.metaKey)&&O.key==="v"?(navigator.clipboard.readText().then(Z=>{p.current&&p.current.readyState===WebSocket.OPEN&&p.current.send(JSON.stringify({type:"input",data:Z}))}).catch(()=>{}),!1):!0),setTimeout(()=>{m.current&&(m.current.fit(),u.current&&p.current&&p.current.readyState===WebSocket.OPEN&&p.current.send(JSON.stringify({type:"resize",cols:u.current.cols,rows:u.current.rows})))},100),b(!0),u.current.onData(O=>{p.current&&p.current.readyState===WebSocket.OPEN&&p.current.send(JSON.stringify({type:"input",data:O}))});const Ae=new ResizeObserver(()=>{m.current&&u.current&&setTimeout(()=>{m.current.fit(),p.current&&p.current.readyState===WebSocket.OPEN&&p.current.send(JSON.stringify({type:"resize",cols:u.current.cols,rows:u.current.rows}))},50)});return d.current&&Ae.observe(d.current),()=>{Ae.disconnect(),p.current&&(p.current.readyState===WebSocket.OPEN||p.current.readyState===WebSocket.CONNECTING)&&p.current.close(),p.current=null,u.current&&(u.current.dispose(),u.current=null)}},[e?.path||e?.fullPath,y]),l.useEffect(()=>{!i||!g||L||f||ie()},[i,g,L,f,ie]),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 ${f?"bg-green-500":"bg-red-500"}`}),t&&r.jsxs("span",{className:"text-xs text-primary/80",children:["(",V,"...)"]}),!t&&r.jsx("span",{className:"text-xs text-gray-400",children:c("shell.status.newSession")}),!g&&r.jsx("span",{className:"text-xs text-yellow-400",children:c("shell.status.initializing")}),y&&r.jsx("span",{className:"text-xs text-primary",children:c("shell.status.restarting")})]}),r.jsxs("div",{className:"flex items-center space-x-3",children:[f&&r.jsxs("button",{onClick:U,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:ce,disabled:y||f,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"}}),!g&&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")})}),g&&!f&&!L&&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:ie,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:o?c("shell.runCommand",{command:n||c("shell.defaultCommand"),projectName:e.displayName}):t?c("shell.resumeSession",{displayName:le}):c("shell.startSession")})]})}),L&&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:o?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 Kd({project:e,session:t=null,command:n=null,isPlainShell:o=null,autoConnect:s=!0,onComplete:a=null,onClose:i=null,title:c=null,className:d="",showHeader:u=!0,compact:m=!1,minimal:p=!1}){const[f,h]=l.useState(!1),g=o!==null?o:n!==null,b=l.useCallback(y=>{h(!0),a&&a(y)},[a]);return e?r.jsxs("div",{className:`h-full w-full flex flex-col ${d}`,children:[!p&&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}),f&&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(_b,{selectedProject:e,selectedSession:t,initialCommand:n,isPlainShell:g,onProcessComplete:b,minimal:p,autoConnect:p?!0:s})})]}):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 Ib(e,t){const n=new FormData,o=`recording_${Date.now()}.webm`,s=new File([e],o,{type:e.type});n.append("audio",s);const a=window.localStorage.getItem("whisperMode")||"default";n.append("mode",a);try{const i=await st.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 Tb({onTranscript:e,className:t=""}){const[n,o]=l.useState("idle"),[s,a]=l.useState(null),[i,c]=l.useState(!0),d=l.useRef(null),u=l.useRef(null),m=l.useRef([]),p=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 f=async()=>{try{if(console.log("Starting recording..."),a(null),m.current=[],!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new Error("Microphone access not available. Please use HTTPS or a supported browser.");const E=await navigator.mediaDevices.getUserMedia({audio:!0});u.current=E;const L=MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4",T=new MediaRecorder(E,{mimeType:L});d.current=T,T.ondataavailable=P=>{P.data.size>0&&m.current.push(P.data)},T.onstop=async()=>{console.log("Recording stopped, creating blob...");const P=new Blob(m.current,{type:L});u.current&&(u.current.getTracks().forEach(S=>S.stop()),u.current=null),o("transcribing");const I=window.localStorage.getItem("whisperMode")||"default",z=I==="prompt"||I==="vibe"||I==="instructions"||I==="architect";let K;z&&(K=setTimeout(()=>{o("processing")},2e3));try{const S=await Ib(P);S&&e&&e(S)}catch(S){console.error("Transcription error:",S),a(S.message)}finally{K&&clearTimeout(K),o("idle")}},T.start(),o("recording"),console.log("Recording started successfully")}catch(E){console.error("Failed to start recording:",E);let L="Microphone access failed";E.name==="NotAllowedError"?L="Microphone access denied. Please allow microphone permissions.":E.name==="NotFoundError"?L="No microphone found. Please check your audio devices.":E.name==="NotSupportedError"?L="Microphone not supported by this browser.":E.name==="NotReadableError"?L="Microphone is being used by another application.":E.message.includes("HTTPS")&&(L=E.message),a(L),o("idle")}},h=()=>{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(E=>E.stop()),u.current=null),o("idle"))},g=E=>{if(E&&(E.preventDefault(),E.stopPropagation()),!i)return;const L=Date.now();if(L-p.current<300){console.log("Ignoring rapid tap");return}p.current=L,console.log("Button clicked, current state:",n),n==="idle"?f():n==="recording"&&h()};l.useEffect(()=>()=>{u.current&&u.current.getTracks().forEach(E=>E.stop())},[]);const b=()=>{if(!i)return{icon:r.jsx(co,{className:"w-5 h-5"}),className:"bg-gray-400 cursor-not-allowed",disabled:!0};switch(n){case"recording":return{icon:r.jsx(co,{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($t,{className:"w-5 h-5 animate-spin"}),className:"bg-primary hover:bg-primary/90",disabled:!0};case"processing":return{icon:r.jsx(vl,{className:"w-5 h-5 animate-pulse"}),className:"bg-purple-500 hover:bg-purple-600",disabled:!0};default:return{icon:r.jsx(co,{className:"w-5 h-5"}),className:"bg-gray-700 hover:bg-gray-600",disabled:!1}}},{icon:y,className:k,disabled:F}=b();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:`
414
+ flex items-center justify-center
415
+ w-12 h-12 rounded-full
416
+ text-white transition-all duration-200
417
+ focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-ring
418
+ dark:ring-offset-gray-800
419
+ touch-action-manipulation
420
+ ${F?"cursor-not-allowed opacity-75":"cursor-pointer"}
421
+ ${n==="recording"?"animate-pulse":""}
422
+ hover:opacity-90
423
+ ${t}
424
+ `,onClick:g,disabled:F,children:y}),s&&r.jsx("div",{className:`absolute top-full mt-2 left-1/2 transform -translate-x-1/2
425
+ bg-red-500 text-white text-xs px-2 py-1 rounded whitespace-nowrap z-10
426
+ animate-fade-in`,children:s}),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 ol({diff:e,fileName:t,isMobile:n,wrapText:o}){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 s=(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&&o?"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(`
427
+ `).map((a,i)=>s(a,i))]})}function Mb({selectedProject:e,isMobile:t,onFileOpen:n}){const[o,s]=l.useState(null),[a,i]=l.useState({}),[c,d]=l.useState(!1),[u,m]=l.useState(""),[p,f]=l.useState(new Set),[h,g]=l.useState(new Set),[b,y]=l.useState(!1),[k,F]=l.useState(""),[E,L]=l.useState([]),[T,P]=l.useState(!0),[I,z]=l.useState(!1),[K,S]=l.useState(!1),[se,ie]=l.useState(!1),[U,Q]=l.useState(""),[V,le]=l.useState(!1),[ce,ue]=l.useState("changes"),[G,Ae]=l.useState([]),[O,Z]=l.useState(new Set),[ae,be]=l.useState({}),[ye,ke]=l.useState(!1),[ne,Se]=l.useState(null),[We,ve]=l.useState(!1),[tt,$e]=l.useState(!1),[je,Te]=l.useState(!1),[qe,et]=l.useState(!1),[Ke,Xe]=l.useState(t),[ge,Le]=l.useState(null),[rt,Re]=l.useState(!1),Oe=l.useRef(null),A=l.useRef(null),[q,v]=l.useState(()=>localStorage.getItem("selected-provider")||"claude");l.useEffect(()=>{const _=()=>{const H=localStorage.getItem("selected-provider")||"claude";v(H)};return window.addEventListener("storage",_),()=>window.removeEventListener("storage",_)},[]),l.useEffect(()=>{e&&(x(),C(),$(),ce==="history"&&Nt())},[e,ce]),l.useEffect(()=>{const _=H=>{A.current&&!A.current.contains(H.target)&&S(!1)};return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[]);const x=async()=>{if(e){d(!0);try{const H=await(await fe(`/api/git/status?project=${encodeURIComponent(e.name)}`)).json();if(H.error)console.error("Git status error:",H.error),s({error:H.error,details:H.details});else{s(H),F(H.branch||"main");const oe=new Set([...H.modified||[],...H.added||[],...H.deleted||[],...H.untracked||[]]);g(oe);for(const Be of H.modified||[])ft(Be);for(const Be of H.added||[])ft(Be);for(const Be of H.deleted||[])ft(Be);for(const Be of H.untracked||[])ft(Be)}}catch(_){console.error("Error fetching git status:",_)}finally{d(!1)}}},C=async()=>{try{const H=await(await fe(`/api/git/branches?project=${encodeURIComponent(e.name)}`)).json();!H.error&&H.branches&&L(H.branches)}catch(_){console.error("Error fetching branches:",_)}},$=async()=>{if(e)try{const H=await(await fe(`/api/git/remote-status?project=${encodeURIComponent(e.name)}`)).json();H.error?Se(null):Se(H)}catch(_){console.error("Error fetching remote status:",_),Se(null)}},D=async _=>{try{const oe=await(await fe("/api/git/checkout",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,branch:_})})).json();oe.success?(F(_),S(!1),x()):console.error("Failed to switch branch:",oe.error)}catch(H){console.error("Error switching branch:",H)}},J=async()=>{if(U.trim()){le(!0);try{const H=await(await fe("/api/git/create-branch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,branch:U.trim()})})).json();H.success?(F(U.trim()),ie(!1),S(!1),Q(""),C(),x()):console.error("Failed to create branch:",H.error)}catch(_){console.error("Error creating branch:",_)}finally{le(!1)}}},pe=async()=>{ve(!0);try{const H=await(await fe("/api/git/fetch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();H.success?(x(),$()):console.error("Fetch failed:",H.error)}catch(_){console.error("Error fetching from remote:",_)}finally{ve(!1)}},Ie=async()=>{$e(!0);try{const H=await(await fe("/api/git/pull",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();H.success?(x(),$()):console.error("Pull failed:",H.error)}catch(_){console.error("Error pulling from remote:",_)}finally{$e(!1)}},Me=async()=>{Te(!0);try{const H=await(await fe("/api/git/push",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();H.success?(x(),$()):console.error("Push failed:",H.error)}catch(_){console.error("Error pushing to remote:",_)}finally{Te(!1)}},it=async()=>{et(!0);try{const H=await(await fe("/api/git/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,branch:k})})).json();H.success?(x(),$()):console.error("Publish failed:",H.error)}catch(_){console.error("Error publishing branch:",_)}finally{et(!1)}},me=async _=>{try{const oe=await(await fe("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,file:_})})).json();oe.success?(g(Be=>{const ot=new Set(Be);return ot.delete(_),ot}),x()):console.error("Discard failed:",oe.error)}catch(H){console.error("Error discarding changes:",H)}},_e=async _=>{try{const oe=await(await fe("/api/git/delete-untracked",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,file:_})})).json();oe.success?(g(Be=>{const ot=new Set(Be);return ot.delete(_),ot}),x()):console.error("Delete failed:",oe.error)}catch(H){console.error("Error deleting untracked file:",H)}},Qe=async()=>{if(!ge)return;const{type:_,file:H,message:oe}=ge;Le(null);try{switch(_){case"discard":await me(H);break;case"delete":await _e(H);break;case"commit":await X();break;case"pull":await Ie();break;case"push":await Me();break;case"publish":await it();break}}catch(Be){console.error(`Error executing ${_}:`,Be)}},ft=async _=>{try{const oe=await(await fe(`/api/git/diff?project=${encodeURIComponent(e.name)}&file=${encodeURIComponent(_)}`)).json();!oe.error&&oe.diff&&i(Be=>({...Be,[_]:oe.diff}))}catch(H){console.error("Error fetching file diff:",H)}},Et=async _=>{if(n)try{const oe=await(await fe(`/api/git/file-with-diff?project=${encodeURIComponent(e.name)}&file=${encodeURIComponent(_)}`)).json();if(oe.error){console.error("Error fetching file with diff:",oe.error),n(_);return}const Be={old_string:oe.oldContent||"",new_string:oe.currentContent||""};n(_,Be)}catch(H){console.error("Error opening file:",H),n(_)}},Nt=async()=>{try{const H=await(await fe(`/api/git/commits?project=${encodeURIComponent(e.name)}&limit=10`)).json();!H.error&&H.commits&&Ae(H.commits)}catch(_){console.error("Error fetching commits:",_)}},yt=async _=>{try{const oe=await(await fe(`/api/git/commit-diff?project=${encodeURIComponent(e.name)}&commit=${_}`)).json();!oe.error&&oe.diff&&be(Be=>({...Be,[_]:oe.diff}))}catch(H){console.error("Error fetching commit diff:",H)}},vt=async()=>{ke(!0);try{const H=await(await fe("/api/git/generate-commit-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,files:Array.from(h),provider:q})})).json();H.message?m(H.message):console.error("Failed to generate commit message:",H.error)}catch(_){console.error("Error generating commit message:",_)}finally{ke(!1)}},we=_=>{f(H=>{const oe=new Set(H);return oe.has(_)?oe.delete(_):oe.add(_),oe})},Tt=_=>{Z(H=>{const oe=new Set(H);return oe.has(_)?oe.delete(_):(oe.add(_),ae[_]||yt(_)),oe})},Rt=_=>{g(H=>{const oe=new Set(H);return oe.has(_)?oe.delete(_):oe.add(_),oe})},X=async()=>{if(!(!u.trim()||h.size===0)){y(!0);try{const H=await(await fe("/api/git/commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,message:u,files:Array.from(h)})})).json();H.success?(m(""),g(new Set),x(),$()):console.error("Commit failed:",H.error)}catch(_){console.error("Error committing changes:",_)}finally{y(!1)}}},xe=async()=>{Re(!0);try{const H=await(await fe("/api/git/initial-commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();H.success?(x(),$()):(console.error("Initial commit failed:",H.error),alert(H.error||"Failed to create initial commit"))}catch(_){console.error("Error creating initial commit:",_),alert("Failed to create initial commit")}finally{Re(!1)}},Ce=_=>{switch(_){case"M":return"Modified";case"A":return"Added";case"D":return"Deleted";case"U":return"Untracked";default:return _}},ze=_=>{const H=O.has(_.hash),oe=ae[_.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:()=>Tt(_.hash),children:[r.jsx("div",{className:"mr-2 mt-1 p-0.5 hover:bg-gray-200 dark:hover:bg-gray-700 rounded",children:H?r.jsx(Tr,{className:"w-3 h-3"}):r.jsx(en,{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:_.message}),r.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:[_.author," • ",_.date]})]}),r.jsx("span",{className:"text-xs font-mono text-gray-400 dark:text-gray-500 flex-shrink-0",children:_.hash.substring(0,7)})]})})]}),H&&oe&&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:_.stats}),r.jsx(ol,{diff:oe,fileName:"commit",isMobile:t,wrapText:T})]})})]},_.hash)},Ve=(_,H)=>{const oe=p.has(_),Be=h.has(_),ot=a[_];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:Be,onChange:()=>Rt(_),onClick:N=>N.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:N=>{N.stopPropagation(),we(_)},children:r.jsx(en,{className:`w-3 h-3 transition-transform duration-200 ease-in-out ${oe?"rotate-90":"rotate-0"}`})}),r.jsx("span",{className:`flex-1 truncate ${t?"text-xs":"text-sm"} cursor-pointer hover:text-primary hover:underline`,onClick:N=>{N.stopPropagation(),Et(_)},title:"Click to open file",children:_}),r.jsxs("div",{className:"flex items-center gap-1",children:[(H==="M"||H==="D")&&r.jsxs("button",{onClick:N=>{N.stopPropagation(),Le({type:"discard",file:_,message:`Discard all changes to "${_}"? 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(ir,{className:"w-3 h-3"}),t&&r.jsx("span",{children:"Discard"})]}),H==="U"&&r.jsxs("button",{onClick:N=>{N.stopPropagation(),Le({type:"delete",file:_,message:`Delete untracked file "${_}"? 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(ir,{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 ${H==="M"?"bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800":H==="A"?"bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300 border-green-200 dark:border-green-800":H==="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:Ce(H),children:H})]})]})]}),r.jsxs("div",{className:`bg-gray-50 dark:bg-gray-900 transition-all duration-400 ease-in-out overflow-hidden ${oe&&ot?"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 ${H==="M"?"bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800":H==="A"?"bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300 border-green-200 dark:border-green-800":H==="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:H}),r.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:Ce(H)})]}),t&&r.jsx("button",{onClick:N=>{N.stopPropagation(),P(!T)},className:"text-xs text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white",title:T?"Switch to horizontal scroll":"Switch to text wrap",children:T?"↔️ Scroll":"↩️ Wrap"})]}),r.jsx("div",{className:"max-h-96 overflow-y-auto",children:ot&&r.jsx(ol,{diff:ot,fileName:_,isMobile:t,wrapText:T})})]})]},_)};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:A,children:[r.jsxs("button",{onClick:()=>S(!K),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(Go,{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:k}),ne?.hasRemote&&r.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[ne.ahead>0&&r.jsxs("span",{className:"text-green-600 dark:text-green-400",title:`${ne.ahead} commit${ne.ahead!==1?"s":""} ahead`,children:["↑",ne.ahead]}),ne.behind>0&&r.jsxs("span",{className:"text-primary",title:`${ne.behind} commit${ne.behind!==1?"s":""} behind`,children:["↓",ne.behind]}),ne.isUpToDate&&r.jsx("span",{className:"text-gray-500 dark:text-gray-400",title:"Up to date with remote",children:"✓"})]})]}),r.jsx(Tr,{className:`w-3 h-3 text-gray-500 transition-transform ${K?"rotate-180":""}`})]}),K&&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:E.map(_=>r.jsx("button",{onClick:()=>D(_),className:`w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 ${_===k?"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:[_===k&&r.jsx(hr,{className:"w-3 h-3 text-green-600 dark:text-green-400"}),r.jsx("span",{className:_===k?"font-medium":"",children:_})]})},_))}),r.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 py-1",children:r.jsxs("button",{onClick:()=>{ie(!0),S(!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(nn,{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:[ne?.hasRemote&&r.jsxs(r.Fragment,{children:[!ne?.hasUpstream&&r.jsxs("button",{onClick:()=>Le({type:"publish",message:`Publish branch "${k}" to ${ne.remoteName}?`}),disabled:qe,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 "${k}" to ${ne.remoteName}`,children:[r.jsx(Wn,{className:`w-3 h-3 ${qe?"animate-pulse":""}`}),r.jsx("span",{children:qe?"Publishing...":"Publish"})]}),ne?.hasUpstream&&!ne?.isUpToDate&&r.jsxs(r.Fragment,{children:[ne.behind>0&&r.jsxs("button",{onClick:()=>Le({type:"pull",message:`Pull ${ne.behind} commit${ne.behind!==1?"s":""} from ${ne.remoteName}?`}),disabled:tt,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 ${ne.behind} commit${ne.behind!==1?"s":""} from ${ne.remoteName}`,children:[r.jsx(ys,{className:`w-3 h-3 ${tt?"animate-pulse":""}`}),r.jsx("span",{children:tt?"Pulling...":`Pull ${ne.behind}`})]}),ne.ahead>0&&r.jsxs("button",{onClick:()=>Le({type:"push",message:`Push ${ne.ahead} commit${ne.ahead!==1?"s":""} to ${ne.remoteName}?`}),disabled:je,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 ${ne.ahead} commit${ne.ahead!==1?"s":""} to ${ne.remoteName}`,children:[r.jsx(Wn,{className:`w-3 h-3 ${je?"animate-pulse":""}`}),r.jsx("span",{children:je?"Pushing...":`Push ${ne.ahead}`})]}),(ne.ahead>0||ne.behind>0&&ne.ahead>0)&&r.jsxs("button",{onClick:pe,disabled:We,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 ${ne.remoteName}`,children:[r.jsx(ar,{className:`w-3 h-3 ${We?"animate-spin":""}`}),r.jsx("span",{children:We?"Fetching...":"Fetch"})]})]})]}),r.jsx("button",{onClick:()=>{x(),C(),$()},disabled:c,className:`hover:bg-gray-100 dark:hover:bg-gray-800 rounded ${t?"p-1":"p-1.5"}`,children:r.jsx(ar,{className:`${c?"animate-spin":""} ${t?"w-3 h-3":"w-4 h-4"}`})})]})]}),o?.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(Go,{className:"w-20 h-20 mb-6 opacity-30"}),r.jsx("h3",{className:"text-xl font-medium mb-3 text-center",children:o.error}),o.details&&r.jsx("p",{className:"text-sm text-center leading-relaxed mb-6 max-w-md",children:o.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 ${p.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:()=>ue("changes"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${ce==="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(Xs,{className:"w-4 h-4"}),r.jsx("span",{children:"Changes"})]})}),r.jsx("button",{onClick:()=>ue("history"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${ce==="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(Fa,{className:"w-4 h-4"}),r.jsx("span",{children:"History"})]})})]}),ce==="changes"&&r.jsx(r.Fragment,{children:r.jsx("div",{className:`transition-all duration-300 ease-in-out ${p.size===0?"max-h-96 opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2 overflow-hidden"}`,children:t&&Ke?r.jsx("div",{className:"px-4 py-2 border-b border-gray-200 dark:border-gray-700",children:r.jsxs("button",{onClick:()=>Xe(!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(Jo,{className:"w-4 h-4"}),r.jsxs("span",{children:["Commit ",h.size," file",h.size!==1?"s":""]}),r.jsx(Tr,{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:()=>Xe(!0),className:"p-1 hover:bg-gray-100 dark:hover:bg-gray-800 rounded",children:r.jsx(Tr,{className:"w-4 h-4 rotate-180"})})]}),r.jsxs("div",{className:"relative",children:[r.jsx("textarea",{ref:Oe,value:u,onChange:_=>m(_.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:_=>{_.key==="Enter"&&(_.ctrlKey||_.metaKey)&&X()}}),r.jsxs("div",{className:"absolute right-2 top-2 flex gap-1",children:[r.jsx("button",{onClick:vt,disabled:h.size===0||ye,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:ye?r.jsx(ar,{className:"w-4 h-4 animate-spin"}):r.jsx(Qs,{className:"w-4 h-4"})}),r.jsx("div",{style:{display:"none"},children:r.jsx(Tb,{onTranscript:_=>m(_),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:[h.size," file",h.size!==1?"s":""," selected"]}),r.jsxs("button",{onClick:()=>Le({type:"commit",message:`Commit ${h.size} file${h.size!==1?"s":""} with message: "${u.trim()}"?`}),disabled:!u.trim()||h.size===0||b,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(hr,{className:"w-3 h-3"}),r.jsx("span",{children:b?"Committing...":"Commit"})]})]})]})})})}),ce==="changes"&&o&&!o.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"} ${p.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:[h.size," of ",(o?.modified?.length||0)+(o?.added?.length||0)+(o?.deleted?.length||0)+(o?.untracked?.length||0)," ",t?"":"files"," selected"]}),r.jsxs("div",{className:`flex ${t?"gap-1":"gap-2"}`,children:[r.jsx("button",{onClick:()=>{const _=new Set([...o?.modified||[],...o?.added||[],...o?.deleted||[],...o?.untracked||[]]);g(_)},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:()=>g(new Set),className:"text-primary hover:text-primary text-xs",children:t?"None":"Deselect All"})]})]}),!o?.error&&!t&&r.jsxs("div",{className:"border-b border-gray-200 dark:border-gray-700",children:[r.jsxs("button",{onClick:()=>z(!I),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(Em,{className:"w-3 h-3"}),r.jsx("span",{children:"File Status Guide"}),I?r.jsx(Tr,{className:"w-3 h-3"}):r.jsx(en,{className:"w-3 h-3"})]}),I&&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"})]})]})})]})]}),ce==="changes"&&!o?.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(ar,{className:"w-6 h-6 animate-spin text-gray-400"})}):o?.hasCommits===!1?r.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[r.jsx(Go,{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:xe,disabled:rt,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:rt?r.jsxs(r.Fragment,{children:[r.jsx(ar,{className:"w-4 h-4 animate-spin"}),r.jsx("span",{children:"Creating Initial Commit..."})]}):r.jsxs(r.Fragment,{children:[r.jsx(Jo,{className:"w-4 h-4"}),r.jsx("span",{children:"Create Initial Commit"})]})})]}):!o||!o.modified?.length&&!o.added?.length&&!o.deleted?.length&&!o.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(Jo,{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:[o.modified?.map(_=>Ve(_,"M")),o.added?.map(_=>Ve(_,"A")),o.deleted?.map(_=>Ve(_,"D")),o.untracked?.map(_=>Ve(_,"U"))]})}),ce==="history"&&!o?.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(ar,{className:"w-6 h-6 animate-spin text-gray-400"})}):G.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(Fa,{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:G.map(_=>ze(_))})}),se&&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:()=>ie(!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:U,onChange:_=>Q(_.target.value),onKeyDown:_=>{_.key==="Enter"&&!V&&J()},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 (",k,")"]}),r.jsxs("div",{className:"flex justify-end space-x-3",children:[r.jsx("button",{onClick:()=>{ie(!1),Q("")},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:J,disabled:!U.trim()||V,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:V?r.jsxs(r.Fragment,{children:[r.jsx(ar,{className:"w-3 h-3 animate-spin"}),r.jsx("span",{children:"Creating..."})]}):r.jsxs(r.Fragment,{children:[r.jsx(nn,{className:"w-3 h-3"}),r.jsx("span",{children:"Create Branch"})]})})]})]})})]}),ge&&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:()=>Le(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 ${ge.type==="discard"||ge.type==="delete"?"bg-red-100 dark:bg-red-900":"bg-yellow-100 dark:bg-yellow-900"}`,children:r.jsx(js,{className:`w-5 h-5 ${ge.type==="discard"||ge.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:ge.type==="discard"?"Discard Changes":ge.type==="delete"?"Delete File":ge.type==="commit"?"Confirm Commit":ge.type==="pull"?"Confirm Pull":ge.type==="publish"?"Publish Branch":"Confirm Push"})]}),r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:ge.message}),r.jsxs("div",{className:"flex justify-end space-x-3",children:[r.jsx("button",{onClick:()=>Le(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:Qe,className:`px-4 py-2 text-sm text-white rounded-md ${ge.type==="discard"||ge.type==="delete"?"bg-red-600 hover:bg-red-700":ge.type==="commit"?"bg-primary hover:bg-primary/90":ge.type==="pull"?"bg-green-600 hover:bg-green-700":ge.type==="publish"?"bg-purple-600 hover:bg-purple-700":"bg-orange-600 hover:bg-orange-700"} flex items-center space-x-2`,children:ge.type==="discard"?r.jsxs(r.Fragment,{children:[r.jsx(ir,{className:"w-4 h-4"}),r.jsx("span",{children:"Discard"})]}):ge.type==="delete"?r.jsxs(r.Fragment,{children:[r.jsx(ir,{className:"w-4 h-4"}),r.jsx("span",{children:"Delete"})]}):ge.type==="commit"?r.jsxs(r.Fragment,{children:[r.jsx(hr,{className:"w-4 h-4"}),r.jsx("span",{children:"Commit"})]}):ge.type==="pull"?r.jsxs(r.Fragment,{children:[r.jsx(ys,{className:"w-4 h-4"}),r.jsx("span",{children:"Pull"})]}):ge.type==="publish"?r.jsxs(r.Fragment,{children:[r.jsx(Wn,{className:"w-4 h-4"}),r.jsx("span",{children:"Publish"})]}):r.jsxs(r.Fragment,{children:[r.jsx(Wn,{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 Pb extends jt.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 Db=l.forwardRef(({className:e,...t},n)=>r.jsx(Lc,{ref:n,className:xt("inline-flex h-10 items-center justify-center rounded-xl bg-muted/60 p-1 text-muted-foreground",e),...t}));Db.displayName=Lc.displayName;const Rb=l.forwardRef(({className:e,...t},n)=>r.jsx(Oc,{ref:n,className:xt("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}));Rb.displayName=Oc.displayName;const Lb=l.forwardRef(({className:e,...t},n)=>r.jsx(Fc,{ref:n,className:xt("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/20",e),...t}));Lb.displayName=Fc.displayName;function Ob({selectedProject:e,selectedSession:t,activeTab:n,setActiveTab:o,ws:s,sendMessage:a,latestMessage:i,isMobile:c,isPWA:d,onMenuClick:u,isLoading:m,onInputFocusChange:p,onSessionActive:f,onSessionInactive:h,onSessionProcessing:g,onSessionNotProcessing:b,processingSessions:y,onReplaceTemporarySession:k,onNavigateToSession:F,onShowSettings:E,autoExpandTools:L,showRawParameters:T,showThinking:P,autoScrollToBottom:I,sendByCtrlEnter:z,externalMessageUpdate:K,urlContext:S,urlPrompt:se,integrationClientId:ie,latestIntegrationMessage:U,sendIntegrationMessage:Q,onShowNewProject:V,onNewSession:le,newSessionResetNonce:ce}){const{t:ue}=St(),[G,Ae]=l.useState(null),[O,Z]=l.useState(600),[ae,be]=l.useState(!1),[ye,ke]=l.useState(!1),ne=l.useRef(null),Se=(Ke,Xe=null)=>{const ge={name:Ke.split("/").pop(),path:Ke,projectName:e?.name,diffInfo:Xe};Ae(ge)},We=()=>{Ae(null),ke(!1)},ve=()=>{ke(!ye)},tt=Ke=>{c||(be(!0),Ke.preventDefault())};if(l.useEffect(()=>{n==="files"&&o("chat")},[n,o]),l.useEffect(()=>{const Ke=ge=>{if(!ae)return;const Le=ne.current?.parentElement;if(!Le)return;const rt=Le.getBoundingClientRect(),Re=rt.right-ge.clientX,Oe=300,A=rt.width*.8;Re>=Oe&&Re<=A&&Z(Re)},Xe=()=>{be(!1)};return ae&&(document.addEventListener("mousemove",Ke),document.addEventListener("mouseup",Xe),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",Ke),document.removeEventListener("mouseup",Xe),document.body.style.cursor="",document.body.style.userSelect=""}},[ae]),m)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:ue("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:ue("mainContent.chooseProject")}),r.jsx("p",{className:"text-gray-600 dark:text-gray-300 mb-6 leading-relaxed",children:ue("mainContent.selectProjectDescription")}),r.jsx("div",{className:"mx-auto flex w-fit items-center",children:r.jsxs("button",{onClick:V,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:ue("sidebar:projects.newProject"),children:[r.jsx(Lr,{className:"w-5 h-5"}),r.jsx("span",{children:ue("sidebar:projects.newProject")})]})})]})})]});const $e=t?.__provider||t?.provider||"claude",je=$e==="openai"?"codex":$e,Te=je==="codex"&&typeof t?.id=="string"?t.id.trim():"",qe=Te?`codex://threads/${encodeURIComponent(Te)}`:"",et=()=>{qe&&(window.location.href=qe)};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:Ke=>{Ke.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:je==="codex"?r.jsx(Pn,{className:"w-4 h-4"}):je==="gemini"?r.jsx(Dn,{className:"w-4 h-4"}):je==="opencode"?r.jsx(Rn,{className:"h-4 w-auto max-w-full"}):r.jsx(pn,{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:je==="codex"?t.summary||t.name||"Codex Session":je==="gemini"?t.summary||t.name||"Gemini Session":je==="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:ue("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"?ue("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"&&je==="codex"&&qe&&!c&&r.jsx("button",{onClick:et,className:"rounded-xl bg-muted/60 p-2 text-muted-foreground transition hover:bg-muted hover:text-foreground",title:ue("mainContent.openInCodexClient"),"aria-label":ue("mainContent.openInCodexClient"),children:r.jsx(vs,{className:"w-5 h-5"})}),r.jsx("button",{onClick:()=>le&&le(e),className:"rounded-xl bg-muted/60 p-2 text-muted-foreground transition hover:bg-muted hover:text-foreground",title:ue("tooltips.newChat","New Chat"),children:r.jsx(Pm,{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 ${G?"mr-0":""} ${ye?"hidden":""}`,children:[r.jsx("div",{className:`h-full ${n==="chat"?"block":"hidden"}`,children:r.jsx(Pb,{showDetails:!0,children:r.jsx(Dv,{selectedProject:e,selectedSession:t,ws:s,sendMessage:a,latestMessage:i,onFileOpen:Se,onInputFocusChange:p,onSessionActive:f,onSessionInactive:h,onSessionProcessing:g,onSessionNotProcessing:b,processingSessions:y,onReplaceTemporarySession:k,onNavigateToSession:F,onShowSettings:E,autoExpandTools:L,showRawParameters:T,showThinking:P,autoScrollToBottom:I,sendByCtrlEnter:z,externalMessageUpdate:K,urlContext:S,urlPrompt:se,integrationClientId:ie,latestIntegrationMessage:U,sendIntegrationMessage:Q,newSessionResetNonce:ce},`${e?.name||"no-project"}:${t?.id||`new-${ce}`}`)})}),n==="shell"&&r.jsx("div",{className:"h-full w-full overflow-hidden",children:r.jsx(Kd,{project:e,session:t,showHeader:!1})}),n==="git"&&r.jsx("div",{className:"chat-surface h-full overflow-hidden",children:r.jsx(Mb,{selectedProject:e,isMobile:c,onFileOpen:Se})}),r.jsx("div",{className:`h-full overflow-hidden ${n==="preview"?"block":"hidden"}`})]}),G&&!c&&r.jsxs(r.Fragment,{children:[!ye&&r.jsx("div",{ref:ne,onMouseDown:tt,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 ${ye?"flex-1":""}`,style:ye?{}:{width:`${O}px`},children:r.jsx(rl,{file:G,onClose:We,projectPath:e?.path,isSidebar:!0,isExpanded:ye,onToggleExpand:ve})})]})]}),G&&c&&r.jsx(rl,{file:G,onClose:We,projectPath:e?.path,isSidebar:!1})]})}const Fb=jt.memo(Ob),Vd="0.2.9",Gd=()=>{const[e,t]=l.useState(!1),[n,o]=l.useState(null),[s,a]=l.useState(null);return l.useEffect(()=>{(async()=>{try{const c=await fe("/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/,"");o(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),o(null),a(null)}catch(c){console.error("Version check failed:",c.message||c),t(!1),o(null),a(null)}})()},[]),{updateAvailable:e,latestVersion:n,currentVersion:Vd,releaseInfo:s}};function $b(){const{t:e}=St("settings"),[t,n]=l.useState([]),[o,s]=l.useState(!0),[a,i]=l.useState(!1),[c,d]=l.useState(""),[u,m]=l.useState(null),[p,f]=l.useState(null),{updateAvailable:h,latestVersion:g,releaseInfo:b}=Gd();l.useEffect(()=>{y()},[]);const y=async()=>{try{s(!0);const P=await(await fe("/api/settings/api-keys")).json();n(P.apiKeys||[])}catch(T){console.error("Error fetching settings:",T)}finally{s(!1)}},k=async()=>{if(c.trim())try{const P=await(await fe("/api/settings/api-keys",{method:"POST",body:JSON.stringify({keyName:c})})).json();P.success&&(f(P.apiKey),d(""),i(!1),y())}catch(T){console.error("Error creating API key:",T)}},F=async T=>{if(confirm(e("apiKeys.confirmDelete")))try{await fe(`/api/settings/api-keys/${T}`,{method:"DELETE"}),y()}catch(P){console.error("Error deleting API key:",P)}},E=async(T,P)=>{try{await fe(`/api/settings/api-keys/${T}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!P})}),y()}catch(I){console.error("Error toggling API key:",I)}},L=(T,P)=>{navigator.clipboard.writeText(T),m(P),setTimeout(()=>m(null),2e3)};return o?r.jsx("div",{className:"text-muted-foreground",children:e("apiKeys.loading")}):r.jsxs("div",{className:"space-y-8",children:[p&&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:p.apiKey}),r.jsx(Je,{size:"sm",variant:"outline",onClick:()=>L(p.apiKey,"new"),children:u==="new"?r.jsx(hr,{className:"h-4 w-4"}):r.jsx(Wp,{className:"h-4 w-4"})})]}),r.jsx(Je,{size:"sm",variant:"ghost",className:"mt-3",onClick:()=>f(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(kl,{className:"h-5 w-5"}),r.jsx("h3",{className:"text-lg font-semibold",children:e("apiKeys.title")})]}),r.jsxs(Je,{size:"sm",onClick:()=>i(!a),children:[r.jsx(nn,{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(vs,{className:"h-3 w-3"})]})]}),a&&r.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card",children:[r.jsx(fr,{placeholder:e("apiKeys.form.placeholder"),value:c,onChange:T=>d(T.target.value),className:"mb-2"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Je,{onClick:k,children:e("apiKeys.form.createButton")}),r.jsx(Je,{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(T=>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:T.key_name}),r.jsx("code",{className:"text-xs text-muted-foreground",children:T.api_key}),r.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[e("apiKeys.list.created")," ",new Date(T.created_at).toLocaleDateString(),T.last_used&&` • ${e("apiKeys.list.lastUsed")} ${new Date(T.last_used).toLocaleDateString()}`]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Je,{size:"sm",variant:T.is_active?"outline":"secondary",onClick:()=>E(T.id,T.is_active),children:T.is_active?e("apiKeys.status.active"):e("apiKeys.status.inactive")}),r.jsx(Je,{size:"sm",variant:"ghost",onClick:()=>F(T.id),children:r.jsx(ir,{className:"h-4 w-4"})})]})]},T.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:b?.htmlUrl||"https://github.com/lintendo/AI-Web-UI/releases",target:"_blank",rel:"noopener noreferrer",className:"hover:text-muted-foreground transition-colors",children:["v",Vd]}),h&&g&&r.jsxs("a",{href:b?.htmlUrl||"https://github.com/lintendo/AI-Web-UI/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:g})}),r.jsx(vs,{className:"h-2.5 w-2.5"})]})]})})]})}function Bb({isOpen:e,onClose:t,provider:n="claude",project:o,onComplete:s,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=m=>{s?.(m),m===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(Ht,{className:"w-6 h-6"})})]}),r.jsx("div",{className:"flex-1 overflow-hidden",children:r.jsx(Kd,{project:o,command:c(),onComplete:u,minimal:!0})})]})})}function Jd({compact:e=!1}){const{i18n:t,t:n}=St("settings"),o=s=>{const a=s.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(jl,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),n("account.language")]}),r.jsx("select",{value:t.language,onChange:o,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:La.map(s=>r.jsx("option",{value:s.value,children:s.nativeName},s.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:o,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:La.map(s=>r.jsx("option",{value:s.value,children:s.nativeName},s.value))})]})})}function zb({isOpen:e,onClose:t,projects:n=[],initialTab:o="appearance"}){const{isDarkMode:s,toggleDarkMode:a}=Ys(),{t:i}=St("settings"),[c,d]=l.useState([]),[u,m]=l.useState([]),[p,f]=l.useState(""),[h,g]=l.useState(""),[b,y]=l.useState(!1),[k,F]=l.useState(!1),[E,L]=l.useState(null),[T,P]=l.useState("name"),[I,z]=l.useState([]),[K,S]=l.useState(!1),[se,ie]=l.useState(null),[U,Q]=l.useState({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),[V,le]=l.useState(!1),[ce,ue]=l.useState({}),[G,Ae]=l.useState({}),[O,Z]=l.useState({}),[ae,be]=l.useState(o),[ye,ke]=l.useState(""),ne=["appearance","api"],[Se,We]=l.useState(()=>localStorage.getItem("codeEditorTheme")||"dark"),[ve,tt]=l.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[$e,je]=l.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[Te,qe]=l.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[et,Ke]=l.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),[Xe,ge]=l.useState([]),[Le,rt]=l.useState("default"),[Re,Oe]=l.useState(!1),[A,q]=l.useState({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),[v,x]=l.useState(null),[C,$]=l.useState(!1),[D,J]=l.useState(!1),[pe,Ie]=l.useState(""),[Me,it]=l.useState(null),[me,_e]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),[Qe,ft]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),[Et,Nt]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),yt=async()=>{try{const M=await fe("/api/codex/mcp/config/read");if(M.ok){const te=await M.json();if(te.success&&te.servers){ge(te.servers);return}}const R=await fe("/api/codex/mcp/cli/list");if(R.ok){const te=await R.json();if(te.success&&te.servers){const Ge=te.servers.map(dt=>({id:dt.name,name:dt.name,type:dt.type||"stdio",scope:"user",config:{command:dt.command||"",args:dt.args||[],env:dt.env||{}}}));ge(Ge)}}}catch(M){console.error("Error fetching Codex MCP servers:",M)}},vt=async()=>{try{const M=await fe("/api/mcp/config/read");if(M.ok){const Ge=await M.json();if(Ge.success&&Ge.servers){z(Ge.servers);return}}const R=await fe("/api/mcp/cli/list");if(R.ok){const Ge=await R.json();if(Ge.success&&Ge.servers){const dt=Ge.servers.map(nt=>({id:nt.name,name:nt.name,type:nt.type,scope:"user",config:{command:nt.command||"",args:nt.args||[],env:nt.env||{},url:nt.url||"",headers:nt.headers||{},timeout:3e4},created:new Date().toISOString(),updated:new Date().toISOString()}));z(dt);return}}const te=await fe("/api/mcp/servers?scope=user");if(te.ok){const Ge=await te.json();z(Ge.servers||[])}else console.error("Failed to fetch MCP servers")}catch(M){console.error("Error fetching MCP servers:",M)}},we=async M=>{try{se&&await Tt(se.id,"user");const R=await fe("/api/mcp/cli/add",{method:"POST",body:JSON.stringify({name:M.name,type:M.type,scope:M.scope,projectPath:M.projectPath,command:M.config?.command,args:M.config?.args||[],url:M.config?.url,headers:M.config?.headers||{},env:M.config?.env||{}})});if(R.ok){const te=await R.json();if(te.success)return await vt(),!0;throw new Error(te.error||"Failed to save server via Claude CLI")}else{const te=await R.json();throw new Error(te.error||"Failed to save server")}}catch(R){throw console.error("Error saving MCP server:",R),R}},Tt=async(M,R="user")=>{try{const te=await fe(`/api/mcp/cli/remove/${M}?scope=${R}`,{method:"DELETE"});if(te.ok){const Ge=await te.json();if(Ge.success)return await vt(),!0;throw new Error(Ge.error||"Failed to delete server via Claude CLI")}else{const Ge=await te.json();throw new Error(Ge.error||"Failed to delete server")}}catch(te){throw console.error("Error deleting MCP server:",te),te}},Rt=async M=>{try{v&&await X(v.id);const R=await fe("/api/codex/mcp/cli/add",{method:"POST",body:JSON.stringify({name:M.name,command:M.config?.command,args:M.config?.args||[],env:M.config?.env||{}})});if(R.ok){const te=await R.json();if(te.success)return await yt(),!0;throw new Error(te.error||"Failed to save Codex MCP server")}else{const te=await R.json();throw new Error(te.error||"Failed to save server")}}catch(R){throw console.error("Error saving Codex MCP server:",R),R}},X=async M=>{try{const R=await fe(`/api/codex/mcp/cli/remove/${M}`,{method:"DELETE"});if(R.ok){const te=await R.json();if(te.success)return await yt(),!0;throw new Error(te.error||"Failed to delete Codex MCP server")}else{const te=await R.json();throw new Error(te.error||"Failed to delete server")}}catch(R){throw console.error("Error deleting Codex MCP server:",R),R}},xe=()=>{q({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),x(null),Oe(!1)},Ce=async M=>{M.preventDefault(),$(!0);try{v&&await X(v.name),await Rt(A),xe(),L("success")}catch(R){alert(`Error: ${R.message}`),L("error")}finally{$(!1)}};l.useEffect(()=>{e&&(ze(),Ve(),_(),H(),be(ne.includes(o)?o:"appearance"))},[e,o]),l.useEffect(()=>{localStorage.setItem("codeEditorTheme",Se),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Se]),l.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",ve.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[ve]),l.useEffect(()=>{localStorage.setItem("codeEditorShowMinimap",$e.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[$e]),l.useEffect(()=>{localStorage.setItem("codeEditorLineNumbers",Te.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Te]),l.useEffect(()=>{localStorage.setItem("codeEditorFontSize",et),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[et]);const ze=async()=>{try{const M=localStorage.getItem("claude-settings");if(M){const te=JSON.parse(M);d(te.allowedTools||[]),m(te.disallowedTools||[]),y(te.skipPermissions||!1),P(te.projectSortOrder||"name")}else d([]),m([]),y(!1),P("name");const R=localStorage.getItem("codex-settings");if(R){const te=JSON.parse(R);rt(te.permissionMode||"default")}else rt("default");await vt(),await yt()}catch(M){console.error("Error loading tool settings:",M),d([]),m([]),y(!1),P("name")}},Ve=async()=>{try{const M=await fe("/api/cli/claude/status");if(M.ok){const R=await M.json();_e({authenticated:R.authenticated,email:R.email,loading:!1,error:R.error||null})}else _e({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(M){console.error("Error checking Claude auth status:",M),_e({authenticated:!1,email:null,loading:!1,error:M.message})}},_=async()=>{try{const M=await fe("/api/cli/codex/status");if(M.ok){const R=await M.json();ft({authenticated:R.authenticated,email:R.email,loading:!1,error:R.error||null})}else ft({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(M){console.error("Error checking Codex auth status:",M),ft({authenticated:!1,email:null,loading:!1,error:M.message})}},H=async()=>{try{const M=await fe("/api/cli/gemini/status");if(M.ok){const R=await M.json();Nt({authenticated:R.authenticated,email:R.email,loading:!1,error:R.error||null})}else Nt({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(M){console.error("Error checking Gemini auth status:",M),Nt({authenticated:!1,email:null,loading:!1,error:M.message})}},oe=M=>{M===0&&(L("success"),pe==="claude"?Ve():pe==="codex"?_():pe==="gemini"&&H())},Be=()=>{F(!0),L(null);try{const M={allowedTools:c,disallowedTools:u,skipPermissions:b,projectSortOrder:T,lastUpdated:new Date().toISOString()},R={permissionMode:Le,lastUpdated:new Date().toISOString()};localStorage.setItem("claude-settings",JSON.stringify(M)),localStorage.setItem("codex-settings",JSON.stringify(R)),L("success"),setTimeout(()=>{t()},1e3)}catch(M){console.error("Error saving tool settings:",M),L("error")}finally{F(!1)}},ot=()=>{Q({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),ie(null),S(!1),ke("")},N=async M=>{M.preventDefault(),le(!0);try{if(U.importMode==="json"){const R=await fe("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:U.name,jsonConfig:U.jsonInput,scope:U.scope,projectPath:U.projectPath})});if(R.ok){const te=await R.json();if(te.success)await vt(),ot(),L("success");else throw new Error(te.error||"Failed to add server via JSON")}else{const te=await R.json();throw new Error(te.error||"Failed to add server")}}else await we(U),ot(),L("success")}catch(R){alert(`Error: ${R.message}`),L("error")}finally{le(!1)}},Ee=(M,R)=>{Q(te=>({...te,config:{...te.config,[M]:R}}))};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(Vm,{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(Je,{variant:"ghost",size:"sm",onClick:t,className:"text-muted-foreground hover:text-foreground touch-manipulation",children:r.jsx(Ht,{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:()=>be("appearance"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${ae==="appearance"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("mainTabs.appearance")}),r.jsxs("button",{onClick:()=>be("api"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${ae==="api"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[r.jsx(kl,{className:"w-4 h-4 inline mr-2"}),i("mainTabs.apiTokens")]})]})}),r.jsxs("div",{className:"p-4 md:p-6 space-y-6 md:space-y-8 pb-safe-area-inset-bottom",children:[ae==="appearance"&&r.jsx("div",{className:"space-y-6 md:space-y-8",children:ae==="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":s,"aria-label":"Toggle dark mode",children:[r.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),r.jsx("span",{className:`${s?"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:s?r.jsx(ws,{className:"w-3.5 h-3.5 text-gray-700"}):r.jsx(ks,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})})}),r.jsx("div",{className:"space-y-4",children:r.jsx(Jd,{})}),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:T,onChange:M=>P(M.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:()=>We(Se==="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":Se==="dark","aria-label":"Toggle editor theme",children:[r.jsx("span",{className:"sr-only",children:"Toggle editor theme"}),r.jsx("span",{className:`${Se==="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:Se==="dark"?r.jsx(ws,{className:"w-3.5 h-3.5 text-gray-700"}):r.jsx(ks,{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:()=>tt(!ve),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":ve,"aria-label":"Toggle word wrap",children:[r.jsx("span",{className:"sr-only",children:"Toggle word wrap"}),r.jsx("span",{className:`${ve?"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:()=>je(!$e),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":$e,"aria-label":"Toggle minimap",children:[r.jsx("span",{className:"sr-only",children:"Toggle minimap"}),r.jsx("span",{className:`${$e?"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:()=>qe(!Te),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":Te,"aria-label":"Toggle line numbers",children:[r.jsx("span",{className:"sr-only",children:"Toggle line numbers"}),r.jsx("span",{className:`${Te?"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:et,onChange:M=>Ke(M.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"})]})]})})]})]})}),K&&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(se?"mcpForm.title.edit":"mcpForm.title.add")}),r.jsx(Je,{variant:"ghost",size:"sm",onClick:ot,children:r.jsx(Ht,{className:"w-4 h-4"})})]}),r.jsxs("form",{onSubmit:N,className:"p-4 space-y-4",children:[!se&&r.jsxs("div",{className:"flex gap-2 mb-4",children:[r.jsx("button",{type:"button",onClick:()=>Q(M=>({...M,importMode:"form"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${U.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:()=>Q(M=>({...M,importMode:"json"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${U.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")})]}),U.importMode==="form"&&se&&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:[U.scope==="user"?r.jsx(Ra,{className:"w-4 h-4"}):r.jsx(Fr,{className:"w-4 h-4"}),r.jsx("span",{className:"text-sm",children:U.scope==="user"?i("mcpForm.scope.userGlobal"):i("mcpForm.scope.projectLocal")}),U.scope==="local"&&U.projectPath&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",U.projectPath]})]}),r.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:i("mcpForm.scope.cannotChange")})]}),U.importMode==="form"&&!se&&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:()=>Q(M=>({...M,scope:"user",projectPath:""})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${U.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(Ra,{className:"w-4 h-4"}),r.jsx("span",{children:i("mcpForm.scope.userGlobal")})]})}),r.jsx("button",{type:"button",onClick:()=>Q(M=>({...M,scope:"local"})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${U.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(Fr,{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:U.scope==="user"?i("mcpForm.scope.userDescription"):i("mcpForm.scope.projectDescription")})]}),U.scope==="local"&&!se&&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:U.projectPath,onChange:M=>Q(R=>({...R,projectPath:M.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:U.scope==="local",children:[r.jsxs("option",{value:"",children:[i("mcpForm.fields.selectProject"),"..."]}),n.map(M=>r.jsx("option",{value:M.path||M.fullPath,children:M.displayName||M.name},M.name))]}),U.projectPath&&r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:i("mcpForm.projectPath",{path:U.projectPath})})]})]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("div",{className:U.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(fr,{value:U.name,onChange:M=>{Q(R=>({...R,name:M.target.value}))},placeholder:i("mcpForm.placeholders.serverName"),required:!0})]}),U.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:U.type,onChange:M=>{Q(R=>({...R,type:M.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"})]})]})]}),se&&U.raw&&U.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:se.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(U.raw,null,2)})]}),U.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:U.jsonInput,onChange:M=>{Q(R=>({...R,jsonInput:M.target.value}));try{if(M.target.value.trim()){const R=JSON.parse(M.target.value);R.type?R.type==="stdio"&&!R.command?ke(i("mcpForm.validation.stdioRequiresCommand")):(R.type==="http"||R.type==="sse")&&!R.url?ke(i("mcpForm.validation.httpRequiresUrl",{type:R.type})):ke(""):ke(i("mcpForm.validation.missingType"))}}catch{M.target.value.trim()?ke(i("mcpForm.validation.invalidJson")):ke("")}},className:`w-full px-3 py-2 border ${ye?"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:`{
428
+ "type": "stdio",
429
+ "command": "/path/to/server",
430
+ "args": ["--api-key", "abc123"],
431
+ "env": {
432
+ "CACHE_DIR": "/tmp"
433
+ }
434
+ }`,required:!0}),ye&&r.jsx("p",{className:"text-xs text-red-500 mt-1",children:ye}),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"}']})]})}),U.importMode==="form"&&U.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(fr,{value:U.config.command,onChange:M=>Ee("command",M.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(U.config.args)?U.config.args.join(`
435
+ `):"",onChange:M=>Ee("args",M.target.value.split(`
436
+ `).filter(R=>R.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
437
+ abc123`})]})]}),U.importMode==="form"&&(U.type==="sse"||U.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(fr,{value:U.config.url,onChange:M=>Ee("url",M.target.value),placeholder:"https://api.example.com/mcp",type:"url",required:!0})]}),U.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(U.config.env||{}).map(([M,R])=>`${M}=${R}`).join(`
438
+ `),onChange:M=>{const R={};M.target.value.split(`
439
+ `).forEach(te=>{const[Ge,...dt]=te.split("=");Ge&&Ge.trim()&&(R[Ge.trim()]=dt.join("=").trim())}),Ee("env",R)},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
440
+ DEBUG=true`})]}),U.importMode==="form"&&(U.type==="sse"||U.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(U.config.headers||{}).map(([M,R])=>`${M}=${R}`).join(`
441
+ `),onChange:M=>{const R={};M.target.value.split(`
442
+ `).forEach(te=>{const[Ge,...dt]=te.split("=");Ge&&Ge.trim()&&(R[Ge.trim()]=dt.join("=").trim())}),Ee("headers",R)},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
443
+ X-API-Key=your-key`})]}),r.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[r.jsx(Je,{type:"button",variant:"outline",onClick:ot,children:i("mcpForm.actions.cancel")}),r.jsx(Je,{type:"submit",disabled:V,className:"bg-purple-600 hover:bg-purple-700 disabled:opacity-50",children:i(V?"mcpForm.actions.saving":se?"mcpForm.actions.updateServer":"mcpForm.actions.addServer")})]})]})]})}),Re&&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(v?"mcpForm.title.edit":"mcpForm.title.add")}),r.jsx(Je,{variant:"ghost",size:"sm",onClick:xe,children:r.jsx(Ht,{className:"w-4 h-4"})})]}),r.jsxs("form",{onSubmit:Ce,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(fr,{value:A.name,onChange:M=>q(R=>({...R,name:M.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(fr,{value:A.config?.command||"",onChange:M=>q(R=>({...R,config:{...R.config,command:M.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:(A.config?.args||[]).join(`
444
+ `),onChange:M=>q(R=>({...R,config:{...R.config,args:M.target.value.split(`
445
+ `).filter(te=>te.trim())}})),placeholder:`--port
446
+ 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(A.config?.env||{}).map(([M,R])=>`${M}=${R}`).join(`
447
+ `),onChange:M=>{const R={};M.target.value.split(`
448
+ `).forEach(te=>{const[Ge,...dt]=te.split("=");Ge&&dt.length>0&&(R[Ge.trim()]=dt.join("=").trim())}),q(te=>({...te,config:{...te.config,env:R}}))},placeholder:`API_KEY=xxx
449
+ 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(Je,{type:"button",variant:"outline",onClick:xe,children:i("mcpForm.actions.cancel")}),r.jsx(Je,{type:"submit",disabled:C||!A.name||!A.config?.command,className:"bg-green-600 hover:bg-green-700 text-white",children:i(C?"mcpForm.actions.saving":v?"mcpForm.actions.updateServer":"mcpForm.actions.addServer")})]})]})]})}),ae==="api"&&r.jsx("div",{className:"space-y-6 md:space-y-8",children:r.jsx($b,{})})]})]}),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:[E==="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")]}),E==="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(Je,{variant:"outline",onClick:t,disabled:k,className:"flex-1 sm:flex-none h-10 touch-manipulation",children:i("footerActions.cancel")}),r.jsx(Je,{onClick:Be,disabled:k,className:"flex-1 sm:flex-none h-10 bg-primary hover:bg-primary/90 disabled:opacity-50 touch-manipulation",children:k?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(Bb,{isOpen:D,onClose:()=>J(!1),provider:pe,project:Me,onComplete:oe,isAuthenticated:pe==="claude"?me.authenticated:pe==="codex"?Qe.authenticated:!1},pe)]}):null}const Wb=({isOpen:e,onToggle:t,autoExpandTools:n,onAutoExpandChange:o,showRawParameters:s,onShowRawParametersChange:a,showThinking:i,onShowThinkingChange:c,autoScrollToBottom:d,onAutoScrollChange:u,sendByCtrlEnter:m,onSendByCtrlEnterChange:p,isMobile:f})=>{const{t:h}=St("settings"),[g,b]=l.useState(e),[y,k]=l.useState(()=>localStorage.getItem("whisperMode")||"default"),{isDarkMode:F}=Ys(),[E,L]=l.useState(()=>{const O=localStorage.getItem("quickSettingsHandlePosition");if(O)try{return JSON.parse(O).y??50}catch{return localStorage.removeItem("quickSettingsHandlePosition"),50}return 50}),[T,P]=l.useState(!1),[I,z]=l.useState(0),[K,S]=l.useState(0),[se,ie]=l.useState(!1),U=l.useRef(null),Q=l.useRef({min:10,max:90}),V=5;l.useEffect(()=>{b(e)},[e]),l.useEffect(()=>{localStorage.setItem("quickSettingsHandlePosition",JSON.stringify({y:E}))},[E]);const le=l.useCallback(()=>f?{bottom:`${window.innerHeight*E/100}px`}:{top:`${E}%`,transform:"translateY(-50%)"},[E,f]),ce=l.useCallback(O=>{O.stopPropagation();const Z=O.type.includes("touch")?O.touches[0].clientY:O.clientY;z(Z),S(E),ie(!1),P(!1)},[E]),ue=l.useCallback(O=>{if(I===0)return;const Z=O.type.includes("touch")?O.touches[0].clientY:O.clientY,ae=Math.abs(Z-I);if(!T&&ae>V&&(P(!0),ie(!0),document.body.style.cursor="grabbing",document.body.style.userSelect="none",O.type.includes("touch")&&(document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%")),!T)return;O.type.includes("touch")&&O.preventDefault();const be=Z-I;let ye;f?ye=-(be/window.innerHeight)*100:ye=be/window.innerHeight*100;let ke=K+ye;ke=Math.max(Q.current.min,Math.min(Q.current.max,ke)),L(ke)},[T,I,K,f,V]),G=l.useCallback(()=>{P(!1),z(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(I!==0){const O=ye=>ue(ye),Z=()=>G(),ae=ye=>ue(ye),be=()=>G();return document.addEventListener("mousemove",O),document.addEventListener("mouseup",Z),document.addEventListener("touchmove",ae,{passive:!1}),document.addEventListener("touchend",be),()=>{document.removeEventListener("mousemove",O),document.removeEventListener("mouseup",Z),document.removeEventListener("touchmove",ae),document.removeEventListener("touchend",be)}}},[I,ue,G]);const Ae=O=>{if(se){O.preventDefault(),ie(!1);return}const Z=!g;b(Z),t(Z)};return r.jsxs(r.Fragment,{children:[r.jsx("button",{ref:U,onClick:Ae,onMouseDown:O=>{ce(O)},onTouchStart:O=>{ce(O)},className:`fixed ${g?"right-64":"right-0"} z-50 ${T?"":"transition-all duration-150 ease-out"} bg-white dark:bg-gray-800 border ${T?"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 ${T?"cursor-grabbing":"cursor-pointer"} touch-none`,style:{...le(),touchAction:"none",WebkitTouchCallout:"none",WebkitUserSelect:"none"},"aria-label":h(T?"quickSettings.dragHandle.dragging":g?"quickSettings.dragHandle.closePanel":"quickSettings.dragHandle.openPanel"),title:h(T?"quickSettings.dragHandle.draggingStatus":"quickSettings.dragHandle.toggleAndMove"),children:T?r.jsx(km,{className:"h-5 w-5 text-primary"}):g?r.jsx(en,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}):r.jsx(bl,{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 ${g?"translate-x-0":"translate-x-full"} ${f?"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(Jm,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}),h("quickSettings.title")]})}),r.jsxs("div",{className:`flex-1 overflow-y-auto overflow-x-hidden p-4 space-y-6 bg-background ${f?"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:h("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:[F?r.jsx(ws,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}):r.jsx(ks,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),h("quickSettings.darkMode")]}),r.jsx(Up,{})]}),r.jsx("div",{children:r.jsx(Jd,{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:h("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(Sl,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),h("quickSettings.autoExpandTools")]}),r.jsx("input",{type:"checkbox",checked:n,onChange:O=>o(O.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(wl,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),h("quickSettings.showRawParameters")]}),r.jsx("input",{type:"checkbox",checked:s,onChange:O=>a(O.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(vl,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),h("quickSettings.showThinking")]}),r.jsx("input",{type:"checkbox",checked:i,onChange:O=>c(O.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:h("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(Qp,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),h("quickSettings.autoScrollToBottom")]}),r.jsx("input",{type:"checkbox",checked:d,onChange:O=>u(O.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:h("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(jl,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),h("quickSettings.sendByCtrlEnter")]}),r.jsx("input",{type:"checkbox",checked:m,onChange:O=>p(O.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:h("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:h("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:y==="default",onChange:()=>{k("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(co,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),h("quickSettings.whisper.modes.default")]}),r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:h("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:y==="prompt",onChange:()=>{k("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(Qs,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),h("quickSettings.whisper.modes.prompt")]}),r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:h("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:y==="vibe"||y==="instructions"||y==="architect",onChange:()=>{k("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(Xs,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),h("quickSettings.whisper.modes.vibe")]}),r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:h("quickSettings.whisper.modes.vibeDescription")})]})]})]})]})]})]})}),g&&r.jsx("div",{className:"fixed inset-0 bg-background/80 backdrop-blur-sm z-30 transition-opacity duration-150 ease-out",onClick:Ae})]})},Yd=l.createContext({user:null,token:null,login:()=>{},register:()=>{},logout:()=>{},isLoading:!0,needsSetup:!1,error:null}),Oo=()=>{const e=l.useContext(Yd);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e},Ub=({children:e})=>{const[t,n]=l.useState(null),[o,s]=l.useState(localStorage.getItem("auth-token")),[a,i]=l.useState(!0),[c,d]=l.useState(!1),[u,m]=l.useState(null);l.useEffect(()=>{p()},[]);const p=async()=>{try{if(i(!0),m(null),(await(await st.auth.status()).json()).needsSetup){d(!0),i(!1);return}if(o)try{const F=await st.auth.user();if(F.ok){const E=await F.json();n(E.user),d(!1)}else localStorage.removeItem("auth-token"),s(null),n(null)}catch(F){console.error("Token verification failed:",F),localStorage.removeItem("auth-token"),s(null),n(null)}}catch(y){console.error("[AuthContext] Auth status check failed:",y),m("Failed to check authentication status")}finally{i(!1)}},b={user:t,token:o,login:async(y,k)=>{try{m(null);const F=await st.auth.login(y,k),E=await F.json();return F.ok?(s(E.token),n(E.user),localStorage.setItem("auth-token",E.token),{success:!0}):(m(E.error||"Login failed"),{success:!1,error:E.error||"Login failed"})}catch(F){console.error("Login error:",F);const E="Network error. Please try again.";return m(E),{success:!1,error:E}}},register:async(y,k)=>{try{m(null);const F=await st.auth.register(y,k),E=await F.json();return F.ok?(s(E.token),n(E.user),d(!1),localStorage.setItem("auth-token",E.token),{success:!0}):(m(E.error||"Registration failed"),{success:!1,error:E.error||"Registration failed"})}catch(F){console.error("Registration error:",F);const E="Network error. Please try again.";return m(E),{success:!1,error:E}}},logout:()=>{s(null),n(null),localStorage.removeItem("auth-token"),o&&st.auth.logout().catch(y=>{console.error("Logout endpoint error:",y)})},isLoading:a,needsSetup:c,error:u};return r.jsx(Yd.Provider,{value:b,children:e})},Xd=l.createContext(null),Hb=()=>{const e=l.useContext(Xd);if(!e)throw new Error("useWebSocket must be used within a WebSocketProvider");return e},qb=e=>{const t=window.location.protocol==="https:"?"wss:":"ws:";return e?`${t}//${window.location.host}/ws?token=${encodeURIComponent(e)}`:null},Kb=()=>{const e=l.useRef(null),t=l.useRef(!1),[n,o]=l.useState(null),[s,a]=l.useState(!1),i=l.useRef(null),c=l.useRef(!1),d=l.useRef([]),u=l.useRef([]),m=l.useRef(null),p=l.useRef(0),{token:f}=Oo(),h=l.useCallback(()=>{if(m.current||t.current)return;const P=()=>{if(m.current=null,t.current){u.current=[];return}const I=u.current.shift();I&&(p.current+=1,o({...I,__messageSeq:p.current}),u.current.length>0&&(m.current=setTimeout(P,0)))};m.current=setTimeout(P,0)},[]),g=l.useCallback(P=>{u.current.push(P),h()},[h]),b=l.useCallback((P,I)=>{g({type:"connection-error",error:I,provider:P?.provider||(typeof P?.type=="string"?P.type.replace(/-command$/,""):"claude"),sessionId:P?.sessionId||P?.options?.sessionId||null,clientRequestId:P?.clientRequestId||null})},[g]),y=l.useCallback(P=>{P.timeoutId&&(clearTimeout(P.timeoutId),P.timeoutId=null)},[]),k=l.useCallback(P=>{if(P.readyState!==WebSocket.OPEN)return;d.current.splice(0,d.current.length).forEach(z=>{y(z),P.send(JSON.stringify(z.payload))})},[y]),F=l.useCallback(P=>{if(!P||typeof P!="object"||P.clientRequestId)return P;const I=typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`client-${Date.now()}-${Math.random().toString(36).slice(2,10)}`;return{...P,clientRequestId:I}},[]),E=l.useCallback(()=>{if(t.current||c.current)return;const P=e.current;if(!(P&&(P.readyState===WebSocket.OPEN||P.readyState===WebSocket.CONNECTING)))try{const I=qb(f);if(!I){d.current.splice(0,d.current.length).forEach(S=>{y(S),b(S.payload,"No authentication token found for WebSocket connection")});return}c.current=!0;const z=new WebSocket(I);e.current=z,z.onopen=()=>{c.current=!1,a(!0),e.current=z,g({type:"ws-connection-state",state:"connected"}),k(z)},z.onmessage=K=>{try{const S=JSON.parse(K.data);g(S)}catch(S){console.error("Error parsing WebSocket message:",S)}},z.onclose=()=>{c.current=!1,a(!1),e.current===z&&(e.current=null),g({type:"ws-connection-state",state:"disconnected"}),i.current=setTimeout(()=>{t.current||E()},3e3)},z.onerror=K=>{console.error("WebSocket error:",K)}}catch(I){c.current=!1,console.error("Error creating WebSocket connection:",I)}},[y,b,k,f]);l.useEffect(()=>(t.current=!1,E(),()=>{c.current=!1,i.current&&clearTimeout(i.current),m.current&&(clearTimeout(m.current),m.current=null),u.current=[],e.current&&(e.current.close(),e.current=null)}),[E,f]),l.useEffect(()=>()=>{t.current=!0,c.current=!1,i.current&&clearTimeout(i.current),m.current&&(clearTimeout(m.current),m.current=null),u.current=[],d.current.splice(0,d.current.length).forEach(I=>y(I)),e.current&&(e.current.close(),e.current=null)},[y]);const L=l.useCallback(P=>{const I=F(P),z=e.current;if(z&&z.readyState===WebSocket.OPEN){try{z.send(JSON.stringify(I))}catch(S){throw S}return}g({type:"ws-connection-state",state:"connecting",sessionId:I?.sessionId||I?.options?.sessionId||null,clientRequestId:I?.clientRequestId||null});const K={payload:I,timeoutId:setTimeout(()=>{d.current=d.current.filter(S=>S!==K),b(I,"Unable to reach the chat server. Message was not sent.")},1e4)};d.current.push(K),E()},[E,b,g,F]);return l.useMemo(()=>({ws:e.current,sendMessage:L,latestMessage:n,isConnected:s}),[L,n,s])},Vb=({children:e})=>{const t=Kb();return r.jsx(Xd.Provider,{value:t,children:e})},Gb=()=>{const{t:e}=St("auth"),[t,n]=l.useState(""),[o,s]=l.useState(""),[a,i]=l.useState(""),[c,d]=l.useState(!1),[u,m]=l.useState(""),{register:p}=Oo(),f=async h=>{if(h.preventDefault(),m(""),o!==a){m(e("register.errors.passwordMismatch"));return}if(t.length<3){m(e("register.errors.usernameTooShort"));return}if(o.length<6){m(e("register.errors.passwordTooShort"));return}d(!0);const g=await p(t,o);g.success||m(g.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(pn,{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:f,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:h=>n(h.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:o,onChange:h=>s(h.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:h=>i(h.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")})})]})})})},Jb=()=>{const{t:e}=St("auth"),[t,n]=l.useState(""),[o,s]=l.useState(""),[a,i]=l.useState(!1),[c,d]=l.useState(""),{login:u}=Oo(),m=async p=>{if(p.preventDefault(),d(""),!t||!o){d(e("login.errors.requiredFields"));return}i(!0);const f=await u(t,o);f.success||d(f.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:m,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:p=>n(p.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:o,onChange:p=>s(p.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")})})]})})})},Yb=()=>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..."})]})}),Xb=({children:e})=>{const{user:t,isLoading:n,needsSetup:o}=Oo();return n?r.jsx(Yb,{}):o?r.jsx(Gb,{}):t?e:r.jsx(Jb,{})};function Zr(e,t){const[n,o]=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)),o(i)}catch(i){console.log(i)}}]}const Qb=3e3;function xn(e){return typeof e=="string"&&e.trim().length>0}function Zb(e="integration"){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${e}_${crypto.randomUUID()}`:`${e}_${Date.now()}_${Math.random().toString(36).slice(2,10)}`}function ew(){return typeof window>"u"?null:`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/agent/ws`}function tw({enabled:e,channel:t,clientId:n,sessionId:o}){const s=l.useRef(null),a=l.useRef(null),i=l.useRef(!1),c=l.useRef(!1),d=l.useRef(0),u=l.useRef(xn(o)?o.trim():null),[m,p]=l.useState(null),[f,h]=l.useState(!1),g=l.useMemo(()=>e===!0&&xn(t)&&xn(n),[e,t,n]);l.useEffect(()=>{u.current=xn(o)?o.trim():null},[o]);const b=l.useCallback(T=>{d.current+=1,p({...T,__messageSeq:d.current})},[]),y=l.useCallback(()=>{const T=s.current;T&&(T.close(),s.current=null),h(!1),i.current=!1},[]),k=l.useCallback((T,P=s.current)=>!T||!P||P.readyState!==WebSocket.OPEN?!1:(P.send(JSON.stringify({type:"integration.ack",requestId:T,payload:{accepted:!0,available:!0,pageUrl:typeof window<"u"?window.location.href:null,sessionId:u.current}})),!0),[]),F=l.useCallback((T=s.current)=>{!g||!T||T.readyState!==WebSocket.OPEN||T.send(JSON.stringify({type:"integration.connect",requestId:Zb("integration_connect"),payload:{role:"frontend-page",channel:t.trim(),clientId:n.trim(),pageUrl:typeof window<"u"?window.location.href:null,sessionId:xn(o)?o.trim():null,capabilities:["context.update","prompt.update","presence.report"]}}))},[t,n,g,o]),E=l.useCallback(()=>{if(!g||c.current||i.current)return;const T=s.current;if(T&&(T.readyState===WebSocket.OPEN||T.readyState===WebSocket.CONNECTING))return;const P=ew();if(!P)return;i.current=!0;const I=new WebSocket(P);s.current=I,I.onopen=()=>{i.current=!1,s.current=I,h(!0),F(I)},I.onmessage=z=>{try{const K=JSON.parse(z.data);K&&typeof K.type=="string"&&K.type.startsWith("integration.")&&(K.type==="integration.ping"&&k(K.requestId||null,I),b(K))}catch(K){console.error("Error parsing integration WebSocket message:",K)}},I.onclose=()=>{s.current===I&&(s.current=null),i.current=!1,h(!1),!c.current&&g&&(a.current=setTimeout(()=>{a.current=null,E()},Qb))},I.onerror=z=>{console.error("Integration WebSocket error:",z)}},[F,b,g,k]);l.useEffect(()=>{if(c.current=!1,!g){a.current&&(clearTimeout(a.current),a.current=null),y();return}return E(),()=>{a.current&&(clearTimeout(a.current),a.current=null),y()}},[y,E,g]),l.useEffect(()=>()=>{c.current=!0,a.current&&(clearTimeout(a.current),a.current=null),y()},[y]),l.useEffect(()=>{g&&F()},[F,g,o]);const L=l.useCallback(T=>{const P=s.current;return!P||P.readyState!==WebSocket.OPEN?!1:(P.send(JSON.stringify(T)),!0)},[]);return{integrationWs:s.current,latestIntegrationMessage:m,sendIntegrationMessage:L,isIntegrationConnected:f,isIntegrationEnabled:g}}function zr(e){if(typeof e!="string")return"";const t=e.trim();if(!t)return"";const n=t.replace(/\\/g,"/");return n==="/"?"/":/^[A-Za-z]:\/?$/.test(n)?`${n[0]}:/`:n.replace(/\/+$/,"")}function kn(e,t){const n=zr(t);return n?[e?.fullPath,e?.path].some(o=>zr(o)===n):!1}function rw(e,t,n={}){if(!t||!Array.isArray(e))return null;const o=typeof n.provider=="string"?n.provider.trim().toLowerCase():"",s=typeof n.projectName=="string"?n.projectName.trim():"",a=zr(n.projectPath);for(const i of e){if(!((!s||i?.name===s)&&(!a||kn(i,a))))continue;const d=[{provider:"claude",items:i?.sessions},{provider:"codex",items:i?.codexSessions},{provider:"gemini",items:i?.geminiSessions},{provider:"opencode",items:i?.opencodeSessions}];for(const u of d){if(o&&u.provider!==o)continue;const m=u.items?.find(p=>p?.id===t);if(m)return{project:i,session:m,provider:u.provider}}}return null}function Qd({projects:e,queryProject:t=null,queryCwd:n=null}){if(!Array.isArray(e)||e.length===0)return null;const o=zr(t),s=zr(n);return e.find(a=>kn(a,s)?!0:o?[a?.name,a?.fullPath,a?.path].some(i=>zr(i)===o):!1)||null}function nw({projects:e,queryProject:t=null,queryCwd:n=null}){const o=Qd({projects:e,queryProject:t,queryCwd:n});return!!(o&&!o.detailsLoaded)}const ow=["context","prompt","model","integrationWs","integrationClientId","integrationChannel"];function sw(e){return e instanceof URLSearchParams?e:typeof e=="string"?new URLSearchParams(e):new URLSearchParams}function Zd(e,t,n={}){const o=typeof e=="string"&&e?e:"/",s=sw(t),a=new URLSearchParams;for(const c of ow){const d=s.get(c);d&&a.set(c,d)}for(const[c,d]of Object.entries(n||{})){if(d==null||d===""){a.delete(c);continue}a.set(c,String(d))}const i=a.toString();return i?`${o}?${i}`:o}const aw=new Set(["claude","codex","gemini","opencode"]);function ka(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();if(!t)return null;const n=t==="openai"?"codex":t;return aw.has(n)?n:null}function eu({provider:e,sessionId:t}){const n=ka(e),o=typeof t=="string"&&t.trim()?t.trim():"";return!n||!o?null:`/session/${n}/${encodeURIComponent(o)}`}function sl(e,t){const n=eu(e);return n?Zd(n,t):null}function iw({isLoadingProjects:e,hasSelectedProject:t,hasSessionRoute:n,sessionRouteStatus:o}){return t?!1:e?!0:!!(n&&o!=="missing"&&o!=="error")}function lw({requestToken:e,activeRequestToken:t,pathname:n,provider:o,sessionId:s}){if(!e||!t||e!==t||typeof n!="string"||typeof s!="string"||!s)return!1;const a=eu({provider:ka(o),sessionId:s});return!!(a&&n===a)}function cw({activeResolution:e,sessionId:t,resolutionKey:n}){return!e||typeof e!="object"?!0:!(e.sessionId===t&&e.status==="resolving"&&e.resolutionKey===n)}const al="lastSelectedProject",il="lastSelectedSession";function dw(e){return!e||typeof e!="object"?[]:[...e.sessions||[],...e.codexSessions||[],...e.geminiSessions||[],...e.opencodeSessions||[]]}function tu(e,t){return e?.name!==t?.name||e?.displayName!==t?.displayName||e?.fullPath!==t?.fullPath||e?.path!==t?.path||e?.isCustomName!==t?.isCustomName||e?.isManuallyAdded!==t?.isManuallyAdded}function ll(e,t=null){const n=!!t?.detailsLoaded;return{...e,detailsLoaded:n,sessions:n?t?.sessions||[]:[],codexSessions:n?t?.codexSessions||[]:[],geminiSessions:n?t?.geminiSessions||[]:[],opencodeSessions:n?t?.opencodeSessions||[]:[],sessionMeta:n?t?.sessionMeta||{hasMore:!1,total:0}:null,taskmaster:n&&t?.taskmaster||null}}function cl(e,t){const n=new Map(e.map(a=>[a.name,a])),o=t.map(a=>{const i=n.get(a.name);return i?tu(i,a)?ll(a,i):i:ll(a)});return o.length!==e.length||o.some((a,i)=>a!==e[i])?o:e}function uw(e,t){let n=!1;const o=e.map(s=>s.name!==t.name?s:(n=!0,{...s,...t,sessions:t.sessions||[],codexSessions:t.codexSessions||[],geminiSessions:t.geminiSessions||[],opencodeSessions:t.opencodeSessions||[],sessionMeta:t.sessionMeta||{hasMore:!1,total:0},taskmaster:t.taskmaster||null,detailsLoaded:!0}));return n?o:e}function pw(e){return e?.name?{name:e.name,displayName:e.displayName||e.name,fullPath:e.fullPath||e.path||null,path:e.path||e.fullPath||null}:null}function mw(e){return e?.id?{id:e.id,title:e.title||e.summary||e.name||"New Session",provider:e.__provider||"claude",projectName:e.__projectName||null}:null}function dl(){const e=sp(),t=ap(),{provider:n,sessionId:o}=ip(),[s]=lp(),{t:a}=St("common");l.useRef(0);const{updateAvailable:i,latestVersion:c,currentVersion:d,releaseInfo:u}=Gd(),[m,p]=l.useState(!1),[f,h]=l.useState([]),[g,b]=l.useState(null),[y,k]=l.useState(null),[F,E]=l.useState({}),[L,T]=l.useState(0),[P,I]=l.useState("chat"),[z,K]=l.useState(!1),S=z&&!1,[se,ie]=l.useState(!1),[U,Q]=l.useState(!0),[V,le]=l.useState(null),[ce,ue]=l.useState(!1),[G,Ae]=l.useState(!1),[O,Z]=l.useState("appearance"),[ae,be]=l.useState(!1),[ye,ke]=Zr("autoExpandTools",!1),[ne,Se]=Zr("showRawParameters",!1),[We,ve]=Zr("showThinking",!0),[tt,$e]=Zr("autoScrollToBottom",!0),[je,Te]=Zr("sendByCtrlEnter",!1),[qe,et]=Zr("sidebarVisible",!0),[Ke,Xe]=l.useState(!1),[ge,Le]=l.useState(new Set),[rt,Re]=l.useState(new Set),Oe=l.useRef({sessionId:null,status:"idle"}),A=l.useRef(0),[q,v]=l.useState("idle"),x=l.useCallback((j,re="claude")=>{if(!j)return re;try{const de=localStorage.getItem("session-provider-map");if(!de)return re;const De=JSON.parse(de)?.[j];return typeof De=="string"&&De?De:re}catch{return re}},[]),[C,$]=l.useState(0),D=l.useRef({selectionKey:null}),J=l.useRef({attemptedKeys:new Set}),pe=l.useRef(f),Ie=l.useRef(g),Me=l.useRef(y),it=s.get("cwd")||s.get("workdir"),me=l.useMemo(()=>zr(it),[it]),_e=s.get("project")||s.get("projectName"),Qe=l.useMemo(()=>ka(n),[n]);s.get("model");const ft=s.get("context"),Et=s.get("prompt"),Nt=s.get("integrationWs"),yt=s.get("integrationClientId"),vt=s.get("integrationChannel"),we=s.toString(),Rt=f.find(j=>!!(kn(j,me)||_e&&(j.fullPath===_e||j.path===_e)))?.name||null,X=(j,re)=>!j||!re?j!==re:tu(j,re)||!!j.detailsLoaded!=!!re.detailsLoaded,xe=j=>{if(!j)return!1;if(o===j)return!0;const re=Oe.current;return re?.sessionId===j&&re?.status!=="missing"&&re?.status!=="error"?!0:ge.has(j)||rt.has(j)},Ce=l.useCallback(j=>{if(!j?.name)return;const re=Ie.current,de=Me.current;if(re?.name===j.name&&re!==j&&(X(re,j)||!re.detailsLoaded&&j.detailsLoaded)&&b(j),!de||de.__projectName!==j.name||!j.detailsLoaded)return;const Fe=dw(j).find(at=>at.id===de.id);if(!Fe){xe(de.id)||k(null);return}const De={...Fe,__provider:de.__provider||x(Fe.id,"claude"),__projectName:j.name};(De.title!==de.title||De.summary!==de.summary||De.updated_at!==de.updated_at||De.lastActivity!==de.lastActivity||De.__provider!==de.__provider||De.__projectName!==de.__projectName)&&k(De)},[x,xe]),ze=l.useCallback(async(j,re={})=>{const{background:de=!1,force:Fe=!1}=re;if(!j)return null;const De=pe.current.find(at=>at.name===j);if(!Fe&&De?.detailsLoaded)return De;if(F[j])return null;E(at=>({...at,[j]:!0}));try{const at=await st.projectDetails(j);if(!at.ok){if(at.status===404)return h(Mt=>Mt.filter(lt=>lt.name!==j)),null;throw new Error(`Failed to load project details: ${at.status}`)}const ut=await at.json();h(Mt=>uw(Mt,ut));const At={...De,...ut,detailsLoaded:!0};return Ce(At),At}catch(at){return console.error(`Error loading details for project ${j}:`,at),null}finally{E(at=>{const ut={...at};return delete ut[j],ut})}},[F,Ce]),Ve=l.useCallback(async(j={})=>{const{background:re=!1}=j;try{re||Q(!0);const Fe=await(await st.projectsList()).json();h(De=>cl(De,Fe))}catch(de){console.error("Error fetching projects:",de)}finally{re||Q(!1)}},[]),_=l.useCallback((j,re)=>{const de=Zd(j,s);t(de,re)},[t,s]),H=l.useCallback((j,re)=>{const de=sl(j,s);return de?(t(de,re),!0):(console.warn("Skipping session navigation because provider or session id is missing.",j),!1)},[t,s]),oe=l.useCallback(()=>{A.current+=1,Oe.current={sessionId:null,status:"idle"},v("idle")},[]),{ws:Be,sendMessage:ot,latestMessage:N}=Hb(),{latestIntegrationMessage:Ee,sendIntegrationMessage:M}=tw({enabled:Nt==="1",clientId:yt,channel:vt,sessionId:y?.id||o||null}),R=l.useCallback(j=>typeof j!="string"?!1:/^new-session-\d+$/i.test(j)||/^codex-\d+$/i.test(j),[]),te=l.useRef(null),[Ge,dt]=l.useState(!1);l.useEffect(()=>{P==="files"&&I("chat")},[P]),l.useEffect(()=>{const j=()=>{const re=window.matchMedia("(display-mode: standalone)").matches||window.navigator.standalone||document.referrer.includes("android-app://");dt(re),document.addEventListener("touchstart",{}),re?(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 j(),window.matchMedia("(display-mode: standalone)").addEventListener("change",j),()=>{window.matchMedia("(display-mode: standalone)").removeEventListener("change",j)}},[]),l.useEffect(()=>{const j=()=>{K(window.innerWidth<768)};return j(),window.addEventListener("resize",j),()=>window.removeEventListener("resize",j)},[]),l.useEffect(()=>{Ve()},[Ve]),l.useEffect(()=>{o||oe()},[oe,o]),l.useEffect(()=>{pe.current=f},[f]),l.useEffect(()=>{Ie.current=g},[g]),l.useEffect(()=>{Me.current=y},[y]),l.useEffect(()=>{try{const j=pw(g);j?localStorage.setItem(al,JSON.stringify(j)):localStorage.removeItem(al);const re=mw(y);re?localStorage.setItem(il,JSON.stringify(re)):localStorage.removeItem(il)}catch(j){console.warn("Failed to persist last selected project/session:",j)}},[g,y]),l.useEffect(()=>{if(!me&&!_e||f.length===0)return;const j=`${me||""}::${_e||""}`;if(D.current.selectionKey===j)return;if(y){D.current.selectionKey=j;return}let re=null;if(me&&(re=f.find(de=>kn(de,me))),!re&&_e){const de=_e.trim().toLowerCase();re=f.find(Fe=>[Fe.name,Fe.displayName,Fe.path,Fe.fullPath].some(at=>typeof at=="string"&&at.toLowerCase()===de))}re&&b(re),D.current.selectionKey=j},[me,_e,f,y]),l.useEffect(()=>{if(!g?.name||f.length===0)return;const j=f.find(re=>re.name===g.name);if(!j){!o&&!me&&!_e&&(b(null),y?.__projectName===g.name&&k(null));return}j!==g&&X(g,j)&&b(j),!j.detailsLoaded&&!F[j.name]&&ze(j.name,{background:!0})},[ze,me,F,f,_e,g,y?.__projectName,o]),l.useEffect(()=>{if(!me||U||y||pe.current.some(De=>kn(De,me)))return;const re=`cwd:${me}`;if(J.current.attemptedKeys.has(re))return;J.current.attemptedKeys.add(re);let de=!1;return(async()=>{try{const De=await st.createProject(me),at=await De.json().catch(()=>({}));if(!De.ok){const ut=at?.error||"Unknown error";if(ut.includes("Project already configured")){await Ve();return}console.warn(`[URL] Failed to auto-create project for cwd "${me}": ${ut}`);return}if(de)return;at?.project&&b(at.project),await Ve()}catch(De){console.error(`[URL] Error auto-creating project for cwd "${me}":`,De)}})(),()=>{de=!0}},[me,U,y]),l.useEffect(()=>{if(N){if(N.type==="loading_progress"){te.current&&(clearTimeout(te.current),te.current=null),le(N),N.phase==="complete"&&(te.current=setTimeout(()=>{le(null),te.current=null},500));return}if(N.type==="projects_updated"){if(N.changedFile&&y&&g){const Xt=N.changedFile.replace(/\\/g,"/").split("/"),ht=Xt[Xt.length-1]||"",kt=ht.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]||ht.replace(".jsonl","");(N.changedSessionId||kt)===y.id&&(ge.has(y.id)||$(Gr=>Gr+1))}const j=Array.isArray(N.projects)?N.projects:[];h(lt=>cl(lt,j));const re=Ie.current,de=Me.current,Fe=re?j.find(lt=>lt.name===re.name):null;if(re&&!Fe&&!xe(de?.id)){b(null),k(null);return}const De=de&&ge.has(de.id)||ge.size>0&&Array.from(ge).some(lt=>lt.startsWith("new-session-")),at=N.affectedProjectName||null;if(!!!((at?pe.current.find(lt=>lt.name===at&&lt.detailsLoaded):null)&&N.requiresDetailsRefresh))return;const Mt=re?.name===at;if(De&&Mt)return;ze(at,{background:!0,force:!0})}}return()=>{te.current&&(clearTimeout(te.current),te.current=null)}},[ge,N,ze,rt,g,y,o,xe]),window.refreshProjects=(j={})=>Ve({background:!0,...j}),window.openSettings=l.useCallback((j="appearance")=>{Z(j),Ae(!0)},[]),l.useEffect(()=>{if(!o)return;const re=(y?.id||null)!==o;if(!Qe){Oe.current={sessionId:o,status:"error"},v("error");return}const de=`${o}::${we}`,Fe=R(o),De=Qd({projects:f,queryProject:_e,queryCwd:me}),at=(ht,kt,_t)=>{if(!ht||!kt)return!1;const Wt=f.find(Ut=>Ut.name===ht.name)||ht,br={...kt,__provider:_t||Qe,__projectName:Wt.name};return b(Ut=>Ut?.name===Wt.name?Ut:Wt),k(Ut=>Ut?.id===br.id&&Ut?.__provider===br.__provider&&Ut?.__projectName===br.__projectName?Ut:br),ze(Wt.name,{background:!0}),re&&I("chat"),Oe.current={sessionId:o,status:"resolved",resolutionKey:de},v("resolved"),!0},ut=rw(f,o,{provider:Qe,projectPath:_e||me||null});if(ut){at(ut.project,ut.session,ut.provider);return}if(nw({projects:f,queryProject:_e,queryCwd:me})){De?.name&&!F[De.name]&&ze(De.name,{background:!0}),Oe.current={sessionId:o,status:"awaiting-project-details",resolutionKey:de},v("awaiting-project-details");return}const At=De;if(At?(b(ht=>ht?.name===At.name?ht:At),k({id:o,title:"New Session",created_at:new Date().toISOString(),updated_at:new Date().toISOString(),__provider:Qe,__projectName:At.name}),re&&I("chat"),Oe.current={sessionId:o,status:"placeholder",resolutionKey:de},v("placeholder")):(b(null),k(null)),Fe||Oe.current.sessionId===o&&Oe.current.status==="resolving"&&Oe.current.resolutionKey===de)return;const Mt=A.current+1;A.current=Mt,Oe.current={sessionId:o,status:"resolving",resolutionKey:de},v("resolving");let lt=!1;return(async()=>{try{const ht=await st.resolveSession(Qe,o),kt=await ht.json().catch(()=>({}));if(lt||!lw({requestToken:Mt,activeRequestToken:A.current,pathname:e.pathname,provider:Qe,sessionId:o}))return;if(!ht.ok||!kt?.found||!kt?.project||!kt?.session){Oe.current={sessionId:o,status:"missing",resolutionKey:de},v("missing");return}if(kt?.provider)try{const br=localStorage.getItem("session-provider-map"),Ut=br?JSON.parse(br):{};Ut[o]=kt.provider,localStorage.setItem("session-provider-map",JSON.stringify(Ut))}catch{}if(!at(kt.project,kt.session,kt.provider||Qe))return;const Wt=sl({provider:kt.provider||Qe,sessionId:o},s),Gr=`${window.location.pathname}${window.location.search}`;Wt&&Wt!==Gr&&t(Wt,{replace:!0})}catch(ht){lt||(console.error("Error resolving session route:",ht),Oe.current={sessionId:o,status:"error",resolutionKey:de},v("error"))}})(),()=>{cw({activeResolution:Oe.current,sessionId:o,resolutionKey:de})&&(lt=!0)}},[R,ze,e.pathname,t,me,F,f,_e,Qe,s,we,y?.id,o]);const nt=j=>{oe(),b(j),k(null),ze(j.name,{background:!0}),_("/"),z&&ie(!1)},or=j=>{oe();let re=null;if(j.__projectName&&(re=pe.current.find(de=>de.name===j.__projectName)||null,re&&b(re)),k(j),P!=="git"&&P!=="preview"&&I("chat"),z){const de=j.__projectName,Fe=g?.name;de!==Fe&&ie(!1)}H({provider:j.__provider||j.provider||null,sessionId:j.id})},qt=j=>{if(oe(),j?.name&&typeof window<"u")try{localStorage.removeItem(`chat_messages_${j.name}`),localStorage.removeItem(`draft_input_${j.name}`)}catch(re){console.warn("Failed to clear local chat cache for new session:",re)}b(j),k(null),T(re=>re+1),I("chat"),_("/"),z&&ie(!1)},ee=j=>{y?.id===j&&(oe(),k(null),_("/")),h(re=>re.map(de=>({...de,sessions:de.sessions?.filter(Fe=>Fe.id!==j)||[],codexSessions:de.codexSessions?.filter(Fe=>Fe.id!==j)||[],geminiSessions:de.geminiSessions?.filter(Fe=>Fe.id!==j)||[],opencodeSessions:de.opencodeSessions?.filter(Fe=>Fe.id!==j)||[],sessionMeta:de.sessionMeta?{...de.sessionMeta,total:Math.max(0,(de.sessionMeta?.total||0)-1)}:de.sessionMeta})))},Lt=async()=>{try{await Ve({background:!0});const j=Array.from(new Set([...pe.current.filter(re=>re.detailsLoaded).map(re=>re.name),Ie.current?.name||null].filter(Boolean)));await Promise.all(j.map(re=>ze(re,{background:!0,force:!0})))}catch(j){console.error("Error refreshing sidebar:",j)}},Ot=j=>{g?.name===j&&(oe(),b(null),k(null),_("/")),h(re=>re.filter(de=>de.name!==j))},Kt=l.useCallback((j,re)=>{h(de=>de.map(Fe=>Fe.name===j?{...Fe,displayName:re,isCustomName:!0}:Fe)),b(de=>!de||de.name!==j?de:{...de,displayName:re,isCustomName:!0})},[]),vr=l.useCallback(j=>{j&&Le(re=>new Set([...re,j]))},[]),Vt=l.useCallback(j=>{j&&Le(re=>{const de=new Set(re);return de.delete(j),de})},[]),gt=l.useCallback(j=>{j&&Re(re=>new Set([...re,j]))},[]),cr=l.useCallback(j=>{j&&Re(re=>{const de=new Set(re);return de.delete(j),de})},[]),Ar=l.useCallback((j,re=null)=>{j&&(Le(de=>{const Fe=new Set;for(const De of de)re&&De===re||De.startsWith("new-session-")||Fe.add(De);return Fe.add(j),Fe}),Re(de=>{const Fe=new Set;for(const De of de)re&&De===re||De.startsWith("new-session-")||Fe.add(De);return Fe.add(j),Fe}))},[]),Vr=()=>{const{t:j}=St("common"),[re,de]=l.useState(!1),[Fe,De]=l.useState(""),[at,ut]=l.useState("");if(!m)return null;const At=lt=>lt?lt.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,`
450
+
451
+ `).trim():"",Mt=async()=>{de(!0),De(`Starting update...
452
+ `),ut("");try{const lt=await fe("/api/system/update",{method:"POST"}),Xt=await lt.json();lt.ok?(De(ht=>ht+Xt.output+`
453
+ `),De(ht=>ht+`
454
+ ✅ Update completed successfully!
455
+ `),De(ht=>ht+`Please restart the server to apply changes.
456
+ `)):(ut(Xt.error||"Update failed"),De(ht=>ht+`
457
+ ❌ Update failed: `+(Xt.error||"Unknown error")+`
458
+ `))}catch(lt){ut(lt.message),De(Xt=>Xt+`
459
+ ❌ Update failed: `+lt.message+`
460
+ `)}finally{de(!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:()=>p(!1),"aria-label":j("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:j("versionUpdate.title")}),r.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:u?.title||j("versionUpdate.newVersionReady")})]})]}),r.jsx("button",{onClick:()=>p(!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:j("versionUpdate.currentVersion")}),r.jsx("span",{className:"text-sm text-gray-900 dark:text-white font-mono",children:d})]}),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:j("versionUpdate.latestVersion")}),r.jsx("span",{className:"text-sm text-primary font-mono",children:c})]})]}),u?.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:j("versionUpdate.whatsNew")}),u?.htmlUrl&&r.jsxs("a",{href:u.htmlUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:text-primary hover:underline flex items-center gap-1",children:[j("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:At(u.body)})})]}),Fe&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:j("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:Fe})})]}),!re&&!Fe&&r.jsxs("div",{className:"space-y-3",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:j("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:j("versionUpdate.manualUpgradeHint")})]}),r.jsxs("div",{className:"flex gap-2 pt-2",children:[r.jsx("button",{onClick:()=>p(!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:j(Fe?"versionUpdate.buttons.close":"versionUpdate.buttons.later")}),!Fe&&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:j("versionUpdate.buttons.copyCommand")}),r.jsx("button",{onClick:Mt,disabled:re,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:re?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),j("versionUpdate.buttons.updating")]}):j("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:[!z&&r.jsx("div",{className:`chat-sidebar h-full flex-shrink-0 overflow-hidden transition-all duration-300 ${qe?"w-[22rem]":"w-[4.25rem]"}`,children:r.jsx("div",{className:"h-full overflow-hidden",children:qe?r.jsx(Za,{projects:f,selectedProject:g,selectedSession:y,onProjectSelect:nt,onProjectRename:Kt,onSessionSelect:or,onNewSession:qt,onSessionDelete:ee,onProjectDelete:Ot,isLoading:U,projectDetailsLoading:F,loadingProgress:V,onProjectExpand:ze,onRefresh:Lt,onShowSettings:()=>Ae(!0),updateAvailable:i,latestVersion:c,currentVersion:d,releaseInfo:u,onShowVersionModal:()=>p(!0),isPWA:Ge,isMobile:z,onToggleSidebar:()=>et(!1),lockedProjectName:Rt,showNewProject:Ke,setShowNewProject:Xe}):r.jsxs("div",{className:"h-full flex flex-col items-center gap-3 py-4",children:[r.jsx("button",{onClick:()=>et(!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":a("versionUpdate.ariaLabels.showSidebar"),title:a("versionUpdate.ariaLabels.showSidebar"),children:r.jsx(en,{className:"w-4 h-4 text-foreground"})}),i&&r.jsxs("button",{onClick:()=>p(!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":a("versionUpdate.ariaLabels.updateAvailable"),title:a("versionUpdate.ariaLabels.updateAvailable"),children:[r.jsx(Qs,{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"})]})]})})}),z&&r.jsxs("div",{className:`fixed inset-0 z-50 flex transition-all duration-150 ease-out ${se?"opacity-100 visible":"opacity-0 invisible"}`,children:[r.jsx("button",{className:"fixed inset-0 bg-black/40 transition-opacity duration-150 ease-out",onClick:j=>{j.stopPropagation(),ie(!1)},onTouchStart:j=>{j.preventDefault(),j.stopPropagation(),ie(!1)},"aria-label":a("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 ${se?"translate-x-0":"-translate-x-full"}`,onClick:j=>j.stopPropagation(),onTouchStart:j=>j.stopPropagation(),children:r.jsx(Za,{projects:f,selectedProject:g,selectedSession:y,onProjectSelect:nt,onProjectRename:Kt,onSessionSelect:or,onNewSession:qt,onSessionDelete:ee,onProjectDelete:Ot,isLoading:U,projectDetailsLoading:F,loadingProgress:V,onProjectExpand:ze,onRefresh:Lt,onShowSettings:()=>Ae(!0),updateAvailable:i,latestVersion:c,currentVersion:d,releaseInfo:u,onShowVersionModal:()=>p(!0),isPWA:Ge,isMobile:z,onToggleSidebar:()=>et(!1),lockedProjectName:Rt,showNewProject:Ke,setShowNewProject:Xe})})]}),r.jsx("div",{className:"chat-shell flex-1 flex min-w-0 flex-col overflow-hidden ",children:r.jsx(Fb,{selectedProject:g,selectedSession:y,activeTab:P,setActiveTab:I,ws:Be,sendMessage:ot,latestMessage:N,isMobile:z,isPWA:Ge,onMenuClick:()=>ie(!0),isLoading:iw({isLoadingProjects:U,hasSelectedProject:!!g,hasSessionRoute:!!o,sessionRouteStatus:q}),onInputFocusChange:ue,onSessionActive:vr,onSessionInactive:Vt,onSessionProcessing:gt,onSessionNotProcessing:cr,processingSessions:rt,onReplaceTemporarySession:Ar,onNavigateToSession:(j,re=null)=>{H({provider:re||Me.current?.__provider||localStorage.getItem("selected-provider")||"claude",sessionId:j})},onShowSettings:()=>Ae(!0),autoExpandTools:ye,showRawParameters:ne,showThinking:We,autoScrollToBottom:tt,sendByCtrlEnter:je,externalMessageUpdate:C,urlContext:ft,urlPrompt:Et,integrationClientId:yt,latestIntegrationMessage:Ee,sendIntegrationMessage:M,onShowNewProject:()=>Xe(!0),onNewSession:qt,newSessionResetNonce:L})}),S,P==="chat"&&r.jsx(Wb,{isOpen:ae,onToggle:be,autoExpandTools:ye,onAutoExpandChange:ke,showRawParameters:ne,onShowRawParametersChange:Se,showThinking:We,onShowThinkingChange:ve,autoScrollToBottom:tt,onAutoScrollChange:$e,sendByCtrlEnter:je,onSendByCtrlEnterChange:Te,isMobile:z}),r.jsx(zb,{isOpen:G,onClose:()=>Ae(!1),projects:f,initialTab:O}),r.jsx(Vr,{})]})}function Sw(){return r.jsx(Hp,{i18n:Yp,children:r.jsx(qp,{children:r.jsx(Ub,{children:r.jsx(Vb,{children:r.jsx(Xb,{children:r.jsx(np,{basename:window.__ROUTER_BASENAME__||"",children:r.jsxs(op,{children:[r.jsx(qo,{path:"/",element:r.jsx(dl,{})}),r.jsx(qo,{path:"/session/:provider/:sessionId",element:r.jsx(dl,{})}),r.jsx(qo,{path:"/review",element:r.jsx(Kp,{})})]})})})})})})})}export{Sw as default};