@kabmo-labs/kabmo 0.34.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/static/js/{CsvGrid-vze4m5ag.js → CsvGrid-0amzgtd7.js} +2 -2
- package/dist/client/static/js/{DocxView-jbf21gmh.js → DocxView-bxjhzxe9.js} +3 -3
- package/dist/client/static/js/{DrawioView-b52qybx5.js → DrawioView-7s1yqsf4.js} +2 -2
- package/dist/client/static/js/{ImageView-mdgzj8px.js → ImageView-ycfbn66h.js} +1 -1
- package/dist/client/static/js/{LayoutWrapper-3c49dvtt.js → LayoutWrapper-tw1q1x0g.js} +2 -2
- package/dist/client/static/js/{Modal-sqp864vd.js → Modal-wqjactyd.js} +16 -16
- package/dist/client/static/js/{PdfView-g06rxqb1.js → PdfView-x6dmtwvr.js} +1 -1
- package/dist/client/static/js/{SessionsView-521adxyr.js → SessionsView-t85wq0me.js} +1 -1
- package/dist/client/static/js/{SheetView-h8xmsz7q.js → SheetView-n52nvz8s.js} +13 -13
- package/dist/client/static/js/{SvgPreview-1j4jvcvz.js → SvgPreview-59z7syme.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-pasxh4b6.js → abnfDiagram-O67JEVCF-91gnt049.js} +1 -1
- package/dist/client/static/js/architecture-7GRP2DOG-bajpnvy7.js +1 -0
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-ms14g0bm.js → architectureDiagram-NJMV4G6O-5b9qtff2.js} +3 -3
- package/dist/client/static/js/{astro-80bs6hvg.js → astro-31cbyw7b.js} +1 -1
- package/dist/client/static/js/bash-0h36tk0k.js +1 -0
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-ycn78fcq.js → blockDiagram-BEXU5L5S-6f23fjkn.js} +3 -3
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-vn2gpjfm.js → c4Diagram-YGBWAQC7-76t6d3am.js} +2 -2
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-fyrm1pr5.js → classDiagram-v2-NBCMYWYE-f9tb19xm.js} +3 -3
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-ea5nwvgq.js → cose-bilkent-JH36ORCC-t6nwrbwj.js} +1 -1
- package/dist/client/static/js/cpp-4wp9sy20.js +1 -0
- package/dist/client/static/js/css-c9nsbkh6.js +1 -0
- package/dist/client/static/js/cynefin-OW5HDTMX-8q9e90m8.js +1 -0
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-j6bsjpre.js → cynefinDiagram-VND7K2PF-69gc244j.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-4smdkwv8.js → dagre-6A5THRUB-54bry3ey.js} +2 -2
- package/dist/client/static/js/{diagram-22UHCM2B-9sm4kqwc.js → diagram-22UHCM2B-gfkebye6.js} +5 -5
- package/dist/client/static/js/{diagram-3UASUU5V-2h3qxaed.js → diagram-3UASUU5V-a1mr319f.js} +1 -1
- package/dist/client/static/js/{diagram-ATOU4E4O-1981bc94.js → diagram-ATOU4E4O-tkyk0qbe.js} +3 -3
- package/dist/client/static/js/{diagram-CDSNMT55-3vgsxavc.js → diagram-CDSNMT55-np0hc9m2.js} +2 -2
- package/dist/client/static/js/{diagram-MLGK6HIB-c9gf2r3f.js → diagram-MLGK6HIB-nh06fshp.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-gjqeq92d.js → diagram-MPIPVDR6-27q2veks.js} +1 -1
- package/dist/client/static/js/{dockerfile-8v935dkn.js → dockerfile-4rtt6c0f.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-4vbsgh99.js → ebnfDiagram-ZINNZB2B-x9p9jqe8.js} +1 -1
- package/dist/client/static/js/{elixir-vcbg60wv.js → elixir-rpa1g4gy.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-nca3t891.js → elk-276RUBZZ-fw7waks3.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-5kfkev03.js → erDiagram-OPXOYQCR-fdfgzr5d.js} +5 -5
- package/dist/client/static/js/{erlang-qt876zrq.js → erlang-trjm07as.js} +1 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-kn4hsm3p.js +1 -0
- package/dist/client/static/js/flowDiagram-KWPJA3E3-ah8cvps1.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-mxc73wmq.js → ganttDiagram-FUAMR5RP-2avbqgdr.js} +2 -2
- package/dist/client/static/js/gitGraph-4MIJSDKK-hvavh16n.js +1 -0
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-7en3ag0e.js → gitGraphDiagram-X574FWY7-9jmc0a3g.js} +2 -2
- package/dist/client/static/js/graphql-hbkmxsty.js +1 -0
- package/dist/client/static/js/html-pv88ny12.js +1 -0
- package/dist/client/static/js/{index-4g46wbdw.js → index-0v34a7wf.js} +1 -1
- package/dist/client/static/js/{index-vtbbfwx0.js → index-1wjp16f0.js} +2 -2
- package/dist/client/static/js/{index-7a64yjrm.js → index-2v1nmxwr.js} +5 -5
- package/dist/client/static/js/{index-rs80cwsv.js → index-3ecsp1rx.js} +3 -3
- package/dist/client/static/js/{index-1y9r4frb.js → index-43qpbxjv.js} +2 -2
- package/dist/client/static/js/{index-ag2rmtas.js → index-4vybd9e7.js} +1 -1
- package/dist/client/static/js/{index-ahv9y42z.js → index-6f6cmcbq.js} +2 -2
- package/dist/client/static/js/{index-vy6termr.js → index-7ct7qrsp.js} +2 -2
- package/dist/client/static/js/{index-fvmfge3p.js → index-7q02xnvq.js} +1 -1
- package/dist/client/static/js/{index-rytaa8ca.js → index-7smwzkvq.js} +2 -2
- package/dist/client/static/js/{index-nccwxv0s.js → index-8f9x7ev8.js} +1 -1
- package/dist/client/static/js/{index-7y6rpsrp.js → index-8mwragbj.js} +2 -2
- package/dist/client/static/js/{index-52rqxgya.js → index-8x9ecxb0.js} +1 -1
- package/dist/client/static/js/{index-ptcrwswj.js → index-9ketbkh6.js} +1 -1
- package/dist/client/static/js/{index-s7gkkkyz.js → index-a293pdg7.js} +2 -2
- package/dist/client/static/js/{index-vhqe0y82.js → index-a628fg4m.js} +2 -2
- package/dist/client/static/js/{index-c3ek61zv.js → index-a8ffattk.js} +2 -2
- package/dist/client/static/js/{index-a0fmsv1d.js → index-b8s3xraa.js} +6 -6
- package/dist/client/static/js/index-btr2w8cq.js +12 -0
- package/dist/client/static/js/index-dfzrpy54.js +2 -0
- package/dist/client/static/js/{index-g2dyfze9.js → index-ee2p07eg.js} +1 -1
- package/dist/client/static/js/{index-ybm2x4vh.js → index-ek2e773p.js} +1 -1
- package/dist/client/static/js/{index-4qwzxj81.js → index-fvc0x6nx.js} +3 -3
- package/dist/client/static/js/{index-3zc1b0dv.js → index-jc1yagmk.js} +2 -2
- package/dist/client/static/js/{index-p0nz38bm.js → index-jmxqefe3.js} +1 -1
- package/dist/client/static/js/{index-1ksg88qf.js → index-k7q01ye4.js} +2 -2
- package/dist/client/static/js/{index-r014brzs.js → index-kdkfyrja.js} +2 -2
- package/dist/client/static/js/{index-0vm41je9.js → index-mc4nefs7.js} +1 -1
- package/dist/client/static/js/{index-j51d5a5m.js → index-nb8tp4mj.js} +30 -30
- package/dist/client/static/js/{index-cgzrpvzj.js → index-ncrenheb.js} +172 -172
- package/dist/client/static/js/{index-f7jhhqtk.js → index-p16scjt7.js} +2 -2
- package/dist/client/static/js/{index-pm6xxwz1.js → index-pc6eg8h2.js} +2 -2
- package/dist/client/static/js/{index-zvfvqvn9.js → index-pnt0vc59.js} +2 -2
- package/dist/client/static/js/{index-jsyekbx9.js → index-py2k8std.js} +2 -2
- package/dist/client/static/js/{index-dbe6afkf.js → index-pzbssnsc.js} +2 -2
- package/dist/client/static/js/{index-qckv9nte.js → index-qqz6bcdd.js} +2 -2
- package/dist/client/static/js/{index-xx6mqpxm.js → index-rbgemjsp.js} +3 -3
- package/dist/client/static/js/{index-rzxcj7cg.js → index-rkn0bxxt.js} +1 -1
- package/dist/client/static/js/{index-76zb4m0n.js → index-rv89xpaf.js} +2 -2
- package/dist/client/static/js/index-sbd5e816.js +1 -0
- package/dist/client/static/js/{index-1b0t1428.js → index-sdby39w4.js} +3 -3
- package/dist/client/static/js/{index-ev3yt353.js → index-t6c0pd43.js} +2 -2
- package/dist/client/static/js/{index-km2zb6wk.js → index-tp7yb3bv.js} +2 -2
- package/dist/client/static/js/{index-fta1y9pc.js → index-vnw3hbeg.js} +27 -27
- package/dist/client/static/js/{index-354mqqra.js → index-vq6wts05.js} +2 -2
- package/dist/client/static/js/{index-ptcwae2n.js → index-w5373tg1.js} +2 -2
- package/dist/client/static/js/{index-cd65zqba.js → index-w7tpgt46.js} +1 -1
- package/dist/client/static/js/{index-b29afsjh.js → index-whbtxmwh.js} +2 -2
- package/dist/client/static/js/{index-2svnq5gg.js → index-xs1m0bpt.js} +1 -1
- package/dist/client/static/js/{index-eyfcm0cy.js → index-xxtsm2rb.js} +2 -2
- package/dist/client/static/js/{index-hf52f59k.js → index-y3ms153k.js} +2 -2
- package/dist/client/static/js/{index-sd66wv26.js → index-yq39qbs1.js} +2 -2
- package/dist/client/static/js/{index-j0r5hj0j.js → index-zh2jj56s.js} +2 -2
- package/dist/client/static/js/info-A6RAGUB7-fmjz8qwg.js +1 -0
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-sef80132.js → infoDiagram-VRGFBTTK-g2dky5xg.js} +1 -1
- package/dist/client/static/js/ini-72yrpvd4.js +1 -0
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-yhvepp1q.js → ishikawaDiagram-OU5B5YK6-exrcjwp1.js} +2 -2
- package/dist/client/static/js/java-ab5tb2ra.js +1 -0
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-5w77y95w.js → journeyDiagram-ZHPQQLJL-pn752qa5.js} +3 -3
- package/dist/client/static/js/jsx-25zj9j3k.js +1 -0
- package/dist/client/static/js/{julia-d4j6wgvf.js → julia-evn99h2m.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-02znqtna.js → kanban-definition-PNTS6WVX-v8nvr373.js} +2 -2
- package/dist/client/static/js/lua-j5w0c9wm.js +1 -0
- package/dist/client/static/js/markdown-j6hn4377.js +1 -0
- package/dist/client/static/js/{mermaid.core-a6e6vck4.js → mermaid.core-egzv89zv.js} +6 -6
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-y4n74q9x.js → mindmap-definition-NLK3R4M7-t9njmv2w.js} +2 -2
- package/dist/client/static/js/one-dark-pro-bm3r4js7.js +1 -0
- package/dist/client/static/js/one-light-e07dt7sy.js +1 -0
- package/dist/client/static/js/packet-AYTQ26CC-cwr6n1cm.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-pr7ehgzb.js → pegDiagram-GJSIUBJH-zhycy2b7.js} +1 -1
- package/dist/client/static/js/{perl-srptw5vm.js → perl-506fy8m8.js} +1 -1
- package/dist/client/static/js/{php-n89g3fk7.js → php-axtsvxck.js} +1 -1
- package/dist/client/static/js/pie-WAS4IAKB-h1ebfzgt.js +1 -0
- package/dist/client/static/js/{pieDiagram-5QR66LMP-39wpsk08.js → pieDiagram-5QR66LMP-sgctvma2.js} +2 -2
- package/dist/client/static/js/properties-q8njes42.js +1 -0
- package/dist/client/static/js/python-vqxc7181.js +1 -0
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-esm913km.js → quadrantDiagram-O4NWA36T-kzzhdcph.js} +1 -1
- package/dist/client/static/js/r-0k5eej8m.js +1 -0
- package/dist/client/static/js/radar-RG4KPBEZ-k7p1m364.js +1 -0
- package/dist/client/static/js/railroad-74A4TZTK-d08dw3t0.js +1 -0
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-txnjycgk.js +1 -0
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-p0r3cv6w.js +1 -0
- package/dist/client/static/js/railroad-peg-WCYAUIDC-sryk900a.js +1 -0
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-wy2mgya6.js → railroadDiagram-XR7U4H2S-nzjffwxm.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-6z9xdgbq.js → requirementDiagram-PLB6GJNP-tz4xxn4d.js} +1 -1
- package/dist/client/static/js/{ruby-r81ytgcm.js → ruby-qp7zfk2m.js} +1 -1
- package/dist/client/static/js/{rust-frn3szvc.js → rust-fz913fvw.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-rtmxk3ys.js → sankeyDiagram-IPEJSGJF-2wcb0xr6.js} +2 -2
- package/dist/client/static/js/{sass-9bxped7y.js → sass-gnk9vsyp.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-awzcrafg.js → sequenceDiagram-PO4LG4MO-vqgebfns.js} +5 -5
- package/dist/client/static/js/{sizeCapture-INFHLROL-03gy196j.js → sizeCapture-INFHLROL-xc314tes.js} +1 -1
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-an8v3q5n.js → stateDiagram-v2-GCMORJYK-8bd9b1h8.js} +2 -2
- package/dist/client/static/js/{svelte-mwtx07d9.js → svelte-brpgzrtv.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-n9yb4wcs.js → swimlanes-2SLR337P-t6hbdzcw.js} +1 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-c1czc7kv.js +8 -0
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-jceb575g.js → timeline-definition-EJHVYXUP-2txxasx5.js} +2 -2
- package/dist/client/static/js/treeView-Q6P3EWNA-77kj68p1.js +1 -0
- package/dist/client/static/js/treemap-WGGIJYW6-rw94xc82.js +1 -0
- package/dist/client/static/js/tsx-yd5wt250.js +1 -0
- package/dist/client/static/js/typescript-v7z7crfe.js +1 -0
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-888h3100.js → usecaseDiagram-POWQR4AR-3x353hn4.js} +5 -5
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-wbfz0rzv.js → vennDiagram-UO4OBE2U-cerpss8e.js} +1 -1
- package/dist/client/static/js/{vue-c0rtg1wf.js → vue-apnkw9qy.js} +1 -1
- package/dist/client/static/js/wardley-WFR3VGLG-18xe4fhz.js +1 -0
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-rn8c5qf9.js → wardleyDiagram-VNRHLVJA-cx6jfsbf.js} +1 -1
- package/dist/client/static/js/xml-94fhzrfs.js +1 -0
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-8sn1apt6.js → xychartDiagram-PMCCYNJV-tgn23xj1.js} +2 -2
- package/dist/client/static/js/yaml-s8af9rnw.js +1 -0
- package/package.json +1 -1
- package/src/client/components/settings/categories/connect-settings/PairDialog.test.tsx +159 -0
- package/src/client/components/settings/categories/connect-settings/PairDialog.tsx +36 -7
- package/src/client/components/settings/categories/connect-settings/QrCode.tsx +2 -19
- package/src/client/components/settings/categories/connect-settings/qr-image.ts +76 -0
- package/src/client/components/workspace/git-panel/init-state.test.ts +5 -0
- package/src/client/hooks/chat/composer/speech-to-text.ts +24 -17
- package/src/client/hooks/editor/file-actions.ts +3 -11
- package/src/client/hooks/editor/font.test.ts +2 -1
- package/src/client/hooks/editor/use-file-transfer.ts +2 -1
- package/src/client/lib/browser/download.ts +22 -0
- package/src/shared/lib/dictation/capture-failure.test.ts +46 -0
- package/src/shared/lib/dictation/capture-failure.ts +36 -0
- package/dist/client/static/js/architecture-7GRP2DOG-fc9kmq1w.js +0 -1
- package/dist/client/static/js/bash-b3rwyg5p.js +0 -1
- package/dist/client/static/js/cpp-y0t6mynx.js +0 -1
- package/dist/client/static/js/css-6vj0d308.js +0 -1
- package/dist/client/static/js/cynefin-OW5HDTMX-a4t8992q.js +0 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-18bdrkv5.js +0 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-fg0yqx0h.js +0 -1
- package/dist/client/static/js/gitGraph-4MIJSDKK-8fa6y40p.js +0 -1
- package/dist/client/static/js/graphql-n43pd5fs.js +0 -1
- package/dist/client/static/js/html-dbrwss36.js +0 -1
- package/dist/client/static/js/index-231241f4.js +0 -12
- package/dist/client/static/js/index-6sf2vsp2.js +0 -1
- package/dist/client/static/js/index-h5bn97p6.js +0 -2
- package/dist/client/static/js/info-A6RAGUB7-3hk844f7.js +0 -1
- package/dist/client/static/js/ini-j5dyq6gm.js +0 -1
- package/dist/client/static/js/java-g4dgwbfd.js +0 -1
- package/dist/client/static/js/jsx-7t5ecz9s.js +0 -1
- package/dist/client/static/js/lua-1g6w30de.js +0 -1
- package/dist/client/static/js/markdown-afx21x8c.js +0 -1
- package/dist/client/static/js/one-dark-pro-vwhfpzr8.js +0 -1
- package/dist/client/static/js/one-light-y5t9x6zh.js +0 -1
- package/dist/client/static/js/packet-AYTQ26CC-4nj2yy10.js +0 -1
- package/dist/client/static/js/pie-WAS4IAKB-k7rde3f9.js +0 -1
- package/dist/client/static/js/properties-thd83wey.js +0 -1
- package/dist/client/static/js/python-264ns4xw.js +0 -1
- package/dist/client/static/js/r-qw82kkv9.js +0 -1
- package/dist/client/static/js/radar-RG4KPBEZ-513dpw4f.js +0 -1
- package/dist/client/static/js/railroad-74A4TZTK-9bqnst9c.js +0 -1
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-7367d5bv.js +0 -1
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-b806b1mj.js +0 -1
- package/dist/client/static/js/railroad-peg-WCYAUIDC-5a67rwf8.js +0 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-nx5nfnf0.js +0 -8
- package/dist/client/static/js/treeView-Q6P3EWNA-kcy40evb.js +0 -1
- package/dist/client/static/js/treemap-WGGIJYW6-fsrvqxf4.js +0 -1
- package/dist/client/static/js/tsx-nm94hed6.js +0 -1
- package/dist/client/static/js/typescript-0s2t05jj.js +0 -1
- package/dist/client/static/js/wardley-WFR3VGLG-36dmxww4.js +0 -1
- package/dist/client/static/js/xml-dz51p1m3.js +0 -1
- package/dist/client/static/js/yaml-2cfkd30t.js +0 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import{d,n,i,V,o,si,u,a,He,Ds,We,Re,e,gr,Gn,S,Tu,La,s,I,jn,En,Pa,m,ui,Kt,D,$r,Ro,Fo,f,B,et,ae,ln,Jt,Y,C,Po,Oo,$o,Dn,tn,Uo,b,Ke,dr,to,Ms,Ps,hi,GA,rt,HA,WA,qo,KA,VA,Ho,YA,JA,dt,ZA,XA,Ru,eg,tg,Ct,xa,ee,yi,wi,ht,ec,Tm,ke,un,Rn,ju,Zr,Fn,qa,It,k,P,Qe,Cr,dn,Xr,re,Gt,an,ue,Jn,Ha,me,it,Wa,Er,jt,T,Me,bn,ye,_,oo,Ug,Gg,jg,qg,Hg,Wg,Kg,Vg,yc,Yg,Kf,qu,Ln,Js,Dm,Jg,xe,Mn,Qm,ts,so,Zs,Hu,Xs,Vf,Nm,Rm,Fm,Lm,el,Ku,Vu,Br,tl,Mm,Pm,Om,$m,zm,th,nh,nl,jm,lo,Hm,kc,Wm,Jf,Km}from"./index-ncrenheb.js";import{uo,mo}from"./index-dfzrpy54.js";import{Ao}from"./index-7ct7qrsp.js";var Pl={name:"square-dashed-text",size:24,node:[["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 14v1",key:"169vum"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M7 16h6",key:"1vyc9m"}],["path",{d:"M7 8h8",key:"1jbsf9"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M9 3h1",key:"1yesri"}]],aliases:["text-selection","text-select"]},Ur=s(Pl);var Nl={name:"text-align-justify",size:24,node:[["path",{d:"M3 5h18",key:"1u36vt"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 19h18",key:"awlh7x"}]],aliases:["align-justify"]},Ot=s(Nl);var Vl={name:"diff",size:24,node:[["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 10h14",key:"elsbfy"}],["path",{d:"M5 21h14",key:"11awu3"}]]},Bt=s(Vl);var Wl={name:"file-x",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m14.5 12.5-5 5",key:"b62r18"}],["path",{d:"m9.5 12.5 5 5",key:"1rk7el"}]]},Ec=s(Wl);var Ul={name:"message-square-off",size:24,node:[["path",{d:"M19 19H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.7.7 0 0 1 2 21.286V5a2 2 0 0 1 1.184-1.826",key:"1wyg69"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.656 3H20a2 2 0 0 1 2 2v11.344",key:"mhl4k6"}]]},_r=s(Ul);var $l={name:"space",size:24,node:[["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]]},On=s($l);function Kr({filePath:t,status:r,isStaged:l,repo:c,root:p,enabled:h=!0}){let[g,y]=n(""),[x,w]=n(""),[v,E]=n(""),[M,L]=n(r),[O,F]=n(l),[W,R]=n(!0),[A,N]=n(null),U=o(l),H=o(r),G=o(0),z=a(async(j={})=>{if(!h||!t)return;let Z=++G.current;R(!0),N(null);try{let Q=j.staged??U.current,ie=j.status??H.current,ne=new URLSearchParams({fileDiff:"1",file:t,staged:Q?"1":"0",repo:c||"."});if(ie)ne.set("status",ie);if(p)ne.set("root",p);let fe=await fetch(`/api/fs/git?${ne.toString()}`),se=await fe.json().catch(()=>null);if(Z!==G.current)return;if(se?.success){if(y(se.diff||""),w(se.oldContent??""),E(se.newContent??""),se.status)H.current=se.status,L(se.status);if(typeof se.staged==="boolean")U.current=se.staged,F(se.staged)}else N(se?.error||`Failed to load file diff (HTTP ${fe.status})`)}catch(Q){if(Z!==G.current)return;N(Q instanceof Error?Q.message:"Error fetching diff")}finally{if(Z===G.current)R(!1)}},[t,c,p,h]);i(()=>{if(!h)return;U.current=l,H.current=r,L(r),F(l),z()},[z,l,r,h]);let K=a((j)=>{if(typeof j.staged==="boolean")U.current=j.staged,F(j.staged);if(j.status)H.current=j.status,L(j.status)},[]);return{rawDiff:g,oldContent:x,newContent:v,currentStatus:M,currentStaged:O,isLoading:W,errorMessage:A,fetchDiff:z,adoptState:K}}function _l(t){if(t==="added")return"A";if(t==="deleted")return"D";return"M"}function Hr(t){let[r,l]=n(""),[c,p]=n(""),[h,g]=n(""),[y,x]=n("M"),[w,v]=n(Boolean(t)),[E,M]=n(null),L=o(0),O=t?.sessionId,F=t?.path,W=t?.from,R=t?.to,A=a(async()=>{if(!O||!F||W===void 0||R===void 0)return;let U=++L.current;v(!0),M(null);try{let H=new URLSearchParams({path:F,from:String(W),to:String(R)}),G=await fetch(`/api/sessions/${encodeURIComponent(O)}/changes/diff?${H.toString()}`),z=await G.json().catch(()=>null);if(U!==L.current)return;if(z?.success){if(p(z.oldContent??""),g(z.newContent??""),l(z.diff??""),x(_l(z.status)),z.unavailable)M("The journal did not store this file’s content (over 8 MB), so the two sides are unknown.")}else M(z?.error||`Failed to load the journal diff (HTTP ${G.status})`)}catch(H){if(U!==L.current)return;M(H instanceof Error?H.message:"Error fetching the journal diff")}finally{if(U===L.current)v(!1)}},[O,F,W,R]);i(()=>{A()},[A]);let N=a(()=>{},[]);return{rawDiff:r,oldContent:c,newContent:h,currentStatus:y,currentStaged:!1,isLoading:w,errorMessage:E,fetchDiff:A,adoptState:N}}function qr(t){let{filePath:r,repo:l,root:c,staged:p,conflicted:h,adoptState:g,fetchDiff:y,onFileSaved:x}=t,[w,v]=n(!1),[E,M]=n(null),[L,O]=n({}),F=a(async(R)=>{let A=new FormData;for(let[N,U]of Object.entries(R))A.set(N,U);if(A.set("repo",l||"."),c)A.set("root",c);try{let N=await fetch("/api/fs/git",{method:"POST",body:A}),U=await N.json().catch(()=>null);if(!N.ok||!U?.success)return M(U?.error||`Request failed (HTTP ${N.status})`),!1;return M(null),!0}catch(N){return M(N instanceof Error?N.message:"Request failed"),!1}},[l,c]),W=a(async(R,A)=>{v(!0);try{if(!await F(R))return;await A()}finally{v(!1)}},[F]);return i(()=>{if(!h){O({});return}let R=!1,A=new URLSearchParams({conflictMarkers:"1",file:r,repo:l||"."});if(c)A.set("root",c);return fetch(`/api/fs/git?${A.toString()}`).then((N)=>N.json()).then((N)=>{if(!R)O(N.markers??{})}).catch(()=>{if(!R)O({})}),()=>{R=!0}},[h,r,l,c]),{isBusy:w,error:E,markers:L,dismissError:()=>M(null),stageUnstage:()=>W({actionType:p?"unstage":"stage",file:r},async()=>{g({staged:!p}),x?.(),await y({staged:!p})}),resolve:(R)=>W({actionType:"resolve_conflict",file:r,...R?{side:R}:{}},async()=>{x?.(),await y()}),revert:()=>W({actionType:"revert",file:r},async()=>{x?.(),await y()})}}var zr=[{target:"compact",label:"Compact view",hint:"Editor takes the chat width: chat hidden, sidebar and right panel kept",Icon:_r},{target:"full",label:"Full view",hint:"Editor takes the chat and sidebar width: chat and sidebar hidden, right panel kept",Icon:ui}];function jr(){let[t,r]=La(Hm,kc);return{mode:Wm(t)?t:kc,setMode:r}}function td(){let{mode:t,setMode:r}=jr();return zr.map(({target:l,label:c,Icon:p})=>({label:c,icon:p,active:t===l,onSelect:()=>r(Jf(t,l))}))}function nd({size:t=14}){let{mode:r,setMode:l}=jr();return e(d,{children:zr.map(({target:c,label:p,hint:h,Icon:g})=>{let y=r===c;return e("button",{type:"button",onClick:()=>l(Jf(r,c)),className:`flex items-center justify-center p-1.5 rounded transition-colors cursor-pointer flex-shrink-0 ${y?"bg-ink/10 text-ink":"text-ink/50 hover:text-ink hover:bg-ink/5"}`,title:h,"aria-label":p,"aria-pressed":y,children:e(g,{size:t})},c)})})}var Ft="px-2 py-0.5 rounded text-[11px] font-medium flex items-center space-x-1 transition-colors cursor-pointer flex-shrink-0",Gr="flex items-center bg-canvas rounded border border-ink/15 p-0.5 mr-0.5 @[440px]:mr-1";function Jr({viewMode:t,onSetViewMode:r}){return e("div",{className:Gr,children:[e("button",{type:"button",onClick:()=>r("split"),className:`${Ft} ${t==="split"?"bg-paper text-ink shadow-xs":"text-ink/60 hover:text-ink"}`,title:"Split (side-by-side) diff","aria-label":"Split (side-by-side) diff","aria-pressed":t==="split",children:[e(En,{size:12}),e("span",{className:"hidden @[420px]:inline",children:"Split"})]}),e("button",{type:"button",onClick:()=>r("unified"),className:`${Ft} ${t==="unified"?"bg-paper text-ink shadow-xs":"text-ink/60 hover:text-ink"}`,title:"Unified diff","aria-label":"Unified diff","aria-pressed":t==="unified",children:[e(Ot,{size:12}),e("span",{className:"hidden @[420px]:inline",children:"Unified"})]})]})}function Yr({contentMode:t,onSetContentMode:r}){return e("div",{className:Gr,children:[e("button",{type:"button",onClick:()=>r("full"),className:`${Ft} ${t==="full"?"bg-paper text-ink shadow-xs":"text-ink/60 hover:text-ink"}`,title:"Full code (whole file, changes marked)","aria-label":"Full code (whole file, changes marked)","aria-pressed":t==="full",children:[e(ln,{size:12}),e("span",{className:"hidden @[420px]:inline",children:"Full Code"})]}),e("button",{type:"button",onClick:()=>r("diff"),className:`${Ft} ${t==="diff"?"bg-paper text-ink shadow-xs":"text-ink/60 hover:text-ink"}`,title:"Diff only (changed hunks)","aria-label":"Diff only (changed hunks)","aria-pressed":t==="diff",children:[e(Bt,{size:12}),e("span",{className:"hidden @[420px]:inline",children:"Diff Only"})]})]})}var Qr="flex items-center justify-center p-1.5 rounded transition-colors cursor-pointer disabled:cursor-default disabled:opacity-40 disabled:hover:bg-transparent disabled:hover:text-ink/50";function eo({index:t,count:r,locked:l,onStep:c}){let p=t>=0?t+1:"–";return e("div",{className:"flex items-center gap-0.5",children:[e("button",{type:"button",onClick:()=>c(-1),disabled:l,className:`${Qr} text-ink/50 hover:text-ink hover:bg-ink/5`,title:"Previous change","aria-label":"Previous change",children:e(et,{size:13})}),e("span",{className:"text-[10px] font-mono tabular-nums text-ink/50 px-0.5 min-w-[3.5ch] text-center",title:`Changed hunk ${p} of ${r}`,"aria-live":"polite",children:[p,"/",r]}),e("button",{type:"button",onClick:()=>c(1),disabled:l,className:`${Qr} text-ink/50 hover:text-ink hover:bg-ink/5`,title:"Next change","aria-label":"Next change",children:e(B,{size:13})})]})}var Pt="flex items-center justify-center p-1.5 rounded transition-colors cursor-pointer disabled:cursor-default disabled:opacity-40 disabled:hover:bg-transparent disabled:hover:text-ink/50";function no({isStaged:t,locked:r,readOnly:l,stageLabel:c,onStageUnstage:p,onDiscard:h}){if(l)return[];let g=[];if(!t)g.push({id:"discard",actions:[{label:"Discard changes in this file",icon:tn,onSelect:h,disabled:r}],children:e("button",{type:"button",onClick:h,className:`${Pt} text-ink/50 hover:text-error hover:bg-error/10`,title:"Discard changes in this file","aria-label":"Discard changes in this file",disabled:r,children:e(tn,{size:13})})});return g.push({id:"stage",pinned:!0,actions:[{label:c,icon:t?Jt:Y,onSelect:p,disabled:r}],children:e("button",{type:"button",onClick:p,className:"px-2 py-1 text-[11px] font-medium rounded border border-ink/15 hover:bg-ink/5 flex items-center space-x-1 transition-colors text-ink cursor-pointer disabled:cursor-default disabled:opacity-40 disabled:hover:bg-transparent",title:c,"aria-label":c,disabled:r,children:t?e(d,{children:[e(Jt,{size:12}),e("span",{className:"hidden @[360px]:inline",children:"Unstage"})]}):e(d,{children:[e(Y,{size:12}),e("span",{className:"hidden @[360px]:inline",children:"Stage"})]})})}),g}function ro({filePath:t,status:r,isStaged:l,viewMode:c,contentMode:p,wordWrap:h,ignoreWhitespace:g,additions:y,deletions:x,chunkIndex:w=-1,chunkCount:v=0,onStepChunk:E,isLoading:M,isCopied:L,isBusy:O=!1,viewModeButtons:F=!0,readOnly:W=!1,onSetViewMode:R,onSetContentMode:A,onToggleWordWrap:N,onToggleWhitespace:U,onStageUnstage:H,onDiscard:G,onOpenInEditor:z,onRefresh:K,onCopyDiff:j}){let Z=td(),Q=t.split("/").pop()||t,ie=Gn(r,l),ne=M||O,fe=l?"Unstage file":"Stage file",se=h?"Word wrap on":"Word wrap off",te=g?"Whitespace changes hidden":"Hide whitespace changes",Se=L?"Copied":"Copy diff text",le=[];if(y>0||x>0)le.push({id:"counts",pinned:!0,actions:[],children:e("div",{className:"flex items-center space-x-1.5 text-[11px] font-mono pr-1.5 mr-0.5 @[440px]:mr-1 border-r border-ink/10",children:[y>0&&e("span",{className:"text-success font-semibold",children:["+",y]}),x>0&&e("span",{className:"text-error font-semibold",children:["-",x]})]})});if(le.push({id:"view-mode",actions:[{label:"Split (side-by-side) diff",icon:En,onSelect:()=>R("split"),active:c==="split"},{label:"Unified diff",icon:Ot,onSelect:()=>R("unified"),active:c==="unified"}],children:e(Jr,{viewMode:c,onSetViewMode:R})}),le.push({id:"content-mode",actions:[{label:"Full code (whole file, changes marked)",icon:ln,onSelect:()=>A("full"),active:p==="full"},{label:"Diff only (changed hunks)",icon:Bt,onSelect:()=>A("diff"),active:p==="diff"}],children:e(Yr,{contentMode:p,onSetContentMode:A})}),E&&v>0)le.push({id:"hunks",actions:[{label:"Previous change",icon:et,onSelect:()=>E(-1),disabled:ne},{label:"Next change",icon:B,onSelect:()=>E(1),disabled:ne}],children:e(eo,{index:w,count:v,locked:ne,onStep:E})});if(le.push({id:"wrap",actions:[{label:se,icon:Kt,onSelect:N,active:h}],children:e("button",{type:"button",onClick:N,className:`p-1.5 rounded transition-colors cursor-pointer flex-shrink-0 ${h?"bg-ink/10 text-ink":"text-ink/50 hover:text-ink hover:bg-ink/5"}`,title:se,"aria-label":se,"aria-pressed":h,children:e(Kt,{size:13})})}),le.push({id:"whitespace",actions:[{label:te,icon:On,onSelect:U,active:g}],children:e("button",{type:"button",onClick:U,className:`p-1.5 rounded transition-colors cursor-pointer flex-shrink-0 ${g?"bg-ink/10 text-ink":"text-ink/50 hover:text-ink hover:bg-ink/5"}`,title:te,"aria-label":te,"aria-pressed":g,children:e(On,{size:13})})}),F)le.push({id:"view-modes",pinned:!0,actions:Z,children:e(nd,{size:13})});if(le.push({id:"refresh",actions:[{label:"Reload this diff",icon:C,onSelect:K,disabled:ne}],children:e("button",{type:"button",onClick:K,className:`${Pt} text-ink/50 hover:text-ink hover:bg-ink/5`,title:"Reload this diff","aria-label":"Reload this diff",disabled:ne,children:e(C,{size:13,className:M?"animate-spin":""})})}),le.push({id:"copy",actions:[{label:Se,icon:ae,onSelect:j}],children:e("button",{type:"button",onClick:j,className:`${Pt} text-ink/50 hover:text-ink hover:bg-ink/5`,title:Se,"aria-label":Se,children:L?e(f,{size:13,className:"text-success"}):e(ae,{size:13})})}),le.push(...no({isStaged:l,locked:ne,readOnly:W,stageLabel:fe,onStageUnstage:H,onDiscard:G})),z)le.push({id:"edit-file",pinned:!0,actions:[{label:"Open in code editor",icon:jn,onSelect:z}],children:e("button",{type:"button",onClick:z,className:"px-2 py-1 text-[11px] font-medium rounded bg-ink text-canvas hover:bg-ink/90 flex items-center space-x-1 transition-colors shadow-xs ml-1 cursor-pointer",title:"Open in code editor","aria-label":"Open in code editor",children:[e(jn,{size:12}),e("span",{className:"hidden @[360px]:inline",children:"Edit File"})]})});return e("div",{className:"@container flex items-center justify-between px-3 py-1.5 bg-paper border-b border-ink/10 text-xs font-sans select-none flex-shrink-0 gap-2 min-w-0",children:[e("div",{className:"hidden @[560px]:flex items-center space-x-2 min-w-0 pr-2",children:[e(rt,{name:Q,size:14,className:"flex-shrink-0"}),e("span",{className:"font-mono text-ink font-medium truncate",title:t,children:Q}),e("span",{className:`px-1.5 py-0.5 text-[10px] font-mono font-semibold rounded border ${ie.badgeBgClass} flex-shrink-0`,children:[ie.charStatus," ",ie.label]})]}),e(Ao,{clusters:le,className:"text-ink/70 ml-auto"})]})}function io({markers:t,isBusy:r,error:l,onResolve:c,onDismissError:p}){let h=t.ours||"ours",g=t.theirs||"theirs";return e("div",{className:"flex-shrink-0 border-b border-warning/30 bg-warning/5",children:[e("div",{className:"flex items-center gap-2 px-3 py-1.5 flex-wrap",children:[e(D,{size:13,className:"text-warning flex-shrink-0"}),e("span",{className:"text-[11px] font-medium text-warning",children:"Conflicted file"}),e("div",{className:"flex items-center gap-1.5 ml-auto flex-wrap",children:[e("button",{type:"button",onClick:()=>c("ours"),disabled:r,title:`Take ${h} — \`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 disabled:opacity-40 max-w-[40%] truncate",children:["take ",h]}),e("button",{type:"button",onClick:()=>c("theirs"),disabled:r,title:`Take ${g} — \`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 disabled:opacity-40 max-w-[40%] truncate",children:["take ",g]}),e("button",{type:"button",onClick:()=>c(""),disabled:r,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 disabled:opacity-40",children:"mark resolved"})]})]}),l&&e("div",{className:"flex items-center gap-2 px-3 py-1 border-t border-error/25 bg-error/10 text-[10px] text-error",children:[e("span",{className:"min-w-0 flex-1 truncate",title:l,children:l}),e("button",{type:"button",onClick:p,className:"px-1 rounded hover:bg-error/15 cursor-pointer",title:"Dismiss","aria-label":"Dismiss",children:"✕"})]})]})}function ao(t){let r=uo();return e(zm,{...t,themeVars:r.vars,themes:r.themes})}function co(t){let r=t.split("/").pop()??"",l=r.lastIndexOf(".");return l>0&&l<r.length-1?r.slice(l).toLowerCase():""}function rA(t){let r=Ct("fileOpener"),l=Ct("sourceCodeRenderer"),c=xa(),p=t.extension??co(t.path),h=r.find((y)=>y.registration.matches({path:t.path,extension:p}));if(h)return{kind:"opener",pluginId:h.pluginId,Component:h.registration.component,props:{...c,path:t.path,extension:p}};let g=l.find((y)=>y.registration.extensions.includes(p));if(g)return{kind:"source",pluginId:g.pluginId,Component:g.registration.component,props:{...c,path:t.path,content:t.content,language:t.language}};return null}function fo(t){let r=Ct("diffRenderer"),l=xa(),c=co(t.path),p=r.find((h)=>{let g=h.registration.extensions;return g===void 0||g.includes(c)});if(!p)return null;return{pluginId:p.pluginId,Component:p.registration.component,props:{...l,path:t.path,diff:t.diff}}}function aA({view:t}){if(t.kind==="opener"){let l=t.Component;return e(Ke,{pluginId:t.pluginId,children:e(l,{...t.props})})}let r=t.Component;return e(Ke,{pluginId:t.pluginId,children:e(r,{...t.props})})}function Bc({filePath:t,status:r="M",isStaged:l=!1,root:c,repo:p=".",onOpenInEditor:h,onFileSaved:g,className:y="",tabKey:x=null,viewModeButtons:w=!0,journalDiff:v,readOnly:E=!1}){let[M,L]=Tu("diff.viewMode","unified"),[O,F]=Tu("diff.contentMode","diff"),[W,R]=Tu("diff.wordWrap",!0),[A,N]=Tu("diff.ignoreWhitespace",!1),[U,H]=n(null),[G,z]=n(!1),[K,j]=n(!1),[Z,Q]=n({additions:0,deletions:0}),[ie,ne]=n({index:-1,count:0}),fe=o(null),se=a((Ne)=>{fe.current?.(Ne)},[]),te=a((Ne)=>{fe.current=Ne},[]),Se=wi(),le=Kr({filePath:t,status:r,isStaged:l,repo:p,root:c,enabled:!v}),be=Hr(v),{rawDiff:Le,oldContent:Xe,newContent:Pe,currentStatus:Ce,currentStaged:Ee,isLoading:Ye,errorMessage:X,fetchDiff:oe,adoptState:ce}=v?be:le,q=!v&&gr(Ce),J=E||Boolean(v),de=dt(t),ve=fo({path:t,diff:Le}),Oe=(Ne)=>{L(Ne)},kt=(Ne)=>{F(Ne)},je=()=>{R(!W)},At=()=>{N(!A)},Tn=()=>{if(!Le)return;navigator.clipboard.writeText(Le).then(()=>{z(!0),setTimeout(()=>z(!1),2000)},()=>H("Clipboard write was refused by the browser"))},Ge=qr({filePath:t,repo:p,root:c,status:Ce,staged:Ee,conflicted:q,adoptState:ce,fetchDiff:oe,onFileSaved:g}),{isBusy:Lt,markers:An}=Ge,at=U??Ge.error;return e("div",{className:`flex flex-col min-h-0 bg-paper select-text relative font-sans ${y}`,children:[e(ro,{filePath:t,status:Ce,isStaged:Ee,viewMode:M,contentMode:O,wordWrap:W,ignoreWhitespace:A,additions:Z.additions,deletions:Z.deletions,chunkIndex:ie.index,chunkCount:ie.count,onStepChunk:se,isLoading:Ye,isCopied:G,isBusy:Lt,viewModeButtons:w,readOnly:J,onSetViewMode:Oe,onSetContentMode:kt,onToggleWordWrap:je,onToggleWhitespace:At,onStageUnstage:()=>{if(!J)Ge.stageUnstage()},onDiscard:()=>{if(!J)j(!0)},onOpenInEditor:h,onRefresh:()=>void oe(),onCopyDiff:Tn}),q&&e(io,{markers:An,isBusy:Lt,error:at,onResolve:(Ne)=>void Ge.resolve(Ne),onDismissError:()=>{Ge.dismissError(),H(null)}}),at&&!q&&e("div",{className:"flex items-center gap-2 border-b border-error/25 bg-error/10 px-3 py-1.5 text-[11px] text-error flex-shrink-0",children:[e(I,{size:13,className:"flex-shrink-0"}),e("span",{className:"min-w-0 flex-1 truncate",title:at,children:at}),e("button",{type:"button",onClick:()=>{Ge.dismissError(),H(null)},className:"px-1.5 rounded hover:bg-error/15 cursor-pointer",title:"Dismiss","aria-label":"Dismiss",children:"✕"})]}),e("div",{className:"flex-1 overflow-hidden relative flex flex-col bg-paper",children:Ye?e("div",{className:"flex-1 flex items-center justify-center space-x-2 text-ink/50 text-xs font-mono",children:[e(C,{size:14,className:"animate-spin"}),e("span",{children:"Loading file diff..."})]}):X?e("div",{className:"flex-1 flex flex-col items-center justify-center p-6 text-center space-y-2",children:[e(I,{size:20,className:"text-error"}),e("p",{className:"text-xs text-error font-medium",children:X}),e("button",{onClick:()=>void oe(),className:"px-3 py-1 text-xs bg-ink/10 hover:bg-ink/15 text-ink rounded font-sans transition-colors cursor-pointer",children:"Retry"})]}):ve?e(Ke,{pluginId:ve.pluginId,children:e(ve.Component,{...ve.props})}):e(ao,{original:Xe,next:Pe,language:de,viewMode:M,contentMode:O,wordWrap:W,ignoreWhitespace:A,tabKey:x,onCounts:Q,onChunkPosition:ne,onStepChunk:te,empty:!Le||!Le.trim(),fontFamily:Se,fontSize:yi})}),K&&e("div",{className:"fixed inset-0 modal-scrim z-50 flex items-center justify-center p-4 backdrop-blur-xs",children:e("div",{className:"glass-overlay bg-paper rounded-lg shadow-xl p-4 w-full max-w-sm border border-ink/15",children:[e("h3",{className:"font-semibold text-ink mb-1.5 text-sm",children:"Discard Changes?"}),e("p",{className:"text-xs text-ink/70 mb-4",children:["Are you sure you want to discard all unstaged changes in ",e("span",{className:"font-mono font-medium text-ink",children:t}),"? This cannot be undone."]}),e("div",{className:"flex justify-end space-x-2",children:[e("button",{type:"button",onClick:()=>j(!1),className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors cursor-pointer",children:"Cancel"}),e("button",{type:"button",onClick:()=>{j(!1),Ge.revert()},className:"px-3 py-1.5 text-xs bg-error text-white rounded hover:bg-error/90 font-medium transition-colors cursor-pointer",children:"Discard Changes"})]})]})})]})}var Zn="flex items-center justify-center p-1.5 rounded transition-colors cursor-pointer disabled:cursor-default disabled:opacity-50";function ns({label:t,pressed:r,title:l,onClick:c,children:p}){return e("button",{type:"button",onClick:c,className:`flex items-center justify-center p-1.5 rounded transition-colors cursor-pointer disabled:cursor-default disabled:opacity-50 hover:bg-ink/5 ${r?"text-ink":"hover:text-ink"}`,title:l??t,"aria-label":t,"aria-pressed":r,children:p})}function po(t){return t.lineStart===t.lineEnd?`L${t.lineStart}`:`L${t.lineStart}-${t.lineEnd}`}function ho({block:t,verdict:r,note:l,anchor:c,onSave:p,onRemove:h,onClose:g}){let y=o(null),x=o(null);i(()=>{x.current?.focus()},[]),i(()=>{let v=(E)=>{if(E.key!=="Escape")return;E.stopPropagation(),g()};return window.addEventListener("keydown",v,!0),()=>window.removeEventListener("keydown",v,!0)},[g]);let w=(v)=>p(v,x.current?.value??l);return e("div",{ref:y,role:"dialog","aria-label":`Review block ${po(t)}`,style:{top:`${c.top}px`,left:`${c.left}px`},className:"glass-popover fixed z-[65] w-[min(24rem,calc(100vw-2rem))] rounded-md border border-ink/15 bg-paper shadow-lg p-2 font-sans text-[11.5px] text-ink",onClick:(v)=>v.stopPropagation(),children:[e("div",{className:"flex items-center gap-1.5 text-[10.5px] font-mono text-ink/50",children:[e("span",{children:po(t)}),e("span",{className:"truncate",children:["«",t.quote,"»"]}),e("button",{type:"button",onClick:g,className:"ml-auto cursor-pointer text-ink/50 hover:text-ink","aria-label":"Close review",children:e(b,{size:12})})]}),e("div",{className:"mt-1.5 flex items-center gap-1.5",children:[e("button",{type:"button","aria-pressed":r==="good",title:"This block is good, so leave it alone",onClick:()=>w("good"),className:`${Zn} border px-2 text-[11px] ${r==="good"?"border-ink bg-ink/10 text-ink":"border-ink/15 text-ink/70 hover:border-ink/40"}`,children:[e(f,{size:11})," Good"]}),e("button",{type:"button","aria-pressed":r==="needs-work",title:"This block needs work",onClick:()=>w("needs-work"),className:`${Zn} border px-2 text-[11px] ${r==="needs-work"?"border-error bg-error/10 text-error":"border-ink/15 text-ink/70 hover:border-ink/40"}`,children:[e(b,{size:11})," Needs work"]}),r&&e("button",{type:"button",onClick:h,className:`${Zn} ml-auto border border-ink/15 px-2 text-[11px] text-ink/60 hover:text-error`,children:"Remove"})]}),e("textarea",{ref:x,defaultValue:l,rows:3,placeholder:"What is wrong (or right) with this block…",onKeyDown:(v)=>{if(v.key==="Enter"&&(v.metaKey||v.ctrlKey)&&r)v.preventDefault(),w(r)},className:"mt-1.5 w-full resize-y rounded border border-ink/15 bg-canvas/40 px-2 py-1 text-[11px] font-sans outline-none focus:border-ink"}),e("div",{className:"mt-1 flex items-center gap-1.5 text-[10.5px] text-ink/45",children:e("span",{children:"Click an answer to save · ⌘↵ keeps the note with it"})})]})}function go(t){return t.lineStart===t.lineEnd?`L${t.lineStart}`:`L${t.lineStart}-${t.lineEnd}`}function bo({counts:t,outdated:r,error:l,sent:c,onSend:p,onRemoveOutdated:h,onExit:g}){let y=t.good+t.needsWork;return e("div",{className:"sticky bottom-0 z-40 mt-2 border-t border-ink/10 bg-paper/95 px-1 py-2 backdrop-blur",children:[r.length>0&&e("div",{className:"mb-1.5 space-y-1",children:[e("div",{className:"text-[10px] uppercase font-mono text-ink/40",children:[r.length," outdated — the block was edited or is no longer rendered"]}),r.map((x)=>e("div",{className:"flex items-start gap-1.5 text-[11px] text-ink/60",children:[e("span",{className:"font-mono text-[10.5px] text-ink/40",children:go(x)}),e("span",{className:"min-w-0 flex-1",children:[e("span",{className:"block truncate text-ink/45",children:x.quote||"(block text unavailable)"}),x.note.trim()&&e("span",{className:"block truncate text-ink/70",children:x.note})]}),e("button",{type:"button",onClick:()=>h(x.id),className:"cursor-pointer text-ink/40 hover:text-error","aria-label":`Remove outdated annotation at ${go(x)}`,children:e(b,{size:11})})]},x.id))]}),l&&e("div",{role:"alert",className:"mb-1.5 text-[11px] text-error",children:l}),e("div",{className:"flex items-center gap-2 font-sans text-[11px]",children:[e("span",{className:"text-ink/70",children:[e("span",{className:"text-ink",children:t.good})," good ·"," ",e("span",{className:"text-error",children:t.needsWork})," needs work"]}),c&&e("span",{className:"text-ink/50",children:"Added to the chat box"}),e("button",{type:"button",onClick:g,className:"ml-auto cursor-pointer p-1 text-ink/50 hover:text-ink",title:"Exit review mode","aria-label":"Exit review mode",children:e(b,{size:13})}),e("button",{type:"button",disabled:y===0,onClick:p,title:"Put this review into the chat box; you still choose to send it",className:"flex items-center gap-1 rounded border border-ink bg-ink px-2 py-1 text-canvas transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",children:[e(Dn,{size:11})," Send to chat"]})]})]})}function Kl(t){let r=new URLSearchParams({path:t.path});if(t.root)r.set("root",t.root);if(t.repo&&t.repo!==".")r.set("repo",t.repo);return r}async function In(t){let r=await t.json().catch(()=>null);return typeof r?.error==="string"?r.error:`Request failed (${t.status})`}async function yo(t,r){let l=await fetch(`/api/review?${Kl(t).toString()}`,{signal:r});if(!l.ok)throw Error(await In(l));let c=await l.json();return Array.isArray(c.annotations)?c.annotations:[]}async function xo(t,r){let l={...r,path:t.path,root:t.root,repo:t.repo},c=await fetch("/api/review",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!c.ok)throw Error(await In(c));let p=await c.json();if(!p.annotation)throw Error("The server answered without the saved annotation");return p.annotation}async function vo(t){let r=await fetch(`/api/review?id=${encodeURIComponent(t)}`,{method:"DELETE"});if(!r.ok)throw Error(await In(r))}function ko(t,r){let[l,c]=n([]),[p,h]=n(!1),[g,y]=n(null),[x,w]=n(0),v=t?.path??null,E=t?.root??null,M=t?.repo??null;i(()=>{if(!r||!v){c([]),y(null),h(!1);return}let W=new AbortController;return h(!0),y(null),yo({path:v,root:E,repo:M},W.signal).then((R)=>{if(W.signal.aborted)return;c(R)}).catch((R)=>{if(W.signal.aborted)return;y(R instanceof Error?R.message:"Could not read annotations")}).finally(()=>{if(!W.signal.aborted)h(!1)}),()=>W.abort()},[r,v,E,M,x]);let L=o(l);L.current=l;let O=a(async(W)=>{if(!v)return;let R=L.current,A={id:`pending:${W.blockKey}`,scope:"",path:v,blockKey:W.blockKey,lineStart:W.lineStart,lineEnd:W.lineEnd,verdict:W.verdict,note:W.note,quote:W.quote,createdAt:Date.now(),updatedAt:Date.now()};c([...R.filter((N)=>N.blockKey!==W.blockKey),A]),y(null);try{let N=await xo({path:v,root:E,repo:M},W);c((U)=>U.map((H)=>H.blockKey===W.blockKey?N:H))}catch(N){c(R),y(N instanceof Error?N.message:"Could not save the annotation")}},[v,E,M]),F=a(async(W)=>{let R=L.current;c(R.filter((A)=>A.id!==W)),y(null);try{await vo(W)}catch(A){c(R),y(A instanceof Error?A.message:"Could not remove the annotation")}},[]);return{annotations:l,loading:p,error:g,save:O,remove:F,reload:()=>w((W)=>W+1)}}function wo(t,r){let l=new Map(t.map((h)=>[h.key,h])),c=new Map,p=[];for(let h of r)if(l.has(h.blockKey))c.set(h.blockKey,h);else p.push(h);return p.sort((h,g)=>g.updatedAt-h.updatedAt),{attached:c,outdated:p}}function So(t){let r=0,l=0;for(let c of t.values())if(c.verdict==="good")r+=1;else l+=1;return{good:r,needsWork:l}}function Co({file:t,active:r}){let[l,c]=n([]),[p,h]=n(null),[g,y]=n(null),x=u(()=>({path:t.path,root:t.root??null,repo:t.repo??null}),[t.path,t.root,t.repo]),{annotations:w,loading:v,error:E,save:M,remove:L}=ko(x,r),{attached:O,outdated:F}=u(()=>wo(l,w),[l,w]),W=u(()=>new Map([...O.values()].map((K)=>[K.blockKey,K.verdict])),[O]),R=u(()=>So(O),[O]),A=u(()=>p?l.find((K)=>K.key===p)??null:null,[l,p]),N=a((K)=>{c((j)=>Hl(j,K)?j:K)},[]),U=a((K,j)=>{h(K.key),y({top:j.bottom+6,left:Math.max(8,j.left)})},[]),H=a(()=>{h(null),y(null)},[]),G=a(({block:K,verdict:j,note:Z})=>{M({blockKey:K.key,lineStart:K.lineStart,lineEnd:K.lineEnd,verdict:j,note:Z,quote:K.quote})},[M]),z=a(()=>{let K=th({path:t.path,annotations:[...O.values()]});if(!K)return!1;return nh(K),!0},[O,t.path]);return{marks:W,selected:p,selectedBlock:A,selectedAnnotation:A?O.get(A.key)??null:null,anchor:g,outdated:F,counts:R,loading:v,error:E,setBlocks:N,pick:U,close:H,save:G,remove:(K)=>void L(K),send:z}}function Hl(t,r){if(t.length!==r.length)return!1;return t.every((l,c)=>l.key===r[c]?.key)}function Ic({content:t,file:r,active:l,onExit:c}){let p=Co({file:r,active:l}),[h,g]=n(!1);i(()=>{if(!p.selected)return;let v=()=>p.close();return window.addEventListener("scroll",v,!0),()=>window.removeEventListener("scroll",v,!0)},[p.selected]),i(()=>{if(!l)p.close()},[l]);let y=p.counts.good+p.counts.needsWork;i(()=>{g(!1)},[y]);let{selectedBlock:x,selectedAnnotation:w}=p;return e("div",{className:l?"md-review-active":void 0,children:[e(ee,{content:t,document:!0,scope:{path:r.path,root:r.root??void 0,repo:r.repo??void 0},onBlocks:p.setBlocks,review:l?{active:!0,marks:p.marks,selected:p.selected,onPick:p.pick}:void 0}),l&&x&&p.anchor&&e(ho,{block:x,verdict:p.marks.get(x.key)??null,note:w?.note??"",anchor:p.anchor,onSave:(v,E)=>{p.save({block:x,verdict:v,note:E}),p.close()},onRemove:()=>{if(w)p.remove(w.id);p.close()},onClose:p.close},x.key),l&&e(bo,{counts:p.counts,outdated:p.outdated,error:p.error,sent:h,onSend:()=>g(p.send()),onRemoveOutdated:p.remove,onExit:()=>{p.close(),c()}})]})}var Eo=typeof String.prototype.normalize=="function"?(t)=>t.normalize("NFKD"):(t)=>t;class ft{constructor(t,r,l=0,c=t.length,p,h){this.test=h,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=t.iterRange(l,c),this.bufferStart=l,this.normalize=p?(g)=>p(Eo(g)):Eo,this.query=this.normalize(r)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Rn(this.buffer,this.bufferPos)}next(){while(this.matches.length)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let t=this.peek();if(t<0)return this.done=!0,this;let r=ju(t),l=this.bufferStart+this.bufferPos;this.bufferPos+=Zr(t);let c=this.normalize(r);if(c.length)for(let p=0,h=l,g=!0;;p++){let y=c.charCodeAt(p),x=this.match(y,h,g,this.bufferPos+this.bufferStart,p==c.length-1);if(x)return this.value=x,this;if(p==c.length-1)break;if(g&&p<r.length&&r.charCodeAt(p)==y)h++;else g=!1}}}match(t,r,l,c,p){let h=null;for(let g=0;g<this.matches.length;){let y=this.matches[g],x=!1;if(this.query.charCodeAt(y.index)==t)if(y.index==this.query.length-1)h={from:y.from,to:c,precise:p&&y.precise};else y.index++,x=!0;if(x)g++;else this.matches.splice(g,1)}if(this.query.charCodeAt(0)==t)if(this.query.length==1)h={from:r,to:c,precise:l&&p};else this.matches.push({from:r,index:1,precise:l});if(h&&this.test&&!this.test(h.from,h.to,this.buffer,this.bufferStart))h=null;return h}}if(typeof Symbol<"u")ft.prototype[Symbol.iterator]=function(){return this};var Do={from:-1,to:-1,match:/.*/.exec(""),precise:!0},To="gm"+(/x/.unicode==null?"":"u");class Vt{constructor(t,r,l,c=0,p=t.length){if(this.text=t,this.to=p,this.curLine="",this.done=!1,this.value=Do,/\\[sWDnr]|\n|\r|\[\^/.test(r))return new Pn(t,r,l,c,p);this.re=new RegExp(r,To+((l===null||l===void 0?void 0:l.ignoreCase)?"i":"")),this.test=l===null||l===void 0?void 0:l.test,this.iter=t.iter();let h=t.lineAt(c);this.curLineStart=h.from,this.matchPos=Nt(t,c),this.getLine(this.curLineStart)}getLine(t){if(this.iter.next(t),this.iter.lineBreak)this.curLine="";else{if(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to)this.curLine=this.curLine.slice(0,this.to-this.curLineStart);this.iter.next()}}nextLine(){if(this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to)this.curLine="";else this.getLine(0)}next(){for(let t=this.matchPos-this.curLineStart;;){this.re.lastIndex=t;let r=this.matchPos<=this.to&&this.re.exec(this.curLine);if(r){let l=this.curLineStart+r.index,c=l+r[0].length;if(this.matchPos=Nt(this.text,c+(l==c?1:0)),l==this.curLineStart+this.curLine.length)this.nextLine();if((l<c||l>this.value.to)&&(!this.test||this.test(l,c,r)))return this.value={from:l,to:c,precise:!0,match:r},this;t=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),t=0;else return this.done=!0,this}}}var Bn=new WeakMap;class ut{constructor(t,r){this.from=t,this.text=r}get to(){return this.from+this.text.length}static get(t,r,l){let c=Bn.get(t);if(!c||c.from>=l||c.to<=r){let g=new ut(r,t.sliceString(r,l));return Bn.set(t,g),g}if(c.from==r&&c.to==l)return c;let{text:p,from:h}=c;if(h>r)p=t.sliceString(r,h)+p,h=r;if(c.to<l)p+=t.sliceString(c.to,l);return Bn.set(t,new ut(h,p)),new ut(r,p.slice(r-h,l-h))}}class Pn{constructor(t,r,l,c,p){this.text=t,this.to=p,this.done=!1,this.value=Do,this.matchPos=Nt(t,c),this.re=new RegExp(r,To+((l===null||l===void 0?void 0:l.ignoreCase)?"i":"")),this.test=l===null||l===void 0?void 0:l.test,this.flat=ut.get(t,c,this.chunkEnd(c+5000))}chunkEnd(t){return t>=this.to?this.to:this.text.lineAt(t).to}next(){for(;;){let t=this.re.lastIndex=this.matchPos-this.flat.from,r=this.re.exec(this.flat.text);if(r&&!r[0]&&r.index==t)this.re.lastIndex=t+1,r=this.re.exec(this.flat.text);if(r){let l=this.flat.from+r.index,c=l+r[0].length;if((this.flat.to>=this.to||r.index+r[0].length<=this.flat.text.length-10)&&(!this.test||this.test(l,c,r)))return this.value={from:l,to:c,precise:!0,match:r},this.matchPos=Nt(this.text,c+(l==c?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=ut.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}if(typeof Symbol<"u")Vt.prototype[Symbol.iterator]=Pn.prototype[Symbol.iterator]=function(){return this};function Nt(t,r){if(r>=t.length)return r;let l=t.lineAt(r),c;while(r<l.to&&(c=l.text.charCodeAt(r-l.from))>=56320&&c<57344)r++;return r}var zl={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Lo=P.define({combine(t){return Jn(t,zl,{highlightWordAroundCursor:(r,l)=>r||l,minSelectionLength:Math.min,maxMatches:Math.min})}});function Io(t){let r=[Yl,Xl];if(t)r.push(Lo.of(t));return r}var jl=T.mark({class:"cm-selectionMatch"}),Gl=T.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Mo(t,r,l,c){return(l==0||t(r.sliceDoc(l-1,l))!=an.Word)&&(c==r.doc.length||t(r.sliceDoc(c,c+1))!=an.Word)}function Jl(t,r,l,c){return t(r.sliceDoc(l,l+1))==an.Word&&t(r.sliceDoc(c-1,c))==an.Word}var Xl=ye.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){if(t.selectionSet||t.docChanged||t.viewportChanged)this.decorations=this.getDeco(t.view)}getDeco(t){let r=t.state.facet(Lo),{state:l}=t,c=l.selection;if(c.ranges.length>1)return T.none;let p=c.main,h,g=null;if(p.empty){if(!r.highlightWordAroundCursor)return T.none;let x=l.wordAt(p.head);if(!x)return T.none;g=l.charCategorizer(p.head),h=l.sliceDoc(x.from,x.to)}else{let x=p.to-p.from;if(x<r.minSelectionLength||x>200)return T.none;if(r.wholeWords){if(h=l.sliceDoc(p.from,p.to),g=l.charCategorizer(p.head),!(Mo(g,l,p.from,p.to)&&Jl(g,l,p.from,p.to)))return T.none}else if(h=l.sliceDoc(p.from,p.to),!h)return T.none}let y=[];for(let x of t.visibleRanges){let w=new ft(l.doc,h,x.from,x.to);while(!w.next().done){let{from:v,to:E}=w.value;if(!g||Mo(g,l,v,E)){if(p.empty&&v<=p.from&&E>=p.to)y.push(Gl.range(v,E));else if(v>=p.to||E<=p.from)y.push(jl.range(v,E));if(y.length>r.maxMatches)return T.none}}}return T.set(y)}},{decorations:(t)=>t.decorations}),Yl=_.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Ql=({state:t,dispatch:r})=>{let{selection:l}=t,c=k.create(l.ranges.map((p)=>t.wordAt(p.head)||k.cursor(p.head)),l.mainIndex);if(c.eq(l))return!1;return r(t.update({selection:c})),!0};function Zl(t,r){let{main:l,ranges:c}=t.selection,p=t.wordAt(l.head),h=p&&p.from==l.from&&p.to==l.to;for(let g=!1,y=new ft(t.doc,r,c[c.length-1].to);;)if(y.next(),y.done){if(g)return null;y=new ft(t.doc,r,0,Math.max(0,c[c.length-1].from-1)),g=!0}else{if(g&&c.some((x)=>x.from==y.value.from))continue;if(h){let x=t.wordAt(y.value.from);if(!x||x.from!=y.value.from||x.to!=y.value.to)continue}return y.value}}var Bo=({state:t,dispatch:r})=>{let{ranges:l}=t.selection;if(l.some((h)=>h.from===h.to))return Ql({state:t,dispatch:r});let c=t.sliceDoc(l[0].from,l[0].to);if(t.selection.ranges.some((h)=>t.sliceDoc(h.from,h.to)!=c))return!1;let p=Zl(t,c);if(!p)return!1;return r(t.update({selection:t.selection.addRange(k.range(p.from,p.to),!1),effects:_.scrollIntoView(p.to)})),!0};var No=({state:t,dispatch:r})=>{let l=t.selection;if(l.ranges.length>1||l.main.empty)return!1;let{from:c,to:p}=l.main,h=[],g=0;for(let y=new ft(t.doc,t.sliceDoc(c,p));!y.next().done;){if(h.length>1000)return!1;if(y.value.from==c)g=h.length;h.push(k.range(y.value.from,y.value.to))}return r(t.update({selection:k.create(h,g),userEvent:"select.search.matches"})),!0};var $n=(t)=>{let{state:r}=t,l=r.doc.lineAt(r.selection.main.from),c=Hn(t.state,l.from);return c.line?ea(t):c.block?ta(t):!1};function _n(t,r){return({state:l,dispatch:c})=>{if(l.readOnly)return!1;let p=t(r,l);if(!p)return!1;return c(l.update(p)),!0}}var ea=_n(oa,0);var Kn=_n(zo,0);var ta=_n((t,r)=>zo(t,r,ra(r)),0);function Hn(t,r){let l=t.languageDataAt("commentTokens",r,1);return l.length?l[0]:{}}var St=50;function na(t,{open:r,close:l},c,p){let h=t.sliceDoc(c-St,c),g=t.sliceDoc(p,p+St),y=/\s*$/.exec(h)[0].length,x=/^\s*/.exec(g)[0].length,w=h.length-y;if(h.slice(w-r.length,w)==r&&g.slice(x,x+l.length)==l)return{open:{pos:c-y,margin:y&&1},close:{pos:p+x,margin:x&&1}};let v,E;if(p-c<=2*St)v=E=t.sliceDoc(c,p);else v=t.sliceDoc(c,c+St),E=t.sliceDoc(p-St,p);let M=/^\s*/.exec(v)[0].length,L=/\s*$/.exec(E)[0].length,O=E.length-L-l.length;if(v.slice(M,M+r.length)==r&&E.slice(O,O+l.length)==l)return{open:{pos:c+M+r.length,margin:/\s/.test(v.charAt(M+r.length))?1:0},close:{pos:p-L-l.length,margin:/\s/.test(E.charAt(O-1))?1:0}};return null}function ra(t){let r=[];for(let l of t.selection.ranges){let c=t.doc.lineAt(l.from),p=l.to<=c.to?c:t.doc.lineAt(l.to);if(p.from>c.from&&p.from==l.to)p=l.to==c.to+1?c:t.doc.lineAt(l.to-1);let h=r.length-1;if(h>=0&&r[h].to>c.from)r[h].to=p.to;else r.push({from:c.from+/^\s*/.exec(c.text)[0].length,to:p.to})}return r}function zo(t,r,l=r.selection.ranges){let c=l.map((h)=>Hn(r,h.from).block);if(!c.every((h)=>h))return null;let p=l.map((h,g)=>na(r,c[g],h.from,h.to));if(t!=2&&!p.every((h)=>h))return{changes:r.changes(l.map((h,g)=>{if(p[g])return[];return[{from:h.from,insert:c[g].open+" "},{from:h.to,insert:" "+c[g].close}]}))};else if(t!=1&&p.some((h)=>h)){let h=[];for(let g=0,y;g<p.length;g++)if(y=p[g]){let x=c[g],{open:w,close:v}=y;h.push({from:w.pos-x.open.length,to:w.pos+w.margin},{from:v.pos-v.margin,to:v.pos+x.close.length})}return{changes:h}}return null}function oa(t,r,l=r.selection.ranges){let c=[],p=-1;e:for(let{from:h,to:g}of l){let y=c.length,x=1e9,w;for(let v=h;v<=g;){let E=r.doc.lineAt(v);if(w==null){if(w=Hn(r,E.from).line,!w)continue e}if(E.from>p&&(h==g||g>E.from)){p=E.from;let M=/^\s*/.exec(E.text)[0].length,L=M==E.length,O=E.text.slice(M,M+w.length)==w?M:-1;if(M<E.text.length&&M<x)x=M;c.push({line:E,comment:O,token:w,indent:M,empty:L,single:!1})}v=E.to+1}if(x<1e9){for(let v=y;v<c.length;v++)if(c[v].indent<c[v].line.text.length)c[v].indent=x}if(c.length==y+1)c[y].single=!0}if(t!=2&&c.some((h)=>h.comment<0&&(!h.empty||h.single))){let h=[];for(let{line:y,token:x,indent:w,empty:v,single:E}of c)if(E||!v)h.push({from:y.from+w,insert:x+" "});let g=r.changes(h);return{changes:g,selection:r.selection.map(g,1)}}else if(t!=1&&c.some((h)=>h.comment>=0)){let h=[];for(let{line:g,comment:y,token:x}of c)if(y>=0){let w=g.from+y,v=w+x.length;if(g.text[v-g.from]==" ")v++;h.push({from:w,to:v})}return{changes:h}}return null}var Vn=Xr.define(),ia=Xr.define(),sa=P.define(),jo=P.define({combine(t){return Jn(t,{minDepth:100,newGroupDelay:500,joinToEvent:(r,l)=>l},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(r,l)=>(c,p)=>r(c,p)||l(c,p)})}}),Go=Qe.define({create(){return qe.empty},update(t,r){let l=r.state.facet(jo),c=r.annotation(Vn);if(c){let x=De.fromTransaction(r,c.selection),w=c.side,v=w==0?t.undone:t.done;if(x)v=Ut(v,v.length,l.minDepth,x);else v=Qo(v,r.startState.selection);return new qe(w==0?c.rest:v,w==0?v:c.rest)}let p=r.annotation(ia);if(p=="full"||p=="before")t=t.isolate();if(r.annotation(Gt.addToHistory)===!1)return!r.changes.empty?t.addMapping(r.changes.desc):t;let h=De.fromTransaction(r),g=r.annotation(Gt.time),y=r.annotation(Gt.userEvent);if(h)t=t.addChanges(h,g,y,l,r);else if(r.selection)t=t.addSelection(r.startState.selection,g,y,l.newGroupDelay);if(p=="full"||p=="after")t=t.isolate();return t},toJSON(t){return{done:t.done.map((r)=>r.toJSON()),undone:t.undone.map((r)=>r.toJSON())}},fromJSON(t){return new qe(t.done.map(De.fromJSON),t.undone.map(De.fromJSON))}});function Jo(t={}){return[Go,jo.of(t),_.domEventHandlers({beforeinput(r,l){let c=r.inputType=="historyUndo"?qn:r.inputType=="historyRedo"?zn:null;if(!c)return!1;return r.preventDefault(),c(l)}})]}function Xo(t,r){return function({state:l,dispatch:c}){if(!r&&l.readOnly)return!1;let p=l.field(Go,!1);if(!p)return!1;let h=p.pop(t,l,r);if(!h)return!1;return c(h),!0}}var qn=Xo(0,!1),zn=Xo(1,!1);class De{constructor(t,r,l,c,p){this.changes=t,this.effects=r,this.mapped=l,this.startSelection=c,this.selectionsAfter=p}setSelAfter(t){return new De(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,r,l;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(r=this.mapped)===null||r===void 0?void 0:r.toJSON(),startSelection:(l=this.startSelection)===null||l===void 0?void 0:l.toJSON(),selectionsAfter:this.selectionsAfter.map((c)=>c.toJSON())}}static fromJSON(t){return new De(t.changes&&It.fromJSON(t.changes),[],t.mapped&&qa.fromJSON(t.mapped),t.startSelection&&k.fromJSON(t.startSelection),t.selectionsAfter.map(k.fromJSON))}static fromTransaction(t,r){let l=Ie;for(let c of t.startState.facet(sa)){let p=c(t);if(p.length)l=l.concat(p)}if(!l.length&&t.changes.empty)return null;return new De(t.changes.invert(t.startState.doc),l,void 0,r||t.startState.selection,Ie)}static selection(t){return new De(void 0,Ie,void 0,void 0,t)}}function Ut(t,r,l,c){let p=r+1>l+20?r-l-1:0,h=t.slice(p,r);return h.push(c),h}function la(t,r){let l=[],c=!1;return t.iterChangedRanges((p,h)=>l.push(p,h)),r.iterChangedRanges((p,h,g,y)=>{for(let x=0;x<l.length;){let w=l[x++],v=l[x++];if(y>=w&&g<=v)c=!0}}),c}function aa(t,r){return t.ranges.length==r.ranges.length&&t.ranges.filter((l,c)=>l.empty!=r.ranges[c].empty).length===0}function Yo(t,r){return!t.length?r:!r.length?t:t.concat(r)}var Ie=[],ca=200;function Qo(t,r){if(!t.length)return[De.selection([r])];else{let l=t[t.length-1],c=l.selectionsAfter.slice(Math.max(0,l.selectionsAfter.length-ca));if(c.length&&c[c.length-1].eq(r))return t;return c.push(r),Ut(t,t.length-1,1e9,l.setSelAfter(c))}}function ua(t){let r=t[t.length-1],l=t.slice();return l[t.length-1]=r.setSelAfter(r.selectionsAfter.slice(0,r.selectionsAfter.length-1)),l}function Nn(t,r){if(!t.length)return t;let l=t.length,c=Ie;while(l){let p=da(t[l-1],r,c);if(p.changes&&!p.changes.empty||p.effects.length){let h=t.slice(0,l);return h[l-1]=p,h}else r=p.mapped,l--,c=p.selectionsAfter}return c.length?[De.selection(c)]:Ie}function da(t,r,l){let c=Yo(t.selectionsAfter.length?t.selectionsAfter.map((y)=>y.map(r)):Ie,l);if(!t.changes)return De.selection(c);let p=t.changes.map(r),h=r.mapDesc(t.changes,!0),g=t.mapped?t.mapped.composeDesc(h):h;return new De(p,re.mapEffects(t.effects,r),g,t.startSelection.map(h),c)}var fa=/^(input\.type|delete)($|\.)/;class qe{constructor(t,r,l=0,c=void 0){this.done=t,this.undone=r,this.prevTime=l,this.prevUserEvent=c}isolate(){return this.prevTime?new qe(this.done,this.undone):this}addChanges(t,r,l,c,p){let h=this.done,g=h[h.length-1];if(g&&g.changes&&!g.changes.empty&&t.changes&&(!l||fa.test(l))&&(!g.selectionsAfter.length&&r-this.prevTime<c.newGroupDelay&&c.joinToEvent(p,la(g.changes,t.changes))||l=="input.type.compose"))h=Ut(h,h.length-1,c.minDepth,new De(t.changes.compose(g.changes),Yo(re.mapEffects(t.effects,g.changes),g.effects),g.mapped,g.startSelection,Ie));else h=Ut(h,h.length,c.minDepth,t);return new qe(h,Ie,r,l)}addSelection(t,r,l,c){let p=this.done.length?this.done[this.done.length-1].selectionsAfter:Ie;if(p.length>0&&r-this.prevTime<c&&l==this.prevUserEvent&&l&&/^select($|\.)/.test(l)&&aa(p[p.length-1],t))return this;return new qe(Qo(this.done,t),this.undone,r,l)}addMapping(t){return new qe(Nn(this.done,t),Nn(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,r,l){let c=t==0?this.done:this.undone;if(c.length==0)return null;let p=c[c.length-1],h=p.selectionsAfter[0]||(p.startSelection?p.startSelection.map(p.changes.invertedDesc,1):r.selection);if(l&&p.selectionsAfter.length)return r.update({selection:p.selectionsAfter[p.selectionsAfter.length-1],annotations:Vn.of({side:t,rest:ua(c),selection:h}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});else if(!p.changes)return null;else{let g=c.length==1?Ie:c.slice(0,c.length-1);if(p.mapped)g=Nn(g,p.mapped);return r.update({changes:p.changes,selection:p.startSelection,effects:p.effects,annotations:Vn.of({side:t,rest:g,selection:h}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}}}qe.empty=new qe(Ie,Ie);function mt(t,r){return k.create(t.ranges.map(r),t.mainIndex)}function Ve(t,r){return t.update({selection:r,scrollIntoView:!0,userEvent:"select"})}function Ue({state:t,dispatch:r},l){let c=mt(t.selection,l);if(c.eq(t.selection,!0))return!1;return r(Ve(t,c)),!0}function zt(t,r){return k.cursor(r?t.to:t.from)}function Zo(t,r){return Ue(t,(l)=>l.empty?t.moveByChar(l,r):zt(l,r))}function we(t){return t.textDirectionAt(t.state.selection.main.head)==Me.LTR}var ei=(t)=>Zo(t,!we(t)),ti=(t)=>Zo(t,we(t));function ni(t,r){return Ue(t,(l)=>l.empty?t.moveByGroup(l,r):zt(l,r))}var ma=(t)=>ni(t,!we(t)),pa=(t)=>ni(t,we(t));var ep=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function ha(t,r,l){if(r.type.prop(l))return!0;let c=r.to-r.from;return c&&(c>2||/[^\s,.;:]/.test(t.sliceDoc(r.from,r.to)))||r.firstChild}function Xt(t,r,l){let c=Mn(t).resolveInner(r.head),p=l?xe.closedBy:xe.openedBy;for(let x=r.head;;){let w=l?c.childAfter(x):c.childBefore(x);if(!w)break;if(ha(t,w,p))c=w;else x=l?w.to:w.from}let h=c.type.prop(p),g,y;if(h&&(g=l?Br(t,c.from,1):Br(t,c.to,-1))&&g.matched)y=l?g.end.to:g.end.from;else y=l?c.to:c.from;return k.cursor(y,l?-1:1)}var ga=(t)=>Ue(t,(r)=>Xt(t.state,r,!we(t))),ba=(t)=>Ue(t,(r)=>Xt(t.state,r,we(t)));function ri(t,r){return Ue(t,(l)=>{if(!l.empty)return zt(l,r);let c=t.moveVertically(l,r);return c.head!=l.head?c:t.moveToLineBoundary(l,r)})}var oi=(t)=>ri(t,!1),ii=(t)=>ri(t,!0);function li(t){let r=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,l=0,c=0,p;if(r){for(let h of t.state.facet(_.scrollMargins)){let g=h(t);if(g===null||g===void 0?void 0:g.top)l=Math.max(g===null||g===void 0?void 0:g.top,l);if(g===null||g===void 0?void 0:g.bottom)c=Math.max(g===null||g===void 0?void 0:g.bottom,c)}p=t.scrollDOM.clientHeight-l-c}else p=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:l,marginBottom:c,selfScroll:r,height:Math.max(t.defaultLineHeight,p-5)}}function ai(t,r){let l=li(t),{state:c}=t,p=mt(c.selection,(g)=>g.empty?t.moveVertically(g,r,l.height):zt(g,r));if(p.eq(c.selection))return!1;let h;if(l.selfScroll){let g=t.coordsAtPos(c.selection.main.head),y=t.scrollDOM.getBoundingClientRect(),x=y.top+l.marginTop,w=y.bottom-l.marginBottom;if(g&&g.top>x&&g.bottom<w)h=_.scrollIntoView(p.main.head,{y:"start",yMargin:g.top-x})}return t.dispatch(Ve(c,p),{effects:h}),!0}var Vo=(t)=>ai(t,!1),Wn=(t)=>ai(t,!0);function Ze(t,r,l){let c=t.lineBlockAt(r.head),p=t.moveToLineBoundary(r,l);if(p.head==r.head&&p.head!=(l?c.to:c.from))p=t.moveToLineBoundary(r,l,!1);if(!l&&p.head==c.from&&c.length){let h=/^\s*/.exec(t.state.sliceDoc(c.from,Math.min(c.from+100,c.to)))[0].length;if(h&&r.head!=c.from+h)p=k.cursor(c.from+h)}return p}var ya=(t)=>Ue(t,(r)=>Ze(t,r,!0)),va=(t)=>Ue(t,(r)=>Ze(t,r,!1)),ka=(t)=>Ue(t,(r)=>Ze(t,r,!we(t))),wa=(t)=>Ue(t,(r)=>Ze(t,r,we(t))),Xn=(t)=>Ue(t,(r)=>t.moveToLineBoundary(r,!1,!1)),Yn=(t)=>Ue(t,(r)=>t.moveToLineBoundary(r,!0,!1));function Sa(t,r,l){let c=!1,p=mt(t.selection,(h)=>{let g=Br(t,h.head,-1)||Br(t,h.head,1)||h.head>0&&Br(t,h.head-1,1)||h.head<t.doc.length&&Br(t,h.head+1,-1);if(!g||!g.end)return h;c=!0;let y=g.start.from==h.head?g.end.to:g.end.from;return l?k.range(h.anchor,y):k.cursor(y)});if(!c)return!1;return r(Ve(t,p)),!0}var Ca=({state:t,dispatch:r})=>Sa(t,r,!1);function Be(t,r,l){let c=mt(t.state.selection,(p)=>{if(p.undirectional&&p.head>=p.anchor!=r)p=k.range(p.head,p.anchor);let h=l(p);return k.range(p.anchor,h.head,h.goalColumn,h.bidiLevel||void 0,h.assoc)});if(c.eq(t.state.selection))return!1;return t.dispatch(Ve(t.state,c)),!0}function ci(t,r){return Be(t,r,(l)=>t.moveByChar(l,r))}var di=(t)=>ci(t,!we(t)),fi=(t)=>ci(t,we(t));function mi(t,r){return Be(t,r,(l)=>t.moveByGroup(l,r))}var Ea=(t)=>mi(t,!we(t)),Ma=(t)=>mi(t,we(t));var Ra=(t)=>{let r=!we(t);return Be(t,r,(l)=>Xt(t.state,l,r))},Da=(t)=>{let r=we(t);return Be(t,r,(l)=>Xt(t.state,l,r))};function pi(t,r){return Be(t,r,(l)=>t.moveVertically(l,r))}var gi=(t)=>pi(t,!1),bi=(t)=>pi(t,!0);function xi(t,r){return Be(t,r,(l)=>t.moveVertically(l,r,li(t).height))}var Wo=(t)=>xi(t,!1),_o=(t)=>xi(t,!0),Ta=(t)=>Be(t,!0,(r)=>Ze(t,r,!0)),Aa=(t)=>Be(t,!1,(r)=>Ze(t,r,!1)),Oa=(t)=>{let r=!we(t);return Be(t,r,(l)=>Ze(t,l,r))},Ia=(t)=>{let r=we(t);return Be(t,r,(l)=>Ze(t,l,r))},Qn=(t)=>Be(t,!1,(r)=>k.cursor(t.lineBlockAt(r.head).from)),er=(t)=>Be(t,!0,(r)=>k.cursor(t.lineBlockAt(r.head).to)),$t=({state:t,dispatch:r})=>(r(Ve(t,{anchor:0})),!0),_t=({state:t,dispatch:r})=>(r(Ve(t,{anchor:t.doc.length})),!0),Ht=({state:t,dispatch:r})=>(r(Ve(t,{anchor:t.selection.main.anchor,head:0})),!0),qt=({state:t,dispatch:r})=>(r(Ve(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),Ba=({state:t,dispatch:r})=>(r(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),tr=({state:t,dispatch:r})=>{let l=Yt(t).map(({from:c,to:p})=>k.undirectionalRange(c,Math.min(p+1,t.doc.length)));return r(t.update({selection:k.create(l),userEvent:"select"})),!0},Fa=({state:t,dispatch:r})=>{let l=mt(t.selection,(c)=>{let p=Mn(t),h=p.resolveStack(c.from,1);if(c.empty){let g=p.resolveStack(c.from,-1);if(g.node.from>=h.node.from&&g.node.to<=h.node.to)h=g}for(let g=h;g;g=g.next){let{node:y}=g;if((y.from<c.from&&y.to>=c.to||y.to>c.to&&y.from<=c.from)&&g.next)return k.undirectionalRange(y.from,y.to)}return c});if(l.eq(t.selection))return!1;return r(Ve(t,l)),!0};function vi(t,r){let{state:l}=t,c=l.selection,p=l.selection.ranges.slice();for(let h of l.selection.ranges){let g=l.doc.lineAt(h.head);if(r?g.to<t.state.doc.length:g.from>0)for(let y=h;;){let x=t.moveVertically(y,r);if(x.head<g.from||x.head>g.to){if(!p.some((w)=>w.head==x.head))p.push(x);break}else if(x.head==y.head)break;else y=x}}if(p.length==c.ranges.length)return!1;return t.dispatch(Ve(l,k.create(p,p.length-1))),!0}var nr=(t)=>vi(t,!1),rr=(t)=>vi(t,!0),or=({state:t,dispatch:r})=>{let l=t.selection,c=null;if(l.ranges.length>1)c=k.create([l.main]);else if(!l.main.empty)c=k.create([k.cursor(l.main.head)]);if(!c)return!1;return r(Ve(t,c)),!0};function Et(t,r){if(t.state.readOnly)return!1;let l="delete.selection",{state:c}=t,p=c.changeByRange((h)=>{let{from:g,to:y}=h;if(g==y){let x=r(h);if(x<g)l="delete.backward",x=Wt(t,x,!1);else if(x>g)l="delete.forward",x=Wt(t,x,!0);g=Math.min(g,x),y=Math.max(y,x)}else g=Wt(t,g,!1),y=Wt(t,y,!0);return g==y?{range:h}:{changes:{from:g,to:y},range:k.cursor(g,g<h.head?-1:1)}});if(p.changes.empty)return!1;return t.dispatch(c.update(p,{scrollIntoView:!0,userEvent:l,effects:l=="delete.selection"?_.announce.of(c.phrase("Selection deleted")):void 0})),!0}function Wt(t,r,l){if(t instanceof _)for(let c of t.state.facet(_.atomicRanges).map((p)=>p(t)))c.between(r,r,(p,h)=>{if(p<r&&h>r)r=l?h:p});return r}var ki=(t,r,l)=>Et(t,(c)=>{let p=c.from,{state:h}=t,g=h.doc.lineAt(p),y,x;if(l&&!r&&p>g.from&&p<g.from+200&&!/[^ \t]/.test(y=g.text.slice(0,p-g.from))){if(y[y.length-1]=="\t")return p-1;let w=Wa(y,h.tabSize),v=w%so(h)||so(h);for(let E=0;E<v&&y[y.length-1-E]==" ";E++)p--;x=p}else if(x=un(g.text,p-g.from,r,r)+g.from,x==p&&g.number!=(r?h.doc.lines:1))x+=r?1:-1;else if(!r&&/[\ufe00-\ufe0f]/.test(g.text.slice(x-g.from,p-g.from)))x=un(g.text,x-g.from,!1,!1)+g.from;return x}),Un=(t)=>ki(t,!1,!0);var Si=(t)=>ki(t,!0,!1),Ci=(t,r)=>Et(t,(l)=>{let c=l.head,{state:p}=t,h=p.doc.lineAt(c),g=p.charCategorizer(c);for(let y=null;;){if(c==(r?h.to:h.from)){if(c==l.head&&h.number!=(r?p.doc.lines:1))c+=r?1:-1;break}let x=un(h.text,c-h.from,r)+h.from,w=h.text.slice(Math.min(c,x)-h.from,Math.max(c,x)-h.from),v=g(w);if(y!=null&&v!=y)break;if(w!=" "||c!=l.head)y=v;c=x}return c}),Ei=(t)=>Ci(t,!1),Na=(t)=>Ci(t,!0);var Va=(t)=>Et(t,(r)=>{let l=t.lineBlockAt(r.head).to;return r.head<l?l:Math.min(t.state.doc.length,r.head+1)});var Ua=(t)=>Et(t,(r)=>{let l=t.moveToLineBoundary(r,!1).head;return r.head>l?l:Math.max(0,r.head-1)}),$a=(t)=>Et(t,(r)=>{let l=t.moveToLineBoundary(r,!0).head;return r.head<l?l:Math.min(t.state.doc.length,r.head+1)});var _a=({state:t,dispatch:r})=>{if(t.readOnly)return!1;let l=t.changeByRange((c)=>({changes:{from:c.from,to:c.to,insert:ke.of(["",""])},range:k.cursor(c.from)}));return r(t.update(l,{scrollIntoView:!0,userEvent:"input"})),!0},Ka=({state:t,dispatch:r})=>{if(t.readOnly)return!1;let l=t.changeByRange((c)=>{if(!c.empty||c.from==0||c.from==t.doc.length)return{range:c};let p=c.from,h=t.doc.lineAt(p),g=p==h.from?p-1:un(h.text,p-h.from,!1)+h.from,y=p==h.to?p+1:un(h.text,p-h.from,!0)+h.from;return{changes:{from:g,to:y,insert:t.doc.slice(p,y).append(t.doc.slice(g,p))},range:k.cursor(y)}});if(l.changes.empty)return!1;return r(t.update(l,{scrollIntoView:!0,userEvent:"move.character"})),!0};function Yt(t){let r=[],l=-1;for(let c of t.selection.ranges){let p=t.doc.lineAt(c.from),h=t.doc.lineAt(c.to);if(!c.empty&&c.to==h.from)h=t.doc.lineAt(c.to-1);if(l>=p.number){let g=r[r.length-1];g.to=h.to,g.ranges.push(c)}else r.push({from:p.from,to:h.to,ranges:[c]});l=h.number+1}return r}function Mi(t,r,l){if(t.readOnly)return!1;let c=[],p=[];for(let h of Yt(t)){if(l?h.to==t.doc.length:h.from==0)continue;let g=t.doc.lineAt(l?h.to+1:h.from-1),y=g.length+1;if(l){c.push({from:h.to,to:g.to},{from:h.from,insert:g.text+t.lineBreak});for(let x of h.ranges)p.push(k.range(Math.min(t.doc.length,x.anchor+y),Math.min(t.doc.length,x.head+y)))}else{c.push({from:g.from,to:h.from},{from:h.to,insert:t.lineBreak+g.text});for(let x of h.ranges)p.push(k.range(x.anchor-y,x.head-y))}}if(!c.length)return!1;return r(t.update({changes:c,scrollIntoView:!0,selection:k.create(p,t.selection.mainIndex),userEvent:"move.line"})),!0}var ir=({state:t,dispatch:r})=>Mi(t,r,!1),sr=({state:t,dispatch:r})=>Mi(t,r,!0);function Ri(t,r,l){if(t.readOnly)return!1;let c=[];for(let h of Yt(t))if(l)c.push({from:h.from,insert:t.doc.slice(h.from,h.to)+t.lineBreak});else c.push({from:h.to,insert:t.lineBreak+t.doc.slice(h.from,h.to)});let p=t.changes(c);return r(t.update({changes:p,selection:t.selection.map(p,l?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}var lr=({state:t,dispatch:r})=>Ri(t,r,!1),ar=({state:t,dispatch:r})=>Ri(t,r,!0),cr=(t)=>{if(t.state.readOnly)return!1;let{state:r}=t,l=r.changes(Yt(r).map(({from:p,to:h})=>{if(p>0)p--;else if(h<r.doc.length)h++;return{from:p,to:h}})),c=mt(r.selection,(p)=>{let h=void 0;if(t.lineWrapping){let g=t.lineBlockAt(p.head),y=t.coordsAtPos(p.head,p.assoc||1);if(y)h=g.bottom+t.documentTop-y.bottom+t.defaultLineHeight/2}return t.moveVertically(p,!0,h)}).map(l);return t.dispatch({changes:l,selection:c,scrollIntoView:!0,userEvent:"delete.line"}),!0};function za(t,r){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(r-1,r+1)))return{from:r,to:r};let l=Mn(t).resolveInner(r),c=l.childBefore(r),p=l.childAfter(r),h;if(c&&p&&c.to<=r&&p.from>=r&&(h=c.type.prop(xe.closedBy))&&h.indexOf(p.name)>-1&&t.doc.lineAt(c.to).from==t.doc.lineAt(p.from).from&&!/\S/.test(t.sliceDoc(c.to,p.from)))return{from:c.to,to:p.from};return null}var Ko=Di(!1),ur=Di(!0);function Di(t){return({state:r,dispatch:l})=>{if(r.readOnly)return!1;let c=r.changeByRange((p)=>{let{from:h,to:g}=p,y=r.doc.lineAt(h),x=!t&&h==g&&za(r,h);if(t)h=g=(g<=y.to?y:r.doc.lineAt(g)).to;let w=new Xs(r,{simulateBreak:h,simulateDoubleBreak:!!x}),v=Hu(w,h);if(v==null)v=Wa(/^\s*/.exec(r.doc.lineAt(h).text)[0],r.tabSize);while(g<y.to&&/\s/.test(y.text[g-y.from]))g++;if(x)({from:h,to:g}=x);else if(h>y.from&&h<y.from+100&&!/\S/.test(y.text.slice(0,h)))h=y.from;let E=["",Zs(r,v)];if(x)E.push(Zs(r,w.lineIndent(y.from,-1)));return{changes:{from:h,to:g,insert:ke.of(E)},range:k.cursor(h+1+E[1].length)}});return l(r.update(c,{scrollIntoView:!0,userEvent:"input"})),!0}}function fr(t,r){let l=-1;return t.changeByRange((c)=>{let p=[];for(let g=c.from;g<=c.to;){let y=t.doc.lineAt(g);if(y.number>l&&(c.empty||c.to>y.from))r(y,p,c),l=y.number;g=y.to+1}let h=t.changes(p);return{changes:p,range:k.range(h.mapPos(c.anchor,1),h.mapPos(c.head,1))}})}var ja=({state:t,dispatch:r})=>{if(t.readOnly)return!1;let l=Object.create(null),c=new Xs(t,{overrideIndentation:(h)=>{let g=l[h];return g==null?-1:g}}),p=fr(t,(h,g,y)=>{let x=Hu(c,h.from);if(x==null)return;if(!/\S/.test(h.text))x=0;let w=/^\s*/.exec(h.text)[0],v=Zs(t,x);if(w!=v||y.from<h.from+w.length)l[h.from]=x,g.push({from:h.from,to:h.from+w.length,insert:v})});if(!p.changes.empty)r(t.update(p,{userEvent:"indent"}));return!0},Qt=({state:t,dispatch:r})=>{if(t.readOnly)return!1;return r(t.update(fr(t,(l,c)=>{c.push({from:l.from,insert:t.facet(ts)})}),{userEvent:"input.indent"})),!0},Zt=({state:t,dispatch:r})=>{if(t.readOnly)return!1;return r(t.update(fr(t,(l,c)=>{let p=/^\s*/.exec(l.text)[0];if(!p)return;let h=Wa(p,t.tabSize),g=0,y=Zs(t,Math.max(0,h-so(t)));while(g<p.length&&g<y.length&&p.charCodeAt(g)==y.charCodeAt(g))g++;c.push({from:l.from+g,to:l.from+p.length,insert:y.slice(g)})}),{userEvent:"delete.dedent"})),!0},Ga=(t)=>(t.setTabFocusMode(),!0);var Ja=[{key:"Ctrl-b",run:ei,shift:di,preventDefault:!0},{key:"Ctrl-f",run:ti,shift:fi},{key:"Ctrl-p",run:oi,shift:gi},{key:"Ctrl-n",run:ii,shift:bi},{key:"Ctrl-a",run:Xn,shift:Qn},{key:"Ctrl-e",run:Yn,shift:er},{key:"Ctrl-d",run:Si},{key:"Ctrl-h",run:Un},{key:"Ctrl-k",run:Va},{key:"Ctrl-Alt-h",run:Ei},{key:"Ctrl-o",run:_a},{key:"Ctrl-t",run:Ka},{key:"Ctrl-v",run:Wn}],Xa=[{key:"ArrowLeft",run:ei,shift:di,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:ma,shift:Ea,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:ka,shift:Oa,preventDefault:!0},{key:"ArrowRight",run:ti,shift:fi,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:pa,shift:Ma,preventDefault:!0},{mac:"Cmd-ArrowRight",run:wa,shift:Ia,preventDefault:!0},{key:"ArrowUp",run:oi,shift:gi,preventDefault:!0},{mac:"Cmd-ArrowUp",run:$t,shift:Ht},{mac:"Ctrl-ArrowUp",run:Vo,shift:Wo},{key:"ArrowDown",run:ii,shift:bi,preventDefault:!0},{mac:"Cmd-ArrowDown",run:_t,shift:qt},{mac:"Ctrl-ArrowDown",run:Wn,shift:_o},{key:"PageUp",run:Vo,shift:Wo},{key:"PageDown",run:Wn,shift:_o},{key:"Home",run:va,shift:Aa,preventDefault:!0},{key:"Mod-Home",run:$t,shift:Ht},{key:"End",run:ya,shift:Ta,preventDefault:!0},{key:"Mod-End",run:_t,shift:qt},{key:"Enter",run:Ko,shift:Ko},{key:"Mod-a",run:Ba},{key:"Backspace",run:Un,shift:Un,preventDefault:!0},{key:"Delete",run:Si,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Ei,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:Na,preventDefault:!0},{mac:"Mod-Backspace",run:Ua,preventDefault:!0},{mac:"Mod-Delete",run:$a,preventDefault:!0}].concat(Ja.map((t)=>({mac:t.key,run:t.run,shift:t.shift}))),Ti=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ga,shift:Ra},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:ba,shift:Da},{key:"Alt-ArrowUp",run:ir},{key:"Shift-Alt-ArrowUp",run:lr},{key:"Alt-ArrowDown",run:sr},{key:"Shift-Alt-ArrowDown",run:ar},{key:"Mod-Alt-ArrowUp",run:nr},{key:"Mod-Alt-ArrowDown",run:rr},{key:"Escape",run:or},{key:"Mod-Enter",run:ur},{key:"Alt-l",mac:"Ctrl-l",run:tr},{key:"Mod-i",run:Fa,preventDefault:!0},{key:"Mod-[",run:Zt},{key:"Mod-]",run:Qt},{key:"Mod-Alt-\\",run:ja},{key:"Shift-Mod-k",run:cr},{key:"Shift-Mod-\\",run:Ca},{key:"Mod-/",run:$n},{key:"Alt-A",mac:"Ctrl-A",run:Kn},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Ga}].concat(Xa);var Ya={python:{line:"#"},bash:{line:"#"},yaml:{line:"#"},toml:{line:"#"},ruby:{line:"#"},perl:{line:"#"},r:{line:"#"},makefile:{line:"#"},dockerfile:{line:"#"},ini:{line:"#"},properties:{line:"#"},elixir:{line:"#"},graphql:{line:"#"},nix:{line:"#"},sql:{line:"--"},lua:{line:"--"},haskell:{line:"--"},css:{block:["/*","*/"]},scss:{block:["/*","*/"]},less:{block:["/*","*/"]},sass:{block:["/*","*/"]},stylus:{block:["/*","*/"]},html:{block:["<!--","-->"]},xml:{block:["<!--","-->"]},markdown:{block:["<!--","-->"]}};function Ai(t){return Ya[t]??{line:"//"}}function Li(t){return/^[ \t]*/.exec(t)?.[0].length??0}var Te=(t)=>/[{[(\[]$/.test(t.trimEnd()),ge=/^[ \t]*[}\])]$/,en={yaml:{opens:(t)=>/:\s*$/.test(t.trimEnd())&&!/^[ \t]*#/.test(t)},toml:{opens:Te,closes:ge},ini:{opens:Te,closes:ge},hcl:{opens:Te,closes:ge},protobuf:{opens:Te,closes:ge},graphql:{opens:Te,closes:ge},nix:{opens:Te,closes:ge},svelte:{opens:Te,closes:ge},astro:{opens:Te,closes:ge},vue:{opens:Te,closes:ge},zig:{opens:Te,closes:ge},solidity:{opens:Te,closes:ge},php:{opens:Te,closes:ge},powershell:{opens:Te,closes:ge},perl:{opens:Te,closes:ge},bash:{opens:(t)=>/\b(then|do|else)\s*$/.test(t.trimEnd()),closes:/^[ \t]*(fi|done|esac|\})$/},haskell:{opens:(t)=>/(=|\bwhere|\bdo|\bof|\bthen|\belse)\s*$/.test(t.trimEnd())},ocaml:{opens:(t)=>/(=|\bdo|\bthen|\belse|\bin|\bwith)\s*$/.test(t.trimEnd())},dockerfile:{opens:(t)=>/\\$/.test(t.trimEnd())},html:{opens:(t)=>{let r=t.trimEnd();return/<[a-zA-Z][^<>]*>$/.test(r)&&!/\/>$/.test(r)},closes:/^[ \t]*<\//},sql:{opens:()=>!1},makefile:{opens:()=>!1},properties:{opens:()=>!1},markdown:{opens:()=>!1},diff:{opens:()=>!1},text:{opens:()=>!1},go:{closes:ge},tsx:{closes:ge},jsx:{closes:ge}};function Oi(t){let r=en[t];return r!==void 0&&(r.opens!==void 0||r.closes!==void 0)}function Ii(t,r,l=2){let c=en[t]?.opens;if(!c)return null;let p=Li(r);return c(r)?p+l:p}function Bi(t,r,l=2){if(!en[t]?.closes?.test(r))return null;return Math.max(0,Li(r)-l)}function Pi(t){return en[t]?.closes??null}var Qa=200;function Za(t){return(r,l)=>{if(!Oi(t))return;let c=r.lineAt(l,-1);for(let h=0;h<Qa&&!c.text.trim()&&c.from>0;h++)c=r.lineAt(Math.max(0,c.from-1),-1);if(!c.text.trim())return;let p=Bi(t,c.text,r.unit);if(p!==null)return p;return Ii(t,c.text,r.unit)??void 0}}function tc(t){let r=Pi(t);return r?[{indentOnInput:r}]:[]}function Ni(t){return[Vf(),Qm.of(Za(t))]}function Vi(t){return ue.languageData.of(()=>tc(t))}class yr{constructor(t,r,l,c){this.state=t,this.pos=r,this.explicit=l,this.view=c,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let r=Mn(this.state).resolveInner(this.pos,-1);while(r&&t.indexOf(r.name)<0)r=r.parent;return r?{from:r.from,to:this.pos,text:this.state.sliceDoc(r.from,this.pos),type:r.type}:null}matchBefore(t){let r=this.state.doc.lineAt(this.pos),l=Math.max(r.from,this.pos-250),c=r.text.slice(l-r.from,this.pos-r.from),p=c.search(zi(t,!1));return p<0?null:{from:l+p,to:this.pos,text:c.slice(p)}}get aborted(){return this.abortListeners==null}addEventListener(t,r,l){if(t=="abort"&&this.abortListeners){if(this.abortListeners.push(r),l&&l.onDocChange)this.abortOnDocChange=!0}}}function Wi(t){let r=Object.keys(t).join(""),l=/\w/.test(r);if(l)r=r.replace(/\w/g,"");return`[${l?"\\w":""}${r.replace(/[^\w\s]/g,"\\$&")}]`}function nc(t){let r=Object.create(null),l=Object.create(null);for(let{label:p}of t){r[p[0]]=!0;for(let h=1;h<p.length;h++)l[p[h]]=!0}let c=Wi(r)+Wi(l)+"*$";return[new RegExp("^"+c),new RegExp(c)]}function rc(t){let r=t.map((p)=>typeof p=="string"?{label:p}:p),[l,c]=r.every((p)=>/^\w+$/.test(p.label))?[/\w*$/,/\w+$/]:nc(r);return(p)=>{let h=p.matchBefore(c);return h||p.explicit?{from:h?h.from:p.pos,options:r,validFor:l}:null}}class br{constructor(t,r,l,c){this.completion=t,this.source=r,this.match=l,this.score=c}}function nt(t){return t.selection.main.from}function zi(t,r){var l;let{source:c}=t,p=r&&c[0]!="^",h=c[c.length-1]!="$";if(!p&&!h)return t;return new RegExp(`${p?"^":""}(?:${c})${h?"$":""}`,(l=t.flags)!==null&&l!==void 0?l:t.ignoreCase?"i":"")}var ji=Xr.define();function oc(t,r,l,c){let{main:p}=t.selection,h=l-p.from,g=c-p.from;return{...t.changeByRange((y)=>{if(y!=p&&l!=c&&t.sliceDoc(y.from+h,y.from+g)!=t.sliceDoc(l,c))return{range:y};let x=t.toText(r);return{changes:{from:y.from+h,to:c==p.from?y.to:y.from+g,insert:x},range:k.cursor(y.from+h+x.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}var Ui=new WeakMap;function ic(t){if(!Array.isArray(t))return t;let r=Ui.get(t);if(!r)Ui.set(t,r=rc(t));return r}var rn=re.define(),Mt=re.define();class Gi{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let r=0;r<t.length;){let l=Rn(t,r),c=Zr(l);this.chars.push(l);let p=t.slice(r,r+c),h=p.toUpperCase();this.folded.push(Rn(h==p?p.toLowerCase():h,0)),r+=c}this.astral=t.length!=this.chars.length}ret(t,r){return this.score=t,this.matched=r,this}match(t){if(this.pattern.length==0)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:r,folded:l,any:c,precise:p,byWord:h}=this;if(r.length==1){let R=Rn(t,0),A=Zr(R),N=A==t.length?0:-100;if(R==r[0]);else if(R==l[0])N+=-200;else return null;return this.ret(N,[0,A])}let g=t.indexOf(this.pattern);if(g==0)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let y=r.length,x=0;if(g<0){for(let R=0,A=Math.min(t.length,200);R<A&&x<y;){let N=Rn(t,R);if(N==r[x]||N==l[x])c[x++]=R;R+=Zr(N)}if(x<y)return null}let w=0,v=0,E=!1,M=0,L=-1,O=-1,F=/[a-z]/.test(t),W=!0;for(let R=0,A=Math.min(t.length,200),N=0;R<A&&v<y;){let U=Rn(t,R);if(g<0){if(w<y&&U==r[w])p[w++]=R;if(M<y)if(U==r[M]||U==l[M]){if(M==0)L=R;O=R+1,M++}else M=0}let H,G=U<255?U>=48&&U<=57||U>=97&&U<=122?2:U>=65&&U<=90?1:0:(H=ju(U))!=H.toLowerCase()?1:H!=H.toUpperCase()?2:0;if(!R||G==1&&F||N==0&&G!=0){if(r[v]==U||l[v]==U&&(E=!0))h[v++]=R;else if(h.length)W=!1}N=G,R+=Zr(U)}if(v==y&&h[0]==0&&W)return this.result(-100+(E?-200:0),h,t);if(M==y&&L==0)return this.ret(-200-t.length+(O==t.length?0:-100),[0,O]);if(g>-1)return this.ret(-700-t.length,[g,g+this.pattern.length]);if(M==y)return this.ret(-900-t.length,[L,O]);if(v==y)return this.result(-100+(E?-200:0)+-700+(W?0:-1100),h,t);return r.length==2?null:this.result((c[0]?-700:0)+-200+-1100,c,t)}result(t,r,l){let c=[],p=0;for(let h of r){let g=h+(this.astral?Zr(Rn(l,h)):1);if(p&&c[p-1]==h)c[p-1]=g;else c[p++]=h,c[p++]=g}return this.ret(t-l.length,c)}}class Ji{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let r=t.slice(0,this.pattern.length),l=r==this.pattern?0:r.toLowerCase()==this.folded?-200:null;if(l==null)return null;return this.matched=[0,r.length],this.score=l+(t.length==this.pattern.length?0:-100),this}}var he=P.define({combine(t){return Jn(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:sc,filterStrict:!1,compareCompletions:(r,l)=>(r.sortText||r.label).localeCompare(l.sortText||l.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(r,l)=>r&&l,closeOnBlur:(r,l)=>r&&l,icons:(r,l)=>r&&l,tooltipClass:(r,l)=>(c)=>$i(r(c),l(c)),optionClass:(r,l)=>(c)=>$i(r(c),l(c)),addToOptions:(r,l)=>r.concat(l),filterStrict:(r,l)=>r||l})}});function $i(t,r){return t?r?t+" "+r:t:r}function sc(t,r,l,c,p,h){let g=t.textDirection==Me.RTL,y=g,x=!1,w="top",v,E,M=r.left-p.left,L=p.right-r.right,O=c.right-c.left,F=c.bottom-c.top;if(y&&M<Math.min(O,L))y=!1;else if(!y&&L<Math.min(O,M))y=!0;if(O<=(y?M:L))v=Math.max(p.top,Math.min(l.top,p.bottom-F))-r.top,E=Math.min(400,y?M:L);else{x=!0,E=Math.min(400,(g?r.right:p.right-r.left)-30);let A=p.bottom-r.bottom;if(A>=F||A>r.top)v=l.bottom-r.top;else w="bottom",v=r.bottom-l.top}let W=(r.bottom-r.top)/h.offsetHeight,R=(r.right-r.left)/h.offsetWidth;return{style:`${w}: ${v/W}px; max-width: ${E/R}px`,class:"cm-completionInfo-"+(x?g?"left-narrow":"right-narrow":y?"left":"right")}}var xr=re.define();function lc(t){let r=t.addToOptions.slice();if(t.icons)r.push({render(l){let c=document.createElement("div");if(c.classList.add("cm-completionIcon"),l.type)c.classList.add(...l.type.split(/\s+/g).map((p)=>"cm-completionIcon-"+p));return c.setAttribute("aria-hidden","true"),c},position:20});return r.push({render(l,c,p,h){let g=document.createElement("span");g.className="cm-completionLabel";let y=l.displayLabel||l.label,x=0;for(let w=0;w<h.length;){let v=h[w++],E=h[w++];if(v>x)g.appendChild(document.createTextNode(y.slice(x,v)));let M=g.appendChild(document.createElement("span"));M.appendChild(document.createTextNode(y.slice(v,E))),M.className="cm-completionMatchedText",x=E}if(x<y.length)g.appendChild(document.createTextNode(y.slice(x)));return g},position:50},{render(l){if(!l.detail)return null;let c=document.createElement("span");return c.className="cm-completionDetail",c.textContent=l.detail,c},position:80}),r.sort((l,c)=>l.position-c.position).map((l)=>l.render)}function mr(t,r,l){if(t<=l)return{from:0,to:t};if(r<0)r=0;if(r<=t>>1){let p=Math.floor(r/l);return{from:p*l,to:(p+1)*l}}let c=Math.ceil((t-r)/l);return{from:t-c*l,to:t-(c-1)*l}}class Xi{constructor(t,r,l){this.view=t,this.stateField=r,this.applyCompletion=l,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:(y)=>this.placeInfo(y),key:this},this.space=null,this.currentClass="";let c=t.state.field(r),{options:p,selected:h}=c.open,g=t.state.facet(he);this.optionContent=lc(g),this.optionClass=g.optionClass,this.tooltipClass=g.tooltipClass,this.range=mr(p.length,h,g.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",(y)=>{let{options:x}=t.state.field(r).open;for(let w=y.target,v;w&&w!=this.dom;w=w.parentNode)if(w.nodeName=="LI"&&(v=/-(\d+)$/.exec(w.id))&&+v[1]<x.length){this.applyCompletion(t,x[+v[1]]),y.preventDefault();return}if(y.target==this.list){let w=this.list.classList.contains("cm-completionListIncompleteTop")&&y.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&y.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;if(w!=null)t.dispatch({effects:xr.of(w)}),y.preventDefault()}}),this.dom.addEventListener("focusout",(y)=>{let x=t.state.field(this.stateField,!1);if(x&&x.tooltip&&t.state.facet(he).closeOnBlur&&y.relatedTarget!=t.contentDOM)t.dispatch({effects:Mt.of(null)})}),this.showOptions(p,c.id)}mount(){this.updateSel()}showOptions(t,r){if(this.list)this.list.remove();this.list=this.dom.appendChild(this.createListBox(t,r,this.range)),this.list.addEventListener("scroll",()=>{if(this.info)this.view.requestMeasure(this.placeInfoReq)})}update(t){var r;let l=t.state.field(this.stateField),c=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),l!=c){let{options:p,selected:h,disabled:g}=l.open;if(!c.open||c.open.options!=p)this.range=mr(p.length,h,t.state.facet(he).maxRenderedOptions),this.showOptions(p,l.id);if(this.updateSel(),g!=((r=c.open)===null||r===void 0?void 0:r.disabled))this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!g)}}updateTooltipClass(t){let r=this.tooltipClass(t);if(r!=this.currentClass){for(let l of this.currentClass.split(" "))if(l)this.dom.classList.remove(l);for(let l of r.split(" "))if(l)this.dom.classList.add(l);this.currentClass=r}}positioned(t){if(this.space=t,this.info)this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),r=t.open;if(r.selected>-1&&r.selected<this.range.from||r.selected>=this.range.to)this.range=mr(r.options.length,r.selected,this.view.state.facet(he).maxRenderedOptions),this.showOptions(r.options,t.id);let l=this.updateSelectedOption(r.selected);if(l){this.destroyInfo();let{completion:c}=r.options[r.selected],{info:p}=c;if(!p)return;let h=typeof p==="string"?document.createTextNode(p):p(c);if(!h)return;if("then"in h)h.then((g)=>{if(g&&this.view.state.field(this.stateField,!1)==t)this.addInfoPane(g,c)}).catch((g)=>bn(this.view.state,g,"completion info"));else this.addInfoPane(h,c),l.setAttribute("aria-describedby",this.info.id)}}addInfoPane(t,r){this.destroyInfo();let l=this.info=document.createElement("div");if(l.className="cm-tooltip cm-completionInfo",l.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),t.nodeType!=null)l.appendChild(t),this.infoDestroy=null;else{let{dom:c,destroy:p}=t;l.appendChild(c),this.infoDestroy=p||null}this.dom.appendChild(l),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let r=null;for(let l=this.list.firstChild,c=this.range.from;l;l=l.nextSibling,c++)if(l.nodeName!="LI"||!l.id)c--;else if(c==t){if(!l.hasAttribute("aria-selected"))l.setAttribute("aria-selected","true"),r=l}else if(l.hasAttribute("aria-selected"))l.removeAttribute("aria-selected"),l.removeAttribute("aria-describedby");if(r)cc(this.list,r);return r}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let r=this.dom.getBoundingClientRect(),l=this.info.getBoundingClientRect(),c=t.getBoundingClientRect(),p=this.space;if(!p){let h=this.dom.ownerDocument.documentElement;p={left:0,top:0,right:h.clientWidth,bottom:h.clientHeight}}if(c.top>Math.min(p.bottom,r.bottom)-10||c.bottom<Math.max(p.top,r.top)+10)return null;return this.view.state.facet(he).positionInfo(this.view,r,c,l,p,this.dom)}placeInfo(t){if(this.info)if(t){if(t.style)this.info.style.cssText=t.style;this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")}else this.info.style.cssText="top: -1e6px"}createListBox(t,r,l){let c=document.createElement("ul");c.id=r,c.setAttribute("role","listbox"),c.setAttribute("aria-expanded","true"),c.setAttribute("aria-label",this.view.state.phrase("Completions")),c.addEventListener("mousedown",(h)=>{if(h.target==c)h.preventDefault()});let p=null;for(let h=l.from;h<l.to;h++){let{completion:g,match:y}=t[h],{section:x}=g;if(x){let E=typeof x=="string"?x:x.name;if(E!=p&&(h>l.from||l.from==0))if(p=E,typeof x!="string"&&x.header)c.appendChild(x.header(x));else{let M=c.appendChild(document.createElement("completion-section"));M.textContent=E}}let w=c.appendChild(document.createElement("li"));w.id=r+"-"+h,w.setAttribute("role","option");let v=this.optionClass(g);if(v)w.className=v;for(let E of this.optionContent){let M=E(g,this.view.state,this.view,y);if(M)w.appendChild(M)}}if(l.from)c.classList.add("cm-completionListIncompleteTop");if(l.to<t.length)c.classList.add("cm-completionListIncompleteBottom");return c}destroyInfo(){if(this.info){if(this.infoDestroy)this.infoDestroy();this.info.remove(),this.info=null}}destroy(){this.destroyInfo()}}function ac(t,r){return(l)=>new Xi(l,t,r)}function cc(t,r){let l=t.getBoundingClientRect(),c=r.getBoundingClientRect(),p=l.height/t.offsetHeight;if(c.top<l.top)t.scrollTop-=(l.top-c.top)/p;else if(c.bottom>l.bottom)t.scrollTop+=(c.bottom-l.bottom)/p}function _i(t){return(t.boost||0)*100+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}function uc(t,r){let l=[],c=null,p=null,h=(v)=>{l.push(v);let{section:E}=v.completion;if(E){if(!c)c=[];let M=typeof E=="string"?E:E.name;if(!c.some((L)=>L.name==M))c.push(typeof E=="string"?{name:M}:E)}},g=r.facet(he);for(let v of t)if(v.hasResult()){let E=v.result.getMatch;if(v.result.filter===!1)for(let M of v.result.options)h(new br(M,v.source,E?E(M):[],1e9-l.length));else{let M=r.sliceDoc(v.from,v.to),L,O=g.filterStrict?new Ji(M):new Gi(M);for(let F of v.result.options)if(L=O.match(F.label)){let W=!F.displayLabel?L.matched:E?E(F,L.matched):[],R=L.score+(F.boost||0);if(h(new br(F,v.source,W,R)),typeof F.section=="object"&&F.section.rank==="dynamic"){let{name:A}=F.section;if(!p)p=Object.create(null);p[A]=Math.max(R,p[A]||-1e9)}}}}if(c){let v=Object.create(null),E=0,M=(L,O)=>(L.rank==="dynamic"&&O.rank==="dynamic"?p[O.name]-p[L.name]:0)||(typeof L.rank=="number"?L.rank:1e9)-(typeof O.rank=="number"?O.rank:1e9)||(L.name<O.name?-1:1);for(let L of c.sort(M))E-=1e5,v[L.name]=E;for(let L of l){let{section:O}=L.completion;if(O)L.score+=v[typeof O=="string"?O:O.name]}}let y=[],x=null,w=g.compareCompletions;for(let v of l.sort((E,M)=>M.score-E.score||w(E.completion,M.completion))){let E=v.completion;if(!x||x.label!=E.label||x.detail!=E.detail||x.type!=null&&E.type!=null&&x.type!=E.type||x.apply!=E.apply||x.boost!=E.boost)y.push(v);else if(_i(v.completion)>_i(x))y[y.length-1]=v;x=v.completion}return y}class pt{constructor(t,r,l,c,p,h){this.options=t,this.attrs=r,this.tooltip=l,this.timestamp=c,this.selected=p,this.disabled=h}setSelected(t,r){return t==this.selected||t>=this.options.length?this:new pt(this.options,Ki(r,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,r,l,c,p,h){if(c&&!h&&t.some((x)=>x.isPending))return c.setDisabled();let g=uc(t,r);if(!g.length)return c&&t.some((x)=>x.isPending)?c.setDisabled():null;let y=r.facet(he).selectOnOpen?0:-1;if(c&&c.selected!=y&&c.selected!=-1){let x=c.options[c.selected].completion;for(let w=0;w<g.length;w++)if(g[w].completion==x){y=w;break}}return new pt(g,Ki(l,y),{pos:t.reduce((x,w)=>w.hasResult()?Math.min(x,w.from):x,1e8),create:gc,above:p.aboveCursor},c?c.timestamp:Date.now(),y,!1)}map(t){return new pt(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new pt(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class on{constructor(t,r,l){this.active=t,this.id=r,this.open=l}static start(){return new on(pc,"cm-ac-"+Math.floor(Math.random()*2000000).toString(36),null)}update(t){let{state:r}=t,l=r.facet(he),p=(l.override||r.languageDataAt("autocomplete",nt(r)).map(ic)).map((y)=>(this.active.find((w)=>w.source==y)||new Fe(y,this.active.some((w)=>w.state!=0)?1:0)).update(t,l));if(p.length==this.active.length&&p.every((y,x)=>y==this.active[x]))p=this.active;let h=this.open,g=t.effects.some((y)=>y.is(vr));if(h&&t.docChanged)h=h.map(t.changes);if(t.selection||p.some((y)=>y.hasResult()&&t.changes.touchesRange(y.from,y.to))||!dc(p,this.active)||g)h=pt.build(p,r,this.id,h,l,g);else if(h&&h.disabled&&!p.some((y)=>y.isPending))h=null;if(!h&&p.every((y)=>!y.isPending)&&p.some((y)=>y.hasResult()))p=p.map((y)=>y.hasResult()?new Fe(y.source,0):y);for(let y of t.effects)if(y.is(xr))h=h&&h.setSelected(y.value,this.id);return p==this.active&&h==this.open?this:new on(p,this.id,h)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?fc:mc}}function dc(t,r){if(t==r)return!0;for(let l=0,c=0;;){while(l<t.length&&!t[l].hasResult())l++;while(c<r.length&&!r[c].hasResult())c++;let p=l==t.length,h=c==r.length;if(p||h)return p==h;if(t[l++].result!=r[c++].result)return!1}}var fc={"aria-autocomplete":"list"},mc={};function Ki(t,r){let l={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};if(r>-1)l["aria-activedescendant"]=t+"-"+r;return l}var pc=[];function Yi(t,r){if(t.isUserEvent("input.complete")){let c=t.annotation(ji);if(c&&r.activateOnCompletion(c))return 12}let l=t.isUserEvent("input.type");return l&&r.activateOnTyping?5:l?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class Fe{constructor(t,r,l=!1){this.source=t,this.state=r,this.explicit=l}hasResult(){return!1}get isPending(){return this.state==1}update(t,r){let l=Yi(t,r),c=this;if(l&8||l&16&&this.touches(t))c=new Fe(c.source,0);if(l&4&&c.state==0)c=new Fe(this.source,1);c=c.updateFor(t,l);for(let p of t.effects)if(p.is(rn))c=new Fe(c.source,1,p.value);else if(p.is(Mt))c=new Fe(c.source,0);else if(p.is(vr)){for(let h of p.value)if(h.source==c.source)c=h}return c}updateFor(t,r){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(nt(t.state))}}class gt extends Fe{constructor(t,r,l,c,p,h){super(t,3,r);this.limit=l,this.result=c,this.from=p,this.to=h}hasResult(){return!0}updateFor(t,r){var l;if(!(r&3))return this.map(t.changes);let c=this.result;if(c.map&&!t.changes.empty)c=c.map(c,t.changes);let p=t.changes.mapPos(this.from),h=t.changes.mapPos(this.to,1),g=nt(t.state);if(g>h||!c||r&2&&(nt(t.startState)==this.from||g<this.limit))return new Fe(this.source,r&4?1:0);let y=t.changes.mapPos(this.limit);if(hc(c.validFor,t.state,p,h))return new gt(this.source,this.explicit,y,c,p,h);if(c.update&&(c=c.update(c,p,h,new yr(t.state,g,!1))))return new gt(this.source,this.explicit,y,c,c.from,(l=c.to)!==null&&l!==void 0?l:nt(t.state));return new Fe(this.source,1,this.explicit)}map(t){if(t.empty)return this;let r=this.result.map?this.result.map(this.result,t):this.result;if(!r)return new Fe(this.source,0);return new gt(this.source,this.explicit,t.mapPos(this.limit),r,t.mapPos(this.from),t.mapPos(this.to,1))}touches(t){return t.changes.touchesRange(this.from,this.to)}}function hc(t,r,l,c){if(!t)return!1;let p=r.sliceDoc(l,c);return typeof t=="function"?t(p,l,c,r):zi(t,!0).test(p)}var vr=re.define({map(t,r){return t.map((l)=>l.map(r))}}),Ae=Qe.define({create(){return on.start()},update(t,r){return t.update(r)},provide:(t)=>[yc.from(t,(r)=>r.tooltip),_.contentAttributes.from(t,(r)=>r.attrs)]});function kr(t,r){let l=r.completion.apply||r.completion.label,c=t.state.field(Ae).active.find((p)=>p.source==r.source);if(!(c instanceof gt))return!1;if(typeof l=="string")t.dispatch({...oc(t.state,l,c.from,c.to),annotations:ji.of(r.completion)});else l(t,r.completion,c.from,c.to);return!0}var gc=ac(Ae,kr);function nn(t,r="option"){return(l)=>{let c=l.state.field(Ae,!1);if(!c||!c.open||c.open.disabled||Date.now()-c.open.timestamp<l.state.facet(he).interactionDelay)return!1;let p=1,h;if(r=="page"&&(h=Kf(l,c.open.tooltip)))p=Math.max(2,Math.floor(h.dom.offsetHeight/h.dom.querySelector("li").offsetHeight)-1);let{length:g}=c.open.options,y=c.open.selected>-1?c.open.selected+p*(t?1:-1):t?0:g-1;if(y<0)y=r=="page"?0:g-1;else if(y>=g)y=r=="page"?g-1:0;return l.dispatch({effects:xr.of(y)}),!0}}var bc=(t)=>{let r=t.state.field(Ae,!1);if(t.state.readOnly||!r||!r.open||r.open.selected<0||r.open.disabled||Date.now()-r.open.timestamp<t.state.facet(he).interactionDelay)return!1;return kr(t,r.open.options[r.open.selected])},pr=(t)=>{if(!t.state.field(Ae,!1))return!1;return t.dispatch({effects:rn.of(!0)}),!0},xc=(t)=>{let r=t.state.field(Ae,!1);if(!r||!r.active.some((l)=>l.state!=0))return!1;return t.dispatch({effects:Mt.of(null)}),!0};class Qi{constructor(t,r){this.active=t,this.context=r,this.time=Date.now(),this.updates=[],this.done=void 0}}var vc=50,wc=1000,Cc=ye.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let r of t.state.field(Ae).active)if(r.isPending)this.startQuery(r)}update(t){let r=t.state.field(Ae),l=t.state.facet(he);if(!t.selectionSet&&!t.docChanged&&t.startState.field(Ae)==r)return;let c=t.transactions.some((h)=>{let g=Yi(h,l);return g&8||(h.selection||h.docChanged)&&!(g&3)});for(let h=0;h<this.running.length;h++){let g=this.running[h];if(c||g.context.abortOnDocChange&&t.docChanged||g.updates.length+t.transactions.length>vc&&Date.now()-g.time>wc){for(let y of g.context.abortListeners)try{y()}catch(x){bn(this.view.state,x)}g.context.abortListeners=null,this.running.splice(h--,1)}else g.updates.push(...t.transactions)}if(this.debounceUpdate>-1)clearTimeout(this.debounceUpdate);if(t.transactions.some((h)=>h.effects.some((g)=>g.is(rn))))this.pendingStart=!0;let p=this.pendingStart?50:l.activateOnTypingDelay;if(this.debounceUpdate=r.active.some((h)=>h.isPending&&!this.running.some((g)=>g.active.source==h.source))?setTimeout(()=>this.startUpdate(),p):-1,this.composing!=0){for(let h of t.transactions)if(h.isUserEvent("input.type"))this.composing=2;else if(this.composing==2&&h.selection)this.composing=3}}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,r=t.field(Ae);for(let l of r.active)if(l.isPending&&!this.running.some((c)=>c.active.source==l.source))this.startQuery(l);if(this.running.length&&r.open&&r.open.disabled)this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(he).updateSyncTime)}startQuery(t){let{state:r}=this.view,l=nt(r),c=new yr(r,l,t.explicit,this.view),p=new Qi(t,c);this.running.push(p),Promise.resolve(t.source(c)).then((h)=>{if(!p.context.aborted)p.done=h||null,this.scheduleAccept()},(h)=>{this.view.dispatch({effects:Mt.of(null)}),bn(this.view.state,h)})}scheduleAccept(){if(this.running.every((t)=>t.done!==void 0))this.accept();else if(this.debounceAccept<0)this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(he).updateSyncTime)}accept(){var t;if(this.debounceAccept>-1)clearTimeout(this.debounceAccept);this.debounceAccept=-1;let r=[],l=this.view.state.facet(he),c=this.view.state.field(Ae);for(let p=0;p<this.running.length;p++){let h=this.running[p];if(h.done===void 0)continue;if(this.running.splice(p--,1),h.done){let y=nt(h.updates.length?h.updates[0].startState:this.view.state),x=Math.min(y,h.done.from+(h.active.explicit?0:1)),w=new gt(h.active.source,h.active.explicit,x,h.done,h.done.from,(t=h.done.to)!==null&&t!==void 0?t:y);for(let v of h.updates)w=w.update(v,l);if(w.hasResult()){r.push(w);continue}}let g=c.active.find((y)=>y.source==h.active.source);if(g&&g.isPending)if(h.done==null){let y=new Fe(h.active.source,0);for(let x of h.updates)y=y.update(x,l);if(!y.isPending)r.push(y)}else this.startQuery(g)}if(r.length||c.open&&c.open.disabled)this.view.dispatch({effects:vr.of(r)})}},{eventHandlers:{blur(t){let r=this.view.state.field(Ae,!1);if(r&&r.tooltip&&this.view.state.facet(he).closeOnBlur){let l=r.open&&Kf(this.view,r.open.tooltip);if(!l||!l.dom.contains(t.relatedTarget))setTimeout(()=>this.view.dispatch({effects:Mt.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){if(this.composing==3)setTimeout(()=>this.view.dispatch({effects:rn.of(!1)}),20);this.composing=0}}}),Ac=typeof navigator=="object"&&/Win/.test(navigator.platform),Vc=Cr.highest(_.domEventHandlers({keydown(t,r){let l=r.state.field(Ae,!1);if(!l||!l.open||l.open.disabled||l.open.selected<0||!t.key||t.key.length>1||t.ctrlKey&&!(Ac&&t.altKey)||t.metaKey)return!1;let c=l.open.options[l.open.selected],p=l.active.find((g)=>g.source==c.source),h=c.completion.commitCharacters||p.result.commitCharacters;if(h&&h.indexOf(t.key)>-1)kr(r,c);return!1}})),Wc=_.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:0.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:0.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'\uD835\uDC65'"}},".cm-completionIcon-constant":{"&:after":{content:"'\uD835\uDC36'"}},".cm-completionIcon-type":{"&:after":{content:"'\uD835\uDC61'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\uD83D\uDD11︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});var Rt={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},tt=re.define({map(t,r){let l=r.mapPos(t,-1,Fn.TrackAfter);return l==null?void 0:l}}),wr=new class extends Ha{};wr.startSide=1;wr.endSide=-1;var Zi=Qe.define({create(){return me.empty},update(t,r){if(t=t.map(r.changes),r.selection){let l=r.state.doc.lineAt(r.selection.main.head);t=t.update({filter:(c)=>c>=l.from&&c<=l.to})}for(let l of r.effects)if(l.is(tt))t=t.update({add:[wr.range(l.value,l.value+1)]});return t}});function es(){return[Hc,Zi]}var hr="()[]{}<>«»»«[]{}";function os(t){for(let r=0;r<hr.length;r+=2)if(hr.charCodeAt(r)==t)return hr.charAt(r+1);return ju(t<128?t:t+1)}function is(t,r){return t.languageDataAt("closeBrackets",r)[0]||Rt}var Kc=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Hc=_.inputHandler.of((t,r,l,c)=>{if((Kc?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let p=t.state.selection.main;if(c.length>2||c.length==2&&Zr(Rn(c,0))==1||r!=p.from||l!=p.to)return!1;let h=jc(t.state,c);if(!h)return!1;return t.dispatch(h),!0}),qc=({state:t,dispatch:r})=>{if(t.readOnly)return!1;let c=is(t,t.selection.main.head).brackets||Rt.brackets,p=null,h=t.changeByRange((g)=>{if(g.empty){let y=Gc(t.doc,g.head);for(let x of c)if(x==y&&sn(t.doc,g.head)==os(Rn(x,0)))return{changes:{from:g.head-x.length,to:g.head+x.length},range:k.cursor(g.head-x.length)}}return{range:p=g}});if(!p)r(t.update(h,{scrollIntoView:!0,userEvent:"delete.backward"}));return!p},ss=[{key:"Backspace",run:qc}];function jc(t,r){let l=is(t,t.selection.main.head),c=l.brackets||Rt.brackets;for(let p of c){let h=os(Rn(p,0));if(r==p)return h==p?Yc(t,p,c.indexOf(p+p+p)>-1,l):Jc(t,p,h,l.before||Rt.before);if(r==h&&ls(t,t.selection.main.from))return Xc(t,p,h)}return null}function ls(t,r){let l=!1;return t.field(Zi).between(0,t.doc.length,(c)=>{if(c==r)l=!0}),l}function sn(t,r){let l=t.sliceString(r,r+2);return l.slice(0,Zr(Rn(l,0)))}function Gc(t,r){let l=t.sliceString(r-2,r);return Zr(Rn(l,0))==l.length?l:l.slice(1)}function Jc(t,r,l,c){let p=null,h=t.changeByRange((g)=>{if(!g.empty)return{changes:[{insert:r,from:g.from},{insert:l,from:g.to}],effects:tt.of(g.to+r.length),range:k.range(g.anchor+r.length,g.head+r.length)};let y=sn(t.doc,g.head);if(!y||/\s/.test(y)||c.indexOf(y)>-1)return{changes:{insert:r+l,from:g.head},effects:tt.of(g.head+r.length),range:k.cursor(g.head+r.length)};return{range:p=g}});return p?null:t.update(h,{scrollIntoView:!0,userEvent:"input.type"})}function Xc(t,r,l){let c=null,p=t.changeByRange((h)=>{if(h.empty&&sn(t.doc,h.head)==l)return{changes:{from:h.head,to:h.head+l.length,insert:l},range:k.cursor(h.head+l.length)};return c={range:h}});return c?null:t.update(p,{scrollIntoView:!0,userEvent:"input.type"})}function Yc(t,r,l,c){let p=c.stringPrefixes||Rt.stringPrefixes,h=null,g=t.changeByRange((y)=>{if(!y.empty)return{changes:[{insert:r,from:y.from},{insert:r,from:y.to}],effects:tt.of(y.to+r.length),range:k.range(y.anchor+r.length,y.head+r.length)};let x=y.head,w=sn(t.doc,x),v;if(w==r){if(Hi(t,x))return{changes:{insert:r+r,from:x},effects:tt.of(x+r.length),range:k.cursor(x+r.length)};else if(ls(t,x)){let M=l&&t.sliceDoc(x,x+r.length*3)==r+r+r?r+r+r:r;return{changes:{from:x,to:x+M.length,insert:M},range:k.cursor(x+M.length)}}}else if(l&&t.sliceDoc(x-2*r.length,x)==r+r&&(v=qi(t,x-2*r.length,p))>-1&&Hi(t,v))return{changes:{insert:r+r+r+r,from:x},effects:tt.of(x+r.length),range:k.cursor(x+r.length)};else if(t.charCategorizer(x)(w)!=an.Word){if(qi(t,x,p)>-1&&!Zc(t,x,r,p))return{changes:{insert:r+r,from:x},effects:tt.of(x+r.length),range:k.cursor(x+r.length)}}return{range:h=y}});return h?null:t.update(g,{scrollIntoView:!0,userEvent:"input.type"})}function Hi(t,r){let l=Mn(t).resolveInner(r+1);return l.parent&&l.from==r}function Zc(t,r,l,c){let p=Mn(t).resolveInner(r,-1),h=c.reduce((g,y)=>Math.max(g,y.length),0);for(let g=0;g<5;g++){let y=t.sliceDoc(p.from,Math.min(p.to,p.from+l.length+h)),x=y.indexOf(l);if(!x||x>-1&&c.indexOf(y.slice(0,x))>-1){let v=p.firstChild;while(v&&v.from==p.from&&v.to-v.from>l.length+x){if(t.sliceDoc(v.to-l.length,v.to)==l)return!1;v=v.firstChild}return!0}let w=p.to==r&&p.parent;if(!w)break;p=w}return!1}function qi(t,r,l){let c=t.charCategorizer(r);if(c(t.sliceDoc(r-1,r))!=an.Word)return r;for(let p of l){let h=r-p.length;if(t.sliceDoc(h,r)==p&&c(t.sliceDoc(h-1,h))!=an.Word)return h}return-1}function cs(t={}){return[Vc,Ae,he.of(t),Cc,tu,Wc]}var eu=[{key:"Ctrl-Space",run:pr},{mac:"Alt-`",run:pr},{mac:"Alt-i",run:pr},{key:"Escape",run:xc},{key:"ArrowDown",run:nn(!0)},{key:"ArrowUp",run:nn(!1)},{key:"PageDown",run:nn(!0,"page")},{key:"PageUp",run:nn(!1,"page")},{key:"Enter",run:bc}],tu=Cr.highest(oo.computeN([he],(t)=>t.facet(he).defaultKeymap?[eu]:[]));var us=500,nu=3,ds=50,fs=/[\w$]{3,}/g;function ru(t){let r=new Set;for(let l of t.matchAll(fs))if(r.add(l[0]),r.size>=ds*4)break;return[...r]}function ou(t){let r=t.matchBefore(fs);if(!r&&!t.explicit)return null;if(r&&r.from===r.to&&!t.explicit)return null;let l=t.state.doc.lineAt(t.pos).number,c=Math.max(1,l-us),p=Math.min(t.state.doc.lines,l+us),h=t.state.sliceDoc(t.state.doc.line(c).from,t.state.doc.line(p).to),g=ru(h).filter((y)=>y.length>=nu).slice(0,ds).map((y)=>({label:y}));if(g.length===0)return null;return{from:r?r.from:t.pos,options:g}}var ms={autoCloseBrackets:!0,autocomplete:!0};function cn({autoCloseBrackets:t,autocomplete:r}){let l=[];if(t)l.push(es(),oo.of(ss));if(r)l.push(cs({override:[ou],activateOnTyping:!0}));return l}var iu={" ":T.mark({class:"cm-whitespace-space"}),"\t":T.mark({class:"cm-whitespace-tab"})};function su(t,r,l,c){let p=t.doc.lineAt(r);for(;;){let h=Math.max(r,p.from),g=Math.min(l,p.to);for(let y=h;y<g;y++){let x=p.text[y-p.from];if(x===" "||x==="\t")c.add(y,y+1,iu[x])}if(p.to>=l||p.to>=t.doc.length)break;p=t.doc.lineAt(p.to+1)}}function lu(t,r,l,c,p){let h=Math.max(r.from,l),g=Math.min(r.to,c);if(h>=g)return;su(t,h,g,p)}var ps=ye.fromClass(class{constructor(t){this.decorations=this.build(t)}update(t){if(t.docChanged||t.selectionSet||t.viewportChanged)this.decorations=this.build(t.view)}build(t){let r=new it;for(let{from:l,to:c}of t.visibleRanges)for(let p of t.state.selection.ranges)if(!p.empty)lu(t.state,p,l,c,r);return r.finish()}},{decorations:(t)=>t.decorations});var fn=re.define(),au=T.mark({class:"find-match"}),cu=T.mark({class:"find-match",attributes:{"data-find-current":""}});function uu(t,r){if(t.marks.length===0)return T.none;let l=new it;for(let c=0;c<t.marks.length;c++){let p=t.marks[c],h=Math.max(0,Math.min(p.start,r.length)),g=Math.max(h,Math.min(p.end,r.length));if(g===h)continue;l.add(h,g,c===t.current?cu:au)}return l.finish()}var hs=Qe.define({create:()=>T.none,update(t,r){for(let l of r.effects)if(l.is(fn))return uu(l.value,r.state.doc);if(r.docChanged)return t.map(r.changes);return t},provide:(t)=>_.decorations.from(t)});var du=new Set([".",",",")","]","}",";",":"]);function gs(t){let r=t.selection.main,l=t.doc.lineAt(r.from).number,c=t.doc.lineAt(r.to),p=r.to>r.from&&c.from===r.to?c.number-1:c.number;return{first:l,last:Math.max(l,p)}}var bs=({state:t,dispatch:r})=>{let l=t.selection.main,c=l.from===l.to,{first:p,last:h}=gs(t),g=c?p+1:h;if(g<=p||g>t.doc.lines)return!1;let y=g,x=[];for(let w=p;w<y;w++){let v=t.doc.line(w),E=t.doc.line(w+1),M=E.text.replace(/^[ \t]+/,""),L=M===""||du.has(M[0])?"":" ";x.push({from:v.to,to:E.from+(E.text.length-M.length),insert:L})}return r(t.update({changes:x,scrollIntoView:!0,userEvent:"input.join"})),!0},ys=({state:t,dispatch:r})=>{let{first:l,last:c}=gs(t),p=[];for(let h=l;h<=c;h++){let g=t.doc.line(h),y=g.text.replace(/[ \t]+$/,"");if(y!==g.text)p.push({from:g.from+y.length,to:g.to,insert:""})}if(p.length===0)return!1;return r(t.update({changes:p,userEvent:"input.trim"})),!0};var fu=(t)=>{let{state:r}=t,l=r.selection.main,c=r.doc.lineAt(l.from),p=/^[ \t]*/.exec(c.text)?.[0]??"";return t.dispatch({changes:{from:c.from,insert:`${p}
|
|
2
|
+
`},selection:{anchor:c.from+p.length}}),!0},mu=(t)=>{if(t.state.selection.ranges.length<=1)return!1;return or(t)},pu={undo:qn,redo:zn,selectNextOccurrence:Bo,selectAllOccurrences:No,insertCursorBelow:rr,insertCursorAbove:nr,moveLineUp:ir,moveLineDown:sr,copyLineUp:lr,copyLineDown:ar,deleteLine:cr,toggleComment:$n,toggleBlockComment:Kn,joinLines:bs,trimTrailingWhitespace:ys,insertLineBelow:ur,insertLineAbove:fu,indent:Qt,outdent:Zt,fold:Nm,unfold:Rm,foldAll:Fm,unfoldAll:Lm,lineStart:Xn,lineEnd:Yn,documentStart:$t,documentEnd:_t,selectToLineStart:Qn,selectToLineEnd:er,selectToDocumentStart:Ht,selectToDocumentEnd:qt,selectLine:tr,escape:mu};function Mr(t,r,l){let c=pu[t];if(c)return c(r);return l?.(t),!0}var hu={Enter:"Enter",Escape:"Escape",Backspace:"Backspace",Delete:"Delete",Tab:"Tab",Space:"Space",ArrowUp:"ArrowUp",ArrowDown:"ArrowDown",ArrowLeft:"ArrowLeft",ArrowRight:"ArrowRight",Home:"Home",End:"End",PageUp:"PageUp",PageDown:"PageDown"},gu={Slash:"/",Backslash:"\\",Comma:",",Period:".",Semicolon:";",Quote:"'",Backquote:"`",Minus:"-",Equal:"=",BracketLeft:"[",BracketRight:"]"};function bu(t){if(/^Key[A-Z]$/.test(t))return t.slice(3).toLowerCase();if(/^Digit\d$/.test(t))return t.slice(5);if(/^F\d{1,2}$/.test(t))return t;return hu[t]??gu[t]??null}function Sr(t){let r=bu(t.code);if(!r)return null;let l=r;if(t.alt)l=`Alt-${l}`;if(t.ctrl)l=`Ctrl-${l}`;if(t.meta)l=`Meta-${l}`;if(t.shift)l=`Shift-${l}`;return l}function yu(t){let r=[];for(let l of lo){let c=Sr(l.other),p=Sr(l.mac),h=l.windows?Sr(l.windows):null;if(!c&&!p)continue;let g=l.command;r.push({key:c??void 0,mac:p??void 0,win:h??void 0,run:(y)=>Mr(g,y,t)})}return r}var xu=[{key:"Tab",run:Qt,shift:Zt}];function xs(t,r=!1){let l=r?[]:xu;return oo.of([...yu(t),...l,...Ti])}var bt="<<<<<<<",vu="|||||||",ku=">>>>>>>",wu=/^(?:<{7}|\|{7}|>{7})(?: .*)?$/,Su=T.line({class:"cm-conflict-ours"}),Cu=T.line({class:"cm-conflict-base"}),Eu=T.line({class:"cm-conflict-theirs"});function Mu(t){if(!wu.test(t))return null;if(t.startsWith(vu))return Cu;if(t.startsWith(ku))return Eu;return Su}function vs(t){let r=[];for(let{from:l,to:c}of t.visibleRanges){let p=l;while(p<=c){let h=t.state.doc.lineAt(p),g=Mu(h.text);if(g)r.push(g.range(h.from));if(h.to===p&&h.to===t.state.doc.length)break;p=h.to+1}}return T.set(r,!0)}function ks(){return ye.fromClass(class{constructor(t){this.decorations=vs(t)}update(t){if(t.docChanged||t.viewportChanged)this.decorations=vs(t.view)}},{decorations:(t)=>t.decorations})}function ws(t){let r=t.indexOf(bt);while(r!==-1){if(r===0||t.charCodeAt(r-1)===10)return!0;r=t.indexOf(bt,r+bt.length)}return!1}function _c(t){let r=0,l=t.indexOf(bt);while(l!==-1){if(l===0||t.charCodeAt(l-1)===10)r++;l=t.indexOf(bt,l+bt.length)}return r}class Rr{constructor(t,r,l){this.from=t,this.to=r,this.diagnostic=l}}class ot{constructor(t,r,l){this.diagnostics=t,this.panel=r,this.selected=l}static init(t,r,l){let c=l.facet(ze).markerFilter;if(c)t=c(t,l);let p=t.slice().sort((M,L)=>M.from-L.from||M.to-L.to),h=new it,g=[],y=0,x=l.doc.iter(),w=0,v=l.doc.length;for(let M=0;;){let L=M==p.length?null:p[M];if(!L&&!g.length)break;let O,F;if(g.length)O=y,F=g.reduce((A,N)=>Math.min(A,N.to),L&&L.from>O?L.from:1e8);else{if(O=L.from,O>v)break;F=L.to,g.push(L),M++}while(M<p.length){let A=p[M];if(A.from==O&&(A.to>A.from||A.to==O))g.push(A),M++,F=Math.min(A.to,F);else{F=Math.min(A.from,F);break}}F=Math.min(F,v);let W=!1;if(g.some((A)=>A.from==O&&(A.to==F||F==v))){if(W=O==F,!W&&F-O<10){let A=O-(w+x.value.length);if(A>0)x.next(A),w=O;for(let N=O;;){if(N>=F){W=!0;break}if(!x.lineBreak&&w+x.value.length>N)break;N=w+x.value.length,w+=x.value.length,x.next()}}}let R=Fs(g);if(W)h.add(O,O,T.widget({widget:new Bs(R),diagnostics:g.slice()}));else{let A=g.reduce((N,U)=>U.markClass?N+" "+U.markClass:N,"");h.add(O,F,T.mark({class:"cm-lintRange cm-lintRange-"+R+A,diagnostics:g.slice(),inclusiveEnd:g.some((N)=>N.to>F)}))}if(y=F,y==v)break;for(let A=0;A<g.length;A++)if(g[A].to<=y)g.splice(A--,1)}let E=h.finish();return new ot(E,r,yt(E))}}function yt(t,r=null,l=0){let c=null;return t.between(l,1e9,(p,h,{spec:g})=>{if(r&&g.diagnostics.indexOf(r)<0)return;if(!c)c=new Rr(p,h,r||g.diagnostics[0]);else if(g.diagnostics.indexOf(c.diagnostic)<0)return!1;else c=new Rr(c.from,h,c.diagnostic)}),c}function Es(t,r){let l=r.pos,c=r.end||l,p=t.state.facet(ze).hideOn(t,l,c);if(p!=null)return p;let h=t.startState.doc.lineAt(r.pos);return!!(t.effects.some((g)=>g.is(gn))||t.changes.touchesRange(h.from,Math.max(h.to,c)))}function Du(t,r){return t.field($e,!1)?r:r.concat(re.appendConfig.of(Vs))}function Au(t,r){return{effects:Du(t,[gn.of(r)])}}var gn=re.define(),Rs=re.define(),Ts=re.define(),$e=Qe.define({create(){return new ot(T.none,null,null)},update(t,r){if(r.docChanged&&t.diagnostics.size){let l=t.diagnostics.map(r.changes),c=null,p=t.panel;if(t.selected){let h=r.changes.mapPos(t.selected.from,1);c=yt(l,t.selected.diagnostic,h)||yt(l,null,h)}if(!l.size&&p&&r.state.facet(ze).autoPanel)p=null;t=new ot(l,p,c)}for(let l of r.effects)if(l.is(gn)){let c=!r.state.facet(ze).autoPanel?t.panel:l.value.length?hn.open:null;t=ot.init(l.value,c,r.state)}else if(l.is(Rs))t=new ot(t.diagnostics,l.value?hn.open:null,t.selected);else if(l.is(Ts))t=new ot(t.diagnostics,t.panel,l.value);return t},provide:(t)=>[qu.from(t,(r)=>r.panel),_.decorations.from(t,(r)=>r.diagnostics)]});var Lu=T.mark({class:"cm-lintRange cm-lintRange-active"});function Ou(t,r,l){let{diagnostics:c}=t.state.field($e),p,h=-1,g=-1;c.between(r-(l<0?1:0),r+(l>0?1:0),(x,w,{spec:v})=>{if(r>=x&&r<=w&&(x==w||(r>x||l>0)&&(r<w||l<0)))return p=v.diagnostics,h=x,g=w,!1});let y=t.state.facet(ze).tooltipFilter;if(p&&y)p=y(p,t.state);if(!p)return null;return{pos:h,end:g,above:!0,create(){return{dom:As(t,p)}}}}function As(t,r){return Er("ul",{class:"cm-tooltip-lint"},r.map((l)=>Is(t,l,!1)))}var Ss=(t)=>{let r=t.state.field($e,!1);if(!r||!r.panel)return!1;return t.dispatch({effects:Rs.of(!1)}),!0};var Iu=ye.fromClass(class{constructor(t){this.view=t,this.timeout=-1,this.set=!0;let{delay:r}=t.state.facet(ze);this.lintTime=Date.now()+r,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,r)}run(){clearTimeout(this.timeout);let t=Date.now();if(t<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-t);else{this.set=!1;let{state:r}=this.view,{sources:l}=r.facet(ze);if(l.length)Bu(l.map((c)=>Promise.resolve(c(this.view))),(c)=>{if(this.view.state.doc==r.doc)this.view.dispatch(Au(this.view.state,c.reduce((p,h)=>p.concat(h))))},(c)=>{bn(this.view.state,c)})}}update(t){let r=t.state.facet(ze);if(t.docChanged||r!=t.startState.facet(ze)||r.needsRefresh&&r.needsRefresh(t)){if(this.lintTime=Date.now()+r.delay,!this.set)this.set=!0,this.timeout=setTimeout(this.run,r.delay)}}force(){if(this.set)this.lintTime=Date.now(),this.run()}destroy(){clearTimeout(this.timeout)}});function Bu(t,r,l){let c=[],p=-1;for(let h of t)h.then((g)=>{if(c.push(g),clearTimeout(p),c.length==t.length)r(c);else p=setTimeout(()=>r(c),200)},l)}var ze=P.define({combine(t){return{sources:t.map((r)=>r.source).filter((r)=>r!=null),...Jn(t.map((r)=>r.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Cs,tooltipFilter:Cs,needsRefresh:(r,l)=>!r?l:!l?r:(c)=>r(c)||l(c),hideOn:(r,l)=>!r?l:!l?r:(c,p,h)=>r(c,p,h)||l(c,p,h),autoPanel:(r,l)=>r||l})}}});function Cs(t,r){return!t?r:!r?t:(l,c)=>r(t(l,c),c)}function Ls(t,r={}){return[ze.of({source:t,config:r}),Iu,Vs]}function Os(t){let r=[];if(t)e:for(let{name:l}of t){for(let c=0;c<l.length;c++){let p=l[c];if(/[a-zA-Z]/.test(p)&&!r.some((h)=>h.toLowerCase()==p.toLowerCase())){r.push(p);continue e}}r.push("")}return r}function Is(t,r,l){var c;let p=l?Os(r.actions):[];return Er("li",{class:"cm-diagnostic cm-diagnostic-"+r.severity},Er("span",{class:"cm-diagnosticText"},r.renderMessage?r.renderMessage(t):r.message),(c=r.actions)===null||c===void 0?void 0:c.map((h,g)=>{let y=!1,x=(L)=>{if(L.preventDefault(),y)return;y=!0;let O=yt(t.state.field($e).diagnostics,r);if(O)h.apply(t,O.from,O.to)},{name:w}=h,v=p[g]?w.indexOf(p[g]):-1,E=v<0?w:[w.slice(0,v),Er("u",w.slice(v,v+1)),w.slice(v+1)],M=h.markClass?" "+h.markClass:"";return Er("button",{type:"button",class:"cm-diagnosticAction"+M,onclick:x,onmousedown:x,"aria-label":` Action: ${w}${v<0?"":` (access key "${p[g]})"`}.`},E)}),r.source&&Er("div",{class:"cm-diagnosticSource"},r.source))}class Bs extends jt{constructor(t){super();this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return Er("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class Dr{constructor(t,r){this.diagnostic=r,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Is(t,r,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class hn{constructor(t){this.view=t,this.items=[];let r=(c)=>{if(c.ctrlKey||c.altKey||c.metaKey)return;if(c.keyCode==27)Ss(this.view),this.view.focus();else if(c.keyCode==38||c.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(c.keyCode==40||c.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(c.keyCode==36)this.moveSelection(0);else if(c.keyCode==35)this.moveSelection(this.items.length-1);else if(c.keyCode==13)this.view.focus();else if(c.keyCode>=65&&c.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:p}=this.items[this.selectedIndex],h=Os(p.actions);for(let g=0;g<h.length;g++)if(h[g].toUpperCase().charCodeAt(0)==c.keyCode){let y=yt(this.view.state.field($e).diagnostics,p);if(y)p.actions[g].apply(t,y.from,y.to)}}else return;c.preventDefault()},l=(c)=>{for(let p=0;p<this.items.length;p++)if(this.items[p].dom.contains(c.target))this.moveSelection(p)};this.list=Er("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:r,onclick:l}),this.dom=Er("div",{class:"cm-panel-lint"},this.list,Er("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>Ss(this.view)},"×")),this.update()}get selectedIndex(){let t=this.view.state.field($e).selected;if(!t)return-1;for(let r=0;r<this.items.length;r++)if(this.items[r].diagnostic==t.diagnostic)return r;return-1}update(){let{diagnostics:t,selected:r}=this.view.state.field($e),l=0,c=!1,p=null,h=new Set;t.between(0,this.view.state.doc.length,(g,y,{spec:x})=>{for(let w of x.diagnostics){if(h.has(w))continue;h.add(w);let v=-1,E;for(let M=l;M<this.items.length;M++)if(this.items[M].diagnostic==w){v=M;break}if(v<0)E=new Dr(this.view,w),this.items.splice(l,0,E),c=!0;else if(E=this.items[v],v>l)this.items.splice(l,v-l),c=!0;if(r&&E.diagnostic==r.diagnostic){if(!E.dom.hasAttribute("aria-selected"))E.dom.setAttribute("aria-selected","true"),p=E}else if(E.dom.hasAttribute("aria-selected"))E.dom.removeAttribute("aria-selected");l++}});while(l<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0))c=!0,this.items.pop();if(this.items.length==0)this.items.push(new Dr(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),c=!0;if(p)this.list.setAttribute("aria-activedescendant",p.id),this.view.requestMeasure({key:this,read:()=>({sel:p.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:g,panel:y})=>{let x=y.height/this.list.offsetHeight;if(g.top<y.top)this.list.scrollTop-=(y.top-g.top)/x;else if(g.bottom>y.bottom)this.list.scrollTop+=(g.bottom-y.bottom)/x}});else if(this.selectedIndex<0)this.list.removeAttribute("aria-activedescendant");if(c)this.sync()}sync(){let t=this.list.firstChild;function r(){let l=t;t=l.nextSibling,l.remove()}for(let l of this.items)if(l.dom.parentNode==this.list){while(t!=l.dom)r();t=l.dom.nextSibling}else this.list.insertBefore(l.dom,t);while(t)r()}moveSelection(t){if(this.selectedIndex<0)return;let r=this.view.state.field($e),l=yt(r.diagnostics,this.items[t].diagnostic);if(!l)return;this.view.dispatch({selection:{anchor:l.from,head:l.to},scrollIntoView:!0,effects:Ts.of(l)})}static open(t){return new hn(t)}}function pn(t,r='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${r}>${encodeURIComponent(t)}</svg>')`}function mn(t){return pn(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}var Fu=_.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:0.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:mn("#f11")},".cm-lintRange-warning":{backgroundImage:mn("orange")},".cm-lintRange-info":{backgroundImage:mn("#999")},".cm-lintRange-hint":{backgroundImage:mn("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function Pu(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function Fs(t){let r="hint",l=1;for(let c of t){let p=Pu(c.severity);if(p>l)l=p,r=c.severity}return r}class Ar extends Ln{constructor(t){super();this.diagnostics=t,this.severity=Fs(t)}toDOM(t){let r=document.createElement("div");r.className="cm-lint-marker cm-lint-marker-"+this.severity;let l=this.diagnostics,c=t.state.facet(yn).tooltipFilter;if(c)l=c(l,t.state);if(l.length)r.onmouseover=()=>Wu(t,r,l);return r}}function Nu(t,r){let l=(c)=>{let p=r.getBoundingClientRect();if(c.clientX>p.left-10&&c.clientX<p.right+10&&c.clientY>p.top-10&&c.clientY<p.bottom+10)return;for(let h=c.target;h;h=h.parentNode)if(h.nodeType==1&&h.classList.contains("cm-tooltip-lint"))return;if(window.removeEventListener("mousemove",l),t.state.field(Ns))t.dispatch({effects:Lr.of(null)})};window.addEventListener("mousemove",l)}function Wu(t,r,l){function c(){let g=t.elementAtHeight(r.getBoundingClientRect().top+5-t.documentTop);if(t.coordsAtPos(g.from))t.dispatch({effects:Lr.of({pos:g.from,above:!1,clip:!1,create(){return{dom:As(t,l),getCoords:()=>r.getBoundingClientRect()}}})});r.onmouseout=r.onmousemove=null,Nu(t,r)}let{hoverTime:p}=t.state.facet(yn),h=setTimeout(c,p);r.onmouseout=()=>{clearTimeout(h),r.onmouseout=r.onmousemove=null},r.onmousemove=()=>{clearTimeout(h),h=setTimeout(c,p)}}function Uu(t,r){let l=Object.create(null);for(let p of r){let h=t.lineAt(p.from);(l[h.from]||(l[h.from]=[])).push(p)}let c=[];for(let p in l)c.push(new Ar(l[p]).range(+p));return me.of(c,!0)}var $u=Js({class:"cm-gutter-lint",markers:(t)=>t.state.field(Tr),widgetMarker:(t,r,l)=>{let c=[];return t.state.field(Tr).between(l.from,l.to,(p,h,g)=>{if(p>l.from&&p<l.to)c.push(...g.diagnostics)}),c.length?new Ar(c):null}}),Tr=Qe.define({create(){return me.empty},update(t,r){t=t.map(r.changes);let l=r.state.facet(yn).markerFilter;for(let c of r.effects)if(c.is(gn)){let p=c.value;if(l)p=l(p||[],r.state);t=Uu(r.state.doc,p.slice(0))}return t}}),Lr=re.define(),Ns=Qe.define({create(){return null},update(t,r){if(t&&r.docChanged)t=Es(r,t)?null:{...t,pos:r.changes.mapPos(t.pos)};return r.effects.reduce((l,c)=>c.is(Lr)?c.value:l,t)},provide:(t)=>yc.from(t)}),_u=_.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:pn('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:pn('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:pn('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),zu=Yg(Ou,{hideOn:Es}),Vs=[$e,_.decorations.compute([$e],(t)=>{let{selected:r,panel:l}=t.field($e);return!r||!l||r.from==r.to?T.none:T.set([Lu.range(r.from,r.to)])}),zu,Fu],yn=P.define({combine(t){return Jn(t,{hoverTime:300,markerFilter:null,tooltipFilter:null})}});function Ws(t={}){return[yn.of(t),Tr,$u,_u,Ns]}function Or(t){if(t==="json")return"json";if(t==="yaml")return"yaml";if(t==="toml")return"toml";return null}async function Gu(t){let{parse:r,printParseErrorCode:l}=await import("./main-rx9grv92.js"),c=[];r(t,c,{disallowComments:!0,allowTrailingComma:!1,allowEmptyContent:!0});let p=new Set,h=[];for(let g of c){if(p.has(g.offset))continue;p.add(g.offset),h.push({from:g.offset,to:g.offset+Math.max(g.length,1),message:l(g.error),severity:"error"})}return h}async function Ju(t){let{parseDocument:r}=await import("./index-h6jxmkxk.js"),l=r(t,{prettyErrors:!1}),c=l.errors.map((p)=>({from:p.pos[0],to:Math.max(p.pos[1],p.pos[0]+1),message:p.message,severity:"error"}));for(let p of l.warnings)c.push({from:p.pos[0],to:Math.max(p.pos[1],p.pos[0]+1),message:p.message,severity:"warning"});return c}async function Xu(t){let{parse:r,TomlError:l}=await import("./index-vnvrzwht.js");try{return r(t),[]}catch(c){if(!(c instanceof l))throw c;let p=dr(t,c.line-1)+Math.max(c.column-1,0);return[{from:p,to:p+1,message:c.message.split(`
|
|
3
|
+
`)[0],severity:"error"}]}}var Yu={json:Gu,yaml:Ju,toml:Xu};async function Us(t,r){return Yu[t](r)}var Qu=2097152,Zu=600;async function ed(t,r){let l=Or(t);if(!l||r.length>Qu)return[];if(ws(r))return[];return(await Us(l,r)).map((p)=>({from:Math.max(0,Math.min(p.from,r.length)),to:Math.max(0,Math.min(p.to,r.length)),severity:p.severity,message:p.message}))}function $s(t){if(!Or(t))return[];return[Ls((l)=>ed(t,l.state.doc.toString()),{delay:Zu}),Ws()]}function xn(t){return[ts.of(t),ue.tabSize.of(t==="\t"?1:t.length)]}function vn(t){return t?_.lineWrapping:[]}function kn(t){return t?[ue.readOnly.of(!0),_.editable.of(!1)]:[]}function od(t){let r=Ai(t);if("line"in r)return{line:r.line};return{block:{open:r.block[0],close:r.block[1]}}}function _s({language:t,wordWrapCompartment:r,readOnlyCompartment:l,themeCompartment:c,languageCompartment:p,indentCompartment:h,typingCompartment:g,wordWrap:y,readOnly:x,themes:w,typing:v,indentUnitText:E,blame:M,blameCompartment:L,onCommand:O,onDocChange:F,onState:W,onCaret:R,placeholder:A}){return[Dm(),Hg(),Jg(),Io(),qg(),jg(),ps,Jo(),Ug(),Gg(),Kg(),Vg(),ue.allowMultipleSelections.of(!0),h.of(xn(E)),p.of([]),ue.languageData.of(()=>[{commentTokens:od(t)}]),...Ni(t),Vi(t),g.of(cn(v)),...$s(t),ks(),hs,Vu(),Pm,$m,Ku(),el({placeholderDOM:Om}),c.of(tl(t,w)),Mm(),L.of(M??[]),r.of(vn(y)),l.of(kn(x)),_.contentAttributes.of({spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no"}),_.updateListener.of((N)=>{if(N.docChanged||N.selectionSet)W(N.state);if(N.docChanged)F(N.state.doc.toString());if(N.docChanged||N.selectionSet){let U=N.state.selection.main,H=N.state.doc.lineAt(U.from),G=N.view.contentDOM.dataset;G.selection=`${U.from},${U.to}`,G.line=String(H.number),R?.({line:H.number,column:U.from-H.from+1})}}),xs(O,x),A?Wg(A):[],_.exceptionSink.of((N)=>XA(N))]}function Ks(t,r,l){let c=[],p=t.length,h=0;for(let g of t)h+=r(g);for(let g of t){if(p<=1)break;if(p<=12&&h<=8388608)break;if(g===l)continue;c.push(g),p-=1,h-=r(g)}return c}function id(t,r){return t!==void 0&&t.light===r.light&&t.dark===r.dark}function Hs(t){let r=new Map,l={wordWrap:t.wordWrap,readOnly:t.readOnly,blame:t.blame??null,themes:t.themes,indentUnitText:t.indentUnitText,typing:t.typing,placeholder:t.placeholder},c=new dn,p=new dn,h=new dn,g=new dn,y=new dn,x=new dn,w=new dn,v=new Map,E=new Map,M=new Map,L=new Map,O=(R)=>_s({language:R,wordWrapCompartment:c,readOnlyCompartment:h,themeCompartment:x,languageCompartment:w,indentCompartment:g,typingCompartment:y,blameCompartment:p,blame:l.blame??null,onCommand:t.onCommand,onDocChange:t.onDocChange,onState:t.onState,onCaret:t.onCaret,...l}),F=(R,A)=>{r.delete(R),r.set(R,A)},W=(R)=>{let A=Ks([...r.keys()],(N)=>r.get(N)?.doc.length??0,R);for(let N of A)r.delete(N)};return{stateFor(R,A,N){let U=r.get(R);if(U)return F(R,U),U;let H=ue.create({doc:N,extensions:O(A)});return r.set(R,H),v.set(R,A),E.set(R,l.themes),M.set(R,l.indentUnitText),L.set(R,l.blame??null),W(R),H},remember(R,A){F(R,A)},drop(R){r.delete(R),v.delete(R),E.delete(R),M.delete(R),L.delete(R)},optionsEffects(R,A){let N=R.wordWrap!==l.wordWrap,U=R.readOnly!==l.readOnly,H=R.blame??null,G=H!==l.blame,z=R.indentUnitText!==l.indentUnitText,K=R.typing.autoCloseBrackets!==l.typing.autoCloseBrackets||R.typing.autocomplete!==l.typing.autocomplete,j=R.themes.light!==l.themes.light||R.themes.dark!==l.themes.dark;l.wordWrap=R.wordWrap,l.readOnly=R.readOnly,l.blame=H,l.themes=R.themes,l.indentUnitText=R.indentUnitText,l.typing=R.typing;let Z=[];if(N)Z.push(c.reconfigure(vn(l.wordWrap)));if(G){if(Z.push(p.reconfigure(l.blame??[])),A)L.set(A,l.blame??null)}if(U)Z.push(h.reconfigure(kn(l.readOnly)));if(z){if(Z.push(g.reconfigure(xn(l.indentUnitText))),A)M.set(A,l.indentUnitText)}if(K)Z.push(y.reconfigure(cn(l.typing)));let Q=A?v.get(A):void 0;if(j&&Q){if(Z.push(x.reconfigure(tl(Q,l.themes))),A)E.set(A,l.themes)}return Z},currentEffects(R){let A=[c.reconfigure(vn(l.wordWrap)),h.reconfigure(kn(l.readOnly))],N=l.blame??null;if(R&&L.get(R)!==N)A.push(p.reconfigure(N??[])),L.set(R,N);let U=R?v.get(R):void 0;if(R&&M.get(R)!==l.indentUnitText)A.push(g.reconfigure(xn(l.indentUnitText))),M.set(R,l.indentUnitText);if(R&&U&&!id(E.get(R),l.themes))A.push(x.reconfigure(tl(U,l.themes))),E.set(R,l.themes);return A},languageEffects(R,A){if(!r.has(R))return[];return[w.reconfigure(A)]}}}function qs({view:t,onCommand:r}){return{getSelection:()=>{let l=t.current;if(!l)return null;let c=l.state.selection.main;return{start:c.from,end:c.to}},select:(l,c,p=!0)=>{let h=t.current;if(!h)return;if(h.dispatch({selection:{anchor:l,head:c},scrollIntoView:!1}),p)h.focus()},applyDocument:(l,c,p)=>{let h=t.current;if(!h)return;h.dispatch({changes:{from:0,to:h.state.doc.length,insert:l},selection:{anchor:c,head:p}})},runCommand:(l)=>{let c=t.current;if(!c)return;Mr(l,c,r.current)},revealOffset:(l)=>{let c=t.current;if(!c)return;let p=Math.max(0,Math.min(l,c.state.doc.length));Tm(c.scrollDOM),c.dispatch({effects:_.scrollIntoView(p,{y:"nearest",yMargin:24})})}}}function Ir(t,r,l,c){if(r===c.current)return;if(r===t.state.doc.toString()){c.current=r;return}l.current=!0;try{t.dispatch({changes:{from:0,to:t.state.doc.length,insert:r}}),c.current=r}finally{l.current=!1}}var sd={typescript:()=>import("./javascript-18thb3jp.js"),tsx:()=>import("./javascript-18thb3jp.js"),javascript:()=>import("./javascript-18thb3jp.js"),jsx:()=>import("./javascript-18thb3jp.js"),json5:()=>import("./javascript-18thb3jp.js"),json:()=>import("./javascript-18thb3jp.js"),yaml:()=>import("./yaml-qwwswzvs.js"),toml:()=>import("./toml-prjdc335.js"),ini:()=>import("./properties-qq2pcfyk.js"),properties:()=>import("./properties-qq2pcfyk.js"),hcl:()=>import("./properties-qq2pcfyk.js"),css:()=>import("./css-c9nsbkh6.js"),less:()=>import("./css-c9nsbkh6.js"),scss:()=>import("./css-c9nsbkh6.js"),sass:()=>import("./sass-gnk9vsyp.js"),stylus:()=>import("./stylus-xh0f7m9m.js"),xml:()=>import("./xml-f6syr877.js"),bash:()=>import("./shell-5rhwzbr3.js"),python:()=>import("./python-wbdfs2gc.js"),ruby:()=>import("./ruby-nq98w40a.js"),perl:()=>import("./perl-3t5fm1te.js"),lua:()=>import("./lua-6at2ddf6.js"),powershell:()=>import("./powershell-rrzhqtmb.js"),go:()=>import("./go-nfrqbjpq.js"),rust:()=>import("./rust-fz913fvw.js"),c:()=>import("./clike-h8p24dc6.js"),cpp:()=>import("./clike-h8p24dc6.js"),csharp:()=>import("./clike-h8p24dc6.js"),java:()=>import("./clike-h8p24dc6.js"),kotlin:()=>import("./clike-h8p24dc6.js"),scala:()=>import("./clike-h8p24dc6.js"),dart:()=>import("./clike-h8p24dc6.js"),"objective-c":()=>import("./clike-h8p24dc6.js"),swift:()=>import("./swift-rr9wc5y7.js"),haskell:()=>import("./haskell-phxh4hcg.js"),elixir:()=>import("./erlang-1ch2hjv9.js"),erlang:()=>import("./erlang-1ch2hjv9.js"),clojure:()=>import("./clojure-w19rx1x5.js"),scheme:()=>import("./scheme-jvs3e9c8.js"),racket:()=>import("./scheme-jvs3e9c8.js"),ocaml:()=>import("./mllike-cnahv8ak.js"),r:()=>import("./r-z4m38eb1.js"),julia:()=>import("./julia-ft9kd90a.js"),sql:()=>import("./sql-wsvbkyd1.js"),dockerfile:()=>import("./dockerfile-4rtt6c0f.js"),protobuf:()=>import("./protobuf-ggczeare.js"),makefile:()=>import("./cmake-qpejsvqg.js"),groovy:()=>import("./groovy-63s5pygd.js")},zs={typescript:"typescript",tsx:"typescript",javascript:"javascript",jsx:"javascript",json5:"json",json:"json",yaml:"yaml",toml:"toml",ini:"properties",properties:"properties",hcl:"properties",css:"css",less:"less",scss:"sCSS",sass:"sass",stylus:"stylus",xml:"xml",bash:"shell",python:"python",ruby:"ruby",perl:"perl",lua:"lua",powershell:"powerShell",go:"go",rust:"rust",c:"c",cpp:"cpp",csharp:"csharp",java:"java",kotlin:"kotlin",scala:"scala",dart:"dart","objective-c":"objectiveC",swift:"swift",haskell:"haskell",elixir:"erlang",erlang:"erlang",clojure:"clojure",scheme:"scheme",racket:"scheme",ocaml:"oCaml",r:"r",julia:"julia",sql:"standardSQL",dockerfile:"dockerFile",protobuf:"protobuf",makefile:"cmake",groovy:"groovy"};function js(t){return sd[t]??null}var Pr=new Map,Fr=new Map,ld=new Set;function ad(t){for(let r of[...ld])try{r(t)}catch{}}function Gs(t){return Pr.get(t)??null}function Ys(t){let r=Pr.get(t);if(r)return Promise.resolve(r);let l=Fr.get(t);if(l)return l;let c=js(t),p=zs[t];if(!c||!p)return Promise.resolve(null);let h=(async()=>{try{let[g,y]=await Promise.all([c(),import("./index-sbd5e816.js")]),x=g[p];if(!x)return null;let w=y.StreamLanguage.define(x);return Pr.set(t,w),ad(t),w}catch{return null}finally{Fr.delete(t)}})();return Fr.set(t,h),h}var Sc=Ds(function({value:r,onValueChange:l,language:c,wordWrap:p,documentKey:h,marks:g,currentMark:y,onCommand:x,readOnly:w=!1,themeVars:v,themes:E,indentUnitText:M=" ",typing:L=ms,blame:O=null,style:F,padding:W=16,onCaret:R,placeholder:A,scrollTestId:N,onScroller:U,className:H},G){let z=o(null),K=o(null),j=o(""),Z=o(""),Q=o(!1),ie=o(r),ne=o(l);ne.current=l;let fe=o(x);fe.current=x;let se=o(U);se.current=U;let te=o(R);te.current=R;let Se=o(g??[]),le=o(y??-1);Se.current=g??[],le.current=y??-1;let be=E??to,Le=o(be);Le.current=be;let Xe=o(M);Xe.current=M;let Pe=o(L);Pe.current=L;let Ce=o(O);Ce.current=O;let Ee=o(null);if(!Ee.current)Ee.current=Hs({wordWrap:p,readOnly:w,themes:Le.current,indentUnitText:Xe.current,typing:Pe.current,blame:Ce.current,placeholder:A,onDocChange:(X)=>{if(ie.current=X,Q.current)return;ne.current(X)},onState:(X)=>{let oe=j.current;if(oe)Ee.current?.remember(oe,X)},onCommand:(X)=>fe.current?.(X),onCaret:(X)=>te.current?.(X)});V(()=>{let X=z.current,oe=Ee.current;if(!X||!oe)return;j.current=h;let ce=new _({state:oe.stateFor(h,c,r),parent:X});if(K.current=ce,ie.current=r,N)ce.scrollDOM.dataset.testid=N;se.current?.(ce.scrollDOM);let q=ce.state.doc.lineAt(ce.state.selection.main.head);return te.current?.({line:q.number,column:ce.state.selection.main.head-q.from+1}),()=>{se.current?.(null),ce.destroy(),K.current=null}},[]),V(()=>{let X=K.current,oe=Ee.current;if(!X||!oe)return;if(j.current===h)return;oe.remember(j.current,X.state),j.current=h,X.setState(oe.stateFor(h,c,r)),X.dispatch({effects:oe.currentEffects(h)}),Ir(X,r,Q,ie);let ce=X.state.doc.lineAt(X.state.selection.main.head);te.current?.({line:ce.number,column:X.state.selection.main.head-ce.from+1}),Z.current="",X.dispatch({effects:fn.of({marks:Se.current,current:le.current})})},[h]),V(()=>{let X=K.current;if(!X||j.current!==h)return;Ir(X,r,Q,ie)},[r,h]),V(()=>{let X=K.current,oe=Ee.current;if(!X||!oe)return;let ce=oe.optionsEffects({wordWrap:p,readOnly:w,themes:be,indentUnitText:M,typing:L,blame:O},j.current);if(ce.length>0)X.dispatch({effects:ce})},[p,w,be.light,be.dark,M,L,O]),V(()=>{let X=K.current,oe=Ee.current;if(!X||!oe)return;let ce=!1,q=(de)=>{if(ce||!de)return;let ve=K.current;if(!ve)return;let Oe=oe.languageEffects(j.current,de);if(Oe.length>0)ve.dispatch({effects:Oe})},J=Gs(c);if(J)return q(J),()=>{ce=!0};return Ys(c).then(q),()=>{ce=!0}},[c,h]),V(()=>{let X=K.current;if(!X)return;let oe=g??[],ce=`${y??-1}:${oe.map((q)=>`${q.start}-${q.end}`).join(",")}`;if(ce===Z.current)return;Z.current=ce,X.dispatch({effects:fn.of({marks:oe,current:y??-1})})},[g,y]),si(G,()=>qs({view:K,onCommand:fe}),[]);let Ye={...v,...F,"--surface-pad":`${W}px`};return e("div",{ref:z,className:H,style:Ye,"data-code-surface":""})});var st="flex items-center justify-center p-1 rounded transition-colors cursor-pointer disabled:cursor-default disabled:opacity-40";function Qs({active:t,title:r,onToggle:l,children:c}){return e("button",{type:"button",onClick:l,className:`${st} ${t?"bg-ink/10 text-ink":"text-ink/50 hover:text-ink hover:bg-ink/5"}`,title:r,"aria-label":r,"aria-pressed":t,children:c})}function Tc({find:t}){let r=o(null),l=ht();i(()=>{r.current?.focus(),r.current?.select()},[t.focusRequest]);let c=t.matches.length,p=t.invalid?"Invalid pattern":c===0?t.query?"No results":"":`${t.currentIndex+1} of ${c}${t.truncated?"+":""}`,h=(x)=>{if(x.key==="Enter"&&!x.metaKey&&!x.ctrlKey&&!x.altKey)x.preventDefault(),t.step(x.shiftKey?-1:1)},g=(x,w)=>{let v=lo.find((E)=>E.command===x);return v?`${w} (${ec(v,l)})`:w},y=(x,w,v,E)=>e(Qs,{active:t.options[x],title:g(v,w),onToggle:()=>t.toggleOption(x),children:E});return e("div",{className:"absolute top-2 right-2 z-30 flex w-[330px] max-w-[calc(100%-1rem)] min-w-0 flex-col gap-1 bg-paper border border-ink/15 rounded-md shadow-lg p-1.5 text-xs text-ink font-sans",children:[e("div",{className:"flex items-center gap-1",children:[e("button",{type:"button",onClick:t.toggleReplace,className:`${st} ${t.replaceOpen?"text-ink":"text-ink/50 hover:text-ink hover:bg-ink/5"}`,title:t.replaceOpen?"Hide replace":"Show replace","aria-label":t.replaceOpen?"Hide replace":"Show replace","aria-pressed":t.replaceOpen,children:t.replaceOpen?e(et,{size:13}):e(B,{size:13})}),e("input",{ref:r,type:"text",value:t.query,onInput:(x)=>t.setQuery(x.currentTarget.value),onKeyDown:h,placeholder:"Find","aria-label":"Find",className:`flex-1 min-w-0 bg-canvas border rounded px-2 py-1 font-mono text-xs focus:outline-none ${t.invalid?"border-error text-error":"border-ink/20 focus:border-ink text-ink"}`}),y("matchCase","Match case","toggleCaseSensitive",e(Fo,{size:13})),y("wholeWord","Match whole word","toggleWholeWord",e(Uo,{size:13})),y("isRegex","Use regular expression","toggleRegex",e(Po,{size:13})),e(Qs,{active:t.options.inSelection,title:t.options.inSelection?"Searching the selection only":"Search the selection only",onToggle:()=>t.toggleOption("inSelection"),children:e(Ur,{size:13})}),e("span",{className:`font-mono text-[10px] whitespace-nowrap min-w-[52px] text-right ${t.invalid?"text-error":"text-ink/50"}`,"aria-live":"polite",children:p}),e("button",{type:"button",onClick:()=>t.step(-1),disabled:c===0,className:`${st} text-ink/50 hover:text-ink hover:bg-ink/5`,title:g("previousMatch","Previous match"),"aria-label":"Previous match",children:e(Ro,{size:13})}),e("button",{type:"button",onClick:()=>t.step(1),disabled:c===0,className:`${st} text-ink/50 hover:text-ink hover:bg-ink/5`,title:g("nextMatch","Next match"),"aria-label":"Next match",children:e($r,{size:13})}),e("button",{type:"button",onClick:t.close,className:`${st} text-ink/50 hover:text-ink hover:bg-ink/5`,title:"Close find (Escape)","aria-label":"Close find",children:e(b,{size:13})})]}),t.history.length>0&&e("div",{className:"flex items-center gap-1 overflow-x-auto no-scrollbar",children:[e("span",{className:"text-[10px] uppercase tracking-wide text-ink/40 flex-shrink-0",children:"Recent"}),t.history.slice(0,6).map((x)=>e("button",{type:"button",onClick:()=>t.useHistoryEntry(x),title:`Find ${x}`,className:"px-1.5 py-0.5 rounded border border-ink/15 font-mono text-[10px] text-ink/70 hover:bg-ink/5 hover:text-ink transition-colors cursor-pointer whitespace-nowrap flex-shrink-0",children:x},x))]}),t.replaceOpen&&e("div",{className:"flex items-center gap-1",children:[e("span",{className:"w-[22px]","aria-hidden":"true"}),e("input",{type:"text",value:t.replacement,onInput:(x)=>t.setReplacement(x.currentTarget.value),onKeyDown:h,placeholder:"Replace","aria-label":"Replace",className:"flex-1 min-w-0 bg-canvas border border-ink/20 rounded px-2 py-1 font-mono text-xs text-ink focus:outline-none focus:border-ink"}),e("button",{type:"button",onClick:t.replaceCurrent,disabled:c===0,className:`${st} text-ink/50 hover:text-ink hover:bg-ink/5`,title:g("replaceOne","Replace"),"aria-label":"Replace",children:e($o,{size:13})}),e("button",{type:"button",onClick:t.replaceAll,disabled:c===0,className:`${st} text-ink/50 hover:text-ink hover:bg-ink/5`,title:g("replaceAll","Replace all"),"aria-label":"Replace all",children:e(Oo,{size:13})})]})]})}var cd=12;function Dc({path:t,scroller:r,preview:l}){let c=He(JA,YA);i(()=>{if(!c||!t||c.path!==t)return;if(!l||!r)return;let p=[...r.querySelectorAll("h1, h2, h3, h4, h5, h6")],h=ZA(p.map((x)=>x.textContent??""),c),g=p[h];if(!g)return;Tm(r);let y=g.getBoundingClientRect().top-r.getBoundingClientRect().top;r.scrollTop+=y-cd,Ho(null)})}var ud={docx:!0},dd={xls:!0,xlsx:!0,xlsm:!0},fd={csv:!0,tsv:!0},md={md:!0,markdown:!0,mdx:!0},pd={drawio:!0,dio:!0},rd={image:!0,pdf:!0,docx:!0,spreadsheet:!0,code:void 0,markdown:void 0,svg:void 0,csv:void 0,drawio:void 0},rs={markdown:!0,svg:!0,csv:!0,drawio:!0,code:void 0,image:void 0,pdf:void 0,docx:void 0,spreadsheet:void 0},Fi={code:"Text",markdown:"Markdown",svg:"SVG",csv:"CSV",image:"Image",pdf:"PDF",docx:"Document",spreadsheet:"Spreadsheet",drawio:"Diagram"};function as(t){let r=Ps(t);if(!r)return"code";if(r==="svg")return"svg";if(pd[r])return"drawio";if(md[r])return"markdown";if(hi(t))return"image";if(r==="pdf")return"pdf";if(ud[r])return"docx";if(dd[r])return"spreadsheet";if(fd[r])return"csv";return"code"}var hd=Re(()=>import("./PdfView-x6dmtwvr.js").then((t)=>({default:t.PdfView}))),gd=Re(()=>import("./DocxView-bxjhzxe9.js").then((t)=>({default:t.DocxView}))),bd=Re(()=>import("./SheetView-n52nvz8s.js").then((t)=>({default:t.SheetView}))),yd=Re(()=>import("./CsvGrid-0amzgtd7.js").then((t)=>({default:t.CsvGrid}))),xd=Re(()=>import("./SvgPreview-59z7syme.js").then((t)=>({default:t.SvgPreview}))),vd=Re(()=>import("./ImageView-ycfbn66h.js").then((t)=>({default:t.ImageView}))),kd=Re(()=>import("./DrawioView-7s1yqsf4.js").then((t)=>({default:t.DrawioView})));function Nc(t){return t==="image"||t==="pdf"||t==="docx"||t==="spreadsheet"||t==="csv"||t==="svg"||t==="drawio"}function lt(){return e("div",{className:"flex flex-1 items-center justify-center gap-2 text-xs text-ink/40",children:[e(m,{size:14,className:"animate-spin"}),e("span",{children:"Loading…"})]})}function al({kind:t,path:r,name:l,source:c,content:p,revision:h,onContentChange:g,onSaveBytes:y,onDirtyChange:x}){if(t==="image")return e(We,{fallback:e(lt,{}),children:e(vd,{source:c,name:l,revision:h})});if(t==="pdf")return e(We,{fallback:e(lt,{}),children:e(hd,{source:c,name:l,revision:h})});if(t==="docx")return e(We,{fallback:e(lt,{}),children:e(gd,{source:c,name:l,revision:h})});if(t==="spreadsheet")return e(We,{fallback:e(lt,{}),children:e(bd,{source:c,name:l,path:r,revision:h,onSaveBytes:y,onDirtyChange:x})});if(t==="csv")return e(We,{fallback:e(lt,{}),children:e(yd,{content:p,path:r,onChange:g})});if(t==="svg")return e(We,{fallback:e(lt,{}),children:e(xd,{content:p,name:l})});if(t==="drawio")return e(We,{fallback:e(lt,{}),children:e(kd,{content:p,name:l})});return null}function il(t){if(!t.path)return!1;if(t.content!==void 0)return!1;if(t.handleId||t.deviceFile)return!1;return!t.isDiff}function Nr(t){return`${t.root??""}\x00${t.repo??"."}\x00${t.path??""}`}async function wd(t){let r=new URLSearchParams({path:t.path??""});if(t.root)r.set("root",t.root);if(t.repo&&t.repo!==".")r.set("repo",t.repo);try{let l=await fetch(`/api/fs/exists?${r.toString()}`),c=await l.json().catch(()=>null);if(!l.ok||!c||typeof c.exists!=="boolean")return!0;return c.exists}catch{return!0}}function Rc(t,r){let[l,c]=n(()=>new Set),[p,h]=n(0),g=t.map((w)=>`${w.id}\x01${Nr(w)}`).join(`
|
|
4
|
+
`),y=o(t);y.current=t;let x=o(new Set);return i(()=>{let w=!1;return(async()=>{let v=new Map;for(let F of y.current)if(il(F))v.set(Nr(F),F);let E=await Promise.all([...v.entries()].map(async([F,W])=>({key:F,exists:await wd(W)})));if(w)return;let M=new Set;for(let{key:F,exists:W}of E)if(!W)M.add(F);let L=new Set;for(let F of y.current)if(il(F)&&M.has(Nr(F)))L.add(F.id);let O=x.current;if(O.size===L.size&&[...L].every((F)=>O.has(F)))return;x.current=L,c(L)})(),()=>{w=!0}},[g,r,p]),i(()=>{let w=()=>h((v)=>v+1);return window.addEventListener("focus",w),document.addEventListener("visibilitychange",w),()=>{window.removeEventListener("focus",w),document.removeEventListener("visibilitychange",w)}},[]),l}async function Fc(t,r,l){if(t.handleId){let p=await jm(t.handleId,r,{interactive:l.interactive});if(p==="written")return{status:"written",mtimeMs:null};if(p==="needs-permission")return{status:"needs-permission"};return{status:"failed",error:"The browser refused the write."}}if(!t.path)return{status:"failed",error:"This file has no path to write to."};let c=new FormData;if(c.append("actionType","saveBytes"),c.append("path",t.path),c.append("bytes",new Blob([r])),t.root)c.append("root",t.root);if(t.repo&&t.repo!==".")c.append("repo",t.repo);if(typeof l.baseMtimeMs==="number")c.append("baseMtime",String(l.baseMtimeMs));try{let p=await fetch("/api/fs/action",{method:"POST",body:c}),h=await p.json().catch(()=>null);if(p.status===409)return{status:"conflict",diskMtimeMs:typeof h?.mtimeMs==="number"?h.mtimeMs:null};if(p.ok&&h?.success)return{status:"written",mtimeMs:typeof h.mtimeMs==="number"?h.mtimeMs:null};return{status:"failed",error:typeof h?.error==="string"?h.error:null}}catch{return{status:"failed",error:null}}}var Sd={id:"",url:null,loadBytes:null,mimeType:null};async function Vr(t){let r=await t.json().catch(()=>null);return typeof r?.error==="string"&&r.error?r.error:`Could not read the file (HTTP ${t.status}).`}function rl(t){let r=GA(t.path);if(t.rawUrl){let p=t.rawUrl;return{id:p,url:p,mimeType:r,loadBytes:async()=>{let h=await fetch(p);if(!h.ok)throw Error(await Vr(h));return h.arrayBuffer()}}}let l=Km(t.handleId);if(l){let{bytes:p}=l;return{id:t.handleId,url:null,mimeType:l.mimeType??r,loadBytes:async()=>p.slice().buffer}}let c=nl(t.handleId);if(c)return{id:t.handleId,url:null,mimeType:r,loadBytes:async()=>(await c.getFile()).arrayBuffer()};return Sd}function ol(t,r){let l=t?as(t.path??""):"code",c=rd[l]===!0,p=Boolean(t?.path)&&!t?.handleId,h=p&&t?.content===void 0&&hi(t?.path)?t.path:null,g=h!==null,y=t&&!g&&c&&p&&t.content===void 0?Ms({path:t.path,root:t.root,repo:t.repo}):null,x=rl({path:t?.path,handleId:t?.handleId,rawUrl:h?`${Ms({path:h,root:t?.root,repo:t?.repo})}&v=${r}`:y});return{viewerKind:l,isBinaryViewer:c,isImage:g,imageUrl:g?x.url:null,byteSource:x}}function sl(t){let r=t.indexOf(`
|
|
5
|
+
`);return r>0&&t[r-1]==="\r"?"crlf":"lf"}function Dt(t){return t.includes("\r")?t.replace(/\r\n?/g,`
|
|
6
|
+
`):t}function ll(t,r){let l=Dt(t);return r==="crlf"?l.replace(/\n/g,`\r
|
|
7
|
+
`):l}function cl(t){return String(t.id??t.path??t.name)}function ul({target:t,key:r,isBinaryViewer:l,revision:c,loadedRef:p,contentsRef:h,baselinesRef:g,pendingRef:y,readingRef:x,remember:w}){let[v,E]=n(!1),[M,L]=n(!1),[O,F]=n(null),[W,R]=n(null);return i(()=>{if(L(!1),!t)return;let A=cl(t);if(p.current.has(A))return;if(p.current.add(A),l){F(null),R(null),E(!1);return}if(t.content!==void 0){w(A,t.content,null,null),F(null),R(null);return}if(!t.path){F("No file path supplied for this attachment."),R(null);return}let N=h.current[A]===void 0,U=!1;if(N)E(!0);F(null),R(null);let H=new URLSearchParams({path:t.path});if(t.root)H.set("root",t.root);if(t.repo&&t.repo!==".")H.set("repo",t.repo);return x.current+=1,L(!0),fetch(`/api/fs/read?${H.toString()}`).then(async(G)=>{let z=await G.json().catch(()=>null);if(!G.ok||!z||typeof z.content!=="string"){let K=Error(z?.error||`HTTP ${G.status}`);if(z?.kind)K.kind=z.kind;else if(G.status===415)K.kind="binary";throw K}return{text:z.content,mtimeMs:typeof z.mtimeMs==="number"?z.mtimeMs:null,hash:typeof z.hash==="string"?z.hash:null}}).then(({text:G,mtimeMs:z,hash:K})=>{if(U)return;let j=h.current[A];if(j!==void 0&&j!==g.current[A])return;let Z=y.current;if(Z&&cl(Z.file)===A)return;w(A,G,z,K)}).catch((G)=>{if(U)return;if(!N)return;w(A,"",null,null);let z=G instanceof Error?G.message:"Failed to read file",K=G?.kind;R(K?z:null),F(z)}).finally(()=>{if(x.current-=1,!U)E(!1),L(!1)}),()=>{U=!0}},[r,t,w,c,l,p,h,g,y,x]),{isLoading:v,isReading:M&&!v,loadError:O,unsupported:W}}async function dl(t,r){let l=await fetch(t);if(!l.ok)throw Error(`HTTP ${l.status}`);mo(await l.blob(),r)}async function fl(t){let r=await fetch(t);if(!r.ok)throw Error(`HTTP ${r.status}`);let l=await r.blob();if(typeof ClipboardItem>"u"||!navigator.clipboard?.write)throw Error("Image clipboard unavailable");await navigator.clipboard.write([new ClipboardItem({[l.type]:l})])}function ml({target:t,content:r,downloadContent:l,imageUrl:c,downloadMimeType:p,byteSource:h,byteViewer:g=!1}){let[y,x]=n(!1),w=a(()=>{x(!0),window.setTimeout(()=>x(!1),1500)},[]),v=a(()=>{if(!t)return;if(c){fl(c).then(w).catch(()=>{});return}if(g)return;if(!navigator.clipboard)return;navigator.clipboard.writeText(r).then(w).catch(()=>{})},[t,r,c,g,w]),E=a(()=>{if(!t)return;if(c){dl(c,t.name).catch(()=>{});return}if(g){let M=h?.loadBytes;if(!M)return;let L=h?.mimeType;M().then((O)=>mo(L?new Blob([O],{type:L}):new Blob([O]),t.name)).catch(()=>{});return}mo(new Blob([l],{type:p}),t.name)},[t,l,p,c,g,h]);return{copied:y,copy:v,download:E}}async function pl(t){let r=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(r),(l)=>l.toString(16).padStart(2,"0")).join("")}async function hl(t,r,l,c){if(t.handleId){let h=l==="crlf"?r.replace(/\n/g,`\r
|
|
8
|
+
`):r,g=await jm(t.handleId,h,{interactive:c.interactive});if(g==="written")return{status:"written",written:{mtimeMs:null,hash:await pl(h)}};if(g==="needs-permission")return{status:"needs-permission"};return{status:"failed"}}if(!t.path)return{status:"failed"};let p=new FormData;if(p.append("actionType","save"),p.append("path",t.path),p.append("content",r),p.append("eol",l),t.root)p.append("root",t.root);if(t.repo&&t.repo!==".")p.append("repo",t.repo);if(typeof c.baseMtimeMs==="number")p.append("baseMtime",String(c.baseMtimeMs));try{let h=await fetch("/api/fs/action",{method:"POST",body:p}),g=await h.json().catch(()=>null);if(h.status===409)return{status:"conflict",diskMtimeMs:typeof g?.mtimeMs==="number"?g.mtimeMs:null};if(h.ok&&g?.success)return{status:"written",written:{mtimeMs:typeof g.mtimeMs==="number"?g.mtimeMs:null,hash:typeof g.hash==="string"?g.hash:null}};return{status:"failed"}}catch{return{status:"failed"}}}function xt(t,r){let l={},c=!1;for(let[p,h]of Object.entries(t))if(r.has(p))l[p]=h;else c=!0;return c?l:t}function wn(t){return String(t.id??t.path??t.name)}function gl({target:t,isBinaryViewer:r,loadError:l,missing:c,contentsRef:p,lineEndingsRef:h,mtimesRef:g,pendingRef:y,flushOnUnmount:x,onSaveStart:w,onSaved:v,onSaveFailed:E,onNeedsPermission:M,onConflict:L}){let[O,F]=n(!1),W=o(c);W.current=c;let R=t?wn(t):"",A=a(async(K,j,Z={})=>{if(!K.path&&!K.handleId)return;if(K.handleId&&!nl(K.handleId))return;if(W.current&&!Z.allowMissing)return;w();let Q=wn(K),ie=Z.allowMissing?null:g.current[Q]??null,ne=await hl(K,j,h.current[Q]??"lf",{interactive:Z.interactive===!0,baseMtimeMs:ie});if(ne.status==="written")v(Q,j,ne.written);else if(ne.status==="needs-permission")M();else if(ne.status==="conflict")L(Q,ne.diskMtimeMs);else E()},[h,g,L,M,E,w,v]),N=o(A);N.current=A;let U=a((K)=>{if(!t||r)return;if(!t.path)return;if(W.current)return;if(y.current)window.clearTimeout(y.current.timer);let j=window.setTimeout(()=>{y.current=null,N.current(t,K)},800);y.current={timer:j,file:t,content:K}},[t,r,y]),H=a(()=>{if(!t||r)return;if(l)return;if(t.handleId&&!nl(t.handleId))return;let K=p.current[wn(t)];if(K===void 0)return;if(y.current)window.clearTimeout(y.current.timer),y.current=null;if(W.current){F(!0);return}N.current(t,K,{interactive:!0})},[t,p,r,l,y]),G=a(()=>{if(F(!1),!t||r||l)return;let K=p.current[wn(t)];if(K===void 0)return;N.current(t,K,{allowMissing:!0,interactive:!0})},[t,p,r,l]),z=a(()=>F(!1),[]);return i(()=>{if(!x)return;return()=>{let K=y.current;if(!K)return;if(window.clearTimeout(K.timer),y.current=null,W.current)return;N.current(K.file,K.content)}},[x,y]),i(()=>{if(!c)F(!1)},[c,R]),{onChange:U,saveNow:H,saveMissingConfirm:O,confirmSaveMissing:G,cancelSaveMissing:z}}function bl({key:t,saveNow:r,mtimesRef:l,setMtimes:c,contentsRef:p,setContents:h,setBaselines:g,loadedRef:y,bumpRevision:x}){let[w,v]=n({}),E=a((R)=>{v((A)=>{if(A[R]===void 0)return A;let N={...A};return delete N[R],N})},[]),M=a((R,A)=>{v((N)=>({...N,[R]:{diskMtimeMs:A}}))},[]),L=a((R,A)=>{l.current={...l.current,[R]:A},c(l.current)},[l,c]),O=a((R)=>{if(!t)return;L(t,R),E(t)},[t,L,E]),F=a(()=>{if(!t)return;E(t),g((R)=>{let A={...R};return delete A[t],A}),h((R)=>{let A={...R};return delete A[t],A}),y.current.delete(t),x()},[t,E,g,h,y,x]),W=a(()=>{if(!t)return;let R=p.current[t],A=w[t]?.diskMtimeMs??null;if(E(t),R===void 0)return;if(A!==null)L(t,A);r()},[t,w,E,L,p,r]);return{conflict:w[t]??null,report:M,reload:F,keepMine:W,adopt:O,clear:E}}var Cd=3000;async function Ed(t,r,l){let c=new URLSearchParams({path:t});if(r)c.set("root",r);if(l&&l!==".")c.set("repo",l);try{let p=await fetch(`/api/fs/digest?${c.toString()}`),h=await p.json().catch(()=>null);if(!p.ok||!h||typeof h.exists!=="boolean")return"unknown";if(h.exists===!1)return"gone";if(typeof h.hash!=="string"||typeof h.mtimeMs!=="number")return"unknown";return{hash:h.hash,mtimeMs:h.mtimeMs}}catch{return"unknown"}}function yl({path:t,root:r=null,repo:l=null,baseHash:c,revision:p,onUnchanged:h,onChanged:g}){let y=o(h);y.current=h;let x=o(g);x.current=g,i(()=>{if(!t||c===null)return;let w=!1,v=!1,E=null,M=async()=>{if(w||v||document.hidden)return;v=!0;try{let W=await Ed(t,r,l);if(w||W==="unknown"||W==="gone")return;if(W.hash===c){y.current(W.mtimeMs);return}if(E===W.hash)return;E=W.hash,x.current(W)}finally{v=!1}},L=window.setInterval(()=>void M(),Cd);M();let O=()=>void M(),F=()=>{if(!document.hidden)M()};return window.addEventListener("focus",O),document.addEventListener("visibilitychange",F),()=>{w=!0,window.clearInterval(L),window.removeEventListener("focus",O),document.removeEventListener("visibilitychange",F)}},[t,r,l,c,p])}function _e(t){return String(t.id??t.path??t.name)}function xl({key:t,target:r,baseHash:l,revision:c,hashesRef:p,mtimesRef:h,contentsRef:g,baselinesRef:y,pendingRef:x,readingRef:w,loadedRef:v,bumpRevision:E,adoptDiskMtime:M,clearConflict:L,reloadDiscardingEdits:O,discardPendingWrite:F}){let[W,R]=n(null),A=o(null);i(()=>{R(null),A.current=null},[t]);let N=a((z)=>{if(!t)return;if(h.current[t]!==z)M(z);R(null),A.current=null},[t,h,M]),U=a((z)=>{if(!t)return;if(p.current[t]===z.hash){R(null);return}if(A.current===z.hash)return;if(W?.hash===z.hash)return;let K=g.current[t],j=x.current;if(K!==void 0&&K!==y.current[t]||j!==null&&_e(j.file)===t){R(z);return}if(w.current>0)return;v.current.delete(t),E()},[t,p,g,y,x,w,v,E,W]);yl({path:r&&il({...r,id:t})?r.path??null:null,root:r?.root??null,repo:r?.repo??null,baseHash:l,revision:c,onUnchanged:N,onChanged:U});let H=a(()=>{if(!r)return;let z=_e(r),K=g.current[z];if(K!==void 0&&K!==y.current[z]){F(z),O();return}L(z),v.current.delete(z),E()},[r,g,y,F,O,L,v,E]),G=a(()=>{if(!W)return;A.current=W.hash,M(W.mtimeMs),R(null)},[W,M]);return{diskChange:W,reloadFromDisk:H,keepMineAgainstDisk:G}}function vl({target:t,loadedRef:r,bumpRevision:l,setContents:c,setBaselines:p,setLineEndings:h,setMtimes:g,setHashes:y}){let x=a((M,L,O,F)=>{let W=sl(L),R=Dt(L);c((A)=>({...A,[M]:R})),p((A)=>({...A,[M]:R})),h((A)=>({...A,[M]:W})),g((A)=>({...A,[M]:O})),y((A)=>({...A,[M]:F}))},[c,p,h,g,y]),w=a(()=>{r.current.clear(),l()},[r,l]),v=a((M)=>{let L=new Set(M.map(String));for(let O of Array.from(r.current))if(!L.has(O))r.current.delete(O);c((O)=>xt(O,L)),p((O)=>xt(O,L)),h((O)=>xt(O,L)),g((O)=>xt(O,L)),y((O)=>xt(O,L))},[r,c,h,g,y]),E=a((M)=>{if(!t)return;h((L)=>({...L,[_e(t)]:M}))},[t,h]);return{remember:x,reset:w,retain:v,setEol:E}}function kl({target:t,key:r,textDirty:l,contents:c,baselines:p,retain:h}){let[g,y]=n(()=>new Set),x=l||g.has(r),w=u(()=>{let M=new Set(g);for(let[L,O]of Object.entries(c)){let F=p[L];if(F!==void 0&&O!==F)M.add(L)}return M},[c,p,g]),v=a((M)=>{if(!t)return;let L=_e(t);y((O)=>{if(O.has(L)===M)return O;let F=new Set(O);if(M)F.add(L);else F.delete(L);return F})},[t]),E=a((M)=>{h(M);let L=new Set(M.map(String));y((O)=>{let F=!1,W=new Set;for(let R of O)if(L.has(R))W.add(R);else F=!0;return F?W:O})},[h]);return{isDirty:x,dirtyKeys:w,setBinaryDirty:v,retain:E}}function Lc(t,r={}){let{flushOnUnmount:l=!1,reportSaveError:c=!1,downloadMimeType:p="text/plain",onFileSaved:h,missing:g=!1}=r,[y,x]=n({}),[w,v]=n({}),[E,M]=n({}),[L,O]=n({}),[F,W]=n({}),[R,A]=n("idle"),[N,U]=n(0),H=t?_e(t):"",G=t?y[H]??(t.content!==void 0?Dt(t.content):""):"",z=G!==(w[H]??G),{viewerKind:K,isBinaryViewer:j,isImage:Z,imageUrl:Q,byteSource:ie}=ol(t,N),ne=o(new Set),fe=o(null),se=o(0),te=o(y);te.current=y;let Se=o(w);Se.current=w;let le=o(E);le.current=E;let be=o(L);be.current=L;let Le=o(F);Le.current=F;let{remember:Xe,reset:Pe,retain:Ce,setEol:Ee}=vl({target:t,loadedRef:ne,bumpRevision:()=>U((pe)=>pe+1),setContents:x,setBaselines:v,setLineEndings:M,setMtimes:O,setHashes:W}),{isDirty:Ye,dirtyKeys:X,setBinaryDirty:oe,retain:ce}=kl({target:t,key:H,textDirty:z,contents:y,baselines:w,retain:Ce}),{isLoading:q,isReading:J,loadError:de,unsupported:ve}=ul({target:t,key:H,isBinaryViewer:j,revision:N,loadedRef:ne,contentsRef:te,baselinesRef:Se,pendingRef:fe,readingRef:se,remember:Xe}),Oe=gl({target:t,isBinaryViewer:j,loadError:de,missing:g,contentsRef:te,lineEndingsRef:le,mtimesRef:be,pendingRef:fe,flushOnUnmount:l,onSaveStart:()=>A("saving"),onSaved:(pe,Je,ct)=>{if(A("saved"),v((wt)=>({...wt,[pe]:Je})),ct.mtimeMs!==null)O((wt)=>({...wt,[pe]:ct.mtimeMs}));if(ct.hash!==null)W((wt)=>({...wt,[pe]:ct.hash}));h?.()},onSaveFailed:()=>A(c?"error":"idle"),onNeedsPermission:()=>A("needs-permission"),onConflict:(pe,Je)=>{A("idle"),je.report(pe,Je)}}),kt=o(Oe);kt.current=Oe;let je=bl({key:H,saveNow:()=>kt.current.saveNow(),mtimesRef:be,setMtimes:O,contentsRef:te,setContents:x,setBaselines:v,loadedRef:ne,bumpRevision:()=>U((pe)=>pe+1)}),At=a((pe)=>{let Je=fe.current;if(!Je||_e(Je.file)!==pe)return;window.clearTimeout(Je.timer),fe.current=null},[]),{diskChange:Tn,reloadFromDisk:Ge,keepMineAgainstDisk:Lt}=xl({key:H,target:t,baseHash:F[H]??null,revision:N,hashesRef:Le,mtimesRef:be,contentsRef:te,baselinesRef:Se,pendingRef:fe,readingRef:se,loadedRef:ne,bumpRevision:()=>U((pe)=>pe+1),adoptDiskMtime:je.adopt,clearConflict:je.clear,reloadDiscardingEdits:je.reload,discardPendingWrite:At});i(()=>{if(R!=="saved")return;let pe=window.setTimeout(()=>A("idle"),1500);return()=>window.clearTimeout(pe)},[R]),i(()=>{A("idle")},[H]);let An=a((pe)=>{if(!t||j)return;let Je=_e(t);x((ct)=>({...ct,[Je]:pe})),kt.current.onChange(pe)},[t,j]),{copied:at,copy:Ne,download:Fl}=ml({target:t,content:G,downloadContent:t?ll(G,E[H]??"lf"):G,imageUrl:Q,downloadMimeType:p,byteSource:ie,byteViewer:j});return{content:G,onChange:An,isLoading:q,isReading:J,loaded:t?j||t.content!==void 0||y[H]!==void 0:!1,loadError:de,unsupported:ve,saveStatus:R,copied:at,isDirty:Ye,setBinaryDirty:oe,eol:E[H]??"lf",setEol:Ee,baseMtimeMs:L[H]??null,dirtyKeys:X,language:t?dt(t.name):"javascript",isImage:Z,imageUrl:Q,viewerKind:K,byteSource:ie,isBinaryViewer:j,revision:N,handleMissing:Boolean(t?.handleId)&&!t?.deviceFile&&nl(t?.handleId)===null,deviceBacked:Boolean(t?.deviceFile),deviceMissing:Boolean(t?.deviceFile)&&Km(t?.handleId)===null,saveNow:Oe.saveNow,copy:Ne,download:Fl,reset:Pe,retain:ce,saveMissingConfirm:Oe.saveMissingConfirm,confirmSaveMissing:Oe.confirmSaveMissing,cancelSaveMissing:Oe.cancelSaveMissing,conflict:je.conflict,resolveConflictByReload:()=>{if(H)At(H);je.reload()},resolveConflictByKeepingMine:je.keepMine,reloadFromDisk:Ge,diskChange:Tn,keepMineAgainstDisk:Lt}}var Md=20;function wl(){let[t,r]=S("editor.findHistory",[]),l=a((c)=>{let p=c.trim();if(!p)return;r((h)=>[p,...h.filter((g)=>g!==p)].slice(0,Md))},[r]);return{entries:t,remember:l}}function Sl(){let[t,r]=n(null),l=a((p)=>{let h=p();if(!h||h.start===h.end)return r(null),!1;return r(h),!0},[]),c=a(()=>r(null),[]);return{range:t,arm:l,disarm:c}}var Cl=5000,Wr={matchCase:!1,wholeWord:!1,isRegex:!1,inSelection:!1},El="gm"+("unicode"in RegExp.prototype?"u":"");function Cn(t,r){if(!t)return null;let l=r.isRegex?t:t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c=r.wholeWord?`\\b(?:${l})\\b`:l;try{return new RegExp(c,r.matchCase?El:`${El}i`)}catch{return null}}var Ml=null,Sn=null;function Rd(t){if(Ml===t&&Sn)return Sn;return Sn=ke.of(t.split(`
|
|
9
|
+
`)),Ml=t,Sn}function Tt(t,r,l,c){if(!r)return{matches:[],truncated:!1,invalid:!1};let p=Cn(r,l);if(!p)return{matches:[],truncated:!1,invalid:!0};let h=[],g;try{g=new Vt(Rd(t),p.source,{ignoreCase:!l.matchCase})}catch{return{matches:[],truncated:!1,invalid:!0}}let y=l.inSelection&&c?c:null;while(h.length<Cl&&!g.next().done){let{from:x,to:w}=g.value;if(x===w)continue;if(y&&(x<y.start||w>y.end))continue;h.push({start:x,end:w})}return{matches:h,truncated:h.length>=Cl,invalid:!1}}function vt(t,r){if(t.length===0)return-1;for(let l=0;l<t.length;l++)if(t[l].end>r)return l;return 0}function Rl(t,r,l){if(r<=0)return-1;if(t<0)return l===1?0:r-1;return(t+l+r)%r}function Dd(t){return{full:t[0],numbered:[void 0,...t.slice(1)],named:t.groups}}var Td=/\$(\$|&|\d{1,2}|<[^>]*>)/g;function Dl(t,r){if(!t.includes("$"))return t;return t.replace(Td,(l,c)=>{if(c==="$")return"$";if(c==="&")return r.full;if(c.startsWith("<"))return r.named?.[c.slice(1,-1)]??"";if(c.length===2){let p=r.numbered[Number(c)];if(p!==void 0)return p;let h=r.numbered[Number(c[0])];return h===void 0?"":h+c[1]}return r.numbered[Number(c)]??""})}function Ad(t,r,l,c,p){let h=Cn(l,p);if(!h)return null;h.lastIndex=r.start;let g=h.exec(t);if(!g||g.index!==r.start)return null;let y=p.isRegex?Dl(c,Dd(g)):c;return{found:g[0],inserted:y,start:g.index,end:g.index+g[0].length}}function Tl(t,r,l,c,p){let h=Ad(t,r,l,c,p);if(!h)return null;return{text:t.slice(0,h.start)+h.inserted+t.slice(h.end),caret:h.start+h.inserted.length}}function Al(t,r,l,c){let p=Cn(r,c);if(!p)return null;if(!c.isRegex)return t.replace(p,()=>l);return t.replace(p,(...h)=>{if(String(h[0]).length===0)return"";let g=h[h.length-1],y=typeof g==="object"&&g!==null,x=h.slice(1,h.length-(y?3:2));return Dl(l,{full:String(h[0]),numbered:[void 0,...x],named:y?g:void 0})})}function Ld(t,r){if(!r||r.start===r.end)return null;let l=t.slice(r.start,r.end);if(!l||l.includes(`
|
|
10
|
+
`)||l.length>200)return null;return l}function Mc({text:t,documentKey:r,readSelection:l,select:c,reveal:p,applyDocument:h,toggleWordWrap:g}){let[y,x]=S("editor.findQuery",""),[w,v]=S("editor.findReplace",""),[E,M]=S("editor.findOptions",Wr),L=u(()=>({...Wr,...E}),[E]),O=Sl(),F=wl(),[W,R]=n(!1),[A,N]=n(!1),[U,H]=n(-1),[G,z]=n(0),[K,j]=n(0),Z=o(!1);Z.current=W;let Q=u(()=>Tt(t,y,L,L.inSelection?O.range:null),[t,y,L,O.range]),ie=o(0),ne=o(!0),fe=o(p);fe.current=p;let se=o(c);se.current=c;let te=a((q)=>{ie.current=q,ne.current=!0},[]);i(()=>{te(0),j((q)=>q+1)},[r,te]),i(()=>{let q=Q.matches;if(ne.current){ne.current=!1;let J=vt(q,ie.current);if(H(J),J>=0)se.current(q[J].start,q[J].end,!1),fe.current(q[J].start);return}H((J)=>{if(q.length===0)return-1;if(J<0)return vt(q,ie.current);return Math.min(J,q.length-1)})},[Q,K]);let Se=a((q)=>{x(q),te(ie.current)},[x,te]),le=a(()=>{if(z((de)=>de+1),Z.current)return;let q=l(),J=Ld(t,q);if(J)x(J);te(q?q.start:0),R(!0),j((de)=>de+1)},[t,l,te,x]),be=a(()=>{N(!0),le()},[le]),Le=a(()=>N((q)=>!q),[]),Xe=a(()=>{F.remember(y),R(!1),N(!1);let q=Q.matches[U];if(q)c(q.start,q.end,!0)},[Q.matches,U,c]),Pe=a((q)=>{let J=Q.matches;if(J.length===0)return;let de=Rl(U,J.length,q);H(de),ie.current=J[de].end,c(J[de].start,J[de].end,!1),p(J[de].start)},[Q.matches,U,c,p]),Ce=a((q)=>{let J={...L,[q]:!L[q]};if(q==="inSelection"&&!O.arm(l)){M({...L,inSelection:!1});return}if(q==="inSelection"&&!J.inSelection)O.disarm();M(J),te(ie.current)},[L,M,te,l,O]),Ee=a((q)=>{x(q),F.remember(q),te(ie.current),j((J)=>J+1)},[F,te]),Ye=a((q)=>{let J=dr(t,Math.max(0,q.line-1)),{matches:de}=Tt(t,q.query,q.options),ve=vt(de,J);if(x(q.query),M(q.options),te(ve>=0?de[ve].start:J),j((Oe)=>Oe+1),ve>=0)se.current(de[ve].start,de[ve].end,!0),fe.current(de[ve].start)},[t,x,M,te]),X=a(()=>{let q=Q.matches[U];if(!q)return;let J=Tl(t,q,y,w,L);if(!J)return;h(J.text,J.caret,J.caret),te(J.caret)},[Q.matches,U,t,y,w,L,h,te]),oe=a(()=>{let q=Al(t,y,w,L);if(q===null||q===t)return;let J=Math.min(ie.current,q.length);h(q,J,J),te(J)},[t,y,w,L,h,te]),ce=a((q)=>{switch(q){case"find":le();return;case"replace":be();return;case"nextMatch":Pe(1);return;case"previousMatch":Pe(-1);return;case"replaceOne":X();return;case"replaceAll":oe();return;case"toggleCaseSensitive":Ce("matchCase");return;case"toggleWholeWord":Ce("wholeWord");return;case"toggleRegex":Ce("isRegex");return;case"toggleWordWrap":g?.();return;default:return}},[le,be,Pe,X,oe,Ce,g]);return{open:W,replaceOpen:A,query:y,replacement:w,options:L,matches:Q.matches,truncated:Q.truncated,invalid:Q.invalid,currentIndex:U,setQuery:Se,setReplacement:v,openFind:le,openReplace:be,toggleReplace:Le,focusRequest:G,close:Xe,runCommand:ce,revealMatch:Ye,toggleOption:Ce,selectionRange:L.inSelection?O.range:null,history:F.entries,useHistoryEntry:Ee,step:Pe,replaceCurrent:X,replaceAll:oe}}function Pc(t,r,l){let c=He(tg,eg),[p,h]=n(null);return i(()=>{if(!c||!t||c.path!==t||!l)return;h({request:c,path:t}),Ru(null)},[c,t,l]),u(()=>{if(!p||p.path!==t)return null;let{matches:g}=Tt(r,p.request.query,p.request.options),y=dr(r,Math.max(0,p.request.line-1));return{request:p.request,matches:g,currentIndex:vt(g,y)}},[p,t,r])}function Ll(t){let r=o({});i(()=>{if(!t)return;HA(r.current,Od(t))}),i(()=>{let l=r.current;return()=>WA(l)},[])}function Od(t){let{file:r}=t;if(!r)return{path:null,name:null,content:"",language:"text",state:"idle",note:null,preview:!1};let l={path:r.path,name:r.name,content:t.content,language:t.language,preview:t.preview&&t.viewerKind==="markdown"};if(r.isDiff)return{...l,content:"",state:"diff",note:null,preview:!1};if(t.loadError)return{...l,state:"error",note:t.loadError,preview:!1};if(t.isBinaryViewer)return{...l,content:"",state:"not-a-document",note:`${Fi[t.viewerKind]} files have no text outline.`,preview:!1};if(t.isLoading||!t.loaded)return{...l,state:"loading",note:null,preview:!1};return{...l,state:"ready",note:null}}function Ol(t,r,l){let c=He(VA,KA);return u(()=>{if(!c||!t||c.path!==t||!l)return null;let p=dr(r,Math.max(0,c.line-1)),h=r.indexOf(`
|
|
11
|
+
`,p),g=(h===-1?r.length:h)-p,y=Math.min(g,Math.max(0,(c.column??1)-1)),x=c.length===void 0?y:Math.min(g,y+c.length);return{path:t,offset:p,selectionStart:p+y,selectionEnd:p+x,request:c}},[c,t,l,r])}function Bl({path:t,content:r,ready:l,surfaceRef:c,isPreview:p,exitPreview:h}){let g=Ol(t,r,l),y=o(null),x=o(null);i(()=>{if(x.current!==null){let v=c.current;if(p||!v)return;let E=x.current;x.current=null,Il(v,E);return}if(!g||y.current===g.request)return;if(p){y.current=g.request,x.current={start:g.selectionStart,end:g.selectionEnd,offset:g.offset},h();return}let w=c.current;if(!w)return;y.current=g.request,Il(w,{start:g.selectionStart,end:g.selectionEnd,offset:g.offset})})}function Il(t,r){t.select(r.start,r.end,!0),t.revealOffset(r.offset),qo(null)}function Oc({file:t,editor:r,surfaceRef:l,isPreview:c,exitPreview:p,publish:h=!0}){Ll(h?{file:t,content:r.content,language:r.language,loaded:r.loaded,isLoading:r.isLoading,loadError:r.loadError,viewerKind:r.viewerKind,isBinaryViewer:r.isBinaryViewer,preview:c}:null),Bl({path:t?.path??null,content:r.content,ready:r.loaded&&!r.loadError,surfaceRef:l,isPreview:c,exitPreview:p})}function $c({fileName:t,onReload:r,onKeepMine:l}){return e("div",{className:"flex items-start gap-2 px-3 py-2 border-b border-info/30 bg-info/10 text-[11px] text-ink flex-shrink-0",role:"status","data-external-change-strip":"",children:[e(C,{size:13,className:"text-info flex-shrink-0 mt-0.5"}),e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"font-medium",children:[e("span",{className:"font-mono",children:t})," changed on disk."]}),e("div",{className:"text-ink/60 mt-0.5",children:"Reload takes the disk copy and discards your edits. Keep mine writes yours over it."})]}),e("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e("button",{type:"button",onClick:r,className:"px-2 py-1 rounded border border-ink/20 hover:bg-ink/5 transition-colors cursor-pointer",title:"Take the file from disk",children:"Reload"}),e("button",{type:"button",onClick:l,className:"px-2 py-1 rounded border border-info/50 text-info hover:bg-info/10 transition-colors cursor-pointer",title:"Keep my buffer; the next save writes it",children:"Keep mine"})]})]})}function zc({fileName:t,filePath:r,onClose:l,onConfirm:c}){return i(()=>{let p=(h)=>{if(h.key!=="Escape")return;h.preventDefault(),l()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[l]),e("div",{className:"fixed inset-0 z-50 flex items-center justify-center modal-scrim animate-in fade-in duration-200 p-4",onClick:l,role:"dialog","aria-modal":"true","aria-label":"Save deleted file",children:e("div",{className:"glass-overlay bg-paper border border-ink/20 rounded-xl shadow-xl w-[min(94vw,440px)] overflow-hidden",onClick:(p)=>p.stopPropagation(),children:[e("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-ink/10",children:[e(Pa,{size:16,className:"text-error shrink-0"}),e("h2",{className:"text-[13px] font-semibold text-ink",children:"This file was deleted"})]}),e("div",{className:"px-4 py-4 space-y-3",children:[e("div",{className:"rounded-lg border border-ink/10 bg-canvas/50 px-3 py-2",children:[e("div",{className:"text-[12px] font-mono text-error line-through truncate",children:t}),e("div",{className:"text-[11px] font-mono text-ink/50 break-all mt-0.5",children:r})]}),e("p",{className:"text-[11.5px] leading-relaxed text-ink/60",children:"It was removed from disk while this tab was open. Saving recreates it with the buffer's current contents — anything written to that path since the deletion is lost."})]}),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",autoFocus:!0,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:"Save anyway"})]})]})})}function Uc(t){let[r,l]=S("editor.reviewMode",{});return{active:r[t]===!0,toggle:()=>l((c)=>({...c,[t]:c[t]!==!0}))}}function Qc(t,r=0){let l=Boolean(t.url)&&!t.url?.startsWith("blob:"),[c,p]=n({url:l?null:t.url,loading:l||!t.url,error:null}),h=o(t);return h.current=t,i(()=>{let g=h.current;if(g.url){let v=g.url;if(v.startsWith("blob:")){p({url:v,loading:!1,error:null});return}let E=!1;return p({url:null,loading:!0,error:null}),fetch(v,{headers:{Range:"bytes=0-0"}}).then(async(M)=>{if(E)return;if(M.ok){p({url:v,loading:!1,error:null});return}p({url:null,loading:!1,error:await Vr(M)})}).catch(()=>{if(!E)p({url:v,loading:!1,error:null})}),()=>{E=!0}}let y=g.loadBytes;if(!y){p({url:null,loading:!1,error:"This file cannot be read from here."});return}let x=!1,w=null;return p({url:null,loading:!0,error:null}),y().then((v)=>{if(x)return;w=URL.createObjectURL(g.mimeType?new Blob([v],{type:g.mimeType}):new Blob([v])),p({url:w,loading:!1,error:null})}).catch((v)=>{if(x)return;p({url:null,loading:!1,error:v instanceof Error?v.message:"Could not read this file."})}),()=>{if(x=!0,w)URL.revokeObjectURL(w)}},[t.id,r]),c}
|
|
12
|
+
export{Ec,td,nd,rA,aA,Bc,Zn,ns,Ic,_c,Sc,Tc,Dc,rd,rs,Fi,as,Qc,Nc,al,il,Rc,Fc,Lc,Mc,Pc,Oc,$c,zc,Uc};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{n,i,s,H,Kr,Zl,$f,zf,kg,Vp}from"./index-ncrenheb.js";var E={name:"save",size:24,node:[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]},yt=s(E);var id="omp:editor-theme-changed";function a(){if(typeof window>"u")return Zl;return H("editorTheme")??Zl}var p={theme:null,vars:{},themes:zf(null)};function uo(){let[e,t]=n(a);if(i(()=>{let r=(d)=>{let c=d.detail;t(c||a())};return window.addEventListener(id,r),()=>window.removeEventListener(id,r)},[]),i(()=>{Vp(e)},[e]),e===Kr)return p;let o=$f(e);return{theme:o,vars:kg(o),themes:zf(e)}}var od="omp:editor-indent-changed",sd=[2,4,8],Gc={width:2,insertSpaces:!0};function ld(){if(typeof window>"u")return Gc;let e=H("editorIndentWidth"),t=H("editorInsertSpaces");return{width:typeof e==="number"&&sd.includes(e)?e:Gc.width,insertSpaces:typeof t==="boolean"?t:Gc.insertSpaces}}function jc(e){return e.insertSpaces?" ".repeat(e.width):"\t"}function qc(){let[e,t]=n(ld);return i(()=>{let o=(r)=>{let d=r.detail;t(d??ld())};return window.addEventListener(od,o),()=>window.removeEventListener(od,o)},[]),e}var cd="omp:editor-typing-changed",ol={autoCloseBrackets:!0,autocomplete:!0};function Hc(){if(typeof window>"u")return ol;let e=H("editorAutoCloseBrackets"),t=H("editorAutocomplete");return{autoCloseBrackets:typeof e==="boolean"?e:ol.autoCloseBrackets,autocomplete:typeof t==="boolean"?t:ol.autocomplete}}function Wc(){let[e,t]=n(Hc);return i(()=>{let o=(r)=>{let d=r.detail;t(d??Hc())};return window.addEventListener(cd,o),()=>window.removeEventListener(cd,o)},[]),e}var os="omp:editor-blame-changed",sl={enabled:!0,inline:!1};function po(){if(typeof window>"u")return sl;let e=H("editorBlame"),t=H("editorBlameInline");return{enabled:typeof e==="boolean"?e:sl.enabled,inline:typeof t==="boolean"?t:sl.inline}}function ud(){let[e,t]=n(po);return i(()=>{let o=(r)=>{let d=r.detail;t(d??po())};return window.addEventListener(os,o),()=>window.removeEventListener(os,o)},[]),e}function mo(e,t){let o=URL.createObjectURL(e),r=document.createElement("a");r.href=o,r.download=t,r.click(),URL.revokeObjectURL(o)}
|
|
2
|
+
export{yt,id,uo,od,sd,Gc,ld,jc,qc,cd,ol,Hc,Wc,os,sl,po,ud,mo};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d,n,i,o,u,a,le,e,Ap,we,S,s,f,B,ie,Aa,ae,pe,C,b,ce,nt,OA,no}from"./index-cgzrpvzj.js";var ne={name:"chevrons-up-down",size:24,node:[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]},O=s(ne);function J(l,r,c=1e6){return{sessionId:l,sessionTitle:r,modelId:"",modelName:"",timestamp:"",contextUsed:0,contextLimit:c,contextPercent:0,messagesCount:0,userCount:0,assistantCount:0,totalCost:0,costFormatted:"$0.00",cacheHitAverage:0,costBreakdown:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0},lastMessage:{input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,cacheHitPercent:0},distribution:{userTokens:0,userPercent:0,assistantTokens:0,assistantPercent:0,toolTokens:0,toolPercent:0,otherTokens:0,otherPercent:100},rawMessages:[]}}function Z({used:l,limit:r,percent:c}){let h=l.toLocaleString(),m=r.toLocaleString(),t=Math.min(100,Math.max(0,c));return e("div",{className:"bg-canvas border border-ink/10 rounded-xl p-4 transition-all",children:[e("div",{className:"flex items-center justify-between text-xs mb-2",children:[e("span",{className:"font-semibold text-ink/80",children:"Context"}),e("span",{className:"font-mono text-ink/70 text-[11px]",children:[h," / ",m]})]}),e("div",{className:"w-full h-1.5 bg-ink/10 rounded-full overflow-hidden mb-2",children:e("div",{className:"h-full bg-ink/70 rounded-full transition-all duration-500 ease-out",style:{width:`${t}%`}})}),e("div",{className:"text-[11px] font-mono text-ink/50 text-left",children:[t.toFixed(1),"% used"]})]})}function _(l){return l<0.01?"$0.01":`$${l.toFixed(6).replace(/0+$/,"").replace(/\.$/,"")}`}function z({open:l,onClose:r,breakdown:c,costFormatted:h}){let m=o(null);if(ce(m,r),!l)return null;let t=c?[{label:"Total Cost",value:_(c.total),strong:!0},{label:"Input (cache miss)",value:_(c.input)},{label:"Output",value:_(c.output)},{label:"Cache Read (cache hit)",value:_(c.cacheRead)},{label:"Cache Write",value:_(c.cacheWrite)}]:[{label:"Total Cost",value:h??"$0.01",strong:!0}];return e("div",{ref:m,className:"glass-popover absolute top-full right-0 mt-1.5 z-50 w-64 bg-paper border border-ink/10 rounded-lg shadow-lg p-3",role:"dialog","aria-modal":"false",children:[e("div",{className:"flex items-center justify-between mb-2.5",children:[e("span",{className:"text-xs font-semibold text-ink tracking-tight",children:"Cost Breakdown"}),e("button",{type:"button",onClick:r,className:"p-1 rounded hover:bg-ink/5 text-ink/60 hover:text-ink transition-colors","aria-label":"Close cost breakdown",children:e(b,{size:14})})]}),e("div",{className:"space-y-1.5",children:t.map((x)=>e("div",{className:"flex items-center justify-between text-[11px] font-mono border-b border-ink/5 last:border-0 pb-1.5 last:pb-0",children:[e("span",{className:"text-ink/60",children:x.label}),e("span",{className:`${x.strong?"font-semibold text-ink":"text-ink/80"}`,children:x.value})]},x.label))})]})}function V({messagesCount:l,userCount:r,assistantCount:c,costFormatted:h,cacheHitAverage:m,costBreakdown:t}){let[x,g]=n(!1);return e(d,{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Session Stats"})}),e("div",{className:"flex gap-2 flex-wrap",children:[e(nt,{variant:"compact",label:"Messages",value:l}),e(nt,{variant:"compact",label:"User",value:r}),e(nt,{variant:"compact",label:"Assistant",value:c}),e(nt,{variant:"compact",label:"Cache Hit",value:m!==void 0?`${m.toFixed(1)}%`:"–"}),e("div",{className:"relative bg-canvas border border-ink/10 rounded-lg px-2.5 py-1.5 flex flex-col gap-0.5 flex-1 min-w-0",children:[e("span",{className:"text-[10px] font-medium text-ink/50 flex items-center gap-1",children:["Cost",e("button",{type:"button",onClick:()=>g(!0),className:"p-0.5 rounded text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors","aria-label":"Show cost breakdown",title:"Cost breakdown",children:e(pe,{size:11})})]}),e("span",{className:"text-xs font-semibold font-mono text-ink truncate",children:h}),e(z,{open:x,onClose:()=>g(!1),breakdown:t,costFormatted:h})]})]})]})}function Q({input:l,output:r,reasoning:c,cacheRead:h,cacheWrite:m,cacheHitPercent:t}){return e(d,{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Last Assistant Message"})}),e("div",{className:"flex gap-2 flex-wrap",children:[e(nt,{variant:"compact",label:"In",value:l.toLocaleString()}),e(nt,{variant:"compact",label:"Out",value:r.toLocaleString()}),e(nt,{variant:"compact",label:"Reason",value:c.toLocaleString()}),e(nt,{variant:"compact",label:"Cache",value:`${h.toLocaleString()}/${m.toLocaleString()}`}),e(nt,{variant:"compact",label:"Hit",value:`${t.toFixed(1)}%`})]})]})}function G({userPercent:l,assistantPercent:r,toolPercent:c,otherPercent:h}){return e("div",{className:"space-y-2.5",children:[e("div",{className:"w-full h-1.5 rounded-full overflow-hidden flex bg-ink/10",children:[e("div",{className:"h-full bg-emerald-500 transition-all duration-300",style:{width:`${l}%`},title:`User: ${l}%`}),e("div",{className:"h-full bg-sky-500 transition-all duration-300",style:{width:`${r}%`},title:`Assistant: ${r}%`}),e("div",{className:"h-full bg-amber-500 transition-all duration-300",style:{width:`${c}%`},title:`Tool Calls: ${c}%`}),e("div",{className:"h-full bg-slate-400 transition-all duration-300",style:{width:`${h}%`},title:`Other: ${h}%`})]}),e("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-ink/70",children:[e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-emerald-500 flex-shrink-0"}),e("span",{children:["User ",l,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-sky-500 flex-shrink-0"}),e("span",{children:["Assistant ",r,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-amber-500 flex-shrink-0"}),e("span",{children:["Tool Calls ",c,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-slate-400 flex-shrink-0"}),e("span",{children:["Other ",h,"%"]})]})]})]})}function K({data:l}){no();let[r,c]=n(!1),h=o(null),m=o(null),t=JSON.stringify(l,null,2),x=OA(t),g=a((y)=>{let v=m.current;if(!v)return;v.scrollLeft=y.currentTarget.scrollLeft,v.scrollTop=y.currentTarget.scrollTop},[]),w=a(async(y)=>{y.stopPropagation();try{await navigator.clipboard.writeText(t)}catch{let v=document.createElement("textarea");v.value=t,v.style.position="fixed",v.style.opacity="0",document.body.appendChild(v),v.select(),document.execCommand("copy"),document.body.removeChild(v)}c(!0),setTimeout(()=>c(!1),2000)},[t]);return e("div",{className:"relative my-1.5 rounded-lg bg-paper/80 border border-ink/10 overflow-hidden",children:[e("div",{className:"flex items-center justify-between px-2.5 py-1.5 bg-ink/[0.04] border-b border-ink/10",children:[e("span",{className:"text-[10px] font-mono text-ink/50 select-none",children:[Object.keys(l).length," keys · ",t.length," chars"]}),e("button",{type:"button",onClick:w,className:"flex items-center space-x-1 px-2 py-1 rounded bg-canvas hover:bg-paper text-ink/70 hover:text-ink border border-ink/10 text-[10px] transition-colors shadow-xs",title:"Copy Pretty JSON",children:r?e(d,{children:[e(f,{size:11,className:"text-success"}),e("span",{className:"text-success font-sans font-medium",children:"Copied"})]}):e(d,{children:[e(ae,{size:11}),e("span",{className:"font-sans",children:"Copy JSON"})]})})]}),e("div",{className:"relative",children:[e("pre",{ref:m,"aria-hidden":!0,className:"absolute inset-0 p-2.5 m-0 font-mono text-[11px] leading-5 overflow-x-auto overflow-y-auto whitespace-pre pointer-events-none",dangerouslySetInnerHTML:{__html:x}}),e("pre",{ref:h,onScroll:g,className:"relative p-2.5 m-0 font-mono text-[11px] leading-5 overflow-x-auto overflow-y-auto whitespace-pre select-text selection:bg-ink selection:text-canvas",children:e("code",{className:"text-transparent",children:t})})]})]})}var j=["bg-emerald-500","bg-sky-500","bg-amber-500","bg-violet-500","bg-rose-500","bg-teal-500","bg-indigo-500","bg-fuchsia-500","bg-lime-500","bg-cyan-500","bg-orange-500","bg-pink-500","bg-yellow-500","bg-purple-500","bg-red-500","bg-blue-500","bg-green-500","bg-cyan-600","bg-violet-600","bg-amber-600"],I=20;function q(l){let r=0;for(let c=0;c<l.length;c++)r=r*31+l.charCodeAt(c)|0;return Math.abs(r)}function Y(l){let r=l.indexOf("/"),c=r>0?l.slice(0,r):l,h=r>0?l.slice(r+1):"";return h?`${c} · ${h}`:c}function X(l,r){if(r<=7)return Array.from({length:r},(x,g)=>g+1);let c=new Set([1,r,l,l-1,l+1]);if(l<=3)[2,3,4].forEach((x)=>c.add(x));if(l>=r-2)[r-3,r-2,r-1].forEach((x)=>c.add(x));let h=[...c].filter((x)=>x>=1&&x<=r).sort((x,g)=>x-g),m=[],t=0;for(let x of h){if(x-t>1)m.push("…");m.push(x),t=x}return m}function ee({sessionId:l,refreshKey:r=0}){let[c,h]=S("context.rawExpandedIds",{}),[m,t]=S("context.rawFilterRole","all"),[x,g]=n(1),[w,y]=n([]),[v,W]=n(0),[T,N]=n(!1),E=o(0),U=o(!1),A=a((p)=>{if(typeof window>"u")return;let k=++E.current;if(!p?.silent)N(!0);let R=new URLSearchParams({page:String(x),pageSize:String(I),role:m});if(l)R.set("sessionId",l);fetch(`/api/telemetry/raw-messages?${R.toString()}`).then((M)=>M.ok?M.json():null).then((M)=>{if(U.current||k!==E.current)return;y(M&&Array.isArray(M.items)?M.items:[]),W(M&&Number.isFinite(M.filteredTotal)?M.filteredTotal:0)}).catch(()=>{if(U.current||k!==E.current)return;y([]),W(0)}).finally(()=>{if(!p?.silent&&k===E.current)N(!1)})},[l,x,m]);i(()=>(U.current=!1,A(),()=>{U.current=!0}),[A,r]);let L=Math.max(1,Math.ceil(v/I)),P=Math.min(x,L),D=(p)=>g(Math.min(Math.max(1,p),L)),te=(p)=>{h((k)=>({...k,[p]:!k[p]}))},se=()=>{if(w.every((k)=>c[k.id]))h({});else{let k={};w.forEach((R)=>{k[R.id]=!0}),h(k)}},F=u(()=>{let p=[];for(let k of w){let R=k.info.modelID;if(!R||p.includes(R))continue;p.push(R)}return p},[w]),H=(p)=>p?j[q(p)%j.length]:"bg-ink/20";return e("div",{className:"space-y-3",children:[F.length>0&&e("div",{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Legend"})}),e("div",{className:"bg-canvas border border-ink/10 rounded-xl px-3 py-2",children:e("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] font-mono text-ink/60",children:F.map((p)=>e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:`w-2 h-2 rounded-full ${H(p)}`}),e("span",{children:Y(p)})]},p))})})]}),e("div",{className:"flex items-center justify-between",children:[e("div",{className:"flex items-center space-x-2",children:[e("span",{className:"text-xs font-semibold text-ink/80",children:"Raw Messages"}),e("span",{className:"text-[10px] font-mono text-ink/50 bg-ink/5 px-1.5 py-0.5 rounded-full border border-ink/10",children:v})]}),e("div",{className:"flex items-center space-x-1",children:[e("div",{className:"flex items-center bg-canvas border border-ink/10 rounded-lg p-0.5 text-[10px]",children:[e("button",{type:"button",onClick:()=>{t("all"),g(1)},className:`px-1.5 py-0.5 rounded ${m==="all"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"All"}),e("button",{type:"button",onClick:()=>{t("assistant"),g(1)},className:`px-1.5 py-0.5 rounded ${m==="assistant"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"AI"}),e("button",{type:"button",onClick:()=>{t("user"),g(1)},className:`px-1.5 py-0.5 rounded ${m==="user"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"User"})]}),e("button",{type:"button",onClick:se,className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors text-[10px] flex items-center",title:"Expand / Collapse All",children:e(O,{size:14})})]})]}),e("div",{className:"space-y-1.5",children:!T&&w.length===0?e("div",{className:"p-4 text-center text-xs text-ink/40 italic bg-canvas rounded-xl border border-ink/10",children:"No raw messages recorded yet."}):w.map((p)=>{let k=Boolean(c[p.id]);return e("div",{className:`bg-canvas border border-ink/10 rounded-xl overflow-hidden transition-all duration-200 ${T?"opacity-50":""}`,children:[e("button",{type:"button",onClick:()=>te(p.id),className:"w-full text-left px-3.5 py-2.5 flex items-center justify-between hover:bg-ink/5 transition-colors cursor-pointer",children:[e("div",{className:"flex items-center space-x-2 min-w-0 flex-1 mr-2",children:[e("span",{className:"text-ink/40 flex-shrink-0",children:k?e(B,{size:14}):e(ie,{size:14})}),e("span",{className:"text-xs font-mono text-ink/90 truncate",children:p.badgeLabel})]}),e("div",{className:"flex items-center space-x-3 text-[11px] font-mono text-ink/50 flex-shrink-0",children:[p.tokenSummary&&e("span",{className:"text-ink/60",children:p.tokenSummary}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:`w-2 h-2 rounded-full ${H(p.info.modelID)}`}),e("span",{children:p.timestamp})]})]})]}),k&&e("div",{className:"px-3.5 pb-3 pt-1 border-t border-ink/5 bg-canvas/60",children:e(K,{data:p.rawPayload})})]},p.id)})}),L>1&&e("div",{className:"flex items-center justify-between pt-1",children:[e("span",{className:"text-[10px] font-mono text-ink/50",children:[(P-1)*I+1,"–",Math.min(P*I,v)," of ",v]}),e("div",{className:"flex items-center gap-0.5",children:[e("button",{type:"button",disabled:P<=1,onClick:()=>D(P-1),className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 disabled:opacity-30 disabled:hover:bg-transparent transition-colors",title:"Previous page",children:e(Aa,{size:14})}),X(P,L).map((p,k)=>p==="…"?e("span",{className:"px-1 text-[10px] font-mono text-ink/40 select-none",children:"…"},`gap-${k}`):e("button",{type:"button",onClick:()=>D(p),className:`min-w-[22px] h-[22px] px-1 rounded text-[10px] font-mono transition-colors ${p===P?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink hover:bg-ink/5"}`,children:p},p)),e("button",{type:"button",disabled:P>=L,onClick:()=>D(P+1),className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 disabled:opacity-30 disabled:hover:bg-transparent transition-colors",title:"Next page",children:e(ie,{size:14})})]})]})]})}function dt({className:l="",enabled:r=!0,refreshKey:c=0}){let[h]=le(),m=h.get("sessionId"),[t,x]=n(()=>J(m||"default","Session not started")),g=o(!1),w=a(()=>{if(typeof window>"u")return;let T=m?`?sessionId=${encodeURIComponent(m)}`:"";fetch(`/api/telemetry/context${T}`).then((N)=>N.ok?N.json():null).then((N)=>{if(!g.current&&N&&N.telemetry)x(N.telemetry)}).catch((N)=>{if(!g.current)console.warn("Failed to fetch context telemetry:",N)})},[m]);i(()=>{if(g.current=!1,!r)return;return w(),()=>{g.current=!0}},[r,c,w]);let y=we(m?Ap(m):null,{enabled:r}),[v,W]=n(0);if(i(()=>{if(y.data)x(y.data),W((T)=>T+1)},[y.data]),!r)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${l}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});if(t.messagesCount===0)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${l}`,children:e("span",{className:"text-xs font-mono",children:"Session not started"})});return e("div",{className:`flex flex-col h-full bg-paper text-ink overflow-hidden select-none ${l}`,children:[e("div",{className:"flex-shrink-0 p-4 border-b border-ink/10 bg-paper",children:e("div",{className:"flex items-start justify-between gap-2",children:[e("div",{className:"min-w-0",children:[e("h2",{className:"text-xs font-medium text-ink tracking-tight truncate",children:t.sessionTitle}),e("div",{className:"text-[11px] text-ink/50 mt-1 truncate font-mono",children:t.timestamp})]}),e("button",{type:"button",onClick:()=>{y.refresh(),w()},disabled:!r,title:"Refresh context telemetry","aria-label":"Refresh context telemetry","aria-busy":y.refreshing,className:"flex-shrink-0 rounded-md border border-ink/15 bg-paper p-1.5 text-ink/80 transition-colors hover:bg-ink/5 disabled:opacity-50",children:e(C,{size:12,className:y.refreshing?"animate-spin text-ink":""})})]})}),e("div",{className:"flex-1 scrollbar-overlay-container p-4 space-y-4",children:[e(Z,{used:t.contextUsed,limit:t.contextLimit,percent:t.contextPercent}),e(V,{messagesCount:t.messagesCount,userCount:t.userCount,assistantCount:t.assistantCount,costFormatted:t.costFormatted,cacheHitAverage:t.cacheHitAverage,costBreakdown:t.costBreakdown}),e(Q,{input:t.lastMessage.input,output:t.lastMessage.output,reasoning:t.lastMessage.reasoning,cacheRead:t.lastMessage.cacheRead,cacheWrite:t.lastMessage.cacheWrite,cacheHitPercent:t.lastMessage.cacheHitPercent}),e(G,{userPercent:t.distribution.userPercent,assistantPercent:t.distribution.assistantPercent,toolPercent:t.distribution.toolPercent,otherPercent:t.distribution.otherPercent}),e(ee,{sessionId:m,refreshKey:c+v})]})]})}export{dt as ContextPanel};
|
|
1
|
+
import{d,n,i,o,u,a,le,e,gp,we,S,s,f,B,ie,Aa,ae,pe,C,b,ce,nt,zA,no}from"./index-ncrenheb.js";var ne={name:"chevrons-up-down",size:24,node:[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]},O=s(ne);function J(l,r,c=1e6){return{sessionId:l,sessionTitle:r,modelId:"",modelName:"",timestamp:"",contextUsed:0,contextLimit:c,contextPercent:0,messagesCount:0,userCount:0,assistantCount:0,totalCost:0,costFormatted:"$0.00",cacheHitAverage:0,costBreakdown:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0},lastMessage:{input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,cacheHitPercent:0},distribution:{userTokens:0,userPercent:0,assistantTokens:0,assistantPercent:0,toolTokens:0,toolPercent:0,otherTokens:0,otherPercent:100},rawMessages:[]}}function Z({used:l,limit:r,percent:c}){let h=l.toLocaleString(),m=r.toLocaleString(),t=Math.min(100,Math.max(0,c));return e("div",{className:"bg-canvas border border-ink/10 rounded-xl p-4 transition-all",children:[e("div",{className:"flex items-center justify-between text-xs mb-2",children:[e("span",{className:"font-semibold text-ink/80",children:"Context"}),e("span",{className:"font-mono text-ink/70 text-[11px]",children:[h," / ",m]})]}),e("div",{className:"w-full h-1.5 bg-ink/10 rounded-full overflow-hidden mb-2",children:e("div",{className:"h-full bg-ink/70 rounded-full transition-all duration-500 ease-out",style:{width:`${t}%`}})}),e("div",{className:"text-[11px] font-mono text-ink/50 text-left",children:[t.toFixed(1),"% used"]})]})}function _(l){return l<0.01?"$0.01":`$${l.toFixed(6).replace(/0+$/,"").replace(/\.$/,"")}`}function z({open:l,onClose:r,breakdown:c,costFormatted:h}){let m=o(null);if(ce(m,r),!l)return null;let t=c?[{label:"Total Cost",value:_(c.total),strong:!0},{label:"Input (cache miss)",value:_(c.input)},{label:"Output",value:_(c.output)},{label:"Cache Read (cache hit)",value:_(c.cacheRead)},{label:"Cache Write",value:_(c.cacheWrite)}]:[{label:"Total Cost",value:h??"$0.01",strong:!0}];return e("div",{ref:m,className:"glass-popover absolute top-full right-0 mt-1.5 z-50 w-64 bg-paper border border-ink/10 rounded-lg shadow-lg p-3",role:"dialog","aria-modal":"false",children:[e("div",{className:"flex items-center justify-between mb-2.5",children:[e("span",{className:"text-xs font-semibold text-ink tracking-tight",children:"Cost Breakdown"}),e("button",{type:"button",onClick:r,className:"p-1 rounded hover:bg-ink/5 text-ink/60 hover:text-ink transition-colors","aria-label":"Close cost breakdown",children:e(b,{size:14})})]}),e("div",{className:"space-y-1.5",children:t.map((x)=>e("div",{className:"flex items-center justify-between text-[11px] font-mono border-b border-ink/5 last:border-0 pb-1.5 last:pb-0",children:[e("span",{className:"text-ink/60",children:x.label}),e("span",{className:`${x.strong?"font-semibold text-ink":"text-ink/80"}`,children:x.value})]},x.label))})]})}function V({messagesCount:l,userCount:r,assistantCount:c,costFormatted:h,cacheHitAverage:m,costBreakdown:t}){let[x,g]=n(!1);return e(d,{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Session Stats"})}),e("div",{className:"flex gap-2 flex-wrap",children:[e(nt,{variant:"compact",label:"Messages",value:l}),e(nt,{variant:"compact",label:"User",value:r}),e(nt,{variant:"compact",label:"Assistant",value:c}),e(nt,{variant:"compact",label:"Cache Hit",value:m!==void 0?`${m.toFixed(1)}%`:"–"}),e("div",{className:"relative bg-canvas border border-ink/10 rounded-lg px-2.5 py-1.5 flex flex-col gap-0.5 flex-1 min-w-0",children:[e("span",{className:"text-[10px] font-medium text-ink/50 flex items-center gap-1",children:["Cost",e("button",{type:"button",onClick:()=>g(!0),className:"p-0.5 rounded text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors","aria-label":"Show cost breakdown",title:"Cost breakdown",children:e(pe,{size:11})})]}),e("span",{className:"text-xs font-semibold font-mono text-ink truncate",children:h}),e(z,{open:x,onClose:()=>g(!1),breakdown:t,costFormatted:h})]})]})]})}function Q({input:l,output:r,reasoning:c,cacheRead:h,cacheWrite:m,cacheHitPercent:t}){return e(d,{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Last Assistant Message"})}),e("div",{className:"flex gap-2 flex-wrap",children:[e(nt,{variant:"compact",label:"In",value:l.toLocaleString()}),e(nt,{variant:"compact",label:"Out",value:r.toLocaleString()}),e(nt,{variant:"compact",label:"Reason",value:c.toLocaleString()}),e(nt,{variant:"compact",label:"Cache",value:`${h.toLocaleString()}/${m.toLocaleString()}`}),e(nt,{variant:"compact",label:"Hit",value:`${t.toFixed(1)}%`})]})]})}function G({userPercent:l,assistantPercent:r,toolPercent:c,otherPercent:h}){return e("div",{className:"space-y-2.5",children:[e("div",{className:"w-full h-1.5 rounded-full overflow-hidden flex bg-ink/10",children:[e("div",{className:"h-full bg-emerald-500 transition-all duration-300",style:{width:`${l}%`},title:`User: ${l}%`}),e("div",{className:"h-full bg-sky-500 transition-all duration-300",style:{width:`${r}%`},title:`Assistant: ${r}%`}),e("div",{className:"h-full bg-amber-500 transition-all duration-300",style:{width:`${c}%`},title:`Tool Calls: ${c}%`}),e("div",{className:"h-full bg-slate-400 transition-all duration-300",style:{width:`${h}%`},title:`Other: ${h}%`})]}),e("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-ink/70",children:[e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-emerald-500 flex-shrink-0"}),e("span",{children:["User ",l,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-sky-500 flex-shrink-0"}),e("span",{children:["Assistant ",r,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-amber-500 flex-shrink-0"}),e("span",{children:["Tool Calls ",c,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-slate-400 flex-shrink-0"}),e("span",{children:["Other ",h,"%"]})]})]})]})}function K({data:l}){no();let[r,c]=n(!1),h=o(null),m=o(null),t=JSON.stringify(l,null,2),x=zA(t),g=a((y)=>{let v=m.current;if(!v)return;v.scrollLeft=y.currentTarget.scrollLeft,v.scrollTop=y.currentTarget.scrollTop},[]),w=a(async(y)=>{y.stopPropagation();try{await navigator.clipboard.writeText(t)}catch{let v=document.createElement("textarea");v.value=t,v.style.position="fixed",v.style.opacity="0",document.body.appendChild(v),v.select(),document.execCommand("copy"),document.body.removeChild(v)}c(!0),setTimeout(()=>c(!1),2000)},[t]);return e("div",{className:"relative my-1.5 rounded-lg bg-paper/80 border border-ink/10 overflow-hidden",children:[e("div",{className:"flex items-center justify-between px-2.5 py-1.5 bg-ink/[0.04] border-b border-ink/10",children:[e("span",{className:"text-[10px] font-mono text-ink/50 select-none",children:[Object.keys(l).length," keys · ",t.length," chars"]}),e("button",{type:"button",onClick:w,className:"flex items-center space-x-1 px-2 py-1 rounded bg-canvas hover:bg-paper text-ink/70 hover:text-ink border border-ink/10 text-[10px] transition-colors shadow-xs",title:"Copy Pretty JSON",children:r?e(d,{children:[e(f,{size:11,className:"text-success"}),e("span",{className:"text-success font-sans font-medium",children:"Copied"})]}):e(d,{children:[e(ae,{size:11}),e("span",{className:"font-sans",children:"Copy JSON"})]})})]}),e("div",{className:"relative",children:[e("pre",{ref:m,"aria-hidden":!0,className:"absolute inset-0 p-2.5 m-0 font-mono text-[11px] leading-5 overflow-x-auto overflow-y-auto whitespace-pre pointer-events-none",dangerouslySetInnerHTML:{__html:x}}),e("pre",{ref:h,onScroll:g,className:"relative p-2.5 m-0 font-mono text-[11px] leading-5 overflow-x-auto overflow-y-auto whitespace-pre select-text selection:bg-ink selection:text-canvas",children:e("code",{className:"text-transparent",children:t})})]})]})}var j=["bg-emerald-500","bg-sky-500","bg-amber-500","bg-violet-500","bg-rose-500","bg-teal-500","bg-indigo-500","bg-fuchsia-500","bg-lime-500","bg-cyan-500","bg-orange-500","bg-pink-500","bg-yellow-500","bg-purple-500","bg-red-500","bg-blue-500","bg-green-500","bg-cyan-600","bg-violet-600","bg-amber-600"],I=20;function q(l){let r=0;for(let c=0;c<l.length;c++)r=r*31+l.charCodeAt(c)|0;return Math.abs(r)}function Y(l){let r=l.indexOf("/"),c=r>0?l.slice(0,r):l,h=r>0?l.slice(r+1):"";return h?`${c} · ${h}`:c}function X(l,r){if(r<=7)return Array.from({length:r},(x,g)=>g+1);let c=new Set([1,r,l,l-1,l+1]);if(l<=3)[2,3,4].forEach((x)=>c.add(x));if(l>=r-2)[r-3,r-2,r-1].forEach((x)=>c.add(x));let h=[...c].filter((x)=>x>=1&&x<=r).sort((x,g)=>x-g),m=[],t=0;for(let x of h){if(x-t>1)m.push("…");m.push(x),t=x}return m}function ee({sessionId:l,refreshKey:r=0}){let[c,h]=S("context.rawExpandedIds",{}),[m,t]=S("context.rawFilterRole","all"),[x,g]=n(1),[w,y]=n([]),[v,W]=n(0),[T,N]=n(!1),E=o(0),U=o(!1),A=a((p)=>{if(typeof window>"u")return;let k=++E.current;if(!p?.silent)N(!0);let R=new URLSearchParams({page:String(x),pageSize:String(I),role:m});if(l)R.set("sessionId",l);fetch(`/api/telemetry/raw-messages?${R.toString()}`).then((M)=>M.ok?M.json():null).then((M)=>{if(U.current||k!==E.current)return;y(M&&Array.isArray(M.items)?M.items:[]),W(M&&Number.isFinite(M.filteredTotal)?M.filteredTotal:0)}).catch(()=>{if(U.current||k!==E.current)return;y([]),W(0)}).finally(()=>{if(!p?.silent&&k===E.current)N(!1)})},[l,x,m]);i(()=>(U.current=!1,A(),()=>{U.current=!0}),[A,r]);let L=Math.max(1,Math.ceil(v/I)),P=Math.min(x,L),D=(p)=>g(Math.min(Math.max(1,p),L)),te=(p)=>{h((k)=>({...k,[p]:!k[p]}))},se=()=>{if(w.every((k)=>c[k.id]))h({});else{let k={};w.forEach((R)=>{k[R.id]=!0}),h(k)}},F=u(()=>{let p=[];for(let k of w){let R=k.info.modelID;if(!R||p.includes(R))continue;p.push(R)}return p},[w]),H=(p)=>p?j[q(p)%j.length]:"bg-ink/20";return e("div",{className:"space-y-3",children:[F.length>0&&e("div",{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Legend"})}),e("div",{className:"bg-canvas border border-ink/10 rounded-xl px-3 py-2",children:e("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] font-mono text-ink/60",children:F.map((p)=>e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:`w-2 h-2 rounded-full ${H(p)}`}),e("span",{children:Y(p)})]},p))})})]}),e("div",{className:"flex items-center justify-between",children:[e("div",{className:"flex items-center space-x-2",children:[e("span",{className:"text-xs font-semibold text-ink/80",children:"Raw Messages"}),e("span",{className:"text-[10px] font-mono text-ink/50 bg-ink/5 px-1.5 py-0.5 rounded-full border border-ink/10",children:v})]}),e("div",{className:"flex items-center space-x-1",children:[e("div",{className:"flex items-center bg-canvas border border-ink/10 rounded-lg p-0.5 text-[10px]",children:[e("button",{type:"button",onClick:()=>{t("all"),g(1)},className:`px-1.5 py-0.5 rounded ${m==="all"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"All"}),e("button",{type:"button",onClick:()=>{t("assistant"),g(1)},className:`px-1.5 py-0.5 rounded ${m==="assistant"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"AI"}),e("button",{type:"button",onClick:()=>{t("user"),g(1)},className:`px-1.5 py-0.5 rounded ${m==="user"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"User"})]}),e("button",{type:"button",onClick:se,className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors text-[10px] flex items-center",title:"Expand / Collapse All",children:e(O,{size:14})})]})]}),e("div",{className:"space-y-1.5",children:!T&&w.length===0?e("div",{className:"p-4 text-center text-xs text-ink/40 italic bg-canvas rounded-xl border border-ink/10",children:"No raw messages recorded yet."}):w.map((p)=>{let k=Boolean(c[p.id]);return e("div",{className:`bg-canvas border border-ink/10 rounded-xl overflow-hidden transition-all duration-200 ${T?"opacity-50":""}`,children:[e("button",{type:"button",onClick:()=>te(p.id),className:"w-full text-left px-3.5 py-2.5 flex items-center justify-between hover:bg-ink/5 transition-colors cursor-pointer",children:[e("div",{className:"flex items-center space-x-2 min-w-0 flex-1 mr-2",children:[e("span",{className:"text-ink/40 flex-shrink-0",children:k?e(B,{size:14}):e(ie,{size:14})}),e("span",{className:"text-xs font-mono text-ink/90 truncate",children:p.badgeLabel})]}),e("div",{className:"flex items-center space-x-3 text-[11px] font-mono text-ink/50 flex-shrink-0",children:[p.tokenSummary&&e("span",{className:"text-ink/60",children:p.tokenSummary}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:`w-2 h-2 rounded-full ${H(p.info.modelID)}`}),e("span",{children:p.timestamp})]})]})]}),k&&e("div",{className:"px-3.5 pb-3 pt-1 border-t border-ink/5 bg-canvas/60",children:e(K,{data:p.rawPayload})})]},p.id)})}),L>1&&e("div",{className:"flex items-center justify-between pt-1",children:[e("span",{className:"text-[10px] font-mono text-ink/50",children:[(P-1)*I+1,"–",Math.min(P*I,v)," of ",v]}),e("div",{className:"flex items-center gap-0.5",children:[e("button",{type:"button",disabled:P<=1,onClick:()=>D(P-1),className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 disabled:opacity-30 disabled:hover:bg-transparent transition-colors",title:"Previous page",children:e(Aa,{size:14})}),X(P,L).map((p,k)=>p==="…"?e("span",{className:"px-1 text-[10px] font-mono text-ink/40 select-none",children:"…"},`gap-${k}`):e("button",{type:"button",onClick:()=>D(p),className:`min-w-[22px] h-[22px] px-1 rounded text-[10px] font-mono transition-colors ${p===P?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink hover:bg-ink/5"}`,children:p},p)),e("button",{type:"button",disabled:P>=L,onClick:()=>D(P+1),className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 disabled:opacity-30 disabled:hover:bg-transparent transition-colors",title:"Next page",children:e(ie,{size:14})})]})]})]})}function dt({className:l="",enabled:r=!0,refreshKey:c=0}){let[h]=le(),m=h.get("sessionId"),[t,x]=n(()=>J(m||"default","Session not started")),g=o(!1),w=a(()=>{if(typeof window>"u")return;let T=m?`?sessionId=${encodeURIComponent(m)}`:"";fetch(`/api/telemetry/context${T}`).then((N)=>N.ok?N.json():null).then((N)=>{if(!g.current&&N&&N.telemetry)x(N.telemetry)}).catch((N)=>{if(!g.current)console.warn("Failed to fetch context telemetry:",N)})},[m]);i(()=>{if(g.current=!1,!r)return;return w(),()=>{g.current=!0}},[r,c,w]);let y=we(m?gp(m):null,{enabled:r}),[v,W]=n(0);if(i(()=>{if(y.data)x(y.data),W((T)=>T+1)},[y.data]),!r)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${l}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});if(t.messagesCount===0)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${l}`,children:e("span",{className:"text-xs font-mono",children:"Session not started"})});return e("div",{className:`flex flex-col h-full bg-paper text-ink overflow-hidden select-none ${l}`,children:[e("div",{className:"flex-shrink-0 p-4 border-b border-ink/10 bg-paper",children:e("div",{className:"flex items-start justify-between gap-2",children:[e("div",{className:"min-w-0",children:[e("h2",{className:"text-xs font-medium text-ink tracking-tight truncate",children:t.sessionTitle}),e("div",{className:"text-[11px] text-ink/50 mt-1 truncate font-mono",children:t.timestamp})]}),e("button",{type:"button",onClick:()=>{y.refresh(),w()},disabled:!r,title:"Refresh context telemetry","aria-label":"Refresh context telemetry","aria-busy":y.refreshing,className:"flex-shrink-0 rounded-md border border-ink/15 bg-paper p-1.5 text-ink/80 transition-colors hover:bg-ink/5 disabled:opacity-50",children:e(C,{size:12,className:y.refreshing?"animate-spin text-ink":""})})]})}),e("div",{className:"flex-1 scrollbar-overlay-container p-4 space-y-4",children:[e(Z,{used:t.contextUsed,limit:t.contextLimit,percent:t.contextPercent}),e(V,{messagesCount:t.messagesCount,userCount:t.userCount,assistantCount:t.assistantCount,costFormatted:t.costFormatted,cacheHitAverage:t.cacheHitAverage,costBreakdown:t.costBreakdown}),e(Q,{input:t.lastMessage.input,output:t.lastMessage.output,reasoning:t.lastMessage.reasoning,cacheRead:t.lastMessage.cacheRead,cacheWrite:t.lastMessage.cacheWrite,cacheHitPercent:t.lastMessage.cacheHitPercent}),e(G,{userPercent:t.distribution.userPercent,assistantPercent:t.distribution.assistantPercent,toolPercent:t.distribution.toolPercent,otherPercent:t.distribution.otherPercent}),e(ee,{sessionId:m,refreshKey:c+v})]})]})}export{dt as ContextPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d,u,le,e,
|
|
1
|
+
import{d,u,le,e,TA,we,I,B,ie,vr,C,Fs,Lu,Pp,ug,Op,$p}from"./index-ncrenheb.js";function k({phase:t,index:o,collapsed:a,currentKey:i,onToggle:x}){let m=Op(t),r=t.tasks.length>0&&m===t.tasks.length;return e("div",{className:"overflow-hidden rounded-lg border border-ink/10 bg-paper",children:[e("button",{type:"button",onClick:x,"aria-expanded":!a,className:"flex w-full items-center gap-1.5 border-b border-ink/8 bg-canvas/40 px-2.5 py-1.5 text-left hover:bg-ink/5",children:[a?e(ie,{size:12,className:"shrink-0 text-ink/40"}):e(B,{size:12,className:"shrink-0 text-ink/40"}),e("span",{className:`min-w-0 flex-1 truncate text-[10px] font-semibold uppercase tracking-wider ${r?"text-ink/35":"text-ink/60"}`,title:t.name,children:[o+1,". ",t.name]}),e("span",{className:"shrink-0 font-mono text-[10px] text-ink/40",children:[m,"/",t.tasks.length]})]}),!a&&e("div",{className:"divide-y divide-ink/[0.05] p-0.5",children:t.tasks.length===0?e("div",{className:"px-2.5 py-1.5 text-[11px] text-ink/40",children:"No tasks in this phase"}):t.tasks.map((l,f)=>e($p,{task:l,current:i===`${o}:${f}`},`${f}-${l.content}`))})]})}function j({className:t="",active:o=!0}){let[a]=le(),i=a.get("sessionId"),[x,m]=Fs("todo.collapsedPhases",{}),{data:r,isLoading:l,refreshing:f,stale:g,refresh:b}=we(i?TA(i):null,{enabled:o}),s=r?.snapshot??null,p=r?.progress??null,v=u(()=>{let n=ug(s?.phases??[]);return n?`${n.phase}:${n.task}`:null},[s]);if(!i)return e("div",{className:`flex h-full flex-col items-center justify-center bg-paper text-ink/40 ${t}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});return e("div",{className:`flex h-full w-full min-w-0 flex-col overflow-hidden bg-paper text-ink ${t}`,children:[e("div",{className:"flex flex-shrink-0 items-center justify-between gap-3 border-b border-ink/10 px-3.5 py-2.5",children:[e("div",{className:"flex min-w-0 items-center gap-2",children:[e("h2",{className:"text-xs font-semibold uppercase tracking-wider text-ink",children:"Todos"}),s&&e("span",{className:"truncate font-mono text-[10.5px] text-ink/50",title:Lu(p),children:Lu(p)}),r?.isMock&&e("span",{className:"flex-shrink-0 rounded border border-ink/15 bg-ink/5 px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-wider text-ink/60",children:"Mock"})]}),e("button",{type:"button",onClick:b,disabled:l,title:"Refresh todos","aria-label":"Refresh todos",className:"flex-shrink-0 rounded-md border border-ink/15 bg-paper p-1.5 text-ink/80 transition-colors hover:bg-ink/5 disabled:opacity-50",children:e(C,{size:12,className:l||f?"animate-spin text-ink":""})})]}),p&&p.total>0&&e("div",{className:"flex-shrink-0 border-b border-ink/10 px-3.5 py-2.5",children:e("div",{className:"h-1.5 overflow-hidden rounded-full bg-ink/8",children:e("div",{className:"h-full rounded-full bg-success transition-all duration-300",style:{width:`${Pp(p)}%`}})})}),e("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto scrollbar-overlay-container p-3.5",children:[g&&e("div",{className:"flex items-start gap-2 rounded-lg border border-ink/15 bg-ink/5 px-3 py-2 text-[11px] text-ink/60",children:[e(I,{size:13,className:"mt-[1px] shrink-0"}),e("span",{className:"min-w-0 break-words",children:"Reconnecting: this list may be out of date."})]}),!s?e("div",{className:"flex flex-col items-center justify-center gap-2 py-12 text-center text-ink/40",children:[e(vr,{size:20}),e("p",{className:"max-w-[240px] text-[11.5px] leading-relaxed",children:["No todo list in this session. The agent writes one with the ",e("span",{className:"font-mono",children:"todo"})," tool when a task is worth planning."]})]}):e(d,{children:[s.phases.map((n,c)=>e(k,{phase:n,index:c,collapsed:Boolean(x[String(c)]),currentKey:v,onToggle:()=>m((h)=>({...h,[String(c)]:!h[String(c)]}))},`${c}-${n.name}`)),e("p",{className:"pt-1 text-[10.5px] leading-relaxed text-ink/35",children:["Read from this session's transcript",s.updatedAt?` · updated ${N(s.updatedAt)}`:"",s.source==="custom"?" · edited by hand":"","."]})]})]})]})}function N(t){let o=new Date(t);if(Number.isNaN(o.getTime()))return t;return o.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}export{j as TodoPanel};
|