@axhub/genie 0.2.8 → 0.2.10

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 (106) hide show
  1. package/LICENSE +21 -675
  2. package/dist/api-docs.html +2 -2
  3. package/dist/assets/App-CYCCsgwf.js +264 -0
  4. package/dist/assets/ReviewApp-0srHIXwb.js +1 -0
  5. package/dist/assets/{_basePickBy-CqJbRZ9y.js → _basePickBy-DVVb07UV.js} +1 -1
  6. package/dist/assets/{_baseUniq-BS8YH8jO.js → _baseUniq-BtbziL5G.js} +1 -1
  7. package/dist/assets/{arc-BBmKEN-S.js → arc-BsCC8yBD.js} +1 -1
  8. package/dist/assets/{architectureDiagram-2XIMDMQ5-N5lcb82R.js → architectureDiagram-2XIMDMQ5-woFp6eNI.js} +1 -1
  9. package/dist/assets/{blockDiagram-WCTKOSBZ-DTMwHuLn.js → blockDiagram-WCTKOSBZ-ya8VAc2k.js} +1 -1
  10. package/dist/assets/{c4Diagram-IC4MRINW-BTKlkXI9.js → c4Diagram-IC4MRINW-CY1dZmIZ.js} +1 -1
  11. package/dist/assets/channel-BMhScXFe.js +1 -0
  12. package/dist/assets/{chunk-4BX2VUAB-DUdoTxAc.js → chunk-4BX2VUAB-CR1lAd74.js} +1 -1
  13. package/dist/assets/{chunk-55IACEB6-Bm_92xe4.js → chunk-55IACEB6-CP98WcFC.js} +1 -1
  14. package/dist/assets/{chunk-FMBD7UC4-CGW0g62g.js → chunk-FMBD7UC4-D9c7ijAB.js} +1 -1
  15. package/dist/assets/{chunk-JSJVCQXG-DYkTH3w1.js → chunk-JSJVCQXG-DQAGYOn-.js} +1 -1
  16. package/dist/assets/{chunk-KX2RTZJC-C9oTlISU.js → chunk-KX2RTZJC-BbTXiDq7.js} +1 -1
  17. package/dist/assets/{chunk-NQ4KR5QH-CM50ygWP.js → chunk-NQ4KR5QH-BI6AX0dr.js} +1 -1
  18. package/dist/assets/{chunk-QZHKN3VN-7dzpYeNJ.js → chunk-QZHKN3VN-DB3V2Ifo.js} +1 -1
  19. package/dist/assets/{chunk-WL4C6EOR-Cm9nQrsr.js → chunk-WL4C6EOR-DhzTthv6.js} +1 -1
  20. package/dist/assets/classDiagram-VBA2DB6C-CMIxlWcT.js +1 -0
  21. package/dist/assets/classDiagram-v2-RAHNMMFH-CMIxlWcT.js +1 -0
  22. package/dist/assets/clone-BPqOt4r3.js +1 -0
  23. package/dist/assets/{cose-bilkent-S5V4N54A-Ccp_p0JZ.js → cose-bilkent-S5V4N54A-BQ09ZE2j.js} +1 -1
  24. package/dist/assets/{dagre-KLK3FWXG-fBwTLUp9.js → dagre-KLK3FWXG-Dc2ueD_R.js} +1 -1
  25. package/dist/assets/{diagram-E7M64L7V-CeNVmFUp.js → diagram-E7M64L7V-DP-LsQoL.js} +1 -1
  26. package/dist/assets/{diagram-IFDJBPK2-CtavyLGa.js → diagram-IFDJBPK2-Cg6r42cB.js} +1 -1
  27. package/dist/assets/{diagram-P4PSJMXO-CpQTjQwc.js → diagram-P4PSJMXO-aHsfoUZE.js} +1 -1
  28. package/dist/assets/{erDiagram-INFDFZHY-B8R5vwhd.js → erDiagram-INFDFZHY-qBXJ4aAz.js} +1 -1
  29. package/dist/assets/{flowDiagram-PKNHOUZH-BvkVVwIQ.js → flowDiagram-PKNHOUZH-D_13emJM.js} +1 -1
  30. package/dist/assets/{ganttDiagram-A5KZAMGK-DOu3hSNa.js → ganttDiagram-A5KZAMGK-BvIcOLwz.js} +1 -1
  31. package/dist/assets/{gitGraphDiagram-K3NZZRJ6-C7zT67YE.js → gitGraphDiagram-K3NZZRJ6-ad0vvNcU.js} +1 -1
  32. package/dist/assets/{graph-D11wiwHo.js → graph-CeJCMjan.js} +1 -1
  33. package/dist/assets/{highlighted-body-TPN3WLV5-Babpthg-.js → highlighted-body-TPN3WLV5-B_novwSz.js} +1 -1
  34. package/dist/assets/index-C514cLyb.js +2 -0
  35. package/dist/assets/index-h1DBl_g3.css +1 -0
  36. package/dist/assets/{infoDiagram-LFFYTUFH-BmA7IpQG.js → infoDiagram-LFFYTUFH-lOxAqb3m.js} +1 -1
  37. package/dist/assets/{ishikawaDiagram-PHBUUO56-BEquZd3E.js → ishikawaDiagram-PHBUUO56-DIr-51gj.js} +1 -1
  38. package/dist/assets/{journeyDiagram-4ABVD52K-BfemGz7f.js → journeyDiagram-4ABVD52K-CYcIW0ZU.js} +1 -1
  39. package/dist/assets/{kanban-definition-K7BYSVSG-CWja3mln.js → kanban-definition-K7BYSVSG-C1ZK616a.js} +1 -1
  40. package/dist/assets/{layout-BLUNf-PJ.js → layout-CI2RM-v6.js} +1 -1
  41. package/dist/assets/{linear-DukIV_Xv.js → linear-DE7bISck.js} +1 -1
  42. package/dist/assets/{mermaid-O7DHMXV3-SgtM28qI.js → mermaid-O7DHMXV3-XxAJo8EK.js} +6 -6
  43. package/dist/assets/{mindmap-definition-YRQLILUH-4UjqXITU.js → mindmap-definition-YRQLILUH-Dz6EFjmn.js} +1 -1
  44. package/dist/assets/{pieDiagram-SKSYHLDU-8AxqJd0M.js → pieDiagram-SKSYHLDU-DPpEzUed.js} +1 -1
  45. package/dist/assets/{quadrantDiagram-337W2JSQ-D60m8V8r.js → quadrantDiagram-337W2JSQ-xdoXNet7.js} +1 -1
  46. package/dist/assets/{requirementDiagram-Z7DCOOCP-zqh9jBVf.js → requirementDiagram-Z7DCOOCP-DUq8H3CL.js} +1 -1
  47. package/dist/assets/{sankeyDiagram-WA2Y5GQK-CDZILTLI.js → sankeyDiagram-WA2Y5GQK-CmqEUxRu.js} +1 -1
  48. package/dist/assets/{sequenceDiagram-2WXFIKYE-7BReFd0L.js → sequenceDiagram-2WXFIKYE-DhtXRNiH.js} +1 -1
  49. package/dist/assets/{stateDiagram-RAJIS63D-HPTVdIG4.js → stateDiagram-RAJIS63D-Dj0HOlbN.js} +1 -1
  50. package/dist/assets/stateDiagram-v2-FVOUBMTO-C9utf5gv.js +1 -0
  51. package/dist/assets/{timeline-definition-YZTLITO2-CTVllFgr.js → timeline-definition-YZTLITO2-DUuJzZB5.js} +1 -1
  52. package/dist/assets/{treemap-KZPCXAKY-BtyxboJZ.js → treemap-KZPCXAKY-DpYBQ0qr.js} +1 -1
  53. package/dist/assets/vendor-codemirror-CMHSJ_9p.js +9 -0
  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-DpePUyOd.js} +1 -1
  56. package/dist/assets/{xychartDiagram-JWTSCODW-eRk-39YO.js → xychartDiagram-JWTSCODW-Cfp1I4_U.js} +1 -1
  57. package/dist/index.html +5 -5
  58. package/package.json +8 -7
  59. package/server/acp-runtime/client.js +129 -16
  60. package/server/acp-runtime/index.js +54 -0
  61. package/server/acp-runtime/registry.js +2 -2
  62. package/server/acp-runtime/session-store.js +79 -5
  63. package/server/cli.js +55 -10
  64. package/server/database/db.js +20 -0
  65. package/server/external-agent/service.js +24 -6
  66. package/server/external-agent/ws.js +540 -27
  67. package/server/index.js +112 -151
  68. package/server/lan-access/core.js +79 -0
  69. package/server/lan-access/state.js +102 -0
  70. package/server/middleware/auth.js +57 -14
  71. package/server/projects.js +930 -667
  72. package/server/routes/auth.js +24 -4
  73. package/server/routes/cli-auth.js +21 -25
  74. package/server/routes/codex.js +84 -298
  75. package/server/routes/commands.js +322 -407
  76. package/server/routes/lan-access.js +231 -0
  77. package/server/routes/projects.js +154 -158
  78. package/server/routes/session-core.js +160 -91
  79. package/server/routes/settings.js +113 -99
  80. package/server/session-core/eventStore.js +60 -20
  81. package/server/session-core/providerAdapters.js +75 -38
  82. package/server/session-core/runtimeState.js +8 -0
  83. package/server/session-core/sessionListMerge.js +47 -0
  84. package/shared/conversationEvents.js +174 -15
  85. package/shared/modelConstants.js +79 -99
  86. package/dist/assets/App-CTKZtqB1.js +0 -460
  87. package/dist/assets/ReviewApp-DM6BNAzR.js +0 -1
  88. package/dist/assets/channel-1oJBvF-0.js +0 -1
  89. package/dist/assets/classDiagram-VBA2DB6C-d5TeKFM4.js +0 -1
  90. package/dist/assets/classDiagram-v2-RAHNMMFH-d5TeKFM4.js +0 -1
  91. package/dist/assets/clone-CinxIlEu.js +0 -1
  92. package/dist/assets/index-DFxzgWoO.js +0 -2
  93. package/dist/assets/index-YCFGDVKw.css +0 -1
  94. package/dist/assets/stateDiagram-v2-FVOUBMTO-DTUf5_gC.js +0 -1
  95. package/dist/assets/vendor-codemirror-Dz7_EqNA.js +0 -39
  96. package/server/_legacy-providers/README.md +0 -30
  97. package/server/_legacy-providers/claude-sdk.js +0 -956
  98. package/server/_legacy-providers/gemini-cli.js +0 -368
  99. package/server/_legacy-providers/openai-codex.js +0 -705
  100. package/server/_legacy-providers/opencode-cli.js +0 -674
  101. package/server/routes/git.js +0 -1110
  102. package/server/routes/mcp-utils.js +0 -48
  103. package/server/routes/mcp.js +0 -536
  104. package/server/routes/taskmaster.js +0 -1963
  105. package/server/utils/mcp-detector.js +0 -198
  106. package/server/utils/taskmaster-websocket.js +0 -129
@@ -0,0 +1,264 @@
1
+ import{j as n}from"./vendor-codemirror-CMHSJ_9p.js";import{a as i,c as ed,R as wt,d as Ur,g as ii,B as td,e as nd,f as yo,u as rd,h as od,i as sd,j as ad}from"./vendor-react-xmA_f8ig.js";import{bJ as Ge,bK as qn,bL as Fo,bM as ci,bN as He,bO as Xt,bP as fs,bQ as li,bR as ln,bS as di,bT as id,bU as cd,bV as wn,bW as ld,bX as dd,bY as ud,bZ as pd,b_ as md,b$ as fd,c0 as hd,c1 as xd,c2 as gd,c3 as vd,c4 as bt,c5 as ui,c6 as At,c7 as yn,c8 as yd,c9 as Ie,ca as Rt,cb as bo,cc as pi,cd as $o,ce as zo,cf as Bo,cg as Wr,ch as Uo,ci as Wo,cj as mi,ck as fi,cl as bd,cm as wd,cn as kd,co as jd,cp as Sd,cq as Nd,cr as Cd,cs as Ed,ct as _d,cu as Ad,cv as Id,cw as Td,cx as Pd,cy as Rd,cz as Md,cA as Dd,cB as Ld,cC as Od,cD as Fd,cE as Dn,cF as $d,cG as zd,cH as Bd,cI as Ud,I as Wd,T as Kd,U as qd,cJ as Vd}from"./mermaid-O7DHMXV3-XxAJo8EK.js";import{r as Hd,a as Gd,b as Jd}from"./vendor-xterm-DfaPXD3y.js";import{l as qs,i as Yd}from"./index-C514cLyb.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 Xd=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Qd=Ge("arrow-left",Xd);/**
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 Zd=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],eu=Ge("chevron-left",Zd);/**
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 tu=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],hi=Ge("chevron-right",tu);/**
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 nu=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Vs=Ge("circle-check-big",nu);/**
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 ru=[["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"}]],Sr=Ge("ellipsis",ru);/**
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 ou=[["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"}]],Kr=Ge("external-link",ou);/**
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 su=[["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"}]],au=Ge("eye",su);/**
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 iu=[["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"}]],cu=Ge("eye-off",iu);/**
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 lu=[["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"}]],du=Ge("file-pen-line",lu);/**
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 uu=[["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"}]],pu=Ge("file-plus-2",uu);/**
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 mu=[["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"}]],fu=Ge("file-search",mu);/**
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 hu=[["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"}]],nr=Ge("folder-open",hu);/**
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 xu=[["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"}]],An=Ge("folder-plus",xu);/**
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 gu=[["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"}]],wo=Ge("folder",gu);/**
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 vu=[["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"}]],yu=Ge("hard-drive",vu);/**
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 bu=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],Hs=Ge("key-round",bu);/**
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 wu=[["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"}]],xi=Ge("key",wu);/**
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 ku=[["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"}]],ju=Ge("languages",ku);/**
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 Su=[["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"}]],Gs=Ge("list-todo",Su);/**
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 Nu=[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]],Cu=Ge("lock-keyhole",Nu);/**
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 Eu=[["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"}]],_u=Ge("message-square-plus",Eu);/**
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 Au=[["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"}]],Ko=Ge("message-square",Au);/**
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 Iu=[["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"}]],Js=Ge("pen-line",Iu);/**
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 Tu=[["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"}]],Ys=Ge("pen",Tu);/**
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 Pu=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],ro=Ge("plus",Pu);/**
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 Ru=[["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"}]],Nr=Ge("qr-code",Ru);/**
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 Mu=[["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"}]],qr=Ge("refresh-cw",Mu);/**
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 Du=[["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"}]],Lu=Ge("settings",Du);/**
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 Ou=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],qo=Ge("shield-check",Ou);/**
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 Fu=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],$u=Ge("shield",Fu);/**
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 zu=[["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"}]],Bu=Ge("square-terminal",zu);/**
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 Uu=[["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"}]],Xs=Ge("star",Uu);/**
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 Wu=[["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"}]],Ku=Ge("sun",Wu);/**
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 qu=[["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"}]],Cn=Ge("trash-2",qu);/**
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 Vu=[["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"}]],Vr=Ge("triangle-alert",Vu);/**
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 Hu=[["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"}]],Gu=Ge("unlink",Hu);/**
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 Ju=[["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"}]],Yu=Ge("wifi",Ju);/**
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 Xu=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],$t=Ge("x",Xu);function Qu(e,t=[]){let r=[];function o(a,c){const l=i.createContext(c),d=r.length;r=[...r,c];const u=p=>{const{scope:f,children:g,...h}=p,_=f?.[e]?.[d]||l,y=i.useMemo(()=>h,Object.values(h));return n.jsx(_.Provider,{value:y,children:g})};u.displayName=a+"Provider";function m(p,f){const g=f?.[e]?.[d]||l,h=i.useContext(g);if(h)return h;if(c!==void 0)return c;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[u,m]}const s=()=>{const a=r.map(c=>i.createContext(c));return function(l){const d=l?.[e]||a;return i.useMemo(()=>({[`__scope${e}`]:{...l,[e]:d}}),[l,d])}};return s.scopeName=e,[o,Zu(s,...t)]}function Zu(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const o=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const c=o.reduce((l,{useScope:d,scopeName:u})=>{const p=d(a)[`__scope${u}`];return{...l,...p}},{});return i.useMemo(()=>({[`__scope${t.scopeName}`]:c}),[c])}};return r.scopeName=t.scopeName,r}function gi(e){const t=ep(e),r=i.forwardRef((o,s)=>{const{children:a,...c}=o,l=i.Children.toArray(a),d=l.find(np);if(d){const u=d.props.children,m=l.map(p=>p===d?i.Children.count(u)>1?i.Children.only(null):i.isValidElement(u)?u.props.children:null:p);return n.jsx(t,{...c,ref:s,children:i.isValidElement(u)?i.cloneElement(u,void 0,m):null})}return n.jsx(t,{...c,ref:s,children:a})});return r.displayName=`${e}.Slot`,r}function ep(e){const t=i.forwardRef((r,o)=>{const{children:s,...a}=r;if(i.isValidElement(s)){const c=op(s),l=rp(a,s.props);return s.type!==i.Fragment&&(l.ref=o?qn(o,c):c),i.cloneElement(s,l)}return i.Children.count(s)>1?i.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var tp=Symbol("radix.slottable");function np(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===tp}function rp(e,t){const r={...t};for(const o in t){const s=e[o],a=t[o];/^on[A-Z]/.test(o)?s&&a?r[o]=(...l)=>{const d=a(...l);return s(...l),d}:s&&(r[o]=s):o==="style"?r[o]={...s,...a}:o==="className"&&(r[o]=[s,a].filter(Boolean).join(" "))}return{...e,...r}}function op(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var sp=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],cr=sp.reduce((e,t)=>{const r=gi(`Primitive.${t}`),o=i.forwardRef((s,a)=>{const{asChild:c,...l}=s,d=c?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),n.jsx(d,{...l,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function ap(e,t){e&&ed.flushSync(()=>e.dispatchEvent(t))}function ip(e,t=[]){let r=[];function o(a,c){const l=i.createContext(c),d=r.length;r=[...r,c];const u=p=>{const{scope:f,children:g,...h}=p,_=f?.[e]?.[d]||l,y=i.useMemo(()=>h,Object.values(h));return n.jsx(_.Provider,{value:y,children:g})};u.displayName=a+"Provider";function m(p,f){const g=f?.[e]?.[d]||l,h=i.useContext(g);if(h)return h;if(c!==void 0)return c;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[u,m]}const s=()=>{const a=r.map(c=>i.createContext(c));return function(l){const d=l?.[e]||a;return i.useMemo(()=>({[`__scope${e}`]:{...l,[e]:d}}),[l,d])}};return s.scopeName=e,[o,cp(s,...t)]}function cp(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const o=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const c=o.reduce((l,{useScope:d,scopeName:u})=>{const p=d(a)[`__scope${u}`];return{...l,...p}},{});return i.useMemo(()=>({[`__scope${t.scopeName}`]:c}),[c])}};return r.scopeName=t.scopeName,r}function lp(e){const t=dp(e),r=i.forwardRef((o,s)=>{const{children:a,...c}=o,l=i.Children.toArray(a),d=l.find(pp);if(d){const u=d.props.children,m=l.map(p=>p===d?i.Children.count(u)>1?i.Children.only(null):i.isValidElement(u)?u.props.children:null:p);return n.jsx(t,{...c,ref:s,children:i.isValidElement(u)?i.cloneElement(u,void 0,m):null})}return n.jsx(t,{...c,ref:s,children:a})});return r.displayName=`${e}.Slot`,r}function dp(e){const t=i.forwardRef((r,o)=>{const{children:s,...a}=r;if(i.isValidElement(s)){const c=fp(s),l=mp(a,s.props);return s.type!==i.Fragment&&(l.ref=o?qn(o,c):c),i.cloneElement(s,l)}return i.Children.count(s)>1?i.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var up=Symbol("radix.slottable");function pp(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===up}function mp(e,t){const r={...t};for(const o in t){const s=e[o],a=t[o];/^on[A-Z]/.test(o)?s&&a?r[o]=(...l)=>{const d=a(...l);return s(...l),d}:s&&(r[o]=s):o==="style"?r[o]={...s,...a}:o==="className"&&(r[o]=[s,a].filter(Boolean).join(" "))}return{...e,...r}}function fp(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var hp=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],vi=hp.reduce((e,t)=>{const r=lp(`Primitive.${t}`),o=i.forwardRef((s,a)=>{const{asChild:c,...l}=s,d=c?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),n.jsx(d,{...l,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{}),ko="rovingFocusGroup.onEntryFocus",xp={bubbles:!1,cancelable:!0},lr="RovingFocusGroup",[Vo,yi,gp]=ci(lr),[vp,bi]=ip(lr,[gp]),[yp,bp]=vp(lr),wi=i.forwardRef((e,t)=>n.jsx(Vo.Provider,{scope:e.__scopeRovingFocusGroup,children:n.jsx(Vo.Slot,{scope:e.__scopeRovingFocusGroup,children:n.jsx(wp,{...e,ref:t})})}));wi.displayName=lr;var wp=i.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,orientation:o,loop:s=!1,dir:a,currentTabStopId:c,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:d,onEntryFocus:u,preventScrollOnEntryFocus:m=!1,...p}=e,f=i.useRef(null),g=Xt(t,f),h=fs(a),[_,y]=li({prop:c,defaultProp:l??null,onChange:d,caller:lr}),[C,B]=i.useState(!1),U=ln(u),Q=yi(r),F=i.useRef(!1),[M,E]=i.useState(0);return i.useEffect(()=>{const $=f.current;if($)return $.addEventListener(ko,U),()=>$.removeEventListener(ko,U)},[U]),n.jsx(yp,{scope:r,orientation:o,dir:h,loop:s,currentTabStopId:_,onItemFocus:i.useCallback($=>y($),[y]),onItemShiftTab:i.useCallback(()=>B(!0),[]),onFocusableItemAdd:i.useCallback(()=>E($=>$+1),[]),onFocusableItemRemove:i.useCallback(()=>E($=>$-1),[]),children:n.jsx(vi.div,{tabIndex:C||M===0?-1:0,"data-orientation":o,...p,ref:g,style:{outline:"none",...e.style},onMouseDown:He(e.onMouseDown,()=>{F.current=!0}),onFocus:He(e.onFocus,$=>{const D=!F.current;if($.target===$.currentTarget&&D&&!C){const j=new CustomEvent(ko,xp);if($.currentTarget.dispatchEvent(j),!j.defaultPrevented){const le=Q().filter(re=>re.focusable),te=le.find(re=>re.active),X=le.find(re=>re.id===_),ae=[te,X,...le].filter(Boolean).map(re=>re.ref.current);Si(ae,m)}}F.current=!1}),onBlur:He(e.onBlur,()=>B(!1))})})}),ki="RovingFocusGroupItem",ji=i.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,focusable:o=!0,active:s=!1,tabStopId:a,children:c,...l}=e,d=Fo(),u=a||d,m=bp(ki,r),p=m.currentTabStopId===u,f=yi(r),{onFocusableItemAdd:g,onFocusableItemRemove:h,currentTabStopId:_}=m;return i.useEffect(()=>{if(o)return g(),()=>h()},[o,g,h]),n.jsx(Vo.ItemSlot,{scope:r,id:u,focusable:o,active:s,children:n.jsx(vi.span,{tabIndex:p?0:-1,"data-orientation":m.orientation,...l,ref:t,onMouseDown:He(e.onMouseDown,y=>{o?m.onItemFocus(u):y.preventDefault()}),onFocus:He(e.onFocus,()=>m.onItemFocus(u)),onKeyDown:He(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){m.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const C=Sp(y,m.orientation,m.dir);if(C!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let U=f().filter(Q=>Q.focusable).map(Q=>Q.ref.current);if(C==="last")U.reverse();else if(C==="prev"||C==="next"){C==="prev"&&U.reverse();const Q=U.indexOf(y.currentTarget);U=m.loop?Np(U,Q+1):U.slice(Q+1)}setTimeout(()=>Si(U))}}),children:typeof c=="function"?c({isCurrentTabStop:p,hasTabStop:_!=null}):c})})});ji.displayName=ki;var kp={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function jp(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Sp(e,t,r){const o=jp(e.key,r);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return kp[o]}function Si(e,t=!1){const r=document.activeElement;for(const o of e)if(o===r||(o.focus({preventScroll:t}),document.activeElement!==r))return}function Np(e,t){return e.map((r,o)=>e[(t+o)%e.length])}var Cp=wi,Ep=ji,Ho=["Enter"," "],_p=["ArrowDown","PageUp","Home"],Ni=["ArrowUp","PageDown","End"],Ap=[..._p,...Ni],Ip={ltr:[...Ho,"ArrowRight"],rtl:[...Ho,"ArrowLeft"]},Tp={ltr:["ArrowLeft"],rtl:["ArrowRight"]},dr="Menu",[or,Pp,Rp]=ci(dr),[Ln,Ci]=Qu(dr,[Rp,di,bi]),oo=di(),Ei=bi(),[Mp,On]=Ln(dr),[Dp,ur]=Ln(dr),_i=e=>{const{__scopeMenu:t,open:r=!1,children:o,dir:s,onOpenChange:a,modal:c=!0}=e,l=oo(t),[d,u]=i.useState(null),m=i.useRef(!1),p=ln(a),f=fs(s);return i.useEffect(()=>{const g=()=>{m.current=!0,document.addEventListener("pointerdown",h,{capture:!0,once:!0}),document.addEventListener("pointermove",h,{capture:!0,once:!0})},h=()=>m.current=!1;return document.addEventListener("keydown",g,{capture:!0}),()=>{document.removeEventListener("keydown",g,{capture:!0}),document.removeEventListener("pointerdown",h,{capture:!0}),document.removeEventListener("pointermove",h,{capture:!0})}},[]),n.jsx(id,{...l,children:n.jsx(Mp,{scope:t,open:r,onOpenChange:p,content:d,onContentChange:u,children:n.jsx(Dp,{scope:t,onClose:i.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:m,dir:f,modal:c,children:o})})})};_i.displayName=dr;var Lp="MenuAnchor",hs=i.forwardRef((e,t)=>{const{__scopeMenu:r,...o}=e,s=oo(r);return n.jsx(cd,{...s,...o,ref:t})});hs.displayName=Lp;var xs="MenuPortal",[Op,Ai]=Ln(xs,{forceMount:void 0}),Ii=e=>{const{__scopeMenu:t,forceMount:r,children:o,container:s}=e,a=On(xs,t);return n.jsx(Op,{scope:t,forceMount:r,children:n.jsx(wn,{present:r||a.open,children:n.jsx(ld,{asChild:!0,container:s,children:o})})})};Ii.displayName=xs;var Yt="MenuContent",[Fp,gs]=Ln(Yt),Ti=i.forwardRef((e,t)=>{const r=Ai(Yt,e.__scopeMenu),{forceMount:o=r.forceMount,...s}=e,a=On(Yt,e.__scopeMenu),c=ur(Yt,e.__scopeMenu);return n.jsx(or.Provider,{scope:e.__scopeMenu,children:n.jsx(wn,{present:o||a.open,children:n.jsx(or.Slot,{scope:e.__scopeMenu,children:c.modal?n.jsx($p,{...s,ref:t}):n.jsx(zp,{...s,ref:t})})})})}),$p=i.forwardRef((e,t)=>{const r=On(Yt,e.__scopeMenu),o=i.useRef(null),s=Xt(t,o);return i.useEffect(()=>{const a=o.current;if(a)return dd(a)},[]),n.jsx(vs,{...e,ref:s,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:He(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),zp=i.forwardRef((e,t)=>{const r=On(Yt,e.__scopeMenu);return n.jsx(vs,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),Bp=gi("MenuContent.ScrollLock"),vs=i.forwardRef((e,t)=>{const{__scopeMenu:r,loop:o=!1,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:c,disableOutsidePointerEvents:l,onEntryFocus:d,onEscapeKeyDown:u,onPointerDownOutside:m,onFocusOutside:p,onInteractOutside:f,onDismiss:g,disableOutsideScroll:h,..._}=e,y=On(Yt,r),C=ur(Yt,r),B=oo(r),U=Ei(r),Q=Pp(r),[F,M]=i.useState(null),E=i.useRef(null),$=Xt(t,E,y.onContentChange),D=i.useRef(0),j=i.useRef(""),le=i.useRef(0),te=i.useRef(null),X=i.useRef("right"),Z=i.useRef(0),ae=h?pd:i.Fragment,re=h?{as:Bp,allowPinchZoom:!0}:void 0,de=q=>{const ye=j.current+q,fe=Q().filter(ke=>!ke.disabled),Te=document.activeElement,ee=fe.find(ke=>ke.ref.current===Te)?.textValue,J=fe.map(ke=>ke.textValue),be=Zp(J,ye,ee),Ce=fe.find(ke=>ke.textValue===be)?.ref.current;(function ke(he){j.current=he,window.clearTimeout(D.current),he!==""&&(D.current=window.setTimeout(()=>ke(""),1e3))})(ye),Ce&&setTimeout(()=>Ce.focus())};i.useEffect(()=>()=>window.clearTimeout(D.current),[]),ud();const ie=i.useCallback(q=>X.current===te.current?.side&&tm(q,te.current?.area),[]);return n.jsx(Fp,{scope:r,searchRef:j,onItemEnter:i.useCallback(q=>{ie(q)&&q.preventDefault()},[ie]),onItemLeave:i.useCallback(q=>{ie(q)||(E.current?.focus(),M(null))},[ie]),onTriggerLeave:i.useCallback(q=>{ie(q)&&q.preventDefault()},[ie]),pointerGraceTimerRef:le,onPointerGraceIntentChange:i.useCallback(q=>{te.current=q},[]),children:n.jsx(ae,{...re,children:n.jsx(md,{asChild:!0,trapped:s,onMountAutoFocus:He(a,q=>{q.preventDefault(),E.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:c,children:n.jsx(fd,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:u,onPointerDownOutside:m,onFocusOutside:p,onInteractOutside:f,onDismiss:g,children:n.jsx(Cp,{asChild:!0,...U,dir:C.dir,orientation:"vertical",loop:o,currentTabStopId:F,onCurrentTabStopIdChange:M,onEntryFocus:He(d,q=>{C.isUsingKeyboardRef.current||q.preventDefault()}),preventScrollOnEntryFocus:!0,children:n.jsx(hd,{role:"menu","aria-orientation":"vertical","data-state":Hi(y.open),"data-radix-menu-content":"",dir:C.dir,...B,..._,ref:$,style:{outline:"none",..._.style},onKeyDown:He(_.onKeyDown,q=>{const fe=q.target.closest("[data-radix-menu-content]")===q.currentTarget,Te=q.ctrlKey||q.altKey||q.metaKey,ee=q.key.length===1;fe&&(q.key==="Tab"&&q.preventDefault(),!Te&&ee&&de(q.key));const J=E.current;if(q.target!==J||!Ap.includes(q.key))return;q.preventDefault();const Ce=Q().filter(ke=>!ke.disabled).map(ke=>ke.ref.current);Ni.includes(q.key)&&Ce.reverse(),Xp(Ce)}),onBlur:He(e.onBlur,q=>{q.currentTarget.contains(q.target)||(window.clearTimeout(D.current),j.current="")}),onPointerMove:He(e.onPointerMove,sr(q=>{const ye=q.target,fe=Z.current!==q.clientX;if(q.currentTarget.contains(ye)&&fe){const Te=q.clientX>Z.current?"right":"left";X.current=Te,Z.current=q.clientX}}))})})})})})})});Ti.displayName=Yt;var Up="MenuGroup",ys=i.forwardRef((e,t)=>{const{__scopeMenu:r,...o}=e;return n.jsx(cr.div,{role:"group",...o,ref:t})});ys.displayName=Up;var Wp="MenuLabel",Pi=i.forwardRef((e,t)=>{const{__scopeMenu:r,...o}=e;return n.jsx(cr.div,{...o,ref:t})});Pi.displayName=Wp;var Hr="MenuItem",Qs="menu.itemSelect",so=i.forwardRef((e,t)=>{const{disabled:r=!1,onSelect:o,...s}=e,a=i.useRef(null),c=ur(Hr,e.__scopeMenu),l=gs(Hr,e.__scopeMenu),d=Xt(t,a),u=i.useRef(!1),m=()=>{const p=a.current;if(!r&&p){const f=new CustomEvent(Qs,{bubbles:!0,cancelable:!0});p.addEventListener(Qs,g=>o?.(g),{once:!0}),ap(p,f),f.defaultPrevented?u.current=!1:c.onClose()}};return n.jsx(Ri,{...s,ref:d,disabled:r,onClick:He(e.onClick,m),onPointerDown:p=>{e.onPointerDown?.(p),u.current=!0},onPointerUp:He(e.onPointerUp,p=>{u.current||p.currentTarget?.click()}),onKeyDown:He(e.onKeyDown,p=>{const f=l.searchRef.current!=="";r||f&&p.key===" "||Ho.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});so.displayName=Hr;var Ri=i.forwardRef((e,t)=>{const{__scopeMenu:r,disabled:o=!1,textValue:s,...a}=e,c=gs(Hr,r),l=Ei(r),d=i.useRef(null),u=Xt(t,d),[m,p]=i.useState(!1),[f,g]=i.useState("");return i.useEffect(()=>{const h=d.current;h&&g((h.textContent??"").trim())},[a.children]),n.jsx(or.ItemSlot,{scope:r,disabled:o,textValue:s??f,children:n.jsx(Ep,{asChild:!0,...l,focusable:!o,children:n.jsx(cr.div,{role:"menuitem","data-highlighted":m?"":void 0,"aria-disabled":o||void 0,"data-disabled":o?"":void 0,...a,ref:u,onPointerMove:He(e.onPointerMove,sr(h=>{o?c.onItemLeave(h):(c.onItemEnter(h),h.defaultPrevented||h.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:He(e.onPointerLeave,sr(h=>c.onItemLeave(h))),onFocus:He(e.onFocus,()=>p(!0)),onBlur:He(e.onBlur,()=>p(!1))})})})}),Kp="MenuCheckboxItem",Mi=i.forwardRef((e,t)=>{const{checked:r=!1,onCheckedChange:o,...s}=e;return n.jsx($i,{scope:e.__scopeMenu,checked:r,children:n.jsx(so,{role:"menuitemcheckbox","aria-checked":Gr(r)?"mixed":r,...s,ref:t,"data-state":ws(r),onSelect:He(s.onSelect,()=>o?.(Gr(r)?!0:!r),{checkForDefaultPrevented:!1})})})});Mi.displayName=Kp;var Di="MenuRadioGroup",[qp,Vp]=Ln(Di,{value:void 0,onValueChange:()=>{}}),Li=i.forwardRef((e,t)=>{const{value:r,onValueChange:o,...s}=e,a=ln(o);return n.jsx(qp,{scope:e.__scopeMenu,value:r,onValueChange:a,children:n.jsx(ys,{...s,ref:t})})});Li.displayName=Di;var Oi="MenuRadioItem",Fi=i.forwardRef((e,t)=>{const{value:r,...o}=e,s=Vp(Oi,e.__scopeMenu),a=r===s.value;return n.jsx($i,{scope:e.__scopeMenu,checked:a,children:n.jsx(so,{role:"menuitemradio","aria-checked":a,...o,ref:t,"data-state":ws(a),onSelect:He(o.onSelect,()=>s.onValueChange?.(r),{checkForDefaultPrevented:!1})})})});Fi.displayName=Oi;var bs="MenuItemIndicator",[$i,Hp]=Ln(bs,{checked:!1}),zi=i.forwardRef((e,t)=>{const{__scopeMenu:r,forceMount:o,...s}=e,a=Hp(bs,r);return n.jsx(wn,{present:o||Gr(a.checked)||a.checked===!0,children:n.jsx(cr.span,{...s,ref:t,"data-state":ws(a.checked)})})});zi.displayName=bs;var Gp="MenuSeparator",Bi=i.forwardRef((e,t)=>{const{__scopeMenu:r,...o}=e;return n.jsx(cr.div,{role:"separator","aria-orientation":"horizontal",...o,ref:t})});Bi.displayName=Gp;var Jp="MenuArrow",Ui=i.forwardRef((e,t)=>{const{__scopeMenu:r,...o}=e,s=oo(r);return n.jsx(xd,{...s,...o,ref:t})});Ui.displayName=Jp;var Yp="MenuSub",[Pv,Wi]=Ln(Yp),er="MenuSubTrigger",Ki=i.forwardRef((e,t)=>{const r=On(er,e.__scopeMenu),o=ur(er,e.__scopeMenu),s=Wi(er,e.__scopeMenu),a=gs(er,e.__scopeMenu),c=i.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:d}=a,u={__scopeMenu:e.__scopeMenu},m=i.useCallback(()=>{c.current&&window.clearTimeout(c.current),c.current=null},[]);return i.useEffect(()=>m,[m]),i.useEffect(()=>{const p=l.current;return()=>{window.clearTimeout(p),d(null)}},[l,d]),n.jsx(hs,{asChild:!0,...u,children:n.jsx(Ri,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":s.contentId,"data-state":Hi(r.open),...e,ref:qn(t,s.onTriggerChange),onClick:p=>{e.onClick?.(p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:He(e.onPointerMove,sr(p=>{a.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!r.open&&!c.current&&(a.onPointerGraceIntentChange(null),c.current=window.setTimeout(()=>{r.onOpenChange(!0),m()},100))})),onPointerLeave:He(e.onPointerLeave,sr(p=>{m();const f=r.content?.getBoundingClientRect();if(f){const g=r.content?.dataset.side,h=g==="right",_=h?-5:5,y=f[h?"left":"right"],C=f[h?"right":"left"];a.onPointerGraceIntentChange({area:[{x:p.clientX+_,y:p.clientY},{x:y,y:f.top},{x:C,y:f.top},{x:C,y:f.bottom},{x:y,y:f.bottom}],side:g}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(p),p.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:He(e.onKeyDown,p=>{const f=a.searchRef.current!=="";e.disabled||f&&p.key===" "||Ip[o.dir].includes(p.key)&&(r.onOpenChange(!0),r.content?.focus(),p.preventDefault())})})})});Ki.displayName=er;var qi="MenuSubContent",Vi=i.forwardRef((e,t)=>{const r=Ai(Yt,e.__scopeMenu),{forceMount:o=r.forceMount,...s}=e,a=On(Yt,e.__scopeMenu),c=ur(Yt,e.__scopeMenu),l=Wi(qi,e.__scopeMenu),d=i.useRef(null),u=Xt(t,d);return n.jsx(or.Provider,{scope:e.__scopeMenu,children:n.jsx(wn,{present:o||a.open,children:n.jsx(or.Slot,{scope:e.__scopeMenu,children:n.jsx(vs,{id:l.contentId,"aria-labelledby":l.triggerId,...s,ref:u,align:"start",side:c.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:m=>{c.isUsingKeyboardRef.current&&d.current?.focus(),m.preventDefault()},onCloseAutoFocus:m=>m.preventDefault(),onFocusOutside:He(e.onFocusOutside,m=>{m.target!==l.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:He(e.onEscapeKeyDown,m=>{c.onClose(),m.preventDefault()}),onKeyDown:He(e.onKeyDown,m=>{const p=m.currentTarget.contains(m.target),f=Tp[c.dir].includes(m.key);p&&f&&(a.onOpenChange(!1),l.trigger?.focus(),m.preventDefault())})})})})})});Vi.displayName=qi;function Hi(e){return e?"open":"closed"}function Gr(e){return e==="indeterminate"}function ws(e){return Gr(e)?"indeterminate":e?"checked":"unchecked"}function Xp(e){const t=document.activeElement;for(const r of e)if(r===t||(r.focus(),document.activeElement!==t))return}function Qp(e,t){return e.map((r,o)=>e[(t+o)%e.length])}function Zp(e,t,r){const s=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,a=r?e.indexOf(r):-1;let c=Qp(e,Math.max(a,0));s.length===1&&(c=c.filter(u=>u!==r));const d=c.find(u=>u.toLowerCase().startsWith(s.toLowerCase()));return d!==r?d:void 0}function em(e,t){const{x:r,y:o}=e;let s=!1;for(let a=0,c=t.length-1;a<t.length;c=a++){const l=t[a],d=t[c],u=l.x,m=l.y,p=d.x,f=d.y;m>o!=f>o&&r<(p-u)*(o-m)/(f-m)+u&&(s=!s)}return s}function tm(e,t){if(!t)return!1;const r={x:e.clientX,y:e.clientY};return em(r,t)}function sr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var nm=_i,rm=hs,om=Ii,sm=Ti,am=ys,im=Pi,cm=so,lm=Mi,dm=Li,um=Fi,pm=zi,mm=Bi,fm=Ui,hm=Ki,xm=Vi;function gm(e,t=[]){let r=[];function o(a,c){const l=i.createContext(c),d=r.length;r=[...r,c];const u=p=>{const{scope:f,children:g,...h}=p,_=f?.[e]?.[d]||l,y=i.useMemo(()=>h,Object.values(h));return n.jsx(_.Provider,{value:y,children:g})};u.displayName=a+"Provider";function m(p,f){const g=f?.[e]?.[d]||l,h=i.useContext(g);if(h)return h;if(c!==void 0)return c;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[u,m]}const s=()=>{const a=r.map(c=>i.createContext(c));return function(l){const d=l?.[e]||a;return i.useMemo(()=>({[`__scope${e}`]:{...l,[e]:d}}),[l,d])}};return s.scopeName=e,[o,vm(s,...t)]}function vm(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const o=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const c=o.reduce((l,{useScope:d,scopeName:u})=>{const p=d(a)[`__scope${u}`];return{...l,...p}},{});return i.useMemo(()=>({[`__scope${t.scopeName}`]:c}),[c])}};return r.scopeName=t.scopeName,r}function ym(e){const t=bm(e),r=i.forwardRef((o,s)=>{const{children:a,...c}=o,l=i.Children.toArray(a),d=l.find(km);if(d){const u=d.props.children,m=l.map(p=>p===d?i.Children.count(u)>1?i.Children.only(null):i.isValidElement(u)?u.props.children:null:p);return n.jsx(t,{...c,ref:s,children:i.isValidElement(u)?i.cloneElement(u,void 0,m):null})}return n.jsx(t,{...c,ref:s,children:a})});return r.displayName=`${e}.Slot`,r}function bm(e){const t=i.forwardRef((r,o)=>{const{children:s,...a}=r;if(i.isValidElement(s)){const c=Sm(s),l=jm(a,s.props);return s.type!==i.Fragment&&(l.ref=o?qn(o,c):c),i.cloneElement(s,l)}return i.Children.count(s)>1?i.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var wm=Symbol("radix.slottable");function km(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===wm}function jm(e,t){const r={...t};for(const o in t){const s=e[o],a=t[o];/^on[A-Z]/.test(o)?s&&a?r[o]=(...l)=>{const d=a(...l);return s(...l),d}:s&&(r[o]=s):o==="style"?r[o]={...s,...a}:o==="className"&&(r[o]=[s,a].filter(Boolean).join(" "))}return{...e,...r}}function Sm(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var Nm=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Cm=Nm.reduce((e,t)=>{const r=ym(`Primitive.${t}`),o=i.forwardRef((s,a)=>{const{asChild:c,...l}=s,d=c?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),n.jsx(d,{...l,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{}),ao="DropdownMenu",[Em,Rv]=gm(ao,[Ci]),Dt=Ci(),[_m,Gi]=Em(ao),Ji=e=>{const{__scopeDropdownMenu:t,children:r,dir:o,open:s,defaultOpen:a,onOpenChange:c,modal:l=!0}=e,d=Dt(t),u=i.useRef(null),[m,p]=li({prop:s,defaultProp:a??!1,onChange:c,caller:ao});return n.jsx(_m,{scope:t,triggerId:Fo(),triggerRef:u,contentId:Fo(),open:m,onOpenChange:p,onOpenToggle:i.useCallback(()=>p(f=>!f),[p]),modal:l,children:n.jsx(nm,{...d,open:m,onOpenChange:p,dir:o,modal:l,children:r})})};Ji.displayName=ao;var Yi="DropdownMenuTrigger",Xi=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,disabled:o=!1,...s}=e,a=Gi(Yi,r),c=Dt(r);return n.jsx(rm,{asChild:!0,...c,children:n.jsx(Cm.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:qn(t,a.triggerRef),onPointerDown:He(e.onPointerDown,l=>{!o&&l.button===0&&l.ctrlKey===!1&&(a.onOpenToggle(),a.open||l.preventDefault())}),onKeyDown:He(e.onKeyDown,l=>{o||(["Enter"," "].includes(l.key)&&a.onOpenToggle(),l.key==="ArrowDown"&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(l.key)&&l.preventDefault())})})})});Xi.displayName=Yi;var Am="DropdownMenuPortal",Qi=e=>{const{__scopeDropdownMenu:t,...r}=e,o=Dt(t);return n.jsx(om,{...o,...r})};Qi.displayName=Am;var Zi="DropdownMenuContent",ec=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...o}=e,s=Gi(Zi,r),a=Dt(r),c=i.useRef(!1);return n.jsx(sm,{id:s.contentId,"aria-labelledby":s.triggerId,...a,...o,ref:t,onCloseAutoFocus:He(e.onCloseAutoFocus,l=>{c.current||s.triggerRef.current?.focus(),c.current=!1,l.preventDefault()}),onInteractOutside:He(e.onInteractOutside,l=>{const d=l.detail.originalEvent,u=d.button===0&&d.ctrlKey===!0,m=d.button===2||u;(!s.modal||m)&&(c.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)"}})});ec.displayName=Zi;var Im="DropdownMenuGroup",Tm=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...o}=e,s=Dt(r);return n.jsx(am,{...s,...o,ref:t})});Tm.displayName=Im;var Pm="DropdownMenuLabel",Rm=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...o}=e,s=Dt(r);return n.jsx(im,{...s,...o,ref:t})});Rm.displayName=Pm;var Mm="DropdownMenuItem",tc=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...o}=e,s=Dt(r);return n.jsx(cm,{...s,...o,ref:t})});tc.displayName=Mm;var Dm="DropdownMenuCheckboxItem",Lm=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...o}=e,s=Dt(r);return n.jsx(lm,{...s,...o,ref:t})});Lm.displayName=Dm;var Om="DropdownMenuRadioGroup",Fm=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...o}=e,s=Dt(r);return n.jsx(dm,{...s,...o,ref:t})});Fm.displayName=Om;var $m="DropdownMenuRadioItem",zm=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...o}=e,s=Dt(r);return n.jsx(um,{...s,...o,ref:t})});zm.displayName=$m;var Bm="DropdownMenuItemIndicator",Um=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...o}=e,s=Dt(r);return n.jsx(pm,{...s,...o,ref:t})});Um.displayName=Bm;var Wm="DropdownMenuSeparator",nc=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...o}=e,s=Dt(r);return n.jsx(mm,{...s,...o,ref:t})});nc.displayName=Wm;var Km="DropdownMenuArrow",qm=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...o}=e,s=Dt(r);return n.jsx(fm,{...s,...o,ref:t})});qm.displayName=Km;var Vm="DropdownMenuSubTrigger",Hm=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...o}=e,s=Dt(r);return n.jsx(hm,{...s,...o,ref:t})});Hm.displayName=Vm;var Gm="DropdownMenuSubContent",Jm=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...o}=e,s=Dt(r);return n.jsx(xm,{...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)"}})});Jm.displayName=Gm;var Cr=Ji,Er=Xi,_r=Qi,Ar=ec,an=tc,Zs=nc;function Ym(e){const t=Xm(e),r=i.forwardRef((o,s)=>{const{children:a,...c}=o,l=i.Children.toArray(a),d=l.find(Zm);if(d){const u=d.props.children,m=l.map(p=>p===d?i.Children.count(u)>1?i.Children.only(null):i.isValidElement(u)?u.props.children:null:p);return n.jsx(t,{...c,ref:s,children:i.isValidElement(u)?i.cloneElement(u,void 0,m):null})}return n.jsx(t,{...c,ref:s,children:a})});return r.displayName=`${e}.Slot`,r}function Xm(e){const t=i.forwardRef((r,o)=>{const{children:s,...a}=r;if(i.isValidElement(s)){const c=tf(s),l=ef(a,s.props);return s.type!==i.Fragment&&(l.ref=o?qn(o,c):c),i.cloneElement(s,l)}return i.Children.count(s)>1?i.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Qm=Symbol("radix.slottable");function Zm(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Qm}function ef(e,t){const r={...t};for(const o in t){const s=e[o],a=t[o];/^on[A-Z]/.test(o)?s&&a?r[o]=(...l)=>{const d=a(...l);return s(...l),d}:s&&(r[o]=s):o==="style"?r[o]={...s,...a}:o==="className"&&(r[o]=[s,a].filter(Boolean).join(" "))}return{...e,...r}}function tf(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var nf=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],pr=nf.reduce((e,t)=>{const r=Ym(`Primitive.${t}`),o=i.forwardRef((s,a)=>{const{asChild:c,...l}=s,d=c?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),n.jsx(d,{...l,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function rf(e,t=[]){let r=[];function o(a,c){const l=i.createContext(c),d=r.length;r=[...r,c];const u=p=>{const{scope:f,children:g,...h}=p,_=f?.[e]?.[d]||l,y=i.useMemo(()=>h,Object.values(h));return n.jsx(_.Provider,{value:y,children:g})};u.displayName=a+"Provider";function m(p,f){const g=f?.[e]?.[d]||l,h=i.useContext(g);if(h)return h;if(c!==void 0)return c;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[u,m]}const s=()=>{const a=r.map(c=>i.createContext(c));return function(l){const d=l?.[e]||a;return i.useMemo(()=>({[`__scope${e}`]:{...l,[e]:d}}),[l,d])}};return s.scopeName=e,[o,of(s,...t)]}function of(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const o=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const c=o.reduce((l,{useScope:d,scopeName:u})=>{const p=d(a)[`__scope${u}`];return{...l,...p}},{});return i.useMemo(()=>({[`__scope${t.scopeName}`]:c}),[c])}};return r.scopeName=t.scopeName,r}function sf(e,t){return i.useReducer((r,o)=>t[r][o]??r,e)}var ks="ScrollArea",[rc,Mv]=rf(ks),[af,Qt]=rc(ks),oc=i.forwardRef((e,t)=>{const{__scopeScrollArea:r,type:o="hover",dir:s,scrollHideDelay:a=600,...c}=e,[l,d]=i.useState(null),[u,m]=i.useState(null),[p,f]=i.useState(null),[g,h]=i.useState(null),[_,y]=i.useState(null),[C,B]=i.useState(0),[U,Q]=i.useState(0),[F,M]=i.useState(!1),[E,$]=i.useState(!1),D=Xt(t,le=>d(le)),j=fs(s);return n.jsx(af,{scope:r,type:o,dir:j,scrollHideDelay:a,scrollArea:l,viewport:u,onViewportChange:m,content:p,onContentChange:f,scrollbarX:g,onScrollbarXChange:h,scrollbarXEnabled:F,onScrollbarXEnabledChange:M,scrollbarY:_,onScrollbarYChange:y,scrollbarYEnabled:E,onScrollbarYEnabledChange:$,onCornerWidthChange:B,onCornerHeightChange:Q,children:n.jsx(pr.div,{dir:j,...c,ref:D,style:{position:"relative","--radix-scroll-area-corner-width":C+"px","--radix-scroll-area-corner-height":U+"px",...e.style}})})});oc.displayName=ks;var sc="ScrollAreaViewport",ac=i.forwardRef((e,t)=>{const{__scopeScrollArea:r,children:o,nonce:s,...a}=e,c=Qt(sc,r),l=i.useRef(null),d=Xt(t,l,c.onViewportChange);return n.jsxs(n.Fragment,{children:[n.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}),n.jsx(pr.div,{"data-radix-scroll-area-viewport":"",...a,ref:d,style:{overflowX:c.scrollbarXEnabled?"scroll":"hidden",overflowY:c.scrollbarYEnabled?"scroll":"hidden",...e.style},children:n.jsx("div",{ref:c.onContentChange,style:{minWidth:"100%",display:"table"},children:o})})]})});ac.displayName=sc;var un="ScrollAreaScrollbar",ic=i.forwardRef((e,t)=>{const{forceMount:r,...o}=e,s=Qt(un,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:c}=s,l=e.orientation==="horizontal";return i.useEffect(()=>(l?a(!0):c(!0),()=>{l?a(!1):c(!1)}),[l,a,c]),s.type==="hover"?n.jsx(cf,{...o,ref:t,forceMount:r}):s.type==="scroll"?n.jsx(lf,{...o,ref:t,forceMount:r}):s.type==="auto"?n.jsx(cc,{...o,ref:t,forceMount:r}):s.type==="always"?n.jsx(js,{...o,ref:t}):null});ic.displayName=un;var cf=i.forwardRef((e,t)=>{const{forceMount:r,...o}=e,s=Qt(un,e.__scopeScrollArea),[a,c]=i.useState(!1);return i.useEffect(()=>{const l=s.scrollArea;let d=0;if(l){const u=()=>{window.clearTimeout(d),c(!0)},m=()=>{d=window.setTimeout(()=>c(!1),s.scrollHideDelay)};return l.addEventListener("pointerenter",u),l.addEventListener("pointerleave",m),()=>{window.clearTimeout(d),l.removeEventListener("pointerenter",u),l.removeEventListener("pointerleave",m)}}},[s.scrollArea,s.scrollHideDelay]),n.jsx(wn,{present:r||a,children:n.jsx(cc,{"data-state":a?"visible":"hidden",...o,ref:t})})}),lf=i.forwardRef((e,t)=>{const{forceMount:r,...o}=e,s=Qt(un,e.__scopeScrollArea),a=e.orientation==="horizontal",c=co(()=>d("SCROLL_END"),100),[l,d]=sf("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 i.useEffect(()=>{if(l==="idle"){const u=window.setTimeout(()=>d("HIDE"),s.scrollHideDelay);return()=>window.clearTimeout(u)}},[l,s.scrollHideDelay,d]),i.useEffect(()=>{const u=s.viewport,m=a?"scrollLeft":"scrollTop";if(u){let p=u[m];const f=()=>{const g=u[m];p!==g&&(d("SCROLL"),c()),p=g};return u.addEventListener("scroll",f),()=>u.removeEventListener("scroll",f)}},[s.viewport,a,d,c]),n.jsx(wn,{present:r||l!=="hidden",children:n.jsx(js,{"data-state":l==="hidden"?"hidden":"visible",...o,ref:t,onPointerEnter:He(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:He(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),cc=i.forwardRef((e,t)=>{const r=Qt(un,e.__scopeScrollArea),{forceMount:o,...s}=e,[a,c]=i.useState(!1),l=e.orientation==="horizontal",d=co(()=>{if(r.viewport){const u=r.viewport.offsetWidth<r.viewport.scrollWidth,m=r.viewport.offsetHeight<r.viewport.scrollHeight;c(l?u:m)}},10);return Un(r.viewport,d),Un(r.content,d),n.jsx(wn,{present:o||a,children:n.jsx(js,{"data-state":a?"visible":"hidden",...s,ref:t})})}),js=i.forwardRef((e,t)=>{const{orientation:r="vertical",...o}=e,s=Qt(un,e.__scopeScrollArea),a=i.useRef(null),c=i.useRef(0),[l,d]=i.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=mc(l.viewport,l.content),m={...o,sizes:l,onSizesChange:d,hasThumb:u>0&&u<1,onThumbChange:f=>a.current=f,onThumbPointerUp:()=>c.current=0,onThumbPointerDown:f=>c.current=f};function p(f,g){return hf(f,c.current,l,g)}return r==="horizontal"?n.jsx(df,{...m,ref:t,onThumbPositionChange:()=>{if(s.viewport&&a.current){const f=s.viewport.scrollLeft,g=ea(f,l,s.dir);a.current.style.transform=`translate3d(${g}px, 0, 0)`}},onWheelScroll:f=>{s.viewport&&(s.viewport.scrollLeft=f)},onDragScroll:f=>{s.viewport&&(s.viewport.scrollLeft=p(f,s.dir))}}):r==="vertical"?n.jsx(uf,{...m,ref:t,onThumbPositionChange:()=>{if(s.viewport&&a.current){const f=s.viewport.scrollTop,g=ea(f,l);a.current.style.transform=`translate3d(0, ${g}px, 0)`}},onWheelScroll:f=>{s.viewport&&(s.viewport.scrollTop=f)},onDragScroll:f=>{s.viewport&&(s.viewport.scrollTop=p(f))}}):null}),df=i.forwardRef((e,t)=>{const{sizes:r,onSizesChange:o,...s}=e,a=Qt(un,e.__scopeScrollArea),[c,l]=i.useState(),d=i.useRef(null),u=Xt(t,d,a.onScrollbarXChange);return i.useEffect(()=>{d.current&&l(getComputedStyle(d.current))},[d]),n.jsx(dc,{"data-orientation":"horizontal",...s,ref:u,sizes:r,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(r)+"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),hc(f,p)&&m.preventDefault()}},onResize:()=>{d.current&&a.viewport&&c&&o({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:Yr(c.paddingLeft),paddingEnd:Yr(c.paddingRight)}})}})}),uf=i.forwardRef((e,t)=>{const{sizes:r,onSizesChange:o,...s}=e,a=Qt(un,e.__scopeScrollArea),[c,l]=i.useState(),d=i.useRef(null),u=Xt(t,d,a.onScrollbarYChange);return i.useEffect(()=>{d.current&&l(getComputedStyle(d.current))},[d]),n.jsx(dc,{"data-orientation":"vertical",...s,ref:u,sizes:r,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(r)+"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),hc(f,p)&&m.preventDefault()}},onResize:()=>{d.current&&a.viewport&&c&&o({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:Yr(c.paddingTop),paddingEnd:Yr(c.paddingBottom)}})}})}),[pf,lc]=rc(un),dc=i.forwardRef((e,t)=>{const{__scopeScrollArea:r,sizes:o,hasThumb:s,onThumbChange:a,onThumbPointerUp:c,onThumbPointerDown:l,onThumbPositionChange:d,onDragScroll:u,onWheelScroll:m,onResize:p,...f}=e,g=Qt(un,r),[h,_]=i.useState(null),y=Xt(t,D=>_(D)),C=i.useRef(null),B=i.useRef(""),U=g.viewport,Q=o.content-o.viewport,F=ln(m),M=ln(d),E=co(p,10);function $(D){if(C.current){const j=D.clientX-C.current.left,le=D.clientY-C.current.top;u({x:j,y:le})}}return i.useEffect(()=>{const D=j=>{const le=j.target;h?.contains(le)&&F(j,Q)};return document.addEventListener("wheel",D,{passive:!1}),()=>document.removeEventListener("wheel",D,{passive:!1})},[U,h,Q,F]),i.useEffect(M,[o,M]),Un(h,E),Un(g.content,E),n.jsx(pf,{scope:r,scrollbar:h,hasThumb:s,onThumbChange:ln(a),onThumbPointerUp:ln(c),onThumbPositionChange:M,onThumbPointerDown:ln(l),children:n.jsx(pr.div,{...f,ref:y,style:{position:"absolute",...f.style},onPointerDown:He(e.onPointerDown,D=>{D.button===0&&(D.target.setPointerCapture(D.pointerId),C.current=h.getBoundingClientRect(),B.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",g.viewport&&(g.viewport.style.scrollBehavior="auto"),$(D))}),onPointerMove:He(e.onPointerMove,$),onPointerUp:He(e.onPointerUp,D=>{const j=D.target;j.hasPointerCapture(D.pointerId)&&j.releasePointerCapture(D.pointerId),document.body.style.webkitUserSelect=B.current,g.viewport&&(g.viewport.style.scrollBehavior=""),C.current=null})})})}),Jr="ScrollAreaThumb",uc=i.forwardRef((e,t)=>{const{forceMount:r,...o}=e,s=lc(Jr,e.__scopeScrollArea);return n.jsx(wn,{present:r||s.hasThumb,children:n.jsx(mf,{ref:t,...o})})}),mf=i.forwardRef((e,t)=>{const{__scopeScrollArea:r,style:o,...s}=e,a=Qt(Jr,r),c=lc(Jr,r),{onThumbPositionChange:l}=c,d=Xt(t,p=>c.onThumbChange(p)),u=i.useRef(void 0),m=co(()=>{u.current&&(u.current(),u.current=void 0)},100);return i.useEffect(()=>{const p=a.viewport;if(p){const f=()=>{if(m(),!u.current){const g=xf(p,l);u.current=g,l()}};return l(),p.addEventListener("scroll",f),()=>p.removeEventListener("scroll",f)}},[a.viewport,m,l]),n.jsx(pr.div,{"data-state":c.hasThumb?"visible":"hidden",...s,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...o},onPointerDownCapture:He(e.onPointerDownCapture,p=>{const g=p.target.getBoundingClientRect(),h=p.clientX-g.left,_=p.clientY-g.top;c.onThumbPointerDown({x:h,y:_})}),onPointerUp:He(e.onPointerUp,c.onThumbPointerUp)})});uc.displayName=Jr;var Ss="ScrollAreaCorner",pc=i.forwardRef((e,t)=>{const r=Qt(Ss,e.__scopeScrollArea),o=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&o?n.jsx(ff,{...e,ref:t}):null});pc.displayName=Ss;var ff=i.forwardRef((e,t)=>{const{__scopeScrollArea:r,...o}=e,s=Qt(Ss,r),[a,c]=i.useState(0),[l,d]=i.useState(0),u=!!(a&&l);return Un(s.scrollbarX,()=>{const m=s.scrollbarX?.offsetHeight||0;s.onCornerHeightChange(m),d(m)}),Un(s.scrollbarY,()=>{const m=s.scrollbarY?.offsetWidth||0;s.onCornerWidthChange(m),c(m)}),u?n.jsx(pr.div,{...o,ref:t,style:{width:a,height:l,position:"absolute",right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Yr(e){return e?parseInt(e,10):0}function mc(e,t){const r=e/t;return isNaN(r)?0:r}function io(e){const t=mc(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,o=(e.scrollbar.size-r)*t;return Math.max(o,18)}function hf(e,t,r,o="ltr"){const s=io(r),a=s/2,c=t||a,l=s-c,d=r.scrollbar.paddingStart+c,u=r.scrollbar.size-r.scrollbar.paddingEnd-l,m=r.content-r.viewport,p=o==="ltr"?[0,m]:[m*-1,0];return fc([d,u],p)(e)}function ea(e,t,r="ltr"){const o=io(t),s=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-s,c=t.content-t.viewport,l=a-o,d=r==="ltr"?[0,c]:[c*-1,0],u=vd(e,d);return fc([0,c],[0,l])(u)}function fc(e,t){return r=>{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*(r-e[0])}}function hc(e,t){return e>0&&e<t}var xf=(e,t=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},o=0;return function s(){const a={left:e.scrollLeft,top:e.scrollTop},c=r.left!==a.left,l=r.top!==a.top;(c||l)&&t(),r=a,o=window.requestAnimationFrame(s)}(),()=>window.cancelAnimationFrame(o)};function co(e,t){const r=ln(e),o=i.useRef(0);return i.useEffect(()=>()=>window.clearTimeout(o.current),[]),i.useCallback(()=>{window.clearTimeout(o.current),o.current=window.setTimeout(r,t)},[r,t])}function Un(e,t){const r=ln(t);gd(()=>{let o=0;if(e){const s=new ResizeObserver(()=>{cancelAnimationFrame(o),o=window.requestAnimationFrame(r)});return s.observe(e),()=>{window.cancelAnimationFrame(o),s.unobserve(e)}}},[e,r])}var xc=oc,gf=ac,gc=ic,vf=uc,yf=pc;const vc=i.forwardRef(({className:e,orientation:t="vertical",...r},o)=>n.jsx(gc,{ref:o,orientation:t,className:bt("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),...r,children:n.jsx(vf,{className:"relative flex-1 rounded-full bg-border/80"})}));vc.displayName=gc.displayName;const yc=i.forwardRef(({className:e,children:t,...r},o)=>n.jsxs(xc,{ref:o,className:bt("relative overflow-hidden",e),...r,children:[n.jsx(gf,{className:"h-full w-full rounded-[inherit]",children:t}),n.jsx(vc,{}),n.jsx(yf,{})]}));yc.displayName=xc.displayName;const bn=i.forwardRef(({className:e,type:t,...r},o)=>n.jsx("input",{type:t,className:bt("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,...r}));bn.displayName="Input";const mr=({className:e="w-5 h-5"})=>n.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:e}),fr=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=ui();return n.jsx("img",{src:t?"/icons/codex-white.svg":"/icons/codex.svg",alt:"Codex",className:e})},hr=({className:e="w-5 h-5"})=>{const t=i.useId(),r=i.useId(),o=i.useId();return n.jsxs("svg",{"aria-label":"Gemini",className:e,role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("title",{children:"Gemini"}),n.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"}),n.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})`}),n.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(#${r})`}),n.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})`}),n.jsxs("defs",{children:[n.jsxs("linearGradient",{id:t,x1:"7",x2:"11",y1:"15.5",y2:"12",gradientUnits:"userSpaceOnUse",children:[n.jsx("stop",{stopColor:"#08B962"}),n.jsx("stop",{offset:"1",stopColor:"#08B962",stopOpacity:"0"})]}),n.jsxs("linearGradient",{id:r,x1:"8",x2:"11.5",y1:"5.5",y2:"11",gradientUnits:"userSpaceOnUse",children:[n.jsx("stop",{stopColor:"#F94543"}),n.jsx("stop",{offset:"1",stopColor:"#F94543",stopOpacity:"0"})]}),n.jsxs("linearGradient",{id:o,x1:"3.5",x2:"17.5",y1:"13.5",y2:"12",gradientUnits:"userSpaceOnUse",children:[n.jsx("stop",{stopColor:"#FABC12"}),n.jsx("stop",{offset:".46",stopColor:"#FABC12",stopOpacity:"0"})]})]})]})},xr=({className:e="h-5 w-auto",style:t,...r})=>n.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",...r,children:[n.jsx("title",{children:"OpenCode"}),n.jsx("rect",{x:"6",y:"2",width:"20",height:"20",rx:"5",fill:"currentColor"}),n.jsx("path",{d:"M20 6h-8v12h8V6zm4 16H8V2h16v20z",fill:"white"})]}),bf=!1;function wf(e,t,r={}){const{timeoutMs:o=null,signal:s,...a}=r,c=typeof AbortController=="function"?new AbortController:null;let l=null;c&&s&&(s.aborted?c.abort(s.reason):s.addEventListener("abort",()=>c.abort(s.reason),{once:!0})),c&&Number.isFinite(o)&&o>0&&(l=setTimeout(()=>{const u=new Error(`Request timed out after ${o}ms`);u.name="AbortError",c.abort(u)},o));const d=e(t,{...a,signal:c?.signal||s});return l?d.finally(()=>{clearTimeout(l)}):d}function ta(e){return e==="resolve"||e==="events"?2e4:null}function kf(){return localStorage.getItem("auth-token")}function jf(e,t={}){const r={...t};!(e instanceof FormData)&&!r["Content-Type"]&&(r["Content-Type"]="application/json");{const o=kf();o&&!r.Authorization&&(r.Authorization=`Bearer ${o}`)}return r}function Kt(e,t={}){const{timeoutMs:r=null,signal:o,headers:s,body:a,...c}=t;return wf(fetch,e,{...c,body:a,headers:jf(a,s),signal:o,timeoutMs:r})}function ut(e,t={}){return Kt(e,t)}function mn(e,t,r={}){return ut(e,{...r,method:"POST",body:JSON.stringify(t)})}function Sf(e,t,r={}){return ut(e,{...r,method:"PUT",body:JSON.stringify(t)})}function Yn(e,t={}){return ut(e,{...t,method:"DELETE"})}function fn(e,t){const r=new URLSearchParams;Object.entries(t||{}).forEach(([s,a])=>{a!=null&&a!==""&&r.set(s,String(a))});const o=r.toString();return o?`${e}?${o}`:e}const Ze={auth:{status:()=>fetch("/api/auth/status"),bootstrap:()=>fetch("/api/auth/bootstrap",{method:"POST",headers:{"Content-Type":"application/json"}}),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:()=>ut("/api/auth/user"),logout:()=>ut("/api/auth/logout",{method:"POST"})},lanAccess:{summary:()=>ut("/api/lan-access/summary"),updatePassword:e=>mn("/api/lan-access/password",{password:e}),createToken:e=>mn("/api/lan-access/token",{address:e}),login:e=>fetch("/api/lan-access/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:e})})},projects:()=>ut("/api/projects"),projectsList:()=>ut("/api/projects/list"),projectDetails:e=>ut(`/api/projects/${e}/details`),sessions:(e,t=5,r=0)=>ut(fn(`/api/projects/${e}/sessions`,{limit:t,offset:r})),historyIndex:e=>ut(`/api/session-core/projects/${e}/history-index`),providerDiscovery:(e,t=null)=>ut(fn(`/api/session-core/providers/${e}`,{projectPath:t})),providersDiscovery:(e=null)=>ut(fn("/api/session-core/providers",{projectPath:e})),sessionEvents:(e,t,r=null,o=null,s=null,a=0)=>ut(fn(`/api/session-core/sessions/${e}/${t}/events`,{projectName:r,projectPath:o,limit:s,offset:a}),{timeoutMs:ta("events")}),sessionMessages:(e,t,r=null,o=0,s="claude")=>ut(fn(`/api/session-core/sessions/${s}/${t}/events`,{projectName:e,limit:r,offset:o})),resolveSession:(e,t)=>ut(`/api/session-core/sessions/${e}/${t}/resolve`,{timeoutMs:ta("resolve")}),renameProject:(e,t)=>Sf(`/api/projects/${e}/rename`,{displayName:t}),deleteSession:(e,t)=>Yn(`/api/projects/${e}/sessions/${t}`),deleteCodexSession:e=>Yn(`/api/codex/sessions/${e}`),deleteOpencodeSession:e=>Yn(`/api/opencode/sessions/${e}`),deleteProject:(e,t=!1)=>Yn(fn(`/api/projects/${e}`,{force:t?"true":null})),createProject:e=>mn("/api/projects/create",{path:e}),createWorkspace:e=>mn("/api/projects/create-workspace",e),readFile:(e,t)=>ut(`/api/projects/${e}/file?filePath=${encodeURIComponent(t)}`),getFiles:e=>ut(`/api/projects/${e}/files`),transcribe:e=>ut("/api/transcribe",{method:"POST",body:e,headers:{}}),browseFilesystem:(e=null)=>ut(fn("/api/browse-filesystem",{path:e})),createFolder:e=>mn("/api/create-folder",{path:e}),ccConnect:{status:()=>ut("/api/cc-connect/status"),providers:()=>ut("/api/cc-connect/providers"),platforms:()=>ut("/api/cc-connect/platforms"),install:()=>ut("/api/cc-connect/install",{method:"POST"}),setup:(e,t)=>mn(`/api/cc-connect/${e}/setup`,t),sessionStatus:(e,t)=>ut(fn(`/api/cc-connect/${e}/status`,{sessionId:t})),refresh:(e,t)=>mn(`/api/cc-connect/${e}/refresh`,{sessionId:t}),cleanupSession:(e,t)=>Yn(fn(`/api/cc-connect/${e}/session`,{sessionId:t})),activeProvider:e=>ut(`/api/cc-connect/${e}/active-provider`),switchProvider:(e,t)=>mn(`/api/cc-connect/${e}/switch-provider`,{provider:t}),updateProject:(e,t)=>mn(`/api/cc-connect/${e}/project`,t),unbind:e=>ut(`/api/cc-connect/${e}/unbind`,{method:"POST"})},get:e=>ut(`/api${e}`)},na="__windows_drives__",Nf="__workspace_roots__",Cf=/^[A-Za-z]:\\?$/,Ef=({onClose:e,onProjectCreated:t})=>{const{t:r}=At(),[o,s]=i.useState(1),[a,c]=i.useState("existing"),[l,d]=i.useState(""),[u,m]=i.useState(!1),[p,f]=i.useState(null),[g,h]=i.useState([]),[_,y]=i.useState(!1),[C,B]=i.useState(!1),[U,Q]=i.useState("~"),[F,M]=i.useState("~"),[E,$]=i.useState([]),[D,j]=i.useState(!1),[le,te]=i.useState(!1),[X,Z]=i.useState(!1),[ae,re]=i.useState(""),[de,ie]=i.useState(!1),[q,ye]=i.useState(null),[fe,Te]=i.useState(null),[ee,J]=i.useState(!1),be=N=>{const L=N.trim();if(!L)return"~";if(L.endsWith("/")||L.endsWith("\\"))return L;if(/^[A-Za-z]:$/.test(L))return`${L}\\`;const ue=Math.max(L.lastIndexOf("/"),L.lastIndexOf("\\"));return ue>0?ue===2&&/^[A-Za-z]:/.test(L)?L.substring(0,3):L.substring(0,ue):"~"},Ce=fe==="windows-drives",ke=fe==="workspace-roots",he=!!fe,De=q==="win32"&&!ee,_e=ee,qe=!he,Ee=!he;i.useEffect(()=>{l.length>2?We(l):(h([]),y(!1))},[l]);const We=async N=>{try{const L=be(N),pe=await(await Ze.browseFilesystem(L)).json();if(pe.suggestions){const b=pe.suggestions.filter(T=>T.path.toLowerCase().startsWith(N.toLowerCase())&&T.path.toLowerCase()!==N.toLowerCase());h(b.slice(0,5)),y(b.length>0)}}catch(L){console.error("Error loading path suggestions:",L)}},Ue=()=>{if(f(null),o===1){if(!a){f(r("projectWizard.errors.selectType"));return}s(2)}else if(o===2){if(!l.trim()){f(r("projectWizard.errors.providePath"));return}s(3)}},Re=()=>{f(null),s(o-1)},at=async()=>{m(!0),f(null);try{const N={workspaceType:a,path:l.trim()},L=await Ze.createWorkspace(N),ue=await L.json();if(!L.ok)throw new Error(ue.details||ue.error||r("projectWizard.errors.failedToCreate"));t&&t(ue.project),e()}catch(N){console.error("Error creating workspace:",N),f(N.message||r("projectWizard.errors.failedToCreate"))}finally{m(!1)}},nt=N=>{d(N.path),y(!1)},Ke=async()=>{B(!0),await Fe()},Fe=async N=>{try{j(!0);const ue=await(await Ze.browseFilesystem(N)).json();Q(ue.path||N),M(ue.displayPath||ue.path||N),$(ue.suggestions||[]),ye(ue.platform||null),Te(ue.virtualRoot||null),J(!!ue.hasWorkspaceRootRestriction)}catch(L){console.error("Error loading folders:",L)}finally{j(!1)}},it=(N,L=!1)=>{!N||N===na||(d(N),B(!1),L&&s(3))},ze=async N=>{await Fe(N)},rt=async()=>{if(!(!ae.trim()||!Ee)){ie(!0),f(null);try{const N=U.includes("\\")?"\\":"/",L=U.endsWith(N)?`${U}${ae.trim()}`:`${U}${N}${ae.trim()}`,ue=await Ze.createFolder(L),pe=await ue.json();if(!ue.ok)throw new Error(pe.error||r("projectWizard.errors.failedToCreateFolder"));re(""),Z(!1),await Fe(pe.path||L)}catch(N){console.error("Error creating folder:",N),f(N.message||r("projectWizard.errors.failedToCreateFolder"))}finally{ie(!1)}}};return n.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:[n.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:[n.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-8 h-8 bg-primary/15 dark:bg-primary/30 rounded-lg flex items-center justify-center",children:n.jsx(An,{className:"w-4 h-4 text-primary"})}),n.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:r("projectWizard.title")})]}),n.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:n.jsx($t,{className:"w-5 h-5"})})]}),n.jsx("div",{className:"px-6 pt-4 pb-2",children:n.jsx("div",{className:"flex items-center justify-between",children:[1,2,3].map(N=>n.jsxs(wt.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center font-medium text-sm ${N<o?"bg-green-500 text-white":N===o?"bg-primary text-white":"bg-gray-200 dark:bg-gray-700 text-gray-500"}`,children:N<o?n.jsx(yn,{className:"w-4 h-4"}):N}),n.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 hidden sm:inline",children:r(N===1?"projectWizard.steps.type":N===2?"projectWizard.steps.configure":"projectWizard.steps.confirm")})]}),N<3&&n.jsx("div",{className:`flex-1 h-1 mx-2 rounded ${N<o?"bg-green-500":"bg-gray-200 dark:bg-gray-700"}`})]},N))})}),n.jsxs("div",{className:"p-6 space-y-6 min-h-[300px]",children:[p&&n.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:[n.jsx(yd,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),n.jsx("div",{className:"flex-1",children:n.jsx("p",{className:"text-sm text-red-800 dark:text-red-200",children:p})})]}),o===1&&n.jsx("div",{className:"space-y-4",children:n.jsxs("div",{children:[n.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:r("projectWizard.step1.question")}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.jsx("button",{onClick:()=>c("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:n.jsxs("div",{className:"flex items-start gap-3",children:[n.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:n.jsx(An,{className:"w-5 h-5 text-green-600 dark:text-green-400"})}),n.jsxs("div",{className:"flex-1",children:[n.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:r("projectWizard.step1.existing.title")}),n.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:r("projectWizard.step1.existing.description")})]})]})}),n.jsx("button",{onClick:()=>c("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:n.jsxs("div",{className:"flex items-start gap-3",children:[n.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:n.jsx(An,{className:"w-5 h-5 text-purple-600 dark:text-purple-400"})}),n.jsxs("div",{className:"flex-1",children:[n.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:r("projectWizard.step1.new.title")}),n.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:r("projectWizard.step1.new.description")})]})]})})]})]})}),o===2&&n.jsx("div",{className:"space-y-4",children:n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r(a==="existing"?"projectWizard.step2.existingPath":"projectWizard.step2.newPath")}),n.jsxs("div",{className:"relative flex gap-2",children:[n.jsxs("div",{className:"flex-1 relative",children:[n.jsx(bn,{type:"text",value:l,onChange:N=>d(N.target.value),placeholder:r(a==="existing"?"projectWizard.step2.existingPlaceholder":"projectWizard.step2.newPlaceholder"),className:"w-full"}),_&&g.length>0&&n.jsx("div",{className:"absolute z-10 w-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg max-h-60 overflow-y-auto",children:g.map((N,L)=>n.jsxs("button",{onClick:()=>nt(N),className:"w-full px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-700 text-sm",children:[n.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:N.name}),n.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:N.path})]},L))})]}),n.jsx(Ie,{type:"button",variant:"outline",onClick:Ke,className:"px-3",title:r("projectWizard.folderBrowser.browseFolders"),children:n.jsx(nr,{className:"w-4 h-4"})})]}),n.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:r(a==="existing"?"projectWizard.step2.existingHelp":"projectWizard.step2.newHelp")})]})}),o===3&&n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:[n.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-white mb-3",children:r("projectWizard.step3.reviewConfig")}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex justify-between text-sm",children:[n.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:r("projectWizard.step3.workspaceType")}),n.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:r(a==="existing"?"projectWizard.step3.existingWorkspace":"projectWizard.step3.newWorkspace")})]}),n.jsxs("div",{className:"flex justify-between text-sm",children:[n.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:r("projectWizard.step3.path")}),n.jsx("span",{className:"font-mono text-xs text-gray-900 dark:text-white break-all",children:l})]})]})]}),n.jsx("div",{className:"bg-primary/10 dark:bg-primary/20 rounded-lg p-4 border border-primary/30 dark:border-primary/60",children:n.jsx("p",{className:"text-sm text-primary",children:r(a==="existing"?"projectWizard.step3.existingInfo":"projectWizard.step3.newEmpty")})})]})]}),n.jsxs("div",{className:"flex items-center justify-between p-6 border-t border-gray-200 dark:border-gray-700",children:[n.jsx(Ie,{variant:"outline",onClick:o===1?e:Re,disabled:u,children:o===1?r("projectWizard.buttons.cancel"):n.jsxs(n.Fragment,{children:[n.jsx(eu,{className:"w-4 h-4 mr-1"}),r("projectWizard.buttons.back")]})}),n.jsx(Ie,{onClick:o===3?at:Ue,disabled:u||o===1&&!a,children:u?n.jsxs(n.Fragment,{children:[n.jsx(Rt,{className:"w-4 h-4 mr-2 animate-spin"}),r("projectWizard.buttons.creating")]}):o===3?n.jsxs(n.Fragment,{children:[n.jsx(yn,{className:"w-4 h-4 mr-1"}),r("projectWizard.buttons.createProject")]}):n.jsxs(n.Fragment,{children:[r("projectWizard.buttons.next"),n.jsx(hi,{className:"w-4 h-4 ml-1"})]})})]})]}),C&&n.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[70] p-4",children:n.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:[n.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-8 h-8 bg-primary/15 dark:bg-primary/30 rounded-lg flex items-center justify-center",children:n.jsx(nr,{className:"w-4 h-4 text-primary"})}),n.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:r("projectWizard.folderBrowser.title")})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("button",{onClick:()=>ze(De?na:Nf),className:`p-2 rounded-md transition-colors ${he?"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"} ${De||_e?"":"hidden"}`,title:r(De?"projectWizard.folderBrowser.browseDrives":"projectWizard.folderBrowser.browseRoots"),children:n.jsx(yu,{className:"w-5 h-5"})}),n.jsx("button",{onClick:()=>te(!le),className:`p-2 rounded-md transition-colors ${le?"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:r(le?"projectWizard.folderBrowser.hideHiddenFolders":"projectWizard.folderBrowser.showHiddenFolders"),children:le?n.jsx(au,{className:"w-5 h-5"}):n.jsx(cu,{className:"w-5 h-5"})}),n.jsx("button",{onClick:()=>Z(!X),className:`p-2 rounded-md transition-colors ${X?"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:r("projectWizard.folderBrowser.createFolder"),disabled:!Ee,children:n.jsx(ro,{className:"w-5 h-5"})}),n.jsx("button",{onClick:()=>B(!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:n.jsx($t,{className:"w-5 h-5"})})]})]}),X&&Ee&&n.jsx("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700 bg-primary/10 dark:bg-primary/20",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(bn,{type:"text",value:ae,onChange:N=>re(N.target.value),placeholder:r("projectWizard.folderBrowser.newFolderPlaceholder"),className:"flex-1",onKeyDown:N=>{N.key==="Enter"&&rt(),N.key==="Escape"&&(Z(!1),re(""))},autoFocus:!0}),n.jsx(Ie,{size:"sm",onClick:rt,disabled:!ae.trim()||de,children:de?n.jsx(Rt,{className:"w-4 h-4 animate-spin"}):r("buttons.create")}),n.jsx(Ie,{size:"sm",variant:"ghost",onClick:()=>{Z(!1),re("")},children:r("buttons.cancel")})]})}),n.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:D?n.jsx("div",{className:"flex items-center justify-center py-8",children:n.jsx(Rt,{className:"w-6 h-6 animate-spin text-gray-400"})}):n.jsxs("div",{className:"space-y-1",children:[U!=="~"&&U!=="/"&&!Cf.test(U)&&!he&&n.jsxs("button",{onClick:()=>{const N=Math.max(U.lastIndexOf("/"),U.lastIndexOf("\\"));let L;N<=0?L="/":N===2&&/^[A-Za-z]:/.test(U)?L=U.substring(0,3):L=U.substring(0,N),ze(L)},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:[n.jsx(nr,{className:"w-5 h-5 text-gray-400"}),n.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:".."})]}),E.length===0?n.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:r("projectWizard.folderBrowser.noSubfolders")}):E.filter(N=>le||!N.name.startsWith(".")).sort((N,L)=>N.name.toLowerCase().localeCompare(L.name.toLowerCase())).map((N,L)=>n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("button",{onClick:()=>ze(N.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:[n.jsx(An,{className:"w-5 h-5 text-primary"}),n.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:N.name})]}),n.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>it(N.path,a==="existing"),className:"text-xs px-3",children:r("buttons.select")})]},L))]})}),n.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700",children:[n.jsxs("div",{className:"px-4 py-3 bg-gray-50 dark:bg-gray-900/50 flex items-center gap-2",children:[n.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:r("projectWizard.folderBrowser.currentPath")}),n.jsx("code",{className:"text-sm font-mono text-gray-900 dark:text-white flex-1 truncate",children:Ce?r("projectWizard.folderBrowser.drivesRoot"):ke?r("projectWizard.folderBrowser.workspaceRoots"):F})]}),n.jsxs("div",{className:"flex items-center justify-end gap-2 p-4",children:[n.jsx(Ie,{variant:"outline",onClick:()=>{B(!1),Z(!1),re("")},children:r("buttons.cancel")}),n.jsx(Ie,{variant:"outline",onClick:()=>it(U,a==="existing"),disabled:!qe,children:r("projectWizard.folderBrowser.useCurrentFolder")})]})]})]})})]})};var _f=["size","strokeWidth","strokeLinecap","strokeLinejoin","theme","fill","className","spin"];function ra(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),r.push.apply(r,o)}return r}function oa(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?ra(Object(r),!0).forEach(function(o){Af(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ra(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function Af(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function If(e,t){if(e==null)return{};var r=Tf(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)&&(r[o]=e[o])}return r}function Tf(e,t){if(e==null)return{};var r={},o=Object.keys(e),s,a;for(a=0;a<o.length;a++)s=o[a],!(t.indexOf(s)>=0)&&(r[s]=e[s]);return r}var Pf={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 Rf(){return"icon-"+((1+Math.random())*4294967296|0).toString(16).substring(1)}function Mf(e,t,r){var o=typeof t.fill=="string"?[t.fill]:t.fill||[],s=[],a=t.theme||r.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]:r.colors.twoTone.twoTone),s.push(typeof o[0]=="string"?o[0]:"currentColor"),s.push(typeof o[1]=="string"?o[1]:r.colors.twoTone.twoTone);break;case"multi-color":s.push(typeof o[0]=="string"?o[0]:"currentColor"),s.push(typeof o[1]=="string"?o[1]:r.colors.multiColor.outFillColor),s.push(typeof o[2]=="string"?o[2]:r.colors.multiColor.innerStrokeColor),s.push(typeof o[3]=="string"?o[3]:r.colors.multiColor.innerFillColor);break}return{size:t.size||r.size,strokeWidth:t.strokeWidth||r.strokeWidth,strokeLinecap:t.strokeLinecap||r.strokeLinecap,strokeLinejoin:t.strokeLinejoin||r.strokeLinejoin,colors:s,id:e}}var bc=i.createContext(Pf);bc.Provider;function wc(e,t,r){return function(o){var s=o.size,a=o.strokeWidth,c=o.strokeLinecap,l=o.strokeLinejoin,d=o.theme,u=o.fill,m=o.className,p=o.spin,f=If(o,_f),g=i.useContext(bc),h=i.useMemo(Rf,[]),_=Mf(h,{size:s,strokeWidth:a,strokeLinecap:c,strokeLinejoin:l,theme:d,fill:u},g),y=[g.prefix+"-icon"];return y.push(g.prefix+"-icon-"+e),g.rtl&&y.push(g.prefix+"-icon-rtl"),p&&y.push(g.prefix+"-icon-spin"),m&&y.push(m),wt.createElement("span",oa(oa({},f),{},{className:y.join(" ")}),r(_))}}const Df=wc("new-lark",!0,function(e){return wt.createElement("svg",{width:e.size,height:e.size,viewBox:"0 0 48 48",fill:"none"},wt.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}),wt.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]}),wt.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}))}),Lf=wc("wechat",!0,function(e){return wt.createElement("svg",{width:e.size,height:e.size,viewBox:"0 0 48 48",fill:"none"},wt.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]}),wt.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}),wt.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]}),wt.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]}),wt.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]}),wt.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}),wt.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M42.0024 35.9728L43 42L38.7618 39.9293",fill:e.colors[1]}),wt.createElement("path",{d:"M42.0024 35.9728L43 42L38.7618 39.9293",stroke:e.colors[0],strokeWidth:e.strokeWidth,strokeLinecap:e.strokeLinecap,strokeLinejoin:e.strokeLinejoin}),wt.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]}),wt.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]}))}),In=({children:e,content:t,position:r="top",className:o="",delay:s=500})=>{const[a,c]=i.useState(!1),[l,d]=i.useState(null),u=()=>{const g=setTimeout(()=>{c(!0)},s);d(g)},m=()=>{l&&(clearTimeout(l),d(null)),c(!1)},p=()=>{switch(r){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(r){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?n.jsxs("div",{className:"relative inline-block",onMouseEnter:u,onMouseLeave:m,children:[e,a&&n.jsxs("div",{className:bt("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,n.jsx("div",{className:bt("absolute w-0 h-0 border-4 border-transparent",f())})]})]}):e},Of=2e3,Sn="lan",sa="lan-access-password",Ff={claude:"Claude",codex:"Codex",gemini:"Gemini",opencode:"OpenCode"};function $f({provider:e,className:t="h-4 w-4"}){return e==="codex"?n.jsx(fr,{className:t}):e==="gemini"?n.jsx(hr,{className:t}):e==="opencode"?n.jsx(xr,{className:"h-4 w-auto"}):n.jsx(mr,{className:t})}function Ir({platform:e,size:t=20}){return e==="weixin"?n.jsx(Lf,{size:t,theme:"filled",fill:"#07C160"}):n.jsx(Df,{size:t,theme:"filled",fill:"#3370FF"})}function zf(e){return Ff[e]||e}function Bf(e){if(!e)return"0:00";const t=e-Date.now();if(t<=0)return"0:00";const r=Math.ceil(t/1e3),o=Math.floor(r/60),s=r%60;return`${o}:${String(s).padStart(2,"0")}`}function Go(e){return e?.fullPath||e?.path||""}function jo(e){const t=Go(e),r=typeof e?.displayName=="string"?e.displayName.trim():"",o=typeof e?.name=="string"?e.name.trim():"";if(r)return r;if(o)return o;if(!t)return"";const a=t.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean);return a[a.length-1]||t}function aa(e){return e&&(e.title||e.label||e.value)||""}function Uf({open:e,onOpenChange:t,selectedProject:r,projects:o=[],onConnectionChange:s}){const{t:a}=At("sidebar"),[c,l]=i.useState(null),[d,u]=i.useState(!1),[m,p]=i.useState(null),[f,g]=i.useState(null),[h,_]=i.useState(null),[y,C]=i.useState(""),[B,U]=i.useState({}),[Q,F]=i.useState(null),[M,E]=i.useState(""),[$,D]=i.useState(""),[j,le]=i.useState(!1),[te,X]=i.useState(""),[Z,ae]=i.useState({}),[re,de]=i.useState({}),ie=i.useRef(null),q=i.useRef(null),ye=Go(r),fe=c?.ccConnect?.installed===!0,Te=i.useMemo(()=>m===Sn?h?{id:Sn,connected:!!h.hasPassword,addresses:h.addresses||[]}:null:c?.platforms?.find(v=>v.id===m)||null,[m,h,c]),ee=f&&f.platform===m?f:null,J=i.useMemo(()=>(c?.providers||[]).filter(v=>v.installed).map(v=>v.id),[c]),be=i.useMemo(()=>{const v=new Map,w=(V,je)=>{const R=String(V||"").trim();!R||v.has(R)||v.set(R,{value:R,title:String(je||R).trim()||R,subtitle:R})};for(const V of o){const je=Go(V);w(je,jo(V))}ye&&w(ye,jo(r));for(const V of c?.platforms||[])V?.projectPath&&w(V.projectPath,jo({path:V.projectPath}));return Array.from(v.values())},[o,r,ye,c]),Ce=i.useMemo(()=>new Map(be.map(v=>[v.value,v])),[be]),ke=i.useMemo(()=>{const v=c?.platforms||[],w=h?[{id:Sn,connected:!!h.hasPassword,projectPath:h.addresses?.length?h.addresses.join(" / "):null,configuredProviders:[],activeProvider:null,addresses:h.addresses||[]}]:[];return[...v,...w]},[h,c]),he=()=>{ie.current&&(clearInterval(ie.current),ie.current=null)},Xe=async({silent:v=!1}={})=>{v||u(!0);try{const w=await Ze.ccConnect.platforms(),V=await w.json();if(!w.ok)throw new Error(V?.error||"Failed to load connection summary.");return l(V),s?.(V),V}catch(w){return E(w.message),null}finally{v||u(!1)}},De=async()=>{try{const v=await Ze.lanAccess.summary(),w=await v.json();if(!v.ok)throw new Error(w?.error||"Failed to load LAN access summary.");if(_(w),w?.hasPassword){const V=localStorage.getItem(sa);V&&C(V)}return w}catch(v){return E(v.message),null}},_e=async(v,{focusQr:w=!1}={})=>{const V=await Ze.lanAccess.createToken(v),je=await V.json();if(!V.ok)throw new Error(je?.error||"Failed to generate LAN access link.");return U(R=>({...R,[v]:je})),w&&F(v),je},qe=async(v=[])=>{const w={};for(const V of v)try{const je=await _e(V);w[V]=je}catch(je){E(je.message)}return w},Ee=async()=>{const v=q.current;if(he(),!(!v?.sessionId||!v?.platform||new Set(["confirmed","error","expired"]).has(v.status)))try{await Ze.ccConnect.cleanupSession(v.platform,v.sessionId)}catch{}};i.useEffect(()=>{q.current=f},[f]),i.useEffect(()=>{if(!e){Ee(),l(null),p(null),g(null),_(null),C(""),U({}),F(null),E(""),D(""),X(""),ae({}),de({});return}return Promise.all([Xe(),De()]).then(([,v])=>{v?.hasPassword&&v.addresses?.length&&qe(v.addresses)}),()=>{he()}},[e]),i.useEffect(()=>{if(!ee?.sessionId){he();return}const v=async()=>{try{const w=await Ze.ccConnect.sessionStatus(ee.platform,ee.sessionId),V=await w.json();if(!w.ok)throw new Error(V?.error||"Failed to read setup status.");g(V),V.status==="confirmed"?(he(),D(V.message||a("ccConnect.messages.connected")),X(""),g(null),await Xe({silent:!0})):(V.status==="error"||V.status==="expired")&&(he(),X(""))}catch(w){he(),X(""),E(w.message)}};return v(),ie.current=setInterval(()=>{v()},Of),()=>he()},[ee?.platform,ee?.sessionId,a]),i.useEffect(()=>{e&&ae(v=>{const w={...v};let V=!1;const je=c?.platforms||[];for(const R of je){if(typeof v[R.id]=="string"?v[R.id].trim():"")continue;const oe=R.projectPath||ye||be[0]?.value||"";oe&&(w[R.id]=oe,V=!0)}return V?w:v})},[e,be,ye,c]),i.useEffect(()=>{e&&de(v=>{const w={...v};let V=!1;for(const je of c?.platforms||[]){const R=Array.isArray(je.configuredProviders)&&je.configuredProviders.length>0?je.configuredProviders:J,Y=typeof v[je.id]=="string"?v[je.id].trim():"";if(Y&&R.includes(Y))continue;const oe=R.includes(je.activeProvider)?je.activeProvider:R[0]||"";oe&&(w[je.id]=oe,V=!0)}return V?w:v})},[J,e,c]);const We=v=>{const w=typeof Z[v]=="string"?Z[v].trim():"";return w||c?.platforms?.find(je=>je.id===v)?.projectPath||ye||be[0]?.value||""},Ue=v=>Array.isArray(v?.configuredProviders)&&v.configuredProviders.length>0?v.configuredProviders:J,Re=v=>{const w=Ue(v),V=typeof re[v?.id]=="string"?re[v.id].trim():"";return V&&w.includes(V)?V:v?.activeProvider&&w.includes(v.activeProvider)?v.activeProvider:w[0]||null},at=async(v,w)=>{if(ae(V=>({...V,[v.id]:w})),E(""),D(""),v.connected&&w&&w!==v.projectPath)try{await L(v.id,w)}catch{}},nt=async(v,w,{persist:V=!1}={})=>{de(je=>({...je,[v.id]:w})),V&&(E(""),D(""),await b(v.id,w))},Ke=()=>{t(!1)},Fe=async()=>{X("lan:password"),E(""),D("");try{const v=await Ze.lanAccess.updatePassword(y),w=await v.json();if(!v.ok)throw new Error(w?.error||"Failed to update LAN access password.");D(w.message||a("ccConnect.messages.lanPasswordUpdated")),localStorage.setItem(sa,y);const V=await De();V?.addresses?.length&&(U({}),await qe(V.addresses))}catch(v){E(v.message)}finally{X("")}},it=async v=>{try{const w=B[v]||await _e(v);await navigator.clipboard.writeText(w.accessUrl),D(a("ccConnect.messages.lanCopied"))}catch(w){E(w.message||a("ccConnect.messages.lanCopyFailed"))}},ze=async v=>{try{const w=B[v]||await _e(v);window.open(w.accessUrl,"_blank","noopener,noreferrer")}catch(w){E(w.message)}},rt=async v=>{try{if(!B[v]){await _e(v,{focusQr:!0});return}F(v)}catch(w){E(w.message)}},N=async(v,w)=>{const V=We(v);if(!V){E(a("ccConnect.messages.selectProjectFirst"));return}E(""),D(""),X(`setup:${v}:${w}`);const je={projectPath:V,mode:w},R=Re(c?.platforms?.find(Y=>Y.id===v));R&&(je.provider=R);try{const Y=await Ze.ccConnect.setup(v,je),oe=await Y.json();if(!Y.ok)throw new Error(oe?.error||a("ccConnect.messages.setupFailed"));g(oe),X(""),p(v)}catch(Y){X(""),E(Y.message)}},L=async(v,w=null)=>{const V=w||We(v);if(!V){E(a("ccConnect.messages.selectProjectFirst"));return}E(""),D(""),X(`project:${v}`);try{const je=await Ze.ccConnect.updateProject(v,{projectPath:V}),R=await je.json();if(!je.ok)throw new Error(R?.error||a("ccConnect.messages.projectUpdateFailed"));D(R.message||a("ccConnect.messages.projectUpdateSuccess")),await Xe({silent:!0})}catch(je){throw E(je.message),je}finally{X("")}},ue=async()=>{if(!(!ee?.platform||!ee?.sessionId)){E(""),X(`refresh:${ee.platform}`);try{const v=await Ze.ccConnect.refresh(ee.platform,ee.sessionId),w=await v.json();if(!v.ok)throw new Error(w?.error||a("ccConnect.messages.refreshFailed"));g(w),X("")}catch(v){X(""),E(v.message)}}},pe=async()=>{E(""),D(""),le(!0);try{const v=await Ze.ccConnect.install(),w=await v.json();if(!v.ok)throw new Error(w?.error||a("ccConnect.messages.installFailed"));D(w.message||a("ccConnect.messages.installSuccess")),await Xe({silent:!0})}catch(v){E(v.message)}finally{le(!1)}},b=async(v,w)=>{E(""),D(""),X(`switch:${v}:${w}`);try{const V=await Ze.ccConnect.switchProvider(v,w),je=await V.json();if(!V.ok)throw new Error(je?.error||a("ccConnect.messages.switchFailed"));D(je.message||a("ccConnect.messages.switchSuccess")),await Xe({silent:!0})}catch(V){E(V.message)}finally{X("")}},T=async v=>{E(""),D(""),X(`unbind:${v}`);try{const w=await Ze.ccConnect.unbind(v),V=await w.json();if(!w.ok)throw new Error(V?.error||a("ccConnect.messages.unbindFailed"));D(V.message||a("ccConnect.messages.unbindSuccess")),await Xe({silent:!0}),g(null)}catch(w){E(w.message)}finally{X("")}},A=async()=>{ee?.sessionId&&(await Ee(),g(null)),E(""),D(""),p(null),F(null)};if(!e)return null;const W=(v,w)=>{if(!w)return null;const V=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 n.jsx("div",{className:`rounded-xl border px-3 py-2 text-sm ${V}`,children:w})},H=()=>n.jsxs("div",{className:"space-y-4 rounded-2xl border border-dashed border-border bg-muted/20 p-4",children:[n.jsxs("div",{className:"flex items-start gap-3",children:[n.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:n.jsx(bo,{className:"h-5 w-5"})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"text-sm font-medium text-foreground",children:a("ccConnect.install.title")}),n.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a("ccConnect.install.description")})]})]}),n.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"}),n.jsxs(Ie,{onClick:pe,disabled:j,children:[j?n.jsx(Rt,{className:"h-4 w-4 animate-spin"}):n.jsx(bo,{className:"h-4 w-4"}),a(j?"ccConnect.install.installing":"ccConnect.install.action")]})]}),xe=v=>{const w=We(v.id),V=te===`project:${v.id}`,je=Ce.get(w)||null,R=be.length>0;return n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("p",{className:"text-sm font-medium text-foreground",children:a("ccConnect.project.label")}),V&&n.jsx(Rt,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"})]}),n.jsxs($o,{value:w||void 0,onValueChange:Y=>{at(v,Y)},disabled:!R||!!te||!!ee,children:[n.jsx(zo,{className:"h-auto min-h-12 w-full items-start py-3",children:je?n.jsxs("div",{className:"min-w-0 text-left",children:[n.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:aa(je)}),n.jsx("div",{className:"truncate text-xs text-muted-foreground",children:je.subtitle})]}):n.jsx("div",{className:"text-sm text-muted-foreground",children:a("ccConnect.project.placeholder")})}),n.jsx(Bo,{children:be.map(Y=>n.jsx(Wr,{value:Y.value,children:n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"truncate font-medium text-foreground",children:aa(Y)}),n.jsx("div",{className:"truncate text-xs text-muted-foreground",children:Y.subtitle})]})},Y.value))})]}),!w&&n.jsx("p",{className:"text-sm text-muted-foreground",children:a("ccConnect.project.empty")})]})},me=({platform:v,providers:w,selectedProvider:V,onSelect:je,disabled:R=!1,disableSelected:Y=!1,busyActionForProvider:oe=null})=>w?.length?n.jsxs("div",{className:"space-y-2",children:[n.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:a("ccConnect.labels.providerSwitcher")}),n.jsx("div",{className:"flex flex-wrap gap-2",children:w.map(Be=>{const Ye=Be===V,$e=typeof oe=="function"?oe(Be):!1;return n.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 ${Ye?"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:R||Y&&Ye&&!$e,onClick:()=>{je(Be)},children:[n.jsx($f,{provider:Be,className:"h-3.5 w-3.5"}),n.jsx("span",{children:zf(Be)}),$e?n.jsx(Rt,{className:"h-3.5 w-3.5 animate-spin"}):Ye?n.jsx(Vs,{className:"h-3.5 w-3.5"}):null]},`${v.id}:${Be}`)})})]}):null,Je=()=>n.jsxs("div",{className:"space-y-4",children:[W("success",$),W("error",M),n.jsx("div",{className:"grid gap-3",children:ke.map(v=>n.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-card",children:[n.jsx("button",{className:"w-full px-4 py-4 text-left transition-colors hover:bg-muted/20",onClick:()=>{p(v.id),E(""),D("")},children:n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary",children:v.id===Sn?n.jsx(qo,{className:"h-5 w-5"}):n.jsx(Ir,{platform:v.id,size:20})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("p",{className:"text-sm font-semibold text-foreground",children:a(`ccConnect.platforms.${v.id}.title`)}),v.connected&&n.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")})]}),n.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a(`ccConnect.platforms.${v.id}.description`)}),v.projectPath?n.jsx("p",{className:"mt-3 break-all text-xs text-muted-foreground",children:v.projectPath}):n.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:a("ccConnect.status.notConnected")})]})]})}),v.connected&&v.configuredProviders?.length>0&&n.jsx("div",{className:"border-t border-border/60 bg-muted/10 px-4 py-3",children:me({platform:v,providers:v.configuredProviders,selectedProvider:v.activeProvider,disabled:!!te,disableSelected:!0,busyActionForProvider:w=>te===`switch:${v.id}:${w}`,onSelect:async w=>{await nt(v,w,{persist:!0})}})})]},v.id))})]}),ge=v=>me({platform:v,providers:Ue(v),selectedProvider:v.activeProvider,disabled:!!te,disableSelected:!0,busyActionForProvider:w=>te===`switch:${v.id}:${w}`,onSelect:async w=>{await nt(v,w,{persist:!0})}}),Le=v=>n.jsxs("div",{className:"space-y-4",children:[n.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:n.jsxs("div",{className:"flex items-start gap-3",children:[n.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:n.jsx(Yu,{className:"h-5 w-5"})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.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`)})}),n.jsx("p",{className:"mt-1 text-sm text-green-700/80 dark:text-green-300/80",children:a("ccConnect.labels.connectedHint")})]})]})}),xe(v),ge(v),n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsxs(Ie,{variant:"outline",onClick:()=>{T(v.id)},disabled:!!te,className:"text-red-600 hover:text-red-600",children:[te===`unbind:${v.id}`?n.jsx(Rt,{className:"h-4 w-4 animate-spin"}):n.jsx(Gu,{className:"h-4 w-4"}),a("ccConnect.actions.unbind")]}),n.jsx(Ie,{variant:"ghost",onClick:A,children:a("ccConnect.actions.back")})]})]}),tt=()=>{if(!ee)return null;const v=ee.mode==="qr",w=ee.status==="pending"&&(ee.qrImageBase64||ee.qrUrl);return n.jsxs("div",{className:"space-y-4",children:[n.jsx("div",{className:"rounded-2xl border border-border/70 bg-muted/20 p-4",children:n.jsxs("div",{className:"flex min-h-[220px] flex-col items-center justify-center gap-3",children:[(ee.status==="starting"||te.startsWith("setup:"))&&n.jsxs(n.Fragment,{children:[n.jsx(Rt,{className:"h-8 w-8 animate-spin text-primary"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:a("ccConnect.status.starting")})]}),w&&n.jsxs(n.Fragment,{children:[ee.qrImageBase64?n.jsx("img",{src:`data:image/png;base64,${ee.qrImageBase64}`,alt:a("ccConnect.labels.qrAlt"),className:"h-48 w-48 rounded-xl border border-border bg-white object-contain p-2"}):n.jsx("img",{src:ee.qrUrl,alt:a("ccConnect.labels.qrAlt"),className:"h-48 w-48 rounded-xl border border-border bg-white object-contain p-2"}),n.jsx("p",{className:"text-sm font-medium text-foreground",children:a("ccConnect.status.awaitingScan")}),n.jsx("p",{className:"text-xs text-muted-foreground",children:a("ccConnect.labels.countdown",{time:Bf(ee.expiresAt)})})]}),ee.status==="scanned"&&n.jsxs(n.Fragment,{children:[n.jsx(Vs,{className:"h-10 w-10 text-primary"}),n.jsx("p",{className:"text-sm font-medium text-foreground",children:a("ccConnect.status.scanned")}),n.jsx("p",{className:"text-xs text-muted-foreground",children:a("ccConnect.status.confirmOnDevice")})]}),ee.status==="error"&&n.jsxs(n.Fragment,{children:[n.jsx(bo,{className:"h-8 w-8 text-red-500"}),n.jsx("p",{className:"text-sm font-medium text-red-600 dark:text-red-300",children:ee.message})]}),ee.status==="expired"&&n.jsxs(n.Fragment,{children:[n.jsx(qr,{className:"h-8 w-8 text-muted-foreground"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:a("ccConnect.status.expired")})]})]})}),v&&(ee.status==="pending"||ee.status==="error"||ee.status==="expired")&&n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs(Ie,{variant:"outline",onClick:()=>{ue()},disabled:!!te,children:[te.startsWith("refresh:")?n.jsx(Rt,{className:"h-4 w-4 animate-spin"}):n.jsx(qr,{className:"h-4 w-4"}),a("ccConnect.actions.refreshQr")]}),n.jsx(Ie,{variant:"ghost",onClick:A,children:a("ccConnect.actions.cancel")})]})]})},St=v=>n.jsxs("div",{className:"space-y-4",children:[xe(v),me({platform:v,providers:Ue(v),selectedProvider:Re(v),disabled:!!ee||!!te,onSelect:async w=>{await nt(v,w)}}),n.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-4",children:[n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary",children:n.jsx(Nr,{className:"h-5 w-5"})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"text-sm font-semibold text-foreground",children:a("ccConnect.platforms.weixin.qrTitle")}),n.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a("ccConnect.platforms.weixin.qrDescription")})]})]}),!ee&&n.jsxs(Ie,{className:"mt-4",onClick:()=>{N(v.id,"qr")},disabled:!We(v.id)||!Re(v)||!!te,children:[te==="setup:weixin:qr"?n.jsx(Rt,{className:"h-4 w-4 animate-spin"}):n.jsx(Ir,{platform:v.id,size:16}),a("ccConnect.actions.connectWeixin")]})]}),tt(),!ee&&n.jsx(Ie,{variant:"ghost",onClick:A,children:a("ccConnect.actions.back")})]}),Nt=v=>n.jsxs("div",{className:"space-y-4",children:[xe(v),me({platform:v,providers:Ue(v),selectedProvider:Re(v),disabled:!!ee||!!te,onSelect:async w=>{await nt(v,w)}}),!ee&&n.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-4",children:[n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary",children:n.jsx(Nr,{className:"h-5 w-5"})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"text-sm font-semibold text-foreground",children:a("ccConnect.platforms.feishu.qrTitle")}),n.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a("ccConnect.platforms.feishu.qrDescription")})]})]}),n.jsxs(Ie,{className:"mt-4",onClick:()=>{N(v.id,"qr")},disabled:!We(v.id)||!Re(v)||!!te,children:[te==="setup:feishu:qr"?n.jsx(Rt,{className:"h-4 w-4 animate-spin"}):n.jsx(Ir,{platform:v.id,size:16}),a("ccConnect.actions.startQrSetup")]})]}),tt(),!ee&&n.jsx(Ie,{variant:"ghost",onClick:A,children:a("ccConnect.actions.back")})]}),Ct=()=>{const v=h?.addresses||[],w=Q?B[Q]:null;return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-4",children:[n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary",children:n.jsx(Hs,{className:"h-5 w-5"})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"text-sm font-semibold text-foreground",children:a("ccConnect.platforms.lan.passwordTitle")}),n.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a("ccConnect.platforms.lan.passwordDescription")})]})]}),n.jsxs("div",{className:"mt-4 flex flex-col gap-3 sm:flex-row",children:[n.jsx("input",{type:"password",value:y,onChange:V=>C(V.target.value),placeholder:a("ccConnect.platforms.lan.passwordPlaceholder"),className:"h-11 flex-1 rounded-2xl border border-border bg-background px-4 text-sm outline-none transition focus:border-primary"}),n.jsxs(Ie,{className:"h-11 rounded-2xl px-4",onClick:()=>{Fe()},disabled:!y.trim()||te==="lan:password",children:[te==="lan:password"?n.jsx(Rt,{className:"h-4 w-4 animate-spin"}):n.jsx(Hs,{className:"h-4 w-4"}),a("ccConnect.actions.saveLanPassword")]})]})]}),n.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-4",children:[n.jsxs("div",{className:"mb-3",children:[n.jsx("p",{className:"text-sm font-semibold text-foreground",children:a("ccConnect.platforms.lan.linksTitle")}),n.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a("ccConnect.platforms.lan.linksDescription")})]}),n.jsx("div",{className:"space-y-3",children:v.length?v.map(V=>(B[V],n.jsx("div",{className:"rounded-2xl border border-border/70 bg-muted/10 px-3 py-2.5",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"min-w-0 flex-1",children:n.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:V})}),n.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1",children:[n.jsx(In,{content:a("ccConnect.actions.copyLink"),delay:150,children:n.jsx("span",{children:n.jsx(Ie,{variant:"outline",size:"icon",className:"h-9 w-9 rounded-xl",disabled:!h?.hasPassword,onClick:()=>{it(V)},"aria-label":a("ccConnect.actions.copyLink"),title:a("ccConnect.actions.copyLink"),children:n.jsx(pi,{className:"h-4 w-4"})})})}),n.jsx(In,{content:a("ccConnect.actions.openLink"),delay:150,children:n.jsx("span",{children:n.jsx(Ie,{variant:"outline",size:"icon",className:"h-9 w-9 rounded-xl",disabled:!h?.hasPassword,onClick:()=>{ze(V)},"aria-label":a("ccConnect.actions.openLink"),title:a("ccConnect.actions.openLink"),children:n.jsx(Kr,{className:"h-4 w-4"})})})}),n.jsx(In,{content:a("ccConnect.actions.showLanQr"),delay:150,children:n.jsx("span",{children:n.jsx(Ie,{size:"icon",className:"h-9 w-9 rounded-xl",disabled:!h?.hasPassword,onClick:()=>{rt(V)},"aria-label":a("ccConnect.actions.showLanQr"),title:a("ccConnect.actions.showLanQr"),children:n.jsx(Nr,{className:"h-4 w-4"})})})})]})]})},V))):n.jsx("div",{className:"rounded-2xl border border-dashed border-border/70 px-4 py-6 text-sm text-muted-foreground",children:a("ccConnect.platforms.lan.noAddresses")})})]}),w?.qrCodeDataUrl&&n.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-4",children:[n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary",children:n.jsx(Nr,{className:"h-5 w-5"})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"text-sm font-semibold text-foreground",children:a("ccConnect.platforms.lan.qrTitle")}),n.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:Q})]})]}),n.jsxs("div",{className:"mt-4 flex flex-col items-center gap-3",children:[n.jsx("img",{src:w.qrCodeDataUrl,alt:a("ccConnect.labels.qrAlt"),className:"h-52 w-52 rounded-2xl border border-border bg-white object-contain p-2"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:a("ccConnect.platforms.lan.qrHint")})]})]})]})},vt=v=>v?n.jsxs("div",{className:"space-y-4",children:[W("success",$),W("error",M),v.id!==Sn&&!fe&&!v.connected?n.jsxs("div",{className:"space-y-4",children:[H(),n.jsx(Ie,{variant:"ghost",onClick:A,children:a("ccConnect.actions.back")})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.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:()=>{A()},children:[n.jsx(Qd,{className:"h-4 w-4"}),a("ccConnect.actions.back")]}),n.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:[v.id===Sn?n.jsx(qo,{className:"h-4 w-4"}):n.jsx(Ir,{platform:v.id,size:16}),a(`ccConnect.platforms.${v.id}.title`)]})]}),v.id===Sn?Ct():v.connected&&!ee?Le(v):v.id==="weixin"?St(v):Nt(v)]})]}):null;return Ur.createPortal(n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm",children:n.jsxs("div",{className:"w-full max-w-2xl overflow-hidden rounded-[28px] border border-border/70 bg-background shadow-2xl",children:[n.jsxs("div",{className:"flex items-center justify-between border-b border-border/60 px-6 py-4",children:[n.jsx("div",{className:"min-w-0",children:n.jsxs("div",{children:[n.jsx("h2",{className:"text-lg font-semibold text-foreground",children:a("ccConnect.title")}),n.jsx("p",{className:"text-sm text-muted-foreground",children:a("ccConnect.subtitle")})]})}),n.jsxs("div",{className:"flex items-center gap-3",children:[d&&n.jsx(Rt,{className:"h-4 w-4 animate-spin text-muted-foreground"}),n.jsx(Ie,{variant:"ghost",size:"icon",onClick:Ke,"aria-label":a("actions.cancel"),children:n.jsx($t,{className:"h-4 w-4"})})]})]}),n.jsx("div",{className:"max-h-[80vh] overflow-y-auto px-6 py-5",children:c||h?Te?vt(Te):Je():n.jsxs("div",{className:"flex min-h-[240px] flex-col items-center justify-center gap-3",children:[n.jsx(Rt,{className:"h-8 w-8 animate-spin text-primary"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:a("ccConnect.loading")})]})})]})}),document.body)}const Wf=(e,t,r)=>{const o=new Date(e),s=t;if(isNaN(o.getTime()))return r?r("status.unknown"):"Unknown";const a=s-o,c=Math.floor(a/1e3),l=Math.floor(a/(1e3*60)),d=Math.floor(a/(1e3*60*60)),u=Math.floor(a/(1e3*60*60*24));return c<60?r?r("time.justNow"):"Just now":l===1?r?r("time.oneMinuteAgo"):"1 min ago":l<60?r?r("time.minutesAgo",{count:l}):`${l} mins ago`:d===1?r?r("time.oneHourAgo"):"1 hour ago":d<24?r?r("time.hoursAgo",{count:d}):`${d} hours ago`:u===1?r?r("time.oneDayAgo"):"1 day ago":u<7?r?r("time.daysAgo",{count:u}):`${u} days ago`:o.toLocaleDateString(void 0,{month:"numeric",day:"numeric"})},Kf=(e,t)=>{if(typeof e!="string")return"";const r=e.trim();return r.length<=t?r:`${r.slice(0,Math.max(0,t-1))}…`},Bn="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",Tr="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",So="block min-w-0 w-full max-w-full overflow-hidden text-ellipsis whitespace-nowrap text-sm font-medium text-foreground",ia=({provider:e,className:t="h-3.5 w-3.5"})=>e==="codex"||e==="openai"?n.jsx(fr,{className:t}):e==="gemini"?n.jsx(hr,{className:t}):e==="opencode"?n.jsx(xr,{className:"h-3.5 w-auto max-w-full"}):n.jsx(mr,{className:t});function ca({projects:e,selectedProject:t,selectedSession:r,onProjectSelect:o,onProjectRename:s,onSessionSelect:a,onNewSession:c,onSessionDelete:l,onProjectDelete:d,isLoading:u,projectDetailsLoading:m,loadingProgress:p,onProjectExpand:f,onRefresh:g,updateAvailable:h,latestVersion:_,currentVersion:y,releaseInfo:C,onShowVersionModal:B,isPWA:U,isMobile:Q,onToggleSidebar:F,onShowSettings:M,lockedProjectName:E,showNewProject:$,setShowNewProject:D}){const{t:j}=At("sidebar"),[le,te]=i.useState(new Set),[X,Z]=i.useState(null),[ae,re]=i.useState(""),[de,ie]=i.useState({}),[q,ye]=i.useState({}),[fe,Te]=i.useState(new Date),[ee,J]=i.useState("name"),[be,Ce]=i.useState(!1),[ke,he]=i.useState(null),[Xe,De]=i.useState(null),[_e,qe]=i.useState(""),[Ee,We]=i.useState(null),[Ue,Re]=i.useState(null),[at,nt]=i.useState({}),[Ke,Fe]=i.useState(""),[it,ze]=i.useState(new Set),[rt,N]=i.useState(null),[L,ue]=i.useState(null),[pe,b]=i.useState(null),[T,A]=i.useState(!1),[W,H]=i.useState(()=>{try{const S=localStorage.getItem("starredProjects");return S?new Set(JSON.parse(S)):new Set}catch(S){return console.error("Error loading starred projects:",S),new Set}}),xe=S=>ve=>{ve.target.closest(".overflow-y-auto")||ve.target.closest("[data-scroll-container]")||(ve.preventDefault(),ve.stopPropagation(),S())};i.useEffect(()=>{const S=setInterval(()=>{Te(new Date)},6e4);return()=>clearInterval(S)},[]),i.useEffect(()=>{ye({})},[e]),i.useEffect(()=>{r&&t&&te(S=>new Set([...S,t.name]))},[r,t]),i.useEffect(()=>{E&&te(new Set([E]))},[E,e.length]),i.useEffect(()=>{const S=()=>{try{const Ae=localStorage.getItem("claude-settings");if(Ae){const Qe=JSON.parse(Ae);J(Qe.projectSortOrder||"name")}}catch(Ae){console.error("Error loading sort order:",Ae)}};S();const ve=Ae=>{Ae.key==="claude-settings"&&S()};window.addEventListener("storage",ve);const Me=setInterval(()=>{document.hasFocus()&&S()},1e3);return()=>{window.removeEventListener("storage",ve),clearInterval(Me)}},[]);const me=i.useCallback(async()=>{try{const S=await Ze.ccConnect.platforms();if(!S.ok)return;const ve=await S.json();b(ve)}catch{}},[]);i.useEffect(()=>{me()},[me]);const Je=async S=>{const ve=new Set,Me=!le.has(S.name);Me&&ve.add(S.name),te(ve),Me&&typeof f=="function"&&await f(S.name,{background:!0})},ge=(S,ve)=>{a({...S,__projectName:ve})},Le=S=>{const ve=new Set(W);ve.has(S)?ve.delete(S):ve.add(S),H(ve);try{localStorage.setItem("starredProjects",JSON.stringify([...ve]))}catch(Me){console.error("Error saving starred projects:",Me)}},tt=S=>W.has(S),St=S=>{let ve={};try{ve=JSON.parse(localStorage.getItem("session-provider-map")||"{}")}catch{}const Me=[...S.sessions||[],...q[S.name]||[]].map(lt=>({...lt,__provider:ve[lt.id]||"claude"})),Ae=(S.codexSessions||[]).map(lt=>({...lt,__provider:"codex"})),Qe=(S.geminiSessions||[]).map(lt=>({...lt,__provider:"gemini"})),Et=(S.opencodeSessions||[]).map(lt=>({...lt,__provider:"opencode"})),zt=lt=>lt.__provider==="codex"?new Date(lt.createdAt||lt.lastActivity):lt.__provider==="gemini"?new Date(lt.createdAt||lt.lastActivity):lt.__provider==="opencode"?new Date(lt.createdAt||lt.lastActivity):new Date(lt.lastActivity);return[...Me,...Ae,...Qe,...Et].sort((lt,Zt)=>zt(Zt)-zt(lt))},Nt=S=>{const ve=St(S);return ve.length===0?new Date(0):ve.reduce((Ae,Qe)=>{const Et=new Date(Qe.lastActivity);return Et>Ae?Et:Ae},new Date(0))},Ct=[...e].sort((S,ve)=>{const Me=tt(S.name),Ae=tt(ve.name);if(Me&&!Ae)return-1;if(!Me&&Ae)return 1;if(ee==="date")return Nt(ve)-Nt(S);{const Qe=S.displayName||S.name,Et=ve.displayName||ve.name;return Qe.localeCompare(Et)}}),vt=S=>{Z(S.name),re(S.displayName||S.name||"")},v=()=>{Z(null),re("")},w=async S=>{const ve=ae.trim();if(ke!==S)try{if(he(S),(await Ze.renameProject(S,ve)).ok)if(ve&&typeof s=="function"&&s(S,ve),typeof g=="function")await g();else if(window.refreshProjects)await window.refreshProjects();else{window.location.reload();return}else console.error("Failed to rename project")}catch(Me){console.error("Error renaming project:",Me)}finally{he(null),Z(null),re("")}},V=(S,ve,Me,Ae="claude")=>{ue({projectName:S,sessionId:ve,sessionTitle:Me,provider:Ae})},je=async()=>{if(!L)return;const{projectName:S,sessionId:ve,provider:Me}=L;ue(null);try{console.log("[Sidebar] Deleting session:",{projectName:S,sessionId:ve,provider:Me});let Ae;if(Me==="codex"?Ae=await Ze.deleteCodexSession(ve):Me==="opencode"?Ae=await Ze.deleteOpencodeSession(ve):Ae=await Ze.deleteSession(S,ve),console.log("[Sidebar] Delete response:",{ok:Ae.ok,status:Ae.status}),Ae.ok)console.log("[Sidebar] Session deleted successfully, calling callback"),l?l(ve):console.warn("[Sidebar] No onSessionDelete callback provided");else{const Qe=await Ae.text();console.error("[Sidebar] Failed to delete session:",{status:Ae.status,error:Qe}),alert(j("messages.deleteSessionFailed"))}}catch(Ae){console.error("[Sidebar] Error deleting session:",Ae),alert(j("messages.deleteSessionError"))}},R=S=>{const ve=St(S).length;N({project:S,sessionCount:ve})},Y=async()=>{if(!rt)return;const{project:S,sessionCount:ve}=rt,Me=ve===0;N(null),ze(Ae=>new Set([...Ae,S.name]));try{const Ae=await Ze.deleteProject(S.name,!Me);if(Ae.ok)d&&d(S.name);else{const Qe=await Ae.json();console.error("Failed to delete project"),alert(Qe.error||j("messages.deleteProjectFailed"))}}catch(Ae){console.error("Error deleting project:",Ae),alert(j("messages.deleteProjectError"))}finally{ze(Ae=>{const Qe=new Set(Ae);return Qe.delete(S.name),Qe})}},oe=async S=>{if(!S.detailsLoaded&&typeof f=="function"){await f(S.name,{background:!0,force:!0});return}if(!(!(S.sessionMeta?.hasMore!==!1)||de[S.name])){ie(Me=>({...Me,[S.name]:!0}));try{const Me=(S.sessions?.length||0)+(q[S.name]?.length||0),Ae=await Ze.sessions(S.name,5,Me);if(Ae.ok){const Qe=await Ae.json();ye(Et=>({...Et,[S.name]:[...Et[S.name]||[],...Qe.sessions]})),Qe.hasMore===!1&&(S.sessionMeta={...S.sessionMeta,hasMore:!1})}}catch(Me){console.error("Error loading more sessions:",Me)}finally{ie(Me=>({...Me,[S.name]:!1}))}}},Be=Ct.filter(S=>{if(!Ke.trim())return!0;const ve=Ke.toLowerCase(),Me=(S.displayName||S.name).toLowerCase(),Ae=S.name.toLowerCase();return Me.includes(ve)||Ae.includes(ve)}),Ye=!!E,$e=Ye?Ct.filter(S=>S.name===E):Be,yt=t||$e[0]||null,Ve=Q?"bottom":"right",pt=Q?"end":"start",mt=Q?4:8;return n.jsxs(n.Fragment,{children:[$&&Ur.createPortal(n.jsx(Ef,{onClose:()=>D(!1),onProjectCreated:S=>{window.refreshProjects?window.refreshProjects():window.location.reload()}}),document.body),rt&&Ur.createPortal(n.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:n.jsxs("div",{className:"bg-card border border-border rounded-xl shadow-2xl max-w-md w-full overflow-hidden",children:[n.jsx("div",{className:"p-6",children:n.jsxs("div",{className:"flex items-start gap-4",children:[n.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:n.jsx(Vr,{className:"w-6 h-6 text-red-600 dark:text-red-400"})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:j("deleteConfirmation.deleteProject")}),n.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:[j("deleteConfirmation.confirmDelete")," ",n.jsx("span",{className:"font-medium text-foreground",children:rt.project.displayName||rt.project.name}),"?"]}),rt.sessionCount>0&&n.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:[n.jsx("p",{className:"text-sm text-red-700 dark:text-red-300 font-medium",children:j("deleteConfirmation.sessionCount",{count:rt.sessionCount})}),n.jsx("p",{className:"text-xs text-red-600 dark:text-red-400 mt-1",children:j("deleteConfirmation.allConversationsDeleted")})]}),n.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:j("deleteConfirmation.cannotUndo")})]})]})}),n.jsxs("div",{className:"flex gap-3 p-4 bg-muted/30 border-t border-border",children:[n.jsx(Ie,{variant:"outline",className:"flex-1",onClick:()=>N(null),children:j("actions.cancel")}),n.jsxs(Ie,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:Y,children:[n.jsx(Cn,{className:"w-4 h-4 mr-2"}),j("actions.delete")]})]})]})}),document.body),L&&Ur.createPortal(n.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:n.jsxs("div",{className:"bg-card border border-border rounded-xl shadow-2xl max-w-md w-full overflow-hidden",children:[n.jsx("div",{className:"p-6",children:n.jsxs("div",{className:"flex items-start gap-4",children:[n.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:n.jsx(Vr,{className:"w-6 h-6 text-red-600 dark:text-red-400"})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:j("deleteConfirmation.deleteSession")}),n.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:[j("deleteConfirmation.confirmDelete")," ",n.jsx("span",{className:"font-medium text-foreground",children:L.sessionTitle||j("sessions.unnamed")}),"?"]}),n.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:j("deleteConfirmation.cannotUndo")})]})]})}),n.jsxs("div",{className:"flex gap-3 p-4 bg-muted/30 border-t border-border",children:[n.jsx(Ie,{variant:"outline",className:"flex-1",onClick:()=>ue(null),children:j("actions.cancel")}),n.jsxs(Ie,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:je,children:[n.jsx(Cn,{className:"w-4 h-4 mr-2"}),j("actions.delete")]})]})]})}),document.body),n.jsxs("div",{className:"h-full flex flex-col bg-muted/10 border-r border-border/60 md:select-none",style:U&&Q?{paddingTop:"44px"}:{},children:[n.jsxs("div",{className:"md:flex-shrink-0 md:px-3 md:pt-3",children:[n.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:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("img",{src:"/logo-64.png",alt:"Logo",className:"w-8 h-8 rounded-lg flex-shrink-0"}),n.jsx("div",{className:"min-w-0",children:n.jsx("h1",{className:"text-base font-semibold leading-none text-foreground truncate",children:j("app.title")})})]}),F&&n.jsx(Ie,{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:F,title:j("tooltips.hideSidebar"),children:n.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})})]}),n.jsx("div",{className:"chat-header border-b border-border/60 bg-white p-3 dark:bg-background md:hidden",style:U&&Q?{paddingTop:"16px"}:{},children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("img",{src:"/logo-64.png",alt:"Logo",className:"w-8 h-8 rounded-lg flex-shrink-0"}),n.jsx("div",{children:n.jsx("h1",{className:"text-base font-semibold text-foreground",children:j("app.title")})})]}),n.jsxs("div",{className:"flex gap-2",children:[n.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:()=>A(!0),title:j("ccConnect.actions.open"),"aria-label":j("ccConnect.actions.open"),children:n.jsx(Ko,{className:"h-4 w-4"})}),n.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()=>{Ce(!0);try{await g()}finally{Ce(!1)}},disabled:be,children:n.jsx(qr,{className:`w-4 h-4 text-foreground ${be?"animate-spin":""}`})}),!Ye&&n.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:j("tooltips.createProject"),"aria-label":j("tooltips.createProject"),children:n.jsx(An,{className:"w-4 h-4"})})]})]})})]}),!u&&!Q&&!Ye&&n.jsx("div",{className:"hidden"}),e.length>0&&!u&&!Ye&&n.jsx("div",{className:"px-3 py-3 md:px-3",children:n.jsxs("div",{className:"relative",children:[n.jsx(Uo,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),n.jsx(bn,{type:"text",placeholder:j("projects.searchPlaceholder"),value:Ke,onChange:S=>Fe(S.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"}),Ke&&n.jsx("button",{onClick:()=>Fe(""),className:"absolute right-2 top-1/2 transform -translate-y-1/2 p-1 hover:bg-accent rounded",children:n.jsx($t,{className:"w-3 h-3 text-muted-foreground"})})]})}),e.length>0&&!u&&yt&&n.jsx("div",{className:"px-3 pb-2",children:n.jsxs(Ie,{variant:"subtle",className:"h-9 w-full justify-start gap-2 rounded-lg px-3 text-sm",onClick:()=>c(yt),children:[n.jsx(ro,{className:"h-4 w-4"}),j("sessions.newSession")]})}),n.jsx(yc,{className:"flex-1 overflow-x-hidden overflow-y-auto overscroll-contain px-2 py-2 md:px-3 md:py-2",children:n.jsx("div",{className:"space-y-1 overflow-x-hidden pb-safe-area-inset-bottom",children:u?n.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:n.jsx("div",{className:"w-full max-w-[320px] text-center space-y-4",children:n.jsxs("div",{className:"space-y-2.5",children:[n.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-muted",children:p&&p.total>0?n.jsx("div",{className:"h-full bg-primary transition-all duration-300 ease-out",style:{width:`${p.current/p.total*100}%`}}):n.jsx("div",{className:"h-full w-1/3 rounded-full bg-primary animate-pulse"})}),p?.currentProject&&n.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?n.jsxs("p",{className:"text-sm text-muted-foreground",children:[p.current,"/",p.total,n.jsx("span",{className:"ml-1 text-sm text-muted-foreground",children:j("projects.projects")})]}):n.jsx("p",{className:"text-sm text-muted-foreground",children:j("projects.loadingProjects")})]})})}):e.length===0?n.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[n.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:n.jsx(wo,{className:"w-6 h-6 text-muted-foreground"})}),n.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:j("projects.noProjects")}),n.jsx("p",{className:"text-sm text-muted-foreground",children:j("projects.runClaudeCli")})]}):$e.length===0?n.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[n.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:n.jsx(Uo,{className:"w-6 h-6 text-muted-foreground"})}),n.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:j("projects.noMatchingProjects")}),n.jsx("p",{className:"text-sm text-muted-foreground",children:j("projects.tryDifferentSearch")})]}):$e.map(S=>{const ve=le.has(S.name),Me=t?.name===S.name,Ae=!!m?.[S.name],Qe=tt(S.name),Et=it.has(S.name),zt=Ye&&S.name===E,lt=zt||ve,Zt=S.displayName||S.name,en=Kf(Zt,Q?22:28);return n.jsxs("div",{className:bt("space-y-2",Et&&"pointer-events-none opacity-50"),children:[!zt&&n.jsxs("div",{className:"group md:group",children:[n.jsx("div",{className:"md:hidden",children:n.jsxs("div",{className:bt("mx-1 flex min-h-10 items-center gap-2 px-2 py-2 text-muted-foreground transition-colors active:scale-[0.98]",Me?"text-foreground":"hover:text-foreground"),onClick:()=>{t?.name!==S.name&&o(S),Je(S)},onTouchEnd:xe(()=>{t?.name!==S.name&&o(S),Je(S)}),children:[n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[n.jsx("div",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:ve?n.jsx(nr,{className:bt("h-4 w-4",Qe?"text-yellow-600 dark:text-yellow-400":"text-foreground")}):n.jsx(wo,{className:bt("h-4 w-4",Qe?"text-yellow-600 dark:text-yellow-400":Me?"text-foreground":"text-muted-foreground")})}),n.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:X===S.name?n.jsx("input",{type:"text",value:ae,onChange:K=>re(K.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:j("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:K=>K.stopPropagation(),onKeyDown:K=>{K.key==="Enter"&&(K.preventDefault(),K.stopPropagation(),w(S.name)),K.key==="Escape"&&(K.preventDefault(),K.stopPropagation(),v())},style:{fontSize:"16px"}}):n.jsx("div",{className:bt(So,Me&&"font-semibold"),children:en})})]}),n.jsx("div",{className:"flex shrink-0 items-center justify-end gap-1",children:X===S.name?n.jsxs(n.Fragment,{children:[n.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:K=>{K.stopPropagation(),w(S.name)},title:j("tooltips.save"),disabled:ke===S.name,children:n.jsx(yn,{className:"h-3.5 w-3.5"})}),n.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:K=>{K.stopPropagation(),v()},title:j("tooltips.cancel"),children:n.jsx($t,{className:"h-3.5 w-3.5"})})]}):n.jsxs(Cr,{children:[n.jsx(Er,{asChild:!0,children:n.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:K=>K.stopPropagation(),"aria-label":j("actions.settings"),children:n.jsx(Sr,{className:"h-4 w-4"})})}),n.jsx(_r,{children:n.jsxs(Ar,{side:Ve,align:pt,sideOffset:mt,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:K=>K.stopPropagation(),children:[n.jsxs(an,{className:Bn,onSelect:K=>{K.preventDefault(),vt(S)},children:[n.jsx(Js,{className:"h-4 w-4"}),j("tooltips.renameProject")]}),n.jsxs(an,{className:Bn,onSelect:K=>{K.preventDefault(),Le(S.name)},children:[n.jsx(Xs,{className:bt("h-4 w-4",Qe&&"fill-yellow-400 text-yellow-500")}),j(Qe?"tooltips.removeFromFavorites":"tooltips.addToFavorites")]}),n.jsx(Zs,{className:"my-1 h-px bg-border"}),n.jsxs(an,{className:Tr,onSelect:K=>{K.preventDefault(),R(S)},children:[n.jsx(Cn,{className:"h-4 w-4"}),j("tooltips.deleteProject")]})]})})]})})]})}),n.jsxs("div",{role:"button",tabIndex:0,className:bt("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",X===S.name?"h-auto":"h-9",Me?"text-foreground":"hover:text-foreground"),onClick:()=>{t?.name!==S.name&&o(S),Je(S)},onTouchEnd:xe(()=>{t?.name!==S.name&&o(S),Je(S)}),onKeyDown:K=>{(K.key==="Enter"||K.key===" ")&&(K.preventDefault(),t?.name!==S.name&&o(S),Je(S))},title:S.fullPath||Zt,children:[n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[n.jsx("div",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:ve?n.jsx(nr,{className:bt("h-4 w-4",Qe?"text-yellow-600 dark:text-yellow-400":"text-foreground")}):n.jsx(wo,{className:bt("h-4 w-4",Qe?"text-yellow-600 dark:text-yellow-400":Me?"text-foreground":"text-muted-foreground")})}),n.jsx("div",{className:"min-w-0 flex-1 overflow-hidden text-left",children:X===S.name?n.jsx("input",{type:"text",value:ae,onChange:K=>re(K.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:j("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:K=>{K.key==="Enter"&&(K.preventDefault(),K.stopPropagation(),w(S.name)),K.key==="Escape"&&(K.preventDefault(),K.stopPropagation(),v())},onClick:K=>K.stopPropagation()}):n.jsx("div",{className:bt(So,Me&&"font-semibold"),children:en})})]}),n.jsx("div",{className:"flex shrink-0 items-center gap-1 pl-1",children:X===S.name?n.jsxs(n.Fragment,{children:[n.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:K=>{K.stopPropagation(),w(S.name)},title:j("tooltips.save"),disabled:ke===S.name,children:n.jsx(yn,{className:"h-3.5 w-3.5"})}),n.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:K=>{K.stopPropagation(),v()},title:j("tooltips.cancel"),children:n.jsx($t,{className:"h-3.5 w-3.5"})})]}):n.jsxs(Cr,{children:[n.jsx(Er,{asChild:!0,children:n.jsx("button",{className:bt("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:K=>K.stopPropagation(),"aria-label":j("actions.settings"),children:n.jsx(Sr,{className:"h-4 w-4"})})}),n.jsx(_r,{children:n.jsxs(Ar,{side:Ve,align:pt,sideOffset:mt,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:K=>K.stopPropagation(),children:[n.jsxs(an,{className:Bn,onSelect:K=>{K.preventDefault(),vt(S)},children:[n.jsx(Js,{className:"h-4 w-4"}),j("tooltips.renameProject")]}),n.jsxs(an,{className:Bn,onSelect:K=>{K.preventDefault(),Le(S.name)},children:[n.jsx(Xs,{className:bt("h-4 w-4",Qe&&"fill-yellow-400 text-yellow-500")}),j(Qe?"tooltips.removeFromFavorites":"tooltips.addToFavorites")]}),n.jsx(Zs,{className:"my-1 h-px bg-border"}),n.jsxs(an,{className:Tr,onSelect:K=>{K.preventDefault(),R(S)},children:[n.jsx(Cn,{className:"h-4 w-4"}),j("tooltips.deleteProject")]})]})})]})})]})]}),lt&&n.jsxs("div",{className:bt("space-y-1",zt?"px-1 md:px-0":"px-0"),children:[!S.detailsLoaded||Ae?Array.from({length:3}).map((K,Lt)=>n.jsx("div",{className:"flex h-9 items-center rounded-lg px-3",children:n.jsx("div",{className:"h-3 w-full animate-pulse rounded bg-muted",style:{width:`${60+Lt*15}%`}})},Lt)):St(S).length===0&&!de[S.name]?n.jsx("div",{className:"px-3 py-2 text-left",children:n.jsx("p",{className:"text-xs text-muted-foreground",children:j("sessions.noSessions")})}):St(S).map(K=>{const Lt=K.__provider==="codex",Ot=K.__provider==="gemini",qt=K.__provider==="opencode",pn=Lt||Ot||qt,k=Xe===K.id&&!Lt,O=r?.id===K.id,G=Lt?K.summary||K.name||j("projects.codexSession"):qt?K.summary||K.name||j("projects.opencodeSession"):K.summary||K.name||j("projects.newSession"),Se=pn&&K.createdAt||K.lastActivity,Ne=Ee===K.id||Ue===K.id;return n.jsxs("div",{className:"group/session relative w-full min-w-0 max-w-full",onMouseEnter:()=>We(K.id),onMouseLeave:()=>We(ne=>ne===K.id?null:ne),children:[n.jsx("div",{className:"w-full min-w-0 max-w-full md:hidden",children:n.jsxs("div",{className:bt("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",O?"chat-sidebar-item-active":"chat-sidebar-item hover:bg-muted/10"),onClick:()=>{o(S),ge(K,S.name)},onTouchEnd:xe(()=>{o(S),ge(K,S.name)}),children:[n.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground",children:n.jsx(ia,{provider:K.__provider})}),n.jsx("div",{className:"min-w-0 flex-1 basis-0 overflow-hidden",children:k?n.jsx("input",{type:"text",value:_e,onChange:ne=>qe(ne.target.value),onKeyDown:ne=>{ne.stopPropagation(),ne.key==="Enter"?updateSessionSummary(S.name,K.id,_e):ne.key==="Escape"&&(De(null),qe(""))},onClick:ne=>ne.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}):n.jsx("div",{className:So,title:G,children:G})}),n.jsx("div",{className:"flex shrink-0 items-center justify-end gap-1",children:k?n.jsxs(n.Fragment,{children:[n.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:ne=>{ne.stopPropagation(),updateSessionSummary(S.name,K.id,_e)},title:j("tooltips.save"),children:n.jsx(yn,{className:"h-3.5 w-3.5"})}),n.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:ne=>{ne.stopPropagation(),De(null),qe("")},title:j("tooltips.cancel"),children:n.jsx($t,{className:"h-3.5 w-3.5"})})]}):n.jsx(n.Fragment,{children:n.jsxs(Cr,{children:[n.jsx(Er,{asChild:!0,children:n.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:ne=>ne.stopPropagation(),"aria-label":j("actions.settings"),children:n.jsx(Sr,{className:"h-4 w-4"})})}),n.jsx(_r,{children:n.jsxs(Ar,{side:Ve,align:pt,sideOffset:mt,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:ne=>ne.stopPropagation(),children:[!Lt&&n.jsxs(an,{className:Bn,onSelect:ne=>{ne.preventDefault(),De(K.id),qe(K.summary||K.name||j("projects.newSession"))},children:[n.jsx(Ys,{className:"h-4 w-4"}),j("tooltips.editSessionName")]}),n.jsxs(an,{className:Tr,onSelect:ne=>{ne.preventDefault(),V(S.name,K.id,G,K.__provider)},children:[n.jsx(Cn,{className:"h-4 w-4"}),j("tooltips.deleteSession")]})]})})]})})})]})}),n.jsx("div",{className:"hidden w-full min-w-0 max-w-full md:block",children:n.jsxs("div",{className:bt("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",O?"chat-sidebar-item-active":"chat-sidebar-item hover:bg-muted/10"),children:[n.jsxs("button",{className:"flex w-full min-w-0 items-center gap-2 overflow-hidden text-left",onClick:()=>ge(K,S.name),onTouchEnd:xe(()=>ge(K,S.name)),children:[n.jsx("span",{className:bt("flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground transition-opacity",O||k?"opacity-100":"opacity-0 group-hover/session:opacity-100"),children:n.jsx(ia,{provider:K.__provider})}),k?n.jsx("input",{type:"text",value:_e,onChange:ne=>qe(ne.target.value),onKeyDown:ne=>{ne.stopPropagation(),ne.key==="Enter"?updateSessionSummary(S.name,K.id,_e):ne.key==="Escape"&&(De(null),qe(""))},onClick:ne=>ne.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}):n.jsx("span",{className:"block min-w-0 w-full flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-sm text-foreground",title:G,children:G})]}),n.jsx("div",{className:"relative flex shrink-0 items-center justify-end pl-1 min-w-[28px]",children:k?n.jsxs(n.Fragment,{children:[n.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:ne=>{ne.stopPropagation(),updateSessionSummary(S.name,K.id,_e)},title:j("tooltips.save"),children:n.jsx(yn,{className:"h-3.5 w-3.5"})}),n.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:ne=>{ne.stopPropagation(),De(null),qe("")},title:j("tooltips.cancel"),children:n.jsx($t,{className:"h-3.5 w-3.5"})})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:bt("text-[11px] text-muted-foreground whitespace-nowrap transition-opacity duration-200",Ne?"opacity-0":"opacity-100"),children:Wf(Se,fe,j)}),Ne&&n.jsx("div",{className:"absolute right-0 top-1/2 -translate-y-1/2 flex items-center justify-end",children:n.jsxs(Cr,{onOpenChange:ne=>Re(ne?K.id:null),children:[n.jsx(Er,{asChild:!0,children:n.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:ne=>ne.stopPropagation(),onFocus:()=>We(K.id),"aria-label":j("actions.settings"),children:n.jsx(Sr,{className:"h-4 w-4"})})}),n.jsx(_r,{children:n.jsxs(Ar,{side:Ve,align:pt,sideOffset:mt,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:ne=>ne.stopPropagation(),children:[!Lt&&n.jsxs(an,{className:Bn,onSelect:ne=>{ne.preventDefault(),De(K.id),qe(K.summary||K.name||j("projects.newSession"))},children:[n.jsx(Ys,{className:"h-4 w-4"}),j("tooltips.editSessionName")]}),n.jsxs(an,{className:Tr,onSelect:ne=>{ne.preventDefault(),V(S.name,K.id,G,K.__provider)},children:[n.jsx(Cn,{className:"h-4 w-4"}),j("tooltips.deleteSession")]})]})})]})})]})})]})})]},K.id)}),S.detailsLoaded&&St(S).length>0&&S.sessionMeta?.hasMore!==!1&&n.jsx(Ie,{variant:"subtle",size:"sm",className:"mt-2 w-full justify-center gap-2 rounded-xl text-muted-foreground hover:text-foreground",onClick:()=>oe(S),disabled:de[S.name],children:de[S.name]?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"w-3 h-3 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),j("sessions.loading")]}):n.jsxs(n.Fragment,{children:[n.jsx(Wo,{className:"w-3 h-3"}),j("sessions.showMore")]})})]})]},S.name)})})}),h&&n.jsxs("div",{className:"px-3 py-3 flex-shrink-0",children:[n.jsx("div",{className:"hidden md:block",children:n.jsxs(Ie,{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:B,children:[n.jsxs("div",{className:"relative",children:[n.jsx("svg",{className:"w-4 h-4 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.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"})}),n.jsx("div",{className:"absolute -top-1 -right-1 w-2 h-2 bg-blue-500 rounded-full animate-pulse"})]}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"text-sm font-medium text-blue-700 dark:text-blue-300",children:C?.title||`Version ${_}`}),n.jsx("div",{className:"text-xs text-blue-600 dark:text-blue-400",children:j("version.updateAvailable")})]})]})}),n.jsx("div",{className:"md:hidden p-3 pb-2",children:n.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:B,children:[n.jsxs("div",{className:"relative",children:[n.jsx("svg",{className:"w-5 h-5 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.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"})}),n.jsx("div",{className:"absolute -top-1 -right-1 w-2 h-2 bg-blue-500 rounded-full animate-pulse"})]}),n.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[n.jsx("div",{className:"text-sm font-medium text-blue-700 dark:text-blue-300",children:C?.title||`Version ${_}`}),n.jsx("div",{className:"text-xs text-blue-600 dark:text-blue-400",children:j("version.updateAvailable")})]})]})})]}),n.jsx("div",{className:"md:p-2 flex-shrink-0",children:n.jsxs("div",{className:"hidden md:flex items-center justify-between gap-2",children:[!Ye&&n.jsxs(Ie,{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:j("tooltips.createProject"),children:[n.jsx(An,{className:"w-4 h-4"}),n.jsx("span",{className:"text-xs leading-none",children:j("projects.newProject").includes("Project")?"New":j("projects.newProject").substring(0,2)})]}),n.jsxs(Ie,{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:()=>A(!0),title:j("ccConnect.actions.open"),children:[n.jsx(Ko,{className:"w-4 h-4"}),n.jsx("span",{className:"text-xs leading-none",children:j("ccConnect.actions.shortOpen")})]}),n.jsxs(Ie,{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()=>{Ce(!0);try{await g()}finally{Ce(!1)}},disabled:be,title:j("tooltips.refresh"),children:[n.jsx(qr,{className:`w-4 h-4 ${be?"animate-spin":""}`}),n.jsx("span",{className:"text-xs leading-none",children:j("actions.refresh")||"Sync"})]})]})})]}),n.jsx(Uf,{open:T,onOpenChange:A,selectedProject:t,projects:e,onConnectionChange:b})]})}function qf(e){if(typeof e=="string")return e;if(e==null)return"";try{return JSON.stringify(e,null,2)}catch{return String(e)}}function la(e){return e==null?null:typeof e=="string"?{content:e,isError:!1,toolUseResult:null}:{content:qf(e.content??e.output??e.result??""),isError:!!e.isError,toolUseResult:e.toolUseResult||null,exitCode:e.exitCode??e.exit_code}}function da(e,t){return e||""}function Vf(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 Hf(e,t,r){return t?.file_path?t.file_path:t?.path?t.path:e==="Read"&&typeof r=="string"?r:""}function Gf(e,t,r,o){const s=Hf(e,t,t),a=da(s);if(e==="Bash"){const c=t?.command||"";return{activityKind:"command",title:o("activity.actions.runCommand"),summary:Vf(c)||o("activity.actions.commandPending"),filePath:s,icon:Bu,heavy:!0}}if(e==="Grep"||e==="Glob"){const c=t?.pattern||t?.glob||"",l=da(t?.path||""),d=[];return c&&d.push(c),l&&d.push(l),{activityKind:"search",title:o("activity.actions.searchContent"),summary:d.join(" · ")||o("activity.actions.searchPending"),filePath:t?.path||"",icon:Uo,heavy:!1}}return e==="Read"?{activityKind:"read",title:o("activity.actions.readFile"),summary:a||o("activity.actions.readPending"),filePath:s,icon:fu,heavy:!1}:e==="Edit"||e==="ApplyPatch"?{activityKind:"edit",title:o("activity.actions.updateFile"),summary:a||o("activity.actions.filePending"),filePath:s,icon:du,heavy:!0}:e==="Write"?{activityKind:"write",title:o("activity.actions.createFile"),summary:a||o("activity.actions.filePending"),filePath:s,icon:pu,heavy:!0}:e==="TodoWrite"?{activityKind:"todo-write",title:o("activity.actions.updateTodo"),summary:o("activity.actions.todoSummary"),filePath:"",icon:Gs,heavy:!0}:e==="TodoRead"?{activityKind:"todo-read",title:o("activity.actions.readTodo"),summary:o("activity.actions.todoSummary"),filePath:"",icon:Gs,heavy:!1}:e==="exit_plan_mode"?{activityKind:"plan",title:o("activity.actions.generatePlan"),summary:o("activity.actions.planSummary"),filePath:"",icon:fi,heavy:!0}:{activityKind:"tool",title:o("activity.actions.runTool"),summary:e,filePath:s,icon:bd,heavy:!0}}function Jf({status:e,messages:t=[],pendingPermissionRequests:r=[],t:o}){if(r.length>0){const a=r[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&&!la(s.toolResult)&&!s.toolEndedAt){const a=mi(s.toolInput)||{},c=la(s.toolResult),l=Gf(s.toolName,a,null,o);return{phaseText:c?.isError?o("activity.stage.toolFailed"):l.activityKind==="search"?o("activity.stage.searching"):l.activityKind==="command"?o("activity.stage.runningCommand"):l.activityKind==="edit"||l.activityKind==="write"?o("activity.stage.editingFile"):l.activityKind==="read"?o("activity.stage.readingFile"):l.activityKind.startsWith("todo")?o("activity.stage.updatingTodo"):o("activity.stage.working"),detailText:l.summary,canAbort:e?.canAbort??!0,startedAt:e?.startedAt||Date.now()}}return e||null}const ce={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",CONFIG_OPTION_UPDATE:"config_option_update",SESSION_INFO_UPDATE:"session_info_update",USAGE_UPDATE:"usage_update",APPROVAL_REQUEST:"approval_request",APPROVAL_RESOLVED:"approval_resolved",SESSION_STATE_CHANGED:"session_state_changed",SYSTEM_NOTICE:"system_notice",ERROR:"error"};function Ht(e="evt"){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${e}:${crypto.randomUUID()}`:`${e}:${Date.now()}:${Math.random().toString(36).slice(2,10)}`}function kc(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 Mt({kind:e,provider:t="claude",sessionId:r=null,timestamp:o,payload:s={},extensions:a={},rawRef:c=null,eventId:l=null}){return{eventId:l||Ht(e),kind:e,provider:t,sessionId:r,timestamp:kc(o),payload:s,extensions:a,rawRef:c}}function Ns(e){return!!(e&&typeof e=="object"&&typeof e.kind=="string"&&typeof e.eventId=="string")}function No({kindPrefix:e="assistant_text",text:t,provider:r,sessionId:o,timestamp:s,messageId:a,extensions:c={},rawRef:l=null}){if(typeof t!="string"||!t.trim())return[];const d=a||Ht(e),u={...c,messageId:d};return[Mt({kind:`${e}_start`,provider:r,sessionId:o,timestamp:s,payload:{messageId:d},extensions:u,rawRef:l}),Mt({kind:`${e}_delta`,provider:r,sessionId:o,timestamp:s,payload:{messageId:d,text:t},extensions:u,rawRef:l}),Mt({kind:`${e}_end`,provider:r,sessionId:o,timestamp:s,payload:{messageId:d},extensions:u,rawRef:l})]}function jc(e){const t=String(e||"").trim();if(!t)return null;const r=t.match(/<dynamic_context(?:\s[^>]*)?>[\s\S]*?<\/dynamic_context>\s*<user_message(?:\s[^>]*)?>\s*([\s\S]*?)\s*<\/user_message>/i);return r?String(r[1]||"").trim():null}function Yf(e){return/<\/?(?:subagent_notification|environment_context|dynamic_context|user_message)(?:\s[^>]*)?>/i.test(String(e||""))}function Jo(e){if(typeof e!="string")return e;const t=jc(e);if(t!=null)return t;const r=Yf(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,""),r&&(o=o.replace(/["']?\s*\}\s*\}\s*$/g,"")),o.trim()}function Sc(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=`
192
+
193
+ [USER MESSAGE]
194
+ `,s=t.indexOf(o);return s>=0?t.slice(s+o.length).trim():""}const r=jc(t);return r??t}function Co(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 Tn(e){if(typeof e=="string")return e;if(e==null)return"";try{return JSON.stringify(e)}catch{return String(e)}}function Gt(e){if(e==null)return e;try{return JSON.parse(JSON.stringify(e))}catch{return e}}function Cs(e){return Array.isArray(e)?e.filter(t=>t&&typeof t=="object").map(t=>Gt(t)):[]}function Nc(e){const t=e?.extensions?.clientRequestId||e?.payload?.clientRequestId||null;return typeof t=="string"&&t.trim()?t.trim():null}function Xf(e){const t=e?.clientRequestId||e?.extensions?.clientRequestId||null;return typeof t=="string"&&t.trim()?t.trim():null}function Qf(e={}){return[...Array.isArray(e?.images)?e.images.map(r=>({type:"image",data:r?.data||r?.image||"",mimeType:r?.mimeType||"application/octet-stream",name:r?.name||r?.filename||""})):[],...Cs(e?.contentBlocks)]}function Zf(e,t,r={}){const o=Nc(t);if(!o)return-1;const s=JSON.stringify(Cs(r.contentBlocks));return Pn(e,a=>String(a?.type||"").trim().toLowerCase()!=="user"||Xf(a)!==o||String(a?.content||"")!==String(r.text||"")?!1:JSON.stringify(Qf(a))===s)}function eh(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)})):[],r=typeof e.currentModeId=="string"&&e.currentModeId.trim()?e.currentModeId.trim():null;return!t.length&&!r?null:{availableModes:t,currentModeId:r||t[0]?.id||null}}function th(e){return(Array.isArray(e?.availableCommands)?e.availableCommands:Array.isArray(e)?e:[]).filter(r=>r&&typeof r=="object"&&String(r.name||"").trim()).map(r=>({name:String(r.name).trim(),description:r.description==null?"":String(r.description),input:r.input&&typeof r.input=="object"?Gt(r.input):null,source:"acp",namespace:"acp",type:"acp"}))}function nh(e){return(Array.isArray(e?.configOptions)?e.configOptions:Array.isArray(e)?e:[]).filter(r=>r&&typeof r=="object"&&String(r.key||"").trim()).map(r=>({key:String(r.key).trim(),description:typeof r.description=="string"?r.description:"",value:Gt(r.value),schema:r.schema&&typeof r.schema=="object"?Gt(r.schema):null}))}function rh(e){if(!e||typeof e!="object")return null;const t=Object.prototype.hasOwnProperty.call(e,"title")?e.title==null?null:String(e.title):void 0,r=Object.prototype.hasOwnProperty.call(e,"updatedAt")?e.updatedAt==null?null:String(e.updatedAt):void 0;return t===void 0&&r===void 0?null:{...t!==void 0?{title:t}:{},...r!==void 0?{updatedAt:r}:{}}}function oh(e){if(!e||typeof e!="object")return null;const t=Number(e.used),r=Number(e.size);if(!Number.isFinite(t)||t<0||!Number.isFinite(r)||r<0)return null;const o=Math.round(t),s=Math.round(r),a=s>0?Math.min(100,Math.max(0,Math.round(o/s*100))):0;return{used:o,total:s,percentage:a,remaining:Math.max(0,s-o),cost:e.cost&&typeof e.cost=="object"?Gt(e.cost):null}}function Pr(e=null,t={}){const r=e&&typeof e=="object"?{...e}:{};return t.title!=null&&(r.title=String(t.title)),t.kind!=null&&(r.kind=String(t.kind)),t.status!=null&&(r.status=String(t.status)),t.rawInput!==void 0&&(r.rawInput=Gt(t.rawInput)),t.rawOutput!==void 0&&(r.rawOutput=Gt(t.rawOutput)),Array.isArray(t.contentBlocks)&&(r.content=Gt(t.contentBlocks)),Array.isArray(t.locations)&&(r.locations=Gt(t.locations)),Object.keys(r).length>0?r:null}function sh(e){const t=new Map;for(const r of e||[])if(!(r?.message?.role!=="user"||!Array.isArray(r?.message?.content)))for(const o of r.message.content)o?.type==="tool_result"&&o.tool_use_id&&t.set(o.tool_use_id,{content:o.content,isError:!!o.is_error,timestamp:r.timestamp,toolUseResult:r.toolUseResult||null});return t}function Pn(e,t){for(let r=e.length-1;r>=0;r-=1)if(t(e[r],r))return r;return-1}function ua(e="",t=""){return t?e?e.endsWith(t)?e:`${e}${t}`:t:e}function Rr(e,{messageId:t,timestamp:r,provider:o,isThinking:s=!1,kind:a="assistant"}){const c=Pn(e,d=>d?.eventMessageId===t&&!d.isToolUse&&!!d.isThinking==!!s);if(c>=0){const d={...e[c]};return d.isStreaming=!0,o&&(d.provider=o),r&&(d.timestamp=d.timestamp||r),e[c]=d,{messages:e,index:c}}const l={type:a,content:"",timestamp:r,provider:o,isStreaming:!0,eventMessageId:t};return s&&(l.isThinking=!0),e.push(l),{messages:e,index:e.length-1}}function ah(e,{messageId:t,timestamp:r,provider:o,role:s="assistant"}){const a=Pn(e,c=>c?.eventMessageId===t&&!c.isToolUse&&!c.isThinking&&String(c?.type||"").trim().toLowerCase()===String(s||"assistant").trim().toLowerCase());if(a>=0){const c={...e[a]};return o&&(c.provider=o),r&&!c.timestamp&&(c.timestamp=r),e[a]=c,{messages:e,index:a}}return e.push({type:s,content:"",timestamp:r,provider:o,isStreaming:!1,eventMessageId:t,contentBlocks:[]}),{messages:e,index:e.length-1}}function Mr(e,{toolCallId:t,toolName:r,timestamp:o,provider:s}){const a=Pn(e,c=>c?.isToolUse&&(c.toolId===t||c.toolCallId===t));if(a>=0){const c={...e[a]};return r&&(c.toolName=r),s&&(c.provider=s),o&&!c.timestamp&&(c.timestamp=o),e[a]=c,{messages:e,index:a}}return e.push({type:"assistant",content:"",timestamp:o,provider:s,isToolUse:!0,toolName:r||"Unknown Tool",toolId:t,toolCallId:t}),{messages:e,index:e.length-1}}function ih(e=[],t="claude",r=null){if(!Array.isArray(e))return[];const o=[],s=sh(e);for(const a of e){const c=kc(a?.timestamp),l={provider:t,timestamp:c,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(`
195
+ `):d=typeof a.message.content=="string"?a.message.content:String(a.message.content||"");const u=Sc(d);u&&(!Co(d)||u!==d)&&o.push(Mt({kind:ce.USER_MESSAGE,provider:t,sessionId:r,timestamp:c,payload:{text:u},rawRef:l}));continue}if(a?.type==="thinking"&&a?.message?.content){o.push(...No({kindPrefix:"reasoning",text:a.message.content,provider:t,sessionId:r,timestamp:c,rawRef:l}));continue}if(a?.type==="tool_use"&&a?.toolName){const d=a.toolCallId||Ht("tool"),u=a.toolResult||null;o.push(Mt({kind:ce.TOOL_CALL_START,provider:t,sessionId:r,timestamp:c,payload:{toolCallId:d,toolName:a.toolName},rawRef:l})),o.push(Mt({kind:ce.TOOL_CALL_INPUT,provider:t,sessionId:r,timestamp:c,payload:{toolCallId:d,input:a.toolInput||""},rawRef:l})),o.push(Mt({kind:ce.TOOL_CALL_END,provider:t,sessionId:r,timestamp:c,payload:{toolCallId:d,toolName:a.toolName},rawRef:l})),u&&o.push(Mt({kind:ce.TOOL_RESULT,provider:t,sessionId:r,timestamp:u.timestamp||c,payload:{toolCallId:d,content:Tn(u.content),isError:!!u.isError,toolUseResult:u.toolUseResult||null},rawRef:l}));continue}if(a?.type==="tool_result"){o.push(Mt({kind:ce.TOOL_RESULT,provider:t,sessionId:r,timestamp:c,payload:{toolCallId:a.toolCallId||null,content:Tn(a.output||""),isError:!1},rawRef:l}));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=Jo(d.text);u&&!Co(u)&&o.push(...No({text:u,provider:t,sessionId:r,timestamp:c,rawRef:l}))}else if(d?.type==="tool_use"){const u=d.id||Ht("tool"),m=s.get(d.id);o.push(Mt({kind:ce.TOOL_CALL_START,provider:t,sessionId:r,timestamp:c,payload:{toolCallId:u,toolName:d.name},rawRef:l})),o.push(Mt({kind:ce.TOOL_CALL_INPUT,provider:t,sessionId:r,timestamp:c,payload:{toolCallId:u,input:Tn(d.input||{})},rawRef:l})),o.push(Mt({kind:ce.TOOL_CALL_END,provider:t,sessionId:r,timestamp:c,payload:{toolCallId:u,toolName:d.name},rawRef:l})),m&&o.push(Mt({kind:ce.TOOL_RESULT,provider:t,sessionId:r,timestamp:m.timestamp||c,payload:{toolCallId:u,content:Tn(m.content),isError:!!m.isError,toolUseResult:m.toolUseResult||null},rawRef:l}))}}else{const d=Jo(a.message.content);d&&!Co(d)&&o.push(...No({text:d,provider:t,sessionId:r,timestamp:c,rawRef:l}))}continue}a?.type&&/error/i.test(a.type)&&o.push(Mt({kind:ce.ERROR,provider:t,sessionId:r,timestamp:c,payload:{message:a.error||a.message||"Provider error"},rawRef:l}))}return o.sort((a,c)=>new Date(a.timestamp)-new Date(c.timestamp))}function Cc(e=[],t,r="claude"){const o=Array.isArray(e)?[...e]:[];if(!Ns(t))return o;const s=t.provider||r,a=t.timestamp||new Date().toISOString(),c=t.payload||{};switch(t.kind){case ce.USER_MESSAGE:{const l=Nc(t),d=Zf(o,t,c),u=Cs(c.contentBlocks),m=typeof c.text=="string"?c.text:"",p=m?Sc(m):"";if(m.trim()&&!p&&u.length===0)break;if(d>=0){const f=o[d]||{},g=Array.isArray(f.images)&&f.images.length>0?u.filter(h=>h?.type!=="image"):u;o[d]={...f,type:"user",content:p||f.content||"",timestamp:f.timestamp||a,provider:s,contentBlocks:g,clientRequestId:l||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:l});break}case ce.ASSISTANT_TEXT_START:{const l=c.messageId||t.extensions?.messageId||Ht("assistant_text");Rr(o,{messageId:l,timestamp:a,provider:s,isThinking:!1});break}case ce.ASSISTANT_TEXT_DELTA:{const l=c.messageId||t.extensions?.messageId||Ht("assistant_text"),{index:d}=Rr(o,{messageId:l,timestamp:a,provider:s,isThinking:!1}),u={...o[d]};u.content=ua(u.content||"",c.text||""),u.timestamp=u.timestamp||a,u.provider=u.provider||s,o[d]=u;break}case ce.ASSISTANT_TEXT_END:{const l=c.messageId||t.extensions?.messageId;if(!l)break;const d=Pn(o,u=>u?.eventMessageId===l&&!u.isToolUse&&!u.isThinking);d>=0&&(o[d]={...o[d],isStreaming:!1});break}case ce.ASSISTANT_CONTENT_BLOCK:{const l=c.messageId||t.extensions?.messageId||Ht("assistant_content"),{index:d}=ah(o,{messageId:l,timestamp:a,provider:s,role:"assistant"}),u={...o[d]},m=Array.isArray(u.contentBlocks)?[...u.contentBlocks]:[];c.contentBlock&&typeof c.contentBlock=="object"&&m.push(Gt(c.contentBlock)),u.contentBlocks=m,u.provider=u.provider||s,u.timestamp=u.timestamp||a,o[d]=u;break}case ce.REASONING_START:{const l=c.messageId||t.extensions?.messageId||Ht("reasoning");Rr(o,{messageId:l,timestamp:a,provider:s,isThinking:!0});break}case ce.REASONING_DELTA:{const l=c.messageId||t.extensions?.messageId||Ht("reasoning"),{index:d}=Rr(o,{messageId:l,timestamp:a,provider:s,isThinking:!0}),u={...o[d]};u.content=ua(u.content||"",c.text||""),u.timestamp=u.timestamp||a,u.provider=u.provider||s,u.isThinking=!0,o[d]=u;break}case ce.REASONING_END:{const l=c.messageId||t.extensions?.messageId;if(!l)break;const d=Pn(o,u=>u?.eventMessageId===l&&!!u.isThinking);d>=0&&(o[d]={...o[d],isStreaming:!1,isThinking:!0});break}case ce.TOOL_CALL_START:{const l=c.toolCallId||Ht("tool"),{index:d}=Mr(o,{toolCallId:l,toolName:c.toolName,timestamp:a,provider:s});o[d]={...o[d],toolName:c.toolName||o[d].toolName,acpToolCall:Pr(o[d].acpToolCall,c)};break}case ce.TOOL_CALL_INPUT:{const l=c.toolCallId||Ht("tool"),{index:d}=Mr(o,{toolCallId:l,toolName:c.toolName,timestamp:a,provider:s});o[d]={...o[d],toolInput:c.input!==void 0?Tn(c.input):c.rawInput!==void 0?Tn(c.rawInput):o[d].toolInput,provider:o[d].provider||s,acpToolCall:Pr(o[d].acpToolCall,c)};break}case ce.TOOL_CALL_END:{const l=c.toolCallId||t.extensions?.toolCallId;if(!l)break;const{index:d}=Mr(o,{toolCallId:l,toolName:c.toolName,timestamp:a,provider:s});o[d]={...o[d],toolName:c.toolName||o[d].toolName,toolEndedAt:a,acpToolCall:Pr(o[d].acpToolCall,c)};break}case ce.TOOL_RESULT:{const l=c.toolCallId||t.extensions?.toolCallId||Ht("tool"),{index:d}=Mr(o,{toolCallId:l,toolName:c.toolName,timestamp:a,provider:s});o[d]={...o[d],toolResult:{content:Tn(c.content??""),isError:!!c.isError,toolUseResult:c.toolUseResult||null,rawOutput:c.rawOutput,contentBlocks:Array.isArray(c.contentBlocks)?Gt(c.contentBlocks):null,status:c.status||null,timestamp:a},toolError:!!c.isError,toolEndedAt:o[d].toolEndedAt||a,provider:o[d].provider||s,acpToolCall:Pr(o[d].acpToolCall,c)};break}case ce.PLAN_UPDATE:{const l=Array.isArray(c.entries)?Gt(c.entries):[],d=Pn(o,m=>!!m?.isPlanUpdate),u={...d>=0?o[d]:{},id:(d>=0?o[d]?.id:null)||`plan:${t.sessionId||s}`,type:"assistant",content:String(c.message||"Plan updated"),timestamp:a,provider:s,isPlanUpdate:!0,planEntries:l};d>=0?o[d]=u:o.push(u);break}case ce.APPROVAL_REQUEST:c.message&&o.push({type:"assistant",content:c.message,timestamp:a,provider:s,isApprovalRequest:!0,approvalRequest:c});break;case ce.APPROVAL_RESOLVED:c.message&&o.push({type:"assistant",content:c.message,timestamp:a,provider:s,approvalResolution:c});break;case ce.SYSTEM_NOTICE:if(c.message){const l=o[o.length-1];l&&l.type==="assistant"&&!l.isToolUse&&(l.content||"").trim()===String(c.message).trim()||o.push({type:"assistant",content:c.message,timestamp:a,provider:s,isSystemNotice:!0})}break;case ce.ERROR:o.push({type:"error",content:c.message||"Provider error",timestamp:a,provider:s,rawRef:t.rawRef||null,extensions:t.extensions||{}});break}return o}function Ec(e=[],t="claude"){return Array.isArray(e)?e.length>0&&!Ns(e[0])?Ec(ih(e,t),t):e.reduce((r,o)=>Cc(r,o,t),[]):[]}function ch(e=[]){const t={modeState:null,availableCommands:[],configOptions:[],sessionInfo:null,tokenUsage:null};for(const r of Array.isArray(e)?e:[])if(Ns(r)){if(r.kind===ce.MODE_UPDATE){const o=eh(r.payload||{});o&&(t.modeState=t.modeState?{availableModes:o.availableModes.length>0?o.availableModes:t.modeState.availableModes,currentModeId:o.currentModeId||t.modeState.currentModeId||null}:o)}if(r.kind===ce.AVAILABLE_COMMANDS_UPDATE&&(t.availableCommands=th(r.payload||{})),r.kind===ce.CONFIG_OPTION_UPDATE&&(t.configOptions=nh(r.payload||{})),r.kind===ce.SESSION_INFO_UPDATE){const o=rh(r.payload||{});o&&(t.sessionInfo={...t.sessionInfo&&typeof t.sessionInfo=="object"?t.sessionInfo:{},...o})}if(r.kind===ce.USAGE_UPDATE){const o=oh(r.payload||{});o&&(t.tokenUsage=o)}}return t}const se={IDLE:"idle",CONNECTING:"connecting",QUEUED:"queued",STREAMING:"streaming",AWAITING_APPROVAL:"awaiting_approval",COMPLETED:"completed",ABORTED:"aborted",ERRORED:"errored"},Xr=new Set([se.CONNECTING,se.QUEUED,se.STREAMING,se.AWAITING_APPROVAL]),_c=new Set([se.COMPLETED,se.ABORTED,se.ERRORED]);function hn(e){return e==null?"":String(e).replace(/\r\n/g,`
196
+ `).trim()}function pa(e){return!e||typeof e!="object"?{content:"",isError:!1}:{content:hn(e.content),isError:!!e.isError}}function lh(e,t){if(!e||!t)return!1;const r=String(e.type||""),o=String(t.type||"");if(r!==o)return!1;const s=!!e.isToolUse,a=!!t.isToolUse;if(s!==a)return!1;if(s&&a){const c=pa(e.toolResult),l=pa(t.toolResult);return hn(e.toolName)===hn(t.toolName)&&hn(e.toolInput)===hn(t.toolInput)&&c.content===l.content&&c.isError===l.isError}return!!e.isThinking!=!!t.isThinking?!1:hn(e.content)===hn(t.content)}function dh(e,t){const r=Math.min(e.length,t.length);let o=0;for(;o<r&&lh(e[o],t[o]);)o+=1;return o}function uh(e=[],t=[],r={}){const o=Array.isArray(e)?e:[],s=Array.isArray(t)?t:[],a=!!r.preserveLocalTail;if(o.length===0)return s;if(s.length===0)return a?o:s;const c=dh(o,s);return c===o.length&&c===s.length?s:a&&c===s.length&&o.length>s.length?o:s}function Dr(e,t){return typeof t=="function"?t(e):t}function ma(e,t={}){const r=Xr.has(e),o=Xr.has(e);return{isLoading:r,canAbortSession:o,...t}}function ar(e,t=se.IDLE){const r=String(e||"").trim().toLowerCase();return Object.values(se).includes(r)?r:t}function Yo(e){return String(e?.rawRef?.type||"").trim().toLowerCase()==="session-status"}function Ac(e){return e===ce.APPROVAL_REQUEST||e===ce.APPROVAL_RESOLVED||e===ce.ASSISTANT_TEXT_START||e===ce.ASSISTANT_TEXT_DELTA||e===ce.ASSISTANT_CONTENT_BLOCK||e===ce.REASONING_START||e===ce.REASONING_DELTA||e===ce.TOOL_CALL_START||e===ce.TOOL_CALL_INPUT||e===ce.TOOL_CALL_END||e===ce.TOOL_RESULT||e===ce.PLAN_UPDATE||e===ce.SYSTEM_NOTICE}function ph(e=[]){let t=!1;for(let r=e.length-1;r>=0;r-=1){const o=e[r];if(!(!o||typeof o!="object")){if(o.kind===ce.ERROR)return se.ERRORED;if(o.kind===ce.SESSION_STATE_CHANGED){const s=ar(o.payload?.state,null);if(!s)continue;if(s===se.IDLE){Yo(o)&&(t=!0);continue}if(_c.has(s))return s;if(Yo(o))continue;return t?se.IDLE:s}if(o.kind===ce.APPROVAL_REQUEST)return t?se.IDLE:se.AWAITING_APPROVAL;if(o.kind===ce.APPROVAL_RESOLVED||Ac(o.kind))return t?se.IDLE:se.STREAMING}}return t?se.IDLE:null}function mh(e=[]){for(let t=e.length-1;t>=0;t-=1){const r=e[t];if(!(!r||typeof r!="object")){if(r.kind===ce.ERROR)return se.ERRORED;if(r.kind===ce.SESSION_STATE_CHANGED){const o=ar(r.payload?.state,null);if(!o||o===se.IDLE||Yo(r))continue;return _c.has(o)?o:null}if(Ac(r.kind))return null}}return null}function fh(e,t){return!e||typeof e!="object"?t:e.kind===ce.SESSION_STATE_CHANGED?ar(e.payload?.state,t):e.kind===ce.APPROVAL_REQUEST?se.AWAITING_APPROVAL:e.kind===ce.APPROVAL_RESOLVED?se.STREAMING:e.kind===ce.ERROR?se.ERRORED:e.kind===ce.ASSISTANT_TEXT_START||e.kind===ce.ASSISTANT_TEXT_DELTA||e.kind===ce.ASSISTANT_CONTENT_BLOCK||e.kind===ce.REASONING_START||e.kind===ce.REASONING_DELTA||e.kind===ce.TOOL_CALL_START||e.kind===ce.TOOL_CALL_INPUT||e.kind===ce.TOOL_CALL_END||e.kind===ce.TOOL_RESULT||e.kind===ce.PLAN_UPDATE||e.kind===ce.SYSTEM_NOTICE?se.STREAMING:t}function hh(e,t){const r=t?.payload||{},o=r.requestId||t?.extensions?.requestId||null,s=r.toolCall&&typeof r.toolCall=="object"?r.toolCall:null,a=Array.isArray(r.options)?r.options:Array.isArray(r.context?.options)?r.context.options:[];return!o||e.some(c=>c?.requestId===o)?e:[...e,{requestId:o,toolName:s?.title||r.toolName||"UnknownTool",input:s?.rawInput??r.input,context:{...r.context||{},kind:s?.kind||r.context?.kind||null,options:a},toolCall:s,options:a,message:r.message||null,sessionId:t?.sessionId||r.sessionId||null,receivedAt:t?.timestamp||new Date().toISOString()}]}function xh(e,t){const o=(t?.payload||{}).requestId||t?.extensions?.requestId||null;return o?e.filter(s=>s?.requestId!==o):e}function gh(e,t){return t?e===se.AWAITING_APPROVAL||Xr.has(e)?e:se.STREAMING:e===se.COMPLETED||e===se.ABORTED||e===se.ERRORED?e:se.IDLE}function vh(e=[]){return{messages:e,pendingPermissionRequests:[],phase:se.IDLE,isLoading:!1,canAbortSession:!1}}function yh(e,t){switch(t.type){case"replace_messages":return{...e,messages:Dr(e.messages,t.value)};case"replace_permissions":return{...e,pendingPermissionRequests:Dr(e.pendingPermissionRequests,t.value)};case"set_phase":{const r=ar(t.phase,e.phase);return{...e,phase:r,...ma(r,t.overrides)}}case"set_loading":{const r=!!Dr(e.isLoading,t.value),o=gh(e.phase,r);return{...e,phase:o,isLoading:r,canAbortSession:r?e.canAbortSession||Xr.has(o):!1}}case"set_can_abort":return{...e,canAbortSession:!!Dr(e.canAbortSession,t.value)};case"apply_conversation_event":{const r=Cc(e.messages,t.event,t.provider),o=fh(t.event,e.phase);let s=e.pendingPermissionRequests;if(t.event?.kind===ce.APPROVAL_REQUEST)s=hh(s,t.event);else if(t.event?.kind===ce.APPROVAL_RESOLVED)s=xh(s,t.event);else if(t.event?.kind===ce.SESSION_STATE_CHANGED){const a=ar(t.event?.payload?.state,"");(a===se.COMPLETED||a===se.ABORTED||a===se.ERRORED||a===se.IDLE)&&(s=[])}return{...e,messages:r,pendingPermissionRequests:s,phase:o,...ma(o)}}default:return e}}function Nn(e){return e&&e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&amp;/g,"&")}function bh(e){if(!e||typeof e!="string")return e;try{return e.replace(/```\s*([^\n\r]+?)\s*```/g,"`$1`")}catch{return e}}function Xo(e){try{return typeof e!="string"?e:e.replace(/Claude AI usage limit reached\|(\d{10,13})/g,(t,r)=>{let o=parseInt(r,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),c=-s.getTimezoneOffset(),l=c>=0?"+":"-",d=Math.abs(c),u=Math.floor(d/60),m=d%60,p=`GMT${l}${u}${m?`:${String(m).padStart(2,"0")}`:""}`,h=((Intl.DateTimeFormat().resolvedOptions().timeZone||"").split("/").pop()||"").replace(/_/g," ").toLowerCase().replace(/\b\w/g,B=>B.toUpperCase()),_=h?`${p} (${h})`:p,y=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],C=`${s.getDate()} ${y[s.getMonth()]} ${s.getFullYear()}`;return`Claude usage limit reached. Your limit will reset at **${a} ${_}** - ${C}`})}catch{return e}}function Ic(e){return Jo(e)}function wh(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=`
197
+
198
+ [USER MESSAGE]
199
+ `,s=t.indexOf(o);return s>=0?t.slice(s+o.length).trim():""}const r=t.match(/^<dynamic_context(?:\s[^>]*)?>[\s\S]*?<\/dynamic_context>\s*<user_message>\s*([\s\S]*?)\s*<\/user_message>$/i);return r?String(r[1]||"").trim():t}function Es(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=Ic(t.content);return s?s===t.content?[t]:[{...t,content:s}]:[]}const o=wh(t.content);return o?o===t.content?[t]:[{...t,content:o}]:[]}):[]}function kh(e=[],t=[]){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r+=1){const o=e[r],s=t[r];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 _s({phaseText:e,detailText:t="",canAbort:r=!0,startedAt:o=Date.now(),elapsedSeconds:s}={}){return{phaseText:e,detailText:t,canAbort:r,startedAt:o,elapsedSeconds:s}}function jh(e,t,r=null){const o=r?.startedAt||Date.now(),s=typeof e=="string"?e:e?.message||e?.status||e?.text||"",a=String(s||"").trim(),c=a.toLowerCase();let l=t("activity.stage.working");return c.includes("permission")?l=t("activity.stage.waitingPermission"):c.includes("think")?l=t("activity.stage.thinking"):c.includes("search")||c.includes("grep")||c.includes("glob")?l=t("activity.stage.searching"):c.includes("command")||c.includes("bash")?l=t("activity.stage.runningCommand"):c.includes("read")?l=t("activity.stage.readingFile"):c.includes("write")||c.includes("edit")||c.includes("patch")?l=t("activity.stage.editingFile"):c.includes("todo")?l=t("activity.stage.updatingTodo"):(c.includes("respond")||c.includes("reply"))&&(l=t("activity.stage.generatingReply")),_s({phaseText:l,detailText:a,canAbort:e?.can_interrupt!==!1,startedAt:o,elapsedSeconds:e?.elapsedSeconds})}const Sh=({node:e,inline:t,className:r,children:o,...s})=>{const{t:a}=At("chat"),[c,l]=i.useState(!1),d=Array.isArray(o)?o.join(""):String(o??""),u=/[\r\n]/.test(d);if(t||e&&e.type==="inlineCode"||!u)return n.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 ${r||""}`,...s,children:o});const f=/language-(\w+)/.exec(r||""),g=f?f[1]:"text",h=d,_=()=>{const y=()=>{l(!0),setTimeout(()=>l(!1),1500)};try{if(navigator?.clipboard?.writeText)navigator.clipboard.writeText(h).then(y).catch(()=>{const C=document.createElement("textarea");C.value=h,C.style.position="fixed",C.style.opacity="0",document.body.appendChild(C),C.select();try{document.execCommand("copy")}catch{}document.body.removeChild(C),y()});else{const C=document.createElement("textarea");C.value=h,C.style.position="fixed",C.style.opacity="0",document.body.appendChild(C),C.select();try{document.execCommand("copy")}catch{}document.body.removeChild(C),y()}}catch{}};return n.jsxs("div",{className:"relative group my-2",children:[g&&g!=="text"&&n.jsx("div",{className:"absolute top-2 left-3 z-10 text-xs text-gray-400 font-medium uppercase",children:g}),n.jsx("button",{type:"button",onClick:_,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(c?"codeBlock.copied":"codeBlock.copyCode"),"aria-label":a(c?"codeBlock.copied":"codeBlock.copyCode"),children:c?n.jsxs("span",{className:"flex items-center gap-1",children:[n.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:n.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")]}):n.jsxs("span",{className:"flex items-center gap-1",children:[n.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:[n.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),n.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),a("codeBlock.copy")]})}),n.jsx(Nd,{language:g,style:Cd,customStyle:{margin:0,borderRadius:"0.5rem",fontSize:"0.875rem",padding:g&&g!=="text"?"2rem 1rem 1rem 1rem":"1rem"},codeTagProps:{style:{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'}},children:d})]})},Nh={code:Sh,blockquote:({children:e})=>n.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})=>n.jsx("a",{href:e,className:"text-primary hover:underline",target:"_blank",rel:"noopener noreferrer",children:t}),p:({children:e})=>n.jsx("div",{className:"mb-2 last:mb-0",children:e}),table:({children:e})=>n.jsx("div",{className:"overflow-x-auto my-2",children:n.jsx("table",{className:"min-w-full border-collapse border border-gray-200 dark:border-gray-700",children:e})}),thead:({children:e})=>n.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800",children:e}),th:({children:e})=>n.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})=>n.jsx("td",{className:"px-3 py-2 align-top text-sm border border-gray-200 dark:border-gray-700",children:e})},Qo=({children:e,className:t})=>{const r=bh(String(e??"")),o=i.useMemo(()=>[wd,kd],[]),s=i.useMemo(()=>[jd],[]);return n.jsx("div",{className:t,children:n.jsx(Sd,{remarkPlugins:o,rehypePlugins:s,components:Nh,children:r})})};i.memo(({message:e,prevMessage:t,provider:r,showThinking:o,isActiveStreamingCard:s})=>{const{t:a}=At("chat"),c=e.provider||e.__provider||r||"claude",l=c==="codex",d=c==="gemini",u=c==="opencode",m=t&&t.type===e.type&&(t.type==="assistant"||t.type==="user"||t.type==="tool"||t.type==="error");return n.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"?n.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:[n.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:[n.jsx("div",{className:"text-sm whitespace-pre-wrap break-words",children:e.content}),e.images&&e.images.length>0&&n.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:e.images.map((p,f)=>n.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))}),n.jsx("div",{className:"text-xs text-primary-foreground/80 mt-1 text-right",children:new Date(e.timestamp).toLocaleTimeString()})]}),!m&&n.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"})]}):n.jsxs("div",{className:"w-full",children:[!m&&n.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[e.type==="error"?n.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"?n.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:"🔧"}):n.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0 p-1",children:l?n.jsx(fr,{className:"w-full h-full"}):d?n.jsx(hr,{className:"w-full h-full"}):u?n.jsx(xr,{className:"h-full w-auto max-w-full text-gray-900 dark:text-white"}):n.jsx(mr,{className:"w-full h-full"})}),n.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"):l?a("messageTypes.codex"):d?a("messageTypes.gemini"):u?"OpenCode":a("messageTypes.claude")})]}),n.jsxs("div",{className:"w-full",children:[e.isToolUse?n.jsx(Ed,{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?n.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:n.jsxs("details",{className:"group",open:s,children:[n.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:[n.jsx("svg",{className:"w-3 h-3 transition-transform group-open:rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),n.jsx("span",{children:a("thinking.emoji")})]}),n.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:n.jsx(Qo,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:e.content})})]})}):n.jsxs("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:[o&&e.reasoning&&n.jsxs("details",{className:"mb-3",open:s,children:[n.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")}),n.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:n.jsx("div",{className:"whitespace-pre-wrap",children:e.reasoning})})]}),(()=>{const p=Ic(Xo(String(e.content||""))),f=p.trim();if((f.startsWith("{")||f.startsWith("["))&&(f.endsWith("}")||f.endsWith("]")))try{const g=JSON.parse(f),h=JSON.stringify(g,null,2);return n.jsxs("div",{className:"my-2",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm text-gray-600 dark:text-gray-400",children:[n.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.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"})}),n.jsx("span",{className:"font-medium",children:"JSON Response"})]}),n.jsx("div",{className:"bg-gray-800 dark:bg-gray-900 border border-gray-600/30 dark:border-gray-700 rounded-lg overflow-hidden",children:n.jsx("pre",{className:"p-4 overflow-x-auto",children:n.jsx("code",{className:"text-gray-100 dark:text-gray-200 text-sm font-mono block whitespace-pre",children:h})})})]})}catch{}return e.type==="assistant"?n.jsx(Qo,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:p}):n.jsx("div",{className:"whitespace-pre-wrap",children:p})})()]}),n.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 Ch({hasSelectedProject:e=!1,hasMessages:t=!1,hasSessionContext:r=!1,isLoading:o=!1,isLoadingSessionMessages:s=!1}={}){return e?t?"messages":s?"loading-session-messages":r?o?"running-empty":"continue":"provider-selection":"no-project"}function Eh({canAbortSession:e=!1,hasInput:t=!1,isInputDisabled:r=!1,isLoading:o=!1}={}){return e&&o?{kind:"abort",disabled:!1}:{buttonType:"button",kind:"submit",disabled:!t||r}}function _h({modes:e=[],disabled:t=!1}={}){return(Array.isArray(e)?e.filter(o=>o?.id):[]).length>1&&!t}function Tc(e,t){return Number.isInteger(e)&&e>=0&&e<t?e:-1}function Ah(e=[],t=-1){const r=Array.isArray(e)?e:[],o=Tc(t,r.length),s=o>=0?r[o]:null;return{activeImage:s,activeIndex:o,isOpen:s!==null}}const Ih=[{id:"claude",label:"Claude Code",Logo:mr},{id:"codex",label:"Codex",Logo:fr},{id:"gemini",label:"Gemini",Logo:hr},{id:"opencode",label:"OpenCode",Logo:xr}];function Th({provider:e,onSelect:t}){return n.jsx("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-2",children:Ih.map(({id:r,label:o,Logo:s})=>n.jsxs("button",{onMouseDown:a=>a.preventDefault(),onClick:()=>t(r),className:`group relative w-full flex items-center gap-3 rounded-2xl border px-4 py-3 text-left transition-all duration-200 ${e===r?"border-primary/50 bg-primary/5 text-foreground shadow-sm":"border-border/60 bg-muted/10 text-muted-foreground hover:bg-muted/20 hover:text-foreground"}`,children:[r==="opencode"?n.jsx(s,{className:"h-10 w-auto max-w-full flex-shrink-0 text-foreground"}):n.jsx(s,{className:"h-10 w-10 flex-shrink-0"}),n.jsx("div",{className:"text-left font-medium text-[14px] leading-6",children:o})]},r))})}function Ph(e,t){const r=e.split(`
200
+ `),o=t.split(`
201
+ `),s=[];let a=0,c=0;for(;a<r.length||c<o.length;){const l=r[a],d=o[c];a>=r.length?(s.push({type:"added",content:d,lineNum:c+1}),c+=1):c>=o.length?(s.push({type:"removed",content:l,lineNum:a+1}),a+=1):l===d?(a+=1,c+=1):(s.push({type:"removed",content:l,lineNum:a+1}),s.push({type:"added",content:d,lineNum:c+1}),a+=1,c+=1)}return s}function Rh({selectedProject:e,selectedSession:t,currentSessionId:r,provider:o,chatMessages:s,threadMessages:a,isLoading:c,isLoadingSessionMessages:l,isLoadingMoreMessages:d,hasMoreMessages:u,totalMessages:m,sessionMessages:p,visibleMessageCount:f,pendingPermissionRequests:g,scrollContainerRef:h,messagesEndRef:_,onScroll:y,onLoadEarlierSessionMessages:C,onLoadEarlierMessages:B,onProviderSelection:U,onFileOpen:Q,onShowSettings:F,onGrantToolPermission:M,onPermissionDecision:E,autoExpandTools:$,showRawParameters:D}){const{t:j}=At("chat"),le=o==="codex"?"Codex":o==="gemini"?"Gemini":o==="opencode"?"OpenCode":"Claude",te=i.useMemo(()=>{const re=new Map;return(de,ie)=>{const q=`${de.length}-${ie.length}-${de.slice(0,50)}`;if(re.has(q))return re.get(q);const ye=Ph(de,ie);if(re.set(q,ye),re.size>100){const fe=re.keys().next().value;re.delete(fe)}return ye}},[]),X=s.length===0?null:n.jsxs(n.Fragment,{children:[d&&n.jsx("div",{className:"pb-3 text-center text-gray-500 dark:text-gray-400",children:n.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[n.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),n.jsx("p",{className:"text-sm",children:j("session.loading.olderMessages")})]})}),u&&!d&&n.jsx("div",{className:"mb-3 text-center text-gray-500 dark:text-gray-400 text-sm",children:m>0&&n.jsxs("span",{children:[j("session.messages.showingOf",{shown:p.length,total:m})," •",n.jsx("button",{className:"ml-1 text-primary hover:text-primary underline",onClick:C,children:j("session.messages.loadEarlier")}),n.jsx("span",{className:"ml-1 text-xs",children:j("session.messages.scrollToLoad")})]})}),!t&&!u&&s.length>f&&n.jsxs("div",{className:"mb-3 text-center text-gray-500 dark:text-gray-400 text-sm",children:[j("session.messages.showingLast",{count:f,total:s.length})," •",n.jsx("button",{className:"ml-1 text-primary hover:text-primary underline",onClick:B,children:j("session.messages.loadEarlier")})]})]}),Z=s.length===0?null:n.jsx(n.Fragment,{children:g.map(re=>n.jsx(_d,{request:re,className:"mx-1 my-3 sm:mx-0",onSelectOption:de=>E(re.requestId,{optionId:de,outcome:{outcome:"selected",optionId:de}}),onCancel:()=>E(re.requestId,{cancelled:!0,outcome:{outcome:"cancelled"}})},re.requestId))}),ae=Ch({hasSelectedProject:!!e,hasMessages:s.length>0,hasSessionContext:!!(t||r),isLoading:c,isLoadingSessionMessages:l});return e?n.jsx("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:ae==="loading-session-messages"?n.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:n.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[n.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),n.jsx("p",{children:j("session.loading.sessionMessages")})]})}):ae==="provider-selection"?n.jsx("div",{className:"flex h-full items-center justify-center overflow-y-auto px-4 py-8 sm:px-6",children:n.jsxs("div",{className:"w-full max-w-3xl text-center",children:[n.jsx("h2",{className:"mb-2 text-3xl font-semibold tracking-tight text-foreground sm:text-4xl",children:j("providerSelection.title")}),n.jsx("p",{className:"mx-auto mb-8 max-w-xl text-base text-muted-foreground",children:j("providerSelection.description")}),n.jsx(Th,{provider:o,onSelect:U})]})}):ae==="continue"?n.jsx("div",{className:"flex h-full items-center justify-center overflow-y-auto px-4 py-8 sm:px-6",children:n.jsxs("div",{className:"px-6 text-center text-muted-foreground sm:px-4",children:[n.jsx("p",{className:"mb-3 text-2xl font-semibold text-foreground",children:j("session.continue.title")}),n.jsx("p",{className:"text-sm sm:text-base leading-relaxed",children:j("session.continue.description")})]})}):ae==="running-empty"?n.jsx("div",{className:"flex h-full items-center justify-center overflow-y-auto px-4 py-8 sm:px-6",children:n.jsx("div",{className:"px-6 text-center text-muted-foreground sm:px-4",children:n.jsxs("div",{className:"mb-3 flex items-center justify-center gap-2",children:[n.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-b-2 border-gray-400"}),n.jsx("p",{className:"text-sm sm:text-base",children:j("session.loading.waitingForFirstReply")})]})})}):n.jsx(Ad,{messages:a,convertMessage:Id,isRunning:c,scrollContainerRef:h,onScroll:y,messagesEndRef:_,provider:o,providerLabel:le,createDiff:te,onFileOpen:Q,onShowSettings:F,onGrantToolPermission:M,showRawParameters:D,autoExpandTools:$,selectedProject:e,markdownRenderer:Qo,topContent:X,bottomContent:Z})}):n.jsx("div",{className:"flex h-full items-center justify-center px-4 py-8 sm:px-6",children:n.jsxs("div",{className:"max-w-lg px-8 py-10 text-center text-muted-foreground",children:[n.jsx("div",{className:"mx-auto mb-5 flex h-14 w-14 items-center justify-center rounded-3xl bg-primary/10 text-primary",children:n.jsx(Ko,{className:"h-7 w-7"})}),n.jsx("p",{className:"text-base font-medium text-foreground",children:"Select a project to start chatting"})]})})}function Mh(e){return String(e||"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Dh(e){if(typeof e!="string")return"";const r=e.replace(/\\/g,"/").split("/").filter(Boolean);return r[r.length-1]||e}function Pc(e,t=""){let r=[];for(const o of Array.isArray(e)?e:[]){const s=t?`${t}/${o.name}`:o.name;o.type==="directory"&&o.children?r=r.concat(Pc(o.children,s)):o.type==="file"&&r.push({name:o.name,path:s,relativePath:o.path})}return r}const Wn="1",fa=5,ha="replace",Zo="append";function xn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function on(e){return typeof e=="string"&&e.trim().length>0}function es(e){if(typeof e!="string")return"";try{return decodeURIComponent(e).trim()}catch{return e.trim()}}function lo(e,{allowEmptyPath:t=!0}={}){return typeof e=="string"?!t&&!e.trim()?null:{path:e,displayName:""}:!xn(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 Mn(e){return lo(e)?.path||""}function Lh(e){const t=lo(e);return t?on(t.displayName)?t.displayName:Dh(t.path):""}function Oh(e,t=72){if(typeof e!="string")return"";const r=e.trim().replace(/\s+/g," ");if(r.length<=t)return r;const o=r.split(/\s*>\s*/).filter(Boolean);if(o.length<=1)return`...${r.slice(-(t-3))}`;const s=[];let a=3;for(let l=o.length-1;l>=0;l-=1){const d=o[l],u=a+d.length+(s.length>0?3:0);if(s.length>0&&u>t)break;s.unshift(d),a=u}const c=`... > ${s.join(" > ")}`;return c.length<=t?c:`...${c.slice(-(t-3))}`}function xa(e){if(!e)return"";const t=[];on(e.label)&&t.push(e.label.trim());const r=Oh(e.selector);return r&&t.push(r),t.join(" · ")}function Fh(e){return e?on(e.systemContext)||on(Mn(e.currentFile))||Array.isArray(e.selectedElements)&&e.selectedElements.length>0?!0:xn(e.extensions)&&Object.keys(e.extensions).length>0:!1}function $h(e){return e?on(e.systemContext)||on(Mn(e.currentFile))?!0:Array.isArray(e.selectedElements)&&e.selectedElements.length>0:!1}function Rc(e){if(!xn(e)||e.version!==Wn||typeof e.systemContext!="string")return null;const t=lo(e.currentFile);if(!t||!Array.isArray(e.selectedElements))return null;const r=[];for(const s of e.selectedElements){if(!xn(s)||typeof s.tag!="string"||typeof s.selector!="string"||typeof s.label!="string")return null;r.push({tag:s.tag,selector:s.selector,label:s.label})}if(e.extensions!==void 0&&!xn(e.extensions))return null;const o={version:Wn,systemContext:e.systemContext,currentFile:t,selectedElements:r};return e.extensions!==void 0&&(o.extensions={...e.extensions}),o}function zh(e){if(!xn(e)||e.version!==void 0&&e.version!==Wn||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 r=lo(e.currentFile);if(!r)return null;t.currentFile=r}if(e.selectedElements!==void 0){const r=[];for(const o of e.selectedElements){if(!xn(o)||typeof o.tag!="string"||typeof o.selector!="string"||typeof o.label!="string")return null;r.push({tag:o.tag,selector:o.selector,label:o.label})}t.selectedElements=r}if(e.extensions!==void 0){if(!xn(e.extensions))return null;t.extensions={...e.extensions}}return t}function Bh(e){return`${e.tag}::${e.selector}::${e.label}`}function Uh(e){if(!Array.isArray(e)||e.length===0)return[];const t=new Set,r=[];for(const o of e){const s=Bh(o);t.has(s)||(t.add(s),r.push(o))}return r}function Wh(){return{version:Wn,systemContext:"",currentFile:{path:"",displayName:""},selectedElements:[]}}function Kh(e,t){const r=Rc(e)||Wh(),o=zh(t);if(!o)return null;const s={...r};return o.systemContext!==void 0&&(s.systemContext=o.systemContext),o.currentFile!==void 0&&on(Mn(o.currentFile))&&(s.currentFile=o.currentFile),o.selectedElements!==void 0&&(s.selectedElements=Uh([...Array.isArray(r.selectedElements)?r.selectedElements:[],...o.selectedElements])),o.extensions!==void 0&&(s.extensions={...xn(r.extensions)?r.extensions:{},...o.extensions}),s}function qh(e){return typeof e!="string"?ha:e.trim().toLowerCase()===Zo?Zo:ha}function ga(e){if(e==null||e==="")return null;let t=e;if(typeof e=="string"){const o=es(e);if(!o)return null;try{t=JSON.parse(o)}catch{return console.warn("[DynamicContext] Ignored invalid context JSON string."),null}}const r=Rc(t);return r||(console.warn("[DynamicContext] Ignored invalid context payload."),null)}function Vh(e){if(!e)return null;const t={version:Wn,systemContext:e.systemContext||"",currentFile:Mn(e.currentFile),selectedElements:Array.isArray(e.selectedElements)?e.selectedElements:[]};return e.extensions!==void 0&&(t.extensions=e.extensions),t}function Hh(e,t){return`<dynamic_context version="${Wn}">
202
+ ${JSON.stringify(e,null,2)}
203
+ </dynamic_context>
204
+
205
+ <user_message>
206
+ ${t}
207
+ </user_message>`}function Gh({visibleDynamicContext:e,visibleSelectedElements:t,hiddenSelectedElements:r,onDismissSystemContext:o,onDismissCurrentFile:s,onDismissSelectedElement:a}){const{t:c}=At("chat");return e?n.jsx("div",{className:"chat-subtle-surface mb-2 rounded-xl p-2.5",children:n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[on(e.systemContext)&&n.jsx(In,{content:e.systemContext,className:"whitespace-normal break-words max-w-sm",delay:200,children:n.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:[n.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:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 5h16M4 12h16M4 19h16"})}),n.jsx("span",{className:"truncate",children:c("input.dynamicContext.systemChip")}),n.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:c("input.dynamicContext.removeSystem"),"aria-label":c("input.dynamicContext.removeSystem"),children:n.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),on(Mn(e.currentFile))&&n.jsx(In,{content:Mn(e.currentFile),className:"whitespace-normal break-words max-w-sm",delay:200,children:n.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:[n.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:n.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"})}),n.jsx("span",{className:"truncate",children:Lh(e.currentFile)}),n.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:c("input.dynamicContext.removeCurrentFile"),"aria-label":c("input.dynamicContext.removeCurrentFile"),children:n.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),t.map((l,d)=>n.jsx(In,{content:xa(l),className:"max-w-[min(28rem,calc(100vw-2rem))] whitespace-normal break-words",delay:200,children:n.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:l.selector,children:[n.jsx("svg",{className:"w-3.5 h-3.5 text-primary flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 15l2 5L7 17l3-10 10 3-5 2z"})}),n.jsx("span",{className:"truncate",children:l.tag||c("input.dynamicContext.elementFallback")}),n.jsx("button",{type:"button",onClick:()=>a(l),className:"ml-0.5 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors",title:c("input.dynamicContext.removeElement"),"aria-label":c("input.dynamicContext.removeElement"),children:n.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})},`${l.selector}-${d}`)),r.length>0&&n.jsx(In,{content:r.map(xa).join(`
208
+ `),className:"max-w-[min(28rem,calc(100vw-2rem))] whitespace-pre-wrap break-words",delay:200,children:n.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:["+",r.length]})})]})}):null}function Jh({file:e,index:t,onPreview:r,onRemove:o,uploadProgress:s,error:a}){const[c,l]=i.useState(null);return i.useEffect(()=>{const d=URL.createObjectURL(e);return l(d),()=>URL.revokeObjectURL(d)},[e]),n.jsxs("div",{className:"relative group",children:[n.jsx("button",{type:"button",onClick:()=>r(t),disabled:!c,className:"block touch-manipulation overflow-hidden rounded-lg focus:outline-none focus:ring-2 focus:ring-primary/40 disabled:cursor-default",children:n.jsx("img",{src:c,alt:e.name,className:"h-20 w-20 object-cover rounded-lg"})}),s!==void 0&&s<100&&n.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:n.jsxs("div",{className:"text-white text-xs",children:[s,"%"]})}),a&&n.jsx("div",{className:"absolute inset-0 bg-red-500/50 flex items-center justify-center",children:n.jsx("svg",{className:"w-6 h-6 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),n.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:n.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}function Yh({attachedImages:e,uploadingImages:t,imageErrors:r,onRemove:o}){const[s,a]=i.useState(-1),[c,l]=i.useState(null),d=i.useMemo(()=>Ah(e,s),[e,s]);return i.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]),i.useEffect(()=>{const u=Tc(s,e.length);u!==s&&a(u)},[e.length,s]),i.useEffect(()=>{if(!d.activeImage){l(null);return}const u=URL.createObjectURL(d.activeImage);return l(u),()=>URL.revokeObjectURL(u)},[d.activeImage]),e.length?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"chat-subtle-surface mb-2 rounded-xl p-2.5",children:n.jsx("div",{className:"flex flex-wrap gap-2",children:e.map((u,m)=>n.jsx(Jh,{file:u,index:m,onPreview:a,onRemove:()=>o(m),uploadProgress:t.get(u.name),error:r.get(u.name)},`${u.name}-${m}`))})}),d.isOpen&&c&&n.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:[n.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:n.jsx($t,{className:"h-5 w-5"})}),n.jsxs("div",{className:"flex max-h-full w-full max-w-5xl flex-col items-center gap-3",onClick:u=>u.stopPropagation(),children:[n.jsx("img",{src:c,alt:d.activeImage?.name||"Preview",className:"max-h-[82vh] w-auto max-w-full rounded-2xl object-contain shadow-2xl"}),n.jsx("div",{className:"max-w-full truncate px-4 text-center text-sm text-white/80",children:d.activeImage?.name})]})]})]}):null}function Xh(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 Qh({composer:e,statusPresentation:t,shouldShowClaudeStatus:r,isLoading:o,chatMessages:s,sendByCtrlEnter:a}){const{t:c}=At("chat"),{provider:l,currentModel:d,modelOptions:u,selectedModelLabel:m,isModelSelectionLocked:p,isOpencodeModelLoading:f,permissionMode:g,acpModes:h,acpModeId:_,handleAcpModeChange:y,selectedPermissionShortLabel:C,permissionDropdownTitle:B,providerModeConfig:U,getPermissionModeLabel:Q,providerThinkingConfig:F,thinkingMode:M,setThinkingMode:E,tokenBudget:$,input:D,isInputFocused:j,setIsInputFocused:le,textareaRef:te,inputContainerRef:X,inputHighlightRef:Z,showFileDropdown:ae,filteredFiles:re,selectedFileIndex:de,selectFile:ie,showCommandMenu:q,filteredCommands:ye,selectedCommandIndex:fe,handleCommandSelect:Te,commandQuery:ee,frequentCommands:J,slashPosition:be,setShowCommandMenu:Ce,setSelectedCommandIndex:ke,setSlashPosition:he,setCommandQuery:Xe,getRootProps:De,getInputProps:_e,isDragActive:qe,openImagePicker:Ee,attachedImages:We,uploadingImages:Ue,imageErrors:Re,removeAttachedImage:at,visibleDynamicContext:nt,visibleSelectedElements:Ke,hiddenSelectedElements:Fe,handleDismissSystemContext:it,handleDismissCurrentFile:ze,handleDismissSelectedElement:rt,renderInputWithMentions:N,handleInputChange:L,handleTextareaClick:ue,handleKeyDown:pe,handlePaste:b,syncInputOverlayScroll:T,handleTextareaInput:A,activeInputProvider:W,isActiveProviderNotInstalled:H,unavailablePlaceholder:xe,isInputDisabled:me,activeProviderInstallReason:Je,activeProviderInstallHint:ge,isCheckingProviderInstallation:Le,checkProviderInstallation:tt,providerCheckLoadingByName:St,handleSubmit:Nt,isUserScrolledUp:Ct,scrollToBottom:vt,setProviderModel:v,setPermissionMode:w,selectedSession:V,handleAbortSession:je,canAbortSession:R,modelSelectorRef:Y,permissionSelectorRef:oe,activeProviderInstallState:Be,activeInputProviderLabel:Ye}=e,$e=Eh({canAbortSession:R,hasInput:!!D.trim(),isInputDisabled:me,isLoading:o}),yt=_h({disabled:me||!V?.id,modes:h});return n.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:[n.jsx("div",{className:"flex-1",children:n.jsx(Td,{phaseText:t?.phaseText,detailText:t?.detailText,elapsedSeconds:t?.elapsedSeconds,startedAt:t?.startedAt,canAbort:t?.canAbort,isLoading:r,onAbort:je,provider:l})}),n.jsx("div",{ref:X,className:"mx-auto mb-3 w-full max-w-4xl"}),n.jsxs("form",{onSubmit:Nt,className:"relative mx-auto w-full max-w-4xl",children:[Ct&&s.length>0&&n.jsx("button",{type:"button",onClick:vt,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:n.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 14l-7 7m0 0l-7-7m7 7V3"})})}),qe&&n.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center rounded-2xl border border-dashed border-primary bg-primary/5",children:n.jsxs("div",{className:"rounded-xl border border-border/70 bg-background p-4",children:[n.jsx("svg",{className:"w-8 h-8 text-primary mx-auto mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.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"})}),n.jsx("p",{className:"text-sm font-medium",children:"将图片拖到这里"})]})}),n.jsx(Yh,{attachedImages:We,uploadingImages:Ue,imageErrors:Re,onRemove:at}),n.jsx(Gh,{visibleDynamicContext:nt,visibleSelectedElements:Ke,hiddenSelectedElements:Fe,onDismissSystemContext:it,onDismissCurrentFile:ze,onDismissSelectedElement:rt}),ae&&re.length>0&&n.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:re.map((Ve,pt)=>n.jsxs("div",{className:`px-4 py-3 cursor-pointer border-b border-gray-100 dark:border-gray-700 last:border-b-0 touch-manipulation ${pt===de?"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:mt=>{mt.preventDefault(),mt.stopPropagation()},onClick:mt=>{mt.preventDefault(),mt.stopPropagation(),ie(Ve)},children:[n.jsx("div",{className:"font-medium text-sm",children:Ve.name}),n.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono",children:Ve.path})]},Ve.path))}),n.jsx(Pd,{commands:ye,selectedIndex:fe,onSelect:Te,onClose:()=>{Ce(!1),he(-1),Xe(""),ke(-1)},position:{top:te.current?Math.max(16,te.current.getBoundingClientRect().top-316):0,left:te.current?te.current.getBoundingClientRect().left:16,bottom:te.current?window.innerHeight-te.current.getBoundingClientRect().top+8:90},isOpen:q,frequentCommands:ee?[]:J}),n.jsxs("div",{...De(),className:`chat-composer-shell relative overflow-visible rounded-[20px] transition-all duration-200 ${e.isTextareaExpanded?"chat-input-expanded":""} ${j?"border-primary/40 ring-2 ring-primary/10":"hover:border-border hover:shadow-md"}`,children:[n.jsx("input",{..._e()}),n.jsx("div",{ref:Z,"aria-hidden":"true",className:"absolute inset-0 pointer-events-none overflow-hidden rounded-[24px]",children:n.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:N(D)})}),n.jsxs("div",{className:"relative z-10 flex flex-col",children:[n.jsx("div",{className:"relative px-4 pt-4",children:n.jsx("textarea",{ref:te,value:D,onChange:L,onClick:ue,onKeyDown:pe,onPaste:b,onScroll:Ve=>T(Ve.target),onFocus:()=>le(!0),onBlur:()=>le(!1),onInput:A,placeholder:H?xe:c("input.placeholder",{provider:W==="codex"?c("messageTypes.codex"):W==="gemini"?c("messageTypes.gemini"):W==="opencode"?"OpenCode":c("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"}})}),H&&n.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:[n.jsx("div",{children:Je||xe}),ge&&n.jsx("div",{className:"mt-1 font-mono text-[11px] opacity-90 break-all",children:ge}),n.jsx("div",{className:"mt-2",children:n.jsx("button",{type:"button",onClick:()=>tt(W,{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:Le,children:c(Le?"input.checkingInstallation":"input.recheckInstallation")})})]}),n.jsxs("div",{className:"flex items-end justify-between gap-2 px-3 pb-3 pt-2 sm:items-center",children:[n.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 sm:flex-nowrap sm:gap-2",children:[n.jsxs("button",{type:"button",onClick:()=>{me||Ee()},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:c("input.attachImages"),children:[n.jsx(ro,{className:"h-4 w-4 sm:hidden"}),n.jsx("svg",{className:"hidden h-5 w-5 sm:block",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.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"})})]}),n.jsx("div",{ref:Y,className:"relative min-w-0 max-w-full flex-[0_1_auto]",children:n.jsxs($o,{value:d||void 0,onValueChange:v,disabled:me||f||p,children:[n.jsx(zo,{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:n.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[f&&n.jsx(Rt,{className:"h-3.5 w-3.5 flex-shrink-0 animate-spin text-muted-foreground"}),n.jsx("span",{className:"truncate max-w-[120px] sm:max-w-[240px] md:max-w-[300px] text-xs font-normal text-muted-foreground",children:f?c("input.loadingModels"):m}),n.jsx(Wo,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground sm:hidden"})]})}),n.jsx(Bo,{children:f?n.jsx(Wr,{value:"__loading",disabled:!0,children:c("input.loadingModels")}):u.map(({value:Ve,label:pt})=>n.jsx(Wr,{value:Ve,children:pt},Ve))})]})}),n.jsx("div",{className:"relative min-w-0 max-w-full flex-[0_1_auto]",ref:oe,children:n.jsxs($o,{value:g,onValueChange:Ve=>{w(Ve),V&&localStorage.setItem(`permissionMode-${V.id}`,Ve)},disabled:me,children:[n.jsx(zo,{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:n.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[n.jsx("span",{className:"truncate text-xs font-normal text-muted-foreground",children:C||B||c("input.clickToChangeMode")}),n.jsx(Wo,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground sm:hidden"})]})}),n.jsx(Bo,{children:n.jsxs(Rd,{children:[n.jsx(Md,{children:B}),U.modes.map(Ve=>n.jsx(Wr,{value:Ve,children:Q(Ve,{short:!0})},Ve))]})})]})}),yt?n.jsx(Dd,{modes:h,value:_,onValueChange:y,disabled:me||!V?.id,label:"智能体模式"}):null,F.enabled&&n.jsx(Ld,{selectedMode:M,onModeChange:E,className:"sm:flex-none"}),$!==null&&n.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:[n.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.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"})}),n.jsx("span",{children:Xh($)})]}),n.jsx("div",{className:"w-px h-4 bg-gray-200 dark:bg-gray-700 mx-1 hidden sm:block"})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("div",{className:"relative group hidden sm:block",children:[n.jsx("button",{type:"button",className:"rounded-lg p-1.5 text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",title:c("input.commands"),children:n.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.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"})})}),n.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:n.jsx("p",{children:c(a?"input.hintText.ctrlEnter":"input.hintText.enter")})})]}),$e.kind==="abort"?n.jsx("button",{type:"button",onClick:je,className:"flex h-9 w-9 items-center justify-center rounded-full bg-red-600 text-white transition-colors hover:bg-red-500",title:c("input.stop"),"aria-label":c("input.stop"),children:n.jsx(Od,{className:"h-4 w-4 fill-current"})}):n.jsx("button",{type:$e.buttonType,disabled:$e.disabled,onClick:Ve=>{Ve.preventDefault(),Nt(Ve)},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:n.jsx("svg",{className:"w-5 h-5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 12h12m-5-5 5 5-5 5"})})})]})]})]})]})]})]})}function Rn(e){if(typeof e!="string")return"";const t=e.trim();if(!t)return"";const r=t.replace(/\\/g,"/");return r==="/"?"/":/^[A-Za-z]:\/?$/.test(r)?`${r[0]}:/`:r.replace(/\/+$/,"")}function tr(e){if(typeof e!="string")return!1;const t=e.trim();return t?/^new-session-\d+$/i.test(t)||/^codex-\d+$/i.test(t):!1}function rr(e,t){const r=Rn(t);return r?[e?.fullPath,e?.path].some(o=>Rn(o)===r):!1}function Zh(e,t,r={}){if(!t||!Array.isArray(e))return null;const o=typeof r.provider=="string"?r.provider.trim().toLowerCase():"",s=typeof r.projectName=="string"?r.projectName.trim():"",a=Rn(r.projectPath);for(const c of e){if(!((!s||c?.name===s)&&(!a||rr(c,a))))continue;const d=[{provider:"claude",items:c?.sessions},{provider:"codex",items:c?.codexSessions},{provider:"gemini",items:c?.geminiSessions},{provider:"opencode",items:c?.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:c,session:m,provider:u.provider}}}return null}function Mc({projects:e,queryProject:t=null,queryCwd:r=null}){if(!Array.isArray(e)||e.length===0)return null;const o=Rn(t),s=Rn(r);return e.find(a=>rr(a,s)?!0:o?[a?.name,a?.fullPath,a?.path].some(c=>Rn(c)===o):!1)||null}function ex({projects:e,queryProject:t=null,queryCwd:r=null}){const o=Mc({projects:e,queryProject:t,queryCwd:r});return!!(o&&!o.detailsLoaded)}function tx(e,t){return Object.freeze({value:e,label:t})}function Xn(e,t){return Object.freeze({OPTIONS:Object.freeze(t.map(([r,o])=>tx(r,o))),DEFAULT:e})}const gr=Object.freeze({claude:Xn("sonnet",[["sonnet","Sonnet"],["opus","Opus"],["haiku","Haiku"],["opusplan","Opus Plan"],["sonnet[1m]","Sonnet [1M]"]]),cursor:Xn("gpt-5",[["gpt-5","GPT-5"],["gpt-5.2-high","GPT-5.2 High"],["gemini-3-pro","Gemini 3 Pro"],["opus-4.5-thinking","Claude 4.5 Opus (Thinking)"],["gpt-5.2","GPT-5.2"],["gpt-5.1","GPT-5.1"],["gpt-5.1-high","GPT-5.1 High"],["composer-1","Composer 1"],["auto","Auto"],["sonnet-4.5","Claude 4.5 Sonnet"],["sonnet-4.5-thinking","Claude 4.5 Sonnet (Thinking)"],["opus-4.5","Claude 4.5 Opus"],["gpt-5.1-codex","GPT-5.1 Codex"],["gpt-5.1-codex-high","GPT-5.1 Codex High"],["gpt-5.1-codex-max","GPT-5.1 Codex Max"],["gpt-5.1-codex-max-high","GPT-5.1 Codex Max High"],["opus-4.1","Claude 4.1 Opus"],["grok","Grok"]]),codex:Xn("gpt-5.2-codex",[["gpt-5","GPT-5"],["gpt-5-codex","GPT-5 Codex"],["gpt-5-codex-mini","GPT-5 Codex Mini"],["gpt-5.1","GPT-5.1"],["gpt-5.1-codex","GPT-5.1 Codex"],["gpt-5.1-codex-max","GPT-5.1 Codex Max"],["gpt-5.1-codex-mini","GPT-5.1 Codex Mini"],["gpt-5.2","GPT-5.2"],["gpt-5.2-codex","GPT-5.2 Codex"],["gpt-5.2-high","GPT-5.2 High"],["gpt-5.2-low","GPT-5.2 Low"],["gpt-5.2-medium","GPT-5.2 Medium"],["gpt-5.2-xhigh","GPT-5.2 XHigh"],["gpt-5.3-codex","GPT-5.3 Codex"],["gpt-5.3-codex-high","GPT-5.3 Codex High"],["gpt-5.3-codex-low","GPT-5.3 Codex Low"],["gpt-5.3-codex-medium","GPT-5.3 Codex Medium"],["gpt-5.3-codex-xhigh","GPT-5.3 Codex XHigh"]]),gemini:Xn("gemini-3-pro-preview",[["gemini-2.5-pro","Gemini 2.5 Pro"],["gemini-2.5-flash","Gemini 2.5 Flash"],["gemini-3-pro-preview","Gemini 3 Pro Preview"],["gemini-3-flash-preview","Gemini 3 Flash Preview"]]),opencode:Xn("kimi-k2.5",[["kimi-k2.5","Kimi K2.5"]])}),nx=gr.claude;gr.cursor;const Dc=gr.codex,rx=gr.gemini,ox=gr.opencode,sx=["claude","codex","gemini","opencode"],Lr="unknown",ax="installed",Eo="not_installed",ix="checking",cx=["claude","codex","gemini","opencode"],lx=300*1e3;function Jt(e){const t=String(e||"").trim().toLowerCase();return sx.includes(t)?t:"claude"}function dx(e){switch(e){case"codex":return Dc;case"gemini":return rx;case"opencode":return ox;case"claude":default:return nx}}function uo(e){return`${Jt(e)}-model`}function As(e){return`${uo(e)}-selection-source`}function Or(e){const t=Jt(e),r=uo(t),o=As(t);return localStorage.getItem(o)!=="manual"?"":localStorage.getItem(r)||""}function ux(e,t){const r=Jt(e);localStorage.setItem(uo(r),t),localStorage.setItem(As(r),"manual")}function px(e){const t=Jt(e);localStorage.removeItem(uo(t)),localStorage.removeItem(As(t))}function Lc(e){if(typeof e!="string")return!1;const t=e.trim().toLowerCase();return t.length>0&&t!=="custom"&&t!=="default"}const mx=new Set(Dc.OPTIONS.map(e=>String(e?.value||"").trim().toLowerCase()).filter(Boolean));function fx(e){if(!Lc(e))return!1;const t=e.trim().toLowerCase();return mx.has(t)?!0:/^(gpt-\d|o[1345](?:$|[-.])|codex(?:$|[-.]))/i.test(t)}function hx(e,t){return Jt(e)==="codex"?fx(t):Lc(t)}function Fr(e){return typeof e=="string"&&/^codex-\d+$/.test(e.trim())}const va=new WeakMap;let ya=0;function xx(e){const t=e instanceof Date?e.getTime():new Date(e||Date.now()).getTime();return Number.isNaN(t)?Date.now():t}function gx(e){return String(e||"").replace(/\s+/g," ").trim().slice(0,120)}function vx(e,t){const r=xx(e?.timestamp),o=String(e?.role||e?.type||"assistant").trim().toLowerCase(),s=String(e?.provider||e?.__provider||"").trim().toLowerCase(),a=String(e?.clientRequestId||e?.requestId||"").trim(),c=String(e?.eventId||e?.toolCallId||e?.toolId||"").trim(),l=gx(e?.content||e?.toolName||e?.reasoning||(e?.isThinking?"thinking":"")||(e?.isLoadingIndicator?"loading-indicator":"")),d=[e?.isToolUse?"tool":"message",e?.isThinking?"thinking":"",e?.isPlanUpdate?"plan":"",e?.isLoadingIndicator?"loading":""].filter(Boolean).join(":");return[o,s,r,a,c,d,l,t].join(":")}function yx(e,t){if(e?.__threadMessageId)return String(e.__threadMessageId);const r=e?.id||e?.eventMessageId||e?.messageId||e?.toolCallId||e?.toolId||e?.requestId;if(r)return String(r);if(e&&typeof e=="object"){const o=va.get(e);if(o)return o;const s=vx(e,t);return va.set(e,s),s}return ya+=1,`runtime:${ya}:${t}`}const xt={setItem:(e,t)=>{try{if(e.startsWith("chat_messages_")&&typeof t=="string")try{const r=JSON.parse(t);if(Array.isArray(r)&&r.length>50){const o=r.slice(-50);t=JSON.stringify(o)}}catch(r){console.warn("Could not parse chat messages for truncation:",r)}localStorage.setItem(e,t)}catch(r){if(r.name==="QuotaExceededError"){const o=Object.keys(localStorage),s=o.filter(c=>c.startsWith("chat_messages_")).sort();s.length>3&&s.slice(0,s.length-3).forEach(c=>{localStorage.removeItem(c)}),o.filter(c=>c.startsWith("draft_input_")).forEach(c=>{localStorage.removeItem(c)});try{localStorage.setItem(e,t)}catch(c){if(e.startsWith("chat_messages_")&&typeof t=="string")try{const l=JSON.parse(t);Array.isArray(l)&&l.length>10&&localStorage.setItem(e,JSON.stringify(l.slice(-10)))}catch(l){console.error("Final save attempt failed:",l)}else console.error("Failed to save to localStorage even after cleanup:",c)}}else console.error("localStorage error:",r)}},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 Oc(e){return e?`chat_messages_${e}`:""}function Fc(e,t=null){return e?t?`chat_messages_${e}__session_${t}`:Oc(e):""}function bx(e,t=null){const r=Fc(e,t);if(!r)return[];const o=xt.getItem(r);if(!o)return[];try{return Es(JSON.parse(o))}catch(s){return console.warn("Failed to parse cached chat messages:",s),[]}}function $c(e,t=null,r=[]){const o=Fc(e,t);if(!o)return;const s=Es(r);if(s.length===0){xt.removeItem(o);return}xt.setItem(o,JSON.stringify(s)),t&&xt.removeItem(Oc(e))}const zc="claude-settings";function wx(){const e=xt.getItem(zc);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 kx(e){if(!e)return{success:!1};const t=wx(),r=t.allowedTools.includes(e),o=r?t.allowedTools:[...t.allowedTools,e],s=t.disallowedTools.filter(c=>c!==e),a={...t,allowedTools:o,disallowedTools:s,lastUpdated:new Date().toISOString()};return xt.setItem(zc,JSON.stringify(a)),{success:!0,alreadyAllowed:r,updatedSettings:a}}function jx({autoScrollToBottom:e,hasMessages:t,isLoadingSession:r}){return!!(e&&t&&!r)}const Sx=100;function ba(e){const t=e?.extensions?.clientRequestId||e?.payload?.clientRequestId||null;return typeof t=="string"&&t.trim()?t.trim():null}function Nx(e,t){if(!e||!t)return!1;const r=ba(e),o=ba(t);return r&&o&&r===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 Cx({selectedProject:e,selectedProjectRef:t,selectedSession:r,currentSessionId:o,setCurrentSessionId:s,provider:a,runtimePhase:c,isLoading:l,isLoadingRef:d,processingSessions:u,autoScrollToBottom:m,externalMessageUpdate:p,ws:f,sendMessage:g,chatMessages:h,setChatMessages:_,setIsLoading:y,setCanAbortSession:C,setRuntimePhase:B,setClaudeStatus:U,setPendingPermissionRequests:Q,resetStreamingState:F,clearLocalRunGuard:M,localRunGuardRef:E,pendingViewSessionRef:$,isSystemSessionChange:D,setIsSystemSessionChange:j,onSessionInactive:le,onSessionNotProcessing:te,onSessionProcessing:X}){const[Z,ae]=i.useState([]),[re,de]=i.useState(!1),[ie,q]=i.useState(!1),[ye,fe]=i.useState(0),[Te,ee]=i.useState(!1),[J,be]=i.useState(0),[Ce,ke]=i.useState(null),[he,Xe]=i.useState(!1),[De,_e]=i.useState(100),qe=i.useRef(null),Ee=i.useRef(null),We=i.useRef(!1),Ue=i.useRef(!1),Re=i.useRef(0),at=i.useRef(!1),nt=i.useRef(null),Ke=i.useRef({height:0,top:0}),Fe=i.useRef(new Map),it=i.useRef(p),ze=i.useRef(null),rt=i.useRef(r),N=e?.fullPath||e?.path||null;i.useEffect(()=>()=>{Fe.current.forEach(R=>clearTimeout(R)),Fe.current.clear(),ze.current&&(clearTimeout(ze.current),ze.current=null)},[]),i.useEffect(()=>{rt.current=r},[r]);const L=i.useCallback(async(R,Y,oe=!1,Be="claude",Ye=null)=>{if(!R||!Y)return[];const $e=!oe;$e?de(!0):q(!0);try{const yt=Ye??(oe?Re.current:0),Ve=await Ze.sessionEvents(Be,Y,R,N,Sx,yt);if(!Ve.ok)throw new Error("Failed to load session messages");const pt=await Ve.json();if($e&&pt.tokenUsage&&ke(pt.tokenUsage),pt.hasMore!==void 0){ee(pt.hasMore),be(pt.total);const S=yt+(pt.events?.length||0);return Re.current=S,fe(S),pt.events||[]}const mt=pt.events||pt.messages||[];return ee(!1),be(mt.length),Re.current=mt.length,fe(mt.length),mt}catch(yt){return console.error("Error loading session messages:",yt),[]}finally{$e?de(!1):q(!1)}},[N]),ue=i.useCallback((R,Y="claude")=>Ec(R,Y).map(oe=>({...oe,provider:oe.provider||Y})),[]),pe=r?.__provider||a||"claude",b=i.useMemo(()=>ue(Z,pe),[pe,ue,Z]),T=i.useCallback((R=[])=>ph(R),[]),A=i.useCallback((R=[])=>mh(R),[]),W=i.useCallback(R=>!(R===se.COMPLETED||R===se.ABORTED||R===se.ERRORED),[]),H=i.useCallback((R,Y)=>Y&&(B(Y),(Y===se.COMPLETED||Y===se.ABORTED||Y===se.ERRORED)&&(M(R),U(null),R&&(le?.(R),te?.(R))),Y),[M,le,te,U,B]),xe=i.useCallback(async(R,Y)=>{const oe=t.current;if(!oe?.name||!R)return null;const Be=await L(oe.name,R,!1,Y||pe);return Array.isArray(Be)&&Be.length>0&&ae(Be),T(Be)},[pe,T,L,t]),me=i.useCallback(async(R,Y)=>{const oe=await xe(R,Y);return H(R,oe)},[xe,H]),Je=i.useCallback((R,Y=[])=>{const oe=T(Y);return H(R,oe),oe},[T,H]),ge=i.useCallback((R,Y)=>Y===se.COMPLETED||Y===se.ABORTED||Y===se.ERRORED?(H(R,Y),Y):null,[H]),Le=i.useCallback((R,Y)=>{if(!R)return;const oe=Fe.current.get(R);oe&&clearTimeout(oe);const Be=setTimeout(()=>{Fe.current.delete(R);const Ye=r?.id||o||null;!Ye||Ye!==R||(me(R,Y),g&&g({type:"check-session-status",sessionId:R,provider:Y||pe}))},1200);Fe.current.set(R,Be)},[pe,o,me,r?.id,g]),tt=i.useCallback(()=>{Ee.current&&(Ee.current.scrollTop=Ee.current.scrollHeight)},[]),St=i.useCallback(()=>{if(!Ee.current)return!1;const{scrollTop:R,scrollHeight:Y,clientHeight:oe}=Ee.current;return Y-R-oe<50},[]),Nt=i.useCallback(async(R=null)=>{const Y=R||Ee.current;if(!Y||Ue.current||ie||!Te||!r||!e)return!1;const oe=r.__provider||a||"claude";Ue.current=!0;const Be=Y.scrollHeight,Ye=Y.scrollTop,$e=Re.current;try{const yt=await L(e.name,r.id,!0,oe,$e);return yt.length>0&&(nt.current={height:Be,top:Ye},ae(Ve=>[...yt,...Ve])),!0}finally{Ue.current=!1}},[Te,ie,L,a,e,r]),Ct=i.useCallback(async()=>{if(Ee.current){const R=Ee.current,Y=St();Xe(!Y),R.scrollTop<100?at.current||await Nt(R)&&(at.current=!0):at.current=!1}},[St,Nt]);i.useLayoutEffect(()=>{if(!nt.current||!Ee.current)return;const{height:R,top:Y}=nt.current,oe=Ee.current,Ye=oe.scrollHeight-R;oe.scrollTop=Y+Math.max(Ye,0),nt.current=null},[h.length]),i.useEffect(()=>{let R=!1,Y=null;return(async()=>{if(r&&e){const Be=r.__provider||Jt(localStorage.getItem("selected-provider"));We.current=!0,sessionStorage.removeItem("pendingSessionId");const Ye=o!==null&&o!==r.id;let $e=null;Ye?(D||(F(),M(),$.current=null,_([]),ae([]),U(null),C(!1)),Re.current=0,fe(0),ee(!1),be(0),ke(null),y(!1)):o===null&&(Re.current=0,fe(0),ee(!1),be(0)),s(r.id);const yt=await L(e.name,r.id,!1,r.__provider||Be||"claude");if(R)return;ae(yt),$e=Je(r.id,yt),$e||B(se.IDLE),f&&g&&W($e)&&g({type:"check-session-status",sessionId:r.id,provider:Be}),D&&!R&&j(!1)}else{const Ye=$.current?.sessionId||null||d.current&&(o||E.current.sessionId)||null,$e=!!(Ye||d.current);D||$e||(F(),M(),$.current=null,_([]),ae([]),U(null),C(!1),y(!1)),s(Ye),Re.current=0,fe(0),ee(!1),be(0),ke(null)}Y=setTimeout(()=>{R||(We.current=!1)},250)})(),()=>{R=!0,Y&&clearTimeout(Y)}},[r?.id,r?.__provider,e?.name,e?.fullPath,e?.path,L,D,F,M,Je,g,B,W,f]),i.useEffect(()=>{const R=it.current;if(p<=R||(it.current=p,!r||!e))return;const Y=r.id,oe=e.name,Be=e.fullPath||e.path||null,Ye=async()=>{try{const $e=r.__provider||Jt(localStorage.getItem("selected-provider")),yt=await L(oe,Y,!1,r.__provider||$e||"claude"),Ve=t.current,pt=rt.current,mt=Ve?.fullPath||Ve?.path||null;if(pt?.id!==Y||Ve?.name!==oe||mt!==Be)return;ae(yt),m&&St()&&setTimeout(()=>tt(),200)}catch($e){console.error("Error reloading messages from external update:",$e)}};return ze.current&&clearTimeout(ze.current),ze.current=setTimeout(()=>{ze.current=null,Ye()},500),()=>{ze.current&&(clearTimeout(ze.current),ze.current=null)}},[m,p,St,L,tt,e,t,r]),i.useEffect(()=>{it.current=p},[p,e?.name,r?.id]),i.useEffect(()=>{r?.id&&($.current=null)},[$,r?.id]),i.useEffect(()=>{const R=r?.id||o||null,Y=E.current,oe=!!(Y.startedAt&&(!Y.sessionId||!R||Y.sessionId===R)&&c!==se.IDLE);_(Be=>uh(Be,b,{preserveLocalTail:oe}))},[b,o,E,c,r?.id,_]),i.useEffect(()=>{e?.name&&$c(e.name,r?.id||null,h)},[h,e?.name,r?.id]),i.useEffect(()=>{const R=Es(h);kh(h,R)||_(R)},[h,_]),i.useEffect(()=>{o&&l&&X&&X(o)},[o,l,X]),i.useEffect(()=>{if(o&&u){const R=u.has(o),Y=A(Z);if(R&&Y){te?.(o);return}R&&!l&&c!==se.COMPLETED&&c!==se.ABORTED&&c!==se.ERRORED&&B(se.STREAMING,{canAbortSession:!0})}},[o,A,l,te,u,c,Z,B]);const vt=i.useMemo(()=>r||h.length<=De?h:h.slice(-De),[h,r,De]),v=i.useMemo(()=>{const R=vt.map((oe,Be)=>({...oe,__threadMessageId:yx(oe,Be)}));return R.length===0||!l||R.some(oe=>oe?.type==="assistant"&&!!(oe.isStreaming||oe.isToolUse||oe.isThinking||oe.reasoning))?R:[...R,{id:"__assistant-loading-indicator__",type:"assistant",content:"",timestamp:new Date,isLoadingIndicator:!0,__provider:r?.__provider||a||"claude"}]},[l,a,r?.__provider,vt]);i.useEffect(()=>{if(!m&&Ee.current){const R=Ee.current;Ke.current={height:R.scrollHeight,top:R.scrollTop}}}),i.useEffect(()=>{if(Ee.current&&h.length>0)if(m)he||setTimeout(()=>tt(),50);else{const R=Ee.current,Y=Ke.current.height,oe=Ke.current.top,Ye=R.scrollHeight-Y;Ye>0&&oe>0&&(R.scrollTop=oe+Ye)}},[m,h.length,he,tt]),i.useEffect(()=>{if(!Ee.current||!jx({autoScrollToBottom:m,hasMessages:h.length>0,isLoadingSession:We.current}))return;Xe(!1);const R=setTimeout(()=>{tt()},200);return()=>{clearTimeout(R)}},[m,h.length,tt,e?.name,r?.id]),i.useEffect(()=>{const R=Ee.current;if(R)return R.addEventListener("scroll",Ct),()=>R.removeEventListener("scroll",Ct)},[Ct]),i.useEffect(()=>{if(!e||!r?.id||tr(r.id)){ke(null);return}if((r.__provider||a||"claude")!=="claude")return;(async()=>{try{const oe=`/api/projects/${e.name}/sessions/${r.id}/token-usage`,Be=await Kt(oe);if(Be.ok){const Ye=await Be.json();ke(Ye)}else ke(null)}catch(oe){console.error("Failed to fetch initial token usage:",oe)}})()},[a,e,r?.__provider,r?.id]);const w=i.useCallback(()=>{_e(R=>R+100)},[]),V=i.useCallback(R=>{!R||typeof R!="object"||ae(Y=>{const oe=Array.isArray(Y)?Y:[];return oe.some(Be=>Nx(Be,R))?oe:[...oe,R]})},[]),je=i.useCallback(()=>{$.current=null,sessionStorage.removeItem("pendingSessionId"),s(null),ae([]),_([]),Q([]),j(!1),B(se.IDLE),U(null),C(!1),ke(null),Xe(!1),e?.name&&(xt.removeItem(`chat_messages_${e.name}`),xt.removeItem(`draft_input_${e.name}`))},[$,e?.name,C,_,U,s,j,Q,B]);return{sessionMessages:Z,setSessionMessages:ae,isLoadingSessionMessages:re,isLoadingMoreMessages:ie,messagesOffset:ye,hasMoreMessages:Te,totalMessages:J,tokenBudget:Ce,setTokenBudget:ke,scrollContainerRef:Ee,messagesEndRef:qe,isUserScrolledUp:he,setIsUserScrolledUp:Xe,visibleMessageCount:De,threadMessages:v,scrollToBottom:tt,handleScroll:Ct,loadOlderMessages:Nt,loadEarlierMessages:w,loadSessionMessages:L,appendSessionConversationEvent:V,inferRuntimePhaseFromSessionEvents:T,inferTerminalPhaseFromSessionEvents:A,recoverAndSettleSessionRuntime:me,recoverTerminalSessionPhase:ge,scheduleSessionStatusRecovery:Le,resetSessionHistoryForNewChat:je}}function Ex(e=0,t=null){const r=Number(t?.__messageSeq||0);return!Number.isFinite(r)||r<=0?!0:r>Number(e||0)}function wa(e,t={}){const r=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&&r.length===0?e||null:{availableModes:r.length>0?r:Array.isArray(e?.availableModes)?e.availableModes:[],currentModeId:o||e?.currentModeId||null}}function _x(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 Ax(e={}){const t=Number(e?.used),r=Number(e?.size);if(!Number.isFinite(t)||t<0||!Number.isFinite(r)||r<0)return null;const o=Math.round(t),s=Math.round(r);return{used:o,total:s,percentage:s>0?Math.min(100,Math.max(0,Math.round(o/s*100))):0,remaining:Math.max(0,s-o),cost:e?.cost&&typeof e.cost=="object"?e.cost:null}}function Ix({latestMessage:e,provider:t,claudeStatus:r,selectedProject:o,selectedSession:s,currentSessionId:a,setCurrentSessionId:c,isLoading:l,runtimePhase:d,sendMessage:u,persistCurrentChatCache:m,setRuntimePhase:p,setIsSystemSessionChange:f,setPendingPermissionRequests:g,setIsLoading:h,setCanAbortSession:_,setClaudeStatus:y,setChatMessages:C,setTokenBudget:B,setAcpSessionModeState:U,setAcpAvailableCommands:Q,applyRealtimeConversationEvent:F,streamBufferRef:M,streamTimerRef:E,clearLocalRunGuard:$,syncLocalRunGuardSession:D,shouldIgnoreStaleIdleSignal:j,pendingViewSessionRef:le,appendSessionConversationEvent:te,recoverAndSettleSessionRuntime:X,recoverTerminalSessionPhase:Z,inferRuntimePhaseFromSessionEvents:ae,inferTerminalPhaseFromSessionEvents:re,scheduleSessionStatusRecovery:de,sessionMessages:ie,setSessionMessages:q,loadSessionMessages:ye,onSessionInactive:fe,onSessionNotProcessing:Te,onSessionProcessing:ee,onReplaceTemporarySession:J,onNavigateToSession:be,t:Ce}){const ke=i.useRef(null),he=i.useRef(new Set),Xe=i.useRef(0),De=s?.__provider||t||"claude";i.useEffect(()=>()=>{E.current&&(clearTimeout(E.current),E.current=null),M.current=""},[M,E]),i.useEffect(()=>{ke.current=r},[r]),i.useEffect(()=>{if(!e||!Ex(Xe.current,e))return;Number.isFinite(Number(e.__messageSeq))&&Number(e.__messageSeq)>0&&(Xe.current=Number(e.__messageSeq));const _e=e.data?.message||e.data,Ee=["projects_updated","session-created"].includes(e.type),We=new Set(["claude-complete","codex-complete","session-aborted","claude-error","codex-error"]),Ue=e.type==="conversation-event"?String(e.event?.payload?.state||"").trim().toLowerCase():"",Re=e.type==="conversation-event"&&(e.event?.kind==="error"||e.event?.kind==="session_state_changed"&&["streaming","awaiting_approval","completed","aborted","errored"].includes(Ue)),nt=e.type==="claude-response"&&_e&&_e.type==="system"&&_e.subtype==="init"?_e?.session_id:null,Ke=sessionStorage.getItem("pendingSessionId");let Fe=s?.id||a||le.current?.sessionId||null;const it=nt&&(!Fe||nt===Fe),ze=Ee||it,rt=!e.sessionId&&le.current&&!le.current.sessionId&&(/error/i.test(e.type||"")||e.type==="conversation-event"&&e.event?.kind==="error"),N=b=>{b&&(fe?.(b),Te?.(b))},L=b=>{b&&ee?.(b)};if(!ze){if(!Fe&&e.sessionId&&!Fr(e.sessionId)&&le.current&&!le.current.sessionId&&(Fe=e.sessionId,le.current.sessionId=e.sessionId,c(e.sessionId)),!Fe&&(e.sessionId&&(We.has(e.type)||Re)&&(Ue==="streaming"||Ue==="awaiting_approval"?L(e.sessionId):N(e.sessionId)),!rt)||!e.sessionId&&!rt)return;if(!rt&&e.sessionId!==Fe){const b=Fr(Fe),T=!!(e.sessionId&&Ke&&e.sessionId===Ke);if(b&&(T||!Fr(e.sessionId||"")))c(e.sessionId),le.current&&(le.current.sessionId=e.sessionId);else{e.sessionId&&(We.has(e.type)||Re)&&(Ue==="streaming"||Ue==="awaiting_approval"?L(e.sessionId):N(e.sessionId)),console.log("Skipping message for different session:",e.sessionId,"current:",Fe);return}}}const ue=e?.event?.sessionId||e.sessionId||Fe||null,pe=!!(ue&&he.current.has(ue));if(e.type==="conversation-event"&&e.event){const b=e.event.sessionId||e.sessionId||Fe||null,T=e.event.rawRef?.type||null,A=e.event.kind==="session_state_changed"?String(e.event.payload?.state||"").trim().toLowerCase():"";if(b&&he.current.add(b),A==="idle"&&j(b,T)){de(b,e.event.provider||De);return}if(!!(b&&(b===(s?.id||null)||b===(a||null)||b===(le.current?.sessionId||null)))&&te(e.event),F(e.event,e.event.provider||De),e.event.kind==="mode_update"&&U(H=>wa(H,e.event.payload)),e.event.kind==="available_commands_update"&&Q(_x(e.event.payload)),e.event.kind==="usage_update"){const H=Ax(e.event.payload);H&&B(H)}if(e.event.kind==="approval_request"&&p(se.AWAITING_APPROVAL),e.event.kind==="approval_resolved"&&p(se.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(se.STREAMING),(e.event.kind==="error"||e.event.payload?.state==="errored")&&($(b),p(se.ERRORED),y(null),b&&(N(b),X(b,e.event.provider||De))),e.event.kind==="session_state_changed"){const H=A;H==="streaming"?(p(se.STREAMING),b&&ee&&ee(b)):H==="awaiting_approval"?(p(se.AWAITING_APPROVAL),b&&ee&&ee(b)):H==="completed"?($(b),p(se.COMPLETED),y(null),b&&(N(b),X(b,e.event.provider||De))):H==="aborted"?($(b),p(se.ABORTED),y(null),b&&(N(b),X(b,e.event.provider||De))):H==="errored"&&($(b),p(se.ERRORED),y(null),b&&(N(b),X(b,e.event.provider||De)))}return}switch(e.type){case"ws-connection-state":e.state==="connecting"&&(d===se.QUEUED||l)?p(se.CONNECTING,{canAbortSession:!1}):e.state==="connected"&&d===se.CONNECTING&&p(se.QUEUED);break;case"connection-error":p(se.ERRORED),y(null),C(b=>[...b,{type:"error",content:e.error||"Unable to reach the chat server. Message was not sent.",timestamp:new Date}]);break;case"error":p(se.ERRORED),_(!1),y(null),C(b=>[...b,{type:"error",content:e.error||"The chat server reported an unexpected error.",timestamp:new Date}]);break;case"session-created":if(e.sessionId){const b=Jt(e.provider||De||t||"claude"),T=le.current?.sessionId||a||null,A=Fr(e.sessionId);if(!(!a||b==="codex"&&e.sessionId!==a)||A)break;sessionStorage.setItem("pendingSessionId",e.sessionId);try{const H=localStorage.getItem("session-provider-map"),xe=H?JSON.parse(H):{};xe[e.sessionId]=b,localStorage.setItem("session-provider-map",JSON.stringify(xe))}catch{}m(e.sessionId),e.modes&&U(H=>wa(H,e.modes)),le.current&&(le.current.sessionId=e.sessionId),c(e.sessionId),D(e.sessionId),ee?.(e.sessionId),f(!0),J&&J(e.sessionId,T),g(H=>H.map(xe=>xe.sessionId?xe:{...xe,sessionId:e.sessionId})),be&&be(e.sessionId,b,o?.fullPath||o?.path||null),typeof window<"u"&&typeof window.refreshProjects=="function"&&window.refreshProjects()}break;case"token-budget":e.data&&B(e.data);break;case"claude-response":{const b=pe&&!(e.data?.type==="system"&&e.data?.subtype==="init");if(!b&&_e&&typeof _e=="object"&&_e.type){if(_e.type==="content_block_delta"&&_e.delta?.text){const T=Nn(_e.delta.text);M.current+=T,E.current||(E.current=setTimeout(()=>{const A=M.current;M.current="",E.current=null,A&&C(W=>{const H=[...W],xe=H[H.length-1];return xe&&xe.type==="assistant"&&!xe.isToolUse&&xe.isStreaming?H[H.length-1]={...xe,content:(xe.content||"")+A}:H.push({type:"assistant",content:A,timestamp:new Date,isStreaming:!0}),H})},100));return}if(_e.type==="content_block_stop"){E.current&&(clearTimeout(E.current),E.current=null);const T=M.current;M.current="",T&&C(A=>{const W=[...A],H=W[W.length-1];return H&&H.type==="assistant"&&!H.isToolUse&&H.isStreaming?W[W.length-1]={...H,content:(H.content||"")+T}:W.push({type:"assistant",content:T,timestamp:new Date,isStreaming:!0}),W}),C(A=>{const W=[...A],H=W[W.length-1];return H&&H.type==="assistant"&&H.isStreaming&&(W[W.length-1]={...H,isStreaming:!1}),W});return}}if(e.data.type==="system"&&e.data.subtype==="init"&&e.data.session_id&&a&&e.data.session_id!==a&&it){f(!0),m(e.data.session_id),be?.(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&&it){f(!0),m(e.data.session_id),be?.(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&&it)return;if(b)break;if(Array.isArray(_e.content)){for(const T of _e.content)if(T.type==="tool_use"){const A=T.input?JSON.stringify(T.input,null,2):"";C(W=>[...W,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:T.name,toolInput:A,toolId:T.id,toolResult:null}])}else if(T.type==="text"&&T.text?.trim()){let A=Nn(T.text);A=Xo(A),C(W=>[...W,{type:"assistant",content:A,timestamp:new Date}])}}else if(typeof _e.content=="string"&&_e.content.trim()){let T=Nn(_e.content);T=Xo(T),C(A=>[...A,{type:"assistant",content:T,timestamp:new Date}])}if(_e.role==="user"&&Array.isArray(_e.content))for(const T of _e.content)T.type==="tool_result"&&C(A=>A.map(W=>W.isToolUse&&W.toolId===T.tool_use_id?{...W,toolResult:{content:T.content,isError:T.is_error,timestamp:new Date}}:W));break}case"claude-output":if(pe)break;{const b=String(e.data||"");b.trim()&&(M.current+=M.current?`
209
+ ${b}`:b,E.current||(E.current=setTimeout(()=>{const T=M.current;M.current="",E.current=null,T&&C(A=>{const W=[...A],H=W[W.length-1];return H&&H.type==="assistant"&&!H.isToolUse&&H.isStreaming?W[W.length-1]={...H,content:H.content?`${H.content}
210
+ ${T}`:T}:W.push({type:"assistant",content:T,timestamp:new Date,isStreaming:!0}),W})},100)))}break;case"claude-interactive-prompt":C(b=>[...b,{type:"assistant",content:e.data,timestamp:new Date,isInteractivePrompt:!0}]);break;case"claude-permission-request":if(pe||t!=="claude"||!e.requestId)break;g(b=>b.some(T=>T.requestId===e.requestId)?b:[...b,{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}]),h(!0),_(!0),y(_s({phaseText:Ce("activity.stage.waitingPermission"),detailText:e.toolName?Ce("activity.requestTool",{tool:Fd(e.toolName)}):Ce("activity.permission.title"),canAbort:!0}));break;case"claude-permission-cancelled":if(pe||!e.requestId)break;g(b=>{const T=b.filter(A=>A.requestId!==e.requestId);return T.length===0&&y(null),T});break;case"claude-error":if(pe)break;$(e.sessionId||a||null),h(!1),_(!1),y(null),C(b=>[...b,{type:"error",content:`出错了:${e.error}`,timestamp:new Date}]);break;case"claude-complete":{if(pe)break;const b=e.sessionId||a||sessionStorage.getItem("pendingSessionId");$(b),(b===a||!a)&&(h(!1),_(!1),y(null)),b&&(fe?.(b),Te?.(b));const T=sessionStorage.getItem("pendingSessionId");T&&!a&&e.exitCode===0&&(c(T),sessionStorage.removeItem("pendingSessionId")),o&&e.exitCode===0&&xt.removeItem(`chat_messages_${o.name}`),g([]);break}case"codex-response":{const b=e.data;if(!b||pe)break;if(b.type==="item_delta"&&b.delta){const T=Nn(String(b.delta));if(T){const A=`codex:${b.itemType||"item"}:${b.itemId||"unknown"}`;C(W=>{const H=[...W];let xe=-1;for(let me=H.length-1;me>=0;me-=1){const Je=H[me];if(Je?.codexItemKey===A&&Je.type==="assistant"&&!Je.isToolUse){xe=me;break}}if(xe===-1)H.push({type:"assistant",content:T,timestamp:new Date,isStreaming:!0,isThinking:!!b.isReasoning,codexItemKey:A});else{const me=H[xe],Je=me.content||"";Je.endsWith(T)||(me.content=Je+T),me.isStreaming=!0}return H})}break}if(b.type==="item_done"){const T=`codex:${b.itemType||"item"}:${b.itemId||"unknown"}`,A=typeof b.content=="string"?Nn(b.content):"";C(W=>{const H=[...W];let xe=-1;for(let me=H.length-1;me>=0;me-=1){const Je=H[me];if(Je?.codexItemKey===T&&Je.type==="assistant"&&!Je.isToolUse){xe=me;break}}if(xe!==-1){const me=H[xe];A&&A!==(me.content||"")&&(me.content=A),me.isStreaming=!1}else A.trim()&&H.push({type:"assistant",content:A,timestamp:new Date,isStreaming:!1,isThinking:!!b.isReasoning});return H});break}if(b.type==="item")switch(b.itemType){case"agent_message":if(b.message?.content?.trim()){const T=Nn(b.message.content);C(A=>{const W=A[A.length-1];return W&&W.type==="assistant"&&!W.isToolUse&&!W.isThinking&&(W.content||"").trim()===T.trim()?A:[...A,{type:"assistant",content:T,timestamp:new Date}]})}break;case"reasoning":if(b.message?.content?.trim()){const T=Nn(b.message.content);C(A=>{const W=A[A.length-1];return W&&W.type==="assistant"&&!W.isToolUse&&W.isThinking&&(W.content||"").trim()===T.trim()?A:[...A,{type:"assistant",content:T,timestamp:new Date,isThinking:!0}]})}break;case"command_execution":b.command&&C(T=>[...T,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:"Bash",toolInput:b.command,toolResult:b.output||null,exitCode:b.exitCode}]);break;case"file_change":if(b.changes?.length>0){const T=b.changes.map(A=>`${A.kind}: ${A.path}`).join(`
211
+ `);C(A=>[...A,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:"FileChanges",toolInput:T,toolResult:`Status: ${b.status}`}])}break;case"mcp_tool_call":C(T=>[...T,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:`${b.server}:${b.tool}`,toolInput:JSON.stringify(b.arguments,null,2),toolResult:b.result?JSON.stringify(b.result,null,2):b.error?.message||null}]);break;case"error":b.message?.content&&C(T=>[...T,{type:"error",content:b.message.content,timestamp:new Date}]);break;default:console.log("[Codex] Unhandled item type:",b.itemType,b)}b.type==="turn_complete"&&h(!1),b.type==="turn_failed"&&(h(!1),C(T=>[...T,{type:"error",content:b.error?.message||"Turn failed",timestamp:new Date}]));break}case"codex-complete":{if(pe)break;const b=e.sessionId||a||sessionStorage.getItem("pendingSessionId");$(b),(b===a||!a)&&(h(!1),_(!1),y(null),C(W=>W.map(H=>H?.codexItemKey&&H.isStreaming?{...H,isStreaming:!1}:H))),b&&(fe?.(b),Te?.(b));const T=sessionStorage.getItem("pendingSessionId"),A=e.actualSessionId||T;T&&!a&&(c(A),f(!0),be?.(A,"codex",o?.fullPath||o?.path||null),sessionStorage.removeItem("pendingSessionId")),o&&b&&ye(o.name,b,!1,"codex").then(W=>{Array.isArray(W)&&W.length>0&&q(W)}).catch(W=>{console.error("Error reloading Codex session after completion:",W)}),o&&xt.removeItem(`chat_messages_${o.name}`);break}case"codex-error":if(pe)break;$(e.sessionId||a||null),h(!1),_(!1),C(b=>b.map(T=>T?.codexItemKey&&T.isStreaming?{...T,isStreaming:!1}:T)),C(b=>[...b,{type:"error",content:e.error||"An error occurred with Codex",timestamp:new Date}]);break;case"session-aborted":{if(pe)break;const b=e.sessionId||a;$(b),b===a&&(h(!1),_(!1),y(null)),b&&(fe?.(b),Te?.(b)),g([]),C(T=>[...T,{type:"assistant",content:"Session interrupted by user.",timestamp:new Date}]);break}case"session-status":{if(pe)break;const b=e.sessionId,T=e.provider||s?.__provider||De,A=b===a||s&&b===s.id,W=ae(ie),H=re(ie);if(A&&e.isProcessing){if(H){Z(b,H);break}h(!0),_(!0),ee?.(b)}else if(A&&e.isProcessing===!1){if(j(b,"session-status")){de(b,T);break}X(b,T).then(xe=>{if(!(xe===se.COMPLETED||xe===se.ABORTED||xe===se.ERRORED)){if(W===se.STREAMING||W===se.AWAITING_APPROVAL){p(W);return}h(!1),_(!1),y(null)}})}break}case"claude-status":{const b=e.data;if(b){let T={text:"Working...",tokens:0,can_interrupt:!0};b.message?T.text=b.message:b.status?T.text=b.status:typeof b=="string"&&(T.text=b),b.tokens?T.tokens=b.tokens:b.token_count&&(T.tokens=b.token_count),b.can_interrupt!==void 0&&(T.can_interrupt=b.can_interrupt);const A=jh(b,Ce,ke.current);ke.current=A,y(A),h(!0),_(T.can_interrupt)}break}}},[De,te,F,$,a,ae,re,l,e,ye,be,J,fe,Te,ee,le,m,t,X,Z,d,de,o,s,ie,Q,U,_,C,y,c,h,f,g,q,B,j,D,Ce])}function gn(e){return Array.isArray?Array.isArray(e):Wc(e)==="[object Array]"}function Tx(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function Px(e){return e==null?"":Tx(e)}function dn(e){return typeof e=="string"}function Bc(e){return typeof e=="number"}function Rx(e){return e===!0||e===!1||Mx(e)&&Wc(e)=="[object Boolean]"}function Uc(e){return typeof e=="object"}function Mx(e){return Uc(e)&&e!==null}function Wt(e){return e!=null}function _o(e){return!e.trim().length}function Wc(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const Dx="Incorrect 'index' type",Lx=e=>`Invalid value for key ${e}`,Ox=e=>`Pattern length exceeds max of ${e}.`,Fx=e=>`Missing ${e} property in key`,$x=e=>`Property 'weight' in key '${e}' must be a positive integer`,ka=Object.prototype.hasOwnProperty;class zx{constructor(t){this._keys=[],this._keyMap={};let r=0;t.forEach(o=>{let s=Kc(o);this._keys.push(s),this._keyMap[s.id]=s,r+=s.weight}),this._keys.forEach(o=>{o.weight/=r})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Kc(e){let t=null,r=null,o=null,s=1,a=null;if(dn(e)||gn(e))o=e,t=ja(e),r=ts(e);else{if(!ka.call(e,"name"))throw new Error(Fx("name"));const c=e.name;if(o=c,ka.call(e,"weight")&&(s=e.weight,s<=0))throw new Error($x(c));t=ja(c),r=ts(c),a=e.getFn}return{path:t,id:r,weight:s,src:o,getFn:a}}function ja(e){return gn(e)?e:e.split(".")}function ts(e){return gn(e)?e.join("."):e}function Bx(e,t){let r=[],o=!1;const s=(a,c,l)=>{if(Wt(a))if(!c[l])r.push(a);else{let d=c[l];const u=a[d];if(!Wt(u))return;if(l===c.length-1&&(dn(u)||Bc(u)||Rx(u)))r.push(Px(u));else if(gn(u)){o=!0;for(let m=0,p=u.length;m<p;m+=1)s(u[m],c,l+1)}else c.length&&s(u,c,l+1)}};return s(e,dn(t)?t.split("."):t,0),o?r:r[0]}const Ux={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Wx={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},Kx={location:0,threshold:.6,distance:100},qx={useExtendedSearch:!1,getFn:Bx,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var Pe={...Wx,...Ux,...Kx,...qx};const Vx=/[^ ]+/g;function Hx(e=1,t=3){const r=new Map,o=Math.pow(10,t);return{get(s){const a=s.match(Vx).length;if(r.has(a))return r.get(a);const c=1/Math.pow(a,.5*e),l=parseFloat(Math.round(c*o)/o);return r.set(a,l),l},clear(){r.clear()}}}class Is{constructor({getFn:t=Pe.getFn,fieldNormWeight:r=Pe.fieldNormWeight}={}){this.norm=Hx(r,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((r,o)=>{this._keysMap[r.id]=o})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,dn(this.docs[0])?this.docs.forEach((t,r)=>{this._addString(t,r)}):this.docs.forEach((t,r)=>{this._addObject(t,r)}),this.norm.clear())}add(t){const r=this.size();dn(t)?this._addString(t,r):this._addObject(t,r)}removeAt(t){this.records.splice(t,1);for(let r=t,o=this.size();r<o;r+=1)this.records[r].i-=1}getValueForItemAtKeyId(t,r){return t[this._keysMap[r]]}size(){return this.records.length}_addString(t,r){if(!Wt(t)||_o(t))return;let o={v:t,i:r,n:this.norm.get(t)};this.records.push(o)}_addObject(t,r){let o={i:r,$:{}};this.keys.forEach((s,a)=>{let c=s.getFn?s.getFn(t):this.getFn(t,s.path);if(Wt(c)){if(gn(c)){let l=[];const d=[{nestedArrIndex:-1,value:c}];for(;d.length;){const{nestedArrIndex:u,value:m}=d.pop();if(Wt(m))if(dn(m)&&!_o(m)){let p={v:m,i:u,n:this.norm.get(m)};l.push(p)}else gn(m)&&m.forEach((p,f)=>{d.push({nestedArrIndex:f,value:p})})}o.$[a]=l}else if(dn(c)&&!_o(c)){let l={v:c,n:this.norm.get(c)};o.$[a]=l}}}),this.records.push(o)}toJSON(){return{keys:this.keys,records:this.records}}}function qc(e,t,{getFn:r=Pe.getFn,fieldNormWeight:o=Pe.fieldNormWeight}={}){const s=new Is({getFn:r,fieldNormWeight:o});return s.setKeys(e.map(Kc)),s.setSources(t),s.create(),s}function Gx(e,{getFn:t=Pe.getFn,fieldNormWeight:r=Pe.fieldNormWeight}={}){const{keys:o,records:s}=e,a=new Is({getFn:t,fieldNormWeight:r});return a.setKeys(o),a.setIndexRecords(s),a}function $r(e,{errors:t=0,currentLocation:r=0,expectedLocation:o=0,distance:s=Pe.distance,ignoreLocation:a=Pe.ignoreLocation}={}){const c=t/e.length;if(a)return c;const l=Math.abs(o-r);return s?c+l/s:l?1:c}function Jx(e=[],t=Pe.minMatchCharLength){let r=[],o=-1,s=-1,a=0;for(let c=e.length;a<c;a+=1){let l=e[a];l&&o===-1?o=a:!l&&o!==-1&&(s=a-1,s-o+1>=t&&r.push([o,s]),o=-1)}return e[a-1]&&a-o>=t&&r.push([o,a-1]),r}const En=32;function Yx(e,t,r,{location:o=Pe.location,distance:s=Pe.distance,threshold:a=Pe.threshold,findAllMatches:c=Pe.findAllMatches,minMatchCharLength:l=Pe.minMatchCharLength,includeMatches:d=Pe.includeMatches,ignoreLocation:u=Pe.ignoreLocation}={}){if(t.length>En)throw new Error(Ox(En));const m=t.length,p=e.length,f=Math.max(0,Math.min(o,p));let g=a,h=f;const _=l>1||d,y=_?Array(p):[];let C;for(;(C=e.indexOf(t,h))>-1;){let E=$r(t,{currentLocation:C,expectedLocation:f,distance:s,ignoreLocation:u});if(g=Math.min(E,g),h=C+m,_){let $=0;for(;$<m;)y[C+$]=1,$+=1}}h=-1;let B=[],U=1,Q=m+p;const F=1<<m-1;for(let E=0;E<m;E+=1){let $=0,D=Q;for(;$<D;)$r(t,{errors:E,currentLocation:f+D,expectedLocation:f,distance:s,ignoreLocation:u})<=g?$=D:Q=D,D=Math.floor((Q-$)/2+$);Q=D;let j=Math.max(1,f-D+1),le=c?p:Math.min(f+D,p)+m,te=Array(le+2);te[le+1]=(1<<E)-1;for(let Z=le;Z>=j;Z-=1){let ae=Z-1,re=r[e.charAt(ae)];if(_&&(y[ae]=+!!re),te[Z]=(te[Z+1]<<1|1)&re,E&&(te[Z]|=(B[Z+1]|B[Z])<<1|1|B[Z+1]),te[Z]&F&&(U=$r(t,{errors:E,currentLocation:ae,expectedLocation:f,distance:s,ignoreLocation:u}),U<=g)){if(g=U,h=ae,h<=f)break;j=Math.max(1,2*f-h)}}if($r(t,{errors:E+1,currentLocation:f,expectedLocation:f,distance:s,ignoreLocation:u})>g)break;B=te}const M={isMatch:h>=0,score:Math.max(.001,U)};if(_){const E=Jx(y,l);E.length?d&&(M.indices=E):M.isMatch=!1}return M}function Xx(e){let t={};for(let r=0,o=e.length;r<o;r+=1){const s=e.charAt(r);t[s]=(t[s]||0)|1<<o-r-1}return t}const Qr=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 Vc{constructor(t,{location:r=Pe.location,threshold:o=Pe.threshold,distance:s=Pe.distance,includeMatches:a=Pe.includeMatches,findAllMatches:c=Pe.findAllMatches,minMatchCharLength:l=Pe.minMatchCharLength,isCaseSensitive:d=Pe.isCaseSensitive,ignoreDiacritics:u=Pe.ignoreDiacritics,ignoreLocation:m=Pe.ignoreLocation}={}){if(this.options={location:r,threshold:o,distance:s,includeMatches:a,findAllMatches:c,minMatchCharLength:l,isCaseSensitive:d,ignoreDiacritics:u,ignoreLocation:m},t=d?t:t.toLowerCase(),t=u?Qr(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const p=(g,h)=>{this.chunks.push({pattern:g,alphabet:Xx(g),startIndex:h})},f=this.pattern.length;if(f>En){let g=0;const h=f%En,_=f-h;for(;g<_;)p(this.pattern.substr(g,En),g),g+=En;if(h){const y=f-En;p(this.pattern.substr(y),y)}}else p(this.pattern,0)}searchIn(t){const{isCaseSensitive:r,ignoreDiacritics:o,includeMatches:s}=this.options;if(t=r?t:t.toLowerCase(),t=o?Qr(t):t,this.pattern===t){let _={isMatch:!0,score:0};return s&&(_.indices=[[0,t.length-1]]),_}const{location:a,distance:c,threshold:l,findAllMatches:d,minMatchCharLength:u,ignoreLocation:m}=this.options;let p=[],f=0,g=!1;this.chunks.forEach(({pattern:_,alphabet:y,startIndex:C})=>{const{isMatch:B,score:U,indices:Q}=Yx(t,_,y,{location:a+C,distance:c,threshold:l,findAllMatches:d,minMatchCharLength:u,includeMatches:s,ignoreLocation:m});B&&(g=!0),f+=U,B&&Q&&(p=[...p,...Q])});let h={isMatch:g,score:g?f/this.chunks.length:1};return g&&s&&(h.indices=p),h}}class kn{constructor(t){this.pattern=t}static isMultiMatch(t){return Sa(t,this.multiRegex)}static isSingleMatch(t){return Sa(t,this.singleRegex)}search(){}}function Sa(e,t){const r=e.match(t);return r?r[1]:null}class Qx extends kn{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const r=t===this.pattern;return{isMatch:r,score:r?0:1,indices:[0,this.pattern.length-1]}}}class Zx extends kn{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 eg extends kn{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const r=t.startsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[0,this.pattern.length-1]}}}class tg extends kn{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const r=!t.startsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[0,t.length-1]}}}class ng extends kn{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const r=t.endsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class rg extends kn{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const r=!t.endsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[0,t.length-1]}}}class Hc extends kn{constructor(t,{location:r=Pe.location,threshold:o=Pe.threshold,distance:s=Pe.distance,includeMatches:a=Pe.includeMatches,findAllMatches:c=Pe.findAllMatches,minMatchCharLength:l=Pe.minMatchCharLength,isCaseSensitive:d=Pe.isCaseSensitive,ignoreDiacritics:u=Pe.ignoreDiacritics,ignoreLocation:m=Pe.ignoreLocation}={}){super(t),this._bitapSearch=new Vc(t,{location:r,threshold:o,distance:s,includeMatches:a,findAllMatches:c,minMatchCharLength:l,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 Gc extends kn{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let r=0,o;const s=[],a=this.pattern.length;for(;(o=t.indexOf(this.pattern,r))>-1;)r=o+a,s.push([o,r-1]);const c=!!s.length;return{isMatch:c,score:c?0:1,indices:s}}}const ns=[Qx,Gc,eg,tg,rg,ng,Zx,Hc],Na=ns.length,og=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,sg="|";function ag(e,t={}){return e.split(sg).map(r=>{let o=r.trim().split(og).filter(a=>a&&!!a.trim()),s=[];for(let a=0,c=o.length;a<c;a+=1){const l=o[a];let d=!1,u=-1;for(;!d&&++u<Na;){const m=ns[u];let p=m.isMultiMatch(l);p&&(s.push(new m(p,t)),d=!0)}if(!d)for(u=-1;++u<Na;){const m=ns[u];let p=m.isSingleMatch(l);if(p){s.push(new m(p,t));break}}}return s})}const ig=new Set([Hc.type,Gc.type]);class cg{constructor(t,{isCaseSensitive:r=Pe.isCaseSensitive,ignoreDiacritics:o=Pe.ignoreDiacritics,includeMatches:s=Pe.includeMatches,minMatchCharLength:a=Pe.minMatchCharLength,ignoreLocation:c=Pe.ignoreLocation,findAllMatches:l=Pe.findAllMatches,location:d=Pe.location,threshold:u=Pe.threshold,distance:m=Pe.distance}={}){this.query=null,this.options={isCaseSensitive:r,ignoreDiacritics:o,includeMatches:s,minMatchCharLength:a,findAllMatches:l,ignoreLocation:c,location:d,threshold:u,distance:m},t=r?t:t.toLowerCase(),t=o?Qr(t):t,this.pattern=t,this.query=ag(this.pattern,this.options)}static condition(t,r){return r.useExtendedSearch}searchIn(t){const r=this.query;if(!r)return{isMatch:!1,score:1};const{includeMatches:o,isCaseSensitive:s,ignoreDiacritics:a}=this.options;t=s?t:t.toLowerCase(),t=a?Qr(t):t;let c=0,l=[],d=0;for(let u=0,m=r.length;u<m;u+=1){const p=r[u];l.length=0,c=0;for(let f=0,g=p.length;f<g;f+=1){const h=p[f],{isMatch:_,indices:y,score:C}=h.search(t);if(_){if(c+=1,d+=C,o){const B=h.constructor.type;ig.has(B)?l=[...l,...y]:l.push(y)}}else{d=0,c=0,l.length=0;break}}if(c){let f={isMatch:!0,score:d/c};return o&&(f.indices=l),f}}return{isMatch:!1,score:1}}}const rs=[];function lg(...e){rs.push(...e)}function os(e,t){for(let r=0,o=rs.length;r<o;r+=1){let s=rs[r];if(s.condition(e,t))return new s(e,t)}return new Vc(e,t)}const Zr={AND:"$and",OR:"$or"},ss={PATH:"$path",PATTERN:"$val"},as=e=>!!(e[Zr.AND]||e[Zr.OR]),dg=e=>!!e[ss.PATH],ug=e=>!gn(e)&&Uc(e)&&!as(e),Ca=e=>({[Zr.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function Jc(e,t,{auto:r=!0}={}){const o=s=>{let a=Object.keys(s);const c=dg(s);if(!c&&a.length>1&&!as(s))return o(Ca(s));if(ug(s)){const d=c?s[ss.PATH]:a[0],u=c?s[ss.PATTERN]:s[d];if(!dn(u))throw new Error(Lx(d));const m={keyId:ts(d),pattern:u};return r&&(m.searcher=os(u,t)),m}let l={children:[],operator:a[0]};return a.forEach(d=>{const u=s[d];gn(u)&&u.forEach(m=>{l.children.push(o(m))})}),l};return as(e)||(e=Ca(e)),o(e)}function pg(e,{ignoreFieldNorm:t=Pe.ignoreFieldNorm}){e.forEach(r=>{let o=1;r.matches.forEach(({key:s,norm:a,score:c})=>{const l=s?s.weight:null;o*=Math.pow(c===0&&l?Number.EPSILON:c,(l||1)*(t?1:a))}),r.score=o})}function mg(e,t){const r=e.matches;t.matches=[],Wt(r)&&r.forEach(o=>{if(!Wt(o.indices)||!o.indices.length)return;const{indices:s,value:a}=o;let c={indices:s,value:a};o.key&&(c.key=o.key.src),o.idx>-1&&(c.refIndex=o.idx),t.matches.push(c)})}function fg(e,t){t.score=e.score}function hg(e,t,{includeMatches:r=Pe.includeMatches,includeScore:o=Pe.includeScore}={}){const s=[];return r&&s.push(mg),o&&s.push(fg),e.map(a=>{const{idx:c}=a,l={item:t[c],refIndex:c};return s.length&&s.forEach(d=>{d(a,l)}),l})}class Vn{constructor(t,r={},o){this.options={...Pe,...r},this.options.useExtendedSearch,this._keyStore=new zx(this.options.keys),this.setCollection(t,o)}setCollection(t,r){if(this._docs=t,r&&!(r instanceof Is))throw new Error(Dx);this._myIndex=r||qc(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){Wt(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const r=[];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,r.push(a))}return r}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:r=-1}={}){const{includeMatches:o,includeScore:s,shouldSort:a,sortFn:c,ignoreFieldNorm:l}=this.options;let d=dn(t)?dn(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return pg(d,{ignoreFieldNorm:l}),a&&d.sort(c),Bc(r)&&r>-1&&(d=d.slice(0,r)),hg(d,this._docs,{includeMatches:o,includeScore:s})}_searchStringList(t){const r=os(t,this.options),{records:o}=this._myIndex,s=[];return o.forEach(({v:a,i:c,n:l})=>{if(!Wt(a))return;const{isMatch:d,score:u,indices:m}=r.searchIn(a);d&&s.push({item:a,idx:c,matches:[{score:u,value:a,norm:l,indices:m}]})}),s}_searchLogical(t){const r=Jc(t,this.options),o=(l,d,u)=>{if(!l.children){const{keyId:p,searcher:f}=l,g=this._findMatches({key:this._keyStore.get(p),value:this._myIndex.getValueForItemAtKeyId(d,p),searcher:f});return g&&g.length?[{idx:u,item:d,matches:g}]:[]}const m=[];for(let p=0,f=l.children.length;p<f;p+=1){const g=l.children[p],h=o(g,d,u);if(h.length)m.push(...h);else if(l.operator===Zr.AND)return[]}return m},s=this._myIndex.records,a={},c=[];return s.forEach(({$:l,i:d})=>{if(Wt(l)){let u=o(r,l,d);u.length&&(a[d]||(a[d]={idx:d,item:l,matches:[]},c.push(a[d])),u.forEach(({matches:m})=>{a[d].matches.push(...m)}))}}),c}_searchObjectList(t){const r=os(t,this.options),{keys:o,records:s}=this._myIndex,a=[];return s.forEach(({$:c,i:l})=>{if(!Wt(c))return;let d=[];o.forEach((u,m)=>{d.push(...this._findMatches({key:u,value:c[m],searcher:r}))}),d.length&&a.push({idx:l,item:c,matches:d})}),a}_findMatches({key:t,value:r,searcher:o}){if(!Wt(r))return[];let s=[];if(gn(r))r.forEach(({v:a,i:c,n:l})=>{if(!Wt(a))return;const{isMatch:d,score:u,indices:m}=o.searchIn(a);d&&s.push({score:u,key:t,value:a,idx:c,norm:l,indices:m})});else{const{v:a,n:c}=r,{isMatch:l,score:d,indices:u}=o.searchIn(a);l&&s.push({score:d,key:t,value:a,norm:c,indices:u})}return s}}Vn.version="7.1.0";Vn.createIndex=qc;Vn.parseIndex=Gx;Vn.config=Pe;Vn.parseQuery=Jc;lg(cg);var Ao={exports:{}},Io,Ea;function xg(){if(Ea)return Io;Ea=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Io=e,Io}var To,_a;function gg(){if(_a)return To;_a=1;var e=xg();function t(){}function r(){}return r.resetWarningCache=t,To=function(){function o(c,l,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:r,resetWarningCache:t};return a.PropTypes=a,a},To}var Aa;function vg(){return Aa||(Aa=1,Ao.exports=gg()()),Ao.exports}var yg=vg();const ft=ii(yg),bg=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 Kn(e,t,r){const o=wg(e),{webkitRelativePath:s}=e,a=typeof t=="string"?t:typeof s=="string"&&s.length>0?s:`./${e.name}`;return typeof o.path!="string"&&Ia(o,"path",a),Ia(o,"relativePath",a),o}function wg(e){const{name:t}=e;if(t&&t.lastIndexOf(".")!==-1&&!e.type){const o=t.split(".").pop().toLowerCase(),s=bg.get(o);s&&Object.defineProperty(e,"type",{value:s,writable:!1,configurable:!1,enumerable:!0})}return e}function Ia(e,t,r){Object.defineProperty(e,t,{value:r,writable:!1,configurable:!1,enumerable:!0})}const kg=[".DS_Store","Thumbs.db"];function jg(e){return Dn(this,void 0,void 0,function*(){return eo(e)&&Sg(e.dataTransfer)?_g(e.dataTransfer,e.type):Ng(e)?Cg(e):Array.isArray(e)&&e.every(t=>"getFile"in t&&typeof t.getFile=="function")?Eg(e):[]})}function Sg(e){return eo(e)}function Ng(e){return eo(e)&&eo(e.target)}function eo(e){return typeof e=="object"&&e!==null}function Cg(e){return is(e.target.files).map(t=>Kn(t))}function Eg(e){return Dn(this,void 0,void 0,function*(){return(yield Promise.all(e.map(r=>r.getFile()))).map(r=>Kn(r))})}function _g(e,t){return Dn(this,void 0,void 0,function*(){if(e.items){const r=is(e.items).filter(s=>s.kind==="file");if(t!=="drop")return r;const o=yield Promise.all(r.map(Ag));return Ta(Yc(o))}return Ta(is(e.files).map(r=>Kn(r)))})}function Ta(e){return e.filter(t=>kg.indexOf(t.name)===-1)}function is(e){if(e===null)return[];const t=[];for(let r=0;r<e.length;r++){const o=e[r];t.push(o)}return t}function Ag(e){if(typeof e.webkitGetAsEntry!="function")return Pa(e);const t=e.webkitGetAsEntry();return t&&t.isDirectory?Xc(t):Pa(e,t)}function Yc(e){return e.reduce((t,r)=>[...t,...Array.isArray(r)?Yc(r):[r]],[])}function Pa(e,t){return Dn(this,void 0,void 0,function*(){var r;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 c=yield a.getFile();return c.handle=a,Kn(c)}}const o=e.getAsFile();if(!o)throw new Error(`${e} is not a File`);return Kn(o,(r=t?.fullPath)!==null&&r!==void 0?r:void 0)})}function Ig(e){return Dn(this,void 0,void 0,function*(){return e.isDirectory?Xc(e):Tg(e)})}function Xc(e){const t=e.createReader();return new Promise((r,o)=>{const s=[];function a(){t.readEntries(c=>Dn(this,void 0,void 0,function*(){if(c.length){const l=Promise.all(c.map(Ig));s.push(l),a()}else try{const l=yield Promise.all(s);r(l)}catch(l){o(l)}}),c=>{o(c)})}a()})}function Tg(e){return Dn(this,void 0,void 0,function*(){return new Promise((t,r)=>{e.file(o=>{const s=Kn(o,e.fullPath);t(s)},o=>{r(o)})})})}var zr={},Ra;function Pg(){return Ra||(Ra=1,zr.__esModule=!0,zr.default=function(e,t){if(e&&t){var r=Array.isArray(t)?t:t.split(",");if(r.length===0)return!0;var o=e.name||"",s=(e.type||"").toLowerCase(),a=s.replace(/\/.*$/,"");return r.some(function(c){var l=c.trim().toLowerCase();return l.charAt(0)==="."?o.toLowerCase().endsWith(l):l.endsWith("/*")?a===l.replace(/\/.*$/,""):s===l})}return!0}),zr}var Rg=Pg();const Po=ii(Rg);function Ma(e){return Lg(e)||Dg(e)||Zc(e)||Mg()}function Mg(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
212
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Dg(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Lg(e){if(Array.isArray(e))return cs(e)}function Da(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),r.push.apply(r,o)}return r}function La(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Da(Object(r),!0).forEach(function(o){Qc(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Da(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function Qc(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ir(e,t){return $g(e)||Fg(e,t)||Zc(e,t)||Og()}function Og(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
213
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Zc(e,t){if(e){if(typeof e=="string")return cs(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return cs(e,t)}}function cs(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}function Fg(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o=[],s=!0,a=!1,c,l;try{for(r=r.call(e);!(s=(c=r.next()).done)&&(o.push(c.value),!(t&&o.length===t));s=!0);}catch(d){a=!0,l=d}finally{try{!s&&r.return!=null&&r.return()}finally{if(a)throw l}}return o}}function $g(e){if(Array.isArray(e))return e}var zg=typeof Po=="function"?Po:Po.default,Bg="file-invalid-type",Ug="file-too-large",Wg="file-too-small",Kg="too-many-files",qg=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",r=t.split(","),o=r.length>1?"one of ".concat(r.join(", ")):r[0];return{code:Bg,message:"File type must be ".concat(o)}},Oa=function(t){return{code:Ug,message:"File is larger than ".concat(t," ").concat(t===1?"byte":"bytes")}},Fa=function(t){return{code:Wg,message:"File is smaller than ".concat(t," ").concat(t===1?"byte":"bytes")}},Vg={code:Kg,message:"Too many files"};function el(e,t){var r=e.type==="application/x-moz-file"||zg(e,t);return[r,r?null:qg(t)]}function tl(e,t,r){if(_n(e.size))if(_n(t)&&_n(r)){if(e.size>r)return[!1,Oa(r)];if(e.size<t)return[!1,Fa(t)]}else{if(_n(t)&&e.size<t)return[!1,Fa(t)];if(_n(r)&&e.size>r)return[!1,Oa(r)]}return[!0,null]}function _n(e){return e!=null}function Hg(e){var t=e.files,r=e.accept,o=e.minSize,s=e.maxSize,a=e.multiple,c=e.maxFiles,l=e.validator;return!a&&t.length>1||a&&c>=1&&t.length>c?!1:t.every(function(d){var u=el(d,r),m=ir(u,1),p=m[0],f=tl(d,o,s),g=ir(f,1),h=g[0],_=l?l(d):null;return p&&h&&!_})}function to(e){return typeof e.isPropagationStopped=="function"?e.isPropagationStopped():typeof e.cancelBubble<"u"?e.cancelBubble:!1}function Br(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 $a(e){e.preventDefault()}function Gg(e){return e.indexOf("MSIE")!==-1||e.indexOf("Trident/")!==-1}function Jg(e){return e.indexOf("Edge/")!==-1}function Yg(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return Gg(e)||Jg(e)}function cn(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(o){for(var s=arguments.length,a=new Array(s>1?s-1:0),c=1;c<s;c++)a[c-1]=arguments[c];return t.some(function(l){return!to(o)&&l&&l.apply(void 0,[o].concat(a)),to(o)})}}function Xg(){return"showOpenFilePicker"in window}function Qg(e){if(_n(e)){var t=Object.entries(e).filter(function(r){var o=ir(r,2),s=o[0],a=o[1],c=!0;return nl(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.')),c=!1),(!Array.isArray(a)||!a.every(rl))&&(console.warn('Skipped "'.concat(s,'" because an invalid file extension was provided.')),c=!1),c}).reduce(function(r,o){var s=ir(o,2),a=s[0],c=s[1];return La(La({},r),{},Qc({},a,c))},{});return[{description:"Files",accept:t}]}return e}function Zg(e){if(_n(e))return Object.entries(e).reduce(function(t,r){var o=ir(r,2),s=o[0],a=o[1];return[].concat(Ma(t),[s],Ma(a))},[]).filter(function(t){return nl(t)||rl(t)}).join(",")}function e0(e){return e instanceof DOMException&&(e.name==="AbortError"||e.code===e.ABORT_ERR)}function t0(e){return e instanceof DOMException&&(e.name==="SecurityError"||e.code===e.SECURITY_ERR)}function nl(e){return e==="audio/*"||e==="video/*"||e==="image/*"||e==="text/*"||e==="application/*"||/\w+\/[-+.\w]+/g.test(e)}function rl(e){return/^.*\.[\w]+$/.test(e)}var n0=["children"],r0=["open"],o0=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],s0=["refKey","onChange","onClick"];function a0(e){return l0(e)||c0(e)||ol(e)||i0()}function i0(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
214
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function c0(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function l0(e){if(Array.isArray(e))return ls(e)}function Ro(e,t){return p0(e)||u0(e,t)||ol(e,t)||d0()}function d0(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
215
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ol(e,t){if(e){if(typeof e=="string")return ls(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ls(e,t)}}function ls(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}function u0(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o=[],s=!0,a=!1,c,l;try{for(r=r.call(e);!(s=(c=r.next()).done)&&(o.push(c.value),!(t&&o.length===t));s=!0);}catch(d){a=!0,l=d}finally{try{!s&&r.return!=null&&r.return()}finally{if(a)throw l}}return o}}function p0(e){if(Array.isArray(e))return e}function za(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),r.push.apply(r,o)}return r}function gt(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?za(Object(r),!0).forEach(function(o){ds(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):za(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function ds(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function no(e,t){if(e==null)return{};var r=m0(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)&&(r[o]=e[o])}return r}function m0(e,t){if(e==null)return{};var r={},o=Object.keys(e),s,a;for(a=0;a<o.length;a++)s=o[a],!(t.indexOf(s)>=0)&&(r[s]=e[s]);return r}var Ts=i.forwardRef(function(e,t){var r=e.children,o=no(e,n0),s=al(o),a=s.open,c=no(s,r0);return i.useImperativeHandle(t,function(){return{open:a}},[a]),wt.createElement(i.Fragment,null,r(gt(gt({},c),{},{open:a})))});Ts.displayName="Dropzone";var sl={disabled:!1,getFilesFromEvent:jg,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};Ts.defaultProps=sl;Ts.propTypes={children:ft.func,accept:ft.objectOf(ft.arrayOf(ft.string)),multiple:ft.bool,preventDropOnDocument:ft.bool,noClick:ft.bool,noKeyboard:ft.bool,noDrag:ft.bool,noDragEventsBubbling:ft.bool,minSize:ft.number,maxSize:ft.number,maxFiles:ft.number,disabled:ft.bool,getFilesFromEvent:ft.func,onFileDialogCancel:ft.func,onFileDialogOpen:ft.func,useFsAccessApi:ft.bool,autoFocus:ft.bool,onDragEnter:ft.func,onDragLeave:ft.func,onDragOver:ft.func,onDrop:ft.func,onDropAccepted:ft.func,onDropRejected:ft.func,onError:ft.func,validator:ft.func};var us={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,acceptedFiles:[],fileRejections:[]};function al(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=gt(gt({},sl),e),r=t.accept,o=t.disabled,s=t.getFilesFromEvent,a=t.maxSize,c=t.minSize,l=t.multiple,d=t.maxFiles,u=t.onDragEnter,m=t.onDragLeave,p=t.onDragOver,f=t.onDrop,g=t.onDropAccepted,h=t.onDropRejected,_=t.onFileDialogCancel,y=t.onFileDialogOpen,C=t.useFsAccessApi,B=t.autoFocus,U=t.preventDropOnDocument,Q=t.noClick,F=t.noKeyboard,M=t.noDrag,E=t.noDragEventsBubbling,$=t.onError,D=t.validator,j=i.useMemo(function(){return Zg(r)},[r]),le=i.useMemo(function(){return Qg(r)},[r]),te=i.useMemo(function(){return typeof y=="function"?y:Ba},[y]),X=i.useMemo(function(){return typeof _=="function"?_:Ba},[_]),Z=i.useRef(null),ae=i.useRef(null),re=i.useReducer(f0,us),de=Ro(re,2),ie=de[0],q=de[1],ye=ie.isFocused,fe=ie.isFileDialogActive,Te=i.useRef(typeof window<"u"&&window.isSecureContext&&C&&Xg()),ee=function(){!Te.current&&fe&&setTimeout(function(){if(ae.current){var L=ae.current.files;L.length||(q({type:"closeDialog"}),X())}},300)};i.useEffect(function(){return window.addEventListener("focus",ee,!1),function(){window.removeEventListener("focus",ee,!1)}},[ae,fe,X,Te]);var J=i.useRef([]),be=function(L){Z.current&&Z.current.contains(L.target)||(L.preventDefault(),J.current=[])};i.useEffect(function(){return U&&(document.addEventListener("dragover",$a,!1),document.addEventListener("drop",be,!1)),function(){U&&(document.removeEventListener("dragover",$a),document.removeEventListener("drop",be))}},[Z,U]),i.useEffect(function(){return!o&&B&&Z.current&&Z.current.focus(),function(){}},[Z,B,o]);var Ce=i.useCallback(function(N){$?$(N):console.error(N)},[$]),ke=i.useCallback(function(N){N.preventDefault(),N.persist(),Fe(N),J.current=[].concat(a0(J.current),[N.target]),Br(N)&&Promise.resolve(s(N)).then(function(L){if(!(to(N)&&!E)){var ue=L.length,pe=ue>0&&Hg({files:L,accept:j,minSize:c,maxSize:a,multiple:l,maxFiles:d,validator:D}),b=ue>0&&!pe;q({isDragAccept:pe,isDragReject:b,isDragActive:!0,type:"setDraggedFiles"}),u&&u(N)}}).catch(function(L){return Ce(L)})},[s,u,Ce,E,j,c,a,l,d,D]),he=i.useCallback(function(N){N.preventDefault(),N.persist(),Fe(N);var L=Br(N);if(L&&N.dataTransfer)try{N.dataTransfer.dropEffect="copy"}catch{}return L&&p&&p(N),!1},[p,E]),Xe=i.useCallback(function(N){N.preventDefault(),N.persist(),Fe(N);var L=J.current.filter(function(pe){return Z.current&&Z.current.contains(pe)}),ue=L.indexOf(N.target);ue!==-1&&L.splice(ue,1),J.current=L,!(L.length>0)&&(q({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),Br(N)&&m&&m(N))},[Z,m,E]),De=i.useCallback(function(N,L){var ue=[],pe=[];N.forEach(function(b){var T=el(b,j),A=Ro(T,2),W=A[0],H=A[1],xe=tl(b,c,a),me=Ro(xe,2),Je=me[0],ge=me[1],Le=D?D(b):null;if(W&&Je&&!Le)ue.push(b);else{var tt=[H,ge];Le&&(tt=tt.concat(Le)),pe.push({file:b,errors:tt.filter(function(St){return St})})}}),(!l&&ue.length>1||l&&d>=1&&ue.length>d)&&(ue.forEach(function(b){pe.push({file:b,errors:[Vg]})}),ue.splice(0)),q({acceptedFiles:ue,fileRejections:pe,isDragReject:pe.length>0,type:"setFiles"}),f&&f(ue,pe,L),pe.length>0&&h&&h(pe,L),ue.length>0&&g&&g(ue,L)},[q,l,j,c,a,d,f,g,h,D]),_e=i.useCallback(function(N){N.preventDefault(),N.persist(),Fe(N),J.current=[],Br(N)&&Promise.resolve(s(N)).then(function(L){to(N)&&!E||De(L,N)}).catch(function(L){return Ce(L)}),q({type:"reset"})},[s,De,Ce,E]),qe=i.useCallback(function(){if(Te.current){q({type:"openDialog"}),te();var N={multiple:l,types:le};window.showOpenFilePicker(N).then(function(L){return s(L)}).then(function(L){De(L,null),q({type:"closeDialog"})}).catch(function(L){e0(L)?(X(L),q({type:"closeDialog"})):t0(L)?(Te.current=!1,ae.current?(ae.current.value=null,ae.current.click()):Ce(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."))):Ce(L)});return}ae.current&&(q({type:"openDialog"}),te(),ae.current.value=null,ae.current.click())},[q,te,X,C,De,Ce,le,l]),Ee=i.useCallback(function(N){!Z.current||!Z.current.isEqualNode(N.target)||(N.key===" "||N.key==="Enter"||N.keyCode===32||N.keyCode===13)&&(N.preventDefault(),qe())},[Z,qe]),We=i.useCallback(function(){q({type:"focus"})},[]),Ue=i.useCallback(function(){q({type:"blur"})},[]),Re=i.useCallback(function(){Q||(Yg()?setTimeout(qe,0):qe())},[Q,qe]),at=function(L){return o?null:L},nt=function(L){return F?null:at(L)},Ke=function(L){return M?null:at(L)},Fe=function(L){E&&L.stopPropagation()},it=i.useMemo(function(){return function(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},L=N.refKey,ue=L===void 0?"ref":L,pe=N.role,b=N.onKeyDown,T=N.onFocus,A=N.onBlur,W=N.onClick,H=N.onDragEnter,xe=N.onDragOver,me=N.onDragLeave,Je=N.onDrop,ge=no(N,o0);return gt(gt(ds({onKeyDown:nt(cn(b,Ee)),onFocus:nt(cn(T,We)),onBlur:nt(cn(A,Ue)),onClick:at(cn(W,Re)),onDragEnter:Ke(cn(H,ke)),onDragOver:Ke(cn(xe,he)),onDragLeave:Ke(cn(me,Xe)),onDrop:Ke(cn(Je,_e)),role:typeof pe=="string"&&pe!==""?pe:"presentation"},ue,Z),!o&&!F?{tabIndex:0}:{}),ge)}},[Z,Ee,We,Ue,Re,ke,he,Xe,_e,F,M,o]),ze=i.useCallback(function(N){N.stopPropagation()},[]),rt=i.useMemo(function(){return function(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},L=N.refKey,ue=L===void 0?"ref":L,pe=N.onChange,b=N.onClick,T=no(N,s0),A=ds({accept:j,multiple:l,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:at(cn(pe,_e)),onClick:at(cn(b,ze)),tabIndex:-1},ue,ae);return gt(gt({},A),T)}},[ae,r,l,_e,o]);return gt(gt({},ie),{},{isFocused:ye&&!o,getRootProps:it,getInputProps:rt,rootRef:Z,inputRef:ae,open:at(qe)})}function f0(e,t){switch(t.type){case"focus":return gt(gt({},e),{},{isFocused:!0});case"blur":return gt(gt({},e),{},{isFocused:!1});case"openDialog":return gt(gt({},us),{},{isFileDialogActive:!0});case"closeDialog":return gt(gt({},e),{},{isFileDialogActive:!1});case"setDraggedFiles":return gt(gt({},e),{},{isDragActive:t.isDragActive,isDragAccept:t.isDragAccept,isDragReject:t.isDragReject});case"setFiles":return gt(gt({},e),{},{acceptedFiles:t.acceptedFiles,fileRejections:t.fileRejections,isDragReject:t.isDragReject});case"reset":return gt({},us);default:return e}}function Ba(){}const Ua={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"]}},Wa={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 Ka(e){return Ua[e]||Ua.claude}function qa(e){return Wa[e]||Wa.claude}function h0(e){return e==="claude"||e==="codex"}function x0(e){if(e==="think")return"low";if(e==="think-hard")return"medium";if(e==="think-harder")return"high";if(e==="ultrathink")return"xhigh"}let Va=!1;function g0(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`client-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function v0(e){return new Promise((t,r)=>{if(!(e instanceof Blob)){r(new Error("无效的图片文件"));return}const o=new FileReader;o.onload=()=>t(typeof o.result=="string"?o.result:""),o.onerror=()=>r(o.error||new Error("读取图片失败")),o.readAsDataURL(e)})}async function y0(e=[]){const t=Array.isArray(e)?e:[];return Promise.all(t.map(async(r,o)=>{const s=await v0(r);if(!s)throw new Error("图片编码失败");return{name:r?.name||`image-${o+1}.png`,data:s,size:Number(r?.size)||0,mimeType:r?.type||"application/octet-stream"}}))}function b0(e){const t=String(e||"").trim();if(!t)return"";const r=t.split(/[\\/]/);return r[r.length-1]||t}function w0(e=[]){return Array.from(new Set(Array.isArray(e)?e.filter(Boolean):[])).map(t=>{const r=String(t||"").trim();return r?{type:"resource_link",uri:r,name:b0(r)}:null}).filter(Boolean)}function k0(e,t=0){if(!e||typeof e!="object")return null;const r=String(e.modeId||e.id||e.value||"").trim();if(!r)return null;const o=`Mode ${t+1}`;return{id:r,name:String(e.name||e.label||r||o).trim()||o,description:typeof e.description=="string"?e.description:""}}function Mo(e=null){const t=e?.acpModes?.availableModes||e?.modes?.availableModes||e?.availableModes||[],r=Array.isArray(t)?t.map((s,a)=>k0(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:r,currentModeId:o}}function Ha(e){return String(e||"").trim().replace(/^\//,"").toLowerCase()}function j0(e,t=0){if(!e||typeof e!="object")return null;const r=String(e.name||e.command||e.id||"").trim();if(!r)return null;const o=r.startsWith("/")?r:`/${r}`;return{...e,id:String(e.id||o||`acp-${t}`).trim(),name:o,description:typeof e.description=="string"?e.description:"",type:"acp",source:"acp"}}function S0(e=null){const t=e?.acpAvailableCommands||e?.availableCommands||e?.acpCommands||[];return Array.isArray(t)?t.map((r,o)=>j0(r,o)).filter(Boolean):[]}function N0(e=[],t=[]){const r=Array.isArray(t)?t:[],o=Array.isArray(e)?e:[],s=new Set(r.map(c=>Ha(c?.name)).filter(Boolean)),a=o.filter(c=>!s.has(Ha(c?.name)));return[...r,...a]}function C0({selectedProject:e,selectedSession:t,selectedProjectRef:r,currentSessionId:o,canAbortSession:s,isLoading:a,setChatMessages:c,setCanAbortSession:l,setRuntimePhase:d,setClaudeStatus:u,pendingPermissionRequests:m,setPendingPermissionRequests:p,sendMessage:f,onSessionActive:g,onInputFocusChange:h,onShowSettings:_,onFileOpen:y,appendSessionConversationEvent:C,startLocalRunGuard:B,pendingViewSessionRef:U,scrollToBottom:Q,setIsUserScrolledUp:F,tokenBudget:M,chatMessages:E,setSessionMessages:$,resetRuntimeForNewChat:D,urlContext:j,urlPrompt:le,integrationClientId:te,latestIntegrationMessage:X,sendIntegrationMessage:Z,sendByCtrlEnter:ae}){const{t:re}=At("chat"),[de,ie]=i.useState(()=>typeof window<"u"&&e?.name&&xt.getItem(`draft_input_${e.name}`)||""),[q,ye]=i.useState(!1),[fe,Te]=i.useState([]),[ee,J]=i.useState(new Map),[be,Ce]=i.useState(new Map),[ke,he]=i.useState(!1),[Xe,De]=i.useState([]),[_e,qe]=i.useState([]),[Ee,We]=i.useState([]),[Ue,Re]=i.useState(-1),[at,nt]=i.useState(0),[Ke,Fe]=i.useState(-1),[it,ze]=i.useState(!1),[rt,N]=i.useState([]),[L,ue]=i.useState([]),[pe,b]=i.useState([]),[T,A]=i.useState(""),[W,H]=i.useState(!1),[xe,me]=i.useState(-1),[Je,ge]=i.useState(-1),[Le,tt]=i.useState(()=>{const x=Jt(localStorage.getItem("selected-provider"));return Ka(x).defaultMode}),St=i.useMemo(()=>Mo(t),[t]),[Nt,Ct]=i.useState(()=>St.currentModeId),[vt,v]=i.useState("none"),[w,V]=i.useState(()=>Jt(localStorage.getItem("selected-provider"))),[je,R]=i.useState(()=>Or("claude")),[Y,oe]=i.useState(()=>Or("codex")),[Be,Ye]=i.useState(()=>Or("gemini")),[$e,yt]=i.useState(()=>Or("opencode")),[Ve,pt]=i.useState({}),[mt,S]=i.useState({}),[ve,Me]=i.useState({}),[Ae,Qe]=i.useState({}),[Et,zt]=i.useState({}),[lt,Zt]=i.useState({}),en=i.useMemo(()=>ga(j),[j]),[K,Lt]=i.useState(en),[Ot,qt]=i.useState(en),[pn,k]=i.useState(!1),O=i.useRef(null),G=i.useRef(null),Se=i.useRef(null),Ne=i.useRef(null),ne=i.useRef(null),ot=i.useRef(null),Bt=i.useRef(en),Tt=i.useRef(!1),et=i.useRef(null),Vt=i.useRef(w),st=i.useMemo(()=>Ka(w),[w]),ht=i.useMemo(()=>N0(rt,L),[L,rt]),tn=i.useMemo(()=>qa(w),[w]),Ft=w==="claude"?je:w==="codex"?Y:w==="gemini"?Be:$e,jn=i.useMemo(()=>dx(w).OPTIONS,[w]),nn=i.useMemo(()=>(Ve[w]||[]).map(x=>({value:x,label:x})),[Ve,w]),kt=t?.__provider===w&&hx(w,t?.model)?t.model.trim():"",Pt=kt||Ft,vr=i.useMemo(()=>{const x=nn.length>0?nn:jn;return!kt||x.some(I=>I.value===kt)?x:[{value:kt,label:kt},...x]},[nn,jn,kt]),xl=vr.find(x=>x.value===Pt)?.label||Pt||re("providerSelection.selectModel"),gl=!!kt,vl=w==="opencode"&&!!ve.opencode,po=i.useCallback((x,{short:I=!1}={})=>{let P=re("codex.modes.default");return x==="acceptEdits"?P=re("codex.modes.acceptEdits"):x==="bypassPermissions"?P=re("codex.modes.bypassPermissions"):x==="plan"&&(P=re("codex.modes.plan")),I?P.replace(/\s*模式$/,"").replace(/\s*Mode$/,""):P},[re]),yl=i.useMemo(()=>po(Le,{short:!0}),[po,Le]),bl=i.useMemo(()=>re("codex.permissionMode").replace(/^权限/,"").replace(/^Permission\s+/i,""),[re]),mo=i.useCallback(async(x,{force:I=!1}={})=>{if(!cx.includes(x))return null;zt(P=>({...P,[x]:!0})),Zt(P=>({...P,[x]:null})),Qe(P=>({...P,[x]:{status:ix}}));try{const z=await Kt(`/api/cli/providers/${x}/installation-status${I?"?force=true":""}`),we=await z.json().catch(()=>({}));if(!z.ok||we?.success!==!0)throw new Error(we?.error||`Failed to check ${x} installation`);const Oe=we.installed?ax:Eo;return Qe(ct=>({...ct,[x]:{status:Oe,command:we.command||null,resolvedPath:we.resolvedPath||null,reason:we.reason||null,installHint:we.installHint||null,checkedAt:we.checkedAt||null,cacheHit:!!we.cacheHit}})),Oe}catch(P){return Qe(z=>({...z,[x]:{status:Lr}})),Zt(z=>({...z,[x]:P.message})),Lr}finally{zt(P=>({...P,[x]:!1}))}},[Zt,zt,Qe]),wl=i.useCallback(x=>{if(!x)return;const I=Jt(x);V(I),localStorage.setItem("selected-provider",I),mo(I)},[mo]);i.useEffect(()=>{const x=vr.map(I=>I.value);!Ft||x.includes(Ft)||(w==="claude"?R(""):w==="codex"?oe(""):w==="gemini"?Ye(""):w==="opencode"&&yt(""),px(w))},[w,Ft,vr]),i.useEffect(()=>{if(!e)return;const x=e.fullPath||e.path;if(!x)return;const I=`runtime-models:v2:${w}:${x}`,P=mi(xt.getItem(I)),z=Array.isArray(P?.models)?P.models:[],we=typeof P?.currentModel=="string"?P.currentModel.trim():"",Oe=Number(P?.timestamp||0);if(z.length>0&&Date.now()-Oe<lx){pt(dt=>({...dt,[w]:z})),we&&S(dt=>({...dt,[w]:{...dt?.[w]||{},currentModel:we}}));return}let _t=!1;return Me(dt=>({...dt,[w]:!0})),Ze.providerDiscovery(w,x).then(async dt=>{if(!dt.ok)throw new Error(`HTTP ${dt.status}`);return dt.json()}).then(dt=>{if(_t)return;const Ut=Array.isArray(dt?.models)?dt.models.map(vn=>vn.id):[],sn=typeof dt?.currentModel=="string"?dt.currentModel.trim():"";S(vn=>({...vn,[w]:dt})),pt(vn=>({...vn,[w]:Ut})),Ut.length>0&&xt.setItem(I,JSON.stringify({models:Ut,currentModel:sn||"",timestamp:Date.now()}))}).catch(()=>{_t||pt(dt=>({...dt,[w]:z}))}).finally(()=>{_t||Me(dt=>({...dt,[w]:!1}))}),()=>{_t=!0}},[w,e]),i.useEffect(()=>{Bt.current=Ot},[Ot]);const Ms=i.useRef(Va);i.useEffect(()=>{if(Ms.current)return;const x=es(le);x&&(ie(x),Tt.current=!0,Ms.current=!0,Va=!0)},[le]),i.useEffect(()=>{Lt(en),qt(en),k(!1)},[en]);const rn=i.useCallback((x,I,P={})=>{!I||typeof Z!="function"||Z({type:x,requestId:I,payload:{...P,clientId:te||null}})},[te,Z]),Ds=i.useCallback((x,I=null)=>{if(typeof x?.context!="object"||x.context==null||Array.isArray(x.context)){console.warn("[DynamicContext] Ignored integration.context.update because context is not an object."),rn("integration.error",I,{code:"INVALID_PAYLOAD",message:"context must be an object"});return}if(qh(x.mode)===Zo){const we=Kh(Bt.current,x.context);if(!we){console.warn("[DynamicContext] Ignored invalid append context payload."),rn("integration.error",I,{code:"INVALID_PAYLOAD",message:"append context payload is invalid"});return}Lt(we),qt(we),k(!1),rn("integration.ack",I,{accepted:!0,applied:!0});return}const z=ga(x.context);if(!z){rn("integration.error",I,{code:"INVALID_PAYLOAD",message:"context payload does not satisfy contextV1"});return}Lt(z),qt(z),k(!1),rn("integration.ack",I,{accepted:!0,applied:!0})},[rn]),Ls=i.useCallback((x,I=null)=>{if(typeof x?.prompt!="string"){rn("integration.error",I,{code:"INVALID_PAYLOAD",message:"prompt must be a string"});return}const P=es(x.prompt);if(ie(P),Tt.current=!0,x.autoSend===!0&&P&&r.current&&!a&&ot.current){const z={preventDefault:()=>{}};ot.current(z,P)}rn("integration.ack",I,{accepted:!0,applied:!0})},[a,r,rn]),Os=i.useCallback((x=null)=>{rn("integration.ack",x,{accepted:!0,available:!0,pageUrl:typeof window<"u"?window.location.href:null,sessionId:t?.id||null})},[t?.id,rn]);i.useEffect(()=>{if(!X?.__messageSeq)return;const I=X?.type;if(I==="integration.context.update"){Ds(X.payload||{},X.requestId||null);return}if(I==="integration.prompt.update"){Ls(X.payload||{},X.requestId||null);return}I==="integration.ping"&&Os(X.requestId||null)},[Ds,Ls,X,Os]);const Hn=i.useMemo(()=>pn||!Ot||!$h(Ot)?null:Ot,[pn,Ot]),kl=i.useMemo(()=>Hn?.selectedElements?.slice(0,fa)||[],[Hn]),jl=i.useMemo(()=>Hn?.selectedElements?.slice(fa)||[],[Hn]),Sl=i.useCallback(()=>{qt(x=>!x||!on(x.systemContext)?x:{...x,systemContext:""})},[]),Nl=i.useCallback(()=>{qt(x=>!x||!on(Mn(x.currentFile))?x:{...x,currentFile:{path:"",displayName:""}})},[]),Cl=i.useCallback(x=>{qt(I=>{if(!I||!Array.isArray(I.selectedElements)||I.selectedElements.length===0)return I;const P=I.selectedElements.findIndex(z=>z.tag===x.tag&&z.selector===x.selector&&z.label===x.label);return P<0?I:{...I,selectedElements:I.selectedElements.filter((z,we)=>we!==P)}})},[]);i.useEffect(()=>{if(t?.id){const x=localStorage.getItem(`permissionMode-${t.id}`);x&&st.modes.includes(x)?tt(x):tt(st.defaultMode)}},[t?.id,st]),i.useEffect(()=>{st.modes.includes(Le)||tt(st.defaultMode)},[Le,st]),i.useEffect(()=>{if(!tn.enabled){vt!==tn.defaultMode&&v(tn.defaultMode);return}tn.modes.includes(vt)||v(tn.defaultMode)},[tn,vt]),i.useEffect(()=>{if(t&&t.__provider&&t.__provider!==w){const x=Jt(t.__provider);V(x),localStorage.setItem("selected-provider",x)}if(t?.id&&t?.__provider)try{const x=localStorage.getItem("session-provider-map"),I=x?JSON.parse(x):{};I[t.id]!==t.__provider&&(I[t.id]=t.__provider,localStorage.setItem("session-provider-map",JSON.stringify(I)))}catch{}},[w,t]),i.useEffect(()=>{Vt.current!==w&&(p([]),Vt.current=w)},[w,p]),i.useEffect(()=>{p(x=>x.filter(I=>!I.sessionId||I.sessionId===t?.id))},[t?.id,p]),i.useEffect(()=>{const x=Mo(t),I=new Set(x.availableModes.map(P=>P.id));Ct(P=>x.currentModeId&&I.has(x.currentModeId)?x.currentModeId:P&&I.has(P)?P:"")},[t]),i.useEffect(()=>{ue(S0(t))},[t]),i.useEffect(()=>{(async()=>{if(e)try{const I=await Kt("/api/commands/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPath:e.path})});if(!I.ok)throw new Error("Failed to fetch commands");const P=await I.json(),z=[...(P.builtIn||[]).map(ct=>({...ct,type:"built-in"})),...(P.custom||[]).map(ct=>({...ct,type:"custom"}))];N(z);const we=`command_history_${e.name}`,Oe=xt.getItem(we);if(Oe)try{const ct=JSON.parse(Oe),_t=[...z].sort((dt,Ut)=>{const sn=ct[dt.name]||0;return(ct[Ut.name]||0)-sn});N(_t)}catch(ct){console.error("Error parsing command history:",ct)}}catch(I){console.error("Error fetching slash commands:",I),N([])}})()},[e]);const fo=i.useMemo(()=>ht.length?new Vn(ht,{keys:[{name:"name",weight:2},{name:"description",weight:1}],threshold:.4,includeScore:!0,minMatchCharLength:1}):null,[ht]);i.useEffect(()=>{if(!T){b(ht);return}if(!fo){b([]);return}const x=fo.search(T);b(x.map(I=>I.item))},[T,ht,fo]);const El=i.useMemo(()=>{if(!e||ht.length===0)return[];const x=`command_history_${e.name}`,I=xt.getItem(x);if(!I)return[];try{const P=JSON.parse(I);return ht.map(z=>({...z,usageCount:P[z.name]||0})).filter(z=>z.usageCount>0).sort((z,we)=>we.usageCount-z.usageCount).slice(0,5)}catch(P){return console.error("Error parsing command history:",P),[]}},[ht,e]),Fs=i.useCallback(x=>{const{action:I,data:P}=x;switch(I){case"clear":c([]),$([]);break;case"help":c(z=>[...z,{role:"assistant",content:P.content,timestamp:Date.now()}]);break;case"model":{const z=Object.entries(P.available||{}).filter(([,Oe])=>Array.isArray(Oe)&&Oe.length>0).map(([Oe,ct])=>`**${Oe.charAt(0).toUpperCase()+Oe.slice(1)}**: ${ct.join(", ")}`).join(`
216
+
217
+ `),we=P.current.provider==="opencode"?P.opencodeDiscovery?"_OpenCode source: runtime provider registry._":"_OpenCode source: local fallback list._":"";c(Oe=>[...Oe,{role:"assistant",content:`**Current Model**: ${P.current.model}
218
+
219
+ **Available Models**:
220
+
221
+ ${z}${we?`
222
+
223
+ ${we}`:""}`,timestamp:Date.now()}]);break}case"cost":{const z=`**Token Usage**: ${P.tokenUsage.used.toLocaleString()} / ${P.tokenUsage.total.toLocaleString()} (${P.tokenUsage.percentage}%)
224
+
225
+ **Estimated Cost**:
226
+ - Input: $${P.cost.input}
227
+ - Output: $${P.cost.output}
228
+ - **Total**: $${P.cost.total}
229
+
230
+ **Model**: ${P.model}`;c(we=>[...we,{role:"assistant",content:z,timestamp:Date.now()}]);break}case"status":{const z=`**System Status**
231
+
232
+ - Version: ${P.version}
233
+ - Uptime: ${P.uptime}
234
+ - Model: ${P.model}
235
+ - Provider: ${P.provider}
236
+ - Node.js: ${P.nodeVersion}
237
+ - Platform: ${P.platform}`;c(we=>[...we,{role:"assistant",content:z,timestamp:Date.now()}]);break}case"memory":P.error?c(z=>[...z,{role:"assistant",content:`⚠️ ${P.message}`,timestamp:Date.now()}]):(c(z=>[...z,{role:"assistant",content:`📝 ${P.message}
238
+
239
+ Path: \`${P.path}\``,timestamp:Date.now()}]),P.exists&&y&&y(P.path));break;case"config":_&&_();break;case"rewind":P.error?c(z=>[...z,{role:"assistant",content:`⚠️ ${P.message}`,timestamp:Date.now()}]):(c(z=>z.slice(0,-P.steps*2)),c(z=>[...z,{role:"assistant",content:`⏪ ${P.message}`,timestamp:Date.now()}]));break;default:console.warn("Unknown built-in command action:",I)}},[y,_,c,$]),$s=i.useCallback(async x=>{const{content:I,hasBashCommands:P}=x;if(P&&!window.confirm("这条命令包含将要执行的 Bash 命令,是否继续?")){c(we=>[...we,{role:"assistant",content:"❌ 已取消命令执行",timestamp:Date.now()}]);return}ie(I),setTimeout(()=>{if(ot.current){const z={preventDefault:()=>{}};ot.current(z)}},50)},[c]),yr=i.useCallback(async x=>{if(!(!x||!e))try{const I=de.match(new RegExp(`${x.name}\\s*(.*)`)),P=I&&I[1]?I[1].trim().split(/\s+/):[],z={projectPath:e.path,projectName:e.name,sessionId:o,provider:w,...Pt?{model:Pt}:{},tokenUsage:M},we=await Kt("/api/commands/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandName:x.name,commandPath:x.path,args:P,context:z})});if(!we.ok)throw new Error("Failed to execute command");const Oe=await we.json();Oe.type==="builtin"?Fs(Oe):Oe.type==="custom"&&await $s(Oe,P),ie(""),ze(!1),ge(-1),A(""),me(-1)}catch(I){console.error("Error executing command:",I),c(P=>[...P,{role:"assistant",content:`Error executing command: ${I.message}`,timestamp:Date.now()}])}},[Pt,o,Fs,$s,de,w,e,c,M]),_l=i.useCallback(x=>{const I=String(x||"").trim();if(!I||I===Nt)return;Ct(I);const P=t?.id||o;if(!P)return;const z=t?.__provider||w||"claude";f({type:"set-session-mode",provider:z,sessionId:P,modeId:I})},[Nt,o,w,t?.__provider,t?.id,f]),br=i.useCallback(x=>{if(!x||!e?.name)return;const I=`command_history_${e.name}`,P=xt.getItem(I);let z={};try{z=P?JSON.parse(P):{}}catch(we){console.error("Error parsing command history:",we)}z[x.name]=(z[x.name]||0)+1,xt.setItem(I,JSON.stringify(z))},[e?.name]),Al=i.useCallback((x,I,P)=>{if(!(!x||!e)){if(P){me(I);return}if(br(x),x?.source==="acp"){const z=String(x.name||"").trim(),we=z.startsWith("/")?`${z} `:`/${z} `;ie(we),ze(!1),ge(-1),A(""),me(-1);return}yr(x)}},[yr,br,e]),ho=i.useCallback(x=>{if(!x)return;const I=x?.source==="acp",P=String(x.name||"").trim(),z=I&&P&&!P.startsWith("/")?`/${P}`:P,we=de.slice(0,Je),Oe=de.slice(Je),ct=Oe.indexOf(" "),_t=ct!==-1?Oe.slice(ct):"",dt=`${we}${z} ${_t}`;ie(dt),ze(!1),ge(-1),A(""),me(-1),et.current&&clearTimeout(et.current),br(x),I||yr(x)},[yr,br,de,Je]);i.useEffect(()=>{e&&Ze.getFiles(e.name).then(async x=>x.ok?x.json():[]).then(x=>{De(Pc(x))}).catch(x=>{console.error("Error fetching files:",x)})},[e]),i.useEffect(()=>{const x=de.slice(0,at),I=x.lastIndexOf("@");if(I!==-1){const P=x.slice(I+1);if(P.includes(" "))he(!1),Fe(-1);else{Fe(I),he(!0);const z=Xe.filter(we=>we.name.toLowerCase().includes(P.toLowerCase())||we.path.toLowerCase().includes(P.toLowerCase())).slice(0,10);We(z),Re(-1)}}else he(!1),Fe(-1)},[de,at,Xe]);const Gn=i.useMemo(()=>!de||_e.length===0?[]:_e.filter(x=>de.includes(x)),[_e,de]),Jn=i.useMemo(()=>Gn.length===0?[]:Array.from(new Set(Gn)).sort((x,I)=>I.length-x.length),[Gn]),xo=i.useMemo(()=>Jn.length===0?null:new RegExp(`(${Jn.map(Mh).join("|")})`,"g"),[Jn]),zs=i.useMemo(()=>new Set(Jn),[Jn]),Il=i.useCallback(x=>x?xo?x.split(xo).map((P,z)=>zs.has(P)?n.jsx("span",{className:"bg-primary/20 -ml-0.5 dark:bg-primary/25 px-0.5 rounded-md box-decoration-clone text-transparent",children:P},`mention-${z}`):n.jsx("span",{children:P},`text-${z}`)):x:"",[xo,zs]),wr=i.useCallback(x=>{const I=x.filter(P=>{try{if(!P||typeof P!="object"||!P.type||!P.type.startsWith("image/"))return!1;if(!P.size||P.size>5242880){const z=P.name||"Unknown file";return Ce(we=>{const Oe=new Map(we);return Oe.set(z,"File too large (max 5MB)"),Oe}),!1}return!0}catch(z){return console.error("Error validating file:",z,P),!1}});I.length>0&&Te(P=>[...P,...I].slice(0,5))},[]),Tl=i.useCallback(x=>{const I=Array.from(x.clipboardData.items);for(const P of I)if(P.type.startsWith("image/")){const z=P.getAsFile();z&&wr([z])}if(I.length===0&&x.clipboardData.files.length>0){const z=Array.from(x.clipboardData.files).filter(we=>we.type.startsWith("image/"));z.length>0&&wr(z)}},[wr]),{getRootProps:Pl,getInputProps:Rl,isDragActive:Ml,open:Dl}=al({accept:{"image/*":[".png",".jpg",".jpeg",".gif",".webp",".svg"]},maxSize:5*1024*1024,maxFiles:5,onDrop:wr,noClick:!0,noKeyboard:!0}),Fn=i.useCallback(async(x,I=null)=>{x.preventDefault();const P=typeof I=="string"?I:de,z=t?.__provider||w||"claude";if((Ae[z]?.status||Lr)===Eo||!P.trim()||a||!e)return;let Oe=P;const ct=qa(z),_t=ct.enabled?$d.find(jt=>jt.id===vt):null;ct.strategy==="prompt-prefix"&&_t?.prefix&&(Oe=`${_t.prefix}: ${P}`);const dt=!pn&&Fh(Ot)?Vh(Ot):null;dt&&(Oe=Hh(dt,Oe)),d("queued"),u(_s({phaseText:re("activity.stage.generatingReply"),detailText:re("activity.detail.preparingReply"),canAbort:!0}));let Ut=[];if(fe.length>0){if(!h0(z)){d("idle"),l(!1),u(null),c(jt=>[...jt,{type:"error",content:`${z} 当前不支持图片输入`,timestamp:new Date}]);return}try{Ut=await y0(fe)}catch(jt){console.error("Image preparation failed:",jt),d("idle"),l(!1),u(null),c(jr=>[...jr,{type:"error",content:`图片处理失败:${jt.message}`,timestamp:new Date}]);return}}const sn=w0(Gn),vn=[...Ut.map(jt=>({type:"image",data:jt.data,mimeType:jt.mimeType,name:jt.name})),...sn],zn=g0(),Ks={type:"user",content:P,provider:z,images:Ut,contentBlocks:sn,timestamp:new Date,clientRequestId:zn};c(jt=>[...jt,Ks]),F(!1),setTimeout(()=>Q(),100);const It=o||t?.id;B(It||t?.id||null),It&&C(Mt({kind:"user_message",provider:z,sessionId:It,timestamp:Ks.timestamp,payload:{text:P,contentBlocks:vn},extensions:{clientRequestId:zn,optimistic:!0}}));const Ql=It||`new-session-${Date.now()}`;!It&&!t?.id&&(U.current={sessionId:null,startedAt:Date.now()}),g&&g(Ql);const Zl=(()=>{try{const jt=w==="codex"?"codex-settings":"claude-settings",jr=xt.getItem(jt);if(jr)return JSON.parse(jr)}catch(jt){console.error("Error loading tools settings:",jt)}return{allowedTools:[],disallowedTools:[],skipPermissions:!1}})();if(z==="codex"){const jt=ct.enabled&&ct.strategy==="native-effort"?x0(vt):void 0;f({type:"codex-command",clientRequestId:zn,command:Oe,sessionId:It,options:{cwd:e.fullPath||e.path,projectPath:e.fullPath||e.path,sessionId:It,resume:!!It,permissionMode:Le==="plan"?"default":Le,...Pt?{model:Pt}:{},...jt?{modelReasoningEffort:jt}:{},images:Ut,resourceLinks:sn}})}else f(z==="gemini"?{type:"gemini-command",clientRequestId:zn,command:Oe,sessionId:It,options:{cwd:e.fullPath||e.path,projectPath:e.fullPath||e.path,sessionId:It,resume:!!It,permissionMode:Le==="plan"?"default":Le,...Pt?{model:Pt}:{},images:Ut,resourceLinks:sn}}:z==="opencode"?{type:"opencode-command",clientRequestId:zn,command:Oe,sessionId:It,options:{cwd:e.fullPath||e.path,projectPath:e.fullPath||e.path,sessionId:It,resume:!!It,permissionMode:Le==="plan"?"default":Le,...Pt?{model:Pt}:{},images:Ut,resourceLinks:sn}}:{type:"claude-command",clientRequestId:zn,command:Oe,options:{projectPath:e.path,cwd:e.fullPath,sessionId:It,resume:!!It,toolsSettings:Zl,permissionMode:Le,...Pt?{model:Pt}:{},images:Ut,resourceLinks:sn}});dt&&k(!0),ie(""),Te([]),J(new Map),Ce(new Map),H(!1),v("none"),O.current&&(O.current.style.height="auto"),e&&xt.removeItem(`draft_input_${e.name}`)},[Gn,C,fe,Pt,o,pn,de,a,g,Ot,U,Le,w,Ae,Q,e,t,f,l,c,u,F,d,B,re,vt]);i.useEffect(()=>{ot.current=Fn},[Fn]);const Ll=i.useCallback(x=>!x||w!=="claude"?{success:!1}:kx(x.entry),[w]),Ol=i.useCallback((x,I)=>{const z=(Array.isArray(x)?x:[x]).filter(Boolean);z.length!==0&&(z.forEach(we=>{f({type:"permission-response",requestId:we,optionId:I?.optionId,outcome:I?.outcome,cancelled:!!I?.cancelled,allow:!!I?.allow,updatedInput:I?.updatedInput,message:I?.message,rememberEntry:I?.rememberEntry})}),p(we=>{const Oe=we.filter(ct=>!z.includes(ct.requestId));return Oe.length===0&&u(null),Oe}))},[f,u,p]),kr=i.useCallback(x=>{const I=de.slice(0,Ke),P=de.slice(Ke),z=P.indexOf(" "),we=z!==-1?P.slice(z):"",Oe=`${I}${x.path} ${we}`,ct=I.length+x.path.length+1;O.current&&!O.current.matches(":focus")&&O.current.focus(),ie(Oe),nt(ct),qe(_t=>_t.includes(x.path)?_t:[..._t,x.path]),he(!1),Fe(-1),O.current&&requestAnimationFrame(()=>{O.current&&(O.current.setSelectionRange(ct,ct),O.current.matches(":focus")||O.current.focus())})},[Ke,de]),Fl=i.useCallback(x=>{const I=x.target.value,P=x.target.selectionStart;if(ie(I),nt(P),!I.trim()){x.target.style.height="auto",H(!1),ze(!1),ge(-1),A("");return}const z=I.slice(0,P);if((z.match(/```/g)||[]).length%2===1){ze(!1),ge(-1),A("");return}const Oe=z.match(/(^|\s)\/(\S*)$/);if(Oe){const ct=Oe.index+Oe[1].length,_t=Oe[2];ge(ct),ze(!0),me(-1),et.current&&clearTimeout(et.current),et.current=setTimeout(()=>{A(_t)},150)}else ze(!1),ge(-1),A(""),et.current&&clearTimeout(et.current)},[]),go=i.useCallback(x=>{!Se.current||!x||(Se.current.scrollTop=x.scrollTop,Se.current.scrollLeft=x.scrollLeft)},[]),$l=i.useCallback(x=>{nt(x.target.selectionStart)},[]),zl=i.useCallback(x=>{x.target.style.height="auto",x.target.style.height=`${x.target.scrollHeight}px`,nt(x.target.selectionStart),go(x.target);const I=parseInt(window.getComputedStyle(x.target).lineHeight,10),P=x.target.scrollHeight>I*2;H(P)},[go]),Bl=i.useCallback(x=>{if(it&&pe.length>0){if(x.key==="ArrowDown"){x.preventDefault(),me(I=>I<pe.length-1?I+1:0);return}if(x.key==="ArrowUp"){x.preventDefault(),me(I=>I>0?I-1:pe.length-1);return}if(x.key==="Tab"||x.key==="Enter"){x.preventDefault(),xe>=0?ho(pe[xe]):pe.length>0&&ho(pe[0]);return}if(x.key==="Escape"){x.preventDefault(),ze(!1),ge(-1),A(""),me(-1),et.current&&clearTimeout(et.current);return}}if(ke&&Ee.length>0){if(x.key==="ArrowDown"){x.preventDefault(),Re(I=>I<Ee.length-1?I+1:0);return}if(x.key==="ArrowUp"){x.preventDefault(),Re(I=>I>0?I-1:Ee.length-1);return}if(x.key==="Tab"||x.key==="Enter"){x.preventDefault(),Ue>=0?kr(Ee[Ue]):Ee.length>0&&kr(Ee[0]);return}if(x.key==="Escape"){x.preventDefault(),he(!1);return}}if(x.key==="Tab"&&!ke&&!it){x.preventDefault();const I=st.modes,z=(I.indexOf(Le)+1)%I.length,we=I[z];tt(we),t?.id&&localStorage.setItem(`permissionMode-${t.id}`,we);return}if(x.key==="Enter"){if(x.nativeEvent.isComposing)return;(x.ctrlKey||x.metaKey)&&!x.shiftKey?(x.preventDefault(),Fn(x)):!x.shiftKey&&!x.ctrlKey&&!x.metaKey&&(ae||(x.preventDefault(),Fn(x)))}},[pe,Ee,Fn,Le,st.modes,ho,kr,xe,Ue,t?.id,ae,it,ke]),$n=t?.__provider||w||"claude",vo=Ae[$n],Bs=vo?.status||Lr,Us=Bs===Eo,Ul=vo?.reason||lt[$n]||null,Wl=vo?.installHint||null,Kl=!!Et[$n],ql=a||Us,Ws=$n==="opencode"?"OpenCode":re(`messageTypes.${$n}`),Vl=re("input.providerNotInstalledWithName",{provider:Ws}),Hl=i.useMemo(()=>Mo(t),[t]);i.useEffect(()=>{e&&de!==""?xt.setItem(`draft_input_${e.name}`,de):e&&de===""&&xt.removeItem(`draft_input_${e.name}`)},[de,e]),i.useEffect(()=>{if(e){if(Tt.current){Tt.current=!1;return}const x=xt.getItem(`draft_input_${e.name}`)||"";x!==de&&ie(x)}},[de,e?.name]),i.useEffect(()=>{h&&h(q)},[q,h]),i.useEffect(()=>{if(O.current){O.current.style.height="auto",O.current.style.height=`${O.current.scrollHeight}px`;const x=parseInt(window.getComputedStyle(O.current).lineHeight,10);H(O.current.scrollHeight>x*2)}},[]),i.useEffect(()=>{O.current&&!de.trim()&&(O.current.style.height="auto",H(!1))},[de]);const Gl=i.useCallback(x=>{Te(I=>I.filter((P,z)=>z!==x))},[]),Jl=i.useCallback(x=>{w==="claude"?R(x):w==="codex"?oe(x):w==="gemini"?Ye(x):w==="opencode"&&yt(x),ux(w,x)},[w]),Yl=i.useCallback(()=>{const x=o||t?.id,I=t?.__provider||w;x&&s&&f({type:"abort-session",sessionId:x,provider:I})},[s,o,w,t?.__provider,t?.id,f]),Xl=i.useCallback(()=>{ie(""),Te([]),J(new Map),Ce(new Map),H(!1),v("none"),ze(!1),he(!1),A(""),ge(-1),me(-1),Re(-1),e?.name&&xt.removeItem(`draft_input_${e.name}`),typeof D=="function"&&D()},[D,e?.name]);return{input:de,setInput:ie,provider:w,setProvider:V,handleProviderSelection:wl,permissionMode:Le,setPermissionMode:tt,acpModes:Hl.availableModes,acpModeId:Nt,handleAcpModeChange:_l,selectedPermissionShortLabel:yl,permissionDropdownTitle:bl,providerModeConfig:st,getPermissionModeLabel:po,providerThinkingConfig:tn,thinkingMode:vt,setThinkingMode:v,currentModel:Pt,modelOptions:vr,selectedModelLabel:xl,isModelSelectionLocked:gl,isOpencodeModelLoading:vl,setProviderModel:Jl,textareaRef:O,inputContainerRef:G,inputHighlightRef:Se,modelSelectorRef:Ne,permissionSelectorRef:ne,showFileDropdown:ke,filteredFiles:Ee,selectedFileIndex:Ue,selectFile:kr,showCommandMenu:it,filteredCommands:pe,selectedCommandIndex:xe,handleCommandSelect:Al,commandQuery:T,frequentCommands:El,slashPosition:Je,setShowCommandMenu:ze,setSelectedCommandIndex:me,setSlashPosition:ge,setCommandQuery:A,getRootProps:Pl,getInputProps:Rl,isDragActive:Ml,openImagePicker:Dl,attachedImages:fe,uploadingImages:ee,imageErrors:be,removeAttachedImage:Gl,visibleDynamicContext:Hn,visibleSelectedElements:kl,hiddenSelectedElements:jl,handleDismissSystemContext:Sl,handleDismissCurrentFile:Nl,handleDismissSelectedElement:Cl,renderInputWithMentions:Il,handleInputChange:Fl,handleTextareaClick:$l,handleKeyDown:Bl,handlePaste:Tl,syncInputOverlayScroll:go,handleTextareaInput:zl,activeInputProvider:$n,activeInputProviderLabel:Ws,activeProviderInstallState:Bs,isActiveProviderNotInstalled:Us,unavailablePlaceholder:Vl,isInputDisabled:ql,activeProviderInstallReason:Ul,activeProviderInstallHint:Wl,isCheckingProviderInstallation:Kl,checkProviderInstallation:mo,providerCheckLoadingByName:Et,isInputFocused:q,setIsInputFocused:ye,isTextareaExpanded:W,tokenBudget:M,handleSubmit:Fn,canAbortSession:s,handleAbortSession:Yl,handleSubmitRef:ot,handleGrantToolPermission:Ll,handlePermissionDecision:Ol,dynamicContext:K,pendingDynamicContext:Ot,setPendingDynamicContext:qt,dynamicContextSent:pn,setDynamicContextSent:k,resetComposerForNewChat:Xl}}function E0({selectedProject:e,selectedSession:t,ws:r,sendMessage:o,latestMessage:s,onFileOpen:a,onInputFocusChange:c,onSessionActive:l,onSessionInactive:d,onSessionProcessing:u,onSessionNotProcessing:m,processingSessions:p,onReplaceTemporarySession:f,onNavigateToSession:g,onShowSettings:h,autoExpandTools:_,showRawParameters:y,showThinking:C,autoScrollToBottom:B,sendByCtrlEnter:U,externalMessageUpdate:Q,urlContext:F,urlPrompt:M,integrationClientId:E,latestIntegrationMessage:$,sendIntegrationMessage:D,newSessionResetNonce:j=0}){const{t:le}=At("chat"),te=i.useMemo(()=>typeof window<"u"&&e?.name?bx(e.name,t?.id||null):[],[e?.name,t?.id]),[X,Z]=i.useReducer(yh,te,vh),[ae,re]=i.useState(t?.id||null),[de,ie]=i.useState(!1),[q,ye]=i.useState(null),[fe,Te]=i.useState(null),[ee,J]=i.useState([]),be=i.useRef(e),Ce=i.useRef(X.messages),ke=i.useRef(X.isLoading),he=i.useRef({sessionId:null,startedAt:0}),Xe=i.useRef(null),De=i.useRef(j),_e=i.useRef(""),qe=i.useRef(null),Ee=X.messages,We=X.phase,Ue=X.isLoading,Re=X.canAbortSession,at=X.pendingPermissionRequests;i.useEffect(()=>{be.current=e},[e]),i.useEffect(()=>{Ce.current=Ee},[Ee]),i.useEffect(()=>{ke.current=Ue},[Ue]);const nt=i.useCallback(ge=>{Z({type:"replace_messages",value:ge})},[]),Ke=i.useCallback(ge=>{Z({type:"replace_permissions",value:ge})},[]),Fe=i.useCallback(ge=>{Z({type:"set_loading",value:ge})},[]),it=i.useCallback(ge=>{Z({type:"set_can_abort",value:ge})},[]),ze=i.useCallback((ge,Le)=>{Z({type:"set_phase",phase:ge,overrides:Le})},[]),rt=i.useCallback((ge,Le)=>{Z({type:"apply_conversation_event",event:ge,provider:Le})},[]),N=i.useCallback(ge=>{he.current={sessionId:ge||null,startedAt:Date.now()}},[]),L=i.useCallback(ge=>{!ge||!he.current.startedAt||(he.current={...he.current,sessionId:ge})},[]),ue=i.useCallback((ge=null)=>{const Le=he.current;Le.startedAt&&(ge&&Le.sessionId&&Le.sessionId!==ge||(he.current={sessionId:null,startedAt:0}))},[]),pe=i.useCallback(()=>{qe.current&&(clearTimeout(qe.current),qe.current=null),_e.current=""},[]),b=i.useCallback((ge,Le=null)=>{if(Le&&Le!=="session-status")return!1;const tt=he.current;return!!(tt.startedAt&&ge&&tt.sessionId===ge&&Date.now()-tt.startedAt<15e3&&(We===se.CONNECTING||We===se.QUEUED||We===se.STREAMING||We===se.AWAITING_APPROVAL||We===se.COMPLETED||We===se.ABORTED||We===se.ERRORED))},[We]),T=i.useCallback((ge=null)=>{const Le=be.current?.name||e?.name||"";Le&&$c(Le,ge,Ce.current)},[e?.name]),A=Cx({selectedProject:e,selectedProjectRef:be,selectedSession:t,currentSessionId:ae,setCurrentSessionId:re,provider:t?.__provider||null,runtimePhase:We,isLoading:Ue,isLoadingRef:ke,processingSessions:p,autoScrollToBottom:B,externalMessageUpdate:Q,ws:r,sendMessage:o,chatMessages:Ee,setChatMessages:nt,setIsLoading:Fe,setCanAbortSession:it,setRuntimePhase:ze,setClaudeStatus:ye,setPendingPermissionRequests:Ke,resetStreamingState:pe,clearLocalRunGuard:ue,localRunGuardRef:he,pendingViewSessionRef:Xe,isSystemSessionChange:de,setIsSystemSessionChange:ie,onSessionInactive:d,onSessionNotProcessing:m,onSessionProcessing:u}),W=i.useMemo(()=>ch(A.sessionMessages),[A.sessionMessages]);i.useEffect(()=>{Te(W.modeState||null),J(Array.isArray(W.availableCommands)?W.availableCommands:[]),A.setTokenBudget(W.tokenUsage||null)},[A.setTokenBudget,W.availableCommands,W.modeState,W.tokenUsage]);const H=i.useMemo(()=>{if(!t&&!ae)return t;const ge=t?{...t}:{};return!ge.id&&ae&&(ge.id=ae),ge.acpModes=fe,ge.acpAvailableCommands=ee,ge},[ee,fe,ae,t]),xe=C0({selectedProject:e,selectedSession:H,selectedProjectRef:be,currentSessionId:ae,canAbortSession:Re,isLoading:Ue,setChatMessages:nt,setCanAbortSession:it,setRuntimePhase:ze,setClaudeStatus:ye,pendingPermissionRequests:at,setPendingPermissionRequests:Ke,sendMessage:o,onSessionActive:l,onInputFocusChange:c,onShowSettings:h,onFileOpen:a,appendSessionConversationEvent:A.appendSessionConversationEvent,startLocalRunGuard:N,pendingViewSessionRef:Xe,scrollToBottom:A.scrollToBottom,setIsUserScrolledUp:A.setIsUserScrolledUp,tokenBudget:A.tokenBudget,chatMessages:Ee,setSessionMessages:A.setSessionMessages,resetRuntimeForNewChat:A.resetSessionHistoryForNewChat,urlContext:F,urlPrompt:M,integrationClientId:E,latestIntegrationMessage:$,sendIntegrationMessage:D,sendByCtrlEnter:U});Ix({latestMessage:s,provider:xe.provider,claudeStatus:q,selectedProject:e,selectedSession:t,currentSessionId:ae,setCurrentSessionId:re,isLoading:Ue,runtimePhase:We,sendMessage:o,persistCurrentChatCache:T,setIsSystemSessionChange:ie,setPendingPermissionRequests:Ke,setIsLoading:Fe,setCanAbortSession:it,setClaudeStatus:ye,setChatMessages:nt,setTokenBudget:A.setTokenBudget,setAcpSessionModeState:Te,setAcpAvailableCommands:J,applyRealtimeConversationEvent:rt,streamBufferRef:_e,streamTimerRef:qe,clearLocalRunGuard:ue,syncLocalRunGuardSession:L,shouldIgnoreStaleIdleSignal:b,pendingViewSessionRef:Xe,appendSessionConversationEvent:A.appendSessionConversationEvent,recoverAndSettleSessionRuntime:A.recoverAndSettleSessionRuntime,recoverTerminalSessionPhase:A.recoverTerminalSessionPhase,inferRuntimePhaseFromSessionEvents:A.inferRuntimePhaseFromSessionEvents,inferTerminalPhaseFromSessionEvents:A.inferTerminalPhaseFromSessionEvents,scheduleSessionStatusRecovery:A.scheduleSessionStatusRecovery,sessionMessages:A.sessionMessages,setSessionMessages:A.setSessionMessages,loadSessionMessages:A.loadSessionMessages,onSessionInactive:d,onSessionNotProcessing:m,onSessionProcessing:u,onReplaceTemporarySession:f,onNavigateToSession:g,t:le,setRuntimePhase:ze}),i.useEffect(()=>{De.current!==j&&(De.current=j,!t&&(pe(),ue(),xe.resetComposerForNewChat()))},[ue,xe.resetComposerForNewChat,j,pe,t]);const me=Jf({status:q,messages:Ee,pendingPermissionRequests:at,t:le}),Je=Ue&&!!me;return n.jsxs(n.Fragment,{children:[n.jsx("style",{children:`
240
+ details[open] .details-chevron {
241
+ transform: rotate(180deg);
242
+ }
243
+ `}),n.jsxs("div",{className:"h-full flex flex-col",children:[n.jsx(Rh,{selectedProject:e,selectedSession:t,currentSessionId:ae,provider:xe.provider,chatMessages:Ee,threadMessages:A.threadMessages,isLoading:Ue,isLoadingSessionMessages:A.isLoadingSessionMessages,isLoadingMoreMessages:A.isLoadingMoreMessages,hasMoreMessages:A.hasMoreMessages,totalMessages:A.totalMessages,sessionMessages:A.sessionMessages,visibleMessageCount:A.visibleMessageCount,pendingPermissionRequests:at,scrollContainerRef:A.scrollContainerRef,messagesEndRef:A.messagesEndRef,onScroll:A.handleScroll,onLoadEarlierSessionMessages:()=>A.loadOlderMessages(),onLoadEarlierMessages:A.loadEarlierMessages,onProviderSelection:xe.handleProviderSelection,onFileOpen:a,onShowSettings:h,onGrantToolPermission:xe.handleGrantToolPermission,onPermissionDecision:xe.handlePermissionDecision,autoExpandTools:_,showRawParameters:y}),n.jsx(Qh,{composer:xe,statusPresentation:me,shouldShowClaudeStatus:Je,isLoading:Ue,chatMessages:Ee,sendByCtrlEnter:U})]})]})}const _0=wt.memo(E0);function A0({file:e,onClose:t}){const r=`/api/projects/${e.projectName}/files/content?path=${encodeURIComponent(e.path)}`,[o,s]=i.useState(null),[a,c]=i.useState(null),[l,d]=i.useState(!0);return i.useEffect(()=>{let u;const m=new AbortController;return(async()=>{try{d(!0),c(null),s(null);const f=await Kt(r,{signal:m.signal});if(!f.ok)throw new Error(`Request failed with status ${f.status}`);const g=await f.blob();u=URL.createObjectURL(g),s(u)}catch(f){if(f.name==="AbortError")return;console.error("Error loading image:",f),c("Unable to load image")}finally{d(!1)}})(),()=>{m.abort(),u&&URL.revokeObjectURL(u)}},[r]),n.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-4xl max-h-[90vh] w-full mx-4 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[n.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:e.name}),n.jsx(Ie,{variant:"ghost",size:"sm",onClick:t,className:"h-8 w-8 p-0",children:n.jsx($t,{className:"h-4 w-4"})})]}),n.jsxs("div",{className:"p-4 flex justify-center items-center bg-gray-50 dark:bg-gray-900 min-h-[400px]",children:[l&&n.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400",children:n.jsx("p",{children:"Loading image…"})}),!l&&o&&n.jsx("img",{src:o,alt:e.name,className:"max-w-full max-h-[70vh] object-contain rounded-lg shadow-md"}),!l&&!o&&n.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[n.jsx("p",{children:a||"Unable to load image"}),n.jsx("p",{className:"text-sm mt-2 break-all",children:e.path})]})]}),n.jsx("div",{className:"p-4 border-t bg-gray-50 dark:bg-gray-800",children:n.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:e.path})})]})})}const I0=new Set(["png","jpg","jpeg","gif","webp","bmp","svg","ico","avif"]);function T0(e){const t=String(e||""),r=t.lastIndexOf(".");return r<0?"":t.slice(r+1).toLowerCase()}function Do(e){return typeof e!="string"?"":e}function P0({file:e,onClose:t}){const[r,o]=i.useState(()=>Do(e?.diffInfo?.new_string)),[s,a]=i.useState(()=>!e?.diffInfo),[c,l]=i.useState(null),d=i.useMemo(()=>I0.has(T0(e?.name)),[e?.name]),u=!!(e?.diffInfo&&typeof e.diffInfo.new_string=="string");return i.useEffect(()=>{if(!e||u||d){a(!1),l(null),o(Do(e?.diffInfo?.new_string));return}let m=!1;return(async()=>{try{a(!0),l(null);const f=await Ze.readFile(e.projectName,e.path);if(!f.ok)throw new Error(`Request failed with status ${f.status}`);const g=await f.json();m||o(Do(g.content))}catch(f){m||(console.error("Error loading file preview:",f),l("Unable to load file preview"),o(""))}finally{m||a(!1)}})(),()=>{m=!0}},[e,u,d]),i.useEffect(()=>{const m=p=>{p.key==="Escape"&&t()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t]),e?d?n.jsx(A0,{file:e,onClose:t}):n.jsx("div",{className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",onClick:t,children:n.jsxs("div",{className:"mx-auto mt-8 flex max-h-[calc(100vh-4rem)] w-[min(1100px,calc(100vw-2rem))] flex-col overflow-hidden rounded-3xl border border-border/60 bg-background shadow-2xl",onClick:m=>m.stopPropagation(),children:[n.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-border/60 px-5 py-4",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-foreground",children:[n.jsx(fi,{className:"h-4 w-4 shrink-0"}),n.jsx("span",{className:"truncate",children:e.name})]}),n.jsx("div",{className:"mt-1 break-all font-mono text-xs text-muted-foreground",children:e.path}),u?n.jsx("div",{className:"mt-2 text-xs text-amber-600 dark:text-amber-300",children:"Showing the updated content from the chat action."}):null]}),n.jsx(Ie,{variant:"ghost",size:"icon",onClick:t,"aria-label":"Close file preview",children:n.jsx($t,{className:"h-5 w-5"})})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-auto bg-muted/20",children:s?n.jsx("div",{className:"flex h-full min-h-[320px] items-center justify-center text-sm text-muted-foreground",children:"Loading file preview..."}):c?n.jsxs("div",{className:"flex h-full min-h-[320px] flex-col items-center justify-center gap-2 px-6 text-center",children:[n.jsx("div",{className:"text-sm font-medium text-foreground",children:c}),n.jsx("div",{className:"font-mono text-xs text-muted-foreground",children:e.path})]}):n.jsx("pre",{className:"min-h-full overflow-auto p-5 font-mono text-xs leading-6 text-foreground whitespace-pre-wrap break-words",children:r})})]})}):null}var R0=Hd(),M0=Gd(),D0=Jd(),Lo={exports:{}},Ga;function L0(){return Ga||(Ga=1,function(e,t){(function(r,o){e.exports=o()})(self,()=>(()=>{var r={6:(c,l)=>{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(l,"__esModule",{value:!0}),l.LinkComputer=l.WebLinkProvider=void 0,l.WebLinkProvider=class{constructor(m,p,f,g={}){this._terminal=m,this._regex=p,this._handler=f,this._options=g}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,g)=>{if(this._options.hover){const{range:h}=p;this._options.hover(f,g,h)}},p))}};class u{static computeLink(p,f,g,h){const _=new RegExp(f.source,(f.flags||"")+"g"),[y,C]=u._getWindowedLineStrings(p-1,g),B=y.join("");let U;const Q=[];for(;U=_.exec(B);){const F=U[0];if(!d(F))continue;const[M,E]=u._mapStrIdx(g,C,0,U.index),[$,D]=u._mapStrIdx(g,M,E,F.length);if(M===-1||E===-1||$===-1||D===-1)continue;const j={start:{x:E+1,y:M+1},end:{x:D,y:$+1}};Q.push({range:j,text:F,activate:h})}return Q}static _getWindowedLineStrings(p,f){let g,h=p,_=p,y=0,C="";const B=[];if(g=f.buffer.active.getLine(p)){const U=g.translateToString(!0);if(g.isWrapped&&U[0]!==" "){for(y=0;(g=f.buffer.active.getLine(--h))&&y<2048&&(C=g.translateToString(!0),y+=C.length,B.push(C),g.isWrapped&&C.indexOf(" ")===-1););B.reverse()}for(B.push(U),y=0;(g=f.buffer.active.getLine(++_))&&g.isWrapped&&y<2048&&(C=g.translateToString(!0),y+=C.length,B.push(C),C.indexOf(" ")===-1););}return[B,h]}static _mapStrIdx(p,f,g,h){const _=p.buffer.active,y=_.getNullCell();let C=g;for(;h;){const B=_.getLine(f);if(!B)return[-1,-1];for(let U=C;U<B.length;++U){B.getCell(U,y);const Q=y.getChars();if(y.getWidth()&&(h-=Q.length||1,U===B.length-1&&Q==="")){const F=_.getLine(f+1);F&&F.isWrapped&&(F.getCell(0,y),y.getWidth()===2&&(h+=1))}if(h<0)return[f,U]}f++,C=0}return[f,C]}}l.LinkComputer=u}},o={};function s(c){var l=o[c];if(l!==void 0)return l.exports;var d=o[c]={exports:{}};return r[c](d,d.exports,s),d.exports}var a={};return(()=>{var c=a;Object.defineProperty(c,"__esModule",{value:!0}),c.WebLinksAddon=void 0;const l=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")}c.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 l.WebLinkProvider(this._terminal,f,this._handler,p))}dispose(){this._linkProvider?.dispose()}}})(),a})())}(Lo)),Lo.exports}var O0=L0();const F0=`
244
+ .xterm .xterm-screen {
245
+ outline: none !important;
246
+ }
247
+ .xterm:focus .xterm-screen {
248
+ outline: none !important;
249
+ }
250
+ .xterm-screen:focus {
251
+ outline: none !important;
252
+ }
253
+ `;if(typeof document<"u"){const e=document.createElement("style");e.type="text/css",e.innerText=F0,document.head.appendChild(e)}function $0({selectedProject:e,selectedSession:t,initialCommand:r,isPlainShell:o=!1,onProcessComplete:s,minimal:a=!1,autoConnect:c=!1}){const{t:l}=At("chat"),d=i.useRef(null),u=i.useRef(null),m=i.useRef(null),p=i.useRef(null),[f,g]=i.useState(!1),[h,_]=i.useState(!1),[y,C]=i.useState(!1),[B,U]=i.useState(null),[Q,F]=i.useState(!1),M=i.useRef(e),E=i.useRef(t),$=i.useRef(r),D=i.useRef(o),j=i.useRef(s);i.useEffect(()=>{M.current=e,E.current=t,$.current=r,D.current=o,j.current=s});const le=i.useCallback(async()=>{if(!(Q||f))try{let ie;if(!bf){const q=localStorage.getItem("auth-token");if(!q){console.error("No authentication token found for Shell WebSocket connection");return}ie=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/shell?token=${encodeURIComponent(q)}`}p.current=new WebSocket(ie),p.current.onopen=()=>{g(!0),F(!1),setTimeout(()=>{m.current&&u.current&&(m.current.fit(),p.current.send(JSON.stringify({type:"init",projectPath:M.current.fullPath||M.current.path,sessionId:D.current?null:E.current?.id,hasSession:D.current?!1:!!E.current,provider:D.current?"plain-shell":E.current?.__provider||"claude",cols:u.current.cols,rows:u.current.rows,initialCommand:$.current,isPlainShell:D.current})))},100)},p.current.onmessage=q=>{try{const ye=JSON.parse(q.data);if(ye.type==="output"){let fe=ye.data;if(D.current&&j.current){const Te=fe.replace(/\x1b\[[0-9;]*m/g,"");if(Te.includes("Process exited with code 0"))j.current(0);else if(Te.match(/Process exited with code (\d+)/)){const ee=parseInt(Te.match(/Process exited with code (\d+)/)[1]);ee!==0&&j.current(ee)}}u.current&&u.current.write(fe)}else ye.type==="url_open"&&window.open(ye.url,"_blank")}catch(ye){console.error("[Shell] Error handling WebSocket message:",ye,q.data)}},p.current.onclose=q=>{g(!1),F(!1),u.current&&(u.current.clear(),u.current.write("\x1B[2J\x1B[H"))},p.current.onerror=q=>{g(!1),F(!1)}}catch{g(!1),F(!1)}},[Q,f]),te=i.useCallback(()=>{!h||f||Q||(F(!0),le())},[h,f,Q,le]),X=i.useCallback(()=>{p.current&&(p.current.close(),p.current=null),u.current&&(u.current.clear(),u.current.write("\x1B[2J\x1B[H")),g(!1),F(!1)},[]),Z=i.useMemo(()=>t?t.summary||t.name||"New Session":null,[t]),ae=i.useMemo(()=>Z?Z.slice(0,30):null,[Z]),re=i.useMemo(()=>Z?Z.slice(0,50):null,[Z]),de=()=>{C(!0),p.current&&(p.current.close(),p.current=null),u.current&&(u.current.dispose(),u.current=null,m.current=null),g(!1),_(!1),setTimeout(()=>{C(!1)},200)};return i.useEffect(()=>{const ie=t?.id||null;B!==null&&B!==ie&&h&&X(),U(ie)},[t?.id,h,X]),i.useEffect(()=>{if(!d.current||!e||y||u.current)return;u.current=new R0.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 M0.FitAddon;const ie=new D0.WebglAddon,q=new O0.WebLinksAddon;u.current.loadAddon(m.current),u.current.loadAddon(q);try{u.current.loadAddon(ie)}catch{console.warn("[Shell] WebGL renderer unavailable, using Canvas fallback")}u.current.open(d.current),u.current.attachCustomKeyEventHandler(fe=>(fe.ctrlKey||fe.metaKey)&&fe.key==="c"&&u.current.hasSelection()?(document.execCommand("copy"),!1):(fe.ctrlKey||fe.metaKey)&&fe.key==="v"?(navigator.clipboard.readText().then(Te=>{p.current&&p.current.readyState===WebSocket.OPEN&&p.current.send(JSON.stringify({type:"input",data:Te}))}).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),_(!0),u.current.onData(fe=>{p.current&&p.current.readyState===WebSocket.OPEN&&p.current.send(JSON.stringify({type:"input",data:fe}))});const ye=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&&ye.observe(d.current),()=>{ye.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]),i.useEffect(()=>{!c||!h||Q||f||te()},[c,h,Q,f,te]),e?a?n.jsx("div",{className:"h-full w-full bg-gray-900",children:n.jsx("div",{ref:d,className:"h-full w-full focus:outline-none",style:{outline:"none"}})}):n.jsxs("div",{className:"h-full flex flex-col bg-gray-900 w-full",children:[n.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("div",{className:`w-2 h-2 rounded-full ${f?"bg-green-500":"bg-red-500"}`}),t&&n.jsxs("span",{className:"text-xs text-primary/80",children:["(",ae,"...)"]}),!t&&n.jsx("span",{className:"text-xs text-gray-400",children:l("shell.status.newSession")}),!h&&n.jsx("span",{className:"text-xs text-yellow-400",children:l("shell.status.initializing")}),y&&n.jsx("span",{className:"text-xs text-primary",children:l("shell.status.restarting")})]}),n.jsxs("div",{className:"flex items-center space-x-3",children:[f&&n.jsxs("button",{onClick:X,className:"px-3 py-1 text-xs bg-red-600 text-white rounded hover:bg-red-700 flex items-center space-x-1",title:l("shell.actions.disconnectTitle"),children:[n.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),n.jsx("span",{children:l("shell.actions.disconnect")})]}),n.jsxs("button",{onClick:de,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:l("shell.actions.restartTitle"),children:[n.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.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"})}),n.jsx("span",{children:l("shell.actions.restart")})]})]})]})}),n.jsxs("div",{className:"flex-1 p-2 overflow-hidden relative",children:[n.jsx("div",{ref:d,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),!h&&n.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90",children:n.jsx("div",{className:"text-white",children:l("shell.loading")})}),h&&!f&&!Q&&n.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:n.jsxs("div",{className:"text-center max-w-sm w-full",children:[n.jsxs("button",{onClick:te,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:l("shell.actions.connectTitle"),children:[n.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),n.jsx("span",{children:l("shell.actions.connect")})]}),n.jsx("p",{className:"text-gray-400 text-sm mt-3 px-2",children:o?l("shell.runCommand",{command:r||l("shell.defaultCommand"),projectName:e.displayName}):t?l("shell.resumeSession",{displayName:re}):l("shell.startSession")})]})}),Q&&n.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:n.jsxs("div",{className:"text-center max-w-sm w-full",children:[n.jsxs("div",{className:"flex items-center justify-center space-x-3 text-yellow-400",children:[n.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-yellow-400 border-t-transparent"}),n.jsx("span",{className:"text-base font-medium",children:l("shell.connecting")})]}),n.jsx("p",{className:"text-gray-400 text-sm mt-3 px-2",children:o?l("shell.runCommand",{command:r||l("shell.defaultCommand"),projectName:e.displayName}):l("shell.startCli",{projectName:e.displayName})})]})})]})]}):n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[n.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:n.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.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"})})}),n.jsx("h3",{className:"text-lg font-semibold mb-2",children:l("shell.selectProject.title")}),n.jsx("p",{children:l("shell.selectProject.description")})]})})}function il({project:e,session:t=null,command:r=null,isPlainShell:o=null,autoConnect:s=!0,onComplete:a=null,onClose:c=null,title:l=null,className:d="",showHeader:u=!0,compact:m=!1,minimal:p=!1}){const[f,g]=i.useState(!1),h=o!==null?o:r!==null,_=i.useCallback(y=>{g(!0),a&&a(y)},[a]);return e?n.jsxs("div",{className:`h-full w-full flex flex-col ${d}`,children:[!p&&u&&l&&n.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-200",children:l}),f&&n.jsx("span",{className:"text-xs text-green-400",children:"(Completed)"})]}),c&&n.jsx("button",{onClick:c,className:"text-gray-400 hover:text-white",title:"Close",children:n.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),n.jsx("div",{className:"flex-1 w-full min-h-0",children:n.jsx($0,{selectedProject:e,selectedSession:t,initialCommand:r,isPlainShell:h,onProcessComplete:_,minimal:p,autoConnect:p?!0:s})})]}):n.jsx("div",{className:`h-full flex items-center justify-center ${d}`,children:n.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[n.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:n.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.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"})})}),n.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Project Selected"}),n.jsx("p",{children:"A project is required to open a shell"})]})})}class z0 extends wt.Component{constructor(t){super(t),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(t){return{hasError:!0}}componentDidCatch(t,r){console.error("ErrorBoundary caught an error:",t,r),this.setState({error:t,errorInfo:r})}render(){return this.state.hasError?n.jsx("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:n.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-6 max-w-md",children:[n.jsxs("div",{className:"flex items-center mb-4",children:[n.jsx("div",{className:"flex-shrink-0",children:n.jsx("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:n.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"})})}),n.jsx("h3",{className:"ml-3 text-sm font-medium text-red-800",children:"Something went wrong"})]}),n.jsxs("div",{className:"text-sm text-red-700",children:[n.jsx("p",{className:"mb-2",children:"An error occurred while loading the chat interface."}),this.props.showDetails&&this.state.error&&n.jsxs("details",{className:"mt-4",children:[n.jsx("summary",{className:"cursor-pointer text-xs font-mono",children:"Error Details"}),n.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]})]})]}),n.jsx("div",{className:"mt-4",children:n.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}}function cl(e){return e==="files"?"chat":e}function B0({selectedProject:e,selectedSession:t,activeTab:r,setActiveTab:o,ws:s,sendMessage:a,latestMessage:c,isMobile:l,isPWA:d,onMenuClick:u,isLoading:m,onInputFocusChange:p,onSessionActive:f,onSessionInactive:g,onSessionProcessing:h,onSessionNotProcessing:_,processingSessions:y,onReplaceTemporarySession:C,onNavigateToSession:B,onShowSettings:U,autoExpandTools:Q,showRawParameters:F,showThinking:M,autoScrollToBottom:E,sendByCtrlEnter:$,externalMessageUpdate:D,urlContext:j,urlPrompt:le,integrationClientId:te,latestIntegrationMessage:X,sendIntegrationMessage:Z,onShowNewProject:ae,onNewSession:re,newSessionResetNonce:de}){const{t:ie}=At(),[q,ye]=i.useState(null),fe=(he,Xe=null)=>{const De={name:he.split("/").pop(),path:he,projectName:e?.name,diffInfo:Xe};ye(De)},Te=()=>{ye(null)};if(i.useEffect(()=>{const he=cl(r);he!==r&&o(he)},[r,o]),m)return n.jsxs("div",{className:"h-full flex flex-col",children:[l&&n.jsx("div",{className:"bg-background/90 p-2 sm:p-3 pwa-header-safe flex-shrink-0 backdrop-blur",children:n.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:n.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[n.jsx("div",{className:"w-12 h-12 mx-auto mb-4",children:n.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"}})}),n.jsx("h2",{className:"text-xl font-semibold",children:ie("mainContent.loading")})]})})]});if(!e)return n.jsxs("div",{className:"chat-shell h-full flex flex-col bg-background",children:[l&&n.jsx("div",{className:"bg-background/90 p-2 sm:p-3 pwa-header-safe flex-shrink-0 backdrop-blur",children:n.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:n.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),n.jsx("div",{className:"flex flex-1 items-center justify-center px-4 py-8 sm:px-6",children:n.jsxs("div",{className:"w-full max-w-xl px-8 py-10 text-center text-muted-foreground",children:[n.jsx("div",{className:"mx-auto mb-6 flex h-16 w-16 items-center justify-center rounded-3xl bg-primary/10 text-primary",children:n.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.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"})})}),n.jsx("h2",{className:"text-2xl font-semibold mb-3 text-gray-900 dark:text-white",children:ie("mainContent.chooseProject")}),n.jsx("p",{className:"text-gray-600 dark:text-gray-300 mb-6 leading-relaxed",children:ie("mainContent.selectProjectDescription")}),n.jsx("div",{className:"mx-auto flex w-fit items-center",children:n.jsxs("button",{onClick:ae,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:ie("sidebar:projects.newProject"),children:[n.jsx(An,{className:"w-5 h-5"}),n.jsx("span",{children:ie("sidebar:projects.newProject")})]})})]})})]});const ee=t?.__provider||t?.provider||"claude",J=ee==="openai"?"codex":ee,be=J==="codex"&&typeof t?.id=="string"?t.id.trim():"",Ce=be?`codex://threads/${encodeURIComponent(be)}`:"",ke=()=>{Ce&&(window.location.href=Ce)};return n.jsxs("div",{className:"chat-shell h-full flex flex-col bg-background",children:[n.jsx("div",{className:"chat-header flex-shrink-0 px-3 py-3 sm:px-4 sm:py-3 pwa-header-safe",children:n.jsxs("div",{className:"relative flex items-center justify-between gap-3",children:[n.jsxs("div",{className:"flex min-w-0 flex-1 items-center space-x-2",children:[l&&n.jsx("button",{onClick:u,onTouchStart:he=>{he.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:n.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),n.jsxs("div",{className:"flex flex-1 items-center gap-3 overflow-x-auto scrollbar-hide min-w-0",children:[r==="chat"&&t&&n.jsx("div",{className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-xl bg-muted/60",children:J==="codex"?n.jsx(fr,{className:"w-4 h-4"}):J==="gemini"?n.jsx(hr,{className:"w-4 h-4"}):J==="opencode"?n.jsx(xr,{className:"h-4 w-auto max-w-full"}):n.jsx(mr,{className:"w-4 h-4"})}),n.jsx("div",{className:"min-w-0 flex-1",children:r==="chat"&&t?n.jsxs("div",{className:"min-w-0",children:[n.jsx("h2",{className:"overflow-x-auto whitespace-nowrap scrollbar-hide text-sm font-semibold text-gray-900 dark:text-white sm:text-base",children:J==="codex"?t.summary||t.name||"Codex Session":J==="gemini"?t.summary||t.name||"Gemini Session":J==="opencode"?t.summary||t.name||"OpenCode Session":t.summary||"New Session"}),n.jsx("div",{className:"truncate text-xs text-gray-500 dark:text-gray-400",children:e.displayName})]}):r==="chat"&&!t?n.jsxs("div",{className:"min-w-0",children:[n.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:ie("mainContent.newSession")}),n.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.displayName})]}):n.jsxs("div",{className:"min-w-0",children:[n.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:"Project"}),n.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.displayName})]})})]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[r==="chat"&&J==="codex"&&Ce&&!l&&n.jsx("button",{onClick:ke,className:"rounded-xl bg-muted/60 p-2 text-muted-foreground transition hover:bg-muted hover:text-foreground",title:ie("mainContent.openInCodexClient"),"aria-label":ie("mainContent.openInCodexClient"),children:n.jsx(Kr,{className:"w-5 h-5"})}),n.jsx("button",{onClick:()=>re&&re(e),className:"rounded-xl bg-muted/60 p-2 text-muted-foreground transition hover:bg-muted hover:text-foreground",title:ie("tooltips.newChat","New Chat"),children:n.jsx(_u,{className:"w-5 h-5"})})]})]})}),n.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:n.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[n.jsx("div",{className:`h-full ${r==="chat"?"block":"hidden"}`,children:n.jsx(z0,{showDetails:!0,children:n.jsx(_0,{selectedProject:e,selectedSession:t,ws:s,sendMessage:a,latestMessage:c,onFileOpen:fe,onInputFocusChange:p,onSessionActive:f,onSessionInactive:g,onSessionProcessing:h,onSessionNotProcessing:_,processingSessions:y,onReplaceTemporarySession:C,onNavigateToSession:B,onShowSettings:U,autoExpandTools:Q,showRawParameters:F,showThinking:M,autoScrollToBottom:E,sendByCtrlEnter:$,externalMessageUpdate:D,urlContext:j,urlPrompt:le,integrationClientId:te,latestIntegrationMessage:X,sendIntegrationMessage:Z,newSessionResetNonce:de},`${e?.name||"no-project"}:${t?.id||`new-${de}`}`)})}),r==="shell"&&n.jsx("div",{className:"h-full w-full overflow-hidden",children:n.jsx(il,{project:e,session:t,showHeader:!1})}),n.jsx("div",{className:`h-full overflow-hidden ${r==="preview"?"block":"hidden"}`})]})}),q&&n.jsx(P0,{file:q,onClose:Te})]})}const U0=wt.memo(B0),ll="0.2.10",dl=()=>{const[e,t]=i.useState(!1),[r,o]=i.useState(null),[s,a]=i.useState(null);return i.useEffect(()=>{(async()=>{try{const l=await Kt("/api/system/version");if(!l.ok)throw new Error(`Version API failed: ${l.status}`);const d=await l.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(l){console.error("Version check failed:",l.message||l),t(!1),o(null),a(null)}})()},[]),{updateAvailable:e,latestVersion:r,currentVersion:ll,releaseInfo:s}};function W0(){const{t:e}=At("settings"),[t,r]=i.useState([]),[o,s]=i.useState(!0),[a,c]=i.useState(!1),[l,d]=i.useState(""),[u,m]=i.useState(null),[p,f]=i.useState(null),{updateAvailable:g,latestVersion:h,releaseInfo:_}=dl();i.useEffect(()=>{y()},[]);const y=async()=>{try{s(!0);const M=await(await Kt("/api/settings/api-keys")).json();r(M.apiKeys||[])}catch(F){console.error("Error fetching settings:",F)}finally{s(!1)}},C=async()=>{if(l.trim())try{const M=await(await Kt("/api/settings/api-keys",{method:"POST",body:JSON.stringify({keyName:l})})).json();M.success&&(f(M.apiKey),d(""),c(!1),y())}catch(F){console.error("Error creating API key:",F)}},B=async F=>{if(confirm(e("apiKeys.confirmDelete")))try{await Kt(`/api/settings/api-keys/${F}`,{method:"DELETE"}),y()}catch(M){console.error("Error deleting API key:",M)}},U=async(F,M)=>{try{await Kt(`/api/settings/api-keys/${F}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!M})}),y()}catch(E){console.error("Error toggling API key:",E)}},Q=(F,M)=>{navigator.clipboard.writeText(F),m(M),setTimeout(()=>m(null),2e3)};return o?n.jsx("div",{className:"text-muted-foreground",children:e("apiKeys.loading")}):n.jsxs("div",{className:"space-y-8",children:[p&&n.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/20 rounded-lg",children:[n.jsx("h4",{className:"font-semibold text-yellow-500 mb-2",children:e("apiKeys.newKey.alertTitle")}),n.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:e("apiKeys.newKey.alertMessage")}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("code",{className:"flex-1 px-3 py-2 bg-background/50 rounded font-mono text-sm break-all",children:p.apiKey}),n.jsx(Ie,{size:"sm",variant:"outline",onClick:()=>Q(p.apiKey,"new"),children:u==="new"?n.jsx(yn,{className:"h-4 w-4"}):n.jsx(pi,{className:"h-4 w-4"})})]}),n.jsx(Ie,{size:"sm",variant:"ghost",className:"mt-3",onClick:()=>f(null),children:e("apiKeys.newKey.iveSavedIt")})]}),n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(xi,{className:"h-5 w-5"}),n.jsx("h3",{className:"text-lg font-semibold",children:e("apiKeys.title")})]}),n.jsxs(Ie,{size:"sm",onClick:()=>c(!a),children:[n.jsx(ro,{className:"h-4 w-4 mr-1"}),e("apiKeys.newButton")]})]}),n.jsxs("div",{className:"mb-4",children:[n.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:e("apiKeys.description")}),n.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"),n.jsx(Kr,{className:"h-3 w-3"})]})]}),a&&n.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card",children:[n.jsx(bn,{placeholder:e("apiKeys.form.placeholder"),value:l,onChange:F=>d(F.target.value),className:"mb-2"}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(Ie,{onClick:C,children:e("apiKeys.form.createButton")}),n.jsx(Ie,{variant:"outline",onClick:()=>c(!1),children:e("apiKeys.form.cancelButton")})]})]}),n.jsx("div",{className:"space-y-2",children:t.length===0?n.jsx("p",{className:"text-sm text-muted-foreground italic",children:e("apiKeys.empty")}):t.map(F=>n.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:"font-medium",children:F.key_name}),n.jsx("code",{className:"text-xs text-muted-foreground",children:F.api_key}),n.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[e("apiKeys.list.created")," ",new Date(F.created_at).toLocaleDateString(),F.last_used&&` • ${e("apiKeys.list.lastUsed")} ${new Date(F.last_used).toLocaleDateString()}`]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Ie,{size:"sm",variant:F.is_active?"outline":"secondary",onClick:()=>U(F.id,F.is_active),children:F.is_active?e("apiKeys.status.active"):e("apiKeys.status.inactive")}),n.jsx(Ie,{size:"sm",variant:"ghost",onClick:()=>B(F.id),children:n.jsx(Cn,{className:"h-4 w-4"})})]})]},F.id))})]}),n.jsx("div",{className:"pt-6 border-t border-border/50",children:n.jsxs("div",{className:"flex items-center justify-between text-xs italic text-muted-foreground/60",children:[n.jsxs("a",{href:_?.htmlUrl||"https://github.com/lintendo/AI-Web-UI/releases",target:"_blank",rel:"noopener noreferrer",className:"hover:text-muted-foreground transition-colors",children:["v",ll]}),g&&h&&n.jsxs("a",{href:_?.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:[n.jsx("span",{className:"text-[10px]",children:e("apiKeys.version.updateAvailable",{version:h})}),n.jsx(Kr,{className:"h-2.5 w-2.5"})]})]})})]})}function K0({compact:e=!1}){const{i18n:t,t:r}=At("settings"),o=s=>{const a=s.target.value;t.changeLanguage(a)};return e?n.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:[n.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[n.jsx(ju,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),r("account.language")]}),n.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:qs.map(s=>n.jsx("option",{value:s.value,children:s.nativeName},s.value))})]}):n.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100 mb-1",children:r("account.languageLabel")}),n.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:r("account.languageDescription")})]}),n.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:qs.map(s=>n.jsx("option",{value:s.value,children:s.nativeName},s.value))})]})})}function q0({isOpen:e,onClose:t,provider:r="claude",project:o,onComplete:s,customCommand:a,isAuthenticated:c=!1}){if(!e)return null;const l=()=>{if(a)return a;switch(r){case"claude":return c?"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 c?"claude setup-token --dangerously-skip-permissions":"claude /exit --dangerously-skip-permissions"}},d=()=>{switch(r){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 n.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:n.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:[n.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[n.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:d()}),n.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:n.jsx($t,{className:"w-6 h-6"})})]}),n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(il,{project:o,command:l(),onComplete:u,minimal:!0})})]})})}const Oo=["appearance","api"],V0={allowedTools:[],disallowedTools:[],skipPermissions:!1,projectSortOrder:"name"},H0={permissionMode:"default"},G0=["Bash(git log:*)","Bash(git diff:*)","Bash(git status:*)","Write","Read","Edit","Glob","Grep","MultiEdit","Task","TodoWrite","TodoRead","WebFetch","WebSearch"],ps=[{key:"claude",label:"Claude CLI",endpoint:"/api/cli/claude/status"},{key:"codex",label:"Codex CLI",endpoint:"/api/cli/codex/status"},{key:"gemini",label:"Gemini CLI",endpoint:"/api/cli/gemini/status"},{key:"opencode",label:"OpenCode CLI",endpoint:"/api/cli/opencode/status"}];function Ja(e,t){try{const r=localStorage.getItem(e);if(!r)return t;const o=JSON.parse(r);return o&&typeof o=="object"?{...t,...o}:t}catch{return t}}function J0(){return ps.reduce((e,t)=>(e[t.key]={authenticated:!1,email:null,loading:!0,error:null},e),{})}function Ya(){if(typeof window>"u")return{name:"default",fullPath:"/"};const e=new URLSearchParams(window.location.search);return{name:"default",fullPath:e.get("cwd")||e.get("workdir")||"/"}}function Xa({title:e,description:t,checked:r,onToggle:o}){return n.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-2xl border border-border/60 bg-card/70 px-4 py-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"text-sm font-medium text-foreground",children:e}),t?n.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:t}):null]}),n.jsx("button",{type:"button",onClick:o,className:`relative h-7 w-12 rounded-full transition ${r?"bg-primary":"bg-muted"}`,"aria-checked":r,role:"switch",children:n.jsx("span",{className:`absolute top-1 h-5 w-5 rounded-full bg-background shadow transition ${r?"left-6":"left-1"}`})})]})}function Qa({items:e,onRemove:t,emptyLabel:r}){return e.length?n.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(o=>n.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-border/60 bg-muted/40 px-3 py-1 text-xs",children:[n.jsx("span",{className:"font-mono",children:o}),n.jsx("button",{type:"button",onClick:()=>t(o),className:"text-muted-foreground hover:text-foreground",children:n.jsx($t,{className:"h-3.5 w-3.5"})})]},o))}):n.jsx("div",{className:"text-xs text-muted-foreground",children:r})}function Y0({provider:e,status:t,onLogin:r}){const o=t?.authenticated,s=t?.loading,a=o?"border-emerald-500/25 bg-emerald-500/5":t?.error?"border-amber-500/25 bg-amber-500/5":"border-border/60 bg-card/70";return n.jsxs("div",{className:`rounded-2xl border px-4 py-4 ${a}`,children:[n.jsxs("div",{className:"flex items-start justify-between gap-3",children:[n.jsxs("div",{children:[n.jsx("div",{className:"text-sm font-semibold text-foreground",children:e.label}),n.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:s?"Checking local authentication...":o?t.email||"Authenticated locally":t?.error||"Not authenticated"})]}),n.jsx(Bd,{variant:o?"default":"secondary",children:s?"Checking":o?"Ready":"Needs login"})]}),n.jsx("div",{className:"mt-4 flex items-center gap-2",children:n.jsxs(Ie,{size:"sm",variant:o?"outline":"default",onClick:()=>r(e.key),children:[n.jsx(Ud,{className:"mr-2 h-4 w-4"}),o?"Re-authenticate":"Open login"]})})]})}function X0({isOpen:e,onClose:t,projects:r=[],initialTab:o="appearance"}){const{isDarkMode:s,toggleDarkMode:a}=ui(),[c,l]=i.useState(Oo.includes(o)?o:"appearance"),[d,u]=i.useState([]),[m,p]=i.useState([]),[f,g]=i.useState(""),[h,_]=i.useState(""),[y,C]=i.useState(!1),[B,U]=i.useState("name"),[Q,F]=i.useState("default"),[M,E]=i.useState(!1),[$,D]=i.useState(null),[j,le]=i.useState(J0),[te,X]=i.useState(!1),[Z,ae]=i.useState("claude"),[re,de]=i.useState(null);i.useEffect(()=>{l(Oo.includes(o)?o:"appearance")},[o]),i.useEffect(()=>{if(!e)return;const J=Ja("claude-settings",V0),be=Ja("codex-settings",H0);u(Array.isArray(J.allowedTools)?J.allowedTools:[]),p(Array.isArray(J.disallowedTools)?J.disallowedTools:[]),C(!!J.skipPermissions),U(J.projectSortOrder==="date"?"date":"name"),F(be.permissionMode||"default"),D(null),q()},[e]);const ie=i.useMemo(()=>re||r?.[0]||Ya(),[r,re]);async function q(){const J=await Promise.all(ps.map(async be=>{try{const Ce=await Kt(be.endpoint),ke=Ce.ok?await Ce.json():null;return[be.key,{authenticated:!!ke?.authenticated,email:ke?.email||null,loading:!1,error:ke?.error||(Ce.ok?null:"Failed to check authentication status")}]}catch(Ce){return[be.key,{authenticated:!1,email:null,loading:!1,error:Ce.message}]}}));le(Object.fromEntries(J))}function ye(){E(!0),D(null);try{localStorage.setItem("claude-settings",JSON.stringify({allowedTools:d,disallowedTools:m,skipPermissions:y,projectSortOrder:B,lastUpdated:new Date().toISOString()})),localStorage.setItem("codex-settings",JSON.stringify({permissionMode:Q,lastUpdated:new Date().toISOString()})),D("success"),window.dispatchEvent(new StorageEvent("storage",{key:"claude-settings"})),window.dispatchEvent(new StorageEvent("storage",{key:"codex-settings"}))}catch(J){console.error("Error saving local settings:",J),D("error")}finally{E(!1)}}function fe(J){ae(J),de(r?.[0]||Ya()),X(!0)}function Te(J){J===0&&(D("success"),q())}function ee(J,be,Ce,ke){const he=J.trim();!he||Ce.includes(he)||(ke([...Ce,he]),be(""))}return e?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",onClick:t}),n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:n.jsxs("div",{className:"flex h-[85vh] w-full max-w-5xl flex-col overflow-hidden rounded-3xl border border-border/60 bg-background shadow-2xl",children:[n.jsxs("div",{className:"flex items-center justify-between border-b border-border/60 px-6 py-4",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"flex h-11 w-11 items-center justify-center rounded-2xl bg-primary/10 text-primary",children:n.jsx(Lu,{className:"h-5 w-5"})}),n.jsxs("div",{children:[n.jsx("div",{className:"text-lg font-semibold text-foreground",children:"Settings"}),n.jsx("div",{className:"text-sm text-muted-foreground",children:"Local preferences, provider auth, and API access."})]})]}),n.jsx(Ie,{variant:"ghost",size:"icon",onClick:t,"aria-label":"Close settings",children:n.jsx($t,{className:"h-5 w-5"})})]}),n.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[n.jsx("div",{className:"w-52 border-r border-border/60 bg-muted/20 p-4",children:n.jsx("div",{className:"space-y-2",children:Oo.map(J=>n.jsxs("button",{type:"button",onClick:()=>l(J),className:`flex w-full items-center gap-3 rounded-2xl px-4 py-3 text-left text-sm transition ${c===J?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:bg-muted/70 hover:text-foreground"}`,children:[J==="appearance"?n.jsx(Ku,{className:"h-4 w-4"}):n.jsx(xi,{className:"h-4 w-4"}),n.jsx("span",{children:J==="appearance"?"Appearance":"API & Auth"})]},J))})}),n.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-5",children:c==="appearance"?n.jsxs("div",{className:"space-y-6",children:[n.jsxs("section",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"text-base font-semibold text-foreground",children:"Application"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Adjust the shell around the editor and sidebar."})]}),n.jsx(Xa,{title:"Dark mode",description:"Switch the overall application theme.",checked:s,onToggle:a}),n.jsxs("div",{className:"rounded-2xl border border-border/60 bg-card/70 px-4 py-3",children:[n.jsxs("div",{className:"mb-3 flex items-center gap-2 text-sm font-medium text-foreground",children:[n.jsx(zd,{className:"h-4 w-4"}),"Interface language"]}),n.jsx(K0,{})]}),n.jsxs("div",{className:"rounded-2xl border border-border/60 bg-card/70 px-4 py-3",children:[n.jsx("div",{className:"mb-2 text-sm font-medium text-foreground",children:"Project list sorting"}),n.jsxs("select",{value:B,onChange:J=>U(J.target.value==="date"?"date":"name"),className:"w-full rounded-xl border border-border bg-background px-3 py-2 text-sm",children:[n.jsx("option",{value:"name",children:"Name"}),n.jsx("option",{value:"date",children:"Last activity"})]})]})]}),n.jsxs("section",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"text-base font-semibold text-foreground",children:"Claude / Codex local behavior"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"These options stay in local storage and are used by the chat runtime."})]}),n.jsx(Xa,{title:"Skip Claude permission prompts",description:"Bypass interactive approvals when the runtime supports it.",checked:y,onToggle:()=>C(J=>!J)}),n.jsxs("div",{className:"rounded-2xl border border-border/60 bg-card/70 px-4 py-3",children:[n.jsx("div",{className:"mb-2 text-sm font-medium text-foreground",children:"Codex permission mode"}),n.jsxs("select",{value:Q,onChange:J=>F(J.target.value||"default"),className:"w-full rounded-xl border border-border bg-background px-3 py-2 text-sm",children:[n.jsx("option",{value:"default",children:"Default"}),n.jsx("option",{value:"acceptEdits",children:"Accept edits"}),n.jsx("option",{value:"bypassPermissions",children:"Bypass permissions"}),n.jsx("option",{value:"plan",children:"Plan"})]})]}),n.jsxs("div",{className:"rounded-2xl border border-border/60 bg-card/70 px-4 py-4",children:[n.jsxs("div",{className:"mb-3 flex items-center gap-2 text-sm font-medium text-foreground",children:[n.jsx($u,{className:"h-4 w-4"}),"Allowed tool patterns"]}),n.jsx("div",{className:"flex flex-wrap gap-2 pb-3",children:G0.map(J=>n.jsx("button",{type:"button",onClick:()=>ee(J,g,d,u),className:"rounded-full border border-border/60 px-3 py-1 text-xs text-muted-foreground transition hover:border-primary hover:text-foreground",children:J},J))}),n.jsxs("div",{className:"flex gap-2 pb-3",children:[n.jsx(bn,{value:f,onChange:J=>g(J.target.value),placeholder:"Add custom allow rule"}),n.jsx(Ie,{onClick:()=>ee(f,g,d,u),children:"Add"})]}),n.jsx(Qa,{items:d,onRemove:J=>u(d.filter(be=>be!==J)),emptyLabel:"No allow-list entries."})]}),n.jsxs("div",{className:"rounded-2xl border border-border/60 bg-card/70 px-4 py-4",children:[n.jsxs("div",{className:"mb-3 flex items-center gap-2 text-sm font-medium text-foreground",children:[n.jsx(Vr,{className:"h-4 w-4"}),"Disallowed tool patterns"]}),n.jsxs("div",{className:"flex gap-2 pb-3",children:[n.jsx(bn,{value:h,onChange:J=>_(J.target.value),placeholder:"Add custom deny rule"}),n.jsx(Ie,{variant:"outline",onClick:()=>ee(h,_,m,p),children:"Add"})]}),n.jsx(Qa,{items:m,onRemove:J=>p(m.filter(be=>be!==J)),emptyLabel:"No deny-list entries."})]})]})]}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("section",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"text-base font-semibold text-foreground",children:"Provider authentication"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Open a local terminal flow to sign the CLI back in when needed."})]}),n.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:ps.map(J=>n.jsx(Y0,{provider:J,status:j[J.key],onLogin:fe},J.key))})]}),n.jsxs("section",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"text-base font-semibold text-foreground",children:"API keys"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage the local keys used to call protected Genie endpoints."})]}),n.jsx(W0,{})]})]})})]}),n.jsxs("div",{className:"flex items-center justify-between border-t border-border/60 px-6 py-4",children:[n.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:$==="success"?n.jsxs(n.Fragment,{children:[n.jsx(yn,{className:"h-4 w-4 text-emerald-500"}),n.jsx("span",{children:"Saved locally."})]}):$==="error"?n.jsxs(n.Fragment,{children:[n.jsx(Vr,{className:"h-4 w-4 text-amber-500"}),n.jsx("span",{children:"Could not save local settings."})]}):n.jsx("span",{children:"Changes only affect this local workspace profile."})}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Ie,{variant:"outline",onClick:t,children:"Close"}),n.jsx(Ie,{onClick:ye,disabled:M,children:M?"Saving...":"Save settings"})]})]})]})}),n.jsx(q0,{isOpen:te,onClose:()=>X(!1),provider:Z,project:ie,onComplete:Te,isAuthenticated:!!j[Z]?.authenticated})]}):null}function Q0(e=window.location.hostname){return e==="localhost"||e==="127.0.0.1"||e==="::1"}const ul=i.createContext({user:null,token:null,authenticateLanAccess:()=>{},logout:()=>{},isLoading:!0,error:null}),Ps=()=>{const e=i.useContext(ul);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e},Z0=({children:e})=>{const[t,r]=i.useState(null),[o,s]=i.useState(localStorage.getItem("auth-token")),[a,c]=i.useState(!0),[l,d]=i.useState(null),u=()=>{localStorage.removeItem("auth-token"),s(null),r(null)},m=(_,y)=>{_&&(localStorage.setItem("auth-token",_),s(_)),r(y||null)},p=async()=>{const _=await Ze.auth.bootstrap(),y=await _.json();if(!_.ok){if(_.status===403)return!1;throw new Error(y?.error||"Failed to initialize local access")}return m(y.token,y.user),!0},f=async()=>{try{c(!0),d(null);const _=localStorage.getItem("auth-token");if(_)try{const y=await Ze.auth.user();if(y.ok){const C=await y.json();s(_),r(C.user);return}u()}catch(y){console.error("Token verification failed:",y),u()}Q0()&&await p()}catch(_){console.error("[AuthContext] Authentication bootstrap failed:",_),d(_.message||"Failed to initialize access")}finally{c(!1)}};i.useEffect(()=>{f()},[]);const g=async _=>{try{d(null);const y=await Ze.lanAccess.login(_),C=await y.json();if(y.ok)return m(C.token,C.user),{success:!0};const B=C?.error||"Access denied";return d(B),{success:!1,error:B}}catch(y){console.error("LAN access login error:",y);const C="Network error. Please try again.";return d(C),{success:!1,error:C}}},h=()=>{u(),o&&Ze.auth.logout().catch(_=>{console.error("Logout endpoint error:",_)})};return n.jsx(ul.Provider,{value:{user:t,token:o,authenticateLanAccess:g,logout:h,isLoading:a,error:l},children:e})},pl=i.createContext(null),ev=()=>{const e=i.useContext(pl);if(!e)throw new Error("useWebSocket must be used within a WebSocketProvider");return e},tv=e=>{const t=window.location.protocol==="https:"?"wss:":"ws:";return e?`${t}//${window.location.host}/ws?token=${encodeURIComponent(e)}`:null},nv=()=>{const e=i.useRef(null),t=i.useRef(!1),[r,o]=i.useState(null),[s,a]=i.useState(!1),c=i.useRef(null),l=i.useRef(!1),d=i.useRef([]),u=i.useRef([]),m=i.useRef(null),p=i.useRef(0),{token:f}=Ps(),g=i.useCallback(()=>{if(m.current||t.current)return;const M=()=>{if(m.current=null,t.current){u.current=[];return}const E=u.current.shift();E&&(p.current+=1,o({...E,__messageSeq:p.current}),u.current.length>0&&(m.current=setTimeout(M,0)))};m.current=setTimeout(M,0)},[]),h=i.useCallback(M=>{u.current.push(M),g()},[g]),_=i.useCallback((M,E)=>{h({type:"connection-error",error:E,provider:M?.provider||(typeof M?.type=="string"?M.type.replace(/-command$/,""):"claude"),sessionId:M?.sessionId||M?.options?.sessionId||null,clientRequestId:M?.clientRequestId||null})},[h]),y=i.useCallback(M=>{M.timeoutId&&(clearTimeout(M.timeoutId),M.timeoutId=null)},[]),C=i.useCallback(M=>{if(M.readyState!==WebSocket.OPEN)return;d.current.splice(0,d.current.length).forEach($=>{y($),M.send(JSON.stringify($.payload))})},[y]),B=i.useCallback(M=>{if(!M||typeof M!="object"||M.clientRequestId)return M;const E=typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`client-${Date.now()}-${Math.random().toString(36).slice(2,10)}`;return{...M,clientRequestId:E}},[]),U=i.useCallback(()=>{if(t.current||l.current)return;const M=e.current;if(!(M&&(M.readyState===WebSocket.OPEN||M.readyState===WebSocket.CONNECTING)))try{const E=tv(f);if(!E){d.current.splice(0,d.current.length).forEach(j=>{y(j),_(j.payload,"No authentication token found for WebSocket connection")});return}l.current=!0;const $=new WebSocket(E);e.current=$,$.onopen=()=>{l.current=!1,a(!0),e.current=$,h({type:"ws-connection-state",state:"connected"}),C($)},$.onmessage=D=>{try{const j=JSON.parse(D.data);h(j)}catch(j){console.error("Error parsing WebSocket message:",j)}},$.onclose=()=>{l.current=!1,a(!1),e.current===$&&(e.current=null),h({type:"ws-connection-state",state:"disconnected"}),c.current=setTimeout(()=>{t.current||U()},3e3)},$.onerror=D=>{console.error("WebSocket error:",D)}}catch(E){l.current=!1,console.error("Error creating WebSocket connection:",E)}},[y,_,C,f]);i.useEffect(()=>(t.current=!1,U(),()=>{l.current=!1,c.current&&clearTimeout(c.current),m.current&&(clearTimeout(m.current),m.current=null),u.current=[],e.current&&(e.current.close(),e.current=null)}),[U,f]),i.useEffect(()=>()=>{t.current=!0,l.current=!1,c.current&&clearTimeout(c.current),m.current&&(clearTimeout(m.current),m.current=null),u.current=[],d.current.splice(0,d.current.length).forEach(E=>y(E)),e.current&&(e.current.close(),e.current=null)},[y]);const Q=i.useCallback(M=>{const E=B(M),$=e.current;if($&&$.readyState===WebSocket.OPEN){try{$.send(JSON.stringify(E))}catch(j){throw j}return}h({type:"ws-connection-state",state:"connecting",sessionId:E?.sessionId||E?.options?.sessionId||null,clientRequestId:E?.clientRequestId||null});const D={payload:E,timeoutId:setTimeout(()=>{d.current=d.current.filter(j=>j!==D),_(E,"Unable to reach the chat server. Message was not sent.")},1e4)};d.current.push(D),U()},[U,_,h,B]);return i.useMemo(()=>({ws:e.current,sendMessage:Q,latestMessage:r,isConnected:s}),[Q,r,s])},rv=({children:e})=>{const t=nv();return n.jsx(pl.Provider,{value:t,children:e})};function ov(){const{t:e}=At("common"),{authenticateLanAccess:t,error:r}=Ps(),[o,s]=i.useState(""),[a,c]=i.useState(!1),l=async d=>{if(d.preventDefault(),!(!o.trim()||a)){c(!0);try{await t(o)}finally{c(!1)}}};return n.jsxs("div",{className:"relative h-dvh overflow-hidden bg-background text-foreground",children:[n.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_top,_hsl(var(--primary)/0.10),_transparent_38%),radial-gradient(circle_at_bottom_right,_hsl(var(--muted-foreground)/0.08),_transparent_30%)]"}),n.jsx("div",{className:"relative flex h-full items-center justify-center overflow-hidden p-4 sm:p-5",children:n.jsxs("div",{className:"w-full max-w-md rounded-[28px] border border-border/70 bg-card/95 p-6 shadow-[0_24px_80px_rgba(15,23,42,0.10)] backdrop-blur-sm",children:[n.jsxs("div",{className:"mb-6 flex items-center gap-3",children:[n.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-2xl bg-primary/10 text-primary",children:n.jsx(qo,{className:"h-6 w-6"})}),n.jsxs("div",{children:[n.jsx("h1",{className:"text-xl font-semibold",children:e("lanAccess.title")}),n.jsx("p",{className:"text-sm text-muted-foreground",children:e("lanAccess.subtitle")})]})]}),n.jsxs("form",{className:"space-y-4",onSubmit:l,children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx("label",{className:"text-sm font-medium text-foreground",htmlFor:"lan-access-password",children:e("lanAccess.placeholder")}),n.jsxs("div",{className:"relative",children:[n.jsx(Cu,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),n.jsx(bn,{id:"lan-access-password",type:"password",value:o,onChange:d=>s(d.target.value),placeholder:e("lanAccess.placeholder"),className:"h-12 rounded-2xl border-border bg-background pl-10 text-foreground placeholder:text-muted-foreground"})]})]}),r?n.jsx("div",{className:"rounded-2xl border border-destructive/20 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:r}):n.jsx("div",{className:"rounded-2xl border border-border/70 bg-muted/40 px-3 py-2 text-sm text-muted-foreground",children:e("lanAccess.hint")}),n.jsx(Ie,{className:"h-12 w-full rounded-2xl text-base font-medium",disabled:a,children:e(a?"lanAccess.submitting":"lanAccess.submit")})]})]})})]})}const sv=()=>n.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:n.jsxs("div",{className:"text-center",children:[n.jsx("div",{className:"flex justify-center mb-4",children:n.jsx("img",{src:"/logo-128.png",alt:"Logo",className:"w-16 h-16 rounded-lg shadow-sm"})}),n.jsx("h1",{className:"text-2xl font-bold text-foreground mb-2",children:"Axhub Genie"}),n.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[n.jsx("div",{className:"w-2 h-2 bg-primary rounded-full animate-bounce"}),n.jsx("div",{className:"w-2 h-2 bg-primary rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),n.jsx("div",{className:"w-2 h-2 bg-primary rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]}),n.jsx("p",{className:"text-muted-foreground mt-2",children:"Loading..."})]})}),av=({children:e})=>{const{user:t,isLoading:r}=Ps();return r?n.jsx(sv,{}):t?e:n.jsx(ov,{})};function Qn(e,t){const[r,o]=i.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[r,a=>{if(!(typeof window>"u"))try{const c=a instanceof Function?a(r):a;window.localStorage.setItem(e,JSON.stringify(c)),o(c)}catch(c){console.log(c)}}]}const iv=3e3;function Zn(e){return typeof e=="string"&&e.trim().length>0}function cv(e="integration"){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${e}_${crypto.randomUUID()}`:`${e}_${Date.now()}_${Math.random().toString(36).slice(2,10)}`}function lv(){return typeof window>"u"?null:`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/agent/ws`}function dv({enabled:e,channel:t,clientId:r,sessionId:o}){const s=i.useRef(null),a=i.useRef(null),c=i.useRef(!1),l=i.useRef(!1),d=i.useRef(0),u=i.useRef(Zn(o)?o.trim():null),[m,p]=i.useState(null),[f,g]=i.useState(!1),h=i.useMemo(()=>e===!0&&Zn(t)&&Zn(r),[e,t,r]);i.useEffect(()=>{u.current=Zn(o)?o.trim():null},[o]);const _=i.useCallback(F=>{d.current+=1,p({...F,__messageSeq:d.current})},[]),y=i.useCallback(()=>{const F=s.current;F&&(F.close(),s.current=null),g(!1),c.current=!1},[]),C=i.useCallback((F,M=s.current)=>!F||!M||M.readyState!==WebSocket.OPEN?!1:(M.send(JSON.stringify({type:"integration.ack",requestId:F,payload:{accepted:!0,available:!0,pageUrl:typeof window<"u"?window.location.href:null,sessionId:u.current}})),!0),[]),B=i.useCallback((F=s.current)=>{!h||!F||F.readyState!==WebSocket.OPEN||F.send(JSON.stringify({type:"integration.connect",requestId:cv("integration_connect"),payload:{role:"frontend-page",channel:t.trim(),clientId:r.trim(),pageUrl:typeof window<"u"?window.location.href:null,sessionId:Zn(o)?o.trim():null,capabilities:["context.update","prompt.update","presence.report"]}}))},[t,r,h,o]),U=i.useCallback(()=>{if(!h||l.current||c.current)return;const F=s.current;if(F&&(F.readyState===WebSocket.OPEN||F.readyState===WebSocket.CONNECTING))return;const M=lv();if(!M)return;c.current=!0;const E=new WebSocket(M);s.current=E,E.onopen=()=>{c.current=!1,s.current=E,g(!0),B(E)},E.onmessage=$=>{try{const D=JSON.parse($.data);D&&typeof D.type=="string"&&D.type.startsWith("integration.")&&(D.type==="integration.ping"&&C(D.requestId||null,E),_(D))}catch(D){console.error("Error parsing integration WebSocket message:",D)}},E.onclose=()=>{s.current===E&&(s.current=null),c.current=!1,g(!1),!l.current&&h&&(a.current=setTimeout(()=>{a.current=null,U()},iv))},E.onerror=$=>{console.error("Integration WebSocket error:",$)}},[B,_,h,C]);i.useEffect(()=>{if(l.current=!1,!h){a.current&&(clearTimeout(a.current),a.current=null),y();return}return U(),()=>{a.current&&(clearTimeout(a.current),a.current=null),y()}},[y,U,h]),i.useEffect(()=>()=>{l.current=!0,a.current&&(clearTimeout(a.current),a.current=null),y()},[y]),i.useEffect(()=>{h&&B()},[B,h,o]);const Q=i.useCallback(F=>{const M=s.current;return!M||M.readyState!==WebSocket.OPEN?!1:(M.send(JSON.stringify(F)),!0)},[]);return{integrationWs:s.current,latestIntegrationMessage:m,sendIntegrationMessage:Q,isIntegrationConnected:f,isIntegrationEnabled:h}}const uv=["cwd","workdir","project","context","prompt","model","integrationWs"];function pv(e){return e instanceof URLSearchParams?e:typeof e=="string"?new URLSearchParams(e):new URLSearchParams}function ms(e,t,r={},o={}){const s=typeof e=="string"&&e?e:"/",a=pv(t),c=new URLSearchParams,l=Array.isArray(o?.persistedKeys)&&o.persistedKeys.length>0?o.persistedKeys:uv;for(const u of l){const m=a.get(u);m&&c.set(u,m)}for(const[u,m]of Object.entries(r||{})){if(m==null||m===""){c.delete(u);continue}c.set(u,String(m))}const d=c.toString();return d?`${s}?${d}`:s}const mv="axhub",Za="axhub-genie.integrationClientId";function ml(e){return typeof e=="string"&&e.trim().length>0}function ei(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`frontend-${crypto.randomUUID()}`:`frontend-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function fv(e,t){return e!=="1"?null:ml(t)?t.trim():mv}function hv(e,t=null){if(e!=="1")return null;const r=t&&typeof t.getItem=="function"&&typeof t.setItem=="function"?t:null;if(!r)return ei();const o=r.getItem(Za);if(ml(o))return o.trim();const s=ei();return r.setItem(Za,s),s}function xv(){if(typeof window>"u")return null;try{return window.sessionStorage}catch{return null}}const gv=new Set(["claude","codex","gemini","opencode"]);function Rs(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();if(!t)return null;const r=t==="openai"?"codex":t;return gv.has(r)?r:null}function fl({provider:e,sessionId:t}){const r=Rs(e),o=typeof t=="string"&&t.trim()?t.trim():"";return!r||!o?null:`/session/${r}/${encodeURIComponent(o)}`}function ti(e,t){const r=fl(e);if(!r)return null;const o=e?.projectPath||e?.cwd||e?.project||null;return ms(r,t,o?{cwd:o,project:o}:{})}function vv({isMobile:e,currentProjectName:t,sessionProjectName:r}){return e?r!==t:!1}function yv({isLoadingProjects:e,hasSelectedProject:t,hasSessionRoute:r,sessionRouteStatus:o}){return t?!1:e?!0:!!(r&&o!=="missing"&&o!=="error")}function bv({requestToken:e,activeRequestToken:t,pathname:r,provider:o,sessionId:s}){if(!e||!t||e!==t||typeof r!="string"||typeof s!="string"||!s)return!1;const a=fl({provider:Rs(o),sessionId:s});return!!(a&&r===a)}function wv({activeResolution:e,sessionId:t,resolutionKey:r}){return!e||typeof e!="object"?!0:!(e.sessionId===t&&e.status==="resolving"&&e.resolutionKey===r)}const ni="lastSelectedProject",ri="lastSelectedSession";function kv(e){return!e||typeof e!="object"?[]:[...e.sessions||[],...e.codexSessions||[],...e.geminiSessions||[],...e.opencodeSessions||[]]}function hl(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 oi(e,t=null){const r=!!t?.detailsLoaded;return{...e,detailsLoaded:r,sessions:r?t?.sessions||[]:[],codexSessions:r?t?.codexSessions||[]:[],geminiSessions:r?t?.geminiSessions||[]:[],opencodeSessions:r?t?.opencodeSessions||[]:[],sessionMeta:r?t?.sessionMeta||{hasMore:!1,total:0}:null}}function si(e,t){const r=new Map(e.map(a=>[a.name,a])),o=t.map(a=>{const c=r.get(a.name);return c?hl(c,a)?oi(a,c):c:oi(a)});return o.length!==e.length||o.some((a,c)=>a!==e[c])?o:e}function jv(e,t){let r=!1;const o=e.map(s=>s.name!==t.name?s:(r=!0,{...s,...t,sessions:t.sessions||[],codexSessions:t.codexSessions||[],geminiSessions:t.geminiSessions||[],opencodeSessions:t.opencodeSessions||[],sessionMeta:t.sessionMeta||{hasMore:!1,total:0},detailsLoaded:!0}));return r?o:e}function Sv(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 Nv(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 ai(){const e=rd(),t=od(),{provider:r,sessionId:o}=sd(),[s]=ad(),{t:a}=At("common");i.useRef(0);const{updateAvailable:c,latestVersion:l,currentVersion:d,releaseInfo:u}=dl(),[m,p]=i.useState(!1),[f,g]=i.useState([]),[h,_]=i.useState(null),[y,C]=i.useState(null),[B,U]=i.useState({}),[Q,F]=i.useState(0),[M,E]=i.useState("chat"),[$,D]=i.useState(!1),j=$&&!1,[le,te]=i.useState(!1),[X,Z]=i.useState(!0),[ae,re]=i.useState(null),[de,ie]=i.useState(!1),[q,ye]=i.useState(!1),[fe,Te]=i.useState("appearance"),[ee]=Qn("autoExpandTools",!1),[J]=Qn("showRawParameters",!1),[be]=Qn("showThinking",!0),Ce=!1,[ke]=Qn("sendByCtrlEnter",!1),[he,Xe]=Qn("sidebarVisible",!0),[De,_e]=i.useState(!1),[qe,Ee]=i.useState(new Set),[We,Ue]=i.useState(new Set),Re=i.useRef({sessionId:null,status:"idle"}),at=i.useRef(0),[nt,Ke]=i.useState("idle"),Fe=i.useCallback((k,O="claude")=>{if(!k)return O;try{const G=localStorage.getItem("session-provider-map");if(!G)return O;const Ne=JSON.parse(G)?.[k];return typeof Ne=="string"&&Ne?Ne:O}catch{return O}},[]),[it,ze]=i.useState(0),rt=i.useRef({selectionKey:null}),N=i.useRef({attemptedKeys:new Set}),L=i.useRef(f),ue=i.useRef(h),pe=i.useRef(y),b=s.get("cwd")||s.get("workdir"),T=i.useMemo(()=>Rn(b),[b]),A=s.get("project")||s.get("projectName"),W=i.useMemo(()=>Rs(r),[r]);s.get("model");const H=s.get("context"),xe=s.get("prompt"),me=s.get("integrationWs"),Je=i.useMemo(()=>xv(),[]),ge=i.useMemo(()=>hv(me,Je),[Je,me]),Le=i.useMemo(()=>fv(me,b),[b,me]),tt=s.toString(),Nt=f.find(k=>!!(rr(k,T)||A&&(k.fullPath===A||k.path===A)))?.name||null,Ct=(k,O)=>!k||!O?k!==O:hl(k,O)||!!k.detailsLoaded!=!!O.detailsLoaded,vt=k=>{if(!k)return!1;if(o===k)return!0;const O=Re.current;return O?.sessionId===k&&O?.status!=="missing"&&O?.status!=="error"?!0:qe.has(k)||We.has(k)},v=i.useCallback(k=>{if(!k?.name)return;const O=ue.current,G=pe.current;if(O?.name===k.name&&O!==k&&(Ct(O,k)||!O.detailsLoaded&&k.detailsLoaded)&&_(k),!G||G.__projectName!==k.name||!k.detailsLoaded)return;const Se=kv(k).find(ne=>ne.id===G.id);if(!Se){vt(G.id)||C(null);return}const Ne={...Se,__provider:G.__provider||Fe(Se.id,"claude"),__projectName:k.name};(Ne.title!==G.title||Ne.summary!==G.summary||Ne.updated_at!==G.updated_at||Ne.lastActivity!==G.lastActivity||Ne.__provider!==G.__provider||Ne.__projectName!==G.__projectName)&&C(Ne)},[Fe,vt]),w=i.useCallback(async(k,O={})=>{const{background:G=!1,force:Se=!1}=O;if(!k)return null;const Ne=L.current.find(ne=>ne.name===k);if(!Se&&Ne?.detailsLoaded)return Ne;if(B[k])return null;U(ne=>({...ne,[k]:!0}));try{const ne=await Ze.projectDetails(k);if(!ne.ok){if(ne.status===404)return g(Tt=>Tt.filter(et=>et.name!==k)),null;throw new Error(`Failed to load project details: ${ne.status}`)}const ot=await ne.json();g(Tt=>jv(Tt,ot));const Bt={...Ne,...ot,detailsLoaded:!0};return v(Bt),Bt}catch(ne){return console.error(`Error loading details for project ${k}:`,ne),null}finally{U(ne=>{const ot={...ne};return delete ot[k],ot})}},[B,v]),V=i.useCallback(async(k={})=>{const{background:O=!1}=k;try{O||Z(!0);const Se=await(await Ze.projectsList()).json();g(Ne=>si(Ne,Se))}catch(G){console.error("Error fetching projects:",G)}finally{O||Z(!1)}},[]),je=i.useCallback((k,O)=>{const G=ms(k,s);t(G,O)},[t,s]),R=i.useCallback(k=>{const O=ms("/",s,{},{persistedKeys:["integrationWs"]});t(O,k)},[t,s]),Y=i.useCallback((k,O)=>{const G=ti(k,s);return G?(t(G,O),!0):(console.warn("Skipping session navigation because provider or session id is missing.",k),!1)},[t,s]),oe=i.useCallback(()=>{at.current+=1,Re.current={sessionId:null,status:"idle"},Ke("idle")},[]),{ws:Be,sendMessage:Ye,latestMessage:$e}=ev(),{latestIntegrationMessage:yt,sendIntegrationMessage:Ve}=dv({enabled:me==="1",clientId:ge,channel:Le,sessionId:y?.id||o||null}),pt=i.useCallback(k=>tr(k),[]),mt=i.useRef(null),[S,ve]=i.useState(!1);i.useEffect(()=>{const k=cl(M);k!==M&&E(k)},[M]),i.useEffect(()=>{const k=()=>{const O=window.matchMedia("(display-mode: standalone)").matches||window.navigator.standalone||document.referrer.includes("android-app://");ve(O),document.addEventListener("touchstart",{}),O?(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 k(),window.matchMedia("(display-mode: standalone)").addEventListener("change",k),()=>{window.matchMedia("(display-mode: standalone)").removeEventListener("change",k)}},[]),i.useEffect(()=>{const k=()=>{D(window.innerWidth<768)};return k(),window.addEventListener("resize",k),()=>window.removeEventListener("resize",k)},[]),i.useEffect(()=>{V()},[V]),i.useEffect(()=>{o||oe()},[oe,o]),i.useEffect(()=>{L.current=f},[f]),i.useEffect(()=>{ue.current=h},[h]),i.useEffect(()=>{pe.current=y},[y]),i.useEffect(()=>{try{const k=Sv(h);k?localStorage.setItem(ni,JSON.stringify(k)):localStorage.removeItem(ni);const O=Nv(y);O?localStorage.setItem(ri,JSON.stringify(O)):localStorage.removeItem(ri)}catch(k){console.warn("Failed to persist last selected project/session:",k)}},[h,y]),i.useEffect(()=>{if(!T&&!A||f.length===0)return;const k=`${T||""}::${A||""}`;if(rt.current.selectionKey===k)return;if(y){rt.current.selectionKey=k;return}let O=null;if(T&&(O=f.find(G=>rr(G,T))),!O&&A){const G=A.trim().toLowerCase();O=f.find(Se=>[Se.name,Se.displayName,Se.path,Se.fullPath].some(ne=>typeof ne=="string"&&ne.toLowerCase()===G))}O&&_(O),rt.current.selectionKey=k},[T,A,f,y]),i.useEffect(()=>{if(!h?.name||f.length===0)return;const k=f.find(O=>O.name===h.name);if(!k){!o&&!T&&!A&&(_(null),y?.__projectName===h.name&&C(null));return}k!==h&&Ct(h,k)&&_(k),!k.detailsLoaded&&!B[k.name]&&w(k.name,{background:!0})},[w,T,B,f,A,h,y?.__projectName,o]),i.useEffect(()=>{if(!T||X||y||L.current.some(Ne=>rr(Ne,T)))return;const O=`cwd:${T}`;if(N.current.attemptedKeys.has(O))return;N.current.attemptedKeys.add(O);let G=!1;return(async()=>{try{const Ne=await Ze.createProject(T),ne=await Ne.json().catch(()=>({}));if(!Ne.ok){const ot=ne?.error||"Unknown error";if(ot.includes("Project already configured")){await V();return}console.warn(`[URL] Failed to auto-create project for cwd "${T}": ${ot}`);return}if(G)return;ne?.project&&_(ne.project),await V()}catch(Ne){console.error(`[URL] Error auto-creating project for cwd "${T}":`,Ne)}})(),()=>{G=!0}},[T,X,y]),i.useEffect(()=>{if($e){if($e.type==="loading_progress"){mt.current&&(clearTimeout(mt.current),mt.current=null),re($e),$e.phase==="complete"&&(mt.current=setTimeout(()=>{re(null),mt.current=null},500));return}if($e.type==="projects_updated"){if($e.changedFile&&y&&h){const Vt=$e.changedFile.replace(/\\/g,"/").split("/"),st=Vt[Vt.length-1]||"",ht=st.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]||st.replace(".jsonl","");($e.changedSessionId||ht)===y.id&&(qe.has(y.id)||ze(jn=>jn+1))}const k=Array.isArray($e.projects)?$e.projects:[];g(et=>si(et,k));const O=ue.current,G=pe.current,Se=O?k.find(et=>et.name===O.name):null;if(O&&!Se&&!vt(G?.id)){_(null),C(null);return}const Ne=G&&qe.has(G.id)||qe.size>0&&Array.from(qe).some(et=>tr(et)),ne=$e.affectedProjectName||null;if(!!!((ne?L.current.find(et=>et.name===ne&&et.detailsLoaded):null)&&$e.requiresDetailsRefresh))return;const Tt=O?.name===ne;if(Ne&&Tt)return;w(ne,{background:!0,force:!0})}}return()=>{mt.current&&(clearTimeout(mt.current),mt.current=null)}},[qe,$e,w,We,h,y,o,vt]),window.refreshProjects=(k={})=>V({background:!0,...k}),window.openSettings=i.useCallback((k="appearance")=>{Te(k),ye(!0)},[]),i.useEffect(()=>{if(!o)return;const k=y?.id||null,O=k!==o;if(!W){Re.current={sessionId:o,status:"error"},Ke("error");return}const G=`${o}::${tt}`,Se=pt(o),Ne=Mc({projects:f,queryProject:A,queryCwd:T}),ne=(st,ht,tn)=>{if(!st||!ht)return!1;const Ft=f.find(kt=>kt.name===st.name)||st,nn={...ht,__provider:tn||W,__projectName:Ft.name};return _(kt=>kt?.name===Ft.name?kt:Ft),C(kt=>kt?.id===nn.id&&kt?.__provider===nn.__provider&&kt?.__projectName===nn.__projectName?kt:nn),w(Ft.name,{background:!0}),O&&E("chat"),Re.current={sessionId:o,status:"resolved",resolutionKey:G},Ke("resolved"),!0};if(k===o&&h?.name&&(!y?.__provider||y.__provider===W)){Re.current={sessionId:o,status:"resolved",resolutionKey:G},Ke("resolved"),O&&E("chat");return}const ot=Zh(f,o,{provider:W,projectPath:A||T||null});if(ot){ne(ot.project,ot.session,ot.provider);return}if(ex({projects:f,queryProject:A,queryCwd:T})){Ne?.name&&!B[Ne.name]&&w(Ne.name,{background:!0}),Re.current={sessionId:o,status:"awaiting-project-details",resolutionKey:G},Ke("awaiting-project-details");return}const Bt=Ne;if(Bt?(_(st=>st?.name===Bt.name?st:Bt),C({id:o,title:"New Session",created_at:new Date().toISOString(),updated_at:new Date().toISOString(),__provider:W,__projectName:Bt.name}),O&&E("chat"),Re.current={sessionId:o,status:"placeholder",resolutionKey:G},Ke("placeholder")):(_(null),C(null)),Se||Re.current.sessionId===o&&Re.current.status==="resolving"&&Re.current.resolutionKey===G)return;const Tt=at.current+1;at.current=Tt,Re.current={sessionId:o,status:"resolving",resolutionKey:G},Ke("resolving");let et=!1;return(async()=>{try{const st=await Ze.resolveSession(W,o),ht=await st.json().catch(()=>({}));if(et||!bv({requestToken:Tt,activeRequestToken:at.current,pathname:e.pathname,provider:W,sessionId:o}))return;if(!st.ok||!ht?.found||!ht?.project||!ht?.session){Re.current={sessionId:o,status:"missing",resolutionKey:G},Ke("missing");return}if(ht?.provider)try{const nn=localStorage.getItem("session-provider-map"),kt=nn?JSON.parse(nn):{};kt[o]=ht.provider,localStorage.setItem("session-provider-map",JSON.stringify(kt))}catch{}if(!ne(ht.project,ht.session,ht.provider||W))return;const Ft=ti({provider:ht.provider||W,sessionId:o},s),jn=`${window.location.pathname}${window.location.search}`;Ft&&Ft!==jn&&t(Ft,{replace:!0})}catch(st){et||(console.error("Error resolving session route:",st),Re.current={sessionId:o,status:"error",resolutionKey:G},Ke("error"))}})(),()=>{wv({activeResolution:Re.current,sessionId:o,resolutionKey:G})&&(et=!0)}},[pt,w,e.pathname,t,T,B,f,A,W,s,tt,y?.id,o]);const Me=k=>{oe(),_(k),C(null),w(k.name,{background:!0}),R()},Ae=k=>{oe();let O=null;k.__projectName&&(O=L.current.find(G=>G.name===k.__projectName)||null,O&&_(O)),C(k),M!=="preview"&&E("chat"),vv({isMobile:$,sessionProjectName:k.__projectName,currentProjectName:h?.name})&&te(!1),Y({provider:k.__provider||k.provider||null,sessionId:k.id})},Qe=k=>{if(oe(),k?.name&&typeof window<"u")try{localStorage.removeItem(`chat_messages_${k.name}`),localStorage.removeItem(`draft_input_${k.name}`)}catch(O){console.warn("Failed to clear local chat cache for new session:",O)}_(k),C(null),F(O=>O+1),E("chat"),R(),$&&te(!1)},Et=k=>{y?.id===k&&(oe(),C(null),je("/")),g(O=>O.map(G=>({...G,sessions:G.sessions?.filter(Se=>Se.id!==k)||[],codexSessions:G.codexSessions?.filter(Se=>Se.id!==k)||[],geminiSessions:G.geminiSessions?.filter(Se=>Se.id!==k)||[],opencodeSessions:G.opencodeSessions?.filter(Se=>Se.id!==k)||[],sessionMeta:G.sessionMeta?{...G.sessionMeta,total:Math.max(0,(G.sessionMeta?.total||0)-1)}:G.sessionMeta})))},zt=async()=>{try{await V({background:!0});const k=Array.from(new Set([...L.current.filter(O=>O.detailsLoaded).map(O=>O.name),ue.current?.name||null].filter(Boolean)));await Promise.all(k.map(O=>w(O,{background:!0,force:!0})))}catch(k){console.error("Error refreshing sidebar:",k)}},lt=k=>{h?.name===k&&(oe(),_(null),C(null),je("/")),g(O=>O.filter(G=>G.name!==k))},Zt=i.useCallback((k,O)=>{g(G=>G.map(Se=>Se.name===k?{...Se,displayName:O,isCustomName:!0}:Se)),_(G=>!G||G.name!==k?G:{...G,displayName:O,isCustomName:!0})},[]),en=i.useCallback(k=>{k&&Ee(O=>new Set([...O,k]))},[]),K=i.useCallback(k=>{k&&Ee(O=>{const G=new Set(O);return G.delete(k),G})},[]),Lt=i.useCallback(k=>{k&&Ue(O=>new Set([...O,k]))},[]),Ot=i.useCallback(k=>{k&&Ue(O=>{const G=new Set(O);return G.delete(k),G})},[]),qt=i.useCallback((k,O=null)=>{k&&(Ee(G=>{const Se=new Set;for(const Ne of G)O&&Ne===O||tr(Ne)||Se.add(Ne);return Se.add(k),Se}),Ue(G=>{const Se=new Set;for(const Ne of G)O&&Ne===O||tr(Ne)||Se.add(Ne);return Se.add(k),Se}))},[]),pn=()=>{const{t:k}=At("common"),[O,G]=i.useState(!1),[Se,Ne]=i.useState(""),[ne,ot]=i.useState("");if(!m)return null;const Bt=et=>et?et.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,`
254
+
255
+ `).trim():"",Tt=async()=>{G(!0),Ne(`Starting update...
256
+ `),ot("");try{const et=await Kt("/api/system/update",{method:"POST"}),Vt=await et.json();et.ok?(Ne(st=>st+Vt.output+`
257
+ `),Ne(st=>st+`
258
+ ✅ Update completed successfully!
259
+ `),Ne(st=>st+`Please restart the server to apply changes.
260
+ `)):(ot(Vt.error||"Update failed"),Ne(st=>st+`
261
+ ❌ Update failed: `+(Vt.error||"Unknown error")+`
262
+ `))}catch(et){ot(et.message),Ne(Vt=>Vt+`
263
+ ❌ Update failed: `+et.message+`
264
+ `)}finally{G(!1)}};return n.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[n.jsx("button",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>p(!1),"aria-label":k("versionUpdate.ariaLabels.closeModal")}),n.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:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-10 h-10 bg-primary/15 dark:bg-primary/25 rounded-lg flex items-center justify-center",children:n.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.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"})})}),n.jsxs("div",{children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:k("versionUpdate.title")}),n.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:u?.title||k("versionUpdate.newVersionReady")})]})]}),n.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:n.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex justify-between items-center p-3 bg-gray-50 dark:bg-gray-700/50 rounded-lg",children:[n.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:k("versionUpdate.currentVersion")}),n.jsx("span",{className:"text-sm text-gray-900 dark:text-white font-mono",children:d})]}),n.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:[n.jsx("span",{className:"text-sm font-medium text-primary",children:k("versionUpdate.latestVersion")}),n.jsx("span",{className:"text-sm text-primary font-mono",children:l})]})]}),u?.body&&n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:k("versionUpdate.whatsNew")}),u?.htmlUrl&&n.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:[k("versionUpdate.viewFullRelease"),n.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.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"})})]})]}),n.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:n.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:Bt(u.body)})})]}),Se&&n.jsxs("div",{className:"space-y-2",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:k("versionUpdate.updateProgress")}),n.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:n.jsx("pre",{className:"text-xs text-green-400 font-mono whitespace-pre-wrap",children:Se})})]}),!O&&!Se&&n.jsxs("div",{className:"space-y-3",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:k("versionUpdate.manualUpgrade")}),n.jsx("div",{className:"bg-gray-100 dark:bg-gray-800 rounded-lg p-3 border",children:n.jsx("code",{className:"text-sm text-gray-800 dark:text-gray-200 font-mono",children:"npm install -g @axhub/genie@latest"})}),n.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:k("versionUpdate.manualUpgradeHint")})]}),n.jsxs("div",{className:"flex gap-2 pt-2",children:[n.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:k(Se?"versionUpdate.buttons.close":"versionUpdate.buttons.later")}),!Se&&n.jsxs(n.Fragment,{children:[n.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:k("versionUpdate.buttons.copyCommand")}),n.jsx("button",{onClick:Tt,disabled:O,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:O?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),k("versionUpdate.buttons.updating")]}):k("versionUpdate.buttons.updateNow")})]})]})]})]})};return n.jsxs("div",{className:"chat-app-shell fixed inset-0 flex overflow-hidden bg-background",style:{"--mobile-nav-total":"0px"},children:[!$&&n.jsx("div",{className:`chat-sidebar h-full flex-shrink-0 overflow-hidden transition-all duration-300 ${he?"w-[22rem]":"w-[4.25rem]"}`,children:n.jsx("div",{className:"h-full overflow-hidden",children:he?n.jsx(ca,{projects:f,selectedProject:h,selectedSession:y,onProjectSelect:Me,onProjectRename:Zt,onSessionSelect:Ae,onNewSession:Qe,onSessionDelete:Et,onProjectDelete:lt,isLoading:X,projectDetailsLoading:B,loadingProgress:ae,onProjectExpand:w,onRefresh:zt,onShowSettings:()=>ye(!0),updateAvailable:c,latestVersion:l,currentVersion:d,releaseInfo:u,onShowVersionModal:()=>p(!0),isPWA:S,isMobile:$,onToggleSidebar:()=>Xe(!1),lockedProjectName:Nt,showNewProject:De,setShowNewProject:_e}):n.jsxs("div",{className:"h-full flex flex-col items-center gap-3 py-4",children:[n.jsx("button",{onClick:()=>Xe(!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:n.jsx(hi,{className:"w-4 h-4 text-foreground"})}),c&&n.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:[n.jsx(Vd,{className:"w-5 h-5 text-primary"}),n.jsx("span",{className:"absolute top-1 right-1 w-2 h-2 bg-primary rounded-full animate-pulse"})]})]})})}),$&&n.jsxs("div",{className:`fixed inset-0 z-50 flex transition-all duration-150 ease-out ${le?"opacity-100 visible":"opacity-0 invisible"}`,children:[n.jsx("button",{className:"fixed inset-0 bg-black/40 transition-opacity duration-150 ease-out",onClick:k=>{k.stopPropagation(),te(!1)},onTouchStart:k=>{k.preventDefault(),k.stopPropagation(),te(!1)},"aria-label":a("versionUpdate.ariaLabels.closeSidebar")}),n.jsx("div",{className:`chat-sidebar relative h-full w-[85vw] max-w-sm bg-white shadow-xl transform dark:bg-background sm:w-80 ${le?"translate-x-0":"-translate-x-full"}`,onClick:k=>k.stopPropagation(),onTouchStart:k=>k.stopPropagation(),children:n.jsx(ca,{projects:f,selectedProject:h,selectedSession:y,onProjectSelect:Me,onProjectRename:Zt,onSessionSelect:Ae,onNewSession:Qe,onSessionDelete:Et,onProjectDelete:lt,isLoading:X,projectDetailsLoading:B,loadingProgress:ae,onProjectExpand:w,onRefresh:zt,onShowSettings:()=>ye(!0),updateAvailable:c,latestVersion:l,currentVersion:d,releaseInfo:u,onShowVersionModal:()=>p(!0),isPWA:S,isMobile:$,onToggleSidebar:()=>Xe(!1),lockedProjectName:Nt,showNewProject:De,setShowNewProject:_e})})]}),n.jsx("div",{className:"chat-shell flex-1 flex min-w-0 flex-col overflow-hidden ",children:n.jsx(U0,{selectedProject:h,selectedSession:y,activeTab:M,setActiveTab:E,ws:Be,sendMessage:Ye,latestMessage:$e,isMobile:$,isPWA:S,onMenuClick:()=>te(!0),isLoading:yv({isLoadingProjects:X,hasSelectedProject:!!h,hasSessionRoute:!!o,sessionRouteStatus:nt}),onInputFocusChange:ie,onSessionActive:en,onSessionInactive:K,onSessionProcessing:Lt,onSessionNotProcessing:Ot,processingSessions:We,onReplaceTemporarySession:qt,onNavigateToSession:(k,O=null,G=null)=>{const Se=O||pe.current?.__provider||localStorage.getItem("selected-provider")||"claude",Ne=G||h?.fullPath||h?.path||null,ne=h?.name||null;C(ot=>ot?.id===k&&ot?.__provider===Se&&ot?.__projectName===ne?ot:{id:k,title:ot?.title||"New Session",created_at:ot?.created_at||new Date().toISOString(),updated_at:new Date().toISOString(),__provider:Se,__projectName:ne,projectPath:Ne}),Y({provider:Se,sessionId:k,projectPath:Ne})},onShowSettings:()=>ye(!0),autoExpandTools:ee,showRawParameters:J,showThinking:be,autoScrollToBottom:Ce,sendByCtrlEnter:ke,externalMessageUpdate:it,urlContext:H,urlPrompt:xe,integrationClientId:ge,latestIntegrationMessage:yt,sendIntegrationMessage:Ve,onShowNewProject:()=>_e(!0),onNewSession:Qe,newSessionResetNonce:Q})}),j,n.jsx(X0,{isOpen:q,onClose:()=>ye(!1),projects:f,initialTab:fe}),n.jsx(pn,{})]})}function Dv(){return n.jsx(Wd,{i18n:Yd,children:n.jsx(Kd,{children:n.jsx(Z0,{children:n.jsx(rv,{children:n.jsx(av,{children:n.jsx(td,{basename:window.__ROUTER_BASENAME__||"",children:n.jsxs(nd,{children:[n.jsx(yo,{path:"/",element:n.jsx(ai,{})}),n.jsx(yo,{path:"/session/:provider/:sessionId",element:n.jsx(ai,{})}),n.jsx(yo,{path:"/review",element:n.jsx(qd,{})})]})})})})})})})}export{Dv as default};