@kabmo-labs/kabmo 0.33.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +785 -624
- package/dist/client/static/js/{CsvGrid-fncjbg6j.js → CsvGrid-vze4m5ag.js} +1 -1
- package/dist/client/static/js/{DocxView-c9v2vr3r.js → DocxView-jbf21gmh.js} +5 -5
- package/dist/client/static/js/{DrawioView-vxjksm12.js → DrawioView-b52qybx5.js} +2 -2
- package/dist/client/static/js/{ImageView-a3g5k226.js → ImageView-mdgzj8px.js} +1 -1
- package/dist/client/static/js/{LayoutWrapper-hnjfwsjh.js → LayoutWrapper-3c49dvtt.js} +2 -2
- package/dist/client/static/js/Modal-sqp864vd.js +38 -0
- package/dist/client/static/js/{PdfView-ksaes53y.js → PdfView-g06rxqb1.js} +1 -1
- package/dist/client/static/js/{SessionsView-30vcr95v.js → SessionsView-521adxyr.js} +1 -1
- package/dist/client/static/js/{SheetView-vc484scg.js → SheetView-h8xmsz7q.js} +22 -22
- package/dist/client/static/js/{SvgPreview-tph89jet.js → SvgPreview-1j4jvcvz.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-xbar278c.js → abnfDiagram-O67JEVCF-pasxh4b6.js} +1 -1
- package/dist/client/static/js/architecture-7GRP2DOG-fc9kmq1w.js +1 -0
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-s171n2z6.js → architectureDiagram-NJMV4G6O-ms14g0bm.js} +4 -4
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-gzx6rv9n.js → blockDiagram-BEXU5L5S-ycn78fcq.js} +4 -4
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-7f00skch.js → c4Diagram-YGBWAQC7-vn2gpjfm.js} +5 -5
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-j79v95nc.js → classDiagram-v2-NBCMYWYE-fyrm1pr5.js} +4 -4
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-5fkn7ee5.js → cose-bilkent-JH36ORCC-ea5nwvgq.js} +1 -1
- package/dist/client/static/js/cynefin-OW5HDTMX-a4t8992q.js +1 -0
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-cfs1yvrd.js → cynefinDiagram-VND7K2PF-j6bsjpre.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-44bgc48p.js → dagre-6A5THRUB-4smdkwv8.js} +2 -2
- package/dist/client/static/js/{diagram-22UHCM2B-a4g4x83k.js → diagram-22UHCM2B-9sm4kqwc.js} +11 -11
- package/dist/client/static/js/{diagram-3UASUU5V-gm4rg5na.js → diagram-3UASUU5V-2h3qxaed.js} +1 -1
- package/dist/client/static/js/{diagram-ATOU4E4O-a95y41vk.js → diagram-ATOU4E4O-1981bc94.js} +3 -3
- package/dist/client/static/js/{diagram-CDSNMT55-t3j93mmc.js → diagram-CDSNMT55-3vgsxavc.js} +4 -4
- package/dist/client/static/js/{diagram-MLGK6HIB-c2wdez02.js → diagram-MLGK6HIB-c9gf2r3f.js} +2 -2
- package/dist/client/static/js/{diagram-MPIPVDR6-gya9jhs5.js → diagram-MPIPVDR6-gjqeq92d.js} +2 -2
- package/dist/client/static/js/{dockerfile-a7q6174s.js → dockerfile-8v935dkn.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-jjhkza6t.js → ebnfDiagram-ZINNZB2B-4vbsgh99.js} +1 -1
- package/dist/client/static/js/{elixir-rpa1g4gy.js → elixir-vcbg60wv.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-f7re45mw.js → elk-276RUBZZ-nca3t891.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-tpm9g5te.js → erDiagram-OPXOYQCR-5kfkev03.js} +2 -2
- package/dist/client/static/js/eventmodeling-NTZA5JFV-18bdrkv5.js +1 -0
- package/dist/client/static/js/flowDiagram-KWPJA3E3-fg0yqx0h.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-fz43n12d.js → ganttDiagram-FUAMR5RP-mxc73wmq.js} +3 -3
- package/dist/client/static/js/gitGraph-4MIJSDKK-8fa6y40p.js +1 -0
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-f61hgbn6.js → gitGraphDiagram-X574FWY7-7en3ag0e.js} +12 -12
- package/dist/client/static/js/html-dbrwss36.js +1 -0
- package/dist/client/static/js/{index-m73za75e.js → index-0vm41je9.js} +3 -3
- package/dist/client/static/js/{index-eyzeya95.js → index-1b0t1428.js} +5 -5
- package/dist/client/static/js/{index-2x5f66t6.js → index-1ksg88qf.js} +1 -1
- package/dist/client/static/js/{index-sffjtm5w.js → index-231241f4.js} +9 -9
- package/dist/client/static/js/index-2mx9ej4k.css +1 -0
- package/dist/client/static/js/{index-8239j2v1.js → index-4g46wbdw.js} +1 -1
- package/dist/client/static/js/{index-1xqs14fr.js → index-4qwzxj81.js} +1 -1
- package/dist/client/static/js/{index-gcs49f3p.js → index-52rqxgya.js} +1 -1
- package/dist/client/static/js/{index-at6bhjyf.js → index-6sf2vsp2.js} +1 -1
- package/dist/client/static/js/{index-q2w6s8n7.js → index-7a64yjrm.js} +4 -4
- package/dist/client/static/js/{index-rg8jpbsw.js → index-8acv5b77.js} +2 -2
- package/dist/client/static/js/{index-js7t1vb1.js → index-a0fmsv1d.js} +5 -5
- package/dist/client/static/js/{index-w0fwb80e.js → index-ag2rmtas.js} +1 -1
- package/dist/client/static/js/{index-djmg1d7h.js → index-b29afsjh.js} +1 -1
- package/dist/client/static/js/{index-e4p4cd3r.js → index-c3ek61zv.js} +1 -1
- package/dist/client/static/js/{index-0e40xskg.js → index-cd65zqba.js} +1 -1
- package/dist/client/static/js/{index-zt75xpq0.js → index-cgzrpvzj.js} +204 -204
- package/dist/client/static/js/{index-0n5wwe60.js → index-ev3yt353.js} +2 -2
- package/dist/client/static/js/{index-9y3gjdj7.js → index-eyfcm0cy.js} +1 -1
- package/dist/client/static/js/{index-qsm2z36d.js → index-f7jhhqtk.js} +1 -1
- package/dist/client/static/js/{index-vw5k8csz.js → index-fta1y9pc.js} +50 -50
- package/dist/client/static/js/{index-ajs3jj6j.js → index-fvmfge3p.js} +1 -1
- package/dist/client/static/js/{index-pxv2nw9w.js → index-g2dyfze9.js} +1 -1
- package/dist/client/static/js/{index-bkye8mz4.js → index-h5bn97p6.js} +1 -1
- package/dist/client/static/js/{index-trm9x02n.js → index-j51d5a5m.js} +6 -6
- package/dist/client/static/js/{index-pbe4yed4.js → index-jsyekbx9.js} +2 -2
- package/dist/client/static/js/{index-gs6f0qwa.js → index-nccwxv0s.js} +2 -2
- package/dist/client/static/js/{index-d495kfm0.js → index-p0nz38bm.js} +1 -1
- package/dist/client/static/js/{index-sdtye3jy.js → index-pm6xxwz1.js} +2 -2
- package/dist/client/static/js/{index-3rcjx70v.js → index-ptcrwswj.js} +1 -1
- package/dist/client/static/js/{index-14vndmcr.js → index-ptcwae2n.js} +1 -1
- package/dist/client/static/js/{index-5tgq7aqx.js → index-r014brzs.js} +2 -2
- package/dist/client/static/js/{index-xj9649ac.js → index-ray2czf6.js} +7 -7
- package/dist/client/static/js/{index-apvkd37e.js → index-rs80cwsv.js} +3 -3
- package/dist/client/static/js/{index-vw4brsdx.js → index-rzxcj7cg.js} +1 -1
- package/dist/client/static/js/{index-a293pdg7.js → index-s7gkkkyz.js} +2 -2
- package/dist/client/static/js/{index-1a0zkj8h.js → index-sd66wv26.js} +2 -2
- package/dist/client/static/js/{index-ypx3qmhq.js → index-vhqe0y82.js} +1 -1
- package/dist/client/static/js/{index-9fjt5anh.js → index-vy6termr.js} +1 -1
- package/dist/client/static/js/{index-0tf0arsp.js → index-xx6mqpxm.js} +3 -3
- package/dist/client/static/js/{index-03h3bkcf.js → index-ybm2x4vh.js} +1 -1
- package/dist/client/static/js/info-A6RAGUB7-3hk844f7.js +1 -0
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-1qj804sn.js → infoDiagram-VRGFBTTK-sef80132.js} +2 -2
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-4j4qsnzw.js → ishikawaDiagram-OU5B5YK6-yhvepp1q.js} +6 -6
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-j0brnfft.js → journeyDiagram-ZHPQQLJL-5w77y95w.js} +5 -5
- package/dist/client/static/js/{julia-4ghmfy3e.js → julia-d4j6wgvf.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-qqc22br0.js → kanban-definition-PNTS6WVX-02znqtna.js} +6 -6
- package/dist/client/static/js/{mermaid.core-vv3wbe65.js → mermaid.core-a6e6vck4.js} +5 -5
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-y5b2z8zp.js → mindmap-definition-NLK3R4M7-y4n74q9x.js} +8 -8
- package/dist/client/static/js/one-dark-pro-vwhfpzr8.js +1 -0
- package/dist/client/static/js/one-light-y5t9x6zh.js +1 -0
- package/dist/client/static/js/packet-AYTQ26CC-4nj2yy10.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-0be07mqs.js → pegDiagram-GJSIUBJH-pr7ehgzb.js} +1 -1
- package/dist/client/static/js/{perl-sd00t4b4.js → perl-srptw5vm.js} +1 -1
- package/dist/client/static/js/{php-2zfyqa61.js → php-n89g3fk7.js} +1 -1
- package/dist/client/static/js/pie-WAS4IAKB-k7rde3f9.js +1 -0
- package/dist/client/static/js/{pieDiagram-5QR66LMP-544w86jk.js → pieDiagram-5QR66LMP-39wpsk08.js} +2 -2
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-p09e7z5s.js → quadrantDiagram-O4NWA36T-esm913km.js} +5 -5
- package/dist/client/static/js/radar-RG4KPBEZ-513dpw4f.js +1 -0
- package/dist/client/static/js/railroad-74A4TZTK-9bqnst9c.js +1 -0
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-7367d5bv.js +1 -0
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-b806b1mj.js +1 -0
- package/dist/client/static/js/railroad-peg-WCYAUIDC-5a67rwf8.js +1 -0
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-de830ed2.js → railroadDiagram-XR7U4H2S-wy2mgya6.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-b47d74p1.js → requirementDiagram-PLB6GJNP-6z9xdgbq.js} +2 -2
- package/dist/client/static/js/{ruby-v9qaqhby.js → ruby-r81ytgcm.js} +1 -1
- package/dist/client/static/js/{rust-fkt0qyrs.js → rust-frn3szvc.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-6ezc2fpj.js → sankeyDiagram-IPEJSGJF-rtmxk3ys.js} +4 -4
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-by5zqj6w.js → sequenceDiagram-PO4LG4MO-awzcrafg.js} +18 -18
- package/dist/client/static/js/{sizeCapture-INFHLROL-q85r06j6.js → sizeCapture-INFHLROL-03gy196j.js} +1 -1
- package/dist/client/static/js/sql-0e9mnrda.js +1 -0
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-ep5pyexs.js → stateDiagram-v2-GCMORJYK-an8v3q5n.js} +3 -3
- package/dist/client/static/js/{swimlanes-2SLR337P-95fcqkh8.js → swimlanes-2SLR337P-n9yb4wcs.js} +1 -1
- package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-xs2en5dv.js → swimlanesDiagram-TC7HE7FX-nx5nfnf0.js} +1 -1
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-461e615g.js → timeline-definition-EJHVYXUP-jceb575g.js} +4 -4
- package/dist/client/static/js/treeView-Q6P3EWNA-kcy40evb.js +1 -0
- package/dist/client/static/js/treemap-WGGIJYW6-fsrvqxf4.js +1 -0
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-ftqfnvhg.js → usecaseDiagram-POWQR4AR-888h3100.js} +13 -13
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-7t96h6ez.js → vennDiagram-UO4OBE2U-wbfz0rzv.js} +7 -7
- package/dist/client/static/js/{vue-j8vb9d7r.js → vue-c0rtg1wf.js} +1 -1
- package/dist/client/static/js/wardley-WFR3VGLG-36dmxww4.js +1 -0
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-0de8w8c6.js → wardleyDiagram-VNRHLVJA-rn8c5qf9.js} +4 -4
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-dez9phkf.js → xychartDiagram-PMCCYNJV-8sn1apt6.js} +5 -5
- package/package.json +4 -1
- package/src/client/components/auth/login-screen/index.tsx +1 -0
- package/src/client/components/common/MarkdownRenderer.tsx +9 -12
- package/src/client/components/settings/Modal.tsx +14 -84
- package/src/client/components/settings/Sidebar.tsx +3 -1
- package/src/client/components/settings/categories/ConnectSettings.tsx +105 -0
- package/src/client/components/settings/categories/connect-settings/DeviceTable.tsx +145 -0
- package/src/client/components/settings/categories/connect-settings/PairDialog.tsx +160 -0
- package/src/client/components/settings/categories/connect-settings/QrCode.tsx +73 -0
- package/src/client/components/settings/categories/connect-settings/ServerCard.tsx +94 -0
- package/src/client/components/settings/categories/connect-settings/TunnelRow.tsx +127 -0
- package/src/client/components/settings/category-content.tsx +116 -0
- package/src/client/components/workspace/chat-timeline/ChangedFilesSummary.test.tsx +120 -0
- package/src/client/components/workspace/chat-timeline/ChangedFilesSummary.tsx +56 -20
- package/src/client/components/workspace/chat-timeline/RunFooter.tsx +1 -0
- package/src/client/hooks/chat/timeline/change-stats.ts +57 -0
- package/src/client/hooks/connect/use-connect-status.ts +116 -0
- package/src/client/hooks/connect/use-pairing.ts +100 -0
- package/src/client/hooks/ui/clipboard.ts +26 -0
- package/src/client/tailwind.css +5 -0
- package/src/server/index.ts +2 -0
- package/src/server/lib/assets/font-css.server.test.ts +19 -0
- package/src/server/lib/auth/client-address.test.ts +58 -0
- package/src/server/lib/auth/client-address.ts +37 -3
- package/src/server/lib/auth/guard.ts +31 -4
- package/src/server/lib/auth/rate-limit.test.ts +25 -8
- package/src/server/lib/auth/rate-limit.ts +8 -5
- package/src/server/lib/connect/cloudflared.lifecycle.test.ts +88 -0
- package/src/server/lib/connect/cloudflared.server.test.ts +65 -0
- package/src/server/lib/connect/cloudflared.server.ts +206 -0
- package/src/server/lib/connect/devices.server.ts +192 -0
- package/src/server/lib/connect/identity.server.ts +81 -0
- package/src/server/lib/connect/pairing.server.test.ts +56 -0
- package/src/server/lib/connect/pairing.server.ts +113 -0
- package/src/server/lib/connect/qr.roundtrip.test.ts +106 -0
- package/src/server/lib/connect/qr.server.ts +36 -0
- package/src/server/lib/connect/run.server.ts +101 -0
- package/src/server/lib/connect/status.server.ts +177 -0
- package/src/server/lib/connect/tailscale.server.test.ts +117 -0
- package/src/server/lib/connect/tailscale.server.ts +172 -0
- package/src/server/lib/db/schema.ts +4 -0
- package/src/server/lib/omp/session/changes.test.ts +64 -1
- package/src/server/lib/omp/session/changes.ts +94 -1
- package/src/server/routes/connect/devices.ts +56 -0
- package/src/server/routes/connect/index.ts +15 -0
- package/src/server/routes/connect/pair-page.ts +177 -0
- package/src/server/routes/connect/pair.ts +158 -0
- package/src/server/routes/connect/status.ts +19 -0
- package/src/server/routes/connect/tunnels.ts +76 -0
- package/src/server/routes/health/probe.ts +5 -0
- package/src/server/routes/index.ts +2 -0
- package/src/server/routes/sessions/changes.test.ts +12 -3
- package/src/server/routes/sessions/changes.ts +27 -3
- package/src/server/routes/sessions/index.ts +2 -1
- package/src/shared/lib/connect/payload.test.ts +144 -0
- package/src/shared/lib/connect/payload.ts +229 -0
- package/src/shared/lib/connect/tier.test.ts +73 -0
- package/src/shared/lib/connect/tier.ts +105 -0
- package/src/shared/lib/connect/types.ts +99 -0
- package/src/shared/lib/markdown/fira-code-fonts.css +65 -6
- package/src/shared/lib/markdown/marked.ts +7 -4
- package/src/shared/lib/markdown/mermaid-actions.test.ts +78 -0
- package/src/shared/lib/markdown/mermaid-actions.ts +45 -0
- package/src/shared/lib/markdown/mermaid.ts +41 -7
- package/src/shared/lib/settings/sections.ts +6 -1
- package/src/shared/types/session-changes.ts +6 -0
- package/src/shared/types/settings/state.ts +2 -0
- package/dist/client/static/js/Modal-qtftcp2t.js +0 -38
- package/dist/client/static/js/architecture-7GRP2DOG-tavtgb8a.js +0 -1
- package/dist/client/static/js/cynefin-OW5HDTMX-cdh3n2z2.js +0 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-as97tpyp.js +0 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-ggm06d12.js +0 -1
- package/dist/client/static/js/gitGraph-4MIJSDKK-eqz7p9ng.js +0 -1
- package/dist/client/static/js/html-pv88ny12.js +0 -1
- package/dist/client/static/js/index-e94a1en0.css +0 -1
- package/dist/client/static/js/info-A6RAGUB7-4pkzh1qx.js +0 -1
- package/dist/client/static/js/one-dark-pro-hm3f56n1.js +0 -1
- package/dist/client/static/js/one-light-xrz49rct.js +0 -1
- package/dist/client/static/js/packet-AYTQ26CC-yg71sp88.js +0 -1
- package/dist/client/static/js/pie-WAS4IAKB-89wd6np0.js +0 -1
- package/dist/client/static/js/radar-RG4KPBEZ-avn0b8r9.js +0 -1
- package/dist/client/static/js/railroad-74A4TZTK-de27xv5w.js +0 -1
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-rg4zzj7x.js +0 -1
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-d84fhj8v.js +0 -1
- package/dist/client/static/js/railroad-peg-WCYAUIDC-dvf8xrmc.js +0 -1
- package/dist/client/static/js/sql-g8wcshpc.js +0 -1
- package/dist/client/static/js/treeView-Q6P3EWNA-mham0bh6.js +0 -1
- package/dist/client/static/js/treemap-WGGIJYW6-mxrxax86.js +0 -1
- package/dist/client/static/js/wardley-WFR3VGLG-8vrvh9p3.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Ra,Dl,ws,fn,Ql,ai}from"./index-vw5k8csz.js";function A(r,t){return r==null||t==null?NaN:r<t?-1:r>t?1:r>=t?0:NaN}function H(r,t){return r==null||t==null?NaN:t<r?-1:t>r?1:t>=r?0:NaN}function fl(r){let t,e,n;if(r.length!==2)t=A,e=(a,m)=>A(r(a),m),n=(a,m)=>r(a)-m;else t=r===A||r===H?r:Pr,e=r,n=r;function i(a,m,o=0,p=a.length){if(o<p){if(t(m,m)!==0)return p;do{let c=o+p>>>1;if(e(a[c],m)<0)o=c+1;else p=c}while(o<p)}return o}function u(a,m,o=0,p=a.length){if(o<p){if(t(m,m)!==0)return p;do{let c=o+p>>>1;if(e(a[c],m)<=0)o=c+1;else p=c}while(o<p)}return o}function f(a,m,o=0,p=a.length){let c=i(a,m,o,p-1);return c>o&&n(a[c-1],m)>-n(a[c],m)?c-1:c}return{left:i,center:f,right:u}}function Pr(){return 0}function J(r){return r===null?NaN:+r}var xr=fl(A),{right:jr,left:Zr}=xr,Hr=fl(J).center,yr=jr;var Fr=Math.sqrt(50),zr=Math.sqrt(10),Dr=Math.sqrt(2);function I(r,t,e){let n=(t-r)/Math.max(0,e),i=Math.floor(Math.log10(n)),u=n/Math.pow(10,i),f=u>=Fr?10:u>=zr?5:u>=Dr?2:1,a,m,o;if(i<0){if(o=Math.pow(10,-i)/f,a=Math.round(r*o),m=Math.round(t*o),a/o<r)++a;if(m/o>t)--m;o=-o}else{if(o=Math.pow(10,i)*f,a=Math.round(r/o),m=Math.round(t/o),a*o<r)++a;if(m*o>t)--m}if(m<a&&0.5<=e&&e<2)return I(r,t,e*2);return[a,m,o]}function K(r,t,e){if(t=+t,r=+r,e=+e,!(e>0))return[];if(r===t)return[r];let n=t<r,[i,u,f]=n?I(t,r,e):I(r,t,e);if(!(u>=i))return[];let a=u-i+1,m=Array(a);if(n)if(f<0)for(let o=0;o<a;++o)m[o]=(u-o)/-f;else for(let o=0;o<a;++o)m[o]=(u-o)*f;else if(f<0)for(let o=0;o<a;++o)m[o]=(i+o)/-f;else for(let o=0;o<a;++o)m[o]=(i+o)*f;return m}function T(r,t,e){return t=+t,r=+r,e=+e,I(r,t,e)[2]}function du(r,t,e){t=+t,r=+r,e=+e;let n=t<r,i=n?T(t,r,e):T(r,t,e);return(n?-1:1)*(i<0?1/-i:i)}function Q(r,t){if(!t)t=[];var e=r?Math.min(t.length,r.length):0,n=t.slice(),i;return function(u){for(i=0;i<e;++i)n[i]=r[i]*(1-u)+t[i]*u;return n}}function Mr(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function wr(r,t){var e=t?t.length:0,n=r?Math.min(e,r.length):0,i=Array(n),u=Array(e),f;for(f=0;f<n;++f)i[f]=b(r[f],t[f]);for(;f<e;++f)u[f]=t[f];return function(a){for(f=0;f<n;++f)u[f]=i[f](a);return u}}function W(r,t){var e=new Date;return r=+r,t=+t,function(n){return e.setTime(r*(1-n)+t*n),e}}function _(r,t){var e={},n={},i;if(r===null||typeof r!=="object")r={};if(t===null||typeof t!=="object")t={};for(i in t)if(i in r)e[i]=b(r[i],t[i]);else n[i]=t[i];return function(u){for(i in e)n[i]=e[i](u);return n}}function b(r,t){var e=typeof t,n;return t==null||e==="boolean"?Dl(t):(e==="number"?fn:e==="string"?(n=Ra(t))?(t=n,ws):Ql:t instanceof Ra?ws:t instanceof Date?W:Mr(t)?Q:Array.isArray(t)?wr:typeof t.valueOf!=="function"&&typeof t.toString!=="function"||isNaN(t)?_:fn)(r,t)}function rr(r,t){return r=+r,t=+t,function(e){return Math.round(r*(1-e)+t*e)}}function tr(r){return Math.abs(r=Math.round(r))>=1000000000000000000000?r.toLocaleString("en").replace(/,/g,""):r.toString(10)}function S(r,t){if(!isFinite(r)||r===0)return null;var e=(r=t?r.toExponential(t-1):r.toExponential()).indexOf("e"),n=r.slice(0,e);return[n.length>1?n[0]+n.slice(2):n,+r.slice(e+1)]}function g(r){return r=S(Math.abs(r)),r?r[1]:NaN}function nr(r,t){return function(e,n){var i=e.length,u=[],f=0,a=r[0],m=0;while(i>0&&a>0){if(m+a+1>n)a=Math.max(1,n-m);if(u.push(e.substring(i-=a,i+a)),(m+=a+1)>n)break;a=r[f=(f+1)%r.length]}return u.reverse().join(t)}}function er(r){return function(t){return t.replace(/[0-9]/g,function(e){return r[+e]})}}var Er=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function w(r){if(!(t=Er.exec(r)))throw Error("invalid format: "+r);var t;return new C({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}w.prototype=C.prototype;function C(r){this.fill=r.fill===void 0?" ":r.fill+"",this.align=r.align===void 0?">":r.align+"",this.sign=r.sign===void 0?"-":r.sign+"",this.symbol=r.symbol===void 0?"":r.symbol+"",this.zero=!!r.zero,this.width=r.width===void 0?void 0:+r.width,this.comma=!!r.comma,this.precision=r.precision===void 0?void 0:+r.precision,this.trim=!!r.trim,this.type=r.type===void 0?"":r.type+""}C.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function ir(r){r:for(var t=r.length,e=1,n=-1,i;e<t;++e)switch(r[e]){case".":n=i=e;break;case"0":if(n===0)n=e;i=e;break;default:if(!+r[e])break r;if(n>0)n=0;break}return n>0?r.slice(0,n)+r.slice(i+1):r}var z;function or(r,t){var e=S(r,t);if(!e)return z=void 0,r.toPrecision(t);var n=e[0],i=e[1],u=i-(z=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,f=n.length;return u===f?n:u>f?n+Array(u-f+1).join("0"):u>0?n.slice(0,u)+"."+n.slice(u):"0."+Array(1-u).join("0")+S(r,Math.max(0,t+u-1))[0]}function q(r,t){var e=S(r,t);if(!e)return r+"";var n=e[0],i=e[1];return i<0?"0."+Array(-i).join("0")+n:n.length>i+1?n.slice(0,i+1)+"."+n.slice(i+1):n+Array(i-n.length+2).join("0")}var fr={"%":(r,t)=>(r*100).toFixed(t),b:(r)=>Math.round(r).toString(2),c:(r)=>r+"",d:tr,e:(r,t)=>r.toExponential(t),f:(r,t)=>r.toFixed(t),g:(r,t)=>r.toPrecision(t),o:(r)=>Math.round(r).toString(8),p:(r,t)=>q(r*100,t),r:q,s:or,X:(r)=>Math.round(r).toString(16).toUpperCase(),x:(r)=>Math.round(r).toString(16)};function V(r){return r}var Nr=Array.prototype.map,kr=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function ar(r){var t=r.grouping===void 0||r.thousands===void 0?V:nr(Nr.call(r.grouping,Number),r.thousands+""),e=r.currency===void 0?"":r.currency[0]+"",n=r.currency===void 0?"":r.currency[1]+"",i=r.decimal===void 0?".":r.decimal+"",u=r.numerals===void 0?V:er(Nr.call(r.numerals,String)),f=r.percent===void 0?"%":r.percent+"",a=r.minus===void 0?"−":r.minus+"",m=r.nan===void 0?"NaN":r.nan+"";function o(c,d){c=w(c);var M=c.fill,j=c.align,x=c.sign,F=c.symbol,D=c.zero,Y=c.width,Z=c.comma,N=c.precision,pr=c.trim,s=c.type;if(s==="n")Z=!0,s="g";else if(!fr[s])N===void 0&&(N=12),pr=!0,s="g";if(D||M==="0"&&j==="=")D=!0,M="0",j="=";var br=(d&&d.prefix!==void 0?d.prefix:"")+(F==="$"?e:F==="#"&&/[boxX]/.test(s)?"0"+s.toLowerCase():""),Sr=(F==="$"?n:/[%p]/.test(s)?f:"")+(d&&d.suffix!==void 0?d.suffix:""),sr=fr[s],vr=/[defgprs%]/.test(s);N=N===void 0?6:/[gprs]/.test(s)?Math.max(1,Math.min(21,N)):Math.max(0,Math.min(20,N));function hr(l){var k=br,h=Sr,v,gr,E;if(s==="c")h=sr(l)+h,l="";else{l=+l;var L=l<0||1/l<0;if(l=isNaN(l)?m:sr(Math.abs(l),N),pr)l=ir(l);if(L&&+l===0&&x!=="+")L=!1;if(k=(L?x==="("?x:a:x==="-"||x==="("?"":x)+k,h=(s==="s"&&!isNaN(l)&&z!==void 0?kr[8+z/3]:"")+h+(L&&x==="("?")":""),vr){v=-1,gr=l.length;while(++v<gr)if(E=l.charCodeAt(v),48>E||E>57){h=(E===46?i+l.slice(v+1):l.slice(v))+h,l=l.slice(0,v);break}}}if(Z&&!D)l=t(l,1/0);var R=k.length+l.length+h.length,y=R<Y?Array(Y-R+1).join(M):"";if(Z&&D)l=t(y+l,y.length?Y-h.length:1/0),y="";switch(j){case"<":l=k+l+h+y;break;case"=":l=k+y+l+h;break;case"^":l=y.slice(0,R=y.length>>1)+k+l+h+y.slice(R);break;default:l=y+k+l+h;break}return u(l)}return hr.toString=function(){return c+""},hr}function p(c,d){var M=Math.max(-8,Math.min(8,Math.floor(g(d)/3)))*3,j=Math.pow(10,-M),x=o((c=w(c),c.type="f",c),{suffix:kr[8+M/3]});return function(F){return x(j*F)}}return{format:o,formatPrefix:p}}var B,Ka,G;ur({thousands:",",grouping:[3],currency:["$",""]});function ur(r){return B=ar(r),Ka=B.format,G=B.formatPrefix,B}function O(r){return Math.max(0,-g(Math.abs(r)))}function X(r,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(g(t)/3)))*3-g(Math.abs(r)))}function U(r,t){return r=Math.abs(r),t=Math.abs(t)-r,Math.max(0,g(t)-g(r))+1}function mr(r){return function(){return r}}function cr(r){return+r}var Ar=[0,1];function P(r){return r}function lr(r,t){return(t-=r=+r)?function(e){return(e-r)/t}:mr(isNaN(t)?NaN:0.5)}function Lr(r,t){var e;if(r>t)e=r,r=t,t=e;return function(n){return Math.max(r,Math.min(t,n))}}function Rr(r,t,e){var n=r[0],i=r[1],u=t[0],f=t[1];if(i<n)n=lr(i,n),u=e(f,u);else n=lr(n,i),u=e(u,f);return function(a){return u(n(a))}}function Ir(r,t,e){var n=Math.min(r.length,t.length)-1,i=Array(n),u=Array(n),f=-1;if(r[n]<r[0])r=r.slice().reverse(),t=t.slice().reverse();while(++f<n)i[f]=lr(r[f],r[f+1]),u[f]=e(t[f],t[f+1]);return function(a){var m=yr(r,a,1,n)-1;return u[m](i[m](a))}}function fd(r,t){return t.domain(r.domain()).range(r.range()).interpolate(r.interpolate()).clamp(r.clamp()).unknown(r.unknown())}function Tr(){var r=Ar,t=Ar,e=b,n,i,u,f=P,a,m,o;function p(){var d=Math.min(r.length,t.length);if(f!==P)f=Lr(r[0],r[d-1]);return a=d>2?Ir:Rr,m=o=null,c}function c(d){return d==null||isNaN(d=+d)?u:(m||(m=a(r.map(n),t,e)))(n(f(d)))}return c.invert=function(d){return f(i((o||(o=a(t,r.map(n),fn)))(d)))},c.domain=function(d){return arguments.length?(r=Array.from(d,cr),p()):r.slice()},c.range=function(d){return arguments.length?(t=Array.from(d),p()):t.slice()},c.rangeRound=function(d){return t=Array.from(d),e=rr,p()},c.clamp=function(d){return arguments.length?(f=d?!0:P,p()):f!==P},c.interpolate=function(d){return arguments.length?(e=d,p()):e},c.unknown=function(d){return arguments.length?(u=d,c):u},function(d,M){return n=d,i=M,p()}}function pu(){return Tr()(P,P)}function dr(r,t,e,n){var i=du(r,t,e),u;switch(n=w(n==null?",f":n),n.type){case"s":{var f=Math.max(Math.abs(r),Math.abs(t));if(n.precision==null&&!isNaN(u=X(i,f)))n.precision=u;return G(n,f)}case"":case"e":case"g":case"p":case"r":{if(n.precision==null&&!isNaN(u=U(i,Math.max(Math.abs(r),Math.abs(t)))))n.precision=u-(n.type==="e");break}case"f":case"%":{if(n.precision==null&&!isNaN(u=O(i)))n.precision=u-(n.type==="%")*2;break}}return Ka(n)}function $r(r){var t=r.domain;return r.ticks=function(e){var n=t();return K(n[0],n[n.length-1],e==null?10:e)},r.tickFormat=function(e,n){var i=t();return dr(i[0],i[i.length-1],e==null?10:e,n)},r.nice=function(e){if(e==null)e=10;var n=t(),i=0,u=n.length-1,f=n[i],a=n[u],m,o,p=10;if(a<f)o=f,f=a,a=o,o=i,i=u,u=o;while(p-- >0){if(o=T(f,a,e),o===m)return n[i]=f,n[u]=a,t(n);else if(o>0)f=Math.floor(f/o)*o,a=Math.ceil(a/o)*o;else if(o<0)f=Math.ceil(f*o)/o,a=Math.floor(a*o)/o;else break;m=o}return r},r}function ta(){var r=pu();return r.copy=function(){return fd(r,ta())},ai.apply(r,arguments),$r(r)}
|
|
2
|
-
export{fl,du,Ka,fd,pu,
|
|
1
|
+
import{Ra,Dl,ws,fn,Ql,ai}from"./index-fta1y9pc.js";function A(r,t){return r==null||t==null?NaN:r<t?-1:r>t?1:r>=t?0:NaN}function H(r,t){return r==null||t==null?NaN:t<r?-1:t>r?1:t>=r?0:NaN}function fl(r){let t,e,n;if(r.length!==2)t=A,e=(a,m)=>A(r(a),m),n=(a,m)=>r(a)-m;else t=r===A||r===H?r:Pr,e=r,n=r;function i(a,m,o=0,p=a.length){if(o<p){if(t(m,m)!==0)return p;do{let c=o+p>>>1;if(e(a[c],m)<0)o=c+1;else p=c}while(o<p)}return o}function u(a,m,o=0,p=a.length){if(o<p){if(t(m,m)!==0)return p;do{let c=o+p>>>1;if(e(a[c],m)<=0)o=c+1;else p=c}while(o<p)}return o}function f(a,m,o=0,p=a.length){let c=i(a,m,o,p-1);return c>o&&n(a[c-1],m)>-n(a[c],m)?c-1:c}return{left:i,center:f,right:u}}function Pr(){return 0}function J(r){return r===null?NaN:+r}var xr=fl(A),{right:jr,left:Zr}=xr,Hr=fl(J).center,yr=jr;var Fr=Math.sqrt(50),zr=Math.sqrt(10),Dr=Math.sqrt(2);function I(r,t,e){let n=(t-r)/Math.max(0,e),i=Math.floor(Math.log10(n)),u=n/Math.pow(10,i),f=u>=Fr?10:u>=zr?5:u>=Dr?2:1,a,m,o;if(i<0){if(o=Math.pow(10,-i)/f,a=Math.round(r*o),m=Math.round(t*o),a/o<r)++a;if(m/o>t)--m;o=-o}else{if(o=Math.pow(10,i)*f,a=Math.round(r/o),m=Math.round(t/o),a*o<r)++a;if(m*o>t)--m}if(m<a&&0.5<=e&&e<2)return I(r,t,e*2);return[a,m,o]}function K(r,t,e){if(t=+t,r=+r,e=+e,!(e>0))return[];if(r===t)return[r];let n=t<r,[i,u,f]=n?I(t,r,e):I(r,t,e);if(!(u>=i))return[];let a=u-i+1,m=Array(a);if(n)if(f<0)for(let o=0;o<a;++o)m[o]=(u-o)/-f;else for(let o=0;o<a;++o)m[o]=(u-o)*f;else if(f<0)for(let o=0;o<a;++o)m[o]=(i+o)/-f;else for(let o=0;o<a;++o)m[o]=(i+o)*f;return m}function T(r,t,e){return t=+t,r=+r,e=+e,I(r,t,e)[2]}function du(r,t,e){t=+t,r=+r,e=+e;let n=t<r,i=n?T(t,r,e):T(r,t,e);return(n?-1:1)*(i<0?1/-i:i)}function Q(r,t){if(!t)t=[];var e=r?Math.min(t.length,r.length):0,n=t.slice(),i;return function(u){for(i=0;i<e;++i)n[i]=r[i]*(1-u)+t[i]*u;return n}}function Mr(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function wr(r,t){var e=t?t.length:0,n=r?Math.min(e,r.length):0,i=Array(n),u=Array(e),f;for(f=0;f<n;++f)i[f]=b(r[f],t[f]);for(;f<e;++f)u[f]=t[f];return function(a){for(f=0;f<n;++f)u[f]=i[f](a);return u}}function W(r,t){var e=new Date;return r=+r,t=+t,function(n){return e.setTime(r*(1-n)+t*n),e}}function _(r,t){var e={},n={},i;if(r===null||typeof r!=="object")r={};if(t===null||typeof t!=="object")t={};for(i in t)if(i in r)e[i]=b(r[i],t[i]);else n[i]=t[i];return function(u){for(i in e)n[i]=e[i](u);return n}}function b(r,t){var e=typeof t,n;return t==null||e==="boolean"?Dl(t):(e==="number"?fn:e==="string"?(n=Ra(t))?(t=n,ws):Ql:t instanceof Ra?ws:t instanceof Date?W:Mr(t)?Q:Array.isArray(t)?wr:typeof t.valueOf!=="function"&&typeof t.toString!=="function"||isNaN(t)?_:fn)(r,t)}function rr(r,t){return r=+r,t=+t,function(e){return Math.round(r*(1-e)+t*e)}}function tr(r){return Math.abs(r=Math.round(r))>=1000000000000000000000?r.toLocaleString("en").replace(/,/g,""):r.toString(10)}function S(r,t){if(!isFinite(r)||r===0)return null;var e=(r=t?r.toExponential(t-1):r.toExponential()).indexOf("e"),n=r.slice(0,e);return[n.length>1?n[0]+n.slice(2):n,+r.slice(e+1)]}function g(r){return r=S(Math.abs(r)),r?r[1]:NaN}function nr(r,t){return function(e,n){var i=e.length,u=[],f=0,a=r[0],m=0;while(i>0&&a>0){if(m+a+1>n)a=Math.max(1,n-m);if(u.push(e.substring(i-=a,i+a)),(m+=a+1)>n)break;a=r[f=(f+1)%r.length]}return u.reverse().join(t)}}function er(r){return function(t){return t.replace(/[0-9]/g,function(e){return r[+e]})}}var Er=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function w(r){if(!(t=Er.exec(r)))throw Error("invalid format: "+r);var t;return new C({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}w.prototype=C.prototype;function C(r){this.fill=r.fill===void 0?" ":r.fill+"",this.align=r.align===void 0?">":r.align+"",this.sign=r.sign===void 0?"-":r.sign+"",this.symbol=r.symbol===void 0?"":r.symbol+"",this.zero=!!r.zero,this.width=r.width===void 0?void 0:+r.width,this.comma=!!r.comma,this.precision=r.precision===void 0?void 0:+r.precision,this.trim=!!r.trim,this.type=r.type===void 0?"":r.type+""}C.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function ir(r){r:for(var t=r.length,e=1,n=-1,i;e<t;++e)switch(r[e]){case".":n=i=e;break;case"0":if(n===0)n=e;i=e;break;default:if(!+r[e])break r;if(n>0)n=0;break}return n>0?r.slice(0,n)+r.slice(i+1):r}var z;function or(r,t){var e=S(r,t);if(!e)return z=void 0,r.toPrecision(t);var n=e[0],i=e[1],u=i-(z=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,f=n.length;return u===f?n:u>f?n+Array(u-f+1).join("0"):u>0?n.slice(0,u)+"."+n.slice(u):"0."+Array(1-u).join("0")+S(r,Math.max(0,t+u-1))[0]}function q(r,t){var e=S(r,t);if(!e)return r+"";var n=e[0],i=e[1];return i<0?"0."+Array(-i).join("0")+n:n.length>i+1?n.slice(0,i+1)+"."+n.slice(i+1):n+Array(i-n.length+2).join("0")}var fr={"%":(r,t)=>(r*100).toFixed(t),b:(r)=>Math.round(r).toString(2),c:(r)=>r+"",d:tr,e:(r,t)=>r.toExponential(t),f:(r,t)=>r.toFixed(t),g:(r,t)=>r.toPrecision(t),o:(r)=>Math.round(r).toString(8),p:(r,t)=>q(r*100,t),r:q,s:or,X:(r)=>Math.round(r).toString(16).toUpperCase(),x:(r)=>Math.round(r).toString(16)};function V(r){return r}var Nr=Array.prototype.map,kr=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function ar(r){var t=r.grouping===void 0||r.thousands===void 0?V:nr(Nr.call(r.grouping,Number),r.thousands+""),e=r.currency===void 0?"":r.currency[0]+"",n=r.currency===void 0?"":r.currency[1]+"",i=r.decimal===void 0?".":r.decimal+"",u=r.numerals===void 0?V:er(Nr.call(r.numerals,String)),f=r.percent===void 0?"%":r.percent+"",a=r.minus===void 0?"−":r.minus+"",m=r.nan===void 0?"NaN":r.nan+"";function o(c,d){c=w(c);var M=c.fill,j=c.align,x=c.sign,F=c.symbol,D=c.zero,Y=c.width,Z=c.comma,N=c.precision,pr=c.trim,s=c.type;if(s==="n")Z=!0,s="g";else if(!fr[s])N===void 0&&(N=12),pr=!0,s="g";if(D||M==="0"&&j==="=")D=!0,M="0",j="=";var br=(d&&d.prefix!==void 0?d.prefix:"")+(F==="$"?e:F==="#"&&/[boxX]/.test(s)?"0"+s.toLowerCase():""),Sr=(F==="$"?n:/[%p]/.test(s)?f:"")+(d&&d.suffix!==void 0?d.suffix:""),sr=fr[s],vr=/[defgprs%]/.test(s);N=N===void 0?6:/[gprs]/.test(s)?Math.max(1,Math.min(21,N)):Math.max(0,Math.min(20,N));function hr(l){var k=br,h=Sr,v,gr,E;if(s==="c")h=sr(l)+h,l="";else{l=+l;var L=l<0||1/l<0;if(l=isNaN(l)?m:sr(Math.abs(l),N),pr)l=ir(l);if(L&&+l===0&&x!=="+")L=!1;if(k=(L?x==="("?x:a:x==="-"||x==="("?"":x)+k,h=(s==="s"&&!isNaN(l)&&z!==void 0?kr[8+z/3]:"")+h+(L&&x==="("?")":""),vr){v=-1,gr=l.length;while(++v<gr)if(E=l.charCodeAt(v),48>E||E>57){h=(E===46?i+l.slice(v+1):l.slice(v))+h,l=l.slice(0,v);break}}}if(Z&&!D)l=t(l,1/0);var R=k.length+l.length+h.length,y=R<Y?Array(Y-R+1).join(M):"";if(Z&&D)l=t(y+l,y.length?Y-h.length:1/0),y="";switch(j){case"<":l=k+l+h+y;break;case"=":l=k+y+l+h;break;case"^":l=y.slice(0,R=y.length>>1)+k+l+h+y.slice(R);break;default:l=y+k+l+h;break}return u(l)}return hr.toString=function(){return c+""},hr}function p(c,d){var M=Math.max(-8,Math.min(8,Math.floor(g(d)/3)))*3,j=Math.pow(10,-M),x=o((c=w(c),c.type="f",c),{suffix:kr[8+M/3]});return function(F){return x(j*F)}}return{format:o,formatPrefix:p}}var B,Ka,G;ur({thousands:",",grouping:[3],currency:["$",""]});function ur(r){return B=ar(r),Ka=B.format,G=B.formatPrefix,B}function O(r){return Math.max(0,-g(Math.abs(r)))}function X(r,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(g(t)/3)))*3-g(Math.abs(r)))}function U(r,t){return r=Math.abs(r),t=Math.abs(t)-r,Math.max(0,g(t)-g(r))+1}function mr(r){return function(){return r}}function cr(r){return+r}var Ar=[0,1];function P(r){return r}function lr(r,t){return(t-=r=+r)?function(e){return(e-r)/t}:mr(isNaN(t)?NaN:0.5)}function Lr(r,t){var e;if(r>t)e=r,r=t,t=e;return function(n){return Math.max(r,Math.min(t,n))}}function Rr(r,t,e){var n=r[0],i=r[1],u=t[0],f=t[1];if(i<n)n=lr(i,n),u=e(f,u);else n=lr(n,i),u=e(u,f);return function(a){return u(n(a))}}function Ir(r,t,e){var n=Math.min(r.length,t.length)-1,i=Array(n),u=Array(n),f=-1;if(r[n]<r[0])r=r.slice().reverse(),t=t.slice().reverse();while(++f<n)i[f]=lr(r[f],r[f+1]),u[f]=e(t[f],t[f+1]);return function(a){var m=yr(r,a,1,n)-1;return u[m](i[m](a))}}function fd(r,t){return t.domain(r.domain()).range(r.range()).interpolate(r.interpolate()).clamp(r.clamp()).unknown(r.unknown())}function Tr(){var r=Ar,t=Ar,e=b,n,i,u,f=P,a,m,o;function p(){var d=Math.min(r.length,t.length);if(f!==P)f=Lr(r[0],r[d-1]);return a=d>2?Ir:Rr,m=o=null,c}function c(d){return d==null||isNaN(d=+d)?u:(m||(m=a(r.map(n),t,e)))(n(f(d)))}return c.invert=function(d){return f(i((o||(o=a(t,r.map(n),fn)))(d)))},c.domain=function(d){return arguments.length?(r=Array.from(d,cr),p()):r.slice()},c.range=function(d){return arguments.length?(t=Array.from(d),p()):t.slice()},c.rangeRound=function(d){return t=Array.from(d),e=rr,p()},c.clamp=function(d){return arguments.length?(f=d?!0:P,p()):f!==P},c.interpolate=function(d){return arguments.length?(e=d,p()):e},c.unknown=function(d){return arguments.length?(u=d,c):u},function(d,M){return n=d,i=M,p()}}function pu(){return Tr()(P,P)}function dr(r,t,e,n){var i=du(r,t,e),u;switch(n=w(n==null?",f":n),n.type){case"s":{var f=Math.max(Math.abs(r),Math.abs(t));if(n.precision==null&&!isNaN(u=X(i,f)))n.precision=u;return G(n,f)}case"":case"e":case"g":case"p":case"r":{if(n.precision==null&&!isNaN(u=U(i,Math.max(Math.abs(r),Math.abs(t)))))n.precision=u-(n.type==="e");break}case"f":case"%":{if(n.precision==null&&!isNaN(u=O(i)))n.precision=u-(n.type==="%")*2;break}}return Ka(n)}function $r(r){var t=r.domain;return r.ticks=function(e){var n=t();return K(n[0],n[n.length-1],e==null?10:e)},r.tickFormat=function(e,n){var i=t();return dr(i[0],i[i.length-1],e==null?10:e,n)},r.nice=function(e){if(e==null)e=10;var n=t(),i=0,u=n.length-1,f=n[i],a=n[u],m,o,p=10;if(a<f)o=f,f=a,a=o,o=i,i=u,u=o;while(p-- >0){if(o=T(f,a,e),o===m)return n[i]=f,n[u]=a,t(n);else if(o>0)f=Math.floor(f/o)*o,a=Math.ceil(a/o)*o;else if(o<0)f=Math.ceil(f*o)/o,a=Math.floor(a*o)/o;else break;m=o}return r},r}function na(){var r=pu();return r.copy=function(){return fd(r,na())},ai.apply(r,arguments),$r(r)}
|
|
2
|
+
export{fl,du,Ka,fd,pu,na};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d,n,i,o,a,e,s,I,ne,ze,Fe,D,Ki,ft,Se,_e,y,ee,io,Im}from"./index-zt75xpq0.js";var F={name:"list-filter",size:24,node:[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]]},M=s(F);function T({title:t,options:r,methodLabel:p,badge:m,icon:x,onCancel:g}){let f=io({title:t,options:r})?Im(t):null,v=f?`Allow ${f.tool}`:t||p;return e("div",{className:"flex items-center justify-between border-b border-ink/8 bg-canvas/40 px-5 py-3.5",children:[e("div",{className:"flex items-center gap-3 min-w-0",children:[e("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-ink/12 bg-paper text-ink shadow-xs",children:x}),e("div",{className:"min-w-0",children:[e("div",{className:"flex items-center gap-2",children:[e("h3",{className:"truncate text-[14px] font-semibold tracking-tight text-ink",children:v}),e("span",{className:"flex items-center gap-1 rounded-full border border-ink/10 bg-paper px-2 py-0.5 font-mono text-[10px] font-medium tracking-wider text-ink/60 uppercase",children:[e(Fe,{size:9,className:"text-ink/40"}),m]})]}),e("p",{className:"mt-0.5 text-[11px] text-ink/50",children:f?"The agent wants to run this. Review it before you allow.":"Autonomous agent inquiry requiring user confirmation"})]})]}),e("button",{type:"button",onClick:g,"aria-label":"Close dialog (Esc)",title:"Cancel (Esc)",className:"flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded-lg border border-ink/10 text-ink/45 transition-colors hover:border-ink/25 hover:bg-ink/5 hover:text-ink",children:e(y,{size:14})})]})}function S({options:t,optionDetails:r,selectedOption:p,customValue:m,onCustomChange:x,customInputRef:g,onSelect:f,onConfirmOption:v,hideCustomAnswer:l=!1}){return e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Available Options"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:["Press [1-",Math.min(9,t.length),"] to choose"]})]}),e("div",{className:"grid gap-2",role:"radiogroup",children:t.map((b,h)=>{let u=p===b,k=r[h]?.description;return e("button",{type:"button",onClick:()=>f(b),onDblClick:()=>v(b),"aria-checked":u,role:"radio",className:`group flex w-full cursor-pointer items-start gap-3 rounded-xl border p-3.5 text-left transition-all ${u?"border-ink bg-paper shadow-sm ring-1 ring-ink/10":"border-ink/10 bg-canvas/30 hover:border-ink/25 hover:bg-paper"}`,children:[e("span",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md font-mono text-[11px] font-semibold transition-colors ${u?"bg-ink text-paper":"border border-ink/15 bg-paper text-ink/60 group-hover:border-ink/30 group-hover:text-ink"}`,children:h+1}),e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"flex items-center gap-2",children:e("span",{className:`text-[13px] font-medium leading-snug ${u?"text-ink font-semibold":"text-ink/85"}`,children:b})}),k&&e("div",{className:"mt-1 text-[11.5px] leading-relaxed text-ink/55",children:k})]}),e("span",{className:"mt-0.5 shrink-0",children:u?e(ne,{size:16,className:"text-ink"}):e(Ki,{size:16,className:"text-ink/20 group-hover:text-ink/40"})})]},b)})}),!l&&e("div",{className:"space-y-1.5 pt-1",children:[e("div",{className:"text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:"Other: type your own answer"}),e("input",{ref:g,type:"text",value:m,placeholder:"Type a custom answer and press Enter...",onChange:(b)=>x(b.currentTarget.value),onKeyDown:(b)=>{if(b.key==="Enter"){if(b.preventDefault(),b.stopPropagation(),m.trim())v(m.trim())}},className:"w-full rounded-xl border border-ink/15 bg-paper px-4 py-3 text-[13.5px] text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:ring-2 focus:ring-ink/15"})]})]})}function P({method:t,optionsLength:r,selectedOption:p,hasCustomAnswer:m=!1,onCancel:x,onSubmit:g}){let f=t==="select"&&!p&&!m;return e("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t border-ink/8 bg-canvas/40 px-5 py-3.5",children:[e("div",{className:"flex items-center gap-2 font-mono text-[11px] text-ink/50",children:[t==="select"&&e(d,{children:[e("span",{className:"hidden items-center gap-1 sm:inline-flex",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:["1-",Math.min(9,r)]}),e("span",{className:"text-ink/40",children:"choose"})]}),e("span",{className:"hidden text-ink/30 sm:inline",children:"•"}),e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"↵"}),e("span",{className:"text-ink/40",children:"select"})]})]}),t==="confirm"&&e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"↵"}),e("span",{className:"text-ink/40",children:"confirm"})]}),t==="editor"&&e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"⌘↵"}),e("span",{className:"text-ink/40",children:"save buffer"})]}),e("span",{className:"text-ink/30",children:"•"}),e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"Esc"}),e("span",{className:"text-ink/40",children:"cancel"})]})]}),e("div",{className:"flex items-center gap-2.5 ml-auto",children:[e("button",{type:"button",onClick:x,className:"flex cursor-pointer items-center gap-1 rounded-lg border border-ink/15 bg-paper px-3.5 py-1.5 text-[12px] font-medium text-ink/70 transition-colors hover:border-ink/30 hover:bg-canvas/50 hover:text-ink",children:[e(y,{size:12,className:"opacity-60"}),e("span",{children:"Cancel"})]}),e("button",{type:"button",onClick:g,disabled:f,className:"flex cursor-pointer items-center gap-1.5 rounded-lg bg-ink px-4 py-1.5 text-[12px] font-semibold text-paper shadow-xs transition-all hover:opacity-90 active:scale-[0.98] disabled:cursor-not-allowed disabled:opacity-35",children:[e("span",{children:t==="confirm"?"Confirm":t==="select"?"Select Option":"Submit Response"}),e(ft,{size:12,className:"opacity-70"})]})]})]})}function R({title:t,options:r}){let p=io({title:t,options:r})?Im(t):null;if(!p)return null;return e("div",{className:"space-y-2",children:[p.reason&&e("div",{className:"flex items-start gap-2 rounded-xl border border-warning/25 bg-warning/8 px-3.5 py-2.5 text-[12px] leading-relaxed text-ink/80",children:[e(D,{size:13,className:"mt-0.5 shrink-0 text-warning"}),e("span",{className:"min-w-0 break-words",children:p.reason})]}),p.details.length>0&&e("div",{className:"rounded-xl border border-ink/10 bg-canvas/40 px-3.5 py-2.5",children:p.details.map((m,x)=>e("div",{className:"font-mono text-[11.5px] leading-relaxed text-ink/75 break-all",children:m},`${x}-${m}`))})]})}function L({method:t,options:r,selectedOption:p,onSelectOption:m,customInputRef:x,onSubmit:g,onCancel:f}){i(()=>{let v=(l)=>{if(l.key==="Escape"){l.preventDefault(),l.stopPropagation(),f();return}if(t==="select"&&r.length>0){if(l.target instanceof HTMLInputElement&&l.target===x.current)return;let h=parseInt(l.key,10);if(!isNaN(h)&&h>=1&&h<=r.length){l.preventDefault(),m(r[h-1]);return}if(l.key==="ArrowDown"){l.preventDefault();let u=r.findIndex((N)=>N===p),k=u<r.length-1?u+1:0;m(r[k]);return}if(l.key==="ArrowUp"){l.preventDefault();let u=r.findIndex((N)=>N===p),k=u>0?u-1:r.length-1;m(r[k]);return}if(l.key==="Enter"&&p){l.preventDefault(),g();return}}if(t==="confirm"){if(l.key==="Enter"){l.preventDefault(),g();return}}if(t==="editor"){if((l.metaKey||l.ctrlKey)&&l.key==="Enter"){l.preventDefault(),g();return}}};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[f,g,t,r,p,m,x])}function O(t,r){switch(t){case"select":return{icon:e(M,{size:16,className:"text-ink"}),label:"Decision Required",badge:`${r} Choices`};case"confirm":return{icon:e(I,{size:16,className:"text-ink"}),label:"Confirmation Required",badge:"Confirm Action"};case"input":return{icon:e(_e,{size:16,className:"text-ink"}),label:"Prompt Input",badge:"Text Input"};case"editor":return{icon:e(Se,{size:16,className:"text-ink"}),label:"Buffer Editor",badge:"Multiline Buffer"};default:return{icon:e(ze,{size:16,className:"text-ink"}),label:"Agent Request",badge:"Input"}}}function ke({request:t,onRespond:r}){let[p,m]=n(t.method==="editor"?t.prefill??"":""),[x,g]=n(null),[f,v]=n(""),l=o(null),b=o(null),h=o(null),u=o(null),k=t.options??[],N=t.optionDetails??[],E=io(t);i(()=>{let c=t.options??[];m(t.method==="editor"?t.prefill??"":""),g(c.length>0?c[0]:null),v("")},[t]),i(()=>{if(l.current?.focus(),t.method==="input")b.current?.focus();else if(t.method==="editor")h.current?.focus();else if(t.method==="select"){if((t.options??[]).some((B)=>/^other\b/i.test(B.trim())))u.current?.focus()}},[t]);let w=a(()=>{r(t,{cancelled:!0})},[r,t]),A=a(()=>{if(t.method==="confirm")r(t,{confirmed:!0});else if(t.method==="select"){if(f.trim()&&!E)r(t,{value:f.trim()});else if(x)r(t,{value:x})}else r(t,{value:p})},[r,t,x,p,f,E]),z=a((c)=>{if(/^other\b/i.test(c.trim())){g(c),u.current?.focus();return}r(t,{value:c})},[r,t]),H=a((c)=>{if(g(c),/^other\b/i.test(c.trim()))u.current?.focus()},[]);L({method:t.method,options:k,selectedOption:x,onSelectOption:g,customInputRef:u,onSubmit:A,onCancel:w});let C=O(t.method,k.length);return e("div",{className:"extension-dialog-backdrop modal-scrim fixed inset-0 z-50 flex items-center justify-center p-4 sm:p-6 backdrop-blur-[8px]",onMouseDown:(c)=>{if(c.target===c.currentTarget)w()},children:e("div",{ref:l,role:"dialog","aria-modal":"true","aria-label":t.title||C.label,tabIndex:-1,className:"glass-overlay extension-dialog-panel w-full max-w-[560px] overflow-hidden rounded-2xl border border-ink/15 bg-paper shadow-2xl outline-none",style:{boxShadow:"0 24px 64px -8px color-mix(in srgb, var(--theme-ink) 28%, transparent)"},children:[e(T,{title:t.title,options:k,methodLabel:C.label,badge:C.badge,icon:C.icon,onCancel:w}),e("div",{className:"max-h-[65vh] overflow-y-auto px-6 py-5 space-y-4",children:[e(R,{title:t.title,options:k}),t.message&&e("div",{className:"rounded-xl border border-ink/8 bg-canvas/40 p-4 text-[13px] leading-relaxed text-ink/85 select-text",children:e(ee,{content:t.message})}),t.method==="select"&&e(S,{options:k,optionDetails:N,selectedOption:x,customValue:f,onCustomChange:v,customInputRef:u,onSelect:H,onConfirmOption:z,hideCustomAnswer:E}),t.method==="confirm"&&e("div",{className:"flex items-center gap-3 rounded-xl border border-ink/10 bg-canvas/30 p-4",children:[e("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-ink/5 text-ink",children:e(ne,{size:18})}),e("div",{className:"text-[12.5px] leading-relaxed text-ink/75",children:["Confirming will allow the autonomous agent to proceed with this operation. Press ",e("kbd",{className:"rounded border border-ink/20 bg-paper px-1 py-0.2 font-mono text-[10.5px]",children:"Enter"})," to confirm or ",e("kbd",{className:"rounded border border-ink/20 bg-paper px-1 py-0.2 font-mono text-[10.5px]",children:"Esc"})," to abort."]})]}),t.method==="input"&&e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Your Response"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:"Press [Enter] to submit"})]}),e("input",{ref:b,type:t.secret===!0?"password":"text",value:p,placeholder:t.placeholder||"Type your response...",onChange:(c)=>m(c.currentTarget.value),onKeyDown:(c)=>{if(c.key==="Enter")c.preventDefault(),A()},className:"w-full rounded-xl border border-ink/15 bg-paper px-4 py-3 text-[13.5px] text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:ring-2 focus:ring-ink/15"})]}),t.method==="editor"&&e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Buffer Content"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:[p.split(`
|
|
2
|
-
`).length," lines · ⌘↵ to save"]})]}),e("textarea",{ref:
|
|
1
|
+
import{d,n,i,o,a,e,s,I,ne,ze,Fe,D,Ki,ft,Se,_e,b,ee,io,Im}from"./index-cgzrpvzj.js";var F={name:"list-filter",size:24,node:[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]]},M=s(F);function T({title:t,options:r,methodLabel:p,badge:m,icon:x,onCancel:g}){let f=io({title:t,options:r})?Im(t):null,h=f?`Allow ${f.tool}`:t||p;return e("div",{className:"flex items-center justify-between border-b border-ink/8 bg-canvas/40 px-5 py-3.5",children:[e("div",{className:"flex items-center gap-3 min-w-0",children:[e("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-ink/12 bg-paper text-ink shadow-xs",children:x}),e("div",{className:"min-w-0",children:[e("div",{className:"flex items-center gap-2",children:[e("h3",{className:"truncate text-[14px] font-semibold tracking-tight text-ink",children:h}),e("span",{className:"flex items-center gap-1 rounded-full border border-ink/10 bg-paper px-2 py-0.5 font-mono text-[10px] font-medium tracking-wider text-ink/60 uppercase",children:[e(Fe,{size:9,className:"text-ink/40"}),m]})]}),e("p",{className:"mt-0.5 text-[11px] text-ink/50",children:f?"The agent wants to run this. Review it before you allow.":"Autonomous agent inquiry requiring user confirmation"})]})]}),e("button",{type:"button",onClick:g,"aria-label":"Close dialog (Esc)",title:"Cancel (Esc)",className:"flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded-lg border border-ink/10 text-ink/45 transition-colors hover:border-ink/25 hover:bg-ink/5 hover:text-ink",children:e(b,{size:14})})]})}function S({options:t,optionDetails:r,selectedOption:p,customValue:m,onCustomChange:x,customInputRef:g,onSelect:f,onConfirmOption:h,hideCustomAnswer:l=!1}){return e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Available Options"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:["Press [1-",Math.min(9,t.length),"] to choose"]})]}),e("div",{className:"grid gap-2",role:"radiogroup",children:t.map((k,y)=>{let u=p===k,v=r[y]?.description;return e("button",{type:"button",onClick:()=>f(k),onDblClick:()=>h(k),"aria-checked":u,role:"radio",className:`group flex w-full cursor-pointer items-start gap-3 rounded-xl border p-3.5 text-left transition-all ${u?"border-ink bg-paper shadow-sm ring-1 ring-ink/10":"border-ink/10 bg-canvas/30 hover:border-ink/25 hover:bg-paper"}`,children:[e("span",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md font-mono text-[11px] font-semibold transition-colors ${u?"bg-ink text-paper":"border border-ink/15 bg-paper text-ink/60 group-hover:border-ink/30 group-hover:text-ink"}`,children:y+1}),e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"flex items-center gap-2",children:e("span",{className:`text-[13px] font-medium leading-snug ${u?"text-ink font-semibold":"text-ink/85"}`,children:k})}),v&&e("div",{className:"mt-1 text-[11.5px] leading-relaxed text-ink/55",children:v})]}),e("span",{className:"mt-0.5 shrink-0",children:u?e(ne,{size:16,className:"text-ink"}):e(Ki,{size:16,className:"text-ink/20 group-hover:text-ink/40"})})]},k)})}),!l&&e("div",{className:"space-y-1.5 pt-1",children:[e("div",{className:"text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:"Other: type your own answer"}),e("input",{ref:g,type:"text",value:m,placeholder:"Type a custom answer and press Enter...",onChange:(k)=>x(k.currentTarget.value),onKeyDown:(k)=>{if(k.key==="Enter"){if(k.preventDefault(),k.stopPropagation(),m.trim())h(m.trim())}},className:"w-full rounded-xl border border-ink/15 bg-paper px-4 py-3 text-[13.5px] text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:ring-2 focus:ring-ink/15"})]})]})}function P({method:t,optionsLength:r,selectedOption:p,hasCustomAnswer:m=!1,onCancel:x,onSubmit:g}){let f=t==="select"&&!p&&!m;return e("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t border-ink/8 bg-canvas/40 px-5 py-3.5",children:[e("div",{className:"flex items-center gap-2 font-mono text-[11px] text-ink/50",children:[t==="select"&&e(d,{children:[e("span",{className:"hidden items-center gap-1 sm:inline-flex",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:["1-",Math.min(9,r)]}),e("span",{className:"text-ink/40",children:"choose"})]}),e("span",{className:"hidden text-ink/30 sm:inline",children:"•"}),e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"↵"}),e("span",{className:"text-ink/40",children:"select"})]})]}),t==="confirm"&&e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"↵"}),e("span",{className:"text-ink/40",children:"confirm"})]}),t==="editor"&&e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"⌘↵"}),e("span",{className:"text-ink/40",children:"save buffer"})]}),e("span",{className:"text-ink/30",children:"•"}),e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"Esc"}),e("span",{className:"text-ink/40",children:"cancel"})]})]}),e("div",{className:"flex items-center gap-2.5 ml-auto",children:[e("button",{type:"button",onClick:x,className:"flex cursor-pointer items-center gap-1 rounded-lg border border-ink/15 bg-paper px-3.5 py-1.5 text-[12px] font-medium text-ink/70 transition-colors hover:border-ink/30 hover:bg-canvas/50 hover:text-ink",children:[e(b,{size:12,className:"opacity-60"}),e("span",{children:"Cancel"})]}),e("button",{type:"button",onClick:g,disabled:f,className:"flex cursor-pointer items-center gap-1.5 rounded-lg bg-ink px-4 py-1.5 text-[12px] font-semibold text-paper shadow-xs transition-all hover:opacity-90 active:scale-[0.98] disabled:cursor-not-allowed disabled:opacity-35",children:[e("span",{children:t==="confirm"?"Confirm":t==="select"?"Select Option":"Submit Response"}),e(ft,{size:12,className:"opacity-70"})]})]})]})}function R({title:t,options:r}){let p=io({title:t,options:r})?Im(t):null;if(!p)return null;return e("div",{className:"space-y-2",children:[p.reason&&e("div",{className:"flex items-start gap-2 rounded-xl border border-warning/25 bg-warning/8 px-3.5 py-2.5 text-[12px] leading-relaxed text-ink/80",children:[e(D,{size:13,className:"mt-0.5 shrink-0 text-warning"}),e("span",{className:"min-w-0 break-words",children:p.reason})]}),p.details.length>0&&e("div",{className:"rounded-xl border border-ink/10 bg-canvas/40 px-3.5 py-2.5",children:p.details.map((m,x)=>e("div",{className:"font-mono text-[11.5px] leading-relaxed text-ink/75 break-all",children:m},`${x}-${m}`))})]})}function L({method:t,options:r,selectedOption:p,onSelectOption:m,customInputRef:x,onSubmit:g,onCancel:f}){i(()=>{let h=(l)=>{if(l.key==="Escape"){l.preventDefault(),l.stopPropagation(),f();return}if(t==="select"&&r.length>0){if(l.target instanceof HTMLInputElement&&l.target===x.current)return;let y=parseInt(l.key,10);if(!isNaN(y)&&y>=1&&y<=r.length){l.preventDefault(),m(r[y-1]);return}if(l.key==="ArrowDown"){l.preventDefault();let u=r.findIndex((N)=>N===p),v=u<r.length-1?u+1:0;m(r[v]);return}if(l.key==="ArrowUp"){l.preventDefault();let u=r.findIndex((N)=>N===p),v=u>0?u-1:r.length-1;m(r[v]);return}if(l.key==="Enter"&&p){l.preventDefault(),g();return}}if(t==="confirm"){if(l.key==="Enter"){l.preventDefault(),g();return}}if(t==="editor"){if((l.metaKey||l.ctrlKey)&&l.key==="Enter"){l.preventDefault(),g();return}}};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[f,g,t,r,p,m,x])}function O(t,r){switch(t){case"select":return{icon:e(M,{size:16,className:"text-ink"}),label:"Decision Required",badge:`${r} Choices`};case"confirm":return{icon:e(I,{size:16,className:"text-ink"}),label:"Confirmation Required",badge:"Confirm Action"};case"input":return{icon:e(_e,{size:16,className:"text-ink"}),label:"Prompt Input",badge:"Text Input"};case"editor":return{icon:e(Se,{size:16,className:"text-ink"}),label:"Buffer Editor",badge:"Multiline Buffer"};default:return{icon:e(ze,{size:16,className:"text-ink"}),label:"Agent Request",badge:"Input"}}}function ke({request:t,onRespond:r}){let[p,m]=n(t.method==="editor"?t.prefill??"":""),[x,g]=n(null),[f,h]=n(""),l=o(null),k=o(null),y=o(null),u=o(null),v=t.options??[],N=t.optionDetails??[],E=io(t);i(()=>{let c=t.options??[];m(t.method==="editor"?t.prefill??"":""),g(c.length>0?c[0]:null),h("")},[t]),i(()=>{if(l.current?.focus(),t.method==="input")k.current?.focus();else if(t.method==="editor")y.current?.focus();else if(t.method==="select"){if((t.options??[]).some((B)=>/^other\b/i.test(B.trim())))u.current?.focus()}},[t]);let w=a(()=>{r(t,{cancelled:!0})},[r,t]),A=a(()=>{if(t.method==="confirm")r(t,{confirmed:!0});else if(t.method==="select"){if(f.trim()&&!E)r(t,{value:f.trim()});else if(x)r(t,{value:x})}else r(t,{value:p})},[r,t,x,p,f,E]),z=a((c)=>{if(/^other\b/i.test(c.trim())){g(c),u.current?.focus();return}r(t,{value:c})},[r,t]),H=a((c)=>{if(g(c),/^other\b/i.test(c.trim()))u.current?.focus()},[]);L({method:t.method,options:v,selectedOption:x,onSelectOption:g,customInputRef:u,onSubmit:A,onCancel:w});let C=O(t.method,v.length);return e("div",{className:"extension-dialog-backdrop modal-scrim fixed inset-0 z-50 flex items-center justify-center p-4 sm:p-6 backdrop-blur-[8px]",onMouseDown:(c)=>{if(c.target===c.currentTarget)w()},children:e("div",{ref:l,role:"dialog","aria-modal":"true","aria-label":t.title||C.label,tabIndex:-1,className:"glass-overlay extension-dialog-panel w-full max-w-[560px] overflow-hidden rounded-2xl border border-ink/15 bg-paper shadow-2xl outline-none",style:{boxShadow:"0 24px 64px -8px color-mix(in srgb, var(--theme-ink) 28%, transparent)"},children:[e(T,{title:t.title,options:v,methodLabel:C.label,badge:C.badge,icon:C.icon,onCancel:w}),e("div",{className:"max-h-[65vh] overflow-y-auto px-6 py-5 space-y-4",children:[e(R,{title:t.title,options:v}),t.message&&e("div",{className:"rounded-xl border border-ink/8 bg-canvas/40 p-4 text-[13px] leading-relaxed text-ink/85 select-text",children:e(ee,{content:t.message})}),t.method==="select"&&e(S,{options:v,optionDetails:N,selectedOption:x,customValue:f,onCustomChange:h,customInputRef:u,onSelect:H,onConfirmOption:z,hideCustomAnswer:E}),t.method==="confirm"&&e("div",{className:"flex items-center gap-3 rounded-xl border border-ink/10 bg-canvas/30 p-4",children:[e("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-ink/5 text-ink",children:e(ne,{size:18})}),e("div",{className:"text-[12.5px] leading-relaxed text-ink/75",children:["Confirming will allow the autonomous agent to proceed with this operation. Press ",e("kbd",{className:"rounded border border-ink/20 bg-paper px-1 py-0.2 font-mono text-[10.5px]",children:"Enter"})," to confirm or ",e("kbd",{className:"rounded border border-ink/20 bg-paper px-1 py-0.2 font-mono text-[10.5px]",children:"Esc"})," to abort."]})]}),t.method==="input"&&e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Your Response"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:"Press [Enter] to submit"})]}),e("input",{ref:k,type:t.secret===!0?"password":"text",value:p,placeholder:t.placeholder||"Type your response...",onChange:(c)=>m(c.currentTarget.value),onKeyDown:(c)=>{if(c.key==="Enter")c.preventDefault(),A()},className:"w-full rounded-xl border border-ink/15 bg-paper px-4 py-3 text-[13.5px] text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:ring-2 focus:ring-ink/15"})]}),t.method==="editor"&&e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Buffer Content"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:[p.split(`
|
|
2
|
+
`).length," lines · ⌘↵ to save"]})]}),e("textarea",{ref:y,value:p,onChange:(c)=>m(c.currentTarget.value),rows:8,placeholder:t.placeholder||"Enter content...",className:"w-full rounded-xl border border-ink/15 bg-canvas/30 px-4 py-3 font-mono text-[12px] leading-relaxed text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:bg-paper focus:ring-2 focus:ring-ink/15"})]})]}),e(P,{method:t.method,optionsLength:v.length,selectedOption:x,hasCustomAnswer:f.trim().length>0,onCancel:w,onSubmit:A})]})})}export{ke as ExtensionDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n,i,u,
|
|
1
|
+
import{n,i,u,le,e,SA,we,I,m,Vt,Se,C,F,Rs,ee}from"./index-cgzrpvzj.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]=Rs("plan.selectedFile",null),[l,o]=n(!1),r=c&&c.sessionId===t?c.path:null,s=we(t?SA(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,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var k=Object.create;var{getPrototypeOf:l,defineProperty:f,getOwnPropertyNames:m}=Object;var j=Object.prototype.hasOwnProperty;function n(a){return this[a]}var o,p,an=(a,b,c)=>{var g=a!=null&&typeof a==="object";if(g){var h=b?o??=new WeakMap:p??=new WeakMap,i=h.get(a);if(i)return i}c=a!=null?k(l(a)):{};let d=b||!a||!a.__esModule||!j.call(a,"default")?f(c,"default",{value:a,enumerable:!0}):c;if(a&&typeof a==="object"||typeof a==="function"){for(let e of m(a))if(!j.call(d,e))f(d,e,{get:n.bind(a,e),enumerable:!0})}if(g)h.set(a,d);return d};var
|
|
3
|
-
export{an,
|
|
2
|
+
var k=Object.create;var{getPrototypeOf:l,defineProperty:f,getOwnPropertyNames:m}=Object;var j=Object.prototype.hasOwnProperty;function n(a){return this[a]}var o,p,an=(a,b,c)=>{var g=a!=null&&typeof a==="object";if(g){var h=b?o??=new WeakMap:p??=new WeakMap,i=h.get(a);if(i)return i}c=a!=null?k(l(a)):{};let d=b||!a||!a.__esModule||!j.call(a,"default")?f(c,"default",{value:a,enumerable:!0}):c;if(a&&typeof a==="object"||typeof a==="function"){for(let e of m(a))if(!j.call(d,e))f(d,e,{get:n.bind(a,e),enumerable:!0})}if(g)h.set(a,d);return d};var bn=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var q=(a)=>a;function r(a,b){this[a]=q.bind(null,b)}var dn=(a,b)=>{for(var c in b)f(a,c,{get:b[c],enumerable:!0,configurable:!0,set:r.bind(b,c)})};var Jf=import.meta.require;
|
|
3
|
+
export{an,bn,dn,Jf};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d,n,i,o,u,a,Ar,He,de,e,Gn,w,TA,we,Ds,S,ir,or,s,Bn,U,Xe,B,ae,oe,Ie,Ge,Yi,Xt,Ji,Ur,C,F,y,le,hn,Du,rt,at,UA,GA,jo,qo,Qu,Ve}from"./index-zt75xpq0.js";import{Eu,ji,Bu,Iu}from"./index-1xqs14fr.js";import{Ss,fr,_u}from"./index-qsm2z36d.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"}]]},Te=s(Zt);function Be({rootPath:t,activeRepo:r,repos:l,reposScanning:c,onRefreshRepos:p,onSelectRepo:f,searchQuery:b,onSearchChange:h,onRefresh:x,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:x,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:b,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:b,folderStatus:h}){let x=f?"text-ink font-semibold":b?b.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(ae,{size:12,className:"flex-shrink-0 text-ink/40"}):e("span",{className:"w-3 flex-shrink-0"}),e(rt,{name:t,isFolder:l,isOpen:c,size:12,className:`flex-shrink-0${p?" opacity-40":""}`}),e("span",{className:`truncate min-w-0 flex-1 ${x}`,title:p?`${r} — git-ignored`:void 0,children:t}),b&&e("span",{className:`font-mono text-[10px] font-bold px-1 rounded flex-shrink-0 ${b.colorClass}`,title:`Git: ${b.label}`,children:b.charStatus}),h&&e("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${h.hasDeleted?"bg-error":h.hasModified||h.hasStaged?"bg-info":"bg-success"}`,title:`${h.count} changed file${h.count>1?"s":""}`})]})}var en=28,tn=9,nn=8;function rn(t){let{isFolder:r,hasGitStatus:l,pasteLabel:c,busy:p,chainLabel:f,foldable:b,selectionCount:h,isArchive:x}=t,g=[],m=h>1,k=h===1?"":` ${h} items`;if(m)return g.push({kind:"item",id:"cut",label:`Cut${k}`,icon:e(Te,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"copy",label:`Copy${k}`,icon:e(oe,{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(U,{size:13,className:"text-error"}),tone:"text-error"}),g;if(r){if(g.push({kind:"item",id:"new_file",label:"New File",icon:e(Yi,{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(b)g.push({kind:"item",id:"fold",label:"Fold Folders",icon:e(ae,{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"})}),x)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(Ji,{size:13,className:"text-warning"}),tone:"font-medium"});g.push({kind:"separator"})}if(g.push({kind:"item",id:"cut",label:"Cut",icon:e(Te,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"copy",label:"Copy",icon:e(oe,{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(Ss,{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(Ie,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"copy_path",label:"Copy Path",icon:e(oe,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"copy_relative",label:"Copy Relative Path",icon:e(oe,{size:13,className:"text-ink/60"})}),g.push({kind:"separator"}),g.push({kind:"item",id:"history",label:"Show Git History",icon:e(Bn,{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(U,{size:13,className:"text-error"}),tone:"text-error"}),g}function on(t){let r=t.filter((c)=>c.kind==="item").length,l=t.length-r;return r*en+l*tn+nn}function Ze({x:t,y:r,isFolder:l,hasGitStatus:c,pasteLabel:p,chainLabel:f,foldable:b,busy:h,selectionCount:x,isArchive:g,onAction:m,menuRef:k}){let D=rn({isFolder:l,hasGitStatus:c,pasteLabel:p,busy:h,chainLabel:f,foldable:b,selectionCount:x,isArchive:g}),E=on(D),N=typeof window<"u"?Math.max(10,Math.min(t,window.innerWidth-210-12)):t,M=typeof window<"u"?Math.max(10,Math.min(r,window.innerHeight-E-12)):r;return de(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:M,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 Ce({folderPath:t,kind:r,value:l,error:c,isLoading:p,onChange:f,onCancel:b,onSubmit:h}){let x=r==="folder"?"Folder":"File";return de(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 ",x]}),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 ${x.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:b,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:b}){let h=c>1;return de(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:b,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:b,onCancel:h,onSubmit:x}){return de(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-3 text-sm",children:["Rename ",t?"Folder":"File"]}),e("input",{autoFocus:!0,type:"text",value:r,onChange:(g)=>b(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 de(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(Bn,{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(y,{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,b)=>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})]},b))})]}):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 ot({actions:t,file:r,isFolder:l,chainLabel:c}){let p=t.selectionCount;return e(d,{children:[t.showCreateModal&&e(Ce,{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 Se(t){let r=t.map(sn);return r.some((l,c)=>l!==t[c])?r:t}function sn(t){if(t.type!=="folder"||!Array.isArray(t.children))return t;let r=Se(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 Ae(t){return t.type==="folder"&&t.name.includes("/")}function Ee(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,b)=>[...p,...l.slice(0,b+1)].join("/"))}function it(t,r){let l=new Map;if(r.size===0)return{nodes:t,roots:l};let c=!1,p=(b)=>b.flatMap((h)=>{if(h.type!=="folder")return[h];let x=Array.isArray(h.children)?p(h.children):h.children,g=x===h.children?h:{...h,children:x},m=r.has(h.path)?Ee(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 v=m.length-1;v>0;v-=1){let D=m[v-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=(b)=>{for(let h of b){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 b=0;b<p.length;b+=1){let h=p.slice(0,b+1).join("/");if(l.has(h))f.push(h)}return f}function Fe({folderPath:t,rootPath:r,repo:l,onCreated:c,onOpenCreated:p}){let f=at(),[b,h]=n(!1),[x,g]=n("file"),[m,k]=n(""),[v,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 M=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:M}),M==="file")p?.({path:N.path,name:T})}else D(N.error||`Could not create the ${x}`)},[f.state,f.data]),{open:b,kind:x,name:m,setName:k,error:v,busy:f.state!=="idle",openDialog:(N="file")=>{g(N),k(""),D(null),h(!0)},closeDialog:()=>h(!1),submit:(N)=>{N.preventDefault();let M=m.trim();if(!M)return;D(null);let T=new FormData;if(T.append("actionType","create"),T.append("path",t),T.append("name",M),x==="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 Ne(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 Me(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=an(p);if(!f)return null;c.push(f)}if(c.length===0)return null;return{scope:r.scope,entries:c,mode:r.mode}}function an(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 Le=[{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 $e(t){let r=t.toLowerCase();for(let[l,c]of mt)if(r.endsWith(l))return c;return null}function ht(t){return $e(t)!==null}function ln(t){return Le.find((r)=>r.id===t)}function cn(t){return ln(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 De(t,r){let l=cn(r);if(t.length===1){let f=t[0],b=gt(f.name),h=b.lastIndexOf(".");return`${(f.kind==="folder"?f.name:h>0?b.slice(0,h):b)||"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:b,onFold:h,clipboard:x,isFolder:g,selection:m,selected:k,archive:v}){let D=at(),[E,N]=n(null),M=o(null),[T,R]=n(!1),[A,I]=n(!1),[_,ee]=n(!1),[te,ie]=n(t.path),[H,P]=n(null),{repo:z,rootPath:G}=t,K=Fe({folderPath:t.path,rootPath:G,repo:z,onCreated:(L)=>p?p(L):c(),onOpenCreated:(L)=>l?.({...L,root:G,repo:z||"."})}),ne=o(null);i(()=>{if(D.state!=="idle"||!D.data)return;let L=D.data;if(ne.current===L)return;if(ne.current=L,L.success&&!L.type)if(R(!1),I(!1),P(null),L.previousPath&&L.path&&f)f(L.previousPath,L.path);else c();else if(!L.success&&L.error&&T)P(L.error)},[D.state,D.data]);let q=(L)=>{if(z&&z!==".")L.append("repo",z);if(G)L.append("root",G);D.submit(L,{method:"post",action:"/api/fs/action"})},V=()=>{l?.({path:t.path,name:t.name,root:G,repo:z||"."})},J={path:t.path,name:t.name,kind:g?"folder":"file"},re=k&&m.length>1?m:[J],he=ht(t.name),Q=x.clip&&!x.refusalFor(J)?`Paste ${Ne(x.clip)??"item"}`:null,fe=(L)=>{if(N(null),P(null),L==="view")V();else if(L==="diff")window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.path,staged:r?.staged,status:r?.status||"M",repo:z||".",root:G}}));else if(L==="explorer"){let j=new FormData;j.append("actionType","open_explorer"),j.append("path",t.path),q(j)}else if(L==="copy_path")hn(Du(t.basePath,t.path));else if(L==="copy_relative")hn(t.path);else if(L==="history"){ee(!0);let j=new FormData;j.append("actionType","git_history"),j.append("path",t.path),q(j)}else if(L==="rename")ie(t.path),R(!0);else if(L==="unfold")b?.();else if(L==="fold")h?.();else if(L==="new_file")K.openDialog("file");else if(L==="new_folder")K.openDialog("folder");else if(L==="delete")I(!0);else if(L==="cut")x.cut(re);else if(L==="copy")x.copy(re);else if(L==="compress")v.openCompress(re);else if(L==="extract")v.openExtract(J);else if(L==="duplicate")x.duplicate(J);else if(L==="paste")x.paste(J)},se=(L)=>{L.preventDefault(),P(null);let j=new FormData;j.append("actionType","rename"),j.append("path",t.path),j.append("newPath",te),q(j)},xe=()=>{let L=new FormData;if(L.append("actionType","delete"),re.length>1)L.append("paths",JSON.stringify(re.map((j)=>j.path)));else L.append("path",t.path);q(L)};return{contextMenu:E,contextMenuRef:M,openContextMenu:(L,j)=>N({x:L,y:j}),closeContextMenu:()=>N(null),showRenameModal:T,showDeleteModal:A,showHistoryModal:_,showCreateModal:K.open,createKind:K.kind,createError:K.error,createName:K.name,setCreateName:K.setName,renameValue:te,setRenameValue:ie,renameError:H,busy:D.state!=="idle"||K.busy||x.busy||v.busy,pasteLabel:Q,selectionCount:re.length,isArchive:he,chainLabel:b!==void 0,foldable:h!==void 0,fetcherState:D.state,fetcherData:D.data,handleAction:fe,submitCreate:K.submit,submitRename:se,submitDelete:xe,closeCreate:K.closeDialog,closeDelete:()=>I(!1),closeRename:()=>R(!1),closeHistory:()=>ee(!1)}}function Nt({target:t,dragging:r,clipboard:l,onDragStart:c,onDragEnd:p,onDropOn:f,onHoverAccept:b}){let h=r?.path===t.path,x=Boolean(r)&&!h&&l.moveRefusalFor(r,t)===null,[g,m]=n(!1);return i(()=>{if(!r)m(!1)},[r]),{isDragging:h,acceptsDrop:x,isDropHovered:g&&x,onDragStart:(v)=>{if(v.dataTransfer?.setData("text/plain",t.path),v.dataTransfer)v.dataTransfer.effectAllowed="move";c(t)},onDragEnd:p,onDragOver:(v)=>{if(!r)return;if(v.stopPropagation(),m(x),!x)return;if(v.preventDefault(),v.dataTransfer)v.dataTransfer.dropEffect="move";b?.(t)},onDragLeave:()=>m(!1),onDrop:(v)=>{if(!r)return;if(v.stopPropagation(),!x)return;v.preventDefault(),f(t)}}}var dn=450,wt=8,pn=700;function Dt({enabled:t,onLongPress:r}){let l=o(null),c=o(null),p=o(0),f=o(r);f.current=r;let b=a(()=>{if(l.current!==null)clearTimeout(l.current),l.current=null;c.current=null},[]);return i(()=>b,[b]),{onTouchStart:(h)=>{if(!t)return;let x=h.touches[0];if(!x)return;b(),c.current={x:x.clientX,y:x.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)},dn)},onTouchMove:(h)=>{let x=c.current,g=h.touches[0];if(!x||!g)return;if(Math.abs(g.clientX-x.x)>wt||Math.abs(g.clientY-x.y)>wt)b()},onTouchEnd:b,onTouchCancel:b,consume:()=>{if(p.current===0)return!1;let h=Date.now()-p.current<pn;return p.current=0,h}}}function un(t,r,l){if(r||l)return!1;return!Array.isArray(t.children)}function ze({file:t,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:b,onCreated:h,onRenamed:x,expandedPaths:g,onToggleFolder:m,gitFileMap:k,gitFolderMap:v,clipboard:D,archive:E,selection:N,selectionTargets:M,dragging:T,onDragStart:R,onDragEnd:A,onDropOn:I,onUnfold:_,onFold:ee,foldRoots:te,touch:ie=!1}){let H=t.type==="folder",[P,z]=n(!1),[G,K]=n(!1),[ne,q]=n(!1),[V,J]=n(!1),re=Array.isArray(t.children)?t.children:[],he=(t.path||"").replace(/^\/+/,""),Q=!H?k?.get(he)||k?.get(t.path):void 0,fe=Q?Gn(Q.status,Q.staged):null,se=H?v?.get(he)||v?.get(t.path):null,xe=Boolean(fe),L=t.ignored===!0,j=g?g.has(t.path):P,ce=t.forceExpanded!==void 0?t.forceExpanded:j;i(()=>{J(!0)},[]),i(()=>{if(H&&g)z(g.has(t.path))},[g,t.path,H]),i(()=>{if(H&&ce&&un(t,G,ne)&&p)q(!0),K(!0),Promise.resolve(p(t.path)).finally(()=>K(!1))},[H,ce,t.children,t.path,p,G,ne]);let ye={path:t.path,name:t.name,kind:H?"folder":"file"},be=N.selected.has(t.path),W=Ft({file:{path:t.path,name:t.name,basePath:l,rootPath:r,repo:c},selection:M,selected:be,archive:E,diff:{staged:Q?.staged||(Q?.status?Q.status[0]!==" "&&Q.status[0]!=="?":!1),status:fe?.charStatus},onOpenFile:f,onActionComplete:b,onCreated:h,onRenamed:x,onUnfold:_&&Ae({type:H?"folder":"file",name:t.name})?()=>_(ye):void 0,onFold:ee&&te?.has(t.path)?()=>ee(te.get(t.path)):void 0,clipboard:D,isFolder:H});le(W.contextMenuRef,W.closeContextMenu);let Y=Dt({enabled:ie,onLongPress:(X,ge)=>W.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),H){let ue=!ce;if(z(ue),t.forceExpanded!==void 0)t.forceExpanded=void 0;if(m?.(t.path,ue),!ue)q(!1)}else if(f)f({...t,root:r,repo:c||"."})},ve=(X)=>{X.preventDefault(),X.stopPropagation(),N.ensureForContext(t.path),W.openContextMenu(X.clientX,X.clientY)},pe=Nt({target:ye,dragging:T,clipboard:D,onDragStart:R,onDragEnd:A,onDropOn:I,onHoverAccept:_});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:!ie,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:H,isOpen:ce,ignored:L,selected:be,gitStatus:fe,folderStatus:se})}),ce&&G&&e("div",{className:"ml-3 border-l border-ink/10 pl-3 py-0.5 text-[10px] text-ink/30",children:"Loading…"}),ce&&!G&&re.length>0&&e("div",{className:"ml-3 border-l border-ink/10 pl-1",children:re.map((X)=>e(ze,{file:X,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:b,onCreated:h,onRenamed:x,expandedPaths:g,onToggleFolder:m,gitFileMap:k,gitFolderMap:v,clipboard:D,archive:E,selection:N,selectionTargets:M,dragging:T,onDragStart:R,onDragEnd:A,onDropOn:I,onUnfold:_,onFold:ee,foldRoots:te,touch:ie},X.path))}),V&&W.contextMenu&&e(Ze,{x:W.contextMenu.x,y:W.contextMenu.y,isFolder:H,hasGitStatus:xe,pasteLabel:W.pasteLabel,chainLabel:W.chainLabel,foldable:W.foldable,busy:W.busy,selectionCount:W.selectionCount,isArchive:W.isArchive,onAction:W.handleAction}),V&&e(ot,{actions:W,file:t,isFolder:H,chainLabel:Ae({type:H?"folder":"file",name:t.name})?t.name:void 0})]})}function Rt({x:t,y:r,pasteLabel:l,busy:c,onAction:p,menuRef:f}){let h=l?104:76,x=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 de(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:x},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(Yi,{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(Ss,{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(Ce,{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:b,onCancel:h,children:x}){return de(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:b,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}),x,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 fn({entries:t,format:r,name:l,destination:c,formats:p,error:f,busy:b,onFormatChange:h,onNameChange:x,onDestinationChange:g,onCancel:m,onSubmit:k}){let v=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:`${v}${D}`,error:f,busy:b,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)=>x(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 mn({archive:t,kindLabel:r,destination:l,error:c,busy:p,onDestinationChange:f,onCancel:b,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:b,onSubmit:(x)=>{x.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:(x)=>f(x.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(fn,{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(mn,{archive:t.extract.archive,kindLabel:Ct($e(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(GA,UA),{symbols:p,total:f,truncated:b,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 x=c.preview,g=(m,k)=>{if(!c.path)return;if(x){let v=Qu(p,k);if(v)qo({path:c.path,...v});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(Ur,{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:b?`${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":x?`${ji(m.kind)} ${m.name}`:`${ji(m.kind)} ${m.name}, line ${m.line}`,title:x?`Jump to ${ji(m.kind).toLowerCase()}`:`${ji(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}),!x&&e("span",{className:"flex-shrink-0 font-mono text-[10px] text-ink/35",children:m.line})]},`${m.line}:${m.kind}:${m.name}`)),b&&e("div",{className:"px-1 py-1 text-[10px] italic text-ink/40",children:Bu(f)})]})})})})]})}function Oe(t,r){return Se(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:Oe(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 Pe(t,r,l){let c=l.path.split("/"),p=c.slice(0,-1).join("/"),f=[...t],b={...r},h=f,x=null;for(let g=0;g<c.length-1;){let m=c.slice(0,g+1).join("/"),k=h.find((M)=>M.type==="folder"&&M.path===m),v=k?null:h.find((M)=>M.type==="folder"&&M.path.startsWith(`${m}/`)&&(p===M.path||p.startsWith(`${M.path}/`))),D=k??v,E=D?b[D.path]??D.children:null;if(D&&!Array.isArray(E))return{nodes:t,cache:r};if(!D){let M=xn(h,b,m);if(M){h=M;let T=h.find((A)=>A.path===m),R=Array.isArray(T?.children)?[...T.children]:[];b[m]=R,h=R,x=m,g+=1;continue}}let N=Array.isArray(E)?[...E]:[];if(D){b[D.path]=N,h=N,x=D.path,g=D.path.split("/").length;continue}h.push({name:c[g],path:m,type:"folder",ignored:!1}),b[m]=N,h=N,x=m,g+=1}if(h.push(l),x!==null)b[x]=Mt(h);return f=Mt(f),{nodes:f,cache:b}}function xn(t,r,l){let c=t.findIndex((x)=>x.type==="folder"&&x.path.startsWith(`${l}/`));if(c===-1)return null;let p=t[c],f=p.path.slice(l.length+1).split("/"),b=r[p.path]??p.children;if(Array.isArray(b))r[p.path]=b;let h={name:f[f.length-1],path:p.path,type:"folder",ignored:p.ignored,...Array.isArray(b)?{children:b}:{}};for(let x=f.length-2;x>=0;x-=1)h={name:f[x],path:`${l}/${f.slice(0,x+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],b=f?.find((m)=>m.path===l);if(f&&b)return{entry:b,nodes:t,cache:{...r,[p]:f.filter((m)=>m.path!==l)}};let x=Object.keys(r).filter((m)=>l.startsWith(`${m}/`)&&r[m].some((k)=>k.path===l)).sort((m,k)=>k.length-m.length)[0];if(!x)return{entry:null,nodes:t,cache:r};let g=r[x];return{entry:g.find((m)=>m.path===l),nodes:t,cache:{...r,[x]:g.filter((m)=>m.path!==l)}}}function zt(t,r,l){let c=!1,p=t.map((f)=>{let b=f.path===r||f.path.startsWith(`${r}/`),h=Array.isArray(f.children)?zt(f.children,r,l):void 0;if(!b&&h===f.children)return f;c=!0;let x=b?f.path===r?l:`${l}${f.path.slice(r.length)}`:f.path,g=b?{...f,path:x,name:Lt(x)}:{...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 b=p===r?l:p.startsWith(`${r}/`)?`${l}${p.slice(r.length)}`:p;c[b]=b===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}`,[b,h]=n({scope:"",files:[],root:""}),[x,g]=n(!1),m=o({}),k=o([]),v=o(f);v.current=f;let D=o(""),E=o(""),N=o(c);N.current=c;let M=(P)=>{let z=new URLSearchParams;if(r)z.set("root",r);if(l&&l!==".")z.set("repo",l);if(P)z.set("path",P);return z.set("t",String(Date.now())),`/api/fs/dir?${z.toString()}`},T=(P,z)=>{D.current=P,E.current=z;let G=Oe(k.current,m.current);return h({scope:P,files:G,root:z}),G},R=async(P)=>{let z=[...N.current];if(z.length===0)return;let G=await Promise.all(z.map(async(V)=>({path:V,read:await Ke(M(V))})));if(v.current!==P)return;let K=[];for(let{path:V,read:J}of G)if(J.status==="ok")m.current[V]=J.files;else if(J.status==="missing")K.push(V);if(K.length===0)return;let ne=new Set(K);for(let V of K)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 P=v.current;g(!0);try{let z=await Ke(M());if(v.current!==P)return;if(z.status!=="ok")return;if(D.current!==P)m.current={};if(k.current=z.files,T(P,z.root),await R(P),v.current!==P)return;T(P,z.root)}finally{if(v.current===P)g(!1)}},I=async(P)=>{let z=v.current,G=await Ke(M(P));if(v.current!==z||G.status!=="ok")return;if(m.current[P]=G.files,D.current===z)T(z,E.current)},_=(P)=>{let z=It(P);if(z.status!=="ok")return;let G=v.current;if(D.current!==G)m.current={};k.current=z.files,T(G,z.root),R(G).then(()=>{if(v.current===G)T(G,z.root)})},ee=()=>{m.current={},k.current=[],D.current="",E.current="",h({scope:"",files:[],root:""})},te=(P)=>{let z=v.current;if(D.current!==z)return null;let G={name:P.path.slice(P.path.lastIndexOf("/")+1),path:P.path,type:P.kind,ignored:!1},K=Pe(k.current,m.current,G);if(K.nodes===k.current)return null;return k.current=K.nodes,m.current=K.cache,T(z,E.current)},ie=(P,z)=>{let G=v.current;if(D.current!==G)return null;let K=$t(k.current,m.current,P);if(!K.entry)return null;m.current=Ot(K.cache,P,z);let ne={...K.entry,path:z,name:z.slice(z.lastIndexOf("/")+1)},q=Pe(K.nodes,m.current,ne);return k.current=q.nodes,m.current=q.cache,T(G,E.current)},H=b.scope===f;return{scope:f,files:H?b.files:[],root:H?b.root:"",isLoading:x,reload:A,loadChildren:I,adoptRoot:_,insertEntry:te,moveEntry:ie,reset:ee}}function Gt({rootPath:t,repo:r,onComplete:l,onError:c}){let p=at(),[f,b]=S("files.clipboard",null),h=ft(f),x=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 M=g.current;if(g.current=!1,N.success){if(M)b(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,M)=>{g.current=M;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]),v=a((N)=>ut(h,x,Me(N.path,N.kind)),[h,x]),D=a((N,M)=>pt(N,Me(M.path,M.kind)),[]),E=a((N,M,T,R)=>{let A=new FormData;A.append("actionType","paste"),A.append("mode",T),A.append("targetPath",M.path),A.append("targetKind",M.kind);for(let I of N)A.append("sourcePath",I.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:v,moveRefusalFor:D,copy:(N)=>{if(N.length===0)return;b({scope:x,entries:N.map(({path:M,name:T,kind:R})=>({path:M,name:T,kind:R})),mode:"copy"})},cut:(N)=>{if(N.length===0)return;b({scope:x,entries:N.map(({path:M,name:T,kind:R})=>({path:M,name:T,kind:R})),mode:"cut"})},duplicate:(N)=>{k({actionType:"duplicate",path:N.path},!1)},move:(N,M)=>{let T=D(N,M);if(T){c(T);return}E([N],M,"cut",Boolean(h?.mode==="cut"&&h.entries.some((R)=>R.path===N.path)))},paste:(N)=>{if(!h)return;let M=v(N);if(M){c(M);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=Le.map((t)=>({...t,available:!0,tool:t.id}));function Kt({rootPath:t,repo:r,onComplete:l}){let c=at(),[p,f]=n(vn),[b,h]=n(null),[x,g]=n(null),[m,k]=n(null),v=o(null),D=o(null);i(()=>{let R=!1;return(async()=>{try{let I=await(await fetch("/api/fs/archive")).json();if(!R&&Array.isArray(I.formats)&&I.formats.length>0)f(I.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=v.current;if(v.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[I,_]of Object.entries(R))A.append(I,_);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((I)=>I.id==="zip"&&I.available)?.id??p.find((I)=>I.available)?.id??"zip";k(null),g(null),h({entries:R.map(({path:I,name:_,kind:ee})=>({path:I,name:_,kind:ee})),format:A,name:De(R,A),destination:yt(R)})},[p]),M=a((R)=>{k(null),h(null),g({archive:R,destination:kt(R.path)})},[]),T=a((R)=>{h((A)=>{if(!A)return A;let I=De(A.entries,A.format),_=A.name===I?De(A.entries,R):A.name;return{...A,format:R,name:_}})},[]);return{formats:p,compress:b,extract:x,error:m,busy:c.state!=="idle",openCompress:N,openExtract:M,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=b;if(!R)return;v.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=x;if(!R)return;v.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),b=Math.max(c,p);return t.slice(f,b+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 v=new Set(k);if(v.has(m))v.delete(m);else v.add(m);return v});return}l(new Set([m]))},[c,t]),b=a((g)=>{l((m)=>{if(m.has(g))return m;return new Set([g])}),p(g)},[]),h=a(()=>{l(new Set),p(null)},[]),x=a(yn,[]);return u(()=>({selected:r,count:r.size,anchor:c,gestureOf:x,applyGesture:f,ensureForContext:b,clear:h}),[r,c,x,f,b,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((x,g)=>{let m=st(g,x);if(m.length===0)return;r((k)=>{if(m.every((D)=>k.has(D)))return k;let v=new Set(k);for(let D of m)v.add(D);return l(Array.from(v)),v})},[r,l]),b=a((x)=>{let g=t.insertEntry(x);if(!g){c();return}f(x.path,g)},[t,c,f]),h=a((x,g)=>{p?.(x,g),r((k)=>{let v=Pt(k,x,g);return l(Array.from(v)),v});let m=t.moveEntry(x,g);if(!m){c();return}f(g,m)},[t,c,f,r,l,p]);return{insertCreated:b,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((x)=>{let g=Ee(x.path,x.name);if(!g)return;p((k)=>{let v=k.scope===t?k.chains:new Map;if(v.get(x.path)?.length===g.length)return k;let E=new Map(v);return E.set(x.path,g),{scope:t,chains:E}});let m=g.slice(0,-1);r((k)=>{if(m.every((D)=>k.has(D)))return k;let v=new Set(k);for(let D of m)v.add(D);return l(Array.from(v)),v})},[t,r,l]),b=a((x)=>{let g=c.scope===t?c.chains.get(x):void 0;if(!g)return;let m=g.slice(0,-1);p((k)=>{if(k.scope!==t)return k;let v=new Map(k.chains);return v.delete(x),{scope:t,chains:v}}),r((k)=>{if(!m.some((D)=>k.has(D)))return k;let v=new Set(k);for(let D of m)v.delete(D);return l(Array.from(v)),v})},[t,c,r,l]),h=a((x,g)=>{let m=c.scope===t?c.chains:null;if(!m)return;let k=new Map,v=[],D=!1;for(let[E,N]of m){if(N.findIndex((A,I)=>A===x&&I>0&&I<N.length-1)!==-1){D=!0;continue}let T=N.map((A)=>A===x?g:A.startsWith(`${x}/`)?`${g}${A.slice(x.length)}`:A),R=T[T.length-1];if(R!==E||T.some((A,I)=>A!==N[I]))D=!0;k.set(R,T),v.push(...T.slice(0,-1))}if(!D)return;p({scope:t,chains:k}),r((E)=>{if(v.every((M)=>E.has(M)))return E;let N=new Set(E);for(let M of v)N.add(M);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:b,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 b=(p.children||[]).map(c).filter((h)=>h!==null);if(f||b.length>0)return{...p,children:f&&b.length===0?p.children:b,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:(b)=>{if(!b.currentTarget.contains(b.relatedTarget))f(!1)},onDragOver:(b)=>{if(!c)return;if(b.preventDefault(),b.dataTransfer)b.dataTransfer.dropEffect="move"},onDrop:(b)=>{if(!c)return;b.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:b}){let[h,x]=S("files.searchQuery",""),[g,m,k]=S("files.expandedPaths",[]),[v,D]=n(()=>new Set(g)),{activeRepo:E,setActiveRepo:N}=ir(c),{repos:M,scanning:T,rescan:R}=or(c,r),{fileMap:A,folderMap:I,refreshGitStatus:_}=Ds(c,E,r),[ee,te]=n(null),ie=o(null);i(()=>{if(!k)return;D((O)=>{let Z=new Set(g);if(O.size===Z.size&&Array.from(Z).every((me)=>O.has(me)))return O;return Z})},[k,g]);let H=Ht({enabled:r,rootPath:c,activeRepo:E,expandedPaths:v,onExpansionPruned:(O)=>{D(O),m(Array.from(O))}});i(()=>{if(!k||!l)return;H.reload()},[f,c,r,E,k,l]);let P=r&&k?TA(H.scope):null,z=we(P);i(()=>{if(z.data)H.adoptRoot(z.data)},[z.data]);let G=(O)=>(_(),H.loadChildren(O)),K=(O,Z)=>{let me=new Set(v);if(Z)me.add(O);else me.delete(O);D(me),m(Array.from(me))},{unfolded:ne,unfold:q,fold:V,rekey:J}=Wt({scope:H.scope,setExpandedPaths:D,setStoredExpandedPaths:m}),re=H.files,he=it(re,ne),Q=Ut(he.nodes,h),fe=je(Q,(O)=>O.forceExpanded!==void 0?O.forceExpanded:v.has(O.path)),se=jt(fe.map((O)=>O.path)),xe=fe.filter((O)=>se.selected.has(O.path)).map(({path:O,name:Z,kind:me})=>({path:O,name:Z,kind:me})),L=(O)=>{if(O===E)return;H.reset(),D(new Set),m([]),se.clear(),N(O)},j=()=>{if(_(),b)b();else H.reload()},{insertCreated:ce,moveRenamed:ye}=_t({listing:H,setExpandedPaths:D,setStoredExpandedPaths:m,reload:j,onMoved:(O,Z)=>J(O,Z)}),be=_u(),{pushToast:W}=Ve(),Y=Gt({rootPath:c,repo:E,onComplete:j,onError:(O)=>W(O,"error")}),ke=Kt({rootPath:c,repo:E,onComplete:j}),ve={path:".",name:".",kind:"folder"},pe=Y.clip&&!Y.refusalFor(ve)?`Paste ${Ne(Y.clip)??"item"}`:null,[X,ge]=n(null),ue=Vt({dragging:X,clipboard:Y,target:ve}),Re=Fe({folderPath:".",rootPath:c,repo:E,onCreated:ce,onOpenCreated:(O)=>p?.({...O,root:c,repo:E})}),[_e,qt]=n(!1);i(()=>qt(!0),[]);let{count:We,clear:Ue}=se;if(i(()=>{if(!l)return;let O=(Z)=>{if(Z.key==="Escape"&&We>0)Ue()};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[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=H.isLoading||z.refreshing;return e("div",{className:`flex flex-col h-full bg-paper ${t}`,children:[e(Be,{rootPath:c,activeRepo:E,repos:M,reposScanning:T,onRefreshRepos:R,onSelectRepo:L,searchQuery:h,onSearchChange:x,onRefresh:j,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:(O)=>{O.preventDefault(),te({x:O.clientX,y:O.clientY})},onDragEnter:ue.onDragEnter,onDragLeave:ue.onDragLeave,onDragOver:ue.onDragOver,onDrop:ue.onDrop,children:H.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((O)=>e(ze,{file:O,rootPath:c,basePath:H.root,repo:E,onLoadChildren:G,onOpenFile:p,onActionComplete:j,onCreated:ce,onRenamed:ye,expandedPaths:v,onToggleFolder:K,gitFileMap:A,gitFolderMap:I,clipboard:Y,archive:ke,selection:se,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},O.path))}),e(Et,{}),_e&&e(Tt,{menu:ee,menuRef:ie,pasteLabel:pe,busy:Y.busy,create:Re,onAction:(O)=>{if(te(null),O==="new_file")Re.openDialog("file");if(O==="new_folder")Re.openDialog("folder");if(O==="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,TA,we,Ds,S,ir,or,s,En,M,Xe,B,ie,ae,Ce,Ge,Yi,Xt,Ji,Gr,C,F,b,ce,Dn,Du,rt,at,UA,GA,jo,qo,Qu,Ve}from"./index-cgzrpvzj.js";import{Eu,ji,Bu,Iu}from"./index-4qwzxj81.js";import{Ss,fr,_u}from"./index-f7jhhqtk.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(rt,{name:t,isFolder:l,isOpen:c,size:12,className:`flex-shrink-0${p?" opacity-40":""}`}),e("span",{className:`truncate min-w-0 flex-1 ${v}`,title:p?`${r} — git-ignored`:void 0,children:t}),x&&e("span",{className:`font-mono text-[10px] font-bold px-1 rounded flex-shrink-0 ${x.colorClass}`,title:`Git: ${x.label}`,children:x.charStatus}),h&&e("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${h.hasDeleted?"bg-error":h.hasModified||h.hasStaged?"bg-info":"bg-success"}`,title:`${h.count} changed file${h.count>1?"s":""}`})]})}var en=28,tn=9,nn=8;function rn(t){let{isFolder:r,hasGitStatus:l,pasteLabel:c,busy:p,chainLabel:f,foldable:x,selectionCount:h,isArchive:v}=t,g=[],m=h>1,k=h===1?"":` ${h} items`;if(m)return g.push({kind:"item",id:"cut",label:`Cut${k}`,icon:e(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(Yi,{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(Ji,{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(Ss,{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(En,{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 on(t){let r=t.filter((c)=>c.kind==="item").length,l=t.length-r;return r*en+l*tn+nn}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=rn({isFolder:l,hasGitStatus:c,pasteLabel:p,busy:h,chainLabel:f,foldable:x,selectionCount:v,isArchive:g}),E=on(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(En,{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 ot({actions:t,file:r,isFolder:l,chainLabel:c}){let p=t.selectionCount;return e(d,{children:[t.showCreateModal&&e(Fe,{folderPath:r.path,kind:t.createKind,value:t.createName,error:t.createError,isLoading:t.busy,onChange:t.setCreateName,onCancel:t.closeCreate,onSubmit:t.submitCreate}),t.showDeleteModal&&e(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(sn);return r.some((l,c)=>l!==t[c])?r:t}function sn(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 it(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=at(),[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=an(p);if(!f)return null;c.push(f)}if(c.length===0)return null;return{scope:r.scope,entries:c,mode:r.mode}}function an(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 ln(t){return $e.find((r)=>r.id===t)}function cn(t){return ln(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=cn(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=at(),[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")Dn(Du(t.basePath,t.path));else if(z==="copy_relative")Dn(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 dn=450,wt=8,pn=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)},dn)},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<pn;return p.current=0,h}}}function un(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&&un(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(ot,{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(Yi,{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(Ss,{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 fn({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 mn({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(fn,{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(mn,{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(GA,UA),{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?`${ji(m.kind)} ${m.name}`:`${ji(m.kind)} ${m.name}, line ${m.line}`,title:v?`Jump to ${ji(m.kind).toLowerCase()}`:`${ji(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)=>hn(l,r)))}function hn(t,r){if(t.type!=="folder")return t;let l=r[t.path];if(!l)return t;return{...t,children:Pe(l,r)}}function gn(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=bn(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 bn(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=gn(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=at(),[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 xn=$e.map((t)=>({...t,available:!0,tool:t.id}));function Kt({rootPath:t,repo:r,onComplete:l}){let c=at(),[p,f]=n(xn),[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 vn(t){if(t.shiftKey)return"range";if(t.metaKey||t.ctrlKey)return"toggle";return"plain"}function yn(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(yn(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(vn,[]);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 kn=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()):kn,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}=Ds(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?TA(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=it(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{t,l,E,p,W,Z,sa,la,wA,Mr,ii,CA,Bs,$t,EA,Bf,ca,oi,_s}from"./index-vw5k8csz.js";import{Oe}from"./index-1a0zkj8h.js";function Ad(e,{edgePathsClass:r="edges edgePaths"}={}){let n=e.insert("g").attr("class","root"),i=n.insert("g").attr("class","clusters"),s=n.insert("g").attr("class",r),o=n.insert("g").attr("class","edgeLabels"),c=n.insert("g").attr("class","nodes");return{clusters:i,edgePaths:s,edgeLabels:o,nodes:c,rootGroups:n}}t(Ad,"createLayoutElementGroups");async function L(e,r,n){if(r.label){let{shapeSvg:i,bbox:s}=await Z(e,n===void 0?r:{...r,width:n});r.labelBBox={width:s.width,height:s.height},i.remove()}else r.labelBBox={width:0,height:0}}t(L,"measureGroupLabel");async function gd(e,r,n){let i=await la(e,r,n),s=i.node()?.getBBox()??{width:0,height:0};return r.width=s.width,r.height=s.height,i}t(gd,"insertMeasuredNode");function D(e,r,n){let i=e,s=new Set;while(i){if(i.dir)return i.dir;if(!i.parentId||s.has(i.parentId))break;s.add(i.parentId),i=r.get(i.parentId)}return n}t(D,"resolveNodeDir");async function S(e,r,n={}){let i=new Oe({multigraph:!0,compound:!0}),s=[...r.edges],o=p(),c=Ad(e),{edgeLabels:f,nodes:a}=c,d=new Map,m=new Map(r.nodes.map((u)=>[u.id,u])),y=r.direction,b=e.node()!=null;await Promise.all(r.nodes.map(async(u)=>{if(u.isGroup){if(b){let h=n.unwrapGroupLabels&&u.labelType!=="markdown";await L(a,u,h?Number.POSITIVE_INFINITY:void 0)}i.setNode(u.id,{...u})}else{if(b){let h=await gd(a,u,{config:o,dir:D(u,m,y)});d.set(u.id,h)}i.setNode(u.id,{...u})}}));for(let u of s){if(b&&Bf(u))await ca(f,u);if(i.setEdge(u.start,u.end,{...u},u.id),!r.edges.some((v)=>v.id===u.id))r.edges.push(u)}if(globalThis.mermaidCaptureSizes){let{captureNodeSizes:u}=await import("./sizeCapture-INFHLROL-q85r06j6.js");u(e,r)}return{graph:i,groups:c,nodeElements:d}}t(S,"createGraphWithElements");var Ae=new Map,g=new Map,P=new Map,V=t(()=>{g.clear(),P.clear(),Ae.clear()},"clear"),w=t((e,r)=>{let n=g.get(r)||[];return l.trace("In isDescendant",r," ",e," = ",n.includes(e)),n.includes(e)},"isDescendant"),Y=t((e,r)=>{let n=g.get(r)||[];if(l.info("Descendants of ",r," is ",n),l.info("Edge is ",e),e.v===r||e.w===r)return!1;if(!n)return l.debug("Tilt, ",r,",not in descendants"),!1;return n.includes(e.v)||w(e.v,r)||w(e.w,r)||n.includes(e.w)},"edgeInCluster"),k=t((e,r,n,i)=>{l.debug("Copying children of ",e,"root",i,"data",r.node(e),i);let s=r.children(e)||[];if(e!==i)s.push(e);l.debug("Copying (nodes) clusterId",e,"nodes",s),s.forEach((o)=>{if(r.children(o).length>0)k(o,r,n,i);else{let c=r.node(o);if(l.info("cp ",o," to ",i," with parent ",e),n.setNode(o,c),i!==r.parent(o))l.debug("Setting parent",o,r.parent(o)),n.setParent(o,r.parent(o));if(e!==i&&o!==e)l.debug("Setting parent",o,e),n.setParent(o,e);else l.info("In copy ",e,"root",i,"data",r.node(e),i),l.debug("Not Setting parent for node=",o,"cluster!==rootId",e!==i,"node!==clusterId",o!==e);let f=r.edges(o);l.debug("Copying Edges",f),f.forEach((a)=>{l.info("Edge",a);let d=r.edge(a.v,a.w,a.name);l.info("Edge data",d,i);try{if(Y(a,i))l.info("Copying as ",a.v,a.w,d,a.name),n.setEdge(a.v,a.w,d,a.name),l.info("newGraph edges ",n.edges(),n.edge(n.edges()[0]));else l.info("Skipping copy of edge ",a.v,"-->",a.w," rootId: ",i," clusterId:",e)}catch(m){l.error(m)}})}l.debug("Removing node",o),r.removeNode(o)})},"copy"),T=t((e,r)=>{let n=r.children(e),i=[...n];for(let s of n)P.set(s,e),i=[...i,...T(s,r)];return i},"extractDescendants"),q=t((e,r,n)=>{let i=e.edges().filter((a)=>a.v===r||a.w===r),s=e.edges().filter((a)=>a.v===n||a.w===n),o=i.map((a)=>({v:a.v===r?n:a.v,w:a.w===r?r:a.w})),c=s.map((a)=>({v:a.v,w:a.w}));return o.filter((a)=>c.some((d)=>a.v===d.v&&a.w===d.w))},"findCommonEdges"),ks=t((e,r,n)=>{let i=r.children(e);if(l.trace("Searching children of id ",e,i),i.length<1)return e;let s;for(let o of i){let c=ks(o,r,n),f=q(r,n,c);if(c)if(f.length>0)s=c;else return c}return s},"findNonClusterChild"),N=t((e)=>{if(!Ae.has(e))return e;if(!Ae.get(e).externalConnections)return e;if(Ae.has(e))return Ae.get(e).id;return e},"getAnchorId"),uA=t((e,r)=>{if(!e||r>10){l.debug("Opting out, no graph ");return}else l.debug("Opting in, graph ");e.nodes().forEach(function(n){if(e.children(n).length>0)l.debug("Cluster identified",n," Replacement id in edges: ",ks(n,e,n)),g.set(n,T(n,e)),Ae.set(n,{id:ks(n,e,n),clusterData:e.node(n)})}),e.nodes().forEach(function(n){let i=e.children(n),s=e.edges();if(i.length>0)l.debug("Cluster identified",n,g),s.forEach((o)=>{let c=w(o.v,n),f=w(o.w,n);if(c^f)l.debug("Edge: ",o," leaves cluster ",n),l.debug("Descendants of XXX ",n,": ",g.get(n)),Ae.get(n).externalConnections=!0});else l.debug("Not a cluster ",n,g)});for(let n of Ae.keys()){let i=Ae.get(n).id,s=e.parent(i);if(s!==n&&Ae.has(s)&&!Ae.get(s).externalConnections)Ae.get(n).id=s;let o=e.edges().some((c)=>c.v===n);if(i&&Ae.get(n)?.externalConnections&&o&&M(e,i,n)){let c=K(e,n,e.parent(i));if(c)Ae.get(n).id=c}}e.edges().forEach(function(n){let i=e.edge(n);l.debug("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(n)),l.debug("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(e.edge(n)));let{v:s,w:o}=n;if(l.debug("Fix XXX",Ae,"ids:",n.v,n.w,"Translating: ",Ae.get(n.v)," --- ",Ae.get(n.w)),Ae.get(n.v)||Ae.get(n.w)){if(l.debug("Fixing and trying - removing XXX",n.v,n.w,n.name),s=N(n.v),o=N(n.w),e.removeEdge(n.v,n.w,n.name),s!==n.v){let c=e.parent(s);Ae.get(c).externalConnections=!0,i.fromCluster=n.v}if(o!==n.w){let c=e.parent(o);Ae.get(c).externalConnections=!0,i.toCluster=n.w}l.debug("Fix Replacing with XXX",s,o,n.name),e.setEdge(s,o,i,n.name)}}),R(e,0),l.trace(Ae)},"adjustClustersAndEdges"),R=t((e,r)=>{if(r>10){l.error("Bailing out");return}let n=e.nodes(),i=!1;for(let s of n){let o=e.children(s);i=i||o.length>0}if(!i){l.debug("Done, no node has children",e.nodes());return}l.debug("Nodes = ",n,r);for(let s of n)if(l.debug("Extracting node",s,Ae,Ae.has(s)&&!Ae.get(s).externalConnections,!e.parent(s),e.node(s),e.children("D")," Depth ",r),!Ae.has(s))l.debug("Not a cluster",s,r);else if(!Ae.get(s).externalConnections&&e.children(s)&&e.children(s).length>0){l.debug("Cluster without external connections, without a parent and with children",s,r);let c=e.graph().rankdir==="TB"?"LR":"TB";if(Ae.get(s)?.clusterData?.dir)c=Ae.get(s).clusterData.dir,l.debug("Fixing dir",Ae.get(s).clusterData.dir,c);let f=new Oe({multigraph:!0,compound:!0}).setGraph({rankdir:c,nodesep:50,ranksep:50,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}});k(s,e,f,s),e.setNode(s,{clusterNode:!0,id:s,clusterData:Ae.get(s).clusterData,label:Ae.get(s).label,graph:f})}else l.debug("Cluster ** ",s," **not meeting the criteria !externalConnections:",!Ae.get(s).externalConnections," no parent: ",!e.parent(s)," children ",e.children(s)&&e.children(s).length>0,e.children("D"),r),l.debug(Ae);n=e.nodes(),l.debug("New list of nodes",n);for(let s of n){let o=e.node(s);if(l.debug(" Now next level",s,o),o?.clusterNode)R(o.graph,r+1)}},"extractor"),B=t((e,r)=>{if(r.length===0)return[];let n=Object.assign([],r);return r.forEach((i)=>{let s=e.children(i),o=B(e,s);n=[...n,...o]}),n},"sorter"),hd=t((e)=>B(e,e.children()),"sortNodesByHierarchy"),M=t((e,r,n)=>{let i=e.parent(r);while(i&&i!==n){let s=Ae.get(i);if(s&&!s.externalConnections)return!0;i=e.parent(i)}return!1},"isNodeInExtractableCluster"),K=t((e,r,n)=>{let i=e.children(r)??[];for(let s of i){if(s===n||w(s,n))continue;let o=ks(s,e,r);if(!o)continue;if(!M(e,o,r))return o}return null},"findSafeAnchorNode");function Pi({prepareLayout:e,measureLayout:r,runLayoutCore:n,paintLayout:i,afterPaint:s,paintOptions:o}){let c=r??bd;return t(async function(a,d,m,y){let b=d.select("g");(m?.insertMarkers??_s)(b,a.markers,a.type,a.diagramId),X();let u={element:b,helpers:m,options:y};u.preparedLayout=await e?.(a,u);let h=await c(a,u),v=await n(a,u),C={...u,measure:h};if(i)await i(a,C,v);else await G(a,C,o);await s?.(a,C,v)},"render")}t(Pi,"createCommonLayoutRenderer");function X(){wA(),EA(),CA(),V()}t(X,"clearLayoutRenderState");async function bd(e,{element:r},n){return await S(r,e,n)}t(bd,"defaultMeasureLayout");async function G(e,r,n={}){let{measure:i}=r,{groups:s}=i;for(let c of n.getNodes?.(e,r)??e.nodes){if(n.skipNode?.(c,r))continue;await _(s,c,r,n)}let o=O(e.nodes);for(let c of e.edges){if(F(c,n))continue;await j(s,c,o,e,n,r)}}t(G,"paintLayoutData");async function _(e,r,n,i){if(r.clusterNode)Mr(r);else if(A(r,n,i))await ii(e.clusters,r);else Mr(r)}t(_,"paintLayoutNode");function A(e,r,n){return e.isGroup===!0&&(n.isCluster?.(e,r)??!0)}t(A,"shouldPaintAsCluster");function O(e){let r=new Map;for(let n of e)if(n?.id)r.set(n.id,n);return r}t(O,"buildNodeLookup");function F(e,r){return e.isLayoutOnly||Boolean(r.skipEdge?.(e))}t(F,"shouldSkipPaintEdge");async function j(e,r,n,i,s,o){let c=oi(e.edgePaths,{...r},s.clusterDb??new Map,i.type,x(r.start,r,n,o,s),x(r.end,r,n,o,s),i.diagramId,H(r,s));if(Bf(r)){if(!Bs.has(r.id))await ca(e.edgeLabels,r);z(r,c)}}t(j,"paintLayoutEdge");function x(e,r,n,i,s){return s.getEdgeNode?.(e,r,i)??(e?n.get(e)??{}:{})}t(x,"getRenderedNode");function H(e,r){return typeof r.skipIntersect==="function"?r.skipIntersect(e):r.skipIntersect??!1}t(H,"shouldSkipIntersect");function z(e,r){let n=r?.updatedPath??r?.originalPath,i=E(),{subGraphTitleTotalMargin:s}=sa({flowchart:i.flowchart??{}});if(e.label){let o=Bs.get(e.id),{x:c,y:f}=e;if(n){let a=W.calcLabelPosition(n);if(l.debug("Moving label "+e.label+" from (",c,",",f,") to (",a.x,",",a.y,") abc88"),r?.updatedPath)c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f+s/2})`)}if(e?.startLabelLeft){let o=$t.get(e.id).startLeft,c=e?.x,f=e?.y;if(n){let a=W.calcTerminalLabelPosition(e.arrowTypeStart?10:0,"start_left",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}if(e.startLabelRight){let o=$t.get(e.id).startRight,{x:c,y:f}=e;if(n){let a=W.calcTerminalLabelPosition(e.arrowTypeStart?10:0,"start_right",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}if(e.endLabelLeft){let o=$t.get(e.id).endLeft,{x:c,y:f}=e;if(n){let a=W.calcTerminalLabelPosition(e.arrowTypeEnd?10:0,"end_left",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}if(e.endLabelRight){let o=$t.get(e.id).endRight,{x:c,y:f}=e;if(n){let a=W.calcTerminalLabelPosition(e.arrowTypeEnd?10:0,"end_right",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}}t(z,"positionRenderedEdgeLabel");
|
|
1
|
+
import{t,l,E,p,W,Z,la,ca,wA,Pr,ii,CA,Bs,$t,EA,Bf,ua,oi,_s}from"./index-fta1y9pc.js";import{Oe}from"./index-sd66wv26.js";function Ad(e,{edgePathsClass:r="edges edgePaths"}={}){let n=e.insert("g").attr("class","root"),i=n.insert("g").attr("class","clusters"),s=n.insert("g").attr("class",r),o=n.insert("g").attr("class","edgeLabels"),c=n.insert("g").attr("class","nodes");return{clusters:i,edgePaths:s,edgeLabels:o,nodes:c,rootGroups:n}}t(Ad,"createLayoutElementGroups");async function L(e,r,n){if(r.label){let{shapeSvg:i,bbox:s}=await Z(e,n===void 0?r:{...r,width:n});r.labelBBox={width:s.width,height:s.height},i.remove()}else r.labelBBox={width:0,height:0}}t(L,"measureGroupLabel");async function gd(e,r,n){let i=await ca(e,r,n),s=i.node()?.getBBox()??{width:0,height:0};return r.width=s.width,r.height=s.height,i}t(gd,"insertMeasuredNode");function D(e,r,n){let i=e,s=new Set;while(i){if(i.dir)return i.dir;if(!i.parentId||s.has(i.parentId))break;s.add(i.parentId),i=r.get(i.parentId)}return n}t(D,"resolveNodeDir");async function S(e,r,n={}){let i=new Oe({multigraph:!0,compound:!0}),s=[...r.edges],o=p(),c=Ad(e),{edgeLabels:f,nodes:a}=c,d=new Map,m=new Map(r.nodes.map((u)=>[u.id,u])),y=r.direction,b=e.node()!=null;await Promise.all(r.nodes.map(async(u)=>{if(u.isGroup){if(b){let h=n.unwrapGroupLabels&&u.labelType!=="markdown";await L(a,u,h?Number.POSITIVE_INFINITY:void 0)}i.setNode(u.id,{...u})}else{if(b){let h=await gd(a,u,{config:o,dir:D(u,m,y)});d.set(u.id,h)}i.setNode(u.id,{...u})}}));for(let u of s){if(b&&Bf(u))await ua(f,u);if(i.setEdge(u.start,u.end,{...u},u.id),!r.edges.some((v)=>v.id===u.id))r.edges.push(u)}if(globalThis.mermaidCaptureSizes){let{captureNodeSizes:u}=await import("./sizeCapture-INFHLROL-03gy196j.js");u(e,r)}return{graph:i,groups:c,nodeElements:d}}t(S,"createGraphWithElements");var Ae=new Map,g=new Map,P=new Map,V=t(()=>{g.clear(),P.clear(),Ae.clear()},"clear"),w=t((e,r)=>{let n=g.get(r)||[];return l.trace("In isDescendant",r," ",e," = ",n.includes(e)),n.includes(e)},"isDescendant"),Y=t((e,r)=>{let n=g.get(r)||[];if(l.info("Descendants of ",r," is ",n),l.info("Edge is ",e),e.v===r||e.w===r)return!1;if(!n)return l.debug("Tilt, ",r,",not in descendants"),!1;return n.includes(e.v)||w(e.v,r)||w(e.w,r)||n.includes(e.w)},"edgeInCluster"),k=t((e,r,n,i)=>{l.debug("Copying children of ",e,"root",i,"data",r.node(e),i);let s=r.children(e)||[];if(e!==i)s.push(e);l.debug("Copying (nodes) clusterId",e,"nodes",s),s.forEach((o)=>{if(r.children(o).length>0)k(o,r,n,i);else{let c=r.node(o);if(l.info("cp ",o," to ",i," with parent ",e),n.setNode(o,c),i!==r.parent(o))l.debug("Setting parent",o,r.parent(o)),n.setParent(o,r.parent(o));if(e!==i&&o!==e)l.debug("Setting parent",o,e),n.setParent(o,e);else l.info("In copy ",e,"root",i,"data",r.node(e),i),l.debug("Not Setting parent for node=",o,"cluster!==rootId",e!==i,"node!==clusterId",o!==e);let f=r.edges(o);l.debug("Copying Edges",f),f.forEach((a)=>{l.info("Edge",a);let d=r.edge(a.v,a.w,a.name);l.info("Edge data",d,i);try{if(Y(a,i))l.info("Copying as ",a.v,a.w,d,a.name),n.setEdge(a.v,a.w,d,a.name),l.info("newGraph edges ",n.edges(),n.edge(n.edges()[0]));else l.info("Skipping copy of edge ",a.v,"-->",a.w," rootId: ",i," clusterId:",e)}catch(m){l.error(m)}})}l.debug("Removing node",o),r.removeNode(o)})},"copy"),T=t((e,r)=>{let n=r.children(e),i=[...n];for(let s of n)P.set(s,e),i=[...i,...T(s,r)];return i},"extractDescendants"),q=t((e,r,n)=>{let i=e.edges().filter((a)=>a.v===r||a.w===r),s=e.edges().filter((a)=>a.v===n||a.w===n),o=i.map((a)=>({v:a.v===r?n:a.v,w:a.w===r?r:a.w})),c=s.map((a)=>({v:a.v,w:a.w}));return o.filter((a)=>c.some((d)=>a.v===d.v&&a.w===d.w))},"findCommonEdges"),ks=t((e,r,n)=>{let i=r.children(e);if(l.trace("Searching children of id ",e,i),i.length<1)return e;let s;for(let o of i){let c=ks(o,r,n),f=q(r,n,c);if(c)if(f.length>0)s=c;else return c}return s},"findNonClusterChild"),N=t((e)=>{if(!Ae.has(e))return e;if(!Ae.get(e).externalConnections)return e;if(Ae.has(e))return Ae.get(e).id;return e},"getAnchorId"),uA=t((e,r)=>{if(!e||r>10){l.debug("Opting out, no graph ");return}else l.debug("Opting in, graph ");e.nodes().forEach(function(n){if(e.children(n).length>0)l.debug("Cluster identified",n," Replacement id in edges: ",ks(n,e,n)),g.set(n,T(n,e)),Ae.set(n,{id:ks(n,e,n),clusterData:e.node(n)})}),e.nodes().forEach(function(n){let i=e.children(n),s=e.edges();if(i.length>0)l.debug("Cluster identified",n,g),s.forEach((o)=>{let c=w(o.v,n),f=w(o.w,n);if(c^f)l.debug("Edge: ",o," leaves cluster ",n),l.debug("Descendants of XXX ",n,": ",g.get(n)),Ae.get(n).externalConnections=!0});else l.debug("Not a cluster ",n,g)});for(let n of Ae.keys()){let i=Ae.get(n).id,s=e.parent(i);if(s!==n&&Ae.has(s)&&!Ae.get(s).externalConnections)Ae.get(n).id=s;let o=e.edges().some((c)=>c.v===n);if(i&&Ae.get(n)?.externalConnections&&o&&M(e,i,n)){let c=K(e,n,e.parent(i));if(c)Ae.get(n).id=c}}e.edges().forEach(function(n){let i=e.edge(n);l.debug("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(n)),l.debug("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(e.edge(n)));let{v:s,w:o}=n;if(l.debug("Fix XXX",Ae,"ids:",n.v,n.w,"Translating: ",Ae.get(n.v)," --- ",Ae.get(n.w)),Ae.get(n.v)||Ae.get(n.w)){if(l.debug("Fixing and trying - removing XXX",n.v,n.w,n.name),s=N(n.v),o=N(n.w),e.removeEdge(n.v,n.w,n.name),s!==n.v){let c=e.parent(s);Ae.get(c).externalConnections=!0,i.fromCluster=n.v}if(o!==n.w){let c=e.parent(o);Ae.get(c).externalConnections=!0,i.toCluster=n.w}l.debug("Fix Replacing with XXX",s,o,n.name),e.setEdge(s,o,i,n.name)}}),R(e,0),l.trace(Ae)},"adjustClustersAndEdges"),R=t((e,r)=>{if(r>10){l.error("Bailing out");return}let n=e.nodes(),i=!1;for(let s of n){let o=e.children(s);i=i||o.length>0}if(!i){l.debug("Done, no node has children",e.nodes());return}l.debug("Nodes = ",n,r);for(let s of n)if(l.debug("Extracting node",s,Ae,Ae.has(s)&&!Ae.get(s).externalConnections,!e.parent(s),e.node(s),e.children("D")," Depth ",r),!Ae.has(s))l.debug("Not a cluster",s,r);else if(!Ae.get(s).externalConnections&&e.children(s)&&e.children(s).length>0){l.debug("Cluster without external connections, without a parent and with children",s,r);let c=e.graph().rankdir==="TB"?"LR":"TB";if(Ae.get(s)?.clusterData?.dir)c=Ae.get(s).clusterData.dir,l.debug("Fixing dir",Ae.get(s).clusterData.dir,c);let f=new Oe({multigraph:!0,compound:!0}).setGraph({rankdir:c,nodesep:50,ranksep:50,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}});k(s,e,f,s),e.setNode(s,{clusterNode:!0,id:s,clusterData:Ae.get(s).clusterData,label:Ae.get(s).label,graph:f})}else l.debug("Cluster ** ",s," **not meeting the criteria !externalConnections:",!Ae.get(s).externalConnections," no parent: ",!e.parent(s)," children ",e.children(s)&&e.children(s).length>0,e.children("D"),r),l.debug(Ae);n=e.nodes(),l.debug("New list of nodes",n);for(let s of n){let o=e.node(s);if(l.debug(" Now next level",s,o),o?.clusterNode)R(o.graph,r+1)}},"extractor"),B=t((e,r)=>{if(r.length===0)return[];let n=Object.assign([],r);return r.forEach((i)=>{let s=e.children(i),o=B(e,s);n=[...n,...o]}),n},"sorter"),hd=t((e)=>B(e,e.children()),"sortNodesByHierarchy"),M=t((e,r,n)=>{let i=e.parent(r);while(i&&i!==n){let s=Ae.get(i);if(s&&!s.externalConnections)return!0;i=e.parent(i)}return!1},"isNodeInExtractableCluster"),K=t((e,r,n)=>{let i=e.children(r)??[];for(let s of i){if(s===n||w(s,n))continue;let o=ks(s,e,r);if(!o)continue;if(!M(e,o,r))return o}return null},"findSafeAnchorNode");function Pi({prepareLayout:e,measureLayout:r,runLayoutCore:n,paintLayout:i,afterPaint:s,paintOptions:o}){let c=r??bd;return t(async function(a,d,m,y){let b=d.select("g");(m?.insertMarkers??_s)(b,a.markers,a.type,a.diagramId),X();let u={element:b,helpers:m,options:y};u.preparedLayout=await e?.(a,u);let h=await c(a,u),v=await n(a,u),C={...u,measure:h};if(i)await i(a,C,v);else await G(a,C,o);await s?.(a,C,v)},"render")}t(Pi,"createCommonLayoutRenderer");function X(){wA(),EA(),CA(),V()}t(X,"clearLayoutRenderState");async function bd(e,{element:r},n){return await S(r,e,n)}t(bd,"defaultMeasureLayout");async function G(e,r,n={}){let{measure:i}=r,{groups:s}=i;for(let c of n.getNodes?.(e,r)??e.nodes){if(n.skipNode?.(c,r))continue;await _(s,c,r,n)}let o=O(e.nodes);for(let c of e.edges){if(F(c,n))continue;await j(s,c,o,e,n,r)}}t(G,"paintLayoutData");async function _(e,r,n,i){if(r.clusterNode)Pr(r);else if(A(r,n,i))await ii(e.clusters,r);else Pr(r)}t(_,"paintLayoutNode");function A(e,r,n){return e.isGroup===!0&&(n.isCluster?.(e,r)??!0)}t(A,"shouldPaintAsCluster");function O(e){let r=new Map;for(let n of e)if(n?.id)r.set(n.id,n);return r}t(O,"buildNodeLookup");function F(e,r){return e.isLayoutOnly||Boolean(r.skipEdge?.(e))}t(F,"shouldSkipPaintEdge");async function j(e,r,n,i,s,o){let c=oi(e.edgePaths,{...r},s.clusterDb??new Map,i.type,x(r.start,r,n,o,s),x(r.end,r,n,o,s),i.diagramId,H(r,s));if(Bf(r)){if(!Bs.has(r.id))await ua(e.edgeLabels,r);z(r,c)}}t(j,"paintLayoutEdge");function x(e,r,n,i,s){return s.getEdgeNode?.(e,r,i)??(e?n.get(e)??{}:{})}t(x,"getRenderedNode");function H(e,r){return typeof r.skipIntersect==="function"?r.skipIntersect(e):r.skipIntersect??!1}t(H,"shouldSkipIntersect");function z(e,r){let n=r?.updatedPath??r?.originalPath,i=E(),{subGraphTitleTotalMargin:s}=la({flowchart:i.flowchart??{}});if(e.label){let o=Bs.get(e.id),{x:c,y:f}=e;if(n){let a=W.calcLabelPosition(n);if(l.debug("Moving label "+e.label+" from (",c,",",f,") to (",a.x,",",a.y,") abc88"),r?.updatedPath)c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f+s/2})`)}if(e?.startLabelLeft){let o=$t.get(e.id).startLeft,c=e?.x,f=e?.y;if(n){let a=W.calcTerminalLabelPosition(e.arrowTypeStart?10:0,"start_left",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}if(e.startLabelRight){let o=$t.get(e.id).startRight,{x:c,y:f}=e;if(n){let a=W.calcTerminalLabelPosition(e.arrowTypeStart?10:0,"start_right",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}if(e.endLabelLeft){let o=$t.get(e.id).endLeft,{x:c,y:f}=e;if(n){let a=W.calcTerminalLabelPosition(e.arrowTypeEnd?10:0,"end_left",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}if(e.endLabelRight){let o=$t.get(e.id).endRight,{x:c,y:f}=e;if(n){let a=W.calcTerminalLabelPosition(e.arrowTypeEnd?10:0,"end_right",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}}t(z,"positionRenderedEdgeLabel");
|
|
2
2
|
export{Ad,gd,Ae,ks,uA,hd,Pi,bd};
|