@kabmo-labs/kabmo 0.49.0 → 0.51.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 +606 -560
- package/dist/client/static/js/{Body-9h5hd351.js → Body-s3nh6vet.js} +3 -3
- package/dist/client/static/js/{CsvGrid-s05k1q18.js → CsvGrid-j4h6cpnn.js} +2 -2
- package/dist/client/static/js/{DocxView-x6sjw5ht.js → DocxView-197x16zq.js} +3 -3
- package/dist/client/static/js/{DrawioView-jashn8sf.js → DrawioView-v6ps0cm5.js} +2 -2
- package/dist/client/static/js/{HtmlPreview-eygzgtyc.js → HtmlPreview-a2t5zngp.js} +1 -1
- package/dist/client/static/js/ImageView-ar7hz7jx.js +1 -0
- package/dist/client/static/js/LayoutWrapper-epef152a.js +2 -0
- package/dist/client/static/js/MergeDiffView-7rwjvzk5.js +1 -0
- package/dist/client/static/js/Modal-9nxt67fm.js +60 -0
- package/dist/client/static/js/{PdfView-syhjmyqf.js → PdfView-gzhcym20.js} +1 -1
- package/dist/client/static/js/SessionsView-3h872gpe.js +1 -0
- package/dist/client/static/js/{SheetView-26r0e506.js → SheetView-baaynkb4.js} +22 -22
- package/dist/client/static/js/{SvgPreview-2fk85jzz.js → SvgPreview-jzcqwwcc.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-fdka7pxr.js → abnfDiagram-O67JEVCF-grb1sfhr.js} +1 -1
- package/dist/client/static/js/architecture-7GRP2DOG-3hkq8grc.js +1 -0
- package/dist/client/static/js/architectureDiagram-NJMV4G6O-9084jzwr.js +36 -0
- package/dist/client/static/js/{astro-rn2bvwpm.js → astro-m3fcq2sa.js} +1 -1
- package/dist/client/static/js/bash-n7wcmq3s.js +1 -0
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-vpcmd3vx.js → blockDiagram-BEXU5L5S-qqcjrg1b.js} +8 -8
- package/dist/client/static/js/c-ypdp030b.js +1 -0
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-1rgpdnbq.js → c4Diagram-YGBWAQC7-gc8fqbpc.js} +3 -3
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-fbsejvb9.js → classDiagram-v2-NBCMYWYE-pp6060kq.js} +9 -9
- package/dist/client/static/js/cose-bilkent-JH36ORCC-744ekavk.js +1 -0
- package/dist/client/static/js/cpp-cxwev3gs.js +1 -0
- package/dist/client/static/js/css-6mxcqf8c.js +1 -0
- package/dist/client/static/js/css-9gak6bze.js +1 -0
- package/dist/client/static/js/cynefin-OW5HDTMX-9m18e6m5.js +1 -0
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-7ta5vbrw.js → cynefinDiagram-VND7K2PF-57dja6g9.js} +2 -2
- package/dist/client/static/js/{dagre-6A5THRUB-b8gtt32x.js → dagre-6A5THRUB-de4xrbrw.js} +2 -2
- package/dist/client/static/js/{diagram-22UHCM2B-7emepy7h.js → diagram-22UHCM2B-ky3ncyv8.js} +21 -21
- package/dist/client/static/js/diagram-3UASUU5V-zgg82bz9.js +24 -0
- package/dist/client/static/js/{diagram-ATOU4E4O-t113exk3.js → diagram-ATOU4E4O-r4s13e4n.js} +3 -3
- package/dist/client/static/js/{diagram-CDSNMT55-pyj3x97y.js → diagram-CDSNMT55-my21t0kq.js} +4 -4
- package/dist/client/static/js/{diagram-MLGK6HIB-183sgpjh.js → diagram-MLGK6HIB-pvt20jtj.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-fmbj4hcx.js → diagram-MPIPVDR6-as9dk4f3.js} +2 -2
- package/dist/client/static/js/{dockerfile-qay672za.js → dockerfile-3b5caedj.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-eafvfws2.js → ebnfDiagram-ZINNZB2B-tj3hkcj4.js} +1 -1
- package/dist/client/static/js/{elixir-t8bep87c.js → elixir-7q2k61zb.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-573f1vfs.js → elk-276RUBZZ-5e7wczf3.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-4z1r88ej.js → erDiagram-OPXOYQCR-5jje7qrh.js} +12 -12
- package/dist/client/static/js/{erlang-261km7r1.js → erlang-tjsd7n4d.js} +1 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-d4egnv9v.js +1 -0
- package/dist/client/static/js/flowDiagram-KWPJA3E3-pdeqndnd.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-49jd7msz.js → ganttDiagram-FUAMR5RP-7hresycc.js} +6 -6
- package/dist/client/static/js/gitGraph-4MIJSDKK-grqv890n.js +1 -0
- package/dist/client/static/js/gitGraphDiagram-X574FWY7-8m202jb7.js +106 -0
- package/dist/client/static/js/graphql-6rwdfcnf.js +1 -0
- package/dist/client/static/js/html-p76eszt9.js +1 -0
- package/dist/client/static/js/{index-0w4jqzqk.js → index-0prwdwyb.js} +2 -2
- package/dist/client/static/js/{index-3v8k8ms3.js → index-0y6tstk8.js} +1 -1
- package/dist/client/static/js/index-20hj80g4.js +4 -0
- package/dist/client/static/js/index-21421tq7.js +2 -0
- package/dist/client/static/js/{index-gg910gpv.js → index-254387vg.js} +2 -2
- package/dist/client/static/js/index-2y4gk5q5.js +2 -0
- package/dist/client/static/js/index-3fk8grhz.js +2 -0
- package/dist/client/static/js/index-3rrdmk9m.js +2 -0
- package/dist/client/static/js/{index-rz0tz4hg.js → index-3sz9cztk.js} +1 -1
- package/dist/client/static/js/index-4m2d73m3.css +1 -0
- package/dist/client/static/js/{index-2bf0txsp.js → index-4nvcwtvr.js} +2 -2
- package/dist/client/static/js/index-4ppap7vb.js +9 -0
- package/dist/client/static/js/{index-qs4n116g.js → index-4tbdws4r.js} +2 -2
- package/dist/client/static/js/index-56hy2hcy.js +1 -0
- package/dist/client/static/js/{index-7rmps91t.js → index-60g0e74a.js} +2 -2
- package/dist/client/static/js/{index-zp40g8ah.js → index-7ag37ghj.js} +12 -12
- package/dist/client/static/js/{index-z6y8j93w.js → index-7ehcjb3r.js} +7 -7
- package/dist/client/static/js/index-899yw6fh.js +2 -0
- package/dist/client/static/js/{index-2yzt8h3d.js → index-8pqx5n2p.js} +2 -2
- package/dist/client/static/js/{index-dh060b7r.js → index-91jm3ywm.js} +2 -2
- package/dist/client/static/js/{index-yg083mk0.js → index-9qf2h9jb.js} +6 -6
- package/dist/client/static/js/{index-tcfpzqb9.js → index-9rp7h1nv.js} +20 -20
- package/dist/client/static/js/index-9rr23e0e.js +2 -0
- package/dist/client/static/js/index-9wj4ma9g.js +3 -0
- package/dist/client/static/js/index-awtk0djy.js +1 -0
- package/dist/client/static/js/{index-4dnc1kys.js → index-awz6pyd0.js} +2 -2
- package/dist/client/static/js/index-cvx1vkrx.js +1 -0
- package/dist/client/static/js/{index-c3whkrwa.js → index-cwwg7k5f.js} +33 -33
- package/dist/client/static/js/{index-ykc14gez.js → index-dzatbdws.js} +6 -6
- package/dist/client/static/js/{index-j37m7pn9.js → index-e6ew77ph.js} +2 -2
- package/dist/client/static/js/{index-tb35a328.js → index-ej1va073.js} +2 -2
- package/dist/client/static/js/{index-4ccs971z.js → index-er7pj5k6.js} +2 -2
- package/dist/client/static/js/index-fm0t4pct.js +4 -0
- package/dist/client/static/js/{index-0857zpr0.js → index-g5wp6ksw.js} +2 -2
- package/dist/client/static/js/{index-nzvte8s5.js → index-gy4mtr2e.js} +2 -2
- package/dist/client/static/js/{index-1yq96wpa.js → index-j9y4tjk0.js} +2 -2
- package/dist/client/static/js/{index-7ff9scbm.js → index-kt7c42n7.js} +2 -2
- package/dist/client/static/js/index-ktmb341a.js +468 -0
- package/dist/client/static/js/{index-taev57jw.js → index-m6zncj00.js} +2 -2
- package/dist/client/static/js/{index-dmc82cxb.js → index-mpyd7qxj.js} +2 -2
- package/dist/client/static/js/{index-1p880x6e.js → index-ms80nne4.js} +2 -2
- package/dist/client/static/js/{index-yyjw1ty9.js → index-my856e49.js} +2 -2
- package/dist/client/static/js/{index-pygy21w5.js → index-nnqyew8n.js} +2 -2
- package/dist/client/static/js/{index-qwxawph7.js → index-nt17ejrm.js} +2 -2
- package/dist/client/static/js/index-pvv340b4.js +2 -0
- package/dist/client/static/js/{index-nbm5r9g1.js → index-pxr36neg.js} +2 -2
- package/dist/client/static/js/{index-5ztdqm1w.js → index-q0k1am0g.js} +2 -2
- package/dist/client/static/js/{index-tc6k8qt7.js → index-qrpx4sk1.js} +2 -2
- package/dist/client/static/js/{index-473hk8nb.js → index-r2zsw7nw.js} +9 -9
- package/dist/client/static/js/{index-gaqjrzdb.js → index-rbkvw2xs.js} +2 -2
- package/dist/client/static/js/{index-wbsvg1d9.js → index-scmtzcv1.js} +2 -2
- package/dist/client/static/js/{index-bmaktvm2.js → index-syvkpnc8.js} +1 -1
- package/dist/client/static/js/index-tfqqsj2g.js +1 -0
- package/dist/client/static/js/{index-4z5ram7g.js → index-tj7xr4ta.js} +1 -1
- package/dist/client/static/js/{index-h8hjcdj1.js → index-wvw70pgd.js} +2 -2
- package/dist/client/static/js/{index-5dn4159w.js → index-wxs0x3g1.js} +2 -2
- package/dist/client/static/js/index-x507ndnc.js +314 -0
- package/dist/client/static/js/{index-gr8sqjpz.js → index-x87scjpa.js} +1 -1
- package/dist/client/static/js/{index-s5vegk6q.js → index-xtrsvm0d.js} +2 -2
- package/dist/client/static/js/{index-e8mt8rag.js → index-y1j18rha.js} +2 -2
- package/dist/client/static/js/{index-7dqq7cjp.js → index-yv2ervdj.js} +5 -5
- package/dist/client/static/js/{index-gz7kvpnm.js → index-z2pmt1bc.js} +1 -1
- package/dist/client/static/js/{index-5p8dwr4y.js → index-z446edg9.js} +1 -1
- package/dist/client/static/js/{index-a4636gt1.js → index-zkgqa0c2.js} +2 -2
- package/dist/client/static/js/index-zwbw177x.js +2 -0
- package/dist/client/static/js/info-A6RAGUB7-rzpg7qk1.js +1 -0
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-xsar9j6v.js → infoDiagram-VRGFBTTK-5mb5w005.js} +2 -2
- package/dist/client/static/js/ini-kjcpgebh.js +1 -0
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-g2rvt9jp.js → ishikawaDiagram-OU5B5YK6-zk7fa0fm.js} +2 -2
- package/dist/client/static/js/java-0bcyv1jt.js +1 -0
- package/dist/client/static/js/javascript-0mqgcvps.js +1 -0
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-q95v18zc.js → journeyDiagram-ZHPQQLJL-8jd7b2aw.js} +6 -6
- package/dist/client/static/js/json-mb8k0b1n.js +1 -0
- package/dist/client/static/js/jsx-8p6dqgpq.js +1 -0
- package/dist/client/static/js/{julia-pe5vpc2m.js → julia-nwh5w343.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-2e7m7ds3.js → kanban-definition-PNTS6WVX-yp9rks4k.js} +7 -7
- package/dist/client/static/js/lua-nxnqww9z.js +1 -0
- package/dist/client/static/js/markdown-8gbyxxjd.js +1 -0
- package/dist/client/static/js/mermaid.core-kxsxr8ec.js +12 -0
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-banecvf8.js → mindmap-definition-NLK3R4M7-anx2kj3b.js} +7 -7
- package/dist/client/static/js/one-dark-pro-wyegjr0d.js +1 -0
- package/dist/client/static/js/one-light-kp6c3eqh.js +1 -0
- package/dist/client/static/js/packet-AYTQ26CC-eac14hsq.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-6erykm1c.js → pegDiagram-GJSIUBJH-9egqyzkc.js} +1 -1
- package/dist/client/static/js/{perl-cc2eqye8.js → perl-wb4wtc9x.js} +1 -1
- package/dist/client/static/js/{php-p9bvnpsv.js → php-9g594k9f.js} +1 -1
- package/dist/client/static/js/pie-WAS4IAKB-a9xqvysf.js +1 -0
- package/dist/client/static/js/{pieDiagram-5QR66LMP-jn1d905q.js → pieDiagram-5QR66LMP-f3dvprbm.js} +3 -3
- package/dist/client/static/js/properties-d5bwhgwz.js +1 -0
- package/dist/client/static/js/python-fdwwjjhh.js +1 -0
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-sz4afnp1.js → quadrantDiagram-O4NWA36T-qsghd295.js} +6 -6
- package/dist/client/static/js/r-4d2ygtfj.js +1 -0
- package/dist/client/static/js/radar-RG4KPBEZ-jv2pm0fe.js +1 -0
- package/dist/client/static/js/railroad-74A4TZTK-j74sc0b6.js +1 -0
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-eaf19baz.js +1 -0
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-d4j5nq31.js +1 -0
- package/dist/client/static/js/railroad-peg-WCYAUIDC-ba862a9p.js +1 -0
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-ewzhhth2.js → railroadDiagram-XR7U4H2S-6vmazht2.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-fcs3xd42.js → requirementDiagram-PLB6GJNP-phs0wn1v.js} +6 -6
- package/dist/client/static/js/{ruby-65s2ca5d.js → ruby-c4hxsegh.js} +1 -1
- package/dist/client/static/js/{rust-ec1j2hwy.js → rust-e4whdswc.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-2r829rjf.js → sankeyDiagram-IPEJSGJF-vkktegjk.js} +5 -5
- package/dist/client/static/js/{sass-p6cssgq8.js → sass-6yxywx7t.js} +1 -1
- package/dist/client/static/js/{scss-qfx8wt3b.js → scss-9wz47c6t.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-3mnte9tv.js → sequenceDiagram-PO4LG4MO-37e6se72.js} +13 -13
- package/dist/client/static/js/{sizeCapture-INFHLROL-r6hf9265.js → sizeCapture-INFHLROL-3b4nsa4s.js} +1 -1
- package/dist/client/static/js/sql-sd00wgem.js +1 -0
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-hm2f0wdb.js → stateDiagram-v2-GCMORJYK-2nnyqs9x.js} +6 -6
- package/dist/client/static/js/{svelte-jz3a190v.js → svelte-mm3jfpje.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-s58xzqhw.js → swimlanes-2SLR337P-eezd46ps.js} +1 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-h78096xp.js +8 -0
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-ezm1c4pz.js → timeline-definition-EJHVYXUP-pz0f2b4h.js} +12 -12
- package/dist/client/static/js/treeView-Q6P3EWNA-e8yb44pd.js +1 -0
- package/dist/client/static/js/treemap-WGGIJYW6-zvdv84vp.js +1 -0
- package/dist/client/static/js/tsx-dk8rpgtw.js +1 -0
- package/dist/client/static/js/typescript-5txwpd9t.js +1 -0
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-ryvgs5ac.js → usecaseDiagram-POWQR4AR-hvg7a87b.js} +82 -82
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-rd5prsf1.js → vennDiagram-UO4OBE2U-03zh9phs.js} +8 -8
- package/dist/client/static/js/{vue-rv4pea8r.js → vue-rcdqpz7q.js} +1 -1
- package/dist/client/static/js/wardley-WFR3VGLG-hbv0cg4s.js +1 -0
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-1kt8q8a4.js → wardleyDiagram-VNRHLVJA-xy77th92.js} +4 -4
- package/dist/client/static/js/xml-vtrdnrn6.js +1 -0
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-q39bbgq4.js → xychartDiagram-PMCCYNJV-h48448cm.js} +4 -4
- package/dist/client/static/js/yaml-6k1tmwtm.js +1 -0
- package/package.json +2 -1
- package/src/client/components/common/MarkdownRenderer.tsx +31 -34
- package/src/client/components/common/ViewportSelector.tsx +4 -0
- package/src/client/components/common/command-palette/index.tsx +5 -2
- package/src/client/components/common/header-button/index.tsx +10 -2
- package/src/client/components/common/markdown-inline-file.test.tsx +131 -0
- package/src/client/components/common/search-select/OptionList.tsx +164 -0
- package/src/client/components/common/search-select/index.tsx +159 -136
- package/src/client/components/common/search-select/option.ts +16 -0
- package/src/client/components/common/search-select/search-select.test.tsx +61 -2
- package/src/client/components/common/sort-menu/index.tsx +9 -4
- package/src/client/components/layout/session-sidebar/HarnessFilter.tsx +26 -6
- package/src/client/components/layout/session-sidebar/scheduler-modal/ModelFields.tsx +45 -49
- package/src/client/components/layout/session-sidebar/scheduler-modal/TaskForm.tsx +31 -25
- package/src/client/components/settings/ProjectSelectorDropdown.tsx +40 -101
- package/src/client/components/settings/apply-side-effects.test.ts +16 -0
- package/src/client/components/settings/apply-side-effects.ts +8 -0
- package/src/client/components/settings/categories/AppearanceSettings.test.tsx +1 -0
- package/src/client/components/settings/categories/AppearanceSettings.tsx +2 -0
- package/src/client/components/settings/categories/HarnessSettings.tsx +8 -0
- package/src/client/components/settings/categories/TokenUsageSettings.tsx +26 -3
- package/src/client/components/settings/categories/agent-settings/DetailPane.tsx +12 -10
- package/src/client/components/settings/categories/appearance-settings/RightSideSection.test.tsx +97 -0
- package/src/client/components/settings/categories/appearance-settings/RightSideSection.tsx +94 -0
- package/src/client/components/settings/categories/appearance-settings/groups.ts +4 -3
- package/src/client/components/settings/categories/command-settings/DetailPane.tsx +12 -10
- package/src/client/components/settings/categories/dictation-settings/CaptureSection.tsx +13 -18
- package/src/client/components/settings/categories/git-settings/CommitMessageSection.tsx +8 -9
- package/src/client/components/settings/categories/harness-settings/AccountLoginPanel.tsx +224 -0
- package/src/client/components/settings/categories/harness-settings/AccountsPanel.test.tsx +139 -0
- package/src/client/components/settings/categories/harness-settings/AccountsPanel.tsx +349 -0
- package/src/client/components/settings/categories/harness-settings/AddAccountForm.tsx +58 -0
- package/src/client/components/settings/categories/harness-settings/HarnessCard.tsx +33 -0
- package/src/client/components/settings/categories/keyboard-settings/ComposerKeys.tsx +10 -10
- package/src/client/components/settings/categories/mcp-settings/AdvancedSection.tsx +21 -18
- package/src/client/components/settings/categories/mcp-settings/DetailPane.tsx +12 -7
- package/src/client/components/settings/categories/omp-settings/PresetBar.tsx +11 -11
- package/src/client/components/settings/categories/omp-settings/RoleEditor.test.ts +14 -11
- package/src/client/components/settings/categories/omp-settings/RowEditor.tsx +17 -16
- package/src/client/components/settings/categories/plugin-settings/MarketplacePane.tsx +11 -9
- package/src/client/components/settings/categories/plugin-settings/SettingsSection.tsx +10 -9
- package/src/client/components/settings/categories/provider-settings/AddModelModal.tsx +10 -8
- package/src/client/components/settings/categories/provider-settings/DialectFields.tsx +40 -24
- package/src/client/components/settings/categories/provider-settings/EntryAdvanced.tsx +13 -9
- package/src/client/components/settings/categories/provider-settings/EntryModal.tsx +22 -17
- package/src/client/components/settings/categories/provider-settings/PresetPicker.tsx +79 -50
- package/src/client/components/settings/categories/provider-settings/model-dialogs.test.tsx +14 -7
- package/src/client/components/settings/categories/token-usage-settings/HarnessFilter.tsx +59 -0
- package/src/client/components/settings/categories/token-usage-settings/panel.test.tsx +37 -0
- package/src/client/components/settings/categories/usage-settings/limit-groups.test.ts +10 -0
- package/src/client/components/settings/categories/usage-settings/limit-groups.ts +4 -1
- package/src/client/components/settings/categories/usage-settings/providers.ts +28 -0
- package/src/client/components/settings/categories/usage-settings/usage-visibility.test.ts +60 -0
- package/src/client/components/settings/categories/voice-settings/SpeechSettings.test.tsx +147 -5
- package/src/client/components/settings/categories/voice-settings/SpeechSettings.tsx +27 -3
- package/src/client/components/settings/categories/voice-settings/speech/EndpointSection.tsx +11 -3
- package/src/client/components/settings/categories/voice-settings/speech/EngineSection.tsx +32 -2
- package/src/client/components/settings/categories/voice-settings/speech/ModelsSection.tsx +277 -0
- package/src/client/components/settings/categories/voice-settings/speech/TestSection.tsx +2 -1
- package/src/client/components/settings/categories/voice-settings/speech/VoiceSection.tsx +123 -50
- package/src/client/components/workspace/btw-panel/TopicMenu.tsx +20 -2
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.speech.test.tsx +35 -6
- package/src/client/components/workspace/chat-timeline/SpeechButton.tsx +111 -36
- package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.tsx +21 -6
- package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.tsx +7 -4
- package/src/client/components/workspace/chat-timeline/chat-input/ThinkingLevelDropdown.tsx +22 -6
- package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.tsx +17 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/index.tsx +8 -65
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Proc.test.ts +12 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/registry.test.ts +35 -218
- package/src/client/components/workspace/chat-timeline/tool-renderers/registry.ts +40 -177
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/DiffView.test.ts +13 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/FallbackToolJson.test.tsx +79 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/FallbackToolJson.tsx +86 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolBody.tsx +25 -16
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/card-header.test.ts +4 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/tool-view.ts +11 -4
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Card.plugin.test.ts +3 -1
- package/src/client/components/workspace/file-explorer/ArchiveModals.tsx +15 -15
- package/src/client/components/workspace/git-panel/BranchToolbar.tsx +30 -5
- package/src/client/components/workspace/usage-panel/index.test.tsx +92 -12
- package/src/client/components/workspace/usage-panel/index.tsx +48 -12
- package/src/client/data/mock/chat.ts +17 -0
- package/src/client/data/mock/token-usage.ts +53 -10
- package/src/client/data/samples/tools-session.ts +8 -5
- package/src/client/hooks/chat/timeline/reader-input.ts +53 -1
- package/src/client/hooks/chat/timeline/scroll-activity.test.ts +103 -0
- package/src/client/hooks/chat/timeline/scroll-geometry.ts +9 -4
- package/src/client/hooks/chat/timeline/scroll.ts +19 -2
- package/src/client/hooks/editor/font.test.ts +21 -0
- package/src/client/hooks/editor/font.ts +12 -9
- package/src/client/hooks/models/harness-accounts.ts +143 -0
- package/src/client/hooks/models/harness-catalog.ts +9 -2
- package/src/client/hooks/models/use-harnesses-controller.ts +12 -0
- package/src/client/hooks/models/use-harnesses.ts +14 -0
- package/src/client/hooks/settings/hide-empty-providers.test.ts +132 -0
- package/src/client/hooks/settings/hide-empty-providers.ts +49 -0
- package/src/client/hooks/settings/local-tts-models.ts +164 -0
- package/src/client/hooks/settings/useTokenUsage.ts +7 -2
- package/src/client/hooks/tts/tts-context.ts +6 -0
- package/src/client/hooks/tts/use-tts-player.ts +10 -0
- package/src/client/hooks/ui/markdown-render.ts +9 -1
- package/src/client/hooks/ui/markdown-scoped-links.ts +77 -0
- package/src/client/hooks/ui/open-inline-file.test.ts +144 -0
- package/src/client/hooks/ui/open-inline-file.ts +71 -0
- package/src/client/hooks/workspace/panel-tabs.ts +1 -1
- package/src/client/hooks/workspace/right-side.test.ts +75 -1
- package/src/client/hooks/workspace/right-side.ts +71 -10
- package/src/client/lib/commands/overlays.ts +16 -2
- package/src/client/lib/tts/player.test.ts +61 -0
- package/src/client/lib/tts/player.ts +120 -41
- package/src/client/tailwind.css +16 -0
- package/src/server/lib/antigravity/home.server.ts +27 -0
- package/src/server/lib/chat/normalize-tools.server.test.ts +79 -0
- package/src/server/lib/chat/normalize-tools.server.ts +87 -0
- package/src/server/lib/db/schema.ts +5 -1
- package/src/server/lib/harness/account-identity.server.ts +163 -0
- package/src/server/lib/harness/account-login.server.test.ts +151 -0
- package/src/server/lib/harness/account-login.server.ts +232 -0
- package/src/server/lib/harness/accounts.server.ts +339 -0
- package/src/server/lib/harness/accounts.test.ts +147 -0
- package/src/server/lib/harness/acp/background-probe.test.ts +314 -0
- package/src/server/lib/harness/acp/background-probe.ts +288 -0
- package/src/server/lib/harness/acp/background-replay.test.ts +37 -1
- package/src/server/lib/harness/acp/background-replay.ts +8 -3
- package/src/server/lib/harness/acp/background-work.test.ts +4 -194
- package/src/server/lib/harness/acp/background-work.ts +4 -207
- package/src/server/lib/harness/acp/client.ts +3 -0
- package/src/server/lib/harness/acp/commands.ts +2 -2
- package/src/server/lib/harness/acp/frames-tool-shapes.test.ts +41 -13
- package/src/server/lib/harness/acp/frames-vendor-names.test.ts +209 -0
- package/src/server/lib/harness/acp/frames.test.ts +11 -20
- package/src/server/lib/harness/acp/frames.ts +5 -3
- package/src/server/lib/harness/acp/mapper.ts +5 -41
- package/src/server/lib/harness/acp/one-shot.server.ts +4 -2
- package/src/server/lib/harness/acp/prewarm.server.ts +21 -16
- package/src/server/lib/harness/acp/replay-transcript.ts +6 -1
- package/src/server/lib/harness/acp/session-background.test.ts +2 -1
- package/src/server/lib/harness/acp/session-intake.test.ts +8 -0
- package/src/server/lib/harness/acp/session-intake.ts +12 -3
- package/src/server/lib/harness/acp/session-options.ts +2 -0
- package/src/server/lib/harness/acp/session-process.ts +1 -0
- package/src/server/lib/harness/acp/session-wiring.test.ts +2 -0
- package/src/server/lib/harness/acp/session-wiring.ts +22 -0
- package/src/server/lib/harness/acp/session.ts +3 -3
- package/src/server/lib/harness/acp/stdio.test.ts +52 -0
- package/src/server/lib/harness/acp/stdio.ts +7 -1
- package/src/server/lib/harness/acp/subagent-frames.test.ts +1 -1
- package/src/server/lib/harness/acp/subagent-frames.ts +0 -2
- package/src/server/lib/harness/acp/tool-calls.ts +5 -16
- package/src/server/lib/harness/acp/tool-identity.test.ts +69 -8
- package/src/server/lib/harness/acp/tool-identity.ts +58 -10
- package/src/server/lib/harness/acp/tool-shape.ts +5 -3
- package/src/server/lib/harness/auto-probe.server.ts +2 -2
- package/src/server/lib/harness/codex/transcript.server.test.ts +3 -1
- package/src/server/lib/harness/codex/transcript.server.ts +8 -15
- package/src/server/lib/harness/launch-table.ts +6 -1
- package/src/server/lib/harness/launch.ts +1 -0
- package/src/server/lib/harness/schema.server.ts +37 -0
- package/src/server/lib/harness/session-delete.server.ts +4 -2
- package/src/server/lib/harness/session-import.server.ts +21 -7
- package/src/server/lib/harness/session-store.server.test.ts +12 -0
- package/src/server/lib/harness/session-store.server.ts +21 -6
- package/src/server/lib/harness/session-transcript.server.ts +2 -1
- package/src/server/lib/harness/spawn.server.ts +27 -6
- package/src/server/lib/lifecycle/paths.ts +12 -0
- package/src/server/lib/models/provider-icon-fetch.test.ts +57 -3
- package/src/server/lib/models/provider-icon-fetch.ts +9 -1
- package/src/server/lib/models/provider-icon-store.server.ts +61 -0
- package/src/server/lib/models/provider-icon-store.test.ts +55 -0
- package/src/server/lib/models/provider-icon-svg.ts +57 -0
- package/src/server/lib/omp/session/messages.ts +5 -1
- package/src/server/lib/realtime/topics/peer-relay.server.ts +9 -1
- package/src/server/lib/realtime/topics/session.server.ts +5 -1
- package/src/server/lib/schedule/runtime.server.ts +4 -1
- package/src/server/lib/sessions/dispatch.server.ts +4 -1
- package/src/server/lib/sessions/fork.server.ts +2 -0
- package/src/server/lib/sessions/resolve.server.ts +4 -0
- package/src/server/lib/sessions/spawn.server.ts +4 -2
- package/src/server/lib/tts/engines/adapters.test.ts +50 -8
- package/src/server/lib/tts/engines/deepgram.ts +30 -9
- package/src/server/lib/tts/engines/elevenlabs.ts +6 -0
- package/src/server/lib/tts/engines/gemini.ts +116 -0
- package/src/server/lib/tts/engines/index.ts +14 -0
- package/src/server/lib/tts/engines/local.ts +53 -0
- package/src/server/lib/tts/engines/openai.ts +21 -4
- package/src/server/lib/tts/engines/sherpa-onnx-node.d.ts +38 -0
- package/src/server/lib/tts/engines/sherpa.test.ts +53 -0
- package/src/server/lib/tts/engines/sherpa.ts +287 -0
- package/src/server/lib/tts/local-models.server.ts +257 -0
- package/src/server/lib/tts/local-request.test.ts +66 -0
- package/src/server/lib/tts/local-request.ts +59 -0
- package/src/server/lib/tts/model-manifest.server.test.ts +71 -0
- package/src/server/lib/tts/model-manifest.server.ts +154 -0
- package/src/server/lib/tts/settings.server.ts +7 -4
- package/src/server/lib/tts/wav.test.ts +37 -0
- package/src/server/lib/tts/wav.ts +43 -0
- package/src/server/lib/usage/antigravity-quota.test.ts +249 -0
- package/src/server/lib/usage/antigravity-quota.ts +197 -0
- package/src/server/lib/usage/antigravity.test.ts +20 -0
- package/src/server/lib/usage/antigravity.ts +267 -0
- package/src/server/lib/usage/index-harness.test.ts +162 -0
- package/src/server/lib/usage/index-parse.test.ts +1 -0
- package/src/server/lib/usage/index-parse.ts +12 -4
- package/src/server/lib/usage/index-query.server.ts +64 -2
- package/src/server/lib/usage/index-scan.server.ts +68 -152
- package/src/server/lib/usage/index-schema.server.ts +24 -8
- package/src/server/lib/usage/index-schema.test.ts +54 -0
- package/src/server/lib/usage/index-sources.server.ts +54 -0
- package/src/server/lib/usage/providers.server.test.ts +67 -1
- package/src/server/lib/usage/providers.server.ts +82 -3
- package/src/server/lib/usage/sources/claude.server.ts +187 -0
- package/src/server/lib/usage/sources/claude.test.ts +86 -0
- package/src/server/lib/usage/sources/codex.server.ts +155 -0
- package/src/server/lib/usage/sources/codex.test.ts +53 -0
- package/src/server/lib/usage/sources/dsh.server.ts +120 -0
- package/src/server/lib/usage/sources/dsh.test.ts +49 -0
- package/src/server/lib/usage/sources/helpers.ts +191 -0
- package/src/server/lib/usage/sources/jsonl.server.ts +78 -0
- package/src/server/lib/usage/sources/jsonl.test.ts +72 -0
- package/src/server/lib/usage/sources/omp.server.ts +124 -0
- package/src/server/lib/usage/sources/opencode.server.ts +203 -0
- package/src/server/lib/usage/sources/opencode.test.ts +104 -0
- package/src/server/lib/usage/sources/qwen.server.ts +122 -0
- package/src/server/lib/usage/sources/qwen.test.ts +62 -0
- package/src/server/lib/usage/sources/types.ts +53 -0
- package/src/server/lib/usage/sources/zcode.server.ts +131 -0
- package/src/server/lib/usage/sources/zcode.test.ts +87 -0
- package/src/server/routes/agent/harness-command.ts +2 -0
- package/src/server/routes/agent/prewarm.ts +7 -2
- package/src/server/routes/chat/session-legacy-tools.test.ts +132 -0
- package/src/server/routes/chat/session.ts +10 -4
- package/src/server/routes/harness/accounts.test.ts +99 -0
- package/src/server/routes/harness/accounts.ts +106 -0
- package/src/server/routes/harness/root.ts +13 -1
- package/src/server/routes/sessions/local-image.ts +2 -2
- package/src/server/routes/telemetry/tokens.test.ts +20 -0
- package/src/server/routes/telemetry/tokens.ts +12 -3
- package/src/server/routes/tts/index.ts +2 -0
- package/src/server/routes/tts/models.test.ts +148 -0
- package/src/server/routes/tts/models.ts +89 -0
- package/src/server/routes/tts/speak.test.ts +40 -0
- package/src/shared/lib/chat/tool/normalize.ts +67 -0
- package/src/shared/lib/chat/tool/render-key.test.ts +167 -0
- package/src/shared/lib/chat/tool/render-key.ts +247 -0
- package/src/shared/lib/chat/tool/tool-aliases.test.ts +42 -0
- package/src/shared/lib/chat/tool/tool-aliases.ts +59 -12
- package/src/shared/lib/fs/open-reference.test.ts +64 -0
- package/src/shared/lib/fs/open-reference.ts +74 -0
- package/src/shared/lib/harness/accounts.test.ts +41 -0
- package/src/shared/lib/harness/accounts.ts +175 -0
- package/src/shared/lib/icons/tint-hues.generated.ts +26 -25
- package/src/shared/lib/markdown/ascii-art.test.ts +154 -0
- package/src/shared/lib/markdown/ascii-art.ts +158 -0
- package/src/shared/lib/markdown/inline-file.test.ts +100 -0
- package/src/shared/lib/markdown/inline-file.ts +213 -0
- package/src/shared/lib/markdown/marked.ts +24 -2
- package/src/shared/lib/models/provider/identity.test.ts +34 -0
- package/src/shared/lib/models/provider/identity.ts +28 -0
- package/src/shared/lib/omp/session/messages-map.test.ts +2 -1
- package/src/shared/lib/omp/session/messages-parse.ts +3 -2
- package/src/shared/lib/omp/session/parse-message-blocks.ts +14 -0
- package/src/shared/lib/omp/subagent/transcript-client.ts +5 -1
- package/src/shared/lib/settings/defaults.ts +2 -0
- package/src/shared/lib/tts/engines.test.ts +39 -2
- package/src/shared/lib/tts/engines.ts +87 -61
- package/src/shared/lib/tts/local-models.test.ts +69 -0
- package/src/shared/lib/tts/local-models.ts +200 -0
- package/src/shared/lib/tts/settings.ts +1 -1
- package/src/shared/lib/tts/speakable.test.ts +21 -1
- package/src/shared/lib/tts/speakable.ts +66 -33
- package/src/shared/lib/tts/voices.ts +204 -0
- package/src/shared/lib/workspace/right-side-hidden.ts +57 -0
- package/src/shared/lib/workspace/session-state/store.ts +7 -5
- package/src/shared/types/chat.ts +3 -0
- package/src/shared/types/harness.ts +5 -0
- package/src/shared/types/index.ts +1 -0
- package/src/shared/types/settings/state.ts +12 -0
- package/src/shared/types/tokenUsage.ts +21 -0
- package/src/shared/types/tool-render.ts +37 -0
- package/src/test-support/preload.ts +9 -0
- package/dist/client/static/js/ImageView-g50pk5pt.js +0 -1
- package/dist/client/static/js/LayoutWrapper-tag0qpts.js +0 -2
- package/dist/client/static/js/MergeDiffView-c4mb8m1w.js +0 -1
- package/dist/client/static/js/Modal-pf9p6m1k.js +0 -59
- package/dist/client/static/js/SessionsView-2r1grxxs.js +0 -1
- package/dist/client/static/js/architecture-7GRP2DOG-ee9wjsht.js +0 -1
- package/dist/client/static/js/architectureDiagram-NJMV4G6O-278nx8rt.js +0 -36
- package/dist/client/static/js/bash-36shcpcw.js +0 -1
- package/dist/client/static/js/c-kxeqssf9.js +0 -1
- package/dist/client/static/js/cose-bilkent-JH36ORCC-ydq7mvy0.js +0 -1
- package/dist/client/static/js/cpp-wtk1s3d7.js +0 -1
- package/dist/client/static/js/css-0a0r6rp3.js +0 -1
- package/dist/client/static/js/css-xhnrhg4e.js +0 -1
- package/dist/client/static/js/cynefin-OW5HDTMX-gs16zjqa.js +0 -1
- package/dist/client/static/js/diagram-3UASUU5V-06nptkzc.js +0 -24
- package/dist/client/static/js/eventmodeling-NTZA5JFV-ftz7zrz5.js +0 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-ax0qfmp3.js +0 -1
- package/dist/client/static/js/gitGraph-4MIJSDKK-3rtkds4s.js +0 -1
- package/dist/client/static/js/gitGraphDiagram-X574FWY7-5p9mgq7n.js +0 -106
- package/dist/client/static/js/graphql-w9ajhndp.js +0 -1
- package/dist/client/static/js/html-krfbq5wp.js +0 -1
- package/dist/client/static/js/index-05n22cg9.js +0 -4
- package/dist/client/static/js/index-14dgbjsm.js +0 -2
- package/dist/client/static/js/index-2jgx68m0.js +0 -1
- package/dist/client/static/js/index-333rq9yy.js +0 -1
- package/dist/client/static/js/index-38g2eevc.js +0 -314
- package/dist/client/static/js/index-80fjn77c.js +0 -2
- package/dist/client/static/js/index-9wc36am3.css +0 -1
- package/dist/client/static/js/index-bvpzzhn2.js +0 -4
- package/dist/client/static/js/index-e19dbqd3.js +0 -2
- package/dist/client/static/js/index-epzvftkq.js +0 -1
- package/dist/client/static/js/index-fbg5vhhw.js +0 -2
- package/dist/client/static/js/index-mbtenbyc.js +0 -9
- package/dist/client/static/js/index-pv4z2mp2.js +0 -463
- package/dist/client/static/js/index-t522tpxt.js +0 -3
- package/dist/client/static/js/index-xw1bptp5.js +0 -2
- package/dist/client/static/js/index-yr3exz70.js +0 -2
- package/dist/client/static/js/index-zdw8bd5t.js +0 -2
- package/dist/client/static/js/index-zyefab6q.js +0 -1
- package/dist/client/static/js/info-A6RAGUB7-vr5mxm6f.js +0 -1
- package/dist/client/static/js/ini-zx7x1jj1.js +0 -1
- package/dist/client/static/js/java-bbw6kdcr.js +0 -1
- package/dist/client/static/js/javascript-p2a8rbpw.js +0 -1
- package/dist/client/static/js/json-zh7m2fyg.js +0 -1
- package/dist/client/static/js/jsx-3zyyt0eh.js +0 -1
- package/dist/client/static/js/lua-d656k76a.js +0 -1
- package/dist/client/static/js/markdown-b5w681mm.js +0 -1
- package/dist/client/static/js/mermaid.core-dzajkp0g.js +0 -12
- package/dist/client/static/js/one-dark-pro-z965dedc.js +0 -1
- package/dist/client/static/js/one-light-capdx801.js +0 -1
- package/dist/client/static/js/packet-AYTQ26CC-ncb5xxtn.js +0 -1
- package/dist/client/static/js/pie-WAS4IAKB-ff8fpvc4.js +0 -1
- package/dist/client/static/js/properties-3c6rmnqp.js +0 -1
- package/dist/client/static/js/python-a3x3zpv1.js +0 -1
- package/dist/client/static/js/r-7h3gwype.js +0 -1
- package/dist/client/static/js/radar-RG4KPBEZ-gbj4b1hf.js +0 -1
- package/dist/client/static/js/railroad-74A4TZTK-ndv5tqgr.js +0 -1
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-yjzj09s1.js +0 -1
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-e6pw7e5z.js +0 -1
- package/dist/client/static/js/railroad-peg-WCYAUIDC-9734dxy4.js +0 -1
- package/dist/client/static/js/sql-7a5vavm0.js +0 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-z4pt2kn1.js +0 -8
- package/dist/client/static/js/treeView-Q6P3EWNA-rs10d4p5.js +0 -1
- package/dist/client/static/js/treemap-WGGIJYW6-ey6c5x9f.js +0 -1
- package/dist/client/static/js/tsx-4a9b8tqf.js +0 -1
- package/dist/client/static/js/typescript-kas107wb.js +0 -1
- package/dist/client/static/js/wardley-WFR3VGLG-kd9swrdr.js +0 -1
- package/dist/client/static/js/xml-3g4bdtpa.js +0 -1
- package/dist/client/static/js/yaml-ktxjn917.js +0 -1
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{d,n,o,K,i,u,a,le,e,s,E,ne,Qe,Ee,p,N,I,lt,rt,f,B,se,ct,qn,Zt,gn,ce,qe,To,Kn,bi,Qr,gr,P,S,U,Xt,b,x,Hg,_e,sa,xm,ut,He,ds,kl,pe,Z,pt,he,Bt,Rt,Lt,la,et,at,pn,oo,ua,Sl,I0,tt,Ss,bf,Ld,Jc,Fa,yf,zo,Uo,Go,_t,vf,Ts,Ds,Zc,_0,S0,kf,Ns,jo,qo,xf,Ho,wf,T0,Cf,D0,Ef,Bf,If,N0,_f,Nl,Sf,Fd,Q0,Xc,Pd,Tf}from"./index-pv4z2mp2.js";var Un={name:"arrow-up-down",size:24,node:[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]},zs=s(Un);var Gn={name:"calendar",size:24,node:[["path",{d:"M8 2v3",key:"1ioesn"}],["path",{d:"M16 2v3",key:"otl347"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M3 9h18",key:"1pudct"}]]},$a=s(Gn);var Xn={name:"check-check",size:24,node:[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]},ft=s(Xn);var jn={name:"list-checks",size:24,node:[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}]]},$r=s(jn);async function Zn(t){let r=await t.json().catch(()=>null);if(!t.ok||!r||r.error)return null;return{tasks:r.tasks??[],serverTimeZone:r.serverTimeZone??""}}function ht(t){let[r,l]=n([]),[c,m]=n(""),[h,g]=n(!1),[y,k]=n(null),w=a(async()=>{g(!0);try{let F=await Zn(await fetch("/api/schedule"));if(F){if(l(F.tasks),F.serverTimeZone)m(F.serverTimeZone);k(null)}else k("Could not load scheduled tasks.")}catch(F){k(F instanceof Error?F.message:String(F))}finally{g(!1)}},[]),C=_e(Hg,{enabled:t});o(()=>{if(!C.data)return;if(l(C.data.tasks),C.data.serverTimeZone)m(C.data.serverTimeZone);g(!1),k(null)},[C.data]);let T=a(async(F,_)=>{try{let D=await fetch(F,_),M=await D.json().catch(()=>null);if(!D.ok||!M||M.error){let q=M?.error??`HTTP ${D.status}`;return k(q),q}if(M.tasks)l(M.tasks);return k(null),null}catch(D){let M=D instanceof Error?D.message:String(D);return k(M),M}},[]),R=a(async(F)=>await T("/api/schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)}),[T]),O=a(async(F,_)=>T(`/api/schedule?id=${encodeURIComponent(F)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)}),[T]),v=a(async(F)=>T(`/api/schedule?id=${encodeURIComponent(F)}`,{method:"DELETE"}),[T]),A=a(async(F)=>await T(`/api/schedule?id=${encodeURIComponent(F)}&run=now`,{method:"POST"}),[T]),L=a(async(F)=>{try{let _=await fetch(`/api/schedule/${encodeURIComponent(F)}/runs`),D=await _.json().catch(()=>null);return _.ok?D?.runs??[]:[]}catch{return[]}},[]);return{tasks:r,serverTimeZone:c,loading:h,error:y,refresh:w,create:R,patch:O,remove:v,runNow:A,loadRuns:L}}function Lu(){let t=_e(Hg);return u(()=>(t.data?.tasks??[]).filter((r)=>r.enabled).length,[t.data])}var gt=new Map;function xt(t){let r=gt.get(t);if(!r)r=new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),gt.set(t,r);return r}function St(t){if(!t)return!1;try{return xt(t),!0}catch{return!1}}function kt(){return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}function Ae(t,r){let l=xt(r).formatToParts(new Date(t)),c=(m)=>{let h=l.find((g)=>g.type===m);return h?Number(h.value):0};return{year:c("year"),month:c("month"),day:c("day"),hour:c("hour"),minute:c("minute"),second:c("second")}}function bt(t,r){let l=Ae(t,r);return Date.UTC(l.year,l.month-1,l.day,l.hour,l.minute,l.second)-Math.floor(t/1000)*1000}function Ye(t,r,l,c,m,h){let g=Date.UTC(t,r-1,l,c,m),y=bt(g,h),k=g-y,w=bt(k,h);if(w!==y)k=g-w;let C=Ae(k,h);if(C.year!==t||C.month!==r||C.day!==l||C.hour!==c||C.minute!==m)return null;return k}var Yn=60000,Vn={s:1000,sec:1000,secs:1000,second:1000,seconds:1000,m:60000,min:60000,mins:60000,minute:60000,minutes:60000,h:3600000,hr:3600000,hrs:3600000,hour:3600000,hours:3600000,d:86400000,day:86400000,days:86400000,w:604800000,week:604800000,weeks:604800000};function vt(t){let r=t.trim().toLowerCase();if(!r)return null;if(/^\d+(\.\d+)?$/.test(r)){let h=Number(r);return h>0?Math.round(h*60000):null}let l=r.match(/(\d+(?:\.\d+)?)\s*([a-z]+)/g);if(!l)return null;if(l.join("").replace(/\s+/g,"").length!==r.replace(/\s+/g,"").length)return null;let m=0;for(let h of l){let g=h.match(/^(\d+(?:\.\d+)?)\s*([a-z]+)$/);if(!g)return null;let y=Vn[g[2]];if(!y)return null;m+=Number(g[1])*y}return m>0?Math.round(m):null}var Jn=[[0,59],[0,23],[1,31],[1,12],[0,7]];function Qn(t,r,l){let c=new Set;for(let m of t.split(",")){let[h,g]=m.split("/"),y=g===void 0?1:Number(g);if(!Number.isInteger(y)||y<1)return null;let k,w;if(h==="*")k=r,w=l;else if(h.includes("-")){let[C,T]=h.split("-");k=Number(C),w=Number(T)}else k=Number(h),w=g===void 0?k:l;if(!Number.isInteger(k)||!Number.isInteger(w))return null;if(k<r||w>l||k>w)return null;for(let C=k;C<=w;C+=y)c.add(C)}return c.size?[...c].sort((m,h)=>m-h):null}function eo(t){let r=t.trim().split(/\s+/);if(r.length!==5)return null;let l=r.map((k,w)=>{let[C,T]=Jn[w];return Qn(k,C,T)});if(l.some((k)=>k===null))return null;let[c,m,h,g,y]=l;return{minutes:c,hours:m,daysOfMonth:h,months:g,daysOfWeek:[...new Set(y.map((k)=>k===7?0:k))].sort((k,w)=>k-w),domRestricted:r[2].trim()!=="*",dowRestricted:r[4].trim()!=="*"}}function to(t,r,l,c){let m=new Date(Date.UTC(r,l-1,c)).getUTCDay(),h=t.daysOfMonth.includes(c),g=t.daysOfWeek.includes(m);if(t.domRestricted&&t.dowRestricted)return h||g;if(t.domRestricted)return h;if(t.dowRestricted)return g;return!0}function no(t,r,l){let c=l&&St(l)?l:kt(),m=Ae(r.getTime(),c),h=Date.UTC(m.year+8,m.month-1,m.day);for(let g=Date.UTC(m.year,m.month-1,m.day);g<=h;){let y=new Date(g),k=y.getUTCFullYear(),w=y.getUTCMonth()+1,C=y.getUTCDate();if(!t.months.includes(w)){g=Date.UTC(k,w,1);continue}if(to(t,k,w,C))for(let T of t.hours)for(let R of t.minutes){let O=Ye(k,w,C,T,R,c);if(O!==null&&O>r.getTime())return O}g=Date.UTC(k,w-1,C+1)}return null}var so=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?$/;function yt(t,r){let l=t.trim();if(!l)return null;if(/^\d+$/.test(l)){let m=Number(l);return m>0?m:null}if(r){let m=l.match(so);if(m){let[,h,g,y,k,w,C,T]=m,R=Ye(Number(h),Number(g),Number(y),Number(k),Number(w),r);if(R===null)return null;let O=(C?Number(C)*1000:0)+(T?Number(T.padEnd(3,"0")):0);return R+O}}let c=Date.parse(l);return Number.isNaN(c)?null:c}function wt(t,r,l=Date.now(),c){if(!r.trim())return{ok:!1,error:"Enter a schedule."};if(t==="once"){let g=yt(r,c);if(g===null)return{ok:!1,error:"Use an ISO timestamp, e.g. 2026-10-01T09:00."};if(g<=l)return{ok:!1,error:"That time is already in the past."};return{ok:!0,nextRunAt:g}}if(t==="every"){let g=vt(r);if(g===null)return{ok:!1,error:"Use a duration, e.g. 30m, 1h30m, 2 days."};if(g<Yn)return{ok:!1,error:"The shortest interval is 1 minute."};return{ok:!0,nextRunAt:l+g}}let m=eo(r);if(!m)return{ok:!1,error:"Use 5 fields: minute hour day-of-month month day-of-week."};let h=no(m,new Date(l),c);if(h===null)return{ok:!1,error:"That expression never matches a date."};return{ok:!0,nextRunAt:h}}function Nt(t,r,l){let c=r.trim();if(t==="once"){let m=yt(c,l);return m===null?c:`Once at ${new Date(m).toLocaleString(void 0,l?{timeZone:l}:void 0)}`}if(t==="every"){let m=vt(c);return m===null?c:`Every ${Ve(m)}`}return`Cron ${c}`}function Ve(t){let r=Math.round(t/1000),l=Math.floor(r/86400),c=Math.floor(r%86400/3600),m=Math.floor(r%3600/60),h=r%60,g=[];if(l)g.push(`${l}d`);if(c)g.push(`${c}h`);if(m)g.push(`${m}m`);if(h&&!l)g.push(`${h}s`);return g.length?g.join(" "):"0s"}var ro={"always-ask":"Ask before writes",write:"Auto-write, ask before exec",yolo:"Auto-run everything"};function Je(t){return`${t.provider}/${t.id}`}function io(t){if(!Array.isArray(t))return[];let r=[];for(let l of t){if(!l||typeof l!=="object")continue;if(!("id"in l)||typeof l.id!=="string")continue;if(!("name"in l)||typeof l.name!=="string")continue;if(!("provider"in l)||typeof l.provider!=="string")continue;let c="thinkingLevels"in l&&Array.isArray(l.thinkingLevels)?l.thinkingLevels.filter((m)=>typeof m==="string"):void 0;r.push({id:l.id,name:l.name,provider:l.provider,...c?{thinkingLevels:c}:{}})}return r}function Tt({harness:t,model:r,onHarnessChange:l,onModelChange:c}){let{harnesses:m}=pn(),h=oo((v)=>{let A=Array.isArray(v.modelList)&&v.modelList.length>0?v.modelList:v.models;return io(A)}),g=Ss(m,t,h??[]),y=g.models,k=r?y.find((v)=>v.provider===r.provider&&v.id===r.modelId):void 0,w=Jc(k?.thinkingLevels),C=bf(m,t),T=(v)=>{if(!v){c(null);return}let A=y.find((L)=>Je(L)===v);if(!A)return;c({provider:A.provider,modelId:A.id,thinkingLevel:"auto",accessMode:r?.accessMode??"always-ask"})},R=(v)=>{if(!r)return;c({...r,thinkingLevel:v})},O=(v)=>{if(!r)return;c({...r,accessMode:v})};return e("div",{className:"space-y-2",children:[e("div",{className:"grid grid-cols-2 gap-2",children:[e("div",{children:[e("label",{className:"block font-semibold mb-1 text-ink",children:"Harness"}),e("select",{value:t,onChange:(v)=>l(v.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 outline-none focus:border-ink/50 text-xs",children:[!C.some((v)=>v.id===t)&&e("option",{value:t,children:t}),C.map((v)=>e("option",{value:v.id,children:v.label},v.id))]})]}),e("div",{children:[e("label",{className:"block font-semibold mb-1 text-ink",children:"Model"}),e("select",{value:r?`${r.provider}/${r.modelId}`:"",onChange:(v)=>T(v.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 outline-none focus:border-ink/50 text-xs",children:[e("option",{value:"",children:t==="omp-rpc"?"Default (composer selection)":"Harness default"}),r&&!y.some((v)=>v.provider===r.provider&&v.id===r.modelId)&&e("option",{value:`${r.provider}/${r.modelId}`,children:[r.provider,"/",r.modelId]}),y.map((v)=>e("option",{value:Je(v),children:[v.name," · ",v.provider]},Je(v)))]})]})]}),e("div",{className:"grid grid-cols-2 gap-2",children:[e("div",{children:[e("label",{className:"block font-semibold mb-1 text-ink",children:"Thinking"}),e("select",{value:r?.thinkingLevel??"auto",disabled:!r||w.length===0,onChange:(v)=>R(v.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 outline-none focus:border-ink/50 text-xs disabled:opacity-40",children:[e("option",{value:"auto",children:"Auto"}),r&&r.thinkingLevel!=="auto"&&!w.includes(r.thinkingLevel)&&e("option",{value:r.thinkingLevel,children:r.thinkingLevel}),w.map((v)=>e("option",{value:v,children:v},v))]})]}),e("div",{children:[e("label",{className:"block font-semibold mb-1 text-ink",children:"Access"}),e("select",{value:r?.accessMode??"always-ask",disabled:!r,onChange:(v)=>O(v.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 outline-none focus:border-ink/50 text-xs disabled:opacity-40",children:Ld.map((v)=>e("option",{value:v,children:ro[v]},v))})]})]}),g.blocked&&e("p",{className:"text-[11px] text-error",children:g.blocked}),g.unprobed&&e("p",{className:"text-[11px] text-ink/40",children:"This harness has not been probed yet; its models appear after a status check."})]})}var Ct={once:"Once",every:"Every",cron:"Cron"},ao={once:"An ISO timestamp, e.g. 2026-10-01T09:00",every:"A duration, e.g. 30m, 1h30m, 2 days",cron:"5 fields: minute hour day-of-month month day-of-week"},lo={once:"2026-10-01T09:00",every:"1h30m",cron:"0 9 * * 1-5"};function co(t){let r=t-Date.now();if(r<=0)return"due now";let l=Math.round(r/60000);if(l<60)return`in ${l}m`;let c=Math.round(l/60);if(c<24)return`in ${c}h`;return`in ${Math.round(c/24)}d`}var Pe=null;function uo(){if(Pe)return Pe;let t=Intl,r=[];try{r=t.supportedValuesOf?.("timeZone")??[]}catch{r=[]}return Pe=r.length?r:["UTC"],Pe}function po(t){let r=uo();return t&&!r.includes(t)?[t,...r]:r}function It({folders:t,initial:r,activeSessionId:l,serverTimeZone:c,busy:m,onSubmit:h,onCancel:g}){let[y,k]=n(""),[w,C]=n(""),[T,R]=n("every"),[O,v]=n("1h"),[A,L]=n("omp-rpc"),[F,_]=n(null),D=c||Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC",[M,q]=n(D),[ee,X]=n(null),[re,ae]=n(!1);o(()=>{k(r?.name??""),C(r?.prompt??""),R(r?.kind??"every"),v(r?.spec??"1h"),L(r?.harness??"omp-rpc"),_(r?.model??null),q(r?.timezone??D),X(r?.folderId??null),ae(Boolean(r?.sessionId))},[r?.id,D]);let Y=wt(T,O,Date.now(),M),V=Boolean(w.trim())&&Y.ok&&!m,me=()=>{if(!V||!Y.ok)return;h({name:y.trim(),prompt:w.trim(),kind:T,spec:O.trim(),harness:A,timezone:M,folderId:ee,sessionId:re?r?.sessionId??l:null,model:F})};return e("div",{className:"space-y-3 text-xs",children:[e("div",{children:[e("label",{className:"block font-semibold mb-1 text-ink",children:["Name ",e("span",{className:"text-ink/40 font-normal",children:"(optional)"})]}),e("input",{type:"text",value:y,onInput:(W)=>k(W.currentTarget.value),placeholder:"Morning standup digest",className:"w-full bg-paper border border-ink/20 rounded px-2.5 py-1.5 outline-none focus:border-ink/50 text-xs"})]}),e("div",{children:[e("label",{className:"block font-semibold mb-1 text-ink",children:"Prompt"}),e("textarea",{value:w,onInput:(W)=>C(W.currentTarget.value),placeholder:"Describe the task, ask a question, or paste commands…",rows:4,className:"w-full bg-paper border border-ink/20 rounded px-2.5 py-1.5 outline-none focus:border-ink/50 text-xs resize-y min-h-[80px]"})]}),e("div",{className:"flex items-end gap-2",children:[e("div",{className:"w-28 flex-shrink-0",children:[e("label",{className:"block font-semibold mb-1 text-ink",children:"Schedule"}),e("select",{value:T,onChange:(W)=>R(W.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 outline-none focus:border-ink/50 text-xs",children:Object.keys(Ct).map((W)=>e("option",{value:W,children:Ct[W]},W))})]}),e("div",{className:"flex-1",children:[e("label",{className:"block font-semibold mb-1 text-ink",children:"When"}),e("input",{type:"text",value:O,onInput:(W)=>v(W.currentTarget.value),placeholder:lo[T],className:`w-full bg-paper border rounded px-2.5 py-1.5 outline-none text-xs font-mono ${Y.ok?"border-ink/20 focus:border-ink/50":"border-error/50 focus:border-error"}`})]})]}),e("p",{className:`text-[11px] ${Y.ok?"text-ink/50":"text-error"}`,children:Y.ok?`Next run ${co(Y.nextRunAt)} · ${new Date(Y.nextRunAt).toLocaleString(void 0,{timeZone:M})} · ${M}`:Y.error}),e("p",{className:"text-[11px] text-ink/40",children:ao[T]}),e("div",{className:"grid grid-cols-2 gap-2",children:[e("div",{children:[e("label",{className:"block font-semibold mb-1 text-ink",children:"Timezone"}),e("select",{value:M,onChange:(W)=>q(W.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 outline-none focus:border-ink/50 text-xs",children:po(M).map((W)=>e("option",{value:W,children:W},W))})]}),e("div",{children:[e("label",{className:"block font-semibold mb-1 text-ink",children:"Run in"}),e("select",{value:ee===null?"":String(ee),onChange:(W)=>X(W.currentTarget.value?Number(W.currentTarget.value):null),className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 outline-none focus:border-ink/50 text-xs",children:[e("option",{value:"",children:"Server default directory"}),t.map((W)=>e("option",{value:W.id,children:W.name},W.id))]})]})]}),e(Tt,{harness:A,model:F,onHarnessChange:(W)=>{L(W),_(null)},onModelChange:_}),e("label",{className:`flex items-center gap-2 text-[11px] ${l?"text-ink/70":"text-ink/35"}`,children:[e("input",{type:"checkbox",checked:re,disabled:!l,onChange:(W)=>ae(W.currentTarget.checked),className:`${he} accent-ink`}),e("span",{children:"Resume the open session each run"})]}),e("div",{className:"flex justify-end gap-2 pt-1",children:[e("button",{type:"button",onClick:g,disabled:m,className:"px-3 py-1.5 text-xs font-medium text-ink/60 hover:text-ink transition-colors",children:"Cancel"}),e("button",{type:"button",onClick:me,disabled:!V,className:"inline-flex items-center gap-1.5 px-4 py-1.5 text-xs font-medium bg-ink text-canvas rounded hover:bg-ink/90 transition-colors disabled:opacity-40",children:[m&&e(p,{size:12,className:"animate-spin"}),r?"Save changes":"Schedule task"]})]})]})}function mo(t){return t===null?"–":new Date(t).toLocaleString()}function fo(t){if(t.name)return t.name;let r=t.prompt.replace(/\s+/g," ").trim();return r.length>60?`${r.slice(0,57)}…`:r||"(empty prompt)"}function Ot({tasks:t,loading:r,pending:l,onRunNow:c,onToggleEnabled:m,onEdit:h,onDelete:g,loadRuns:y}){let[k,w]=n(null),[C,T]=n([]),[R,O]=n(!1);if(o(()=>{if(!k)return;let v=!0;return O(!0),y(k).then((A)=>{if(!v)return;T(A),O(!1)}),()=>{v=!1}},[k,y]),t.length===0)return e("div",{className:"px-3 py-8 text-center text-[11px] text-ink/50 border border-dashed border-ink/15 rounded-lg",children:r?"Loading…":"No scheduled tasks yet. Create one above."});return e("ul",{className:"space-y-2",children:t.map((v)=>{let A=l===v.id,L=k===v.id;return e("li",{className:"border border-ink/10 rounded-lg bg-paper",children:[e("div",{className:"flex items-start gap-2 p-2.5",children:[e("span",{className:"mt-0.5 shrink-0","aria-hidden":"true",children:!v.enabled?e(To,{size:14,className:"text-ink/40"}):v.lastStatus==="error"?e(E,{size:14,className:"text-error"}):v.lastStatus==="success"?e(ne,{size:14,className:"text-ink/60"}):e(qn,{size:14,className:"text-ink/60"})}),e("div",{className:"min-w-0 flex-1",children:[e("p",{className:"text-xs font-medium text-ink truncate",children:fo(v)}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:[Nt(v.kind,v.spec,v.timezone),v.kind!=="every"&&e(d,{children:[e("span",{className:"text-ink/30",children:" · "}),v.timezone]}),e("span",{className:"text-ink/30",children:" · "}),!v.enabled?v.kind==="once"&&v.lastRunAt!==null?"Ran once, with no next run":"Paused":`Next ${mo(v.nextRunAt)}`]}),v.cwd&&e("p",{className:"text-[10.5px] text-ink/40 font-mono truncate mt-0.5",children:v.cwd}),e("p",{className:"text-[10.5px] text-ink/40 truncate mt-0.5",children:[v.harness,v.model&&` · ${v.model.provider}/${v.model.modelId}`]}),v.sessionId&&e("p",{className:"text-[10.5px] text-ink/40 font-mono truncate mt-0.5",children:["resumes ",v.sessionId.slice(0,8)]}),v.lastStatus==="error"&&v.lastError&&e("p",{className:"text-[10.5px] text-error mt-0.5 break-words",children:v.lastError}),v.runCount>0&&e("p",{className:"text-[10.5px] text-ink/40 mt-0.5",children:["Fired ",v.runCount,"×"]})]}),e("div",{className:"flex items-center gap-1 shrink-0",children:[e("button",{type:"button",title:"Run now","aria-label":"Run now",disabled:A,onClick:()=>c(v.id),className:"p-1.5 rounded hover:bg-ink/5 text-ink/60 hover:text-ink transition-colors disabled:opacity-40",children:A?e(p,{size:13,className:"animate-spin"}):e(gr,{size:13})}),e("button",{type:"button",title:v.enabled?"Pause":"Resume","aria-label":v.enabled?"Pause":"Resume","aria-pressed":v.enabled,disabled:A,onClick:()=>m(v),className:"p-1.5 rounded hover:bg-ink/5 text-ink/60 hover:text-ink transition-colors disabled:opacity-40",children:v.enabled?e(To,{size:13}):e(gr,{size:13})}),e("button",{type:"button",title:"Edit","aria-label":"Edit",disabled:A,onClick:()=>h(v),className:"p-1.5 rounded hover:bg-ink/5 text-ink/60 hover:text-ink transition-colors disabled:opacity-40",children:e(Kn,{size:13})}),e("button",{type:"button",title:"Delete","aria-label":"Delete",disabled:A,onClick:()=>g(v.id),className:"p-1.5 rounded hover:bg-ink/5 text-ink/60 hover:text-error transition-colors disabled:opacity-40",children:e(N,{size:13})})]})]}),e("button",{type:"button",onClick:()=>w(L?null:v.id),"aria-expanded":L,className:"w-full text-left px-2.5 py-1.5 border-t border-ink/5 text-[10.5px] text-ink/50 hover:text-ink transition-colors",children:L?"Hide run history":"Run history"}),L&&e("div",{className:"px-2.5 pb-2.5 space-y-1",children:[R&&e("p",{className:"text-[10.5px] text-ink/40",children:"Loading…"}),!R&&C.length===0&&e("p",{className:"text-[10.5px] text-ink/40",children:"This task has not run yet."}),!R&&C.map((F)=>e("div",{className:"flex items-start gap-2 text-[10.5px]",children:[e("span",{className:"w-16 shrink-0 text-ink/50",children:new Date(F.startedAt).toLocaleTimeString()}),e("span",{className:`w-14 shrink-0 font-medium ${F.status==="error"?"text-error":F.status==="running"?"text-ink/60":"text-ink/70"}`,children:F.status}),e("span",{className:"w-12 shrink-0 text-ink/40",children:F.finishedAt===null?"…":Ve(F.finishedAt-F.startedAt)}),e("span",{className:"min-w-0 flex-1 text-ink/60 break-words",children:[F.detail||"–",F.sessionId&&e("span",{className:"block font-mono text-[10px] text-ink/40",children:["session ",F.sessionId.slice(0,8)]})]})]},F.id))]})]},v.id)})})}function At(){let[t,r]=n([]);return o(()=>{let l=!0;return fetch("/api/settings/projects").then((c)=>c.json()).then((c)=>{if(!l)return;r((c.projects??[]).filter((m)=>typeof m.folderId==="number").map((m)=>({id:m.folderId,name:m.name})))}).catch((c)=>console.error("Failed to load workspace folders:",c)),()=>{l=!1}},[]),t}function Mu({isOpen:t,onClose:r,activeSessionId:l=null,onToast:c}){let m=ht(t),h=At(),[g,y]=n(null),[k,w]=n(!1),[C,T]=n(!1),[R,O]=n(null);if(o(()=>{if(t)return;y(null),w(!1),T(!1),O(null)},[t]),o(()=>{let D=(M)=>{if(M.key!=="Escape"||C)return;if(M.preventDefault(),g||k){y(null),w(!1);return}r()};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[r,C,g,k]),!t)return null;let v=async(D)=>{T(!0);let M=g?await m.patch(g.id,D):await m.create(D);if(T(!1),M){c?.(M,"error");return}c?.(g?"Scheduled task updated.":"Scheduled task created.","success"),y(null),w(!1)},A=async(D)=>{O(D.id);let M=await m.patch(D.id,{enabled:!D.enabled});if(O(null),M)c?.(M,"error")},L=async(D)=>{O(D);let M=await m.runNow(D);if(O(null),M){c?.(M,"error");return}c?.("Task dispatched. Open the session to watch it run.","success")},F=async(D)=>{O(D);let M=await m.remove(D);if(O(null),M){c?.(M,"error");return}if(g?.id===D)y(null)},_=g!==null||k;return e("div",{className:"fixed inset-0 modal-scrim backdrop-blur-[2px] z-50 flex items-center justify-center modal-safe",onClick:C?void 0:r,role:"dialog","aria-modal":"true","aria-label":"Scheduled tasks",children:e("div",{className:"glass-overlay bg-paper border border-ink/15 rounded-xl shadow-2xl w-[min(94vw,640px)] max-h-[88vh] flex flex-col overflow-hidden text-ink",onClick:(D)=>D.stopPropagation(),children:[e("div",{className:"flex items-center justify-between px-4 py-3 border-b border-ink/10",children:[e("div",{className:"flex items-center gap-2",children:[e($a,{size:15}),e("h3",{className:"font-semibold text-sm",children:"Scheduled Tasks"})]}),e("button",{type:"button",onClick:r,"aria-label":"Close",className:"p-1.5 -m-1.5 rounded text-ink/50 hover:text-ink hover:bg-ink/5 transition-colors",children:e(b,{size:16})})]}),e("div",{className:"p-4 overflow-y-auto space-y-4",children:[m.error&&!_&&e("p",{className:"text-[11px] text-error border border-error/30 bg-error/5 rounded px-2.5 py-1.5",children:m.error}),_?e(It,{folders:h,initial:g,activeSessionId:l,serverTimeZone:m.serverTimeZone,busy:C,onSubmit:v,onCancel:()=>{y(null),w(!1)}}):e("button",{type:"button",onClick:()=>w(!0),className:"w-full py-2 rounded-lg border border-dashed border-ink/20 text-xs font-medium text-ink/70 hover:text-ink hover:border-ink/40 transition-colors",children:"+ New scheduled task"}),!_&&e(Ot,{tasks:m.tasks,loading:m.loading,pending:R,onRunNow:L,onToggleEnabled:A,onEdit:(D)=>y({id:D.id,name:D.name,prompt:D.prompt,kind:D.kind,spec:D.spec,harness:D.harness,timezone:D.timezone,folderId:D.folderId,sessionId:D.sessionId,model:D.model}),onDelete:F,loadRuns:m.loadRuns})]})]})})}var nt=["A-Z","Z-A","LATEST_SESSION","LATEST_ADDED"],Pt={"A-Z":"A-Z","Z-A":"Z-A",LATEST_SESSION:"Latest Session",LATEST_ADDED:"Latest Added"};function Jo({variant:t,sortOption:r,onSortChange:l}){if(t==="mobile")return e(d,{children:[e("div",{className:"px-2 py-1 text-[10px] uppercase font-bold text-ink/40 font-mono",children:"Sort Workspaces"}),nt.map((c)=>e("button",{type:"button",onClick:()=>l(c),className:`w-full text-left px-2.5 py-1.5 rounded-lg flex items-center justify-between transition-colors ${r===c?"bg-ink/10 font-semibold text-ink":"hover:bg-ink/5 text-ink/80"}`,children:[e("span",{children:c.replace("_"," ")}),r===c&&e(f,{size:13,className:"text-ink"})]},c))]});return e(d,{children:[e("div",{className:"px-3 py-1 text-[10px] uppercase font-bold text-ink/40 tracking-wider",children:"Sort Workspaces"}),nt.map((c)=>e("div",{className:`px-3 py-1.5 text-xs cursor-pointer flex items-center justify-between ${r===c?"bg-ink/5 text-ink font-medium":"text-ink/70 hover:bg-ink/5 hover:text-ink"}`,onClick:()=>l(c),children:[e("span",{children:Pt[c]}),r===c&&e("div",{className:"w-1.5 h-1.5 rounded-full bg-ink"})]},c))]})}function Fu({actions:t,sortHidden:r,sortOption:l,onSortChange:c,layout:m="desktop"}){let h=m==="mobile",[g,y]=n(!1),k=i(null);pe(k,()=>y(!1)),o(()=>{if(!g)return;let C=(T)=>{if(T.key==="Escape")y(!1)};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[g]);let w=(C)=>{y(!1),C.onSelect()};return e("div",{className:"relative shrink-0",ref:k,children:[e("button",{type:"button",title:"More sidebar actions","aria-label":"More sidebar actions","aria-haspopup":"menu","aria-expanded":g,onClick:()=>y(!g),className:`inline-flex items-center justify-center transition-colors cursor-pointer ${h?"w-9.5 h-9.5 rounded-xl border shadow-xs":"w-7 h-7 rounded border"} ${g?"border-ink/30 bg-ink/10 text-ink":"border-ink/15 bg-paper text-ink/70 hover:bg-ink/5 hover:text-ink"}`,children:e(Ee,{size:h?16:14})}),g&&e("div",{role:"menu",className:`glass-popover absolute right-0 top-full mt-2 w-52 bg-paper border border-ink/15 shadow-lg z-50 py-1 text-xs ${h?"rounded-xl p-2":"rounded-lg"}`,children:[t.map((C)=>e("button",{type:"button",role:"menuitem",onClick:()=>w(C),"aria-pressed":C.active,className:`w-full text-left flex items-center gap-2 transition-colors ${h?"px-2.5 py-1.5 rounded-lg":"px-3 py-1.5"} ${C.active?"bg-ink/5 text-ink font-medium":"text-ink/75 hover:bg-ink/5 hover:text-ink"}`,children:[e(C.icon,{size:13}),e("span",{children:C.label})]},C.id)),r&&e("div",{className:"mt-1 border-t border-ink/10 pt-1",children:e(Jo,{variant:m,sortOption:l,onSortChange:c})})]})]})}function Us(t){let r=i(null),[l,c]=n(0);return K(()=>{let m=r.current;if(!m)return;let h=()=>c(Math.max(0,m.clientWidth-t));if(h(),typeof ResizeObserver>"u")return;let g=new ResizeObserver(h);return g.observe(m),()=>g.disconnect()},[t]),{ref:r,width:l}}var op=["new-workspace","refresh","search","select","archive","scheduler","sort"];var CA=8;function EA(t){let r=op.length;if(!(t>0))return r;let l=t-112-6-8;if(r*28+(r-1)*6<=l)return r;let m=Math.floor((l-28-8)/34);return Math.max(2,Math.min(r,m))}var ho=38,go=8,bo=126,xo=1,ip=["new-workspace","refresh","archive","sort","scheduler","select"];function BA(t){let r=ip.length;if(!(t>0))return r;let l=ho+go,c=Math.floor((t-bo)/l);if(c>=r)return r;return Math.max(xo,Math.min(r,c-1))}var Et="inline-flex max-w-full shrink-0 items-center border font-medium transition-colors cursor-pointer",So="border-ink bg-ink text-paper",ko="border-ink/15 text-ink/60 hover:border-ink/30 hover:text-ink",Dt="w-full px-2.5 py-1.5 flex items-center gap-2 text-left hover:bg-ink/5 cursor-pointer",Ft="bg-ink/10 font-semibold text-ink",Mt="text-ink/75";function Gs({options:t,value:r,onChange:l,form:c="chip",touch:m=!1}){let[h,g]=n(null),y=r&&!t.some((T)=>T.harness===r)?[{harness:r,label:la(r),count:0},...t]:t;if(y.length<2&&!r)return null;let k=r?y.find((T)=>T.harness===r):void 0,w=k?k.label:"All harnesses",C=c==="icon"?e("button",{type:"button","aria-haspopup":"menu","aria-expanded":h!==null,"aria-label":`Filter by harness: ${w}`,title:r?`Harness: ${w}`:"Filter by harness",onClick:(T)=>g(h?null:Bt(T.currentTarget)),className:`${Et} h-[22px] w-[22px] justify-center rounded-md ${r?"border-ink bg-ink text-paper":"border-ink/15 text-ink/55 hover:border-ink/30 hover:text-ink"}`,children:k?e(et,{harness:k.harness,size:at.compact,inherit:!0,decorative:!0}):e(rt,{size:13})}):e("button",{type:"button","aria-haspopup":"menu","aria-expanded":h!==null,title:"Filter by harness",onClick:(T)=>g(h?null:Bt(T.currentTarget)),className:`${Et} gap-1 rounded-full ${m?"px-2 py-1 text-xs":"px-2 py-0.5 text-[11px]"} ${r?So:ko}`,children:[k?e(et,{harness:k.harness,size:at.compact,inherit:!0,decorative:!0}):null,e("span",{className:"max-w-[9rem] truncate",children:w}),k?e("span",{className:"font-mono tabular-nums opacity-70",children:k.count}):null,e(B,{size:11,className:"shrink-0 opacity-60"})]});return e(d,{children:[C,e(Rt,{anchor:h,align:"start",ariaLabel:"Filter by harness",className:"w-56 bg-paper border border-ink/15 rounded-lg shadow-xl py-1 text-xs",onClose:()=>g(null),children:[e("button",{type:"button",onClick:()=>{l(null),g(null)},className:`${Dt} ${!r?Ft:Mt}`,children:[e("span",{className:"flex-1 truncate",children:"All harnesses"}),!r?e(f,{size:12}):null]}),y.map((T)=>{let R=T.harness===r;return e("button",{type:"button",onClick:()=>{l(T.harness),g(null)},className:`${Dt} ${R?Ft:Mt}`,children:[e(et,{harness:T.harness,size:at.compact,decorative:!0}),e("span",{className:"flex-1 truncate",children:T.label}),e("span",{className:"font-mono tabular-nums text-ink/50",children:T.count}),R?e(f,{size:12}):null]},T.harness)})]})]})}function js(t=5,r=7){let[l,c]=n(t),m=a(()=>c((g)=>g+r),[r]),h=a(()=>c(t),[t]);return{visibleCount:l,showMore:m,showLess:h,canShowLess:l>t}}function qs(t,r,l){let[c,m]=n(!1),h=pt(),g=pt(),{handleArchive:y,handleRename:k,handleRenameWithAi:w}=yf(r,l),C=()=>{if(typeof t.id!=="number")return;h.submit({isPinned:String(!t.isPinned)},{method:"POST",action:`/api/folders/${t.id}/pin`}),r()},T=()=>{if(typeof t.id!=="number")return;g.submit({},{method:"POST",action:`/api/folders/${t.id}/delete`}),m(!1),r()},R=t.project_path?()=>{(async()=>{try{let O=await fetch(`/api/folders/${encodeURIComponent(String(t.id))}/open`,{method:"POST"}),v=await O.json().catch(()=>({}));if(!O.ok)l?.(v.error||`Could not open the folder (HTTP ${O.status})`)}catch(O){l?.(O instanceof Error?O.message:String(O))}})()}:void 0;return{confirmDelete:c,requestDelete:()=>m(!0),cancelDelete:()=>m(!1),handlePin:C,handleOpenFolder:R,handleDelete:T,handleArchive:y,handleRename:k,handleRenameWithAi:w}}function zr({checked:t,indeterminate:r=!1,label:l,onChange:c,size:m="sm"}){let h=i(null);return o(()=>{if(h.current)h.current.indeterminate=r},[r]),e("input",{ref:h,type:"checkbox",checked:t,"aria-label":l,onChange:c,onClick:(g)=>g.stopPropagation(),className:`${he} shrink-0 accent-ink cursor-pointer ${m==="md"?"w-3.5 h-3.5":"w-3 h-3"}`})}function vo(t){let r=t.branch||(t.detached?"detached":"worktree");return t.status==="missing"?`${r} · ${"missing"}`:r}function yo(t){if(t.status==="missing")return`Worktree folder is missing: ${t.path}`;return t.detached?`Detached HEAD in worktree ${t.path}`:`Runs in worktree ${t.path}`}function Hs({worktree:t}){let r=t.status==="missing";return e("span",{className:`flex min-w-0 items-center gap-1 truncate text-[10px] font-normal ${r?"text-warning":"text-ink/45"}`,title:yo(t),"data-worktree-status":t.status,children:[e("span",{"aria-hidden":"true",className:"shrink-0 font-mono",children:"⑂"}),e("span",{className:"truncate",children:vo(t)})]})}var wo=1000,De=new Set,Oe=null;function No(){let t=Date.now();for(let r of De)r(t)}function Co(t){if(De.add(t),Oe===null)Oe=setInterval(No,wo);return()=>{if(De.delete(t),De.size===0&&Oe!==null)clearInterval(Oe),Oe=null}}function $t(t=!0){let[r,l]=n(()=>Date.now());return o(()=>{if(!t)return;return Co(l)},[t]),r}function Ws(t,r=Date.now()){if(t===null||t===void 0||t==="")return null;let l=typeof t==="number"?t:Date.parse(t);if(Number.isNaN(l))return null;let c=Math.round((r-l)/1000);if(c<45)return"now";let m=Math.round(c/60);if(m<60)return`${m}m`;let h=Math.round(m/60);if(h<24)return`${h}h`;let g=Math.round(h/24);if(g<7)return`${g}d`;let y=Math.round(g/7);if(y<5)return`${y}w`;let k=new Date(l),w=k.getFullYear()===new Date(r).getFullYear(),C=k.getDate(),T=k.toLocaleString("en-US",{month:"short"});return w?`${C} ${T}`:`${C} ${T} ${k.getFullYear()}`}function Zo(t){if(t===null||t===void 0||t==="")return null;let r=typeof t==="number"?t:Date.parse(t);if(Number.isNaN(r))return null;return new Date(r).toLocaleString("en-US",{weekday:"short",day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}function Wt(t){if(!Number.isFinite(t)||t<1000)return"0s";return xf(t)??"0s"}function zt({startedAt:t,className:r}){let l=$t(),c=Wt(Math.max(0,l-t)),m=u(()=>Zo(t),[t]);return e("span",{role:"timer",className:`tabular-nums ${r??""}`,title:m?`Started ${m}`:void 0,"aria-label":`Running for ${c}`,children:c})}var Io="text-ink/40",Oo="text-ink/80";function Ks({timeAgo:t,timeTitle:r,runStartedAt:l,className:c,restingClassName:m=Io}){if(l!==void 0)return e(zt,{startedAt:l,className:`${c} ${Oo}`});if(!t)return null;return e("span",{className:`${c} ${m}`,title:r??void 0,children:t})}var Vs="bg-ink/10 text-ink ring-1 ring-inset ring-ink/20";function Ys({variant:t,isPinned:r=!1,onOpenFolder:l,onSelectSessions:c,onNewWorktree:m,confirmDelete:h,onPin:g,onDelete:y,onRequestDelete:k,onCancelDelete:w}){if(t==="mobile")return h?e(d,{children:[e("div",{className:"px-3 py-2 text-ink/80 font-medium",children:"Delete workspace?"}),e("button",{type:"button",onClick:y,className:"w-full text-left px-3 py-2 hover:bg-error/10 text-error flex items-center space-x-2",children:[e(N,{size:13}),e("span",{children:"Yes, delete"})]}),e("button",{type:"button",onClick:w,className:"w-full text-left px-3 py-2 hover:bg-ink/5 text-ink/70",children:"Cancel"})]}):e(d,{children:[l&&e("button",{type:"button",onClick:l,className:"w-full text-left px-3 py-2 hover:bg-ink/5 text-ink/80 flex items-center space-x-2",children:[e(Zt,{size:13}),e("span",{children:"Go to Explorer"})]}),e("button",{type:"button",onClick:g,className:"w-full text-left px-3 py-2 hover:bg-ink/5 text-ink/80 flex items-center space-x-2",children:[r?e(bi,{size:13}):e(Qr,{size:13}),e("span",{children:r?"Unpin Workspace":"Pin Workspace"})]}),c&&e("button",{type:"button",onClick:c,className:"w-full text-left px-3 py-2 hover:bg-ink/5 text-ink/80 flex items-center space-x-2",children:[e($r,{size:13}),e("span",{children:"Select sessions"})]}),m&&e("button",{type:"button",onClick:m,className:"w-full text-left px-3 py-2 hover:bg-ink/5 text-ink/80 flex items-center space-x-2",children:[e(ce,{size:13}),e("span",{children:"New worktree…"})]}),e("button",{type:"button",onClick:k,className:"w-full text-left px-3 py-2 hover:bg-error/10 text-error flex items-center space-x-2",children:[e(N,{size:13}),e("span",{children:"Delete Workspace"})]})]});return h?e(d,{children:[e("div",{className:"px-3 py-1.5 text-xs text-ink/80 font-medium",children:"Delete workspace?"}),e("button",{type:"button",onClick:y,className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-error",children:[e(N,{size:12}),e("span",{children:"Yes, delete"})]}),e("button",{type:"button",onClick:w,className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-ink/70",children:e("span",{children:"Cancel"})})]}):e(d,{children:[l&&e("button",{type:"button",onClick:l,className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-ink/80",children:[e(Zt,{size:12}),e("span",{children:"Go to Explorer"})]}),e("button",{type:"button",onClick:g,className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-ink/80",children:[r?e(bi,{size:12}):e(Qr,{size:12}),e("span",{children:r?"Unpin Workspace":"Pin Workspace"})]}),c&&e("button",{type:"button",onClick:c,className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-ink/80",children:[e($r,{size:12}),e("span",{children:"Select sessions"})]}),m&&e("button",{type:"button",onClick:m,className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-ink/80",children:[e(ce,{size:12}),e("span",{children:"New worktree…"})]}),e("button",{type:"button",onClick:k,className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-error",children:[e(N,{size:12}),e("span",{children:"Delete Workspace"})]})]})}function Fe({ancestors:t,isLast:r,first:l,style:c}){let m=c.insetPx+c.slotWidth/2,h=c.slotWidth/2+c.markGap+c.glyph/2,g=h+c.insetPx-m,y=2,k=m-1,w=l?r?{left:k,top:-6,height:"calc(50% + 6px)"}:{left:k,top:-6,bottom:-2}:r?{left:k,top:0,height:"50%"}:{left:k,top:0,bottom:-2};return e(d,{children:[t.map((C,T)=>e("span",{"data-guide":"ancestor","data-continues":C?void 0:"true","aria-hidden":"true",className:"relative shrink-0",style:{width:h},children:!C&&e("span",{className:"absolute z-10 bg-ink/40",style:{left:k,top:0,bottom:-2,width:2}})},T)),e("span",{"data-guide":"connector","data-last":r?"true":void 0,"data-first":l?"true":void 0,"aria-hidden":"true",className:"relative shrink-0",style:{width:h},children:[e("span",{className:"absolute z-10 bg-ink/40",style:{width:2,...w}}),e("span",{className:"absolute z-10 bg-ink/40",style:{left:k,top:"calc(50% - 1px)",width:g+1,height:2}})]})]})}function Ht({subagent:t,sessionId:r,style:l,running:c}){let[m]=le(),h=t.id===m.get("subagent"),g=T0(t),y=t.task??t.assignment??t.description??g;return e("div",{className:"group/subagent-row flex items-center",children:[e("button",{type:"button",title:y,onClick:()=>window.dispatchEvent(new CustomEvent("omp:view-subagent",{detail:{sessionId:r,subagent:t}})),className:`flex-1 min-w-0 flex items-center text-left text-xs rounded-md ${l.inset} ${l.padding} cursor-pointer transition-colors select-none ${h?"bg-ink/10 font-medium text-ink":"text-ink/70 hover:text-ink hover:bg-ink/5"}`,children:[e("span",{"data-testid":"subagent-status-slot",className:"w-4 h-4 flex items-center justify-center shrink-0",children:e(wf,{status:t.status,live:c,size:11})}),e("span",{className:"w-2 shrink-0"}),e("span",{"data-testid":"subagent-mark",className:"mr-1.5 flex shrink-0 items-center text-ink/55",children:e(rt,{size:l.glyph,"aria-hidden":"true"})}),e("span",{className:"flex-1 min-w-0 truncate leading-snug",children:g})]}),c&&e("button",{type:"button",title:"Stop this subagent","aria-label":"Stop this subagent",onClick:()=>void Cf(r,t.id),className:"touch-visible shrink-0 mr-1 w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-error hover:bg-error/5 opacity-0 group-hover/subagent-row:opacity-100 transition-opacity cursor-pointer",children:e(Xt,{size:10})})]})}var Ro={pending:"started",running:"started",completed:"completed",failed:"failed",aborted:"aborted"};function Ao(t,r){return t.map((l)=>{if(r.id!==void 0){if(l.id!==r.id)return l}else if(r.index===void 0||r.index<0||l.index!==r.index)return l;let c=r.status&&l.status==="started"?Ro[r.status]??l.status:l.status;return{...l,status:c,progress:{...l.progress,...r},lastUpdate:Date.now()}})}function Ut(t,r,l){let[c,m]=n([]),[h,g]=n(!1);return o(()=>{if(!l)return;let y=!1;return m([]),g(!0),D0(t).then((k)=>{if(y||!k)return;let w=k.map(Ef);m((C)=>_f(C,w))}).finally(()=>{if(!y)g(!1)}),()=>{y=!0}},[t,l]),o(()=>{if(!l||!r)return;let y=!1,k=Date.now(),w=(R)=>R.sessionId===t?R.payload:null,C=Nl("subagent_lifecycle",(R)=>{let O=Bf(w(R));if(O)m((v)=>_f(v,[O]))}),T=Nl("subagent_progress",(R)=>{let O=If(w(R));if(O)m((v)=>Ao(v,O))});return fetch(`/api/agent/${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"get_subagents"})}).then((R)=>R.ok?R.json():null).then((R)=>{if(y||!x(R))return;let O="data"in R?R.data:R;m((v)=>_f(v,N0(O),k))}).catch(()=>{}),()=>{y=!0,C(),T()}},[l,r,t]),{subagents:c,isLoading:h}}function Js(t,r,l,c,m=!1){let h=String(t.id);return{expandable:(r.get(h)?.length??0)>0||Boolean(t.hasSubagents),isExpanded:l.has(h),onToggleExpand:()=>c(h),isChild:m}}function Li({parentId:t,hasSubagents:r,childrenOf:l,expandedIds:c,onToggle:m,activeSessionId:h,renderSession:g,style:y,ancestors:k=[]}){let w=l.get(t)??[],{subagents:C,isLoading:T}=Ut(t,h===t,r),R=[...w.map((O)=>({kind:"session",session:O})),...C.map((O)=>({kind:"subagent",subagent:O}))];if(R.length===0){if(!T)return null;return e("div",{"data-testid":"session-branch",className:"space-y-0.5",children:e("div",{className:"flex items-stretch",children:[e(Fe,{ancestors:k,isLast:!0,first:!0,style:y}),e("div",{className:`flex min-w-0 flex-1 items-center text-xs italic text-ink/40 ${y.inset} ${y.padding}`,children:"Loading subagents…"})]})})}return e("div",{"data-testid":"session-branch",className:"space-y-0.5",children:R.map((O,v)=>{let A=v===R.length-1;if(O.kind==="subagent")return e("div",{className:"flex items-stretch",children:[e(Fe,{ancestors:k,isLast:A,first:v===0,style:y}),e("div",{className:"min-w-0 flex-1",children:e(Ht,{subagent:O.subagent,sessionId:t,style:y,running:h===t&&O.subagent.status==="started"})})]},`subagent:${O.subagent.id}`);let L=String(O.session.id),_={expandable:(l.get(L)?.length??0)>0||Boolean(O.session.hasSubagents),isExpanded:c.has(L),onToggleExpand:()=>m(L),isChild:!0};return e(d,{children:[e("div",{className:"flex items-stretch",children:[e(Fe,{ancestors:k,isLast:A,first:v===0,style:y}),e("div",{className:"min-w-0 flex-1",children:g(O.session,_)})]}),_.isExpanded&&e(Li,{parentId:L,hasSubagents:Boolean(O.session.hasSubagents),childrenOf:l,expandedIds:c,onToggle:m,activeSessionId:h,renderSession:g,style:y,ancestors:[...k,A]})]},L)})})}function Xo(t){let r=new Set(t.map((m)=>String(m.id))),l=new Map,c=[];for(let m of t){let h=m.parentSessionId;if(!h||!r.has(h)||h===String(m.id)){c.push(m);continue}let g=l.get(h);if(g)g.push(m);else l.set(h,[m])}return{roots:c,childrenOf:l}}function ot(t,r,l=1,c=new Set){if(c.has(t))return[];c.add(t);let m=[];for(let h of r.get(t)??[]){if(c.has(String(h.id)))continue;m.push({session:h,depth:l}),m.push(...ot(String(h.id),r,l+1,c))}return m}function Gt(t,r){return t.includes(r)?t.filter((l)=>l!==r):[...t,r]}function Kt(t,r){let l=new Set(t),c=r.filter((m)=>l.has(m)).length;return{count:c,all:r.length>0&&c===r.length,some:c>0&&c<r.length}}function Be(t,r){return t.filter((l)=>r?l.is_archived===1:l.is_archived!==1).map((l)=>String(l.id))}function jt(t,r){let l=new Set(r);return t.filter((c)=>l.has(c))}function Yt(t,r,{activeSessionId:l,sessionStatus:c={}}){if(t.length<=r)return{rendered:t,hiddenCount:0};let m=new Set;for(let w of t){let C=String(w.id);if((l!==null?String(l)===C:w.is_active===1)||c[C]==="stream"||Boolean(w.awaitingInput))m.add(C)}let h=Xo(t),g=new Set,y=0;for(let w=0;w<h.roots.length;w+=1){let C=h.roots[w],T=String(C.id),R=ot(T,h.childrenOf),O=m.has(T)||R.some((v)=>m.has(String(v.session.id)));if(w<r||O){g.add(T);for(let v of R)g.add(String(v.session.id))}else y+=1}return{rendered:t.filter((w)=>g.has(String(w.id))),hiddenCount:y}}function Vt(t,r){return t.mode==="workspace"||t.mode==="session"&&t.scopeFolderId===r}function qt(t,r){return t.mode==="session"&&t.scopeFolderId===r}function Zs({batch:t,folder:r,sessions:l,showArchived:c,visibleCount:m,activeSessionId:h,sessionStatus:g}){let y=t?Vt(t,r.id):!1,k=t?qt(t,r.id):!1,w=k?Be(l,c):y?[String(r.id)]:[],C=t&&y?t.summaryOf(w):null,T=Yt(l,m,{activeSessionId:h,sessionStatus:g});return{folderCheckbox:y,sessionCheckboxes:k,folderSummary:C,selectableIds:w,toggleFolderSelection:()=>{if(!t)return;if(y&&!k){t.toggle(String(r.id));return}if(!k)return;if(C?.all)t.unselectAllOf(w);else t.selectAllOf(w)},rendered:k?l:T.rendered,hiddenCount:k?0:T.hiddenCount}}function Xs({touch:t=!1,onRetry:r,refreshing:l=!1}){return e("div",{role:"alert",className:`flex flex-col items-center justify-center gap-2 px-4 text-center ${t?"py-10":"py-8"}`,children:[e("span",{className:"flex h-8 w-8 items-center justify-center rounded-md border border-ink/10 bg-ink/5 text-muted",children:e(I,{size:15,"aria-hidden":"true"})}),e("p",{className:"text-xs font-semibold text-ink",children:"The session list could not be loaded."}),e("p",{className:`text-muted leading-relaxed ${t?"text-xs":"text-[11px]"}`,children:"The live connection closed before the first reply arrived. Your sessions are still on disk; they are not shown here because this tab never received them."}),e("button",{type:"button",onClick:r,disabled:l,"aria-busy":l,className:`mt-1 inline-flex items-center gap-1.5 rounded-md border border-ink/20 bg-paper px-2.5 font-medium text-ink transition-colors hover:bg-ink/5 disabled:opacity-60 ${t?"h-11 text-sm":"h-7 text-xs"}`,children:[e(S,{size:13,className:l?"animate-spin":void 0,"aria-hidden":"true"}),"Try again"]})]})}function Jt({value:t,onChange:r,touch:l=!1}){return e("div",{className:l?"px-3 pt-3 pb-2":"px-3 pt-2 pb-2",children:e("div",{className:`flex items-center gap-1.5 rounded-lg border border-ink/10 bg-ink/[0.04] px-2 transition-colors focus-within:border-ink/30 focus-within:bg-paper ${l?"h-9":"h-7"}`,children:[e(U,{size:l?15:13,"aria-hidden":"true",className:"shrink-0 text-ink/35"}),e("input",{type:"search",value:t,onChange:(c)=>r(c.currentTarget.value),placeholder:"Search workspaces & sessions","aria-label":"Search workspaces and sessions",className:`kabmo-search-field min-w-0 flex-1 bg-transparent text-ink outline-none placeholder:text-ink/40 ${l?"text-[13px]":"text-xs"}`}),t.length>0&&e("button",{type:"button",onClick:()=>r(""),title:"Clear search","aria-label":"Clear search",className:"-mr-0.5 shrink-0 rounded p-0.5 text-ink/40 transition-colors cursor-pointer hover:bg-ink/10 hover:text-ink",children:e(b,{size:l?14:12})})]})})}var Ne={all:32,running:69,runningCount:14,archived:79,select:66};function Po(t,r){let l=[Ne.all,Ne.running+(t>0?Ne.runningCount:0),Ne.archived,...r?[Ne.select]:[]];return l.reduce((c,m)=>c+m,0)+(l.length-1)*4}var Le={chip:105,icon:22};function Qt(t,r){if(!(t>0))return{select:"mini",harness:"icon",wrap:!1};let l=Po(r,!1),c=(m,h)=>l+8+m+h<=t;if(c(Le.chip,Ne.select))return{select:"chip",harness:"chip",wrap:!1};if(c(Le.chip,28))return{select:"button",harness:"chip",wrap:!1};if(c(Le.icon,28))return{select:"button",harness:"icon",wrap:!1};if(c(Le.icon,22))return{select:"mini",harness:"icon",wrap:!1};return{select:"mini",harness:"icon",wrap:!0}}var Me="inline-flex shrink-0 items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium transition-colors cursor-pointer",st="border-ink bg-ink text-paper",$e="border-ink/15 text-ink/60 hover:border-ink/30 hover:text-ink",Eo=(t)=>t?"Cancel":"Select";function en({focus:t,onFocusChange:r,runningCount:l,showArchived:c,onToggleArchived:m,harnessFilter:h,onHarnessFilterChange:g,harnessOptions:y,selecting:k,onToggleSelect:w}){let{ref:C,width:T}=Us(0),R=Qt(T,l),O=k?e(b,{size:10}):e($r,{size:10}),v=e(Gs,{options:y,value:h,onChange:g,form:R.wrap?"chip":R.harness});return e("div",{className:"px-3 pb-2",children:e("div",{ref:C,className:`flex items-center gap-1 ${R.wrap?"flex-wrap":"flex-nowrap"}`,children:[e("div",{className:"flex shrink-0 items-center gap-1",role:"group","aria-label":"Session filters",children:[e("button",{type:"button",onClick:()=>r("all"),"aria-pressed":t==="all",className:`${Me} ${t==="all"?st:$e}`,children:"All"}),e("button",{type:"button",onClick:()=>r("running"),"aria-pressed":t==="running",title:l>0?`${l} running or waiting`:"Nothing running",className:`${Me} ${t==="running"?st:$e}`,children:[e("span",{"aria-hidden":"true",className:`h-1.5 w-1.5 rounded-full ${l>0?"bg-current":"bg-current opacity-30"}`}),"Running",l>0&&e("span",{className:"font-mono tabular-nums opacity-70",children:l})]}),e("button",{type:"button",onClick:m,"aria-pressed":c,title:c?"Hide archived sessions":"Show archived sessions",className:`${Me} ${c?"border-warning/40 bg-warning/10 text-warning hover:bg-warning/15":$e}`,children:[e(lt,{size:10}),"Archived"]})]}),R.wrap?null:v,R.select==="chip"?e("button",{type:"button",onClick:w,"aria-pressed":k,title:k?"Cancel selection":"Select workspaces",className:`${Me} ml-auto ${k?st:$e}`,children:[O,Eo(k)]}):e("button",{type:"button",onClick:w,title:k?"Cancel selection":"Select workspaces","aria-label":k?"Cancel selection":"Select workspaces","aria-pressed":k,className:`ml-auto inline-flex shrink-0 items-center justify-center rounded-md transition-colors cursor-pointer ${R.select==="mini"?"h-[22px] w-[22px]":"h-7 w-7"} ${k?"bg-ink/10 text-ink":"text-ink/55 hover:bg-ink/[0.06] hover:text-ink"}`,children:k?e(b,{size:R.select==="mini"?12:14}):e($r,{size:R.select==="mini"?12:14})}),R.wrap?v:null]})})}var Do="shrink-0 inline-flex items-center justify-center rounded-md text-ink/55 transition-colors cursor-pointer hover:bg-ink/[0.06] hover:text-ink",Fo="bg-ink/10 text-ink",tn={"A-Z":"A–Z","Z-A":"Z–A",LATEST_SESSION:"Latest chat",LATEST_ADDED:"Latest added"};function nn({onNewSession:t,onNewWorkspace:r,onScheduler:l,scheduledCount:c,onRefresh:m,refreshing:h,sortOption:g,optionsOpen:y,onToggleOptions:k,onCloseOptions:w,onSortChange:C,touch:T=!1}){let R=`${Do} ${T?He.mobile:He.desktop}`,O=c>0?`Scheduled tasks (${c} armed)`:"Scheduled tasks";return e("div",{className:`flex items-center ${kl} px-3 pb-2`,children:[e("button",{type:"button",onClick:t,title:"New Session","aria-label":"New Session",className:`flex min-w-0 flex-1 items-center justify-center gap-1.5 rounded-md bg-ink px-2 font-semibold text-canvas transition-colors cursor-pointer hover:bg-ink/90 ${T?"h-9 text-[13px]":"h-7 text-xs"}`,children:[e(P,{size:T?16:14,className:"shrink-0"}),e("span",{className:"truncate",children:"New Session"})]}),e("div",{className:`flex shrink-0 items-center ${ds}`,children:[e("button",{type:"button",onClick:r,title:"New Workspace","aria-label":"New Workspace",className:R,children:e(gn,{size:T?16:14})}),e("button",{type:"button",onClick:l,title:O,"aria-label":c>0?`Scheduled tasks, ${c} armed`:"Scheduled tasks",className:`relative ${R}`,children:[e($a,{size:T?16:14}),c>0&&e("span",{className:"absolute right-0.5 top-0.5 min-w-[10px] rounded-full bg-ink px-[2px] text-center text-[7px] font-semibold leading-[10px] text-canvas",children:c>9?"9+":c})]}),e("button",{type:"button",onClick:m,title:"Refresh sessions","aria-label":"Refresh sessions","aria-busy":h,className:R,children:e(S,{size:T?16:14,className:h?"animate-spin":""})}),e("div",{className:"relative",children:[e("button",{type:"button",onClick:k,title:`Sort: ${tn[g]}`,"aria-label":`Sort workspaces, currently ${tn[g]}`,"aria-haspopup":"menu","aria-expanded":y,className:`${R} ${y||g!=="A-Z"?Fo:""}`,children:e(zs,{size:T?16:14})}),y&&e("div",{className:"glass-popover absolute right-0 top-full z-50 mt-1 w-48 rounded-lg border border-ink/15 bg-paper py-1 shadow-lg",onMouseLeave:w,children:e(Jo,{variant:"desktop",sortOption:g,onSortChange:C})})]})]})]})}function on({title:t,status:r,awaitingInput:l=!1,renaming:c=!1,waitingFor:m,expandable:h=!1,isExpanded:g=!1,onToggleExpand:y,child:k=!1,selectable:w=!1,selected:C=!1,onToggleSelect:T,touch:R=!1}){if(w)return e("span",{className:"flex shrink-0 items-center",children:[e(zr,{checked:C,label:`Select ${t}`,onChange:()=>T?.()}),e("span",{className:"w-2 shrink-0"})]});let O=R?14:13,v=Boolean(m),A=l||r==="stream"||v,L=Boolean(h&&y)&&!A&&!c,F=Boolean(c||l||v||r)&&!L;return e(d,{children:[e("span",{className:`relative shrink-0 ${R?"w-[18px] h-5":"w-4 h-4"}`,children:[h&&y&&e("button",{type:"button",onClick:(_)=>{_.stopPropagation(),y(_)},title:g?"Collapse sessions and subagents":"Expand sessions and subagents","aria-expanded":g,"aria-label":g?"Collapse sessions and subagents":"Expand sessions and subagents",className:`peer absolute inset-0 flex items-center justify-center rounded cursor-pointer transition-opacity ${L?"text-ink/55 hover:text-ink":"text-ink/40 opacity-0 hover:text-ink group-hover/item:opacity-100 focus-visible:opacity-100"}`,children:g?e(B,{size:O}):e(se,{size:O})}),F&&e("span",{className:`pointer-events-none absolute inset-0 flex items-center justify-center text-ink/60 transition-opacity ${h?"group-hover/item:opacity-0 peer-focus-visible:opacity-0":""}`,children:c?e("span",{role:"status","aria-label":"Generating a name…",children:e(p,{size:O-1,className:"animate-spin"})}):l?e(Qe,{size:O-1,className:"animate-pulse text-warning"}):v?e("span",{role:"status","aria-label":`Waiting for ${m?.title??"another session"}`,children:e(qe,{size:O-1,className:"animate-pulse"})}):r==="stream"?e("span",{role:"status","aria-label":"Running",children:e(p,{size:O-1,className:"animate-spin"})}):e(f,{size:O-1})}),k&&!(h&&y)&&!F&&e("span",{"data-testid":"child-indicator","aria-hidden":"true",className:"pointer-events-none absolute inset-0 flex items-center justify-center text-ink/35",children:e(ce,{size:O-1,"aria-hidden":"true"})})]}),e("span",{className:"w-2 shrink-0"})]})}function sn({timeAgo:t,timeTitle:r,runStartedAt:l,onOpenMenu:c,menuOpen:m=!1,touch:h=!1}){let g=(k)=>e(Ks,{timeAgo:t,timeTitle:r,runStartedAt:l,className:k});if(!c)return g("ml-2 shrink-0 font-mono text-[10px]");let y=e("button",{type:"button",onClick:c,title:"Session actions","aria-label":"Session actions","aria-haspopup":"menu","aria-expanded":m,className:`shrink-0 rounded text-ink/40 hover:bg-ink/10 hover:text-ink cursor-pointer ${h?"p-1.5":"p-1"} ${h?"":"opacity-0 transition-opacity group-hover/item:opacity-100 group-focus-within/item:opacity-100 focus-visible:opacity-100"}`,children:e(Ee,{size:h?16:14})});if(h)return e("span",{className:"ml-1 flex shrink-0 items-center gap-0.5",children:[g("font-mono text-[10px]"),y]});return e("span",{className:"relative ml-2 flex h-4 min-w-8 shrink-0 items-center justify-end pr-1",children:[g("whitespace-nowrap font-mono text-[10px] leading-none transition-opacity group-hover/item:opacity-0 group-focus-within/item:opacity-0"),e("span",{className:"absolute right-0 -my-1 flex",children:y})]})}function rn(t){return{inset:t?"pl-1 pr-1":"pl-1 pr-[3px]",insetPx:4,slotWidth:t?18:16,markGap:8,padding:t?"py-0.5":"py-[7px]",glyph:t?at.touch:at.compact}}function an({sessionId:t,title:r,harness:l,isActive:c=!1,isArchived:m=!1,status:h,awaitingInput:g=!1,timeAgo:y,timeTitle:k,runStartedAt:w,worktree:C,waitingFor:T,expandable:R=!1,isExpanded:O=!1,onToggleExpand:v,isChild:A=!1,folderId:L,onClick:F,onRename:_,onRenameWithAi:D,onArchive:M,onDelete:q,onCancelWait:ee,selectable:X=!1,selected:re=!1,onToggleSelect:ae,density:Y="compact"}){let V=Y==="touch",me=Fa(t),W=jo(),{isEditing:be,draft:fe,setDraft:de,inputRef:J,startRename:ke,handleKeyDown:ve,handleBlur:te}=Go(r,_),oe=Boolean(_||M||q||ee),Q=W.anchor!==null,ye=Boolean(T),ie=r.charAt(0).toUpperCase()+r.slice(1);if(be)return e("div",{className:`flex w-full items-center rounded-lg bg-ink/10 ${V?"px-2 py-1.5":"px-2 py-1"}`,children:e("input",{ref:J,autoFocus:!0,value:fe,onChange:(ge)=>de(ge.currentTarget.value),onClick:(ge)=>ge.stopPropagation(),onKeyDown:ve,onBlur:te,"aria-label":"Session name",className:"min-w-0 flex-1 rounded border border-ink/25 bg-paper px-2 py-0.5 text-xs text-ink outline-none focus:border-ink/50"})});return e(d,{children:[e("div",{"data-testid":"session-item","data-session-id":String(t),"data-selected":X&&re?"true":void 0,"data-menu-open":Q?"true":void 0,onClick:X?ae:F,onContextMenu:oe&&!X?W.openAtCursor:void 0,className:`group/item relative flex w-full items-center rounded-lg text-xs transition-colors select-none cursor-pointer ${V?"py-0.5 pl-1 pr-1":"py-[7px] pl-1 pr-[3px]"} ${X&&re||Q?Vs:c?"bg-ink/[0.08] font-medium text-ink":"text-ink/75 hover:bg-ink/[0.04] hover:text-ink"}`,children:[c&&!X&&e("span",{"aria-hidden":"true",className:"absolute left-0 top-1.5 bottom-1.5 w-[2px] rounded-full bg-ink"}),e(on,{title:r,status:h,awaitingInput:g,renaming:me,waitingFor:T,expandable:R,isExpanded:O,onToggleExpand:v,child:A,selectable:X,selected:re,onToggleSelect:ae,touch:V}),l&&e("span",{className:"mr-1.5 flex shrink-0 items-center",children:e(et,{harness:l,size:V?at.touch:at.compact})}),e("span",{className:`flex min-w-0 flex-1 flex-col leading-snug ${m?"text-ink/45":""}`,children:[e("span",{className:"min-w-0 truncate",children:ie}),ye&&e("span",{className:"truncate text-[10px] font-normal text-ink/40",children:["waiting for ",T?.title??"another session"]}),C&&e(Hs,{worktree:C})]}),e(sn,{timeAgo:y,timeTitle:k,runStartedAt:w,touch:V,menuOpen:Q,onOpenMenu:oe&&!X?W.openBelow:void 0})]}),W.anchor&&e(qo,{anchor:W.anchor,sessionId:t,...l?{harness:l}:{},...L!==void 0?{folderId:L}:{},isArchived:m,onRename:_?ke:void 0,onRenameWithAi:D,onArchive:M,onDelete:q,onCancelWait:ee,onClose:W.close})]})}function _o(t){let r=t.parentElement;while(r){let l=getComputedStyle(r);if(/(auto|scroll|overlay)/.test(l.overflowY))return r;r=r.parentElement}return null}function ln(t){let[r,l]=n(!1);return o(()=>{let c=t.current;if(!c)return;let m=_o(c),h=!1,g=()=>{h=!1;let w=m?m.getBoundingClientRect():{top:0},C=m?m.scrollTop>0:window.scrollY>0,T=c.getBoundingClientRect();l(C&&T.top<=w.top+0.5&&T.bottom>w.top)},y=()=>{if(h)return;h=!0,requestAnimationFrame(g)};g();let k=typeof ResizeObserver>"u"?null:new ResizeObserver(y);if(k?.observe(c),m)k?.observe(m);return(m??window).addEventListener("scroll",y,{passive:!0}),window.addEventListener("resize",y),()=>{h=!1,k?.disconnect(),(m??window).removeEventListener("scroll",y),window.removeEventListener("resize",y)}},[t]),r}function cn({folder:t,isOpen:r,onToggleFolder:l,sessionCount:c,checkbox:m,batchActive:h,showMenu:g,onToggleMenu:y,onCloseMenu:k,onNewSession:w,menu:C,touch:T=!1}){let R=ua(t.icon),O=t.accentColor||void 0,v=i(null),[A,L]=n(null),F=i(null),_=ln(F);return e("div",{ref:F,"data-stuck":_?"":void 0,className:`group/ws sticky top-0 z-10 -mx-1 flex items-center gap-1 rounded-md px-1 text-xs font-semibold text-ink ${T?"h-8 bg-canvas glass-sticky":"h-[26px] bg-paper glass-sticky"}`,children:[e("button",{type:"button",onClick:h?void 0:l,"aria-expanded":r,"aria-label":`${t.name}${r?", collapse":", expand"}`,className:"flex h-full min-w-0 flex-1 items-center gap-2 rounded-md px-1 text-left cursor-pointer hover:bg-ink/[0.04]",children:[m?e(zr,{size:"md",checked:m.checked,indeterminate:m.indeterminate,label:m.label,onChange:m.onChange}):e("span",{className:`relative flex shrink-0 items-center justify-center ${T?"h-[18px] w-[18px]":"h-4 w-4"}`,children:t.customIconUrl?e("img",{src:t.customIconUrl,alt:"",className:"h-[15px] w-[15px] shrink-0 rounded-xs object-contain",referrerPolicy:"no-referrer"}):e(R,{size:15,className:"project-accent-mark text-ink/70",style:Sl(O)})}),e("span",{className:"glass-sticky-label truncate text-[13px] font-semibold tracking-tight",children:t.name}),t.isPinned&&e(Qr,{size:10,className:"shrink-0 text-ink/45"}),O&&!m&&e("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{backgroundColor:O}}),e("span",{className:"glass-sticky-label shrink-0 font-mono text-[10px] font-normal tabular-nums text-ink/35",children:c}),e("span",{className:"ml-auto shrink-0 text-ink/40",children:r?e(B,{size:T?14:12}):e(se,{size:T?14:12})})]}),!h&&e("div",{className:`flex shrink-0 items-center gap-0.5 ${T?"pr-1":"pr-[3px]"}`,children:[e("button",{type:"button",title:"New Session","aria-label":`New session in ${t.name}`,onClick:(D)=>{D.stopPropagation(),w()},className:`flex items-center justify-center rounded text-ink/40 transition-colors cursor-pointer hover:bg-ink/10 hover:text-ink ${T?"h-7 w-7":"h-[22px] w-[22px]"}`,children:e(P,{size:T?15:12})}),e("div",{className:"relative flex items-center",children:[e("button",{ref:v,type:"button",title:`Options for ${t.name}`,"aria-label":`Options for ${t.name}`,"aria-haspopup":"menu","aria-expanded":g,onClick:(D)=>{if(D.stopPropagation(),v.current)L(Bt(v.current));y()},className:`flex items-center justify-center rounded text-ink/40 transition-colors cursor-pointer hover:bg-ink/10 hover:text-ink ${T?"h-7 w-7":"h-[22px] w-[22px]"}`,children:e(Ee,{size:T?15:12})}),e(Rt,{anchor:g&&C?A:null,align:"end",ariaLabel:`Options for ${t.name}`,className:"glass-popover w-44 rounded-md border border-ink/15 bg-paper py-1 text-xs shadow-lg",onClose:k,children:C})]})]})]})}function dn({hiddenCount:t,canShowLess:r,onShowMore:l,onShowLess:c}){if(t<=0&&!r)return null;return e("div",{className:"flex items-center gap-1 pl-6",children:[t>0&&e("button",{type:"button",onClick:l,className:"min-w-0 truncate rounded-md px-1 py-1 text-[11px] text-ink/45 transition-colors cursor-pointer hover:bg-ink/[0.04] hover:text-ink/80",children:[e(B,{size:11,className:"mr-1 inline align-[-2px]"}),t," more"]}),r&&e("button",{type:"button",onClick:c,className:"ml-auto shrink-0 rounded-md px-1 py-1 text-[11px] text-ink/45 transition-colors cursor-pointer hover:bg-ink/[0.04] hover:text-ink/80",children:[e(ct,{size:11,className:"mr-1 inline align-[-2px]"}),"Less"]})]})}function un({folder:t,activeSessionId:r,sessionStatus:l,showArchived:c,forceExpanded:m=!1,density:h="compact",batch:g,onSelectSession:y,onNewSessionForFolder:k,onNewWorktreeSession:w,onToast:C,onStartSessionSelection:T,onCancelWait:R}){let[O,v]=n(t.isExpanded||!1),[A,L]=n(!1),[F,_]=n(!1),{visibleCount:D,showMore:M,showLess:q,canShowLess:ee}=js(),[X]=le(),re=X.get("subagent"),ae=X.get("sessionId"),{expandedSessionIds:Y,toggleSession:V}=Ns(),{refresh:me,runStartedAtMap:W}=tt(),be=pt(),{confirmDelete:fe,requestDelete:de,cancelDelete:J,handlePin:ke,handleDelete:ve,handleArchive:te,handleRename:oe,handleRenameWithAi:Q,handleOpenFolder:ye}=qs(t,me,C),ie=zo();o(()=>{if(typeof t.isExpanded==="boolean")v(t.isExpanded)},[t.isExpanded]);let ge=()=>{L(!1),J()},Ke=()=>{let z=!O;if(v(z),typeof t.id!=="number")return;be.submit({isExpanded:String(z)},{method:"POST",action:`/api/folders/${t.id}/toggle`})},Te=t.sessions.filter((z)=>c?z.is_archived===1:z.is_archived!==1),{folderCheckbox:Re,sessionCheckboxes:Ce,folderSummary:xe,toggleFolderSelection:Xe,rendered:je,hiddenCount:H}=Zs({batch:g,folder:t,sessions:Te,showArchived:c,visibleCount:D,activeSessionId:r,sessionStatus:l}),j=Xo(je),G=m||O||Ce,Ie=(z,we)=>{let ue=String(z.id),mt=r===null?z.is_active===1:String(r)===ue,zn=mt&&ae===ue&&Boolean(re),Ze=_t(ue);return e(an,{sessionId:z.id,title:z.title,harness:z.harness,folderId:z.folder_id,density:h,isActive:mt&&!zn,isArchived:z.is_archived===1,status:l[ue],awaitingInput:Boolean(z.awaitingInput),timeAgo:Ws(z.updated_at??z.created_at),timeTitle:Zo(z.updated_at??z.created_at),runStartedAt:l[ue]==="stream"?W[ue]:void 0,worktree:z.worktree,waitingFor:z.waitingFor?{title:z.waitingFor.title}:void 0,expandable:we.expandable,isChild:we.isChild,isExpanded:we.isExpanded,onToggleExpand:we.onToggleExpand,onClick:()=>y(z.id),onArchive:()=>te(z),onDelete:Ze?void 0:()=>ie.requestDelete(z),onRename:Ze?void 0:(Hn)=>void oe(z,Hn),onRenameWithAi:Ze?void 0:()=>void Q(z),onCancelWait:z.waitingFor?()=>R?.(z.waitingFor.waitId):void 0,selectable:Ce,selected:Boolean(g?.selected.includes(ue)),onToggleSelect:g?()=>g.toggle(ue):void 0})},Wn=(z)=>Js(z,j.childrenOf,Y,V),dt=Boolean(w&&t.project_path);return e("div",{className:"space-y-0.5",children:[e(cn,{folder:t,isOpen:G,onToggleFolder:Ke,sessionCount:Te.length,checkbox:Re&&xe?{checked:xe.all,indeterminate:xe.some,label:`Select ${t.name}`,onChange:Xe}:null,batchActive:Boolean(g),showMenu:A,onToggleMenu:()=>L((z)=>!z),onCloseMenu:ge,onNewSession:()=>k(t.id),touch:h==="touch",menu:e(Ys,{variant:"desktop",isPinned:t.isPinned,onOpenFolder:ye?()=>{ye(),L(!1)}:void 0,onSelectSessions:T?()=>{L(!1),T(t.id)}:void 0,onNewWorktree:dt?()=>{L(!1),_(!0)}:void 0,confirmDelete:fe,onPin:()=>{ke(),L(!1)},onDelete:()=>{ve(),L(!1)},onRequestDelete:de,onCancelDelete:J})}),G&&e("div",{className:"space-y-0.5",children:[j.roots.map((z)=>{let we=String(z.id),ue=Wn(z);return e("div",{className:"space-y-0.5",children:[Ie(z,ue),ue.isExpanded&&e(Li,{parentId:we,hasSubagents:Boolean(z.hasSubagents),childrenOf:j.childrenOf,expandedIds:Y,onToggle:V,activeSessionId:r===null?null:String(r),renderSession:Ie,style:rn(h==="touch")})]},z.id)}),!Ce&&e(dn,{hiddenCount:H,canShowLess:ee,onShowMore:M,onShowLess:q}),Te.length===0&&e("div",{className:"px-1 py-1 pl-6 text-[11px] italic text-ink/40",children:c?"No archived sessions.":"No sessions."})]}),e(Uo,{session:ie.pending,isDeleting:ie.isDeleting,error:ie.error,onClose:ie.cancelDelete,onConfirm:()=>void ie.confirmDelete()}),dt&&e(Ho,{isOpen:F,onClose:()=>_(!1),root:t.project_path??null,folderId:t.id,folderName:t.name,onCreated:(z)=>{_(!1),w?.(t.id,z.path)}})]})}var Bo=[3,2];function mn({touch:t=!1}){return e("div",{className:"space-y-3","aria-hidden":"true",children:Bo.map((r,l)=>e("div",{className:"space-y-0.5",children:[e("div",{className:`flex items-center gap-2 px-1 ${t?"h-8":"h-[26px]"}`,children:[e("span",{className:`animate-pulse rounded-sm bg-ink/10 ${t?"h-[18px] w-[18px]":"h-4 w-4"}`}),e("span",{className:"h-3 w-24 animate-pulse rounded bg-ink/10"})]}),Array.from({length:r},(c,m)=>e("div",{className:`flex items-center gap-2 pl-1 pr-2 ${t?"h-8":"h-[31px]"}`,children:[e("span",{className:`shrink-0 animate-pulse rounded-full bg-ink/10 ${t?"h-[18px] w-[18px]":"h-4 w-4"}`}),e("span",{className:"h-3 animate-pulse rounded bg-ink/10",style:{width:`${58-m%3*12}%`}})]},m))]},l))})}function fn(t,r){if(t.awaitingInput)return!0;if(t.waitingFor)return!0;return r==="stream"}function hn(t,{focus:r,statusOf:l}){if(r==="all")return t;return t.map((c)=>({...c,sessions:c.sessions.filter((m)=>fn(m,l(String(m.id))))})).filter((c)=>c.sessions.length>0)}function bn(t,r){let l=0;for(let c of t)for(let m of c.sessions)if(fn(m,r(String(m.id))))l+=1;return l}function Pu({className:t="",folders:r,initializing:l,failed:c,activeSessionId:m,sessionStatus:h,searchQuery:g,onSearchChange:y,showArchived:k,onToggleArchived:w,sortOption:C,optionsOpen:T,onToggleOptions:R,onCloseOptions:O,onSortChange:v,harnessFilter:A,onHarnessFilterChange:L,harnessOptions:F,onRefresh:_,refreshing:D,scheduledCount:M,onNewSession:q,onNewWorkspace:ee,onScheduler:X,onSelectSession:re,onNewSessionForFolder:ae,onNewWorktreeSession:Y,onToast:V,onCancelWait:me,batch:W,onSelectWorkspaces:be,onStartSessionSelection:fe,touch:de=!1}){let[J,ke]=n("all"),ve=u(()=>bn(r,(Q)=>h[Q]),[r,h]),te=u(()=>hn(r,{focus:J,statusOf:(Q)=>h[Q]}),[r,J,h]),oe=Boolean(W);return e("div",{className:`flex flex-col ${t}`,children:[e(Jt,{value:g,onChange:y,touch:de}),e(en,{focus:J,onFocusChange:ke,runningCount:ve,showArchived:k,onToggleArchived:w,harnessFilter:A,onHarnessFilterChange:L,harnessOptions:F,selecting:oe,onToggleSelect:be}),e(nn,{onNewSession:q,onNewWorkspace:ee,onScheduler:X,scheduledCount:M,onRefresh:_,refreshing:D,sortOption:C,optionsOpen:T,onToggleOptions:R,onCloseOptions:O,onSortChange:v,touch:de}),e("div",{className:"mt-1 flex-1 scrollbar-overlay-container pl-2 session-list-gutter pb-3",children:c?e(Xs,{touch:de,onRetry:_,refreshing:D}):l?e(mn,{touch:de}):te.length===0?e("div",{className:"px-1 py-8 text-center text-[11px] leading-relaxed text-muted",children:J==="running"?"Nothing is running right now.":g?"No workspace or chat matches that search.":A?`No chats on ${la(A)}.`:"No workspaces yet."}):e("div",{className:"space-y-3",children:te.map((Q)=>e(un,{folder:Q,activeSessionId:m,sessionStatus:h,showArchived:k,forceExpanded:g.trim().length>0,density:de?"touch":"compact",batch:W,onSelectSession:re,onNewSessionForFolder:ae,onNewWorktreeSession:Y,onToast:V,onStartSessionSelection:fe,onCancelWait:me},Q.id))})})]})}function Lo(t){if(!t)return Number.NaN;let r=Date.parse(t);return Number.isFinite(r)?r:Number.NaN}function xn(t){let r=Number.NEGATIVE_INFINITY;for(let l of t.sessions??[]){let c=Lo(l.updated_at??l.created_at);if(c>r)r=c}return r}function Sn(t){let r=Number.NEGATIVE_INFINITY;for(let l of t.sessions??[]){let c=Number(l.id);if(Number.isFinite(c)&&c>r)r=c}return r}function Se(t){let r=Number(t.id);return Number.isFinite(r)?r:Number.NEGATIVE_INFINITY}function We(t,r){if(t===r)return 0;return t>r?-1:1}function kn(t,r){if(t===r)return 0;return t>r?1:-1}function Mo(t,r,l){let c=Boolean(t.isPinned),m=Boolean(r.isPinned);if(c!==m)return c?-1:1;switch(l){case"Z-A":{let h=r.name.localeCompare(t.name);return h!==0?h:kn(Se(t),Se(r))}case"LATEST_SESSION":{let h=We(xn(t),xn(r));if(h!==0)return h;let g=We(Sn(t),Sn(r));if(g!==0)return g;let y=We(Se(t),Se(r));return y!==0?y:t.name.localeCompare(r.name)}case"LATEST_ADDED":{let h=We(Se(t),Se(r));return h!==0?h:t.name.localeCompare(r.name)}case"A-Z":default:{let h=t.name.localeCompare(r.name);return h!==0?h:kn(Se(t),Se(r))}}}function vn(t,r){return[...t].sort((l,c)=>Mo(l,c,r))}var $o=["A-Z","Z-A","LATEST_SESSION","LATEST_ADDED"],yn="LATEST_SESSION";function wn(t){return typeof t==="string"&&$o.includes(t)}function Nn(t,r,l){if(r.length===0||t.length===0)return t;let c=new Set;for(let g of t)for(let y of g.sessions??[])c.add(String(y.id));let m=r.filter((g)=>!c.has(String(g.id)));if(m.length===0)return t;let h=t;for(let g of m){let y=Cn(h,g,l);if(!y)continue;let k=new Date(g.createdAt).toISOString(),w={id:g.id,folder_id:y.id,title:g.title??l.titleFor?.(String(g.id))??vf(g.id),created_at:k,updated_at:k,...g.parentSessionId?{parentSessionId:g.parentSessionId}:{},...g.harness?{harness:g.harness}:{},...g.waiting?{waitingFor:{waitId:g.waiting.waitId,sessionId:g.waiting.dependsOn,title:g.waiting.dependsOnTitle}}:{}};h=h.map((C)=>C.id===y.id?{...C,isExpanded:!0,sessions:[w,...C.sessions??[]]}:C)}return h}function Tn(t,r,l){if(r.length===0||t.length===0)return[];let c=new Set;for(let m of r){let h=Cn(t,m,l);if(h)c.add(String(h.id))}return[...c]}function Cn(t,r,l){if(r.folderId!==null&&r.folderId!==void 0){let c=t.find((m)=>String(m.id)===String(r.folderId));if(c)return c}if(l.activeId){let c=t.find((m)=>(m.sessions??[]).some((h)=>String(h.id)===String(l.activeId)));if(c)return c}if(l.urlFolderId){let c=t.find((m)=>String(m.id)===String(l.urlFolderId));if(c)return c}return t[0]}function In(t,r,l){if(!r.trim())return t;let c=r.toLowerCase(),m=(h)=>h.title.toLowerCase().includes(c)||String(h.id).toLowerCase().includes(c);if(l)return t.filter((h)=>{let g=h.name.toLowerCase().includes(c),y=h.sessions?.some(m);return g||y}).map((h)=>{let g=h.sessions?.filter((y)=>h.name.toLowerCase().includes(c)||m(y));return{...h,sessions:g,isExpanded:!0}});return t.map((h)=>{let g=h.name.toLowerCase().includes(c),y=(h.sessions||[]).filter(m);if(g)return h;return{...h,sessions:y}}).filter((h)=>h.sessions&&h.sessions.length>0)}async function sp(t,r){try{return(await fetch(`/api/folders/${encodeURIComponent(String(t))}/toggle`,{method:"POST",body:new URLSearchParams({isExpanded:String(r)})})).ok}catch(l){return console.error("Failed to save workspace expansion:",l),!1}}function On(t,r){return t.find((l)=>(l.sessions??[]).some((c)=>String(c.id)===r))}function Rn(t){let{folders:r,initializing:l,runningIds:c,pendingEntries:m,activeId:h,urlFolderId:g}=t,y=u(()=>{let w=new Set;for(let C of c){let T=On(r,C);if(T)w.add(String(T.id))}return w},[r,c]),k=i({running:new Set,pending:new Set});return o(()=>{if(l||r.length===0)return;let w=k.current,C=new Set,T=new Set,R=new Set;for(let v of c){if(w.running.has(v)){C.add(v);continue}let A=On(r,v);if(!A)continue;C.add(v),R.add(String(A.id))}let O={activeId:h,urlFolderId:g};for(let v of m){let A=String(v.id);if(w.pending.has(A)){T.add(A);continue}T.add(A);for(let L of Tn(r,[v],O))R.add(L)}w.running=C,w.pending=T;for(let v of R){let A=r.find((L)=>String(L.id)===v);if(!A||A.isExpanded)continue;sp(v,!0)}},[l,r,c,m,h,g]),y}function An(t){let r=new Map;for(let l of t)for(let c of l.sessions){if(!c.harness)continue;r.set(c.harness,(r.get(c.harness)??0)+1)}return[...r].map(([l,c])=>({harness:l,label:la(l),count:c})).sort((l,c)=>c.count-l.count||l.label.localeCompare(c.label))}function Pn(t,r){if(!r)return t;return t.map((l)=>({...l,sessions:l.sessions.filter((c)=>c.harness===r)})).filter((l)=>l.sessions.length>0)}var Wo=200;function Ou(t={},r={}){let{expandSearchMatches:l=!1,onSelectSession:c,onAfterSelect:m}=r,{folders:h,initializing:g,failed:y,refresh:k,refreshNow:w,refreshing:C,isRefreshing:T,markSeen:R,hasSeen:O,streamStatusMap:v,titleHint:A}=tt(),[L,F]=le(),_=L.get("sessionId"),D=L.get("folderId"),M=_?Number.isNaN(Number(_))?_:Number(_):null,q=i(k);q.current=k;let ee=a(()=>q.current(),[]),[X,re]=n(""),[ae,Y]=n(!1),[V,me]=n(null),[W,be]=n(!1),[fe,de]=n(()=>wn(t.omp_sidebar_sort)?t.omp_sidebar_sort:yn),J=i(null),ke=a((H)=>{if(J.current)clearTimeout(J.current);J.current=setTimeout(()=>{ut("omp_sidebar_sort",H)},Wo)},[]);o(()=>()=>{if(J.current)clearTimeout(J.current)},[]);let ve=(H)=>{de(H),be(!1),ke(H)},te=v;I0(te,M,ee,O);let oe=kf(),{prompts:Q,loaded:ye}=Xc(),ie=u(()=>new Set(Object.entries(te).filter(([,H])=>H==="stream").map(([H])=>H)),[te]),ge=Rn({folders:h,initializing:g,runningIds:ie,pendingEntries:oe,activeId:_,urlFolderId:D});o(()=>{if(!_||g)return;if(h.some((H)=>(H.sessions??[]).some((j)=>String(j.id)===_)))return;_0(_,D,te[_]==="stream")},[_,h,g,D,te]),o(()=>{if(g||!ye)return;for(let H of oe){let j=String(H.id),G=Q.find((Ie)=>Ie.pendingId===j&&Ie.status==="waiting");if(!G||H.waiting?.waitId===G.id)continue;Sf(j,{waitId:G.id,dependsOn:G.dependsOn,dependsOnTitle:G.dependsOnTitle})}},[oe,Q,ye,g]);let[Ke,Te]=n(0),Re=oe.map((H)=>String(H.id)).join(`
|
|
2
|
-
`);o(()=>{let H=()=>Te((G)=>G+1),j=Re.split(`
|
|
3
|
-
`).filter(Boolean).flatMap((G)=>[sa(G,Ts,H),sa(G,Ds,H)]);return()=>{for(let G of j)G()}},[Re]),o(()=>{if(g)return;let H=new Set;for(let j of h)for(let G of j.sessions??[])H.add(String(G.id));S0({listed:H,running:ie,activeId:_})},[h,g,ie,_,Ke]);let Ce=(H)=>{if(R(H),c)c(H);else F((j)=>{let G=Lt(j);if(G.set("sessionId",H.toString()),G.has("subagent"))G.delete("subagent");return G},{replace:!0});m?.()},xe=u(()=>Nn(h,oe,{activeId:_,urlFolderId:D,titleFor:A}),[h,oe,_,D,A]),Xe=u(()=>An(xe),[xe]),je=u(()=>{let H=In(xe,X,l);if(H=Pn(H,V),ge.size>0)H=H.map((j)=>ge.has(String(j.id))?{...j,isExpanded:!0}:j);return vn(H,fe)},[xe,X,V,fe,l,ge]);return{folders:h,initializing:g,failed:y,refresh:ee,refreshNow:w,refreshing:C,isRefreshing:T,activeSessionId:M,sessionParam:_,searchQuery:X,setSearchQuery:re,showArchived:ae,setShowArchived:Y,optionsOpen:W,setOptionsOpen:be,sortOption:fe,handleSortChange:ve,harnessFilter:V,setHarnessFilter:me,harnessOptions:Xe,processedFolders:je,sessionStatus:te,handleSelectSession:Ce}}function $u({onNotice:t}={}){let{prompts:r}=Xc(),[,l]=le(),c=i(t);c.current=t;let m=i(new Set);o(()=>{let h=new URLSearchParams(window.location.search).get("sessionId");for(let g of r){let{pendingId:y,targetSessionId:k}=g,w=y?Q0(y):null,C=Boolean(y)&&(Boolean(w)||h===y),T=Boolean(k)&&h===k;if(!y&&!k)continue;let R=`${g.id}:${g.status}`;if(m.current.has(R))continue;if(g.status==="dispatched"&&g.sessionId){if(m.current.add(R),y&&C)Zc(y,g.sessionId,g.folderId),l((O)=>{if(O.get("sessionId")!==y)return O;let v=Lt(O);return v.set("sessionId",g.sessionId),v},{replace:!0}),c.current?.("Waiting finished — your prompt is now running in a new session.","success");else if(k&&T)c.current?.("Waiting finished — your prompt is now running in this chat.","success");continue}if(g.status==="error"){if(m.current.add(R),!C&&!T)continue;if(Pd(g),y)Fd(y);c.current?.(`The prompt you held was not sent: ${g.error??"the dispatch failed."} Your draft is back in the composer.`,"error");continue}if(g.status==="cancelled"){if(m.current.add(R),!C&&!T)continue;if(Pd(g),y)Fd(y)}}},[r,l])}function En(){let[t,r]=n(null),[l,c]=n(null),[m,h]=n([]),g=a((R,O)=>{r(R),c(R==="session"?O??null:null),h([])},[]),y=a(()=>{r(null),c(null),h([])},[]),k=a((R)=>{h((O)=>Gt(O,R))},[]),w=a((R)=>{h((O)=>[...new Set([...O,...R])])},[]),C=a((R)=>{h((O)=>{let v=new Set(R);return O.filter((A)=>!v.has(A))})},[]),T=a((R)=>Kt(m,R),[m]);return u(()=>({mode:t,scopeFolderId:l,selected:m,begin:g,end:y,toggle:k,selectAllOf:w,unselectAllOf:C,summaryOf:T}),[t,l,m,g,y,k,w,C,T])}var ze=500,Dn=200;function Ue(t,r){if(!Number.isSafeInteger(r)||r<1)throw Error(`chunkIds needs a positive integer limit, got ${r}`);let l=[];for(let c=0;c<t.length;c+=r)l.push(t.slice(c,c+r));return l}var Ge={removed:[],refused:[]};async function Ko(t,r){try{let l=await fetch(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ids:r})}),c=await l.json().catch(()=>null);if(!l.ok)return{...Ge,error:c?.error||`Could not delete (HTTP ${l.status}).`};return{removed:Array.isArray(c?.removed)?c.removed:[],refused:Array.isArray(c?.refused)?c.refused:[]}}catch(l){return{...Ge,error:l instanceof Error?l.message:"Could not reach the server."}}}async function Fn(t,r,l,c){let m=[],h=[],g,y=0;for(let k of Ue(r,l)){let w=await Ko(t,k);m.push(...w.removed),h.push(...w.refused),g??=w.error,y+=k.length,c?.({done:y,total:r.length})}return{removed:m,refused:h,...g?{error:g}:{}}}function _n(t,r){if(t.length===0)return Promise.resolve({...Ge});return Fn("/api/sessions/batch-delete",t,ze,r)}function Bn(t,r){if(t.length===0)return Promise.resolve({...Ge});return Fn("/api/folders/batch-delete",t,Dn,r)}function Ln(t){let[r,l]=n([]),[c,m]=n(!1),[h,g]=n(null),[y,k]=n(null),[w,C]=le(),T=a((v)=>{g(null),k(null),l([...v])},[]),R=a(()=>{g(null),k(null),l([])},[]),O=a(async(v)=>{if(r.length===0||c)return null;m(!0),g(null);let A=r;k({done:0,total:A.length});let L=(_)=>k(_),F=v==="workspace"?await Bn(A,L):await _n(A,L);if(v==="session"&&F.removed.length>0){for(let D of F.removed)xm(D);let _=w.get("sessionId");if(_&&F.removed.includes(_))C((D)=>{let M=Lt(D);return M.delete("sessionId"),M.delete("subagent"),M},{replace:!0})}if(F.removed.length>0)t();if(g(F),k(null),m(!1),F.removed.length===A.length)l([]);return F},[r,c,w,C,t]);return{pending:r,isDeleting:c,outcome:h,progress:y,request:T,cancel:R,confirm:O}}var it={archived:[],refused:[]};async function Yo(t,r){try{let l=await fetch(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ids:r})}),c=await l.json().catch(()=>null);if(!l.ok)return{...it,error:c?.error||`Could not archive (HTTP ${l.status}).`};return{archived:Array.isArray(c?.archived)?c.archived:[],refused:Array.isArray(c?.refused)?c.refused:[]}}catch(l){return{...it,error:l instanceof Error?l.message:"Could not reach the server."}}}async function Mn(t){if(t.length===0)return{...it};let r=[],l=[],c;for(let m of Ue(t,ze)){let h=await Yo("/api/sessions/batch-archive",m);r.push(...h.archived),l.push(...h.refused),c??=h.error}return{archived:r,refused:l,...c?{error:c}:{}}}function zu(t){if(t.error)return{message:t.error,tone:"error"};let r=t.archived.length,l=t.refused.length;if(r===0&&l===0)return null;if(l===0)return{message:`Archived ${r} ${r===1?"session":"sessions"}.`,tone:"success"};if(r===0)return{message:`${l} ${l===1?"session":"sessions"} could not be archived.`,tone:"error"};return{message:`Archived ${r} ${r===1?"session":"sessions"}; ${l} refused.`,tone:"warning"}}function $n(t){let[r,l]=n(!1),c=a(async(m)=>{if(m.length===0||r)return null;l(!0);let h=await Mn(m);if(h.archived.length>0)t();return l(!1),h},[r,t]);return{isArchiving:r,archive:c}}function Uu(t,r,l){let c=En(),m=Ln(l),h=$n(l),g=c.scopeFolderId===null?null:t.find((T)=>T.id===c.scopeFolderId)??null,y=c.mode==="workspace"?t.map((T)=>String(T.id)):c.mode==="session"?Be(g?.sessions??[],r):[],k=jt(c.selected,y),w=c.mode?{mode:c.mode,scopeFolderId:c.scopeFolderId,selected:c.selected,toggle:c.toggle,selectAllOf:c.selectAllOf,unselectAllOf:c.unselectAllOf,summaryOf:c.summaryOf}:void 0,C=a(()=>{if(c.mode==="workspace")c.end();else c.begin("workspace")},[c]);return{selection:c,deleteRun:m,archiveRun:h,binding:w,scopeFolder:g,available:y,selected:k,toggleWorkspaceSelection:C}}function Gu({mode:t,count:r,total:l,busy:c,archiving:m=!1,scopeLabel:h,onSelectAll:g,onUnselectAll:y,onDelete:k,onArchive:w,onCancel:C,drawer:T=!1}){let R=t==="workspace"?"workspace":"session",O=r===1?R:`${R}s`,v=t==="session"&&h?` in ${h}`:"",A=c||m,L=A||r===0,F=t==="session"&&Boolean(w),_="min-w-0 w-full h-7 flex items-center justify-center gap-1 px-2 rounded border text-[11px] font-medium transition-colors cursor-pointer disabled:opacity-40",D="border-ink/20 text-ink hover:bg-ink/5";return e("div",{"data-testid":"batch-action-bar",className:`border-t border-ink/15 bg-paper ${T?"px-3":"px-2.5"} py-2 flex flex-col gap-1.5 flex-shrink-0`,children:[e("div",{className:"flex items-center justify-between gap-2 text-[11px]",children:[e("span",{className:"min-w-0 truncate text-ink/70",children:[e("span",{className:"font-semibold text-ink",children:r})," ","of ",l," ",l===1?R:`${R}s`," selected",v]}),e("button",{type:"button",onClick:C,disabled:A,title:"Cancel selection","aria-label":"Cancel selection",className:"shrink-0 w-5 h-5 flex items-center justify-center rounded text-ink/50 hover:text-ink hover:bg-ink/10 transition-colors cursor-pointer disabled:opacity-50",children:e(b,{size:13})})]}),e("div",{className:`grid gap-1.5 ${F?"grid-cols-2":"grid-cols-3"}`,children:[e("button",{type:"button",onClick:g,disabled:A||l===0||r===l,className:"min-w-0 w-full h-7 flex items-center justify-center gap-1 px-2 rounded border text-[11px] font-medium transition-colors cursor-pointer disabled:opacity-40 border-ink/20 text-ink hover:bg-ink/5",children:[e(ft,{size:12,className:"shrink-0"}),e("span",{className:"truncate",children:"Select all"})]}),e("button",{type:"button",onClick:y,disabled:A||r===0,className:"min-w-0 w-full h-7 flex items-center justify-center gap-1 px-2 rounded border text-[11px] font-medium transition-colors cursor-pointer disabled:opacity-40 border-ink/20 text-ink hover:bg-ink/5",children:e("span",{className:"truncate",children:"Unselect all"})}),F&&e("button",{type:"button",onClick:w,disabled:L,className:"min-w-0 w-full h-7 flex items-center justify-center gap-1 px-2 rounded border text-[11px] font-medium transition-colors cursor-pointer disabled:opacity-40 border-ink/20 text-ink hover:bg-ink/5",children:m?e(d,{children:[e(p,{size:12,className:"animate-spin shrink-0"}),e("span",{className:"truncate",children:"Archiving…"})]}):e(d,{children:[e(lt,{size:12,className:"shrink-0"}),e("span",{className:"truncate",children:["Archive ",r>0?`${r} ${O}`:O]})]})}),e("button",{type:"button",onClick:k,disabled:L,className:"min-w-0 w-full h-7 flex items-center justify-center gap-1 px-2 rounded bg-error text-canvas text-[11px] font-semibold hover:opacity-90 transition-opacity cursor-pointer disabled:opacity-40",children:c?e(d,{children:[e(p,{size:12,className:"animate-spin shrink-0"}),e("span",{className:"truncate",children:"Deleting…"})]}):e(d,{children:[e(N,{size:12,className:"shrink-0"}),e("span",{className:"truncate",children:["Delete ",r>0?`${r} ${O}`:O]})]})})]})]})}function ju({mode:t,count:r,scopeLabel:l,isDeleting:c,progress:m=null,outcome:h,onClose:g,onConfirm:y}){if(o(()=>{let A=(L)=>{if(L.key!=="Escape"||c)return;L.preventDefault(),g()};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[g,c]),r===0)return null;let k=t==="session",w=k?"session":"workspace",C=r===1?w:`${w}s`,T=k&&l?` in ${l}`:"",R=!c&&h!==null,O=h?.removed.length??0,v=h?.refused??[];return e(Z,{onClose:c?()=>{}:g,zClass:"z-[70]",maxWidthClass:"max-w-[460px]",header:e("div",{className:"flex items-center gap-3 min-w-0",children:[e(N,{size:16,className:"text-error shrink-0"}),e("div",{className:"min-w-0",children:[e("h2",{className:"text-sm font-semibold text-ink",children:["Delete ",r," ",C,"?"]}),e("p",{className:"text-[11px] text-ink/50 truncate",children:T?T.trim():"Selected rows"})]})]}),footer:e("div",{className:"flex items-center justify-end gap-2 px-5 py-3.5 border-t border-ink/10",children:[e("button",{type:"button",onClick:g,disabled:c,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-50",children:R?"Close":"Cancel"}),e("button",{type:"button",onClick:y,disabled:c||R,className:"px-3.5 py-1.5 rounded-md bg-error text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer disabled:opacity-50 flex items-center gap-1.5",children:c?e(d,{children:[e(p,{size:13,className:"animate-spin"}),e("span",{children:"Deleting…"})]}):e(d,{children:[e(N,{size:13}),e("span",{children:["Delete ",r," ",C]})]})})]}),children:e("div",{className:"px-5 py-4 space-y-3",children:[c&&e("div",{className:"space-y-1.5","data-testid":"batch-delete-progress",children:[e("div",{className:"flex items-center justify-between text-[11px] text-ink/60",children:[e("span",{children:["Deleting ",m?.done??0," of ",r,"…"]}),e("span",{children:[Math.round((m?.done??0)/Math.max(1,r)*100),"%"]})]}),e(Tf,{percent:(m?.done??0)/Math.max(1,r)*100,label:`Deleting ${r} ${C}`,tone:"error"})]}),k?e("ul",{className:"text-[11.5px] leading-relaxed text-ink/70 space-y-1.5",children:[e("li",{children:["Each transcript is removed from"," ",e("span",{className:"font-mono text-ink",children:"~/.omp/agent/sessions"})," — the conversations are gone from the sidebar and from oh-my-pi."]}),e("li",{children:"Chats that ran on another agent (opencode, dsh, …) are removed from that agent's own history too; one the agent cannot delete is refused, not silently forgotten."}),e("li",{children:"Their subagent transcripts, side questions, queued messages and saved layout go too."}),e("li",{children:"A session that is mid-run is refused rather than interrupted; stop it and delete again."})]}):e("ul",{className:"text-[11.5px] leading-relaxed text-ink/70 space-y-1.5",children:[e("li",{children:"The workspaces are removed from this sidebar."}),e("li",{children:["Their directories and every transcript on disk are left alone — re-add a workspace with"," ",e("span",{className:"font-mono text-ink",children:"New Workspace"})," when you want it back."]})]}),h?.error?e("div",{className:"flex items-start gap-2 px-3 py-2 rounded-md border border-error/30 bg-error/5 text-[11px] text-ink/75",children:[e(I,{size:13,className:"mt-0.5 shrink-0 text-error"}),e("span",{children:h.error})]}):R?e("div",{className:"flex items-start gap-2 px-3 py-2 rounded-md border border-ink/15 bg-ink/5 text-[11px] text-ink/75",children:e("span",{children:["Removed ",O," ",O===1?w:`${w}s`,v.length>0?`, ${v.length} refused:`:"."]})}):e("div",{className:"flex items-start gap-2 px-3 py-2 rounded-md border border-error/30 bg-error/5 text-[11px] text-ink/75",children:[e(I,{size:13,className:"mt-0.5 shrink-0 text-error"}),e("span",{children:k?"This cannot be undone from the UI. Archive a session instead to keep its transcript.":"This removes the sidebar entry only. The folder itself is not deleted."})]}),v.length>0&&e("ul",{className:"max-h-40 overflow-y-auto scrollbar-overlay-container space-y-1 text-[11px] text-ink/70",children:v.map((A)=>e("li",{className:"flex items-start gap-1.5",children:[e("span",{className:"font-mono text-ink/50 shrink-0 max-w-[7rem] truncate",title:A.id,children:A.id}),e("span",{className:"min-w-0",children:A.error})]},A.id))})]})})}
|
|
4
|
-
export{zs,$a,$r,Lu,Mu,Jo,Fu,Us,op,CA,EA,ip,BA,Gs,js,qs,zr,Hs,Ws,Zo,Ks,Vs,Ys,Js,Li,Xo,Zs,Xs,Pu,sp,Ou,$u,zu,Uu,Gu,ju};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{n,Q,me,ys,tA}from"./index-pv4z2mp2.js";var r={left:tA.left,right:tA.right},a="omp:mobile-panel-nav-changed";function s(e,t){return ys(Q(r[e],t))}function ig(e,t){if(typeof window>"u")return;window.dispatchEvent(new CustomEvent(a,{detail:{side:e,style:ys(t)}}))}function Zd(e){let[t,i]=n(()=>s(e));return me(a,(l)=>{let o=l.detail;if(o?.side!==e)return;i(ys(o.style))}),t}
|
|
2
|
-
export{ig,Zd};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n,o,K,i,a,Oe,Le,Be,oe,e,s,p,I,B,Ye,gi,tr,b,nr,Ge,xe,T,Ze,ki,pe,Z,dt,Mo,Oo,k0,R0,Lf,Ko,Ti,Yf,pA}from"./index-pv4z2mp2.js";import"./index-gg910gpv.js";import{Qi}from"./index-yr3exz70.js";import"./index-zp40g8ah.js";import{bA,yu,Ps,vu,ku,xu,wu,Cu,Eu,Bu,Iu,_u}from"./index-473hk8nb.js";var vt={name:"panel-right-close",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]]},ge=s(vt);var z=new Set,ae=new Set,ve=new Set;function he(){ve=new Set(z);for(let t of[...ae])t()}function ye(t){let r=new Set(t);if(r.size===z.size){let l=!0;for(let d of r)if(!z.has(d)){l=!1;break}if(l)return}z.clear();for(let l of r)z.add(l);he()}function Ce(t){let r=new Set(t),l=!1;for(let d of[...z])if(!r.has(d))z.delete(d),l=!0;if(l)he()}function Se(t){return z.has(t)}function ke(){return z.size>0}function ht(t){return ae.add(t),()=>{ae.delete(t)}}var yt=ht;function we(){return Oe(yt,()=>ve)}function Ee({x:t,y:r,rows:l,onAction:d,onClose:u}){let y=i(null),[m,c]=n({left:t,top:r});return K(()=>{let g=y.current;if(!g)return;let{width:S,height:v}=g.getBoundingClientRect();c({left:Math.min(t,Math.max(0,window.innerWidth-S-8)),top:Math.min(r,Math.max(0,window.innerHeight-v-8))})},[t,r,l.length]),oe(e("div",{className:"fixed inset-0 z-[70]",onClick:u,onContextMenu:(g)=>{g.preventDefault(),u()},children:e("div",{ref:y,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:`${m.left}px`,top:`${m.top}px`},onClick:(g)=>g.stopPropagation(),children:l.map((g)=>e("button",{type:"button",role:"menuitem",onClick:()=>{d(g.action),u()},className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 transition-colors cursor-pointer",children:g.label},g.action))})}),document.body)}var ee={rightFileId:null,fraction:0.5};function ne(t,r,l){if(t===null)return!1;if(t===r)return!1;return l.includes(t)}function Te(t,r){for(let l=r.length-1;l>=0;l-=1){let d=r[l];if(d!==t)return d}return null}function Ne(t,r){if(t.rightFileId===null)return t;if(t.rightFileId!==r)return t;return{...t,rightFileId:null}}function J(t){if(!Number.isFinite(t))return ee.fraction;return Math.max(0.2,Math.min(0.8,t))}function Me(t,r){if(typeof t!=="object"||t===null)return ee;let l=t,d=typeof l.fraction==="number"?J(l.fraction):ee.fraction,u=typeof l.rightFileId==="string"||typeof l.rightFileId==="number"?l.rightFileId:null;if(u===null||!r.includes(u))return{rightFileId:null,fraction:d};return{rightFileId:u,fraction:d}}function Pe({tab:t,openedFiles:r,dirtyIds:l,reopenable:d,activeFileId:u,splitRightFileId:y}){let m=r.filter((v)=>v.id!==t.id),c=r.filter((v)=>!l.has(v.id)),g=r.map((v)=>v.id);return[{action:"split-right",label:"Split right",enabled:ne(t.id,u,g)},{action:"unsplit",label:"Unsplit",enabled:y!==null},{action:"close",label:"Close",enabled:!0},{action:"close-others",label:"Close others",enabled:m.length>0},{action:"close-all",label:"Close all",enabled:r.length>0},{action:"close-saved",label:"Close saved",enabled:c.some((v)=>v.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:d>0}].filter((v)=>v.enabled)}function Y({onHide:t}){let r=Ko("toggleEditorPanel","Hide Editor Panel");return e("button",{type:"button",onClick:t,className:"p-1.5 mx-1 rounded transition-colors cursor-pointer text-ink/60 hover:bg-ink/10 hover:text-ink flex-shrink-0",title:r,"aria-label":r,children:e(ge,{size:14})})}function Re({openedFiles:t,activeFileId:r,onSelectFile:l,onCloseFile:d,missingIds:u,onCopyPath:y,onRevealInFiles:m,onReopenClosed:c,reopenableCount:g,onSplitTo:S,onUnsplit:v,splitRightFileId:x=null,onHide:D}){let N=we(),M=i(null),F=i(null),[P,R]=n(5),[O,A]=n(!1),[f,Q]=n(null);pe(F,()=>A(!1)),o(()=>{let h=new ResizeObserver((w)=>{for(let k of w){let q=k.contentRect.width,H=Math.max(1,Math.floor((q-60)/150));R(H)}});if(M.current)h.observe(M.current);return()=>h.disconnect()},[]);let U=Te(r,t.map((h)=>h.id)),j=[],G=[];if(t.length<=P)j=t;else{let h=t.findIndex((k)=>k.id===r),w=new Set;if(h!==-1&&r!==null)w.add(r);for(let k=t.length-1;k>=0;k--){if(w.size>=P)break;w.add(t[k].id)}j=t.filter((k)=>w.has(k.id)),G=t.filter((k)=>!w.has(k.id))}return e("div",{className:`${ki.desktop} flex bg-ink/10 w-full relative border-b border-ink/10`,ref:M,children:[e("div",{className:"flex overflow-hidden",children:j.map((h)=>{let w=h.id===r,k=Boolean(h.isDiff),q=k?nr(h.diffStatus||"M",h.diffStaged):null,H=Boolean(u?.has(h.id));return e("div",{onClick:()=>l(h.id),onContextMenu:(_)=>{_.preventDefault(),Q({tab:h,x:_.clientX,y:_.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 ${w?"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:H?`${h.path} — file no longer exists`:h.path,children:[k?e(gi,{size:14,className:w?"text-info flex-shrink-0":"text-info/70 flex-shrink-0"}):e(dt,{name:h.name,size:14,className:`flex-shrink-0${w||H?"":" opacity-60"}${H?" text-error":""}`}),e("span",{className:`text-xs font-mono truncate flex-1${H?" text-error line-through":""}`,children:h.name}),q&&e("span",{className:`px-1 text-[10px] font-mono font-bold rounded ${q.badgeBgClass}`,children:q.charStatus}),e(De,{dirty:N.has(h.id),active:w,label:`Close ${h.name}`,onClose:()=>d(h.id)})]},h.id)})}),f?e(Ee,{x:f.x,y:f.y,rows:Pe({tab:f.tab,openedFiles:t,dirtyIds:N,reopenable:g?.()??0,activeFileId:r,splitRightFileId:x}),onAction:(h)=>{let w=f.tab;switch(h){case"close":d(w.id);return;case"close-others":for(let k of[...t].reverse())if(k.id!==w.id)d(k.id);l(w.id);return;case"close-all":for(let k of[...t].reverse())d(k.id);return;case"close-saved":for(let k of[...t].reverse())if(!N.has(k.id))d(k.id);return;case"copy-path":y?.(w);return;case"reveal-in-files":m?.(w);return;case"reopen-closed":c?.();return;case"split-right":S?.(w.id);return;case"unsplit":v?.();return}},onClose:()=>Q(null)}):null,e("div",{className:"ml-auto flex items-center",children:[e("button",{type:"button",onClick:()=>x!==null?v?.():S?.(U),disabled:x===null&&U===null,"aria-pressed":x!==null,"aria-label":"Split editor",title:x!==null?"Close the split pane (the tab stays open)":U===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 ${x!==null?"bg-ink/10 text-ink":"text-ink/60 hover:bg-ink/10"}`,children:e(tr,{size:14})}),D&&e(Y,{onHide:D})]}),G.length>0&&e("div",{className:"relative flex items-center bg-ink/10",ref:F,children:[e("button",{className:`p-1.5 mx-1 rounded hover:bg-ink/10 text-ink/60 ${O?"bg-ink/10 text-ink":""}`,onClick:()=>A(!O),title:"More open files",children:e(B,{size:14})}),O&&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"}),G.map((h)=>{let w=Boolean(u?.has(h.id));return e("div",{onClick:()=>{l(h.id),A(!1)},className:"flex items-center space-x-2 px-3 py-1.5 hover:bg-ink/5 cursor-pointer group",children:[h.isDiff?e(gi,{size:14,className:"text-info/80"}):e(dt,{name:h.name,size:14,className:w?"text-error":"opacity-60"}),e("span",{className:`text-xs font-mono truncate flex-1 ${w?"text-error line-through":"text-ink/80"}`,children:h.name}),e(De,{dirty:N.has(h.id),active:!1,label:`Close ${h.name}`,onClose:()=>{if(d(h.id),G.length===1)A(!1)}})]},h.id)})]})]})]})}function De({dirty:t,active:r,label:l,onClose:d}){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:(u)=>{u.stopPropagation(),d()},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 Ie({pluginId:t,Component:r,sessionId:l,className:d="",onHide:u}){return e("div",{className:`flex flex-col h-full bg-canvas ${d}`,children:[u&&e("div",{className:"flex justify-end flex-shrink-0 border-b border-ink/10",children:e(Y,{onHide:u})}),e(Ze,{pluginId:t,children:e(r,{sessionId:l,workspacePath:null})})]})}function Ae({className:t="",onHide:r}){return e("div",{className:`relative flex flex-col h-full bg-canvas items-center justify-center text-muted ${t}`,children:[r&&e("div",{className:"absolute top-0 right-0 flex items-center",children:e(Y,{onHide:r})}),e(dt,{name:"placeholder.txt",size:48,className:"mb-4 opacity-20"}),e("p",{className:"font-mono text-sm",children:"Select a file to open"})]})}function Fe({searchReveal:t,revealMatch:r}){let l=i(r);l.current=r;let d=i(null);o(()=>{if(!t||d.current===t.request)return;d.current=t.request,l.current({query:t.request.query,options:t.request.options,line:t.request.line})},[t])}function Ke({openedFiles:t,dirtyKeys:r,activeFile:l,previewReady:d,setPreviewMode:u,sessionId:y}){o(()=>{let m=new Set(t.filter((c)=>!c.isDiff&&c.content===void 0).map((c)=>c.id));ye([...r].filter((c)=>m.has(c)))},[r,t]),o(()=>{if(!d)return;let m=l?.id;if(!l||m===void 0||m===null)return;if(!yu(Ps(l.name)))return;let c=xe(y,"editor.previewMode");if(c&&c[m]!==void 0)return;u((g)=>g[m]===void 0?{...g,[m]:!0}:g)},[d,l])}function ze({activeFile:t,externalChange:r,conflict:l,onReload:d,onKeepMine:u}){if(!t)return null;if(l)return e(Bu,{diskMtimeMs:l.diskMtimeMs,fileName:t.name,onReload:d,onKeepMine:u});if(r)return e(Eu,{fileName:t.name,onReload:d,onKeepMine:u});return null}async function He(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 d=await fetch("/api/fs/action",{method:"POST",body:l}),u=await d.json().catch(()=>null),y=typeof u?.error==="string"?u.error:null;if(d.status===409)return{status:"exists",reason:y??`${r} already exists.`};if(d.ok&&u?.success&&typeof u.path==="string")return{status:"written",path:u.path};return{status:"failed",reason:y??"The file could not be written."}}catch{return{status:"failed",reason:"The file could not be written."}}}function $e(t){let r=t.lastIndexOf(".");if(r<=0)return`${t} copy`;return`${t.slice(0,r)} copy${t.slice(r)}`}function Ue(t){let r=t.trim();if(!r)return!1;if(r==="."||r==="..")return!1;return!r.includes("/")&&!r.includes("\\")}function xt(t){let r=t.lastIndexOf("/");return r===-1?"":t.slice(0,r)}function qe({fileName:t,filePath:r,content:l,eol:d,root:u,repo:y,onSaved:m,onClose:c}){let[g,S]=n(()=>xt(r)),[v,x]=n(()=>$e(t)),[D,N]=n(!1),[M,F]=n(null),P=i(null);o(()=>{P.current?.focus(),P.current?.select()},[]);let R=Ue(v),O=async()=>{if(!R||D)return;N(!0),F(null);let f=await He({parent:g,name:v,content:l,eol:d,root:u,repo:y});if(N(!1),f.status==="written"){m({path:f.path});return}F(f.reason)},A=(f)=>{if(f.key==="Enter"){f.preventDefault(),O();return}if(f.key==="Escape")f.preventDefault(),c()};return e(Z,{onClose:c,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:c,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 O(),disabled:!R||D,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:[D?e(p,{size:12,className:"animate-spin"}):e(Ye,{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:g,onInput:(f)=>S(f.target.value),onKeyDown:A,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:P,value:v,onInput:(f)=>x(f.target.value),onKeyDown:A,"aria-label":"File name","aria-invalid":!R,className:`w-full bg-paper border rounded px-2 py-1 font-mono text-ink outline-none ${R?"border-ink/20 focus:border-ink/40":"border-error text-error"}`})]}),!R?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 _e(){o(()=>{let t=(r)=>{if(!ke())return;r.preventDefault(),r.returnValue=""};return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)},[])}function We({fileName:t,onAnswer:r}){return e(Z,{onClose:()=>r("cancel"),header:e("div",{className:"flex items-center gap-2",children:[e(I,{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 Ve({closeGuard:t,activeFile:r,saveMissingConfirm:l,onCancelSaveMissing:d,onConfirmSaveMissing:u}){if(t.pending)return e(We,{fileName:t.pending.name,onAnswer:t.answer});if(l&&r)return e(Iu,{fileName:r.name,filePath:r.path,onClose:d,onConfirm:u});return null}function Xe({className:t="",isMaximized:r,onKeyDownCapture:l,onFocusCapture:d,asSplitPane:u,tabs:y,activeFile:m,editor:c,externalChange:g,conflict:S,onReload:v,onKeepMine:x,body:D,saveAsOpen:N,onSaveAsClose:M,onSavedAs:F,closeGuard:P}){let R=r?"fixed inset-0 z-50 flex flex-col bg-canvas":`flex flex-col h-full bg-canvas ${t}`;return e("div",{className:R,onKeyDownCapture:l,onFocusCapture:d,children:[u?null:y,e(ze,{activeFile:m,externalChange:g,conflict:S,onReload:v,onKeepMine:x}),D,N&&m?e(qe,{fileName:m.name,filePath:m.path,content:c.content,eol:c.eol,root:m.root,repo:m.repo,onSaved:({path:O})=>F(O),onClose:M}):null,e(Ve,{closeGuard:P,activeFile:m,saveMissingConfirm:c.saveMissingConfirm,onCancelSaveMissing:c.cancelSaveMissing,onConfirmSaveMissing:c.confirmSaveMissing})]})}function Je({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 Qe({fraction:t,onFraction:r,rightPaneName:l,onClosePane:d,rightPane:u,children:y}){let m=i(null),c=i(null),g=Lf(c),S=(v)=>{let x=v.currentTarget,D=m.current;if(!x||!D)return;x.setPointerCapture(v.pointerId);let N=(F)=>{let P=D.getBoundingClientRect();if(P.width===0)return;r(J((F.clientX-P.left)/P.width))},M=()=>{x.releasePointerCapture(v.pointerId),x.removeEventListener("pointermove",N),x.removeEventListener("pointerup",M)};x.addEventListener("pointermove",N),x.addEventListener("pointerup",M)};return e("div",{ref:m,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(J(t)*100)}%`},children:y}),e("div",{ref:c,className:`w-[3px] flex-shrink-0 cursor-col-resize transition-colors active:bg-ink/40 ${g?"bg-ink/40":"bg-ink/10"}`,role:"separator","aria-orientation":"vertical","aria-label":"Resize split panes",onPointerDown:S}),e("div",{className:"flex-1 min-w-0 h-full",children:e(Je,{fileName:l,onClose:d,children:u})})]})}function je({openedFiles:t,activeFileId:r,enabled:l}){let[d,u]=T("editor.split",ee),y=t.map((x)=>x.id),m=Ne(Me(d,y),r),c=l&&m.rightFileId!==null?t.find((x)=>x.id===m.rightFileId)??null:null,g=a((x)=>{if(x!==null&&!ne(x,r,y))return;u({...m,rightFileId:x})},[m,u,r,y]),S=a(()=>u({...m,rightFileId:null}),[m,u]),v=a((x)=>u({...m,fraction:J(x)}),[m,u]);return{rightFile:c,fraction:m.fraction,splitTo:g,close:S,setFraction:v}}function et({find:t,runCommand:r,reopenClosed:l}){let d=i(t);d.current=t;let u=i(r);u.current=r;let y=i(l);return y.current=l,{onKeyDownCapture:a((c)=>{let g=d.current;if(c.key==="Escape"){if(!g.open)return;c.preventDefault(),c.stopPropagation(),g.close();return}if((c.metaKey||c.ctrlKey)&&c.shiftKey&&c.code==="KeyT"){if(y.current?.())c.preventDefault(),c.stopPropagation();return}let S=k0(Ti,c);if(!S||!Yf(S))return;c.preventDefault(),c.stopPropagation(),u.current(S)},[])}}function tt(t){let r=i(t);r.current=t;let l=i(null);if(!l.current)l.current={saveNow:()=>r.current.saveNow(),runCommand:(u)=>r.current.runCommand(u)};return o(()=>{let u=l.current;if(!u)return;return pA(u)},[]),{onFocusCapture:a(()=>{if(l.current)pA(l.current)},[])}}function nt({openedFiles:t,activeFileId:r,onSelectFile:l,onCloseFile:d,saveNow:u}){let[y,m]=n(null);_e();let c=a((S)=>{let v=t.find((x)=>x.id===S);if(v&&Se(S)){m(v);return}d(S)},[t,d]),g=a((S)=>{let v=y;if(!v)return;if(S==="cancel"){m(null);return}if(S==="save"){if(v.id!==r)l(v.id);u()}m(null),d(v.id)},[y,r,l,u,d]);return{requestClose:c,pending:y,answer:g}}function ot(){let[t,r]=n(0),[l,d]=n(!1),u=a(()=>r((y)=>y+1),[]);return{goToLineRequest:t,openGoToLine:u,saveAsOpen:l,setSaveAsOpen:d}}var Ct=Be(()=>import("./Body-9h5hd351.js").then((t)=>({default:t.EditorBody})));function rt(t){return e(Le,{fallback:e("div",{className:"h-full w-full"}),children:e(Ct,{...t})})}function St({className:t="",openedFiles:r,activeFileId:l,onSelectFile:d,onCloseFile:u,onConvertDiffToEditor:y,refreshKey:m=0,onFileSaved:c,onOpenPath:g,onReopenClosed:S,reopenableCount:v,onCopyPath:x,onRevealInFiles:D,rootPath:N=null,repoPath:M=null,activeEditorPanelKey:F=null,forcedActiveFileId:P=null,asSplitPane:R=!1,onHidePanel:O}){let A=R?P:l,f=r.find((C)=>C.id===A),[Q,U,j]=T("editor.previewMode",{}),G=_u(String(A??"")),[h,w]=T("editor.zoomLevel",Mo),[k,q]=n(!1),[H,_]=T("editor.wordWrap",!0),X=ot(),{sessionId:le}=Ge(),L=je({openedFiles:r,activeFileId:A,enabled:!R}),W=i(null),it=Oo(),st=Qi(),de=vu(r,m),ue=Boolean(f&&de.has(f.id)),E=ku(f??null,{reportSaveError:!0,onFileSaved:c,missing:ue}),at=bA({path:f?.path??"",content:E.content,language:E.language}),lt=E.diskChange,ce=nt({openedFiles:r,activeFileId:A,onSelectFile:d,onCloseFile:u,saveNow:E.saveNow}),te=xu({text:E.content,documentKey:`${f?.id??""}\x00${E.language}`,readSelection:()=>W.current?.getSelection()??null,select:(C,V,se=!0)=>W.current?.select(C,V,se),reveal:(C)=>W.current?.revealOffset(C),applyDocument:(C,V,se)=>W.current?.applyDocument(C,V,se),toggleWordWrap:()=>_((C)=>!C)}),me=wu(f?.path??null,E.content,E.loaded&&!E.loadError);Fe({searchReveal:me,revealMatch:te.revealMatch}),Cu({file:f,editor:E,surfaceRef:W,isPreview:f?Q[f.id]===!0:!1,exitPreview:()=>{let C=f?.id;if(C===void 0||C===null)return;U((V)=>({...V,[C]:!1}))}}),o(()=>{if(m>0)E.reset()},[m]),o(()=>{E.retain(r.map((C)=>C.id)),Ce(r.map((C)=>C.id))},[r]),Ke({openedFiles:r,dirtyKeys:E.dirtyKeys,activeFile:f,previewReady:j,setPreviewMode:U,sessionId:le});let ut=()=>{if(!f)return;U((C)=>({...C,[f.id]:!C[f.id]}))},re=(C)=>{if(Yf(C)){te.runCommand(C);return}if(C==="toggleWordWrap"){_((V)=>!V);return}if(C==="goToLine"){X.openGoToLine();return}W.current?.runCommand(C)},pt=et({find:te,runCommand:re,reopenClosed:S}),ct=tt({saveNow:E.saveNow,runCommand:re}),ie=R0(F);if(ie)return e(Ie,{pluginId:ie.pluginId,Component:ie.Component,sessionId:le,className:t,onHide:O});if(r.length===0)return e(Ae,{className:t,onHide:O});let mt=E.viewerKind,fe=f?Q[f.id]:!1,ft={activeFile:f,editor:E,find:te,surfaceRef:W,pluginFileView:at,wordWrap:H,setWordWrap:_,viewerKind:mt,isPreview:Boolean(fe),isReviewing:Boolean(fe)&&G.active,onToggleReview:G.toggle,isMaximized:k,setIsMaximized:q,zoomLevel:h,setZoomLevel:w,goToLineRequest:X.goToLineRequest,onSaveAs:()=>X.setSaveAsOpen(!0),onOpenPath:g,rootPath:N,repoPath:M,runCommand:re,editorFontFamily:it,editorTheme:st,togglePreview:ut,revealActive:Boolean(me),missing:ue,onConvertDiffToEditor:y,onFileSaved:c},bt=(C)=>({openedFiles:r,activeFileId:l,onSelectFile:d,onCloseFile:u,onConvertDiffToEditor:y,refreshKey:m,onFileSaved:c,onOpenPath:g,rootPath:N,repoPath:M,forcedActiveFileId:C,asSplitPane:!0}),gt=e(Re,{openedFiles:r,activeFileId:l,onSelectFile:d,onCloseFile:ce.requestClose,missingIds:de,onCopyPath:x,onRevealInFiles:D,onReopenClosed:S,reopenableCount:v,onSplitTo:L.splitTo,onUnsplit:L.close,splitRightFileId:L.rightFile?.id??null,onHide:O}),be=e(Xe,{className:t,isMaximized:k,onKeyDownCapture:pt.onKeyDownCapture,onFocusCapture:ct.onFocusCapture,asSplitPane:R,tabs:gt,activeFile:f,editor:E,externalChange:lt,conflict:E.conflict,onReload:E.resolveConflictByReload,onKeepMine:E.keepMineAgainstDisk,body:e(rt,{...ft}),saveAsOpen:X.saveAsOpen,onSaveAsClose:()=>X.setSaveAsOpen(!1),onSavedAs:(C)=>{X.setSaveAsOpen(!1),g?.(C)},closeGuard:ce});if(!L.rightFile)return be;return e(Qe,{fraction:L.fraction,onFraction:L.setFraction,rightPaneName:L.rightFile.name,onClosePane:L.close,rightPane:e(St,{...bt(L.rightFile.id)}),children:be})}export{St as Editor};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{d,n,K,i,e,s,f,B,re,Ie,_a,Sa,yt,Da,hr,Bt,Rt}from"./index-pv4z2mp2.js";import{Ga,ja,ti}from"./index-nzvte8s5.js";var Q={name:"square-pen",size:24,node:[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],aliases:["pen-box","edit","pen-square"]},w=s(Q);var Y={name:"laptop",size:24,node:[["path",{d:"M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z",key:"1pdavp"}],["path",{d:"M20.054 15.987H3.946",key:"14rxg9"}]]},O=s(Y);var j={name:"ratio",size:24,node:[["rect",{width:"12",height:"20",x:"6",y:"2",rx:"2",key:"1oxtiu"}],["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]},C=s(j);var ee={name:"tablet",size:24,node:[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18",key:"1dp563"}]]},N=s(ee);var g=[{id:"responsive",label:"Responsive (100% Fluid)",category:"responsive",icon:Sa},{id:"desktop-16-9",label:"Desktop 16:9 (Auto H:W)",category:"responsive",icon:C},{id:"laptop",label:"Laptop (1024 × 768)",category:"responsive",icon:O},{id:"tablet",label:"Tablet (768 × 1024)",category:"mobile",icon:N},{id:"mobile",label:"Mobile Phone (375 × 667)",category:"mobile",icon:hr},{id:"mobile-lg",label:"Mobile Large (414 × 896)",category:"mobile",icon:hr}];function oe(t){switch(t){case"desktop-16-9":return"Desktop 16:9";case"laptop":return"Laptop 1024p";case"tablet":return"Tablet 768p";case"mobile":return"Mobile 375p";case"mobile-lg":return"Mobile Lg 414p";case"responsive":default:return"Responsive"}}function P({viewportMode:t,onChangeViewport:a,zoomLevel:r=100,onSetZoom:l}){let[p,c]=n(null);return e("div",{className:"flex items-center space-x-1.5 flex-shrink-0",children:[e("div",{className:"hidden sm:flex items-center bg-canvas border border-ink/10 rounded-md p-0.5",children:[e("button",{type:"button",onClick:()=>a("responsive"),className:`p-1 rounded text-xs transition-colors cursor-pointer ${t==="responsive"?"bg-ink text-canvas font-medium":"text-ink/50 hover:text-ink"}`,title:"Responsive (100% Fluid)",children:e(Sa,{size:12})}),e("button",{type:"button",onClick:()=>a("desktop-16-9"),className:`p-1 rounded text-xs transition-colors cursor-pointer ${t==="desktop-16-9"?"bg-ink text-canvas font-medium":"text-ink/50 hover:text-ink"}`,title:"Desktop 16:9 (Auto Height following Width)",children:e(C,{size:12})}),e("button",{type:"button",onClick:()=>a("tablet"),className:`p-1 rounded text-xs transition-colors cursor-pointer ${t==="tablet"?"bg-ink text-canvas font-medium":"text-ink/50 hover:text-ink"}`,title:"Tablet (768px)",children:e(N,{size:12})}),e("button",{type:"button",onClick:()=>a("mobile"),className:`p-1 rounded text-xs transition-colors cursor-pointer ${t==="mobile"?"bg-ink text-canvas font-medium":"text-ink/50 hover:text-ink"}`,title:"Mobile (375px)",children:e(hr,{size:12})})]}),e("button",{type:"button","aria-haspopup":"menu","aria-expanded":p!==null,onClick:(o)=>c(p?null:Bt(o.currentTarget)),className:"flex items-center space-x-1 px-2 py-1 rounded bg-canvas border border-ink/15 hover:border-ink/30 text-ink text-[11px] font-mono transition-colors cursor-pointer",title:"Device & Responsive Testing Menu",children:[e("span",{className:"hidden md:inline text-[10px] font-medium",children:oe(t)}),e(B,{size:11,className:"text-ink/60"})]}),e(Rt,{anchor:p,ariaLabel:"Device & Responsive Testing Menu",className:"w-56 bg-paper border border-ink/15 rounded-lg shadow-xl py-1 text-xs font-mono",onClose:()=>c(null),children:[e("div",{className:"px-2.5 py-1 text-[10px] text-ink/40 uppercase tracking-wider font-semibold",children:"Responsive Testing"}),g.filter((o)=>o.category==="responsive").map((o)=>{let u=o.icon,b=t===o.id;return e("button",{type:"button",onClick:()=>{a(o.id),c(null)},className:`w-full px-2.5 py-1.5 flex items-center justify-between text-left hover:bg-ink/5 cursor-pointer ${b?"bg-ink/10 font-semibold text-ink":"text-ink/75"}`,children:[e("div",{className:"flex items-center space-x-2",children:[e(u,{size:13,className:"text-ink/60"}),e("span",{children:o.label})]}),b&&e(f,{size:12,className:"text-success"})]},o.id)}),e("div",{className:"mt-1 pt-1 border-t border-ink/10 px-2.5 py-1 text-[10px] text-ink/40 uppercase tracking-wider font-semibold",children:"Mobile Testing"}),g.filter((o)=>o.category==="mobile").map((o)=>{let u=o.icon,b=t===o.id;return e("button",{type:"button",onClick:()=>{a(o.id),c(null)},className:`w-full px-2.5 py-1.5 flex items-center justify-between text-left hover:bg-ink/5 cursor-pointer ${b?"bg-ink/10 font-semibold text-ink":"text-ink/75"}`,children:[e("div",{className:"flex items-center space-x-2",children:[e(u,{size:13,className:"text-ink/60"}),e("span",{children:o.label})]}),b&&e(f,{size:12,className:"text-success"})]},o.id)}),l&&e(d,{children:[e("div",{className:"mt-1 pt-1 border-t border-ink/10 px-2.5 py-1 text-[10px] text-ink/40 uppercase tracking-wider font-semibold",children:["Zoom Scale (",r,"%)"]}),e("div",{className:"grid grid-cols-3 gap-1 px-2 py-1",children:[50,75,100,125,150,200].map((o)=>e("button",{type:"button",onClick:()=>{l(o),c(null)},className:`px-1.5 py-1 text-center rounded text-[11px] font-mono cursor-pointer transition-colors ${r===o?"bg-ink text-canvas font-semibold":"bg-canvas border border-ink/10 text-ink/75 hover:bg-ink/5"}`,children:[o,"%"]},o))})]})]})]})}function A({zoomLevel:t,onZoomIn:a,onZoomOut:r,onResetZoom:l}){return e("div",{className:"flex items-center bg-canvas border border-ink/10 rounded-md p-0.5 space-x-0.5 text-xs font-mono",children:[e("button",{type:"button",onClick:r,disabled:t<=50,"aria-label":"Perkecil tampilan",title:"Zoom Out (-10%)",className:"p-1 rounded hover:bg-ink/5 disabled:opacity-25 disabled:hover:bg-transparent text-ink/70 hover:text-ink cursor-pointer disabled:cursor-not-allowed transition-colors",children:e(ja,{size:12})}),e("button",{type:"button",onClick:l,className:"px-1 text-[10px] font-medium text-ink/75 hover:text-ink hover:underline cursor-pointer select-none",title:"Reset Zoom (100%)",children:[t,"%"]}),e("button",{type:"button",onClick:a,disabled:t>=200,"aria-label":"Perbesar tampilan",title:"Zoom In (+10%)",className:"p-1 rounded hover:bg-ink/5 disabled:opacity-25 disabled:hover:bg-transparent text-ink/70 hover:text-ink cursor-pointer disabled:cursor-not-allowed transition-colors",children:e(Ga,{size:12})})]})}var h="p-1.5 rounded hover:bg-ink/5 disabled:opacity-25 disabled:hover:bg-transparent text-ink/70 hover:text-ink transition-colors cursor-pointer disabled:cursor-not-allowed";function V(t){let a=[],{url:r,zoomLevel:l,copied:p,included:c}=t;if(t.viewportMode&&t.onChangeViewport){let{viewportMode:o,onChangeViewport:u,onSetZoom:b}=t;a.push({id:"viewport",actions:g.map((x)=>({label:x.label,icon:x.icon,onSelect:()=>u(x.id),active:o===x.id})),children:e(P,{viewportMode:o,onChangeViewport:u,zoomLevel:l,onSetZoom:b})})}if(a.push({id:"zoom",actions:[{label:"Zoom in (+10%)",icon:Ga,onSelect:t.onZoomIn,disabled:l>=200},{label:"Zoom out (-10%)",icon:ja,onSelect:t.onZoomOut,disabled:l<=50},{label:"Reset zoom (100%)",icon:yt,onSelect:t.onResetZoom,active:l===100}],children:e(A,{zoomLevel:l,onZoomIn:t.onZoomIn,onZoomOut:t.onZoomOut,onResetZoom:t.onResetZoom})}),a.push({id:"include",actions:[{label:c?"Page context added to the draft":"Include this page in the chat draft",icon:_a,onSelect:t.onIncludeInChat,disabled:!r}],children:e("button",{type:"button",onClick:t.onIncludeInChat,disabled:!r,"aria-label":"Include this page in the chat draft",title:c?"Page context added to the draft":"Include this page in the chat draft",className:h,children:c?e(f,{size:14,className:"text-success"}):e(_a,{size:14})})}),t.annotate){let o=t.annotate;a.push({id:"annotate",actions:[{label:o.count>0?`${o.active?"Tutup mode anotasi":"Buka mode anotasi"} (${o.count})`:"Mark a part of the page, then send it to the chat",icon:w,onSelect:o.onToggle,active:o.active,disabled:!r}],children:e("button",{type:"button",onClick:o.onToggle,disabled:!r,"aria-label":"Page annotation mode","aria-pressed":o.active,title:o.active?"Tutup mode anotasi":o.count>0?`Anotasi (${o.count}) — buka lagi`:"Mark a part of the page, then send it to the chat",className:`${h} relative ${o.active?"bg-ink/10 text-ink":""}`,children:[e(w,{size:14}),o.count>0&&e("span",{className:"absolute -top-0.5 -right-0.5 min-w-[13px] h-[13px] px-0.5 rounded-full bg-error text-paper text-[10px] leading-[13px] font-mono text-center",children:o.count})]})})}if(a.push({id:"copy",actions:[{label:p?"Copied URL!":"Copy URL",icon:re,onSelect:t.onCopy,disabled:!r}],children:e("button",{type:"button",onClick:t.onCopy,disabled:!r,"aria-label":"Salin URL",title:p?"Copied URL!":"Copy URL",className:h,children:p?e(f,{size:14,className:"text-success"}):e(re,{size:14})})}),t.onReconnect){let o=t.onReconnect;a.push({id:"reconnect",actions:[{label:"Sambungkan ulang live view",icon:Da,onSelect:o}],children:e("button",{type:"button",onClick:o,"aria-label":"Sambungkan ulang live view",title:"Reconnect live view",className:h,children:e(Da,{size:14})})})}return a.push({id:"open-external",actions:[{label:t.openExternalLabel,icon:Ie,onSelect:t.onOpenExternal,disabled:!r}],children:e("button",{type:"button",onClick:t.onOpenExternal,disabled:!r,"aria-label":t.openExternalLabel,title:t.openExternalTitle,className:h,children:e(Ie,{size:14})})}),a}var E=108,te=280,ne=18,ie=140,ae=36;function ed({url:t,statusDotClass:a,statusLabel:r,viewportMode:l,zoomLevel:p,onChangeViewport:c,onZoomIn:o,onZoomOut:u,onResetZoom:b,onSetZoom:x,annotate:D,onIncludeInChat:_,onOpenExternal:U,onReconnect:W,openExternalLabel:H,openExternalTitle:X,twoRows:k=!1,children:q}){let[F,T]=n(!1),[G,R]=n(!1),y=i(null),[m,I]=n(0),S=V({url:t,zoomLevel:p,copied:F,included:G,viewportMode:l,onChangeViewport:c,annotate:D,onReconnect:W,onIncludeInChat:()=>{_(),R(!0),setTimeout(()=>R(!1),2500)},onCopy:()=>{if(!t)return;navigator.clipboard.writeText(t).then(()=>{T(!0),setTimeout(()=>T(!1),2000)}).catch(()=>{})},onOpenExternal:U,onZoomIn:o,onZoomOut:u,onResetZoom:b,onSetZoom:x,openExternalLabel:H,openExternalTitle:X});K(()=>{let v=y.current;if(!v)return;I(v.clientWidth)}),K(()=>{let v=y.current;if(!v||typeof ResizeObserver>"u")return;let L=new ResizeObserver(()=>I(v.clientWidth));return L.observe(v),()=>L.disconnect()},[]);let M=m===0||m>=te,Z=M?m>0?Math.min(E,m*0.25):E:ne,z=k?m>0?m:void 0:m>0?Math.max(0,m-Z-ie-ae):void 0,J=e("div",{className:"flex items-center space-x-1.5 flex-shrink-0 min-w-0",style:{maxWidth:`${Z}px`},title:r,children:[e("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${a}`}),M&&e("span",{className:"text-[10px] font-mono uppercase tracking-wide text-ink/60 truncate",children:r})]});return e("div",{ref:y,"data-browser-toolbar":"",className:`px-2.5 border-b border-ink/10 bg-paper flex flex-col gap-y-1 flex-shrink-0 select-none ${k?"py-1":"h-10 justify-center"}`,children:[e("div",{"data-toolbar-band":"address",className:"flex items-center gap-x-2 min-w-0",children:[J,e("div",{className:"flex flex-1 min-w-0 items-center",children:q}),!k&&e(ti,{clusters:S,available:z})]}),k&&e("div",{"data-toolbar-band":"controls",className:"flex items-center min-w-0",children:e(ti,{clusters:S,available:z})})]})}
|
|
2
|
-
export{ed};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import{d,n,o,K,i,u,a,Ir,e,s,Ja,Ee,Za,p,jn,Te,N,I,lt,f,B,se,ct,re,Ae,ce,Wn,un,Kn,P,S,Da,U,Na,hn,b,Lr,Qo,nr,km,_e,T,wm,Wg,br,yr,vt,Xe,pe,xd,wi,Z,dt,pt,mt,Cl,je,he,J}from"./index-pv4z2mp2.js";import{bm,Br}from"./index-a4636gt1.js";var jt={name:"folder-tree",size:24,node:[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]]},Ve=s(jt);var Ut={name:"list",size:24,node:[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]},Ye=s(Ut);function Ze({message:t,hasStagedChanges:l,isBusy:c=!1,amend:r=!1,seeded:m=!1,isGenerating:h=!1,suggestion:g=null,generated:v=!1,onToggleAmend:w,onChangeMessage:A,onCommit:R,onGenerate:C,onUseSuggestion:G,onDismissSuggestion:M}){let L=t.trim().length>0&&!c&&(r||l),y=(r||l)&&!c&&!h,x=r?"Rewrite the previous commit with this message":l?"Commit staged changes":"Stage changes first",k=h?"Generating…":r||l?"Generate a commit message from the staged changes":"Stage changes first";return e("div",{className:"border-t border-ink/10 bg-canvas/50 p-3 flex flex-col gap-2",children:[g&&e("div",{className:"rounded border border-ink/20 bg-paper p-2.5 space-y-2",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-ink/45",children:"Generated message"}),e("div",{className:"flex items-center gap-1",children:[e("button",{type:"button",onClick:G,className:"px-2 py-0.5 rounded bg-ink text-canvas text-[10px] font-medium hover:bg-ink/90 transition-colors cursor-pointer",children:"Use"}),e("button",{type:"button",onClick:M,className:"px-2 py-0.5 rounded border border-ink/20 text-ink/70 text-[10px] font-medium hover:bg-ink/5 transition-colors cursor-pointer",children:"Dismiss"})]})]}),e("pre",{className:"whitespace-pre-wrap break-words text-[11px] text-ink/80 font-mono max-h-32 overflow-y-auto",children:g})]}),e("textarea",{value:t,onChange:(D)=>A(D.currentTarget.value),onKeyDown:(D)=>{if(D.key==="Enter"&&(D.metaKey||D.ctrlKey)&&L)D.preventDefault(),R()},placeholder:r?"New message for the previous commit (⌘/Ctrl+Enter to commit)":"Commit message (⌘/Ctrl+Enter to commit)",rows:5,className:"w-full resize-y min-h-[100px] max-h-[200px] bg-paper border border-ink/20 rounded px-2.5 py-1.5 text-xs text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors font-mono"}),v&&t.trim().length>0&&e("div",{className:"flex items-center gap-1 text-[10px] text-ink/40",children:[e(Te,{size:10})," Generated from staged changes"]}),e("div",{className:"flex flex-wrap items-center gap-2",children:[e("label",{className:"flex items-center gap-1.5 text-[11px] text-ink/70 cursor-pointer select-none",children:[e("input",{type:"checkbox",checked:r,onChange:(D)=>w?.(D.currentTarget.checked),className:`${he} accent-ink cursor-pointer`}),"Amend"]}),r&&m&&e("span",{className:"text-[10px] text-ink/40",title:"The previous commit's message, loaded as an editable starting point",children:"previous message loaded"}),e("button",{type:"button",onClick:C,disabled:!y,title:k,"aria-label":"Generate commit message with AI",className:"ml-auto flex items-center justify-center gap-1.5 px-3 py-1.5 rounded border border-ink/20 text-ink/80 hover:bg-ink/5 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[h?e(p,{size:12,className:"animate-spin"}):e(Te,{size:12}),h?"Generating…":"Generate"]}),e("button",{type:"button",onClick:R,disabled:!L,title:x,className:"flex items-center justify-center gap-1.5 px-3 py-1.5 rounded bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[e(f,{size:12}),r?"Amend commit":"Commit"]})]})]})}function Qe({operation:t,conflicts:l,isBusy:c,onAbort:r,onContinue:m}){let h=Qo[t],g=l.length,v=g===0,w=t!=="stash-pop";return e("div",{className:"border-t border-warning/30 bg-warning/5 p-3 flex flex-col gap-2",children:[e("div",{className:"flex items-center gap-2 text-xs text-ink",children:[e(I,{size:13,className:"text-warning flex-shrink-0"}),e("span",{className:"font-medium",children:[h.charAt(0).toUpperCase()+h.slice(1)," in progress"]}),e("span",{className:`font-mono tabular-nums text-[10px] ${v?"text-success":"text-warning"}`,children:v?"all conflicts resolved":`${g} conflict${g===1?"":"s"} left`})]}),!v&&e("div",{className:"max-h-20 overflow-y-auto scrollbar-overlay-container font-mono text-[10px] text-warning/90 space-y-0.5",children:l.map((A)=>e("div",{className:"truncate",title:A,children:A},A))}),e("div",{className:"flex items-stretch gap-2",children:[e("button",{type:"button",onClick:r,disabled:c,title:`Abort the ${h} and restore the previous state`,className:"flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded border border-error/40 text-error hover:bg-error/10 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[e(hn,{size:12}),"Abort ",h]}),w&&e("button",{type:"button",onClick:m,disabled:c||!v,title:v?`Conclude the ${h}`:`Resolve all ${g} conflict(s) first`,className:"flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded border border-transparent bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[e(Wn,{size:12}),"Continue ",h]})]})]})}function Je({branchRef:t,showBranchMenu:l,setShowBranchMenu:c,branch:r,branches:m,remoteBranches:h,onCheckout:g,onMerge:v,onOpenBranchPrompt:w,onManageBranches:A,optionsRef:R,showOptions:C,setShowOptions:G,onHistory:M,onGraph:L,viewMode:y,setViewMode:x,isBusy:k=!1,syncCount:D={ahead:0,behind:0},syncing:F=!1,onSync:O,onFetch:V,detached:E=!1}){return e("div",{className:"p-3 border-b border-ink/10 bg-canvas/50 flex items-center justify-between",children:[e("div",{className:"relative",ref:t,children:[e("button",{onClick:()=>c(!l),className:"flex items-center space-x-1.5 hover:bg-ink/5 px-2 py-1 -ml-2 rounded transition-colors text-[11px] text-ink/80 font-medium",title:E?`Detached HEAD at ${r}`:`On branch ${r}`,children:[e(ce,{size:12,className:E?"text-warning":"text-ink/60"}),e("span",{className:`truncate max-w-[140px] ${E?"font-mono text-warning":""}`,children:r}),e(B,{size:12,className:"text-ink/40"})]}),l&&e("div",{className:"glass-popover absolute top-full left-0 mt-1 w-56 bg-paper border border-ink/20 rounded-md shadow-lg z-50 flex flex-col overflow-hidden text-xs",children:e("div",{className:"max-h-48 scrollbar-overlay-container py-1",children:[m.length>0&&e(d,{children:[e("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold",children:"Local"}),m.map((H)=>e("div",{className:"flex items-center group/branch",children:[e("button",{onClick:()=>{g(H),c(!1)},className:"flex-1 min-w-0 text-left px-3 py-2 hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("span",{className:"truncate",children:H}),r===H&&e(f,{size:12,className:"text-ink flex-shrink-0"})]}),r!==H&&e("button",{type:"button",onClick:()=>{v(H),c(!1)},title:`Merge ${H} into ${r}`,"aria-label":`Merge ${H} into ${r}`,className:"touch-visible opacity-0 group-hover/branch:opacity-100 px-2 py-2 text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer flex-shrink-0",children:e(Wn,{size:12})})]},H))]}),h.length>0&&e(d,{children:[e("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold",children:"Remote"}),h.map((H)=>e("div",{className:"flex items-center group/branch",children:[e("button",{onClick:()=>{g(H),c(!1)},className:"flex-1 min-w-0 text-left px-3 py-2 hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("span",{className:"truncate",children:H}),r===H&&e(f,{size:12,className:"text-ink flex-shrink-0"})]}),r!==H&&e("button",{type:"button",onClick:()=>{v(H),c(!1)},title:`Merge ${H} into ${r}`,"aria-label":`Merge ${H} into ${r}`,className:"touch-visible opacity-0 group-hover/branch:opacity-100 px-2 py-2 text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer flex-shrink-0",children:e(Wn,{size:12})})]},H))]}),e("div",{className:"w-full h-px bg-ink/10 my-1"}),e("button",{onClick:()=>{w(),c(!1)},className:"w-full text-left px-3 py-2 hover:bg-ink/5 flex items-center space-x-2 transition-colors text-ink/80 italic",children:[e(P,{size:12}),e("span",{children:"Create new branch..."})]}),e("button",{onClick:A,className:"w-full text-left px-3 py-2 hover:bg-ink/5 flex items-center space-x-2 transition-colors text-ink/80",children:[e(Na,{size:12}),e("span",{children:"Manage branches..."})]})]})})]}),e("div",{className:"flex items-center space-x-2 text-ink/40 relative",ref:R,children:[e("button",{type:"button",onClick:V,disabled:k,title:"Fetch from all remotes and prune deleted branches","aria-label":"Fetch",className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:e(Ja,{size:13})}),e("button",{type:"button",onClick:O,disabled:k,title:F?"Syncing with upstream…":D.ahead>0&&D.behind>0?`Pull ${D.behind} then push ${D.ahead} commit(s)`:D.ahead>0?`Push ${D.ahead} commit(s)`:D.behind>0?`Pull ${D.behind} commit(s)`:"Up to date — sync anyway","aria-label":"Sync with upstream","aria-busy":F,className:`flex items-center gap-1 p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors disabled:cursor-not-allowed ${F?"":"disabled:opacity-40"}`,children:[e(S,{size:13,className:F?"animate-spin":"","aria-hidden":"true"}),e("span",{className:"font-mono tabular-nums text-[10px]",children:["↑",D.ahead," ↓",D.behind]})]}),e("button",{type:"button",onClick:M,title:"Commit History","aria-label":"Commit History",className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors",children:e(jn,{size:13})}),e("button",{type:"button",onClick:L,title:"Git Graph","aria-label":"Git Graph",className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors",children:e(Wn,{size:13})}),e("button",{type:"button",onClick:()=>G(!C),title:"View Options","aria-label":"View Options","aria-expanded":C,className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors",children:e(Ee,{size:13})}),C&&e("div",{className:"glass-popover absolute right-0 top-full mt-1 w-36 bg-paper border border-ink/15 rounded-md shadow-lg z-50 py-1 font-mono text-xs",children:[e("button",{type:"button",onClick:()=>{x("flat"),G(!1)},className:"w-full px-3 py-1.5 text-left text-ink hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("div",{className:"flex items-center space-x-1.5",children:[e(Ye,{size:12,className:"text-ink/60"}),e("span",{children:"View as List"})]}),y==="flat"&&e(f,{size:12,className:"text-ink"})]}),e("button",{type:"button",onClick:()=>{x("tree"),G(!1)},className:"w-full px-3 py-1.5 text-left text-ink hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("div",{className:"flex items-center space-x-1.5",children:[e(Ve,{size:12,className:"text-ink/60"}),e("span",{children:"View as Tree"})]}),y==="tree"&&e(f,{size:12,className:"text-ink"})]})]})]})]})}function et({activeRepo:t,repos:l,isRefreshing:c,rootPath:r,reposScanning:m,onSelectRepo:h,onRefresh:g,onRefreshRepos:v}){return e(vt,{left:e(d,{children:[e(bm,{size:12,className:"text-ink/50 flex-shrink-0","aria-hidden":!0}),e(Br,{rootPath:r,activeRepo:t,onSelectRepo:h,repos:l,scanning:m,onRefreshRepos:v})]}),right:e(Xe,{label:"Refresh",onClick:g,busy:c})})}function Fe({change:t,isStaged:l,repo:c,rootPath:r,onAction:m}){let h=nr(t.status,l),{charStatus:g,colorClass:v}=h,w=t.file.split("/"),A=w.pop()||t.file,R=w.length>0?w.join("/"):"";return e("div",{className:"flex items-center justify-between px-3 py-1 hover:bg-ink/5 cursor-pointer group text-[11px] transition-colors",onClick:()=>{window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.file,staged:l,status:g,repo:c||".",root:r}}))},children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-2",children:[e("span",{className:`font-bold font-mono text-[10px] w-3 flex-shrink-0 text-center ${v}`,title:`Status: ${h.label}`,children:g}),e(dt,{name:A,size:12,className:"flex-shrink-0"}),e("span",{className:`truncate ${v}`,title:t.file,children:A}),R&&e("span",{className:"text-[10px] text-ink/40 truncate ml-1",children:R})]}),e("div",{className:"flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("div",{className:"flex items-center touch-visible opacity-0 group-hover:opacity-100 space-x-1",children:[!l&&e(d,{children:[e("button",{type:"button",onClick:(G)=>{G.stopPropagation(),m("revert",t.file)},title:"Discard Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-error hover:bg-error/10 cursor-pointer transition-colors",children:e(hn,{size:11})}),e("button",{type:"button",onClick:(G)=>{G.stopPropagation(),m("stage",t.file)},title:"Stage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(P,{size:11})})]}),l&&e("button",{type:"button",onClick:(G)=>{G.stopPropagation(),m("unstage",t.file)},title:"Unstage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(un,{size:11})})]})})]})}function tt({change:t,repo:l,rootPath:c,onResolve:r}){let[m,h]=n(!1),[g,v]=n(null),w=t.file.split("/"),A=w.pop()||t.file,R=w.length>0?w.join("/"):"",C=()=>{window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.file,staged:!1,status:t.status,repo:l,root:c}}))},G=async()=>{let y=!m;if(h(y),y&&g===null){let x=new URLSearchParams({conflictMarkers:"1",file:t.file,repo:l||"."});if(c)x.set("root",c);try{let D=await(await fetch(`/api/fs/git?${x.toString()}`)).json();v(D.markers??{})}catch{v({})}}},M=g?.ours||"ours",L=g?.theirs||"theirs";return e("div",{className:"border-b border-warning/20 last:border-b-0",children:[e("div",{className:"flex items-center justify-between px-3 py-1 hover:bg-warning/5 cursor-pointer group text-[11px] transition-colors",onClick:C,children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-2",children:[e(Za,{size:11,className:"text-warning flex-shrink-0"}),e(dt,{name:A,size:12,className:"flex-shrink-0"}),e("span",{className:"truncate text-warning",title:t.file,children:A}),R&&e("span",{className:"text-[10px] text-ink/40 truncate ml-1",children:R}),Lr(t.status)&&e("span",{className:"text-[10px] text-warning/70 font-mono flex-shrink-0",children:t.status})]}),e("button",{type:"button",onClick:(y)=>{y.stopPropagation(),G()},title:m?"Hide resolve actions":"Show resolve actions","aria-label":m?"Hide resolve actions":"Show resolve actions","aria-expanded":m,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 flex-shrink-0",children:m?e(ct,{size:11}):e(B,{size:11})})]}),m&&e("div",{className:"px-3 pb-2 pt-0.5 flex flex-wrap items-center gap-1.5",children:[e("button",{type:"button",onClick:()=>r(t.file,"ours"),title:`Take ${M} — \`git checkout --ours\` then stage`,className:"px-2 py-0.5 text-[10px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer max-w-[45%] truncate",children:["take ",M]}),e("button",{type:"button",onClick:()=>r(t.file,"theirs"),title:`Take ${L} — \`git checkout --theirs\` then stage`,className:"px-2 py-0.5 text-[10px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer max-w-[45%] truncate",children:["take ",L]}),e("button",{type:"button",onClick:()=>r(t.file,""),title:"Mark resolved: the file was edited by hand, this stages it",className:"px-2 py-0.5 text-[10px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer flex items-center gap-1",children:[e(f,{size:10}),"mark resolved"]})]})]})}function Wt(t){let l={id:"",name:"",path:"",type:"folder",children:[],changeCount:0};for(let r of t){let m=r.file.replace(/^[./]+/,""),h=m.endsWith("/"),g=m.replace(/\/$/,"").split("/").filter(Boolean),v=l,w="";for(let A=0;A<g.length;A++){let R=g[A];w=w?`${w}/${R}`:R;let C=A===g.length-1;if(C&&!h)v.children.push({id:w,name:R,path:w,type:"file",change:r,children:[],changeCount:1});else{let M=v.children.find((L)=>L.type==="folder"&&L.name===R);if(!M)M={id:w,name:R,path:w,type:"folder",children:[],changeCount:0,change:C&&h?r:void 0},v.children.push(M);v=M}}}function c(r){if(r.type==="file")return 1;let m=r.change?1:0;for(let h of r.children)m+=c(h);return r.changeCount=m,r.children.sort((h,g)=>{if(h.type==="folder"&&g.type==="file")return-1;if(h.type==="file"&&g.type==="folder")return 1;return h.name.localeCompare(g.name)}),m}return c(l),l.children}function nt(t){let{sessionId:l,ready:c,read:r}=wm(),m=u(()=>Wt(t),[t]),h=u(()=>{let G=new Set;function M(L){for(let y of L)if(y.type==="folder"){if(G.add(y.id),y.children&&y.children.length>0)M(y.children)}}return M(m),G},[m]),[g,v]=T("git.expandedFolders",[]),w=u(()=>new Set(g),[g]),A=i(null);o(()=>{if(!c||A.current===l)return;if(h.size===0)return;if(A.current=l,r("git.expandedFolders",[]).length>0)return;v(Array.from(h))},[c,l,h,r,v]);let R=a((G)=>{v((M)=>{let L=new Set(M);if(L.has(G))L.delete(G);else L.add(G);return Array.from(L)})},[v]),C=a((G)=>w.has(G),[w]);return{tree:m,expandedFolders:w,toggleFolder:R,isFolderOpen:C,expandAll:()=>v(Array.from(h)),collapseAll:()=>v([])}}function He({node:t,isStaged:l,isFolderOpen:c,toggleFolder:r,onAction:m,repo:h,rootPath:g}){let v=t.type==="folder",w=v?c(t.id):!1;if(v)return e("div",{className:"select-none",children:[e("div",{className:"flex items-center justify-between px-2 py-1 hover:bg-ink/5 cursor-pointer rounded group transition-colors text-[11px]",onClick:()=>r(t.id),children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-1",children:[e("span",{className:"w-3.5 h-3.5 flex items-center justify-center text-ink/40 flex-shrink-0",children:w?e(B,{size:12}):e(se,{size:12})}),e(dt,{name:t.name,isFolder:!0,isOpen:w,size:13,className:"flex-shrink-0"}),e("span",{className:"font-medium text-ink truncate",children:t.name}),e("span",{className:"text-[10px] text-ink/40 font-normal px-1 py-0.2 bg-ink/5 rounded-full ml-1",children:t.changeCount})]}),e("div",{className:"flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("div",{className:"flex items-center touch-visible opacity-0 group-hover:opacity-100 space-x-1",children:!l?e(d,{children:[e("button",{type:"button",onClick:(y)=>{y.stopPropagation(),m("revert",t.path)},title:`Discard changes in ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded hover:text-error hover:bg-error/10 cursor-pointer transition-colors",children:e(hn,{size:11})}),e("button",{type:"button",onClick:(y)=>{y.stopPropagation(),m("stage",t.path)},title:`Stage ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(P,{size:11})})]}):e("button",{type:"button",onClick:(y)=>{y.stopPropagation(),m("unstage",t.path)},title:`Unstage ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(un,{size:11})})})})]}),w&&t.children&&t.children.length>0&&e("div",{className:"ml-3 border-l border-ink/10 pl-1",children:t.children.map((y)=>e(He,{node:y,isStaged:l,isFolderOpen:c,toggleFolder:r,onAction:m,repo:h,rootPath:g},y.id))})]});let A=t.change,R=nr(A?.status||"M",l),{charStatus:C,colorClass:G}=R,M=A?A.file:t.path;return e("div",{className:"flex items-center justify-between px-2 py-0.5 hover:bg-ink/5 cursor-pointer rounded group transition-colors text-[11px]",onClick:()=>{window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:M,staged:l,status:C,repo:h||".",root:g}}))},children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-1",children:[e("span",{className:"w-3.5 h-3.5 flex items-center justify-center flex-shrink-0",children:e("span",{className:`font-bold font-mono text-[10px] ${G}`,title:`Status: ${R.label}`,children:C})}),e(dt,{name:t.name,size:12,className:"flex-shrink-0"}),e("span",{className:`truncate ${G}`,title:M,children:t.name})]}),e("div",{className:"flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("div",{className:"flex items-center touch-visible opacity-0 group-hover:opacity-100 space-x-1",children:!l?e(d,{children:[e("button",{type:"button",onClick:(y)=>{y.stopPropagation(),m("revert",M)},title:"Discard Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-error hover:bg-error/10 cursor-pointer transition-colors",children:e(hn,{size:11})}),e("button",{type:"button",onClick:(y)=>{y.stopPropagation(),m("stage",M)},title:"Stage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(P,{size:11})})]}):e("button",{type:"button",onClick:(y)=>{y.stopPropagation(),m("unstage",M)},title:"Unstage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(un,{size:11})})})})]})}function ze({changes:t,isStaged:l,repo:c,rootPath:r,onAction:m}){let{tree:h,isFolderOpen:g,toggleFolder:v}=nt(t);if(h.length===0)return null;return e("div",{className:"py-0.5",children:h.map((w)=>e(He,{node:w,isStaged:l,isFolderOpen:g,toggleFolder:v,onAction:m,repo:c,rootPath:r},w.id))})}function ot({changes:t,isLoading:l,viewMode:c,repo:r,rootPath:m,onAction:h,onResolve:g}){let[v,w]=T("git.stagedExpanded",!0),[A,R]=T("git.unstagedExpanded",!0),[C,G]=T("git.conflictsExpanded",!0),M=t.filter((x)=>Lr(x.status)),L=t.filter((x)=>{if(Lr(x.status))return!1;let k=x.status;return k&&k[0]!==" "&&k[0]!=="?"}),y=t.filter((x)=>{if(Lr(x.status))return!1;let k=x.status;return k&&k[1]!==" "&&k[1]!=="?"||k==="??"});if(l&&t.length===0)return e("div",{className:"flex-1 scrollbar-overlay-container font-mono text-[11px] text-ink/80",children:e("div",{className:"p-4 text-center text-ink/40 italic",children:"Loading..."})});if(t.length===0)return e("div",{className:"flex-1 scrollbar-overlay-container font-mono text-[11px] text-ink/80",children:e("div",{className:"p-4 text-center text-ink/40 italic",children:"No changes found."})});return e("div",{className:"flex-1 scrollbar-overlay-container font-mono text-[11px] text-ink/80",children:e("div",{className:"py-1",children:[M.length>0&&e("div",{className:"mb-2",children:[e("div",{className:"flex items-center justify-between px-3 py-1 group hover:bg-warning/5 cursor-pointer transition-colors",onClick:()=>G(!C),children:e("div",{className:"flex items-center space-x-1 font-semibold text-warning text-xs",children:[e("span",{className:"w-3 text-center",children:C?"▾":"▸"}),e("span",{children:"Conflicts"}),e("span",{className:"text-warning/70 font-normal ml-1 border border-warning/30 rounded-full px-1.5 text-[10px] bg-paper",children:M.length})]})}),C&&M.map((x)=>e(tt,{change:x,repo:r,rootPath:m,onResolve:g??(()=>{})},`conflict-${x.file}`))]}),L.length>0&&e("div",{className:"mb-2",children:[e("div",{className:"flex items-center justify-between px-3 py-1 group hover:bg-ink/5 cursor-pointer transition-colors",onClick:()=>w(!v),children:[e("div",{className:"flex items-center space-x-1 font-semibold text-ink text-xs",children:[e("span",{className:"w-3 text-center",children:v?"▾":"▸"}),e("span",{children:"Staged Changes"}),e("span",{className:"text-ink/40 font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[10px] bg-paper",children:L.length})]}),e("div",{className:"touch-visible opacity-0 group-hover:opacity-100 flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("button",{type:"button",onClick:(x)=>{x.stopPropagation(),h("unstage_all")},title:"Unstage All Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(un,{size:12})})})]}),v&&(c==="tree"?e(ze,{changes:L,isStaged:!0,repo:r,rootPath:m,onAction:h}):L.map((x)=>e(Fe,{change:x,isStaged:!0,repo:r,rootPath:m,onAction:h},x.file+"staged")))]}),y.length>0&&e("div",{children:[e("div",{className:"flex items-center justify-between px-3 py-1 group hover:bg-ink/5 cursor-pointer transition-colors",onClick:()=>R(!A),children:[e("div",{className:"flex items-center space-x-1 font-semibold text-ink text-xs",children:[e("span",{className:"w-3 text-center",children:A?"▾":"▸"}),e("span",{children:"Changes"}),e("span",{className:"text-ink/40 font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[10px] bg-paper",children:y.length})]}),e("div",{className:"touch-visible opacity-0 group-hover:opacity-100 flex items-center space-x-1 text-ink/40 flex-shrink-0",children:[e("button",{type:"button",onClick:(x)=>{x.stopPropagation(),h("revert_all")},title:"Discard All Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-error hover:bg-error/10 cursor-pointer transition-colors",children:e(hn,{size:12})}),e("button",{type:"button",onClick:(x)=>{x.stopPropagation(),h("stage_all")},title:"Stage All Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(P,{size:12})})]})]}),A&&(c==="tree"?e(ze,{changes:y,isStaged:!1,repo:r,rootPath:m,onAction:h}):y.map((x)=>e(Fe,{change:x,isStaged:!1,repo:r,rootPath:m,onAction:h},x.file+"unstaged")))]})]})})}function st({matches:t,loaded:l,total:c,hasMore:r,isFiltering:m}){if(m)return`${t} of ${l} loaded`;if(typeof c==="number"&&c>0)return r||l<c?`${l} of ${c}`:`${c} commits`;return r?`${l}+ commits`:`${l} commits`}function rt({isGraphMode:t,onToggleMode:l,searchQuery:c,onSearchChange:r,onRefresh:m,onClose:h,isRefreshing:g,totalCommits:v,loadedCount:w,totalCount:A,hasMore:R}){let C=st({matches:v,loaded:w,total:A,hasMore:R,isFiltering:c.trim().length>0});return e("div",{className:`flex flex-col gap-2 px-3 lg:px-5 py-3 border-b border-ink/10 bg-paper select-none
|
|
2
|
-
pl-[max(0.75rem,env(safe-area-inset-left,0px))] pr-[max(0.75rem,env(safe-area-inset-right,0px))]`,children:[e("div",{className:"flex items-center justify-between gap-2 lg:gap-4",children:[e("div",{className:"flex flex-col min-w-0",children:[e("div",{className:"flex items-center gap-2.5 min-w-0",children:[e("h2",{className:"text-base font-semibold text-ink tracking-tight",children:t?"Graph":"History"}),e("span",{className:"text-[11px] font-mono px-2 py-0.5 rounded-full bg-ink/5 text-ink/80 border border-ink/10 whitespace-nowrap",children:C})]}),e("p",{className:"text-xs text-muted mt-0.5 hidden lg:block",children:t?"Follow branch topology and inspect commits.":"Browse recent commits and inspect changed files."})]}),e("div",{className:"flex items-center gap-1.5 lg:gap-2 flex-shrink-0",children:[e("div",{className:"flex items-center text-xs lg:bg-ink/5 lg:p-0.5 lg:rounded-lg lg:border lg:border-ink/10",children:[e("button",{type:"button",onClick:()=>l(!1),title:"History view","aria-label":"History view","aria-pressed":!t,className:`tap-target flex items-center justify-center gap-1.5 p-2 rounded-md font-medium transition-colors cursor-pointer lg:px-2.5 lg:py-1 ${!t?"bg-ink/5 text-ink lg:bg-paper lg:shadow-xs":"text-ink/80 lg:hover:text-ink lg:hover:bg-ink/5"}`,children:[e(jn,{size:13,"aria-hidden":"true"}),e("span",{className:"hidden lg:inline",children:"History"})]}),e("button",{type:"button",onClick:()=>l(!0),title:"Graph view","aria-label":"Graph view","aria-pressed":t,className:`tap-target flex items-center justify-center gap-1.5 p-2 rounded-md font-medium transition-colors cursor-pointer lg:px-2.5 lg:py-1 ${t?"bg-ink/5 text-ink lg:bg-paper lg:shadow-xs":"text-ink/80 lg:hover:text-ink lg:hover:bg-ink/5"}`,children:[e(Wn,{size:13,"aria-hidden":"true"}),e("span",{className:"hidden lg:inline",children:"Graph"})]})]}),e("button",{type:"button",onClick:m,disabled:g,className:"tap-target flex items-center justify-center gap-1.5 p-2 rounded-md text-ink/70 transition-colors cursor-pointer text-xs disabled:opacity-40 lg:px-2.5 lg:py-1.5 lg:border lg:border-ink/15 lg:hover:bg-ink/5 lg:hover:text-ink",title:"Refresh commit history","aria-label":"Refresh commit history",children:[e(Da,{size:13,className:g?"animate-spin text-ink":"","aria-hidden":"true"}),e("span",{className:"hidden lg:inline",children:"Refresh"})]}),e("button",{type:"button",onClick:h,className:"tap-target p-2 -mr-1 rounded-md hover:bg-ink/5 text-muted hover:text-ink transition-colors cursor-pointer",title:"Close modal","aria-label":"Close commit history",children:e(b,{size:16,"aria-hidden":"true"})})]})]}),e("div",{className:"relative mt-1",children:[e(U,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-ink/55","aria-hidden":"true"}),e("input",{type:"text",value:c,onChange:(G)=>r(G.currentTarget.value),placeholder:"Filter commits by message, author, or hash...","aria-label":"Filter commits",className:"w-full bg-ink/[0.03] border border-ink/15 rounded-md pl-8 pr-3 py-1.5 text-xs text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors font-mono"}),c&&e("button",{type:"button",onClick:()=>r(""),"aria-label":"Clear filter",className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-ink/55 hover:text-ink cursor-pointer",children:e(b,{size:12,"aria-hidden":"true"})})]})]})}var de=["#38bdf8","#f97316","#a855f7","#10b981","#ec4899","#eab308","#06b6d4","#6366f1"];function Oe(t,l){if(!t||!l)return!1;if(t===l)return!0;let c=Math.min(t.length,l.length);if(c>=4)return t.substring(0,c)===l.substring(0,c);return!1}function we(t){let l=new Map,c=[];for(let r of t){if(typeof r.lane==="number"){l.set(r.hash,r.lane);continue}let m=c.findIndex((g)=>Oe(g,r.hash)||Oe(g,r.shortHash));if(m===-1)if(m=c.indexOf(null),m===-1)m=c.length,c.push(r.hash);else c[m]=r.hash;l.set(r.hash,m);let h=r.parents&&r.parents[0];if(h)c[m]=h;else c[m]=null;if(r.parents&&r.parents.length>1)for(let g=1;g<r.parents.length;g++){let v=r.parents[g];if(!c.some((A)=>Oe(A,v))){let A=c.indexOf(null);if(A===-1)c.push(v);else c[A]=v}}}return l}function it(t,l,c,r){let m=[],h=new Map;t.forEach((g,v)=>{if(h.set(g.hash,v),g.shortHash)h.set(g.shortHash,v);if(g.hash.length>=7)h.set(g.hash.substring(0,7),v)});for(let g of t){let v=l.get(g.hash)??0,w=c[g.hash]??0,A=de[v%de.length];if(!g.parents||g.parents.length===0)continue;for(let R of g.parents){let C=h.get(R);if(typeof C!=="number"&&R.length>=7)C=h.get(R.substring(0,7));if(typeof C==="number"){let G=t[C],M=l.get(G.hash)??v,L=c[G.hash]??w+60;m.push({fromHash:g.hash,toHash:G.hash,fromLane:v,toLane:M,fromY:w,toY:L,color:de[v%de.length]})}else m.push({fromHash:g.hash,toHash:"tail-"+g.hash,fromLane:v,toLane:v,fromY:w,toY:Math.max(w+80,r),color:A})}}return m}function at(t,l,c,r){if(Math.abs(t-c)<1)return`M ${t} ${l} L ${c} ${r}`;let m=r-l,h=l+m*0.45,g=r-m*0.45;return`M ${t} ${l} C ${t} ${h}, ${c} ${g}, ${c} ${r}`}function ut({commits:t,nodePositions:l,expandedHash:c,hoveredHash:r,isGraphMode:m,laneWidth:h=18,paddingLeft:g=16,totalHeight:v}){let w=u(()=>{if(!m){let G=new Map;return t.forEach((M)=>G.set(M.hash,0)),G}return we(t)},[t,m]),A=u(()=>{let G=0;return w.forEach((M)=>{if(M>G)G=M}),G},[w]),R=m?(A+1)*h+g*2:36,C=u(()=>{if(!m){let G=[];for(let M=0;M<t.length-1;M++){let L=l[t[M].hash]??M*60+20,y=l[t[M+1].hash]??(M+1)*60+20;G.push({fromHash:t[M].hash,toHash:t[M+1].hash,fromLane:0,toLane:0,fromY:L,toY:y,color:"var(--theme-ink)"})}return G}return it(t,w,l,v)},[t,w,l,v,m]);return e("div",{className:"absolute top-0 left-0 pointer-events-none z-10",style:{width:R,height:v},"aria-hidden":"true",children:e("svg",{className:"w-full h-full overflow-visible",style:{width:R,height:v},children:[C.map((G)=>{let M=m?g+G.fromLane*h:16,L=m?g+G.toLane*h:16,y=m?G.color:"currentColor",x=m?0.95:0.25,k=at(M,G.fromY,L,G.toY);return e("path",{d:k,fill:"none",stroke:y,strokeWidth:m?2.25:1.5,strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:x},`${G.fromHash}->${G.toHash}`)}),t.map((G)=>{let M=w.get(G.hash)??0,L=m?g+M*h:16,y=l[G.hash]??20,x=c===G.hash||c===G.shortHash,k=r===G.hash||r===G.shortHash,D=m?de[M%de.length]:"var(--theme-success)";return e("g",{"data-commit-node":G.hash,children:[(x||k)&&e("circle",{cx:L,cy:y,r:8,fill:D,fillOpacity:x?0.35:0.2,stroke:D,strokeWidth:1}),e("circle",{"data-commit-dot":"",cx:L,cy:y,r:m?4:4.5,fill:m?"var(--theme-paper)":D,stroke:D,strokeWidth:m?2.5:1.5}),m&&e("circle",{cx:L,cy:y,r:1.8,fill:D})]},`node-${G.hash}`)})]})})}var qt=[{action:"checkout",label:"checkout"},{action:"create_branch_here",label:"create branch here"},{action:"cherry_pick",label:"cherry-pick"},{action:"revert",label:"revert"},{action:"reset",label:"reset..."},{action:"merge",label:"merge into current"},{action:"rebase",label:"rebase onto this"}];function ft({commit:t,onAction:l}){return e("div",{className:"flex flex-wrap items-center gap-1.5 pt-1.5 pb-2",children:qt.map(({action:c,label:r})=>e("button",{type:"button",onClick:(m)=>{m.stopPropagation(),l(c,t)},className:"px-2.5 py-1 text-[11px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer",children:r},c))})}var Re=3;function Kt(t){let l=[];for(let c=0;c<t.length;c+=1){if(t[c].type!=="context"){l.push({row:t[c],index:c});continue}let r=c;while(r<t.length&&t[r].type==="context")r+=1;let m=r-c;if(m>Re*2+1){for(let h=c;h<c+Re;h+=1)l.push({row:t[h],index:h});l.push({row:{type:"elided",count:m-Re*2},index:-1});for(let h=r-Re;h<r;h+=1)l.push({row:t[h],index:h})}else for(let h=c;h<r;h+=1)l.push({row:t[h],index:h});c=r-1}return l}function ht({diffText:t,isLoading:l,filePath:c,fullContext:r=!1,onToggleContext:m}){let h=wi(),g=u(()=>{if(!t)return[];let R=[],C=1,G=1,M=t.split(/\r?\n/),y=M.some((x)=>x.startsWith("@@"))?M:[`@@ -0,0 +1,${M.length} @@`,...M.map((x)=>x.startsWith("+")||x.startsWith("-")?x:`+${x}`)];for(let x of y){if(x.startsWith("diff --git")||x.startsWith("index ")||x.startsWith("---")||x.startsWith("+++")||x.startsWith("new file mode")||x.startsWith("deleted file mode")||x.startsWith("similarity index")||x.startsWith("old mode")||x.startsWith("new mode")||x.startsWith("\\ No newline"))continue;if(x.startsWith("@@")){let k=x.match(/@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(k)C=parseInt(k[1],10),G=parseInt(k[2],10);R.push({type:"meta",text:x})}else if(x.startsWith("+"))R.push({type:"add",text:x.slice(1),newNum:G++});else if(x.startsWith("-"))R.push({type:"del",text:x.slice(1),oldNum:C++});else{let k=x.startsWith(" ")?x.slice(1):x;R.push({type:"context",text:k,oldNum:C++,newNum:G++})}}return R},[t]),v=mt(c),w=u(()=>{let R=Array(g.length).fill(""),C=-1,G=(M)=>{if(C<0)return;let L=xd(g.slice(C,M).map((y)=>y.text).join(`
|
|
3
|
-
`),v);for(let y=C;y<M;y++)R[y]=L[y-C]??"";C=-1};return g.forEach((M,L)=>{if(M.type==="meta")G(L);else if(C<0)C=L}),G(g.length),R},[g,v,h]),A=u(()=>r?g.map((R,C)=>({row:R,index:C})):Kt(g),[g,r]);if(l)return e("div",{className:"my-2 p-4 rounded bg-canvas border border-ink/10 text-muted font-mono text-xs flex items-center justify-center",children:"Loading commit diff..."});if(!t||g.length===0)return e("div",{className:"my-2 p-3 rounded bg-canvas border border-ink/10 text-muted font-mono text-xs text-center",children:"No diff content available for this file."});return e("div",{className:"my-2 rounded border border-ink/15 bg-paper overflow-hidden text-[11px] font-mono leading-relaxed text-ink",children:[e("div",{className:"flex items-center justify-between px-3 py-1.5 bg-canvas border-b border-ink/10 text-ink/70 text-[10.5px]",children:[e("span",{className:"font-semibold text-muted",children:"Diff preview"}),e("button",{type:"button",onClick:m,disabled:!m,className:"hover:text-ink flex items-center gap-1 cursor-pointer transition-colors disabled:opacity-40 disabled:cursor-default",title:r?"Show only the changed hunks":"Read the whole file around the change","aria-pressed":r,children:r?e(d,{children:[e(ct,{size:12,"aria-hidden":"true"})," Collapse context"]}):e(d,{children:[e(B,{size:12,"aria-hidden":"true"})," Expand all context"]})})]}),e("div",{className:"overflow-x-auto max-h-72 select-text",children:e("div",{className:"w-max min-w-full divide-y divide-ink/[0.04]",children:A.map(({row:R,index:C},G)=>{if(R.type==="elided")return e("div",{className:"px-3 py-1 bg-canvas text-muted text-[10px] text-center select-none",title:`${R.count} unchanged line(s) hidden`,children:["⋯ ",R.count," unchanged line",R.count===1?"":"s"," hidden ⋯"]},`elided-${G}`);let M=R,L=C;if(M.type==="meta")return e("div",{className:"flex items-center gap-2 px-3 py-1 bg-canvas border-y border-ink/10 text-muted text-[10px] font-semibold",children:[e("span",{children:"↕"}),e("span",{children:M.text})]},L);let y=M.type==="add",x=M.type==="del";return e("div",{className:`flex items-start font-mono ${y?"bg-success/10 hover:bg-success/15":x?"bg-error/10 hover:bg-error/15":"text-ink hover:bg-ink/[0.02]"}`,children:[e("div",{className:`w-10 flex-shrink-0 text-right pr-2 py-0.5 select-none border-r border-ink/10 text-[10px] tabular-nums font-mono ${x?"bg-error/15 text-ink/80 font-semibold":y?"bg-success/15 text-ink/80":"bg-canvas/50 text-muted"}`,children:M.oldNum??(y?"+":"")}),e("div",{className:`w-10 flex-shrink-0 text-right pr-2 py-0.5 select-none border-r border-ink/10 text-[10px] tabular-nums font-mono ${y?"bg-success/15 text-ink/80 font-semibold":x?"bg-error/15 text-ink/80":"bg-canvas/50 text-muted"}`,children:M.newNum??(x?"-":"")}),e("div",{className:`w-4 flex-shrink-0 text-center py-0.5 select-none font-bold ${y||x?"text-ink/80":"opacity-0"}`,children:y?"+":x?"-":" "}),e("div",{className:"flex-1 py-0.5 pr-3 whitespace-pre text-ink",children:M.text?e("span",{className:"shiki",dangerouslySetInnerHTML:{__html:w[L]}}):" "})]},L)})})})]})}function gt({commit:t,isExpanded:l,onToggleExpand:c,onAction:r,onToggleFile:m,isExpandedFile:h,isLoadingFile:g,isFullContextFile:v,onToggleContext:w,fileDiffs:A,headerRef:R}){let[C,G]=n(!1),M=t.body?.trim()??"",L=M.length>0,y=t.files??[],x=y.length,k=x>0,D=L||k,F=(E)=>{E.stopPropagation(),navigator.clipboard.writeText(t.hash),G(!0),setTimeout(()=>G(!1),2000)},O=(E,H)=>{E.stopPropagation(),m(t.hash,H)},V=D?"border-b border-ink/5 transition-colors cursor-pointer hover:bg-ink/[0.015]":"border-b border-ink/5";return e("div",{onClick:D?c:void 0,"data-testid":"commit-row","data-commit-hash":t.hash,className:V,children:e("div",{className:"py-2.5 flex flex-col",children:[e("div",{className:"flex flex-col gap-1",children:[t.refs&&t.refs.length>0&&e("div",{className:"flex flex-wrap items-center gap-1.5 pb-0.5",children:t.refs.map((E,H)=>{let Q=E.includes("stash"),Y=E.includes("HEAD")||E.includes("main")||E.includes("master");return e("span",{className:`px-2 py-0.5 rounded text-[10px] font-mono border ${Q?"bg-warning/10 text-ink/80 border-warning/25 font-semibold":Y?"bg-ink/10 text-ink font-semibold border-ink/20":"bg-canvas text-muted border-ink/10 font-medium"}`,children:E},H)})}),e("div",{ref:R,className:"flex items-start gap-1.5",children:e("button",{type:"button",onClick:D?(E)=>{E.stopPropagation(),c()}:void 0,"aria-expanded":D?l:void 0,className:"flex flex-1 min-w-0 items-start gap-1.5 text-left cursor-pointer rounded focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ink/20",children:[e("span",{"data-commit-title":"",className:"text-[13px] font-semibold text-ink leading-snug break-words flex-1 min-w-0",children:t.message}),D&&e("span",{className:"text-ink/55 flex-shrink-0 mt-0.5","aria-hidden":"true",children:l?e(B,{size:13}):e(se,{size:13})})]})}),L&&l&&e("div",{className:"border-l-2 border-ink/15 pl-3 py-1",children:e(J,{content:M,className:"text-ink/70"})}),e("div",{className:"flex items-center gap-x-2 gap-y-0.5 text-[11px] text-muted font-mono flex-wrap",children:[e("span",{children:t.author}),e("span",{children:t.date}),e("button",{type:"button",onClick:F,title:"Copy commit hash","aria-label":`Copy commit hash ${t.shortHash}`,className:"inline-flex items-center gap-1 hover:text-ink transition-colors cursor-pointer text-ink/70",children:[e("span",{children:t.shortHash}),C?e(f,{size:11,className:"text-success-text","aria-hidden":"true"}):e(re,{size:11,"aria-hidden":"true"})]}),k&&e("span",{children:[x," ",x===1?"file":"files"]})]})]}),l&&e("div",{className:"mt-2",children:e(ft,{commit:t,onAction:r})}),k&&l&&e("div",{className:"mt-2 flex flex-col gap-1",children:y.map((E,H)=>{let Q=h(t.hash,E.file),Y=`${t.hash}:${E.file}`,z=A[Y]!==void 0?A[Y]:E.diff,_=g(t.hash,E.file),W=E.status==="A"?"text-success-text font-bold":E.status==="D"?"text-error-text font-bold":E.status==="R"?"text-meta-text font-bold":"text-info-text font-bold";return e("div",{className:"flex flex-col",children:[e("button",{type:"button",onClick:(oe)=>O(oe,E),"aria-expanded":Q,className:"flex w-full items-center gap-2 py-1 px-2 rounded text-[11.5px] font-mono text-ink/80 transition-colors group cursor-pointer border border-transparent hover:border-ink/10 text-left",children:[e("span",{className:`w-3.5 text-center flex-shrink-0 text-[11px] ${W}`,children:E.status||"M"}),e("span",{className:"truncate flex-1 min-w-0 text-ink/90 group-hover:text-ink font-medium",children:E.file}),e("span",{className:"flex items-center gap-1 text-[10.5px] tabular-nums flex-shrink-0 font-medium",children:[e("span",{className:"text-success-text",children:["+",E.additions]}),e("span",{className:"text-ink/30",children:"/"}),e("span",{className:"text-error-text",children:["-",E.deletions]})]}),e("span",{className:"text-ink/55 group-hover:text-ink flex-shrink-0",children:Q?e(B,{size:13,"aria-hidden":"true"}):e(se,{size:13,"aria-hidden":"true"})})]}),Q&&e("div",{className:"pl-4 pr-1",children:e(ht,{diffText:z,isLoading:_,filePath:E.file,fullContext:v(t.hash,E.file),onToggleContext:()=>w(t.hash,E)})})]},H)})})]})})}var xe=50;function Vt(t){if(!Array.isArray(t))return[];let l=[];for(let c of t){if(!c||typeof c!=="object")continue;let r=c;if(typeof r.file!=="string"||!r.file)continue;l.push({file:r.file,status:typeof r.status==="string"?r.status:"M",additions:typeof r.additions==="number"&&Number.isFinite(r.additions)?r.additions:0,deletions:typeof r.deletions==="number"&&Number.isFinite(r.deletions)?r.deletions:0,diff:typeof r.diff==="string"?r.diff:void 0})}return l}function Ie(t){if(!Array.isArray(t))return[];let l=[];for(let c of t){if(!c||typeof c!=="object")continue;let r=c,m=typeof r.hash==="string"&&r.hash?r.hash:"";if(!m)continue;l.push({hash:m,shortHash:typeof r.shortHash==="string"&&r.shortHash?r.shortHash:m.slice(0,8),author:typeof r.author==="string"?r.author:"Unknown",date:typeof r.date==="string"?r.date:typeof r.time==="string"?r.time:"",message:typeof r.message==="string"?r.message:"",body:typeof r.body==="string"?r.body:void 0,parents:Array.isArray(r.parents)?r.parents.filter((h)=>typeof h==="string"):[],refs:Array.isArray(r.refs)?r.refs.filter((h)=>typeof h==="string"):[],files:Vt(r.files),lane:typeof r.lane==="number"?r.lane:void 0})}return l}function xt({output:t,isGraphMode:l,rootPath:c,activeRepo:r}){let[m,h]=n(!1),[g,v]=n(t?.hasMore??t?.data?.length===xe),[w,A]=n(t?.total),R=u(()=>Ie(t?.data),[t?.data]),C=Array.isArray(t?.data)?t.data.length:0,[G,M]=n(R),[L,y]=n(C);o(()=>{if(M(R),y(C),v(t?.hasMore??C===xe),typeof t?.total==="number")A(t.total)},[R,C,t?.hasMore,t?.total]);let x=a(async()=>{if(m||!g)return;h(!0);try{let k=new FormData;if(k.set("actionType",l?"graph":"history"),k.set("limit",String(xe)),k.set("skip",String(L)),c)k.set("root",c);if(r)k.set("repo",r);let F=await(await fetch("/api/fs/git",{method:"POST",body:k})).json();if(F.success&&Array.isArray(F.data)){let O=Ie(F.data),V=F.data.length;if(M((E)=>{let H=new Set(E.map((Y)=>Y.hash)),Q=O.filter((Y)=>!H.has(Y.hash));return[...E,...Q]}),y((E)=>E+V),v(Boolean(F.hasMore??V===xe)),typeof F.total==="number")A(F.total)}else v(!1)}catch(k){console.error("Failed to load more commits:",k)}finally{h(!1)}},[m,g,l,L,c,r]);return{commits:G,hasMore:g,totalCount:w,isLoadingMore:m,handleLoadMore:x}}function bt({onExecuteAction:t,rootPath:l,activeRepo:c}){let[r,m]=n({}),[h,g]=n(new Set),[v,w]=n(new Set),[A,R]=n(new Set),C=a(async(y,x,k)=>{let D=`${y}:${x.file}`;w((F)=>new Set(F).add(D));try{let F=new FormData;if(F.set("actionType","commit_diff"),F.set("hash",y),F.set("file",x.file),k)F.set("full","1");if(l)F.set("root",l);if(c&&c!==".")F.set("repo",c);let V=await(await fetch("/api/fs/git",{method:"POST",body:F})).json();if(V&&typeof V.diff==="string")m((E)=>({...E,[D]:V.diff}));else if(V&&V.error)m((E)=>({...E,[D]:`// Error: ${V.error}`}))}catch(F){console.error("Failed to load file diff:",F);let O=F instanceof Error?F.message:"Network error";m((V)=>({...V,[D]:`// Error loading diff: ${O}`}))}finally{w((F)=>{let O=new Set(F);return O.delete(D),O})}},[l,c]),G=a(async(y,x)=>{let k=`${y}:${x.file}`,D=!h.has(k);if(g((F)=>{let O=new Set(F);if(O.has(k))O.delete(k);else O.add(k);return O}),D&&r[k]===void 0&&!x.diff)await C(y,x,!1)},[h,r,C]),M=a(async(y,x)=>{let k=`${y}:${x.file}`,D=!A.has(k);R((F)=>{let O=new Set(F);if(O.has(k))O.delete(k);else O.add(k);return O}),await C(y,x,D)},[A,C]),L=a((y,x)=>{if(!t)return;if(y==="checkout")t("checkout",void 0,{branch:x.hash});else if(y==="create_branch_here"){let k=window.prompt(`Create new branch at commit ${x.shortHash}:`,`branch-${x.shortHash}`);if(k?.trim())t("create_branch_at",void 0,{branch:k.trim(),hash:x.hash})}else if(y==="cherry_pick"){if(window.confirm(`Cherry-pick commit ${x.shortHash} onto current branch?`))t("cherry_pick",void 0,{hash:x.hash})}else if(y==="revert"){if(window.confirm(`Revert commit ${x.shortHash}?`))t("revert_commit",void 0,{hash:x.hash})}else if(y==="reset"){let k=window.prompt(`Reset current branch to ${x.shortHash} (soft, mixed, hard):`,"soft");if(k&&["soft","mixed","hard"].includes(k.toLowerCase()))t("reset_commit",void 0,{hash:x.hash,mode:k.toLowerCase()})}else if(y==="merge"){if(window.confirm(`Merge commit ${x.shortHash} into current branch?`))t("merge_commit",void 0,{hash:x.hash})}else if(y==="rebase"){if(window.confirm(`Rebase current branch onto commit ${x.shortHash}?`))t("rebase_commit",void 0,{hash:x.hash})}},[t]);return{fileDiffs:r,expandedFiles:h,loadingFiles:v,fullContextFiles:A,handleToggleFile:G,handleToggleContext:M,handleCommitAction:L}}function yt(t){let[l,c]=n({page:t,hash:""}),r=l.page===t?l.hash:"",m=a((h)=>{c((g)=>{let v=g.page===t&&g.hash===h;return{page:t,hash:v?"":h}})},[t]);return{expandedHash:r,toggleExpanded:m}}function Ue({output:t,onClose:l,onRefresh:c,onExecuteAction:r,rootPath:m,activeRepo:h}){if(o(()=>{if(!t)return;let j=(q)=>{if(q.key==="Escape")l()};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[t,l]),!t)return null;let[g,v]=n(()=>({title:t.title,graph:t.title.toLowerCase().includes("graph")}));if(g.title!==t.title)v({title:t.title,graph:t.title.toLowerCase().includes("graph")});let w=g.graph,A=(j)=>v((q)=>({...q,graph:j})),[R,C]=n(""),{expandedHash:G,toggleExpanded:M}=yt(t),[L,y]=n(!1),{commits:x,hasMore:k,totalCount:D,isLoadingMore:F,handleLoadMore:O}=xt({output:t,isGraphMode:w,rootPath:m,activeRepo:h}),{fileDiffs:V,expandedFiles:E,loadingFiles:H,fullContextFiles:Q,handleToggleFile:Y,handleToggleContext:z,handleCommitAction:_}=bt({onExecuteAction:r,rootPath:m,activeRepo:h}),W=u(()=>{if(!R.trim())return x;let j=R.toLowerCase().trim();return x.filter((q)=>q.message.toLowerCase().includes(j)||q.author.toLowerCase().includes(j)||q.shortHash.toLowerCase().includes(j)||q.hash.toLowerCase().includes(j)||q.refs?.some((ne)=>ne.toLowerCase().includes(j)))},[x,R]),oe=i(null),ie=i(null),be=i(null),ue=i({}),[fe,ve]=n({}),[Ge,Se]=n(800);o(()=>{let j=be.current;if(!j||!k||F||R.trim())return;let q=new IntersectionObserver((ne)=>{if(ne[0].isIntersecting)O()},{root:oe.current,threshold:0.1});return q.observe(j),()=>q.disconnect()},[k,F,R,O]);let ae=a(()=>{if(!oe.current||!ie.current)return;let j=oe.current.getBoundingClientRect(),q=oe.current.scrollTop,ne={};W.forEach((ge,De)=>{let Ce=ue.current[ge.hash];if(Ce){let me=Ce.getBoundingClientRect();ne[ge.hash]=me.top+me.height/2-j.top+q}else ne[ge.hash]=De*60+20}),ve(ne);let Le=ie.current.offsetHeight;Se(Math.max(Le,oe.current.clientHeight,600))},[W]);K(()=>{ae();let j=requestAnimationFrame(()=>{ae()});return()=>cancelAnimationFrame(j)},[ae,W,V,E,w,G]),o(()=>{let j=ie.current;if(!j)return;let q=new ResizeObserver(()=>{ae()});q.observe(j);for(let ne of Array.from(j.children))q.observe(ne);return()=>q.disconnect()},[ae,W]);let ee=u(()=>we(W),[W]),Pe=u(()=>{let j=0;return ee.forEach((q)=>{if(q>j)j=q}),j},[ee]),ye=18,ke=16,$e=w?(Pe+1)*ye+ke*2:36,Me=()=>{y(!0),c?.(),setTimeout(()=>y(!1),600)};return e("div",{className:"fixed inset-0 z-50 modal-scrim backdrop-blur-xs flex items-center justify-center p-0 lg:p-5",onClick:l,role:"dialog","aria-modal":"true","aria-label":t.title,children:e("div",{className:`glass-overlay bg-paper border-ink/20 shadow-2xl flex flex-col overflow-hidden
|
|
4
|
-
w-full h-full rounded-none border-0
|
|
5
|
-
lg:w-[min(94vw,1200px)] lg:h-[88vh] lg:rounded-xl lg:border
|
|
6
|
-
pt-[env(safe-area-inset-top,0px)] lg:pt-0`,onClick:(j)=>j.stopPropagation(),children:[e(rt,{isGraphMode:w,onToggleMode:A,searchQuery:R,onSearchChange:C,onRefresh:Me,onClose:l,isRefreshing:L,totalCommits:W.length,loadedCount:x.length,totalCount:D,hasMore:k}),e("div",{ref:oe,className:`flex-1 overflow-y-auto scrollbar-overlay-container relative select-text
|
|
7
|
-
px-3 lg:px-5
|
|
8
|
-
pl-[max(0.75rem,env(safe-area-inset-left,0px))] pr-[max(0.75rem,env(safe-area-inset-right,0px))]`,children:W.length===0?e("div",{className:"flex flex-col items-center justify-center py-20 text-muted font-mono text-xs",children:R.trim()?"No matching commits found.":"No commits in this branch."}):e("div",{className:"relative min-h-full pb-8",children:[e(ut,{commits:W,nodePositions:fe,expandedHash:G,isGraphMode:w,laneWidth:ye,paddingLeft:ke,totalHeight:Ge}),e("div",{ref:ie,className:"flex flex-col relative z-20",style:{paddingLeft:`${$e}px`},children:[W.map((j)=>e(gt,{commit:j,isExpanded:G===j.hash,onToggleExpand:()=>M(j.hash),onAction:_,onToggleFile:Y,isExpandedFile:(q,ne)=>E.has(`${q}:${ne}`),isLoadingFile:(q,ne)=>H.has(`${q}:${ne}`),isFullContextFile:(q,ne)=>Q.has(`${q}:${ne}`),onToggleContext:z,fileDiffs:V,headerRef:(q)=>{ue.current[j.hash]=q}},j.hash)),e("div",{ref:be,className:"pt-3 pb-4 px-4 flex items-center justify-center",children:F?e("div",{className:"flex items-center gap-2 text-xs text-muted font-mono py-2",children:[e(p,{size:14,className:"animate-spin text-info-text","aria-hidden":"true"}),e("span",{children:"Loading more commits..."})]}):k&&!R.trim()?e("button",{type:"button",onClick:O,className:"px-3 py-1.5 text-xs font-mono text-ink/70 hover:text-ink bg-ink/5 hover:bg-ink/10 rounded-md border border-ink/10 transition-colors cursor-pointer",children:"Load more commits..."}):W.length>10?e("div",{className:"text-[11px] font-mono text-muted py-2",children:["End of commit history (",typeof D==="number"&&D>0?D:x.length," commits)"]}):null})]})]})})]})})}function kt({children:t,onClose:l}){return e("div",{className:"fixed inset-0 z-50 modal-scrim flex items-center justify-center modal-safe",onClick:l,role:"dialog","aria-modal":"true",children:e("div",{className:"glass-overlay bg-paper border border-ink/20 rounded-lg shadow-xl flex flex-col overflow-hidden w-[min(94vw,420px)] max-h-[80vh]",onClick:(c)=>c.stopPropagation(),children:t})})}function Ct({modal:t,onClose:l,onConfirm:c}){if(!t)return null;return e(kt,{onClose:l,children:[e("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-ink/10",children:[e(I,{size:16,className:"text-error flex-shrink-0"}),e("h3",{className:"text-sm font-semibold text-ink",children:"Confirm Action"})]}),e("div",{className:"px-4 py-4 text-xs text-ink/80 leading-relaxed",children:t.message}),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:l,className:"px-3 py-1.5 rounded border border-ink/20 text-ink/70 hover:bg-ink/5 hover:text-ink transition-colors cursor-pointer text-xs",children:"Cancel"}),e("button",{type:"button",onClick:c,className:"px-3 py-1.5 rounded bg-error text-canvas hover:bg-error/90 transition-colors cursor-pointer text-xs font-medium",children:"Confirm"})]})]})}function Nt({isOpen:t,branchName:l,inputRef:c,onChange:r,onClose:m,onCreate:h}){if(!t)return null;let g=a(()=>{if(l.trim())h()},[l,h]);return e(kt,{onClose:m,children:[e("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-ink/10",children:[e(Wn,{size:16,className:"text-ink/60 flex-shrink-0"}),e("h3",{className:"text-sm font-semibold text-ink",children:"Create New Branch"})]}),e("div",{className:"px-4 py-4",children:e("input",{ref:c,type:"text",value:l,onChange:(v)=>r(v.currentTarget.value),onKeyDown:(v)=>{if(v.key==="Enter")g();if(v.key==="Escape")m()},placeholder:"branch-name",className:"w-full bg-canvas border border-ink/20 rounded px-3 py-2 text-xs focus:outline-none focus:border-ink/40 text-ink placeholder-ink/40 transition-colors"})}),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:m,className:"px-3 py-1.5 rounded border border-ink/20 text-ink/70 hover:bg-ink/5 hover:text-ink transition-colors cursor-pointer text-xs",children:"Cancel"}),e("button",{type:"button",onClick:g,disabled:!l.trim(),className:"px-3 py-1.5 rounded bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:"Create"})]})]})}function wt({branch:t,detached:l,onCheckout:c,onMerge:r,onRename:m,onDelete:h}){let g=t.current&&!l;return e("div",{className:"grid grid-cols-[1rem_minmax(0,1fr)_minmax(0,9.5rem)_4.25rem_4rem] 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:g&&e(f,{size:12,className:"text-ink","aria-label":"Current branch"})}),e("button",{type:"button",onClick:c,disabled:g,title:g?"Already on this branch":`Check out ${t.name}`,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(ce,{size:11,className:g?"text-ink/60 flex-shrink-0":"text-ink/40 flex-shrink-0"}),e("span",{className:`truncate text-xs ${g?"font-semibold text-ink":"text-ink/90"}`,children:t.name})]}),t.subject&&e("div",{className:"h-4 flex items-center pl-[18px] min-w-0",children:e("span",{className:"truncate text-[10px] text-ink/40",title:t.subject,children:t.subject})})]}),e("div",{className:"h-5 flex items-center justify-end min-w-0",children:e(Yt,{branch:t})}),e("div",{className:"h-5 flex items-center justify-end",children:t.date&&e("span",{className:"text-[10px] text-ink/40 truncate",children:t.date})}),e("div",{className:"h-5 flex items-center justify-end gap-0.5 touch-visible opacity-0 group-hover/row:opacity-100",children:[!g&&e("button",{type:"button",onClick:r,title:`Merge ${t.name} into the current branch`,"aria-label":`Merge ${t.name} into the current branch`,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(Wn,{size:11})}),e("button",{type:"button",onClick:m,title:`Rename ${t.name}`,"aria-label":`Rename ${t.name}`,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(Kn,{size:11})}),!g&&e("button",{type:"button",onClick:h,title:`Delete ${t.name}`,"aria-label":`Delete ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-error hover:bg-error/10 cursor-pointer transition-colors",children:e(N,{size:11})})]})]})}function Yt({branch:t}){if(t.gone)return e("span",{className:"text-[10px] font-mono text-warning border border-warning/30 rounded px-1 truncate",title:`${t.upstream} no longer exists on the remote — fetch --prune to drop it`,children:"gone"});if(!t.upstream)return e("span",{className:"text-[10px] font-mono text-ink/40 truncate",title:"No upstream: this branch has never been published",children:"unpublished"});return e("span",{className:"flex items-center gap-1 text-[10px] font-mono text-ink/50 min-w-0",children:[e("span",{className:"truncate",title:t.upstream,children:t.upstream}),(t.ahead>0||t.behind>0)&&e("span",{className:"tabular-nums text-ink/70 flex-shrink-0",children:[t.ahead>0&&`↑${t.ahead}`,t.behind>0&&`↓${t.behind}`]})]})}function Rt({branch:t,onClose:l,onSubmit:c}){if(!t)return null;return e(Xt,{branch:t,onClose:l,onSubmit:c})}function Xt({branch:t,onClose:l,onSubmit:c}){let[r,m]=n(t.name),[h,g]=n(!1),v=r.trim(),w=v===t.name,A=v.length>0&&!w,R=()=>{if(A)c(t.name,v,h)};return e(Z,{onClose:l,maxWidthClass:"max-w-[min(94vw,460px)]",header:e("div",{className:"flex items-center gap-2",children:[e("h2",{className:"text-sm font-semibold text-ink",children:"Rename branch"}),e("span",{className:"text-[10px] font-mono text-ink/50 truncate",children:t.name})]}),children:[e("div",{className:"px-5 py-4 flex flex-col gap-3",children:[e("div",{children:[e("label",{className:"text-[10px] uppercase tracking-wider text-ink/50 font-semibold",htmlFor:"branch-rename-input",children:"New name"}),e("input",{id:"branch-rename-input",type:"text",value:r,autoFocus:!0,onChange:(C)=>m(C.currentTarget.value),onKeyDown:(C)=>{if(C.key==="Enter")R();if(C.key==="Escape")l()},className:"mt-1 w-full bg-paper border border-ink/20 rounded px-2.5 py-1.5 text-xs font-mono text-ink focus:outline-none focus:border-ink/40 transition-colors"}),w&&v.length>0&&e("p",{className:"mt-1 text-[10px] text-ink/50",children:"The name is unchanged."})]}),e("div",{className:"text-[10px] font-mono text-ink/60 flex flex-col gap-0.5 border border-ink/10 rounded p-2 bg-canvas/40",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("span",{className:"text-ink/40",children:"upstream"}),e("span",{className:"truncate",children:t.upstream||"none (unpublished)"})]}),e("p",{className:"text-ink/40 leading-relaxed mt-0.5",children:"A local rename keeps this upstream unchanged — a plain push afterwards will refuse until the upstream matches the new name, which is what the remote option below does."})]}),e("label",{className:"flex items-start gap-2 text-[11px] text-ink/80 cursor-pointer select-none",children:[e("input",{type:"checkbox",checked:h,onChange:(C)=>g(C.currentTarget.checked),className:`${he} accent-ink cursor-pointer mt-0.5`}),e("span",{className:"flex flex-col gap-0.5",children:[e("span",{children:"Also rename it on the remote"}),e("span",{className:"text-[10px] font-mono text-ink/50",children:["git push -u ",t.upstream?t.upstream.split("/")[0]:"origin"," ",v||"<new>",e("br",{}),"git push ",t.upstream?t.upstream.split("/")[0]:"origin"," --delete ",t.name,e("br",{}),"git fetch --prune"]})]})]})]}),e("div",{className:"flex items-center justify-end gap-2 px-5 py-3 border-t border-ink/10",children:[e("button",{type:"button",onClick:l,className:"px-3 py-1.5 rounded border border-ink/20 text-ink/70 hover:bg-ink/5 hover:text-ink transition-colors cursor-pointer text-xs",children:"Cancel"}),e("button",{type:"button",onClick:R,disabled:!A,className:"px-3 py-1.5 rounded bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:"Rename"})]})]})}function Gt({branch:t,force:l,onForceChange:c,onClose:r,onConfirm:m}){if(!t)return null;return e(Z,{onClose:r,maxWidthClass:"max-w-[min(94vw,440px)]",header:e("div",{className:"flex items-center gap-2",children:[e(I,{size:15,className:"text-error flex-shrink-0"}),e("h2",{className:"text-sm font-semibold text-ink",children:"Delete branch"})]}),children:[e("div",{className:"px-5 py-4 flex flex-col gap-3 text-xs text-ink/80 leading-relaxed",children:[e("p",{children:["Delete ",e("span",{className:"font-mono font-semibold text-ink",children:t.name}),t.upstream&&e(d,{children:[" ","(tracks ",e("span",{className:"font-mono",children:t.upstream}),")"]}),"?"]}),e("div",{className:"text-[10px] font-mono text-ink/60 border border-ink/10 rounded p-2 bg-canvas/40 flex flex-col gap-0.5",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("span",{className:"text-ink/40",children:"last commit"}),e("span",{className:"truncate",children:t.subject||"–"})]}),e("div",{className:"flex items-center justify-between gap-2",children:[e("span",{className:"text-ink/40",children:"when"}),e("span",{children:t.date||"–"})]})]}),e("label",{className:"flex items-start gap-2 cursor-pointer select-none text-[11px]",children:[e("input",{type:"checkbox",checked:l,onChange:(h)=>c(h.currentTarget.checked),className:`${he} accent-error cursor-pointer mt-0.5`}),e("span",{className:"flex flex-col gap-0.5",children:[e("span",{className:"text-error font-medium",children:"Delete even if its commits are not merged"}),e("span",{className:"text-[10px] font-mono text-ink/50",children:["git branch ",l?"-D":"-d"," ",t.name]}),e("span",{className:"text-ink/50",children:"Without this, git refuses when the branch holds commits no other branch has. Leaving it off is the safe default."})]})]})]}),e("div",{className:"flex items-center justify-end gap-2 px-5 py-3 border-t border-ink/10",children:[e("button",{type:"button",onClick:r,className:"px-3 py-1.5 rounded border border-ink/20 text-ink/70 hover:bg-ink/5 hover:text-ink transition-colors cursor-pointer text-xs",children:"Cancel"}),e("button",{type:"button",onClick:()=>m(t.name),className:"px-3 py-1.5 rounded bg-error text-canvas hover:bg-error/90 transition-colors cursor-pointer text-xs font-medium",children:["Delete ",l?"(force)":""]})]})]})}function St({isOpen:t,rootPath:l,repo:c,currentBranch:r,detached:m,isBusy:h,onClose:g,onAction:v,onConfirmDelete:w}){let[A,R]=n([]),[C,G]=n(!1),[M,L]=n(null),[y,x]=n(""),[k,D]=n(null),[F,O]=n(null),[V,E]=n(!1),H=a(async()=>{G(!0),L(null);let z=new URLSearchParams({branches:"1",repo:c||"."});if(l)z.set("root",l);try{let _=await fetch(`/api/fs/git?${z.toString()}`),W=await _.json();if(W.success&&Array.isArray(W.branches))R(W.branches);else L(W.error||`Failed to read branches (HTTP ${_.status})`)}catch(_){L(_ instanceof Error?_.message:"Failed to read branches")}finally{G(!1)}},[l,c]);o(()=>{if(t)H()},[t,H]);let Q=i(!1);o(()=>{if(!t){Q.current=!1;return}if(Q.current&&!h)H();Q.current=h},[t,h,H]),o(()=>{if(!t)D(null),O(null),E(!1),x("")},[t]);let Y=u(()=>{let z=y.trim().toLowerCase();if(!z)return A;return A.filter((_)=>_.name.toLowerCase().includes(z)||_.upstream.toLowerCase().includes(z))},[A,y]);if(!t)return null;return e(d,{children:[e(Z,{onClose:g,maxWidthClass:"max-w-[min(96vw,720px)]",header:e("div",{className:"flex items-center gap-2 min-w-0",children:[e("h2",{className:"text-sm font-semibold text-ink",children:"Branches"}),e("span",{className:"text-[10px] font-mono text-ink/50",children:m?`detached at ${r}`:`on ${r}`})]}),children:[e("div",{className:"px-5 py-3 flex items-center gap-2 border-b border-ink/10",children:[e(U,{size:12,className:"text-ink/40 flex-shrink-0"}),e("input",{type:"text",value:y,onChange:(z)=>x(z.currentTarget.value),placeholder:"Filter branches…","aria-label":"Filter branches",className:"flex-1 min-w-0 bg-transparent outline-none text-xs text-ink placeholder-ink/40",autoFocus:!0}),e("button",{type:"button",onClick:()=>void H(),disabled:C,title:"Refresh","aria-label":"Refresh branches",className:"text-ink/40 hover:text-ink transition-colors cursor-pointer disabled:opacity-40 flex-shrink-0",children:e(S,{size:12,className:C?"animate-spin":""})})]}),e("div",{className:"min-h-[40vh] max-h-[60vh] overflow-y-auto scrollbar-overlay-container",children:C&&A.length===0?e("div",{className:"flex items-center justify-center gap-2 py-12 text-xs text-ink/50 font-mono",children:[e(p,{size:14,className:"animate-spin text-info"}),"Loading branches…"]}):M?e("div",{className:"py-12 px-6 text-center text-xs text-error font-mono",children:M}):Y.length===0?e("div",{className:"py-12 text-center text-xs text-ink/40 font-mono",children:y.trim()?"No matching branches.":"No branches."}):Y.map((z)=>e(wt,{branch:z,detached:m,onCheckout:()=>{v("checkout",{branch:z.name}),g()},onMerge:()=>{v("merge_branch",{branch:z.name}),g()},onRename:()=>D(z),onDelete:()=>{O(z),E(!1)}},z.name))})]}),e(Rt,{branch:k,onClose:()=>D(null),onSubmit:(z,_,W)=>{v("rename_branch",{branch:z,newName:_,...W?{remote:"1"}:{}}),D(null)}},k?.name??"none"),e(Gt,{branch:F,force:V,onForceChange:E,onClose:()=>{O(null),E(!1)},onConfirm:(z)=>{w(z,V),O(null),E(!1)}})]})}function Pt({mounted:t,confirmModal:l,onCloseConfirm:c,onConfirm:r,branchPrompt:m,newBranchName:h,newBranchInputRef:g,onNewBranchNameChange:v,onCloseBranchPrompt:w,onCreateBranch:A,viewingOutput:R,onCloseOutput:C,onRefreshOutput:G,onExecuteAction:M,branchModalOpen:L,onCloseBranchModal:y,rootPath:x,activeRepo:k,currentBranch:D,detached:F,isBusy:O,onBranchAction:V,onConfirmDeleteBranch:E}){if(!t)return null;return e(d,{children:[e(Ct,{modal:l,onClose:c,onConfirm:r}),e(Nt,{isOpen:m,branchName:h,inputRef:g,onChange:v,onClose:w,onCreate:A}),e(Ue,{output:R,onClose:C,onRefresh:G,onExecuteAction:M,rootPath:x,activeRepo:k}),e(St,{isOpen:L,rootPath:x,repo:k,currentBranch:D,detached:F,isBusy:O,onClose:y,onAction:V,onConfirmDelete:E})]})}function $t({rootPath:t,repo:l,isBusy:c,onAction:r}){let[m,h]=T("git.stashExpanded",!1),[g,v]=n([]),[w,A]=n(!1),[R,C]=n(""),[G,M]=n(!1),L=Ir(),y=a(async()=>{A(!0);let k=new URLSearchParams({stashes:"1",repo:l||"."});if(t)k.set("root",t);try{let F=await(await fetch(`/api/fs/git?${k.toString()}`)).json();v(F.stashes??[])}catch{v([])}finally{A(!1)}},[t,l]);o(()=>{if(m)y()},[m,y,c]);let x=(k,D)=>{if(r(k,D),k==="stash_push")C(""),M(!1)};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:()=>h(!m),"aria-expanded":m,"aria-controls":L,title:m?"Hide stashes":"Show stashes",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:m?"▾":"▸"}),e(lt,{size:12}),e("span",{children:"Stash"}),g.length>0&&e("span",{className:"font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[10px] text-ink/50",children:g.length})]}),e("button",{type:"button",onClick:()=>x("stash_push",{...R.trim()?{message:R.trim()}:{},...G?{untracked:"1"}:{}}),disabled:c,title:"Stash the working tree",className:"mr-3 flex flex-shrink-0 items-center gap-1 px-2 py-0.5 text-[10px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/70 hover:text-ink transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",children:[e(P,{size:10}),"Save"]})]}),e("div",{className:"section-reveal","data-expanded":m,id:L,inert:!m,children:e("div",{children:e("div",{className:"px-3 pb-2 flex flex-col gap-1.5",children:[e("div",{className:"flex items-center gap-1.5",children:[e("input",{type:"text",value:R,onChange:(k)=>C(k.currentTarget.value),placeholder:"Stash message (optional)","aria-label":"Stash message",className:"flex-1 min-w-0 bg-paper border border-ink/20 rounded px-2 py-1 text-[11px] text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors font-mono"}),e("label",{className:"flex items-center gap-1 text-[10px] text-ink/60 cursor-pointer select-none flex-shrink-0",title:"Also stash untracked files (-u)",children:[e("input",{type:"checkbox",checked:G,onChange:(k)=>M(k.currentTarget.checked),className:`${he} accent-ink cursor-pointer`}),"-u"]})]}),w&&g.length===0?e("div",{className:"text-[10px] text-ink/40 italic py-1",children:"Loading…"}):g.length===0?e("div",{className:"text-[10px] text-ink/40 italic py-1",children:"No stash entries."}):e("div",{className:"max-h-40 overflow-y-auto scrollbar-overlay-container flex flex-col",children:g.map((k)=>e("div",{className:"grid grid-cols-[4rem_minmax(0,1fr)_3.5rem_4.5rem] items-center gap-x-1 group/stash py-0.5",children:[e("span",{className:"text-[10px] font-mono text-ink/50 truncate",children:k.ref}),e("span",{className:"min-w-0 truncate text-[10px] text-ink/80",title:k.subject,children:k.subject}),e("span",{className:"text-[10px] text-ink/40 text-right truncate",children:k.date}),e("div",{className:"flex items-center justify-end gap-0.5 touch-visible opacity-0 group-hover/stash:opacity-100",children:[e("button",{type:"button",onClick:()=>x("stash_apply",{ref:k.ref,pop:"1"}),disabled:c,title:"Pop: apply and remove the entry","aria-label":"Pop stash",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors disabled:opacity-40",children:e(Ae,{size:10})}),e("button",{type:"button",onClick:()=>x("stash_apply",{ref:k.ref}),disabled:c,title:"Apply: keep the entry","aria-label":"Apply stash",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors disabled:opacity-40",children:e(lt,{size:10})}),e("button",{type:"button",onClick:()=>x("stash_drop",{ref:k.ref}),disabled:c,title:"Drop: discard the entry (the stash is not recoverable from the panel)","aria-label":"Drop stash",className:"w-5 h-5 flex items-center justify-center rounded hover:text-error hover:bg-error/10 cursor-pointer transition-colors disabled:opacity-40",children:e(N,{size:10})})]})]},k.ref))})]})})})]})}function Mt({repo:t,isBusy:l,onInit:c}){let r=t==="."?"this folder":t;return e("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 px-6 text-center",children:[e(ce,{size:26,className:"text-ink/25","aria-hidden":!0}),e("div",{className:"font-mono space-y-1",children:[e("p",{className:"text-xs text-ink/70",children:"Not a Git repository"}),e("p",{className:"text-[11px] leading-4 text-ink/40",children:["Initialize one in ",r," to track changes, commit and manage branches."]})]}),e("button",{type:"button",onClick:c,disabled:l,"aria-label":"Initialize Git repository",title:`git init in ${r}`,className:"flex items-center justify-center gap-1.5 px-3 py-1.5 rounded bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[e(ce,{size:12,"aria-hidden":!0}),"Initialize repository"]})]})}function Tt(t,l,c){let r=pt(),{pickedRepo:m,setActiveRepo:h,ready:g}=br(t),{repos:v,scanning:w,rescan:A}=yr(t,l),R=Wg(m,v),C=i(R);C.current=R;let G=i("");G.current=`${t??""}\x00${R}`;let M=i(""),L=i(""),y=i(void 0);if(r.data!==y.current)y.current=r.data,L.current=M.current;let x=l&&g?km(`${t??""}\x00${R}`):null,k=_e(x),D=i(k.refresh);D.current=k.refresh;let F=L.current===G.current?r.data:void 0,O=k.data??F,V=O?.syncCount??F?.syncCount,E=a((Y)=>{if(!l)return;let z=Y??C.current,_=new URLSearchParams;if(t)_.set("root",t);if(z)_.set("repo",z);_.set("sync","1"),_.set("t",String(Date.now())),M.current=G.current;let W=D.current;r.load(`/api/fs/git?${_.toString()}`).then(()=>W())},[l,t,r.load]);o(()=>{if(!g)return;E()},[c,t,l,g,R,E]);let H=r.state==="loading",Q=H||k.refreshing;return{activeRepo:R,setActiveRepo:h,repos:v,reposScanning:w,refreshRepos:A,isReading:H,isRefreshing:Q,data:O,syncCount:V,loadRepo:E,refreshTopic:k.refresh}}function At(t,l){let c=pt(),r=i(null),m=a((h,g,v)=>{r.current={actionType:h,extra:v};let w=new FormData;if(w.append("actionType",h),w.append("repo",l),t)w.append("root",t);if(g)w.append("file",g);if(v)Object.entries(v).forEach(([A,R])=>w.append(A,R));c.submit(w,{method:"POST",action:"/api/fs/git"})},[l,t,c]);return{state:c.state,execute:m,data:c.data,lastAction:r.current}}function Lt({rootPath:t,repo:l,execute:c}){let{sessionId:r}=wm(),[m,h]=T("git.commitDraft",""),[g,v]=T("git.amend",!1),[w,A]=n(!1),[R,C]=n(null),[G,M]=n(!1),L=i(!1),y=i(null),x=i(m);x.current=m;let k=i(g);k.current=g;let D=i(h);D.current=h;let F=a((Y)=>{h(Y),M(!1)},[h]),O=a(()=>{if(L.current)return;L.current=!0,A(!0),C(null);let Y={...t?{root:t}:{},repo:l,...r?{sessionId:r}:{},...k.current?{amend:!0}:{}};fetch("/api/fs/git-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Y)}).then(async(z)=>{let _=await z.json().catch(()=>null);if(!z.ok||typeof _?.message!=="string"||!_.message.trim())throw Error(typeof _?.error==="string"?_.error:`Request failed (HTTP ${z.status})`);let W=_.message.trim();if(x.current.trim().length===0)D.current(W),M(!0);else C(W)}).catch((z)=>{Cl(z instanceof Error?z.message:String(z),"error")}).finally(()=>{L.current=!1,A(!1)})},[t,l,r]),V=a(()=>{if(R===null)return;h(R),M(!0),C(null)},[R,h]),E=a(()=>C(null),[]);o(()=>{if(!g)return;if(x.current.trim().length>0)return;let Y=new URLSearchParams({headMessage:"1"});if(t)Y.set("root",t);if(l&&l!==".")Y.set("repo",l);let z=!1;return fetch(`/api/fs/git?${Y.toString()}`).then((_)=>_.json()).then((_)=>{if(z)return;if(!k.current||x.current.trim().length>0)return;let W=typeof _?.message==="string"?_.message:"";if(W.length===0)return;y.current=W,D.current(W)}).catch(()=>{}),()=>{z=!0}},[g,r,t,l]);let H=a((Y)=>{if(Y){v(!0);return}if(y.current!==null&&x.current===y.current)h("");y.current=null,v(!1)},[v,h]),Q=a(()=>{c("commit",void 0,{message:x.current,...k.current?{amend:"1"}:{}}),h(""),v(!1),y.current=null,C(null),M(!1)},[c,v,h]);return{message:m,setMessage:F,amend:g,seeded:y.current!==null&&m===y.current,toggleAmend:H,commit:Q,isGenerating:w,suggestion:R,generated:G,generate:O,useSuggestion:V,dismissSuggestion:E}}var Dt=48;function Zt(t,l){let c=l?.branch?.trim()??"",r=(l?.hash??"").slice(0,7),m=l?.ref?.trim()||"stash@{0}";switch(t){case"init":return{done:"Initialized the repository"};case"fetch":return{done:"Fetched every remote"};case"push":return{done:"Pushed to upstream"};case"pull":return{done:"Pulled from upstream",stopped:"Pulled"};case"sync":return{done:"Synced with upstream",stopped:"Pulled, but nothing was pushed"};case"abort_operation":return{done:"Aborted the operation in progress"};case"continue_operation":return{done:"Concluded the operation"};case"commit":{if(l?.amend==="1")return{done:"Amended the last commit"};let h=(l?.message??"").split(`
|
|
9
|
-
`)[0].trim();if(!h)return{done:"Commit created"};return{done:`Committed “${h.length>Dt?`${h.slice(0,Dt-1)}…`:h}”`}}case"checkout":return{done:c?`Switched to ${c}`:"Switched branch"};case"create_branch":case"create_branch_at":return{done:c?`Created branch ${c}`:"Created branch"};case"rename_branch":{let h=l?.newName?.trim()??"";return{done:c&&h?`Renamed ${c} to ${h}`:"Renamed branch"}}case"delete_branch":return{done:c?`Deleted branch ${c}`:"Deleted branch"};case"merge_branch":return{done:c?`Merged ${c}`:"Merged branch",stopped:c?`Merging ${c}`:"Merging the branch"};case"merge_commit":return{done:r?`Merged commit ${r}`:"Merged commit",stopped:r?`Merging ${r}`:"Merging the commit"};case"cherry_pick":return{done:r?`Cherry-picked ${r}`:"Cherry-picked commit",stopped:r?`Cherry-picking ${r}`:"Cherry-picking the commit"};case"revert_commit":return{done:r?`Reverted commit ${r}`:"Reverted commit",stopped:r?`Reverting ${r}`:"Reverting the commit"};case"rebase_commit":return{done:r?`Rebased onto ${r}`:"Rebased",stopped:r?`Rebasing onto ${r}`:"Rebasing"};case"reset_commit":{let h=l?.mode??"mixed";return{done:r?`Reset to ${r} (${h})`:`Reset (${h})`}}case"stash_push":return{done:"Stashed your changes"};case"stash_apply":return{done:l?.pop==="1"?`Popped ${m}`:`Applied ${m}`,stopped:l?.pop==="1"?`Popping ${m}`:`Applying ${m}`};case"stash_drop":return{done:`Dropped ${m}`};default:return null}}function Et({actionType:t,extra:l,stopped:c}){let r=Zt(t,l);if(!c)return r?.done??null;let m=Qo[c]??c,h=r?.stopped??r?.done??"",g=t==="sync"?"resolve it above, then Sync again":"resolve it above";return h?`${h} — the ${m} stopped on a conflict; ${g}`:`The ${m} stopped on a conflict; ${g}`}function Bt(t){let{fetcher:l,onPage:c,onReload:r,onSuccess:m,onError:h}=t,g=i(null),v=i({onPage:c,onReload:r,onSuccess:m,onError:h});v.current={onPage:c,onReload:r,onSuccess:m,onError:h},o(()=>{if(l.state!=="idle"||!l.data)return;let w=l.data;if(w===g.current)return;g.current=w;let A=v.current;if(w.type==="history"||w.type==="graph"){A.onPage({title:w.type==="graph"?"Git Graph":"Commit History",data:w.data||[],hasMore:w.hasMore,total:w.total});return}if(!w.success){A.onError(w.error||"Git operation failed");return}A.onReload();let R=l.lastAction,C=R?Et({...R,stopped:w.stopped}):null;if(C)A.onSuccess(C,w.stopped?"warning":"success")},[l.state,l.data,l.lastAction])}function Ft(t,l,c,r){if(t==="revert")return{type:t,file:l,message:`Are you sure you want to discard changes in ${l}?`};if(t==="revert_all")return{type:t,message:"Are you sure you want to discard ALL unstaged changes? This cannot be undone."};if(t==="abort_operation"){let m=r?Qo[r]:"operation";return{type:t,message:`Abort the ${m}? Everything resolved so far is discarded and the working tree returns to its pre-${m} state.`}}if(t==="delete_branch"){let m=c?.branch??"",h=c?.force==="1";return{type:t,extra:{branch:m,...h?{force:"1"}:{}},message:h?`Delete branch ${m} even though its commits are not merged? This cannot be undone from the panel.`:`Delete branch ${m}?`}}if(t==="stash_drop"){let m=c?.ref||"the top entry";return{type:t,extra:{ref:c?.ref??""},message:`Drop ${m}? The stash entry is removed — this cannot be undone from the panel.`}}return null}function Nr({className:t="",enabled:l=!0,rootPath:c,refreshKey:r=0}){let{activeRepo:m,setActiveRepo:h,repos:g,reposScanning:v,refreshRepos:w,isReading:A,isRefreshing:R,data:C,syncCount:G,loadRepo:M,refreshTopic:L}=Tt(c,l,r),y=At(c,m),[x,k]=T("git.viewMode","flat"),[D,F]=n(!1),O=i(null),[V,E]=n(!1),H=i(null),[Q,Y]=n(null),[z,_]=n(!1),[W,oe]=n(""),ie=i(null),[be,ue]=n(!1),[fe,ve]=n(null),[Ge,Se]=n(!1),{pushToast:ae}=je();o(()=>{Se(!0)},[]),o(()=>{if(z&&ie.current)ie.current.focus()},[z]),Bt({fetcher:y,onPage:ve,onReload:M,onSuccess:(X,te)=>ae(X,te),onError:(X)=>ae(X,"error")}),pe(O,()=>F(!1)),pe(H,()=>E(!1));let ee=y.execute,{message:Pe,setMessage:ye,amend:ke,seeded:$e,toggleAmend:Me,commit:j,isGenerating:q,suggestion:ne,generated:Le,generate:ge,useSuggestion:De,dismissSuggestion:Ce}=Lt({rootPath:c,repo:m,execute:ee}),me=(X,te,Ne)=>{let Ke=Ft(X,te,Ne,C?.state?.operation??null);if(Ke){Y(Ke);return}ee(X,te,Ne)},Ht=(X,te)=>{ee("resolve_conflict",X,te?{side:te}:void 0)},We=C?.branch||"main",zt=C?.branches||["main"],Ot=C?.remoteBranches||[],qe=C?.changes||[],le=A||y.state!=="idle",Be=y.state==="idle"?null:y.lastAction?.actionType??null,It=Be==="sync"||Be==="push"||Be==="pull",_t=qe.filter((X)=>{if(Lr(X.status))return!1;let te=X.status;return te&&te[0]!==" "&&te[0]!=="?"});if(!l)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"})});return e("div",{className:`flex flex-col h-full bg-paper relative ${t}`,children:[e(Pt,{mounted:Ge,confirmModal:Q,onCloseConfirm:()=>Y(null),onConfirm:()=>{if(Q)ee(Q.type,Q.file,Q.extra),Y(null)},branchPrompt:z,newBranchName:W,newBranchInputRef:ie,onNewBranchNameChange:oe,onCloseBranchPrompt:()=>{_(!1),oe("")},onCreateBranch:()=>{if(W.trim())ee("create_branch",void 0,{branch:W.trim()}),_(!1),oe("")},viewingOutput:fe,onCloseOutput:()=>ve(null),onRefreshOutput:()=>{if(fe)ee(fe.title.toLowerCase().includes("graph")?"graph":"history")},onExecuteAction:(X,te,Ne)=>ee(X,te,Ne),branchModalOpen:be,onCloseBranchModal:()=>ue(!1),rootPath:c,activeRepo:m,currentBranch:We,detached:C?.state?.detached??!1,isBusy:le,onBranchAction:(X,te)=>ee(X,void 0,te),onConfirmDeleteBranch:(X,te)=>{ee("delete_branch",void 0,{branch:X,...te?{force:"1"}:{}})}}),e(et,{activeRepo:m,repos:g,isRefreshing:R,rootPath:c,reposScanning:v,onSelectRepo:(X)=>{if(X!==m)h(X)},onRefresh:()=>{L(),M()},onRefreshRepos:w}),C?.isRepo===!1?e(Mt,{repo:m,isBusy:le,onInit:()=>ee("init")}):e(d,{children:[e(Je,{branchRef:H,showBranchMenu:V,setShowBranchMenu:E,branch:We,branches:zt,remoteBranches:Ot,onCheckout:(X)=>ee("checkout",void 0,{branch:X}),onMerge:(X)=>ee("merge_branch",void 0,{branch:X}),onOpenBranchPrompt:()=>_(!0),onManageBranches:()=>{ue(!0),E(!1)},optionsRef:O,showOptions:D,setShowOptions:F,onHistory:()=>ee("history"),onGraph:()=>ee("graph"),viewMode:x,setViewMode:k,isBusy:le,syncCount:G,syncing:It,onSync:()=>ee("sync"),onFetch:()=>ee("fetch"),detached:C?.state?.detached??!1}),C?.state?.operation?e(Qe,{operation:C.state.operation,conflicts:C.state.conflicts,isBusy:le,onAbort:()=>me("abort_operation"),onContinue:()=>ee("continue_operation")}):e(Ze,{message:Pe,hasStagedChanges:_t.length>0,isBusy:le,amend:ke,seeded:$e,isGenerating:q,suggestion:ne,generated:Le,onToggleAmend:Me,onChangeMessage:ye,onCommit:j,onGenerate:ge,onUseSuggestion:De,onDismissSuggestion:Ce}),e(ot,{changes:qe,isLoading:le,viewMode:x,repo:m,rootPath:c,onAction:me,onResolve:Ht}),e($t,{rootPath:c,repo:m,isBusy:le,onAction:(X,te)=>me(X,void 0,te)})]})]})}export{Nr as GitPanel};
|