@kabmo-labs/kabmo 0.60.0 → 0.61.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/static/js/{Body-p82s28sj.js → Body-ab8wswhm.js} +1 -1
- package/dist/client/static/js/{CsvGrid-erc5mcvc.js → CsvGrid-czssywvz.js} +1 -1
- package/dist/client/static/js/{DocxView-x3faj0jv.js → DocxView-ke0dwdmt.js} +1 -1
- package/dist/client/static/js/{DrawioView-t7fh3ens.js → DrawioView-a1whhy84.js} +1 -1
- package/dist/client/static/js/{HtmlPreview-zy7x7jmm.js → HtmlPreview-dr32dwjy.js} +1 -1
- package/dist/client/static/js/{ImageView-xc90jc1c.js → ImageView-zf4kh5wp.js} +1 -1
- package/dist/client/static/js/{LayoutWrapper-wyqe98kf.js → LayoutWrapper-dncbzcea.js} +1 -1
- package/dist/client/static/js/MergeDiffView-btdx9yb9.js +1 -0
- package/dist/client/static/js/{Modal-89jk7wff.js → Modal-5cxfw2rv.js} +1 -1
- package/dist/client/static/js/{PdfView-kqx472q7.js → PdfView-2kdn91f9.js} +1 -1
- package/dist/client/static/js/{SessionsView-6bpz1faj.js → SessionsView-vbn0nvx4.js} +1 -1
- package/dist/client/static/js/{SheetView-0n9fze50.js → SheetView-ettr9pdw.js} +1 -1
- package/dist/client/static/js/{SvgPreview-6xc6ts46.js → SvgPreview-hzcejjry.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-2xdkkqwg.js → abnfDiagram-O67JEVCF-kdmv4y72.js} +1 -1
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-ja8cx19z.js → architectureDiagram-NJMV4G6O-qyrwaq0x.js} +1 -1
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-ytf7s99c.js → blockDiagram-BEXU5L5S-tszxy2g7.js} +1 -1
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-5a0kdx0z.js → c4Diagram-YGBWAQC7-0ye36hhv.js} +1 -1
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-hd98dvjw.js → classDiagram-v2-NBCMYWYE-szgk1shv.js} +1 -1
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-man3fqcj.js → cose-bilkent-JH36ORCC-0s9s4mmv.js} +1 -1
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-2f0kbbv2.js → cynefinDiagram-VND7K2PF-664g28ze.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-k7pyhgzn.js → dagre-6A5THRUB-ga4rp1jx.js} +1 -1
- package/dist/client/static/js/{diagram-22UHCM2B-qx0afa2m.js → diagram-22UHCM2B-aagj46ty.js} +1 -1
- package/dist/client/static/js/{diagram-3UASUU5V-ydpe77sv.js → diagram-3UASUU5V-20qk6whk.js} +1 -1
- package/dist/client/static/js/{diagram-ATOU4E4O-e63v984n.js → diagram-ATOU4E4O-1vg1tfca.js} +1 -1
- package/dist/client/static/js/{diagram-CDSNMT55-8c765h3a.js → diagram-CDSNMT55-90d6jrqs.js} +1 -1
- package/dist/client/static/js/{diagram-MLGK6HIB-3pq0n7v8.js → diagram-MLGK6HIB-8je4z8m1.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-638atzxz.js → diagram-MPIPVDR6-0kzpexsj.js} +1 -1
- package/dist/client/static/js/{dockerfile-yehc914q.js → dockerfile-5nrbr0ef.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-3gv43zvm.js → ebnfDiagram-ZINNZB2B-47yg36zx.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-6s5pggfc.js → elk-276RUBZZ-5hqp6r2d.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-x7cqyb89.js → erDiagram-OPXOYQCR-bt9te7r0.js} +1 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-500fcx2a.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-g97te4v1.js → ganttDiagram-FUAMR5RP-kzc13swm.js} +1 -1
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-sw4f94tc.js → gitGraphDiagram-X574FWY7-bjf8aa3j.js} +1 -1
- package/dist/client/static/js/{index-9pw441wc.js → index-0kcnghxn.js} +2 -2
- package/dist/client/static/js/{index-vejz38qt.js → index-1fmjhm2d.js} +1 -1
- package/dist/client/static/js/{index-qkqkygrf.js → index-24a40rw8.js} +1 -1
- package/dist/client/static/js/{index-ddkjgv5h.js → index-2zhmmtye.js} +1 -1
- package/dist/client/static/js/{index-9rz6kzsv.js → index-3x7cbxwq.js} +1 -1
- package/dist/client/static/js/{index-cfvc1zpk.js → index-475dc6h9.js} +1 -1
- package/dist/client/static/js/{index-95jfphx5.js → index-4vtc4xct.js} +7 -7
- package/dist/client/static/js/{index-bqapt2e8.js → index-5srvxsht.js} +1 -1
- package/dist/client/static/js/{index-z8k42dwz.js → index-653x8zdq.js} +1 -1
- package/dist/client/static/js/{index-qkyy563e.js → index-6c1s0v4b.js} +1 -1
- package/dist/client/static/js/{index-0ze5bwvw.js → index-776n5n29.js} +1 -1
- package/dist/client/static/js/{index-cf69bhjx.js → index-85jfn1fz.js} +1 -1
- package/dist/client/static/js/{index-vcq6zfxx.js → index-9g2nzgpx.js} +1 -1
- package/dist/client/static/js/{index-6qn9kygb.js → index-bq9f0mxp.js} +1 -1
- package/dist/client/static/js/{index-bjz54ht6.js → index-cvm2ha01.js} +1 -1
- package/dist/client/static/js/{index-hxsqw7sz.js → index-d11mbz2q.js} +1 -1
- package/dist/client/static/js/{index-jfqd838j.js → index-dabnbvbc.js} +1 -1
- package/dist/client/static/js/{index-h65zrhva.js → index-fen0x3qh.js} +1 -1
- package/dist/client/static/js/{index-dekvtt2a.js → index-gwgh27h3.js} +2 -2
- package/dist/client/static/js/{index-pdgc9ccr.js → index-h7agc069.js} +1 -1
- package/dist/client/static/js/{index-111bq6rs.js → index-jz4012t5.js} +1 -1
- package/dist/client/static/js/{index-pdz6j2g2.js → index-k9yf2txw.js} +1 -1
- package/dist/client/static/js/{index-bpcg34jp.js → index-kj70d2q9.js} +1 -1
- package/dist/client/static/js/{index-hwdkxe4n.js → index-krdz5vby.js} +1 -1
- package/dist/client/static/js/{index-4xbc0j7t.js → index-kyr612aa.js} +1 -1
- package/dist/client/static/js/{index-hgfyx8dt.js → index-m24sebb0.js} +1 -1
- package/dist/client/static/js/{index-4h2zkrk1.js → index-pg87cgpy.js} +1 -1
- package/dist/client/static/js/{index-wrk99kks.js → index-q1a40v20.js} +1 -1
- package/dist/client/static/js/{index-fnwaxc6r.js → index-qmvstmvh.js} +1 -1
- package/dist/client/static/js/{index-vec7m1yd.js → index-r38e0rya.js} +1 -1
- package/dist/client/static/js/{index-2n2evsg0.js → index-sr14vwn5.js} +1 -1
- package/dist/client/static/js/{index-ywp0sd1e.js → index-vgcw01yk.js} +1 -1
- package/dist/client/static/js/{index-dv01prse.js → index-vn59zz0k.js} +1 -1
- package/dist/client/static/js/{index-ja0ajnvq.js → index-wf5j0009.js} +1 -1
- package/dist/client/static/js/{index-8zct30zd.js → index-xy0m8te9.js} +1 -1
- package/dist/client/static/js/{index-5nm8hm4k.js → index-y6zbkh4p.js} +1 -1
- package/dist/client/static/js/{index-37apvxgj.js → index-z5s9tmj8.js} +1 -1
- package/dist/client/static/js/{index-43gmn7yb.js → index-zr3965k9.js} +1 -1
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-pw2qaa27.js → infoDiagram-VRGFBTTK-jy5zvvj8.js} +1 -1
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-d13jhvxy.js → ishikawaDiagram-OU5B5YK6-pfky1nnf.js} +1 -1
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-20gb8a04.js → journeyDiagram-ZHPQQLJL-mvaf7rfh.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-s78e158c.js → kanban-definition-PNTS6WVX-hw2xwe6e.js} +1 -1
- package/dist/client/static/js/{mermaid.core-xbm27k28.js → mermaid.core-hsw87hmq.js} +2 -2
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-6y7xe2zm.js → mindmap-definition-NLK3R4M7-wfe4d846.js} +1 -1
- package/dist/client/static/js/one-dark-pro-ckq5capv.js +1 -0
- package/dist/client/static/js/one-light-a908z398.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-dmvewetf.js → pegDiagram-GJSIUBJH-cvnmxgst.js} +1 -1
- package/dist/client/static/js/{pieDiagram-5QR66LMP-1q9e7rcm.js → pieDiagram-5QR66LMP-0n3gz7sv.js} +1 -1
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-mvrem3n6.js → quadrantDiagram-O4NWA36T-9qqh6xvv.js} +1 -1
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-axttcfhw.js → railroadDiagram-XR7U4H2S-5f3x3762.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-5qx7erta.js → requirementDiagram-PLB6GJNP-a68bv6kh.js} +1 -1
- package/dist/client/static/js/{rust-b3ckax3e.js → rust-qjhdt4b0.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-es87a3j6.js → sankeyDiagram-IPEJSGJF-ry7xcphh.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-dgpnjrtk.js → sequenceDiagram-PO4LG4MO-mekzzhet.js} +1 -1
- package/dist/client/static/js/{sizeCapture-INFHLROL-kyw0p86n.js → sizeCapture-INFHLROL-pvc16ame.js} +1 -1
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-vnsbw8y9.js → stateDiagram-v2-GCMORJYK-3ytxby83.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-060q1rep.js → swimlanes-2SLR337P-c2zfp416.js} +1 -1
- package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-y77g9dq0.js → swimlanesDiagram-TC7HE7FX-9gm67sq4.js} +1 -1
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-8a3yqmx0.js → timeline-definition-EJHVYXUP-xtvv4za2.js} +1 -1
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-18sp73v7.js → usecaseDiagram-POWQR4AR-sz6b7bnv.js} +1 -1
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-gf4y1r3s.js → vennDiagram-UO4OBE2U-56q0qs51.js} +1 -1
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-q0kwmbzh.js → wardleyDiagram-VNRHLVJA-xvtyvde9.js} +1 -1
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-y0gpmg6m.js → xychartDiagram-PMCCYNJV-jcs20s84.js} +1 -1
- package/package.json +1 -1
- package/src/client/components/workspace/panel-tabs/TabChip.tsx +17 -15
- package/src/client/components/workspace/panel-tabs/TabStrip.connected.test.tsx +14 -5
- package/dist/client/static/js/MergeDiffView-bng34cpr.js +0 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-7sn6nwjv.js +0 -1
- package/dist/client/static/js/one-dark-pro-7bgqnyhm.js +0 -1
- package/dist/client/static/js/one-light-47y6etng.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d,n,o,i,u,a,Lr,He,se,e,sr,k,Hh,Se,kl,Uo,S,vr,kr,s,Yn,Q,At,I,le,oe,Be,at,_i,yn,Ho,ma,D,G,h,Bt,it,$e,Tt,$d,ut,bt,a0,o0,Wo,xs,zd,Ue}from"./index-95jfphx5.js";import{Sd,Td,xi,Dd,Nd}from"./index-wrk99kks.js";import{Z}from"./index-ddkjgv5h.js";import{yl,Rr}from"./index-2n2evsg0.js";var rn={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"]},Ye=s(rn);var on={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"}]]},qe=s(on);var sn={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"}]]},Qe=s(sn);var an={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"}]]},Re=s(an);function Je({rootPath:t,activeRepo:r,repos:l,reposScanning:c,onRefreshRepos:p,onSelectRepo:f,searchQuery:x,onSearchChange:m,onRefresh:y,refreshing:g}){return e("div",{className:"border-b border-ink/10",children:[e(Bt,{className:"border-b-0",left:e(Rr,{rootPath:t,activeRepo:r,onSelectRepo:f,repos:l,scanning:c,onRefreshRepos:p}),right:e(it,{label:"Refresh",onClick:y,busy:g})}),e("div",{className:"px-3 pb-3",children:e("div",{className:"relative",children:[e(G,{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:(b)=>m(b.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 Ze({name:t,path:r,isFolder:l,isOpen:c,ignored:p,selected:f,gitStatus:x,folderStatus:m}){let y=f?"text-ink font-semibold":x?x.colorClass:m?m.colorClass:p?"text-ink/40":"";return e(d,{children:[l?c?e(I,{size:12,className:"flex-shrink-0 text-ink/40"}):e(le,{size:12,className:"flex-shrink-0 text-ink/40"}):e("span",{className:"w-3 flex-shrink-0"}),e(ut,{name:t,isFolder:l,isOpen:c,size:12,className:`flex-shrink-0${p?" opacity-40":""}`}),e("span",{className:`truncate min-w-0 flex-1 ${y}`,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}),m&&e("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${m.dotClass}`,title:`${m.count} changed file${m.count>1?"s":""}`})]})}var ln=28,cn=9,dn=8;function pn(t){let{isFolder:r,hasGitStatus:l,pasteLabel:c,busy:p,chainLabel:f,foldable:x,selectionCount:m,isArchive:y}=t,g=[],b=m>1,F=m===1?"":` ${m} items`;if(b)return g.push({kind:"item",id:"cut",label:`Cut${F}`,icon:e(Re,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"copy",label:`Copy${F}`,icon:e(oe,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"separator"}),g.push({kind:"item",id:"compress",label:`Compress${F} to…`,icon:e(At,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"separator"}),g.push({kind:"item",id:"delete",label:`Delete${F}`,icon:e(Q,{size:13,className:"text-error-text"}),tone:"text-error-text"}),g;if(r){if(g.push({kind:"item",id:"new_file",label:"New File",icon:e(_i,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"new_folder",label:"New Folder",icon:e(yn,{size:13,className:"text-ink/60"})}),f)g.push({kind:"item",id:"unfold",label:"Unfold Folders",icon:e(I,{size:13,className:"text-ink/60"})});if(x)g.push({kind:"item",id:"fold",label:"Fold Folders",icon:e(le,{size:13,className:"text-ink/60"})});g.push({kind:"separator"})}else{if(g.push({kind:"item",id:"view",label:"View",icon:e(at,{size:13,className:"text-ink/60"})}),y)g.push({kind:"item",id:"extract",label:"Extract…",icon:e(Qe,{size:13,className:"text-ink/60"}),disabled:p});if(l)g.push({kind:"item",id:"diff",label:"Open in Diff Panel",icon:e(Ho,{size:13,className:"text-warning-text"}),tone:"font-medium"});g.push({kind:"separator"})}if(g.push({kind:"item",id:"cut",label:"Cut",icon:e(Re,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"copy",label:"Copy",icon:e(oe,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"compress",label:"Compress to…",icon:e(At,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"duplicate",label:"Duplicate",icon:e(qe,{size:13,className:"text-ink/60"}),disabled:p}),c)g.push({kind:"item",id:"paste",label:c,icon:e(yl,{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(Be,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"copy_path",label:"Copy Path",icon:e(oe,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"copy_relative",label:"Copy Relative Path",icon:e(oe,{size:13,className:"text-ink/60"})}),g.push({kind:"separator"}),g.push({kind:"item",id:"history",label:"Show Git History",icon:e(Yn,{size:13,className:"text-ink/60"})}),g.push({kind:"separator"}),g.push({kind:"item",id:"rename",label:"Rename",icon:e(Ye,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"delete",label:"Delete",icon:e(Q,{size:13,className:"text-error-text"}),tone:"text-error-text"}),g}function un(t){let r=t.filter((c)=>c.kind==="item").length,l=t.length-r;return r*ln+l*cn+dn}function et({x:t,y:r,isFolder:l,hasGitStatus:c,pasteLabel:p,chainLabel:f,foldable:x,busy:m,selectionCount:y,isArchive:g,onAction:b,menuRef:F}){let N=pn({isFolder:l,hasGitStatus:c,pasteLabel:p,busy:m,chainLabel:f,foldable:x,selectionCount:y,isArchive:g}),w=un(N),C=typeof window<"u"?Math.max(10,Math.min(t,window.innerWidth-210-12)):t,A=typeof window<"u"?Math.max(10,Math.min(r,window.innerHeight-w-12)):r;return se(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>b("close"),onContextMenu:(E)=>{E.preventDefault(),b("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:A,left:C},onClick:(E)=>E.stopPropagation(),children:N.map((E,T)=>E.kind==="separator"?e("div",{className:"my-1 border-t border-ink/10"},`sep-${T}`):e("button",{type:"button",disabled:E.disabled,onClick:()=>b(E.id),className:`w-full text-left px-3 py-1.5 flex items-center space-x-2 transition-colors ${E.disabled?"opacity-40 cursor-default":"hover:bg-ink/5"} ${E.tone??""}`,children:[E.icon,e("span",{children:E.label})]},E.id))})}),document.body)}function Fe({folderPath:t,kind:r,value:l,error:c,isLoading:p,onChange:f,onCancel:x,onSubmit:m}){let y=r==="folder"?"Folder":"File";return se(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center modal-safe backdrop-blur-sm",children:e("form",{onSubmit:m,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 ",y]}),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 ${y.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-text 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 tt({fileName:t,displayName:r,isFolder:l,count:c=1,isLoading:p,onCancel:f,onConfirm:x}){let m=c>1;return se(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center modal-safe 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 ",m?`${c} Items`:l?"Folder":"File"]}),e("p",{className:"text-xs text-ink/70 mb-4",children:["Are you sure you want to delete ",m?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 nt({isFolder:t,renameValue:r,originalPath:l,displayName:c,error:p,isLoading:f,onChange:x,onCancel:m,onSubmit:y}){return se(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center modal-safe backdrop-blur-sm",children:e("form",{onSubmit:y,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-text mb-2",children:p}),e("div",{className:"flex justify-end space-x-2",children:[e("button",{type:"button",onClick:m,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 rt({filePath:t,fetcherState:r,fetcherData:l,onClose:c}){let p=l?.type==="history"?l.data:void 0;return se(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center modal-safe 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(Yn,{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(h,{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-text 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 ot({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(tt,{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(nt,{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(rt,{filePath:r.path,fetcherState:t.fetcherState,fetcherData:t.fetcherData,onClose:t.closeHistory})]})}function Ae(t){let r=t.map(fn);return r.some((l,c)=>l!==t[c])?r:t}function fn(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 Me(t){return t.type==="folder"&&t.name.includes("/")}function Le(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 st(t,r){let l=new Map;if(r.size===0)return{nodes:t,roots:l};let c=!1,p=(x)=>x.flatMap((m)=>{if(m.type!=="folder")return[m];let y=Array.isArray(m.children)?p(m.children):m.children,g=y===m.children?m:{...m,children:y},b=r.has(m.path)?Le(m.path,m.name):null;if(!b)return[g];c=!0,l.set(b[0],m.path);let F={...g,name:b[b.length-1].split("/").pop()};for(let v=b.length-1;v>0;v-=1){let N=b[v-1];F={name:N.split("/").pop(),path:N,type:"folder",ignored:g.ignored,children:[F]}}return[F]}),f=p(t);return{nodes:c?f:t,roots:l}}function lt(t,r){let l=new Set,c=(x)=>{for(let m of x){if(m.type!=="folder")continue;if(l.add(m.path),Array.isArray(m.children))c(m.children)}};c(t);let p=r.split("/").slice(0,-1),f=[];for(let x=0;x<p.length;x+=1){let m=p.slice(0,x+1).join("/");if(l.has(m))f.push(m)}return f}function Ne({folderPath:t,rootPath:r,repo:l,onCreated:c,onOpenCreated:p}){let f=bt(),[x,m]=n(!1),[y,g]=n("file"),[b,F]=n(""),[v,N]=n(null),w=i(null);return o(()=>{if(f.state!=="idle"||!f.data)return;let C=f.data;if(w.current===C)return;if(w.current=C,C.success&&C.path){let A=C.kind==="folder"?"folder":"file";m(!1),F(""),N(null);let E=C.path.split("/").pop()||C.path;if(c({path:C.path,name:E,kind:A}),A==="file")p?.({path:C.path,name:E})}else N(C.error||`Could not create the ${y}`)},[f.state,f.data]),{open:x,kind:y,name:b,setName:F,error:v,busy:f.state!=="idle",openDialog:(C="file")=>{g(C),F(""),N(null),m(!0)},closeDialog:()=>m(!1),submit:(C)=>{C.preventDefault();let A=b.trim();if(!A)return;N(null);let E=new FormData;if(E.append("actionType","create"),E.append("path",t),E.append("name",A),y==="folder")E.append("kind","folder");if(l&&l!==".")E.append("repo",l);if(r)E.append("root",r);f.submit(E,{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 ct(t,r){return`${t??""}\x00${r}`}function Oe(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 ft(t,r){let l=pt(t,r);if(l)return l;if(r===dt(t.path))return"Already in this folder";return null}function mt(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 ht(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=mn(p);if(!f)return null;c.push(f)}if(c.length===0)return null;return{scope:r.scope,entries:c,mode:r.mode}}function mn(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 ze=[{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 Pe(t){let r=t.toLowerCase();for(let[l,c]of gt)if(r.endsWith(l))return c;return null}function xt(t){return Pe(t)!==null}function hn(t){return ze.find((r)=>r.id===t)}function gn(t){return hn(t)?.extension??"zip"}function vt(t){let r=t.toLowerCase();for(let[l]of gt)if(r.endsWith(l))return t.slice(0,-l.length);return t}function yt(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)||"."}function kt(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)=>yt(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 Ee(t,r){let l=gn(r);if(t.length===1){let f=t[0],x=vt(f.name),m=x.lastIndexOf(".");return`${(f.kind==="folder"?f.name:m>0?x.slice(0,m):x)||"archive"}.${l}`}let c=Ct(t.map((f)=>f.path)),p=kt(c);return`${p==="."||p===""?"archive":p}.${l}`}function Ft(t){return Ct(t.map((r)=>r.path))}function Nt(t){let r=yt(t),l=vt(kt(t));if(!l)return r;return r==="."?l:`${r}/${l}`}function wt(t){return t.toUpperCase()}function Et({file:t,diff:r,onOpenFile:l,onActionComplete:c,onCreated:p,onRenamed:f,onUnfold:x,onFold:m,clipboard:y,isFolder:g,selection:b,selected:F,archive:v}){let N=bt(),[w,C]=n(null),A=i(null),[E,T]=n(!1),[R,P]=n(!1),[U,Y]=n(!1),[q,te]=n(t.path),[H,z]=n(null),{repo:L,rootPath:_}=t,K=Ne({folderPath:t.path,rootPath:_,repo:L,onCreated:(M)=>p?p(M):c(),onOpenCreated:(M)=>l?.({...M,root:_,repo:L||"."})}),ie=i(null);o(()=>{if(N.state!=="idle"||!N.data)return;let M=N.data;if(ie.current===M)return;if(ie.current=M,M.success&&!M.type)if(T(!1),P(!1),z(null),M.previousPath&&M.path&&f)f(M.previousPath,M.path);else c();else if(!M.success&&M.error&&E)z(M.error)},[N.state,N.data]);let B=(M)=>{if(L&&L!==".")M.append("repo",L);if(_)M.append("root",_);N.submit(M,{method:"post",action:"/api/fs/action"})},V=()=>{l?.({path:t.path,name:t.name,root:_,repo:L||"."})},ne={path:t.path,name:t.name,kind:g?"folder":"file"},ae=F&&b.length>1?b:[ne],he=xt(t.name),J=y.clip&&!y.refusalFor(ne)?`Paste ${we(y.clip)??"item"}`:null,fe=(M)=>{if(C(null),z(null),M==="view")V();else if(M==="diff")window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.path,staged:r?.staged,status:r?.status||"M",repo:L||".",root:_}}));else if(M==="explorer"){let j=new FormData;j.append("actionType","open_explorer"),j.append("path",t.path),B(j)}else if(M==="copy_path")Tt($d(t.basePath,t.path));else if(M==="copy_relative")Tt(t.path);else if(M==="history"){Y(!0);let j=new FormData;j.append("actionType","git_history"),j.append("path",t.path),B(j)}else if(M==="rename")te(t.path),T(!0);else if(M==="unfold")x?.();else if(M==="fold")m?.();else if(M==="new_file")K.openDialog("file");else if(M==="new_folder")K.openDialog("folder");else if(M==="delete")P(!0);else if(M==="cut")y.cut(ae);else if(M==="copy")y.copy(ae);else if(M==="compress")v.openCompress(ae);else if(M==="extract")v.openExtract(ne);else if(M==="duplicate")y.duplicate(ne);else if(M==="paste")y.paste(ne)},ce=(M)=>{M.preventDefault(),z(null);let j=new FormData;j.append("actionType","rename"),j.append("path",t.path),j.append("newPath",q),B(j)},xe=()=>{let M=new FormData;if(M.append("actionType","delete"),ae.length>1)M.append("paths",JSON.stringify(ae.map((j)=>j.path)));else M.append("path",t.path);B(M)};return{contextMenu:w,contextMenuRef:A,openContextMenu:(M,j)=>C({x:M,y:j}),closeContextMenu:()=>C(null),showRenameModal:E,showDeleteModal:R,showHistoryModal:U,showCreateModal:K.open,createKind:K.kind,createError:K.error,createName:K.name,setCreateName:K.setName,renameValue:q,setRenameValue:te,renameError:H,busy:N.state!=="idle"||K.busy||y.busy||v.busy,pasteLabel:J,selectionCount:ae.length,isArchive:he,chainLabel:x!==void 0,foldable:m!==void 0,fetcherState:N.state,fetcherData:N.data,handleAction:fe,submitCreate:K.submit,submitRename:ce,submitDelete:xe,closeCreate:K.closeDialog,closeDelete:()=>P(!1),closeRename:()=>T(!1),closeHistory:()=>Y(!1)}}function Dt({target:t,dragging:r,clipboard:l,onDragStart:c,onDragEnd:p,onDropOn:f,onHoverAccept:x}){let m=r?.path===t.path,y=Boolean(r)&&!m&&l.moveRefusalFor(r,t)===null,[g,b]=n(!1);return o(()=>{if(!r)b(!1)},[r]),{isDragging:m,acceptsDrop:y,isDropHovered:g&&y,onDragStart:(v)=>{if(v.dataTransfer?.setData("text/plain",t.path),v.dataTransfer)v.dataTransfer.effectAllowed="move";c(t)},onDragEnd:p,onDragOver:(v)=>{if(!r)return;if(v.stopPropagation(),b(y),!y)return;if(v.preventDefault(),v.dataTransfer)v.dataTransfer.dropEffect="move";x?.(t)},onDragLeave:()=>b(!1),onDrop:(v)=>{if(!r)return;if(v.stopPropagation(),!y)return;v.preventDefault(),f(t)}}}function bn(t,r,l){if(r||l)return!1;return!Array.isArray(t.children)}function Ie({file:t,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:x,onCreated:m,onRenamed:y,expandedPaths:g,onToggleFolder:b,gitFileMap:F,gitFolderMap:v,clipboard:N,archive:w,selection:C,selectionTargets:A,dragging:E,onDragStart:T,onDragEnd:R,onDropOn:P,onUnfold:U,onFold:Y,foldRoots:q,touch:te=!1}){let H=t.type==="folder",[z,L]=n(!1),[_,K]=n(!1),[ie,B]=n(!1),[V,ne]=n(!1),ae=Array.isArray(t.children)?t.children:[],he=(t.path||"").replace(/^\/+/,""),J=!H?F?.get(he)||F?.get(t.path):void 0,fe=J?sr(J.status,J.staged):null,ce=H?v?.get(he)||v?.get(t.path):null,xe=Boolean(fe),M=t.ignored===!0,j=g?g.has(t.path):z,de=t.forceExpanded!==void 0?t.forceExpanded:j;o(()=>{ne(!0)},[]),o(()=>{if(H&&g)L(g.has(t.path))},[g,t.path,H]),o(()=>{if(H&&de&&bn(t,_,ie)&&p)B(!0),K(!0),Promise.resolve(p(t.path)).finally(()=>K(!1))},[H,de,t.children,t.path,p,_,ie]);let ke={path:t.path,name:t.name,kind:H?"folder":"file"},be=C.selected.has(t.path),W=Et({file:{path:t.path,name:t.name,basePath:l,rootPath:r,repo:c},selection:A,selected:be,archive:w,diff:{staged:J?.staged||(J?.status?J.status[0]!==" "&&J.status[0]!=="?":!1),status:fe?.charStatus},onOpenFile:f,onActionComplete:x,onCreated:m,onRenamed:y,onUnfold:U&&Me({type:H?"folder":"file",name:t.name})?()=>U(ke):void 0,onFold:Y&&q?.has(t.path)?()=>Y(q.get(t.path)):void 0,clipboard:N,isFolder:H});$e(W.contextMenuRef,W.closeContextMenu);let ee=Sd({enabled:te,onLongPress:(X,ge)=>W.openContextMenu(X,ge)}),Ce=(X)=>{if(X.stopPropagation(),ee.consume())return;let ge=C.gestureOf(X);if(ge!=="plain"){C.applyGesture(ge,t.path);return}if(C.applyGesture("plain",t.path),H){let ue=!de;if(L(ue),t.forceExpanded!==void 0)t.forceExpanded=void 0;if(b?.(t.path,ue),!ue)B(!1)}else if(f)f({...t,root:r,repo:c||"."})},ve=(X)=>{X.preventDefault(),X.stopPropagation(),C.ensureForContext(t.path),W.openContextMenu(X.clientX,X.clientY)},pe=Dt({target:ke,dragging:E,clipboard:N,onDragStart:T,onDragEnd:R,onDropOn:P,onHoverAccept:U});return e("div",{children:[e("div",{className:`flex items-center space-x-1.5 py-1 px-2 cursor-pointer rounded group select-none ${pe.isDragging?"opacity-40":""} ${pe.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:!te,onClick:Ce,onContextMenu:ve,onDragStart:pe.onDragStart,onDragEnd:pe.onDragEnd,onDragOver:pe.onDragOver,onDragLeave:pe.onDragLeave,onDrop:pe.onDrop,onTouchStart:ee.onTouchStart,onTouchMove:ee.onTouchMove,onTouchEnd:ee.onTouchEnd,onTouchCancel:ee.onTouchCancel,children:e(Ze,{name:t.name,path:t.path,isFolder:H,isOpen:de,ignored:M,selected:be,gitStatus:fe,folderStatus:ce})}),de&&_&&e("div",{className:"ml-3 border-l border-ink/10 pl-3 py-0.5 text-[10px] text-ink/30",children:"Loading…"}),de&&!_&&ae.length>0&&e("div",{className:"ml-3 border-l border-ink/10 pl-1",children:ae.map((X)=>e(Ie,{file:X,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:x,onCreated:m,onRenamed:y,expandedPaths:g,onToggleFolder:b,gitFileMap:F,gitFolderMap:v,clipboard:N,archive:w,selection:C,selectionTargets:A,dragging:E,onDragStart:T,onDragEnd:R,onDropOn:P,onUnfold:U,onFold:Y,foldRoots:q,touch:te},X.path))}),V&&W.contextMenu&&e(et,{x:W.contextMenu.x,y:W.contextMenu.y,isFolder:H,hasGitStatus:xe,pasteLabel:W.pasteLabel,chainLabel:W.chainLabel,foldable:W.foldable,busy:W.busy,selectionCount:W.selectionCount,isArchive:W.isArchive,onAction:W.handleAction}),V&&e(ot,{actions:W,file:t,isFolder:H,chainLabel:Me({type:H?"folder":"file",name:t.name})?t.name:void 0})]})}function Rt({x:t,y:r,pasteLabel:l,busy:c,onAction:p,menuRef:f}){let m=l?104:76,y=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-m-12)):r;return se(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>p("close"),onContextMenu:(b)=>{b.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:y},onClick:(b)=>b.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(_i,{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(yn,{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(yl,{size:13,className:"text-ink/60"}),e("span",{children:l})]})]})}),document.body)}function St({menu:t,menuRef:r,pasteLabel:l,busy:c,onAction:p,create:f}){return e(d,{children:[t&&e(Rt,{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 Mt({title:t,subject:r,error:l,busy:c,submitLabel:p,busyLabel:f,onSubmit:x,onCancel:m,children:y}){return se(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center modal-safe 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}),y,l&&e("p",{className:"text-[11px] text-error-text mb-2",children:l}),e("div",{className:"flex justify-end space-x-2 mt-3",children:[e("button",{type:"button",onClick:m,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 xn({entries:t,format:r,name:l,destination:c,formats:p,error:f,busy:x,onFormatChange:m,onNameChange:y,onDestinationChange:g,onCancel:b,onSubmit:F}){let v=t.slice(0,4).map((w)=>w.name).join(", "),N=t.length>4?` +${t.length-4} more`:"";return e(Mt,{title:`Compress ${t.length===1?t[0].name:`${t.length} items`}`,subject:`${v}${N}`,error:f,busy:x,submitLabel:"Compress",busyLabel:"Compressing...",onCancel:b,onSubmit:(w)=>{w.preventDefault(),F()},children:[e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",children:"Format"}),e(Z,{ariaLabel:"Format",value:r,onChange:(w)=>m(w),placeholder:"Format",searchable:!1,allowEmpty:!1,className:"mb-3 text-xs",options:p.map((w)=>({value:w.id,label:w.available?w.label:`${w.label} — ${w.tool} not installed`,disabled:!w.available}))}),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:(w)=>y(w.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:(w)=>g(w.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 vn({archive:t,kindLabel:r,destination:l,error:c,busy:p,onDestinationChange:f,onCancel:x,onSubmit:m}){return e(Mt,{title:`Extract ${t.name}`,subject:`${r} archive · extracts into a folder`,error:c,busy:p,submitLabel:"Extract",busyLabel:"Extracting...",onCancel:x,onSubmit:(y)=>{y.preventDefault(),m()},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:(y)=>f(y.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 Lt({archive:t}){if(t.compress)return e(xn,{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(vn,{archive:t.extract.archive,kindLabel:wt(Pe(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}var Ot=240,zt=96;var $t=32;function ye(t){let r=Number.isFinite(t)&&t>0?t:840;return Math.max(96,Math.min(640,Math.round(r-200)))}function De(t,r=640){let l=Math.max(96,Math.min(640,r));if(!Number.isFinite(t))return Math.min(240,l);return Math.min(l,Math.max(96,Math.round(t)))}function Pt(t){let[r,l]=S("files.outlineHeight",Ot),[c,p]=n(null),f=i(null),[x,m]=n(ye(0)),[y,g]=n(!1),b=i(null);o(()=>{let w=t.current?.parentElement;if(!w)return;let C=()=>m(ye(w.clientHeight));if(C(),typeof ResizeObserver>"u")return;let A=new ResizeObserver(C);return A.observe(w),()=>A.disconnect()},[t]),o(()=>()=>b.current?.(),[]);let F=De(c??r,x);return{height:F,max:x,resizing:y,onPointerDown:(w)=>{if(w.button!==0)return;let C=ye(t.current?.parentElement?.clientHeight??0);m(C);let A=w.clientY,E=F;w.preventDefault(),g(!0);let T=document.body.style.cursor,R=document.body.style.userSelect;document.body.style.cursor="row-resize",document.body.style.userSelect="none";let P=E,U=0,Y=(z)=>{if(P=De(E-(z.clientY-A),C),U!==0)return;U=requestAnimationFrame(()=>{U=0,f.current=P,p(P)})},q=(z)=>{if(window.removeEventListener("pointermove",Y),window.removeEventListener("pointerup",te),window.removeEventListener("pointercancel",H),U!==0)cancelAnimationFrame(U);if(U=0,b.current=null,document.body.style.cursor=T,document.body.style.userSelect=R,g(!1),z&&P!==E)l(P);f.current=null,p(null)},te=()=>q(!0),H=()=>q(!1);window.addEventListener("pointermove",Y),window.addEventListener("pointerup",te),window.addEventListener("pointercancel",H),b.current=()=>q(!1)},onKeyDown:(w)=>{let C=w.key==="ArrowUp"?1:w.key==="ArrowDown"?-1:0;if(C===0)return;w.preventDefault();let A=ye(t.current?.parentElement?.clientHeight??0);m(A),l(De(F+C*$t,A))}}}function It(){let[t,r]=S("files.outlineExpanded",!1),l=Lr(),c=i(null),p=Pt(c),f=He(o0,a0),{symbols:x,total:m,truncated:y,notice:g}=Nd({content:f.content,language:f.language,state:f.state,note:f.note,path:f.path});if(f.state==="diff")return null;let b=f.preview,F=(v,N)=>{if(!f.path)return;if(b){let w=zd(x,N);if(w)xs({path:f.path,...w});return}Wo({path:f.path,line:v.line,column:v.column,length:v.name.length})};return e("div",{ref:c,className:"border-t border-ink/10 bg-canvas/30 flex-shrink-0",children:[e("div",{role:"separator","aria-orientation":"horizontal","aria-label":"Resize outline","aria-valuemin":zt,"aria-valuemax":p.max,"aria-valuenow":p.height,title:"Drag to resize the outline",tabIndex:0,onPointerDown:(v)=>{if(!t)r(!0);p.onPointerDown(v)},onKeyDown:(v)=>{if(!t)r(!0);p.onKeyDown(v)},className:"group flex h-3 w-full cursor-row-resize touch-none items-center justify-center outline-none focus-visible:bg-ink/5",children:e("span",{"aria-hidden":"true",className:`h-0.5 w-6 rounded-full transition-colors ${p.resizing?"bg-ink/50":"bg-ink/20 group-hover:bg-ink/40"}`})}),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(ma,{size:12}),e("span",{children:"Outline"}),m>0&&e("span",{className:"font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[10px] text-ink/50",children:y?`${x.length}/${m.toLocaleString()}`:m})]})}),e("div",{className:"section-reveal","data-expanded":t,id:l,inert:!t,children:e("div",{children:e("div",{className:"px-2 pb-2",children:x.length===0?e("div",{className:"px-1 text-[10px] text-ink/40 italic py-1",children:g}):e("div",{className:"overflow-y-auto scrollbar-overlay-container flex flex-col",style:{height:`${p.height}px`},children:[x.map((v,N)=>e("button",{type:"button",onClick:()=>F(v,N),"aria-label":b?`${xi(v.kind)} ${v.name}`:`${xi(v.kind)} ${v.name}, line ${v.line}`,title:b?`Jump to ${xi(v.kind).toLowerCase()}`:`${xi(v.kind)} · line ${v.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+v.depth*12}px`},children:[e(Td,{kind:v.kind}),e("span",{className:"min-w-0 flex-1 truncate text-[11px] font-mono text-ink/80",children:v.name}),!b&&e("span",{className:"flex-shrink-0 font-mono text-[10px] text-ink/35",children:v.line})]},`${v.line}:${v.kind}:${v.name}`)),y&&e("div",{className:"px-1 py-1 text-[10px] italic text-ink/40",children:Dd(m)})]})})})})]})}function _e(t,r){return Ae(t.map((l)=>kn(l,r)))}function kn(t,r){if(t.type!=="folder")return t;let l=r[t.path];if(!l)return t;return{...t,children:_e(l,r)}}function Cn(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 Ht(t){return[...t].sort((r,l)=>{if(r.type!==l.type)return r.type==="folder"?-1:1;return r.name.localeCompare(l.name)})}function Ge(t,r,l){let c=l.path.split("/"),p=c.slice(0,-1).join("/"),f=[...t],x={...r},m=f,y=null;for(let g=0;g<c.length-1;){let b=c.slice(0,g+1).join("/"),F=m.find((A)=>A.type==="folder"&&A.path===b),v=F?null:m.find((A)=>A.type==="folder"&&A.path.startsWith(`${b}/`)&&(p===A.path||p.startsWith(`${A.path}/`))),N=F??v,w=N?x[N.path]??N.children:null;if(N&&!Array.isArray(w))return{nodes:t,cache:r};if(!N){let A=Fn(m,x,b);if(A){m=A;let E=m.find((R)=>R.path===b),T=Array.isArray(E?.children)?[...E.children]:[];x[b]=T,m=T,y=b,g+=1;continue}}let C=Array.isArray(w)?[...w]:[];if(N){x[N.path]=C,m=C,y=N.path,g=N.path.split("/").length;continue}m.push({name:c[g],path:b,type:"folder",ignored:!1}),x[b]=C,m=C,y=b,g+=1}if(m.push(l),y!==null)x[y]=Ht(m);return f=Ht(f),{nodes:f,cache:x}}function Fn(t,r,l){let c=t.findIndex((y)=>y.type==="folder"&&y.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 m={name:f[f.length-1],path:p.path,type:"folder",ignored:p.ignored,...Array.isArray(x)?{children:x}:{}};for(let y=f.length-2;y>=0;y-=1)m={name:f[y],path:`${l}/${f.slice(0,y+1).join("/")}`,type:"folder",ignored:!1,children:[m]};return t[c]={name:_t(l),path:l,type:"folder",ignored:!1,children:[m]},t}function Gt(t,r,l){let c=t.find((b)=>b.path===l);if(c)return{entry:c,nodes:t.filter((b)=>b.path!==l),cache:r};let p=Cn(l),f=r[p],x=f?.find((b)=>b.path===l);if(f&&x)return{entry:x,nodes:t,cache:{...r,[p]:f.filter((b)=>b.path!==l)}};let y=Object.keys(r).filter((b)=>l.startsWith(`${b}/`)&&r[b].some((F)=>F.path===l)).sort((b,F)=>F.length-b.length)[0];if(!y)return{entry:null,nodes:t,cache:r};let g=r[y];return{entry:g.find((b)=>b.path===l),nodes:t,cache:{...r,[y]:g.filter((b)=>b.path!==l)}}}function Kt(t,r,l){let c=!1,p=t.map((f)=>{let x=f.path===r||f.path.startsWith(`${r}/`),m=Array.isArray(f.children)?Kt(f.children,r,l):void 0;if(!x&&m===f.children)return f;c=!0;let y=x?f.path===r?l:`${l}${f.path.slice(r.length)}`:f.path,g=x?{...f,path:y,name:_t(y)}:{...f};if(m!==void 0)g.children=m;return g});return c?p:t}function Ut(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:Kt(f,r,l)}return c}function jt(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 Wt(t){if(!k(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)=>k(r)):[],root:t.root}}async function Ke(t){try{return Wt(await(await fetch(t)).json())}catch{return{status:"failed"}}}function Xt({enabled:t,rootPath:r,activeRepo:l,expandedPaths:c,onExpansionPruned:p}){let f=`${r??""}\x00${l}`,[x,m]=n({scope:"",files:[],root:""}),[y,g]=n(!1),b=i({}),F=i([]),v=i(f);v.current=f;let N=i(""),w=i(""),C=i(c);C.current=c;let A=(z)=>{let L=new URLSearchParams;if(r)L.set("root",r);if(l&&l!==".")L.set("repo",l);if(z)L.set("path",z);return L.set("t",String(Date.now())),`/api/fs/dir?${L.toString()}`},E=(z,L)=>{N.current=z,w.current=L;let _=_e(F.current,b.current);return m({scope:z,files:_,root:L}),_},T=async(z)=>{let L=[...C.current];if(L.length===0)return;let _=await Promise.all(L.map(async(V)=>({path:V,read:await Ke(A(V))})));if(v.current!==z)return;let K=[];for(let{path:V,read:ne}of _)if(ne.status==="ok")b.current[V]=ne.files;else if(ne.status==="missing")K.push(V);if(K.length===0)return;let ie=new Set(K);for(let V of K)delete b.current[V];let B=new Set([...C.current].filter((V)=>!ie.has(V)));C.current=B,p(B)},R=async()=>{if(!t)return;let z=v.current;g(!0);try{let L=await Ke(A());if(v.current!==z)return;if(L.status!=="ok")return;if(N.current!==z)b.current={};if(F.current=L.files,E(z,L.root),await T(z),v.current!==z)return;E(z,L.root)}finally{if(v.current===z)g(!1)}},P=async(z)=>{let L=v.current,_=await Ke(A(z));if(v.current!==L||_.status!=="ok")return;if(b.current[z]=_.files,N.current===L)E(L,w.current)},U=(z)=>{let L=Wt(z);if(L.status!=="ok")return;let _=v.current;if(N.current!==_)b.current={};F.current=L.files,E(_,L.root),T(_).then(()=>{if(v.current===_)E(_,L.root)})},Y=()=>{b.current={},F.current=[],N.current="",w.current="",m({scope:"",files:[],root:""})},q=(z)=>{let L=v.current;if(N.current!==L)return null;let _={name:z.path.slice(z.path.lastIndexOf("/")+1),path:z.path,type:z.kind,ignored:!1},K=Ge(F.current,b.current,_);if(K.nodes===F.current)return null;return F.current=K.nodes,b.current=K.cache,E(L,w.current)},te=(z,L)=>{let _=v.current;if(N.current!==_)return null;let K=Gt(F.current,b.current,z);if(!K.entry)return null;b.current=Ut(K.cache,z,L);let ie={...K.entry,path:L,name:L.slice(L.lastIndexOf("/")+1)},B=Ge(K.nodes,b.current,ie);return F.current=B.nodes,b.current=B.cache,E(_,w.current)},H=x.scope===f;return{scope:f,files:H?x.files:[],root:H?x.root:"",isLoading:y,reload:R,loadChildren:P,adoptRoot:U,insertEntry:q,moveEntry:te,reset:Y}}function Vt({rootPath:t,repo:r,onComplete:l,onError:c}){let p=bt(),[f,x]=S("files.clipboard",null),m=ht(f),y=ct(t,r),g=i(!1),b=i(null);o(()=>{if(p.state!=="idle"||!p.data)return;let C=p.data;if(b.current===C)return;b.current=C;let A=g.current;if(g.current=!1,C.success){if(A)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 F=a((C,A)=>{g.current=A;let E=new FormData;for(let[T,R]of Object.entries(C))E.append(T,R);if(r&&r!==".")E.append("repo",r);if(t)E.append("root",t);p.submit(E,{method:"post",action:"/api/fs/action"})},[p,r,t]),v=a((C)=>mt(m,y,Oe(C.path,C.kind)),[m,y]),N=a((C,A)=>ft(C,Oe(A.path,A.kind)),[]),w=a((C,A,E,T)=>{let R=new FormData;R.append("actionType","paste"),R.append("mode",E),R.append("targetPath",A.path),R.append("targetKind",A.kind);for(let P of C)R.append("sourcePath",P.path);if(r&&r!==".")R.append("repo",r);if(t)R.append("root",t);g.current=T,p.submit(R,{method:"post",action:"/api/fs/action"})},[p,r,t]);return{clip:m,busy:p.state!=="idle",refusalFor:v,moveRefusalFor:N,copy:(C)=>{if(C.length===0)return;x({scope:y,entries:C.map(({path:A,name:E,kind:T})=>({path:A,name:E,kind:T})),mode:"copy"})},cut:(C)=>{if(C.length===0)return;x({scope:y,entries:C.map(({path:A,name:E,kind:T})=>({path:A,name:E,kind:T})),mode:"cut"})},duplicate:(C)=>{F({actionType:"duplicate",path:C.path},!1)},move:(C,A)=>{let E=N(C,A);if(E){c(E);return}w([C],A,"cut",Boolean(m?.mode==="cut"&&m.entries.some((T)=>T.path===C.path)))},paste:(C)=>{if(!m)return;let A=v(C);if(A){c(A);return}w(m.entries.map(({path:E,name:T,kind:R})=>({path:E,name:T,kind:R})),C,m.mode,m.mode==="cut")}}}var Nn=ze.map((t)=>({...t,available:!0,tool:t.id}));function Yt({rootPath:t,repo:r,onComplete:l}){let c=bt(),[p,f]=n(Nn),[x,m]=n(null),[y,g]=n(null),[b,F]=n(null),v=i(null),N=i(null);o(()=>{let T=!1;return(async()=>{try{let P=await(await fetch("/api/fs/archive")).json();if(!T&&Array.isArray(P.formats)&&P.formats.length>0)f(P.formats)}catch{}})(),()=>{T=!0}},[]),o(()=>{if(c.state!=="idle"||!c.data)return;let T=c.data;if(N.current===T)return;N.current=T;let R=v.current;if(v.current=null,T.success){if(F(null),R==="compress")m(null);if(R==="extract")g(null);l()}else if(R)F(T.error||"The archive request failed")},[c.state,c.data]);let w=a((T)=>{let R=new FormData;for(let[P,U]of Object.entries(T))R.append(P,U);if(r&&r!==".")R.append("repo",r);if(t)R.append("root",t);c.submit(R,{method:"post",action:"/api/fs/action"})},[c,r,t]),C=a((T)=>{if(T.length===0)return;let R=p.find((P)=>P.id==="zip"&&P.available)?.id??p.find((P)=>P.available)?.id??"zip";F(null),g(null),m({entries:T.map(({path:P,name:U,kind:Y})=>({path:P,name:U,kind:Y})),format:R,name:Ee(T,R),destination:Ft(T)})},[p]),A=a((T)=>{F(null),m(null),g({archive:T,destination:Nt(T.path)})},[]),E=a((T)=>{m((R)=>{if(!R)return R;let P=Ee(R.entries,R.format),U=R.name===P?Ee(R.entries,T):R.name;return{...R,format:T,name:U}})},[]);return{formats:p,compress:x,extract:y,error:b,busy:c.state!=="idle",openCompress:C,openExtract:A,setFormat:E,setName:(T)=>m((R)=>R&&{...R,name:T}),setCompressDestination:(T)=>m((R)=>R&&{...R,destination:T}),setExtractDestination:(T)=>g((R)=>R&&{...R,destination:T}),cancel:()=>{m(null),g(null),F(null)},submitCompress:()=>{let T=x;if(!T)return;v.current="compress",F(null),w({actionType:"compress",format:T.format,name:T.name.trim(),destination:T.destination.trim()||".",paths:JSON.stringify(T.entries.map((R)=>R.path))})},submitExtract:()=>{let T=y;if(!T)return;v.current="extract",F(null),w({actionType:"extract",path:T.archive.path,destination:T.destination.trim()||"."})}}}function wn(t){if(t.shiftKey)return"range";if(t.metaKey||t.ctrlKey)return"toggle";return"plain"}function En(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 qt(t){let[r,l]=n(()=>new Set),[c,p]=n(null),f=a((g,b)=>{if(g==="range"){l(new Set(En(t,c,b)));return}if(p(b),g==="toggle"){l((F)=>{let v=new Set(F);if(v.has(b))v.delete(b);else v.add(b);return v});return}l(new Set([b]))},[c,t]),x=a((g)=>{l((b)=>{if(b.has(g))return b;return new Set([g])}),p(g)},[]),m=a(()=>{l(new Set),p(null)},[]),y=a(wn,[]);return u(()=>({selected:r,count:r.size,anchor:c,gestureOf:y,applyGesture:f,ensureForContext:x,clear:m}),[r,c,y,f,x,m])}function je(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))je(p.children,r,l+1,c);return c}function Qt({listing:t,setExpandedPaths:r,setStoredExpandedPaths:l,reload:c,onMoved:p}){let f=a((y,g)=>{let b=lt(g,y);if(b.length===0)return;r((F)=>{if(b.every((N)=>F.has(N)))return F;let v=new Set(F);for(let N of b)v.add(N);return l(Array.from(v)),v})},[r,l]),x=a((y)=>{let g=t.insertEntry(y);if(!g){c();return}f(y.path,g)},[t,c,f]),m=a((y,g)=>{p?.(y,g),r((F)=>{let v=jt(F,y,g);return l(Array.from(v)),v});let b=t.moveEntry(y,g);if(!b){c();return}f(g,b)},[t,c,f,r,l,p]);return{insertCreated:x,moveRenamed:m}}var Dn=new Set;function Jt({scope:t,setExpandedPaths:r,setStoredExpandedPaths:l}){let[c,p]=n({scope:t,chains:new Map}),f=a((y)=>{let g=Le(y.path,y.name);if(!g)return;p((F)=>{let v=F.scope===t?F.chains:new Map;if(v.get(y.path)?.length===g.length)return F;let w=new Map(v);return w.set(y.path,g),{scope:t,chains:w}});let b=g.slice(0,-1);r((F)=>{if(b.every((N)=>F.has(N)))return F;let v=new Set(F);for(let N of b)v.add(N);return l(Array.from(v)),v})},[t,r,l]),x=a((y)=>{let g=c.scope===t?c.chains.get(y):void 0;if(!g)return;let b=g.slice(0,-1);p((F)=>{if(F.scope!==t)return F;let v=new Map(F.chains);return v.delete(y),{scope:t,chains:v}}),r((F)=>{if(!b.some((N)=>F.has(N)))return F;let v=new Set(F);for(let N of b)v.delete(N);return l(Array.from(v)),v})},[t,c,r,l]),m=a((y,g)=>{let b=c.scope===t?c.chains:null;if(!b)return;let F=new Map,v=[],N=!1;for(let[w,C]of b){if(C.findIndex((R,P)=>R===y&&P>0&&P<C.length-1)!==-1){N=!0;continue}let E=C.map((R)=>R===y?g:R.startsWith(`${y}/`)?`${g}${R.slice(y.length)}`:R),T=E[E.length-1];if(T!==w||E.some((R,P)=>R!==C[P]))N=!0;F.set(T,E),v.push(...E.slice(0,-1))}if(!N)return;p({scope:t,chains:F}),r((w)=>{if(v.every((A)=>w.has(A)))return w;let C=new Set(w);for(let A of v)C.add(A);return l(Array.from(C)),C})},[t,c,r,l]);return{unfolded:c.scope===t&&c.chains.size>0?new Set(c.chains.keys()):Dn,unfold:f,fold:x,rekey:m}}function Zt(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((m)=>m!==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 en({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 bi({className:t="",enabled:r=!0,active:l=!0,rootPath:c,onOpenFile:p,refreshKey:f=0,onRefresh:x}){let[m,y]=S("files.searchQuery",""),[g,b,F]=S("files.expandedPaths",[]),[v,N]=n(()=>new Set(g)),{activeRepo:w,setActiveRepo:C}=vr(c),{repos:A,scanning:E,rescan:T}=kr(c,r),{fileMap:R,folderMap:P,refreshGitStatus:U}=kl(c,w,r),[Y,q]=n(null),te=i(null);o(()=>{if(!F)return;N((O)=>{let re=new Set(g);if(O.size===re.size&&Array.from(re).every((me)=>O.has(me)))return O;return re})},[F,g]);let H=Xt({enabled:r,rootPath:c,activeRepo:w,expandedPaths:v,onExpansionPruned:(O)=>{N(O),b(Array.from(O))}});o(()=>{if(!F||!l)return;H.reload()},[f,c,r,w,F,l]);let z=r&&F?Hh(H.scope):null,L=Se(z);o(()=>{if(L.data)H.adoptRoot(L.data)},[L.data]);let _=(O)=>(U(),H.loadChildren(O)),K=(O,re)=>{let me=new Set(v);if(re)me.add(O);else me.delete(O);N(me),b(Array.from(me))},{unfolded:ie,unfold:B,fold:V,rekey:ne}=Jt({scope:H.scope,setExpandedPaths:N,setStoredExpandedPaths:b}),ae=H.files,he=st(ae,ie),J=Zt(he.nodes,m),fe=je(J,(O)=>O.forceExpanded!==void 0?O.forceExpanded:v.has(O.path)),ce=qt(fe.map((O)=>O.path)),xe=fe.filter((O)=>ce.selected.has(O.path)).map(({path:O,name:re,kind:me})=>({path:O,name:re,kind:me})),M=(O)=>{if(O===w)return;H.reset(),N(new Set),b([]),ce.clear(),C(O)},j=()=>{if(U(),x)x();else H.reload()},{insertCreated:de,moveRenamed:ke}=Qt({listing:H,setExpandedPaths:N,setStoredExpandedPaths:b,reload:j,onMoved:(O,re)=>ne(O,re)}),be=Uo(),{pushToast:W}=Ue(),ee=Vt({rootPath:c,repo:w,onComplete:j,onError:(O)=>W(O,"error")}),Ce=Yt({rootPath:c,repo:w,onComplete:j}),ve={path:".",name:".",kind:"folder"},pe=ee.clip&&!ee.refusalFor(ve)?`Paste ${we(ee.clip)??"item"}`:null,[X,ge]=n(null),ue=en({dragging:X,clipboard:ee,target:ve}),Te=Ne({folderPath:".",rootPath:c,repo:w,onCreated:de,onOpenCreated:(O)=>p?.({...O,root:c,repo:w})}),[We,tn]=n(!1);o(()=>tn(!0),[]);let{count:Xe,clear:Ve}=ce;if(o(()=>{if(!l)return;let O=(re)=>{if(re.key==="Escape"&&Xe>0)Ve()};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[l,Xe,Ve]),!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 nn=H.isLoading||L.refreshing;return e("div",{className:`flex flex-col h-full bg-paper ${t}`,children:[e(Je,{rootPath:c,activeRepo:w,repos:A,reposScanning:E,onRefreshRepos:T,onSelectRepo:M,searchQuery:m,onSearchChange:y,onRefresh:j,refreshing:nn}),e("div",{className:`flex-1 min-h-0 scrollbar-overlay-container p-2 font-mono text-[11px] text-ink/80 ${be?"file-tree-touch":""} ${ue.highlighted?"bg-info/[0.06]":""}`,onContextMenu:(O)=>{O.preventDefault(),q({x:O.clientX,y:O.clientY})},onDragEnter:ue.onDragEnter,onDragLeave:ue.onDragLeave,onDragOver:ue.onDragOver,onDrop:ue.onDrop,children:H.isLoading&&J.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"Loading files..."}):J.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"No files found"}):J.map((O)=>e(Ie,{file:O,rootPath:c,basePath:H.root,repo:w,onLoadChildren:_,onOpenFile:p,onActionComplete:j,onCreated:de,onRenamed:ke,expandedPaths:v,onToggleFolder:K,gitFileMap:R,gitFolderMap:P,clipboard:ee,archive:Ce,selection:ce,selectionTargets:xe,dragging:X,onDragStart:ge,onDragEnd:()=>ge(null),onDropOn:(re)=>{if(!X)return;ee.move(X,re)},onUnfold:B,onFold:V,foldRoots:he.roots,touch:be},O.path))}),e(It,{}),We&&e(St,{menu:Y,menuRef:te,pasteLabel:pe,busy:ee.busy,create:Te,onAction:(O)=>{if(q(null),O==="new_file")Te.openDialog("file");if(O==="new_folder")Te.openDialog("folder");if(O==="paste")ee.paste(ve)}}),We&&e(Lt,{archive:Ce})]})}export{bi as FileExplorer};
|
|
1
|
+
import{d,n,o,i,u,a,Lr,He,se,e,sr,k,Hh,Se,kl,Uo,S,vr,kr,s,Yn,Q,At,I,le,oe,Be,at,_i,yn,Ho,ma,D,G,h,Bt,it,$e,Tt,$d,ut,bt,a0,o0,Wo,xs,zd,Ue}from"./index-4vtc4xct.js";import{Sd,Td,xi,Dd,Nd}from"./index-q1a40v20.js";import{Z}from"./index-2zhmmtye.js";import{yl,Rr}from"./index-sr14vwn5.js";var rn={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"]},Ye=s(rn);var on={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"}]]},qe=s(on);var sn={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"}]]},Qe=s(sn);var an={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"}]]},Re=s(an);function Je({rootPath:t,activeRepo:r,repos:l,reposScanning:c,onRefreshRepos:p,onSelectRepo:f,searchQuery:x,onSearchChange:m,onRefresh:y,refreshing:g}){return e("div",{className:"border-b border-ink/10",children:[e(Bt,{className:"border-b-0",left:e(Rr,{rootPath:t,activeRepo:r,onSelectRepo:f,repos:l,scanning:c,onRefreshRepos:p}),right:e(it,{label:"Refresh",onClick:y,busy:g})}),e("div",{className:"px-3 pb-3",children:e("div",{className:"relative",children:[e(G,{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:(b)=>m(b.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 Ze({name:t,path:r,isFolder:l,isOpen:c,ignored:p,selected:f,gitStatus:x,folderStatus:m}){let y=f?"text-ink font-semibold":x?x.colorClass:m?m.colorClass:p?"text-ink/40":"";return e(d,{children:[l?c?e(I,{size:12,className:"flex-shrink-0 text-ink/40"}):e(le,{size:12,className:"flex-shrink-0 text-ink/40"}):e("span",{className:"w-3 flex-shrink-0"}),e(ut,{name:t,isFolder:l,isOpen:c,size:12,className:`flex-shrink-0${p?" opacity-40":""}`}),e("span",{className:`truncate min-w-0 flex-1 ${y}`,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}),m&&e("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${m.dotClass}`,title:`${m.count} changed file${m.count>1?"s":""}`})]})}var ln=28,cn=9,dn=8;function pn(t){let{isFolder:r,hasGitStatus:l,pasteLabel:c,busy:p,chainLabel:f,foldable:x,selectionCount:m,isArchive:y}=t,g=[],b=m>1,F=m===1?"":` ${m} items`;if(b)return g.push({kind:"item",id:"cut",label:`Cut${F}`,icon:e(Re,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"copy",label:`Copy${F}`,icon:e(oe,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"separator"}),g.push({kind:"item",id:"compress",label:`Compress${F} to…`,icon:e(At,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"separator"}),g.push({kind:"item",id:"delete",label:`Delete${F}`,icon:e(Q,{size:13,className:"text-error-text"}),tone:"text-error-text"}),g;if(r){if(g.push({kind:"item",id:"new_file",label:"New File",icon:e(_i,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"new_folder",label:"New Folder",icon:e(yn,{size:13,className:"text-ink/60"})}),f)g.push({kind:"item",id:"unfold",label:"Unfold Folders",icon:e(I,{size:13,className:"text-ink/60"})});if(x)g.push({kind:"item",id:"fold",label:"Fold Folders",icon:e(le,{size:13,className:"text-ink/60"})});g.push({kind:"separator"})}else{if(g.push({kind:"item",id:"view",label:"View",icon:e(at,{size:13,className:"text-ink/60"})}),y)g.push({kind:"item",id:"extract",label:"Extract…",icon:e(Qe,{size:13,className:"text-ink/60"}),disabled:p});if(l)g.push({kind:"item",id:"diff",label:"Open in Diff Panel",icon:e(Ho,{size:13,className:"text-warning-text"}),tone:"font-medium"});g.push({kind:"separator"})}if(g.push({kind:"item",id:"cut",label:"Cut",icon:e(Re,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"copy",label:"Copy",icon:e(oe,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"compress",label:"Compress to…",icon:e(At,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"duplicate",label:"Duplicate",icon:e(qe,{size:13,className:"text-ink/60"}),disabled:p}),c)g.push({kind:"item",id:"paste",label:c,icon:e(yl,{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(Be,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"copy_path",label:"Copy Path",icon:e(oe,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"copy_relative",label:"Copy Relative Path",icon:e(oe,{size:13,className:"text-ink/60"})}),g.push({kind:"separator"}),g.push({kind:"item",id:"history",label:"Show Git History",icon:e(Yn,{size:13,className:"text-ink/60"})}),g.push({kind:"separator"}),g.push({kind:"item",id:"rename",label:"Rename",icon:e(Ye,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"delete",label:"Delete",icon:e(Q,{size:13,className:"text-error-text"}),tone:"text-error-text"}),g}function un(t){let r=t.filter((c)=>c.kind==="item").length,l=t.length-r;return r*ln+l*cn+dn}function et({x:t,y:r,isFolder:l,hasGitStatus:c,pasteLabel:p,chainLabel:f,foldable:x,busy:m,selectionCount:y,isArchive:g,onAction:b,menuRef:F}){let N=pn({isFolder:l,hasGitStatus:c,pasteLabel:p,busy:m,chainLabel:f,foldable:x,selectionCount:y,isArchive:g}),w=un(N),C=typeof window<"u"?Math.max(10,Math.min(t,window.innerWidth-210-12)):t,A=typeof window<"u"?Math.max(10,Math.min(r,window.innerHeight-w-12)):r;return se(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>b("close"),onContextMenu:(E)=>{E.preventDefault(),b("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:A,left:C},onClick:(E)=>E.stopPropagation(),children:N.map((E,T)=>E.kind==="separator"?e("div",{className:"my-1 border-t border-ink/10"},`sep-${T}`):e("button",{type:"button",disabled:E.disabled,onClick:()=>b(E.id),className:`w-full text-left px-3 py-1.5 flex items-center space-x-2 transition-colors ${E.disabled?"opacity-40 cursor-default":"hover:bg-ink/5"} ${E.tone??""}`,children:[E.icon,e("span",{children:E.label})]},E.id))})}),document.body)}function Fe({folderPath:t,kind:r,value:l,error:c,isLoading:p,onChange:f,onCancel:x,onSubmit:m}){let y=r==="folder"?"Folder":"File";return se(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center modal-safe backdrop-blur-sm",children:e("form",{onSubmit:m,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 ",y]}),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 ${y.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-text 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 tt({fileName:t,displayName:r,isFolder:l,count:c=1,isLoading:p,onCancel:f,onConfirm:x}){let m=c>1;return se(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center modal-safe 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 ",m?`${c} Items`:l?"Folder":"File"]}),e("p",{className:"text-xs text-ink/70 mb-4",children:["Are you sure you want to delete ",m?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 nt({isFolder:t,renameValue:r,originalPath:l,displayName:c,error:p,isLoading:f,onChange:x,onCancel:m,onSubmit:y}){return se(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center modal-safe backdrop-blur-sm",children:e("form",{onSubmit:y,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-text mb-2",children:p}),e("div",{className:"flex justify-end space-x-2",children:[e("button",{type:"button",onClick:m,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 rt({filePath:t,fetcherState:r,fetcherData:l,onClose:c}){let p=l?.type==="history"?l.data:void 0;return se(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center modal-safe 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(Yn,{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(h,{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-text 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 ot({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(tt,{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(nt,{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(rt,{filePath:r.path,fetcherState:t.fetcherState,fetcherData:t.fetcherData,onClose:t.closeHistory})]})}function Ae(t){let r=t.map(fn);return r.some((l,c)=>l!==t[c])?r:t}function fn(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 Me(t){return t.type==="folder"&&t.name.includes("/")}function Le(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 st(t,r){let l=new Map;if(r.size===0)return{nodes:t,roots:l};let c=!1,p=(x)=>x.flatMap((m)=>{if(m.type!=="folder")return[m];let y=Array.isArray(m.children)?p(m.children):m.children,g=y===m.children?m:{...m,children:y},b=r.has(m.path)?Le(m.path,m.name):null;if(!b)return[g];c=!0,l.set(b[0],m.path);let F={...g,name:b[b.length-1].split("/").pop()};for(let v=b.length-1;v>0;v-=1){let N=b[v-1];F={name:N.split("/").pop(),path:N,type:"folder",ignored:g.ignored,children:[F]}}return[F]}),f=p(t);return{nodes:c?f:t,roots:l}}function lt(t,r){let l=new Set,c=(x)=>{for(let m of x){if(m.type!=="folder")continue;if(l.add(m.path),Array.isArray(m.children))c(m.children)}};c(t);let p=r.split("/").slice(0,-1),f=[];for(let x=0;x<p.length;x+=1){let m=p.slice(0,x+1).join("/");if(l.has(m))f.push(m)}return f}function Ne({folderPath:t,rootPath:r,repo:l,onCreated:c,onOpenCreated:p}){let f=bt(),[x,m]=n(!1),[y,g]=n("file"),[b,F]=n(""),[v,N]=n(null),w=i(null);return o(()=>{if(f.state!=="idle"||!f.data)return;let C=f.data;if(w.current===C)return;if(w.current=C,C.success&&C.path){let A=C.kind==="folder"?"folder":"file";m(!1),F(""),N(null);let E=C.path.split("/").pop()||C.path;if(c({path:C.path,name:E,kind:A}),A==="file")p?.({path:C.path,name:E})}else N(C.error||`Could not create the ${y}`)},[f.state,f.data]),{open:x,kind:y,name:b,setName:F,error:v,busy:f.state!=="idle",openDialog:(C="file")=>{g(C),F(""),N(null),m(!0)},closeDialog:()=>m(!1),submit:(C)=>{C.preventDefault();let A=b.trim();if(!A)return;N(null);let E=new FormData;if(E.append("actionType","create"),E.append("path",t),E.append("name",A),y==="folder")E.append("kind","folder");if(l&&l!==".")E.append("repo",l);if(r)E.append("root",r);f.submit(E,{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 ct(t,r){return`${t??""}\x00${r}`}function Oe(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 ft(t,r){let l=pt(t,r);if(l)return l;if(r===dt(t.path))return"Already in this folder";return null}function mt(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 ht(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=mn(p);if(!f)return null;c.push(f)}if(c.length===0)return null;return{scope:r.scope,entries:c,mode:r.mode}}function mn(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 ze=[{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 Pe(t){let r=t.toLowerCase();for(let[l,c]of gt)if(r.endsWith(l))return c;return null}function xt(t){return Pe(t)!==null}function hn(t){return ze.find((r)=>r.id===t)}function gn(t){return hn(t)?.extension??"zip"}function vt(t){let r=t.toLowerCase();for(let[l]of gt)if(r.endsWith(l))return t.slice(0,-l.length);return t}function yt(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)||"."}function kt(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)=>yt(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 Ee(t,r){let l=gn(r);if(t.length===1){let f=t[0],x=vt(f.name),m=x.lastIndexOf(".");return`${(f.kind==="folder"?f.name:m>0?x.slice(0,m):x)||"archive"}.${l}`}let c=Ct(t.map((f)=>f.path)),p=kt(c);return`${p==="."||p===""?"archive":p}.${l}`}function Ft(t){return Ct(t.map((r)=>r.path))}function Nt(t){let r=yt(t),l=vt(kt(t));if(!l)return r;return r==="."?l:`${r}/${l}`}function wt(t){return t.toUpperCase()}function Et({file:t,diff:r,onOpenFile:l,onActionComplete:c,onCreated:p,onRenamed:f,onUnfold:x,onFold:m,clipboard:y,isFolder:g,selection:b,selected:F,archive:v}){let N=bt(),[w,C]=n(null),A=i(null),[E,T]=n(!1),[R,P]=n(!1),[U,Y]=n(!1),[q,te]=n(t.path),[H,z]=n(null),{repo:L,rootPath:_}=t,K=Ne({folderPath:t.path,rootPath:_,repo:L,onCreated:(M)=>p?p(M):c(),onOpenCreated:(M)=>l?.({...M,root:_,repo:L||"."})}),ie=i(null);o(()=>{if(N.state!=="idle"||!N.data)return;let M=N.data;if(ie.current===M)return;if(ie.current=M,M.success&&!M.type)if(T(!1),P(!1),z(null),M.previousPath&&M.path&&f)f(M.previousPath,M.path);else c();else if(!M.success&&M.error&&E)z(M.error)},[N.state,N.data]);let B=(M)=>{if(L&&L!==".")M.append("repo",L);if(_)M.append("root",_);N.submit(M,{method:"post",action:"/api/fs/action"})},V=()=>{l?.({path:t.path,name:t.name,root:_,repo:L||"."})},ne={path:t.path,name:t.name,kind:g?"folder":"file"},ae=F&&b.length>1?b:[ne],he=xt(t.name),J=y.clip&&!y.refusalFor(ne)?`Paste ${we(y.clip)??"item"}`:null,fe=(M)=>{if(C(null),z(null),M==="view")V();else if(M==="diff")window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.path,staged:r?.staged,status:r?.status||"M",repo:L||".",root:_}}));else if(M==="explorer"){let j=new FormData;j.append("actionType","open_explorer"),j.append("path",t.path),B(j)}else if(M==="copy_path")Tt($d(t.basePath,t.path));else if(M==="copy_relative")Tt(t.path);else if(M==="history"){Y(!0);let j=new FormData;j.append("actionType","git_history"),j.append("path",t.path),B(j)}else if(M==="rename")te(t.path),T(!0);else if(M==="unfold")x?.();else if(M==="fold")m?.();else if(M==="new_file")K.openDialog("file");else if(M==="new_folder")K.openDialog("folder");else if(M==="delete")P(!0);else if(M==="cut")y.cut(ae);else if(M==="copy")y.copy(ae);else if(M==="compress")v.openCompress(ae);else if(M==="extract")v.openExtract(ne);else if(M==="duplicate")y.duplicate(ne);else if(M==="paste")y.paste(ne)},ce=(M)=>{M.preventDefault(),z(null);let j=new FormData;j.append("actionType","rename"),j.append("path",t.path),j.append("newPath",q),B(j)},xe=()=>{let M=new FormData;if(M.append("actionType","delete"),ae.length>1)M.append("paths",JSON.stringify(ae.map((j)=>j.path)));else M.append("path",t.path);B(M)};return{contextMenu:w,contextMenuRef:A,openContextMenu:(M,j)=>C({x:M,y:j}),closeContextMenu:()=>C(null),showRenameModal:E,showDeleteModal:R,showHistoryModal:U,showCreateModal:K.open,createKind:K.kind,createError:K.error,createName:K.name,setCreateName:K.setName,renameValue:q,setRenameValue:te,renameError:H,busy:N.state!=="idle"||K.busy||y.busy||v.busy,pasteLabel:J,selectionCount:ae.length,isArchive:he,chainLabel:x!==void 0,foldable:m!==void 0,fetcherState:N.state,fetcherData:N.data,handleAction:fe,submitCreate:K.submit,submitRename:ce,submitDelete:xe,closeCreate:K.closeDialog,closeDelete:()=>P(!1),closeRename:()=>T(!1),closeHistory:()=>Y(!1)}}function Dt({target:t,dragging:r,clipboard:l,onDragStart:c,onDragEnd:p,onDropOn:f,onHoverAccept:x}){let m=r?.path===t.path,y=Boolean(r)&&!m&&l.moveRefusalFor(r,t)===null,[g,b]=n(!1);return o(()=>{if(!r)b(!1)},[r]),{isDragging:m,acceptsDrop:y,isDropHovered:g&&y,onDragStart:(v)=>{if(v.dataTransfer?.setData("text/plain",t.path),v.dataTransfer)v.dataTransfer.effectAllowed="move";c(t)},onDragEnd:p,onDragOver:(v)=>{if(!r)return;if(v.stopPropagation(),b(y),!y)return;if(v.preventDefault(),v.dataTransfer)v.dataTransfer.dropEffect="move";x?.(t)},onDragLeave:()=>b(!1),onDrop:(v)=>{if(!r)return;if(v.stopPropagation(),!y)return;v.preventDefault(),f(t)}}}function bn(t,r,l){if(r||l)return!1;return!Array.isArray(t.children)}function Ie({file:t,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:x,onCreated:m,onRenamed:y,expandedPaths:g,onToggleFolder:b,gitFileMap:F,gitFolderMap:v,clipboard:N,archive:w,selection:C,selectionTargets:A,dragging:E,onDragStart:T,onDragEnd:R,onDropOn:P,onUnfold:U,onFold:Y,foldRoots:q,touch:te=!1}){let H=t.type==="folder",[z,L]=n(!1),[_,K]=n(!1),[ie,B]=n(!1),[V,ne]=n(!1),ae=Array.isArray(t.children)?t.children:[],he=(t.path||"").replace(/^\/+/,""),J=!H?F?.get(he)||F?.get(t.path):void 0,fe=J?sr(J.status,J.staged):null,ce=H?v?.get(he)||v?.get(t.path):null,xe=Boolean(fe),M=t.ignored===!0,j=g?g.has(t.path):z,de=t.forceExpanded!==void 0?t.forceExpanded:j;o(()=>{ne(!0)},[]),o(()=>{if(H&&g)L(g.has(t.path))},[g,t.path,H]),o(()=>{if(H&&de&&bn(t,_,ie)&&p)B(!0),K(!0),Promise.resolve(p(t.path)).finally(()=>K(!1))},[H,de,t.children,t.path,p,_,ie]);let ke={path:t.path,name:t.name,kind:H?"folder":"file"},be=C.selected.has(t.path),W=Et({file:{path:t.path,name:t.name,basePath:l,rootPath:r,repo:c},selection:A,selected:be,archive:w,diff:{staged:J?.staged||(J?.status?J.status[0]!==" "&&J.status[0]!=="?":!1),status:fe?.charStatus},onOpenFile:f,onActionComplete:x,onCreated:m,onRenamed:y,onUnfold:U&&Me({type:H?"folder":"file",name:t.name})?()=>U(ke):void 0,onFold:Y&&q?.has(t.path)?()=>Y(q.get(t.path)):void 0,clipboard:N,isFolder:H});$e(W.contextMenuRef,W.closeContextMenu);let ee=Sd({enabled:te,onLongPress:(X,ge)=>W.openContextMenu(X,ge)}),Ce=(X)=>{if(X.stopPropagation(),ee.consume())return;let ge=C.gestureOf(X);if(ge!=="plain"){C.applyGesture(ge,t.path);return}if(C.applyGesture("plain",t.path),H){let ue=!de;if(L(ue),t.forceExpanded!==void 0)t.forceExpanded=void 0;if(b?.(t.path,ue),!ue)B(!1)}else if(f)f({...t,root:r,repo:c||"."})},ve=(X)=>{X.preventDefault(),X.stopPropagation(),C.ensureForContext(t.path),W.openContextMenu(X.clientX,X.clientY)},pe=Dt({target:ke,dragging:E,clipboard:N,onDragStart:T,onDragEnd:R,onDropOn:P,onHoverAccept:U});return e("div",{children:[e("div",{className:`flex items-center space-x-1.5 py-1 px-2 cursor-pointer rounded group select-none ${pe.isDragging?"opacity-40":""} ${pe.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:!te,onClick:Ce,onContextMenu:ve,onDragStart:pe.onDragStart,onDragEnd:pe.onDragEnd,onDragOver:pe.onDragOver,onDragLeave:pe.onDragLeave,onDrop:pe.onDrop,onTouchStart:ee.onTouchStart,onTouchMove:ee.onTouchMove,onTouchEnd:ee.onTouchEnd,onTouchCancel:ee.onTouchCancel,children:e(Ze,{name:t.name,path:t.path,isFolder:H,isOpen:de,ignored:M,selected:be,gitStatus:fe,folderStatus:ce})}),de&&_&&e("div",{className:"ml-3 border-l border-ink/10 pl-3 py-0.5 text-[10px] text-ink/30",children:"Loading…"}),de&&!_&&ae.length>0&&e("div",{className:"ml-3 border-l border-ink/10 pl-1",children:ae.map((X)=>e(Ie,{file:X,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:x,onCreated:m,onRenamed:y,expandedPaths:g,onToggleFolder:b,gitFileMap:F,gitFolderMap:v,clipboard:N,archive:w,selection:C,selectionTargets:A,dragging:E,onDragStart:T,onDragEnd:R,onDropOn:P,onUnfold:U,onFold:Y,foldRoots:q,touch:te},X.path))}),V&&W.contextMenu&&e(et,{x:W.contextMenu.x,y:W.contextMenu.y,isFolder:H,hasGitStatus:xe,pasteLabel:W.pasteLabel,chainLabel:W.chainLabel,foldable:W.foldable,busy:W.busy,selectionCount:W.selectionCount,isArchive:W.isArchive,onAction:W.handleAction}),V&&e(ot,{actions:W,file:t,isFolder:H,chainLabel:Me({type:H?"folder":"file",name:t.name})?t.name:void 0})]})}function Rt({x:t,y:r,pasteLabel:l,busy:c,onAction:p,menuRef:f}){let m=l?104:76,y=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-m-12)):r;return se(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>p("close"),onContextMenu:(b)=>{b.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:y},onClick:(b)=>b.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(_i,{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(yn,{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(yl,{size:13,className:"text-ink/60"}),e("span",{children:l})]})]})}),document.body)}function St({menu:t,menuRef:r,pasteLabel:l,busy:c,onAction:p,create:f}){return e(d,{children:[t&&e(Rt,{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 Mt({title:t,subject:r,error:l,busy:c,submitLabel:p,busyLabel:f,onSubmit:x,onCancel:m,children:y}){return se(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center modal-safe 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}),y,l&&e("p",{className:"text-[11px] text-error-text mb-2",children:l}),e("div",{className:"flex justify-end space-x-2 mt-3",children:[e("button",{type:"button",onClick:m,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 xn({entries:t,format:r,name:l,destination:c,formats:p,error:f,busy:x,onFormatChange:m,onNameChange:y,onDestinationChange:g,onCancel:b,onSubmit:F}){let v=t.slice(0,4).map((w)=>w.name).join(", "),N=t.length>4?` +${t.length-4} more`:"";return e(Mt,{title:`Compress ${t.length===1?t[0].name:`${t.length} items`}`,subject:`${v}${N}`,error:f,busy:x,submitLabel:"Compress",busyLabel:"Compressing...",onCancel:b,onSubmit:(w)=>{w.preventDefault(),F()},children:[e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",children:"Format"}),e(Z,{ariaLabel:"Format",value:r,onChange:(w)=>m(w),placeholder:"Format",searchable:!1,allowEmpty:!1,className:"mb-3 text-xs",options:p.map((w)=>({value:w.id,label:w.available?w.label:`${w.label} — ${w.tool} not installed`,disabled:!w.available}))}),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:(w)=>y(w.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:(w)=>g(w.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 vn({archive:t,kindLabel:r,destination:l,error:c,busy:p,onDestinationChange:f,onCancel:x,onSubmit:m}){return e(Mt,{title:`Extract ${t.name}`,subject:`${r} archive · extracts into a folder`,error:c,busy:p,submitLabel:"Extract",busyLabel:"Extracting...",onCancel:x,onSubmit:(y)=>{y.preventDefault(),m()},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:(y)=>f(y.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 Lt({archive:t}){if(t.compress)return e(xn,{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(vn,{archive:t.extract.archive,kindLabel:wt(Pe(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}var Ot=240,zt=96;var $t=32;function ye(t){let r=Number.isFinite(t)&&t>0?t:840;return Math.max(96,Math.min(640,Math.round(r-200)))}function De(t,r=640){let l=Math.max(96,Math.min(640,r));if(!Number.isFinite(t))return Math.min(240,l);return Math.min(l,Math.max(96,Math.round(t)))}function Pt(t){let[r,l]=S("files.outlineHeight",Ot),[c,p]=n(null),f=i(null),[x,m]=n(ye(0)),[y,g]=n(!1),b=i(null);o(()=>{let w=t.current?.parentElement;if(!w)return;let C=()=>m(ye(w.clientHeight));if(C(),typeof ResizeObserver>"u")return;let A=new ResizeObserver(C);return A.observe(w),()=>A.disconnect()},[t]),o(()=>()=>b.current?.(),[]);let F=De(c??r,x);return{height:F,max:x,resizing:y,onPointerDown:(w)=>{if(w.button!==0)return;let C=ye(t.current?.parentElement?.clientHeight??0);m(C);let A=w.clientY,E=F;w.preventDefault(),g(!0);let T=document.body.style.cursor,R=document.body.style.userSelect;document.body.style.cursor="row-resize",document.body.style.userSelect="none";let P=E,U=0,Y=(z)=>{if(P=De(E-(z.clientY-A),C),U!==0)return;U=requestAnimationFrame(()=>{U=0,f.current=P,p(P)})},q=(z)=>{if(window.removeEventListener("pointermove",Y),window.removeEventListener("pointerup",te),window.removeEventListener("pointercancel",H),U!==0)cancelAnimationFrame(U);if(U=0,b.current=null,document.body.style.cursor=T,document.body.style.userSelect=R,g(!1),z&&P!==E)l(P);f.current=null,p(null)},te=()=>q(!0),H=()=>q(!1);window.addEventListener("pointermove",Y),window.addEventListener("pointerup",te),window.addEventListener("pointercancel",H),b.current=()=>q(!1)},onKeyDown:(w)=>{let C=w.key==="ArrowUp"?1:w.key==="ArrowDown"?-1:0;if(C===0)return;w.preventDefault();let A=ye(t.current?.parentElement?.clientHeight??0);m(A),l(De(F+C*$t,A))}}}function It(){let[t,r]=S("files.outlineExpanded",!1),l=Lr(),c=i(null),p=Pt(c),f=He(o0,a0),{symbols:x,total:m,truncated:y,notice:g}=Nd({content:f.content,language:f.language,state:f.state,note:f.note,path:f.path});if(f.state==="diff")return null;let b=f.preview,F=(v,N)=>{if(!f.path)return;if(b){let w=zd(x,N);if(w)xs({path:f.path,...w});return}Wo({path:f.path,line:v.line,column:v.column,length:v.name.length})};return e("div",{ref:c,className:"border-t border-ink/10 bg-canvas/30 flex-shrink-0",children:[e("div",{role:"separator","aria-orientation":"horizontal","aria-label":"Resize outline","aria-valuemin":zt,"aria-valuemax":p.max,"aria-valuenow":p.height,title:"Drag to resize the outline",tabIndex:0,onPointerDown:(v)=>{if(!t)r(!0);p.onPointerDown(v)},onKeyDown:(v)=>{if(!t)r(!0);p.onKeyDown(v)},className:"group flex h-3 w-full cursor-row-resize touch-none items-center justify-center outline-none focus-visible:bg-ink/5",children:e("span",{"aria-hidden":"true",className:`h-0.5 w-6 rounded-full transition-colors ${p.resizing?"bg-ink/50":"bg-ink/20 group-hover:bg-ink/40"}`})}),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(ma,{size:12}),e("span",{children:"Outline"}),m>0&&e("span",{className:"font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[10px] text-ink/50",children:y?`${x.length}/${m.toLocaleString()}`:m})]})}),e("div",{className:"section-reveal","data-expanded":t,id:l,inert:!t,children:e("div",{children:e("div",{className:"px-2 pb-2",children:x.length===0?e("div",{className:"px-1 text-[10px] text-ink/40 italic py-1",children:g}):e("div",{className:"overflow-y-auto scrollbar-overlay-container flex flex-col",style:{height:`${p.height}px`},children:[x.map((v,N)=>e("button",{type:"button",onClick:()=>F(v,N),"aria-label":b?`${xi(v.kind)} ${v.name}`:`${xi(v.kind)} ${v.name}, line ${v.line}`,title:b?`Jump to ${xi(v.kind).toLowerCase()}`:`${xi(v.kind)} · line ${v.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+v.depth*12}px`},children:[e(Td,{kind:v.kind}),e("span",{className:"min-w-0 flex-1 truncate text-[11px] font-mono text-ink/80",children:v.name}),!b&&e("span",{className:"flex-shrink-0 font-mono text-[10px] text-ink/35",children:v.line})]},`${v.line}:${v.kind}:${v.name}`)),y&&e("div",{className:"px-1 py-1 text-[10px] italic text-ink/40",children:Dd(m)})]})})})})]})}function _e(t,r){return Ae(t.map((l)=>kn(l,r)))}function kn(t,r){if(t.type!=="folder")return t;let l=r[t.path];if(!l)return t;return{...t,children:_e(l,r)}}function Cn(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 Ht(t){return[...t].sort((r,l)=>{if(r.type!==l.type)return r.type==="folder"?-1:1;return r.name.localeCompare(l.name)})}function Ge(t,r,l){let c=l.path.split("/"),p=c.slice(0,-1).join("/"),f=[...t],x={...r},m=f,y=null;for(let g=0;g<c.length-1;){let b=c.slice(0,g+1).join("/"),F=m.find((A)=>A.type==="folder"&&A.path===b),v=F?null:m.find((A)=>A.type==="folder"&&A.path.startsWith(`${b}/`)&&(p===A.path||p.startsWith(`${A.path}/`))),N=F??v,w=N?x[N.path]??N.children:null;if(N&&!Array.isArray(w))return{nodes:t,cache:r};if(!N){let A=Fn(m,x,b);if(A){m=A;let E=m.find((R)=>R.path===b),T=Array.isArray(E?.children)?[...E.children]:[];x[b]=T,m=T,y=b,g+=1;continue}}let C=Array.isArray(w)?[...w]:[];if(N){x[N.path]=C,m=C,y=N.path,g=N.path.split("/").length;continue}m.push({name:c[g],path:b,type:"folder",ignored:!1}),x[b]=C,m=C,y=b,g+=1}if(m.push(l),y!==null)x[y]=Ht(m);return f=Ht(f),{nodes:f,cache:x}}function Fn(t,r,l){let c=t.findIndex((y)=>y.type==="folder"&&y.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 m={name:f[f.length-1],path:p.path,type:"folder",ignored:p.ignored,...Array.isArray(x)?{children:x}:{}};for(let y=f.length-2;y>=0;y-=1)m={name:f[y],path:`${l}/${f.slice(0,y+1).join("/")}`,type:"folder",ignored:!1,children:[m]};return t[c]={name:_t(l),path:l,type:"folder",ignored:!1,children:[m]},t}function Gt(t,r,l){let c=t.find((b)=>b.path===l);if(c)return{entry:c,nodes:t.filter((b)=>b.path!==l),cache:r};let p=Cn(l),f=r[p],x=f?.find((b)=>b.path===l);if(f&&x)return{entry:x,nodes:t,cache:{...r,[p]:f.filter((b)=>b.path!==l)}};let y=Object.keys(r).filter((b)=>l.startsWith(`${b}/`)&&r[b].some((F)=>F.path===l)).sort((b,F)=>F.length-b.length)[0];if(!y)return{entry:null,nodes:t,cache:r};let g=r[y];return{entry:g.find((b)=>b.path===l),nodes:t,cache:{...r,[y]:g.filter((b)=>b.path!==l)}}}function Kt(t,r,l){let c=!1,p=t.map((f)=>{let x=f.path===r||f.path.startsWith(`${r}/`),m=Array.isArray(f.children)?Kt(f.children,r,l):void 0;if(!x&&m===f.children)return f;c=!0;let y=x?f.path===r?l:`${l}${f.path.slice(r.length)}`:f.path,g=x?{...f,path:y,name:_t(y)}:{...f};if(m!==void 0)g.children=m;return g});return c?p:t}function Ut(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:Kt(f,r,l)}return c}function jt(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 Wt(t){if(!k(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)=>k(r)):[],root:t.root}}async function Ke(t){try{return Wt(await(await fetch(t)).json())}catch{return{status:"failed"}}}function Xt({enabled:t,rootPath:r,activeRepo:l,expandedPaths:c,onExpansionPruned:p}){let f=`${r??""}\x00${l}`,[x,m]=n({scope:"",files:[],root:""}),[y,g]=n(!1),b=i({}),F=i([]),v=i(f);v.current=f;let N=i(""),w=i(""),C=i(c);C.current=c;let A=(z)=>{let L=new URLSearchParams;if(r)L.set("root",r);if(l&&l!==".")L.set("repo",l);if(z)L.set("path",z);return L.set("t",String(Date.now())),`/api/fs/dir?${L.toString()}`},E=(z,L)=>{N.current=z,w.current=L;let _=_e(F.current,b.current);return m({scope:z,files:_,root:L}),_},T=async(z)=>{let L=[...C.current];if(L.length===0)return;let _=await Promise.all(L.map(async(V)=>({path:V,read:await Ke(A(V))})));if(v.current!==z)return;let K=[];for(let{path:V,read:ne}of _)if(ne.status==="ok")b.current[V]=ne.files;else if(ne.status==="missing")K.push(V);if(K.length===0)return;let ie=new Set(K);for(let V of K)delete b.current[V];let B=new Set([...C.current].filter((V)=>!ie.has(V)));C.current=B,p(B)},R=async()=>{if(!t)return;let z=v.current;g(!0);try{let L=await Ke(A());if(v.current!==z)return;if(L.status!=="ok")return;if(N.current!==z)b.current={};if(F.current=L.files,E(z,L.root),await T(z),v.current!==z)return;E(z,L.root)}finally{if(v.current===z)g(!1)}},P=async(z)=>{let L=v.current,_=await Ke(A(z));if(v.current!==L||_.status!=="ok")return;if(b.current[z]=_.files,N.current===L)E(L,w.current)},U=(z)=>{let L=Wt(z);if(L.status!=="ok")return;let _=v.current;if(N.current!==_)b.current={};F.current=L.files,E(_,L.root),T(_).then(()=>{if(v.current===_)E(_,L.root)})},Y=()=>{b.current={},F.current=[],N.current="",w.current="",m({scope:"",files:[],root:""})},q=(z)=>{let L=v.current;if(N.current!==L)return null;let _={name:z.path.slice(z.path.lastIndexOf("/")+1),path:z.path,type:z.kind,ignored:!1},K=Ge(F.current,b.current,_);if(K.nodes===F.current)return null;return F.current=K.nodes,b.current=K.cache,E(L,w.current)},te=(z,L)=>{let _=v.current;if(N.current!==_)return null;let K=Gt(F.current,b.current,z);if(!K.entry)return null;b.current=Ut(K.cache,z,L);let ie={...K.entry,path:L,name:L.slice(L.lastIndexOf("/")+1)},B=Ge(K.nodes,b.current,ie);return F.current=B.nodes,b.current=B.cache,E(_,w.current)},H=x.scope===f;return{scope:f,files:H?x.files:[],root:H?x.root:"",isLoading:y,reload:R,loadChildren:P,adoptRoot:U,insertEntry:q,moveEntry:te,reset:Y}}function Vt({rootPath:t,repo:r,onComplete:l,onError:c}){let p=bt(),[f,x]=S("files.clipboard",null),m=ht(f),y=ct(t,r),g=i(!1),b=i(null);o(()=>{if(p.state!=="idle"||!p.data)return;let C=p.data;if(b.current===C)return;b.current=C;let A=g.current;if(g.current=!1,C.success){if(A)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 F=a((C,A)=>{g.current=A;let E=new FormData;for(let[T,R]of Object.entries(C))E.append(T,R);if(r&&r!==".")E.append("repo",r);if(t)E.append("root",t);p.submit(E,{method:"post",action:"/api/fs/action"})},[p,r,t]),v=a((C)=>mt(m,y,Oe(C.path,C.kind)),[m,y]),N=a((C,A)=>ft(C,Oe(A.path,A.kind)),[]),w=a((C,A,E,T)=>{let R=new FormData;R.append("actionType","paste"),R.append("mode",E),R.append("targetPath",A.path),R.append("targetKind",A.kind);for(let P of C)R.append("sourcePath",P.path);if(r&&r!==".")R.append("repo",r);if(t)R.append("root",t);g.current=T,p.submit(R,{method:"post",action:"/api/fs/action"})},[p,r,t]);return{clip:m,busy:p.state!=="idle",refusalFor:v,moveRefusalFor:N,copy:(C)=>{if(C.length===0)return;x({scope:y,entries:C.map(({path:A,name:E,kind:T})=>({path:A,name:E,kind:T})),mode:"copy"})},cut:(C)=>{if(C.length===0)return;x({scope:y,entries:C.map(({path:A,name:E,kind:T})=>({path:A,name:E,kind:T})),mode:"cut"})},duplicate:(C)=>{F({actionType:"duplicate",path:C.path},!1)},move:(C,A)=>{let E=N(C,A);if(E){c(E);return}w([C],A,"cut",Boolean(m?.mode==="cut"&&m.entries.some((T)=>T.path===C.path)))},paste:(C)=>{if(!m)return;let A=v(C);if(A){c(A);return}w(m.entries.map(({path:E,name:T,kind:R})=>({path:E,name:T,kind:R})),C,m.mode,m.mode==="cut")}}}var Nn=ze.map((t)=>({...t,available:!0,tool:t.id}));function Yt({rootPath:t,repo:r,onComplete:l}){let c=bt(),[p,f]=n(Nn),[x,m]=n(null),[y,g]=n(null),[b,F]=n(null),v=i(null),N=i(null);o(()=>{let T=!1;return(async()=>{try{let P=await(await fetch("/api/fs/archive")).json();if(!T&&Array.isArray(P.formats)&&P.formats.length>0)f(P.formats)}catch{}})(),()=>{T=!0}},[]),o(()=>{if(c.state!=="idle"||!c.data)return;let T=c.data;if(N.current===T)return;N.current=T;let R=v.current;if(v.current=null,T.success){if(F(null),R==="compress")m(null);if(R==="extract")g(null);l()}else if(R)F(T.error||"The archive request failed")},[c.state,c.data]);let w=a((T)=>{let R=new FormData;for(let[P,U]of Object.entries(T))R.append(P,U);if(r&&r!==".")R.append("repo",r);if(t)R.append("root",t);c.submit(R,{method:"post",action:"/api/fs/action"})},[c,r,t]),C=a((T)=>{if(T.length===0)return;let R=p.find((P)=>P.id==="zip"&&P.available)?.id??p.find((P)=>P.available)?.id??"zip";F(null),g(null),m({entries:T.map(({path:P,name:U,kind:Y})=>({path:P,name:U,kind:Y})),format:R,name:Ee(T,R),destination:Ft(T)})},[p]),A=a((T)=>{F(null),m(null),g({archive:T,destination:Nt(T.path)})},[]),E=a((T)=>{m((R)=>{if(!R)return R;let P=Ee(R.entries,R.format),U=R.name===P?Ee(R.entries,T):R.name;return{...R,format:T,name:U}})},[]);return{formats:p,compress:x,extract:y,error:b,busy:c.state!=="idle",openCompress:C,openExtract:A,setFormat:E,setName:(T)=>m((R)=>R&&{...R,name:T}),setCompressDestination:(T)=>m((R)=>R&&{...R,destination:T}),setExtractDestination:(T)=>g((R)=>R&&{...R,destination:T}),cancel:()=>{m(null),g(null),F(null)},submitCompress:()=>{let T=x;if(!T)return;v.current="compress",F(null),w({actionType:"compress",format:T.format,name:T.name.trim(),destination:T.destination.trim()||".",paths:JSON.stringify(T.entries.map((R)=>R.path))})},submitExtract:()=>{let T=y;if(!T)return;v.current="extract",F(null),w({actionType:"extract",path:T.archive.path,destination:T.destination.trim()||"."})}}}function wn(t){if(t.shiftKey)return"range";if(t.metaKey||t.ctrlKey)return"toggle";return"plain"}function En(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 qt(t){let[r,l]=n(()=>new Set),[c,p]=n(null),f=a((g,b)=>{if(g==="range"){l(new Set(En(t,c,b)));return}if(p(b),g==="toggle"){l((F)=>{let v=new Set(F);if(v.has(b))v.delete(b);else v.add(b);return v});return}l(new Set([b]))},[c,t]),x=a((g)=>{l((b)=>{if(b.has(g))return b;return new Set([g])}),p(g)},[]),m=a(()=>{l(new Set),p(null)},[]),y=a(wn,[]);return u(()=>({selected:r,count:r.size,anchor:c,gestureOf:y,applyGesture:f,ensureForContext:x,clear:m}),[r,c,y,f,x,m])}function je(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))je(p.children,r,l+1,c);return c}function Qt({listing:t,setExpandedPaths:r,setStoredExpandedPaths:l,reload:c,onMoved:p}){let f=a((y,g)=>{let b=lt(g,y);if(b.length===0)return;r((F)=>{if(b.every((N)=>F.has(N)))return F;let v=new Set(F);for(let N of b)v.add(N);return l(Array.from(v)),v})},[r,l]),x=a((y)=>{let g=t.insertEntry(y);if(!g){c();return}f(y.path,g)},[t,c,f]),m=a((y,g)=>{p?.(y,g),r((F)=>{let v=jt(F,y,g);return l(Array.from(v)),v});let b=t.moveEntry(y,g);if(!b){c();return}f(g,b)},[t,c,f,r,l,p]);return{insertCreated:x,moveRenamed:m}}var Dn=new Set;function Jt({scope:t,setExpandedPaths:r,setStoredExpandedPaths:l}){let[c,p]=n({scope:t,chains:new Map}),f=a((y)=>{let g=Le(y.path,y.name);if(!g)return;p((F)=>{let v=F.scope===t?F.chains:new Map;if(v.get(y.path)?.length===g.length)return F;let w=new Map(v);return w.set(y.path,g),{scope:t,chains:w}});let b=g.slice(0,-1);r((F)=>{if(b.every((N)=>F.has(N)))return F;let v=new Set(F);for(let N of b)v.add(N);return l(Array.from(v)),v})},[t,r,l]),x=a((y)=>{let g=c.scope===t?c.chains.get(y):void 0;if(!g)return;let b=g.slice(0,-1);p((F)=>{if(F.scope!==t)return F;let v=new Map(F.chains);return v.delete(y),{scope:t,chains:v}}),r((F)=>{if(!b.some((N)=>F.has(N)))return F;let v=new Set(F);for(let N of b)v.delete(N);return l(Array.from(v)),v})},[t,c,r,l]),m=a((y,g)=>{let b=c.scope===t?c.chains:null;if(!b)return;let F=new Map,v=[],N=!1;for(let[w,C]of b){if(C.findIndex((R,P)=>R===y&&P>0&&P<C.length-1)!==-1){N=!0;continue}let E=C.map((R)=>R===y?g:R.startsWith(`${y}/`)?`${g}${R.slice(y.length)}`:R),T=E[E.length-1];if(T!==w||E.some((R,P)=>R!==C[P]))N=!0;F.set(T,E),v.push(...E.slice(0,-1))}if(!N)return;p({scope:t,chains:F}),r((w)=>{if(v.every((A)=>w.has(A)))return w;let C=new Set(w);for(let A of v)C.add(A);return l(Array.from(C)),C})},[t,c,r,l]);return{unfolded:c.scope===t&&c.chains.size>0?new Set(c.chains.keys()):Dn,unfold:f,fold:x,rekey:m}}function Zt(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((m)=>m!==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 en({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 bi({className:t="",enabled:r=!0,active:l=!0,rootPath:c,onOpenFile:p,refreshKey:f=0,onRefresh:x}){let[m,y]=S("files.searchQuery",""),[g,b,F]=S("files.expandedPaths",[]),[v,N]=n(()=>new Set(g)),{activeRepo:w,setActiveRepo:C}=vr(c),{repos:A,scanning:E,rescan:T}=kr(c,r),{fileMap:R,folderMap:P,refreshGitStatus:U}=kl(c,w,r),[Y,q]=n(null),te=i(null);o(()=>{if(!F)return;N((O)=>{let re=new Set(g);if(O.size===re.size&&Array.from(re).every((me)=>O.has(me)))return O;return re})},[F,g]);let H=Xt({enabled:r,rootPath:c,activeRepo:w,expandedPaths:v,onExpansionPruned:(O)=>{N(O),b(Array.from(O))}});o(()=>{if(!F||!l)return;H.reload()},[f,c,r,w,F,l]);let z=r&&F?Hh(H.scope):null,L=Se(z);o(()=>{if(L.data)H.adoptRoot(L.data)},[L.data]);let _=(O)=>(U(),H.loadChildren(O)),K=(O,re)=>{let me=new Set(v);if(re)me.add(O);else me.delete(O);N(me),b(Array.from(me))},{unfolded:ie,unfold:B,fold:V,rekey:ne}=Jt({scope:H.scope,setExpandedPaths:N,setStoredExpandedPaths:b}),ae=H.files,he=st(ae,ie),J=Zt(he.nodes,m),fe=je(J,(O)=>O.forceExpanded!==void 0?O.forceExpanded:v.has(O.path)),ce=qt(fe.map((O)=>O.path)),xe=fe.filter((O)=>ce.selected.has(O.path)).map(({path:O,name:re,kind:me})=>({path:O,name:re,kind:me})),M=(O)=>{if(O===w)return;H.reset(),N(new Set),b([]),ce.clear(),C(O)},j=()=>{if(U(),x)x();else H.reload()},{insertCreated:de,moveRenamed:ke}=Qt({listing:H,setExpandedPaths:N,setStoredExpandedPaths:b,reload:j,onMoved:(O,re)=>ne(O,re)}),be=Uo(),{pushToast:W}=Ue(),ee=Vt({rootPath:c,repo:w,onComplete:j,onError:(O)=>W(O,"error")}),Ce=Yt({rootPath:c,repo:w,onComplete:j}),ve={path:".",name:".",kind:"folder"},pe=ee.clip&&!ee.refusalFor(ve)?`Paste ${we(ee.clip)??"item"}`:null,[X,ge]=n(null),ue=en({dragging:X,clipboard:ee,target:ve}),Te=Ne({folderPath:".",rootPath:c,repo:w,onCreated:de,onOpenCreated:(O)=>p?.({...O,root:c,repo:w})}),[We,tn]=n(!1);o(()=>tn(!0),[]);let{count:Xe,clear:Ve}=ce;if(o(()=>{if(!l)return;let O=(re)=>{if(re.key==="Escape"&&Xe>0)Ve()};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[l,Xe,Ve]),!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 nn=H.isLoading||L.refreshing;return e("div",{className:`flex flex-col h-full bg-paper ${t}`,children:[e(Je,{rootPath:c,activeRepo:w,repos:A,reposScanning:E,onRefreshRepos:T,onSelectRepo:M,searchQuery:m,onSearchChange:y,onRefresh:j,refreshing:nn}),e("div",{className:`flex-1 min-h-0 scrollbar-overlay-container p-2 font-mono text-[11px] text-ink/80 ${be?"file-tree-touch":""} ${ue.highlighted?"bg-info/[0.06]":""}`,onContextMenu:(O)=>{O.preventDefault(),q({x:O.clientX,y:O.clientY})},onDragEnter:ue.onDragEnter,onDragLeave:ue.onDragLeave,onDragOver:ue.onDragOver,onDrop:ue.onDrop,children:H.isLoading&&J.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"Loading files..."}):J.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"No files found"}):J.map((O)=>e(Ie,{file:O,rootPath:c,basePath:H.root,repo:w,onLoadChildren:_,onOpenFile:p,onActionComplete:j,onCreated:de,onRenamed:ke,expandedPaths:v,onToggleFolder:K,gitFileMap:R,gitFolderMap:P,clipboard:ee,archive:Ce,selection:ce,selectionTargets:xe,dragging:X,onDragStart:ge,onDragEnd:()=>ge(null),onDropOn:(re)=>{if(!X)return;ee.move(X,re)},onUnfold:B,onFold:V,foldRoots:he.roots,touch:be},O.path))}),e(It,{}),We&&e(St,{menu:Y,menuRef:te,pasteLabel:pe,busy:ee.busy,create:Te,onAction:(O)=>{if(q(null),O==="new_file")Te.openDialog("file");if(O==="new_folder")Te.openDialog("folder");if(O==="paste")ee.paste(ve)}}),We&&e(Lt,{archive:Ce})]})}export{bi as FileExplorer};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d,n,o,i,a,e,s,B,ae,Re,Ne,E,Bi,rt,Oe,Le,h,J,Pi,bg}from"./index-95jfphx5.js";var F={name:"list-filter",size:24,node:[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]]},I=s(F);function T({title:t,options:r,methodLabel:c,badge:m,icon:x,onCancel:b}){let f=Pi({title:t,options:r})?bg(t):null,v=f?`Allow ${f.tool}`:t||c;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:v}),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(Ne,{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:b,"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(h,{size:14})})]})}function S({options:t,optionDetails:r,selectedOption:c,customValue:m,onCustomChange:x,customInputRef:b,onSelect:f,onConfirmOption:v,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=c===k,g=r[y]?.description;return e("button",{type:"button",onClick:()=>f(k),onDblClick:()=>v(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})}),g&&e("div",{className:"mt-1 text-[11.5px] leading-relaxed text-ink/55",children:g})]}),e("span",{className:"mt-0.5 shrink-0",children:u?e(ae,{size:16,className:"text-ink"}):e(Bi,{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:b,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())v(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 P({method:t,optionsLength:r,selectedOption:c,hasCustomAnswer:m=!1,onCancel:x,onSubmit:b}){let f=t==="select"&&!c&&!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(h,{size:12,className:"opacity-60"}),e("span",{children:"Cancel"})]}),e("button",{type:"button",onClick:b,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 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 R({title:t,options:r}){let c=Pi({title:t,options:r})?bg(t):null;if(!c)return null;return e("div",{className:"space-y-2",children:[c.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(E,{size:13,className:"mt-0.5 shrink-0 text-warning-text"}),e("span",{className:"min-w-0 break-words",children:c.reason})]}),c.details.length>0&&e("div",{className:"rounded-xl border border-ink/10 bg-canvas/40 px-3.5 py-2.5",children:c.details.map((m,x)=>e("div",{className:"font-mono text-[11.5px] leading-relaxed text-ink/75 break-all",children:m},`${x}-${m}`))})]})}function L({method:t,options:r,selectedOption:c,onSelectOption:m,customInputRef:x,onSubmit:b,onCancel:f}){o(()=>{let v=(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===c),g=u<r.length-1?u+1:0;m(r[g]);return}if(l.key==="ArrowUp"){l.preventDefault();let u=r.findIndex((N)=>N===c),g=u>0?u-1:r.length-1;m(r[g]);return}if(l.key==="Enter"&&c){l.preventDefault(),b();return}}if(t==="confirm"){if(l.key==="Enter"){l.preventDefault(),b();return}}if(t==="editor"){if((l.metaKey||l.ctrlKey)&&l.key==="Enter"){l.preventDefault(),b();return}}};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[f,b,t,r,c,m,x])}function z(t,r){switch(t){case"select":return{icon:e(I,{size:16,className:"text-ink"}),label:"Decision Required",badge:`${r} Choices`};case"confirm":return{icon:e(B,{size:16,className:"text-ink"}),label:"Confirmation Required",badge:"Confirm Action"};case"input":return{icon:e(Le,{size:16,className:"text-ink"}),label:"Prompt Input",badge:"Text Input"};case"editor":return{icon:e(Oe,{size:16,className:"text-ink"}),label:"Buffer Editor",badge:"Multiline Buffer"};default:return{icon:e(Re,{size:16,className:"text-ink"}),label:"Agent Request",badge:"Input"}}}function ke({request:t,onRespond:r}){let[c,m]=n(t.method==="editor"?t.prefill??"":""),[x,b]=n(null),[f,v]=n(""),l=i(null),k=i(null),y=i(null),u=i(null),g=t.options??[],N=t.optionDetails??[],A=Pi(t);o(()=>{let p=t.options??[];m(t.method==="editor"?t.prefill??"":""),b(p.length>0?p[0]:null),v("")},[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((C)=>/^other\b/i.test(C.trim())))u.current?.focus()}},[t]);let w=a(()=>{r(t,{cancelled:!0})},[r,t]),M=a(()=>{if(t.method==="confirm")r(t,{confirmed:!0});else if(t.method==="select"){if(f.trim()&&!A)r(t,{value:f.trim()});else if(x)r(t,{value:x})}else r(t,{value:c})},[r,t,x,c,f,A]),O=a((p)=>{if(/^other\b/i.test(p.trim())){b(p),u.current?.focus();return}r(t,{value:p})},[r,t]),H=a((p)=>{if(b(p),/^other\b/i.test(p.trim()))u.current?.focus()},[]);L({method:t.method,options:g,selectedOption:x,onSelectOption:b,customInputRef:u,onSubmit:M,onCancel:w});let D=z(t.method,g.length);return e("div",{className:"extension-dialog-backdrop modal-scrim fixed inset-0 z-50 flex items-center justify-center modal-safe sm:p-6 backdrop-blur-[8px]",onMouseDown:(p)=>{if(p.target===p.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(T,{title:t.title,options:g,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(R,{title:t.title,options:g}),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(S,{options:g,optionDetails:N,selectedOption:x,customValue:f,onCustomChange:v,customInputRef:u,onSelect:H,onConfirmOption:O,hideCustomAnswer:A}),t.method==="confirm"&&g.length>0&&e("div",{className:"space-y-2",children:g.map((p,C)=>e("button",{type:"button",onClick:()=>r(t,{optionId:t.optionIds?.[C]??p}),className:"flex w-full cursor-pointer items-center justify-between rounded-xl border border-ink/15 bg-canvas/30 px-4 py-3 text-left text-[13px] font-medium text-ink transition-colors hover:border-ink/30 hover:bg-canvas/50",children:e("span",{className:"min-w-0 break-words",children:p})},t.optionIds?.[C]??p))}),t.method==="confirm"&&g.length===0&&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(ae,{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:c,placeholder:t.placeholder||"Type your response...",onChange:(p)=>m(p.currentTarget.value),onKeyDown:(p)=>{if(p.key==="Enter")p.preventDefault(),M()},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:[c.split(`
|
|
1
|
+
import{d,n,o,i,a,e,s,B,ae,Re,Ne,E,Bi,rt,Oe,Le,h,J,Pi,bg}from"./index-4vtc4xct.js";var F={name:"list-filter",size:24,node:[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]]},I=s(F);function T({title:t,options:r,methodLabel:c,badge:m,icon:x,onCancel:b}){let f=Pi({title:t,options:r})?bg(t):null,v=f?`Allow ${f.tool}`:t||c;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:v}),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(Ne,{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:b,"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(h,{size:14})})]})}function S({options:t,optionDetails:r,selectedOption:c,customValue:m,onCustomChange:x,customInputRef:b,onSelect:f,onConfirmOption:v,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=c===k,g=r[y]?.description;return e("button",{type:"button",onClick:()=>f(k),onDblClick:()=>v(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})}),g&&e("div",{className:"mt-1 text-[11.5px] leading-relaxed text-ink/55",children:g})]}),e("span",{className:"mt-0.5 shrink-0",children:u?e(ae,{size:16,className:"text-ink"}):e(Bi,{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:b,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())v(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 P({method:t,optionsLength:r,selectedOption:c,hasCustomAnswer:m=!1,onCancel:x,onSubmit:b}){let f=t==="select"&&!c&&!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(h,{size:12,className:"opacity-60"}),e("span",{children:"Cancel"})]}),e("button",{type:"button",onClick:b,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 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 R({title:t,options:r}){let c=Pi({title:t,options:r})?bg(t):null;if(!c)return null;return e("div",{className:"space-y-2",children:[c.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(E,{size:13,className:"mt-0.5 shrink-0 text-warning-text"}),e("span",{className:"min-w-0 break-words",children:c.reason})]}),c.details.length>0&&e("div",{className:"rounded-xl border border-ink/10 bg-canvas/40 px-3.5 py-2.5",children:c.details.map((m,x)=>e("div",{className:"font-mono text-[11.5px] leading-relaxed text-ink/75 break-all",children:m},`${x}-${m}`))})]})}function L({method:t,options:r,selectedOption:c,onSelectOption:m,customInputRef:x,onSubmit:b,onCancel:f}){o(()=>{let v=(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===c),g=u<r.length-1?u+1:0;m(r[g]);return}if(l.key==="ArrowUp"){l.preventDefault();let u=r.findIndex((N)=>N===c),g=u>0?u-1:r.length-1;m(r[g]);return}if(l.key==="Enter"&&c){l.preventDefault(),b();return}}if(t==="confirm"){if(l.key==="Enter"){l.preventDefault(),b();return}}if(t==="editor"){if((l.metaKey||l.ctrlKey)&&l.key==="Enter"){l.preventDefault(),b();return}}};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[f,b,t,r,c,m,x])}function z(t,r){switch(t){case"select":return{icon:e(I,{size:16,className:"text-ink"}),label:"Decision Required",badge:`${r} Choices`};case"confirm":return{icon:e(B,{size:16,className:"text-ink"}),label:"Confirmation Required",badge:"Confirm Action"};case"input":return{icon:e(Le,{size:16,className:"text-ink"}),label:"Prompt Input",badge:"Text Input"};case"editor":return{icon:e(Oe,{size:16,className:"text-ink"}),label:"Buffer Editor",badge:"Multiline Buffer"};default:return{icon:e(Re,{size:16,className:"text-ink"}),label:"Agent Request",badge:"Input"}}}function ke({request:t,onRespond:r}){let[c,m]=n(t.method==="editor"?t.prefill??"":""),[x,b]=n(null),[f,v]=n(""),l=i(null),k=i(null),y=i(null),u=i(null),g=t.options??[],N=t.optionDetails??[],A=Pi(t);o(()=>{let p=t.options??[];m(t.method==="editor"?t.prefill??"":""),b(p.length>0?p[0]:null),v("")},[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((C)=>/^other\b/i.test(C.trim())))u.current?.focus()}},[t]);let w=a(()=>{r(t,{cancelled:!0})},[r,t]),M=a(()=>{if(t.method==="confirm")r(t,{confirmed:!0});else if(t.method==="select"){if(f.trim()&&!A)r(t,{value:f.trim()});else if(x)r(t,{value:x})}else r(t,{value:c})},[r,t,x,c,f,A]),O=a((p)=>{if(/^other\b/i.test(p.trim())){b(p),u.current?.focus();return}r(t,{value:p})},[r,t]),H=a((p)=>{if(b(p),/^other\b/i.test(p.trim()))u.current?.focus()},[]);L({method:t.method,options:g,selectedOption:x,onSelectOption:b,customInputRef:u,onSubmit:M,onCancel:w});let D=z(t.method,g.length);return e("div",{className:"extension-dialog-backdrop modal-scrim fixed inset-0 z-50 flex items-center justify-center modal-safe sm:p-6 backdrop-blur-[8px]",onMouseDown:(p)=>{if(p.target===p.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(T,{title:t.title,options:g,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(R,{title:t.title,options:g}),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(S,{options:g,optionDetails:N,selectedOption:x,customValue:f,onCustomChange:v,customInputRef:u,onSelect:H,onConfirmOption:O,hideCustomAnswer:A}),t.method==="confirm"&&g.length>0&&e("div",{className:"space-y-2",children:g.map((p,C)=>e("button",{type:"button",onClick:()=>r(t,{optionId:t.optionIds?.[C]??p}),className:"flex w-full cursor-pointer items-center justify-between rounded-xl border border-ink/15 bg-canvas/30 px-4 py-3 text-left text-[13px] font-medium text-ink transition-colors hover:border-ink/30 hover:bg-canvas/50",children:e("span",{className:"min-w-0 break-words",children:p})},t.optionIds?.[C]??p))}),t.method==="confirm"&&g.length===0&&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(ae,{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:c,placeholder:t.placeholder||"Type your response...",onChange:(p)=>m(p.currentTarget.value),onKeyDown:(p)=>{if(p.key==="Enter")p.preventDefault(),M()},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:[c.split(`
|
|
2
2
|
`).length," lines · ⌘↵ to save"]})]}),e("textarea",{ref:y,value:c,onChange:(p)=>m(p.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(P,{method:t.method,optionsLength:g.length,selectedOption:x,hasCustomAnswer:f.trim().length>0,onCancel:w,onSubmit:M})]})})}export{ke as ExtensionDialog};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d,n,o,i,u,a,e,zo,s,p,E,ua,ds,f,oe,nt,de,D,G,Wm,X,Tt,wA,Zm,$d}from"./index-95jfphx5.js";var U={name:"clipboard-paste",size:24,node:[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]]},yl=s(U);var Q={name:"folder-git-2",size:24,node:[["path",{d:"M18 19a5 5 0 0 1-5-5v8",key:"sz5oeg"}],["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]},Pm=s(Q);function B({row:t,active:r,name:l,loading:h,onSelect:c,onCopyPath:b,onReveal:N}){return e("div",{className:"grid grid-cols-[1rem_minmax(0,1fr)_3.5rem] items-start gap-x-2 px-4 py-2 border-b border-ink/5 last:border-b-0 hover:bg-ink/[0.02] group/row transition-colors",children:[e("div",{className:"h-5 flex items-center justify-center",children:r&&e(f,{size:12,className:"text-ink","aria-label":"Selected repository"})}),e("button",{type:"button",onClick:c,disabled:r||!t.isRepo,title:!t.isRepo?t.error??"Not a git repository":r?"Already showing this repository":`Show ${t.path}`,className:"min-w-0 text-left cursor-pointer disabled:cursor-default",children:e("div",{className:"h-5 flex items-center gap-1.5 min-w-0",children:[e(de,{size:11,className:r?"text-ink/60 flex-shrink-0":"text-ink/40 flex-shrink-0"}),e("span",{className:`truncate text-xs ${r?"font-semibold text-ink":"text-ink/90"}`,children:l})]})}),e("div",{className:"h-5 flex items-center justify-end gap-0.5 touch-visible opacity-0 group-hover/row:opacity-100",children:[e("button",{type:"button",onClick:b,disabled:h,title:`Copy the absolute path of ${t.path}`,"aria-label":`Copy path of ${t.path}`,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors disabled:opacity-30 disabled:cursor-default",children:e(oe,{size:11})}),e("button",{type:"button",onClick:N,title:`Reveal ${t.path} in the file manager`,"aria-label":`Reveal ${t.path}`,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(nt,{size:11})})]}),e("div",{className:"col-start-2 col-span-2 flex flex-wrap items-center gap-x-2 gap-y-0.5 min-w-0 mt-0.5",children:[t.isRepo?e(d,{children:[e("span",{className:`text-[10px] font-mono truncate ${t.detached?"text-warning-text":"text-ink/50"}`,title:t.detached?`Detached HEAD at ${t.branch}`:`On branch ${t.branch}`,children:t.branch}),e("span",{className:"text-[10px] text-ink/25","aria-hidden":!0,children:"·"}),e(V,{row:t})]}):e("span",{className:"text-[10px] text-ink/40 truncate",children:t.error??"Not a git repository"}),t.isRepo&&t.subject&&e(d,{children:[e("span",{className:"text-[10px] text-ink/25","aria-hidden":!0,children:"·"}),e("span",{className:"text-[10px] text-ink/40 truncate min-w-0",title:t.subject,children:t.subject})]})]})]})}function V({row:t}){let r=[];if(t.operation)r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning-text",title:t.operation==="stash-pop"?`A stash pop stopped on ${t.conflicts} conflict(s)`:`A ${zo[t.operation]} is in progress, stopped on ${t.conflicts} conflict(s)`,children:[e(E,{size:9}),zo[t.operation]]},"operation"));else if(t.conflicts>0)r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning-text",title:`${t.conflicts} conflicted path(s)`,children:[e(E,{size:9}),t.conflicts]},"conflicts"));if(t.changed>0||t.untracked>0)r.push(e("span",{className:"flex-shrink-0 rounded border border-info/30 px-1 text-[10px] font-mono tabular-nums text-info-text",title:`${t.changed} changed, ${t.untracked} untracked`,children:[t.changed>0?`${t.changed}±`:"",t.changed>0&&t.untracked>0?" ":"",t.untracked>0?`${t.untracked}?`:""]},"dirty"));if(t.gone)r.push(e("span",{className:"flex-shrink-0 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning-text",title:`${t.upstream} no longer exists on the remote — fetch --prune to drop it`,children:"gone"},"gone"));else if(t.upstream&&(t.ahead>0||t.behind>0))r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 text-[10px] font-mono tabular-nums text-ink/60",title:`${t.ahead} ahead of, ${t.behind} behind ${t.upstream}`,children:[t.ahead>0&&e("span",{className:"flex items-center",children:[e(ds,{size:9}),t.ahead]}),t.behind>0&&e("span",{className:"flex items-center",children:[e(ua,{size:9}),t.behind]})]},"track"));if(r.length===0)return e("span",{className:"text-[10px] font-mono text-ink/30",title:"Nothing to report: clean and in sync",children:"clean, in sync"});return e(d,{children:r})}function _(t){let{open:r,rootPath:l,scanning:h}=t,[c,b]=n([]),[N,k]=n(!1),[C,P]=n(!1),[S,y]=n(null),[M,T]=n(0),j=t.repos.join("\x00"),z=i(!0),g=i(null);o(()=>(z.current=!0,()=>{z.current=!1,g.current?.abort(),g.current=null}),[]);let w=a(async()=>{g.current?.abort();let v=new AbortController;g.current=v,P(!0),k(!0);try{let R=new URLSearchParams({repoDetails:"1"});if(l)R.set("root",l);let F=await fetch(`/api/fs/git?${R.toString()}`,{signal:v.signal}),L=await F.json();if(!z.current||g.current!==v)return;if(!F.ok||!Array.isArray(L.details)){y(L.error||`Failed to read repositories (HTTP ${F.status})`);return}b(L.details),y(null)}catch(R){if(!z.current||g.current!==v)return;if(R instanceof Error&&R.name==="AbortError")return;y(R instanceof Error?R.message:"Failed to read repositories")}finally{if(z.current&&g.current===v)g.current=null,P(!1),k(!1)}},[l]);o(()=>{if(!r){b([]),y(null),k(!1);return}w()},[r,w,j,h,M]);let H=a(()=>T((v)=>v+1),[]);return{details:c,loading:N,reading:C,error:S,refresh:H}}function I(t){let r=new Map;for(let l of t){if(!l||l==="."){if(!r.has(""))r.set("",{key:"",label:null,paths:[]});r.get("").paths.push(".");continue}let h=l.indexOf("/"),c=h===-1?"":l.slice(0,h),b=r.get(c);if(!b)b={key:c,label:c===""?null:c,paths:[]},r.set(c,b);b.paths.push(l)}for(let l of r.values())l.paths.sort((h,c)=>h==="."?-1:c==="."?1:h.localeCompare(c));return[...r.values()].sort((l,h)=>{if(l.key==="")return-1;if(h.key==="")return 1;return l.key.localeCompare(h.key)})}function W(t,r){if(t===".")return"workspace root";if(r==="")return t;return t.slice(r.length+1)}function q({isOpen:t,rootPath:r,activeRepo:l,repos:h,scanning:c,onSelectRepo:b,onRefreshRepos:N,onClose:k}){let[C,P]=n(""),[S,y]=n(null),{details:M,loading:T,reading:j,error:z,refresh:g}=_({open:t,rootPath:r,repos:h,scanning:c});o(()=>{if(!t)P(""),y(null)},[t]);let w=u(()=>{let x=C.trim().toLowerCase();if(!x)return M;return M.filter((m)=>m.path.toLowerCase().includes(x))},[M,C]),H=u(()=>I(w.map((x)=>x.path)),[w]),v=u(()=>{let x=new Map;for(let m of M)x.set(m.path,m);return x},[M]),R=a(()=>{N(),g()},[N,g]),F=a(async(x)=>{let m=r?$d(r,x==="."?"":x):x,A=await Tt(m);y(A?{text:`Copied ${m}`,kind:"success"}:{text:"Clipboard unavailable",kind:"error"})},[r]),L=a(async(x)=>{let m=new FormData;if(m.append("actionType","open_explorer"),m.append("path","."),m.append("repo",x),r)m.append("root",r);try{let A=await fetch("/api/fs/action",{method:"POST",body:m}),O=await A.json();if(!A.ok||O.error)y({text:O.error||"Could not open the file manager",kind:"error"})}catch{y({text:"Could not open the file manager",kind:"error"})}},[r]);if(!t)return null;return e(X,{onClose:k,maxWidthClass:"max-w-[min(96vw,720px)]",header:e("div",{className:"flex items-center gap-2 min-w-0",children:[e(Pm,{size:14,className:"text-ink/60 flex-shrink-0"}),e("h2",{className:"text-sm font-semibold text-ink",children:"Repositories"}),e("span",{className:"text-[10px] font-mono text-ink/50 truncate",children:[h.length," in this workspace"]})]}),children:[e("div",{className:"px-5 py-3 flex items-center gap-2 border-b border-ink/10",children:[e(G,{size:12,className:"text-ink/40 flex-shrink-0"}),e("input",{type:"text",value:C,onChange:(x)=>P(x.currentTarget.value),placeholder:"Filter repositories…","aria-label":"Filter repositories",className:"flex-1 min-w-0 bg-transparent outline-none text-xs text-ink placeholder-ink/40",autoFocus:!0}),e("button",{type:"button",onClick:R,disabled:j||c,title:"Re-discover repositories and re-read their state","aria-label":"Refresh repositories",className:"text-ink/40 hover:text-ink transition-colors cursor-pointer disabled:opacity-40 flex-shrink-0",children:e(D,{size:12,className:j||c?"animate-spin":""})})]}),c&&e("div",{className:"px-5 py-1.5 border-b border-ink/10 text-[10px] font-mono text-ink/50 flex items-center gap-1.5",children:[e(p,{size:10,className:"animate-spin"}),"Still discovering repositories in this workspace…"]}),S&&e("div",{className:`px-5 py-1.5 border-b border-ink/10 text-[10px] font-mono truncate ${S.kind==="error"?"text-error-text":"text-ink/60"}`,title:S.text,role:"status",children:S.text}),e("div",{className:"min-h-[40vh] max-h-[60vh] overflow-y-auto scrollbar-overlay-container",children:T&&M.length===0?e("div",{className:"flex items-center justify-center gap-2 py-12 text-xs text-ink/50 font-mono",children:[e(p,{size:14,className:"animate-spin text-info-text"}),"Reading repositories…"]}):z?e("div",{className:"py-12 px-6 text-center text-xs text-error-text font-mono",children:z}):w.length===0?e("div",{className:"py-12 text-center text-xs text-ink/40 font-mono",children:C.trim()?"No matching repositories.":"No repositories in this workspace."}):H.map((x)=>e("div",{children:[e("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold bg-canvas/40 border-b border-ink/5 sticky top-0",children:x.label??wA(".",r)}),x.paths.map((m)=>{let A=v.get(m);if(!A)return null;return e(B,{row:A,active:m===l,name:W(m,x.key),loading:j,onSelect:()=>{b(m),k()},onCopyPath:()=>void F(m),onReveal:()=>void L(m)},m)})]},x.key))})]})}function Rr({rootPath:t,activeRepo:r,onSelectRepo:l,repos:h,scanning:c,onRefreshRepos:b}){let[N,k]=n(!1),C=u(()=>({root:t??null,repo:r,rows:Zm(t,h),scanning:c,ready:!0,setRepo:l,refresh:b}),[t,r,h,c,l,b]),P=a(()=>k(!0),[]);return e("div",{className:"relative min-w-0",children:[e(Wm,{scope:C,onManage:P}),e(q,{isOpen:N,rootPath:t,activeRepo:r,repos:h,scanning:c,onSelectRepo:l,onRefreshRepos:b,onClose:()=>k(!1)})]})}
|
|
1
|
+
import{d,n,o,i,u,a,e,zo,s,p,E,ua,ds,f,oe,nt,de,D,G,Wm,X,Tt,wA,Zm,$d}from"./index-4vtc4xct.js";var U={name:"clipboard-paste",size:24,node:[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]]},yl=s(U);var Q={name:"folder-git-2",size:24,node:[["path",{d:"M18 19a5 5 0 0 1-5-5v8",key:"sz5oeg"}],["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]},Pm=s(Q);function B({row:t,active:r,name:l,loading:h,onSelect:c,onCopyPath:b,onReveal:N}){return e("div",{className:"grid grid-cols-[1rem_minmax(0,1fr)_3.5rem] items-start gap-x-2 px-4 py-2 border-b border-ink/5 last:border-b-0 hover:bg-ink/[0.02] group/row transition-colors",children:[e("div",{className:"h-5 flex items-center justify-center",children:r&&e(f,{size:12,className:"text-ink","aria-label":"Selected repository"})}),e("button",{type:"button",onClick:c,disabled:r||!t.isRepo,title:!t.isRepo?t.error??"Not a git repository":r?"Already showing this repository":`Show ${t.path}`,className:"min-w-0 text-left cursor-pointer disabled:cursor-default",children:e("div",{className:"h-5 flex items-center gap-1.5 min-w-0",children:[e(de,{size:11,className:r?"text-ink/60 flex-shrink-0":"text-ink/40 flex-shrink-0"}),e("span",{className:`truncate text-xs ${r?"font-semibold text-ink":"text-ink/90"}`,children:l})]})}),e("div",{className:"h-5 flex items-center justify-end gap-0.5 touch-visible opacity-0 group-hover/row:opacity-100",children:[e("button",{type:"button",onClick:b,disabled:h,title:`Copy the absolute path of ${t.path}`,"aria-label":`Copy path of ${t.path}`,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors disabled:opacity-30 disabled:cursor-default",children:e(oe,{size:11})}),e("button",{type:"button",onClick:N,title:`Reveal ${t.path} in the file manager`,"aria-label":`Reveal ${t.path}`,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(nt,{size:11})})]}),e("div",{className:"col-start-2 col-span-2 flex flex-wrap items-center gap-x-2 gap-y-0.5 min-w-0 mt-0.5",children:[t.isRepo?e(d,{children:[e("span",{className:`text-[10px] font-mono truncate ${t.detached?"text-warning-text":"text-ink/50"}`,title:t.detached?`Detached HEAD at ${t.branch}`:`On branch ${t.branch}`,children:t.branch}),e("span",{className:"text-[10px] text-ink/25","aria-hidden":!0,children:"·"}),e(V,{row:t})]}):e("span",{className:"text-[10px] text-ink/40 truncate",children:t.error??"Not a git repository"}),t.isRepo&&t.subject&&e(d,{children:[e("span",{className:"text-[10px] text-ink/25","aria-hidden":!0,children:"·"}),e("span",{className:"text-[10px] text-ink/40 truncate min-w-0",title:t.subject,children:t.subject})]})]})]})}function V({row:t}){let r=[];if(t.operation)r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning-text",title:t.operation==="stash-pop"?`A stash pop stopped on ${t.conflicts} conflict(s)`:`A ${zo[t.operation]} is in progress, stopped on ${t.conflicts} conflict(s)`,children:[e(E,{size:9}),zo[t.operation]]},"operation"));else if(t.conflicts>0)r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning-text",title:`${t.conflicts} conflicted path(s)`,children:[e(E,{size:9}),t.conflicts]},"conflicts"));if(t.changed>0||t.untracked>0)r.push(e("span",{className:"flex-shrink-0 rounded border border-info/30 px-1 text-[10px] font-mono tabular-nums text-info-text",title:`${t.changed} changed, ${t.untracked} untracked`,children:[t.changed>0?`${t.changed}±`:"",t.changed>0&&t.untracked>0?" ":"",t.untracked>0?`${t.untracked}?`:""]},"dirty"));if(t.gone)r.push(e("span",{className:"flex-shrink-0 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning-text",title:`${t.upstream} no longer exists on the remote — fetch --prune to drop it`,children:"gone"},"gone"));else if(t.upstream&&(t.ahead>0||t.behind>0))r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 text-[10px] font-mono tabular-nums text-ink/60",title:`${t.ahead} ahead of, ${t.behind} behind ${t.upstream}`,children:[t.ahead>0&&e("span",{className:"flex items-center",children:[e(ds,{size:9}),t.ahead]}),t.behind>0&&e("span",{className:"flex items-center",children:[e(ua,{size:9}),t.behind]})]},"track"));if(r.length===0)return e("span",{className:"text-[10px] font-mono text-ink/30",title:"Nothing to report: clean and in sync",children:"clean, in sync"});return e(d,{children:r})}function _(t){let{open:r,rootPath:l,scanning:h}=t,[c,b]=n([]),[N,k]=n(!1),[C,P]=n(!1),[S,y]=n(null),[M,T]=n(0),j=t.repos.join("\x00"),z=i(!0),g=i(null);o(()=>(z.current=!0,()=>{z.current=!1,g.current?.abort(),g.current=null}),[]);let w=a(async()=>{g.current?.abort();let v=new AbortController;g.current=v,P(!0),k(!0);try{let R=new URLSearchParams({repoDetails:"1"});if(l)R.set("root",l);let F=await fetch(`/api/fs/git?${R.toString()}`,{signal:v.signal}),L=await F.json();if(!z.current||g.current!==v)return;if(!F.ok||!Array.isArray(L.details)){y(L.error||`Failed to read repositories (HTTP ${F.status})`);return}b(L.details),y(null)}catch(R){if(!z.current||g.current!==v)return;if(R instanceof Error&&R.name==="AbortError")return;y(R instanceof Error?R.message:"Failed to read repositories")}finally{if(z.current&&g.current===v)g.current=null,P(!1),k(!1)}},[l]);o(()=>{if(!r){b([]),y(null),k(!1);return}w()},[r,w,j,h,M]);let H=a(()=>T((v)=>v+1),[]);return{details:c,loading:N,reading:C,error:S,refresh:H}}function I(t){let r=new Map;for(let l of t){if(!l||l==="."){if(!r.has(""))r.set("",{key:"",label:null,paths:[]});r.get("").paths.push(".");continue}let h=l.indexOf("/"),c=h===-1?"":l.slice(0,h),b=r.get(c);if(!b)b={key:c,label:c===""?null:c,paths:[]},r.set(c,b);b.paths.push(l)}for(let l of r.values())l.paths.sort((h,c)=>h==="."?-1:c==="."?1:h.localeCompare(c));return[...r.values()].sort((l,h)=>{if(l.key==="")return-1;if(h.key==="")return 1;return l.key.localeCompare(h.key)})}function W(t,r){if(t===".")return"workspace root";if(r==="")return t;return t.slice(r.length+1)}function q({isOpen:t,rootPath:r,activeRepo:l,repos:h,scanning:c,onSelectRepo:b,onRefreshRepos:N,onClose:k}){let[C,P]=n(""),[S,y]=n(null),{details:M,loading:T,reading:j,error:z,refresh:g}=_({open:t,rootPath:r,repos:h,scanning:c});o(()=>{if(!t)P(""),y(null)},[t]);let w=u(()=>{let x=C.trim().toLowerCase();if(!x)return M;return M.filter((m)=>m.path.toLowerCase().includes(x))},[M,C]),H=u(()=>I(w.map((x)=>x.path)),[w]),v=u(()=>{let x=new Map;for(let m of M)x.set(m.path,m);return x},[M]),R=a(()=>{N(),g()},[N,g]),F=a(async(x)=>{let m=r?$d(r,x==="."?"":x):x,A=await Tt(m);y(A?{text:`Copied ${m}`,kind:"success"}:{text:"Clipboard unavailable",kind:"error"})},[r]),L=a(async(x)=>{let m=new FormData;if(m.append("actionType","open_explorer"),m.append("path","."),m.append("repo",x),r)m.append("root",r);try{let A=await fetch("/api/fs/action",{method:"POST",body:m}),O=await A.json();if(!A.ok||O.error)y({text:O.error||"Could not open the file manager",kind:"error"})}catch{y({text:"Could not open the file manager",kind:"error"})}},[r]);if(!t)return null;return e(X,{onClose:k,maxWidthClass:"max-w-[min(96vw,720px)]",header:e("div",{className:"flex items-center gap-2 min-w-0",children:[e(Pm,{size:14,className:"text-ink/60 flex-shrink-0"}),e("h2",{className:"text-sm font-semibold text-ink",children:"Repositories"}),e("span",{className:"text-[10px] font-mono text-ink/50 truncate",children:[h.length," in this workspace"]})]}),children:[e("div",{className:"px-5 py-3 flex items-center gap-2 border-b border-ink/10",children:[e(G,{size:12,className:"text-ink/40 flex-shrink-0"}),e("input",{type:"text",value:C,onChange:(x)=>P(x.currentTarget.value),placeholder:"Filter repositories…","aria-label":"Filter repositories",className:"flex-1 min-w-0 bg-transparent outline-none text-xs text-ink placeholder-ink/40",autoFocus:!0}),e("button",{type:"button",onClick:R,disabled:j||c,title:"Re-discover repositories and re-read their state","aria-label":"Refresh repositories",className:"text-ink/40 hover:text-ink transition-colors cursor-pointer disabled:opacity-40 flex-shrink-0",children:e(D,{size:12,className:j||c?"animate-spin":""})})]}),c&&e("div",{className:"px-5 py-1.5 border-b border-ink/10 text-[10px] font-mono text-ink/50 flex items-center gap-1.5",children:[e(p,{size:10,className:"animate-spin"}),"Still discovering repositories in this workspace…"]}),S&&e("div",{className:`px-5 py-1.5 border-b border-ink/10 text-[10px] font-mono truncate ${S.kind==="error"?"text-error-text":"text-ink/60"}`,title:S.text,role:"status",children:S.text}),e("div",{className:"min-h-[40vh] max-h-[60vh] overflow-y-auto scrollbar-overlay-container",children:T&&M.length===0?e("div",{className:"flex items-center justify-center gap-2 py-12 text-xs text-ink/50 font-mono",children:[e(p,{size:14,className:"animate-spin text-info-text"}),"Reading repositories…"]}):z?e("div",{className:"py-12 px-6 text-center text-xs text-error-text font-mono",children:z}):w.length===0?e("div",{className:"py-12 text-center text-xs text-ink/40 font-mono",children:C.trim()?"No matching repositories.":"No repositories in this workspace."}):H.map((x)=>e("div",{children:[e("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold bg-canvas/40 border-b border-ink/5 sticky top-0",children:x.label??wA(".",r)}),x.paths.map((m)=>{let A=v.get(m);if(!A)return null;return e(B,{row:A,active:m===l,name:W(m,x.key),loading:j,onSelect:()=>{b(m),k()},onCopyPath:()=>void F(m),onReveal:()=>void L(m)},m)})]},x.key))})]})}function Rr({rootPath:t,activeRepo:r,onSelectRepo:l,repos:h,scanning:c,onRefreshRepos:b}){let[N,k]=n(!1),C=u(()=>({root:t??null,repo:r,rows:Zm(t,h),scanning:c,ready:!0,setRepo:l,refresh:b}),[t,r,h,c,l,b]),P=a(()=>k(!0),[]);return e("div",{className:"relative min-w-0",children:[e(Wm,{scope:C,onManage:P}),e(q,{isOpen:N,rootPath:t,activeRepo:r,repos:h,scanning:c,onSelectRepo:l,onRefreshRepos:b,onClose:()=>k(!1)})]})}
|
|
2
2
|
export{yl,Pm,Rr};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d,u,ce,e,Gh,Se,B,I,le,$r,_l,Bt,xA,it,jd,ff,B0,gf,Af}from"./index-
|
|
1
|
+
import{d,u,ce,e,Gh,Se,B,I,le,$r,_l,Bt,xA,it,jd,ff,B0,gf,Af}from"./index-4vtc4xct.js";function k({phase:o,index:s,collapsed:r,currentKey:f,onToggle:i}){let m=gf(o),x=o.tasks.length>0&&m===o.tasks.length;return e("div",{className:"overflow-hidden rounded-lg border border-ink/10 bg-paper",children:[e("button",{type:"button",onClick:i,"aria-expanded":!r,className:"flex w-full items-center gap-1.5 border-b border-ink/8 bg-canvas/40 px-2.5 py-1.5 text-left hover:bg-ink/5",children:[r?e(le,{size:12,className:"shrink-0 text-ink/40"}):e(I,{size:12,className:"shrink-0 text-ink/40"}),e("span",{className:`min-w-0 flex-1 truncate text-[10px] font-semibold uppercase tracking-wider ${x?"text-ink/35":"text-ink/60"}`,title:o.name,children:[s+1,". ",o.name]}),e("span",{className:"shrink-0 font-mono text-[10px] text-ink/40",children:[m,"/",o.tasks.length]})]}),!r&&e("div",{className:"divide-y divide-ink/[0.05] p-0.5",children:o.tasks.length===0?e("div",{className:"px-2.5 py-1.5 text-[11px] text-ink/40",children:"No tasks in this phase"}):o.tasks.map((n,l)=>e(Af,{task:n,current:f===`${s}:${l}`},`${l}-${n.content}`))})]})}function E({className:o="",active:s=!0,tabsMode:r=!1}){let[f]=ce(),i=f.get("sessionId"),[m,x]=_l("todo.collapsedPhases",{}),{data:n,isLoading:l,refreshing:g,stale:b,refresh:v}=Se(i?Gh(i):null,{enabled:s}),t=n?.snapshot??null,p=n?.progress??null,N=u(()=>{let a=B0(t?.phases??[]);return a?`${a.phase}:${a.task}`:null},[t]);if(!i)return e("div",{className:`flex h-full flex-col items-center justify-center bg-paper text-ink/40 ${o}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});return e("div",{className:`flex h-full w-full min-w-0 flex-col overflow-hidden bg-paper text-ink ${o}`,children:[xA("todo",r)?e(Bt,{left:e(d,{children:[e("h2",{className:"text-xs font-semibold uppercase tracking-wider text-ink",children:"Todos"}),t&&e("span",{className:"truncate font-mono text-[10.5px] text-ink/50",title:jd(p),children:jd(p)}),n?.isMock&&e("span",{className:"flex-shrink-0 rounded border border-ink/15 bg-ink/5 px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-wider text-ink/60",children:"Mock"})]}),right:e(it,{label:"Refresh todos",onClick:v,busy:l||g,disabled:l})}):null,p&&p.total>0&&e("div",{className:"flex-shrink-0 border-b border-ink/10 px-3.5 py-2.5",children:e("div",{className:"h-1.5 overflow-hidden rounded-full bg-ink/8",children:e("div",{className:"h-full rounded-full bg-success transition-all duration-300",style:{width:`${ff(p)}%`}})})}),e("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto scrollbar-overlay-container p-3.5",children:[b&&e("div",{className:"flex items-start gap-2 rounded-lg border border-ink/15 bg-ink/5 px-3 py-2 text-[11px] text-ink/60",children:[e(B,{size:13,className:"mt-[1px] shrink-0"}),e("span",{className:"min-w-0 break-words",children:"Reconnecting: this list may be out of date."})]}),!t?e("div",{className:"flex flex-col items-center justify-center gap-2 py-12 text-center text-ink/40",children:[e($r,{size:20}),e("p",{className:"max-w-[240px] text-[11.5px] leading-relaxed",children:["No todo list in this session. The agent writes one with the ",e("span",{className:"font-mono",children:"todo"})," tool when a task is worth planning."]})]}):e(d,{children:[t.phases.map((a,c)=>e(k,{phase:a,index:c,collapsed:Boolean(m[String(c)]),currentKey:N,onToggle:()=>x((h)=>({...h,[String(c)]:!h[String(c)]}))},`${c}-${a.name}`)),e("p",{className:"pt-1 text-[10.5px] leading-relaxed text-ink/35",children:["Read from this session's transcript",t.updatedAt?` · updated ${y(t.updatedAt)}`:"",t.source==="custom"?" · edited by hand":"","."]})]})]})]})}function y(o){let s=new Date(o);if(Number.isNaN(s.getTime()))return o;return s.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}export{E as TodoPanel};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n,o,i,a,e,Pe,S,s,ae,Kn,p,E,xr,rt,qe,Je,zr,tr,ga,As,h,Gc}from"./index-
|
|
1
|
+
import{n,o,i,a,e,Pe,S,s,ae,Kn,p,E,xr,rt,qe,Je,zr,tr,ga,As,h,Gc}from"./index-4vtc4xct.js";import{md}from"./index-3x7cbxwq.js";import"./index-z5s9tmj8.js";var te={name:"mouse-pointer-click",size:24,node:[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]]},U=s(te);var re={name:"move-vertical",size:24,node:[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m8 18 4 4 4-4",key:"bh5tu3"}],["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}]]},D=s(re);var ne={live:"Live","agent-offline":"Agent offline","browser-offline":"Browser offline","no-tab":"Tanpa tab"};function j({url:t,status:r,zoomLevel:d=100,onIncludeInChat:c,onReconnect:l,onOpenExternal:u,onZoomIn:m,onZoomOut:b,onResetZoom:k}){return e(md,{url:t??"",statusDotClass:r==="live"?"bg-success animate-pulse":"bg-ink/25",statusLabel:ne[r],zoomLevel:d,onZoomIn:m,onZoomOut:b,onResetZoom:k,onIncludeInChat:c,onOpenExternal:u,onReconnect:l,openExternalLabel:"Buka di jendela baru",openExternalTitle:t?"Open in new window":"No URL loaded",children:e("div",{className:"flex-1 min-w-0 flex items-center bg-canvas border border-ink/15 rounded-md px-2 py-0.5",children:[e(qe,{size:12,className:"text-ink/40 mr-1.5 flex-shrink-0"}),e("span",{className:"w-full truncate text-ink/80 font-mono text-[11px]",title:t??"",children:t||"No page open yet"})]})})}var oe=[["RAM","~93 MB → ~259 MB untuk satu tab"],["Disk","~346 MB untuk Chrome for Testing bila belum terpasang"],["Idle","Tab Chromium terus melukis; omp membekukannya saat turn selesai"],["Deteksi","Halaman bisa melihat otomasi (navigator.webdriver, CDP)"]];function Z({saving:t,onUseChromium:r}){return e("button",{type:"button",onClick:r,disabled:t,className:"inline-flex items-center gap-1.5 rounded-md border border-ink/15 bg-ink/5 px-2.5 py-1 text-[11px] font-medium text-ink transition-colors hover:bg-ink/10 disabled:cursor-not-allowed disabled:opacity-60",children:[t&&e(p,{size:11,className:"animate-spin"}),t?"Mengaktifkan…":"Pakai Chromium"]})}function _({saving:t,error:r,onUseChromium:d,variant:c}){if(c==="strip")return e("div",{className:"flex items-center justify-between gap-2 border-b border-ink/10 bg-ink/[0.03] px-2.5 py-1.5 flex-shrink-0",children:[e("span",{className:"min-w-0 truncate text-[11px] text-ink/70",children:"Agen memakai WebKit — tab baru tidak akan muncul di panel ini."}),e(Z,{saving:t,onUseChromium:d})]});return e("div",{className:"flex-1 flex flex-col items-center justify-center overflow-y-auto p-6 text-center select-none my-auto",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(E,{size:24})}),e("h3",{className:"text-sm font-semibold text-ink mb-1",children:"Agen memakai WebKit — panel ini tidak bisa memantulkannya"}),e("p",{className:"text-xs text-ink/60 max-w-sm",children:"WebKit milik omp tidak punya CDP dan tidak mengekspos aliran frame, jadi tab yang dijalankannya tidak bisa ditampilkan di sini. Panel ini hanya bisa memantulkan Chromium."}),e("div",{className:"mt-4 w-full max-w-sm rounded-lg border border-ink/10 bg-paper text-left",children:[e("div",{className:"border-b border-ink/10 px-3 py-1.5 text-[10px] uppercase tracking-wider text-ink/50",children:"Biaya pindah ke Chromium"}),e("dl",{className:"divide-y divide-ink/5",children:oe.map(([l,u])=>e("div",{className:"flex gap-2 px-3 py-1.5",children:[e("dt",{className:"w-14 flex-shrink-0 text-[11px] font-medium text-ink/70",children:l}),e("dd",{className:"text-[11px] text-ink/60",children:u})]},l))})]}),e("div",{className:"mt-3 flex flex-col items-center gap-1.5",children:[e(Z,{saving:t,onUseChromium:d}),e("p",{className:"text-[10.5px] text-ink/45 max-w-sm",children:"Berlaku untuk tab yang dibuka berikutnya; sesi tidak perlu di-restart. Tab WebKit yang sudah terbuka tetap tidak terlihat."}),r&&e("p",{role:"alert",className:"text-[11px] text-error-text max-w-sm",children:r})]})]})}var se={open:qe,navigate:qe,loaded:ae,click:U,type:ga,press:rt,submit:tr,wait:Je,screenshot:xr,scroll:D,upload:As,close:Kn,error:Kn};function F({actions:t}){if(t.length===0)return null;return e("div",{className:"absolute bottom-3 left-3 z-20 flex flex-col gap-1.5 pointer-events-none max-w-[320px]",children:t.map((r)=>{let d=se[r.kind],c=r.kind==="error";return e("div",{className:`flex items-center gap-2 rounded-md border px-2.5 py-1.5 text-[11px] shadow-sm backdrop-blur-sm ${c?"border-error/30 bg-error/10 text-error-text":"border-ink/15 bg-paper/95 text-ink"}`,children:[e(d,{size:12,className:`flex-shrink-0 ${c?"text-error-text":"text-ink/60"}`}),e("span",{className:"truncate",children:r.label})]},r.id)})})}function ie(t){return t.title||t.url||t.targetId}function H({tabs:t,targetId:r,closing:d,onSelectTarget:c,onCloseTarget:l}){let u=i(null);return o(()=>{u.current?.scrollIntoView({block:"nearest",inline:"nearest"})},[r,t.length]),e("div",{className:"px-2 py-1 border-b border-ink/10 bg-paper flex items-center gap-1 overflow-x-auto flex-shrink-0",children:t.map((m)=>{let b=m.targetId===r,k=ie(m);return e("div",{ref:b?u:void 0,className:`group flex items-center rounded border transition-colors flex-shrink-0 ${b?"bg-ink text-canvas border-ink":"bg-paper text-ink/70 border-ink/15 hover:border-ink/35 hover:text-ink"}`,children:[e("button",{type:"button",onClick:()=>c(b?"":m.targetId),className:"pl-2 pr-1 py-0.5 text-[11px] font-mono max-w-[220px] truncate cursor-pointer",title:`${k}
|
|
2
2
|
${m.url}`,"aria-pressed":b,children:k}),e("button",{type:"button",onClick:()=>l(m.targetId),disabled:d===m.targetId,className:`mr-0.5 p-1 rounded hover:bg-error hover:text-paper transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed ${b?"text-on-ink-muted":"text-ink/40 opacity-0 group-hover:opacity-100 focus-visible:opacity-100"}`,"aria-label":`Tutup tab ${k}`,title:`Tutup tab ${k}`,children:e(h,{size:11})})]},m.targetId)})})}function le(t){let r=atob(t),d=new Uint8Array(r.length);for(let c=0;c<r.length;c++)d[c]=r.charCodeAt(c);return d}function ce(t,r){return new Blob([le(t)],{type:r})}async function K(t,r,d){let c=t.getContext("2d");if(!c)return!1;if(typeof createImageBitmap!=="function")return!1;let l;try{l=await createImageBitmap(ce(r,d))}catch{return!1}try{if(t.width!==l.width||t.height!==l.height)t.width=l.width,t.height=l.height;return c.drawImage(l,0,0),!0}finally{l.close()}}var ue={"agent-offline":{title:"The agent is not running",body:"Start this session so the agent can drive the browser."},"browser-offline":{title:"No browser is open",body:"Ask the agent to open a page; the live view appears here."},"no-tab":{title:"Browser is open, with no tab yet",body:"This session has not opened a tab in the shared browser."}};function J({status:t,url:r,tabs:d,targetId:c,frame:l,actions:u,onSelectTarget:m,onCloseTarget:b,closingTarget:k,zoomLevel:I}){let B=t==="live",R=B?null:ue[t],g=i(null),[f,w]=n(!1);return o(()=>{let A=g.current;if(!A||!l)return;let y=!1;return K(A,l.data,l.mimeType).then((T)=>{if(T&&!y)w(!0)}),()=>{y=!0}},[l]),o(()=>{if(!B)w(!1)},[B]),e("div",{className:"flex-1 flex flex-col min-h-0 bg-canvas/60 relative overflow-hidden",children:[e(F,{actions:u}),B&&d.length>0&&e(H,{tabs:d,targetId:c,closing:k,onSelectTarget:m,onCloseTarget:b}),e("div",{className:"flex-1 flex items-center justify-center p-2 min-h-0 overflow-auto",children:B?e("div",{className:"relative flex flex-col bg-paper w-full h-full transition-all duration-200",style:{zoom:I!==100?`${I}%`:void 0,transformOrigin:"top center"},children:[e("canvas",{ref:g,"aria-label":r||"Live browser view",className:`w-full h-full object-contain bg-paper ${f?"":"hidden"}`}),!f&&e("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-center p-6 select-none",children:[e(p,{size:20,className:"animate-spin text-ink/40 mb-2"}),e("p",{className:"text-xs text-ink/60",children:"Menunggu frame pertama dari browser…"})]})]}):e("div",{className:"flex-1 flex flex-col items-center justify-center p-6 text-center select-none my-auto",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:t==="agent-offline"?e(zr,{size:24}):e(qe,{size:24})}),e("h3",{className:"text-sm font-semibold text-ink mb-1",children:R?.title}),e("p",{className:"text-xs text-ink/60 max-w-sm",children:R?.body})]})})]})}function W(t){if(typeof t!=="object"||t===null||!("error"in t))return null;return typeof t.error==="string"?t.error:null}function X(){let[t,r]=n(null),[d,c]=n(!0),[l,u]=n(!1),[m,b]=n(null),[k,I]=n(0);o(()=>{let g=!1;return c(!0),fetch("/api/browser/engine").then((f)=>f.json()).then((f)=>{if(g)return;let w=W(f);if(w){b(w);return}r(f),b(null)}).catch((f)=>{if(!g)b(f instanceof Error?f.message:String(f))}).finally(()=>{if(!g)c(!1)}),()=>{g=!0}},[k]);let B=a(()=>I((g)=>g+1),[]),R=a(async()=>{u(!0),b(null);try{let g=await fetch("/api/browser/engine",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({webkit:!1})}),f=await g.json().catch(()=>null),w=W(f)??(g.ok?null:`The write answered ${g.status}`);if(w)return b(w),!1;return r(f),!0}catch(g){return b(g instanceof Error?g.message:String(g)),!1}finally{u(!1)}},[]);return{state:t,loading:d,saving:l,error:m,refresh:B,useChromium:R}}var G={status:"agent-offline",tabs:[]},Y=5000,de=4000,me=500,pe=3,q=16;function Q(t=!0){let{sessionId:r,ready:d}=Pe(),[c,l]=n(G),[u,m]=n(null),[b,k]=n([]),[I,B]=n(""),[R,g]=n(0),f=i(null),w=i(null),A=i(void 0),y=i(0),T=i([]),O=a((N)=>{B(N.trim())},[]),V=a(()=>{g((N)=>N+1)},[]);return o(()=>{let N=setInterval(()=>{k((L)=>{let M=Date.now(),P=L.filter((x)=>x.expiresAt>M),C=T.current.shift();if(!C)return P.length===L.length?L:P;return[...P.slice(-(pe-1)),{...C,expiresAt:M+de}]})},me);return()=>clearInterval(N)},[]),o(()=>{l(G),m(null),B(""),T.current=[],k([])},[r]),o(()=>{if(!d||!r||!t)return;let N=!1,L=()=>{if(N)return;let P=I?`?target=${encodeURIComponent(I)}`:"",C=new EventSource(`/api/browser/${encodeURIComponent(r)}/stream${P}`);f.current=C,C.addEventListener("open",()=>{y.current=0}),C.addEventListener("state",(x)=>{try{let v=JSON.parse(x.data);if(A.current=v.targetId,l(v),v.status!=="live")m(null)}catch{}}),C.addEventListener("frame",(x)=>{try{let v=JSON.parse(x.data),z=A.current;if(z&&v.targetId&&v.targetId!==z)return;if(!z&&v.targetId)A.current=v.targetId;m({data:v.data,mimeType:v.mimeType})}catch{}}),C.addEventListener("action",(x)=>{try{let v=JSON.parse(x.data);if(typeof v?.label!=="string"||!v.label)return;if(T.current.push(v),T.current.length>q)T.current.splice(0,T.current.length-q)}catch{}}),C.addEventListener("error",()=>{if(C.readyState===EventSource.CLOSED)M()})},M=()=>{if(N||w.current)return;let P=Math.min(y.current+1,Y/1000);y.current=P,w.current=setTimeout(()=>{w.current=null,f.current?.close(),f.current=null,L()},Math.min(P*1000,Y))};return L(),()=>{if(N=!0,w.current)clearTimeout(w.current),w.current=null;f.current?.close(),f.current=null}},[d,r,I,R,t]),{status:c.status,url:c.url,title:c.title,tabs:c.tabs,targetId:c.targetId,frame:u,actions:b,sessionId:r,selectTarget:O,reconnect:V}}function fe(t){return typeof t==="string"&&t?t:null}function ee(t){let[r,d]=n(null);return{closeTab:a(async(l)=>{if(!t||!l)return{ok:!1,next:null,error:"No tab to close"};d(l);try{let u=await fetch(`/api/browser/${encodeURIComponent(t)}/tabs/close`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({targetId:l})}),m=await u.json().catch(()=>({}));if(!u.ok)return{ok:!1,next:null,error:typeof m.error==="string"&&m.error?m.error:`Close failed (${u.status})`};return{ok:!0,next:fe(m.next)}}catch(u){return{ok:!1,next:null,error:u instanceof Error?u.message:String(u)}}finally{d(null)}},[t]),closing:r}}function it({className:t="",active:r=!0}){let[d,c]=S("browser.zoomLevel",100),{status:l,url:u,title:m,tabs:b,targetId:k,frame:I,actions:B,sessionId:R,selectTarget:g,reconnect:f}=Q(r),{closeTab:w,closing:A}=ee(R),y=X(),[T,O]=n(null),V=y.state?.effective==="webkit"&&!y.state.mock,N=V&&(l==="browser-offline"||l==="no-tab"),L=a(()=>{y.useChromium().then((x)=>{if(x)f()})},[y.useChromium,f]),M=()=>{if(!u)return;let x=u.startsWith("/")&&typeof window<"u"?`${window.location.origin}${u}`:u;window.open(x,"_blank","noopener,noreferrer")},P=a(()=>{if(!u)return;Gc({url:u,title:m})},[u,m]),C=a((x)=>{if(A===x)return;w(x).then((v)=>{if(!v.ok){O(v.error??"The tab could not be closed");return}O(null),g(v.next??"")})},[w,A,g]);return e("div",{className:`flex flex-col h-full w-full bg-paper text-ink overflow-hidden select-none ${t}`,children:[e(j,{url:u,status:l,zoomLevel:d,onIncludeInChat:P,onReconnect:f,onOpenExternal:M,onZoomIn:()=>c((x)=>Math.min(200,x+10)),onZoomOut:()=>c((x)=>Math.max(50,x-10)),onResetZoom:()=>c(100)}),T&&e("div",{role:"alert",className:"px-2.5 py-1 border-b border-error/30 bg-error/5 text-[11px] text-error-text flex items-center justify-between gap-2 flex-shrink-0",children:[e("span",{className:"truncate",title:T,children:T}),e("button",{type:"button",onClick:()=>O(null),className:"text-[10px] uppercase tracking-wide text-error-text hover:text-error-text cursor-pointer flex-shrink-0",children:"Tutup"})]}),V&&l==="live"&&y.state&&e(_,{saving:y.saving,error:y.error,onUseChromium:L,variant:"strip"}),N&&y.state?e(_,{saving:y.saving,error:y.error,onUseChromium:L,variant:"body"}):e(J,{status:l,url:u,tabs:b,targetId:k,frame:I,actions:B,onSelectTarget:g,onCloseTarget:C,closingTarget:A,zoomLevel:d})]})}export{it as BrowserPanel};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n,o,i,u,a,He,e,S,co,E,D,ot,ur,Tl,Li,Mi,r0,i0,s0,Wo,l0,c0,yt,Ud,f0,g0,Ot,ja,tp,Wl,lp,xg}from"./index-
|
|
1
|
+
import{n,o,i,u,a,He,e,S,co,E,D,ot,ur,Tl,Li,Mi,r0,i0,s0,Wo,l0,c0,yt,Ud,f0,g0,Ot,ja,tp,Wl,lp,xg}from"./index-4vtc4xct.js";import{ke,Dn,Xl,Tr,x,P,cn,Nn,N,ye,_}from"./index-wsy6y5em.js";function We(t){let r=t.split("/").pop()??"",s=r.lastIndexOf(".");return s>0&&s<r.length-1?r.slice(s).toLowerCase():""}function KA(t){let r=Ot("fileOpener"),s=Ot("sourceCodeRenderer"),l=ja(),c=t.extension??We(t.path),d=r.find((h)=>h.registration.matches({path:t.path,extension:c}));if(d)return{kind:"opener",pluginId:d.pluginId,Component:d.registration.component,props:{...l,path:t.path,extension:c}};let f=s.find((h)=>h.registration.extensions.includes(c));if(f)return{kind:"source",pluginId:f.pluginId,Component:f.registration.component,props:{...l,path:t.path,content:t.content,language:t.language}};return null}function VA(t){let r=Ot("diffRenderer"),s=ja(),l=We(t.path),c=r.find((d)=>{let f=d.registration.extensions;return f===void 0||f.includes(l)});if(!c)return null;return{pluginId:c.pluginId,Component:c.registration.component,props:{...s,path:t.path,diff:t.diff}}}function YA({view:t}){if(t.kind==="opener"){let s=t.Component;return e(ot,{pluginId:t.pluginId,children:e(s,{...t.props})})}let r=t.Component;return e(ot,{pluginId:t.pluginId,children:e(r,{...t.props})})}var Tt={docx:!0},Ct={xls:!0,xlsx:!0,xlsm:!0},Lt={csv:!0,tsv:!0},Dt={md:!0,markdown:!0,mdx:!0},It={html:!0,htm:!0},Pt={drawio:!0,dio:!0},$s={image:!0,pdf:!0,docx:!0,spreadsheet:!0,code:void 0,markdown:void 0,html:void 0,svg:void 0,csv:void 0,drawio:void 0},Du={markdown:!0,html:!0,svg:!0,csv:!0,drawio:!0,code:void 0,image:void 0,pdf:void 0,docx:void 0,spreadsheet:void 0},Nt={markdown:!0,svg:!0,csv:!0,drawio:!0,html:void 0,code:void 0,image:void 0,pdf:void 0,docx:void 0,spreadsheet:void 0};function Nu(t){return Nt[t]===!0}var ci={code:"Text",markdown:"Markdown",html:"HTML",svg:"SVG",csv:"CSV",image:"Image",pdf:"PDF",docx:"Document",spreadsheet:"Spreadsheet",drawio:"Diagram"};function zs(t){let r=Li(t);if(!r)return"code";if(r==="svg")return"svg";if(Pt[r])return"drawio";if(Dt[r])return"markdown";if(It[r])return"html";if(Mi(t))return"image";if(r==="pdf")return"pdf";if(Tt[r])return"docx";if(Ct[r])return"spreadsheet";if(Lt[r])return"csv";return"code"}var Wt={id:"",url:null,loadBytes:null,mimeType:null};async function Le(t){let r=await t.json().catch(()=>null);return typeof r?.error==="string"&&r.error?r.error:`Could not read the file (HTTP ${t.status}).`}function Ae(t){let r=r0(t.path);if(t.rawUrl){let c=t.rawUrl;return{id:c,url:c,mimeType:r,loadBytes:async()=>{let d=await fetch(c);if(!d.ok)throw Error(await Le(d));return d.arrayBuffer()}}}let s=xg(t.handleId);if(s){let{bytes:c}=s;return{id:t.handleId,url:null,mimeType:s.mimeType??r,loadBytes:async()=>c.slice().buffer}}let l=Wl(t.handleId);if(l)return{id:t.handleId,url:null,mimeType:r,loadBytes:async()=>(await l.getFile()).arrayBuffer()};return Wt}function Be(t,r){let s=t?zs(t.path??""):"code",l=$s[s]===!0,c=Boolean(t?.path)&&!t?.handleId,d=c&&t?.content===void 0&&Mi(t?.path)?t.path:null,f=d!==null,h=t&&!f&&l&&c&&t.content===void 0?Tl({path:t.path,root:t.root,repo:t.repo}):null,p=Ae({path:t?.path,handleId:t?.handleId,rawUrl:d?`${Tl({path:d,root:t?.root,repo:t?.repo})}&v=${r}`:h});return{viewerKind:s,isBinaryViewer:l,isImage:f,imageUrl:f?p.url:null,byteSource:p}}function Ke(t){let r=t.indexOf(`
|
|
2
2
|
`);return r>0&&t[r-1]==="\r"?"crlf":"lf"}function me(t){return t.includes("\r")?t.replace(/\r\n?/g,`
|
|
3
3
|
`):t}function Ue(t,r){let s=me(t);return r==="crlf"?s.replace(/\n/g,`\r
|
|
4
4
|
`):s}function qe(t){return String(t.id??t.path??t.name)}function Ve({target:t,key:r,isBinaryViewer:s,revision:l,loadedRef:c,contentsRef:d,baselinesRef:f,pendingRef:h,readingRef:p,remember:g}){let[v,k]=n(!1),[w,m]=n(!1),[R,y]=n(null),[T,F]=n(null);return o(()=>{if(m(!1),!t)return;let b=qe(t);if(c.current.has(b))return;if(c.current.add(b),s){y(null),F(null),k(!1);return}if(t.content!==void 0){g(b,t.content,null,null),y(null),F(null);return}if(!t.path){y("No file path supplied for this attachment."),F(null);return}let W=d.current[b]===void 0,U=!1;if(W)k(!0);y(null),F(null);let O=new URLSearchParams({path:t.path});if(t.root)O.set("root",t.root);if(t.repo&&t.repo!==".")O.set("repo",t.repo);return p.current+=1,m(!0),fetch(`/api/fs/read?${O.toString()}`).then(async(B)=>{let I=await B.json().catch(()=>null);if(!B.ok||!I||typeof I.content!=="string"){let C=Error(I?.error||`HTTP ${B.status}`);if(I?.kind)C.kind=I.kind;else if(B.status===415)C.kind="binary";throw C}return{text:I.content,mtimeMs:typeof I.mtimeMs==="number"?I.mtimeMs:null,hash:typeof I.hash==="string"?I.hash:null}}).then(({text:B,mtimeMs:I,hash:C})=>{if(U)return;let A=d.current[b];if(A!==void 0&&A!==f.current[b])return;let X=h.current;if(X&&qe(X.file)===b)return;g(b,B,I,C)}).catch((B)=>{if(U)return;if(!W)return;g(b,"",null,null);let I=B instanceof Error?B.message:"Failed to read file",C=B?.kind;F(C?I:null),y(I)}).finally(()=>{if(p.current-=1,!U)k(!1),m(!1)}),()=>{U=!0}},[r,t,g,l,s,c,d,f,h,p]),{isLoading:v,isReading:w&&!v,loadError:R,unsupported:T}}async function _e(t,r){let s=await fetch(t);if(!s.ok)throw Error(`HTTP ${s.status}`);tp(await s.blob(),r)}async function $e(t){let r=await fetch(t);if(!r.ok)throw Error(`HTTP ${r.status}`);let s=await r.blob();if(typeof ClipboardItem>"u"||!navigator.clipboard?.write)throw Error("Image clipboard unavailable");await navigator.clipboard.write([new ClipboardItem({[s.type]:s})])}function je({target:t,content:r,downloadContent:s,imageUrl:l,downloadMimeType:c,byteSource:d,byteViewer:f=!1}){let[h,p]=n(!1),g=a(()=>{p(!0),window.setTimeout(()=>p(!1),1500)},[]),v=a(()=>{if(!t)return;if(l){$e(l).then(g).catch(()=>{});return}if(f)return;if(!navigator.clipboard)return;navigator.clipboard.writeText(r).then(g).catch(()=>{})},[t,r,l,f,g]),k=a(()=>{if(!t)return;if(l){_e(l,t.name).catch(()=>{});return}if(f){let w=d?.loadBytes;if(!w)return;let m=d?.mimeType;w().then((R)=>tp(m?new Blob([R],{type:m}):new Blob([R]),t.name)).catch(()=>{});return}tp(new Blob([s],{type:c}),t.name)},[t,s,c,l,f,d]);return{copied:h,copy:v,download:k}}async function ze(t){let r=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(r),(s)=>s.toString(16).padStart(2,"0")).join("")}async function Xe(t,r,s,l){if(t.handleId){let d=s==="crlf"?r.replace(/\n/g,`\r
|