@kabmo-labs/kabmo 0.42.1 → 0.42.2

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 (110) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +415 -415
  3. package/dist/client/static/js/{CsvGrid-8gdp5b49.js → CsvGrid-g6rek8y9.js} +1 -1
  4. package/dist/client/static/js/{DocxView-j9sphgra.js → DocxView-41t9ryws.js} +1 -1
  5. package/dist/client/static/js/{DrawioView-xsgjc7d8.js → DrawioView-mfxhfz1h.js} +1 -1
  6. package/dist/client/static/js/{ImageView-ve9hc519.js → ImageView-bxqw3t4k.js} +1 -1
  7. package/dist/client/static/js/{LayoutWrapper-5mqffvkc.js → LayoutWrapper-zt14rv9m.js} +1 -1
  8. package/dist/client/static/js/{Modal-50whypff.js → Modal-cm35g20x.js} +1 -1
  9. package/dist/client/static/js/{PdfView-afd5cg54.js → PdfView-bek8k888.js} +1 -1
  10. package/dist/client/static/js/{SessionsView-7719nvy0.js → SessionsView-gn53zyn7.js} +1 -1
  11. package/dist/client/static/js/{SheetView-gfzgxb4r.js → SheetView-vezssf6b.js} +1 -1
  12. package/dist/client/static/js/{SvgPreview-225pkb99.js → SvgPreview-f1qaw73k.js} +1 -1
  13. package/dist/client/static/js/{abnfDiagram-O67JEVCF-z70sk69m.js → abnfDiagram-O67JEVCF-4qn94h52.js} +1 -1
  14. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-pf1gpkje.js → architectureDiagram-NJMV4G6O-tbewzdya.js} +1 -1
  15. package/dist/client/static/js/{blockDiagram-BEXU5L5S-sr25kbn6.js → blockDiagram-BEXU5L5S-njgnwckz.js} +1 -1
  16. package/dist/client/static/js/{c4Diagram-YGBWAQC7-znstpg86.js → c4Diagram-YGBWAQC7-f58pcvbk.js} +1 -1
  17. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-7n0pdcd8.js → classDiagram-v2-NBCMYWYE-52g73vyw.js} +1 -1
  18. package/dist/client/static/js/{cose-bilkent-JH36ORCC-zn3qw4c4.js → cose-bilkent-JH36ORCC-ptdnshzh.js} +1 -1
  19. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-3z41vtzs.js → cynefinDiagram-VND7K2PF-qabfdkzr.js} +1 -1
  20. package/dist/client/static/js/{dagre-6A5THRUB-5j3zn883.js → dagre-6A5THRUB-kyf5jetf.js} +1 -1
  21. package/dist/client/static/js/{diagram-22UHCM2B-ryw1w2kh.js → diagram-22UHCM2B-bxrsjtv9.js} +1 -1
  22. package/dist/client/static/js/{diagram-3UASUU5V-p91q4gkh.js → diagram-3UASUU5V-0f41s00j.js} +1 -1
  23. package/dist/client/static/js/{diagram-ATOU4E4O-22dn73g4.js → diagram-ATOU4E4O-0z1zx9h1.js} +1 -1
  24. package/dist/client/static/js/{diagram-CDSNMT55-589p9n53.js → diagram-CDSNMT55-znrmr6bk.js} +1 -1
  25. package/dist/client/static/js/{diagram-MLGK6HIB-ezw06wbx.js → diagram-MLGK6HIB-jfe2jhk0.js} +1 -1
  26. package/dist/client/static/js/{diagram-MPIPVDR6-cfwrsvk1.js → diagram-MPIPVDR6-2kaawmwa.js} +1 -1
  27. package/dist/client/static/js/{dockerfile-r4k7q34y.js → dockerfile-12exatm9.js} +1 -1
  28. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-3rv2wvbf.js → ebnfDiagram-ZINNZB2B-s5n37rfp.js} +1 -1
  29. package/dist/client/static/js/{elk-276RUBZZ-ma40kneq.js → elk-276RUBZZ-433rd9fp.js} +1 -1
  30. package/dist/client/static/js/{erDiagram-OPXOYQCR-xwstsfqa.js → erDiagram-OPXOYQCR-key6ah0b.js} +1 -1
  31. package/dist/client/static/js/flowDiagram-KWPJA3E3-nznq0n36.js +1 -0
  32. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-qxyx9tr9.js → ganttDiagram-FUAMR5RP-4efkhmca.js} +1 -1
  33. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-v6sg7bkh.js → gitGraphDiagram-X574FWY7-ac376y2k.js} +1 -1
  34. package/dist/client/static/js/{index-mq6s2faf.js → index-02543wk3.js} +1 -1
  35. package/dist/client/static/js/{index-df4yxfzd.js → index-0e9nkc0g.js} +1 -1
  36. package/dist/client/static/js/{index-cqaz1281.js → index-0gbj4270.js} +1 -1
  37. package/dist/client/static/js/{index-b3d2k7ec.js → index-0pabfaac.js} +1 -1
  38. package/dist/client/static/js/{index-x7a5jpvq.js → index-1t5ybx9v.js} +1 -1
  39. package/dist/client/static/js/{index-9ss64g4g.js → index-1y3rzw6b.js} +1 -1
  40. package/dist/client/static/js/{index-5599dngt.js → index-38xv8h4t.js} +1 -1
  41. package/dist/client/static/js/{index-0nca2nhp.js → index-50mdqev0.js} +1 -1
  42. package/dist/client/static/js/{index-9hzfvjrb.js → index-5jnvz9hw.js} +1 -1
  43. package/dist/client/static/js/{index-8fvmyv7t.js → index-77t0nvt1.js} +1 -1
  44. package/dist/client/static/js/{index-mphhvgm9.js → index-7a2efrbj.js} +1 -1
  45. package/dist/client/static/js/{index-2w9j2nj4.js → index-82vk27q1.js} +1 -1
  46. package/dist/client/static/js/{index-0p43qr4k.js → index-8k7vjp8b.js} +1 -1
  47. package/dist/client/static/js/{index-4y0ayjfx.js → index-8kbp24xg.js} +1 -1
  48. package/dist/client/static/js/{index-xsts4pqm.js → index-cz50ha6x.js} +2 -2
  49. package/dist/client/static/js/{index-v5dbrq83.js → index-dtj73vs1.js} +1 -1
  50. package/dist/client/static/js/{index-x7m6dmt4.js → index-dzmar8jr.js} +1 -1
  51. package/dist/client/static/js/{index-313ctswm.js → index-f33c4paw.js} +1 -1
  52. package/dist/client/static/js/{index-001vebsp.js → index-fb6pw9xb.js} +1 -1
  53. package/dist/client/static/js/{index-qh753ynv.js → index-gp57dx2v.js} +1 -1
  54. package/dist/client/static/js/{index-rt6ac0kk.js → index-pzvr1699.js} +181 -181
  55. package/dist/client/static/js/{index-6dxs0tvg.js → index-r9db1gsf.js} +1 -1
  56. package/dist/client/static/js/{index-sr7sdm2t.js → index-raca8tsh.js} +1 -1
  57. package/dist/client/static/js/{index-y1p3bdsw.js → index-rf29f3fq.js} +1 -1
  58. package/dist/client/static/js/{index-kh6vp5w5.js → index-s4gv0rpk.js} +1 -1
  59. package/dist/client/static/js/{index-6eq445nn.js → index-v3f7we4n.js} +1 -1
  60. package/dist/client/static/js/{index-b37ewyvk.js → index-yjmm73jm.js} +1 -1
  61. package/dist/client/static/js/{index-w5q9ymf4.js → index-ykfd2fyj.js} +1 -1
  62. package/dist/client/static/js/{index-869bpqcs.js → index-yzda8j2d.js} +2 -2
  63. package/dist/client/static/js/{index-8pdz41yh.js → index-z78bzryw.js} +1 -1
  64. package/dist/client/static/js/{index-q3qpm7jn.js → index-zndbhb9w.js} +1 -1
  65. package/dist/client/static/js/{index-3d40c0a7.js → index-zs73zwjz.js} +1 -1
  66. package/dist/client/static/js/{index-mvykbyhe.js → index-zs7sjv6x.js} +1 -1
  67. package/dist/client/static/js/{index-5asf5625.js → index-zw621xez.js} +1 -1
  68. package/dist/client/static/js/{infoDiagram-VRGFBTTK-0anekyhb.js → infoDiagram-VRGFBTTK-4e7ej63f.js} +1 -1
  69. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-zxpmfkjb.js → ishikawaDiagram-OU5B5YK6-k3yet1ec.js} +1 -1
  70. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-1e86fzra.js → journeyDiagram-ZHPQQLJL-qe352kyd.js} +1 -1
  71. package/dist/client/static/js/{kanban-definition-PNTS6WVX-e85hhmr1.js → kanban-definition-PNTS6WVX-58hag75n.js} +1 -1
  72. package/dist/client/static/js/{mermaid.core-jpcrnzyw.js → mermaid.core-6e89h6vm.js} +2 -2
  73. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-xwy5928e.js → mindmap-definition-NLK3R4M7-ncsam2fm.js} +1 -1
  74. package/dist/client/static/js/one-dark-pro-qmyne0tn.js +1 -0
  75. package/dist/client/static/js/one-light-dj0ecjcj.js +1 -0
  76. package/dist/client/static/js/{pegDiagram-GJSIUBJH-7dy6pw26.js → pegDiagram-GJSIUBJH-b5ckc39d.js} +1 -1
  77. package/dist/client/static/js/{pieDiagram-5QR66LMP-nrv2t5yn.js → pieDiagram-5QR66LMP-s4d47ve8.js} +1 -1
  78. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-3nt63xr8.js → quadrantDiagram-O4NWA36T-zm0ekvjz.js} +1 -1
  79. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-evm05hzp.js → railroadDiagram-XR7U4H2S-52vdqf53.js} +1 -1
  80. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-tzrcmktj.js → requirementDiagram-PLB6GJNP-7kf8bmk9.js} +1 -1
  81. package/dist/client/static/js/{rust-pcvgybk3.js → rust-q98kssv3.js} +1 -1
  82. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-jvjd5rz8.js → sankeyDiagram-IPEJSGJF-bcb9f54a.js} +1 -1
  83. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-0zvjwx29.js → sequenceDiagram-PO4LG4MO-76ywvj7g.js} +1 -1
  84. package/dist/client/static/js/{sizeCapture-INFHLROL-6t6g0edv.js → sizeCapture-INFHLROL-p9bsf5dc.js} +1 -1
  85. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-nb13b23a.js → stateDiagram-v2-GCMORJYK-1ecfb3fs.js} +1 -1
  86. package/dist/client/static/js/{swimlanes-2SLR337P-ef8vmg6f.js → swimlanes-2SLR337P-2pyjr946.js} +1 -1
  87. package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-f4sx355z.js → swimlanesDiagram-TC7HE7FX-qr5hdxm4.js} +1 -1
  88. package/dist/client/static/js/{timeline-definition-EJHVYXUP-3bfph698.js → timeline-definition-EJHVYXUP-4csxwmn2.js} +1 -1
  89. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-vj6yj6tc.js → usecaseDiagram-POWQR4AR-0p1jnbsn.js} +1 -1
  90. package/dist/client/static/js/{vennDiagram-UO4OBE2U-9xyyabaq.js → vennDiagram-UO4OBE2U-y1hgdet4.js} +1 -1
  91. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-zpcwgv9d.js → wardleyDiagram-VNRHLVJA-p578yrgm.js} +1 -1
  92. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-pdr2rms2.js → xychartDiagram-PMCCYNJV-b08b4ah0.js} +1 -1
  93. package/package.json +1 -1
  94. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolBody.tsx +3 -3
  95. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolRowActions.tsx +45 -0
  96. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/tool-view.ts +14 -4
  97. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Card.tsx +2 -12
  98. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Compact.tsx +42 -38
  99. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Minimal.tsx +25 -21
  100. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Trace.tsx +41 -29
  101. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.tsx +47 -43
  102. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/parity.test.tsx +136 -0
  103. package/src/server/lib/omp/session/scan.ts +15 -2
  104. package/src/server/lib/omp/session/session-discovery.test.ts +21 -0
  105. package/src/shared/lib/chat/timeline/tool-render-mode.ts +3 -3
  106. package/src/shared/lib/omp/session/operator-title.test.ts +21 -0
  107. package/src/shared/lib/omp/session/operator-title.ts +28 -0
  108. package/dist/client/static/js/flowDiagram-KWPJA3E3-evp84v09.js +0 -1
  109. package/dist/client/static/js/one-dark-pro-r0tswz8r.js +0 -1
  110. package/dist/client/static/js/one-light-xzcfrptf.js +0 -1
@@ -1,2 +1,2 @@
1
- import{d,n,o,i,a,e,s,E,ne,Ne,Me,_,ni,rt,Te,_e,b,J,di,Vm}from"./index-rt6ac0kk.js";var B={name:"list-filter",size:24,node:[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]]},M=s(B);function I({title:t,options:r,methodLabel:p,badge:m,icon:x,onCancel:g}){let f=di({title:t,options:r})?Vm(t):null,h=f?`Allow ${f.tool}`:t||p;return e("div",{className:"flex items-center justify-between border-b border-ink/8 bg-canvas/40 px-5 py-3.5",children:[e("div",{className:"flex items-center gap-3 min-w-0",children:[e("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-ink/12 bg-paper text-ink shadow-xs",children:x}),e("div",{className:"min-w-0",children:[e("div",{className:"flex items-center gap-2",children:[e("h3",{className:"truncate text-[14px] font-semibold tracking-tight text-ink",children:h}),e("span",{className:"flex items-center gap-1 rounded-full border border-ink/10 bg-paper px-2 py-0.5 font-mono text-[10px] font-medium tracking-wider text-ink/60 uppercase",children:[e(Me,{size:9,className:"text-ink/40"}),m]})]}),e("p",{className:"mt-0.5 text-[11px] text-ink/50",children:f?"The agent wants to run this. Review it before you allow.":"Autonomous agent inquiry requiring user confirmation"})]})]}),e("button",{type:"button",onClick:g,"aria-label":"Close dialog (Esc)",title:"Cancel (Esc)",className:"flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded-lg border border-ink/10 text-ink/45 transition-colors hover:border-ink/25 hover:bg-ink/5 hover:text-ink",children:e(b,{size:14})})]})}function T({options:t,optionDetails:r,selectedOption:p,customValue:m,onCustomChange:x,customInputRef:g,onSelect:f,onConfirmOption:h,hideCustomAnswer:l=!1}){return e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Available Options"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:["Press [1-",Math.min(9,t.length),"] to choose"]})]}),e("div",{className:"grid gap-2",role:"radiogroup",children:t.map((k,y)=>{let u=p===k,v=r[y]?.description;return e("button",{type:"button",onClick:()=>f(k),onDblClick:()=>h(k),"aria-checked":u,role:"radio",className:`group flex w-full cursor-pointer items-start gap-3 rounded-xl border p-3.5 text-left transition-all ${u?"border-ink bg-paper shadow-sm ring-1 ring-ink/10":"border-ink/10 bg-canvas/30 hover:border-ink/25 hover:bg-paper"}`,children:[e("span",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md font-mono text-[11px] font-semibold transition-colors ${u?"bg-ink text-paper":"border border-ink/15 bg-paper text-ink/60 group-hover:border-ink/30 group-hover:text-ink"}`,children:y+1}),e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"flex items-center gap-2",children:e("span",{className:`text-[13px] font-medium leading-snug ${u?"text-ink font-semibold":"text-ink/85"}`,children:k})}),v&&e("div",{className:"mt-1 text-[11.5px] leading-relaxed text-ink/55",children:v})]}),e("span",{className:"mt-0.5 shrink-0",children:u?e(ne,{size:16,className:"text-ink"}):e(ni,{size:16,className:"text-ink/20 group-hover:text-ink/40"})})]},k)})}),!l&&e("div",{className:"space-y-1.5 pt-1",children:[e("div",{className:"text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:"Other: type your own answer"}),e("input",{ref:g,type:"text",value:m,placeholder:"Type a custom answer and press Enter...",onChange:(k)=>x(k.currentTarget.value),onKeyDown:(k)=>{if(k.key==="Enter"){if(k.preventDefault(),k.stopPropagation(),m.trim())h(m.trim())}},className:"w-full rounded-xl border border-ink/15 bg-paper px-4 py-3 text-[13.5px] text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:ring-2 focus:ring-ink/15"})]})]})}function S({method:t,optionsLength:r,selectedOption:p,hasCustomAnswer:m=!1,onCancel:x,onSubmit:g}){let f=t==="select"&&!p&&!m;return e("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t border-ink/8 bg-canvas/40 px-5 py-3.5",children:[e("div",{className:"flex items-center gap-2 font-mono text-[11px] text-ink/50",children:[t==="select"&&e(d,{children:[e("span",{className:"hidden items-center gap-1 sm:inline-flex",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:["1-",Math.min(9,r)]}),e("span",{className:"text-ink/40",children:"choose"})]}),e("span",{className:"hidden text-ink/30 sm:inline",children:"•"}),e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"↵"}),e("span",{className:"text-ink/40",children:"select"})]})]}),t==="confirm"&&e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"↵"}),e("span",{className:"text-ink/40",children:"confirm"})]}),t==="editor"&&e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"⌘↵"}),e("span",{className:"text-ink/40",children:"save buffer"})]}),e("span",{className:"text-ink/30",children:"•"}),e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"Esc"}),e("span",{className:"text-ink/40",children:"cancel"})]})]}),e("div",{className:"flex items-center gap-2.5 ml-auto",children:[e("button",{type:"button",onClick:x,className:"flex cursor-pointer items-center gap-1 rounded-lg border border-ink/15 bg-paper px-3.5 py-1.5 text-[12px] font-medium text-ink/70 transition-colors hover:border-ink/30 hover:bg-canvas/50 hover:text-ink",children:[e(b,{size:12,className:"opacity-60"}),e("span",{children:"Cancel"})]}),e("button",{type:"button",onClick:g,disabled:f,className:"flex cursor-pointer items-center gap-1.5 rounded-lg bg-ink px-4 py-1.5 text-[12px] font-semibold text-paper shadow-xs transition-all hover:opacity-90 active:scale-[0.98] disabled:cursor-not-allowed disabled:opacity-35",children:[e("span",{children:t==="confirm"?"Confirm":t==="select"?"Select Option":"Submit Response"}),e(rt,{size:12,className:"opacity-70"})]})]})]})}function P({title:t,options:r}){let p=di({title:t,options:r})?Vm(t):null;if(!p)return null;return e("div",{className:"space-y-2",children:[p.reason&&e("div",{className:"flex items-start gap-2 rounded-xl border border-warning/25 bg-warning/8 px-3.5 py-2.5 text-[12px] leading-relaxed text-ink/80",children:[e(_,{size:13,className:"mt-0.5 shrink-0 text-warning"}),e("span",{className:"min-w-0 break-words",children:p.reason})]}),p.details.length>0&&e("div",{className:"rounded-xl border border-ink/10 bg-canvas/40 px-3.5 py-2.5",children:p.details.map((m,x)=>e("div",{className:"font-mono text-[11.5px] leading-relaxed text-ink/75 break-all",children:m},`${x}-${m}`))})]})}function R({method:t,options:r,selectedOption:p,onSelectOption:m,customInputRef:x,onSubmit:g,onCancel:f}){o(()=>{let h=(l)=>{if(l.key==="Escape"){l.preventDefault(),l.stopPropagation(),f();return}if(t==="select"&&r.length>0){if(l.target instanceof HTMLInputElement&&l.target===x.current)return;let y=parseInt(l.key,10);if(!isNaN(y)&&y>=1&&y<=r.length){l.preventDefault(),m(r[y-1]);return}if(l.key==="ArrowDown"){l.preventDefault();let u=r.findIndex((N)=>N===p),v=u<r.length-1?u+1:0;m(r[v]);return}if(l.key==="ArrowUp"){l.preventDefault();let u=r.findIndex((N)=>N===p),v=u>0?u-1:r.length-1;m(r[v]);return}if(l.key==="Enter"&&p){l.preventDefault(),g();return}}if(t==="confirm"){if(l.key==="Enter"){l.preventDefault(),g();return}}if(t==="editor"){if((l.metaKey||l.ctrlKey)&&l.key==="Enter"){l.preventDefault(),g();return}}};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[f,g,t,r,p,m,x])}function L(t,r){switch(t){case"select":return{icon:e(M,{size:16,className:"text-ink"}),label:"Decision Required",badge:`${r} Choices`};case"confirm":return{icon:e(E,{size:16,className:"text-ink"}),label:"Confirmation Required",badge:"Confirm Action"};case"input":return{icon:e(_e,{size:16,className:"text-ink"}),label:"Prompt Input",badge:"Text Input"};case"editor":return{icon:e(Te,{size:16,className:"text-ink"}),label:"Buffer Editor",badge:"Multiline Buffer"};default:return{icon:e(Ne,{size:16,className:"text-ink"}),label:"Agent Request",badge:"Input"}}}function ke({request:t,onRespond:r}){let[p,m]=n(t.method==="editor"?t.prefill??"":""),[x,g]=n(null),[f,h]=n(""),l=i(null),k=i(null),y=i(null),u=i(null),v=t.options??[],N=t.optionDetails??[],C=di(t);o(()=>{let c=t.options??[];m(t.method==="editor"?t.prefill??"":""),g(c.length>0?c[0]:null),h("")},[t]),o(()=>{if(l.current?.focus(),t.method==="input")k.current?.focus();else if(t.method==="editor")y.current?.focus();else if(t.method==="select"){if((t.options??[]).some((H)=>/^other\b/i.test(H.trim())))u.current?.focus()}},[t]);let w=a(()=>{r(t,{cancelled:!0})},[r,t]),A=a(()=>{if(t.method==="confirm")r(t,{confirmed:!0});else if(t.method==="select"){if(f.trim()&&!C)r(t,{value:f.trim()});else if(x)r(t,{value:x})}else r(t,{value:p})},[r,t,x,p,f,C]),O=a((c)=>{if(/^other\b/i.test(c.trim())){g(c),u.current?.focus();return}r(t,{value:c})},[r,t]),z=a((c)=>{if(g(c),/^other\b/i.test(c.trim()))u.current?.focus()},[]);R({method:t.method,options:v,selectedOption:x,onSelectOption:g,customInputRef:u,onSubmit:A,onCancel:w});let D=L(t.method,v.length);return e("div",{className:"extension-dialog-backdrop modal-scrim fixed inset-0 z-50 flex items-center justify-center p-4 sm:p-6 backdrop-blur-[8px]",onMouseDown:(c)=>{if(c.target===c.currentTarget)w()},children:e("div",{ref:l,role:"dialog","aria-modal":"true","aria-label":t.title||D.label,tabIndex:-1,className:"glass-overlay extension-dialog-panel w-full max-w-[560px] overflow-hidden rounded-2xl border border-ink/15 bg-paper shadow-2xl outline-none",style:{boxShadow:"0 24px 64px -8px color-mix(in srgb, var(--theme-ink) 28%, transparent)"},children:[e(I,{title:t.title,options:v,methodLabel:D.label,badge:D.badge,icon:D.icon,onCancel:w}),e("div",{className:"max-h-[65vh] overflow-y-auto px-6 py-5 space-y-4",children:[e(P,{title:t.title,options:v}),t.message&&e("div",{className:"rounded-xl border border-ink/8 bg-canvas/40 p-4 text-[13px] leading-relaxed text-ink/85 select-text",children:e(J,{content:t.message})}),t.method==="select"&&e(T,{options:v,optionDetails:N,selectedOption:x,customValue:f,onCustomChange:h,customInputRef:u,onSelect:z,onConfirmOption:O,hideCustomAnswer:C}),t.method==="confirm"&&e("div",{className:"flex items-center gap-3 rounded-xl border border-ink/10 bg-canvas/30 p-4",children:[e("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-ink/5 text-ink",children:e(ne,{size:18})}),e("div",{className:"text-[12.5px] leading-relaxed text-ink/75",children:["Confirming will allow the autonomous agent to proceed with this operation. Press ",e("kbd",{className:"rounded border border-ink/20 bg-paper px-1 py-0.2 font-mono text-[10.5px]",children:"Enter"})," to confirm or ",e("kbd",{className:"rounded border border-ink/20 bg-paper px-1 py-0.2 font-mono text-[10.5px]",children:"Esc"})," to abort."]})]}),t.method==="input"&&e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Your Response"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:"Press [Enter] to submit"})]}),e("input",{ref:k,type:t.secret===!0?"password":"text",value:p,placeholder:t.placeholder||"Type your response...",onChange:(c)=>m(c.currentTarget.value),onKeyDown:(c)=>{if(c.key==="Enter")c.preventDefault(),A()},className:"w-full rounded-xl border border-ink/15 bg-paper px-4 py-3 text-[13.5px] text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:ring-2 focus:ring-ink/15"})]}),t.method==="editor"&&e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Buffer Content"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:[p.split(`
1
+ import{d,n,o,i,a,e,s,E,ne,Ne,Me,_,ni,rt,Te,_e,b,J,di,Vm}from"./index-pzvr1699.js";var B={name:"list-filter",size:24,node:[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]]},M=s(B);function I({title:t,options:r,methodLabel:p,badge:m,icon:x,onCancel:g}){let f=di({title:t,options:r})?Vm(t):null,h=f?`Allow ${f.tool}`:t||p;return e("div",{className:"flex items-center justify-between border-b border-ink/8 bg-canvas/40 px-5 py-3.5",children:[e("div",{className:"flex items-center gap-3 min-w-0",children:[e("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-ink/12 bg-paper text-ink shadow-xs",children:x}),e("div",{className:"min-w-0",children:[e("div",{className:"flex items-center gap-2",children:[e("h3",{className:"truncate text-[14px] font-semibold tracking-tight text-ink",children:h}),e("span",{className:"flex items-center gap-1 rounded-full border border-ink/10 bg-paper px-2 py-0.5 font-mono text-[10px] font-medium tracking-wider text-ink/60 uppercase",children:[e(Me,{size:9,className:"text-ink/40"}),m]})]}),e("p",{className:"mt-0.5 text-[11px] text-ink/50",children:f?"The agent wants to run this. Review it before you allow.":"Autonomous agent inquiry requiring user confirmation"})]})]}),e("button",{type:"button",onClick:g,"aria-label":"Close dialog (Esc)",title:"Cancel (Esc)",className:"flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded-lg border border-ink/10 text-ink/45 transition-colors hover:border-ink/25 hover:bg-ink/5 hover:text-ink",children:e(b,{size:14})})]})}function T({options:t,optionDetails:r,selectedOption:p,customValue:m,onCustomChange:x,customInputRef:g,onSelect:f,onConfirmOption:h,hideCustomAnswer:l=!1}){return e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Available Options"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:["Press [1-",Math.min(9,t.length),"] to choose"]})]}),e("div",{className:"grid gap-2",role:"radiogroup",children:t.map((k,y)=>{let u=p===k,v=r[y]?.description;return e("button",{type:"button",onClick:()=>f(k),onDblClick:()=>h(k),"aria-checked":u,role:"radio",className:`group flex w-full cursor-pointer items-start gap-3 rounded-xl border p-3.5 text-left transition-all ${u?"border-ink bg-paper shadow-sm ring-1 ring-ink/10":"border-ink/10 bg-canvas/30 hover:border-ink/25 hover:bg-paper"}`,children:[e("span",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md font-mono text-[11px] font-semibold transition-colors ${u?"bg-ink text-paper":"border border-ink/15 bg-paper text-ink/60 group-hover:border-ink/30 group-hover:text-ink"}`,children:y+1}),e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"flex items-center gap-2",children:e("span",{className:`text-[13px] font-medium leading-snug ${u?"text-ink font-semibold":"text-ink/85"}`,children:k})}),v&&e("div",{className:"mt-1 text-[11.5px] leading-relaxed text-ink/55",children:v})]}),e("span",{className:"mt-0.5 shrink-0",children:u?e(ne,{size:16,className:"text-ink"}):e(ni,{size:16,className:"text-ink/20 group-hover:text-ink/40"})})]},k)})}),!l&&e("div",{className:"space-y-1.5 pt-1",children:[e("div",{className:"text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:"Other: type your own answer"}),e("input",{ref:g,type:"text",value:m,placeholder:"Type a custom answer and press Enter...",onChange:(k)=>x(k.currentTarget.value),onKeyDown:(k)=>{if(k.key==="Enter"){if(k.preventDefault(),k.stopPropagation(),m.trim())h(m.trim())}},className:"w-full rounded-xl border border-ink/15 bg-paper px-4 py-3 text-[13.5px] text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:ring-2 focus:ring-ink/15"})]})]})}function S({method:t,optionsLength:r,selectedOption:p,hasCustomAnswer:m=!1,onCancel:x,onSubmit:g}){let f=t==="select"&&!p&&!m;return e("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t border-ink/8 bg-canvas/40 px-5 py-3.5",children:[e("div",{className:"flex items-center gap-2 font-mono text-[11px] text-ink/50",children:[t==="select"&&e(d,{children:[e("span",{className:"hidden items-center gap-1 sm:inline-flex",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:["1-",Math.min(9,r)]}),e("span",{className:"text-ink/40",children:"choose"})]}),e("span",{className:"hidden text-ink/30 sm:inline",children:"•"}),e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"↵"}),e("span",{className:"text-ink/40",children:"select"})]})]}),t==="confirm"&&e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"↵"}),e("span",{className:"text-ink/40",children:"confirm"})]}),t==="editor"&&e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"⌘↵"}),e("span",{className:"text-ink/40",children:"save buffer"})]}),e("span",{className:"text-ink/30",children:"•"}),e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"Esc"}),e("span",{className:"text-ink/40",children:"cancel"})]})]}),e("div",{className:"flex items-center gap-2.5 ml-auto",children:[e("button",{type:"button",onClick:x,className:"flex cursor-pointer items-center gap-1 rounded-lg border border-ink/15 bg-paper px-3.5 py-1.5 text-[12px] font-medium text-ink/70 transition-colors hover:border-ink/30 hover:bg-canvas/50 hover:text-ink",children:[e(b,{size:12,className:"opacity-60"}),e("span",{children:"Cancel"})]}),e("button",{type:"button",onClick:g,disabled:f,className:"flex cursor-pointer items-center gap-1.5 rounded-lg bg-ink px-4 py-1.5 text-[12px] font-semibold text-paper shadow-xs transition-all hover:opacity-90 active:scale-[0.98] disabled:cursor-not-allowed disabled:opacity-35",children:[e("span",{children:t==="confirm"?"Confirm":t==="select"?"Select Option":"Submit Response"}),e(rt,{size:12,className:"opacity-70"})]})]})]})}function P({title:t,options:r}){let p=di({title:t,options:r})?Vm(t):null;if(!p)return null;return e("div",{className:"space-y-2",children:[p.reason&&e("div",{className:"flex items-start gap-2 rounded-xl border border-warning/25 bg-warning/8 px-3.5 py-2.5 text-[12px] leading-relaxed text-ink/80",children:[e(_,{size:13,className:"mt-0.5 shrink-0 text-warning"}),e("span",{className:"min-w-0 break-words",children:p.reason})]}),p.details.length>0&&e("div",{className:"rounded-xl border border-ink/10 bg-canvas/40 px-3.5 py-2.5",children:p.details.map((m,x)=>e("div",{className:"font-mono text-[11.5px] leading-relaxed text-ink/75 break-all",children:m},`${x}-${m}`))})]})}function R({method:t,options:r,selectedOption:p,onSelectOption:m,customInputRef:x,onSubmit:g,onCancel:f}){o(()=>{let h=(l)=>{if(l.key==="Escape"){l.preventDefault(),l.stopPropagation(),f();return}if(t==="select"&&r.length>0){if(l.target instanceof HTMLInputElement&&l.target===x.current)return;let y=parseInt(l.key,10);if(!isNaN(y)&&y>=1&&y<=r.length){l.preventDefault(),m(r[y-1]);return}if(l.key==="ArrowDown"){l.preventDefault();let u=r.findIndex((N)=>N===p),v=u<r.length-1?u+1:0;m(r[v]);return}if(l.key==="ArrowUp"){l.preventDefault();let u=r.findIndex((N)=>N===p),v=u>0?u-1:r.length-1;m(r[v]);return}if(l.key==="Enter"&&p){l.preventDefault(),g();return}}if(t==="confirm"){if(l.key==="Enter"){l.preventDefault(),g();return}}if(t==="editor"){if((l.metaKey||l.ctrlKey)&&l.key==="Enter"){l.preventDefault(),g();return}}};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[f,g,t,r,p,m,x])}function L(t,r){switch(t){case"select":return{icon:e(M,{size:16,className:"text-ink"}),label:"Decision Required",badge:`${r} Choices`};case"confirm":return{icon:e(E,{size:16,className:"text-ink"}),label:"Confirmation Required",badge:"Confirm Action"};case"input":return{icon:e(_e,{size:16,className:"text-ink"}),label:"Prompt Input",badge:"Text Input"};case"editor":return{icon:e(Te,{size:16,className:"text-ink"}),label:"Buffer Editor",badge:"Multiline Buffer"};default:return{icon:e(Ne,{size:16,className:"text-ink"}),label:"Agent Request",badge:"Input"}}}function ke({request:t,onRespond:r}){let[p,m]=n(t.method==="editor"?t.prefill??"":""),[x,g]=n(null),[f,h]=n(""),l=i(null),k=i(null),y=i(null),u=i(null),v=t.options??[],N=t.optionDetails??[],C=di(t);o(()=>{let c=t.options??[];m(t.method==="editor"?t.prefill??"":""),g(c.length>0?c[0]:null),h("")},[t]),o(()=>{if(l.current?.focus(),t.method==="input")k.current?.focus();else if(t.method==="editor")y.current?.focus();else if(t.method==="select"){if((t.options??[]).some((H)=>/^other\b/i.test(H.trim())))u.current?.focus()}},[t]);let w=a(()=>{r(t,{cancelled:!0})},[r,t]),A=a(()=>{if(t.method==="confirm")r(t,{confirmed:!0});else if(t.method==="select"){if(f.trim()&&!C)r(t,{value:f.trim()});else if(x)r(t,{value:x})}else r(t,{value:p})},[r,t,x,p,f,C]),O=a((c)=>{if(/^other\b/i.test(c.trim())){g(c),u.current?.focus();return}r(t,{value:c})},[r,t]),z=a((c)=>{if(g(c),/^other\b/i.test(c.trim()))u.current?.focus()},[]);R({method:t.method,options:v,selectedOption:x,onSelectOption:g,customInputRef:u,onSubmit:A,onCancel:w});let D=L(t.method,v.length);return e("div",{className:"extension-dialog-backdrop modal-scrim fixed inset-0 z-50 flex items-center justify-center p-4 sm:p-6 backdrop-blur-[8px]",onMouseDown:(c)=>{if(c.target===c.currentTarget)w()},children:e("div",{ref:l,role:"dialog","aria-modal":"true","aria-label":t.title||D.label,tabIndex:-1,className:"glass-overlay extension-dialog-panel w-full max-w-[560px] overflow-hidden rounded-2xl border border-ink/15 bg-paper shadow-2xl outline-none",style:{boxShadow:"0 24px 64px -8px color-mix(in srgb, var(--theme-ink) 28%, transparent)"},children:[e(I,{title:t.title,options:v,methodLabel:D.label,badge:D.badge,icon:D.icon,onCancel:w}),e("div",{className:"max-h-[65vh] overflow-y-auto px-6 py-5 space-y-4",children:[e(P,{title:t.title,options:v}),t.message&&e("div",{className:"rounded-xl border border-ink/8 bg-canvas/40 p-4 text-[13px] leading-relaxed text-ink/85 select-text",children:e(J,{content:t.message})}),t.method==="select"&&e(T,{options:v,optionDetails:N,selectedOption:x,customValue:f,onCustomChange:h,customInputRef:u,onSelect:z,onConfirmOption:O,hideCustomAnswer:C}),t.method==="confirm"&&e("div",{className:"flex items-center gap-3 rounded-xl border border-ink/10 bg-canvas/30 p-4",children:[e("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-ink/5 text-ink",children:e(ne,{size:18})}),e("div",{className:"text-[12.5px] leading-relaxed text-ink/75",children:["Confirming will allow the autonomous agent to proceed with this operation. Press ",e("kbd",{className:"rounded border border-ink/20 bg-paper px-1 py-0.2 font-mono text-[10.5px]",children:"Enter"})," to confirm or ",e("kbd",{className:"rounded border border-ink/20 bg-paper px-1 py-0.2 font-mono text-[10.5px]",children:"Esc"})," to abort."]})]}),t.method==="input"&&e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Your Response"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:"Press [Enter] to submit"})]}),e("input",{ref:k,type:t.secret===!0?"password":"text",value:p,placeholder:t.placeholder||"Type your response...",onChange:(c)=>m(c.currentTarget.value),onKeyDown:(c)=>{if(c.key==="Enter")c.preventDefault(),A()},className:"w-full rounded-xl border border-ink/15 bg-paper px-4 py-3 text-[13.5px] text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:ring-2 focus:ring-ink/15"})]}),t.method==="editor"&&e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Buffer Content"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:[p.split(`
2
2
  `).length," lines · ⌘↵ to save"]})]}),e("textarea",{ref:y,value:p,onChange:(c)=>m(c.currentTarget.value),rows:8,placeholder:t.placeholder||"Enter content...",className:"w-full rounded-xl border border-ink/15 bg-canvas/30 px-4 py-3 font-mono text-[12px] leading-relaxed text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:bg-paper focus:ring-2 focus:ring-ink/15"})]})]}),e(S,{method:t.method,optionsLength:v.length,selectedOption:x,hasCustomAnswer:f.trim().length>0,onCancel:w,onSubmit:A})]})})}export{ke as ExtensionDialog};
@@ -1 +1 @@
1
- import{d,n,o,i,a,e,S,m,L,tn,ba,Qe,D,Pn,b,DA,Xp,Yu,NA,ic}from"./index-rt6ac0kk.js";import{Cu}from"./index-8fvmyv7t.js";import"./index-df4yxfzd.js";var de={idle:"Kosong",loading:"Memuat",ready:"Siap"},V="p-1 rounded hover:bg-ink/5 disabled:opacity-25 disabled:hover:bg-transparent text-ink/70 hover:text-ink cursor-pointer disabled:cursor-not-allowed transition-colors";function K({url:t,input:s,loading:r,error:l,canGoBack:p,canGoForward:f,viewportMode:h,zoomLevel:c,onInputChange:x,onSubmit:A,onBack:P,onForward:T,onReload:v,onOpenExternal:E,onIncludeInChat:I,onChangeViewport:C,onZoomIn:N,onZoomOut:B,onResetZoom:u,onSetZoom:g,annotate:k}){let w=i(void 0);o(()=>{if(w.current===t)return;if(w.current=t,t)x(t)},[t,x]);let M=!t?"idle":r?"loading":"ready",O=M==="ready"?"bg-success animate-pulse":M==="loading"?"bg-ink/40 animate-pulse":"bg-ink/25",H=e("div",{className:"flex items-center bg-canvas border border-ink/10 rounded-md p-0.5 space-x-0.5 flex-shrink-0",children:[e("button",{type:"button",onClick:P,disabled:!p,"aria-label":"Back",title:"Back",className:V,children:e(tn,{size:12})}),e("button",{type:"button",onClick:T,disabled:!f,"aria-label":"Maju",title:"Maju",className:V,children:e(ba,{size:12})}),e("button",{type:"button",onClick:v,disabled:!t,"aria-label":"Reload",title:"Reload",className:V,children:e(D,{size:12,className:r?"animate-spin":void 0})})]});return e(Cu,{url:t,statusDotClass:O,statusLabel:de[M],viewportMode:h,zoomLevel:c,onChangeViewport:C,onZoomIn:N,onZoomOut:B,onResetZoom:u,onSetZoom:g,annotate:k,onIncludeInChat:I,onOpenExternal:E,openExternalLabel:"Buka di tab baru",openExternalTitle:"Buka di tab baru (untuk situs yang menolak iframe)",children:e("div",{className:"flex items-center flex-1 min-w-0 space-x-1.5",children:[H,e("form",{className:`flex-1 min-w-0 flex items-center bg-canvas border rounded-md px-2 py-0.5 space-x-1 focus-within:border-ink/40 ${l?"border-error":"border-ink/15"}`,onSubmit:(y)=>{y.preventDefault(),A(s)},children:[e(Qe,{size:12,className:"text-ink/40 flex-shrink-0"}),e("input",{type:"text",value:s,onChange:(y)=>x(y.currentTarget.value),placeholder:"Type an address (e.g. localhost:5173) and press Enter…","aria-label":"Browser address","aria-invalid":l!==void 0&&l!==null,title:l??void 0,spellcheck:!1,autoComplete:"off",className:`w-full min-w-0 bg-transparent outline-none font-mono text-[11px] placeholder:text-ink/35 ${l?"text-error":"text-ink/90"}`})]})]})})}var Z={"desktop-16-9":"w-full max-w-[1280px] aspect-video max-h-full border border-ink/20 rounded-lg shadow-md overflow-hidden my-auto",laptop:"w-[1024px] max-w-full h-[768px] max-h-full border border-ink/20 rounded-lg shadow-md overflow-hidden my-auto",tablet:"w-[768px] max-w-full h-[1024px] max-h-full border border-ink/20 rounded-lg shadow-md overflow-hidden my-auto",mobile:"w-[375px] max-w-full h-[667px] max-h-full border border-ink/20 rounded-xl shadow-md overflow-hidden my-auto","mobile-lg":"w-[414px] max-w-full h-[896px] max-h-full border border-ink/20 rounded-xl shadow-md overflow-hidden my-auto",responsive:"w-full h-full border-0"};var ce="clipboard-read; clipboard-write; fullscreen";function X({url:t,frameKey:s,loading:r,viewportMode:l,zoomLevel:p,onLoad:f,active:h=!0,overlay:c,onFrame:x}){if(!h)return null;if(!t)return e("div",{className:"flex-1 flex flex-col items-center justify-center p-6 text-center select-none",children:[e("div",{className:"w-12 h-12 rounded-xl bg-ink/5 border border-ink/10 flex items-center justify-center text-ink/40 mb-3",children:e(Qe,{size:22})}),e("h3",{className:"text-sm font-semibold text-ink mb-1",children:"Browser Anda"}),e("p",{className:"text-xs text-ink/60 max-w-sm",children:"Type an address above and press Enter. The page loads inside this panel."}),e("p",{className:"text-[11px] text-ink/45 max-w-sm mt-2",children:"Sebagian situs (Google, GitHub) menolak ditampilkan dalam iframe — pakai tombol buka di tab baru."})]});return e("div",{className:"flex-1 min-h-0 relative flex items-center justify-center p-2 overflow-auto bg-canvas/60",children:[r?e("div",{className:"absolute inset-0 z-10 flex items-center justify-center pointer-events-none",children:e("div",{className:"flex items-center space-x-2 px-3 py-1.5 rounded-md bg-paper border border-ink/15",children:[e(m,{size:13,className:"animate-spin text-ink/50"}),e("span",{className:"text-[11px] font-mono text-ink/60",children:"Memuat…"})]})}):null,e("div",{className:`relative flex flex-col bg-white ${Z[l]} transition-all duration-200`,style:{zoom:p!==100?`${p}%`:void 0,transformOrigin:"top center"},children:[e("iframe",{ref:(A)=>x?.(A),src:t,title:"Browser pengguna",onLoad:f,referrerPolicy:"no-referrer",allow:ce,className:"w-full h-full bg-white border-0",style:c?{pointerEvents:"none"}:void 0},s),c]})]})}var W="w-full min-w-0 bg-canvas border border-ink/15 rounded px-2 py-1 text-[11px] font-mono text-ink placeholder:text-ink/35 focus:outline-none focus:border-ink/40";function ue(t){if(!t||t.ok)return null;if(t.reason==="cross-origin")return"This page is cross-origin, so its elements cannot be read. Name the part and add a note instead.";if(t.reason==="no-frame")return"The page has not loaded, so its elements cannot be read yet.";return"There is no element at this point (empty space). Name the part instead."}function Y({shape:t,index:s,readability:r,onLabel:l,onNote:p}){let f=ue(r),h=t.element;return e("div",{className:"flex items-start gap-1.5 min-w-0",children:[e("span",{className:"text-[11px] font-mono text-ink/45 pt-1 flex-shrink-0",children:[Yu[t.tool]," #",s]}),e("div",{className:"flex-1 min-w-0 space-y-1",children:[e("div",{className:"flex items-center gap-1 flex-wrap",children:[e("span",{className:"text-[10px] uppercase font-mono text-ink/40",children:"bagian"}),NA.map((c)=>{let x=t.label===c;return e("button",{type:"button",onClick:()=>l(x?"":c),"aria-pressed":x,className:`px-1.5 py-0.5 rounded-full border text-[10px] font-mono transition-colors cursor-pointer ${x?"bg-ink text-canvas border-ink":"bg-canvas text-ink/65 border-ink/15 hover:border-ink/40"}`,children:c},c)}),e("input",{value:t.label,onInput:(c)=>l(c.currentTarget.value),placeholder:"or type your own…","aria-label":"Name of the marked part",spellcheck:!1,className:`${W} flex-1 min-w-[110px]`})]}),e("textarea",{value:t.note,onInput:(c)=>p(c.currentTarget.value),placeholder:"What is wrong with this part? (e.g. the Pay button looks disabled)",rows:2,"aria-label":"Annotation note",className:`${W} resize-y`}),h?e("p",{className:"text-[10px] font-mono text-ink/45 truncate",title:h.path,children:["elemen: ",h.path,h.state?` · ${h.state}`:""]}):null,f?e("p",{className:"text-[10px] text-ink/40",children:f}):null]})]})}var me=["box","pin","arrow"],pe="px-2 py-1 rounded text-[11px] font-mono border transition-colors cursor-pointer",U="flex items-center gap-1 px-2 py-1 rounded text-[11px] border border-ink/15 hover:border-ink/40 text-ink/80 hover:text-ink transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed";function j({tool:t,shapes:s,selectedId:r,readability:l,onTool:p,onLabel:f,onNote:h,onRemove:c,onReset:x,onCancel:A,onSend:P}){let T=s.find((E)=>E.id===r)??null,v=s.length>0;return e("div",{className:"flex-shrink-0 border-b border-ink/10 bg-paper px-2.5 py-1.5 space-y-1.5 select-none",children:[e("div",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-[10px] uppercase font-mono text-ink/50 mr-1",children:"Anotasi"}),me.map((E)=>e("button",{type:"button",onClick:()=>p(E),"aria-pressed":t===E,className:`${pe} ${t===E?"bg-ink text-canvas border-ink":"bg-canvas text-ink/70 border-ink/15 hover:border-ink/40"}`,children:Yu[E]},E)),e("span",{className:"text-[11px] font-mono text-ink/45 ml-1",children:s.length>0?`${s.length} mark${s.length===1?"":"s"}`:"drag on the page to mark a part"}),e("div",{className:"flex-1"}),e("button",{type:"button",onClick:x,disabled:!v,className:U,title:"Clear all marks",children:[e(L,{size:12})," Bersihkan"]}),e("button",{type:"button",onClick:P,disabled:!v,className:U,title:"Kirim anotasi ke draft chat",children:[e(Pn,{size:12})," Kirim ke chat"]}),e("button",{type:"button",onClick:A,className:U,title:"Tutup mode anotasi",children:e(b,{size:12})})]}),T?e("div",{className:"flex items-start gap-1.5",children:[e("div",{className:"flex-1 min-w-0",children:e(Y,{shape:T,index:s.indexOf(T)+1,readability:l,onLabel:(E)=>f(T.id,E),onNote:(E)=>h(T.id,E)})}),e("button",{type:"button",onClick:()=>c(T.id),className:U,title:"Remove this mark",children:e(L,{size:12})})]}):e("p",{className:"text-[11px] text-ink/45",children:"This page cannot be screenshotted, so what gets sent is the area, the part name and your note."})]})}var q=0;function J(){return q+=1,`annot-${Date.now().toString(36)}-${q}`}function Q(t){let[s,r]=n(!1),[l,p]=n("box"),[f,h]=n([]),[c,x]=n(null);o(()=>{h([]),x(null)},[t]);let A=a(()=>{r((N)=>!N),x(null)},[]),P=a(()=>{x(null),r(!1)},[]),T=a((N)=>{h((B)=>[...B,N]),x(N.id)},[]),v=a((N,B)=>{h((u)=>u.map((g)=>g.id===N?{...g,note:B}:g))},[]),E=a((N,B)=>{h((u)=>u.map((g)=>g.id===N?{...g,label:B}:g))},[]),I=a((N)=>{h((B)=>B.filter((u)=>u.id!==N)),x((B)=>B===N?null:B)},[]),C=a(()=>{h([]),x(null)},[]);return{active:s,tool:l,shapes:f,selectedId:c,setTool:p,toggle:A,close:P,add:T,setNote:v,setLabel:E,select:x,remove:I,reset:C}}var fe=4,_="var(--theme-error)";function ee({shapes:t,tool:s,selectedId:r,onMeasure:l,onAdd:p,onSelect:f}){let h=i(null),c=i(null),[x,A]=n(null),[P,T]=n({width:0,height:0});o(()=>{let u=h.current;if(!u)return;let g=()=>{let w=u.getBoundingClientRect();if(w.width<=0||w.height<=0)return;T((M)=>M.width===w.width&&M.height===w.height?M:{width:w.width,height:w.height}),l({width:w.width,height:w.height})};if(g(),typeof ResizeObserver!=="function")return;let k=new ResizeObserver(g);return k.observe(u),()=>k.disconnect()},[l]);let v=(u)=>{let g=h.current;if(!g)return null;let k=g.getBoundingClientRect(),w={x:u.clientX-k.left,y:u.clientY-k.top};return{normalized:DA(k,w),px:w.x,py:w.y}},E=(u)=>{if(u.button!==0)return;let g=v(u);if(!g)return;u.preventDefault(),f(null),u.currentTarget.setPointerCapture?.(u.pointerId);let k={id:J(),tool:s,start:g.normalized,end:g.normalized,label:"",note:""};c.current=k,A(k)},I=(u)=>{let g=c.current;if(!g)return;let k=v(u);if(!k)return;let w={...g,end:k.normalized};c.current=w,A(w)},C=(u)=>{let g=c.current;if(!g)return;let k=v(u),w=k?{...g,end:k.normalized}:g;if(c.current=null,A(null),u.currentTarget.releasePointerCapture?.(u.pointerId),w.tool!=="pin"){let M=h.current?.getBoundingClientRect();if((M?Math.hypot((w.end.x-w.start.x)*M.width,(w.end.y-w.start.y)*M.height):0)<fe)return}p(w)},N=()=>{c.current=null,A(null)},B=x?[...t,x]:t;return e("div",{ref:h,className:"absolute inset-0 cursor-crosshair touch-none",onPointerDown:E,onPointerMove:I,onPointerUp:C,onPointerCancel:N,children:e("svg",{className:"absolute inset-0 w-full h-full",viewBox:`0 0 ${Math.max(1,P.width)} ${Math.max(1,P.height)}`,preserveAspectRatio:"none","aria-label":"Page annotation area",children:B.map((u,g)=>e(he,{shape:u,index:g+1,box:P,selected:u.id===r,onSelect:()=>f(u.id)},u.id))})})}function he({shape:t,index:s,box:r,selected:l,onSelect:p}){let f={x:t.start.x*r.width,y:t.start.y*r.height},h={x:t.end.x*r.width,y:t.end.y*r.height},c=Xp(t),x=l?3:2,A=String(s);return e("g",{onPointerDown:(T)=>{T.stopPropagation(),T.preventDefault(),p()},className:"cursor-pointer",children:[t.tool==="box"&&e("rect",{x:c.x*r.width,y:c.y*r.height,width:Math.max(1,c.width*r.width),height:Math.max(1,c.height*r.height),fill:_,fillOpacity:l?0.16:0.1,stroke:_,strokeWidth:x,vectorEffect:"non-scaling-stroke",rx:3}),t.tool==="arrow"&&e(d,{children:[e("line",{x1:f.x,y1:f.y,x2:h.x,y2:h.y,stroke:_,strokeWidth:x,vectorEffect:"non-scaling-stroke"}),e("circle",{cx:h.x,cy:h.y,r:4,fill:_})]}),t.tool==="pin"&&e("circle",{cx:f.x,cy:f.y,r:7,fill:_,fillOpacity:l?0.5:0.3,stroke:_,strokeWidth:x}),e("circle",{cx:f.x,cy:f.y,r:9,fill:_}),e("text",{x:f.x,y:f.y,textAnchor:"middle",dominantBaseline:"central",fontSize:11,fontWeight:700,fill:"var(--theme-paper)",children:A})]})}function te(t){let s=t.trim();if(!s)return s;let r=/^[a-z][a-z0-9+.-]*:/i.test(s)?s:`https://${s}`,l=new URL(r);if(l.protocol!=="http:"&&l.protocol!=="https:")throw Error("Only http and https URLs are allowed");return l.toString()}var ge="userBrowser.history",be="userBrowser.historyIndex",xe="userBrowser.inputUrl";function ne(){let[t,s]=S(ge,[]),[r,l]=S(be,-1),[p,f]=S(xe,""),[h,c]=n(0),[x,A]=n(!1),[P,T]=n(void 0),v=r>=0&&r<t.length?t[r]??"":"",E=a((u)=>{let g=u.trim();if(!g)return;let k;try{k=te(g)}catch(O){T(O instanceof Error?O.message:"Alamat tidak valid");return}T(void 0),A(!0);let M=[...t.slice(0,r+1),k];s(M),l(M.length-1),f(k),c((O)=>O+1)},[t,r,s,l,f]),I=a(()=>{if(r<=0)return;A(!0),l(r-1)},[r,l]),C=a(()=>{if(r>=t.length-1)return;A(!0),l(r+1)},[t.length,r,l]),N=a(()=>{if(!v)return;A(!0),c((u)=>u+1)},[v]),B=a(()=>{A(!1)},[]);return{url:v,input:p,setInput:f,frameKey:h,loading:x,error:P,canGoBack:r>0,canGoForward:r>=0&&r<t.length-1,submit:E,goBack:I,goForward:C,reload:N,markLoaded:B}}function we(t){if(!t)return"no-frame";try{return t.contentDocument?"readable":"cross-origin"}catch{return"cross-origin"}}function F(t){let s=t.replace(/\s+/g," ").trim();return s.length>60?`${s.slice(0,59)}…`:s}function ve(t){let s=t.tagName.toLowerCase();if(t.id)return`${s}#${t.id}`;for(let l of["data-testid","data-test","aria-label"]){let p=t.getAttribute(l);if(p)return`${s}[${l}="${F(p)}"]`}let r=t.getAttribute("role");if(r)return`${s}[role="${r}"]`;return s}function ye(t){let s=[],r=t;while(r&&s.length<4){if(r.tagName.toLowerCase()==="html")break;s.unshift(ve(r)),r=r.parentElement}return s.join(" > ")}function ke(t){let s=[];if(t.disabled)s.push("nonaktif");if(t instanceof HTMLSelectElement||t.tagName.toLowerCase()==="select"){let r=t,p=r.selectedOptions?.[0]?.textContent?.trim()||r.value;if(p)s.push(`nilai "${F(p)}"`);let f=r.options?.length??0;if(f>0)s.push(`${f} opsi`)}else if(t.tagName.toLowerCase()==="input"){let r=t;if(r.type)s.push(`tipe ${r.type}`);if(r.type!=="password"&&r.placeholder)s.push(`placeholder "${F(r.placeholder)}"`)}return s.length>0?s.join(", "):void 0}function Ae(t){let s={path:ye(t),tag:t.tagName.toLowerCase()},r=t.getAttribute("role");if(r)s.role=r;let l=F(t.innerText??t.textContent??"");if(l)s.text=l;let p=ke(t);if(p)s.state=p;return s}function oe(t,s){let r=we(t);if(r!=="readable")return{ok:!1,reason:r};let{contentWindow:l,contentDocument:p}=t;if(!l||!p)return{ok:!1,reason:"cross-origin"};try{let f=Math.min(Math.max(s.x,0),1)*l.innerWidth,h=Math.min(Math.max(s.y,0),1)*l.innerHeight,c=p.elementFromPoint(f,h);if(!c||c===p.documentElement||c===p.body)return{ok:!1,reason:"no-element"};return{ok:!0,element:Ae(c)}}catch{return{ok:!1,reason:"cross-origin"}}}function mt({className:t="",active:s=!0}){let[r,l]=S("userBrowser.viewportMode","responsive"),[p,f]=S("userBrowser.zoomLevel",100),[h,c]=n(null),[x,A]=n(null),[P,T]=n(null),{url:v,input:E,setInput:I,frameKey:C,loading:N,error:B,canGoBack:u,canGoForward:g,submit:k,goBack:w,goForward:M,reload:O,markLoaded:H}=ne(),y=Q(C),re=a(()=>{if(!v)return;window.open(v,"_blank","noopener,noreferrer")},[v]),ae=a(()=>{if(!v)return;ic({url:v})},[v]),ie=a((R)=>{c((z)=>z&&z.width===R.width&&z.height===R.height?z:R)},[]),se=a((R)=>{let z=oe(x,R.start);T(z),y.add(z.ok?{...R,element:z.element}:R)},[y,x]),le=a(()=>{if(!v||y.shapes.length===0)return;let R=p/100;ic({url:v,annotations:y.shapes,panel:{width:(h?.width??0)/R,height:(h?.height??0)/R,viewportMode:r,zoom:p}}),y.close()},[v,y,h,r,p]),G=y.active&&Boolean(v);return e("div",{className:`flex flex-col h-full w-full bg-paper text-ink overflow-hidden ${t}`,children:[e(K,{url:v,input:E,loading:N,error:B,canGoBack:u,canGoForward:g,viewportMode:r,zoomLevel:p,onInputChange:I,onSubmit:k,onBack:w,onForward:M,onReload:O,onOpenExternal:re,onIncludeInChat:ae,onChangeViewport:l,onZoomIn:()=>f((R)=>Math.min(200,R+10)),onZoomOut:()=>f((R)=>Math.max(50,R-10)),onResetZoom:()=>f(100),onSetZoom:f,annotate:{active:G,count:y.shapes.length,onToggle:y.toggle}}),G&&e(j,{tool:y.tool,shapes:y.shapes,selectedId:y.selectedId,readability:P,onTool:y.setTool,onLabel:y.setLabel,onNote:y.setNote,onRemove:y.remove,onReset:y.reset,onCancel:y.close,onSend:le}),e(X,{url:v,frameKey:C,loading:N,viewportMode:r,zoomLevel:p,onLoad:H,onFrame:A,active:s,overlay:G?e(ee,{shapes:y.shapes,tool:y.tool,selectedId:y.selectedId,onMeasure:ie,onAdd:se,onSelect:y.select}):null})]})}export{mt as UserBrowserPanel};
1
+ import{d,n,o,i,a,e,S,m,L,tn,ba,Qe,D,Pn,b,DA,Xp,Yu,NA,ic}from"./index-pzvr1699.js";import{Cu}from"./index-77t0nvt1.js";import"./index-0e9nkc0g.js";var de={idle:"Kosong",loading:"Memuat",ready:"Siap"},V="p-1 rounded hover:bg-ink/5 disabled:opacity-25 disabled:hover:bg-transparent text-ink/70 hover:text-ink cursor-pointer disabled:cursor-not-allowed transition-colors";function K({url:t,input:s,loading:r,error:l,canGoBack:p,canGoForward:f,viewportMode:h,zoomLevel:c,onInputChange:x,onSubmit:A,onBack:P,onForward:T,onReload:v,onOpenExternal:E,onIncludeInChat:I,onChangeViewport:C,onZoomIn:N,onZoomOut:B,onResetZoom:u,onSetZoom:g,annotate:k}){let w=i(void 0);o(()=>{if(w.current===t)return;if(w.current=t,t)x(t)},[t,x]);let M=!t?"idle":r?"loading":"ready",O=M==="ready"?"bg-success animate-pulse":M==="loading"?"bg-ink/40 animate-pulse":"bg-ink/25",H=e("div",{className:"flex items-center bg-canvas border border-ink/10 rounded-md p-0.5 space-x-0.5 flex-shrink-0",children:[e("button",{type:"button",onClick:P,disabled:!p,"aria-label":"Back",title:"Back",className:V,children:e(tn,{size:12})}),e("button",{type:"button",onClick:T,disabled:!f,"aria-label":"Maju",title:"Maju",className:V,children:e(ba,{size:12})}),e("button",{type:"button",onClick:v,disabled:!t,"aria-label":"Reload",title:"Reload",className:V,children:e(D,{size:12,className:r?"animate-spin":void 0})})]});return e(Cu,{url:t,statusDotClass:O,statusLabel:de[M],viewportMode:h,zoomLevel:c,onChangeViewport:C,onZoomIn:N,onZoomOut:B,onResetZoom:u,onSetZoom:g,annotate:k,onIncludeInChat:I,onOpenExternal:E,openExternalLabel:"Buka di tab baru",openExternalTitle:"Buka di tab baru (untuk situs yang menolak iframe)",children:e("div",{className:"flex items-center flex-1 min-w-0 space-x-1.5",children:[H,e("form",{className:`flex-1 min-w-0 flex items-center bg-canvas border rounded-md px-2 py-0.5 space-x-1 focus-within:border-ink/40 ${l?"border-error":"border-ink/15"}`,onSubmit:(y)=>{y.preventDefault(),A(s)},children:[e(Qe,{size:12,className:"text-ink/40 flex-shrink-0"}),e("input",{type:"text",value:s,onChange:(y)=>x(y.currentTarget.value),placeholder:"Type an address (e.g. localhost:5173) and press Enter…","aria-label":"Browser address","aria-invalid":l!==void 0&&l!==null,title:l??void 0,spellcheck:!1,autoComplete:"off",className:`w-full min-w-0 bg-transparent outline-none font-mono text-[11px] placeholder:text-ink/35 ${l?"text-error":"text-ink/90"}`})]})]})})}var Z={"desktop-16-9":"w-full max-w-[1280px] aspect-video max-h-full border border-ink/20 rounded-lg shadow-md overflow-hidden my-auto",laptop:"w-[1024px] max-w-full h-[768px] max-h-full border border-ink/20 rounded-lg shadow-md overflow-hidden my-auto",tablet:"w-[768px] max-w-full h-[1024px] max-h-full border border-ink/20 rounded-lg shadow-md overflow-hidden my-auto",mobile:"w-[375px] max-w-full h-[667px] max-h-full border border-ink/20 rounded-xl shadow-md overflow-hidden my-auto","mobile-lg":"w-[414px] max-w-full h-[896px] max-h-full border border-ink/20 rounded-xl shadow-md overflow-hidden my-auto",responsive:"w-full h-full border-0"};var ce="clipboard-read; clipboard-write; fullscreen";function X({url:t,frameKey:s,loading:r,viewportMode:l,zoomLevel:p,onLoad:f,active:h=!0,overlay:c,onFrame:x}){if(!h)return null;if(!t)return e("div",{className:"flex-1 flex flex-col items-center justify-center p-6 text-center select-none",children:[e("div",{className:"w-12 h-12 rounded-xl bg-ink/5 border border-ink/10 flex items-center justify-center text-ink/40 mb-3",children:e(Qe,{size:22})}),e("h3",{className:"text-sm font-semibold text-ink mb-1",children:"Browser Anda"}),e("p",{className:"text-xs text-ink/60 max-w-sm",children:"Type an address above and press Enter. The page loads inside this panel."}),e("p",{className:"text-[11px] text-ink/45 max-w-sm mt-2",children:"Sebagian situs (Google, GitHub) menolak ditampilkan dalam iframe — pakai tombol buka di tab baru."})]});return e("div",{className:"flex-1 min-h-0 relative flex items-center justify-center p-2 overflow-auto bg-canvas/60",children:[r?e("div",{className:"absolute inset-0 z-10 flex items-center justify-center pointer-events-none",children:e("div",{className:"flex items-center space-x-2 px-3 py-1.5 rounded-md bg-paper border border-ink/15",children:[e(m,{size:13,className:"animate-spin text-ink/50"}),e("span",{className:"text-[11px] font-mono text-ink/60",children:"Memuat…"})]})}):null,e("div",{className:`relative flex flex-col bg-white ${Z[l]} transition-all duration-200`,style:{zoom:p!==100?`${p}%`:void 0,transformOrigin:"top center"},children:[e("iframe",{ref:(A)=>x?.(A),src:t,title:"Browser pengguna",onLoad:f,referrerPolicy:"no-referrer",allow:ce,className:"w-full h-full bg-white border-0",style:c?{pointerEvents:"none"}:void 0},s),c]})]})}var W="w-full min-w-0 bg-canvas border border-ink/15 rounded px-2 py-1 text-[11px] font-mono text-ink placeholder:text-ink/35 focus:outline-none focus:border-ink/40";function ue(t){if(!t||t.ok)return null;if(t.reason==="cross-origin")return"This page is cross-origin, so its elements cannot be read. Name the part and add a note instead.";if(t.reason==="no-frame")return"The page has not loaded, so its elements cannot be read yet.";return"There is no element at this point (empty space). Name the part instead."}function Y({shape:t,index:s,readability:r,onLabel:l,onNote:p}){let f=ue(r),h=t.element;return e("div",{className:"flex items-start gap-1.5 min-w-0",children:[e("span",{className:"text-[11px] font-mono text-ink/45 pt-1 flex-shrink-0",children:[Yu[t.tool]," #",s]}),e("div",{className:"flex-1 min-w-0 space-y-1",children:[e("div",{className:"flex items-center gap-1 flex-wrap",children:[e("span",{className:"text-[10px] uppercase font-mono text-ink/40",children:"bagian"}),NA.map((c)=>{let x=t.label===c;return e("button",{type:"button",onClick:()=>l(x?"":c),"aria-pressed":x,className:`px-1.5 py-0.5 rounded-full border text-[10px] font-mono transition-colors cursor-pointer ${x?"bg-ink text-canvas border-ink":"bg-canvas text-ink/65 border-ink/15 hover:border-ink/40"}`,children:c},c)}),e("input",{value:t.label,onInput:(c)=>l(c.currentTarget.value),placeholder:"or type your own…","aria-label":"Name of the marked part",spellcheck:!1,className:`${W} flex-1 min-w-[110px]`})]}),e("textarea",{value:t.note,onInput:(c)=>p(c.currentTarget.value),placeholder:"What is wrong with this part? (e.g. the Pay button looks disabled)",rows:2,"aria-label":"Annotation note",className:`${W} resize-y`}),h?e("p",{className:"text-[10px] font-mono text-ink/45 truncate",title:h.path,children:["elemen: ",h.path,h.state?` · ${h.state}`:""]}):null,f?e("p",{className:"text-[10px] text-ink/40",children:f}):null]})]})}var me=["box","pin","arrow"],pe="px-2 py-1 rounded text-[11px] font-mono border transition-colors cursor-pointer",U="flex items-center gap-1 px-2 py-1 rounded text-[11px] border border-ink/15 hover:border-ink/40 text-ink/80 hover:text-ink transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed";function j({tool:t,shapes:s,selectedId:r,readability:l,onTool:p,onLabel:f,onNote:h,onRemove:c,onReset:x,onCancel:A,onSend:P}){let T=s.find((E)=>E.id===r)??null,v=s.length>0;return e("div",{className:"flex-shrink-0 border-b border-ink/10 bg-paper px-2.5 py-1.5 space-y-1.5 select-none",children:[e("div",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-[10px] uppercase font-mono text-ink/50 mr-1",children:"Anotasi"}),me.map((E)=>e("button",{type:"button",onClick:()=>p(E),"aria-pressed":t===E,className:`${pe} ${t===E?"bg-ink text-canvas border-ink":"bg-canvas text-ink/70 border-ink/15 hover:border-ink/40"}`,children:Yu[E]},E)),e("span",{className:"text-[11px] font-mono text-ink/45 ml-1",children:s.length>0?`${s.length} mark${s.length===1?"":"s"}`:"drag on the page to mark a part"}),e("div",{className:"flex-1"}),e("button",{type:"button",onClick:x,disabled:!v,className:U,title:"Clear all marks",children:[e(L,{size:12})," Bersihkan"]}),e("button",{type:"button",onClick:P,disabled:!v,className:U,title:"Kirim anotasi ke draft chat",children:[e(Pn,{size:12})," Kirim ke chat"]}),e("button",{type:"button",onClick:A,className:U,title:"Tutup mode anotasi",children:e(b,{size:12})})]}),T?e("div",{className:"flex items-start gap-1.5",children:[e("div",{className:"flex-1 min-w-0",children:e(Y,{shape:T,index:s.indexOf(T)+1,readability:l,onLabel:(E)=>f(T.id,E),onNote:(E)=>h(T.id,E)})}),e("button",{type:"button",onClick:()=>c(T.id),className:U,title:"Remove this mark",children:e(L,{size:12})})]}):e("p",{className:"text-[11px] text-ink/45",children:"This page cannot be screenshotted, so what gets sent is the area, the part name and your note."})]})}var q=0;function J(){return q+=1,`annot-${Date.now().toString(36)}-${q}`}function Q(t){let[s,r]=n(!1),[l,p]=n("box"),[f,h]=n([]),[c,x]=n(null);o(()=>{h([]),x(null)},[t]);let A=a(()=>{r((N)=>!N),x(null)},[]),P=a(()=>{x(null),r(!1)},[]),T=a((N)=>{h((B)=>[...B,N]),x(N.id)},[]),v=a((N,B)=>{h((u)=>u.map((g)=>g.id===N?{...g,note:B}:g))},[]),E=a((N,B)=>{h((u)=>u.map((g)=>g.id===N?{...g,label:B}:g))},[]),I=a((N)=>{h((B)=>B.filter((u)=>u.id!==N)),x((B)=>B===N?null:B)},[]),C=a(()=>{h([]),x(null)},[]);return{active:s,tool:l,shapes:f,selectedId:c,setTool:p,toggle:A,close:P,add:T,setNote:v,setLabel:E,select:x,remove:I,reset:C}}var fe=4,_="var(--theme-error)";function ee({shapes:t,tool:s,selectedId:r,onMeasure:l,onAdd:p,onSelect:f}){let h=i(null),c=i(null),[x,A]=n(null),[P,T]=n({width:0,height:0});o(()=>{let u=h.current;if(!u)return;let g=()=>{let w=u.getBoundingClientRect();if(w.width<=0||w.height<=0)return;T((M)=>M.width===w.width&&M.height===w.height?M:{width:w.width,height:w.height}),l({width:w.width,height:w.height})};if(g(),typeof ResizeObserver!=="function")return;let k=new ResizeObserver(g);return k.observe(u),()=>k.disconnect()},[l]);let v=(u)=>{let g=h.current;if(!g)return null;let k=g.getBoundingClientRect(),w={x:u.clientX-k.left,y:u.clientY-k.top};return{normalized:DA(k,w),px:w.x,py:w.y}},E=(u)=>{if(u.button!==0)return;let g=v(u);if(!g)return;u.preventDefault(),f(null),u.currentTarget.setPointerCapture?.(u.pointerId);let k={id:J(),tool:s,start:g.normalized,end:g.normalized,label:"",note:""};c.current=k,A(k)},I=(u)=>{let g=c.current;if(!g)return;let k=v(u);if(!k)return;let w={...g,end:k.normalized};c.current=w,A(w)},C=(u)=>{let g=c.current;if(!g)return;let k=v(u),w=k?{...g,end:k.normalized}:g;if(c.current=null,A(null),u.currentTarget.releasePointerCapture?.(u.pointerId),w.tool!=="pin"){let M=h.current?.getBoundingClientRect();if((M?Math.hypot((w.end.x-w.start.x)*M.width,(w.end.y-w.start.y)*M.height):0)<fe)return}p(w)},N=()=>{c.current=null,A(null)},B=x?[...t,x]:t;return e("div",{ref:h,className:"absolute inset-0 cursor-crosshair touch-none",onPointerDown:E,onPointerMove:I,onPointerUp:C,onPointerCancel:N,children:e("svg",{className:"absolute inset-0 w-full h-full",viewBox:`0 0 ${Math.max(1,P.width)} ${Math.max(1,P.height)}`,preserveAspectRatio:"none","aria-label":"Page annotation area",children:B.map((u,g)=>e(he,{shape:u,index:g+1,box:P,selected:u.id===r,onSelect:()=>f(u.id)},u.id))})})}function he({shape:t,index:s,box:r,selected:l,onSelect:p}){let f={x:t.start.x*r.width,y:t.start.y*r.height},h={x:t.end.x*r.width,y:t.end.y*r.height},c=Xp(t),x=l?3:2,A=String(s);return e("g",{onPointerDown:(T)=>{T.stopPropagation(),T.preventDefault(),p()},className:"cursor-pointer",children:[t.tool==="box"&&e("rect",{x:c.x*r.width,y:c.y*r.height,width:Math.max(1,c.width*r.width),height:Math.max(1,c.height*r.height),fill:_,fillOpacity:l?0.16:0.1,stroke:_,strokeWidth:x,vectorEffect:"non-scaling-stroke",rx:3}),t.tool==="arrow"&&e(d,{children:[e("line",{x1:f.x,y1:f.y,x2:h.x,y2:h.y,stroke:_,strokeWidth:x,vectorEffect:"non-scaling-stroke"}),e("circle",{cx:h.x,cy:h.y,r:4,fill:_})]}),t.tool==="pin"&&e("circle",{cx:f.x,cy:f.y,r:7,fill:_,fillOpacity:l?0.5:0.3,stroke:_,strokeWidth:x}),e("circle",{cx:f.x,cy:f.y,r:9,fill:_}),e("text",{x:f.x,y:f.y,textAnchor:"middle",dominantBaseline:"central",fontSize:11,fontWeight:700,fill:"var(--theme-paper)",children:A})]})}function te(t){let s=t.trim();if(!s)return s;let r=/^[a-z][a-z0-9+.-]*:/i.test(s)?s:`https://${s}`,l=new URL(r);if(l.protocol!=="http:"&&l.protocol!=="https:")throw Error("Only http and https URLs are allowed");return l.toString()}var ge="userBrowser.history",be="userBrowser.historyIndex",xe="userBrowser.inputUrl";function ne(){let[t,s]=S(ge,[]),[r,l]=S(be,-1),[p,f]=S(xe,""),[h,c]=n(0),[x,A]=n(!1),[P,T]=n(void 0),v=r>=0&&r<t.length?t[r]??"":"",E=a((u)=>{let g=u.trim();if(!g)return;let k;try{k=te(g)}catch(O){T(O instanceof Error?O.message:"Alamat tidak valid");return}T(void 0),A(!0);let M=[...t.slice(0,r+1),k];s(M),l(M.length-1),f(k),c((O)=>O+1)},[t,r,s,l,f]),I=a(()=>{if(r<=0)return;A(!0),l(r-1)},[r,l]),C=a(()=>{if(r>=t.length-1)return;A(!0),l(r+1)},[t.length,r,l]),N=a(()=>{if(!v)return;A(!0),c((u)=>u+1)},[v]),B=a(()=>{A(!1)},[]);return{url:v,input:p,setInput:f,frameKey:h,loading:x,error:P,canGoBack:r>0,canGoForward:r>=0&&r<t.length-1,submit:E,goBack:I,goForward:C,reload:N,markLoaded:B}}function we(t){if(!t)return"no-frame";try{return t.contentDocument?"readable":"cross-origin"}catch{return"cross-origin"}}function F(t){let s=t.replace(/\s+/g," ").trim();return s.length>60?`${s.slice(0,59)}…`:s}function ve(t){let s=t.tagName.toLowerCase();if(t.id)return`${s}#${t.id}`;for(let l of["data-testid","data-test","aria-label"]){let p=t.getAttribute(l);if(p)return`${s}[${l}="${F(p)}"]`}let r=t.getAttribute("role");if(r)return`${s}[role="${r}"]`;return s}function ye(t){let s=[],r=t;while(r&&s.length<4){if(r.tagName.toLowerCase()==="html")break;s.unshift(ve(r)),r=r.parentElement}return s.join(" > ")}function ke(t){let s=[];if(t.disabled)s.push("nonaktif");if(t instanceof HTMLSelectElement||t.tagName.toLowerCase()==="select"){let r=t,p=r.selectedOptions?.[0]?.textContent?.trim()||r.value;if(p)s.push(`nilai "${F(p)}"`);let f=r.options?.length??0;if(f>0)s.push(`${f} opsi`)}else if(t.tagName.toLowerCase()==="input"){let r=t;if(r.type)s.push(`tipe ${r.type}`);if(r.type!=="password"&&r.placeholder)s.push(`placeholder "${F(r.placeholder)}"`)}return s.length>0?s.join(", "):void 0}function Ae(t){let s={path:ye(t),tag:t.tagName.toLowerCase()},r=t.getAttribute("role");if(r)s.role=r;let l=F(t.innerText??t.textContent??"");if(l)s.text=l;let p=ke(t);if(p)s.state=p;return s}function oe(t,s){let r=we(t);if(r!=="readable")return{ok:!1,reason:r};let{contentWindow:l,contentDocument:p}=t;if(!l||!p)return{ok:!1,reason:"cross-origin"};try{let f=Math.min(Math.max(s.x,0),1)*l.innerWidth,h=Math.min(Math.max(s.y,0),1)*l.innerHeight,c=p.elementFromPoint(f,h);if(!c||c===p.documentElement||c===p.body)return{ok:!1,reason:"no-element"};return{ok:!0,element:Ae(c)}}catch{return{ok:!1,reason:"cross-origin"}}}function mt({className:t="",active:s=!0}){let[r,l]=S("userBrowser.viewportMode","responsive"),[p,f]=S("userBrowser.zoomLevel",100),[h,c]=n(null),[x,A]=n(null),[P,T]=n(null),{url:v,input:E,setInput:I,frameKey:C,loading:N,error:B,canGoBack:u,canGoForward:g,submit:k,goBack:w,goForward:M,reload:O,markLoaded:H}=ne(),y=Q(C),re=a(()=>{if(!v)return;window.open(v,"_blank","noopener,noreferrer")},[v]),ae=a(()=>{if(!v)return;ic({url:v})},[v]),ie=a((R)=>{c((z)=>z&&z.width===R.width&&z.height===R.height?z:R)},[]),se=a((R)=>{let z=oe(x,R.start);T(z),y.add(z.ok?{...R,element:z.element}:R)},[y,x]),le=a(()=>{if(!v||y.shapes.length===0)return;let R=p/100;ic({url:v,annotations:y.shapes,panel:{width:(h?.width??0)/R,height:(h?.height??0)/R,viewportMode:r,zoom:p}}),y.close()},[v,y,h,r,p]),G=y.active&&Boolean(v);return e("div",{className:`flex flex-col h-full w-full bg-paper text-ink overflow-hidden ${t}`,children:[e(K,{url:v,input:E,loading:N,error:B,canGoBack:u,canGoForward:g,viewportMode:r,zoomLevel:p,onInputChange:I,onSubmit:k,onBack:w,onForward:M,onReload:O,onOpenExternal:re,onIncludeInChat:ae,onChangeViewport:l,onZoomIn:()=>f((R)=>Math.min(200,R+10)),onZoomOut:()=>f((R)=>Math.max(50,R-10)),onResetZoom:()=>f(100),onSetZoom:f,annotate:{active:G,count:y.shapes.length,onToggle:y.toggle}}),G&&e(j,{tool:y.tool,shapes:y.shapes,selectedId:y.selectedId,readability:P,onTool:y.setTool,onLabel:y.setLabel,onNote:y.setNote,onRemove:y.remove,onReset:y.reset,onCancel:y.close,onSend:le}),e(X,{url:v,frameKey:C,loading:N,viewportMode:r,zoomLevel:p,onLoad:H,onFrame:A,active:s,overlay:G?e(ee,{shapes:y.shapes,tool:y.tool,selectedId:y.selectedId,onMeasure:ie,onAdd:se,onSelect:y.select}):null})]})}export{mt as UserBrowserPanel};
@@ -1 +1 @@
1
- import{d,n,o,W,i,u,a,Zt,e,S,cr,ur,Ie,$i,f,Gi,ji,qi,O,Wi,b,ht,pe,li,Ws,lt,ct,bt,Vu,rc}from"./index-rt6ac0kk.js";import{br}from"./index-mphhvgm9.js";var fe=2000,D=new Map;function me(s){if(s.length===0)return"";let r="";for(let t of s)r+=`${t.start}-${t.end},`;return r}function Z(s,r,t){let h=li(r),c=`${r}\x00${me(t)}\x00${s}`;if(h){let m=D.get(c);if(m!==void 0)return D.delete(c),D.set(c,m),m}let l=Ws(s,r,{marks:t});if(!h)return l;if(D.set(c,l),D.size>fe){let m=D.keys().next();if(!m.done)D.delete(m.value)}return l}function ee(s,r,t){let h=[],c=0;for(let l of r){if(l.start<c||l.end<=l.start||l.end>s.length)continue;if(l.start>c)h.push({text:s.slice(c,l.start),kind:"plain"});if(h.push({text:s.slice(l.start,l.end),kind:"removed"}),t)h.push({text:t,kind:"inserted"});c=l.end}if(c<s.length)h.push({text:s.slice(c),kind:"plain"});return h}function ge({file:s,result:r,replacement:t,showReplacePreview:h,onOpen:c}){let l=r.ranges??[],m=h&&t.length>0;return e("button",{type:"button",onClick:()=>c(r),className:"flex w-full items-start gap-2 rounded px-1 py-0.5 text-left hover:bg-ink/5 cursor-pointer",title:`Open ${s}:${r.line}`,children:[e("span",{className:"w-6 flex-shrink-0 text-right font-mono text-ink/40",children:r.line}),m?e("span",{className:"min-w-0 truncate font-mono text-ink",children:ee(r.content,l,t).map((R,p)=>R.kind==="plain"?e("span",{children:R.text},p):R.kind==="removed"?e("del",{className:"search-replace-old",children:R.text},p):e("ins",{className:"search-replace-new",children:R.text},p))}):e("span",{className:"min-w-0 truncate font-mono text-ink",dangerouslySetInnerHTML:{__html:Z(r.content,bt(s),l)}})]})}var te=Zt(ge);var Y={header:4,hit:4,group:16},re={headerBox:16,hitBox:20},ne=5000;function se(s){let r=[],t=null;for(let h of s){if(!t||t.file!==h.file)t={file:h.file,results:[]},r.push(t);t.results.push(h)}return r}function oe(s){let r=[];for(let t of s){r.push({kind:"group",file:t.file,count:t.results.length});for(let h=0;h<t.results.length;h++)r.push({kind:"hit",file:t.file,result:t.results[h],last:h===t.results.length-1})}return r}function xe(s,r){if(s.kind==="group")return r.headerBox+Y.header;return r.hitBox+(s.last?Y.group:Y.hit)}function ie(s,r){let t=Array(s.length),h=Array(s.length),c=0;for(let l=0;l<s.length;l++){let m=xe(s[l],r);t[l]=c,h[l]=m,c+=m}return{offsets:t,heights:h,total:c}}function ae(s,r,t,h,c=240){if(s.length===0)return{start:0,end:0};let l=Math.max(0,t),m=l-c,R=l+h+c,p=0,v=s.length-1;while(p<v){let x=p+v>>1;if(s[x]+r[x]>m)v=x;else p=x+1}let w=p;p=w,v=s.length;while(p<v){let x=p+v>>1;if(s[x]>=R)v=x;else p=x+1}return{start:w,end:p}}var be=8,Se=8;function le({groups:s,replacement:r,showReplacePreview:t,onOpen:h,onReplaceFile:c,replaceBusy:l}){let m=i(null),R=i(null),p=u(()=>oe(s),[s]),[v,w]=n(re),x=u(()=>ie(p,v),[p,v]),[M,E]=n(()=>({start:0,end:Math.min(p.length,60)})),F=a((g)=>{m.current=g},[]),k=a(()=>{let g=m.current;if(!g)return;let N=ae(x.offsets,x.heights,g.scrollTop,g.clientHeight);E((I)=>I.start===N.start&&I.end===N.end?I:N)},[x]),y=a(()=>{k()},[k]);W(()=>{let g=R.current;if(!g)return;let N=g.querySelector("[data-search-header] > div")?.offsetHeight??0,I=g.querySelector("[data-search-hit] > button")?.offsetHeight??0;if(N>0&&N!==v.headerBox)w((C)=>({...C,headerBox:N}));if(I>0&&I!==v.hitBox)w((C)=>({...C,hitBox:I}))},[M,v,p]),W(()=>{k()},[k]),W(()=>{let g=m.current;if(!g||typeof ResizeObserver>"u")return;let N=new ResizeObserver(()=>k());return N.observe(g),()=>N.disconnect()},[k]);let P=p.length===0?0:Math.min(M.start,p.length-1),L=Math.min(M.end,p.length),B=p.slice(P,L),A=L<p.length?x.total-x.offsets[L]:0;return e("div",{ref:F,onScroll:y,className:"flex-1 scrollbar-overlay-container px-3 text-xs",style:{overflowAnchor:"none"},children:[e("div",{style:{height:be+(x.offsets[P]??0)},"aria-hidden":"true"}),e("div",{ref:R,children:B.map((g,N)=>{let I=P+N,C=x.heights[I];if(g.kind==="group")return e("div",{"data-search-header":"",style:{height:C},children:e("div",{className:"font-semibold text-ink/80 flex items-center justify-between group",children:[e("div",{className:"flex items-center min-w-0",children:[e(lt,{name:g.file,size:12,className:"mr-1.5 flex-shrink-0"}),e("span",{className:"truncate",children:g.file}),e("span",{className:"ml-2 bg-ink/10 text-[10px] px-1.5 py-0.5 rounded-full flex-shrink-0",children:g.count})]}),e("button",{onClick:()=>c(g.file),disabled:l,className:"touch-visible opacity-0 group-hover:opacity-100 p-1 text-ink/40 hover:text-ink rounded hover:bg-ink/5 disabled:opacity-50 flex-shrink-0",title:"Replace in this file",children:e(qi,{size:12})})]})},`group:${g.file}`);return e("div",{"data-search-hit":"",style:{height:C},children:e(te,{file:g.file,result:g.result,replacement:r,showReplacePreview:t,onOpen:h})},`hit:${g.file}:${g.result.line}:${I}`)})}),e("div",{style:{height:Se+A},"aria-hidden":"true"})]})}function ce({className:s,query:r,setQuery:t,replaceQuery:h,setReplaceQuery:c,matchCase:l,setMatchCase:m,wholeWord:R,setWholeWord:p,useRegex:v,setUseRegex:w,includeFiles:x,setIncludeFiles:M,showIncludeField:E,setShowIncludeField:F,showMenu:k,setShowMenu:y,menuRef:P,rootPath:L,activeRepo:B,setActiveRepo:A,repos:g,reposScanning:N,rescanRepos:I,results:C,isSearching:G,truncated:H,error:z,onOpenFile:J,handleReplace:q,replaceBusy:Q}){let X=u(()=>se(C),[C]),_=i(null),K=i(null),U=a(()=>{t(""),_.current?.focus()},[t]),j=a(()=>{c(""),K.current?.focus()},[c]),V=u(()=>({matchCase:l,wholeWord:R,isRegex:v,inSelection:!1}),[l,R,v]),he=a((T)=>{Vu({path:T.file,line:Number(T.line),query:r,options:V}),J?.({path:T.file,name:T.file.split("/").pop()||T.file,root:L,repo:B})},[r,V,L,B,J]),de=a((T)=>q(T),[q]);return e("div",{className:`flex flex-col h-full bg-paper ${s}`,children:[e(ht,{left:e(d,{children:[e("h2",{className:"text-xs font-semibold text-ink uppercase tracking-wider",children:"Search"}),e(br,{rootPath:L,activeRepo:B,onSelectRepo:A,repos:g,scanning:N,onRefreshRepos:I})]}),right:e("div",{className:"relative",ref:P,children:[e("button",{onClick:()=>y(!k),className:`p-1 rounded hover:bg-ink/5 transition-colors ${k||E?"text-ink":"text-ink/40"}`,title:"Search Options",children:e(Ie,{size:14})}),k&&e("div",{className:"glass-popover absolute right-0 top-full mt-1 w-48 bg-paper border border-ink/10 rounded shadow-lg z-10 py-1",children:e("button",{onClick:()=>{if(F(!E),E)M("");y(!1)},className:"w-full px-3 py-1.5 text-left text-xs text-ink hover:bg-ink/5 flex items-center justify-between",children:[e("span",{children:"Files to include"}),E&&e(f,{size:12,className:"text-ink/60"})]})})]})}),e("div",{className:"p-3 flex flex-col gap-2.5 border-b border-ink/10",children:[e("div",{className:"relative",children:e("div",{className:"flex items-center border border-ink/20 rounded bg-paper focus-within:border-ink/40 focus-within:ring-1 focus-within:ring-ink/10 transition-all",children:[e(O,{size:14,className:"ml-2 text-ink/40 flex-shrink-0"}),e("input",{ref:_,type:"text",placeholder:"Search",value:r,onChange:(T)=>t(T.currentTarget.value),className:"w-full bg-transparent border-none text-xs px-2 py-1.5 focus:outline-none text-ink placeholder-ink/35 min-w-0"}),r&&e("button",{type:"button",onClick:U,title:"Clear search","aria-label":"Clear search",className:"p-1 mr-0.5 rounded text-ink/40 hover:text-ink hover:bg-ink/5 flex-shrink-0",children:e(b,{size:12})}),e("div",{className:"flex items-center space-x-0.5 pr-1 text-ink/40 flex-shrink-0",children:[e("button",{onClick:()=>m(!l),className:`p-1 rounded hover:text-ink ${l?"bg-ink/10 text-ink":"hover:bg-ink/5"}`,title:"Match Case",children:e($i,{size:14})}),e("button",{onClick:()=>p(!R),className:`p-1 rounded hover:text-ink ${R?"bg-ink/10 text-ink":"hover:bg-ink/5"}`,title:"Match Whole Word",children:e(Wi,{size:14})}),e("button",{onClick:()=>w(!v),className:`p-1 rounded hover:text-ink ${v?"bg-ink/10 text-ink":"hover:bg-ink/5"}`,title:"Use Regular Expression",children:e(Gi,{size:14})})]})]})}),e("div",{className:"relative flex items-center space-x-1",children:[e("div",{className:"flex flex-1 min-w-0 items-center border border-ink/20 rounded bg-paper focus-within:border-ink/40 focus-within:ring-1 focus-within:ring-ink/10 transition-all",children:[e("input",{ref:K,type:"text",placeholder:"Replace",value:h,onChange:(T)=>c(T.currentTarget.value),className:"flex-1 min-w-0 bg-transparent border-none text-xs px-2 py-1.5 focus:outline-none text-ink placeholder-ink/35"}),h&&e("button",{type:"button",onClick:j,title:"Clear replace","aria-label":"Clear replace",className:"p-1 mr-0.5 rounded text-ink/40 hover:text-ink hover:bg-ink/5 flex-shrink-0",children:e(b,{size:12})})]}),e("button",{onClick:()=>q(),disabled:C.length===0||Q,className:"p-1.5 rounded border border-ink/20 text-ink/60 hover:text-ink hover:bg-ink/5 disabled:opacity-50 disabled:cursor-not-allowed bg-paper",title:"Replace All",children:e(ji,{size:14})})]}),E&&e("div",{className:"relative",children:e("input",{type:"text",value:x,onChange:(T)=>M(T.currentTarget.value),placeholder:"Files to include (e.g. *.js, src/*)",className:"w-full bg-paper border border-ink/20 rounded text-xs px-2 py-1.5 focus:outline-none focus:border-ink/40 focus:ring-1 focus:ring-ink/10 transition-all text-ink placeholder-ink/40"})})]}),z&&C.length===0?e("div",{className:"flex-1 px-3 py-3",role:"alert",children:e("div",{className:"rounded border border-error/30 bg-error/5 px-2.5 py-2",children:[e("div",{className:"text-[11px] font-semibold text-error",children:"Search failed"}),e("div",{className:"mt-1 whitespace-pre-wrap break-words font-mono text-[10.5px] text-ink/70",children:z}),v&&e("div",{className:"mt-1 text-[10.5px] text-ink/50",children:["Regex is on — escape metacharacters such as ",e("code",{className:"font-mono",children:"( ) [ ] * ? +"})," or turn it off to search literally."]})]})}):G&&C.length===0?e("div",{className:"flex-1 text-ink/40 italic text-center py-4",children:"Searching..."}):r.trim().length<=2?e("div",{className:"flex-1 text-ink/40 italic text-center py-4",children:"Type at least 3 characters to search."}):C.length===0?e("div",{className:"flex-1 text-ink/40 italic text-center py-4",children:"No results found."}):e(d,{children:[z&&e("div",{className:"px-3 pt-2 text-[10.5px] text-error",role:"alert",children:["Search failed: ",e("span",{className:"font-mono",children:z})]}),G&&e("div",{className:"px-3 pt-2 text-ink/40 italic",children:"Searching…"}),H&&e("div",{className:"px-3 pt-2 text-ink/50 italic",children:["Showing the first ",ne," matches — refine the query to see the rest."]}),e(le,{groups:X,replacement:h,showReplacePreview:h.length>0,onOpen:he,onReplaceFile:de,replaceBusy:Q})]})]})}function ue(s){let[r,t]=n({scope:s,results:[],truncated:!1,error:null}),[h,c]=n(!1),l=i(null),m=i(!0),R=i(s);R.current=s,o(()=>(m.current=!0,()=>{m.current=!1,l.current?.abort(),l.current=null}),[]);let p=a(async(v)=>{l.current?.abort();let w=new AbortController;l.current=w;let x=R.current;t({scope:x,results:[],truncated:!1,error:null}),c(!0);try{let M=await fetch("/api/fs/search",{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:new URLSearchParams(v),signal:w.signal});await rc(M,(E,F)=>{if(R.current!==x)return;if(E==="done"){let k=!1;try{k=JSON.parse(F)?.truncated===!0}catch{}t((y)=>y.scope===x?{...y,truncated:k}:y);return}if(E==="error"){let k="Search failed";try{k=JSON.parse(F)?.error||k}catch{}t((y)=>y.scope===x?{...y,error:k}:y);return}if(E!=="matches")return;try{let k=JSON.parse(F);if(Array.isArray(k))t((y)=>y.scope===x?{...y,results:[...y.results,...k]}:y)}catch{}},w.signal)}catch{}finally{if(m.current&&l.current===w)l.current=null,c(!1)}},[]);return{results:r.scope===s?r.results:[],isSearching:h&&r.scope===s,truncated:r.scope===s&&r.truncated,error:r.scope===s?r.error:null,start:p}}function st({className:s="",enabled:r=!0,rootPath:t,onOpenFile:h}){let[c,l]=S("search.query",""),[m,R]=S("search.replaceQuery",""),[p,v]=S("search.matchCase",!1),[w,x]=S("search.wholeWord",!1),[M,E]=S("search.useRegex",!1),[F,k]=S("search.includeFiles",""),[y,P]=n(!1),[L,B]=S("search.showIncludeField",!1),{activeRepo:A,setActiveRepo:g}=cr(t),{repos:N,scanning:I,rescan:C}=ur(t,r),G=i(null),H=ct(),{results:z,isSearching:J,truncated:q,error:Q,start:X}=ue(`${t??""}\x00${A}`);pe(G,()=>P(!1));let _=a(()=>{if(!r)return;if(c.trim().length>2)return X({q:c,matchCase:String(p),wholeWord:String(w),useRegex:String(M),includeFiles:L?F:"",...t?{root:t}:{},...A!=="."?{repo:A}:{}})},[r,c,p,w,M,L,F,t,A,X]);o(()=>{let U=setTimeout(()=>{_()},300);return()=>clearTimeout(U)},[_]);let K=a((U)=>{if(!c)return;let j=U?[U]:Array.from(new Set(z.map((V)=>V.file)));if(j.length===0)return;H.submit({q:c,replaceWith:m,matchCase:String(p),wholeWord:String(w),useRegex:String(M),files:JSON.stringify(j),...t?{root:t}:{},...A!=="."?{repo:A}:{}},{method:"POST",action:"/api/fs/replace"})},[c,m,p,w,M,z,t,A,H]);if(o(()=>{if(H.state==="idle"&&H.data?.success)_()},[H.state,H.data,_]),!r)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${s}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});return e(ce,{className:s,query:c,setQuery:l,replaceQuery:m,setReplaceQuery:R,matchCase:p,setMatchCase:v,wholeWord:w,setWholeWord:x,useRegex:M,setUseRegex:E,includeFiles:F,setIncludeFiles:k,showIncludeField:L,setShowIncludeField:B,showMenu:y,setShowMenu:P,menuRef:G,rootPath:t,activeRepo:A,setActiveRepo:g,repos:N,reposScanning:I,rescanRepos:C,results:z,isSearching:J,truncated:q,error:Q,onOpenFile:h,handleReplace:K,replaceBusy:H.state!=="idle"})}export{st as SearchPanel};
1
+ import{d,n,o,W,i,u,a,Zt,e,S,cr,ur,Ie,$i,f,Gi,ji,qi,O,Wi,b,ht,pe,li,Ws,lt,ct,bt,Vu,rc}from"./index-pzvr1699.js";import{br}from"./index-7a2efrbj.js";var fe=2000,D=new Map;function me(s){if(s.length===0)return"";let r="";for(let t of s)r+=`${t.start}-${t.end},`;return r}function Z(s,r,t){let h=li(r),c=`${r}\x00${me(t)}\x00${s}`;if(h){let m=D.get(c);if(m!==void 0)return D.delete(c),D.set(c,m),m}let l=Ws(s,r,{marks:t});if(!h)return l;if(D.set(c,l),D.size>fe){let m=D.keys().next();if(!m.done)D.delete(m.value)}return l}function ee(s,r,t){let h=[],c=0;for(let l of r){if(l.start<c||l.end<=l.start||l.end>s.length)continue;if(l.start>c)h.push({text:s.slice(c,l.start),kind:"plain"});if(h.push({text:s.slice(l.start,l.end),kind:"removed"}),t)h.push({text:t,kind:"inserted"});c=l.end}if(c<s.length)h.push({text:s.slice(c),kind:"plain"});return h}function ge({file:s,result:r,replacement:t,showReplacePreview:h,onOpen:c}){let l=r.ranges??[],m=h&&t.length>0;return e("button",{type:"button",onClick:()=>c(r),className:"flex w-full items-start gap-2 rounded px-1 py-0.5 text-left hover:bg-ink/5 cursor-pointer",title:`Open ${s}:${r.line}`,children:[e("span",{className:"w-6 flex-shrink-0 text-right font-mono text-ink/40",children:r.line}),m?e("span",{className:"min-w-0 truncate font-mono text-ink",children:ee(r.content,l,t).map((R,p)=>R.kind==="plain"?e("span",{children:R.text},p):R.kind==="removed"?e("del",{className:"search-replace-old",children:R.text},p):e("ins",{className:"search-replace-new",children:R.text},p))}):e("span",{className:"min-w-0 truncate font-mono text-ink",dangerouslySetInnerHTML:{__html:Z(r.content,bt(s),l)}})]})}var te=Zt(ge);var Y={header:4,hit:4,group:16},re={headerBox:16,hitBox:20},ne=5000;function se(s){let r=[],t=null;for(let h of s){if(!t||t.file!==h.file)t={file:h.file,results:[]},r.push(t);t.results.push(h)}return r}function oe(s){let r=[];for(let t of s){r.push({kind:"group",file:t.file,count:t.results.length});for(let h=0;h<t.results.length;h++)r.push({kind:"hit",file:t.file,result:t.results[h],last:h===t.results.length-1})}return r}function xe(s,r){if(s.kind==="group")return r.headerBox+Y.header;return r.hitBox+(s.last?Y.group:Y.hit)}function ie(s,r){let t=Array(s.length),h=Array(s.length),c=0;for(let l=0;l<s.length;l++){let m=xe(s[l],r);t[l]=c,h[l]=m,c+=m}return{offsets:t,heights:h,total:c}}function ae(s,r,t,h,c=240){if(s.length===0)return{start:0,end:0};let l=Math.max(0,t),m=l-c,R=l+h+c,p=0,v=s.length-1;while(p<v){let x=p+v>>1;if(s[x]+r[x]>m)v=x;else p=x+1}let w=p;p=w,v=s.length;while(p<v){let x=p+v>>1;if(s[x]>=R)v=x;else p=x+1}return{start:w,end:p}}var be=8,Se=8;function le({groups:s,replacement:r,showReplacePreview:t,onOpen:h,onReplaceFile:c,replaceBusy:l}){let m=i(null),R=i(null),p=u(()=>oe(s),[s]),[v,w]=n(re),x=u(()=>ie(p,v),[p,v]),[M,E]=n(()=>({start:0,end:Math.min(p.length,60)})),F=a((g)=>{m.current=g},[]),k=a(()=>{let g=m.current;if(!g)return;let N=ae(x.offsets,x.heights,g.scrollTop,g.clientHeight);E((I)=>I.start===N.start&&I.end===N.end?I:N)},[x]),y=a(()=>{k()},[k]);W(()=>{let g=R.current;if(!g)return;let N=g.querySelector("[data-search-header] > div")?.offsetHeight??0,I=g.querySelector("[data-search-hit] > button")?.offsetHeight??0;if(N>0&&N!==v.headerBox)w((C)=>({...C,headerBox:N}));if(I>0&&I!==v.hitBox)w((C)=>({...C,hitBox:I}))},[M,v,p]),W(()=>{k()},[k]),W(()=>{let g=m.current;if(!g||typeof ResizeObserver>"u")return;let N=new ResizeObserver(()=>k());return N.observe(g),()=>N.disconnect()},[k]);let P=p.length===0?0:Math.min(M.start,p.length-1),L=Math.min(M.end,p.length),B=p.slice(P,L),A=L<p.length?x.total-x.offsets[L]:0;return e("div",{ref:F,onScroll:y,className:"flex-1 scrollbar-overlay-container px-3 text-xs",style:{overflowAnchor:"none"},children:[e("div",{style:{height:be+(x.offsets[P]??0)},"aria-hidden":"true"}),e("div",{ref:R,children:B.map((g,N)=>{let I=P+N,C=x.heights[I];if(g.kind==="group")return e("div",{"data-search-header":"",style:{height:C},children:e("div",{className:"font-semibold text-ink/80 flex items-center justify-between group",children:[e("div",{className:"flex items-center min-w-0",children:[e(lt,{name:g.file,size:12,className:"mr-1.5 flex-shrink-0"}),e("span",{className:"truncate",children:g.file}),e("span",{className:"ml-2 bg-ink/10 text-[10px] px-1.5 py-0.5 rounded-full flex-shrink-0",children:g.count})]}),e("button",{onClick:()=>c(g.file),disabled:l,className:"touch-visible opacity-0 group-hover:opacity-100 p-1 text-ink/40 hover:text-ink rounded hover:bg-ink/5 disabled:opacity-50 flex-shrink-0",title:"Replace in this file",children:e(qi,{size:12})})]})},`group:${g.file}`);return e("div",{"data-search-hit":"",style:{height:C},children:e(te,{file:g.file,result:g.result,replacement:r,showReplacePreview:t,onOpen:h})},`hit:${g.file}:${g.result.line}:${I}`)})}),e("div",{style:{height:Se+A},"aria-hidden":"true"})]})}function ce({className:s,query:r,setQuery:t,replaceQuery:h,setReplaceQuery:c,matchCase:l,setMatchCase:m,wholeWord:R,setWholeWord:p,useRegex:v,setUseRegex:w,includeFiles:x,setIncludeFiles:M,showIncludeField:E,setShowIncludeField:F,showMenu:k,setShowMenu:y,menuRef:P,rootPath:L,activeRepo:B,setActiveRepo:A,repos:g,reposScanning:N,rescanRepos:I,results:C,isSearching:G,truncated:H,error:z,onOpenFile:J,handleReplace:q,replaceBusy:Q}){let X=u(()=>se(C),[C]),_=i(null),K=i(null),U=a(()=>{t(""),_.current?.focus()},[t]),j=a(()=>{c(""),K.current?.focus()},[c]),V=u(()=>({matchCase:l,wholeWord:R,isRegex:v,inSelection:!1}),[l,R,v]),he=a((T)=>{Vu({path:T.file,line:Number(T.line),query:r,options:V}),J?.({path:T.file,name:T.file.split("/").pop()||T.file,root:L,repo:B})},[r,V,L,B,J]),de=a((T)=>q(T),[q]);return e("div",{className:`flex flex-col h-full bg-paper ${s}`,children:[e(ht,{left:e(d,{children:[e("h2",{className:"text-xs font-semibold text-ink uppercase tracking-wider",children:"Search"}),e(br,{rootPath:L,activeRepo:B,onSelectRepo:A,repos:g,scanning:N,onRefreshRepos:I})]}),right:e("div",{className:"relative",ref:P,children:[e("button",{onClick:()=>y(!k),className:`p-1 rounded hover:bg-ink/5 transition-colors ${k||E?"text-ink":"text-ink/40"}`,title:"Search Options",children:e(Ie,{size:14})}),k&&e("div",{className:"glass-popover absolute right-0 top-full mt-1 w-48 bg-paper border border-ink/10 rounded shadow-lg z-10 py-1",children:e("button",{onClick:()=>{if(F(!E),E)M("");y(!1)},className:"w-full px-3 py-1.5 text-left text-xs text-ink hover:bg-ink/5 flex items-center justify-between",children:[e("span",{children:"Files to include"}),E&&e(f,{size:12,className:"text-ink/60"})]})})]})}),e("div",{className:"p-3 flex flex-col gap-2.5 border-b border-ink/10",children:[e("div",{className:"relative",children:e("div",{className:"flex items-center border border-ink/20 rounded bg-paper focus-within:border-ink/40 focus-within:ring-1 focus-within:ring-ink/10 transition-all",children:[e(O,{size:14,className:"ml-2 text-ink/40 flex-shrink-0"}),e("input",{ref:_,type:"text",placeholder:"Search",value:r,onChange:(T)=>t(T.currentTarget.value),className:"w-full bg-transparent border-none text-xs px-2 py-1.5 focus:outline-none text-ink placeholder-ink/35 min-w-0"}),r&&e("button",{type:"button",onClick:U,title:"Clear search","aria-label":"Clear search",className:"p-1 mr-0.5 rounded text-ink/40 hover:text-ink hover:bg-ink/5 flex-shrink-0",children:e(b,{size:12})}),e("div",{className:"flex items-center space-x-0.5 pr-1 text-ink/40 flex-shrink-0",children:[e("button",{onClick:()=>m(!l),className:`p-1 rounded hover:text-ink ${l?"bg-ink/10 text-ink":"hover:bg-ink/5"}`,title:"Match Case",children:e($i,{size:14})}),e("button",{onClick:()=>p(!R),className:`p-1 rounded hover:text-ink ${R?"bg-ink/10 text-ink":"hover:bg-ink/5"}`,title:"Match Whole Word",children:e(Wi,{size:14})}),e("button",{onClick:()=>w(!v),className:`p-1 rounded hover:text-ink ${v?"bg-ink/10 text-ink":"hover:bg-ink/5"}`,title:"Use Regular Expression",children:e(Gi,{size:14})})]})]})}),e("div",{className:"relative flex items-center space-x-1",children:[e("div",{className:"flex flex-1 min-w-0 items-center border border-ink/20 rounded bg-paper focus-within:border-ink/40 focus-within:ring-1 focus-within:ring-ink/10 transition-all",children:[e("input",{ref:K,type:"text",placeholder:"Replace",value:h,onChange:(T)=>c(T.currentTarget.value),className:"flex-1 min-w-0 bg-transparent border-none text-xs px-2 py-1.5 focus:outline-none text-ink placeholder-ink/35"}),h&&e("button",{type:"button",onClick:j,title:"Clear replace","aria-label":"Clear replace",className:"p-1 mr-0.5 rounded text-ink/40 hover:text-ink hover:bg-ink/5 flex-shrink-0",children:e(b,{size:12})})]}),e("button",{onClick:()=>q(),disabled:C.length===0||Q,className:"p-1.5 rounded border border-ink/20 text-ink/60 hover:text-ink hover:bg-ink/5 disabled:opacity-50 disabled:cursor-not-allowed bg-paper",title:"Replace All",children:e(ji,{size:14})})]}),E&&e("div",{className:"relative",children:e("input",{type:"text",value:x,onChange:(T)=>M(T.currentTarget.value),placeholder:"Files to include (e.g. *.js, src/*)",className:"w-full bg-paper border border-ink/20 rounded text-xs px-2 py-1.5 focus:outline-none focus:border-ink/40 focus:ring-1 focus:ring-ink/10 transition-all text-ink placeholder-ink/40"})})]}),z&&C.length===0?e("div",{className:"flex-1 px-3 py-3",role:"alert",children:e("div",{className:"rounded border border-error/30 bg-error/5 px-2.5 py-2",children:[e("div",{className:"text-[11px] font-semibold text-error",children:"Search failed"}),e("div",{className:"mt-1 whitespace-pre-wrap break-words font-mono text-[10.5px] text-ink/70",children:z}),v&&e("div",{className:"mt-1 text-[10.5px] text-ink/50",children:["Regex is on — escape metacharacters such as ",e("code",{className:"font-mono",children:"( ) [ ] * ? +"})," or turn it off to search literally."]})]})}):G&&C.length===0?e("div",{className:"flex-1 text-ink/40 italic text-center py-4",children:"Searching..."}):r.trim().length<=2?e("div",{className:"flex-1 text-ink/40 italic text-center py-4",children:"Type at least 3 characters to search."}):C.length===0?e("div",{className:"flex-1 text-ink/40 italic text-center py-4",children:"No results found."}):e(d,{children:[z&&e("div",{className:"px-3 pt-2 text-[10.5px] text-error",role:"alert",children:["Search failed: ",e("span",{className:"font-mono",children:z})]}),G&&e("div",{className:"px-3 pt-2 text-ink/40 italic",children:"Searching…"}),H&&e("div",{className:"px-3 pt-2 text-ink/50 italic",children:["Showing the first ",ne," matches — refine the query to see the rest."]}),e(le,{groups:X,replacement:h,showReplacePreview:h.length>0,onOpen:he,onReplaceFile:de,replaceBusy:Q})]})]})}function ue(s){let[r,t]=n({scope:s,results:[],truncated:!1,error:null}),[h,c]=n(!1),l=i(null),m=i(!0),R=i(s);R.current=s,o(()=>(m.current=!0,()=>{m.current=!1,l.current?.abort(),l.current=null}),[]);let p=a(async(v)=>{l.current?.abort();let w=new AbortController;l.current=w;let x=R.current;t({scope:x,results:[],truncated:!1,error:null}),c(!0);try{let M=await fetch("/api/fs/search",{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:new URLSearchParams(v),signal:w.signal});await rc(M,(E,F)=>{if(R.current!==x)return;if(E==="done"){let k=!1;try{k=JSON.parse(F)?.truncated===!0}catch{}t((y)=>y.scope===x?{...y,truncated:k}:y);return}if(E==="error"){let k="Search failed";try{k=JSON.parse(F)?.error||k}catch{}t((y)=>y.scope===x?{...y,error:k}:y);return}if(E!=="matches")return;try{let k=JSON.parse(F);if(Array.isArray(k))t((y)=>y.scope===x?{...y,results:[...y.results,...k]}:y)}catch{}},w.signal)}catch{}finally{if(m.current&&l.current===w)l.current=null,c(!1)}},[]);return{results:r.scope===s?r.results:[],isSearching:h&&r.scope===s,truncated:r.scope===s&&r.truncated,error:r.scope===s?r.error:null,start:p}}function st({className:s="",enabled:r=!0,rootPath:t,onOpenFile:h}){let[c,l]=S("search.query",""),[m,R]=S("search.replaceQuery",""),[p,v]=S("search.matchCase",!1),[w,x]=S("search.wholeWord",!1),[M,E]=S("search.useRegex",!1),[F,k]=S("search.includeFiles",""),[y,P]=n(!1),[L,B]=S("search.showIncludeField",!1),{activeRepo:A,setActiveRepo:g}=cr(t),{repos:N,scanning:I,rescan:C}=ur(t,r),G=i(null),H=ct(),{results:z,isSearching:J,truncated:q,error:Q,start:X}=ue(`${t??""}\x00${A}`);pe(G,()=>P(!1));let _=a(()=>{if(!r)return;if(c.trim().length>2)return X({q:c,matchCase:String(p),wholeWord:String(w),useRegex:String(M),includeFiles:L?F:"",...t?{root:t}:{},...A!=="."?{repo:A}:{}})},[r,c,p,w,M,L,F,t,A,X]);o(()=>{let U=setTimeout(()=>{_()},300);return()=>clearTimeout(U)},[_]);let K=a((U)=>{if(!c)return;let j=U?[U]:Array.from(new Set(z.map((V)=>V.file)));if(j.length===0)return;H.submit({q:c,replaceWith:m,matchCase:String(p),wholeWord:String(w),useRegex:String(M),files:JSON.stringify(j),...t?{root:t}:{},...A!=="."?{repo:A}:{}},{method:"POST",action:"/api/fs/replace"})},[c,m,p,w,M,z,t,A,H]);if(o(()=>{if(H.state==="idle"&&H.data?.success)_()},[H.state,H.data,_]),!r)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${s}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});return e(ce,{className:s,query:c,setQuery:l,replaceQuery:m,setReplaceQuery:R,matchCase:p,setMatchCase:v,wholeWord:w,setWholeWord:x,useRegex:M,setUseRegex:E,includeFiles:F,setIncludeFiles:k,showIncludeField:L,setShowIncludeField:B,showMenu:y,setShowMenu:P,menuRef:G,rootPath:t,activeRepo:A,setActiveRepo:g,repos:N,reposScanning:I,rescanRepos:C,results:z,isSearching:J,truncated:q,error:Q,onOpenFile:h,handleReplace:K,replaceBusy:H.state!=="idle"})}export{st as SearchPanel};
@@ -1,2 +1,2 @@
1
- import{n,o,s,G,Xr,uc,sg,lg,qA,dm}from"./index-rt6ac0kk.js";var p={name:"save",size:24,node:[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]},Et=s(p);var wd="omp:editor-theme-changed";function a(){if(typeof window>"u")return uc;return G("editorTheme")??uc}var m={theme:null,vars:{},themes:lg(null)};function hi(){let[e,t]=n(a);if(o(()=>{let i=(d)=>{let E=d.detail;t(E||a())};return window.addEventListener(wd,i),()=>window.removeEventListener(wd,i)},[]),o(()=>{dm(e)},[e]),e===Xr)return m;let r=sg(e);return{theme:r,vars:qA(r),themes:lg(e)}}var Cd="omp:editor-indent-changed",Ed=[2,4,8],ru={width:2,insertSpaces:!0};function Bd(){if(typeof window>"u")return ru;let e=G("editorIndentWidth"),t=G("editorInsertSpaces");return{width:typeof e==="number"&&Ed.includes(e)?e:ru.width,insertSpaces:typeof t==="boolean"?t:ru.insertSpaces}}function au(e){return e.insertSpaces?" ".repeat(e.width):"\t"}function ou(){let[e,t]=n(Bd);return o(()=>{let r=(i)=>{let d=i.detail;t(d??Bd())};return window.addEventListener(Cd,r),()=>window.removeEventListener(Cd,r)},[]),e}var Id="omp:editor-typing-changed",hl={autoCloseBrackets:!0,autocomplete:!0};function iu(){if(typeof window>"u")return hl;let e=G("editorAutoCloseBrackets"),t=G("editorAutocomplete");return{autoCloseBrackets:typeof e==="boolean"?e:hl.autoCloseBrackets,autocomplete:typeof t==="boolean"?t:hl.autocomplete}}function su(){let[e,t]=n(iu);return o(()=>{let r=(i)=>{let d=i.detail;t(d??iu())};return window.addEventListener(Id,r),()=>window.removeEventListener(Id,r)},[]),e}var As="omp:editor-blame-changed",bl={enabled:!0,inline:!1};function bi(){if(typeof window>"u")return bl;let e=G("editorBlame"),t=G("editorBlameInline");return{enabled:typeof e==="boolean"?e:bl.enabled,inline:typeof t==="boolean"?t:bl.inline}}function _d(){let[e,t]=n(bi);return o(()=>{let r=(i)=>{let d=i.detail;t(d??bi())};return window.addEventListener(As,r),()=>window.removeEventListener(As,r)},[]),e}
1
+ import{n,o,s,G,Xr,uc,sg,lg,qA,dm}from"./index-pzvr1699.js";var p={name:"save",size:24,node:[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]},Et=s(p);var wd="omp:editor-theme-changed";function a(){if(typeof window>"u")return uc;return G("editorTheme")??uc}var m={theme:null,vars:{},themes:lg(null)};function hi(){let[e,t]=n(a);if(o(()=>{let i=(d)=>{let E=d.detail;t(E||a())};return window.addEventListener(wd,i),()=>window.removeEventListener(wd,i)},[]),o(()=>{dm(e)},[e]),e===Xr)return m;let r=sg(e);return{theme:r,vars:qA(r),themes:lg(e)}}var Cd="omp:editor-indent-changed",Ed=[2,4,8],ru={width:2,insertSpaces:!0};function Bd(){if(typeof window>"u")return ru;let e=G("editorIndentWidth"),t=G("editorInsertSpaces");return{width:typeof e==="number"&&Ed.includes(e)?e:ru.width,insertSpaces:typeof t==="boolean"?t:ru.insertSpaces}}function au(e){return e.insertSpaces?" ".repeat(e.width):"\t"}function ou(){let[e,t]=n(Bd);return o(()=>{let r=(i)=>{let d=i.detail;t(d??Bd())};return window.addEventListener(Cd,r),()=>window.removeEventListener(Cd,r)},[]),e}var Id="omp:editor-typing-changed",hl={autoCloseBrackets:!0,autocomplete:!0};function iu(){if(typeof window>"u")return hl;let e=G("editorAutoCloseBrackets"),t=G("editorAutocomplete");return{autoCloseBrackets:typeof e==="boolean"?e:hl.autoCloseBrackets,autocomplete:typeof t==="boolean"?t:hl.autocomplete}}function su(){let[e,t]=n(iu);return o(()=>{let r=(i)=>{let d=i.detail;t(d??iu())};return window.addEventListener(Id,r),()=>window.removeEventListener(Id,r)},[]),e}var As="omp:editor-blame-changed",bl={enabled:!0,inline:!1};function bi(){if(typeof window>"u")return bl;let e=G("editorBlame"),t=G("editorBlameInline");return{enabled:typeof e==="boolean"?e:bl.enabled,inline:typeof t==="boolean"?t:bl.inline}}function _d(){let[e,t]=n(bi);return o(()=>{let r=(i)=>{let d=i.detail;t(d??bi())};return window.addEventListener(As,r),()=>window.removeEventListener(As,r)},[]),e}
2
2
  export{Et,wd,hi,Cd,Ed,ru,Bd,au,ou,Id,hl,iu,su,As,bl,bi,_d};
@@ -1 +1 @@
1
- import{d,n,o,i,u,a,yr,Ue,oe,e,Kn,w,eA,Ce,zs,S,cr,ur,s,Qn,L,tt,B,ie,vo,re,Ee,qe,ai,sn,oi,Kr,D,O,b,ht,it,pe,kt,Wu,lt,ct,dA,pA,Ji,Zi,Ku,je,es}from"./index-rt6ac0kk.js";import{$u,zu,Zo,Uu,Gu}from"./index-x7a5jpvq.js";import{br}from"./index-mphhvgm9.js";var Qt={name:"pen",size:24,node:[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],aliases:["edit-2"]},Ve=s(Qt);var Yt={name:"copy-plus",size:24,node:[["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"}]]},Xe=s(Yt);var Jt={name:"package-open",size:24,node:[["path",{d:"M12 22v-9",key:"x3hkom"}],["path",{d:"M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z",key:"2ntwy6"}],["path",{d:"M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13",key:"1pmm1c"}],["path",{d:"M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z",key:"12ttoo"}]]},Be=s(Jt);var Zt={name:"scissors",size:24,node:[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]},Te=s(Zt);function Qe({rootPath:t,activeRepo:r,repos:l,reposScanning:c,onRefreshRepos:p,onSelectRepo:f,searchQuery:x,onSearchChange:h,onRefresh:v,refreshing:g}){return e("div",{className:"border-b border-ink/10",children:[e(ht,{className:"border-b-0",left:e(br,{rootPath:t,activeRepo:r,onSelectRepo:f,repos:l,scanning:c,onRefreshRepos:p}),right:e(it,{label:"Refresh",onClick:v,busy:g})}),e("div",{className:"px-3 pb-3",children:e("div",{className:"relative",children:[e(O,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-ink/40"}),e("input",{type:"text",placeholder:"Search files...",value:x,onChange:(m)=>h(m.currentTarget.value),className:"w-full bg-canvas border border-ink/20 rounded pl-8 pr-3 py-1.5 text-xs focus:outline-none focus:border-ink transition-colors text-ink placeholder-ink/40"})]})})]})}function Ye({name:t,path:r,isFolder:l,isOpen:c,ignored:p,selected:f,gitStatus:x,folderStatus:h}){let v=f?"text-ink font-semibold":x?x.colorClass:h?h.colorClass:p?"text-ink/40":"";return e(d,{children:[l?c?e(B,{size:12,className:"flex-shrink-0 text-ink/40"}):e(ie,{size:12,className:"flex-shrink-0 text-ink/40"}):e("span",{className:"w-3 flex-shrink-0"}),e(lt,{name:t,isFolder:l,isOpen:c,size:12,className:`flex-shrink-0${p?" opacity-40":""}`}),e("span",{className:`truncate min-w-0 flex-1 ${v}`,title:p?`${r} — git-ignored`:void 0,children:t}),x&&e("span",{className:`font-mono text-[10px] font-bold px-1 rounded flex-shrink-0 ${x.colorClass}`,title:`Git: ${x.label}`,children:x.charStatus}),h&&e("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${h.hasDeleted?"bg-error":h.hasModified||h.hasStaged?"bg-info":"bg-success"}`,title:`${h.count} changed file${h.count>1?"s":""}`})]})}var en=28,tn=9,nn=8;function rn(t){let{isFolder:r,hasGitStatus:l,pasteLabel:c,busy:p,chainLabel:f,foldable:x,selectionCount:h,isArchive:v}=t,g=[],m=h>1,k=h===1?"":` ${h} items`;if(m)return g.push({kind:"item",id:"cut",label:`Cut${k}`,icon:e(Te,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"copy",label:`Copy${k}`,icon:e(re,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"separator"}),g.push({kind:"item",id:"compress",label:`Compress${k} to…`,icon:e(tt,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"separator"}),g.push({kind:"item",id:"delete",label:`Delete${k}`,icon:e(L,{size:13,className:"text-error"}),tone:"text-error"}),g;if(r){if(g.push({kind:"item",id:"new_file",label:"New File",icon:e(ai,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"new_folder",label:"New Folder",icon:e(sn,{size:13,className:"text-ink/60"})}),f)g.push({kind:"item",id:"unfold",label:"Unfold Folders",icon:e(B,{size:13,className:"text-ink/60"})});if(x)g.push({kind:"item",id:"fold",label:"Fold Folders",icon:e(ie,{size:13,className:"text-ink/60"})});g.push({kind:"separator"})}else{if(g.push({kind:"item",id:"view",label:"View",icon:e(qe,{size:13,className:"text-ink/60"})}),v)g.push({kind:"item",id:"extract",label:"Extract…",icon:e(Be,{size:13,className:"text-ink/60"}),disabled:p});if(l)g.push({kind:"item",id:"diff",label:"Open in Diff Panel",icon:e(oi,{size:13,className:"text-warning"}),tone:"font-medium"});g.push({kind:"separator"})}if(g.push({kind:"item",id:"cut",label:"Cut",icon:e(Te,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"copy",label:"Copy",icon:e(re,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"compress",label:"Compress to…",icon:e(tt,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"duplicate",label:"Duplicate",icon:e(Xe,{size:13,className:"text-ink/60"}),disabled:p}),c)g.push({kind:"item",id:"paste",label:c,icon:e(vo,{size:13,className:"text-ink/60"}),disabled:p});return g.push({kind:"separator"}),g.push({kind:"item",id:"explorer",label:"Go to Explorer",icon:e(Ee,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"copy_path",label:"Copy Path",icon:e(re,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"copy_relative",label:"Copy Relative Path",icon:e(re,{size:13,className:"text-ink/60"})}),g.push({kind:"separator"}),g.push({kind:"item",id:"history",label:"Show Git History",icon:e(Qn,{size:13,className:"text-ink/60"})}),g.push({kind:"separator"}),g.push({kind:"item",id:"rename",label:"Rename",icon:e(Ve,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"delete",label:"Delete",icon:e(L,{size:13,className:"text-error"}),tone:"text-error"}),g}function on(t){let r=t.filter((c)=>c.kind==="item").length,l=t.length-r;return r*en+l*tn+nn}function Je({x:t,y:r,isFolder:l,hasGitStatus:c,pasteLabel:p,chainLabel:f,foldable:x,busy:h,selectionCount:v,isArchive:g,onAction:m,menuRef:k}){let F=rn({isFolder:l,hasGitStatus:c,pasteLabel:p,busy:h,chainLabel:f,foldable:x,selectionCount:v,isArchive:g}),A=on(F),C=typeof window<"u"?Math.max(10,Math.min(t,window.innerWidth-210-12)):t,E=typeof window<"u"?Math.max(10,Math.min(r,window.innerHeight-A-12)):r;return oe(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>m("close"),onContextMenu:(R)=>{R.preventDefault(),m("close")},children:e("div",{ref:k,className:"glass-popover fixed z-50 bg-paper border border-ink/15 shadow-2xl rounded-lg py-1 min-w-[185px] text-xs text-ink font-sans",style:{top:E,left:C},onClick:(R)=>R.stopPropagation(),children:F.map((R,N)=>R.kind==="separator"?e("div",{className:"my-1 border-t border-ink/10"},`sep-${N}`):e("button",{type:"button",disabled:R.disabled,onClick:()=>m(R.id),className:`w-full text-left px-3 py-1.5 flex items-center space-x-2 transition-colors ${R.disabled?"opacity-40 cursor-default":"hover:bg-ink/5"} ${R.tone??""}`,children:[R.icon,e("span",{children:R.label})]},R.id))})}),document.body)}function Fe({folderPath:t,kind:r,value:l,error:c,isLoading:p,onChange:f,onCancel:x,onSubmit:h}){let v=r==="folder"?"Folder":"File";return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:h,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-3 text-sm",children:["New ",v]}),e("div",{className:"flex items-center gap-1 mb-1 text-xs font-mono text-ink/50 min-w-0",children:e("span",{className:"truncate",title:t,children:[t||".","/"]})}),e("input",{autoFocus:!0,type:"text",value:l,onChange:(g)=>f(g.currentTarget.value),placeholder:r==="folder"?"folder name or nested/path":"file name or nested/path","aria-label":`New ${v.toLowerCase()} name`,className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none mb-1 ${c?"border-error":"border-ink/20 focus:border-ink"}`}),e("p",{className:"text-[10px] text-ink/40 mb-2",children:["Nested paths create the folders they need — ",e("span",{className:"font-mono",children:"lib/parse.ts"}),"."]}),c&&e("p",{className:"text-[11px] text-error mb-2",children:c}),e("div",{className:"flex justify-end space-x-2 mt-2",children:[e("button",{type:"button",onClick:x,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:p,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:p||!l.trim(),children:p?"Creating...":"Create"})]})]})}),document.body)}function Ze({fileName:t,displayName:r,isFolder:l,count:c=1,isLoading:p,onCancel:f,onConfirm:x}){let h=c>1;return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("div",{className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-2 text-sm",children:["Delete ",h?`${c} Items`:l?"Folder":"File"]}),e("p",{className:"text-xs text-ink/70 mb-4",children:["Are you sure you want to delete ",h?e(d,{children:["the ",c," selected entries"]}):e("span",{className:"font-mono bg-canvas px-1 rounded",children:t}),"? This action cannot be undone."]}),r&&r!==t&&e("p",{className:"text-[11px] text-ink/50 mb-4",children:["The row is ",e("span",{className:"font-mono",children:r}),"; this deletes"," ",e("span",{className:"font-mono",children:t})," only."]}),e("div",{className:"flex justify-end space-x-2",children:[e("button",{onClick:f,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:p,children:"Cancel"}),e("button",{onClick:x,className:"px-3 py-1.5 text-xs bg-error text-white rounded hover:bg-error/90 transition-colors flex items-center",disabled:p,children:p?"Deleting...":"Delete"})]})]})}),document.body)}function et({isFolder:t,renameValue:r,originalPath:l,displayName:c,error:p,isLoading:f,onChange:x,onCancel:h,onSubmit:v}){return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:v,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-3 text-sm",children:["Rename ",t?"Folder":"File"]}),e("input",{autoFocus:!0,type:"text",value:r,onChange:(g)=>x(g.currentTarget.value),"aria-label":`Rename ${t?"folder":"file"} path`,className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none mb-1 ${p?"border-error":"border-ink/20 focus:border-ink"}`}),e("p",{className:"text-[10px] text-ink/40 mb-2",children:["Paths are relative to the tree — ",e("span",{className:"font-mono",children:"lib/deep/name.ts"})," moves it too."]}),c&&e("p",{className:"text-[11px] text-ink/50 mb-2",children:["The row is ",e("span",{className:"font-mono",children:c}),"; this renames"," ",e("span",{className:"font-mono",children:l}),". Use"," ",e("span",{className:"font-mono",children:"Unfold Folders"})," to rename a folder inside the chain."]}),p&&e("p",{className:"text-[11px] text-error mb-2",children:p}),e("div",{className:"flex justify-end space-x-2",children:[e("button",{type:"button",onClick:h,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:f,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:f||!r.trim()||r===l,children:f?"Renaming...":"Rename"})]})]})}),document.body)}function nt({filePath:t,fetcherState:r,fetcherData:l,onClose:c}){let p=l?.type==="history"?l.data:void 0;return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("div",{className:"glass-overlay bg-paper rounded-lg shadow-xl w-full max-w-4xl border border-ink/10 flex flex-col max-h-[85vh]",children:[e("div",{className:"flex items-center justify-between p-4 border-b border-ink/10",children:[e("h3",{className:"text-sm font-semibold text-ink flex items-center space-x-2",children:[e(Qn,{size:16,className:"text-ink/60"}),e("span",{children:["Git History: ",e("span",{className:"font-mono font-normal opacity-80",children:t})]})]}),e("button",{onClick:c,className:"p-1 hover:bg-ink/5 rounded text-ink/60 transition-colors",children:e(b,{size:14})})]}),e("div",{className:"flex-1 scrollbar-overlay-container p-2",children:r==="idle"?p?p.length>0?e("table",{className:"w-full text-left border-collapse text-[11px]",children:[e("thead",{className:"bg-canvas sticky top-0 z-10 border-b border-ink/10",children:e("tr",{children:[e("th",{className:"px-3 py-2 font-semibold text-ink/70 rounded-tl",children:"Description"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-32",children:"Date"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-32",children:"Author"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-24 text-right rounded-tr",children:"Commit"})]})}),e("tbody",{className:"divide-y divide-ink/5",children:p.map((f,x)=>e("tr",{className:"hover:bg-ink/[0.03] transition-colors group",children:[e("td",{className:"px-3 py-2 text-ink",children:f.message?e("span",{className:"font-medium text-ink/90 group-hover:text-ink",children:f.message}):null}),e("td",{className:"px-3 py-2 text-ink/60 whitespace-nowrap font-mono text-[10.5px]",children:f.time}),e("td",{className:"px-3 py-2 text-ink/70 whitespace-nowrap truncate max-w-[120px]",children:f.author}),e("td",{className:"px-3 py-2 text-right",children:f.hash?e("span",{className:"font-mono text-ink/50 group-hover:text-ink font-semibold transition-colors bg-canvas px-1.5 py-0.5 rounded border border-ink/10",children:f.hash}):null})]},x))})]}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs",children:"No commit history found for this file."}):l?.error?e("div",{className:"p-8 text-center text-error font-mono text-xs",children:l.error}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs",children:"Loading history..."}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs flex items-center justify-center space-x-2",children:[e(D,{size:14,className:"animate-spin"}),e("span",{children:"Loading history..."})]})})]})}),document.body)}function rt({actions:t,file:r,isFolder:l,chainLabel:c}){let p=t.selectionCount;return e(d,{children:[t.showCreateModal&&e(Fe,{folderPath:r.path,kind:t.createKind,value:t.createName,error:t.createError,isLoading:t.busy,onChange:t.setCreateName,onCancel:t.closeCreate,onSubmit:t.submitCreate}),t.showDeleteModal&&e(Ze,{fileName:r.path,displayName:p>1?void 0:c,isFolder:l,count:p,isLoading:t.busy,onCancel:t.closeDelete,onConfirm:t.submitDelete}),t.showRenameModal&&e(et,{isFolder:l,renameValue:t.renameValue,originalPath:r.path,displayName:l?c:void 0,error:t.renameError,isLoading:t.busy,onChange:t.setRenameValue,onCancel:t.closeRename,onSubmit:t.submitRename}),t.showHistoryModal&&e(nt,{filePath:r.path,fetcherState:t.fetcherState,fetcherData:t.fetcherData,onClose:t.closeHistory})]})}function Ae(t){let r=t.map(an);return r.some((l,c)=>l!==t[c])?r:t}function an(t){if(t.type!=="folder"||!Array.isArray(t.children))return t;let r=Ae(t.children),l=r===t.children?t:{...t,children:r};while(Array.isArray(l.children)&&l.children.length===1){let c=l.children[0];if(c.type!=="folder")break;l={...l,name:`${l.name}/${c.name}`,path:c.path,children:c.children,ignored:c.ignored??l.ignored}}return l}function Se(t){return t.type==="folder"&&t.name.includes("/")}function Me(t,r){let l=r.split("/"),c=t.split("/");if(l.length<2||l.length>c.length||l.some((f)=>!f))return null;let p=c.slice(0,c.length-l.length);return l.map((f,x)=>[...p,...l.slice(0,x+1)].join("/"))}function ot(t,r){let l=new Map;if(r.size===0)return{nodes:t,roots:l};let c=!1,p=(x)=>x.flatMap((h)=>{if(h.type!=="folder")return[h];let v=Array.isArray(h.children)?p(h.children):h.children,g=v===h.children?h:{...h,children:v},m=r.has(h.path)?Me(h.path,h.name):null;if(!m)return[g];c=!0,l.set(m[0],h.path);let k={...g,name:m[m.length-1].split("/").pop()};for(let y=m.length-1;y>0;y-=1){let F=m[y-1];k={name:F.split("/").pop(),path:F,type:"folder",ignored:g.ignored,children:[k]}}return[k]}),f=p(t);return{nodes:c?f:t,roots:l}}function st(t,r){let l=new Set,c=(x)=>{for(let h of x){if(h.type!=="folder")continue;if(l.add(h.path),Array.isArray(h.children))c(h.children)}};c(t);let p=r.split("/").slice(0,-1),f=[];for(let x=0;x<p.length;x+=1){let h=p.slice(0,x+1).join("/");if(l.has(h))f.push(h)}return f}function Ne({folderPath:t,rootPath:r,repo:l,onCreated:c,onOpenCreated:p}){let f=ct(),[x,h]=n(!1),[v,g]=n("file"),[m,k]=n(""),[y,F]=n(null),A=i(null);return o(()=>{if(f.state!=="idle"||!f.data)return;let C=f.data;if(A.current===C)return;if(A.current=C,C.success&&C.path){let E=C.kind==="folder"?"folder":"file";h(!1),k(""),F(null);let R=C.path.split("/").pop()||C.path;if(c({path:C.path,name:R,kind:E}),E==="file")p?.({path:C.path,name:R})}else F(C.error||`Could not create the ${v}`)},[f.state,f.data]),{open:x,kind:v,name:m,setName:k,error:y,busy:f.state!=="idle",openDialog:(C="file")=>{g(C),k(""),F(null),h(!0)},closeDialog:()=>h(!1),submit:(C)=>{C.preventDefault();let E=m.trim();if(!E)return;F(null);let R=new FormData;if(R.append("actionType","create"),R.append("path",t),R.append("name",E),v==="folder")R.append("kind","folder");if(l&&l!==".")R.append("repo",l);if(r)R.append("root",r);f.submit(R,{method:"post",action:"/api/fs/action"})}}}function we(t){if(!t)return null;if(t.entries.length===1)return t.entries[0].name;return`${t.entries.length} items`}function at(t,r){return`${t??""}\x00${r}`}function Le(t,r){if(r==="folder")return t;let l=t.lastIndexOf("/");return l===-1?".":t.slice(0,l)}function dt(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)}function pt(t,r){if(t.path===""||t.path===".")return"The workspace root cannot be moved or copied";if(t.kind==="folder"&&(r===t.path||r.startsWith(`${t.path}/`)))return"Cannot paste a folder into itself";return null}function ut(t,r){let l=pt(t,r);if(l)return l;if(r===dt(t.path))return"Already in this folder";return null}function ft(t,r,l){if(!t||t.entries.length===0)return"Nothing to paste";if(t.scope!==r)return"The clipboard holds an entry from another workspace";if(t.mode==="cut"&&t.entries.some((c)=>l===dt(c.path)))return"Already in this folder";for(let c of t.entries){let p=pt(c,l);if(p)return p}return null}function mt(t){if(typeof t!=="object"||t===null)return null;let r=t;if(typeof r.scope!=="string")return null;if(r.mode!=="copy"&&r.mode!=="cut")return null;let l=Array.isArray(r.entries)?r.entries:typeof r.path==="string"?[{path:r.path,name:r.name,kind:r.kind}]:[],c=[];for(let p of l){let f=ln(p);if(!f)return null;c.push(f)}if(c.length===0)return null;return{scope:r.scope,entries:c,mode:r.mode}}function ln(t){if(typeof t!=="object"||t===null)return null;let r=t;if(typeof r.path!=="string"||typeof r.name!=="string")return null;if(r.kind!=="file"&&r.kind!=="folder")return null;let l=r.path.split("/");if(r.path===""||r.path.startsWith("/")||l.some((c)=>c===""||c==="."||c===".."))return null;return{path:r.path,name:r.name,kind:r.kind}}var $e=[{id:"zip",label:"ZIP",extension:"zip"},{id:"7z",label:"7Z",extension:"7z"},{id:"rar",label:"RAR",extension:"rar"},{id:"tar",label:"TAR",extension:"tar"},{id:"tar.gz",label:"TAR.GZ",extension:"tar.gz"}],gt=[[".tar.gz","tar.gz"],[".tar.bz2","tar.bz2"],[".tar.xz","tar.xz"],[".tgz","tar.gz"],[".tbz2","tar.bz2"],[".txz","tar.xz"],[".tar","tar"],[".zip","zip"],[".7z","7z"],[".rar","rar"],[".gz","gz"],[".bz2","bz2"],[".xz","xz"]];function ze(t){let r=t.toLowerCase();for(let[l,c]of gt)if(r.endsWith(l))return c;return null}function bt(t){return ze(t)!==null}function cn(t){return $e.find((r)=>r.id===t)}function dn(t){return cn(t)?.extension??"zip"}function xt(t){let r=t.toLowerCase();for(let[l]of gt)if(r.endsWith(l))return t.slice(0,-l.length);return t}function vt(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)||"."}function yt(t){let r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}function Ct(t){if(t.length===0)return".";let r=t.map((c)=>vt(c).split("/").filter((p)=>p!==".")),l=r[0]??[];for(let c of r.slice(1)){let p=0;while(p<l.length&&p<c.length&&l[p]===c[p])p+=1;l=l.slice(0,p)}return l.length===0?".":l.join("/")}function De(t,r){let l=dn(r);if(t.length===1){let f=t[0],x=xt(f.name),h=x.lastIndexOf(".");return`${(f.kind==="folder"?f.name:h>0?x.slice(0,h):x)||"archive"}.${l}`}let c=Ct(t.map((f)=>f.path)),p=yt(c);return`${p==="."||p===""?"archive":p}.${l}`}function Ft(t){return Ct(t.map((r)=>r.path))}function Nt(t){let r=vt(t),l=xt(yt(t));if(!l)return r;return r==="."?l:`${r}/${l}`}function wt(t){return t.toUpperCase()}function Dt({file:t,diff:r,onOpenFile:l,onActionComplete:c,onCreated:p,onRenamed:f,onUnfold:x,onFold:h,clipboard:v,isFolder:g,selection:m,selected:k,archive:y}){let F=ct(),[A,C]=n(null),E=i(null),[R,N]=n(!1),[T,H]=n(!1),[W,ee]=n(!1),[te,ae]=n(t.path),[G,I]=n(null),{repo:z,rootPath:K}=t,j=Ne({folderPath:t.path,rootPath:K,repo:z,onCreated:(M)=>p?p(M):c(),onOpenCreated:(M)=>l?.({...M,root:K,repo:z||"."})}),ne=i(null);o(()=>{if(F.state!=="idle"||!F.data)return;let M=F.data;if(ne.current===M)return;if(ne.current=M,M.success&&!M.type)if(N(!1),H(!1),I(null),M.previousPath&&M.path&&f)f(M.previousPath,M.path);else c();else if(!M.success&&M.error&&R)I(M.error)},[F.state,F.data]);let q=(M)=>{if(z&&z!==".")M.append("repo",z);if(K)M.append("root",K);F.submit(M,{method:"post",action:"/api/fs/action"})},X=()=>{l?.({path:t.path,name:t.name,root:K,repo:z||"."})},J={path:t.path,name:t.name,kind:g?"folder":"file"},se=k&&m.length>1?m:[J],he=bt(t.name),Q=v.clip&&!v.refusalFor(J)?`Paste ${we(v.clip)??"item"}`:null,fe=(M)=>{if(C(null),I(null),M==="view")X();else if(M==="diff")window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.path,staged:r?.staged,status:r?.status||"M",repo:z||".",root:K}}));else if(M==="explorer"){let _=new FormData;_.append("actionType","open_explorer"),_.append("path",t.path),q(_)}else if(M==="copy_path")kt(Wu(t.basePath,t.path));else if(M==="copy_relative")kt(t.path);else if(M==="history"){ee(!0);let _=new FormData;_.append("actionType","git_history"),_.append("path",t.path),q(_)}else if(M==="rename")ae(t.path),N(!0);else if(M==="unfold")x?.();else if(M==="fold")h?.();else if(M==="new_file")j.openDialog("file");else if(M==="new_folder")j.openDialog("folder");else if(M==="delete")H(!0);else if(M==="cut")v.cut(se);else if(M==="copy")v.copy(se);else if(M==="compress")y.openCompress(se);else if(M==="extract")y.openExtract(J);else if(M==="duplicate")v.duplicate(J);else if(M==="paste")v.paste(J)},le=(M)=>{M.preventDefault(),I(null);let _=new FormData;_.append("actionType","rename"),_.append("path",t.path),_.append("newPath",te),q(_)},xe=()=>{let M=new FormData;if(M.append("actionType","delete"),se.length>1)M.append("paths",JSON.stringify(se.map((_)=>_.path)));else M.append("path",t.path);q(M)};return{contextMenu:A,contextMenuRef:E,openContextMenu:(M,_)=>C({x:M,y:_}),closeContextMenu:()=>C(null),showRenameModal:R,showDeleteModal:T,showHistoryModal:W,showCreateModal:j.open,createKind:j.kind,createError:j.error,createName:j.name,setCreateName:j.setName,renameValue:te,setRenameValue:ae,renameError:G,busy:F.state!=="idle"||j.busy||v.busy||y.busy,pasteLabel:Q,selectionCount:se.length,isArchive:he,chainLabel:x!==void 0,foldable:h!==void 0,fetcherState:F.state,fetcherData:F.data,handleAction:fe,submitCreate:j.submit,submitRename:le,submitDelete:xe,closeCreate:j.closeDialog,closeDelete:()=>H(!1),closeRename:()=>N(!1),closeHistory:()=>ee(!1)}}function Rt({target:t,dragging:r,clipboard:l,onDragStart:c,onDragEnd:p,onDropOn:f,onHoverAccept:x}){let h=r?.path===t.path,v=Boolean(r)&&!h&&l.moveRefusalFor(r,t)===null,[g,m]=n(!1);return o(()=>{if(!r)m(!1)},[r]),{isDragging:h,acceptsDrop:v,isDropHovered:g&&v,onDragStart:(y)=>{if(y.dataTransfer?.setData("text/plain",t.path),y.dataTransfer)y.dataTransfer.effectAllowed="move";c(t)},onDragEnd:p,onDragOver:(y)=>{if(!r)return;if(y.stopPropagation(),m(v),!v)return;if(y.preventDefault(),y.dataTransfer)y.dataTransfer.dropEffect="move";x?.(t)},onDragLeave:()=>m(!1),onDrop:(y)=>{if(!r)return;if(y.stopPropagation(),!v)return;y.preventDefault(),f(t)}}}function pn(t,r,l){if(r||l)return!1;return!Array.isArray(t.children)}function Oe({file:t,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:x,onCreated:h,onRenamed:v,expandedPaths:g,onToggleFolder:m,gitFileMap:k,gitFolderMap:y,clipboard:F,archive:A,selection:C,selectionTargets:E,dragging:R,onDragStart:N,onDragEnd:T,onDropOn:H,onUnfold:W,onFold:ee,foldRoots:te,touch:ae=!1}){let G=t.type==="folder",[I,z]=n(!1),[K,j]=n(!1),[ne,q]=n(!1),[X,J]=n(!1),se=Array.isArray(t.children)?t.children:[],he=(t.path||"").replace(/^\/+/,""),Q=!G?k?.get(he)||k?.get(t.path):void 0,fe=Q?Kn(Q.status,Q.staged):null,le=G?y?.get(he)||y?.get(t.path):null,xe=Boolean(fe),M=t.ignored===!0,_=g?g.has(t.path):I,ce=t.forceExpanded!==void 0?t.forceExpanded:_;o(()=>{J(!0)},[]),o(()=>{if(G&&g)z(g.has(t.path))},[g,t.path,G]),o(()=>{if(G&&ce&&pn(t,K,ne)&&p)q(!0),j(!0),Promise.resolve(p(t.path)).finally(()=>j(!1))},[G,ce,t.children,t.path,p,K,ne]);let ye={path:t.path,name:t.name,kind:G?"folder":"file"},be=C.selected.has(t.path),U=Dt({file:{path:t.path,name:t.name,basePath:l,rootPath:r,repo:c},selection:E,selected:be,archive:A,diff:{staged:Q?.staged||(Q?.status?Q.status[0]!==" "&&Q.status[0]!=="?":!1),status:fe?.charStatus},onOpenFile:f,onActionComplete:x,onCreated:h,onRenamed:v,onUnfold:W&&Se({type:G?"folder":"file",name:t.name})?()=>W(ye):void 0,onFold:ee&&te?.has(t.path)?()=>ee(te.get(t.path)):void 0,clipboard:F,isFolder:G});pe(U.contextMenuRef,U.closeContextMenu);let Y=$u({enabled:ae,onLongPress:(V,ge)=>U.openContextMenu(V,ge)}),ke=(V)=>{if(V.stopPropagation(),Y.consume())return;let ge=C.gestureOf(V);if(ge!=="plain"){C.applyGesture(ge,t.path);return}if(C.applyGesture("plain",t.path),G){let ue=!ce;if(z(ue),t.forceExpanded!==void 0)t.forceExpanded=void 0;if(m?.(t.path,ue),!ue)q(!1)}else if(f)f({...t,root:r,repo:c||"."})},ve=(V)=>{V.preventDefault(),V.stopPropagation(),C.ensureForContext(t.path),U.openContextMenu(V.clientX,V.clientY)},de=Rt({target:ye,dragging:R,clipboard:F,onDragStart:N,onDragEnd:T,onDropOn:H,onHoverAccept:W});return e("div",{children:[e("div",{className:`flex items-center space-x-1.5 py-1 px-2 cursor-pointer rounded group select-none ${de.isDragging?"opacity-40":""} ${de.isDropHovered?"bg-info/10 ring-1 ring-info/40 ring-inset":be?"bg-ink/[0.08] ring-1 ring-ink/20 ring-inset":"hover:bg-ink/5"}`,draggable:!ae,onClick:ke,onContextMenu:ve,onDragStart:de.onDragStart,onDragEnd:de.onDragEnd,onDragOver:de.onDragOver,onDragLeave:de.onDragLeave,onDrop:de.onDrop,onTouchStart:Y.onTouchStart,onTouchMove:Y.onTouchMove,onTouchEnd:Y.onTouchEnd,onTouchCancel:Y.onTouchCancel,children:e(Ye,{name:t.name,path:t.path,isFolder:G,isOpen:ce,ignored:M,selected:be,gitStatus:fe,folderStatus:le})}),ce&&K&&e("div",{className:"ml-3 border-l border-ink/10 pl-3 py-0.5 text-[10px] text-ink/30",children:"Loading…"}),ce&&!K&&se.length>0&&e("div",{className:"ml-3 border-l border-ink/10 pl-1",children:se.map((V)=>e(Oe,{file:V,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:x,onCreated:h,onRenamed:v,expandedPaths:g,onToggleFolder:m,gitFileMap:k,gitFolderMap:y,clipboard:F,archive:A,selection:C,selectionTargets:E,dragging:R,onDragStart:N,onDragEnd:T,onDropOn:H,onUnfold:W,onFold:ee,foldRoots:te,touch:ae},V.path))}),X&&U.contextMenu&&e(Je,{x:U.contextMenu.x,y:U.contextMenu.y,isFolder:G,hasGitStatus:xe,pasteLabel:U.pasteLabel,chainLabel:U.chainLabel,foldable:U.foldable,busy:U.busy,selectionCount:U.selectionCount,isArchive:U.isArchive,onAction:U.handleAction}),X&&e(rt,{actions:U,file:t,isFolder:G,chainLabel:Se({type:G?"folder":"file",name:t.name})?t.name:void 0})]})}function Tt({x:t,y:r,pasteLabel:l,busy:c,onAction:p,menuRef:f}){let h=l?104:76,v=typeof window<"u"?Math.max(10,Math.min(t,window.innerWidth-190-12)):t,g=typeof window<"u"?Math.max(10,Math.min(r,window.innerHeight-h-12)):r;return oe(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>p("close"),onContextMenu:(m)=>{m.preventDefault(),p("close")},children:e("div",{ref:f,className:"glass-popover fixed z-50 bg-paper border border-ink/15 shadow-2xl rounded-lg py-1 min-w-[185px] text-xs text-ink font-sans",style:{top:g,left:v},onClick:(m)=>m.stopPropagation(),children:[e("button",{type:"button",onClick:()=>p("new_file"),className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 flex items-center space-x-2 transition-colors",children:[e(ai,{size:13,className:"text-ink/60"}),e("span",{children:"New File"})]}),e("button",{type:"button",onClick:()=>p("new_folder"),className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 flex items-center space-x-2 transition-colors",children:[e(sn,{size:13,className:"text-ink/60"}),e("span",{children:"New Folder"})]}),l&&e("button",{type:"button",disabled:c,onClick:()=>p("paste"),className:`w-full text-left px-3 py-1.5 flex items-center space-x-2 transition-colors ${c?"opacity-40 cursor-default":"hover:bg-ink/5"}`,children:[e(vo,{size:13,className:"text-ink/60"}),e("span",{children:l})]})]})}),document.body)}function At({menu:t,menuRef:r,pasteLabel:l,busy:c,onAction:p,create:f}){return e(d,{children:[t&&e(Tt,{x:t.x,y:t.y,menuRef:r,pasteLabel:l,busy:c,onAction:p}),f.open&&e(Fe,{folderPath:".",kind:f.kind,value:f.name,error:f.error,isLoading:f.busy,onChange:f.setName,onCancel:f.closeDialog,onSubmit:f.submit})]})}function St({title:t,subject:r,error:l,busy:c,submitLabel:p,busyLabel:f,onSubmit:x,onCancel:h,children:v}){return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:x,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-1 text-sm",children:t}),e("p",{className:"text-[11px] text-ink/50 mb-3 break-words",children:r}),v,l&&e("p",{className:"text-[11px] text-error mb-2",children:l}),e("div",{className:"flex justify-end space-x-2 mt-3",children:[e("button",{type:"button",onClick:h,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:c,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:c,children:c?f:p})]})]})}),document.body)}function un({entries:t,format:r,name:l,destination:c,formats:p,error:f,busy:x,onFormatChange:h,onNameChange:v,onDestinationChange:g,onCancel:m,onSubmit:k}){let y=t.slice(0,4).map((A)=>A.name).join(", "),F=t.length>4?` +${t.length-4} more`:"";return e(St,{title:`Compress ${t.length===1?t[0].name:`${t.length} items`}`,subject:`${y}${F}`,error:f,busy:x,submitLabel:"Compress",busyLabel:"Compressing...",onCancel:m,onSubmit:(A)=>{A.preventDefault(),k()},children:[e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"archive-format",children:"Format"}),e("select",{id:"archive-format",value:r,onChange:(A)=>h(A.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 text-xs font-mono focus:outline-none focus:border-ink mb-3",children:p.map((A)=>e("option",{value:A.id,disabled:!A.available,children:[A.label,A.available?"":` — ${A.tool} not installed`]},A.id))}),e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"archive-name",children:"Archive name"}),e("input",{id:"archive-name",autoFocus:!0,type:"text",value:l,onChange:(A)=>v(A.currentTarget.value),"aria-label":"Archive name",className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none mb-3 ${f?"border-error":"border-ink/20 focus:border-ink"}`}),e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"archive-destination",children:"Destination folder"}),e("input",{id:"archive-destination",type:"text",value:c,onChange:(A)=>g(A.currentTarget.value),"aria-label":"Archive destination",className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 text-xs font-mono focus:outline-none focus:border-ink"})]})}function fn({archive:t,kindLabel:r,destination:l,error:c,busy:p,onDestinationChange:f,onCancel:x,onSubmit:h}){return e(St,{title:`Extract ${t.name}`,subject:`${r} archive · extracts into a folder`,error:c,busy:p,submitLabel:"Extract",busyLabel:"Extracting...",onCancel:x,onSubmit:(v)=>{v.preventDefault(),h()},children:[e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"extract-destination",children:"Extract to folder"}),e("input",{id:"extract-destination",autoFocus:!0,type:"text",value:l,onChange:(v)=>f(v.currentTarget.value),"aria-label":"Extract destination",className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none ${c?"border-error":"border-ink/20 focus:border-ink"}`})]})}function Et({archive:t}){if(t.compress)return e(un,{entries:t.compress.entries,format:t.compress.format,name:t.compress.name,destination:t.compress.destination,formats:t.formats,error:t.error,busy:t.busy,onFormatChange:t.setFormat,onNameChange:t.setName,onDestinationChange:t.setCompressDestination,onCancel:t.cancel,onSubmit:t.submitCompress});if(t.extract)return e(fn,{archive:t.extract.archive,kindLabel:wt(ze(t.extract.archive.name)??"zip"),destination:t.extract.destination,error:t.error,busy:t.busy,onDestinationChange:t.setExtractDestination,onCancel:t.cancel,onSubmit:t.submitExtract});return null}function Mt(){let[t,r]=S("files.outlineExpanded",!1),l=yr(),c=Ue(pA,dA),{symbols:p,total:f,truncated:x,notice:h}=Gu({content:c.content,language:c.language,state:c.state,note:c.note,path:c.path});if(c.state==="diff")return null;let v=c.preview,g=(m,k)=>{if(!c.path)return;if(v){let y=Ku(p,k);if(y)Zi({path:c.path,...y});return}Ji({path:c.path,line:m.line,column:m.column,length:m.name.length})};return e("div",{className:"border-t border-ink/10 bg-canvas/30 flex-shrink-0",children:[e("div",{className:"flex items-center hover:bg-ink/5 transition-colors",children:e("button",{type:"button",onClick:()=>r(!t),"aria-expanded":t,"aria-controls":l,"aria-label":"Outline",title:t?"Hide outline":"Show outline",className:"flex flex-1 min-w-0 items-center space-x-1 py-1.5 pl-3 pr-2 text-left font-semibold text-xs text-ink transition-colors cursor-pointer",children:[e("span",{className:"w-3 text-center font-mono","aria-hidden":"true",children:t?"▾":"▸"}),e(Kr,{size:12}),e("span",{children:"Outline"}),f>0&&e("span",{className:"font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[10px] text-ink/50",children:x?`${p.length}/${f.toLocaleString()}`:f})]})}),e("div",{className:"section-reveal","data-expanded":t,id:l,inert:!t,children:e("div",{children:e("div",{className:"px-2 pb-2",children:p.length===0?e("div",{className:"px-1 text-[10px] text-ink/40 italic py-1",children:h}):e("div",{className:"max-h-48 overflow-y-auto scrollbar-overlay-container flex flex-col",children:[p.map((m,k)=>e("button",{type:"button",onClick:()=>g(m,k),"aria-label":v?`${Zo(m.kind)} ${m.name}`:`${Zo(m.kind)} ${m.name}, line ${m.line}`,title:v?`Jump to ${Zo(m.kind).toLowerCase()}`:`${Zo(m.kind)} · line ${m.line}`,className:"flex w-full min-w-0 items-center gap-1.5 rounded px-1 py-0.5 text-left transition-colors hover:bg-ink/5 active:bg-ink/10",style:{paddingLeft:`${4+m.depth*12}px`},children:[e(zu,{kind:m.kind}),e("span",{className:"min-w-0 flex-1 truncate text-[11px] font-mono text-ink/80",children:m.name}),!v&&e("span",{className:"flex-shrink-0 font-mono text-[10px] text-ink/35",children:m.line})]},`${m.line}:${m.kind}:${m.name}`)),x&&e("div",{className:"px-1 py-1 text-[10px] italic text-ink/40",children:Uu(f)})]})})})})]})}function Pe(t,r){return Ae(t.map((l)=>mn(l,r)))}function mn(t,r){if(t.type!=="folder")return t;let l=r[t.path];if(!l)return t;return{...t,children:Pe(l,r)}}function hn(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)}function $t(t){let r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}function Lt(t){return[...t].sort((r,l)=>{if(r.type!==l.type)return r.type==="folder"?-1:1;return r.name.localeCompare(l.name)})}function Ie(t,r,l){let c=l.path.split("/"),p=c.slice(0,-1).join("/"),f=[...t],x={...r},h=f,v=null;for(let g=0;g<c.length-1;){let m=c.slice(0,g+1).join("/"),k=h.find((E)=>E.type==="folder"&&E.path===m),y=k?null:h.find((E)=>E.type==="folder"&&E.path.startsWith(`${m}/`)&&(p===E.path||p.startsWith(`${E.path}/`))),F=k??y,A=F?x[F.path]??F.children:null;if(F&&!Array.isArray(A))return{nodes:t,cache:r};if(!F){let E=gn(h,x,m);if(E){h=E;let R=h.find((T)=>T.path===m),N=Array.isArray(R?.children)?[...R.children]:[];x[m]=N,h=N,v=m,g+=1;continue}}let C=Array.isArray(A)?[...A]:[];if(F){x[F.path]=C,h=C,v=F.path,g=F.path.split("/").length;continue}h.push({name:c[g],path:m,type:"folder",ignored:!1}),x[m]=C,h=C,v=m,g+=1}if(h.push(l),v!==null)x[v]=Lt(h);return f=Lt(f),{nodes:f,cache:x}}function gn(t,r,l){let c=t.findIndex((v)=>v.type==="folder"&&v.path.startsWith(`${l}/`));if(c===-1)return null;let p=t[c],f=p.path.slice(l.length+1).split("/"),x=r[p.path]??p.children;if(Array.isArray(x))r[p.path]=x;let h={name:f[f.length-1],path:p.path,type:"folder",ignored:p.ignored,...Array.isArray(x)?{children:x}:{}};for(let v=f.length-2;v>=0;v-=1)h={name:f[v],path:`${l}/${f.slice(0,v+1).join("/")}`,type:"folder",ignored:!1,children:[h]};return t[c]={name:$t(l),path:l,type:"folder",ignored:!1,children:[h]},t}function zt(t,r,l){let c=t.find((m)=>m.path===l);if(c)return{entry:c,nodes:t.filter((m)=>m.path!==l),cache:r};let p=hn(l),f=r[p],x=f?.find((m)=>m.path===l);if(f&&x)return{entry:x,nodes:t,cache:{...r,[p]:f.filter((m)=>m.path!==l)}};let v=Object.keys(r).filter((m)=>l.startsWith(`${m}/`)&&r[m].some((k)=>k.path===l)).sort((m,k)=>k.length-m.length)[0];if(!v)return{entry:null,nodes:t,cache:r};let g=r[v];return{entry:g.find((m)=>m.path===l),nodes:t,cache:{...r,[v]:g.filter((m)=>m.path!==l)}}}function Ot(t,r,l){let c=!1,p=t.map((f)=>{let x=f.path===r||f.path.startsWith(`${r}/`),h=Array.isArray(f.children)?Ot(f.children,r,l):void 0;if(!x&&h===f.children)return f;c=!0;let v=x?f.path===r?l:`${l}${f.path.slice(r.length)}`:f.path,g=x?{...f,path:v,name:$t(v)}:{...f};if(h!==void 0)g.children=h;return g});return c?p:t}function Pt(t,r,l){let c={};for(let[p,f]of Object.entries(t)){let x=p===r?l:p.startsWith(`${r}/`)?`${l}${p.slice(r.length)}`:p;c[x]=x===p?f:Ot(f,r,l)}return c}function It(t,r,l){let c=new Set;for(let p of t)if(p===r)c.add(l);else if(p.startsWith(`${r}/`))c.add(`${l}${p.slice(r.length)}`);else c.add(p);return c}function Ht(t){if(!w(t))return{status:"missing"};if(typeof t.root!=="string"||t.root==="")return{status:"missing"};return{status:"ok",files:Array.isArray(t.files)?t.files.filter((r)=>w(r)):[],root:t.root}}async function He(t){try{return Ht(await(await fetch(t)).json())}catch{return{status:"failed"}}}function Gt({enabled:t,rootPath:r,activeRepo:l,expandedPaths:c,onExpansionPruned:p}){let f=`${r??""}\x00${l}`,[x,h]=n({scope:"",files:[],root:""}),[v,g]=n(!1),m=i({}),k=i([]),y=i(f);y.current=f;let F=i(""),A=i(""),C=i(c);C.current=c;let E=(I)=>{let z=new URLSearchParams;if(r)z.set("root",r);if(l&&l!==".")z.set("repo",l);if(I)z.set("path",I);return z.set("t",String(Date.now())),`/api/fs/dir?${z.toString()}`},R=(I,z)=>{F.current=I,A.current=z;let K=Pe(k.current,m.current);return h({scope:I,files:K,root:z}),K},N=async(I)=>{let z=[...C.current];if(z.length===0)return;let K=await Promise.all(z.map(async(X)=>({path:X,read:await He(E(X))})));if(y.current!==I)return;let j=[];for(let{path:X,read:J}of K)if(J.status==="ok")m.current[X]=J.files;else if(J.status==="missing")j.push(X);if(j.length===0)return;let ne=new Set(j);for(let X of j)delete m.current[X];let q=new Set([...C.current].filter((X)=>!ne.has(X)));C.current=q,p(q)},T=async()=>{if(!t)return;let I=y.current;g(!0);try{let z=await He(E());if(y.current!==I)return;if(z.status!=="ok")return;if(F.current!==I)m.current={};if(k.current=z.files,R(I,z.root),await N(I),y.current!==I)return;R(I,z.root)}finally{if(y.current===I)g(!1)}},H=async(I)=>{let z=y.current,K=await He(E(I));if(y.current!==z||K.status!=="ok")return;if(m.current[I]=K.files,F.current===z)R(z,A.current)},W=(I)=>{let z=Ht(I);if(z.status!=="ok")return;let K=y.current;if(F.current!==K)m.current={};k.current=z.files,R(K,z.root),N(K).then(()=>{if(y.current===K)R(K,z.root)})},ee=()=>{m.current={},k.current=[],F.current="",A.current="",h({scope:"",files:[],root:""})},te=(I)=>{let z=y.current;if(F.current!==z)return null;let K={name:I.path.slice(I.path.lastIndexOf("/")+1),path:I.path,type:I.kind,ignored:!1},j=Ie(k.current,m.current,K);if(j.nodes===k.current)return null;return k.current=j.nodes,m.current=j.cache,R(z,A.current)},ae=(I,z)=>{let K=y.current;if(F.current!==K)return null;let j=zt(k.current,m.current,I);if(!j.entry)return null;m.current=Pt(j.cache,I,z);let ne={...j.entry,path:z,name:z.slice(z.lastIndexOf("/")+1)},q=Ie(j.nodes,m.current,ne);return k.current=q.nodes,m.current=q.cache,R(K,A.current)},G=x.scope===f;return{scope:f,files:G?x.files:[],root:G?x.root:"",isLoading:v,reload:T,loadChildren:H,adoptRoot:W,insertEntry:te,moveEntry:ae,reset:ee}}function Kt({rootPath:t,repo:r,onComplete:l,onError:c}){let p=ct(),[f,x]=S("files.clipboard",null),h=mt(f),v=at(t,r),g=i(!1),m=i(null);o(()=>{if(p.state!=="idle"||!p.data)return;let C=p.data;if(m.current===C)return;m.current=C;let E=g.current;if(g.current=!1,C.success){if(E)x(null);if(C.failures?.length)c(`${C.failures.length} item(s) could not be moved: ${C.failures[0].error}`);l()}else c(C.error||"The transfer did not complete")},[p.state,p.data]);let k=a((C,E)=>{g.current=E;let R=new FormData;for(let[N,T]of Object.entries(C))R.append(N,T);if(r&&r!==".")R.append("repo",r);if(t)R.append("root",t);p.submit(R,{method:"post",action:"/api/fs/action"})},[p,r,t]),y=a((C)=>ft(h,v,Le(C.path,C.kind)),[h,v]),F=a((C,E)=>ut(C,Le(E.path,E.kind)),[]),A=a((C,E,R,N)=>{let T=new FormData;T.append("actionType","paste"),T.append("mode",R),T.append("targetPath",E.path),T.append("targetKind",E.kind);for(let H of C)T.append("sourcePath",H.path);if(r&&r!==".")T.append("repo",r);if(t)T.append("root",t);g.current=N,p.submit(T,{method:"post",action:"/api/fs/action"})},[p,r,t]);return{clip:h,busy:p.state!=="idle",refusalFor:y,moveRefusalFor:F,copy:(C)=>{if(C.length===0)return;x({scope:v,entries:C.map(({path:E,name:R,kind:N})=>({path:E,name:R,kind:N})),mode:"copy"})},cut:(C)=>{if(C.length===0)return;x({scope:v,entries:C.map(({path:E,name:R,kind:N})=>({path:E,name:R,kind:N})),mode:"cut"})},duplicate:(C)=>{k({actionType:"duplicate",path:C.path},!1)},move:(C,E)=>{let R=F(C,E);if(R){c(R);return}A([C],E,"cut",Boolean(h?.mode==="cut"&&h.entries.some((N)=>N.path===C.path)))},paste:(C)=>{if(!h)return;let E=y(C);if(E){c(E);return}A(h.entries.map(({path:R,name:N,kind:T})=>({path:R,name:N,kind:T})),C,h.mode,h.mode==="cut")}}}var bn=$e.map((t)=>({...t,available:!0,tool:t.id}));function jt({rootPath:t,repo:r,onComplete:l}){let c=ct(),[p,f]=n(bn),[x,h]=n(null),[v,g]=n(null),[m,k]=n(null),y=i(null),F=i(null);o(()=>{let N=!1;return(async()=>{try{let H=await(await fetch("/api/fs/archive")).json();if(!N&&Array.isArray(H.formats)&&H.formats.length>0)f(H.formats)}catch{}})(),()=>{N=!0}},[]),o(()=>{if(c.state!=="idle"||!c.data)return;let N=c.data;if(F.current===N)return;F.current=N;let T=y.current;if(y.current=null,N.success){if(k(null),T==="compress")h(null);if(T==="extract")g(null);l()}else if(T)k(N.error||"The archive request failed")},[c.state,c.data]);let A=a((N)=>{let T=new FormData;for(let[H,W]of Object.entries(N))T.append(H,W);if(r&&r!==".")T.append("repo",r);if(t)T.append("root",t);c.submit(T,{method:"post",action:"/api/fs/action"})},[c,r,t]),C=a((N)=>{if(N.length===0)return;let T=p.find((H)=>H.id==="zip"&&H.available)?.id??p.find((H)=>H.available)?.id??"zip";k(null),g(null),h({entries:N.map(({path:H,name:W,kind:ee})=>({path:H,name:W,kind:ee})),format:T,name:De(N,T),destination:Ft(N)})},[p]),E=a((N)=>{k(null),h(null),g({archive:N,destination:Nt(N.path)})},[]),R=a((N)=>{h((T)=>{if(!T)return T;let H=De(T.entries,T.format),W=T.name===H?De(T.entries,N):T.name;return{...T,format:N,name:W}})},[]);return{formats:p,compress:x,extract:v,error:m,busy:c.state!=="idle",openCompress:C,openExtract:E,setFormat:R,setName:(N)=>h((T)=>T&&{...T,name:N}),setCompressDestination:(N)=>h((T)=>T&&{...T,destination:N}),setExtractDestination:(N)=>g((T)=>T&&{...T,destination:N}),cancel:()=>{h(null),g(null),k(null)},submitCompress:()=>{let N=x;if(!N)return;y.current="compress",k(null),A({actionType:"compress",format:N.format,name:N.name.trim(),destination:N.destination.trim()||".",paths:JSON.stringify(N.entries.map((T)=>T.path))})},submitExtract:()=>{let N=v;if(!N)return;y.current="extract",k(null),A({actionType:"extract",path:N.archive.path,destination:N.destination.trim()||"."})}}}function xn(t){if(t.shiftKey)return"range";if(t.metaKey||t.ctrlKey)return"toggle";return"plain"}function vn(t,r,l){if(!r)return[l];let c=t.indexOf(r),p=t.indexOf(l);if(c===-1||p===-1)return[l];let f=Math.min(c,p),x=Math.max(c,p);return t.slice(f,x+1)}function _t(t){let[r,l]=n(()=>new Set),[c,p]=n(null),f=a((g,m)=>{if(g==="range"){l(new Set(vn(t,c,m)));return}if(p(m),g==="toggle"){l((k)=>{let y=new Set(k);if(y.has(m))y.delete(m);else y.add(m);return y});return}l(new Set([m]))},[c,t]),x=a((g)=>{l((m)=>{if(m.has(g))return m;return new Set([g])}),p(g)},[]),h=a(()=>{l(new Set),p(null)},[]),v=a(xn,[]);return u(()=>({selected:r,count:r.size,anchor:c,gestureOf:v,applyGesture:f,ensureForContext:x,clear:h}),[r,c,v,f,x,h])}function Ge(t,r,l=0,c=[]){for(let p of t)if(c.push({path:p.path,name:p.name,kind:p.type==="folder"?"folder":"file",depth:l}),p.type==="folder"&&r(p)&&Array.isArray(p.children))Ge(p.children,r,l+1,c);return c}function Wt({listing:t,setExpandedPaths:r,setStoredExpandedPaths:l,reload:c,onMoved:p}){let f=a((v,g)=>{let m=st(g,v);if(m.length===0)return;r((k)=>{if(m.every((F)=>k.has(F)))return k;let y=new Set(k);for(let F of m)y.add(F);return l(Array.from(y)),y})},[r,l]),x=a((v)=>{let g=t.insertEntry(v);if(!g){c();return}f(v.path,g)},[t,c,f]),h=a((v,g)=>{p?.(v,g),r((k)=>{let y=It(k,v,g);return l(Array.from(y)),y});let m=t.moveEntry(v,g);if(!m){c();return}f(g,m)},[t,c,f,r,l,p]);return{insertCreated:x,moveRenamed:h}}var yn=new Set;function Ut({scope:t,setExpandedPaths:r,setStoredExpandedPaths:l}){let[c,p]=n({scope:t,chains:new Map}),f=a((v)=>{let g=Me(v.path,v.name);if(!g)return;p((k)=>{let y=k.scope===t?k.chains:new Map;if(y.get(v.path)?.length===g.length)return k;let A=new Map(y);return A.set(v.path,g),{scope:t,chains:A}});let m=g.slice(0,-1);r((k)=>{if(m.every((F)=>k.has(F)))return k;let y=new Set(k);for(let F of m)y.add(F);return l(Array.from(y)),y})},[t,r,l]),x=a((v)=>{let g=c.scope===t?c.chains.get(v):void 0;if(!g)return;let m=g.slice(0,-1);p((k)=>{if(k.scope!==t)return k;let y=new Map(k.chains);return y.delete(v),{scope:t,chains:y}}),r((k)=>{if(!m.some((F)=>k.has(F)))return k;let y=new Set(k);for(let F of m)y.delete(F);return l(Array.from(y)),y})},[t,c,r,l]),h=a((v,g)=>{let m=c.scope===t?c.chains:null;if(!m)return;let k=new Map,y=[],F=!1;for(let[A,C]of m){if(C.findIndex((T,H)=>T===v&&H>0&&H<C.length-1)!==-1){F=!0;continue}let R=C.map((T)=>T===v?g:T.startsWith(`${v}/`)?`${g}${T.slice(v.length)}`:T),N=R[R.length-1];if(N!==A||R.some((T,H)=>T!==C[H]))F=!0;k.set(N,R),y.push(...R.slice(0,-1))}if(!F)return;p({scope:t,chains:k}),r((A)=>{if(y.every((E)=>A.has(E)))return A;let C=new Set(A);for(let E of y)C.add(E);return l(Array.from(C)),C})},[t,c,r,l]);return{unfolded:c.scope===t&&c.chains.size>0?new Set(c.chains.keys()):yn,unfold:f,fold:x,rekey:h}}function Vt(t,r){let l=r.trim().toLowerCase();if(!l)return t;let c=(p)=>{let f=p.name.toLowerCase().includes(l);if(p.type==="folder"){let x=(p.children||[]).map(c).filter((h)=>h!==null);if(f||x.length>0)return{...p,children:f&&x.length===0?p.children:x,forceExpanded:!0};return null}return f?p:null};return t.map(c).filter((p)=>p!==null)}function Xt({dragging:t,clipboard:r,target:l}){let c=Boolean(t)&&r.moveRefusalFor(t,l)===null,[p,f]=n(!1);return o(()=>{if(!t)f(!1)},[t]),{accepts:c,highlighted:p&&c,onDragEnter:()=>{if(t)f(!0)},onDragLeave:(x)=>{if(!x.currentTarget.contains(x.relatedTarget))f(!1)},onDragOver:(x)=>{if(!c)return;if(x.preventDefault(),x.dataTransfer)x.dataTransfer.dropEffect="move"},onDrop:(x)=>{if(!c)return;x.preventDefault(),f(!1),r.move(t,l)}}}function ni({className:t="",enabled:r=!0,active:l=!0,rootPath:c,onOpenFile:p,refreshKey:f=0,onRefresh:x}){let[h,v]=S("files.searchQuery",""),[g,m,k]=S("files.expandedPaths",[]),[y,F]=n(()=>new Set(g)),{activeRepo:A,setActiveRepo:C}=cr(c),{repos:E,scanning:R,rescan:N}=ur(c,r),{fileMap:T,folderMap:H,refreshGitStatus:W}=zs(c,A,r),[ee,te]=n(null),ae=i(null);o(()=>{if(!k)return;F((P)=>{let Z=new Set(g);if(P.size===Z.size&&Array.from(Z).every((me)=>P.has(me)))return P;return Z})},[k,g]);let G=Gt({enabled:r,rootPath:c,activeRepo:A,expandedPaths:y,onExpansionPruned:(P)=>{F(P),m(Array.from(P))}});o(()=>{if(!k||!l)return;G.reload()},[f,c,r,A,k,l]);let I=r&&k?eA(G.scope):null,z=Ce(I);o(()=>{if(z.data)G.adoptRoot(z.data)},[z.data]);let K=(P)=>(W(),G.loadChildren(P)),j=(P,Z)=>{let me=new Set(y);if(Z)me.add(P);else me.delete(P);F(me),m(Array.from(me))},{unfolded:ne,unfold:q,fold:X,rekey:J}=Ut({scope:G.scope,setExpandedPaths:F,setStoredExpandedPaths:m}),se=G.files,he=ot(se,ne),Q=Vt(he.nodes,h),fe=Ge(Q,(P)=>P.forceExpanded!==void 0?P.forceExpanded:y.has(P.path)),le=_t(fe.map((P)=>P.path)),xe=fe.filter((P)=>le.selected.has(P.path)).map(({path:P,name:Z,kind:me})=>({path:P,name:Z,kind:me})),M=(P)=>{if(P===A)return;G.reset(),F(new Set),m([]),le.clear(),C(P)},_=()=>{if(W(),x)x();else G.reload()},{insertCreated:ce,moveRenamed:ye}=Wt({listing:G,setExpandedPaths:F,setStoredExpandedPaths:m,reload:_,onMoved:(P,Z)=>J(P,Z)}),be=es(),{pushToast:U}=je(),Y=Kt({rootPath:c,repo:A,onComplete:_,onError:(P)=>U(P,"error")}),ke=jt({rootPath:c,repo:A,onComplete:_}),ve={path:".",name:".",kind:"folder"},de=Y.clip&&!Y.refusalFor(ve)?`Paste ${we(Y.clip)??"item"}`:null,[V,ge]=n(null),ue=Xt({dragging:V,clipboard:Y,target:ve}),Re=Ne({folderPath:".",rootPath:c,repo:A,onCreated:ce,onOpenCreated:(P)=>p?.({...P,root:c,repo:A})}),[Ke,qt]=n(!1);o(()=>qt(!0),[]);let{count:_e,clear:We}=le;if(o(()=>{if(!l)return;let P=(Z)=>{if(Z.key==="Escape"&&_e>0)We()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[l,_e,We]),!r)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${t}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});let Bt=G.isLoading||z.refreshing;return e("div",{className:`flex flex-col h-full bg-paper ${t}`,children:[e(Qe,{rootPath:c,activeRepo:A,repos:E,reposScanning:R,onRefreshRepos:N,onSelectRepo:M,searchQuery:h,onSearchChange:v,onRefresh:_,refreshing:Bt}),e("div",{className:`flex-1 scrollbar-overlay-container p-2 font-mono text-[11px] text-ink/80 ${be?"file-tree-touch":""} ${ue.highlighted?"bg-info/[0.06]":""}`,onContextMenu:(P)=>{P.preventDefault(),te({x:P.clientX,y:P.clientY})},onDragEnter:ue.onDragEnter,onDragLeave:ue.onDragLeave,onDragOver:ue.onDragOver,onDrop:ue.onDrop,children:G.isLoading&&Q.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"Loading files..."}):Q.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"No files found"}):Q.map((P)=>e(Oe,{file:P,rootPath:c,basePath:G.root,repo:A,onLoadChildren:K,onOpenFile:p,onActionComplete:_,onCreated:ce,onRenamed:ye,expandedPaths:y,onToggleFolder:j,gitFileMap:T,gitFolderMap:H,clipboard:Y,archive:ke,selection:le,selectionTargets:xe,dragging:V,onDragStart:ge,onDragEnd:()=>ge(null),onDropOn:(Z)=>{if(!V)return;Y.move(V,Z)},onUnfold:q,onFold:X,foldRoots:he.roots,touch:be},P.path))}),e(Mt,{}),Ke&&e(At,{menu:ee,menuRef:ae,pasteLabel:de,busy:Y.busy,create:Re,onAction:(P)=>{if(te(null),P==="new_file")Re.openDialog("file");if(P==="new_folder")Re.openDialog("folder");if(P==="paste")Y.paste(ve)}}),Ke&&e(Et,{archive:ke})]})}export{ni as FileExplorer};
1
+ import{d,n,o,i,u,a,yr,Ue,oe,e,Kn,w,eA,Ce,zs,S,cr,ur,s,Qn,L,tt,B,ie,vo,re,Ee,qe,ai,sn,oi,Kr,D,O,b,ht,it,pe,kt,Wu,lt,ct,dA,pA,Ji,Zi,Ku,je,es}from"./index-pzvr1699.js";import{$u,zu,Zo,Uu,Gu}from"./index-1t5ybx9v.js";import{br}from"./index-7a2efrbj.js";var Qt={name:"pen",size:24,node:[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],aliases:["edit-2"]},Ve=s(Qt);var Yt={name:"copy-plus",size:24,node:[["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"}]]},Xe=s(Yt);var Jt={name:"package-open",size:24,node:[["path",{d:"M12 22v-9",key:"x3hkom"}],["path",{d:"M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z",key:"2ntwy6"}],["path",{d:"M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13",key:"1pmm1c"}],["path",{d:"M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z",key:"12ttoo"}]]},Be=s(Jt);var Zt={name:"scissors",size:24,node:[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]},Te=s(Zt);function Qe({rootPath:t,activeRepo:r,repos:l,reposScanning:c,onRefreshRepos:p,onSelectRepo:f,searchQuery:x,onSearchChange:h,onRefresh:v,refreshing:g}){return e("div",{className:"border-b border-ink/10",children:[e(ht,{className:"border-b-0",left:e(br,{rootPath:t,activeRepo:r,onSelectRepo:f,repos:l,scanning:c,onRefreshRepos:p}),right:e(it,{label:"Refresh",onClick:v,busy:g})}),e("div",{className:"px-3 pb-3",children:e("div",{className:"relative",children:[e(O,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-ink/40"}),e("input",{type:"text",placeholder:"Search files...",value:x,onChange:(m)=>h(m.currentTarget.value),className:"w-full bg-canvas border border-ink/20 rounded pl-8 pr-3 py-1.5 text-xs focus:outline-none focus:border-ink transition-colors text-ink placeholder-ink/40"})]})})]})}function Ye({name:t,path:r,isFolder:l,isOpen:c,ignored:p,selected:f,gitStatus:x,folderStatus:h}){let v=f?"text-ink font-semibold":x?x.colorClass:h?h.colorClass:p?"text-ink/40":"";return e(d,{children:[l?c?e(B,{size:12,className:"flex-shrink-0 text-ink/40"}):e(ie,{size:12,className:"flex-shrink-0 text-ink/40"}):e("span",{className:"w-3 flex-shrink-0"}),e(lt,{name:t,isFolder:l,isOpen:c,size:12,className:`flex-shrink-0${p?" opacity-40":""}`}),e("span",{className:`truncate min-w-0 flex-1 ${v}`,title:p?`${r} — git-ignored`:void 0,children:t}),x&&e("span",{className:`font-mono text-[10px] font-bold px-1 rounded flex-shrink-0 ${x.colorClass}`,title:`Git: ${x.label}`,children:x.charStatus}),h&&e("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${h.hasDeleted?"bg-error":h.hasModified||h.hasStaged?"bg-info":"bg-success"}`,title:`${h.count} changed file${h.count>1?"s":""}`})]})}var en=28,tn=9,nn=8;function rn(t){let{isFolder:r,hasGitStatus:l,pasteLabel:c,busy:p,chainLabel:f,foldable:x,selectionCount:h,isArchive:v}=t,g=[],m=h>1,k=h===1?"":` ${h} items`;if(m)return g.push({kind:"item",id:"cut",label:`Cut${k}`,icon:e(Te,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"copy",label:`Copy${k}`,icon:e(re,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"separator"}),g.push({kind:"item",id:"compress",label:`Compress${k} to…`,icon:e(tt,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"separator"}),g.push({kind:"item",id:"delete",label:`Delete${k}`,icon:e(L,{size:13,className:"text-error"}),tone:"text-error"}),g;if(r){if(g.push({kind:"item",id:"new_file",label:"New File",icon:e(ai,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"new_folder",label:"New Folder",icon:e(sn,{size:13,className:"text-ink/60"})}),f)g.push({kind:"item",id:"unfold",label:"Unfold Folders",icon:e(B,{size:13,className:"text-ink/60"})});if(x)g.push({kind:"item",id:"fold",label:"Fold Folders",icon:e(ie,{size:13,className:"text-ink/60"})});g.push({kind:"separator"})}else{if(g.push({kind:"item",id:"view",label:"View",icon:e(qe,{size:13,className:"text-ink/60"})}),v)g.push({kind:"item",id:"extract",label:"Extract…",icon:e(Be,{size:13,className:"text-ink/60"}),disabled:p});if(l)g.push({kind:"item",id:"diff",label:"Open in Diff Panel",icon:e(oi,{size:13,className:"text-warning"}),tone:"font-medium"});g.push({kind:"separator"})}if(g.push({kind:"item",id:"cut",label:"Cut",icon:e(Te,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"copy",label:"Copy",icon:e(re,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"compress",label:"Compress to…",icon:e(tt,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"duplicate",label:"Duplicate",icon:e(Xe,{size:13,className:"text-ink/60"}),disabled:p}),c)g.push({kind:"item",id:"paste",label:c,icon:e(vo,{size:13,className:"text-ink/60"}),disabled:p});return g.push({kind:"separator"}),g.push({kind:"item",id:"explorer",label:"Go to Explorer",icon:e(Ee,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"copy_path",label:"Copy Path",icon:e(re,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"copy_relative",label:"Copy Relative Path",icon:e(re,{size:13,className:"text-ink/60"})}),g.push({kind:"separator"}),g.push({kind:"item",id:"history",label:"Show Git History",icon:e(Qn,{size:13,className:"text-ink/60"})}),g.push({kind:"separator"}),g.push({kind:"item",id:"rename",label:"Rename",icon:e(Ve,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"delete",label:"Delete",icon:e(L,{size:13,className:"text-error"}),tone:"text-error"}),g}function on(t){let r=t.filter((c)=>c.kind==="item").length,l=t.length-r;return r*en+l*tn+nn}function Je({x:t,y:r,isFolder:l,hasGitStatus:c,pasteLabel:p,chainLabel:f,foldable:x,busy:h,selectionCount:v,isArchive:g,onAction:m,menuRef:k}){let F=rn({isFolder:l,hasGitStatus:c,pasteLabel:p,busy:h,chainLabel:f,foldable:x,selectionCount:v,isArchive:g}),A=on(F),C=typeof window<"u"?Math.max(10,Math.min(t,window.innerWidth-210-12)):t,E=typeof window<"u"?Math.max(10,Math.min(r,window.innerHeight-A-12)):r;return oe(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>m("close"),onContextMenu:(R)=>{R.preventDefault(),m("close")},children:e("div",{ref:k,className:"glass-popover fixed z-50 bg-paper border border-ink/15 shadow-2xl rounded-lg py-1 min-w-[185px] text-xs text-ink font-sans",style:{top:E,left:C},onClick:(R)=>R.stopPropagation(),children:F.map((R,N)=>R.kind==="separator"?e("div",{className:"my-1 border-t border-ink/10"},`sep-${N}`):e("button",{type:"button",disabled:R.disabled,onClick:()=>m(R.id),className:`w-full text-left px-3 py-1.5 flex items-center space-x-2 transition-colors ${R.disabled?"opacity-40 cursor-default":"hover:bg-ink/5"} ${R.tone??""}`,children:[R.icon,e("span",{children:R.label})]},R.id))})}),document.body)}function Fe({folderPath:t,kind:r,value:l,error:c,isLoading:p,onChange:f,onCancel:x,onSubmit:h}){let v=r==="folder"?"Folder":"File";return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:h,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-3 text-sm",children:["New ",v]}),e("div",{className:"flex items-center gap-1 mb-1 text-xs font-mono text-ink/50 min-w-0",children:e("span",{className:"truncate",title:t,children:[t||".","/"]})}),e("input",{autoFocus:!0,type:"text",value:l,onChange:(g)=>f(g.currentTarget.value),placeholder:r==="folder"?"folder name or nested/path":"file name or nested/path","aria-label":`New ${v.toLowerCase()} name`,className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none mb-1 ${c?"border-error":"border-ink/20 focus:border-ink"}`}),e("p",{className:"text-[10px] text-ink/40 mb-2",children:["Nested paths create the folders they need — ",e("span",{className:"font-mono",children:"lib/parse.ts"}),"."]}),c&&e("p",{className:"text-[11px] text-error mb-2",children:c}),e("div",{className:"flex justify-end space-x-2 mt-2",children:[e("button",{type:"button",onClick:x,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:p,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:p||!l.trim(),children:p?"Creating...":"Create"})]})]})}),document.body)}function Ze({fileName:t,displayName:r,isFolder:l,count:c=1,isLoading:p,onCancel:f,onConfirm:x}){let h=c>1;return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("div",{className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-2 text-sm",children:["Delete ",h?`${c} Items`:l?"Folder":"File"]}),e("p",{className:"text-xs text-ink/70 mb-4",children:["Are you sure you want to delete ",h?e(d,{children:["the ",c," selected entries"]}):e("span",{className:"font-mono bg-canvas px-1 rounded",children:t}),"? This action cannot be undone."]}),r&&r!==t&&e("p",{className:"text-[11px] text-ink/50 mb-4",children:["The row is ",e("span",{className:"font-mono",children:r}),"; this deletes"," ",e("span",{className:"font-mono",children:t})," only."]}),e("div",{className:"flex justify-end space-x-2",children:[e("button",{onClick:f,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:p,children:"Cancel"}),e("button",{onClick:x,className:"px-3 py-1.5 text-xs bg-error text-white rounded hover:bg-error/90 transition-colors flex items-center",disabled:p,children:p?"Deleting...":"Delete"})]})]})}),document.body)}function et({isFolder:t,renameValue:r,originalPath:l,displayName:c,error:p,isLoading:f,onChange:x,onCancel:h,onSubmit:v}){return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:v,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-3 text-sm",children:["Rename ",t?"Folder":"File"]}),e("input",{autoFocus:!0,type:"text",value:r,onChange:(g)=>x(g.currentTarget.value),"aria-label":`Rename ${t?"folder":"file"} path`,className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none mb-1 ${p?"border-error":"border-ink/20 focus:border-ink"}`}),e("p",{className:"text-[10px] text-ink/40 mb-2",children:["Paths are relative to the tree — ",e("span",{className:"font-mono",children:"lib/deep/name.ts"})," moves it too."]}),c&&e("p",{className:"text-[11px] text-ink/50 mb-2",children:["The row is ",e("span",{className:"font-mono",children:c}),"; this renames"," ",e("span",{className:"font-mono",children:l}),". Use"," ",e("span",{className:"font-mono",children:"Unfold Folders"})," to rename a folder inside the chain."]}),p&&e("p",{className:"text-[11px] text-error mb-2",children:p}),e("div",{className:"flex justify-end space-x-2",children:[e("button",{type:"button",onClick:h,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:f,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:f||!r.trim()||r===l,children:f?"Renaming...":"Rename"})]})]})}),document.body)}function nt({filePath:t,fetcherState:r,fetcherData:l,onClose:c}){let p=l?.type==="history"?l.data:void 0;return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("div",{className:"glass-overlay bg-paper rounded-lg shadow-xl w-full max-w-4xl border border-ink/10 flex flex-col max-h-[85vh]",children:[e("div",{className:"flex items-center justify-between p-4 border-b border-ink/10",children:[e("h3",{className:"text-sm font-semibold text-ink flex items-center space-x-2",children:[e(Qn,{size:16,className:"text-ink/60"}),e("span",{children:["Git History: ",e("span",{className:"font-mono font-normal opacity-80",children:t})]})]}),e("button",{onClick:c,className:"p-1 hover:bg-ink/5 rounded text-ink/60 transition-colors",children:e(b,{size:14})})]}),e("div",{className:"flex-1 scrollbar-overlay-container p-2",children:r==="idle"?p?p.length>0?e("table",{className:"w-full text-left border-collapse text-[11px]",children:[e("thead",{className:"bg-canvas sticky top-0 z-10 border-b border-ink/10",children:e("tr",{children:[e("th",{className:"px-3 py-2 font-semibold text-ink/70 rounded-tl",children:"Description"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-32",children:"Date"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-32",children:"Author"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-24 text-right rounded-tr",children:"Commit"})]})}),e("tbody",{className:"divide-y divide-ink/5",children:p.map((f,x)=>e("tr",{className:"hover:bg-ink/[0.03] transition-colors group",children:[e("td",{className:"px-3 py-2 text-ink",children:f.message?e("span",{className:"font-medium text-ink/90 group-hover:text-ink",children:f.message}):null}),e("td",{className:"px-3 py-2 text-ink/60 whitespace-nowrap font-mono text-[10.5px]",children:f.time}),e("td",{className:"px-3 py-2 text-ink/70 whitespace-nowrap truncate max-w-[120px]",children:f.author}),e("td",{className:"px-3 py-2 text-right",children:f.hash?e("span",{className:"font-mono text-ink/50 group-hover:text-ink font-semibold transition-colors bg-canvas px-1.5 py-0.5 rounded border border-ink/10",children:f.hash}):null})]},x))})]}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs",children:"No commit history found for this file."}):l?.error?e("div",{className:"p-8 text-center text-error font-mono text-xs",children:l.error}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs",children:"Loading history..."}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs flex items-center justify-center space-x-2",children:[e(D,{size:14,className:"animate-spin"}),e("span",{children:"Loading history..."})]})})]})}),document.body)}function rt({actions:t,file:r,isFolder:l,chainLabel:c}){let p=t.selectionCount;return e(d,{children:[t.showCreateModal&&e(Fe,{folderPath:r.path,kind:t.createKind,value:t.createName,error:t.createError,isLoading:t.busy,onChange:t.setCreateName,onCancel:t.closeCreate,onSubmit:t.submitCreate}),t.showDeleteModal&&e(Ze,{fileName:r.path,displayName:p>1?void 0:c,isFolder:l,count:p,isLoading:t.busy,onCancel:t.closeDelete,onConfirm:t.submitDelete}),t.showRenameModal&&e(et,{isFolder:l,renameValue:t.renameValue,originalPath:r.path,displayName:l?c:void 0,error:t.renameError,isLoading:t.busy,onChange:t.setRenameValue,onCancel:t.closeRename,onSubmit:t.submitRename}),t.showHistoryModal&&e(nt,{filePath:r.path,fetcherState:t.fetcherState,fetcherData:t.fetcherData,onClose:t.closeHistory})]})}function Ae(t){let r=t.map(an);return r.some((l,c)=>l!==t[c])?r:t}function an(t){if(t.type!=="folder"||!Array.isArray(t.children))return t;let r=Ae(t.children),l=r===t.children?t:{...t,children:r};while(Array.isArray(l.children)&&l.children.length===1){let c=l.children[0];if(c.type!=="folder")break;l={...l,name:`${l.name}/${c.name}`,path:c.path,children:c.children,ignored:c.ignored??l.ignored}}return l}function Se(t){return t.type==="folder"&&t.name.includes("/")}function Me(t,r){let l=r.split("/"),c=t.split("/");if(l.length<2||l.length>c.length||l.some((f)=>!f))return null;let p=c.slice(0,c.length-l.length);return l.map((f,x)=>[...p,...l.slice(0,x+1)].join("/"))}function ot(t,r){let l=new Map;if(r.size===0)return{nodes:t,roots:l};let c=!1,p=(x)=>x.flatMap((h)=>{if(h.type!=="folder")return[h];let v=Array.isArray(h.children)?p(h.children):h.children,g=v===h.children?h:{...h,children:v},m=r.has(h.path)?Me(h.path,h.name):null;if(!m)return[g];c=!0,l.set(m[0],h.path);let k={...g,name:m[m.length-1].split("/").pop()};for(let y=m.length-1;y>0;y-=1){let F=m[y-1];k={name:F.split("/").pop(),path:F,type:"folder",ignored:g.ignored,children:[k]}}return[k]}),f=p(t);return{nodes:c?f:t,roots:l}}function st(t,r){let l=new Set,c=(x)=>{for(let h of x){if(h.type!=="folder")continue;if(l.add(h.path),Array.isArray(h.children))c(h.children)}};c(t);let p=r.split("/").slice(0,-1),f=[];for(let x=0;x<p.length;x+=1){let h=p.slice(0,x+1).join("/");if(l.has(h))f.push(h)}return f}function Ne({folderPath:t,rootPath:r,repo:l,onCreated:c,onOpenCreated:p}){let f=ct(),[x,h]=n(!1),[v,g]=n("file"),[m,k]=n(""),[y,F]=n(null),A=i(null);return o(()=>{if(f.state!=="idle"||!f.data)return;let C=f.data;if(A.current===C)return;if(A.current=C,C.success&&C.path){let E=C.kind==="folder"?"folder":"file";h(!1),k(""),F(null);let R=C.path.split("/").pop()||C.path;if(c({path:C.path,name:R,kind:E}),E==="file")p?.({path:C.path,name:R})}else F(C.error||`Could not create the ${v}`)},[f.state,f.data]),{open:x,kind:v,name:m,setName:k,error:y,busy:f.state!=="idle",openDialog:(C="file")=>{g(C),k(""),F(null),h(!0)},closeDialog:()=>h(!1),submit:(C)=>{C.preventDefault();let E=m.trim();if(!E)return;F(null);let R=new FormData;if(R.append("actionType","create"),R.append("path",t),R.append("name",E),v==="folder")R.append("kind","folder");if(l&&l!==".")R.append("repo",l);if(r)R.append("root",r);f.submit(R,{method:"post",action:"/api/fs/action"})}}}function we(t){if(!t)return null;if(t.entries.length===1)return t.entries[0].name;return`${t.entries.length} items`}function at(t,r){return`${t??""}\x00${r}`}function Le(t,r){if(r==="folder")return t;let l=t.lastIndexOf("/");return l===-1?".":t.slice(0,l)}function dt(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)}function pt(t,r){if(t.path===""||t.path===".")return"The workspace root cannot be moved or copied";if(t.kind==="folder"&&(r===t.path||r.startsWith(`${t.path}/`)))return"Cannot paste a folder into itself";return null}function ut(t,r){let l=pt(t,r);if(l)return l;if(r===dt(t.path))return"Already in this folder";return null}function ft(t,r,l){if(!t||t.entries.length===0)return"Nothing to paste";if(t.scope!==r)return"The clipboard holds an entry from another workspace";if(t.mode==="cut"&&t.entries.some((c)=>l===dt(c.path)))return"Already in this folder";for(let c of t.entries){let p=pt(c,l);if(p)return p}return null}function mt(t){if(typeof t!=="object"||t===null)return null;let r=t;if(typeof r.scope!=="string")return null;if(r.mode!=="copy"&&r.mode!=="cut")return null;let l=Array.isArray(r.entries)?r.entries:typeof r.path==="string"?[{path:r.path,name:r.name,kind:r.kind}]:[],c=[];for(let p of l){let f=ln(p);if(!f)return null;c.push(f)}if(c.length===0)return null;return{scope:r.scope,entries:c,mode:r.mode}}function ln(t){if(typeof t!=="object"||t===null)return null;let r=t;if(typeof r.path!=="string"||typeof r.name!=="string")return null;if(r.kind!=="file"&&r.kind!=="folder")return null;let l=r.path.split("/");if(r.path===""||r.path.startsWith("/")||l.some((c)=>c===""||c==="."||c===".."))return null;return{path:r.path,name:r.name,kind:r.kind}}var $e=[{id:"zip",label:"ZIP",extension:"zip"},{id:"7z",label:"7Z",extension:"7z"},{id:"rar",label:"RAR",extension:"rar"},{id:"tar",label:"TAR",extension:"tar"},{id:"tar.gz",label:"TAR.GZ",extension:"tar.gz"}],gt=[[".tar.gz","tar.gz"],[".tar.bz2","tar.bz2"],[".tar.xz","tar.xz"],[".tgz","tar.gz"],[".tbz2","tar.bz2"],[".txz","tar.xz"],[".tar","tar"],[".zip","zip"],[".7z","7z"],[".rar","rar"],[".gz","gz"],[".bz2","bz2"],[".xz","xz"]];function ze(t){let r=t.toLowerCase();for(let[l,c]of gt)if(r.endsWith(l))return c;return null}function bt(t){return ze(t)!==null}function cn(t){return $e.find((r)=>r.id===t)}function dn(t){return cn(t)?.extension??"zip"}function xt(t){let r=t.toLowerCase();for(let[l]of gt)if(r.endsWith(l))return t.slice(0,-l.length);return t}function vt(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)||"."}function yt(t){let r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}function Ct(t){if(t.length===0)return".";let r=t.map((c)=>vt(c).split("/").filter((p)=>p!==".")),l=r[0]??[];for(let c of r.slice(1)){let p=0;while(p<l.length&&p<c.length&&l[p]===c[p])p+=1;l=l.slice(0,p)}return l.length===0?".":l.join("/")}function De(t,r){let l=dn(r);if(t.length===1){let f=t[0],x=xt(f.name),h=x.lastIndexOf(".");return`${(f.kind==="folder"?f.name:h>0?x.slice(0,h):x)||"archive"}.${l}`}let c=Ct(t.map((f)=>f.path)),p=yt(c);return`${p==="."||p===""?"archive":p}.${l}`}function Ft(t){return Ct(t.map((r)=>r.path))}function Nt(t){let r=vt(t),l=xt(yt(t));if(!l)return r;return r==="."?l:`${r}/${l}`}function wt(t){return t.toUpperCase()}function Dt({file:t,diff:r,onOpenFile:l,onActionComplete:c,onCreated:p,onRenamed:f,onUnfold:x,onFold:h,clipboard:v,isFolder:g,selection:m,selected:k,archive:y}){let F=ct(),[A,C]=n(null),E=i(null),[R,N]=n(!1),[T,H]=n(!1),[W,ee]=n(!1),[te,ae]=n(t.path),[G,I]=n(null),{repo:z,rootPath:K}=t,j=Ne({folderPath:t.path,rootPath:K,repo:z,onCreated:(M)=>p?p(M):c(),onOpenCreated:(M)=>l?.({...M,root:K,repo:z||"."})}),ne=i(null);o(()=>{if(F.state!=="idle"||!F.data)return;let M=F.data;if(ne.current===M)return;if(ne.current=M,M.success&&!M.type)if(N(!1),H(!1),I(null),M.previousPath&&M.path&&f)f(M.previousPath,M.path);else c();else if(!M.success&&M.error&&R)I(M.error)},[F.state,F.data]);let q=(M)=>{if(z&&z!==".")M.append("repo",z);if(K)M.append("root",K);F.submit(M,{method:"post",action:"/api/fs/action"})},X=()=>{l?.({path:t.path,name:t.name,root:K,repo:z||"."})},J={path:t.path,name:t.name,kind:g?"folder":"file"},se=k&&m.length>1?m:[J],he=bt(t.name),Q=v.clip&&!v.refusalFor(J)?`Paste ${we(v.clip)??"item"}`:null,fe=(M)=>{if(C(null),I(null),M==="view")X();else if(M==="diff")window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.path,staged:r?.staged,status:r?.status||"M",repo:z||".",root:K}}));else if(M==="explorer"){let _=new FormData;_.append("actionType","open_explorer"),_.append("path",t.path),q(_)}else if(M==="copy_path")kt(Wu(t.basePath,t.path));else if(M==="copy_relative")kt(t.path);else if(M==="history"){ee(!0);let _=new FormData;_.append("actionType","git_history"),_.append("path",t.path),q(_)}else if(M==="rename")ae(t.path),N(!0);else if(M==="unfold")x?.();else if(M==="fold")h?.();else if(M==="new_file")j.openDialog("file");else if(M==="new_folder")j.openDialog("folder");else if(M==="delete")H(!0);else if(M==="cut")v.cut(se);else if(M==="copy")v.copy(se);else if(M==="compress")y.openCompress(se);else if(M==="extract")y.openExtract(J);else if(M==="duplicate")v.duplicate(J);else if(M==="paste")v.paste(J)},le=(M)=>{M.preventDefault(),I(null);let _=new FormData;_.append("actionType","rename"),_.append("path",t.path),_.append("newPath",te),q(_)},xe=()=>{let M=new FormData;if(M.append("actionType","delete"),se.length>1)M.append("paths",JSON.stringify(se.map((_)=>_.path)));else M.append("path",t.path);q(M)};return{contextMenu:A,contextMenuRef:E,openContextMenu:(M,_)=>C({x:M,y:_}),closeContextMenu:()=>C(null),showRenameModal:R,showDeleteModal:T,showHistoryModal:W,showCreateModal:j.open,createKind:j.kind,createError:j.error,createName:j.name,setCreateName:j.setName,renameValue:te,setRenameValue:ae,renameError:G,busy:F.state!=="idle"||j.busy||v.busy||y.busy,pasteLabel:Q,selectionCount:se.length,isArchive:he,chainLabel:x!==void 0,foldable:h!==void 0,fetcherState:F.state,fetcherData:F.data,handleAction:fe,submitCreate:j.submit,submitRename:le,submitDelete:xe,closeCreate:j.closeDialog,closeDelete:()=>H(!1),closeRename:()=>N(!1),closeHistory:()=>ee(!1)}}function Rt({target:t,dragging:r,clipboard:l,onDragStart:c,onDragEnd:p,onDropOn:f,onHoverAccept:x}){let h=r?.path===t.path,v=Boolean(r)&&!h&&l.moveRefusalFor(r,t)===null,[g,m]=n(!1);return o(()=>{if(!r)m(!1)},[r]),{isDragging:h,acceptsDrop:v,isDropHovered:g&&v,onDragStart:(y)=>{if(y.dataTransfer?.setData("text/plain",t.path),y.dataTransfer)y.dataTransfer.effectAllowed="move";c(t)},onDragEnd:p,onDragOver:(y)=>{if(!r)return;if(y.stopPropagation(),m(v),!v)return;if(y.preventDefault(),y.dataTransfer)y.dataTransfer.dropEffect="move";x?.(t)},onDragLeave:()=>m(!1),onDrop:(y)=>{if(!r)return;if(y.stopPropagation(),!v)return;y.preventDefault(),f(t)}}}function pn(t,r,l){if(r||l)return!1;return!Array.isArray(t.children)}function Oe({file:t,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:x,onCreated:h,onRenamed:v,expandedPaths:g,onToggleFolder:m,gitFileMap:k,gitFolderMap:y,clipboard:F,archive:A,selection:C,selectionTargets:E,dragging:R,onDragStart:N,onDragEnd:T,onDropOn:H,onUnfold:W,onFold:ee,foldRoots:te,touch:ae=!1}){let G=t.type==="folder",[I,z]=n(!1),[K,j]=n(!1),[ne,q]=n(!1),[X,J]=n(!1),se=Array.isArray(t.children)?t.children:[],he=(t.path||"").replace(/^\/+/,""),Q=!G?k?.get(he)||k?.get(t.path):void 0,fe=Q?Kn(Q.status,Q.staged):null,le=G?y?.get(he)||y?.get(t.path):null,xe=Boolean(fe),M=t.ignored===!0,_=g?g.has(t.path):I,ce=t.forceExpanded!==void 0?t.forceExpanded:_;o(()=>{J(!0)},[]),o(()=>{if(G&&g)z(g.has(t.path))},[g,t.path,G]),o(()=>{if(G&&ce&&pn(t,K,ne)&&p)q(!0),j(!0),Promise.resolve(p(t.path)).finally(()=>j(!1))},[G,ce,t.children,t.path,p,K,ne]);let ye={path:t.path,name:t.name,kind:G?"folder":"file"},be=C.selected.has(t.path),U=Dt({file:{path:t.path,name:t.name,basePath:l,rootPath:r,repo:c},selection:E,selected:be,archive:A,diff:{staged:Q?.staged||(Q?.status?Q.status[0]!==" "&&Q.status[0]!=="?":!1),status:fe?.charStatus},onOpenFile:f,onActionComplete:x,onCreated:h,onRenamed:v,onUnfold:W&&Se({type:G?"folder":"file",name:t.name})?()=>W(ye):void 0,onFold:ee&&te?.has(t.path)?()=>ee(te.get(t.path)):void 0,clipboard:F,isFolder:G});pe(U.contextMenuRef,U.closeContextMenu);let Y=$u({enabled:ae,onLongPress:(V,ge)=>U.openContextMenu(V,ge)}),ke=(V)=>{if(V.stopPropagation(),Y.consume())return;let ge=C.gestureOf(V);if(ge!=="plain"){C.applyGesture(ge,t.path);return}if(C.applyGesture("plain",t.path),G){let ue=!ce;if(z(ue),t.forceExpanded!==void 0)t.forceExpanded=void 0;if(m?.(t.path,ue),!ue)q(!1)}else if(f)f({...t,root:r,repo:c||"."})},ve=(V)=>{V.preventDefault(),V.stopPropagation(),C.ensureForContext(t.path),U.openContextMenu(V.clientX,V.clientY)},de=Rt({target:ye,dragging:R,clipboard:F,onDragStart:N,onDragEnd:T,onDropOn:H,onHoverAccept:W});return e("div",{children:[e("div",{className:`flex items-center space-x-1.5 py-1 px-2 cursor-pointer rounded group select-none ${de.isDragging?"opacity-40":""} ${de.isDropHovered?"bg-info/10 ring-1 ring-info/40 ring-inset":be?"bg-ink/[0.08] ring-1 ring-ink/20 ring-inset":"hover:bg-ink/5"}`,draggable:!ae,onClick:ke,onContextMenu:ve,onDragStart:de.onDragStart,onDragEnd:de.onDragEnd,onDragOver:de.onDragOver,onDragLeave:de.onDragLeave,onDrop:de.onDrop,onTouchStart:Y.onTouchStart,onTouchMove:Y.onTouchMove,onTouchEnd:Y.onTouchEnd,onTouchCancel:Y.onTouchCancel,children:e(Ye,{name:t.name,path:t.path,isFolder:G,isOpen:ce,ignored:M,selected:be,gitStatus:fe,folderStatus:le})}),ce&&K&&e("div",{className:"ml-3 border-l border-ink/10 pl-3 py-0.5 text-[10px] text-ink/30",children:"Loading…"}),ce&&!K&&se.length>0&&e("div",{className:"ml-3 border-l border-ink/10 pl-1",children:se.map((V)=>e(Oe,{file:V,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:x,onCreated:h,onRenamed:v,expandedPaths:g,onToggleFolder:m,gitFileMap:k,gitFolderMap:y,clipboard:F,archive:A,selection:C,selectionTargets:E,dragging:R,onDragStart:N,onDragEnd:T,onDropOn:H,onUnfold:W,onFold:ee,foldRoots:te,touch:ae},V.path))}),X&&U.contextMenu&&e(Je,{x:U.contextMenu.x,y:U.contextMenu.y,isFolder:G,hasGitStatus:xe,pasteLabel:U.pasteLabel,chainLabel:U.chainLabel,foldable:U.foldable,busy:U.busy,selectionCount:U.selectionCount,isArchive:U.isArchive,onAction:U.handleAction}),X&&e(rt,{actions:U,file:t,isFolder:G,chainLabel:Se({type:G?"folder":"file",name:t.name})?t.name:void 0})]})}function Tt({x:t,y:r,pasteLabel:l,busy:c,onAction:p,menuRef:f}){let h=l?104:76,v=typeof window<"u"?Math.max(10,Math.min(t,window.innerWidth-190-12)):t,g=typeof window<"u"?Math.max(10,Math.min(r,window.innerHeight-h-12)):r;return oe(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>p("close"),onContextMenu:(m)=>{m.preventDefault(),p("close")},children:e("div",{ref:f,className:"glass-popover fixed z-50 bg-paper border border-ink/15 shadow-2xl rounded-lg py-1 min-w-[185px] text-xs text-ink font-sans",style:{top:g,left:v},onClick:(m)=>m.stopPropagation(),children:[e("button",{type:"button",onClick:()=>p("new_file"),className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 flex items-center space-x-2 transition-colors",children:[e(ai,{size:13,className:"text-ink/60"}),e("span",{children:"New File"})]}),e("button",{type:"button",onClick:()=>p("new_folder"),className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 flex items-center space-x-2 transition-colors",children:[e(sn,{size:13,className:"text-ink/60"}),e("span",{children:"New Folder"})]}),l&&e("button",{type:"button",disabled:c,onClick:()=>p("paste"),className:`w-full text-left px-3 py-1.5 flex items-center space-x-2 transition-colors ${c?"opacity-40 cursor-default":"hover:bg-ink/5"}`,children:[e(vo,{size:13,className:"text-ink/60"}),e("span",{children:l})]})]})}),document.body)}function At({menu:t,menuRef:r,pasteLabel:l,busy:c,onAction:p,create:f}){return e(d,{children:[t&&e(Tt,{x:t.x,y:t.y,menuRef:r,pasteLabel:l,busy:c,onAction:p}),f.open&&e(Fe,{folderPath:".",kind:f.kind,value:f.name,error:f.error,isLoading:f.busy,onChange:f.setName,onCancel:f.closeDialog,onSubmit:f.submit})]})}function St({title:t,subject:r,error:l,busy:c,submitLabel:p,busyLabel:f,onSubmit:x,onCancel:h,children:v}){return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:x,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-1 text-sm",children:t}),e("p",{className:"text-[11px] text-ink/50 mb-3 break-words",children:r}),v,l&&e("p",{className:"text-[11px] text-error mb-2",children:l}),e("div",{className:"flex justify-end space-x-2 mt-3",children:[e("button",{type:"button",onClick:h,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:c,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:c,children:c?f:p})]})]})}),document.body)}function un({entries:t,format:r,name:l,destination:c,formats:p,error:f,busy:x,onFormatChange:h,onNameChange:v,onDestinationChange:g,onCancel:m,onSubmit:k}){let y=t.slice(0,4).map((A)=>A.name).join(", "),F=t.length>4?` +${t.length-4} more`:"";return e(St,{title:`Compress ${t.length===1?t[0].name:`${t.length} items`}`,subject:`${y}${F}`,error:f,busy:x,submitLabel:"Compress",busyLabel:"Compressing...",onCancel:m,onSubmit:(A)=>{A.preventDefault(),k()},children:[e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"archive-format",children:"Format"}),e("select",{id:"archive-format",value:r,onChange:(A)=>h(A.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 text-xs font-mono focus:outline-none focus:border-ink mb-3",children:p.map((A)=>e("option",{value:A.id,disabled:!A.available,children:[A.label,A.available?"":` — ${A.tool} not installed`]},A.id))}),e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"archive-name",children:"Archive name"}),e("input",{id:"archive-name",autoFocus:!0,type:"text",value:l,onChange:(A)=>v(A.currentTarget.value),"aria-label":"Archive name",className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none mb-3 ${f?"border-error":"border-ink/20 focus:border-ink"}`}),e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"archive-destination",children:"Destination folder"}),e("input",{id:"archive-destination",type:"text",value:c,onChange:(A)=>g(A.currentTarget.value),"aria-label":"Archive destination",className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 text-xs font-mono focus:outline-none focus:border-ink"})]})}function fn({archive:t,kindLabel:r,destination:l,error:c,busy:p,onDestinationChange:f,onCancel:x,onSubmit:h}){return e(St,{title:`Extract ${t.name}`,subject:`${r} archive · extracts into a folder`,error:c,busy:p,submitLabel:"Extract",busyLabel:"Extracting...",onCancel:x,onSubmit:(v)=>{v.preventDefault(),h()},children:[e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"extract-destination",children:"Extract to folder"}),e("input",{id:"extract-destination",autoFocus:!0,type:"text",value:l,onChange:(v)=>f(v.currentTarget.value),"aria-label":"Extract destination",className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none ${c?"border-error":"border-ink/20 focus:border-ink"}`})]})}function Et({archive:t}){if(t.compress)return e(un,{entries:t.compress.entries,format:t.compress.format,name:t.compress.name,destination:t.compress.destination,formats:t.formats,error:t.error,busy:t.busy,onFormatChange:t.setFormat,onNameChange:t.setName,onDestinationChange:t.setCompressDestination,onCancel:t.cancel,onSubmit:t.submitCompress});if(t.extract)return e(fn,{archive:t.extract.archive,kindLabel:wt(ze(t.extract.archive.name)??"zip"),destination:t.extract.destination,error:t.error,busy:t.busy,onDestinationChange:t.setExtractDestination,onCancel:t.cancel,onSubmit:t.submitExtract});return null}function Mt(){let[t,r]=S("files.outlineExpanded",!1),l=yr(),c=Ue(pA,dA),{symbols:p,total:f,truncated:x,notice:h}=Gu({content:c.content,language:c.language,state:c.state,note:c.note,path:c.path});if(c.state==="diff")return null;let v=c.preview,g=(m,k)=>{if(!c.path)return;if(v){let y=Ku(p,k);if(y)Zi({path:c.path,...y});return}Ji({path:c.path,line:m.line,column:m.column,length:m.name.length})};return e("div",{className:"border-t border-ink/10 bg-canvas/30 flex-shrink-0",children:[e("div",{className:"flex items-center hover:bg-ink/5 transition-colors",children:e("button",{type:"button",onClick:()=>r(!t),"aria-expanded":t,"aria-controls":l,"aria-label":"Outline",title:t?"Hide outline":"Show outline",className:"flex flex-1 min-w-0 items-center space-x-1 py-1.5 pl-3 pr-2 text-left font-semibold text-xs text-ink transition-colors cursor-pointer",children:[e("span",{className:"w-3 text-center font-mono","aria-hidden":"true",children:t?"▾":"▸"}),e(Kr,{size:12}),e("span",{children:"Outline"}),f>0&&e("span",{className:"font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[10px] text-ink/50",children:x?`${p.length}/${f.toLocaleString()}`:f})]})}),e("div",{className:"section-reveal","data-expanded":t,id:l,inert:!t,children:e("div",{children:e("div",{className:"px-2 pb-2",children:p.length===0?e("div",{className:"px-1 text-[10px] text-ink/40 italic py-1",children:h}):e("div",{className:"max-h-48 overflow-y-auto scrollbar-overlay-container flex flex-col",children:[p.map((m,k)=>e("button",{type:"button",onClick:()=>g(m,k),"aria-label":v?`${Zo(m.kind)} ${m.name}`:`${Zo(m.kind)} ${m.name}, line ${m.line}`,title:v?`Jump to ${Zo(m.kind).toLowerCase()}`:`${Zo(m.kind)} · line ${m.line}`,className:"flex w-full min-w-0 items-center gap-1.5 rounded px-1 py-0.5 text-left transition-colors hover:bg-ink/5 active:bg-ink/10",style:{paddingLeft:`${4+m.depth*12}px`},children:[e(zu,{kind:m.kind}),e("span",{className:"min-w-0 flex-1 truncate text-[11px] font-mono text-ink/80",children:m.name}),!v&&e("span",{className:"flex-shrink-0 font-mono text-[10px] text-ink/35",children:m.line})]},`${m.line}:${m.kind}:${m.name}`)),x&&e("div",{className:"px-1 py-1 text-[10px] italic text-ink/40",children:Uu(f)})]})})})})]})}function Pe(t,r){return Ae(t.map((l)=>mn(l,r)))}function mn(t,r){if(t.type!=="folder")return t;let l=r[t.path];if(!l)return t;return{...t,children:Pe(l,r)}}function hn(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)}function $t(t){let r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}function Lt(t){return[...t].sort((r,l)=>{if(r.type!==l.type)return r.type==="folder"?-1:1;return r.name.localeCompare(l.name)})}function Ie(t,r,l){let c=l.path.split("/"),p=c.slice(0,-1).join("/"),f=[...t],x={...r},h=f,v=null;for(let g=0;g<c.length-1;){let m=c.slice(0,g+1).join("/"),k=h.find((E)=>E.type==="folder"&&E.path===m),y=k?null:h.find((E)=>E.type==="folder"&&E.path.startsWith(`${m}/`)&&(p===E.path||p.startsWith(`${E.path}/`))),F=k??y,A=F?x[F.path]??F.children:null;if(F&&!Array.isArray(A))return{nodes:t,cache:r};if(!F){let E=gn(h,x,m);if(E){h=E;let R=h.find((T)=>T.path===m),N=Array.isArray(R?.children)?[...R.children]:[];x[m]=N,h=N,v=m,g+=1;continue}}let C=Array.isArray(A)?[...A]:[];if(F){x[F.path]=C,h=C,v=F.path,g=F.path.split("/").length;continue}h.push({name:c[g],path:m,type:"folder",ignored:!1}),x[m]=C,h=C,v=m,g+=1}if(h.push(l),v!==null)x[v]=Lt(h);return f=Lt(f),{nodes:f,cache:x}}function gn(t,r,l){let c=t.findIndex((v)=>v.type==="folder"&&v.path.startsWith(`${l}/`));if(c===-1)return null;let p=t[c],f=p.path.slice(l.length+1).split("/"),x=r[p.path]??p.children;if(Array.isArray(x))r[p.path]=x;let h={name:f[f.length-1],path:p.path,type:"folder",ignored:p.ignored,...Array.isArray(x)?{children:x}:{}};for(let v=f.length-2;v>=0;v-=1)h={name:f[v],path:`${l}/${f.slice(0,v+1).join("/")}`,type:"folder",ignored:!1,children:[h]};return t[c]={name:$t(l),path:l,type:"folder",ignored:!1,children:[h]},t}function zt(t,r,l){let c=t.find((m)=>m.path===l);if(c)return{entry:c,nodes:t.filter((m)=>m.path!==l),cache:r};let p=hn(l),f=r[p],x=f?.find((m)=>m.path===l);if(f&&x)return{entry:x,nodes:t,cache:{...r,[p]:f.filter((m)=>m.path!==l)}};let v=Object.keys(r).filter((m)=>l.startsWith(`${m}/`)&&r[m].some((k)=>k.path===l)).sort((m,k)=>k.length-m.length)[0];if(!v)return{entry:null,nodes:t,cache:r};let g=r[v];return{entry:g.find((m)=>m.path===l),nodes:t,cache:{...r,[v]:g.filter((m)=>m.path!==l)}}}function Ot(t,r,l){let c=!1,p=t.map((f)=>{let x=f.path===r||f.path.startsWith(`${r}/`),h=Array.isArray(f.children)?Ot(f.children,r,l):void 0;if(!x&&h===f.children)return f;c=!0;let v=x?f.path===r?l:`${l}${f.path.slice(r.length)}`:f.path,g=x?{...f,path:v,name:$t(v)}:{...f};if(h!==void 0)g.children=h;return g});return c?p:t}function Pt(t,r,l){let c={};for(let[p,f]of Object.entries(t)){let x=p===r?l:p.startsWith(`${r}/`)?`${l}${p.slice(r.length)}`:p;c[x]=x===p?f:Ot(f,r,l)}return c}function It(t,r,l){let c=new Set;for(let p of t)if(p===r)c.add(l);else if(p.startsWith(`${r}/`))c.add(`${l}${p.slice(r.length)}`);else c.add(p);return c}function Ht(t){if(!w(t))return{status:"missing"};if(typeof t.root!=="string"||t.root==="")return{status:"missing"};return{status:"ok",files:Array.isArray(t.files)?t.files.filter((r)=>w(r)):[],root:t.root}}async function He(t){try{return Ht(await(await fetch(t)).json())}catch{return{status:"failed"}}}function Gt({enabled:t,rootPath:r,activeRepo:l,expandedPaths:c,onExpansionPruned:p}){let f=`${r??""}\x00${l}`,[x,h]=n({scope:"",files:[],root:""}),[v,g]=n(!1),m=i({}),k=i([]),y=i(f);y.current=f;let F=i(""),A=i(""),C=i(c);C.current=c;let E=(I)=>{let z=new URLSearchParams;if(r)z.set("root",r);if(l&&l!==".")z.set("repo",l);if(I)z.set("path",I);return z.set("t",String(Date.now())),`/api/fs/dir?${z.toString()}`},R=(I,z)=>{F.current=I,A.current=z;let K=Pe(k.current,m.current);return h({scope:I,files:K,root:z}),K},N=async(I)=>{let z=[...C.current];if(z.length===0)return;let K=await Promise.all(z.map(async(X)=>({path:X,read:await He(E(X))})));if(y.current!==I)return;let j=[];for(let{path:X,read:J}of K)if(J.status==="ok")m.current[X]=J.files;else if(J.status==="missing")j.push(X);if(j.length===0)return;let ne=new Set(j);for(let X of j)delete m.current[X];let q=new Set([...C.current].filter((X)=>!ne.has(X)));C.current=q,p(q)},T=async()=>{if(!t)return;let I=y.current;g(!0);try{let z=await He(E());if(y.current!==I)return;if(z.status!=="ok")return;if(F.current!==I)m.current={};if(k.current=z.files,R(I,z.root),await N(I),y.current!==I)return;R(I,z.root)}finally{if(y.current===I)g(!1)}},H=async(I)=>{let z=y.current,K=await He(E(I));if(y.current!==z||K.status!=="ok")return;if(m.current[I]=K.files,F.current===z)R(z,A.current)},W=(I)=>{let z=Ht(I);if(z.status!=="ok")return;let K=y.current;if(F.current!==K)m.current={};k.current=z.files,R(K,z.root),N(K).then(()=>{if(y.current===K)R(K,z.root)})},ee=()=>{m.current={},k.current=[],F.current="",A.current="",h({scope:"",files:[],root:""})},te=(I)=>{let z=y.current;if(F.current!==z)return null;let K={name:I.path.slice(I.path.lastIndexOf("/")+1),path:I.path,type:I.kind,ignored:!1},j=Ie(k.current,m.current,K);if(j.nodes===k.current)return null;return k.current=j.nodes,m.current=j.cache,R(z,A.current)},ae=(I,z)=>{let K=y.current;if(F.current!==K)return null;let j=zt(k.current,m.current,I);if(!j.entry)return null;m.current=Pt(j.cache,I,z);let ne={...j.entry,path:z,name:z.slice(z.lastIndexOf("/")+1)},q=Ie(j.nodes,m.current,ne);return k.current=q.nodes,m.current=q.cache,R(K,A.current)},G=x.scope===f;return{scope:f,files:G?x.files:[],root:G?x.root:"",isLoading:v,reload:T,loadChildren:H,adoptRoot:W,insertEntry:te,moveEntry:ae,reset:ee}}function Kt({rootPath:t,repo:r,onComplete:l,onError:c}){let p=ct(),[f,x]=S("files.clipboard",null),h=mt(f),v=at(t,r),g=i(!1),m=i(null);o(()=>{if(p.state!=="idle"||!p.data)return;let C=p.data;if(m.current===C)return;m.current=C;let E=g.current;if(g.current=!1,C.success){if(E)x(null);if(C.failures?.length)c(`${C.failures.length} item(s) could not be moved: ${C.failures[0].error}`);l()}else c(C.error||"The transfer did not complete")},[p.state,p.data]);let k=a((C,E)=>{g.current=E;let R=new FormData;for(let[N,T]of Object.entries(C))R.append(N,T);if(r&&r!==".")R.append("repo",r);if(t)R.append("root",t);p.submit(R,{method:"post",action:"/api/fs/action"})},[p,r,t]),y=a((C)=>ft(h,v,Le(C.path,C.kind)),[h,v]),F=a((C,E)=>ut(C,Le(E.path,E.kind)),[]),A=a((C,E,R,N)=>{let T=new FormData;T.append("actionType","paste"),T.append("mode",R),T.append("targetPath",E.path),T.append("targetKind",E.kind);for(let H of C)T.append("sourcePath",H.path);if(r&&r!==".")T.append("repo",r);if(t)T.append("root",t);g.current=N,p.submit(T,{method:"post",action:"/api/fs/action"})},[p,r,t]);return{clip:h,busy:p.state!=="idle",refusalFor:y,moveRefusalFor:F,copy:(C)=>{if(C.length===0)return;x({scope:v,entries:C.map(({path:E,name:R,kind:N})=>({path:E,name:R,kind:N})),mode:"copy"})},cut:(C)=>{if(C.length===0)return;x({scope:v,entries:C.map(({path:E,name:R,kind:N})=>({path:E,name:R,kind:N})),mode:"cut"})},duplicate:(C)=>{k({actionType:"duplicate",path:C.path},!1)},move:(C,E)=>{let R=F(C,E);if(R){c(R);return}A([C],E,"cut",Boolean(h?.mode==="cut"&&h.entries.some((N)=>N.path===C.path)))},paste:(C)=>{if(!h)return;let E=y(C);if(E){c(E);return}A(h.entries.map(({path:R,name:N,kind:T})=>({path:R,name:N,kind:T})),C,h.mode,h.mode==="cut")}}}var bn=$e.map((t)=>({...t,available:!0,tool:t.id}));function jt({rootPath:t,repo:r,onComplete:l}){let c=ct(),[p,f]=n(bn),[x,h]=n(null),[v,g]=n(null),[m,k]=n(null),y=i(null),F=i(null);o(()=>{let N=!1;return(async()=>{try{let H=await(await fetch("/api/fs/archive")).json();if(!N&&Array.isArray(H.formats)&&H.formats.length>0)f(H.formats)}catch{}})(),()=>{N=!0}},[]),o(()=>{if(c.state!=="idle"||!c.data)return;let N=c.data;if(F.current===N)return;F.current=N;let T=y.current;if(y.current=null,N.success){if(k(null),T==="compress")h(null);if(T==="extract")g(null);l()}else if(T)k(N.error||"The archive request failed")},[c.state,c.data]);let A=a((N)=>{let T=new FormData;for(let[H,W]of Object.entries(N))T.append(H,W);if(r&&r!==".")T.append("repo",r);if(t)T.append("root",t);c.submit(T,{method:"post",action:"/api/fs/action"})},[c,r,t]),C=a((N)=>{if(N.length===0)return;let T=p.find((H)=>H.id==="zip"&&H.available)?.id??p.find((H)=>H.available)?.id??"zip";k(null),g(null),h({entries:N.map(({path:H,name:W,kind:ee})=>({path:H,name:W,kind:ee})),format:T,name:De(N,T),destination:Ft(N)})},[p]),E=a((N)=>{k(null),h(null),g({archive:N,destination:Nt(N.path)})},[]),R=a((N)=>{h((T)=>{if(!T)return T;let H=De(T.entries,T.format),W=T.name===H?De(T.entries,N):T.name;return{...T,format:N,name:W}})},[]);return{formats:p,compress:x,extract:v,error:m,busy:c.state!=="idle",openCompress:C,openExtract:E,setFormat:R,setName:(N)=>h((T)=>T&&{...T,name:N}),setCompressDestination:(N)=>h((T)=>T&&{...T,destination:N}),setExtractDestination:(N)=>g((T)=>T&&{...T,destination:N}),cancel:()=>{h(null),g(null),k(null)},submitCompress:()=>{let N=x;if(!N)return;y.current="compress",k(null),A({actionType:"compress",format:N.format,name:N.name.trim(),destination:N.destination.trim()||".",paths:JSON.stringify(N.entries.map((T)=>T.path))})},submitExtract:()=>{let N=v;if(!N)return;y.current="extract",k(null),A({actionType:"extract",path:N.archive.path,destination:N.destination.trim()||"."})}}}function xn(t){if(t.shiftKey)return"range";if(t.metaKey||t.ctrlKey)return"toggle";return"plain"}function vn(t,r,l){if(!r)return[l];let c=t.indexOf(r),p=t.indexOf(l);if(c===-1||p===-1)return[l];let f=Math.min(c,p),x=Math.max(c,p);return t.slice(f,x+1)}function _t(t){let[r,l]=n(()=>new Set),[c,p]=n(null),f=a((g,m)=>{if(g==="range"){l(new Set(vn(t,c,m)));return}if(p(m),g==="toggle"){l((k)=>{let y=new Set(k);if(y.has(m))y.delete(m);else y.add(m);return y});return}l(new Set([m]))},[c,t]),x=a((g)=>{l((m)=>{if(m.has(g))return m;return new Set([g])}),p(g)},[]),h=a(()=>{l(new Set),p(null)},[]),v=a(xn,[]);return u(()=>({selected:r,count:r.size,anchor:c,gestureOf:v,applyGesture:f,ensureForContext:x,clear:h}),[r,c,v,f,x,h])}function Ge(t,r,l=0,c=[]){for(let p of t)if(c.push({path:p.path,name:p.name,kind:p.type==="folder"?"folder":"file",depth:l}),p.type==="folder"&&r(p)&&Array.isArray(p.children))Ge(p.children,r,l+1,c);return c}function Wt({listing:t,setExpandedPaths:r,setStoredExpandedPaths:l,reload:c,onMoved:p}){let f=a((v,g)=>{let m=st(g,v);if(m.length===0)return;r((k)=>{if(m.every((F)=>k.has(F)))return k;let y=new Set(k);for(let F of m)y.add(F);return l(Array.from(y)),y})},[r,l]),x=a((v)=>{let g=t.insertEntry(v);if(!g){c();return}f(v.path,g)},[t,c,f]),h=a((v,g)=>{p?.(v,g),r((k)=>{let y=It(k,v,g);return l(Array.from(y)),y});let m=t.moveEntry(v,g);if(!m){c();return}f(g,m)},[t,c,f,r,l,p]);return{insertCreated:x,moveRenamed:h}}var yn=new Set;function Ut({scope:t,setExpandedPaths:r,setStoredExpandedPaths:l}){let[c,p]=n({scope:t,chains:new Map}),f=a((v)=>{let g=Me(v.path,v.name);if(!g)return;p((k)=>{let y=k.scope===t?k.chains:new Map;if(y.get(v.path)?.length===g.length)return k;let A=new Map(y);return A.set(v.path,g),{scope:t,chains:A}});let m=g.slice(0,-1);r((k)=>{if(m.every((F)=>k.has(F)))return k;let y=new Set(k);for(let F of m)y.add(F);return l(Array.from(y)),y})},[t,r,l]),x=a((v)=>{let g=c.scope===t?c.chains.get(v):void 0;if(!g)return;let m=g.slice(0,-1);p((k)=>{if(k.scope!==t)return k;let y=new Map(k.chains);return y.delete(v),{scope:t,chains:y}}),r((k)=>{if(!m.some((F)=>k.has(F)))return k;let y=new Set(k);for(let F of m)y.delete(F);return l(Array.from(y)),y})},[t,c,r,l]),h=a((v,g)=>{let m=c.scope===t?c.chains:null;if(!m)return;let k=new Map,y=[],F=!1;for(let[A,C]of m){if(C.findIndex((T,H)=>T===v&&H>0&&H<C.length-1)!==-1){F=!0;continue}let R=C.map((T)=>T===v?g:T.startsWith(`${v}/`)?`${g}${T.slice(v.length)}`:T),N=R[R.length-1];if(N!==A||R.some((T,H)=>T!==C[H]))F=!0;k.set(N,R),y.push(...R.slice(0,-1))}if(!F)return;p({scope:t,chains:k}),r((A)=>{if(y.every((E)=>A.has(E)))return A;let C=new Set(A);for(let E of y)C.add(E);return l(Array.from(C)),C})},[t,c,r,l]);return{unfolded:c.scope===t&&c.chains.size>0?new Set(c.chains.keys()):yn,unfold:f,fold:x,rekey:h}}function Vt(t,r){let l=r.trim().toLowerCase();if(!l)return t;let c=(p)=>{let f=p.name.toLowerCase().includes(l);if(p.type==="folder"){let x=(p.children||[]).map(c).filter((h)=>h!==null);if(f||x.length>0)return{...p,children:f&&x.length===0?p.children:x,forceExpanded:!0};return null}return f?p:null};return t.map(c).filter((p)=>p!==null)}function Xt({dragging:t,clipboard:r,target:l}){let c=Boolean(t)&&r.moveRefusalFor(t,l)===null,[p,f]=n(!1);return o(()=>{if(!t)f(!1)},[t]),{accepts:c,highlighted:p&&c,onDragEnter:()=>{if(t)f(!0)},onDragLeave:(x)=>{if(!x.currentTarget.contains(x.relatedTarget))f(!1)},onDragOver:(x)=>{if(!c)return;if(x.preventDefault(),x.dataTransfer)x.dataTransfer.dropEffect="move"},onDrop:(x)=>{if(!c)return;x.preventDefault(),f(!1),r.move(t,l)}}}function ni({className:t="",enabled:r=!0,active:l=!0,rootPath:c,onOpenFile:p,refreshKey:f=0,onRefresh:x}){let[h,v]=S("files.searchQuery",""),[g,m,k]=S("files.expandedPaths",[]),[y,F]=n(()=>new Set(g)),{activeRepo:A,setActiveRepo:C}=cr(c),{repos:E,scanning:R,rescan:N}=ur(c,r),{fileMap:T,folderMap:H,refreshGitStatus:W}=zs(c,A,r),[ee,te]=n(null),ae=i(null);o(()=>{if(!k)return;F((P)=>{let Z=new Set(g);if(P.size===Z.size&&Array.from(Z).every((me)=>P.has(me)))return P;return Z})},[k,g]);let G=Gt({enabled:r,rootPath:c,activeRepo:A,expandedPaths:y,onExpansionPruned:(P)=>{F(P),m(Array.from(P))}});o(()=>{if(!k||!l)return;G.reload()},[f,c,r,A,k,l]);let I=r&&k?eA(G.scope):null,z=Ce(I);o(()=>{if(z.data)G.adoptRoot(z.data)},[z.data]);let K=(P)=>(W(),G.loadChildren(P)),j=(P,Z)=>{let me=new Set(y);if(Z)me.add(P);else me.delete(P);F(me),m(Array.from(me))},{unfolded:ne,unfold:q,fold:X,rekey:J}=Ut({scope:G.scope,setExpandedPaths:F,setStoredExpandedPaths:m}),se=G.files,he=ot(se,ne),Q=Vt(he.nodes,h),fe=Ge(Q,(P)=>P.forceExpanded!==void 0?P.forceExpanded:y.has(P.path)),le=_t(fe.map((P)=>P.path)),xe=fe.filter((P)=>le.selected.has(P.path)).map(({path:P,name:Z,kind:me})=>({path:P,name:Z,kind:me})),M=(P)=>{if(P===A)return;G.reset(),F(new Set),m([]),le.clear(),C(P)},_=()=>{if(W(),x)x();else G.reload()},{insertCreated:ce,moveRenamed:ye}=Wt({listing:G,setExpandedPaths:F,setStoredExpandedPaths:m,reload:_,onMoved:(P,Z)=>J(P,Z)}),be=es(),{pushToast:U}=je(),Y=Kt({rootPath:c,repo:A,onComplete:_,onError:(P)=>U(P,"error")}),ke=jt({rootPath:c,repo:A,onComplete:_}),ve={path:".",name:".",kind:"folder"},de=Y.clip&&!Y.refusalFor(ve)?`Paste ${we(Y.clip)??"item"}`:null,[V,ge]=n(null),ue=Xt({dragging:V,clipboard:Y,target:ve}),Re=Ne({folderPath:".",rootPath:c,repo:A,onCreated:ce,onOpenCreated:(P)=>p?.({...P,root:c,repo:A})}),[Ke,qt]=n(!1);o(()=>qt(!0),[]);let{count:_e,clear:We}=le;if(o(()=>{if(!l)return;let P=(Z)=>{if(Z.key==="Escape"&&_e>0)We()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[l,_e,We]),!r)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${t}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});let Bt=G.isLoading||z.refreshing;return e("div",{className:`flex flex-col h-full bg-paper ${t}`,children:[e(Qe,{rootPath:c,activeRepo:A,repos:E,reposScanning:R,onRefreshRepos:N,onSelectRepo:M,searchQuery:h,onSearchChange:v,onRefresh:_,refreshing:Bt}),e("div",{className:`flex-1 scrollbar-overlay-container p-2 font-mono text-[11px] text-ink/80 ${be?"file-tree-touch":""} ${ue.highlighted?"bg-info/[0.06]":""}`,onContextMenu:(P)=>{P.preventDefault(),te({x:P.clientX,y:P.clientY})},onDragEnter:ue.onDragEnter,onDragLeave:ue.onDragLeave,onDragOver:ue.onDragOver,onDrop:ue.onDrop,children:G.isLoading&&Q.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"Loading files..."}):Q.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"No files found"}):Q.map((P)=>e(Oe,{file:P,rootPath:c,basePath:G.root,repo:A,onLoadChildren:K,onOpenFile:p,onActionComplete:_,onCreated:ce,onRenamed:ye,expandedPaths:y,onToggleFolder:j,gitFileMap:T,gitFolderMap:H,clipboard:Y,archive:ke,selection:le,selectionTargets:xe,dragging:V,onDragStart:ge,onDragEnd:()=>ge(null),onDropOn:(Z)=>{if(!V)return;Y.move(V,Z)},onUnfold:q,onFold:X,foldRoots:he.roots,touch:be},P.path))}),e(Mt,{}),Ke&&e(At,{menu:ee,menuRef:ae,pasteLabel:de,busy:Y.busy,create:Re,onAction:(P)=>{if(te(null),P==="new_file")Re.openDialog("file");if(P==="new_folder")Re.openDialog("folder");if(P==="paste")Y.paste(ve)}}),Ke&&e(Et,{archive:ke})]})}export{ni as FileExplorer};