orc-ai 0.1.40 → 0.1.41

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 (101) hide show
  1. package/dist/index.js +470 -455
  2. package/dist/web/assets/{Agents-KNRLNcpI.js → Agents-1lX_DRrR.js} +1 -1
  3. package/dist/web/assets/{Audit-ngeaHJiy.js → Audit-DnRP9Ivm.js} +1 -1
  4. package/dist/web/assets/{Dashboard-3F8aWN_d.js → Dashboard-bT5SABu_.js} +1 -1
  5. package/dist/web/assets/{DocumentWorkspace-VHzjE2ih.js → DocumentWorkspace-BI4JWVsO.js} +1 -1
  6. package/dist/web/assets/{FileEditor-DijNrJWf.js → FileEditor-Cb8uXr6e.js} +1 -1
  7. package/dist/web/assets/{JobWebhooks-BtzsOTHL.js → JobWebhooks-CYE2UA0V.js} +1 -1
  8. package/dist/web/assets/{Jobs-DmkPxHxP.js → Jobs-Fyd46CkI.js} +1 -1
  9. package/dist/web/assets/{Knowledge-R_6uAqDE.js → Knowledge-prZWODFP.js} +7 -7
  10. package/dist/web/assets/{PackageCatalog-CkZgscbx.js → PackageCatalog-R8kcGP28.js} +4 -4
  11. package/dist/web/assets/{Pager-DjrHsuOJ.js → Pager-urh4-P2a.js} +1 -1
  12. package/dist/web/assets/{Rules-BEzXQ7L5.js → Rules-if9ZzABl.js} +1 -1
  13. package/dist/web/assets/Sessions-AfC-wZoj.js +5 -0
  14. package/dist/web/assets/{Settings-O3qQRgTI.js → Settings-CNPE54fO.js} +3 -3
  15. package/dist/web/assets/{Skills-B3R-l8Ou.js → Skills-BJcE6uiQ.js} +1 -1
  16. package/dist/web/assets/{SourceEditor-CHubUpaP.js → SourceEditor-a2_IdCoT.js} +3 -3
  17. package/dist/web/assets/{Tasks-DF9FqHDq.js → Tasks-COQCj4HF.js} +1 -1
  18. package/dist/web/assets/Terminals-D4K_u_ch.js +115 -0
  19. package/dist/web/assets/{Webhooks-DW7d9R_t.js → Webhooks-DvsCfbZY.js} +1 -1
  20. package/dist/web/assets/{abnfDiagram-VCTEODGH-BVZ_t6ts.js → abnfDiagram-VCTEODGH-C1g9AmGT.js} +1 -1
  21. package/dist/web/assets/{arc-Bp1Q5GVT.js → arc-BX1-afFK.js} +1 -1
  22. package/dist/web/assets/{architectureDiagram-5GKGNRK7-Cw_Fh8Fr.js → architectureDiagram-5GKGNRK7-DTDe767x.js} +2 -2
  23. package/dist/web/assets/{blockDiagram-I7D4REHJ-C9qLtS_w.js → blockDiagram-I7D4REHJ-DJnvrUZM.js} +1 -1
  24. package/dist/web/assets/{c4Diagram-7LVT6UL2-k3kt69iB.js → c4Diagram-7LVT6UL2-rpXv4dc9.js} +1 -1
  25. package/dist/web/assets/channel-DsRXlXQz.js +1 -0
  26. package/dist/web/assets/{chunk-2Q5K7J3B-DVLrwP2r.js → chunk-2Q5K7J3B-BEq6zYAO.js} +1 -1
  27. package/dist/web/assets/{chunk-5VM5RSS4-D3tEfTaL.js → chunk-5VM5RSS4-kAS1IBM0.js} +1 -1
  28. package/dist/web/assets/{chunk-F27PBJKO-DfkCzGL9.js → chunk-F27PBJKO-BtG5IndH.js} +1 -1
  29. package/dist/web/assets/{chunk-IMKFNOWR-yN65S3YD.js → chunk-IMKFNOWR-C-NO8OSz.js} +1 -1
  30. package/dist/web/assets/{chunk-JWPE2WC7-ByQ6NS99.js → chunk-JWPE2WC7-2IhqyMft.js} +1 -1
  31. package/dist/web/assets/{chunk-POPQ4Y6H-CHRLyTiT.js → chunk-POPQ4Y6H-DmxK4niw.js} +1 -1
  32. package/dist/web/assets/{chunk-SVP7TREG-DvLoUZ9h.js → chunk-SVP7TREG-BkVeMS09.js} +1 -1
  33. package/dist/web/assets/{chunk-TICWLB2K-BvzbxDY6.js → chunk-TICWLB2K-DzlMwg1V.js} +1 -1
  34. package/dist/web/assets/{chunk-XXDRQBXY-DkfEU2XD.js → chunk-XXDRQBXY-ttUQmtBw.js} +1 -1
  35. package/dist/web/assets/classDiagram-ZZMXUADV-CZXMGXM8.js +1 -0
  36. package/dist/web/assets/classDiagram-v2-VYDZK3BY-CZXMGXM8.js +1 -0
  37. package/dist/web/assets/{cose-bilkent-JH36ORCC-D2Hh7gs6.js → cose-bilkent-JH36ORCC-yhoqj6vM.js} +1 -1
  38. package/dist/web/assets/{cynefin-OW5HDTMX-DwbOregT.js → cynefin-OW5HDTMX-CQZuSJ5b.js} +1 -1
  39. package/dist/web/assets/{cynefinDiagram-5FMLGOSQ-vE21HTel.js → cynefinDiagram-5FMLGOSQ-Dz-2nuEW.js} +1 -1
  40. package/dist/web/assets/{dagre-GXQ25YYZ-Dtj5PNkl.js → dagre-GXQ25YYZ-DZJid-R_.js} +1 -1
  41. package/dist/web/assets/{diagram-S7CK7UJ4-CE958Up8.js → diagram-S7CK7UJ4-DB-Uzpn6.js} +1 -1
  42. package/dist/web/assets/{diagram-UQ7AKVKN-eKQdP4HV.js → diagram-UQ7AKVKN-BjIgjC39.js} +1 -1
  43. package/dist/web/assets/{diagram-VSXAHHWV-CYvYJQrA.js → diagram-VSXAHHWV-CjFlgbiX.js} +1 -1
  44. package/dist/web/assets/{diagram-VX7I27RA-BbKYzLMW.js → diagram-VX7I27RA-BlfR5PYu.js} +1 -1
  45. package/dist/web/assets/{diagram-Z3DM3KII-DV77g65D.js → diagram-Z3DM3KII-DL6_QJQh.js} +1 -1
  46. package/dist/web/assets/{download-36kk3IeP.js → download-CK_EusLu.js} +1 -1
  47. package/dist/web/assets/{ebnfDiagram-PWID7BFC-D0sEmHPl.js → ebnfDiagram-PWID7BFC-BjdizMG0.js} +1 -1
  48. package/dist/web/assets/{erDiagram-RLTQ6QDP-DK-Z6i0m.js → erDiagram-RLTQ6QDP-BxMzPgpM.js} +1 -1
  49. package/dist/web/assets/{flowDiagram-HODETNUW-Dp0aJQEZ.js → flowDiagram-HODETNUW-C-HgPS9G.js} +1 -1
  50. package/dist/web/assets/{folder-open-D1-I40k-.js → folder-open-Bcqha5Pu.js} +1 -1
  51. package/dist/web/assets/{ganttDiagram-EL5Y4UJY-BoG15yoq.js → ganttDiagram-EL5Y4UJY-BEx6HKx_.js} +4 -4
  52. package/dist/web/assets/{gitGraphDiagram-WWUBYQGX-K4reAMXM.js → gitGraphDiagram-WWUBYQGX-D9yMgjsA.js} +1 -1
  53. package/dist/web/assets/{highlighted-body-KPVGNVTW-5ZVqRrCq.js → highlighted-body-KPVGNVTW-Cdq0W8LG.js} +1 -1
  54. package/dist/web/assets/index-BqQDBYwx.js +461 -0
  55. package/dist/web/assets/index-D1sNa9P-.css +1 -0
  56. package/dist/web/assets/{infoDiagram-27XIBGKW-67wFgmJP.js → infoDiagram-27XIBGKW-e_LgGqFP.js} +1 -1
  57. package/dist/web/assets/{ishikawaDiagram-5VMMS53U-B9jfOEH9.js → ishikawaDiagram-5VMMS53U-jOCokdCr.js} +1 -1
  58. package/dist/web/assets/{journeyDiagram-3NMN7TZE-CuSLYkR9.js → journeyDiagram-3NMN7TZE-DfyXRW30.js} +1 -1
  59. package/dist/web/assets/{kanban-definition-UXKFOSKX-Cw5N-uDl.js → kanban-definition-UXKFOSKX-D6Mgx6_N.js} +1 -1
  60. package/dist/web/assets/{layout-CWCq0m-I.js → layout-BFQQ8SSL.js} +1 -1
  61. package/dist/web/assets/{linear-DKAXfoGA.js → linear-C251cMFR.js} +1 -1
  62. package/dist/web/assets/{list-CaqywJgg.js → list-BnZDr6iH.js} +1 -1
  63. package/dist/web/assets/{mermaid-HWGCJPDP-CMQlzgg9.js → mermaid-HWGCJPDP-DE8bnMel.js} +6 -6
  64. package/dist/web/assets/{mindmap-definition-YA3MSWOX-CA6cGhJr.js → mindmap-definition-YA3MSWOX-hX6YQE6d.js} +1 -1
  65. package/dist/web/assets/{pegDiagram-XKGWAZYB-CX-B1UCC.js → pegDiagram-XKGWAZYB-DRRv8KEz.js} +1 -1
  66. package/dist/web/assets/{pencil-C-6rguDb.js → pencil-ClEwbF1x.js} +1 -1
  67. package/dist/web/assets/{pieDiagram-E7YTZNPT-ZxtffUUp.js → pieDiagram-E7YTZNPT-DwRQy5kr.js} +1 -1
  68. package/dist/web/assets/{quadrantDiagram-AXDQQJYC-hp3sjfpX.js → quadrantDiagram-AXDQQJYC-u-NZRX9E.js} +1 -1
  69. package/dist/web/assets/{railroadDiagram-O6MQD6OU-DA06SOlR.js → railroadDiagram-O6MQD6OU-DsGn0lJc.js} +1 -1
  70. package/dist/web/assets/{refresh-cw-BQyph7xD.js → refresh-cw-BGtNOi70.js} +1 -1
  71. package/dist/web/assets/{requirementDiagram-BXWQKSXE-B6uWt2Rc.js → requirementDiagram-BXWQKSXE-Bak7hmyH.js} +1 -1
  72. package/dist/web/assets/{sankeyDiagram-P5KCCOFB-C5_tPpb5.js → sankeyDiagram-P5KCCOFB-Bx5Wxkio.js} +1 -1
  73. package/dist/web/assets/{save-qGawhRKH.js → save-ChNqW56W.js} +1 -1
  74. package/dist/web/assets/{scroll-area-C-MTuK1y.js → scroll-area-YSA2ORI8.js} +1 -1
  75. package/dist/web/assets/{sequenceDiagram-WJ2MYXX4-CP1FmNA0.js → sequenceDiagram-WJ2MYXX4-CyWelz_H.js} +1 -1
  76. package/dist/web/assets/{sizeCapture-INFHLROL-BnZ0rzQe.js → sizeCapture-INFHLROL-BCzEf-8B.js} +1 -1
  77. package/dist/web/assets/{stateDiagram-D77RDMKH-B--86L9i.js → stateDiagram-D77RDMKH-BkqZfGYQ.js} +1 -1
  78. package/dist/web/assets/stateDiagram-v2-MP3YSRHH-PLwI4Xlh.js +1 -0
  79. package/dist/web/assets/{swimlanes-42K2YHIH-BV8_rH1v.js → swimlanes-42K2YHIH-BMYDAy8X.js} +1 -1
  80. package/dist/web/assets/swimlanesDiagram-VR7AAH4N-BEGqjIIe.js +8 -0
  81. package/dist/web/assets/{timeline-definition-24CTP7MA-Cm1hEfH0.js → timeline-definition-24CTP7MA-BrGykZXB.js} +1 -1
  82. package/dist/web/assets/{upload-CCnbjfQN.js → upload-waJ36Q68.js} +1 -1
  83. package/dist/web/assets/{useJobs-DDRY0jra.js → useJobs-By4K4BjX.js} +1 -1
  84. package/dist/web/assets/{useKnowledge-CHZ4AwZh.js → useKnowledge-DMSoPz-b.js} +1 -1
  85. package/dist/web/assets/{useMemories-BGxDOJge.js → useMemories-bv4XvbzQ.js} +1 -1
  86. package/dist/web/assets/useProjectScope-BvcpSOql.js +1 -0
  87. package/dist/web/assets/{vennDiagram-4TSXK5OY-vVCoILPC.js → vennDiagram-4TSXK5OY-CkLSasvk.js} +1 -1
  88. package/dist/web/assets/{wardleyDiagram-VM6X3IG4-CnkLT61Q.js → wardleyDiagram-VM6X3IG4-DfPte2eh.js} +1 -1
  89. package/dist/web/assets/{xychartDiagram-S5SC5T6Z-Bvv63kic.js → xychartDiagram-S5SC5T6Z-ClFkeona.js} +1 -1
  90. package/dist/web/index.html +2 -2
  91. package/package.json +1 -1
  92. package/dist/web/assets/Sessions-CCpWptIl.js +0 -5
  93. package/dist/web/assets/Terminals-wWVDPX68.js +0 -115
  94. package/dist/web/assets/channel-BSVHIa5R.js +0 -1
  95. package/dist/web/assets/classDiagram-ZZMXUADV-3BGzDrBP.js +0 -1
  96. package/dist/web/assets/classDiagram-v2-VYDZK3BY-3BGzDrBP.js +0 -1
  97. package/dist/web/assets/index-CB3c1nr-.css +0 -1
  98. package/dist/web/assets/index-SOCnaNS0.js +0 -453
  99. package/dist/web/assets/stateDiagram-v2-MP3YSRHH-CXtInY-i.js +0 -1
  100. package/dist/web/assets/swimlanesDiagram-VR7AAH4N-DyVW1GT5.js +0 -8
  101. package/dist/web/assets/useProjectScope-B28fk5NO.js +0 -1
@@ -0,0 +1,115 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FileEditor-Cb8uXr6e.js","assets/index-BqQDBYwx.js","assets/index-D1sNa9P-.css","assets/save-ChNqW56W.js"])))=>i.map(i=>d[i]);
2
+ import{a as he,r as p,cF as Pt,cG as Tt,c as X,u as te,j as e,cs as mt,cH as ft,d as W,b as je,Q as ce,ad as Te,c4 as pt,cx as Ft,ak as Lt,cz as Et,cA as Dt,cB as Mt,cI as qt,ch as ge,cJ as ze,cK as Ce,cL as xt,am as At,a7 as Ue,c2 as Ot,b_ as Se,a8 as It,U as Kt,X as Ut,at as Bt,Z as Ht,B as pe,g as le,cm as Wt,cn as Gt,co as Vt,cp as Qt,cM as Yt,cN as Ee,L as ve,cO as Xt,cP as Zt,cQ as Jt,cR as es,aD as ts,f as Be,cS as ss,aG as as,m as gt,cd as ns,az as is,cb as rs,a1 as ue,h as bt,aC as ls,cT as os,l as jt,cU as st,cV as cs,b$ as ds,cW as us,E as vt,S as yt,cX as hs,c0 as at,cY as ms,a2 as fs,a3 as ps,a4 as xs,a5 as gs,a6 as bs,o as kt,R as js}from"./index-BqQDBYwx.js";import{F as He,E as We,A as vs}from"./folder-open-Bcqha5Pu.js";import{P as ys}from"./pencil-ClEwbF1x.js";import{R as Ge}from"./refresh-cw-BGtNOi70.js";import{L as wt}from"./list-BnZDr6iH.js";function Nt(t,s){const a=he(s);return ks({filters:{...t,status:"pending"}},a).length}function nt(t,s){return t.findAll(s.filters).map(a=>s.select?s.select(a):a.state)}function ks(t={},s){const a=he(s).getMutationCache(),h=p.useRef(t),n=p.useRef(null);return n.current===null&&(n.current=nt(a,t)),p.useEffect(()=>{h.current=t}),p.useSyncExternalStore(p.useCallback(o=>a.subscribe(()=>{const i=Pt(n.current,nt(a,h.current));n.current!==i&&(n.current=i,Tt.schedule(o))}),[a]),()=>n.current,()=>n.current)}/**
3
+ * @license lucide-react v1.27.0 - ISC
4
+ *
5
+ * This source code is licensed under the ISC license.
6
+ * See the LICENSE file in the root directory of this source tree.
7
+ */const ws=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Ns=X("arrow-right",ws);/**
8
+ * @license lucide-react v1.27.0 - ISC
9
+ *
10
+ * This source code is licensed under the ISC license.
11
+ * See the LICENSE file in the root directory of this source tree.
12
+ */const Cs=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],Ss=X("braces",Cs);/**
13
+ * @license lucide-react v1.27.0 - ISC
14
+ *
15
+ * This source code is licensed under the ISC license.
16
+ * See the LICENSE file in the root directory of this source tree.
17
+ */const $s=[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]],Rs=X("chevrons-down-up",$s);/**
18
+ * @license lucide-react v1.27.0 - ISC
19
+ *
20
+ * This source code is licensed under the ISC license.
21
+ * See the LICENSE file in the root directory of this source tree.
22
+ */const _s=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],zs=X("circle-check",_s);/**
23
+ * @license lucide-react v1.27.0 - ISC
24
+ *
25
+ * This source code is licensed under the ISC license.
26
+ * See the LICENSE file in the root directory of this source tree.
27
+ */const Ps=[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]],Ts=X("circle-dashed",Ps);/**
28
+ * @license lucide-react v1.27.0 - ISC
29
+ *
30
+ * This source code is licensed under the ISC license.
31
+ * See the LICENSE file in the root directory of this source tree.
32
+ */const Fs=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Ls=X("circle-x",Fs);/**
33
+ * @license lucide-react v1.27.0 - ISC
34
+ *
35
+ * This source code is licensed under the ISC license.
36
+ * See the LICENSE file in the root directory of this source tree.
37
+ */const Es=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],Ve=X("columns-2",Es);/**
38
+ * @license lucide-react v1.27.0 - ISC
39
+ *
40
+ * This source code is licensed under the ISC license.
41
+ * See the LICENSE file in the root directory of this source tree.
42
+ */const Ds=[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Ms=X("copy-plus",Ds);/**
43
+ * @license lucide-react v1.27.0 - ISC
44
+ *
45
+ * This source code is licensed under the ISC license.
46
+ * See the LICENSE file in the root directory of this source tree.
47
+ */const qs=[["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"}]],Qe=X("external-link",qs);/**
48
+ * @license lucide-react v1.27.0 - ISC
49
+ *
50
+ * This source code is licensed under the ISC license.
51
+ * See the LICENSE file in the root directory of this source tree.
52
+ */const As=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],Os=X("file-code-corner",As);/**
53
+ * @license lucide-react v1.27.0 - ISC
54
+ *
55
+ * This source code is licensed under the ISC license.
56
+ * See the LICENSE file in the root directory of this source tree.
57
+ */const Is=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]],Ks=X("file-image",Is);/**
58
+ * @license lucide-react v1.27.0 - ISC
59
+ *
60
+ * This source code is licensed under the ISC license.
61
+ * See the LICENSE file in the root directory of this source tree.
62
+ */const Us=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],De=X("file",Us);/**
63
+ * @license lucide-react v1.27.0 - ISC
64
+ *
65
+ * This source code is licensed under the ISC license.
66
+ * See the LICENSE file in the root directory of this source tree.
67
+ */const Bs=[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]],Ct=X("files",Bs);/**
68
+ * @license lucide-react v1.27.0 - ISC
69
+ *
70
+ * This source code is licensed under the ISC license.
71
+ * See the LICENSE file in the root directory of this source tree.
72
+ */const Hs=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]],St=X("git-pull-request",Hs);/**
73
+ * @license lucide-react v1.27.0 - ISC
74
+ *
75
+ * This source code is licensed under the ISC license.
76
+ * See the LICENSE file in the root directory of this source tree.
77
+ */const Ws=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],Gs=X("keyboard",Ws);/**
78
+ * @license lucide-react v1.27.0 - ISC
79
+ *
80
+ * This source code is licensed under the ISC license.
81
+ * See the LICENSE file in the root directory of this source tree.
82
+ */const Vs=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]],Qs=X("list-todo",Vs);/**
83
+ * @license lucide-react v1.27.0 - ISC
84
+ *
85
+ * This source code is licensed under the ISC license.
86
+ * See the LICENSE file in the root directory of this source tree.
87
+ */const Ys=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M12 8v6",key:"1ib9pf"}],["path",{d:"M9 11h6",key:"1fldmi"}]],it=X("message-square-plus",Ys);/**
88
+ * @license lucide-react v1.27.0 - ISC
89
+ *
90
+ * This source code is licensed under the ISC license.
91
+ * See the LICENSE file in the root directory of this source tree.
92
+ */const Xs=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],Zs=X("panel-left-close",Xs);/**
93
+ * @license lucide-react v1.27.0 - ISC
94
+ *
95
+ * This source code is licensed under the ISC license.
96
+ * See the LICENSE file in the root directory of this source tree.
97
+ */const Js=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],ea=X("panel-left-open",Js);/**
98
+ * @license lucide-react v1.27.0 - ISC
99
+ *
100
+ * This source code is licensed under the ISC license.
101
+ * See the LICENSE file in the root directory of this source tree.
102
+ */const ta=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}]],sa=X("panel-top",ta);/**
103
+ * @license lucide-react v1.27.0 - ISC
104
+ *
105
+ * This source code is licensed under the ISC license.
106
+ * See the LICENSE file in the root directory of this source tree.
107
+ */const aa=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]],na=X("panels-top-left",aa);/**
108
+ * @license lucide-react v1.27.0 - ISC
109
+ *
110
+ * This source code is licensed under the ISC license.
111
+ * See the LICENSE file in the root directory of this source tree.
112
+ */const ia=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 12h18",key:"1i2n21"}]],ra=X("rows-2",ia);function la({initial:t,host:s,onPick:a,onClose:h}){const[n,o]=p.useState(t),{data:i,error:g,isFetching:m}=te({queryKey:["terminals","browse",s,n],queryFn:()=>W.terminals.browse(n||void 0,s),retry:!1}),c=l=>i?`${i.path.replace(/\/$/,"")}/${l}`:l;return e.jsxs("div",{"data-testid":"remote-folder-browser",className:"border border-outline-variant rounded-md bg-background p-1 space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1 px-1",children:[e.jsx("button",{type:"button","data-testid":"remote-folder-up",disabled:!(i!=null&&i.parent),onClick:()=>(i==null?void 0:i.parent)&&o(i.parent),"aria-label":"Parent folder",title:"Parent folder",className:"shrink-0 min-h-11 min-w-11 sm:min-h-8 sm:min-w-8 inline-flex items-center justify-center p-1 rounded-md text-on-surface-variant hover:bg-surface hover:text-on-surface disabled:opacity-40",children:e.jsx(mt,{size:12})}),e.jsxs("span",{className:"min-w-0 flex-1 truncate font-body text-xs text-on-surface",title:i==null?void 0:i.path,children:[i!=null&&i.host?`${i.host}:`:"",(i==null?void 0:i.path)??n]})]}),g&&e.jsx("p",{className:"px-1 font-body text-xs text-error break-words",children:g instanceof Error?g.message:String(g)}),e.jsxs("ul",{className:"max-h-48 overflow-y-auto",children:[i==null?void 0:i.directories.map(l=>e.jsx("li",{children:e.jsxs("button",{type:"button","data-testid":"remote-folder-entry",onClick:()=>o(c(l)),className:"w-full min-h-11 flex items-center gap-1.5 px-1 py-0.5 rounded-md font-body text-xs text-on-surface-variant hover:bg-surface hover:text-on-surface",children:[e.jsx(ft,{size:11,className:"shrink-0 text-on-surface-variant"}),e.jsx("span",{className:"truncate",children:l})]})},l)),i&&i.directories.length===0&&!m&&e.jsx("li",{className:"px-1 py-0.5 font-body text-xs text-on-surface-variant",children:"No subfolders"})]}),e.jsxs("div",{className:"flex justify-end gap-1 px-1",children:[e.jsx("button",{type:"button",onClick:h,className:"min-h-11 px-2 py-0.5 rounded-md font-label text-xs text-on-surface-variant hover:text-on-surface",children:"Cancel"}),e.jsx("button",{type:"button","data-testid":"remote-folder-pick",disabled:!i,onClick:()=>i&&a(i.path),className:"min-h-11 px-2 py-0.5 rounded-md bg-transparent border border-control-border text-on-surface font-label text-xs hover:bg-surface disabled:opacity-50",children:"Use folder"})]})]})}function oa(t,s){return te({queryKey:["worktrees",t,s],queryFn:()=>W.git.worktrees(t,s),enabled:t.trim()!=="",retry:!1,staleTime:5e3})}function ca(){const t=he();return je({mutationFn:s=>W.git.removeWorktree(s),onSettled:()=>t.invalidateQueries({queryKey:["worktrees"]})})}const Me="orc_terminal_cwd",$t="orc_terminal_worktree";function da(t){try{return{cwd:(t==null?void 0:t.getItem(Me))??"",worktree:(t==null?void 0:t.getItem($t))==="1"}}catch{return{cwd:"",worktree:!1}}}function Fe(t,s,a){try{t==null||t.setItem(s,a)}catch{}}function ua(t,s){return t!=="shell"&&s.trim()===""}function rt(t,s,a){const h=s.trim();return{kind:t,...h?{cwd:h}:{},...a&&t!=="shell"&&h?{worktree:!0}:{}}}function xe({className:t,children:s,...a}){return e.jsxs("span",{className:"terminal-select-wrap",children:[e.jsx("select",{...a,className:ce("terminal-select",t),children:s}),e.jsx(Te,{size:12,strokeWidth:1.5,"aria-hidden":"true"})]})}const _e=(()=>{try{return typeof window>"u"?void 0:window.localStorage}catch{return}})();function lt(t,s){const[a,h]=p.useState(t);return p.useEffect(()=>{const n=setTimeout(()=>h(t),s);return()=>clearTimeout(n)},[t,s]),a}function ha({open:t,onOpenChange:s,launchers:a,host:h,pending:n,error:o,onCreate:i,className:g,compact:m=!1}){const c=p.useId(),[l]=p.useState(()=>da(_e)),[x,F]=p.useState(h),[f,b]=p.useState(h?"":l.cwd),[S,d]=p.useState(l.worktree),[j,v]=p.useState(!1),[w,y]=p.useState(!1),[L,z]=p.useState(null),[P,D]=p.useState(null),V=p.useRef(null),I=p.useRef(new Map([[null,l.cwd]])),{data:U,error:A}=pt(),C=!x||(U==null?void 0:U.supported)===!0,{data:K,error:Q,isFetching:Z}=te({queryKey:["terminal-launchers",x],queryFn:()=>W.terminals.list(x),enabled:t&&C,retry:!1,staleTime:3e4});let Y=[];K!=null&&K.ready?Y=K.launchers:!K&&x===h&&!Q&&C&&(Y=a);const r=lt(f.trim(),300),O=lt(x??"",300),{data:k}=oa(t&&C&&O===(x??"")?r:"",x),N=ca(),E=k!=null&&k.root?k.worktrees:[],_=n||j||Z||!C;p.useEffect(()=>{var ee,se;if(!t||P)return;(se=(ee=V.current)==null?void 0:ee.querySelector("input[data-testid='terminal-cwd']"))==null||se.focus();const R=me=>{var de;(de=V.current)!=null&&de.contains(me.target)||s(!1)},G=me=>{var de,ye;me.key==="Escape"&&(me.preventDefault(),s(!1),(ye=(de=V.current)==null?void 0:de.querySelector("button[data-testid='terminal-new']"))==null||ye.focus())};return document.addEventListener("pointerdown",R),document.addEventListener("keydown",G),()=>{document.removeEventListener("pointerdown",R),document.removeEventListener("keydown",G)}},[t,s,P]);const B=R=>{b(R),I.current.set(x,R),x===null&&Fe(_e,Me,R)},M=R=>{I.current.set(x,f),F(R),b(I.current.get(R)??""),y(!1),z(null),D(null)},ae=async()=>{if(z(null),x)return y(!0),null;v(!0);try{const{path:R}=await W.terminals.pickFolder(f.trim()||void 0,null);return R&&B(R),R}catch(R){return z(R instanceof Error?R.message:String(R)),null}finally{v(!1)}},oe=async R=>{z(null);let G=f.trim();if(ua(R,G)){const ee=await ae();if(!ee)return;G=ee}await i({...rt(R,G,S),host:x})&&x===null&&Fe(_e,Me,G)},T=(R,G)=>{z(null),i({...rt(R,G.path,!1),host:x})},q=async R=>{var ee;z(null);const G=((ee=E.find(se=>se.main))==null?void 0:ee.path)??r;try{await N.mutateAsync({cwd:G,path:R.worktree.path,force:R.step==="dirty",host:x}),D(null),R.worktree.path===r&&B(G)}catch(se){if(se instanceof Ot&&se.code==="WORKTREE_DIRTY"){D({worktree:R.worktree,step:"dirty"});return}D(null),z(se instanceof Error?se.message:String(se))}},ie=()=>{if(P){if(P.step==="confirm"&&P.worktree.dirty){D({worktree:P.worktree,step:"dirty"});return}q(P)}},$e=L??o??(x&&!C?U==null?void 0:U.unsupported_reason:null)??(Q==null?void 0:Q.message)??(A==null?void 0:A.message)??(K==null?void 0:K.reason),Re=m?Dt:"div";return e.jsx(Ft,{open:m&&t,onOpenChange:s,children:e.jsxs("div",{ref:V,className:ce("relative",g),children:[e.jsxs("button",{type:"button","data-testid":"terminal-new","aria-haspopup":"dialog","aria-expanded":t,onClick:()=>s(!t),className:"w-full min-w-11 inline-flex items-center justify-center gap-2 min-h-11 px-3 py-2 rounded-md bg-primary border border-primary text-primary-foreground font-label text-xs hover:bg-primary/90 transition-colors",children:[e.jsx(Lt,{size:14}),e.jsx("span",{className:m?"sr-only":void 0,children:"New terminal"})]}),m&&t&&e.jsx(Et,{className:"fixed inset-0 z-50 bg-black/70"}),t&&e.jsxs(Re,{...m?{onCloseAutoFocus:R=>{var G,ee;R.preventDefault(),(ee=(G=V.current)==null?void 0:G.querySelector('[data-testid="terminal-new"]'))==null||ee.focus()}}:{},role:"dialog","aria-label":"New terminal","aria-describedby":void 0,"data-testid":"terminal-launch-menu",className:ce("terminal-launch-controls bg-surface-high border border-outline-variant rounded-lg shadow-xl p-3 space-y-3 overflow-y-auto overscroll-contain",m?"fixed inset-x-3 top-[calc(var(--app-top,0px)_+_env(safe-area-inset-top)_+_1rem)] z-50 max-h-[calc(var(--app-height,100dvh)-2rem)]":"absolute left-0 top-full mt-1 z-30 w-[22rem] max-w-[calc(100vw-2rem)] max-h-[70dvh]"),children:[m&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Mt,{className:"text-sm font-medium",children:"New terminal"}),e.jsx(qt,{className:"flex size-11 items-center justify-center rounded-md text-on-surface-variant hover:bg-surface","aria-label":"Close terminal launcher",children:e.jsx(ge,{size:18})})]}),e.jsxs("label",{htmlFor:c,className:"flex items-center gap-2 text-sm text-on-surface-variant",children:["Host",e.jsxs(xe,{id:c,"data-testid":"terminal-host-select",value:x??"",onChange:R=>M(R.target.value||null),disabled:n||j,children:[e.jsx("option",{value:"",children:"Local"}),[...new Set([...(U==null?void 0:U.hosts)??[],...U!=null&&U.host?[U.host]:[]])].map(R=>e.jsx("option",{value:R,children:R},R))]})]}),e.jsxs("label",{className:"block",children:[e.jsxs("span",{className:"font-label text-xs text-on-surface-variant",children:["Working directory",x&&e.jsxs("span",{"data-testid":"terminal-host",className:"ml-1 px-1 rounded-md bg-surface-highest text-on-surface normal-case tracking-normal",children:["on ",x]})]}),e.jsxs("div",{className:"mt-1 flex gap-1",children:[e.jsx("input",{type:"text","data-testid":"terminal-cwd",value:f,onChange:R=>B(R.target.value),placeholder:"~ (home folder)",spellCheck:!1,className:"min-w-0 flex-1 bg-background border border-control-border rounded-md min-h-11 px-2 py-1 font-body text-base sm:text-sm text-on-surface placeholder:text-on-surface-variant focus:outline-none focus:ring-2 focus:ring-focus"}),e.jsxs("button",{type:"button","data-testid":"terminal-browse",disabled:_,onClick:()=>void ae(),title:"Choose a folder",className:"shrink-0 inline-flex items-center gap-1 min-h-11 px-2 py-1 rounded-md border border-control-border font-label text-xs text-on-surface-variant hover:bg-surface hover:text-on-surface disabled:opacity-50",children:[e.jsx(He,{size:12}),j?"Choosing":"Browse"]})]})]}),x&&w&&e.jsx(la,{host:x,initial:f.trim(),onPick:R=>{B(R),y(!1)},onClose:()=>y(!1)},x),e.jsxs("label",{className:"flex items-center gap-2 px-1 cursor-pointer select-none",children:[e.jsx("input",{type:"checkbox","data-testid":"terminal-worktree",checked:S,onChange:R=>{d(R.target.checked),Fe(_e,$t,R.target.checked?"1":"0")},className:"accent-primary"}),e.jsx("span",{className:"font-body text-xs text-on-surface-variant",children:"New git worktree for agents"})]}),e.jsxs("div",{className:"space-y-0.5",children:[Y.map(R=>{const{label:G,icon:ee}=ze[R];return e.jsxs("button",{type:"button","data-testid":`terminal-launch-${R}`,disabled:_,onClick:()=>void oe(R),className:"w-full flex items-center gap-2 min-h-11 px-2 py-1.5 rounded-md font-label text-xs text-on-surface-variant hover:bg-surface hover:text-on-surface disabled:opacity-50",children:[e.jsx(ee,{size:14}),G]},R)}),Y.length===0&&e.jsx("p",{className:"min-h-11 px-2 py-1 font-body text-base sm:text-sm text-on-surface-variant",children:"No launchers available"})]}),E.length>0&&e.jsxs("div",{"data-testid":"terminal-worktrees",className:"border-t border-surface-highest pt-2",children:[e.jsx("p",{className:"px-1 pb-1 font-label text-xs text-on-surface-variant",children:"Checkouts"}),e.jsx("ul",{className:"max-h-56 overflow-y-auto space-y-0.5",children:E.map(R=>e.jsxs("li",{"data-testid":"terminal-worktree-row",className:"group flex items-center gap-2 px-1 py-1 rounded-md hover:bg-surface",children:[e.jsxs("div",{className:"min-w-0 flex-1",title:R.path,children:[e.jsxs("div",{className:"flex items-center gap-1 font-body text-xs text-on-surface",children:[e.jsx(Ce,{size:11,className:"shrink-0 text-on-surface-variant"}),e.jsx("span",{className:"truncate",children:R.branch??(R.head?R.head.slice(0,8):"detached")}),R.main&&e.jsx("span",{className:"shrink-0 px-1 rounded-md bg-surface-highest text-on-surface font-label text-xs",children:"main"}),R.dirty&&e.jsx("span",{className:"shrink-0 px-1 rounded-md text-tertiary font-label text-xs",children:"dirty"}),R.prunable&&e.jsx("span",{className:"shrink-0 px-1 rounded-md text-error font-label text-xs",children:"missing"})]}),e.jsx("div",{className:"truncate font-body text-xs text-on-surface-variant",children:xt(R.path)})]}),!R.prunable&&Y.map(G=>{const{label:ee,icon:se}=ze[G];return e.jsx("button",{type:"button","data-testid":`terminal-worktree-open-${G}`,disabled:_,onClick:()=>T(G,R),title:`Open ${ee} here`,"aria-label":`Open ${ee} in ${R.path}`,className:"shrink-0 min-h-11 min-w-11 sm:min-h-8 sm:min-w-8 inline-flex items-center justify-center p-1 rounded-md text-on-surface-variant hover:bg-surface hover:text-on-surface disabled:opacity-50",children:e.jsx(se,{size:12})},G)}),!R.main&&e.jsx("button",{type:"button","data-testid":"terminal-worktree-remove",disabled:_||N.isPending,onClick:()=>D({worktree:R,step:"confirm"}),title:"Remove worktree","aria-label":`Remove worktree ${R.path}`,className:"shrink-0 min-h-11 min-w-11 sm:min-h-8 sm:min-w-8 inline-flex items-center justify-center p-1 rounded-md text-on-surface-variant hover:bg-error/15 hover:text-error disabled:opacity-50",children:e.jsx(At,{size:12})})]},R.path))})]}),$e&&e.jsx("p",{role:"alert",className:"px-1 font-body text-xs text-error break-words",children:$e})]}),e.jsx(Ue,{open:P!==null,onCancel:()=>D(null),onConfirm:ie,isPending:N.isPending,title:(P==null?void 0:P.step)==="dirty"?"Discard uncommitted changes?":"Remove worktree?",description:(P==null?void 0:P.step)==="dirty"?`${P.worktree.path} has uncommitted changes. Removing it deletes them for good.`:`Deletes the folder ${(P==null?void 0:P.worktree.path)??""}. The branch ${(P==null?void 0:P.worktree.branch)??""} is kept.`,confirmLabel:(P==null?void 0:P.step)==="dirty"?"Discard and remove":"Remove"})]})})}function ma({terminal:t,onClose:s}){const{rename:a}=Se(),[h,n]=p.useState(t.name),[o,i]=p.useState(!1),[g,m]=p.useState(null);return e.jsx(It,{open:!0,onOpenChange:c=>{o||c||s()},children:e.jsxs(Kt,{onCloseAutoFocus:c=>{var l;c.preventDefault(),(l=document.querySelector(`[data-terminal-actions="${CSS.escape(t.id)}"]`))==null||l.focus()},children:[e.jsx(Ut,{children:"Rename terminal"}),e.jsx(Bt,{children:"Choose a friendly name for this terminal session."}),e.jsxs("form",{className:"space-y-4",onSubmit:async c=>{if(c.preventDefault(),!(o||!h.trim())){i(!0),m(null);try{await a(t.id,h.trim()),s()}catch(l){m(l instanceof Error?l.message:String(l))}finally{i(!1)}}},children:[e.jsxs("label",{htmlFor:`terminal-name-${t.id}`,className:"block space-y-2",children:[e.jsx("span",{className:"text-sm",children:"Terminal name"}),e.jsx(Ht,{id:`terminal-name-${t.id}`,"data-testid":"terminal-rename-input",value:h,onChange:c=>n(c.target.value),maxLength:120,required:!0,disabled:o})]}),g&&e.jsx("p",{role:"alert","data-testid":"terminal-rename-error",className:"text-sm text-error",children:g}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(pe,{type:"button",variant:"ghost","data-testid":"terminal-rename-cancel",disabled:o,onClick:s,children:"Cancel"}),e.jsx(pe,{type:"submit","data-testid":"terminal-rename-save",disabled:o||!h.trim(),children:o?"Saving…":"Save"})]})]})]})})}function qe({terminal:t,paneId:s}){var n;const[,a]=le(),h=te({queryKey:["git",t.id,"status"],queryFn:()=>W.git.status(t.id)});return h.error?e.jsx("button",{type:"button",onClick:()=>void h.refetch(),className:"min-h-8 text-xs text-warning",title:h.error.message,children:"Git unavailable · Retry"}):(n=h.data)!=null&&n.root?e.jsxs("button",{type:"button","data-testid":s?"pane-checkout":"terminal-checkout",title:"Review checkout changes",onClick:()=>a(o=>{const i=new URLSearchParams(o);return i.set("view","git"),s&&i.set("pane",s),i.set("paneTerminal",t.id),i.delete("file"),i}),className:"flex items-center gap-2 min-h-6 sm:min-h-8 min-w-0 max-w-full text-xs text-on-surface-variant hover:text-on-surface",children:[e.jsx(Ce,{size:13,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:h.data.branch??"Detached HEAD"}),e.jsx("span",{className:"shrink-0",children:h.data.files.length?`${h.data.files.length} changed`:"Clean"})]}):null}function fa({terminal:t,onRename:s,onDuplicate:a,onClose:h,canDuplicate:n,pending:o,open:i,onOpenChange:g}){const[m,c]=p.useState(!1),l=g??c,x="flex w-full items-center gap-2 rounded px-3 min-h-11 text-sm text-left hover:bg-surface-highest focus-visible:outline focus-visible:outline-2 focus-visible:outline-focus disabled:opacity-40";return e.jsxs(Wt,{open:i??m,onOpenChange:l,children:[e.jsx(Gt,{asChild:!0,children:e.jsx("button",{type:"button","data-testid":"terminal-actions","data-terminal-actions":t.id,"aria-label":`Actions for ${t.name}`,title:"Terminal actions (also right-click the tab)",className:"shrink-0 inline-flex min-h-11 min-w-11 sm:min-h-8 sm:min-w-8 items-center justify-center rounded text-on-surface-variant hover:bg-surface hover:text-on-surface",children:e.jsx(We,{size:16})})}),e.jsx(Vt,{children:e.jsxs(Qt,{"data-testid":"terminal-actions-menu","aria-label":`Actions for ${t.name}`,align:"end",sideOffset:4,collisionPadding:8,className:"z-50 w-64 max-w-[calc(100vw-16px)] rounded-md border border-outline-variant bg-surface-high p-1 shadow-lg",children:[e.jsx("p",{className:"truncate px-3 py-2 text-xs text-on-surface-variant",title:t.name,children:t.name}),e.jsxs("button",{type:"button","data-testid":"terminal-rename",onClick:()=>{l(!1),s(t)},className:x,children:[e.jsx(ys,{size:14}),"Rename"]}),e.jsxs("button",{type:"button","data-testid":"terminal-duplicate",disabled:o||!n,onClick:()=>{l(!1),a(t)},className:x,title:n?"Start a fresh session of the same type in this folder":"The session's host or launcher is unavailable",children:[e.jsx(Ms,{size:14}),"Duplicate tab"]}),e.jsx("p",{className:"px-3 pb-2 text-xs text-on-surface-variant",children:"Duplicate starts a fresh session in the same folder."}),e.jsx("div",{className:"border-t border-outline-variant pt-1",children:e.jsxs("button",{type:"button","data-testid":"terminal-close-selected",onClick:()=>{l(!1),h(t)},className:`${x} text-error`,children:[e.jsx(ge,{size:14}),"Close terminal"]})})]})})]})}function pa({terminals:t,activeId:s,onClose:a,connectionOf:h,onRename:n,onDuplicate:o,canDuplicate:i,pending:g}){const[m]=le(),[c,l]=p.useState("all"),[x,F]=p.useState(null),f=Yt(t,"",c);return e.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[e.jsx("div",{className:"space-y-2 px-3 pb-3 border-b border-outline-variant",children:e.jsx("fieldset",{className:"flex items-center gap-1","aria-label":"Filter terminals",children:["all","running","exited"].map(b=>e.jsxs("button",{type:"button","data-testid":`terminal-filter-${b}`,"aria-pressed":c===b,onClick:()=>l(b),className:ce("flex-1 min-h-11 sm:min-h-8 rounded px-1 text-xs",c===b?"bg-surface-highest text-on-surface":"text-on-surface-variant hover:bg-surface"),children:[b==="all"?"All":b==="running"?"Running":"Exited"," ",e.jsx("span",{className:"tabular-nums",children:b==="all"?t.length:t.filter(S=>S.status===b).length})]},b))})}),e.jsxs("div",{"data-testid":"terminals-list",className:"flex-1 min-h-0 overflow-y-auto py-1",children:[f.length===0&&e.jsx("p",{"data-testid":"terminal-search-empty",className:"p-4 text-sm text-on-surface-variant",children:"No sessions in this filter."}),f.map(b=>{const S=b.id===s,{label:d,icon:j}=ze[b.kind],v=xt(b.cwd),w=Ee(b,h(b.id)),y=w==="Disconnected"||w==="Reconnecting",L=new URLSearchParams(m);return L.delete("file"),L.delete("session"),L.has("view")&&L.set("paneTerminal",b.id),e.jsxs("div",{"data-testid":"terminal-item","data-status":b.status,"data-active":S,className:ce("flex items-center gap-2 px-3 py-2 transition-colors",S?"bg-surface-highest":"hover:bg-surface"),children:[e.jsx("span",{className:ce("h-2 w-2 shrink-0 rounded-full",y?"bg-warning":b.status==="running"?"bg-secondary":"bg-outline"),title:w}),e.jsxs(ve,{onContextMenu:z=>{z.preventDefault(),F(b.id)},to:{pathname:`/terminals/${b.id}`,search:L.toString()},title:`${b.name}
113
+ ${b.cwd??""}
114
+ ${w}`,"aria-current":S?"page":void 0,className:"flex-1 min-w-0",onKeyDown:z=>{(z.key==="ContextMenu"||z.shiftKey&&z.key==="F10")&&(z.preventDefault(),F(b.id))},children:[e.jsx("div",{className:ce("truncate font-body text-xs",S?"text-on-surface font-medium":"text-on-surface"),children:b.name}),e.jsxs("div",{className:"flex items-center gap-1 font-label text-xs text-on-surface-variant min-w-0",children:[e.jsx(j,{size:10,className:"shrink-0"}),e.jsx("span",{className:"shrink-0",children:d}),e.jsx("span",{"data-testid":"terminal-item-state",className:ce("ml-auto truncate",y?"text-warning":"text-on-surface-variant"),children:w}),b.host&&e.jsxs("span",{"data-testid":"terminal-item-host",className:"shrink-0 normal-case tracking-normal text-primary",children:["@",b.host]})]}),v&&e.jsx("div",{className:"truncate text-xs text-on-surface-variant",title:b.cwd??void 0,children:v})]}),e.jsx(fa,{terminal:b,open:x===b.id,onOpenChange:z=>F(z?b.id:null),onRename:n,onDuplicate:o,onClose:a,canDuplicate:i(b),pending:g})]},b.id)})]})]})}const xa=[{name:"Escape",label:"Esc",data:"\x1B"},{name:"Tab",label:"Tab",data:" "},{name:"Interrupt command",label:"Ctrl C",data:""},{name:"Arrow up",label:e.jsx(mt,{size:16}),data:"\x1B[A"},{name:"Arrow down",label:e.jsx(ts,{size:16}),data:"\x1B[B"},{name:"Arrow left",label:e.jsx(vs,{size:16}),data:"\x1B[D"},{name:"Arrow right",label:e.jsx(Ns,{size:16}),data:"\x1B[C"}];function ke({onPress:t,disabled:s,...a}){const h=p.useRef(null),n=p.useRef(!1);return e.jsx("button",{...a,disabled:s,onPointerDown:o=>{o.pointerType==="mouse"&&(n.current=!1)},onMouseDown:o=>o.preventDefault(),onTouchStart:o=>{const i=o.touches.length===1?o.touches[0]:void 0;h.current=i?{x:i.clientX,y:i.clientY,moved:!1}:null,n.current=!1},onTouchMove:o=>{const i=h.current,g=o.touches[0];i&&g&&Math.hypot(g.clientX-i.x,g.clientY-i.y)>6&&(i.moved=!0)},onTouchCancel:()=>{h.current=null},onTouchEnd:o=>{const i=h.current;h.current=null,!(s||!i||i.moved)&&(o.preventDefault(),n.current=!0,t())},onClick:o=>{if(n.current&&o.detail>0){n.current=!1;return}n.current=!1,s||t()}})}function ga({terminalId:t}){const s=Xt("(any-pointer: coarse)"),{sendInput:a,focus:h,connectionOf:n,terminals:o,fontSizeOf:i,setFontSize:g}=Se();if(!s)return null;const m=n(t)==="connected"&&o.some(c=>c.id===t&&c.status==="running");return e.jsxs("fieldset",{"data-testid":"terminal-touch-controls","aria-label":"Terminal keyboard shortcuts",className:"flex min-w-0 w-full shrink-0 gap-1 border-t border-outline-variant bg-background px-2 py-1",children:[e.jsx(ke,{type:"button","data-testid":"terminal-keyboard-show","aria-label":"Show terminal keyboard",disabled:!m,onPress:()=>h(t),className:"inline-flex size-11 shrink-0 items-center justify-center rounded-md text-on-surface-variant hover:bg-surface disabled:opacity-40",children:e.jsx(Gs,{size:18})}),e.jsx("fieldset",{"data-testid":"terminal-special-keys",className:"flex min-w-0 flex-1 gap-1 overflow-x-auto overscroll-x-contain","aria-label":"Swipe for more terminal keys",children:xa.map(c=>e.jsx(ke,{type:"button","aria-label":c.name,disabled:!m,onPress:()=>a(t,c.data),className:"inline-flex min-h-11 min-w-11 shrink-0 items-center justify-center rounded-md px-2 text-xs text-on-surface-variant hover:bg-surface disabled:opacity-40",children:c.label},c.name))}),e.jsxs("fieldset",{className:"flex shrink-0 border-l border-outline-variant","aria-label":"Terminal text size",children:[e.jsx(ke,{type:"button","data-testid":"terminal-font-smaller","aria-label":"Smaller terminal text",disabled:i(t)<=Zt,onPress:()=>g(t,i(t)-1),className:"min-h-11 min-w-11 rounded-md text-sm hover:bg-surface disabled:opacity-40",children:"A−"}),e.jsxs(ke,{type:"button","data-testid":"terminal-font-reset","aria-label":"Reset terminal text size",title:"Pinch terminal to zoom; tap to reset",onPress:()=>g(t,Jt),className:"min-h-11 min-w-11 rounded-md text-xs hover:bg-surface",children:[i(t),"px"]}),e.jsx(ke,{type:"button","data-testid":"terminal-font-larger","aria-label":"Larger terminal text",disabled:i(t)>=es,onPress:()=>g(t,i(t)+1),className:"min-h-11 min-w-11 rounded-md text-sm hover:bg-surface disabled:opacity-40",children:"A+"})]})]})}function H(t){return"kind"in t?[t]:[...H(t.first),...H(t.second)]}function Pe(t,s,a){return t.id===s?a(t):"kind"in t?t:{...t,first:Pe(t.first,s,a),second:Pe(t.second,s,a)}}function Ae(t,s){return"kind"in t?t:t.first.id===s?t.second:t.second.id===s?t.first:{...t,first:Ae(t.first,s),second:Ae(t.second,s)}}function Oe(t,s=0){if(!t||typeof t!="object"||s>7)return null;const a=t;if(typeof a.id!="string"||a.id.length>100)return null;if(["terminal","git","files"].includes(String(a.kind))&&(a.terminalId===null||typeof a.terminalId=="string"))return{id:a.id,kind:a.kind,terminalId:a.terminalId};if(a.direction!=="row"&&a.direction!=="column"||typeof a.ratio!="number"||!Number.isFinite(a.ratio))return null;const h=Oe(a.first,s+1),n=Oe(a.second,s+1);if(!h||!n)return null;const o={id:a.id,direction:a.direction,ratio:Math.max(20,Math.min(80,a.ratio)),first:h,second:n},i=H(o);if(i.length>8||new Set(i.map(m=>m.id)).size!==i.length)return null;const g=i.filter(m=>m.kind==="terminal"&&m.terminalId).map(m=>m.terminalId);return new Set(g).size!==g.length?null:o}function ne(t){const s=["DD","AU","UD","UA","DU","AA","UU"].includes(t.index+t.working),a=!s&&t.index!==" "&&t.index!=="?",h=s||t.working!==" ",n=s?"U":t.original?"R":t.working!==" "?t.working:t.index,o={M:"Modified",A:"Added",D:"Deleted",R:"Renamed",C:"Copied",U:"Conflict","?":"Untracked"}[n]??"Changed";return{staged:a,working:h,conflict:s,label:o}}const ba=p.lazy(()=>ss(()=>import("./FileEditor-Cb8uXr6e.js"),__vite__mapDeps([0,1,2,3])).then(t=>({default:t.FileEditor}))),be=new Map;function ja(t){var a;const s=(a=t.split(".").pop())==null?void 0:a.toLowerCase();return["ts","tsx","js","jsx","py","sh","css","html","rs","go"].includes(s??"")?Os:["json","yml","yaml","toml","xml"].includes(s??"")?Ss:["png","jpg","jpeg","gif","svg","webp","ico"].includes(s??"")?Ks:["md","txt","log","csv"].includes(s??"")?as:De}function Rt({terminalId:t,path:s,selected:a,expanded:h,toggle:n,select:o,changes:i}){var m,c,l,x,F;const g=te({queryKey:["checkout-files",t,s],queryFn:()=>W.git.files(t,s)});return e.jsxs("ul",{className:s?"ml-3 border-l border-outline/20 pl-1":"",children:[g.isPending&&e.jsx("li",{className:"px-3 py-2 text-xs text-on-surface-variant",children:"Loading files…"}),g.error&&e.jsx("li",{role:"alert",className:"px-3 py-2 text-xs text-error",children:g.error.message}),((c=(m=g.data)==null?void 0:m.entries)==null?void 0:c.length)===0&&e.jsx("li",{className:"px-3 py-2 text-xs text-on-surface-variant",children:"Empty folder"}),(x=(l=g.data)==null?void 0:l.entries)==null?void 0:x.map(f=>{const b=h.has(f.path),S=i.find(v=>v.path===f.path),d=S?ne(S):null;let j=ja(f.name);return f.directory&&(j=b?He:ft),e.jsxs("li",{children:[e.jsxs("button",{type:"button","data-testid":"file-entry","data-path":f.path,"aria-expanded":f.directory?b:void 0,"aria-current":!f.directory&&a===f.path?"true":void 0,title:f.path,onClick:()=>f.directory?n(f.path):o(f.path),className:`flex min-h-11 sm:min-h-8 w-full min-w-0 items-center gap-2 rounded px-2 text-left text-[13px] focus-visible:outline focus-visible:outline-2 focus-visible:outline-focus ${a===f.path?"bg-surface-highest text-on-surface":"hover:bg-surface"}`,children:[e.jsx("span",{className:"flex w-3 shrink-0 items-center",children:f.directory&&e.jsx(Be,{size:12,className:`transition-transform ${b?"rotate-90":""}`})}),e.jsx(j,{size:15,className:`shrink-0 ${f.directory,"text-on-surface-variant"}`}),e.jsx("span",{className:"truncate flex-1",children:f.name}),d&&e.jsx("span",{"data-testid":"file-change-badge",title:d.label,className:`shrink-0 text-xs ${d.conflict?"text-error":"text-warning"}`,children:d.conflict?"U":(S==null?void 0:S.index)==="?"?"?":d.label.slice(0,1)})]}),f.directory&&b&&e.jsx(Rt,{terminalId:t,path:f.path,selected:a,expanded:h,toggle:n,select:o,changes:i})]},f.path)}),((F=g.data)==null?void 0:F.truncated)&&e.jsx("li",{className:"px-3 py-2 text-xs text-on-surface-variant",children:"Showing the first 500 entries."})]})}function va({terminal:t,active:s=!0,paneId:a}){var Q,Z,Y,r,O;const h=`${t.id}:${a}`,n=be.get(h),[o,i]=le(),g=s&&o.get("view")==="files"&&(o.get("paneTerminal")??t.id)===t.id?o.get("file"):null,[m,c]=p.useState(g??(n==null?void 0:n.selected)??null),[l,x]=p.useState(()=>[...new Set([...(n==null?void 0:n.openFiles)??[],...g?[g]:[]])]),[F,f]=p.useState((n==null?void 0:n.dirtyFiles)??new Set),[b,S]=p.useState(!1),[d,j]=p.useState(!0),[v,w]=p.useState(!1),[y,L]=p.useState((n==null?void 0:n.expanded)??new Set);p.useEffect(()=>{for(be.delete(h),be.set(h,{selected:m,openFiles:l,dirtyFiles:F,expanded:y});be.size>64;){const k=be.keys().next().value;if(k===void 0)break;be.delete(k)}},[h,m,l,F,y]),p.useEffect(()=>{if(s&&(g!==m&&(c(g),S(!1)),g)){x(N=>N.includes(g)?N:[...N,g]);const k=g.split("/");L(N=>new Set([...N,...k.slice(0,-1).map((E,_)=>k.slice(0,_+1).join("/"))]))}},[g,s,m]);const z=he(),P=te({queryKey:["checkout-files",t.id,""],queryFn:()=>W.git.files(t.id,"")}),D=te({queryKey:["checkout-files",t.id,m],queryFn:()=>W.git.files(t.id,m??""),enabled:m!==null,staleTime:Number.POSITIVE_INFINITY,refetchOnWindowFocus:!1}),V=((Q=P.data)==null?void 0:Q.root)??t.cwd??"",I=te({queryKey:["git",t.id,"status"],queryFn:()=>W.git.status(t.id)}),U=V.replace(/\\/g,"/").replace(/\/$/,"").split("/").pop()||V||"Files";function A(k){k!==m&&(b&&!window.confirm("Leave this file with unsaved changes? Your draft will be kept in this page.")||(S(!1),k&&x(N=>N.includes(k)?N:[...N,k]),c(k),w(!1),i(N=>{const E=new URLSearchParams(N);return E.set("view","files"),E.set("paneTerminal",t.id),k===null?E.delete("file"):E.set("file",k),E})))}function C(k){const N=l.filter(E=>E!==k);if(m===k){if(b&&!window.confirm("Close this file with unsaved changes? Your draft will be kept in this page."))return;S(!1);const E=N[Math.max(0,l.indexOf(k)-1)]??null;c(E),i(_=>{const B=new URLSearchParams(_);return E?B.set("file",E):B.delete("file"),B})}else if(F.has(k)&&!window.confirm("Close this file with unsaved changes? Your draft will be kept in this page."))return;x(N)}function K(k){if(!(k.target instanceof HTMLButtonElement))return;const N=[...k.currentTarget.querySelectorAll("button[data-path]")],E=N.indexOf(k.target),_=k.target.dataset.path??"",B=k.target.getAttribute("aria-expanded");let M;if(k.key==="ArrowDown")M=N[E+1];else if(k.key==="ArrowUp")M=N[E-1];else if(k.key==="Home")M=N[0];else if(k.key==="End")M=N[N.length-1];else if(k.key==="ArrowRight")B==="false"?k.target.click():B==="true"&&(M=N[E+1]);else if(k.key==="ArrowLeft")B==="true"?k.target.click():M=N.find(ae=>ae.dataset.path===_.split("/").slice(0,-1).join("/"));else return;k.preventDefault(),M==null||M.focus()}return e.jsxs("div",{"data-testid":"file-panel",className:"file-panel flex flex-1 min-h-0 min-w-0 flex-col overflow-hidden text-sm",children:[e.jsxs("header",{className:"flex shrink-0 items-center gap-2 border-b border-surface-highest px-3 py-2",children:[e.jsx("span",{className:"min-w-0 flex-1 text-xs font-medium text-on-surface-variant",children:"Explorer"}),m!==null&&e.jsx("button",{type:"button","data-testid":"files-browser-toggle","aria-expanded":v,onClick:()=>w(!v),className:"md:hidden min-h-11 rounded-md px-2 text-sm text-primary hover:bg-surface",children:v?"Show document":"Browse files"}),e.jsx("button",{type:"button","data-testid":"files-collapse","aria-label":"Collapse all folders",title:"Collapse all folders",disabled:y.size===0,onClick:()=>L(new Set),className:"min-h-11 min-w-11 sm:min-h-8 sm:min-w-8 inline-flex items-center justify-center rounded-md p-1 text-on-surface-variant hover:bg-surface hover:text-primary disabled:opacity-30 disabled:hover:bg-transparent",children:e.jsx(Rs,{size:14})}),e.jsx("button",{type:"button","data-testid":"files-refresh","aria-label":"Refresh files",title:"Refresh files",onClick:()=>void z.invalidateQueries({queryKey:["checkout-files",t.id]}),className:"min-h-11 min-w-11 sm:min-h-8 sm:min-w-8 inline-flex items-center justify-center rounded-md p-1 text-on-surface-variant hover:bg-surface hover:text-primary",children:e.jsx(Ge,{size:14,className:P.isFetching?"animate-spin":""})})]}),l.length>0&&e.jsx("nav",{"data-testid":"file-tabs","aria-label":"Open files",className:"flex shrink-0 min-w-0 overflow-x-auto border-b border-outline-variant bg-background",children:l.map(k=>e.jsxs("div",{className:`flex shrink-0 items-center border-r border-outline-variant ${k===m?"bg-surface":""}`,children:[e.jsxs("button",{type:"button","data-testid":"file-tab","data-path":k,"aria-current":k===m?"page":void 0,title:k,onClick:()=>A(k),className:`flex items-center gap-2 max-w-56 min-h-11 sm:min-h-9 pl-3 pr-1 text-xs ${k===m?"text-on-surface":"text-on-surface-variant"}`,children:[e.jsx(De,{size:13,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:k.split("/").pop()}),F.has(k)&&e.jsx("span",{title:"Unsaved changes",children:"●"})]}),e.jsx("button",{type:"button","data-testid":"file-tab-close","aria-label":`Close ${k}`,title:`Close ${k}`,onClick:()=>C(k),className:"flex min-h-11 min-w-11 sm:min-h-9 sm:min-w-8 items-center justify-center text-on-surface-variant hover:text-on-surface",children:e.jsx(ge,{size:12})})]},k))}),e.jsxs("div",{className:"file-panel-body","data-preview":m!==null,"data-browser-open":v,children:[e.jsxs("nav",{"aria-label":"Project files","data-testid":"files-tree",onKeyDown:K,className:"file-panel-tree overflow-auto p-2",children:[e.jsxs("button",{type:"button","data-testid":"files-root","data-path":"",title:V,"aria-expanded":d,onClick:()=>j(k=>!k),className:"mb-1 flex min-h-11 sm:min-h-8 w-full min-w-0 items-center gap-2 rounded px-2 text-left text-[13px] font-medium hover:bg-surface focus-visible:outline focus-visible:outline-2 focus-visible:outline-focus",children:[e.jsx(Be,{size:12,className:`shrink-0 transition-transform ${d?"rotate-90":""}`}),e.jsx(He,{size:16,className:"shrink-0 text-primary"}),e.jsx("span",{className:"truncate",children:U})]}),d&&e.jsx("div",{className:"ml-3 border-l border-outline/20 pl-1",children:e.jsx(Rt,{terminalId:t.id,path:"",selected:m,expanded:y,select:A,toggle:k=>L(N=>{const E=new Set(N);return E.has(k)?E.delete(k):E.add(k),E}),changes:((Z=I.data)==null?void 0:Z.files)??[]})})]}),m!==null&&e.jsxs("section",{"aria-label":"File preview",className:"file-panel-preview flex flex-col",children:[e.jsxs("header",{className:"flex shrink-0 items-center gap-2 bg-background px-3 py-1.5",children:[e.jsx(De,{size:14,className:"shrink-0 text-primary"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"truncate text-xs font-medium",children:[m.split("/").pop(),b&&e.jsx("span",{className:"ml-2 text-primary",title:"Unsaved changes",children:"●"})]}),e.jsx("p",{title:m,className:"truncate pt-0.5 text-xs text-on-surface-variant",children:m})]}),e.jsx("button",{type:"button","data-testid":"file-preview-close","aria-label":"Close file preview",onClick:()=>A(null),className:"min-h-11 min-w-11 sm:min-h-8 sm:min-w-8 inline-flex items-center justify-center rounded-md p-1 text-on-surface-variant hover:bg-surface",children:e.jsx(ge,{size:14})})]}),D.isPending&&e.jsx("p",{className:"p-3 text-xs text-on-surface-variant",children:"Loading preview…"}),D.error&&e.jsx("p",{role:"alert",className:"p-3 text-xs text-error",children:D.error.message}),((Y=D.data)==null?void 0:Y.binary)&&e.jsx("p",{className:"p-3 text-xs text-on-surface-variant",children:"Binary file; text preview unavailable."}),((r=D.data)==null?void 0:r.content)!=null&&e.jsx(p.Suspense,{fallback:e.jsx("p",{className:"p-3 text-xs text-on-surface-variant",children:"Loading editor…"}),children:e.jsx(ba,{terminalId:t.id,path:m,content:D.data.content,readOnly:D.data.truncated,onDirty:k=>{S(k),f(N=>{if(N.has(m)===k)return N;const E=new Set(N);return k?E.add(m):E.delete(m),E})}},`${t.id}:${m}`)}),((O=D.data)==null?void 0:O.truncated)&&e.jsx("p",{className:"px-3 py-1 text-xs text-on-surface-variant",children:"Preview limited to 200 KB."})]})]})]})}function _t(t){let s=0,a=0,h=!1,n=0;return t.split(`
115
+ `).map(o=>{const i=n;n+=o.length+1;const g=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(o);return g?(s=Number(g[1]),a=Number(g[2]),h=!0,{id:i,text:o,kind:"hunk",old:null,next:null}):(o.startsWith("diff --git")&&(h=!1),h&&o.startsWith("+")?{id:i,text:o,kind:"add",old:null,next:a++}:h&&o.startsWith("-")?{id:i,text:o,kind:"remove",old:s++,next:null}:h&&o.startsWith(" ")?{id:i,text:o,kind:"context",old:s++,next:a++}:{id:i,text:o,kind:"meta",old:null,next:null})})}function zt(t){var a,h;const s=[];for(let n=0;n<t.length;){const o=t[n];if(!o)break;if(o.kind==="add"||o.kind==="remove"){const i=[],g=[];for(;((a=t[n])==null?void 0:a.kind)==="remove"||((h=t[n])==null?void 0:h.kind)==="add";){const m=t[n];if(!m)break;m.kind==="remove"?i.push(m):g.push(m),n++}for(let m=0;m<Math.max(i.length,g.length);m++)s.push({id:`${o.id}:${m}`,left:i[m]??null,right:g[m]??null,full:null})}else s.push({id:String(o.id),left:o.kind==="context"?o:null,right:o.kind==="context"?o:null,full:o.kind==="context"?null:o}),n++}return s}function ot({terminalId:t,path:s,staged:a,sideBySide:h}){var x,F;const n=p.useRef(null),o=he(),i=["git",t,"diff",a,s],[g,m]=p.useState(()=>o.getQueryData(i)!==void 0);p.useEffect(()=>{if(g)return;const f=n.current;if(!f)return;const b=new IntersectionObserver(S=>{S.some(d=>d.isIntersecting)&&m(!0)},{rootMargin:"300px"});return b.observe(f),()=>b.disconnect()},[g]);const c=te({queryKey:i,queryFn:()=>W.git.diff(t,a,s),enabled:g}),l=(x=c.data)!=null&&x.diff?_t(c.data.diff).filter(f=>f.kind!=="meta"):[];return e.jsxs("div",{ref:n,"data-testid":a?"git-diff-staged-section":"git-diff-working-section",className:"border-t border-surface-highest",children:[e.jsxs("div",{className:"flex justify-between p-2 text-xs text-on-surface-variant",children:[e.jsx("span",{children:a?"Staged":"Unstaged"}),c.data&&e.jsxs("span",{children:[e.jsxs("span",{className:"text-secondary",children:["+",l.filter(f=>f.kind==="add").length]})," ",e.jsxs("span",{className:"text-error",children:["−",l.filter(f=>f.kind==="remove").length]})]})]}),c.error&&e.jsx("p",{role:"alert",className:"p-3",children:c.error.message}),e.jsx("div",{"data-testid":"git-diff",className:"overflow-auto font-mono text-xs",children:c.isPending?e.jsx("p",{className:"p-3 text-on-surface-variant",children:"Loading diff…"}):l.length?h?e.jsxs("div",{"data-testid":"git-diff-side-by-side",className:"min-w-[640px]",children:[e.jsxs("div",{className:"grid grid-cols-2 border-b border-outline-variant text-on-surface-variant",children:[e.jsx("span",{className:"px-3 py-1",children:"Before"}),e.jsx("span",{className:"border-l border-outline-variant px-3 py-1",children:"After"})]}),zt(l).map(f=>f.full?e.jsx("div",{className:"whitespace-pre bg-surface px-3 text-on-surface-variant",children:f.full.text||" "},f.id):e.jsx("div",{className:"grid grid-cols-2",children:["left","right"].map(b=>{const S=f[b];return e.jsxs("div",{"data-testid":S?`git-diff-${S.kind}`:"git-diff-empty",className:`flex min-w-0 whitespace-pre ${b==="right"?"border-l border-outline-variant":""} ${(S==null?void 0:S.kind)==="remove"?"bg-error/10 text-error":(S==null?void 0:S.kind)==="add"?"bg-secondary/10 text-secondary":""}`,children:[e.jsx("span",{className:"w-12 shrink-0 pr-2 text-right select-none text-on-surface-variant",children:b==="left"?S==null?void 0:S.old:S==null?void 0:S.next}),e.jsx("span",{className:"min-w-0 flex-1 whitespace-pre-wrap break-all pr-3",children:(S==null?void 0:S.text.slice(1))||" "})]},b)})},f.id))]}):l.map(f=>e.jsxs("div",{"data-testid":`git-diff-${f.kind}`,className:`flex min-w-max whitespace-pre ${f.kind==="add"?"bg-secondary/10 text-secondary":f.kind==="remove"?"bg-error/10 text-error":f.kind==="hunk"?"bg-surface text-on-surface-variant":f.kind==="meta"?"text-on-surface-variant":""}`,children:[e.jsx("span",{className:"w-10 shrink-0 text-right pr-2 select-none opacity-60",children:f.old}),e.jsx("span",{className:"w-10 shrink-0 text-right pr-2 select-none opacity-60",children:f.next}),e.jsx("span",{className:"pr-3",children:f.text||" "})]},f.id)):e.jsx("p",{className:"p-3 text-on-surface-variant",children:"No text changes in this view."})}),((F=c.data)==null?void 0:F.truncated)&&e.jsx("p",{className:"p-2 text-on-surface-variant",children:"Diff truncated at 200 KB."})]})}function ya({terminalId:t,file:s,open:a,checked:h,select:n,toggle:o,sideBySide:i=!1,openFile:g}){const{staged:m,working:c,conflict:l,label:x}=ne(s);return e.jsxs("section",{"data-testid":"git-diff-file","data-path":s.path,className:"border-t border-outline-variant overflow-hidden",children:[e.jsxs("div",{"data-testid":"git-status-file",className:"flex items-center px-2",children:[e.jsx("input",{type:"checkbox","aria-label":`Select ${s.path}`,checked:h,onChange:F=>n(F.target.checked),className:"shrink-0"}),e.jsxs("button",{type:"button","data-testid":"git-diff-file-toggle","aria-expanded":a,onClick:o,className:"flex-1 min-w-0 min-h-11 sm:min-h-9 flex items-center gap-2 text-left px-2 py-2 hover:bg-surface",children:[a?e.jsx(Te,{size:16,className:"shrink-0"}):e.jsx(Be,{size:16,className:"shrink-0"}),e.jsxs("span",{className:"flex-1 min-w-0 break-all font-mono text-xs",children:[s.original?`${s.original} → `:"",s.path]}),e.jsxs("span",{"data-testid":"git-file-status",className:"shrink-0 text-xs text-on-surface-variant text-right",children:[x," · ",l?"Resolve then stage":m?c?"Staged + Unstaged":"Staged":"Unstaged"]})]}),g&&e.jsx("button",{type:"button","data-testid":"git-open-file",onClick:()=>g(s.path),className:"shrink-0 min-h-11 px-2 text-xs text-primary hover:bg-surface",title:`Open ${s.path} in Files`,children:"Open file"})]}),a&&e.jsxs(e.Fragment,{children:[m&&e.jsx(ot,{terminalId:t,path:s.path,staged:!0,sideBySide:i}),c&&e.jsx(ot,{terminalId:t,path:s.path,staged:!1,sideBySide:i})]})]})}function Le({terminalId:t,number:s,input:a,label:h,onSent:n,onClose:o,drafts:i,disabled:g=!1}){const m=a.kind==="inline"?`inline:${a.path}:${a.side}:${a.line}`:a.kind==="reply"?`reply:${a.comment_id}`:"discussion",[c,l]=p.useState(()=>i.get(m)??""),x=p.useRef(null);p.useEffect(()=>{var b;(b=x.current)==null||b.focus()},[]);const F=je({mutationKey:["git",t,"pull",s,"comment"],mutationFn:()=>W.git.postPullComment(t,s,{...a,body:c}),onSuccess:()=>{l(""),i.delete(m),n()},retry:!1}),f=Nt({mutationKey:["git",t,"pull",s,"comment"]})>0;return e.jsxs("form",{className:"pr-comment-composer",onKeyDown:b=>{b.key==="Escape"&&!b.nativeEvent.isComposing&&!f&&(b.preventDefault(),b.stopPropagation(),o())},onSubmit:b=>{b.preventDefault(),c.trim()&&!f&&!g&&F.mutate()},children:[e.jsxs("div",{className:"pr-composer-heading",children:[e.jsx("label",{htmlFor:`pr-draft-${t}-${s}-${m}`,children:h}),e.jsx("button",{type:"button",className:"git-icon-button","data-testid":"pr-comment-close","aria-label":"Close comment editor",title:"Close comment editor (draft retained)",disabled:f,onClick:o,children:e.jsx(ge,{size:14})})]}),e.jsx("textarea",{ref:x,id:`pr-draft-${t}-${s}-${m}`,"data-testid":"pr-comment-input",className:"terminal-field",value:c,maxLength:2e4,onChange:b=>{l(b.target.value),i.set(m,b.target.value)},placeholder:"Write a comment…",rows:3,disabled:f}),e.jsx("div",{children:e.jsx("button",{type:"submit","data-testid":"pr-comment-send",disabled:!c.trim()||f||g,children:f?"Sending…":"Send comment"})}),F.error&&e.jsxs("p",{role:"alert",children:[F.error.message," Your draft is retained. Check GitHub before retrying if the result is uncertain."]})]})}function we({comment:t}){var a;const s=/^https:\/\/github\.com\//.test(t.html_url)?t.html_url:void 0;return e.jsxs("article",{className:"pr-comment","data-testid":"pr-comment",children:[e.jsxs("div",{children:[e.jsx("strong",{children:((a=t.user)==null?void 0:a.login)??"Deleted user"}),t.state&&e.jsx("span",{children:t.state.replace(/_/g," ").toLowerCase()}),t.path&&e.jsxs("span",{children:[t.path,":",t.line??t.original_line??"file",t.line===null?" · Outdated":""]}),s&&e.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer","aria-label":"Open comment on GitHub",children:e.jsx(Qe,{size:12})})]}),e.jsx("p",{children:t.body})]})}function ka({patch:t,split:s,onComment:a,commentable:h,inline:n}){const o=_t(t).filter(c=>c.kind!=="meta"),i=c=>n&&(n.side==="LEFT"?c==null?void 0:c.old:c==null?void 0:c.next)===n.line,g=n&&o.some(i);function m(c,l){const x=l==="LEFT"?c==null?void 0:c.old:c==null?void 0:c.next;return x?e.jsx("button",{type:"button","data-testid":"pr-comment-line","data-line":x,"data-side":l,className:"pr-line-number",disabled:!h,title:`Comment on ${l==="LEFT"?"old":"new"} line ${x}`,"aria-label":`Comment on ${l==="LEFT"?"old":"new"} line ${x}`,onClick:F=>a(x,l,F.currentTarget),children:x}):e.jsx("span",{className:"pr-line-number"})}return e.jsxs("div",{"data-testid":"pr-diff",className:`pr-diff ${s?"pr-diff-split":""}`,children:[s?zt(o).map(c=>c.full?e.jsx("div",{className:"pr-diff-hunk",children:c.full.text},c.id):e.jsxs(p.Fragment,{children:[e.jsx("div",{className:"pr-diff-pair",children:["left","right"].map(l=>{const x=c[l];return e.jsxs("div",{className:`pr-diff-line pr-line-${(x==null?void 0:x.kind)??"empty"}`,children:[m(x,l==="left"?"LEFT":"RIGHT"),e.jsx("code",{children:(x==null?void 0:x.text.slice(1))??" "})]},l)})}),n&&i(n.side==="LEFT"?c.left:c.right)&&e.jsx("div",{className:"pr-diff-comment-row",children:n.content})]},c.id)):o.map(c=>c.kind==="hunk"?e.jsx("div",{className:"pr-diff-hunk",children:c.text},c.id):e.jsxs(p.Fragment,{children:[e.jsxs("div",{className:`pr-diff-line pr-line-${c.kind}`,children:[m(c,"LEFT"),m(c,"RIGHT"),e.jsx("code",{children:c.text})]}),n&&i(c)&&e.jsx("div",{className:"pr-diff-comment-row",children:n.content})]},c.id)),n&&!g&&e.jsxs("div",{className:"pr-diff-comment-row",children:[e.jsx("p",{className:"pr-review-notice",children:"The selected line is no longer in this diff. Choose a current line to continue."}),n.content]})]})}function wa({terminalId:t,number:s,active:a}){const h=he(),n=Nt({mutationKey:["git",t,"pull",s,"comment"]})>0,o=p.useRef(new Map),i=["git",t,"pull",s],g=te({queryKey:i,queryFn:()=>W.git.pullReview(t,s),enabled:a,staleTime:3e4,retry:!1}),[m,c]=p.useState("files"),[l,x]=p.useState(""),[F,f]=p.useState(null),[b,S]=p.useState(!1),[d,j]=p.useState(null),[v,w]=p.useState(null),[y,L]=p.useState(!1),[z,P]=p.useState(!1),D=p.useRef(new Map),V=p.useRef(null),I=p.useRef(null),U=p.useRef(null),A=p.useRef(null),C=g.data,K=(C==null?void 0:C.files.filter(r=>`${r.filename} ${r.previous_filename??""}`.toLowerCase().includes(l.toLowerCase())))??[],Q=K.find(r=>r.filename===F)??K.find(r=>r.patch)??K[0],Z=()=>{P(!0),h.invalidateQueries({queryKey:i})},Y=r=>{f(r),P(!1),requestAnimationFrame(()=>{var O;return(O=D.current.get(r))==null?void 0:O.scrollIntoView({block:"start"})})};return e.jsxs("div",{"data-testid":"pr-review-panel",className:"pr-review-panel",style:{display:a?void 0:"none"},children:[e.jsxs("header",{className:"pr-review-heading",children:[e.jsxs("div",{children:[e.jsx("strong",{children:(C==null?void 0:C.title)??`Pull request #${s}`}),C&&e.jsxs("p",{children:[C.author," · ",C.branch," into ",C.base," · ",C.head.slice(0,7)]})]}),e.jsx("button",{type:"button",className:"git-icon-button","data-testid":"pr-refresh",title:"Refresh PR","aria-label":"Refresh PR",onClick:()=>void g.refetch(),children:e.jsx(Ge,{size:14})})]}),g.isPending&&e.jsx("p",{className:"git-review-empty",children:"Loading pull request…"}),g.error&&e.jsx("p",{role:"alert",className:"git-review-error",children:g.error.message}),C&&e.jsxs(e.Fragment,{children:[e.jsxs("fieldset",{className:"pr-review-tabs","aria-label":"Pull request review",children:[e.jsxs("button",{type:"button","aria-pressed":m==="files","data-testid":"pr-files-tab",onClick:()=>c("files"),children:["Files changed ",e.jsx("span",{children:C.changed_files})]}),e.jsxs("button",{type:"button","aria-pressed":m==="discussion","data-testid":"pr-discussion-tab",onClick:()=>c("discussion"),children:["Discussion"," ",e.jsx("span",{children:C.discussion.length+C.reviews.length+C.comments.length})]})]}),C.truncated&&e.jsx("p",{className:"pr-review-notice",children:"Showing limited results. Open GitHub for the full review."}),C.state!=="open"&&e.jsxs("p",{className:"pr-review-notice",children:["This PR is ",C.state,". Comments are read-only here."]}),z&&e.jsx("p",{role:"status",className:"pr-review-notice",children:"Comment sent to GitHub."}),e.jsxs("div",{className:"pr-files-view",style:{display:m==="files"?void 0:"none"},children:[e.jsxs("div",{className:"git-review-filters",children:[e.jsx("input",{"data-testid":"pr-file-filter",className:"terminal-field","aria-label":"Filter PR files",placeholder:"Find a PR file…",value:l,onChange:r=>x(r.target.value)}),e.jsxs("fieldset",{className:"git-diff-layout","aria-label":"PR diff layout",children:[e.jsxs("button",{type:"button","data-testid":"pr-layout-unified","aria-pressed":!b,onClick:()=>S(!1),title:"Unified",children:[e.jsx(wt,{size:14}),e.jsx("span",{children:"Unified"})]}),e.jsxs("button",{type:"button","data-testid":"pr-layout-split","aria-pressed":b,onClick:()=>S(!0),title:"Split",children:[e.jsx(Ve,{size:14}),e.jsx("span",{children:"Split"})]})]})]}),e.jsx("div",{className:"pr-file-picker",children:e.jsx(xe,{"aria-label":"PR file","data-testid":"pr-file-select",value:(Q==null?void 0:Q.filename)??"",onChange:r=>Y(r.target.value),children:K.map(r=>e.jsx("option",{value:r.filename,children:r.filename},r.filename))})}),e.jsxs("div",{className:"git-review-body",children:[e.jsxs("aside",{className:"git-change-list","aria-label":"PR changed files",children:[e.jsxs("div",{className:"git-list-heading",children:["Files changed",e.jsx("span",{children:K.length})]}),e.jsx("section",{children:K.map(r=>e.jsxs("button",{type:"button","data-testid":"pr-file-entry","aria-current":(Q==null?void 0:Q.filename)===r.filename?"true":void 0,title:r.filename,onClick:()=>Y(r.filename),children:[e.jsx("span",{className:"git-change-name",children:r.filename.split("/").pop()}),e.jsx("span",{className:"git-change-parent",children:r.filename.includes("/")?r.filename.slice(0,r.filename.lastIndexOf("/")):""}),e.jsx("span",{className:"text-on-surface-variant",children:r.status.slice(0,1).toUpperCase()})]},r.filename))})]}),e.jsxs("div",{className:"git-diff-scroll",ref:V,"data-testid":"pr-diff-scroll",onScroll:()=>{var k;const r=((k=V.current)==null?void 0:k.getBoundingClientRect().top)??0,O=K.find(N=>{var _;const E=(_=D.current.get(N.filename))==null?void 0:_.getBoundingClientRect();return E&&E.bottom>r+40});O&&f(O.filename)},children:[K.length===0&&e.jsx("p",{className:"git-review-empty",children:"No PR files match this filter."}),K.map(r=>{const O=C.comments.filter(N=>N.path===r.filename),k=(d==null?void 0:d.path)===r.filename&&C.state==="open"?e.jsxs("div",{"data-testid":"pr-inline-composer",className:"pr-inline-compose",style:{display:d.path===r.filename?void 0:"none"},children:[e.jsx(it,{size:14}),e.jsx(Le,{drafts:o.current,disabled:d.head!==C.head,terminalId:t,number:s,input:{kind:"inline",...d,body:""},label:`Comment on ${d.path}, ${d.side==="LEFT"?"old":"new"} line ${d.line}`,onClose:()=>{var E,_;j(null);const N=(E=I.current)!=null&&E.isConnected?I.current:(_=D.current.get(d.path))==null?void 0:_.querySelector('[data-testid="pr-comment-line"][data-side="'+d.side+'"][data-line="'+d.line+'"]');N==null||N.focus()},onSent:()=>{Z(),j(N=>(N==null?void 0:N.path)===d.path&&N.side===d.side&&N.line===d.line?null:N)}},`inline:${d.path}:${d.side}:${d.line}`),d.head!==C.head&&e.jsx("p",{role:"alert",children:"The PR has new commits. Select a line in the latest diff before sending this draft."})]}):null;return e.jsxs("section",{"data-testid":"pr-file-diff","data-path":r.filename,ref:N=>{N?D.current.set(r.filename,N):D.current.delete(r.filename)},children:[e.jsxs("div",{className:"pr-file-heading",children:[e.jsxs("span",{children:[r.previous_filename?`${r.previous_filename} → `:"",r.filename]}),e.jsxs("span",{children:[e.jsxs("span",{className:"text-secondary",children:["+",r.additions]})," ",e.jsxs("span",{className:"text-error",children:["−",r.deletions]})]})]}),r.patch?e.jsx(ka,{inline:d&&k?{line:d.line,side:d.side,content:k}:void 0,patch:r.patch,split:b,commentable:C.state==="open"&&!n,onComment:(N,E,_)=>{if(I.current=_,(d==null?void 0:d.path)===r.filename&&d.head!==C.head){const B=`inline:${d.path}:${d.side}:${d.line}`,M=`inline:${r.filename}:${E}:${N}`,ae=o.current.get(B);ae&&!o.current.get(M)&&o.current.set(M,ae)}j({path:r.filename,head:C.head,line:N,side:E}),P(!1)}}):e.jsx("p",{className:"pr-review-notice",children:"No text patch available for this file. Open the PR in GitHub to inspect binary or unavailable changes."}),r.patch_truncated&&e.jsx("p",{className:"pr-review-notice",children:"Patch truncated. Open GitHub for the complete diff."}),O.filter(N=>!N.in_reply_to_id).map(N=>{var E;return e.jsxs("section",{className:"pr-thread","data-testid":"pr-review-thread",children:[e.jsx(we,{comment:N}),O.filter(_=>_.in_reply_to_id===N.id).map(_=>e.jsx(we,{comment:_},_.id)),C.state==="open"&&e.jsx("button",{type:"button","data-testid":"pr-reply",disabled:n,onClick:_=>{U.current=_.currentTarget,w(v===N.id?null:N.id)},children:"Reply"}),v===N.id&&C.state==="open"&&e.jsx(Le,{drafts:o.current,terminalId:t,number:s,input:{kind:"reply",head:C.head,comment_id:N.id,body:""},label:`Reply to ${((E=N.user)==null?void 0:E.login)??"reviewer"}`,onClose:()=>{var _;w(null),(_=U.current)==null||_.focus()},onSent:()=>{Z(),w(_=>_===N.id?null:_)}})]},N.id)})]},r.filename)})]})]})]}),e.jsxs("div",{"data-testid":"pr-discussion-panel",className:"pr-discussion",style:{display:m==="discussion"?void 0:"none"},children:[e.jsxs("article",{className:"pr-description",children:[e.jsx("h3",{children:"Description"}),e.jsx("p",{children:C.body||"No description provided."})]}),[...C.discussion,...C.reviews].sort((r,O)=>r.created_at.localeCompare(O.created_at)).map(r=>e.jsx(we,{comment:r},`${r.state??"comment"}:${r.id}`)),C.comments.filter(r=>!r.in_reply_to_id).map(r=>e.jsxs("section",{className:"pr-thread",children:[e.jsx(we,{comment:r}),C.comments.filter(O=>O.in_reply_to_id===r.id).map(O=>e.jsx(we,{comment:O},O.id)),C.files.some(O=>O.filename===r.path)&&e.jsx("button",{type:"button","data-testid":"pr-open-thread",onClick:()=>{x(""),c("files"),r.path&&Y(r.path)},children:"Open thread in Files"})]},`thread:${r.id}`)),C.state==="open"&&!y&&e.jsxs("button",{type:"button",className:"pr-add-comment","data-testid":"pr-add-comment",disabled:n,ref:A,onClick:()=>L(!0),children:[e.jsx(it,{size:14})," Add comment"]}),C.state==="open"&&y&&e.jsx(Le,{drafts:o.current,terminalId:t,number:s,input:{kind:"discussion",head:C.head,body:""},label:"Comment on this PR",onClose:()=>{L(!1),requestAnimationFrame(()=>{var r;return(r=A.current)==null?void 0:r.focus()})},onSent:()=>{Z(),L(!1)}})]})]})]})}function Na({terminal:t}){var f,b,S;const[s]=le(),[a,h]=p.useState(!1),[n,o]=p.useState(""),i=p.useRef(null),g=p.useRef(null),[m,c]=p.useState({left:8,top:8});p.useEffect(()=>{if(!a)return;const d=v=>{var w,y;!((w=i.current)!=null&&w.contains(v.target))&&!((y=g.current)!=null&&y.contains(v.target))&&h(!1)},j=v=>{var w;v.key==="Escape"&&(h(!1),(w=i.current)==null||w.focus())};return document.addEventListener("pointerdown",d),document.addEventListener("keydown",j),()=>{document.removeEventListener("pointerdown",d),document.removeEventListener("keydown",j)}},[a]);const l=gt(),x=ns(),F=te({queryKey:["git",t.id,"status"],queryFn:()=>W.git.status(t.id),enabled:a});return e.jsxs("div",{className:"relative shrink-0",children:[e.jsx("button",{ref:i,type:"button","data-testid":"terminal-task-link-toggle","aria-label":"Link ORC task",title:"Link ORC task","aria-expanded":a,onClick:()=>{var j;const d=(j=i.current)==null?void 0:j.getBoundingClientRect();d&&c({left:Math.max(8,Math.min(window.innerWidth-304,d.right-288)),top:Math.max(8,Math.min(window.innerHeight-240,d.bottom+8))}),h(!a)},className:"git-icon-button",children:e.jsx(is,{size:14})}),a&&rs.createPortal(e.jsxs("div",{ref:g,style:m,"data-testid":"terminal-task-link-menu",className:"fixed z-50 w-72 max-w-[calc(100vw-2rem)] max-h-[calc(100vh-16px)] overflow-auto bg-surface-high border border-outline-variant shadow-xl rounded p-3 space-y-3 text-sm",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("strong",{children:"Link this terminal checkout"}),e.jsx("button",{className:"min-h-11 min-w-11 inline-flex items-center justify-center rounded-md hover:bg-surface",type:"button","aria-label":"Close task linking",onClick:()=>h(!1),children:e.jsx(ge,{size:14})})]}),e.jsxs(xe,{"data-testid":"git-link-task","aria-label":"Task to link",value:n,onChange:d=>o(d.target.value),children:[e.jsx("option",{value:"",children:"Choose task"}),(f=l.data)==null?void 0:f.map(d=>e.jsx("option",{value:d.id,children:d.title},d.id))]}),e.jsx("button",{type:"button","data-testid":"git-link-save",disabled:!n||x.isPending||F.isPending||!!F.error,onClick:()=>{var d,j,v;return x.mutate({id:n,git_repo:((d=F.data)==null?void 0:d.root)??null,git_branch:((j=F.data)==null?void 0:j.branch)??null,git_worktree:((v=F.data)==null?void 0:v.root)??t.cwd})},className:"min-h-11 sm:min-h-8 rounded-md text-primary disabled:opacity-40",children:"Link checkout"}),x.isSuccess&&e.jsx(ve,{"data-testid":"git-linked-task",to:ue(`/tasks/${n}`,s.get("project")??"all",s.toString()),className:"block text-primary",children:"Open linked task"}),(x.error||F.error)&&e.jsx("p",{role:"alert",children:((b=x.error)==null?void 0:b.message)??((S=F.error)==null?void 0:S.message)})]}),document.body)]})}function fe(t,s){const a=n=>n.replace(/\\/g,"/").replace(/\/$/,"");return/^[A-Za-z]:[\\/]/.test(t)?a(t).toLowerCase()===a(s??"").toLowerCase():a(t)===a(s??"")}function Ca({terminal:t,paneId:s}){var Re,R,G,ee,se,me,de,ye,Ye,Xe,Ze,Je,et;const{create:a}=Se(),h=bt(),[n,o]=le(),i=he(),[g,m]=p.useState(!1),[c,l]=p.useState(!1),[x,F]=p.useState(!1),[f,b]=p.useState(null),S=p.useRef(new Map),[d,j]=p.useState([]),[v,w]=p.useState(""),[y,L]=p.useState([]),[z,P]=p.useState(""),[D,V]=p.useState("all"),[I,U]=p.useState(!1),A=te({queryKey:["git",t.id,"status"],queryFn:()=>W.git.status(t.id)}),C=te({queryKey:["git",t.id,"github",(Re=A.data)==null?void 0:Re.branch],queryFn:()=>W.git.checkoutGithub(t.id),enabled:!!((R=A.data)!=null&&R.root),staleTime:6e4}),K=je({mutationFn:u=>W.git.switchBranch(t.id,u),onSuccess:()=>{j([]),i.invalidateQueries({queryKey:["git",t.id]}),i.invalidateQueries({queryKey:["worktrees"]})}}),Q=te({queryKey:["worktrees",t.id],queryFn:()=>W.git.terminalWorktrees(t.id),enabled:!!((G=A.data)!=null&&G.root)}),Z=je({mutationFn:async u=>{if(u==="stage"){for(let $=0;$<d.length;$+=100)await W.git.stage(t.id,d.slice($,$+100));return}return u==="commit"?W.git.commit(t.id,v):W.git.addWorktree(t.id)},onSuccess:(u,$)=>{$==="stage"&&j([]),$==="commit"&&w(""),i.invalidateQueries({queryKey:["git",t.id]}),i.invalidateQueries({queryKey:["worktrees"]})}}),Y=je({mutationFn:u=>a({kind:"shell",cwd:u,host:t.host}),onSuccess:u=>{const $=new URLSearchParams(n);$.set("view","git"),$.set("pane",s),$.set("paneTerminal",u.id),$.delete("file"),$.delete("session"),h({pathname:`/terminals/${u.id}`,search:$.toString()})}}),r=A.data,O=((ee=Q.data)==null?void 0:ee.worktrees.slice().sort((u,$)=>Number(fe($.path,(r==null?void 0:r.root)??null))-Number(fe(u.path,(r==null?void 0:r.root)??null))||(u.branch??u.path).localeCompare($.branch??$.path)))??[],k=O.find(u=>fe(u.path,(r==null?void 0:r.root)??null)),N=K.isPending||Y.isPending||Z.isPending,E=r==null?void 0:r.files.some(u=>ne(u).conflict),_=((r==null?void 0:r.files)??[]).filter(u=>{const $=ne(u);return`${u.path} ${u.original??""}`.toLowerCase().includes(z.toLowerCase())&&(D==="all"||D==="staged"&&$.staged||D==="working"&&$.working||D==="conflicts"&&$.conflict)}),B=(se=C.data)==null?void 0:se.items.find(u=>u.kind==="pr"&&u.branch===(r==null?void 0:r.branch)&&/^https:\/\/github[.]com\//.test(u.url)),M=B&&n.get("pr")===String(B.number)&&n.get("pane")===s?"pr":"changes",ae=u=>o($=>{const J=new URLSearchParams($);return u==="pr"&&B?(J.set("pr",String(B.number)),J.set("pane",s),J.set("paneTerminal",t.id),J.set("view","git")):J.delete("pr"),J}),oe=!!B&&!!C.data&&C.data.auth!=="none",T=(r==null?void 0:r.files.filter(u=>ne(u).staged).length)??0,q=[{name:"Conflicts",files:_.filter(u=>ne(u).conflict)},{name:"Staged",files:_.filter(u=>ne(u).staged&&!ne(u).conflict)},{name:"Unstaged",files:_.filter(u=>ne(u).working&&!ne(u).conflict&&u.index!=="?")},{name:"Untracked",files:_.filter(u=>u.index==="?")}].filter(u=>u.files.length>0),ie=(u,$,J)=>j(re=>J?[...new Set([...re,u,...$?[$]:[]])]:re.filter(tt=>tt!==u&&tt!==$)),$e=()=>{A.refetch(),Q.refetch(),C.refetch(),i.invalidateQueries({queryKey:["git",t.id,"diff"]})};return e.jsxs("div",{"data-testid":"terminal-git-panel",className:"git-review","data-files-hidden":c,children:[e.jsxs("div",{className:"git-review-toolbar",children:[e.jsxs("button",{type:"button","data-testid":"git-checkout-toggle",disabled:!(r!=null&&r.root),"aria-expanded":g,"aria-controls":`git-checkout-${s}`,onClick:()=>m(!g),title:"Branch and worktree",className:"git-branch-trigger",children:[e.jsx(Ce,{size:14}),e.jsx("span",{children:(r==null?void 0:r.branch)??(r!=null&&r.root?"Detached HEAD":"Git")}),e.jsx(Te,{size:12,strokeWidth:1.5,className:g?"rotate-180":""})]}),e.jsxs("fieldset",{className:"git-mode-tabs","aria-label":"Git view",children:[e.jsxs("button",{type:"button","data-testid":"git-local-mode","aria-label":"Local changes","aria-pressed":M!=="pr"||!oe,onClick:()=>ae("changes"),children:[e.jsx("span",{className:"git-local-label",children:"Local changes"}),e.jsx("span",{className:"git-local-label-short","aria-hidden":"true",children:"Changes"}),e.jsx("span",{"data-testid":"git-changes-summary",children:(r==null?void 0:r.files.length)??0})]}),oe&&e.jsxs("button",{type:"button","data-testid":"git-pr-mode","aria-pressed":M==="pr",onClick:()=>ae("pr"),children:[e.jsx(St,{size:13}),"PR #",B.number]}),B&&e.jsx("a",{"data-testid":"git-pr-browser",href:B.url,target:"_blank",rel:"noopener noreferrer",title:"Open PR in browser","aria-label":"Open PR in browser",children:e.jsx(Qe,{size:13})})]}),e.jsxs("div",{className:"git-review-toolbar-end",children:[e.jsx("button",{type:"button",className:"git-icon-button git-files-desktop-toggle","data-testid":"git-files-toggle","aria-label":c?"Show changed files":"Hide changed files","aria-expanded":!c,onClick:()=>l(!c),children:c?e.jsx(ea,{size:15}):e.jsx(Zs,{size:15})}),(r==null?void 0:r.root)&&e.jsx(Na,{terminal:t}),e.jsx("button",{type:"button","data-testid":"git-refresh",className:"git-icon-button",onClick:$e,"aria-label":"Refresh Git",title:"Refresh Git",children:e.jsx(Ge,{size:14,className:A.isFetching?"animate-spin":""})})]})]}),(r==null?void 0:r.root)&&e.jsxs("div",{"data-testid":"git-checkout-controls",id:`git-checkout-${s}`,hidden:!g,className:"git-checkout-panel",children:[e.jsxs("div",{className:"flex flex-wrap items-end gap-3 p-3 pt-0",children:[e.jsx("div",{className:"flex w-full max-w-64 items-end gap-2",children:e.jsxs("label",{htmlFor:`git-branch-${s}`,className:"flex-1 min-w-0 text-xs text-on-surface-variant",children:["Branch",e.jsxs(xe,{id:`git-branch-${s}`,"data-testid":"git-branch-select","aria-label":"Branch",value:r.branch??"",disabled:N,className:"",onChange:u=>{const $=O.find(J=>J.branch===u.target.value&&!fe(J.path,r.root));$?Y.mutate($.path):K.mutate(u.target.value)},children:[!r.branch&&e.jsx("option",{value:"",children:"Detached HEAD · Current"}),[...r.branches].sort((u,$)=>+($===r.branch)-+(u===r.branch)||u.localeCompare($)).map(u=>e.jsxs("option",{"data-testid":"git-branch",value:u,"aria-current":u===r.branch?"true":void 0,children:[u,u===r.branch?" · Current":""]},u))]})]})}),e.jsxs("div",{className:"flex min-w-0 flex-1 basis-80 max-w-[32rem] items-end gap-2",children:[e.jsxs("label",{htmlFor:`git-worktree-${s}`,className:"block flex-1 min-w-0 text-xs text-on-surface-variant",children:["Worktree",e.jsxs(xe,{id:`git-worktree-${s}`,"data-testid":"git-worktree-select","aria-label":"Worktree",value:(k==null?void 0:k.path)??r.root,disabled:N,title:(k==null?void 0:k.path)??r.root,className:"block min-h-11 rounded-md w-full border border-control-border bg-background p-2 text-on-surface",onChange:u=>{fe(u.target.value,r.root)||Y.mutate(u.target.value)},children:[!k&&e.jsxs("option",{value:r.root,children:[r.branch??"detached"," · ",r.root," · Current"]}),O.map(u=>e.jsxs("option",{"data-testid":"git-panel-worktree",value:u.path,"aria-current":fe(u.path,r.root)?"true":void 0,children:[u.branch??"detached"," · ",u.path,fe(u.path,r.root)?" · Current":"",u.dirty?" · dirty":""]},u.path))]})]}),e.jsx("button",{type:"button","data-testid":"git-add-worktree",disabled:N,onClick:()=>Z.mutate("worktree"),className:"shrink-0 min-h-11 rounded-md px-2 text-sm text-primary hover:bg-surface disabled:opacity-40",children:"New worktree"})]}),Q.error&&e.jsx("p",{role:"alert",children:Q.error.message}),Y.error&&e.jsx("p",{role:"alert",children:Y.error.message}),K.error&&e.jsx("p",{role:"alert",children:K.error.message})]}),e.jsx("div",{"data-testid":"git-current-pr",className:"border-b border-outline-variant pb-3",children:C.isPending?"Checking open pull requests…":C.error?e.jsx("span",{role:"alert",children:C.error.message}):(me=C.data)!=null&&me.errors.length?e.jsx("span",{role:"alert",children:C.data.errors.map(u=>u.error).join("; ")}):(de=C.data)!=null&&de.items.filter(u=>u.kind==="pr"&&u.state==="open").length?C.data.items.filter(u=>u.kind==="pr"&&u.state==="open").map(u=>e.jsxs("a",{href:u.url,target:"_blank",rel:"noreferrer",className:"block text-primary",children:["Open PR #",u.number,": ",u.title]},u.url)):e.jsx("span",{className:"text-on-surface-variant",children:((ye=C.data)==null?void 0:ye.unavailable_reason)==="no_remote"?"This checkout has no GitHub origin remote.":((Ye=C.data)==null?void 0:Ye.unavailable_reason)==="detached_head"?"Detached HEAD: select a branch to find its pull request.":((Xe=C.data)==null?void 0:Xe.auth)==="none"?"GitHub authentication is unavailable on this terminal's host. Authenticate gh there or configure a GitHub token.":(Ze=C.data)!=null&&Ze.truncated?"No matching PR found in the loaded results (results limited).":"No open PR for this branch."})})]}),(Z.error||A.error)&&e.jsx("p",{role:"alert",className:"git-review-error",children:((Je=Z.error)==null?void 0:Je.message)??((et=A.error)==null?void 0:et.message)}),A.isPending&&e.jsx("p",{className:"git-review-empty",children:"Loading changes…"}),r&&!r.root&&e.jsx("p",{className:"git-review-empty",children:"This folder is not a git repository."}),(r==null?void 0:r.root)&&e.jsxs("div",{className:"git-local-body",style:{display:M==="pr"&&oe?"none":void 0},children:[e.jsxs("div",{className:"git-review-filters",children:[e.jsx("button",{type:"button","data-testid":"git-files-menu",className:"git-icon-button git-files-mobile-toggle","aria-expanded":x,"aria-label":"Show changed files",onClick:()=>F(!x),children:e.jsx(Ct,{size:15})}),e.jsxs("label",{className:"git-select-visible",title:"Select all displayed changes",children:[" ",e.jsx("input",{type:"checkbox","data-testid":"git-select-all","aria-label":"Select all displayed changes",disabled:_.length===0,checked:_.length>0&&_.every(u=>d.includes(u.path)),onChange:u=>j(u.target.checked?[...new Set(_.flatMap($=>[$.path,...$.original?[$.original]:[]]))]:[])}),e.jsx("span",{className:"sr-only",children:"Select all displayed changes"})]}),e.jsxs("div",{className:"git-file-search",children:[e.jsx(ls,{size:13,"aria-hidden":"true"}),e.jsx("input",{"data-testid":"git-file-filter","aria-label":"Filter changed files",placeholder:"Find a changed file…",value:z,onChange:u=>{P(u.target.value),j([])},className:"terminal-field"})]}),e.jsx("div",{className:"git-change-filter",children:e.jsxs(xe,{"data-testid":"git-change-filter","aria-label":"Change type",value:D,onChange:u=>{V(u.target.value),j([])},children:[e.jsx("option",{value:"all",children:"All changes"}),e.jsx("option",{value:"staged",children:"Staged"}),e.jsx("option",{value:"working",children:"Unstaged"}),e.jsx("option",{value:"conflicts",children:"Conflicts"})]})}),e.jsxs("fieldset",{className:"git-diff-layout","aria-label":"Diff layout",children:[e.jsxs("button",{type:"button","data-testid":"git-layout-unified","aria-pressed":!I,onClick:()=>U(!1),title:"Unified diff",children:[e.jsx(wt,{size:14}),e.jsx("span",{children:"Unified"})]}),e.jsxs("button",{type:"button","data-testid":"git-layout-split","aria-pressed":I,onClick:()=>U(!0),title:"Side-by-side diff",children:[e.jsx(Ve,{size:14}),e.jsx("span",{children:"Split"})]})]})]}),e.jsxs("div",{className:"git-review-body","data-mobile-files-open":x,children:[e.jsxs("aside",{"data-testid":"git-changed-files","aria-label":"Changed files",className:"git-change-list",children:[e.jsxs("div",{className:"git-list-heading",children:[e.jsx("span",{children:"Changes"}),e.jsx("span",{children:_.length})]}),q.map(u=>e.jsxs("section",{children:[e.jsxs("h3",{children:[u.name,e.jsx("span",{children:u.files.length})]}),u.files.map($=>e.jsxs("button",{type:"button","data-testid":"git-change-entry","data-path":$.path,title:$.original?`${$.original} → ${$.path}`:$.path,"aria-current":f===$.path?"true":void 0,onClick:()=>{b($.path),L(J=>J.filter(re=>re!==$.path)),F(!1),requestAnimationFrame(()=>{var J;return(J=S.current.get($.path))==null?void 0:J.scrollIntoView({block:"start"})})},children:[e.jsx("span",{className:"git-change-name",children:$.path.split(/[\\/]/).pop()}),e.jsx("span",{className:"git-change-parent",children:$.path.includes("/")?$.path.slice(0,$.path.lastIndexOf("/")):""}),e.jsx("span",{className:ne($).conflict?"text-error":"text-on-surface-variant",children:$.index==="?"?"U":ne($).label.slice(0,1)})]},$.path))]},u.name)),_.length===0&&e.jsx("p",{className:"git-list-empty",children:r.files.length?"No matching files":"No local changes"})]}),e.jsxs("div",{className:"git-diff-scroll","data-testid":"git-review-diffs",children:[r.files.length===0&&e.jsxs("div",{"data-testid":"git-clean",className:"git-review-empty",children:[e.jsx(Ce,{size:22}),e.jsx("p",{children:"Working tree clean"}),e.jsx("span",{children:"Local changes will appear here."})]}),r.files.length>0&&_.length===0&&e.jsx("p",{"data-testid":"git-filter-empty",className:"git-review-empty",children:"No changed files match this filter."}),_.length>0&&e.jsxs("div",{className:"git-diff-actions",children:[e.jsxs("span",{children:[T," staged"]}),e.jsx("button",{type:"button","data-testid":"git-diff-expand-all",onClick:()=>L([]),children:"Expand all"}),e.jsx("button",{type:"button","data-testid":"git-diff-collapse-all",onClick:()=>L(r.files.map(u=>u.path)),children:"Collapse all"})]}),_.map(u=>e.jsx("div",{ref:$=>{$?S.current.set(u.path,$):S.current.delete(u.path)},children:e.jsx(ya,{terminalId:t.id,sideBySide:I,file:u,openFile:ne(u).label==="Deleted"?void 0:$=>o(J=>{const re=new URLSearchParams(J);return re.set("view","files"),re.set("pane",s),re.set("paneTerminal",t.id),re.set("file",$),re}),open:!y.includes(u.path),checked:d.includes(u.path),select:$=>ie(u.path,u.original,$),toggle:()=>L($=>$.includes(u.path)?$.filter(J=>J!==u.path):[...$,u.path])})},u.path))]})]}),e.jsxs("div",{className:"git-commit-bar",children:[e.jsxs("button",{type:"button","data-testid":"git-stage",disabled:!d.length||N,onClick:()=>Z.mutate("stage"),className:"git-stage-action",children:["Stage selected",d.length>0?` (${_.filter(u=>d.includes(u.path)).length})`:""]}),e.jsxs("div",{className:"git-commit-composer",children:[e.jsx("input",{"data-testid":"git-commit-message","aria-label":"Commit message",value:v,onChange:u=>w(u.target.value),placeholder:"Commit message…",className:"terminal-field"}),e.jsxs("button",{type:"button","data-testid":"git-commit",disabled:!v.trim()||E||N||T===0,onClick:()=>Z.mutate("commit"),children:["Commit",T>0?` (${T})`:""]})]})]})]}),oe&&e.jsx(wa,{terminalId:t.id,number:B.number,active:M==="pr"},`${B.repo}:${B.number}`)]})}function Sa(t,s){if(!t)return!1;const a=h=>h.replace(/\\/g,"/").replace(/\/$/,"");return/^[A-Za-z]:[\\/]/.test(s)?a(t).toLowerCase()===a(s).toLowerCase():a(t)===a(s)}function $a({terminal:t,paneId:s}){var F,f,b,S,d,j,v;const[a,h]=le(),n=gt(),o=te({queryKey:["git",t.id,"status"],queryFn:()=>W.git.status(t.id)}),i=te({queryKey:["sessions","live",!1],queryFn:()=>W.sessions.live({active:!1,limit:5e3}),enabled:!!t.live_session_id,select:w=>w.sessions}),g=te({queryKey:["git",t.id,"github",(F=o.data)==null?void 0:F.branch],queryFn:()=>W.git.checkoutGithub(t.id),enabled:!!((f=o.data)!=null&&f.root),staleTime:6e4,refetchInterval:6e4}),m=o.data,c=((S=(b=i.data)==null?void 0:b.find(w=>w.id===t.live_session_id))==null?void 0:S.task)??((d=n.data)==null?void 0:d.find(w=>(m==null?void 0:m.root)&&m.branch&&w.git_branch===m.branch&&Sa(w.git_worktree??w.git_repo,m.root))),l=(j=g.data)==null?void 0:j.items.find(w=>w.kind==="pr"&&w.branch===(m==null?void 0:m.branch)&&/^https:\/\/github\.com\//.test(w.url)),x="items-center gap-1.5 min-h-8 min-w-0 text-xs text-on-surface-variant hover:text-on-surface";return e.jsxs(e.Fragment,{children:[c&&e.jsxs(ve,{"data-testid":"pane-linked-task",to:ue(`/tasks/${c.id}`,a.get("project")??"all",a.toString()),title:`ORC task: ${c.title}`,"aria-label":`Open ORC task: ${c.title}`,className:`pane-task-context max-w-40 ${x}`,children:[e.jsx(Qs,{size:13,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:c.title})]}),l&&e.jsxs("div",{className:"pane-pr-context items-center gap-2 shrink-0",children:[e.jsxs("a",{"data-testid":"pane-linked-pr",href:l.url,onClick:w=>{var y;w.ctrlKey||w.metaKey||w.shiftKey||w.altKey||((y=g.data)==null?void 0:y.auth)==="none"||(w.preventDefault(),h(L=>{const z=new URLSearchParams(L);return z.set("view","git"),z.set("pane",s),z.set("paneTerminal",t.id),z.set("pr",String(l.number)),z.delete("file"),z}))},target:"_blank",rel:"noopener noreferrer",title:`PR #${l.number}: ${l.title} (${l.state})`,"aria-label":`Review PR #${l.number}: ${l.title}`,className:`inline-flex shrink-0 ${x}`,children:[e.jsx(St,{size:13}),"#",l.number]}),e.jsx("a",{href:l.url,target:"_blank",rel:"noopener noreferrer","data-testid":"pane-pr-browser","aria-label":"Open PR in browser",title:"Open PR in browser",className:`inline-flex ${x}`,children:e.jsx(Qe,{size:12})}),((v=g.data)==null?void 0:v.auth)!=="none"&&l.ci&&/^https:\/\/github\.com\//.test(l.ci.url)&&e.jsxs("a",{"data-testid":"pane-ci-status",href:l.ci.url,target:"_blank",rel:"noopener noreferrer",title:`${l.ci.total} checks/statuses on the PR's current commit`,"aria-label":`CI ${l.ci.state==="none"?"has no checks":l.ci.state}`,className:`inline-flex items-center gap-1 text-xs ${l.ci.state==="failure"?"text-error":l.ci.state==="pending"?"text-warning":"text-on-surface-variant"}`,children:[l.ci.state==="success"?e.jsx(zs,{size:13}):l.ci.state==="failure"?e.jsx(Ls,{size:13}):l.ci.state==="pending"?e.jsx(os,{size:13}):e.jsx(Ts,{size:13}),l.ci.state==="none"?"No checks":`CI ${l.ci.state==="success"?"passed":l.ci.state==="failure"?"failed":"pending"}`]})]})]})}function Ie(t){const{node:s,root:a,terminals:h,active:n,focus:o,change:i,close:g,renderTerminal:m,mobile:c,zoomed:l,zoom:x}=t;if(!("kind"in s)){const d=s.direction==="row",j=v=>i(s.id,w=>"kind"in w?w:{...w,ratio:Math.max(20,Math.min(80,v))});return e.jsxs("div",{"data-testid":"workspace-split",className:"flex flex-1 min-w-0 min-h-0 overflow-hidden",style:{flexDirection:c?"column":s.direction},children:[e.jsx("div",{className:`${c&&!H(s.first).some(v=>v.id===n)||l&&!H(s.first).some(v=>v.id===l)?"hidden":"flex"} min-w-0 min-h-0`,style:{flex:c||l?"1 1 0%":`${s.ratio} 1 0%`},children:e.jsx(Ie,{...t,node:s.first})}),e.jsx("div",{role:"separator","aria-label":d?"Resize panes horizontally":"Resize panes vertically","aria-orientation":d?"vertical":"horizontal","aria-valuenow":Math.round(s.ratio),"aria-valuemin":20,"aria-valuemax":80,tabIndex:0,"data-testid":"workspace-resize",className:`${c||l?"hidden":""} shrink-0 bg-border hover:bg-surface focus-visible:bg-focus touch-none ${d?"w-2 cursor-col-resize":"h-2 cursor-row-resize"}`,onDoubleClick:()=>j(50),onKeyDown:v=>{const w=d?"ArrowLeft":"ArrowUp",y=d?"ArrowRight":"ArrowDown";v.key!==w&&v.key!==y||(v.preventDefault(),j(s.ratio+(v.key===w?-5:5)))},onPointerDown:v=>{var P;v.preventDefault();const w=v.currentTarget,y=(P=w.parentElement)==null?void 0:P.getBoundingClientRect();if(!y)return;w.setPointerCapture(v.pointerId);const L=D=>j(100*(d?(D.clientX-y.left)/y.width:(D.clientY-y.top)/y.height)),z=()=>{w.removeEventListener("pointermove",L),w.removeEventListener("pointerup",z),w.removeEventListener("pointercancel",z)};w.addEventListener("pointermove",L),w.addEventListener("pointerup",z),w.addEventListener("pointercancel",z)}}),e.jsx("div",{className:`${c&&!H(s.second).some(v=>v.id===n)||l&&!H(s.second).some(v=>v.id===l)?"hidden":"flex"} min-w-0 min-h-0`,style:{flex:c||l?"1 1 0%":`${100-s.ratio} 1 0%`},children:e.jsx(Ie,{...t,node:s.second})})]})}const F=new Set(H(a).filter(d=>d.id!==s.id&&d.kind==="terminal").map(d=>d.terminalId)),f=h.find(d=>d.id===s.terminalId),b=d=>i(s.id,j=>"kind"in j?{...j,...d}:j),S=d=>{if(H(a).length>=8)return;x(null);const j=crypto.randomUUID();i(s.id,v=>({id:crypto.randomUUID(),direction:d,ratio:50,first:v,second:{id:j,kind:s.kind==="git"?"files":"git",terminalId:s.terminalId}})),o(j)};return e.jsxs("section",{"data-testid":"workspace-pane","data-kind":s.kind,"data-active":n===s.id?"true":"false",onPointerDownCapture:()=>o(s.id),onFocusCapture:()=>o(s.id),className:`terminal-workspace-pane flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden border ${n===s.id?"border-outline-variant":"border-transparent"}`,children:[e.jsxs("header",{className:"flex shrink-0 gap-1 items-center p-1.5 bg-background border-b border-outline-variant",children:[e.jsx("fieldset",{"data-testid":"pane-view","data-view":s.kind,"aria-label":"Pane view",className:"flex items-center rounded-md bg-surface p-0.5",children:[{kind:"terminal",label:"Terminal",icon:st},{kind:"files",label:"Files",icon:Ct},{kind:"git",label:"Git",icon:Ce}].map(({kind:d,label:j,icon:v})=>e.jsxs("button",{type:"button","data-testid":`pane-view-${d}`,"aria-label":j,"aria-pressed":s.kind===d,onClick:()=>{var w;b({kind:d,terminalId:d==="terminal"&&F.has(s.terminalId)?((w=h.find(y=>!F.has(y.id)))==null?void 0:w.id)??null:s.terminalId})},className:`inline-flex items-center justify-center gap-1.5 min-h-11 sm:min-h-8 rounded px-2 text-xs ${s.kind===d?"bg-surface-highest text-on-surface":"text-on-surface-variant hover:text-on-surface"}`,children:[e.jsx(v,{size:14}),e.jsx("span",{className:"pane-view-label",children:j})]},d))}),e.jsx("div",{className:"flex-1 min-w-0 flex items-center gap-3 overflow-hidden px-1",children:f&&e.jsxs(e.Fragment,{children:[s.kind!=="git"&&e.jsx("div",{className:"pane-checkout-context min-w-0 max-w-72",children:e.jsx(qe,{terminal:f,paneId:s.id})}),e.jsx($a,{terminal:f,paneId:s.id})]})}),e.jsxs("button",{type:"button","data-testid":"pane-terminal","data-terminal-id":(f==null?void 0:f.id)??"","aria-label":"Find and switch terminal","aria-haspopup":"dialog",title:`Find terminal: ${(f==null?void 0:f.name)??"None selected"}`,className:"shrink-0 inline-flex items-center justify-center min-h-11 w-11 sm:min-h-8 sm:w-10 rounded-md text-on-surface-variant hover:bg-surface",onClick:()=>cs({currentId:(f==null?void 0:f.id)??null,select:d=>{const j=H(a).find(v=>v.kind==="terminal"&&v.terminalId===d);if(s.kind==="terminal"&&j&&j.id!==s.id){x(null),o(j.id);return}b({terminalId:d})}}),children:[e.jsx(st,{size:16,"aria-hidden":"true"}),e.jsx(Te,{size:11,"aria-hidden":"true"})]}),e.jsxs("details",{className:"relative md:hidden",onKeyDown:d=>{d.key==="Escape"&&d.currentTarget.removeAttribute("open")},onClick:d=>{d.target.closest("button")&&d.currentTarget.removeAttribute("open")},children:[e.jsx("summary",{"data-testid":"pane-actions","aria-label":"Pane actions",title:"Pane actions",className:"list-none flex min-h-11 min-w-11 items-center justify-center rounded-md text-on-surface-variant hover:bg-surface cursor-pointer",children:e.jsx(We,{size:18})}),e.jsxs("div",{className:"absolute right-0 top-full z-30 w-60 rounded-md border border-outline-variant bg-surface-high p-2 shadow-lg",children:[e.jsx("button",{type:"button","data-testid":"pane-action-split-horizontal",disabled:H(a).length>=8,onClick:()=>S("row"),className:"w-full text-left min-h-11 px-2 rounded hover:bg-surface",children:"Split side by side"}),e.jsx("button",{type:"button",disabled:H(a).length>=8,onClick:()=>S("column"),className:"w-full text-left min-h-11 px-2 rounded hover:bg-surface",children:"Split top and bottom"}),H(a).length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>x(l?null:s.id),className:"w-full text-left min-h-11 px-2 rounded hover:bg-surface",children:l?"Restore split layout":"Expand pane"}),e.jsx("button",{type:"button",onClick:()=>g(s.id),className:"w-full text-left min-h-11 px-2 rounded hover:bg-surface",children:"Close pane"})]})]})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-1",children:[e.jsx("button",{type:"button","data-testid":"pane-split-horizontal","aria-label":"Split side by side",title:"Split side by side",disabled:H(a).length>=8,onClick:()=>S("row"),className:"min-h-11 min-w-11 sm:min-h-8 sm:min-w-8 inline-flex items-center justify-center rounded-md text-primary hover:bg-surface disabled:opacity-40",children:e.jsx(Ve,{size:16})}),e.jsx("button",{type:"button","data-testid":"pane-split-vertical","aria-label":"Split top and bottom",title:"Split top and bottom",disabled:H(a).length>=8,onClick:()=>S("column"),className:"min-h-11 min-w-11 sm:min-h-8 sm:min-w-8 inline-flex items-center justify-center rounded-md text-primary hover:bg-surface disabled:opacity-40",children:e.jsx(ra,{size:16})}),H(a).length>1&&e.jsx("button",{type:"button","data-testid":"pane-focus","aria-label":l?"Restore split layout":"Expand pane",title:l?"Restore split layout":"Expand pane","aria-pressed":!!l,onClick:()=>x(l?null:s.id),className:"min-h-11 min-w-11 sm:min-h-8 sm:min-w-8 inline-flex items-center justify-center rounded-md text-on-surface-variant hover:bg-surface",children:l?e.jsx(na,{size:15}):e.jsx(sa,{size:15})}),H(a).length>1&&e.jsx("button",{type:"button","data-testid":"pane-close","aria-label":"Close pane (keep terminal running)",title:"Close pane; terminal keeps running",onClick:()=>g(s.id),className:"min-h-11 min-w-11 sm:min-h-8 sm:min-w-8 inline-flex items-center justify-center rounded-md text-on-surface-variant hover:bg-surface",children:e.jsx(ge,{size:16})})]})]}),f?s.kind==="terminal"?m(f.id):s.kind==="git"?e.jsx(Ca,{terminal:f,paneId:s.id},f.id):e.jsx(va,{terminal:f,active:n===s.id,paneId:s.id},f.id):e.jsx("p",{className:"p-4 text-sm text-on-surface-variant",children:s.terminalId?"This terminal is unavailable or has been closed. Choose another terminal from the selector.":"Choose a terminal or launch one from New terminal."})]})}function Ra(t){const s=jt("lg"),[a,h]=le(),[n,o]=p.useState(()=>{try{const y=Oe(JSON.parse(localStorage.getItem("orc_workspace_layout")??"null"));if(y)return y}catch{}return{id:crypto.randomUUID(),kind:"terminal",terminalId:t.selected.id}}),[i,g]=p.useState(()=>{var y;return((y=H(n)[0])==null?void 0:y.id)??n.id}),[m,c]=p.useState(null),l=p.useRef(n);l.current=n;const x=a.get("view"),F=a.get("pane"),f=a.get("paneTerminal"),b=a.get("file"),S=p.useRef(new Map);p.useEffect(()=>{if(x!=="files")return;const y=H(l.current).find(z=>z.id===F)??H(l.current)[0];if(!y)return;const L=`${y.id}:${f??t.selected.id}`;b?S.current.set(L,b):S.current.delete(L)},[x,F,f,b,t.selected.id]),p.useEffect(()=>{const y=x==="files"||x==="git"?x:"terminal",L=l.current,z=H(L),P=z.find(I=>I.id===F)??z[0];if(!P)return;c(I=>I&&I!==P.id?null:I);const D=f??t.selected.id,V=y==="terminal"?z.find(I=>I.id!==P.id&&I.kind==="terminal"&&I.terminalId===D):void 0;if(V){g(V.id);return}g(P.id),o(I=>{const U=H(I).find(C=>C.id===P.id);if(!U||U.kind===y&&U.terminalId===D)return I;const A=Pe(I,P.id,C=>"kind"in C?{...C,kind:y,terminalId:D}:C);return l.current=A,A})},[x,F,f,t.selected.id]);function d(y,L){const z=H(y).find(V=>V.id===L);if(!z)return;const P=new URLSearchParams(a);P.set("view",z.kind),P.set("pane",z.id),z.terminalId?P.set("paneTerminal",z.terminalId):P.delete("paneTerminal");const D=S.current.get(`${z.id}:${z.terminalId}`);z.kind==="files"&&D?P.set("file",D):P.delete("file"),P.toString()!==a.toString()&&h(P)}function j(y){y!==i&&(g(y),m&&c(y),d(l.current,y))}p.useEffect(()=>{try{localStorage.setItem("orc_workspace_layout",JSON.stringify(n))}catch{}},[n]);const v=H(n),w=v.find(y=>y.id===i)??v[0];return e.jsxs("div",{"data-testid":"terminal-workspace",className:"flex flex-col flex-1 min-h-0 min-w-0",children:[!s&&v.length>1&&e.jsx("nav",{"aria-label":"Workspace panes","data-testid":"mobile-workspace-panes",className:"flex shrink-0 gap-1 overflow-x-auto border-b border-outline-variant bg-background px-2 py-1",children:v.map((y,L)=>e.jsxs("button",{type:"button","data-testid":"mobile-workspace-pane","aria-current":y.id===w.id?"page":void 0,onClick:()=>j(y.id),className:`min-h-11 shrink-0 rounded-md px-3 text-sm ${y.id===w.id?"bg-surface-highest text-on-surface":"text-on-surface-variant hover:bg-surface"}`,children:[y.kind==="terminal"?"Terminal":y.kind==="files"?"Files":"Git"," ",L+1]},y.id))}),e.jsx(Ie,{...t,node:n,root:n,active:w.id,zoomed:v.some(y=>y.id===m)?m:null,zoom:c,mobile:!s,focus:j,change:(y,L)=>{const z=Pe(l.current,y,L);l.current=z,o(z);const P=H(z).find(D=>D.id===y);d(z,(P==null?void 0:P.id)??w.id)},close:y=>{var P;c(null);const L=Ae(l.current,y);l.current=L,o(L);const z=i===y?((P=H(L)[0])==null?void 0:P.id)??L.id:i;g(z),d(L,z)}})]})}function ct({compact:t=!1}){var f,b,S,d;const[s,a]=p.useState(!1),[h,n]=p.useState({}),[o,i]=p.useState(!1),[g,m]=p.useState(!1),c=he(),l=te({queryKey:["worktrees","registry"],queryFn:()=>W.git.registry(),enabled:s}),x=je({mutationFn:()=>W.git.cleanup(Object.values(h).map(j=>{var w,y;const v=(w=l.data)==null?void 0:w.repos.flatMap(L=>L.worktrees).find(L=>L.path===j.path);return{...j,delete_branch:g&&!!(v!=null&&v.merged&&((y=v.branch)!=null&&y.startsWith("orc/")))}})),onSuccess:()=>{n({}),i(!1),c.invalidateQueries({queryKey:["worktrees"]})}});function F(j){return!j.main&&!j.dirty&&!j.locked&&!j.active_terminal&&!!(j.merged||j.prunable)}return e.jsxs("div",{className:`${t?"px-2 border-b":"p-3 border-t"} border-surface-highest space-y-2 text-xs`,children:[e.jsx("button",{type:"button","data-testid":"worktree-registry-toggle",onClick:()=>a(!s),className:"min-h-11 sm:min-h-8 rounded-md text-primary",children:s?"Hide worktrees":"Manage worktrees"}),s&&e.jsxs("div",{"data-testid":"worktree-registry",className:"space-y-2 max-h-[40dvh] overflow-auto",children:[e.jsx("button",{type:"button","data-testid":"worktree-registry-refresh",onClick:()=>void l.refetch(),children:"Refresh"}),l.isLoading&&e.jsx("p",{children:"Loading repositories…"}),l.error&&e.jsx("p",{role:"alert",children:l.error.message}),((f=l.data)==null?void 0:f.repos.length)===0&&e.jsx("p",{children:"No known repositories. Set a project folder or launch a terminal in a repository."}),(b=l.data)==null?void 0:b.repos.map(j=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"break-all text-on-surface-variant",children:j.root}),j.worktrees.map(v=>e.jsxs("label",{"data-testid":"registry-worktree",className:"flex min-h-11 gap-2 items-start py-2",title:v.path,children:[e.jsx("input",{type:"checkbox","data-testid":"registry-worktree-select",disabled:!F(v)||x.isPending,checked:!!h[v.path],onChange:w=>n(y=>{const L={...y};return w.target.checked?L[v.path]={cwd:j.root??"",path:v.path}:delete L[v.path],L})}),e.jsxs("span",{className:"break-all",children:[v.branch??"detached"," ",v.main&&"· main"," ",v.merged&&"· merged"," ",v.upstream_gone&&"· upstream gone"," ",v.prunable&&"· missing"," ",v.dirty&&"· dirty"," ",v.locked&&"· locked"," ",v.active_terminal&&`· running: ${v.active_terminal}`]})]},v.path))]},j.root)),(S=l.data)==null?void 0:S.errors.map(j=>e.jsxs("p",{role:"alert",children:[j.cwd,": ",j.error]},j.cwd)),e.jsxs("label",{className:"flex min-h-11 gap-2 items-center",children:[e.jsx("input",{type:"checkbox","data-testid":"cleanup-delete-branch",checked:g,onChange:j=>m(j.target.checked)}),"Also delete merged orc/* branches"]}),e.jsxs("button",{type:"button","data-testid":"worktree-cleanup",disabled:!Object.keys(h).length||x.isPending,onClick:()=>i(!0),className:"min-h-11 sm:min-h-8 rounded-md text-primary disabled:opacity-40",children:["Clean selected (",Object.keys(h).length,")"]}),x.error&&e.jsx("p",{role:"alert",children:x.error.message}),(d=x.data)==null?void 0:d.results.map(j=>e.jsxs("p",{"data-testid":"cleanup-result",role:j.error?"alert":void 0,children:[j.path,": ",j.removed?"removed":j.error]},j.path))]}),e.jsx(Ue,{open:o,title:"Clean selected worktrees?",description:`Remove ${Object.keys(h).length} selected worktree folders. Dirty, locked, active and unmerged worktrees are refused. ${g?"Merged orc/* branches will also be deleted safely.":"Branches are kept."}`,confirmLabel:"Clean selected",isPending:x.isPending,onConfirm:()=>x.mutate(),onCancel:()=>i(!1)})]})}const _a=256,dt=160,ut=480;function za({terminalId:t}){const{attach:s,detach:a,engineError:h}=Se(),n=p.useRef(null);return p.useEffect(()=>{const o=n.current;if(o)return s(t,o),()=>a(t)},[t,s,a]),e.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0 flex-col",children:[e.jsx("div",{ref:n,"data-testid":"terminal-viewport",className:"relative flex-1 min-h-0 min-w-0 bg-black",children:h&&e.jsxs("p",{role:"alert",className:"absolute inset-0 flex items-center justify-center p-4 bg-surface text-error font-label text-xs text-center",children:["Terminal renderer failed to load: ",h]})}),e.jsx(ga,{terminalId:t})]})}const Ke="shrink-0 inline-flex min-h-11 items-center rounded-md font-label text-sm text-primary hover:text-on-surface";function ht({liveSessionId:t}){var o;const[s]=le(),a=s.get("project")??"all",{data:h}=kt(!1),n=(o=h==null?void 0:h.find(i=>i.id===t))==null?void 0:o.task;return e.jsxs("div",{className:"shrink-0 flex items-center gap-3",children:[e.jsx(ve,{to:`${ue("/sessions",a,s.toString())}&session=${encodeURIComponent(t)}`,"data-testid":"terminal-open-session",className:Ke,children:"Session"}),n&&e.jsx(ve,{to:ue(`/tasks/${n.id}`,a,s.toString()),"data-testid":"terminal-open-task",title:n.title,className:Ke,children:"Task"})]})}function Pa({liveSessionId:t}){const[s]=le(),{data:a,isLoading:h,error:n,refetch:o}=kt(!1),i=a==null?void 0:a.find(g=>g.id===t);return h?e.jsx(yt,{className:"h-24 w-full max-w-md"}):n?e.jsx(vt,{message:n.message,onRetry:()=>o()}):e.jsxs("div",{"data-testid":"no-session-terminal",className:"max-w-md space-y-3 text-center",children:[e.jsx("h2",{className:"font-headline text-sm text-on-surface",children:i?"No terminal is open for this session":"Session not found"}),i&&e.jsx("p",{className:"truncate font-body text-sm text-on-surface-variant",children:i.name??i.summary??i.id}),e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[i&&e.jsx(js,{session:i}),e.jsx(ve,{to:ue("/terminals",s.get("project")??"all",s.toString()),className:Ke,children:"All terminals"})]})]})}function Ne({children:t}){return e.jsx("div",{className:"flex-1 min-h-0 flex items-center justify-center p-6",children:t})}function Ma(){const{terminalId:t}=ds(),[s]=le(),a=s.get("session"),h=bt(),{terminals:n,info:o,isLoading:i,error:g,refetch:m,lastActiveId:c,connectionOf:l,create:x,remove:F}=Se(),f=jt("lg"),{data:b}=pt(),S=us({storageKey:"orc_terminal_sidebar_width",initial:_a,min:dt,max:ut}),[d,j]=p.useState(!1),[v,w]=p.useState(!1),y=p.useRef(null),[L,z]=p.useState(),P=p.useCallback(T=>{T&&z(void 0),j(T)},[]);p.useEffect(()=>{if(s.get("new")!=="1")return;z(s.has("terminalHost")?s.get("terminalHost")||null:void 0),j(!0);const T=new URLSearchParams(s);T.delete("new"),T.delete("terminalHost"),h({search:T.toString()},{replace:!0})},[s,h]);const[D,V]=p.useState(!1),[I,U]=p.useState(null),[A,C]=p.useState(null),[K,Q]=p.useState(null),[Z,Y]=p.useState(null),r=p.useCallback(async T=>{V(!0),U(null);try{const q=await x(T);return j(!1),h(ue(`/terminals/${q.id}`,s.get("project")??"all",s.toString())),!0}catch(q){return U(q instanceof Error?q.message:String(q)),!1}finally{V(!1)}},[x,h,s]),O=p.useCallback(async T=>{Y(null);try{if(await F(T.id),C(null),T.id===t){const q=n.find(ie=>ie.id!==T.id);h(ue(q?`/terminals/${q.id}`:"/terminals",s.get("project")??"all",s.toString()),{replace:!0})}}catch(q){C(null),Y(q instanceof Error?q.message:String(q))}},[F,t,n,h,s]),k=p.useCallback(T=>{T.status==="running"?C(T):O(T)},[O]),N=T=>!!o&&(T.host?(b==null?void 0:b.supported)===!0:o.launchers.includes(T.kind)),E=async T=>{if(!(!N(T)||D)){V(!0),Y(null);try{const q=await x({kind:T.kind,host:T.host,...T.cwd?{cwd:T.cwd}:{},name:`${T.name.slice(0,113)} (copy)`}),ie=new URLSearchParams(s);ie.delete("session"),ie.delete("file"),ie.set("view","terminal"),ie.set("paneTerminal",q.id),h({pathname:`/terminals/${q.id}`,search:ie.toString()})}catch(q){Y(q instanceof Error?q.message:String(q))}finally{V(!1)}}};if(g&&!o)return e.jsx(Ne,{children:e.jsx("div",{"data-testid":"terminal-load-error",children:e.jsx(vt,{message:g.message,onRetry:m})})});if(i||!o)return e.jsx(Ne,{children:e.jsxs("div",{role:"status","data-testid":"terminal-loading","aria-label":"Loading terminals",className:"w-full max-w-md",children:[e.jsx(yt,{className:"h-40 w-full"}),e.jsx("span",{className:"sr-only",children:"Loading terminals…"})]})});if(!o.ready)return e.jsx(Ne,{children:e.jsxs("div",{className:"max-w-md space-y-3 text-center",children:[e.jsx("h2",{className:"font-headline text-sm text-on-surface",children:"Terminals are not available"}),e.jsx("p",{className:"font-body text-sm text-on-surface-variant",children:o.reason??"The API has not enabled terminals."}),e.jsxs("p",{className:"font-body text-xs text-on-surface-variant",children:["Terminals require Bun 1.4.2 or newer and can be turned off with"," ",e.jsx("code",{className:"text-primary",children:"terminals.enabled: false"}),"."]})]})});if(!t&&a){const T=hs(n,a);return T?e.jsx(at,{to:{pathname:ms(T.id),search:s.toString()},replace:!0}):e.jsx(Ne,{children:e.jsx(Pa,{liveSessionId:a})})}if(!t&&n.length>0){const T=n.find(q=>q.id===c)??n[0];return e.jsx(at,{to:{pathname:`/terminals/${T.id}`,search:s.toString()},replace:!0})}const _=t?n.find(T=>T.id===t):void 0,B=s.get("paneTerminal")??t,M=n.find(T=>T.id===B),ae=L===void 0?(b==null?void 0:b.host)??null:L,oe=e.jsx(ha,{open:d,onOpenChange:P,launchers:ae===o.host?o.launchers:[],host:ae,pending:D,error:I,onCreate:r,compact:!f},ae??"local");return e.jsxs("div",{className:"terminal-workspace-page flex h-full w-full min-h-0 bg-background",children:[f&&e.jsxs("aside",{"data-testid":"terminal-sidebar",style:{width:S.width},className:"relative shrink-0 flex flex-col min-h-0 border-r border-outline-variant bg-background",children:[e.jsxs("div",{className:"shrink-0 p-3",children:[e.jsx("h2",{className:"mb-3 text-sm font-medium text-on-surface",children:"Sessions"}),oe]}),e.jsx(pa,{terminals:n,activeId:t??null,onClose:k,connectionOf:l,onRename:Q,onDuplicate:T=>void E(T),canDuplicate:N,pending:D}),e.jsx(ct,{}),e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize terminal list","aria-valuenow":S.width,"aria-valuemin":dt,"aria-valuemax":ut,tabIndex:0,"data-testid":"terminal-sidebar-resize",title:"Drag to resize, double-click to reset",className:"absolute inset-y-0 -right-1 z-20 w-2 cursor-col-resize touch-none hover:bg-surface-highest focus-visible:bg-focus",...S.handleProps})]}),e.jsxs("section",{className:"flex-1 min-w-0 min-h-0 flex flex-col",children:[!f&&e.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-2 py-1 border-b border-surface-highest",children:[e.jsxs(xe,{"aria-label":"Terminal",value:(M==null?void 0:M.id)??"",onChange:T=>{const q=new URLSearchParams(s);q.delete("file"),q.delete("session"),q.has("view")&&q.set("paneTerminal",T.target.value),h({pathname:`/terminals/${T.target.value}`,search:q.toString()})},disabled:n.length===0,className:"flex-1 min-w-0 bg-background border border-control-border text-on-surface font-label text-base sm:text-sm min-h-11 px-2 py-2 rounded-md",children:[n.length===0&&e.jsx("option",{value:"",children:"No terminals"}),n.length>0&&!M&&e.jsx("option",{value:"",children:"Choose terminal"}),n.map(T=>e.jsx("option",{value:T.id,children:T.name},T.id))]}),e.jsx("div",{className:"shrink-0",children:oe}),e.jsx(pe,{variant:"ghost",size:"icon","data-testid":"terminal-options",ref:y,"aria-label":"Terminal options",onClick:()=>w(!0),children:e.jsx(We,{size:18})})]}),_?e.jsxs(e.Fragment,{children:[e.jsxs("header",{className:"hidden lg:flex shrink-0 flex-wrap items-center gap-3 px-3 py-3 border-b border-outline-variant bg-background min-w-0",children:[e.jsx("span",{className:ce("h-2 w-2 shrink-0 rounded-full",_.status==="running"?"bg-secondary":"bg-outline")}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{"data-testid":"terminal-name",title:_.name,className:"truncate font-body text-sm text-on-surface",children:_.name}),e.jsxs("div",{className:"truncate font-label text-xs text-on-surface-variant",children:[ze[_.kind].label,_.host&&e.jsxs("span",{"data-testid":"terminal-selected-host",title:`SSH host: ${_.host}`,children:[" ","· ",_.host]}),_.cwd&&e.jsxs("span",{className:"normal-case tracking-normal",children:[" · ",_.cwd]}),e.jsxs("span",{children:[" · ",Ee(_,l(_.id))]})]}),e.jsx("div",{className:s.get("view")==="git"?"hidden":"md:hidden",children:e.jsx(qe,{terminal:_},_.id)})]}),Z&&e.jsx("span",{role:"alert",className:"w-full font-body text-sm text-error break-words",children:Z}),_.live_session_id&&e.jsx(ht,{liveSessionId:_.live_session_id})]}),!f&&Z&&e.jsx("p",{role:"alert",className:"p-2 text-sm text-error break-words",children:Z}),e.jsx(Ra,{selected:_,terminals:n,renderTerminal:T=>e.jsx(za,{terminalId:T})})]}):e.jsx(Ne,{children:e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("p",{className:"font-label text-xs text-on-surface-variant",children:t?"Terminal not found":"No terminals yet"}),e.jsx(pe,{type:"button",variant:"outline",size:"sm",onClick:()=>t?h(ue("/terminals",s.get("project")??"all",s.toString())):j(!0),className:"font-label text-sm",children:t?"Back to terminals":"Start a terminal"})]})})]}),e.jsx(fs,{open:v&&!f,onOpenChange:w,children:e.jsxs(ps,{"aria-describedby":void 0,onCloseAutoFocus:T=>{var q;T.preventDefault(),(q=y.current)==null||q.focus()},children:[e.jsx(xs,{children:e.jsx(gs,{children:"Terminal options"})}),e.jsxs(bs,{className:"space-y-4",children:[M&&e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsx("p",{className:"break-words font-medium",children:M.name}),e.jsx("p",{className:"break-all text-on-surface-variant",children:M.cwd}),e.jsx("p",{children:Ee(M,l(M.id))}),M.live_session_id&&e.jsx(ht,{liveSessionId:M.live_session_id}),e.jsx(qe,{terminal:M},M.id),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(pe,{variant:"outline","data-testid":"terminal-rename",onClick:()=>{w(!1),Q(M)},children:"Rename"}),e.jsx(pe,{variant:"outline","data-testid":"terminal-duplicate",disabled:D||!N(M),onClick:()=>{w(!1),E(M)},children:"Duplicate tab"})]}),e.jsx(pe,{variant:"outline","data-testid":"terminal-close-selected",onClick:()=>{w(!1),k(M)},"aria-label":`Close ${M.name}`,className:"text-error",children:"Close terminal"})]}),e.jsx(ct,{compact:!0})]})]})}),K&&e.jsx(ma,{terminal:K,onClose:()=>Q(null)},K.id),e.jsx(Ue,{open:A!==null,title:"Close terminal",description:`"${(A==null?void 0:A.name)??""}" is still running. Closing it kills the process.`,confirmLabel:"Close",onConfirm:()=>A&&void O(A),onCancel:()=>C(null)})]})}export{Ma as default};
@@ -1 +1 @@
1
- import{r as p,j as e,V as j,B as l,E as x,L as u}from"./index-SOCnaNS0.js";import{u as w,a as g,W as f,b as k}from"./JobWebhooks-BtzsOTHL.js";import{u as N}from"./useProjectScope-B28fk5NO.js";import"./useJobs-DDRY0jra.js";function E({projectId:h}){const t=N(h),r=t==="all"||t==="unassigned"?void 0:t,{data:a,error:c,isLoading:m,refetch:b}=w(r),n=g(),[i,d]=p.useState(!1),o=a==null?void 0:a.filter(s=>t!=="unassigned"||s.project_id===null);return e.jsxs("div",{className:"space-y-6",children:[e.jsx(j,{title:"Webhooks",meta:"Configured event sources and connected jobs",action:e.jsx(l,{type:"button",size:"sm","data-testid":"new-webhook-button",onClick:()=>d(!i),children:i?"Close new webhook":"Create webhook"})}),e.jsx("p",{className:"text-sm text-outline",children:"Configure each event source once, then select it in Jobs. One webhook can trigger multiple jobs, each with its own event filters and action."}),i&&e.jsxs("section",{className:"space-y-4 border-y border-border py-4",children:[e.jsx("h2",{className:"text-sm font-medium",children:"New webhook"}),e.jsx("p",{className:"text-xs text-outline",children:r?"This webhook belongs to the selected project.":"This webhook will be shared across projects. Select a project in the workspace to scope it."}),e.jsx(f,{projectId:r,onCreated:()=>d(!1)})]}),c?e.jsx(x,{message:c.message,onRetry:()=>b()}):m?e.jsx("p",{role:"status",children:"Loading webhooks..."}):o!=null&&o.length?e.jsxs("section",{className:"space-y-6",children:[e.jsxs("h2",{className:"text-sm font-medium",children:["Configured webhooks (",o.length,")"]}),o.map(s=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{hook:s}),e.jsx(l,{type:"button",variant:"ghost",size:"sm",disabled:n.isPending,onClick:()=>{window.confirm(`Delete ${s.name}? Connected jobs will stop receiving events from this endpoint.`)&&n.mutate(s.id)},children:"Delete webhook"})]},s.id))]}):e.jsxs("section",{className:"space-y-3 border-t border-border py-6",children:[e.jsx("h2",{className:"text-sm font-medium",children:"No webhooks configured"}),e.jsx("p",{className:"text-sm text-outline",children:"Create a webhook above, register its URL and secret with your provider, then select it when creating a job."}),e.jsx(u,{className:"inline-block text-sm underline",to:`/jobs?project=${encodeURIComponent(t)}`,"data-testid":"webhooks-go-jobs",children:"Open Jobs"})]}),n.error&&e.jsx("p",{role:"alert",className:"text-sm text-error",children:n.error.message})]})}export{E as default};
1
+ import{r as p,j as e,V as j,B as l,E as x,L as u}from"./index-BqQDBYwx.js";import{u as w,a as g,W as f,b as k}from"./JobWebhooks-CYE2UA0V.js";import{u as N}from"./useProjectScope-BvcpSOql.js";import"./useJobs-By4K4BjX.js";function E({projectId:h}){const t=N(h),r=t==="all"||t==="unassigned"?void 0:t,{data:a,error:c,isLoading:m,refetch:b}=w(r),n=g(),[i,d]=p.useState(!1),o=a==null?void 0:a.filter(s=>t!=="unassigned"||s.project_id===null);return e.jsxs("div",{className:"space-y-6",children:[e.jsx(j,{title:"Webhooks",meta:"Configured event sources and connected jobs",action:e.jsx(l,{type:"button",size:"sm","data-testid":"new-webhook-button",onClick:()=>d(!i),children:i?"Close new webhook":"Create webhook"})}),e.jsx("p",{className:"text-sm text-outline",children:"Configure each event source once, then select it in Jobs. One webhook can trigger multiple jobs, each with its own event filters and action."}),i&&e.jsxs("section",{className:"space-y-4 border-y border-border py-4",children:[e.jsx("h2",{className:"text-sm font-medium",children:"New webhook"}),e.jsx("p",{className:"text-xs text-outline",children:r?"This webhook belongs to the selected project.":"This webhook will be shared across projects. Select a project in the workspace to scope it."}),e.jsx(f,{projectId:r,onCreated:()=>d(!1)})]}),c?e.jsx(x,{message:c.message,onRetry:()=>b()}):m?e.jsx("p",{role:"status",children:"Loading webhooks..."}):o!=null&&o.length?e.jsxs("section",{className:"space-y-6",children:[e.jsxs("h2",{className:"text-sm font-medium",children:["Configured webhooks (",o.length,")"]}),o.map(s=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{hook:s}),e.jsx(l,{type:"button",variant:"ghost",size:"sm",disabled:n.isPending,onClick:()=>{window.confirm(`Delete ${s.name}? Connected jobs will stop receiving events from this endpoint.`)&&n.mutate(s.id)},children:"Delete webhook"})]},s.id))]}):e.jsxs("section",{className:"space-y-3 border-t border-border py-6",children:[e.jsx("h2",{className:"text-sm font-medium",children:"No webhooks configured"}),e.jsx("p",{className:"text-sm text-outline",children:"Create a webhook above, register its URL and secret with your provider, then select it when creating a job."}),e.jsx(u,{className:"inline-block text-sm underline",to:`/jobs?project=${encodeURIComponent(t)}`,"data-testid":"webhooks-go-jobs",children:"Open Jobs"})]}),n.error&&e.jsx("p",{role:"alert",className:"text-sm text-error",children:n.error.message})]})}export{E as default};
@@ -1 +1 @@
1
- import{g as p,r as u,d as a}from"./chunk-SVP7TREG-DvLoUZ9h.js";import{p as f}from"./chunk-JWPE2WC7-ByQ6NS99.js";import{_ as n,l as o}from"./mermaid-HWGCJPDP-CMQlzgg9.js";import{M as c,b as d}from"./cynefin-OW5HDTMX-DwbOregT.js";import"./index-SOCnaNS0.js";import"./wiki-links-Y6CQL1QZ.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},F={parser:R,db:a,renderer:u,styles:p};export{F as diagram};
1
+ import{g as p,r as u,d as a}from"./chunk-SVP7TREG-BkVeMS09.js";import{p as f}from"./chunk-JWPE2WC7-2IhqyMft.js";import{_ as n,l as o}from"./mermaid-HWGCJPDP-DE8bnMel.js";import{M as c,b as d}from"./cynefin-OW5HDTMX-CQZuSJ5b.js";import"./index-BqQDBYwx.js";import"./wiki-links-Y6CQL1QZ.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},F={parser:R,db:a,renderer:u,styles:p};export{F as diagram};
@@ -1 +1 @@
1
- import{J as ln,K as un,L as V,M as O,N as M,O as an,P as y,Q as tn,R as Y,T as _,V as rn,W as o,X as on,Y as sn,Z as fn}from"./mermaid-HWGCJPDP-CMQlzgg9.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,E,q,v,R,N,u){var I=E-l,i=q-h,n=N-v,d=u-R,a=d*I-n*i;if(!(a*a<y))return a=(n*(h-R)-d*(l-v))/a,[l+a*I,h+a*i]}function F(l,h,E,q,v,R,N){var u=l-E,I=h-q,i=(N?R:-R)/Y(u*u+I*I),n=i*I,d=-i*u,a=l+n,s=h+d,f=E+n,c=q+d,Q=(a+f)/2,t=(s+c)/2,m=f-a,g=c-s,A=m*m+g*g,T=v-R,P=a*c-f*s,J=(g<0?-1:1)*Y(on(0,T*T*A-P*P)),K=(P*g-m*J)/A,L=(-P*m-g*J)/A,w=(P*g+m*J)/A,p=(-P*m+g*J)/A,x=K-Q,e=L-t,r=w-Q,S=p-t;return x*x+e*e>r*r+S*S&&(K=w,L=p),{cx:K,cy:L,x01:-n,y01:-d,x11:K*(v/T-1),y11:L*(v/T-1)}}function hn(){var l=cn,h=yn,E=M(0),q=null,v=gn,R=dn,N=mn,u=null,I=ln(i);function i(){var n,d,a=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-an,c=R.apply(this,arguments)-an,Q=rn(c-f),t=c>f;if(u||(u=n=I()),s<a&&(d=s,s=a,a=d),!(s>y))u.moveTo(0,0);else if(Q>tn-y)u.moveTo(s*V(f),s*O(f)),u.arc(0,0,s,f,c,!t),a>y&&(u.moveTo(a*V(c),a*O(c)),u.arc(0,0,a,c,f,t));else{var m=f,g=c,A=f,T=c,P=Q,J=Q,K=N.apply(this,arguments)/2,L=K>y&&(q?+q.apply(this,arguments):Y(a*a+s*s)),w=_(rn(s-a)/2,+E.apply(this,arguments)),p=w,x=w,e,r;if(L>y){var S=sn(L/a*O(K)),Z=sn(L/s*O(K));(P-=S*2)>y?(S*=t?1:-1,A+=S,T-=S):(P=0,A=T=(f+c)/2),(J-=Z*2)>y?(Z*=t?1:-1,m+=Z,g-=Z):(J=0,m=g=(f+c)/2)}var W=s*V(m),X=s*O(m),j=a*V(T),z=a*O(T);if(w>y){var B=s*V(g),C=s*O(g),G=a*V(A),H=a*O(A),D;if(Q<un)if(D=pn(W,X,G,H,B,C,j,z)){var U=W-D[0],$=X-D[1],k=B-D[0],b=C-D[1],nn=1/O(fn((U*k+$*b)/(Y(U*U+$*$)*Y(k*k+b*b)))/2),en=Y(D[0]*D[0]+D[1]*D[1]);p=_(w,(a-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}J>y?x>y?(e=F(G,H,W,X,s,x,t),r=F(B,C,j,z,s,x,t),u.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),u.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(u.moveTo(W,X),u.arc(0,0,s,m,g,!t)):u.moveTo(W,X),!(a>y)||!(P>y)?u.lineTo(j,z):p>y?(e=F(j,z,B,C,a,-p,t),r=F(W,X,G,H,a,-p,t),u.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?u.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,a,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),u.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):u.arc(0,0,a,T,A,t)}if(u.closePath(),n)return u=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +R.apply(this,arguments))/2-un/2;return[V(d)*n,O(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:M(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:M(+n),i):h},i.cornerRadius=function(n){return arguments.length?(E=typeof n=="function"?n:M(+n),i):E},i.padRadius=function(n){return arguments.length?(q=n==null?null:typeof n=="function"?n:M(+n),i):q},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:M(+n),i):v},i.endAngle=function(n){return arguments.length?(R=typeof n=="function"?n:M(+n),i):R},i.padAngle=function(n){return arguments.length?(N=typeof n=="function"?n:M(+n),i):N},i.context=function(n){return arguments.length?(u=n??null,i):u},i}export{hn as d};
1
+ import{J as ln,K as un,L as V,M as O,N as M,O as an,P as y,Q as tn,R as Y,T as _,V as rn,W as o,X as on,Y as sn,Z as fn}from"./mermaid-HWGCJPDP-DE8bnMel.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,E,q,v,R,N,u){var I=E-l,i=q-h,n=N-v,d=u-R,a=d*I-n*i;if(!(a*a<y))return a=(n*(h-R)-d*(l-v))/a,[l+a*I,h+a*i]}function F(l,h,E,q,v,R,N){var u=l-E,I=h-q,i=(N?R:-R)/Y(u*u+I*I),n=i*I,d=-i*u,a=l+n,s=h+d,f=E+n,c=q+d,Q=(a+f)/2,t=(s+c)/2,m=f-a,g=c-s,A=m*m+g*g,T=v-R,P=a*c-f*s,J=(g<0?-1:1)*Y(on(0,T*T*A-P*P)),K=(P*g-m*J)/A,L=(-P*m-g*J)/A,w=(P*g+m*J)/A,p=(-P*m+g*J)/A,x=K-Q,e=L-t,r=w-Q,S=p-t;return x*x+e*e>r*r+S*S&&(K=w,L=p),{cx:K,cy:L,x01:-n,y01:-d,x11:K*(v/T-1),y11:L*(v/T-1)}}function hn(){var l=cn,h=yn,E=M(0),q=null,v=gn,R=dn,N=mn,u=null,I=ln(i);function i(){var n,d,a=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-an,c=R.apply(this,arguments)-an,Q=rn(c-f),t=c>f;if(u||(u=n=I()),s<a&&(d=s,s=a,a=d),!(s>y))u.moveTo(0,0);else if(Q>tn-y)u.moveTo(s*V(f),s*O(f)),u.arc(0,0,s,f,c,!t),a>y&&(u.moveTo(a*V(c),a*O(c)),u.arc(0,0,a,c,f,t));else{var m=f,g=c,A=f,T=c,P=Q,J=Q,K=N.apply(this,arguments)/2,L=K>y&&(q?+q.apply(this,arguments):Y(a*a+s*s)),w=_(rn(s-a)/2,+E.apply(this,arguments)),p=w,x=w,e,r;if(L>y){var S=sn(L/a*O(K)),Z=sn(L/s*O(K));(P-=S*2)>y?(S*=t?1:-1,A+=S,T-=S):(P=0,A=T=(f+c)/2),(J-=Z*2)>y?(Z*=t?1:-1,m+=Z,g-=Z):(J=0,m=g=(f+c)/2)}var W=s*V(m),X=s*O(m),j=a*V(T),z=a*O(T);if(w>y){var B=s*V(g),C=s*O(g),G=a*V(A),H=a*O(A),D;if(Q<un)if(D=pn(W,X,G,H,B,C,j,z)){var U=W-D[0],$=X-D[1],k=B-D[0],b=C-D[1],nn=1/O(fn((U*k+$*b)/(Y(U*U+$*$)*Y(k*k+b*b)))/2),en=Y(D[0]*D[0]+D[1]*D[1]);p=_(w,(a-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}J>y?x>y?(e=F(G,H,W,X,s,x,t),r=F(B,C,j,z,s,x,t),u.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),u.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(u.moveTo(W,X),u.arc(0,0,s,m,g,!t)):u.moveTo(W,X),!(a>y)||!(P>y)?u.lineTo(j,z):p>y?(e=F(j,z,B,C,a,-p,t),r=F(W,X,G,H,a,-p,t),u.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?u.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,a,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),u.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):u.arc(0,0,a,T,A,t)}if(u.closePath(),n)return u=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +R.apply(this,arguments))/2-un/2;return[V(d)*n,O(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:M(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:M(+n),i):h},i.cornerRadius=function(n){return arguments.length?(E=typeof n=="function"?n:M(+n),i):E},i.padRadius=function(n){return arguments.length?(q=n==null?null:typeof n=="function"?n:M(+n),i):q},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:M(+n),i):v},i.endAngle=function(n){return arguments.length?(R=typeof n=="function"?n:M(+n),i):R},i.padAngle=function(n){return arguments.length?(N=typeof n=="function"?n:M(+n),i):N},i.context=function(n){return arguments.length?(u=n??null,i):u},i}export{hn as d};