@kabmo-labs/kabmo 0.39.1 → 0.41.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 +364 -363
- package/dist/client/static/js/{CsvGrid-7synegzg.js → CsvGrid-60njj97j.js} +2 -2
- package/dist/client/static/js/{DocxView-v5d9n5yw.js → DocxView-rsv0j46a.js} +5 -5
- package/dist/client/static/js/{DrawioView-ww7y98tt.js → DrawioView-n2g5df3a.js} +2 -2
- package/dist/client/static/js/ImageView-t330jx6y.js +1 -0
- package/dist/client/static/js/LayoutWrapper-qp6nsw65.js +2 -0
- package/dist/client/static/js/{Modal-qj39shgb.js → Modal-sbya4ahp.js} +17 -17
- package/dist/client/static/js/{PdfView-t9v4datp.js → PdfView-1r7a0qkp.js} +1 -1
- package/dist/client/static/js/SessionsView-yqs5m8tj.js +1 -0
- package/dist/client/static/js/{SheetView-6zkxbjd4.js → SheetView-bt5pp042.js} +24 -24
- package/dist/client/static/js/{SvgPreview-7rt2p1y1.js → SvgPreview-vfmqgmrx.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-888zn5zg.js → abnfDiagram-O67JEVCF-8k5hk1yx.js} +1 -1
- package/dist/client/static/js/architecture-7GRP2DOG-1wqga929.js +1 -0
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-b04e26rb.js → architectureDiagram-NJMV4G6O-7jcb7fgy.js} +3 -3
- package/dist/client/static/js/{astro-4ybhkc9b.js → astro-0rh34hha.js} +1 -1
- package/dist/client/static/js/bash-vv2ysp0a.js +1 -0
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-32ph2m52.js → blockDiagram-BEXU5L5S-04sbtdth.js} +5 -5
- package/dist/client/static/js/c-67jyc7sg.js +1 -0
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-hwnaa333.js → c4Diagram-YGBWAQC7-vwac9za0.js} +2 -2
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-2kg7dqeb.js → classDiagram-v2-NBCMYWYE-18cc0bsb.js} +5 -5
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-tj2sbtyv.js → cose-bilkent-JH36ORCC-dk683zvp.js} +1 -1
- package/dist/client/static/js/cpp-crfbnwv8.js +1 -0
- package/dist/client/static/js/css-2re5mbea.js +1 -0
- package/dist/client/static/js/css-983fbv00.js +1 -0
- package/dist/client/static/js/cynefin-OW5HDTMX-j2dpdgkh.js +1 -0
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-wx2y8dhm.js → cynefinDiagram-VND7K2PF-m2sx8d8s.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-5v3rzdxd.js → dagre-6A5THRUB-qf3pr59p.js} +2 -2
- package/dist/client/static/js/{diagram-22UHCM2B-7er2jwy1.js → diagram-22UHCM2B-twnz23mt.js} +11 -11
- package/dist/client/static/js/{diagram-3UASUU5V-2b7nmdha.js → diagram-3UASUU5V-417bas6t.js} +1 -1
- package/dist/client/static/js/{diagram-ATOU4E4O-yf61ftn0.js → diagram-ATOU4E4O-n63cpdnx.js} +3 -3
- package/dist/client/static/js/{diagram-CDSNMT55-cn3rs9xn.js → diagram-CDSNMT55-v86p14dd.js} +3 -3
- package/dist/client/static/js/{diagram-MLGK6HIB-7kvtsj6c.js → diagram-MLGK6HIB-7a0h1hs3.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-g3zg3r5e.js → diagram-MPIPVDR6-w75bftmd.js} +2 -2
- package/dist/client/static/js/{dockerfile-f9j396wm.js → dockerfile-g5qbaeq3.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-ft02nzne.js → ebnfDiagram-ZINNZB2B-vdzm3tsv.js} +1 -1
- package/dist/client/static/js/{elixir-v9bbxsgg.js → elixir-gpez1k9m.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-87fvkn2k.js → elk-276RUBZZ-2fsbb484.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-gh9mp6j8.js → erDiagram-OPXOYQCR-vnkztq7d.js} +5 -5
- package/dist/client/static/js/{erlang-55r0skxa.js → erlang-jqqa3ehb.js} +1 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-xjvjawd3.js +1 -0
- package/dist/client/static/js/flowDiagram-KWPJA3E3-j21f2bfg.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-227xs61z.js → ganttDiagram-FUAMR5RP-pbvcch52.js} +2 -2
- package/dist/client/static/js/{ghostty-web-2gt2tp72.js → ghostty-web-22pdvhta.js} +4 -4
- package/dist/client/static/js/gitGraph-4MIJSDKK-r0zbk95f.js +1 -0
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-4671gdym.js → gitGraphDiagram-X574FWY7-dkvktvzr.js} +2 -2
- package/dist/client/static/js/graphql-npbd9fdx.js +1 -0
- package/dist/client/static/js/html-1cpe2xc8.js +1 -0
- package/dist/client/static/js/{index-enmh3w27.js → index-0c6vpk89.js} +2 -2
- package/dist/client/static/js/{index-35mh9kbs.js → index-0xaz2eyv.js} +3 -3
- package/dist/client/static/js/{index-668chrpq.js → index-1sw00wm0.js} +1 -1
- package/dist/client/static/js/index-2z9wrb46.js +2 -0
- package/dist/client/static/js/{index-qbnd827h.js → index-3rymer2w.js} +1 -1
- package/dist/client/static/js/{index-f1nqk6z6.js → index-4jk8ngjg.js} +2 -2
- package/dist/client/static/js/index-55hq7tnj.js +1 -0
- package/dist/client/static/js/{index-8egjccbq.js → index-6fx2t6y7.js} +52 -52
- package/dist/client/static/js/{index-8xasfxf3.js → index-7fwppdkn.js} +1 -1
- package/dist/client/static/js/{index-28a5kf88.js → index-7w3gqw2b.js} +1 -1
- package/dist/client/static/js/{index-c1be3rva.js → index-9dnkfpx4.js} +2 -2
- package/dist/client/static/js/{index-s80x8d58.js → index-9fnzcg2x.js} +2 -2
- package/dist/client/static/js/{index-h8rr48px.js → index-a4ed3mks.js} +4 -4
- package/dist/client/static/js/{index-j2g39xq7.js → index-ae91g8ka.js} +5 -5
- package/dist/client/static/js/{index-xrp2zv8z.js → index-agdbjh5k.js} +2 -2
- package/dist/client/static/js/{index-2rs03vfy.js → index-ajjq0b8y.js} +2 -2
- package/dist/client/static/js/{index-xfr6r539.js → index-amawahyh.js} +2 -2
- package/dist/client/static/js/{index-y5ymgp20.js → index-b6cyn4hr.js} +50 -50
- package/dist/client/static/js/index-c6kx7s6a.js +2 -0
- package/dist/client/static/js/{index-k7sdsmgv.js → index-ce4vytm6.js} +2 -2
- package/dist/client/static/js/{index-b08hx4tw.js → index-cytks03p.js} +2 -2
- package/dist/client/static/js/{index-cfnxda13.js → index-djv15k5s.js} +2 -2
- package/dist/client/static/js/{index-kkfbd1db.js → index-ds6a2cx7.js} +5 -5
- package/dist/client/static/js/{index-tmnnafht.js → index-e6qjfcz9.js} +1 -1
- package/dist/client/static/js/{index-442mbhwb.js → index-e7yf273s.js} +2 -2
- package/dist/client/static/js/{index-f73v86a3.js → index-efn233xp.js} +4 -4
- package/dist/client/static/js/index-esx3zwnt.js +1 -0
- package/dist/client/static/js/{index-d3prrt2q.js → index-f8pq132s.js} +1 -1
- package/dist/client/static/js/index-fbbp5cwj.js +2 -0
- package/dist/client/static/js/{index-drjtwfp5.js → index-fg965t62.js} +2 -2
- package/dist/client/static/js/{index-xnk1500f.js → index-g1cggqgx.js} +12 -12
- package/dist/client/static/js/index-ghsdzs4m.js +1 -0
- package/dist/client/static/js/{index-4wvtar0v.js → index-gn92c6hp.js} +2 -2
- package/dist/client/static/js/{index-4c2zcvem.js → index-gs7ytgdw.js} +180 -180
- package/dist/client/static/js/{index-q0bph5x0.js → index-haaz8t7e.js} +2 -2
- package/dist/client/static/js/{index-t6gznaxm.js → index-hz177dr2.js} +2 -2
- package/dist/client/static/js/{index-7qc2avfy.js → index-j5ram1ve.js} +2 -2
- package/dist/client/static/js/{index-cst843zs.css → index-jqs23cc7.css} +1 -1
- package/dist/client/static/js/{index-y91j4t1q.js → index-ne131hmw.js} +2 -2
- package/dist/client/static/js/{index-1sgad84m.js → index-ngk9h0v9.js} +2 -2
- package/dist/client/static/js/{index-4wtr5wjp.js → index-ntcqyqd5.js} +2 -2
- package/dist/client/static/js/{index-m847wafq.js → index-pbsm2vw7.js} +2 -2
- package/dist/client/static/js/{index-vb3srfyc.js → index-pfbyfab5.js} +2 -2
- package/dist/client/static/js/{index-qsrw5c67.js → index-pn91shfp.js} +2 -2
- package/dist/client/static/js/{index-6rs8e8ng.js → index-qjsy6p86.js} +1 -1
- package/dist/client/static/js/{index-fjnkzk12.js → index-qsw5edtk.js} +5 -5
- package/dist/client/static/js/{index-72289dgx.js → index-rc8wrs2a.js} +2 -2
- package/dist/client/static/js/{index-w0rbyw47.js → index-rdqn92tc.js} +2 -2
- package/dist/client/static/js/{index-phm1zb8m.js → index-re1xz433.js} +1 -1
- package/dist/client/static/js/{index-mtadrbxt.js → index-rebnv57p.js} +2 -2
- package/dist/client/static/js/{index-9d6x1f3t.js → index-s78n0dtv.js} +2 -2
- package/dist/client/static/js/{index-c36pag9y.js → index-sj4y8kj2.js} +2 -2
- package/dist/client/static/js/{index-87qandgr.js → index-tgper3yy.js} +2 -2
- package/dist/client/static/js/index-x2kb1kx5.js +3 -0
- package/dist/client/static/js/{index-0j518hqm.js → index-xf36nmbm.js} +2 -2
- package/dist/client/static/js/{index-hdd8nqz8.js → index-xfa5hswh.js} +1 -1
- package/dist/client/static/js/{index-9gepbvdt.js → index-yq9vnd1y.js} +2 -2
- package/dist/client/static/js/{index-y3qxrs90.js → index-yzg9mbsv.js} +2 -2
- package/dist/client/static/js/{index-wgvysmnr.js → index-zfykeg7x.js} +10 -10
- package/dist/client/static/js/{index-rj81xrvw.js → index-zye9309h.js} +2 -2
- package/dist/client/static/js/info-A6RAGUB7-a8xap43w.js +1 -0
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-k1jnhhbp.js → infoDiagram-VRGFBTTK-mh6yks62.js} +1 -1
- package/dist/client/static/js/ini-df5bw23e.js +1 -0
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-ar94x2gr.js → ishikawaDiagram-OU5B5YK6-hnfqppnv.js} +2 -2
- package/dist/client/static/js/java-8j33rj1p.js +1 -0
- package/dist/client/static/js/javascript-zegm06a1.js +1 -0
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-ntfp0w54.js → journeyDiagram-ZHPQQLJL-s4nv1f3q.js} +3 -3
- package/dist/client/static/js/json-g5ggnd94.js +1 -0
- package/dist/client/static/js/jsx-f6p72qpc.js +1 -0
- package/dist/client/static/js/{julia-jhe2vd4f.js → julia-yre4bxb9.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-q5rsr6j3.js → kanban-definition-PNTS6WVX-t8kbfefp.js} +8 -8
- package/dist/client/static/js/lua-bahx6qze.js +1 -0
- package/dist/client/static/js/markdown-9dhg1fax.js +1 -0
- package/dist/client/static/js/{mermaid.core-0gafsqrm.js → mermaid.core-0784021p.js} +7 -7
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-jgz6nyhk.js → mindmap-definition-NLK3R4M7-swkkze8c.js} +8 -8
- package/dist/client/static/js/one-dark-pro-h5tmw145.js +1 -0
- package/dist/client/static/js/one-light-x7vj1pxr.js +1 -0
- package/dist/client/static/js/packet-AYTQ26CC-b5bvg6v1.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-b3e9ma2c.js → pegDiagram-GJSIUBJH-jqayzh7z.js} +1 -1
- package/dist/client/static/js/{perl-qhj6tk7k.js → perl-weeskn1v.js} +1 -1
- package/dist/client/static/js/{php-arycc4w7.js → php-vf3045p9.js} +1 -1
- package/dist/client/static/js/pie-WAS4IAKB-77ee73zg.js +1 -0
- package/dist/client/static/js/{pieDiagram-5QR66LMP-66mn2qnt.js → pieDiagram-5QR66LMP-w03a65ky.js} +2 -2
- package/dist/client/static/js/properties-49mfnee4.js +1 -0
- package/dist/client/static/js/python-qb69wp1s.js +1 -0
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-n7warg0e.js → quadrantDiagram-O4NWA36T-2j7sfa9s.js} +3 -3
- package/dist/client/static/js/r-s3mf2tch.js +1 -0
- package/dist/client/static/js/radar-RG4KPBEZ-cp79xtvb.js +1 -0
- package/dist/client/static/js/railroad-74A4TZTK-dcpgqhcb.js +1 -0
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-qasqv686.js +1 -0
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-e46908rd.js +1 -0
- package/dist/client/static/js/railroad-peg-WCYAUIDC-7009t6bk.js +1 -0
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-k8j43rxj.js → railroadDiagram-XR7U4H2S-jtkkgy34.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-ef2v7nyq.js → requirementDiagram-PLB6GJNP-t85ckjdb.js} +3 -3
- package/dist/client/static/js/{ruby-fb6zzevm.js → ruby-1a2ryzy6.js} +1 -1
- package/dist/client/static/js/{rust-jvkbr060.js → rust-736r0f0v.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-3njbd1yd.js → sankeyDiagram-IPEJSGJF-5pfkw8ne.js} +3 -3
- package/dist/client/static/js/{sass-fzs6a0kr.js → sass-tq4vw7hd.js} +1 -1
- package/dist/client/static/js/{scss-gdb52d0c.js → scss-x7ddw6gb.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-k2wqc0qt.js → sequenceDiagram-PO4LG4MO-55vs9zv5.js} +7 -7
- package/dist/client/static/js/{sizeCapture-INFHLROL-cpnd12ee.js → sizeCapture-INFHLROL-pzqqd7f4.js} +1 -1
- package/dist/client/static/js/sql-aczp05f2.js +1 -0
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-1ydpxaeg.js → stateDiagram-v2-GCMORJYK-6nhrph8n.js} +3 -3
- package/dist/client/static/js/{svelte-8s3k6qjd.js → svelte-0hv6pak2.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-4md43da2.js → swimlanes-2SLR337P-6tcnxfbv.js} +1 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-7xrkrkpa.js +8 -0
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-sp32bf3e.js → timeline-definition-EJHVYXUP-1dz46nt5.js} +4 -4
- package/dist/client/static/js/treeView-Q6P3EWNA-tpn62q8j.js +1 -0
- package/dist/client/static/js/treemap-WGGIJYW6-w910f1g4.js +1 -0
- package/dist/client/static/js/tsx-s1shkfg9.js +1 -0
- package/dist/client/static/js/typescript-htx9v6bf.js +1 -0
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-p2ssettn.js → usecaseDiagram-POWQR4AR-b3jfveq6.js} +28 -28
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-ejqq8b82.js → vennDiagram-UO4OBE2U-dnc3jqvp.js} +3 -3
- package/dist/client/static/js/{vue-k3f3chre.js → vue-zccj3qa5.js} +1 -1
- package/dist/client/static/js/wardley-WFR3VGLG-pt9tq808.js +1 -0
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-tkk79rsn.js → wardleyDiagram-VNRHLVJA-466m8400.js} +3 -3
- package/dist/client/static/js/xml-wr1dxav5.js +1 -0
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-zhgrsqpb.js → xychartDiagram-PMCCYNJV-kryrpqp1.js} +3 -3
- package/dist/client/static/js/yaml-0y9fdskg.js +1 -0
- package/marketplace/plugins/command-runner/package.json +2 -2
- package/marketplace/plugins/command-runner/src/panel/Custom.test.tsx +1 -0
- package/marketplace/plugins/command-runner/src/panel/Groups.test.tsx +10 -0
- package/marketplace/plugins/command-runner/src/panel/Groups.tsx +24 -3
- package/marketplace/plugins/command-runner/src/panel/index.tsx +1 -0
- package/marketplace/plugins/command-runner/src/protocol.ts +10 -0
- package/marketplace/plugins/command-runner/src/server/discovery.test.ts +30 -0
- package/marketplace/plugins/command-runner/src/server/scan.ts +16 -3
- package/package.json +1 -1
- package/src/client/components/common/header-controls/MoreMenu.tsx +24 -14
- package/src/client/components/common/header-controls/index.test.tsx +22 -0
- package/src/client/components/common/header-controls/index.tsx +8 -2
- package/src/client/components/layout/desktop-layout/LeftColumn.tsx +7 -0
- package/src/client/components/layout/session-sidebar/SessionsView.tsx +2 -1
- package/src/client/components/layout/session-sidebar/about-modal/index.test.tsx +1 -1
- package/src/client/components/mobile/LayoutWrapper.tsx +19 -2
- package/src/client/components/mobile/RightSidebar.tsx +49 -1
- package/src/client/components/mobile/SessionSidebar.tsx +29 -1
- package/src/client/components/mobile/header-titlebar.test.tsx +17 -0
- package/src/client/components/mobile/mobile-main-view/Header.test.tsx +43 -0
- package/src/client/components/mobile/mobile-main-view/Header.tsx +30 -0
- package/src/client/components/mobile/mobile-session-sidebar/Dock.tsx +5 -1
- package/src/client/components/mobile/mobile-session-sidebar/Header.tsx +12 -1
- package/src/client/components/mobile/panel-chips.test.tsx +13 -0
- package/src/client/components/mobile/panel-chips.tsx +9 -2
- package/src/client/components/settings/categories/connect-settings/DeviceTable.test.tsx +92 -0
- package/src/client/components/settings/categories/connect-settings/DeviceTable.tsx +22 -3
- package/src/client/components/workspace/chat-timeline/MessageList.test.ts +19 -19
- package/src/client/components/workspace/git-panel/commit-modal/Header.test.tsx +21 -0
- package/src/client/components/workspace/git-panel/commit-modal/Header.tsx +13 -9
- package/src/client/components/workspace/terminal-panel/focus-target.test.ts +121 -0
- package/src/client/components/workspace/terminal-panel/focus-target.ts +54 -0
- package/src/client/components/workspace/terminal-panel/index.tsx +7 -1
- package/src/client/components/workspace/terminal-panel/instance.ts +82 -0
- package/src/client/components/workspace/terminal-panel/mount.ts +22 -63
- package/src/client/components/workspace/terminal-panel/soft-keyboard.ts +29 -0
- package/src/client/hooks/commands/use-command-runtime.ts +15 -0
- package/src/client/hooks/ui/touch-device.ts +8 -3
- package/src/client/hooks/ui/updates/check-request.ts +41 -0
- package/src/client/hooks/ui/updates/index.ts +13 -5
- package/src/client/hooks/ui/visibility-menu-trigger.test.ts +155 -0
- package/src/client/hooks/ui/visibility-menu-trigger.ts +85 -0
- package/src/client/hooks/workspace/panel-visibility-menu.ts +50 -0
- package/src/client/lib/native/run-command.test.ts +95 -0
- package/src/client/lib/native/run-command.ts +52 -0
- package/src/client/lib/router/open-session.test.ts +26 -1
- package/src/client/lib/router/open-session.ts +21 -0
- package/src/client/lib/ui/soft-keyboard.test.ts +103 -0
- package/src/client/lib/ui/soft-keyboard.ts +90 -0
- package/src/client/main.tsx +9 -0
- package/src/server/lib/auth/guard.ts +8 -2
- package/src/server/lib/changes/capture-shell.test.ts +253 -0
- package/src/server/lib/changes/capture-targets.test.ts +83 -0
- package/src/server/lib/changes/capture-targets.ts +51 -0
- package/src/server/lib/changes/capture-write.server.ts +2 -2
- package/src/server/lib/changes/capture.server.ts +14 -29
- package/src/server/lib/changes/capture.test.ts +69 -149
- package/src/server/lib/changes/patch-paths.ts +37 -0
- package/src/server/lib/connect/devices.server.test.ts +70 -0
- package/src/server/lib/connect/devices.server.ts +43 -1
- package/src/server/lib/connect/last-connect.gate.test.ts +52 -0
- package/src/server/routes/connect/devices.ts +5 -4
- package/src/shared/lib/commands/catalog.test.ts +36 -0
- package/src/shared/lib/commands/catalog.ts +16 -0
- package/src/shared/lib/connect/types.ts +1 -0
- package/src/shared/lib/updates/popup-state.ts +11 -0
- package/dist/client/static/js/ImageView-t3rkypzs.js +0 -1
- package/dist/client/static/js/LayoutWrapper-th2pd4yt.js +0 -2
- package/dist/client/static/js/SessionsView-yqy0a1xg.js +0 -1
- package/dist/client/static/js/architecture-7GRP2DOG-y0zb4vqa.js +0 -1
- package/dist/client/static/js/bash-k6p3y3pr.js +0 -1
- package/dist/client/static/js/c-ve09y19q.js +0 -1
- package/dist/client/static/js/cpp-vhqp7bcy.js +0 -1
- package/dist/client/static/js/css-77mvf0ca.js +0 -1
- package/dist/client/static/js/css-tys2rrny.js +0 -1
- package/dist/client/static/js/cynefin-OW5HDTMX-nt1ed192.js +0 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-v4edaxx7.js +0 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-6gc6gd1d.js +0 -1
- package/dist/client/static/js/gitGraph-4MIJSDKK-adzhec96.js +0 -1
- package/dist/client/static/js/graphql-g97hycb3.js +0 -1
- package/dist/client/static/js/html-2syect3n.js +0 -1
- package/dist/client/static/js/index-1jeyjqkh.js +0 -2
- package/dist/client/static/js/index-4ry8kz8h.js +0 -3
- package/dist/client/static/js/index-fjqp03xe.js +0 -2
- package/dist/client/static/js/index-fs3pbqwn.js +0 -1
- package/dist/client/static/js/index-jze0zg3z.js +0 -2
- package/dist/client/static/js/index-w0xvdda9.js +0 -1
- package/dist/client/static/js/index-wfcgqjzr.js +0 -1
- package/dist/client/static/js/info-A6RAGUB7-2ye26vqn.js +0 -1
- package/dist/client/static/js/ini-7ffv28px.js +0 -1
- package/dist/client/static/js/java-4x5yky4a.js +0 -1
- package/dist/client/static/js/javascript-4kw2j9t3.js +0 -1
- package/dist/client/static/js/json-h3kwpty2.js +0 -1
- package/dist/client/static/js/jsx-jk20f0dr.js +0 -1
- package/dist/client/static/js/lua-k02dpxq8.js +0 -1
- package/dist/client/static/js/markdown-fhhg7ms6.js +0 -1
- package/dist/client/static/js/one-dark-pro-n0as47q7.js +0 -1
- package/dist/client/static/js/one-light-05nw3mzj.js +0 -1
- package/dist/client/static/js/packet-AYTQ26CC-b0j3te0q.js +0 -1
- package/dist/client/static/js/pie-WAS4IAKB-28qq62fn.js +0 -1
- package/dist/client/static/js/properties-qhvcxc13.js +0 -1
- package/dist/client/static/js/python-3qsrs510.js +0 -1
- package/dist/client/static/js/r-z2ng7mza.js +0 -1
- package/dist/client/static/js/radar-RG4KPBEZ-fyrcbpyd.js +0 -1
- package/dist/client/static/js/railroad-74A4TZTK-9s62qncd.js +0 -1
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-f7yjmhrk.js +0 -1
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-sfrw8gkz.js +0 -1
- package/dist/client/static/js/railroad-peg-WCYAUIDC-4mm4cern.js +0 -1
- package/dist/client/static/js/sql-ypk53ntb.js +0 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-d48g5gjf.js +0 -8
- package/dist/client/static/js/treeView-Q6P3EWNA-a5vgg4gz.js +0 -1
- package/dist/client/static/js/treemap-WGGIJYW6-ctqhajgg.js +0 -1
- package/dist/client/static/js/tsx-zy7hb2hw.js +0 -1
- package/dist/client/static/js/typescript-2hr53c8j.js +0 -1
- package/dist/client/static/js/wardley-WFR3VGLG-ns7e0fqf.js +0 -1
- package/dist/client/static/js/xml-p4742r9b.js +0 -1
- package/dist/client/static/js/yaml-qbckg671.js +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{d,n,o,W,i,u,a,$e,oe,e,Wn,Ze,ze,S,s,E,m,Xt,_,f,B,re,tt,fe,Ct,qe,ti,sn,Vr,D,O,b,Jr,Ve,pe,fr,J,it,js,Bo,qs,Hs,_o,MA,YA,Bm,el,Ne,ae,Vt,T,ye,ui,Jm,ig}from"./index-4c2zcvem.js";import{vt,mi,Vc,Yc,Zc,cs,fi,bd}from"./index-jze0zg3z.js";import{Tc,ld,cd,dg,pg,Dc,tr,os,Qc,Nc,Rc,Fc,Lc,is,Oo,ss,pi,Pc,ll,cl,Oc,$c,zc,Uc,Gc,jc,qc,Hc,Wc}from"./index-xnk1500f.js";import{Da,Qa,Ai}from"./index-vb3srfyc.js";var fn={name:"git-commit-vertical",size:24,node:[["path",{d:"M12 3v6",key:"1holv5"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M12 15v6",key:"a9ows0"}]]},Le=s(fn);var bn={name:"maximize",size:24,node:[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]},xe=s(bn);var gn={name:"minimize",size:24,node:[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]]},we=s(gn);var hn={name:"save-all",size:24,node:[["path",{d:"M10 2v3a1 1 0 0 0 1 1h5",key:"1xspal"}],["path",{d:"M18 18v-6a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6",key:"1ra60u"}],["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"M8 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9.172a2 2 0 0 1 1.414.586l2.828 2.828A2 2 0 0 1 22 6.828V16a2 2 0 0 1-2.01 2z",key:"1yve0x"}]]},ke=s(hn);var ie=new Set,Be=new Set,Fe=new Set;function He(){Fe=new Set(ie);for(let t of[...Be])t()}function We(t){let r=new Set(t);if(r.size===ie.size){let l=!0;for(let c of r)if(!ie.has(c)){l=!1;break}if(l)return}ie.clear();for(let l of r)ie.add(l);He()}function Ke(t){let r=new Set(t),l=!1;for(let c of[...ie])if(!r.has(c))ie.delete(c),l=!0;if(l)He()}function Ue(t){return ie.has(t)}function _e(){return ie.size>0}function vn(t){return Be.add(t),()=>{Be.delete(t)}}var yn=vn;function Ge(){return $e(yn,()=>Fe)}function Xe({x:t,y:r,rows:l,onAction:c,onClose:p}){let h=i(null),[v,g]=n({left:t,top:r});return W(()=>{let y=h.current;if(!y)return;let{width:w,height:x}=y.getBoundingClientRect();g({left:Math.min(t,Math.max(0,window.innerWidth-w-8)),top:Math.min(r,Math.max(0,window.innerHeight-x-8))})},[t,r,l.length]),oe(e("div",{className:"fixed inset-0 z-[70]",onClick:p,onContextMenu:(y)=>{y.preventDefault(),p()},children:e("div",{ref:h,role:"menu","aria-label":"Tab actions",className:"glass-popover absolute w-52 bg-paper border border-ink/15 rounded-md shadow-xl py-1 text-xs text-ink",style:{left:`${v.left}px`,top:`${v.top}px`},onClick:(y)=>y.stopPropagation(),children:l.map((y)=>e("button",{type:"button",role:"menuitem",onClick:()=>{c(y.action),p()},className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 transition-colors cursor-pointer",children:y.label},y.action))})}),document.body)}var ge={rightFileId:null,fraction:0.5};function Se(t,r,l){if(t===null)return!1;if(t===r)return!1;return l.includes(t)}function Ye(t,r){for(let l=r.length-1;l>=0;l-=1){let c=r[l];if(c!==t)return c}return null}function je(t,r){if(t.rightFileId===null)return t;if(t.rightFileId!==r)return t;return{...t,rightFileId:null}}function ue(t){if(!Number.isFinite(t))return ge.fraction;return Math.max(0.2,Math.min(0.8,t))}function Je(t,r){if(typeof t!=="object"||t===null)return ge;let l=t,c=typeof l.fraction==="number"?ue(l.fraction):ge.fraction,p=typeof l.rightFileId==="string"||typeof l.rightFileId==="number"?l.rightFileId:null;if(p===null||!r.includes(p))return{rightFileId:null,fraction:c};return{rightFileId:p,fraction:c}}function Qe({tab:t,openedFiles:r,dirtyIds:l,reopenable:c,activeFileId:p,splitRightFileId:h}){let v=r.filter((x)=>x.id!==t.id),g=r.filter((x)=>!l.has(x.id)),y=r.map((x)=>x.id);return[{action:"split-right",label:"Split right",enabled:Se(t.id,p,y)},{action:"unsplit",label:"Unsplit",enabled:h!==null},{action:"close",label:"Close",enabled:!0},{action:"close-others",label:"Close others",enabled:v.length>0},{action:"close-all",label:"Close all",enabled:r.length>0},{action:"close-saved",label:"Close saved",enabled:g.some((x)=>x.id!==t.id)},{action:"copy-path",label:"Copy path",enabled:Boolean(t.path)},{action:"reveal-in-files",label:"Reveal in Files",enabled:Boolean(t.path)&&!t.isDiff},{action:"reopen-closed",label:"Reopen closed tab",enabled:c>0}].filter((x)=>x.enabled)}function nt({openedFiles:t,activeFileId:r,onSelectFile:l,onCloseFile:c,missingIds:p,onCopyPath:h,onRevealInFiles:v,onReopenClosed:g,reopenableCount:y,onSplitTo:w,onUnsplit:x,splitRightFileId:k=null}){let I=Ge(),C=i(null),M=i(null),[z,V]=n(5),[H,F]=n(!1),[L,U]=n(null);pe(M,()=>F(!1)),o(()=>{let N=new ResizeObserver((R)=>{for(let P of R){let Q=P.contentRect.width,X=Math.max(1,Math.floor((Q-60)/150));V(X)}});if(C.current)N.observe(C.current);return()=>N.disconnect()},[]);let A=Ye(r,t.map((N)=>N.id)),G=[],Z=[];if(t.length<=z)G=t;else{let N=t.findIndex((P)=>P.id===r),R=new Set;if(N!==-1&&r!==null)R.add(r);for(let P=t.length-1;P>=0;P--){if(R.size>=z)break;R.add(t[P].id)}G=t.filter((P)=>R.has(P.id)),Z=t.filter((P)=>!R.has(P.id))}return e("div",{className:"flex bg-ink/10 w-full relative border-b border-ink/10",ref:C,children:[e("div",{className:"flex overflow-hidden",children:G.map((N)=>{let R=N.id===r,P=Boolean(N.isDiff),Q=P?Wn(N.diffStatus||"M",N.diffStaged):null,X=Boolean(p?.has(N.id));return e("div",{onClick:()=>l(N.id),onContextMenu:(j)=>{j.preventDefault(),U({tab:N,x:j.clientX,y:j.clientY})},className:`flex items-center space-x-1.5 px-3 py-1.5 cursor-pointer border-r border-ink/10 min-w-[120px] max-w-[210px] group ${R?"bg-paper border-t-2 border-t-ink text-ink":"bg-transparent border-t-2 border-t-transparent text-ink/60 hover:bg-paper/50"}`,title:X?`${N.path} — file no longer exists`:N.path,children:[P?e(ti,{size:14,className:R?"text-info flex-shrink-0":"text-info/70 flex-shrink-0"}):e(it,{name:N.name,size:14,className:`flex-shrink-0${R||X?"":" opacity-60"}${X?" text-error":""}`}),e("span",{className:`text-xs font-mono truncate flex-1${X?" text-error line-through":""}`,children:N.name}),Q&&e("span",{className:`px-1 text-[10px] font-mono font-bold rounded ${Q.badgeBgClass}`,children:Q.charStatus}),e(et,{dirty:I.has(N.id),active:R,label:`Close ${N.name}`,onClose:()=>c(N.id)})]},N.id)})}),L?e(Xe,{x:L.x,y:L.y,rows:Qe({tab:L.tab,openedFiles:t,dirtyIds:I,reopenable:y?.()??0,activeFileId:r,splitRightFileId:k}),onAction:(N)=>{let R=L.tab;switch(N){case"close":c(R.id);return;case"close-others":for(let P of[...t].reverse())if(P.id!==R.id)c(P.id);l(R.id);return;case"close-all":for(let P of[...t].reverse())c(P.id);return;case"close-saved":for(let P of[...t].reverse())if(!I.has(P.id))c(P.id);return;case"copy-path":h?.(R);return;case"reveal-in-files":v?.(R);return;case"reopen-closed":g?.();return;case"split-right":w?.(R.id);return;case"unsplit":x?.();return}},onClose:()=>U(null)}):null,e("div",{className:"ml-auto flex items-center",children:e("button",{type:"button",onClick:()=>k!==null?x?.():w?.(A),disabled:k===null&&A===null,"aria-pressed":k!==null,"aria-label":"Split editor",title:k!==null?"Close the split pane (the tab stays open)":A===null?"Open another file to split the editor":"Split the editor and show the newest other file",className:`p-1.5 mx-1 rounded transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-default ${k!==null?"bg-ink/10 text-ink":"text-ink/60 hover:bg-ink/10"}`,children:e(Vr,{size:14})})}),Z.length>0&&e("div",{className:"relative flex items-center bg-ink/10",ref:M,children:[e("button",{className:`p-1.5 mx-1 rounded hover:bg-ink/10 text-ink/60 ${H?"bg-ink/10 text-ink":""}`,onClick:()=>F(!H),title:"More open files",children:e(B,{size:14})}),H&&e("div",{className:"glass-popover absolute right-0 top-full mt-1 w-52 bg-paper border border-ink/10 rounded shadow-lg z-50 py-1",children:[e("div",{className:"px-3 py-1 text-[10px] uppercase font-mono text-ink/40 border-b border-ink/10 mb-1",children:"Older Tabs"}),Z.map((N)=>{let R=Boolean(p?.has(N.id));return e("div",{onClick:()=>{l(N.id),F(!1)},className:"flex items-center space-x-2 px-3 py-1.5 hover:bg-ink/5 cursor-pointer group",children:[N.isDiff?e(ti,{size:14,className:"text-info/80"}):e(it,{name:N.name,size:14,className:R?"text-error":"opacity-60"}),e("span",{className:`text-xs font-mono truncate flex-1 ${R?"text-error line-through":"text-ink/80"}`,children:N.name}),e(et,{dirty:I.has(N.id),active:!1,label:`Close ${N.name}`,onClose:()=>{if(c(N.id),Z.length===1)F(!1)}})]},N.id)})]})]})]})}function et({dirty:t,active:r,label:l,onClose:c}){return e("div",{role:"button",tabIndex:-1,"aria-label":l,title:t?`${l} — unsaved changes`:l,className:`p-0.5 rounded hover:bg-ink/10 touch-visible ${r||t?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:(p)=>{p.stopPropagation(),c()},children:t?e("span",{className:"block w-2 h-2 rounded-full bg-current mx-0.5","data-tab-dirty":"","aria-hidden":"true"}):e(b,{size:12})})}function xn(t){if(t===null)return null;let r=new Date(t);if(Number.isNaN(r.getTime()))return null;return r.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Ce({diskMtimeMs:t,fileName:r,onReload:l,onKeepMine:c}){let p=xn(t);return e("div",{className:"flex items-start gap-2 px-3 py-2 border-b border-warning/30 bg-warning/10 text-[11px] text-ink flex-shrink-0",role:"alert","data-conflict-strip":"",children:[e(_,{size:13,className:"text-warning flex-shrink-0 mt-0.5"}),e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"font-medium",children:[e("span",{className:"font-mono",children:r})," changed on disk",p?e("span",{className:"text-ink/60",children:[" at ",p]}):null,"."]}),e("div",{className:"text-ink/60 mt-0.5",children:"Your save was refused so nothing was overwritten."})]}),e("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e("button",{type:"button",onClick:l,className:"px-2 py-1 rounded border border-ink/20 hover:bg-ink/5 transition-colors cursor-pointer",title:"Discard my changes and take the file from disk",children:"Reload"}),e("button",{type:"button",onClick:c,className:"px-2 py-1 rounded border border-warning/50 text-warning hover:bg-warning/10 transition-colors cursor-pointer",title:"Write my buffer over the file on disk",children:"Keep mine"})]})]})}function ot(t){if(t.byteViewer)return[];return[{id:"save",pinned:!0,actions:[{label:"Save file",icon:ke,onSelect:t.onSave,disabled:t.saveDisabled}],children:t.saveButton},{id:"save-as",actions:[{label:"Save as…",icon:ke,onSelect:t.onSaveAs}],children:e("button",{type:"button",onClick:t.onSaveAs,className:`${tr} hover:bg-ink/5 hover:text-ink`,title:"Save the buffer to a new file","aria-label":"Save as",children:e(ke,{size:14})})}]}function rt(t){if(!t.hasReview)return[];let r=t.isReviewing?"Exit review mode":"Review this document";return[{id:"review",actions:[{label:r,icon:sn,onSelect:t.onToggleReview,active:t.isReviewing}],children:e(os,{label:r,pressed:t.isReviewing,title:t.isReviewing?"Review mode is on — click a block to judge it":"Review: click blocks to mark them good or needing work",onClick:t.onToggleReview,children:e(sn,{size:14})})}]}function at(t){if(!t.hasPreview)return[];return[{id:"preview",actions:[{label:t.previewLabel,icon:t.isPreview?Ct:qe,onSelect:t.onTogglePreview,active:t.isPreview}],children:e(os,{label:t.previewLabel,pressed:t.isPreview,onClick:t.onTogglePreview,children:t.isPreview?e(Ct,{size:14}):e(qe,{size:14})})}]}function st(t){let r=[];if(r.push(...ot(t),...rt(t),...at(t)),!t.byteViewer)r.push({id:"find",actions:[{label:t.findLabel,icon:O,onSelect:t.onToggleFind,active:t.findOpen}],children:e(os,{label:t.findLabel,pressed:t.findOpen,title:`${t.findLabel} (Ctrl+F)`,onClick:t.onToggleFind,children:e(O,{size:14})})}),r.push({id:"wrap",actions:[{label:t.wordWrapLabel,icon:Xt,onSelect:t.onToggleWordWrap,active:t.wordWrap}],children:e(os,{label:t.wordWrapLabel,pressed:t.wordWrap,onClick:t.onToggleWordWrap,children:e(Xt,{size:14})})}),r.push({id:"blame",actions:[{label:t.blameInline?"Hide line blame":"Show line blame",icon:Le,onSelect:t.onToggleBlameInline,active:t.blameInline}],children:e(os,{label:t.blameInline?"Hide line blame":"Show line blame",pressed:t.blameInline,title:"Who last changed each block, from git (hover a line for the commit)",onClick:t.onToggleBlameInline,children:e(Le,{size:14})})}),r.push({id:"zoom",actions:[{label:"Decrease font size",icon:Qa,onSelect:t.onZoomOut},{label:"Increase font size",icon:Da,onSelect:t.onZoomIn}],children:e(d,{children:[e("button",{type:"button",onClick:t.onZoomOut,className:`${tr} hover:bg-ink/5 hover:text-ink`,title:"Decrease font size","aria-label":"Decrease font size",children:e(Qa,{size:14})}),e("button",{type:"button",onClick:t.onZoomIn,className:`${tr} hover:bg-ink/5 hover:text-ink`,title:"Increase font size","aria-label":"Increase font size",children:e(Da,{size:14})})]})}),r.push({id:"reload",actions:[{label:"Reload from disk",icon:D,onSelect:t.onReload,disabled:!t.canReload}],children:e("button",{type:"button",onClick:t.onReload,disabled:!t.canReload||t.refreshing,"aria-busy":t.refreshing,className:`${tr} hover:bg-ink/5 hover:text-ink`,title:!t.canReload?"Nothing to reload — this tab has no file on disk":t.reloadDiscardsEdits?"Discard my changes and reload from disk":"Reload from disk","aria-label":"Reload from disk",children:e(D,{size:14,className:t.refreshing?"animate-spin":void 0})})});return r.push({id:"copy",actions:[{label:t.copyLabel,icon:re,onSelect:t.onCopy},{label:"Download file",icon:fe,onSelect:t.onDownload}],children:e(d,{children:[e("button",{type:"button",onClick:t.onCopy,className:`${tr} hover:bg-ink/5 hover:text-ink`,title:t.copyLabel,"aria-label":t.copyLabel,children:t.copied?e(re,{size:14,className:"text-success"}):e(re,{size:14})}),e("button",{type:"button",onClick:t.onDownload,className:`${tr} hover:bg-ink/5 hover:text-ink`,title:"Download file","aria-label":"Download file",children:e(fe,{size:14})})]})}),r.push({id:"view-modes",pinned:!0,actions:t.viewModeActions,children:t.viewModeButtons}),r.push({id:"maximize",pinned:!0,actions:[{label:t.maximizeLabel,icon:t.isMaximized?we:xe,onSelect:t.onToggleMaximize,active:t.isMaximized}],children:t.maximizeButton}),r}function lt({path:t,saveStatus:r,wordWrap:l,hasPreview:c,isPreview:p,hasReview:h,isReviewing:v,copied:g,byteViewer:y=!1,saveDisabled:w=!1,unsupported:x=!1,handleMissing:k=!1,readOnly:I=!1,isMaximized:C=!1,findOpen:M=!1,onToggleFind:z,onSave:V,onTogglePreview:H,onToggleReview:F,onToggleWordWrap:L,onZoomIn:U,onZoomOut:A,onCopy:G,onDownload:Z,onReload:N,canReload:R,refreshing:P=!1,reloadDiscardsEdits:Q,onSaveAs:X,onToggleMaximize:j}){let ne=w?I?"Read-only — this file was opened from the phone, not from a workspace":k?"Cannot save — reopen the file from the system to restore write access":x?"Nothing to save — this file cannot be opened as a document":"Nothing to save — this file could not be read":r==="needs-permission"?"Click Save to allow writing this file":r==="saving"?"Saving…":r==="error"?"Save failed — the file on disk was not changed":"Save file (Ctrl+S)",ce=e("button",{type:"button",onClick:V,disabled:w||r==="saving",className:`${tr} hover:bg-ink/5`,title:ne,"aria-label":ne,children:r==="saving"?e(vt,{size:14,className:"text-warning animate-pulse"}):r==="saved"?e(f,{size:14,className:"text-success"}):r==="error"?e(E,{size:14,className:"text-error"}):r==="needs-permission"?e(vt,{size:14,className:"text-warning"}):e(vt,{size:14,className:"hover:text-ink"})}),ee=C?"Exit full screen":"Full screen",te=e("button",{type:"button",onClick:j,className:`${tr} hover:bg-ink/5 hover:text-ink ${C?"text-ink":""}`,title:ee,"aria-label":ee,"aria-pressed":C,children:C?e(we,{size:14}):e(xe,{size:14})}),me=bd(),se=ld(),le=st({byteViewer:y,hasPreview:c,isPreview:p,wordWrap:l,hasReview:h,isReviewing:v,blameInline:me.inline,findOpen:M,copied:g,isMaximized:C,saveDisabled:w,canReload:R,refreshing:P,reloadDiscardsEdits:Q,saveButton:ce,maximizeButton:te,viewModeButtons:e(cd,{size:14}),viewModeActions:se,previewLabel:p?"Show source":"Show preview",findLabel:"Find and replace",wordWrapLabel:l?"Word wrap on":"Word wrap off",copyLabel:g?"Copied":y?"Copy image":"Copy content",maximizeLabel:ee,onTogglePreview:H,onToggleReview:F,onToggleFind:z,onToggleWordWrap:L,onToggleBlameInline:()=>{let be={...fi(),inline:!me.inline};Jr({editorBlameInline:be.inline}),window.dispatchEvent(new CustomEvent(cs,{detail:be}))},onZoomIn:U,onZoomOut:A,onCopy:G,onDownload:Z,onReload:N,onSaveAs:X,onToggleMaximize:j,onSave:V});return e("div",{className:"@container flex items-center justify-between gap-2 px-3 py-2 border-b border-ink/10 bg-paper flex-shrink-0",children:[e("div",{className:"hidden @[420px]:flex items-center space-x-2 text-xs font-mono text-ink/40 min-w-0",children:e("span",{className:"truncate max-w-[300px]",title:t,children:t})}),e(Ai,{clusters:le,className:"text-ink/40 ml-auto"})]})}function dt({content:t,file:r,zoomLevel:l,reviewActive:c,onExitReview:p,scrollRef:h,onScroll:v}){return e("div",{ref:h,onScroll:v,"data-testid":"editor-scroller",className:"flex-1 overflow-auto bg-paper flex",children:e("div",{className:"p-6 max-w-4xl mx-auto font-sans flex-1",style:{fontSize:`${l}px`},children:e(Qc,{content:t,file:r,active:c,onExit:p})})})}function wn(t,r){return r?`Spaces: ${t}`:"Tabs"}function ct({caret:t,eol:r,onSetEol:l,indentWidth:c,insertSpaces:p,language:h,byteViewer:v,viewerKind:g,lineCount:y,conflicts:w=0}){return e("footer",{className:"flex bg-canvas border-t border-ink/10 px-3 items-center justify-between text-[10px] text-ink/50 flex-shrink-0 font-mono h-6","data-editor-status-bar":"",children:[e("div",{className:"flex items-center gap-3 min-w-0",children:v?e("span",{className:"uppercase",children:Oo[g]}):e(d,{children:[e("span",{className:"tabular-nums",children:t?`Ln ${t.line}, Col ${t.column}`:"Ln —, Col —"}),e("span",{children:wn(c,p)}),e("button",{type:"button",onClick:()=>l(r==="lf"?"crlf":"lf"),className:"uppercase hover:text-ink transition-colors cursor-pointer",title:`Line endings: ${r.toUpperCase()} — click to switch`,"aria-label":`Line endings ${r.toUpperCase()}, switch`,children:r}),e("span",{children:[y," lines"]})]})}),e("div",{className:"flex items-center gap-3 min-w-0",children:[w>0&&e("span",{className:"text-error font-semibold tabular-nums",title:`${w} unresolved conflict${w===1?"":"s"} — markers are highlighted in the file`,children:["⚠ ",w," conflict",w===1?"":"s"]}),e("span",{className:"uppercase text-ink/40",children:h})]})]})}function kn(t){if(t===0)return 0;return Math.max(-1,Math.min(1,-Math.sign(t)))}function Sn(t,r,l=qs,c=Hs){return Math.max(l,Math.min(c,t+r))}function Cn(t,r){let l=t instanceof HTMLElement?t:null;while(l&&l!==r){let c=getComputedStyle(l);if(/(auto|scroll)/.test(c.overflowY)&&l.scrollHeight>l.clientHeight)return!0;l=l.parentElement}return!1}function mt(t,r){o(()=>{if(!t)return;let l=t.closest("[data-code-surface]"),c=l instanceof HTMLElement?l:t,p=(h)=>{if(!h.ctrlKey&&!h.metaKey)return;if(h.preventDefault(),Cn(h.target,c))return;let v=kn(h.deltaY);if(v===0)return;r((g)=>Sn(g,v))};return t.addEventListener("wheel",p,{passive:!1}),()=>t.removeEventListener("wheel",p)},[t,r])}function ut(t,r){let l=t.trim();if(!/^\d+$/.test(l))return null;let c=Number(l);if(c<1)return null;return Math.min(c,Math.max(r,1))}function pt({lineCount:t,onGo:r,onClose:l}){let[c,p]=n(""),h=i(null);o(()=>{h.current?.focus(),h.current?.select()},[]);let v=()=>{let w=ut(c,t);if(w===null)return;r(w)},g=(w)=>{if(w.key==="Enter"){w.preventDefault(),v();return}if(w.key==="Escape")w.preventDefault(),l()},y=ut(c,t);return e(J,{onClose:l,maxWidthClass:"max-w-xs",header:e("span",{className:"text-sm font-semibold text-ink",children:"Go to line"}),children:e("div",{className:"px-4 py-3 space-y-2",children:[e("div",{className:"flex items-center gap-2",children:[e("input",{ref:h,value:c,onInput:(w)=>p(w.target.value),onKeyDown:g,inputMode:"numeric",placeholder:"1","aria-label":"Line number",className:"flex-1 bg-paper border border-ink/20 rounded px-2 py-1 text-xs font-mono text-ink outline-none focus:border-ink/40"}),e("span",{className:"text-[10px] font-mono text-ink/40",children:["/ ",t]}),e("button",{type:"button",onClick:v,disabled:y===null,className:"flex items-center gap-1 px-2 py-1 rounded bg-ink text-paper text-xs disabled:opacity-40 disabled:cursor-default cursor-pointer",children:[e(tt,{size:12}),"Go"]})]}),c&&y!==null&&String(y)!==c.trim()?e("div",{className:"text-[10px] text-ink/50 font-mono",children:["line ",y," (the last line)"]}):null,c&&y===null?e("div",{className:"text-[10px] text-error font-mono",children:"Enter a line number"}):null]})})}var ft={status:"idle",payload:null,message:null};function bt(t){if(!t?.path)return"";return`${t.root??""}\x00${t.repo??""}\x00${t.path}`}function gt(t,r={}){let l=r.enabled!==!1&&Boolean(t?.path)&&t?.deviceFile!==!0,c=r.dirty===!0,p=bt(t),[h,v]=n({key:"",value:ft}),g=i(t);g.current=t;let y=i(p);y.current=p;let w=i(l);w.current=l;let x=i(c);x.current=c;let k=i(h);k.current=h;let I=i(0),C=i(""),M=i(new Map),z=i(new Set),V=a(async()=>{let A=g.current;if(!A?.path)return;let G=bt(A),Z=++I.current;C.current=G,v((R)=>({key:G,value:{status:"loading",payload:R.key===G?R.value.payload:null,message:null}}));let N=new URLSearchParams({blame:"1",file:A.path,repo:A.repo||"."});if(A.root)N.set("root",A.root);try{let R=await fetch(`/api/fs/git?${N.toString()}`),P=await R.json().catch(()=>null);if(Z!==I.current)return;if(!R.ok||!P){v({key:G,value:{status:"error",payload:null,message:P?.error??`Blame request failed (HTTP ${R.status})`}});return}v({key:G,value:P.available?{status:"ready",payload:P,message:null}:{status:"unavailable",payload:P,message:P.message??null}})}catch(R){if(Z!==I.current)return;v({key:G,value:{status:"error",payload:null,message:R instanceof Error?R.message:"Blame failed"}})}finally{if(C.current===G)C.current=""}},[]),H=a(async(A)=>{let G=M.current.get(A);if(G)return G;let Z=g.current;if(!Z?.path)return{entries:[],truncated:!1};let N=new URLSearchParams({blameHistory:"1",file:Z.path,line:String(A),repo:Z.repo||"."});if(Z.root)N.set("root",Z.root);try{let P=await(await fetch(`/api/fs/git?${N.toString()}`)).json().catch(()=>null),Q={entries:Array.isArray(P?.entries)?P.entries:[],truncated:P?.truncated===!0};return M.current.set(A,Q),Q}catch{return{entries:[],truncated:!1}}},[]),F=i(null);if(!F.current)F.current={ensure:()=>{if(!w.current||x.current)return;let A=k.current;if(A.key===y.current&&A.value.status!=="idle")return;if(C.current===y.current)return;V()},reload:()=>{M.current.clear(),V()},history:H,snapshot:()=>{let A=k.current;return A.key===y.current?A.value:ft},stale:()=>x.current,subscribe:(A)=>(z.current.add(A),()=>{z.current.delete(A)})};o(()=>{if(!l||c||!p)return;M.current.clear(),V()},[l,c,p,V]);let L=i(c);return o(()=>{if(L.current===c)return;L.current=c;for(let A of z.current)A()},[c]),o(()=>{for(let A of z.current)A()},[h]),F.current}var En="0".repeat(40);function Ee(t){return t===En}function he(t,r=Date.now()){let l=Math.max(0,Math.floor(r/1000)-t);if(l<60)return"just now";let c=Math.floor(l/60);if(c<60)return`${c}m ago`;let p=Math.floor(c/60);if(p<24)return`${p}h ago`;let h=Math.floor(p/24);if(h<30)return`${h}d ago`;let v=Math.floor(h/30);if(v<12)return`${v}mo ago`;return`${Math.floor(h/365)}y ago`}function ht(t,r){switch(t){case"not-repo":return"This folder is not a git repository.";case"no-commit":return"This repository has no commits yet.";case"untracked":return"This file has never been committed, so it has no history.";case"too-large":return r??"This file is too large to blame.";case"empty":return"This file is empty.";default:return r??"git could not read this file."}}var kt="fixed z-50 w-[min(340px,92vw)] rounded-xl border border-ink/20 bg-paper p-3 shadow-xl font-sans text-xs text-ink",yt="flex items-baseline justify-between gap-2",xt="truncate text-xs font-semibold text-ink",Tn="shrink-0 font-mono text-[10px] text-ink/40",Mn="mt-1 line-clamp-2 text-[11px] leading-snug text-ink/80",Nn="mt-2 border-t border-ink/10 pt-2",Rn="flex items-center gap-2 font-mono text-[10px] text-ink/40",wt="mt-1 text-[10px] leading-snug text-ink/50",Pn="mt-2 flex w-full items-center gap-1.5 text-left text-[10px] text-ink/50 hover:text-ink cursor-pointer",Ln="mt-1.5 space-y-1 border-t border-ink/10 pt-1.5",Te="flex items-center gap-1.5 font-mono text-[10px]";function q(t,r,l){let c=document.createElement(t);if(c.className=r,l!==void 0)c.textContent=l;return c}function Bn(t){return new Date(t*1000).toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric"})}function Dn(t){let r=t.payload;if(t.status==="error")return{title:"Blame failed",body:t.message??"git could not read this file."};if(t.status==="unavailable")return{title:r?.reason==="untracked"?"Not tracked":"No history",body:ht(r?.reason??"error",t.message??void 0)};if(!r)return null;if(t.stale)return{title:"Not committed yet",body:"This line changed in the editor. Save the file to see its blame."};if(t.line>r.lines)return{title:"Not committed yet",body:`Line ${t.line} is past the end of the file at HEAD (${r.lines} lines).`};let l=r.runs.length>0?St(r,t.line):null;if(!l)return{title:"Not committed yet",body:`git has no attribution for line ${t.line}.`};if(Ee(l.sha))return{title:"Not committed yet",body:"This line differs from the last commit."};return null}function St(t,r){for(let l of t.runs)if(r>=l.from&&r<=l.to)return t.commits[l.sha]??null;return null}function On(t,r){t.replaceChildren(),t.className=kt;let l=Dn(r);if(l){let w=q("div",yt);if(w.append(q("span",xt,l.title)),r.status==="error"&&r.message){let x=q("button","shrink-0 cursor-pointer text-[10px] text-ink/50 hover:text-ink","Try again");x.type="button",x.setAttribute("aria-label","Read the blame again"),w.append(x)}t.append(w,q("p",wt,l.body));return}let c=r.payload;if(!c){t.append(q("p",wt,"Reading blame…"));return}let p=St(c,r.line),h=q("div",yt);if(h.append(q("span",xt,p.author.trim()||"Unknown"),q("span",Tn,he(p.time))),t.append(h),p.summary)t.append(q("p",Mn,p.summary));let v=q("div",`${Rn} ${Nn}`);if(v.append(q("code","truncate",p.sha.slice(0,7)),q("span","",Bn(p.time))),p.mail){let w=q("span","truncate",p.mail);w.title=p.mail,v.append(w)}t.append(v);let g=q("button",Pn);if(g.type="button",g.setAttribute("aria-expanded",r.historyOpen?"true":"false"),g.textContent=`${r.historyOpen?"▾":"▸"} Line history`,t.append(g),!r.historyOpen)return;let y=q("ol",Ln);if(r.historyLoading)y.append(q("li",`${Te} text-ink/40`,"Reading history…"));else if(!r.history||r.history.entries.length===0)y.append(q("li",`${Te} text-ink/40`,"No commits touched this line."));else{let w=r.history.entries;if(w.forEach((x,k)=>{let I=q("li",Te),C=k===w.length-1?"new":"edit";I.append(q("span","text-ink/40",k===0?"●":"○"),q("code","text-ink/60",x.sha.slice(0,7)),q("span","truncate text-ink/80",x.author.trim()||"Unknown"),q("span","ml-auto shrink-0 text-ink/40",he(x.time)),q("span","shrink-0 rounded bg-ink/5 px-1 text-[8.5px] uppercase tracking-wider text-ink/45",C)),y.append(I)}),r.history.truncated)y.append(q("li",`${Te} text-ink/40`,"Older commits are not shown."))}t.append(y)}function Et(t,r,l){let c=q("div",kt);c.setAttribute("role","dialog"),c.setAttribute("aria-label","Line blame"),c.addEventListener("mousedown",(x)=>x.stopPropagation());let p=null,h=!1,v=!1,g=()=>{let x=r.snapshot();return{line:t,status:x.status,payload:x.payload,message:x.message,stale:r.stale(),history:p,historyOpen:h,historyLoading:v}},y=()=>{On(c,g());let x=c.querySelector('[aria-label="Read the blame again"]');if(x)x.addEventListener("click",(k)=>{k.stopPropagation(),l()});c.querySelector("button[aria-expanded]")?.addEventListener("click",(k)=>{if(k.stopPropagation(),h=!h,y(),!h||p||v)return;v=!0,y(),r.history(t).then((I)=>{p=I,v=!1,y()})})};y();let w=r.subscribe(y);return{element:c,place(x){let k=c.ownerDocument.defaultView,I=k?.innerWidth??1024,C=k?.innerHeight??768,M=c.offsetWidth||340,z=c.offsetHeight||120,V=8,H=Math.max(8,Math.min(x.left,I-M-8)),F=x.bottom+6,L=x.top-z-6,U=F+z>C-8&&L>8?L:F;c.style.left=`${H}px`,c.style.top=`${Math.max(8,U)}px`},destroy(){w(),c.remove()}}}function Tt(t){return ye.define((r)=>{let l=null,c=0,p,h=()=>{clearTimeout(p),p=void 0,l?.destroy(),l=null,c=0},v=(C,M)=>{let z=C.getBoundingClientRect();if(z.width>0)return{left:z.left,top:z.top,bottom:z.bottom};let V=r.state.doc.line(Math.min(M,r.state.doc.lines)),H=null;try{H=r.coordsAtPos(V.from)}catch{H=null}if(H)return H;let F=r.scrollDOM.getBoundingClientRect();return{left:F.left,top:F.top+24,bottom:F.top+24}},g=(C,M)=>{if(c===C&&l)return;h(),c=C,l=Et(C,t,()=>{t.reload(),h()}),document.body.append(l.element),l.place(M)},y=(C)=>{let M=C.target,z=M?.closest?.(".cm-blame-label");if(z){let F=Number(z.dataset.blameLine);return Number.isInteger(F)&&F>0?{line:F,anchor:z}:null}let V=M?.closest?.(".cm-lineNumbers .cm-gutterElement");if(!V)return null;let H=Number((V.textContent??"").trim());return Number.isInteger(H)&&H>0?{line:H,anchor:V}:null},w=(C)=>{let M=y(C);if(!M)return;g(M.line,v(M.anchor,M.line))},x=(C)=>{let M=y(C);if(M){C.preventDefault(),g(M.line,v(M.anchor,M.line));return}if(l&&!l.element.contains(C.target))h()},k=(C)=>{if(C.key==="Escape"&&l)h(),C.stopPropagation()},I=(C)=>{if(!l)return;let M=C.relatedTarget;if(M&&(l.element.contains(M)||r.scrollDOM.contains(M)))return;p=setTimeout(h,200)};return r.scrollDOM.addEventListener("mouseover",w),r.scrollDOM.addEventListener("mouseleave",I),r.scrollDOM.addEventListener("mousedown",x),document.addEventListener("mousedown",x),document.addEventListener("keydown",k,!0),{update(C){if(C.docChanged&&l)h()},destroy(){h(),r.scrollDOM.removeEventListener("mouseover",w),r.scrollDOM.removeEventListener("mouseleave",I),r.scrollDOM.removeEventListener("mousedown",x),document.removeEventListener("mousedown",x),document.removeEventListener("keydown",k,!0)}}})}var Mt=40,Rt=ae.define();function An(t){return Ne.define({create:()=>({payload:t.snapshot().payload,stale:!1}),update(r,l){let c=r;for(let p of l.effects){if(!p.is(Rt))continue;c=p.value.payload!==r.payload?{payload:p.value.payload,stale:!1}:{payload:r.payload,stale:r.stale}}if(l.docChanged&&!c.stale)c={payload:c.payload,stale:!0};return c}})}function In(t,r,l){let c=t.commits[r];if(!c||Ee(r))return null;let p=c.author.trim()||"Unknown";return l?p:`${p} · ${he(c.time)}`}class Pt extends Vt{constructor(t,r,l){super();this.line=t;this.text=r;this.title=l}eq(t){return t.line===this.line&&t.text===this.text&&t.title===this.title}toDOM(){let t=document.createElement("span");return t.className="cm-blame-label",t.dataset.blameLine=String(this.line),t.title=this.title,t.textContent=this.text,t}}function Nt(t,r,l){let{payload:c,stale:p}=t;if(!c?.available||p)return T.none;let h=Math.min(c.lines,r.state.doc.lines);if(h<1)return T.none;let v=r.state.doc.lineAt(Math.max(0,Math.min(r.viewport.from,r.state.doc.length))).number,g=r.state.doc.lineAt(Math.max(0,Math.min(r.viewport.to,r.state.doc.length))).number,y=Math.max(1,v-Mt),w=Math.min(h,g+Mt),x=[];for(let k of c.runs){let I=Math.max(k.from,y);if(I>k.to||I>w)continue;let C=In(c,k.sha,l);if(!C)continue;let M=c.commits[k.sha],z=r.state.doc.line(I);x.push({from:z.to,deco:T.widget({widget:new Pt(z.number,C,M.summary||M.sha),side:1})})}return T.set(x.map((k)=>k.deco.range(k.from)),!0)}function Fn(t,r){return ye.fromClass(class{constructor(l){this.view=l;this.decorations=Nt(l.state.field(t),l,r)}update(l){if(l.startState.field(t)===l.state.field(t)&&!l.docChanged&&!l.viewportChanged)return;this.decorations=Nt(l.state.field(t),l.view,r)}},{decorations:(l)=>l.decorations})}function zn(t){return ye.define((r)=>{let l=!0,c=()=>{if(!l)return;let h=t.snapshot();r.dispatch({effects:Rt.of({payload:h.payload,stale:!1})})},p=t.subscribe(c);return{destroy(){l=!1,p()}}})}function Lt({controller:t,inline:r=!0,compact:l=!1}){let c=An(t);return[c,zn(t),r?Fn(c,l):[],Tt(t)]}function Bt({activeFile:t,editor:r,find:l,surfaceRef:c,goToLineRequest:p,rootPath:h=null,repoPath:v=null,onRunCommand:g,wordWrap:y,zoomLevel:w,setZoomLevel:x,editorFontFamily:k,editorTheme:I,viewerKind:C,isPreview:M,reviewActive:z,onToggleReview:V,revealActive:H}){let F=C==="markdown",L=Yc(),U=Zc(),A=bd(),G=gt({name:t.name,path:t.path,root:t.root??h??void 0,repo:t.repo??v??"."},{enabled:A.enabled,dirty:r.isDirty}),Z=u(()=>A.enabled?Lt({controller:G,inline:A.inline}):null,[A.enabled,A.inline,G]),[N,R]=n(null),P=u(()=>Nc(r.content),[r.content]),[Q,X]=n(!1);o(()=>{if(p>0)X(!0)},[p]);let[j,ne]=n(null),[ce,ee]=n(null);mt(j,x);let te=el({tabKey:String(t.id),surface:F&&M?"rendered":"code",ready:r.loaded,element:F&&M?void 0:j}),me=a((se)=>{te.ref(se),ee(se)},[te.ref]);return Lc({path:t.path,scroller:ce,preview:F&&M}),e("div",{className:"relative flex-1 min-h-0 flex flex-col",children:[l.open?e(Fc,{find:l}):null,Q?e(pt,{lineCount:r.content?r.content.split(`
|
|
2
|
-
`).length:1,onGo:(se)=>{X(!1);let le=
|
|
3
|
-
`).length:0,conflicts:P}):null]})}function Dt({activeFile:t,editor:r,find:l,surfaceRef:c,pluginFileView:p,wordWrap:h,setWordWrap:v,viewerKind:g,isPreview:y,isReviewing:w,onToggleReview:x,isMaximized:k,setIsMaximized:I,zoomLevel:C,setZoomLevel:M,goToLineRequest:z,onSaveAs:V,rootPath:H=null,repoPath:F=null,runCommand:L,editorFontFamily:U,editorTheme:A,togglePreview:G,revealActive:Z,missing:N}){let R=g==="image"||g==="pdf"||g==="docx"||g==="spreadsheet",P=is[g]===!0,Q=a(async(X)=>{let j=await $c(t,X,{interactive:!0,baseMtimeMs:r.baseMtimeMs});if(j.status==="written")return{ok:!0};if(j.status==="conflict")return{ok:!1,error:"This file changed on disk since it was opened."};if(j.status==="needs-permission")return{ok:!1,error:"Click Save again to grant write access."};return{ok:!1,error:j.error}},[t,r.baseMtimeMs]);return e(d,{children:[e(lt,{path:t.path,saveStatus:r.saveStatus,wordWrap:h,hasPreview:P,isPreview:y,hasReview:g==="markdown"&&y,isReviewing:w,copied:r.copied,byteViewer:R,saveDisabled:Boolean(r.loadError)||r.handleMissing||r.deviceBacked,unsupported:Boolean(r.unsupported),handleMissing:r.handleMissing,readOnly:r.deviceBacked,isMaximized:k,findOpen:l.open,onToggleFind:()=>l.open?l.close():l.openFind(),onSave:r.saveNow,onTogglePreview:G,onToggleReview:x,onToggleWordWrap:()=>v(!h),onZoomIn:()=>M((X)=>Math.min(Hs,X+1)),onZoomOut:()=>M((X)=>Math.max(qs,X-1)),onCopy:r.copy,onDownload:r.download,onReload:r.reloadFromDisk,onSaveAs:V,canReload:cl(t)&&!r.loadError&&!r.unsupported,refreshing:r.isReading,reloadDiscardsEdits:r.isDirty,onToggleMaximize:()=>I(!k)}),N&&e("div",{className:"flex items-start gap-2 px-3 py-2 border-b border-error/30 bg-error/10 text-error",children:[e(_,{size:14,className:"shrink-0 mt-0.5"}),e("div",{className:"min-w-0",children:[e("div",{className:"text-[11.5px] font-sans",children:"This file was deleted from disk."}),e("div",{className:"text-[11px] font-sans text-error/80",children:"The buffer is still here. Saving recreates the file — autosave is off until then."})]})]}),r.conflict&&e(Ce,{diskMtimeMs:r.conflict.diskMtimeMs,fileName:t.name,onReload:r.resolveConflictByReload,onKeepMine:r.resolveConflictByKeepingMine}),r.handleMissing&&e("div",{className:"flex items-start gap-2 px-3 py-2 border-b border-warning/30 bg-warning/10 text-warning",children:[e(_,{size:14,className:"shrink-0 mt-0.5"}),e("div",{className:"min-w-0",children:[e("div",{className:"text-[11.5px] font-sans",children:"This file was opened by the system, not from a workspace."}),e("div",{className:"text-[11px] font-sans text-warning/80",children:"Its write permission ended with the last page load. Reopen the file from the OS to edit it again."})]})]}),r.deviceBacked&&e("div",{className:"flex items-start gap-2 px-3 py-2 border-b border-ink/20 bg-ink/5 text-ink/70",children:[e(_,{size:14,className:"shrink-0 mt-0.5"}),e("div",{className:"min-w-0",children:[e("div",{className:"text-[11.5px] font-sans",children:r.deviceMissing?"The bytes for this file did not survive the reload.":"Opened from this device, so it is read-only here."}),e("div",{className:"text-[11px] font-sans text-ink/50",children:r.deviceMissing?"A phone's file lives only on the phone, so it cannot be re-read. Open it again from the app that shared it.":"The console cannot reach a file on your phone. Copy it into a workspace to edit it."})]})]}),r.isImage&&r.imageUrl?e(pi,{src:r.imageUrl,name:t.name,className:"flex-1 min-h-0"}):r.isImage?e(ll,{kind:"image",path:t.path,name:t.name,source:r.byteSource,content:r.content,revision:r.revision}):r.isLoading?e("div",{className:"flex-1 flex items-center justify-center gap-2 text-ink/40 text-xs font-mono",children:[e(m,{size:14,className:"animate-spin"}),e("span",{children:"Loading file content…"})]}):r.unsupported?e("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 px-6 text-center",children:[e(Tc,{size:20,className:"text-ink/40"}),e("span",{className:"text-xs text-ink/70 font-sans",children:[t.name," cannot be opened here"]}),e("span",{className:"text-[11px] text-ink/50 font-sans max-w-[42ch]",children:r.unsupported})]}):r.loadError?e("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 px-6 text-center",children:[e(_,{size:20,className:"text-error"}),e("span",{className:"text-xs text-error font-sans",children:["Could not read ",t.name]}),e("span",{className:"text-[11px] text-ink/50 font-mono break-all",children:r.loadError})]}):p&&!r.isImage?e(pg,{view:p}):Pc(g)&&(R||y)?e(ll,{kind:g,path:t.path,name:t.name,source:r.byteSource,content:r.content,revision:r.revision,onContentChange:r.onChange,onSaveBytes:r.deviceBacked?void 0:Q,onDirtyChange:r.setBinaryDirty}):e(Bt,{activeFile:t,editor:r,find:l,surfaceRef:c,goToLineRequest:z,rootPath:H,repoPath:F,onRunCommand:L,wordWrap:h,zoomLevel:C,setZoomLevel:M,editorFontFamily:U,editorTheme:A,isPreview:y,reviewActive:w,onToggleReview:x,viewerKind:g,revealActive:Z})]})}function Ot({activeFile:t,editor:r,find:l,surfaceRef:c,pluginFileView:p,wordWrap:h,setWordWrap:v,viewerKind:g,isPreview:y,isReviewing:w,onToggleReview:x,isMaximized:k,setIsMaximized:I,zoomLevel:C,setZoomLevel:M,goToLineRequest:z,onSaveAs:V,rootPath:H=null,repoPath:F=null,runCommand:L,editorFontFamily:U,editorTheme:A,togglePreview:G,revealActive:Z,missing:N,onConvertDiffToEditor:R,onFileSaved:P}){if(!t)return e("div",{className:"flex-1 flex items-center justify-center text-ink/40",children:e("p",{className:"font-mono text-sm",children:"Select a tab to view content"})});if(t.isDiff)return e(Dc,{filePath:t.path,status:t.diffStatus||"M",isStaged:Boolean(t.diffStaged),root:t.root,repo:t.repo||".",journalDiff:t.journalDiff,readOnly:t.diffSource==="journal",onOpenInEditor:()=>R(t.id),onFileSaved:P,className:"flex-1",tabKey:String(t.id)});return e(Dt,{activeFile:t,editor:r,find:l,surfaceRef:c,pluginFileView:p,wordWrap:h,setWordWrap:v,viewerKind:g,isPreview:y,isReviewing:w,onToggleReview:x,isMaximized:k,setIsMaximized:I,zoomLevel:C,setZoomLevel:M,goToLineRequest:z,onSaveAs:V,rootPath:H,repoPath:F,runCommand:L,editorFontFamily:U,editorTheme:A,togglePreview:G,revealActive:Z,missing:N})}function At({pluginId:t,Component:r,sessionId:l,className:c=""}){return e("div",{className:`flex flex-col h-full bg-canvas ${c}`,children:e(Ve,{pluginId:t,children:e(r,{sessionId:l,workspacePath:null})})})}function It({className:t=""}){return e("div",{className:`flex flex-col h-full bg-canvas items-center justify-center text-muted ${t}`,children:[e(it,{name:"placeholder.txt",size:48,className:"mb-4 opacity-20"}),e("p",{className:"font-mono text-sm",children:"Select a file to open"})]})}function Ft({searchReveal:t,revealMatch:r}){let l=i(r);l.current=r;let c=i(null);o(()=>{if(!t||c.current===t.request)return;c.current=t.request,l.current({query:t.request.query,options:t.request.options,line:t.request.line})},[t])}function zt({openedFiles:t,dirtyKeys:r,activeFile:l,previewReady:c,setPreviewMode:p,sessionId:h}){o(()=>{let v=new Set(t.filter((g)=>!g.isDiff&&g.content===void 0).map((g)=>g.id));We([...r].filter((g)=>v.has(g)))},[r,t]),o(()=>{if(!c)return;let v=l?.id;if(!l||v===void 0||v===null)return;if(!is[ss(l.name)])return;let g=ze(h,"editor.previewMode");if(g&&g[v]!==void 0)return;p((y)=>y[v]===void 0?{...y,[v]:!0}:y)},[c,l])}function Ht({activeFile:t,externalChange:r,conflict:l,onReload:c,onKeepMine:p}){if(!t)return null;if(l)return e(Ce,{diskMtimeMs:l.diskMtimeMs,fileName:t.name,onReload:c,onKeepMine:p});if(r)return e(qc,{fileName:t.name,onReload:c,onKeepMine:p});return null}async function $t(t){let r=t.name.trim();if(!r)return{status:"failed",reason:"Enter a file name."};let l=new FormData;if(l.append("actionType","saveAs"),l.append("path",t.parent),l.append("name",r),l.append("content",t.content),l.append("eol",t.eol),t.root)l.append("root",t.root);if(t.repo&&t.repo!==".")l.append("repo",t.repo);try{let c=await fetch("/api/fs/action",{method:"POST",body:l}),p=await c.json().catch(()=>null),h=typeof p?.error==="string"?p.error:null;if(c.status===409)return{status:"exists",reason:h??`${r} already exists.`};if(c.ok&&p?.success&&typeof p.path==="string")return{status:"written",path:p.path};return{status:"failed",reason:h??"The file could not be written."}}catch{return{status:"failed",reason:"The file could not be written."}}}function Wt(t){let r=t.lastIndexOf(".");if(r<=0)return`${t} copy`;return`${t.slice(0,r)} copy${t.slice(r)}`}function Kt(t){let r=t.trim();if(!r)return!1;if(r==="."||r==="..")return!1;return!r.includes("/")&&!r.includes("\\")}function Hn(t){let r=t.lastIndexOf("/");return r===-1?"":t.slice(0,r)}function Ut({fileName:t,filePath:r,content:l,eol:c,root:p,repo:h,onSaved:v,onClose:g}){let[y,w]=n(()=>Hn(r)),[x,k]=n(()=>Wt(t)),[I,C]=n(!1),[M,z]=n(null),V=i(null);o(()=>{V.current?.focus(),V.current?.select()},[]);let H=Kt(x),F=async()=>{if(!H||I)return;C(!0),z(null);let U=await $t({parent:y,name:x,content:l,eol:c,root:p,repo:h});if(C(!1),U.status==="written"){v({path:U.path});return}z(U.reason)},L=(U)=>{if(U.key==="Enter"){U.preventDefault(),F();return}if(U.key==="Escape")U.preventDefault(),g()};return e(J,{onClose:g,maxWidthClass:"max-w-md",header:e("span",{className:"text-sm font-semibold text-ink",children:"Save as"}),footer:e("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-ink/10",children:[e("button",{type:"button",onClick:g,className:"px-3 py-1.5 rounded border border-ink/20 text-ink/80 hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),e("button",{type:"button",onClick:()=>void F(),disabled:!H||I,className:"flex items-center gap-1.5 px-3 py-1.5 rounded bg-ink text-paper disabled:opacity-40 disabled:cursor-default cursor-pointer",children:[I?e(m,{size:12,className:"animate-spin"}):e(tt,{size:12}),"Save"]})]}),children:e("div",{className:"px-4 py-3 space-y-2 text-xs",children:[e("label",{className:"block",children:[e("span",{className:"block text-[10px] uppercase tracking-wide text-ink/50 mb-1",children:"Folder"}),e("input",{value:y,onInput:(U)=>w(U.target.value),onKeyDown:L,placeholder:"(workspace root)","aria-label":"Destination folder",className:"w-full bg-paper border border-ink/20 rounded px-2 py-1 font-mono text-ink outline-none focus:border-ink/40"})]}),e("label",{className:"block",children:[e("span",{className:"block text-[10px] uppercase tracking-wide text-ink/50 mb-1",children:"Name"}),e("input",{ref:V,value:x,onInput:(U)=>k(U.target.value),onKeyDown:L,"aria-label":"File name","aria-invalid":!H,className:`w-full bg-paper border rounded px-2 py-1 font-mono text-ink outline-none ${H?"border-ink/20 focus:border-ink/40":"border-error text-error"}`})]}),!H?e("div",{className:"text-[10px] text-error font-mono",children:"Enter a file name without a path separator"}):null,M?e("div",{className:"text-[10px] text-error font-mono",children:M}):null,e("div",{className:"text-[10px] text-ink/40",children:"The original file stays where it is, and its tab stays open."})]})})}function _t(){o(()=>{let t=(r)=>{if(!_e())return;r.preventDefault(),r.returnValue=""};return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)},[])}function Gt({fileName:t,onAnswer:r}){return e(J,{onClose:()=>r("cancel"),header:e("div",{className:"flex items-center gap-2",children:[e(_,{size:15,className:"text-warning"}),e("span",{className:"text-sm font-semibold text-ink",children:"Unsaved changes"})]}),footer:e("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-ink/10",children:[e("button",{type:"button",onClick:()=>r("cancel"),className:"px-3 py-1.5 rounded border border-ink/20 text-ink/80 hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),e("button",{type:"button",onClick:()=>r("discard"),className:"px-3 py-1.5 rounded border border-error/40 text-error hover:bg-error/10 transition-colors cursor-pointer",children:"Discard"}),e("button",{type:"button",onClick:()=>r("save"),className:"px-3 py-1.5 rounded bg-ink text-paper hover:bg-ink/90 transition-colors cursor-pointer",children:"Save & close"})]}),children:e("div",{className:"px-4 py-3 text-xs text-ink/80",children:[e("span",{className:"font-mono text-ink",children:t})," has changes that are not on disk.",e("div",{className:"mt-1 text-ink/50",children:"Discarding them cannot be undone."})]})})}function qt({closeGuard:t,activeFile:r,saveMissingConfirm:l,onCancelSaveMissing:c,onConfirmSaveMissing:p}){if(t.pending)return e(Gt,{fileName:t.pending.name,onAnswer:t.answer});if(l&&r)return e(Hc,{fileName:r.name,filePath:r.path,onClose:c,onConfirm:p});return null}function Zt({className:t="",isMaximized:r,onKeyDownCapture:l,onFocusCapture:c,asSplitPane:p,tabs:h,activeFile:v,editor:g,externalChange:y,conflict:w,onReload:x,onKeepMine:k,body:I,saveAsOpen:C,onSaveAsClose:M,onSavedAs:z,closeGuard:V}){let H=r?"fixed inset-0 z-50 flex flex-col bg-canvas":`flex flex-col h-full bg-canvas ${t}`;return e("div",{className:H,onKeyDownCapture:l,onFocusCapture:c,children:[p?null:h,e(Ht,{activeFile:v,externalChange:y,conflict:w,onReload:x,onKeepMine:k}),I,C&&v?e(Ut,{fileName:v.name,filePath:v.path,content:g.content,eol:g.eol,root:v.root,repo:v.repo,onSaved:({path:F})=>z(F),onClose:M}):null,e(qt,{closeGuard:V,activeFile:v,saveMissingConfirm:g.saveMissingConfirm,onCancelSaveMissing:g.cancelSaveMissing,onConfirmSaveMissing:g.confirmSaveMissing})]})}function Yt({fileName:t,onClose:r,children:l}){return e("div",{className:"flex flex-col h-full min-w-0","data-split-pane":"",children:[e("div",{className:"flex items-center justify-between gap-2 px-3 py-1 border-b border-ink/10 bg-canvas flex-shrink-0",children:[e("span",{className:"text-[11px] font-mono text-ink/60 truncate",title:t,children:t}),e("button",{type:"button",onClick:r,className:"p-0.5 rounded hover:bg-ink/10 text-ink/50 hover:text-ink transition-colors cursor-pointer flex-shrink-0",title:"Close this pane (the tab stays open)","aria-label":"Close split pane",children:e(b,{size:12})})]}),e("div",{className:"flex-1 min-h-0",children:l})]})}function jt({fraction:t,onFraction:r,rightPaneName:l,onClosePane:c,rightPane:p,children:h}){let v=i(null),g=i(null),y=Bm(g),w=(x)=>{let k=x.currentTarget,I=v.current;if(!k||!I)return;k.setPointerCapture(x.pointerId);let C=(z)=>{let V=I.getBoundingClientRect();if(V.width===0)return;r(ue((z.clientX-V.left)/V.width))},M=()=>{k.releasePointerCapture(x.pointerId),k.removeEventListener("pointermove",C),k.removeEventListener("pointerup",M)};k.addEventListener("pointermove",C),k.addEventListener("pointerup",M)};return e("div",{ref:v,className:"flex w-full h-full","data-split-column":"",children:[e("div",{className:"flex flex-col min-w-0 h-full",style:{width:`${Math.round(ue(t)*100)}%`},children:h}),e("div",{ref:g,className:`w-[3px] flex-shrink-0 cursor-col-resize transition-colors active:bg-ink/40 ${y?"bg-ink/40":"bg-ink/10"}`,role:"separator","aria-orientation":"vertical","aria-label":"Resize split panes",onPointerDown:w}),e("div",{className:"flex-1 min-w-0 h-full",children:e(Yt,{fileName:l,onClose:c,children:p})})]})}function Jt({openedFiles:t,activeFileId:r,enabled:l}){let[c,p]=S("editor.split",ge),h=t.map((k)=>k.id),v=je(Je(c,h),r),g=l&&v.rightFileId!==null?t.find((k)=>k.id===v.rightFileId)??null:null,y=a((k)=>{if(k!==null&&!Se(k,r,h))return;p({...v,rightFileId:k})},[v,p,r,h]),w=a(()=>p({...v,rightFileId:null}),[v,p]),x=a((k)=>p({...v,fraction:ue(k)}),[v,p]);return{rightFile:g,fraction:v.fraction,splitTo:y,close:w,setFraction:x}}function Qt({find:t,runCommand:r,reopenClosed:l}){let c=i(t);c.current=t;let p=i(r);p.current=r;let h=i(l);return h.current=l,{onKeyDownCapture:a((g)=>{let y=c.current;if(g.key==="Escape"){if(!y.open)return;g.preventDefault(),g.stopPropagation(),y.close();return}if((g.metaKey||g.ctrlKey)&&g.shiftKey&&g.code==="KeyT"){if(h.current?.())g.preventDefault(),g.stopPropagation();return}let w=MA(ui,g);if(!w||!Jm(w))return;g.preventDefault(),g.stopPropagation(),p.current(w)},[])}}function en(t){let r=i(t);r.current=t;let l=i(null);if(!l.current)l.current={saveNow:()=>r.current.saveNow(),runCommand:(p)=>r.current.runCommand(p)};return o(()=>{let p=l.current;if(!p)return;return ig(p)},[]),{onFocusCapture:a(()=>{if(l.current)ig(l.current)},[])}}function tn({openedFiles:t,activeFileId:r,onSelectFile:l,onCloseFile:c,saveNow:p}){let[h,v]=n(null);_t();let g=a((w)=>{let x=t.find((k)=>k.id===w);if(x&&Ue(w)){v(x);return}c(w)},[t,c]),y=a((w)=>{let x=h;if(!x)return;if(w==="cancel"){v(null);return}if(w==="save"){if(x.id!==r)l(x.id);p()}v(null),c(x.id)},[h,r,l,p,c]);return{requestClose:g,pending:h,answer:y}}function nn(){let[t,r]=n(0),[l,c]=n(!1),p=a(()=>r((h)=>h+1),[]);return{goToLineRequest:t,openGoToLine:p,saveAsOpen:l,setSaveAsOpen:c}}function $n({className:t="",openedFiles:r,activeFileId:l,onSelectFile:c,onCloseFile:p,onConvertDiffToEditor:h,refreshKey:v=0,onFileSaved:g,onOpenPath:y,onReopenClosed:w,reopenableCount:x,onCopyPath:k,onRevealInFiles:I,rootPath:C=null,repoPath:M=null,activeEditorPanelKey:z=null,forcedActiveFileId:V=null,asSplitPane:H=!1}){let F=H?V:l,L=r.find((K)=>K.id===F),[U,A,G]=S("editor.previewMode",{}),Z=Wc(String(F??"")),[N,R]=S("editor.zoomLevel",Bo),[P,Q]=n(!1),[X,j]=S("editor.wordWrap",!0),ne=nn(),{sessionId:ce}=Ze(),ee=Jt({openedFiles:r,activeFileId:F,enabled:!H}),te=i(null),me=_o(),se=mi(),le=Oc(r,v),be=Boolean(L&&le.has(L.id)),Y=zc(L??null,{reportSaveError:!0,onFileSaved:g,missing:be}),on=dg({path:L?.path??"",content:Y.content,language:Y.language}),rn=Y.diskChange,De=tn({openedFiles:r,activeFileId:F,onSelectFile:c,onCloseFile:p,saveNow:Y.saveNow}),ve=Uc({text:Y.content,documentKey:`${L?.id??""}\x00${Y.language}`,readSelection:()=>te.current?.getSelection()??null,select:(K,de,Pe=!0)=>te.current?.select(K,de,Pe),reveal:(K)=>te.current?.revealOffset(K),applyDocument:(K,de,Pe)=>te.current?.applyDocument(K,de,Pe),toggleWordWrap:()=>j((K)=>!K)}),Oe=Gc(L?.path??null,Y.content,Y.loaded&&!Y.loadError);Ft({searchReveal:Oe,revealMatch:ve.revealMatch}),jc({file:L,editor:Y,surfaceRef:te,isPreview:L?U[L.id]===!0:!1,exitPreview:()=>{let K=L?.id;if(K===void 0||K===null)return;A((de)=>({...de,[K]:!1}))}}),o(()=>{if(v>0)Y.reset()},[v]),o(()=>{Y.retain(r.map((K)=>K.id)),Ke(r.map((K)=>K.id))},[r]),zt({openedFiles:r,dirtyKeys:Y.dirtyKeys,activeFile:L,previewReady:G,setPreviewMode:A,sessionId:ce});let an=()=>{if(!L)return;A((K)=>({...K,[L.id]:!K[L.id]}))},Me=(K)=>{if(Jm(K)){ve.runCommand(K);return}if(K==="toggleWordWrap"){j((de)=>!de);return}if(K==="goToLine"){ne.openGoToLine();return}te.current?.runCommand(K)},ln=Qt({find:ve,runCommand:Me,reopenClosed:w}),dn=en({saveNow:Y.saveNow,runCommand:Me}),Re=YA(z);if(Re)return e(At,{pluginId:Re.pluginId,Component:Re.Component,sessionId:ce,className:t});if(r.length===0)return e(It,{className:t});let cn=Y.viewerKind,Ae=L?U[L.id]:!1,mn={activeFile:L,editor:Y,find:ve,surfaceRef:te,pluginFileView:on,wordWrap:X,setWordWrap:j,viewerKind:cn,isPreview:Boolean(Ae),isReviewing:Boolean(Ae)&&Z.active,onToggleReview:Z.toggle,isMaximized:P,setIsMaximized:Q,zoomLevel:N,setZoomLevel:R,goToLineRequest:ne.goToLineRequest,onSaveAs:()=>ne.setSaveAsOpen(!0),onOpenPath:y,rootPath:C,repoPath:M,runCommand:Me,editorFontFamily:me,editorTheme:se,togglePreview:an,revealActive:Boolean(Oe),missing:be,onConvertDiffToEditor:h,onFileSaved:g},un=(K)=>({openedFiles:r,activeFileId:l,onSelectFile:c,onCloseFile:p,onConvertDiffToEditor:h,refreshKey:v,onFileSaved:g,onOpenPath:y,rootPath:C,repoPath:M,forcedActiveFileId:K,asSplitPane:!0}),pn=e(nt,{openedFiles:r,activeFileId:l,onSelectFile:c,onCloseFile:De.requestClose,missingIds:le,onCopyPath:k,onRevealInFiles:I,onReopenClosed:w,reopenableCount:x,onSplitTo:ee.splitTo,onUnsplit:ee.close,splitRightFileId:ee.rightFile?.id??null}),Ie=e(Zt,{className:t,isMaximized:P,onKeyDownCapture:ln.onKeyDownCapture,onFocusCapture:dn.onFocusCapture,asSplitPane:H,tabs:pn,activeFile:L,editor:Y,externalChange:rn,conflict:Y.conflict,onReload:Y.resolveConflictByReload,onKeepMine:Y.keepMineAgainstDisk,body:e(Ot,{...mn}),saveAsOpen:ne.saveAsOpen,onSaveAsClose:()=>ne.setSaveAsOpen(!1),onSavedAs:(K)=>{ne.setSaveAsOpen(!1),y?.(K)},closeGuard:De});if(!ee.rightFile)return Ie;return e(jt,{fraction:ee.fraction,onFraction:ee.setFraction,rightPaneName:ee.rightFile.name,onClosePane:ee.close,rightPane:e($n,{...un(ee.rightFile.id)}),children:Ie})}export{$n as Editor};
|
|
1
|
+
import{d,n,o,W,i,u,a,Ue,oe,e,Kn,Ze,Se,S,s,E,m,en,_,f,B,re,tt,fe,Et,qe,ai,ln,Yr,D,O,b,Zr,Ve,pe,gr,J,it,Vs,_o,Ys,Js,To,KA,sh,Rm,ol,Re,ae,Yt,T,ye,mi,lf,Ag}from"./index-gs7ytgdw.js";import{kt,Ai,nu,ru,ou,fs,hi,Bd}from"./index-fbbp5cwj.js";import{Mc,Ad,hd,kg,xg,Pc,nr,us,Oc,$c,zc,Uc,Gc,ds,Uo,ps,gi,qc,ml,fl,Hc,Wc,Kc,Vc,Yc,Jc,Zc,Xc,eu}from"./index-g1cggqgx.js";import{Qa,Na,yi}from"./index-pfbyfab5.js";var fn={name:"git-commit-vertical",size:24,node:[["path",{d:"M12 3v6",key:"1holv5"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M12 15v6",key:"a9ows0"}]]},Be=s(fn);var bn={name:"maximize",size:24,node:[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]},xe=s(bn);var gn={name:"minimize",size:24,node:[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]]},we=s(gn);var hn={name:"save-all",size:24,node:[["path",{d:"M10 2v3a1 1 0 0 0 1 1h5",key:"1xspal"}],["path",{d:"M18 18v-6a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6",key:"1ra60u"}],["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"M8 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9.172a2 2 0 0 1 1.414.586l2.828 2.828A2 2 0 0 1 22 6.828V16a2 2 0 0 1-2.01 2z",key:"1yve0x"}]]},ke=s(hn);var ie=new Set,De=new Set,ze=new Set;function He(){ze=new Set(ie);for(let t of[...De])t()}function $e(t){let r=new Set(t);if(r.size===ie.size){let l=!0;for(let c of r)if(!ie.has(c)){l=!1;break}if(l)return}ie.clear();for(let l of r)ie.add(l);He()}function We(t){let r=new Set(t),l=!1;for(let c of[...ie])if(!r.has(c))ie.delete(c),l=!0;if(l)He()}function Ke(t){return ie.has(t)}function _e(){return ie.size>0}function vn(t){return De.add(t),()=>{De.delete(t)}}var yn=vn;function Ge(){return Ue(yn,()=>ze)}function Xe({x:t,y:r,rows:l,onAction:c,onClose:p}){let h=i(null),[v,g]=n({left:t,top:r});return W(()=>{let y=h.current;if(!y)return;let{width:w,height:x}=y.getBoundingClientRect();g({left:Math.min(t,Math.max(0,window.innerWidth-w-8)),top:Math.min(r,Math.max(0,window.innerHeight-x-8))})},[t,r,l.length]),oe(e("div",{className:"fixed inset-0 z-[70]",onClick:p,onContextMenu:(y)=>{y.preventDefault(),p()},children:e("div",{ref:h,role:"menu","aria-label":"Tab actions",className:"glass-popover absolute w-52 bg-paper border border-ink/15 rounded-md shadow-xl py-1 text-xs text-ink",style:{left:`${v.left}px`,top:`${v.top}px`},onClick:(y)=>y.stopPropagation(),children:l.map((y)=>e("button",{type:"button",role:"menuitem",onClick:()=>{c(y.action),p()},className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 transition-colors cursor-pointer",children:y.label},y.action))})}),document.body)}var ge={rightFileId:null,fraction:0.5};function Ce(t,r,l){if(t===null)return!1;if(t===r)return!1;return l.includes(t)}function Ye(t,r){for(let l=r.length-1;l>=0;l-=1){let c=r[l];if(c!==t)return c}return null}function je(t,r){if(t.rightFileId===null)return t;if(t.rightFileId!==r)return t;return{...t,rightFileId:null}}function ue(t){if(!Number.isFinite(t))return ge.fraction;return Math.max(0.2,Math.min(0.8,t))}function Je(t,r){if(typeof t!=="object"||t===null)return ge;let l=t,c=typeof l.fraction==="number"?ue(l.fraction):ge.fraction,p=typeof l.rightFileId==="string"||typeof l.rightFileId==="number"?l.rightFileId:null;if(p===null||!r.includes(p))return{rightFileId:null,fraction:c};return{rightFileId:p,fraction:c}}function Qe({tab:t,openedFiles:r,dirtyIds:l,reopenable:c,activeFileId:p,splitRightFileId:h}){let v=r.filter((x)=>x.id!==t.id),g=r.filter((x)=>!l.has(x.id)),y=r.map((x)=>x.id);return[{action:"split-right",label:"Split right",enabled:Ce(t.id,p,y)},{action:"unsplit",label:"Unsplit",enabled:h!==null},{action:"close",label:"Close",enabled:!0},{action:"close-others",label:"Close others",enabled:v.length>0},{action:"close-all",label:"Close all",enabled:r.length>0},{action:"close-saved",label:"Close saved",enabled:g.some((x)=>x.id!==t.id)},{action:"copy-path",label:"Copy path",enabled:Boolean(t.path)},{action:"reveal-in-files",label:"Reveal in Files",enabled:Boolean(t.path)&&!t.isDiff},{action:"reopen-closed",label:"Reopen closed tab",enabled:c>0}].filter((x)=>x.enabled)}function nt({openedFiles:t,activeFileId:r,onSelectFile:l,onCloseFile:c,missingIds:p,onCopyPath:h,onRevealInFiles:v,onReopenClosed:g,reopenableCount:y,onSplitTo:w,onUnsplit:x,splitRightFileId:k=null}){let I=Ge(),C=i(null),M=i(null),[z,V]=n(5),[H,F]=n(!1),[L,U]=n(null);pe(M,()=>F(!1)),o(()=>{let N=new ResizeObserver((R)=>{for(let P of R){let Q=P.contentRect.width,X=Math.max(1,Math.floor((Q-60)/150));V(X)}});if(C.current)N.observe(C.current);return()=>N.disconnect()},[]);let A=Ye(r,t.map((N)=>N.id)),G=[],Z=[];if(t.length<=z)G=t;else{let N=t.findIndex((P)=>P.id===r),R=new Set;if(N!==-1&&r!==null)R.add(r);for(let P=t.length-1;P>=0;P--){if(R.size>=z)break;R.add(t[P].id)}G=t.filter((P)=>R.has(P.id)),Z=t.filter((P)=>!R.has(P.id))}return e("div",{className:"flex bg-ink/10 w-full relative border-b border-ink/10",ref:C,children:[e("div",{className:"flex overflow-hidden",children:G.map((N)=>{let R=N.id===r,P=Boolean(N.isDiff),Q=P?Kn(N.diffStatus||"M",N.diffStaged):null,X=Boolean(p?.has(N.id));return e("div",{onClick:()=>l(N.id),onContextMenu:(j)=>{j.preventDefault(),U({tab:N,x:j.clientX,y:j.clientY})},className:`flex items-center space-x-1.5 px-3 py-1.5 cursor-pointer border-r border-ink/10 min-w-[120px] max-w-[210px] group ${R?"bg-paper border-t-2 border-t-ink text-ink":"bg-transparent border-t-2 border-t-transparent text-ink/60 hover:bg-paper/50"}`,title:X?`${N.path} — file no longer exists`:N.path,children:[P?e(ai,{size:14,className:R?"text-info flex-shrink-0":"text-info/70 flex-shrink-0"}):e(it,{name:N.name,size:14,className:`flex-shrink-0${R||X?"":" opacity-60"}${X?" text-error":""}`}),e("span",{className:`text-xs font-mono truncate flex-1${X?" text-error line-through":""}`,children:N.name}),Q&&e("span",{className:`px-1 text-[10px] font-mono font-bold rounded ${Q.badgeBgClass}`,children:Q.charStatus}),e(et,{dirty:I.has(N.id),active:R,label:`Close ${N.name}`,onClose:()=>c(N.id)})]},N.id)})}),L?e(Xe,{x:L.x,y:L.y,rows:Qe({tab:L.tab,openedFiles:t,dirtyIds:I,reopenable:y?.()??0,activeFileId:r,splitRightFileId:k}),onAction:(N)=>{let R=L.tab;switch(N){case"close":c(R.id);return;case"close-others":for(let P of[...t].reverse())if(P.id!==R.id)c(P.id);l(R.id);return;case"close-all":for(let P of[...t].reverse())c(P.id);return;case"close-saved":for(let P of[...t].reverse())if(!I.has(P.id))c(P.id);return;case"copy-path":h?.(R);return;case"reveal-in-files":v?.(R);return;case"reopen-closed":g?.();return;case"split-right":w?.(R.id);return;case"unsplit":x?.();return}},onClose:()=>U(null)}):null,e("div",{className:"ml-auto flex items-center",children:e("button",{type:"button",onClick:()=>k!==null?x?.():w?.(A),disabled:k===null&&A===null,"aria-pressed":k!==null,"aria-label":"Split editor",title:k!==null?"Close the split pane (the tab stays open)":A===null?"Open another file to split the editor":"Split the editor and show the newest other file",className:`p-1.5 mx-1 rounded transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-default ${k!==null?"bg-ink/10 text-ink":"text-ink/60 hover:bg-ink/10"}`,children:e(Yr,{size:14})})}),Z.length>0&&e("div",{className:"relative flex items-center bg-ink/10",ref:M,children:[e("button",{className:`p-1.5 mx-1 rounded hover:bg-ink/10 text-ink/60 ${H?"bg-ink/10 text-ink":""}`,onClick:()=>F(!H),title:"More open files",children:e(B,{size:14})}),H&&e("div",{className:"glass-popover absolute right-0 top-full mt-1 w-52 bg-paper border border-ink/10 rounded shadow-lg z-50 py-1",children:[e("div",{className:"px-3 py-1 text-[10px] uppercase font-mono text-ink/40 border-b border-ink/10 mb-1",children:"Older Tabs"}),Z.map((N)=>{let R=Boolean(p?.has(N.id));return e("div",{onClick:()=>{l(N.id),F(!1)},className:"flex items-center space-x-2 px-3 py-1.5 hover:bg-ink/5 cursor-pointer group",children:[N.isDiff?e(ai,{size:14,className:"text-info/80"}):e(it,{name:N.name,size:14,className:R?"text-error":"opacity-60"}),e("span",{className:`text-xs font-mono truncate flex-1 ${R?"text-error line-through":"text-ink/80"}`,children:N.name}),e(et,{dirty:I.has(N.id),active:!1,label:`Close ${N.name}`,onClose:()=>{if(c(N.id),Z.length===1)F(!1)}})]},N.id)})]})]})]})}function et({dirty:t,active:r,label:l,onClose:c}){return e("div",{role:"button",tabIndex:-1,"aria-label":l,title:t?`${l} — unsaved changes`:l,className:`p-0.5 rounded hover:bg-ink/10 touch-visible ${r||t?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:(p)=>{p.stopPropagation(),c()},children:t?e("span",{className:"block w-2 h-2 rounded-full bg-current mx-0.5","data-tab-dirty":"","aria-hidden":"true"}):e(b,{size:12})})}function xn(t){if(t===null)return null;let r=new Date(t);if(Number.isNaN(r.getTime()))return null;return r.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Ee({diskMtimeMs:t,fileName:r,onReload:l,onKeepMine:c}){let p=xn(t);return e("div",{className:"flex items-start gap-2 px-3 py-2 border-b border-warning/30 bg-warning/10 text-[11px] text-ink flex-shrink-0",role:"alert","data-conflict-strip":"",children:[e(_,{size:13,className:"text-warning flex-shrink-0 mt-0.5"}),e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"font-medium",children:[e("span",{className:"font-mono",children:r})," changed on disk",p?e("span",{className:"text-ink/60",children:[" at ",p]}):null,"."]}),e("div",{className:"text-ink/60 mt-0.5",children:"Your save was refused so nothing was overwritten."})]}),e("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e("button",{type:"button",onClick:l,className:"px-2 py-1 rounded border border-ink/20 hover:bg-ink/5 transition-colors cursor-pointer",title:"Discard my changes and take the file from disk",children:"Reload"}),e("button",{type:"button",onClick:c,className:"px-2 py-1 rounded border border-warning/50 text-warning hover:bg-warning/10 transition-colors cursor-pointer",title:"Write my buffer over the file on disk",children:"Keep mine"})]})]})}function ot(t){if(t.byteViewer)return[];return[{id:"save",pinned:!0,actions:[{label:"Save file",icon:ke,onSelect:t.onSave,disabled:t.saveDisabled}],children:t.saveButton},{id:"save-as",actions:[{label:"Save as…",icon:ke,onSelect:t.onSaveAs}],children:e("button",{type:"button",onClick:t.onSaveAs,className:`${nr} hover:bg-ink/5 hover:text-ink`,title:"Save the buffer to a new file","aria-label":"Save as",children:e(ke,{size:14})})}]}function rt(t){if(!t.hasReview)return[];let r=t.isReviewing?"Exit review mode":"Review this document";return[{id:"review",actions:[{label:r,icon:ln,onSelect:t.onToggleReview,active:t.isReviewing}],children:e(us,{label:r,pressed:t.isReviewing,title:t.isReviewing?"Review mode is on — click a block to judge it":"Review: click blocks to mark them good or needing work",onClick:t.onToggleReview,children:e(ln,{size:14})})}]}function at(t){if(!t.hasPreview)return[];return[{id:"preview",actions:[{label:t.previewLabel,icon:t.isPreview?Et:qe,onSelect:t.onTogglePreview,active:t.isPreview}],children:e(us,{label:t.previewLabel,pressed:t.isPreview,onClick:t.onTogglePreview,children:t.isPreview?e(Et,{size:14}):e(qe,{size:14})})}]}function st(t){let r=[];if(r.push(...ot(t),...rt(t),...at(t)),!t.byteViewer)r.push({id:"find",actions:[{label:t.findLabel,icon:O,onSelect:t.onToggleFind,active:t.findOpen}],children:e(us,{label:t.findLabel,pressed:t.findOpen,title:`${t.findLabel} (Ctrl+F)`,onClick:t.onToggleFind,children:e(O,{size:14})})}),r.push({id:"wrap",actions:[{label:t.wordWrapLabel,icon:en,onSelect:t.onToggleWordWrap,active:t.wordWrap}],children:e(us,{label:t.wordWrapLabel,pressed:t.wordWrap,onClick:t.onToggleWordWrap,children:e(en,{size:14})})}),r.push({id:"blame",actions:[{label:t.blameInline?"Hide line blame":"Show line blame",icon:Be,onSelect:t.onToggleBlameInline,active:t.blameInline}],children:e(us,{label:t.blameInline?"Hide line blame":"Show line blame",pressed:t.blameInline,title:"Who last changed each block, from git (hover a line for the commit)",onClick:t.onToggleBlameInline,children:e(Be,{size:14})})}),r.push({id:"zoom",actions:[{label:"Decrease font size",icon:Na,onSelect:t.onZoomOut},{label:"Increase font size",icon:Qa,onSelect:t.onZoomIn}],children:e(d,{children:[e("button",{type:"button",onClick:t.onZoomOut,className:`${nr} hover:bg-ink/5 hover:text-ink`,title:"Decrease font size","aria-label":"Decrease font size",children:e(Na,{size:14})}),e("button",{type:"button",onClick:t.onZoomIn,className:`${nr} hover:bg-ink/5 hover:text-ink`,title:"Increase font size","aria-label":"Increase font size",children:e(Qa,{size:14})})]})}),r.push({id:"reload",actions:[{label:"Reload from disk",icon:D,onSelect:t.onReload,disabled:!t.canReload}],children:e("button",{type:"button",onClick:t.onReload,disabled:!t.canReload||t.refreshing,"aria-busy":t.refreshing,className:`${nr} hover:bg-ink/5 hover:text-ink`,title:!t.canReload?"Nothing to reload — this tab has no file on disk":t.reloadDiscardsEdits?"Discard my changes and reload from disk":"Reload from disk","aria-label":"Reload from disk",children:e(D,{size:14,className:t.refreshing?"animate-spin":void 0})})});return r.push({id:"copy",actions:[{label:t.copyLabel,icon:re,onSelect:t.onCopy},{label:"Download file",icon:fe,onSelect:t.onDownload}],children:e(d,{children:[e("button",{type:"button",onClick:t.onCopy,className:`${nr} hover:bg-ink/5 hover:text-ink`,title:t.copyLabel,"aria-label":t.copyLabel,children:t.copied?e(re,{size:14,className:"text-success"}):e(re,{size:14})}),e("button",{type:"button",onClick:t.onDownload,className:`${nr} hover:bg-ink/5 hover:text-ink`,title:"Download file","aria-label":"Download file",children:e(fe,{size:14})})]})}),r.push({id:"view-modes",pinned:!0,actions:t.viewModeActions,children:t.viewModeButtons}),r.push({id:"maximize",pinned:!0,actions:[{label:t.maximizeLabel,icon:t.isMaximized?we:xe,onSelect:t.onToggleMaximize,active:t.isMaximized}],children:t.maximizeButton}),r}function lt({path:t,saveStatus:r,wordWrap:l,hasPreview:c,isPreview:p,hasReview:h,isReviewing:v,copied:g,byteViewer:y=!1,saveDisabled:w=!1,unsupported:x=!1,handleMissing:k=!1,readOnly:I=!1,isMaximized:C=!1,findOpen:M=!1,onToggleFind:z,onSave:V,onTogglePreview:H,onToggleReview:F,onToggleWordWrap:L,onZoomIn:U,onZoomOut:A,onCopy:G,onDownload:Z,onReload:N,canReload:R,refreshing:P=!1,reloadDiscardsEdits:Q,onSaveAs:X,onToggleMaximize:j}){let ne=w?I?"Read-only — this file was opened from the phone, not from a workspace":k?"Cannot save — reopen the file from the system to restore write access":x?"Nothing to save — this file cannot be opened as a document":"Nothing to save — this file could not be read":r==="needs-permission"?"Click Save to allow writing this file":r==="saving"?"Saving…":r==="error"?"Save failed — the file on disk was not changed":"Save file (Ctrl+S)",ce=e("button",{type:"button",onClick:V,disabled:w||r==="saving",className:`${nr} hover:bg-ink/5`,title:ne,"aria-label":ne,children:r==="saving"?e(kt,{size:14,className:"text-warning animate-pulse"}):r==="saved"?e(f,{size:14,className:"text-success"}):r==="error"?e(E,{size:14,className:"text-error"}):r==="needs-permission"?e(kt,{size:14,className:"text-warning"}):e(kt,{size:14,className:"hover:text-ink"})}),ee=C?"Exit full screen":"Full screen",te=e("button",{type:"button",onClick:j,className:`${nr} hover:bg-ink/5 hover:text-ink ${C?"text-ink":""}`,title:ee,"aria-label":ee,"aria-pressed":C,children:C?e(we,{size:14}):e(xe,{size:14})}),me=Bd(),se=Ad(),le=st({byteViewer:y,hasPreview:c,isPreview:p,wordWrap:l,hasReview:h,isReviewing:v,blameInline:me.inline,findOpen:M,copied:g,isMaximized:C,saveDisabled:w,canReload:R,refreshing:P,reloadDiscardsEdits:Q,saveButton:ce,maximizeButton:te,viewModeButtons:e(hd,{size:14}),viewModeActions:se,previewLabel:p?"Show source":"Show preview",findLabel:"Find and replace",wordWrapLabel:l?"Word wrap on":"Word wrap off",copyLabel:g?"Copied":y?"Copy image":"Copy content",maximizeLabel:ee,onTogglePreview:H,onToggleReview:F,onToggleFind:z,onToggleWordWrap:L,onToggleBlameInline:()=>{let be={...hi(),inline:!me.inline};Zr({editorBlameInline:be.inline}),window.dispatchEvent(new CustomEvent(fs,{detail:be}))},onZoomIn:U,onZoomOut:A,onCopy:G,onDownload:Z,onReload:N,onSaveAs:X,onToggleMaximize:j,onSave:V});return e("div",{className:"@container flex items-center justify-between gap-2 px-3 py-2 border-b border-ink/10 bg-paper flex-shrink-0",children:[e("div",{className:"hidden @[420px]:flex items-center space-x-2 text-xs font-mono text-ink/40 min-w-0",children:e("span",{className:"truncate max-w-[300px]",title:t,children:t})}),e(yi,{clusters:le,className:"text-ink/40 ml-auto"})]})}function dt({content:t,file:r,zoomLevel:l,reviewActive:c,onExitReview:p,scrollRef:h,onScroll:v}){return e("div",{ref:h,onScroll:v,"data-testid":"editor-scroller",className:"flex-1 overflow-auto bg-paper flex",children:e("div",{className:"p-6 max-w-4xl mx-auto font-sans flex-1",style:{fontSize:`${l}px`},children:e(Oc,{content:t,file:r,active:c,onExit:p})})})}function wn(t,r){return r?`Spaces: ${t}`:"Tabs"}function ct({caret:t,eol:r,onSetEol:l,indentWidth:c,insertSpaces:p,language:h,byteViewer:v,viewerKind:g,lineCount:y,conflicts:w=0}){return e("footer",{className:"flex bg-canvas border-t border-ink/10 px-3 items-center justify-between text-[10px] text-ink/50 flex-shrink-0 font-mono h-6","data-editor-status-bar":"",children:[e("div",{className:"flex items-center gap-3 min-w-0",children:v?e("span",{className:"uppercase",children:Uo[g]}):e(d,{children:[e("span",{className:"tabular-nums",children:t?`Ln ${t.line}, Col ${t.column}`:"Ln —, Col —"}),e("span",{children:wn(c,p)}),e("button",{type:"button",onClick:()=>l(r==="lf"?"crlf":"lf"),className:"uppercase hover:text-ink transition-colors cursor-pointer",title:`Line endings: ${r.toUpperCase()} — click to switch`,"aria-label":`Line endings ${r.toUpperCase()}, switch`,children:r}),e("span",{children:[y," lines"]})]})}),e("div",{className:"flex items-center gap-3 min-w-0",children:[w>0&&e("span",{className:"text-error font-semibold tabular-nums",title:`${w} unresolved conflict${w===1?"":"s"} — markers are highlighted in the file`,children:["⚠ ",w," conflict",w===1?"":"s"]}),e("span",{className:"uppercase text-ink/40",children:h})]})]})}function kn(t){if(t===0)return 0;return Math.max(-1,Math.min(1,-Math.sign(t)))}function Sn(t,r,l=Ys,c=Js){return Math.max(l,Math.min(c,t+r))}function Cn(t,r){let l=t instanceof HTMLElement?t:null;while(l&&l!==r){let c=getComputedStyle(l);if(/(auto|scroll)/.test(c.overflowY)&&l.scrollHeight>l.clientHeight)return!0;l=l.parentElement}return!1}function mt(t,r){o(()=>{if(!t)return;let l=t.closest("[data-code-surface]"),c=l instanceof HTMLElement?l:t,p=(h)=>{if(!h.ctrlKey&&!h.metaKey)return;if(h.preventDefault(),Cn(h.target,c))return;let v=kn(h.deltaY);if(v===0)return;r((g)=>Sn(g,v))};return t.addEventListener("wheel",p,{passive:!1}),()=>t.removeEventListener("wheel",p)},[t,r])}function ut(t,r){let l=t.trim();if(!/^\d+$/.test(l))return null;let c=Number(l);if(c<1)return null;return Math.min(c,Math.max(r,1))}function pt({lineCount:t,onGo:r,onClose:l}){let[c,p]=n(""),h=i(null);o(()=>{h.current?.focus(),h.current?.select()},[]);let v=()=>{let w=ut(c,t);if(w===null)return;r(w)},g=(w)=>{if(w.key==="Enter"){w.preventDefault(),v();return}if(w.key==="Escape")w.preventDefault(),l()},y=ut(c,t);return e(J,{onClose:l,maxWidthClass:"max-w-xs",header:e("span",{className:"text-sm font-semibold text-ink",children:"Go to line"}),children:e("div",{className:"px-4 py-3 space-y-2",children:[e("div",{className:"flex items-center gap-2",children:[e("input",{ref:h,value:c,onInput:(w)=>p(w.target.value),onKeyDown:g,inputMode:"numeric",placeholder:"1","aria-label":"Line number",className:"flex-1 bg-paper border border-ink/20 rounded px-2 py-1 text-xs font-mono text-ink outline-none focus:border-ink/40"}),e("span",{className:"text-[10px] font-mono text-ink/40",children:["/ ",t]}),e("button",{type:"button",onClick:v,disabled:y===null,className:"flex items-center gap-1 px-2 py-1 rounded bg-ink text-paper text-xs disabled:opacity-40 disabled:cursor-default cursor-pointer",children:[e(tt,{size:12}),"Go"]})]}),c&&y!==null&&String(y)!==c.trim()?e("div",{className:"text-[10px] text-ink/50 font-mono",children:["line ",y," (the last line)"]}):null,c&&y===null?e("div",{className:"text-[10px] text-error font-mono",children:"Enter a line number"}):null]})})}var ft={status:"idle",payload:null,message:null};function bt(t){if(!t?.path)return"";return`${t.root??""}\x00${t.repo??""}\x00${t.path}`}function gt(t,r={}){let l=r.enabled!==!1&&Boolean(t?.path)&&t?.deviceFile!==!0,c=r.dirty===!0,p=bt(t),[h,v]=n({key:"",value:ft}),g=i(t);g.current=t;let y=i(p);y.current=p;let w=i(l);w.current=l;let x=i(c);x.current=c;let k=i(h);k.current=h;let I=i(0),C=i(""),M=i(new Map),z=i(new Set),V=a(async()=>{let A=g.current;if(!A?.path)return;let G=bt(A),Z=++I.current;C.current=G,v((R)=>({key:G,value:{status:"loading",payload:R.key===G?R.value.payload:null,message:null}}));let N=new URLSearchParams({blame:"1",file:A.path,repo:A.repo||"."});if(A.root)N.set("root",A.root);try{let R=await fetch(`/api/fs/git?${N.toString()}`),P=await R.json().catch(()=>null);if(Z!==I.current)return;if(!R.ok||!P){v({key:G,value:{status:"error",payload:null,message:P?.error??`Blame request failed (HTTP ${R.status})`}});return}v({key:G,value:P.available?{status:"ready",payload:P,message:null}:{status:"unavailable",payload:P,message:P.message??null}})}catch(R){if(Z!==I.current)return;v({key:G,value:{status:"error",payload:null,message:R instanceof Error?R.message:"Blame failed"}})}finally{if(C.current===G)C.current=""}},[]),H=a(async(A)=>{let G=M.current.get(A);if(G)return G;let Z=g.current;if(!Z?.path)return{entries:[],truncated:!1};let N=new URLSearchParams({blameHistory:"1",file:Z.path,line:String(A),repo:Z.repo||"."});if(Z.root)N.set("root",Z.root);try{let P=await(await fetch(`/api/fs/git?${N.toString()}`)).json().catch(()=>null),Q={entries:Array.isArray(P?.entries)?P.entries:[],truncated:P?.truncated===!0};return M.current.set(A,Q),Q}catch{return{entries:[],truncated:!1}}},[]),F=i(null);if(!F.current)F.current={ensure:()=>{if(!w.current||x.current)return;let A=k.current;if(A.key===y.current&&A.value.status!=="idle")return;if(C.current===y.current)return;V()},reload:()=>{M.current.clear(),V()},history:H,snapshot:()=>{let A=k.current;return A.key===y.current?A.value:ft},stale:()=>x.current,subscribe:(A)=>(z.current.add(A),()=>{z.current.delete(A)})};o(()=>{if(!l||c||!p)return;M.current.clear(),V()},[l,c,p,V]);let L=i(c);return o(()=>{if(L.current===c)return;L.current=c;for(let A of z.current)A()},[c]),o(()=>{for(let A of z.current)A()},[h]),F.current}var En="0".repeat(40);function Te(t){return t===En}function he(t,r=Date.now()){let l=Math.max(0,Math.floor(r/1000)-t);if(l<60)return"just now";let c=Math.floor(l/60);if(c<60)return`${c}m ago`;let p=Math.floor(c/60);if(p<24)return`${p}h ago`;let h=Math.floor(p/24);if(h<30)return`${h}d ago`;let v=Math.floor(h/30);if(v<12)return`${v}mo ago`;return`${Math.floor(h/365)}y ago`}function ht(t,r){switch(t){case"not-repo":return"This folder is not a git repository.";case"no-commit":return"This repository has no commits yet.";case"untracked":return"This file has never been committed, so it has no history.";case"too-large":return r??"This file is too large to blame.";case"empty":return"This file is empty.";default:return r??"git could not read this file."}}var wt="fixed z-50 w-[min(340px,92vw)] rounded-xl border border-ink/20 bg-paper p-3 shadow-xl font-sans text-xs text-ink",vt="flex items-baseline justify-between gap-2",yt="truncate text-xs font-semibold text-ink",Tn="shrink-0 font-mono text-[10px] text-ink/40",Mn="mt-1 line-clamp-2 text-[11px] leading-snug text-ink/80",Nn="mt-2 border-t border-ink/10 pt-2",Rn="flex items-center gap-2 font-mono text-[10px] text-ink/40",xt="mt-1 text-[10px] leading-snug text-ink/50",Pn="mt-2 flex w-full items-center gap-1.5 text-left text-[10px] text-ink/50 hover:text-ink cursor-pointer",Ln="mt-1.5 space-y-1 border-t border-ink/10 pt-1.5",Me="flex items-center gap-1.5 font-mono text-[10px]";function q(t,r,l){let c=document.createElement(t);if(c.className=r,l!==void 0)c.textContent=l;return c}function Bn(t){return new Date(t*1000).toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric"})}function Dn(t){let r=t.payload;if(t.status==="error")return{title:"Blame failed",body:t.message??"git could not read this file."};if(t.status==="unavailable")return{title:r?.reason==="untracked"?"Not tracked":"No history",body:ht(r?.reason??"error",t.message??void 0)};if(!r)return null;if(t.stale)return{title:"Not committed yet",body:"This line changed in the editor. Save the file to see its blame."};if(t.line>r.lines)return{title:"Not committed yet",body:`Line ${t.line} is past the end of the file at HEAD (${r.lines} lines).`};let l=r.runs.length>0?St(r,t.line):null;if(!l)return{title:"Not committed yet",body:`git has no attribution for line ${t.line}.`};if(Te(l.sha))return{title:"Not committed yet",body:"This line differs from the last commit."};return null}function St(t,r){for(let l of t.runs)if(r>=l.from&&r<=l.to)return t.commits[l.sha]??null;return null}function On(t,r){t.replaceChildren(),t.className=wt;let l=Dn(r);if(l){let w=q("div",vt);if(w.append(q("span",yt,l.title)),r.status==="error"&&r.message){let x=q("button","shrink-0 cursor-pointer text-[10px] text-ink/50 hover:text-ink","Try again");x.type="button",x.setAttribute("aria-label","Read the blame again"),w.append(x)}t.append(w,q("p",xt,l.body));return}let c=r.payload;if(!c){t.append(q("p",xt,"Reading blame…"));return}let p=St(c,r.line),h=q("div",vt);if(h.append(q("span",yt,p.author.trim()||"Unknown"),q("span",Tn,he(p.time))),t.append(h),p.summary)t.append(q("p",Mn,p.summary));let v=q("div",`${Rn} ${Nn}`);if(v.append(q("code","truncate",p.sha.slice(0,7)),q("span","",Bn(p.time))),p.mail){let w=q("span","truncate",p.mail);w.title=p.mail,v.append(w)}t.append(v);let g=q("button",Pn);if(g.type="button",g.setAttribute("aria-expanded",r.historyOpen?"true":"false"),g.textContent=`${r.historyOpen?"▾":"▸"} Line history`,t.append(g),!r.historyOpen)return;let y=q("ol",Ln);if(r.historyLoading)y.append(q("li",`${Me} text-ink/40`,"Reading history…"));else if(!r.history||r.history.entries.length===0)y.append(q("li",`${Me} text-ink/40`,"No commits touched this line."));else{let w=r.history.entries;if(w.forEach((x,k)=>{let I=q("li",Me),C=k===w.length-1?"new":"edit";I.append(q("span","text-ink/40",k===0?"●":"○"),q("code","text-ink/60",x.sha.slice(0,7)),q("span","truncate text-ink/80",x.author.trim()||"Unknown"),q("span","ml-auto shrink-0 text-ink/40",he(x.time)),q("span","shrink-0 rounded bg-ink/5 px-1 text-[8.5px] uppercase tracking-wider text-ink/45",C)),y.append(I)}),r.history.truncated)y.append(q("li",`${Me} text-ink/40`,"Older commits are not shown."))}t.append(y)}function Ct(t,r,l){let c=q("div",wt);c.setAttribute("role","dialog"),c.setAttribute("aria-label","Line blame"),c.addEventListener("mousedown",(x)=>x.stopPropagation());let p=null,h=!1,v=!1,g=()=>{let x=r.snapshot();return{line:t,status:x.status,payload:x.payload,message:x.message,stale:r.stale(),history:p,historyOpen:h,historyLoading:v}},y=()=>{On(c,g());let x=c.querySelector('[aria-label="Read the blame again"]');if(x)x.addEventListener("click",(k)=>{k.stopPropagation(),l()});c.querySelector("button[aria-expanded]")?.addEventListener("click",(k)=>{if(k.stopPropagation(),h=!h,y(),!h||p||v)return;v=!0,y(),r.history(t).then((I)=>{p=I,v=!1,y()})})};y();let w=r.subscribe(y);return{element:c,place(x){let k=c.ownerDocument.defaultView,I=k?.innerWidth??1024,C=k?.innerHeight??768,M=c.offsetWidth||340,z=c.offsetHeight||120,V=8,H=Math.max(8,Math.min(x.left,I-M-8)),F=x.bottom+6,L=x.top-z-6,U=F+z>C-8&&L>8?L:F;c.style.left=`${H}px`,c.style.top=`${Math.max(8,U)}px`},destroy(){w(),c.remove()}}}function Tt(t){return ye.define((r)=>{let l=null,c=0,p,h=()=>{clearTimeout(p),p=void 0,l?.destroy(),l=null,c=0},v=(C,M)=>{let z=C.getBoundingClientRect();if(z.width>0)return{left:z.left,top:z.top,bottom:z.bottom};let V=r.state.doc.line(Math.min(M,r.state.doc.lines)),H=null;try{H=r.coordsAtPos(V.from)}catch{H=null}if(H)return H;let F=r.scrollDOM.getBoundingClientRect();return{left:F.left,top:F.top+24,bottom:F.top+24}},g=(C,M)=>{if(c===C&&l)return;h(),c=C,l=Ct(C,t,()=>{t.reload(),h()}),document.body.append(l.element),l.place(M)},y=(C)=>{let M=C.target,z=M?.closest?.(".cm-blame-label");if(z){let F=Number(z.dataset.blameLine);return Number.isInteger(F)&&F>0?{line:F,anchor:z}:null}let V=M?.closest?.(".cm-lineNumbers .cm-gutterElement");if(!V)return null;let H=Number((V.textContent??"").trim());return Number.isInteger(H)&&H>0?{line:H,anchor:V}:null},w=(C)=>{let M=y(C);if(!M)return;g(M.line,v(M.anchor,M.line))},x=(C)=>{let M=y(C);if(M){C.preventDefault(),g(M.line,v(M.anchor,M.line));return}if(l&&!l.element.contains(C.target))h()},k=(C)=>{if(C.key==="Escape"&&l)h(),C.stopPropagation()},I=(C)=>{if(!l)return;let M=C.relatedTarget;if(M&&(l.element.contains(M)||r.scrollDOM.contains(M)))return;p=setTimeout(h,200)};return r.scrollDOM.addEventListener("mouseover",w),r.scrollDOM.addEventListener("mouseleave",I),r.scrollDOM.addEventListener("mousedown",x),document.addEventListener("mousedown",x),document.addEventListener("keydown",k,!0),{update(C){if(C.docChanged&&l)h()},destroy(){h(),r.scrollDOM.removeEventListener("mouseover",w),r.scrollDOM.removeEventListener("mouseleave",I),r.scrollDOM.removeEventListener("mousedown",x),document.removeEventListener("mousedown",x),document.removeEventListener("keydown",k,!0)}}})}var Mt=40,Rt=ae.define();function An(t){return Re.define({create:()=>({payload:t.snapshot().payload,stale:!1}),update(r,l){let c=r;for(let p of l.effects){if(!p.is(Rt))continue;c=p.value.payload!==r.payload?{payload:p.value.payload,stale:!1}:{payload:r.payload,stale:r.stale}}if(l.docChanged&&!c.stale)c={payload:c.payload,stale:!0};return c}})}function In(t,r,l){let c=t.commits[r];if(!c||Te(r))return null;let p=c.author.trim()||"Unknown";return l?p:`${p} · ${he(c.time)}`}class Pt extends Yt{constructor(t,r,l){super();this.line=t;this.text=r;this.title=l}eq(t){return t.line===this.line&&t.text===this.text&&t.title===this.title}toDOM(){let t=document.createElement("span");return t.className="cm-blame-label",t.dataset.blameLine=String(this.line),t.title=this.title,t.textContent=this.text,t}}function Nt(t,r,l){let{payload:c,stale:p}=t;if(!c?.available||p)return T.none;let h=Math.min(c.lines,r.state.doc.lines);if(h<1)return T.none;let v=r.state.doc.lineAt(Math.max(0,Math.min(r.viewport.from,r.state.doc.length))).number,g=r.state.doc.lineAt(Math.max(0,Math.min(r.viewport.to,r.state.doc.length))).number,y=Math.max(1,v-Mt),w=Math.min(h,g+Mt),x=[];for(let k of c.runs){let I=Math.max(k.from,y);if(I>k.to||I>w)continue;let C=In(c,k.sha,l);if(!C)continue;let M=c.commits[k.sha],z=r.state.doc.line(I);x.push({from:z.to,deco:T.widget({widget:new Pt(z.number,C,M.summary||M.sha),side:1})})}return T.set(x.map((k)=>k.deco.range(k.from)),!0)}function Fn(t,r){return ye.fromClass(class{constructor(l){this.view=l;this.decorations=Nt(l.state.field(t),l,r)}update(l){if(l.startState.field(t)===l.state.field(t)&&!l.docChanged&&!l.viewportChanged)return;this.decorations=Nt(l.state.field(t),l.view,r)}},{decorations:(l)=>l.decorations})}function zn(t){return ye.define((r)=>{let l=!0,c=()=>{if(!l)return;let h=t.snapshot();r.dispatch({effects:Rt.of({payload:h.payload,stale:!1})})},p=t.subscribe(c);return{destroy(){l=!1,p()}}})}function Lt({controller:t,inline:r=!0,compact:l=!1}){let c=An(t);return[c,zn(t),r?Fn(c,l):[],Tt(t)]}function Bt({activeFile:t,editor:r,find:l,surfaceRef:c,goToLineRequest:p,rootPath:h=null,repoPath:v=null,onRunCommand:g,wordWrap:y,zoomLevel:w,setZoomLevel:x,editorFontFamily:k,editorTheme:I,viewerKind:C,isPreview:M,reviewActive:z,onToggleReview:V,revealActive:H}){let F=C==="markdown",L=ru(),U=ou(),A=Bd(),G=gt({name:t.name,path:t.path,root:t.root??h??void 0,repo:t.repo??v??"."},{enabled:A.enabled,dirty:r.isDirty}),Z=u(()=>A.enabled?Lt({controller:G,inline:A.inline}):null,[A.enabled,A.inline,G]),[N,R]=n(null),P=u(()=>$c(r.content),[r.content]),[Q,X]=n(!1);o(()=>{if(p>0)X(!0)},[p]);let[j,ne]=n(null),[ce,ee]=n(null);mt(j,x);let te=ol({tabKey:String(t.id),surface:F&&M?"rendered":"code",ready:r.loaded,element:F&&M?void 0:j}),me=a((se)=>{te.ref(se),ee(se)},[te.ref]);return Gc({path:t.path,scroller:ce,preview:F&&M}),e("div",{className:"relative flex-1 min-h-0 flex flex-col",children:[l.open?e(Uc,{find:l}):null,Q?e(pt,{lineCount:r.content?r.content.split(`
|
|
2
|
+
`).length:1,onGo:(se)=>{X(!1);let le=gr(r.content,se-1);c.current?.select(le,le,!0),c.current?.revealOffset(le)},onClose:()=>X(!1)}):null,F&&M?e(dt,{content:r.content,file:{name:t.name,path:t.path,root:t.root,repo:t.repo},zoomLevel:w,reviewActive:z,onExitReview:V,scrollRef:me,onScroll:te.onScroll}):e(zc,{ref:c,value:r.content,onValueChange:r.onChange,language:r.language,wordWrap:y,documentKey:String(t.id),marks:l.open||H?l.matches:void 0,currentMark:l.currentIndex,onCommand:g,onScroller:ne,onCaret:R,scrollTestId:"editor-scroller",className:"flex-1 min-h-0 text-ink select-text",blame:Z,themeVars:I.vars,themes:I.themes,indentUnitText:nu(L),typing:U,padding:16,placeholder:"This file is empty",style:{fontFamily:k,fontSize:`${w}px`,lineHeight:Vs}}),!F||!M?e(ct,{caret:N,eol:r.eol,onSetEol:r.setEol,indentWidth:L.width,insertSpaces:L.insertSpaces,language:r.language,byteViewer:r.isBinaryViewer,viewerKind:C,lineCount:r.content?r.content.split(`
|
|
3
|
+
`).length:0,conflicts:P}):null]})}function Dt({activeFile:t,editor:r,find:l,surfaceRef:c,pluginFileView:p,wordWrap:h,setWordWrap:v,viewerKind:g,isPreview:y,isReviewing:w,onToggleReview:x,isMaximized:k,setIsMaximized:I,zoomLevel:C,setZoomLevel:M,goToLineRequest:z,onSaveAs:V,rootPath:H=null,repoPath:F=null,runCommand:L,editorFontFamily:U,editorTheme:A,togglePreview:G,revealActive:Z,missing:N}){let R=g==="image"||g==="pdf"||g==="docx"||g==="spreadsheet",P=ds[g]===!0,Q=a(async(X)=>{let j=await Wc(t,X,{interactive:!0,baseMtimeMs:r.baseMtimeMs});if(j.status==="written")return{ok:!0};if(j.status==="conflict")return{ok:!1,error:"This file changed on disk since it was opened."};if(j.status==="needs-permission")return{ok:!1,error:"Click Save again to grant write access."};return{ok:!1,error:j.error}},[t,r.baseMtimeMs]);return e(d,{children:[e(lt,{path:t.path,saveStatus:r.saveStatus,wordWrap:h,hasPreview:P,isPreview:y,hasReview:g==="markdown"&&y,isReviewing:w,copied:r.copied,byteViewer:R,saveDisabled:Boolean(r.loadError)||r.handleMissing||r.deviceBacked,unsupported:Boolean(r.unsupported),handleMissing:r.handleMissing,readOnly:r.deviceBacked,isMaximized:k,findOpen:l.open,onToggleFind:()=>l.open?l.close():l.openFind(),onSave:r.saveNow,onTogglePreview:G,onToggleReview:x,onToggleWordWrap:()=>v(!h),onZoomIn:()=>M((X)=>Math.min(Js,X+1)),onZoomOut:()=>M((X)=>Math.max(Ys,X-1)),onCopy:r.copy,onDownload:r.download,onReload:r.reloadFromDisk,onSaveAs:V,canReload:fl(t)&&!r.loadError&&!r.unsupported,refreshing:r.isReading,reloadDiscardsEdits:r.isDirty,onToggleMaximize:()=>I(!k)}),N&&e("div",{className:"flex items-start gap-2 px-3 py-2 border-b border-error/30 bg-error/10 text-error",children:[e(_,{size:14,className:"shrink-0 mt-0.5"}),e("div",{className:"min-w-0",children:[e("div",{className:"text-[11.5px] font-sans",children:"This file was deleted from disk."}),e("div",{className:"text-[11px] font-sans text-error/80",children:"The buffer is still here. Saving recreates the file — autosave is off until then."})]})]}),r.conflict&&e(Ee,{diskMtimeMs:r.conflict.diskMtimeMs,fileName:t.name,onReload:r.resolveConflictByReload,onKeepMine:r.resolveConflictByKeepingMine}),r.handleMissing&&e("div",{className:"flex items-start gap-2 px-3 py-2 border-b border-warning/30 bg-warning/10 text-warning",children:[e(_,{size:14,className:"shrink-0 mt-0.5"}),e("div",{className:"min-w-0",children:[e("div",{className:"text-[11.5px] font-sans",children:"This file was opened by the system, not from a workspace."}),e("div",{className:"text-[11px] font-sans text-warning/80",children:"Its write permission ended with the last page load. Reopen the file from the OS to edit it again."})]})]}),r.deviceBacked&&e("div",{className:"flex items-start gap-2 px-3 py-2 border-b border-ink/20 bg-ink/5 text-ink/70",children:[e(_,{size:14,className:"shrink-0 mt-0.5"}),e("div",{className:"min-w-0",children:[e("div",{className:"text-[11.5px] font-sans",children:r.deviceMissing?"The bytes for this file did not survive the reload.":"Opened from this device, so it is read-only here."}),e("div",{className:"text-[11px] font-sans text-ink/50",children:r.deviceMissing?"A phone's file lives only on the phone, so it cannot be re-read. Open it again from the app that shared it.":"The console cannot reach a file on your phone. Copy it into a workspace to edit it."})]})]}),r.isImage&&r.imageUrl?e(gi,{src:r.imageUrl,name:t.name,className:"flex-1 min-h-0"}):r.isImage?e(ml,{kind:"image",path:t.path,name:t.name,source:r.byteSource,content:r.content,revision:r.revision}):r.isLoading?e("div",{className:"flex-1 flex items-center justify-center gap-2 text-ink/40 text-xs font-mono",children:[e(m,{size:14,className:"animate-spin"}),e("span",{children:"Loading file content…"})]}):r.unsupported?e("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 px-6 text-center",children:[e(Mc,{size:20,className:"text-ink/40"}),e("span",{className:"text-xs text-ink/70 font-sans",children:[t.name," cannot be opened here"]}),e("span",{className:"text-[11px] text-ink/50 font-sans max-w-[42ch]",children:r.unsupported})]}):r.loadError?e("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 px-6 text-center",children:[e(_,{size:20,className:"text-error"}),e("span",{className:"text-xs text-error font-sans",children:["Could not read ",t.name]}),e("span",{className:"text-[11px] text-ink/50 font-mono break-all",children:r.loadError})]}):p&&!r.isImage?e(xg,{view:p}):qc(g)&&(R||y)?e(ml,{kind:g,path:t.path,name:t.name,source:r.byteSource,content:r.content,revision:r.revision,onContentChange:r.onChange,onSaveBytes:r.deviceBacked?void 0:Q,onDirtyChange:r.setBinaryDirty}):e(Bt,{activeFile:t,editor:r,find:l,surfaceRef:c,goToLineRequest:z,rootPath:H,repoPath:F,onRunCommand:L,wordWrap:h,zoomLevel:C,setZoomLevel:M,editorFontFamily:U,editorTheme:A,isPreview:y,reviewActive:w,onToggleReview:x,viewerKind:g,revealActive:Z})]})}function Ot({activeFile:t,editor:r,find:l,surfaceRef:c,pluginFileView:p,wordWrap:h,setWordWrap:v,viewerKind:g,isPreview:y,isReviewing:w,onToggleReview:x,isMaximized:k,setIsMaximized:I,zoomLevel:C,setZoomLevel:M,goToLineRequest:z,onSaveAs:V,rootPath:H=null,repoPath:F=null,runCommand:L,editorFontFamily:U,editorTheme:A,togglePreview:G,revealActive:Z,missing:N,onConvertDiffToEditor:R,onFileSaved:P}){if(!t)return e("div",{className:"flex-1 flex items-center justify-center text-ink/40",children:e("p",{className:"font-mono text-sm",children:"Select a tab to view content"})});if(t.isDiff)return e(Pc,{filePath:t.path,status:t.diffStatus||"M",isStaged:Boolean(t.diffStaged),root:t.root,repo:t.repo||".",journalDiff:t.journalDiff,readOnly:t.diffSource==="journal",onOpenInEditor:()=>R(t.id),onFileSaved:P,className:"flex-1",tabKey:String(t.id)});return e(Dt,{activeFile:t,editor:r,find:l,surfaceRef:c,pluginFileView:p,wordWrap:h,setWordWrap:v,viewerKind:g,isPreview:y,isReviewing:w,onToggleReview:x,isMaximized:k,setIsMaximized:I,zoomLevel:C,setZoomLevel:M,goToLineRequest:z,onSaveAs:V,rootPath:H,repoPath:F,runCommand:L,editorFontFamily:U,editorTheme:A,togglePreview:G,revealActive:Z,missing:N})}function At({pluginId:t,Component:r,sessionId:l,className:c=""}){return e("div",{className:`flex flex-col h-full bg-canvas ${c}`,children:e(Ve,{pluginId:t,children:e(r,{sessionId:l,workspacePath:null})})})}function It({className:t=""}){return e("div",{className:`flex flex-col h-full bg-canvas items-center justify-center text-muted ${t}`,children:[e(it,{name:"placeholder.txt",size:48,className:"mb-4 opacity-20"}),e("p",{className:"font-mono text-sm",children:"Select a file to open"})]})}function Ft({searchReveal:t,revealMatch:r}){let l=i(r);l.current=r;let c=i(null);o(()=>{if(!t||c.current===t.request)return;c.current=t.request,l.current({query:t.request.query,options:t.request.options,line:t.request.line})},[t])}function zt({openedFiles:t,dirtyKeys:r,activeFile:l,previewReady:c,setPreviewMode:p,sessionId:h}){o(()=>{let v=new Set(t.filter((g)=>!g.isDiff&&g.content===void 0).map((g)=>g.id));$e([...r].filter((g)=>v.has(g)))},[r,t]),o(()=>{if(!c)return;let v=l?.id;if(!l||v===void 0||v===null)return;if(!ds[ps(l.name)])return;let g=Se(h,"editor.previewMode");if(g&&g[v]!==void 0)return;p((y)=>y[v]===void 0?{...y,[v]:!0}:y)},[c,l])}function Ht({activeFile:t,externalChange:r,conflict:l,onReload:c,onKeepMine:p}){if(!t)return null;if(l)return e(Ee,{diskMtimeMs:l.diskMtimeMs,fileName:t.name,onReload:c,onKeepMine:p});if(r)return e(Zc,{fileName:t.name,onReload:c,onKeepMine:p});return null}async function $t(t){let r=t.name.trim();if(!r)return{status:"failed",reason:"Enter a file name."};let l=new FormData;if(l.append("actionType","saveAs"),l.append("path",t.parent),l.append("name",r),l.append("content",t.content),l.append("eol",t.eol),t.root)l.append("root",t.root);if(t.repo&&t.repo!==".")l.append("repo",t.repo);try{let c=await fetch("/api/fs/action",{method:"POST",body:l}),p=await c.json().catch(()=>null),h=typeof p?.error==="string"?p.error:null;if(c.status===409)return{status:"exists",reason:h??`${r} already exists.`};if(c.ok&&p?.success&&typeof p.path==="string")return{status:"written",path:p.path};return{status:"failed",reason:h??"The file could not be written."}}catch{return{status:"failed",reason:"The file could not be written."}}}function Vt(t){let r=t.lastIndexOf(".");if(r<=0)return`${t} copy`;return`${t.slice(0,r)} copy${t.slice(r)}`}function Wt(t){let r=t.trim();if(!r)return!1;if(r==="."||r==="..")return!1;return!r.includes("/")&&!r.includes("\\")}function Hn(t){let r=t.lastIndexOf("/");return r===-1?"":t.slice(0,r)}function Kt({fileName:t,filePath:r,content:l,eol:c,root:p,repo:h,onSaved:v,onClose:g}){let[y,w]=n(()=>Hn(r)),[x,k]=n(()=>Vt(t)),[I,C]=n(!1),[M,z]=n(null),V=i(null);o(()=>{V.current?.focus(),V.current?.select()},[]);let H=Wt(x),F=async()=>{if(!H||I)return;C(!0),z(null);let U=await $t({parent:y,name:x,content:l,eol:c,root:p,repo:h});if(C(!1),U.status==="written"){v({path:U.path});return}z(U.reason)},L=(U)=>{if(U.key==="Enter"){U.preventDefault(),F();return}if(U.key==="Escape")U.preventDefault(),g()};return e(J,{onClose:g,maxWidthClass:"max-w-md",header:e("span",{className:"text-sm font-semibold text-ink",children:"Save as"}),footer:e("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-ink/10",children:[e("button",{type:"button",onClick:g,className:"px-3 py-1.5 rounded border border-ink/20 text-ink/80 hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),e("button",{type:"button",onClick:()=>void F(),disabled:!H||I,className:"flex items-center gap-1.5 px-3 py-1.5 rounded bg-ink text-paper disabled:opacity-40 disabled:cursor-default cursor-pointer",children:[I?e(m,{size:12,className:"animate-spin"}):e(tt,{size:12}),"Save"]})]}),children:e("div",{className:"px-4 py-3 space-y-2 text-xs",children:[e("label",{className:"block",children:[e("span",{className:"block text-[10px] uppercase tracking-wide text-ink/50 mb-1",children:"Folder"}),e("input",{value:y,onInput:(U)=>w(U.target.value),onKeyDown:L,placeholder:"(workspace root)","aria-label":"Destination folder",className:"w-full bg-paper border border-ink/20 rounded px-2 py-1 font-mono text-ink outline-none focus:border-ink/40"})]}),e("label",{className:"block",children:[e("span",{className:"block text-[10px] uppercase tracking-wide text-ink/50 mb-1",children:"Name"}),e("input",{ref:V,value:x,onInput:(U)=>k(U.target.value),onKeyDown:L,"aria-label":"File name","aria-invalid":!H,className:`w-full bg-paper border rounded px-2 py-1 font-mono text-ink outline-none ${H?"border-ink/20 focus:border-ink/40":"border-error text-error"}`})]}),!H?e("div",{className:"text-[10px] text-error font-mono",children:"Enter a file name without a path separator"}):null,M?e("div",{className:"text-[10px] text-error font-mono",children:M}):null,e("div",{className:"text-[10px] text-ink/40",children:"The original file stays where it is, and its tab stays open."})]})})}function Ut(){o(()=>{let t=(r)=>{if(!_e())return;r.preventDefault(),r.returnValue=""};return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)},[])}function _t({fileName:t,onAnswer:r}){return e(J,{onClose:()=>r("cancel"),header:e("div",{className:"flex items-center gap-2",children:[e(_,{size:15,className:"text-warning"}),e("span",{className:"text-sm font-semibold text-ink",children:"Unsaved changes"})]}),footer:e("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-ink/10",children:[e("button",{type:"button",onClick:()=>r("cancel"),className:"px-3 py-1.5 rounded border border-ink/20 text-ink/80 hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),e("button",{type:"button",onClick:()=>r("discard"),className:"px-3 py-1.5 rounded border border-error/40 text-error hover:bg-error/10 transition-colors cursor-pointer",children:"Discard"}),e("button",{type:"button",onClick:()=>r("save"),className:"px-3 py-1.5 rounded bg-ink text-paper hover:bg-ink/90 transition-colors cursor-pointer",children:"Save & close"})]}),children:e("div",{className:"px-4 py-3 text-xs text-ink/80",children:[e("span",{className:"font-mono text-ink",children:t})," has changes that are not on disk.",e("div",{className:"mt-1 text-ink/50",children:"Discarding them cannot be undone."})]})})}function Gt({closeGuard:t,activeFile:r,saveMissingConfirm:l,onCancelSaveMissing:c,onConfirmSaveMissing:p}){if(t.pending)return e(_t,{fileName:t.pending.name,onAnswer:t.answer});if(l&&r)return e(Xc,{fileName:r.name,filePath:r.path,onClose:c,onConfirm:p});return null}function qt({className:t="",isMaximized:r,onKeyDownCapture:l,onFocusCapture:c,asSplitPane:p,tabs:h,activeFile:v,editor:g,externalChange:y,conflict:w,onReload:x,onKeepMine:k,body:I,saveAsOpen:C,onSaveAsClose:M,onSavedAs:z,closeGuard:V}){let H=r?"fixed inset-0 z-50 flex flex-col bg-canvas":`flex flex-col h-full bg-canvas ${t}`;return e("div",{className:H,onKeyDownCapture:l,onFocusCapture:c,children:[p?null:h,e(Ht,{activeFile:v,externalChange:y,conflict:w,onReload:x,onKeepMine:k}),I,C&&v?e(Kt,{fileName:v.name,filePath:v.path,content:g.content,eol:g.eol,root:v.root,repo:v.repo,onSaved:({path:F})=>z(F),onClose:M}):null,e(Gt,{closeGuard:V,activeFile:v,saveMissingConfirm:g.saveMissingConfirm,onCancelSaveMissing:g.cancelSaveMissing,onConfirmSaveMissing:g.confirmSaveMissing})]})}function Zt({fileName:t,onClose:r,children:l}){return e("div",{className:"flex flex-col h-full min-w-0","data-split-pane":"",children:[e("div",{className:"flex items-center justify-between gap-2 px-3 py-1 border-b border-ink/10 bg-canvas flex-shrink-0",children:[e("span",{className:"text-[11px] font-mono text-ink/60 truncate",title:t,children:t}),e("button",{type:"button",onClick:r,className:"p-0.5 rounded hover:bg-ink/10 text-ink/50 hover:text-ink transition-colors cursor-pointer flex-shrink-0",title:"Close this pane (the tab stays open)","aria-label":"Close split pane",children:e(b,{size:12})})]}),e("div",{className:"flex-1 min-h-0",children:l})]})}function Xt({fraction:t,onFraction:r,rightPaneName:l,onClosePane:c,rightPane:p,children:h}){let v=i(null),g=i(null),y=Rm(g),w=(x)=>{let k=x.currentTarget,I=v.current;if(!k||!I)return;k.setPointerCapture(x.pointerId);let C=(z)=>{let V=I.getBoundingClientRect();if(V.width===0)return;r(ue((z.clientX-V.left)/V.width))},M=()=>{k.releasePointerCapture(x.pointerId),k.removeEventListener("pointermove",C),k.removeEventListener("pointerup",M)};k.addEventListener("pointermove",C),k.addEventListener("pointerup",M)};return e("div",{ref:v,className:"flex w-full h-full","data-split-column":"",children:[e("div",{className:"flex flex-col min-w-0 h-full",style:{width:`${Math.round(ue(t)*100)}%`},children:h}),e("div",{ref:g,className:`w-[3px] flex-shrink-0 cursor-col-resize transition-colors active:bg-ink/40 ${y?"bg-ink/40":"bg-ink/10"}`,role:"separator","aria-orientation":"vertical","aria-label":"Resize split panes",onPointerDown:w}),e("div",{className:"flex-1 min-w-0 h-full",children:e(Zt,{fileName:l,onClose:c,children:p})})]})}function jt({openedFiles:t,activeFileId:r,enabled:l}){let[c,p]=S("editor.split",ge),h=t.map((k)=>k.id),v=je(Je(c,h),r),g=l&&v.rightFileId!==null?t.find((k)=>k.id===v.rightFileId)??null:null,y=a((k)=>{if(k!==null&&!Ce(k,r,h))return;p({...v,rightFileId:k})},[v,p,r,h]),w=a(()=>p({...v,rightFileId:null}),[v,p]),x=a((k)=>p({...v,fraction:ue(k)}),[v,p]);return{rightFile:g,fraction:v.fraction,splitTo:y,close:w,setFraction:x}}function Jt({find:t,runCommand:r,reopenClosed:l}){let c=i(t);c.current=t;let p=i(r);p.current=r;let h=i(l);return h.current=l,{onKeyDownCapture:a((g)=>{let y=c.current;if(g.key==="Escape"){if(!y.open)return;g.preventDefault(),g.stopPropagation(),y.close();return}if((g.metaKey||g.ctrlKey)&&g.shiftKey&&g.code==="KeyT"){if(h.current?.())g.preventDefault(),g.stopPropagation();return}let w=KA(mi,g);if(!w||!lf(w))return;g.preventDefault(),g.stopPropagation(),p.current(w)},[])}}function Qt(t){let r=i(t);r.current=t;let l=i(null);if(!l.current)l.current={saveNow:()=>r.current.saveNow(),runCommand:(p)=>r.current.runCommand(p)};return o(()=>{let p=l.current;if(!p)return;return Ag(p)},[]),{onFocusCapture:a(()=>{if(l.current)Ag(l.current)},[])}}function tn({openedFiles:t,activeFileId:r,onSelectFile:l,onCloseFile:c,saveNow:p}){let[h,v]=n(null);Ut();let g=a((w)=>{let x=t.find((k)=>k.id===w);if(x&&Ke(w)){v(x);return}c(w)},[t,c]),y=a((w)=>{let x=h;if(!x)return;if(w==="cancel"){v(null);return}if(w==="save"){if(x.id!==r)l(x.id);p()}v(null),c(x.id)},[h,r,l,p,c]);return{requestClose:g,pending:h,answer:y}}function nn(){let[t,r]=n(0),[l,c]=n(!1),p=a(()=>r((h)=>h+1),[]);return{goToLineRequest:t,openGoToLine:p,saveAsOpen:l,setSaveAsOpen:c}}function $n({className:t="",openedFiles:r,activeFileId:l,onSelectFile:c,onCloseFile:p,onConvertDiffToEditor:h,refreshKey:v=0,onFileSaved:g,onOpenPath:y,onReopenClosed:w,reopenableCount:x,onCopyPath:k,onRevealInFiles:I,rootPath:C=null,repoPath:M=null,activeEditorPanelKey:z=null,forcedActiveFileId:V=null,asSplitPane:H=!1}){let F=H?V:l,L=r.find((K)=>K.id===F),[U,A,G]=S("editor.previewMode",{}),Z=eu(String(F??"")),[N,R]=S("editor.zoomLevel",_o),[P,Q]=n(!1),[X,j]=S("editor.wordWrap",!0),ne=nn(),{sessionId:ce}=Ze(),ee=jt({openedFiles:r,activeFileId:F,enabled:!H}),te=i(null),me=To(),se=Ai(),le=Hc(r,v),be=Boolean(L&&le.has(L.id)),Y=Kc(L??null,{reportSaveError:!0,onFileSaved:g,missing:be}),on=kg({path:L?.path??"",content:Y.content,language:Y.language}),rn=Y.diskChange,Oe=tn({openedFiles:r,activeFileId:F,onSelectFile:c,onCloseFile:p,saveNow:Y.saveNow}),ve=Vc({text:Y.content,documentKey:`${L?.id??""}\x00${Y.language}`,readSelection:()=>te.current?.getSelection()??null,select:(K,de,Le=!0)=>te.current?.select(K,de,Le),reveal:(K)=>te.current?.revealOffset(K),applyDocument:(K,de,Le)=>te.current?.applyDocument(K,de,Le),toggleWordWrap:()=>j((K)=>!K)}),Ae=Yc(L?.path??null,Y.content,Y.loaded&&!Y.loadError);Ft({searchReveal:Ae,revealMatch:ve.revealMatch}),Jc({file:L,editor:Y,surfaceRef:te,isPreview:L?U[L.id]===!0:!1,exitPreview:()=>{let K=L?.id;if(K===void 0||K===null)return;A((de)=>({...de,[K]:!1}))}}),o(()=>{if(v>0)Y.reset()},[v]),o(()=>{Y.retain(r.map((K)=>K.id)),We(r.map((K)=>K.id))},[r]),zt({openedFiles:r,dirtyKeys:Y.dirtyKeys,activeFile:L,previewReady:G,setPreviewMode:A,sessionId:ce});let an=()=>{if(!L)return;A((K)=>({...K,[L.id]:!K[L.id]}))},Ne=(K)=>{if(lf(K)){ve.runCommand(K);return}if(K==="toggleWordWrap"){j((de)=>!de);return}if(K==="goToLine"){ne.openGoToLine();return}te.current?.runCommand(K)},sn=Jt({find:ve,runCommand:Ne,reopenClosed:w}),dn=Qt({saveNow:Y.saveNow,runCommand:Ne}),Pe=sh(z);if(Pe)return e(At,{pluginId:Pe.pluginId,Component:Pe.Component,sessionId:ce,className:t});if(r.length===0)return e(It,{className:t});let cn=Y.viewerKind,Ie=L?U[L.id]:!1,mn={activeFile:L,editor:Y,find:ve,surfaceRef:te,pluginFileView:on,wordWrap:X,setWordWrap:j,viewerKind:cn,isPreview:Boolean(Ie),isReviewing:Boolean(Ie)&&Z.active,onToggleReview:Z.toggle,isMaximized:P,setIsMaximized:Q,zoomLevel:N,setZoomLevel:R,goToLineRequest:ne.goToLineRequest,onSaveAs:()=>ne.setSaveAsOpen(!0),onOpenPath:y,rootPath:C,repoPath:M,runCommand:Ne,editorFontFamily:me,editorTheme:se,togglePreview:an,revealActive:Boolean(Ae),missing:be,onConvertDiffToEditor:h,onFileSaved:g},un=(K)=>({openedFiles:r,activeFileId:l,onSelectFile:c,onCloseFile:p,onConvertDiffToEditor:h,refreshKey:v,onFileSaved:g,onOpenPath:y,rootPath:C,repoPath:M,forcedActiveFileId:K,asSplitPane:!0}),pn=e(nt,{openedFiles:r,activeFileId:l,onSelectFile:c,onCloseFile:Oe.requestClose,missingIds:le,onCopyPath:k,onRevealInFiles:I,onReopenClosed:w,reopenableCount:x,onSplitTo:ee.splitTo,onUnsplit:ee.close,splitRightFileId:ee.rightFile?.id??null}),Fe=e(qt,{className:t,isMaximized:P,onKeyDownCapture:sn.onKeyDownCapture,onFocusCapture:dn.onFocusCapture,asSplitPane:H,tabs:pn,activeFile:L,editor:Y,externalChange:rn,conflict:Y.conflict,onReload:Y.resolveConflictByReload,onKeepMine:Y.keepMineAgainstDisk,body:e(Ot,{...mn}),saveAsOpen:ne.saveAsOpen,onSaveAsClose:()=>ne.setSaveAsOpen(!1),onSavedAs:(K)=>{ne.setSaveAsOpen(!1),y?.(K)},closeGuard:Oe});if(!ee.rightFile)return Fe;return e(Xt,{fraction:ee.fraction,onFraction:ee.setFraction,rightPaneName:ee.rightFile.name,onClosePane:ee.close,rightPane:e($n,{...un(ee.rightFile.id)}),children:Fe})}export{$n as Editor};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d,n,o,i,a,e,s,E,ne,De,Le,_,Zo,tt,Se,_e,b,ee,si,Lm}from"./index-4c2zcvem.js";var B={name:"list-filter",size:24,node:[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]]},M=s(B);function I({title:t,options:r,methodLabel:p,badge:m,icon:x,onCancel:g}){let f=si({title:t,options:r})?Lm(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(Le,{size:9,className:"text-ink/40"}),m]})]}),e("p",{className:"mt-0.5 text-[11px] text-ink/50",children:f?"The agent wants to run this. Review it before you allow.":"Autonomous agent inquiry requiring user confirmation"})]})]}),e("button",{type:"button",onClick:g,"aria-label":"Close dialog (Esc)",title:"Cancel (Esc)",className:"flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded-lg border border-ink/10 text-ink/45 transition-colors hover:border-ink/25 hover:bg-ink/5 hover:text-ink",children:e(b,{size:14})})]})}function T({options:t,optionDetails:r,selectedOption:p,customValue:m,onCustomChange:x,customInputRef:g,onSelect:f,onConfirmOption:h,hideCustomAnswer:l=!1}){return e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Available Options"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:["Press [1-",Math.min(9,t.length),"] to choose"]})]}),e("div",{className:"grid gap-2",role:"radiogroup",children:t.map((k,y)=>{let u=p===k,v=r[y]?.description;return e("button",{type:"button",onClick:()=>f(k),onDblClick:()=>h(k),"aria-checked":u,role:"radio",className:`group flex w-full cursor-pointer items-start gap-3 rounded-xl border p-3.5 text-left transition-all ${u?"border-ink bg-paper shadow-sm ring-1 ring-ink/10":"border-ink/10 bg-canvas/30 hover:border-ink/25 hover:bg-paper"}`,children:[e("span",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md font-mono text-[11px] font-semibold transition-colors ${u?"bg-ink text-paper":"border border-ink/15 bg-paper text-ink/60 group-hover:border-ink/30 group-hover:text-ink"}`,children:y+1}),e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"flex items-center gap-2",children:e("span",{className:`text-[13px] font-medium leading-snug ${u?"text-ink font-semibold":"text-ink/85"}`,children:k})}),v&&e("div",{className:"mt-1 text-[11.5px] leading-relaxed text-ink/55",children:v})]}),e("span",{className:"mt-0.5 shrink-0",children:u?e(ne,{size:16,className:"text-ink"}):e(Zo,{size:16,className:"text-ink/20 group-hover:text-ink/40"})})]},k)})}),!l&&e("div",{className:"space-y-1.5 pt-1",children:[e("div",{className:"text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:"Other: type your own answer"}),e("input",{ref:g,type:"text",value:m,placeholder:"Type a custom answer and press Enter...",onChange:(k)=>x(k.currentTarget.value),onKeyDown:(k)=>{if(k.key==="Enter"){if(k.preventDefault(),k.stopPropagation(),m.trim())h(m.trim())}},className:"w-full rounded-xl border border-ink/15 bg-paper px-4 py-3 text-[13.5px] text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:ring-2 focus:ring-ink/15"})]})]})}function S({method:t,optionsLength:r,selectedOption:p,hasCustomAnswer:m=!1,onCancel:x,onSubmit:g}){let f=t==="select"&&!p&&!m;return e("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t border-ink/8 bg-canvas/40 px-5 py-3.5",children:[e("div",{className:"flex items-center gap-2 font-mono text-[11px] text-ink/50",children:[t==="select"&&e(d,{children:[e("span",{className:"hidden items-center gap-1 sm:inline-flex",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:["1-",Math.min(9,r)]}),e("span",{className:"text-ink/40",children:"choose"})]}),e("span",{className:"hidden text-ink/30 sm:inline",children:"•"}),e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"↵"}),e("span",{className:"text-ink/40",children:"select"})]})]}),t==="confirm"&&e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"↵"}),e("span",{className:"text-ink/40",children:"confirm"})]}),t==="editor"&&e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"⌘↵"}),e("span",{className:"text-ink/40",children:"save buffer"})]}),e("span",{className:"text-ink/30",children:"•"}),e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"Esc"}),e("span",{className:"text-ink/40",children:"cancel"})]})]}),e("div",{className:"flex items-center gap-2.5 ml-auto",children:[e("button",{type:"button",onClick:x,className:"flex cursor-pointer items-center gap-1 rounded-lg border border-ink/15 bg-paper px-3.5 py-1.5 text-[12px] font-medium text-ink/70 transition-colors hover:border-ink/30 hover:bg-canvas/50 hover:text-ink",children:[e(b,{size:12,className:"opacity-60"}),e("span",{children:"Cancel"})]}),e("button",{type:"button",onClick:g,disabled:f,className:"flex cursor-pointer items-center gap-1.5 rounded-lg bg-ink px-4 py-1.5 text-[12px] font-semibold text-paper shadow-xs transition-all hover:opacity-90 active:scale-[0.98] disabled:cursor-not-allowed disabled:opacity-35",children:[e("span",{children:t==="confirm"?"Confirm":t==="select"?"Select Option":"Submit Response"}),e(tt,{size:12,className:"opacity-70"})]})]})]})}function P({title:t,options:r}){let p=si({title:t,options:r})?Lm(t):null;if(!p)return null;return e("div",{className:"space-y-2",children:[p.reason&&e("div",{className:"flex items-start gap-2 rounded-xl border border-warning/25 bg-warning/8 px-3.5 py-2.5 text-[12px] leading-relaxed text-ink/80",children:[e(_,{size:13,className:"mt-0.5 shrink-0 text-warning"}),e("span",{className:"min-w-0 break-words",children:p.reason})]}),p.details.length>0&&e("div",{className:"rounded-xl border border-ink/10 bg-canvas/40 px-3.5 py-2.5",children:p.details.map((m,x)=>e("div",{className:"font-mono text-[11.5px] leading-relaxed text-ink/75 break-all",children:m},`${x}-${m}`))})]})}function R({method:t,options:r,selectedOption:p,onSelectOption:m,customInputRef:x,onSubmit:g,onCancel:f}){o(()=>{let h=(l)=>{if(l.key==="Escape"){l.preventDefault(),l.stopPropagation(),f();return}if(t==="select"&&r.length>0){if(l.target instanceof HTMLInputElement&&l.target===x.current)return;let y=parseInt(l.key,10);if(!isNaN(y)&&y>=1&&y<=r.length){l.preventDefault(),m(r[y-1]);return}if(l.key==="ArrowDown"){l.preventDefault();let u=r.findIndex((N)=>N===p),v=u<r.length-1?u+1:0;m(r[v]);return}if(l.key==="ArrowUp"){l.preventDefault();let u=r.findIndex((N)=>N===p),v=u>0?u-1:r.length-1;m(r[v]);return}if(l.key==="Enter"&&p){l.preventDefault(),g();return}}if(t==="confirm"){if(l.key==="Enter"){l.preventDefault(),g();return}}if(t==="editor"){if((l.metaKey||l.ctrlKey)&&l.key==="Enter"){l.preventDefault(),g();return}}};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[f,g,t,r,p,m,x])}function L(t,r){switch(t){case"select":return{icon:e(M,{size:16,className:"text-ink"}),label:"Decision Required",badge:`${r} Choices`};case"confirm":return{icon:e(E,{size:16,className:"text-ink"}),label:"Confirmation Required",badge:"Confirm Action"};case"input":return{icon:e(_e,{size:16,className:"text-ink"}),label:"Prompt Input",badge:"Text Input"};case"editor":return{icon:e(Se,{size:16,className:"text-ink"}),label:"Buffer Editor",badge:"Multiline Buffer"};default:return{icon:e(De,{size:16,className:"text-ink"}),label:"Agent Request",badge:"Input"}}}function ke({request:t,onRespond:r}){let[p,m]=n(t.method==="editor"?t.prefill??"":""),[x,g]=n(null),[f,h]=n(""),l=i(null),k=i(null),y=i(null),u=i(null),v=t.options??[],N=t.optionDetails??[],C=si(t);o(()=>{let c=t.options??[];m(t.method==="editor"?t.prefill??"":""),g(c.length>0?c[0]:null),h("")},[t]),o(()=>{if(l.current?.focus(),t.method==="input")k.current?.focus();else if(t.method==="editor")y.current?.focus();else if(t.method==="select"){if((t.options??[]).some((H)=>/^other\b/i.test(H.trim())))u.current?.focus()}},[t]);let w=a(()=>{r(t,{cancelled:!0})},[r,t]),A=a(()=>{if(t.method==="confirm")r(t,{confirmed:!0});else if(t.method==="select"){if(f.trim()&&!C)r(t,{value:f.trim()});else if(x)r(t,{value:x})}else r(t,{value:p})},[r,t,x,p,f,C]),O=a((c)=>{if(/^other\b/i.test(c.trim())){g(c),u.current?.focus();return}r(t,{value:c})},[r,t]),z=a((c)=>{if(g(c),/^other\b/i.test(c.trim()))u.current?.focus()},[]);R({method:t.method,options:v,selectedOption:x,onSelectOption:g,customInputRef:u,onSubmit:A,onCancel:w});let D=L(t.method,v.length);return e("div",{className:"extension-dialog-backdrop modal-scrim fixed inset-0 z-50 flex items-center justify-center p-4 sm:p-6 backdrop-blur-[8px]",onMouseDown:(c)=>{if(c.target===c.currentTarget)w()},children:e("div",{ref:l,role:"dialog","aria-modal":"true","aria-label":t.title||D.label,tabIndex:-1,className:"glass-overlay extension-dialog-panel w-full max-w-[560px] overflow-hidden rounded-2xl border border-ink/15 bg-paper shadow-2xl outline-none",style:{boxShadow:"0 24px 64px -8px color-mix(in srgb, var(--theme-ink) 28%, transparent)"},children:[e(I,{title:t.title,options:v,methodLabel:D.label,badge:D.badge,icon:D.icon,onCancel:w}),e("div",{className:"max-h-[65vh] overflow-y-auto px-6 py-5 space-y-4",children:[e(P,{title:t.title,options:v}),t.message&&e("div",{className:"rounded-xl border border-ink/8 bg-canvas/40 p-4 text-[13px] leading-relaxed text-ink/85 select-text",children:e(ee,{content:t.message})}),t.method==="select"&&e(T,{options:v,optionDetails:N,selectedOption:x,customValue:f,onCustomChange:h,customInputRef:u,onSelect:z,onConfirmOption:O,hideCustomAnswer:C}),t.method==="confirm"&&e("div",{className:"flex items-center gap-3 rounded-xl border border-ink/10 bg-canvas/30 p-4",children:[e("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-ink/5 text-ink",children:e(ne,{size:18})}),e("div",{className:"text-[12.5px] leading-relaxed text-ink/75",children:["Confirming will allow the autonomous agent to proceed with this operation. Press ",e("kbd",{className:"rounded border border-ink/20 bg-paper px-1 py-0.2 font-mono text-[10.5px]",children:"Enter"})," to confirm or ",e("kbd",{className:"rounded border border-ink/20 bg-paper px-1 py-0.2 font-mono text-[10.5px]",children:"Esc"})," to abort."]})]}),t.method==="input"&&e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Your Response"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:"Press [Enter] to submit"})]}),e("input",{ref:k,type:t.secret===!0?"password":"text",value:p,placeholder:t.placeholder||"Type your response...",onChange:(c)=>m(c.currentTarget.value),onKeyDown:(c)=>{if(c.key==="Enter")c.preventDefault(),A()},className:"w-full rounded-xl border border-ink/15 bg-paper px-4 py-3 text-[13.5px] text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:ring-2 focus:ring-ink/15"})]}),t.method==="editor"&&e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Buffer Content"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:[p.split(`
|
|
1
|
+
import{d,n,o,i,a,e,s,E,ne,Qe,Me,_,ti,tt,Te,_e,b,ee,ui,Hm}from"./index-gs7ytgdw.js";var B={name:"list-filter",size:24,node:[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]]},M=s(B);function I({title:t,options:r,methodLabel:p,badge:m,icon:x,onCancel:g}){let f=ui({title:t,options:r})?Hm(t):null,h=f?`Allow ${f.tool}`:t||p;return e("div",{className:"flex items-center justify-between border-b border-ink/8 bg-canvas/40 px-5 py-3.5",children:[e("div",{className:"flex items-center gap-3 min-w-0",children:[e("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-ink/12 bg-paper text-ink shadow-xs",children:x}),e("div",{className:"min-w-0",children:[e("div",{className:"flex items-center gap-2",children:[e("h3",{className:"truncate text-[14px] font-semibold tracking-tight text-ink",children:h}),e("span",{className:"flex items-center gap-1 rounded-full border border-ink/10 bg-paper px-2 py-0.5 font-mono text-[10px] font-medium tracking-wider text-ink/60 uppercase",children:[e(Me,{size:9,className:"text-ink/40"}),m]})]}),e("p",{className:"mt-0.5 text-[11px] text-ink/50",children:f?"The agent wants to run this. Review it before you allow.":"Autonomous agent inquiry requiring user confirmation"})]})]}),e("button",{type:"button",onClick:g,"aria-label":"Close dialog (Esc)",title:"Cancel (Esc)",className:"flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded-lg border border-ink/10 text-ink/45 transition-colors hover:border-ink/25 hover:bg-ink/5 hover:text-ink",children:e(b,{size:14})})]})}function T({options:t,optionDetails:r,selectedOption:p,customValue:m,onCustomChange:x,customInputRef:g,onSelect:f,onConfirmOption:h,hideCustomAnswer:l=!1}){return e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Available Options"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:["Press [1-",Math.min(9,t.length),"] to choose"]})]}),e("div",{className:"grid gap-2",role:"radiogroup",children:t.map((k,y)=>{let u=p===k,v=r[y]?.description;return e("button",{type:"button",onClick:()=>f(k),onDblClick:()=>h(k),"aria-checked":u,role:"radio",className:`group flex w-full cursor-pointer items-start gap-3 rounded-xl border p-3.5 text-left transition-all ${u?"border-ink bg-paper shadow-sm ring-1 ring-ink/10":"border-ink/10 bg-canvas/30 hover:border-ink/25 hover:bg-paper"}`,children:[e("span",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md font-mono text-[11px] font-semibold transition-colors ${u?"bg-ink text-paper":"border border-ink/15 bg-paper text-ink/60 group-hover:border-ink/30 group-hover:text-ink"}`,children:y+1}),e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"flex items-center gap-2",children:e("span",{className:`text-[13px] font-medium leading-snug ${u?"text-ink font-semibold":"text-ink/85"}`,children:k})}),v&&e("div",{className:"mt-1 text-[11.5px] leading-relaxed text-ink/55",children:v})]}),e("span",{className:"mt-0.5 shrink-0",children:u?e(ne,{size:16,className:"text-ink"}):e(ti,{size:16,className:"text-ink/20 group-hover:text-ink/40"})})]},k)})}),!l&&e("div",{className:"space-y-1.5 pt-1",children:[e("div",{className:"text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:"Other: type your own answer"}),e("input",{ref:g,type:"text",value:m,placeholder:"Type a custom answer and press Enter...",onChange:(k)=>x(k.currentTarget.value),onKeyDown:(k)=>{if(k.key==="Enter"){if(k.preventDefault(),k.stopPropagation(),m.trim())h(m.trim())}},className:"w-full rounded-xl border border-ink/15 bg-paper px-4 py-3 text-[13.5px] text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:ring-2 focus:ring-ink/15"})]})]})}function S({method:t,optionsLength:r,selectedOption:p,hasCustomAnswer:m=!1,onCancel:x,onSubmit:g}){let f=t==="select"&&!p&&!m;return e("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t border-ink/8 bg-canvas/40 px-5 py-3.5",children:[e("div",{className:"flex items-center gap-2 font-mono text-[11px] text-ink/50",children:[t==="select"&&e(d,{children:[e("span",{className:"hidden items-center gap-1 sm:inline-flex",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:["1-",Math.min(9,r)]}),e("span",{className:"text-ink/40",children:"choose"})]}),e("span",{className:"hidden text-ink/30 sm:inline",children:"•"}),e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"↵"}),e("span",{className:"text-ink/40",children:"select"})]})]}),t==="confirm"&&e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"↵"}),e("span",{className:"text-ink/40",children:"confirm"})]}),t==="editor"&&e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"⌘↵"}),e("span",{className:"text-ink/40",children:"save buffer"})]}),e("span",{className:"text-ink/30",children:"•"}),e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"Esc"}),e("span",{className:"text-ink/40",children:"cancel"})]})]}),e("div",{className:"flex items-center gap-2.5 ml-auto",children:[e("button",{type:"button",onClick:x,className:"flex cursor-pointer items-center gap-1 rounded-lg border border-ink/15 bg-paper px-3.5 py-1.5 text-[12px] font-medium text-ink/70 transition-colors hover:border-ink/30 hover:bg-canvas/50 hover:text-ink",children:[e(b,{size:12,className:"opacity-60"}),e("span",{children:"Cancel"})]}),e("button",{type:"button",onClick:g,disabled:f,className:"flex cursor-pointer items-center gap-1.5 rounded-lg bg-ink px-4 py-1.5 text-[12px] font-semibold text-paper shadow-xs transition-all hover:opacity-90 active:scale-[0.98] disabled:cursor-not-allowed disabled:opacity-35",children:[e("span",{children:t==="confirm"?"Confirm":t==="select"?"Select Option":"Submit Response"}),e(tt,{size:12,className:"opacity-70"})]})]})]})}function P({title:t,options:r}){let p=ui({title:t,options:r})?Hm(t):null;if(!p)return null;return e("div",{className:"space-y-2",children:[p.reason&&e("div",{className:"flex items-start gap-2 rounded-xl border border-warning/25 bg-warning/8 px-3.5 py-2.5 text-[12px] leading-relaxed text-ink/80",children:[e(_,{size:13,className:"mt-0.5 shrink-0 text-warning"}),e("span",{className:"min-w-0 break-words",children:p.reason})]}),p.details.length>0&&e("div",{className:"rounded-xl border border-ink/10 bg-canvas/40 px-3.5 py-2.5",children:p.details.map((m,x)=>e("div",{className:"font-mono text-[11.5px] leading-relaxed text-ink/75 break-all",children:m},`${x}-${m}`))})]})}function R({method:t,options:r,selectedOption:p,onSelectOption:m,customInputRef:x,onSubmit:g,onCancel:f}){o(()=>{let h=(l)=>{if(l.key==="Escape"){l.preventDefault(),l.stopPropagation(),f();return}if(t==="select"&&r.length>0){if(l.target instanceof HTMLInputElement&&l.target===x.current)return;let y=parseInt(l.key,10);if(!isNaN(y)&&y>=1&&y<=r.length){l.preventDefault(),m(r[y-1]);return}if(l.key==="ArrowDown"){l.preventDefault();let u=r.findIndex((N)=>N===p),v=u<r.length-1?u+1:0;m(r[v]);return}if(l.key==="ArrowUp"){l.preventDefault();let u=r.findIndex((N)=>N===p),v=u>0?u-1:r.length-1;m(r[v]);return}if(l.key==="Enter"&&p){l.preventDefault(),g();return}}if(t==="confirm"){if(l.key==="Enter"){l.preventDefault(),g();return}}if(t==="editor"){if((l.metaKey||l.ctrlKey)&&l.key==="Enter"){l.preventDefault(),g();return}}};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[f,g,t,r,p,m,x])}function L(t,r){switch(t){case"select":return{icon:e(M,{size:16,className:"text-ink"}),label:"Decision Required",badge:`${r} Choices`};case"confirm":return{icon:e(E,{size:16,className:"text-ink"}),label:"Confirmation Required",badge:"Confirm Action"};case"input":return{icon:e(_e,{size:16,className:"text-ink"}),label:"Prompt Input",badge:"Text Input"};case"editor":return{icon:e(Te,{size:16,className:"text-ink"}),label:"Buffer Editor",badge:"Multiline Buffer"};default:return{icon:e(Qe,{size:16,className:"text-ink"}),label:"Agent Request",badge:"Input"}}}function ke({request:t,onRespond:r}){let[p,m]=n(t.method==="editor"?t.prefill??"":""),[x,g]=n(null),[f,h]=n(""),l=i(null),k=i(null),y=i(null),u=i(null),v=t.options??[],N=t.optionDetails??[],C=ui(t);o(()=>{let c=t.options??[];m(t.method==="editor"?t.prefill??"":""),g(c.length>0?c[0]:null),h("")},[t]),o(()=>{if(l.current?.focus(),t.method==="input")k.current?.focus();else if(t.method==="editor")y.current?.focus();else if(t.method==="select"){if((t.options??[]).some((H)=>/^other\b/i.test(H.trim())))u.current?.focus()}},[t]);let w=a(()=>{r(t,{cancelled:!0})},[r,t]),A=a(()=>{if(t.method==="confirm")r(t,{confirmed:!0});else if(t.method==="select"){if(f.trim()&&!C)r(t,{value:f.trim()});else if(x)r(t,{value:x})}else r(t,{value:p})},[r,t,x,p,f,C]),O=a((c)=>{if(/^other\b/i.test(c.trim())){g(c),u.current?.focus();return}r(t,{value:c})},[r,t]),z=a((c)=>{if(g(c),/^other\b/i.test(c.trim()))u.current?.focus()},[]);R({method:t.method,options:v,selectedOption:x,onSelectOption:g,customInputRef:u,onSubmit:A,onCancel:w});let D=L(t.method,v.length);return e("div",{className:"extension-dialog-backdrop modal-scrim fixed inset-0 z-50 flex items-center justify-center p-4 sm:p-6 backdrop-blur-[8px]",onMouseDown:(c)=>{if(c.target===c.currentTarget)w()},children:e("div",{ref:l,role:"dialog","aria-modal":"true","aria-label":t.title||D.label,tabIndex:-1,className:"glass-overlay extension-dialog-panel w-full max-w-[560px] overflow-hidden rounded-2xl border border-ink/15 bg-paper shadow-2xl outline-none",style:{boxShadow:"0 24px 64px -8px color-mix(in srgb, var(--theme-ink) 28%, transparent)"},children:[e(I,{title:t.title,options:v,methodLabel:D.label,badge:D.badge,icon:D.icon,onCancel:w}),e("div",{className:"max-h-[65vh] overflow-y-auto px-6 py-5 space-y-4",children:[e(P,{title:t.title,options:v}),t.message&&e("div",{className:"rounded-xl border border-ink/8 bg-canvas/40 p-4 text-[13px] leading-relaxed text-ink/85 select-text",children:e(ee,{content:t.message})}),t.method==="select"&&e(T,{options:v,optionDetails:N,selectedOption:x,customValue:f,onCustomChange:h,customInputRef:u,onSelect:z,onConfirmOption:O,hideCustomAnswer:C}),t.method==="confirm"&&e("div",{className:"flex items-center gap-3 rounded-xl border border-ink/10 bg-canvas/30 p-4",children:[e("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-ink/5 text-ink",children:e(ne,{size:18})}),e("div",{className:"text-[12.5px] leading-relaxed text-ink/75",children:["Confirming will allow the autonomous agent to proceed with this operation. Press ",e("kbd",{className:"rounded border border-ink/20 bg-paper px-1 py-0.2 font-mono text-[10.5px]",children:"Enter"})," to confirm or ",e("kbd",{className:"rounded border border-ink/20 bg-paper px-1 py-0.2 font-mono text-[10.5px]",children:"Esc"})," to abort."]})]}),t.method==="input"&&e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Your Response"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:"Press [Enter] to submit"})]}),e("input",{ref:k,type:t.secret===!0?"password":"text",value:p,placeholder:t.placeholder||"Type your response...",onChange:(c)=>m(c.currentTarget.value),onKeyDown:(c)=>{if(c.key==="Enter")c.preventDefault(),A()},className:"w-full rounded-xl border border-ink/15 bg-paper px-4 py-3 text-[13.5px] text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:ring-2 focus:ring-ink/15"})]}),t.method==="editor"&&e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Buffer Content"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:[p.split(`
|
|
2
2
|
`).length," lines · ⌘↵ to save"]})]}),e("textarea",{ref:y,value:p,onChange:(c)=>m(c.currentTarget.value),rows:8,placeholder:t.placeholder||"Enter content...",className:"w-full rounded-xl border border-ink/15 bg-canvas/30 px-4 py-3 font-mono text-[12px] leading-relaxed text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:bg-paper focus:ring-2 focus:ring-ink/15"})]})]}),e(S,{method:t.method,optionsLength:v.length,selectedOption:x,hasCustomAnswer:f.trim().length>0,onCancel:w,onSubmit:A})]})})}export{ke as ExtensionDialog};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{d,n,o,i,u,a,e,Ao,s,m,_,qr,Pi,f,re,Rt,ge,D,O,Pp,J,qt,Xl,Op,qu}from"./index-gs7ytgdw.js";var U={name:"folder-git-2",size:24,node:[["path",{d:"M18 19a5 5 0 0 1-5-5v8",key:"sz5oeg"}],["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]},Sp=s(U);function H({row:t,active:r,name:l,loading:h,onSelect:p,onCopyPath:g,onReveal:C}){return e("div",{className:"grid grid-cols-[1rem_minmax(0,1fr)_3.5rem] items-start gap-x-2 px-4 py-2 border-b border-ink/5 last:border-b-0 hover:bg-ink/[0.02] group/row transition-colors",children:[e("div",{className:"h-5 flex items-center justify-center",children:r&&e(f,{size:12,className:"text-ink","aria-label":"Selected repository"})}),e("button",{type:"button",onClick:p,disabled:r||!t.isRepo,title:!t.isRepo?t.error??"Not a git repository":r?"Already showing this repository":`Show ${t.path}`,className:"min-w-0 text-left cursor-pointer disabled:cursor-default",children:e("div",{className:"h-5 flex items-center gap-1.5 min-w-0",children:[e(ge,{size:11,className:r?"text-ink/60 flex-shrink-0":"text-ink/40 flex-shrink-0"}),e("span",{className:`truncate text-xs ${r?"font-semibold text-ink":"text-ink/90"}`,children:l})]})}),e("div",{className:"h-5 flex items-center justify-end gap-0.5 touch-visible opacity-0 group-hover/row:opacity-100",children:[e("button",{type:"button",onClick:g,disabled:h,title:`Copy the absolute path of ${t.path}`,"aria-label":`Copy path of ${t.path}`,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors disabled:opacity-30 disabled:cursor-default",children:e(re,{size:11})}),e("button",{type:"button",onClick:C,title:`Reveal ${t.path} in the file manager`,"aria-label":`Reveal ${t.path}`,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Rt,{size:11})})]}),e("div",{className:"col-start-2 col-span-2 flex flex-wrap items-center gap-x-2 gap-y-0.5 min-w-0 mt-0.5",children:[t.isRepo?e(d,{children:[e("span",{className:`text-[10px] font-mono truncate ${t.detached?"text-warning":"text-ink/50"}`,title:t.detached?`Detached HEAD at ${t.branch}`:`On branch ${t.branch}`,children:t.branch}),e("span",{className:"text-[10px] text-ink/25","aria-hidden":!0,children:"·"}),e(Q,{row:t})]}):e("span",{className:"text-[10px] text-ink/40 truncate",children:t.error??"Not a git repository"}),t.isRepo&&t.subject&&e(d,{children:[e("span",{className:"text-[10px] text-ink/25","aria-hidden":!0,children:"·"}),e("span",{className:"text-[10px] text-ink/40 truncate min-w-0",title:t.subject,children:t.subject})]})]})]})}function Q({row:t}){let r=[];if(t.operation)r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning",title:t.operation==="stash-pop"?`A stash pop stopped on ${t.conflicts} conflict(s)`:`A ${Ao[t.operation]} is in progress, stopped on ${t.conflicts} conflict(s)`,children:[e(_,{size:9}),Ao[t.operation]]},"operation"));else if(t.conflicts>0)r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning",title:`${t.conflicts} conflicted path(s)`,children:[e(_,{size:9}),t.conflicts]},"conflicts"));if(t.changed>0||t.untracked>0)r.push(e("span",{className:"flex-shrink-0 rounded border border-info/30 px-1 text-[10px] font-mono tabular-nums text-info",title:`${t.changed} changed, ${t.untracked} untracked`,children:[t.changed>0?`${t.changed}±`:"",t.changed>0&&t.untracked>0?" ":"",t.untracked>0?`${t.untracked}?`:""]},"dirty"));if(t.gone)r.push(e("span",{className:"flex-shrink-0 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning",title:`${t.upstream} no longer exists on the remote — fetch --prune to drop it`,children:"gone"},"gone"));else if(t.upstream&&(t.ahead>0||t.behind>0))r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 text-[10px] font-mono tabular-nums text-ink/60",title:`${t.ahead} ahead of, ${t.behind} behind ${t.upstream}`,children:[t.ahead>0&&e("span",{className:"flex items-center",children:[e(Pi,{size:9}),t.ahead]}),t.behind>0&&e("span",{className:"flex items-center",children:[e(qr,{size:9}),t.behind]})]},"track"));if(r.length===0)return e("span",{className:"text-[10px] font-mono text-ink/30",title:"Nothing to report: clean and in sync",children:"clean, in sync"});return e(d,{children:r})}function B(t){let{open:r,rootPath:l,scanning:h}=t,[p,g]=n([]),[C,y]=n(!1),[G,z]=n(!1),[k,v]=n(null),[A,E]=n(0),L=t.repos.join("\x00"),S=i(!0),b=i(null);o(()=>(S.current=!0,()=>{S.current=!1,b.current?.abort(),b.current=null}),[]);let P=a(async()=>{b.current?.abort();let R=new AbortController;b.current=R,z(!0),y(!0);try{let N=new URLSearchParams({repoDetails:"1"});if(l)N.set("root",l);let j=await fetch(`/api/fs/git?${N.toString()}`,{signal:R.signal}),F=await j.json();if(!S.current||b.current!==R)return;if(!j.ok||!Array.isArray(F.details)){v(F.error||`Failed to read repositories (HTTP ${j.status})`);return}g(F.details),v(null)}catch(N){if(!S.current||b.current!==R)return;if(N instanceof Error&&N.name==="AbortError")return;v(N instanceof Error?N.message:"Failed to read repositories")}finally{if(S.current&&b.current===R)b.current=null,z(!1),y(!1)}},[l]);o(()=>{if(!r){g([]),v(null),y(!1);return}P()},[r,P,L,h,A]);let w=a(()=>E((R)=>R+1),[]);return{details:p,loading:C,reading:G,error:k,refresh:w}}function W(t){let r=new Map;for(let l of t){if(!l||l==="."){if(!r.has(""))r.set("",{key:"",label:null,paths:[]});r.get("").paths.push(".");continue}let h=l.indexOf("/"),p=h===-1?"":l.slice(0,h),g=r.get(p);if(!g)g={key:p,label:p===""?null:p,paths:[]},r.set(p,g);g.paths.push(l)}for(let l of r.values())l.paths.sort((h,p)=>h==="."?-1:p==="."?1:h.localeCompare(p));return[...r.values()].sort((l,h)=>{if(l.key==="")return-1;if(h.key==="")return 1;return l.key.localeCompare(h.key)})}function q(t,r){if(t===".")return"workspace root";if(r==="")return t;return t.slice(r.length+1)}function I({isOpen:t,rootPath:r,activeRepo:l,repos:h,scanning:p,onSelectRepo:g,onRefreshRepos:C,onClose:y}){let[G,z]=n(""),[k,v]=n(null),{details:A,loading:E,reading:L,error:S,refresh:b}=B({open:t,rootPath:r,repos:h,scanning:p});o(()=>{if(!t)z(""),v(null)},[t]);let P=u(()=>{let x=G.trim().toLowerCase();if(!x)return A;return A.filter((c)=>c.path.toLowerCase().includes(x))},[A,G]),w=u(()=>W(P.map((x)=>x.path)),[P]),R=u(()=>{let x=new Map;for(let c of A)x.set(c.path,c);return x},[A]),N=a(()=>{C(),b()},[C,b]),j=a(async(x)=>{let c=r?qu(r,x==="."?"":x):x,M=await qt(c);v(M?{text:`Copied ${c}`,kind:"success"}:{text:"Clipboard unavailable",kind:"error"})},[r]),F=a(async(x)=>{let c=new FormData;if(c.append("actionType","open_explorer"),c.append("path","."),c.append("repo",x),r)c.append("root",r);try{let M=await fetch("/api/fs/action",{method:"POST",body:c}),T=await M.json();if(!M.ok||T.error)v({text:T.error||"Could not open the file manager",kind:"error"})}catch{v({text:"Could not open the file manager",kind:"error"})}},[r]);if(!t)return null;return e(J,{onClose:y,maxWidthClass:"max-w-[min(96vw,720px)]",header:e("div",{className:"flex items-center gap-2 min-w-0",children:[e(Sp,{size:14,className:"text-ink/60 flex-shrink-0"}),e("h2",{className:"text-sm font-semibold text-ink",children:"Repositories"}),e("span",{className:"text-[10px] font-mono text-ink/50 truncate",children:[h.length," in this workspace"]})]}),children:[e("div",{className:"px-5 py-3 flex items-center gap-2 border-b border-ink/10",children:[e(O,{size:12,className:"text-ink/40 flex-shrink-0"}),e("input",{type:"text",value:G,onChange:(x)=>z(x.currentTarget.value),placeholder:"Filter repositories…","aria-label":"Filter repositories",className:"flex-1 min-w-0 bg-transparent outline-none text-xs text-ink placeholder-ink/40",autoFocus:!0}),e("button",{type:"button",onClick:N,disabled:L||p,title:"Re-discover repositories and re-read their state","aria-label":"Refresh repositories",className:"text-ink/40 hover:text-ink transition-colors cursor-pointer disabled:opacity-40 flex-shrink-0",children:e(D,{size:12,className:L||p?"animate-spin":""})})]}),p&&e("div",{className:"px-5 py-1.5 border-b border-ink/10 text-[10px] font-mono text-ink/50 flex items-center gap-1.5",children:[e(m,{size:10,className:"animate-spin"}),"Still discovering repositories in this workspace…"]}),k&&e("div",{className:`px-5 py-1.5 border-b border-ink/10 text-[10px] font-mono truncate ${k.kind==="error"?"text-error":"text-ink/60"}`,title:k.text,role:"status",children:k.text}),e("div",{className:"min-h-[40vh] max-h-[60vh] overflow-y-auto scrollbar-overlay-container",children:E&&A.length===0?e("div",{className:"flex items-center justify-center gap-2 py-12 text-xs text-ink/50 font-mono",children:[e(m,{size:14,className:"animate-spin text-info"}),"Reading repositories…"]}):S?e("div",{className:"py-12 px-6 text-center text-xs text-error font-mono",children:S}):P.length===0?e("div",{className:"py-12 text-center text-xs text-ink/40 font-mono",children:G.trim()?"No matching repositories.":"No repositories in this workspace."}):w.map((x)=>e("div",{children:[e("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold bg-canvas/40 border-b border-ink/5 sticky top-0",children:x.label??Xl(".",r)}),x.paths.map((c)=>{let M=R.get(c);if(!M)return null;return e(H,{row:M,active:c===l,name:q(c,x.key),loading:L,onSelect:()=>{g(c),y()},onCopyPath:()=>void j(c),onReveal:()=>void F(c)},c)})]},x.key))})]})}function br({rootPath:t,activeRepo:r,onSelectRepo:l,repos:h,scanning:p,onRefreshRepos:g}){let[C,y]=n(!1),G=u(()=>({root:t??null,repo:r,rows:h.map((k)=>({repo:k,label:Xl(k,t),short:Op(k,t)})),scanning:p,ready:!0,setRepo:l,refresh:g}),[t,r,h,p,l,g]),z=a(()=>y(!0),[]);return e("div",{className:"relative",children:[e(Pp,{scope:G,onManage:z}),e(I,{isOpen:C,rootPath:t,activeRepo:r,repos:h,scanning:p,onSelectRepo:l,onRefreshRepos:g,onClose:()=>y(!1)})]})}
|
|
2
|
+
export{Sp,br};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d,e,
|
|
1
|
+
import{d,e,Xg,Ce,E,ft,at}from"./index-gs7ytgdw.js";import{aa,yu,Ss,vu,ku}from"./index-tgper3yy.js";function u(t,r){if(!t)return r;if(!r)return t;let n=Date.parse(t.generatedAt),s=Date.parse(r.generatedAt);if(Number.isNaN(n)||Number.isNaN(s))return t;return s>n?r:t}function R({className:t="",active:r=!0}){let{report:n,isLoading:s,error:o,reload:i}=ku(),l=Ce(Xg,{enabled:r}),a=u(l.data,n),p=a?Ss(a):[];if(o&&!a)return e("div",{className:`flex h-full w-full flex-col items-center justify-center gap-2 p-8 text-center text-xs ${t}`,children:[e(E,{size:16,className:"text-error"}),e("p",{className:"text-error text-xs",children:o}),e("button",{type:"button",onClick:()=>i(),className:"text-[11px] font-semibold text-ink/70 hover:text-ink underline underline-offset-2",children:"Try again"})]});if(!a)return e("div",{className:`flex h-full w-full items-center justify-center text-ink/40 text-xs ${t}`,children:"Loading provider usage..."});return e("div",{className:`flex h-full w-full min-w-0 min-h-0 flex-col overflow-hidden bg-paper text-xs text-ink ${t}`,children:[e(ft,{left:e(d,{children:[e("h2",{className:"text-xs font-semibold text-ink uppercase tracking-wider",children:"Usage"}),e("span",{className:"text-[11px] text-ink/50 truncate",children:["Updated ",aa(a.generatedAt)]}),a.isMock&&e("span",{className:"text-[10px] font-mono uppercase tracking-wider bg-ink/5 border border-ink/15 rounded px-1.5 py-0.5 text-ink/60",children:"Mock"})]}),right:e(at,{label:"Refresh usage",onClick:()=>i({force:!0}),busy:s||l.refreshing,disabled:s})}),e("div",{className:"flex-1 min-w-0 min-h-0 w-full overflow-y-auto scrollbar-overlay-container p-3.5 space-y-4",children:[o&&e("p",{className:"text-error text-xs",children:o}),p.length>0?p.map((m)=>e(yu,{summary:m.summary},m.id)):e("p",{className:"text-[11px] text-ink/50 leading-relaxed",children:"No provider credentials detected. Add an API key in Settings → Providers and it will appear here."}),e(vu,{})]})]})}export{R as UsagePanel};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t,
|
|
2
|
-
export{
|
|
1
|
+
import{t,Ds,h,Rs}from"./index-b6cyn4hr.js";import{mn}from"./index-hz177dr2.js";var o=mn(Rs(),1);var Ho=t((s,e)=>{let r=s.append("rect");if(r.attr("x",e.x),r.attr("y",e.y),r.attr("fill",e.fill),r.attr("stroke",e.stroke),r.attr("width",e.width),r.attr("height",e.height),e.name)r.attr("name",e.name);if(e.rx)r.attr("rx",e.rx);if(e.ry)r.attr("ry",e.ry);if(e.attrs!==void 0)for(let a in e.attrs)r.attr(a,e.attrs[a]);if(e.class)r.attr("class",e.class);return r},"drawRect"),Iu=t((s,e)=>{let r={x:e.startx,y:e.starty,width:e.stopx-e.startx,height:e.stopy-e.starty,fill:e.fill,stroke:e.stroke,class:"rect"};Ho(s,r).lower()},"drawBackgroundRect"),Qg=t((s,e)=>{let r=e.text.replace(Ds," "),a=s.append("text");if(a.attr("x",e.x),a.attr("y",e.y),a.attr("class","legend"),a.style("text-anchor",e.anchor),e.class)a.attr("class",e.class);let i=a.append("tspan");return i.attr("x",e.x+e.textMargin*2),i.text(r),a},"drawText"),Vd=t((s,e,r,a)=>{let i=s.append("image");i.attr("x",e),i.attr("y",r);let n=o.sanitizeUrl(a);i.attr("xlink:href",n)},"drawImage"),Yd=t((s,e,r,a)=>{let i=s.append("use");i.attr("x",e),i.attr("y",r);let n=o.sanitizeUrl(a);i.attr("xlink:href",`#${n}`)},"drawEmbeddedImage"),or=t(()=>({x:0,y:0,width:100,height:100,fill:"#EDF2AE",stroke:"#666",anchor:"start",rx:0,ry:0}),"getNoteRect"),Jd=t(()=>({x:0,y:0,width:100,height:100,"text-anchor":"start",style:"#666",textMargin:0,rx:0,ry:0,tspan:!0}),"getTextObj"),Ma=t(()=>{let s=h(".mermaidTooltip");if(s.empty())s=h("body").append("div").attr("class","mermaidTooltip").style("opacity",0).style("position","absolute").style("text-align","center").style("max-width","200px").style("padding","2px").style("font-size","12px").style("background","#ffffde").style("border","1px solid #333").style("border-radius","2px").style("pointer-events","none").style("z-index","100");return s},"createTooltip");
|
|
2
|
+
export{Ho,Iu,Qg,Vd,Yd,or,Jd,Ma};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d,n,o,i,u,a,yr,Ue,oe,e,Kn,w,Jg,Ce,Os,S,cr,ur,s,Nn,L,Xe,B,ie,yo,re,Ee,qe,ri,sn,ai,Kr,D,O,b,ft,at,pe,qt,qu,it,st,cA,uA,Vi,Yi,Hu,je,Zi}from"./index-gs7ytgdw.js";import{Pu,Ou,Jo,$u,zu}from"./index-x2kb1kx5.js";import{br}from"./index-2z9wrb46.js";var Qt={name:"pen",size:24,node:[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],aliases:["edit-2"]},Ve=s(Qt);var Yt={name:"copy-plus",size:24,node:[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]},Be=s(Yt);var Jt={name:"package-open",size:24,node:[["path",{d:"M12 22v-9",key:"x3hkom"}],["path",{d:"M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z",key:"2ntwy6"}],["path",{d:"M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13",key:"1pmm1c"}],["path",{d:"M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z",key:"12ttoo"}]]},Qe=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 Ye({rootPath:t,activeRepo:r,repos:l,reposScanning:c,onRefreshRepos:p,onSelectRepo:f,searchQuery:x,onSearchChange:h,onRefresh:v,refreshing:g}){return e("div",{className:"border-b border-ink/10",children:[e(ft,{className:"border-b-0",left:e(br,{rootPath:t,activeRepo:r,onSelectRepo:f,repos:l,scanning:c,onRefreshRepos:p}),right:e(at,{label:"Refresh",onClick:v,busy:g})}),e("div",{className:"px-3 pb-3",children:e("div",{className:"relative",children:[e(O,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-ink/40"}),e("input",{type:"text",placeholder:"Search files...",value:x,onChange:(m)=>h(m.currentTarget.value),className:"w-full bg-canvas border border-ink/20 rounded pl-8 pr-3 py-1.5 text-xs focus:outline-none focus:border-ink transition-colors text-ink placeholder-ink/40"})]})})]})}function 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(it,{name:t,isFolder:l,isOpen:c,size:12,className:`flex-shrink-0${p?" opacity-40":""}`}),e("span",{className:`truncate min-w-0 flex-1 ${v}`,title:p?`${r} — git-ignored`:void 0,children:t}),x&&e("span",{className:`font-mono text-[10px] font-bold px-1 rounded flex-shrink-0 ${x.colorClass}`,title:`Git: ${x.label}`,children:x.charStatus}),h&&e("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${h.hasDeleted?"bg-error":h.hasModified||h.hasStaged?"bg-info":"bg-success"}`,title:`${h.count} changed file${h.count>1?"s":""}`})]})}var en=28,tn=9,nn=8;function rn(t){let{isFolder:r,hasGitStatus:l,pasteLabel:c,busy:p,chainLabel:f,foldable:x,selectionCount:h,isArchive:v}=t,g=[],m=h>1,k=h===1?"":` ${h} items`;if(m)return g.push({kind:"item",id:"cut",label:`Cut${k}`,icon:e(Te,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"copy",label:`Copy${k}`,icon:e(re,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"separator"}),g.push({kind:"item",id:"compress",label:`Compress${k} to…`,icon:e(Xe,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"separator"}),g.push({kind:"item",id:"delete",label:`Delete${k}`,icon:e(L,{size:13,className:"text-error"}),tone:"text-error"}),g;if(r){if(g.push({kind:"item",id:"new_file",label:"New File",icon:e(ri,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"new_folder",label:"New Folder",icon:e(sn,{size:13,className:"text-ink/60"})}),f)g.push({kind:"item",id:"unfold",label:"Unfold Folders",icon:e(B,{size:13,className:"text-ink/60"})});if(x)g.push({kind:"item",id:"fold",label:"Fold Folders",icon:e(ie,{size:13,className:"text-ink/60"})});g.push({kind:"separator"})}else{if(g.push({kind:"item",id:"view",label:"View",icon:e(qe,{size:13,className:"text-ink/60"})}),v)g.push({kind:"item",id:"extract",label:"Extract…",icon:e(Qe,{size:13,className:"text-ink/60"}),disabled:p});if(l)g.push({kind:"item",id:"diff",label:"Open in Diff Panel",icon:e(ai,{size:13,className:"text-warning"}),tone:"font-medium"});g.push({kind:"separator"})}if(g.push({kind:"item",id:"cut",label:"Cut",icon:e(Te,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"copy",label:"Copy",icon:e(re,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"compress",label:"Compress to…",icon:e(Xe,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"duplicate",label:"Duplicate",icon:e(Be,{size:13,className:"text-ink/60"}),disabled:p}),c)g.push({kind:"item",id:"paste",label:c,icon:e(yo,{size:13,className:"text-ink/60"}),disabled:p});return g.push({kind:"separator"}),g.push({kind:"item",id:"explorer",label:"Go to Explorer",icon:e(Ee,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"copy_path",label:"Copy Path",icon:e(re,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"copy_relative",label:"Copy Relative Path",icon:e(re,{size:13,className:"text-ink/60"})}),g.push({kind:"separator"}),g.push({kind:"item",id:"history",label:"Show Git History",icon:e(Nn,{size:13,className:"text-ink/60"})}),g.push({kind:"separator"}),g.push({kind:"item",id:"rename",label:"Rename",icon:e(Ve,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"delete",label:"Delete",icon:e(L,{size:13,className:"text-error"}),tone:"text-error"}),g}function on(t){let r=t.filter((c)=>c.kind==="item").length,l=t.length-r;return r*en+l*tn+nn}function 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 F=rn({isFolder:l,hasGitStatus:c,pasteLabel:p,busy:h,chainLabel:f,foldable:x,selectionCount:v,isArchive:g}),A=on(F),C=typeof window<"u"?Math.max(10,Math.min(t,window.innerWidth-210-12)):t,E=typeof window<"u"?Math.max(10,Math.min(r,window.innerHeight-A-12)):r;return oe(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>m("close"),onContextMenu:(R)=>{R.preventDefault(),m("close")},children:e("div",{ref:k,className:"glass-popover fixed z-50 bg-paper border border-ink/15 shadow-2xl rounded-lg py-1 min-w-[185px] text-xs text-ink font-sans",style:{top:E,left:C},onClick:(R)=>R.stopPropagation(),children:F.map((R,N)=>R.kind==="separator"?e("div",{className:"my-1 border-t border-ink/10"},`sep-${N}`):e("button",{type:"button",disabled:R.disabled,onClick:()=>m(R.id),className:`w-full text-left px-3 py-1.5 flex items-center space-x-2 transition-colors ${R.disabled?"opacity-40 cursor-default":"hover:bg-ink/5"} ${R.tone??""}`,children:[R.icon,e("span",{children:R.label})]},R.id))})}),document.body)}function Fe({folderPath:t,kind:r,value:l,error:c,isLoading:p,onChange:f,onCancel:x,onSubmit:h}){let v=r==="folder"?"Folder":"File";return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:h,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-3 text-sm",children:["New ",v]}),e("div",{className:"flex items-center gap-1 mb-1 text-xs font-mono text-ink/50 min-w-0",children:e("span",{className:"truncate",title:t,children:[t||".","/"]})}),e("input",{autoFocus:!0,type:"text",value:l,onChange:(g)=>f(g.currentTarget.value),placeholder:r==="folder"?"folder name or nested/path":"file name or nested/path","aria-label":`New ${v.toLowerCase()} name`,className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none mb-1 ${c?"border-error":"border-ink/20 focus:border-ink"}`}),e("p",{className:"text-[10px] text-ink/40 mb-2",children:["Nested paths create the folders they need — ",e("span",{className:"font-mono",children:"lib/parse.ts"}),"."]}),c&&e("p",{className:"text-[11px] text-error mb-2",children:c}),e("div",{className:"flex justify-end space-x-2 mt-2",children:[e("button",{type:"button",onClick:x,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:p,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:p||!l.trim(),children:p?"Creating...":"Create"})]})]})}),document.body)}function et({fileName:t,displayName:r,isFolder:l,count:c=1,isLoading:p,onCancel:f,onConfirm:x}){let h=c>1;return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("div",{className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-2 text-sm",children:["Delete ",h?`${c} Items`:l?"Folder":"File"]}),e("p",{className:"text-xs text-ink/70 mb-4",children:["Are you sure you want to delete ",h?e(d,{children:["the ",c," selected entries"]}):e("span",{className:"font-mono bg-canvas px-1 rounded",children:t}),"? This action cannot be undone."]}),r&&r!==t&&e("p",{className:"text-[11px] text-ink/50 mb-4",children:["The row is ",e("span",{className:"font-mono",children:r}),"; this deletes"," ",e("span",{className:"font-mono",children:t})," only."]}),e("div",{className:"flex justify-end space-x-2",children:[e("button",{onClick:f,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:p,children:"Cancel"}),e("button",{onClick:x,className:"px-3 py-1.5 text-xs bg-error text-white rounded hover:bg-error/90 transition-colors flex items-center",disabled:p,children:p?"Deleting...":"Delete"})]})]})}),document.body)}function tt({isFolder:t,renameValue:r,originalPath:l,displayName:c,error:p,isLoading:f,onChange:x,onCancel:h,onSubmit:v}){return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:v,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-3 text-sm",children:["Rename ",t?"Folder":"File"]}),e("input",{autoFocus:!0,type:"text",value:r,onChange:(g)=>x(g.currentTarget.value),"aria-label":`Rename ${t?"folder":"file"} path`,className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none mb-1 ${p?"border-error":"border-ink/20 focus:border-ink"}`}),e("p",{className:"text-[10px] text-ink/40 mb-2",children:["Paths are relative to the tree — ",e("span",{className:"font-mono",children:"lib/deep/name.ts"})," moves it too."]}),c&&e("p",{className:"text-[11px] text-ink/50 mb-2",children:["The row is ",e("span",{className:"font-mono",children:c}),"; this renames"," ",e("span",{className:"font-mono",children:l}),". Use"," ",e("span",{className:"font-mono",children:"Unfold Folders"})," to rename a folder inside the chain."]}),p&&e("p",{className:"text-[11px] text-error mb-2",children:p}),e("div",{className:"flex justify-end space-x-2",children:[e("button",{type:"button",onClick:h,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:f,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:f||!r.trim()||r===l,children:f?"Renaming...":"Rename"})]})]})}),document.body)}function nt({filePath:t,fetcherState:r,fetcherData:l,onClose:c}){let p=l?.type==="history"?l.data:void 0;return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("div",{className:"glass-overlay bg-paper rounded-lg shadow-xl w-full max-w-4xl border border-ink/10 flex flex-col max-h-[85vh]",children:[e("div",{className:"flex items-center justify-between p-4 border-b border-ink/10",children:[e("h3",{className:"text-sm font-semibold text-ink flex items-center space-x-2",children:[e(Nn,{size:16,className:"text-ink/60"}),e("span",{children:["Git History: ",e("span",{className:"font-mono font-normal opacity-80",children:t})]})]}),e("button",{onClick:c,className:"p-1 hover:bg-ink/5 rounded text-ink/60 transition-colors",children:e(b,{size:14})})]}),e("div",{className:"flex-1 scrollbar-overlay-container p-2",children:r==="idle"?p?p.length>0?e("table",{className:"w-full text-left border-collapse text-[11px]",children:[e("thead",{className:"bg-canvas sticky top-0 z-10 border-b border-ink/10",children:e("tr",{children:[e("th",{className:"px-3 py-2 font-semibold text-ink/70 rounded-tl",children:"Description"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-32",children:"Date"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-32",children:"Author"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-24 text-right rounded-tr",children:"Commit"})]})}),e("tbody",{className:"divide-y divide-ink/5",children:p.map((f,x)=>e("tr",{className:"hover:bg-ink/[0.03] transition-colors group",children:[e("td",{className:"px-3 py-2 text-ink",children:f.message?e("span",{className:"font-medium text-ink/90 group-hover:text-ink",children:f.message}):null}),e("td",{className:"px-3 py-2 text-ink/60 whitespace-nowrap font-mono text-[10.5px]",children:f.time}),e("td",{className:"px-3 py-2 text-ink/70 whitespace-nowrap truncate max-w-[120px]",children:f.author}),e("td",{className:"px-3 py-2 text-right",children:f.hash?e("span",{className:"font-mono text-ink/50 group-hover:text-ink font-semibold transition-colors bg-canvas px-1.5 py-0.5 rounded border border-ink/10",children:f.hash}):null})]},x))})]}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs",children:"No commit history found for this file."}):l?.error?e("div",{className:"p-8 text-center text-error font-mono text-xs",children:l.error}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs",children:"Loading history..."}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs flex items-center justify-center space-x-2",children:[e(D,{size:14,className:"animate-spin"}),e("span",{children:"Loading history..."})]})})]})}),document.body)}function rt({actions:t,file:r,isFolder:l,chainLabel:c}){let p=t.selectionCount;return e(d,{children:[t.showCreateModal&&e(Fe,{folderPath:r.path,kind:t.createKind,value:t.createName,error:t.createError,isLoading:t.busy,onChange:t.setCreateName,onCancel:t.closeCreate,onSubmit:t.submitCreate}),t.showDeleteModal&&e(et,{fileName:r.path,displayName:p>1?void 0:c,isFolder:l,count:p,isLoading:t.busy,onCancel:t.closeDelete,onConfirm:t.submitDelete}),t.showRenameModal&&e(tt,{isFolder:l,renameValue:t.renameValue,originalPath:r.path,displayName:l?c:void 0,error:t.renameError,isLoading:t.busy,onChange:t.setRenameValue,onCancel:t.closeRename,onSubmit:t.submitRename}),t.showHistoryModal&&e(nt,{filePath:r.path,fetcherState:t.fetcherState,fetcherData:t.fetcherData,onClose:t.closeHistory})]})}function Ae(t){let r=t.map(an);return r.some((l,c)=>l!==t[c])?r:t}function an(t){if(t.type!=="folder"||!Array.isArray(t.children))return t;let r=Ae(t.children),l=r===t.children?t:{...t,children:r};while(Array.isArray(l.children)&&l.children.length===1){let c=l.children[0];if(c.type!=="folder")break;l={...l,name:`${l.name}/${c.name}`,path:c.path,children:c.children,ignored:c.ignored??l.ignored}}return l}function Se(t){return t.type==="folder"&&t.name.includes("/")}function Me(t,r){let l=r.split("/"),c=t.split("/");if(l.length<2||l.length>c.length||l.some((f)=>!f))return null;let p=c.slice(0,c.length-l.length);return l.map((f,x)=>[...p,...l.slice(0,x+1)].join("/"))}function ot(t,r){let l=new Map;if(r.size===0)return{nodes:t,roots:l};let c=!1,p=(x)=>x.flatMap((h)=>{if(h.type!=="folder")return[h];let v=Array.isArray(h.children)?p(h.children):h.children,g=v===h.children?h:{...h,children:v},m=r.has(h.path)?Me(h.path,h.name):null;if(!m)return[g];c=!0,l.set(m[0],h.path);let k={...g,name:m[m.length-1].split("/").pop()};for(let y=m.length-1;y>0;y-=1){let F=m[y-1];k={name:F.split("/").pop(),path:F,type:"folder",ignored:g.ignored,children:[k]}}return[k]}),f=p(t);return{nodes:c?f:t,roots:l}}function lt(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=st(),[x,h]=n(!1),[v,g]=n("file"),[m,k]=n(""),[y,F]=n(null),A=i(null);return o(()=>{if(f.state!=="idle"||!f.data)return;let C=f.data;if(A.current===C)return;if(A.current=C,C.success&&C.path){let E=C.kind==="folder"?"folder":"file";h(!1),k(""),F(null);let R=C.path.split("/").pop()||C.path;if(c({path:C.path,name:R,kind:E}),E==="file")p?.({path:C.path,name:R})}else F(C.error||`Could not create the ${v}`)},[f.state,f.data]),{open:x,kind:v,name:m,setName:k,error:y,busy:f.state!=="idle",openDialog:(C="file")=>{g(C),k(""),F(null),h(!0)},closeDialog:()=>h(!1),submit:(C)=>{C.preventDefault();let E=m.trim();if(!E)return;F(null);let R=new FormData;if(R.append("actionType","create"),R.append("path",t),R.append("name",E),v==="folder")R.append("kind","folder");if(l&&l!==".")R.append("repo",l);if(r)R.append("root",r);f.submit(R,{method:"post",action:"/api/fs/action"})}}}function we(t){if(!t)return null;if(t.entries.length===1)return t.entries[0].name;return`${t.entries.length} items`}function ct(t,r){return`${t??""}\x00${r}`}function Le(t,r){if(r==="folder")return t;let l=t.lastIndexOf("/");return l===-1?".":t.slice(0,l)}function dt(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)}function pt(t,r){if(t.path===""||t.path===".")return"The workspace root cannot be moved or copied";if(t.kind==="folder"&&(r===t.path||r.startsWith(`${t.path}/`)))return"Cannot paste a folder into itself";return null}function ut(t,r){let l=pt(t,r);if(l)return l;if(r===dt(t.path))return"Already in this folder";return null}function mt(t,r,l){if(!t||t.entries.length===0)return"Nothing to paste";if(t.scope!==r)return"The clipboard holds an entry from another workspace";if(t.mode==="cut"&&t.entries.some((c)=>l===dt(c.path)))return"Already in this folder";for(let c of t.entries){let p=pt(c,l);if(p)return p}return null}function ht(t){if(typeof t!=="object"||t===null)return null;let r=t;if(typeof r.scope!=="string")return null;if(r.mode!=="copy"&&r.mode!=="cut")return null;let l=Array.isArray(r.entries)?r.entries:typeof r.path==="string"?[{path:r.path,name:r.name,kind:r.kind}]:[],c=[];for(let p of l){let f=ln(p);if(!f)return null;c.push(f)}if(c.length===0)return null;return{scope:r.scope,entries:c,mode:r.mode}}function ln(t){if(typeof t!=="object"||t===null)return null;let r=t;if(typeof r.path!=="string"||typeof r.name!=="string")return null;if(r.kind!=="file"&&r.kind!=="folder")return null;let l=r.path.split("/");if(r.path===""||r.path.startsWith("/")||l.some((c)=>c===""||c==="."||c===".."))return null;return{path:r.path,name:r.name,kind:r.kind}}var $e=[{id:"zip",label:"ZIP",extension:"zip"},{id:"7z",label:"7Z",extension:"7z"},{id:"rar",label:"RAR",extension:"rar"},{id:"tar",label:"TAR",extension:"tar"},{id:"tar.gz",label:"TAR.GZ",extension:"tar.gz"}],gt=[[".tar.gz","tar.gz"],[".tar.bz2","tar.bz2"],[".tar.xz","tar.xz"],[".tgz","tar.gz"],[".tbz2","tar.bz2"],[".txz","tar.xz"],[".tar","tar"],[".zip","zip"],[".7z","7z"],[".rar","rar"],[".gz","gz"],[".bz2","bz2"],[".xz","xz"]];function ze(t){let r=t.toLowerCase();for(let[l,c]of gt)if(r.endsWith(l))return c;return null}function bt(t){return ze(t)!==null}function cn(t){return $e.find((r)=>r.id===t)}function dn(t){return cn(t)?.extension??"zip"}function xt(t){let r=t.toLowerCase();for(let[l]of gt)if(r.endsWith(l))return t.slice(0,-l.length);return t}function vt(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)||"."}function yt(t){let r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}function kt(t){if(t.length===0)return".";let r=t.map((c)=>vt(c).split("/").filter((p)=>p!==".")),l=r[0]??[];for(let c of r.slice(1)){let p=0;while(p<l.length&&p<c.length&&l[p]===c[p])p+=1;l=l.slice(0,p)}return l.length===0?".":l.join("/")}function De(t,r){let l=dn(r);if(t.length===1){let f=t[0],x=xt(f.name),h=x.lastIndexOf(".");return`${(f.kind==="folder"?f.name:h>0?x.slice(0,h):x)||"archive"}.${l}`}let c=kt(t.map((f)=>f.path)),p=yt(c);return`${p==="."||p===""?"archive":p}.${l}`}function Ct(t){return kt(t.map((r)=>r.path))}function Ft(t){let r=vt(t),l=xt(yt(t));if(!l)return r;return r==="."?l:`${r}/${l}`}function Nt(t){return t.toUpperCase()}function wt({file:t,diff:r,onOpenFile:l,onActionComplete:c,onCreated:p,onRenamed:f,onUnfold:x,onFold:h,clipboard:v,isFolder:g,selection:m,selected:k,archive:y}){let F=st(),[A,C]=n(null),E=i(null),[R,N]=n(!1),[T,H]=n(!1),[W,ee]=n(!1),[te,ae]=n(t.path),[G,I]=n(null),{repo:z,rootPath:K}=t,j=Ne({folderPath:t.path,rootPath:K,repo:z,onCreated:(M)=>p?p(M):c(),onOpenCreated:(M)=>l?.({...M,root:K,repo:z||"."})}),ne=i(null);o(()=>{if(F.state!=="idle"||!F.data)return;let M=F.data;if(ne.current===M)return;if(ne.current=M,M.success&&!M.type)if(N(!1),H(!1),I(null),M.previousPath&&M.path&&f)f(M.previousPath,M.path);else c();else if(!M.success&&M.error&&R)I(M.error)},[F.state,F.data]);let q=(M)=>{if(z&&z!==".")M.append("repo",z);if(K)M.append("root",K);F.submit(M,{method:"post",action:"/api/fs/action"})},X=()=>{l?.({path:t.path,name:t.name,root:K,repo:z||"."})},J={path:t.path,name:t.name,kind:g?"folder":"file"},se=k&&m.length>1?m:[J],he=bt(t.name),Q=v.clip&&!v.refusalFor(J)?`Paste ${we(v.clip)??"item"}`:null,fe=(M)=>{if(C(null),I(null),M==="view")X();else if(M==="diff")window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.path,staged:r?.staged,status:r?.status||"M",repo:z||".",root:K}}));else if(M==="explorer"){let _=new FormData;_.append("actionType","open_explorer"),_.append("path",t.path),q(_)}else if(M==="copy_path")qt(qu(t.basePath,t.path));else if(M==="copy_relative")qt(t.path);else if(M==="history"){ee(!0);let _=new FormData;_.append("actionType","git_history"),_.append("path",t.path),q(_)}else if(M==="rename")ae(t.path),N(!0);else if(M==="unfold")x?.();else if(M==="fold")h?.();else if(M==="new_file")j.openDialog("file");else if(M==="new_folder")j.openDialog("folder");else if(M==="delete")H(!0);else if(M==="cut")v.cut(se);else if(M==="copy")v.copy(se);else if(M==="compress")y.openCompress(se);else if(M==="extract")y.openExtract(J);else if(M==="duplicate")v.duplicate(J);else if(M==="paste")v.paste(J)},le=(M)=>{M.preventDefault(),I(null);let _=new FormData;_.append("actionType","rename"),_.append("path",t.path),_.append("newPath",te),q(_)},xe=()=>{let M=new FormData;if(M.append("actionType","delete"),se.length>1)M.append("paths",JSON.stringify(se.map((_)=>_.path)));else M.append("path",t.path);q(M)};return{contextMenu:A,contextMenuRef:E,openContextMenu:(M,_)=>C({x:M,y:_}),closeContextMenu:()=>C(null),showRenameModal:R,showDeleteModal:T,showHistoryModal:W,showCreateModal:j.open,createKind:j.kind,createError:j.error,createName:j.name,setCreateName:j.setName,renameValue:te,setRenameValue:ae,renameError:G,busy:F.state!=="idle"||j.busy||v.busy||y.busy,pasteLabel:Q,selectionCount:se.length,isArchive:he,chainLabel:x!==void 0,foldable:h!==void 0,fetcherState:F.state,fetcherData:F.data,handleAction:fe,submitCreate:j.submit,submitRename:le,submitDelete:xe,closeCreate:j.closeDialog,closeDelete:()=>H(!1),closeRename:()=>N(!1),closeHistory:()=>ee(!1)}}function Dt({target:t,dragging:r,clipboard:l,onDragStart:c,onDragEnd:p,onDropOn:f,onHoverAccept:x}){let h=r?.path===t.path,v=Boolean(r)&&!h&&l.moveRefusalFor(r,t)===null,[g,m]=n(!1);return o(()=>{if(!r)m(!1)},[r]),{isDragging:h,acceptsDrop:v,isDropHovered:g&&v,onDragStart:(y)=>{if(y.dataTransfer?.setData("text/plain",t.path),y.dataTransfer)y.dataTransfer.effectAllowed="move";c(t)},onDragEnd:p,onDragOver:(y)=>{if(!r)return;if(y.stopPropagation(),m(v),!v)return;if(y.preventDefault(),y.dataTransfer)y.dataTransfer.dropEffect="move";x?.(t)},onDragLeave:()=>m(!1),onDrop:(y)=>{if(!r)return;if(y.stopPropagation(),!v)return;y.preventDefault(),f(t)}}}function pn(t,r,l){if(r||l)return!1;return!Array.isArray(t.children)}function Oe({file:t,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:x,onCreated:h,onRenamed:v,expandedPaths:g,onToggleFolder:m,gitFileMap:k,gitFolderMap:y,clipboard:F,archive:A,selection:C,selectionTargets:E,dragging:R,onDragStart:N,onDragEnd:T,onDropOn:H,onUnfold:W,onFold:ee,foldRoots:te,touch:ae=!1}){let G=t.type==="folder",[I,z]=n(!1),[K,j]=n(!1),[ne,q]=n(!1),[X,J]=n(!1),se=Array.isArray(t.children)?t.children:[],he=(t.path||"").replace(/^\/+/,""),Q=!G?k?.get(he)||k?.get(t.path):void 0,fe=Q?Kn(Q.status,Q.staged):null,le=G?y?.get(he)||y?.get(t.path):null,xe=Boolean(fe),M=t.ignored===!0,_=g?g.has(t.path):I,ce=t.forceExpanded!==void 0?t.forceExpanded:_;o(()=>{J(!0)},[]),o(()=>{if(G&&g)z(g.has(t.path))},[g,t.path,G]),o(()=>{if(G&&ce&&pn(t,K,ne)&&p)q(!0),j(!0),Promise.resolve(p(t.path)).finally(()=>j(!1))},[G,ce,t.children,t.path,p,K,ne]);let ye={path:t.path,name:t.name,kind:G?"folder":"file"},be=C.selected.has(t.path),U=wt({file:{path:t.path,name:t.name,basePath:l,rootPath:r,repo:c},selection:E,selected:be,archive:A,diff:{staged:Q?.staged||(Q?.status?Q.status[0]!==" "&&Q.status[0]!=="?":!1),status:fe?.charStatus},onOpenFile:f,onActionComplete:x,onCreated:h,onRenamed:v,onUnfold:W&&Se({type:G?"folder":"file",name:t.name})?()=>W(ye):void 0,onFold:ee&&te?.has(t.path)?()=>ee(te.get(t.path)):void 0,clipboard:F,isFolder:G});pe(U.contextMenuRef,U.closeContextMenu);let Y=Pu({enabled:ae,onLongPress:(V,ge)=>U.openContextMenu(V,ge)}),ke=(V)=>{if(V.stopPropagation(),Y.consume())return;let ge=C.gestureOf(V);if(ge!=="plain"){C.applyGesture(ge,t.path);return}if(C.applyGesture("plain",t.path),G){let ue=!ce;if(z(ue),t.forceExpanded!==void 0)t.forceExpanded=void 0;if(m?.(t.path,ue),!ue)q(!1)}else if(f)f({...t,root:r,repo:c||"."})},ve=(V)=>{V.preventDefault(),V.stopPropagation(),C.ensureForContext(t.path),U.openContextMenu(V.clientX,V.clientY)},de=Dt({target:ye,dragging:R,clipboard:F,onDragStart:N,onDragEnd:T,onDropOn:H,onHoverAccept:W});return e("div",{children:[e("div",{className:`flex items-center space-x-1.5 py-1 px-2 cursor-pointer rounded group select-none ${de.isDragging?"opacity-40":""} ${de.isDropHovered?"bg-info/10 ring-1 ring-info/40 ring-inset":be?"bg-ink/[0.08] ring-1 ring-ink/20 ring-inset":"hover:bg-ink/5"}`,draggable:!ae,onClick:ke,onContextMenu:ve,onDragStart:de.onDragStart,onDragEnd:de.onDragEnd,onDragOver:de.onDragOver,onDragLeave:de.onDragLeave,onDrop:de.onDrop,onTouchStart:Y.onTouchStart,onTouchMove:Y.onTouchMove,onTouchEnd:Y.onTouchEnd,onTouchCancel:Y.onTouchCancel,children:e(Je,{name:t.name,path:t.path,isFolder:G,isOpen:ce,ignored:M,selected:be,gitStatus:fe,folderStatus:le})}),ce&&K&&e("div",{className:"ml-3 border-l border-ink/10 pl-3 py-0.5 text-[10px] text-ink/30",children:"Loading…"}),ce&&!K&&se.length>0&&e("div",{className:"ml-3 border-l border-ink/10 pl-1",children:se.map((V)=>e(Oe,{file:V,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:x,onCreated:h,onRenamed:v,expandedPaths:g,onToggleFolder:m,gitFileMap:k,gitFolderMap:y,clipboard:F,archive:A,selection:C,selectionTargets:E,dragging:R,onDragStart:N,onDragEnd:T,onDropOn:H,onUnfold:W,onFold:ee,foldRoots:te,touch:ae},V.path))}),X&&U.contextMenu&&e(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}),X&&e(rt,{actions:U,file:t,isFolder:G,chainLabel:Se({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 oe(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>p("close"),onContextMenu:(m)=>{m.preventDefault(),p("close")},children:e("div",{ref:f,className:"glass-popover fixed z-50 bg-paper border border-ink/15 shadow-2xl rounded-lg py-1 min-w-[185px] text-xs text-ink font-sans",style:{top:g,left:v},onClick:(m)=>m.stopPropagation(),children:[e("button",{type:"button",onClick:()=>p("new_file"),className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 flex items-center space-x-2 transition-colors",children:[e(ri,{size:13,className:"text-ink/60"}),e("span",{children:"New File"})]}),e("button",{type:"button",onClick:()=>p("new_folder"),className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 flex items-center space-x-2 transition-colors",children:[e(sn,{size:13,className:"text-ink/60"}),e("span",{children:"New Folder"})]}),l&&e("button",{type:"button",disabled:c,onClick:()=>p("paste"),className:`w-full text-left px-3 py-1.5 flex items-center space-x-2 transition-colors ${c?"opacity-40 cursor-default":"hover:bg-ink/5"}`,children:[e(yo,{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 At({title:t,subject:r,error:l,busy:c,submitLabel:p,busyLabel:f,onSubmit:x,onCancel:h,children:v}){return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:x,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-1 text-sm",children:t}),e("p",{className:"text-[11px] text-ink/50 mb-3 break-words",children:r}),v,l&&e("p",{className:"text-[11px] text-error mb-2",children:l}),e("div",{className:"flex justify-end space-x-2 mt-3",children:[e("button",{type:"button",onClick:h,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:c,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:c,children:c?f:p})]})]})}),document.body)}function un({entries:t,format:r,name:l,destination:c,formats:p,error:f,busy:x,onFormatChange:h,onNameChange:v,onDestinationChange:g,onCancel:m,onSubmit:k}){let y=t.slice(0,4).map((A)=>A.name).join(", "),F=t.length>4?` +${t.length-4} more`:"";return e(At,{title:`Compress ${t.length===1?t[0].name:`${t.length} items`}`,subject:`${y}${F}`,error:f,busy:x,submitLabel:"Compress",busyLabel:"Compressing...",onCancel:m,onSubmit:(A)=>{A.preventDefault(),k()},children:[e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"archive-format",children:"Format"}),e("select",{id:"archive-format",value:r,onChange:(A)=>h(A.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 text-xs font-mono focus:outline-none focus:border-ink mb-3",children:p.map((A)=>e("option",{value:A.id,disabled:!A.available,children:[A.label,A.available?"":` — ${A.tool} not installed`]},A.id))}),e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"archive-name",children:"Archive name"}),e("input",{id:"archive-name",autoFocus:!0,type:"text",value:l,onChange:(A)=>v(A.currentTarget.value),"aria-label":"Archive name",className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none mb-3 ${f?"border-error":"border-ink/20 focus:border-ink"}`}),e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"archive-destination",children:"Destination folder"}),e("input",{id:"archive-destination",type:"text",value:c,onChange:(A)=>g(A.currentTarget.value),"aria-label":"Archive destination",className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 text-xs font-mono focus:outline-none focus:border-ink"})]})}function fn({archive:t,kindLabel:r,destination:l,error:c,busy:p,onDestinationChange:f,onCancel:x,onSubmit:h}){return e(At,{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 St({archive:t}){if(t.compress)return e(un,{entries:t.compress.entries,format:t.compress.format,name:t.compress.name,destination:t.compress.destination,formats:t.formats,error:t.error,busy:t.busy,onFormatChange:t.setFormat,onNameChange:t.setName,onDestinationChange:t.setCompressDestination,onCancel:t.cancel,onSubmit:t.submitCompress});if(t.extract)return e(fn,{archive:t.extract.archive,kindLabel:Nt(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=yr(),c=Ue(uA,cA),{symbols:p,total:f,truncated:x,notice:h}=zu({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=Hu(p,k);if(y)Yi({path:c.path,...y});return}Vi({path:c.path,line:m.line,column:m.column,length:m.name.length})};return e("div",{className:"border-t border-ink/10 bg-canvas/30 flex-shrink-0",children:[e("div",{className:"flex items-center hover:bg-ink/5 transition-colors",children:e("button",{type:"button",onClick:()=>r(!t),"aria-expanded":t,"aria-controls":l,"aria-label":"Outline",title:t?"Hide outline":"Show outline",className:"flex flex-1 min-w-0 items-center space-x-1 py-1.5 pl-3 pr-2 text-left font-semibold text-xs text-ink transition-colors cursor-pointer",children:[e("span",{className:"w-3 text-center font-mono","aria-hidden":"true",children:t?"▾":"▸"}),e(Kr,{size:12}),e("span",{children:"Outline"}),f>0&&e("span",{className:"font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[10px] text-ink/50",children:x?`${p.length}/${f.toLocaleString()}`:f})]})}),e("div",{className:"section-reveal","data-expanded":t,id:l,inert:!t,children:e("div",{children:e("div",{className:"px-2 pb-2",children:p.length===0?e("div",{className:"px-1 text-[10px] text-ink/40 italic py-1",children:h}):e("div",{className:"max-h-48 overflow-y-auto scrollbar-overlay-container flex flex-col",children:[p.map((m,k)=>e("button",{type:"button",onClick:()=>g(m,k),"aria-label":v?`${Jo(m.kind)} ${m.name}`:`${Jo(m.kind)} ${m.name}, line ${m.line}`,title:v?`Jump to ${Jo(m.kind).toLowerCase()}`:`${Jo(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(Ou,{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:$u(f)})]})})})})]})}function Pe(t,r){return Ae(t.map((l)=>mn(l,r)))}function mn(t,r){if(t.type!=="folder")return t;let l=r[t.path];if(!l)return t;return{...t,children:Pe(l,r)}}function hn(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)}function 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((E)=>E.type==="folder"&&E.path===m),y=k?null:h.find((E)=>E.type==="folder"&&E.path.startsWith(`${m}/`)&&(p===E.path||p.startsWith(`${E.path}/`))),F=k??y,A=F?x[F.path]??F.children:null;if(F&&!Array.isArray(A))return{nodes:t,cache:r};if(!F){let E=gn(h,x,m);if(E){h=E;let R=h.find((T)=>T.path===m),N=Array.isArray(R?.children)?[...R.children]:[];x[m]=N,h=N,v=m,g+=1;continue}}let C=Array.isArray(A)?[...A]:[];if(F){x[F.path]=C,h=C,v=F.path,g=F.path.split("/").length;continue}h.push({name:c[g],path:m,type:"folder",ignored:!1}),x[m]=C,h=C,v=m,g+=1}if(h.push(l),v!==null)x[v]=Mt(h);return f=Mt(f),{nodes:f,cache:x}}function gn(t,r,l){let c=t.findIndex((v)=>v.type==="folder"&&v.path.startsWith(`${l}/`));if(c===-1)return null;let p=t[c],f=p.path.slice(l.length+1).split("/"),x=r[p.path]??p.children;if(Array.isArray(x))r[p.path]=x;let h={name:f[f.length-1],path:p.path,type:"folder",ignored:p.ignored,...Array.isArray(x)?{children:x}:{}};for(let v=f.length-2;v>=0;v-=1)h={name:f[v],path:`${l}/${f.slice(0,v+1).join("/")}`,type:"folder",ignored:!1,children:[h]};return t[c]={name: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=hn(l),f=r[p],x=f?.find((m)=>m.path===l);if(f&&x)return{entry:x,nodes:t,cache:{...r,[p]:f.filter((m)=>m.path!==l)}};let v=Object.keys(r).filter((m)=>l.startsWith(`${m}/`)&&r[m].some((k)=>k.path===l)).sort((m,k)=>k.length-m.length)[0];if(!v)return{entry:null,nodes:t,cache:r};let g=r[v];return{entry:g.find((m)=>m.path===l),nodes:t,cache:{...r,[v]:g.filter((m)=>m.path!==l)}}}function 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 He(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=i({}),k=i([]),y=i(f);y.current=f;let F=i(""),A=i(""),C=i(c);C.current=c;let E=(I)=>{let z=new URLSearchParams;if(r)z.set("root",r);if(l&&l!==".")z.set("repo",l);if(I)z.set("path",I);return z.set("t",String(Date.now())),`/api/fs/dir?${z.toString()}`},R=(I,z)=>{F.current=I,A.current=z;let K=Pe(k.current,m.current);return h({scope:I,files:K,root:z}),K},N=async(I)=>{let z=[...C.current];if(z.length===0)return;let K=await Promise.all(z.map(async(X)=>({path:X,read:await He(E(X))})));if(y.current!==I)return;let j=[];for(let{path:X,read:J}of K)if(J.status==="ok")m.current[X]=J.files;else if(J.status==="missing")j.push(X);if(j.length===0)return;let ne=new Set(j);for(let X of j)delete m.current[X];let q=new Set([...C.current].filter((X)=>!ne.has(X)));C.current=q,p(q)},T=async()=>{if(!t)return;let I=y.current;g(!0);try{let z=await He(E());if(y.current!==I)return;if(z.status!=="ok")return;if(F.current!==I)m.current={};if(k.current=z.files,R(I,z.root),await N(I),y.current!==I)return;R(I,z.root)}finally{if(y.current===I)g(!1)}},H=async(I)=>{let z=y.current,K=await He(E(I));if(y.current!==z||K.status!=="ok")return;if(m.current[I]=K.files,F.current===z)R(z,A.current)},W=(I)=>{let z=It(I);if(z.status!=="ok")return;let K=y.current;if(F.current!==K)m.current={};k.current=z.files,R(K,z.root),N(K).then(()=>{if(y.current===K)R(K,z.root)})},ee=()=>{m.current={},k.current=[],F.current="",A.current="",h({scope:"",files:[],root:""})},te=(I)=>{let z=y.current;if(F.current!==z)return null;let K={name:I.path.slice(I.path.lastIndexOf("/")+1),path:I.path,type:I.kind,ignored:!1},j=Ie(k.current,m.current,K);if(j.nodes===k.current)return null;return k.current=j.nodes,m.current=j.cache,R(z,A.current)},ae=(I,z)=>{let K=y.current;if(F.current!==K)return null;let j=$t(k.current,m.current,I);if(!j.entry)return null;m.current=Ot(j.cache,I,z);let ne={...j.entry,path:z,name:z.slice(z.lastIndexOf("/")+1)},q=Ie(j.nodes,m.current,ne);return k.current=q.nodes,m.current=q.cache,R(K,A.current)},G=x.scope===f;return{scope:f,files:G?x.files:[],root:G?x.root:"",isLoading:v,reload:T,loadChildren:H,adoptRoot:W,insertEntry:te,moveEntry:ae,reset:ee}}function Gt({rootPath:t,repo:r,onComplete:l,onError:c}){let p=st(),[f,x]=S("files.clipboard",null),h=ht(f),v=ct(t,r),g=i(!1),m=i(null);o(()=>{if(p.state!=="idle"||!p.data)return;let C=p.data;if(m.current===C)return;m.current=C;let E=g.current;if(g.current=!1,C.success){if(E)x(null);if(C.failures?.length)c(`${C.failures.length} item(s) could not be moved: ${C.failures[0].error}`);l()}else c(C.error||"The transfer did not complete")},[p.state,p.data]);let k=a((C,E)=>{g.current=E;let R=new FormData;for(let[N,T]of Object.entries(C))R.append(N,T);if(r&&r!==".")R.append("repo",r);if(t)R.append("root",t);p.submit(R,{method:"post",action:"/api/fs/action"})},[p,r,t]),y=a((C)=>mt(h,v,Le(C.path,C.kind)),[h,v]),F=a((C,E)=>ut(C,Le(E.path,E.kind)),[]),A=a((C,E,R,N)=>{let T=new FormData;T.append("actionType","paste"),T.append("mode",R),T.append("targetPath",E.path),T.append("targetKind",E.kind);for(let H of C)T.append("sourcePath",H.path);if(r&&r!==".")T.append("repo",r);if(t)T.append("root",t);g.current=N,p.submit(T,{method:"post",action:"/api/fs/action"})},[p,r,t]);return{clip:h,busy:p.state!=="idle",refusalFor:y,moveRefusalFor:F,copy:(C)=>{if(C.length===0)return;x({scope:v,entries:C.map(({path:E,name:R,kind:N})=>({path:E,name:R,kind:N})),mode:"copy"})},cut:(C)=>{if(C.length===0)return;x({scope:v,entries:C.map(({path:E,name:R,kind:N})=>({path:E,name:R,kind:N})),mode:"cut"})},duplicate:(C)=>{k({actionType:"duplicate",path:C.path},!1)},move:(C,E)=>{let R=F(C,E);if(R){c(R);return}A([C],E,"cut",Boolean(h?.mode==="cut"&&h.entries.some((N)=>N.path===C.path)))},paste:(C)=>{if(!h)return;let E=y(C);if(E){c(E);return}A(h.entries.map(({path:R,name:N,kind:T})=>({path:R,name:N,kind:T})),C,h.mode,h.mode==="cut")}}}var bn=$e.map((t)=>({...t,available:!0,tool:t.id}));function Kt({rootPath:t,repo:r,onComplete:l}){let c=st(),[p,f]=n(bn),[x,h]=n(null),[v,g]=n(null),[m,k]=n(null),y=i(null),F=i(null);o(()=>{let N=!1;return(async()=>{try{let H=await(await fetch("/api/fs/archive")).json();if(!N&&Array.isArray(H.formats)&&H.formats.length>0)f(H.formats)}catch{}})(),()=>{N=!0}},[]),o(()=>{if(c.state!=="idle"||!c.data)return;let N=c.data;if(F.current===N)return;F.current=N;let T=y.current;if(y.current=null,N.success){if(k(null),T==="compress")h(null);if(T==="extract")g(null);l()}else if(T)k(N.error||"The archive request failed")},[c.state,c.data]);let A=a((N)=>{let T=new FormData;for(let[H,W]of Object.entries(N))T.append(H,W);if(r&&r!==".")T.append("repo",r);if(t)T.append("root",t);c.submit(T,{method:"post",action:"/api/fs/action"})},[c,r,t]),C=a((N)=>{if(N.length===0)return;let T=p.find((H)=>H.id==="zip"&&H.available)?.id??p.find((H)=>H.available)?.id??"zip";k(null),g(null),h({entries:N.map(({path:H,name:W,kind:ee})=>({path:H,name:W,kind:ee})),format:T,name:De(N,T),destination:Ct(N)})},[p]),E=a((N)=>{k(null),h(null),g({archive:N,destination:Ft(N.path)})},[]),R=a((N)=>{h((T)=>{if(!T)return T;let H=De(T.entries,T.format),W=T.name===H?De(T.entries,N):T.name;return{...T,format:N,name:W}})},[]);return{formats:p,compress:x,extract:v,error:m,busy:c.state!=="idle",openCompress:C,openExtract:E,setFormat:R,setName:(N)=>h((T)=>T&&{...T,name:N}),setCompressDestination:(N)=>h((T)=>T&&{...T,destination:N}),setExtractDestination:(N)=>g((T)=>T&&{...T,destination:N}),cancel:()=>{h(null),g(null),k(null)},submitCompress:()=>{let N=x;if(!N)return;y.current="compress",k(null),A({actionType:"compress",format:N.format,name:N.name.trim(),destination:N.destination.trim()||".",paths:JSON.stringify(N.entries.map((T)=>T.path))})},submitExtract:()=>{let N=v;if(!N)return;y.current="extract",k(null),A({actionType:"extract",path:N.archive.path,destination:N.destination.trim()||"."})}}}function xn(t){if(t.shiftKey)return"range";if(t.metaKey||t.ctrlKey)return"toggle";return"plain"}function vn(t,r,l){if(!r)return[l];let c=t.indexOf(r),p=t.indexOf(l);if(c===-1||p===-1)return[l];let f=Math.min(c,p),x=Math.max(c,p);return t.slice(f,x+1)}function jt(t){let[r,l]=n(()=>new Set),[c,p]=n(null),f=a((g,m)=>{if(g==="range"){l(new Set(vn(t,c,m)));return}if(p(m),g==="toggle"){l((k)=>{let y=new Set(k);if(y.has(m))y.delete(m);else y.add(m);return y});return}l(new Set([m]))},[c,t]),x=a((g)=>{l((m)=>{if(m.has(g))return m;return new Set([g])}),p(g)},[]),h=a(()=>{l(new Set),p(null)},[]),v=a(xn,[]);return u(()=>({selected:r,count:r.size,anchor:c,gestureOf:v,applyGesture:f,ensureForContext:x,clear:h}),[r,c,v,f,x,h])}function Ge(t,r,l=0,c=[]){for(let p of t)if(c.push({path:p.path,name:p.name,kind:p.type==="folder"?"folder":"file",depth:l}),p.type==="folder"&&r(p)&&Array.isArray(p.children))Ge(p.children,r,l+1,c);return c}function _t({listing:t,setExpandedPaths:r,setStoredExpandedPaths:l,reload:c,onMoved:p}){let f=a((v,g)=>{let m=lt(g,v);if(m.length===0)return;r((k)=>{if(m.every((F)=>k.has(F)))return k;let y=new Set(k);for(let F of m)y.add(F);return l(Array.from(y)),y})},[r,l]),x=a((v)=>{let g=t.insertEntry(v);if(!g){c();return}f(v.path,g)},[t,c,f]),h=a((v,g)=>{p?.(v,g),r((k)=>{let y=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 yn=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 A=new Map(y);return A.set(v.path,g),{scope:t,chains:A}});let m=g.slice(0,-1);r((k)=>{if(m.every((F)=>k.has(F)))return k;let y=new Set(k);for(let F of m)y.add(F);return l(Array.from(y)),y})},[t,r,l]),x=a((v)=>{let g=c.scope===t?c.chains.get(v):void 0;if(!g)return;let m=g.slice(0,-1);p((k)=>{if(k.scope!==t)return k;let y=new Map(k.chains);return y.delete(v),{scope:t,chains:y}}),r((k)=>{if(!m.some((F)=>k.has(F)))return k;let y=new Set(k);for(let F of m)y.delete(F);return l(Array.from(y)),y})},[t,c,r,l]),h=a((v,g)=>{let m=c.scope===t?c.chains:null;if(!m)return;let k=new Map,y=[],F=!1;for(let[A,C]of m){if(C.findIndex((T,H)=>T===v&&H>0&&H<C.length-1)!==-1){F=!0;continue}let R=C.map((T)=>T===v?g:T.startsWith(`${v}/`)?`${g}${T.slice(v.length)}`:T),N=R[R.length-1];if(N!==A||R.some((T,H)=>T!==C[H]))F=!0;k.set(N,R),y.push(...R.slice(0,-1))}if(!F)return;p({scope:t,chains:k}),r((A)=>{if(y.every((E)=>A.has(E)))return A;let C=new Set(A);for(let E of y)C.add(E);return l(Array.from(C)),C})},[t,c,r,l]);return{unfolded:c.scope===t&&c.chains.size>0?new Set(c.chains.keys()):yn,unfold:f,fold:x,rekey:h}}function 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 o(()=>{if(!t)f(!1)},[t]),{accepts:c,highlighted:p&&c,onDragEnter:()=>{if(t)f(!0)},onDragLeave:(x)=>{if(!x.currentTarget.contains(x.relatedTarget))f(!1)},onDragOver:(x)=>{if(!c)return;if(x.preventDefault(),x.dataTransfer)x.dataTransfer.dropEffect="move"},onDrop:(x)=>{if(!c)return;x.preventDefault(),f(!1),r.move(t,l)}}}function ni({className:t="",enabled:r=!0,active:l=!0,rootPath:c,onOpenFile:p,refreshKey:f=0,onRefresh:x}){let[h,v]=S("files.searchQuery",""),[g,m,k]=S("files.expandedPaths",[]),[y,F]=n(()=>new Set(g)),{activeRepo:A,setActiveRepo:C}=cr(c),{repos:E,scanning:R,rescan:N}=ur(c,r),{fileMap:T,folderMap:H,refreshGitStatus:W}=Os(c,A,r),[ee,te]=n(null),ae=i(null);o(()=>{if(!k)return;F((P)=>{let Z=new Set(g);if(P.size===Z.size&&Array.from(Z).every((me)=>P.has(me)))return P;return Z})},[k,g]);let G=Ht({enabled:r,rootPath:c,activeRepo:A,expandedPaths:y,onExpansionPruned:(P)=>{F(P),m(Array.from(P))}});o(()=>{if(!k||!l)return;G.reload()},[f,c,r,A,k,l]);let I=r&&k?Jg(G.scope):null,z=Ce(I);o(()=>{if(z.data)G.adoptRoot(z.data)},[z.data]);let K=(P)=>(W(),G.loadChildren(P)),j=(P,Z)=>{let me=new Set(y);if(Z)me.add(P);else me.delete(P);F(me),m(Array.from(me))},{unfolded:ne,unfold:q,fold:X,rekey:J}=Wt({scope:G.scope,setExpandedPaths:F,setStoredExpandedPaths:m}),se=G.files,he=ot(se,ne),Q=Ut(he.nodes,h),fe=Ge(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})),M=(P)=>{if(P===A)return;G.reset(),F(new Set),m([]),le.clear(),C(P)},_=()=>{if(W(),x)x();else G.reload()},{insertCreated:ce,moveRenamed:ye}=_t({listing:G,setExpandedPaths:F,setStoredExpandedPaths:m,reload:_,onMoved:(P,Z)=>J(P,Z)}),be=Zi(),{pushToast:U}=je(),Y=Gt({rootPath:c,repo:A,onComplete:_,onError:(P)=>U(P,"error")}),ke=Kt({rootPath:c,repo:A,onComplete:_}),ve={path:".",name:".",kind:"folder"},de=Y.clip&&!Y.refusalFor(ve)?`Paste ${we(Y.clip)??"item"}`:null,[V,ge]=n(null),ue=Vt({dragging:V,clipboard:Y,target:ve}),Re=Ne({folderPath:".",rootPath:c,repo:A,onCreated:ce,onOpenCreated:(P)=>p?.({...P,root:c,repo:A})}),[Ke,Xt]=n(!1);o(()=>Xt(!0),[]);let{count:_e,clear:We}=le;if(o(()=>{if(!l)return;let P=(Z)=>{if(Z.key==="Escape"&&_e>0)We()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[l,_e,We]),!r)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${t}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});let Bt=G.isLoading||z.refreshing;return e("div",{className:`flex flex-col h-full bg-paper ${t}`,children:[e(Ye,{rootPath:c,activeRepo:A,repos:E,reposScanning:R,onRefreshRepos:N,onSelectRepo:M,searchQuery:h,onSearchChange:v,onRefresh:_,refreshing:Bt}),e("div",{className:`flex-1 scrollbar-overlay-container p-2 font-mono text-[11px] text-ink/80 ${be?"file-tree-touch":""} ${ue.highlighted?"bg-info/[0.06]":""}`,onContextMenu:(P)=>{P.preventDefault(),te({x:P.clientX,y:P.clientY})},onDragEnter:ue.onDragEnter,onDragLeave:ue.onDragLeave,onDragOver:ue.onDragOver,onDrop:ue.onDrop,children:G.isLoading&&Q.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"Loading files..."}):Q.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"No files found"}):Q.map((P)=>e(Oe,{file:P,rootPath:c,basePath:G.root,repo:A,onLoadChildren:K,onOpenFile:p,onActionComplete:_,onCreated:ce,onRenamed:ye,expandedPaths:y,onToggleFolder:j,gitFileMap:T,gitFolderMap:H,clipboard:Y,archive:ke,selection:le,selectionTargets:xe,dragging:V,onDragStart:ge,onDragEnd:()=>ge(null),onDropOn:(Z)=>{if(!V)return;Y.move(V,Z)},onUnfold:q,onFold:X,foldRoots:he.roots,touch:be},P.path))}),e(Et,{}),Ke&&e(Tt,{menu:ee,menuRef:ae,pasteLabel:de,busy:Y.busy,create:Re,onAction:(P)=>{if(te(null),P==="new_file")Re.openDialog("file");if(P==="new_folder")Re.openDialog("folder");if(P==="paste")Y.paste(ve)}}),Ke&&e(St,{archive:ke})]})}export{ni as FileExplorer};
|