@kabmo-labs/kabmo 0.38.0 → 0.38.1
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 +420 -419
- package/dist/client/static/js/{CsvGrid-90zfbn7f.js → CsvGrid-t1n057vw.js} +1 -1
- package/dist/client/static/js/{DocxView-vwq2rf16.js → DocxView-c9g6teks.js} +1 -1
- package/dist/client/static/js/{DrawioView-bvx7eqcz.js → DrawioView-gd14j54m.js} +1 -1
- package/dist/client/static/js/{ImageView-q6xfmbrq.js → ImageView-57f1ecdp.js} +1 -1
- package/dist/client/static/js/{LayoutWrapper-qatdaw3n.js → LayoutWrapper-x7srbpz1.js} +1 -1
- package/dist/client/static/js/{Modal-6jx1fvfb.js → Modal-0bn3f77b.js} +1 -1
- package/dist/client/static/js/{PdfView-tkv2d2zs.js → PdfView-cybz0xbj.js} +1 -1
- package/dist/client/static/js/{SessionsView-rbnecykz.js → SessionsView-gx5q68tp.js} +1 -1
- package/dist/client/static/js/{SheetView-t08g8kdr.js → SheetView-1kk5y326.js} +1 -1
- package/dist/client/static/js/{SvgPreview-9vh6mdcp.js → SvgPreview-mp4tk37p.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-bxcn33e1.js → abnfDiagram-O67JEVCF-78qb3can.js} +1 -1
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-40ggw6e8.js → architectureDiagram-NJMV4G6O-n0fr4hb6.js} +1 -1
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-k41cvjrd.js → blockDiagram-BEXU5L5S-2xemfrzh.js} +1 -1
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-rdcmn6ac.js → c4Diagram-YGBWAQC7-zxfdx3eb.js} +1 -1
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-txbmbkxv.js → classDiagram-v2-NBCMYWYE-z9sasy3k.js} +1 -1
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-bxzh3qj1.js → cose-bilkent-JH36ORCC-9byp0czh.js} +1 -1
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-abx5343b.js → cynefinDiagram-VND7K2PF-gnm129fx.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-baj278kt.js → dagre-6A5THRUB-sc5tfv1w.js} +1 -1
- package/dist/client/static/js/{diagram-22UHCM2B-vqvhdc5m.js → diagram-22UHCM2B-hq11eek7.js} +1 -1
- package/dist/client/static/js/{diagram-3UASUU5V-w328rfx0.js → diagram-3UASUU5V-7bk532gd.js} +1 -1
- package/dist/client/static/js/{diagram-ATOU4E4O-zzcmwnm8.js → diagram-ATOU4E4O-yt8wxttm.js} +1 -1
- package/dist/client/static/js/{diagram-CDSNMT55-8yw39mmj.js → diagram-CDSNMT55-n3978w6p.js} +1 -1
- package/dist/client/static/js/{diagram-MLGK6HIB-zgc386pv.js → diagram-MLGK6HIB-004x4gyw.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-efmvvscm.js → diagram-MPIPVDR6-498nt489.js} +1 -1
- package/dist/client/static/js/{dockerfile-bp5dre33.js → dockerfile-6hbcmkc8.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-p66h0dzq.js → ebnfDiagram-ZINNZB2B-5fkmymqn.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-g0jjxcqd.js → elk-276RUBZZ-6xrfa2kd.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-39gat96z.js → erDiagram-OPXOYQCR-byz4zbkn.js} +1 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-s3fbfwrz.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-nsjv1zt4.js → ganttDiagram-FUAMR5RP-4fkw1k01.js} +1 -1
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-r4vnkcy3.js → gitGraphDiagram-X574FWY7-19g84yw8.js} +1 -1
- package/dist/client/static/js/{index-hzx81cjq.js → index-0v8b5pzb.js} +1 -1
- package/dist/client/static/js/{index-h8h5c2r8.js → index-1j1s91c4.js} +1 -1
- package/dist/client/static/js/{index-6ax2z70w.js → index-20vhkcb9.js} +1 -1
- package/dist/client/static/js/{index-st202rjv.js → index-3wpsr2bc.js} +7 -7
- package/dist/client/static/js/{index-73jwm4d5.js → index-3y6krykq.js} +1 -1
- package/dist/client/static/js/{index-1qszrvzk.js → index-4jbbdq6n.js} +1 -1
- package/dist/client/static/js/{index-tfsaj5d1.js → index-4qt2e84b.js} +1 -1
- package/dist/client/static/js/{index-da10qpns.js → index-57z8mtmx.js} +1 -1
- package/dist/client/static/js/{index-ha75kff0.js → index-5gn56236.js} +1 -1
- package/dist/client/static/js/{index-k9xsvab3.js → index-74scnfpk.js} +1 -1
- package/dist/client/static/js/{index-dkseg29t.js → index-7kafzae0.js} +2 -2
- package/dist/client/static/js/{index-ra38ggke.js → index-89a2702q.js} +1 -1
- package/dist/client/static/js/{index-tv61v3t3.js → index-8j90mdgz.js} +1 -1
- package/dist/client/static/js/{index-50z4ek83.js → index-baet2nv8.js} +1 -1
- package/dist/client/static/js/{index-a74k07z2.js → index-bhng2dax.js} +1 -1
- package/dist/client/static/js/{index-24yyj78e.js → index-cj9193d5.js} +1 -1
- package/dist/client/static/js/{index-5ebhb94w.js → index-dd4q54y0.js} +1 -1
- package/dist/client/static/js/{index-dfgdn3fj.js → index-e3w46vsc.js} +1 -1
- package/dist/client/static/js/{index-rgp69pa8.js → index-e99ec2f0.js} +1 -1
- package/dist/client/static/js/{index-2ndq1ngv.js → index-ehnztdd2.js} +1 -1
- package/dist/client/static/js/{index-rqrcw8nj.js → index-epbqzayj.js} +1 -1
- package/dist/client/static/js/{index-vnn7m9yp.js → index-fpf1jkwd.js} +1 -1
- package/dist/client/static/js/{index-vxd4gykh.js → index-g252205p.js} +1 -1
- package/dist/client/static/js/{index-11bdd235.js → index-gxtgyya0.js} +1 -1
- package/dist/client/static/js/{index-tzm90bsz.js → index-j314me09.js} +1 -1
- package/dist/client/static/js/{index-gwhx66f4.js → index-jbwns6sc.js} +1 -1
- package/dist/client/static/js/{index-c15r8jd3.js → index-kdgcbt17.js} +1 -1
- package/dist/client/static/js/{index-rf0p3v7q.js → index-m4bjsyj2.js} +1 -1
- package/dist/client/static/js/{index-2drjp9ks.js → index-pfwd0160.js} +1 -1
- package/dist/client/static/js/{index-e1pr3k50.js → index-qntytvt0.js} +1 -1
- package/dist/client/static/js/{index-z0cpp5bc.js → index-rgdhyry3.js} +1 -1
- package/dist/client/static/js/{index-9wtg6ywn.js → index-sjnnv1gd.js} +1 -1
- package/dist/client/static/js/{index-5y0bvq4q.js → index-zj45wj1x.js} +2 -2
- package/dist/client/static/js/{index-0kxqzafy.js → index-zw7qjx65.js} +1 -1
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-e39pvm4j.js → infoDiagram-VRGFBTTK-aw6ter0a.js} +1 -1
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-rqhszgvp.js → ishikawaDiagram-OU5B5YK6-62gst5wh.js} +1 -1
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-wgy5qrsv.js → journeyDiagram-ZHPQQLJL-6kgv5a4j.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-b8bxn0h1.js → kanban-definition-PNTS6WVX-8p3515b7.js} +1 -1
- package/dist/client/static/js/{mermaid.core-vb5ehtre.js → mermaid.core-b6ga2y8y.js} +2 -2
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-t4p38s38.js → mindmap-definition-NLK3R4M7-na9e9b4a.js} +1 -1
- package/dist/client/static/js/one-dark-pro-xp6ssk4z.js +1 -0
- package/dist/client/static/js/one-light-xgab7b02.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-3gp4madx.js → pegDiagram-GJSIUBJH-d1hk7fnq.js} +1 -1
- package/dist/client/static/js/{pieDiagram-5QR66LMP-0cbm773h.js → pieDiagram-5QR66LMP-7b9f4x0y.js} +1 -1
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-jwg7fc9f.js → quadrantDiagram-O4NWA36T-q4wxgmhg.js} +1 -1
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-38xh691s.js → railroadDiagram-XR7U4H2S-jngq1qx4.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-gpddawxh.js → requirementDiagram-PLB6GJNP-6xph3b72.js} +1 -1
- package/dist/client/static/js/{rust-bx3ecv4n.js → rust-w6hen2h4.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-s6t6bbhk.js → sankeyDiagram-IPEJSGJF-ncfzgdj8.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-wkq51pmb.js → sequenceDiagram-PO4LG4MO-sqz0yfg0.js} +1 -1
- package/dist/client/static/js/{sizeCapture-INFHLROL-xtwexf8k.js → sizeCapture-INFHLROL-vt8qp04d.js} +1 -1
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-jnwsqa7y.js → stateDiagram-v2-GCMORJYK-myjtrmfe.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-mnkkqcbx.js → swimlanes-2SLR337P-z9vx7z4j.js} +1 -1
- package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-6xmrz03n.js → swimlanesDiagram-TC7HE7FX-5vha7thx.js} +1 -1
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-rxq6heqh.js → timeline-definition-EJHVYXUP-z815np57.js} +1 -1
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-dz94f57t.js → usecaseDiagram-POWQR4AR-06ntggng.js} +1 -1
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-5mmvkhsq.js → vennDiagram-UO4OBE2U-nmtaf5rp.js} +1 -1
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-dctdntpa.js → wardleyDiagram-VNRHLVJA-zgsxmak8.js} +1 -1
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-njyfrqkv.js → xychartDiagram-PMCCYNJV-8bg9qdra.js} +1 -1
- package/package.json +1 -1
- package/src/server/lib/changes/capture-bash.server.ts +69 -4
- package/src/server/lib/changes/capture-fs.server.ts +2 -2
- package/src/server/lib/changes/capture-races.test.ts +107 -0
- package/src/server/lib/changes/capture-scan.test.ts +157 -0
- package/src/server/lib/changes/capture-test-util.ts +1 -1
- package/src/server/lib/changes/capture-types.ts +3 -1
- package/src/server/lib/changes/capture-write.server.ts +50 -0
- package/src/server/lib/changes/capture.server.ts +32 -16
- package/src/server/lib/changes/capture.test.ts +48 -0
- package/src/server/lib/changes/journal.server.ts +3 -1
- package/src/server/lib/changes/omp-fallback.server.ts +48 -0
- package/src/server/lib/changes/omp-fallback.test.ts +75 -0
- package/src/server/lib/changes/reader.server.ts +28 -0
- package/src/server/lib/changes/scan.server.ts +51 -1
- package/src/server/lib/changes/sessions.server.ts +65 -0
- package/src/server/lib/changes/sessions.test.ts +52 -0
- package/dist/client/static/js/flowDiagram-KWPJA3E3-f6jpcqyq.js +0 -1
- package/dist/client/static/js/one-dark-pro-dhybn1ff.js +0 -1
- package/dist/client/static/js/one-light-bqg77ay0.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n,i,o,u,a,e,TA,we,S,ir,or,I,m,Vt,Yt,Ce,Gr,C,F,J,ee}from"./index-st202rjv.js";import{fr}from"./index-tfsaj5d1.js";function K({sections:c,selected:t,onSelect:l}){let[r,d]=n(""),k=u(()=>{let p=r.trim().toLowerCase();if(!p)return c;return c.map((x)=>({...x,links:x.links.filter((s)=>s.label.toLowerCase().includes(p)||(s.path??s.target).toLowerCase().includes(p))})).filter((x)=>x.links.length>0)},[c,r]),f=c.some((p)=>p.links.length>0);return e("div",{className:"flex h-full min-h-0 w-full flex-col bg-canvas/40",children:[e("div",{className:"flex items-center gap-1.5 border-b border-ink/10 px-2 py-1.5 flex-shrink-0",children:[e(F,{size:11,className:"flex-shrink-0 text-ink/40"}),e("input",{type:"text",value:r,onChange:(p)=>d(p.currentTarget.value),placeholder:"Filter pages…",title:"Filter wiki pages",className:"w-full min-w-0 bg-transparent text-xs text-ink outline-none placeholder-ink/40"}),r&&e("button",{type:"button",onClick:()=>d(""),title:"Clear filter",className:"flex-shrink-0 text-ink/40 hover:text-ink",children:"×"})]}),e("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-overlay-container",children:k.length===0?e("p",{className:"px-3 py-2 text-[11px] italic text-ink/40",children:f?"No page matches the filter":"This wiki has no pages"}):k.map((p,x)=>e("div",{className:"py-0.5",children:[p.title&&e("div",{className:"px-2.5 py-1 text-[10px] font-semibold uppercase tracking-wider text-ink/40",children:p.title}),p.links.map((s,h)=>{let v=s.path!==null&&s.path===t,b=`${s.path??s.target}-${h}`;if(s.path)return e("button",{type:"button",onClick:()=>l(s.path),title:s.path,"aria-current":v?"page":void 0,className:`flex w-full items-center gap-1 px-2.5 py-1 text-left text-xs transition-colors ${v?"bg-ink/8 font-medium text-ink":"text-ink/70 hover:bg-ink/5 hover:text-ink"}`,children:e("span",{className:"truncate",children:s.label})},b);if(s.url)return e("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",title:s.url,className:"flex w-full items-center gap-1 px-2.5 py-1 text-left text-xs text-ink/70 hover:bg-ink/5 hover:text-ink",children:[e("span",{className:"truncate",children:s.label}),e(Ce,{size:10,className:"flex-shrink-0 text-ink/30"})]},b);return e("div",{title:`Not in this wiki: ${s.target}`,className:"flex w-full items-center px-2.5 py-1 text-left text-xs text-ink/35 line-through decoration-ink/20",children:e("span",{className:"truncate",children:s.label})},b)}),p.notes.map((s,h)=>e("p",{className:"px-2.5 py-0.5 text-[10px] leading-snug text-ink/50",children:s},`note-${h}`))]},`${p.title??"links"}-${x}`))})]})}function q({open:c,onClick:t}){return e("button",{type:"button",onClick:t,title:"Browse wiki pages","aria-label":"Browse wiki pages","aria-expanded":c,className:"absolute bottom-3 right-3 z-20 flex h-9 w-9 items-center justify-center rounded-full border border-ink/20 bg-paper text-ink/60 shadow-sm transition-all hover:bg-ink/5 hover:text-ink active:scale-95",children:e(Gr,{size:16})})}function V({open:c,sections:t,selected:l,onSelect:r,onClose:d}){if(i(()=>{if(!c)return;let k=(f)=>{if(f.key==="Escape")d()};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[c,d]),!c)return null;return e(J,{onClose:d,maxWidthClass:"max-w-sm",zClass:"z-[70]",ariaLabel:"Wiki pages",header:e("div",{className:"flex min-w-0 items-center gap-2",children:[e(Gr,{size:15,className:"flex-shrink-0 text-ink/50"}),e("span",{className:"text-sm font-medium",children:"Wiki pages"})]}),children:e("div",{className:"flex h-[60vh] min-h-0 flex-col",children:e(K,{sections:t,selected:l,onSelect:(k)=>{r(k),d()}})})})}function re(c,t){if(!c.webUrl)return null;let r=(t.split("/").pop()??t).replace(/\.(md|markdown)$/i,"");return c.provider==="gitlab"?`${c.webUrl.replace(/\/home$/,"")}/${encodeURIComponent(t.replace(/\.(md|markdown)$/i,""))}`:`${c.webUrl}/${encodeURIComponent(r)}`}function G({repo:c,entries:t,path:l,page:r,isLoading:d,error:k,rootPath:f,repoScope:p,onNavigate:x,onBack:s}){let h=re(c,l),v=u(()=>({path:l,entries:t,root:f,repo:p}),[l,t,f,p]);return e("div",{className:"flex h-full min-h-0 w-full flex-col bg-paper",children:[e("div",{className:"flex flex-shrink-0 items-center gap-1.5 border-b border-ink/10 px-2.5 py-1.5",children:[s&&e("button",{type:"button",onClick:s,title:"Back to the page list","aria-label":"Back to the page list",className:"flex-shrink-0 rounded p-1 text-ink/60 hover:bg-ink/5 hover:text-ink @[520px]:hidden",children:e(Vt,{size:13})}),e("span",{className:"min-w-0 flex-1 truncate text-[11px] text-ink/50",title:l,children:l}),d&&e(m,{size:12,className:"flex-shrink-0 animate-spin text-ink/40"}),h&&e("a",{href:h,target:"_blank",rel:"noopener noreferrer",title:"Open this page on the wiki host","aria-label":"Open this page on the wiki host",className:"flex-shrink-0 rounded p-1 text-ink/60 hover:bg-ink/5 hover:text-ink",children:e(Ce,{size:13})})]}),e("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-overlay-container",children:k?e("div",{className:"flex flex-col items-center gap-2 px-6 py-8 text-center",children:[e(I,{size:16,className:"text-error"}),e("p",{className:"text-xs text-error",children:k})]}):!r?e("div",{className:"px-6 py-8 text-center text-xs text-ink/40",children:d?"Loading page…":"No page selected"}):e("article",{className:"mx-auto max-w-4xl px-5 py-4",children:[e(ee,{content:r.content,className:"max-w-none",wikiScope:v,onWikiNavigate:x}),r.truncated&&e("p",{className:"mt-4 border-t border-ink/10 pt-2 text-[11px] text-ink/50",children:"This page is longer than the reader's budget and was cut off."})]})})]})}function B(c,t){return`${c??""}\x00${t}`}function X(c,t){let l=new URLSearchParams;if(c)l.set("root",c);if(t&&t!==".")l.set("repo",t);return l}function H(c){let{rootPath:t,repo:l,enabled:r,active:d,revisionKey:k=0}=c,f=B(t,l),[p,x]=n(null),s=o(f);s.current=f;let h=we(TA(f),{enabled:r&&d}),{refresh:v}=h;i(()=>{x(null)},[f]);let b=a((P)=>{if(!r)return;if(!P?.force){v();return}let y=s.current,R=X(t,l);R.set("refresh","1"),fetch(`/api/wiki?${R.toString()}`).then(async(w)=>{let N=await w.json();if(!w.ok)throw Error(N?.error||`Wiki request failed (${w.status})`)}).then(()=>{if(s.current!==y)return;x(null),v()}).catch((w)=>{if(s.current!==y)return;x(w instanceof Error?w.message:"Failed to load the wiki")})},[r,t,l,v]);return i(()=>{if(k>0)v()},[k]),{data:h.data,isLoading:h.isLoading,refreshing:h.refreshing,error:p,reload:b}}function Q(c){let{rootPath:t,repo:l,path:r,enabled:d,active:k,revisionKey:f=0}=c,p=`${B(t,l)}\x00${r??""}`,[x,s]=n({scope:p,data:null}),[h,v]=n(!1),[b,P]=n(null),y=o(0);return i(()=>{if(!d||!k||!r){s({scope:p,data:null}),P(null);return}let R=++y.current;v(!0);let w=X(t,l);w.set("path",r),fetch(`/api/wiki/page?${w.toString()}`).then(async(N)=>{let T=await N.json();if(!N.ok)throw Error(T?.error||`Page request failed (${N.status})`);return T}).then((N)=>{if(y.current!==R)return;s({scope:p,data:N}),P(null)}).catch((N)=>{if(y.current!==R)return;P(N instanceof Error?N.message:"Failed to load the page")}).finally(()=>{if(y.current===R)v(!1)})},[p,t,l,r,d,k,f]),{data:x.scope===p?x.data:null,isLoading:h,error:b}}function Y(c){let t=[];for(let l of c){if(!l.isMarkdown)continue;let r=t[t.length-1],d={label:l.title,target:l.path,path:l.path,url:null};if(r&&r.title===(l.folder||"Pages")){r.links.push(d);continue}t.push({title:l.folder||"Pages",links:[d],notes:[]})}return t}var ae={"no-remote":"This repository has no origin remote, so there is no wiki to find.","unsupported-remote":"The origin remote is not a URL a wiki can be derived from.","no-wiki":"This project has no wiki (or Kabmo cannot read it).",unreachable:"The wiki could not be reached."};function Oe({className:c="",enabled:t=!0,active:l=!0,rootPath:r,refreshKey:d=0,layout:k="desktop"}){let f=k==="phone",{activeRepo:p,setActiveRepo:x}=ir(r),{repos:s,scanning:h,rescan:v}=or(r,t),b=B(r,p),[P,y]=S("wiki.selectedPage",null),[R,w]=n(!1),[N,T]=n(!1),[Z,te]=n(0),g=H({rootPath:r,repo:p,enabled:t,active:l,revisionKey:d}),z=g.data?.entries??[],A=u(()=>z.filter((L)=>L.isMarkdown),[z]),M=u(()=>g.data?.sidebar??Y(z),[g.data?.sidebar,z]),ie=u(()=>M.some((L)=>L.links.length>0),[M]),_=P&&P.scope===b?P.path:null,E=u(()=>{if(_&&A.some((j)=>j.path===_))return _;return(A.find((j)=>j.title.toLowerCase()==="home")??A[0])?.path??null},[_,A]),O=Q({rootPath:r,repo:p,path:E,enabled:t,active:l,revisionKey:Z});i(()=>{if(!E||E===_)return;y({scope:b,path:E})},[E,_,b,y]),i(()=>{w(!1),T(!1)},[b]);let D=(L)=>{if(y({scope:b,path:L}),!f)T(!0)},ne=()=>{g.reload({force:!0}),te((L)=>L+1)},W=g.data?.repo??null,U=g.data&&!W?g.data:null;if(!t)return e("div",{className:`flex h-full flex-col items-center justify-center bg-paper text-ink/40 ${c}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});return e("div",{className:`@container flex h-full min-h-0 w-full flex-col bg-paper text-xs text-ink ${c}`,children:[e("div",{className:"flex flex-shrink-0 items-center justify-between gap-2 border-b border-ink/10 px-2 py-1.5",children:[e("div",{className:"flex min-w-0 items-center gap-1.5",children:[e(fr,{rootPath:r,activeRepo:p,onSelectRepo:x,repos:s,scanning:h,onRefreshRepos:v}),W&&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",title:`${W.host}/${W.slug} · ${W.revision.slice(0,8)}`,children:W.provider})]}),e("div",{className:"flex flex-shrink-0 items-center gap-0.5",children:[W?.webUrl&&e("a",{href:W.webUrl,target:"_blank",rel:"noopener noreferrer",title:"Open the wiki on its host","aria-label":"Open the wiki on its host",className:"rounded p-1 text-ink/60 hover:bg-ink/5 hover:text-ink",children:e(Ce,{size:13})}),e("button",{type:"button",onClick:ne,disabled:g.isLoading,title:"Re-fetch the wiki","aria-label":"Re-fetch the wiki",className:"rounded p-1 text-ink/60 transition-colors hover:bg-ink/5 hover:text-ink disabled:opacity-50",children:e(C,{size:13,className:g.isLoading||g.refreshing?"animate-spin":""})})]})]}),g.error&&!g.data?e("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center",children:[e(I,{size:16,className:"text-error"}),e("p",{className:"text-error",children:g.error}),e("button",{type:"button",onClick:()=>g.reload(),className:"text-[11px] font-semibold text-ink/70 underline underline-offset-2 hover:text-ink",children:"Try again"})]}):!g.data?e("div",{className:"flex flex-1 items-center justify-center gap-2 text-ink/40",children:[e(m,{size:14,className:"animate-spin"}),e("span",{children:"Reading the wiki…"})]}):U?e("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center",children:[e(Yt,{size:18,className:"text-ink/30"}),e("p",{className:"max-w-sm text-[11px] leading-relaxed text-ink/60",children:ae[U.reason??"no-wiki"]}),U.detail&&e("p",{className:"max-w-sm break-words font-mono text-[10px] text-ink/40",children:U.detail})]}):e("div",{className:"flex min-h-0 flex-1 flex-col @[520px]:flex-row-reverse",children:[e("div",{className:`${f?"hidden":N?"hidden @[520px]:flex":"flex"} min-h-0 w-full flex-col @[520px]:w-52 @[520px]:flex-shrink-0 @[520px]:border-l @[520px]:border-ink/10`,children:e(K,{sections:M,selected:E,onSelect:D})}),e("div",{className:`relative min-w-0 min-h-0 flex-1 ${f?"flex":N?"flex":"hidden @[520px]:flex"} flex-col`,children:[W&&E?e(G,{repo:W,entries:z,path:E,page:O.data,isLoading:O.isLoading,error:O.error,rootPath:r,repoScope:p,onNavigate:D,onBack:f?void 0:()=>T(!1)}):e("div",{className:"flex h-full items-center justify-center px-6 text-center text-[11px] text-ink/40",children:"This wiki has no markdown pages."}),f&&ie&&e(q,{open:R,onClick:()=>w(!0)}),e(V,{open:R,sections:M,selected:E,onSelect:D,onClose:()=>w(!1)})]})]})]})}export{Oe as WikiPanel};
|
|
1
|
+
import{n,i,o,u,a,e,TA,we,S,ir,or,I,m,Vt,Yt,Ce,Gr,C,F,J,ee}from"./index-3wpsr2bc.js";import{fr}from"./index-4qt2e84b.js";function K({sections:c,selected:t,onSelect:l}){let[r,d]=n(""),k=u(()=>{let p=r.trim().toLowerCase();if(!p)return c;return c.map((x)=>({...x,links:x.links.filter((s)=>s.label.toLowerCase().includes(p)||(s.path??s.target).toLowerCase().includes(p))})).filter((x)=>x.links.length>0)},[c,r]),f=c.some((p)=>p.links.length>0);return e("div",{className:"flex h-full min-h-0 w-full flex-col bg-canvas/40",children:[e("div",{className:"flex items-center gap-1.5 border-b border-ink/10 px-2 py-1.5 flex-shrink-0",children:[e(F,{size:11,className:"flex-shrink-0 text-ink/40"}),e("input",{type:"text",value:r,onChange:(p)=>d(p.currentTarget.value),placeholder:"Filter pages…",title:"Filter wiki pages",className:"w-full min-w-0 bg-transparent text-xs text-ink outline-none placeholder-ink/40"}),r&&e("button",{type:"button",onClick:()=>d(""),title:"Clear filter",className:"flex-shrink-0 text-ink/40 hover:text-ink",children:"×"})]}),e("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-overlay-container",children:k.length===0?e("p",{className:"px-3 py-2 text-[11px] italic text-ink/40",children:f?"No page matches the filter":"This wiki has no pages"}):k.map((p,x)=>e("div",{className:"py-0.5",children:[p.title&&e("div",{className:"px-2.5 py-1 text-[10px] font-semibold uppercase tracking-wider text-ink/40",children:p.title}),p.links.map((s,h)=>{let v=s.path!==null&&s.path===t,b=`${s.path??s.target}-${h}`;if(s.path)return e("button",{type:"button",onClick:()=>l(s.path),title:s.path,"aria-current":v?"page":void 0,className:`flex w-full items-center gap-1 px-2.5 py-1 text-left text-xs transition-colors ${v?"bg-ink/8 font-medium text-ink":"text-ink/70 hover:bg-ink/5 hover:text-ink"}`,children:e("span",{className:"truncate",children:s.label})},b);if(s.url)return e("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",title:s.url,className:"flex w-full items-center gap-1 px-2.5 py-1 text-left text-xs text-ink/70 hover:bg-ink/5 hover:text-ink",children:[e("span",{className:"truncate",children:s.label}),e(Ce,{size:10,className:"flex-shrink-0 text-ink/30"})]},b);return e("div",{title:`Not in this wiki: ${s.target}`,className:"flex w-full items-center px-2.5 py-1 text-left text-xs text-ink/35 line-through decoration-ink/20",children:e("span",{className:"truncate",children:s.label})},b)}),p.notes.map((s,h)=>e("p",{className:"px-2.5 py-0.5 text-[10px] leading-snug text-ink/50",children:s},`note-${h}`))]},`${p.title??"links"}-${x}`))})]})}function q({open:c,onClick:t}){return e("button",{type:"button",onClick:t,title:"Browse wiki pages","aria-label":"Browse wiki pages","aria-expanded":c,className:"absolute bottom-3 right-3 z-20 flex h-9 w-9 items-center justify-center rounded-full border border-ink/20 bg-paper text-ink/60 shadow-sm transition-all hover:bg-ink/5 hover:text-ink active:scale-95",children:e(Gr,{size:16})})}function V({open:c,sections:t,selected:l,onSelect:r,onClose:d}){if(i(()=>{if(!c)return;let k=(f)=>{if(f.key==="Escape")d()};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[c,d]),!c)return null;return e(J,{onClose:d,maxWidthClass:"max-w-sm",zClass:"z-[70]",ariaLabel:"Wiki pages",header:e("div",{className:"flex min-w-0 items-center gap-2",children:[e(Gr,{size:15,className:"flex-shrink-0 text-ink/50"}),e("span",{className:"text-sm font-medium",children:"Wiki pages"})]}),children:e("div",{className:"flex h-[60vh] min-h-0 flex-col",children:e(K,{sections:t,selected:l,onSelect:(k)=>{r(k),d()}})})})}function re(c,t){if(!c.webUrl)return null;let r=(t.split("/").pop()??t).replace(/\.(md|markdown)$/i,"");return c.provider==="gitlab"?`${c.webUrl.replace(/\/home$/,"")}/${encodeURIComponent(t.replace(/\.(md|markdown)$/i,""))}`:`${c.webUrl}/${encodeURIComponent(r)}`}function G({repo:c,entries:t,path:l,page:r,isLoading:d,error:k,rootPath:f,repoScope:p,onNavigate:x,onBack:s}){let h=re(c,l),v=u(()=>({path:l,entries:t,root:f,repo:p}),[l,t,f,p]);return e("div",{className:"flex h-full min-h-0 w-full flex-col bg-paper",children:[e("div",{className:"flex flex-shrink-0 items-center gap-1.5 border-b border-ink/10 px-2.5 py-1.5",children:[s&&e("button",{type:"button",onClick:s,title:"Back to the page list","aria-label":"Back to the page list",className:"flex-shrink-0 rounded p-1 text-ink/60 hover:bg-ink/5 hover:text-ink @[520px]:hidden",children:e(Vt,{size:13})}),e("span",{className:"min-w-0 flex-1 truncate text-[11px] text-ink/50",title:l,children:l}),d&&e(m,{size:12,className:"flex-shrink-0 animate-spin text-ink/40"}),h&&e("a",{href:h,target:"_blank",rel:"noopener noreferrer",title:"Open this page on the wiki host","aria-label":"Open this page on the wiki host",className:"flex-shrink-0 rounded p-1 text-ink/60 hover:bg-ink/5 hover:text-ink",children:e(Ce,{size:13})})]}),e("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-overlay-container",children:k?e("div",{className:"flex flex-col items-center gap-2 px-6 py-8 text-center",children:[e(I,{size:16,className:"text-error"}),e("p",{className:"text-xs text-error",children:k})]}):!r?e("div",{className:"px-6 py-8 text-center text-xs text-ink/40",children:d?"Loading page…":"No page selected"}):e("article",{className:"mx-auto max-w-4xl px-5 py-4",children:[e(ee,{content:r.content,className:"max-w-none",wikiScope:v,onWikiNavigate:x}),r.truncated&&e("p",{className:"mt-4 border-t border-ink/10 pt-2 text-[11px] text-ink/50",children:"This page is longer than the reader's budget and was cut off."})]})})]})}function B(c,t){return`${c??""}\x00${t}`}function X(c,t){let l=new URLSearchParams;if(c)l.set("root",c);if(t&&t!==".")l.set("repo",t);return l}function H(c){let{rootPath:t,repo:l,enabled:r,active:d,revisionKey:k=0}=c,f=B(t,l),[p,x]=n(null),s=o(f);s.current=f;let h=we(TA(f),{enabled:r&&d}),{refresh:v}=h;i(()=>{x(null)},[f]);let b=a((P)=>{if(!r)return;if(!P?.force){v();return}let y=s.current,R=X(t,l);R.set("refresh","1"),fetch(`/api/wiki?${R.toString()}`).then(async(w)=>{let N=await w.json();if(!w.ok)throw Error(N?.error||`Wiki request failed (${w.status})`)}).then(()=>{if(s.current!==y)return;x(null),v()}).catch((w)=>{if(s.current!==y)return;x(w instanceof Error?w.message:"Failed to load the wiki")})},[r,t,l,v]);return i(()=>{if(k>0)v()},[k]),{data:h.data,isLoading:h.isLoading,refreshing:h.refreshing,error:p,reload:b}}function Q(c){let{rootPath:t,repo:l,path:r,enabled:d,active:k,revisionKey:f=0}=c,p=`${B(t,l)}\x00${r??""}`,[x,s]=n({scope:p,data:null}),[h,v]=n(!1),[b,P]=n(null),y=o(0);return i(()=>{if(!d||!k||!r){s({scope:p,data:null}),P(null);return}let R=++y.current;v(!0);let w=X(t,l);w.set("path",r),fetch(`/api/wiki/page?${w.toString()}`).then(async(N)=>{let T=await N.json();if(!N.ok)throw Error(T?.error||`Page request failed (${N.status})`);return T}).then((N)=>{if(y.current!==R)return;s({scope:p,data:N}),P(null)}).catch((N)=>{if(y.current!==R)return;P(N instanceof Error?N.message:"Failed to load the page")}).finally(()=>{if(y.current===R)v(!1)})},[p,t,l,r,d,k,f]),{data:x.scope===p?x.data:null,isLoading:h,error:b}}function Y(c){let t=[];for(let l of c){if(!l.isMarkdown)continue;let r=t[t.length-1],d={label:l.title,target:l.path,path:l.path,url:null};if(r&&r.title===(l.folder||"Pages")){r.links.push(d);continue}t.push({title:l.folder||"Pages",links:[d],notes:[]})}return t}var ae={"no-remote":"This repository has no origin remote, so there is no wiki to find.","unsupported-remote":"The origin remote is not a URL a wiki can be derived from.","no-wiki":"This project has no wiki (or Kabmo cannot read it).",unreachable:"The wiki could not be reached."};function Oe({className:c="",enabled:t=!0,active:l=!0,rootPath:r,refreshKey:d=0,layout:k="desktop"}){let f=k==="phone",{activeRepo:p,setActiveRepo:x}=ir(r),{repos:s,scanning:h,rescan:v}=or(r,t),b=B(r,p),[P,y]=S("wiki.selectedPage",null),[R,w]=n(!1),[N,T]=n(!1),[Z,te]=n(0),g=H({rootPath:r,repo:p,enabled:t,active:l,revisionKey:d}),z=g.data?.entries??[],A=u(()=>z.filter((L)=>L.isMarkdown),[z]),M=u(()=>g.data?.sidebar??Y(z),[g.data?.sidebar,z]),ie=u(()=>M.some((L)=>L.links.length>0),[M]),_=P&&P.scope===b?P.path:null,E=u(()=>{if(_&&A.some((j)=>j.path===_))return _;return(A.find((j)=>j.title.toLowerCase()==="home")??A[0])?.path??null},[_,A]),O=Q({rootPath:r,repo:p,path:E,enabled:t,active:l,revisionKey:Z});i(()=>{if(!E||E===_)return;y({scope:b,path:E})},[E,_,b,y]),i(()=>{w(!1),T(!1)},[b]);let D=(L)=>{if(y({scope:b,path:L}),!f)T(!0)},ne=()=>{g.reload({force:!0}),te((L)=>L+1)},W=g.data?.repo??null,U=g.data&&!W?g.data:null;if(!t)return e("div",{className:`flex h-full flex-col items-center justify-center bg-paper text-ink/40 ${c}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});return e("div",{className:`@container flex h-full min-h-0 w-full flex-col bg-paper text-xs text-ink ${c}`,children:[e("div",{className:"flex flex-shrink-0 items-center justify-between gap-2 border-b border-ink/10 px-2 py-1.5",children:[e("div",{className:"flex min-w-0 items-center gap-1.5",children:[e(fr,{rootPath:r,activeRepo:p,onSelectRepo:x,repos:s,scanning:h,onRefreshRepos:v}),W&&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",title:`${W.host}/${W.slug} · ${W.revision.slice(0,8)}`,children:W.provider})]}),e("div",{className:"flex flex-shrink-0 items-center gap-0.5",children:[W?.webUrl&&e("a",{href:W.webUrl,target:"_blank",rel:"noopener noreferrer",title:"Open the wiki on its host","aria-label":"Open the wiki on its host",className:"rounded p-1 text-ink/60 hover:bg-ink/5 hover:text-ink",children:e(Ce,{size:13})}),e("button",{type:"button",onClick:ne,disabled:g.isLoading,title:"Re-fetch the wiki","aria-label":"Re-fetch the wiki",className:"rounded p-1 text-ink/60 transition-colors hover:bg-ink/5 hover:text-ink disabled:opacity-50",children:e(C,{size:13,className:g.isLoading||g.refreshing?"animate-spin":""})})]})]}),g.error&&!g.data?e("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center",children:[e(I,{size:16,className:"text-error"}),e("p",{className:"text-error",children:g.error}),e("button",{type:"button",onClick:()=>g.reload(),className:"text-[11px] font-semibold text-ink/70 underline underline-offset-2 hover:text-ink",children:"Try again"})]}):!g.data?e("div",{className:"flex flex-1 items-center justify-center gap-2 text-ink/40",children:[e(m,{size:14,className:"animate-spin"}),e("span",{children:"Reading the wiki…"})]}):U?e("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center",children:[e(Yt,{size:18,className:"text-ink/30"}),e("p",{className:"max-w-sm text-[11px] leading-relaxed text-ink/60",children:ae[U.reason??"no-wiki"]}),U.detail&&e("p",{className:"max-w-sm break-words font-mono text-[10px] text-ink/40",children:U.detail})]}):e("div",{className:"flex min-h-0 flex-1 flex-col @[520px]:flex-row-reverse",children:[e("div",{className:`${f?"hidden":N?"hidden @[520px]:flex":"flex"} min-h-0 w-full flex-col @[520px]:w-52 @[520px]:flex-shrink-0 @[520px]:border-l @[520px]:border-ink/10`,children:e(K,{sections:M,selected:E,onSelect:D})}),e("div",{className:`relative min-w-0 min-h-0 flex-1 ${f?"flex":N?"flex":"hidden @[520px]:flex"} flex-col`,children:[W&&E?e(G,{repo:W,entries:z,path:E,page:O.data,isLoading:O.isLoading,error:O.error,rootPath:r,repoScope:p,onNavigate:D,onBack:f?void 0:()=>T(!1)}):e("div",{className:"flex h-full items-center justify-center px-6 text-center text-[11px] text-ink/40",children:"This wiki has no markdown pages."}),f&&ie&&e(q,{open:R,onClick:()=>w(!0)}),e(V,{open:R,sections:M,selected:E,onSelect:D,onClose:()=>w(!1)})]})]})]})}export{Oe as WikiPanel};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d,n,V,o,e,s,f,B,ae,Ce,Ua,ha,ut,va,ur,zt,Ut}from"./index-st202rjv.js";import{Sa,Ta,fo}from"./index-rqrcw8nj.js";var J={name:"square-pen",size:24,node:[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],aliases:["pen-box","edit","pen-square"]},y=s(J);var K={name:"laptop",size:24,node:[["path",{d:"M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z",key:"1pdavp"}],["path",{d:"M20.054 15.987H3.946",key:"14rxg9"}]]},Z=s(K);var Q={name:"ratio",size:24,node:[["rect",{width:"12",height:"20",x:"6",y:"2",rx:"2",key:"1oxtiu"}],["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]},w=s(Q);var Y={name:"tablet",size:24,node:[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18",key:"1dp563"}]]},C=s(Y);var k=[{id:"responsive",label:"Responsive (100% Fluid)",category:"responsive",icon:ha},{id:"desktop-16-9",label:"Desktop 16:9 (Auto H:W)",category:"responsive",icon:w},{id:"laptop",label:"Laptop (1024 × 768)",category:"responsive",icon:Z},{id:"tablet",label:"Tablet (768 × 1024)",category:"mobile",icon:C},{id:"mobile",label:"Mobile Phone (375 × 667)",category:"mobile",icon:ur},{id:"mobile-lg",label:"Mobile Large (414 × 896)",category:"mobile",icon:ur}];function j(i){switch(i){case"desktop-16-9":return"Desktop 16:9";case"laptop":return"Laptop 1024p";case"tablet":return"Tablet 768p";case"mobile":return"Mobile 375p";case"mobile-lg":return"Mobile Lg 414p";case"responsive":default:return"Responsive"}}function z({viewportMode:i,onChangeViewport:r,zoomLevel:a=100,onSetZoom:l}){let[p,c]=n(null);return e("div",{className:"flex items-center space-x-1.5 flex-shrink-0",children:[e("div",{className:"hidden sm:flex items-center bg-canvas border border-ink/10 rounded-md p-0.5",children:[e("button",{type:"button",onClick:()=>r("responsive"),className:`p-1 rounded text-xs transition-colors cursor-pointer ${i==="responsive"?"bg-ink text-canvas font-medium":"text-ink/50 hover:text-ink"}`,title:"Responsive (100% Fluid)",children:e(ha,{size:12})}),e("button",{type:"button",onClick:()=>r("desktop-16-9"),className:`p-1 rounded text-xs transition-colors cursor-pointer ${i==="desktop-16-9"?"bg-ink text-canvas font-medium":"text-ink/50 hover:text-ink"}`,title:"Desktop 16:9 (Auto Height following Width)",children:e(w,{size:12})}),e("button",{type:"button",onClick:()=>r("tablet"),className:`p-1 rounded text-xs transition-colors cursor-pointer ${i==="tablet"?"bg-ink text-canvas font-medium":"text-ink/50 hover:text-ink"}`,title:"Tablet (768px)",children:e(C,{size:12})}),e("button",{type:"button",onClick:()=>r("mobile"),className:`p-1 rounded text-xs transition-colors cursor-pointer ${i==="mobile"?"bg-ink text-canvas font-medium":"text-ink/50 hover:text-ink"}`,title:"Mobile (375px)",children:e(ur,{size:12})})]}),e("button",{type:"button","aria-haspopup":"menu","aria-expanded":p!==null,onClick:(t)=>c(p?null:zt(t.currentTarget)),className:"flex items-center space-x-1 px-2 py-1 rounded bg-canvas border border-ink/15 hover:border-ink/30 text-ink text-[11px] font-mono transition-colors cursor-pointer",title:"Device & Responsive Testing Menu",children:[e("span",{className:"hidden md:inline text-[10px] font-medium",children:j(i)}),e(B,{size:11,className:"text-ink/60"})]}),e(Ut,{anchor:p,ariaLabel:"Device & Responsive Testing Menu",className:"w-56 bg-paper border border-ink/15 rounded-lg shadow-xl py-1 text-xs font-mono",onClose:()=>c(null),children:[e("div",{className:"px-2.5 py-1 text-[10px] text-ink/40 uppercase tracking-wider font-semibold",children:"Responsive Testing"}),k.filter((t)=>t.category==="responsive").map((t)=>{let u=t.icon,b=i===t.id;return e("button",{type:"button",onClick:()=>{r(t.id),c(null)},className:`w-full px-2.5 py-1.5 flex items-center justify-between text-left hover:bg-ink/5 cursor-pointer ${b?"bg-ink/10 font-semibold text-ink":"text-ink/75"}`,children:[e("div",{className:"flex items-center space-x-2",children:[e(u,{size:13,className:"text-ink/60"}),e("span",{children:t.label})]}),b&&e(f,{size:12,className:"text-success"})]},t.id)}),e("div",{className:"mt-1 pt-1 border-t border-ink/10 px-2.5 py-1 text-[10px] text-ink/40 uppercase tracking-wider font-semibold",children:"Mobile Testing"}),k.filter((t)=>t.category==="mobile").map((t)=>{let u=t.icon,b=i===t.id;return e("button",{type:"button",onClick:()=>{r(t.id),c(null)},className:`w-full px-2.5 py-1.5 flex items-center justify-between text-left hover:bg-ink/5 cursor-pointer ${b?"bg-ink/10 font-semibold text-ink":"text-ink/75"}`,children:[e("div",{className:"flex items-center space-x-2",children:[e(u,{size:13,className:"text-ink/60"}),e("span",{children:t.label})]}),b&&e(f,{size:12,className:"text-success"})]},t.id)}),l&&e(d,{children:[e("div",{className:"mt-1 pt-1 border-t border-ink/10 px-2.5 py-1 text-[10px] text-ink/40 uppercase tracking-wider font-semibold",children:["Zoom Scale (",a,"%)"]}),e("div",{className:"grid grid-cols-3 gap-1 px-2 py-1",children:[50,75,100,125,150,200].map((t)=>e("button",{type:"button",onClick:()=>{l(t),c(null)},className:`px-1.5 py-1 text-center rounded text-[11px] font-mono cursor-pointer transition-colors ${a===t?"bg-ink text-canvas font-semibold":"bg-canvas border border-ink/10 text-ink/75 hover:bg-ink/5"}`,children:[t,"%"]},t))})]})]})]})}function L({zoomLevel:i,onZoomIn:r,onZoomOut:a,onResetZoom:l}){return e("div",{className:"flex items-center bg-canvas border border-ink/10 rounded-md p-0.5 space-x-0.5 text-xs font-mono",children:[e("button",{type:"button",onClick:a,disabled:i<=50,"aria-label":"Perkecil tampilan",title:"Zoom Out (-10%)",className:"p-1 rounded hover:bg-ink/5 disabled:opacity-25 disabled:hover:bg-transparent text-ink/70 hover:text-ink cursor-pointer disabled:cursor-not-allowed transition-colors",children:e(Ta,{size:12})}),e("button",{type:"button",onClick:l,className:"px-1 text-[10px] font-medium text-ink/75 hover:text-ink hover:underline cursor-pointer select-none",title:"Reset Zoom (100%)",children:[i,"%"]}),e("button",{type:"button",onClick:r,disabled:i>=200,"aria-label":"Perbesar tampilan",title:"Zoom In (+10%)",className:"p-1 rounded hover:bg-ink/5 disabled:opacity-25 disabled:hover:bg-transparent text-ink/70 hover:text-ink cursor-pointer disabled:cursor-not-allowed transition-colors",children:e(Sa,{size:12})})]})}var h="p-1.5 rounded hover:bg-ink/5 disabled:opacity-25 disabled:hover:bg-transparent text-ink/70 hover:text-ink transition-colors cursor-pointer disabled:cursor-not-allowed";function O(i){let r=[],{url:a,zoomLevel:l,copied:p,included:c}=i;if(i.viewportMode&&i.onChangeViewport){let{viewportMode:t,onChangeViewport:u,onSetZoom:b}=i;r.push({id:"viewport",actions:k.map((m)=>({label:m.label,icon:m.icon,onSelect:()=>u(m.id),active:t===m.id})),children:e(z,{viewportMode:t,onChangeViewport:u,zoomLevel:l,onSetZoom:b})})}if(r.push({id:"zoom",actions:[{label:"Zoom in (+10%)",icon:Sa,onSelect:i.onZoomIn,disabled:l>=200},{label:"Zoom out (-10%)",icon:Ta,onSelect:i.onZoomOut,disabled:l<=50},{label:"Reset zoom (100%)",icon:ut,onSelect:i.onResetZoom,active:l===100}],children:e(L,{zoomLevel:l,onZoomIn:i.onZoomIn,onZoomOut:i.onZoomOut,onResetZoom:i.onResetZoom})}),r.push({id:"include",actions:[{label:c?"Page context added to the draft":"Include this page in the chat draft",icon:Ua,onSelect:i.onIncludeInChat,disabled:!a}],children:e("button",{type:"button",onClick:i.onIncludeInChat,disabled:!a,"aria-label":"Include this page in the chat draft",title:c?"Page context added to the draft":"Include this page in the chat draft",className:h,children:c?e(f,{size:14,className:"text-success"}):e(Ua,{size:14})})}),i.annotate){let t=i.annotate;r.push({id:"annotate",actions:[{label:t.count>0?`${t.active?"Tutup mode anotasi":"Buka mode anotasi"} (${t.count})`:"Mark a part of the page, then send it to the chat",icon:y,onSelect:t.onToggle,active:t.active,disabled:!a}],children:e("button",{type:"button",onClick:t.onToggle,disabled:!a,"aria-label":"Page annotation mode","aria-pressed":t.active,title:t.active?"Tutup mode anotasi":t.count>0?`Anotasi (${t.count}) — buka lagi`:"Mark a part of the page, then send it to the chat",className:`${h} relative ${t.active?"bg-ink/10 text-ink":""}`,children:[e(y,{size:14}),t.count>0&&e("span",{className:"absolute -top-0.5 -right-0.5 min-w-[13px] h-[13px] px-0.5 rounded-full bg-error text-paper text-[10px] leading-[13px] font-mono text-center",children:t.count})]})})}if(r.push({id:"copy",actions:[{label:p?"Copied URL!":"Copy URL",icon:ae,onSelect:i.onCopy,disabled:!a}],children:e("button",{type:"button",onClick:i.onCopy,disabled:!a,"aria-label":"Salin URL",title:p?"Copied URL!":"Copy URL",className:h,children:p?e(f,{size:14,className:"text-success"}):e(ae,{size:14})})}),i.onReconnect){let t=i.onReconnect;r.push({id:"reconnect",actions:[{label:"Sambungkan ulang live view",icon:va,onSelect:t}],children:e("button",{type:"button",onClick:t,"aria-label":"Sambungkan ulang live view",title:"Reconnect live view",className:h,children:e(va,{size:14})})})}return r.push({id:"open-external",actions:[{label:i.openExternalLabel,icon:Ce,onSelect:i.onOpenExternal,disabled:!a}],children:e("button",{type:"button",onClick:i.onOpenExternal,disabled:!a,"aria-label":i.openExternalLabel,title:i.openExternalTitle,className:h,children:e(Ce,{size:14})})}),r}var P=108,ee=280,oe=18,te=140,ne=36;function cu({url:i,statusDotClass:r,statusLabel:a,viewportMode:l,zoomLevel:p,onChangeViewport:c,onZoomIn:t,onZoomOut:u,onResetZoom:b,onSetZoom:m,annotate:A,onIncludeInChat:E,onOpenExternal:D,onReconnect:_,openExternalLabel:U,openExternalTitle:W,children:H}){let[X,T]=n(!1),[q,N]=n(!1),g=o(null),[x,R]=n(0),F=O({url:i,zoomLevel:p,copied:X,included:q,viewportMode:l,onChangeViewport:c,annotate:A,onReconnect:_,onIncludeInChat:()=>{E(),N(!0),setTimeout(()=>N(!1),2500)},onCopy:()=>{if(!i)return;navigator.clipboard.writeText(i).then(()=>{T(!0),setTimeout(()=>T(!1),2000)}).catch(()=>{})},onOpenExternal:D,onZoomIn:t,onZoomOut:u,onResetZoom:b,onSetZoom:m,openExternalLabel:U,openExternalTitle:W});V(()=>{let v=g.current;if(!v)return;R(v.clientWidth)}),V(()=>{let v=g.current;if(!v||typeof ResizeObserver>"u")return;let M=new ResizeObserver(()=>R(v.clientWidth));return M.observe(v),()=>M.disconnect()},[]);let I=x===0||x>=ee,S=I?x>0?Math.min(P,x*0.25):P:oe,G=x>0?Math.max(0,x-S-te-ne):void 0;return e("div",{ref:g,"data-browser-toolbar":"",className:"h-10 px-2.5 border-b border-ink/10 bg-paper flex items-center gap-x-2 flex-shrink-0 select-none",children:[e("div",{className:"flex items-center space-x-1.5 flex-shrink-0 min-w-0",style:{maxWidth:`${S}px`},title:a,children:[e("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${r}`}),I&&e("span",{className:"text-[10px] font-mono uppercase tracking-wide text-ink/60 truncate",children:a})]}),e("div",{className:"flex flex-1 min-w-0 items-center",children:H}),e(fo,{clusters:F,available:G})]})}
|
|
1
|
+
import{d,n,V,o,e,s,f,B,ae,Ce,Ua,ha,ut,va,ur,zt,Ut}from"./index-3wpsr2bc.js";import{Sa,Ta,fo}from"./index-epbqzayj.js";var J={name:"square-pen",size:24,node:[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],aliases:["pen-box","edit","pen-square"]},y=s(J);var K={name:"laptop",size:24,node:[["path",{d:"M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z",key:"1pdavp"}],["path",{d:"M20.054 15.987H3.946",key:"14rxg9"}]]},Z=s(K);var Q={name:"ratio",size:24,node:[["rect",{width:"12",height:"20",x:"6",y:"2",rx:"2",key:"1oxtiu"}],["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]},w=s(Q);var Y={name:"tablet",size:24,node:[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18",key:"1dp563"}]]},C=s(Y);var k=[{id:"responsive",label:"Responsive (100% Fluid)",category:"responsive",icon:ha},{id:"desktop-16-9",label:"Desktop 16:9 (Auto H:W)",category:"responsive",icon:w},{id:"laptop",label:"Laptop (1024 × 768)",category:"responsive",icon:Z},{id:"tablet",label:"Tablet (768 × 1024)",category:"mobile",icon:C},{id:"mobile",label:"Mobile Phone (375 × 667)",category:"mobile",icon:ur},{id:"mobile-lg",label:"Mobile Large (414 × 896)",category:"mobile",icon:ur}];function j(i){switch(i){case"desktop-16-9":return"Desktop 16:9";case"laptop":return"Laptop 1024p";case"tablet":return"Tablet 768p";case"mobile":return"Mobile 375p";case"mobile-lg":return"Mobile Lg 414p";case"responsive":default:return"Responsive"}}function z({viewportMode:i,onChangeViewport:r,zoomLevel:a=100,onSetZoom:l}){let[p,c]=n(null);return e("div",{className:"flex items-center space-x-1.5 flex-shrink-0",children:[e("div",{className:"hidden sm:flex items-center bg-canvas border border-ink/10 rounded-md p-0.5",children:[e("button",{type:"button",onClick:()=>r("responsive"),className:`p-1 rounded text-xs transition-colors cursor-pointer ${i==="responsive"?"bg-ink text-canvas font-medium":"text-ink/50 hover:text-ink"}`,title:"Responsive (100% Fluid)",children:e(ha,{size:12})}),e("button",{type:"button",onClick:()=>r("desktop-16-9"),className:`p-1 rounded text-xs transition-colors cursor-pointer ${i==="desktop-16-9"?"bg-ink text-canvas font-medium":"text-ink/50 hover:text-ink"}`,title:"Desktop 16:9 (Auto Height following Width)",children:e(w,{size:12})}),e("button",{type:"button",onClick:()=>r("tablet"),className:`p-1 rounded text-xs transition-colors cursor-pointer ${i==="tablet"?"bg-ink text-canvas font-medium":"text-ink/50 hover:text-ink"}`,title:"Tablet (768px)",children:e(C,{size:12})}),e("button",{type:"button",onClick:()=>r("mobile"),className:`p-1 rounded text-xs transition-colors cursor-pointer ${i==="mobile"?"bg-ink text-canvas font-medium":"text-ink/50 hover:text-ink"}`,title:"Mobile (375px)",children:e(ur,{size:12})})]}),e("button",{type:"button","aria-haspopup":"menu","aria-expanded":p!==null,onClick:(t)=>c(p?null:zt(t.currentTarget)),className:"flex items-center space-x-1 px-2 py-1 rounded bg-canvas border border-ink/15 hover:border-ink/30 text-ink text-[11px] font-mono transition-colors cursor-pointer",title:"Device & Responsive Testing Menu",children:[e("span",{className:"hidden md:inline text-[10px] font-medium",children:j(i)}),e(B,{size:11,className:"text-ink/60"})]}),e(Ut,{anchor:p,ariaLabel:"Device & Responsive Testing Menu",className:"w-56 bg-paper border border-ink/15 rounded-lg shadow-xl py-1 text-xs font-mono",onClose:()=>c(null),children:[e("div",{className:"px-2.5 py-1 text-[10px] text-ink/40 uppercase tracking-wider font-semibold",children:"Responsive Testing"}),k.filter((t)=>t.category==="responsive").map((t)=>{let u=t.icon,b=i===t.id;return e("button",{type:"button",onClick:()=>{r(t.id),c(null)},className:`w-full px-2.5 py-1.5 flex items-center justify-between text-left hover:bg-ink/5 cursor-pointer ${b?"bg-ink/10 font-semibold text-ink":"text-ink/75"}`,children:[e("div",{className:"flex items-center space-x-2",children:[e(u,{size:13,className:"text-ink/60"}),e("span",{children:t.label})]}),b&&e(f,{size:12,className:"text-success"})]},t.id)}),e("div",{className:"mt-1 pt-1 border-t border-ink/10 px-2.5 py-1 text-[10px] text-ink/40 uppercase tracking-wider font-semibold",children:"Mobile Testing"}),k.filter((t)=>t.category==="mobile").map((t)=>{let u=t.icon,b=i===t.id;return e("button",{type:"button",onClick:()=>{r(t.id),c(null)},className:`w-full px-2.5 py-1.5 flex items-center justify-between text-left hover:bg-ink/5 cursor-pointer ${b?"bg-ink/10 font-semibold text-ink":"text-ink/75"}`,children:[e("div",{className:"flex items-center space-x-2",children:[e(u,{size:13,className:"text-ink/60"}),e("span",{children:t.label})]}),b&&e(f,{size:12,className:"text-success"})]},t.id)}),l&&e(d,{children:[e("div",{className:"mt-1 pt-1 border-t border-ink/10 px-2.5 py-1 text-[10px] text-ink/40 uppercase tracking-wider font-semibold",children:["Zoom Scale (",a,"%)"]}),e("div",{className:"grid grid-cols-3 gap-1 px-2 py-1",children:[50,75,100,125,150,200].map((t)=>e("button",{type:"button",onClick:()=>{l(t),c(null)},className:`px-1.5 py-1 text-center rounded text-[11px] font-mono cursor-pointer transition-colors ${a===t?"bg-ink text-canvas font-semibold":"bg-canvas border border-ink/10 text-ink/75 hover:bg-ink/5"}`,children:[t,"%"]},t))})]})]})]})}function L({zoomLevel:i,onZoomIn:r,onZoomOut:a,onResetZoom:l}){return e("div",{className:"flex items-center bg-canvas border border-ink/10 rounded-md p-0.5 space-x-0.5 text-xs font-mono",children:[e("button",{type:"button",onClick:a,disabled:i<=50,"aria-label":"Perkecil tampilan",title:"Zoom Out (-10%)",className:"p-1 rounded hover:bg-ink/5 disabled:opacity-25 disabled:hover:bg-transparent text-ink/70 hover:text-ink cursor-pointer disabled:cursor-not-allowed transition-colors",children:e(Ta,{size:12})}),e("button",{type:"button",onClick:l,className:"px-1 text-[10px] font-medium text-ink/75 hover:text-ink hover:underline cursor-pointer select-none",title:"Reset Zoom (100%)",children:[i,"%"]}),e("button",{type:"button",onClick:r,disabled:i>=200,"aria-label":"Perbesar tampilan",title:"Zoom In (+10%)",className:"p-1 rounded hover:bg-ink/5 disabled:opacity-25 disabled:hover:bg-transparent text-ink/70 hover:text-ink cursor-pointer disabled:cursor-not-allowed transition-colors",children:e(Sa,{size:12})})]})}var h="p-1.5 rounded hover:bg-ink/5 disabled:opacity-25 disabled:hover:bg-transparent text-ink/70 hover:text-ink transition-colors cursor-pointer disabled:cursor-not-allowed";function O(i){let r=[],{url:a,zoomLevel:l,copied:p,included:c}=i;if(i.viewportMode&&i.onChangeViewport){let{viewportMode:t,onChangeViewport:u,onSetZoom:b}=i;r.push({id:"viewport",actions:k.map((m)=>({label:m.label,icon:m.icon,onSelect:()=>u(m.id),active:t===m.id})),children:e(z,{viewportMode:t,onChangeViewport:u,zoomLevel:l,onSetZoom:b})})}if(r.push({id:"zoom",actions:[{label:"Zoom in (+10%)",icon:Sa,onSelect:i.onZoomIn,disabled:l>=200},{label:"Zoom out (-10%)",icon:Ta,onSelect:i.onZoomOut,disabled:l<=50},{label:"Reset zoom (100%)",icon:ut,onSelect:i.onResetZoom,active:l===100}],children:e(L,{zoomLevel:l,onZoomIn:i.onZoomIn,onZoomOut:i.onZoomOut,onResetZoom:i.onResetZoom})}),r.push({id:"include",actions:[{label:c?"Page context added to the draft":"Include this page in the chat draft",icon:Ua,onSelect:i.onIncludeInChat,disabled:!a}],children:e("button",{type:"button",onClick:i.onIncludeInChat,disabled:!a,"aria-label":"Include this page in the chat draft",title:c?"Page context added to the draft":"Include this page in the chat draft",className:h,children:c?e(f,{size:14,className:"text-success"}):e(Ua,{size:14})})}),i.annotate){let t=i.annotate;r.push({id:"annotate",actions:[{label:t.count>0?`${t.active?"Tutup mode anotasi":"Buka mode anotasi"} (${t.count})`:"Mark a part of the page, then send it to the chat",icon:y,onSelect:t.onToggle,active:t.active,disabled:!a}],children:e("button",{type:"button",onClick:t.onToggle,disabled:!a,"aria-label":"Page annotation mode","aria-pressed":t.active,title:t.active?"Tutup mode anotasi":t.count>0?`Anotasi (${t.count}) — buka lagi`:"Mark a part of the page, then send it to the chat",className:`${h} relative ${t.active?"bg-ink/10 text-ink":""}`,children:[e(y,{size:14}),t.count>0&&e("span",{className:"absolute -top-0.5 -right-0.5 min-w-[13px] h-[13px] px-0.5 rounded-full bg-error text-paper text-[10px] leading-[13px] font-mono text-center",children:t.count})]})})}if(r.push({id:"copy",actions:[{label:p?"Copied URL!":"Copy URL",icon:ae,onSelect:i.onCopy,disabled:!a}],children:e("button",{type:"button",onClick:i.onCopy,disabled:!a,"aria-label":"Salin URL",title:p?"Copied URL!":"Copy URL",className:h,children:p?e(f,{size:14,className:"text-success"}):e(ae,{size:14})})}),i.onReconnect){let t=i.onReconnect;r.push({id:"reconnect",actions:[{label:"Sambungkan ulang live view",icon:va,onSelect:t}],children:e("button",{type:"button",onClick:t,"aria-label":"Sambungkan ulang live view",title:"Reconnect live view",className:h,children:e(va,{size:14})})})}return r.push({id:"open-external",actions:[{label:i.openExternalLabel,icon:Ce,onSelect:i.onOpenExternal,disabled:!a}],children:e("button",{type:"button",onClick:i.onOpenExternal,disabled:!a,"aria-label":i.openExternalLabel,title:i.openExternalTitle,className:h,children:e(Ce,{size:14})})}),r}var P=108,ee=280,oe=18,te=140,ne=36;function cu({url:i,statusDotClass:r,statusLabel:a,viewportMode:l,zoomLevel:p,onChangeViewport:c,onZoomIn:t,onZoomOut:u,onResetZoom:b,onSetZoom:m,annotate:A,onIncludeInChat:E,onOpenExternal:D,onReconnect:_,openExternalLabel:U,openExternalTitle:W,children:H}){let[X,T]=n(!1),[q,N]=n(!1),g=o(null),[x,R]=n(0),F=O({url:i,zoomLevel:p,copied:X,included:q,viewportMode:l,onChangeViewport:c,annotate:A,onReconnect:_,onIncludeInChat:()=>{E(),N(!0),setTimeout(()=>N(!1),2500)},onCopy:()=>{if(!i)return;navigator.clipboard.writeText(i).then(()=>{T(!0),setTimeout(()=>T(!1),2000)}).catch(()=>{})},onOpenExternal:D,onZoomIn:t,onZoomOut:u,onResetZoom:b,onSetZoom:m,openExternalLabel:U,openExternalTitle:W});V(()=>{let v=g.current;if(!v)return;R(v.clientWidth)}),V(()=>{let v=g.current;if(!v||typeof ResizeObserver>"u")return;let M=new ResizeObserver(()=>R(v.clientWidth));return M.observe(v),()=>M.disconnect()},[]);let I=x===0||x>=ee,S=I?x>0?Math.min(P,x*0.25):P:oe,G=x>0?Math.max(0,x-S-te-ne):void 0;return e("div",{ref:g,"data-browser-toolbar":"",className:"h-10 px-2.5 border-b border-ink/10 bg-paper flex items-center gap-x-2 flex-shrink-0 select-none",children:[e("div",{className:"flex items-center space-x-1.5 flex-shrink-0 min-w-0",style:{maxWidth:`${S}px`},title:a,children:[e("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${r}`}),I&&e("span",{className:"text-[10px] font-mono uppercase tracking-wide text-ink/60 truncate",children:a})]}),e("div",{className:"flex flex-1 min-w-0 items-center",children:H}),e(fo,{clusters:F,available:G})]})}
|
|
2
2
|
export{cu};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d,n,i,o,u,a,Ar,He,se,e,Gn,w,SA,we,Qs,S,ir,or,s,In,M,Xe,B,ie,ae,Ce,Ge,Ji,Xt,Zi,Gr,C,F,b,ce,nn,Du,at,it,zA,UA,jo,qo,Qu,Ve}from"./index-st202rjv.js";import{Eu,qi,Bu,Iu}from"./index-e1pr3k50.js";import{Ts,fr,_u}from"./index-tfsaj5d1.js";var Yt={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"]},qe=s(Yt);var Bt={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(Bt);var Jt={name:"package-open",size:24,node:[["path",{d:"M12 22v-9",key:"x3hkom"}],["path",{d:"M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z",key:"2ntwy6"}],["path",{d:"M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13",key:"1pmm1c"}],["path",{d:"M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z",key:"12ttoo"}]]},Ye=s(Jt);var Zt={name:"scissors",size:24,node:[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]},Se=s(Zt);function Be({rootPath:t,activeRepo:r,repos:l,reposScanning:c,onRefreshRepos:p,onSelectRepo:f,searchQuery:x,onSearchChange:h,onRefresh:v,refreshing:g}){return e("div",{className:"p-3 border-b border-ink/10 flex flex-col space-y-2",children:[e("div",{className:"flex items-center justify-between",children:[e(fr,{rootPath:t,activeRepo:r,onSelectRepo:f,repos:l,scanning:c,onRefreshRepos:p}),e("button",{onClick:v,className:"p-1.5 text-ink/40 hover:text-ink hover:bg-ink/5 rounded transition-colors",title:"Refresh",children:e(C,{size:14,className:g?"animate-spin":""})})]}),e("div",{className:"relative",children:[e(F,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-ink/40"}),e("input",{type:"text",placeholder:"Search files...",value:x,onChange:(m)=>h(m.currentTarget.value),className:"w-full bg-canvas border border-ink/20 rounded pl-8 pr-3 py-1.5 text-xs focus:outline-none focus:border-ink transition-colors text-ink placeholder-ink/40"})]})]})}function Je({name:t,path:r,isFolder:l,isOpen:c,ignored:p,selected:f,gitStatus:x,folderStatus:h}){let v=f?"text-ink font-semibold":x?x.colorClass:h?h.colorClass:p?"text-ink/40":"";return e(d,{children:[l?c?e(B,{size:12,className:"flex-shrink-0 text-ink/40"}):e(ie,{size:12,className:"flex-shrink-0 text-ink/40"}):e("span",{className:"w-3 flex-shrink-0"}),e(at,{name:t,isFolder:l,isOpen:c,size:12,className:`flex-shrink-0${p?" opacity-40":""}`}),e("span",{className:`truncate min-w-0 flex-1 ${v}`,title:p?`${r} — git-ignored`:void 0,children:t}),x&&e("span",{className:`font-mono text-[10px] font-bold px-1 rounded flex-shrink-0 ${x.colorClass}`,title:`Git: ${x.label}`,children:x.charStatus}),h&&e("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${h.hasDeleted?"bg-error":h.hasModified||h.hasStaged?"bg-info":"bg-success"}`,title:`${h.count} changed file${h.count>1?"s":""}`})]})}var en=28,tn=9,rn=8;function on(t){let{isFolder:r,hasGitStatus:l,pasteLabel:c,busy:p,chainLabel:f,foldable:x,selectionCount:h,isArchive:v}=t,g=[],m=h>1,k=h===1?"":` ${h} items`;if(m)return g.push({kind:"item",id:"cut",label:`Cut${k}`,icon:e(Se,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"copy",label:`Copy${k}`,icon:e(ae,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"separator"}),g.push({kind:"item",id:"compress",label:`Compress${k} to…`,icon:e(Xe,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"separator"}),g.push({kind:"item",id:"delete",label:`Delete${k}`,icon:e(M,{size:13,className:"text-error"}),tone:"text-error"}),g;if(r){if(g.push({kind:"item",id:"new_file",label:"New File",icon:e(Ji,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"new_folder",label:"New Folder",icon:e(Xt,{size:13,className:"text-ink/60"})}),f)g.push({kind:"item",id:"unfold",label:"Unfold Folders",icon:e(B,{size:13,className:"text-ink/60"})});if(x)g.push({kind:"item",id:"fold",label:"Fold Folders",icon:e(ie,{size:13,className:"text-ink/60"})});g.push({kind:"separator"})}else{if(g.push({kind:"item",id:"view",label:"View",icon:e(Ge,{size:13,className:"text-ink/60"})}),v)g.push({kind:"item",id:"extract",label:"Extract…",icon:e(Ye,{size:13,className:"text-ink/60"}),disabled:p});if(l)g.push({kind:"item",id:"diff",label:"Open in Diff Panel",icon:e(Zi,{size:13,className:"text-warning"}),tone:"font-medium"});g.push({kind:"separator"})}if(g.push({kind:"item",id:"cut",label:"Cut",icon:e(Se,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"copy",label:"Copy",icon:e(ae,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"compress",label:"Compress to…",icon:e(Xe,{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(Ts,{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(Ce,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"copy_path",label:"Copy Path",icon:e(ae,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"copy_relative",label:"Copy Relative Path",icon:e(ae,{size:13,className:"text-ink/60"})}),g.push({kind:"separator"}),g.push({kind:"item",id:"history",label:"Show Git History",icon:e(In,{size:13,className:"text-ink/60"})}),g.push({kind:"separator"}),g.push({kind:"item",id:"rename",label:"Rename",icon:e(qe,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"delete",label:"Delete",icon:e(M,{size:13,className:"text-error"}),tone:"text-error"}),g}function sn(t){let r=t.filter((c)=>c.kind==="item").length,l=t.length-r;return r*en+l*tn+rn}function Ze({x:t,y:r,isFolder:l,hasGitStatus:c,pasteLabel:p,chainLabel:f,foldable:x,busy:h,selectionCount:v,isArchive:g,onAction:m,menuRef:k}){let D=on({isFolder:l,hasGitStatus:c,pasteLabel:p,busy:h,chainLabel:f,foldable:x,selectionCount:v,isArchive:g}),E=sn(D),N=typeof window<"u"?Math.max(10,Math.min(t,window.innerWidth-210-12)):t,L=typeof window<"u"?Math.max(10,Math.min(r,window.innerHeight-E-12)):r;return se(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>m("close"),onContextMenu:(T)=>{T.preventDefault(),m("close")},children:e("div",{ref:k,className:"glass-popover fixed z-50 bg-paper border border-ink/15 shadow-2xl rounded-lg py-1 min-w-[185px] text-xs text-ink font-sans",style:{top:L,left:N},onClick:(T)=>T.stopPropagation(),children:D.map((T,R)=>T.kind==="separator"?e("div",{className:"my-1 border-t border-ink/10"},`sep-${R}`):e("button",{type:"button",disabled:T.disabled,onClick:()=>m(T.id),className:`w-full text-left px-3 py-1.5 flex items-center space-x-2 transition-colors ${T.disabled?"opacity-40 cursor-default":"hover:bg-ink/5"} ${T.tone??""}`,children:[T.icon,e("span",{children:T.label})]},T.id))})}),document.body)}function Fe({folderPath:t,kind:r,value:l,error:c,isLoading:p,onChange:f,onCancel:x,onSubmit:h}){let v=r==="folder"?"Folder":"File";return se(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:h,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-3 text-sm",children:["New ",v]}),e("div",{className:"flex items-center gap-1 mb-1 text-xs font-mono text-ink/50 min-w-0",children:e("span",{className:"truncate",title:t,children:[t||".","/"]})}),e("input",{autoFocus:!0,type:"text",value:l,onChange:(g)=>f(g.currentTarget.value),placeholder:r==="folder"?"folder name or nested/path":"file name or nested/path","aria-label":`New ${v.toLowerCase()} name`,className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none mb-1 ${c?"border-error":"border-ink/20 focus:border-ink"}`}),e("p",{className:"text-[10px] text-ink/40 mb-2",children:["Nested paths create the folders they need — ",e("span",{className:"font-mono",children:"lib/parse.ts"}),"."]}),c&&e("p",{className:"text-[11px] text-error mb-2",children:c}),e("div",{className:"flex justify-end space-x-2 mt-2",children:[e("button",{type:"button",onClick:x,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:p,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:p||!l.trim(),children:p?"Creating...":"Create"})]})]})}),document.body)}function et({fileName:t,displayName:r,isFolder:l,count:c=1,isLoading:p,onCancel:f,onConfirm:x}){let h=c>1;return se(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("div",{className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-2 text-sm",children:["Delete ",h?`${c} Items`:l?"Folder":"File"]}),e("p",{className:"text-xs text-ink/70 mb-4",children:["Are you sure you want to delete ",h?e(d,{children:["the ",c," selected entries"]}):e("span",{className:"font-mono bg-canvas px-1 rounded",children:t}),"? This action cannot be undone."]}),r&&r!==t&&e("p",{className:"text-[11px] text-ink/50 mb-4",children:["The row is ",e("span",{className:"font-mono",children:r}),"; this deletes"," ",e("span",{className:"font-mono",children:t})," only."]}),e("div",{className:"flex justify-end space-x-2",children:[e("button",{onClick:f,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:p,children:"Cancel"}),e("button",{onClick:x,className:"px-3 py-1.5 text-xs bg-error text-white rounded hover:bg-error/90 transition-colors flex items-center",disabled:p,children:p?"Deleting...":"Delete"})]})]})}),document.body)}function tt({isFolder:t,renameValue:r,originalPath:l,displayName:c,error:p,isLoading:f,onChange:x,onCancel:h,onSubmit:v}){return se(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:v,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-3 text-sm",children:["Rename ",t?"Folder":"File"]}),e("input",{autoFocus:!0,type:"text",value:r,onChange:(g)=>x(g.currentTarget.value),"aria-label":`Rename ${t?"folder":"file"} path`,className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none mb-1 ${p?"border-error":"border-ink/20 focus:border-ink"}`}),e("p",{className:"text-[10px] text-ink/40 mb-2",children:["Paths are relative to the tree — ",e("span",{className:"font-mono",children:"lib/deep/name.ts"})," moves it too."]}),c&&e("p",{className:"text-[11px] text-ink/50 mb-2",children:["The row is ",e("span",{className:"font-mono",children:c}),"; this renames"," ",e("span",{className:"font-mono",children:l}),". Use"," ",e("span",{className:"font-mono",children:"Unfold Folders"})," to rename a folder inside the chain."]}),p&&e("p",{className:"text-[11px] text-error mb-2",children:p}),e("div",{className:"flex justify-end space-x-2",children:[e("button",{type:"button",onClick:h,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:f,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:f||!r.trim()||r===l,children:f?"Renaming...":"Rename"})]})]})}),document.body)}function nt({filePath:t,fetcherState:r,fetcherData:l,onClose:c}){let p=l?.type==="history"?l.data:void 0;return se(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("div",{className:"glass-overlay bg-paper rounded-lg shadow-xl w-full max-w-4xl border border-ink/10 flex flex-col max-h-[85vh]",children:[e("div",{className:"flex items-center justify-between p-4 border-b border-ink/10",children:[e("h3",{className:"text-sm font-semibold text-ink flex items-center space-x-2",children:[e(In,{size:16,className:"text-ink/60"}),e("span",{children:["Git History: ",e("span",{className:"font-mono font-normal opacity-80",children:t})]})]}),e("button",{onClick:c,className:"p-1 hover:bg-ink/5 rounded text-ink/60 transition-colors",children:e(b,{size:14})})]}),e("div",{className:"flex-1 scrollbar-overlay-container p-2",children:r==="idle"?p?p.length>0?e("table",{className:"w-full text-left border-collapse text-[11px]",children:[e("thead",{className:"bg-canvas sticky top-0 z-10 border-b border-ink/10",children:e("tr",{children:[e("th",{className:"px-3 py-2 font-semibold text-ink/70 rounded-tl",children:"Description"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-32",children:"Date"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-32",children:"Author"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-24 text-right rounded-tr",children:"Commit"})]})}),e("tbody",{className:"divide-y divide-ink/5",children:p.map((f,x)=>e("tr",{className:"hover:bg-ink/[0.03] transition-colors group",children:[e("td",{className:"px-3 py-2 text-ink",children:f.message?e("span",{className:"font-medium text-ink/90 group-hover:text-ink",children:f.message}):null}),e("td",{className:"px-3 py-2 text-ink/60 whitespace-nowrap font-mono text-[10.5px]",children:f.time}),e("td",{className:"px-3 py-2 text-ink/70 whitespace-nowrap truncate max-w-[120px]",children:f.author}),e("td",{className:"px-3 py-2 text-right",children:f.hash?e("span",{className:"font-mono text-ink/50 group-hover:text-ink font-semibold transition-colors bg-canvas px-1.5 py-0.5 rounded border border-ink/10",children:f.hash}):null})]},x))})]}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs",children:"No commit history found for this file."}):l?.error?e("div",{className:"p-8 text-center text-error font-mono text-xs",children:l.error}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs",children:"Loading history..."}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs flex items-center justify-center space-x-2",children:[e(C,{size:14,className:"animate-spin"}),e("span",{children:"Loading history..."})]})})]})}),document.body)}function rt({actions:t,file:r,isFolder:l,chainLabel:c}){let p=t.selectionCount;return e(d,{children:[t.showCreateModal&&e(Fe,{folderPath:r.path,kind:t.createKind,value:t.createName,error:t.createError,isLoading:t.busy,onChange:t.setCreateName,onCancel:t.closeCreate,onSubmit:t.submitCreate}),t.showDeleteModal&&e(et,{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(tt,{isFolder:l,renameValue:t.renameValue,originalPath:r.path,displayName:l?c:void 0,error:t.renameError,isLoading:t.busy,onChange:t.setRenameValue,onCancel:t.closeRename,onSubmit:t.submitRename}),t.showHistoryModal&&e(nt,{filePath:r.path,fetcherState:t.fetcherState,fetcherData:t.fetcherData,onClose:t.closeHistory})]})}function Ae(t){let r=t.map(an);return r.some((l,c)=>l!==t[c])?r:t}function an(t){if(t.type!=="folder"||!Array.isArray(t.children))return t;let r=Ae(t.children),l=r===t.children?t:{...t,children:r};while(Array.isArray(l.children)&&l.children.length===1){let c=l.children[0];if(c.type!=="folder")break;l={...l,name:`${l.name}/${c.name}`,path:c.path,children:c.children,ignored:c.ignored??l.ignored}}return l}function Ee(t){return t.type==="folder"&&t.name.includes("/")}function Me(t,r){let l=r.split("/"),c=t.split("/");if(l.length<2||l.length>c.length||l.some((f)=>!f))return null;let p=c.slice(0,c.length-l.length);return l.map((f,x)=>[...p,...l.slice(0,x+1)].join("/"))}function ot(t,r){let l=new Map;if(r.size===0)return{nodes:t,roots:l};let c=!1,p=(x)=>x.flatMap((h)=>{if(h.type!=="folder")return[h];let v=Array.isArray(h.children)?p(h.children):h.children,g=v===h.children?h:{...h,children:v},m=r.has(h.path)?Me(h.path,h.name):null;if(!m)return[g];c=!0,l.set(m[0],h.path);let k={...g,name:m[m.length-1].split("/").pop()};for(let y=m.length-1;y>0;y-=1){let D=m[y-1];k={name:D.split("/").pop(),path:D,type:"folder",ignored:g.ignored,children:[k]}}return[k]}),f=p(t);return{nodes:c?f:t,roots:l}}function st(t,r){let l=new Set,c=(x)=>{for(let h of x){if(h.type!=="folder")continue;if(l.add(h.path),Array.isArray(h.children))c(h.children)}};c(t);let p=r.split("/").slice(0,-1),f=[];for(let x=0;x<p.length;x+=1){let h=p.slice(0,x+1).join("/");if(l.has(h))f.push(h)}return f}function Ne({folderPath:t,rootPath:r,repo:l,onCreated:c,onOpenCreated:p}){let f=it(),[x,h]=n(!1),[v,g]=n("file"),[m,k]=n(""),[y,D]=n(null),E=o(null);return i(()=>{if(f.state!=="idle"||!f.data)return;let N=f.data;if(E.current===N)return;if(E.current=N,N.success&&N.path){let L=N.kind==="folder"?"folder":"file";h(!1),k(""),D(null);let T=N.path.split("/").pop()||N.path;if(c({path:N.path,name:T,kind:L}),L==="file")p?.({path:N.path,name:T})}else D(N.error||`Could not create the ${v}`)},[f.state,f.data]),{open:x,kind:v,name:m,setName:k,error:y,busy:f.state!=="idle",openDialog:(N="file")=>{g(N),k(""),D(null),h(!0)},closeDialog:()=>h(!1),submit:(N)=>{N.preventDefault();let L=m.trim();if(!L)return;D(null);let T=new FormData;if(T.append("actionType","create"),T.append("path",t),T.append("name",L),v==="folder")T.append("kind","folder");if(l&&l!==".")T.append("repo",l);if(r)T.append("root",r);f.submit(T,{method:"post",action:"/api/fs/action"})}}}function De(t){if(!t)return null;if(t.entries.length===1)return t.entries[0].name;return`${t.entries.length} items`}function lt(t,r){return`${t??""}\x00${r}`}function Le(t,r){if(r==="folder")return t;let l=t.lastIndexOf("/");return l===-1?".":t.slice(0,l)}function ct(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)}function dt(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 pt(t,r){let l=dt(t,r);if(l)return l;if(r===ct(t.path))return"Already in this folder";return null}function ut(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===ct(c.path)))return"Already in this folder";for(let c of t.entries){let p=dt(c,l);if(p)return p}return null}function ft(t){if(typeof t!=="object"||t===null)return null;let r=t;if(typeof r.scope!=="string")return null;if(r.mode!=="copy"&&r.mode!=="cut")return null;let l=Array.isArray(r.entries)?r.entries:typeof r.path==="string"?[{path:r.path,name:r.name,kind:r.kind}]:[],c=[];for(let p of l){let f=ln(p);if(!f)return null;c.push(f)}if(c.length===0)return null;return{scope:r.scope,entries:c,mode:r.mode}}function ln(t){if(typeof t!=="object"||t===null)return null;let r=t;if(typeof r.path!=="string"||typeof r.name!=="string")return null;if(r.kind!=="file"&&r.kind!=="folder")return null;let l=r.path.split("/");if(r.path===""||r.path.startsWith("/")||l.some((c)=>c===""||c==="."||c===".."))return null;return{path:r.path,name:r.name,kind:r.kind}}var $e=[{id:"zip",label:"ZIP",extension:"zip"},{id:"7z",label:"7Z",extension:"7z"},{id:"rar",label:"RAR",extension:"rar"},{id:"tar",label:"TAR",extension:"tar"},{id:"tar.gz",label:"TAR.GZ",extension:"tar.gz"}],mt=[[".tar.gz","tar.gz"],[".tar.bz2","tar.bz2"],[".tar.xz","tar.xz"],[".tgz","tar.gz"],[".tbz2","tar.bz2"],[".txz","tar.xz"],[".tar","tar"],[".zip","zip"],[".7z","7z"],[".rar","rar"],[".gz","gz"],[".bz2","bz2"],[".xz","xz"]];function ze(t){let r=t.toLowerCase();for(let[l,c]of mt)if(r.endsWith(l))return c;return null}function ht(t){return ze(t)!==null}function cn(t){return $e.find((r)=>r.id===t)}function dn(t){return cn(t)?.extension??"zip"}function gt(t){let r=t.toLowerCase();for(let[l]of mt)if(r.endsWith(l))return t.slice(0,-l.length);return t}function bt(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)||"."}function xt(t){let r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}function vt(t){if(t.length===0)return".";let r=t.map((c)=>bt(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 Re(t,r){let l=dn(r);if(t.length===1){let f=t[0],x=gt(f.name),h=x.lastIndexOf(".");return`${(f.kind==="folder"?f.name:h>0?x.slice(0,h):x)||"archive"}.${l}`}let c=vt(t.map((f)=>f.path)),p=xt(c);return`${p==="."||p===""?"archive":p}.${l}`}function yt(t){return vt(t.map((r)=>r.path))}function kt(t){let r=bt(t),l=gt(xt(t));if(!l)return r;return r==="."?l:`${r}/${l}`}function Ct(t){return t.toUpperCase()}function Ft({file:t,diff:r,onOpenFile:l,onActionComplete:c,onCreated:p,onRenamed:f,onUnfold:x,onFold:h,clipboard:v,isFolder:g,selection:m,selected:k,archive:y}){let D=it(),[E,N]=n(null),L=o(null),[T,R]=n(!1),[A,H]=n(!1),[W,ee]=n(!1),[te,oe]=n(t.path),[G,I]=n(null),{repo:O,rootPath:K}=t,j=Ne({folderPath:t.path,rootPath:K,repo:O,onCreated:(z)=>p?p(z):c(),onOpenCreated:(z)=>l?.({...z,root:K,repo:O||"."})}),ne=o(null);i(()=>{if(D.state!=="idle"||!D.data)return;let z=D.data;if(ne.current===z)return;if(ne.current=z,z.success&&!z.type)if(R(!1),H(!1),I(null),z.previousPath&&z.path&&f)f(z.previousPath,z.path);else c();else if(!z.success&&z.error&&T)I(z.error)},[D.state,D.data]);let q=(z)=>{if(O&&O!==".")z.append("repo",O);if(K)z.append("root",K);D.submit(z,{method:"post",action:"/api/fs/action"})},V=()=>{l?.({path:t.path,name:t.name,root:K,repo:O||"."})},J={path:t.path,name:t.name,kind:g?"folder":"file"},re=k&&m.length>1?m:[J],he=ht(t.name),Q=v.clip&&!v.refusalFor(J)?`Paste ${De(v.clip)??"item"}`:null,fe=(z)=>{if(N(null),I(null),z==="view")V();else if(z==="diff")window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.path,staged:r?.staged,status:r?.status||"M",repo:O||".",root:K}}));else if(z==="explorer"){let _=new FormData;_.append("actionType","open_explorer"),_.append("path",t.path),q(_)}else if(z==="copy_path")nn(Du(t.basePath,t.path));else if(z==="copy_relative")nn(t.path);else if(z==="history"){ee(!0);let _=new FormData;_.append("actionType","git_history"),_.append("path",t.path),q(_)}else if(z==="rename")oe(t.path),R(!0);else if(z==="unfold")x?.();else if(z==="fold")h?.();else if(z==="new_file")j.openDialog("file");else if(z==="new_folder")j.openDialog("folder");else if(z==="delete")H(!0);else if(z==="cut")v.cut(re);else if(z==="copy")v.copy(re);else if(z==="compress")y.openCompress(re);else if(z==="extract")y.openExtract(J);else if(z==="duplicate")v.duplicate(J);else if(z==="paste")v.paste(J)},le=(z)=>{z.preventDefault(),I(null);let _=new FormData;_.append("actionType","rename"),_.append("path",t.path),_.append("newPath",te),q(_)},xe=()=>{let z=new FormData;if(z.append("actionType","delete"),re.length>1)z.append("paths",JSON.stringify(re.map((_)=>_.path)));else z.append("path",t.path);q(z)};return{contextMenu:E,contextMenuRef:L,openContextMenu:(z,_)=>N({x:z,y:_}),closeContextMenu:()=>N(null),showRenameModal:T,showDeleteModal:A,showHistoryModal:W,showCreateModal:j.open,createKind:j.kind,createError:j.error,createName:j.name,setCreateName:j.setName,renameValue:te,setRenameValue:oe,renameError:G,busy:D.state!=="idle"||j.busy||v.busy||y.busy,pasteLabel:Q,selectionCount:re.length,isArchive:he,chainLabel:x!==void 0,foldable:h!==void 0,fetcherState:D.state,fetcherData:D.data,handleAction:fe,submitCreate:j.submit,submitRename:le,submitDelete:xe,closeCreate:j.closeDialog,closeDelete:()=>H(!1),closeRename:()=>R(!1),closeHistory:()=>ee(!1)}}function Nt({target:t,dragging:r,clipboard:l,onDragStart:c,onDragEnd:p,onDropOn:f,onHoverAccept:x}){let h=r?.path===t.path,v=Boolean(r)&&!h&&l.moveRefusalFor(r,t)===null,[g,m]=n(!1);return i(()=>{if(!r)m(!1)},[r]),{isDragging:h,acceptsDrop:v,isDropHovered:g&&v,onDragStart:(y)=>{if(y.dataTransfer?.setData("text/plain",t.path),y.dataTransfer)y.dataTransfer.effectAllowed="move";c(t)},onDragEnd:p,onDragOver:(y)=>{if(!r)return;if(y.stopPropagation(),m(v),!v)return;if(y.preventDefault(),y.dataTransfer)y.dataTransfer.dropEffect="move";x?.(t)},onDragLeave:()=>m(!1),onDrop:(y)=>{if(!r)return;if(y.stopPropagation(),!v)return;y.preventDefault(),f(t)}}}var pn=450,wt=8,un=700;function Dt({enabled:t,onLongPress:r}){let l=o(null),c=o(null),p=o(0),f=o(r);f.current=r;let x=a(()=>{if(l.current!==null)clearTimeout(l.current),l.current=null;c.current=null},[]);return i(()=>x,[x]),{onTouchStart:(h)=>{if(!t)return;let v=h.touches[0];if(!v)return;x(),c.current={x:v.clientX,y:v.clientY},l.current=setTimeout(()=>{l.current=null;let g=c.current;if(c.current=null,!g)return;p.current=Date.now(),f.current(g.x,g.y)},pn)},onTouchMove:(h)=>{let v=c.current,g=h.touches[0];if(!v||!g)return;if(Math.abs(g.clientX-v.x)>wt||Math.abs(g.clientY-v.y)>wt)x()},onTouchEnd:x,onTouchCancel:x,consume:()=>{if(p.current===0)return!1;let h=Date.now()-p.current<un;return p.current=0,h}}}function fn(t,r,l){if(r||l)return!1;return!Array.isArray(t.children)}function Oe({file:t,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:x,onCreated:h,onRenamed:v,expandedPaths:g,onToggleFolder:m,gitFileMap:k,gitFolderMap:y,clipboard:D,archive:E,selection:N,selectionTargets:L,dragging:T,onDragStart:R,onDragEnd:A,onDropOn:H,onUnfold:W,onFold:ee,foldRoots:te,touch:oe=!1}){let G=t.type==="folder",[I,O]=n(!1),[K,j]=n(!1),[ne,q]=n(!1),[V,J]=n(!1),re=Array.isArray(t.children)?t.children:[],he=(t.path||"").replace(/^\/+/,""),Q=!G?k?.get(he)||k?.get(t.path):void 0,fe=Q?Gn(Q.status,Q.staged):null,le=G?y?.get(he)||y?.get(t.path):null,xe=Boolean(fe),z=t.ignored===!0,_=g?g.has(t.path):I,de=t.forceExpanded!==void 0?t.forceExpanded:_;i(()=>{J(!0)},[]),i(()=>{if(G&&g)O(g.has(t.path))},[g,t.path,G]),i(()=>{if(G&&de&&fn(t,K,ne)&&p)q(!0),j(!0),Promise.resolve(p(t.path)).finally(()=>j(!1))},[G,de,t.children,t.path,p,K,ne]);let ye={path:t.path,name:t.name,kind:G?"folder":"file"},be=N.selected.has(t.path),U=Ft({file:{path:t.path,name:t.name,basePath:l,rootPath:r,repo:c},selection:L,selected:be,archive:E,diff:{staged:Q?.staged||(Q?.status?Q.status[0]!==" "&&Q.status[0]!=="?":!1),status:fe?.charStatus},onOpenFile:f,onActionComplete:x,onCreated:h,onRenamed:v,onUnfold:W&&Ee({type:G?"folder":"file",name:t.name})?()=>W(ye):void 0,onFold:ee&&te?.has(t.path)?()=>ee(te.get(t.path)):void 0,clipboard:D,isFolder:G});ce(U.contextMenuRef,U.closeContextMenu);let Y=Dt({enabled:oe,onLongPress:(X,ge)=>U.openContextMenu(X,ge)}),ke=(X)=>{if(X.stopPropagation(),Y.consume())return;let ge=N.gestureOf(X);if(ge!=="plain"){N.applyGesture(ge,t.path);return}if(N.applyGesture("plain",t.path),G){let ue=!de;if(O(ue),t.forceExpanded!==void 0)t.forceExpanded=void 0;if(m?.(t.path,ue),!ue)q(!1)}else if(f)f({...t,root:r,repo:c||"."})},ve=(X)=>{X.preventDefault(),X.stopPropagation(),N.ensureForContext(t.path),U.openContextMenu(X.clientX,X.clientY)},pe=Nt({target:ye,dragging:T,clipboard:D,onDragStart:R,onDragEnd:A,onDropOn:H,onHoverAccept:W});return e("div",{children:[e("div",{className:`flex items-center space-x-1.5 py-1 px-2 cursor-pointer rounded group select-none ${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:!oe,onClick:ke,onContextMenu:ve,onDragStart:pe.onDragStart,onDragEnd:pe.onDragEnd,onDragOver:pe.onDragOver,onDragLeave:pe.onDragLeave,onDrop:pe.onDrop,onTouchStart:Y.onTouchStart,onTouchMove:Y.onTouchMove,onTouchEnd:Y.onTouchEnd,onTouchCancel:Y.onTouchCancel,children:e(Je,{name:t.name,path:t.path,isFolder:G,isOpen:de,ignored:z,selected:be,gitStatus:fe,folderStatus:le})}),de&&K&&e("div",{className:"ml-3 border-l border-ink/10 pl-3 py-0.5 text-[10px] text-ink/30",children:"Loading…"}),de&&!K&&re.length>0&&e("div",{className:"ml-3 border-l border-ink/10 pl-1",children:re.map((X)=>e(Oe,{file:X,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:x,onCreated:h,onRenamed:v,expandedPaths:g,onToggleFolder:m,gitFileMap:k,gitFolderMap:y,clipboard:D,archive:E,selection:N,selectionTargets:L,dragging:T,onDragStart:R,onDragEnd:A,onDropOn:H,onUnfold:W,onFold:ee,foldRoots:te,touch:oe},X.path))}),V&&U.contextMenu&&e(Ze,{x:U.contextMenu.x,y:U.contextMenu.y,isFolder:G,hasGitStatus:xe,pasteLabel:U.pasteLabel,chainLabel:U.chainLabel,foldable:U.foldable,busy:U.busy,selectionCount:U.selectionCount,isArchive:U.isArchive,onAction:U.handleAction}),V&&e(rt,{actions:U,file:t,isFolder:G,chainLabel:Ee({type:G?"folder":"file",name:t.name})?t.name:void 0})]})}function Rt({x:t,y:r,pasteLabel:l,busy:c,onAction:p,menuRef:f}){let h=l?104:76,v=typeof window<"u"?Math.max(10,Math.min(t,window.innerWidth-190-12)):t,g=typeof window<"u"?Math.max(10,Math.min(r,window.innerHeight-h-12)):r;return se(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>p("close"),onContextMenu:(m)=>{m.preventDefault(),p("close")},children:e("div",{ref:f,className:"glass-popover fixed z-50 bg-paper border border-ink/15 shadow-2xl rounded-lg py-1 min-w-[185px] text-xs text-ink font-sans",style:{top:g,left:v},onClick:(m)=>m.stopPropagation(),children:[e("button",{type:"button",onClick:()=>p("new_file"),className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 flex items-center space-x-2 transition-colors",children:[e(Ji,{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(Xt,{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(Ts,{size:13,className:"text-ink/60"}),e("span",{children:l})]})]})}),document.body)}function Tt({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 St({title:t,subject:r,error:l,busy:c,submitLabel:p,busyLabel:f,onSubmit:x,onCancel:h,children:v}){return se(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:x,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-1 text-sm",children:t}),e("p",{className:"text-[11px] text-ink/50 mb-3 break-words",children:r}),v,l&&e("p",{className:"text-[11px] text-error mb-2",children:l}),e("div",{className:"flex justify-end space-x-2 mt-3",children:[e("button",{type:"button",onClick:h,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:c,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:c,children:c?f:p})]})]})}),document.body)}function mn({entries:t,format:r,name:l,destination:c,formats:p,error:f,busy:x,onFormatChange:h,onNameChange:v,onDestinationChange:g,onCancel:m,onSubmit:k}){let y=t.slice(0,4).map((E)=>E.name).join(", "),D=t.length>4?` +${t.length-4} more`:"";return e(St,{title:`Compress ${t.length===1?t[0].name:`${t.length} items`}`,subject:`${y}${D}`,error:f,busy:x,submitLabel:"Compress",busyLabel:"Compressing...",onCancel:m,onSubmit:(E)=>{E.preventDefault(),k()},children:[e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"archive-format",children:"Format"}),e("select",{id:"archive-format",value:r,onChange:(E)=>h(E.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 text-xs font-mono focus:outline-none focus:border-ink mb-3",children:p.map((E)=>e("option",{value:E.id,disabled:!E.available,children:[E.label,E.available?"":` — ${E.tool} not installed`]},E.id))}),e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"archive-name",children:"Archive name"}),e("input",{id:"archive-name",autoFocus:!0,type:"text",value:l,onChange:(E)=>v(E.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:(E)=>g(E.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 hn({archive:t,kindLabel:r,destination:l,error:c,busy:p,onDestinationChange:f,onCancel:x,onSubmit:h}){return e(St,{title:`Extract ${t.name}`,subject:`${r} archive · extracts into a folder`,error:c,busy:p,submitLabel:"Extract",busyLabel:"Extracting...",onCancel:x,onSubmit:(v)=>{v.preventDefault(),h()},children:[e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"extract-destination",children:"Extract to folder"}),e("input",{id:"extract-destination",autoFocus:!0,type:"text",value:l,onChange:(v)=>f(v.currentTarget.value),"aria-label":"Extract destination",className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none ${c?"border-error":"border-ink/20 focus:border-ink"}`})]})}function At({archive:t}){if(t.compress)return e(mn,{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(hn,{archive:t.extract.archive,kindLabel:Ct(ze(t.extract.archive.name)??"zip"),destination:t.extract.destination,error:t.error,busy:t.busy,onDestinationChange:t.setExtractDestination,onCancel:t.cancel,onSubmit:t.submitExtract});return null}function Et(){let[t,r]=S("files.outlineExpanded",!1),l=Ar(),c=He(UA,zA),{symbols:p,total:f,truncated:x,notice:h}=Iu({content:c.content,language:c.language,state:c.state,note:c.note,path:c.path});if(c.state==="diff")return null;let v=c.preview,g=(m,k)=>{if(!c.path)return;if(v){let y=Qu(p,k);if(y)qo({path:c.path,...y});return}jo({path:c.path,line:m.line,column:m.column,length:m.name.length})};return e("div",{className:"border-t border-ink/10 bg-canvas/30 flex-shrink-0",children:[e("div",{className:"flex items-center hover:bg-ink/5 transition-colors",children:e("button",{type:"button",onClick:()=>r(!t),"aria-expanded":t,"aria-controls":l,"aria-label":"Outline",title:t?"Hide outline":"Show outline",className:"flex flex-1 min-w-0 items-center space-x-1 py-1.5 pl-3 pr-2 text-left font-semibold text-xs text-ink transition-colors cursor-pointer",children:[e("span",{className:"w-3 text-center font-mono","aria-hidden":"true",children:t?"▾":"▸"}),e(Gr,{size:12}),e("span",{children:"Outline"}),f>0&&e("span",{className:"font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[10px] text-ink/50",children:x?`${p.length}/${f.toLocaleString()}`:f})]})}),e("div",{className:"section-reveal","data-expanded":t,id:l,inert:!t,children:e("div",{children:e("div",{className:"px-2 pb-2",children:p.length===0?e("div",{className:"px-1 text-[10px] text-ink/40 italic py-1",children:h}):e("div",{className:"max-h-48 overflow-y-auto scrollbar-overlay-container flex flex-col",children:[p.map((m,k)=>e("button",{type:"button",onClick:()=>g(m,k),"aria-label":v?`${qi(m.kind)} ${m.name}`:`${qi(m.kind)} ${m.name}, line ${m.line}`,title:v?`Jump to ${qi(m.kind).toLowerCase()}`:`${qi(m.kind)} · line ${m.line}`,className:"flex w-full min-w-0 items-center gap-1.5 rounded px-1 py-0.5 text-left transition-colors hover:bg-ink/5 active:bg-ink/10",style:{paddingLeft:`${4+m.depth*12}px`},children:[e(Eu,{kind:m.kind}),e("span",{className:"min-w-0 flex-1 truncate text-[11px] font-mono text-ink/80",children:m.name}),!v&&e("span",{className:"flex-shrink-0 font-mono text-[10px] text-ink/35",children:m.line})]},`${m.line}:${m.kind}:${m.name}`)),x&&e("div",{className:"px-1 py-1 text-[10px] italic text-ink/40",children:Bu(f)})]})})})})]})}function Pe(t,r){return Ae(t.map((l)=>gn(l,r)))}function gn(t,r){if(t.type!=="folder")return t;let l=r[t.path];if(!l)return t;return{...t,children:Pe(l,r)}}function bn(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)}function Lt(t){let r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}function Mt(t){return[...t].sort((r,l)=>{if(r.type!==l.type)return r.type==="folder"?-1:1;return r.name.localeCompare(l.name)})}function Ie(t,r,l){let c=l.path.split("/"),p=c.slice(0,-1).join("/"),f=[...t],x={...r},h=f,v=null;for(let g=0;g<c.length-1;){let m=c.slice(0,g+1).join("/"),k=h.find((L)=>L.type==="folder"&&L.path===m),y=k?null:h.find((L)=>L.type==="folder"&&L.path.startsWith(`${m}/`)&&(p===L.path||p.startsWith(`${L.path}/`))),D=k??y,E=D?x[D.path]??D.children:null;if(D&&!Array.isArray(E))return{nodes:t,cache:r};if(!D){let L=xn(h,x,m);if(L){h=L;let T=h.find((A)=>A.path===m),R=Array.isArray(T?.children)?[...T.children]:[];x[m]=R,h=R,v=m,g+=1;continue}}let N=Array.isArray(E)?[...E]:[];if(D){x[D.path]=N,h=N,v=D.path,g=D.path.split("/").length;continue}h.push({name:c[g],path:m,type:"folder",ignored:!1}),x[m]=N,h=N,v=m,g+=1}if(h.push(l),v!==null)x[v]=Mt(h);return f=Mt(f),{nodes:f,cache:x}}function xn(t,r,l){let c=t.findIndex((v)=>v.type==="folder"&&v.path.startsWith(`${l}/`));if(c===-1)return null;let p=t[c],f=p.path.slice(l.length+1).split("/"),x=r[p.path]??p.children;if(Array.isArray(x))r[p.path]=x;let h={name:f[f.length-1],path:p.path,type:"folder",ignored:p.ignored,...Array.isArray(x)?{children:x}:{}};for(let v=f.length-2;v>=0;v-=1)h={name:f[v],path:`${l}/${f.slice(0,v+1).join("/")}`,type:"folder",ignored:!1,children:[h]};return t[c]={name:Lt(l),path:l,type:"folder",ignored:!1,children:[h]},t}function $t(t,r,l){let c=t.find((m)=>m.path===l);if(c)return{entry:c,nodes:t.filter((m)=>m.path!==l),cache:r};let p=bn(l),f=r[p],x=f?.find((m)=>m.path===l);if(f&&x)return{entry:x,nodes:t,cache:{...r,[p]:f.filter((m)=>m.path!==l)}};let v=Object.keys(r).filter((m)=>l.startsWith(`${m}/`)&&r[m].some((k)=>k.path===l)).sort((m,k)=>k.length-m.length)[0];if(!v)return{entry:null,nodes:t,cache:r};let g=r[v];return{entry:g.find((m)=>m.path===l),nodes:t,cache:{...r,[v]:g.filter((m)=>m.path!==l)}}}function zt(t,r,l){let c=!1,p=t.map((f)=>{let x=f.path===r||f.path.startsWith(`${r}/`),h=Array.isArray(f.children)?zt(f.children,r,l):void 0;if(!x&&h===f.children)return f;c=!0;let v=x?f.path===r?l:`${l}${f.path.slice(r.length)}`:f.path,g=x?{...f,path:v,name:Lt(v)}:{...f};if(h!==void 0)g.children=h;return g});return c?p:t}function Ot(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:zt(f,r,l)}return c}function Pt(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 It(t){if(!w(t))return{status:"missing"};if(typeof t.root!=="string"||t.root==="")return{status:"missing"};return{status:"ok",files:Array.isArray(t.files)?t.files.filter((r)=>w(r)):[],root:t.root}}async function Ke(t){try{return It(await(await fetch(t)).json())}catch{return{status:"failed"}}}function Ht({enabled:t,rootPath:r,activeRepo:l,expandedPaths:c,onExpansionPruned:p}){let f=`${r??""}\x00${l}`,[x,h]=n({scope:"",files:[],root:""}),[v,g]=n(!1),m=o({}),k=o([]),y=o(f);y.current=f;let D=o(""),E=o(""),N=o(c);N.current=c;let L=(I)=>{let O=new URLSearchParams;if(r)O.set("root",r);if(l&&l!==".")O.set("repo",l);if(I)O.set("path",I);return O.set("t",String(Date.now())),`/api/fs/dir?${O.toString()}`},T=(I,O)=>{D.current=I,E.current=O;let K=Pe(k.current,m.current);return h({scope:I,files:K,root:O}),K},R=async(I)=>{let O=[...N.current];if(O.length===0)return;let K=await Promise.all(O.map(async(V)=>({path:V,read:await Ke(L(V))})));if(y.current!==I)return;let j=[];for(let{path:V,read:J}of K)if(J.status==="ok")m.current[V]=J.files;else if(J.status==="missing")j.push(V);if(j.length===0)return;let ne=new Set(j);for(let V of j)delete m.current[V];let q=new Set([...N.current].filter((V)=>!ne.has(V)));N.current=q,p(q)},A=async()=>{if(!t)return;let I=y.current;g(!0);try{let O=await Ke(L());if(y.current!==I)return;if(O.status!=="ok")return;if(D.current!==I)m.current={};if(k.current=O.files,T(I,O.root),await R(I),y.current!==I)return;T(I,O.root)}finally{if(y.current===I)g(!1)}},H=async(I)=>{let O=y.current,K=await Ke(L(I));if(y.current!==O||K.status!=="ok")return;if(m.current[I]=K.files,D.current===O)T(O,E.current)},W=(I)=>{let O=It(I);if(O.status!=="ok")return;let K=y.current;if(D.current!==K)m.current={};k.current=O.files,T(K,O.root),R(K).then(()=>{if(y.current===K)T(K,O.root)})},ee=()=>{m.current={},k.current=[],D.current="",E.current="",h({scope:"",files:[],root:""})},te=(I)=>{let O=y.current;if(D.current!==O)return null;let K={name:I.path.slice(I.path.lastIndexOf("/")+1),path:I.path,type:I.kind,ignored:!1},j=Ie(k.current,m.current,K);if(j.nodes===k.current)return null;return k.current=j.nodes,m.current=j.cache,T(O,E.current)},oe=(I,O)=>{let K=y.current;if(D.current!==K)return null;let j=$t(k.current,m.current,I);if(!j.entry)return null;m.current=Ot(j.cache,I,O);let ne={...j.entry,path:O,name:O.slice(O.lastIndexOf("/")+1)},q=Ie(j.nodes,m.current,ne);return k.current=q.nodes,m.current=q.cache,T(K,E.current)},G=x.scope===f;return{scope:f,files:G?x.files:[],root:G?x.root:"",isLoading:v,reload:A,loadChildren:H,adoptRoot:W,insertEntry:te,moveEntry:oe,reset:ee}}function Gt({rootPath:t,repo:r,onComplete:l,onError:c}){let p=it(),[f,x]=S("files.clipboard",null),h=ft(f),v=lt(t,r),g=o(!1),m=o(null);i(()=>{if(p.state!=="idle"||!p.data)return;let N=p.data;if(m.current===N)return;m.current=N;let L=g.current;if(g.current=!1,N.success){if(L)x(null);if(N.failures?.length)c(`${N.failures.length} item(s) could not be moved: ${N.failures[0].error}`);l()}else c(N.error||"The transfer did not complete")},[p.state,p.data]);let k=a((N,L)=>{g.current=L;let T=new FormData;for(let[R,A]of Object.entries(N))T.append(R,A);if(r&&r!==".")T.append("repo",r);if(t)T.append("root",t);p.submit(T,{method:"post",action:"/api/fs/action"})},[p,r,t]),y=a((N)=>ut(h,v,Le(N.path,N.kind)),[h,v]),D=a((N,L)=>pt(N,Le(L.path,L.kind)),[]),E=a((N,L,T,R)=>{let A=new FormData;A.append("actionType","paste"),A.append("mode",T),A.append("targetPath",L.path),A.append("targetKind",L.kind);for(let H of N)A.append("sourcePath",H.path);if(r&&r!==".")A.append("repo",r);if(t)A.append("root",t);g.current=R,p.submit(A,{method:"post",action:"/api/fs/action"})},[p,r,t]);return{clip:h,busy:p.state!=="idle",refusalFor:y,moveRefusalFor:D,copy:(N)=>{if(N.length===0)return;x({scope:v,entries:N.map(({path:L,name:T,kind:R})=>({path:L,name:T,kind:R})),mode:"copy"})},cut:(N)=>{if(N.length===0)return;x({scope:v,entries:N.map(({path:L,name:T,kind:R})=>({path:L,name:T,kind:R})),mode:"cut"})},duplicate:(N)=>{k({actionType:"duplicate",path:N.path},!1)},move:(N,L)=>{let T=D(N,L);if(T){c(T);return}E([N],L,"cut",Boolean(h?.mode==="cut"&&h.entries.some((R)=>R.path===N.path)))},paste:(N)=>{if(!h)return;let L=y(N);if(L){c(L);return}E(h.entries.map(({path:T,name:R,kind:A})=>({path:T,name:R,kind:A})),N,h.mode,h.mode==="cut")}}}var vn=$e.map((t)=>({...t,available:!0,tool:t.id}));function Kt({rootPath:t,repo:r,onComplete:l}){let c=it(),[p,f]=n(vn),[x,h]=n(null),[v,g]=n(null),[m,k]=n(null),y=o(null),D=o(null);i(()=>{let R=!1;return(async()=>{try{let H=await(await fetch("/api/fs/archive")).json();if(!R&&Array.isArray(H.formats)&&H.formats.length>0)f(H.formats)}catch{}})(),()=>{R=!0}},[]),i(()=>{if(c.state!=="idle"||!c.data)return;let R=c.data;if(D.current===R)return;D.current=R;let A=y.current;if(y.current=null,R.success){if(k(null),A==="compress")h(null);if(A==="extract")g(null);l()}else if(A)k(R.error||"The archive request failed")},[c.state,c.data]);let E=a((R)=>{let A=new FormData;for(let[H,W]of Object.entries(R))A.append(H,W);if(r&&r!==".")A.append("repo",r);if(t)A.append("root",t);c.submit(A,{method:"post",action:"/api/fs/action"})},[c,r,t]),N=a((R)=>{if(R.length===0)return;let A=p.find((H)=>H.id==="zip"&&H.available)?.id??p.find((H)=>H.available)?.id??"zip";k(null),g(null),h({entries:R.map(({path:H,name:W,kind:ee})=>({path:H,name:W,kind:ee})),format:A,name:Re(R,A),destination:yt(R)})},[p]),L=a((R)=>{k(null),h(null),g({archive:R,destination:kt(R.path)})},[]),T=a((R)=>{h((A)=>{if(!A)return A;let H=Re(A.entries,A.format),W=A.name===H?Re(A.entries,R):A.name;return{...A,format:R,name:W}})},[]);return{formats:p,compress:x,extract:v,error:m,busy:c.state!=="idle",openCompress:N,openExtract:L,setFormat:T,setName:(R)=>h((A)=>A&&{...A,name:R}),setCompressDestination:(R)=>h((A)=>A&&{...A,destination:R}),setExtractDestination:(R)=>g((A)=>A&&{...A,destination:R}),cancel:()=>{h(null),g(null),k(null)},submitCompress:()=>{let R=x;if(!R)return;y.current="compress",k(null),E({actionType:"compress",format:R.format,name:R.name.trim(),destination:R.destination.trim()||".",paths:JSON.stringify(R.entries.map((A)=>A.path))})},submitExtract:()=>{let R=v;if(!R)return;y.current="extract",k(null),E({actionType:"extract",path:R.archive.path,destination:R.destination.trim()||"."})}}}function yn(t){if(t.shiftKey)return"range";if(t.metaKey||t.ctrlKey)return"toggle";return"plain"}function kn(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 jt(t){let[r,l]=n(()=>new Set),[c,p]=n(null),f=a((g,m)=>{if(g==="range"){l(new Set(kn(t,c,m)));return}if(p(m),g==="toggle"){l((k)=>{let y=new Set(k);if(y.has(m))y.delete(m);else y.add(m);return y});return}l(new Set([m]))},[c,t]),x=a((g)=>{l((m)=>{if(m.has(g))return m;return new Set([g])}),p(g)},[]),h=a(()=>{l(new Set),p(null)},[]),v=a(yn,[]);return u(()=>({selected:r,count:r.size,anchor:c,gestureOf:v,applyGesture:f,ensureForContext:x,clear:h}),[r,c,v,f,x,h])}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 _t({listing:t,setExpandedPaths:r,setStoredExpandedPaths:l,reload:c,onMoved:p}){let f=a((v,g)=>{let m=st(g,v);if(m.length===0)return;r((k)=>{if(m.every((D)=>k.has(D)))return k;let y=new Set(k);for(let D of m)y.add(D);return l(Array.from(y)),y})},[r,l]),x=a((v)=>{let g=t.insertEntry(v);if(!g){c();return}f(v.path,g)},[t,c,f]),h=a((v,g)=>{p?.(v,g),r((k)=>{let y=Pt(k,v,g);return l(Array.from(y)),y});let m=t.moveEntry(v,g);if(!m){c();return}f(g,m)},[t,c,f,r,l,p]);return{insertCreated:x,moveRenamed:h}}var Cn=new Set;function Wt({scope:t,setExpandedPaths:r,setStoredExpandedPaths:l}){let[c,p]=n({scope:t,chains:new Map}),f=a((v)=>{let g=Me(v.path,v.name);if(!g)return;p((k)=>{let y=k.scope===t?k.chains:new Map;if(y.get(v.path)?.length===g.length)return k;let E=new Map(y);return E.set(v.path,g),{scope:t,chains:E}});let m=g.slice(0,-1);r((k)=>{if(m.every((D)=>k.has(D)))return k;let y=new Set(k);for(let D of m)y.add(D);return l(Array.from(y)),y})},[t,r,l]),x=a((v)=>{let g=c.scope===t?c.chains.get(v):void 0;if(!g)return;let m=g.slice(0,-1);p((k)=>{if(k.scope!==t)return k;let y=new Map(k.chains);return y.delete(v),{scope:t,chains:y}}),r((k)=>{if(!m.some((D)=>k.has(D)))return k;let y=new Set(k);for(let D of m)y.delete(D);return l(Array.from(y)),y})},[t,c,r,l]),h=a((v,g)=>{let m=c.scope===t?c.chains:null;if(!m)return;let k=new Map,y=[],D=!1;for(let[E,N]of m){if(N.findIndex((A,H)=>A===v&&H>0&&H<N.length-1)!==-1){D=!0;continue}let T=N.map((A)=>A===v?g:A.startsWith(`${v}/`)?`${g}${A.slice(v.length)}`:A),R=T[T.length-1];if(R!==E||T.some((A,H)=>A!==N[H]))D=!0;k.set(R,T),y.push(...T.slice(0,-1))}if(!D)return;p({scope:t,chains:k}),r((E)=>{if(y.every((L)=>E.has(L)))return E;let N=new Set(E);for(let L of y)N.add(L);return l(Array.from(N)),N})},[t,c,r,l]);return{unfolded:c.scope===t&&c.chains.size>0?new Set(c.chains.keys()):Cn,unfold:f,fold:x,rekey:h}}function Ut(t,r){let l=r.trim().toLowerCase();if(!l)return t;let c=(p)=>{let f=p.name.toLowerCase().includes(l);if(p.type==="folder"){let x=(p.children||[]).map(c).filter((h)=>h!==null);if(f||x.length>0)return{...p,children:f&&x.length===0?p.children:x,forceExpanded:!0};return null}return f?p:null};return t.map(c).filter((p)=>p!==null)}function Vt({dragging:t,clipboard:r,target:l}){let c=Boolean(t)&&r.moveRefusalFor(t,l)===null,[p,f]=n(!1);return i(()=>{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 oi({className:t="",enabled:r=!0,active:l=!0,rootPath:c,onOpenFile:p,refreshKey:f=0,onRefresh:x}){let[h,v]=S("files.searchQuery",""),[g,m,k]=S("files.expandedPaths",[]),[y,D]=n(()=>new Set(g)),{activeRepo:E,setActiveRepo:N}=ir(c),{repos:L,scanning:T,rescan:R}=or(c,r),{fileMap:A,folderMap:H,refreshGitStatus:W}=Qs(c,E,r),[ee,te]=n(null),oe=o(null);i(()=>{if(!k)return;D((P)=>{let Z=new Set(g);if(P.size===Z.size&&Array.from(Z).every((me)=>P.has(me)))return P;return Z})},[k,g]);let G=Ht({enabled:r,rootPath:c,activeRepo:E,expandedPaths:y,onExpansionPruned:(P)=>{D(P),m(Array.from(P))}});i(()=>{if(!k||!l)return;G.reload()},[f,c,r,E,k,l]);let I=r&&k?SA(G.scope):null,O=we(I);i(()=>{if(O.data)G.adoptRoot(O.data)},[O.data]);let K=(P)=>(W(),G.loadChildren(P)),j=(P,Z)=>{let me=new Set(y);if(Z)me.add(P);else me.delete(P);D(me),m(Array.from(me))},{unfolded:ne,unfold:q,fold:V,rekey:J}=Wt({scope:G.scope,setExpandedPaths:D,setStoredExpandedPaths:m}),re=G.files,he=ot(re,ne),Q=Ut(he.nodes,h),fe=je(Q,(P)=>P.forceExpanded!==void 0?P.forceExpanded:y.has(P.path)),le=jt(fe.map((P)=>P.path)),xe=fe.filter((P)=>le.selected.has(P.path)).map(({path:P,name:Z,kind:me})=>({path:P,name:Z,kind:me})),z=(P)=>{if(P===E)return;G.reset(),D(new Set),m([]),le.clear(),N(P)},_=()=>{if(W(),x)x();else G.reload()},{insertCreated:de,moveRenamed:ye}=_t({listing:G,setExpandedPaths:D,setStoredExpandedPaths:m,reload:_,onMoved:(P,Z)=>J(P,Z)}),be=_u(),{pushToast:U}=Ve(),Y=Gt({rootPath:c,repo:E,onComplete:_,onError:(P)=>U(P,"error")}),ke=Kt({rootPath:c,repo:E,onComplete:_}),ve={path:".",name:".",kind:"folder"},pe=Y.clip&&!Y.refusalFor(ve)?`Paste ${De(Y.clip)??"item"}`:null,[X,ge]=n(null),ue=Vt({dragging:X,clipboard:Y,target:ve}),Te=Ne({folderPath:".",rootPath:c,repo:E,onCreated:de,onOpenCreated:(P)=>p?.({...P,root:c,repo:E})}),[_e,qt]=n(!1);i(()=>qt(!0),[]);let{count:We,clear:Ue}=le;if(i(()=>{if(!l)return;let P=(Z)=>{if(Z.key==="Escape"&&We>0)Ue()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[l,We,Ue]),!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 Qt=G.isLoading||O.refreshing;return e("div",{className:`flex flex-col h-full bg-paper ${t}`,children:[e(Be,{rootPath:c,activeRepo:E,repos:L,reposScanning:T,onRefreshRepos:R,onSelectRepo:z,searchQuery:h,onSearchChange:v,onRefresh:_,refreshing:Qt}),e("div",{className:`flex-1 scrollbar-overlay-container p-2 font-mono text-[11px] text-ink/80 ${be?"file-tree-touch":""} ${ue.highlighted?"bg-info/[0.06]":""}`,onContextMenu:(P)=>{P.preventDefault(),te({x:P.clientX,y:P.clientY})},onDragEnter:ue.onDragEnter,onDragLeave:ue.onDragLeave,onDragOver:ue.onDragOver,onDrop:ue.onDrop,children:G.isLoading&&Q.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"Loading files..."}):Q.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"No files found"}):Q.map((P)=>e(Oe,{file:P,rootPath:c,basePath:G.root,repo:E,onLoadChildren:K,onOpenFile:p,onActionComplete:_,onCreated:de,onRenamed:ye,expandedPaths:y,onToggleFolder:j,gitFileMap:A,gitFolderMap:H,clipboard:Y,archive:ke,selection:le,selectionTargets:xe,dragging:X,onDragStart:ge,onDragEnd:()=>ge(null),onDropOn:(Z)=>{if(!X)return;Y.move(X,Z)},onUnfold:q,onFold:V,foldRoots:he.roots,touch:be},P.path))}),e(Et,{}),_e&&e(Tt,{menu:ee,menuRef:oe,pasteLabel:pe,busy:Y.busy,create:Te,onAction:(P)=>{if(te(null),P==="new_file")Te.openDialog("file");if(P==="new_folder")Te.openDialog("folder");if(P==="paste")Y.paste(ve)}}),_e&&e(At,{archive:ke})]})}export{oi as FileExplorer};
|
|
1
|
+
import{d,n,i,o,u,a,Ar,He,se,e,Gn,w,SA,we,Qs,S,ir,or,s,In,M,Xe,B,ie,ae,Ce,Ge,Ji,Xt,Zi,Gr,C,F,b,ce,nn,Du,at,it,zA,UA,jo,qo,Qu,Ve}from"./index-3wpsr2bc.js";import{Eu,qi,Bu,Iu}from"./index-qntytvt0.js";import{Ts,fr,_u}from"./index-4qt2e84b.js";var Yt={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"]},qe=s(Yt);var Bt={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(Bt);var Jt={name:"package-open",size:24,node:[["path",{d:"M12 22v-9",key:"x3hkom"}],["path",{d:"M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z",key:"2ntwy6"}],["path",{d:"M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13",key:"1pmm1c"}],["path",{d:"M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z",key:"12ttoo"}]]},Ye=s(Jt);var Zt={name:"scissors",size:24,node:[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]},Se=s(Zt);function Be({rootPath:t,activeRepo:r,repos:l,reposScanning:c,onRefreshRepos:p,onSelectRepo:f,searchQuery:x,onSearchChange:h,onRefresh:v,refreshing:g}){return e("div",{className:"p-3 border-b border-ink/10 flex flex-col space-y-2",children:[e("div",{className:"flex items-center justify-between",children:[e(fr,{rootPath:t,activeRepo:r,onSelectRepo:f,repos:l,scanning:c,onRefreshRepos:p}),e("button",{onClick:v,className:"p-1.5 text-ink/40 hover:text-ink hover:bg-ink/5 rounded transition-colors",title:"Refresh",children:e(C,{size:14,className:g?"animate-spin":""})})]}),e("div",{className:"relative",children:[e(F,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-ink/40"}),e("input",{type:"text",placeholder:"Search files...",value:x,onChange:(m)=>h(m.currentTarget.value),className:"w-full bg-canvas border border-ink/20 rounded pl-8 pr-3 py-1.5 text-xs focus:outline-none focus:border-ink transition-colors text-ink placeholder-ink/40"})]})]})}function Je({name:t,path:r,isFolder:l,isOpen:c,ignored:p,selected:f,gitStatus:x,folderStatus:h}){let v=f?"text-ink font-semibold":x?x.colorClass:h?h.colorClass:p?"text-ink/40":"";return e(d,{children:[l?c?e(B,{size:12,className:"flex-shrink-0 text-ink/40"}):e(ie,{size:12,className:"flex-shrink-0 text-ink/40"}):e("span",{className:"w-3 flex-shrink-0"}),e(at,{name:t,isFolder:l,isOpen:c,size:12,className:`flex-shrink-0${p?" opacity-40":""}`}),e("span",{className:`truncate min-w-0 flex-1 ${v}`,title:p?`${r} — git-ignored`:void 0,children:t}),x&&e("span",{className:`font-mono text-[10px] font-bold px-1 rounded flex-shrink-0 ${x.colorClass}`,title:`Git: ${x.label}`,children:x.charStatus}),h&&e("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${h.hasDeleted?"bg-error":h.hasModified||h.hasStaged?"bg-info":"bg-success"}`,title:`${h.count} changed file${h.count>1?"s":""}`})]})}var en=28,tn=9,rn=8;function on(t){let{isFolder:r,hasGitStatus:l,pasteLabel:c,busy:p,chainLabel:f,foldable:x,selectionCount:h,isArchive:v}=t,g=[],m=h>1,k=h===1?"":` ${h} items`;if(m)return g.push({kind:"item",id:"cut",label:`Cut${k}`,icon:e(Se,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"copy",label:`Copy${k}`,icon:e(ae,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"separator"}),g.push({kind:"item",id:"compress",label:`Compress${k} to…`,icon:e(Xe,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"separator"}),g.push({kind:"item",id:"delete",label:`Delete${k}`,icon:e(M,{size:13,className:"text-error"}),tone:"text-error"}),g;if(r){if(g.push({kind:"item",id:"new_file",label:"New File",icon:e(Ji,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"new_folder",label:"New Folder",icon:e(Xt,{size:13,className:"text-ink/60"})}),f)g.push({kind:"item",id:"unfold",label:"Unfold Folders",icon:e(B,{size:13,className:"text-ink/60"})});if(x)g.push({kind:"item",id:"fold",label:"Fold Folders",icon:e(ie,{size:13,className:"text-ink/60"})});g.push({kind:"separator"})}else{if(g.push({kind:"item",id:"view",label:"View",icon:e(Ge,{size:13,className:"text-ink/60"})}),v)g.push({kind:"item",id:"extract",label:"Extract…",icon:e(Ye,{size:13,className:"text-ink/60"}),disabled:p});if(l)g.push({kind:"item",id:"diff",label:"Open in Diff Panel",icon:e(Zi,{size:13,className:"text-warning"}),tone:"font-medium"});g.push({kind:"separator"})}if(g.push({kind:"item",id:"cut",label:"Cut",icon:e(Se,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"copy",label:"Copy",icon:e(ae,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"compress",label:"Compress to…",icon:e(Xe,{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(Ts,{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(Ce,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"copy_path",label:"Copy Path",icon:e(ae,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"copy_relative",label:"Copy Relative Path",icon:e(ae,{size:13,className:"text-ink/60"})}),g.push({kind:"separator"}),g.push({kind:"item",id:"history",label:"Show Git History",icon:e(In,{size:13,className:"text-ink/60"})}),g.push({kind:"separator"}),g.push({kind:"item",id:"rename",label:"Rename",icon:e(qe,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"delete",label:"Delete",icon:e(M,{size:13,className:"text-error"}),tone:"text-error"}),g}function sn(t){let r=t.filter((c)=>c.kind==="item").length,l=t.length-r;return r*en+l*tn+rn}function Ze({x:t,y:r,isFolder:l,hasGitStatus:c,pasteLabel:p,chainLabel:f,foldable:x,busy:h,selectionCount:v,isArchive:g,onAction:m,menuRef:k}){let D=on({isFolder:l,hasGitStatus:c,pasteLabel:p,busy:h,chainLabel:f,foldable:x,selectionCount:v,isArchive:g}),E=sn(D),N=typeof window<"u"?Math.max(10,Math.min(t,window.innerWidth-210-12)):t,L=typeof window<"u"?Math.max(10,Math.min(r,window.innerHeight-E-12)):r;return se(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>m("close"),onContextMenu:(T)=>{T.preventDefault(),m("close")},children:e("div",{ref:k,className:"glass-popover fixed z-50 bg-paper border border-ink/15 shadow-2xl rounded-lg py-1 min-w-[185px] text-xs text-ink font-sans",style:{top:L,left:N},onClick:(T)=>T.stopPropagation(),children:D.map((T,R)=>T.kind==="separator"?e("div",{className:"my-1 border-t border-ink/10"},`sep-${R}`):e("button",{type:"button",disabled:T.disabled,onClick:()=>m(T.id),className:`w-full text-left px-3 py-1.5 flex items-center space-x-2 transition-colors ${T.disabled?"opacity-40 cursor-default":"hover:bg-ink/5"} ${T.tone??""}`,children:[T.icon,e("span",{children:T.label})]},T.id))})}),document.body)}function Fe({folderPath:t,kind:r,value:l,error:c,isLoading:p,onChange:f,onCancel:x,onSubmit:h}){let v=r==="folder"?"Folder":"File";return se(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:h,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-3 text-sm",children:["New ",v]}),e("div",{className:"flex items-center gap-1 mb-1 text-xs font-mono text-ink/50 min-w-0",children:e("span",{className:"truncate",title:t,children:[t||".","/"]})}),e("input",{autoFocus:!0,type:"text",value:l,onChange:(g)=>f(g.currentTarget.value),placeholder:r==="folder"?"folder name or nested/path":"file name or nested/path","aria-label":`New ${v.toLowerCase()} name`,className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none mb-1 ${c?"border-error":"border-ink/20 focus:border-ink"}`}),e("p",{className:"text-[10px] text-ink/40 mb-2",children:["Nested paths create the folders they need — ",e("span",{className:"font-mono",children:"lib/parse.ts"}),"."]}),c&&e("p",{className:"text-[11px] text-error mb-2",children:c}),e("div",{className:"flex justify-end space-x-2 mt-2",children:[e("button",{type:"button",onClick:x,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:p,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:p||!l.trim(),children:p?"Creating...":"Create"})]})]})}),document.body)}function et({fileName:t,displayName:r,isFolder:l,count:c=1,isLoading:p,onCancel:f,onConfirm:x}){let h=c>1;return se(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("div",{className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-2 text-sm",children:["Delete ",h?`${c} Items`:l?"Folder":"File"]}),e("p",{className:"text-xs text-ink/70 mb-4",children:["Are you sure you want to delete ",h?e(d,{children:["the ",c," selected entries"]}):e("span",{className:"font-mono bg-canvas px-1 rounded",children:t}),"? This action cannot be undone."]}),r&&r!==t&&e("p",{className:"text-[11px] text-ink/50 mb-4",children:["The row is ",e("span",{className:"font-mono",children:r}),"; this deletes"," ",e("span",{className:"font-mono",children:t})," only."]}),e("div",{className:"flex justify-end space-x-2",children:[e("button",{onClick:f,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:p,children:"Cancel"}),e("button",{onClick:x,className:"px-3 py-1.5 text-xs bg-error text-white rounded hover:bg-error/90 transition-colors flex items-center",disabled:p,children:p?"Deleting...":"Delete"})]})]})}),document.body)}function tt({isFolder:t,renameValue:r,originalPath:l,displayName:c,error:p,isLoading:f,onChange:x,onCancel:h,onSubmit:v}){return se(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:v,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-3 text-sm",children:["Rename ",t?"Folder":"File"]}),e("input",{autoFocus:!0,type:"text",value:r,onChange:(g)=>x(g.currentTarget.value),"aria-label":`Rename ${t?"folder":"file"} path`,className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none mb-1 ${p?"border-error":"border-ink/20 focus:border-ink"}`}),e("p",{className:"text-[10px] text-ink/40 mb-2",children:["Paths are relative to the tree — ",e("span",{className:"font-mono",children:"lib/deep/name.ts"})," moves it too."]}),c&&e("p",{className:"text-[11px] text-ink/50 mb-2",children:["The row is ",e("span",{className:"font-mono",children:c}),"; this renames"," ",e("span",{className:"font-mono",children:l}),". Use"," ",e("span",{className:"font-mono",children:"Unfold Folders"})," to rename a folder inside the chain."]}),p&&e("p",{className:"text-[11px] text-error mb-2",children:p}),e("div",{className:"flex justify-end space-x-2",children:[e("button",{type:"button",onClick:h,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:f,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:f||!r.trim()||r===l,children:f?"Renaming...":"Rename"})]})]})}),document.body)}function nt({filePath:t,fetcherState:r,fetcherData:l,onClose:c}){let p=l?.type==="history"?l.data:void 0;return se(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("div",{className:"glass-overlay bg-paper rounded-lg shadow-xl w-full max-w-4xl border border-ink/10 flex flex-col max-h-[85vh]",children:[e("div",{className:"flex items-center justify-between p-4 border-b border-ink/10",children:[e("h3",{className:"text-sm font-semibold text-ink flex items-center space-x-2",children:[e(In,{size:16,className:"text-ink/60"}),e("span",{children:["Git History: ",e("span",{className:"font-mono font-normal opacity-80",children:t})]})]}),e("button",{onClick:c,className:"p-1 hover:bg-ink/5 rounded text-ink/60 transition-colors",children:e(b,{size:14})})]}),e("div",{className:"flex-1 scrollbar-overlay-container p-2",children:r==="idle"?p?p.length>0?e("table",{className:"w-full text-left border-collapse text-[11px]",children:[e("thead",{className:"bg-canvas sticky top-0 z-10 border-b border-ink/10",children:e("tr",{children:[e("th",{className:"px-3 py-2 font-semibold text-ink/70 rounded-tl",children:"Description"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-32",children:"Date"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-32",children:"Author"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-24 text-right rounded-tr",children:"Commit"})]})}),e("tbody",{className:"divide-y divide-ink/5",children:p.map((f,x)=>e("tr",{className:"hover:bg-ink/[0.03] transition-colors group",children:[e("td",{className:"px-3 py-2 text-ink",children:f.message?e("span",{className:"font-medium text-ink/90 group-hover:text-ink",children:f.message}):null}),e("td",{className:"px-3 py-2 text-ink/60 whitespace-nowrap font-mono text-[10.5px]",children:f.time}),e("td",{className:"px-3 py-2 text-ink/70 whitespace-nowrap truncate max-w-[120px]",children:f.author}),e("td",{className:"px-3 py-2 text-right",children:f.hash?e("span",{className:"font-mono text-ink/50 group-hover:text-ink font-semibold transition-colors bg-canvas px-1.5 py-0.5 rounded border border-ink/10",children:f.hash}):null})]},x))})]}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs",children:"No commit history found for this file."}):l?.error?e("div",{className:"p-8 text-center text-error font-mono text-xs",children:l.error}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs",children:"Loading history..."}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs flex items-center justify-center space-x-2",children:[e(C,{size:14,className:"animate-spin"}),e("span",{children:"Loading history..."})]})})]})}),document.body)}function rt({actions:t,file:r,isFolder:l,chainLabel:c}){let p=t.selectionCount;return e(d,{children:[t.showCreateModal&&e(Fe,{folderPath:r.path,kind:t.createKind,value:t.createName,error:t.createError,isLoading:t.busy,onChange:t.setCreateName,onCancel:t.closeCreate,onSubmit:t.submitCreate}),t.showDeleteModal&&e(et,{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(tt,{isFolder:l,renameValue:t.renameValue,originalPath:r.path,displayName:l?c:void 0,error:t.renameError,isLoading:t.busy,onChange:t.setRenameValue,onCancel:t.closeRename,onSubmit:t.submitRename}),t.showHistoryModal&&e(nt,{filePath:r.path,fetcherState:t.fetcherState,fetcherData:t.fetcherData,onClose:t.closeHistory})]})}function Ae(t){let r=t.map(an);return r.some((l,c)=>l!==t[c])?r:t}function an(t){if(t.type!=="folder"||!Array.isArray(t.children))return t;let r=Ae(t.children),l=r===t.children?t:{...t,children:r};while(Array.isArray(l.children)&&l.children.length===1){let c=l.children[0];if(c.type!=="folder")break;l={...l,name:`${l.name}/${c.name}`,path:c.path,children:c.children,ignored:c.ignored??l.ignored}}return l}function Ee(t){return t.type==="folder"&&t.name.includes("/")}function Me(t,r){let l=r.split("/"),c=t.split("/");if(l.length<2||l.length>c.length||l.some((f)=>!f))return null;let p=c.slice(0,c.length-l.length);return l.map((f,x)=>[...p,...l.slice(0,x+1)].join("/"))}function ot(t,r){let l=new Map;if(r.size===0)return{nodes:t,roots:l};let c=!1,p=(x)=>x.flatMap((h)=>{if(h.type!=="folder")return[h];let v=Array.isArray(h.children)?p(h.children):h.children,g=v===h.children?h:{...h,children:v},m=r.has(h.path)?Me(h.path,h.name):null;if(!m)return[g];c=!0,l.set(m[0],h.path);let k={...g,name:m[m.length-1].split("/").pop()};for(let y=m.length-1;y>0;y-=1){let D=m[y-1];k={name:D.split("/").pop(),path:D,type:"folder",ignored:g.ignored,children:[k]}}return[k]}),f=p(t);return{nodes:c?f:t,roots:l}}function st(t,r){let l=new Set,c=(x)=>{for(let h of x){if(h.type!=="folder")continue;if(l.add(h.path),Array.isArray(h.children))c(h.children)}};c(t);let p=r.split("/").slice(0,-1),f=[];for(let x=0;x<p.length;x+=1){let h=p.slice(0,x+1).join("/");if(l.has(h))f.push(h)}return f}function Ne({folderPath:t,rootPath:r,repo:l,onCreated:c,onOpenCreated:p}){let f=it(),[x,h]=n(!1),[v,g]=n("file"),[m,k]=n(""),[y,D]=n(null),E=o(null);return i(()=>{if(f.state!=="idle"||!f.data)return;let N=f.data;if(E.current===N)return;if(E.current=N,N.success&&N.path){let L=N.kind==="folder"?"folder":"file";h(!1),k(""),D(null);let T=N.path.split("/").pop()||N.path;if(c({path:N.path,name:T,kind:L}),L==="file")p?.({path:N.path,name:T})}else D(N.error||`Could not create the ${v}`)},[f.state,f.data]),{open:x,kind:v,name:m,setName:k,error:y,busy:f.state!=="idle",openDialog:(N="file")=>{g(N),k(""),D(null),h(!0)},closeDialog:()=>h(!1),submit:(N)=>{N.preventDefault();let L=m.trim();if(!L)return;D(null);let T=new FormData;if(T.append("actionType","create"),T.append("path",t),T.append("name",L),v==="folder")T.append("kind","folder");if(l&&l!==".")T.append("repo",l);if(r)T.append("root",r);f.submit(T,{method:"post",action:"/api/fs/action"})}}}function De(t){if(!t)return null;if(t.entries.length===1)return t.entries[0].name;return`${t.entries.length} items`}function lt(t,r){return`${t??""}\x00${r}`}function Le(t,r){if(r==="folder")return t;let l=t.lastIndexOf("/");return l===-1?".":t.slice(0,l)}function ct(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)}function dt(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 pt(t,r){let l=dt(t,r);if(l)return l;if(r===ct(t.path))return"Already in this folder";return null}function ut(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===ct(c.path)))return"Already in this folder";for(let c of t.entries){let p=dt(c,l);if(p)return p}return null}function ft(t){if(typeof t!=="object"||t===null)return null;let r=t;if(typeof r.scope!=="string")return null;if(r.mode!=="copy"&&r.mode!=="cut")return null;let l=Array.isArray(r.entries)?r.entries:typeof r.path==="string"?[{path:r.path,name:r.name,kind:r.kind}]:[],c=[];for(let p of l){let f=ln(p);if(!f)return null;c.push(f)}if(c.length===0)return null;return{scope:r.scope,entries:c,mode:r.mode}}function ln(t){if(typeof t!=="object"||t===null)return null;let r=t;if(typeof r.path!=="string"||typeof r.name!=="string")return null;if(r.kind!=="file"&&r.kind!=="folder")return null;let l=r.path.split("/");if(r.path===""||r.path.startsWith("/")||l.some((c)=>c===""||c==="."||c===".."))return null;return{path:r.path,name:r.name,kind:r.kind}}var $e=[{id:"zip",label:"ZIP",extension:"zip"},{id:"7z",label:"7Z",extension:"7z"},{id:"rar",label:"RAR",extension:"rar"},{id:"tar",label:"TAR",extension:"tar"},{id:"tar.gz",label:"TAR.GZ",extension:"tar.gz"}],mt=[[".tar.gz","tar.gz"],[".tar.bz2","tar.bz2"],[".tar.xz","tar.xz"],[".tgz","tar.gz"],[".tbz2","tar.bz2"],[".txz","tar.xz"],[".tar","tar"],[".zip","zip"],[".7z","7z"],[".rar","rar"],[".gz","gz"],[".bz2","bz2"],[".xz","xz"]];function ze(t){let r=t.toLowerCase();for(let[l,c]of mt)if(r.endsWith(l))return c;return null}function ht(t){return ze(t)!==null}function cn(t){return $e.find((r)=>r.id===t)}function dn(t){return cn(t)?.extension??"zip"}function gt(t){let r=t.toLowerCase();for(let[l]of mt)if(r.endsWith(l))return t.slice(0,-l.length);return t}function bt(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)||"."}function xt(t){let r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}function vt(t){if(t.length===0)return".";let r=t.map((c)=>bt(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 Re(t,r){let l=dn(r);if(t.length===1){let f=t[0],x=gt(f.name),h=x.lastIndexOf(".");return`${(f.kind==="folder"?f.name:h>0?x.slice(0,h):x)||"archive"}.${l}`}let c=vt(t.map((f)=>f.path)),p=xt(c);return`${p==="."||p===""?"archive":p}.${l}`}function yt(t){return vt(t.map((r)=>r.path))}function kt(t){let r=bt(t),l=gt(xt(t));if(!l)return r;return r==="."?l:`${r}/${l}`}function Ct(t){return t.toUpperCase()}function Ft({file:t,diff:r,onOpenFile:l,onActionComplete:c,onCreated:p,onRenamed:f,onUnfold:x,onFold:h,clipboard:v,isFolder:g,selection:m,selected:k,archive:y}){let D=it(),[E,N]=n(null),L=o(null),[T,R]=n(!1),[A,H]=n(!1),[W,ee]=n(!1),[te,oe]=n(t.path),[G,I]=n(null),{repo:O,rootPath:K}=t,j=Ne({folderPath:t.path,rootPath:K,repo:O,onCreated:(z)=>p?p(z):c(),onOpenCreated:(z)=>l?.({...z,root:K,repo:O||"."})}),ne=o(null);i(()=>{if(D.state!=="idle"||!D.data)return;let z=D.data;if(ne.current===z)return;if(ne.current=z,z.success&&!z.type)if(R(!1),H(!1),I(null),z.previousPath&&z.path&&f)f(z.previousPath,z.path);else c();else if(!z.success&&z.error&&T)I(z.error)},[D.state,D.data]);let q=(z)=>{if(O&&O!==".")z.append("repo",O);if(K)z.append("root",K);D.submit(z,{method:"post",action:"/api/fs/action"})},V=()=>{l?.({path:t.path,name:t.name,root:K,repo:O||"."})},J={path:t.path,name:t.name,kind:g?"folder":"file"},re=k&&m.length>1?m:[J],he=ht(t.name),Q=v.clip&&!v.refusalFor(J)?`Paste ${De(v.clip)??"item"}`:null,fe=(z)=>{if(N(null),I(null),z==="view")V();else if(z==="diff")window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.path,staged:r?.staged,status:r?.status||"M",repo:O||".",root:K}}));else if(z==="explorer"){let _=new FormData;_.append("actionType","open_explorer"),_.append("path",t.path),q(_)}else if(z==="copy_path")nn(Du(t.basePath,t.path));else if(z==="copy_relative")nn(t.path);else if(z==="history"){ee(!0);let _=new FormData;_.append("actionType","git_history"),_.append("path",t.path),q(_)}else if(z==="rename")oe(t.path),R(!0);else if(z==="unfold")x?.();else if(z==="fold")h?.();else if(z==="new_file")j.openDialog("file");else if(z==="new_folder")j.openDialog("folder");else if(z==="delete")H(!0);else if(z==="cut")v.cut(re);else if(z==="copy")v.copy(re);else if(z==="compress")y.openCompress(re);else if(z==="extract")y.openExtract(J);else if(z==="duplicate")v.duplicate(J);else if(z==="paste")v.paste(J)},le=(z)=>{z.preventDefault(),I(null);let _=new FormData;_.append("actionType","rename"),_.append("path",t.path),_.append("newPath",te),q(_)},xe=()=>{let z=new FormData;if(z.append("actionType","delete"),re.length>1)z.append("paths",JSON.stringify(re.map((_)=>_.path)));else z.append("path",t.path);q(z)};return{contextMenu:E,contextMenuRef:L,openContextMenu:(z,_)=>N({x:z,y:_}),closeContextMenu:()=>N(null),showRenameModal:T,showDeleteModal:A,showHistoryModal:W,showCreateModal:j.open,createKind:j.kind,createError:j.error,createName:j.name,setCreateName:j.setName,renameValue:te,setRenameValue:oe,renameError:G,busy:D.state!=="idle"||j.busy||v.busy||y.busy,pasteLabel:Q,selectionCount:re.length,isArchive:he,chainLabel:x!==void 0,foldable:h!==void 0,fetcherState:D.state,fetcherData:D.data,handleAction:fe,submitCreate:j.submit,submitRename:le,submitDelete:xe,closeCreate:j.closeDialog,closeDelete:()=>H(!1),closeRename:()=>R(!1),closeHistory:()=>ee(!1)}}function Nt({target:t,dragging:r,clipboard:l,onDragStart:c,onDragEnd:p,onDropOn:f,onHoverAccept:x}){let h=r?.path===t.path,v=Boolean(r)&&!h&&l.moveRefusalFor(r,t)===null,[g,m]=n(!1);return i(()=>{if(!r)m(!1)},[r]),{isDragging:h,acceptsDrop:v,isDropHovered:g&&v,onDragStart:(y)=>{if(y.dataTransfer?.setData("text/plain",t.path),y.dataTransfer)y.dataTransfer.effectAllowed="move";c(t)},onDragEnd:p,onDragOver:(y)=>{if(!r)return;if(y.stopPropagation(),m(v),!v)return;if(y.preventDefault(),y.dataTransfer)y.dataTransfer.dropEffect="move";x?.(t)},onDragLeave:()=>m(!1),onDrop:(y)=>{if(!r)return;if(y.stopPropagation(),!v)return;y.preventDefault(),f(t)}}}var pn=450,wt=8,un=700;function Dt({enabled:t,onLongPress:r}){let l=o(null),c=o(null),p=o(0),f=o(r);f.current=r;let x=a(()=>{if(l.current!==null)clearTimeout(l.current),l.current=null;c.current=null},[]);return i(()=>x,[x]),{onTouchStart:(h)=>{if(!t)return;let v=h.touches[0];if(!v)return;x(),c.current={x:v.clientX,y:v.clientY},l.current=setTimeout(()=>{l.current=null;let g=c.current;if(c.current=null,!g)return;p.current=Date.now(),f.current(g.x,g.y)},pn)},onTouchMove:(h)=>{let v=c.current,g=h.touches[0];if(!v||!g)return;if(Math.abs(g.clientX-v.x)>wt||Math.abs(g.clientY-v.y)>wt)x()},onTouchEnd:x,onTouchCancel:x,consume:()=>{if(p.current===0)return!1;let h=Date.now()-p.current<un;return p.current=0,h}}}function fn(t,r,l){if(r||l)return!1;return!Array.isArray(t.children)}function Oe({file:t,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:x,onCreated:h,onRenamed:v,expandedPaths:g,onToggleFolder:m,gitFileMap:k,gitFolderMap:y,clipboard:D,archive:E,selection:N,selectionTargets:L,dragging:T,onDragStart:R,onDragEnd:A,onDropOn:H,onUnfold:W,onFold:ee,foldRoots:te,touch:oe=!1}){let G=t.type==="folder",[I,O]=n(!1),[K,j]=n(!1),[ne,q]=n(!1),[V,J]=n(!1),re=Array.isArray(t.children)?t.children:[],he=(t.path||"").replace(/^\/+/,""),Q=!G?k?.get(he)||k?.get(t.path):void 0,fe=Q?Gn(Q.status,Q.staged):null,le=G?y?.get(he)||y?.get(t.path):null,xe=Boolean(fe),z=t.ignored===!0,_=g?g.has(t.path):I,de=t.forceExpanded!==void 0?t.forceExpanded:_;i(()=>{J(!0)},[]),i(()=>{if(G&&g)O(g.has(t.path))},[g,t.path,G]),i(()=>{if(G&&de&&fn(t,K,ne)&&p)q(!0),j(!0),Promise.resolve(p(t.path)).finally(()=>j(!1))},[G,de,t.children,t.path,p,K,ne]);let ye={path:t.path,name:t.name,kind:G?"folder":"file"},be=N.selected.has(t.path),U=Ft({file:{path:t.path,name:t.name,basePath:l,rootPath:r,repo:c},selection:L,selected:be,archive:E,diff:{staged:Q?.staged||(Q?.status?Q.status[0]!==" "&&Q.status[0]!=="?":!1),status:fe?.charStatus},onOpenFile:f,onActionComplete:x,onCreated:h,onRenamed:v,onUnfold:W&&Ee({type:G?"folder":"file",name:t.name})?()=>W(ye):void 0,onFold:ee&&te?.has(t.path)?()=>ee(te.get(t.path)):void 0,clipboard:D,isFolder:G});ce(U.contextMenuRef,U.closeContextMenu);let Y=Dt({enabled:oe,onLongPress:(X,ge)=>U.openContextMenu(X,ge)}),ke=(X)=>{if(X.stopPropagation(),Y.consume())return;let ge=N.gestureOf(X);if(ge!=="plain"){N.applyGesture(ge,t.path);return}if(N.applyGesture("plain",t.path),G){let ue=!de;if(O(ue),t.forceExpanded!==void 0)t.forceExpanded=void 0;if(m?.(t.path,ue),!ue)q(!1)}else if(f)f({...t,root:r,repo:c||"."})},ve=(X)=>{X.preventDefault(),X.stopPropagation(),N.ensureForContext(t.path),U.openContextMenu(X.clientX,X.clientY)},pe=Nt({target:ye,dragging:T,clipboard:D,onDragStart:R,onDragEnd:A,onDropOn:H,onHoverAccept:W});return e("div",{children:[e("div",{className:`flex items-center space-x-1.5 py-1 px-2 cursor-pointer rounded group select-none ${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:!oe,onClick:ke,onContextMenu:ve,onDragStart:pe.onDragStart,onDragEnd:pe.onDragEnd,onDragOver:pe.onDragOver,onDragLeave:pe.onDragLeave,onDrop:pe.onDrop,onTouchStart:Y.onTouchStart,onTouchMove:Y.onTouchMove,onTouchEnd:Y.onTouchEnd,onTouchCancel:Y.onTouchCancel,children:e(Je,{name:t.name,path:t.path,isFolder:G,isOpen:de,ignored:z,selected:be,gitStatus:fe,folderStatus:le})}),de&&K&&e("div",{className:"ml-3 border-l border-ink/10 pl-3 py-0.5 text-[10px] text-ink/30",children:"Loading…"}),de&&!K&&re.length>0&&e("div",{className:"ml-3 border-l border-ink/10 pl-1",children:re.map((X)=>e(Oe,{file:X,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:x,onCreated:h,onRenamed:v,expandedPaths:g,onToggleFolder:m,gitFileMap:k,gitFolderMap:y,clipboard:D,archive:E,selection:N,selectionTargets:L,dragging:T,onDragStart:R,onDragEnd:A,onDropOn:H,onUnfold:W,onFold:ee,foldRoots:te,touch:oe},X.path))}),V&&U.contextMenu&&e(Ze,{x:U.contextMenu.x,y:U.contextMenu.y,isFolder:G,hasGitStatus:xe,pasteLabel:U.pasteLabel,chainLabel:U.chainLabel,foldable:U.foldable,busy:U.busy,selectionCount:U.selectionCount,isArchive:U.isArchive,onAction:U.handleAction}),V&&e(rt,{actions:U,file:t,isFolder:G,chainLabel:Ee({type:G?"folder":"file",name:t.name})?t.name:void 0})]})}function Rt({x:t,y:r,pasteLabel:l,busy:c,onAction:p,menuRef:f}){let h=l?104:76,v=typeof window<"u"?Math.max(10,Math.min(t,window.innerWidth-190-12)):t,g=typeof window<"u"?Math.max(10,Math.min(r,window.innerHeight-h-12)):r;return se(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>p("close"),onContextMenu:(m)=>{m.preventDefault(),p("close")},children:e("div",{ref:f,className:"glass-popover fixed z-50 bg-paper border border-ink/15 shadow-2xl rounded-lg py-1 min-w-[185px] text-xs text-ink font-sans",style:{top:g,left:v},onClick:(m)=>m.stopPropagation(),children:[e("button",{type:"button",onClick:()=>p("new_file"),className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 flex items-center space-x-2 transition-colors",children:[e(Ji,{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(Xt,{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(Ts,{size:13,className:"text-ink/60"}),e("span",{children:l})]})]})}),document.body)}function Tt({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 St({title:t,subject:r,error:l,busy:c,submitLabel:p,busyLabel:f,onSubmit:x,onCancel:h,children:v}){return se(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:x,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-1 text-sm",children:t}),e("p",{className:"text-[11px] text-ink/50 mb-3 break-words",children:r}),v,l&&e("p",{className:"text-[11px] text-error mb-2",children:l}),e("div",{className:"flex justify-end space-x-2 mt-3",children:[e("button",{type:"button",onClick:h,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:c,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:c,children:c?f:p})]})]})}),document.body)}function mn({entries:t,format:r,name:l,destination:c,formats:p,error:f,busy:x,onFormatChange:h,onNameChange:v,onDestinationChange:g,onCancel:m,onSubmit:k}){let y=t.slice(0,4).map((E)=>E.name).join(", "),D=t.length>4?` +${t.length-4} more`:"";return e(St,{title:`Compress ${t.length===1?t[0].name:`${t.length} items`}`,subject:`${y}${D}`,error:f,busy:x,submitLabel:"Compress",busyLabel:"Compressing...",onCancel:m,onSubmit:(E)=>{E.preventDefault(),k()},children:[e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"archive-format",children:"Format"}),e("select",{id:"archive-format",value:r,onChange:(E)=>h(E.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 text-xs font-mono focus:outline-none focus:border-ink mb-3",children:p.map((E)=>e("option",{value:E.id,disabled:!E.available,children:[E.label,E.available?"":` — ${E.tool} not installed`]},E.id))}),e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"archive-name",children:"Archive name"}),e("input",{id:"archive-name",autoFocus:!0,type:"text",value:l,onChange:(E)=>v(E.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:(E)=>g(E.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 hn({archive:t,kindLabel:r,destination:l,error:c,busy:p,onDestinationChange:f,onCancel:x,onSubmit:h}){return e(St,{title:`Extract ${t.name}`,subject:`${r} archive · extracts into a folder`,error:c,busy:p,submitLabel:"Extract",busyLabel:"Extracting...",onCancel:x,onSubmit:(v)=>{v.preventDefault(),h()},children:[e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"extract-destination",children:"Extract to folder"}),e("input",{id:"extract-destination",autoFocus:!0,type:"text",value:l,onChange:(v)=>f(v.currentTarget.value),"aria-label":"Extract destination",className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none ${c?"border-error":"border-ink/20 focus:border-ink"}`})]})}function At({archive:t}){if(t.compress)return e(mn,{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(hn,{archive:t.extract.archive,kindLabel:Ct(ze(t.extract.archive.name)??"zip"),destination:t.extract.destination,error:t.error,busy:t.busy,onDestinationChange:t.setExtractDestination,onCancel:t.cancel,onSubmit:t.submitExtract});return null}function Et(){let[t,r]=S("files.outlineExpanded",!1),l=Ar(),c=He(UA,zA),{symbols:p,total:f,truncated:x,notice:h}=Iu({content:c.content,language:c.language,state:c.state,note:c.note,path:c.path});if(c.state==="diff")return null;let v=c.preview,g=(m,k)=>{if(!c.path)return;if(v){let y=Qu(p,k);if(y)qo({path:c.path,...y});return}jo({path:c.path,line:m.line,column:m.column,length:m.name.length})};return e("div",{className:"border-t border-ink/10 bg-canvas/30 flex-shrink-0",children:[e("div",{className:"flex items-center hover:bg-ink/5 transition-colors",children:e("button",{type:"button",onClick:()=>r(!t),"aria-expanded":t,"aria-controls":l,"aria-label":"Outline",title:t?"Hide outline":"Show outline",className:"flex flex-1 min-w-0 items-center space-x-1 py-1.5 pl-3 pr-2 text-left font-semibold text-xs text-ink transition-colors cursor-pointer",children:[e("span",{className:"w-3 text-center font-mono","aria-hidden":"true",children:t?"▾":"▸"}),e(Gr,{size:12}),e("span",{children:"Outline"}),f>0&&e("span",{className:"font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[10px] text-ink/50",children:x?`${p.length}/${f.toLocaleString()}`:f})]})}),e("div",{className:"section-reveal","data-expanded":t,id:l,inert:!t,children:e("div",{children:e("div",{className:"px-2 pb-2",children:p.length===0?e("div",{className:"px-1 text-[10px] text-ink/40 italic py-1",children:h}):e("div",{className:"max-h-48 overflow-y-auto scrollbar-overlay-container flex flex-col",children:[p.map((m,k)=>e("button",{type:"button",onClick:()=>g(m,k),"aria-label":v?`${qi(m.kind)} ${m.name}`:`${qi(m.kind)} ${m.name}, line ${m.line}`,title:v?`Jump to ${qi(m.kind).toLowerCase()}`:`${qi(m.kind)} · line ${m.line}`,className:"flex w-full min-w-0 items-center gap-1.5 rounded px-1 py-0.5 text-left transition-colors hover:bg-ink/5 active:bg-ink/10",style:{paddingLeft:`${4+m.depth*12}px`},children:[e(Eu,{kind:m.kind}),e("span",{className:"min-w-0 flex-1 truncate text-[11px] font-mono text-ink/80",children:m.name}),!v&&e("span",{className:"flex-shrink-0 font-mono text-[10px] text-ink/35",children:m.line})]},`${m.line}:${m.kind}:${m.name}`)),x&&e("div",{className:"px-1 py-1 text-[10px] italic text-ink/40",children:Bu(f)})]})})})})]})}function Pe(t,r){return Ae(t.map((l)=>gn(l,r)))}function gn(t,r){if(t.type!=="folder")return t;let l=r[t.path];if(!l)return t;return{...t,children:Pe(l,r)}}function bn(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)}function Lt(t){let r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}function Mt(t){return[...t].sort((r,l)=>{if(r.type!==l.type)return r.type==="folder"?-1:1;return r.name.localeCompare(l.name)})}function Ie(t,r,l){let c=l.path.split("/"),p=c.slice(0,-1).join("/"),f=[...t],x={...r},h=f,v=null;for(let g=0;g<c.length-1;){let m=c.slice(0,g+1).join("/"),k=h.find((L)=>L.type==="folder"&&L.path===m),y=k?null:h.find((L)=>L.type==="folder"&&L.path.startsWith(`${m}/`)&&(p===L.path||p.startsWith(`${L.path}/`))),D=k??y,E=D?x[D.path]??D.children:null;if(D&&!Array.isArray(E))return{nodes:t,cache:r};if(!D){let L=xn(h,x,m);if(L){h=L;let T=h.find((A)=>A.path===m),R=Array.isArray(T?.children)?[...T.children]:[];x[m]=R,h=R,v=m,g+=1;continue}}let N=Array.isArray(E)?[...E]:[];if(D){x[D.path]=N,h=N,v=D.path,g=D.path.split("/").length;continue}h.push({name:c[g],path:m,type:"folder",ignored:!1}),x[m]=N,h=N,v=m,g+=1}if(h.push(l),v!==null)x[v]=Mt(h);return f=Mt(f),{nodes:f,cache:x}}function xn(t,r,l){let c=t.findIndex((v)=>v.type==="folder"&&v.path.startsWith(`${l}/`));if(c===-1)return null;let p=t[c],f=p.path.slice(l.length+1).split("/"),x=r[p.path]??p.children;if(Array.isArray(x))r[p.path]=x;let h={name:f[f.length-1],path:p.path,type:"folder",ignored:p.ignored,...Array.isArray(x)?{children:x}:{}};for(let v=f.length-2;v>=0;v-=1)h={name:f[v],path:`${l}/${f.slice(0,v+1).join("/")}`,type:"folder",ignored:!1,children:[h]};return t[c]={name:Lt(l),path:l,type:"folder",ignored:!1,children:[h]},t}function $t(t,r,l){let c=t.find((m)=>m.path===l);if(c)return{entry:c,nodes:t.filter((m)=>m.path!==l),cache:r};let p=bn(l),f=r[p],x=f?.find((m)=>m.path===l);if(f&&x)return{entry:x,nodes:t,cache:{...r,[p]:f.filter((m)=>m.path!==l)}};let v=Object.keys(r).filter((m)=>l.startsWith(`${m}/`)&&r[m].some((k)=>k.path===l)).sort((m,k)=>k.length-m.length)[0];if(!v)return{entry:null,nodes:t,cache:r};let g=r[v];return{entry:g.find((m)=>m.path===l),nodes:t,cache:{...r,[v]:g.filter((m)=>m.path!==l)}}}function zt(t,r,l){let c=!1,p=t.map((f)=>{let x=f.path===r||f.path.startsWith(`${r}/`),h=Array.isArray(f.children)?zt(f.children,r,l):void 0;if(!x&&h===f.children)return f;c=!0;let v=x?f.path===r?l:`${l}${f.path.slice(r.length)}`:f.path,g=x?{...f,path:v,name:Lt(v)}:{...f};if(h!==void 0)g.children=h;return g});return c?p:t}function Ot(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:zt(f,r,l)}return c}function Pt(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 It(t){if(!w(t))return{status:"missing"};if(typeof t.root!=="string"||t.root==="")return{status:"missing"};return{status:"ok",files:Array.isArray(t.files)?t.files.filter((r)=>w(r)):[],root:t.root}}async function Ke(t){try{return It(await(await fetch(t)).json())}catch{return{status:"failed"}}}function Ht({enabled:t,rootPath:r,activeRepo:l,expandedPaths:c,onExpansionPruned:p}){let f=`${r??""}\x00${l}`,[x,h]=n({scope:"",files:[],root:""}),[v,g]=n(!1),m=o({}),k=o([]),y=o(f);y.current=f;let D=o(""),E=o(""),N=o(c);N.current=c;let L=(I)=>{let O=new URLSearchParams;if(r)O.set("root",r);if(l&&l!==".")O.set("repo",l);if(I)O.set("path",I);return O.set("t",String(Date.now())),`/api/fs/dir?${O.toString()}`},T=(I,O)=>{D.current=I,E.current=O;let K=Pe(k.current,m.current);return h({scope:I,files:K,root:O}),K},R=async(I)=>{let O=[...N.current];if(O.length===0)return;let K=await Promise.all(O.map(async(V)=>({path:V,read:await Ke(L(V))})));if(y.current!==I)return;let j=[];for(let{path:V,read:J}of K)if(J.status==="ok")m.current[V]=J.files;else if(J.status==="missing")j.push(V);if(j.length===0)return;let ne=new Set(j);for(let V of j)delete m.current[V];let q=new Set([...N.current].filter((V)=>!ne.has(V)));N.current=q,p(q)},A=async()=>{if(!t)return;let I=y.current;g(!0);try{let O=await Ke(L());if(y.current!==I)return;if(O.status!=="ok")return;if(D.current!==I)m.current={};if(k.current=O.files,T(I,O.root),await R(I),y.current!==I)return;T(I,O.root)}finally{if(y.current===I)g(!1)}},H=async(I)=>{let O=y.current,K=await Ke(L(I));if(y.current!==O||K.status!=="ok")return;if(m.current[I]=K.files,D.current===O)T(O,E.current)},W=(I)=>{let O=It(I);if(O.status!=="ok")return;let K=y.current;if(D.current!==K)m.current={};k.current=O.files,T(K,O.root),R(K).then(()=>{if(y.current===K)T(K,O.root)})},ee=()=>{m.current={},k.current=[],D.current="",E.current="",h({scope:"",files:[],root:""})},te=(I)=>{let O=y.current;if(D.current!==O)return null;let K={name:I.path.slice(I.path.lastIndexOf("/")+1),path:I.path,type:I.kind,ignored:!1},j=Ie(k.current,m.current,K);if(j.nodes===k.current)return null;return k.current=j.nodes,m.current=j.cache,T(O,E.current)},oe=(I,O)=>{let K=y.current;if(D.current!==K)return null;let j=$t(k.current,m.current,I);if(!j.entry)return null;m.current=Ot(j.cache,I,O);let ne={...j.entry,path:O,name:O.slice(O.lastIndexOf("/")+1)},q=Ie(j.nodes,m.current,ne);return k.current=q.nodes,m.current=q.cache,T(K,E.current)},G=x.scope===f;return{scope:f,files:G?x.files:[],root:G?x.root:"",isLoading:v,reload:A,loadChildren:H,adoptRoot:W,insertEntry:te,moveEntry:oe,reset:ee}}function Gt({rootPath:t,repo:r,onComplete:l,onError:c}){let p=it(),[f,x]=S("files.clipboard",null),h=ft(f),v=lt(t,r),g=o(!1),m=o(null);i(()=>{if(p.state!=="idle"||!p.data)return;let N=p.data;if(m.current===N)return;m.current=N;let L=g.current;if(g.current=!1,N.success){if(L)x(null);if(N.failures?.length)c(`${N.failures.length} item(s) could not be moved: ${N.failures[0].error}`);l()}else c(N.error||"The transfer did not complete")},[p.state,p.data]);let k=a((N,L)=>{g.current=L;let T=new FormData;for(let[R,A]of Object.entries(N))T.append(R,A);if(r&&r!==".")T.append("repo",r);if(t)T.append("root",t);p.submit(T,{method:"post",action:"/api/fs/action"})},[p,r,t]),y=a((N)=>ut(h,v,Le(N.path,N.kind)),[h,v]),D=a((N,L)=>pt(N,Le(L.path,L.kind)),[]),E=a((N,L,T,R)=>{let A=new FormData;A.append("actionType","paste"),A.append("mode",T),A.append("targetPath",L.path),A.append("targetKind",L.kind);for(let H of N)A.append("sourcePath",H.path);if(r&&r!==".")A.append("repo",r);if(t)A.append("root",t);g.current=R,p.submit(A,{method:"post",action:"/api/fs/action"})},[p,r,t]);return{clip:h,busy:p.state!=="idle",refusalFor:y,moveRefusalFor:D,copy:(N)=>{if(N.length===0)return;x({scope:v,entries:N.map(({path:L,name:T,kind:R})=>({path:L,name:T,kind:R})),mode:"copy"})},cut:(N)=>{if(N.length===0)return;x({scope:v,entries:N.map(({path:L,name:T,kind:R})=>({path:L,name:T,kind:R})),mode:"cut"})},duplicate:(N)=>{k({actionType:"duplicate",path:N.path},!1)},move:(N,L)=>{let T=D(N,L);if(T){c(T);return}E([N],L,"cut",Boolean(h?.mode==="cut"&&h.entries.some((R)=>R.path===N.path)))},paste:(N)=>{if(!h)return;let L=y(N);if(L){c(L);return}E(h.entries.map(({path:T,name:R,kind:A})=>({path:T,name:R,kind:A})),N,h.mode,h.mode==="cut")}}}var vn=$e.map((t)=>({...t,available:!0,tool:t.id}));function Kt({rootPath:t,repo:r,onComplete:l}){let c=it(),[p,f]=n(vn),[x,h]=n(null),[v,g]=n(null),[m,k]=n(null),y=o(null),D=o(null);i(()=>{let R=!1;return(async()=>{try{let H=await(await fetch("/api/fs/archive")).json();if(!R&&Array.isArray(H.formats)&&H.formats.length>0)f(H.formats)}catch{}})(),()=>{R=!0}},[]),i(()=>{if(c.state!=="idle"||!c.data)return;let R=c.data;if(D.current===R)return;D.current=R;let A=y.current;if(y.current=null,R.success){if(k(null),A==="compress")h(null);if(A==="extract")g(null);l()}else if(A)k(R.error||"The archive request failed")},[c.state,c.data]);let E=a((R)=>{let A=new FormData;for(let[H,W]of Object.entries(R))A.append(H,W);if(r&&r!==".")A.append("repo",r);if(t)A.append("root",t);c.submit(A,{method:"post",action:"/api/fs/action"})},[c,r,t]),N=a((R)=>{if(R.length===0)return;let A=p.find((H)=>H.id==="zip"&&H.available)?.id??p.find((H)=>H.available)?.id??"zip";k(null),g(null),h({entries:R.map(({path:H,name:W,kind:ee})=>({path:H,name:W,kind:ee})),format:A,name:Re(R,A),destination:yt(R)})},[p]),L=a((R)=>{k(null),h(null),g({archive:R,destination:kt(R.path)})},[]),T=a((R)=>{h((A)=>{if(!A)return A;let H=Re(A.entries,A.format),W=A.name===H?Re(A.entries,R):A.name;return{...A,format:R,name:W}})},[]);return{formats:p,compress:x,extract:v,error:m,busy:c.state!=="idle",openCompress:N,openExtract:L,setFormat:T,setName:(R)=>h((A)=>A&&{...A,name:R}),setCompressDestination:(R)=>h((A)=>A&&{...A,destination:R}),setExtractDestination:(R)=>g((A)=>A&&{...A,destination:R}),cancel:()=>{h(null),g(null),k(null)},submitCompress:()=>{let R=x;if(!R)return;y.current="compress",k(null),E({actionType:"compress",format:R.format,name:R.name.trim(),destination:R.destination.trim()||".",paths:JSON.stringify(R.entries.map((A)=>A.path))})},submitExtract:()=>{let R=v;if(!R)return;y.current="extract",k(null),E({actionType:"extract",path:R.archive.path,destination:R.destination.trim()||"."})}}}function yn(t){if(t.shiftKey)return"range";if(t.metaKey||t.ctrlKey)return"toggle";return"plain"}function kn(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 jt(t){let[r,l]=n(()=>new Set),[c,p]=n(null),f=a((g,m)=>{if(g==="range"){l(new Set(kn(t,c,m)));return}if(p(m),g==="toggle"){l((k)=>{let y=new Set(k);if(y.has(m))y.delete(m);else y.add(m);return y});return}l(new Set([m]))},[c,t]),x=a((g)=>{l((m)=>{if(m.has(g))return m;return new Set([g])}),p(g)},[]),h=a(()=>{l(new Set),p(null)},[]),v=a(yn,[]);return u(()=>({selected:r,count:r.size,anchor:c,gestureOf:v,applyGesture:f,ensureForContext:x,clear:h}),[r,c,v,f,x,h])}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 _t({listing:t,setExpandedPaths:r,setStoredExpandedPaths:l,reload:c,onMoved:p}){let f=a((v,g)=>{let m=st(g,v);if(m.length===0)return;r((k)=>{if(m.every((D)=>k.has(D)))return k;let y=new Set(k);for(let D of m)y.add(D);return l(Array.from(y)),y})},[r,l]),x=a((v)=>{let g=t.insertEntry(v);if(!g){c();return}f(v.path,g)},[t,c,f]),h=a((v,g)=>{p?.(v,g),r((k)=>{let y=Pt(k,v,g);return l(Array.from(y)),y});let m=t.moveEntry(v,g);if(!m){c();return}f(g,m)},[t,c,f,r,l,p]);return{insertCreated:x,moveRenamed:h}}var Cn=new Set;function Wt({scope:t,setExpandedPaths:r,setStoredExpandedPaths:l}){let[c,p]=n({scope:t,chains:new Map}),f=a((v)=>{let g=Me(v.path,v.name);if(!g)return;p((k)=>{let y=k.scope===t?k.chains:new Map;if(y.get(v.path)?.length===g.length)return k;let E=new Map(y);return E.set(v.path,g),{scope:t,chains:E}});let m=g.slice(0,-1);r((k)=>{if(m.every((D)=>k.has(D)))return k;let y=new Set(k);for(let D of m)y.add(D);return l(Array.from(y)),y})},[t,r,l]),x=a((v)=>{let g=c.scope===t?c.chains.get(v):void 0;if(!g)return;let m=g.slice(0,-1);p((k)=>{if(k.scope!==t)return k;let y=new Map(k.chains);return y.delete(v),{scope:t,chains:y}}),r((k)=>{if(!m.some((D)=>k.has(D)))return k;let y=new Set(k);for(let D of m)y.delete(D);return l(Array.from(y)),y})},[t,c,r,l]),h=a((v,g)=>{let m=c.scope===t?c.chains:null;if(!m)return;let k=new Map,y=[],D=!1;for(let[E,N]of m){if(N.findIndex((A,H)=>A===v&&H>0&&H<N.length-1)!==-1){D=!0;continue}let T=N.map((A)=>A===v?g:A.startsWith(`${v}/`)?`${g}${A.slice(v.length)}`:A),R=T[T.length-1];if(R!==E||T.some((A,H)=>A!==N[H]))D=!0;k.set(R,T),y.push(...T.slice(0,-1))}if(!D)return;p({scope:t,chains:k}),r((E)=>{if(y.every((L)=>E.has(L)))return E;let N=new Set(E);for(let L of y)N.add(L);return l(Array.from(N)),N})},[t,c,r,l]);return{unfolded:c.scope===t&&c.chains.size>0?new Set(c.chains.keys()):Cn,unfold:f,fold:x,rekey:h}}function Ut(t,r){let l=r.trim().toLowerCase();if(!l)return t;let c=(p)=>{let f=p.name.toLowerCase().includes(l);if(p.type==="folder"){let x=(p.children||[]).map(c).filter((h)=>h!==null);if(f||x.length>0)return{...p,children:f&&x.length===0?p.children:x,forceExpanded:!0};return null}return f?p:null};return t.map(c).filter((p)=>p!==null)}function Vt({dragging:t,clipboard:r,target:l}){let c=Boolean(t)&&r.moveRefusalFor(t,l)===null,[p,f]=n(!1);return i(()=>{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 oi({className:t="",enabled:r=!0,active:l=!0,rootPath:c,onOpenFile:p,refreshKey:f=0,onRefresh:x}){let[h,v]=S("files.searchQuery",""),[g,m,k]=S("files.expandedPaths",[]),[y,D]=n(()=>new Set(g)),{activeRepo:E,setActiveRepo:N}=ir(c),{repos:L,scanning:T,rescan:R}=or(c,r),{fileMap:A,folderMap:H,refreshGitStatus:W}=Qs(c,E,r),[ee,te]=n(null),oe=o(null);i(()=>{if(!k)return;D((P)=>{let Z=new Set(g);if(P.size===Z.size&&Array.from(Z).every((me)=>P.has(me)))return P;return Z})},[k,g]);let G=Ht({enabled:r,rootPath:c,activeRepo:E,expandedPaths:y,onExpansionPruned:(P)=>{D(P),m(Array.from(P))}});i(()=>{if(!k||!l)return;G.reload()},[f,c,r,E,k,l]);let I=r&&k?SA(G.scope):null,O=we(I);i(()=>{if(O.data)G.adoptRoot(O.data)},[O.data]);let K=(P)=>(W(),G.loadChildren(P)),j=(P,Z)=>{let me=new Set(y);if(Z)me.add(P);else me.delete(P);D(me),m(Array.from(me))},{unfolded:ne,unfold:q,fold:V,rekey:J}=Wt({scope:G.scope,setExpandedPaths:D,setStoredExpandedPaths:m}),re=G.files,he=ot(re,ne),Q=Ut(he.nodes,h),fe=je(Q,(P)=>P.forceExpanded!==void 0?P.forceExpanded:y.has(P.path)),le=jt(fe.map((P)=>P.path)),xe=fe.filter((P)=>le.selected.has(P.path)).map(({path:P,name:Z,kind:me})=>({path:P,name:Z,kind:me})),z=(P)=>{if(P===E)return;G.reset(),D(new Set),m([]),le.clear(),N(P)},_=()=>{if(W(),x)x();else G.reload()},{insertCreated:de,moveRenamed:ye}=_t({listing:G,setExpandedPaths:D,setStoredExpandedPaths:m,reload:_,onMoved:(P,Z)=>J(P,Z)}),be=_u(),{pushToast:U}=Ve(),Y=Gt({rootPath:c,repo:E,onComplete:_,onError:(P)=>U(P,"error")}),ke=Kt({rootPath:c,repo:E,onComplete:_}),ve={path:".",name:".",kind:"folder"},pe=Y.clip&&!Y.refusalFor(ve)?`Paste ${De(Y.clip)??"item"}`:null,[X,ge]=n(null),ue=Vt({dragging:X,clipboard:Y,target:ve}),Te=Ne({folderPath:".",rootPath:c,repo:E,onCreated:de,onOpenCreated:(P)=>p?.({...P,root:c,repo:E})}),[_e,qt]=n(!1);i(()=>qt(!0),[]);let{count:We,clear:Ue}=le;if(i(()=>{if(!l)return;let P=(Z)=>{if(Z.key==="Escape"&&We>0)Ue()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[l,We,Ue]),!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 Qt=G.isLoading||O.refreshing;return e("div",{className:`flex flex-col h-full bg-paper ${t}`,children:[e(Be,{rootPath:c,activeRepo:E,repos:L,reposScanning:T,onRefreshRepos:R,onSelectRepo:z,searchQuery:h,onSearchChange:v,onRefresh:_,refreshing:Qt}),e("div",{className:`flex-1 scrollbar-overlay-container p-2 font-mono text-[11px] text-ink/80 ${be?"file-tree-touch":""} ${ue.highlighted?"bg-info/[0.06]":""}`,onContextMenu:(P)=>{P.preventDefault(),te({x:P.clientX,y:P.clientY})},onDragEnter:ue.onDragEnter,onDragLeave:ue.onDragLeave,onDragOver:ue.onDragOver,onDrop:ue.onDrop,children:G.isLoading&&Q.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"Loading files..."}):Q.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"No files found"}):Q.map((P)=>e(Oe,{file:P,rootPath:c,basePath:G.root,repo:E,onLoadChildren:K,onOpenFile:p,onActionComplete:_,onCreated:de,onRenamed:ye,expandedPaths:y,onToggleFolder:j,gitFileMap:A,gitFolderMap:H,clipboard:Y,archive:ke,selection:le,selectionTargets:xe,dragging:X,onDragStart:ge,onDragEnd:()=>ge(null),onDropOn:(Z)=>{if(!X)return;Y.move(X,Z)},onUnfold:q,onFold:V,foldRoots:he.roots,touch:be},P.path))}),e(Et,{}),_e&&e(Tt,{menu:ee,menuRef:oe,pasteLabel:pe,busy:Y.busy,create:Te,onAction:(P)=>{if(te(null),P==="new_file")Te.openDialog("file");if(P==="new_folder")Te.openDialog("folder");if(P==="paste")Y.paste(ve)}}),_e&&e(At,{archive:ke})]})}export{oi as FileExplorer};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n,i,s,H,Kr,Zl,Mf,Pf,vg,Hp}from"./index-
|
|
1
|
+
import{n,i,s,H,Kr,Zl,Mf,Pf,vg,Hp}from"./index-3wpsr2bc.js";var p={name:"save",size:24,node:[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]},yt=s(p);var ad="omp:editor-theme-changed";function a(){if(typeof window>"u")return Zl;return H("editorTheme")??Zl}var m={theme:null,vars:{},themes:Pf(null)};function uo(){let[e,t]=n(a);if(i(()=>{let r=(d)=>{let E=d.detail;t(E||a())};return window.addEventListener(ad,r),()=>window.removeEventListener(ad,r)},[]),i(()=>{Hp(e)},[e]),e===Kr)return m;let o=Mf(e);return{theme:o,vars:vg(o),themes:Pf(e)}}var id="omp:editor-indent-changed",od=[2,4,8],Uc={width:2,insertSpaces:!0};function sd(){if(typeof window>"u")return Uc;let e=H("editorIndentWidth"),t=H("editorInsertSpaces");return{width:typeof e==="number"&&od.includes(e)?e:Uc.width,insertSpaces:typeof t==="boolean"?t:Uc.insertSpaces}}function Gc(e){return e.insertSpaces?" ".repeat(e.width):"\t"}function jc(){let[e,t]=n(sd);return i(()=>{let o=(r)=>{let d=r.detail;t(d??sd())};return window.addEventListener(id,o),()=>window.removeEventListener(id,o)},[]),e}var ld="omp:editor-typing-changed",ol={autoCloseBrackets:!0,autocomplete:!0};function qc(){if(typeof window>"u")return ol;let e=H("editorAutoCloseBrackets"),t=H("editorAutocomplete");return{autoCloseBrackets:typeof e==="boolean"?e:ol.autoCloseBrackets,autocomplete:typeof t==="boolean"?t:ol.autocomplete}}function Hc(){let[e,t]=n(qc);return i(()=>{let o=(r)=>{let d=r.detail;t(d??qc())};return window.addEventListener(ld,o),()=>window.removeEventListener(ld,o)},[]),e}var os="omp:editor-blame-changed",sl={enabled:!0,inline:!1};function po(){if(typeof window>"u")return sl;let e=H("editorBlame"),t=H("editorBlameInline");return{enabled:typeof e==="boolean"?e:sl.enabled,inline:typeof t==="boolean"?t:sl.inline}}function cd(){let[e,t]=n(po);return i(()=>{let o=(r)=>{let d=r.detail;t(d??po())};return window.addEventListener(os,o),()=>window.removeEventListener(os,o)},[]),e}
|
|
2
2
|
export{yt,ad,uo,id,od,Uc,sd,Gc,jc,ld,ol,qc,Hc,os,sl,po,cd};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n,i,o,a,e,s,sr,m,ie,Dt,nt,C,b,H,Ie}from"./index-
|
|
1
|
+
import{n,i,o,a,e,s,sr,m,ie,Dt,nt,C,b,H,Ie}from"./index-3wpsr2bc.js";var Y={name:"pin-off",size:24,node:[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]},cl=s(Y);var M={name:"pin",size:24,node:[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]},_a=s(M);async function md(r){let u=r?`?path=${encodeURIComponent(r)}`:"",p=await fetch(`/api/fs/browse${u}`),l=await p.json();if(!p.ok||l.error)throw Error(l.error||`HTTP ${p.status}`);return l}function ys({initialPath:r,onSelect:u,onClose:p}){let[l,P]=n(r??""),[f,y]=n(""),[h,D]=n([]),[x,T]=n(null),[R,k]=n(!0),[v,S]=n(null),[z,g]=n(null),L=o(null),d=a(async(t)=>{k(!0),S(null);try{let c=await md(t);P(c.path??t??""),T(c.parentPath??null),y(c.path??t??""),D(c.directories??[])}catch(c){S(c instanceof Error?c.message:String(c))}finally{k(!1)}},[]);i(()=>{d(r)},[r,d]);let A=()=>{if(x)d(x)},I=(t)=>{t.preventDefault();let c=f.trim();if(c)d(c)},w=(t)=>{d(t.path)},_=(t)=>{g(t.path),u(t.path)},B=()=>{if(l)g(l),u(l)};return e("div",{className:"fixed inset-0 modal-scrim z-[60] flex items-center justify-center p-4",onClick:p,children:e("div",{className:"glass-overlay bg-paper border border-ink/15 rounded-lg shadow-2xl w-full max-w-lg flex flex-col overflow-hidden",onClick:(t)=>t.stopPropagation(),children:[e("div",{className:"flex items-center justify-between px-4 py-3 border-b border-ink/10",children:[e("h3",{className:"font-semibold text-sm flex items-center space-x-2",children:[e(Dt,{size:15,className:"text-ink/70"}),e("span",{children:"Choose Project Folder"})]}),e("button",{type:"button",onClick:p,className:"p-1 rounded hover:bg-ink/10 text-ink/60 hover:text-ink transition-colors","aria-label":"Close picker",children:e(b,{size:15})})]}),e("div",{className:"px-4 py-2 border-b border-ink/10 bg-canvas/50",children:[e("form",{onSubmit:I,className:"flex items-center space-x-2",children:[e(sr,{size:14,className:"text-ink/40 flex-shrink-0"}),e("input",{ref:L,type:"text",value:f,onChange:(t)=>y(t.currentTarget.value),placeholder:"~ or /absolute/path",className:"flex-1 bg-transparent outline-none text-xs font-mono text-ink placeholder-ink/35 py-1",spellcheck:!1}),e("button",{type:"submit",className:"px-2 py-1 rounded bg-ink/5 border border-ink/10 text-[11px] font-medium hover:bg-ink/10 transition-colors",children:"Go"})]}),e("div",{className:"flex items-center space-x-1 mt-1 text-[11px] text-ink/40 truncate",children:[e("button",{type:"button",onClick:()=>void d(),className:"hover:text-ink transition-colors flex items-center",children:[e(sr,{size:11,className:"mr-0.5"})," home"]}),l.split("/").filter(Boolean).map((t,c,F)=>{let N="/"+l.split("/").filter(Boolean).slice(0,c+1).join("/"),j=c===F.length-1;return e("span",{className:"flex items-center space-x-1 min-w-0",children:[e(ie,{size:10,className:"text-ink/20 flex-shrink-0"}),j?e("span",{className:"text-ink/70 truncate",children:t}):e("button",{type:"button",onClick:()=>void d(N),className:"hover:text-ink transition-colors truncate max-w-[120px]",children:t})]},N)})]})]}),e("div",{className:"flex-1 min-h-[240px] max-h-[360px] scrollbar-overlay-container p-2",children:R?e("div",{className:"flex items-center justify-center h-40 text-ink/40",children:e(m,{size:18,className:"animate-spin"})}):v?e("div",{className:"flex flex-col items-center justify-center h-40 text-xs text-error space-y-2 px-4",children:[e("span",{children:v}),e("button",{type:"button",onClick:()=>void d(l||void 0),className:"px-2 py-1 rounded bg-ink/5 border border-ink/10 text-ink/70 hover:bg-ink/10 flex items-center space-x-1",children:[e(C,{size:11})," Retry"]})]}):h.length===0?e("div",{className:"text-center py-16 text-xs text-ink/40",children:"No subfolders"}):h.map((t)=>e("div",{className:`group flex items-center justify-between px-2.5 py-2 rounded cursor-pointer transition-colors ${z===t.path?"bg-ink/10":"hover:bg-ink/5"}`,onDblClick:()=>w(t),children:[e("button",{type:"button",onClick:()=>w(t),className:"flex items-center space-x-2 min-w-0 flex-1 text-left",children:[e(nt,{size:15,className:"text-ink/50 flex-shrink-0"}),e("span",{className:"text-xs truncate text-ink/85",children:t.name})]}),e("button",{type:"button",onClick:()=>_(t),className:"touch-shown-flex hidden group-hover:flex px-2 py-0.5 rounded bg-ink text-canvas text-[10px] font-semibold hover:bg-ink/80 transition-colors flex-shrink-0",children:"Choose"})]},t.path))}),e("div",{className:"flex items-center justify-between px-4 py-3 border-t border-ink/10",children:[e("div",{className:"flex items-center space-x-2 min-w-0",children:[e("button",{type:"button",onClick:A,disabled:!x,className:"px-2.5 py-1.5 rounded bg-ink/5 border border-ink/10 text-[11px] font-medium hover:bg-ink/10 disabled:opacity-40 transition-colors flex items-center space-x-1",children:[e("span",{children:"↑"}),e("span",{children:"Up"})]}),e("button",{type:"button",onClick:()=>void d(),className:"px-2.5 py-1.5 rounded bg-ink/5 border border-ink/10 text-[11px] font-medium hover:bg-ink/10 transition-colors",children:"Home"})]}),e("div",{className:"flex items-center space-x-2",children:[e("button",{type:"button",onClick:p,className:"px-3 py-1.5 text-xs font-medium text-ink/60 hover:text-ink transition-colors",children:"Cancel"}),e("button",{type:"button",onClick:B,disabled:!l,className:"px-3.5 py-1.5 text-xs font-medium bg-ink text-canvas rounded hover:bg-ink/90 disabled:opacity-50 transition-colors",children:"Use This Folder"})]})]})]})})}var iA="modern",oA=["classic","modern"];function U(r){return r==="classic"||r==="modern"}function ul(r){return U(r)?r:"modern"}var sA={classic:{label:"Classic",description:"A toolbar of boxed icons and compact rows — the layout Kabmo has always shipped.",caption:"Toolbar · 24px rows"},modern:{label:"Modern",description:"Permanent search, filter chips, sticky workspace headers and taller rows with one trailing column.",caption:"Search · chips · 30px rows"}};var V="sidebarStyle",E="omp:sidebar-style-changed";function G(r){return ul(H(V,r))}function lA(r){if(typeof window>"u")return;window.dispatchEvent(new CustomEvent(E,{detail:ul(r)}))}function iu(){let[r,u]=n(()=>G());return Ie(E,(p)=>{u(ul(p.detail))}),r}
|
|
2
2
|
export{cl,_a,iA,oA,ul,sA,lA,iu,md,ys};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n,i,u,le,e,_A,we,I,m,Vt,Se,C,F,Fs,ee}from"./index-
|
|
1
|
+
import{n,i,u,le,e,_A,we,I,m,Vt,Se,C,F,Fs,ee}from"./index-3wpsr2bc.js";function w(a){if(!Number.isFinite(a)||a<=0)return"";return new Date(a).toLocaleString(void 0,{dateStyle:"short",timeStyle:"short"})}function N({files:a,selected:f,onSelect:h}){let[t,c]=n(""),p=u(()=>{let l=t.trim().toLowerCase();if(!l)return a;return a.filter((o)=>o.title.toLowerCase().includes(l))},[a,t]);return e("div",{className:"flex h-full min-h-0 w-full flex-col bg-canvas/40",children:[e("div",{className:"flex flex-shrink-0 items-center gap-1.5 border-b border-ink/10 px-2 py-1.5",children:[e(F,{size:12,className:"flex-shrink-0 text-ink/40"}),e("input",{type:"search",value:t,onChange:(l)=>c(l.target.value),placeholder:"Filter plans…","aria-label":"Filter plans",className:"min-w-0 flex-1 bg-transparent text-[11px] text-ink outline-none placeholder:text-ink/35"})]}),e("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-overlay-container",children:p.length===0?e("p",{className:"px-3 py-2 text-[11px] text-ink/40 italic",children:a.length===0?"No plan yet":"No plan matches the filter"}):e("ul",{className:"py-1",children:p.map((l)=>{let o=l.path===f,r=w(l.modifiedAt);return e("li",{children:e("button",{type:"button",onClick:()=>h(l.path),"aria-current":o?"true":void 0,title:`${l.path}${r?` · ${r}`:""}`,className:`flex w-full items-start gap-1.5 px-2.5 py-1.5 text-left transition-colors ${o?"bg-ink/10 font-semibold text-ink":"text-ink/80 hover:bg-ink/5 hover:text-ink"}`,children:[e(Se,{size:12,className:`mt-0.5 flex-shrink-0 ${o?"text-ink":"text-ink/40"}`}),e("span",{className:"min-w-0 flex-1",children:[e("span",{className:"block truncate text-[11.5px]",children:l.title}),r&&e("span",{className:"block truncate font-mono text-[10px] text-ink/40",children:r})]})]})},l.path)})})})]})}function g({file:a,content:f,isLoading:h,error:t,truncated:c,onBack:p}){return e("div",{className:"flex h-full min-h-0 w-full flex-col bg-paper",children:[e("div",{className:"flex flex-shrink-0 items-center gap-1.5 border-b border-ink/10 px-2.5 py-1.5",children:[e("button",{type:"button",onClick:p,title:"Back to the plan list","aria-label":"Back to the plan list",className:"flex-shrink-0 rounded p-1 text-ink/60 hover:bg-ink/5 hover:text-ink @[520px]:hidden",children:e(Vt,{size:13})}),e("span",{className:"min-w-0 flex-1 truncate text-[11px] text-ink/50",title:a?.path??"",children:a?.path??"Plan"}),h&&e(m,{size:12,className:"flex-shrink-0 animate-spin text-ink/40"})]}),e("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-overlay-container",children:t?e("div",{className:"flex flex-col items-center gap-2 px-6 py-8 text-center",children:[e(I,{size:16,className:"text-error"}),e("p",{className:"text-xs text-error",children:t})]}):!f?e("div",{className:"px-6 py-8 text-center text-xs text-ink/40",children:h?"Reading the plan…":"This plan is empty."}):e("article",{className:"mx-auto max-w-4xl px-5 py-4",children:[e(ee,{content:f,className:"max-w-none"}),c&&e("p",{className:"mt-4 border-t border-ink/10 pt-2 text-[11px] text-ink/50",children:"This plan is longer than the reader's budget and was cut off."})]})})]})}function J({className:a="",active:f=!0}){let[h]=le(),t=h.get("sessionId"),[c,p]=Fs("plan.selectedFile",null),[l,o]=n(!1),r=c&&c.sessionId===t?c.path:null,s=we(t?_A(t):null,{enabled:f}),x=s.data?.files??[],b=s.data?.current??null,d=u(()=>{if(r&&x.some((k)=>k.path===r))return r;return b},[r,x,b]),P=u(()=>x.find((k)=>k.path===d)??null,[x,d]);i(()=>{if(!t||!d||d===r)return;p({sessionId:t,path:d})},[t,d,r,p]),i(()=>{o(!1)},[t]);let y=(k)=>{if(t)p({sessionId:t,path:k});o(!0)};if(!t)return e("div",{className:`flex h-full flex-col items-center justify-center bg-paper text-ink/40 ${a}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});let v=x.length>0;return e("div",{className:`@container flex h-full min-h-0 w-full flex-col bg-paper text-xs text-ink ${a}`,children:[e("div",{className:"flex flex-shrink-0 items-center justify-between gap-2 border-b border-ink/10 px-2 py-1.5",children:[e("div",{className:"flex min-w-0 items-center gap-1.5",children:[e(Se,{size:12,className:"flex-shrink-0 text-ink/50"}),e("span",{className:"truncate text-[11px] font-medium text-ink/70",children:"Plan mode"}),v&&e("span",{className:"flex-shrink-0 rounded border border-ink/15 bg-ink/5 px-1.5 py-0.5 font-mono text-[10px] text-ink/60",children:x.length})]}),e("button",{type:"button",onClick:s.refresh,disabled:s.isLoading,title:"Re-read the plan","aria-label":"Re-read the plan",className:"flex-shrink-0 rounded p-1 text-ink/60 transition-colors hover:bg-ink/5 hover:text-ink disabled:opacity-50",children:e(C,{size:13,className:s.isLoading||s.refreshing?"animate-spin":""})})]}),s.stale&&!s.data?e("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center",children:[e(I,{size:16,className:"text-error"}),e("p",{className:"text-error",children:"The plan could not be read."}),e("button",{type:"button",onClick:s.refresh,className:"text-[11px] font-semibold text-ink/70 underline underline-offset-2 hover:text-ink",children:"Try again"})]}):!s.data?e("div",{className:"flex flex-1 items-center justify-center gap-2 text-ink/40",children:[e(m,{size:14,className:"animate-spin"}),e("span",{children:"Reading the plan…"})]}):!v?e("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center",children:[e(Se,{size:18,className:"text-ink/30"}),e("p",{className:"max-w-sm text-[11px] leading-relaxed text-ink/60",children:"No plan yet. Turn on Plan mode in the composer, and the plan this session writes will appear here."})]}):e("div",{className:"flex min-h-0 flex-1 flex-col @[520px]:flex-row-reverse",children:[e("div",{className:`min-h-0 w-full @[520px]:w-52 @[520px]:flex-shrink-0 border-b border-ink/10 @[520px]:border-b-0 @[520px]:border-l ${l?"hidden @[520px]:flex":"flex"} flex-col`,children:e(N,{files:x,selected:d,onSelect:y})}),e("div",{className:`min-w-0 min-h-0 flex-1 ${l?"flex":"hidden @[520px]:flex"} flex-col`,children:e(g,{file:P,content:s.data.content,isLoading:s.isLoading,error:s.stale?"The plan could not be read.":null,truncated:s.data.truncated,onBack:()=>o(!1)})})]})]})}export{J as PlanPanel};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t,l,st,ia,x,R,L,z,O,U,j,G,p,oa,Bo,h,nr,rr,W,hn,lt,Ye,Je,zn,$l,_t,St,wn,Tt,ct}from"./index-
|
|
1
|
+
import{t,l,st,ia,x,R,L,z,O,U,j,G,p,oa,Bo,h,nr,rr,W,hn,lt,Ye,Je,zn,$l,_t,St,wn,Tt,ct}from"./index-zj45wj1x.js";import{Nt}from"./index-3wpsr2bc.js";import{Ra}from"./index-kdgcbt17.js";var h1="flowchart-",d1=class{constructor(){this.vertexCounter=0,this.config=p(),this.diagramId="",this.vertices=new Map,this.edges=[],this.classes=new Map,this.subGraphs=[],this.subGraphLookup=new Map,this.tooltips=new Map,this.subCount=0,this.firstGraphFlag=!0,this.secCount=-1,this.posCrossRef=[],this.funs=[],this.setAccTitle=L,this.setAccDescription=O,this.setDiagramTitle=j,this.getAccTitle=z,this.getAccDescription=U,this.getDiagramTitle=G,this.funs.push(this.setupToolTips.bind(this)),this.addVertex=this.addVertex.bind(this),this.firstGraph=this.firstGraph.bind(this),this.setDirection=this.setDirection.bind(this),this.addSubGraph=this.addSubGraph.bind(this),this.addLink=this.addLink.bind(this),this.setLink=this.setLink.bind(this),this.updateLink=this.updateLink.bind(this),this.addClass=this.addClass.bind(this),this.setClass=this.setClass.bind(this),this.destructLink=this.destructLink.bind(this),this.setClickEvent=this.setClickEvent.bind(this),this.setTooltip=this.setTooltip.bind(this),this.updateLinkInterpolate=this.updateLinkInterpolate.bind(this),this.setClickFun=this.setClickFun.bind(this),this.bindFunctions=this.bindFunctions.bind(this),this.lex={firstGraph:this.firstGraph.bind(this)},this.clear(),this.setGen("gen-2")}static{t(this,"FlowDB")}sanitizeText(e){return x.sanitizeText(e,this.config)}sanitizeNodeLabelType(e){switch(e){case"markdown":case"string":case"text":return e;default:return"markdown"}}setDiagramId(e){this.diagramId=e}lookUpDomId(e){for(let r of this.vertices.values())if(r.id===e)return this.diagramId?`${this.diagramId}-${r.domId}`:r.domId;return this.diagramId?`${this.diagramId}-${e}`:e}addVertex(e,r,a,n,o,k,c={},A){if(!e||e.trim().length===0)return;let f;if(A!==void 0){let T;if(!A.includes(`
|
|
2
2
|
`))T=`{
|
|
3
3
|
`+A+`
|
|
4
4
|
}`;else T=A+`
|