@band-app/server 0.54.1 → 0.54.2

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.
Files changed (70) hide show
  1. package/dist/client/_shell.html +0 -0
  2. package/dist/client/assets/{TerminalPanel-CfzL015Z.js → TerminalPanel-zm8MgtWD.js} +1 -1
  3. package/dist/client/assets/{_basePickBy-DCBI2ZYZ.js → _basePickBy-Df9AWPQJ.js} +1 -1
  4. package/dist/client/assets/{_baseUniq-DcG-qGfl.js → _baseUniq-C8iGnWYN.js} +1 -1
  5. package/dist/client/assets/{arc-Dtd3NOeG.js → arc-Dotr_YMW.js} +1 -1
  6. package/dist/client/assets/{architectureDiagram-VXUJARFQ-_4wJCo66.js → architectureDiagram-VXUJARFQ-BkG8VmpL.js} +1 -1
  7. package/dist/client/assets/{blockDiagram-VD42YOAC-BLg8A5DO.js → blockDiagram-VD42YOAC-DZYGOHoq.js} +1 -1
  8. package/dist/client/assets/{c4Diagram-YG6GDRKO-1o6lovC1.js → c4Diagram-YG6GDRKO-Ce9RV_Np.js} +1 -1
  9. package/dist/client/assets/channel-BQWEKiCC.js +1 -0
  10. package/dist/client/assets/{chunk-4BX2VUAB-pUhlexDl.js → chunk-4BX2VUAB-Ck1qaTAA.js} +1 -1
  11. package/dist/client/assets/{chunk-55IACEB6-DIOOkGXI.js → chunk-55IACEB6-CeH02gXd.js} +1 -1
  12. package/dist/client/assets/{chunk-B4BG7PRW-betJcaMy.js → chunk-B4BG7PRW-DqBzx79X.js} +1 -1
  13. package/dist/client/assets/{chunk-DI55MBZ5-Du6zLzqO.js → chunk-DI55MBZ5-p68JZT5Z.js} +1 -1
  14. package/dist/client/assets/{chunk-FMBD7UC4-jlnPGz3-.js → chunk-FMBD7UC4-DC8dY12t.js} +1 -1
  15. package/dist/client/assets/{chunk-QN33PNHL-BtZcZKWT.js → chunk-QN33PNHL-D1Af7sn_.js} +1 -1
  16. package/dist/client/assets/{chunk-QZHKN3VN-CCXlh8PQ.js → chunk-QZHKN3VN-BHBPr8iM.js} +1 -1
  17. package/dist/client/assets/{chunk-TZMSLE5B-EGqxu3bA.js → chunk-TZMSLE5B-BP9v1VXR.js} +1 -1
  18. package/dist/client/assets/classDiagram-2ON5EDUG-Bkz5oJ-y.js +1 -0
  19. package/dist/client/assets/classDiagram-v2-WZHVMYZB-Bkz5oJ-y.js +1 -0
  20. package/dist/client/assets/clone-Dr7z_3vQ.js +1 -0
  21. package/dist/client/assets/{cose-bilkent-S5V4N54A-CiQDuqKy.js → cose-bilkent-S5V4N54A-C7S-iRjs.js} +1 -1
  22. package/dist/client/assets/{dagre-6UL2VRFP-BV1RIA6i.js → dagre-6UL2VRFP-CIdLKDDa.js} +1 -1
  23. package/dist/client/assets/{diagram-PSM6KHXK-oZBpmBZ4.js → diagram-PSM6KHXK-_VfU4I5J.js} +1 -1
  24. package/dist/client/assets/{diagram-QEK2KX5R-BvBvt_5J.js → diagram-QEK2KX5R-ByPoixdO.js} +1 -1
  25. package/dist/client/assets/{diagram-S2PKOQOG-sjeU7pbV.js → diagram-S2PKOQOG-CU2nF5Pi.js} +1 -1
  26. package/dist/client/assets/{erDiagram-Q2GNP2WA-DnmU3JYj.js → erDiagram-Q2GNP2WA-DuReqla0.js} +1 -1
  27. package/dist/client/assets/{flowDiagram-NV44I4VS-vWTy8wO1.js → flowDiagram-NV44I4VS-BzbJhnQR.js} +1 -1
  28. package/dist/client/assets/{ganttDiagram-JELNMOA3-C8UgEfn6.js → ganttDiagram-JELNMOA3-BeBP4O51.js} +1 -1
  29. package/dist/client/assets/{gitGraphDiagram-V2S2FVAM-D4Y2-pQd.js → gitGraphDiagram-V2S2FVAM-7rU4MgM6.js} +1 -1
  30. package/dist/client/assets/{graph-wAJZ-snQ.js → graph-v9lPIGDx.js} +1 -1
  31. package/dist/client/assets/{highlighted-body-B3W2YXNL-BS1x7lkZ.js → highlighted-body-B3W2YXNL-Bt5DPhhI.js} +1 -1
  32. package/dist/client/assets/{index-DRo8uUPl.js → index-Be1D1vwS.js} +1 -1
  33. package/dist/client/assets/{index-B52rCane.js → index-CJefa5Go.js} +1 -1
  34. package/dist/client/assets/{index-ClYtumza.js → index-CsZW3tVv.js} +1 -1
  35. package/dist/client/assets/{index-DIelkckr.js → index-D2wFO-D3.js} +1 -1
  36. package/dist/client/assets/{index-ZYHE2FSs.js → index-DGN6wKkW.js} +1 -1
  37. package/dist/client/assets/{index-BULPK8ND.js → index-DjGPjARU.js} +1 -1
  38. package/dist/client/assets/{index-Hh-Dy8VL.js → index-DoGYlvHl.js} +1 -1
  39. package/dist/client/assets/{index-21p4gEDF.js → index-DrM0qB0a.js} +1 -1
  40. package/dist/client/assets/{index-CxNXgFPY.js → index-Dy40JkoS.js} +1 -1
  41. package/dist/client/assets/{index-DvCvhnCb.js → index-Q6D-8JjG.js} +1 -1
  42. package/dist/client/assets/{index-CDRJgI3A.js → index-Qk1h8PGS.js} +1 -1
  43. package/dist/client/assets/{index-BMcO1RPX.js → index-XAyPsPHs.js} +1 -1
  44. package/dist/client/assets/{index-g0Sr5h74.js → index-jC0z3Kaq.js} +1 -1
  45. package/dist/client/assets/{infoDiagram-HS3SLOUP-CmZ04ZX2.js → infoDiagram-HS3SLOUP-BOjyAfYW.js} +1 -1
  46. package/dist/client/assets/{journeyDiagram-XKPGCS4Q-CyBTVa_6.js → journeyDiagram-XKPGCS4Q-daUwYLfO.js} +1 -1
  47. package/dist/client/assets/{kanban-definition-3W4ZIXB7-C6sCohDW.js → kanban-definition-3W4ZIXB7-Dkcl1vfA.js} +1 -1
  48. package/dist/client/assets/{layout-DbAdffkE.js → layout-CSSEtaEF.js} +1 -1
  49. package/dist/client/assets/{main-DfjP5I-Q.js → main-BzXVe5ia.js} +9 -9
  50. package/dist/client/assets/{mindmap-definition-VGOIOE7T-D4byQ-t_.js → mindmap-definition-VGOIOE7T-D17_XGFA.js} +1 -1
  51. package/dist/client/assets/{pieDiagram-ADFJNKIX-SdHTH4tD.js → pieDiagram-ADFJNKIX-D07iYAxA.js} +1 -1
  52. package/dist/client/assets/{quadrantDiagram-AYHSOK5B-CctaxdVX.js → quadrantDiagram-AYHSOK5B-B9imU2k-.js} +1 -1
  53. package/dist/client/assets/{requirementDiagram-UZGBJVZJ-BiuKR3TQ.js → requirementDiagram-UZGBJVZJ-CMH8dVSi.js} +1 -1
  54. package/dist/client/assets/{sankeyDiagram-TZEHDZUN-BTpPs36c.js → sankeyDiagram-TZEHDZUN-CWS08bde.js} +1 -1
  55. package/dist/client/assets/{sequenceDiagram-WL72ISMW-BRAorH_1.js → sequenceDiagram-WL72ISMW-BcDiQ1t6.js} +1 -1
  56. package/dist/client/assets/{stateDiagram-FKZM4ZOC-BtHKF925.js → stateDiagram-FKZM4ZOC-Be7DSpGK.js} +1 -1
  57. package/dist/client/assets/stateDiagram-v2-4FDKWEC3-CSGrJZGI.js +1 -0
  58. package/dist/client/assets/{timeline-definition-IT6M3QCI-BxQS_MT5.js → timeline-definition-IT6M3QCI-BwTGYKzr.js} +1 -1
  59. package/dist/client/assets/{treemap-GDKQZRPO-DdrDkT5H.js → treemap-GDKQZRPO-DDASk1M2.js} +1 -1
  60. package/dist/client/assets/{worktree._worktreeId-CVx6cyp5.js → worktree._worktreeId-C3DGXQD8.js} +1 -1
  61. package/dist/client/assets/{worktree._worktreeId-C2psBRXR.js → worktree._worktreeId-DsTjUoT9.js} +1 -1
  62. package/dist/client/assets/{xychartDiagram-PRI3JC2R-R2Q9xRsW.js → xychartDiagram-PRI3JC2R-CShK1tn5.js} +1 -1
  63. package/dist/openapi.json +16 -0
  64. package/dist/start-server.mjs +59 -4
  65. package/package.json +7 -7
  66. package/dist/client/assets/channel-CXnvJLnE.js +0 -1
  67. package/dist/client/assets/classDiagram-2ON5EDUG-Dp5-cWrq.js +0 -1
  68. package/dist/client/assets/classDiagram-v2-WZHVMYZB-Dp5-cWrq.js +0 -1
  69. package/dist/client/assets/clone-D5FdW0HP.js +0 -1
  70. package/dist/client/assets/stateDiagram-v2-4FDKWEC3-B40ZaZyn.js +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/angular-html-CU67Zn6k.js","assets/html-GMplVEZG.js","assets/javascript-wDzz0qaB.js","assets/css-DPfMkruS.js","assets/angular-ts-BwZT4LLn.js","assets/scss-OYdSNvt2.js","assets/apl-dKokRX4l.js","assets/xml-sdJ4AIDG.js","assets/java-CylS5w8V.js","assets/json-Cp-IABpG.js","assets/astro-CbQHKStN.js","assets/typescript-BPQ3VLAy.js","assets/postcss-CXtECtnM.js","assets/tsx-COt5Ahok.js","assets/blade-D4QpJJKB.js","assets/html-derivative-BFtXZ54Q.js","assets/sql-BLtJtn59.js","assets/bsl-BO_Y6i37.js","assets/sdbl-DVxCFoDh.js","assets/cairo-KRGpt6FW.js","assets/python-B6aJPvgy.js","assets/cobol-nwyudZeR.js","assets/coffee-Ch7k5sss.js","assets/cpp-CofmeUqb.js","assets/regexp-CDVJQ6XC.js","assets/glsl-DplSGwfg.js","assets/c-BIGW1oBm.js","assets/crystal-tKQVLTB8.js","assets/shellscript-Yzrsuije.js","assets/edge-BkV0erSs.js","assets/elixir-CDX3lj18.js","assets/elm-DbKCFpqz.js","assets/erb-B12qg9BL.js","assets/ruby-Dw2BHqvy.js","assets/haml-B8DHNrY2.js","assets/graphql-ChdNCCLP.js","assets/jsx-g9-lgVsj.js","assets/lua-BaeVxFsk.js","assets/yaml-Buea-lGh.js","assets/erlang-DsQrWhSR.js","assets/markdown-Cvjx9yec.js","assets/fortran-fixed-form-CkoXwp7k.js","assets/fortran-free-form-BxgE0vQu.js","assets/fsharp-CXgrBDvD.js","assets/gdresource-BOOCDP_w.js","assets/gdshader-DkwncUOv.js","assets/gdscript-C5YyOfLZ.js","assets/git-commit-F4YmCXRG.js","assets/diff-D97Zzqfu.js","assets/git-rebase-r7XF79zn.js","assets/glimmer-js-Rg0-pVw9.js","assets/glimmer-ts-U6CK756n.js","assets/hack-CaT9iCJl.js","assets/handlebars-BL8al0AC.js","assets/http-jrhK8wxY.js","assets/hurl-irOxFIW8.js","assets/csv-fuZLfV_i.js","assets/hxml-Bvhsp5Yf.js","assets/haxe-CzTSHFRz.js","assets/jinja-4LBKfQ-Z.js","assets/jison-wvAkD_A8.js","assets/julia-CxzCAyBv.js","assets/r-Dspwwk_N.js","assets/just-Cw27pwNe.js","assets/perl-C0TMdlhV.js","assets/latex-CWtU0Tv5.js","assets/tex-idrVyKtj.js","assets/liquid-DYVedYrR.js","assets/marko-CnJfTvn9.js","assets/less-B1dDrJ26.js","assets/mdc-BMNejdWA.js","assets/nextflow-Zz6hmt5N.js","assets/nextflow-groovy-BeH2EWoN.js","assets/nginx-BpAMiNFr.js","assets/nim-CVrawwO9.js","assets/php-Dhbhpdrm.js","assets/pug-CGlum2m_.js","assets/qml-3beO22l8.js","assets/razor-Uh8Bk_45.js","assets/csharp-COcwbKMJ.js","assets/rst-BrH8l1NY.js","assets/cmake-D1j8_8rp.js","assets/sas-cz2c8ADy.js","assets/shaderlab-Dg9Lc6iA.js","assets/hlsl-D3lLCCz7.js","assets/shellsession-BADoaaVG.js","assets/soy-Brmx7dQM.js","assets/sparql-rVzFXLq3.js","assets/turtle-BsS91CYL.js","assets/stata-BH5u7GGu.js","assets/surrealql-Bq5Q-fJD.js","assets/svelte-C_ipcX3V.js","assets/templ-P3uqSqPl.js","assets/go-CxLEBnE3.js","assets/ts-tags-zn1MmPIZ.js","assets/twig-DNn4PbVi.js","assets/vue-DN_0RTcg.js","assets/vue-html-AaS7Mt5G.js","assets/vue-vine-CQOfvN7w.js","assets/stylus-BEDo0Tqx.js","assets/xsl-CtQFsRM5.js","assets/dagre-6UL2VRFP-BV1RIA6i.js","assets/graph-wAJZ-snQ.js","assets/_baseUniq-DcG-qGfl.js","assets/layout-DbAdffkE.js","assets/_basePickBy-DCBI2ZYZ.js","assets/clone-D5FdW0HP.js","assets/cose-bilkent-S5V4N54A-CiQDuqKy.js","assets/cytoscape.esm-5J0xJHOV.js","assets/c4Diagram-YG6GDRKO-1o6lovC1.js","assets/chunk-TZMSLE5B-EGqxu3bA.js","assets/flowDiagram-NV44I4VS-vWTy8wO1.js","assets/chunk-FMBD7UC4-jlnPGz3-.js","assets/chunk-55IACEB6-DIOOkGXI.js","assets/chunk-QN33PNHL-BtZcZKWT.js","assets/channel-CXnvJLnE.js","assets/erDiagram-Q2GNP2WA-DnmU3JYj.js","assets/gitGraphDiagram-V2S2FVAM-D4Y2-pQd.js","assets/chunk-4BX2VUAB-pUhlexDl.js","assets/chunk-QZHKN3VN-CCXlh8PQ.js","assets/treemap-GDKQZRPO-DdrDkT5H.js","assets/infoDiagram-HS3SLOUP-CmZ04ZX2.js","assets/pieDiagram-ADFJNKIX-SdHTH4tD.js","assets/arc-Dtd3NOeG.js","assets/requirementDiagram-UZGBJVZJ-BiuKR3TQ.js","assets/sequenceDiagram-WL72ISMW-BRAorH_1.js","assets/classDiagram-2ON5EDUG-Dp5-cWrq.js","assets/chunk-B4BG7PRW-betJcaMy.js","assets/classDiagram-v2-WZHVMYZB-Dp5-cWrq.js","assets/stateDiagram-FKZM4ZOC-BtHKF925.js","assets/chunk-DI55MBZ5-Du6zLzqO.js","assets/stateDiagram-v2-4FDKWEC3-B40ZaZyn.js","assets/journeyDiagram-XKPGCS4Q-CyBTVa_6.js","assets/timeline-definition-IT6M3QCI-BxQS_MT5.js","assets/mindmap-definition-VGOIOE7T-D4byQ-t_.js","assets/kanban-definition-3W4ZIXB7-C6sCohDW.js","assets/diagram-S2PKOQOG-sjeU7pbV.js","assets/diagram-QEK2KX5R-BvBvt_5J.js","assets/blockDiagram-VD42YOAC-BLg8A5DO.js","assets/architectureDiagram-VXUJARFQ-_4wJCo66.js","assets/diagram-PSM6KHXK-oZBpmBZ4.js","assets/xterm-AZ511Krh.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/angular-html-CU67Zn6k.js","assets/html-GMplVEZG.js","assets/javascript-wDzz0qaB.js","assets/css-DPfMkruS.js","assets/angular-ts-BwZT4LLn.js","assets/scss-OYdSNvt2.js","assets/apl-dKokRX4l.js","assets/xml-sdJ4AIDG.js","assets/java-CylS5w8V.js","assets/json-Cp-IABpG.js","assets/astro-CbQHKStN.js","assets/typescript-BPQ3VLAy.js","assets/postcss-CXtECtnM.js","assets/tsx-COt5Ahok.js","assets/blade-D4QpJJKB.js","assets/html-derivative-BFtXZ54Q.js","assets/sql-BLtJtn59.js","assets/bsl-BO_Y6i37.js","assets/sdbl-DVxCFoDh.js","assets/cairo-KRGpt6FW.js","assets/python-B6aJPvgy.js","assets/cobol-nwyudZeR.js","assets/coffee-Ch7k5sss.js","assets/cpp-CofmeUqb.js","assets/regexp-CDVJQ6XC.js","assets/glsl-DplSGwfg.js","assets/c-BIGW1oBm.js","assets/crystal-tKQVLTB8.js","assets/shellscript-Yzrsuije.js","assets/edge-BkV0erSs.js","assets/elixir-CDX3lj18.js","assets/elm-DbKCFpqz.js","assets/erb-B12qg9BL.js","assets/ruby-Dw2BHqvy.js","assets/haml-B8DHNrY2.js","assets/graphql-ChdNCCLP.js","assets/jsx-g9-lgVsj.js","assets/lua-BaeVxFsk.js","assets/yaml-Buea-lGh.js","assets/erlang-DsQrWhSR.js","assets/markdown-Cvjx9yec.js","assets/fortran-fixed-form-CkoXwp7k.js","assets/fortran-free-form-BxgE0vQu.js","assets/fsharp-CXgrBDvD.js","assets/gdresource-BOOCDP_w.js","assets/gdshader-DkwncUOv.js","assets/gdscript-C5YyOfLZ.js","assets/git-commit-F4YmCXRG.js","assets/diff-D97Zzqfu.js","assets/git-rebase-r7XF79zn.js","assets/glimmer-js-Rg0-pVw9.js","assets/glimmer-ts-U6CK756n.js","assets/hack-CaT9iCJl.js","assets/handlebars-BL8al0AC.js","assets/http-jrhK8wxY.js","assets/hurl-irOxFIW8.js","assets/csv-fuZLfV_i.js","assets/hxml-Bvhsp5Yf.js","assets/haxe-CzTSHFRz.js","assets/jinja-4LBKfQ-Z.js","assets/jison-wvAkD_A8.js","assets/julia-CxzCAyBv.js","assets/r-Dspwwk_N.js","assets/just-Cw27pwNe.js","assets/perl-C0TMdlhV.js","assets/latex-CWtU0Tv5.js","assets/tex-idrVyKtj.js","assets/liquid-DYVedYrR.js","assets/marko-CnJfTvn9.js","assets/less-B1dDrJ26.js","assets/mdc-BMNejdWA.js","assets/nextflow-Zz6hmt5N.js","assets/nextflow-groovy-BeH2EWoN.js","assets/nginx-BpAMiNFr.js","assets/nim-CVrawwO9.js","assets/php-Dhbhpdrm.js","assets/pug-CGlum2m_.js","assets/qml-3beO22l8.js","assets/razor-Uh8Bk_45.js","assets/csharp-COcwbKMJ.js","assets/rst-BrH8l1NY.js","assets/cmake-D1j8_8rp.js","assets/sas-cz2c8ADy.js","assets/shaderlab-Dg9Lc6iA.js","assets/hlsl-D3lLCCz7.js","assets/shellsession-BADoaaVG.js","assets/soy-Brmx7dQM.js","assets/sparql-rVzFXLq3.js","assets/turtle-BsS91CYL.js","assets/stata-BH5u7GGu.js","assets/surrealql-Bq5Q-fJD.js","assets/svelte-C_ipcX3V.js","assets/templ-P3uqSqPl.js","assets/go-CxLEBnE3.js","assets/ts-tags-zn1MmPIZ.js","assets/twig-DNn4PbVi.js","assets/vue-DN_0RTcg.js","assets/vue-html-AaS7Mt5G.js","assets/vue-vine-CQOfvN7w.js","assets/stylus-BEDo0Tqx.js","assets/xsl-CtQFsRM5.js","assets/dagre-6UL2VRFP-CIdLKDDa.js","assets/graph-v9lPIGDx.js","assets/_baseUniq-C8iGnWYN.js","assets/layout-CSSEtaEF.js","assets/_basePickBy-Df9AWPQJ.js","assets/clone-Dr7z_3vQ.js","assets/cose-bilkent-S5V4N54A-C7S-iRjs.js","assets/cytoscape.esm-5J0xJHOV.js","assets/c4Diagram-YG6GDRKO-Ce9RV_Np.js","assets/chunk-TZMSLE5B-BP9v1VXR.js","assets/flowDiagram-NV44I4VS-BzbJhnQR.js","assets/chunk-FMBD7UC4-DC8dY12t.js","assets/chunk-55IACEB6-CeH02gXd.js","assets/chunk-QN33PNHL-D1Af7sn_.js","assets/channel-BQWEKiCC.js","assets/erDiagram-Q2GNP2WA-DuReqla0.js","assets/gitGraphDiagram-V2S2FVAM-7rU4MgM6.js","assets/chunk-4BX2VUAB-Ck1qaTAA.js","assets/chunk-QZHKN3VN-BHBPr8iM.js","assets/treemap-GDKQZRPO-DDASk1M2.js","assets/infoDiagram-HS3SLOUP-BOjyAfYW.js","assets/pieDiagram-ADFJNKIX-D07iYAxA.js","assets/arc-Dotr_YMW.js","assets/requirementDiagram-UZGBJVZJ-CMH8dVSi.js","assets/sequenceDiagram-WL72ISMW-BcDiQ1t6.js","assets/classDiagram-2ON5EDUG-Bkz5oJ-y.js","assets/chunk-B4BG7PRW-DqBzx79X.js","assets/classDiagram-v2-WZHVMYZB-Bkz5oJ-y.js","assets/stateDiagram-FKZM4ZOC-Be7DSpGK.js","assets/chunk-DI55MBZ5-p68JZT5Z.js","assets/stateDiagram-v2-4FDKWEC3-CSGrJZGI.js","assets/journeyDiagram-XKPGCS4Q-daUwYLfO.js","assets/timeline-definition-IT6M3QCI-BwTGYKzr.js","assets/mindmap-definition-VGOIOE7T-D17_XGFA.js","assets/kanban-definition-3W4ZIXB7-Dkcl1vfA.js","assets/diagram-S2PKOQOG-CU2nF5Pi.js","assets/diagram-QEK2KX5R-ByPoixdO.js","assets/blockDiagram-VD42YOAC-DZYGOHoq.js","assets/architectureDiagram-VXUJARFQ-BkG8VmpL.js","assets/diagram-PSM6KHXK-_VfU4I5J.js","assets/xterm-AZ511Krh.css"])))=>i.map(i=>d[i]);
2
2
  function oXe(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const o in r)if(o!=="default"&&!(o in t)){const i=Object.getOwnPropertyDescriptor(r,o);i&&Object.defineProperty(t,o,i.get?i:{enumerable:!0,get:()=>r[o]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var hse=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Y0(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function bJn(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var n=function r(){var o=!1;try{o=this instanceof r}catch{}return o?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var o=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,o.get?o:{enumerable:!0,get:function(){return t[r]}})}),n}var cI={exports:{}},b7={};var pse;function iXe(){if(pse)return b7;pse=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,o,i){var s=null;if(i!==void 0&&(s=""+i),o.key!==void 0&&(s=""+o.key),"key"in o){i={};for(var a in o)a!=="key"&&(i[a]=o[a])}else i=o;return o=i.ref,{$$typeof:t,type:r,key:s,ref:o!==void 0?o:null,props:i}}return b7.Fragment=e,b7.jsx=n,b7.jsxs=n,b7}var mse;function sXe(){return mse||(mse=1,cI.exports=iXe()),cI.exports}var f=sXe(),Lo=(t=>(t[t.None=0]="None",t[t.Mutable=1]="Mutable",t[t.Watching=2]="Watching",t[t.RecursedCheck=4]="RecursedCheck",t[t.Recursed=8]="Recursed",t[t.Dirty=16]="Dirty",t[t.Pending=32]="Pending",t))(Lo||{});function T8e({update:t,notify:e,unwatched:n}){return{link:r,unlink:o,propagate:i,checkDirty:s,shallowPropagate:a};function r(c,u,d){const h=u.depsTail;if(h!==void 0&&h.dep===c)return;const p=h!==void 0?h.nextDep:u.deps;if(p!==void 0&&p.dep===c){p.version=d,u.depsTail=p;return}const g=c.subsTail;if(g!==void 0&&g.version===d&&g.sub===u)return;const _=u.depsTail=c.subsTail={version:d,dep:c,sub:u,prevDep:h,nextDep:p,prevSub:g,nextSub:void 0};p!==void 0&&(p.prevDep=_),h!==void 0?h.nextDep=_:u.deps=_,g!==void 0?g.nextSub=_:c.subs=_}function o(c,u=c.sub){const d=c.dep,h=c.prevDep,p=c.nextDep,g=c.nextSub,_=c.prevSub;return p!==void 0?p.prevDep=h:u.depsTail=h,h!==void 0?h.nextDep=p:u.deps=p,g!==void 0?g.prevSub=_:d.subsTail=_,_!==void 0?_.nextSub=g:(d.subs=g)===void 0&&n(d),p}function i(c){let u=c.nextSub,d;e:do{const h=c.sub;let p=h.flags;if(p&60?p&12?p&4?!(p&48)&&l(c,h)?(h.flags=p|40,p&=1):p=0:h.flags=p&-9|32:p=0:h.flags=p|32,p&2&&e(h),p&1){const g=h.subs;if(g!==void 0){const _=(c=g).nextSub;_!==void 0&&(d={value:u,prev:d},u=_);continue}}if((c=u)!==void 0){u=c.nextSub;continue}for(;d!==void 0;)if(c=d.value,d=d.prev,c!==void 0){u=c.nextSub;continue e}break}while(!0)}function s(c,u){let d,h=0,p=!1;e:do{const g=c.dep,_=g.flags;if(u.flags&16)p=!0;else if((_&17)===17){if(t(g)){const x=g.subs;x.nextSub!==void 0&&a(x),p=!0}}else if((_&33)===33){(c.nextSub!==void 0||c.prevSub!==void 0)&&(d={value:c,prev:d}),c=g.deps,u=g,++h;continue}if(!p){const x=c.nextDep;if(x!==void 0){c=x;continue}}for(;h--;){const x=u.subs,y=x.nextSub!==void 0;if(y?(c=d.value,d=d.prev):c=x,p){if(t(u)){y&&a(x),u=c.sub;continue}p=!1}else u.flags&=-33;u=c.sub;const k=c.nextDep;if(k!==void 0){c=k;continue e}}return p}while(!0)}function a(c){do{const u=c.sub,d=u.flags;(d&48)===32&&(u.flags=d|16,(d&6)===2&&e(u))}while((c=c.nextSub)!==void 0)}function l(c,u){let d=u.depsTail;for(;d!==void 0;){if(d===c)return!0;d=d.prevDep}return!1}}let WW=0,hp=0,s9=0;const v2=[],{link:_Jn,unlink:M8e,propagate:xJn,checkDirty:aXe,shallowPropagate:yJn}=T8e({update(t){return t.depsTail!==void 0?dXe(t):fXe(t)},notify(t){let e=s9,n=e;do if(v2[e++]=t,t.flags&=-3,t=t.subs?.sub,t===void 0||!(t.flags&2))break;while(!0);for(s9=e;n<--e;){const r=v2[n];v2[n++]=v2[e],v2[e]=r}},unwatched(t){t.flags&1?t.depsTail!==void 0&&(t.depsTail=void 0,t.flags=17,eM(t)):mXe.call(t)}});function lXe(){return WW}function cXe(){++WW}function uXe(){--WW||pXe()}function dXe(t){t.depsTail=void 0,t.flags=5;try{const e=t.value;return e!==(t.value=t.getter(e))}finally{t.flags&=-5,eM(t)}}function fXe(t){return t.flags=1,t.currentValue!==(t.currentValue=t.pendingValue)}function hXe(t){const e=t.flags;if(e&16||e&32&&aXe(t.deps,t)){t.depsTail=void 0,t.flags=6;try{t.fn()}finally{t.flags&=-5,eM(t)}}else t.flags=2}function pXe(){try{for(;hp<s9;){const t=v2[hp];v2[hp++]=void 0,hXe(t)}}finally{for(;hp<s9;){const t=v2[hp];v2[hp++]=void 0,t.flags|=10}hp=0,s9=0}}function mXe(){this.depsTail=void 0,this.flags=0,eM(this);const t=this.subs;t!==void 0&&M8e(t)}function eM(t){const e=t.depsTail;let n=e!==void 0?e.nextDep:t.deps;for(;n!==void 0;)n=M8e(n,t)}function ZW(t,e,n){const r=typeof t=="object",o=r?t:void 0;return{next:(r?t.next:t)?.bind(o),error:(r?t.error:e)?.bind(o),complete:(r?t.complete:n)?.bind(o)}}const $H=[];let qO=0;const{link:gse,unlink:gXe,propagate:vXe,checkDirty:P8e,shallowPropagate:vse}=T8e({update(t){return t._update()},notify(t){$H[BH++]=t,t.flags&=~Lo.Watching},unwatched(t){t.depsTail!==void 0&&(t.depsTail=void 0,t.flags=Lo.Mutable|Lo.Dirty,cC(t))}});let ww=0,BH=0,j1;function cC(t){const e=t.depsTail;let n=e!==void 0?e.nextDep:t.deps;for(;n!==void 0;)n=gXe(n,t)}function j8e(){if(!(lXe()>0)){for(;ww<BH;){const t=$H[ww];$H[ww++]=void 0,t.notify()}ww=0,BH=0}}function N8e(t,e){const n=typeof t=="function",r=t,o={_snapshot:n?void 0:t,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:n?Lo.None:Lo.Mutable,get(){return j1!==void 0&&gse(o,j1,qO),o._snapshot},subscribe(i){const s=ZW(i),a={current:!1},l=bXe(()=>{o.get(),a.current?s.next?.(o._snapshot):a.current=!0});return{unsubscribe:()=>{l.stop()}}},_update(i){const s=j1,a=Object.is;j1=o,++qO,o.depsTail=void 0,n&&(o.flags=Lo.Mutable|Lo.RecursedCheck);try{const l=o._snapshot,c=typeof i=="function"?i(l):i===void 0&&n?r(l):i;return l===void 0||!a(l,c)?(o._snapshot=c,!0):!1}finally{j1=s,n&&(o.flags&=~Lo.RecursedCheck),cC(o)}}};return n?(o.flags=Lo.Mutable|Lo.Dirty,o.get=function(){const i=o.flags;if(i&Lo.Dirty||i&Lo.Pending&&P8e(o.deps,o)){if(o._update()){const s=o.subs;s!==void 0&&vse(s)}}else i&Lo.Pending&&(o.flags=i&~Lo.Pending);return j1!==void 0&&gse(o,j1,qO),o._snapshot}):o.set=function(i){if(o._update(i)){const s=o.subs;s!==void 0&&(vXe(s),vse(s),j8e())}},o}function bXe(t){const e=()=>{const r=j1;j1=n,++qO,n.depsTail=void 0,n.flags=Lo.Watching|Lo.RecursedCheck;try{return t()}finally{j1=r,n.flags&=~Lo.RecursedCheck,cC(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:Lo.Watching|Lo.RecursedCheck,notify(){const r=this.flags;r&Lo.Dirty||r&Lo.Pending&&P8e(this.deps,this)?e():this.flags=Lo.Watching},stop(){this.flags=Lo.None,this.depsTail=void 0,cC(this)}};return e(),n}class _Xe{constructor(e){this.atom=N8e(e)}setState(e){this.atom.set(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(ZW(e))}}class xXe{constructor(e){this.atom=N8e(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(ZW(e))}}function yXe(t){return typeof t=="function"?new xXe(t):new _Xe(t)}function wXe(t){try{cXe(),t()}finally{uXe(),j8e()}}const Bf="__TSR_index",bse="popstate",_se="beforeunload";function kXe(t){let e=t.getLocation();const n=new Set,r=s=>{e=t.getLocation(),n.forEach(a=>a({location:e,action:s}))},o=s=>{t.notifyOnIndexChange??!0?r(s):e=t.getLocation()},i=async({task:s,navigateOpts:a,...l})=>{if(a?.ignoreBlocker??!1){s();return}const u=t.getBlockers?.()??[],d=l.type==="PUSH"||l.type==="REPLACE";if(typeof document<"u"&&u.length&&d)for(const h of u){const p=uC(l.path,l.state);if(await h.blockerFn({currentLocation:e,nextLocation:p,action:l.type})){t.onBlocked?.();return}}s()};return{get location(){return e},get length(){return t.getLength()},subscribers:n,subscribe:s=>(n.add(s),()=>{n.delete(s)}),push:(s,a,l)=>{const c=e.state[Bf];a=xse(c+1,a),i({task:()=>{t.pushState(s,a),r({type:"PUSH"})},navigateOpts:l,type:"PUSH",path:s,state:a})},replace:(s,a,l)=>{const c=e.state[Bf];a=xse(c,a),i({task:()=>{t.replaceState(s,a),r({type:"REPLACE"})},navigateOpts:l,type:"REPLACE",path:s,state:a})},go:(s,a)=>{i({task:()=>{t.go(s),o({type:"GO",index:s})},navigateOpts:a,type:"GO"})},back:s=>{i({task:()=>{t.back(s?.ignoreBlocker??!1),o({type:"BACK"})},navigateOpts:s,type:"BACK"})},forward:s=>{i({task:()=>{t.forward(s?.ignoreBlocker??!1),o({type:"FORWARD"})},navigateOpts:s,type:"FORWARD"})},canGoBack:()=>e.state[Bf]!==0,createHref:s=>t.createHref(s),block:s=>{if(!t.setBlockers)return()=>{};const a=t.getBlockers?.()??[];return t.setBlockers([...a,s]),()=>{const l=t.getBlockers?.()??[];t.setBlockers?.(l.filter(c=>c!==s))}},flush:()=>t.flush?.(),destroy:()=>t.destroy?.(),notify:r}}function xse(t,e){e||(e={});const n=GW();return{...e,key:n,__TSR_key:n,[Bf]:t}}function OXe(t){const e=typeof document<"u"?window:void 0,n=e.history.pushState,r=e.history.replaceState;let o=[];const i=()=>o,s=P=>o=P,a=(P=>P),l=(()=>uC(`${e.location.pathname}${e.location.search}${e.location.hash}`,e.history.state));if(!e.history.state?.__TSR_key&&!e.history.state?.key){const P=GW();e.history.replaceState({[Bf]:0,key:P,__TSR_key:P},"")}let c=l(),u,d=!1,h=!1,p=!1,g=!1;const _=()=>c;let x,y;const k=()=>{x&&(M._ignoreSubscribers=!0,(x.isPush?e.history.pushState:e.history.replaceState)(x.state,"",x.href),M._ignoreSubscribers=!1,x=void 0,y=void 0,u=void 0)},O=(P,L,D)=>{const I=a(L);y||(u=c),c=uC(L,D),x={href:I,state:D,isPush:x?.isPush||P==="push"},y||(y=Promise.resolve().then(()=>k()))},C=P=>{c=l(),M.notify({type:P})},A=async()=>{if(h){h=!1;return}const P=l(),L=P.state[Bf]-c.state[Bf],D=L===1,I=L===-1,z=!D&&!I||d;d=!1;const Y=z?"GO":I?"BACK":"FORWARD",Q=z?{type:"GO",index:L}:{type:I?"BACK":"FORWARD"};if(p)p=!1;else{const H=i();if(typeof document<"u"&&H.length){for(const N of H)if(await N.blockerFn({currentLocation:c,nextLocation:P,action:Y})){h=!0,e.history.go(1),M.notify(Q);return}}}c=l(),M.notify(Q)},E=P=>{if(g){g=!1;return}let L=!1;const D=i();if(typeof document<"u"&&D.length)for(const I of D){const z=I.enableBeforeUnload??!0;if(z===!0){L=!0;break}if(typeof z=="function"&&z()===!0){L=!0;break}}if(L)return P.preventDefault(),P.returnValue=""},M=kXe({getLocation:_,getLength:()=>e.history.length,pushState:(P,L)=>O("push",P,L),replaceState:(P,L)=>O("replace",P,L),back:P=>(P&&(p=!0),g=!0,e.history.back()),forward:P=>{P&&(p=!0),g=!0,e.history.forward()},go:P=>{d=!0,e.history.go(P)},createHref:P=>a(P),flush:k,destroy:()=>{e.history.pushState=n,e.history.replaceState=r,e.removeEventListener(_se,E,{capture:!0}),e.removeEventListener(bse,A)},onBlocked:()=>{u&&c!==u&&(c=u)},getBlockers:i,setBlockers:s,notifyOnIndexChange:!1});return e.addEventListener(_se,E,{capture:!0}),e.addEventListener(bse,A),e.history.pushState=function(...P){const L=n.apply(e.history,P);return M._ignoreSubscribers||C("PUSH"),L},e.history.replaceState=function(...P){const L=r.apply(e.history,P);return M._ignoreSubscribers||C("REPLACE"),L},M}function SXe(t){let e=t.replace(/[\x00-\x1f\x7f]/g,"");return e.startsWith("//")&&(e="/"+e.replace(/^\/+/,"")),e}function uC(t,e){const n=SXe(t),r=n.indexOf("#"),o=n.indexOf("?"),i=GW();return{href:n,pathname:n.substring(0,r>0?o>0?Math.min(r,o):r:o>0?o:n.length),hash:r>-1?n.substring(r):"",search:o>-1?n.slice(o,r===-1?void 0:r):"",state:e||{[Bf]:0,key:i,__TSR_key:i}}}function GW(){return(Math.random()+1).toString(36).substring(7)}const CXe=!1;function F5(t){let e;return wXe(()=>{e=t()}),e}function sb(t){return t[t.length-1]}function AXe(t){return typeof t=="function"}function Mf(t,e){return AXe(t)?t(e):t}const EXe=Object.prototype.hasOwnProperty,yse=Object.prototype.propertyIsEnumerable;function Hl(t,e,n=0){if(t===e)return t;if(n>500)return e;const r=e,o=Ose(t)&&Ose(r);if(!o&&!(dC(t)&&dC(r)))return r;const i=o?t:wse(t);if(!i)return r;const s=o?r:wse(r);if(!s)return r;const a=i.length,l=s.length,c=o?new Array(l):{};let u=0;for(let d=0;d<l;d++){const h=o?d:s[d],p=t[h],g=r[h];if(p===g){c[h]=p,(o?d<a:EXe.call(t,h))&&u++;continue}if(p===null||g===null||typeof p!="object"||typeof g!="object"){c[h]=g;continue}const _=Hl(p,g,n+1);c[h]=_,_===p&&u++}return a===l&&u===a?t:c}function wse(t){const e=Object.getOwnPropertyNames(t);for(const o of e)if(!yse.call(t,o))return!1;const n=Object.getOwnPropertySymbols(t);if(n.length===0)return e;const r=e;for(const o of n){if(!yse.call(t,o))return!1;r.push(o)}return r}function dC(t){if(!kse(t))return!1;const e=t.constructor;if(typeof e>"u")return!0;const n=e.prototype;return!(!kse(n)||!n.hasOwnProperty("isPrototypeOf"))}function kse(t){return Object.prototype.toString.call(t)==="[object Object]"}function Ose(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function p3(t,e,n){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(let r=0,o=t.length;r<o;r++)if(!p3(t[r],e[r],n))return!1;return!0}if(dC(t)&&dC(e)){const r=n?.ignoreUndefined??!0;if(n?.partial){for(const s in e)if((!r||e[s]!==void 0)&&!p3(t[s],e[s],n))return!1;return!0}let o=0;if(!r)o=Object.keys(t).length;else for(const s in t)t[s]!==void 0&&o++;let i=0;for(const s in e)if((!r||e[s]!==void 0)&&(i++,i>o||!p3(t[s],e[s],n)))return!1;return o===i}return!1}function C3(t){let e,n;const r=new Promise((o,i)=>{e=o,n=i});return r.status="pending",r.resolve=o=>{r.status="resolved",r.value=o,e(o),t?.(o)},r.reject=o=>{r.status="rejected",n(o)},r}function TXe(t){return typeof t?.message!="string"?!1:t.message.startsWith("Failed to fetch dynamically imported module")||t.message.startsWith("error loading dynamically imported module")||t.message.startsWith("Importing a module script failed")}function ab(t){return!!(t&&typeof t=="object"&&typeof t.then=="function")}function MXe(t){return t.replace(/[\x00-\x1f\x7f]/g,"")}function Sse(t){let e;try{e=decodeURI(t)}catch{e=t.replaceAll(/%[0-9A-F]{2}/gi,n=>{try{return decodeURI(n)}catch{return n}})}return MXe(e)}const PXe=["http:","https:","mailto:","tel:"];function fC(t,e){if(!t)return!1;try{const n=new URL(t);return!e.has(n.protocol)}catch{return!1}}const jXe={"&":"\\u0026",">":"\\u003e","<":"\\u003c","\u2028":"\\u2028","\u2029":"\\u2029"},NXe=/[&><\u2028\u2029]/g;function RXe(t){return t.replace(NXe,e=>jXe[e])}function _7(t){if(!t)return{path:t,handledProtocolRelativeURL:!1};if(!/[%\\\x00-\x1f\x7f]/.test(t)&&!t.startsWith("//"))return{path:t,handledProtocolRelativeURL:!1};const e=/%25|%5C/gi;let n=0,r="",o;for(;(o=e.exec(t))!==null;)r+=Sse(t.slice(n,o.index))+o[0],n=e.lastIndex;r=r+Sse(n?t.slice(n):t);let i=!1;return r.startsWith("//")&&(i=!0,r="/"+r.replace(/^\/+/,"")),{path:r,handledProtocolRelativeURL:i}}function LXe(t){return/\s|[^\u0000-\u007F]/.test(t)?t.replace(/\s|[^\u0000-\u007F]/gu,encodeURIComponent):t}var IXe="Invariant failed";function Xl(t,e){if(!t)throw new Error(IXe)}function hC(t){const e=new Map;let n,r;const o=i=>{i.next&&(i.prev?(i.prev.next=i.next,i.next.prev=i.prev,i.next=void 0,r&&(r.next=i,i.prev=r)):(i.next.prev=void 0,n=i.next,i.next=void 0,r&&(i.prev=r,r.next=i)),r=i)};return{get(i){const s=e.get(i);if(s)return o(s),s.value},set(i,s){if(e.size>=t&&n){const l=n;e.delete(l.key),l.next&&(n=l.next,l.next.prev=void 0),l===r&&(r=void 0)}const a=e.get(i);if(a)a.value=s,o(a);else{const l={key:i,value:s,prev:r};r&&(r.next=l),r=l,n||(n=l),e.set(i,l)}},clear(){e.clear(),n=void 0,r=void 0}}}const j6=0,A3=1,E3=2,lb=3,Wp=4,R8e=5;function DXe(t){const e=t.indexOf("{");if(e===-1)return null;const n=t.indexOf("}",e);return n===-1||e+1>=t.length?null:[e,n]}function YW(t,e,n=new Uint16Array(6)){const r=t.indexOf("/",e),o=r===-1?t.length:r,i=t.substring(e,o);if(!i||!i.includes("$"))return n[0]=j6,n[1]=e,n[2]=e,n[3]=o,n[4]=o,n[5]=o,n;if(i==="$"){const a=t.length;return n[0]=E3,n[1]=e,n[2]=e,n[3]=a,n[4]=a,n[5]=a,n}if(i.charCodeAt(0)===36)return n[0]=A3,n[1]=e,n[2]=e+1,n[3]=o,n[4]=o,n[5]=o,n;const s=DXe(i);if(s){const[a,l]=s,c=i.charCodeAt(a+1);if(c===45){if(a+2<i.length&&i.charCodeAt(a+2)===36){const u=a+3,d=l;if(u<d)return n[0]=lb,n[1]=e+a,n[2]=e+u,n[3]=e+d,n[4]=e+l+1,n[5]=o,n}}else if(c===36){const u=a+1,d=a+2;return d===l?(n[0]=E3,n[1]=e+a,n[2]=e+u,n[3]=e+d,n[4]=e+l+1,n[5]=t.length,n):(n[0]=A3,n[1]=e+a,n[2]=e+d,n[3]=e+l,n[4]=e+l+1,n[5]=o,n)}}return n[0]=j6,n[1]=e,n[2]=e,n[3]=o,n[4]=o,n[5]=o,n}function tM(t,e,n,r,o,i,s){s?.(n);let a=r;{const l=n.fullPath??n.from,c=l.length,u=n.options?.caseSensitive??t,d=!!(n.options?.params?.parse&&n.options?.skipRouteOnParseError?.params);for(;a<c;){const p=YW(l,a,e);let g;const _=a,x=p[5];switch(a=x+1,i++,p[0]){case j6:{const k=l.substring(p[2],p[3]);if(u){const O=o.static?.get(k);if(O)g=O;else{o.static??=new Map;const C=Zp(n.fullPath??n.from);C.parent=o,C.depth=i,g=C,o.static.set(k,C)}}else{const O=k.toLowerCase(),C=o.staticInsensitive?.get(O);if(C)g=C;else{o.staticInsensitive??=new Map;const A=Zp(n.fullPath??n.from);A.parent=o,A.depth=i,g=A,o.staticInsensitive.set(O,A)}}break}case A3:{const k=l.substring(_,p[1]),O=l.substring(p[4],x),C=u&&!!(k||O),A=k?C?k:k.toLowerCase():void 0,E=O?C?O:O.toLowerCase():void 0,M=!d&&o.dynamic?.find(P=>!P.skipOnParamError&&P.caseSensitive===C&&P.prefix===A&&P.suffix===E);if(M)g=M;else{const P=dI(A3,n.fullPath??n.from,C,A,E);g=P,P.depth=i,P.parent=o,o.dynamic??=[],o.dynamic.push(P)}break}case lb:{const k=l.substring(_,p[1]),O=l.substring(p[4],x),C=u&&!!(k||O),A=k?C?k:k.toLowerCase():void 0,E=O?C?O:O.toLowerCase():void 0,M=!d&&o.optional?.find(P=>!P.skipOnParamError&&P.caseSensitive===C&&P.prefix===A&&P.suffix===E);if(M)g=M;else{const P=dI(lb,n.fullPath??n.from,C,A,E);g=P,P.parent=o,P.depth=i,o.optional??=[],o.optional.push(P)}break}case E3:{const k=l.substring(_,p[1]),O=l.substring(p[4],x),C=u&&!!(k||O),A=k?C?k:k.toLowerCase():void 0,E=O?C?O:O.toLowerCase():void 0,M=dI(E3,n.fullPath??n.from,C,A,E);g=M,M.parent=o,M.depth=i,o.wildcard??=[],o.wildcard.push(M)}}o=g}if(d&&n.children&&!n.isRoot&&n.id&&n.id.charCodeAt(n.id.lastIndexOf("/")+1)===95){const p=Zp(n.fullPath??n.from);p.kind=R8e,p.parent=o,i++,p.depth=i,o.pathless??=[],o.pathless.push(p),o=p}const h=(n.path||!n.children)&&!n.isRoot;if(h&&l.endsWith("/")){const p=Zp(n.fullPath??n.from);p.kind=Wp,p.parent=o,i++,p.depth=i,o.index=p,o=p}o.parse=n.options?.params?.parse??null,o.skipOnParamError=d,o.parsingPriority=n.options?.skipRouteOnParseError?.priority??0,h&&!o.route&&(o.route=n,o.fullPath=n.fullPath??n.from)}if(n.children)for(const l of n.children)tM(t,e,l,a,o,i,s)}function uI(t,e){if(t.skipOnParamError&&!e.skipOnParamError)return-1;if(!t.skipOnParamError&&e.skipOnParamError)return 1;if(t.skipOnParamError&&e.skipOnParamError&&(t.parsingPriority||e.parsingPriority))return e.parsingPriority-t.parsingPriority;if(t.prefix&&e.prefix&&t.prefix!==e.prefix){if(t.prefix.startsWith(e.prefix))return-1;if(e.prefix.startsWith(t.prefix))return 1}if(t.suffix&&e.suffix&&t.suffix!==e.suffix){if(t.suffix.endsWith(e.suffix))return-1;if(e.suffix.endsWith(t.suffix))return 1}return t.prefix&&!e.prefix?-1:!t.prefix&&e.prefix?1:t.suffix&&!e.suffix?-1:!t.suffix&&e.suffix?1:t.caseSensitive&&!e.caseSensitive?-1:!t.caseSensitive&&e.caseSensitive?1:0}function mf(t){if(t.pathless)for(const e of t.pathless)mf(e);if(t.static)for(const e of t.static.values())mf(e);if(t.staticInsensitive)for(const e of t.staticInsensitive.values())mf(e);if(t.dynamic?.length){t.dynamic.sort(uI);for(const e of t.dynamic)mf(e)}if(t.optional?.length){t.optional.sort(uI);for(const e of t.optional)mf(e)}if(t.wildcard?.length){t.wildcard.sort(uI);for(const e of t.wildcard)mf(e)}}function Zp(t){return{kind:j6,depth:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:t,parent:null,parse:null,skipOnParamError:!1,parsingPriority:0}}function dI(t,e,n,r,o){return{kind:t,depth:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:e,parent:null,parse:null,skipOnParamError:!1,parsingPriority:0,caseSensitive:n,prefix:r,suffix:o}}function zXe(t,e){const n=Zp("/"),r=new Uint16Array(6);for(const o of t)tM(!1,r,o,1,n,0);mf(n),e.masksTree=n,e.flatCache=hC(1e3)}function $Xe(t,e){t||="/";const n=e.flatCache.get(t);if(n)return n;const r=XW(t,e.masksTree);return e.flatCache.set(t,r),r}function BXe(t,e,n,r,o){t||="/",r||="/";const i=e?`case\0${t}`:t;let s=o.singleCache.get(i);if(!s){s=Zp("/");const a=new Uint16Array(6);tM(e,a,{from:t},1,s,0),o.singleCache.set(i,s)}return XW(r,s,n)}function HXe(t,e,n=!1){const r=n?t:`nofuzz\0${t}`,o=e.matchCache.get(r);if(o!==void 0)return o;t||="/";let i;try{i=XW(t,e.segmentTree,n)}catch(s){if(s instanceof URIError)i=null;else throw s}return i&&(i.branch=VXe(i.route)),e.matchCache.set(r,i),i}function FXe(t){return t==="/"?t:t.replace(/\/{1,}$/,"")}function qXe(t,e=!1,n){const r=Zp(t.fullPath),o=new Uint16Array(6),i={},s={};let a=0;return tM(e,o,t,1,r,0,c=>{if(n?.(c,a),Xl(!(c.id in i),`Duplicate routes found with id: ${String(c.id)}`),i[c.id]=c,a!==0&&c.path){const u=FXe(c.fullPath);(!s[u]||c.fullPath.endsWith("/"))&&(s[u]=c)}a++}),mf(r),{processedTree:{segmentTree:r,singleCache:hC(1e3),matchCache:hC(1e3),flatCache:null,masksTree:null},routesById:i,routesByPath:s}}function XW(t,e,n=!1){const r=t.split("/"),o=UXe(t,r,e,n);if(!o)return null;const[i]=L8e(t,r,o);return{route:o.node.route,rawParams:i,parsedParams:o.parsedParams}}function L8e(t,e,n){const r=QXe(n.node);let o=null;const i={};let s=n.extract?.part??0,a=n.extract?.node??0,l=n.extract?.path??0,c=n.extract?.segment??0;for(;a<r.length;s++,a++,l++,c++){const u=r[a];if(u.kind===Wp)break;if(u.kind===R8e){c--,s--,l--;continue}const d=e[s],h=l;if(d&&(l+=d.length),u.kind===A3){o??=n.node.fullPath.split("/");const p=o[c],g=u.prefix?.length??0;if(p.charCodeAt(g)===123){const x=u.suffix?.length??0,y=p.substring(g+2,p.length-x-1),k=d.substring(g,d.length-x);i[y]=decodeURIComponent(k)}else{const x=p.substring(1);i[x]=decodeURIComponent(d)}}else if(u.kind===lb){if(n.skipped&1<<a){s--,l=h-1;continue}o??=n.node.fullPath.split("/");const p=o[c],g=u.prefix?.length??0,_=u.suffix?.length??0,x=p.substring(g+3,p.length-_-1),y=u.suffix||u.prefix?d.substring(g,d.length-_):d;y&&(i[x]=decodeURIComponent(y))}else if(u.kind===E3){const p=u,g=t.substring(h+(p.prefix?.length??0),t.length-(p.suffix?.length??0)),_=decodeURIComponent(g);i["*"]=_,i._splat=_;break}}return n.rawParams&&Object.assign(i,n.rawParams),[i,{part:s,node:a,path:l,segment:c}]}function VXe(t){const e=[t];for(;t.parentRoute;)t=t.parentRoute,e.push(t);return e.reverse(),e}function QXe(t){const e=Array(t.depth+1);do e[t.depth]=t,t=t.parent;while(t);return e}function UXe(t,e,n,r){if(t==="/"&&n.index)return{node:n.index,skipped:0};const o=!sb(e),i=o&&t!=="/",s=e.length-(o?1:0),a=[{node:n,index:1,skipped:0,depth:1,statics:1,dynamics:0,optionals:0}];let l=null,c=null,u=null;for(;a.length;){const d=a.pop(),{node:h,index:p,skipped:g,depth:_,statics:x,dynamics:y,optionals:k}=d;let{extract:O,rawParams:C,parsedParams:A}=d;if(h.skipOnParamError){if(!fI(t,e,d))continue;C=d.rawParams,O=d.extract,A=d.parsedParams}r&&h.route&&h.kind!==Wp&&x7(c,d)&&(c=d);const E=p===s;if(E&&(h.route&&!i&&x7(u,d)&&(u=d),!h.optional&&!h.wildcard&&!h.index&&!h.pathless))continue;const M=E?void 0:e[p];let P;if(E&&h.index){const L={node:h.index,index:p,skipped:g,depth:_+1,statics:x,dynamics:y,optionals:k,extract:O,rawParams:C,parsedParams:A};let D=!0;if(h.index.skipOnParamError&&(fI(t,e,L)||(D=!1)),D){if(x===s&&!y&&!k&&!g)return L;x7(u,L)&&(u=L)}}if(h.wildcard&&x7(l,d))for(const L of h.wildcard){const{prefix:D,suffix:I}=L;if(D&&(E||!(L.caseSensitive?M:P??=M.toLowerCase()).startsWith(D)))continue;if(I){if(E)continue;const Y=e.slice(p).join("/").slice(-I.length);if((L.caseSensitive?Y:Y.toLowerCase())!==I)continue}const z={node:L,index:s,skipped:g,depth:_,statics:x,dynamics:y,optionals:k,extract:O,rawParams:C,parsedParams:A};if(!(L.skipOnParamError&&!fI(t,e,z))){l=z;break}}if(h.optional){const L=g|1<<_,D=_+1;for(let I=h.optional.length-1;I>=0;I--){const z=h.optional[I];a.push({node:z,index:p,skipped:L,depth:D,statics:x,dynamics:y,optionals:k,extract:O,rawParams:C,parsedParams:A})}if(!E)for(let I=h.optional.length-1;I>=0;I--){const z=h.optional[I],{prefix:Y,suffix:Q}=z;if(Y||Q){const H=z.caseSensitive?M:P??=M.toLowerCase();if(Y&&!H.startsWith(Y)||Q&&!H.endsWith(Q))continue}a.push({node:z,index:p+1,skipped:g,depth:D,statics:x,dynamics:y,optionals:k+1,extract:O,rawParams:C,parsedParams:A})}}if(!E&&h.dynamic&&M)for(let L=h.dynamic.length-1;L>=0;L--){const D=h.dynamic[L],{prefix:I,suffix:z}=D;if(I||z){const Y=D.caseSensitive?M:P??=M.toLowerCase();if(I&&!Y.startsWith(I)||z&&!Y.endsWith(z))continue}a.push({node:D,index:p+1,skipped:g,depth:_+1,statics:x,dynamics:y+1,optionals:k,extract:O,rawParams:C,parsedParams:A})}if(!E&&h.staticInsensitive){const L=h.staticInsensitive.get(P??=M.toLowerCase());L&&a.push({node:L,index:p+1,skipped:g,depth:_+1,statics:x+1,dynamics:y,optionals:k,extract:O,rawParams:C,parsedParams:A})}if(!E&&h.static){const L=h.static.get(M);L&&a.push({node:L,index:p+1,skipped:g,depth:_+1,statics:x+1,dynamics:y,optionals:k,extract:O,rawParams:C,parsedParams:A})}if(h.pathless){const L=_+1;for(let D=h.pathless.length-1;D>=0;D--){const I=h.pathless[D];a.push({node:I,index:p,skipped:g,depth:L,statics:x,dynamics:y,optionals:k,extract:O,rawParams:C,parsedParams:A})}}}if(u&&l)return x7(l,u)?u:l;if(u)return u;if(l)return l;if(r&&c){let d=c.index;for(let p=0;p<c.index;p++)d+=e[p].length;const h=d===t.length?"/":t.slice(d);return c.rawParams??={},c.rawParams["**"]=decodeURIComponent(h),c}return null}function fI(t,e,n){try{const[r,o]=L8e(t,e,n);n.rawParams=r,n.extract=o;const i=n.node.parse(r);return n.parsedParams=Object.assign({},n.parsedParams,i),!0}catch{return null}}function x7(t,e){return t?e.statics>t.statics||e.statics===t.statics&&(e.dynamics>t.dynamics||e.dynamics===t.dynamics&&(e.optionals>t.optionals||e.optionals===t.optionals&&((e.node.kind===Wp)>(t.node.kind===Wp)||e.node.kind===Wp==(t.node.kind===Wp)&&e.depth>t.depth))):!0}function VO(t){return KW(t.filter(e=>e!==void 0).join("/"))}function KW(t){return t.replace(/\/{2,}/g,"/")}function I8e(t){return t==="/"?t:t.replace(/^\/{1,}/,"")}function Hf(t){const e=t.length;return e>1&&t[e-1]==="/"?t.replace(/\/{1,}$/,""):t}function D8e(t){return Hf(I8e(t))}function pC(t,e){return t?.endsWith("/")&&t!=="/"&&t!==`${e}/`?t.slice(0,-1):t}function WXe(t,e,n){return pC(t,n)===pC(e,n)}function ZXe({base:t,to:e,trailingSlash:n="never",cache:r}){const o=e.startsWith("/"),i=!o&&e===".";let s;if(r){s=o?e:i?t:t+"\0"+e;const d=r.get(s);if(d)return d}let a;if(i)a=t.split("/");else if(o)a=e.split("/");else{for(a=t.split("/");a.length>1&&sb(a)==="";)a.pop();const d=e.split("/");for(let h=0,p=d.length;h<p;h++){const g=d[h];g===""?h?h===p-1&&a.push(g):a=[g]:g===".."?a.pop():g==="."||a.push(g)}}a.length>1&&(sb(a)===""?n==="never"&&a.pop():n==="always"&&a.push(""));let l,c="";for(let d=0;d<a.length;d++){d>0&&(c+="/");const h=a[d];if(!h)continue;l=YW(h,0,l);const p=l[0];if(p===j6){c+=h;continue}const g=l[5],_=h.substring(0,l[1]),x=h.substring(l[4],g),y=h.substring(l[2],l[3]);p===A3?c+=_||x?`${_}{$${y}}${x}`:`$${y}`:p===E3?c+=_||x?`${_}{$}${x}`:"$":c+=`${_}{-$${y}}${x}`}c=KW(c);const u=c||"/";return s&&r&&r.set(s,u),u}function GXe(t){const e=new Map(t.map(o=>[encodeURIComponent(o),o])),n=Array.from(e.keys()).map(o=>o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),r=new RegExp(n,"g");return o=>o.replace(r,i=>e.get(i)??i)}function hI(t,e,n){const r=e[t];return typeof r!="string"?r:t==="_splat"?/^[a-zA-Z0-9\-._~!/]*$/.test(r)?r:r.split("/").map(o=>Ase(o,n)).join("/"):Ase(r,n)}function Cse({path:t,params:e,decoder:n,...r}){let o=!1;const i={};if(!t||t==="/")return{interpolatedPath:"/",usedParams:i,isMissingParams:o};if(!t.includes("$"))return{interpolatedPath:t,usedParams:i,isMissingParams:o};const s=t.length;let a=0,l,c="";for(;a<s;){const d=a;l=YW(t,d,l);const h=l[5];if(a=h+1,d===h)continue;const p=l[0];if(p===j6){c+="/"+t.substring(d,h);continue}if(p===E3){const g=e._splat;i._splat=g,i["*"]=g;const _=t.substring(d,l[1]),x=t.substring(l[4],h);if(!g){o=!0,(_||x)&&(c+="/"+_+x);continue}const y=hI("_splat",e,n);c+="/"+_+y+x;continue}if(p===A3){const g=t.substring(l[2],l[3]);!o&&!(g in e)&&(o=!0),i[g]=e[g];const _=t.substring(d,l[1]),x=t.substring(l[4],h),y=hI(g,e,n)??"undefined";c+="/"+_+y+x;continue}if(p===lb){const g=t.substring(l[2],l[3]),_=e[g];if(_==null)continue;i[g]=_;const x=t.substring(d,l[1]),y=t.substring(l[4],h),k=hI(g,e,n)??"";c+="/"+x+k+y;continue}}return t.endsWith("/")&&(c+="/"),{usedParams:i,interpolatedPath:c||"/",isMissingParams:o}}function Ase(t,e){const n=encodeURIComponent(t);return e?.(n)??n}function la(t){return!!t?.isNotFound}function YXe(){try{if(typeof window<"u"&&typeof window.sessionStorage=="object")return window.sessionStorage}catch{}}const HH="tsr-scroll-restoration-v1_3",XXe=(t,e)=>{let n;return(...r)=>{n||(n=setTimeout(()=>{t(...r),n=null},e))}};function KXe(){const t=YXe();if(!t)return null;const e=t.getItem(HH);let n=e?JSON.parse(e):{};return{state:n,set:r=>{n=Mf(r,n)||n;try{t.setItem(HH,JSON.stringify(n))}catch{console.warn("[ts-router] Could not persist scroll restoration state to sessionStorage.")}}}}const kw=KXe(),JXe=t=>t.state.__TSR_key||t.href;function eKe(t){const e=[];let n;for(;n=t.parentNode;)e.push(`${t.tagName}:nth-child(${Array.prototype.indexOf.call(n.children,t)+1})`),t=n;return`${e.reverse().join(" > ")}`.toLowerCase()}let mC=!1;function tKe({storageKey:t,key:e,behavior:n,shouldScrollRestoration:r,scrollToTopSelectors:o,location:i}){let s;try{s=JSON.parse(sessionStorage.getItem(t)||"{}")}catch(c){console.error(c);return}const a=e||window.history.state?.__TSR_key,l=s[a];mC=!0;e:{if(r&&l&&Object.keys(l).length>0){for(const d in l){const h=l[d];if(d==="window")window.scrollTo({top:h.scrollY,left:h.scrollX,behavior:n});else if(d){const p=document.querySelector(d);p&&(p.scrollLeft=h.scrollX,p.scrollTop=h.scrollY)}}break e}const c=(i??window.location).hash.split("#",2)[1];if(c){const d=window.history.state?.__hashScrollIntoViewOptions??!0;if(d){const h=document.getElementById(c);h&&h.scrollIntoView(d)}break e}const u={top:0,left:0,behavior:n};if(window.scrollTo(u),o)for(const d of o){if(d==="window")continue;const h=typeof d=="function"?d():document.querySelector(d);h&&h.scrollTo(u)}}mC=!1}function nKe(t,e){if(!kw||((t.options.scrollRestoration??!1)&&(t.isScrollRestoring=!0),t.isScrollRestorationSetup||!kw))return;t.isScrollRestorationSetup=!0,mC=!1;const r=t.options.getScrollRestorationKey||JXe;window.history.scrollRestoration="manual";const o=i=>{if(mC||!t.isScrollRestoring)return;let s="";if(i.target===document||i.target===window)s="window";else{const l=i.target.getAttribute("data-scroll-restoration-id");l?s=`[data-scroll-restoration-id="${l}"]`:s=eKe(i.target)}const a=r(t.state.location);kw.set(l=>{const c=l[a]||={},u=c[s]||={};if(s==="window")u.scrollX=window.scrollX||0,u.scrollY=window.scrollY||0;else if(s){const d=document.querySelector(s);d&&(u.scrollX=d.scrollLeft||0,u.scrollY=d.scrollTop||0)}return l})};typeof document<"u"&&document.addEventListener("scroll",XXe(o,100),!0),t.subscribe("onRendered",i=>{const s=r(i.toLocation);if(!t.resetNextScroll){t.resetNextScroll=!0;return}typeof t.options.scrollRestoration=="function"&&!t.options.scrollRestoration({location:t.latestLocation})||(tKe({storageKey:HH,key:s,behavior:t.options.scrollRestorationBehavior,shouldScrollRestoration:t.isScrollRestoring,scrollToTopSelectors:t.options.scrollToTopSelectors,location:t.history.location}),t.isScrollRestoring&&kw.set(a=>(a[s]||={},a)))})}function rKe(t){if(typeof document<"u"&&document.querySelector){const e=t.state.location.state.__hashScrollIntoViewOptions??!0;if(e&&t.state.location.hash!==""){const n=document.getElementById(t.state.location.hash);n&&n.scrollIntoView(e)}}}function z8e(t,e=String){const n=new URLSearchParams;for(const r in t){const o=t[r];o!==void 0&&n.set(r,e(o))}return n.toString()}function pI(t){return t?t==="false"?!1:t==="true"?!0:+t*0===0&&+t+""===t?+t:t:""}function oKe(t){const e=new URLSearchParams(t),n={};for(const[r,o]of e.entries()){const i=n[r];i==null?n[r]=pI(o):Array.isArray(i)?i.push(pI(o)):n[r]=[i,pI(o)]}return n}const iKe=aKe(JSON.parse),sKe=lKe(JSON.stringify,JSON.parse);function aKe(t){return e=>{e[0]==="?"&&(e=e.substring(1));const n=oKe(e);for(const r in n){const o=n[r];if(typeof o=="string")try{n[r]=t(o)}catch{}}return n}}function lKe(t,e){const n=typeof e=="function";function r(o){if(typeof o=="object"&&o!==null)try{return t(o)}catch{}else if(n&&typeof o=="string")try{return e(o),t(o)}catch{}return o}return o=>{const i=z8e(o,r);return i?`?${i}`:""}}const kc="__root__";function $8e(t){if(t.statusCode=t.statusCode||t.code||307,!t._builtLocation&&!t.reloadDocument&&typeof t.href=="string")try{new URL(t.href),t.reloadDocument=!0}catch{}const e=new Headers(t.headers);t.href&&e.get("Location")===null&&e.set("Location",t.href);const n=new Response(null,{status:t.statusCode,headers:e});if(n.options=t,t.throw)throw n;return n}function Zl(t){return t instanceof Response&&!!t.options}function cKe(t){if(t!==null&&typeof t=="object"&&t.isSerializedRedirect)return $8e(t)}const FH=t=>{if(!t.rendered)return t.rendered=!0,t.onReady?.()},nM=(t,e)=>!!(t.preload&&!t.router.state.matches.some(n=>n.id===e)),q5=(t,e,n=!0)=>{const r={...t.router.options.context??{}},o=n?e:e-1;for(let i=0;i<=o;i++){const s=t.matches[i];if(!s)continue;const a=t.router.getMatch(s.id);a&&Object.assign(r,a.__routeContext,a.__beforeLoadContext)}return r},Ese=(t,e)=>{if(!t.matches.length)return;const n=e.routeId,r=t.matches.findIndex(s=>s.routeId===t.router.routeTree.id),o=r>=0?r:0;let i=n?t.matches.findIndex(s=>s.routeId===n):t.firstBadMatchIndex??t.matches.length-1;i<0&&(i=o);for(let s=i;s>=0;s--){const a=t.matches[s];if(t.router.looseRoutesById[a.routeId].options.notFoundComponent)return s}return n?i:o},Pf=(t,e,n)=>{if(!(!Zl(n)&&!la(n)))throw Zl(n)&&n.redirectHandled&&!n.options.reloadDocument||(e&&(e._nonReactive.beforeLoadPromise?.resolve(),e._nonReactive.loaderPromise?.resolve(),e._nonReactive.beforeLoadPromise=void 0,e._nonReactive.loaderPromise=void 0,e._nonReactive.error=n,t.updateMatch(e.id,r=>({...r,status:Zl(n)?"redirected":r.status==="pending"?"success":r.status,context:q5(t,e.index),isFetching:!1,error:n})),la(n)&&!n.routeId&&(n.routeId=e.routeId),e._nonReactive.loadPromise?.resolve()),Zl(n)&&(t.rendered=!0,n.options._fromLocation=t.location,n.redirectHandled=!0,n=t.router.resolveRedirect(n))),n},B8e=(t,e)=>!!t.router.getMatch(e)._nonReactive.dehydrated,y7=(t,e,n,r)=>{const{id:o,routeId:i}=t.matches[e],s=t.router.looseRoutesById[i];if(n instanceof Promise)throw n;n.routerCode=r,t.firstBadMatchIndex??=e,Pf(t,t.router.getMatch(o),n);try{s.options.onError?.(n)}catch(a){n=a,Pf(t,t.router.getMatch(o),n)}t.updateMatch(o,a=>(a._nonReactive.beforeLoadPromise?.resolve(),a._nonReactive.beforeLoadPromise=void 0,a._nonReactive.loadPromise?.resolve(),{...a,error:n,status:"error",isFetching:!1,updatedAt:Date.now(),abortController:new AbortController})),!t.preload&&!Zl(n)&&!la(n)&&(t.serialError??=n)},H8e=(t,e,n,r)=>{if(r._nonReactive.pendingTimeout!==void 0)return;const o=n.options.pendingMs??t.router.options.defaultPendingMs;if(!!(t.onReady&&!nM(t,e)&&(n.options.loader||n.options.beforeLoad||q8e(n))&&typeof o=="number"&&o!==1/0&&(n.options.pendingComponent??t.router.options?.defaultPendingComponent))){const s=setTimeout(()=>{FH(t)},o);r._nonReactive.pendingTimeout=s}},uKe=(t,e,n)=>{const r=t.router.getMatch(e);if(!r._nonReactive.beforeLoadPromise&&!r._nonReactive.loaderPromise)return;H8e(t,e,n,r);const o=()=>{const i=t.router.getMatch(e);i.preload&&(i.status==="redirected"||i.status==="notFound")&&Pf(t,i,i.error)};return r._nonReactive.beforeLoadPromise?r._nonReactive.beforeLoadPromise.then(o):o()},dKe=(t,e,n,r)=>{const o=t.router.getMatch(e),i=o._nonReactive.loadPromise;o._nonReactive.loadPromise=C3(()=>{i?.resolve()});const{paramsError:s,searchError:a}=o;s&&y7(t,n,s,"PARSE_PARAMS"),a&&y7(t,n,a,"VALIDATE_SEARCH"),H8e(t,e,r,o);const l=new AbortController;let c=!1;const u=()=>{c||(c=!0,t.updateMatch(e,C=>({...C,isFetching:"beforeLoad",fetchCount:C.fetchCount+1,abortController:l})))},d=()=>{o._nonReactive.beforeLoadPromise?.resolve(),o._nonReactive.beforeLoadPromise=void 0,t.updateMatch(e,C=>({...C,isFetching:!1}))};if(!r.options.beforeLoad){F5(()=>{u(),d()});return}o._nonReactive.beforeLoadPromise=C3();const h={...q5(t,n,!1),...o.__routeContext},{search:p,params:g,cause:_}=o,x=nM(t,e),y={search:p,abortController:l,params:g,preload:x,context:h,location:t.location,navigate:C=>t.router.navigate({...C,_fromLocation:t.location}),buildLocation:t.router.buildLocation,cause:x?"preload":_,matches:t.matches,routeId:r.id,...t.router.options.additionalContext},k=C=>{if(C===void 0){F5(()=>{u(),d()});return}(Zl(C)||la(C))&&(u(),y7(t,n,C,"BEFORE_LOAD")),F5(()=>{u(),t.updateMatch(e,A=>({...A,__beforeLoadContext:C})),d()})};let O;try{if(O=r.options.beforeLoad(y),ab(O))return u(),O.catch(C=>{y7(t,n,C,"BEFORE_LOAD")}).then(k)}catch(C){u(),y7(t,n,C,"BEFORE_LOAD")}k(O)},fKe=(t,e)=>{const{id:n,routeId:r}=t.matches[e],o=t.router.looseRoutesById[r],i=()=>a(),s=()=>dKe(t,n,e,o),a=()=>{if(B8e(t,n))return;const l=uKe(t,n,o);return ab(l)?l.then(s):s()};return i()},hKe=(t,e,n)=>{const r=t.router.getMatch(e);if(!r||!n.options.head&&!n.options.scripts&&!n.options.headers)return;const o={ssr:t.router.options.ssr,matches:t.matches,match:r,params:r.params,loaderData:r.loaderData};return Promise.all([n.options.head?.(o),n.options.scripts?.(o),n.options.headers?.(o)]).then(([i,s,a])=>{const l=i?.meta,c=i?.links,u=i?.scripts,d=i?.styles;return{meta:l,links:c,headScripts:u,headers:a,scripts:s,styles:d}})},F8e=(t,e,n,r,o)=>{const i=e[r-1],{params:s,loaderDeps:a,abortController:l,cause:c}=t.router.getMatch(n),u=q5(t,r),d=nM(t,n);return{params:s,deps:a,preload:!!d,parentMatchPromise:i,abortController:l,context:u,location:t.location,navigate:h=>t.router.navigate({...h,_fromLocation:t.location}),cause:d?"preload":c,route:o,...t.router.options.additionalContext}},Tse=async(t,e,n,r,o)=>{try{const i=t.router.getMatch(n);try{(!(CXe??t.router.isServer)||i.ssr===!0)&&gC(o);const s=o.options.loader?.(F8e(t,e,n,r,o)),a=o.options.loader&&ab(s);if((a||o._lazyPromise||o._componentsPromise||o.options.head||o.options.scripts||o.options.headers||i._nonReactive.minPendingPromise)&&t.updateMatch(n,u=>({...u,isFetching:"loader"})),o.options.loader){const u=a?await s:s;Pf(t,t.router.getMatch(n),u),u!==void 0&&t.updateMatch(n,d=>({...d,loaderData:u}))}o._lazyPromise&&await o._lazyPromise;const c=i._nonReactive.minPendingPromise;c&&await c,o._componentsPromise&&await o._componentsPromise,t.updateMatch(n,u=>({...u,error:void 0,context:q5(t,r),status:"success",isFetching:!1,updatedAt:Date.now()}))}catch(s){let a=s;if(a?.name==="AbortError"){if(i.abortController.signal.aborted){i._nonReactive.loaderPromise?.resolve(),i._nonReactive.loaderPromise=void 0;return}t.updateMatch(n,c=>({...c,status:c.status==="pending"?"success":c.status,isFetching:!1,context:q5(t,r)}));return}const l=i._nonReactive.minPendingPromise;l&&await l,la(s)&&await o.options.notFoundComponent?.preload?.(),Pf(t,t.router.getMatch(n),s);try{o.options.onError?.(s)}catch(c){a=c,Pf(t,t.router.getMatch(n),c)}t.updateMatch(n,c=>({...c,error:a,context:q5(t,r),status:"error",isFetching:!1}))}}catch(i){const s=t.router.getMatch(n);s&&(s._nonReactive.loaderPromise=void 0),Pf(t,s,i)}},pKe=async(t,e,n)=>{async function r(d,h,p,g){const _=Date.now()-h.updatedAt,x=d?g.options.preloadStaleTime??t.router.options.defaultPreloadStaleTime??3e4:g.options.staleTime??t.router.options.defaultStaleTime??0,y=g.options.shouldReload,k=typeof y=="function"?y(F8e(t,e,o,n,g)):y,{status:O,invalid:C}=p;s=O==="success"&&(C||(k??_>x)),d&&g.options.preload===!1||(s&&!t.sync?(a=!0,(async()=>{try{await Tse(t,e,o,n,g);const A=t.router.getMatch(o);A._nonReactive.loaderPromise?.resolve(),A._nonReactive.loadPromise?.resolve(),A._nonReactive.loaderPromise=void 0}catch(A){Zl(A)&&await t.router.navigate(A.options)}})()):(O!=="success"||s&&t.sync)&&await Tse(t,e,o,n,g))}const{id:o,routeId:i}=t.matches[n];let s=!1,a=!1;const l=t.router.looseRoutesById[i];if(!B8e(t,o)){const d=t.router.getMatch(o),h=nM(t,o);if(d._nonReactive.loaderPromise){if(d.status==="success"&&!t.sync&&!d.preload)return d;await d._nonReactive.loaderPromise;const p=t.router.getMatch(o),g=p._nonReactive.error||p.error;g&&Pf(t,p,g),p.status==="pending"&&await r(h,d,p,l)}else{const p=h&&!t.router.state.matches.some(_=>_.id===o),g=t.router.getMatch(o);g._nonReactive.loaderPromise=C3(),p!==g.preload&&t.updateMatch(o,_=>({..._,preload:p})),await r(h,d,g,l)}}const c=t.router.getMatch(o);a||(c._nonReactive.loaderPromise?.resolve(),c._nonReactive.loadPromise?.resolve()),clearTimeout(c._nonReactive.pendingTimeout),c._nonReactive.pendingTimeout=void 0,a||(c._nonReactive.loaderPromise=void 0),c._nonReactive.dehydrated=void 0;const u=a?c.isFetching:!1;return u!==c.isFetching||c.invalid!==!1?(t.updateMatch(o,d=>({...d,isFetching:u,invalid:!1})),t.router.getMatch(o)):c};async function Mse(t){const e=t,n=[];e.router.state.matches.some(h=>h._forcePending)&&FH(e);let r;for(let h=0;h<e.matches.length;h++){try{const p=fKe(e,h);ab(p)&&await p}catch(p){if(Zl(p))throw p;if(la(p))r=p;else if(!e.preload)throw p;break}if(e.serialError)break}const o=e.firstBadMatchIndex??e.matches.length,i=r&&!e.preload?Ese(e,r):void 0,s=r&&e.preload?0:i!==void 0?Math.min(i+1,o):o;let a,l;for(let h=0;h<s;h++)n.push(pKe(e,n,h));try{await Promise.all(n)}catch{const h=await Promise.allSettled(n);for(const p of h){if(p.status!=="rejected")continue;const g=p.reason;if(Zl(g))throw g;la(g)?a??=g:l??=g}if(l!==void 0)throw l}const c=a??(r&&!e.preload?r:void 0);let u=e.serialError?e.firstBadMatchIndex??0:e.matches.length-1;if(!c&&r&&e.preload)return e.matches;if(c){const h=Ese(e,c);Xl(h!==void 0);const p=e.matches[h],g=e.router.looseRoutesById[p.routeId],_=e.router.options?.defaultNotFoundComponent;!g.options.notFoundComponent&&_&&(g.options.notFoundComponent=_),c.routeId=p.routeId;const x=p.routeId===e.router.routeTree.id;e.updateMatch(p.id,y=>({...y,...x?{status:"success",globalNotFound:!0,error:void 0}:{status:"notFound",error:c},isFetching:!1})),u=h,await gC(g)}else if(!e.preload){const h=e.matches[0];h.globalNotFound||e.router.getMatch(h.id)?.globalNotFound&&e.updateMatch(h.id,g=>({...g,globalNotFound:!1,error:void 0}))}if(e.serialError&&e.firstBadMatchIndex!==void 0){const h=e.router.looseRoutesById[e.matches[e.firstBadMatchIndex].routeId];await gC(h)}for(let h=0;h<=u;h++){const p=e.matches[h],{id:g,routeId:_}=p,x=e.router.looseRoutesById[_];try{const y=hKe(e,g,x);if(y){const k=await y;e.updateMatch(g,O=>({...O,...k}))}}catch(y){console.error(`Error executing head for route ${_}:`,y)}}const d=FH(e);if(ab(d)&&await d,c)throw c;if(e.serialError&&!e.preload&&!e.onReady)throw e.serialError;return e.matches}async function gC(t){if(!t._lazyLoaded&&t._lazyPromise===void 0&&(t.lazyFn?t._lazyPromise=t.lazyFn().then(e=>{const{id:n,...r}=e.options;Object.assign(t.options,r),t._lazyLoaded=!0,t._lazyPromise=void 0}):t._lazyLoaded=!0),!t._componentsLoaded&&t._componentsPromise===void 0){const e=()=>{const n=[];for(const r of V8e){const o=t.options[r]?.preload;o&&n.push(o())}if(n.length)return Promise.all(n).then(()=>{t._componentsLoaded=!0,t._componentsPromise=void 0});t._componentsLoaded=!0,t._componentsPromise=void 0};t._componentsPromise=t._lazyPromise?t._lazyPromise.then(e):e()}return t._componentsPromise}function q8e(t){for(const e of V8e)if(t.options[e]?.preload)return!0;return!1}const V8e=["component","errorComponent","pendingComponent","notFoundComponent"];function mKe(t){return{input:({url:e})=>{for(const n of t)e=qH(n,e);return e},output:({url:e})=>{for(let n=t.length-1;n>=0;n--)e=Q8e(t[n],e);return e}}}function gKe(t){const e=D8e(t.basepath),n=`/${e}`,r=`${n}/`,o=t.caseSensitive?n:n.toLowerCase(),i=t.caseSensitive?r:r.toLowerCase();return{input:({url:s})=>{const a=t.caseSensitive?s.pathname:s.pathname.toLowerCase();return a===o?s.pathname="/":a.startsWith(i)&&(s.pathname=s.pathname.slice(n.length)),s},output:({url:s})=>(s.pathname=VO(["/",e,s.pathname]),s)}}function qH(t,e){const n=t?.input?.({url:e});if(n){if(typeof n=="string")return new URL(n);if(n instanceof URL)return n}return e}function Q8e(t,e){const n=t?.output?.({url:e});if(n){if(typeof n=="string")return new URL(n);if(n instanceof URL)return n}return e}function vKe(t){return t instanceof Error?{name:t.name,message:t.message}:{data:t}}function m3(t){const e=t.resolvedLocation,n=t.location,r=e?.pathname!==n.pathname,o=e?.href!==n.href,i=e?.hash!==n.hash;return{fromLocation:e,toLocation:n,pathChanged:r,hrefChanged:o,hashChanged:i}}function bKe(t){const e=t.filter(n=>n.status!=="redirected");return e.length===t.length?t:e}class _Ke{constructor(e){this.tempLocationKey=`${Math.round(Math.random()*1e7)}`,this.resetNextScroll=!0,this.shouldViewTransition=void 0,this.isViewTransitionTypesSupported=void 0,this.subscribers=new Set,this.isScrollRestoring=!1,this.isScrollRestorationSetup=!1,this.startTransition=n=>n(),this.update=n=>{const r=this.options,o=this.basepath??r?.basepath??"/",i=this.basepath===void 0,s=r?.rewrite;if(this.options={...r,...n},this.isServer=this.options.isServer??typeof document>"u",this.protocolAllowlist=new Set(this.options.protocolAllowlist),this.options.pathParamsAllowedCharacters&&(this.pathParamsDecoder=GXe(this.options.pathParamsAllowedCharacters)),(!this.history||this.options.history&&this.options.history!==this.history)&&(this.options.history?this.history=this.options.history:this.history=OXe()),this.origin=this.options.origin,this.origin||(window?.origin&&window.origin!=="null"?this.origin=window.origin:this.origin="http://localhost"),this.history&&this.updateLatestLocation(),this.options.routeTree!==this.routeTree){this.routeTree=this.options.routeTree;let h;this.resolvePathCache=hC(1e3),h=this.buildRouteTree(),this.setRoutes(h)}!this.__store&&this.latestLocation&&(this.__store=yXe(yKe(this.latestLocation)),nKe(this));let a=!1;const l=this.options.basepath??"/",c=this.options.rewrite;if(i||o!==l||s!==c){this.basepath=l;const h=[],p=D8e(l);p&&p!=="/"&&h.push(gKe({basepath:l})),c&&h.push(c),this.rewrite=h.length===0?void 0:h.length===1?h[0]:mKe(h),this.history&&this.updateLatestLocation(),a=!0}a&&this.__store&&this.__store.setState(h=>({...h,location:this.latestLocation})),typeof window<"u"&&"CSS"in window&&typeof window.CSS?.supports=="function"&&(this.isViewTransitionTypesSupported=window.CSS.supports("selector(:active-view-transition-type(a)"))},this.updateLatestLocation=()=>{this.latestLocation=this.parseLocation(this.history.location,this.latestLocation)},this.buildRouteTree=()=>{const n=qXe(this.routeTree,this.options.caseSensitive,(r,o)=>{r.init({originalIndex:o})});return this.options.routeMasks&&zXe(this.options.routeMasks,n.processedTree),n},this.subscribe=(n,r)=>{const o={eventType:n,fn:r};return this.subscribers.add(o),()=>{this.subscribers.delete(o)}},this.emit=n=>{this.subscribers.forEach(r=>{r.eventType===n.type&&r.fn(n)})},this.parseLocation=(n,r)=>{const o=({pathname:l,search:c,hash:u,href:d,state:h})=>{if(!this.rewrite&&!/[ \x00-\x1f\x7f\u0080-\uffff]/.test(l)){const k=this.options.parseSearch(c),O=this.options.stringifySearch(k);return{href:l+O+u,publicHref:d,pathname:_7(l).path,external:!1,searchStr:O,search:Hl(r?.search,k),hash:_7(u.slice(1)).path,state:Hl(r?.state,h)}}const p=new URL(d,this.origin),g=qH(this.rewrite,p),_=this.options.parseSearch(g.search),x=this.options.stringifySearch(_);return g.search=x,{href:g.href.replace(g.origin,""),publicHref:d,pathname:_7(g.pathname).path,external:!!this.rewrite&&g.origin!==this.origin,searchStr:x,search:Hl(r?.search,_),hash:_7(g.hash.slice(1)).path,state:Hl(r?.state,h)}},i=o(n),{__tempLocation:s,__tempKey:a}=i.state;if(s&&(!a||a===this.tempLocationKey)){const l=o(s);return l.state.key=i.state.key,l.state.__TSR_key=i.state.__TSR_key,delete l.state.__tempLocation,{...l,maskedLocation:i}}return i},this.resolvePathWithBase=(n,r)=>ZXe({base:n,to:KW(r),trailingSlash:this.options.trailingSlash,cache:this.resolvePathCache}),this.matchRoutes=(n,r,o)=>typeof n=="string"?this.matchRoutesInternal({pathname:n,search:r},o):this.matchRoutesInternal(n,r),this.getMatchedRoutes=n=>wKe({pathname:n,routesById:this.routesById,processedTree:this.processedTree}),this.cancelMatch=n=>{const r=this.getMatch(n);r&&(r.abortController.abort(),clearTimeout(r._nonReactive.pendingTimeout),r._nonReactive.pendingTimeout=void 0)},this.cancelMatches=()=>{const n=this.state.matches.filter(i=>i.status==="pending"),r=this.state.matches.filter(i=>i.isFetching==="loader");new Set([...this.state.pendingMatches??[],...n,...r]).forEach(i=>{this.cancelMatch(i.id)})},this.buildLocation=n=>{const r=(i={})=>{const s=i._fromLocation||this.pendingBuiltLocation||this.latestLocation,a=this.matchRoutesLightweight(s);i.from;const l=i.unsafeRelative==="path"?s.pathname:i.from??a.fullPath,c=this.resolvePathWithBase(l,"."),u=a.search,d={...a.params},h=i.to?this.resolvePathWithBase(c,`${i.to}`):this.resolvePathWithBase(c,"."),p=i.params===!1||i.params===null?{}:(i.params??!0)===!0?d:Object.assign(d,Mf(i.params,d)),g=this.getMatchedRoutes(h);let _=g.matchedRoutes;if((!g.foundRoute||g.foundRoute.path!=="/"&&g.routeParams["**"])&&this.options.notFoundRoute&&(_=[..._,this.options.notFoundRoute]),Object.keys(p).length>0)for(const I of _){const z=I.options.params?.stringify??I.options.stringifyParams;if(z)try{Object.assign(p,z(p))}catch{}}const y=n.leaveParams?h:_7(Cse({path:h,params:p,decoder:this.pathParamsDecoder,server:this.isServer}).interpolatedPath).path;let k=u;if(n._includeValidateSearch&&this.options.search?.strict){const I={};_.forEach(z=>{if(z.options.validateSearch)try{Object.assign(I,QO(z.options.validateSearch,{...I,...k}))}catch{}}),k=I}k=kKe({search:k,dest:i,destRoutes:_,_includeValidateSearch:n._includeValidateSearch}),k=Hl(u,k);const O=this.options.stringifySearch(k),C=i.hash===!0?s.hash:i.hash?Mf(i.hash,s.hash):void 0,A=C?`#${C}`:"";let E=i.state===!0?s.state:i.state?Mf(i.state,s.state):{};E=Hl(s.state,E);const M=`${y}${O}${A}`;let P,L,D=!1;if(this.rewrite){const I=new URL(M,this.origin),z=Q8e(this.rewrite,I);P=I.href.replace(I.origin,""),z.origin!==this.origin?(L=z.href,D=!0):L=z.pathname+z.search+z.hash}else P=LXe(M),L=P;return{publicHref:L,href:P,pathname:y,search:k,searchStr:O,state:E,hash:C??"",external:D,unmaskOnReload:i.unmaskOnReload}},o=(i={},s)=>{const a=r(i);let l=s?r(s):void 0;if(!l){const c={};if(this.options.routeMasks){const u=$Xe(a.pathname,this.processedTree);if(u){Object.assign(c,u.rawParams);const{from:d,params:h,...p}=u.route,g=h===!1||h===null?{}:(h??!0)===!0?c:Object.assign(c,Mf(h,c));s={from:n.from,...p,params:g},l=r(s)}}}return l&&(a.maskedLocation=l),a};return n.mask?o(n,{from:n.from,...n.mask}):o(n)},this.commitLocation=async({viewTransition:n,ignoreBlocker:r,...o})=>{const i=()=>{const l=["key","__TSR_key","__TSR_index","__hashScrollIntoViewOptions"];l.forEach(u=>{o.state[u]=this.latestLocation.state[u]});const c=p3(o.state,this.latestLocation.state);return l.forEach(u=>{delete o.state[u]}),c},s=Hf(this.latestLocation.href)===Hf(o.href),a=this.commitLocationPromise;if(this.commitLocationPromise=C3(()=>{a?.resolve()}),s&&i())this.load();else{let{maskedLocation:l,hashScrollIntoView:c,...u}=o;l&&(u={...l,state:{...l.state,__tempKey:void 0,__tempLocation:{...u,search:u.searchStr,state:{...u.state,__tempKey:void 0,__tempLocation:void 0,__TSR_key:void 0,key:void 0}}}},(u.unmaskOnReload??this.options.unmaskOnReload??!1)&&(u.state.__tempKey=this.tempLocationKey)),u.state.__hashScrollIntoViewOptions=c??this.options.defaultHashScrollIntoView??!0,this.shouldViewTransition=n,this.history[o.replace?"replace":"push"](u.publicHref,u.state,{ignoreBlocker:r})}return this.resetNextScroll=o.resetScroll??!0,this.history.subscribers.size||this.load(),this.commitLocationPromise},this.buildAndCommitLocation=({replace:n,resetScroll:r,hashScrollIntoView:o,viewTransition:i,ignoreBlocker:s,href:a,...l}={})=>{if(a){const d=this.history.location.state.__TSR_index,h=uC(a,{__TSR_index:n?d:d+1}),p=new URL(h.pathname,this.origin),g=qH(this.rewrite,p);l.to=g.pathname,l.search=this.options.parseSearch(h.search),l.hash=h.hash.slice(1)}const c=this.buildLocation({...l,_includeValidateSearch:!0});this.pendingBuiltLocation=c;const u=this.commitLocation({...c,viewTransition:i,replace:n,resetScroll:r,hashScrollIntoView:o,ignoreBlocker:s});return Promise.resolve().then(()=>{this.pendingBuiltLocation===c&&(this.pendingBuiltLocation=void 0)}),u},this.navigate=async({to:n,reloadDocument:r,href:o,publicHref:i,...s})=>{let a=!1;if(o)try{new URL(`${o}`),a=!0}catch{}if(a&&!r&&(r=!0),r){if(n!==void 0||!o){const c=this.buildLocation({to:n,...s});o=o??c.publicHref,i=i??c.publicHref}const l=!a&&i?i:o;if(fC(l,this.protocolAllowlist))return Promise.resolve();if(!s.ignoreBlocker){const u=this.history.getBlockers?.()??[];for(const d of u)if(d?.blockerFn&&await d.blockerFn({currentLocation:this.latestLocation,nextLocation:this.latestLocation,action:"PUSH"}))return Promise.resolve()}return s.replace?window.location.replace(l):window.location.href=l,Promise.resolve()}return this.buildAndCommitLocation({...s,href:o,to:n,_isNavigate:!0})},this.beforeLoad=()=>{this.cancelMatches(),this.updateLatestLocation();const n=this.matchRoutes(this.latestLocation);this.__store.setState(r=>({...r,status:"pending",statusCode:200,isLoading:!0,location:this.latestLocation,pendingMatches:n,cachedMatches:r.cachedMatches.filter(o=>!n.some(i=>i.id===o.id))}))},this.load=async n=>{let r,o,i;for(i=new Promise(a=>{this.startTransition(async()=>{try{this.beforeLoad();const l=this.latestLocation,c=this.state.resolvedLocation;this.state.redirect||this.emit({type:"onBeforeNavigate",...m3({resolvedLocation:c,location:l})}),this.emit({type:"onBeforeLoad",...m3({resolvedLocation:c,location:l})}),await Mse({router:this,sync:n?.sync,matches:this.state.pendingMatches,location:l,updateMatch:this.updateMatch,onReady:async()=>{this.startTransition(()=>{this.startViewTransition(async()=>{let u=[],d=[],h=[],p=[];F5(()=>{this.__store.setState(g=>{const _=g.matches,x=g.pendingMatches||g.matches;return u=_.filter(y=>!x.some(k=>k.id===y.id)),d=_.filter(y=>!x.some(k=>k.routeId===y.routeId)),h=x.filter(y=>!_.some(k=>k.routeId===y.routeId)),p=x.filter(y=>_.some(k=>k.routeId===y.routeId)),{...g,isLoading:!1,loadedAt:Date.now(),matches:x,pendingMatches:void 0,cachedMatches:[...g.cachedMatches,...u.filter(y=>y.status!=="error"&&y.status!=="notFound"&&y.status!=="redirected")]}}),this.clearExpiredCache()}),[[d,"onLeave"],[h,"onEnter"],[p,"onStay"]].forEach(([g,_])=>{g.forEach(x=>{this.looseRoutesById[x.routeId].options[_]?.(x)})})})})}})}catch(l){Zl(l)?(r=l,this.navigate({...r.options,replace:!0,ignoreBlocker:!0})):la(l)&&(o=l),this.__store.setState(c=>({...c,statusCode:r?r.status:o?404:c.matches.some(u=>u.status==="error")?500:200,redirect:r}))}this.latestLoadPromise===i&&(this.commitLocationPromise?.resolve(),this.latestLoadPromise=void 0,this.commitLocationPromise=void 0),a()})}),this.latestLoadPromise=i,await i;this.latestLoadPromise&&i!==this.latestLoadPromise;)await this.latestLoadPromise;let s;this.hasNotFoundMatch()?s=404:this.__store.state.matches.some(a=>a.status==="error")&&(s=500),s!==void 0&&this.__store.setState(a=>({...a,statusCode:s}))},this.startViewTransition=n=>{const r=this.shouldViewTransition??this.options.defaultViewTransition;if(this.shouldViewTransition=void 0,r&&typeof document<"u"&&"startViewTransition"in document&&typeof document.startViewTransition=="function"){let o;if(typeof r=="object"&&this.isViewTransitionTypesSupported){const i=this.latestLocation,s=this.state.resolvedLocation,a=typeof r.types=="function"?r.types(m3({resolvedLocation:s,location:i})):r.types;if(a===!1){n();return}o={update:n,types:a}}else o=n;document.startViewTransition(o)}else n()},this.updateMatch=(n,r)=>{this.startTransition(()=>{const o=this.state.pendingMatches?.some(i=>i.id===n)?"pendingMatches":this.state.matches.some(i=>i.id===n)?"matches":this.state.cachedMatches.some(i=>i.id===n)?"cachedMatches":"";o&&(o==="cachedMatches"?this.__store.setState(i=>({...i,cachedMatches:bKe(i.cachedMatches.map(s=>s.id===n?r(s):s))})):this.__store.setState(i=>({...i,[o]:i[o]?.map(s=>s.id===n?r(s):s)})))})},this.getMatch=n=>{const r=o=>o.id===n;return this.state.cachedMatches.find(r)??this.state.pendingMatches?.find(r)??this.state.matches.find(r)},this.invalidate=n=>{const r=o=>n?.filter?.(o)??!0?{...o,invalid:!0,...n?.forcePending||o.status==="error"||o.status==="notFound"?{status:"pending",error:void 0}:void 0}:o;return this.__store.setState(o=>({...o,matches:o.matches.map(r),cachedMatches:o.cachedMatches.map(r),pendingMatches:o.pendingMatches?.map(r)})),this.shouldViewTransition=!1,this.load({sync:n?.sync})},this.getParsedLocationHref=n=>n.publicHref||"/",this.resolveRedirect=n=>{const r=n.headers.get("Location");if(!n.options.href||n.options._builtLocation){const o=n.options._builtLocation??this.buildLocation(n.options),i=this.getParsedLocationHref(o);n.options.href=i,n.headers.set("Location",i)}else if(r)try{const o=new URL(r);if(this.origin&&o.origin===this.origin){const i=o.pathname+o.search+o.hash;n.options.href=i,n.headers.set("Location",i)}}catch{}if(n.options.href&&!n.options._builtLocation&&fC(n.options.href,this.protocolAllowlist))throw new Error("Redirect blocked: unsafe protocol");return n.headers.get("Location")||n.headers.set("Location",n.options.href),n},this.clearCache=n=>{const r=n?.filter;r!==void 0?this.__store.setState(o=>({...o,cachedMatches:o.cachedMatches.filter(i=>!r(i))})):this.__store.setState(o=>({...o,cachedMatches:[]}))},this.clearExpiredCache=()=>{const n=r=>{const o=this.looseRoutesById[r.routeId];if(!o.options.loader)return!0;const i=(r.preload?o.options.preloadGcTime??this.options.defaultPreloadGcTime:o.options.gcTime??this.options.defaultGcTime)??300*1e3;return r.status==="error"?!0:Date.now()-r.updatedAt>=i};this.clearCache({filter:n})},this.loadRouteChunk=gC,this.preloadRoute=async n=>{const r=n._builtLocation??this.buildLocation(n);let o=this.matchRoutes(r,{throwOnError:!0,preload:!0,dest:n});const i=new Set([...this.state.matches,...this.state.pendingMatches??[]].map(a=>a.id)),s=new Set([...i,...this.state.cachedMatches.map(a=>a.id)]);F5(()=>{o.forEach(a=>{s.has(a.id)||this.__store.setState(l=>({...l,cachedMatches:[...l.cachedMatches,a]}))})});try{return o=await Mse({router:this,matches:o,location:r,preload:!0,updateMatch:(a,l)=>{i.has(a)?o=o.map(c=>c.id===a?l(c):c):this.updateMatch(a,l)}}),o}catch(a){if(Zl(a))return a.options.reloadDocument?void 0:await this.preloadRoute({...a.options,_fromLocation:r});la(a)||console.error(a);return}},this.matchRoute=(n,r)=>{const o={...n,to:n.to?this.resolvePathWithBase(n.from||"",n.to):void 0,params:n.params||{},leaveParams:!0},i=this.buildLocation(o);if(r?.pending&&this.state.status!=="pending")return!1;const a=(r?.pending===void 0?!this.state.isLoading:r.pending)?this.latestLocation:this.state.resolvedLocation||this.state.location,l=BXe(i.pathname,r?.caseSensitive??!1,r?.fuzzy??!1,a.pathname,this.processedTree);return!l||n.params&&!p3(l.rawParams,n.params,{partial:!0})?!1:r?.includeSearch??!0?p3(a.search,i.search,{partial:!0})?l.rawParams:!1:l.rawParams},this.hasNotFoundMatch=()=>this.__store.state.matches.some(n=>n.status==="notFound"||n.globalNotFound),this.update({defaultPreloadDelay:50,defaultPendingMs:1e3,defaultPendingMinMs:500,context:void 0,...e,caseSensitive:e.caseSensitive??!1,notFoundMode:e.notFoundMode??"fuzzy",stringifySearch:e.stringifySearch??sKe,parseSearch:e.parseSearch??iKe,protocolAllowlist:e.protocolAllowlist??PXe}),typeof document<"u"&&(self.__TSR_ROUTER__=this)}isShell(){return!!this.options.isShell}isPrerendering(){return!!this.options.isPrerendering}get state(){return this.__store.state}setRoutes({routesById:e,routesByPath:n,processedTree:r}){this.routesById=e,this.routesByPath=n,this.processedTree=r;const o=this.options.notFoundRoute;o&&(o.init({originalIndex:99999999999}),this.routesById[o.id]=o)}get looseRoutesById(){return this.routesById}getParentContext(e){return e?.id?e.context??this.options.context??void 0:this.options.context??void 0}matchRoutesInternal(e,n){const r=this.getMatchedRoutes(e.pathname),{foundRoute:o,routeParams:i,parsedParams:s}=r;let{matchedRoutes:a}=r,l=!1;(o?o.path!=="/"&&i["**"]:Hf(e.pathname))&&(this.options.notFoundRoute?a=[...a,this.options.notFoundRoute]:l=!0);const c=l?SKe(this.options.notFoundMode,a):void 0,u=new Array(a.length),d=new Map(this.state.matches.map(h=>[h.routeId,h]));for(let h=0;h<a.length;h++){const p=a[h],g=u[h-1];let _,x,y;{const Q=g?.search??e.search,H=g?._strictSearch??void 0;try{const N=QO(p.options.validateSearch,{...Q})??void 0;_={...Q,...N},x={...H,...N},y=void 0}catch(N){let V=N;if(N instanceof vC||(V=new vC(N.message,{cause:N})),n?.throwOnError)throw V;_=Q,x={},y=V}}const k=p.options.loaderDeps?.({search:_})??"",O=k?JSON.stringify(k):"",{interpolatedPath:C,usedParams:A}=Cse({path:p.fullPath,params:i,decoder:this.pathParamsDecoder,server:this.isServer}),E=p.id+C+O,M=this.getMatch(E),P=d.get(p.id),L=M?._strictParams??A;let D;if(!M)try{Pse(p,A,s,L)}catch(Q){if(la(Q)||Zl(Q)?D=Q:D=new xKe(Q.message,{cause:Q}),n?.throwOnError)throw D}Object.assign(i,L);const I=P?"stay":"enter";let z;if(M)z={...M,cause:I,params:P?.params??i,_strictParams:L,search:Hl(P?P.search:M.search,_),_strictSearch:x};else{const Q=p.options.loader||p.options.beforeLoad||p.lazyFn||q8e(p)?"pending":"success";z={id:E,ssr:p.options.ssr,index:h,routeId:p.id,params:P?.params??i,_strictParams:L,pathname:C,updatedAt:Date.now(),search:P?Hl(P.search,_):_,_strictSearch:x,searchError:void 0,status:Q,isFetching:!1,error:void 0,paramsError:D,__routeContext:void 0,_nonReactive:{loadPromise:C3()},__beforeLoadContext:void 0,context:{},abortController:new AbortController,fetchCount:0,cause:I,loaderDeps:P?Hl(P.loaderDeps,k):k,invalid:!1,preload:!1,links:void 0,scripts:void 0,headScripts:void 0,meta:void 0,staticData:p.options.staticData||{},fullPath:p.fullPath}}n?.preload||(z.globalNotFound=c===p.id),z.searchError=y;const Y=this.getParentContext(g);z.context={...Y,...z.__routeContext,...z.__beforeLoadContext},u[h]=z}for(let h=0;h<u.length;h++){const p=u[h],g=this.looseRoutesById[p.routeId],_=this.getMatch(p.id),x=d.get(p.routeId);if(p.params=x?Hl(x.params,i):i,!_){const y=u[h-1],k=this.getParentContext(y);if(g.options.context){const O={deps:p.loaderDeps,params:p.params,context:k??{},location:e,navigate:C=>this.navigate({...C,_fromLocation:e}),buildLocation:this.buildLocation,cause:p.cause,abortController:p.abortController,preload:!!p.preload,matches:u,routeId:g.id};p.__routeContext=g.options.context(O)??void 0}p.context={...k,...p.__routeContext,...p.__beforeLoadContext}}}return u}matchRoutesLightweight(e){const{matchedRoutes:n,routeParams:r,parsedParams:o}=this.getMatchedRoutes(e.pathname),i=sb(n),s={...e.search};for(const u of n)try{Object.assign(s,QO(u.options.validateSearch,s))}catch{}const a=sb(this.state.matches),l=a&&a.routeId===i.id&&e.pathname===this.state.location.pathname;let c;if(l)c=a.params;else{const u={...r};for(const d of n)try{Pse(d,r,o??{},u)}catch{}c=u}return{matchedRoutes:n,fullPath:i.fullPath,search:s,params:c}}}class vC extends Error{}class xKe extends Error{}function yKe(t){return{loadedAt:0,isLoading:!1,isTransitioning:!1,status:"idle",resolvedLocation:void 0,location:t,matches:[],pendingMatches:[],cachedMatches:[],statusCode:200}}function QO(t,e){if(t==null)return{};if("~standard"in t){const n=t["~standard"].validate(e);if(n instanceof Promise)throw new vC("Async validation not supported");if(n.issues)throw new vC(JSON.stringify(n.issues,void 0,2),{cause:n});return n.value}return"parse"in t?t.parse(e):typeof t=="function"?t(e):{}}function wKe({pathname:t,routesById:e,processedTree:n}){const r={},o=Hf(t);let i,s;const a=HXe(o,n,!0);return a&&(i=a.route,Object.assign(r,a.rawParams),s=Object.assign({},a.parsedParams)),{matchedRoutes:a?.branch||[e[kc]],routeParams:r,foundRoute:i,parsedParams:s}}function kKe({search:t,dest:e,destRoutes:n,_includeValidateSearch:r}){return OKe(n)(t,e,r??!1)}function OKe(t){const e={dest:null,_includeValidateSearch:!1,middlewares:[]};for(const o of t){if("search"in o.options)o.options.search?.middlewares&&e.middlewares.push(...o.options.search.middlewares);else if(o.options.preSearchFilters||o.options.postSearchFilters){const i=({search:s,next:a})=>{let l=s;"preSearchFilters"in o.options&&o.options.preSearchFilters&&(l=o.options.preSearchFilters.reduce((u,d)=>d(u),s));const c=a(l);return"postSearchFilters"in o.options&&o.options.postSearchFilters?o.options.postSearchFilters.reduce((u,d)=>d(u),c):c};e.middlewares.push(i)}if(o.options.validateSearch){const i=({search:s,next:a})=>{const l=a(s);if(!e._includeValidateSearch)return l;try{return{...l,...QO(o.options.validateSearch,l)??void 0}}catch{return l}};e.middlewares.push(i)}}const n=({search:o})=>{const i=e.dest;return i.search?i.search===!0?o:Mf(i.search,o):{}};e.middlewares.push(n);const r=(o,i,s)=>{if(o>=s.length)return i;const a=s[o];return a({search:i,next:c=>r(o+1,c,s)})};return function(i,s,a){return e.dest=s,e._includeValidateSearch=a,r(0,i,e.middlewares)}}function SKe(t,e){if(t!=="root")for(let n=e.length-1;n>=0;n--){const r=e[n];if(r.children)return r.id}return kc}function Pse(t,e,n,r){const o=t.options.params?.parse??t.options.parseParams;if(o)if(t.options.skipRouteOnParseError)for(const i in e)i in n&&(r[i]=n[i]);else{const i=o(r);Object.assign(r,i)}}const L1=Symbol.for("TSR_DEFERRED_PROMISE");function CKe(t,e){const n=t;return n[L1]||(n[L1]={status:"pending"},n.then(r=>{n[L1].status="success",n[L1].data=r}).catch(r=>{n[L1].status="error",n[L1].error={data:vKe(r),__isServerError:!0}})),n}const AKe="Error preloading route! ☝️";class U8e{constructor(e){if(this.init=n=>{this.originalIndex=n.originalIndex;const r=this.options,o=!r?.path&&!r?.id;this.parentRoute=this.options.getParentRoute?.(),o?this._path=kc:this.parentRoute||Xl(!1);let i=o?kc:r?.path;i&&i!=="/"&&(i=I8e(i));const s=r?.id||i;let a=o?kc:VO([this.parentRoute.id===kc?"":this.parentRoute.id,s]);i===kc&&(i="/"),a!==kc&&(a=VO(["/",a]));const l=a===kc?"/":VO([this.parentRoute.fullPath,i]);this._path=i,this._id=a,this._fullPath=l,this._to=Hf(l)},this.addChildren=n=>this._addFileChildren(n),this._addFileChildren=n=>(Array.isArray(n)&&(this.children=n),typeof n=="object"&&n!==null&&(this.children=Object.values(n)),this),this._addFileTypes=()=>this,this.updateLoader=n=>(Object.assign(this.options,n),this),this.update=n=>(Object.assign(this.options,n),this),this.lazy=n=>(this.lazyFn=n,this),this.redirect=n=>$8e({from:this.fullPath,...n}),this.options=e||{},this.isRoot=!e?.getParentRoute,e?.id&&e?.path)throw new Error("Route cannot have both an 'id' and a 'path' option.")}get to(){return this._to}get id(){return this._id}get path(){return this._path}get fullPath(){return this._fullPath}}class EKe extends U8e{constructor(e){super(e)}}var TKe=(t=>(t[t.AggregateError=1]="AggregateError",t[t.ArrowFunction=2]="ArrowFunction",t[t.ErrorPrototypeStack=4]="ErrorPrototypeStack",t[t.ObjectAssign=8]="ObjectAssign",t[t.BigIntTypedArray=16]="BigIntTypedArray",t[t.RegExp=32]="RegExp",t))(TKe||{}),z2=Symbol.asyncIterator,W8e=Symbol.hasInstance,V5=Symbol.isConcatSpreadable,$2=Symbol.iterator,Z8e=Symbol.match,G8e=Symbol.matchAll,Y8e=Symbol.replace,X8e=Symbol.search,K8e=Symbol.species,J8e=Symbol.split,e7e=Symbol.toPrimitive,Q5=Symbol.toStringTag,t7e=Symbol.unscopables,n7e={[z2]:0,[W8e]:1,[V5]:2,[$2]:3,[Z8e]:4,[G8e]:5,[Y8e]:6,[X8e]:7,[K8e]:8,[J8e]:9,[e7e]:10,[Q5]:11,[t7e]:12},MKe={0:z2,1:W8e,2:V5,3:$2,4:Z8e,5:G8e,6:Y8e,7:X8e,8:K8e,9:J8e,10:e7e,11:Q5,12:t7e},de=void 0,PKe={2:!0,3:!1,1:de,0:null,4:-0,5:Number.POSITIVE_INFINITY,6:Number.NEGATIVE_INFINITY,7:Number.NaN},jKe={0:"Error",1:"EvalError",2:"RangeError",3:"ReferenceError",4:"SyntaxError",5:"TypeError",6:"URIError"},NKe={0:Error,1:EvalError,2:RangeError,3:ReferenceError,4:SyntaxError,5:TypeError,6:URIError};function Qr(t,e,n,r,o,i,s,a,l,c,u,d){return{t,i:e,s:n,c:r,m:o,p:i,e:s,a,f:l,b:c,o:u,l:d}}function yh(t){return Qr(2,de,t,de,de,de,de,de,de,de,de,de)}var r7e=yh(2),o7e=yh(3),RKe=yh(1),LKe=yh(0),IKe=yh(4),DKe=yh(5),zKe=yh(6),$Ke=yh(7);function BKe(t){switch(t){case'"':return'\\"';case"\\":return"\\\\";case`
3
3
  `:return"\\n";case"\r":return"\\r";case"\b":return"\\b";case" ":return"\\t";case"\f":return"\\f";case"<":return"\\x3C";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029";default:return de}}function wh(t){let e="",n=0,r;for(let o=0,i=t.length;o<i;o++)r=BKe(t[o]),r&&(e+=t.slice(n,o)+r,n=o+1);return n===0?e=t:e+=t.slice(n),e}function HKe(t){switch(t){case"\\\\":return"\\";case'\\"':return'"';case"\\n":return`
4
4
  `;case"\\r":return"\r";case"\\b":return"\b";case"\\t":return" ";case"\\f":return"\f";case"\\x3C":return"<";case"\\u2028":return"\u2028";case"\\u2029":return"\u2029";default:return t}}function _4(t){return t.replace(/(\\\\|\\"|\\n|\\r|\\b|\\t|\\f|\\u2028|\\u2029|\\x3C)/g,HKe)}var Ow="__SEROVAL_REFS__",i7e=new Map,S5=new Map;function s7e(t){return i7e.has(t)}function FKe(t){return S5.has(t)}function qKe(t){if(s7e(t))return i7e.get(t);throw new xJe(t)}function VKe(t){if(FKe(t))return S5.get(t);throw new yJe(t)}typeof globalThis<"u"?Object.defineProperty(globalThis,Ow,{value:S5,configurable:!0,writable:!1,enumerable:!1}):typeof window<"u"?Object.defineProperty(window,Ow,{value:S5,configurable:!0,writable:!1,enumerable:!1}):typeof self<"u"?Object.defineProperty(self,Ow,{value:S5,configurable:!0,writable:!1,enumerable:!1}):typeof global<"u"&&Object.defineProperty(global,Ow,{value:S5,configurable:!0,writable:!1,enumerable:!1});function JW(t){return t instanceof EvalError?1:t instanceof RangeError?2:t instanceof ReferenceError?3:t instanceof SyntaxError?4:t instanceof TypeError?5:t instanceof URIError?6:0}function QKe(t){let e=jKe[JW(t)];return t.name!==e?{name:t.name}:t.constructor.name!==e?{name:t.constructor.name}:{}}function a7e(t,e){let n=QKe(t),r=Object.getOwnPropertyNames(t);for(let o=0,i=r.length,s;o<i;o++)s=r[o],s!=="name"&&s!=="message"&&(s==="stack"?e&4&&(n=n||{},n[s]=t[s]):(n=n||{},n[s]=t[s]));return n}function l7e(t){return Object.isFrozen(t)?3:Object.isSealed(t)?2:Object.isExtensible(t)?0:1}function UKe(t){switch(t){case Number.POSITIVE_INFINITY:return DKe;case Number.NEGATIVE_INFINITY:return zKe}return t!==t?$Ke:Object.is(t,-0)?IKe:Qr(0,de,t,de,de,de,de,de,de,de,de,de)}function c7e(t){return Qr(1,de,wh(t),de,de,de,de,de,de,de,de,de)}function WKe(t){return Qr(3,de,""+t,de,de,de,de,de,de,de,de,de)}function ZKe(t){return Qr(4,t,de,de,de,de,de,de,de,de,de,de)}function GKe(t,e){let n=e.valueOf();return Qr(5,t,n!==n?"":e.toISOString(),de,de,de,de,de,de,de,de,de)}function YKe(t,e){return Qr(6,t,de,wh(e.source),e.flags,de,de,de,de,de,de,de)}function XKe(t,e){return Qr(17,t,n7e[e],de,de,de,de,de,de,de,de,de)}function KKe(t,e){return Qr(18,t,wh(qKe(e)),de,de,de,de,de,de,de,de,de)}function JKe(t,e,n){return Qr(25,t,n,wh(e),de,de,de,de,de,de,de,de)}function eJe(t,e,n){return Qr(9,t,de,de,de,de,de,n,de,de,l7e(e),de)}function tJe(t,e){return Qr(21,t,de,de,de,de,de,de,e,de,de,de)}function nJe(t,e,n){return Qr(15,t,de,e.constructor.name,de,de,de,de,n,e.byteOffset,de,e.length)}function rJe(t,e,n){return Qr(16,t,de,e.constructor.name,de,de,de,de,n,e.byteOffset,de,e.byteLength)}function oJe(t,e,n){return Qr(20,t,de,de,de,de,de,de,n,e.byteOffset,de,e.byteLength)}function iJe(t,e,n){return Qr(13,t,JW(e),de,wh(e.message),n,de,de,de,de,de,de)}function sJe(t,e,n){return Qr(14,t,JW(e),de,wh(e.message),n,de,de,de,de,de,de)}function aJe(t,e){return Qr(7,t,de,de,de,de,de,e,de,de,de,de)}function lJe(t,e){return Qr(28,de,de,de,de,de,de,[t,e],de,de,de,de)}function cJe(t,e){return Qr(30,de,de,de,de,de,de,[t,e],de,de,de,de)}function uJe(t,e,n){return Qr(31,t,de,de,de,de,de,n,e,de,de,de)}function dJe(t,e){return Qr(32,t,de,de,de,de,de,de,e,de,de,de)}function fJe(t,e){return Qr(33,t,de,de,de,de,de,de,e,de,de,de)}function hJe(t,e){return Qr(34,t,de,de,de,de,de,de,e,de,de,de)}function pJe(t,e,n,r){return Qr(35,t,n,de,de,de,de,e,de,de,de,r)}var mJe={parsing:1,serialization:2,deserialization:3};function gJe(t){return`Seroval Error (step: ${mJe[t]})`}var vJe=(t,e)=>gJe(t),u7e=class extends Error{constructor(e,n){super(vJe(e)),this.cause=n}},jse=class extends u7e{constructor(e){super("parsing",e)}},bJe=class extends u7e{constructor(e){super("deserialization",e)}};function ad(t){return`Seroval Error (specific: ${t})`}var rM=class extends Error{constructor(e){super(ad(1)),this.value=e}},d7e=class extends Error{constructor(e){super(ad(2))}},_Je=class extends Error{constructor(e){super(ad(3))}},V_=class extends Error{constructor(e){super(ad(4))}},xJe=class extends Error{constructor(e){super(ad(5)),this.value=e}},yJe=class extends Error{constructor(e){super(ad(6))}},wJe=class extends Error{constructor(e){super(ad(7))}},kh=class extends Error{constructor(e){super(ad(8))}},kJe=class extends Error{constructor(e){super(ad(9))}},OJe=class{constructor(e,n){this.value=e,this.replacement=n}},oM=()=>{let t={p:0,s:0,f:0};return t.p=new Promise((e,n)=>{t.s=e,t.f=n}),t},SJe=(t,e)=>{t.s(e),t.p.s=1,t.p.v=e},CJe=(t,e)=>{t.f(e),t.p.s=2,t.p.v=e};oM.toString();SJe.toString();CJe.toString();var AJe=()=>{let t=[],e=[],n=!0,r=!1,o=0,i=(l,c,u)=>{for(u=0;u<o;u++)e[u]&&e[u][c](l)},s=(l,c,u,d)=>{for(c=0,u=t.length;c<u;c++)d=t[c],!n&&c===u-1?l[r?"return":"throw"](d):l.next(d)},a=(l,c)=>(n&&(c=o++,e[c]=l),s(l),()=>{n&&(e[c]=e[o],e[o--]=void 0)});return{__SEROVAL_STREAM__:!0,on:l=>a(l),next:l=>{n&&(t.push(l),i(l,"next"))},throw:l=>{n&&(t.push(l),i(l,"throw"),n=!1,r=!1,e.length=0)},return:l=>{n&&(t.push(l),i(l,"return"),n=!1,r=!0,e.length=0)}}},EJe=t=>e=>()=>{let n=0,r={[t]:()=>r,next:()=>{if(n>e.d)return{done:!0,value:void 0};let o=n++,i=e.v[o];if(o===e.t)throw i;return{done:o===e.d,value:i}}};return r},TJe=(t,e)=>n=>()=>{let r=0,o=-1,i=!1,s=[],a=[],l=(u=0,d=a.length)=>{for(;u<d;u++)a[u].s({done:!0,value:void 0})};n.on({next:u=>{let d=a.shift();d&&d.s({done:!1,value:u}),s.push(u)},throw:u=>{let d=a.shift();d&&d.f(u),l(),o=s.length,i=!0,s.push(u)},return:u=>{let d=a.shift();d&&d.s({done:!0,value:u}),l(),o=s.length,s.push(u)}});let c={[t]:()=>c,next:()=>{if(o===-1){let h=r++;if(h>=s.length){let p=e();return a.push(p),p.p}return{done:!1,value:s[h]}}if(r>o)return{done:!0,value:void 0};let u=r++,d=s[u];if(u!==o)return{done:!1,value:d};if(i)throw d;return{done:!0,value:d}}};return c},f7e=t=>{let e=atob(t),n=e.length,r=new Uint8Array(n);for(let o=0;o<n;o++)r[o]=e.charCodeAt(o);return r.buffer};f7e.toString();function MJe(t){return"__SEROVAL_SEQUENCE__"in t}function h7e(t,e,n){return{__SEROVAL_SEQUENCE__:!0,v:t,t:e,d:n}}function PJe(t){let e=[],n=-1,r=-1,o=t[$2]();for(;;)try{let i=o.next();if(e.push(i.value),i.done){r=e.length-1;break}}catch(i){n=e.length,e.push(i)}return h7e(e,n,r)}var jJe=EJe($2);function NJe(t){return jJe(t)}var RJe={},LJe={},IJe={0:{},1:{},2:{},3:{},4:{},5:{}};function iM(t){return"__SEROVAL_STREAM__"in t}function x4(){return AJe()}function DJe(t){let e=x4(),n=t[z2]();async function r(){try{let o=await n.next();o.done?e.return(o.value):(e.next(o.value),await r())}catch(o){e.throw(o)}}return r().catch(()=>{}),e}var zJe=TJe(z2,oM);function $Je(t){return zJe(t)}async function BJe(t){try{return[1,await t]}catch(e){return[0,e]}}function HJe(t,e){return{plugins:e.plugins,mode:t,marked:new Set,features:63^(e.disabledFeatures||0),refs:e.refs||new Map,depthLimit:e.depthLimit||1e3}}function UO(t,e){t.marked.add(e)}function FJe(t,e){let n=t.refs.size;return t.refs.set(e,n),n}function sM(t,e){let n=t.refs.get(e);return n!=null?(UO(t,n),{type:1,value:ZKe(n)}):{type:0,value:FJe(t,e)}}function eZ(t,e){let n=sM(t,e);return n.type===1?n:s7e(e)?{type:2,value:KKe(n.value,e)}:n}function Gp(t,e){let n=eZ(t,e);if(n.type!==0)return n.value;if(e in n7e)return XKe(n.value,e);throw new rM(e)}function aM(t,e){let n=sM(t,IJe[e]);return n.type===1?n.value:Qr(26,n.value,e,de,de,de,de,de,de,de,de,de)}function qJe(t){let e=sM(t,RJe);return e.type===1?e.value:Qr(27,e.value,de,de,de,de,de,de,Gp(t,$2),de,de,de)}function VJe(t){let e=sM(t,LJe);return e.type===1?e.value:Qr(29,e.value,de,de,de,de,de,[aM(t,1),Gp(t,z2)],de,de,de,de)}function QJe(t,e,n,r){return Qr(n?11:10,t,de,de,de,r,de,de,de,de,l7e(e),de)}function UJe(t,e,n,r){return Qr(8,e,de,de,de,de,{k:n,v:r},de,aM(t,0),de,de,de)}function WJe(t,e,n){let r=new Uint8Array(n),o="";for(let i=0,s=r.length;i<s;i++)o+=String.fromCharCode(r[i]);return Qr(19,e,wh(btoa(o)),de,de,de,de,de,aM(t,5),de,de,de)}function ZJe(t,e){return{base:HJe(t,e),child:void 0}}var GJe=class{constructor(e,n){this._p=e,this.depth=n}parse(e){return Xi(this._p,this.depth,e)}};async function YJe(t,e,n){let r=[];for(let o=0,i=n.length;o<i;o++)o in n?r[o]=await Xi(t,e,n[o]):r[o]=0;return r}async function XJe(t,e,n,r){return eJe(n,r,await YJe(t,e,r))}async function tZ(t,e,n){let r=Object.entries(n),o=[],i=[];for(let s=0,a=r.length;s<a;s++)o.push(wh(r[s][0])),i.push(await Xi(t,e,r[s][1]));return $2 in n&&(o.push(Gp(t.base,$2)),i.push(lJe(qJe(t.base),await Xi(t,e,PJe(n))))),z2 in n&&(o.push(Gp(t.base,z2)),i.push(cJe(VJe(t.base),await Xi(t,e,DJe(n))))),Q5 in n&&(o.push(Gp(t.base,Q5)),i.push(c7e(n[Q5]))),V5 in n&&(o.push(Gp(t.base,V5)),i.push(n[V5]?r7e:o7e)),{k:o,v:i}}async function mI(t,e,n,r,o){return QJe(n,r,o,await tZ(t,e,r))}async function KJe(t,e,n,r){return tJe(n,await Xi(t,e,r.valueOf()))}async function JJe(t,e,n,r){return nJe(n,r,await Xi(t,e,r.buffer))}async function eet(t,e,n,r){return rJe(n,r,await Xi(t,e,r.buffer))}async function tet(t,e,n,r){return oJe(n,r,await Xi(t,e,r.buffer))}async function Nse(t,e,n,r){let o=a7e(r,t.base.features);return iJe(n,r,o?await tZ(t,e,o):de)}async function net(t,e,n,r){let o=a7e(r,t.base.features);return sJe(n,r,o?await tZ(t,e,o):de)}async function ret(t,e,n,r){let o=[],i=[];for(let[s,a]of r.entries())o.push(await Xi(t,e,s)),i.push(await Xi(t,e,a));return UJe(t.base,n,o,i)}async function oet(t,e,n,r){let o=[];for(let i of r.keys())o.push(await Xi(t,e,i));return aJe(n,o)}async function p7e(t,e,n,r){let o=t.base.plugins;if(o)for(let i=0,s=o.length;i<s;i++){let a=o[i];if(a.parse.async&&a.test(r))return JKe(n,a.tag,await a.parse.async(r,new GJe(t,e),{id:n}))}return de}async function iet(t,e,n,r){let[o,i]=await BJe(r);return Qr(12,n,o,de,de,de,de,de,await Xi(t,e,i),de,de,de)}function set(t,e,n,r,o){let i=[],s=n.on({next:a=>{UO(this.base,e),Xi(this,t,a).then(l=>{i.push(dJe(e,l))},l=>{o(l),s()})},throw:a=>{UO(this.base,e),Xi(this,t,a).then(l=>{i.push(fJe(e,l)),r(i),s()},l=>{o(l),s()})},return:a=>{UO(this.base,e),Xi(this,t,a).then(l=>{i.push(hJe(e,l)),r(i),s()},l=>{o(l),s()})}})}async function aet(t,e,n,r){return uJe(n,aM(t.base,4),await new Promise(set.bind(t,e,n,r)))}async function cet(t,e,n,r){let o=[];for(let i=0,s=r.v.length;i<s;i++)o[i]=await Xi(t,e,r.v[i]);return pJe(n,o,r.t,r.d)}async function uet(t,e,n,r){if(Array.isArray(r))return XJe(t,e,n,r);if(iM(r))return aet(t,e,n,r);if(MJe(r))return cet(t,e,n,r);let o=r.constructor;if(o===OJe)return Xi(t,e,r.replacement);let i=await p7e(t,e,n,r);if(i)return i;switch(o){case Object:return mI(t,e,n,r,!1);case de:return mI(t,e,n,r,!0);case Date:return GKe(n,r);case Error:case EvalError:case RangeError:case ReferenceError:case SyntaxError:case TypeError:case URIError:return Nse(t,e,n,r);case Number:case Boolean:case String:case BigInt:return KJe(t,e,n,r);case ArrayBuffer:return WJe(t.base,n,r);case Int8Array:case Int16Array:case Int32Array:case Uint8Array:case Uint16Array:case Uint32Array:case Uint8ClampedArray:case Float32Array:case Float64Array:return JJe(t,e,n,r);case DataView:return tet(t,e,n,r);case Map:return ret(t,e,n,r);case Set:return oet(t,e,n,r)}if(o===Promise||r instanceof Promise)return iet(t,e,n,r);let s=t.base.features;if(s&32&&o===RegExp)return YKe(n,r);if(s&16)switch(o){case BigInt64Array:case BigUint64Array:return eet(t,e,n,r)}if(s&1&&typeof AggregateError<"u"&&(o===AggregateError||r instanceof AggregateError))return net(t,e,n,r);if(r instanceof Error)return Nse(t,e,n,r);if($2 in r||z2 in r)return mI(t,e,n,r,!!o);throw new rM(r)}async function det(t,e,n){let r=eZ(t.base,n);if(r.type!==0)return r.value;let o=await p7e(t,e,r.value,n);if(o)return o;throw new rM(n)}async function Xi(t,e,n){switch(typeof n){case"boolean":return n?r7e:o7e;case"undefined":return RKe;case"string":return c7e(n);case"number":return UKe(n);case"bigint":return WKe(n);case"object":{if(n){let r=eZ(t.base,n);return r.type===0?await uet(t,e+1,r.value,n):r.value}return LKe}case"symbol":return Gp(t.base,n);case"function":return det(t,e,n);default:throw new rM(n)}}async function fet(t,e){try{return await Xi(t,0,e)}catch(n){throw n instanceof jse?n:new jse(n)}}var het=(t=>(t[t.Vanilla=1]="Vanilla",t[t.Cross=2]="Cross",t))(het||{});function m7e(t,e){for(let n=0,r=e.length;n<r;n++){let o=e[n];t.has(o)||(t.add(o),o.extends&&m7e(t,o.extends))}}function g7e(t){if(t){let e=new Set;return m7e(e,t),[...e]}}function pet(t){switch(t){case"Int8Array":return Int8Array;case"Int16Array":return Int16Array;case"Int32Array":return Int32Array;case"Uint8Array":return Uint8Array;case"Uint16Array":return Uint16Array;case"Uint32Array":return Uint32Array;case"Uint8ClampedArray":return Uint8ClampedArray;case"Float32Array":return Float32Array;case"Float64Array":return Float64Array;case"BigInt64Array":return BigInt64Array;case"BigUint64Array":return BigUint64Array;default:throw new wJe(t)}}var met=1e6,get=1e4,vet=2e4;function v7e(t,e){switch(e){case 3:return Object.freeze(t);case 1:return Object.preventExtensions(t);case 2:return Object.seal(t);default:return t}}var bet=1e3;function _et(t,e){var n;return{mode:t,plugins:e.plugins,refs:e.refs||new Map,features:(n=e.features)!=null?n:63^(e.disabledFeatures||0),depthLimit:e.depthLimit||bet}}function xet(t){return{mode:2,base:_et(2,t),child:de}}var yet=class{constructor(e,n){this._p=e,this.depth=n}deserialize(e){return mo(this._p,this.depth,e)}};function b7e(t,e){if(e<0||!Number.isFinite(e)||!Number.isInteger(e))throw new kh({t:4,i:e});if(t.refs.has(e))throw new Error("Conflicted ref id: "+e)}function wet(t,e,n){return b7e(t.base,e),t.state.marked.has(e)&&t.base.refs.set(e,n),n}function ket(t,e,n){return b7e(t.base,e),t.base.refs.set(e,n),n}function Ki(t,e,n){return t.mode===1?wet(t,e,n):ket(t,e,n)}function VH(t,e,n){if(Object.hasOwn(e,n))return e[n];throw new kh(t)}function Oet(t,e){return Ki(t,e.i,VKe(_4(e.s)))}function Cet(t,e,n){let r=n.a,o=r.length,i=Ki(t,n.i,new Array(o));for(let s=0,a;s<o;s++)a=r[s],a&&(i[s]=mo(t,e,a));return v7e(i,n.o),i}function Aet(t){switch(t){case"constructor":case"__proto__":case"prototype":case"__defineGetter__":case"__defineSetter__":case"__lookupGetter__":case"__lookupSetter__":return!1;default:return!0}}function Eet(t){switch(t){case z2:case V5:case Q5:case $2:return!0;default:return!1}}function Rse(t,e,n){Aet(e)?t[e]=n:Object.defineProperty(t,e,{value:n,configurable:!0,enumerable:!0,writable:!0})}function Tet(t,e,n,r,o){if(typeof r=="string")Rse(n,r,mo(t,e,o));else{let i=mo(t,e,r);switch(typeof i){case"string":Rse(n,i,mo(t,e,o));break;case"symbol":Eet(i)&&(n[i]=mo(t,e,o));break;default:throw new kh(r)}}}function _7e(t,e,n,r){let o=n.k;if(o.length>0)for(let i=0,s=n.v,a=o.length;i<a;i++)Tet(t,e,r,o[i],s[i]);return r}function Met(t,e,n){let r=Ki(t,n.i,n.t===10?{}:Object.create(null));return _7e(t,e,n.p,r),v7e(r,n.o),r}function Pet(t,e){return Ki(t,e.i,new Date(e.s))}function jet(t,e){if(t.base.features&32){let n=_4(e.c);if(n.length>vet)throw new kh(e);return Ki(t,e.i,new RegExp(n,e.m))}throw new d7e(e)}function Net(t,e,n){let r=Ki(t,n.i,new Set);for(let o=0,i=n.a,s=i.length;o<s;o++)r.add(mo(t,e,i[o]));return r}function Ret(t,e,n){let r=Ki(t,n.i,new Map);for(let o=0,i=n.e.k,s=n.e.v,a=i.length;o<a;o++)r.set(mo(t,e,i[o]),mo(t,e,s[o]));return r}function Let(t,e){if(e.s.length>met)throw new kh(e);return Ki(t,e.i,f7e(_4(e.s)))}function Iet(t,e,n){var r;let o=pet(n.c),i=mo(t,e,n.f),s=(r=n.b)!=null?r:0;if(s<0||s>i.byteLength)throw new kh(n);return Ki(t,n.i,new o(i,s,n.l))}function Det(t,e,n){var r;let o=mo(t,e,n.f),i=(r=n.b)!=null?r:0;if(i<0||i>o.byteLength)throw new kh(n);return Ki(t,n.i,new DataView(o,i,n.l))}function x7e(t,e,n,r){if(n.p){let o=_7e(t,e,n.p,{});Object.defineProperties(r,Object.getOwnPropertyDescriptors(o))}return r}function zet(t,e,n){let r=Ki(t,n.i,new AggregateError([],_4(n.m)));return x7e(t,e,n,r)}function $et(t,e,n){let r=VH(n,NKe,n.s),o=Ki(t,n.i,new r(_4(n.m)));return x7e(t,e,n,o)}function Bet(t,e,n){let r=oM(),o=Ki(t,n.i,r.p),i=mo(t,e,n.f);return n.s?r.s(i):r.f(i),o}function Het(t,e,n){return Ki(t,n.i,Object(mo(t,e,n.f)))}function Fet(t,e,n){let r=t.base.plugins;if(r){let o=_4(n.c);for(let i=0,s=r.length;i<s;i++){let a=r[i];if(a.tag===o)return Ki(t,n.i,a.deserialize(n.s,new yet(t,e),{id:n.i}))}}throw new _Je(n.c)}function qet(t,e){return Ki(t,e.i,Ki(t,e.s,oM()).p)}function Vet(t,e,n){let r=t.base.refs.get(n.i);if(r)return r.s(mo(t,e,n.a[1])),de;throw new V_("Promise")}function Qet(t,e,n){let r=t.base.refs.get(n.i);if(r)return r.f(mo(t,e,n.a[1])),de;throw new V_("Promise")}function Uet(t,e,n){mo(t,e,n.a[0]);let r=mo(t,e,n.a[1]);return NJe(r)}function Wet(t,e,n){mo(t,e,n.a[0]);let r=mo(t,e,n.a[1]);return $Je(r)}function Zet(t,e,n){let r=Ki(t,n.i,x4()),o=n.a,i=o.length;if(i)for(let s=0;s<i;s++)mo(t,e,o[s]);return r}function Get(t,e,n){let r=t.base.refs.get(n.i);if(r&&iM(r))return r.next(mo(t,e,n.f)),de;throw new V_("Stream")}function Yet(t,e,n){let r=t.base.refs.get(n.i);if(r&&iM(r))return r.throw(mo(t,e,n.f)),de;throw new V_("Stream")}function Xet(t,e,n){let r=t.base.refs.get(n.i);if(r&&iM(r))return r.return(mo(t,e,n.f)),de;throw new V_("Stream")}function Ket(t,e,n){return mo(t,e,n.f),de}function Jet(t,e,n){return mo(t,e,n.a[1]),de}function ett(t,e,n){let r=Ki(t,n.i,h7e([],n.s,n.l));for(let o=0,i=n.a.length;o<i;o++)r.v[o]=mo(t,e,n.a[o]);return r}function mo(t,e,n){if(e>t.base.depthLimit)throw new kJe(t.base.depthLimit);switch(e+=1,n.t){case 2:return VH(n,PKe,n.s);case 0:return Number(n.s);case 1:return _4(String(n.s));case 3:if(String(n.s).length>get)throw new kh(n);return BigInt(n.s);case 4:return t.base.refs.get(n.i);case 18:return Oet(t,n);case 9:return Cet(t,e,n);case 10:case 11:return Met(t,e,n);case 5:return Pet(t,n);case 6:return jet(t,n);case 7:return Net(t,e,n);case 8:return Ret(t,e,n);case 19:return Let(t,n);case 16:case 15:return Iet(t,e,n);case 20:return Det(t,e,n);case 14:return zet(t,e,n);case 13:return $et(t,e,n);case 12:return Bet(t,e,n);case 17:return VH(n,MKe,n.s);case 21:return Het(t,e,n);case 25:return Fet(t,e,n);case 22:return qet(t,n);case 23:return Vet(t,e,n);case 24:return Qet(t,e,n);case 28:return Uet(t,e,n);case 30:return Wet(t,e,n);case 31:return Zet(t,e,n);case 32:return Get(t,e,n);case 33:return Yet(t,e,n);case 34:return Xet(t,e,n);case 27:return Ket(t,e,n);case 29:return Jet(t,e,n);case 35:return ett(t,e,n);default:throw new d7e(n)}}function ttt(t,e){try{return mo(t,0,e)}catch(n){throw new bJe(n)}}var ntt=()=>T;ntt.toString();function gI(t,e){let n=g7e(e.plugins),r=xet({plugins:n,refs:e.refs,features:e.features,disabledFeatures:e.disabledFeatures});return ttt(r,t)}async function rtt(t,e={}){let n=g7e(e.plugins),r=ZJe(1,{plugins:n,disabledFeatures:e.disabledFeatures});return{t:await fet(r,t),f:r.base.features,m:Array.from(r.base.marked)}}function ott(t){return{tag:"$TSR/t/"+t.key,test:t.test,parse:{sync(e,n){return n.parse(t.toSerializable(e))},async async(e,n){return await n.parse(t.toSerializable(e))},stream(e,n){return n.parse(t.toSerializable(e))}},serialize:void 0,deserialize(e,n){return t.fromSerializable(n.deserialize(e))}}}var Of={},y7e=t=>new ReadableStream({start:e=>{t.on({next:n=>{try{e.enqueue(n)}catch{}},throw:n=>{e.error(n)},return:()=>{try{e.close()}catch{}}})}}),itt={tag:"seroval-plugins/web/ReadableStreamFactory",test(t){return t===Of},parse:{sync(){return Of},async async(){return await Promise.resolve(Of)},stream(){return Of}},serialize(){return y7e.toString()},deserialize(){return Of}};function Lse(t){let e=x4(),n=t.getReader();async function r(){try{let o=await n.read();o.done?e.return(o.value):(e.next(o.value),await r())}catch(o){e.throw(o)}}return r().catch(()=>{}),e}var stt={tag:"seroval/plugins/web/ReadableStream",extends:[itt],test(t){return typeof ReadableStream>"u"?!1:t instanceof ReadableStream},parse:{sync(t,e){return{factory:e.parse(Of),stream:e.parse(x4())}},async async(t,e){return{factory:await e.parse(Of),stream:await e.parse(Lse(t))}},stream(t,e){return{factory:e.parse(Of),stream:e.parse(Lse(t))}}},serialize(t,e){return"("+e.serialize(t.factory)+")("+e.serialize(t.stream)+")"},deserialize(t,e){let n=e.deserialize(t.stream);return y7e(n)}},att=stt;const ltt={tag:"$TSR/Error",test(t){return t instanceof Error},parse:{sync(t,e){return{message:e.parse(t.message)}},async async(t,e){return{message:await e.parse(t.message)}},stream(t,e){return{message:e.parse(t.message)}}},serialize(t,e){return"new Error("+e.serialize(t.message)+")"},deserialize(t,e){return new Error(e.deserialize(t.message))}};class ctt{constructor(e,n){this.stream=e,this.hint=n?.hint??"binary"}}const bC=globalThis.Buffer,w7e=!!bC&&typeof bC.from=="function";function k7e(t){if(t.length===0)return"";if(w7e)return bC.from(t).toString("base64");const e=32768,n=[];for(let r=0;r<t.length;r+=e){const o=t.subarray(r,r+e);n.push(String.fromCharCode.apply(null,o))}return btoa(n.join(""))}function O7e(t){if(t.length===0)return new Uint8Array(0);if(w7e){const r=bC.from(t,"base64");return new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}const e=atob(t),n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return n}const a9=Object.create(null),l9=Object.create(null),utt=t=>new ReadableStream({start(e){t.on({next(n){try{e.enqueue(O7e(n))}catch{}},throw(n){e.error(n)},return(){try{e.close()}catch{}}})}}),dtt=new TextEncoder,ftt=t=>new ReadableStream({start(e){t.on({next(n){try{typeof n=="string"?e.enqueue(dtt.encode(n)):e.enqueue(O7e(n.$b64))}catch{}},throw(n){e.error(n)},return(){try{e.close()}catch{}}})}}),htt="(s=>new ReadableStream({start(c){s.on({next(b){try{const d=atob(b),a=new Uint8Array(d.length);for(let i=0;i<d.length;i++)a[i]=d.charCodeAt(i);c.enqueue(a)}catch(_){}},throw(e){c.error(e)},return(){try{c.close()}catch(_){}}})}}))",ptt="(s=>{const e=new TextEncoder();return new ReadableStream({start(c){s.on({next(v){try{if(typeof v==='string'){c.enqueue(e.encode(v))}else{const d=atob(v.$b64),a=new Uint8Array(d.length);for(let i=0;i<d.length;i++)a[i]=d.charCodeAt(i);c.enqueue(a)}}catch(_){}},throw(x){c.error(x)},return(){try{c.close()}catch(_){}}})}})})";function Ise(t){const e=x4(),n=t.getReader();return(async()=>{try{for(;;){const{done:r,value:o}=await n.read();if(r){e.return(void 0);break}e.next(k7e(o))}}catch(r){e.throw(r)}finally{n.releaseLock()}})(),e}function Dse(t){const e=x4(),n=t.getReader(),r=new TextDecoder("utf-8",{fatal:!0});return(async()=>{try{for(;;){const{done:o,value:i}=await n.read();if(o){try{const s=r.decode();s.length>0&&e.next(s)}catch{}e.return(void 0);break}try{const s=r.decode(i,{stream:!0});s.length>0&&e.next(s)}catch{e.next({$b64:k7e(i)})}}}catch(o){e.throw(o)}finally{n.releaseLock()}})(),e}const mtt={tag:"tss/RawStreamFactory",test(t){return t===a9},parse:{sync(){},async(){return Promise.resolve(void 0)},stream(){}},serialize(){return htt},deserialize(){return a9}},gtt={tag:"tss/RawStreamFactoryText",test(t){return t===l9},parse:{sync(){},async(){return Promise.resolve(void 0)},stream(){}},serialize(){return ptt},deserialize(){return l9}},vtt={tag:"tss/RawStream",extends:[mtt,gtt],test(t){return t instanceof ctt},parse:{sync(t,e){const n=t.hint==="text"?l9:a9;return{hint:t.hint,factory:e.parse(n),stream:e.parse(x4())}},async async(t,e){const n=t.hint==="text"?l9:a9,r=t.hint==="text"?Dse(t.stream):Ise(t.stream);return{hint:t.hint,factory:await e.parse(n),stream:await e.parse(r)}},stream(t,e){const n=t.hint==="text"?l9:a9,r=t.hint==="text"?Dse(t.stream):Ise(t.stream);return{hint:t.hint,factory:e.parse(n),stream:e.parse(r)}}},serialize(t,e){return"("+e.serialize(t.factory)+")("+e.serialize(t.stream)+")"},deserialize(t,e){const n=e.deserialize(t.stream);return t.hint==="text"?ftt(n):utt(n)}};function btt(t){return{tag:"tss/RawStream",test:()=>!1,parse:{},serialize(){throw new Error("RawStreamDeserializePlugin.serialize should not be called. Client only deserializes.")},deserialize(e){return t(e.streamId)}}}const _tt=[ltt,vtt,att];var vI={exports:{}},Vn={};var zse;function xtt(){if(zse)return Vn;zse=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),i=Symbol.for("react.consumer"),s=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),c=Symbol.for("react.memo"),u=Symbol.for("react.lazy"),d=Symbol.for("react.activity"),h=Symbol.iterator;function p(Z){return Z===null||typeof Z!="object"?null:(Z=h&&Z[h]||Z["@@iterator"],typeof Z=="function"?Z:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,x={};function y(Z,U,B){this.props=Z,this.context=U,this.refs=x,this.updater=B||g}y.prototype.isReactComponent={},y.prototype.setState=function(Z,U){if(typeof Z!="object"&&typeof Z!="function"&&Z!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,Z,U,"setState")},y.prototype.forceUpdate=function(Z){this.updater.enqueueForceUpdate(this,Z,"forceUpdate")};function k(){}k.prototype=y.prototype;function O(Z,U,B){this.props=Z,this.context=U,this.refs=x,this.updater=B||g}var C=O.prototype=new k;C.constructor=O,_(C,y.prototype),C.isPureReactComponent=!0;var A=Array.isArray;function E(){}var M={H:null,A:null,T:null,S:null},P=Object.prototype.hasOwnProperty;function L(Z,U,B){var ee=B.ref;return{$$typeof:t,type:Z,key:U,ref:ee!==void 0?ee:null,props:B}}function D(Z,U){return L(Z.type,U,Z.props)}function I(Z){return typeof Z=="object"&&Z!==null&&Z.$$typeof===t}function z(Z){var U={"=":"=0",":":"=2"};return"$"+Z.replace(/[=:]/g,function(B){return U[B]})}var Y=/\/+/g;function Q(Z,U){return typeof Z=="object"&&Z!==null&&Z.key!=null?z(""+Z.key):U.toString(36)}function H(Z){switch(Z.status){case"fulfilled":return Z.value;case"rejected":throw Z.reason;default:switch(typeof Z.status=="string"?Z.then(E,E):(Z.status="pending",Z.then(function(U){Z.status==="pending"&&(Z.status="fulfilled",Z.value=U)},function(U){Z.status==="pending"&&(Z.status="rejected",Z.reason=U)})),Z.status){case"fulfilled":return Z.value;case"rejected":throw Z.reason}}throw Z}function N(Z,U,B,ee,te){var se=typeof Z;(se==="undefined"||se==="boolean")&&(Z=null);var ae=!1;if(Z===null)ae=!0;else switch(se){case"bigint":case"string":case"number":ae=!0;break;case"object":switch(Z.$$typeof){case t:case e:ae=!0;break;case u:return ae=Z._init,N(ae(Z._payload),U,B,ee,te)}}if(ae)return te=te(Z),ae=ee===""?"."+Q(Z,0):ee,A(te)?(B="",ae!=null&&(B=ae.replace(Y,"$&/")+"/"),N(te,U,B,"",function(be){return be})):te!=null&&(I(te)&&(te=D(te,B+(te.key==null||Z&&Z.key===te.key?"":(""+te.key).replace(Y,"$&/")+"/")+ae)),U.push(te)),1;ae=0;var he=ee===""?".":ee+":";if(A(Z))for(var fe=0;fe<Z.length;fe++)ee=Z[fe],se=he+Q(ee,fe),ae+=N(ee,U,B,se,te);else if(fe=p(Z),typeof fe=="function")for(Z=fe.call(Z),fe=0;!(ee=Z.next()).done;)ee=ee.value,se=he+Q(ee,fe++),ae+=N(ee,U,B,se,te);else if(se==="object"){if(typeof Z.then=="function")return N(H(Z),U,B,ee,te);throw U=String(Z),Error("Objects are not valid as a React child (found: "+(U==="[object Object]"?"object with keys {"+Object.keys(Z).join(", ")+"}":U)+"). If you meant to render a collection of children, use an array instead.")}return ae}function V(Z,U,B){if(Z==null)return Z;var ee=[],te=0;return N(Z,ee,"","",function(se){return U.call(B,se,te++)}),ee}function G(Z){if(Z._status===-1){var U=Z._result;U=U(),U.then(function(B){(Z._status===0||Z._status===-1)&&(Z._status=1,Z._result=B)},function(B){(Z._status===0||Z._status===-1)&&(Z._status=2,Z._result=B)}),Z._status===-1&&(Z._status=0,Z._result=U)}if(Z._status===1)return Z._result.default;throw Z._result}var K=typeof reportError=="function"?reportError:function(Z){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var U=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof Z=="object"&&Z!==null&&typeof Z.message=="string"?String(Z.message):String(Z),error:Z});if(!window.dispatchEvent(U))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",Z);return}console.error(Z)},q={map:V,forEach:function(Z,U,B){V(Z,function(){U.apply(this,arguments)},B)},count:function(Z){var U=0;return V(Z,function(){U++}),U},toArray:function(Z){return V(Z,function(U){return U})||[]},only:function(Z){if(!I(Z))throw Error("React.Children.only expected to receive a single React element child.");return Z}};return Vn.Activity=d,Vn.Children=q,Vn.Component=y,Vn.Fragment=n,Vn.Profiler=o,Vn.PureComponent=O,Vn.StrictMode=r,Vn.Suspense=l,Vn.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=M,Vn.__COMPILER_RUNTIME={__proto__:null,c:function(Z){return M.H.useMemoCache(Z)}},Vn.cache=function(Z){return function(){return Z.apply(null,arguments)}},Vn.cacheSignal=function(){return null},Vn.cloneElement=function(Z,U,B){if(Z==null)throw Error("The argument must be a React element, but you passed "+Z+".");var ee=_({},Z.props),te=Z.key;if(U!=null)for(se in U.key!==void 0&&(te=""+U.key),U)!P.call(U,se)||se==="key"||se==="__self"||se==="__source"||se==="ref"&&U.ref===void 0||(ee[se]=U[se]);var se=arguments.length-2;if(se===1)ee.children=B;else if(1<se){for(var ae=Array(se),he=0;he<se;he++)ae[he]=arguments[he+2];ee.children=ae}return L(Z.type,te,ee)},Vn.createContext=function(Z){return Z={$$typeof:s,_currentValue:Z,_currentValue2:Z,_threadCount:0,Provider:null,Consumer:null},Z.Provider=Z,Z.Consumer={$$typeof:i,_context:Z},Z},Vn.createElement=function(Z,U,B){var ee,te={},se=null;if(U!=null)for(ee in U.key!==void 0&&(se=""+U.key),U)P.call(U,ee)&&ee!=="key"&&ee!=="__self"&&ee!=="__source"&&(te[ee]=U[ee]);var ae=arguments.length-2;if(ae===1)te.children=B;else if(1<ae){for(var he=Array(ae),fe=0;fe<ae;fe++)he[fe]=arguments[fe+2];te.children=he}if(Z&&Z.defaultProps)for(ee in ae=Z.defaultProps,ae)te[ee]===void 0&&(te[ee]=ae[ee]);return L(Z,se,te)},Vn.createRef=function(){return{current:null}},Vn.forwardRef=function(Z){return{$$typeof:a,render:Z}},Vn.isValidElement=I,Vn.lazy=function(Z){return{$$typeof:u,_payload:{_status:-1,_result:Z},_init:G}},Vn.memo=function(Z,U){return{$$typeof:c,type:Z,compare:U===void 0?null:U}},Vn.startTransition=function(Z){var U=M.T,B={};M.T=B;try{var ee=Z(),te=M.S;te!==null&&te(B,ee),typeof ee=="object"&&ee!==null&&typeof ee.then=="function"&&ee.then(E,K)}catch(se){K(se)}finally{U!==null&&B.types!==null&&(U.types=B.types),M.T=U}},Vn.unstable_useCacheRefresh=function(){return M.H.useCacheRefresh()},Vn.use=function(Z){return M.H.use(Z)},Vn.useActionState=function(Z,U,B){return M.H.useActionState(Z,U,B)},Vn.useCallback=function(Z,U){return M.H.useCallback(Z,U)},Vn.useContext=function(Z){return M.H.useContext(Z)},Vn.useDebugValue=function(){},Vn.useDeferredValue=function(Z,U){return M.H.useDeferredValue(Z,U)},Vn.useEffect=function(Z,U){return M.H.useEffect(Z,U)},Vn.useEffectEvent=function(Z){return M.H.useEffectEvent(Z)},Vn.useId=function(){return M.H.useId()},Vn.useImperativeHandle=function(Z,U,B){return M.H.useImperativeHandle(Z,U,B)},Vn.useInsertionEffect=function(Z,U){return M.H.useInsertionEffect(Z,U)},Vn.useLayoutEffect=function(Z,U){return M.H.useLayoutEffect(Z,U)},Vn.useMemo=function(Z,U){return M.H.useMemo(Z,U)},Vn.useOptimistic=function(Z,U){return M.H.useOptimistic(Z,U)},Vn.useReducer=function(Z,U,B){return M.H.useReducer(Z,U,B)},Vn.useRef=function(Z){return M.H.useRef(Z)},Vn.useState=function(Z){return M.H.useState(Z)},Vn.useSyncExternalStore=function(Z,U,B){return M.H.useSyncExternalStore(Z,U,B)},Vn.useTransition=function(){return M.H.useTransition()},Vn.version="19.2.4",Vn}var $se;function Mg(){return $se||($se=1,vI.exports=xtt()),vI.exports}var v=Mg();const Bt=Y0(v),lM=oXe({__proto__:null,default:Bt},[v]),ytt="use",_C=lM[ytt],Av=typeof window<"u"?v.useLayoutEffect:v.useEffect;function bI(t){const e=v.useRef({value:t,prev:null}),n=e.current.value;return t!==n&&(e.current={value:t,prev:n}),e.current.prev}function wtt(t,e,n={},r={}){v.useEffect(()=>{if(!t.current||r.disabled||typeof IntersectionObserver!="function")return;const o=new IntersectionObserver(([i])=>{e(i)},n);return o.observe(t.current),()=>{o.disconnect()}},[e,n,r.disabled,t])}function ktt(t){const e=v.useRef(null);return v.useImperativeHandle(t,()=>e.current,[]),e}function Ott({promise:t}){if(_C)return _C(t);const e=CKe(t);if(e[L1].status==="pending")throw e;if(e[L1].status==="error")throw e[L1].error;return e[L1].data}function Stt(t){const e=f.jsx(Ctt,{...t});return t.fallback?f.jsx(v.Suspense,{fallback:t.fallback,children:e}):e}function Ctt(t){const e=Ott(t);return t.children(e)}function nZ(t){const e=t.errorComponent??rZ;return f.jsx(Att,{getResetKey:t.getResetKey,onCatch:t.onCatch,children:({error:n,reset:r})=>n?v.createElement(e,{error:n,reset:r}):t.children})}class Att extends v.Component{constructor(){super(...arguments),this.state={error:null}}static getDerivedStateFromProps(e){return{resetKey:e.getResetKey()}}static getDerivedStateFromError(e){return{error:e}}reset(){this.setState({error:null})}componentDidUpdate(e,n){n.error&&n.resetKey!==this.state.resetKey&&this.reset()}componentDidCatch(e,n){this.props.onCatch&&this.props.onCatch(e,n)}render(){return this.props.children({error:this.state.resetKey!==this.props.getResetKey()?null:this.state.error,reset:()=>{this.reset()}})}}function rZ({error:t}){const[e,n]=v.useState(!1);return f.jsxs("div",{style:{padding:".5rem",maxWidth:"100%"},children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:".5rem"},children:[f.jsx("strong",{style:{fontSize:"1rem"},children:"Something went wrong!"}),f.jsx("button",{style:{appearance:"none",fontSize:".6em",border:"1px solid currentColor",padding:".1rem .2rem",fontWeight:"bold",borderRadius:".25rem"},onClick:()=>n(r=>!r),children:e?"Hide Error":"Show Error"})]}),f.jsx("div",{style:{height:".25rem"}}),e?f.jsx("div",{children:f.jsx("pre",{style:{fontSize:".7em",border:"1px solid red",borderRadius:".25rem",padding:".3rem",color:"red",overflow:"auto"},children:t.message?f.jsx("code",{children:t.message}):null})}):null]})}function Ett({children:t,fallback:e=null}){return oZ()?f.jsx(Bt.Fragment,{children:t}):f.jsx(Bt.Fragment,{children:e})}function oZ(){return Bt.useSyncExternalStore(Ttt,()=>!0,()=>!1)}function Ttt(){return()=>{}}var _I={exports:{}},xI={},yI={exports:{}},wI={};var Bse;function Mtt(){if(Bse)return wI;Bse=1;var t=Mg();function e(d,h){return d===h&&(d!==0||1/d===1/h)||d!==d&&h!==h}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,o=t.useEffect,i=t.useLayoutEffect,s=t.useDebugValue;function a(d,h){var p=h(),g=r({inst:{value:p,getSnapshot:h}}),_=g[0].inst,x=g[1];return i(function(){_.value=p,_.getSnapshot=h,l(_)&&x({inst:_})},[d,p,h]),o(function(){return l(_)&&x({inst:_}),d(function(){l(_)&&x({inst:_})})},[d]),s(p),p}function l(d){var h=d.getSnapshot;d=d.value;try{var p=h();return!n(d,p)}catch{return!0}}function c(d,h){return h()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:a;return wI.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:u,wI}var Hse;function Ptt(){return Hse||(Hse=1,yI.exports=Mtt()),yI.exports}var Fse;function jtt(){if(Fse)return xI;Fse=1;var t=Mg(),e=Ptt();function n(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var r=typeof Object.is=="function"?Object.is:n,o=e.useSyncExternalStore,i=t.useRef,s=t.useEffect,a=t.useMemo,l=t.useDebugValue;return xI.useSyncExternalStoreWithSelector=function(c,u,d,h,p){var g=i(null);if(g.current===null){var _={hasValue:!1,value:null};g.current=_}else _=g.current;g=a(function(){function y(E){if(!k){if(k=!0,O=E,E=h(E),p!==void 0&&_.hasValue){var M=_.value;if(p(M,E))return C=M}return C=E}if(M=C,r(O,E))return M;var P=h(E);return p!==void 0&&p(M,P)?(O=E,M):(O=E,C=P)}var k=!1,O,C,A=d===void 0?null:d;return[function(){return y(u())},A===null?void 0:function(){return y(A())}]},[u,d,h,p]);var x=o(c,g[0],g[1]);return s(function(){_.hasValue=!0,_.value=x},[x]),l(x),x},xI}var qse;function Ntt(){return qse||(qse=1,_I.exports=jtt()),_I.exports}var S7e=Ntt();function Rtt(t,e){return t===e}function Ltt(t,e,n=Rtt){const r=v.useCallback(s=>{if(!t)return()=>{};const{unsubscribe:a}=t.subscribe(s);return a},[t]),o=v.useCallback(()=>t?.get(),[t]);return S7e.useSyncExternalStoreWithSelector(r,o,o,e,n)}const C7e=v.createContext(null);function ns(t){const e=v.useContext(C7e);return t?.warn,e}function Mo(t){const e=ns({warn:t?.router===void 0}),n=t?.router||e,r=v.useRef(void 0);return Ltt(n.__store,o=>{if(t?.select){if(t.structuralSharing??n.options.defaultStructuralSharing){const i=Hl(r.current,t.select(o));return r.current=i,i}return t.select(o)}return o})}const cM=v.createContext(void 0),Itt=v.createContext(void 0);function iu(t){const e=v.useContext(t.from?Itt:cM);return Mo({select:r=>{const o=r.matches.find(i=>t.from?t.from===i.routeId:i.id===e);if(Xl(!((t.shouldThrow??!0)&&!o),`Could not find ${t.from?`an active match from "${t.from}"`:"a nearest match!"}`),o!==void 0)return t.select?t.select(o):o},structuralSharing:t.structuralSharing})}function iZ(t){return iu({from:t.from,strict:t.strict,structuralSharing:t.structuralSharing,select:e=>t.select?t.select(e.loaderData):e.loaderData})}function sZ(t){const{select:e,...n}=t;return iu({...n,select:r=>e?e(r.loaderDeps):r.loaderDeps})}function aZ(t){return iu({from:t.from,shouldThrow:t.shouldThrow,structuralSharing:t.structuralSharing,strict:t.strict,select:e=>{const n=t.strict===!1?e.params:e._strictParams;return t.select?t.select(n):n}})}function lZ(t){return iu({from:t.from,strict:t.strict,shouldThrow:t.shouldThrow,structuralSharing:t.structuralSharing,select:e=>t.select?t.select(e.search):e.search})}function uM(t){const e=ns();return v.useCallback(n=>e.navigate({...n,from:n.from??t?.from}),[t?.from,e])}function DJn(t){const e=ns(),n=uM(),r=v.useRef(null);return Av(()=>{r.current!==t&&(n(t),r.current=t)},[e,t,n]),null}var kI={exports:{}},Ks={};var Vse;function Dtt(){if(Vse)return Ks;Vse=1;var t=Mg();function e(l){var c="https://react.dev/errors/"+l;if(1<arguments.length){c+="?args[]="+encodeURIComponent(arguments[1]);for(var u=2;u<arguments.length;u++)c+="&args[]="+encodeURIComponent(arguments[u])}return"Minified React error #"+l+"; visit "+c+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(e(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},o=Symbol.for("react.portal");function i(l,c,u){var d=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:d==null?null:""+d,children:l,containerInfo:c,implementation:u}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function a(l,c){if(l==="font")return"";if(typeof c=="string")return c==="use-credentials"?c:""}return Ks.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Ks.createPortal=function(l,c){var u=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!c||c.nodeType!==1&&c.nodeType!==9&&c.nodeType!==11)throw Error(e(299));return i(l,c,null,u)},Ks.flushSync=function(l){var c=s.T,u=r.p;try{if(s.T=null,r.p=2,l)return l()}finally{s.T=c,r.p=u,r.d.f()}},Ks.preconnect=function(l,c){typeof l=="string"&&(c?(c=c.crossOrigin,c=typeof c=="string"?c==="use-credentials"?c:"":void 0):c=null,r.d.C(l,c))},Ks.prefetchDNS=function(l){typeof l=="string"&&r.d.D(l)},Ks.preinit=function(l,c){if(typeof l=="string"&&c&&typeof c.as=="string"){var u=c.as,d=a(u,c.crossOrigin),h=typeof c.integrity=="string"?c.integrity:void 0,p=typeof c.fetchPriority=="string"?c.fetchPriority:void 0;u==="style"?r.d.S(l,typeof c.precedence=="string"?c.precedence:void 0,{crossOrigin:d,integrity:h,fetchPriority:p}):u==="script"&&r.d.X(l,{crossOrigin:d,integrity:h,fetchPriority:p,nonce:typeof c.nonce=="string"?c.nonce:void 0})}},Ks.preinitModule=function(l,c){if(typeof l=="string")if(typeof c=="object"&&c!==null){if(c.as==null||c.as==="script"){var u=a(c.as,c.crossOrigin);r.d.M(l,{crossOrigin:u,integrity:typeof c.integrity=="string"?c.integrity:void 0,nonce:typeof c.nonce=="string"?c.nonce:void 0})}}else c==null&&r.d.M(l)},Ks.preload=function(l,c){if(typeof l=="string"&&typeof c=="object"&&c!==null&&typeof c.as=="string"){var u=c.as,d=a(u,c.crossOrigin);r.d.L(l,u,{crossOrigin:d,integrity:typeof c.integrity=="string"?c.integrity:void 0,nonce:typeof c.nonce=="string"?c.nonce:void 0,type:typeof c.type=="string"?c.type:void 0,fetchPriority:typeof c.fetchPriority=="string"?c.fetchPriority:void 0,referrerPolicy:typeof c.referrerPolicy=="string"?c.referrerPolicy:void 0,imageSrcSet:typeof c.imageSrcSet=="string"?c.imageSrcSet:void 0,imageSizes:typeof c.imageSizes=="string"?c.imageSizes:void 0,media:typeof c.media=="string"?c.media:void 0})}},Ks.preloadModule=function(l,c){if(typeof l=="string")if(c){var u=a(c.as,c.crossOrigin);r.d.m(l,{as:typeof c.as=="string"&&c.as!=="script"?c.as:void 0,crossOrigin:u,integrity:typeof c.integrity=="string"?c.integrity:void 0})}else r.d.m(l)},Ks.requestFormReset=function(l){r.d.r(l)},Ks.unstable_batchedUpdates=function(l,c){return l(c)},Ks.useFormState=function(l,c,u){return s.H.useFormState(l,c,u)},Ks.useFormStatus=function(){return s.H.useHostTransitionStatus()},Ks.version="19.2.4",Ks}var Qse;function A7e(){if(Qse)return kI.exports;Qse=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),kI.exports=Dtt(),kI.exports}var Bs=A7e();const ztt=Y0(Bs);function $tt(t,e){const n=ns(),r=ktt(e),{activeProps:o,inactiveProps:i,activeOptions:s,to:a,preload:l,preloadDelay:c,hashScrollIntoView:u,replace:d,startTransition:h,resetScroll:p,viewTransition:g,children:_,target:x,disabled:y,style:k,className:O,onClick:C,onBlur:A,onFocus:E,onMouseEnter:M,onMouseLeave:P,onTouchStart:L,ignoreBlocker:D,params:I,search:z,hash:Y,state:Q,mask:H,reloadDocument:N,unsafeRelative:V,from:G,_fromLocation:K,...q}=t,Z=oZ(),U=Mo({select:ue=>{const Pe=ue.matches[ue.matches.length-1];return{search:Pe?.search,hash:ue.location.hash,path:Pe?.pathname}},structuralSharing:!0}),B=t.from,ee=v.useMemo(()=>({...t,from:B}),[n,U,B,t._fromLocation,t.hash,t.to,t.search,t.params,t.state,t.mask,t.unsafeRelative]),te=v.useMemo(()=>n.buildLocation({...ee}),[n,ee]),se=te.maskedLocation?te.maskedLocation.publicHref:te.publicHref,ae=te.maskedLocation?te.maskedLocation.external:te.external,he=v.useMemo(()=>Qtt(se,ae,n.history,y),[y,ae,se,n.history]),fe=v.useMemo(()=>{if(he?.external)return fC(he.href,n.protocolAllowlist)?void 0:he.href;if(!Utt(a)&&!(typeof a!="string"||a.indexOf(":")===-1))try{return new URL(a),fC(a,n.protocolAllowlist)?void 0:a}catch{}},[a,he,n.protocolAllowlist]),be=Mo({select:ue=>{if(fe)return!1;if(s?.exact){if(!WXe(ue.location.pathname,te.pathname,n.basepath))return!1}else{const Pe=pC(ue.location.pathname,n.basepath),Ee=pC(te.pathname,n.basepath);if(!(Pe.startsWith(Ee)&&(Pe.length===Ee.length||Pe[Ee.length]==="/")))return!1}return(s?.includeSearch??!0)&&!p3(ue.location.search,te.search,{partial:!s?.exact,ignoreUndefined:!s?.explicitUndefined})?!1:s?.includeHash?Z&&ue.location.hash===te.hash:!0}}),me=be?Mf(o,{})??Btt:OI,le=be?OI:Mf(i,{})??OI,Be=[O,me.className,le.className].filter(Boolean).join(" "),Xe=(k||me.style||le.style)&&{...k,...me.style,...le.style},[ot,Qe]=v.useState(!1),lt=v.useRef(!1),bt=t.reloadDocument||fe?!1:l??n.options.defaultPreload,ve=c??n.options.defaultPreloadDelay??0,Te=v.useCallback(()=>{n.preloadRoute({...ee,_builtLocation:te}).catch(ue=>{console.warn(ue),console.warn(AKe)})},[n,ee,te]),pe=v.useCallback(ue=>{ue?.isIntersecting&&Te()},[Te]);wtt(r,pe,Vtt,{disabled:!!y||bt!=="viewport"}),v.useEffect(()=>{lt.current||!y&&bt==="render"&&(Te(),lt.current=!0)},[y,Te,bt]);const Ne=ue=>{const Pe=ue.currentTarget.getAttribute("target"),Ee=x!==void 0?x:Pe;if(!y&&!Wtt(ue)&&!ue.defaultPrevented&&(!Ee||Ee==="_self")&&ue.button===0){ue.preventDefault(),Bs.flushSync(()=>{Qe(!0)});const Le=n.subscribe("onResolved",()=>{Le(),Qe(!1)});n.navigate({...ee,replace:d,resetScroll:p,hashScrollIntoView:u,startTransition:h,viewTransition:g,ignoreBlocker:D})}};if(fe)return{...q,ref:r,href:fe,..._&&{children:_},...x&&{target:x},...y&&{disabled:y},...k&&{style:k},...O&&{className:O},...C&&{onClick:C},...A&&{onBlur:A},...E&&{onFocus:E},...M&&{onMouseEnter:M},...P&&{onMouseLeave:P},...L&&{onTouchStart:L}};const $e=ue=>{if(y||bt!=="intent")return;if(!ve){Te();return}const Pe=ue.currentTarget;if(w7.has(Pe))return;const Ee=setTimeout(()=>{w7.delete(Pe),Te()},ve);w7.set(Pe,Ee)},De=ue=>{y||bt!=="intent"||Te()},ct=ue=>{if(y||!bt||!ve)return;const Pe=ue.currentTarget,Ee=w7.get(Pe);Ee&&(clearTimeout(Ee),w7.delete(Pe))};return{...q,...me,...le,href:he?.href,ref:r,onClick:Mm([C,Ne]),onBlur:Mm([A,ct]),onFocus:Mm([E,$e]),onMouseEnter:Mm([M,$e]),onMouseLeave:Mm([P,ct]),onTouchStart:Mm([L,De]),disabled:!!y,target:x,...Xe&&{style:Xe},...Be&&{className:Be},...y&&Htt,...be&&Ftt,...Z&&ot&&qtt}}const OI={},Btt={className:"active"},Htt={role:"link","aria-disabled":!0},Ftt={"data-status":"active","aria-current":"page"},qtt={"data-transitioning":"transitioning"},w7=new WeakMap,Vtt={rootMargin:"100px"},Mm=t=>e=>{for(const n of t)if(n){if(e.defaultPrevented)return;n(e)}};function Qtt(t,e,n,r){if(!r)return e?{href:t,external:!0}:{href:n.createHref(t)||"/",external:!1}}function Utt(t){if(typeof t!="string")return!1;const e=t.charCodeAt(0);return e===47?t.charCodeAt(1)!==47:e===46}const cZ=v.forwardRef((t,e)=>{const{_asChild:n,...r}=t,{type:o,...i}=$tt(r,e),s=typeof r.children=="function"?r.children({isActive:i["data-status"]==="active"}):r.children;if(!n){const{disabled:a,...l}=i;return v.createElement("a",l,s)}return v.createElement(n,i,s)});function Wtt(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}let Ztt=class extends U8e{constructor(e){super(e),this.useMatch=n=>iu({select:n?.select,from:this.id,structuralSharing:n?.structuralSharing}),this.useRouteContext=n=>iu({...n,from:this.id,select:r=>n?.select?n.select(r.context):r.context}),this.useSearch=n=>lZ({select:n?.select,structuralSharing:n?.structuralSharing,from:this.id}),this.useParams=n=>aZ({select:n?.select,structuralSharing:n?.structuralSharing,from:this.id}),this.useLoaderDeps=n=>sZ({...n,from:this.id}),this.useLoaderData=n=>iZ({...n,from:this.id}),this.useNavigate=()=>uM({from:this.fullPath}),this.Link=Bt.forwardRef((n,r)=>f.jsx(cZ,{ref:r,from:this.fullPath,...n})),this.$$typeof=Symbol.for("react.memo")}};function Gtt(t){return new Ztt(t)}class Ytt extends EKe{constructor(e){super(e),this.useMatch=n=>iu({select:n?.select,from:this.id,structuralSharing:n?.structuralSharing}),this.useRouteContext=n=>iu({...n,from:this.id,select:r=>n?.select?n.select(r.context):r.context}),this.useSearch=n=>lZ({select:n?.select,structuralSharing:n?.structuralSharing,from:this.id}),this.useParams=n=>aZ({select:n?.select,structuralSharing:n?.structuralSharing,from:this.id}),this.useLoaderDeps=n=>sZ({...n,from:this.id}),this.useLoaderData=n=>iZ({...n,from:this.id}),this.useNavigate=()=>uM({from:this.fullPath}),this.Link=Bt.forwardRef((n,r)=>f.jsx(cZ,{ref:r,from:this.fullPath,...n})),this.$$typeof=Symbol.for("react.memo")}}function Xtt(t){return new Ytt(t)}function xC(t){return typeof t=="object"?new Use(t,{silent:!0}).createRoute(t):new Use(t,{silent:!0}).createRoute}class Use{constructor(e,n){this.path=e,this.createRoute=r=>{const o=Gtt(r);return o.isRoot=!1,o},this.silent=n?.silent}}class Wse{constructor(e){this.useMatch=n=>iu({select:n?.select,from:this.options.id,structuralSharing:n?.structuralSharing}),this.useRouteContext=n=>iu({from:this.options.id,select:r=>n?.select?n.select(r.context):r.context}),this.useSearch=n=>lZ({select:n?.select,structuralSharing:n?.structuralSharing,from:this.options.id}),this.useParams=n=>aZ({select:n?.select,structuralSharing:n?.structuralSharing,from:this.options.id}),this.useLoaderDeps=n=>sZ({...n,from:this.options.id}),this.useLoaderData=n=>iZ({...n,from:this.options.id}),this.useNavigate=()=>{const n=ns();return uM({from:n.routesById[this.options.id].fullPath})},this.options=e,this.$$typeof=Symbol.for("react.memo")}}function Zse(t){return typeof t=="object"?new Wse(t):e=>new Wse({id:t,...e})}function QH(t,e){let n,r,o,i;const s=()=>(n||(n=t().then(l=>{n=void 0,r=l[e??"default"]}).catch(l=>{if(o=l,TXe(o)&&o instanceof Error&&typeof window<"u"&&typeof sessionStorage<"u"){const c=`tanstack_router_reload:${o.message}`;sessionStorage.getItem(c)||(sessionStorage.setItem(c,"1"),i=!0)}})),n),a=function(c){if(i)throw window.location.reload(),new Promise(()=>{});if(o)throw o;if(!r)if(_C)_C(s());else throw s();return v.createElement(r,c)};return a.preload=s,a}function Ktt(){const t=ns(),e=v.useRef({router:t,mounted:!1}),[n,r]=v.useState(!1),{hasPendingMatches:o,isLoading:i}=Mo({select:d=>({isLoading:d.isLoading,hasPendingMatches:d.matches.some(h=>h.status==="pending")}),structuralSharing:!0}),s=bI(i),a=i||n||o,l=bI(a),c=i||o,u=bI(c);return t.startTransition=d=>{r(!0),v.startTransition(()=>{d(),r(!1)})},v.useEffect(()=>{const d=t.history.subscribe(t.load),h=t.buildLocation({to:t.latestLocation.pathname,search:!0,params:!0,hash:!0,state:!0,_includeValidateSearch:!0});return Hf(t.latestLocation.publicHref)!==Hf(h.publicHref)&&t.commitLocation({...h,replace:!0}),()=>{d()}},[t,t.history]),Av(()=>{if(typeof window<"u"&&t.ssr||e.current.router===t&&e.current.mounted)return;e.current={router:t,mounted:!0},(async()=>{try{await t.load()}catch(h){console.error(h)}})()},[t]),Av(()=>{s&&!i&&t.emit({type:"onLoad",...m3(t.state)})},[s,t,i]),Av(()=>{u&&!c&&t.emit({type:"onBeforeRouteMount",...m3(t.state)})},[c,u,t]),Av(()=>{if(l&&!a){const d=m3(t.state);t.emit({type:"onResolved",...d}),t.__store.setState(h=>({...h,status:"idle",resolvedLocation:h.location})),d.hrefChanged&&rKe(t)}},[a,l,t]),null}function Jtt(t){const e=Mo({select:n=>`not-found-${n.location.pathname}-${n.status}`});return f.jsx(nZ,{getResetKey:()=>e,onCatch:(n,r)=>{if(la(n))t.onCatch?.(n,r);else throw n},errorComponent:({error:n})=>{if(la(n))return t.fallback?.(n);throw n},children:t.children})}function ent(){return f.jsx("p",{children:"Not Found"})}function u5(t){return f.jsx(f.Fragment,{children:t.children})}function E7e(t,e,n){return e.options.notFoundComponent?f.jsx(e.options.notFoundComponent,{...n}):t.options.defaultNotFoundComponent?f.jsx(t.options.defaultNotFoundComponent,{...n}):f.jsx(ent,{})}function tnt(){return ns().isScrollRestoring,null}const T7e=v.memo(function({matchId:e}){const n=ns(),r=Mo({select:_=>{const x=_.matches.findIndex(k=>k.id===e),y=_.matches[x];return Xl(y),{routeId:y.routeId,ssr:y.ssr,_displayPending:y._displayPending,resetKey:_.loadedAt,parentRouteId:_.matches[x-1]?.routeId}},structuralSharing:!0}),o=n.routesById[r.routeId],i=o.options.pendingComponent??n.options.defaultPendingComponent,s=i?f.jsx(i,{}):null,a=o.options.errorComponent??n.options.defaultErrorComponent,l=o.options.onCatch??n.options.defaultOnCatch,c=o.isRoot?o.options.notFoundComponent??n.options.notFoundRoute?.options.component:o.options.notFoundComponent,u=r.ssr===!1||r.ssr==="data-only",d=(!o.isRoot||o.options.wrapInSuspense||u)&&(o.options.wrapInSuspense??i??(o.options.errorComponent?.preload||u))?v.Suspense:u5,h=a?nZ:u5,p=c?Jtt:u5,g=o.isRoot?o.options.shellComponent??u5:u5;return f.jsxs(g,{children:[f.jsx(cM.Provider,{value:e,children:f.jsx(d,{fallback:s,children:f.jsx(h,{getResetKey:()=>r.resetKey,errorComponent:a||rZ,onCatch:(_,x)=>{if(la(_))throw _;l?.(_,x)},children:f.jsx(p,{fallback:_=>{if(!c||_.routeId&&_.routeId!==r.routeId||!_.routeId&&!o.isRoot)throw _;return v.createElement(c,_)},children:u||r._displayPending?f.jsx(Ett,{fallback:s,children:f.jsx(Gse,{matchId:e})}):f.jsx(Gse,{matchId:e})})})})}),r.parentRouteId===kc&&n.options.scrollRestoration?f.jsxs(f.Fragment,{children:[f.jsx(nnt,{}),f.jsx(tnt,{})]}):null]})});function nnt(){const t=ns(),e=v.useRef(void 0);return f.jsx("script",{suppressHydrationWarning:!0,ref:n=>{n&&(e.current===void 0||e.current.href!==t.latestLocation.href)&&(t.emit({type:"onRendered",...m3(t.state)}),e.current=t.latestLocation)}},t.latestLocation.state.__TSR_key)}const Gse=v.memo(function({matchId:e}){const n=ns(),{match:r,key:o,routeId:i}=Mo({select:l=>{const c=l.matches.find(g=>g.id===e),u=c.routeId,h=(n.routesById[u].options.remountDeps??n.options.defaultRemountDeps)?.({routeId:u,loaderDeps:c.loaderDeps,params:c._strictParams,search:c._strictSearch});return{key:h?JSON.stringify(h):void 0,routeId:u,match:{id:c.id,status:c.status,error:c.error,invalid:c.invalid,_forcePending:c._forcePending,_displayPending:c._displayPending}}},structuralSharing:!0}),s=n.routesById[i],a=v.useMemo(()=>{const l=s.options.component??n.options.defaultComponent;return l?f.jsx(l,{},o):f.jsx(UH,{})},[o,s.options.component,n.options.defaultComponent]);if(r._displayPending)throw n.getMatch(r.id)?._nonReactive.displayPendingPromise;if(r._forcePending)throw n.getMatch(r.id)?._nonReactive.minPendingPromise;if(r.status==="pending"){const l=s.options.pendingMinMs??n.options.defaultPendingMinMs;if(l){const c=n.getMatch(r.id);if(c&&!c._nonReactive.minPendingPromise){const u=C3();c._nonReactive.minPendingPromise=u,setTimeout(()=>{u.resolve(),c._nonReactive.minPendingPromise=void 0},l)}}throw n.getMatch(r.id)?._nonReactive.loadPromise}if(r.status==="notFound")return Xl(la(r.error)),E7e(n,s,r.error);if(r.status==="redirected")throw Xl(Zl(r.error)),n.getMatch(r.id)?._nonReactive.loadPromise;if(r.status==="error")throw r.error;return a}),UH=v.memo(function(){const e=ns(),n=v.useContext(cM),r=Mo({select:c=>c.matches.find(u=>u.id===n)?.routeId}),o=e.routesById[r],i=Mo({select:c=>{const d=c.matches.find(h=>h.id===n);return Xl(d),d.globalNotFound}}),s=Mo({select:c=>{const u=c.matches,d=u.findIndex(h=>h.id===n);return u[d+1]?.id}}),a=e.options.defaultPendingComponent?f.jsx(e.options.defaultPendingComponent,{}):null;if(i)return E7e(e,o,void 0);if(!s)return null;const l=f.jsx(T7e,{matchId:s});return r===kc?f.jsx(v.Suspense,{fallback:a,children:l}):l});function rnt(){const t=ns(),n=t.routesById[kc].options.pendingComponent??t.options.defaultPendingComponent,r=n?f.jsx(n,{}):null,o=typeof document<"u"&&t.ssr?u5:v.Suspense,i=f.jsxs(o,{fallback:r,children:[f.jsx(Ktt,{}),f.jsx(ont,{})]});return t.options.InnerWrap?f.jsx(t.options.InnerWrap,{children:i}):i}function ont(){const t=ns(),e=Mo({select:o=>o.matches[0]?.id}),n=Mo({select:o=>o.loadedAt}),r=e?f.jsx(T7e,{matchId:e}):null;return f.jsx(cM.Provider,{value:e,children:t.options.disableGlobalCatchBoundary?r:f.jsx(nZ,{getResetKey:()=>n,errorComponent:rZ,onCatch:void 0,children:r})})}const int=t=>new snt(t);class snt extends _Ke{constructor(e){super(e)}}typeof globalThis<"u"?(globalThis.createFileRoute=xC,globalThis.createLazyFileRoute=Zse):typeof window<"u"&&(window.createFileRoute=xC,window.createLazyFileRoute=Zse);function ant({router:t,children:e,...n}){Object.keys(n).length>0&&t.update({...t.options,...n,context:{...t.options.context,...n.context}});const r=f.jsx(C7e.Provider,{value:t,children:e});return t.options.Wrap?f.jsx(t.options.Wrap,{children:r}):r}function lnt({router:t,...e}){return f.jsx(ant,{router:t,...e,children:f.jsx(rnt,{})})}function M7e({tag:t,attrs:e,children:n,nonce:r}){switch(t){case"title":return f.jsx("title",{...e,suppressHydrationWarning:!0,children:n});case"meta":return f.jsx("meta",{...e,suppressHydrationWarning:!0});case"link":return f.jsx("link",{...e,nonce:r,suppressHydrationWarning:!0});case"style":return f.jsx("style",{...e,dangerouslySetInnerHTML:{__html:n},nonce:r});case"script":return f.jsx(cnt,{attrs:e,children:n});default:return null}}function cnt({attrs:t,children:e}){ns();const n=oZ(),r=typeof t?.type=="string"&&t.type!==""&&t.type!=="text/javascript"&&t.type!=="module";if(v.useEffect(()=>{if(!r){if(t?.src){const o=(()=>{try{const a=document.baseURI||window.location.href;return new URL(t.src,a).href}catch{return t.src}})();if(Array.from(document.querySelectorAll("script[src]")).find(a=>a.src===o))return;const s=document.createElement("script");for(const[a,l]of Object.entries(t))a!=="suppressHydrationWarning"&&l!==void 0&&l!==!1&&s.setAttribute(a,typeof l=="boolean"?"":String(l));return document.head.appendChild(s),()=>{s.parentNode&&s.parentNode.removeChild(s)}}if(typeof e=="string"){const o=typeof t?.type=="string"?t.type:"text/javascript",i=typeof t?.nonce=="string"?t.nonce:void 0;if(Array.from(document.querySelectorAll("script:not([src])")).find(l=>{if(!(l instanceof HTMLScriptElement))return!1;const c=l.getAttribute("type")??"text/javascript",u=l.getAttribute("nonce")??void 0;return l.textContent===e&&c===o&&u===i}))return;const a=document.createElement("script");if(a.textContent=e,t)for(const[l,c]of Object.entries(t))l!=="suppressHydrationWarning"&&c!==void 0&&c!==!1&&a.setAttribute(l,typeof c=="boolean"?"":String(c));return document.head.appendChild(a),()=>{a.parentNode&&a.parentNode.removeChild(a)}}}},[t,e,r]),r&&typeof e=="string")return f.jsx("script",{...t,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:e}});if(!n){if(t?.src)return f.jsx("script",{...t,suppressHydrationWarning:!0});if(typeof e=="string")return f.jsx("script",{...t,dangerouslySetInnerHTML:{__html:e},suppressHydrationWarning:!0})}return null}const unt=()=>{const t=ns(),e=t.options.ssr?.nonce,n=Mo({select:l=>l.matches.map(c=>c.meta).filter(Boolean)}),r=v.useMemo(()=>{const l=[],c={};let u;for(let d=n.length-1;d>=0;d--){const h=n[d];for(let p=h.length-1;p>=0;p--){const g=h[p];if(g)if(g.title)u||(u={tag:"title",children:g.title});else if("script:ld+json"in g)try{const _=JSON.stringify(g["script:ld+json"]);l.push({tag:"script",attrs:{type:"application/ld+json"},children:RXe(_)})}catch{}else{const _=g.name??g.property;if(_){if(c[_])continue;c[_]=!0}l.push({tag:"meta",attrs:{...g,nonce:e}})}}}return u&&l.push(u),e&&l.push({tag:"meta",attrs:{property:"csp-nonce",content:e}}),l.reverse(),l},[n,e]),o=Mo({select:l=>{const c=l.matches.map(h=>h.links).filter(Boolean).flat(1).map(h=>({tag:"link",attrs:{...h,nonce:e}})),u=t.ssr?.manifest,d=l.matches.map(h=>u?.routes[h.routeId]?.assets??[]).filter(Boolean).flat(1).filter(h=>h.tag==="link").map(h=>({tag:"link",attrs:{...h.attrs,suppressHydrationWarning:!0,nonce:e}}));return[...c,...d]},structuralSharing:!0}),i=Mo({select:l=>{const c=[];return l.matches.map(u=>t.looseRoutesById[u.routeId]).forEach(u=>t.ssr?.manifest?.routes[u.id]?.preloads?.filter(Boolean).forEach(d=>{c.push({tag:"link",attrs:{rel:"modulepreload",href:d,nonce:e}})})),c},structuralSharing:!0}),s=Mo({select:l=>l.matches.map(c=>c.styles).flat(1).filter(Boolean).map(({children:c,...u})=>({tag:"style",attrs:{...u,nonce:e},children:c})),structuralSharing:!0}),a=Mo({select:l=>l.matches.map(c=>c.headScripts).flat(1).filter(Boolean).map(({children:c,...u})=>({tag:"script",attrs:{...u,nonce:e},children:c})),structuralSharing:!0});return dnt([...r,...i,...o,...s,...a],l=>JSON.stringify(l))};function dnt(t,e){const n=new Set;return t.filter(r=>{const o=e(r);return n.has(o)?!1:(n.add(o),!0)})}function fnt(){const t=unt(),n=ns().options.ssr?.nonce;return f.jsx(f.Fragment,{children:t.map(r=>v.createElement(M7e,{...r,key:`tsr-meta-${JSON.stringify(r)}`,nonce:n}))})}const hnt=()=>{const t=ns(),e=t.options.ssr?.nonce,n=Mo({select:s=>{const a=[],l=t.ssr?.manifest;return l?(s.matches.map(c=>t.looseRoutesById[c.routeId]).forEach(c=>l.routes[c.id]?.assets?.filter(u=>u.tag==="script").forEach(u=>{a.push({tag:"script",attrs:{...u.attrs,nonce:e},children:u.children})})),a):[]},structuralSharing:!0}),{scripts:r}=Mo({select:s=>({scripts:s.matches.map(a=>a.scripts).flat(1).filter(Boolean).map(({children:a,...l})=>({tag:"script",attrs:{...l,suppressHydrationWarning:!0,nonce:e},children:a}))}),structuralSharing:!0});let o;t.serverSsr&&(o=t.serverSsr.takeBufferedScripts());const i=[...r,...n];return o&&i.unshift(o),f.jsx(f.Fragment,{children:i.map((s,a)=>v.createElement(M7e,{...s,key:`tsr-scripts-${s.tag}-${a}`}))})};function Yse(t){return t.replaceAll("\0","/").replaceAll("�","/")}function pnt(t,e){t.id=e.i,t.__beforeLoadContext=e.b,t.loaderData=e.l,t.status=e.s,t.ssr=e.ssr,t.updatedAt=e.u,t.error=e.e,e.g!==void 0&&(t.globalNotFound=e.g)}async function mnt(t){Xl(window.$_TSR);const e=t.options.serializationAdapters;if(e?.length){const x=new Map;e.forEach(y=>{x.set(y.key,y.fromSerializable)}),window.$_TSR.t=x,window.$_TSR.buffer.forEach(y=>y())}window.$_TSR.initialized=!0,Xl(window.$_TSR.router);const n=window.$_TSR.router;n.matches.forEach(x=>{x.i=Yse(x.i)}),n.lastMatchId&&(n.lastMatchId=Yse(n.lastMatchId));const{manifest:r,dehydratedData:o,lastMatchId:i}=n;t.ssr={manifest:r};const a=document.querySelector('meta[property="csp-nonce"]')?.content;t.options.ssr={nonce:a};const l=t.matchRoutes(t.state.location),c=Promise.all(l.map(x=>t.loadRouteChunk(t.looseRoutesById[x.routeId])));function u(x){const k=t.looseRoutesById[x.routeId].options.pendingMinMs??t.options.defaultPendingMinMs;if(k){const O=C3();x._nonReactive.minPendingPromise=O,x._forcePending=!0,setTimeout(()=>{O.resolve(),t.updateMatch(x.id,C=>(C._nonReactive.minPendingPromise=void 0,{...C,_forcePending:void 0}))},k)}}function d(x){const y=t.looseRoutesById[x.routeId];y&&(y.options.ssr=x.ssr)}let h;l.forEach(x=>{const y=n.matches.find(k=>k.i===x.id);if(!y){x._nonReactive.dehydrated=!1,x.ssr=!1,d(x);return}pnt(x,y),d(x),x._nonReactive.dehydrated=x.ssr!==!1,(x.ssr==="data-only"||x.ssr===!1)&&h===void 0&&(h=x.index,u(x))}),t.__store.setState(x=>({...x,matches:l})),await t.options.hydrate?.(o),await Promise.all(t.state.matches.map(async x=>{try{const y=t.looseRoutesById[x.routeId],O=t.state.matches[x.index-1]?.context??t.options.context;if(y.options.context){const M={deps:x.loaderDeps,params:x.params,context:O??{},location:t.state.location,navigate:P=>t.navigate({...P,_fromLocation:t.state.location}),buildLocation:t.buildLocation,cause:x.cause,abortController:x.abortController,preload:!1,matches:l,routeId:y.id};x.__routeContext=y.options.context(M)??void 0}x.context={...O,...x.__routeContext,...x.__beforeLoadContext};const C={ssr:t.options.ssr,matches:t.state.matches,match:x,params:x.params,loaderData:x.loaderData},A=await y.options.head?.(C),E=await y.options.scripts?.(C);x.meta=A?.meta,x.links=A?.links,x.headScripts=A?.scripts,x.styles=A?.styles,x.scripts=E}catch(y){if(la(y))x.error={isNotFound:!0},console.error(`NotFound error during hydration for routeId: ${x.routeId}`,y);else throw x.error=y,console.error(`Error during hydration for route ${x.routeId}:`,y),y}}));const p=l[l.length-1].id!==i;if(!l.some(x=>x.ssr===!1)&&!p)return l.forEach(x=>{x._nonReactive.dehydrated=void 0}),c;const _=Promise.resolve().then(()=>t.load()).catch(x=>{console.error("Error during router hydration:",x)});if(p){const x=l[1];Xl(x),u(x),x._displayPending=!0,x._nonReactive.displayPendingPromise=_,_.then(()=>{F5(()=>{t.__store.state.status==="pending"&&t.__store.setState(y=>({...y,status:"idle",resolvedLocation:y.location})),t.updateMatch(x.id,y=>({...y,_displayPending:void 0,displayPendingPromise:void 0}))})})}return c}const gnt="__TSS_CONTEXT",WH=Symbol.for("TSS_SERVER_FUNCTION"),vnt="x-tss-serialized",bnt="x-tss-raw",P7e="application/x-tss-framed",Ju={JSON:0,CHUNK:1,END:2,ERROR:3},Pm=9,Xse=1,_nt=/;\s*v=(\d+)/;function xnt(t){const e=t.match(_nt);return e?parseInt(e[1],10):void 0}function ynt(t){const e=xnt(t);if(e!==void 0&&e!==Xse)throw new Error(`Incompatible framed protocol version: server=${e}, client=${Xse}. Please ensure client and server are using compatible versions.`)}const j7e=()=>window.__TSS_START_OPTIONS__;function wnt(){return[...j7e()?.serializationAdapters?.map(ott)??[],..._tt]}const Kse=new TextDecoder,knt=new Uint8Array(0),Jse=16*1024*1024,eae=32*1024*1024,tae=1024,nae=1e5;function Ont(t){const e=new Map,n=new Map,r=new Set;let o=!1,i=null,s=0,a;const l=new ReadableStream({start(d){a=d},cancel(){o=!0;try{i?.cancel()}catch{}e.forEach(d=>{try{d.error(new Error("Framed response cancelled"))}catch{}}),e.clear(),n.clear(),r.clear()}});function c(d){const h=n.get(d);if(h)return h;if(r.has(d))return new ReadableStream({start(g){g.close()}});if(n.size>=tae)throw new Error(`Too many raw streams in framed response (max ${tae})`);const p=new ReadableStream({start(g){e.set(d,g)},cancel(){r.add(d),e.delete(d),n.delete(d)}});return n.set(d,p),p}function u(d){return c(d),e.get(d)}return(async()=>{const d=t.getReader();i=d;const h=[];let p=0;function g(){if(p<Pm)return null;const x=h[0];if(x.length>=Pm){const M=x[0],P=(x[1]<<24|x[2]<<16|x[3]<<8|x[4])>>>0,L=(x[5]<<24|x[6]<<16|x[7]<<8|x[8])>>>0;return{type:M,streamId:P,length:L}}const y=new Uint8Array(Pm);let k=0,O=Pm;for(let M=0;M<h.length&&O>0;M++){const P=h[M],L=Math.min(P.length,O);y.set(P.subarray(0,L),k),k+=L,O-=L}const C=y[0],A=(y[1]<<24|y[2]<<16|y[3]<<8|y[4])>>>0,E=(y[5]<<24|y[6]<<16|y[7]<<8|y[8])>>>0;return{type:C,streamId:A,length:E}}function _(x){if(x===0)return knt;const y=new Uint8Array(x);let k=0,O=x;for(;O>0&&h.length>0;){const C=h[0];if(!C)break;const A=Math.min(C.length,O);y.set(C.subarray(0,A),k),k+=A,O-=A,A===C.length?h.shift():h[0]=C.subarray(A)}return p-=x,y}try{for(;;){const{done:x,value:y}=await d.read();if(o||x)break;if(y){if(p+y.length>eae)throw new Error(`Framed response buffer exceeded ${eae} bytes`);for(h.push(y),p+=y.length;;){const k=g();if(!k)break;const{type:O,streamId:C,length:A}=k;if(O!==Ju.JSON&&O!==Ju.CHUNK&&O!==Ju.END&&O!==Ju.ERROR)throw new Error(`Unknown frame type: ${O}`);if(O===Ju.JSON){if(C!==0)throw new Error("Invalid JSON frame streamId (expected 0)")}else if(C===0)throw new Error("Invalid raw frame streamId (expected non-zero)");if(A>Jse)throw new Error(`Frame payload too large: ${A} bytes (max ${Jse})`);const E=Pm+A;if(p<E)break;if(++s>nae)throw new Error(`Too many frames in framed response (max ${nae})`);_(Pm);const M=_(A);switch(O){case Ju.JSON:{try{a.enqueue(Kse.decode(M))}catch{}break}case Ju.CHUNK:{const P=u(C);P&&P.enqueue(M);break}case Ju.END:{const P=u(C);if(r.add(C),P){try{P.close()}catch{}e.delete(C)}break}case Ju.ERROR:{const P=u(C);if(r.add(C),P){const L=Kse.decode(M);P.error(new Error(L)),e.delete(C)}break}}}}}if(p!==0)throw new Error("Incomplete frame at end of framed response");try{a.close()}catch{}e.forEach(x=>{try{x.close()}catch{}}),e.clear()}catch(x){try{a.error(x)}catch{}e.forEach(y=>{try{y.error(x)}catch{}}),e.clear()}finally{try{d.releaseLock()}catch{}i=null}})(),{getOrCreateStream:c,jsonChunks:l}}let U5=null;const Snt=Object.prototype.hasOwnProperty;function N7e(t){for(const e in t)if(Snt.call(t,e))return!0;return!1}async function Cnt(t,e,n){U5||(U5=wnt());const o=e[0],i=o.fetch??n,s=o.data instanceof FormData?"formData":"payload",a=o.headers?new Headers(o.headers):new Headers;if(a.set("x-tsr-serverFn","true"),s==="payload"&&a.set("accept",`${P7e}, application/x-ndjson, application/json`),o.method==="GET"){if(s==="formData")throw new Error("FormData is not supported with GET requests");const c=await R7e(o);if(c!==void 0){const u=z8e({payload:c});t.includes("?")?t+=`&${u}`:t+=`?${u}`}}let l;if(o.method==="POST"){const c=await Ant(o);c?.contentType&&a.set("content-type",c.contentType),l=c?.body}return await Ent(async()=>i(t,{method:o.method,headers:a,signal:o.signal,body:l}))}async function R7e(t){let e=!1;const n={};if(t.data!==void 0&&(e=!0,n.data=t.data),t.context&&N7e(t.context)&&(e=!0,n.context=t.context),e)return L7e(n)}async function L7e(t){return JSON.stringify(await Promise.resolve(rtt(t,{plugins:U5})))}async function Ant(t){if(t.data instanceof FormData){let n;return t.context&&N7e(t.context)&&(n=await L7e(t.context)),n!==void 0&&t.data.set(gnt,n),{body:t.data}}const e=await R7e(t);if(e)return{body:e,contentType:"application/json"}}async function Ent(t){let e;try{e=await t()}catch(o){if(o instanceof Response)e=o;else throw console.log(o),o}if(e.headers.get(bnt)==="true")return e;const n=e.headers.get("content-type");if(Xl(n),!!e.headers.get(vnt)){let o;if(n.includes(P7e)){if(ynt(n),!e.body)throw new Error("No response body for framed response");const{getOrCreateStream:i,jsonChunks:s}=Ont(e.body),l=[btt(i),...U5||[]],c=new Map;o=await Mnt({jsonStream:s,onMessage:u=>gI(u,{refs:c,plugins:l}),onError(u,d){console.error(u,d)}})}else if(n.includes("application/x-ndjson")){const i=new Map;o=await Tnt({response:e,onMessage:s=>gI(s,{refs:i,plugins:U5}),onError(s,a){console.error(s,a)}})}else if(n.includes("application/json")){const i=await e.json();o=gI(i,{plugins:U5})}if(Xl(o),o instanceof Error)throw o;return o}if(n.includes("application/json")){const o=await e.json(),i=cKe(o);if(i)throw i;if(la(o))throw o;return o}if(!e.ok)throw new Error(await e.text());return e}async function Tnt({response:t,onMessage:e,onError:n}){if(!t.body)throw new Error("No response body");const r=t.body.pipeThrough(new TextDecoderStream).getReader();let o="",i=!1,s;for(;!i;){const{value:a,done:l}=await r.read();if(a&&(o+=a),o.length===0&&l)throw new Error("Stream ended before first object");if(o.endsWith(`
@@ -64,7 +64,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${e.do
64
64
  `,h),g=p<0?d.length:p;if(g>h&&r(d.slice(h,g),u),p<0)break;o(),h=p+1}a=c}}eY(e,n,(c,u,d)=>{l(c,""),l(u,d)},i,s),l(s,"")}class Djt{constructor(e,n,r){this.at=e,this.highlighters=n,this.span=r,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,r,o,i){let{type:s,from:a,to:l}=e;if(a>=r||l<=n)return;s.isTop&&(i=this.highlighters.filter(p=>!p.scope||p.scope(s)));let c=o,u=zjt(e)||Cb.empty,d=Ijt(i,u.tags);if(d&&(c&&(c+=" "),c+=d,u.mode==1&&(o+=(o?" ":"")+d)),this.startSpan(Math.max(n,a),c),u.opaque)return;let h=e.tree&&e.tree.prop(Bn.mounted);if(h&&h.overlay){let p=e.node.enter(h.overlay[0].from+a,1),g=this.highlighters.filter(x=>!x.scope||x.scope(h.tree.type)),_=e.firstChild();for(let x=0,y=a;;x++){let k=x<h.overlay.length?h.overlay[x]:null,O=k?k.from+a:l,C=Math.max(n,y),A=Math.min(r,O);if(C<A&&_)for(;e.from<A&&(this.highlightRange(e,C,A,o,i),this.startSpan(Math.min(A,e.to),c),!(e.to>=O||!e.nextSibling())););if(!k||O>r)break;y=k.to+a,y>n&&(this.highlightRange(p.cursor(),Math.max(n,k.from+a),Math.min(r,y),"",g),this.startSpan(Math.min(r,y),c))}_&&e.parent()}else if(e.firstChild()){h&&(o="");do if(!(e.to<=n)){if(e.from>=r)break;this.highlightRange(e,n,r,o,i),this.startSpan(Math.min(r,e.to),c)}while(e.nextSibling());e.parent()}}}function zjt(t){let e=t.type.prop(pke);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const Rt=Ul.define,Jw=Rt(),gf=Rt(),Mce=Rt(gf),Pce=Rt(gf),vf=Rt(),ek=Rt(vf),iD=Rt(vf),w1=Rt(),vp=Rt(w1),p1=Rt(),m1=Rt(),aq=Rt(),A7=Rt(aq),tk=Rt(),_e={comment:Jw,lineComment:Rt(Jw),blockComment:Rt(Jw),docComment:Rt(Jw),name:gf,variableName:Rt(gf),typeName:Mce,tagName:Rt(Mce),propertyName:Pce,attributeName:Rt(Pce),className:Rt(gf),labelName:Rt(gf),namespace:Rt(gf),macroName:Rt(gf),literal:vf,string:ek,docString:Rt(ek),character:Rt(ek),attributeValue:Rt(ek),number:iD,integer:Rt(iD),float:Rt(iD),bool:Rt(vf),regexp:Rt(vf),escape:Rt(vf),color:Rt(vf),url:Rt(vf),keyword:p1,self:Rt(p1),null:Rt(p1),atom:Rt(p1),unit:Rt(p1),modifier:Rt(p1),operatorKeyword:Rt(p1),controlKeyword:Rt(p1),definitionKeyword:Rt(p1),moduleKeyword:Rt(p1),operator:m1,derefOperator:Rt(m1),arithmeticOperator:Rt(m1),logicOperator:Rt(m1),bitwiseOperator:Rt(m1),compareOperator:Rt(m1),updateOperator:Rt(m1),definitionOperator:Rt(m1),typeOperator:Rt(m1),controlOperator:Rt(m1),punctuation:aq,separator:Rt(aq),bracket:A7,angleBracket:Rt(A7),squareBracket:Rt(A7),paren:Rt(A7),brace:Rt(A7),content:w1,heading:vp,heading1:Rt(vp),heading2:Rt(vp),heading3:Rt(vp),heading4:Rt(vp),heading5:Rt(vp),heading6:Rt(vp),contentSeparator:Rt(w1),list:Rt(w1),quote:Rt(w1),emphasis:Rt(w1),strong:Rt(w1),link:Rt(w1),monospace:Rt(w1),strikethrough:Rt(w1),inserted:Rt(),deleted:Rt(),changed:Rt(),invalid:Rt(),meta:tk,documentMeta:Rt(tk),annotation:Rt(tk),processingInstruction:Rt(tk),definition:Ul.defineModifier("definition"),constant:Ul.defineModifier("constant"),function:Ul.defineModifier("function"),standard:Ul.defineModifier("standard"),local:Ul.defineModifier("local"),special:Ul.defineModifier("special")};for(let t in _e){let e=_e[t];e instanceof Ul&&(e.name=t)}mke([{tag:_e.link,class:"tok-link"},{tag:_e.heading,class:"tok-heading"},{tag:_e.emphasis,class:"tok-emphasis"},{tag:_e.strong,class:"tok-strong"},{tag:_e.keyword,class:"tok-keyword"},{tag:_e.atom,class:"tok-atom"},{tag:_e.bool,class:"tok-bool"},{tag:_e.url,class:"tok-url"},{tag:_e.labelName,class:"tok-labelName"},{tag:_e.inserted,class:"tok-inserted"},{tag:_e.deleted,class:"tok-deleted"},{tag:_e.literal,class:"tok-literal"},{tag:_e.string,class:"tok-string"},{tag:_e.number,class:"tok-number"},{tag:[_e.regexp,_e.escape,_e.special(_e.string)],class:"tok-string2"},{tag:_e.variableName,class:"tok-variableName"},{tag:_e.local(_e.variableName),class:"tok-variableName tok-local"},{tag:_e.definition(_e.variableName),class:"tok-variableName tok-definition"},{tag:_e.special(_e.variableName),class:"tok-variableName2"},{tag:_e.definition(_e.propertyName),class:"tok-propertyName tok-definition"},{tag:_e.typeName,class:"tok-typeName"},{tag:_e.namespace,class:"tok-namespace"},{tag:_e.className,class:"tok-className"},{tag:_e.macroName,class:"tok-macroName"},{tag:_e.propertyName,class:"tok-propertyName"},{tag:_e.operator,class:"tok-operator"},{tag:_e.comment,class:"tok-comment"},{tag:_e.meta,class:"tok-meta"},{tag:_e.invalid,class:"tok-invalid"},{tag:_e.punctuation,class:"tok-punctuation"}]);var sD;const Rf=new Bn;function pP(t){return Ft.define({combine:t?e=>e.concat(t):void 0})}const tY=new Bn;class Gl{constructor(e,n,r=[],o=""){this.data=e,this.name=o,Gn.prototype.hasOwnProperty("tree")||Object.defineProperty(Gn.prototype,"tree",{get(){return Dr(this)}}),this.parser=n,this.extension=[Qc.of(this),Gn.languageData.of((i,s,a)=>{let l=jce(i,s,a),c=l.type.prop(Rf);if(!c)return[];let u=i.facet(c),d=l.type.prop(tY);if(d){let h=l.resolve(s-l.from,a);for(let p of d)if(p.test(h,i)){let g=i.facet(p.facet);return p.type=="replace"?g:g.concat(u)}}return u})].concat(r)}isActiveAt(e,n,r=-1){return jce(e,n,r).type.prop(Rf)==this.data}findRegions(e){let n=e.facet(Qc);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],o=(i,s)=>{if(i.prop(Rf)==this.data){r.push({from:s,to:s+i.length});return}let a=i.prop(Bn.mounted);if(a){if(a.tree.prop(Rf)==this.data){if(a.overlay)for(let l of a.overlay)r.push({from:l.from+s,to:l.to+s});else r.push({from:s,to:s+i.length});return}else if(a.overlay){let l=r.length;if(o(a.tree,a.overlay[0].from+s),r.length>l)return}}for(let l=0;l<i.children.length;l++){let c=i.children[l];c instanceof fr&&o(c,i.positions[l]+s)}};return o(Dr(e),0),r}get allowsNesting(){return!0}}Gl.setState=xn.define();function jce(t,e,n){let r=t.facet(Qc),o=Dr(t).topNode;if(!r||r.allowsNesting)for(let i=o;i;i=i.enter(e,n,Zr.ExcludeBuffers|Zr.EnterBracketed))i.type.isTop&&(o=i);return o}class q6 extends Gl{constructor(e,n,r){super(e,n,[],r),this.parser=n}static define(e){let n=pP(e.languageData);return new q6(n,e.parser.configure({props:[Rf.add(r=>r.isTop?n:void 0)]}),e.name)}configure(e,n){return new q6(this.data,this.parser.configure(e),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Dr(t){let e=t.field(Gl.state,!1);return e?e.tree:fr.empty}class $jt{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,n){let r=this.cursorPos-this.string.length;return e<r||n>=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let E7=null;class q3{constructor(e,n,r=[],o,i,s,a,l){this.parser=e,this.state=n,this.fragments=r,this.tree=o,this.treeLen=i,this.viewport=s,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new q3(e,n,[],fr.empty,0,r,[],null)}startParse(){return this.parser.startParse(new $jt(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=fr.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let o=Date.now()+e;e=()=>Date.now()>o}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n<this.state.doc.length&&this.parse.stopAt(n);;){let o=this.parse.advance();if(o)if(this.fragments=this.withoutTempSkipped(M2.addTree(o,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(r=this.parse.stoppedAt)!==null&&r!==void 0?r:this.state.doc.length,this.tree=o,this.parse=null,this.treeLen<(n??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,n;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(M2.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=E7;E7=this;try{return e()}finally{E7=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Nce(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:o,treeLen:i,viewport:s,skipped:a}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((c,u,d,h)=>l.push({fromA:c,toA:u,fromB:d,toB:h})),r=M2.applyChanges(r,l),o=fr.empty,i=0,s={from:e.mapPos(s.from,-1),to:e.mapPos(s.to,1)},this.skipped.length){a=[];for(let c of this.skipped){let u=e.mapPos(c.from,1),d=e.mapPos(c.to,-1);u<d&&a.push({from:u,to:d})}}}return new q3(this.parser,n,r,o,i,s,a,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let n=this.skipped.length;for(let r=0;r<this.skipped.length;r++){let{from:o,to:i}=this.skipped[r];o<e.to&&i>e.from&&(this.fragments=Nce(this.fragments,o,i),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends hP{createParse(n,r,o){let i=o[0].from,s=o[o.length-1].to;return{parsedPos:i,advance(){let l=E7;if(l){for(let c of o)l.tempSkipped.push(c);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=s,new fr(Mi.none,[],[],s-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return E7}}function Nce(t,e,n){return M2.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class V6{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new V6(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=q3.create(e.facet(Qc).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new V6(r)}}Gl.state=to.define({create:V6.init,update(t,e){for(let n of e.effects)if(n.is(Gl.setState))return n.value;return e.startState.facet(Qc)!=e.state.facet(Qc)?V6.init(e.state):t.apply(e)}});let vke=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(vke=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const aD=typeof navigator<"u"&&(!((sD=navigator.scheduling)===null||sD===void 0)&&sD.isInputPending)?()=>navigator.scheduling.isInputPending():null,Bjt=oi.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let n=this.view.state.field(Gl.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(Gl.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=vke(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnd<n&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=n+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:o}}=this.view,i=r.field(Gl.state);if(i.tree==i.context.tree&&i.context.isDone(o+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,e&&!aD?Math.max(25,e.timeRemaining()-5):1e9),a=i.context.treeLen<o&&r.doc.length>o+1e3,l=i.context.work(()=>aD&&aD()||Date.now()>s,o+(a?0:1e5));this.chunkBudget-=Date.now()-n,(l||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:Gl.setState.of(new V6(i.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>bl(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Qc=Ft.define({combine(t){return t.length?t[0]:null},enables:t=>[Gl.state,Bjt,ft.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class js{constructor(e,n=[]){this.language=e,this.support=n,this.extension=[e,n]}}class Ab{constructor(e,n,r,o,i,s=void 0){this.name=e,this.alias=n,this.extensions=r,this.filename=o,this.loadFunc=i,this.support=s,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e}))}static of(e){let{load:n,support:r}=e;if(!n){if(!r)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");n=()=>Promise.resolve(r)}return new Ab(e.name,(e.alias||[]).concat(e.name).map(o=>o.toLowerCase()),e.extensions||[],e.filename,n,r)}static matchFilename(e,n){for(let o of e)if(o.filename&&o.filename.test(n))return o;let r=/\.([^.]+)$/.exec(n);if(r){for(let o of e)if(o.extensions.indexOf(r[1])>-1)return o}return null}static matchLanguageName(e,n,r=!0){n=n.toLowerCase();for(let o of e)if(o.alias.some(i=>i==n))return o;if(r)for(let o of e)for(let i of o.alias){let s=n.indexOf(i);if(s>-1&&(i.length>2||!/\w/.test(n[s-1])&&!/\w/.test(n[s+i.length])))return o}return null}}const Hjt=Ft.define(),Rh=Ft.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function ah(t){let e=t.facet(Rh);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Eb(t,e){let n="",r=t.tabSize,o=t.facet(Rh)[0];if(o==" "){for(;e>=r;)n+=" ",e-=r;o=" "}for(let i=0;i<e;i++)n+=o;return n}function nY(t,e){t instanceof Gn&&(t=new mP(t));for(let r of t.state.facet(Hjt)){let o=r(t,e);if(o!==void 0)return o}let n=Dr(t.state);return n.length>=e?Fjt(t,n,e):null}class mP{constructor(e,n={}){this.state=e,this.options=n,this.unit=ah(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:o,simulateDoubleBreak:i}=this.options;return o!=null&&o>=r.from&&o<=r.to?i&&o==e?{text:"",from:e}:(n<0?o<e:o<=e)?{text:r.text.slice(o-r.from),from:o}:{text:r.text.slice(0,o-r.from),from:r.from}:r}textAfterPos(e,n=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:r,from:o}=this.lineAt(e,n);return r.slice(e-o,Math.min(r.length,e+100-o))}column(e,n=1){let{text:r,from:o}=this.lineAt(e,n),i=this.countColumn(r,e-o),s=this.options.overrideIndentation?this.options.overrideIndentation(o):-1;return s>-1&&(i+=s-this.countColumn(r,r.search(/\S|$/))),i}countColumn(e,n=e.length){return W2(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:o}=this.lineAt(e,n),i=this.options.overrideIndentation;if(i){let s=i(o);if(s>-1)return s}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Fg=new Bn;function Fjt(t,e,n){let r=e.resolveStack(n),o=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(o!=r.node){let i=[];for(let s=o;s&&!(s.from<r.node.from||s.to>r.node.to||s.from==r.node.from&&s.type==r.node.type);s=s.parent)i.push(s);for(let s=i.length-1;s>=0;s--)r={node:i[s],next:r}}return bke(r,t,n)}function bke(t,e,n){for(let r=t;r;r=r.next){let o=Vjt(r.node);if(o)return o(rY.create(e,n,r))}return 0}function qjt(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function Vjt(t){let e=t.type.prop(Fg);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(Bn.closedBy))){let o=t.lastChild,i=o&&r.indexOf(o.name)>-1;return s=>_ke(s,!0,1,void 0,i&&!qjt(s)?o.from:void 0)}return t.parent==null?Qjt:null}function Qjt(){return 0}class rY extends mP{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new rY(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(Ujt(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return bke(this.context.next,this.base,this.pos)}}function Ujt(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function Wjt(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let o=t.options.simulateBreak,i=t.state.doc.lineAt(n.from),s=o==null||o<=i.from?i.to:Math.min(i.to,o);for(let a=n.to;;){let l=e.childAfter(a);if(!l||l==r)return null;if(!l.type.isSkipped){if(l.from>=s)return null;let c=/^ */.exec(i.text.slice(n.to-i.from))[0].length;return{from:n.from,to:n.to+c}}a=l.to}}function Zjt({closing:t,align:e=!0,units:n=1}){return r=>_ke(r,e,n,t)}function _ke(t,e,n,r,o){let i=t.textAfter,s=i.match(/^\s*/)[0].length,a=r&&i.slice(s,s+r.length)==r||o==t.pos+s,l=e?Wjt(t):null;return l?a?t.column(l.from):t.column(l.to):t.baseIndent+(a?0:t.unit*n)}const Gjt=t=>t.baseIndent;function iS({except:t,units:e=1}={}){return n=>{let r=t&&t.test(n.textAfter);return n.baseIndent+(r?0:e*n.unit)}}const Yjt=200;function Xjt(){return Gn.transactionFilter.of(t=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let n=t.newDoc,{head:r}=t.newSelection.main,o=n.lineAt(r);if(r>o.from+Yjt)return t;let i=n.sliceString(o.from,r);if(!e.some(c=>c.test(i)))return t;let{state:s}=t,a=-1,l=[];for(let{head:c}of s.selection.ranges){let u=s.doc.lineAt(c);if(u.from==a)continue;a=u.from;let d=nY(s,u.from);if(d==null)continue;let h=/^\s*/.exec(u.text)[0],p=Eb(s,d);h!=p&&l.push({from:u.from,to:u.from+h.length,insert:p})}return l.length?[t,{changes:l,sequential:!0}]:t})}const xke=Ft.define(),qg=new Bn;function yke(t){let e=t.firstChild,n=t.lastChild;return e&&e.to<n.from?{from:e.to,to:n.type.isError?t.to:n.from}:null}function Kjt(t,e,n){let r=Dr(t);if(r.length<n)return null;let o=r.resolveStack(n,1),i=null;for(let s=o;s;s=s.next){let a=s.node;if(a.to<=n||a.from>n)continue;if(i&&a.from<e)break;let l=a.type.prop(qg);if(l&&(a.to<r.length-50||r.length==t.doc.length||!Jjt(a))){let c=l(a,t);c&&c.from<=n&&c.from>=e&&c.to>n&&(i=c)}}return i}function Jjt(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}function KC(t,e,n){for(let r of t.facet(xke)){let o=r(t,e,n);if(o)return o}return Kjt(t,e,n)}function wke(t,e){let n=e.mapPos(t.from,1),r=e.mapPos(t.to,-1);return n>=r?void 0:{from:n,to:r}}const gP=xn.define({map:wke}),cx=xn.define({map:wke});function kke(t){let e=[];for(let{head:n}of t.state.selection.ranges)e.some(r=>r.from<=n&&r.to>=n)||e.push(t.lineBlockAt(n));return e}const V3=to.define({create(){return yt.none},update(t,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((n,r)=>t=Rce(t,n,r)),t=t.map(e.changes);for(let n of e.effects)if(n.is(gP)&&!eNt(t,n.value.from,n.value.to)){let{preparePlaceholder:r}=e.state.facet(Cke),o=r?yt.replace({widget:new aNt(r(e.state,n.value))}):Lce;t=t.update({add:[o.range(n.value.from,n.value.to)]})}else n.is(cx)&&(t=t.update({filter:(r,o)=>n.value.from!=r||n.value.to!=o,filterFrom:n.value.from,filterTo:n.value.to}));return e.selection&&(t=Rce(t,e.selection.main.head)),t},provide:t=>ft.decorations.from(t),toJSON(t,e){let n=[];return t.between(0,e.doc.length,(r,o)=>{n.push(r,o)}),n},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let n=0;n<t.length;){let r=t[n++],o=t[n++];if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid JSON for fold state");e.push(Lce.range(r,o))}return yt.set(e,!0)}});function Rce(t,e,n=e){let r=!1;return t.between(e,n,(o,i)=>{o<n&&i>e&&(r=!0)}),r?t.update({filterFrom:e,filterTo:n,filter:(o,i)=>o>=n||i<=e}):t}function JC(t,e,n){var r;let o=null;return(r=t.field(V3,!1))===null||r===void 0||r.between(e,n,(i,s)=>{(!o||o.from>i)&&(o={from:i,to:s})}),o}function eNt(t,e,n){let r=!1;return t.between(e,e,(o,i)=>{o==e&&i==n&&(r=!0)}),r}function Oke(t,e){return t.field(V3,!1)?e:e.concat(xn.appendConfig.of(Ake()))}const tNt=t=>{for(let e of kke(t)){let n=KC(t.state,e.from,e.to);if(n)return t.dispatch({effects:Oke(t.state,[gP.of(n),Ske(t,n)])}),!0}return!1},nNt=t=>{if(!t.state.field(V3,!1))return!1;let e=[];for(let n of kke(t)){let r=JC(t.state,n.from,n.to);r&&e.push(cx.of(r),Ske(t,r,!1))}return e.length&&t.dispatch({effects:e}),e.length>0};function Ske(t,e,n=!0){let r=t.state.doc.lineAt(e.from).number,o=t.state.doc.lineAt(e.to).number;return ft.announce.of(`${t.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${t.state.phrase("to")} ${o}.`)}const rNt=t=>{let{state:e}=t,n=[];for(let r=0;r<e.doc.length;){let o=t.lineBlockAt(r),i=KC(e,o.from,o.to);i&&n.push(gP.of(i)),r=(i?t.lineBlockAt(i.to):o).to+1}return n.length&&t.dispatch({effects:Oke(t.state,n)}),!!n.length},oNt=t=>{let e=t.state.field(V3,!1);if(!e||!e.size)return!1;let n=[];return e.between(0,t.state.doc.length,(r,o)=>{n.push(cx.of({from:r,to:o}))}),t.dispatch({effects:n}),!0},iNt=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:tNt},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:nNt},{key:"Ctrl-Alt-[",run:rNt},{key:"Ctrl-Alt-]",run:oNt}],sNt={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Cke=Ft.define({combine(t){return M4(t,sNt)}});function Ake(t){return[V3,uNt]}function Eke(t,e){let{state:n}=t,r=n.facet(Cke),o=s=>{let a=t.lineBlockAt(t.posAtDOM(s.target)),l=JC(t.state,a.from,a.to);l&&t.dispatch({effects:cx.of(l)}),s.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(t,o,e);let i=document.createElement("span");return i.textContent=r.placeholderText,i.setAttribute("aria-label",n.phrase("folded code")),i.title=n.phrase("unfold"),i.className="cm-foldPlaceholder",i.onclick=o,i}const Lce=yt.replace({widget:new class extends rs{toDOM(t){return Eke(t,null)}}});class aNt extends rs{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Eke(e,this.value)}}const lNt={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class lD extends q0{constructor(e,n){super(),this.config=e,this.open=n}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let n=document.createElement("span");return n.textContent=this.open?this.config.openText:this.config.closedText,n.title=e.state.phrase(this.open?"Fold line":"Unfold line"),n}}function cNt(t={}){let e={...lNt,...t},n=new lD(e,!0),r=new lD(e,!1),o=oi.fromClass(class{constructor(s){this.from=s.viewport.from,this.markers=this.buildMarkers(s)}update(s){(s.docChanged||s.viewportChanged||s.startState.facet(Qc)!=s.state.facet(Qc)||s.startState.field(V3,!1)!=s.state.field(V3,!1)||Dr(s.startState)!=Dr(s.state)||e.foldingChanged(s))&&(this.markers=this.buildMarkers(s.view))}buildMarkers(s){let a=new Ua;for(let l of s.viewportLineBlocks){let c=JC(s.state,l.from,l.to)?r:KC(s.state,l.from,l.to)?n:null;c&&a.add(l.from,l.from,c)}return a.finish()}}),{domEventHandlers:i}=e;return[o,ZG({class:"cm-foldGutter",markers(s){var a;return((a=s.plugin(o))===null||a===void 0?void 0:a.markers)||cr.empty},initialSpacer(){return new lD(e,!1)},domEventHandlers:{...i,click:(s,a,l)=>{if(i.click&&i.click(s,a,l))return!0;let c=JC(s.state,a.from,a.to);if(c)return s.dispatch({effects:cx.of(c)}),!0;let u=KC(s.state,a.from,a.to);return u?(s.dispatch({effects:gP.of(u)}),!0):!1}}}),Ake()]}const uNt=ft.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class ux{constructor(e,n){this.specs=e;let r;function o(a){let l=Z2.newName();return(r||(r=Object.create(null)))["."+l]=a,l}const i=typeof n.all=="string"?n.all:n.all?o(n.all):void 0,s=n.scope;this.scope=s instanceof Gl?a=>a.prop(Rf)==s.data:s?a=>a==s:void 0,this.style=mke(e.map(a=>({tag:a.tag,class:a.class||o(Object.assign({},a,{tag:null}))})),{all:i}).style,this.module=r?new Z2(r):null,this.themeType=n.themeType}static define(e,n){return new ux(e,n||{})}}const lq=Ft.define(),dNt=Ft.define({combine(t){return t.length?[t[0]]:null}});function sS(t){let e=t.facet(lq);return e.length?e:t.facet(dNt)}function Tke(t,e){let n=[hNt],r;return t instanceof ux&&(t.module&&n.push(ft.styleModule.of(t.module)),r=t.themeType),r?n.push(lq.computeN([ft.darkTheme],o=>o.facet(ft.darkTheme)==(r=="dark")?[t]:[])):n.push(lq.of(t)),n}function oY(t,e,n){let r=sS(t),o=null;if(r){for(let i of r)if(!i.scope||n){let s=i.style(e);s&&(o=o?o+" "+s:s)}}return o}class fNt{constructor(e){this.markCache=Object.create(null),this.tree=Dr(e.state),this.decorations=this.buildDeco(e,sS(e.state)),this.decoratedTo=e.viewport.to}update(e){let n=Dr(e.state),r=sS(e.state),o=r!=sS(e.startState),{viewport:i}=e.view,s=e.changes.mapPos(this.decoratedTo,1);n.length<i.to&&!o&&n.type==this.tree.type&&s>=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=s):(n!=this.tree||e.viewportChanged||o)&&(this.tree=n,this.decorations=this.buildDeco(e.view,r),this.decoratedTo=i.to)}buildDeco(e,n){if(!n||!this.tree.length)return yt.none;let r=new Ua;for(let{from:o,to:i}of e.visibleRanges)eY(this.tree,n,(s,a,l)=>{r.add(s,a,this.markCache[l]||(this.markCache[l]=yt.mark({class:l})))},o,i);return r.finish()}}const hNt=r0.high(oi.fromClass(fNt,{decorations:t=>t.decorations})),pNt=ft.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Mke=1e4,Pke="()[]{}",jke=Ft.define({combine(t){return M4(t,{afterCursor:!0,brackets:Pke,maxScanDistance:Mke,renderMatch:vNt})}}),mNt=yt.mark({class:"cm-matchingBracket"}),gNt=yt.mark({class:"cm-nonmatchingBracket"});function vNt(t){let e=[],n=t.matched?mNt:gNt;return e.push(n.range(t.start.from,t.start.to)),t.end&&e.push(n.range(t.end.from,t.end.to)),e}function Ice(t){let e=[],n=t.facet(jke);for(let r of t.selection.ranges){if(!r.empty)continue;let o=W1(t,r.head,-1,n)||r.head>0&&W1(t,r.head-1,1,n)||n.afterCursor&&(W1(t,r.head,1,n)||r.head<t.doc.length&&W1(t,r.head+1,-1,n));o&&(e=e.concat(n.renderMatch(o,t)))}return yt.set(e,!0)}const bNt=oi.fromClass(class{constructor(t){this.paused=!1,this.decorations=Ice(t.state)}update(t){(t.docChanged||t.selectionSet||this.paused)&&(t.view.composing?(this.decorations=this.decorations.map(t.changes),this.paused=!0):(this.decorations=Ice(t.state),this.paused=!1))}},{decorations:t=>t.decorations}),_Nt=[bNt,pNt];function Nke(t={}){return[jke.of(t),_Nt]}const Rke=new Bn;function cq(t,e,n){let r=t.prop(e<0?Bn.openedBy:Bn.closedBy);if(r)return r;if(t.name.length==1){let o=n.indexOf(t.name);if(o>-1&&o%2==(e<0?1:0))return[n[o+e]]}return null}function uq(t){let e=t.type.prop(Rke);return e?e(t.node):t}function W1(t,e,n,r={}){let o=r.maxScanDistance||Mke,i=r.brackets||Pke,s=Dr(t),a=s.resolveInner(e,n);for(let l=a;l;l=l.parent){let c=cq(l.type,n,i);if(c&&l.from<l.to){let u=uq(l);if(u&&(n>0?e>=u.from&&e<u.to:e>u.from&&e<=u.to))return xNt(t,e,n,l,u,c,i)}}return yNt(t,e,n,s,a.type,o,i)}function xNt(t,e,n,r,o,i,s){let a=r.parent,l={from:o.from,to:o.to},c=0,u=a?.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(c==0&&i.indexOf(u.type.name)>-1&&u.from<u.to){let d=uq(u);return{start:l,end:d?{from:d.from,to:d.to}:void 0,matched:!0}}else if(cq(u.type,n,s))c++;else if(cq(u.type,-n,s)){if(c==0){let d=uq(u);return{start:l,end:d&&d.from<d.to?{from:d.from,to:d.to}:void 0,matched:!1}}c--}}while(n<0?u.prevSibling():u.nextSibling());return{start:l,matched:!1}}function yNt(t,e,n,r,o,i,s){let a=n<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),l=s.indexOf(a);if(l<0||l%2==0!=n>0)return null;let c={from:n<0?e-1:e,to:n>0?e+1:e},u=t.doc.iterRange(e,n>0?t.doc.length:0),d=0;for(let h=0;!u.next().done&&h<=i;){let p=u.value;n<0&&(h+=p.length);let g=e+h*n;for(let _=n>0?0:p.length-1,x=n>0?p.length:-1;_!=x;_+=n){let y=s.indexOf(p[_]);if(!(y<0||r.resolveInner(g+_,1).type!=o))if(y%2==0==n>0)d++;else{if(d==1)return{start:c,end:{from:g+_,to:g+_+1},matched:y>>1==l>>1};d--}}n>0&&(h+=p.length)}return u.done?{start:c,matched:!1}:null}function Dce(t,e,n,r=0,o=0){e==null&&(e=t.search(/[^\s\u00a0]/),e==-1&&(e=t.length));let i=o;for(let s=r;s<e;s++)t.charCodeAt(s)==9?i+=n-i%n:i++;return i}class Lke{constructor(e,n,r,o){this.string=e,this.tabSize=n,this.indentUnit=r,this.overrideIndent=o,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(e){let n=this.string.charAt(this.pos),r;if(typeof e=="string"?r=n==e:r=n&&(e instanceof RegExp?e.test(n):e(n)),r)return++this.pos,n}eatWhile(e){let n=this.pos;for(;this.eat(e););return this.pos>n}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let n=this.string.indexOf(e,this.pos);if(n>-1)return this.pos=n,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=Dce(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var e;return(e=this.overrideIndent)!==null&&e!==void 0?e:Dce(this.string,null,this.tabSize)}match(e,n,r){if(typeof e=="string"){let o=s=>r?s.toLowerCase():s,i=this.string.substr(this.pos,e.length);return o(i)==o(e)?(n!==!1&&(this.pos+=e.length),!0):null}else{let o=this.string.slice(this.pos).match(e);return o&&o.index>0?null:(o&&n!==!1&&(this.pos+=o[0].length),o)}}current(){return this.string.slice(this.start,this.pos)}}function wNt(t){return{name:t.name||"",token:t.token,blankLine:t.blankLine||(()=>{}),startState:t.startState||(()=>!0),copyState:t.copyState||kNt,indent:t.indent||(()=>null),languageData:t.languageData||{},tokenTable:t.tokenTable||sY,mergeTokens:t.mergeTokens!==!1}}function kNt(t){if(typeof t!="object")return t;let e={};for(let n in t){let r=t[n];e[n]=r instanceof Array?r.slice():r}return e}const zce=new WeakMap;class cl extends Gl{constructor(e){let n=pP(e.languageData),r=wNt(e),o,i=new class extends hP{createParse(s,a,l){return new SNt(o,s,a,l)}};super(n,i,[],e.name),this.topNode=ENt(n,this),o=this,this.streamParser=r,this.stateAfter=new Bn({perNode:!0}),this.tokenTable=e.tokenTable?new $ke(r.tokenTable):ANt}static define(e){return new cl(e)}getIndent(e){let n,{overrideIndentation:r}=e.options;r&&(n=zce.get(e.state),n!=null&&n<e.pos-1e4&&(n=void 0));let o=iY(this,e.node.tree,e.node.from,e.node.from,n??e.pos),i,s;if(o?(s=o.state,i=o.pos+1):(s=this.streamParser.startState(e.unit),i=e.node.from),e.pos-i>1e4)return null;for(;i<e.pos;){let l=e.state.doc.lineAt(i),c=Math.min(e.pos,l.to);if(l.length){let u=r?r(l.from):-1,d=new Lke(l.text,e.state.tabSize,e.unit,u<0?void 0:u);for(;d.pos<c-l.from;)Dke(this.streamParser.token,d,s)}else this.streamParser.blankLine(s,e.unit);if(c==e.pos)break;i=l.to+1}let a=e.lineAt(e.pos);return r&&n==null&&zce.set(e.state,a.from),this.streamParser.indent(s,/^\s*(.*)/.exec(a.text)[1],e)}get allowsNesting(){return!1}}function iY(t,e,n,r,o){let i=n>=r&&n+e.length<=o&&e.prop(t.stateAfter);if(i)return{state:t.streamParser.copyState(i),pos:n+e.length};for(let s=e.children.length-1;s>=0;s--){let a=e.children[s],l=n+e.positions[s],c=a instanceof fr&&l<o&&iY(t,a,l,r,o);if(c)return c}return null}function Ike(t,e,n,r,o){if(o&&n<=0&&r>=e.length)return e;!o&&n==0&&e.type==t.topNode&&(o=!0);for(let i=e.children.length-1;i>=0;i--){let s=e.positions[i],a=e.children[i],l;if(s<r&&a instanceof fr){if(!(l=Ike(t,a,n-s,r-s,o)))break;return o?new fr(e.type,e.children.slice(0,i).concat(l),e.positions.slice(0,i+1),s+l.length):l}}return null}function ONt(t,e,n,r,o){for(let i of e){let s=i.from+(i.openStart?25:0),a=i.to-(i.openEnd?25:0),l=s<=n&&a>n&&iY(t,i.tree,0-i.offset,n,a),c;if(l&&l.pos<=r&&(c=Ike(t,i.tree,n+i.offset,l.pos+i.offset,!1)))return{state:l.state,tree:c}}return{state:t.streamParser.startState(o?ah(o):4),tree:fr.empty}}let SNt=class{constructor(e,n,r,o){this.lang=e,this.input=n,this.fragments=r,this.ranges=o,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=o[o.length-1].to;let i=q3.get(),s=o[0].from,{state:a,tree:l}=ONt(e,r,s,this.to,i?.state);this.state=a,this.parsedPos=this.chunkStart=s+l.length;for(let c=0;c<l.children.length;c++)this.chunks.push(l.children[c]),this.chunkPos.push(l.positions[c]);i&&this.parsedPos<i.viewport.from-1e5&&o.some(c=>c.from<=i.viewport.from&&c.to>=i.viewport.from)&&(this.state=this.lang.streamParser.startState(ah(i.state)),i.skipUntilInView(this.parsedPos,i.viewport.from),this.parsedPos=i.viewport.from),this.moveRangeIndex()}advance(){let e=q3.get(),n=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),r=Math.min(n,this.chunkStart+512);for(e&&(r=Math.min(r,e.viewport.to));this.parsedPos<r;)this.parseLine(e);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=n?this.finish():e&&this.parsedPos>=e.viewport.to?(e.skipUntilInView(this.parsedPos,n),this.finish()):null}stopAt(e){this.stoppedAt=e}lineAfter(e){let n=this.input.chunk(e);if(this.input.lineChunks)n==`
65
65
  `&&(n="");else{let r=n.indexOf(`
66
66
  `);r>-1&&(n=n.slice(0,r))}return e+n.length<=this.to?n:n.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,n=this.lineAfter(e),r=e+n.length;for(let o=this.rangeIndex;;){let i=this.ranges[o].to;if(i>=r||(n=n.slice(0,i-(r-n.length)),o++,o==this.ranges.length))break;let s=this.ranges[o].from,a=this.lineAfter(s);n+=a,r=s+a.length}return{line:n,end:r}}skipGapsTo(e,n,r){for(;;){let o=this.ranges[this.rangeIndex].to,i=e+n;if(r>0?o>i:o>=i)break;let s=this.ranges[++this.rangeIndex].from;n+=s-o}return n}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(e,n,r,o){let i=4;if(this.ranges.length>1){o=this.skipGapsTo(n,o,1),n+=o;let a=this.chunk.length;o=this.skipGapsTo(r,o,-1),r+=o,i+=this.chunk.length-a}let s=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&i==4&&s>=0&&this.chunk[s]==e&&this.chunk[s+2]==n?this.chunk[s+2]=r:this.chunk.push(e,n,r,i),o}parseLine(e){let{line:n,end:r}=this.nextLine(),o=0,{streamParser:i}=this.lang,s=new Lke(n,e?e.state.tabSize:4,e?ah(e.state):2);if(s.eol())i.blankLine(this.state,s.indentUnit);else for(;!s.eol();){let a=Dke(i.token,s,this.state);if(a&&(o=this.emitToken(this.lang.tokenTable.resolve(a),this.parsedPos+s.start,this.parsedPos+s.pos,o)),s.start>1e4)break}this.parsedPos=r,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let e=fr.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:CNt,topID:0,maxBufferLength:512,reused:this.chunkReused});e=new fr(e.type,e.children,e.positions,e.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(e),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new fr(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function Dke(t,e,n){e.start=e.pos;for(let r=0;r<10;r++){let o=t(e,n);if(e.pos>e.start)return o}throw new Error("Stream parser failed to advance stream.")}const sY=Object.create(null),Tb=[Mi.none],CNt=new Bg(Tb),$ce=[],Bce=Object.create(null),zke=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])zke[t]=Bke(sY,e);class $ke{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),zke)}resolve(e){return e?this.table[e]||(this.table[e]=Bke(this.extra,e)):0}}const ANt=new $ke(sY);function cD(t,e){$ce.indexOf(t)>-1||($ce.push(t),console.warn(e))}function Bke(t,e){let n=[];for(let a of e.split(" ")){let l=[];for(let c of a.split(".")){let u=t[c]||_e[c];u?typeof u=="function"?l.length?l=l.map(u):cD(c,`Modifier ${c} used at start of tag`):l.length?cD(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:cD(c,`Unknown highlighting tag ${c}`)}for(let c of l)n.push(c)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),o=r+" "+n.map(a=>a.id),i=Bce[o];if(i)return i.id;let s=Bce[o]=Mi.define({id:Tb.length,name:r,props:[Hg({[r]:n})]});return Tb.push(s),s.id}function ENt(t,e){let n=Mi.define({id:Tb.length,name:"Document",props:[Rf.add(()=>t),Fg.add(()=>r=>e.getIndent(r))],top:!0});return Tb.push(n),n}$o.RTL,$o.LTR;class aY{constructor(e,n,r,o){this.state=e,this.pos=n,this.explicit=r,this.view=o,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let n=Dr(this.state).resolveInner(this.pos,-1);for(;n&&e.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(e){let n=this.state.doc.lineAt(this.pos),r=Math.max(n.from,this.pos-250),o=n.text.slice(r-n.from,this.pos-n.from),i=o.search(Fke(e,!1));return i<0?null:{from:r+i,to:this.pos,text:o.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,n,r){e=="abort"&&this.abortListeners&&(this.abortListeners.push(n),r&&r.onDocChange&&(this.abortOnDocChange=!0))}}function Hce(t){let e=Object.keys(t).join(""),n=/\w/.test(e);return n&&(e=e.replace(/\w/g,"")),`[${n?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function TNt(t){let e=Object.create(null),n=Object.create(null);for(let{label:o}of t){e[o[0]]=!0;for(let i=1;i<o.length;i++)n[o[i]]=!0}let r=Hce(e)+Hce(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function Hke(t){let e=t.map(o=>typeof o=="string"?{label:o}:o),[n,r]=e.every(o=>/^\w+$/.test(o.label))?[/\w*$/,/\w+$/]:TNt(e);return o=>{let i=o.matchBefore(r);return i||o.explicit?{from:i?i.from:o.pos,options:e,validFor:n}:null}}function MNt(t,e){return n=>{for(let r=Dr(n.state).resolveInner(n.pos,-1);r;r=r.parent){if(t.indexOf(r.name)>-1)return null;if(r.type.isTop)break}return e(n)}}class Fce{constructor(e,n,r,o){this.completion=e,this.source=n,this.match=r,this.score=o}}function g3(t){return t.selection.main.from}function Fke(t,e){var n;let{source:r}=t,o=e&&r[0]!="^",i=r[r.length-1]!="$";return!o&&!i?t:new RegExp(`${o?"^":""}(?:${r})${i?"$":""}`,(n=t.flags)!==null&&n!==void 0?n:t.ignoreCase?"i":"")}const lY=ud.define();function PNt(t,e,n,r){let{main:o}=t.selection,i=n-o.from,s=r-o.from;return{...t.changeByRange(a=>{if(a!=o&&n!=r&&t.sliceDoc(a.from+i,a.from+s)!=t.sliceDoc(n,r))return{range:a};let l=t.toText(e);return{changes:{from:a.from+i,to:r==o.from?a.to:a.from+s,insert:l},range:it.cursor(a.from+i+l.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const qce=new WeakMap;function jNt(t){if(!Array.isArray(t))return t;let e=qce.get(t);return e||qce.set(t,e=Hke(t)),e}const eA=xn.define(),Mb=xn.define();class NNt{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<e.length;){let r=Ql(e,n),o=H1(r);this.chars.push(r);let i=e.slice(n,n+o),s=i.toUpperCase();this.folded.push(Ql(s==i?i.toLowerCase():s,0)),n+=o}this.astral=e.length!=this.chars.length}ret(e,n){return this.score=e,this.matched=n,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:n,folded:r,any:o,precise:i,byWord:s}=this;if(n.length==1){let k=Ql(e,0),O=H1(k),C=O==e.length?0:-100;if(k!=n[0])if(k==r[0])C+=-200;else return null;return this.ret(C,[0,O])}let a=e.indexOf(this.pattern);if(a==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=n.length,c=0;if(a<0){for(let k=0,O=Math.min(e.length,200);k<O&&c<l;){let C=Ql(e,k);(C==n[c]||C==r[c])&&(o[c++]=k),k+=H1(C)}if(c<l)return null}let u=0,d=0,h=!1,p=0,g=-1,_=-1,x=/[a-z]/.test(e),y=!0;for(let k=0,O=Math.min(e.length,200),C=0;k<O&&d<l;){let A=Ql(e,k);a<0&&(u<l&&A==n[u]&&(i[u++]=k),p<l&&(A==n[p]||A==r[p]?(p==0&&(g=k),_=k+1,p++):p=0));let E,M=A<255?A>=48&&A<=57||A>=97&&A<=122?2:A>=65&&A<=90?1:0:(E=PG(A))!=E.toLowerCase()?1:E!=E.toUpperCase()?2:0;(!k||M==1&&x||C==0&&M!=0)&&(n[d]==A||r[d]==A&&(h=!0)?s[d++]=k:s.length&&(y=!1)),C=M,k+=H1(A)}return d==l&&s[0]==0&&y?this.result(-100+(h?-200:0),s,e):p==l&&g==0?this.ret(-200-e.length+(_==e.length?0:-100),[0,_]):a>-1?this.ret(-700-e.length,[a,a+this.pattern.length]):p==l?this.ret(-900-e.length,[g,_]):d==l?this.result(-100+(h?-200:0)+-700+(y?0:-1100),s,e):n.length==2?null:this.result((o[0]?-700:0)+-200+-1100,o,e)}result(e,n,r){let o=[],i=0;for(let s of n){let a=s+(this.astral?H1(Ql(r,s)):1);i&&o[i-1]==s?o[i-1]=a:(o[i++]=s,o[i++]=a)}return this.ret(e-r.length,o)}}class RNt{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let n=e.slice(0,this.pattern.length),r=n==this.pattern?0:n.toLowerCase()==this.folded?-200:null;return r==null?null:(this.matched=[0,n.length],this.score=r+(e.length==this.pattern.length?0:-100),this)}}const hs=Ft.define({combine(t){return M4(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:LNt,filterStrict:!1,compareCompletions:(e,n)=>(e.sortText||e.label).localeCompare(n.sortText||n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,n)=>e&&n,closeOnBlur:(e,n)=>e&&n,icons:(e,n)=>e&&n,tooltipClass:(e,n)=>r=>Vce(e(r),n(r)),optionClass:(e,n)=>r=>Vce(e(r),n(r)),addToOptions:(e,n)=>e.concat(n),filterStrict:(e,n)=>e||n})}});function Vce(t,e){return t?e?t+" "+e:t:e}function LNt(t,e,n,r,o,i){let s=t.textDirection==$o.RTL,a=s,l=!1,c="top",u,d,h=e.left-o.left,p=o.right-e.right,g=r.right-r.left,_=r.bottom-r.top;if(a&&h<Math.min(g,p)?a=!1:!a&&p<Math.min(g,h)&&(a=!0),g<=(a?h:p))u=Math.max(o.top,Math.min(n.top,o.bottom-_))-e.top,d=Math.min(400,a?h:p);else{l=!0,d=Math.min(400,(s?e.right:o.right-e.left)-30);let k=o.bottom-e.bottom;k>=_||k>e.top?u=n.bottom-e.top:(c="bottom",u=e.bottom-n.top)}let x=(e.bottom-e.top)/i.offsetHeight,y=(e.right-e.left)/i.offsetWidth;return{style:`${c}: ${u/x}px; max-width: ${d/y}px`,class:"cm-completionInfo-"+(l?s?"left-narrow":"right-narrow":a?"left":"right")}}const cY=xn.define();function INt(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(n){let r=document.createElement("div");return r.classList.add("cm-completionIcon"),n.type&&r.classList.add(...n.type.split(/\s+/g).map(o=>"cm-completionIcon-"+o)),r.setAttribute("aria-hidden","true"),r},position:20}),e.push({render(n,r,o,i){let s=document.createElement("span");s.className="cm-completionLabel";let a=n.displayLabel||n.label,l=0;for(let c=0;c<i.length;){let u=i[c++],d=i[c++];u>l&&s.appendChild(document.createTextNode(a.slice(l,u)));let h=s.appendChild(document.createElement("span"));h.appendChild(document.createTextNode(a.slice(u,d))),h.className="cm-completionMatchedText",l=d}return l<a.length&&s.appendChild(document.createTextNode(a.slice(l))),s},position:50},{render(n){if(!n.detail)return null;let r=document.createElement("span");return r.className="cm-completionDetail",r.textContent=n.detail,r},position:80}),e.sort((n,r)=>n.position-r.position).map(n=>n.render)}function uD(t,e,n){if(t<=n)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let o=Math.floor(e/n);return{from:o*n,to:(o+1)*n}}let r=Math.floor((t-e)/n);return{from:t-(r+1)*n,to:t-r*n}}class DNt{constructor(e,n,r){this.view=e,this.stateField=n,this.applyCompletion=r,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let o=e.state.field(n),{options:i,selected:s}=o.open,a=e.state.facet(hs);this.optionContent=INt(a),this.optionClass=a.optionClass,this.tooltipClass=a.tooltipClass,this.range=uD(i.length,s,a.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",l=>{let{options:c}=e.state.field(n).open;for(let u=l.target,d;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(d=/-(\d+)$/.exec(u.id))&&+d[1]<c.length){this.applyCompletion(e,c[+d[1]]),l.preventDefault();return}if(l.target==this.list){let u=this.list.classList.contains("cm-completionListIncompleteTop")&&l.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&l.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;u!=null&&(e.dispatch({effects:cY.of(u)}),l.preventDefault())}}),this.dom.addEventListener("focusout",l=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(hs).closeOnBlur&&l.relatedTarget!=e.contentDOM&&e.dispatch({effects:Mb.of(null)})}),this.showOptions(i,o.id)}mount(){this.updateSel()}showOptions(e,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var n;let r=e.state.field(this.stateField),o=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),r!=o){let{options:i,selected:s,disabled:a}=r.open;(!o.open||o.open.options!=i)&&(this.range=uD(i.length,s,e.state.facet(hs).maxRenderedOptions),this.showOptions(i,r.id)),this.updateSel(),a!=((n=o.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!a)}}updateTooltipClass(e){let n=this.tooltipClass(e);if(n!=this.currentClass){for(let r of this.currentClass.split(" "))r&&this.dom.classList.remove(r);for(let r of n.split(" "))r&&this.dom.classList.add(r);this.currentClass=n}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),n=e.open;(n.selected>-1&&n.selected<this.range.from||n.selected>=this.range.to)&&(this.range=uD(n.options.length,n.selected,this.view.state.facet(hs).maxRenderedOptions),this.showOptions(n.options,e.id));let r=this.updateSelectedOption(n.selected);if(r){this.destroyInfo();let{completion:o}=n.options[n.selected],{info:i}=o;if(!i)return;let s=typeof i=="string"?document.createTextNode(i):i(o);if(!s)return;"then"in s?s.then(a=>{a&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(a,o)}).catch(a=>bl(this.view.state,a,"completion info")):(this.addInfoPane(s,o),r.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,n){this.destroyInfo();let r=this.info=document.createElement("div");if(r.className="cm-tooltip cm-completionInfo",r.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)r.appendChild(e),this.infoDestroy=null;else{let{dom:o,destroy:i}=e;r.appendChild(o),this.infoDestroy=i||null}this.dom.appendChild(r),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let n=null;for(let r=this.list.firstChild,o=this.range.from;r;r=r.nextSibling,o++)r.nodeName!="LI"||!r.id?o--:o==e?r.hasAttribute("aria-selected")||(r.setAttribute("aria-selected","true"),n=r):r.hasAttribute("aria-selected")&&(r.removeAttribute("aria-selected"),r.removeAttribute("aria-describedby"));return n&&$Nt(this.list,n),n}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let n=this.dom.getBoundingClientRect(),r=this.info.getBoundingClientRect(),o=e.getBoundingClientRect(),i=this.space;if(!i){let s=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:s.clientWidth,bottom:s.clientHeight}}return o.top>Math.min(i.bottom,n.bottom)-10||o.bottom<Math.max(i.top,n.top)+10?null:this.view.state.facet(hs).positionInfo(this.view,n,o,r,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,n,r){const o=document.createElement("ul");o.id=n,o.setAttribute("role","listbox"),o.setAttribute("aria-expanded","true"),o.setAttribute("aria-label",this.view.state.phrase("Completions")),o.addEventListener("mousedown",s=>{s.target==o&&s.preventDefault()});let i=null;for(let s=r.from;s<r.to;s++){let{completion:a,match:l}=e[s],{section:c}=a;if(c){let h=typeof c=="string"?c:c.name;if(h!=i&&(s>r.from||r.from==0))if(i=h,typeof c!="string"&&c.header)o.appendChild(c.header(c));else{let p=o.appendChild(document.createElement("completion-section"));p.textContent=h}}const u=o.appendChild(document.createElement("li"));u.id=n+"-"+s,u.setAttribute("role","option");let d=this.optionClass(a);d&&(u.className=d);for(let h of this.optionContent){let p=h(a,this.view.state,this.view,l);p&&u.appendChild(p)}}return r.from&&o.classList.add("cm-completionListIncompleteTop"),r.to<e.length&&o.classList.add("cm-completionListIncompleteBottom"),o}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function zNt(t,e){return n=>new DNt(n,t,e)}function $Nt(t,e){let n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),o=n.height/t.offsetHeight;r.top<n.top?t.scrollTop-=(n.top-r.top)/o:r.bottom>n.bottom&&(t.scrollTop+=(r.bottom-n.bottom)/o)}function Qce(t){return(t.boost||0)*100+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}function BNt(t,e){let n=[],r=null,o=null,i=u=>{n.push(u);let{section:d}=u.completion;if(d){r||(r=[]);let h=typeof d=="string"?d:d.name;r.some(p=>p.name==h)||r.push(typeof d=="string"?{name:h}:d)}},s=e.facet(hs);for(let u of t)if(u.hasResult()){let d=u.result.getMatch;if(u.result.filter===!1)for(let h of u.result.options)i(new Fce(h,u.source,d?d(h):[],1e9-n.length));else{let h=e.sliceDoc(u.from,u.to),p,g=s.filterStrict?new RNt(h):new NNt(h);for(let _ of u.result.options)if(p=g.match(_.label)){let x=_.displayLabel?d?d(_,p.matched):[]:p.matched,y=p.score+(_.boost||0);if(i(new Fce(_,u.source,x,y)),typeof _.section=="object"&&_.section.rank==="dynamic"){let{name:k}=_.section;o||(o=Object.create(null)),o[k]=Math.max(y,o[k]||-1e9)}}}}if(r){let u=Object.create(null),d=0,h=(p,g)=>(p.rank==="dynamic"&&g.rank==="dynamic"?o[g.name]-o[p.name]:0)||(typeof p.rank=="number"?p.rank:1e9)-(typeof g.rank=="number"?g.rank:1e9)||(p.name<g.name?-1:1);for(let p of r.sort(h))d-=1e5,u[p.name]=d;for(let p of n){let{section:g}=p.completion;g&&(p.score+=u[typeof g=="string"?g:g.name])}}let a=[],l=null,c=s.compareCompletions;for(let u of n.sort((d,h)=>h.score-d.score||c(d.completion,h.completion))){let d=u.completion;!l||l.label!=d.label||l.detail!=d.detail||l.type!=null&&d.type!=null&&l.type!=d.type||l.apply!=d.apply||l.boost!=d.boost?a.push(u):Qce(u.completion)>Qce(l)&&(a[a.length-1]=u),l=u.completion}return a}class M5{constructor(e,n,r,o,i,s){this.options=e,this.attrs=n,this.tooltip=r,this.timestamp=o,this.selected=i,this.disabled=s}setSelected(e,n){return e==this.selected||e>=this.options.length?this:new M5(this.options,Uce(n,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,n,r,o,i,s){if(o&&!s&&e.some(c=>c.isPending))return o.setDisabled();let a=BNt(e,n);if(!a.length)return o&&e.some(c=>c.isPending)?o.setDisabled():null;let l=n.facet(hs).selectOnOpen?0:-1;if(o&&o.selected!=l&&o.selected!=-1){let c=o.options[o.selected].completion;for(let u=0;u<a.length;u++)if(a[u].completion==c){l=u;break}}return new M5(a,Uce(r,l),{pos:e.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:UNt,above:i.aboveCursor},o?o.timestamp:Date.now(),l,!1)}map(e){return new M5(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new M5(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class tA{constructor(e,n,r){this.active=e,this.id=n,this.open=r}static start(){return new tA(VNt,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:n}=e,r=n.facet(hs),i=(r.override||n.languageDataAt("autocomplete",g3(n)).map(jNt)).map(l=>(this.active.find(u=>u.source==l)||new Nc(l,this.active.some(u=>u.state!=0)?1:0)).update(e,r));i.length==this.active.length&&i.every((l,c)=>l==this.active[c])&&(i=this.active);let s=this.open,a=e.effects.some(l=>l.is(uY));s&&e.docChanged&&(s=s.map(e.changes)),e.selection||i.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!HNt(i,this.active)||a?s=M5.build(i,n,this.id,s,r,a):s&&s.disabled&&!i.some(l=>l.isPending)&&(s=null),!s&&i.every(l=>!l.isPending)&&i.some(l=>l.hasResult())&&(i=i.map(l=>l.hasResult()?new Nc(l.source,0):l));for(let l of e.effects)l.is(cY)&&(s=s&&s.setSelected(l.value,this.id));return i==this.active&&s==this.open?this:new tA(i,this.id,s)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?FNt:qNt}}function HNt(t,e){if(t==e)return!0;for(let n=0,r=0;;){for(;n<t.length&&!t[n].hasResult();)n++;for(;r<e.length&&!e[r].hasResult();)r++;let o=n==t.length,i=r==e.length;if(o||i)return o==i;if(t[n++].result!=e[r++].result)return!1}}const FNt={"aria-autocomplete":"list"},qNt={};function Uce(t,e){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(n["aria-activedescendant"]=t+"-"+e),n}const VNt=[];function qke(t,e){if(t.isUserEvent("input.complete")){let r=t.annotation(lY);if(r&&e.activateOnCompletion(r))return 12}let n=t.isUserEvent("input.type");return n&&e.activateOnTyping?5:n?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class Nc{constructor(e,n,r=!1){this.source=e,this.state=n,this.explicit=r}hasResult(){return!1}get isPending(){return this.state==1}update(e,n){let r=qke(e,n),o=this;(r&8||r&16&&this.touches(e))&&(o=new Nc(o.source,0)),r&4&&o.state==0&&(o=new Nc(this.source,1)),o=o.updateFor(e,r);for(let i of e.effects)if(i.is(eA))o=new Nc(o.source,1,i.value);else if(i.is(Mb))o=new Nc(o.source,0);else if(i.is(uY))for(let s of i.value)s.source==o.source&&(o=s);return o}updateFor(e,n){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(g3(e.state))}}class r6 extends Nc{constructor(e,n,r,o,i,s){super(e,3,n),this.limit=r,this.result=o,this.from=i,this.to=s}hasResult(){return!0}updateFor(e,n){var r;if(!(n&3))return this.map(e.changes);let o=this.result;o.map&&!e.changes.empty&&(o=o.map(o,e.changes));let i=e.changes.mapPos(this.from),s=e.changes.mapPos(this.to,1),a=g3(e.state);if(a>s||!o||n&2&&(g3(e.startState)==this.from||a<this.limit))return new Nc(this.source,n&4?1:0);let l=e.changes.mapPos(this.limit);return QNt(o.validFor,e.state,i,s)?new r6(this.source,this.explicit,l,o,i,s):o.update&&(o=o.update(o,i,s,new aY(e.state,a,!1)))?new r6(this.source,this.explicit,l,o,o.from,(r=o.to)!==null&&r!==void 0?r:g3(e.state)):new Nc(this.source,1,this.explicit)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new r6(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new Nc(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function QNt(t,e,n,r){if(!t)return!1;let o=e.sliceDoc(n,r);return typeof t=="function"?t(o,n,r,e):Fke(t,!0).test(o)}const uY=xn.define({map(t,e){return t.map(n=>n.map(e))}}),fl=to.define({create(){return tA.start()},update(t,e){return t.update(e)},provide:t=>[dP.from(t,e=>e.tooltip),ft.contentAttributes.from(t,e=>e.attrs)]});function dY(t,e){const n=e.completion.apply||e.completion.label;let r=t.state.field(fl).active.find(o=>o.source==e.source);return r instanceof r6?(typeof n=="string"?t.dispatch({...PNt(t.state,n,r.from,r.to),annotations:lY.of(e.completion)}):n(t,e.completion,r.from,r.to),!0):!1}const UNt=zNt(fl,dY);function nk(t,e="option"){return n=>{let r=n.state.field(fl,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(hs).interactionDelay)return!1;let o=1,i;e=="page"&&(i=nke(n,r.open.tooltip))&&(o=Math.max(2,Math.floor(i.dom.offsetHeight/i.dom.querySelector("li").offsetHeight)-1));let{length:s}=r.open.options,a=r.open.selected>-1?r.open.selected+o*(t?1:-1):t?0:s-1;return a<0?a=e=="page"?0:s-1:a>=s&&(a=e=="page"?s-1:0),n.dispatch({effects:cY.of(a)}),!0}}const WNt=t=>{let e=t.state.field(fl,!1);return t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(hs).interactionDelay?!1:dY(t,e.open.options[e.open.selected])},dD=t=>t.state.field(fl,!1)?(t.dispatch({effects:eA.of(!0)}),!0):!1,ZNt=t=>{let e=t.state.field(fl,!1);return!e||!e.active.some(n=>n.state!=0)?!1:(t.dispatch({effects:Mb.of(null)}),!0)};class GNt{constructor(e,n){this.active=e,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const YNt=50,XNt=1e3,KNt=oi.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(fl).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field(fl),n=t.state.facet(hs);if(!t.selectionSet&&!t.docChanged&&t.startState.field(fl)==e)return;let r=t.transactions.some(i=>{let s=qke(i,n);return s&8||(i.selection||i.docChanged)&&!(s&3)});for(let i=0;i<this.running.length;i++){let s=this.running[i];if(r||s.context.abortOnDocChange&&t.docChanged||s.updates.length+t.transactions.length>YNt&&Date.now()-s.time>XNt){for(let a of s.context.abortListeners)try{a()}catch(l){bl(this.view.state,l)}s.context.abortListeners=null,this.running.splice(i--,1)}else s.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some(i=>i.effects.some(s=>s.is(eA)))&&(this.pendingStart=!0);let o=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(i=>i.isPending&&!this.running.some(s=>s.active.source==i.source))?setTimeout(()=>this.startUpdate(),o):-1,this.composing!=0)for(let i of t.transactions)i.isUserEvent("input.type")?this.composing=2:this.composing==2&&i.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(fl);for(let n of e.active)n.isPending&&!this.running.some(r=>r.active.source==n.source)&&this.startQuery(n);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(hs).updateSyncTime))}startQuery(t){let{state:e}=this.view,n=g3(e),r=new aY(e,n,t.explicit,this.view),o=new GNt(t,r);this.running.push(o),Promise.resolve(t.source(r)).then(i=>{o.context.aborted||(o.done=i||null,this.scheduleAccept())},i=>{this.view.dispatch({effects:Mb.of(null)}),bl(this.view.state,i)})}scheduleAccept(){this.running.every(t=>t.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(hs).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],n=this.view.state.facet(hs),r=this.view.state.field(fl);for(let o=0;o<this.running.length;o++){let i=this.running[o];if(i.done===void 0)continue;if(this.running.splice(o--,1),i.done){let a=g3(i.updates.length?i.updates[0].startState:this.view.state),l=Math.min(a,i.done.from+(i.active.explicit?0:1)),c=new r6(i.active.source,i.active.explicit,l,i.done,i.done.from,(t=i.done.to)!==null&&t!==void 0?t:a);for(let u of i.updates)c=c.update(u,n);if(c.hasResult()){e.push(c);continue}}let s=r.active.find(a=>a.source==i.active.source);if(s&&s.isPending)if(i.done==null){let a=new Nc(i.active.source,0);for(let l of i.updates)a=a.update(l,n);a.isPending||e.push(a)}else this.startQuery(s)}(e.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:uY.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(fl,!1);if(e&&e.tooltip&&this.view.state.facet(hs).closeOnBlur){let n=e.open&&nke(this.view,e.open.tooltip);(!n||!n.dom.contains(t.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Mb.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:eA.of(!1)}),20),this.composing=0}}}),JNt=typeof navigator=="object"&&/Win/.test(navigator.platform),eRt=r0.highest(ft.domEventHandlers({keydown(t,e){let n=e.state.field(fl,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||t.key.length>1||t.ctrlKey&&!(JNt&&t.altKey)||t.metaKey)return!1;let r=n.open.options[n.open.selected],o=n.active.find(s=>s.source==r.source),i=r.completion.commitCharacters||o.result.commitCharacters;return i&&i.indexOf(t.key)>-1&&dY(e,r),!1}})),Vke=ft.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:.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:.5,display:"block",textAlign:"center"},".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:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class tRt{constructor(e,n,r,o){this.field=e,this.line=n,this.from=r,this.to=o}}class fY{constructor(e,n,r){this.field=e,this.from=n,this.to=r}map(e){let n=e.mapPos(this.from,-1,Zi.TrackDel),r=e.mapPos(this.to,1,Zi.TrackDel);return n==null||r==null?null:new fY(this.field,n,r)}}class hY{constructor(e,n){this.lines=e,this.fieldPositions=n}instantiate(e,n){let r=[],o=[n],i=e.doc.lineAt(n),s=/^\s*/.exec(i.text)[0];for(let l of this.lines){if(r.length){let c=s,u=/^\t*/.exec(l)[0].length;for(let d=0;d<u;d++)c+=e.facet(Rh);o.push(n+c.length-u),l=c+l.slice(u)}r.push(l),n+=l.length+1}let a=this.fieldPositions.map(l=>new fY(l.field,o[l.line]+l.from,o[l.line]+l.to));return{text:r,ranges:a}}static parse(e){let n=[],r=[],o=[],i;for(let s of e.split(/\r\n?|\n/)){for(;i=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(s);){let a=i[1]?+i[1]:null,l=i[2]||i[3]||"",c=-1,u=l.replace(/\\[{}]/g,d=>d[1]);for(let d=0;d<n.length;d++)(a!=null?n[d].seq==a:u&&n[d].name==u)&&(c=d);if(c<0){let d=0;for(;d<n.length&&(a==null||n[d].seq!=null&&n[d].seq<a);)d++;n.splice(d,0,{seq:a,name:u}),c=d;for(let h of o)h.field>=c&&h.field++}for(let d of o)if(d.line==r.length&&d.from>i.index){let h=i[2]?3+(i[1]||"").length:2;d.from-=h,d.to-=h}o.push(new tRt(c,r.length,i.index,i.index+u.length)),s=s.slice(0,i.index)+l+s.slice(i.index+i[0].length)}s=s.replace(/\\([{}])/g,(a,l,c)=>{for(let u of o)u.line==r.length&&u.from>c&&(u.from--,u.to--);return l}),r.push(s)}return new hY(r,o)}}let nRt=yt.widget({widget:new class extends rs{toDOM(){let t=document.createElement("span");return t.className="cm-snippetFieldPosition",t}ignoreEvent(){return!1}}}),rRt=yt.mark({class:"cm-snippetField"});class Vg{constructor(e,n){this.ranges=e,this.active=n,this.deco=yt.set(e.map(r=>(r.from==r.to?nRt:rRt).range(r.from,r.to)),!0)}map(e){let n=[];for(let r of this.ranges){let o=r.map(e);if(!o)return null;n.push(o)}return new Vg(n,this.active)}selectionInsideField(e){return e.ranges.every(n=>this.ranges.some(r=>r.field==this.active&&r.from<=n.from&&r.to>=n.to))}}const dx=xn.define({map(t,e){return t&&t.map(e)}}),oRt=xn.define(),Pb=to.define({create(){return null},update(t,e){for(let n of e.effects){if(n.is(dx))return n.value;if(n.is(oRt)&&t)return new Vg(t.ranges,n.value)}return t&&e.docChanged&&(t=t.map(e.changes)),t&&e.selection&&!t.selectionInsideField(e.selection)&&(t=null),t},provide:t=>ft.decorations.from(t,e=>e?e.deco:yt.none)});function pY(t,e){return it.create(t.filter(n=>n.field==e).map(n=>it.range(n.from,n.to)))}function Qke(t){let e=hY.parse(t);return(n,r,o,i)=>{let{text:s,ranges:a}=e.instantiate(n.state,o),{main:l}=n.state.selection,c={changes:{from:o,to:i==l.from?l.to:i,insert:Pr.of(s)},scrollIntoView:!0,annotations:r?[lY.of(r),Ai.userEvent.of("input.complete")]:void 0};if(a.length&&(c.selection=pY(a,0)),a.some(u=>u.field>0)){let u=new Vg(a,0),d=c.effects=[dx.of(u)];n.state.field(Pb,!1)===void 0&&d.push(xn.appendConfig.of([Pb,cRt,uRt,Vke]))}n.dispatch(n.state.update(c))}}function Uke(t){return({state:e,dispatch:n})=>{let r=e.field(Pb,!1);if(!r||t<0&&r.active==0)return!1;let o=r.active+t,i=t>0&&!r.ranges.some(s=>s.field==o+t);return n(e.update({selection:pY(r.ranges,o),effects:dx.of(i?null:new Vg(r.ranges,o)),scrollIntoView:!0})),!0}}const iRt=({state:t,dispatch:e})=>t.field(Pb,!1)?(e(t.update({effects:dx.of(null)})),!0):!1,sRt=Uke(1),aRt=Uke(-1),lRt=[{key:"Tab",run:sRt,shift:aRt},{key:"Escape",run:iRt}],Wce=Ft.define({combine(t){return t.length?t[0]:lRt}}),cRt=r0.highest(dd.compute([Wce],t=>t.facet(Wce)));function ul(t,e){return{...e,apply:Qke(t)}}const uRt=ft.domEventHandlers({mousedown(t,e){let n=e.state.field(Pb,!1),r;if(!n||(r=e.posAtCoords({x:t.clientX,y:t.clientY}))==null)return!1;let o=n.ranges.find(i=>i.from<=r&&i.to>=r);return!o||o.field==n.active?!1:(e.dispatch({selection:pY(n.ranges,o.field),effects:dx.of(n.ranges.some(i=>i.field>o.field)?new Vg(n.ranges,o.field):null),scrollIntoView:!0}),!0)}}),jb={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Jp=xn.define({map(t,e){let n=e.mapPos(t,-1,Zi.TrackAfter);return n??void 0}}),mY=new class extends rh{};mY.startSide=1;mY.endSide=-1;const Wke=to.define({create(){return cr.empty},update(t,e){if(t=t.map(e.changes),e.selection){let n=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:r=>r>=n.from&&r<=n.to})}for(let n of e.effects)n.is(Jp)&&(t=t.update({add:[mY.range(n.value,n.value+1)]}));return t}});function dRt(){return[hRt,Wke]}const fD="()[]{}<>«»»«[]{}";function Zke(t){for(let e=0;e<fD.length;e+=2)if(fD.charCodeAt(e)==t)return fD.charAt(e+1);return PG(t<128?t:t+1)}function Gke(t,e){return t.languageDataAt("closeBrackets",e)[0]||jb}const fRt=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),hRt=ft.inputHandler.of((t,e,n,r)=>{if((fRt?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let o=t.state.selection.main;if(r.length>2||r.length==2&&H1(Ql(r,0))==1||e!=o.from||n!=o.to)return!1;let i=gRt(t.state,r);return i?(t.dispatch(i),!0):!1}),pRt=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let r=Gke(t,t.selection.main.head).brackets||jb.brackets,o=null,i=t.changeByRange(s=>{if(s.empty){let a=vRt(t.doc,s.head);for(let l of r)if(l==a&&vP(t.doc,s.head)==Zke(Ql(l,0)))return{changes:{from:s.head-l.length,to:s.head+l.length},range:it.cursor(s.head-l.length)}}return{range:o=s}});return o||e(t.update(i,{scrollIntoView:!0,userEvent:"delete.backward"})),!o},mRt=[{key:"Backspace",run:pRt}];function gRt(t,e){let n=Gke(t,t.selection.main.head),r=n.brackets||jb.brackets;for(let o of r){let i=Zke(Ql(o,0));if(e==o)return i==o?xRt(t,o,r.indexOf(o+o+o)>-1,n):bRt(t,o,i,n.before||jb.before);if(e==i&&Yke(t,t.selection.main.from))return _Rt(t,o,i)}return null}function Yke(t,e){let n=!1;return t.field(Wke).between(0,t.doc.length,r=>{r==e&&(n=!0)}),n}function vP(t,e){let n=t.sliceString(e,e+2);return n.slice(0,H1(Ql(n,0)))}function vRt(t,e){let n=t.sliceString(e-2,e);return H1(Ql(n,0))==n.length?n:n.slice(1)}function bRt(t,e,n,r){let o=null,i=t.changeByRange(s=>{if(!s.empty)return{changes:[{insert:e,from:s.from},{insert:n,from:s.to}],effects:Jp.of(s.to+e.length),range:it.range(s.anchor+e.length,s.head+e.length)};let a=vP(t.doc,s.head);return!a||/\s/.test(a)||r.indexOf(a)>-1?{changes:{insert:e+n,from:s.head},effects:Jp.of(s.head+e.length),range:it.cursor(s.head+e.length)}:{range:o=s}});return o?null:t.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function _Rt(t,e,n){let r=null,o=t.changeByRange(i=>i.empty&&vP(t.doc,i.head)==n?{changes:{from:i.head,to:i.head+n.length,insert:n},range:it.cursor(i.head+n.length)}:r={range:i});return r?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function xRt(t,e,n,r){let o=r.stringPrefixes||jb.stringPrefixes,i=null,s=t.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:e,from:a.to}],effects:Jp.of(a.to+e.length),range:it.range(a.anchor+e.length,a.head+e.length)};let l=a.head,c=vP(t.doc,l),u;if(c==e){if(Zce(t,l))return{changes:{insert:e+e,from:l},effects:Jp.of(l+e.length),range:it.cursor(l+e.length)};if(Yke(t,l)){let h=n&&t.sliceDoc(l,l+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:l,to:l+h.length,insert:h},range:it.cursor(l+h.length)}}}else{if(n&&t.sliceDoc(l-2*e.length,l)==e+e&&(u=Gce(t,l-2*e.length,o))>-1&&Zce(t,u))return{changes:{insert:e+e+e+e,from:l},effects:Jp.of(l+e.length),range:it.cursor(l+e.length)};if(t.charCategorizer(l)(c)!=zo.Word&&Gce(t,l,o)>-1&&!yRt(t,l,e,o))return{changes:{insert:e+e,from:l},effects:Jp.of(l+e.length),range:it.cursor(l+e.length)}}return{range:i=a}});return i?null:t.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function Zce(t,e){let n=Dr(t).resolveInner(e+1);return n.parent&&n.from==e}function yRt(t,e,n,r){let o=Dr(t).resolveInner(e,-1),i=r.reduce((s,a)=>Math.max(s,a.length),0);for(let s=0;s<5;s++){let a=t.sliceDoc(o.from,Math.min(o.to,o.from+n.length+i)),l=a.indexOf(n);if(!l||l>-1&&r.indexOf(a.slice(0,l))>-1){let u=o.firstChild;for(;u&&u.from==o.from&&u.to-u.from>n.length+l;){if(t.sliceDoc(u.to-n.length,u.to)==n)return!1;u=u.firstChild}return!0}let c=o.to==e&&o.parent;if(!c)break;o=c}return!1}function Gce(t,e,n){let r=t.charCategorizer(e);if(r(t.sliceDoc(e-1,e))!=zo.Word)return e;for(let o of n){let i=e-o.length;if(t.sliceDoc(i,e)==o&&r(t.sliceDoc(i-1,i))!=zo.Word)return i}return-1}function Yce(t={}){return[eRt,fl,hs.of(t),KNt,kRt,Vke]}const wRt=[{key:"Ctrl-Space",run:dD},{mac:"Alt-`",run:dD},{mac:"Alt-i",run:dD},{key:"Escape",run:ZNt},{key:"ArrowDown",run:nk(!0)},{key:"ArrowUp",run:nk(!1)},{key:"PageDown",run:nk(!0,"page")},{key:"PageUp",run:nk(!1,"page")},{key:"Enter",run:WNt}],kRt=r0.highest(dd.computeN([hs],t=>t.facet(hs).defaultKeymap?[wRt]:[])),ORt=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=vY(t.state,n.from);return r.line?SRt(t):r.block?ARt(t):!1};function gY(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let o=t(e,n);return o?(r(n.update(o)),!0):!1}}const SRt=gY(MRt,0),CRt=gY(Xke,0),ARt=gY((t,e)=>Xke(t,e,TRt(e)),0);function vY(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const T7=50;function ERt(t,{open:e,close:n},r,o){let i=t.sliceDoc(r-T7,r),s=t.sliceDoc(o,o+T7),a=/\s*$/.exec(i)[0].length,l=/^\s*/.exec(s)[0].length,c=i.length-a;if(i.slice(c-e.length,c)==e&&s.slice(l,l+n.length)==n)return{open:{pos:r-a,margin:a&&1},close:{pos:o+l,margin:l&&1}};let u,d;o-r<=2*T7?u=d=t.sliceDoc(r,o):(u=t.sliceDoc(r,r+T7),d=t.sliceDoc(o-T7,o));let h=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,g=d.length-p-n.length;return u.slice(h,h+e.length)==e&&d.slice(g,g+n.length)==n?{open:{pos:r+h+e.length,margin:/\s/.test(u.charAt(h+e.length))?1:0},close:{pos:o-p-n.length,margin:/\s/.test(d.charAt(g-1))?1:0}}:null}function TRt(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),o=n.to<=r.to?r:t.doc.lineAt(n.to);o.from>r.from&&o.from==n.to&&(o=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let i=e.length-1;i>=0&&e[i].to>r.from?e[i].to=o.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:o.to})}return e}function Xke(t,e,n=e.selection.ranges){let r=n.map(i=>vY(e,i.from).block);if(!r.every(i=>i))return null;let o=n.map((i,s)=>ERt(e,r[s],i.from,i.to));if(t!=2&&!o.every(i=>i))return{changes:e.changes(n.map((i,s)=>o[s]?[]:[{from:i.from,insert:r[s].open+" "},{from:i.to,insert:" "+r[s].close}]))};if(t!=1&&o.some(i=>i)){let i=[];for(let s=0,a;s<o.length;s++)if(a=o[s]){let l=r[s],{open:c,close:u}=a;i.push({from:c.pos-l.open.length,to:c.pos+c.margin},{from:u.pos-u.margin,to:u.pos+l.close.length})}return{changes:i}}return null}function MRt(t,e,n=e.selection.ranges){let r=[],o=-1;e:for(let{from:i,to:s}of n){let a=r.length,l=1e9,c;for(let u=i;u<=s;){let d=e.doc.lineAt(u);if(c==null&&(c=vY(e,d.from).line,!c))continue e;if(d.from>o&&(i==s||s>d.from)){o=d.from;let h=/^\s*/.exec(d.text)[0].length,p=h==d.length,g=d.text.slice(h,h+c.length)==c?h:-1;h<d.text.length&&h<l&&(l=h),r.push({line:d,comment:g,token:c,indent:h,empty:p,single:!1})}u=d.to+1}if(l<1e9)for(let u=a;u<r.length;u++)r[u].indent<r[u].line.text.length&&(r[u].indent=l);r.length==a+1&&(r[a].single=!0)}if(t!=2&&r.some(i=>i.comment<0&&(!i.empty||i.single))){let i=[];for(let{line:a,token:l,indent:c,empty:u,single:d}of r)(d||!u)&&i.push({from:a.from+c,insert:l+" "});let s=e.changes(i);return{changes:s,selection:e.selection.map(s,1)}}else if(t!=1&&r.some(i=>i.comment>=0)){let i=[];for(let{line:s,comment:a,token:l}of r)if(a>=0){let c=s.from+a,u=c+l.length;s.text[u-s.from]==" "&&u++,i.push({from:c,to:u})}return{changes:i}}return null}const dq=ud.define(),PRt=ud.define(),jRt=Ft.define(),Kke=Ft.define({combine(t){return M4(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,o)=>e(r,o)||n(r,o)})}}),bY=to.define({create(){return Z1.empty},update(t,e){let n=e.state.facet(Kke),r=e.annotation(dq);if(r){let l=_l.fromTransaction(e,r.selection),c=r.side,u=c==0?t.undone:t.done;return l?u=nA(u,u.length,n.minDepth,l):u=nOe(u,e.startState.selection),new Z1(c==0?r.rest:u,c==0?u:r.rest)}let o=e.annotation(PRt);if((o=="full"||o=="before")&&(t=t.isolate()),e.annotation(Ai.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let i=_l.fromTransaction(e),s=e.annotation(Ai.time),a=e.annotation(Ai.userEvent);return i?t=t.addChanges(i,s,a,n,e):e.selection&&(t=t.addSelection(e.startState.selection,s,a,n.newGroupDelay)),(o=="full"||o=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Z1(t.done.map(_l.fromJSON),t.undone.map(_l.fromJSON))}});function Jke(t={}){return[bY,Kke.of(t),ft.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?_Y:e.inputType=="historyRedo"?Nb:null;return r?(e.preventDefault(),r(n)):!1}})]}const eOe=bY;function bP(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let o=n.field(bY,!1);if(!o)return!1;let i=o.pop(t,n,e);return i?(r(i),!0):!1}}const _Y=bP(0,!1),Nb=bP(1,!1),NRt=bP(0,!0),RRt=bP(1,!0);class _l{constructor(e,n,r,o,i){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=o,this.selectionsAfter=i}setSelAfter(e){return new _l(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(o=>o.toJSON())}}static fromJSON(e){return new _l(e.changes&&Do.fromJSON(e.changes),[],e.mapped&&eu.fromJSON(e.mapped),e.startSelection&&it.fromJSON(e.startSelection),e.selectionsAfter.map(it.fromJSON))}static fromTransaction(e,n){let r=Rc;for(let o of e.startState.facet(jRt)){let i=o(e);i.length&&(r=r.concat(i))}return!r.length&&e.changes.empty?null:new _l(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,Rc)}static selection(e){return new _l(void 0,Rc,void 0,void 0,e)}}function nA(t,e,n,r){let o=e+1>n+20?e-n-1:0,i=t.slice(o,e);return i.push(r),i}function LRt(t,e){let n=[],r=!1;return t.iterChangedRanges((o,i)=>n.push(o,i)),e.iterChangedRanges((o,i,s,a)=>{for(let l=0;l<n.length;){let c=n[l++],u=n[l++];a>=c&&s<=u&&(r=!0)}}),r}function IRt(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function tOe(t,e){return t.length?e.length?t.concat(e):t:e}const Rc=[],DRt=200;function nOe(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-DRt));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),nA(t,t.length-1,1e9,n.setSelAfter(r)))}else return[_l.selection([e])]}function zRt(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function hD(t,e){if(!t.length)return t;let n=t.length,r=Rc;for(;n;){let o=$Rt(t[n-1],e,r);if(o.changes&&!o.changes.empty||o.effects.length){let i=t.slice(0,n);return i[n-1]=o,i}else e=o.mapped,n--,r=o.selectionsAfter}return r.length?[_l.selection(r)]:Rc}function $Rt(t,e,n){let r=tOe(t.selectionsAfter.length?t.selectionsAfter.map(a=>a.map(e)):Rc,n);if(!t.changes)return _l.selection(r);let o=t.changes.map(e),i=e.mapDesc(t.changes,!0),s=t.mapped?t.mapped.composeDesc(i):i;return new _l(o,xn.mapEffects(t.effects,e),s,t.startSelection.map(i),r)}const BRt=/^(input\.type|delete)($|\.)/;class Z1{constructor(e,n,r=0,o=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=o}isolate(){return this.prevTime?new Z1(this.done,this.undone):this}addChanges(e,n,r,o,i){let s=this.done,a=s[s.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!r||BRt.test(r))&&(!a.selectionsAfter.length&&n-this.prevTime<o.newGroupDelay&&o.joinToEvent(i,LRt(a.changes,e.changes))||r=="input.type.compose")?s=nA(s,s.length-1,o.minDepth,new _l(e.changes.compose(a.changes),tOe(xn.mapEffects(e.effects,a.changes),a.effects),a.mapped,a.startSelection,Rc)):s=nA(s,s.length,o.minDepth,e),new Z1(s,Rc,n,r)}addSelection(e,n,r,o){let i=this.done.length?this.done[this.done.length-1].selectionsAfter:Rc;return i.length>0&&n-this.prevTime<o&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&IRt(i[i.length-1],e)?this:new Z1(nOe(this.done,e),this.undone,n,r)}addMapping(e){return new Z1(hD(this.done,e),hD(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,n,r){let o=e==0?this.done:this.undone;if(o.length==0)return null;let i=o[o.length-1],s=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):n.selection);if(r&&i.selectionsAfter.length)return n.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:dq.of({side:e,rest:zRt(o),selection:s}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(i.changes){let a=o.length==1?Rc:o.slice(0,o.length-1);return i.mapped&&(a=hD(a,i.mapped)),n.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:dq.of({side:e,rest:a,selection:s}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}Z1.empty=new Z1(Rc,Rc);const rOe=[{key:"Mod-z",run:_Y,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Nb,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Nb,preventDefault:!0},{key:"Mod-u",run:NRt,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:RRt,preventDefault:!0}];function Qg(t,e){return it.create(t.ranges.map(e),t.mainIndex)}function n1(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function r1({state:t,dispatch:e},n){let r=Qg(t.selection,n);return r.eq(t.selection,!0)?!1:(e(n1(t,r)),!0)}function _P(t,e){return it.cursor(e?t.to:t.from)}function oOe(t,e){return r1(t,n=>n.empty?t.moveByChar(n,e):_P(n,e))}function ba(t){return t.textDirectionAt(t.state.selection.main.head)==$o.LTR}const iOe=t=>oOe(t,!ba(t)),sOe=t=>oOe(t,ba(t));function aOe(t,e){return r1(t,n=>n.empty?t.moveByGroup(n,e):_P(n,e))}const HRt=t=>aOe(t,!ba(t)),FRt=t=>aOe(t,ba(t));function qRt(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function xP(t,e,n){let r=Dr(t).resolveInner(e.head),o=n?Bn.closedBy:Bn.openedBy;for(let l=e.head;;){let c=n?r.childAfter(l):r.childBefore(l);if(!c)break;qRt(t,c,o)?r=c:l=n?c.to:c.from}let i=r.type.prop(o),s,a;return i&&(s=n?W1(t,r.from,1):W1(t,r.to,-1))&&s.matched?a=n?s.end.to:s.end.from:a=n?r.to:r.from,it.cursor(a,n?-1:1)}const VRt=t=>r1(t,e=>xP(t.state,e,!ba(t))),QRt=t=>r1(t,e=>xP(t.state,e,ba(t)));function lOe(t,e){return r1(t,n=>{if(!n.empty)return _P(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const cOe=t=>lOe(t,!1),uOe=t=>lOe(t,!0);function dOe(t){let e=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,n=0,r=0,o;if(e){for(let i of t.state.facet(ft.scrollMargins)){let s=i(t);s?.top&&(n=Math.max(s?.top,n)),s?.bottom&&(r=Math.max(s?.bottom,r))}o=t.scrollDOM.clientHeight-n-r}else o=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:e,height:Math.max(t.defaultLineHeight,o-5)}}function fOe(t,e){let n=dOe(t),{state:r}=t,o=Qg(r.selection,s=>s.empty?t.moveVertically(s,e,n.height):_P(s,e));if(o.eq(r.selection))return!1;let i;if(n.selfScroll){let s=t.coordsAtPos(r.selection.main.head),a=t.scrollDOM.getBoundingClientRect(),l=a.top+n.marginTop,c=a.bottom-n.marginBottom;s&&s.top>l&&s.bottom<c&&(i=ft.scrollIntoView(o.main.head,{y:"start",yMargin:s.top-l}))}return t.dispatch(n1(r,o),{effects:i}),!0}const Xce=t=>fOe(t,!1),fq=t=>fOe(t,!0);function Lh(t,e,n){let r=t.lineBlockAt(e.head),o=t.moveToLineBoundary(e,n);if(o.head==e.head&&o.head!=(n?r.to:r.from)&&(o=t.moveToLineBoundary(e,n,!1)),!n&&o.head==r.from&&r.length){let i=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;i&&e.head!=r.from+i&&(o=it.cursor(r.from+i))}return o}const URt=t=>r1(t,e=>Lh(t,e,!0)),WRt=t=>r1(t,e=>Lh(t,e,!1)),ZRt=t=>r1(t,e=>Lh(t,e,!ba(t))),GRt=t=>r1(t,e=>Lh(t,e,ba(t))),YRt=t=>r1(t,e=>it.cursor(t.lineBlockAt(e.head).from,1)),XRt=t=>r1(t,e=>it.cursor(t.lineBlockAt(e.head).to,-1));function KRt(t,e,n){let r=!1,o=Qg(t.selection,i=>{let s=W1(t,i.head,-1)||W1(t,i.head,1)||i.head>0&&W1(t,i.head-1,1)||i.head<t.doc.length&&W1(t,i.head+1,-1);if(!s||!s.end)return i;r=!0;let a=s.start.from==i.head?s.end.to:s.end.from;return it.cursor(a)});return r?(e(n1(t,o)),!0):!1}const JRt=({state:t,dispatch:e})=>KRt(t,e);function o0(t,e){let n=Qg(t.state.selection,r=>{let o=e(r);return it.range(r.anchor,o.head,o.goalColumn,o.bidiLevel||void 0,o.assoc)});return n.eq(t.state.selection)?!1:(t.dispatch(n1(t.state,n)),!0)}function hOe(t,e){return o0(t,n=>t.moveByChar(n,e))}const pOe=t=>hOe(t,!ba(t)),mOe=t=>hOe(t,ba(t));function gOe(t,e){return o0(t,n=>t.moveByGroup(n,e))}const eLt=t=>gOe(t,!ba(t)),tLt=t=>gOe(t,ba(t)),nLt=t=>o0(t,e=>xP(t.state,e,!ba(t))),rLt=t=>o0(t,e=>xP(t.state,e,ba(t)));function vOe(t,e){return o0(t,n=>t.moveVertically(n,e))}const bOe=t=>vOe(t,!1),_Oe=t=>vOe(t,!0);function xOe(t,e){return o0(t,n=>t.moveVertically(n,e,dOe(t).height))}const Kce=t=>xOe(t,!1),Jce=t=>xOe(t,!0),oLt=t=>o0(t,e=>Lh(t,e,!0)),iLt=t=>o0(t,e=>Lh(t,e,!1)),sLt=t=>o0(t,e=>Lh(t,e,!ba(t))),aLt=t=>o0(t,e=>Lh(t,e,ba(t))),lLt=t=>o0(t,e=>it.cursor(t.lineBlockAt(e.head).from)),cLt=t=>o0(t,e=>it.cursor(t.lineBlockAt(e.head).to)),e0e=({state:t,dispatch:e})=>(e(n1(t,{anchor:0})),!0),t0e=({state:t,dispatch:e})=>(e(n1(t,{anchor:t.doc.length})),!0),n0e=({state:t,dispatch:e})=>(e(n1(t,{anchor:t.selection.main.anchor,head:0})),!0),r0e=({state:t,dispatch:e})=>(e(n1(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),uLt=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),dLt=({state:t,dispatch:e})=>{let n=yP(t).map(({from:r,to:o})=>it.range(r,Math.min(o+1,t.doc.length)));return e(t.update({selection:it.create(n),userEvent:"select"})),!0},fLt=({state:t,dispatch:e})=>{let n=Qg(t.selection,r=>{let o=Dr(t),i=o.resolveStack(r.from,1);if(r.empty){let s=o.resolveStack(r.from,-1);s.node.from>=i.node.from&&s.node.to<=i.node.to&&(i=s)}for(let s=i;s;s=s.next){let{node:a}=s;if((a.from<r.from&&a.to>=r.to||a.to>r.to&&a.from<=r.from)&&s.next)return it.range(a.to,a.from)}return r});return n.eq(t.selection)?!1:(e(n1(t,n)),!0)};function yOe(t,e){let{state:n}=t,r=n.selection,o=n.selection.ranges.slice();for(let i of n.selection.ranges){let s=n.doc.lineAt(i.head);if(e?s.to<t.state.doc.length:s.from>0)for(let a=i;;){let l=t.moveVertically(a,e);if(l.head<s.from||l.head>s.to){o.some(c=>c.head==l.head)||o.push(l);break}else{if(l.head==a.head)break;a=l}}}return o.length==r.ranges.length?!1:(t.dispatch(n1(n,it.create(o,o.length-1))),!0)}const hLt=t=>yOe(t,!1),pLt=t=>yOe(t,!0),mLt=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=it.create([n.main]):n.main.empty||(r=it.create([it.cursor(n.main.head)])),r?(e(n1(t,r)),!0):!1};function fx(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,o=r.changeByRange(i=>{let{from:s,to:a}=i;if(s==a){let l=e(i);l<s?(n="delete.backward",l=rk(t,l,!1)):l>s&&(n="delete.forward",l=rk(t,l,!0)),s=Math.min(s,l),a=Math.max(a,l)}else s=rk(t,s,!1),a=rk(t,a,!0);return s==a?{range:i}:{changes:{from:s,to:a},range:it.cursor(s,s<i.head?-1:1)}});return o.changes.empty?!1:(t.dispatch(r.update(o,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?ft.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function rk(t,e,n){if(t instanceof ft)for(let r of t.state.facet(ft.atomicRanges).map(o=>o(t)))r.between(e,e,(o,i)=>{o<e&&i>e&&(e=n?i:o)});return e}const wOe=(t,e,n)=>fx(t,r=>{let o=r.from,{state:i}=t,s=i.doc.lineAt(o),a,l;if(n&&!e&&o>s.from&&o<s.from+200&&!/[^ \t]/.test(a=s.text.slice(0,o-s.from))){if(a[a.length-1]==" ")return o-1;let c=W2(a,i.tabSize),u=c%ah(i)||ah(i);for(let d=0;d<u&&a[a.length-1-d]==" ";d++)o--;l=o}else l=gs(s.text,o-s.from,e,e)+s.from,l==o&&s.number!=(e?i.doc.lines:1)?l+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(s.text.slice(l-s.from,o-s.from))&&(l=gs(s.text,l-s.from,!1,!1)+s.from);return l}),hq=t=>wOe(t,!1,!0),kOe=t=>wOe(t,!0,!1),OOe=(t,e)=>fx(t,n=>{let r=n.head,{state:o}=t,i=o.doc.lineAt(r),s=o.charCategorizer(r);for(let a=null;;){if(r==(e?i.to:i.from)){r==n.head&&i.number!=(e?o.doc.lines:1)&&(r+=e?1:-1);break}let l=gs(i.text,r-i.from,e)+i.from,c=i.text.slice(Math.min(r,l)-i.from,Math.max(r,l)-i.from),u=s(c);if(a!=null&&u!=a)break;(c!=" "||r!=n.head)&&(a=u),r=l}return r}),SOe=t=>OOe(t,!1),gLt=t=>OOe(t,!0),vLt=t=>fx(t,e=>{let n=t.lineBlockAt(e.head).to;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),bLt=t=>fx(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),_Lt=t=>fx(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),xLt=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:Pr.of(["",""])},range:it.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},yLt=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let o=r.from,i=t.doc.lineAt(o),s=o==i.from?o-1:gs(i.text,o-i.from,!1)+i.from,a=o==i.to?o+1:gs(i.text,o-i.from,!0)+i.from;return{changes:{from:s,to:a,insert:t.doc.slice(o,a).append(t.doc.slice(s,o))},range:it.cursor(a)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function yP(t){let e=[],n=-1;for(let r of t.selection.ranges){let o=t.doc.lineAt(r.from),i=t.doc.lineAt(r.to);if(!r.empty&&r.to==i.from&&(i=t.doc.lineAt(r.to-1)),n>=o.number){let s=e[e.length-1];s.to=i.to,s.ranges.push(r)}else e.push({from:o.from,to:i.to,ranges:[r]});n=i.number+1}return e}function COe(t,e,n){if(t.readOnly)return!1;let r=[],o=[];for(let i of yP(t)){if(n?i.to==t.doc.length:i.from==0)continue;let s=t.doc.lineAt(n?i.to+1:i.from-1),a=s.length+1;if(n){r.push({from:i.to,to:s.to},{from:i.from,insert:s.text+t.lineBreak});for(let l of i.ranges)o.push(it.range(Math.min(t.doc.length,l.anchor+a),Math.min(t.doc.length,l.head+a)))}else{r.push({from:s.from,to:i.from},{from:i.to,insert:t.lineBreak+s.text});for(let l of i.ranges)o.push(it.range(l.anchor-a,l.head-a))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:it.create(o,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const wLt=({state:t,dispatch:e})=>COe(t,e,!1),kLt=({state:t,dispatch:e})=>COe(t,e,!0);function AOe(t,e,n){if(t.readOnly)return!1;let r=[];for(let i of yP(t))n?r.push({from:i.from,insert:t.doc.slice(i.from,i.to)+t.lineBreak}):r.push({from:i.to,insert:t.lineBreak+t.doc.slice(i.from,i.to)});let o=t.changes(r);return e(t.update({changes:o,selection:t.selection.map(o,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const OLt=({state:t,dispatch:e})=>AOe(t,e,!1),SLt=({state:t,dispatch:e})=>AOe(t,e,!0),CLt=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(yP(e).map(({from:o,to:i})=>(o>0?o--:i<e.doc.length&&i++,{from:o,to:i}))),r=Qg(e.selection,o=>{let i;if(t.lineWrapping){let s=t.lineBlockAt(o.head),a=t.coordsAtPos(o.head,o.assoc||1);a&&(i=s.bottom+t.documentTop-a.bottom+t.defaultLineHeight/2)}return t.moveVertically(o,!0,i)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function ALt(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Dr(t).resolveInner(e),r=n.childBefore(e),o=n.childAfter(e),i;return r&&o&&r.to<=e&&o.from>=e&&(i=r.type.prop(Bn.closedBy))&&i.indexOf(o.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(o.from).from&&!/\S/.test(t.sliceDoc(r.to,o.from))?{from:r.to,to:o.from}:null}const o0e=EOe(!1),ELt=EOe(!0);function EOe(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(o=>{let{from:i,to:s}=o,a=e.doc.lineAt(i),l=!t&&i==s&&ALt(e,i);t&&(i=s=(s<=a.to?a:e.doc.lineAt(s)).to);let c=new mP(e,{simulateBreak:i,simulateDoubleBreak:!!l}),u=nY(c,i);for(u==null&&(u=W2(/^\s*/.exec(e.doc.lineAt(i).text)[0],e.tabSize));s<a.to&&/\s/.test(a.text[s-a.from]);)s++;l?{from:i,to:s}=l:i>a.from&&i<a.from+100&&!/\S/.test(a.text.slice(0,i))&&(i=a.from);let d=["",Eb(e,u)];return l&&d.push(Eb(e,c.lineIndent(a.from,-1))),{changes:{from:i,to:s,insert:Pr.of(d)},range:it.cursor(i+1+d[1].length)}});return n(e.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function xY(t,e){let n=-1;return t.changeByRange(r=>{let o=[];for(let s=r.from;s<=r.to;){let a=t.doc.lineAt(s);a.number>n&&(r.empty||r.to>a.from)&&(e(a,o,r),n=a.number),s=a.to+1}let i=t.changes(o);return{changes:o,range:it.range(i.mapPos(r.anchor,1),i.mapPos(r.head,1))}})}const TLt=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new mP(t,{overrideIndentation:i=>{let s=n[i];return s??-1}}),o=xY(t,(i,s,a)=>{let l=nY(r,i.from);if(l==null)return;/\S/.test(i.text)||(l=0);let c=/^\s*/.exec(i.text)[0],u=Eb(t,l);(c!=u||a.from<i.from+c.length)&&(n[i.from]=l,s.push({from:i.from,to:i.from+c.length,insert:u}))});return o.changes.empty||e(t.update(o,{userEvent:"indent"})),!0},yY=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(xY(t,(n,r)=>{r.push({from:n.from,insert:t.facet(Rh)})}),{userEvent:"input.indent"})),!0),wY=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(xY(t,(n,r)=>{let o=/^\s*/.exec(n.text)[0];if(!o)return;let i=W2(o,t.tabSize),s=0,a=Eb(t,Math.max(0,i-ah(t)));for(;s<o.length&&s<a.length&&o.charCodeAt(s)==a.charCodeAt(s);)s++;r.push({from:n.from+s,to:n.from+o.length,insert:a.slice(s)})}),{userEvent:"delete.dedent"})),!0),MLt=t=>(t.setTabFocusMode(),!0),PLt=[{key:"Ctrl-b",run:iOe,shift:pOe,preventDefault:!0},{key:"Ctrl-f",run:sOe,shift:mOe},{key:"Ctrl-p",run:cOe,shift:bOe},{key:"Ctrl-n",run:uOe,shift:_Oe},{key:"Ctrl-a",run:YRt,shift:lLt},{key:"Ctrl-e",run:XRt,shift:cLt},{key:"Ctrl-d",run:kOe},{key:"Ctrl-h",run:hq},{key:"Ctrl-k",run:vLt},{key:"Ctrl-Alt-h",run:SOe},{key:"Ctrl-o",run:xLt},{key:"Ctrl-t",run:yLt},{key:"Ctrl-v",run:fq}],jLt=[{key:"ArrowLeft",run:iOe,shift:pOe,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:HRt,shift:eLt,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:ZRt,shift:sLt,preventDefault:!0},{key:"ArrowRight",run:sOe,shift:mOe,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:FRt,shift:tLt,preventDefault:!0},{mac:"Cmd-ArrowRight",run:GRt,shift:aLt,preventDefault:!0},{key:"ArrowUp",run:cOe,shift:bOe,preventDefault:!0},{mac:"Cmd-ArrowUp",run:e0e,shift:n0e},{mac:"Ctrl-ArrowUp",run:Xce,shift:Kce},{key:"ArrowDown",run:uOe,shift:_Oe,preventDefault:!0},{mac:"Cmd-ArrowDown",run:t0e,shift:r0e},{mac:"Ctrl-ArrowDown",run:fq,shift:Jce},{key:"PageUp",run:Xce,shift:Kce},{key:"PageDown",run:fq,shift:Jce},{key:"Home",run:WRt,shift:iLt,preventDefault:!0},{key:"Mod-Home",run:e0e,shift:n0e},{key:"End",run:URt,shift:oLt,preventDefault:!0},{key:"Mod-End",run:t0e,shift:r0e},{key:"Enter",run:o0e,shift:o0e},{key:"Mod-a",run:uLt},{key:"Backspace",run:hq,shift:hq,preventDefault:!0},{key:"Delete",run:kOe,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:SOe,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:gLt,preventDefault:!0},{mac:"Mod-Backspace",run:bLt,preventDefault:!0},{mac:"Mod-Delete",run:_Lt,preventDefault:!0}].concat(PLt.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),kY=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:VRt,shift:nLt},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:QRt,shift:rLt},{key:"Alt-ArrowUp",run:wLt},{key:"Shift-Alt-ArrowUp",run:OLt},{key:"Alt-ArrowDown",run:kLt},{key:"Shift-Alt-ArrowDown",run:SLt},{key:"Mod-Alt-ArrowUp",run:hLt},{key:"Mod-Alt-ArrowDown",run:pLt},{key:"Escape",run:mLt},{key:"Mod-Enter",run:ELt},{key:"Alt-l",mac:"Ctrl-l",run:dLt},{key:"Mod-i",run:fLt,preventDefault:!0},{key:"Mod-[",run:wY},{key:"Mod-]",run:yY},{key:"Mod-Alt-\\",run:TLt},{key:"Shift-Mod-k",run:CLt},{key:"Shift-Mod-\\",run:JRt},{key:"Mod-/",run:ORt},{key:"Alt-A",run:CRt},{key:"Ctrl-m",mac:"Shift-Alt-m",run:MLt}].concat(jLt),i0e=typeof String.prototype.normalize=="function"?t=>t.normalize("NFKD"):t=>t;class OY{constructor(e,n,r=0,o=e.length,i,s){this.test=s,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(r,o),this.bufferStart=r,this.normalize=i?a=>i(i0e(a)):i0e,this.query=this.normalize(n)}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 Ql(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let n=PG(e),r=this.bufferStart+this.bufferPos;this.bufferPos+=H1(e);let o=this.normalize(n);if(o.length)for(let i=0,s=r;;i++){let a=o.charCodeAt(i),l=this.match(a,s,this.bufferPos+this.bufferStart);if(i==o.length-1){if(l)return this.value=l,this;break}s==r&&i<n.length&&n.charCodeAt(i)==a&&s++}}}match(e,n,r){let o=null;for(let i=0;i<this.matches.length;i+=2){let s=this.matches[i],a=!1;this.query.charCodeAt(s)==e&&(s==this.query.length-1?o={from:this.matches[i+1],to:r}:(this.matches[i]++,a=!0)),a||(this.matches.splice(i,2),i-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?o={from:n,to:r}:this.matches.push(1,n)),o&&this.test&&!this.test(o.from,o.to,this.buffer,this.bufferStart)&&(o=null),o}}typeof Symbol<"u"&&(OY.prototype[Symbol.iterator]=function(){return this});const TOe={from:-1,to:-1,match:/.*/.exec("")},SY="gm"+(/x/.unicode==null?"":"u");class MOe{constructor(e,n,r,o=0,i=e.length){if(this.text=e,this.to=i,this.curLine="",this.done=!1,this.value=TOe,/\\[sWDnr]|\n|\r|\[\^/.test(n))return new POe(e,n,r,o,i);this.re=new RegExp(n,SY+(r?.ignoreCase?"i":"")),this.test=r?.test,this.iter=e.iter();let s=e.lineAt(o);this.curLineStart=s.from,this.matchPos=rA(e,o),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(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(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let n=this.matchPos<=this.to&&this.re.exec(this.curLine);if(n){let r=this.curLineStart+n.index,o=r+n[0].length;if(this.matchPos=rA(this.text,o+(r==o?1:0)),r==this.curLineStart+this.curLine.length&&this.nextLine(),(r<o||r>this.value.to)&&(!this.test||this.test(r,o,n)))return this.value={from:r,to:o,match:n},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const pD=new WeakMap;class o6{constructor(e,n){this.from=e,this.text=n}get to(){return this.from+this.text.length}static get(e,n,r){let o=pD.get(e);if(!o||o.from>=r||o.to<=n){let a=new o6(n,e.sliceString(n,r));return pD.set(e,a),a}if(o.from==n&&o.to==r)return o;let{text:i,from:s}=o;return s>n&&(i=e.sliceString(n,s)+i,s=n),o.to<r&&(i+=e.sliceString(o.to,r)),pD.set(e,new o6(s,i)),new o6(n,i.slice(n-s,r-s))}}class POe{constructor(e,n,r,o,i){this.text=e,this.to=i,this.done=!1,this.value=TOe,this.matchPos=rA(e,o),this.re=new RegExp(n,SY+(r?.ignoreCase?"i":"")),this.test=r?.test,this.flat=o6.get(e,o,this.chunkEnd(o+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,n=this.re.exec(this.flat.text);if(n&&!n[0]&&n.index==e&&(this.re.lastIndex=e+1,n=this.re.exec(this.flat.text)),n){let r=this.flat.from+n.index,o=r+n[0].length;if((this.flat.to>=this.to||n.index+n[0].length<=this.flat.text.length-10)&&(!this.test||this.test(r,o,n)))return this.value={from:r,to:o,match:n},this.matchPos=rA(this.text,o+(r==o?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=o6.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(MOe.prototype[Symbol.iterator]=POe.prototype[Symbol.iterator]=function(){return this});function NLt(t){try{return new RegExp(t,SY),!0}catch{return!1}}function rA(t,e){if(e>=t.length)return e;let n=t.lineAt(e),r;for(;e<n.to&&(r=n.text.charCodeAt(e-n.from))>=56320&&r<57344;)e++;return e}const RLt={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},LLt=Ft.define({combine(t){return M4(t,RLt,{highlightWordAroundCursor:(e,n)=>e||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function jOe(t){return[BLt,$Lt]}const ILt=yt.mark({class:"cm-selectionMatch"}),DLt=yt.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function s0e(t,e,n,r){return(n==0||t(e.sliceDoc(n-1,n))!=zo.Word)&&(r==e.doc.length||t(e.sliceDoc(r,r+1))!=zo.Word)}function zLt(t,e,n,r){return t(e.sliceDoc(n,n+1))==zo.Word&&t(e.sliceDoc(r-1,r))==zo.Word}const $Lt=oi.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(LLt),{state:n}=t,r=n.selection;if(r.ranges.length>1)return yt.none;let o=r.main,i,s=null;if(o.empty){if(!e.highlightWordAroundCursor)return yt.none;let l=n.wordAt(o.head);if(!l)return yt.none;s=n.charCategorizer(o.head),i=n.sliceDoc(l.from,l.to)}else{let l=o.to-o.from;if(l<e.minSelectionLength||l>200)return yt.none;if(e.wholeWords){if(i=n.sliceDoc(o.from,o.to),s=n.charCategorizer(o.head),!(s0e(s,n,o.from,o.to)&&zLt(s,n,o.from,o.to)))return yt.none}else if(i=n.sliceDoc(o.from,o.to),!i)return yt.none}let a=[];for(let l of t.visibleRanges){let c=new OY(n.doc,i,l.from,l.to);for(;!c.next().done;){let{from:u,to:d}=c.value;if((!s||s0e(s,n,u,d))&&(o.empty&&u<=o.from&&d>=o.to?a.push(DLt.range(u,d)):(u>=o.to||d<=o.from)&&a.push(ILt.range(u,d)),a.length>e.maxMatches))return yt.none}}return yt.set(a)}},{decorations:t=>t.decorations}),BLt=ft.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});class HLt{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||NLt(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(n,r)=>r=="n"?`
67
- `:r=="r"?"\r":r=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new WLt(this):new VLt(this)}getCursor(e,n=0,r){let o=e.doc?e:Gn.create({doc:e});return r==null&&(r=o.doc.length),this.regexp?v5(this,o,n,r):g5(this,o,n,r)}}class NOe{constructor(e){this.spec=e}}function FLt(t,e,n){return(r,o,i,s)=>{if(n&&!n(r,o,i,s))return!1;let a=r>=s&&o<=s+i.length?i.slice(r-s,o-s):e.doc.sliceString(r,o);return t(a,e,r,o)}}function g5(t,e,n,r){let o;return t.wholeWord&&(o=qLt(e.doc,e.charCategorizer(e.selection.main.head))),t.test&&(o=FLt(t.test,e,o)),new OY(e.doc,t.unquoted,n,r,t.caseSensitive?void 0:i=>i.toLowerCase(),o)}function qLt(t,e){return(n,r,o,i)=>((i>n||i+o.length<r)&&(i=Math.max(0,n-2),o=t.sliceString(i,Math.min(t.length,r+2))),(e(oA(o,n-i))!=zo.Word||e(iA(o,n-i))!=zo.Word)&&(e(iA(o,r-i))!=zo.Word||e(oA(o,r-i))!=zo.Word))}class VLt extends NOe{constructor(e){super(e)}nextMatch(e,n,r){let o=g5(this.spec,e,r,e.doc.length).nextOverlapping();if(o.done){let i=Math.min(e.doc.length,n+this.spec.unquoted.length);o=g5(this.spec,e,0,i).nextOverlapping()}return o.done||o.value.from==n&&o.value.to==r?null:o.value}prevMatchInRange(e,n,r){for(let o=r;;){let i=Math.max(n,o-1e4-this.spec.unquoted.length),s=g5(this.spec,e,i,o),a=null;for(;!s.nextOverlapping().done;)a=s.value;if(a)return a;if(i==n)return null;o-=1e4}}prevMatch(e,n,r){let o=this.prevMatchInRange(e,0,n);return o||(o=this.prevMatchInRange(e,Math.max(0,r-this.spec.unquoted.length),e.doc.length)),o&&(o.from!=n||o.to!=r)?o:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,n){let r=g5(this.spec,e,0,e.doc.length),o=[];for(;!r.next().done;){if(o.length>=n)return null;o.push(r.value)}return o}highlight(e,n,r,o){let i=g5(this.spec,e,Math.max(0,n-this.spec.unquoted.length),Math.min(r+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)o(i.value.from,i.value.to)}}function QLt(t,e,n){return(r,o,i)=>(!n||n(r,o,i))&&t(i[0],e,r,o)}function v5(t,e,n,r){let o;return t.wholeWord&&(o=ULt(e.charCategorizer(e.selection.main.head))),t.test&&(o=QLt(t.test,e,o)),new MOe(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:o},n,r)}function oA(t,e){return t.slice(gs(t,e,!1),e)}function iA(t,e){return t.slice(e,gs(t,e))}function ULt(t){return(e,n,r)=>!r[0].length||(t(oA(r.input,r.index))!=zo.Word||t(iA(r.input,r.index))!=zo.Word)&&(t(iA(r.input,r.index+r[0].length))!=zo.Word||t(oA(r.input,r.index+r[0].length))!=zo.Word)}class WLt extends NOe{nextMatch(e,n,r){let o=v5(this.spec,e,r,e.doc.length).next();return o.done&&(o=v5(this.spec,e,0,n).next()),o.done?null:o.value}prevMatchInRange(e,n,r){for(let o=1;;o++){let i=Math.max(n,r-o*1e4),s=v5(this.spec,e,i,r),a=null;for(;!s.next().done;)a=s.value;if(a&&(i==n||a.from>i+10))return a;if(i==n)return null}}prevMatch(e,n,r){return this.prevMatchInRange(e,0,n)||this.prevMatchInRange(e,r,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(n,r)=>{if(r=="&")return e.match[0];if(r=="$")return"$";for(let o=r.length;o>0;o--){let i=+r.slice(0,o);if(i>0&&i<e.match.length)return e.match[i]+r.slice(o)}return n})}matchAll(e,n){let r=v5(this.spec,e,0,e.doc.length),o=[];for(;!r.next().done;){if(o.length>=n)return null;o.push(r.value)}return o}highlight(e,n,r,o){let i=v5(this.spec,e,Math.max(0,n-250),Math.min(r+250,e.doc.length));for(;!i.next().done;)o(i.value.from,i.value.to)}}const zi=t=>`var(--syntax-${t})`,ROe=[{tag:[_e.keyword,_e.modifier,_e.definitionKeyword,_e.moduleKeyword],color:zi("keyword")},{tag:[_e.controlKeyword,_e.operatorKeyword],color:zi("control")},{tag:[_e.string,_e.special(_e.string),_e.character],color:zi("string")},{tag:[_e.regexp,_e.escape],color:zi("regexp")},{tag:[_e.number,_e.integer,_e.float],color:zi("number")},{tag:[_e.bool,_e.null,_e.atom,_e.constant(_e.variableName)],color:zi("constant")},{tag:[_e.comment,_e.lineComment,_e.blockComment,_e.docComment],color:zi("comment"),fontStyle:"italic"},{tag:[_e.function(_e.variableName),_e.function(_e.propertyName),_e.definition(_e.function(_e.variableName))],color:zi("function")},{tag:[_e.variableName,_e.definition(_e.variableName)],color:zi("variable")},{tag:[_e.typeName,_e.className,_e.namespace,_e.macroName],color:zi("type")},{tag:[_e.propertyName,_e.definition(_e.propertyName)],color:zi("property")},{tag:[_e.operator,_e.derefOperator,_e.compareOperator],color:zi("operator")},{tag:[_e.tagName],color:zi("tag")},{tag:[_e.attributeName],color:zi("attribute")},{tag:[_e.punctuation,_e.bracket,_e.angleBracket,_e.separator],color:zi("punctuation")},{tag:_e.inserted,color:zi("inserted")},{tag:_e.deleted,color:zi("deleted")},{tag:_e.invalid,color:zi("invalid")}],ZLt=[{tag:_e.heading,color:zi("heading"),fontWeight:"bold"},{tag:[_e.link,_e.url],color:"var(--link)",textDecoration:"underline"},{tag:_e.strong,fontWeight:"bold"},{tag:_e.emphasis,fontStyle:"italic"},{tag:_e.strikethrough,textDecoration:"line-through"}],GLt=ux.define(ROe),YLt=ux.define([...ROe,...ZLt]);function CY(t){return`var(--code-font-size, ${t}px)`}function LOe(t){return[ft.theme({"&":{color:"var(--foreground)",backgroundColor:"var(--background)"},".cm-scroller":{fontFamily:"var(--font-code)"},".cm-content":{caretColor:"var(--foreground)"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--foreground)"},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"var(--selection)"},".cm-gutters":{backgroundColor:"var(--background)",color:"var(--muted-foreground)",border:"none"},".cm-activeLine":{backgroundColor:"var(--editor-active-line)"},".cm-activeLineGutter":{backgroundColor:"var(--editor-active-line)",color:"var(--foreground)"},".cm-selectionMatch":{backgroundColor:"var(--search-match)"},".cm-searchMatch":{backgroundColor:"var(--search-match)",borderRadius:"2px"},".cm-searchMatch-selected":{backgroundColor:"var(--search-match-current)"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"var(--selection)"},".cm-foldPlaceholder":{backgroundColor:"var(--muted)",color:"var(--muted-foreground)",border:"none"},".cm-tooltip":{backgroundColor:"var(--popover)",color:"var(--popover-foreground)",border:"1px solid var(--border)"},".cm-panels":{backgroundColor:"var(--popover)",color:"var(--popover-foreground)"}},{dark:t}),Tke(YLt)]}async function wP(t){try{switch(t){case"javascript":return re(()=>Promise.resolve().then(()=>sk),void 0).then(e=>e.javascript());case"jsx":return re(()=>Promise.resolve().then(()=>sk),void 0).then(e=>e.javascript({jsx:!0}));case"typescript":return re(()=>Promise.resolve().then(()=>sk),void 0).then(e=>e.javascript({typescript:!0}));case"tsx":return re(()=>Promise.resolve().then(()=>sk),void 0).then(e=>e.javascript({jsx:!0,typescript:!0}));case"python":return re(()=>import("./index-DRo8uUPl.js"),[]).then(e=>e.python());case"html":return re(()=>Promise.resolve().then(()=>e$t),void 0).then(e=>e.html());case"css":return re(()=>Promise.resolve().then(()=>lzt),void 0).then(e=>e.css());case"scss":case"sass":return re(()=>import("./index-B52rCane.js"),[]).then(e=>e.sass());case"less":return re(()=>import("./index-g0Sr5h74.js"),[]).then(e=>e.less());case"json":case"jsonc":return re(()=>import("./index-CDRJgI3A.js"),[]).then(e=>e.json());case"markdown":case"mdx":return re(()=>Promise.resolve().then(()=>d$t),void 0).then(e=>e.markdown());case"xml":return re(()=>import("./index-Hh-Dy8VL.js"),[]).then(e=>e.xml());case"yaml":return re(()=>import("./index-21p4gEDF.js"),[]).then(e=>e.yaml());case"sql":return re(()=>import("./index-ClYtumza.js"),[]).then(e=>e.sql());case"rust":return re(()=>import("./index-DvCvhnCb.js"),[]).then(e=>e.rust());case"go":return re(()=>import("./index-CxNXgFPY.js"),[]).then(e=>e.go());case"java":return re(()=>import("./index-BMcO1RPX.js"),[]).then(e=>e.java());case"kotlin":return re(()=>import("./index-BMcO1RPX.js"),[]).then(e=>e.java());case"c":case"cpp":return re(()=>import("./index-BULPK8ND.js"),[]).then(e=>e.cpp());case"php":return re(()=>import("./index-ZYHE2FSs.js"),[]).then(e=>e.php());case"bash":case"fish":case"powershell":return re(async()=>{const{shell:e}=await import("./shell-CjFT_Tl9.js");return{shell:e}},[]).then(({shell:e})=>new js(cl.define(e)));case"ruby":return re(async()=>{const{ruby:e}=await import("./ruby-B2Rjki9n.js");return{ruby:e}},[]).then(({ruby:e})=>new js(cl.define(e)));case"dockerfile":return re(async()=>{const{dockerFile:e}=await import("./dockerfile-ZL4hHokT.js");return{dockerFile:e}},[]).then(({dockerFile:e})=>new js(cl.define(e)));case"toml":return re(async()=>{const{toml:e}=await import("./toml-Bm5Em-hy.js");return{toml:e}},[]).then(({toml:e})=>new js(cl.define(e)));case"lua":return re(async()=>{const{lua:e}=await import("./lua-BgMRiT3U.js");return{lua:e}},[]).then(({lua:e})=>new js(cl.define(e)));case"r":return re(async()=>{const{r:e}=await import("./r-B6wPVr8A.js");return{r:e}},[]).then(({r:e})=>new js(cl.define(e)));case"swift":return re(async()=>{const{swift:e}=await import("./swift-BzpIVaGY.js");return{swift:e}},[]).then(({swift:e})=>new js(cl.define(e)));case"clojure":return re(async()=>{const{clojure:e}=await import("./clojure-BMjYHr_A.js");return{clojure:e}},[]).then(({clojure:e})=>new js(cl.define(e)));case"dart":return re(async()=>{const{dart:e}=await import("./clike-B9uivgTg.js");return{dart:e}},[]).then(({dart:e})=>new js(cl.define(e)));case"erlang":return re(async()=>{const{erlang:e}=await import("./erlang-BNw1qcRV.js");return{erlang:e}},[]).then(({erlang:e})=>new js(cl.define(e)));case"haskell":return re(async()=>{const{haskell:e}=await import("./haskell-Cw1EW3IL.js");return{haskell:e}},[]).then(({haskell:e})=>new js(cl.define(e)));case"diff":return re(async()=>{const{diff:e}=await import("./diff-DbItnlRl.js");return{diff:e}},[]).then(({diff:e})=>new js(cl.define(e)));default:return null}}catch{return null}}function aS(t=!0,e){const n=e?.naturalHeight??!1,r={fontSize:CY(13)};n||(r.height="100%");const o=n?{overflowX:"auto",height:"auto"}:{overflow:"auto"};return[Gn.readOnly.of(!0),ft.editable.of(!1),...e?.skipLineNumbers?[]:[GG()],Nke(),jOe(),LOe(t),dd.of([...kY]),ft.theme({"&":r,".cm-scroller":o,".cm-lineNumbers":{paddingLeft:"12px",paddingRight:"12px"},".cm-activeLineGutter":{backgroundColor:"transparent"},".cm-activeLine":{backgroundColor:"transparent"}},{dark:t})]}function XLt(t){const{state:e}=t;if(e.selection.ranges.length>1)return!1;const{from:n,to:r}=e.selection.main,o=e.doc.lineAt(n),i=/^\s*/.exec(o.text)[0],s=o.text.slice(0,n-o.from).trimEnd(),a=/[{([]$/.test(s),l=e.doc.lineAt(r),c=l.text.slice(r-l.from).trimStart(),u=/^[})\]]/.test(c),d=e.facet(Rh);if(a&&u){const g=`
67
+ `:r=="r"?"\r":r=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new WLt(this):new VLt(this)}getCursor(e,n=0,r){let o=e.doc?e:Gn.create({doc:e});return r==null&&(r=o.doc.length),this.regexp?v5(this,o,n,r):g5(this,o,n,r)}}class NOe{constructor(e){this.spec=e}}function FLt(t,e,n){return(r,o,i,s)=>{if(n&&!n(r,o,i,s))return!1;let a=r>=s&&o<=s+i.length?i.slice(r-s,o-s):e.doc.sliceString(r,o);return t(a,e,r,o)}}function g5(t,e,n,r){let o;return t.wholeWord&&(o=qLt(e.doc,e.charCategorizer(e.selection.main.head))),t.test&&(o=FLt(t.test,e,o)),new OY(e.doc,t.unquoted,n,r,t.caseSensitive?void 0:i=>i.toLowerCase(),o)}function qLt(t,e){return(n,r,o,i)=>((i>n||i+o.length<r)&&(i=Math.max(0,n-2),o=t.sliceString(i,Math.min(t.length,r+2))),(e(oA(o,n-i))!=zo.Word||e(iA(o,n-i))!=zo.Word)&&(e(iA(o,r-i))!=zo.Word||e(oA(o,r-i))!=zo.Word))}class VLt extends NOe{constructor(e){super(e)}nextMatch(e,n,r){let o=g5(this.spec,e,r,e.doc.length).nextOverlapping();if(o.done){let i=Math.min(e.doc.length,n+this.spec.unquoted.length);o=g5(this.spec,e,0,i).nextOverlapping()}return o.done||o.value.from==n&&o.value.to==r?null:o.value}prevMatchInRange(e,n,r){for(let o=r;;){let i=Math.max(n,o-1e4-this.spec.unquoted.length),s=g5(this.spec,e,i,o),a=null;for(;!s.nextOverlapping().done;)a=s.value;if(a)return a;if(i==n)return null;o-=1e4}}prevMatch(e,n,r){let o=this.prevMatchInRange(e,0,n);return o||(o=this.prevMatchInRange(e,Math.max(0,r-this.spec.unquoted.length),e.doc.length)),o&&(o.from!=n||o.to!=r)?o:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,n){let r=g5(this.spec,e,0,e.doc.length),o=[];for(;!r.next().done;){if(o.length>=n)return null;o.push(r.value)}return o}highlight(e,n,r,o){let i=g5(this.spec,e,Math.max(0,n-this.spec.unquoted.length),Math.min(r+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)o(i.value.from,i.value.to)}}function QLt(t,e,n){return(r,o,i)=>(!n||n(r,o,i))&&t(i[0],e,r,o)}function v5(t,e,n,r){let o;return t.wholeWord&&(o=ULt(e.charCategorizer(e.selection.main.head))),t.test&&(o=QLt(t.test,e,o)),new MOe(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:o},n,r)}function oA(t,e){return t.slice(gs(t,e,!1),e)}function iA(t,e){return t.slice(e,gs(t,e))}function ULt(t){return(e,n,r)=>!r[0].length||(t(oA(r.input,r.index))!=zo.Word||t(iA(r.input,r.index))!=zo.Word)&&(t(iA(r.input,r.index+r[0].length))!=zo.Word||t(oA(r.input,r.index+r[0].length))!=zo.Word)}class WLt extends NOe{nextMatch(e,n,r){let o=v5(this.spec,e,r,e.doc.length).next();return o.done&&(o=v5(this.spec,e,0,n).next()),o.done?null:o.value}prevMatchInRange(e,n,r){for(let o=1;;o++){let i=Math.max(n,r-o*1e4),s=v5(this.spec,e,i,r),a=null;for(;!s.next().done;)a=s.value;if(a&&(i==n||a.from>i+10))return a;if(i==n)return null}}prevMatch(e,n,r){return this.prevMatchInRange(e,0,n)||this.prevMatchInRange(e,r,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(n,r)=>{if(r=="&")return e.match[0];if(r=="$")return"$";for(let o=r.length;o>0;o--){let i=+r.slice(0,o);if(i>0&&i<e.match.length)return e.match[i]+r.slice(o)}return n})}matchAll(e,n){let r=v5(this.spec,e,0,e.doc.length),o=[];for(;!r.next().done;){if(o.length>=n)return null;o.push(r.value)}return o}highlight(e,n,r,o){let i=v5(this.spec,e,Math.max(0,n-250),Math.min(r+250,e.doc.length));for(;!i.next().done;)o(i.value.from,i.value.to)}}const zi=t=>`var(--syntax-${t})`,ROe=[{tag:[_e.keyword,_e.modifier,_e.definitionKeyword,_e.moduleKeyword],color:zi("keyword")},{tag:[_e.controlKeyword,_e.operatorKeyword],color:zi("control")},{tag:[_e.string,_e.special(_e.string),_e.character],color:zi("string")},{tag:[_e.regexp,_e.escape],color:zi("regexp")},{tag:[_e.number,_e.integer,_e.float],color:zi("number")},{tag:[_e.bool,_e.null,_e.atom,_e.constant(_e.variableName)],color:zi("constant")},{tag:[_e.comment,_e.lineComment,_e.blockComment,_e.docComment],color:zi("comment"),fontStyle:"italic"},{tag:[_e.function(_e.variableName),_e.function(_e.propertyName),_e.definition(_e.function(_e.variableName))],color:zi("function")},{tag:[_e.variableName,_e.definition(_e.variableName)],color:zi("variable")},{tag:[_e.typeName,_e.className,_e.namespace,_e.macroName],color:zi("type")},{tag:[_e.propertyName,_e.definition(_e.propertyName)],color:zi("property")},{tag:[_e.operator,_e.derefOperator,_e.compareOperator],color:zi("operator")},{tag:[_e.tagName],color:zi("tag")},{tag:[_e.attributeName],color:zi("attribute")},{tag:[_e.punctuation,_e.bracket,_e.angleBracket,_e.separator],color:zi("punctuation")},{tag:_e.inserted,color:zi("inserted")},{tag:_e.deleted,color:zi("deleted")},{tag:_e.invalid,color:zi("invalid")}],ZLt=[{tag:_e.heading,color:zi("heading"),fontWeight:"bold"},{tag:[_e.link,_e.url],color:"var(--link)",textDecoration:"underline"},{tag:_e.strong,fontWeight:"bold"},{tag:_e.emphasis,fontStyle:"italic"},{tag:_e.strikethrough,textDecoration:"line-through"}],GLt=ux.define(ROe),YLt=ux.define([...ROe,...ZLt]);function CY(t){return`var(--code-font-size, ${t}px)`}function LOe(t){return[ft.theme({"&":{color:"var(--foreground)",backgroundColor:"var(--background)"},".cm-scroller":{fontFamily:"var(--font-code)"},".cm-content":{caretColor:"var(--foreground)"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--foreground)"},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"var(--selection)"},".cm-gutters":{backgroundColor:"var(--background)",color:"var(--muted-foreground)",border:"none"},".cm-activeLine":{backgroundColor:"var(--editor-active-line)"},".cm-activeLineGutter":{backgroundColor:"var(--editor-active-line)",color:"var(--foreground)"},".cm-selectionMatch":{backgroundColor:"var(--search-match)"},".cm-searchMatch":{backgroundColor:"var(--search-match)",borderRadius:"2px"},".cm-searchMatch-selected":{backgroundColor:"var(--search-match-current)"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"var(--selection)"},".cm-foldPlaceholder":{backgroundColor:"var(--muted)",color:"var(--muted-foreground)",border:"none"},".cm-tooltip":{backgroundColor:"var(--popover)",color:"var(--popover-foreground)",border:"1px solid var(--border)"},".cm-panels":{backgroundColor:"var(--popover)",color:"var(--popover-foreground)"}},{dark:t}),Tke(YLt)]}async function wP(t){try{switch(t){case"javascript":return re(()=>Promise.resolve().then(()=>sk),void 0).then(e=>e.javascript());case"jsx":return re(()=>Promise.resolve().then(()=>sk),void 0).then(e=>e.javascript({jsx:!0}));case"typescript":return re(()=>Promise.resolve().then(()=>sk),void 0).then(e=>e.javascript({typescript:!0}));case"tsx":return re(()=>Promise.resolve().then(()=>sk),void 0).then(e=>e.javascript({jsx:!0,typescript:!0}));case"python":return re(()=>import("./index-Be1D1vwS.js"),[]).then(e=>e.python());case"html":return re(()=>Promise.resolve().then(()=>e$t),void 0).then(e=>e.html());case"css":return re(()=>Promise.resolve().then(()=>lzt),void 0).then(e=>e.css());case"scss":case"sass":return re(()=>import("./index-CJefa5Go.js"),[]).then(e=>e.sass());case"less":return re(()=>import("./index-jC0z3Kaq.js"),[]).then(e=>e.less());case"json":case"jsonc":return re(()=>import("./index-Qk1h8PGS.js"),[]).then(e=>e.json());case"markdown":case"mdx":return re(()=>Promise.resolve().then(()=>d$t),void 0).then(e=>e.markdown());case"xml":return re(()=>import("./index-DoGYlvHl.js"),[]).then(e=>e.xml());case"yaml":return re(()=>import("./index-DrM0qB0a.js"),[]).then(e=>e.yaml());case"sql":return re(()=>import("./index-CsZW3tVv.js"),[]).then(e=>e.sql());case"rust":return re(()=>import("./index-Q6D-8JjG.js"),[]).then(e=>e.rust());case"go":return re(()=>import("./index-Dy40JkoS.js"),[]).then(e=>e.go());case"java":return re(()=>import("./index-XAyPsPHs.js"),[]).then(e=>e.java());case"kotlin":return re(()=>import("./index-XAyPsPHs.js"),[]).then(e=>e.java());case"c":case"cpp":return re(()=>import("./index-DjGPjARU.js"),[]).then(e=>e.cpp());case"php":return re(()=>import("./index-DGN6wKkW.js"),[]).then(e=>e.php());case"bash":case"fish":case"powershell":return re(async()=>{const{shell:e}=await import("./shell-CjFT_Tl9.js");return{shell:e}},[]).then(({shell:e})=>new js(cl.define(e)));case"ruby":return re(async()=>{const{ruby:e}=await import("./ruby-B2Rjki9n.js");return{ruby:e}},[]).then(({ruby:e})=>new js(cl.define(e)));case"dockerfile":return re(async()=>{const{dockerFile:e}=await import("./dockerfile-ZL4hHokT.js");return{dockerFile:e}},[]).then(({dockerFile:e})=>new js(cl.define(e)));case"toml":return re(async()=>{const{toml:e}=await import("./toml-Bm5Em-hy.js");return{toml:e}},[]).then(({toml:e})=>new js(cl.define(e)));case"lua":return re(async()=>{const{lua:e}=await import("./lua-BgMRiT3U.js");return{lua:e}},[]).then(({lua:e})=>new js(cl.define(e)));case"r":return re(async()=>{const{r:e}=await import("./r-B6wPVr8A.js");return{r:e}},[]).then(({r:e})=>new js(cl.define(e)));case"swift":return re(async()=>{const{swift:e}=await import("./swift-BzpIVaGY.js");return{swift:e}},[]).then(({swift:e})=>new js(cl.define(e)));case"clojure":return re(async()=>{const{clojure:e}=await import("./clojure-BMjYHr_A.js");return{clojure:e}},[]).then(({clojure:e})=>new js(cl.define(e)));case"dart":return re(async()=>{const{dart:e}=await import("./clike-B9uivgTg.js");return{dart:e}},[]).then(({dart:e})=>new js(cl.define(e)));case"erlang":return re(async()=>{const{erlang:e}=await import("./erlang-BNw1qcRV.js");return{erlang:e}},[]).then(({erlang:e})=>new js(cl.define(e)));case"haskell":return re(async()=>{const{haskell:e}=await import("./haskell-Cw1EW3IL.js");return{haskell:e}},[]).then(({haskell:e})=>new js(cl.define(e)));case"diff":return re(async()=>{const{diff:e}=await import("./diff-DbItnlRl.js");return{diff:e}},[]).then(({diff:e})=>new js(cl.define(e)));default:return null}}catch{return null}}function aS(t=!0,e){const n=e?.naturalHeight??!1,r={fontSize:CY(13)};n||(r.height="100%");const o=n?{overflowX:"auto",height:"auto"}:{overflow:"auto"};return[Gn.readOnly.of(!0),ft.editable.of(!1),...e?.skipLineNumbers?[]:[GG()],Nke(),jOe(),LOe(t),dd.of([...kY]),ft.theme({"&":r,".cm-scroller":o,".cm-lineNumbers":{paddingLeft:"12px",paddingRight:"12px"},".cm-activeLineGutter":{backgroundColor:"transparent"},".cm-activeLine":{backgroundColor:"transparent"}},{dark:t})]}function XLt(t){const{state:e}=t;if(e.selection.ranges.length>1)return!1;const{from:n,to:r}=e.selection.main,o=e.doc.lineAt(n),i=/^\s*/.exec(o.text)[0],s=o.text.slice(0,n-o.from).trimEnd(),a=/[{([]$/.test(s),l=e.doc.lineAt(r),c=l.text.slice(r-l.from).trimStart(),u=/^[})\]]/.test(c),d=e.facet(Rh);if(a&&u){const g=`
68
68
  ${i}${d}`,_=`
69
69
  ${i}`;return t.dispatch(e.update({changes:{from:n,to:r,insert:g+_},selection:it.cursor(n+g.length),userEvent:"input"})),!0}const p=`
70
70
  ${i}${a?d:""}`;return t.dispatch(e.update({changes:{from:n,to:r,insert:p},selection:it.cursor(n+p.length),userEvent:"input"})),!0}function KLt(t=!0,e,n){const i=[...e?[{key:"Mod-s",run:()=>(e(),!0)}]:[]];return[GG(),Jke(),cNt(),Nke(),dRt(),Xjt(),Rh.of(" "),Gn.tabSize.of(2),jOe(),LOe(t),dd.of([...i,{key:"Enter",run:XLt},{key:"Tab",run:yY},{key:"Shift-Tab",run:wY},...mRt,...kY,...rOe,...iNt,{key:"Mod-z",run:()=>!0},{key:"Mod-Shift-z",run:()=>!0},{key:"Mod-y",run:()=>!0}]),ft.domEventHandlers({keydown(s){const a=s.metaKey||s.ctrlKey;return(s.key==="Tab"||a&&s.key.toLowerCase()==="z"||a&&s.key.toLowerCase()==="y")&&s.stopPropagation(),!1}}),ft.theme({"&":{height:"100%",fontSize:CY(13)},".cm-scroller":{overflow:"auto"},".cm-lineNumbers":{paddingLeft:"12px",paddingRight:"12px"}},{dark:t})]}const AY=xn.define(),JLt=yt.mark({class:"cm-searchMatch"}),eIt=2e5,tIt=to.define({create(){return{query:"",decorations:yt.none}},update(t,e){for(const n of e.effects)if(n.is(AY)){const{query:r,opts:o}=n.value;return{query:r,opts:o,decorations:a0e(e.state,r,o)}}return e.docChanged?t.query&&e.state.doc.length<=eIt?{...t,decorations:a0e(e.state,t.query,t.opts)}:{...t,decorations:t.decorations.map(e.changes)}:t},provide:t=>ft.decorations.from(t,e=>e.decorations)});function sA(){return tIt}function a0e(t,e,n){if(!e)return yt.none;const r=IOe(e,n);if(!r.valid)return yt.none;const o=new Ua,i=r.getCursor(t);let s=i.next();for(;!s.done;)o.add(s.value.from,s.value.to,JLt),s=i.next();return o.finish()}function IOe(t,e){return new HLt({search:t,caseSensitive:e?.caseSensitive??!1,literal:!e?.regex,regexp:e?.regex??!1,wholeWord:e?.wholeWord??!1})}function l0e(t,e,n){for(const r of t)r.dispatch({effects:AY.of({query:e,opts:n})})}function nIt(t,e,n){if(!e)return[];const r=IOe(e,n),o=[];for(const i of t){const s=r.getCursor(i.state);let a=s.next();for(;!a.done;)o.push({view:i,from:a.value.from,to:a.value.to}),a=s.next()}return o}function c0e(t){t.view.dispatch({selection:{anchor:t.from,head:t.to},effects:ft.scrollIntoView(t.from,{y:"center"}),userEvent:"select.search"})}function rIt(t){for(const e of t)e.dispatch({effects:AY.of({query:""}),selection:{anchor:e.state.selection.main.head}})}const kP=xn.define(),oIt=yt.line({class:"cm-highlighted-line"}),iIt=to.define({create(){return yt.none},update(t,e){for(const n of e.effects)if(n.is(kP)){if(!n.value)return yt.none;const{from:r,to:o}=n.value,i=e.state.doc,s=[];for(let a=r;a<=o&&a<=i.lines;a++)s.push(oIt.range(i.line(a).from));return yt.set(s)}return t},provide:t=>ft.decorations.from(t)});function DOe(t=!0){return[iIt,ft.theme({".cm-highlighted-line":{backgroundColor:"color-mix(in oklab, var(--search-match) 50%, transparent)"}},{dark:t})]}function aA(t,e,n,r){const o=t.state.doc,i=Math.max(1,Math.min(e,o.lines)),s=n?Math.max(i,Math.min(n,o.lines)):i,a=o.line(i),l=r!=null?Math.min(a.from+r-1,a.to):a.from;t.dispatch({selection:{anchor:l},effects:[kP.of({from:i,to:s}),ft.scrollIntoView(l,{y:"center"})]})}const sIt=10;function zOe(t){let e=-1;return ft.updateListener.of(n=>{if(!n.selectionSet||!n.transactions.some(o=>o.isUserEvent("select")))return;const r=n.state.doc.lineAt(n.state.selection.main.head).number;e>=0&&Math.abs(r-e)>=sIt&&t(e,r),e=r})}function aIt(t){return{editorState:t.state.toJSON({history:eOe}),scrollTop:t.scrollDOM.scrollTop}}function lIt(t){return{selection:t.state.selection.toJSON(),scrollTop:t.scrollDOM.scrollTop}}function cIt(t,e){try{const n=it.fromJSON(t),r=o=>Math.max(0,Math.min(o,e));return it.create(n.ranges.map(o=>it.range(r(o.anchor),r(o.head))),n.mainIndex)}catch{return null}}class lA{static create(e,n,r,o,i){let s=o+(o<<8)+e+(n<<4)|0;return new lA(e,n,r,s,i,[],[])}constructor(e,n,r,o,i,s,a){this.type=e,this.value=n,this.from=r,this.hash=o,this.end=i,this.children=s,this.positions=a,this.hashProp=[[Bn.contextHash,o]]}addChild(e,n){e.prop(Bn.contextHash)!=this.hash&&(e=new fr(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(n)}toTree(e,n=this.end){let r=this.children.length-1;return r>=0&&(n=Math.max(n,this.positions[r]+this.children[r].length+this.from)),new fr(e.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(o,i,s)=>new fr(Mi.none,o,i,s,this.hashProp)})}}var St;(function(t){t[t.Document=1]="Document",t[t.CodeBlock=2]="CodeBlock",t[t.FencedCode=3]="FencedCode",t[t.Blockquote=4]="Blockquote",t[t.HorizontalRule=5]="HorizontalRule",t[t.BulletList=6]="BulletList",t[t.OrderedList=7]="OrderedList",t[t.ListItem=8]="ListItem",t[t.ATXHeading1=9]="ATXHeading1",t[t.ATXHeading2=10]="ATXHeading2",t[t.ATXHeading3=11]="ATXHeading3",t[t.ATXHeading4=12]="ATXHeading4",t[t.ATXHeading5=13]="ATXHeading5",t[t.ATXHeading6=14]="ATXHeading6",t[t.SetextHeading1=15]="SetextHeading1",t[t.SetextHeading2=16]="SetextHeading2",t[t.HTMLBlock=17]="HTMLBlock",t[t.LinkReference=18]="LinkReference",t[t.Paragraph=19]="Paragraph",t[t.CommentBlock=20]="CommentBlock",t[t.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",t[t.Escape=22]="Escape",t[t.Entity=23]="Entity",t[t.HardBreak=24]="HardBreak",t[t.Emphasis=25]="Emphasis",t[t.StrongEmphasis=26]="StrongEmphasis",t[t.Link=27]="Link",t[t.Image=28]="Image",t[t.InlineCode=29]="InlineCode",t[t.HTMLTag=30]="HTMLTag",t[t.Comment=31]="Comment",t[t.ProcessingInstruction=32]="ProcessingInstruction",t[t.Autolink=33]="Autolink",t[t.HeaderMark=34]="HeaderMark",t[t.QuoteMark=35]="QuoteMark",t[t.ListMark=36]="ListMark",t[t.LinkMark=37]="LinkMark",t[t.EmphasisMark=38]="EmphasisMark",t[t.CodeMark=39]="CodeMark",t[t.CodeText=40]="CodeText",t[t.CodeInfo=41]="CodeInfo",t[t.LinkTitle=42]="LinkTitle",t[t.LinkLabel=43]="LinkLabel",t[t.URL=44]="URL"})(St||(St={}));class uIt{constructor(e,n){this.start=e,this.content=n,this.marks=[],this.parsers=[]}}class dIt{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return g9(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,n=0,r=0){for(let o=n;o<e;o++)r+=this.text.charCodeAt(o)==9?4-r%4:1;return r}findColumn(e){let n=0;for(let r=0;n<this.text.length&&r<e;n++)r+=this.text.charCodeAt(n)==9?4-r%4:1;return n}scrub(){if(!this.baseIndent)return this.text;let e="";for(let n=0;n<this.basePos;n++)e+=" ";return e+this.text.slice(this.basePos)}}function u0e(t,e,n){if(n.pos==n.text.length||t!=e.block&&n.indent>=e.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let r=(t.type==St.OrderedList?MY:TY)(n,e,!1);return r>0&&(t.type!=St.BulletList||EY(n,e,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==t.value}const $Oe={[St.Blockquote](t,e,n){return n.next!=62?!1:(n.markers.push(Lr(St.QuoteMark,e.lineStart+n.pos,e.lineStart+n.pos+1)),n.moveBase(n.pos+(i0(n.text.charCodeAt(n.pos+1))?2:1)),t.end=e.lineStart+n.text.length,!0)},[St.ListItem](t,e,n){return n.indent<n.baseIndent+t.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+t.value),!0)},[St.OrderedList]:u0e,[St.BulletList]:u0e,[St.Document](){return!0}};function i0(t){return t==32||t==9||t==10||t==13}function g9(t,e=0){for(;e<t.length&&i0(t.charCodeAt(e));)e++;return e}function d0e(t,e,n){for(;e>n&&i0(t.charCodeAt(e-1));)e--;return e}function BOe(t){if(t.next!=96&&t.next!=126)return-1;let e=t.pos+1;for(;e<t.text.length&&t.text.charCodeAt(e)==t.next;)e++;if(e<t.pos+3)return-1;if(t.next==96){for(let n=e;n<t.text.length;n++)if(t.text.charCodeAt(n)==96)return-1}return e}function HOe(t){return t.next!=62?-1:t.text.charCodeAt(t.pos+1)==32?2:1}function EY(t,e,n){if(t.next!=42&&t.next!=45&&t.next!=95)return-1;let r=1;for(let o=t.pos+1;o<t.text.length;o++){let i=t.text.charCodeAt(o);if(i==t.next)r++;else if(!i0(i))return-1}return n&&t.next==45&&VOe(t)>-1&&t.depth==e.stack.length&&e.parser.leafBlockParsers.indexOf(ZOe.SetextHeading)>-1||r<3?-1:1}function FOe(t,e){for(let n=t.stack.length-1;n>=0;n--)if(t.stack[n].type==e)return!0;return!1}function TY(t,e,n){return(t.next==45||t.next==43||t.next==42)&&(t.pos==t.text.length-1||i0(t.text.charCodeAt(t.pos+1)))&&(!n||FOe(e,St.BulletList)||t.skipSpace(t.pos+2)<t.text.length)?1:-1}function MY(t,e,n){let r=t.pos,o=t.next;for(;o>=48&&o<=57;){r++;if(r==t.text.length)return-1;o=t.text.charCodeAt(r)}return r==t.pos||r>t.pos+9||o!=46&&o!=41||r<t.text.length-1&&!i0(t.text.charCodeAt(r+1))||n&&!FOe(e,St.OrderedList)&&(t.skipSpace(r+1)==t.text.length||r>t.pos+1||t.next!=49)?-1:r+1-t.pos}function qOe(t){if(t.next!=35)return-1;let e=t.pos+1;for(;e<t.text.length&&t.text.charCodeAt(e)==35;)e++;if(e<t.text.length&&t.text.charCodeAt(e)!=32)return-1;let n=e-t.pos;return n>6?-1:n}function VOe(t){if(t.next!=45&&t.next!=61||t.indent>=t.baseIndent+4)return-1;let e=t.pos+1;for(;e<t.text.length&&t.text.charCodeAt(e)==t.next;)e++;let n=e;for(;e<t.text.length&&i0(t.text.charCodeAt(e));)e++;return e==t.text.length?n:-1}const pq=/^[ \t]*$/,QOe=/-->/,UOe=/\?>/,mq=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,QOe],[/^\s*<\?/,UOe],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,pq],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,pq]];function WOe(t,e,n){if(t.next!=60)return-1;let r=t.text.slice(t.pos);for(let o=0,i=mq.length-(n?1:0);o<i;o++)if(mq[o][0].test(r))return o;return-1}function f0e(t,e){let n=t.countIndent(e,t.pos,t.indent),r=t.countIndent(t.skipSpace(e),e,n);return r>=n+5?n+1:r}function Xd(t,e,n){let r=t.length-1;r>=0&&t[r].to==e&&t[r].type==St.CodeText?t[r].to=n:t.push(Lr(St.CodeText,e,n))}const ok={LinkReference:void 0,IndentedCode(t,e){let n=e.baseIndent+4;if(e.indent<n)return!1;let r=e.findColumn(n),o=t.lineStart+r,i=t.lineStart+e.text.length,s=[],a=[];for(Xd(s,o,i);t.nextLine()&&e.depth>=t.stack.length;)if(e.pos==e.text.length){Xd(a,t.lineStart-1,t.lineStart);for(let l of e.markers)a.push(l)}else{if(e.indent<n)break;{if(a.length){for(let c of a)c.type==St.CodeText?Xd(s,c.from,c.to):s.push(c);a=[]}Xd(s,t.lineStart-1,t.lineStart);for(let c of e.markers)s.push(c);i=t.lineStart+e.text.length;let l=t.lineStart+e.findColumn(e.baseIndent+4);l<i&&Xd(s,l,i)}}return a.length&&(a=a.filter(l=>l.type!=St.CodeText),a.length&&(e.markers=a.concat(e.markers))),t.addNode(t.buffer.writeElements(s,-o).finish(St.CodeBlock,i-o),o),!0},FencedCode(t,e){let n=BOe(e);if(n<0)return!1;let r=t.lineStart+e.pos,o=e.next,i=n-e.pos,s=e.skipSpace(n),a=d0e(e.text,e.text.length,s),l=[Lr(St.CodeMark,r,r+i)];s<a&&l.push(Lr(St.CodeInfo,t.lineStart+s,t.lineStart+a));for(let c=!0,u=!0,d=!1;t.nextLine()&&e.depth>=t.stack.length;c=!1){let h=e.pos;if(e.indent-e.baseIndent<4)for(;h<e.text.length&&e.text.charCodeAt(h)==o;)h++;if(h-e.pos>=i&&e.skipSpace(h)==e.text.length){for(let p of e.markers)l.push(p);u&&d&&Xd(l,t.lineStart-1,t.lineStart),l.push(Lr(St.CodeMark,t.lineStart+e.pos,t.lineStart+h)),t.nextLine();break}else{d=!0,c||(Xd(l,t.lineStart-1,t.lineStart),u=!1);for(let _ of e.markers)l.push(_);let p=t.lineStart+e.basePos,g=t.lineStart+e.text.length;p<g&&(Xd(l,p,g),u=!1)}}return t.addNode(t.buffer.writeElements(l,-r).finish(St.FencedCode,t.prevLineEnd()-r),r),!0},Blockquote(t,e){let n=HOe(e);return n<0?!1:(t.startContext(St.Blockquote,e.pos),t.addNode(St.QuoteMark,t.lineStart+e.pos,t.lineStart+e.pos+1),e.moveBase(e.pos+n),null)},HorizontalRule(t,e){if(EY(e,t,!1)<0)return!1;let n=t.lineStart+e.pos;return t.nextLine(),t.addNode(St.HorizontalRule,n),!0},BulletList(t,e){let n=TY(e,t,!1);if(n<0)return!1;t.block.type!=St.BulletList&&t.startContext(St.BulletList,e.basePos,e.next);let r=f0e(e,e.pos+1);return t.startContext(St.ListItem,e.basePos,r-e.baseIndent),t.addNode(St.ListMark,t.lineStart+e.pos,t.lineStart+e.pos+n),e.moveBaseColumn(r),null},OrderedList(t,e){let n=MY(e,t,!1);if(n<0)return!1;t.block.type!=St.OrderedList&&t.startContext(St.OrderedList,e.basePos,e.text.charCodeAt(e.pos+n-1));let r=f0e(e,e.pos+n);return t.startContext(St.ListItem,e.basePos,r-e.baseIndent),t.addNode(St.ListMark,t.lineStart+e.pos,t.lineStart+e.pos+n),e.moveBaseColumn(r),null},ATXHeading(t,e){let n=qOe(e);if(n<0)return!1;let r=e.pos,o=t.lineStart+r,i=d0e(e.text,e.text.length,r),s=i;for(;s>r&&e.text.charCodeAt(s-1)==e.next;)s--;(s==i||s==r||!i0(e.text.charCodeAt(s-1)))&&(s=e.text.length);let a=t.buffer.write(St.HeaderMark,0,n).writeElements(t.parser.parseInline(e.text.slice(r+n+1,s),o+n+1),-o);s<e.text.length&&a.write(St.HeaderMark,s-r,i-r);let l=a.finish(St.ATXHeading1-1+n,e.text.length-r);return t.nextLine(),t.addNode(l,o),!0},HTMLBlock(t,e){let n=WOe(e,t,!1);if(n<0)return!1;let r=t.lineStart+e.pos,o=mq[n][1],i=[],s=o!=pq;for(;!o.test(e.text)&&t.nextLine();){if(e.depth<t.stack.length){s=!1;break}for(let c of e.markers)i.push(c)}s&&t.nextLine();let a=o==QOe?St.CommentBlock:o==UOe?St.ProcessingInstructionBlock:St.HTMLBlock,l=t.prevLineEnd();return t.addNode(t.buffer.writeElements(i,-r).finish(a,l-r),r),!0},SetextHeading:void 0};class fIt{constructor(e){this.stage=0,this.elts=[],this.pos=0,this.start=e.start,this.advance(e.content)}nextLine(e,n,r){if(this.stage==-1)return!1;let o=r.content+`
@@ -202,7 +202,7 @@ ${this.parser.parse(e)}</blockquote>
202
202
  ${e}</tr>
203
203
  `}tablecell(e){let n=this.parser.parseInline(e.tokens),r=e.header?"th":"td";return(e.align?`<${r} align="${e.align}">`:`<${r}>`)+n+`</${r}>
204
204
  `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${k1(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:n,tokens:r}){let o=this.parser.parseInline(r),i=Jue(e);if(i===null)return o;e=i;let s='<a href="'+e+'"';return n&&(s+=' title="'+k1(n)+'"'),s+=">"+o+"</a>",s}image({href:e,title:n,text:r,tokens:o}){o&&(r=this.parser.parseInline(o,this.parser.textRenderer));let i=Jue(e);if(i===null)return k1(r);e=i;let s=`<img src="${e}" alt="${k1(r)}"`;return n&&(s+=` title="${k1(n)}"`),s+=">",s}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:k1(e.text)}},BX=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},b0=class Xq{options;renderer;textRenderer;constructor(e){this.options=e||D4,this.options.renderer=this.options.renderer||new TA,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new BX}static parse(e,n){return new Xq(n).parse(e)}static parseInline(e,n){return new Xq(n).parseInline(e)}parse(e){let n="";for(let r=0;r<e.length;r++){let o=e[r];if(this.options.extensions?.renderers?.[o.type]){let s=o,a=this.options.extensions.renderers[s.type].call({parser:this},s);if(a!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(s.type)){n+=a||"";continue}}let i=o;switch(i.type){case"space":{n+=this.renderer.space(i);break}case"hr":{n+=this.renderer.hr(i);break}case"heading":{n+=this.renderer.heading(i);break}case"code":{n+=this.renderer.code(i);break}case"table":{n+=this.renderer.table(i);break}case"blockquote":{n+=this.renderer.blockquote(i);break}case"list":{n+=this.renderer.list(i);break}case"checkbox":{n+=this.renderer.checkbox(i);break}case"html":{n+=this.renderer.html(i);break}case"def":{n+=this.renderer.def(i);break}case"paragraph":{n+=this.renderer.paragraph(i);break}case"text":{n+=this.renderer.text(i);break}default:{let s='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return n}parseInline(e,n=this.renderer){let r="";for(let o=0;o<e.length;o++){let i=e[o];if(this.options.extensions?.renderers?.[i.type]){let a=this.options.extensions.renderers[i.type].call({parser:this},i);if(a!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){r+=a||"";continue}}let s=i;switch(s.type){case"escape":{r+=n.text(s);break}case"html":{r+=n.html(s);break}case"link":{r+=n.link(s);break}case"image":{r+=n.image(s);break}case"checkbox":{r+=n.checkbox(s);break}case"strong":{r+=n.strong(s);break}case"em":{r+=n.em(s);break}case"codespan":{r+=n.codespan(s);break}case"br":{r+=n.br(s);break}case"del":{r+=n.del(s);break}case"text":{r+=n.text(s);break}default:{let a='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return r}},zv=class{options;block;constructor(e){this.options=e||D4}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?Ec.lex:Ec.lexInline}provideParser(){return this.block?b0.parse:b0.parseInline}},len=class{defaults=jX();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=b0;Renderer=TA;TextRenderer=BX;Lexer=Ec;Tokenizer=EA;Hooks=zv;constructor(...e){this.use(...e)}walkTokens(e,n){let r=[];for(let o of e)switch(r=r.concat(n.call(this,o)),o.type){case"table":{let i=o;for(let s of i.header)r=r.concat(this.walkTokens(s.tokens,n));for(let s of i.rows)for(let a of s)r=r.concat(this.walkTokens(a.tokens,n));break}case"list":{let i=o;r=r.concat(this.walkTokens(i.items,n));break}default:{let i=o;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(s=>{let a=i[s].flat(1/0);r=r.concat(this.walkTokens(a,n))}):i.tokens&&(r=r.concat(this.walkTokens(i.tokens,n)))}}return r}use(...e){let n=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(r=>{let o={...r};if(o.async=this.defaults.async||o.async||!1,r.extensions&&(r.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=n.renderers[i.name];s?n.renderers[i.name]=function(...a){let l=i.renderer.apply(this,a);return l===!1&&(l=s.apply(this,a)),l}:n.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=n[i.level];s?s.unshift(i.tokenizer):n[i.level]=[i.tokenizer],i.start&&(i.level==="block"?n.startBlock?n.startBlock.push(i.start):n.startBlock=[i.start]:i.level==="inline"&&(n.startInline?n.startInline.push(i.start):n.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(n.childTokens[i.name]=i.childTokens)}),o.extensions=n),r.renderer){let i=this.defaults.renderer||new TA(this.defaults);for(let s in r.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let a=s,l=r.renderer[a],c=i[a];i[a]=(...u)=>{let d=l.apply(i,u);return d===!1&&(d=c.apply(i,u)),d||""}}o.renderer=i}if(r.tokenizer){let i=this.defaults.tokenizer||new EA(this.defaults);for(let s in r.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let a=s,l=r.tokenizer[a],c=i[a];i[a]=(...u)=>{let d=l.apply(i,u);return d===!1&&(d=c.apply(i,u)),d}}o.tokenizer=i}if(r.hooks){let i=this.defaults.hooks||new zv;for(let s in r.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let a=s,l=r.hooks[a],c=i[a];zv.passThroughHooks.has(s)?i[a]=u=>{if(this.defaults.async&&zv.passThroughHooksRespectAsync.has(s))return(async()=>{let h=await l.call(i,u);return c.call(i,h)})();let d=l.call(i,u);return c.call(i,d)}:i[a]=(...u)=>{if(this.defaults.async)return(async()=>{let h=await l.apply(i,u);return h===!1&&(h=await c.apply(i,u)),h})();let d=l.apply(i,u);return d===!1&&(d=c.apply(i,u)),d}}o.hooks=i}if(r.walkTokens){let i=this.defaults.walkTokens,s=r.walkTokens;o.walkTokens=function(a){let l=[];return l.push(s.call(this,a)),i&&(l=l.concat(i.call(this,a))),l}}this.defaults={...this.defaults,...o}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,n){return Ec.lex(e,n??this.defaults)}parser(e,n){return b0.parse(e,n??this.defaults)}parseMarkdown(e){return(n,r)=>{let o={...r},i={...this.defaults,...o},s=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&o.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let a=i.hooks?await i.hooks.preprocess(n):n,l=await(i.hooks?await i.hooks.provideLexer():e?Ec.lex:Ec.lexInline)(a,i),c=i.hooks?await i.hooks.processAllTokens(l):l;i.walkTokens&&await Promise.all(this.walkTokens(c,i.walkTokens));let u=await(i.hooks?await i.hooks.provideParser():e?b0.parse:b0.parseInline)(c,i);return i.hooks?await i.hooks.postprocess(u):u})().catch(s);try{i.hooks&&(n=i.hooks.preprocess(n));let a=(i.hooks?i.hooks.provideLexer():e?Ec.lex:Ec.lexInline)(n,i);i.hooks&&(a=i.hooks.processAllTokens(a)),i.walkTokens&&this.walkTokens(a,i.walkTokens);let l=(i.hooks?i.hooks.provideParser():e?b0.parse:b0.parseInline)(a,i);return i.hooks&&(l=i.hooks.postprocess(l)),l}catch(a){return s(a)}}}onError(e,n){return r=>{if(r.message+=`
205
- Please report this to https://github.com/markedjs/marked.`,e){let o="<p>An error occurred:</p><pre>"+k1(r.message+"",!0)+"</pre>";return n?Promise.resolve(o):o}if(n)return Promise.reject(r);throw r}}},W3=new len;function lo(t,e){return W3.parse(t,e)}lo.options=lo.setOptions=function(t){return W3.setOptions(t),lo.defaults=W3.defaults,mTe(lo.defaults),lo};lo.getDefaults=jX;lo.defaults=D4;lo.use=function(...t){return W3.use(...t),lo.defaults=W3.defaults,mTe(lo.defaults),lo};lo.walkTokens=function(t,e){return W3.walkTokens(t,e)};lo.parseInline=W3.parseInline;lo.Parser=b0;lo.parser=b0.parse;lo.Renderer=TA;lo.TextRenderer=BX;lo.Lexer=Ec;lo.lexer=Ec.lex;lo.Tokenizer=EA;lo.Hooks=zv;lo.parse=lo;lo.options;lo.setOptions;lo.use;lo.walkTokens;lo.parseInline;b0.parse;Ec.lex;var cen=300,uen="300px",den=500;function fen(t={}){let{immediate:e=!1,debounceDelay:n=cen,rootMargin:r=uen,idleTimeout:o=den}=t,[i,s]=v.useState(!1),a=v.useRef(null),l=v.useRef(null),c=v.useRef(null),u=v.useMemo(()=>p=>{let g=Date.now();return window.setTimeout(()=>{p({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-g))})},1)},[]),d=v.useMemo(()=>typeof window<"u"&&window.requestIdleCallback?(p,g)=>window.requestIdleCallback(p,g):u,[u]),h=v.useMemo(()=>typeof window<"u"&&window.cancelIdleCallback?p=>window.cancelIdleCallback(p):p=>{clearTimeout(p)},[]);return v.useEffect(()=>{if(e){s(!0);return}let p=a.current;if(!p)return;l.current&&(clearTimeout(l.current),l.current=null),c.current&&(h(c.current),c.current=null);let g=()=>{l.current&&(clearTimeout(l.current),l.current=null),c.current&&(h(c.current),c.current=null)},_=O=>{c.current=d(C=>{C.timeRemaining()>0||C.didTimeout?(s(!0),O.disconnect()):c.current=d(()=>{s(!0),O.disconnect()},{timeout:o/2})},{timeout:o})},x=O=>{g(),l.current=window.setTimeout(()=>{var C,A;let E=O.takeRecords();(E.length===0||(A=(C=E.at(-1))==null?void 0:C.isIntersecting)!=null&&A)&&_(O)},n)},y=(O,C)=>{O.isIntersecting?x(C):g()},k=new IntersectionObserver(O=>{for(let C of O)y(C,k)},{rootMargin:r,threshold:0});return k.observe(p),()=>{l.current&&clearTimeout(l.current),c.current&&h(c.current),k.disconnect()}},[e,n,r,o,h,d]),{shouldRender:i,containerRef:a}}var ATe=/\s/,hen=/^\s+$/,pen=new Set(["code","pre","svg","math","annotation"]),men=t=>typeof t=="object"&&t!==null&&"type"in t&&t.type==="element",gen=t=>t.some(e=>men(e)&&pen.has(e.tagName)),ven=t=>{let e=[],n="",r=!1;for(let o of t){let i=ATe.test(o);i!==r&&n&&(e.push(n),n=""),n+=o,r=i}return n&&e.push(n),e},ben=t=>{let e=[],n="";for(let r of t)ATe.test(r)?n+=r:(n&&(e.push(n),n=""),e.push(r));return n&&e.push(n),e},_en=(t,e,n,r)=>({type:"element",tagName:"span",properties:{"data-sd-animate":!0,style:`--sd-animation:sd-${e};--sd-duration:${n}ms;--sd-easing:${r}`},children:[{type:"text",value:t}]}),xen=(t,e,n)=>{let r=e.at(-1);if(!(r&&"children"in r))return;if(gen(e))return e3;let o=r,i=o.children.indexOf(t);if(i===-1)return;let s=t.value;if(!s.trim())return;let a=(n.sep==="char"?ben(s):ven(s)).map(l=>hen.test(l)?{type:"text",value:l}:_en(l,n.animation,n.duration,n.easing));return o.children.splice(i,1,...a),i+a.length};function Kq(t){var e,n,r,o;let i={animation:(e=t?.animation)!=null?e:"fadeIn",duration:(n=t?.duration)!=null?n:150,easing:(r=t?.easing)!=null?r:"ease",sep:(o=t?.sep)!=null?o:"word"};return{name:"animate",type:"animate",rehypePlugin:()=>s=>{PP(s,"text",(a,l)=>xen(a,l,i))}}}Kq();var ETe=v.createContext(!1),yen=()=>v.useContext(ETe),In=(...t)=>Txe(fo(t)),a6=(t,e,n)=>{let r=typeof e=="string"?new Blob([e],{type:n}):e,o=URL.createObjectURL(r),i=document.createElement("a");i.href=o,i.download=t,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o)},wen=In("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-6","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),ken=t=>{let e={};for(let n of t.split(";")){let r=n.indexOf(":");if(r>0){let o=n.slice(0,r).trim(),i=n.slice(r+1).trim();o&&i&&(e[o]=i)}}return e},Oen=v.memo(({children:t,result:e,language:n,className:r,...o})=>{let i=v.useMemo(()=>{let s={};return e.bg&&(s["--sdm-bg"]=e.bg),e.fg&&(s["--sdm-fg"]=e.fg),e.rootStyle&&Object.assign(s,ken(e.rootStyle)),s},[e.bg,e.fg,e.rootStyle]);return f.jsx("div",{className:In(r,"overflow-hidden rounded-md border border-border bg-background p-4 text-sm"),"data-language":n,"data-streamdown":"code-block-body",...o,children:f.jsx("pre",{className:In(r,"bg-[var(--sdm-bg,inherit]","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit)]"),style:i,children:f.jsx("code",{className:"[counter-increment:line_0] [counter-reset:line]",children:e.tokens.map((s,a)=>f.jsx("span",{className:wen,children:s.map((l,c)=>{let u={},d=!!l.bgColor;if(l.color&&(u["--sdm-c"]=l.color),l.bgColor&&(u["--sdm-tbg"]=l.bgColor),l.htmlStyle)for(let[h,p]of Object.entries(l.htmlStyle))h==="color"?u["--sdm-c"]=p:h==="background-color"?(u["--sdm-tbg"]=p,d=!0):u[h]=p;return f.jsx("span",{className:In("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",d&&"bg-[var(--sdm-tbg)]",d&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:u,...l.htmlAttrs,children:l.content},c)})},a))})})})},(t,e)=>t.result===e.result&&t.language===e.language&&t.className===e.className),Sen=({className:t,language:e,style:n,isIncomplete:r,...o})=>f.jsx("div",{className:In("my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-incomplete":r||void 0,"data-language":e,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...n},...o}),TTe=v.createContext({code:""}),MTe=()=>v.useContext(TTe),Cen=({language:t})=>f.jsx("div",{className:"flex h-8 items-center text-muted-foreground text-xs","data-language":t,"data-streamdown":"code-block-header",children:f.jsx("span",{className:"ml-1 font-mono lowercase",children:t})}),Aen=/\n+$/,Een=v.lazy(()=>re(()=>import("./highlighted-body-B3W2YXNL-BS1x7lkZ.js"),[]).then(t=>({default:t.HighlightedCodeBlockBody}))),Ten=({code:t,language:e,className:n,children:r,isIncomplete:o=!1,...i})=>{let s=v.useMemo(()=>t.replace(Aen,""),[t]),a=v.useMemo(()=>({bg:"transparent",fg:"inherit",tokens:s.split(`
205
+ Please report this to https://github.com/markedjs/marked.`,e){let o="<p>An error occurred:</p><pre>"+k1(r.message+"",!0)+"</pre>";return n?Promise.resolve(o):o}if(n)return Promise.reject(r);throw r}}},W3=new len;function lo(t,e){return W3.parse(t,e)}lo.options=lo.setOptions=function(t){return W3.setOptions(t),lo.defaults=W3.defaults,mTe(lo.defaults),lo};lo.getDefaults=jX;lo.defaults=D4;lo.use=function(...t){return W3.use(...t),lo.defaults=W3.defaults,mTe(lo.defaults),lo};lo.walkTokens=function(t,e){return W3.walkTokens(t,e)};lo.parseInline=W3.parseInline;lo.Parser=b0;lo.parser=b0.parse;lo.Renderer=TA;lo.TextRenderer=BX;lo.Lexer=Ec;lo.lexer=Ec.lex;lo.Tokenizer=EA;lo.Hooks=zv;lo.parse=lo;lo.options;lo.setOptions;lo.use;lo.walkTokens;lo.parseInline;b0.parse;Ec.lex;var cen=300,uen="300px",den=500;function fen(t={}){let{immediate:e=!1,debounceDelay:n=cen,rootMargin:r=uen,idleTimeout:o=den}=t,[i,s]=v.useState(!1),a=v.useRef(null),l=v.useRef(null),c=v.useRef(null),u=v.useMemo(()=>p=>{let g=Date.now();return window.setTimeout(()=>{p({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-g))})},1)},[]),d=v.useMemo(()=>typeof window<"u"&&window.requestIdleCallback?(p,g)=>window.requestIdleCallback(p,g):u,[u]),h=v.useMemo(()=>typeof window<"u"&&window.cancelIdleCallback?p=>window.cancelIdleCallback(p):p=>{clearTimeout(p)},[]);return v.useEffect(()=>{if(e){s(!0);return}let p=a.current;if(!p)return;l.current&&(clearTimeout(l.current),l.current=null),c.current&&(h(c.current),c.current=null);let g=()=>{l.current&&(clearTimeout(l.current),l.current=null),c.current&&(h(c.current),c.current=null)},_=O=>{c.current=d(C=>{C.timeRemaining()>0||C.didTimeout?(s(!0),O.disconnect()):c.current=d(()=>{s(!0),O.disconnect()},{timeout:o/2})},{timeout:o})},x=O=>{g(),l.current=window.setTimeout(()=>{var C,A;let E=O.takeRecords();(E.length===0||(A=(C=E.at(-1))==null?void 0:C.isIntersecting)!=null&&A)&&_(O)},n)},y=(O,C)=>{O.isIntersecting?x(C):g()},k=new IntersectionObserver(O=>{for(let C of O)y(C,k)},{rootMargin:r,threshold:0});return k.observe(p),()=>{l.current&&clearTimeout(l.current),c.current&&h(c.current),k.disconnect()}},[e,n,r,o,h,d]),{shouldRender:i,containerRef:a}}var ATe=/\s/,hen=/^\s+$/,pen=new Set(["code","pre","svg","math","annotation"]),men=t=>typeof t=="object"&&t!==null&&"type"in t&&t.type==="element",gen=t=>t.some(e=>men(e)&&pen.has(e.tagName)),ven=t=>{let e=[],n="",r=!1;for(let o of t){let i=ATe.test(o);i!==r&&n&&(e.push(n),n=""),n+=o,r=i}return n&&e.push(n),e},ben=t=>{let e=[],n="";for(let r of t)ATe.test(r)?n+=r:(n&&(e.push(n),n=""),e.push(r));return n&&e.push(n),e},_en=(t,e,n,r)=>({type:"element",tagName:"span",properties:{"data-sd-animate":!0,style:`--sd-animation:sd-${e};--sd-duration:${n}ms;--sd-easing:${r}`},children:[{type:"text",value:t}]}),xen=(t,e,n)=>{let r=e.at(-1);if(!(r&&"children"in r))return;if(gen(e))return e3;let o=r,i=o.children.indexOf(t);if(i===-1)return;let s=t.value;if(!s.trim())return;let a=(n.sep==="char"?ben(s):ven(s)).map(l=>hen.test(l)?{type:"text",value:l}:_en(l,n.animation,n.duration,n.easing));return o.children.splice(i,1,...a),i+a.length};function Kq(t){var e,n,r,o;let i={animation:(e=t?.animation)!=null?e:"fadeIn",duration:(n=t?.duration)!=null?n:150,easing:(r=t?.easing)!=null?r:"ease",sep:(o=t?.sep)!=null?o:"word"};return{name:"animate",type:"animate",rehypePlugin:()=>s=>{PP(s,"text",(a,l)=>xen(a,l,i))}}}Kq();var ETe=v.createContext(!1),yen=()=>v.useContext(ETe),In=(...t)=>Txe(fo(t)),a6=(t,e,n)=>{let r=typeof e=="string"?new Blob([e],{type:n}):e,o=URL.createObjectURL(r),i=document.createElement("a");i.href=o,i.download=t,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o)},wen=In("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-6","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),ken=t=>{let e={};for(let n of t.split(";")){let r=n.indexOf(":");if(r>0){let o=n.slice(0,r).trim(),i=n.slice(r+1).trim();o&&i&&(e[o]=i)}}return e},Oen=v.memo(({children:t,result:e,language:n,className:r,...o})=>{let i=v.useMemo(()=>{let s={};return e.bg&&(s["--sdm-bg"]=e.bg),e.fg&&(s["--sdm-fg"]=e.fg),e.rootStyle&&Object.assign(s,ken(e.rootStyle)),s},[e.bg,e.fg,e.rootStyle]);return f.jsx("div",{className:In(r,"overflow-hidden rounded-md border border-border bg-background p-4 text-sm"),"data-language":n,"data-streamdown":"code-block-body",...o,children:f.jsx("pre",{className:In(r,"bg-[var(--sdm-bg,inherit]","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit)]"),style:i,children:f.jsx("code",{className:"[counter-increment:line_0] [counter-reset:line]",children:e.tokens.map((s,a)=>f.jsx("span",{className:wen,children:s.map((l,c)=>{let u={},d=!!l.bgColor;if(l.color&&(u["--sdm-c"]=l.color),l.bgColor&&(u["--sdm-tbg"]=l.bgColor),l.htmlStyle)for(let[h,p]of Object.entries(l.htmlStyle))h==="color"?u["--sdm-c"]=p:h==="background-color"?(u["--sdm-tbg"]=p,d=!0):u[h]=p;return f.jsx("span",{className:In("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",d&&"bg-[var(--sdm-tbg)]",d&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:u,...l.htmlAttrs,children:l.content},c)})},a))})})})},(t,e)=>t.result===e.result&&t.language===e.language&&t.className===e.className),Sen=({className:t,language:e,style:n,isIncomplete:r,...o})=>f.jsx("div",{className:In("my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-incomplete":r||void 0,"data-language":e,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...n},...o}),TTe=v.createContext({code:""}),MTe=()=>v.useContext(TTe),Cen=({language:t})=>f.jsx("div",{className:"flex h-8 items-center text-muted-foreground text-xs","data-language":t,"data-streamdown":"code-block-header",children:f.jsx("span",{className:"ml-1 font-mono lowercase",children:t})}),Aen=/\n+$/,Een=v.lazy(()=>re(()=>import("./highlighted-body-B3W2YXNL-Bt5DPhhI.js"),[]).then(t=>({default:t.HighlightedCodeBlockBody}))),Ten=({code:t,language:e,className:n,children:r,isIncomplete:o=!1,...i})=>{let s=v.useMemo(()=>t.replace(Aen,""),[t]),a=v.useMemo(()=>({bg:"transparent",fg:"inherit",tokens:s.split(`
206
206
  `).map(l=>[{content:l,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[s]);return f.jsx(TTe.Provider,{value:{code:t},children:f.jsxs(Sen,{isIncomplete:o,language:e,children:[f.jsx(Cen,{language:e}),r?f.jsx("div",{className:"pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end",children:f.jsx("div",{className:"pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur","data-streamdown":"code-block-actions",children:r})}):null,f.jsx(v.Suspense,{fallback:f.jsx(Oen,{className:n,language:e,result:a,...i}),children:f.jsx(Een,{className:n,code:s,language:e,raw:a,...i})})]})})},HX=t=>f.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...t,children:f.jsx("path",{clipRule:"evenodd",d:"M15.5607 3.99999L15.0303 4.53032L6.23744 13.3232C5.55403 14.0066 4.44599 14.0066 3.76257 13.3232L4.2929 12.7929L3.76257 13.3232L0.969676 10.5303L0.439346 9.99999L1.50001 8.93933L2.03034 9.46966L4.82323 12.2626C4.92086 12.3602 5.07915 12.3602 5.17678 12.2626L13.9697 3.46966L14.5 2.93933L15.5607 3.99999Z",fill:"currentColor",fillRule:"evenodd"})}),FX=t=>f.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...t,children:f.jsx("path",{clipRule:"evenodd",d:"M2.75 0.5C1.7835 0.5 1 1.2835 1 2.25V9.75C1 10.7165 1.7835 11.5 2.75 11.5H3.75H4.5V10H3.75H2.75C2.61193 10 2.5 9.88807 2.5 9.75V2.25C2.5 2.11193 2.61193 2 2.75 2H8.25C8.38807 2 8.5 2.11193 8.5 2.25V3H10V2.25C10 1.2835 9.2165 0.5 8.25 0.5H2.75ZM7.75 4.5C6.7835 4.5 6 5.2835 6 6.25V13.75C6 14.7165 6.7835 15.5 7.75 15.5H13.25C14.2165 15.5 15 14.7165 15 13.75V6.25C15 5.2835 14.2165 4.5 13.25 4.5H7.75ZM7.5 6.25C7.5 6.11193 7.61193 6 7.75 6H13.25C13.3881 6 13.5 6.11193 13.5 6.25V13.75C13.5 13.8881 13.3881 14 13.25 14H7.75C7.61193 14 7.5 13.8881 7.5 13.75V6.25Z",fill:"currentColor",fillRule:"evenodd"})}),qP=t=>f.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...t,children:f.jsx("path",{clipRule:"evenodd",d:"M8.75 1V1.75V8.68934L10.7197 6.71967L11.25 6.18934L12.3107 7.25L11.7803 7.78033L8.70711 10.8536C8.31658 11.2441 7.68342 11.2441 7.29289 10.8536L4.21967 7.78033L3.68934 7.25L4.75 6.18934L5.28033 6.71967L7.25 8.68934V1.75V1H8.75ZM13.5 9.25V13.5H2.5V9.25V8.5H1V9.25V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.25V8.5H13.5V9.25Z",fill:"currentColor",fillRule:"evenodd"})}),Men=t=>f.jsxs("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...t,children:[f.jsx("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),f.jsx("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),f.jsx("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),f.jsx("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),f.jsx("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),f.jsx("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),f.jsx("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),f.jsx("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),f.jsx("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),f.jsx("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),Pen=t=>f.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...t,children:f.jsx("path",{clipRule:"evenodd",d:"M1 5.25V6H2.5V5.25V2.5H5.25H6V1H5.25H2C1.44772 1 1 1.44772 1 2V5.25ZM5.25 14.9994H6V13.4994H5.25H2.5V10.7494V9.99939H1V10.7494V13.9994C1 14.5517 1.44772 14.9994 2 14.9994H5.25ZM15 10V10.75V14C15 14.5523 14.5523 15 14 15H10.75H10V13.5H10.75H13.5V10.75V10H15ZM10.75 1H10V2.5H10.75H13.5V5.25V6H15V5.25V2C15 1.44772 14.5523 1 14 1H10.75Z",fill:"currentColor",fillRule:"evenodd"})}),jen=t=>f.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...t,children:f.jsx("path",{clipRule:"evenodd",d:"M13.5 8C13.5 4.96643 11.0257 2.5 7.96452 2.5C5.42843 2.5 3.29365 4.19393 2.63724 6.5H5.25H6V8H5.25H0.75C0.335787 8 0 7.66421 0 7.25V2.75V2H1.5V2.75V5.23347C2.57851 2.74164 5.06835 1 7.96452 1C11.8461 1 15 4.13001 15 8C15 11.87 11.8461 15 7.96452 15C5.62368 15 3.54872 13.8617 2.27046 12.1122L1.828 11.5066L3.03915 10.6217L3.48161 11.2273C4.48831 12.6051 6.12055 13.5 7.96452 13.5C11.0257 13.5 13.5 11.0336 13.5 8Z",fill:"currentColor",fillRule:"evenodd"})}),PTe=t=>f.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...t,children:f.jsx("path",{clipRule:"evenodd",d:"M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z",fill:"currentColor",fillRule:"evenodd"})}),n2e=t=>f.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...t,children:f.jsx("path",{clipRule:"evenodd",d:"M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z",fill:"currentColor",fillRule:"evenodd"})}),Nen=t=>f.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...t,children:f.jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H5.875V4.75V4.125H7.125V4.75V5.875H8.25H8.875V7.125H8.25H7.125V8.25V8.875H5.875V8.25V7.125H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})}),Ren=t=>f.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...t,children:f.jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})}),r2e=({onCopy:t,onError:e,timeout:n=2e3,children:r,className:o,code:i,...s})=>{let[a,l]=v.useState(!1),c=v.useRef(0),{code:u}=MTe(),{isAnimating:d}=v.useContext(Uc),h=i??u,p=async()=>{var _;if(typeof window>"u"||!((_=navigator?.clipboard)!=null&&_.writeText)){e?.(new Error("Clipboard API not available"));return}try{a||(await navigator.clipboard.writeText(h),l(!0),t?.(),c.current=window.setTimeout(()=>l(!1),n))}catch(x){e?.(x)}};v.useEffect(()=>()=>{window.clearTimeout(c.current)},[]);let g=a?HX:FX;return f.jsx("button",{className:In("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",o),"data-streamdown":"code-block-copy-button",disabled:d,onClick:p,title:"Copy Code",type:"button",...s,children:r??f.jsx(g,{size:14})})},o2e={"1c":"1c","1c-query":"1cq",abap:"abap","actionscript-3":"as",ada:"ada",adoc:"adoc","angular-html":"html","angular-ts":"ts",apache:"conf",apex:"cls",apl:"apl",applescript:"applescript",ara:"ara",asciidoc:"adoc",asm:"asm",astro:"astro",awk:"awk",ballerina:"bal",bash:"sh",bat:"bat",batch:"bat",be:"be",beancount:"beancount",berry:"berry",bibtex:"bib",bicep:"bicep",blade:"blade.php",bsl:"bsl",c:"c","c#":"cs","c++":"cpp",cadence:"cdc",cairo:"cairo",cdc:"cdc",clarity:"clar",clj:"clj",clojure:"clj","closure-templates":"soy",cmake:"cmake",cmd:"cmd",cobol:"cob",codeowners:"CODEOWNERS",codeql:"ql",coffee:"coffee",coffeescript:"coffee","common-lisp":"lisp",console:"sh",coq:"v",cpp:"cpp",cql:"cql",crystal:"cr",cs:"cs",csharp:"cs",css:"css",csv:"csv",cue:"cue",cypher:"cql",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",docker:"dockerfile",dockerfile:"dockerfile",dotenv:"env","dream-maker":"dm",edge:"edge",elisp:"el",elixir:"ex",elm:"elm","emacs-lisp":"el",erb:"erb",erl:"erl",erlang:"erl",f:"f","f#":"fs",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"f90",f95:"f95",fennel:"fnl",fish:"fish",fluent:"ftl",for:"for","fortran-fixed-form":"f","fortran-free-form":"f90",fs:"fs",fsharp:"fs",fsl:"fsl",ftl:"ftl",gdresource:"tres",gdscript:"gd",gdshader:"gdshader",genie:"gs",gherkin:"feature","git-commit":"gitcommit","git-rebase":"gitrebase",gjs:"js",gleam:"gleam","glimmer-js":"js","glimmer-ts":"ts",glsl:"glsl",gnuplot:"plt",go:"go",gql:"gql",graphql:"graphql",groovy:"groovy",gts:"gts",hack:"hack",haml:"haml",handlebars:"hbs",haskell:"hs",haxe:"hx",hbs:"hbs",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",hs:"hs",html:"html","html-derivative":"html",http:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",jade:"jade",java:"java",javascript:"js",jinja:"jinja",jison:"jison",jl:"jl",js:"js",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",julia:"jl",kotlin:"kt",kql:"kql",kt:"kt",kts:"kts",kusto:"kql",latex:"tex",lean:"lean",lean4:"lean",less:"less",liquid:"liquid",lisp:"lisp",lit:"lit",llvm:"ll",log:"log",logo:"logo",lua:"lua",luau:"luau",make:"mak",makefile:"mak",markdown:"md",marko:"marko",matlab:"m",md:"md",mdc:"mdc",mdx:"mdx",mediawiki:"wiki",mermaid:"mmd",mips:"s",mipsasm:"s",mmd:"mmd",mojo:"mojo",move:"move",nar:"nar",narrat:"narrat",nextflow:"nf",nf:"nf",nginx:"conf",nim:"nim",nix:"nix",nu:"nu",nushell:"nu",objc:"m","objective-c":"m","objective-cpp":"mm",ocaml:"ml",pascal:"pas",perl:"pl",perl6:"p6",php:"php",plsql:"pls",po:"po",polar:"polar",postcss:"pcss",pot:"pot",potx:"potx",powerquery:"pq",powershell:"ps1",prisma:"prisma",prolog:"pl",properties:"properties",proto:"proto",protobuf:"proto",ps:"ps",ps1:"ps1",pug:"pug",puppet:"pp",purescript:"purs",py:"py",python:"py",ql:"ql",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",racket:"rkt",raku:"raku",razor:"cshtml",rb:"rb",reg:"reg",regex:"regex",regexp:"regexp",rel:"rel",riscv:"s",rs:"rs",rst:"rst",ruby:"rb",rust:"rs",sas:"sas",sass:"sass",scala:"scala",scheme:"scm",scss:"scss",sdbl:"sdbl",sh:"sh",shader:"shader",shaderlab:"shader",shell:"sh",shellscript:"sh",shellsession:"sh",smalltalk:"st",solidity:"sol",soy:"soy",sparql:"rq",spl:"spl",splunk:"spl",sql:"sql","ssh-config":"config",stata:"do",styl:"styl",stylus:"styl",svelte:"svelte",swift:"swift","system-verilog":"sv",systemd:"service",talon:"talon",talonscript:"talon",tasl:"tasl",tcl:"tcl",templ:"templ",terraform:"tf",tex:"tex",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"ts","ts-tags":"ts",tsp:"tsp",tsv:"tsv",tsx:"tsx",turtle:"ttl",twig:"twig",typ:"typ",typescript:"ts",typespec:"tsp",typst:"typ",v:"v",vala:"vala",vb:"vb",verilog:"v",vhdl:"vhdl",vim:"vim",viml:"vim",vimscript:"vim",vue:"vue","vue-html":"html","vue-vine":"vine",vy:"vy",vyper:"vy",wasm:"wasm",wenyan:"wy",wgsl:"wgsl",wiki:"wiki",wikitext:"wiki",wit:"wit",wl:"wl",wolfram:"wl",xml:"xml",xsl:"xsl",yaml:"yaml",yml:"yml",zenscript:"zs",zig:"zig",zsh:"zsh",文言:"wy"},Len=({onDownload:t,onError:e,language:n,children:r,className:o,code:i,...s})=>{let{code:a}=MTe(),{isAnimating:l}=v.useContext(Uc),c=i??a,u=`file.${n&&n in o2e?o2e[n]:"txt"}`,d="text/plain",h=()=>{try{a6(u,c,d),t?.()}catch(p){e?.(p)}};return f.jsx("button",{className:In("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",o),"data-streamdown":"code-block-download-button",disabled:l,onClick:h,title:"Download file",type:"button",...s,children:r??f.jsx(qP,{size:14})})},Ien=()=>f.jsxs("div",{className:"w-full divide-y divide-border overflow-hidden rounded-xl border border-border",children:[f.jsx("div",{className:"h-[46px] w-full bg-muted/80"}),f.jsx("div",{className:"flex w-full items-center justify-center p-4",children:f.jsx(Men,{className:"size-4 animate-spin"})})]}),Den=/\.[^/.]+$/,zen=({node:t,className:e,src:n,alt:r,onLoad:o,onError:i,...s})=>{let a=v.useRef(null),[l,c]=v.useState(!1),[u,d]=v.useState(!1),h=s.width!=null||s.height!=null,p=(l||h)&&!u,g=u&&!h;v.useEffect(()=>{let k=a.current;if(k!=null&&k.complete){let O=k.naturalWidth>0;c(O),d(!O)}},[]);let _=v.useCallback(k=>{c(!0),d(!1),o?.(k)},[o]),x=v.useCallback(k=>{c(!1),d(!0),i?.(k)},[i]),y=async()=>{if(n)try{let k=await(await fetch(n)).blob(),O=new URL(n,window.location.origin).pathname.split("/").pop()||"",C=O.split(".").pop(),A=O.includes(".")&&C!==void 0&&C.length<=4,E="";if(A)E=O;else{let M=k.type,P="png";M.includes("jpeg")||M.includes("jpg")?P="jpg":M.includes("png")?P="png":M.includes("svg")?P="svg":M.includes("gif")?P="gif":M.includes("webp")&&(P="webp"),E=`${(r||O||"image").replace(Den,"")}.${P}`}a6(E,k,k.type)}catch{window.open(n,"_blank")}};return n?f.jsxs("div",{className:"group relative my-4 inline-block","data-streamdown":"image-wrapper",children:[f.jsx("img",{alt:r,className:In("max-w-full rounded-lg",g&&"hidden",e),"data-streamdown":"image",onError:x,onLoad:_,ref:a,src:n,...s}),g&&f.jsx("span",{className:"text-muted-foreground text-xs italic","data-streamdown":"image-fallback",children:"Image not available"}),f.jsx("div",{className:"pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block"}),p&&f.jsx("button",{className:In("absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background","opacity-0 group-hover:opacity-100"),onClick:y,title:"Download image",type:"button",children:f.jsx(qP,{size:14})})]}):null},j9=0,$en=()=>{j9+=1,j9===1&&(document.body.style.overflow="hidden")},Ben=()=>{j9=Math.max(0,j9-1),j9===0&&(document.body.style.overflow="")},Hen=({url:t,isOpen:e,onClose:n,onConfirm:r})=>{let[o,i]=v.useState(!1),s=v.useCallback(async()=>{try{await navigator.clipboard.writeText(t),i(!0),setTimeout(()=>i(!1),2e3)}catch{}},[t]),a=v.useCallback(()=>{r(),n()},[r,n]);return v.useEffect(()=>{if(e){$en();let l=c=>{c.key==="Escape"&&n()};return document.addEventListener("keydown",l),()=>{document.removeEventListener("keydown",l),Ben()}}},[e,n]),e?f.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm","data-streamdown":"link-safety-modal",onClick:n,onKeyDown:l=>{l.key==="Escape"&&n()},role:"button",tabIndex:0,children:f.jsxs("div",{className:"relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg",onClick:l=>l.stopPropagation(),onKeyDown:l=>l.stopPropagation(),role:"presentation",children:[f.jsx("button",{className:"absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground",onClick:n,title:"Close",type:"button",children:f.jsx(PTe,{size:16})}),f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsxs("div",{className:"flex items-center gap-2 font-semibold text-lg",children:[f.jsx(n2e,{size:20}),f.jsx("span",{children:"Open external link?"})]}),f.jsx("p",{className:"text-muted-foreground text-sm",children:"You're about to visit an external website."})]}),f.jsx("div",{className:In("break-all rounded-md bg-muted p-3 font-mono text-sm",t.length>100&&"max-h-32 overflow-y-auto"),children:t}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx("button",{className:"flex flex-1 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 font-medium text-sm transition-all hover:bg-muted",onClick:s,type:"button",children:o?f.jsxs(f.Fragment,{children:[f.jsx(HX,{size:14}),f.jsx("span",{children:"Copied"})]}):f.jsxs(f.Fragment,{children:[f.jsx(FX,{size:14}),f.jsx("span",{children:"Copy link"})]})}),f.jsxs("button",{className:"flex flex-1 items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 font-medium text-primary-foreground text-sm transition-all hover:bg-primary/90",onClick:a,type:"button",children:[f.jsx(n2e,{size:14}),f.jsx("span",{children:"Open link"})]})]})]})}):null},Jq=v.createContext(null),jTe=()=>v.useContext(Jq),aer=()=>{var t;let e=jTe();return(t=e?.code)!=null?t:null},qX=()=>{var t;let e=jTe();return(t=e?.mermaid)!=null?t:null},Fen=(t,e)=>{var n;let r=(n=void 0)!=null?n:5;return new Promise((o,i)=>{let s="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(t))),a=new Image;a.crossOrigin="anonymous",a.onload=()=>{let l=document.createElement("canvas"),c=a.width*r,u=a.height*r;l.width=c,l.height=u;let d=l.getContext("2d");if(!d){i(new Error("Failed to create 2D canvas context for PNG export"));return}d.drawImage(a,0,0,c,u),l.toBlob(h=>{if(!h){i(new Error("Failed to create PNG blob"));return}o(h)},"image/png")},a.onerror=()=>i(new Error("Failed to load SVG image")),a.src=s})},qen=({chart:t,children:e,className:n,onDownload:r,config:o,onError:i})=>{let[s,a]=v.useState(!1),l=v.useRef(null),{isAnimating:c}=v.useContext(Uc),u=qX(),d=async h=>{try{if(h==="mmd"){a6("diagram.mmd",t,"text/plain"),a(!1),r?.(h);return}if(!u){i?.(new Error("Mermaid plugin not available"));return}let p=u.getMermaid(o),g=t.split("").reduce((y,k)=>(y<<5)-y+k.charCodeAt(0)|0,0),_=`mermaid-${Math.abs(g)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:x}=await p.render(_,t);if(!x){i?.(new Error("SVG not found. Please wait for the diagram to render."));return}if(h==="svg"){a6("diagram.svg",x,"image/svg+xml"),a(!1),r?.(h);return}if(h==="png"){let y=await Fen(x);a6("diagram.png",y,"image/png"),r?.(h),a(!1);return}}catch(p){i?.(p)}};return v.useEffect(()=>{let h=p=>{let g=p.composedPath();l.current&&!g.includes(l.current)&&a(!1)};return document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h)}},[]),f.jsxs("div",{className:"relative",ref:l,children:[f.jsx("button",{className:In("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",n),disabled:c,onClick:()=>a(!s),title:"Download diagram",type:"button",children:e??f.jsx(qP,{size:14})}),s?f.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[f.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>d("svg"),title:"Download diagram as SVG",type:"button",children:"SVG"}),f.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>d("png"),title:"Download diagram as PNG",type:"button",children:"PNG"}),f.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>d("mmd"),title:"Download diagram as MMD",type:"button",children:"MMD"})]}):null]})},N9=0,Ven=()=>{N9+=1,N9===1&&(document.body.style.overflow="hidden")},Qen=()=>{N9=Math.max(0,N9-1),N9===0&&(document.body.style.overflow="")},Uen=({chart:t,config:e,onFullscreen:n,onExit:r,className:o,...i})=>{let[s,a]=v.useState(!1),{isAnimating:l,controls:c}=v.useContext(Uc),u=(()=>{if(typeof c=="boolean")return c;let h=c.mermaid;return h===!1?!1:h===!0||h===void 0?!0:h.panZoom!==!1})(),d=()=>{a(!s)};return v.useEffect(()=>{if(s){Ven();let h=p=>{p.key==="Escape"&&a(!1)};return document.addEventListener("keydown",h),()=>{document.removeEventListener("keydown",h),Qen()}}},[s]),v.useEffect(()=>{s?n?.():r&&r()},[s,n,r]),f.jsxs(f.Fragment,{children:[f.jsx("button",{className:In("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",o),disabled:l,onClick:d,title:"View fullscreen",type:"button",...i,children:f.jsx(Pen,{size:14})}),s?Bs.createPortal(f.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm",onClick:d,onKeyDown:h=>{h.key==="Escape"&&d()},role:"button",tabIndex:0,children:[f.jsx("button",{className:"absolute top-4 right-4 z-10 rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground",onClick:d,title:"Exit fullscreen",type:"button",children:f.jsx(PTe,{size:20})}),f.jsx("div",{className:"flex size-full items-center justify-center p-4",onClick:h=>h.stopPropagation(),onKeyDown:h=>h.stopPropagation(),role:"presentation",children:f.jsx(cMe,{chart:t,className:"size-full [&_svg]:h-auto [&_svg]:w-auto",config:e,fullscreen:!0,showControls:u})})]}),document.body):null]})},NTe=t=>{var e,n;let r=[],o=[],i=t.querySelectorAll("thead th");for(let a of i)r.push(((e=a.textContent)==null?void 0:e.trim())||"");let s=t.querySelectorAll("tbody tr");for(let a of s){let l=[],c=a.querySelectorAll("td");for(let u of c)l.push(((n=u.textContent)==null?void 0:n.trim())||"");o.push(l)}return{headers:r,rows:o}},RTe=t=>{let{headers:e,rows:n}=t,r=a=>{let l=!1,c=!1;for(let u of a){if(u==='"'){l=!0,c=!0;break}(u===","||u===`
207
207
  `)&&(l=!0)}return l?c?`"${a.replace(/"/g,'""')}"`:`"${a}"`:a},o=e.length>0?n.length+1:n.length,i=new Array(o),s=0;e.length>0&&(i[s]=e.map(r).join(","),s+=1);for(let a of n)i[s]=a.map(r).join(","),s+=1;return i.join(`
208
208
  `)},Wen=t=>{let{headers:e,rows:n}=t,r=a=>{let l=!1;for(let u of a)if(u===" "||u===`
@@ -869,8 +869,8 @@ Please report this to https://github.com/markedjs/marked.`,e){let o="<p>An error
869
869
  node : x:${t.x} y:${t.y} w:${t.width} h:${t.height}`);const r=t.x,o=t.y,i=Math.abs(r-n.x),s=t.width/2;let a=n.x<e.x?s-i:s+i;const l=t.height/2,c=Math.abs(e.y-n.y),u=Math.abs(e.x-n.x);if(Math.abs(o-e.y)*s>Math.abs(r-e.x)*l){let d=n.y<e.y?e.y-l-o:o-l-e.y;a=u*d/c;const h={x:n.x<e.x?n.x+a:n.x-u+a,y:n.y<e.y?n.y+c-d:n.y-c+d};return a===0&&(h.x=e.x,h.y=e.y),u===0&&(h.x=e.x),c===0&&(h.y=e.y),ut.debug(`abc89 top/bottom calc, Q ${c}, q ${d}, R ${u}, r ${a}`,h),h}else{n.x<e.x?a=e.x-s-r:a=r-s-e.x;let d=c*a/u,h=n.x<e.x?n.x+u-a:n.x-u+a,p=n.y<e.y?n.y+d:n.y-d;return ut.debug(`sides calc abc89, Q ${c}, q ${d}, R ${u}, r ${a}`,{_x:h,_y:p}),a===0&&(h=e.x,p=e.y),u===0&&(h=e.x),c===0&&(p=e.y),{x:h,y:p}}},"intersection"),$he=W((t,e)=>{ut.warn("abc88 cutPathAtIntersect",t,e);let n=[],r=t[0],o=!1;return t.forEach(i=>{if(ut.info("abc88 checking point",i,e),!G6n(e,i)&&!o){const s=Y6n(e,r,i);ut.debug("abc88 inside",i,r,s),ut.debug("abc88 intersection",s,e);let a=!1;n.forEach(l=>{a=a||l.x===s.x&&l.y===s.y}),n.some(l=>l.x===s.x&&l.y===s.y)?ut.warn("abc88 no intersect",s,n):n.push(s),o=!0}else ut.warn("abc88 outside",i,r),r=i,o||n.push(i)}),ut.debug("returning points",n),n},"cutPathAtIntersect");function kze(t){const e=[],n=[];for(let r=1;r<t.length-1;r++){const o=t[r-1],i=t[r],s=t[r+1];(o.x===i.x&&i.y===s.y&&Math.abs(i.x-s.x)>5&&Math.abs(i.y-o.y)>5||o.y===i.y&&i.x===s.x&&Math.abs(i.x-o.x)>5&&Math.abs(i.y-s.y)>5)&&(e.push(i),n.push(r))}return{cornerPoints:e,cornerPointPositions:n}}W(kze,"extractCornerPoints");var Bhe=W(function(t,e,n){const r=e.x-t.x,o=e.y-t.y,i=Math.sqrt(r*r+o*o),s=n/i;return{x:e.x-s*r,y:e.y-s*o}},"findAdjacentPoint"),X6n=W(function(t){const{cornerPointPositions:e}=kze(t),n=[];for(let r=0;r<t.length;r++)if(e.includes(r)){const o=t[r-1],i=t[r+1],s=t[r],a=Bhe(o,s,5),l=Bhe(i,s,5),c=l.x-a.x,u=l.y-a.y;n.push(a);const d=Math.sqrt(2)*2;let h={x:s.x,y:s.y};if(Math.abs(i.x-o.x)>10&&Math.abs(i.y-o.y)>=10){ut.debug("Corner point fixing",Math.abs(i.x-o.x),Math.abs(i.y-o.y));const p=5;s.x===a.x?h={x:c<0?a.x-p+d:a.x+p-d,y:u<0?a.y-d:a.y+d}:h={x:c<0?a.x-d:a.x+d,y:u<0?a.y-p+d:a.y+p-d}}else ut.debug("Corner point skipping fixing",Math.abs(i.x-o.x),Math.abs(i.y-o.y));n.push(h,l)}else n.push(t[r]);return n},"fixCorners"),K6n=W((t,e,n)=>{const r=t-e-n,o=2,i=2,s=o+i,a=Math.floor(r/s),l=Array(a).fill(`${o} ${i}`).join(" ");return`0 ${e} ${l} ${n}`},"generateDashArray"),J6n=W(function(t,e,n,r,o,i,s,a=!1){const{handDrawnSeed:l}=Gr();let c=e.points,u=!1;const d=o;var h=i;const p=[];for(const Q in e.cssCompiledStyles)eIe(Q)||p.push(e.cssCompiledStyles[Q]);ut.debug("UIO intersect check",e.points,h.x,d.x),h.intersect&&d.intersect&&!a&&(c=c.slice(1,e.points.length-1),c.unshift(d.intersect(c[0])),ut.debug("Last point UIO",e.start,"-->",e.end,c[c.length-1],h,h.intersect(c[c.length-1])),c.push(h.intersect(c[c.length-1])));const g=btoa(JSON.stringify(c));e.toCluster&&(ut.info("to cluster abc88",n.get(e.toCluster)),c=$he(e.points,n.get(e.toCluster).node),u=!0),e.fromCluster&&(ut.debug("from cluster abc88",n.get(e.fromCluster),JSON.stringify(c,null,2)),c=$he(c.reverse(),n.get(e.fromCluster).node).reverse(),u=!0);let _=c.filter(Q=>!Number.isNaN(Q.y));_=X6n(_);let x=q9;switch(x=J3,e.curve){case"linear":x=J3;break;case"basis":x=q9;break;case"cardinal":x=cRe;break;case"bumpX":x=mJ;break;case"bumpY":x=gJ;break;case"catmullRom":x=dRe;break;case"monotoneX":x=yJ;break;case"monotoneY":x=wJ;break;case"natural":x=kJ;break;case"step":x=OJ;break;case"stepAfter":x=CJ;break;case"stepBefore":x=SJ;break;default:x=q9}const{x:y,y:k}=Xpn(e),O=pJ().x(y).y(k).curve(x);let C;switch(e.thickness){case"normal":C="edge-thickness-normal";break;case"thick":C="edge-thickness-thick";break;case"invisible":C="edge-thickness-invisible";break;default:C="edge-thickness-normal"}switch(e.pattern){case"solid":C+=" edge-pattern-solid";break;case"dotted":C+=" edge-pattern-dotted";break;case"dashed":C+=" edge-pattern-dashed";break;default:C+=" edge-pattern-solid"}let A,E=e.curve==="rounded"?Oze(Sze(_,e),5):O(_);const M=Array.isArray(e.style)?e.style:[e.style];let P=M.find(Q=>Q?.startsWith("stroke:")),L=!1;if(e.look==="handDrawn"){const Q=on.svg(t);Object.assign([],_);const H=Q.path(E,{roughness:.3,seed:l});C+=" transition",A=Ir(H).select("path").attr("id",e.id).attr("class"," "+C+(e.classes?" "+e.classes:"")).attr("style",M?M.reduce((V,G)=>V+";"+G,""):"");let N=A.attr("d");A.attr("d",N),t.node().appendChild(A.node())}else{const Q=p.join(";"),H=M?M.reduce((U,B)=>U+B+";",""):"";let N="";e.animate&&(N=" edge-animation-fast"),e.animation&&(N=" edge-animation-"+e.animation);const V=(Q?Q+";"+H+";":H)+";"+(M?M.reduce((U,B)=>U+";"+B,""):"");A=t.append("path").attr("d",E).attr("id",e.id).attr("class"," "+C+(e.classes?" "+e.classes:"")+(N??"")).attr("style",V),P=V.match(/stroke:([^;]+)/)?.[1],L=e.animate===!0||!!e.animation||Q.includes("animation");const G=A.node(),K=typeof G.getTotalLength=="function"?G.getTotalLength():0,q=nhe[e.arrowTypeStart]||0,Z=nhe[e.arrowTypeEnd]||0;if(e.look==="neo"&&!L){const B=`stroke-dasharray: ${e.pattern==="dotted"||e.pattern==="dashed"?K6n(K,q,Z):`0 ${q} ${K-q-Z} ${Z}`}; stroke-dashoffset: 0;`;A.attr("style",B+A.attr("style"))}}A.attr("data-edge",!0),A.attr("data-et","edge"),A.attr("data-id",e.id),A.attr("data-points",g),e.showPoints&&_.forEach(Q=>{t.append("circle").style("stroke","red").style("fill","red").attr("r",1).attr("cx",Q.x).attr("cy",Q.y)});let D="";(Gr().flowchart.arrowMarkerAbsolute||Gr().state.arrowMarkerAbsolute)&&(D=window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search,D=D.replace(/\(/g,"\\(").replace(/\)/g,"\\)")),ut.info("arrowTypeStart",e.arrowTypeStart),ut.info("arrowTypeEnd",e.arrowTypeEnd),Q6n(A,e,D,s,r,P);const I=Math.floor(c.length/2),z=c[I];A0.isLabelCoordinateInPath(z,A.attr("d"))||(u=!0);let Y={};return u&&(Y.updatedPath=c),Y.originalPath=e.points,Y},"insertEdge");function Oze(t,e){if(t.length<2)return"";let n="";const r=t.length,o=1e-5;for(let i=0;i<r;i++){const s=t[i],a=t[i-1],l=t[i+1];if(i===0)n+=`M${s.x},${s.y}`;else if(i===r-1)n+=`L${s.x},${s.y}`;else{const c=s.x-a.x,u=s.y-a.y,d=l.x-s.x,h=l.y-s.y,p=Math.hypot(c,u),g=Math.hypot(d,h);if(p<o||g<o){n+=`L${s.x},${s.y}`;continue}const _=c/p,x=u/p,y=d/g,k=h/g,O=_*y+x*k,C=Math.max(-1,Math.min(1,O)),A=Math.acos(C);if(A<o||Math.abs(Math.PI-A)<o){n+=`L${s.x},${s.y}`;continue}const E=Math.min(e/Math.sin(A/2),p/2,g/2),M=s.x-_*E,P=s.y-x*E,L=s.x+y*E,D=s.y+k*E;n+=`L${M},${P}`,n+=`Q${s.x},${s.y} ${L},${D}`}}return n}W(Oze,"generateRoundedPath");function EQ(t,e){if(!t||!e)return{angle:0,deltaX:0,deltaY:0};const n=e.x-t.x,r=e.y-t.y;return{angle:Math.atan2(r,n),deltaX:n,deltaY:r}}W(EQ,"calculateDeltaAndAngle");function Sze(t,e){const n=t.map(o=>({...o}));if(t.length>=2&&ta[e.arrowTypeStart]){const o=ta[e.arrowTypeStart],i=t[0],s=t[1],{angle:a}=EQ(i,s),l=o*Math.cos(a),c=o*Math.sin(a);n[0].x=i.x+l,n[0].y=i.y+c}const r=t.length;if(r>=2&&ta[e.arrowTypeEnd]){const o=ta[e.arrowTypeEnd],i=t[r-1],s=t[r-2],{angle:a}=EQ(s,i),l=o*Math.cos(a),c=o*Math.sin(a);n[r-1].x=i.x-l,n[r-1].y=i.y-c}return n}W(Sze,"applyMarkerOffsetsToPoints");var egn=W((t,e,n,r)=>{e.forEach(o=>{ggn[o](t,n,r)})},"insertMarkers"),tgn=W((t,e,n)=>{ut.trace("Making markers for ",n),t.append("defs").append("marker").attr("id",n+"_"+e+"-extensionStart").attr("class","marker extension "+e).attr("refX",18).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 1,7 L18,13 V 1 Z"),t.append("defs").append("marker").attr("id",n+"_"+e+"-extensionEnd").attr("class","marker extension "+e).attr("refX",1).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 1,1 V 13 L18,7 Z")},"extension"),ngn=W((t,e,n)=>{t.append("defs").append("marker").attr("id",n+"_"+e+"-compositionStart").attr("class","marker composition "+e).attr("refX",18).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z"),t.append("defs").append("marker").attr("id",n+"_"+e+"-compositionEnd").attr("class","marker composition "+e).attr("refX",1).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z")},"composition"),rgn=W((t,e,n)=>{t.append("defs").append("marker").attr("id",n+"_"+e+"-aggregationStart").attr("class","marker aggregation "+e).attr("refX",18).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z"),t.append("defs").append("marker").attr("id",n+"_"+e+"-aggregationEnd").attr("class","marker aggregation "+e).attr("refX",1).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z")},"aggregation"),ogn=W((t,e,n)=>{t.append("defs").append("marker").attr("id",n+"_"+e+"-dependencyStart").attr("class","marker dependency "+e).attr("refX",6).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 5,7 L9,13 L1,7 L9,1 Z"),t.append("defs").append("marker").attr("id",n+"_"+e+"-dependencyEnd").attr("class","marker dependency "+e).attr("refX",13).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L14,7 L9,1 Z")},"dependency"),ign=W((t,e,n)=>{t.append("defs").append("marker").attr("id",n+"_"+e+"-lollipopStart").attr("class","marker lollipop "+e).attr("refX",13).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("circle").attr("stroke","black").attr("fill","transparent").attr("cx",7).attr("cy",7).attr("r",6),t.append("defs").append("marker").attr("id",n+"_"+e+"-lollipopEnd").attr("class","marker lollipop "+e).attr("refX",1).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("circle").attr("stroke","black").attr("fill","transparent").attr("cx",7).attr("cy",7).attr("r",6)},"lollipop"),sgn=W((t,e,n)=>{t.append("marker").attr("id",n+"_"+e+"-pointEnd").attr("class","marker "+e).attr("viewBox","0 0 10 10").attr("refX",5).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",8).attr("markerHeight",8).attr("orient","auto").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0"),t.append("marker").attr("id",n+"_"+e+"-pointStart").attr("class","marker "+e).attr("viewBox","0 0 10 10").attr("refX",4.5).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",8).attr("markerHeight",8).attr("orient","auto").append("path").attr("d","M 0 5 L 10 10 L 10 0 z").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0")},"point"),agn=W((t,e,n)=>{t.append("marker").attr("id",n+"_"+e+"-circleEnd").attr("class","marker "+e).attr("viewBox","0 0 10 10").attr("refX",11).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("circle").attr("cx","5").attr("cy","5").attr("r","5").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0"),t.append("marker").attr("id",n+"_"+e+"-circleStart").attr("class","marker "+e).attr("viewBox","0 0 10 10").attr("refX",-1).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("circle").attr("cx","5").attr("cy","5").attr("r","5").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0")},"circle"),lgn=W((t,e,n)=>{t.append("marker").attr("id",n+"_"+e+"-crossEnd").attr("class","marker cross "+e).attr("viewBox","0 0 11 11").attr("refX",12).attr("refY",5.2).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("path").attr("d","M 1,1 l 9,9 M 10,1 l -9,9").attr("class","arrowMarkerPath").style("stroke-width",2).style("stroke-dasharray","1,0"),t.append("marker").attr("id",n+"_"+e+"-crossStart").attr("class","marker cross "+e).attr("viewBox","0 0 11 11").attr("refX",-1).attr("refY",5.2).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("path").attr("d","M 1,1 l 9,9 M 10,1 l -9,9").attr("class","arrowMarkerPath").style("stroke-width",2).style("stroke-dasharray","1,0")},"cross"),cgn=W((t,e,n)=>{t.append("defs").append("marker").attr("id",n+"_"+e+"-barbEnd").attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",14).attr("markerUnits","userSpaceOnUse").attr("orient","auto").append("path").attr("d","M 19,7 L9,13 L14,7 L9,1 Z")},"barb"),ugn=W((t,e,n)=>{t.append("defs").append("marker").attr("id",n+"_"+e+"-onlyOneStart").attr("class","marker onlyOne "+e).attr("refX",0).attr("refY",9).attr("markerWidth",18).attr("markerHeight",18).attr("orient","auto").append("path").attr("d","M9,0 L9,18 M15,0 L15,18"),t.append("defs").append("marker").attr("id",n+"_"+e+"-onlyOneEnd").attr("class","marker onlyOne "+e).attr("refX",18).attr("refY",9).attr("markerWidth",18).attr("markerHeight",18).attr("orient","auto").append("path").attr("d","M3,0 L3,18 M9,0 L9,18")},"only_one"),dgn=W((t,e,n)=>{const r=t.append("defs").append("marker").attr("id",n+"_"+e+"-zeroOrOneStart").attr("class","marker zeroOrOne "+e).attr("refX",0).attr("refY",9).attr("markerWidth",30).attr("markerHeight",18).attr("orient","auto");r.append("circle").attr("fill","white").attr("cx",21).attr("cy",9).attr("r",6),r.append("path").attr("d","M9,0 L9,18");const o=t.append("defs").append("marker").attr("id",n+"_"+e+"-zeroOrOneEnd").attr("class","marker zeroOrOne "+e).attr("refX",30).attr("refY",9).attr("markerWidth",30).attr("markerHeight",18).attr("orient","auto");o.append("circle").attr("fill","white").attr("cx",9).attr("cy",9).attr("r",6),o.append("path").attr("d","M21,0 L21,18")},"zero_or_one"),fgn=W((t,e,n)=>{t.append("defs").append("marker").attr("id",n+"_"+e+"-oneOrMoreStart").attr("class","marker oneOrMore "+e).attr("refX",18).attr("refY",18).attr("markerWidth",45).attr("markerHeight",36).attr("orient","auto").append("path").attr("d","M0,18 Q 18,0 36,18 Q 18,36 0,18 M42,9 L42,27"),t.append("defs").append("marker").attr("id",n+"_"+e+"-oneOrMoreEnd").attr("class","marker oneOrMore "+e).attr("refX",27).attr("refY",18).attr("markerWidth",45).attr("markerHeight",36).attr("orient","auto").append("path").attr("d","M3,9 L3,27 M9,18 Q27,0 45,18 Q27,36 9,18")},"one_or_more"),hgn=W((t,e,n)=>{const r=t.append("defs").append("marker").attr("id",n+"_"+e+"-zeroOrMoreStart").attr("class","marker zeroOrMore "+e).attr("refX",18).attr("refY",18).attr("markerWidth",57).attr("markerHeight",36).attr("orient","auto");r.append("circle").attr("fill","white").attr("cx",48).attr("cy",18).attr("r",6),r.append("path").attr("d","M0,18 Q18,0 36,18 Q18,36 0,18");const o=t.append("defs").append("marker").attr("id",n+"_"+e+"-zeroOrMoreEnd").attr("class","marker zeroOrMore "+e).attr("refX",39).attr("refY",18).attr("markerWidth",57).attr("markerHeight",36).attr("orient","auto");o.append("circle").attr("fill","white").attr("cx",9).attr("cy",18).attr("r",6),o.append("path").attr("d","M21,18 Q39,0 57,18 Q39,36 21,18")},"zero_or_more"),pgn=W((t,e,n)=>{t.append("defs").append("marker").attr("id",n+"_"+e+"-requirement_arrowEnd").attr("refX",20).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").append("path").attr("d",`M0,0
870
870
  L20,10
871
871
  M20,10
872
- L0,20`)},"requirement_arrow"),mgn=W((t,e,n)=>{const r=t.append("defs").append("marker").attr("id",n+"_"+e+"-requirement_containsStart").attr("refX",0).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").append("g");r.append("circle").attr("cx",10).attr("cy",10).attr("r",9).attr("fill","none"),r.append("line").attr("x1",1).attr("x2",19).attr("y1",10).attr("y2",10),r.append("line").attr("y1",1).attr("y2",19).attr("x1",10).attr("x2",10)},"requirement_contains"),ggn={extension:tgn,composition:ngn,aggregation:rgn,dependency:ogn,lollipop:ign,point:sgn,circle:agn,cross:lgn,barb:cgn,only_one:ugn,zero_or_one:dgn,one_or_more:fgn,zero_or_more:hgn,requirement_arrow:pgn,requirement_contains:mgn},vgn=egn,bgn={common:i8,getConfig:da,insertCluster:C6n,insertEdge:J6n,insertEdgeLabel:W6n,insertMarkers:vgn,insertNode:wze,interpolateToCurve:$J,labelHelper:Nn,log:ut,positionEdgeLabel:Z6n},p_={},Cze=W(t=>{for(const e of t)p_[e.name]=e},"registerLayoutLoaders"),_gn=W(()=>{Cze([{name:"dagre",loader:W(async()=>await re(()=>import("./dagre-6UL2VRFP-BV1RIA6i.js"),__vite__mapDeps([101,102,103,104,105,106])),"loader")},{name:"cose-bilkent",loader:W(async()=>await re(()=>import("./cose-bilkent-S5V4N54A-CiQDuqKy.js"),__vite__mapDeps([107,108])),"loader")}])},"registerDefaultLayoutLoaders");_gn();var Her=W(async(t,e)=>{if(!(t.layoutAlgorithm in p_))throw new Error(`Unknown layout algorithm: ${t.layoutAlgorithm}`);const n=p_[t.layoutAlgorithm];return(await n.loader()).render(t,e,bgn,{algorithm:n.algorithm})},"render"),Fer=W((t="",{fallback:e="dagre"}={})=>{if(t in p_)return t;if(e in p_)return ut.warn(`Layout algorithm ${t} is not registered. Using ${e} as fallback.`),e;throw new Error(`Both layout algorithms ${t} and ${e} are not registered.`)},"getRegisteredLayoutAlgorithm"),Aze="comm",Eze="rule",Tze="decl",xgn="@import",ygn="@namespace",wgn="@keyframes",kgn="@layer",Mze=Math.abs,iee=String.fromCharCode;function Pze(t){return t.trim()}function LS(t,e,n){return t.replace(e,n)}function Ogn(t,e,n){return t.indexOf(e,n)}function h6(t,e){return t.charCodeAt(e)|0}function pg(t,e,n){return t.slice(e,n)}function R1(t){return t.length}function Sgn(t){return t.length}function Yk(t,e){return e.push(t),t}var Fj=1,mg=1,jze=0,Xc=0,Si=0,d8="";function see(t,e,n,r,o,i,s,a){return{value:t,root:e,parent:n,type:r,props:o,children:i,line:Fj,column:mg,length:s,return:"",siblings:a}}function Cgn(){return Si}function Agn(){return Si=Xc>0?h6(d8,--Xc):0,mg--,Si===10&&(mg=1,Fj--),Si}function D0(){return Si=Xc<jze?h6(d8,Xc++):0,mg++,Si===10&&(mg=1,Fj++),Si}function zf(){return h6(d8,Xc)}function IS(){return Xc}function qj(t,e){return pg(d8,t,e)}function m_(t){switch(t){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function Egn(t){return Fj=mg=1,jze=R1(d8=t),Xc=0,[]}function Tgn(t){return d8="",t}function h$(t){return Pze(qj(Xc-1,TQ(t===91?t+2:t===40?t+1:t)))}function Mgn(t){for(;(Si=zf())&&Si<33;)D0();return m_(t)>2||m_(Si)>3?"":" "}function Pgn(t,e){for(;--e&&D0()&&!(Si<48||Si>102||Si>57&&Si<65||Si>70&&Si<97););return qj(t,IS()+(e<6&&zf()==32&&D0()==32))}function TQ(t){for(;D0();)switch(Si){case t:return Xc;case 34:case 39:t!==34&&t!==39&&TQ(Si);break;case 40:t===41&&TQ(t);break;case 92:D0();break}return Xc}function jgn(t,e){for(;D0()&&t+Si!==57;)if(t+Si===84&&zf()===47)break;return"/*"+qj(e,Xc-1)+"*"+iee(t===47?t:D0())}function Ngn(t){for(;!m_(zf());)D0();return qj(t,Xc)}function Rgn(t){return Tgn(DS("",null,null,null,[""],t=Egn(t),0,[0],t))}function DS(t,e,n,r,o,i,s,a,l){for(var c=0,u=0,d=s,h=0,p=0,g=0,_=1,x=1,y=1,k=0,O="",C=o,A=i,E=r,M=O;x;)switch(g=k,k=D0()){case 40:if(g!=108&&h6(M,d-1)==58){Ogn(M+=LS(h$(k),"&","&\f"),"&\f",Mze(c?a[c-1]:0))!=-1&&(y=-1);break}case 34:case 39:case 91:M+=h$(k);break;case 9:case 10:case 13:case 32:M+=Mgn(g);break;case 92:M+=Pgn(IS()-1,7);continue;case 47:switch(zf()){case 42:case 47:Yk(Lgn(jgn(D0(),IS()),e,n,l),l),(m_(g||1)==5||m_(zf()||1)==5)&&R1(M)&&pg(M,-1,void 0)!==" "&&(M+=" ");break;default:M+="/"}break;case 123*_:a[c++]=R1(M)*y;case 125*_:case 59:case 0:switch(k){case 0:case 125:x=0;case 59+u:y==-1&&(M=LS(M,/\f/g,"")),p>0&&(R1(M)-d||_===0&&g===47)&&Yk(p>32?Fhe(M+";",r,n,d-1,l):Fhe(LS(M," ","")+";",r,n,d-2,l),l);break;case 59:M+=";";default:if(Yk(E=Hhe(M,e,n,c,u,o,a,O,C=[],A=[],d,i),i),k===123)if(u===0)DS(M,e,E,E,C,i,d,a,A);else{switch(h){case 99:if(h6(M,3)===110)break;case 108:if(h6(M,2)===97)break;default:u=0;case 100:case 109:case 115:}u?DS(t,E,E,r&&Yk(Hhe(t,E,E,0,0,o,a,O,o,C=[],d,A),A),o,A,d,a,r?C:A):DS(M,E,E,E,[""],A,0,a,A)}}c=u=p=0,_=y=1,O=M="",d=s;break;case 58:d=1+R1(M),p=g;default:if(_<1){if(k==123)--_;else if(k==125&&_++==0&&Agn()==125)continue}switch(M+=iee(k),k*_){case 38:y=u>0?1:(M+="\f",-1);break;case 44:a[c++]=(R1(M)-1)*y,y=1;break;case 64:zf()===45&&(M+=h$(D0())),h=zf(),u=d=R1(O=M+=Ngn(IS())),k++;break;case 45:g===45&&R1(M)==2&&(_=0)}}return i}function Hhe(t,e,n,r,o,i,s,a,l,c,u,d){for(var h=o-1,p=o===0?i:[""],g=Sgn(p),_=0,x=0,y=0;_<r;++_)for(var k=0,O=pg(t,h+1,h=Mze(x=s[_])),C=t;k<g;++k)(C=Pze(x>0?p[k]+" "+O:LS(O,/&\f/g,p[k])))&&(l[y++]=C);return see(t,e,n,o===0?Eze:a,l,c,u,d)}function Lgn(t,e,n,r){return see(t,e,n,Aze,iee(Cgn()),pg(t,2,-2),0,r)}function Fhe(t,e,n,r,o){return see(t,e,n,Tze,pg(t,0,r),pg(t,r+1,-1),r,o)}function MQ(t,e){for(var n="",r=0;r<t.length;r++)n+=e(t[r],r,t,e)||"";return n}function Ign(t,e,n,r){switch(t.type){case kgn:if(t.children.length)break;case xgn:case ygn:case Tze:return t.return=t.return||t.value;case Aze:return"";case wgn:return t.return=t.value+"{"+MQ(t.children,r)+"}";case Eze:if(!R1(t.value=t.props.join(",")))return""}return R1(n=MQ(t.children,r))?t.return=t.value+"{"+n+"}":""}var Dgn=oIe(Object.keys,Object),zgn=Object.prototype,$gn=zgn.hasOwnProperty;function Bgn(t){if(!jj(t))return Dgn(t);var e=[];for(var n in Object(t))$gn.call(t,n)&&n!="constructor"&&e.push(n);return e}var PQ=V4(ju,"DataView"),jQ=V4(ju,"Promise"),NQ=V4(ju,"Set"),RQ=V4(ju,"WeakMap"),qhe="[object Map]",Hgn="[object Object]",Vhe="[object Promise]",Qhe="[object Set]",Uhe="[object WeakMap]",Whe="[object DataView]",Fgn=q4(PQ),qgn=q4(f_),Vgn=q4(jQ),Qgn=q4(NQ),Ugn=q4(RQ),Lp=l8;(PQ&&Lp(new PQ(new ArrayBuffer(1)))!=Whe||f_&&Lp(new f_)!=qhe||jQ&&Lp(jQ.resolve())!=Vhe||NQ&&Lp(new NQ)!=Qhe||RQ&&Lp(new RQ)!=Uhe)&&(Lp=function(t){var e=l8(t),n=e==Hgn?t.constructor:void 0,r=n?q4(n):"";if(r)switch(r){case Fgn:return Whe;case qgn:return qhe;case Vgn:return Vhe;case Qgn:return Qhe;case Ugn:return Uhe}return e});var Wgn="[object Map]",Zgn="[object Set]",Ggn=Object.prototype,Ygn=Ggn.hasOwnProperty;function Zhe(t){if(t==null)return!0;if(Nj(t)&&(SE(t)||typeof t=="string"||typeof t.splice=="function"||DJ(t)||zJ(t)||OE(t)))return!t.length;var e=Lp(t);if(e==Wgn||e==Zgn)return!t.size;if(jj(t))return!Bgn(t).length;for(var n in t)if(Ygn.call(t,n))return!1;return!0}var Nze="c4",Xgn=W(t=>/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(t),"detector"),Kgn=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./c4Diagram-YG6GDRKO-1o6lovC1.js");return{diagram:e}},__vite__mapDeps([109,110]));return{id:Nze,diagram:t}},"loader"),Jgn={id:Nze,detector:Xgn,loader:Kgn},e8n=Jgn,Rze="flowchart",t8n=W((t,e)=>e?.flowchart?.defaultRenderer==="dagre-wrapper"||e?.flowchart?.defaultRenderer==="elk"?!1:/^\s*graph/.test(t),"detector"),n8n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./flowDiagram-NV44I4VS-vWTy8wO1.js");return{diagram:e}},__vite__mapDeps([111,112,113,114,115]));return{id:Rze,diagram:t}},"loader"),r8n={id:Rze,detector:t8n,loader:n8n},o8n=r8n,Lze="flowchart-v2",i8n=W((t,e)=>e?.flowchart?.defaultRenderer==="dagre-d3"?!1:(e?.flowchart?.defaultRenderer==="elk"&&(e.layout="elk"),/^\s*graph/.test(t)&&e?.flowchart?.defaultRenderer==="dagre-wrapper"?!0:/^\s*flowchart/.test(t)),"detector"),s8n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./flowDiagram-NV44I4VS-vWTy8wO1.js");return{diagram:e}},__vite__mapDeps([111,112,113,114,115]));return{id:Lze,diagram:t}},"loader"),a8n={id:Lze,detector:i8n,loader:s8n},l8n=a8n,Ize="er",c8n=W(t=>/^\s*erDiagram/.test(t),"detector"),u8n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./erDiagram-Q2GNP2WA-DnmU3JYj.js");return{diagram:e}},__vite__mapDeps([116,113,114,115]));return{id:Ize,diagram:t}},"loader"),d8n={id:Ize,detector:c8n,loader:u8n},f8n=d8n,Dze="gitGraph",h8n=W(t=>/^\s*gitGraph/.test(t),"detector"),p8n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./gitGraphDiagram-V2S2FVAM-D4Y2-pQd.js");return{diagram:e}},__vite__mapDeps([117,118,119,120,103,105,106]));return{id:Dze,diagram:t}},"loader"),m8n={id:Dze,detector:h8n,loader:p8n},g8n=m8n,zze="gantt",v8n=W(t=>/^\s*gantt/.test(t),"detector"),b8n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./ganttDiagram-JELNMOA3-C8UgEfn6.js");return{diagram:e}},[]);return{id:zze,diagram:t}},"loader"),_8n={id:zze,detector:v8n,loader:b8n},x8n=_8n,$ze="info",y8n=W(t=>/^\s*info/.test(t),"detector"),w8n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./infoDiagram-HS3SLOUP-CmZ04ZX2.js");return{diagram:e}},__vite__mapDeps([121,120,103,105,106]));return{id:$ze,diagram:t}},"loader"),k8n={id:$ze,detector:y8n,loader:w8n},Bze="pie",O8n=W(t=>/^\s*pie/.test(t),"detector"),S8n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./pieDiagram-ADFJNKIX-SdHTH4tD.js");return{diagram:e}},__vite__mapDeps([122,118,120,103,105,106,123]));return{id:Bze,diagram:t}},"loader"),C8n={id:Bze,detector:O8n,loader:S8n},Hze="quadrantChart",A8n=W(t=>/^\s*quadrantChart/.test(t),"detector"),E8n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./quadrantDiagram-AYHSOK5B-CctaxdVX.js");return{diagram:e}},[]);return{id:Hze,diagram:t}},"loader"),T8n={id:Hze,detector:A8n,loader:E8n},M8n=T8n,Fze="xychart",P8n=W(t=>/^\s*xychart(-beta)?/.test(t),"detector"),j8n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./xychartDiagram-PRI3JC2R-R2Q9xRsW.js");return{diagram:e}},[]);return{id:Fze,diagram:t}},"loader"),N8n={id:Fze,detector:P8n,loader:j8n},R8n=N8n,qze="requirement",L8n=W(t=>/^\s*requirement(Diagram)?/.test(t),"detector"),I8n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./requirementDiagram-UZGBJVZJ-BiuKR3TQ.js");return{diagram:e}},__vite__mapDeps([124,113,114]));return{id:qze,diagram:t}},"loader"),D8n={id:qze,detector:L8n,loader:I8n},z8n=D8n,Vze="sequence",$8n=W(t=>/^\s*sequenceDiagram/.test(t),"detector"),B8n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./sequenceDiagram-WL72ISMW-BRAorH_1.js");return{diagram:e}},__vite__mapDeps([125,110,119]));return{id:Vze,diagram:t}},"loader"),H8n={id:Vze,detector:$8n,loader:B8n},F8n=H8n,Qze="class",q8n=W((t,e)=>e?.class?.defaultRenderer==="dagre-wrapper"?!1:/^\s*classDiagram/.test(t),"detector"),V8n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./classDiagram-2ON5EDUG-Dp5-cWrq.js");return{diagram:e}},__vite__mapDeps([126,127,112,113,114]));return{id:Qze,diagram:t}},"loader"),Q8n={id:Qze,detector:q8n,loader:V8n},U8n=Q8n,Uze="classDiagram",W8n=W((t,e)=>/^\s*classDiagram/.test(t)&&e?.class?.defaultRenderer==="dagre-wrapper"?!0:/^\s*classDiagram-v2/.test(t),"detector"),Z8n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./classDiagram-v2-WZHVMYZB-Dp5-cWrq.js");return{diagram:e}},__vite__mapDeps([128,127,112,113,114]));return{id:Uze,diagram:t}},"loader"),G8n={id:Uze,detector:W8n,loader:Z8n},Y8n=G8n,Wze="state",X8n=W((t,e)=>e?.state?.defaultRenderer==="dagre-wrapper"?!1:/^\s*stateDiagram/.test(t),"detector"),K8n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./stateDiagram-FKZM4ZOC-BtHKF925.js");return{diagram:e}},__vite__mapDeps([129,130,113,114,102,103,104,105]));return{id:Wze,diagram:t}},"loader"),J8n={id:Wze,detector:X8n,loader:K8n},e7n=J8n,Zze="stateDiagram",t7n=W((t,e)=>!!(/^\s*stateDiagram-v2/.test(t)||/^\s*stateDiagram/.test(t)&&e?.state?.defaultRenderer==="dagre-wrapper"),"detector"),n7n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./stateDiagram-v2-4FDKWEC3-B40ZaZyn.js");return{diagram:e}},__vite__mapDeps([131,130,113,114]));return{id:Zze,diagram:t}},"loader"),r7n={id:Zze,detector:t7n,loader:n7n},o7n=r7n,Gze="journey",i7n=W(t=>/^\s*journey/.test(t),"detector"),s7n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./journeyDiagram-XKPGCS4Q-CyBTVa_6.js");return{diagram:e}},__vite__mapDeps([132,110,112,123]));return{id:Gze,diagram:t}},"loader"),a7n={id:Gze,detector:i7n,loader:s7n},l7n=a7n,c7n=W((t,e,n)=>{ut.debug(`rendering svg for syntax error
873
- `);const r=qhn(e),o=r.append("g");r.attr("viewBox","0 0 2412 512"),Wje(r,100,512,!0),o.append("path").attr("class","error-icon").attr("d","m411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z"),o.append("path").attr("class","error-icon").attr("d","m459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z"),o.append("path").attr("class","error-icon").attr("d","m340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z"),o.append("path").attr("class","error-icon").attr("d","m400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z"),o.append("path").attr("class","error-icon").attr("d","m496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z"),o.append("path").attr("class","error-icon").attr("d","m436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z"),o.append("text").attr("class","error-text").attr("x",1440).attr("y",250).attr("font-size","150px").style("text-anchor","middle").text("Syntax error in text"),o.append("text").attr("class","error-text").attr("x",1250).attr("y",400).attr("font-size","100px").style("text-anchor","middle").text(`mermaid version ${n}`)},"draw"),Yze={draw:c7n},u7n=Yze,d7n={db:{},renderer:Yze,parser:{parse:W(()=>{},"parse")}},f7n=d7n,Xze="flowchart-elk",h7n=W((t,e={})=>/^\s*flowchart-elk/.test(t)||/^\s*(flowchart|graph)/.test(t)&&e?.flowchart?.defaultRenderer==="elk"?(e.layout="elk",!0):!1,"detector"),p7n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./flowDiagram-NV44I4VS-vWTy8wO1.js");return{diagram:e}},__vite__mapDeps([111,112,113,114,115]));return{id:Xze,diagram:t}},"loader"),m7n={id:Xze,detector:h7n,loader:p7n},g7n=m7n,Kze="timeline",v7n=W(t=>/^\s*timeline/.test(t),"detector"),b7n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./timeline-definition-IT6M3QCI-BxQS_MT5.js");return{diagram:e}},__vite__mapDeps([133,123]));return{id:Kze,diagram:t}},"loader"),_7n={id:Kze,detector:v7n,loader:b7n},x7n=_7n,Jze="mindmap",y7n=W(t=>/^\s*mindmap/.test(t),"detector"),w7n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./mindmap-definition-VGOIOE7T-D4byQ-t_.js");return{diagram:e}},__vite__mapDeps([134,113,114]));return{id:Jze,diagram:t}},"loader"),k7n={id:Jze,detector:y7n,loader:w7n},O7n=k7n,e$e="kanban",S7n=W(t=>/^\s*kanban/.test(t),"detector"),C7n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./kanban-definition-3W4ZIXB7-C6sCohDW.js");return{diagram:e}},__vite__mapDeps([135,112]));return{id:e$e,diagram:t}},"loader"),A7n={id:e$e,detector:S7n,loader:C7n},E7n=A7n,t$e="sankey",T7n=W(t=>/^\s*sankey(-beta)?/.test(t),"detector"),M7n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./sankeyDiagram-TZEHDZUN-BTpPs36c.js");return{diagram:e}},[]);return{id:t$e,diagram:t}},"loader"),P7n={id:t$e,detector:T7n,loader:M7n},j7n=P7n,n$e="packet",N7n=W(t=>/^\s*packet(-beta)?/.test(t),"detector"),R7n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./diagram-S2PKOQOG-sjeU7pbV.js");return{diagram:e}},__vite__mapDeps([136,118,120,103,105,106]));return{id:n$e,diagram:t}},"loader"),L7n={id:n$e,detector:N7n,loader:R7n},r$e="radar",I7n=W(t=>/^\s*radar-beta/.test(t),"detector"),D7n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./diagram-QEK2KX5R-BvBvt_5J.js");return{diagram:e}},__vite__mapDeps([137,118,120,103,105,106]));return{id:r$e,diagram:t}},"loader"),z7n={id:r$e,detector:I7n,loader:D7n},o$e="block",$7n=W(t=>/^\s*block(-beta)?/.test(t),"detector"),B7n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./blockDiagram-VD42YOAC-BLg8A5DO.js");return{diagram:e}},__vite__mapDeps([138,112,106,103,102,115]));return{id:o$e,diagram:t}},"loader"),H7n={id:o$e,detector:$7n,loader:B7n},F7n=H7n,i$e="architecture",q7n=W(t=>/^\s*architecture/.test(t),"detector"),V7n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./architectureDiagram-VXUJARFQ-_4wJCo66.js");return{diagram:e}},__vite__mapDeps([139,118,120,103,105,106,108]));return{id:i$e,diagram:t}},"loader"),Q7n={id:i$e,detector:q7n,loader:V7n},U7n=Q7n,s$e="treemap",W7n=W(t=>/^\s*treemap/.test(t),"detector"),Z7n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./diagram-PSM6KHXK-oZBpmBZ4.js");return{diagram:e}},__vite__mapDeps([140,114,118,120,103,105,106]));return{id:s$e,diagram:t}},"loader"),G7n={id:s$e,detector:W7n,loader:Z7n},Ghe=!1,Vj=W(()=>{Ghe||(Ghe=!0,KA("error",f7n,t=>t.toLowerCase().trim()==="error"),KA("---",{db:{clear:W(()=>{},"clear")},styles:{},renderer:{draw:W(()=>{},"draw")},parser:{parse:W(()=>{throw new Error("Diagrams beginning with --- are not valid. If you were trying to use a YAML front-matter, please ensure that you've correctly opened and closed the YAML front-matter with un-indented `---` blocks")},"parse")},init:W(()=>null,"init")},t=>t.toLowerCase().trimStart().startsWith("---")),LV(g7n,O7n,U7n),LV(e8n,E7n,Y8n,U8n,f8n,x8n,k8n,C8n,z8n,F8n,l8n,o8n,x7n,g8n,o7n,e7n,l7n,M8n,j7n,L7n,R8n,F7n,z7n,G7n))},"addDiagrams"),Y7n=W(async()=>{ut.debug("Loading registered diagrams");const e=(await Promise.allSettled(Object.entries(G3).map(async([n,{detector:r,loader:o}])=>{if(o)try{$V(n)}catch{try{const{diagram:i,id:s}=await o();KA(s,i,r)}catch(i){throw ut.error(`Failed to load external diagram with key ${n}. Removing from detectors.`),delete G3[n],i}}}))).filter(n=>n.status==="rejected");if(e.length>0){ut.error(`Failed to load ${e.length} external diagrams`);for(const n of e)ut.error(n);throw new Error(`Failed to load ${e.length} external diagrams`)}},"loadRegisteredDiagrams"),X7n="graphics-document document";function a$e(t,e){t.attr("role",X7n),e!==""&&t.attr("aria-roledescription",e)}W(a$e,"setA11yDiagramInfo");function l$e(t,e,n,r){if(t.insert!==void 0){if(n){const o=`chart-desc-${r}`;t.attr("aria-describedby",o),t.insert("desc",":first-child").attr("id",o).text(n)}if(e){const o=`chart-title-${r}`;t.attr("aria-labelledby",o),t.insert("title",":first-child").attr("id",o).text(e)}}}W(l$e,"addSVGa11yTitleDescription");var S3,LQ=(S3=class{constructor(e,n,r,o,i){this.type=e,this.text=n,this.db=r,this.parser=o,this.renderer=i}static async fromText(e,n={}){const r=da(),o=jK(e,r);e=Gmn(e)+`
872
+ L0,20`)},"requirement_arrow"),mgn=W((t,e,n)=>{const r=t.append("defs").append("marker").attr("id",n+"_"+e+"-requirement_containsStart").attr("refX",0).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").append("g");r.append("circle").attr("cx",10).attr("cy",10).attr("r",9).attr("fill","none"),r.append("line").attr("x1",1).attr("x2",19).attr("y1",10).attr("y2",10),r.append("line").attr("y1",1).attr("y2",19).attr("x1",10).attr("x2",10)},"requirement_contains"),ggn={extension:tgn,composition:ngn,aggregation:rgn,dependency:ogn,lollipop:ign,point:sgn,circle:agn,cross:lgn,barb:cgn,only_one:ugn,zero_or_one:dgn,one_or_more:fgn,zero_or_more:hgn,requirement_arrow:pgn,requirement_contains:mgn},vgn=egn,bgn={common:i8,getConfig:da,insertCluster:C6n,insertEdge:J6n,insertEdgeLabel:W6n,insertMarkers:vgn,insertNode:wze,interpolateToCurve:$J,labelHelper:Nn,log:ut,positionEdgeLabel:Z6n},p_={},Cze=W(t=>{for(const e of t)p_[e.name]=e},"registerLayoutLoaders"),_gn=W(()=>{Cze([{name:"dagre",loader:W(async()=>await re(()=>import("./dagre-6UL2VRFP-CIdLKDDa.js"),__vite__mapDeps([101,102,103,104,105,106])),"loader")},{name:"cose-bilkent",loader:W(async()=>await re(()=>import("./cose-bilkent-S5V4N54A-C7S-iRjs.js"),__vite__mapDeps([107,108])),"loader")}])},"registerDefaultLayoutLoaders");_gn();var Her=W(async(t,e)=>{if(!(t.layoutAlgorithm in p_))throw new Error(`Unknown layout algorithm: ${t.layoutAlgorithm}`);const n=p_[t.layoutAlgorithm];return(await n.loader()).render(t,e,bgn,{algorithm:n.algorithm})},"render"),Fer=W((t="",{fallback:e="dagre"}={})=>{if(t in p_)return t;if(e in p_)return ut.warn(`Layout algorithm ${t} is not registered. Using ${e} as fallback.`),e;throw new Error(`Both layout algorithms ${t} and ${e} are not registered.`)},"getRegisteredLayoutAlgorithm"),Aze="comm",Eze="rule",Tze="decl",xgn="@import",ygn="@namespace",wgn="@keyframes",kgn="@layer",Mze=Math.abs,iee=String.fromCharCode;function Pze(t){return t.trim()}function LS(t,e,n){return t.replace(e,n)}function Ogn(t,e,n){return t.indexOf(e,n)}function h6(t,e){return t.charCodeAt(e)|0}function pg(t,e,n){return t.slice(e,n)}function R1(t){return t.length}function Sgn(t){return t.length}function Yk(t,e){return e.push(t),t}var Fj=1,mg=1,jze=0,Xc=0,Si=0,d8="";function see(t,e,n,r,o,i,s,a){return{value:t,root:e,parent:n,type:r,props:o,children:i,line:Fj,column:mg,length:s,return:"",siblings:a}}function Cgn(){return Si}function Agn(){return Si=Xc>0?h6(d8,--Xc):0,mg--,Si===10&&(mg=1,Fj--),Si}function D0(){return Si=Xc<jze?h6(d8,Xc++):0,mg++,Si===10&&(mg=1,Fj++),Si}function zf(){return h6(d8,Xc)}function IS(){return Xc}function qj(t,e){return pg(d8,t,e)}function m_(t){switch(t){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function Egn(t){return Fj=mg=1,jze=R1(d8=t),Xc=0,[]}function Tgn(t){return d8="",t}function h$(t){return Pze(qj(Xc-1,TQ(t===91?t+2:t===40?t+1:t)))}function Mgn(t){for(;(Si=zf())&&Si<33;)D0();return m_(t)>2||m_(Si)>3?"":" "}function Pgn(t,e){for(;--e&&D0()&&!(Si<48||Si>102||Si>57&&Si<65||Si>70&&Si<97););return qj(t,IS()+(e<6&&zf()==32&&D0()==32))}function TQ(t){for(;D0();)switch(Si){case t:return Xc;case 34:case 39:t!==34&&t!==39&&TQ(Si);break;case 40:t===41&&TQ(t);break;case 92:D0();break}return Xc}function jgn(t,e){for(;D0()&&t+Si!==57;)if(t+Si===84&&zf()===47)break;return"/*"+qj(e,Xc-1)+"*"+iee(t===47?t:D0())}function Ngn(t){for(;!m_(zf());)D0();return qj(t,Xc)}function Rgn(t){return Tgn(DS("",null,null,null,[""],t=Egn(t),0,[0],t))}function DS(t,e,n,r,o,i,s,a,l){for(var c=0,u=0,d=s,h=0,p=0,g=0,_=1,x=1,y=1,k=0,O="",C=o,A=i,E=r,M=O;x;)switch(g=k,k=D0()){case 40:if(g!=108&&h6(M,d-1)==58){Ogn(M+=LS(h$(k),"&","&\f"),"&\f",Mze(c?a[c-1]:0))!=-1&&(y=-1);break}case 34:case 39:case 91:M+=h$(k);break;case 9:case 10:case 13:case 32:M+=Mgn(g);break;case 92:M+=Pgn(IS()-1,7);continue;case 47:switch(zf()){case 42:case 47:Yk(Lgn(jgn(D0(),IS()),e,n,l),l),(m_(g||1)==5||m_(zf()||1)==5)&&R1(M)&&pg(M,-1,void 0)!==" "&&(M+=" ");break;default:M+="/"}break;case 123*_:a[c++]=R1(M)*y;case 125*_:case 59:case 0:switch(k){case 0:case 125:x=0;case 59+u:y==-1&&(M=LS(M,/\f/g,"")),p>0&&(R1(M)-d||_===0&&g===47)&&Yk(p>32?Fhe(M+";",r,n,d-1,l):Fhe(LS(M," ","")+";",r,n,d-2,l),l);break;case 59:M+=";";default:if(Yk(E=Hhe(M,e,n,c,u,o,a,O,C=[],A=[],d,i),i),k===123)if(u===0)DS(M,e,E,E,C,i,d,a,A);else{switch(h){case 99:if(h6(M,3)===110)break;case 108:if(h6(M,2)===97)break;default:u=0;case 100:case 109:case 115:}u?DS(t,E,E,r&&Yk(Hhe(t,E,E,0,0,o,a,O,o,C=[],d,A),A),o,A,d,a,r?C:A):DS(M,E,E,E,[""],A,0,a,A)}}c=u=p=0,_=y=1,O=M="",d=s;break;case 58:d=1+R1(M),p=g;default:if(_<1){if(k==123)--_;else if(k==125&&_++==0&&Agn()==125)continue}switch(M+=iee(k),k*_){case 38:y=u>0?1:(M+="\f",-1);break;case 44:a[c++]=(R1(M)-1)*y,y=1;break;case 64:zf()===45&&(M+=h$(D0())),h=zf(),u=d=R1(O=M+=Ngn(IS())),k++;break;case 45:g===45&&R1(M)==2&&(_=0)}}return i}function Hhe(t,e,n,r,o,i,s,a,l,c,u,d){for(var h=o-1,p=o===0?i:[""],g=Sgn(p),_=0,x=0,y=0;_<r;++_)for(var k=0,O=pg(t,h+1,h=Mze(x=s[_])),C=t;k<g;++k)(C=Pze(x>0?p[k]+" "+O:LS(O,/&\f/g,p[k])))&&(l[y++]=C);return see(t,e,n,o===0?Eze:a,l,c,u,d)}function Lgn(t,e,n,r){return see(t,e,n,Aze,iee(Cgn()),pg(t,2,-2),0,r)}function Fhe(t,e,n,r,o){return see(t,e,n,Tze,pg(t,0,r),pg(t,r+1,-1),r,o)}function MQ(t,e){for(var n="",r=0;r<t.length;r++)n+=e(t[r],r,t,e)||"";return n}function Ign(t,e,n,r){switch(t.type){case kgn:if(t.children.length)break;case xgn:case ygn:case Tze:return t.return=t.return||t.value;case Aze:return"";case wgn:return t.return=t.value+"{"+MQ(t.children,r)+"}";case Eze:if(!R1(t.value=t.props.join(",")))return""}return R1(n=MQ(t.children,r))?t.return=t.value+"{"+n+"}":""}var Dgn=oIe(Object.keys,Object),zgn=Object.prototype,$gn=zgn.hasOwnProperty;function Bgn(t){if(!jj(t))return Dgn(t);var e=[];for(var n in Object(t))$gn.call(t,n)&&n!="constructor"&&e.push(n);return e}var PQ=V4(ju,"DataView"),jQ=V4(ju,"Promise"),NQ=V4(ju,"Set"),RQ=V4(ju,"WeakMap"),qhe="[object Map]",Hgn="[object Object]",Vhe="[object Promise]",Qhe="[object Set]",Uhe="[object WeakMap]",Whe="[object DataView]",Fgn=q4(PQ),qgn=q4(f_),Vgn=q4(jQ),Qgn=q4(NQ),Ugn=q4(RQ),Lp=l8;(PQ&&Lp(new PQ(new ArrayBuffer(1)))!=Whe||f_&&Lp(new f_)!=qhe||jQ&&Lp(jQ.resolve())!=Vhe||NQ&&Lp(new NQ)!=Qhe||RQ&&Lp(new RQ)!=Uhe)&&(Lp=function(t){var e=l8(t),n=e==Hgn?t.constructor:void 0,r=n?q4(n):"";if(r)switch(r){case Fgn:return Whe;case qgn:return qhe;case Vgn:return Vhe;case Qgn:return Qhe;case Ugn:return Uhe}return e});var Wgn="[object Map]",Zgn="[object Set]",Ggn=Object.prototype,Ygn=Ggn.hasOwnProperty;function Zhe(t){if(t==null)return!0;if(Nj(t)&&(SE(t)||typeof t=="string"||typeof t.splice=="function"||DJ(t)||zJ(t)||OE(t)))return!t.length;var e=Lp(t);if(e==Wgn||e==Zgn)return!t.size;if(jj(t))return!Bgn(t).length;for(var n in t)if(Ygn.call(t,n))return!1;return!0}var Nze="c4",Xgn=W(t=>/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(t),"detector"),Kgn=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./c4Diagram-YG6GDRKO-Ce9RV_Np.js");return{diagram:e}},__vite__mapDeps([109,110]));return{id:Nze,diagram:t}},"loader"),Jgn={id:Nze,detector:Xgn,loader:Kgn},e8n=Jgn,Rze="flowchart",t8n=W((t,e)=>e?.flowchart?.defaultRenderer==="dagre-wrapper"||e?.flowchart?.defaultRenderer==="elk"?!1:/^\s*graph/.test(t),"detector"),n8n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./flowDiagram-NV44I4VS-BzbJhnQR.js");return{diagram:e}},__vite__mapDeps([111,112,113,114,115]));return{id:Rze,diagram:t}},"loader"),r8n={id:Rze,detector:t8n,loader:n8n},o8n=r8n,Lze="flowchart-v2",i8n=W((t,e)=>e?.flowchart?.defaultRenderer==="dagre-d3"?!1:(e?.flowchart?.defaultRenderer==="elk"&&(e.layout="elk"),/^\s*graph/.test(t)&&e?.flowchart?.defaultRenderer==="dagre-wrapper"?!0:/^\s*flowchart/.test(t)),"detector"),s8n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./flowDiagram-NV44I4VS-BzbJhnQR.js");return{diagram:e}},__vite__mapDeps([111,112,113,114,115]));return{id:Lze,diagram:t}},"loader"),a8n={id:Lze,detector:i8n,loader:s8n},l8n=a8n,Ize="er",c8n=W(t=>/^\s*erDiagram/.test(t),"detector"),u8n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./erDiagram-Q2GNP2WA-DuReqla0.js");return{diagram:e}},__vite__mapDeps([116,113,114,115]));return{id:Ize,diagram:t}},"loader"),d8n={id:Ize,detector:c8n,loader:u8n},f8n=d8n,Dze="gitGraph",h8n=W(t=>/^\s*gitGraph/.test(t),"detector"),p8n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./gitGraphDiagram-V2S2FVAM-7rU4MgM6.js");return{diagram:e}},__vite__mapDeps([117,118,119,120,103,105,106]));return{id:Dze,diagram:t}},"loader"),m8n={id:Dze,detector:h8n,loader:p8n},g8n=m8n,zze="gantt",v8n=W(t=>/^\s*gantt/.test(t),"detector"),b8n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./ganttDiagram-JELNMOA3-BeBP4O51.js");return{diagram:e}},[]);return{id:zze,diagram:t}},"loader"),_8n={id:zze,detector:v8n,loader:b8n},x8n=_8n,$ze="info",y8n=W(t=>/^\s*info/.test(t),"detector"),w8n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./infoDiagram-HS3SLOUP-BOjyAfYW.js");return{diagram:e}},__vite__mapDeps([121,120,103,105,106]));return{id:$ze,diagram:t}},"loader"),k8n={id:$ze,detector:y8n,loader:w8n},Bze="pie",O8n=W(t=>/^\s*pie/.test(t),"detector"),S8n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./pieDiagram-ADFJNKIX-D07iYAxA.js");return{diagram:e}},__vite__mapDeps([122,118,120,103,105,106,123]));return{id:Bze,diagram:t}},"loader"),C8n={id:Bze,detector:O8n,loader:S8n},Hze="quadrantChart",A8n=W(t=>/^\s*quadrantChart/.test(t),"detector"),E8n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./quadrantDiagram-AYHSOK5B-B9imU2k-.js");return{diagram:e}},[]);return{id:Hze,diagram:t}},"loader"),T8n={id:Hze,detector:A8n,loader:E8n},M8n=T8n,Fze="xychart",P8n=W(t=>/^\s*xychart(-beta)?/.test(t),"detector"),j8n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./xychartDiagram-PRI3JC2R-CShK1tn5.js");return{diagram:e}},[]);return{id:Fze,diagram:t}},"loader"),N8n={id:Fze,detector:P8n,loader:j8n},R8n=N8n,qze="requirement",L8n=W(t=>/^\s*requirement(Diagram)?/.test(t),"detector"),I8n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./requirementDiagram-UZGBJVZJ-CMH8dVSi.js");return{diagram:e}},__vite__mapDeps([124,113,114]));return{id:qze,diagram:t}},"loader"),D8n={id:qze,detector:L8n,loader:I8n},z8n=D8n,Vze="sequence",$8n=W(t=>/^\s*sequenceDiagram/.test(t),"detector"),B8n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./sequenceDiagram-WL72ISMW-BcDiQ1t6.js");return{diagram:e}},__vite__mapDeps([125,110,119]));return{id:Vze,diagram:t}},"loader"),H8n={id:Vze,detector:$8n,loader:B8n},F8n=H8n,Qze="class",q8n=W((t,e)=>e?.class?.defaultRenderer==="dagre-wrapper"?!1:/^\s*classDiagram/.test(t),"detector"),V8n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./classDiagram-2ON5EDUG-Bkz5oJ-y.js");return{diagram:e}},__vite__mapDeps([126,127,112,113,114]));return{id:Qze,diagram:t}},"loader"),Q8n={id:Qze,detector:q8n,loader:V8n},U8n=Q8n,Uze="classDiagram",W8n=W((t,e)=>/^\s*classDiagram/.test(t)&&e?.class?.defaultRenderer==="dagre-wrapper"?!0:/^\s*classDiagram-v2/.test(t),"detector"),Z8n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./classDiagram-v2-WZHVMYZB-Bkz5oJ-y.js");return{diagram:e}},__vite__mapDeps([128,127,112,113,114]));return{id:Uze,diagram:t}},"loader"),G8n={id:Uze,detector:W8n,loader:Z8n},Y8n=G8n,Wze="state",X8n=W((t,e)=>e?.state?.defaultRenderer==="dagre-wrapper"?!1:/^\s*stateDiagram/.test(t),"detector"),K8n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./stateDiagram-FKZM4ZOC-Be7DSpGK.js");return{diagram:e}},__vite__mapDeps([129,130,113,114,102,103,104,105]));return{id:Wze,diagram:t}},"loader"),J8n={id:Wze,detector:X8n,loader:K8n},e7n=J8n,Zze="stateDiagram",t7n=W((t,e)=>!!(/^\s*stateDiagram-v2/.test(t)||/^\s*stateDiagram/.test(t)&&e?.state?.defaultRenderer==="dagre-wrapper"),"detector"),n7n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./stateDiagram-v2-4FDKWEC3-CSGrJZGI.js");return{diagram:e}},__vite__mapDeps([131,130,113,114]));return{id:Zze,diagram:t}},"loader"),r7n={id:Zze,detector:t7n,loader:n7n},o7n=r7n,Gze="journey",i7n=W(t=>/^\s*journey/.test(t),"detector"),s7n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./journeyDiagram-XKPGCS4Q-daUwYLfO.js");return{diagram:e}},__vite__mapDeps([132,110,112,123]));return{id:Gze,diagram:t}},"loader"),a7n={id:Gze,detector:i7n,loader:s7n},l7n=a7n,c7n=W((t,e,n)=>{ut.debug(`rendering svg for syntax error
873
+ `);const r=qhn(e),o=r.append("g");r.attr("viewBox","0 0 2412 512"),Wje(r,100,512,!0),o.append("path").attr("class","error-icon").attr("d","m411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z"),o.append("path").attr("class","error-icon").attr("d","m459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z"),o.append("path").attr("class","error-icon").attr("d","m340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z"),o.append("path").attr("class","error-icon").attr("d","m400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z"),o.append("path").attr("class","error-icon").attr("d","m496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z"),o.append("path").attr("class","error-icon").attr("d","m436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z"),o.append("text").attr("class","error-text").attr("x",1440).attr("y",250).attr("font-size","150px").style("text-anchor","middle").text("Syntax error in text"),o.append("text").attr("class","error-text").attr("x",1250).attr("y",400).attr("font-size","100px").style("text-anchor","middle").text(`mermaid version ${n}`)},"draw"),Yze={draw:c7n},u7n=Yze,d7n={db:{},renderer:Yze,parser:{parse:W(()=>{},"parse")}},f7n=d7n,Xze="flowchart-elk",h7n=W((t,e={})=>/^\s*flowchart-elk/.test(t)||/^\s*(flowchart|graph)/.test(t)&&e?.flowchart?.defaultRenderer==="elk"?(e.layout="elk",!0):!1,"detector"),p7n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./flowDiagram-NV44I4VS-BzbJhnQR.js");return{diagram:e}},__vite__mapDeps([111,112,113,114,115]));return{id:Xze,diagram:t}},"loader"),m7n={id:Xze,detector:h7n,loader:p7n},g7n=m7n,Kze="timeline",v7n=W(t=>/^\s*timeline/.test(t),"detector"),b7n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./timeline-definition-IT6M3QCI-BwTGYKzr.js");return{diagram:e}},__vite__mapDeps([133,123]));return{id:Kze,diagram:t}},"loader"),_7n={id:Kze,detector:v7n,loader:b7n},x7n=_7n,Jze="mindmap",y7n=W(t=>/^\s*mindmap/.test(t),"detector"),w7n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./mindmap-definition-VGOIOE7T-D17_XGFA.js");return{diagram:e}},__vite__mapDeps([134,113,114]));return{id:Jze,diagram:t}},"loader"),k7n={id:Jze,detector:y7n,loader:w7n},O7n=k7n,e$e="kanban",S7n=W(t=>/^\s*kanban/.test(t),"detector"),C7n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./kanban-definition-3W4ZIXB7-Dkcl1vfA.js");return{diagram:e}},__vite__mapDeps([135,112]));return{id:e$e,diagram:t}},"loader"),A7n={id:e$e,detector:S7n,loader:C7n},E7n=A7n,t$e="sankey",T7n=W(t=>/^\s*sankey(-beta)?/.test(t),"detector"),M7n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./sankeyDiagram-TZEHDZUN-CWS08bde.js");return{diagram:e}},[]);return{id:t$e,diagram:t}},"loader"),P7n={id:t$e,detector:T7n,loader:M7n},j7n=P7n,n$e="packet",N7n=W(t=>/^\s*packet(-beta)?/.test(t),"detector"),R7n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./diagram-S2PKOQOG-CU2nF5Pi.js");return{diagram:e}},__vite__mapDeps([136,118,120,103,105,106]));return{id:n$e,diagram:t}},"loader"),L7n={id:n$e,detector:N7n,loader:R7n},r$e="radar",I7n=W(t=>/^\s*radar-beta/.test(t),"detector"),D7n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./diagram-QEK2KX5R-ByPoixdO.js");return{diagram:e}},__vite__mapDeps([137,118,120,103,105,106]));return{id:r$e,diagram:t}},"loader"),z7n={id:r$e,detector:I7n,loader:D7n},o$e="block",$7n=W(t=>/^\s*block(-beta)?/.test(t),"detector"),B7n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./blockDiagram-VD42YOAC-DZYGOHoq.js");return{diagram:e}},__vite__mapDeps([138,112,106,103,102,115]));return{id:o$e,diagram:t}},"loader"),H7n={id:o$e,detector:$7n,loader:B7n},F7n=H7n,i$e="architecture",q7n=W(t=>/^\s*architecture/.test(t),"detector"),V7n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./architectureDiagram-VXUJARFQ-BkG8VmpL.js");return{diagram:e}},__vite__mapDeps([139,118,120,103,105,106,108]));return{id:i$e,diagram:t}},"loader"),Q7n={id:i$e,detector:q7n,loader:V7n},U7n=Q7n,s$e="treemap",W7n=W(t=>/^\s*treemap/.test(t),"detector"),Z7n=W(async()=>{const{diagram:t}=await re(async()=>{const{diagram:e}=await import("./diagram-PSM6KHXK-_VfU4I5J.js");return{diagram:e}},__vite__mapDeps([140,114,118,120,103,105,106]));return{id:s$e,diagram:t}},"loader"),G7n={id:s$e,detector:W7n,loader:Z7n},Ghe=!1,Vj=W(()=>{Ghe||(Ghe=!0,KA("error",f7n,t=>t.toLowerCase().trim()==="error"),KA("---",{db:{clear:W(()=>{},"clear")},styles:{},renderer:{draw:W(()=>{},"draw")},parser:{parse:W(()=>{throw new Error("Diagrams beginning with --- are not valid. If you were trying to use a YAML front-matter, please ensure that you've correctly opened and closed the YAML front-matter with un-indented `---` blocks")},"parse")},init:W(()=>null,"init")},t=>t.toLowerCase().trimStart().startsWith("---")),LV(g7n,O7n,U7n),LV(e8n,E7n,Y8n,U8n,f8n,x8n,k8n,C8n,z8n,F8n,l8n,o8n,x7n,g8n,o7n,e7n,l7n,M8n,j7n,L7n,R8n,F7n,z7n,G7n))},"addDiagrams"),Y7n=W(async()=>{ut.debug("Loading registered diagrams");const e=(await Promise.allSettled(Object.entries(G3).map(async([n,{detector:r,loader:o}])=>{if(o)try{$V(n)}catch{try{const{diagram:i,id:s}=await o();KA(s,i,r)}catch(i){throw ut.error(`Failed to load external diagram with key ${n}. Removing from detectors.`),delete G3[n],i}}}))).filter(n=>n.status==="rejected");if(e.length>0){ut.error(`Failed to load ${e.length} external diagrams`);for(const n of e)ut.error(n);throw new Error(`Failed to load ${e.length} external diagrams`)}},"loadRegisteredDiagrams"),X7n="graphics-document document";function a$e(t,e){t.attr("role",X7n),e!==""&&t.attr("aria-roledescription",e)}W(a$e,"setA11yDiagramInfo");function l$e(t,e,n,r){if(t.insert!==void 0){if(n){const o=`chart-desc-${r}`;t.attr("aria-describedby",o),t.insert("desc",":first-child").attr("id",o).text(n)}if(e){const o=`chart-title-${r}`;t.attr("aria-labelledby",o),t.insert("title",":first-child").attr("id",o).text(e)}}}W(l$e,"addSVGa11yTitleDescription");var S3,LQ=(S3=class{constructor(e,n,r,o,i){this.type=e,this.text=n,this.db=r,this.parser=o,this.renderer=i}static async fromText(e,n={}){const r=da(),o=jK(e,r);e=Gmn(e)+`
874
874
  `;try{$V(o)}catch{const c=f0n(o);if(!c)throw new Lje(`Diagram ${o} not found.`);const{id:u,diagram:d}=await c();KA(u,d)}const{db:i,parser:s,renderer:a,init:l}=$V(o);return s.parser&&(s.parser.yy=i),i.clear?.(),l?.(r),n.title&&i.setDiagramTitle?.(n.title),await s.parse(e),new S3(o,e,i,s,a)}async render(e,n){await this.renderer.draw(this.text,e,n,this)}getParser(){return this.parser}getType(){return this.type}},W(S3,"Diagram"),S3),Yhe=[],K7n=W(()=>{Yhe.forEach(t=>{t()}),Yhe=[]},"attachFunctions"),J7n=W(t=>t.replace(/^\s*%%(?!{)[^\n]+\n?/gm,"").trimStart(),"cleanupComments");function c$e(t){const e=t.match(Rje);if(!e)return{text:t,metadata:{}};let n=Ypn(e[1],{schema:Gpn})??{};n=typeof n=="object"&&!Array.isArray(n)?n:{};const r={};return n.displayMode&&(r.displayMode=n.displayMode.toString()),n.title&&(r.title=n.title.toString()),n.config&&(r.config=n.config),{text:t.slice(e[0].length),metadata:r}}W(c$e,"extractFrontMatter");var evn=W(t=>t.replace(/\r\n?/g,`
875
875
  `).replace(/<(\w+)([^>]*)>/g,(e,n,r)=>"<"+n+r.replace(/="([^"]*)"/g,"='$1'")+">"),"cleanupText"),tvn=W(t=>{const{text:e,metadata:n}=c$e(t),{displayMode:r,title:o,config:i={}}=n;return r&&(i.gantt||(i.gantt={}),i.gantt.displayMode=r),{title:o,config:i,text:e}},"processFrontmatter"),nvn=W(t=>{const e=A0.detectInit(t)??{},n=A0.detectDirective(t,"wrap");return Array.isArray(n)?e.wrap=n.some(({type:r})=>r==="wrap"):n?.type==="wrap"&&(e.wrap=!0),{text:Imn(t),directive:e}},"processDirectives");function aee(t){const e=evn(t),n=tvn(e),r=nvn(n.text),o=VJ(n.config,r.directive);return t=J7n(r.text),{code:t,title:n.title,config:o}}W(aee,"preprocessDiagram");function u$e(t){const e=new TextEncoder().encode(t),n=Array.from(e,r=>String.fromCodePoint(r)).join("");return btoa(n)}W(u$e,"toBase64");var rvn=5e4,ovn="graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa",ivn="sandbox",svn="loose",avn="http://www.w3.org/2000/svg",lvn="http://www.w3.org/1999/xlink",cvn="http://www.w3.org/1999/xhtml",uvn="100%",dvn="100%",fvn="border:0;margin:0;",hvn="margin:0",pvn="allow-top-navigation-by-user-activation allow-popups",mvn='The "iframe" tag is not supported by your browser.',gvn=["foreignobject"],vvn=["dominant-baseline"];function lee(t){const e=aee(t);return YA(),E0n(e.config??{}),e}W(lee,"processAndSetConfigs");async function d$e(t,e){Vj();try{const{code:n,config:r}=lee(t);return{diagramType:(await h$e(n)).type,config:r}}catch(n){if(e?.suppressErrors)return!1;throw n}}W(d$e,"parse");var Xhe=W((t,e,n=[])=>`
876
876
  .${t} ${e} { ${n.join(" !important; ")} !important; }`,"cssImportantStyles"),bvn=W((t,e=new Map)=>{let n="";if(t.themeCSS!==void 0&&(n+=`
@@ -882,7 +882,7 @@ ${t.themeCSS}`),t.fontFamily!==void 0&&(n+=`
882
882
  To pick up a draggable item, press the space bar.
883
883
  While dragging, use the arrow keys to move the item.
884
884
  Press space again to drop the item in its new position, or press escape to cancel.
885
- `},V9n={onDragStart(t){let{active:e}=t;return"Picked up draggable item "+e.id+"."},onDragOver(t){let{active:e,over:n}=t;return n?"Draggable item "+e.id+" was moved over droppable area "+n.id+".":"Draggable item "+e.id+" is no longer over a droppable area."},onDragEnd(t){let{active:e,over:n}=t;return n?"Draggable item "+e.id+" was dropped over droppable area "+n.id:"Draggable item "+e.id+" was dropped."},onDragCancel(t){let{active:e}=t;return"Dragging was cancelled. Draggable item "+e.id+" was dropped."}};function Q9n(t){let{announcements:e=V9n,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=q9n}=t;const{announce:i,announcement:s}=B9n(),a=Qx("DndLiveRegion"),[l,c]=v.useState(!1);if(v.useEffect(()=>{c(!0)},[]),H9n(v.useMemo(()=>({onDragStart(d){let{active:h}=d;i(e.onDragStart({active:h}))},onDragMove(d){let{active:h,over:p}=d;e.onDragMove&&i(e.onDragMove({active:h,over:p}))},onDragOver(d){let{active:h,over:p}=d;i(e.onDragOver({active:h,over:p}))},onDragEnd(d){let{active:h,over:p}=d;i(e.onDragEnd({active:h,over:p}))},onDragCancel(d){let{active:h,over:p}=d;i(e.onDragCancel({active:h,over:p}))}}),[i,e])),!l)return null;const u=Bt.createElement(Bt.Fragment,null,Bt.createElement(z9n,{id:r,value:o.draggable}),Bt.createElement($9n,{id:a,announcement:s}));return n?Bs.createPortal(u,n):u}var Qi;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(Qi||(Qi={}));function FE(){}function Gf(t,e){return v.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function Zj(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return v.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const Q0=Object.freeze({x:0,y:0});function pee(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function U9n(t,e){const n=HE(t);if(!n)return"0 0";const r={x:(n.x-e.left)/e.width*100,y:(n.y-e.top)/e.height*100};return r.x+"% "+r.y+"%"}function mee(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function W9n(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function BQ(t){let{left:e,top:n,height:r,width:o}=t;return[{x:e,y:n},{x:e+o,y:n},{x:e,y:n+r},{x:e+o,y:n+r}]}function L$e(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function spe(t,e,n){return e===void 0&&(e=t.left),n===void 0&&(n=t.top),{x:e+t.width*.5,y:n+t.height*.5}}const qE=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const o=spe(e,e.left,e.top),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=pee(spe(l),o);i.push({id:a,data:{droppableContainer:s,value:c}})}}return i.sort(mee)},Z9n=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const o=BQ(e),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=BQ(l),u=o.reduce((h,p,g)=>h+pee(c[g],p),0),d=Number((u/4).toFixed(4));i.push({id:a,data:{droppableContainer:s,value:d}})}}return i.sort(mee)};function G9n(t,e){const n=Math.max(e.top,t.top),r=Math.max(e.left,t.left),o=Math.min(e.left+e.width,t.left+t.width),i=Math.min(e.top+e.height,t.top+t.height),s=o-r,a=i-n;if(r<o&&n<i){const l=e.width*e.height,c=t.width*t.height,u=s*a,d=u/(l+c-u);return Number(d.toFixed(4))}return 0}const Y9n=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const o=[];for(const i of r){const{id:s}=i,a=n.get(s);if(a){const l=G9n(a,e);l>0&&o.push({id:s,data:{droppableContainer:i,value:l}})}}return o.sort(W9n)};function X9n(t,e){const{top:n,left:r,bottom:o,right:i}=e;return n<=t.y&&t.y<=o&&r<=t.x&&t.x<=i}const K9n=t=>{let{droppableContainers:e,droppableRects:n,pointerCoordinates:r}=t;if(!r)return[];const o=[];for(const i of e){const{id:s}=i,a=n.get(s);if(a&&X9n(r,a)){const c=BQ(a).reduce((d,h)=>d+pee(r,h),0),u=Number((c/4).toFixed(4));o.push({id:s,data:{droppableContainer:i,value:u}})}}return o.sort(mee)};function J9n(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function I$e(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:Q0}function ebn(t){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return o.reduce((s,a)=>({...s,top:s.top+t*a.y,bottom:s.bottom+t*a.y,left:s.left+t*a.x,right:s.right+t*a.x}),{...n})}}const tbn=ebn(1);function D$e(t){if(t.startsWith("matrix3d(")){const e=t.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(t.startsWith("matrix(")){const e=t.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function nbn(t,e,n){const r=D$e(e);if(!r)return t;const{scaleX:o,scaleY:i,x:s,y:a}=r,l=t.left-s-(1-o)*parseFloat(n),c=t.top-a-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),u=o?t.width/o:t.width,d=i?t.height/i:t.height;return{width:u,height:d,top:c,right:l+u,bottom:c+d,left:l}}const rbn={ignoreTransform:!1};function p8(t,e){e===void 0&&(e=rbn);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:c,transformOrigin:u}=Xa(t).getComputedStyle(t);c&&(n=nbn(n,c,u))}const{top:r,left:o,width:i,height:s,bottom:a,right:l}=n;return{top:r,left:o,width:i,height:s,bottom:a,right:l}}function ape(t){return p8(t,{ignoreTransform:!0})}function obn(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function ibn(t,e){return e===void 0&&(e=Xa(t).getComputedStyle(t)),e.position==="fixed"}function sbn(t,e){e===void 0&&(e=Xa(t).getComputedStyle(t));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const i=e[o];return typeof i=="string"?n.test(i):!1})}function Gj(t,e){const n=[];function r(o){if(e!=null&&n.length>=e||!o)return n;if(hee(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!qx(o)||j$e(o)||n.includes(o))return n;const i=Xa(t).getComputedStyle(o);return o!==t&&sbn(o,i)&&n.push(o),ibn(o,i)?n:r(o.parentNode)}return t?r(t):n}function z$e(t){const[e]=Gj(t,1);return e??null}function x$(t){return!Qj||!t?null:f8(t)?t:fee(t)?hee(t)||t===h8(t).scrollingElement?window:qx(t)?t:null:null}function $$e(t){return f8(t)?t.scrollX:t.scrollLeft}function B$e(t){return f8(t)?t.scrollY:t.scrollTop}function HQ(t){return{x:$$e(t),y:B$e(t)}}var fs;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(fs||(fs={}));function H$e(t){return!Qj||!t?!1:t===document.scrollingElement}function F$e(t){const e={x:0,y:0},n=H$e(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},r={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height},o=t.scrollTop<=e.y,i=t.scrollLeft<=e.x,s=t.scrollTop>=r.y,a=t.scrollLeft>=r.x;return{isTop:o,isLeft:i,isBottom:s,isRight:a,maxScroll:r,minScroll:e}}const abn={x:.2,y:.2};function lbn(t,e,n,r,o){let{top:i,left:s,right:a,bottom:l}=n;r===void 0&&(r=10),o===void 0&&(o=abn);const{isTop:c,isBottom:u,isLeft:d,isRight:h}=F$e(t),p={x:0,y:0},g={x:0,y:0},_={height:e.height*o.y,width:e.width*o.x};return!c&&i<=e.top+_.height?(p.y=fs.Backward,g.y=r*Math.abs((e.top+_.height-i)/_.height)):!u&&l>=e.bottom-_.height&&(p.y=fs.Forward,g.y=r*Math.abs((e.bottom-_.height-l)/_.height)),!h&&a>=e.right-_.width?(p.x=fs.Forward,g.x=r*Math.abs((e.right-_.width-a)/_.width)):!d&&s<=e.left+_.width&&(p.x=fs.Backward,g.x=r*Math.abs((e.left+_.width-s)/_.width)),{direction:p,speed:g}}function cbn(t){if(t===document.scrollingElement){const{innerWidth:i,innerHeight:s}=window;return{top:0,left:0,right:i,bottom:s,width:i,height:s}}const{top:e,left:n,right:r,bottom:o}=t.getBoundingClientRect();return{top:e,left:n,right:r,bottom:o,width:t.clientWidth,height:t.clientHeight}}function q$e(t){return t.reduce((e,n)=>p6(e,HQ(n)),Q0)}function ubn(t){return t.reduce((e,n)=>e+$$e(n),0)}function dbn(t){return t.reduce((e,n)=>e+B$e(n),0)}function V$e(t,e){if(e===void 0&&(e=p8),!t)return;const{top:n,left:r,bottom:o,right:i}=e(t);z$e(t)&&(o<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const fbn=[["x",["left","right"],ubn],["y",["top","bottom"],dbn]];class gee{constructor(e,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=Gj(n),o=q$e(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[i,s,a]of fbn)for(const l of s)Object.defineProperty(this,l,{get:()=>{const c=a(r),u=o[i]-c;return this.rect[l]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class U9{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=e}add(e,n,r){var o;(o=this.target)==null||o.addEventListener(e,n,r),this.listeners.push([e,n,r])}}function hbn(t){const{EventTarget:e}=Xa(t);return t instanceof e?t:h8(t)}function y$(t,e){const n=Math.abs(t.x),r=Math.abs(t.y);return typeof e=="number"?Math.sqrt(n**2+r**2)>e:"x"in e&&"y"in e?n>e.x&&r>e.y:"x"in e?n>e.x:"y"in e?r>e.y:!1}var Sc;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Sc||(Sc={}));function lpe(t){t.preventDefault()}function pbn(t){t.stopPropagation()}var Tr;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(Tr||(Tr={}));const Q$e={start:[Tr.Space,Tr.Enter],cancel:[Tr.Esc],end:[Tr.Space,Tr.Enter,Tr.Tab]},mbn=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case Tr.Right:return{...n,x:n.x+25};case Tr.Left:return{...n,x:n.x-25};case Tr.Down:return{...n,y:n.y+25};case Tr.Up:return{...n,y:n.y-25}}};class Yj{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:n}}=e;this.props=e,this.listeners=new U9(h8(n)),this.windowListeners=new U9(Xa(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Sc.Resize,this.handleCancel),this.windowListeners.add(Sc.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Sc.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&V$e(r),n(Q0)}handleKeyDown(e){if(Wj(e)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:i=Q$e,coordinateGetter:s=mbn,scrollBehavior:a="smooth"}=o,{code:l}=e;if(i.end.includes(l)){this.handleEnd(e);return}if(i.cancel.includes(l)){this.handleCancel(e);return}const{collisionRect:c}=r.current,u=c?{x:c.left,y:c.top}:Q0;this.referenceCoordinates||(this.referenceCoordinates=u);const d=s(e,{active:n,context:r.current,currentCoordinates:u});if(d){const h=v_(d,u),p={x:0,y:0},{scrollableAncestors:g}=r.current;for(const _ of g){const x=e.code,{isTop:y,isRight:k,isLeft:O,isBottom:C,maxScroll:A,minScroll:E}=F$e(_),M=cbn(_),P={x:Math.min(x===Tr.Right?M.right-M.width/2:M.right,Math.max(x===Tr.Right?M.left:M.left+M.width/2,d.x)),y:Math.min(x===Tr.Down?M.bottom-M.height/2:M.bottom,Math.max(x===Tr.Down?M.top:M.top+M.height/2,d.y))},L=x===Tr.Right&&!k||x===Tr.Left&&!O,D=x===Tr.Down&&!C||x===Tr.Up&&!y;if(L&&P.x!==d.x){const I=_.scrollLeft+h.x,z=x===Tr.Right&&I<=A.x||x===Tr.Left&&I>=E.x;if(z&&!h.y){_.scrollTo({left:I,behavior:a});return}z?p.x=_.scrollLeft-I:p.x=x===Tr.Right?_.scrollLeft-A.x:_.scrollLeft-E.x,p.x&&_.scrollBy({left:-p.x,behavior:a});break}else if(D&&P.y!==d.y){const I=_.scrollTop+h.y,z=x===Tr.Down&&I<=A.y||x===Tr.Up&&I>=E.y;if(z&&!h.x){_.scrollTo({top:I,behavior:a});return}z?p.y=_.scrollTop-I:p.y=x===Tr.Down?_.scrollTop-A.y:_.scrollTop-E.y,p.y&&_.scrollBy({top:-p.y,behavior:a});break}}this.handleMove(e,p6(v_(d,this.referenceCoordinates),p))}}}handleMove(e,n){const{onMove:r}=this.props;e.preventDefault(),r(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Yj.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=Q$e,onActivation:o}=e,{active:i}=n;const{code:s}=t.nativeEvent;if(r.start.includes(s)){const a=i.activatorNode.current;return a&&t.target!==a?!1:(t.preventDefault(),o?.({event:t.nativeEvent}),!0)}return!1}}];function cpe(t){return!!(t&&"distance"in t)}function upe(t){return!!(t&&"delay"in t)}class vee{constructor(e,n,r){var o;r===void 0&&(r=hbn(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=n;const{event:i}=e,{target:s}=i;this.props=e,this.events=n,this.document=h8(s),this.documentListeners=new U9(this.document),this.listeners=new U9(r),this.windowListeners=new U9(Xa(s)),this.initialCoordinates=(o=HE(i))!=null?o:Q0,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Sc.Resize,this.handleCancel),this.windowListeners.add(Sc.DragStart,lpe),this.windowListeners.add(Sc.VisibilityChange,this.handleCancel),this.windowListeners.add(Sc.ContextMenu,lpe),this.documentListeners.add(Sc.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(upe(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(cpe(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,n){const{active:r,onPending:o}=this.props;o(r,e,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:e}=this,{onStart:n}=this.props;e&&(this.activated=!0,this.documentListeners.add(Sc.Click,pbn,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Sc.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:o,props:i}=this,{onMove:s,options:{activationConstraint:a}}=i;if(!o)return;const l=(n=HE(e))!=null?n:Q0,c=v_(o,l);if(!r&&a){if(cpe(a)){if(a.tolerance!=null&&y$(c,a.tolerance))return this.handleCancel();if(y$(c,a.distance))return this.handleStart()}if(upe(a)&&y$(c,a.tolerance))return this.handleCancel();this.handlePending(a,c);return}e.cancelable&&e.preventDefault(),s(l)}handleEnd(){const{onAbort:e,onEnd:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleCancel(){const{onAbort:e,onCancel:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleKeydown(e){e.code===Tr.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const gbn={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class bee extends vee{constructor(e){const{event:n}=e,r=h8(n.target);super(e,gbn,r)}}bee.activators=[{eventName:"onPointerDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const vbn={move:{name:"mousemove"},end:{name:"mouseup"}};var FQ;(function(t){t[t.RightClick=2]="RightClick"})(FQ||(FQ={}));class Xj extends vee{constructor(e){super(e,vbn,h8(e.event.target))}}Xj.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===FQ.RightClick?!1:(r?.({event:n}),!0)}}];const w$={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class _ee extends vee{constructor(e){super(e,w$)}static setup(){return window.addEventListener(w$.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(w$.move.name,e)};function e(){}}}_ee.activators=[{eventName:"onTouchStart",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;const{touches:o}=n;return o.length>1?!1:(r?.({event:n}),!0)}}];var W9;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(W9||(W9={}));var VE;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(VE||(VE={}));function bbn(t){let{acceleration:e,activator:n=W9.Pointer,canScroll:r,draggingRect:o,enabled:i,interval:s=5,order:a=VE.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:u,delta:d,threshold:h}=t;const p=xbn({delta:d,disabled:!i}),[g,_]=N9n(),x=v.useRef({x:0,y:0}),y=v.useRef({x:0,y:0}),k=v.useMemo(()=>{switch(n){case W9.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case W9.DraggableRect:return o}},[n,o,l]),O=v.useRef(null),C=v.useCallback(()=>{const E=O.current;if(!E)return;const M=x.current.x*y.current.x,P=x.current.y*y.current.y;E.scrollBy(M,P)},[]),A=v.useMemo(()=>a===VE.TreeOrder?[...c].reverse():c,[a,c]);v.useEffect(()=>{if(!i||!c.length||!k){_();return}for(const E of A){if(r?.(E)===!1)continue;const M=c.indexOf(E),P=u[M];if(!P)continue;const{direction:L,speed:D}=lbn(E,P,k,e,h);for(const I of["x","y"])p[I][L[I]]||(D[I]=0,L[I]=0);if(D.x>0||D.y>0){_(),O.current=E,g(C,s),x.current=D,y.current=L;return}}x.current={x:0,y:0},y.current={x:0,y:0},_()},[e,C,r,_,i,s,JSON.stringify(k),JSON.stringify(p),g,c,A,u,JSON.stringify(h)])}const _bn={x:{[fs.Backward]:!1,[fs.Forward]:!1},y:{[fs.Backward]:!1,[fs.Forward]:!1}};function xbn(t){let{delta:e,disabled:n}=t;const r=BE(e);return Vx(o=>{if(n||!r||!o)return _bn;const i={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[fs.Backward]:o.x[fs.Backward]||i.x===-1,[fs.Forward]:o.x[fs.Forward]||i.x===1},y:{[fs.Backward]:o.y[fs.Backward]||i.y===-1,[fs.Forward]:o.y[fs.Forward]||i.y===1}}},[n,e,r])}function ybn(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return Vx(o=>{var i;return e==null?null:(i=r??o)!=null?i:null},[r,e])}function wbn(t,e){return v.useMemo(()=>t.reduce((n,r)=>{const{sensor:o}=r,i=o.activators.map(s=>({eventName:s.eventName,handler:e(s.handler,r)}));return[...n,...i]},[]),[t,e])}var b_;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(b_||(b_={}));var qQ;(function(t){t.Optimized="optimized"})(qQ||(qQ={}));const dpe=new Map;function kbn(t,e){let{dragging:n,dependencies:r,config:o}=e;const[i,s]=v.useState(null),{frequency:a,measure:l,strategy:c}=o,u=v.useRef(t),d=x(),h=g_(d),p=v.useCallback(function(y){y===void 0&&(y=[]),!h.current&&s(k=>k===null?y:k.concat(y.filter(O=>!k.includes(O))))},[h]),g=v.useRef(null),_=Vx(y=>{if(d&&!n)return dpe;if(!y||y===dpe||u.current!==t||i!=null){const k=new Map;for(let O of t){if(!O)continue;if(i&&i.length>0&&!i.includes(O.id)&&O.rect.current){k.set(O.id,O.rect.current);continue}const C=O.node.current,A=C?new gee(l(C),C):null;O.rect.current=A,A&&k.set(O.id,A)}return k}return y},[t,i,n,d,l]);return v.useEffect(()=>{u.current=t},[t]),v.useEffect(()=>{d||p()},[n,d]),v.useEffect(()=>{i&&i.length>0&&s(null)},[JSON.stringify(i)]),v.useEffect(()=>{d||typeof a!="number"||g.current!==null||(g.current=setTimeout(()=>{p(),g.current=null},a))},[a,d,p,...r]),{droppableRects:_,measureDroppableContainers:p,measuringScheduled:i!=null};function x(){switch(c){case b_.Always:return!1;case b_.BeforeDragging:return n;default:return!n}}}function xee(t,e){return Vx(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function Obn(t,e){return xee(t,e)}function Sbn(t){let{callback:e,disabled:n}=t;const r=Uj(e),o=v.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:i}=window;return new i(r)},[r,n]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function Kj(t){let{callback:e,disabled:n}=t;const r=Uj(e),o=v.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:i}=window;return new i(r)},[n]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function Cbn(t){return new gee(p8(t),t)}function fpe(t,e,n){e===void 0&&(e=Cbn);const[r,o]=v.useState(null);function i(){o(l=>{if(!t)return null;if(t.isConnected===!1){var c;return(c=l??n)!=null?c:null}const u=e(t);return JSON.stringify(l)===JSON.stringify(u)?l:u})}const s=Sbn({callback(l){if(t)for(const c of l){const{type:u,target:d}=c;if(u==="childList"&&d instanceof HTMLElement&&d.contains(t)){i();break}}}}),a=Kj({callback:i});return V0(()=>{i(),t?(a?.observe(t),s?.observe(document.body,{childList:!0,subtree:!0})):(a?.disconnect(),s?.disconnect())},[t]),r}function Abn(t){const e=xee(t);return I$e(t,e)}const hpe=[];function Ebn(t){const e=v.useRef(t),n=Vx(r=>t?r&&r!==hpe&&t&&e.current&&t.parentNode===e.current.parentNode?r:Gj(t):hpe,[t]);return v.useEffect(()=>{e.current=t},[t]),n}function Tbn(t){const[e,n]=v.useState(null),r=v.useRef(t),o=v.useCallback(i=>{const s=x$(i.target);s&&n(a=>a?(a.set(s,HQ(s)),new Map(a)):null)},[]);return v.useEffect(()=>{const i=r.current;if(t!==i){s(i);const a=t.map(l=>{const c=x$(l);return c?(c.addEventListener("scroll",o,{passive:!0}),[c,HQ(c)]):null}).filter(l=>l!=null);n(a.length?new Map(a):null),r.current=t}return()=>{s(t),s(i)};function s(a){a.forEach(l=>{const c=x$(l);c?.removeEventListener("scroll",o)})}},[o,t]),v.useMemo(()=>t.length?e?Array.from(e.values()).reduce((i,s)=>p6(i,s),Q0):q$e(t):Q0,[t,e])}function ppe(t,e){e===void 0&&(e=[]);const n=v.useRef(null);return v.useEffect(()=>{n.current=null},e),v.useEffect(()=>{const r=t!==Q0;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?v_(t,n.current):Q0}function Mbn(t){v.useEffect(()=>{if(!Qj)return;const e=t.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of e)n?.()}},t.map(e=>{let{sensor:n}=e;return n}))}function Pbn(t,e){return v.useMemo(()=>t.reduce((n,r)=>{let{eventName:o,handler:i}=r;return n[o]=s=>{i(s,e)},n},{}),[t,e])}function U$e(t){return v.useMemo(()=>t?obn(t):null,[t])}const mpe=[];function jbn(t,e){e===void 0&&(e=p8);const[n]=t,r=U$e(n?Xa(n):null),[o,i]=v.useState(mpe);function s(){i(()=>t.length?t.map(l=>H$e(l)?r:new gee(e(l),l)):mpe)}const a=Kj({callback:s});return V0(()=>{a?.disconnect(),s(),t.forEach(l=>a?.observe(l))},[t]),o}function W$e(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return qx(e)?e:t}function Nbn(t){let{measure:e}=t;const[n,r]=v.useState(null),o=v.useCallback(c=>{for(const{target:u}of c)if(qx(u)){r(d=>{const h=e(u);return d?{...d,width:h.width,height:h.height}:h});break}},[e]),i=Kj({callback:o}),s=v.useCallback(c=>{const u=W$e(c);i?.disconnect(),u&&i?.observe(u),r(u?e(u):null)},[e,i]),[a,l]=$E(s);return v.useMemo(()=>({nodeRef:a,rect:n,setRef:l}),[n,a,l])}const Rbn=[{sensor:bee,options:{}},{sensor:Yj,options:{}}],Lbn={current:{}},$S={draggable:{measure:ape},droppable:{measure:ape,strategy:b_.WhileDragging,frequency:qQ.Optimized},dragOverlay:{measure:p8}};class Z9 extends Map{get(e){var n;return e!=null&&(n=super.get(e))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:n}=e;return!n})}getNodeFor(e){var n,r;return(n=(r=this.get(e))==null?void 0:r.node.current)!=null?n:void 0}}const Ibn={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Z9,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:FE},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:$S,measureDroppableContainers:FE,windowRect:null,measuringScheduled:!1},Z$e={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:FE,draggableNodes:new Map,over:null,measureDroppableContainers:FE},Ux=v.createContext(Z$e),G$e=v.createContext(Ibn);function Dbn(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Z9}}}function zbn(t,e){switch(e.type){case Qi.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case Qi.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case Qi.DragEnd:case Qi.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Qi.RegisterDroppable:{const{element:n}=e,{id:r}=n,o=new Z9(t.droppable.containers);return o.set(r,n),{...t,droppable:{...t.droppable,containers:o}}}case Qi.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const s=new Z9(t.droppable.containers);return s.set(n,{...i,disabled:o}),{...t,droppable:{...t.droppable,containers:s}}}case Qi.UnregisterDroppable:{const{id:n,key:r}=e,o=t.droppable.containers.get(n);if(!o||r!==o.key)return t;const i=new Z9(t.droppable.containers);return i.delete(n),{...t,droppable:{...t.droppable,containers:i}}}default:return t}}function $bn(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:o}=v.useContext(Ux),i=BE(r),s=BE(n?.id);return v.useEffect(()=>{if(!e&&!r&&i&&s!=null){if(!Wj(i)||document.activeElement===i.target)return;const a=o.get(s);if(!a)return;const{activatorNode:l,node:c}=a;if(!l.current&&!c.current)return;requestAnimationFrame(()=>{for(const u of[l.current,c.current]){if(!u)continue;const d=I9n(u);if(d){d.focus();break}}})}},[r,e,o,s,i]),null}function Y$e(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((o,i)=>i({transform:o,...r}),n):n}function Bbn(t){return v.useMemo(()=>({draggable:{...$S.draggable,...t?.draggable},droppable:{...$S.droppable,...t?.droppable},dragOverlay:{...$S.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function Hbn(t){let{activeNode:e,measure:n,initialRect:r,config:o=!0}=t;const i=v.useRef(!1),{x:s,y:a}=typeof o=="boolean"?{x:o,y:o}:o;V0(()=>{if(!s&&!a||!e){i.current=!1;return}if(i.current||!r)return;const c=e?.node.current;if(!c||c.isConnected===!1)return;const u=n(c),d=I$e(u,r);if(s||(d.x=0),a||(d.y=0),i.current=!0,Math.abs(d.x)>0||Math.abs(d.y)>0){const h=z$e(c);h&&h.scrollBy({top:d.y,left:d.x})}},[e,s,a,r,n])}const Jj=v.createContext({...Q0,scaleX:1,scaleY:1});var _f;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(_f||(_f={}));const eN=v.memo(function(e){var n,r,o,i;let{id:s,accessibility:a,autoScroll:l=!0,children:c,sensors:u=Rbn,collisionDetection:d=Y9n,measuring:h,modifiers:p,...g}=e;const _=v.useReducer(zbn,void 0,Dbn),[x,y]=_,[k,O]=F9n(),[C,A]=v.useState(_f.Uninitialized),E=C===_f.Initialized,{draggable:{active:M,nodes:P,translate:L},droppable:{containers:D}}=x,I=M!=null?P.get(M):null,z=v.useRef({initial:null,translated:null}),Y=v.useMemo(()=>{var Ut;return M!=null?{id:M,data:(Ut=I?.data)!=null?Ut:Lbn,rect:z}:null},[M,I]),Q=v.useRef(null),[H,N]=v.useState(null),[V,G]=v.useState(null),K=g_(g,Object.values(g)),q=Qx("DndDescribedBy",s),Z=v.useMemo(()=>D.getEnabled(),[D]),U=Bbn(h),{droppableRects:B,measureDroppableContainers:ee,measuringScheduled:te}=kbn(Z,{dragging:E,dependencies:[L.x,L.y],config:U.droppable}),se=ybn(P,M),ae=v.useMemo(()=>V?HE(V):null,[V]),he=Dt(),fe=Obn(se,U.draggable.measure);Hbn({activeNode:M!=null?P.get(M):null,config:he.layoutShiftCompensation,initialRect:fe,measure:U.draggable.measure});const be=fpe(se,U.draggable.measure,fe),me=fpe(se?se.parentElement:null),le=v.useRef({activatorEvent:null,active:null,activeNode:se,collisionRect:null,collisions:null,droppableRects:B,draggableNodes:P,draggingNode:null,draggingNodeRect:null,droppableContainers:D,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Be=D.getNodeFor((n=le.current.over)==null?void 0:n.id),Xe=Nbn({measure:U.dragOverlay.measure}),ot=(r=Xe.nodeRef.current)!=null?r:se,Qe=E?(o=Xe.rect)!=null?o:be:null,lt=!!(Xe.nodeRef.current&&Xe.rect),bt=Abn(lt?null:be),ve=U$e(ot?Xa(ot):null),Te=Ebn(E?Be??se:null),pe=jbn(Te),Ne=Y$e(p,{transform:{x:L.x-bt.x,y:L.y-bt.y,scaleX:1,scaleY:1},activatorEvent:V,active:Y,activeNodeRect:be,containerNodeRect:me,draggingNodeRect:Qe,over:le.current.over,overlayNodeRect:Xe.rect,scrollableAncestors:Te,scrollableAncestorRects:pe,windowRect:ve}),$e=ae?p6(ae,L):null,De=Tbn(Te),ct=ppe(De),ue=ppe(De,[be]),Pe=p6(Ne,ct),Ee=Qe?tbn(Qe,Ne):null,Le=Y&&Ee?d({active:Y,collisionRect:Ee,droppableRects:B,droppableContainers:Z,pointerCoordinates:$e}):null,et=L$e(Le,"id"),[kt,tn]=v.useState(null),Kt=lt?Ne:p6(Ne,ue),Dn=J9n(Kt,(i=kt?.rect)!=null?i:null,be),Qt=v.useRef(null),Ve=v.useCallback((Ut,kn)=>{let{sensor:jt,options:pn}=kn;if(Q.current==null)return;const ke=P.get(Q.current);if(!ke)return;const Ke=Ut.nativeEvent,dt=new jt({active:Q.current,activeNode:ke,event:Ke,options:pn,context:le,onAbort(Yt){if(!P.get(Yt))return;const{onDragAbort:ir}=K.current,Nt={id:Yt};ir?.(Nt),k({type:"onDragAbort",event:Nt})},onPending(Yt,Wt,ir,Nt){if(!P.get(Yt))return;const{onDragPending:dn}=K.current,Kn={id:Yt,constraint:Wt,initialCoordinates:ir,offset:Nt};dn?.(Kn),k({type:"onDragPending",event:Kn})},onStart(Yt){const Wt=Q.current;if(Wt==null)return;const ir=P.get(Wt);if(!ir)return;const{onDragStart:Nt}=K.current,Xt={activatorEvent:Ke,active:{id:Wt,data:ir.data,rect:z}};Bs.unstable_batchedUpdates(()=>{Nt?.(Xt),A(_f.Initializing),y({type:Qi.DragStart,initialCoordinates:Yt,active:Wt}),k({type:"onDragStart",event:Xt}),N(Qt.current),G(Ke)})},onMove(Yt){y({type:Qi.DragMove,coordinates:Yt})},onEnd:sn(Qi.DragEnd),onCancel:sn(Qi.DragCancel)});Qt.current=dt;function sn(Yt){return async function(){const{active:ir,collisions:Nt,over:Xt,scrollAdjustedTranslate:dn}=le.current;let Kn=null;if(ir&&dn){const{cancelDrop:Ie}=K.current;Kn={activatorEvent:Ke,active:ir,collisions:Nt,delta:dn,over:Xt},Yt===Qi.DragEnd&&typeof Ie=="function"&&await Promise.resolve(Ie(Kn))&&(Yt=Qi.DragCancel)}Q.current=null,Bs.unstable_batchedUpdates(()=>{y({type:Yt}),A(_f.Uninitialized),tn(null),N(null),G(null),Qt.current=null;const Ie=Yt===Qi.DragEnd?"onDragEnd":"onDragCancel";if(Kn){const gt=K.current[Ie];gt?.(Kn),k({type:Ie,event:Kn})}})}}},[P]),Ct=v.useCallback((Ut,kn)=>(jt,pn)=>{const ke=jt.nativeEvent,Ke=P.get(pn);if(Q.current!==null||!Ke||ke.dndKit||ke.defaultPrevented)return;const dt={active:Ke};Ut(jt,kn.options,dt)===!0&&(ke.dndKit={capturedBy:kn.sensor},Q.current=pn,Ve(jt,kn))},[P,Ve]),Mt=wbn(u,Ct);Mbn(u),V0(()=>{be&&C===_f.Initializing&&A(_f.Initialized)},[be,C]),v.useEffect(()=>{const{onDragMove:Ut}=K.current,{active:kn,activatorEvent:jt,collisions:pn,over:ke}=le.current;if(!kn||!jt)return;const Ke={active:kn,activatorEvent:jt,collisions:pn,delta:{x:Pe.x,y:Pe.y},over:ke};Bs.unstable_batchedUpdates(()=>{Ut?.(Ke),k({type:"onDragMove",event:Ke})})},[Pe.x,Pe.y]),v.useEffect(()=>{const{active:Ut,activatorEvent:kn,collisions:jt,droppableContainers:pn,scrollAdjustedTranslate:ke}=le.current;if(!Ut||Q.current==null||!kn||!ke)return;const{onDragOver:Ke}=K.current,dt=pn.get(et),sn=dt&&dt.rect.current?{id:dt.id,rect:dt.rect.current,data:dt.data,disabled:dt.disabled}:null,Yt={active:Ut,activatorEvent:kn,collisions:jt,delta:{x:ke.x,y:ke.y},over:sn};Bs.unstable_batchedUpdates(()=>{tn(sn),Ke?.(Yt),k({type:"onDragOver",event:Yt})})},[et]),V0(()=>{le.current={activatorEvent:V,active:Y,activeNode:se,collisionRect:Ee,collisions:Le,droppableRects:B,draggableNodes:P,draggingNode:ot,draggingNodeRect:Qe,droppableContainers:D,over:kt,scrollableAncestors:Te,scrollAdjustedTranslate:Pe},z.current={initial:Qe,translated:Ee}},[Y,se,Le,Ee,P,ot,Qe,B,D,kt,Te,Pe]),bbn({...he,delta:L,draggingRect:Ee,pointerCoordinates:$e,scrollableAncestors:Te,scrollableAncestorRects:pe});const Ye=v.useMemo(()=>({active:Y,activeNode:se,activeNodeRect:be,activatorEvent:V,collisions:Le,containerNodeRect:me,dragOverlay:Xe,draggableNodes:P,droppableContainers:D,droppableRects:B,over:kt,measureDroppableContainers:ee,scrollableAncestors:Te,scrollableAncestorRects:pe,measuringConfiguration:U,measuringScheduled:te,windowRect:ve}),[Y,se,be,V,Le,me,Xe,P,D,B,kt,ee,Te,pe,U,te,ve]),Pt=v.useMemo(()=>({activatorEvent:V,activators:Mt,active:Y,activeNodeRect:be,ariaDescribedById:{draggable:q},dispatch:y,draggableNodes:P,over:kt,measureDroppableContainers:ee}),[V,Mt,Y,be,y,q,P,kt,ee]);return Bt.createElement(R$e.Provider,{value:O},Bt.createElement(Ux.Provider,{value:Pt},Bt.createElement(G$e.Provider,{value:Ye},Bt.createElement(Jj.Provider,{value:Dn},c)),Bt.createElement($bn,{disabled:a?.restoreFocus===!1})),Bt.createElement(Q9n,{...a,hiddenTextDescribedById:q}));function Dt(){const Ut=H?.autoScrollEnabled===!1,kn=typeof l=="object"?l.enabled===!1:l===!1,jt=E&&!Ut&&!kn;return typeof l=="object"?{...l,enabled:jt}:{enabled:jt}}}),Fbn=v.createContext(null),gpe="button",qbn="Draggable";function tN(t){let{id:e,data:n,disabled:r=!1,attributes:o}=t;const i=Qx(qbn),{activators:s,activatorEvent:a,active:l,activeNodeRect:c,ariaDescribedById:u,draggableNodes:d,over:h}=v.useContext(Ux),{role:p=gpe,roleDescription:g="draggable",tabIndex:_=0}=o??{},x=l?.id===e,y=v.useContext(x?Jj:Fbn),[k,O]=$E(),[C,A]=$E(),E=Pbn(s,e),M=g_(n);V0(()=>(d.set(e,{id:e,key:i,node:k,activatorNode:C,data:M}),()=>{const L=d.get(e);L&&L.key===i&&d.delete(e)}),[d,e]);const P=v.useMemo(()=>({role:p,tabIndex:_,"aria-disabled":r,"aria-pressed":x&&p===gpe?!0:void 0,"aria-roledescription":g,"aria-describedby":u.draggable}),[r,p,_,x,g,u.draggable]);return{active:l,activatorEvent:a,activeNodeRect:c,attributes:P,isDragging:x,listeners:r?void 0:E,node:k,over:h,setNodeRef:O,setActivatorNodeRef:A,transform:y}}function nN(){return v.useContext(G$e)}const Vbn="Droppable",Qbn={timeout:25};function rN(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:o}=t;const i=Qx(Vbn),{active:s,dispatch:a,over:l,measureDroppableContainers:c}=v.useContext(Ux),u=v.useRef({disabled:n}),d=v.useRef(!1),h=v.useRef(null),p=v.useRef(null),{disabled:g,updateMeasurementsFor:_,timeout:x}={...Qbn,...o},y=g_(_??r),k=v.useCallback(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{c(Array.isArray(y.current)?y.current:[y.current]),p.current=null},x)},[x]),O=Kj({callback:k,disabled:g||!s}),C=v.useCallback((P,L)=>{O&&(L&&(O.unobserve(L),d.current=!1),P&&O.observe(P))},[O]),[A,E]=$E(C),M=g_(e);return v.useEffect(()=>{!O||!A.current||(O.disconnect(),d.current=!1,O.observe(A.current))},[A,O]),v.useEffect(()=>(a({type:Qi.RegisterDroppable,element:{id:r,key:i,disabled:n,node:A,rect:h,data:M}}),()=>a({type:Qi.UnregisterDroppable,key:i,id:r})),[r]),v.useEffect(()=>{n!==u.current.disabled&&(a({type:Qi.SetDroppableDisabled,id:r,key:i,disabled:n}),u.current.disabled=n)},[r,i,n,a]),{active:s,rect:h,isOver:l?.id===r,node:A,over:l,setNodeRef:E}}function Ubn(t){let{animation:e,children:n}=t;const[r,o]=v.useState(null),[i,s]=v.useState(null),a=BE(n);return!n&&!r&&a&&o(a),V0(()=>{if(!i)return;const l=r?.key,c=r?.props.id;if(l==null||c==null){o(null);return}Promise.resolve(e(c,i)).then(()=>{o(null)})},[e,r,i]),Bt.createElement(Bt.Fragment,null,n,r?v.cloneElement(r,{ref:s}):null)}const Wbn={x:0,y:0,scaleX:1,scaleY:1};function Zbn(t){let{children:e}=t;return Bt.createElement(Ux.Provider,{value:Z$e},Bt.createElement(Jj.Provider,{value:Wbn},e))}const Gbn={position:"fixed",touchAction:"none"},Ybn=t=>Wj(t)?"transform 250ms ease":void 0,Xbn=v.forwardRef((t,e)=>{let{as:n,activatorEvent:r,adjustScale:o,children:i,className:s,rect:a,style:l,transform:c,transition:u=Ybn}=t;if(!a)return null;const d=o?c:{...c,scaleX:1,scaleY:1},h={...Gbn,width:a.width,height:a.height,top:a.top,left:a.left,transform:du.Transform.toString(d),transformOrigin:o&&r?U9n(r,a):void 0,transition:typeof u=="function"?u(r):u,...l};return Bt.createElement(n,{className:s,style:h,ref:e},i)}),Kbn=t=>e=>{let{active:n,dragOverlay:r}=e;const o={},{styles:i,className:s}=t;if(i!=null&&i.active)for(const[a,l]of Object.entries(i.active))l!==void 0&&(o[a]=n.node.style.getPropertyValue(a),n.node.style.setProperty(a,l));if(i!=null&&i.dragOverlay)for(const[a,l]of Object.entries(i.dragOverlay))l!==void 0&&r.node.style.setProperty(a,l);return s!=null&&s.active&&n.node.classList.add(s.active),s!=null&&s.dragOverlay&&r.node.classList.add(s.dragOverlay),function(){for(const[l,c]of Object.entries(o))n.node.style.setProperty(l,c);s!=null&&s.active&&n.node.classList.remove(s.active)}},Jbn=t=>{let{transform:{initial:e,final:n}}=t;return[{transform:du.Transform.toString(e)},{transform:du.Transform.toString(n)}]},e_n={duration:250,easing:"ease",keyframes:Jbn,sideEffects:Kbn({styles:{active:{opacity:"0"}}})};function t_n(t){let{config:e,draggableNodes:n,droppableContainers:r,measuringConfiguration:o}=t;return Uj((i,s)=>{if(e===null)return;const a=n.get(i);if(!a)return;const l=a.node.current;if(!l)return;const c=W$e(s);if(!c)return;const{transform:u}=Xa(s).getComputedStyle(s),d=D$e(u);if(!d)return;const h=typeof e=="function"?e:n_n(e);return V$e(l,o.draggable.measure),h({active:{id:i,data:a.data,node:l,rect:o.draggable.measure(l)},draggableNodes:n,dragOverlay:{node:s,rect:o.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:o,transform:d})})}function n_n(t){const{duration:e,easing:n,sideEffects:r,keyframes:o}={...e_n,...t};return i=>{let{active:s,dragOverlay:a,transform:l,...c}=i;if(!e)return;const u={x:a.rect.left-s.rect.left,y:a.rect.top-s.rect.top},d={scaleX:l.scaleX!==1?s.rect.width*l.scaleX/a.rect.width:1,scaleY:l.scaleY!==1?s.rect.height*l.scaleY/a.rect.height:1},h={x:l.x-u.x,y:l.y-u.y,...d},p=o({...c,active:s,dragOverlay:a,transform:{initial:l,final:h}}),[g]=p,_=p[p.length-1];if(JSON.stringify(g)===JSON.stringify(_))return;const x=r?.({active:s,dragOverlay:a,...c}),y=a.node.animate(p,{duration:e,easing:n,fill:"forwards"});return new Promise(k=>{y.onfinish=()=>{x?.(),k()}})}}let vpe=0;function r_n(t){return v.useMemo(()=>{if(t!=null)return vpe++,vpe},[t])}const o_n=Bt.memo(t=>{let{adjustScale:e=!1,children:n,dropAnimation:r,style:o,transition:i,modifiers:s,wrapperElement:a="div",className:l,zIndex:c=999}=t;const{activatorEvent:u,active:d,activeNodeRect:h,containerNodeRect:p,draggableNodes:g,droppableContainers:_,dragOverlay:x,over:y,measuringConfiguration:k,scrollableAncestors:O,scrollableAncestorRects:C,windowRect:A}=nN(),E=v.useContext(Jj),M=r_n(d?.id),P=Y$e(s,{activatorEvent:u,active:d,activeNodeRect:h,containerNodeRect:p,draggingNodeRect:x.rect,over:y,overlayNodeRect:x.rect,scrollableAncestors:O,scrollableAncestorRects:C,transform:E,windowRect:A}),L=xee(h),D=t_n({config:r,draggableNodes:g,droppableContainers:_,measuringConfiguration:k}),I=L?x.setRef:void 0;return Bt.createElement(Zbn,null,Bt.createElement(Ubn,{animation:D},d&&M?Bt.createElement(Xbn,{key:M,id:d.id,ref:I,as:a,activatorEvent:u,adjustScale:e,className:l,transition:i,rect:L,style:{zIndex:c,...o},transform:P},n):null))});function oN(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function i_n(t,e){return t.reduce((n,r,o)=>{const i=e.get(r);return i&&(n[o]=i),n},Array(t.length))}function Xk(t){return t!==null&&t>=0}function s_n(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function a_n(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const X$e=t=>{let{rects:e,activeIndex:n,overIndex:r,index:o}=t;const i=oN(e,r,n),s=e[o],a=i[o];return!a||!s?null:{x:a.left-s.left,y:a.top-s.top,scaleX:a.width/s.width,scaleY:a.height/s.height}},Kk={scaleX:1,scaleY:1},yee=t=>{var e;let{activeIndex:n,activeNodeRect:r,index:o,rects:i,overIndex:s}=t;const a=(e=i[n])!=null?e:r;if(!a)return null;if(o===n){const c=i[s];return c?{x:0,y:n<s?c.top+c.height-(a.top+a.height):c.top-a.top,...Kk}:null}const l=l_n(i,o,n);return o>n&&o<=s?{x:0,y:-a.height-l,...Kk}:o<n&&o>=s?{x:0,y:a.height+l,...Kk}:{x:0,y:0,...Kk}};function l_n(t,e,n){const r=t[e],o=t[e-1],i=t[e+1];return r?n<e?o?r.top-(o.top+o.height):i?i.top-(r.top+r.height):0:i?i.top-(r.top+r.height):o?r.top-(o.top+o.height):0:0}const K$e="Sortable",J$e=Bt.createContext({activeIndex:-1,containerId:K$e,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:X$e,disabled:{draggable:!1,droppable:!1}});function wee(t){let{children:e,id:n,items:r,strategy:o=X$e,disabled:i=!1}=t;const{active:s,dragOverlay:a,droppableRects:l,over:c,measureDroppableContainers:u}=nN(),d=Qx(K$e,n),h=a.rect!==null,p=v.useMemo(()=>r.map(E=>typeof E=="object"&&"id"in E?E.id:E),[r]),g=s!=null,_=s?p.indexOf(s.id):-1,x=c?p.indexOf(c.id):-1,y=v.useRef(p),k=!s_n(p,y.current),O=x!==-1&&_===-1||k,C=a_n(i);V0(()=>{k&&g&&u(p)},[k,p,g,u]),v.useEffect(()=>{y.current=p},[p]);const A=v.useMemo(()=>({activeIndex:_,containerId:d,disabled:C,disableTransforms:O,items:p,overIndex:x,useDragOverlay:h,sortedRects:i_n(p,l),strategy:o}),[_,d,C.draggable,C.droppable,O,p,x,l,h,o]);return Bt.createElement(J$e.Provider,{value:A},e)}const c_n=t=>{let{id:e,items:n,activeIndex:r,overIndex:o}=t;return oN(n,r,o).indexOf(e)},u_n=t=>{let{containerId:e,isSorting:n,wasDragging:r,index:o,items:i,newIndex:s,previousItems:a,previousContainerId:l,transition:c}=t;return!c||!r||a!==i&&o===s?!1:n?!0:s!==o&&e===l},d_n={duration:200,easing:"ease"},eBe="transform",f_n=du.Transition.toString({property:eBe,duration:0,easing:"linear"}),h_n={roleDescription:"sortable"};function p_n(t){let{disabled:e,index:n,node:r,rect:o}=t;const[i,s]=v.useState(null),a=v.useRef(n);return V0(()=>{if(!e&&n!==a.current&&r.current){const l=o.current;if(l){const c=p8(r.current,{ignoreTransform:!0}),u={x:l.left-c.left,y:l.top-c.top,scaleX:l.width/c.width,scaleY:l.height/c.height};(u.x||u.y)&&s(u)}}n!==a.current&&(a.current=n)},[e,n,r,o]),v.useEffect(()=>{i&&s(null)},[i]),i}function kee(t){let{animateLayoutChanges:e=u_n,attributes:n,disabled:r,data:o,getNewIndex:i=c_n,id:s,strategy:a,resizeObserverConfig:l,transition:c=d_n}=t;const{items:u,containerId:d,activeIndex:h,disabled:p,disableTransforms:g,sortedRects:_,overIndex:x,useDragOverlay:y,strategy:k}=v.useContext(J$e),O=m_n(r,p),C=u.indexOf(s),A=v.useMemo(()=>({sortable:{containerId:d,index:C,items:u},...o}),[d,o,C,u]),E=v.useMemo(()=>u.slice(u.indexOf(s)),[u,s]),{rect:M,node:P,isOver:L,setNodeRef:D}=rN({id:s,data:A,disabled:O.droppable,resizeObserverConfig:{updateMeasurementsFor:E,...l}}),{active:I,activatorEvent:z,activeNodeRect:Y,attributes:Q,setNodeRef:H,listeners:N,isDragging:V,over:G,setActivatorNodeRef:K,transform:q}=tN({id:s,data:A,attributes:{...h_n,...n},disabled:O.draggable}),Z=j9n(D,H),U=!!I,B=U&&!g&&Xk(h)&&Xk(x),ee=!y&&V,te=ee&&B?q:null,ae=B?te??(a??k)({rects:_,activeNodeRect:Y,activeIndex:h,overIndex:x,index:C}):null,he=Xk(h)&&Xk(x)?i({id:s,items:u,activeIndex:h,overIndex:x}):C,fe=I?.id,be=v.useRef({activeId:fe,items:u,newIndex:he,containerId:d}),me=u!==be.current.items,le=e({active:I,containerId:d,isDragging:V,isSorting:U,id:s,index:C,items:u,newIndex:be.current.newIndex,previousItems:be.current.items,previousContainerId:be.current.containerId,transition:c,wasDragging:be.current.activeId!=null}),Be=p_n({disabled:!le,index:C,node:P,rect:M});return v.useEffect(()=>{U&&be.current.newIndex!==he&&(be.current.newIndex=he),d!==be.current.containerId&&(be.current.containerId=d),u!==be.current.items&&(be.current.items=u)},[U,he,d,u]),v.useEffect(()=>{if(fe===be.current.activeId)return;if(fe!=null&&be.current.activeId==null){be.current.activeId=fe;return}const ot=setTimeout(()=>{be.current.activeId=fe},50);return()=>clearTimeout(ot)},[fe]),{active:I,activeIndex:h,attributes:Q,data:A,rect:M,index:C,newIndex:he,items:u,isOver:L,isSorting:U,isDragging:V,listeners:N,node:P,overIndex:x,over:G,setNodeRef:Z,setActivatorNodeRef:K,setDroppableNodeRef:D,setDraggableNodeRef:H,transform:Be??ae,transition:Xe()};function Xe(){if(Be||me&&be.current.newIndex===C)return f_n;if(!(ee&&!Wj(z)||!c)&&(U||le))return du.Transition.toString({...c,property:eBe})}}function m_n(t,e){var n,r;return typeof t=="boolean"?{draggable:t,droppable:!1}:{draggable:(n=t?.draggable)!=null?n:e.draggable,droppable:(r=t?.droppable)!=null?r:e.droppable}}function QE(t){if(!t)return!1;const e=t.data.current;return!!(e&&"sortable"in e&&typeof e.sortable=="object"&&"containerId"in e.sortable&&"items"in e.sortable&&"index"in e.sortable)}const g_n=[Tr.Down,Tr.Right,Tr.Up,Tr.Left],tBe=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:i,over:s,scrollableAncestors:a}}=e;if(g_n.includes(t.code)){if(t.preventDefault(),!n||!r)return;const l=[];i.getEnabled().forEach(d=>{if(!d||d!=null&&d.disabled)return;const h=o.get(d.id);if(h)switch(t.code){case Tr.Down:r.top<h.top&&l.push(d);break;case Tr.Up:r.top>h.top&&l.push(d);break;case Tr.Left:r.left>h.left&&l.push(d);break;case Tr.Right:r.left<h.left&&l.push(d);break}});const c=Z9n({collisionRect:r,droppableRects:o,droppableContainers:l});let u=L$e(c,"id");if(u===s?.id&&c.length>1&&(u=c[1].id),u!=null){const d=i.get(n.id),h=i.get(u),p=h?o.get(h.id):null,g=h?.node.current;if(g&&p&&d&&h){const x=Gj(g).some((E,M)=>a[M]!==E),y=nBe(d,h),k=v_n(d,h),O=x||!y?{x:0,y:0}:{x:k?r.width-p.width:0,y:k?r.height-p.height:0},C={x:p.left,y:p.top};return O.x&&O.y?C:v_(C,O)}}}};function nBe(t,e){return!QE(t)||!QE(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function v_n(t,e){return!QE(t)||!QE(e)||!nBe(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}const VQ=["hostRequests.list"];function b_n(){const t=Rr(),e=Rn();return v.useEffect(()=>t.subscribeStatusEvents(r=>{if(r.kind==="host-status-changed"){e.invalidateQueries({queryKey:Un.repos});return}r.kind==="host-request-changed"&&(e.invalidateQueries({queryKey:VQ}),e.invalidateQueries({queryKey:Un.repos}))}),[t,e]),It({queryKey:VQ,queryFn:async()=>(await Se.hostRequests.list.query()).requests}).data??[]}function __n(){const t=Rn();return $s({mutationFn:e=>Se.hostRequests.cancel.mutate({requestId:e}),onSettled:()=>t.invalidateQueries({queryKey:VQ})})}function rBe(){const t=Rr(),e=Rn(),n=Cn(c=>c.setError),{repos:r}=xs(),o=v.useMemo(()=>{const c=[];for(const u of r)for(const d of u.worktrees)d.pinned&&c.push({repo:u,worktree:d,worktreeId:jr(u.name,d.name,d.hostId)});return c},[r]),i=v.useMemo(()=>new Set(o.map(c=>c.worktreeId)),[o]),s=v.useCallback(c=>i.has(c),[i]),a=$s({mutationFn:({repo:c,name:u,pinned:d,hostId:h})=>t.setWorktreePinned(c,u,d,h),onMutate:async({repo:c,name:u,pinned:d,hostId:h})=>{await e.cancelQueries({queryKey:Un.repos});const p=e.getQueryData(Un.repos);if(p){const g=p.map(_=>_.name===c?{..._,worktrees:_.worktrees.map(x=>x.name===u&&(x.hostId??"local")===(h??"local")?{...x,pinned:d}:x)}:_);e.setQueryData(Un.repos,g)}return{previous:p}},onError:(c,u,d)=>{d?.previous&&e.setQueryData(Un.repos,d.previous),n(c)},onSettled:()=>{e.invalidateQueries({queryKey:Un.repos})}}),l=v.useCallback((c,u,d,h)=>a.mutate({repo:c,name:u,pinned:!d,hostId:h}),[a.mutate]);return{pinned:o,isPinned:s,toggle:l}}function x_n(){const t=Rr(),e=Rn(),n=Cn(r=>r.setError);return $s({mutationFn:r=>t.removeRepo(r),onSuccess:()=>{e.invalidateQueries({queryKey:Un.repos})},onError:r=>{n(r)}})}function y_n(){const t=Rr(),e=Rn(),n=Cn(r=>r.setError);return $s({mutationFn:r=>t.reorderRepos(r),onMutate:async r=>{await e.cancelQueries({queryKey:Un.repos});const o=e.getQueryData(Un.repos);if(o){const i=[...o].sort((s,a)=>r.indexOf(s.name)-r.indexOf(a.name));e.setQueryData(Un.repos,i)}return{previous:o}},onError:(r,o,i)=>{i?.previous&&e.setQueryData(Un.repos,i.previous),n(r)},onSettled:()=>{e.invalidateQueries({queryKey:Un.repos})}})}function w_n(){const t=Rr(),e=Rn(),n=Cn(r=>r.setError);return $s({mutationFn:r=>t.reorderWorktrees(r),onMutate:async r=>{await e.cancelQueries({queryKey:Un.repos});const o=e.getQueryData(Un.repos);if(o){const i=l=>l??"local",s=r.scope==="pins"?"pinSortIndex":"sortIndex",a=o.map(l=>({...l,worktrees:l.worktrees.map(c=>{const u=r.order.findIndex(p=>p.repo===l.name&&p.name===c.name&&i(p.hostId)===i(c.hostId));let d=u===-1?c:{...c,[s]:u};const h=r.reparent;return h&&h.repo===l.name&&h.name===c.name&&i(h.hostId)===i(c.hostId)&&(d={...d,origin:h.origin===null?null:{worktreeId:h.origin,removed:!1}}),d})}));e.setQueryData(Un.repos,a)}return{previous:o}},onError:(r,o,i)=>{i?.previous&&e.setQueryData(Un.repos,i.previous),n(r)},onSettled:()=>{e.invalidateQueries({queryKey:Un.repos})}})}function k_n(){const t=Rr(),e=Rn(),n=Cn(r=>r.setError);return $s({mutationFn:r=>t.promoteRepoToGit?t.promoteRepoToGit(r):Promise.reject(new Error("This dashboard adapter doesn't support promoting plain repos to git.")),onSuccess:()=>{e.invalidateQueries({queryKey:Un.repos})},onError:r=>{n(r)}})}function O_n(){const t=Rr(),e=Rn(),n=Cn(o=>o.setError),r=Cn(o=>o.openWorktree);return $s({mutationFn:({repo:o,branch:i,base:s,prompt:a,host:l,groupId:c})=>t.createWorktree(o,i,s,a,Fb(),l,c),onSuccess:(o,i)=>{e.invalidateQueries({queryKey:Un.repos});const s=jr(i.repo,i.branch,o.hostId??i.host?.hostId);r(s)},onError:o=>{n(o)}})}function oBe(){const t=Rr(),e=Rn(),n=Cn(s=>s.setError),r=Cn(s=>s.openWorktree),o=Cn(s=>s.setDeleting),i=Hye();return $s({mutationFn:({repo:s,name:a,hostId:l})=>t.removeWorktree(s,a,l),onMutate:({repo:s,name:a,hostId:l})=>{o(jr(s,a,l),!0)},onSuccess:async(s,{repo:a,name:l,hostId:c})=>{await e.invalidateQueries({queryKey:Un.repos});const u=jr(a,l,c);if(i.getState().activeWorktreeId===u){const h=e.getQueryData(Un.repos)?.find(p=>p.name===a);if(h){const p=h.worktrees.find(g=>(g.name===h.defaultBranch||g.branch===h.defaultBranch)&&(g.hostId??"local")===(c??"local"));r(jr(a,p?.name??h.defaultBranch,p?.hostId??c))}}},onError:s=>{n(s)},onSettled:(s,a,{repo:l,name:c,hostId:u})=>{o(jr(l,c,u),!1)}})}function iBe(t,e,n){const r=t.indexOf(e),o=r+n;if(r<0||o<0||o>=t.length)return null;const i=[...t];return[i[r],i[o]]=[i[o],i[r]],i}function S_n(t,e,n){const r=t.indexOf(e),o=t.indexOf(n);if(r<0||o<0||r===o)return null;const i=[...t];return i.splice(r,1),i.splice(o,0,e),i}const gg={type:"none"},sBe=t=>({repo:t.repo.name,name:t.worktree.name,hostId:t.worktree.hostId});function C_n(t,e,n){const r=t.height>0?(e-t.top)/t.height:.5;return n?r<.25?"before":r>.75?"after":"into":r<.5?"before":"after"}function Oee(t,e,n,r){const o=t.filter(s=>s!==e),i=o.indexOf(n);return i===-1?t:(o.splice(r==="before"?i:i+1,0,e),o)}function aBe(t,e,n){const r=e.flatMap(o=>{const i=t.get(o);return i?[sBe(i)]:[]});return r.length===0?gg:{type:"reorder",scope:n,order:r}}function A_n(t,e,n,r){if(e===n||r==="into")return null;const o=Oee(t,e,n,r);return o.join("|")===t.join("|")?null:o}function E_n(t,e,n,r){if(e===n||r==="into")return gg;const o=new Map(t.pins.map(s=>[s.worktreeId,s])),i=Oee(t.pins.map(s=>s.worktreeId),e,n,r);return aBe(o,i,"pins")}function T_n(t,e,n,r){if(e===n||r==="into")return gg;const o=new Map(t.map(s=>[s.worktreeId,s]));if(!o.has(e)||!o.has(n))return gg;const i=Oee(t.map(s=>s.worktreeId),e,n,r);return aBe(o,i,"siblings")}function M_n(t,e,n,r){if(e===n)return{type:"refuse",reason:"A worktree can't become its own parent."};const o=t.find(d=>d.worktreeId===e),i=t.find(d=>d.worktreeId===n);if(!o||!i)return gg;const s=new Set([e,...O$e(t,e).map(d=>d.worktreeId)]),a={type:"refuse",reason:"A worktree can't become a child of one that was started from it."};let l;if(r==="into"){if(s.has(n))return a;l=n}else{const d=i.worktree.origin?.worktreeId;if(l=d!==void 0&&t.some(p=>p.worktreeId===d)?d:null,l!==null&&s.has(l))return a}const c=i.worktree.groupId??null;return(o.worktree.origin?.worktreeId??null)===l&&(o.worktree.groupId??null)===c?gg:{type:"parent",worktree:sBe(o),worktreeId:e,origin:l,groupId:c}}function P_n({open:t,onOpenChange:e,onConfirm:n,branchName:r,isUnmerged:o,isDirty:i,hasUnpushedCommits:s}){return f.jsx(nr,{open:t,onOpenChange:e,children:f.jsxs(rr,{className:"sm:max-w-[425px]",onClick:a=>a.stopPropagation(),children:[f.jsxs(hr,{children:[f.jsx(or,{children:"Delete worktree"}),f.jsxs(Nr,{children:["Are you sure you want to delete ",f.jsx("strong",{children:r}),"?"]})]}),f.jsxs("div",{className:"flex flex-col gap-2 text-sm",children:[o&&f.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-warning/30 bg-warning-bg p-3",children:[f.jsx(Mc,{className:"size-4 shrink-0 text-warning mt-0.5"}),f.jsx("span",{children:"This branch has not been merged to main."})]}),s&&f.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-warning/30 bg-warning-bg p-3",children:[f.jsx(Mc,{className:"size-4 shrink-0 text-warning mt-0.5"}),f.jsx("span",{children:"This branch has unpushed commits that will be lost."})]}),i&&f.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-warning/30 bg-warning-bg p-3",children:[f.jsx(Mc,{className:"size-4 shrink-0 text-warning mt-0.5"}),f.jsx("span",{children:"There are uncommitted changes that will be lost."})]})]}),f.jsxs(ii,{children:[f.jsx(Ce,{variant:"ghost",onClick:()=>e(!1),children:"Cancel"}),f.jsx(Ce,{variant:"destructive",onClick:n,children:"Delete"})]})]})})}const QQ=[{name:"Indigo",value:"#6366f1"},{name:"Blue",value:"#3b82f6"},{name:"Green",value:"#22c55e"},{name:"Amber",value:"#f59e0b"},{name:"Red",value:"#ef4444"},{name:"Pink",value:"#ec4899"},{name:"Gray",value:"#6b7280"}],j_n="flex size-8 items-center justify-center rounded-full text-white";function lBe({color:t,onChange:e,testId:n,Swatch:r="button",custom:o=!0}){const i=v.useRef(null);return f.jsxs("div",{className:"flex w-44 flex-col gap-2 p-1",children:[f.jsx("div",{className:"grid grid-cols-4 gap-2",children:QQ.map(s=>f.jsx(r,{...r==="button"?{type:"button"}:{},"aria-label":s.name,"aria-pressed":t.toLowerCase()===s.value,"data-testid":`${n}--${s.name.toLowerCase()}`,onClick:()=>e(s.value),className:j_n,style:{backgroundColor:s.value},children:t.toLowerCase()===s.value?f.jsx(Ji,{className:"size-4"}):null},s.value))}),o?f.jsxs(f.Fragment,{children:[f.jsx("button",{type:"button","data-testid":`${n}-custom-button`,onClick:()=>i.current?.click(),className:"rounded px-2 py-1 text-left text-xs text-foreground hover:bg-accent",children:"Custom colour…"}),f.jsx("input",{ref:i,type:"color","aria-label":"Custom colour","data-testid":`${n}-custom`,value:t,onChange:s=>e(s.target.value),className:"sr-only",tabIndex:-1})]}):null]})}function N_n({color:t,onChange:e,label:n,testId:r,dotTestId:o,children:i}){const[s,a]=v.useState(!1);return f.jsxs(t0,{open:s,onOpenChange:a,children:[f.jsx(ku,{asChild:!0,children:f.jsxs("button",{type:"button","aria-label":n,"data-testid":o,className:"flex size-6 shrink-0 items-center justify-center rounded hover:bg-accent/50",children:[f.jsx("span",{className:"size-3 rounded-full",style:{backgroundColor:t}}),i]})}),f.jsx(n0,{align:"start",className:"w-auto p-2",children:f.jsx(lBe,{color:t,testId:r,onChange:l=>{e(l),a(!1)}})})]})}const iN=v.createContext({overId:null,zone:null});function cBe({dndId:t,data:e,disabled:n,className:r,style:o,testId:i,children:s}){const a=tN({id:t,data:e,disabled:n}),l=rN({id:t,data:e}),{overId:c,zone:u}=v.useContext(iN),d=v.useCallback(p=>{a.setNodeRef(p),l.setNodeRef(p)},[a.setNodeRef,l.setNodeRef]),h=c===t&&!a.isDragging?u:null;return f.jsxs("div",{ref:d,"data-testid":i,"data-dnd-id":t,"data-drop-zone":h??void 0,className:`relative [-webkit-touch-callout:none] ${a.isDragging?"opacity-40":""} ${h==="into"?"rounded-md bg-primary/15":""} ${r??""}`,style:o,...a.listeners,children:[h==="before"&&f.jsx("span",{className:"pointer-events-none absolute inset-x-0 top-0 z-10 h-0.5 bg-primary"}),s,h==="after"&&f.jsx("span",{className:"pointer-events-none absolute inset-x-0 bottom-0 z-10 h-0.5 bg-primary"})]})}function R_n({dndId:t,groupId:e,children:n}){const r=rN({id:t,data:{kind:"group",groupId:e}}),o=tN({id:`grouphdr:${e??"none"}`,data:{kind:"groupmove",groupId:e},disabled:e===null}),{overId:i,zone:s}=v.useContext(iN),a=v.useCallback(c=>{r.setNodeRef(c),o.setNodeRef(c)},[r.setNodeRef,o.setNodeRef]),l=i===t&&!o.isDragging;return f.jsx(f.Fragment,{children:n({setNodeRef:a,over:l,zone:l?s:null,dragListeners:o.listeners,dragging:o.isDragging})})}function L_n({hidden:t}){const{active:e}=nN(),{setNodeRef:n}=rN({id:"group:__top",data:{kind:"group",groupId:null}}),{overId:r}=v.useContext(iN),o=e?.data.current?.kind==="wt";return t?null:f.jsx("div",{ref:n,"data-testid":"repo-list__top-level-drop","data-drop-zone":r==="group:__top"?"into":void 0,className:`mx-2 h-5 rounded border border-dashed text-center text-[11px] leading-[18px] text-muted-foreground ${o?"":"border-transparent"} ${r==="group:__top"?"bg-primary/20":""}`,children:o?"Top level, no group":null})}const uBe="band:continued-seen:",I_n=1440*60*1e3;function D_n(t,e,n){return e!==null&&e>=t?!1:n-t<I_n}function z_n(t){const e=Hn.getItem(uBe+t),n=e===null?Number.NaN:Number(e);return Number.isFinite(n)?n:null}function $_n(t){window.addEventListener("storage",t);const e=bA(t);return()=>{window.removeEventListener("storage",t),e()}}function B_n(t,e,n){const r=v.useSyncExternalStore($_n,()=>z_n(t),()=>null);return v.useEffect(()=>{n&&(r!==null&&r>=e||Hn.setItem(uBe+t,String(e)))},[n,t,e,r]),D_n(e,r,Date.now())}function sN(){const t=It({queryKey:["hosts.list"],queryFn:async()=>(await Se.workers.list.query()).hosts});return e=>{if(!e)return"the hub";const n=t.data?.find(r=>r.id===e);return n?.name?.trim()?n.name:"unknown worker"}}function H_n(t){const e=It({queryKey:["hosts.list"],queryFn:async()=>(await Se.workers.list.query()).hosts});if(!(!e.data||e.data.length<2))return!t||t==="local"?"This hub":e.data.find(n=>n.id===t)?.name?.trim()||"unknown worker"}function UQ(t){return t.onBattery||!t.focused}let Cf={onBattery:!1,focused:typeof document>"u"?!0:!document.hidden&&document.hasFocus()};const WQ=new Set;let bpe=!1;function m6(t){const e={...Cf,...t};if(!(e.onBattery===Cf.onBattery&&e.focused===Cf.focused)){Cf=e,dBe(Cf);for(const n of WQ)n()}}function dBe(t){const e=document.documentElement;UQ(t)?e.setAttribute("data-power","saver"):e.removeAttribute("data-power"),e.toggleAttribute("data-on-battery",t.onBattery)}function F_n(){return Cf.onBattery||typeof document<"u"&&document.hidden}function U0(){return Cf}function Wx(t){return WQ.add(t),()=>WQ.delete(t)}function q_n(){return v.useSyncExternalStore(Wx,U0,U0)}function V_n(){const t=()=>m6({focused:!document.hidden&&document.hasFocus()});window.addEventListener("focus",()=>m6({focused:!document.hidden})),window.addEventListener("blur",()=>{const e=document.activeElement?.tagName;e==="WEBVIEW"||e==="IFRAME"||m6({focused:!1})}),document.addEventListener("visibilitychange",t),t()}function Q_n(){const t=EP();if(!t)return!1;t.invoke("get_power_state").then(e=>m6({onBattery:e.onBattery===!0})).catch(()=>{});try{t.on("power-state-changed",e=>m6({onBattery:e.onBattery===!0}))}catch{}return!0}function U_n(){const t=navigator;typeof t.getBattery=="function"&&t.getBattery().then(e=>{const n=()=>m6({onBattery:!e.charging});e.addEventListener("chargingchange",n),n()}).catch(()=>{})}function W_n(){bpe||typeof window>"u"||(bpe=!0,dBe(Cf),V_n(),Q_n()||U_n())}const Z_n=3;function G_n(t,e,n=Z_n){return t===!1||!e.focused?!1:e.onBattery?t*n:t}function See(t,e){return G_n(t,q_n(),e)}const Y_n=["hosts.list"];function fBe(){return It({queryKey:Y_n,queryFn:async()=>(await Se.workers.list.query()).hosts,refetchInterval:See(5e3,6)}).data??[]}function hBe(t){const e=fBe(),n=!t||t==="local"?void 0:e.find(r=>r.id===t);return{offline:n!==void 0&&n.status!=="online",name:n?.name||t||"",lastSeenAt:n?.lastSeenAt??null}}function ZQ(t,e=Date.now()){const n=Math.max(0,Math.round((e-t)/1e3));if(n<60)return"just now";const r=Math.round(n/60);if(r<60)return`${r} minute${r===1?"":"s"} ago`;const o=Math.round(r/60);if(o<48)return`${o} hour${o===1?"":"s"} ago`;const i=Math.round(o/24);return`${i} day${i===1?"":"s"} ago`}const X_n="plugin:github.pull-request";function K_n(t){window.dispatchEvent(new CustomEvent("band:right-sidepanel-set-tab",{detail:{tab:X_n,worktreeId:t}})),window.dispatchEvent(new CustomEvent("band:show-right-panel"))}const J_n=["Ignored files (node_modules, build output, .env) are not carried over.","Running processes and open terminals are not carried over."];function pBe(t){const e=Math.max(0,Math.round(t/1e3));if(e<90)return`${e} s`;const n=Math.round(e/60);if(n<90)return`${n} min`;const r=Math.round(n/60);return r<48?`${r} h`:`${Math.round(r/24)} d`}function mBe(t,e){return`Continued from ${e} · ${t.reason} · checkpoint ${pBe(t.at-t.checkpointAt)} old`}function exn({from:t,testId:e}){const n=sN(),r=mBe(t,n(t.fromHostId));return f.jsxs(Or,{delayDuration:300,children:[f.jsx(Sr,{asChild:!0,children:f.jsx("span",{"data-testid":e,"data-reason":t.reason,"data-from-host":t.fromHostId,role:"img","aria-label":r,className:"flex shrink-0 items-center ml-auto pl-2 text-muted-foreground",children:f.jsx(gZ,{className:"size-3.5"})})}),f.jsx(Cr,{side:"right",children:r})]})}let BS=null,gBe=0;const __=new Set,GQ=()=>{for(const t of __)t()};function vBe(t,e){return BS?Promise.resolve(null):new Promise(n=>{BS={id:++gBe,answer:t,chatId:e,resolve:r=>{BS=null,GQ(),n(r)}},GQ()})}let bBe=null;function _Be(t){bBe={id:++gBe,worktreeId:t},GQ()}function txn(){return v.useSyncExternalStore(t=>(__.add(t),()=>__.delete(t)),()=>bBe,()=>null)}function k$(t,e){e&&e!==t&&_Be(e)}function nxn(){return v.useSyncExternalStore(t=>(__.add(t),()=>__.delete(t)),()=>BS,()=>null)}function rxn(t){const e=t?.data?.hostOffline;return e?.offer?e:null}function HS(t){const e=rxn(t);e&&vBe(e)}const oxn=t=>t instanceof Error?t.message:String(t);function ixn(){const t=nxn(),e=txn(),n=Rn(),r=Gs(),o=e?.id,i=e?.worktreeId;if(v.useEffect(()=>{if(o===void 0||!i)return;n.invalidateQueries({queryKey:["repos"]});const l=r.getWorktreeHref?.(i);l&&r.navigate&&r.navigate(l)},[o,i,n,r]),!t)return null;const{answer:s,chatId:a}=t;return f.jsx(Cee,{offer:s.offer,chatId:a,blockedMessage:s.code==="CONTINUE_NOT_POSSIBLE"?s.error:void 0,title:"Worker is offline",onClose:t.resolve},t.id)}function Cee({offer:t,chatId:e,blockedMessage:n,title:r="Open on another worker",onClose:o}){const i=Rn(),s=Gs(),a=t.targets.find(y=>y.recommended)?.hostId??"",[l,c]=v.useState(a),[u,d]=v.useState(!1),[h,p]=v.useState(null),g=n!==void 0||!!t.blocked,_=()=>{u||o(null)},x=async()=>{d(!0),p(null);try{const y=await Se.follow.continue.mutate({worktreeId:t.worktreeId,toHostId:l,...e?{chatId:e}:{}});await i.invalidateQueries({queryKey:["repos"]});const k=s.getWorktreeHref?.(y.worktreeId);k&&s.navigate&&s.navigate(k),o({worktreeId:y.worktreeId})}catch(y){p(oxn(y)),d(!1)}};return f.jsx(nr,{open:!0,onOpenChange:y=>y?void 0:_(),children:f.jsxs(rr,{className:"sm:max-w-[520px]","data-testid":"continue-dialog",children:[f.jsxs(hr,{children:[f.jsx(or,{children:g?"Cannot continue elsewhere":r}),f.jsx(Nr,{"data-testid":"continue-dialog__question",children:g?t.blocked?.message??n:t.question})]}),g?f.jsx("div",{className:"flex justify-end",children:f.jsx(Ce,{size:"sm","data-testid":"continue-dialog__close",onClick:_,children:"Close"})}):f.jsxs("div",{className:"space-y-3",children:[f.jsxs("fieldset",{className:"space-y-1.5","data-testid":"continue-dialog__targets",children:[f.jsx("legend",{className:"text-xs font-medium",children:"Continue on"}),t.targets.map(y=>f.jsxs("label",{className:`flex items-start gap-2 text-sm ${y.agentReady?"":"opacity-60"}`,children:[f.jsx("input",{type:"radio",name:"continue-target",value:y.hostId,checked:l===y.hostId,disabled:!y.agentReady||u,"data-testid":"continue-dialog__target","data-host-id":y.hostId,onChange:()=>c(y.hostId)}),f.jsxs("span",{children:[y.hostName,f.jsx("span",{className:"block text-xs text-muted-foreground",children:[y.recommended?"recommended":null,y.hasClone?"has a clone":"no clone yet",`${y.load} worktree${y.load===1?"":"s"}`,y.agentReady?null:y.agentProblem??"agent not available"].filter(Boolean).join(" · ")})]})]},y.hostId))]}),f.jsxs("div",{className:"space-y-1","data-testid":"continue-dialog__notes",children:[(t.limits.length>0?t.limits:[...J_n]).map(y=>f.jsx("p",{className:"text-xs text-muted-foreground",children:y},y)),t.willRun.map(y=>f.jsx("p",{className:"text-xs text-muted-foreground",children:y},y)),t.checkpointAgeMs!==void 0?f.jsxs("p",{className:"text-xs text-muted-foreground",children:["Work after the checkpoint (",pBe(t.checkpointAgeMs)," old) is not carried over."]}):null]}),h?f.jsx("p",{role:"alert",className:"text-xs text-destructive","data-testid":"continue-dialog__error",children:h}):null,f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(Ce,{variant:"ghost",size:"sm","data-testid":"continue-dialog__cancel",disabled:u,onClick:_,children:"Cancel"}),f.jsxs(Ce,{size:"sm","data-testid":"continue-dialog__confirm",disabled:u||l==="",onClick:()=>{x()},children:[u?f.jsx(wo,{className:"size-3"}):null,"Continue"]})]})]})]})})}const Jk=t=>t instanceof Error?t.message:String(t);function sxn({open:t,onOpenChange:e,worktreeId:n}){const r=Rn(),o=It({queryKey:["follow.divergence",n],queryFn:()=>Se.follow.divergence.query({worktreeId:n}),enabled:t}),[i,s]=v.useState(null),a=It({queryKey:["follow.divergenceDiff",n,i],queryFn:()=>Se.follow.divergenceDiff.query({worktreeId:n,path:i}),enabled:t&&i!==null}),[l,c]=v.useState(!1),[u,d]=v.useState(null),[h,p]=v.useState(null),[g,_]=v.useState([]),[x,y]=v.useState(!1),[k,O]=v.useState(!1),C=async()=>{await r.invalidateQueries({queryKey:["repos"]}),await r.invalidateQueries({queryKey:["follow.divergence",n]})},A=async()=>{c(!0),d(null),p(null),_([]);try{const L=await Se.follow.bringOver.mutate({worktreeId:n});L.applied?(p(`Brought over ${L.files} file${L.files===1?"":"s"} to the new copy.`),await C()):(_(L.conflicts),p("The changes conflict with the new copy. Nothing was changed."))}catch(L){d(Jk(L))}finally{c(!1)}},E=async()=>{c(!0),d(null);try{await Se.follow.discardOld.mutate({worktreeId:n,confirm:!0,...o.data?.state==="diverged"?{discardChanges:!0}:{}}),await r.invalidateQueries({queryKey:["repos"]}),e(!1)}catch(L){d(Jk(L)),y(!1),O(!1)}finally{c(!1)}},M=o.data,P=M?.files.length??0;return f.jsx(nr,{open:t,onOpenChange:e,children:f.jsxs(rr,{className:"sm:max-w-[640px]","data-testid":"divergence-panel",children:[f.jsxs(hr,{children:[f.jsx(or,{children:"Changes on the old copy"}),f.jsx(Nr,{children:"This worker was offline while the work continued elsewhere. These files differ from the checkpoint the continuation used."})]}),o.isLoading?f.jsx(wo,{className:"size-4"}):null,o.error?f.jsx("p",{role:"alert",className:"text-xs text-destructive",children:Jk(o.error)}):null,M&&!M.hostOnline?f.jsx("p",{className:"text-sm text-muted-foreground",children:"The worker is offline, so the old copy cannot be compared now."}):null,M?.hostOnline&&M.state==="clean"?f.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"divergence-panel__clean",children:"The old copy has nothing the continuation lacks."}):null,M&&M.files.length>0?f.jsx("ul",{className:"max-h-40 space-y-0.5 overflow-auto","data-testid":"divergence-panel__files",children:M.files.map(L=>f.jsx("li",{children:f.jsxs("button",{type:"button","data-testid":"divergence-panel__file","data-path":L.path,className:`w-full text-left font-mono text-xs hover:underline ${i===L.path?"font-bold":""}`,onClick:()=>s(L.path),children:[L.status," ",L.path]})},L.path))}):null,i!==null?f.jsx("pre",{className:"max-h-60 overflow-auto rounded border bg-muted/40 p-2 font-mono text-xs","data-testid":"divergence-panel__diff",children:a.isLoading?"Loading…":a.data?.diff??Jk(a.error)}):null,h?f.jsx("p",{className:"text-xs","data-testid":"divergence-panel__notice",children:h}):null,g.length>0?f.jsx("ul",{className:"space-y-0.5 text-xs text-destructive","data-testid":"divergence-panel__conflicts",children:g.map(L=>f.jsxs("li",{children:[f.jsx("span",{className:"font-mono",children:L.path}),": ",L.message]},L.path))}):null,u?f.jsx("p",{role:"alert",className:"text-xs text-destructive","data-testid":"divergence-panel__error",children:u}):null,x?f.jsxs("div",{className:"space-y-2 rounded border border-destructive/50 p-2","data-testid":"divergence-panel__confirm",children:[M?.state==="diverged"&&k?f.jsxs("p",{className:"text-xs font-medium","data-testid":"divergence-panel__loss",children:[P," changed file",P===1?"":"s"," exist only on the old copy and will be lost for good. Bring them over first if you want to keep them."]}):f.jsxs("p",{className:"text-xs",children:["Discard the old copy? Its files on the old worker are deleted. The continued worktree is not touched.",M?.state==="diverged"?` It holds ${P} changed file${P===1?"":"s"} the new copy lacks (listed above).`:""]}),f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(Ce,{variant:"ghost",size:"sm",disabled:l,onClick:()=>{y(!1),O(!1)},children:"Keep it"}),M?.state==="diverged"&&!k?f.jsx(Ce,{variant:"destructive",size:"sm","data-testid":"divergence-panel__review-loss",disabled:l,onClick:()=>O(!0),children:"Continue"}):f.jsx(Ce,{variant:"destructive",size:"sm","data-testid":"divergence-panel__confirm-discard",disabled:l,onClick:()=>{E()},children:M?.state==="diverged"?`Delete old copy and ${P} changed file${P===1?"":"s"}`:"Delete old copy"})]})]}):f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(Ce,{variant:"ghost",size:"sm","data-testid":"divergence-panel__discard",disabled:l,onClick:()=>y(!0),children:"Discard old copy"}),f.jsxs(Ce,{size:"sm","data-testid":"divergence-panel__bring-over",disabled:l||!M?.hostOnline||M.state!=="diverged",onClick:()=>{A()},children:[l?f.jsx(wo,{className:"size-3"}):null,"Bring these changes over"]})]})]})})}function axn({git:t}){const e=[];return t.conflict?e.push({kind:"conflict",text:"!",color:"text-git-conflict",tooltip:"Merge conflict"}):t.dirty&&e.push({kind:"dirty",text:"M",color:"text-git-untracked",tooltip:"Uncommitted changes"}),t.sync_state==="ahead"?e.push({kind:"ahead",text:`↑${t.ahead}`,color:"text-git-ahead",tooltip:`${t.ahead} commit${t.ahead>1?"s":""} ahead`}):t.sync_state==="behind"?e.push({kind:"behind",text:`↓${t.behind}`,color:"text-git-behind",tooltip:`${t.behind} commit${t.behind>1?"s":""} behind`}):t.sync_state==="diverged"&&e.push({kind:"diverged",text:`↑${t.ahead}↓${t.behind}`,color:"text-git-diverged",tooltip:`Diverged: ${t.ahead} ahead, ${t.behind} behind`}),e.length===0?null:f.jsxs(Or,{children:[f.jsx(Sr,{asChild:!0,children:f.jsx("span",{className:"inline-flex items-center gap-0.5 font-mono text-[11px] leading-none shrink-0 pr-0.5",children:e.map(n=>f.jsx("span",{className:n.color,"data-testid":`worktree-card__git-${n.kind}`,children:n.text},n.kind))})}),f.jsx(Cr,{children:e.map(n=>n.tooltip).join(", ")})]})}const YQ="local";function _pe(t,e){return!t||t===YQ?e?.find(n=>n.id===YQ)?.name?.trim()||"This hub":e?.find(n=>n.id===t)?.name?.trim()||"unknown worker"}function lxn(t,e,n){for(const a of e??[])for(const l of a.worktrees)if(jr(a.name,l.name,l.hostId)===t){const u=!!l.hostId&&l.hostId!==YQ?_pe(l.hostId,n):null;return{repo:a.name,name:l.name,host:u,label:`${a.name} · ${l.name}${u?` on ${u}`:""}`}}const r=t.lastIndexOf("@"),o=r>=0?t.slice(r+1):null,i=r>=0?t.slice(0,r):t,s=o?_pe(o,n):null;return{repo:null,name:i,host:s,label:s?`${i} on ${s}`:i}}function cxn(){return It({queryKey:["hosts.list"],queryFn:async()=>(await Se.workers.list.query()).hosts}).data}function Aee(){const{repos:t}=xs(),e=cxn();return n=>lxn(n,t,e)}var uxn=Object.defineProperty,UE=Object.getOwnPropertySymbols,xBe=Object.prototype.hasOwnProperty,yBe=Object.prototype.propertyIsEnumerable,xpe=(t,e,n)=>e in t?uxn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,XQ=(t,e)=>{for(var n in e||(e={}))xBe.call(e,n)&&xpe(t,n,e[n]);if(UE)for(var n of UE(e))yBe.call(e,n)&&xpe(t,n,e[n]);return t},KQ=(t,e)=>{var n={};for(var r in t)xBe.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&UE)for(var r of UE(t))e.indexOf(r)<0&&yBe.call(t,r)&&(n[r]=t[r]);return n};var i4;(t=>{const e=class br{constructor(l,c,u,d){if(this.version=l,this.errorCorrectionLevel=c,this.modules=[],this.isFunction=[],l<br.MIN_VERSION||l>br.MAX_VERSION)throw new RangeError("Version value out of range");if(d<-1||d>7)throw new RangeError("Mask value out of range");this.size=l*4+17;let h=[];for(let g=0;g<this.size;g++)h.push(!1);for(let g=0;g<this.size;g++)this.modules.push(h.slice()),this.isFunction.push(h.slice());this.drawFunctionPatterns();const p=this.addEccAndInterleave(u);if(this.drawCodewords(p),d==-1){let g=1e9;for(let _=0;_<8;_++){this.applyMask(_),this.drawFormatBits(_);const x=this.getPenaltyScore();x<g&&(d=_,g=x),this.applyMask(_)}}o(0<=d&&d<=7),this.mask=d,this.applyMask(d),this.drawFormatBits(d),this.isFunction=[]}static encodeText(l,c){const u=t.QrSegment.makeSegments(l);return br.encodeSegments(u,c)}static encodeBinary(l,c){const u=t.QrSegment.makeBytes(l);return br.encodeSegments([u],c)}static encodeSegments(l,c,u=1,d=40,h=-1,p=!0){if(!(br.MIN_VERSION<=u&&u<=d&&d<=br.MAX_VERSION)||h<-1||h>7)throw new RangeError("Invalid value");let g,_;for(g=u;;g++){const O=br.getNumDataCodewords(g,c)*8,C=s.getTotalBits(l,g);if(C<=O){_=C;break}if(g>=d)throw new RangeError("Data too long")}for(const O of[br.Ecc.MEDIUM,br.Ecc.QUARTILE,br.Ecc.HIGH])p&&_<=br.getNumDataCodewords(g,O)*8&&(c=O);let x=[];for(const O of l){n(O.mode.modeBits,4,x),n(O.numChars,O.mode.numCharCountBits(g),x);for(const C of O.getData())x.push(C)}o(x.length==_);const y=br.getNumDataCodewords(g,c)*8;o(x.length<=y),n(0,Math.min(4,y-x.length),x),n(0,(8-x.length%8)%8,x),o(x.length%8==0);for(let O=236;x.length<y;O^=253)n(O,8,x);let k=[];for(;k.length*8<x.length;)k.push(0);return x.forEach((O,C)=>k[C>>>3]|=O<<7-(C&7)),new br(g,c,k,h)}getModule(l,c){return 0<=l&&l<this.size&&0<=c&&c<this.size&&this.modules[c][l]}getModules(){return this.modules}drawFunctionPatterns(){for(let u=0;u<this.size;u++)this.setFunctionModule(6,u,u%2==0),this.setFunctionModule(u,6,u%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const l=this.getAlignmentPatternPositions(),c=l.length;for(let u=0;u<c;u++)for(let d=0;d<c;d++)u==0&&d==0||u==0&&d==c-1||u==c-1&&d==0||this.drawAlignmentPattern(l[u],l[d]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(l){const c=this.errorCorrectionLevel.formatBits<<3|l;let u=c;for(let h=0;h<10;h++)u=u<<1^(u>>>9)*1335;const d=(c<<10|u)^21522;o(d>>>15==0);for(let h=0;h<=5;h++)this.setFunctionModule(8,h,r(d,h));this.setFunctionModule(8,7,r(d,6)),this.setFunctionModule(8,8,r(d,7)),this.setFunctionModule(7,8,r(d,8));for(let h=9;h<15;h++)this.setFunctionModule(14-h,8,r(d,h));for(let h=0;h<8;h++)this.setFunctionModule(this.size-1-h,8,r(d,h));for(let h=8;h<15;h++)this.setFunctionModule(8,this.size-15+h,r(d,h));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let l=this.version;for(let u=0;u<12;u++)l=l<<1^(l>>>11)*7973;const c=this.version<<12|l;o(c>>>18==0);for(let u=0;u<18;u++){const d=r(c,u),h=this.size-11+u%3,p=Math.floor(u/3);this.setFunctionModule(h,p,d),this.setFunctionModule(p,h,d)}}drawFinderPattern(l,c){for(let u=-4;u<=4;u++)for(let d=-4;d<=4;d++){const h=Math.max(Math.abs(d),Math.abs(u)),p=l+d,g=c+u;0<=p&&p<this.size&&0<=g&&g<this.size&&this.setFunctionModule(p,g,h!=2&&h!=4)}}drawAlignmentPattern(l,c){for(let u=-2;u<=2;u++)for(let d=-2;d<=2;d++)this.setFunctionModule(l+d,c+u,Math.max(Math.abs(d),Math.abs(u))!=1)}setFunctionModule(l,c,u){this.modules[c][l]=u,this.isFunction[c][l]=!0}addEccAndInterleave(l){const c=this.version,u=this.errorCorrectionLevel;if(l.length!=br.getNumDataCodewords(c,u))throw new RangeError("Invalid argument");const d=br.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][c],h=br.ECC_CODEWORDS_PER_BLOCK[u.ordinal][c],p=Math.floor(br.getNumRawDataModules(c)/8),g=d-p%d,_=Math.floor(p/d);let x=[];const y=br.reedSolomonComputeDivisor(h);for(let O=0,C=0;O<d;O++){let A=l.slice(C,C+_-h+(O<g?0:1));C+=A.length;const E=br.reedSolomonComputeRemainder(A,y);O<g&&A.push(0),x.push(A.concat(E))}let k=[];for(let O=0;O<x[0].length;O++)x.forEach((C,A)=>{(O!=_-h||A>=g)&&k.push(C[O])});return o(k.length==p),k}drawCodewords(l){if(l.length!=Math.floor(br.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let c=0;for(let u=this.size-1;u>=1;u-=2){u==6&&(u=5);for(let d=0;d<this.size;d++)for(let h=0;h<2;h++){const p=u-h,_=(u+1&2)==0?this.size-1-d:d;!this.isFunction[_][p]&&c<l.length*8&&(this.modules[_][p]=r(l[c>>>3],7-(c&7)),c++)}}o(c==l.length*8)}applyMask(l){if(l<0||l>7)throw new RangeError("Mask value out of range");for(let c=0;c<this.size;c++)for(let u=0;u<this.size;u++){let d;switch(l){case 0:d=(u+c)%2==0;break;case 1:d=c%2==0;break;case 2:d=u%3==0;break;case 3:d=(u+c)%3==0;break;case 4:d=(Math.floor(u/3)+Math.floor(c/2))%2==0;break;case 5:d=u*c%2+u*c%3==0;break;case 6:d=(u*c%2+u*c%3)%2==0;break;case 7:d=((u+c)%2+u*c%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[c][u]&&d&&(this.modules[c][u]=!this.modules[c][u])}}getPenaltyScore(){let l=0;for(let h=0;h<this.size;h++){let p=!1,g=0,_=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[h][x]==p?(g++,g==5?l+=br.PENALTY_N1:g>5&&l++):(this.finderPenaltyAddHistory(g,_),p||(l+=this.finderPenaltyCountPatterns(_)*br.PENALTY_N3),p=this.modules[h][x],g=1);l+=this.finderPenaltyTerminateAndCount(p,g,_)*br.PENALTY_N3}for(let h=0;h<this.size;h++){let p=!1,g=0,_=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[x][h]==p?(g++,g==5?l+=br.PENALTY_N1:g>5&&l++):(this.finderPenaltyAddHistory(g,_),p||(l+=this.finderPenaltyCountPatterns(_)*br.PENALTY_N3),p=this.modules[x][h],g=1);l+=this.finderPenaltyTerminateAndCount(p,g,_)*br.PENALTY_N3}for(let h=0;h<this.size-1;h++)for(let p=0;p<this.size-1;p++){const g=this.modules[h][p];g==this.modules[h][p+1]&&g==this.modules[h+1][p]&&g==this.modules[h+1][p+1]&&(l+=br.PENALTY_N2)}let c=0;for(const h of this.modules)c=h.reduce((p,g)=>p+(g?1:0),c);const u=this.size*this.size,d=Math.ceil(Math.abs(c*20-u*10)/u)-1;return o(0<=d&&d<=9),l+=d*br.PENALTY_N4,o(0<=l&&l<=2568888),l}getAlignmentPatternPositions(){if(this.version==1)return[];{const l=Math.floor(this.version/7)+2,c=this.version==32?26:Math.ceil((this.version*4+4)/(l*2-2))*2;let u=[6];for(let d=this.size-7;u.length<l;d-=c)u.splice(1,0,d);return u}}static getNumRawDataModules(l){if(l<br.MIN_VERSION||l>br.MAX_VERSION)throw new RangeError("Version number out of range");let c=(16*l+128)*l+64;if(l>=2){const u=Math.floor(l/7)+2;c-=(25*u-10)*u-55,l>=7&&(c-=36)}return o(208<=c&&c<=29648),c}static getNumDataCodewords(l,c){return Math.floor(br.getNumRawDataModules(l)/8)-br.ECC_CODEWORDS_PER_BLOCK[c.ordinal][l]*br.NUM_ERROR_CORRECTION_BLOCKS[c.ordinal][l]}static reedSolomonComputeDivisor(l){if(l<1||l>255)throw new RangeError("Degree out of range");let c=[];for(let d=0;d<l-1;d++)c.push(0);c.push(1);let u=1;for(let d=0;d<l;d++){for(let h=0;h<c.length;h++)c[h]=br.reedSolomonMultiply(c[h],u),h+1<c.length&&(c[h]^=c[h+1]);u=br.reedSolomonMultiply(u,2)}return c}static reedSolomonComputeRemainder(l,c){let u=c.map(d=>0);for(const d of l){const h=d^u.shift();u.push(0),c.forEach((p,g)=>u[g]^=br.reedSolomonMultiply(p,h))}return u}static reedSolomonMultiply(l,c){if(l>>>8||c>>>8)throw new RangeError("Byte out of range");let u=0;for(let d=7;d>=0;d--)u=u<<1^(u>>>7)*285,u^=(c>>>d&1)*l;return o(u>>>8==0),u}finderPenaltyCountPatterns(l){const c=l[1];o(c<=this.size*3);const u=c>0&&l[2]==c&&l[3]==c*3&&l[4]==c&&l[5]==c;return(u&&l[0]>=c*4&&l[6]>=c?1:0)+(u&&l[6]>=c*4&&l[0]>=c?1:0)}finderPenaltyTerminateAndCount(l,c,u){return l&&(this.finderPenaltyAddHistory(c,u),c=0),c+=this.size,this.finderPenaltyAddHistory(c,u),this.finderPenaltyCountPatterns(u)}finderPenaltyAddHistory(l,c){c[0]==0&&(l+=this.size),c.pop(),c.unshift(l)}};e.MIN_VERSION=1,e.MAX_VERSION=40,e.PENALTY_N1=3,e.PENALTY_N2=3,e.PENALTY_N3=40,e.PENALTY_N4=10,e.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],e.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],t.QrCode=e;function n(a,l,c){if(l<0||l>31||a>>>l)throw new RangeError("Value out of range");for(let u=l-1;u>=0;u--)c.push(a>>>u&1)}function r(a,l){return(a>>>l&1)!=0}function o(a){if(!a)throw new Error("Assertion error")}const i=class Ko{constructor(l,c,u){if(this.mode=l,this.numChars=c,this.bitData=u,c<0)throw new RangeError("Invalid argument");this.bitData=u.slice()}static makeBytes(l){let c=[];for(const u of l)n(u,8,c);return new Ko(Ko.Mode.BYTE,l.length,c)}static makeNumeric(l){if(!Ko.isNumeric(l))throw new RangeError("String contains non-numeric characters");let c=[];for(let u=0;u<l.length;){const d=Math.min(l.length-u,3);n(parseInt(l.substring(u,u+d),10),d*3+1,c),u+=d}return new Ko(Ko.Mode.NUMERIC,l.length,c)}static makeAlphanumeric(l){if(!Ko.isAlphanumeric(l))throw new RangeError("String contains unencodable characters in alphanumeric mode");let c=[],u;for(u=0;u+2<=l.length;u+=2){let d=Ko.ALPHANUMERIC_CHARSET.indexOf(l.charAt(u))*45;d+=Ko.ALPHANUMERIC_CHARSET.indexOf(l.charAt(u+1)),n(d,11,c)}return u<l.length&&n(Ko.ALPHANUMERIC_CHARSET.indexOf(l.charAt(u)),6,c),new Ko(Ko.Mode.ALPHANUMERIC,l.length,c)}static makeSegments(l){return l==""?[]:Ko.isNumeric(l)?[Ko.makeNumeric(l)]:Ko.isAlphanumeric(l)?[Ko.makeAlphanumeric(l)]:[Ko.makeBytes(Ko.toUtf8ByteArray(l))]}static makeEci(l){let c=[];if(l<0)throw new RangeError("ECI assignment value out of range");if(l<128)n(l,8,c);else if(l<16384)n(2,2,c),n(l,14,c);else if(l<1e6)n(6,3,c),n(l,21,c);else throw new RangeError("ECI assignment value out of range");return new Ko(Ko.Mode.ECI,0,c)}static isNumeric(l){return Ko.NUMERIC_REGEX.test(l)}static isAlphanumeric(l){return Ko.ALPHANUMERIC_REGEX.test(l)}getData(){return this.bitData.slice()}static getTotalBits(l,c){let u=0;for(const d of l){const h=d.mode.numCharCountBits(c);if(d.numChars>=1<<h)return 1/0;u+=4+h+d.bitData.length}return u}static toUtf8ByteArray(l){l=encodeURI(l);let c=[];for(let u=0;u<l.length;u++)l.charAt(u)!="%"?c.push(l.charCodeAt(u)):(c.push(parseInt(l.substring(u+1,u+3),16)),u+=2);return c}};i.NUMERIC_REGEX=/^[0-9]*$/,i.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,i.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let s=i;t.QrSegment=i})(i4||(i4={}));(t=>{(e=>{const n=class{constructor(o,i){this.ordinal=o,this.formatBits=i}};n.LOW=new n(0,1),n.MEDIUM=new n(1,0),n.QUARTILE=new n(2,3),n.HIGH=new n(3,2),e.Ecc=n})(t.QrCode||(t.QrCode={}))})(i4||(i4={}));(t=>{(e=>{const n=class{constructor(o,i){this.modeBits=o,this.numBitsCharCount=i}numCharCountBits(o){return this.numBitsCharCount[Math.floor((o+7)/17)]}};n.NUMERIC=new n(1,[10,12,14]),n.ALPHANUMERIC=new n(2,[9,11,13]),n.BYTE=new n(4,[8,16,16]),n.KANJI=new n(8,[8,10,12]),n.ECI=new n(7,[0,0,0]),e.Mode=n})(t.QrSegment||(t.QrSegment={}))})(i4||(i4={}));var L5=i4;var dxn={L:L5.QrCode.Ecc.LOW,M:L5.QrCode.Ecc.MEDIUM,Q:L5.QrCode.Ecc.QUARTILE,H:L5.QrCode.Ecc.HIGH},wBe=128,kBe="L",OBe="#FFFFFF",SBe="#000000",CBe=!1,ABe=1,fxn=4,hxn=0,pxn=.1;function EBe(t,e=0){const n=[];return t.forEach(function(r,o){let i=null;r.forEach(function(s,a){if(!s&&i!==null){n.push(`M${i+e} ${o+e}h${a-i}v1H${i+e}z`),i=null;return}if(a===r.length-1){if(!s)return;i===null?n.push(`M${a+e},${o+e} h1v1H${a+e}z`):n.push(`M${i+e},${o+e} h${a+1-i}v1H${i+e}z`);return}s&&i===null&&(i=a)})}),n.join("")}function TBe(t,e){return t.slice().map((n,r)=>r<e.y||r>=e.y+e.h?n:n.map((o,i)=>i<e.x||i>=e.x+e.w?o:!1))}function mxn(t,e,n,r){if(r==null)return null;const o=t.length+n*2,i=Math.floor(e*pxn),s=o/e,a=(r.width||i)*s,l=(r.height||i)*s,c=r.x==null?t.length/2-a/2:r.x*s,u=r.y==null?t.length/2-l/2:r.y*s,d=r.opacity==null?1:r.opacity;let h=null;if(r.excavate){let g=Math.floor(c),_=Math.floor(u),x=Math.ceil(a+c-g),y=Math.ceil(l+u-_);h={x:g,y:_,w:x,h:y}}const p=r.crossOrigin;return{x:c,y:u,h:l,w:a,excavation:h,opacity:d,crossOrigin:p}}function gxn(t,e){return e!=null?Math.max(Math.floor(e),0):t?fxn:hxn}function MBe({value:t,level:e,minVersion:n,includeMargin:r,marginSize:o,imageSettings:i,size:s,boostLevel:a}){let l=Bt.useMemo(()=>{const g=(Array.isArray(t)?t:[t]).reduce((_,x)=>(_.push(...L5.QrSegment.makeSegments(x)),_),[]);return L5.QrCode.encodeSegments(g,dxn[e],n,void 0,void 0,a)},[t,e,n,a]);const{cells:c,margin:u,numCells:d,calculatedImageSettings:h}=Bt.useMemo(()=>{let p=l.getModules();const g=gxn(r,o),_=p.length+g*2,x=mxn(p,s,g,i);return{cells:p,margin:g,numCells:_,calculatedImageSettings:x}},[l,s,i,r,o]);return{qrcode:l,margin:u,cells:c,numCells:d,calculatedImageSettings:h}}var vxn=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),bxn=Bt.forwardRef(function(e,n){const r=e,{value:o,size:i=wBe,level:s=kBe,bgColor:a=OBe,fgColor:l=SBe,includeMargin:c=CBe,minVersion:u=ABe,boostLevel:d,marginSize:h,imageSettings:p}=r,_=KQ(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:x}=_,y=KQ(_,["style"]),k=p?.src,O=Bt.useRef(null),C=Bt.useRef(null),A=Bt.useCallback(Q=>{O.current=Q,typeof n=="function"?n(Q):n&&(n.current=Q)},[n]),[E,M]=Bt.useState(!1),{margin:P,cells:L,numCells:D,calculatedImageSettings:I}=MBe({value:o,level:s,minVersion:u,boostLevel:d,includeMargin:c,marginSize:h,imageSettings:p,size:i});Bt.useEffect(()=>{if(O.current!=null){const Q=O.current,H=Q.getContext("2d");if(!H)return;let N=L;const V=C.current,G=I!=null&&V!==null&&V.complete&&V.naturalHeight!==0&&V.naturalWidth!==0;G&&I.excavation!=null&&(N=TBe(L,I.excavation));const K=window.devicePixelRatio||1;Q.height=Q.width=i*K;const q=i/D*K;H.scale(q,q),H.fillStyle=a,H.fillRect(0,0,D,D),H.fillStyle=l,vxn?H.fill(new Path2D(EBe(N,P))):L.forEach(function(Z,U){Z.forEach(function(B,ee){B&&H.fillRect(ee+P,U+P,1,1)})}),I&&(H.globalAlpha=I.opacity),G&&H.drawImage(V,I.x+P,I.y+P,I.w,I.h)}}),Bt.useEffect(()=>{M(!1)},[k]);const z=XQ({height:i,width:i},x);let Y=null;return k!=null&&(Y=Bt.createElement("img",{src:k,key:k,style:{display:"none"},onLoad:()=>{M(!0)},ref:C,crossOrigin:I?.crossOrigin})),Bt.createElement(Bt.Fragment,null,Bt.createElement("canvas",XQ({style:z,height:i,width:i,ref:A,role:"img"},y)),Y)});bxn.displayName="QRCodeCanvas";var Eee=Bt.forwardRef(function(e,n){const r=e,{value:o,size:i=wBe,level:s=kBe,bgColor:a=OBe,fgColor:l=SBe,includeMargin:c=CBe,minVersion:u=ABe,boostLevel:d,title:h,marginSize:p,imageSettings:g}=r,_=KQ(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:x,cells:y,numCells:k,calculatedImageSettings:O}=MBe({value:o,level:s,minVersion:u,boostLevel:d,includeMargin:c,marginSize:p,imageSettings:g,size:i});let C=y,A=null;g!=null&&O!=null&&(O.excavation!=null&&(C=TBe(y,O.excavation)),A=Bt.createElement("image",{href:g.src,height:O.h,width:O.w,x:O.x+x,y:O.y+x,preserveAspectRatio:"none",opacity:O.opacity,crossOrigin:O.crossOrigin}));const E=EBe(C,x);return Bt.createElement("svg",XQ({height:i,width:i,viewBox:`0 0 ${k} ${k}`,ref:n,role:"img"},_),!!h&&Bt.createElement("title",null,h),Bt.createElement("path",{fill:a,d:`M0,0 h${k}v${k}H0z`,shapeRendering:"crispEdges"}),Bt.createElement("path",{fill:l,d:E,shapeRendering:"crispEdges"}),A)});Eee.displayName="QRCodeSVG";function _xn(t){const e=[],n=new Set,r=o=>{n.has(o.url)||(n.add(o.url),e.push(o))};t.publicUrl&&r({url:t.publicUrl,label:`Public URL (${t.publicUrl})`,source:"public"}),r({url:t.pageOrigin,label:`This page (${t.pageOrigin})`,source:"page"});for(const o of t.interfaces)r({url:o.url,label:o.kind==="bridge"?`${o.label} · virtual network`:o.label,source:"interface",kind:o.kind});for(const o of t.custom)r({url:o,label:`Custom (${o})`,source:"custom"});return e}function xxn(t,e){return(e?t.find(r=>r.url===e):void 0)??t.find(r=>r.source==="public")??t.find(r=>r.source==="page")??t[0]}function yxn(t,e){return`${t.replace(/\/+$/,"")}/?pair=${encodeURIComponent(e)}`}const eO=t=>t instanceof Error?t.message:String(t);function PBe(){return i1()?.origin??window.location.origin}const ype=()=>`band.pairing-address:${PBe()}`;function wxn(t){try{const e=new URL(t).hostname;return e==="localhost"||e==="::1"||e==="[::1]"||/^127\./.test(e)}catch{return!1}}function kxn(t){return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Oxn({device:t,onClose:e}){const[n,r]=v.useState(null),[o,i]=v.useState(null),[s,a]=v.useState(null),[l,c]=v.useState(null),[u,d]=v.useState(""),[h,p]=v.useState(!1),g=v.useCallback(async E=>{c(null);try{const M=await Se.tokens.pairing.mutate({tokenId:t.id,regenerate:E});r({code:M.code,expiresAt:M.expiresAt})}catch(M){c(eO(M))}},[t.id]),_=v.useCallback(async()=>{try{i(await Se.tokens.pairingAddresses.query())}catch(E){c(eO(E))}},[]);v.useEffect(()=>{g(!1),_()},[g,_]),v.useEffect(()=>{if(!n)return;const E=Math.max(0,n.expiresAt-Date.now())+250,M=setTimeout(()=>{g(!1)},E);return()=>clearTimeout(M)},[n,g]);const x=v.useMemo(()=>o?_xn({publicUrl:o.publicUrl,pageOrigin:PBe(),interfaces:o.interfaces,custom:o.custom}):[],[o]),y=v.useMemo(()=>(s?x.find(M=>M.url===s):void 0)??xxn(x,localStorage.getItem(ype())),[x,s]),k=E=>{a(E),localStorage.setItem(ype(),E)},O=n&&y?yxn(y.url,n.code):null,C=async()=>{c(null);try{const E=await Se.tokens.addPairingAddress.mutate({url:u});await _(),k(E.url),d(""),p(!1)}catch(E){c(eO(E))}},A=async E=>{c(null);try{await Se.tokens.removePairingAddress.mutate({url:E}),s===E&&a(null),await _()}catch(M){c(eO(M))}};return f.jsx(nr,{open:!0,onOpenChange:E=>E?void 0:e(),children:f.jsxs(rr,{className:"sm:max-w-[440px]","data-testid":"settings__pairing-dialog",children:[f.jsxs(hr,{children:[f.jsxs(or,{children:["Connect ",t.label||t.id]}),f.jsx(Nr,{children:"Open the link or scan the code on the device. It works once and expires in 15 minutes. Opening it signs that device in and replaces its previous token."})]}),f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{className:"space-y-1",children:[f.jsx("label",{className:"block text-xs font-medium",htmlFor:"pairing-address",children:"Address"}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx("select",{id:"pairing-address","data-testid":"settings__pairing-address",className:"h-8 min-w-0 flex-1 rounded-md border border-input bg-background px-2 text-xs",value:y?.url??"",onChange:E=>k(E.target.value),children:x.map(E=>f.jsx("option",{value:E.url,"data-testid":"settings__pairing-option","data-source":E.source,"data-kind":E.kind,children:E.label},E.url))}),f.jsx(Ce,{type:"button",variant:"outline",size:"sm","aria-label":"Refresh network interfaces",onClick:()=>{_()},children:f.jsx($0,{className:"size-3"})})]}),f.jsx("div",{className:"flex items-center gap-2",children:h?f.jsxs(f.Fragment,{children:[f.jsx(Sn,{"aria-label":"Custom address",placeholder:"https://band.example.ts.net",value:u,onChange:E=>d(E.target.value),className:"h-8 text-xs"}),f.jsx(Ce,{type:"button",size:"sm",disabled:u.trim()==="",onClick:()=>{C()},children:"Save address"}),f.jsx(Ce,{type:"button",variant:"ghost",size:"sm","data-testid":"settings__pairing-cancel-custom",onClick:()=>p(!1),children:"Cancel"})]}):f.jsxs(f.Fragment,{children:[f.jsx(Ce,{type:"button",variant:"ghost",size:"sm","data-testid":"settings__pairing-add-custom",onClick:()=>p(!0),children:"Add custom address…"}),y?.source==="custom"?f.jsx(Ce,{type:"button",variant:"ghost",size:"sm","data-testid":"settings__pairing-remove-custom",onClick:()=>{A(y.url)},children:"Remove this address"}):null]})})]}),y&&wxn(y.url)?f.jsxs("p",{role:"alert",className:"text-xs text-destructive",children:[y.url," is only reachable from this machine. Pick another address for a phone or another computer."]}):null,O?f.jsxs("div",{className:"space-y-3","data-testid":"settings__pairing-result",children:[f.jsx("div",{className:"flex justify-center rounded-lg bg-white p-3",children:f.jsx(Eee,{value:O,size:200,"data-testid":"settings__pairing-qr","data-value":O})}),f.jsx("label",{className:"block text-xs font-medium",htmlFor:"pairing-link",children:"Connect link"}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx(Sn,{id:"pairing-link",readOnly:!0,value:O,"data-testid":"settings__pairing-link",className:"h-8 font-mono text-xs"}),f.jsxs(Ce,{type:"button",variant:"outline",size:"sm","data-testid":"settings__pairing-copy",onClick:()=>{navigator.clipboard?.writeText(O).catch(()=>{})},children:[f.jsx(z0,{className:"size-3"}),"Copy"]})]}),f.jsxs("p",{className:"text-xs text-muted-foreground","data-testid":"settings__pairing-expiry",children:["Expires at ",kxn(n?.expiresAt??0),"."]})]}):null,l?f.jsx("p",{role:"alert",className:"text-xs text-destructive","data-testid":"settings__pairing-error",children:l}):null]}),f.jsxs(ii,{children:[f.jsx(Ce,{type:"button",variant:"outline",size:"sm","data-testid":"settings__pairing-regenerate",onClick:()=>{g(!0)},children:"Regenerate"}),f.jsx(Ce,{type:"button",size:"sm",onClick:e,children:"Done"})]})]})})}function _n({label:t,description:e,leadingIcon:n,htmlFor:r,variant:o="inline",children:i,className:s}){const a=(t||e)&&f.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[t?f.jsx(To,{htmlFor:r,className:"text-sm font-medium leading-tight text-foreground",children:t}):null,e?f.jsx("p",{className:"text-xs leading-snug text-muted-foreground",children:e}):null]});return o==="stacked"?f.jsxs("div",{"data-slot":"settings-row",className:Ze("space-y-2.5 px-4 py-3.5",s),children:[f.jsxs("div",{className:"flex items-start gap-3",children:[n?f.jsx("div",{className:"mt-0.5 shrink-0",children:n}):null,a]}),i?f.jsx("div",{children:i}):null]}):o==="responsive"?f.jsxs("div",{"data-slot":"settings-row",className:Ze("flex flex-col gap-2.5 px-4 py-3.5","sm:flex-row sm:items-center sm:gap-4 sm:py-3",s),children:[n?f.jsx("div",{className:"shrink-0 sm:mt-0",children:n}):null,a,i?f.jsx("div",{className:"sm:shrink-0",children:i}):null]}):f.jsxs("div",{"data-slot":"settings-row",className:Ze("flex items-center gap-4 px-4 py-3",s),children:[n?f.jsx("div",{className:"shrink-0",children:n}):null,a,i?f.jsx("div",{className:"shrink-0",children:i}):null]})}const O$=["tokens.list"],jBe=["tokens.current"],wpe=t=>t instanceof Error?t.message:String(t);function kpe(t){return t==null?"Never":new Date(t).toLocaleString()}function fu(){return It({queryKey:jBe,queryFn:()=>Se.tokens.current.query(),staleTime:6e4}).data?.admin===!0}function Sxn(){const t=Rn(),e=It({queryKey:jBe,queryFn:()=>Se.tokens.current.query()}),r=(It({queryKey:O$,queryFn:async()=>(await Se.tokens.list.query()).tokens,refetchInterval:5e3}).data??[]).filter(E=>E.kind==="device"),[o,i]=v.useState(null),[s,a]=v.useState(!1),[l,c]=v.useState("Phone"),[u,d]=v.useState(!1),[h,p]=v.useState(null),[g,_]=v.useState(!1),[x,y]=v.useState(null),k=async()=>{await t.cancelQueries({queryKey:O$}),await t.invalidateQueries({queryKey:O$})},O=()=>{a(!1),c("Phone"),d(!1),i(null)},C=async()=>{_(!0),i(null);try{const{view:E}=await Se.tokens.createUnpairedDevice.mutate({label:l.trim(),admin:u});O(),p({id:E.id,label:E.label}),await k()}catch(E){i(wpe(E))}finally{_(!1)}},A=async E=>{i(null),y(null);try{await Se.tokens.revoke.mutate({tokenId:E.id})}catch(M){i(wpe(M))}await k()};return e.data&&!e.data.admin?f.jsx("p",{role:"alert",className:"text-xs text-muted-foreground","data-testid":"settings__devices-denied",children:"Managing devices needs an admin token."}):f.jsxs(f.Fragment,{children:[f.jsx(_n,{variant:"stacked",label:"Add device",description:"Connect a phone, tablet or another browser with a one-time link and QR code.",children:f.jsxs(Ce,{type:"button",variant:"outline",size:"sm","data-testid":"settings__add-device",onClick:()=>a(!0),children:[f.jsx(wl,{className:"size-3"}),"Add device"]})}),f.jsxs(_n,{variant:"stacked",label:"Devices",description:"Revoking a device signs it out and removes it. The shared token in settings.json cannot be revoked here.",children:[f.jsx("ul",{className:"divide-y divide-border rounded-md border border-border",children:r.map(E=>{const M=E.id===e.data?.tokenId,P=x===E.id;return f.jsxs("li",{"data-testid":"settings__device","data-token-id":E.id,"data-state":E.state,"data-current":M?"true":void 0,"data-confirming":P?M?"self":"other":void 0,className:"flex items-center justify-between gap-2 px-3 py-2 text-sm",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsxs("div",{className:"truncate",children:[E.label||E.id,M?f.jsx("span",{"data-testid":"settings__device-this",className:"ml-2 rounded bg-secondary px-1.5 py-0.5 text-xs",children:"This device"}):null]}),f.jsxs("div",{className:"text-xs text-muted-foreground",children:[E.admin?"Admin":"Standard"," · ",E.state," · Added"," ",kpe(E.createdAt)," · Last used ",kpe(E.lastUsedAt)]}),P?f.jsx("p",{role:"alert",className:"mt-1 text-xs text-destructive",children:M?"This is the token you are signed in with. Revoking it signs you out here.":"Revoking signs this device out and removes it from the list."}):null]}),f.jsx("div",{className:"flex shrink-0 items-center gap-1",children:P?f.jsxs(f.Fragment,{children:[f.jsx(Ce,{type:"button",variant:"destructive",size:"sm","aria-label":`Confirm revoke ${E.label||E.id}`,onClick:()=>{A(E)},children:"Revoke"}),f.jsx(Ce,{type:"button",variant:"ghost",size:"sm",onClick:()=>y(null),children:"Cancel"})]}):f.jsxs(f.Fragment,{children:[E.id==="shared"?null:f.jsx(Ce,{type:"button",variant:"outline",size:"sm","aria-label":`Connect details ${E.label||E.id}`,onClick:()=>p({id:E.id,label:E.label}),children:"Connect details"}),f.jsx(Ce,{type:"button",variant:"outline",size:"sm","aria-label":`Revoke device ${E.label||E.id}`,disabled:E.state!=="active"||E.id==="shared",onClick:()=>y(E.id),children:"Revoke"})]})})]},E.id)})}),o&&!s?f.jsx("p",{role:"alert",className:"mt-2 text-xs text-destructive",children:o}):null]}),f.jsx(nr,{open:s,onOpenChange:E=>E?a(!0):O(),children:f.jsxs(rr,{className:"sm:max-w-[420px]","data-testid":"settings__add-device-dialog",children:[f.jsxs(hr,{children:[f.jsx(or,{children:"Add device"}),f.jsx(Nr,{children:"Name the device. You get a link and QR code to connect it next. You can revoke it from this list later."})]}),f.jsxs("div",{className:"space-y-3",children:[f.jsx(Sn,{"aria-label":"Device label",placeholder:"Label",value:l,onChange:E=>c(E.target.value),className:"h-8 text-sm"}),f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsx("label",{htmlFor:"device-admin",className:"text-sm",children:"Admin device"}),f.jsx(Hi,{id:"device-admin",checked:u,onCheckedChange:d})]}),u?f.jsx("p",{role:"alert",className:"text-xs text-destructive",children:"An admin device can create and revoke devices, workers and credentials. Give it to devices you trust as much as this one."}):null,o?f.jsx("p",{role:"alert",className:"text-xs text-destructive",children:o}):null,f.jsxs(ii,{children:[f.jsx(Ce,{type:"button",variant:"ghost",size:"sm",onClick:O,children:"Cancel"}),f.jsx(Ce,{type:"button",size:"sm",disabled:g||l.trim()==="",onClick:()=>{C()},children:"Create device"})]})]})]})}),h?f.jsx(Oxn,{device:h,onClose:()=>{p(null),k()}}):null]})}const Cxn=t=>t instanceof Error?t.message:String(t);function Axn({open:t,onOpenChange:e,repoName:n,worktree:r,initialTarget:o}){const{repos:i}=xs(),s=Aee(),a={name:n,allowedHostIds:i.find(V=>V.name===n)?.allowedHostIds},l=Rn(),c=Gs(),u=fu(),d=fBe(),h=r.hostId??"local",p=jr(a.name,r.name,r.hostId),g=d.filter(V=>V.status==="online"&&V.id!==h&&V.id!=="local"),[_,x]=v.useState(o??""),[y,k]=v.useState(!1),[O,C]=v.useState(!1),[A,E]=v.useState(null),[M,P]=v.useState(!1),[L,D]=v.useState(null),I=_||g[0]?.id||"",z=a.allowedHostIds??null,Y=I!==""&&z!==null&&!z.includes(I),Q=V=>d.find(G=>G.id===V)?.name||V,H=async()=>{C(!0),E(null);try{const V={worktreeId:p,toHostId:I,...y?{addHost:!0}:{}};D(await Se.checkpoints.move.mutate(V)),await l.invalidateQueries({queryKey:["repos"]})}catch(V){E(Cxn(V)),V.data?.code==="PRECONDITION_FAILED"&&Y&&P(!0)}finally{C(!1)}},N=()=>{if(!L)return;const V=c.getWorktreeHref?.(L.worktreeId);V&&c.navigate&&c.navigate(V),e(!1)};return f.jsx(nr,{open:t,onOpenChange:e,children:f.jsxs(rr,{className:"sm:max-w-[480px]","data-testid":"move-worktree__dialog",children:[f.jsxs(hr,{children:[f.jsx(or,{children:"Open on another worker"}),f.jsxs(Nr,{children:["Takes a fresh checkpoint of ",r.name,", recreates it on the chosen host with its uncommitted files and agent sessions, then removes the copy on ",Q(h),"."]}),f.jsx("p",{className:"text-xs text-muted-foreground","data-testid":"move-worktree__ignored-files",children:"Ignored files (node_modules, build output, .env) are not carried over."})]}),L?f.jsxs("div",{className:"space-y-2","data-testid":"move-worktree__result",children:[f.jsxs("p",{className:"text-sm",children:["Moved to ",Q(L.hostId)," as"," ",f.jsx("span",{className:"font-mono",children:s(L.worktreeId).name}),"."]}),L.warning?f.jsx("p",{role:"alert",className:"text-xs text-destructive","data-testid":"move-worktree__warning",children:L.warning}):null,f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>e(!1),children:"Close"}),f.jsx(Ce,{size:"sm","data-testid":"move-worktree__open",onClick:N,children:"Open worktree"})]})]}):f.jsxs("div",{className:"space-y-3",children:[g.length===0?f.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"move-worktree__no-hosts",children:"No other worker is online."}):f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(To,{htmlFor:"move-worktree-host",children:"Target worker"}),f.jsx("select",{id:"move-worktree-host","data-testid":"move-worktree__host",className:"h-8 w-full rounded-md border border-border bg-transparent px-2 text-sm",value:I,disabled:O,onChange:V=>{x(V.target.value),k(!1),P(!1),E(null)},children:g.map(V=>f.jsx("option",{value:V.id,children:V.name||V.id},V.id))})]}),Y||M?f.jsxs("div",{className:"space-y-1","data-testid":"move-worktree__add-host",children:[f.jsxs("p",{className:"text-xs text-muted-foreground",children:[a.name," is not allowed on ",Q(I),"."]}),f.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[f.jsx("input",{type:"checkbox",checked:y,disabled:!u||O,"data-testid":"move-worktree__add-host-checkbox",onChange:V=>k(V.target.checked)}),"Add ",Q(I)," to ",a.name,"'s allowed hosts"]}),u?null:f.jsx("p",{className:"text-xs text-muted-foreground",children:"Adding a worker needs an admin token."})]}):null,A?f.jsx("p",{role:"alert",className:"text-xs text-destructive","data-testid":"move-worktree__error",children:A}):null,f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>e(!1),children:"Cancel"}),f.jsxs(Ce,{size:"sm","data-testid":"move-worktree__submit",disabled:O||I===""||Y&&!y,onClick:()=>{H()},children:[O?f.jsx(wo,{className:"size-3"}):null,"Open on another worker"]})]})]})]})})}function Exn(t,e){if(t.state==="merged")return"merged";if(t.state==="closed")return"closed";switch(e){case"failure":return"failure";case"running":case"pending":return"pending";case"success":return"success";default:return"neutral"}}const Ope={failure:"text-danger border-danger/40 bg-danger-bg",pending:"text-warning border-warning/40 bg-warning-bg",success:"text-success border-success/40 bg-success-bg",neutral:"text-muted-foreground border-border bg-muted/50",merged:"text-merged border-merged/40 bg-merged-bg",closed:"text-muted-foreground border-border bg-muted/50 line-through"},NBe="inline-flex items-center rounded border px-1 py-px leading-none",Spe=`${NBe} text-[11px] font-semibold tabular-nums`;function Cpe(t,e){if(t.state==="merged")return"Merged";if(t.state==="closed")return"Closed";switch(e){case"failure":return"Checks failing";case"running":return"Checks running";case"pending":return"Checks pending";case"success":return"Checks passed";case"cancelled":return"Checks cancelled";default:return"No checks"}}const Txn=400,S$=200;function Mxn({pr:t,ciState:e,onOpenChecks:n}){const r=Gs(),[o,i]=v.useState(!1),[s,a]=v.useState(!1),l=v.useRef(null),c=v.useRef(null),u=v.useRef(null),d=v.useRef(!1),h=()=>{u.current&&clearTimeout(u.current),u.current=null},p=(y,k)=>{h(),u.current=setTimeout(()=>i(y),k)};v.useEffect(()=>()=>{u.current&&clearTimeout(u.current)},[]),v.useEffect(()=>{if(!s)return;const y=setTimeout(()=>a(!1),1500);return()=>clearTimeout(y)},[s]);const g=Exn(t,e),_=`Pull request #${t.number}: ${Cpe(t,e)}${t.isDraft?", draft":""}`,x=y=>y instanceof Node&&(c.current?.contains(y)||l.current?.contains(y));return f.jsxs(t0,{open:o,onOpenChange:i,children:[f.jsx(Lxe,{asChild:!0,children:f.jsxs("button",{ref:l,type:"button","aria-label":_,"aria-haspopup":"dialog","aria-expanded":o,"data-testid":"worktree-card__pr-badge","data-tone":g,className:`shrink-0 outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring ${Spe} ${Ope[g]}`,onPointerEnter:y=>{y.pointerType!=="touch"&&p(!0,Txn)},onPointerLeave:y=>{y.pointerType!=="touch"&&p(!1,S$)},onFocus:y=>{if(d.current){d.current=!1;return}y.currentTarget.matches(":focus-visible")&&(h(),i(!0))},onBlur:y=>{x(y.relatedTarget)||p(!1,S$)},onClick:y=>{y.stopPropagation(),h(),i(!1),n()},onKeyDown:y=>{y.key==="ArrowDown"&&o&&(y.preventDefault(),c.current?.querySelector("button")?.focus()),(y.key==="Enter"||y.key===" "||y.key.startsWith("Arrow"))&&y.stopPropagation()},children:["#",t.number]})}),f.jsxs(n0,{ref:c,side:"right",align:"start",className:"w-72 p-3","data-testid":"pr-popover",onOpenAutoFocus:y=>y.preventDefault(),onCloseAutoFocus:y=>y.preventDefault(),onEscapeKeyDown:()=>{c.current?.contains(document.activeElement)&&(d.current=!0,l.current?.focus())},onFocusOutside:y=>{x(y.target)&&y.preventDefault()},onPointerEnter:h,onPointerLeave:y=>{y.pointerType!=="touch"&&p(!1,S$)},onBlur:y=>{x(y.relatedTarget)||i(!1)},onClick:y=>y.stopPropagation(),onKeyDown:y=>y.stopPropagation(),onContextMenu:y=>y.stopPropagation(),children:[f.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[f.jsxs("span",{"data-testid":"pr-popover__number","data-tone":g,className:`${Spe} ${Ope[g]}`,children:["#",t.number]}),t.isDraft&&f.jsx("span",{"data-testid":"pr-popover__draft",className:`${NBe} border-border text-[10px] font-medium text-muted-foreground`,children:"Draft"}),f.jsx("span",{"data-testid":"pr-popover__status","data-status":t.state==="open"?e:t.state,className:"text-muted-foreground",children:Cpe(t,e)})]}),f.jsx("p",{"data-testid":"pr-popover__title",className:"mt-1.5 line-clamp-3 break-words text-[13px] font-medium text-foreground",children:t.title}),f.jsxs("div",{className:"mt-2 -ml-1.5 flex items-center gap-1",children:[r.openUrl&&f.jsxs(Ce,{variant:"ghost",size:"xs","data-testid":"pr-popover__open",onClick:()=>{i(!1),r.openUrl?.(t.url)},children:[f.jsx(gM,{}),"Open on GitHub"]}),f.jsxs(Ce,{variant:"ghost",size:"xs","data-testid":"pr-popover__copy","data-copied":s||void 0,onClick:()=>{Vs(t.url).then(y=>a(y))},children:[s?f.jsx(Ji,{}):f.jsx(Pot,{}),s?"Copied":"Copy link"]})]})]})]})}const RBe=6;function Pxn(t){const e=t.match(/[\p{L}\p{N}]/u);return e?e[0].toUpperCase():"?"}function jxn(t){let e=0;for(const n of t)e=e*31+(n.codePointAt(0)??0)>>>0;return e%RBe}function Nxn({name:t,className:e,textClassName:n="text-[9px]",testId:r}){const o=jxn(t)%RBe;return f.jsx("span",{"aria-hidden":!0,"data-testid":r,"data-color-index":o,className:`${e} flex shrink-0 select-none items-center justify-center rounded-sm font-semibold leading-none ${n}`,style:{backgroundColor:`var(--repo-avatar-${o+1})`,color:"var(--repo-avatar-foreground)"},children:Pxn(t)})}function m8({name:t,avatar:e,fallback:n,className:r,textClassName:o,testId:i}){const[s,a]=v.useState(null),l=n??f.jsx(Nxn,{name:t,className:r,textClassName:o,testId:i?`${i}-fallback`:void 0});if(!e)return f.jsx(f.Fragment,{children:l});const c=s?.src===e.src?s.ok:void 0;return f.jsxs(f.Fragment,{children:[c!==!0&&l,c!==!1&&f.jsx("img",{src:lh(e.src),alt:e.label,hidden:c!==!0,draggable:!1,"data-testid":i,ref:u=>{u?.complete&&c===void 0&&a({src:e.src,ok:u.naturalWidth>0})},className:`${r} shrink-0 rounded-sm object-cover`,onLoad:()=>a({src:e.src,ok:!0}),onError:()=>a({src:e.src,ok:!1})})]})}function JQ({testId:t="worktree-card__root-star"}){return f.jsxs(Or,{delayDuration:200,children:[f.jsx(Sr,{asChild:!0,children:f.jsx("span",{role:"img","aria-label":"Repository root","data-testid":t,className:"inline-flex shrink-0 items-center text-muted-foreground",children:f.jsx($it,{className:"size-3"})})}),f.jsx(Cr,{side:"top","data-testid":"worktree-card__root-star-tooltip",children:"Repository root"})]})}function Rxn(t,e){const n=new Map;for(const i of t)for(const s of i.worktrees)n.set(jr(i.name,s.name,s.hostId),s.children??[]);const r=new Set([e]),o=[e];for(let i=o.pop();i!==void 0;i=o.pop())for(const s of n.get(i)??[])r.has(s)||(r.add(s),o.push(s));return r}function Lxn({open:t,onOpenChange:e,repoName:n,worktree:r}){const{repos:o}=xs(),i=Rn(),s=sN(),[a,l]=v.useState(null),[c,u]=v.useState(!1),d=jr(n,r.name,r.hostId),h=v.useMemo(()=>{const _=Rxn(o,d);return o.flatMap(x=>x.worktrees.map(y=>({worktreeId:jr(x.name,y.name,y.hostId),repoName:x.name,name:y.name,branch:y.branch,hostId:y.hostId})).filter(y=>!_.has(y.worktreeId)))},[o,d]),p=new Set(o.flatMap(_=>_.worktrees.map(x=>x.hostId??"local"))).size>1,g=async _=>{u(!0),l(null);try{await Se.worktrees.setOrigin.mutate({repo:n,name:r.name,hostId:r.hostId,origin:_}),e(!1),await i.invalidateQueries({queryKey:Un.repos})}catch(x){l(x instanceof Error?x.message:String(x))}finally{u(!1)}};return f.jsx(nr,{open:t,onOpenChange:e,children:f.jsxs(rr,{variant:"command-palette",className:"overflow-hidden p-0 lg:max-w-[520px]",showCloseButton:!1,"data-testid":"set-parent__dialog",children:[f.jsxs(hr,{className:"sr-only",children:[f.jsx(or,{children:"Set parent"}),f.jsxs(Nr,{children:["Choose the worktree ",r.name," was started from"]})]}),f.jsxs(S4,{shouldFilter:!0,children:[f.jsx(zg,{placeholder:`Set parent of ${r.name}...`}),f.jsxs(jh,{className:"max-h-[360px]",children:[f.jsx(C4,{children:"No worktrees found."}),h.map(_=>f.jsxs(M0,{value:`${_.repoName} ${_.name} ${_.branch} ${p?s(_.hostId==="local"?void 0:_.hostId):""}`,disabled:c,onSelect:()=>{g(_.worktreeId)},"data-testid":`set-parent__item--${_.worktreeId}`,children:[f.jsxs("span",{className:"truncate",children:[_.repoName," · ",_.name]}),p&&f.jsx("span",{className:"ml-auto shrink-0 text-xs text-muted-foreground",children:s(_.hostId==="local"?void 0:_.hostId)})]},_.worktreeId))]})]}),a&&f.jsx("p",{role:"alert",className:"px-3 pb-2 text-xs text-destructive","data-testid":"set-parent__error",children:a})]})})}function Ixn({setup:t}){return t?t.state==="running"?f.jsxs(Or,{children:[f.jsx(Sr,{asChild:!0,children:f.jsx(H2,{className:"size-3.5 shrink-0 text-info animate-spin"})}),f.jsx(Cr,{side:"top",children:"Setting up worktree..."})]}):t.state==="failed"?f.jsxs(Or,{children:[f.jsx(Sr,{asChild:!0,children:f.jsx(_u,{className:"size-3.5 shrink-0 text-danger"})}),f.jsxs(Cr,{side:"top",children:["Setup failed",t.error?`: ${t.error}`:""]})]}):null:null}function Tee({name:t,repoName:e,isActive:n,tone:r="sidebar",repoIcon:o,hostTag:i}){const s=r==="switcher"?`text-foreground ${n?"font-semibold":"font-medium"}`:n?"font-bold text-foreground":"font-medium text-foreground/75",a=r==="switcher"?"text-foreground/70":n?"text-foreground/80":"text-foreground/60",l=r==="sidebar";return f.jsxs("div",{"data-testid":"worktree-label",className:"flex flex-col min-w-0 leading-tight",children:[f.jsx("span",{"data-testid":"worktree-label__name",className:Ze(l?"text-[13px]":"text-sm","truncate",s),children:t}),f.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[o,f.jsx("span",{"data-testid":"worktree-label__repo",className:Ze(l?"text-[11px]":"text-xs","truncate",a),children:e}),i&&f.jsx("span",{"data-testid":"worktree-label__host",className:"shrink-0 rounded bg-muted px-1 text-[10px] leading-4 text-muted-foreground",children:i})]})]})}const Dxn=300;let WE=null,c3=null;function LBe(t){WE=t,c3&&clearTimeout(c3),c3=setTimeout(()=>{WE=null,c3=null},Dxn)}function zxn(t){return WE!==t?!1:(WE=null,c3&&(clearTimeout(c3),c3=null),!0)}function lv({testId:t,label:e,details:n,attrs:r,children:o}){return f.jsxs(Or,{delayDuration:300,children:[f.jsx(Sr,{asChild:!0,children:f.jsx("span",{"data-testid":t,role:"img","aria-label":e,...r,className:"flex shrink-0 items-center ml-auto pl-2 text-muted-foreground",children:o})}),f.jsx(Cr,{side:"right","data-testid":`${t}-details`,children:n??e})]})}const IBe=v.memo(function({worktree:e,repoName:n,defaultBranch:r,repoKind:o,status:i,branchStatus:s,setupStatus:a,isFocused:l,onShowDeleteDialog:c,showRepoName:u,repoAvatar:d,hostTag:h,allowedHostIds:p,chevronGutter:g,onTogglePinned:_}){const x=o==="plain",y=H_n(e.hostId),k=h??y,O=v.useRef(null),C=Gs(),A=Cn(Le=>Le.openWorktree),E=Cn(Le=>Le.clearNeedsAttention),M=Cn(Le=>Le.runScript),P=Cn(Le=>Le.gitPull),L=Cn(Le=>Le.gitPush),D=oBe(),I=e.pinned,z=hBe(e.hostId),Y=z.offline,Q=e.supersededBy,H=e.lastCheckpointAt??null,[N,V]=v.useState(!1),[G,K]=v.useState(!1),q=Rn(),Z=Cn(Le=>Le.setError),[U,B]=v.useState(!1),ee=e.divergence?.state==="diverged",te=!!e.hostId&&e.hostId!=="local"&&!Q,se=z.name||e.hostId||"this worker",ae=te?Y?"offline":"move":null,he=ae===null?null:p?.every(Le=>Le===e.hostId)?`Only available on ${se}`:ae==="offline"&&H===null?"The hub has no checkpoint of this worktree":null,[fe,be]=v.useState(null),me=()=>{if(ae==="move"){V(!0);return}Se.follow.offer.query({worktreeId:jr(n,e.name,e.hostId)}).then(be).catch(Le=>Z(Le))},le=!x&&e.name===r,Be=jr(n,e.name,e.hostId),Xe=Cn(Le=>Le.activeWorktreeId===Be),ot=B_n(Be,e.continuedFrom?.at??0,Xe&&!!e.continuedFrom),Qe=sN(),lt=Cn(Le=>Bye(Le,Be)),bt=C.getWorktreeHref?.(Be);v.useEffect(()=>{Xe&&(zxn(Be)||O.current?.scrollIntoView({block:"center"}))},[Xe,Be]);const ve=()=>{lt||(E(Be),LBe(Be),bt&&C.navigate?C.navigate(bt):bt||A(Be))},Te=()=>{lt||(K_n(Be),Xe||ve())},Ne={ref:O,className:`@container group flex flex-row items-center justify-between rounded-md ${g?"pl-5":"pl-3"} pr-2 py-1 min-h-9 min-w-0 overflow-hidden select-none touch-manipulation transition-colors ${lt?"cursor-not-allowed opacity-50":`cursor-pointer hover:bg-accent/50 ${Y&&!Q?"opacity-60":""}`} [@media(pointer:coarse)]:min-h-11 [@media(pointer:coarse)]:py-2 ${Xe?"bg-selection text-selection-foreground outline outline-1 -outline-offset-1 outline-selection-border hover:bg-selection":l?"bg-accent":""} ${bt?"no-underline text-inherit":""}`,tabIndex:lt?-1:0,"aria-disabled":lt||void 0,"data-deleting":lt||void 0,"data-active":Xe||void 0,"aria-current":Xe?"page":void 0,"data-testid":`repo-list__worktree-card--${Be}`,onClick:Le=>{Le.stopPropagation(),ve()},onKeyDown:Le=>{(Le.key==="Enter"||Le.key===" ")&&(Le.stopPropagation(),ve())}},$e=s?.ci.state,De=$e!==void 0&&$e!=="none"&&$e!=="merged",ct=s?.git.dirty??!1,ue=(s?.git.ahead??0)>0,Pe=()=>{Se.worktrees.setOrigin.mutate({repo:n,name:e.name,hostId:e.hostId,origin:null}).then(()=>q.invalidateQueries({queryKey:Un.repos})).catch(Le=>Z(Le))},Ee=()=>{!De&&!ct&&!ue?D.mutate({repo:n,name:e.name,hostId:e.hostId}):c({repoName:n,name:e.name,hostId:e.hostId,isUnmerged:De,isDirty:ct,hasUnpushedCommits:ue})};return f.jsxs(J0,{children:[f.jsx(e1,{asChild:!0,disabled:lt,children:f.jsxs("div",{...Ne,children:[f.jsxs(Or,{delayDuration:800,children:[f.jsx(Sr,{asChild:!0,children:f.jsxs("div",{className:"flex flex-1 items-center gap-2 min-w-0 overflow-hidden",children:[f.jsx(_G,{agent:i?.agent,tabStatuses:i?.tabStatuses}),u?f.jsxs(f.Fragment,{children:[f.jsx(Tee,{name:e.name,repoName:n,isActive:Xe,hostTag:k,repoIcon:f.jsx(m8,{name:n,avatar:d,className:"size-3 shrink-0 rounded-sm",textClassName:"text-[7px]",testId:`worktree-label__avatar--${n}`})}),le&&f.jsx(JQ,{})]}):f.jsxs(f.Fragment,{children:[f.jsx("span",{className:`text-[13px] truncate ${Xe?"font-bold text-foreground":"font-medium text-foreground/75"}`,children:e.name}),le&&f.jsx(JQ,{}),k&&f.jsx("span",{"data-testid":"worktree-label__host",className:"shrink-0 rounded bg-muted px-1 text-[10px] leading-4 text-muted-foreground",children:k})]})]})}),f.jsx(Cr,{side:"right",children:`${n}/${e.name}`})]}),lt&&f.jsx(lv,{testId:"worktree-card__deleting",label:"Deleting",children:f.jsx(H2,{className:"size-3.5 animate-spin"})}),e.lifecycle&&!lt&&f.jsx(lv,{testId:"worktree-card__lifecycle",label:e.lifecycle==="waking"?"Waking":"Sleeping",attrs:{"data-lifecycle":e.lifecycle},children:e.lifecycle==="waking"?f.jsx(H2,{className:"size-3.5 animate-spin"}):f.jsx(Yot,{className:"size-3.5"})}),e.continuedFrom&&!lt&&ot&&f.jsx(exn,{from:e.continuedFrom,testId:"worktree-card__continued-from"}),Q&&!lt&&f.jsx(lv,{testId:"worktree-card__superseded",label:`Superseded by ${Q}`,details:`Restored as ${Q}. The files on this worker are untouched.`,attrs:{"data-superseded-by":Q},children:f.jsx(yit,{className:"size-3.5"})}),Q&&ee&&!lt&&f.jsx("button",{type:"button","data-testid":"worktree-card__diverged","aria-label":"Diverged: this copy changed after the checkpoint",title:"Diverged: this copy changed after the checkpoint",className:"flex shrink-0 items-center pl-2 text-destructive",onClick:Le=>{Le.stopPropagation(),B(!0)},children:f.jsx(iae,{className:"size-3.5"})}),e.hostNotAllowed&&!lt&&f.jsx(lv,{testId:"worktree-card__not-allowed",label:"Not allowed on this worker",details:"This repo is no longer allowed on this worker. The worktree is kept and still opens.",children:f.jsx($7e,{className:"size-3.5"})}),e.missing&&!lt&&f.jsx(lv,{testId:"worktree-card__missing",label:"Missing",details:"The worker no longer has this worktree's folder. Remove drops the record.",children:f.jsx(Aot,{className:"size-3.5"})}),f.jsxs("div",{className:`${lt?"hidden":"hidden @[10rem]:flex group-hover:flex group-focus-within:flex"} items-center gap-2 shrink-0 pl-2`,children:[f.jsx(Ixn,{setup:a}),!x&&s&&f.jsx(axn,{git:s.git}),!x&&s?.ci.pr&&f.jsx(Mxn,{pr:s.ci.pr,ciState:s.ci.state,onOpenChecks:Te}),!x&&s&&!s.ci.pr&&f.jsx(DTt,{ci:s.ci})]}),Y&&!Q&&!lt&&f.jsxs(Or,{delayDuration:300,children:[f.jsx(Sr,{asChild:!0,children:f.jsx("span",{"data-testid":"worktree-card__offline","data-checkpoint":H!==null?"true":"false",role:"img","aria-label":`${se} is offline`,className:"flex shrink-0 items-center pl-2 text-muted-foreground",children:f.jsx(V7e,{className:"size-3.5"})})}),f.jsxs(Cr,{side:"right","data-testid":"worktree-card__offline-details",children:[f.jsxs("div",{children:[se," is offline"]}),f.jsx("div",{children:z.lastSeenAt!==null?`Last seen ${ZQ(z.lastSeenAt)}`:"Never seen"}),f.jsx("div",{children:H!==null?`Last checkpoint ${ZQ(H)}`:"No checkpoint"})]})]})]})}),f.jsxs(t1,{children:[f.jsx(Vae,{children:"Worktree"}),e.continuedFrom&&f.jsx(Vae,{"data-testid":"worktree-card__continued-from-line",className:"font-normal text-muted-foreground",children:mBe(e.continuedFrom,Qe(e.continuedFrom.fromHostId))}),f.jsxs(Qn,{onClick:()=>_(n,e.name,I,e.hostId),children:[I?f.jsx(K7e,{}):f.jsx(vZ,{}),I?"Unpin worktree":"Pin worktree"]}),f.jsxs(Qn,{"data-testid":"worktree-card__set-parent",onClick:()=>requestAnimationFrame(()=>K(!0)),children:[f.jsx(Hrt,{}),"Set parent…"]}),e.origin&&f.jsxs(Qn,{"data-testid":"worktree-card__remove-parent",onClick:Pe,children:[f.jsx(Kit,{}),"Remove parent"]}),f.jsx(P0,{}),C.copyPath&&f.jsxs(Qn,{onClick:()=>navigator.clipboard.writeText(e.path),children:[f.jsx(q7e,{}),"Copy path"]}),C.revealInFinder&&f.jsxs(Qn,{onClick:()=>C.revealInFinder(e.path),children:[f.jsx(ld,{}),"Open in Finder"]}),e.hasSetup&&f.jsxs(Qn,{onClick:()=>M(e.path,"setup"),children:[f.jsx(J7e,{}),"Run setup"]}),e.hasTeardown&&f.jsxs(Qn,{onClick:()=>M(e.path,"teardown"),children:[f.jsx(nve,{}),"Run teardown"]}),!x&&f.jsxs(Qn,{onClick:()=>P(n,e.name,e.hostId),children:[f.jsx(Hnt,{}),"Git pull"]}),!x&&f.jsxs(Qn,{onClick:()=>L(n,e.name,e.hostId),children:[f.jsx(Unt,{}),"Git push"]}),ae&&!x&&f.jsxs(Qn,{"data-testid":"worktree-card__move",disabled:he!==null,onClick:me,children:[f.jsx(Jot,{}),f.jsxs("span",{className:"flex flex-col",children:["Open on another worker…",he?f.jsx("span",{"data-testid":"worktree-card__move-reason",className:"text-xs",children:he}):null]})]}),Q&&f.jsxs(Qn,{variant:"destructive","data-testid":"worktree-card__remove-superseded",onClick:()=>{window.confirm(`Remove this copy? The files of ${e.name} on its worker are deleted. The restored worktree ${Q} is not touched.`)&&D.mutate({repo:n,name:e.name,hostId:e.hostId})},children:[f.jsx(Kl,{}),"Remove this copy"]}),Q&&ee&&f.jsxs(Qn,{"data-testid":"worktree-card__review-divergence",onClick:()=>B(!0),children:[f.jsx(iae,{}),"Review changes made after the checkpoint"]}),e.missing&&!Q&&f.jsxs(Qn,{variant:"destructive","data-testid":"worktree-card__remove-missing",onClick:()=>D.mutate({repo:n,name:e.name,hostId:e.hostId}),children:[f.jsx(Kl,{}),"Remove missing worktree"]}),!x&&e.name!==r&&f.jsxs(Qn,{variant:"destructive",onClick:Ee,children:[f.jsx(Kl,{}),"Delete worktree"]})]}),Q&&U&&f.jsx(sxn,{open:U,onOpenChange:B,worktreeId:Be}),G&&f.jsx(Lxn,{open:G,onOpenChange:K,repoName:n,worktree:e}),fe&&f.jsx(Cee,{offer:fe,onClose:()=>{be(null)}}),ae==="move"&&N&&f.jsx(Axn,{open:N,onOpenChange:V,repoName:n,worktree:e})]})}),$xn=16,Bxn={grouped:10,pinned:6,ungrouped:0};function DBe({entry:t,mode:e,isFocused:n,hosts:r,statuses:o,branchStatuses:i,setupStatuses:s,onShowDeleteDialog:a,onTogglePinned:l}){return f.jsx(IBe,{worktree:t.worktree,repoName:t.repo.name,defaultBranch:t.repo.defaultBranch,repoKind:t.repo.kind,status:o.get(t.worktreeId),branchStatus:i.get(t.worktreeId),setupStatus:s.get(t.worktreeId),isFocused:n,onShowDeleteDialog:a,showRepoName:!0,repoAvatar:t.repo.avatar,hostTag:e==="repo"||bh(t.worktree)==="local"?void 0:zE(bh(t.worktree),r),allowedHostIds:t.repo.allowedHostIds,chevronGutter:!0,onTogglePinned:l})}function zBe({row:t,index:e,mode:n,originCollapse:r,hosts:o,statuses:i,branchStatuses:s,setupStatuses:a,focusedIndex:l,onShowDeleteDialog:c,onTogglePinned:u}){const{entry:d}=t,h=t.pinned===!0&&t.depth===0,p=Gs(),g=Cn(k=>k.openWorktree),_=k=>{const O=p.getWorktreeHref?.(k);O&&p.navigate?p.navigate(O):g(k)},x=t.pinned?"repo-list__pinned-row":"repo-list__grouped-row",y=Bxn[t.pinned?"pinned":t.ungrouped?"ungrouped":"grouped"]+t.depth*$xn;return f.jsx(cBe,{dndId:`${h?"pin":"wt"}:${d.worktreeId}`,disabled:n==="repo"&&t.depth>0,testId:`repo-list__drag-row--${d.worktreeId}`,className:t.pinned?void 0:"mr-2",data:{kind:h?"pin":"wt",worktreeId:d.worktreeId,repoName:d.repo.name,hostId:bh(d.worktree),inset:y},children:f.jsxs("div",{"data-testid":`${x}--${d.worktreeId}`,"data-depth":t.depth,"data-ungrouped":t.ungrouped||void 0,className:"flex min-w-0 flex-col",style:{paddingLeft:y},children:[f.jsxs("div",{className:"relative min-w-0",children:[t.childCount>0&&f.jsx("button",{type:"button","aria-label":t.collapsed?"Expand started worktrees":"Collapse started worktrees","aria-expanded":!t.collapsed,"data-testid":`repo-list__origin-toggle--${d.worktreeId}`,onClick:()=>r.toggle(d.worktreeId),className:"absolute left-0 top-1/2 z-10 flex size-5 -translate-y-1/2 items-center justify-center rounded text-muted-foreground hover:bg-accent/50",children:f.jsx(bo,{"data-testid":`repo-list__origin-toggle-icon--${d.worktreeId}`,className:`size-3 transition-transform ${t.collapsed?"":"rotate-90"}`})}),f.jsx(DBe,{entry:d,mode:n,isFocused:e===l,hosts:o,statuses:i,branchStatuses:s,setupStatuses:a,onShowDeleteDialog:c,onTogglePinned:u})]}),t.fromParent&&f.jsxs("button",{type:"button","data-testid":`repo-list__from-parent--${d.worktreeId}`,title:`Open ${t.fromParent.name}`,onClick:()=>_(t.fromParent.worktreeId),className:"ml-5 w-fit max-w-full truncate rounded px-1 text-left text-[11px] text-muted-foreground hover:bg-accent/50 hover:text-foreground",children:["from ",t.fromParent.name]}),t.parentRemoved&&f.jsx("span",{"data-testid":`repo-list__parent-removed--${d.worktreeId}`,className:"pl-5 text-[11px] text-muted-foreground",children:"parent removed"})]})})}function Hxn({header:t,group:e,actions:n,canMoveUp:r,canMoveDown:o}){return f.jsxs(J0,{children:[f.jsx(e1,{asChild:!0,children:t}),f.jsxs(t1,{children:[f.jsxs(Qn,{"data-testid":"repo-list__group-action--rename",onClick:()=>n.onRename(e),children:[f.jsx(y4,{}),"Rename…"]}),f.jsxs(Qn,{"data-testid":"repo-list__group-action--move-up",disabled:!r,onClick:()=>n.onMove(e,-1),children:[f.jsx(z7e,{}),"Move up"]}),f.jsxs(Qn,{"data-testid":"repo-list__group-action--move-down",disabled:!o,onClick:()=>n.onMove(e,1),children:[f.jsx(uZ,{}),"Move down"]}),f.jsxs(wdt,{children:[f.jsxs(kdt,{"data-testid":"repo-list__group-action--color",children:[f.jsx(rit,{}),"Color"]}),f.jsx(Odt,{children:f.jsx(lBe,{color:e.color,testId:"repo-list__group-color",Swatch:Qn,custom:!1,onChange:i=>n.onColor(e,i)})})]}),f.jsxs(Qn,{"data-testid":"repo-list__group-action--delete",onClick:()=>n.onDelete(e),children:[f.jsx(Kl,{}),"Delete…"]})]})]})}function Fxn({rows:t,groupCollapse:e,groupActions:n,groupOrder:r,navStart:o,...i}){let s=o;return f.jsxs("div",{className:"flex flex-col gap-0.5","data-testid":"repo-list__grouped--groups",children:[t.map(a=>{if(a.kind==="group"){const c=a.groupId??"",u=a.groupId&&a.color?{id:a.groupId,name:a.name,color:a.color}:null,d=f.jsxs("div",{className:"group/header mt-1 flex items-center pr-2",children:[f.jsx(R_n,{dndId:a.key,groupId:a.groupId,children:({setNodeRef:h,over:p,zone:g,dragListeners:_,dragging:x})=>f.jsxs("button",{ref:h,type:"button","data-testid":`repo-list__group-header--${c}`,"data-drop-zone":p?g??"into":void 0,"aria-expanded":!a.collapsed,onClick:()=>e.toggle(c),..._,className:`relative flex h-9 min-w-0 flex-1 items-center gap-2 pl-3 pr-2 text-left transition-colors hover:bg-accent/50 ${p&&g==="into"?"bg-primary/20":""} ${x?"opacity-40":""}`,children:[p&&g==="before"&&f.jsx("span",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 bg-primary"}),p&&g==="after"&&f.jsx("span",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-0.5 bg-primary"}),a.color?f.jsx("span",{"data-testid":`repo-list__group-dot--${c}`,className:"size-2.5 shrink-0 rounded-full",style:{backgroundColor:a.color}}):f.jsx(hM,{className:"size-2.5 shrink-0 text-muted-foreground"}),f.jsx("span",{"data-testid":`repo-list__group-name--${c}`,className:"truncate text-[13px] font-semibold text-foreground/90",children:a.name}),f.jsx("span",{"data-testid":`repo-list__group-count--${c}`,className:"ml-auto shrink-0 text-[11px] text-muted-foreground",children:a.count}),f.jsx(bo,{className:`size-3.5 shrink-0 text-muted-foreground transition-transform ${a.collapsed?"":"rotate-90"}`})]})}),f.jsx(Ce,{variant:"ghost",size:"icon-xs","aria-label":`New worktree in ${a.name}`,"data-testid":`repo-list__group-add--${c}`,onClick:()=>n.onAddWorktree(a.groupId),children:f.jsx(wl,{})})]},a.key);return u?f.jsx(Hxn,{header:d,group:u,actions:n,canMoveUp:r.indexOf(u.id)>0,canMoveDown:r.indexOf(u.id)<r.length-1},a.key):d}const l=s++;return f.jsx(zBe,{row:a,index:l,mode:"groups",...i},a.key)}),f.jsx(L_n,{hidden:t.some(a=>a.kind==="worktree"&&a.ungrouped)})]})}const qxn=t=>t instanceof Error?t.message:String(t);function Vxn({repo:t,hosts:e}){const n=Rn(),[r,o]=v.useState(null),[i,s]=v.useState(null),a=t.mainMissing;if(!a)return null;const l=(t.clones??[]).filter(d=>d.hostId!==a.hostId&&(!t.allowedHostIds||t.allowedHostIds.includes(d.hostId))),c=zE(a.hostId,e),u=async d=>{s(null),o(d);try{await Se.repos.update.mutate({name:t.name,primaryHostId:d}),await n.invalidateQueries({queryKey:["repos"]})}catch(h){s(qxn(h))}finally{o(null)}};return f.jsxs("div",{className:"flex flex-col gap-1 rounded-md px-3 py-2 text-[13px]","data-testid":"repo-main-missing","data-primary-host":a.hostId,children:[f.jsxs("div",{className:"flex items-start gap-2",children:[f.jsx(Mc,{className:"mt-0.5 size-3.5 shrink-0 text-warning","aria-hidden":!0}),f.jsxs("div",{className:"min-w-0",children:[f.jsx("div",{className:"truncate font-medium",children:t.defaultBranch}),f.jsxs("div",{className:"text-foreground/60","data-testid":"repo-main-missing__text",children:["not checked out on ",c]})]})]}),l.length===0?f.jsxs("p",{className:"text-xs text-foreground/60",children:["Check out ",t.defaultBranch," on ",c,", or add another clone from Add repo."]}):null,l.map(d=>f.jsxs(Ce,{size:"sm",variant:"outline",disabled:r!==null,"data-testid":"repo-main-missing__make-primary","data-host-id":d.hostId,onClick:()=>u(d.hostId),children:["Make ",zE(d.hostId,e)," the primary host"]},d.hostId)),i?f.jsx("p",{role:"alert",className:"text-xs text-destructive",children:i}):null]})}function Qxn(t){return t.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9\-/]/g,"").replace(/-{2,}/g,"-").replace(/\/+/g,"/").replace(/^[-/]+|[-/]+$/g,"")}const Uxn="local";function Wxn(t,e){return t?t.includes(e||Uxn):!0}const cv="local";function Zxn(t){const e=t?.data?.existingWorktreeId;return typeof e=="string"?e:void 0}function Gxn({repoName:t,groupId:e,open:n,onOpenChange:r}){const[o,i]=v.useState(cv),[s,a]=v.useState(""),[l,c]=v.useState(""),[u,d]=v.useState(""),[h,p]=v.useState(""),[g,_]=v.useState(!1),x=O_n(),{repos:y}=xs(),[k]=nX(),O=rX(),C=k&&O.some(ee=>ee.id===k)?k:void 0,A=e!==void 0?e:C,E=It({queryKey:["hosts.list"],queryFn:async()=>(await Se.workers.list.query()).hosts,enabled:n}),M=sN(),P=Cn(ee=>ee.openWorktree),L=y.find(ee=>ee.name===t),D=(E.data??[]).filter(ee=>ee.usable&&(ee.id===cv||ee.status==="online")&&Wxn(L?.allowedHostIds,ee.id)),I=D.some(ee=>ee.id===o)?o:D[0]?.id??cv,z=I!==cv,Y=Qxn(l),Q=Y?L?.worktrees.find(ee=>(ee.name===Y||ee.branch===Y)&&(ee.hostId||cv)!==I):void 0,H=Q?jr(t,Q.name,Q.hostId):Zxn(x.error)??null,N=l&&!Y?"Branch name contains no valid characters.":Q?`${Y} is already on ${M(Q.hostId)}`:Y&&L?.worktrees.some(ee=>ee.branch===Y)?`A worktree named "${Y}" already exists.`:null,V=async ee=>{if(ee.preventDefault(),!(!Y||N)){try{await x.mutateAsync({repo:t,branch:Y,base:u.trim()||void 0,prompt:h.trim()||void 0,host:z?{hostId:I,hostRepoPath:s.trim()||void 0}:void 0,groupId:A})}catch{return}c(""),d(""),p(""),r(!1)}},G=D.find(ee=>ee.id===I)?.name??I,K=z&&!L?.remoteUrl,q=z,Z=f.jsxs("div",{className:"grid gap-1.5",children:[f.jsx(To,{htmlFor:"host-repo-path",children:K?`Repository folder on ${G}`:`Folder on ${G}`}),f.jsx(Sn,{id:"host-repo-path","data-testid":"new-worktree-form__host-path",value:s,onChange:ee=>a(ee.target.value),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1})]}),U=!!N,B=x.error;return f.jsx(nr,{open:n,onOpenChange:r,children:f.jsx(rr,{className:"sm:max-w-lg","data-testid":"new-worktree-form__dialog",children:f.jsxs("form",{onSubmit:V,children:[f.jsxs(hr,{children:[f.jsxs(or,{children:["New worktree in ",t]}),f.jsx(Nr,{className:"sr-only",children:"Choose a branch name and an optional prompt for the coding agent."})]}),f.jsxs(su,{open:g,onOpenChange:_,children:[f.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)] gap-3 py-4",children:[f.jsxs("div",{className:"grid gap-1.5",children:[f.jsx(To,{htmlFor:"branch-name",children:"Branch"}),f.jsxs("div",{className:"relative",children:[f.jsx(Sn,{id:"branch-name","data-testid":"new-worktree-form__branch",placeholder:"feat/my-branch",value:l,onChange:ee=>c(ee.target.value),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,autoFocus:!0,"aria-invalid":U||void 0,className:U?"border-destructive pr-9":void 0}),N&&f.jsxs(Ape,{testId:"new-worktree-form__slug-error",label:"Branch error",className:"absolute right-1 top-1/2 -translate-y-1/2",children:[f.jsx("p",{"data-testid":"new-worktree-form__slug-error-message",children:N}),H&&f.jsx(Ce,{type:"button",variant:"outline",size:"sm",className:"mt-2","data-testid":"new-worktree-form__open-existing",onClick:()=>{P(H),r(!1)},children:"Open it"})]})]}),l&&Y&&Y!==l&&!N&&f.jsxs("p",{className:"text-xs text-muted-foreground","data-testid":"new-worktree-form__slug",children:["Creates ",f.jsx("code",{children:Y})]})]}),f.jsxs("div",{className:"grid gap-1.5",children:[f.jsx(To,{htmlFor:"initial-prompt",children:"Prompt"}),f.jsx(cG,{id:"initial-prompt",placeholder:"What should the agent do? Leave empty to start without a task.",value:h,onChange:ee=>p(ee.target.value),rows:3})]}),K&&Z,f.jsxs(au,{className:"grid gap-3",children:[f.jsxs("div",{className:"grid gap-1.5",children:[f.jsx(To,{htmlFor:"base-branch",children:"Base branch"}),f.jsx(Sn,{id:"base-branch","data-testid":"new-worktree-form__base",placeholder:L?.defaultBranch??"main",value:u,onChange:ee=>d(ee.target.value),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1})]}),q&&!K&&Z]})]}),f.jsxs(ii,{className:"items-center",children:[f.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2 sm:mr-auto sm:flex-1",children:[D.length>1&&f.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[f.jsx(To,{htmlFor:"worktree-host",children:"Worker"}),f.jsx("select",{id:"worktree-host","data-testid":"new-worktree-form__host",value:I,onChange:ee=>i(ee.target.value),className:"h-9 min-w-0 flex-1 rounded-md border border-input bg-transparent px-3 text-sm",children:D.map(ee=>f.jsx("option",{value:ee.id,children:ee.name},ee.id))})]}),f.jsx(Ph,{asChild:!0,children:f.jsxs(Ce,{type:"button",variant:"ghost",size:"sm",className:"gap-1 text-muted-foreground","data-testid":"new-worktree-form__more-options",children:[f.jsx(bo,{className:`size-4 transition-transform ${g?"rotate-90":""}`}),"More options"]})})]}),B&&f.jsx(Ape,{testId:"new-worktree-form__error",label:"Create error",children:f.jsx("p",{"data-testid":"new-worktree-form__error-message",children:B.message})}),f.jsx("p",{role:"alert",className:"sr-only",children:B?.message}),f.jsx(Ce,{type:"button",variant:"ghost",onClick:()=>r(!1),children:"Cancel"}),f.jsx(Ce,{type:"submit","data-testid":"new-worktree-form__submit",disabled:!Y||!!N||x.isPending,children:"Create"})]})]})]})})})}function Ape({testId:t,label:e,className:n,children:r}){return f.jsxs(t0,{children:[f.jsx(ku,{asChild:!0,children:f.jsx("button",{type:"button","aria-label":e,"data-testid":t,className:`rounded-sm p-1 text-destructive outline-none focus-visible:ring-2 focus-visible:ring-ring ${n??""}`,children:f.jsx(_u,{className:"size-4"})})}),f.jsx(n0,{align:"end",className:"text-sm","aria-live":"polite",children:r})]})}function Yxn({open:t,onOpenChange:e,onConfirm:n,repoName:r}){return f.jsx(nr,{open:t,onOpenChange:e,children:f.jsxs(rr,{className:"sm:max-w-[425px]",onClick:o=>o.stopPropagation(),children:[f.jsxs(hr,{children:[f.jsx(or,{children:"Promote to git"}),f.jsxs(Nr,{children:["This will run ",f.jsx("code",{children:"git init -b main"})," in ",f.jsx("strong",{children:r})," and turn it into a git repository."]})]}),f.jsx("div",{className:"flex flex-col gap-2 text-sm",children:f.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-info/30 bg-info-bg p-3",children:[f.jsx(ub,{className:"size-4 shrink-0 text-info mt-0.5"}),f.jsx("span",{children:"After promotion you'll be able to create branches, view diffs, and use git pull / push for this repo. The existing worktree stays in place."})]})}),f.jsxs(ii,{children:[f.jsx(Ce,{variant:"ghost",onClick:()=>e(!1),children:"Cancel"}),f.jsx(Ce,{onClick:n,children:"Promote to git"})]})]})})}const Xxn={pending:"Waiting for a worker",leased:"Starting a worker",fulfilled:"Setting up the worktree",failed:"Failed",cancelled:"Cancelled"};function Kxn({request:t}){const e=__n(),n=t.status==="failed",r=Object.entries(t.labels).map(([o,i])=>`${o}=${i}`);return f.jsxs("div",{className:"flex items-start gap-2 rounded-md px-3 py-2 text-[13px]","data-testid":"provisioning-worktree__card","data-status":t.status,"data-branch":t.branch,children:[n?f.jsx(Mc,{className:"mt-0.5 size-3.5 shrink-0 text-destructive","aria-hidden":!0}):f.jsx(H2,{className:"mt-0.5 size-3.5 shrink-0 animate-spin","aria-hidden":!0}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsx("div",{className:"truncate font-medium",children:t.branch}),f.jsxs("div",{className:n?"text-destructive":"text-foreground/60","data-testid":"provisioning-worktree__status",children:[Xxn[t.status],r.length>0&&!n?` (${r.join(", ")})`:""]}),n&&t.error&&f.jsx("div",{className:"break-words text-xs text-destructive","data-testid":"provisioning-worktree__error",children:t.error})]}),f.jsx("button",{type:"button",className:"shrink-0 rounded p-1 text-foreground/60 hover:bg-primary/10 hover:text-foreground","aria-label":n?`Dismiss ${t.branch}`:`Cancel ${t.branch}`,"data-testid":"provisioning-worktree__cancel",disabled:e.isPending,onClick:()=>e.mutate(t.id),children:f.jsx(pa,{className:"size-3.5","aria-hidden":!0})})]})}function $Be({collapsed:t,className:e,children:n}){return f.jsx("div",{className:`grid transition-[grid-template-rows] duration-200 ease-out motion-reduce:transition-none ${t?"grid-rows-[0fr]":"grid-rows-[1fr]"}`,children:f.jsx("div",{className:`overflow-hidden ${e??""}`,inert:t,children:n})})}function Jxn({repo:t,statuses:e,branchStatuses:n,setupStatuses:r,removeRepo:o,onPromoteToGit:i,setWorktreeDialog:s,onShowDeleteDialog:a,focusedIndex:l,worktreeIndexStart:c,collapsed:u,onToggleCollapse:d,hasPinnedSiblings:h,onTogglePinned:p,hosts:g}){const _=t.kind==="plain",{attributes:x,listeners:y,setNodeRef:k,transform:O,transition:C,isDragging:A}=kee({id:t.name}),E=Gs(),P=typeof Rr().promoteRepoToGit=="function",{active:L}=nN(),D={transform:du.Translate.toString(O),transition:L?C:void 0,opacity:A?.5:void 0},I=b_n().filter(se=>se.repo===t.name),z=Cn(se=>se.openWorktree),Y=Cn(se=>se.clearNeedsAttention),Q=_?t.worktrees[0].name:"",H=_?jr(t.name,Q,t.worktrees[0].hostId):"",N=Cn(se=>_&&se.activeWorktreeId===H),V=_?E.getWorktreeHref?.(H):void 0,G=_?e.get(H)?.agent:void 0,K=_&&c===l,q=Cn(se=>se.activeWorktreeId),Z=v.useMemo(()=>!_&&t.worktrees.some(se=>jr(t.name,se.name,se.hostId)===q),[_,t.worktrees,t.name,q]),U=()=>{Y(H),V&&E.navigate?E.navigate(V):V||z(H)};let B=c;const ee=_?`group flex items-center justify-between mb-0.5 rounded-md pl-1 pr-1 py-1.5 min-w-0 overflow-hidden cursor-pointer select-none touch-pan-y transition-colors hover:bg-accent/50 [@media(pointer:coarse)]:min-h-11 [@media(pointer:coarse)]:py-2.5 ${N?"bg-primary/15 hover:bg-primary/15":K?"bg-accent":""}`:"group flex items-center justify-between mb-0.5 pl-1 pr-0 rounded select-none touch-pan-y transition-colors hover:bg-accent/50 [@media(pointer:coarse)]:min-h-11",te=se=>{const{Item:ae}=se;return f.jsxs(f.Fragment,{children:[!_&&f.jsxs(ae,{"data-testid":"repo-list__action--add-worktree",onClick:()=>s(t.name),children:[f.jsx(wl,{}),"Add worktree"]}),_&&P&&f.jsxs(ae,{onClick:()=>i(t.name),children:[f.jsx(ub,{}),"Promote to git…"]}),E.copyPath&&f.jsxs(ae,{onClick:()=>navigator.clipboard.writeText(t.path),children:[f.jsx(q7e,{}),"Copy path"]}),E.revealInFinder&&f.jsxs(ae,{onClick:()=>E.revealInFinder(t.path),children:[f.jsx(ld,{}),"Open in Finder"]}),f.jsxs(ae,{onClick:()=>o(t.name),children:[f.jsx(Rot,{}),"Remove from list"]})]})};return f.jsxs("div",{ref:k,style:D,className:"min-w-0 px-2",children:[f.jsxs(J0,{children:[f.jsx(e1,{asChild:!0,children:f.jsxs("div",{className:ee,"data-testid":`repo-list__repo-header--${t.name}`,onClick:()=>_?U():d(t.name),children:[f.jsxs("div",{className:"flex items-center gap-2 min-w-0 cursor-grab",...x,...y,children:[_?G&&pye(G.status)?f.jsx(_G,{agent:G,tabStatuses:e.get(H)?.tabStatuses}):f.jsx(yC,{className:"size-4 shrink-0 text-muted-foreground"}):f.jsx(m8,{name:t.name,avatar:t.avatar,className:"size-4",testId:`repo-list__repo-avatar--${t.name}`}),f.jsxs(Or,{children:[f.jsx(Sr,{asChild:!0,children:f.jsx("h2",{className:`text-[13px] truncate ${_&&N||Z?"font-bold text-foreground":"font-semibold text-foreground/90"}`,children:t.name})}),f.jsx(Cr,{side:"right",children:t.name})]})]}),f.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100 [@media(pointer:coarse)]:hidden",children:[!_&&f.jsxs(Us,{children:[f.jsxs(Or,{children:[f.jsx(Sr,{asChild:!0,children:f.jsx(Ws,{asChild:!0,children:f.jsx(Ce,{variant:"ghost",size:"icon-xs","aria-label":"Repo actions","data-testid":`repo-list__repo-menu-trigger--${t.name}`,onPointerDown:se=>se.stopPropagation(),onClick:se=>se.stopPropagation(),children:f.jsx(mM,{})})})}),f.jsx(Cr,{children:"More actions"})]}),f.jsx(Zs,{align:"end",children:te({Item:dr})})]}),!_&&f.jsxs(Or,{children:[f.jsx(Sr,{asChild:!0,children:f.jsx(Ce,{variant:"ghost",size:"icon-xs",onPointerDown:se=>se.stopPropagation(),onClick:se=>{se.stopPropagation(),s(t.name)},children:f.jsx(wl,{})})}),f.jsx(Cr,{children:"Add worktree"})]})]})]})}),f.jsx(t1,{children:te({Item:Qn})})]}),!_&&f.jsxs($Be,{collapsed:u,className:"flex flex-col gap-0.5 ml-3",children:[I.map(se=>f.jsx(Kxn,{request:se},se.id)),f.jsx(Vxn,{repo:t,hosts:g}),t.worktrees.length===0?h||I.length>0?null:f.jsx("p",{className:"text-[13px] text-foreground/60 px-4 py-2",children:"No worktrees yet"}):t.worktrees.map(se=>{const ae=jr(t.name,se.name,se.hostId),he=B++;return f.jsx(cBe,{dndId:`wt:${ae}`,data:{kind:"wt",worktreeId:ae,repoName:t.name,hostId:bh(se)},children:f.jsx(IBe,{worktree:se,repoName:t.name,defaultBranch:t.defaultBranch,repoKind:t.kind,status:e.get(ae),branchStatus:n.get(ae),setupStatus:r.get(ae),isFocused:!u&&he===l,onShowDeleteDialog:a,onTogglePinned:p,hostTag:h9n(t)?zE(bh(se),g):void 0,allowedHostIds:t.allowedHostIds})},se.name)})]})]})}function C$(t,e){for(const n of t)for(const r of n.worktrees)if(jr(n.name,r.name,r.hostId)===e)return{wt:r,repo:n}}function eyn({groupFilter:t}){const{repos:e}=xs(),n=rX(),r=oX(),o=Cn(Ie=>Ie.statuses),i=Cn(Ie=>Ie.branchStatuses),s=Cn(Ie=>Ie.setupStatuses),a=Cn(Ie=>Ie.openWorktree),l=Cn(Ie=>Ie.activeWorktreeId),c=x_n(),u=y_n(),d=w_n(),h=Rn(),p=k_n(),g=oBe(),[_,x]=v.useState(null),[y,k]=v.useState(),O=v.useCallback(Ie=>{x(Ie),Ie===null&&k(void 0)},[]),[C,A]=v.useState(null),[E,M]=v.useState(null),[P,L]=v.useState(null),[D,I]=v.useState(-1),z=Hye(),[Y,Q]=v.useState(null),[H,N]=v.useState(null),[V,G]=v.useState(0),[K,q]=v.useState(null),[Z,U]=v.useState({overId:null,zone:null}),[B,ee]=v.useState(null),te=v.useRef(null),se=v.useRef(!1),ae=Lf(nAe),he=Lf(rAe),fe=Lf(oAe),be=Lf(S$e),me=n.length>0,le=me?"groups":"repo",[Be,Xe]=v.useState(null),[ot,Qe]=v.useState(null),[lt,bt]=v.useState(null),ve=It({queryKey:["hosts.list"],queryFn:async()=>(await Se.workers.list.query()).hosts}),{toggle:Te}=rBe(),pe=v.useMemo(()=>y$e(e),[e]),Ne=v.useMemo(()=>t?pe.map(Ie=>({...Ie,worktrees:Ie.worktrees.filter(gt=>gt.groupId===t)})).filter(Ie=>Ie.worktrees.length>0):pe,[pe,t]),$e=v.useMemo(()=>w$e(Ne),[Ne]),De=v.useMemo(()=>c9n($e,be.isCollapsed),[$e,be]),ct=Zj(Gf(Xj,{activationConstraint:{distance:8}}),Gf(_ee,{activationConstraint:{delay:250,tolerance:5}})),{displayRepos:ue,reposWithPinned:Pe}=v.useMemo(()=>{const Ie=zQ(Ne,$e);return{displayRepos:Ie.repos,reposWithPinned:Ie.reposWithPinned}},[Ne,$e]),Ee=fe.isCollapsed(w9),Le=$e.pins.length>0,et=v.useMemo(()=>Le&&!Ee?De.map(Ie=>Ie.entry.worktreeId):[],[Le,Ee,De]),kt=et.length,tn=v.useMemo(()=>zQ(Ne,$e).repos,[Ne,$e]),Kt=v.useMemo(()=>me?d9n({repos:tn,allRepos:pe,groups:n,filter:t,isGroupCollapsed:he.isCollapsed,isOriginCollapsed:be.isCollapsed}):[],[me,tn,pe,n,t,he,be]),Dn=v.useMemo(()=>S2(tn),[tn]),Qt=v.useMemo(()=>S2(pe),[pe]),Ve=v.useMemo(()=>{if(me)return[...et,...p9n(Kt)];const Ie=ue.flatMap(gt=>ae.isCollapsed(gt.name)?[]:gt.worktrees.map(At=>jr(gt.name,At.name,At.hostId)));return[...et,...Ie]},[me,Kt,ue,ae,et]),Ct=v.useMemo(()=>{const Ie=new Map;let gt=kt;for(const At of ue)Ie.set(At.name,gt),ae.isCollapsed(At.name)||(gt+=At.worktrees.length);return Ie},[ue,ae,kt]);v.useEffect(()=>{if(!se.current)if(l){const Ie=Ve.indexOf(l);I(Ie)}else I(-1)},[l,Ve]);const Mt=v.useRef(null),Ye=v.useRef(!1),Pt=v.useRef(le);v.useEffect(()=>{if(!l){Mt.current=null,Ye.current=!1;return}const Ie=$e.ids.has(l);if(!(Mt.current===l&&Ye.current===Ie&&Pt.current===le)){if(Pt.current=le,Mt.current=l,Ye.current=Ie,Ie){fe.expand(w9);let gt=l;const At=new Set;for(;gt&&!At.has(gt);){At.add(gt);const qt=C$(e,gt)?.wt.origin?.worktreeId;qt&&$e.ids.has(qt)&&be.expand(qt),gt=qt&&$e.ids.has(qt)?qt:void 0}se.current=!1;return}if(me){const gt=C$(e,l);gt?.wt.groupId&&he.expand(gt.wt.groupId);let At=l;const qt=new Set;for(;At&&!qt.has(At);){qt.add(At);const yr=C$(e,At);if(!yr)break;const Mn=yr.wt.origin;Mn&&!Mn.removed&&be.expand(Mn.worktreeId),At=Mn&&!Mn.removed?Mn.worktreeId:void 0}se.current=!1;return}for(const gt of ue)if(gt.worktrees.some(qt=>jr(gt.name,qt.name,qt.hostId)===l)){ae.expand(gt.name),se.current=!1;return}}},[l,me,le,e,be,ue,he,ae,fe,$e]);const Dt=e.length>0;v.useEffect(()=>{Dt&&te.current?.focus({preventScroll:!0})},[Dt]);const Ut=Gs(),kn=v.useCallback(Ie=>{LBe(Ie);const gt=Ut.getWorktreeHref?.(Ie);gt&&Ut.navigate?Ut.navigate(gt):a(Ie)},[Ut,a]);function jt(Ie){if(Ve.length!==0){if(Ie.key==="ArrowDown")Ie.preventDefault(),se.current=!0,I(gt=>gt<Ve.length-1?gt+1:gt),te.current?.focus({preventScroll:!0});else if(Ie.key==="ArrowUp")Ie.preventDefault(),se.current=!0,I(gt=>gt>0?gt-1:gt),te.current?.focus({preventScroll:!0});else if(Ie.key==="Enter"){Ie.preventDefault();const gt=Ve[D];gt!==void 0&&!Bye(z.getState(),gt)&&(se.current=!1,kn(gt))}}}const pn=v.useMemo(()=>ue.map(Ie=>Ie.name),[ue]),ke=v.useCallback(Ie=>{const gt=Ie.active.data.current,At=Mn=>Mn.data.current?.kind;if(!gt?.kind)return qE({...Ie,droppableContainers:Ie.droppableContainers.filter(Mn=>!At(Mn))});const qt=Ie.droppableContainers.filter(Mn=>{const Kr=At(Mn);return gt.kind==="pin"?Kr==="pin":gt.kind==="groupmove"?Kr==="group"&&Mn.data.current.groupId!=null:me?Kr==="wt"||Kr==="pin"||Kr==="group":Kr==="wt"&&Mn.data.current?.repoName===gt.repoName}),yr=K9n({...Ie,droppableContainers:qt});return yr.length>0?yr:qE({...Ie,droppableContainers:qt})},[me]);function Ke(Ie){const gt=Ie.active.data.current;if(gt?.kind==="groupmove"){q(n.find(At=>At.id===gt.groupId)??null);return}if(gt?.kind){G(gt.inset??0);const At=[...Dn,...S2(pe)].find(qt=>qt.worktreeId===gt.worktreeId);N(At??null);return}Q(Ie.active.id)}function dt(Ie){const{active:gt,over:At,activatorEvent:qt,delta:yr}=Ie;if(!At)return null;const Mn=At.data.current?.kind,Kr=gt.data.current?.kind;if(Mn==="group"&&Kr!=="groupmove"||Mn==="pin"&&Kr==="wt")return"into";const as=qt,Xs=as.clientY??as.touches?.[0]?.clientY??as.changedTouches?.[0]?.clientY;if(Xs===void 0)return null;const Zt=me&&Kr==="wt"&&Mn==="wt";return C_n(At.rect,Xs+yr.y,Zt)}function sn(Ie){const gt=Ie.over?String(Ie.over.id):null,At=dt(Ie);U(qt=>qt.overId===gt&&qt.zone===At?qt:{overId:gt,zone:At})}function Yt(Ie){Ie.type==="reorder"?d.mutate({order:Ie.order,scope:Ie.scope,reparent:Ie.reparent}):Ie.type==="refuse"?ee(Ie.reason):Ie.type==="parent"&&Wt(Ie)}async function Wt(Ie){const gt=Qt.find(At=>At.worktreeId===Ie.worktreeId);if(gt)try{(gt.worktree.origin?.worktreeId??null)!==Ie.origin&&(await Se.worktrees.setOrigin.mutate({...Ie.worktree,origin:Ie.origin}),await h.invalidateQueries({queryKey:Un.repos})),Nt(Ie.worktreeId,Ie.groupId)}catch(At){ee(At instanceof Error?At.message:String(At))}}async function ir(Ie,gt){const At=Qt.find(Mn=>Mn.worktreeId===Ie),qt=At?.worktree.origin?.worktreeId,yr=qt?Qt.find(Mn=>Mn.worktreeId===qt):void 0;if(At&&gt===null&&yr?.worktree.groupId)try{await Se.worktrees.setOrigin.mutate({repo:At.repo.name,name:At.worktree.name,hostId:At.worktree.hostId,origin:null}),await h.invalidateQueries({queryKey:Un.repos})}catch(Mn){ee(Mn instanceof Error?Mn.message:String(Mn));return}Nt(Ie,gt)}function Nt(Ie,gt){const At=Qt.find(Mn=>Mn.worktreeId===Ie);if(!At||(At.worktree.groupId??null)===gt)return;const qt=O$e(Qt,Ie).filter(Mn=>(Mn.worktree.groupId??null)!==gt),yr=n.find(Mn=>Mn.id===gt)??null;qt.length>0?bt({entry:At,group:yr,childCount:qt.length}):r.setWorktreeGroup.mutate({worktreeId:Ie,groupId:gt})}function Xt(Ie){const{active:gt,over:At}=Ie;if(!At)return;const qt=gt.data.current,yr=At.data.current,Mn=dt(Ie);if(!Mn)return;const Kr=qt.worktreeId;if(qt.kind==="pin"){yr.worktreeId&&Yt(E_n($e,Kr,yr.worktreeId,Mn));return}if(qt.kind==="groupmove"){const as=gt.data.current.groupId;if(as&&yr.groupId){const Xs=A_n(n.map(Zt=>Zt.id),as,yr.groupId,Mn);Xs&&r.reorder.mutate({ids:Xs})}return}if(yr.kind==="group"){ir(Kr,yr.groupId??null);return}if(!me){const as=S2(ue.filter(Xs=>Xs.name===qt.repoName));yr.worktreeId&&Yt(T_n(as,Kr,yr.worktreeId,Mn));return}yr.worktreeId&&Yt(M_n(Qt,Kr,yr.worktreeId,Mn))}function dn(Ie){Q(null),N(null),q(null),U({overId:null,zone:null});const{active:gt,over:At}=Ie;if(!At||gt.id===At.id)return;if(gt.data.current?.kind){Xt(Ie);return}const qt=gt.id,yr=At.id,Mn=e.map(Xs=>Xs.name),Kr=Mn.indexOf(qt),as=Mn.indexOf(yr);Kr<0||as<0||u.mutate(oN(Mn,Kr,as))}function Kn(){Q(null),N(null),q(null),U({overId:null,zone:null})}return v.useEffect(()=>{if(!B)return;const Ie=setTimeout(()=>ee(null),8e3);return()=>clearTimeout(Ie)},[B]),e.length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground",children:[f.jsx("p",{className:"text-lg mb-2",children:"No repos registered"}),f.jsx("p",{className:"text-sm",children:"Click the + button to register a folder"})]}):f.jsxs(f.Fragment,{children:[f.jsxs("div",{ref:te,tabIndex:-1,"data-testid":"repo-list__root",onKeyDown:jt,onPointerDown:()=>{se.current=!1},className:"flex flex-col gap-0.5 outline-none min-w-0",children:[B&&f.jsxs("div",{role:"status","data-testid":"repo-list__drop-refused",className:"mx-2 mb-1 flex items-start gap-2 rounded-md border border-warning/40 bg-warning-bg px-2 py-1.5 text-[12px] text-foreground",children:[f.jsx("span",{className:"flex-1",children:B}),f.jsx("button",{type:"button","aria-label":"Dismiss",onClick:()=>ee(null),className:"shrink-0 text-muted-foreground hover:text-foreground",children:"×"})]}),f.jsx(iN.Provider,{value:Z,children:f.jsxs(eN,{sensors:ct,collisionDetection:ke,onDragStart:Ke,onDragMove:sn,onDragEnd:dn,onDragCancel:Kn,children:[Le&&f.jsxs("div",{"data-testid":"repo-list__pinned",children:[f.jsxs("button",{type:"button","data-testid":"repo-list__pinned-header",onClick:()=>fe.toggle(w9),"aria-expanded":!Ee,className:"flex h-9 w-full items-center gap-2 pl-3 pr-4 mb-0.5 text-left transition-colors hover:bg-primary/10",children:[f.jsx(vZ,{className:"size-3.5 -rotate-45 text-muted-foreground"}),f.jsx("span",{className:"text-[13px] font-semibold text-foreground/90",children:"Pinned"}),f.jsx(bo,{className:`ml-auto size-3.5 shrink-0 text-muted-foreground transition-transform ${Ee?"":"rotate-90"}`})]}),f.jsx($Be,{collapsed:Ee,className:"flex flex-col gap-0.5 px-2",children:!Ee&&De.map((Ie,gt)=>f.jsx(zBe,{row:Ie,index:gt,mode:le,originCollapse:be,hosts:ve.data??[],statuses:o,branchStatuses:i,setupStatuses:s,focusedIndex:D,onShowDeleteDialog:M,onTogglePinned:Te},Ie.key))})]},"__pinned"),me?f.jsx(Fxn,{rows:Kt,groupCollapse:he,groupOrder:n.map(Ie=>Ie.id),groupActions:{onRename:Xe,onColor:(Ie,gt)=>r.update.mutate({id:Ie.id,color:gt}),onDelete:Qe,onMove:(Ie,gt)=>{const At=iBe(n.map(qt=>qt.id),Ie.id,gt);At&&r.reorder.mutate({ids:At})},onAddWorktree:Ie=>A({groupId:Ie})},navStart:kt,originCollapse:be,hosts:ve.data??[],statuses:o,branchStatuses:i,setupStatuses:s,focusedIndex:D,onShowDeleteDialog:M,onTogglePinned:Te}):f.jsx(wee,{items:pn,strategy:yee,children:ue.map(Ie=>f.jsx("div",{className:"pt-1 first:pt-0",children:f.jsx(Jxn,{repo:Ie,statuses:o,branchStatuses:i,setupStatuses:s,removeRepo:gt=>c.mutate(gt),onPromoteToGit:L,setWorktreeDialog:O,onShowDeleteDialog:M,focusedIndex:D,worktreeIndexStart:Ct.get(Ie.name)??0,collapsed:ae.isCollapsed(Ie.name),onToggleCollapse:ae.toggle,hasPinnedSiblings:Pe.has(Ie.name),onTogglePinned:Te,hosts:ve.data??[]})},Ie.name))}),f.jsx(o_n,{dropAnimation:null,children:H?f.jsx("div",{"data-testid":"repo-list__drag-overlay",className:"rounded-md shadow-lg",style:{paddingLeft:V},children:f.jsx(DBe,{entry:H,mode:le,isFocused:!1,hosts:ve.data??[],statuses:o,branchStatuses:i,setupStatuses:s,onShowDeleteDialog:M,onTogglePinned:Te})}):K?f.jsxs("div",{"data-testid":"repo-list__group-drag-overlay",className:"flex h-9 items-center gap-2 rounded border bg-background pl-3 pr-4 shadow-lg",children:[f.jsx("span",{className:"size-2.5 shrink-0 rounded-full",style:{backgroundColor:K.color}}),f.jsx("span",{className:"truncate text-[13px] font-semibold text-foreground/90",children:K.name})]}):Y?f.jsxs("div",{className:"flex items-center gap-2 px-1 py-1 bg-background rounded shadow-lg border",children:[f.jsx(m8,{name:Y,avatar:e.find(Ie=>Ie.name===Y)?.avatar,className:"size-3.5"}),f.jsx("span",{className:"text-[13px] font-semibold text-foreground",children:Y})]}):null})]})})]}),f.jsx(M$e,{open:Be!==null,onOpenChange:Ie=>{Ie||Xe(null)},title:"Rename group",submitLabel:"Rename",initialName:Be?.name??"",onSubmit:Ie=>{Be&&r.update.mutate({id:Be.id,name:Ie})}}),f.jsx(P$e,{open:ot!==null,onOpenChange:Ie=>{Ie||Qe(null)},groupName:ot?.name??"",onConfirm:()=>{ot&&r.remove.mutate({id:ot.id})}}),f.jsx(M9n,{open:lt!==null,onOpenChange:Ie=>{Ie||bt(null)},worktreeName:lt?.entry.worktree.name??"",groupName:lt?.group?.name??"Ungrouped",childCount:lt?.childCount??0,onChoose:Ie=>{lt&&r.setWorktreeGroup.mutate({worktreeId:lt.entry.worktreeId,groupId:lt.group?.id??null,withChildren:Ie})}}),f.jsx(P9n,{open:C!==null,onOpenChange:Ie=>{Ie||A(null)},groupName:n.find(Ie=>Ie.id===C?.groupId)?.name??"Ungrouped",repos:e.filter(Ie=>Ie.kind!=="plain").map(Ie=>Ie.name),onPick:Ie=>{k(C?.groupId??null),x(Ie)}}),f.jsx(Gxn,{repoName:_??"",groupId:y,open:_!==null,onOpenChange:Ie=>O(Ie?_:null)}),f.jsx(P_n,{open:E!==null,onOpenChange:Ie=>{Ie||M(null)},onConfirm:()=>{E&&(g.mutate({repo:E.repoName,name:E.name,hostId:E.hostId}),M(null))},branchName:E?.name??"",isUnmerged:E?.isUnmerged??!1,isDirty:E?.isDirty??!1,hasUnpushedCommits:E?.hasUnpushedCommits??!1}),f.jsx(Yxn,{open:P!==null,onOpenChange:Ie=>{Ie||L(null)},onConfirm:()=>{P&&p.mutate(P,{onSettled:()=>L(null)})},repoName:P??""})]})}function tyn({count:t,actions:e,onListClick:n,tall:r,children:o}){return f.jsxs("section",{className:"flex min-h-0 flex-1 flex-col","data-testid":"repos-panel","aria-label":"Repos",children:[f.jsxs("div",{"data-testid":"repos-panel__header",className:Ze("flex shrink-0 items-center justify-between gap-1 pr-2 pl-4",r?"h-12":"h-7"),children:[f.jsxs("div",{className:"flex h-full shrink-0 items-center gap-1 text-[11px] font-semibold tracking-wide text-muted-foreground uppercase",children:[f.jsx("span",{children:"Repos"}),t!==null&&f.jsx("span",{className:"text-[10px] font-medium tabular-nums","data-testid":"repos-panel__count",children:t})]}),e]}),f.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto pb-3","data-testid":"repos-panel__list",onClick:n,children:o})]})}function nyn(){const[t,e]=v.useState(!1);return v.useEffect(()=>{if(!On)return;let n=null,r=!1;return Ho("get_window_fullscreen").then(o=>{r||e(o)}).catch(()=>{}),Qf("window-fullscreen-changed",({payload:o})=>{e(o)}).then(o=>{r?o():n=o}).catch(()=>{}),()=>{r=!0,n?.()}},[]),t}function BBe(){const t=nyn();return On&&!t?"pl-[80px]":"pl-2"}const Mee=v.createContext(null);function ryn(){return v.useContext(Mee)}function HBe(){const t=Rr(),e=Rn(),n=Cn(r=>r.setError);return $s({mutationFn:r=>t.updateSettings(r),onSuccess:(r,o)=>{e.setQueryData(Un.settings,o)},onError:r=>{n(r)}})}function Qh(){const t=Rr(),{data:e,isLoading:n,error:r}=It({queryKey:Un.settings,queryFn:()=>t.getSettings()});return{settings:e??{worktreesDir:null},isLoading:n,error:r?String(r):null}}function oyn(){const t=Cn(e=>e.setError);return $s({mutationFn:()=>Se.terminal.restartDaemon.mutate(),onError:e=>{t(e)}})}function iyn({open:t,onOpenChange:e,onConfirm:n,busy:r}){return f.jsx(nr,{open:t,onOpenChange:o=>!r&&e(o),children:f.jsxs(rr,{className:"sm:max-w-[425px]",onClick:o=>o.stopPropagation(),showCloseButton:!r,children:[f.jsxs(hr,{children:[f.jsx(or,{children:"Restart the terminal service?"}),f.jsx(Nr,{children:"Ends every terminal in Band's terminal service and starts a fresh one. Panes show that the process exited and can be reopened. Sessions from a previous version of Band are kept."})]}),f.jsxs(ii,{children:[f.jsx(Ce,{variant:"ghost",onClick:()=>e(!1),disabled:r,children:"Cancel"}),f.jsx(Ce,{variant:"destructive",onClick:n,disabled:r,children:r?"Restarting…":"Restart"})]})]})})}const syn={installed:"Installed",outdated:"Outdated",not_installed:"Not installed",offline:"Worker offline"};function ayn(){const{hosts:t,isError:e,refresh:n}=cAe(),[r,o]=v.useState(null),[i,s]=v.useState(null),a=async(l,c)=>{o(l),s(null);try{await Se.hooks[c].mutate({hostId:l})}catch(u){s(u instanceof Error?u.message:String(u))}finally{o(null),await n()}};return f.jsxs(_n,{variant:"stacked",label:"Claude Code hooks",description:"Hooks report what Claude Code does in a terminal (working, waiting for an answer, done), so the sidebar and notifications can show it. Chats in Band need no hooks. Remove deletes only Band's entries.",children:[e?f.jsx("p",{role:"alert",className:"text-xs text-muted-foreground","data-testid":"settings__hooks-denied",children:"Managing hooks needs an admin token."}):null,i?f.jsx("p",{role:"alert",className:"text-xs text-destructive","data-testid":"settings__hooks-error",children:i}):null,f.jsx("ul",{className:"divide-y divide-border rounded-md border border-border",children:t.map(l=>{const c=EFt(l),u=r===l.hostId;return f.jsxs("li",{"data-testid":"settings__hooks-host","data-host-id":l.hostId,"data-state":c,className:"flex items-center justify-between gap-2 px-3 py-2 text-sm",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsx("div",{className:"truncate font-medium",children:l.name}),f.jsxs("div",{className:"text-xs text-muted-foreground","data-testid":"settings__hooks-state",children:[syn[c],l.online&&!l.hasClaudeCode?" · Claude Code not found":"",l.error?` · ${l.error}`:""]})]}),f.jsxs("div",{className:"flex shrink-0 gap-1",children:[f.jsx(Ce,{size:"sm",variant:"outline",disabled:!l.online||u,"data-testid":"settings__hooks-install",onClick:()=>a(l.hostId,"install"),children:c==="installed"||c==="outdated"?"Reinstall":"Install"}),f.jsx(Ce,{size:"sm",variant:"ghost",disabled:!l.online||u||c==="not_installed","data-testid":"settings__hooks-remove",onClick:()=>a(l.hostId,"remove"),children:"Remove"})]})]},l.hostId)})})]})}const FBe={"claude-code":[{id:"setup-token",label:"Setup token (claude setup-token)",secretVar:"CLAUDE_CODE_OAUTH_TOKEN",clears:["ANTHROPIC_API_KEY","ANTHROPIC_AUTH_TOKEN"],note:"A setup token cannot use Remote Control or claude.ai connectors."},{id:"api-key",label:"Anthropic API key",secretVar:"ANTHROPIC_API_KEY",clears:["CLAUDE_CODE_OAUTH_TOKEN","ANTHROPIC_AUTH_TOKEN"]}],codex:[{id:"api-key",label:"OpenAI API key",secretVar:"OPENAI_API_KEY",alsoSecretVars:["CODEX_API_KEY"],fixedEnv:{DEFAULT_AUTH_REQUEST:'{"methodId":"api-key"}'},clears:[]}],opencode:[{id:"anthropic-api-key",label:"Anthropic API key",secretVar:"ANTHROPIC_API_KEY",clears:[]},{id:"openai-api-key",label:"OpenAI API key",secretVar:"OPENAI_API_KEY",clears:[]},{id:"openrouter-api-key",label:"OpenRouter API key",secretVar:"OPENROUTER_API_KEY",clears:[]},{id:"gemini-api-key",label:"Gemini API key",secretVar:"GEMINI_API_KEY",clears:[]}],"gemini-cli":[{id:"api-key",label:"Gemini API key",secretVar:"GEMINI_API_KEY",clears:["GOOGLE_API_KEY"]}],"cursor-cli":[{id:"api-key",label:"Cursor API key",secretVar:"CURSOR_API_KEY",clears:[]}],amp:[{id:"api-key",label:"Amp API key",secretVar:"AMP_API_KEY",clears:[]}],copilot:[{id:"token",label:"GitHub token",secretVar:"COPILOT_GITHUB_TOKEN",clears:[]}]};function qBe(t){return FBe[t]??[]}new Set(Object.values(FBe).flatMap(t=>t.flatMap(e=>[e.secretVar,...e.alsoSecretVars??[]])));const Zx=t=>t instanceof Error?t.message:String(t);function tf({title:t,description:e,from:n,testId:r,children:o}){return f.jsxs("section",{className:"overflow-hidden rounded-xl border border-border","data-testid":r,"aria-label":t,children:[f.jsxs("header",{className:"flex items-baseline justify-between gap-3 border-border border-b px-4 py-3",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsx("h2",{className:"text-sm font-semibold",children:t}),e?f.jsx("p",{className:"text-xs text-muted-foreground",children:e}):null]}),n?f.jsx("span",{className:"shrink-0 whitespace-nowrap text-[11px] text-muted-foreground",children:n}):null]}),f.jsx("div",{className:"[&>*+*]:border-border [&>*+*]:border-t",children:o})]})}function Fc({label:t,description:e,htmlFor:n,readOnly:r,testId:o,data:i,children:s}){return f.jsxs("div",{className:Ze("grid grid-cols-1 items-center gap-2 px-4 py-3 sm:grid-cols-[220px_1fr] sm:gap-4",r&&"bg-muted/40"),"data-testid":o,...i,children:[f.jsxs("div",{className:"min-w-0",children:[n?f.jsx("label",{htmlFor:n,className:"block text-[13px] font-semibold",children:t}):f.jsx("div",{className:"text-[13px] font-semibold",children:t}),e?f.jsx("div",{className:"text-xs text-muted-foreground",children:e}):null]}),f.jsx("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:s})]})}const lyn={neutral:"bg-muted text-foreground",ok:"bg-success-bg text-success",warn:"bg-warning-bg text-warning",scoped:"bg-info-bg text-info"};function qc({tone:t="neutral",testId:e,children:n}){return f.jsx("span",{className:Ze("inline-flex items-center whitespace-nowrap rounded-full px-2 py-px text-xs",lyn[t]),"data-testid":e,"data-tone":t,children:n})}function W0({children:t,testId:e}){return f.jsx("span",{className:"text-xs text-muted-foreground","data-testid":e,children:t})}const VBe="h-8 min-w-48 rounded-md border border-border bg-background px-2 text-sm disabled:opacity-60",Pee=["agentLogins.list"];function QBe(){return It({queryKey:Pee,queryFn:()=>Se.agentLogins.list.query(),retry:!1})}const aN=t=>t instanceof Error?t.message:String(t);function UBe(){const t=It({queryKey:["models.listAll"],queryFn:()=>Se.models.listAll.query()}),e=new Set,n=[];for(const r of t.data?.agents??[])e.has(r.agentType)||qBe(r.agentType).length===0||(e.add(r.agentType),n.push({type:r.agentType,label:r.agentLabel}));return n}function cyn({agentType:t,onAdded:e}){const n=qBe(t),[r,o]=v.useState(n[0]?.id??""),[i,s]=v.useState(""),[a,l]=v.useState(""),[c,u]=v.useState(!1),[d,h]=v.useState(null),p=n.find(_=>_.id===r),g=async()=>{u(!0),h(null);try{await Se.agentLogins.create.mutate({agentType:t,kind:r,label:i.trim(),secret:a}),s(""),l(""),e()}catch(_){h(aN(_))}finally{u(!1)}};return f.jsxs("div",{className:"space-y-2","data-testid":"settings-agent-logins__add",children:[f.jsx("select",{"aria-label":`Login kind for ${t}`,value:r,onChange:_=>o(_.target.value),className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm",children:n.map(_=>f.jsx("option",{value:_.id,children:_.label},_.id))}),t==="codex"?f.jsx("p",{className:"text-xs text-muted-foreground","data-testid":"settings-agent-logins__codex-note",children:"Used only on workers with no Codex login of their own. Isolating CODEX_HOME comes later."}):null,p?.note?f.jsx("p",{className:"text-xs text-muted-foreground","data-testid":"settings-agent-logins__note",children:p.note}):null,f.jsx(Sn,{"aria-label":`Login label for ${t}`,placeholder:"Label, such as Team subscription",value:i,onChange:_=>s(_.target.value),className:"h-8 text-sm"}),f.jsx(Sn,{"aria-label":`Login secret for ${t}`,type:"password",autoComplete:"off",placeholder:"Secret",value:a,onChange:_=>l(_.target.value),className:"h-8 text-sm"}),f.jsx(Ce,{type:"button",size:"sm","data-testid":"settings-agent-logins__add-submit",disabled:c||i.trim()===""||a==="",onClick:()=>{g()},children:"Add login"}),d?f.jsx("p",{role:"alert",className:"text-xs text-destructive","data-testid":"settings-agent-logins__error",children:d}):null]})}function uyn({login:t,onChanged:e}){const[n,r]=v.useState(!1),[o,i]=v.useState(null),s=async()=>{i(null);try{await Se.agentLogins.remove.mutate({id:t.id}),e()}catch(a){i(aN(a))}};return f.jsxs("li",{className:"flex items-center justify-between gap-2 px-3 py-2 text-sm","data-testid":"settings-agent-logins__login","data-login-id":t.id,children:[f.jsxs("div",{className:"min-w-0",children:[f.jsx("div",{className:"truncate","data-testid":"settings-agent-logins__login-label",children:t.label}),f.jsxs("div",{className:"text-xs text-muted-foreground",children:[t.kindLabel," · ",t.envVar,t.missingSecret?f.jsxs("span",{className:"text-destructive","data-testid":"settings-agent-logins__missing",children:[" ","· missing secret"]}):null]}),o?f.jsx("p",{role:"alert",className:"text-xs text-destructive",children:o}):null]}),n?f.jsxs("div",{className:"flex shrink-0 gap-2",children:[f.jsx(Ce,{type:"button",size:"sm",variant:"outline","data-testid":"settings-agent-logins__remove-confirm",onClick:()=>{s()},children:"Confirm remove"}),f.jsx(Ce,{type:"button",size:"sm",variant:"ghost",onClick:()=>r(!1),children:"Cancel"})]}):f.jsx(Ce,{type:"button",size:"sm",variant:"outline",className:"shrink-0","aria-label":`Remove login ${t.label}`,"data-testid":"settings-agent-logins__remove",onClick:()=>r(!0),children:"Remove"})]})}function dyn(){const t=Rn(),e=QBe(),n=UBe(),[r,o]=v.useState(null),i=()=>t.invalidateQueries({queryKey:Pee});if(e.isError)return f.jsx("p",{role:"alert",className:"text-xs text-muted-foreground","data-testid":"settings-agent-logins__denied",children:"Managing agent logins needs an admin token."});const s=async(a,l)=>{o(null);try{await Se.agentLogins.setDefault.mutate({agentType:a,loginId:l||null}),await i()}catch(c){o(aN(c))}};return f.jsxs(f.Fragment,{children:[n.map(a=>{const l=(e.data?.logins??[]).filter(u=>u.agentType===a.type),c=e.data?.defaults[a.type]??"";return f.jsx(_n,{variant:"stacked",label:a.label,description:"With no default, the agent uses the machine's own login.",children:f.jsxs("div",{className:"space-y-3","data-testid":"settings-agent-logins__agent","data-agent":a.type,children:[l.length>0?f.jsx("ul",{className:"divide-y divide-border rounded-md border border-border",children:l.map(u=>f.jsx(uyn,{login:u,onChanged:()=>{i()}},u.id))}):null,f.jsxs("select",{"aria-label":`Default login for ${a.label}`,"data-testid":"settings-agent-logins__default",value:c,onChange:u=>{s(a.type,u.target.value)},className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm",children:[f.jsx("option",{value:"",children:"The machine's own login"}),l.map(u=>f.jsx("option",{value:u.id,children:u.label},u.id))]}),f.jsx(cyn,{agentType:a.type,onAdded:()=>{i()}})]})},a.type)}),r?f.jsx("p",{role:"alert",className:"text-xs text-destructive",children:r}):null]})}function fyn({repoName:t}){const e=Rn(),n=QBe(),r=UBe(),[o,i]=v.useState(null),[s,a]=v.useState(!1),l=n.data;if(!l)return f.jsx("p",{className:"px-4 py-3 text-xs text-muted-foreground","data-testid":"settings-repo__logins-none",children:n.isError?"Changing logins needs an admin token.":"Loading…"});if(r.length===0)return f.jsx("p",{className:"px-4 py-3 text-xs text-muted-foreground","data-testid":"settings-repo__logins-none",children:"No coding agent that takes a login is set up. Enable one in Coding Agents."});const c=async(u,d)=>{i(null),a(!0);try{await Se.agentLogins.setRepoOverride.mutate({agentType:u,repo:t,loginId:d||null}),await e.invalidateQueries({queryKey:Pee})}catch(h){i(aN(h))}finally{a(!1)}};return f.jsxs(f.Fragment,{children:[r.map(u=>{const d=l.logins.filter(_=>_.agentType===u.type),h=l.repoOverrides.find(_=>_.agentType===u.type&&_.repo===t)?.loginId??"",p=l.logins.find(_=>_.id===l.defaults[u.type]),g=`settings-repo-${t}-login-${u.type}`;return d.length===0?f.jsx(Fc,{label:u.label,description:"No logins yet.",testId:"settings-repo__login-row",data:{"data-agent":u.type},children:f.jsx(W0,{children:"Add one in Agent logins"})},u.type):f.jsxs(Fc,{htmlFor:g,label:u.label,description:`Default: ${p?.label??"none (the machine's own login)"}.`,testId:"settings-repo__login-row",data:{"data-agent":u.type},children:[f.jsxs("select",{id:g,"aria-label":`${u.label} login for ${t}`,"data-testid":"settings-repo__login-override","data-agent":u.type,"data-repo":t,value:h,disabled:s,onChange:_=>{c(u.type,_.target.value)},className:VBe,children:[f.jsx("option",{value:"",children:"Use the default"}),d.map(_=>f.jsx("option",{value:_.id,children:_.label},_.id))]}),h?f.jsx(qc,{tone:"scoped",testId:"settings-repo__login-override-chip",children:"override"}):null]},u.type)}),o?f.jsx("p",{role:"alert",className:"px-4 py-2 text-xs text-destructive",children:o}):null]})}const WBe=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i;function eU(t){const e=WBe.exec(t.trim());if(!e)return null;let n=e[1];return n.length===3&&(n=n.split("").map(r=>r+r).join("")),{r:Number.parseInt(n.slice(0,2),16),g:Number.parseInt(n.slice(2,4),16),b:Number.parseInt(n.slice(4,6),16)}}function hyn(t){return WBe.test(t.trim())}function jn({r:t,g:e,b:n}){const r=o=>Math.round(Math.min(255,Math.max(0,o))).toString(16).padStart(2,"0");return`#${r(t)}${r(e)}${r(n)}`}function ZBe(t){const e=eU(t);return e?jn(e):null}function g6(t){const e=t/255;return e<=.04045?e/12.92:((e+.055)/1.055)**2.4}function A$(t){return(t<=.0031308?t*12.92:1.055*t**.4166666666666667-.055)*255}function ZE(t){return .2126*g6(t.r)+.7152*g6(t.g)+.0722*g6(t.b)}function v6(t,e){const n=ZE(t),r=ZE(e),o=Math.max(n,r),i=Math.min(n,r);return(o+.05)/(i+.05)}function Epe({r:t,g:e,b:n}){const r=g6(t),o=g6(e),i=g6(n),s=Math.cbrt(.4122214708*r+.5363325363*o+.0514459929*i),a=Math.cbrt(.2119034982*r+.6806995451*o+.1073969566*i),l=Math.cbrt(.0883024619*r+.2817188376*o+.6299787005*i);return{l:.2104542553*s+.793617785*a-.0040720468*l,a:1.9779984951*s-2.428592205*a+.4505937099*l,b:.0259040371*s+.7827717662*a-.808675766*l}}function pyn({l:t,a:e,b:n}){const r=t+.3963377774*e+.2158037573*n,o=t-.1055613458*e-.0638541728*n,i=t-.0894841775*e-1.291485548*n,s=r**3,a=o**3,l=i**3;return{r:A$(4.0767416621*s-3.3077115913*a+.2309699292*l),g:A$(-1.2684380046*s+2.6097574011*a-.3413193965*l),b:A$(-.0041960863*s-.7034186147*a+1.707614701*l)}}function GE(t,e,n){const r=Epe(t),o=Epe(e);return pyn({l:r.l+(o.l-r.l)*n,a:r.a+(o.a-r.a)*n,b:r.b+(o.b-r.b)*n})}const YE={r:255,g:255,b:255},G9={r:0,g:0,b:0};function u3(t,e,n){const r=Array.isArray(e)?e:[e],o=c=>Math.min(...r.map(u=>v6(c,u)));if(o(t)>=n)return t;const s=r.reduce((c,u)=>c+ZE(u),0)/r.length>.4?G9:YE;let a=t;for(let c=1;c<=20;c++){const u=GE(t,s,c/20);if(a=u,o(u)>=n)return u}const l=s===G9?YE:G9;return o(l)>o(a)?l:a}function hf(t){return v6(YE,t)>=v6(G9,t)?YE:G9}function xf(t,e){return`rgba(${Math.round(t.r)}, ${Math.round(t.g)}, ${Math.round(t.b)}, ${e})`}function GBe(t){return ZE(t)<.18}const I5=4.6;function Aa(t,e){return eU(t)??eU(e)}function myn(t){const e=Aa(t.background,"#1e1e1e"),n=GBe(e),r=u3(Aa(t.foreground,"#e8e8e8"),e,I5),o=Aa(t.accent,"#3b82f6"),i=d=>GE(e,r,d);let s=i(.07),a=n?i(.1):e,l=r;for(let d=1;d>=0&&(s=i(.07*d),a=n?i(.1*d):e,l=u3(GE(r,e,.4),[e,s,a],I5),!(Math.min(v6(l,e),v6(l,s),v6(l,a))>=I5));d-=.1);const c=u3(o,[e,a],I5),u=hf(o);return{"--background":jn(e),"--foreground":jn(r),"--card":jn(i(.02)),"--card-foreground":jn(r),"--popover":jn(a),"--popover-foreground":jn(r),"--primary":jn(o),"--primary-foreground":jn(u),"--secondary":jn(s),"--secondary-foreground":jn(r),"--muted":jn(s),"--muted-foreground":jn(l),"--accent":jn(i(.09)),"--accent-foreground":jn(r),"--sidebar":jn(i(.04)),"--border":jn(i(n?.18:.14)),"--input":jn(i(.12)),"--ring":jn(i(.4)),"--highlight":jn(c),"--link":jn(c),"--terminal-background":jn(e),"--terminal-foreground":jn(r),"--terminal-selection":xf(r,n?.2:.15),"--editor-active-line":xf(r,.03)}}function gyn(t,e,n){const r=Aa(e,"#1e1e1e"),o=GBe(r),i=u3(Aa(n,"#e8e8e8"),r,I5),s=k=>u3(Aa(k,"#888888"),r,I5),a=k=>u3(Aa(k,"#888888"),r,3),l=s(t.green),c=s(t.yellow),u=s(t.red),d=s(t.blue),h=s(t.magenta),p=s(t.orange),g={"--success":jn(l),"--warning":jn(c),"--danger":jn(u),"--info":jn(d),"--merged":jn(h),"--success-foreground":jn(hf(l)),"--warning-foreground":jn(hf(c)),"--danger-foreground":jn(hf(u)),"--info-foreground":jn(hf(d)),"--merged-foreground":jn(hf(h)),"--destructive":jn(u),"--destructive-foreground":jn(hf(u)),"--status-foreground":jn(hf(p)),"--diff-added-bg":xf(l,.1),"--diff-removed-bg":xf(u,.1),"--diff-added-marker":xf(l,.8),"--diff-removed-marker":xf(u,.8),"--git-untracked":jn(c),"--git-behind":jn(c),"--git-diverged":jn(p),"--status-working":jn(c),"--status-question":jn(p),"--status-done":jn(l),"--status-failed":jn(u),"--search-match":xf(Aa(t.yellow,"#ffd33d"),.35),"--search-match-current":xf(Aa(t.orange,"#f97316"),.8)},_=k=>o?GE(Aa(k,"#888888"),i,.25):Aa(k,"#888888");[Aa(t.black,"#000000"),a(t.red),a(t.green),a(t.yellow),a(t.blue),a(t.magenta),a(t.cyan),Aa(t.white,"#e5e5e5"),Aa(t.comment,"#666666"),a(jn(_(t.red))),a(jn(_(t.green))),a(jn(_(t.yellow))),a(jn(_(t.blue))),a(jn(_(t.magenta))),a(jn(_(t.cyan))),i].forEach((k,O)=>{g[`--ansi-${O}`]=jn(k)});const y={comment:u3(Aa(t.comment,"#888888"),r,3),keyword:s(t.magenta),control:s(t.magenta),string:s(t.green),number:p,function:d,variable:u,type:c,property:s(t.cyan),operator:s(t.cyan),tag:u,attribute:p,punctuation:i,constant:p,regexp:s(t.cyan),heading:d,inserted:l,deleted:u,invalid:u};for(const[k,O]of Object.entries(y))g[`--syntax-${k}`]=jn(O);return g}const jee="band",vyn={light:{accent:"#155dfc",background:"#ffffff",foreground:"#0a0a0a"},dark:{accent:"#51a2ff",background:"#1e1e1e",foreground:"#e5e5e5"}},XE=[{id:jee,label:"Band",light:null,dark:null},{id:"github",label:"GitHub",light:{colors:{accent:"#0969da",background:"#ffffff",foreground:"#1f2328"},hues:{red:"#cf222e",green:"#1a7f37",yellow:"#9a6700",blue:"#0969da",magenta:"#8250df",cyan:"#1b7c83",orange:"#bc4c00",comment:"#6e7781",black:"#24292f",white:"#6e7781"}},dark:{colors:{accent:"#2f81f7",background:"#0d1117",foreground:"#e6edf3"},hues:{red:"#ff7b72",green:"#3fb950",yellow:"#d29922",blue:"#58a6ff",magenta:"#bc8cff",cyan:"#39c5cf",orange:"#ffa657",comment:"#8b949e",black:"#484f58",white:"#b1bac4"}}},{id:"solarized",label:"Solarized",light:{colors:{accent:"#268bd2",background:"#fdf6e3",foreground:"#586e75"},hues:{red:"#dc322f",green:"#859900",yellow:"#b58900",blue:"#268bd2",magenta:"#d33682",cyan:"#2aa198",orange:"#cb4b16",comment:"#93a1a1",black:"#073642",white:"#93a1a1"}},dark:{colors:{accent:"#268bd2",background:"#002b36",foreground:"#93a1a1"},hues:{red:"#dc322f",green:"#859900",yellow:"#b58900",blue:"#268bd2",magenta:"#d33682",cyan:"#2aa198",orange:"#cb4b16",comment:"#586e75",black:"#073642",white:"#eee8d5"}}},{id:"nord",label:"Nord",light:{colors:{accent:"#5e81ac",background:"#eceff4",foreground:"#2e3440"},hues:{red:"#bf616a",green:"#7a9a5e",yellow:"#a98a45",blue:"#5e81ac",magenta:"#b48ead",cyan:"#4c8f98",orange:"#c0795a",comment:"#7b88a1",black:"#3b4252",white:"#7b88a1"}},dark:{colors:{accent:"#88c0d0",background:"#2e3440",foreground:"#d8dee9"},hues:{red:"#bf616a",green:"#a3be8c",yellow:"#ebcb8b",blue:"#81a1c1",magenta:"#b48ead",cyan:"#88c0d0",orange:"#d08770",comment:"#616e88",black:"#3b4252",white:"#e5e9f0"}}},{id:"catppuccin",label:"Catppuccin",light:{colors:{accent:"#8839ef",background:"#eff1f5",foreground:"#4c4f69"},hues:{red:"#d20f39",green:"#40a02b",yellow:"#df8e1d",blue:"#1e66f5",magenta:"#ea76cb",cyan:"#179299",orange:"#fe640b",comment:"#8c8fa1",black:"#5c5f77",white:"#acb0be"}},dark:{colors:{accent:"#cba6f7",background:"#1e1e2e",foreground:"#cdd6f4"},hues:{red:"#f38ba8",green:"#a6e3a1",yellow:"#f9e2af",blue:"#89b4fa",magenta:"#f5c2e7",cyan:"#94e2d5",orange:"#fab387",comment:"#6c7086",black:"#45475a",white:"#bac2de"}}}];function Nee(t){return XE.find(e=>e.id===t)??XE[0]}const x_="band-appearance",vg="band-theme",YBe="band-theme-vars",XBe=16,byn=13,KBe={min:11,max:22},JBe={min:9,max:24},_yn='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',Ree=[{id:"system",label:"System",stack:null},{id:"inter",label:"Inter",stack:`Inter, ${_yn}`},{id:"helvetica",label:"Helvetica Neue",stack:'"Helvetica Neue", Helvetica, Arial, sans-serif'},{id:"serif",label:"Georgia",stack:'Georgia, "Times New Roman", serif'}],Lee=[{id:"system",label:"System",stack:null},{id:"sf-mono",label:"SF Mono",stack:'"SF Mono", SFMono-Regular, ui-monospace, Menlo, Monaco, monospace'},{id:"menlo",label:"Menlo",stack:'Menlo, Monaco, "Courier New", monospace'},{id:"jetbrains-mono",label:"JetBrains Mono",stack:'"JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace'},{id:"fira-code",label:"Fira Code",stack:'"Fira Code", ui-monospace, SFMono-Regular, Menlo, monospace'},{id:"consolas",label:"Consolas",stack:'Consolas, "Liberation Mono", Menlo, monospace'}],eHe=["accent","background","foreground"],y_={preset:jee,overrides:{},uiFont:"system",codeFont:"system",uiFontSize:null,codeFontSize:null};function Tpe(t,e){return typeof t!="number"||!Number.isFinite(t)?null:Math.min(e.max,Math.max(e.min,Math.round(t)))}function Mpe(t){if(!t||typeof t!="object")return;const e={};for(const n of eHe){const r=t[n];typeof r=="string"&&hyn(r)&&(e[n]=ZBe(r))}return Object.keys(e).length>0?e:void 0}function Iee(t){if(!t)return y_;try{const e=JSON.parse(t),n=Mpe(e.overrides?.light),r=Mpe(e.overrides?.dark),o=typeof e.preset=="string"?Nee(e.preset).id:jee,i=Ree.some(a=>a.id===e.uiFont)?e.uiFont:"system",s=Lee.some(a=>a.id===e.codeFont)?e.codeFont:"system";return{preset:o,overrides:{...n?{light:n}:{},...r?{dark:r}:{}},uiFont:i,codeFont:s,uiFontSize:Tpe(e.uiFontSize,KBe),codeFontSize:Tpe(e.codeFontSize,JBe)}}catch{return y_}}function KE(t){return JSON.stringify(t)}function xyn(t){return KE(yyn(t))===KE(y_)}function yyn(t){return Iee(KE(t))}function tHe(t,e){const n=Nee(t.preset);return{...(e==="dark"?n.dark:n.light)?.colors??vyn[e],...t.overrides[e]??{}}}function tU(t,e){return Object.keys(t.overrides[e]??{}).length>0}function wyn(t){return tU(t,"light")||tU(t,"dark")}function kyn(t,e){const n=Nee(t.preset),r=e==="dark"?n.dark:n.light,o=tU(t,e);if(!r&&!o)return{};const i=tHe(t,e),s=myn(i);return r&&Object.assign(s,gyn(r.hues,i.background,i.foreground)),s}function Oyn(t){const e={},n=Ree.find(o=>o.id===t.uiFont)?.stack,r=Lee.find(o=>o.id===t.codeFont)?.stack;return n&&(e["--font-ui"]=n),r&&(e["--font-code"]=r),t.uiFontSize&&t.uiFontSize!==XBe&&(e["--font-size-ui"]=`${t.uiFontSize}px`),t.codeFontSize&&(e["--code-font-size"]=`${t.codeFontSize}px`),e}function E$(t,e){return{...kyn(t,e),...Oyn(t)}}function Syn(t){return t==="light"||t==="system"?t:"dark"}const w_="band-theme-changed",tO=new Set;let Ppe=!1;function Cyn(t){return t==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t}function Dee(){try{return Syn(localStorage.getItem(vg))}catch{return"dark"}}function Ayn(){try{return Iee(Hn.getItem(x_))}catch{return y_}}function Eyn(t){const e=document.documentElement.style;if(!Ppe){Ppe=!0;for(let n=0;n<e.length;n++){const r=e.item(n);r.startsWith("--")&&tO.add(r)}}for(const n of tO)n in t||e.removeProperty(n);tO.clear();for(const[n,r]of Object.entries(t))e.setProperty(n,r),tO.add(n)}function Y9(){const t=Dee(),e=Ayn(),n=Cyn(t);document.documentElement.classList.toggle("dark",n==="dark"),Eyn(E$(e,n));try{localStorage.setItem(YBe,JSON.stringify({light:E$(e,"light"),dark:E$(e,"dark")}))}catch{}window.dispatchEvent(new CustomEvent(w_,{detail:{mode:n}}))}function Tyn(t){try{localStorage.setItem(vg,t)}catch{}Y9()}let T$=0;function Myn(){T$||(T$=requestAnimationFrame(()=>{T$=0,Y9()}))}function nHe(t){const e=KE(t);Hn.getItem(x_)!==e&&(Hn.setItem(x_,e),Myn())}function Pyn(){nHe(y_)}function jyn(){Y9();const t=window.matchMedia("(prefers-color-scheme: dark)"),e=()=>{Dee()==="system"&&Y9()},n=r=>{(r.key===null||r.key===vg||r.key===x_)&&Y9()};return t.addEventListener("change",e),window.addEventListener("storage",n),()=>{t.removeEventListener("change",e),window.removeEventListener("storage",n)}}function b6(t){return getComputedStyle(document.documentElement).getPropertyValue(t).trim()}let a2;function jpe(t,e,n="#808080"){if(a2===void 0&&(a2=document.createElement("canvas").getContext("2d",{willReadFrequently:!0})),!a2||!t)return n;a2.clearRect(0,0,1,1),e&&(a2.fillStyle=e,a2.fillRect(0,0,1,1)),a2.fillStyle=t,a2.fillRect(0,0,1,1);const[r=0,o=0,i=0]=a2.getImageData(0,0,1,1).data;return`#${[r,o,i].map(s=>s.toString(16).padStart(2,"0")).join("")}`}function M$(t){return window.addEventListener(w_,t),window.addEventListener("storage",t),()=>{window.removeEventListener(w_,t),window.removeEventListener("storage",t)}}function Nyn(){const t=v.useSyncExternalStore(M$,()=>Hn.getItem(x_),()=>null),e=v.useSyncExternalStore(M$,Dee,()=>"dark"),n=v.useMemo(()=>Iee(t),[t]),r=v.useSyncExternalStore(M$,()=>document.documentElement.classList.contains("dark")?"dark":"light",()=>"dark");return{appearance:n,mode:e,resolvedMode:r}}const Npe={page:"#ffffff",side:"#f4f4f5",line:"#d4d4d8",accent:"#3b82f6"},Rpe={page:"#1e1e1e",side:"#2a2a2c",line:"#4a4a4f",accent:"#60a5fa"};function P$({palette:t}){return f.jsxs("div",{className:"flex h-full w-full",style:{background:t.page},children:[f.jsx("div",{className:"w-1/4",style:{background:t.side}}),f.jsxs("div",{className:"flex flex-1 flex-col gap-1 p-1.5",children:[f.jsx("div",{className:"h-1 w-3/4 rounded-full",style:{background:t.accent}}),f.jsx("div",{className:"h-1 w-full rounded-full",style:{background:t.line}}),f.jsx("div",{className:"h-1 w-2/3 rounded-full",style:{background:t.line}}),f.jsx("div",{className:"mt-auto h-2 rounded-full",style:{background:t.side}})]})]})}function Ryn({mode:t,selected:e}){return f.jsx("div",{className:Ze("h-14 w-20 overflow-hidden rounded-lg border-2 transition-colors",e?"border-highlight":"border-border"),children:t==="system"?f.jsxs("div",{className:"flex h-full",children:[f.jsx("div",{className:"w-1/2 overflow-hidden",children:f.jsx("div",{className:"h-full w-[160%]",children:f.jsx(P$,{palette:Npe})})}),f.jsx("div",{className:"w-1/2 overflow-hidden",children:f.jsx("div",{className:"-ml-[60%] h-full w-[160%]",children:f.jsx(P$,{palette:Rpe})})})]}):f.jsx(P$,{palette:t==="dark"?Rpe:Npe})})}const rHe=v.createContext(!1);function wi({title:t,description:e,action:n,children:r,className:o}){const i=v.useContext(rHe);return f.jsxs("section",{className:Ze("space-y-2",o),children:[(t&&!i||n)&&f.jsxs("div",{className:"flex items-center justify-between gap-2 px-1",children:[t&&!i?f.jsx("h3",{className:"text-sm font-medium text-foreground/90",children:t}):f.jsx("span",{}),n?f.jsx("div",{className:"shrink-0",children:n}):null]}),e&&!i?f.jsx("p",{className:"px-1 text-xs text-muted-foreground",children:e}):null,f.jsx("div",{"data-slot":"settings-section-card","data-testid":"settings__section-card",className:Ze("overflow-hidden rounded-xl border border-border","[&>*+*]:border-t [&>*+*]:border-border"),children:r})]})}const Lyn=[{id:"system",label:"System"},{id:"light",label:"Light"},{id:"dark",label:"Dark"}],nU={accent:"Accent",background:"Background",foreground:"Foreground"},j$="custom";function Iyn({id:t,value:e,onCommit:n}){const[r,o]=v.useState(e.toUpperCase());v.useEffect(()=>o(e.toUpperCase()),[e]);const i=s=>{const a=ZBe(s);a?n(a):o(e.toUpperCase())};return f.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-border px-2 py-1",children:[f.jsx("label",{className:"relative size-5 shrink-0 cursor-pointer overflow-hidden rounded-full border border-border",style:{backgroundColor:e},children:f.jsx("input",{type:"color","aria-label":`${nU[t]} color picker`,"data-testid":`appearance__${t}-picker`,value:e,onChange:s=>n(s.target.value),className:"absolute inset-0 size-full cursor-pointer opacity-0"})}),f.jsx("input",{"aria-label":`${nU[t]} hex`,"data-testid":`appearance__${t}-hex`,value:r,maxLength:7,spellCheck:!1,onChange:s=>o(s.target.value),onBlur:s=>i(s.target.value),onKeyDown:s=>{s.key==="Enter"&&i(s.currentTarget.value)},className:"w-[4.5rem] bg-transparent font-mono text-sm uppercase outline-none"})]})}function Lpe({id:t,value:e,fallback:n,range:r,onCommit:o}){const i=e??n,[s,a]=v.useState(String(i));v.useEffect(()=>a(String(i)),[i]);const l=()=>{const c=Number.parseInt(s,10);if(!Number.isFinite(c)){a(String(i));return}const u=Math.min(r.max,Math.max(r.min,c));a(String(u)),u!==e&&o(u)};return f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Sn,{id:t,"data-testid":t,inputMode:"numeric",value:s,onChange:c=>a(c.target.value),onBlur:l,onKeyDown:c=>{c.key==="Enter"&&l()},className:"h-8 w-16 text-center text-sm"}),f.jsx("span",{className:"text-sm text-muted-foreground",children:"px"})]})}function Dyn({translucentSidebarAvailable:t,translucentSidebar:e,onTranslucentSidebarChange:n}){const{appearance:r,mode:o,resolvedMode:i}=Nyn(),s=tHe(r,i),a=wyn(r),l=h=>nHe({...r,...h}),c=(h,p)=>{l({overrides:{...r.overrides,[i]:{...r.overrides[i]??{},[h]:p}}})},u=h=>{h!==j$&&l({preset:h,overrides:{}})},d=XE.find(h=>h.id===r.preset)?.label??"Band";return f.jsxs("div",{className:"flex flex-col gap-6","data-testid":"appearance",children:[f.jsx(wi,{title:"Visual style",children:f.jsx(_n,{variant:"responsive",label:"Mode",children:f.jsx("div",{className:"flex gap-3",role:"radiogroup","aria-label":"Mode",children:Lyn.map(h=>f.jsxs("button",{type:"button",role:"radio","aria-checked":o===h.id,"aria-label":h.label,"data-testid":`appearance__mode-${h.id}`,onClick:()=>Tyn(h.id),className:"flex flex-col items-center gap-1 rounded-lg focus-visible:outline-2 focus-visible:outline-focus-ring",children:[f.jsx(Ryn,{mode:h.id,selected:o===h.id}),f.jsx("span",{className:Ze("text-xs",o===h.id?"text-foreground":"text-muted-foreground"),children:h.label})]},h.id))})})}),f.jsxs(wi,{children:[f.jsx(_n,{variant:"responsive",label:"Theme",description:`The colors below are for ${i} mode. Switch the mode to edit the other.`,children:f.jsxs(ja,{value:a?j$:r.preset,onValueChange:u,children:[f.jsx(Ra,{className:"h-8 w-full text-sm sm:w-44","aria-label":"Theme","data-testid":"appearance__preset",children:f.jsx(Na,{})}),f.jsxs(La,{children:[a?f.jsxs(ni,{value:j$,disabled:!0,children:["Custom (",d,")"]}):null,XE.map(h=>f.jsx(ni,{value:h.id,children:h.label},h.id))]})]})}),eHe.map(h=>f.jsx(_n,{label:nU[h],children:f.jsx(Iyn,{id:h,value:s[h],onCommit:p=>c(h,p)})},h)),f.jsx(_n,{variant:"responsive",label:"UI font",children:f.jsxs(ja,{value:r.uiFont,onValueChange:h=>l({uiFont:h}),children:[f.jsx(Ra,{className:"h-8 w-full text-sm sm:w-44","aria-label":"UI font","data-testid":"appearance__ui-font",children:f.jsx(Na,{})}),f.jsx(La,{children:Ree.map(h=>f.jsx(ni,{value:h.id,children:h.label},h.id))})]})}),f.jsx(_n,{variant:"responsive",label:"Code font",children:f.jsxs(ja,{value:r.codeFont,onValueChange:h=>l({codeFont:h}),children:[f.jsx(Ra,{className:"h-8 w-full text-sm sm:w-44","aria-label":"Code font","data-testid":"appearance__code-font",children:f.jsx(Na,{})}),f.jsx(La,{children:Lee.map(h=>f.jsx(ni,{value:h.id,children:h.label},h.id))})]})})]}),f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsx("div",{className:"flex items-center justify-end px-1",children:f.jsx(Ce,{type:"button",variant:"ghost",size:"sm","data-testid":"appearance__reset",disabled:xyn(r),onClick:Pyn,children:"Reset to default"})}),f.jsxs(wi,{children:[f.jsx(_n,{htmlFor:"appearance__ui-size",label:"UI font size",description:"The base size for the interface.",children:f.jsx(Lpe,{id:"appearance__ui-size",value:r.uiFontSize,fallback:XBe,range:KBe,onCommit:h=>l({uiFontSize:h})})}),f.jsx(_n,{htmlFor:"appearance__code-size",label:"Code font size",description:"The size for code in chats, the editor, diffs and the terminal.",children:f.jsx(Lpe,{id:"appearance__code-size",value:r.codeFontSize,fallback:byn,range:JBe,onCommit:h=>l({codeFontSize:h})})}),t&&f.jsx(_n,{htmlFor:"translucent-sidebar",label:"Translucent sidebar",description:"Show the desktop through the repo list, blurred and tinted.",children:f.jsx(Hi,{id:"translucent-sidebar",checked:e,onCheckedChange:n})})]})]})]})}const zyn=Object.freeze([]),$yn=Object.freeze({});function zee(){const t=Rr(),{data:e,isFetched:n}=It({queryKey:Un.browserProfiles,queryFn:()=>t.listBrowserProfiles?.()??Promise.resolve([]),retry:1});return{profiles:e??zyn,isLoaded:n}}function Byn(){const t=Rr(),{data:e}=It({queryKey:Un.repoBrowserProfiles,queryFn:()=>t.listRepoBrowserProfiles?.()??Promise.resolve({})});return e??$yn}function Hyn(){const t=Rr(),e=Rn();return $s({mutationFn:({repoName:n,profileId:r})=>t.setRepoBrowserProfile?.(n,r)??Promise.resolve(),onSettled:()=>e.invalidateQueries({queryKey:Un.repoBrowserProfiles})})}function Fyn(){const t=Rr(),e=Rn();return $s({mutationFn:n=>t.removeBrowserProfile?.(n)??Promise.resolve(),onSettled:()=>Promise.all([e.invalidateQueries({queryKey:Un.browserProfiles}),e.invalidateQueries({queryKey:Un.repoBrowserProfiles})])})}function qyn(){const t=Rn();return()=>Promise.all([t.invalidateQueries({queryKey:Un.browserProfiles}),t.invalidateQueries({queryKey:Un.repoBrowserProfiles})])}const N$="__default__";function Vyn(t){return t==="chrome"?"Imported from Chrome":"No cookies imported"}function Qyn(){const{profiles:t}=zee(),e=Fyn();return f.jsx(_n,{variant:"stacked",label:"Browser profiles",description:"Each profile keeps its own cookies. Import a Chrome profile from the profile menu in a browser tab's toolbar. Deleting a profile signs you out of every site in it.",children:f.jsxs("ul",{className:"divide-y divide-border rounded-md border border-border",children:[f.jsxs("li",{className:"flex items-center justify-between px-3 py-2 text-sm",children:[f.jsx("span",{children:"Default"}),f.jsx("span",{className:"text-xs text-muted-foreground",children:"Built in"})]}),t.map(n=>f.jsxs("li",{className:"flex items-center justify-between gap-2 px-3 py-2 text-sm","data-testid":"settings__browser-profile",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsx("div",{className:"truncate",children:n.name}),f.jsx("div",{className:"text-xs text-muted-foreground",children:Vyn(n.source)})]}),f.jsx(Ce,{variant:"ghost",size:"icon",className:"size-7 shrink-0","aria-label":`Delete browser profile ${n.name}`,disabled:e.isPending,onClick:()=>e.mutate(n.id),children:f.jsx(Kl,{className:"size-3.5"})})]},n.id))]})})}function Uyn({repoName:t}){const{profiles:e}=zee(),n=Byn(),r=Hyn();return f.jsxs(ja,{value:n[t]??N$,onValueChange:o=>r.mutate({repoName:t,profileId:o===N$?null:o}),children:[f.jsx(Ra,{className:"h-8 w-full text-sm sm:w-48","aria-label":`Browser profile for ${t}`,"data-testid":"settings-repo__browser-profile",children:f.jsx(Na,{})}),f.jsxs(La,{children:[f.jsx(ni,{value:N$,children:"Default"}),e.map(o=>f.jsx(ni,{value:o.id,children:o.name},o.id))]})]})}const Ipe=["vault.list"],Wyn={api_key:"API key",env:"Environment variable",oauth:"OAuth",git:"Git credential"};function Zyn(t){return t==null?"Never":new Date(t).toLocaleString()}function Gyn(t){const e=typeof t.metadata.account=="string"?t.metadata.account:null,n=typeof t.metadata.scopes=="string"?t.metadata.scopes:null;return[e?`Account ${e}`:null,n?`Scopes ${n}`:null].filter(Boolean).join(" · ")}function Yyn(){const t=Rn(),e=It({queryKey:Ipe,queryFn:()=>Se.vault.list.query()}),[n,r]=v.useState(""),[o,i]=v.useState("api_key"),[s,a]=v.useState("github.com"),[l,c]=v.useState(""),[u,d]=v.useState(""),[h,p]=v.useState(null),[g,_]=v.useState(!1),x=()=>t.invalidateQueries({queryKey:Ipe}),y=C=>p(C instanceof Error?C.message:String(C)),k=async()=>{_(!0),p(null);try{await Se.vault.put.mutate({name:n.trim(),kind:o,value:u,scope:"global",...o==="git"&&{host:s.trim(),pathPattern:l.trim()}}),r(""),d(""),await x()}catch(C){y(C)}finally{_(!1)}},O=async C=>{p(null);try{await Se.vault.delete.mutate({id:C.id})}catch(A){y(A)}await x()};return f.jsxs(f.Fragment,{children:[f.jsxs(_n,{variant:"stacked",label:"Stored credentials",description:"Encrypted on the hub. A value cannot be read back, only replaced or deleted. The hub refreshes OAuth tokens before they expire.",children:[e.isError?f.jsx("p",{role:"alert",className:"text-xs text-muted-foreground","data-testid":"settings__credentials-denied",children:"Managing credentials needs an admin token."}):null,f.jsx("ul",{className:"divide-y divide-border rounded-md border border-border",children:(e.data?.items??[]).map(C=>f.jsxs("li",{"data-testid":"settings__credential","data-kind":C.kind,className:"flex items-center justify-between gap-2 px-3 py-2 text-sm",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsx("div",{className:"truncate","data-testid":"settings__credential-name",children:C.name}),f.jsxs("div",{className:"text-xs text-muted-foreground",children:[Wyn[C.kind]," · ",C.scope," · Last used ",Zyn(C.lastUsedAt)]}),C.kind==="oauth"?f.jsx("div",{className:"truncate text-xs text-muted-foreground","data-testid":"settings__credential-oauth",children:Gyn(C)}):null]}),f.jsx(Ce,{type:"button",variant:"outline",size:"sm",className:"shrink-0","aria-label":`Delete credential ${C.name}`,onClick:()=>{O(C)},children:"Delete"})]},C.id))})]}),f.jsx(_n,{variant:"stacked",label:"Add a key",description:"An API key or an environment variable value. The value is sent once and is not shown again.",children:f.jsxs("div",{className:"space-y-2",children:[f.jsx(Sn,{"aria-label":"Credential name",placeholder:"Name (for an environment variable, its name)",value:n,onChange:C=>r(C.target.value),className:"h-8 text-sm"}),f.jsxs("select",{"aria-label":"Credential kind",value:o,onChange:C=>i(C.target.value),className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm",children:[f.jsx("option",{value:"api_key",children:"API key"}),f.jsx("option",{value:"env",children:"Environment variable"}),f.jsx("option",{value:"git",children:"Git credential (access token)"})]}),o==="git"&&f.jsxs(f.Fragment,{children:[f.jsx(Sn,{"aria-label":"Git host",placeholder:"Host, such as github.com",value:s,onChange:C=>a(C.target.value),className:"h-8 text-sm"}),f.jsx(Sn,{"aria-label":"Git path pattern",placeholder:"Repositories, such as owner/* or owner/repo",value:l,onChange:C=>c(C.target.value),className:"h-8 text-sm"})]}),f.jsx(Sn,{"aria-label":"Credential value",type:"password",autoComplete:"off",placeholder:"Value",value:u,onChange:C=>d(C.target.value),className:"h-8 text-sm"}),f.jsx(Ce,{type:"button",size:"sm","data-testid":"settings__credential-add",disabled:g||n.trim()===""||u===""||o==="git"&&l.trim()==="",onClick:()=>{k()},children:"Add credential"})]})}),h?f.jsx("p",{role:"alert",className:"text-xs text-destructive","data-testid":"settings__credential-error",children:h}):null]})}function Xyn(t,e){const n=t.trim();return n?e.some(r=>r.name.trim().toLowerCase()===n.toLowerCase())?"A group with this name already exists.":null:"The name is empty."}function oHe({initial:t,others:e,editing:n,onStart:r,onCommit:o,onCancel:i,testId:s}){const[a,l]=v.useState(t),c=v.useRef(null),u=v.useRef(!1);if(v.useEffect(()=>{n&&(l(t),u.current=!1,c.current?.focus(),c.current?.select())},[n,t]),!n)return f.jsx("button",{type:"button","data-testid":s,onClick:r,className:"min-w-0 flex-1 truncate rounded px-1 py-0.5 text-left text-sm hover:bg-accent/50",children:t});const d=a.trim()===t?null:Xyn(a,e),h=a.trim()===t,p=g=>{u.current||(u.current=!0,g())};return f.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:[f.jsx(Sn,{ref:c,"aria-label":`Name of group ${t}`,"aria-invalid":d!==null,"data-testid":`${s}-input`,"data-settings-inline-edit":!0,value:a,onChange:g=>l(g.target.value),onKeyDown:g=>{g.key==="Escape"?p(i):g.key==="Enter"&&(h?p(i):d||p(()=>o(a.trim())))},onBlur:()=>{!d&&!h&&a.trim()?p(()=>o(a.trim())):p(i)},className:"h-7 min-w-24 flex-1 text-sm"}),d?f.jsxs(Or,{children:[f.jsx(Sr,{asChild:!0,children:f.jsx("span",{role:"img","aria-label":d,"data-testid":"settings-groups__name-error",className:"text-destructive",children:f.jsx(_u,{className:"size-4"})})}),f.jsx(Cr,{children:d})]}):null]})}function Kyn({group:t,groups:e,index:n,onRename:r,onColor:o,onMove:i,onDelete:s}){const{attributes:a,listeners:l,setNodeRef:c,transform:u,transition:d,isDragging:h}=kee({id:t.id}),[p,g]=v.useState(!1);return f.jsxs("div",{ref:c,"data-slot":"settings-row","data-testid":"settings-groups__row","data-group-id":t.id,tabIndex:0,onKeyDown:_=>{!_.altKey||p||(_.key==="ArrowUp"?(_.preventDefault(),i(-1)):_.key==="ArrowDown"&&(_.preventDefault(),i(1)))},style:{transform:du.Translate.toString(u),transition:d},className:`flex items-center gap-2 bg-background px-3 py-2 outline-none focus-visible:ring-1 focus-visible:ring-ring ${h?"relative z-10 opacity-70 shadow-lg":""}`,children:[f.jsx("button",{type:"button","aria-label":`Drag ${t.name} to reorder`,"data-testid":"settings-groups__handle",className:"flex size-6 shrink-0 cursor-grab items-center justify-center rounded text-muted-foreground hover:bg-accent/50",...a,...l,children:f.jsx(_ot,{className:"size-4"})}),f.jsx(N_n,{color:t.color,onChange:o,label:`Colour of ${t.name}`,testId:"settings-groups__color",dotTestId:"settings-groups__dot"}),f.jsx(oHe,{initial:t.name,others:e.filter(_=>_.id!==t.id),editing:p,onStart:()=>g(!0),onCommit:_=>{g(!1),r(_)},onCancel:()=>g(!1),testId:"settings-groups__name"}),f.jsxs(Us,{children:[f.jsx(Ws,{asChild:!0,children:f.jsx(Ce,{variant:"ghost",size:"icon-xs","aria-label":`Actions for ${t.name}`,"data-testid":"settings-groups__menu",children:f.jsx(hZ,{className:"size-4"})})}),f.jsxs(Zs,{align:"end",onCloseAutoFocus:_=>_.preventDefault(),children:[f.jsxs(dr,{"data-testid":"settings-groups__rename",onClick:()=>g(!0),children:[f.jsx(y4,{}),"Rename"]}),f.jsxs(dr,{"data-testid":"settings-groups__move-up",disabled:n===0,onClick:()=>i(-1),children:[f.jsx(z7e,{}),"Move up"]}),f.jsxs(dr,{"data-testid":"settings-groups__move-down",disabled:n===e.length-1,onClick:()=>i(1),children:[f.jsx(uZ,{}),"Move down"]}),f.jsx(A4,{}),f.jsxs(dr,{"data-testid":"settings-groups__delete",onClick:s,children:[f.jsx(Kl,{}),"Delete…"]})]})]})]})}function Jyn({color:t,groups:e,onCreate:n,onCancel:r}){return f.jsxs("div",{"data-slot":"settings-row","data-testid":"settings-groups__new-row",className:"flex items-center gap-2 px-3 py-2",children:[f.jsx("span",{className:"size-6 shrink-0"}),f.jsx("span",{className:"flex size-6 shrink-0 items-center justify-center",children:f.jsx("span",{className:"size-3 rounded-full",style:{backgroundColor:t}})}),f.jsx(oHe,{initial:"",others:e,editing:!0,onStart:()=>{},onCommit:n,onCancel:r,testId:"settings-groups__new-name"})]})}function ewn(){const t=rX(),{repos:e}=xs(),{create:n,update:r,remove:o,reorder:i}=oX(),[s,a]=v.useState(!1),[l,c]=v.useState(null),u=Zj(Gf(bee,{activationConstraint:{distance:4}}),Gf(Yj,{coordinateGetter:tBe})),d=t.map(x=>x.id),h=x=>e.reduce((y,k)=>y+k.worktrees.filter(O=>O.groupId===x).length,0),p=QQ.find(x=>!t.some(y=>y.color.toLowerCase()===x.value))?.value??QQ[0].value,g=x=>{if(!x.over)return;const y=S_n(d,String(x.active.id),String(x.over.id));y&&i.mutate({ids:y})},_=(x,y)=>{const k=iBe(d,x,y);k&&i.mutate({ids:k})};return f.jsxs(wi,{title:"Groups",description:"Sort worktrees in the sidebar. A worktree is in one group.",action:f.jsxs(Ce,{variant:"outline",size:"sm","data-testid":"settings-groups__add",onClick:()=>a(!0),children:[f.jsx(wl,{className:"size-3"}),"New group"]}),children:[f.jsxs("div",{"data-testid":"settings-groups",children:[t.length===0&&!s?f.jsx("p",{"data-slot":"settings-row","data-testid":"settings-groups__empty",className:"px-4 py-3 text-sm text-muted-foreground",children:"No groups yet"}):null,f.jsx(eN,{sensors:u,collisionDetection:qE,onDragEnd:g,children:f.jsx(wee,{items:d,strategy:yee,children:t.map((x,y)=>f.jsx(Kyn,{group:x,groups:t,index:y,onRename:k=>r.mutate({id:x.id,name:k}),onColor:k=>r.mutate({id:x.id,color:k}),onMove:k=>_(x.id,k),onDelete:()=>{h(x.id)===0?o.mutate({id:x.id}):c(x)}},x.id))})}),s?f.jsx(Jyn,{color:p,groups:t,onCreate:x=>{a(!1),n.mutate({name:x,color:p})},onCancel:()=>a(!1)}):null]}),f.jsx(P$e,{open:l!==null,onOpenChange:x=>{x||c(null)},groupName:l?.name??"",onConfirm:()=>{l&&o.mutate({id:l.id})}})]})}const twn=t=>t instanceof Error?t.message:String(t);function nwn({open:t,onOpenChange:e,from:n,hosts:r}){const o=Rn(),i=Aee(),s=r.filter(A=>A.id!==n.id&&A.id!=="local"&&A.status==="online"),[a,l]=v.useState(""),[c,u]=v.useState(!1),[d,h]=v.useState(!1),[p,g]=v.useState(null),[_,x]=v.useState(null),y=a||s[0]?.id||"",k=It({queryKey:["checkpoints.evacuable",n.id],queryFn:async()=>(await Se.checkpoints.evacuable.query({hostId:n.id})).worktrees,enabled:t}),O=async()=>{h(!0),g(null);try{x(await Se.checkpoints.evacuate.mutate({fromHostId:n.id,toHostId:y,...c?{addHost:!0}:{}})),await o.invalidateQueries({queryKey:["repos"]})}catch(A){g(twn(A))}finally{h(!1)}},C=k.data?.length??0;return f.jsx(nr,{open:t,onOpenChange:e,children:f.jsxs(rr,{className:"sm:max-w-[520px]","data-testid":"evacuate__dialog",children:[f.jsxs(hr,{children:[f.jsxs(or,{children:["Move all worktrees on ",n.name]}),f.jsx(Nr,{children:n.status==="online"?"Each worktree gets a fresh checkpoint, is recreated on the target worker, and is then removed here. One at a time.":`${n.name} is offline, so each worktree is restored from its last checkpoint. The copies on ${n.name} stay untouched and are listed as superseded when it comes back.`})]}),_?f.jsxs("ul",{className:"space-y-1 text-sm","data-testid":"evacuate__summary",children:[_.results.length===0?f.jsx("li",{children:"There was nothing to move."}):null,_.results.map(A=>f.jsxs("li",{"data-testid":"evacuate__result","data-worktree":A.worktreeId,"data-ok":A.ok?"true":"false",children:[f.jsx("span",{className:"font-mono",children:i(A.worktreeId).label}),":"," ",A.ok?`${A.mode==="move"?"moved":"restored"} as ${i(A.newWorktreeId??"").label}`:`failed. ${A.error}`]},A.worktreeId))]}):f.jsxs("div",{className:"space-y-3",children:[f.jsx("p",{className:"text-sm","data-testid":"evacuate__count",children:k.isLoading?"Counting worktrees…":`${C} worktree${C===1?"":"s"} will move.`}),f.jsx("ul",{className:"max-h-32 overflow-auto text-xs text-muted-foreground",children:(k.data??[]).map(A=>f.jsx("li",{"data-testid":"evacuate__worktree",children:i(A.worktreeId).label},A.worktreeId))}),s.length===0?f.jsx("p",{className:"text-sm text-muted-foreground",children:"No other worker is online."}):f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(To,{htmlFor:"evacuate-target",children:"Target worker"}),f.jsx("select",{id:"evacuate-target","data-testid":"evacuate__target",className:"h-8 w-full rounded-md border border-border bg-transparent px-2 text-sm",value:y,disabled:d,onChange:A=>l(A.target.value),children:s.map(A=>f.jsx("option",{value:A.id,children:A.name||A.id},A.id))})]}),f.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[f.jsx("input",{type:"checkbox",checked:c,disabled:d,"data-testid":"evacuate__add-host",onChange:A=>u(A.target.checked)}),"Add the target worker to the allowed workers of repos that need it"]}),p?f.jsx("p",{role:"alert",className:"text-xs text-destructive","data-testid":"evacuate__error",children:p}):null,f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>e(!1),children:"Cancel"}),f.jsxs(Ce,{size:"sm","data-testid":"evacuate__submit",disabled:d||y===""||C===0,onClick:()=>{O()},children:[d?f.jsx(wo,{className:"size-3"}):null,"Move all"]})]})]}),_?f.jsx("div",{className:"flex justify-end",children:f.jsx(Ce,{size:"sm",variant:"ghost",onClick:()=>e(!1),children:"Close"})}):null]})})}function rwn({host:t,state:e,editable:n,onChanged:r}){const[o,i]=v.useState(e.override??""),[s,a]=v.useState(null),l=async d=>{a(null);try{await Se.workers.setAgentCommand.mutate({hostId:t.id,agentId:e.agentId,command:d}),d===null&&i(""),r()}catch(h){a(h instanceof Error?h.message:String(h))}},c=`settings__host-agent-command-${e.agentId}`,u=e.found===!1;return f.jsxs(jxe,{value:e.agentId,className:"border-b-0",children:[f.jsxs(Pxe,{className:"flex items-center gap-3 px-3 py-2",children:[f.jsx("span",{"data-testid":`${c}-status`,"data-state":e.found===!0?"found":u?"missing":"unknown",className:Ze("size-2 shrink-0 rounded-full",u?"bg-destructive":"bg-success")}),f.jsx(D3,{type:e.type,className:"size-4 shrink-0"}),f.jsx(RC,{"data-testid":`${c}-toggle`,"aria-label":`Command of ${e.label} on ${t.name}`,className:"flex-1 rounded-md text-left text-sm font-medium text-foreground",children:e.label}),f.jsx("span",{"data-testid":`${c}-effective`,"data-effective":e.effective??"",className:Ze("truncate text-xs",u?"text-destructive":"text-muted-foreground"),title:u?`${e.effective} not found on ${t.name}`:void 0,children:e.effective??""}),u?f.jsxs("span",{role:"alert",className:"sr-only","data-testid":`${c}-not-found`,children:[e.effective," not found on ",t.name]}):null,f.jsx(RC,{"aria-label":`Toggle command settings for ${e.label}`,className:"-mr-1 inline-flex size-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground [&[data-state=open]>svg]:rotate-180",children:f.jsx(Pi,{className:"size-4 shrink-0 transition-transform duration-200"})})]}),f.jsxs(Nxe,{className:"space-y-1 px-3 pb-2 pl-11",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Sn,{"aria-label":`${e.label} command on ${t.name}`,"data-testid":`${c}-input`,className:"h-8 flex-1 text-xs",placeholder:"Default binary",disabled:!n,value:o,onChange:d=>i(d.target.value)}),n?f.jsxs(f.Fragment,{children:[f.jsx(Ce,{type:"button",variant:"outline",size:"sm","data-testid":`${c}-save`,disabled:o.trim()===(e.override??"")||o.trim()==="",onClick:()=>{l(o.trim())},children:"Save"}),e.override?f.jsx(Ce,{type:"button",variant:"ghost",size:"sm","data-testid":`${c}-clear`,onClick:()=>{l(null)},children:"Clear"}):null]}):null]}),s?f.jsx("div",{role:"alert",className:"text-xs text-destructive","data-testid":`${c}-error`,children:s}):null]})]})}function own({host:t,isAdmin:e,onChanged:n}){return t.agentCommandStates.length===0?null:f.jsx(Mxe,{type:"multiple",className:"mt-2 w-full rounded-md border border-border","data-testid":"settings__host-agents-commands",children:t.agentCommandStates.map(r=>f.jsx(rwn,{host:t,state:r,editable:e,onChanged:n},`${r.agentId}:${r.override??""}`))})}const iwn=["hosts.updateStatus"],JE=["hosts.list"],swn=10*6e4;function iHe(){return It({queryKey:iwn,queryFn:()=>Se.workers.updateStatus.query(),refetchInterval:swn,retry:!1})}function g8(t=!0){const e=Rr(),n=Rn();return v.useEffect(()=>{if(t)return e.subscribeStatusEvents(r=>{r.kind==="host-status-changed"&&n.invalidateQueries({queryKey:JE})})},[e,n,t]),It({queryKey:JE,queryFn:async()=>(await Se.workers.list.query()).hosts,enabled:t})}function rU({command:t,testId:e,label:n}){const[r,o]=v.useState(!1),i=v.useRef(void 0);v.useEffect(()=>()=>clearTimeout(i.current),[]);const s=async()=>{await Vs(t)&&(o(!0),clearTimeout(i.current),i.current=setTimeout(()=>o(!1),1500))};return f.jsxs("div",{className:"flex items-start gap-2",children:[f.jsx("code",{"data-testid":`${e}-command`,className:"min-w-0 flex-1 break-all rounded bg-muted px-2 py-1 font-mono text-xs",children:t}),f.jsx(Ce,{type:"button",variant:"outline",size:"sm","aria-label":n,"data-testid":`${e}-copy`,onClick:()=>{s()},children:r?f.jsx(Ji,{className:"size-3"}):f.jsx(z0,{className:"size-3"})})]})}function sHe({host:t}){const e=Rn(),[n,r]=v.useState(!1),[o,i]=v.useState(!1),[s,a]=v.useState(null),l=It({queryKey:["hosts.interruptions",t.id],queryFn:()=>Se.workers.interruptions.query({hostId:t.id}),enabled:n,gcTime:0}),c=t.update?.state,u=c==="installing"||c==="restarting",d=async()=>{i(!0),a(null);try{await Se.workers.update.mutate({hostId:t.id}),r(!1)}catch(p){a(p instanceof Error?p.message:String(p))}finally{i(!1),await e.invalidateQueries({queryKey:JE})}},h=l.data?.agents??[];return f.jsxs(f.Fragment,{children:[f.jsx(Ce,{type:"button",variant:"outline",size:"sm","aria-label":`Update ${t.name}`,"data-testid":"update-worker__button",disabled:u,onClick:()=>{a(null),r(!0)},children:c==="installing"?"Installing…":c==="restarting"?"Restarting…":c==="failed"?"Retry update":"Update"}),f.jsx(nr,{open:n,onOpenChange:p=>!o&&r(p),children:f.jsxs(rr,{className:"sm:max-w-[460px]","data-testid":"update-worker__dialog",children:[f.jsxs(hr,{children:[f.jsxs(or,{children:["Update ",t.name," to ",t.updateTarget,"?"]}),f.jsx(Nr,{children:"The worker installs the new version and restarts. Restarting ends every agent running on this worker, and a turn in progress is lost."})]}),f.jsx("div",{className:"text-sm","data-testid":"update-worker__agents","data-state":l.isLoading?"loading":l.isError?"error":h.length===0?"none":"some",children:l.isLoading?f.jsx("span",{className:"text-muted-foreground",children:"Checking running agents…"}):l.isError?f.jsx("span",{className:"text-destructive","data-testid":"update-worker__agents-error",children:"Could not check which agents are running on this worker."}):h.length===0?f.jsx("span",{className:"text-muted-foreground",children:"No agents are running on this worker."}):f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"mb-1 font-medium",children:[h.length===1?"1 agent":`${h.length} agents`," will be interrupted:"]}),f.jsx("ul",{className:"list-disc pl-5",children:h.map(p=>f.jsxs("li",{"data-testid":"update-worker__agent",children:[p.worktreeId," (",p.busy?"working":"idle",")"]},p.chatId))})]})}),s?f.jsx("p",{role:"alert","data-testid":"update-worker__error",className:"text-sm text-destructive",children:s}):null,f.jsxs(ii,{children:[f.jsx(Ce,{variant:"ghost",onClick:()=>r(!1),disabled:o,children:"Cancel"}),f.jsx(Ce,{variant:"destructive","data-testid":"update-worker__confirm",onClick:()=>{d()},disabled:o||l.isLoading||l.isError,children:o?"Installing…":"Update and restart"})]})]})})]})}const awn={current:null,ahead:"ahead of the hub",behind:"behind the hub",unknown:"version unknown, update recommended",refused:"update required"};function Dpe({label:t,testId:e,message:n,onDismiss:r}){return f.jsxs(t0,{children:[f.jsx(ku,{asChild:!0,children:f.jsx("button",{type:"button","aria-label":t,"data-testid":`${e}-icon`,className:"shrink-0 rounded-sm text-destructive",children:f.jsx(_u,{className:"size-3.5","aria-hidden":"true"})})}),f.jsxs(n0,{align:"start",className:"w-72 space-y-2 text-xs",children:[f.jsx("p",{role:"alert","data-testid":e,className:"break-words text-destructive",children:n}),r?f.jsx(Ce,{type:"button",variant:"outline",size:"sm","data-testid":"settings__host-update-dismiss",onClick:r,children:"Dismiss"}):null]})]})}function lwn({host:t,isAdmin:e}){const n=Rn(),r=awn[t.versionState],o=t.canUpdate&&e;return f.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground","data-testid":"settings__host-version-block",children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f.jsxs("span",{"data-testid":"settings__host-version","data-version":t.workerVersion??"unknown",children:["Version: ",t.workerVersion??"unknown"]}),r?f.jsx("span",{"data-testid":"settings__host-version-state","data-state":t.versionState,className:"rounded bg-warning-bg px-1.5 py-0.5 text-warning",children:r}):null,t.updateRequired?f.jsx(Dpe,{label:"Update required",testId:"settings__host-update-required",message:t.updateRequired}):null,t.update?.state==="failed"?f.jsx(Dpe,{label:"Update failed",testId:"settings__host-update-error",message:t.update.error,onDismiss:()=>{Se.workers.dismissUpdate.mutate({hostId:t.id}).then(()=>n.invalidateQueries({queryKey:JE}))}}):null,o?f.jsx(sHe,{host:t}):null]}),t.update&&t.update.state!=="failed"?f.jsxs("div",{"data-testid":"settings__host-update-progress",children:[t.update.state==="installing"?"Installing":"Restarting"," ",t.update.target,"…"]}):null,t.updateTarget&&!o&&t.manualCommand?f.jsxs("div",{className:"space-y-1",children:[f.jsx("div",{children:"Run on the worker, then restart it:"}),f.jsx(rU,{command:t.manualCommand,testId:"settings__host-manual",label:`Copy the update command for ${t.name}`})]}):null]})}const cwn={waiting:"Waiting for the command to run",provisioning:"Provisioning",online:"Online",failed:"Failed",expired:"Expired"};function uwn(){return i1()?.origin??window.location.origin}function zpe(t){navigator.clipboard?.writeText(t).catch(()=>{})}function dwn(){const t=fu(),e=It({queryKey:["provisioning","settings"],queryFn:()=>Se.provisioning.settings.query(),enabled:t}),[n,r]=v.useState(""),[o,i]=v.useState(""),[s,a]=v.useState(""),[l,c]=v.useState(""),[u,d]=v.useState(null),[h,p]=v.useState(null),[g,_]=v.useState(null),[x,y]=v.useState(null),[k,O]=v.useState(!1),C=v.useRef(!1);v.useEffect(()=>{!e.data||C.current||(C.current=!0,r(e.data.repoUrl),i(e.data.branch),a(e.data.command))},[e.data]);const A=u?.id;if(v.useEffect(()=>{if(!A)return;let L=!1,D=!1,I;const z=async()=>{if(!D)try{const{commands:Y}=await Se.provisioning.status.query({id:A}),Q=Y[0]??null;if(L)return;p(Q),Q&&["online","failed","expired"].includes(Q.status)&&(D=!0,clearInterval(I))}catch{}};return z(),I=setInterval(()=>{z()},2e3),()=>{L=!0,I&&clearInterval(I)}},[A]),!t)return null;const E=async()=>{_(null),y(null);try{await Se.provisioning.updateSettings.mutate({repoUrl:n.trim(),branch:o.trim(),command:s.trim()||void 0}),y("Saved. New commands use this repo."),await e.refetch()}catch(L){_(L instanceof Error?L.message:String(L))}},M=async()=>{O(!0),_(null),y(null);try{p(null),d(await Se.provisioning.createCommand.mutate({hubUrl:uwn(),hostName:l.trim()||void 0})),c("")}catch(L){_(L instanceof Error?L.message:String(L))}finally{O(!1)}},P=h?.status??"waiting";return f.jsx(_n,{variant:"stacked",label:"Add a worker",description:"Paste one command on a blank Linux or macOS computer. It works once and expires in an hour.",children:f.jsxs("div",{className:"space-y-2","data-testid":"settings__provision",children:[f.jsxs("details",{children:[f.jsx("summary",{className:"cursor-pointer text-xs font-medium",children:"Provisioning repo"}),f.jsxs("div",{className:"mt-2 space-y-2",children:[f.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. The hub fetches this repo with its git credential and the computer runs the start command from it before the worker starts. Leave it empty for the built-in install."}),f.jsx(Sn,{"aria-label":"Provisioning repo URL",placeholder:"https://github.com/you/dotfiles.git",value:n,onChange:L=>r(L.target.value),className:"h-8 text-sm"}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx(Sn,{"aria-label":"Provisioning repo branch",placeholder:"Branch (default branch if empty)",value:o,onChange:L=>i(L.target.value),className:"h-8 text-sm"}),f.jsx(Sn,{"aria-label":"Provisioning start command",placeholder:"band/provision.sh",value:s,onChange:L=>a(L.target.value),className:"h-8 text-sm"})]}),f.jsx(Ce,{type:"button",variant:"outline",size:"sm","data-testid":"settings__provision-save",onClick:()=>{E()},children:"Save repo"})]})]}),u?f.jsxs("div",{className:"space-y-2","data-testid":"settings__provision-result",children:[f.jsx("textarea",{"aria-label":"Provisioning command",readOnly:!0,rows:3,value:u.command,"data-testid":"settings__provision-command",className:"w-full rounded-md border border-border bg-transparent p-2 font-mono text-xs"}),f.jsxs("p",{className:"text-xs text-muted-foreground","data-testid":"settings__provision-expiry","data-expires-at":u.expiresAt,children:["Expires ",new Date(u.expiresAt).toLocaleString(),". It works once.",u.commitSha?` Repo pinned at ${u.commitSha.slice(0,12)}.`:""]}),f.jsxs("div",{className:"flex flex-wrap gap-2",children:[f.jsxs(Ce,{type:"button",variant:"outline",size:"sm","data-testid":"settings__provision-copy",onClick:()=>zpe(u.command),children:[f.jsx(z0,{className:"size-3"}),"Copy command"]}),f.jsxs(Ce,{type:"button",variant:"outline",size:"sm","data-testid":"settings__provision-copy-cloud-init",onClick:()=>zpe(u.cloudInit),children:[f.jsx(z0,{className:"size-3"}),"Copy as cloud-init"]}),f.jsx(Ce,{type:"button",variant:"ghost",size:"sm",onClick:()=>d(null),children:"Done"})]}),f.jsxs("div",{className:"text-xs","data-testid":"settings__provision-status","data-status":P,children:[cwn[P]??P,h?.hostId?` (${h.hostId})`:""]}),h?.log?f.jsx("pre",{"data-testid":"settings__provision-log",className:"max-h-64 overflow-auto rounded-md border border-border p-2 font-mono text-xs",children:h.log}):null]}):f.jsxs("div",{className:"flex gap-2",children:[f.jsx(Sn,{"aria-label":"Name for the new worker",placeholder:"Worker name (optional)",value:l,onChange:L=>c(L.target.value),className:"h-8 text-sm"}),f.jsxs(Ce,{type:"button",size:"sm",disabled:k,"data-testid":"settings__provision-create",onClick:()=>{M()},children:[f.jsx(xM,{className:"size-3"}),"Get provisioning command"]})]}),x?f.jsx("p",{className:"text-xs text-muted-foreground",children:x}):null,g?f.jsx("p",{role:"alert",className:"text-xs text-destructive","data-testid":"settings__provision-error",children:g}):null]})})}function aHe(){return Ho("pick_folder")}function lHe(){const[t,e]=v.useState(null),[n,r]=v.useState(!1),[o,i]=v.useState(null),[s,a]=v.useState(null),l=v.useCallback(async()=>{if(On)try{e(await Ho("worker_status"))}catch{e(null)}},[]);v.useEffect(()=>{l()},[l]);const c=v.useCallback(async(u,d)=>{r(!0),i(null),a(null);try{const h=await Ho(u,d);return h.ok?(h.note&&a(h.note),!0):(i(h.error),!1)}catch(h){return i(h instanceof Error?h.message:String(h)),!1}finally{r(!1),await l()}},[l]);return{status:t,busy:n,error:o,note:s,refresh:l,run:c}}function fwn(){const{status:t,busy:e,error:n,note:r,run:o}=lHe(),[i,s]=v.useState(""),[a,l]=v.useState([]);if(v.useEffect(()=>{t&&i===""&&s(t.defaultName)},[t,i]),!On||!t?.supported)return null;const c=async()=>{const d=await aHe().catch(()=>null);d&&!a.includes(d)&&l([...a,d])};let u;if(!t.remoteHub&&!t.installed)u=f.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"this-computer__local-hub",children:"This app runs its own hub, which already covers this computer."});else if(t.installed){const d=t.forThisHub?t.hostStatus??"unknown":"connected to another hub";u=f.jsxs("div",{className:"space-y-2 text-sm",children:[f.jsxs("div",{"data-testid":"this-computer__state","data-status":d,children:[t.name??"This computer",": ",d,t.bundled?` · worker ${t.version}`:" · installed from npm"]}),t.roots.length>0?f.jsxs("div",{className:"text-xs text-muted-foreground",children:["Folders: ",t.roots.join(", ")]}):null,f.jsxs("div",{className:"flex gap-2",children:[t.bundled?null:f.jsx(Ce,{type:"button",size:"sm","data-testid":"this-computer__switch",disabled:e,onClick:()=>{o("worker_switch_bundled")},children:"Switch to the worker in this app"}),f.jsx(Ce,{type:"button",variant:"outline",size:"sm","data-testid":"this-computer__remove",disabled:e,onClick:()=>{o("worker_remove")},children:e?"Working…":"Remove this computer"})]})]})}else u=f.jsxs("div",{className:"space-y-2",children:[f.jsx(Sn,{"aria-label":"Computer name","data-testid":"this-computer__name",value:i,maxLength:100,disabled:e,onChange:d=>s(d.target.value)}),a.map(d=>f.jsx("div",{className:"font-mono text-xs",children:d},d)),f.jsxs("div",{className:"flex gap-2",children:[f.jsx(Ce,{type:"button",variant:"outline",size:"sm",disabled:e,onClick:()=>{c()},children:"Add folder"}),f.jsx(Ce,{type:"button",size:"sm","data-testid":"this-computer__add",disabled:e||i.trim()==="",onClick:()=>{o("worker_add",{name:i,roots:a})},children:e?"Setting up…":"Add this computer"})]})]});return f.jsx(_n,{variant:"stacked",label:"Use this computer as a worker",description:"Run worktrees and agents on this Mac from the hub the app is connected to. The service runs the worker bundled in this app, so an app update updates it.",children:f.jsxs("div",{"data-testid":"this-computer",children:[u,r?f.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:r}):null,n?f.jsx("p",{role:"alert","data-testid":"this-computer__error",className:"mt-2 text-xs text-destructive",children:n}):null]})})}const $pe=[{id:"service",label:"npm service",hint:"Linux and macOS. Installs @band-app/worker (Node 22.5 or newer), then registers it as a systemd user unit on Linux or a launchd agent on macOS, so it starts at login and restarts on failure."},{id:"foreground",label:"npm foreground",hint:"Runs the worker in this terminal until you stop it. Needs @band-app/worker installed (npm install -g @band-app/worker)."},{id:"docker",label:"Docker run",hint:"Runs the published worker image. The volumes keep the worker's repositories and its identity across restarts."},{id:"compose",label:"Docker compose",hint:"Save as compose.yml on the worker machine and run docker compose up -d."}],hwn=new Set(["localhost","127.0.0.1","[::1]"]);function Bpe(t){try{return hwn.has(new URL(t).hostname)}catch{return!1}}function pwn(t,e){const{hubUrl:n,hostId:r,token:o}=e;switch(t){case"service":return["npm install -g @band-app/worker &&",`band-worker install-service --hub ${n} --worker-id ${r} --token ${o}`].join(" ");case"foreground":return[`BAND_HUB_URL=${n}`,`BAND_WORKER_ID=${r}`,`BAND_BOOTSTRAP_TOKEN=${o}`,"band-worker"].join(" ");case"docker":return["docker run -d --name band-worker --restart unless-stopped",...Bpe(n)?["--network host"]:[],"-v band-work:/work -v band-worker-state:/home/worker/.band/worker",`-e BAND_HUB_URL=${n} -e BAND_WORKER_ID=${r} -e BAND_WORKER_TOKEN=${o}`,"ghcr.io/band-app/band-worker:latest"].join(" ");case"compose":return["services:"," band-worker:"," image: ghcr.io/band-app/band-worker:latest"," restart: unless-stopped",...Bpe(n)?[" network_mode: host"]:[]," environment:",` BAND_HUB_URL: ${n}`,` BAND_WORKER_ID: ${r}`,` BAND_WORKER_TOKEN: ${o}`," volumes:"," - band-work:/work"," - band-worker-state:/home/worker/.band/worker","volumes:"," band-work:"," band-worker-state:",""].join(`
885
+ `},V9n={onDragStart(t){let{active:e}=t;return"Picked up draggable item "+e.id+"."},onDragOver(t){let{active:e,over:n}=t;return n?"Draggable item "+e.id+" was moved over droppable area "+n.id+".":"Draggable item "+e.id+" is no longer over a droppable area."},onDragEnd(t){let{active:e,over:n}=t;return n?"Draggable item "+e.id+" was dropped over droppable area "+n.id:"Draggable item "+e.id+" was dropped."},onDragCancel(t){let{active:e}=t;return"Dragging was cancelled. Draggable item "+e.id+" was dropped."}};function Q9n(t){let{announcements:e=V9n,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=q9n}=t;const{announce:i,announcement:s}=B9n(),a=Qx("DndLiveRegion"),[l,c]=v.useState(!1);if(v.useEffect(()=>{c(!0)},[]),H9n(v.useMemo(()=>({onDragStart(d){let{active:h}=d;i(e.onDragStart({active:h}))},onDragMove(d){let{active:h,over:p}=d;e.onDragMove&&i(e.onDragMove({active:h,over:p}))},onDragOver(d){let{active:h,over:p}=d;i(e.onDragOver({active:h,over:p}))},onDragEnd(d){let{active:h,over:p}=d;i(e.onDragEnd({active:h,over:p}))},onDragCancel(d){let{active:h,over:p}=d;i(e.onDragCancel({active:h,over:p}))}}),[i,e])),!l)return null;const u=Bt.createElement(Bt.Fragment,null,Bt.createElement(z9n,{id:r,value:o.draggable}),Bt.createElement($9n,{id:a,announcement:s}));return n?Bs.createPortal(u,n):u}var Qi;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(Qi||(Qi={}));function FE(){}function Gf(t,e){return v.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function Zj(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return v.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const Q0=Object.freeze({x:0,y:0});function pee(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function U9n(t,e){const n=HE(t);if(!n)return"0 0";const r={x:(n.x-e.left)/e.width*100,y:(n.y-e.top)/e.height*100};return r.x+"% "+r.y+"%"}function mee(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function W9n(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function BQ(t){let{left:e,top:n,height:r,width:o}=t;return[{x:e,y:n},{x:e+o,y:n},{x:e,y:n+r},{x:e+o,y:n+r}]}function L$e(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function spe(t,e,n){return e===void 0&&(e=t.left),n===void 0&&(n=t.top),{x:e+t.width*.5,y:n+t.height*.5}}const qE=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const o=spe(e,e.left,e.top),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=pee(spe(l),o);i.push({id:a,data:{droppableContainer:s,value:c}})}}return i.sort(mee)},Z9n=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const o=BQ(e),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=BQ(l),u=o.reduce((h,p,g)=>h+pee(c[g],p),0),d=Number((u/4).toFixed(4));i.push({id:a,data:{droppableContainer:s,value:d}})}}return i.sort(mee)};function G9n(t,e){const n=Math.max(e.top,t.top),r=Math.max(e.left,t.left),o=Math.min(e.left+e.width,t.left+t.width),i=Math.min(e.top+e.height,t.top+t.height),s=o-r,a=i-n;if(r<o&&n<i){const l=e.width*e.height,c=t.width*t.height,u=s*a,d=u/(l+c-u);return Number(d.toFixed(4))}return 0}const Y9n=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const o=[];for(const i of r){const{id:s}=i,a=n.get(s);if(a){const l=G9n(a,e);l>0&&o.push({id:s,data:{droppableContainer:i,value:l}})}}return o.sort(W9n)};function X9n(t,e){const{top:n,left:r,bottom:o,right:i}=e;return n<=t.y&&t.y<=o&&r<=t.x&&t.x<=i}const K9n=t=>{let{droppableContainers:e,droppableRects:n,pointerCoordinates:r}=t;if(!r)return[];const o=[];for(const i of e){const{id:s}=i,a=n.get(s);if(a&&X9n(r,a)){const c=BQ(a).reduce((d,h)=>d+pee(r,h),0),u=Number((c/4).toFixed(4));o.push({id:s,data:{droppableContainer:i,value:u}})}}return o.sort(mee)};function J9n(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function I$e(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:Q0}function ebn(t){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return o.reduce((s,a)=>({...s,top:s.top+t*a.y,bottom:s.bottom+t*a.y,left:s.left+t*a.x,right:s.right+t*a.x}),{...n})}}const tbn=ebn(1);function D$e(t){if(t.startsWith("matrix3d(")){const e=t.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(t.startsWith("matrix(")){const e=t.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function nbn(t,e,n){const r=D$e(e);if(!r)return t;const{scaleX:o,scaleY:i,x:s,y:a}=r,l=t.left-s-(1-o)*parseFloat(n),c=t.top-a-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),u=o?t.width/o:t.width,d=i?t.height/i:t.height;return{width:u,height:d,top:c,right:l+u,bottom:c+d,left:l}}const rbn={ignoreTransform:!1};function p8(t,e){e===void 0&&(e=rbn);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:c,transformOrigin:u}=Xa(t).getComputedStyle(t);c&&(n=nbn(n,c,u))}const{top:r,left:o,width:i,height:s,bottom:a,right:l}=n;return{top:r,left:o,width:i,height:s,bottom:a,right:l}}function ape(t){return p8(t,{ignoreTransform:!0})}function obn(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function ibn(t,e){return e===void 0&&(e=Xa(t).getComputedStyle(t)),e.position==="fixed"}function sbn(t,e){e===void 0&&(e=Xa(t).getComputedStyle(t));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const i=e[o];return typeof i=="string"?n.test(i):!1})}function Gj(t,e){const n=[];function r(o){if(e!=null&&n.length>=e||!o)return n;if(hee(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!qx(o)||j$e(o)||n.includes(o))return n;const i=Xa(t).getComputedStyle(o);return o!==t&&sbn(o,i)&&n.push(o),ibn(o,i)?n:r(o.parentNode)}return t?r(t):n}function z$e(t){const[e]=Gj(t,1);return e??null}function x$(t){return!Qj||!t?null:f8(t)?t:fee(t)?hee(t)||t===h8(t).scrollingElement?window:qx(t)?t:null:null}function $$e(t){return f8(t)?t.scrollX:t.scrollLeft}function B$e(t){return f8(t)?t.scrollY:t.scrollTop}function HQ(t){return{x:$$e(t),y:B$e(t)}}var fs;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(fs||(fs={}));function H$e(t){return!Qj||!t?!1:t===document.scrollingElement}function F$e(t){const e={x:0,y:0},n=H$e(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},r={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height},o=t.scrollTop<=e.y,i=t.scrollLeft<=e.x,s=t.scrollTop>=r.y,a=t.scrollLeft>=r.x;return{isTop:o,isLeft:i,isBottom:s,isRight:a,maxScroll:r,minScroll:e}}const abn={x:.2,y:.2};function lbn(t,e,n,r,o){let{top:i,left:s,right:a,bottom:l}=n;r===void 0&&(r=10),o===void 0&&(o=abn);const{isTop:c,isBottom:u,isLeft:d,isRight:h}=F$e(t),p={x:0,y:0},g={x:0,y:0},_={height:e.height*o.y,width:e.width*o.x};return!c&&i<=e.top+_.height?(p.y=fs.Backward,g.y=r*Math.abs((e.top+_.height-i)/_.height)):!u&&l>=e.bottom-_.height&&(p.y=fs.Forward,g.y=r*Math.abs((e.bottom-_.height-l)/_.height)),!h&&a>=e.right-_.width?(p.x=fs.Forward,g.x=r*Math.abs((e.right-_.width-a)/_.width)):!d&&s<=e.left+_.width&&(p.x=fs.Backward,g.x=r*Math.abs((e.left+_.width-s)/_.width)),{direction:p,speed:g}}function cbn(t){if(t===document.scrollingElement){const{innerWidth:i,innerHeight:s}=window;return{top:0,left:0,right:i,bottom:s,width:i,height:s}}const{top:e,left:n,right:r,bottom:o}=t.getBoundingClientRect();return{top:e,left:n,right:r,bottom:o,width:t.clientWidth,height:t.clientHeight}}function q$e(t){return t.reduce((e,n)=>p6(e,HQ(n)),Q0)}function ubn(t){return t.reduce((e,n)=>e+$$e(n),0)}function dbn(t){return t.reduce((e,n)=>e+B$e(n),0)}function V$e(t,e){if(e===void 0&&(e=p8),!t)return;const{top:n,left:r,bottom:o,right:i}=e(t);z$e(t)&&(o<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const fbn=[["x",["left","right"],ubn],["y",["top","bottom"],dbn]];class gee{constructor(e,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=Gj(n),o=q$e(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[i,s,a]of fbn)for(const l of s)Object.defineProperty(this,l,{get:()=>{const c=a(r),u=o[i]-c;return this.rect[l]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class U9{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=e}add(e,n,r){var o;(o=this.target)==null||o.addEventListener(e,n,r),this.listeners.push([e,n,r])}}function hbn(t){const{EventTarget:e}=Xa(t);return t instanceof e?t:h8(t)}function y$(t,e){const n=Math.abs(t.x),r=Math.abs(t.y);return typeof e=="number"?Math.sqrt(n**2+r**2)>e:"x"in e&&"y"in e?n>e.x&&r>e.y:"x"in e?n>e.x:"y"in e?r>e.y:!1}var Sc;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Sc||(Sc={}));function lpe(t){t.preventDefault()}function pbn(t){t.stopPropagation()}var Tr;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(Tr||(Tr={}));const Q$e={start:[Tr.Space,Tr.Enter],cancel:[Tr.Esc],end:[Tr.Space,Tr.Enter,Tr.Tab]},mbn=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case Tr.Right:return{...n,x:n.x+25};case Tr.Left:return{...n,x:n.x-25};case Tr.Down:return{...n,y:n.y+25};case Tr.Up:return{...n,y:n.y-25}}};class Yj{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:n}}=e;this.props=e,this.listeners=new U9(h8(n)),this.windowListeners=new U9(Xa(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Sc.Resize,this.handleCancel),this.windowListeners.add(Sc.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Sc.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&V$e(r),n(Q0)}handleKeyDown(e){if(Wj(e)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:i=Q$e,coordinateGetter:s=mbn,scrollBehavior:a="smooth"}=o,{code:l}=e;if(i.end.includes(l)){this.handleEnd(e);return}if(i.cancel.includes(l)){this.handleCancel(e);return}const{collisionRect:c}=r.current,u=c?{x:c.left,y:c.top}:Q0;this.referenceCoordinates||(this.referenceCoordinates=u);const d=s(e,{active:n,context:r.current,currentCoordinates:u});if(d){const h=v_(d,u),p={x:0,y:0},{scrollableAncestors:g}=r.current;for(const _ of g){const x=e.code,{isTop:y,isRight:k,isLeft:O,isBottom:C,maxScroll:A,minScroll:E}=F$e(_),M=cbn(_),P={x:Math.min(x===Tr.Right?M.right-M.width/2:M.right,Math.max(x===Tr.Right?M.left:M.left+M.width/2,d.x)),y:Math.min(x===Tr.Down?M.bottom-M.height/2:M.bottom,Math.max(x===Tr.Down?M.top:M.top+M.height/2,d.y))},L=x===Tr.Right&&!k||x===Tr.Left&&!O,D=x===Tr.Down&&!C||x===Tr.Up&&!y;if(L&&P.x!==d.x){const I=_.scrollLeft+h.x,z=x===Tr.Right&&I<=A.x||x===Tr.Left&&I>=E.x;if(z&&!h.y){_.scrollTo({left:I,behavior:a});return}z?p.x=_.scrollLeft-I:p.x=x===Tr.Right?_.scrollLeft-A.x:_.scrollLeft-E.x,p.x&&_.scrollBy({left:-p.x,behavior:a});break}else if(D&&P.y!==d.y){const I=_.scrollTop+h.y,z=x===Tr.Down&&I<=A.y||x===Tr.Up&&I>=E.y;if(z&&!h.x){_.scrollTo({top:I,behavior:a});return}z?p.y=_.scrollTop-I:p.y=x===Tr.Down?_.scrollTop-A.y:_.scrollTop-E.y,p.y&&_.scrollBy({top:-p.y,behavior:a});break}}this.handleMove(e,p6(v_(d,this.referenceCoordinates),p))}}}handleMove(e,n){const{onMove:r}=this.props;e.preventDefault(),r(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Yj.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=Q$e,onActivation:o}=e,{active:i}=n;const{code:s}=t.nativeEvent;if(r.start.includes(s)){const a=i.activatorNode.current;return a&&t.target!==a?!1:(t.preventDefault(),o?.({event:t.nativeEvent}),!0)}return!1}}];function cpe(t){return!!(t&&"distance"in t)}function upe(t){return!!(t&&"delay"in t)}class vee{constructor(e,n,r){var o;r===void 0&&(r=hbn(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=n;const{event:i}=e,{target:s}=i;this.props=e,this.events=n,this.document=h8(s),this.documentListeners=new U9(this.document),this.listeners=new U9(r),this.windowListeners=new U9(Xa(s)),this.initialCoordinates=(o=HE(i))!=null?o:Q0,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Sc.Resize,this.handleCancel),this.windowListeners.add(Sc.DragStart,lpe),this.windowListeners.add(Sc.VisibilityChange,this.handleCancel),this.windowListeners.add(Sc.ContextMenu,lpe),this.documentListeners.add(Sc.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(upe(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(cpe(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,n){const{active:r,onPending:o}=this.props;o(r,e,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:e}=this,{onStart:n}=this.props;e&&(this.activated=!0,this.documentListeners.add(Sc.Click,pbn,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Sc.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:o,props:i}=this,{onMove:s,options:{activationConstraint:a}}=i;if(!o)return;const l=(n=HE(e))!=null?n:Q0,c=v_(o,l);if(!r&&a){if(cpe(a)){if(a.tolerance!=null&&y$(c,a.tolerance))return this.handleCancel();if(y$(c,a.distance))return this.handleStart()}if(upe(a)&&y$(c,a.tolerance))return this.handleCancel();this.handlePending(a,c);return}e.cancelable&&e.preventDefault(),s(l)}handleEnd(){const{onAbort:e,onEnd:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleCancel(){const{onAbort:e,onCancel:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleKeydown(e){e.code===Tr.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const gbn={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class bee extends vee{constructor(e){const{event:n}=e,r=h8(n.target);super(e,gbn,r)}}bee.activators=[{eventName:"onPointerDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const vbn={move:{name:"mousemove"},end:{name:"mouseup"}};var FQ;(function(t){t[t.RightClick=2]="RightClick"})(FQ||(FQ={}));class Xj extends vee{constructor(e){super(e,vbn,h8(e.event.target))}}Xj.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===FQ.RightClick?!1:(r?.({event:n}),!0)}}];const w$={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class _ee extends vee{constructor(e){super(e,w$)}static setup(){return window.addEventListener(w$.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(w$.move.name,e)};function e(){}}}_ee.activators=[{eventName:"onTouchStart",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;const{touches:o}=n;return o.length>1?!1:(r?.({event:n}),!0)}}];var W9;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(W9||(W9={}));var VE;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(VE||(VE={}));function bbn(t){let{acceleration:e,activator:n=W9.Pointer,canScroll:r,draggingRect:o,enabled:i,interval:s=5,order:a=VE.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:u,delta:d,threshold:h}=t;const p=xbn({delta:d,disabled:!i}),[g,_]=N9n(),x=v.useRef({x:0,y:0}),y=v.useRef({x:0,y:0}),k=v.useMemo(()=>{switch(n){case W9.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case W9.DraggableRect:return o}},[n,o,l]),O=v.useRef(null),C=v.useCallback(()=>{const E=O.current;if(!E)return;const M=x.current.x*y.current.x,P=x.current.y*y.current.y;E.scrollBy(M,P)},[]),A=v.useMemo(()=>a===VE.TreeOrder?[...c].reverse():c,[a,c]);v.useEffect(()=>{if(!i||!c.length||!k){_();return}for(const E of A){if(r?.(E)===!1)continue;const M=c.indexOf(E),P=u[M];if(!P)continue;const{direction:L,speed:D}=lbn(E,P,k,e,h);for(const I of["x","y"])p[I][L[I]]||(D[I]=0,L[I]=0);if(D.x>0||D.y>0){_(),O.current=E,g(C,s),x.current=D,y.current=L;return}}x.current={x:0,y:0},y.current={x:0,y:0},_()},[e,C,r,_,i,s,JSON.stringify(k),JSON.stringify(p),g,c,A,u,JSON.stringify(h)])}const _bn={x:{[fs.Backward]:!1,[fs.Forward]:!1},y:{[fs.Backward]:!1,[fs.Forward]:!1}};function xbn(t){let{delta:e,disabled:n}=t;const r=BE(e);return Vx(o=>{if(n||!r||!o)return _bn;const i={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[fs.Backward]:o.x[fs.Backward]||i.x===-1,[fs.Forward]:o.x[fs.Forward]||i.x===1},y:{[fs.Backward]:o.y[fs.Backward]||i.y===-1,[fs.Forward]:o.y[fs.Forward]||i.y===1}}},[n,e,r])}function ybn(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return Vx(o=>{var i;return e==null?null:(i=r??o)!=null?i:null},[r,e])}function wbn(t,e){return v.useMemo(()=>t.reduce((n,r)=>{const{sensor:o}=r,i=o.activators.map(s=>({eventName:s.eventName,handler:e(s.handler,r)}));return[...n,...i]},[]),[t,e])}var b_;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(b_||(b_={}));var qQ;(function(t){t.Optimized="optimized"})(qQ||(qQ={}));const dpe=new Map;function kbn(t,e){let{dragging:n,dependencies:r,config:o}=e;const[i,s]=v.useState(null),{frequency:a,measure:l,strategy:c}=o,u=v.useRef(t),d=x(),h=g_(d),p=v.useCallback(function(y){y===void 0&&(y=[]),!h.current&&s(k=>k===null?y:k.concat(y.filter(O=>!k.includes(O))))},[h]),g=v.useRef(null),_=Vx(y=>{if(d&&!n)return dpe;if(!y||y===dpe||u.current!==t||i!=null){const k=new Map;for(let O of t){if(!O)continue;if(i&&i.length>0&&!i.includes(O.id)&&O.rect.current){k.set(O.id,O.rect.current);continue}const C=O.node.current,A=C?new gee(l(C),C):null;O.rect.current=A,A&&k.set(O.id,A)}return k}return y},[t,i,n,d,l]);return v.useEffect(()=>{u.current=t},[t]),v.useEffect(()=>{d||p()},[n,d]),v.useEffect(()=>{i&&i.length>0&&s(null)},[JSON.stringify(i)]),v.useEffect(()=>{d||typeof a!="number"||g.current!==null||(g.current=setTimeout(()=>{p(),g.current=null},a))},[a,d,p,...r]),{droppableRects:_,measureDroppableContainers:p,measuringScheduled:i!=null};function x(){switch(c){case b_.Always:return!1;case b_.BeforeDragging:return n;default:return!n}}}function xee(t,e){return Vx(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function Obn(t,e){return xee(t,e)}function Sbn(t){let{callback:e,disabled:n}=t;const r=Uj(e),o=v.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:i}=window;return new i(r)},[r,n]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function Kj(t){let{callback:e,disabled:n}=t;const r=Uj(e),o=v.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:i}=window;return new i(r)},[n]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function Cbn(t){return new gee(p8(t),t)}function fpe(t,e,n){e===void 0&&(e=Cbn);const[r,o]=v.useState(null);function i(){o(l=>{if(!t)return null;if(t.isConnected===!1){var c;return(c=l??n)!=null?c:null}const u=e(t);return JSON.stringify(l)===JSON.stringify(u)?l:u})}const s=Sbn({callback(l){if(t)for(const c of l){const{type:u,target:d}=c;if(u==="childList"&&d instanceof HTMLElement&&d.contains(t)){i();break}}}}),a=Kj({callback:i});return V0(()=>{i(),t?(a?.observe(t),s?.observe(document.body,{childList:!0,subtree:!0})):(a?.disconnect(),s?.disconnect())},[t]),r}function Abn(t){const e=xee(t);return I$e(t,e)}const hpe=[];function Ebn(t){const e=v.useRef(t),n=Vx(r=>t?r&&r!==hpe&&t&&e.current&&t.parentNode===e.current.parentNode?r:Gj(t):hpe,[t]);return v.useEffect(()=>{e.current=t},[t]),n}function Tbn(t){const[e,n]=v.useState(null),r=v.useRef(t),o=v.useCallback(i=>{const s=x$(i.target);s&&n(a=>a?(a.set(s,HQ(s)),new Map(a)):null)},[]);return v.useEffect(()=>{const i=r.current;if(t!==i){s(i);const a=t.map(l=>{const c=x$(l);return c?(c.addEventListener("scroll",o,{passive:!0}),[c,HQ(c)]):null}).filter(l=>l!=null);n(a.length?new Map(a):null),r.current=t}return()=>{s(t),s(i)};function s(a){a.forEach(l=>{const c=x$(l);c?.removeEventListener("scroll",o)})}},[o,t]),v.useMemo(()=>t.length?e?Array.from(e.values()).reduce((i,s)=>p6(i,s),Q0):q$e(t):Q0,[t,e])}function ppe(t,e){e===void 0&&(e=[]);const n=v.useRef(null);return v.useEffect(()=>{n.current=null},e),v.useEffect(()=>{const r=t!==Q0;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?v_(t,n.current):Q0}function Mbn(t){v.useEffect(()=>{if(!Qj)return;const e=t.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of e)n?.()}},t.map(e=>{let{sensor:n}=e;return n}))}function Pbn(t,e){return v.useMemo(()=>t.reduce((n,r)=>{let{eventName:o,handler:i}=r;return n[o]=s=>{i(s,e)},n},{}),[t,e])}function U$e(t){return v.useMemo(()=>t?obn(t):null,[t])}const mpe=[];function jbn(t,e){e===void 0&&(e=p8);const[n]=t,r=U$e(n?Xa(n):null),[o,i]=v.useState(mpe);function s(){i(()=>t.length?t.map(l=>H$e(l)?r:new gee(e(l),l)):mpe)}const a=Kj({callback:s});return V0(()=>{a?.disconnect(),s(),t.forEach(l=>a?.observe(l))},[t]),o}function W$e(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return qx(e)?e:t}function Nbn(t){let{measure:e}=t;const[n,r]=v.useState(null),o=v.useCallback(c=>{for(const{target:u}of c)if(qx(u)){r(d=>{const h=e(u);return d?{...d,width:h.width,height:h.height}:h});break}},[e]),i=Kj({callback:o}),s=v.useCallback(c=>{const u=W$e(c);i?.disconnect(),u&&i?.observe(u),r(u?e(u):null)},[e,i]),[a,l]=$E(s);return v.useMemo(()=>({nodeRef:a,rect:n,setRef:l}),[n,a,l])}const Rbn=[{sensor:bee,options:{}},{sensor:Yj,options:{}}],Lbn={current:{}},$S={draggable:{measure:ape},droppable:{measure:ape,strategy:b_.WhileDragging,frequency:qQ.Optimized},dragOverlay:{measure:p8}};class Z9 extends Map{get(e){var n;return e!=null&&(n=super.get(e))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:n}=e;return!n})}getNodeFor(e){var n,r;return(n=(r=this.get(e))==null?void 0:r.node.current)!=null?n:void 0}}const Ibn={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Z9,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:FE},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:$S,measureDroppableContainers:FE,windowRect:null,measuringScheduled:!1},Z$e={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:FE,draggableNodes:new Map,over:null,measureDroppableContainers:FE},Ux=v.createContext(Z$e),G$e=v.createContext(Ibn);function Dbn(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Z9}}}function zbn(t,e){switch(e.type){case Qi.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case Qi.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case Qi.DragEnd:case Qi.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Qi.RegisterDroppable:{const{element:n}=e,{id:r}=n,o=new Z9(t.droppable.containers);return o.set(r,n),{...t,droppable:{...t.droppable,containers:o}}}case Qi.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const s=new Z9(t.droppable.containers);return s.set(n,{...i,disabled:o}),{...t,droppable:{...t.droppable,containers:s}}}case Qi.UnregisterDroppable:{const{id:n,key:r}=e,o=t.droppable.containers.get(n);if(!o||r!==o.key)return t;const i=new Z9(t.droppable.containers);return i.delete(n),{...t,droppable:{...t.droppable,containers:i}}}default:return t}}function $bn(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:o}=v.useContext(Ux),i=BE(r),s=BE(n?.id);return v.useEffect(()=>{if(!e&&!r&&i&&s!=null){if(!Wj(i)||document.activeElement===i.target)return;const a=o.get(s);if(!a)return;const{activatorNode:l,node:c}=a;if(!l.current&&!c.current)return;requestAnimationFrame(()=>{for(const u of[l.current,c.current]){if(!u)continue;const d=I9n(u);if(d){d.focus();break}}})}},[r,e,o,s,i]),null}function Y$e(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((o,i)=>i({transform:o,...r}),n):n}function Bbn(t){return v.useMemo(()=>({draggable:{...$S.draggable,...t?.draggable},droppable:{...$S.droppable,...t?.droppable},dragOverlay:{...$S.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function Hbn(t){let{activeNode:e,measure:n,initialRect:r,config:o=!0}=t;const i=v.useRef(!1),{x:s,y:a}=typeof o=="boolean"?{x:o,y:o}:o;V0(()=>{if(!s&&!a||!e){i.current=!1;return}if(i.current||!r)return;const c=e?.node.current;if(!c||c.isConnected===!1)return;const u=n(c),d=I$e(u,r);if(s||(d.x=0),a||(d.y=0),i.current=!0,Math.abs(d.x)>0||Math.abs(d.y)>0){const h=z$e(c);h&&h.scrollBy({top:d.y,left:d.x})}},[e,s,a,r,n])}const Jj=v.createContext({...Q0,scaleX:1,scaleY:1});var _f;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(_f||(_f={}));const eN=v.memo(function(e){var n,r,o,i;let{id:s,accessibility:a,autoScroll:l=!0,children:c,sensors:u=Rbn,collisionDetection:d=Y9n,measuring:h,modifiers:p,...g}=e;const _=v.useReducer(zbn,void 0,Dbn),[x,y]=_,[k,O]=F9n(),[C,A]=v.useState(_f.Uninitialized),E=C===_f.Initialized,{draggable:{active:M,nodes:P,translate:L},droppable:{containers:D}}=x,I=M!=null?P.get(M):null,z=v.useRef({initial:null,translated:null}),Y=v.useMemo(()=>{var Ut;return M!=null?{id:M,data:(Ut=I?.data)!=null?Ut:Lbn,rect:z}:null},[M,I]),Q=v.useRef(null),[H,N]=v.useState(null),[V,G]=v.useState(null),K=g_(g,Object.values(g)),q=Qx("DndDescribedBy",s),Z=v.useMemo(()=>D.getEnabled(),[D]),U=Bbn(h),{droppableRects:B,measureDroppableContainers:ee,measuringScheduled:te}=kbn(Z,{dragging:E,dependencies:[L.x,L.y],config:U.droppable}),se=ybn(P,M),ae=v.useMemo(()=>V?HE(V):null,[V]),he=Dt(),fe=Obn(se,U.draggable.measure);Hbn({activeNode:M!=null?P.get(M):null,config:he.layoutShiftCompensation,initialRect:fe,measure:U.draggable.measure});const be=fpe(se,U.draggable.measure,fe),me=fpe(se?se.parentElement:null),le=v.useRef({activatorEvent:null,active:null,activeNode:se,collisionRect:null,collisions:null,droppableRects:B,draggableNodes:P,draggingNode:null,draggingNodeRect:null,droppableContainers:D,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Be=D.getNodeFor((n=le.current.over)==null?void 0:n.id),Xe=Nbn({measure:U.dragOverlay.measure}),ot=(r=Xe.nodeRef.current)!=null?r:se,Qe=E?(o=Xe.rect)!=null?o:be:null,lt=!!(Xe.nodeRef.current&&Xe.rect),bt=Abn(lt?null:be),ve=U$e(ot?Xa(ot):null),Te=Ebn(E?Be??se:null),pe=jbn(Te),Ne=Y$e(p,{transform:{x:L.x-bt.x,y:L.y-bt.y,scaleX:1,scaleY:1},activatorEvent:V,active:Y,activeNodeRect:be,containerNodeRect:me,draggingNodeRect:Qe,over:le.current.over,overlayNodeRect:Xe.rect,scrollableAncestors:Te,scrollableAncestorRects:pe,windowRect:ve}),$e=ae?p6(ae,L):null,De=Tbn(Te),ct=ppe(De),ue=ppe(De,[be]),Pe=p6(Ne,ct),Ee=Qe?tbn(Qe,Ne):null,Le=Y&&Ee?d({active:Y,collisionRect:Ee,droppableRects:B,droppableContainers:Z,pointerCoordinates:$e}):null,et=L$e(Le,"id"),[kt,tn]=v.useState(null),Kt=lt?Ne:p6(Ne,ue),Dn=J9n(Kt,(i=kt?.rect)!=null?i:null,be),Qt=v.useRef(null),Ve=v.useCallback((Ut,kn)=>{let{sensor:jt,options:pn}=kn;if(Q.current==null)return;const ke=P.get(Q.current);if(!ke)return;const Ke=Ut.nativeEvent,dt=new jt({active:Q.current,activeNode:ke,event:Ke,options:pn,context:le,onAbort(Yt){if(!P.get(Yt))return;const{onDragAbort:ir}=K.current,Nt={id:Yt};ir?.(Nt),k({type:"onDragAbort",event:Nt})},onPending(Yt,Wt,ir,Nt){if(!P.get(Yt))return;const{onDragPending:dn}=K.current,Kn={id:Yt,constraint:Wt,initialCoordinates:ir,offset:Nt};dn?.(Kn),k({type:"onDragPending",event:Kn})},onStart(Yt){const Wt=Q.current;if(Wt==null)return;const ir=P.get(Wt);if(!ir)return;const{onDragStart:Nt}=K.current,Xt={activatorEvent:Ke,active:{id:Wt,data:ir.data,rect:z}};Bs.unstable_batchedUpdates(()=>{Nt?.(Xt),A(_f.Initializing),y({type:Qi.DragStart,initialCoordinates:Yt,active:Wt}),k({type:"onDragStart",event:Xt}),N(Qt.current),G(Ke)})},onMove(Yt){y({type:Qi.DragMove,coordinates:Yt})},onEnd:sn(Qi.DragEnd),onCancel:sn(Qi.DragCancel)});Qt.current=dt;function sn(Yt){return async function(){const{active:ir,collisions:Nt,over:Xt,scrollAdjustedTranslate:dn}=le.current;let Kn=null;if(ir&&dn){const{cancelDrop:Ie}=K.current;Kn={activatorEvent:Ke,active:ir,collisions:Nt,delta:dn,over:Xt},Yt===Qi.DragEnd&&typeof Ie=="function"&&await Promise.resolve(Ie(Kn))&&(Yt=Qi.DragCancel)}Q.current=null,Bs.unstable_batchedUpdates(()=>{y({type:Yt}),A(_f.Uninitialized),tn(null),N(null),G(null),Qt.current=null;const Ie=Yt===Qi.DragEnd?"onDragEnd":"onDragCancel";if(Kn){const gt=K.current[Ie];gt?.(Kn),k({type:Ie,event:Kn})}})}}},[P]),Ct=v.useCallback((Ut,kn)=>(jt,pn)=>{const ke=jt.nativeEvent,Ke=P.get(pn);if(Q.current!==null||!Ke||ke.dndKit||ke.defaultPrevented)return;const dt={active:Ke};Ut(jt,kn.options,dt)===!0&&(ke.dndKit={capturedBy:kn.sensor},Q.current=pn,Ve(jt,kn))},[P,Ve]),Mt=wbn(u,Ct);Mbn(u),V0(()=>{be&&C===_f.Initializing&&A(_f.Initialized)},[be,C]),v.useEffect(()=>{const{onDragMove:Ut}=K.current,{active:kn,activatorEvent:jt,collisions:pn,over:ke}=le.current;if(!kn||!jt)return;const Ke={active:kn,activatorEvent:jt,collisions:pn,delta:{x:Pe.x,y:Pe.y},over:ke};Bs.unstable_batchedUpdates(()=>{Ut?.(Ke),k({type:"onDragMove",event:Ke})})},[Pe.x,Pe.y]),v.useEffect(()=>{const{active:Ut,activatorEvent:kn,collisions:jt,droppableContainers:pn,scrollAdjustedTranslate:ke}=le.current;if(!Ut||Q.current==null||!kn||!ke)return;const{onDragOver:Ke}=K.current,dt=pn.get(et),sn=dt&&dt.rect.current?{id:dt.id,rect:dt.rect.current,data:dt.data,disabled:dt.disabled}:null,Yt={active:Ut,activatorEvent:kn,collisions:jt,delta:{x:ke.x,y:ke.y},over:sn};Bs.unstable_batchedUpdates(()=>{tn(sn),Ke?.(Yt),k({type:"onDragOver",event:Yt})})},[et]),V0(()=>{le.current={activatorEvent:V,active:Y,activeNode:se,collisionRect:Ee,collisions:Le,droppableRects:B,draggableNodes:P,draggingNode:ot,draggingNodeRect:Qe,droppableContainers:D,over:kt,scrollableAncestors:Te,scrollAdjustedTranslate:Pe},z.current={initial:Qe,translated:Ee}},[Y,se,Le,Ee,P,ot,Qe,B,D,kt,Te,Pe]),bbn({...he,delta:L,draggingRect:Ee,pointerCoordinates:$e,scrollableAncestors:Te,scrollableAncestorRects:pe});const Ye=v.useMemo(()=>({active:Y,activeNode:se,activeNodeRect:be,activatorEvent:V,collisions:Le,containerNodeRect:me,dragOverlay:Xe,draggableNodes:P,droppableContainers:D,droppableRects:B,over:kt,measureDroppableContainers:ee,scrollableAncestors:Te,scrollableAncestorRects:pe,measuringConfiguration:U,measuringScheduled:te,windowRect:ve}),[Y,se,be,V,Le,me,Xe,P,D,B,kt,ee,Te,pe,U,te,ve]),Pt=v.useMemo(()=>({activatorEvent:V,activators:Mt,active:Y,activeNodeRect:be,ariaDescribedById:{draggable:q},dispatch:y,draggableNodes:P,over:kt,measureDroppableContainers:ee}),[V,Mt,Y,be,y,q,P,kt,ee]);return Bt.createElement(R$e.Provider,{value:O},Bt.createElement(Ux.Provider,{value:Pt},Bt.createElement(G$e.Provider,{value:Ye},Bt.createElement(Jj.Provider,{value:Dn},c)),Bt.createElement($bn,{disabled:a?.restoreFocus===!1})),Bt.createElement(Q9n,{...a,hiddenTextDescribedById:q}));function Dt(){const Ut=H?.autoScrollEnabled===!1,kn=typeof l=="object"?l.enabled===!1:l===!1,jt=E&&!Ut&&!kn;return typeof l=="object"?{...l,enabled:jt}:{enabled:jt}}}),Fbn=v.createContext(null),gpe="button",qbn="Draggable";function tN(t){let{id:e,data:n,disabled:r=!1,attributes:o}=t;const i=Qx(qbn),{activators:s,activatorEvent:a,active:l,activeNodeRect:c,ariaDescribedById:u,draggableNodes:d,over:h}=v.useContext(Ux),{role:p=gpe,roleDescription:g="draggable",tabIndex:_=0}=o??{},x=l?.id===e,y=v.useContext(x?Jj:Fbn),[k,O]=$E(),[C,A]=$E(),E=Pbn(s,e),M=g_(n);V0(()=>(d.set(e,{id:e,key:i,node:k,activatorNode:C,data:M}),()=>{const L=d.get(e);L&&L.key===i&&d.delete(e)}),[d,e]);const P=v.useMemo(()=>({role:p,tabIndex:_,"aria-disabled":r,"aria-pressed":x&&p===gpe?!0:void 0,"aria-roledescription":g,"aria-describedby":u.draggable}),[r,p,_,x,g,u.draggable]);return{active:l,activatorEvent:a,activeNodeRect:c,attributes:P,isDragging:x,listeners:r?void 0:E,node:k,over:h,setNodeRef:O,setActivatorNodeRef:A,transform:y}}function nN(){return v.useContext(G$e)}const Vbn="Droppable",Qbn={timeout:25};function rN(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:o}=t;const i=Qx(Vbn),{active:s,dispatch:a,over:l,measureDroppableContainers:c}=v.useContext(Ux),u=v.useRef({disabled:n}),d=v.useRef(!1),h=v.useRef(null),p=v.useRef(null),{disabled:g,updateMeasurementsFor:_,timeout:x}={...Qbn,...o},y=g_(_??r),k=v.useCallback(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{c(Array.isArray(y.current)?y.current:[y.current]),p.current=null},x)},[x]),O=Kj({callback:k,disabled:g||!s}),C=v.useCallback((P,L)=>{O&&(L&&(O.unobserve(L),d.current=!1),P&&O.observe(P))},[O]),[A,E]=$E(C),M=g_(e);return v.useEffect(()=>{!O||!A.current||(O.disconnect(),d.current=!1,O.observe(A.current))},[A,O]),v.useEffect(()=>(a({type:Qi.RegisterDroppable,element:{id:r,key:i,disabled:n,node:A,rect:h,data:M}}),()=>a({type:Qi.UnregisterDroppable,key:i,id:r})),[r]),v.useEffect(()=>{n!==u.current.disabled&&(a({type:Qi.SetDroppableDisabled,id:r,key:i,disabled:n}),u.current.disabled=n)},[r,i,n,a]),{active:s,rect:h,isOver:l?.id===r,node:A,over:l,setNodeRef:E}}function Ubn(t){let{animation:e,children:n}=t;const[r,o]=v.useState(null),[i,s]=v.useState(null),a=BE(n);return!n&&!r&&a&&o(a),V0(()=>{if(!i)return;const l=r?.key,c=r?.props.id;if(l==null||c==null){o(null);return}Promise.resolve(e(c,i)).then(()=>{o(null)})},[e,r,i]),Bt.createElement(Bt.Fragment,null,n,r?v.cloneElement(r,{ref:s}):null)}const Wbn={x:0,y:0,scaleX:1,scaleY:1};function Zbn(t){let{children:e}=t;return Bt.createElement(Ux.Provider,{value:Z$e},Bt.createElement(Jj.Provider,{value:Wbn},e))}const Gbn={position:"fixed",touchAction:"none"},Ybn=t=>Wj(t)?"transform 250ms ease":void 0,Xbn=v.forwardRef((t,e)=>{let{as:n,activatorEvent:r,adjustScale:o,children:i,className:s,rect:a,style:l,transform:c,transition:u=Ybn}=t;if(!a)return null;const d=o?c:{...c,scaleX:1,scaleY:1},h={...Gbn,width:a.width,height:a.height,top:a.top,left:a.left,transform:du.Transform.toString(d),transformOrigin:o&&r?U9n(r,a):void 0,transition:typeof u=="function"?u(r):u,...l};return Bt.createElement(n,{className:s,style:h,ref:e},i)}),Kbn=t=>e=>{let{active:n,dragOverlay:r}=e;const o={},{styles:i,className:s}=t;if(i!=null&&i.active)for(const[a,l]of Object.entries(i.active))l!==void 0&&(o[a]=n.node.style.getPropertyValue(a),n.node.style.setProperty(a,l));if(i!=null&&i.dragOverlay)for(const[a,l]of Object.entries(i.dragOverlay))l!==void 0&&r.node.style.setProperty(a,l);return s!=null&&s.active&&n.node.classList.add(s.active),s!=null&&s.dragOverlay&&r.node.classList.add(s.dragOverlay),function(){for(const[l,c]of Object.entries(o))n.node.style.setProperty(l,c);s!=null&&s.active&&n.node.classList.remove(s.active)}},Jbn=t=>{let{transform:{initial:e,final:n}}=t;return[{transform:du.Transform.toString(e)},{transform:du.Transform.toString(n)}]},e_n={duration:250,easing:"ease",keyframes:Jbn,sideEffects:Kbn({styles:{active:{opacity:"0"}}})};function t_n(t){let{config:e,draggableNodes:n,droppableContainers:r,measuringConfiguration:o}=t;return Uj((i,s)=>{if(e===null)return;const a=n.get(i);if(!a)return;const l=a.node.current;if(!l)return;const c=W$e(s);if(!c)return;const{transform:u}=Xa(s).getComputedStyle(s),d=D$e(u);if(!d)return;const h=typeof e=="function"?e:n_n(e);return V$e(l,o.draggable.measure),h({active:{id:i,data:a.data,node:l,rect:o.draggable.measure(l)},draggableNodes:n,dragOverlay:{node:s,rect:o.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:o,transform:d})})}function n_n(t){const{duration:e,easing:n,sideEffects:r,keyframes:o}={...e_n,...t};return i=>{let{active:s,dragOverlay:a,transform:l,...c}=i;if(!e)return;const u={x:a.rect.left-s.rect.left,y:a.rect.top-s.rect.top},d={scaleX:l.scaleX!==1?s.rect.width*l.scaleX/a.rect.width:1,scaleY:l.scaleY!==1?s.rect.height*l.scaleY/a.rect.height:1},h={x:l.x-u.x,y:l.y-u.y,...d},p=o({...c,active:s,dragOverlay:a,transform:{initial:l,final:h}}),[g]=p,_=p[p.length-1];if(JSON.stringify(g)===JSON.stringify(_))return;const x=r?.({active:s,dragOverlay:a,...c}),y=a.node.animate(p,{duration:e,easing:n,fill:"forwards"});return new Promise(k=>{y.onfinish=()=>{x?.(),k()}})}}let vpe=0;function r_n(t){return v.useMemo(()=>{if(t!=null)return vpe++,vpe},[t])}const o_n=Bt.memo(t=>{let{adjustScale:e=!1,children:n,dropAnimation:r,style:o,transition:i,modifiers:s,wrapperElement:a="div",className:l,zIndex:c=999}=t;const{activatorEvent:u,active:d,activeNodeRect:h,containerNodeRect:p,draggableNodes:g,droppableContainers:_,dragOverlay:x,over:y,measuringConfiguration:k,scrollableAncestors:O,scrollableAncestorRects:C,windowRect:A}=nN(),E=v.useContext(Jj),M=r_n(d?.id),P=Y$e(s,{activatorEvent:u,active:d,activeNodeRect:h,containerNodeRect:p,draggingNodeRect:x.rect,over:y,overlayNodeRect:x.rect,scrollableAncestors:O,scrollableAncestorRects:C,transform:E,windowRect:A}),L=xee(h),D=t_n({config:r,draggableNodes:g,droppableContainers:_,measuringConfiguration:k}),I=L?x.setRef:void 0;return Bt.createElement(Zbn,null,Bt.createElement(Ubn,{animation:D},d&&M?Bt.createElement(Xbn,{key:M,id:d.id,ref:I,as:a,activatorEvent:u,adjustScale:e,className:l,transition:i,rect:L,style:{zIndex:c,...o},transform:P},n):null))});function oN(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function i_n(t,e){return t.reduce((n,r,o)=>{const i=e.get(r);return i&&(n[o]=i),n},Array(t.length))}function Xk(t){return t!==null&&t>=0}function s_n(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function a_n(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const X$e=t=>{let{rects:e,activeIndex:n,overIndex:r,index:o}=t;const i=oN(e,r,n),s=e[o],a=i[o];return!a||!s?null:{x:a.left-s.left,y:a.top-s.top,scaleX:a.width/s.width,scaleY:a.height/s.height}},Kk={scaleX:1,scaleY:1},yee=t=>{var e;let{activeIndex:n,activeNodeRect:r,index:o,rects:i,overIndex:s}=t;const a=(e=i[n])!=null?e:r;if(!a)return null;if(o===n){const c=i[s];return c?{x:0,y:n<s?c.top+c.height-(a.top+a.height):c.top-a.top,...Kk}:null}const l=l_n(i,o,n);return o>n&&o<=s?{x:0,y:-a.height-l,...Kk}:o<n&&o>=s?{x:0,y:a.height+l,...Kk}:{x:0,y:0,...Kk}};function l_n(t,e,n){const r=t[e],o=t[e-1],i=t[e+1];return r?n<e?o?r.top-(o.top+o.height):i?i.top-(r.top+r.height):0:i?i.top-(r.top+r.height):o?r.top-(o.top+o.height):0:0}const K$e="Sortable",J$e=Bt.createContext({activeIndex:-1,containerId:K$e,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:X$e,disabled:{draggable:!1,droppable:!1}});function wee(t){let{children:e,id:n,items:r,strategy:o=X$e,disabled:i=!1}=t;const{active:s,dragOverlay:a,droppableRects:l,over:c,measureDroppableContainers:u}=nN(),d=Qx(K$e,n),h=a.rect!==null,p=v.useMemo(()=>r.map(E=>typeof E=="object"&&"id"in E?E.id:E),[r]),g=s!=null,_=s?p.indexOf(s.id):-1,x=c?p.indexOf(c.id):-1,y=v.useRef(p),k=!s_n(p,y.current),O=x!==-1&&_===-1||k,C=a_n(i);V0(()=>{k&&g&&u(p)},[k,p,g,u]),v.useEffect(()=>{y.current=p},[p]);const A=v.useMemo(()=>({activeIndex:_,containerId:d,disabled:C,disableTransforms:O,items:p,overIndex:x,useDragOverlay:h,sortedRects:i_n(p,l),strategy:o}),[_,d,C.draggable,C.droppable,O,p,x,l,h,o]);return Bt.createElement(J$e.Provider,{value:A},e)}const c_n=t=>{let{id:e,items:n,activeIndex:r,overIndex:o}=t;return oN(n,r,o).indexOf(e)},u_n=t=>{let{containerId:e,isSorting:n,wasDragging:r,index:o,items:i,newIndex:s,previousItems:a,previousContainerId:l,transition:c}=t;return!c||!r||a!==i&&o===s?!1:n?!0:s!==o&&e===l},d_n={duration:200,easing:"ease"},eBe="transform",f_n=du.Transition.toString({property:eBe,duration:0,easing:"linear"}),h_n={roleDescription:"sortable"};function p_n(t){let{disabled:e,index:n,node:r,rect:o}=t;const[i,s]=v.useState(null),a=v.useRef(n);return V0(()=>{if(!e&&n!==a.current&&r.current){const l=o.current;if(l){const c=p8(r.current,{ignoreTransform:!0}),u={x:l.left-c.left,y:l.top-c.top,scaleX:l.width/c.width,scaleY:l.height/c.height};(u.x||u.y)&&s(u)}}n!==a.current&&(a.current=n)},[e,n,r,o]),v.useEffect(()=>{i&&s(null)},[i]),i}function kee(t){let{animateLayoutChanges:e=u_n,attributes:n,disabled:r,data:o,getNewIndex:i=c_n,id:s,strategy:a,resizeObserverConfig:l,transition:c=d_n}=t;const{items:u,containerId:d,activeIndex:h,disabled:p,disableTransforms:g,sortedRects:_,overIndex:x,useDragOverlay:y,strategy:k}=v.useContext(J$e),O=m_n(r,p),C=u.indexOf(s),A=v.useMemo(()=>({sortable:{containerId:d,index:C,items:u},...o}),[d,o,C,u]),E=v.useMemo(()=>u.slice(u.indexOf(s)),[u,s]),{rect:M,node:P,isOver:L,setNodeRef:D}=rN({id:s,data:A,disabled:O.droppable,resizeObserverConfig:{updateMeasurementsFor:E,...l}}),{active:I,activatorEvent:z,activeNodeRect:Y,attributes:Q,setNodeRef:H,listeners:N,isDragging:V,over:G,setActivatorNodeRef:K,transform:q}=tN({id:s,data:A,attributes:{...h_n,...n},disabled:O.draggable}),Z=j9n(D,H),U=!!I,B=U&&!g&&Xk(h)&&Xk(x),ee=!y&&V,te=ee&&B?q:null,ae=B?te??(a??k)({rects:_,activeNodeRect:Y,activeIndex:h,overIndex:x,index:C}):null,he=Xk(h)&&Xk(x)?i({id:s,items:u,activeIndex:h,overIndex:x}):C,fe=I?.id,be=v.useRef({activeId:fe,items:u,newIndex:he,containerId:d}),me=u!==be.current.items,le=e({active:I,containerId:d,isDragging:V,isSorting:U,id:s,index:C,items:u,newIndex:be.current.newIndex,previousItems:be.current.items,previousContainerId:be.current.containerId,transition:c,wasDragging:be.current.activeId!=null}),Be=p_n({disabled:!le,index:C,node:P,rect:M});return v.useEffect(()=>{U&&be.current.newIndex!==he&&(be.current.newIndex=he),d!==be.current.containerId&&(be.current.containerId=d),u!==be.current.items&&(be.current.items=u)},[U,he,d,u]),v.useEffect(()=>{if(fe===be.current.activeId)return;if(fe!=null&&be.current.activeId==null){be.current.activeId=fe;return}const ot=setTimeout(()=>{be.current.activeId=fe},50);return()=>clearTimeout(ot)},[fe]),{active:I,activeIndex:h,attributes:Q,data:A,rect:M,index:C,newIndex:he,items:u,isOver:L,isSorting:U,isDragging:V,listeners:N,node:P,overIndex:x,over:G,setNodeRef:Z,setActivatorNodeRef:K,setDroppableNodeRef:D,setDraggableNodeRef:H,transform:Be??ae,transition:Xe()};function Xe(){if(Be||me&&be.current.newIndex===C)return f_n;if(!(ee&&!Wj(z)||!c)&&(U||le))return du.Transition.toString({...c,property:eBe})}}function m_n(t,e){var n,r;return typeof t=="boolean"?{draggable:t,droppable:!1}:{draggable:(n=t?.draggable)!=null?n:e.draggable,droppable:(r=t?.droppable)!=null?r:e.droppable}}function QE(t){if(!t)return!1;const e=t.data.current;return!!(e&&"sortable"in e&&typeof e.sortable=="object"&&"containerId"in e.sortable&&"items"in e.sortable&&"index"in e.sortable)}const g_n=[Tr.Down,Tr.Right,Tr.Up,Tr.Left],tBe=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:i,over:s,scrollableAncestors:a}}=e;if(g_n.includes(t.code)){if(t.preventDefault(),!n||!r)return;const l=[];i.getEnabled().forEach(d=>{if(!d||d!=null&&d.disabled)return;const h=o.get(d.id);if(h)switch(t.code){case Tr.Down:r.top<h.top&&l.push(d);break;case Tr.Up:r.top>h.top&&l.push(d);break;case Tr.Left:r.left>h.left&&l.push(d);break;case Tr.Right:r.left<h.left&&l.push(d);break}});const c=Z9n({collisionRect:r,droppableRects:o,droppableContainers:l});let u=L$e(c,"id");if(u===s?.id&&c.length>1&&(u=c[1].id),u!=null){const d=i.get(n.id),h=i.get(u),p=h?o.get(h.id):null,g=h?.node.current;if(g&&p&&d&&h){const x=Gj(g).some((E,M)=>a[M]!==E),y=nBe(d,h),k=v_n(d,h),O=x||!y?{x:0,y:0}:{x:k?r.width-p.width:0,y:k?r.height-p.height:0},C={x:p.left,y:p.top};return O.x&&O.y?C:v_(C,O)}}}};function nBe(t,e){return!QE(t)||!QE(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function v_n(t,e){return!QE(t)||!QE(e)||!nBe(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}const VQ=["hostRequests.list"];function b_n(){const t=Rr(),e=Rn();return v.useEffect(()=>t.subscribeStatusEvents(r=>{if(r.kind==="host-status-changed"){e.invalidateQueries({queryKey:Un.repos});return}r.kind==="host-request-changed"&&(e.invalidateQueries({queryKey:VQ}),e.invalidateQueries({queryKey:Un.repos}))}),[t,e]),It({queryKey:VQ,queryFn:async()=>(await Se.hostRequests.list.query()).requests}).data??[]}function __n(){const t=Rn();return $s({mutationFn:e=>Se.hostRequests.cancel.mutate({requestId:e}),onSettled:()=>t.invalidateQueries({queryKey:VQ})})}function rBe(){const t=Rr(),e=Rn(),n=Cn(c=>c.setError),{repos:r}=xs(),o=v.useMemo(()=>{const c=[];for(const u of r)for(const d of u.worktrees)d.pinned&&c.push({repo:u,worktree:d,worktreeId:jr(u.name,d.name,d.hostId)});return c},[r]),i=v.useMemo(()=>new Set(o.map(c=>c.worktreeId)),[o]),s=v.useCallback(c=>i.has(c),[i]),a=$s({mutationFn:({repo:c,name:u,pinned:d,hostId:h})=>t.setWorktreePinned(c,u,d,h),onMutate:async({repo:c,name:u,pinned:d,hostId:h})=>{await e.cancelQueries({queryKey:Un.repos});const p=e.getQueryData(Un.repos);if(p){const g=p.map(_=>_.name===c?{..._,worktrees:_.worktrees.map(x=>x.name===u&&(x.hostId??"local")===(h??"local")?{...x,pinned:d}:x)}:_);e.setQueryData(Un.repos,g)}return{previous:p}},onError:(c,u,d)=>{d?.previous&&e.setQueryData(Un.repos,d.previous),n(c)},onSettled:()=>{e.invalidateQueries({queryKey:Un.repos})}}),l=v.useCallback((c,u,d,h)=>a.mutate({repo:c,name:u,pinned:!d,hostId:h}),[a.mutate]);return{pinned:o,isPinned:s,toggle:l}}function x_n(){const t=Rr(),e=Rn(),n=Cn(r=>r.setError);return $s({mutationFn:r=>t.removeRepo(r),onSuccess:()=>{e.invalidateQueries({queryKey:Un.repos})},onError:r=>{n(r)}})}function y_n(){const t=Rr(),e=Rn(),n=Cn(r=>r.setError);return $s({mutationFn:r=>t.reorderRepos(r),onMutate:async r=>{await e.cancelQueries({queryKey:Un.repos});const o=e.getQueryData(Un.repos);if(o){const i=[...o].sort((s,a)=>r.indexOf(s.name)-r.indexOf(a.name));e.setQueryData(Un.repos,i)}return{previous:o}},onError:(r,o,i)=>{i?.previous&&e.setQueryData(Un.repos,i.previous),n(r)},onSettled:()=>{e.invalidateQueries({queryKey:Un.repos})}})}function w_n(){const t=Rr(),e=Rn(),n=Cn(r=>r.setError);return $s({mutationFn:r=>t.reorderWorktrees(r),onMutate:async r=>{await e.cancelQueries({queryKey:Un.repos});const o=e.getQueryData(Un.repos);if(o){const i=l=>l??"local",s=r.scope==="pins"?"pinSortIndex":"sortIndex",a=o.map(l=>({...l,worktrees:l.worktrees.map(c=>{const u=r.order.findIndex(p=>p.repo===l.name&&p.name===c.name&&i(p.hostId)===i(c.hostId));let d=u===-1?c:{...c,[s]:u};const h=r.reparent;return h&&h.repo===l.name&&h.name===c.name&&i(h.hostId)===i(c.hostId)&&(d={...d,origin:h.origin===null?null:{worktreeId:h.origin,removed:!1}}),d})}));e.setQueryData(Un.repos,a)}return{previous:o}},onError:(r,o,i)=>{i?.previous&&e.setQueryData(Un.repos,i.previous),n(r)},onSettled:()=>{e.invalidateQueries({queryKey:Un.repos})}})}function k_n(){const t=Rr(),e=Rn(),n=Cn(r=>r.setError);return $s({mutationFn:r=>t.promoteRepoToGit?t.promoteRepoToGit(r):Promise.reject(new Error("This dashboard adapter doesn't support promoting plain repos to git.")),onSuccess:()=>{e.invalidateQueries({queryKey:Un.repos})},onError:r=>{n(r)}})}function O_n(){const t=Rr(),e=Rn(),n=Cn(o=>o.setError),r=Cn(o=>o.openWorktree);return $s({mutationFn:({repo:o,branch:i,base:s,prompt:a,host:l,groupId:c})=>t.createWorktree(o,i,s,a,Fb(),l,c),onSuccess:(o,i)=>{e.invalidateQueries({queryKey:Un.repos});const s=jr(i.repo,i.branch,o.hostId??i.host?.hostId);r(s)},onError:o=>{n(o)}})}function oBe(){const t=Rr(),e=Rn(),n=Cn(s=>s.setError),r=Cn(s=>s.openWorktree),o=Cn(s=>s.setDeleting),i=Hye();return $s({mutationFn:({repo:s,name:a,hostId:l})=>t.removeWorktree(s,a,l),onMutate:({repo:s,name:a,hostId:l})=>{o(jr(s,a,l),!0)},onSuccess:async(s,{repo:a,name:l,hostId:c})=>{await e.invalidateQueries({queryKey:Un.repos});const u=jr(a,l,c);if(i.getState().activeWorktreeId===u){const h=e.getQueryData(Un.repos)?.find(p=>p.name===a);if(h){const p=h.worktrees.find(g=>(g.name===h.defaultBranch||g.branch===h.defaultBranch)&&(g.hostId??"local")===(c??"local"));r(jr(a,p?.name??h.defaultBranch,p?.hostId??c))}}},onError:s=>{n(s)},onSettled:(s,a,{repo:l,name:c,hostId:u})=>{o(jr(l,c,u),!1)}})}function iBe(t,e,n){const r=t.indexOf(e),o=r+n;if(r<0||o<0||o>=t.length)return null;const i=[...t];return[i[r],i[o]]=[i[o],i[r]],i}function S_n(t,e,n){const r=t.indexOf(e),o=t.indexOf(n);if(r<0||o<0||r===o)return null;const i=[...t];return i.splice(r,1),i.splice(o,0,e),i}const gg={type:"none"},sBe=t=>({repo:t.repo.name,name:t.worktree.name,hostId:t.worktree.hostId});function C_n(t,e,n){const r=t.height>0?(e-t.top)/t.height:.5;return n?r<.25?"before":r>.75?"after":"into":r<.5?"before":"after"}function Oee(t,e,n,r){const o=t.filter(s=>s!==e),i=o.indexOf(n);return i===-1?t:(o.splice(r==="before"?i:i+1,0,e),o)}function aBe(t,e,n){const r=e.flatMap(o=>{const i=t.get(o);return i?[sBe(i)]:[]});return r.length===0?gg:{type:"reorder",scope:n,order:r}}function A_n(t,e,n,r){if(e===n||r==="into")return null;const o=Oee(t,e,n,r);return o.join("|")===t.join("|")?null:o}function E_n(t,e,n,r){if(e===n||r==="into")return gg;const o=new Map(t.pins.map(s=>[s.worktreeId,s])),i=Oee(t.pins.map(s=>s.worktreeId),e,n,r);return aBe(o,i,"pins")}function T_n(t,e,n,r){if(e===n||r==="into")return gg;const o=new Map(t.map(s=>[s.worktreeId,s]));if(!o.has(e)||!o.has(n))return gg;const i=Oee(t.map(s=>s.worktreeId),e,n,r);return aBe(o,i,"siblings")}function M_n(t,e,n,r){if(e===n)return{type:"refuse",reason:"A worktree can't become its own parent."};const o=t.find(d=>d.worktreeId===e),i=t.find(d=>d.worktreeId===n);if(!o||!i)return gg;const s=new Set([e,...O$e(t,e).map(d=>d.worktreeId)]),a={type:"refuse",reason:"A worktree can't become a child of one that was started from it."};let l;if(r==="into"){if(s.has(n))return a;l=n}else{const d=i.worktree.origin?.worktreeId;if(l=d!==void 0&&t.some(p=>p.worktreeId===d)?d:null,l!==null&&s.has(l))return a}const c=i.worktree.groupId??null;return(o.worktree.origin?.worktreeId??null)===l&&(o.worktree.groupId??null)===c?gg:{type:"parent",worktree:sBe(o),worktreeId:e,origin:l,groupId:c}}function P_n({open:t,onOpenChange:e,onConfirm:n,branchName:r,isUnmerged:o,isDirty:i,hasUnpushedCommits:s}){return f.jsx(nr,{open:t,onOpenChange:e,children:f.jsxs(rr,{className:"sm:max-w-[425px]",onClick:a=>a.stopPropagation(),children:[f.jsxs(hr,{children:[f.jsx(or,{children:"Delete worktree"}),f.jsxs(Nr,{children:["Are you sure you want to delete ",f.jsx("strong",{children:r}),"?"]})]}),f.jsxs("div",{className:"flex flex-col gap-2 text-sm",children:[o&&f.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-warning/30 bg-warning-bg p-3",children:[f.jsx(Mc,{className:"size-4 shrink-0 text-warning mt-0.5"}),f.jsx("span",{children:"This branch has not been merged to main."})]}),s&&f.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-warning/30 bg-warning-bg p-3",children:[f.jsx(Mc,{className:"size-4 shrink-0 text-warning mt-0.5"}),f.jsx("span",{children:"This branch has unpushed commits that will be lost."})]}),i&&f.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-warning/30 bg-warning-bg p-3",children:[f.jsx(Mc,{className:"size-4 shrink-0 text-warning mt-0.5"}),f.jsx("span",{children:"There are uncommitted changes that will be lost."})]})]}),f.jsxs(ii,{children:[f.jsx(Ce,{variant:"ghost",onClick:()=>e(!1),children:"Cancel"}),f.jsx(Ce,{variant:"destructive",onClick:n,children:"Delete"})]})]})})}const QQ=[{name:"Indigo",value:"#6366f1"},{name:"Blue",value:"#3b82f6"},{name:"Green",value:"#22c55e"},{name:"Amber",value:"#f59e0b"},{name:"Red",value:"#ef4444"},{name:"Pink",value:"#ec4899"},{name:"Gray",value:"#6b7280"}],j_n="flex size-8 items-center justify-center rounded-full text-white";function lBe({color:t,onChange:e,testId:n,Swatch:r="button",custom:o=!0}){const i=v.useRef(null);return f.jsxs("div",{className:"flex w-44 flex-col gap-2 p-1",children:[f.jsx("div",{className:"grid grid-cols-4 gap-2",children:QQ.map(s=>f.jsx(r,{...r==="button"?{type:"button"}:{},"aria-label":s.name,"aria-pressed":t.toLowerCase()===s.value,"data-testid":`${n}--${s.name.toLowerCase()}`,onClick:()=>e(s.value),className:j_n,style:{backgroundColor:s.value},children:t.toLowerCase()===s.value?f.jsx(Ji,{className:"size-4"}):null},s.value))}),o?f.jsxs(f.Fragment,{children:[f.jsx("button",{type:"button","data-testid":`${n}-custom-button`,onClick:()=>i.current?.click(),className:"rounded px-2 py-1 text-left text-xs text-foreground hover:bg-accent",children:"Custom colour…"}),f.jsx("input",{ref:i,type:"color","aria-label":"Custom colour","data-testid":`${n}-custom`,value:t,onChange:s=>e(s.target.value),className:"sr-only",tabIndex:-1})]}):null]})}function N_n({color:t,onChange:e,label:n,testId:r,dotTestId:o,children:i}){const[s,a]=v.useState(!1);return f.jsxs(t0,{open:s,onOpenChange:a,children:[f.jsx(ku,{asChild:!0,children:f.jsxs("button",{type:"button","aria-label":n,"data-testid":o,className:"flex size-6 shrink-0 items-center justify-center rounded hover:bg-accent/50",children:[f.jsx("span",{className:"size-3 rounded-full",style:{backgroundColor:t}}),i]})}),f.jsx(n0,{align:"start",className:"w-auto p-2",children:f.jsx(lBe,{color:t,testId:r,onChange:l=>{e(l),a(!1)}})})]})}const iN=v.createContext({overId:null,zone:null});function cBe({dndId:t,data:e,disabled:n,className:r,style:o,testId:i,children:s}){const a=tN({id:t,data:e,disabled:n}),l=rN({id:t,data:e}),{overId:c,zone:u}=v.useContext(iN),d=v.useCallback(p=>{a.setNodeRef(p),l.setNodeRef(p)},[a.setNodeRef,l.setNodeRef]),h=c===t&&!a.isDragging?u:null;return f.jsxs("div",{ref:d,"data-testid":i,"data-dnd-id":t,"data-drop-zone":h??void 0,className:`relative [-webkit-touch-callout:none] ${a.isDragging?"opacity-40":""} ${h==="into"?"rounded-md bg-primary/15":""} ${r??""}`,style:o,...a.listeners,children:[h==="before"&&f.jsx("span",{className:"pointer-events-none absolute inset-x-0 top-0 z-10 h-0.5 bg-primary"}),s,h==="after"&&f.jsx("span",{className:"pointer-events-none absolute inset-x-0 bottom-0 z-10 h-0.5 bg-primary"})]})}function R_n({dndId:t,groupId:e,children:n}){const r=rN({id:t,data:{kind:"group",groupId:e}}),o=tN({id:`grouphdr:${e??"none"}`,data:{kind:"groupmove",groupId:e},disabled:e===null}),{overId:i,zone:s}=v.useContext(iN),a=v.useCallback(c=>{r.setNodeRef(c),o.setNodeRef(c)},[r.setNodeRef,o.setNodeRef]),l=i===t&&!o.isDragging;return f.jsx(f.Fragment,{children:n({setNodeRef:a,over:l,zone:l?s:null,dragListeners:o.listeners,dragging:o.isDragging})})}function L_n({hidden:t}){const{active:e}=nN(),{setNodeRef:n}=rN({id:"group:__top",data:{kind:"group",groupId:null}}),{overId:r}=v.useContext(iN),o=e?.data.current?.kind==="wt";return t?null:f.jsx("div",{ref:n,"data-testid":"repo-list__top-level-drop","data-drop-zone":r==="group:__top"?"into":void 0,className:`mx-2 h-5 rounded border border-dashed text-center text-[11px] leading-[18px] text-muted-foreground ${o?"":"border-transparent"} ${r==="group:__top"?"bg-primary/20":""}`,children:o?"Top level, no group":null})}const uBe="band:continued-seen:",I_n=1440*60*1e3;function D_n(t,e,n){return e!==null&&e>=t?!1:n-t<I_n}function z_n(t){const e=Hn.getItem(uBe+t),n=e===null?Number.NaN:Number(e);return Number.isFinite(n)?n:null}function $_n(t){window.addEventListener("storage",t);const e=bA(t);return()=>{window.removeEventListener("storage",t),e()}}function B_n(t,e,n){const r=v.useSyncExternalStore($_n,()=>z_n(t),()=>null);return v.useEffect(()=>{n&&(r!==null&&r>=e||Hn.setItem(uBe+t,String(e)))},[n,t,e,r]),D_n(e,r,Date.now())}function sN(){const t=It({queryKey:["hosts.list"],queryFn:async()=>(await Se.workers.list.query()).hosts});return e=>{if(!e)return"the hub";const n=t.data?.find(r=>r.id===e);return n?.name?.trim()?n.name:"unknown worker"}}function H_n(t){const e=It({queryKey:["hosts.list"],queryFn:async()=>(await Se.workers.list.query()).hosts});if(!(!e.data||e.data.length<2))return!t||t==="local"?"This hub":e.data.find(n=>n.id===t)?.name?.trim()||"unknown worker"}function UQ(t){return t.onBattery||!t.focused}let Cf={onBattery:!1,focused:typeof document>"u"?!0:!document.hidden&&document.hasFocus()};const WQ=new Set;let bpe=!1;function m6(t){const e={...Cf,...t};if(!(e.onBattery===Cf.onBattery&&e.focused===Cf.focused)){Cf=e,dBe(Cf);for(const n of WQ)n()}}function dBe(t){const e=document.documentElement;UQ(t)?e.setAttribute("data-power","saver"):e.removeAttribute("data-power"),e.toggleAttribute("data-on-battery",t.onBattery)}function F_n(){return Cf.onBattery||typeof document<"u"&&document.hidden}function U0(){return Cf}function Wx(t){return WQ.add(t),()=>WQ.delete(t)}function q_n(){return v.useSyncExternalStore(Wx,U0,U0)}function V_n(){const t=()=>m6({focused:!document.hidden&&document.hasFocus()});window.addEventListener("focus",()=>m6({focused:!document.hidden})),window.addEventListener("blur",()=>{const e=document.activeElement?.tagName;e==="WEBVIEW"||e==="IFRAME"||m6({focused:!1})}),document.addEventListener("visibilitychange",t),t()}function Q_n(){const t=EP();if(!t)return!1;t.invoke("get_power_state").then(e=>m6({onBattery:e.onBattery===!0})).catch(()=>{});try{t.on("power-state-changed",e=>m6({onBattery:e.onBattery===!0}))}catch{}return!0}function U_n(){const t=navigator;typeof t.getBattery=="function"&&t.getBattery().then(e=>{const n=()=>m6({onBattery:!e.charging});e.addEventListener("chargingchange",n),n()}).catch(()=>{})}function W_n(){bpe||typeof window>"u"||(bpe=!0,dBe(Cf),V_n(),Q_n()||U_n())}const Z_n=3;function G_n(t,e,n=Z_n){return t===!1||!e.focused?!1:e.onBattery?t*n:t}function See(t,e){return G_n(t,q_n(),e)}const Y_n=["hosts.list"];function fBe(){return It({queryKey:Y_n,queryFn:async()=>(await Se.workers.list.query()).hosts,refetchInterval:See(5e3,6)}).data??[]}function hBe(t){const e=fBe(),n=!t||t==="local"?void 0:e.find(r=>r.id===t);return{offline:n!==void 0&&n.status!=="online",name:n?.name||t||"",lastSeenAt:n?.lastSeenAt??null}}function ZQ(t,e=Date.now()){const n=Math.max(0,Math.round((e-t)/1e3));if(n<60)return"just now";const r=Math.round(n/60);if(r<60)return`${r} minute${r===1?"":"s"} ago`;const o=Math.round(r/60);if(o<48)return`${o} hour${o===1?"":"s"} ago`;const i=Math.round(o/24);return`${i} day${i===1?"":"s"} ago`}const X_n="plugin:github.pull-request";function K_n(t){window.dispatchEvent(new CustomEvent("band:right-sidepanel-set-tab",{detail:{tab:X_n,worktreeId:t}})),window.dispatchEvent(new CustomEvent("band:show-right-panel"))}const J_n=["Ignored files (node_modules, build output, .env) are not carried over.","Running processes and open terminals are not carried over."];function pBe(t){const e=Math.max(0,Math.round(t/1e3));if(e<90)return`${e} s`;const n=Math.round(e/60);if(n<90)return`${n} min`;const r=Math.round(n/60);return r<48?`${r} h`:`${Math.round(r/24)} d`}function mBe(t,e){return`Continued from ${e} · ${t.reason} · checkpoint ${pBe(t.at-t.checkpointAt)} old`}function exn({from:t,testId:e}){const n=sN(),r=mBe(t,n(t.fromHostId));return f.jsxs(Or,{delayDuration:300,children:[f.jsx(Sr,{asChild:!0,children:f.jsx("span",{"data-testid":e,"data-reason":t.reason,"data-from-host":t.fromHostId,role:"img","aria-label":r,className:"flex shrink-0 items-center ml-auto pl-2 text-muted-foreground",children:f.jsx(gZ,{className:"size-3.5"})})}),f.jsx(Cr,{side:"right",children:r})]})}let BS=null,gBe=0;const __=new Set,GQ=()=>{for(const t of __)t()};function vBe(t,e){return BS?Promise.resolve(null):new Promise(n=>{BS={id:++gBe,answer:t,chatId:e,resolve:r=>{BS=null,GQ(),n(r)}},GQ()})}let bBe=null;function _Be(t){bBe={id:++gBe,worktreeId:t},GQ()}function txn(){return v.useSyncExternalStore(t=>(__.add(t),()=>__.delete(t)),()=>bBe,()=>null)}function k$(t,e){e&&e!==t&&_Be(e)}function nxn(){return v.useSyncExternalStore(t=>(__.add(t),()=>__.delete(t)),()=>BS,()=>null)}function rxn(t){const e=t?.data?.hostOffline;return e?.offer?e:null}function HS(t){const e=rxn(t);e&&vBe(e)}const oxn=t=>t instanceof Error?t.message:String(t);function ixn(){const t=nxn(),e=txn(),n=Rn(),r=Gs(),o=e?.id,i=e?.worktreeId;if(v.useEffect(()=>{if(o===void 0||!i)return;n.invalidateQueries({queryKey:["repos"]});const l=r.getWorktreeHref?.(i);l&&r.navigate&&r.navigate(l)},[o,i,n,r]),!t)return null;const{answer:s,chatId:a}=t;return f.jsx(Cee,{offer:s.offer,chatId:a,blockedMessage:s.code==="CONTINUE_NOT_POSSIBLE"?s.error:void 0,title:"Worker is offline",onClose:t.resolve},t.id)}function Cee({offer:t,chatId:e,blockedMessage:n,title:r="Open on another worker",onClose:o}){const i=Rn(),s=Gs(),a=t.targets.find(y=>y.recommended)?.hostId??"",[l,c]=v.useState(a),[u,d]=v.useState(!1),[h,p]=v.useState(null),g=n!==void 0||!!t.blocked,_=()=>{u||o(null)},x=async()=>{d(!0),p(null);try{const y=await Se.follow.continue.mutate({worktreeId:t.worktreeId,toHostId:l,...e?{chatId:e}:{}});await i.invalidateQueries({queryKey:["repos"]});const k=s.getWorktreeHref?.(y.worktreeId);k&&s.navigate&&s.navigate(k),o({worktreeId:y.worktreeId})}catch(y){p(oxn(y)),d(!1)}};return f.jsx(nr,{open:!0,onOpenChange:y=>y?void 0:_(),children:f.jsxs(rr,{className:"sm:max-w-[520px]","data-testid":"continue-dialog",children:[f.jsxs(hr,{children:[f.jsx(or,{children:g?"Cannot continue elsewhere":r}),f.jsx(Nr,{"data-testid":"continue-dialog__question",children:g?t.blocked?.message??n:t.question})]}),g?f.jsx("div",{className:"flex justify-end",children:f.jsx(Ce,{size:"sm","data-testid":"continue-dialog__close",onClick:_,children:"Close"})}):f.jsxs("div",{className:"space-y-3",children:[f.jsxs("fieldset",{className:"space-y-1.5","data-testid":"continue-dialog__targets",children:[f.jsx("legend",{className:"text-xs font-medium",children:"Continue on"}),t.targets.map(y=>f.jsxs("label",{className:`flex items-start gap-2 text-sm ${y.agentReady?"":"opacity-60"}`,children:[f.jsx("input",{type:"radio",name:"continue-target",value:y.hostId,checked:l===y.hostId,disabled:!y.agentReady||u,"data-testid":"continue-dialog__target","data-host-id":y.hostId,onChange:()=>c(y.hostId)}),f.jsxs("span",{children:[y.hostName,f.jsx("span",{className:"block text-xs text-muted-foreground",children:[y.recommended?"recommended":null,y.hasClone?"has a clone":"no clone yet",`${y.load} worktree${y.load===1?"":"s"}`,y.agentReady?null:y.agentProblem??"agent not available"].filter(Boolean).join(" · ")})]})]},y.hostId))]}),f.jsxs("div",{className:"space-y-1","data-testid":"continue-dialog__notes",children:[(t.limits.length>0?t.limits:[...J_n]).map(y=>f.jsx("p",{className:"text-xs text-muted-foreground",children:y},y)),t.willRun.map(y=>f.jsx("p",{className:"text-xs text-muted-foreground",children:y},y)),t.checkpointAgeMs!==void 0?f.jsxs("p",{className:"text-xs text-muted-foreground",children:["Work after the checkpoint (",pBe(t.checkpointAgeMs)," old) is not carried over."]}):null]}),h?f.jsx("p",{role:"alert",className:"text-xs text-destructive","data-testid":"continue-dialog__error",children:h}):null,f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(Ce,{variant:"ghost",size:"sm","data-testid":"continue-dialog__cancel",disabled:u,onClick:_,children:"Cancel"}),f.jsxs(Ce,{size:"sm","data-testid":"continue-dialog__confirm",disabled:u||l==="",onClick:()=>{x()},children:[u?f.jsx(wo,{className:"size-3"}):null,"Continue"]})]})]})]})})}const Jk=t=>t instanceof Error?t.message:String(t);function sxn({open:t,onOpenChange:e,worktreeId:n}){const r=Rn(),o=It({queryKey:["follow.divergence",n],queryFn:()=>Se.follow.divergence.query({worktreeId:n}),enabled:t}),[i,s]=v.useState(null),a=It({queryKey:["follow.divergenceDiff",n,i],queryFn:()=>Se.follow.divergenceDiff.query({worktreeId:n,path:i}),enabled:t&&i!==null}),[l,c]=v.useState(!1),[u,d]=v.useState(null),[h,p]=v.useState(null),[g,_]=v.useState([]),[x,y]=v.useState(!1),[k,O]=v.useState(!1),C=async()=>{await r.invalidateQueries({queryKey:["repos"]}),await r.invalidateQueries({queryKey:["follow.divergence",n]})},A=async()=>{c(!0),d(null),p(null),_([]);try{const L=await Se.follow.bringOver.mutate({worktreeId:n});L.applied?(p(`Brought over ${L.files} file${L.files===1?"":"s"} to the new copy.`),await C()):(_(L.conflicts),p("The changes conflict with the new copy. Nothing was changed."))}catch(L){d(Jk(L))}finally{c(!1)}},E=async()=>{c(!0),d(null);try{await Se.follow.discardOld.mutate({worktreeId:n,confirm:!0,...o.data?.state==="diverged"?{discardChanges:!0}:{}}),await r.invalidateQueries({queryKey:["repos"]}),e(!1)}catch(L){d(Jk(L)),y(!1),O(!1)}finally{c(!1)}},M=o.data,P=M?.files.length??0;return f.jsx(nr,{open:t,onOpenChange:e,children:f.jsxs(rr,{className:"sm:max-w-[640px]","data-testid":"divergence-panel",children:[f.jsxs(hr,{children:[f.jsx(or,{children:"Changes on the old copy"}),f.jsx(Nr,{children:"This worker was offline while the work continued elsewhere. These files differ from the checkpoint the continuation used."})]}),o.isLoading?f.jsx(wo,{className:"size-4"}):null,o.error?f.jsx("p",{role:"alert",className:"text-xs text-destructive",children:Jk(o.error)}):null,M&&!M.hostOnline?f.jsx("p",{className:"text-sm text-muted-foreground",children:"The worker is offline, so the old copy cannot be compared now."}):null,M?.hostOnline&&M.state==="clean"?f.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"divergence-panel__clean",children:"The old copy has nothing the continuation lacks."}):null,M&&M.files.length>0?f.jsx("ul",{className:"max-h-40 space-y-0.5 overflow-auto","data-testid":"divergence-panel__files",children:M.files.map(L=>f.jsx("li",{children:f.jsxs("button",{type:"button","data-testid":"divergence-panel__file","data-path":L.path,className:`w-full text-left font-mono text-xs hover:underline ${i===L.path?"font-bold":""}`,onClick:()=>s(L.path),children:[L.status," ",L.path]})},L.path))}):null,i!==null?f.jsx("pre",{className:"max-h-60 overflow-auto rounded border bg-muted/40 p-2 font-mono text-xs","data-testid":"divergence-panel__diff",children:a.isLoading?"Loading…":a.data?.diff??Jk(a.error)}):null,h?f.jsx("p",{className:"text-xs","data-testid":"divergence-panel__notice",children:h}):null,g.length>0?f.jsx("ul",{className:"space-y-0.5 text-xs text-destructive","data-testid":"divergence-panel__conflicts",children:g.map(L=>f.jsxs("li",{children:[f.jsx("span",{className:"font-mono",children:L.path}),": ",L.message]},L.path))}):null,u?f.jsx("p",{role:"alert",className:"text-xs text-destructive","data-testid":"divergence-panel__error",children:u}):null,x?f.jsxs("div",{className:"space-y-2 rounded border border-destructive/50 p-2","data-testid":"divergence-panel__confirm",children:[M?.state==="diverged"&&k?f.jsxs("p",{className:"text-xs font-medium","data-testid":"divergence-panel__loss",children:[P," changed file",P===1?"":"s"," exist only on the old copy and will be lost for good. Bring them over first if you want to keep them."]}):f.jsxs("p",{className:"text-xs",children:["Discard the old copy? Its files on the old worker are deleted. The continued worktree is not touched.",M?.state==="diverged"?` It holds ${P} changed file${P===1?"":"s"} the new copy lacks (listed above).`:""]}),f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(Ce,{variant:"ghost",size:"sm",disabled:l,onClick:()=>{y(!1),O(!1)},children:"Keep it"}),M?.state==="diverged"&&!k?f.jsx(Ce,{variant:"destructive",size:"sm","data-testid":"divergence-panel__review-loss",disabled:l,onClick:()=>O(!0),children:"Continue"}):f.jsx(Ce,{variant:"destructive",size:"sm","data-testid":"divergence-panel__confirm-discard",disabled:l,onClick:()=>{E()},children:M?.state==="diverged"?`Delete old copy and ${P} changed file${P===1?"":"s"}`:"Delete old copy"})]})]}):f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(Ce,{variant:"ghost",size:"sm","data-testid":"divergence-panel__discard",disabled:l,onClick:()=>y(!0),children:"Discard old copy"}),f.jsxs(Ce,{size:"sm","data-testid":"divergence-panel__bring-over",disabled:l||!M?.hostOnline||M.state!=="diverged",onClick:()=>{A()},children:[l?f.jsx(wo,{className:"size-3"}):null,"Bring these changes over"]})]})]})})}function axn({git:t}){const e=[];return t.conflict?e.push({kind:"conflict",text:"!",color:"text-git-conflict",tooltip:"Merge conflict"}):t.dirty&&e.push({kind:"dirty",text:"M",color:"text-git-untracked",tooltip:"Uncommitted changes"}),t.sync_state==="ahead"?e.push({kind:"ahead",text:`↑${t.ahead}`,color:"text-git-ahead",tooltip:`${t.ahead} commit${t.ahead>1?"s":""} ahead`}):t.sync_state==="behind"?e.push({kind:"behind",text:`↓${t.behind}`,color:"text-git-behind",tooltip:`${t.behind} commit${t.behind>1?"s":""} behind`}):t.sync_state==="diverged"&&e.push({kind:"diverged",text:`↑${t.ahead}↓${t.behind}`,color:"text-git-diverged",tooltip:`Diverged: ${t.ahead} ahead, ${t.behind} behind`}),e.length===0?null:f.jsxs(Or,{children:[f.jsx(Sr,{asChild:!0,children:f.jsx("span",{className:"inline-flex items-center gap-0.5 font-mono text-[11px] leading-none shrink-0 pr-0.5",children:e.map(n=>f.jsx("span",{className:n.color,"data-testid":`worktree-card__git-${n.kind}`,children:n.text},n.kind))})}),f.jsx(Cr,{children:e.map(n=>n.tooltip).join(", ")})]})}const YQ="local";function _pe(t,e){return!t||t===YQ?e?.find(n=>n.id===YQ)?.name?.trim()||"This hub":e?.find(n=>n.id===t)?.name?.trim()||"unknown worker"}function lxn(t,e,n){for(const a of e??[])for(const l of a.worktrees)if(jr(a.name,l.name,l.hostId)===t){const u=!!l.hostId&&l.hostId!==YQ?_pe(l.hostId,n):null;return{repo:a.name,name:l.name,host:u,label:`${a.name} · ${l.name}${u?` on ${u}`:""}`}}const r=t.lastIndexOf("@"),o=r>=0?t.slice(r+1):null,i=r>=0?t.slice(0,r):t,s=o?_pe(o,n):null;return{repo:null,name:i,host:s,label:s?`${i} on ${s}`:i}}function cxn(){return It({queryKey:["hosts.list"],queryFn:async()=>(await Se.workers.list.query()).hosts}).data}function Aee(){const{repos:t}=xs(),e=cxn();return n=>lxn(n,t,e)}var uxn=Object.defineProperty,UE=Object.getOwnPropertySymbols,xBe=Object.prototype.hasOwnProperty,yBe=Object.prototype.propertyIsEnumerable,xpe=(t,e,n)=>e in t?uxn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,XQ=(t,e)=>{for(var n in e||(e={}))xBe.call(e,n)&&xpe(t,n,e[n]);if(UE)for(var n of UE(e))yBe.call(e,n)&&xpe(t,n,e[n]);return t},KQ=(t,e)=>{var n={};for(var r in t)xBe.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&UE)for(var r of UE(t))e.indexOf(r)<0&&yBe.call(t,r)&&(n[r]=t[r]);return n};var i4;(t=>{const e=class br{constructor(l,c,u,d){if(this.version=l,this.errorCorrectionLevel=c,this.modules=[],this.isFunction=[],l<br.MIN_VERSION||l>br.MAX_VERSION)throw new RangeError("Version value out of range");if(d<-1||d>7)throw new RangeError("Mask value out of range");this.size=l*4+17;let h=[];for(let g=0;g<this.size;g++)h.push(!1);for(let g=0;g<this.size;g++)this.modules.push(h.slice()),this.isFunction.push(h.slice());this.drawFunctionPatterns();const p=this.addEccAndInterleave(u);if(this.drawCodewords(p),d==-1){let g=1e9;for(let _=0;_<8;_++){this.applyMask(_),this.drawFormatBits(_);const x=this.getPenaltyScore();x<g&&(d=_,g=x),this.applyMask(_)}}o(0<=d&&d<=7),this.mask=d,this.applyMask(d),this.drawFormatBits(d),this.isFunction=[]}static encodeText(l,c){const u=t.QrSegment.makeSegments(l);return br.encodeSegments(u,c)}static encodeBinary(l,c){const u=t.QrSegment.makeBytes(l);return br.encodeSegments([u],c)}static encodeSegments(l,c,u=1,d=40,h=-1,p=!0){if(!(br.MIN_VERSION<=u&&u<=d&&d<=br.MAX_VERSION)||h<-1||h>7)throw new RangeError("Invalid value");let g,_;for(g=u;;g++){const O=br.getNumDataCodewords(g,c)*8,C=s.getTotalBits(l,g);if(C<=O){_=C;break}if(g>=d)throw new RangeError("Data too long")}for(const O of[br.Ecc.MEDIUM,br.Ecc.QUARTILE,br.Ecc.HIGH])p&&_<=br.getNumDataCodewords(g,O)*8&&(c=O);let x=[];for(const O of l){n(O.mode.modeBits,4,x),n(O.numChars,O.mode.numCharCountBits(g),x);for(const C of O.getData())x.push(C)}o(x.length==_);const y=br.getNumDataCodewords(g,c)*8;o(x.length<=y),n(0,Math.min(4,y-x.length),x),n(0,(8-x.length%8)%8,x),o(x.length%8==0);for(let O=236;x.length<y;O^=253)n(O,8,x);let k=[];for(;k.length*8<x.length;)k.push(0);return x.forEach((O,C)=>k[C>>>3]|=O<<7-(C&7)),new br(g,c,k,h)}getModule(l,c){return 0<=l&&l<this.size&&0<=c&&c<this.size&&this.modules[c][l]}getModules(){return this.modules}drawFunctionPatterns(){for(let u=0;u<this.size;u++)this.setFunctionModule(6,u,u%2==0),this.setFunctionModule(u,6,u%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const l=this.getAlignmentPatternPositions(),c=l.length;for(let u=0;u<c;u++)for(let d=0;d<c;d++)u==0&&d==0||u==0&&d==c-1||u==c-1&&d==0||this.drawAlignmentPattern(l[u],l[d]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(l){const c=this.errorCorrectionLevel.formatBits<<3|l;let u=c;for(let h=0;h<10;h++)u=u<<1^(u>>>9)*1335;const d=(c<<10|u)^21522;o(d>>>15==0);for(let h=0;h<=5;h++)this.setFunctionModule(8,h,r(d,h));this.setFunctionModule(8,7,r(d,6)),this.setFunctionModule(8,8,r(d,7)),this.setFunctionModule(7,8,r(d,8));for(let h=9;h<15;h++)this.setFunctionModule(14-h,8,r(d,h));for(let h=0;h<8;h++)this.setFunctionModule(this.size-1-h,8,r(d,h));for(let h=8;h<15;h++)this.setFunctionModule(8,this.size-15+h,r(d,h));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let l=this.version;for(let u=0;u<12;u++)l=l<<1^(l>>>11)*7973;const c=this.version<<12|l;o(c>>>18==0);for(let u=0;u<18;u++){const d=r(c,u),h=this.size-11+u%3,p=Math.floor(u/3);this.setFunctionModule(h,p,d),this.setFunctionModule(p,h,d)}}drawFinderPattern(l,c){for(let u=-4;u<=4;u++)for(let d=-4;d<=4;d++){const h=Math.max(Math.abs(d),Math.abs(u)),p=l+d,g=c+u;0<=p&&p<this.size&&0<=g&&g<this.size&&this.setFunctionModule(p,g,h!=2&&h!=4)}}drawAlignmentPattern(l,c){for(let u=-2;u<=2;u++)for(let d=-2;d<=2;d++)this.setFunctionModule(l+d,c+u,Math.max(Math.abs(d),Math.abs(u))!=1)}setFunctionModule(l,c,u){this.modules[c][l]=u,this.isFunction[c][l]=!0}addEccAndInterleave(l){const c=this.version,u=this.errorCorrectionLevel;if(l.length!=br.getNumDataCodewords(c,u))throw new RangeError("Invalid argument");const d=br.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][c],h=br.ECC_CODEWORDS_PER_BLOCK[u.ordinal][c],p=Math.floor(br.getNumRawDataModules(c)/8),g=d-p%d,_=Math.floor(p/d);let x=[];const y=br.reedSolomonComputeDivisor(h);for(let O=0,C=0;O<d;O++){let A=l.slice(C,C+_-h+(O<g?0:1));C+=A.length;const E=br.reedSolomonComputeRemainder(A,y);O<g&&A.push(0),x.push(A.concat(E))}let k=[];for(let O=0;O<x[0].length;O++)x.forEach((C,A)=>{(O!=_-h||A>=g)&&k.push(C[O])});return o(k.length==p),k}drawCodewords(l){if(l.length!=Math.floor(br.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let c=0;for(let u=this.size-1;u>=1;u-=2){u==6&&(u=5);for(let d=0;d<this.size;d++)for(let h=0;h<2;h++){const p=u-h,_=(u+1&2)==0?this.size-1-d:d;!this.isFunction[_][p]&&c<l.length*8&&(this.modules[_][p]=r(l[c>>>3],7-(c&7)),c++)}}o(c==l.length*8)}applyMask(l){if(l<0||l>7)throw new RangeError("Mask value out of range");for(let c=0;c<this.size;c++)for(let u=0;u<this.size;u++){let d;switch(l){case 0:d=(u+c)%2==0;break;case 1:d=c%2==0;break;case 2:d=u%3==0;break;case 3:d=(u+c)%3==0;break;case 4:d=(Math.floor(u/3)+Math.floor(c/2))%2==0;break;case 5:d=u*c%2+u*c%3==0;break;case 6:d=(u*c%2+u*c%3)%2==0;break;case 7:d=((u+c)%2+u*c%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[c][u]&&d&&(this.modules[c][u]=!this.modules[c][u])}}getPenaltyScore(){let l=0;for(let h=0;h<this.size;h++){let p=!1,g=0,_=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[h][x]==p?(g++,g==5?l+=br.PENALTY_N1:g>5&&l++):(this.finderPenaltyAddHistory(g,_),p||(l+=this.finderPenaltyCountPatterns(_)*br.PENALTY_N3),p=this.modules[h][x],g=1);l+=this.finderPenaltyTerminateAndCount(p,g,_)*br.PENALTY_N3}for(let h=0;h<this.size;h++){let p=!1,g=0,_=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[x][h]==p?(g++,g==5?l+=br.PENALTY_N1:g>5&&l++):(this.finderPenaltyAddHistory(g,_),p||(l+=this.finderPenaltyCountPatterns(_)*br.PENALTY_N3),p=this.modules[x][h],g=1);l+=this.finderPenaltyTerminateAndCount(p,g,_)*br.PENALTY_N3}for(let h=0;h<this.size-1;h++)for(let p=0;p<this.size-1;p++){const g=this.modules[h][p];g==this.modules[h][p+1]&&g==this.modules[h+1][p]&&g==this.modules[h+1][p+1]&&(l+=br.PENALTY_N2)}let c=0;for(const h of this.modules)c=h.reduce((p,g)=>p+(g?1:0),c);const u=this.size*this.size,d=Math.ceil(Math.abs(c*20-u*10)/u)-1;return o(0<=d&&d<=9),l+=d*br.PENALTY_N4,o(0<=l&&l<=2568888),l}getAlignmentPatternPositions(){if(this.version==1)return[];{const l=Math.floor(this.version/7)+2,c=this.version==32?26:Math.ceil((this.version*4+4)/(l*2-2))*2;let u=[6];for(let d=this.size-7;u.length<l;d-=c)u.splice(1,0,d);return u}}static getNumRawDataModules(l){if(l<br.MIN_VERSION||l>br.MAX_VERSION)throw new RangeError("Version number out of range");let c=(16*l+128)*l+64;if(l>=2){const u=Math.floor(l/7)+2;c-=(25*u-10)*u-55,l>=7&&(c-=36)}return o(208<=c&&c<=29648),c}static getNumDataCodewords(l,c){return Math.floor(br.getNumRawDataModules(l)/8)-br.ECC_CODEWORDS_PER_BLOCK[c.ordinal][l]*br.NUM_ERROR_CORRECTION_BLOCKS[c.ordinal][l]}static reedSolomonComputeDivisor(l){if(l<1||l>255)throw new RangeError("Degree out of range");let c=[];for(let d=0;d<l-1;d++)c.push(0);c.push(1);let u=1;for(let d=0;d<l;d++){for(let h=0;h<c.length;h++)c[h]=br.reedSolomonMultiply(c[h],u),h+1<c.length&&(c[h]^=c[h+1]);u=br.reedSolomonMultiply(u,2)}return c}static reedSolomonComputeRemainder(l,c){let u=c.map(d=>0);for(const d of l){const h=d^u.shift();u.push(0),c.forEach((p,g)=>u[g]^=br.reedSolomonMultiply(p,h))}return u}static reedSolomonMultiply(l,c){if(l>>>8||c>>>8)throw new RangeError("Byte out of range");let u=0;for(let d=7;d>=0;d--)u=u<<1^(u>>>7)*285,u^=(c>>>d&1)*l;return o(u>>>8==0),u}finderPenaltyCountPatterns(l){const c=l[1];o(c<=this.size*3);const u=c>0&&l[2]==c&&l[3]==c*3&&l[4]==c&&l[5]==c;return(u&&l[0]>=c*4&&l[6]>=c?1:0)+(u&&l[6]>=c*4&&l[0]>=c?1:0)}finderPenaltyTerminateAndCount(l,c,u){return l&&(this.finderPenaltyAddHistory(c,u),c=0),c+=this.size,this.finderPenaltyAddHistory(c,u),this.finderPenaltyCountPatterns(u)}finderPenaltyAddHistory(l,c){c[0]==0&&(l+=this.size),c.pop(),c.unshift(l)}};e.MIN_VERSION=1,e.MAX_VERSION=40,e.PENALTY_N1=3,e.PENALTY_N2=3,e.PENALTY_N3=40,e.PENALTY_N4=10,e.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],e.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],t.QrCode=e;function n(a,l,c){if(l<0||l>31||a>>>l)throw new RangeError("Value out of range");for(let u=l-1;u>=0;u--)c.push(a>>>u&1)}function r(a,l){return(a>>>l&1)!=0}function o(a){if(!a)throw new Error("Assertion error")}const i=class Ko{constructor(l,c,u){if(this.mode=l,this.numChars=c,this.bitData=u,c<0)throw new RangeError("Invalid argument");this.bitData=u.slice()}static makeBytes(l){let c=[];for(const u of l)n(u,8,c);return new Ko(Ko.Mode.BYTE,l.length,c)}static makeNumeric(l){if(!Ko.isNumeric(l))throw new RangeError("String contains non-numeric characters");let c=[];for(let u=0;u<l.length;){const d=Math.min(l.length-u,3);n(parseInt(l.substring(u,u+d),10),d*3+1,c),u+=d}return new Ko(Ko.Mode.NUMERIC,l.length,c)}static makeAlphanumeric(l){if(!Ko.isAlphanumeric(l))throw new RangeError("String contains unencodable characters in alphanumeric mode");let c=[],u;for(u=0;u+2<=l.length;u+=2){let d=Ko.ALPHANUMERIC_CHARSET.indexOf(l.charAt(u))*45;d+=Ko.ALPHANUMERIC_CHARSET.indexOf(l.charAt(u+1)),n(d,11,c)}return u<l.length&&n(Ko.ALPHANUMERIC_CHARSET.indexOf(l.charAt(u)),6,c),new Ko(Ko.Mode.ALPHANUMERIC,l.length,c)}static makeSegments(l){return l==""?[]:Ko.isNumeric(l)?[Ko.makeNumeric(l)]:Ko.isAlphanumeric(l)?[Ko.makeAlphanumeric(l)]:[Ko.makeBytes(Ko.toUtf8ByteArray(l))]}static makeEci(l){let c=[];if(l<0)throw new RangeError("ECI assignment value out of range");if(l<128)n(l,8,c);else if(l<16384)n(2,2,c),n(l,14,c);else if(l<1e6)n(6,3,c),n(l,21,c);else throw new RangeError("ECI assignment value out of range");return new Ko(Ko.Mode.ECI,0,c)}static isNumeric(l){return Ko.NUMERIC_REGEX.test(l)}static isAlphanumeric(l){return Ko.ALPHANUMERIC_REGEX.test(l)}getData(){return this.bitData.slice()}static getTotalBits(l,c){let u=0;for(const d of l){const h=d.mode.numCharCountBits(c);if(d.numChars>=1<<h)return 1/0;u+=4+h+d.bitData.length}return u}static toUtf8ByteArray(l){l=encodeURI(l);let c=[];for(let u=0;u<l.length;u++)l.charAt(u)!="%"?c.push(l.charCodeAt(u)):(c.push(parseInt(l.substring(u+1,u+3),16)),u+=2);return c}};i.NUMERIC_REGEX=/^[0-9]*$/,i.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,i.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let s=i;t.QrSegment=i})(i4||(i4={}));(t=>{(e=>{const n=class{constructor(o,i){this.ordinal=o,this.formatBits=i}};n.LOW=new n(0,1),n.MEDIUM=new n(1,0),n.QUARTILE=new n(2,3),n.HIGH=new n(3,2),e.Ecc=n})(t.QrCode||(t.QrCode={}))})(i4||(i4={}));(t=>{(e=>{const n=class{constructor(o,i){this.modeBits=o,this.numBitsCharCount=i}numCharCountBits(o){return this.numBitsCharCount[Math.floor((o+7)/17)]}};n.NUMERIC=new n(1,[10,12,14]),n.ALPHANUMERIC=new n(2,[9,11,13]),n.BYTE=new n(4,[8,16,16]),n.KANJI=new n(8,[8,10,12]),n.ECI=new n(7,[0,0,0]),e.Mode=n})(t.QrSegment||(t.QrSegment={}))})(i4||(i4={}));var L5=i4;var dxn={L:L5.QrCode.Ecc.LOW,M:L5.QrCode.Ecc.MEDIUM,Q:L5.QrCode.Ecc.QUARTILE,H:L5.QrCode.Ecc.HIGH},wBe=128,kBe="L",OBe="#FFFFFF",SBe="#000000",CBe=!1,ABe=1,fxn=4,hxn=0,pxn=.1;function EBe(t,e=0){const n=[];return t.forEach(function(r,o){let i=null;r.forEach(function(s,a){if(!s&&i!==null){n.push(`M${i+e} ${o+e}h${a-i}v1H${i+e}z`),i=null;return}if(a===r.length-1){if(!s)return;i===null?n.push(`M${a+e},${o+e} h1v1H${a+e}z`):n.push(`M${i+e},${o+e} h${a+1-i}v1H${i+e}z`);return}s&&i===null&&(i=a)})}),n.join("")}function TBe(t,e){return t.slice().map((n,r)=>r<e.y||r>=e.y+e.h?n:n.map((o,i)=>i<e.x||i>=e.x+e.w?o:!1))}function mxn(t,e,n,r){if(r==null)return null;const o=t.length+n*2,i=Math.floor(e*pxn),s=o/e,a=(r.width||i)*s,l=(r.height||i)*s,c=r.x==null?t.length/2-a/2:r.x*s,u=r.y==null?t.length/2-l/2:r.y*s,d=r.opacity==null?1:r.opacity;let h=null;if(r.excavate){let g=Math.floor(c),_=Math.floor(u),x=Math.ceil(a+c-g),y=Math.ceil(l+u-_);h={x:g,y:_,w:x,h:y}}const p=r.crossOrigin;return{x:c,y:u,h:l,w:a,excavation:h,opacity:d,crossOrigin:p}}function gxn(t,e){return e!=null?Math.max(Math.floor(e),0):t?fxn:hxn}function MBe({value:t,level:e,minVersion:n,includeMargin:r,marginSize:o,imageSettings:i,size:s,boostLevel:a}){let l=Bt.useMemo(()=>{const g=(Array.isArray(t)?t:[t]).reduce((_,x)=>(_.push(...L5.QrSegment.makeSegments(x)),_),[]);return L5.QrCode.encodeSegments(g,dxn[e],n,void 0,void 0,a)},[t,e,n,a]);const{cells:c,margin:u,numCells:d,calculatedImageSettings:h}=Bt.useMemo(()=>{let p=l.getModules();const g=gxn(r,o),_=p.length+g*2,x=mxn(p,s,g,i);return{cells:p,margin:g,numCells:_,calculatedImageSettings:x}},[l,s,i,r,o]);return{qrcode:l,margin:u,cells:c,numCells:d,calculatedImageSettings:h}}var vxn=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),bxn=Bt.forwardRef(function(e,n){const r=e,{value:o,size:i=wBe,level:s=kBe,bgColor:a=OBe,fgColor:l=SBe,includeMargin:c=CBe,minVersion:u=ABe,boostLevel:d,marginSize:h,imageSettings:p}=r,_=KQ(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:x}=_,y=KQ(_,["style"]),k=p?.src,O=Bt.useRef(null),C=Bt.useRef(null),A=Bt.useCallback(Q=>{O.current=Q,typeof n=="function"?n(Q):n&&(n.current=Q)},[n]),[E,M]=Bt.useState(!1),{margin:P,cells:L,numCells:D,calculatedImageSettings:I}=MBe({value:o,level:s,minVersion:u,boostLevel:d,includeMargin:c,marginSize:h,imageSettings:p,size:i});Bt.useEffect(()=>{if(O.current!=null){const Q=O.current,H=Q.getContext("2d");if(!H)return;let N=L;const V=C.current,G=I!=null&&V!==null&&V.complete&&V.naturalHeight!==0&&V.naturalWidth!==0;G&&I.excavation!=null&&(N=TBe(L,I.excavation));const K=window.devicePixelRatio||1;Q.height=Q.width=i*K;const q=i/D*K;H.scale(q,q),H.fillStyle=a,H.fillRect(0,0,D,D),H.fillStyle=l,vxn?H.fill(new Path2D(EBe(N,P))):L.forEach(function(Z,U){Z.forEach(function(B,ee){B&&H.fillRect(ee+P,U+P,1,1)})}),I&&(H.globalAlpha=I.opacity),G&&H.drawImage(V,I.x+P,I.y+P,I.w,I.h)}}),Bt.useEffect(()=>{M(!1)},[k]);const z=XQ({height:i,width:i},x);let Y=null;return k!=null&&(Y=Bt.createElement("img",{src:k,key:k,style:{display:"none"},onLoad:()=>{M(!0)},ref:C,crossOrigin:I?.crossOrigin})),Bt.createElement(Bt.Fragment,null,Bt.createElement("canvas",XQ({style:z,height:i,width:i,ref:A,role:"img"},y)),Y)});bxn.displayName="QRCodeCanvas";var Eee=Bt.forwardRef(function(e,n){const r=e,{value:o,size:i=wBe,level:s=kBe,bgColor:a=OBe,fgColor:l=SBe,includeMargin:c=CBe,minVersion:u=ABe,boostLevel:d,title:h,marginSize:p,imageSettings:g}=r,_=KQ(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:x,cells:y,numCells:k,calculatedImageSettings:O}=MBe({value:o,level:s,minVersion:u,boostLevel:d,includeMargin:c,marginSize:p,imageSettings:g,size:i});let C=y,A=null;g!=null&&O!=null&&(O.excavation!=null&&(C=TBe(y,O.excavation)),A=Bt.createElement("image",{href:g.src,height:O.h,width:O.w,x:O.x+x,y:O.y+x,preserveAspectRatio:"none",opacity:O.opacity,crossOrigin:O.crossOrigin}));const E=EBe(C,x);return Bt.createElement("svg",XQ({height:i,width:i,viewBox:`0 0 ${k} ${k}`,ref:n,role:"img"},_),!!h&&Bt.createElement("title",null,h),Bt.createElement("path",{fill:a,d:`M0,0 h${k}v${k}H0z`,shapeRendering:"crispEdges"}),Bt.createElement("path",{fill:l,d:E,shapeRendering:"crispEdges"}),A)});Eee.displayName="QRCodeSVG";function _xn(t){const e=[],n=new Set,r=o=>{n.has(o.url)||(n.add(o.url),e.push(o))};t.publicUrl&&r({url:t.publicUrl,label:`Public URL (${t.publicUrl})`,source:"public"}),r({url:t.pageOrigin,label:`This page (${t.pageOrigin})`,source:"page"});for(const o of t.interfaces)r({url:o.url,label:o.kind==="bridge"?`${o.label} · virtual network`:o.label,source:"interface",kind:o.kind});for(const o of t.custom)r({url:o,label:`Custom (${o})`,source:"custom"});return e}function xxn(t,e){return(e?t.find(r=>r.url===e):void 0)??t.find(r=>r.source==="public")??t.find(r=>r.source==="page")??t[0]}function yxn(t,e){return`${t.replace(/\/+$/,"")}/?pair=${encodeURIComponent(e)}`}const eO=t=>t instanceof Error?t.message:String(t);function PBe(){return i1()?.origin??window.location.origin}const ype=()=>`band.pairing-address:${PBe()}`;function wxn(t){try{const e=new URL(t).hostname;return e==="localhost"||e==="::1"||e==="[::1]"||/^127\./.test(e)}catch{return!1}}function kxn(t){return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Oxn({device:t,onClose:e}){const[n,r]=v.useState(null),[o,i]=v.useState(null),[s,a]=v.useState(null),[l,c]=v.useState(null),[u,d]=v.useState(""),[h,p]=v.useState(!1),g=v.useCallback(async E=>{c(null);try{const M=await Se.tokens.pairing.mutate({tokenId:t.id,regenerate:E});r({code:M.code,expiresAt:M.expiresAt})}catch(M){c(eO(M))}},[t.id]),_=v.useCallback(async()=>{try{i(await Se.tokens.pairingAddresses.query())}catch(E){c(eO(E))}},[]);v.useEffect(()=>{g(!1),_()},[g,_]),v.useEffect(()=>{if(!n)return;const E=Math.max(0,n.expiresAt-Date.now())+250,M=setTimeout(()=>{g(!1)},E);return()=>clearTimeout(M)},[n,g]);const x=v.useMemo(()=>o?_xn({publicUrl:o.publicUrl,pageOrigin:PBe(),interfaces:o.interfaces,custom:o.custom}):[],[o]),y=v.useMemo(()=>(s?x.find(M=>M.url===s):void 0)??xxn(x,localStorage.getItem(ype())),[x,s]),k=E=>{a(E),localStorage.setItem(ype(),E)},O=n&&y?yxn(y.url,n.code):null,C=async()=>{c(null);try{const E=await Se.tokens.addPairingAddress.mutate({url:u});await _(),k(E.url),d(""),p(!1)}catch(E){c(eO(E))}},A=async E=>{c(null);try{await Se.tokens.removePairingAddress.mutate({url:E}),s===E&&a(null),await _()}catch(M){c(eO(M))}};return f.jsx(nr,{open:!0,onOpenChange:E=>E?void 0:e(),children:f.jsxs(rr,{className:"sm:max-w-[440px]","data-testid":"settings__pairing-dialog",children:[f.jsxs(hr,{children:[f.jsxs(or,{children:["Connect ",t.label||t.id]}),f.jsx(Nr,{children:"Open the link or scan the code on the device. It works once and expires in 15 minutes. Opening it signs that device in and replaces its previous token."})]}),f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{className:"space-y-1",children:[f.jsx("label",{className:"block text-xs font-medium",htmlFor:"pairing-address",children:"Address"}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx("select",{id:"pairing-address","data-testid":"settings__pairing-address",className:"h-8 min-w-0 flex-1 rounded-md border border-input bg-background px-2 text-xs",value:y?.url??"",onChange:E=>k(E.target.value),children:x.map(E=>f.jsx("option",{value:E.url,"data-testid":"settings__pairing-option","data-source":E.source,"data-kind":E.kind,children:E.label},E.url))}),f.jsx(Ce,{type:"button",variant:"outline",size:"sm","aria-label":"Refresh network interfaces",onClick:()=>{_()},children:f.jsx($0,{className:"size-3"})})]}),f.jsx("div",{className:"flex items-center gap-2",children:h?f.jsxs(f.Fragment,{children:[f.jsx(Sn,{"aria-label":"Custom address",placeholder:"https://band.example.ts.net",value:u,onChange:E=>d(E.target.value),className:"h-8 text-xs"}),f.jsx(Ce,{type:"button",size:"sm",disabled:u.trim()==="",onClick:()=>{C()},children:"Save address"}),f.jsx(Ce,{type:"button",variant:"ghost",size:"sm","data-testid":"settings__pairing-cancel-custom",onClick:()=>p(!1),children:"Cancel"})]}):f.jsxs(f.Fragment,{children:[f.jsx(Ce,{type:"button",variant:"ghost",size:"sm","data-testid":"settings__pairing-add-custom",onClick:()=>p(!0),children:"Add custom address…"}),y?.source==="custom"?f.jsx(Ce,{type:"button",variant:"ghost",size:"sm","data-testid":"settings__pairing-remove-custom",onClick:()=>{A(y.url)},children:"Remove this address"}):null]})})]}),y&&wxn(y.url)?f.jsxs("p",{role:"alert",className:"text-xs text-destructive",children:[y.url," is only reachable from this machine. Pick another address for a phone or another computer."]}):null,O?f.jsxs("div",{className:"space-y-3","data-testid":"settings__pairing-result",children:[f.jsx("div",{className:"flex justify-center rounded-lg bg-white p-3",children:f.jsx(Eee,{value:O,size:200,"data-testid":"settings__pairing-qr","data-value":O})}),f.jsx("label",{className:"block text-xs font-medium",htmlFor:"pairing-link",children:"Connect link"}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx(Sn,{id:"pairing-link",readOnly:!0,value:O,"data-testid":"settings__pairing-link",className:"h-8 font-mono text-xs"}),f.jsxs(Ce,{type:"button",variant:"outline",size:"sm","data-testid":"settings__pairing-copy",onClick:()=>{navigator.clipboard?.writeText(O).catch(()=>{})},children:[f.jsx(z0,{className:"size-3"}),"Copy"]})]}),f.jsxs("p",{className:"text-xs text-muted-foreground","data-testid":"settings__pairing-expiry",children:["Expires at ",kxn(n?.expiresAt??0),"."]})]}):null,l?f.jsx("p",{role:"alert",className:"text-xs text-destructive","data-testid":"settings__pairing-error",children:l}):null]}),f.jsxs(ii,{children:[f.jsx(Ce,{type:"button",variant:"outline",size:"sm","data-testid":"settings__pairing-regenerate",onClick:()=>{g(!0)},children:"Regenerate"}),f.jsx(Ce,{type:"button",size:"sm",onClick:e,children:"Done"})]})]})})}function _n({label:t,description:e,leadingIcon:n,htmlFor:r,variant:o="inline",children:i,className:s}){const a=(t||e)&&f.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[t?f.jsx(To,{htmlFor:r,className:"text-sm font-medium leading-tight text-foreground",children:t}):null,e?f.jsx("p",{className:"text-xs leading-snug text-muted-foreground",children:e}):null]});return o==="stacked"?f.jsxs("div",{"data-slot":"settings-row",className:Ze("space-y-2.5 px-4 py-3.5",s),children:[f.jsxs("div",{className:"flex items-start gap-3",children:[n?f.jsx("div",{className:"mt-0.5 shrink-0",children:n}):null,a]}),i?f.jsx("div",{children:i}):null]}):o==="responsive"?f.jsxs("div",{"data-slot":"settings-row",className:Ze("flex flex-col gap-2.5 px-4 py-3.5","sm:flex-row sm:items-center sm:gap-4 sm:py-3",s),children:[n?f.jsx("div",{className:"shrink-0 sm:mt-0",children:n}):null,a,i?f.jsx("div",{className:"sm:shrink-0",children:i}):null]}):f.jsxs("div",{"data-slot":"settings-row",className:Ze("flex items-center gap-4 px-4 py-3",s),children:[n?f.jsx("div",{className:"shrink-0",children:n}):null,a,i?f.jsx("div",{className:"shrink-0",children:i}):null]})}const O$=["tokens.list"],jBe=["tokens.current"],wpe=t=>t instanceof Error?t.message:String(t);function kpe(t){return t==null?"Never":new Date(t).toLocaleString()}function fu(){return It({queryKey:jBe,queryFn:()=>Se.tokens.current.query(),staleTime:6e4}).data?.admin===!0}function Sxn(){const t=Rn(),e=It({queryKey:jBe,queryFn:()=>Se.tokens.current.query()}),r=(It({queryKey:O$,queryFn:async()=>(await Se.tokens.list.query()).tokens,refetchInterval:5e3}).data??[]).filter(E=>E.kind==="device"),[o,i]=v.useState(null),[s,a]=v.useState(!1),[l,c]=v.useState("Phone"),[u,d]=v.useState(!1),[h,p]=v.useState(null),[g,_]=v.useState(!1),[x,y]=v.useState(null),k=async()=>{await t.cancelQueries({queryKey:O$}),await t.invalidateQueries({queryKey:O$})},O=()=>{a(!1),c("Phone"),d(!1),i(null)},C=async()=>{_(!0),i(null);try{const{view:E}=await Se.tokens.createUnpairedDevice.mutate({label:l.trim(),admin:u});O(),p({id:E.id,label:E.label}),await k()}catch(E){i(wpe(E))}finally{_(!1)}},A=async E=>{i(null),y(null);try{await Se.tokens.revoke.mutate({tokenId:E.id})}catch(M){i(wpe(M))}await k()};return e.data&&!e.data.admin?f.jsx("p",{role:"alert",className:"text-xs text-muted-foreground","data-testid":"settings__devices-denied",children:"Managing devices needs an admin token."}):f.jsxs(f.Fragment,{children:[f.jsx(_n,{variant:"stacked",label:"Add device",description:"Connect a phone, tablet or another browser with a one-time link and QR code.",children:f.jsxs(Ce,{type:"button",variant:"outline",size:"sm","data-testid":"settings__add-device",onClick:()=>a(!0),children:[f.jsx(wl,{className:"size-3"}),"Add device"]})}),f.jsxs(_n,{variant:"stacked",label:"Devices",description:"Revoking a device signs it out and removes it. The shared token in settings.json cannot be revoked here.",children:[f.jsx("ul",{className:"divide-y divide-border rounded-md border border-border",children:r.map(E=>{const M=E.id===e.data?.tokenId,P=x===E.id;return f.jsxs("li",{"data-testid":"settings__device","data-token-id":E.id,"data-state":E.state,"data-current":M?"true":void 0,"data-confirming":P?M?"self":"other":void 0,className:"flex items-center justify-between gap-2 px-3 py-2 text-sm",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsxs("div",{className:"truncate",children:[E.label||E.id,M?f.jsx("span",{"data-testid":"settings__device-this",className:"ml-2 rounded bg-secondary px-1.5 py-0.5 text-xs",children:"This device"}):null]}),f.jsxs("div",{className:"text-xs text-muted-foreground",children:[E.admin?"Admin":"Standard"," · ",E.state," · Added"," ",kpe(E.createdAt)," · Last used ",kpe(E.lastUsedAt)]}),P?f.jsx("p",{role:"alert",className:"mt-1 text-xs text-destructive",children:M?"This is the token you are signed in with. Revoking it signs you out here.":"Revoking signs this device out and removes it from the list."}):null]}),f.jsx("div",{className:"flex shrink-0 items-center gap-1",children:P?f.jsxs(f.Fragment,{children:[f.jsx(Ce,{type:"button",variant:"destructive",size:"sm","aria-label":`Confirm revoke ${E.label||E.id}`,onClick:()=>{A(E)},children:"Revoke"}),f.jsx(Ce,{type:"button",variant:"ghost",size:"sm",onClick:()=>y(null),children:"Cancel"})]}):f.jsxs(f.Fragment,{children:[E.id==="shared"?null:f.jsx(Ce,{type:"button",variant:"outline",size:"sm","aria-label":`Connect details ${E.label||E.id}`,onClick:()=>p({id:E.id,label:E.label}),children:"Connect details"}),f.jsx(Ce,{type:"button",variant:"outline",size:"sm","aria-label":`Revoke device ${E.label||E.id}`,disabled:E.state!=="active"||E.id==="shared",onClick:()=>y(E.id),children:"Revoke"})]})})]},E.id)})}),o&&!s?f.jsx("p",{role:"alert",className:"mt-2 text-xs text-destructive",children:o}):null]}),f.jsx(nr,{open:s,onOpenChange:E=>E?a(!0):O(),children:f.jsxs(rr,{className:"sm:max-w-[420px]","data-testid":"settings__add-device-dialog",children:[f.jsxs(hr,{children:[f.jsx(or,{children:"Add device"}),f.jsx(Nr,{children:"Name the device. You get a link and QR code to connect it next. You can revoke it from this list later."})]}),f.jsxs("div",{className:"space-y-3",children:[f.jsx(Sn,{"aria-label":"Device label",placeholder:"Label",value:l,onChange:E=>c(E.target.value),className:"h-8 text-sm"}),f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsx("label",{htmlFor:"device-admin",className:"text-sm",children:"Admin device"}),f.jsx(Hi,{id:"device-admin",checked:u,onCheckedChange:d})]}),u?f.jsx("p",{role:"alert",className:"text-xs text-destructive",children:"An admin device can create and revoke devices, workers and credentials. Give it to devices you trust as much as this one."}):null,o?f.jsx("p",{role:"alert",className:"text-xs text-destructive",children:o}):null,f.jsxs(ii,{children:[f.jsx(Ce,{type:"button",variant:"ghost",size:"sm",onClick:O,children:"Cancel"}),f.jsx(Ce,{type:"button",size:"sm",disabled:g||l.trim()==="",onClick:()=>{C()},children:"Create device"})]})]})]})}),h?f.jsx(Oxn,{device:h,onClose:()=>{p(null),k()}}):null]})}const Cxn=t=>t instanceof Error?t.message:String(t);function Axn({open:t,onOpenChange:e,repoName:n,worktree:r,initialTarget:o}){const{repos:i}=xs(),s=Aee(),a={name:n,allowedHostIds:i.find(V=>V.name===n)?.allowedHostIds},l=Rn(),c=Gs(),u=fu(),d=fBe(),h=r.hostId??"local",p=jr(a.name,r.name,r.hostId),g=d.filter(V=>V.status==="online"&&V.id!==h&&V.id!=="local"),[_,x]=v.useState(o??""),[y,k]=v.useState(!1),[O,C]=v.useState(!1),[A,E]=v.useState(null),[M,P]=v.useState(!1),[L,D]=v.useState(null),I=_||g[0]?.id||"",z=a.allowedHostIds??null,Y=I!==""&&z!==null&&!z.includes(I),Q=V=>d.find(G=>G.id===V)?.name||V,H=async()=>{C(!0),E(null);try{const V={worktreeId:p,toHostId:I,...y?{addHost:!0}:{}};D(await Se.checkpoints.move.mutate(V)),await l.invalidateQueries({queryKey:["repos"]})}catch(V){E(Cxn(V)),V.data?.code==="PRECONDITION_FAILED"&&Y&&P(!0)}finally{C(!1)}},N=()=>{if(!L)return;const V=c.getWorktreeHref?.(L.worktreeId);V&&c.navigate&&c.navigate(V),e(!1)};return f.jsx(nr,{open:t,onOpenChange:e,children:f.jsxs(rr,{className:"sm:max-w-[480px]","data-testid":"move-worktree__dialog",children:[f.jsxs(hr,{children:[f.jsx(or,{children:"Open on another worker"}),f.jsxs(Nr,{children:["Takes a fresh checkpoint of ",r.name,", recreates it on the chosen host with its uncommitted files and agent sessions, then removes the copy on ",Q(h),"."]}),f.jsx("p",{className:"text-xs text-muted-foreground","data-testid":"move-worktree__ignored-files",children:"Ignored files (node_modules, build output, .env) are not carried over."})]}),L?f.jsxs("div",{className:"space-y-2","data-testid":"move-worktree__result",children:[f.jsxs("p",{className:"text-sm",children:["Moved to ",Q(L.hostId)," as"," ",f.jsx("span",{className:"font-mono",children:s(L.worktreeId).name}),"."]}),L.warning?f.jsx("p",{role:"alert",className:"text-xs text-destructive","data-testid":"move-worktree__warning",children:L.warning}):null,f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>e(!1),children:"Close"}),f.jsx(Ce,{size:"sm","data-testid":"move-worktree__open",onClick:N,children:"Open worktree"})]})]}):f.jsxs("div",{className:"space-y-3",children:[g.length===0?f.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"move-worktree__no-hosts",children:"No other worker is online."}):f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(To,{htmlFor:"move-worktree-host",children:"Target worker"}),f.jsx("select",{id:"move-worktree-host","data-testid":"move-worktree__host",className:"h-8 w-full rounded-md border border-border bg-transparent px-2 text-sm",value:I,disabled:O,onChange:V=>{x(V.target.value),k(!1),P(!1),E(null)},children:g.map(V=>f.jsx("option",{value:V.id,children:V.name||V.id},V.id))})]}),Y||M?f.jsxs("div",{className:"space-y-1","data-testid":"move-worktree__add-host",children:[f.jsxs("p",{className:"text-xs text-muted-foreground",children:[a.name," is not allowed on ",Q(I),"."]}),f.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[f.jsx("input",{type:"checkbox",checked:y,disabled:!u||O,"data-testid":"move-worktree__add-host-checkbox",onChange:V=>k(V.target.checked)}),"Add ",Q(I)," to ",a.name,"'s allowed hosts"]}),u?null:f.jsx("p",{className:"text-xs text-muted-foreground",children:"Adding a worker needs an admin token."})]}):null,A?f.jsx("p",{role:"alert",className:"text-xs text-destructive","data-testid":"move-worktree__error",children:A}):null,f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>e(!1),children:"Cancel"}),f.jsxs(Ce,{size:"sm","data-testid":"move-worktree__submit",disabled:O||I===""||Y&&!y,onClick:()=>{H()},children:[O?f.jsx(wo,{className:"size-3"}):null,"Open on another worker"]})]})]})]})})}function Exn(t,e){if(t.state==="merged")return"merged";if(t.state==="closed")return"closed";switch(e){case"failure":return"failure";case"running":case"pending":return"pending";case"success":return"success";default:return"neutral"}}const Ope={failure:"text-danger border-danger/40 bg-danger-bg",pending:"text-warning border-warning/40 bg-warning-bg",success:"text-success border-success/40 bg-success-bg",neutral:"text-muted-foreground border-border bg-muted/50",merged:"text-merged border-merged/40 bg-merged-bg",closed:"text-muted-foreground border-border bg-muted/50 line-through"},NBe="inline-flex items-center rounded border px-1 py-px leading-none",Spe=`${NBe} text-[11px] font-semibold tabular-nums`;function Cpe(t,e){if(t.state==="merged")return"Merged";if(t.state==="closed")return"Closed";switch(e){case"failure":return"Checks failing";case"running":return"Checks running";case"pending":return"Checks pending";case"success":return"Checks passed";case"cancelled":return"Checks cancelled";default:return"No checks"}}const Txn=400,S$=200;function Mxn({pr:t,ciState:e,onOpenChecks:n}){const r=Gs(),[o,i]=v.useState(!1),[s,a]=v.useState(!1),l=v.useRef(null),c=v.useRef(null),u=v.useRef(null),d=v.useRef(!1),h=()=>{u.current&&clearTimeout(u.current),u.current=null},p=(y,k)=>{h(),u.current=setTimeout(()=>i(y),k)};v.useEffect(()=>()=>{u.current&&clearTimeout(u.current)},[]),v.useEffect(()=>{if(!s)return;const y=setTimeout(()=>a(!1),1500);return()=>clearTimeout(y)},[s]);const g=Exn(t,e),_=`Pull request #${t.number}: ${Cpe(t,e)}${t.isDraft?", draft":""}`,x=y=>y instanceof Node&&(c.current?.contains(y)||l.current?.contains(y));return f.jsxs(t0,{open:o,onOpenChange:i,children:[f.jsx(Lxe,{asChild:!0,children:f.jsxs("button",{ref:l,type:"button","aria-label":_,"aria-haspopup":"dialog","aria-expanded":o,"data-testid":"worktree-card__pr-badge","data-tone":g,className:`shrink-0 outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring ${Spe} ${Ope[g]}`,onPointerEnter:y=>{y.pointerType!=="touch"&&p(!0,Txn)},onPointerLeave:y=>{y.pointerType!=="touch"&&p(!1,S$)},onFocus:y=>{if(d.current){d.current=!1;return}y.currentTarget.matches(":focus-visible")&&(h(),i(!0))},onBlur:y=>{x(y.relatedTarget)||p(!1,S$)},onClick:y=>{y.stopPropagation(),h(),i(!1),n()},onKeyDown:y=>{y.key==="ArrowDown"&&o&&(y.preventDefault(),c.current?.querySelector("button")?.focus()),(y.key==="Enter"||y.key===" "||y.key.startsWith("Arrow"))&&y.stopPropagation()},children:["#",t.number]})}),f.jsxs(n0,{ref:c,side:"right",align:"start",className:"w-72 p-3","data-testid":"pr-popover",onOpenAutoFocus:y=>y.preventDefault(),onCloseAutoFocus:y=>y.preventDefault(),onEscapeKeyDown:()=>{c.current?.contains(document.activeElement)&&(d.current=!0,l.current?.focus())},onFocusOutside:y=>{x(y.target)&&y.preventDefault()},onPointerEnter:h,onPointerLeave:y=>{y.pointerType!=="touch"&&p(!1,S$)},onBlur:y=>{x(y.relatedTarget)||i(!1)},onClick:y=>y.stopPropagation(),onKeyDown:y=>y.stopPropagation(),onContextMenu:y=>y.stopPropagation(),children:[f.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[f.jsxs("span",{"data-testid":"pr-popover__number","data-tone":g,className:`${Spe} ${Ope[g]}`,children:["#",t.number]}),t.isDraft&&f.jsx("span",{"data-testid":"pr-popover__draft",className:`${NBe} border-border text-[10px] font-medium text-muted-foreground`,children:"Draft"}),f.jsx("span",{"data-testid":"pr-popover__status","data-status":t.state==="open"?e:t.state,className:"text-muted-foreground",children:Cpe(t,e)})]}),f.jsx("p",{"data-testid":"pr-popover__title",className:"mt-1.5 line-clamp-3 break-words text-[13px] font-medium text-foreground",children:t.title}),f.jsxs("div",{className:"mt-2 -ml-1.5 flex items-center gap-1",children:[r.openUrl&&f.jsxs(Ce,{variant:"ghost",size:"xs","data-testid":"pr-popover__open",onClick:()=>{i(!1),r.openUrl?.(t.url)},children:[f.jsx(gM,{}),"Open on GitHub"]}),f.jsxs(Ce,{variant:"ghost",size:"xs","data-testid":"pr-popover__copy","data-copied":s||void 0,onClick:()=>{Vs(t.url).then(y=>a(y))},children:[s?f.jsx(Ji,{}):f.jsx(Pot,{}),s?"Copied":"Copy link"]})]})]})]})}const RBe=6;function Pxn(t){const e=t.match(/[\p{L}\p{N}]/u);return e?e[0].toUpperCase():"?"}function jxn(t){let e=0;for(const n of t)e=e*31+(n.codePointAt(0)??0)>>>0;return e%RBe}function Nxn({name:t,className:e,textClassName:n="text-[9px]",testId:r}){const o=jxn(t)%RBe;return f.jsx("span",{"aria-hidden":!0,"data-testid":r,"data-color-index":o,className:`${e} flex shrink-0 select-none items-center justify-center rounded-sm font-semibold leading-none ${n}`,style:{backgroundColor:`var(--repo-avatar-${o+1})`,color:"var(--repo-avatar-foreground)"},children:Pxn(t)})}function m8({name:t,avatar:e,fallback:n,className:r,textClassName:o,testId:i}){const[s,a]=v.useState(null),l=n??f.jsx(Nxn,{name:t,className:r,textClassName:o,testId:i?`${i}-fallback`:void 0});if(!e)return f.jsx(f.Fragment,{children:l});const c=s?.src===e.src?s.ok:void 0;return f.jsxs(f.Fragment,{children:[c!==!0&&l,c!==!1&&f.jsx("img",{src:lh(e.src),alt:e.label,hidden:c!==!0,draggable:!1,"data-testid":i,ref:u=>{u?.complete&&c===void 0&&a({src:e.src,ok:u.naturalWidth>0})},className:`${r} shrink-0 rounded-sm object-cover`,onLoad:()=>a({src:e.src,ok:!0}),onError:()=>a({src:e.src,ok:!1})})]})}function JQ({testId:t="worktree-card__root-star"}){return f.jsxs(Or,{delayDuration:200,children:[f.jsx(Sr,{asChild:!0,children:f.jsx("span",{role:"img","aria-label":"Repository root","data-testid":t,className:"inline-flex shrink-0 items-center text-muted-foreground",children:f.jsx($it,{className:"size-3"})})}),f.jsx(Cr,{side:"top","data-testid":"worktree-card__root-star-tooltip",children:"Repository root"})]})}function Rxn(t,e){const n=new Map;for(const i of t)for(const s of i.worktrees)n.set(jr(i.name,s.name,s.hostId),s.children??[]);const r=new Set([e]),o=[e];for(let i=o.pop();i!==void 0;i=o.pop())for(const s of n.get(i)??[])r.has(s)||(r.add(s),o.push(s));return r}function Lxn({open:t,onOpenChange:e,repoName:n,worktree:r}){const{repos:o}=xs(),i=Rn(),s=sN(),[a,l]=v.useState(null),[c,u]=v.useState(!1),d=jr(n,r.name,r.hostId),h=v.useMemo(()=>{const _=Rxn(o,d);return o.flatMap(x=>x.worktrees.map(y=>({worktreeId:jr(x.name,y.name,y.hostId),repoName:x.name,name:y.name,branch:y.branch,hostId:y.hostId})).filter(y=>!_.has(y.worktreeId)))},[o,d]),p=new Set(o.flatMap(_=>_.worktrees.map(x=>x.hostId??"local"))).size>1,g=async _=>{u(!0),l(null);try{await Se.worktrees.setOrigin.mutate({repo:n,name:r.name,hostId:r.hostId,origin:_}),e(!1),await i.invalidateQueries({queryKey:Un.repos})}catch(x){l(x instanceof Error?x.message:String(x))}finally{u(!1)}};return f.jsx(nr,{open:t,onOpenChange:e,children:f.jsxs(rr,{variant:"command-palette",className:"overflow-hidden p-0 lg:max-w-[520px]",showCloseButton:!1,"data-testid":"set-parent__dialog",children:[f.jsxs(hr,{className:"sr-only",children:[f.jsx(or,{children:"Set parent"}),f.jsxs(Nr,{children:["Choose the worktree ",r.name," was started from"]})]}),f.jsxs(S4,{shouldFilter:!0,children:[f.jsx(zg,{placeholder:`Set parent of ${r.name}...`}),f.jsxs(jh,{className:"max-h-[360px]",children:[f.jsx(C4,{children:"No worktrees found."}),h.map(_=>f.jsxs(M0,{value:`${_.repoName} ${_.name} ${_.branch} ${p?s(_.hostId==="local"?void 0:_.hostId):""}`,disabled:c,onSelect:()=>{g(_.worktreeId)},"data-testid":`set-parent__item--${_.worktreeId}`,children:[f.jsxs("span",{className:"truncate",children:[_.repoName," · ",_.name]}),p&&f.jsx("span",{className:"ml-auto shrink-0 text-xs text-muted-foreground",children:s(_.hostId==="local"?void 0:_.hostId)})]},_.worktreeId))]})]}),a&&f.jsx("p",{role:"alert",className:"px-3 pb-2 text-xs text-destructive","data-testid":"set-parent__error",children:a})]})})}function Ixn({setup:t}){return t?t.state==="running"?f.jsxs(Or,{children:[f.jsx(Sr,{asChild:!0,children:f.jsx(H2,{className:"size-3.5 shrink-0 text-info animate-spin"})}),f.jsx(Cr,{side:"top",children:"Setting up worktree..."})]}):t.state==="failed"?f.jsxs(Or,{children:[f.jsx(Sr,{asChild:!0,children:f.jsx(_u,{className:"size-3.5 shrink-0 text-danger"})}),f.jsxs(Cr,{side:"top",children:["Setup failed",t.error?`: ${t.error}`:""]})]}):null:null}function Tee({name:t,repoName:e,isActive:n,tone:r="sidebar",repoIcon:o,hostTag:i}){const s=r==="switcher"?`text-foreground ${n?"font-semibold":"font-medium"}`:n?"font-bold text-foreground":"font-medium text-foreground/75",a=r==="switcher"?"text-foreground/70":n?"text-foreground/80":"text-foreground/60",l=r==="sidebar";return f.jsxs("div",{"data-testid":"worktree-label",className:"flex flex-col min-w-0 leading-tight",children:[f.jsx("span",{"data-testid":"worktree-label__name",className:Ze(l?"text-[13px]":"text-sm","truncate",s),children:t}),f.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[o,f.jsx("span",{"data-testid":"worktree-label__repo",className:Ze(l?"text-[11px]":"text-xs","truncate",a),children:e}),i&&f.jsx("span",{"data-testid":"worktree-label__host",className:"shrink-0 rounded bg-muted px-1 text-[10px] leading-4 text-muted-foreground",children:i})]})]})}const Dxn=300;let WE=null,c3=null;function LBe(t){WE=t,c3&&clearTimeout(c3),c3=setTimeout(()=>{WE=null,c3=null},Dxn)}function zxn(t){return WE!==t?!1:(WE=null,c3&&(clearTimeout(c3),c3=null),!0)}function lv({testId:t,label:e,details:n,attrs:r,children:o}){return f.jsxs(Or,{delayDuration:300,children:[f.jsx(Sr,{asChild:!0,children:f.jsx("span",{"data-testid":t,role:"img","aria-label":e,...r,className:"flex shrink-0 items-center ml-auto pl-2 text-muted-foreground",children:o})}),f.jsx(Cr,{side:"right","data-testid":`${t}-details`,children:n??e})]})}const IBe=v.memo(function({worktree:e,repoName:n,defaultBranch:r,repoKind:o,status:i,branchStatus:s,setupStatus:a,isFocused:l,onShowDeleteDialog:c,showRepoName:u,repoAvatar:d,hostTag:h,allowedHostIds:p,chevronGutter:g,onTogglePinned:_}){const x=o==="plain",y=H_n(e.hostId),k=h??y,O=v.useRef(null),C=Gs(),A=Cn(Le=>Le.openWorktree),E=Cn(Le=>Le.clearNeedsAttention),M=Cn(Le=>Le.runScript),P=Cn(Le=>Le.gitPull),L=Cn(Le=>Le.gitPush),D=oBe(),I=e.pinned,z=hBe(e.hostId),Y=z.offline,Q=e.supersededBy,H=e.lastCheckpointAt??null,[N,V]=v.useState(!1),[G,K]=v.useState(!1),q=Rn(),Z=Cn(Le=>Le.setError),[U,B]=v.useState(!1),ee=e.divergence?.state==="diverged",te=!!e.hostId&&e.hostId!=="local"&&!Q,se=z.name||e.hostId||"this worker",ae=te?Y?"offline":"move":null,he=ae===null?null:p?.every(Le=>Le===e.hostId)?`Only available on ${se}`:ae==="offline"&&H===null?"The hub has no checkpoint of this worktree":null,[fe,be]=v.useState(null),me=()=>{if(ae==="move"){V(!0);return}Se.follow.offer.query({worktreeId:jr(n,e.name,e.hostId)}).then(be).catch(Le=>Z(Le))},le=!x&&e.name===r,Be=jr(n,e.name,e.hostId),Xe=Cn(Le=>Le.activeWorktreeId===Be),ot=B_n(Be,e.continuedFrom?.at??0,Xe&&!!e.continuedFrom),Qe=sN(),lt=Cn(Le=>Bye(Le,Be)),bt=C.getWorktreeHref?.(Be);v.useEffect(()=>{Xe&&(zxn(Be)||O.current?.scrollIntoView({block:"center"}))},[Xe,Be]);const ve=()=>{lt||(E(Be),LBe(Be),bt&&C.navigate?C.navigate(bt):bt||A(Be))},Te=()=>{lt||(K_n(Be),Xe||ve())},Ne={ref:O,className:`@container group flex flex-row items-center justify-between rounded-md ${g?"pl-5":"pl-3"} pr-2 py-1 min-h-9 min-w-0 overflow-hidden select-none touch-manipulation transition-colors ${lt?"cursor-not-allowed opacity-50":`cursor-pointer hover:bg-accent/50 ${Y&&!Q?"opacity-60":""}`} [@media(pointer:coarse)]:min-h-11 [@media(pointer:coarse)]:py-2 ${Xe?"bg-selection text-selection-foreground outline outline-1 -outline-offset-1 outline-selection-border hover:bg-selection":l?"bg-accent":""} ${bt?"no-underline text-inherit":""}`,tabIndex:lt?-1:0,"aria-disabled":lt||void 0,"data-deleting":lt||void 0,"data-active":Xe||void 0,"aria-current":Xe?"page":void 0,"data-testid":`repo-list__worktree-card--${Be}`,onClick:Le=>{Le.stopPropagation(),ve()},onKeyDown:Le=>{(Le.key==="Enter"||Le.key===" ")&&(Le.stopPropagation(),ve())}},$e=s?.ci.state,De=$e!==void 0&&$e!=="none"&&$e!=="merged",ct=s?.git.dirty??!1,ue=(s?.git.ahead??0)>0,Pe=()=>{Se.worktrees.setOrigin.mutate({repo:n,name:e.name,hostId:e.hostId,origin:null}).then(()=>q.invalidateQueries({queryKey:Un.repos})).catch(Le=>Z(Le))},Ee=()=>{!De&&!ct&&!ue?D.mutate({repo:n,name:e.name,hostId:e.hostId}):c({repoName:n,name:e.name,hostId:e.hostId,isUnmerged:De,isDirty:ct,hasUnpushedCommits:ue})};return f.jsxs(J0,{children:[f.jsx(e1,{asChild:!0,disabled:lt,children:f.jsxs("div",{...Ne,children:[f.jsxs(Or,{delayDuration:800,children:[f.jsx(Sr,{asChild:!0,children:f.jsxs("div",{className:"flex flex-1 items-center gap-2 min-w-0 overflow-hidden",children:[f.jsx(_G,{agent:i?.agent,tabStatuses:i?.tabStatuses}),u?f.jsxs(f.Fragment,{children:[f.jsx(Tee,{name:e.name,repoName:n,isActive:Xe,hostTag:k,repoIcon:f.jsx(m8,{name:n,avatar:d,className:"size-3 shrink-0 rounded-sm",textClassName:"text-[7px]",testId:`worktree-label__avatar--${n}`})}),le&&f.jsx(JQ,{})]}):f.jsxs(f.Fragment,{children:[f.jsx("span",{className:`text-[13px] truncate ${Xe?"font-bold text-foreground":"font-medium text-foreground/75"}`,children:e.name}),le&&f.jsx(JQ,{}),k&&f.jsx("span",{"data-testid":"worktree-label__host",className:"shrink-0 rounded bg-muted px-1 text-[10px] leading-4 text-muted-foreground",children:k})]})]})}),f.jsx(Cr,{side:"right",children:`${n}/${e.name}`})]}),lt&&f.jsx(lv,{testId:"worktree-card__deleting",label:"Deleting",children:f.jsx(H2,{className:"size-3.5 animate-spin"})}),e.lifecycle&&!lt&&f.jsx(lv,{testId:"worktree-card__lifecycle",label:e.lifecycle==="waking"?"Waking":"Sleeping",attrs:{"data-lifecycle":e.lifecycle},children:e.lifecycle==="waking"?f.jsx(H2,{className:"size-3.5 animate-spin"}):f.jsx(Yot,{className:"size-3.5"})}),e.continuedFrom&&!lt&&ot&&f.jsx(exn,{from:e.continuedFrom,testId:"worktree-card__continued-from"}),Q&&!lt&&f.jsx(lv,{testId:"worktree-card__superseded",label:`Superseded by ${Q}`,details:`Restored as ${Q}. The files on this worker are untouched.`,attrs:{"data-superseded-by":Q},children:f.jsx(yit,{className:"size-3.5"})}),Q&&ee&&!lt&&f.jsx("button",{type:"button","data-testid":"worktree-card__diverged","aria-label":"Diverged: this copy changed after the checkpoint",title:"Diverged: this copy changed after the checkpoint",className:"flex shrink-0 items-center pl-2 text-destructive",onClick:Le=>{Le.stopPropagation(),B(!0)},children:f.jsx(iae,{className:"size-3.5"})}),e.hostNotAllowed&&!lt&&f.jsx(lv,{testId:"worktree-card__not-allowed",label:"Not allowed on this worker",details:"This repo is no longer allowed on this worker. The worktree is kept and still opens.",children:f.jsx($7e,{className:"size-3.5"})}),e.missing&&!lt&&f.jsx(lv,{testId:"worktree-card__missing",label:"Missing",details:"The worker no longer has this worktree's folder. Remove drops the record.",children:f.jsx(Aot,{className:"size-3.5"})}),f.jsxs("div",{className:`${lt?"hidden":"hidden @[10rem]:flex group-hover:flex group-focus-within:flex"} items-center gap-2 shrink-0 pl-2`,children:[f.jsx(Ixn,{setup:a}),!x&&s&&f.jsx(axn,{git:s.git}),!x&&s?.ci.pr&&f.jsx(Mxn,{pr:s.ci.pr,ciState:s.ci.state,onOpenChecks:Te}),!x&&s&&!s.ci.pr&&f.jsx(DTt,{ci:s.ci})]}),Y&&!Q&&!lt&&f.jsxs(Or,{delayDuration:300,children:[f.jsx(Sr,{asChild:!0,children:f.jsx("span",{"data-testid":"worktree-card__offline","data-checkpoint":H!==null?"true":"false",role:"img","aria-label":`${se} is offline`,className:"flex shrink-0 items-center pl-2 text-muted-foreground",children:f.jsx(V7e,{className:"size-3.5"})})}),f.jsxs(Cr,{side:"right","data-testid":"worktree-card__offline-details",children:[f.jsxs("div",{children:[se," is offline"]}),f.jsx("div",{children:z.lastSeenAt!==null?`Last seen ${ZQ(z.lastSeenAt)}`:"Never seen"}),f.jsx("div",{children:H!==null?`Last checkpoint ${ZQ(H)}`:"No checkpoint"})]})]})]})}),f.jsxs(t1,{children:[f.jsx(Vae,{children:"Worktree"}),e.continuedFrom&&f.jsx(Vae,{"data-testid":"worktree-card__continued-from-line",className:"font-normal text-muted-foreground",children:mBe(e.continuedFrom,Qe(e.continuedFrom.fromHostId))}),f.jsxs(Qn,{onClick:()=>_(n,e.name,I,e.hostId),children:[I?f.jsx(K7e,{}):f.jsx(vZ,{}),I?"Unpin worktree":"Pin worktree"]}),f.jsxs(Qn,{"data-testid":"worktree-card__set-parent",onClick:()=>requestAnimationFrame(()=>K(!0)),children:[f.jsx(Hrt,{}),"Set parent…"]}),e.origin&&f.jsxs(Qn,{"data-testid":"worktree-card__remove-parent",onClick:Pe,children:[f.jsx(Kit,{}),"Remove parent"]}),f.jsx(P0,{}),C.copyPath&&f.jsxs(Qn,{onClick:()=>navigator.clipboard.writeText(e.path),children:[f.jsx(q7e,{}),"Copy path"]}),C.revealInFinder&&f.jsxs(Qn,{onClick:()=>C.revealInFinder(e.path),children:[f.jsx(ld,{}),"Open in Finder"]}),e.hasSetup&&f.jsxs(Qn,{onClick:()=>M(e.path,"setup"),children:[f.jsx(J7e,{}),"Run setup"]}),e.hasTeardown&&f.jsxs(Qn,{onClick:()=>M(e.path,"teardown"),children:[f.jsx(nve,{}),"Run teardown"]}),!x&&f.jsxs(Qn,{onClick:()=>P(n,e.name,e.hostId),children:[f.jsx(Hnt,{}),"Git pull"]}),!x&&f.jsxs(Qn,{onClick:()=>L(n,e.name,e.hostId),children:[f.jsx(Unt,{}),"Git push"]}),ae&&!x&&f.jsxs(Qn,{"data-testid":"worktree-card__move",disabled:he!==null,onClick:me,children:[f.jsx(Jot,{}),f.jsxs("span",{className:"flex flex-col",children:["Open on another worker…",he?f.jsx("span",{"data-testid":"worktree-card__move-reason",className:"text-xs",children:he}):null]})]}),Q&&f.jsxs(Qn,{variant:"destructive","data-testid":"worktree-card__remove-superseded",onClick:()=>{window.confirm(`Remove this copy? The files of ${e.name} on its worker are deleted. The restored worktree ${Q} is not touched.`)&&D.mutate({repo:n,name:e.name,hostId:e.hostId})},children:[f.jsx(Kl,{}),"Remove this copy"]}),Q&&ee&&f.jsxs(Qn,{"data-testid":"worktree-card__review-divergence",onClick:()=>B(!0),children:[f.jsx(iae,{}),"Review changes made after the checkpoint"]}),e.missing&&!Q&&f.jsxs(Qn,{variant:"destructive","data-testid":"worktree-card__remove-missing",onClick:()=>D.mutate({repo:n,name:e.name,hostId:e.hostId}),children:[f.jsx(Kl,{}),"Remove missing worktree"]}),!x&&e.name!==r&&f.jsxs(Qn,{variant:"destructive",onClick:Ee,children:[f.jsx(Kl,{}),"Delete worktree"]})]}),Q&&U&&f.jsx(sxn,{open:U,onOpenChange:B,worktreeId:Be}),G&&f.jsx(Lxn,{open:G,onOpenChange:K,repoName:n,worktree:e}),fe&&f.jsx(Cee,{offer:fe,onClose:()=>{be(null)}}),ae==="move"&&N&&f.jsx(Axn,{open:N,onOpenChange:V,repoName:n,worktree:e})]})}),$xn=16,Bxn={grouped:10,pinned:6,ungrouped:0};function DBe({entry:t,mode:e,isFocused:n,hosts:r,statuses:o,branchStatuses:i,setupStatuses:s,onShowDeleteDialog:a,onTogglePinned:l}){return f.jsx(IBe,{worktree:t.worktree,repoName:t.repo.name,defaultBranch:t.repo.defaultBranch,repoKind:t.repo.kind,status:o.get(t.worktreeId),branchStatus:i.get(t.worktreeId),setupStatus:s.get(t.worktreeId),isFocused:n,onShowDeleteDialog:a,showRepoName:!0,repoAvatar:t.repo.avatar,hostTag:e==="repo"||bh(t.worktree)==="local"?void 0:zE(bh(t.worktree),r),allowedHostIds:t.repo.allowedHostIds,chevronGutter:!0,onTogglePinned:l})}function zBe({row:t,index:e,mode:n,originCollapse:r,hosts:o,statuses:i,branchStatuses:s,setupStatuses:a,focusedIndex:l,onShowDeleteDialog:c,onTogglePinned:u}){const{entry:d}=t,h=t.pinned===!0&&t.depth===0,p=Gs(),g=Cn(k=>k.openWorktree),_=k=>{const O=p.getWorktreeHref?.(k);O&&p.navigate?p.navigate(O):g(k)},x=t.pinned?"repo-list__pinned-row":"repo-list__grouped-row",y=Bxn[t.pinned?"pinned":t.ungrouped?"ungrouped":"grouped"]+t.depth*$xn;return f.jsx(cBe,{dndId:`${h?"pin":"wt"}:${d.worktreeId}`,disabled:n==="repo"&&t.depth>0,testId:`repo-list__drag-row--${d.worktreeId}`,className:t.pinned?void 0:"mr-2",data:{kind:h?"pin":"wt",worktreeId:d.worktreeId,repoName:d.repo.name,hostId:bh(d.worktree),inset:y},children:f.jsxs("div",{"data-testid":`${x}--${d.worktreeId}`,"data-depth":t.depth,"data-ungrouped":t.ungrouped||void 0,className:"flex min-w-0 flex-col",style:{paddingLeft:y},children:[f.jsxs("div",{className:"relative min-w-0",children:[t.childCount>0&&f.jsx("button",{type:"button","aria-label":t.collapsed?"Expand started worktrees":"Collapse started worktrees","aria-expanded":!t.collapsed,"data-testid":`repo-list__origin-toggle--${d.worktreeId}`,onClick:()=>r.toggle(d.worktreeId),className:"absolute left-0 top-1/2 z-10 flex size-5 -translate-y-1/2 items-center justify-center rounded text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:f.jsx(bo,{"data-testid":`repo-list__origin-toggle-icon--${d.worktreeId}`,className:`size-3 transition-transform ${t.collapsed?"":"rotate-90"}`})}),f.jsx(DBe,{entry:d,mode:n,isFocused:e===l,hosts:o,statuses:i,branchStatuses:s,setupStatuses:a,onShowDeleteDialog:c,onTogglePinned:u})]}),t.fromParent&&f.jsxs("button",{type:"button","data-testid":`repo-list__from-parent--${d.worktreeId}`,title:`Open ${t.fromParent.name}`,onClick:()=>_(t.fromParent.worktreeId),className:"ml-5 w-fit max-w-full truncate rounded px-1 text-left text-[11px] text-muted-foreground hover:bg-accent/50 hover:text-foreground",children:["from ",t.fromParent.name]}),t.parentRemoved&&f.jsx("span",{"data-testid":`repo-list__parent-removed--${d.worktreeId}`,className:"pl-5 text-[11px] text-muted-foreground",children:"parent removed"})]})})}function Hxn({header:t,group:e,actions:n,canMoveUp:r,canMoveDown:o}){return f.jsxs(J0,{children:[f.jsx(e1,{asChild:!0,children:t}),f.jsxs(t1,{children:[f.jsxs(Qn,{"data-testid":"repo-list__group-action--rename",onClick:()=>n.onRename(e),children:[f.jsx(y4,{}),"Rename…"]}),f.jsxs(Qn,{"data-testid":"repo-list__group-action--move-up",disabled:!r,onClick:()=>n.onMove(e,-1),children:[f.jsx(z7e,{}),"Move up"]}),f.jsxs(Qn,{"data-testid":"repo-list__group-action--move-down",disabled:!o,onClick:()=>n.onMove(e,1),children:[f.jsx(uZ,{}),"Move down"]}),f.jsxs(wdt,{children:[f.jsxs(kdt,{"data-testid":"repo-list__group-action--color",children:[f.jsx(rit,{}),"Color"]}),f.jsx(Odt,{children:f.jsx(lBe,{color:e.color,testId:"repo-list__group-color",Swatch:Qn,custom:!1,onChange:i=>n.onColor(e,i)})})]}),f.jsxs(Qn,{"data-testid":"repo-list__group-action--delete",onClick:()=>n.onDelete(e),children:[f.jsx(Kl,{}),"Delete…"]})]})]})}function Fxn({rows:t,groupCollapse:e,groupActions:n,groupOrder:r,navStart:o,...i}){let s=o;return f.jsxs("div",{className:"flex flex-col gap-0.5","data-testid":"repo-list__grouped--groups",children:[t.map(a=>{if(a.kind==="group"){const c=a.groupId??"",u=a.groupId&&a.color?{id:a.groupId,name:a.name,color:a.color}:null,d=f.jsxs("div",{className:"group/header mt-1 flex items-center pr-2",children:[f.jsx(R_n,{dndId:a.key,groupId:a.groupId,children:({setNodeRef:h,over:p,zone:g,dragListeners:_,dragging:x})=>f.jsxs("button",{ref:h,type:"button","data-testid":`repo-list__group-header--${c}`,"data-drop-zone":p?g??"into":void 0,"aria-expanded":!a.collapsed,onClick:()=>e.toggle(c),..._,className:`relative flex h-9 min-w-0 flex-1 items-center gap-2 pl-3 pr-2 text-left transition-colors hover:bg-accent/50 ${p&&g==="into"?"bg-primary/20":""} ${x?"opacity-40":""}`,children:[p&&g==="before"&&f.jsx("span",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 bg-primary"}),p&&g==="after"&&f.jsx("span",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-0.5 bg-primary"}),a.color?f.jsx("span",{"data-testid":`repo-list__group-dot--${c}`,className:"size-2.5 shrink-0 rounded-full",style:{backgroundColor:a.color}}):f.jsx(hM,{className:"size-2.5 shrink-0 text-muted-foreground"}),f.jsx("span",{"data-testid":`repo-list__group-name--${c}`,className:"truncate text-[13px] font-semibold text-foreground/90",children:a.name}),f.jsx("span",{"data-testid":`repo-list__group-count--${c}`,className:"ml-auto shrink-0 text-[11px] text-muted-foreground",children:a.count}),f.jsx(bo,{className:`size-3.5 shrink-0 text-muted-foreground transition-transform ${a.collapsed?"":"rotate-90"}`})]})}),f.jsx(Ce,{variant:"ghost",size:"icon-xs","aria-label":`New worktree in ${a.name}`,"data-testid":`repo-list__group-add--${c}`,onClick:()=>n.onAddWorktree(a.groupId),children:f.jsx(wl,{})})]},a.key);return u?f.jsx(Hxn,{header:d,group:u,actions:n,canMoveUp:r.indexOf(u.id)>0,canMoveDown:r.indexOf(u.id)<r.length-1},a.key):d}const l=s++;return f.jsx(zBe,{row:a,index:l,mode:"groups",...i},a.key)}),f.jsx(L_n,{hidden:t.some(a=>a.kind==="worktree"&&a.ungrouped)})]})}const qxn=t=>t instanceof Error?t.message:String(t);function Vxn({repo:t,hosts:e}){const n=Rn(),[r,o]=v.useState(null),[i,s]=v.useState(null),a=t.mainMissing;if(!a)return null;const l=(t.clones??[]).filter(d=>d.hostId!==a.hostId&&(!t.allowedHostIds||t.allowedHostIds.includes(d.hostId))),c=zE(a.hostId,e),u=async d=>{s(null),o(d);try{await Se.repos.update.mutate({name:t.name,primaryHostId:d}),await n.invalidateQueries({queryKey:["repos"]})}catch(h){s(qxn(h))}finally{o(null)}};return f.jsxs("div",{className:"flex flex-col gap-1 rounded-md px-3 py-2 text-[13px]","data-testid":"repo-main-missing","data-primary-host":a.hostId,children:[f.jsxs("div",{className:"flex items-start gap-2",children:[f.jsx(Mc,{className:"mt-0.5 size-3.5 shrink-0 text-warning","aria-hidden":!0}),f.jsxs("div",{className:"min-w-0",children:[f.jsx("div",{className:"truncate font-medium",children:t.defaultBranch}),f.jsxs("div",{className:"text-foreground/60","data-testid":"repo-main-missing__text",children:["not checked out on ",c]})]})]}),l.length===0?f.jsxs("p",{className:"text-xs text-foreground/60",children:["Check out ",t.defaultBranch," on ",c,", or add another clone from Add repo."]}):null,l.map(d=>f.jsxs(Ce,{size:"sm",variant:"outline",disabled:r!==null,"data-testid":"repo-main-missing__make-primary","data-host-id":d.hostId,onClick:()=>u(d.hostId),children:["Make ",zE(d.hostId,e)," the primary host"]},d.hostId)),i?f.jsx("p",{role:"alert",className:"text-xs text-destructive",children:i}):null]})}function Qxn(t){return t.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9\-/]/g,"").replace(/-{2,}/g,"-").replace(/\/+/g,"/").replace(/^[-/]+|[-/]+$/g,"")}const Uxn="local";function Wxn(t,e){return t?t.includes(e||Uxn):!0}const cv="local";function Zxn(t){const e=t?.data?.existingWorktreeId;return typeof e=="string"?e:void 0}function Gxn({repoName:t,groupId:e,open:n,onOpenChange:r}){const[o,i]=v.useState(cv),[s,a]=v.useState(""),[l,c]=v.useState(""),[u,d]=v.useState(""),[h,p]=v.useState(""),[g,_]=v.useState(!1),x=O_n(),{repos:y}=xs(),[k]=nX(),O=rX(),C=k&&O.some(ee=>ee.id===k)?k:void 0,A=e!==void 0?e:C,E=It({queryKey:["hosts.list"],queryFn:async()=>(await Se.workers.list.query()).hosts,enabled:n}),M=sN(),P=Cn(ee=>ee.openWorktree),L=y.find(ee=>ee.name===t),D=(E.data??[]).filter(ee=>ee.usable&&(ee.id===cv||ee.status==="online")&&Wxn(L?.allowedHostIds,ee.id)),I=D.some(ee=>ee.id===o)?o:D[0]?.id??cv,z=I!==cv,Y=Qxn(l),Q=Y?L?.worktrees.find(ee=>(ee.name===Y||ee.branch===Y)&&(ee.hostId||cv)!==I):void 0,H=Q?jr(t,Q.name,Q.hostId):Zxn(x.error)??null,N=l&&!Y?"Branch name contains no valid characters.":Q?`${Y} is already on ${M(Q.hostId)}`:Y&&L?.worktrees.some(ee=>ee.branch===Y)?`A worktree named "${Y}" already exists.`:null,V=async ee=>{if(ee.preventDefault(),!(!Y||N)){try{await x.mutateAsync({repo:t,branch:Y,base:u.trim()||void 0,prompt:h.trim()||void 0,host:z?{hostId:I,hostRepoPath:s.trim()||void 0}:void 0,groupId:A})}catch{return}c(""),d(""),p(""),r(!1)}},G=D.find(ee=>ee.id===I)?.name??I,K=z&&!L?.remoteUrl,q=z,Z=f.jsxs("div",{className:"grid gap-1.5",children:[f.jsx(To,{htmlFor:"host-repo-path",children:K?`Repository folder on ${G}`:`Folder on ${G}`}),f.jsx(Sn,{id:"host-repo-path","data-testid":"new-worktree-form__host-path",value:s,onChange:ee=>a(ee.target.value),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1})]}),U=!!N,B=x.error;return f.jsx(nr,{open:n,onOpenChange:r,children:f.jsx(rr,{className:"sm:max-w-lg","data-testid":"new-worktree-form__dialog",children:f.jsxs("form",{onSubmit:V,children:[f.jsxs(hr,{children:[f.jsxs(or,{children:["New worktree in ",t]}),f.jsx(Nr,{className:"sr-only",children:"Choose a branch name and an optional prompt for the coding agent."})]}),f.jsxs(su,{open:g,onOpenChange:_,children:[f.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)] gap-3 py-4",children:[f.jsxs("div",{className:"grid gap-1.5",children:[f.jsx(To,{htmlFor:"branch-name",children:"Branch"}),f.jsxs("div",{className:"relative",children:[f.jsx(Sn,{id:"branch-name","data-testid":"new-worktree-form__branch",placeholder:"feat/my-branch",value:l,onChange:ee=>c(ee.target.value),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,autoFocus:!0,"aria-invalid":U||void 0,className:U?"border-destructive pr-9":void 0}),N&&f.jsxs(Ape,{testId:"new-worktree-form__slug-error",label:"Branch error",className:"absolute right-1 top-1/2 -translate-y-1/2",children:[f.jsx("p",{"data-testid":"new-worktree-form__slug-error-message",children:N}),H&&f.jsx(Ce,{type:"button",variant:"outline",size:"sm",className:"mt-2","data-testid":"new-worktree-form__open-existing",onClick:()=>{P(H),r(!1)},children:"Open it"})]})]}),l&&Y&&Y!==l&&!N&&f.jsxs("p",{className:"text-xs text-muted-foreground","data-testid":"new-worktree-form__slug",children:["Creates ",f.jsx("code",{children:Y})]})]}),f.jsxs("div",{className:"grid gap-1.5",children:[f.jsx(To,{htmlFor:"initial-prompt",children:"Prompt"}),f.jsx(cG,{id:"initial-prompt",placeholder:"What should the agent do? Leave empty to start without a task.",value:h,onChange:ee=>p(ee.target.value),rows:3})]}),K&&Z,f.jsxs(au,{className:"grid gap-3",children:[f.jsxs("div",{className:"grid gap-1.5",children:[f.jsx(To,{htmlFor:"base-branch",children:"Base branch"}),f.jsx(Sn,{id:"base-branch","data-testid":"new-worktree-form__base",placeholder:L?.defaultBranch??"main",value:u,onChange:ee=>d(ee.target.value),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1})]}),q&&!K&&Z]})]}),f.jsxs(ii,{className:"items-center",children:[f.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2 sm:mr-auto sm:flex-1",children:[D.length>1&&f.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[f.jsx(To,{htmlFor:"worktree-host",children:"Worker"}),f.jsx("select",{id:"worktree-host","data-testid":"new-worktree-form__host",value:I,onChange:ee=>i(ee.target.value),className:"h-9 min-w-0 flex-1 rounded-md border border-input bg-transparent px-3 text-sm",children:D.map(ee=>f.jsx("option",{value:ee.id,children:ee.name},ee.id))})]}),f.jsx(Ph,{asChild:!0,children:f.jsxs(Ce,{type:"button",variant:"ghost",size:"sm",className:"gap-1 text-muted-foreground","data-testid":"new-worktree-form__more-options",children:[f.jsx(bo,{className:`size-4 transition-transform ${g?"rotate-90":""}`}),"More options"]})})]}),B&&f.jsx(Ape,{testId:"new-worktree-form__error",label:"Create error",children:f.jsx("p",{"data-testid":"new-worktree-form__error-message",children:B.message})}),f.jsx("p",{role:"alert",className:"sr-only",children:B?.message}),f.jsx(Ce,{type:"button",variant:"ghost",onClick:()=>r(!1),children:"Cancel"}),f.jsx(Ce,{type:"submit","data-testid":"new-worktree-form__submit",disabled:!Y||!!N||x.isPending,children:"Create"})]})]})]})})})}function Ape({testId:t,label:e,className:n,children:r}){return f.jsxs(t0,{children:[f.jsx(ku,{asChild:!0,children:f.jsx("button",{type:"button","aria-label":e,"data-testid":t,className:`rounded-sm p-1 text-destructive outline-none focus-visible:ring-2 focus-visible:ring-ring ${n??""}`,children:f.jsx(_u,{className:"size-4"})})}),f.jsx(n0,{align:"end",className:"text-sm","aria-live":"polite",children:r})]})}function Yxn({open:t,onOpenChange:e,onConfirm:n,repoName:r}){return f.jsx(nr,{open:t,onOpenChange:e,children:f.jsxs(rr,{className:"sm:max-w-[425px]",onClick:o=>o.stopPropagation(),children:[f.jsxs(hr,{children:[f.jsx(or,{children:"Promote to git"}),f.jsxs(Nr,{children:["This will run ",f.jsx("code",{children:"git init -b main"})," in ",f.jsx("strong",{children:r})," and turn it into a git repository."]})]}),f.jsx("div",{className:"flex flex-col gap-2 text-sm",children:f.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-info/30 bg-info-bg p-3",children:[f.jsx(ub,{className:"size-4 shrink-0 text-info mt-0.5"}),f.jsx("span",{children:"After promotion you'll be able to create branches, view diffs, and use git pull / push for this repo. The existing worktree stays in place."})]})}),f.jsxs(ii,{children:[f.jsx(Ce,{variant:"ghost",onClick:()=>e(!1),children:"Cancel"}),f.jsx(Ce,{onClick:n,children:"Promote to git"})]})]})})}const Xxn={pending:"Waiting for a worker",leased:"Starting a worker",fulfilled:"Setting up the worktree",failed:"Failed",cancelled:"Cancelled"};function Kxn({request:t}){const e=__n(),n=t.status==="failed",r=Object.entries(t.labels).map(([o,i])=>`${o}=${i}`);return f.jsxs("div",{className:"flex items-start gap-2 rounded-md px-3 py-2 text-[13px]","data-testid":"provisioning-worktree__card","data-status":t.status,"data-branch":t.branch,children:[n?f.jsx(Mc,{className:"mt-0.5 size-3.5 shrink-0 text-destructive","aria-hidden":!0}):f.jsx(H2,{className:"mt-0.5 size-3.5 shrink-0 animate-spin","aria-hidden":!0}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsx("div",{className:"truncate font-medium",children:t.branch}),f.jsxs("div",{className:n?"text-destructive":"text-foreground/60","data-testid":"provisioning-worktree__status",children:[Xxn[t.status],r.length>0&&!n?` (${r.join(", ")})`:""]}),n&&t.error&&f.jsx("div",{className:"break-words text-xs text-destructive","data-testid":"provisioning-worktree__error",children:t.error})]}),f.jsx("button",{type:"button",className:"shrink-0 rounded p-1 text-foreground/60 hover:bg-primary/10 hover:text-foreground","aria-label":n?`Dismiss ${t.branch}`:`Cancel ${t.branch}`,"data-testid":"provisioning-worktree__cancel",disabled:e.isPending,onClick:()=>e.mutate(t.id),children:f.jsx(pa,{className:"size-3.5","aria-hidden":!0})})]})}function $Be({collapsed:t,className:e,children:n}){return f.jsx("div",{className:`grid transition-[grid-template-rows] duration-200 ease-out motion-reduce:transition-none ${t?"grid-rows-[0fr]":"grid-rows-[1fr]"}`,children:f.jsx("div",{className:`overflow-hidden ${e??""}`,inert:t,children:n})})}function Jxn({repo:t,statuses:e,branchStatuses:n,setupStatuses:r,removeRepo:o,onPromoteToGit:i,setWorktreeDialog:s,onShowDeleteDialog:a,focusedIndex:l,worktreeIndexStart:c,collapsed:u,onToggleCollapse:d,hasPinnedSiblings:h,onTogglePinned:p,hosts:g}){const _=t.kind==="plain",{attributes:x,listeners:y,setNodeRef:k,transform:O,transition:C,isDragging:A}=kee({id:t.name}),E=Gs(),P=typeof Rr().promoteRepoToGit=="function",{active:L}=nN(),D={transform:du.Translate.toString(O),transition:L?C:void 0,opacity:A?.5:void 0},I=b_n().filter(se=>se.repo===t.name),z=Cn(se=>se.openWorktree),Y=Cn(se=>se.clearNeedsAttention),Q=_?t.worktrees[0].name:"",H=_?jr(t.name,Q,t.worktrees[0].hostId):"",N=Cn(se=>_&&se.activeWorktreeId===H),V=_?E.getWorktreeHref?.(H):void 0,G=_?e.get(H)?.agent:void 0,K=_&&c===l,q=Cn(se=>se.activeWorktreeId),Z=v.useMemo(()=>!_&&t.worktrees.some(se=>jr(t.name,se.name,se.hostId)===q),[_,t.worktrees,t.name,q]),U=()=>{Y(H),V&&E.navigate?E.navigate(V):V||z(H)};let B=c;const ee=_?`group flex items-center justify-between mb-0.5 rounded-md pl-1 pr-1 py-1.5 min-w-0 overflow-hidden cursor-pointer select-none touch-pan-y transition-colors hover:bg-accent/50 [@media(pointer:coarse)]:min-h-11 [@media(pointer:coarse)]:py-2.5 ${N?"bg-primary/15 hover:bg-primary/15":K?"bg-accent":""}`:"group flex items-center justify-between mb-0.5 pl-1 pr-0 rounded select-none touch-pan-y transition-colors hover:bg-accent/50 [@media(pointer:coarse)]:min-h-11",te=se=>{const{Item:ae}=se;return f.jsxs(f.Fragment,{children:[!_&&f.jsxs(ae,{"data-testid":"repo-list__action--add-worktree",onClick:()=>s(t.name),children:[f.jsx(wl,{}),"Add worktree"]}),_&&P&&f.jsxs(ae,{onClick:()=>i(t.name),children:[f.jsx(ub,{}),"Promote to git…"]}),E.copyPath&&f.jsxs(ae,{onClick:()=>navigator.clipboard.writeText(t.path),children:[f.jsx(q7e,{}),"Copy path"]}),E.revealInFinder&&f.jsxs(ae,{onClick:()=>E.revealInFinder(t.path),children:[f.jsx(ld,{}),"Open in Finder"]}),f.jsxs(ae,{onClick:()=>o(t.name),children:[f.jsx(Rot,{}),"Remove from list"]})]})};return f.jsxs("div",{ref:k,style:D,className:"min-w-0 px-2",children:[f.jsxs(J0,{children:[f.jsx(e1,{asChild:!0,children:f.jsxs("div",{className:ee,"data-testid":`repo-list__repo-header--${t.name}`,onClick:()=>_?U():d(t.name),children:[f.jsxs("div",{className:"flex items-center gap-2 min-w-0 cursor-grab",...x,...y,children:[_?G&&pye(G.status)?f.jsx(_G,{agent:G,tabStatuses:e.get(H)?.tabStatuses}):f.jsx(yC,{className:"size-4 shrink-0 text-muted-foreground"}):f.jsx(m8,{name:t.name,avatar:t.avatar,className:"size-4",testId:`repo-list__repo-avatar--${t.name}`}),f.jsxs(Or,{children:[f.jsx(Sr,{asChild:!0,children:f.jsx("h2",{className:`text-[13px] truncate ${_&&N||Z?"font-bold text-foreground":"font-semibold text-foreground/90"}`,children:t.name})}),f.jsx(Cr,{side:"right",children:t.name})]})]}),f.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100 [@media(pointer:coarse)]:hidden",children:[!_&&f.jsxs(Us,{children:[f.jsxs(Or,{children:[f.jsx(Sr,{asChild:!0,children:f.jsx(Ws,{asChild:!0,children:f.jsx(Ce,{variant:"ghost",size:"icon-xs","aria-label":"Repo actions","data-testid":`repo-list__repo-menu-trigger--${t.name}`,onPointerDown:se=>se.stopPropagation(),onClick:se=>se.stopPropagation(),children:f.jsx(mM,{})})})}),f.jsx(Cr,{children:"More actions"})]}),f.jsx(Zs,{align:"end",children:te({Item:dr})})]}),!_&&f.jsxs(Or,{children:[f.jsx(Sr,{asChild:!0,children:f.jsx(Ce,{variant:"ghost",size:"icon-xs",onPointerDown:se=>se.stopPropagation(),onClick:se=>{se.stopPropagation(),s(t.name)},children:f.jsx(wl,{})})}),f.jsx(Cr,{children:"Add worktree"})]})]})]})}),f.jsx(t1,{children:te({Item:Qn})})]}),!_&&f.jsxs($Be,{collapsed:u,className:"flex flex-col gap-0.5 ml-3",children:[I.map(se=>f.jsx(Kxn,{request:se},se.id)),f.jsx(Vxn,{repo:t,hosts:g}),t.worktrees.length===0?h||I.length>0?null:f.jsx("p",{className:"text-[13px] text-foreground/60 px-4 py-2",children:"No worktrees yet"}):t.worktrees.map(se=>{const ae=jr(t.name,se.name,se.hostId),he=B++;return f.jsx(cBe,{dndId:`wt:${ae}`,data:{kind:"wt",worktreeId:ae,repoName:t.name,hostId:bh(se)},children:f.jsx(IBe,{worktree:se,repoName:t.name,defaultBranch:t.defaultBranch,repoKind:t.kind,status:e.get(ae),branchStatus:n.get(ae),setupStatus:r.get(ae),isFocused:!u&&he===l,onShowDeleteDialog:a,onTogglePinned:p,hostTag:h9n(t)?zE(bh(se),g):void 0,allowedHostIds:t.allowedHostIds})},se.name)})]})]})}function C$(t,e){for(const n of t)for(const r of n.worktrees)if(jr(n.name,r.name,r.hostId)===e)return{wt:r,repo:n}}function eyn({groupFilter:t}){const{repos:e}=xs(),n=rX(),r=oX(),o=Cn(Ie=>Ie.statuses),i=Cn(Ie=>Ie.branchStatuses),s=Cn(Ie=>Ie.setupStatuses),a=Cn(Ie=>Ie.openWorktree),l=Cn(Ie=>Ie.activeWorktreeId),c=x_n(),u=y_n(),d=w_n(),h=Rn(),p=k_n(),g=oBe(),[_,x]=v.useState(null),[y,k]=v.useState(),O=v.useCallback(Ie=>{x(Ie),Ie===null&&k(void 0)},[]),[C,A]=v.useState(null),[E,M]=v.useState(null),[P,L]=v.useState(null),[D,I]=v.useState(-1),z=Hye(),[Y,Q]=v.useState(null),[H,N]=v.useState(null),[V,G]=v.useState(0),[K,q]=v.useState(null),[Z,U]=v.useState({overId:null,zone:null}),[B,ee]=v.useState(null),te=v.useRef(null),se=v.useRef(!1),ae=Lf(nAe),he=Lf(rAe),fe=Lf(oAe),be=Lf(S$e),me=n.length>0,le=me?"groups":"repo",[Be,Xe]=v.useState(null),[ot,Qe]=v.useState(null),[lt,bt]=v.useState(null),ve=It({queryKey:["hosts.list"],queryFn:async()=>(await Se.workers.list.query()).hosts}),{toggle:Te}=rBe(),pe=v.useMemo(()=>y$e(e),[e]),Ne=v.useMemo(()=>t?pe.map(Ie=>({...Ie,worktrees:Ie.worktrees.filter(gt=>gt.groupId===t)})).filter(Ie=>Ie.worktrees.length>0):pe,[pe,t]),$e=v.useMemo(()=>w$e(Ne),[Ne]),De=v.useMemo(()=>c9n($e,be.isCollapsed),[$e,be]),ct=Zj(Gf(Xj,{activationConstraint:{distance:8}}),Gf(_ee,{activationConstraint:{delay:250,tolerance:5}})),{displayRepos:ue,reposWithPinned:Pe}=v.useMemo(()=>{const Ie=zQ(Ne,$e);return{displayRepos:Ie.repos,reposWithPinned:Ie.reposWithPinned}},[Ne,$e]),Ee=fe.isCollapsed(w9),Le=$e.pins.length>0,et=v.useMemo(()=>Le&&!Ee?De.map(Ie=>Ie.entry.worktreeId):[],[Le,Ee,De]),kt=et.length,tn=v.useMemo(()=>zQ(Ne,$e).repos,[Ne,$e]),Kt=v.useMemo(()=>me?d9n({repos:tn,allRepos:pe,groups:n,filter:t,isGroupCollapsed:he.isCollapsed,isOriginCollapsed:be.isCollapsed}):[],[me,tn,pe,n,t,he,be]),Dn=v.useMemo(()=>S2(tn),[tn]),Qt=v.useMemo(()=>S2(pe),[pe]),Ve=v.useMemo(()=>{if(me)return[...et,...p9n(Kt)];const Ie=ue.flatMap(gt=>ae.isCollapsed(gt.name)?[]:gt.worktrees.map(At=>jr(gt.name,At.name,At.hostId)));return[...et,...Ie]},[me,Kt,ue,ae,et]),Ct=v.useMemo(()=>{const Ie=new Map;let gt=kt;for(const At of ue)Ie.set(At.name,gt),ae.isCollapsed(At.name)||(gt+=At.worktrees.length);return Ie},[ue,ae,kt]);v.useEffect(()=>{if(!se.current)if(l){const Ie=Ve.indexOf(l);I(Ie)}else I(-1)},[l,Ve]);const Mt=v.useRef(null),Ye=v.useRef(!1),Pt=v.useRef(le);v.useEffect(()=>{if(!l){Mt.current=null,Ye.current=!1;return}const Ie=$e.ids.has(l);if(!(Mt.current===l&&Ye.current===Ie&&Pt.current===le)){if(Pt.current=le,Mt.current=l,Ye.current=Ie,Ie){fe.expand(w9);let gt=l;const At=new Set;for(;gt&&!At.has(gt);){At.add(gt);const qt=C$(e,gt)?.wt.origin?.worktreeId;qt&&$e.ids.has(qt)&&be.expand(qt),gt=qt&&$e.ids.has(qt)?qt:void 0}se.current=!1;return}if(me){const gt=C$(e,l);gt?.wt.groupId&&he.expand(gt.wt.groupId);let At=l;const qt=new Set;for(;At&&!qt.has(At);){qt.add(At);const yr=C$(e,At);if(!yr)break;const Mn=yr.wt.origin;Mn&&!Mn.removed&&be.expand(Mn.worktreeId),At=Mn&&!Mn.removed?Mn.worktreeId:void 0}se.current=!1;return}for(const gt of ue)if(gt.worktrees.some(qt=>jr(gt.name,qt.name,qt.hostId)===l)){ae.expand(gt.name),se.current=!1;return}}},[l,me,le,e,be,ue,he,ae,fe,$e]);const Dt=e.length>0;v.useEffect(()=>{Dt&&te.current?.focus({preventScroll:!0})},[Dt]);const Ut=Gs(),kn=v.useCallback(Ie=>{LBe(Ie);const gt=Ut.getWorktreeHref?.(Ie);gt&&Ut.navigate?Ut.navigate(gt):a(Ie)},[Ut,a]);function jt(Ie){if(Ve.length!==0){if(Ie.key==="ArrowDown")Ie.preventDefault(),se.current=!0,I(gt=>gt<Ve.length-1?gt+1:gt),te.current?.focus({preventScroll:!0});else if(Ie.key==="ArrowUp")Ie.preventDefault(),se.current=!0,I(gt=>gt>0?gt-1:gt),te.current?.focus({preventScroll:!0});else if(Ie.key==="Enter"){Ie.preventDefault();const gt=Ve[D];gt!==void 0&&!Bye(z.getState(),gt)&&(se.current=!1,kn(gt))}}}const pn=v.useMemo(()=>ue.map(Ie=>Ie.name),[ue]),ke=v.useCallback(Ie=>{const gt=Ie.active.data.current,At=Mn=>Mn.data.current?.kind;if(!gt?.kind)return qE({...Ie,droppableContainers:Ie.droppableContainers.filter(Mn=>!At(Mn))});const qt=Ie.droppableContainers.filter(Mn=>{const Kr=At(Mn);return gt.kind==="pin"?Kr==="pin":gt.kind==="groupmove"?Kr==="group"&&Mn.data.current.groupId!=null:me?Kr==="wt"||Kr==="pin"||Kr==="group":Kr==="wt"&&Mn.data.current?.repoName===gt.repoName}),yr=K9n({...Ie,droppableContainers:qt});return yr.length>0?yr:qE({...Ie,droppableContainers:qt})},[me]);function Ke(Ie){const gt=Ie.active.data.current;if(gt?.kind==="groupmove"){q(n.find(At=>At.id===gt.groupId)??null);return}if(gt?.kind){G(gt.inset??0);const At=[...Dn,...S2(pe)].find(qt=>qt.worktreeId===gt.worktreeId);N(At??null);return}Q(Ie.active.id)}function dt(Ie){const{active:gt,over:At,activatorEvent:qt,delta:yr}=Ie;if(!At)return null;const Mn=At.data.current?.kind,Kr=gt.data.current?.kind;if(Mn==="group"&&Kr!=="groupmove"||Mn==="pin"&&Kr==="wt")return"into";const as=qt,Xs=as.clientY??as.touches?.[0]?.clientY??as.changedTouches?.[0]?.clientY;if(Xs===void 0)return null;const Zt=me&&Kr==="wt"&&Mn==="wt";return C_n(At.rect,Xs+yr.y,Zt)}function sn(Ie){const gt=Ie.over?String(Ie.over.id):null,At=dt(Ie);U(qt=>qt.overId===gt&&qt.zone===At?qt:{overId:gt,zone:At})}function Yt(Ie){Ie.type==="reorder"?d.mutate({order:Ie.order,scope:Ie.scope,reparent:Ie.reparent}):Ie.type==="refuse"?ee(Ie.reason):Ie.type==="parent"&&Wt(Ie)}async function Wt(Ie){const gt=Qt.find(At=>At.worktreeId===Ie.worktreeId);if(gt)try{(gt.worktree.origin?.worktreeId??null)!==Ie.origin&&(await Se.worktrees.setOrigin.mutate({...Ie.worktree,origin:Ie.origin}),await h.invalidateQueries({queryKey:Un.repos})),Nt(Ie.worktreeId,Ie.groupId)}catch(At){ee(At instanceof Error?At.message:String(At))}}async function ir(Ie,gt){const At=Qt.find(Mn=>Mn.worktreeId===Ie),qt=At?.worktree.origin?.worktreeId,yr=qt?Qt.find(Mn=>Mn.worktreeId===qt):void 0;if(At&&gt===null&&yr?.worktree.groupId)try{await Se.worktrees.setOrigin.mutate({repo:At.repo.name,name:At.worktree.name,hostId:At.worktree.hostId,origin:null}),await h.invalidateQueries({queryKey:Un.repos})}catch(Mn){ee(Mn instanceof Error?Mn.message:String(Mn));return}Nt(Ie,gt)}function Nt(Ie,gt){const At=Qt.find(Mn=>Mn.worktreeId===Ie);if(!At||(At.worktree.groupId??null)===gt)return;const qt=O$e(Qt,Ie).filter(Mn=>(Mn.worktree.groupId??null)!==gt),yr=n.find(Mn=>Mn.id===gt)??null;qt.length>0?bt({entry:At,group:yr,childCount:qt.length}):r.setWorktreeGroup.mutate({worktreeId:Ie,groupId:gt})}function Xt(Ie){const{active:gt,over:At}=Ie;if(!At)return;const qt=gt.data.current,yr=At.data.current,Mn=dt(Ie);if(!Mn)return;const Kr=qt.worktreeId;if(qt.kind==="pin"){yr.worktreeId&&Yt(E_n($e,Kr,yr.worktreeId,Mn));return}if(qt.kind==="groupmove"){const as=gt.data.current.groupId;if(as&&yr.groupId){const Xs=A_n(n.map(Zt=>Zt.id),as,yr.groupId,Mn);Xs&&r.reorder.mutate({ids:Xs})}return}if(yr.kind==="group"){ir(Kr,yr.groupId??null);return}if(!me){const as=S2(ue.filter(Xs=>Xs.name===qt.repoName));yr.worktreeId&&Yt(T_n(as,Kr,yr.worktreeId,Mn));return}yr.worktreeId&&Yt(M_n(Qt,Kr,yr.worktreeId,Mn))}function dn(Ie){Q(null),N(null),q(null),U({overId:null,zone:null});const{active:gt,over:At}=Ie;if(!At||gt.id===At.id)return;if(gt.data.current?.kind){Xt(Ie);return}const qt=gt.id,yr=At.id,Mn=e.map(Xs=>Xs.name),Kr=Mn.indexOf(qt),as=Mn.indexOf(yr);Kr<0||as<0||u.mutate(oN(Mn,Kr,as))}function Kn(){Q(null),N(null),q(null),U({overId:null,zone:null})}return v.useEffect(()=>{if(!B)return;const Ie=setTimeout(()=>ee(null),8e3);return()=>clearTimeout(Ie)},[B]),e.length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground",children:[f.jsx("p",{className:"text-lg mb-2",children:"No repos registered"}),f.jsx("p",{className:"text-sm",children:"Click the + button to register a folder"})]}):f.jsxs(f.Fragment,{children:[f.jsxs("div",{ref:te,tabIndex:-1,"data-testid":"repo-list__root",onKeyDown:jt,onPointerDown:()=>{se.current=!1},className:"flex flex-col gap-0.5 outline-none min-w-0",children:[B&&f.jsxs("div",{role:"status","data-testid":"repo-list__drop-refused",className:"mx-2 mb-1 flex items-start gap-2 rounded-md border border-warning/40 bg-warning-bg px-2 py-1.5 text-[12px] text-foreground",children:[f.jsx("span",{className:"flex-1",children:B}),f.jsx("button",{type:"button","aria-label":"Dismiss",onClick:()=>ee(null),className:"shrink-0 text-muted-foreground hover:text-foreground",children:"×"})]}),f.jsx(iN.Provider,{value:Z,children:f.jsxs(eN,{sensors:ct,collisionDetection:ke,onDragStart:Ke,onDragMove:sn,onDragEnd:dn,onDragCancel:Kn,children:[Le&&f.jsxs("div",{"data-testid":"repo-list__pinned",children:[f.jsxs("button",{type:"button","data-testid":"repo-list__pinned-header",onClick:()=>fe.toggle(w9),"aria-expanded":!Ee,className:"flex h-9 w-full items-center gap-2 pl-3 pr-4 mb-0.5 text-left transition-colors hover:bg-primary/10",children:[f.jsx(vZ,{className:"size-3.5 -rotate-45 text-muted-foreground"}),f.jsx("span",{className:"text-[13px] font-semibold text-foreground/90",children:"Pinned"}),f.jsx(bo,{className:`ml-auto size-3.5 shrink-0 text-muted-foreground transition-transform ${Ee?"":"rotate-90"}`})]}),f.jsx($Be,{collapsed:Ee,className:"flex flex-col gap-0.5 px-2",children:!Ee&&De.map((Ie,gt)=>f.jsx(zBe,{row:Ie,index:gt,mode:le,originCollapse:be,hosts:ve.data??[],statuses:o,branchStatuses:i,setupStatuses:s,focusedIndex:D,onShowDeleteDialog:M,onTogglePinned:Te},Ie.key))})]},"__pinned"),me?f.jsx(Fxn,{rows:Kt,groupCollapse:he,groupOrder:n.map(Ie=>Ie.id),groupActions:{onRename:Xe,onColor:(Ie,gt)=>r.update.mutate({id:Ie.id,color:gt}),onDelete:Qe,onMove:(Ie,gt)=>{const At=iBe(n.map(qt=>qt.id),Ie.id,gt);At&&r.reorder.mutate({ids:At})},onAddWorktree:Ie=>A({groupId:Ie})},navStart:kt,originCollapse:be,hosts:ve.data??[],statuses:o,branchStatuses:i,setupStatuses:s,focusedIndex:D,onShowDeleteDialog:M,onTogglePinned:Te}):f.jsx(wee,{items:pn,strategy:yee,children:ue.map(Ie=>f.jsx("div",{className:"pt-1 first:pt-0",children:f.jsx(Jxn,{repo:Ie,statuses:o,branchStatuses:i,setupStatuses:s,removeRepo:gt=>c.mutate(gt),onPromoteToGit:L,setWorktreeDialog:O,onShowDeleteDialog:M,focusedIndex:D,worktreeIndexStart:Ct.get(Ie.name)??0,collapsed:ae.isCollapsed(Ie.name),onToggleCollapse:ae.toggle,hasPinnedSiblings:Pe.has(Ie.name),onTogglePinned:Te,hosts:ve.data??[]})},Ie.name))}),f.jsx(o_n,{dropAnimation:null,children:H?f.jsx("div",{"data-testid":"repo-list__drag-overlay",className:"rounded-md shadow-lg",style:{paddingLeft:V},children:f.jsx(DBe,{entry:H,mode:le,isFocused:!1,hosts:ve.data??[],statuses:o,branchStatuses:i,setupStatuses:s,onShowDeleteDialog:M,onTogglePinned:Te})}):K?f.jsxs("div",{"data-testid":"repo-list__group-drag-overlay",className:"flex h-9 items-center gap-2 rounded border bg-background pl-3 pr-4 shadow-lg",children:[f.jsx("span",{className:"size-2.5 shrink-0 rounded-full",style:{backgroundColor:K.color}}),f.jsx("span",{className:"truncate text-[13px] font-semibold text-foreground/90",children:K.name})]}):Y?f.jsxs("div",{className:"flex items-center gap-2 px-1 py-1 bg-background rounded shadow-lg border",children:[f.jsx(m8,{name:Y,avatar:e.find(Ie=>Ie.name===Y)?.avatar,className:"size-3.5"}),f.jsx("span",{className:"text-[13px] font-semibold text-foreground",children:Y})]}):null})]})})]}),f.jsx(M$e,{open:Be!==null,onOpenChange:Ie=>{Ie||Xe(null)},title:"Rename group",submitLabel:"Rename",initialName:Be?.name??"",onSubmit:Ie=>{Be&&r.update.mutate({id:Be.id,name:Ie})}}),f.jsx(P$e,{open:ot!==null,onOpenChange:Ie=>{Ie||Qe(null)},groupName:ot?.name??"",onConfirm:()=>{ot&&r.remove.mutate({id:ot.id})}}),f.jsx(M9n,{open:lt!==null,onOpenChange:Ie=>{Ie||bt(null)},worktreeName:lt?.entry.worktree.name??"",groupName:lt?.group?.name??"Ungrouped",childCount:lt?.childCount??0,onChoose:Ie=>{lt&&r.setWorktreeGroup.mutate({worktreeId:lt.entry.worktreeId,groupId:lt.group?.id??null,withChildren:Ie})}}),f.jsx(P9n,{open:C!==null,onOpenChange:Ie=>{Ie||A(null)},groupName:n.find(Ie=>Ie.id===C?.groupId)?.name??"Ungrouped",repos:e.filter(Ie=>Ie.kind!=="plain").map(Ie=>Ie.name),onPick:Ie=>{k(C?.groupId??null),x(Ie)}}),f.jsx(Gxn,{repoName:_??"",groupId:y,open:_!==null,onOpenChange:Ie=>O(Ie?_:null)}),f.jsx(P_n,{open:E!==null,onOpenChange:Ie=>{Ie||M(null)},onConfirm:()=>{E&&(g.mutate({repo:E.repoName,name:E.name,hostId:E.hostId}),M(null))},branchName:E?.name??"",isUnmerged:E?.isUnmerged??!1,isDirty:E?.isDirty??!1,hasUnpushedCommits:E?.hasUnpushedCommits??!1}),f.jsx(Yxn,{open:P!==null,onOpenChange:Ie=>{Ie||L(null)},onConfirm:()=>{P&&p.mutate(P,{onSettled:()=>L(null)})},repoName:P??""})]})}function tyn({count:t,actions:e,onListClick:n,tall:r,children:o}){return f.jsxs("section",{className:"flex min-h-0 flex-1 flex-col","data-testid":"repos-panel","aria-label":"Repos",children:[f.jsxs("div",{"data-testid":"repos-panel__header",className:Ze("flex shrink-0 items-center justify-between gap-1 pr-2 pl-4",r?"h-12":"h-7"),children:[f.jsxs("div",{className:"flex h-full shrink-0 items-center gap-1 text-[11px] font-semibold tracking-wide text-muted-foreground uppercase",children:[f.jsx("span",{children:"Repos"}),t!==null&&f.jsx("span",{className:"text-[10px] font-medium tabular-nums","data-testid":"repos-panel__count",children:t})]}),e]}),f.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto pb-3","data-testid":"repos-panel__list",onClick:n,children:o})]})}function nyn(){const[t,e]=v.useState(!1);return v.useEffect(()=>{if(!On)return;let n=null,r=!1;return Ho("get_window_fullscreen").then(o=>{r||e(o)}).catch(()=>{}),Qf("window-fullscreen-changed",({payload:o})=>{e(o)}).then(o=>{r?o():n=o}).catch(()=>{}),()=>{r=!0,n?.()}},[]),t}function BBe(){const t=nyn();return On&&!t?"pl-[80px]":"pl-2"}const Mee=v.createContext(null);function ryn(){return v.useContext(Mee)}function HBe(){const t=Rr(),e=Rn(),n=Cn(r=>r.setError);return $s({mutationFn:r=>t.updateSettings(r),onSuccess:(r,o)=>{e.setQueryData(Un.settings,o)},onError:r=>{n(r)}})}function Qh(){const t=Rr(),{data:e,isLoading:n,error:r}=It({queryKey:Un.settings,queryFn:()=>t.getSettings()});return{settings:e??{worktreesDir:null},isLoading:n,error:r?String(r):null}}function oyn(){const t=Cn(e=>e.setError);return $s({mutationFn:()=>Se.terminal.restartDaemon.mutate(),onError:e=>{t(e)}})}function iyn({open:t,onOpenChange:e,onConfirm:n,busy:r}){return f.jsx(nr,{open:t,onOpenChange:o=>!r&&e(o),children:f.jsxs(rr,{className:"sm:max-w-[425px]",onClick:o=>o.stopPropagation(),showCloseButton:!r,children:[f.jsxs(hr,{children:[f.jsx(or,{children:"Restart the terminal service?"}),f.jsx(Nr,{children:"Ends every terminal in Band's terminal service and starts a fresh one. Panes show that the process exited and can be reopened. Sessions from a previous version of Band are kept."})]}),f.jsxs(ii,{children:[f.jsx(Ce,{variant:"ghost",onClick:()=>e(!1),disabled:r,children:"Cancel"}),f.jsx(Ce,{variant:"destructive",onClick:n,disabled:r,children:r?"Restarting…":"Restart"})]})]})})}const syn={installed:"Installed",outdated:"Outdated",not_installed:"Not installed",offline:"Worker offline"};function ayn(){const{hosts:t,isError:e,refresh:n}=cAe(),[r,o]=v.useState(null),[i,s]=v.useState(null),a=async(l,c)=>{o(l),s(null);try{await Se.hooks[c].mutate({hostId:l})}catch(u){s(u instanceof Error?u.message:String(u))}finally{o(null),await n()}};return f.jsxs(_n,{variant:"stacked",label:"Claude Code hooks",description:"Hooks report what Claude Code does in a terminal (working, waiting for an answer, done), so the sidebar and notifications can show it. Chats in Band need no hooks. Remove deletes only Band's entries.",children:[e?f.jsx("p",{role:"alert",className:"text-xs text-muted-foreground","data-testid":"settings__hooks-denied",children:"Managing hooks needs an admin token."}):null,i?f.jsx("p",{role:"alert",className:"text-xs text-destructive","data-testid":"settings__hooks-error",children:i}):null,f.jsx("ul",{className:"divide-y divide-border rounded-md border border-border",children:t.map(l=>{const c=EFt(l),u=r===l.hostId;return f.jsxs("li",{"data-testid":"settings__hooks-host","data-host-id":l.hostId,"data-state":c,className:"flex items-center justify-between gap-2 px-3 py-2 text-sm",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsx("div",{className:"truncate font-medium",children:l.name}),f.jsxs("div",{className:"text-xs text-muted-foreground","data-testid":"settings__hooks-state",children:[syn[c],l.online&&!l.hasClaudeCode?" · Claude Code not found":"",l.error?` · ${l.error}`:""]})]}),f.jsxs("div",{className:"flex shrink-0 gap-1",children:[f.jsx(Ce,{size:"sm",variant:"outline",disabled:!l.online||u,"data-testid":"settings__hooks-install",onClick:()=>a(l.hostId,"install"),children:c==="installed"||c==="outdated"?"Reinstall":"Install"}),f.jsx(Ce,{size:"sm",variant:"ghost",disabled:!l.online||u||c==="not_installed","data-testid":"settings__hooks-remove",onClick:()=>a(l.hostId,"remove"),children:"Remove"})]})]},l.hostId)})})]})}const FBe={"claude-code":[{id:"setup-token",label:"Setup token (claude setup-token)",secretVar:"CLAUDE_CODE_OAUTH_TOKEN",clears:["ANTHROPIC_API_KEY","ANTHROPIC_AUTH_TOKEN"],note:"A setup token cannot use Remote Control or claude.ai connectors."},{id:"api-key",label:"Anthropic API key",secretVar:"ANTHROPIC_API_KEY",clears:["CLAUDE_CODE_OAUTH_TOKEN","ANTHROPIC_AUTH_TOKEN"]}],codex:[{id:"api-key",label:"OpenAI API key",secretVar:"OPENAI_API_KEY",alsoSecretVars:["CODEX_API_KEY"],fixedEnv:{DEFAULT_AUTH_REQUEST:'{"methodId":"api-key"}'},clears:[]}],opencode:[{id:"anthropic-api-key",label:"Anthropic API key",secretVar:"ANTHROPIC_API_KEY",clears:[]},{id:"openai-api-key",label:"OpenAI API key",secretVar:"OPENAI_API_KEY",clears:[]},{id:"openrouter-api-key",label:"OpenRouter API key",secretVar:"OPENROUTER_API_KEY",clears:[]},{id:"gemini-api-key",label:"Gemini API key",secretVar:"GEMINI_API_KEY",clears:[]}],"gemini-cli":[{id:"api-key",label:"Gemini API key",secretVar:"GEMINI_API_KEY",clears:["GOOGLE_API_KEY"]}],"cursor-cli":[{id:"api-key",label:"Cursor API key",secretVar:"CURSOR_API_KEY",clears:[]}],amp:[{id:"api-key",label:"Amp API key",secretVar:"AMP_API_KEY",clears:[]}],copilot:[{id:"token",label:"GitHub token",secretVar:"COPILOT_GITHUB_TOKEN",clears:[]}]};function qBe(t){return FBe[t]??[]}new Set(Object.values(FBe).flatMap(t=>t.flatMap(e=>[e.secretVar,...e.alsoSecretVars??[]])));const Zx=t=>t instanceof Error?t.message:String(t);function tf({title:t,description:e,from:n,testId:r,children:o}){return f.jsxs("section",{className:"overflow-hidden rounded-xl border border-border","data-testid":r,"aria-label":t,children:[f.jsxs("header",{className:"flex items-baseline justify-between gap-3 border-border border-b px-4 py-3",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsx("h2",{className:"text-sm font-semibold",children:t}),e?f.jsx("p",{className:"text-xs text-muted-foreground",children:e}):null]}),n?f.jsx("span",{className:"shrink-0 whitespace-nowrap text-[11px] text-muted-foreground",children:n}):null]}),f.jsx("div",{className:"[&>*+*]:border-border [&>*+*]:border-t",children:o})]})}function Fc({label:t,description:e,htmlFor:n,readOnly:r,testId:o,data:i,children:s}){return f.jsxs("div",{className:Ze("grid grid-cols-1 items-center gap-2 px-4 py-3 sm:grid-cols-[220px_1fr] sm:gap-4",r&&"bg-muted/40"),"data-testid":o,...i,children:[f.jsxs("div",{className:"min-w-0",children:[n?f.jsx("label",{htmlFor:n,className:"block text-[13px] font-semibold",children:t}):f.jsx("div",{className:"text-[13px] font-semibold",children:t}),e?f.jsx("div",{className:"text-xs text-muted-foreground",children:e}):null]}),f.jsx("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:s})]})}const lyn={neutral:"bg-muted text-foreground",ok:"bg-success-bg text-success",warn:"bg-warning-bg text-warning",scoped:"bg-info-bg text-info"};function qc({tone:t="neutral",testId:e,children:n}){return f.jsx("span",{className:Ze("inline-flex items-center whitespace-nowrap rounded-full px-2 py-px text-xs",lyn[t]),"data-testid":e,"data-tone":t,children:n})}function W0({children:t,testId:e}){return f.jsx("span",{className:"text-xs text-muted-foreground","data-testid":e,children:t})}const VBe="h-8 min-w-48 rounded-md border border-border bg-background px-2 text-sm disabled:opacity-60",Pee=["agentLogins.list"];function QBe(){return It({queryKey:Pee,queryFn:()=>Se.agentLogins.list.query(),retry:!1})}const aN=t=>t instanceof Error?t.message:String(t);function UBe(){const t=It({queryKey:["models.listAll"],queryFn:()=>Se.models.listAll.query()}),e=new Set,n=[];for(const r of t.data?.agents??[])e.has(r.agentType)||qBe(r.agentType).length===0||(e.add(r.agentType),n.push({type:r.agentType,label:r.agentLabel}));return n}function cyn({agentType:t,onAdded:e}){const n=qBe(t),[r,o]=v.useState(n[0]?.id??""),[i,s]=v.useState(""),[a,l]=v.useState(""),[c,u]=v.useState(!1),[d,h]=v.useState(null),p=n.find(_=>_.id===r),g=async()=>{u(!0),h(null);try{await Se.agentLogins.create.mutate({agentType:t,kind:r,label:i.trim(),secret:a}),s(""),l(""),e()}catch(_){h(aN(_))}finally{u(!1)}};return f.jsxs("div",{className:"space-y-2","data-testid":"settings-agent-logins__add",children:[f.jsx("select",{"aria-label":`Login kind for ${t}`,value:r,onChange:_=>o(_.target.value),className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm",children:n.map(_=>f.jsx("option",{value:_.id,children:_.label},_.id))}),t==="codex"?f.jsx("p",{className:"text-xs text-muted-foreground","data-testid":"settings-agent-logins__codex-note",children:"Used only on workers with no Codex login of their own. Isolating CODEX_HOME comes later."}):null,p?.note?f.jsx("p",{className:"text-xs text-muted-foreground","data-testid":"settings-agent-logins__note",children:p.note}):null,f.jsx(Sn,{"aria-label":`Login label for ${t}`,placeholder:"Label, such as Team subscription",value:i,onChange:_=>s(_.target.value),className:"h-8 text-sm"}),f.jsx(Sn,{"aria-label":`Login secret for ${t}`,type:"password",autoComplete:"off",placeholder:"Secret",value:a,onChange:_=>l(_.target.value),className:"h-8 text-sm"}),f.jsx(Ce,{type:"button",size:"sm","data-testid":"settings-agent-logins__add-submit",disabled:c||i.trim()===""||a==="",onClick:()=>{g()},children:"Add login"}),d?f.jsx("p",{role:"alert",className:"text-xs text-destructive","data-testid":"settings-agent-logins__error",children:d}):null]})}function uyn({login:t,onChanged:e}){const[n,r]=v.useState(!1),[o,i]=v.useState(null),s=async()=>{i(null);try{await Se.agentLogins.remove.mutate({id:t.id}),e()}catch(a){i(aN(a))}};return f.jsxs("li",{className:"flex items-center justify-between gap-2 px-3 py-2 text-sm","data-testid":"settings-agent-logins__login","data-login-id":t.id,children:[f.jsxs("div",{className:"min-w-0",children:[f.jsx("div",{className:"truncate","data-testid":"settings-agent-logins__login-label",children:t.label}),f.jsxs("div",{className:"text-xs text-muted-foreground",children:[t.kindLabel," · ",t.envVar,t.missingSecret?f.jsxs("span",{className:"text-destructive","data-testid":"settings-agent-logins__missing",children:[" ","· missing secret"]}):null]}),o?f.jsx("p",{role:"alert",className:"text-xs text-destructive",children:o}):null]}),n?f.jsxs("div",{className:"flex shrink-0 gap-2",children:[f.jsx(Ce,{type:"button",size:"sm",variant:"outline","data-testid":"settings-agent-logins__remove-confirm",onClick:()=>{s()},children:"Confirm remove"}),f.jsx(Ce,{type:"button",size:"sm",variant:"ghost",onClick:()=>r(!1),children:"Cancel"})]}):f.jsx(Ce,{type:"button",size:"sm",variant:"outline",className:"shrink-0","aria-label":`Remove login ${t.label}`,"data-testid":"settings-agent-logins__remove",onClick:()=>r(!0),children:"Remove"})]})}function dyn(){const t=Rn(),e=QBe(),n=UBe(),[r,o]=v.useState(null),i=()=>t.invalidateQueries({queryKey:Pee});if(e.isError)return f.jsx("p",{role:"alert",className:"text-xs text-muted-foreground","data-testid":"settings-agent-logins__denied",children:"Managing agent logins needs an admin token."});const s=async(a,l)=>{o(null);try{await Se.agentLogins.setDefault.mutate({agentType:a,loginId:l||null}),await i()}catch(c){o(aN(c))}};return f.jsxs(f.Fragment,{children:[n.map(a=>{const l=(e.data?.logins??[]).filter(u=>u.agentType===a.type),c=e.data?.defaults[a.type]??"";return f.jsx(_n,{variant:"stacked",label:a.label,description:"With no default, the agent uses the machine's own login.",children:f.jsxs("div",{className:"space-y-3","data-testid":"settings-agent-logins__agent","data-agent":a.type,children:[l.length>0?f.jsx("ul",{className:"divide-y divide-border rounded-md border border-border",children:l.map(u=>f.jsx(uyn,{login:u,onChanged:()=>{i()}},u.id))}):null,f.jsxs("select",{"aria-label":`Default login for ${a.label}`,"data-testid":"settings-agent-logins__default",value:c,onChange:u=>{s(a.type,u.target.value)},className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm",children:[f.jsx("option",{value:"",children:"The machine's own login"}),l.map(u=>f.jsx("option",{value:u.id,children:u.label},u.id))]}),f.jsx(cyn,{agentType:a.type,onAdded:()=>{i()}})]})},a.type)}),r?f.jsx("p",{role:"alert",className:"text-xs text-destructive",children:r}):null]})}function fyn({repoName:t}){const e=Rn(),n=QBe(),r=UBe(),[o,i]=v.useState(null),[s,a]=v.useState(!1),l=n.data;if(!l)return f.jsx("p",{className:"px-4 py-3 text-xs text-muted-foreground","data-testid":"settings-repo__logins-none",children:n.isError?"Changing logins needs an admin token.":"Loading…"});if(r.length===0)return f.jsx("p",{className:"px-4 py-3 text-xs text-muted-foreground","data-testid":"settings-repo__logins-none",children:"No coding agent that takes a login is set up. Enable one in Coding Agents."});const c=async(u,d)=>{i(null),a(!0);try{await Se.agentLogins.setRepoOverride.mutate({agentType:u,repo:t,loginId:d||null}),await e.invalidateQueries({queryKey:Pee})}catch(h){i(aN(h))}finally{a(!1)}};return f.jsxs(f.Fragment,{children:[r.map(u=>{const d=l.logins.filter(_=>_.agentType===u.type),h=l.repoOverrides.find(_=>_.agentType===u.type&&_.repo===t)?.loginId??"",p=l.logins.find(_=>_.id===l.defaults[u.type]),g=`settings-repo-${t}-login-${u.type}`;return d.length===0?f.jsx(Fc,{label:u.label,description:"No logins yet.",testId:"settings-repo__login-row",data:{"data-agent":u.type},children:f.jsx(W0,{children:"Add one in Agent logins"})},u.type):f.jsxs(Fc,{htmlFor:g,label:u.label,description:`Default: ${p?.label??"none (the machine's own login)"}.`,testId:"settings-repo__login-row",data:{"data-agent":u.type},children:[f.jsxs("select",{id:g,"aria-label":`${u.label} login for ${t}`,"data-testid":"settings-repo__login-override","data-agent":u.type,"data-repo":t,value:h,disabled:s,onChange:_=>{c(u.type,_.target.value)},className:VBe,children:[f.jsx("option",{value:"",children:"Use the default"}),d.map(_=>f.jsx("option",{value:_.id,children:_.label},_.id))]}),h?f.jsx(qc,{tone:"scoped",testId:"settings-repo__login-override-chip",children:"override"}):null]},u.type)}),o?f.jsx("p",{role:"alert",className:"px-4 py-2 text-xs text-destructive",children:o}):null]})}const WBe=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i;function eU(t){const e=WBe.exec(t.trim());if(!e)return null;let n=e[1];return n.length===3&&(n=n.split("").map(r=>r+r).join("")),{r:Number.parseInt(n.slice(0,2),16),g:Number.parseInt(n.slice(2,4),16),b:Number.parseInt(n.slice(4,6),16)}}function hyn(t){return WBe.test(t.trim())}function jn({r:t,g:e,b:n}){const r=o=>Math.round(Math.min(255,Math.max(0,o))).toString(16).padStart(2,"0");return`#${r(t)}${r(e)}${r(n)}`}function ZBe(t){const e=eU(t);return e?jn(e):null}function g6(t){const e=t/255;return e<=.04045?e/12.92:((e+.055)/1.055)**2.4}function A$(t){return(t<=.0031308?t*12.92:1.055*t**.4166666666666667-.055)*255}function ZE(t){return .2126*g6(t.r)+.7152*g6(t.g)+.0722*g6(t.b)}function v6(t,e){const n=ZE(t),r=ZE(e),o=Math.max(n,r),i=Math.min(n,r);return(o+.05)/(i+.05)}function Epe({r:t,g:e,b:n}){const r=g6(t),o=g6(e),i=g6(n),s=Math.cbrt(.4122214708*r+.5363325363*o+.0514459929*i),a=Math.cbrt(.2119034982*r+.6806995451*o+.1073969566*i),l=Math.cbrt(.0883024619*r+.2817188376*o+.6299787005*i);return{l:.2104542553*s+.793617785*a-.0040720468*l,a:1.9779984951*s-2.428592205*a+.4505937099*l,b:.0259040371*s+.7827717662*a-.808675766*l}}function pyn({l:t,a:e,b:n}){const r=t+.3963377774*e+.2158037573*n,o=t-.1055613458*e-.0638541728*n,i=t-.0894841775*e-1.291485548*n,s=r**3,a=o**3,l=i**3;return{r:A$(4.0767416621*s-3.3077115913*a+.2309699292*l),g:A$(-1.2684380046*s+2.6097574011*a-.3413193965*l),b:A$(-.0041960863*s-.7034186147*a+1.707614701*l)}}function GE(t,e,n){const r=Epe(t),o=Epe(e);return pyn({l:r.l+(o.l-r.l)*n,a:r.a+(o.a-r.a)*n,b:r.b+(o.b-r.b)*n})}const YE={r:255,g:255,b:255},G9={r:0,g:0,b:0};function u3(t,e,n){const r=Array.isArray(e)?e:[e],o=c=>Math.min(...r.map(u=>v6(c,u)));if(o(t)>=n)return t;const s=r.reduce((c,u)=>c+ZE(u),0)/r.length>.4?G9:YE;let a=t;for(let c=1;c<=20;c++){const u=GE(t,s,c/20);if(a=u,o(u)>=n)return u}const l=s===G9?YE:G9;return o(l)>o(a)?l:a}function hf(t){return v6(YE,t)>=v6(G9,t)?YE:G9}function xf(t,e){return`rgba(${Math.round(t.r)}, ${Math.round(t.g)}, ${Math.round(t.b)}, ${e})`}function GBe(t){return ZE(t)<.18}const I5=4.6;function Aa(t,e){return eU(t)??eU(e)}function myn(t){const e=Aa(t.background,"#1e1e1e"),n=GBe(e),r=u3(Aa(t.foreground,"#e8e8e8"),e,I5),o=Aa(t.accent,"#3b82f6"),i=d=>GE(e,r,d);let s=i(.07),a=n?i(.1):e,l=r;for(let d=1;d>=0&&(s=i(.07*d),a=n?i(.1*d):e,l=u3(GE(r,e,.4),[e,s,a],I5),!(Math.min(v6(l,e),v6(l,s),v6(l,a))>=I5));d-=.1);const c=u3(o,[e,a],I5),u=hf(o);return{"--background":jn(e),"--foreground":jn(r),"--card":jn(i(.02)),"--card-foreground":jn(r),"--popover":jn(a),"--popover-foreground":jn(r),"--primary":jn(o),"--primary-foreground":jn(u),"--secondary":jn(s),"--secondary-foreground":jn(r),"--muted":jn(s),"--muted-foreground":jn(l),"--accent":jn(i(.09)),"--accent-foreground":jn(r),"--sidebar":jn(i(.04)),"--border":jn(i(n?.18:.14)),"--input":jn(i(.12)),"--ring":jn(i(.4)),"--highlight":jn(c),"--link":jn(c),"--terminal-background":jn(e),"--terminal-foreground":jn(r),"--terminal-selection":xf(r,n?.2:.15),"--editor-active-line":xf(r,.03)}}function gyn(t,e,n){const r=Aa(e,"#1e1e1e"),o=GBe(r),i=u3(Aa(n,"#e8e8e8"),r,I5),s=k=>u3(Aa(k,"#888888"),r,I5),a=k=>u3(Aa(k,"#888888"),r,3),l=s(t.green),c=s(t.yellow),u=s(t.red),d=s(t.blue),h=s(t.magenta),p=s(t.orange),g={"--success":jn(l),"--warning":jn(c),"--danger":jn(u),"--info":jn(d),"--merged":jn(h),"--success-foreground":jn(hf(l)),"--warning-foreground":jn(hf(c)),"--danger-foreground":jn(hf(u)),"--info-foreground":jn(hf(d)),"--merged-foreground":jn(hf(h)),"--destructive":jn(u),"--destructive-foreground":jn(hf(u)),"--status-foreground":jn(hf(p)),"--diff-added-bg":xf(l,.1),"--diff-removed-bg":xf(u,.1),"--diff-added-marker":xf(l,.8),"--diff-removed-marker":xf(u,.8),"--git-untracked":jn(c),"--git-behind":jn(c),"--git-diverged":jn(p),"--status-working":jn(c),"--status-question":jn(p),"--status-done":jn(l),"--status-failed":jn(u),"--search-match":xf(Aa(t.yellow,"#ffd33d"),.35),"--search-match-current":xf(Aa(t.orange,"#f97316"),.8)},_=k=>o?GE(Aa(k,"#888888"),i,.25):Aa(k,"#888888");[Aa(t.black,"#000000"),a(t.red),a(t.green),a(t.yellow),a(t.blue),a(t.magenta),a(t.cyan),Aa(t.white,"#e5e5e5"),Aa(t.comment,"#666666"),a(jn(_(t.red))),a(jn(_(t.green))),a(jn(_(t.yellow))),a(jn(_(t.blue))),a(jn(_(t.magenta))),a(jn(_(t.cyan))),i].forEach((k,O)=>{g[`--ansi-${O}`]=jn(k)});const y={comment:u3(Aa(t.comment,"#888888"),r,3),keyword:s(t.magenta),control:s(t.magenta),string:s(t.green),number:p,function:d,variable:u,type:c,property:s(t.cyan),operator:s(t.cyan),tag:u,attribute:p,punctuation:i,constant:p,regexp:s(t.cyan),heading:d,inserted:l,deleted:u,invalid:u};for(const[k,O]of Object.entries(y))g[`--syntax-${k}`]=jn(O);return g}const jee="band",vyn={light:{accent:"#155dfc",background:"#ffffff",foreground:"#0a0a0a"},dark:{accent:"#51a2ff",background:"#1e1e1e",foreground:"#e5e5e5"}},XE=[{id:jee,label:"Band",light:null,dark:null},{id:"github",label:"GitHub",light:{colors:{accent:"#0969da",background:"#ffffff",foreground:"#1f2328"},hues:{red:"#cf222e",green:"#1a7f37",yellow:"#9a6700",blue:"#0969da",magenta:"#8250df",cyan:"#1b7c83",orange:"#bc4c00",comment:"#6e7781",black:"#24292f",white:"#6e7781"}},dark:{colors:{accent:"#2f81f7",background:"#0d1117",foreground:"#e6edf3"},hues:{red:"#ff7b72",green:"#3fb950",yellow:"#d29922",blue:"#58a6ff",magenta:"#bc8cff",cyan:"#39c5cf",orange:"#ffa657",comment:"#8b949e",black:"#484f58",white:"#b1bac4"}}},{id:"solarized",label:"Solarized",light:{colors:{accent:"#268bd2",background:"#fdf6e3",foreground:"#586e75"},hues:{red:"#dc322f",green:"#859900",yellow:"#b58900",blue:"#268bd2",magenta:"#d33682",cyan:"#2aa198",orange:"#cb4b16",comment:"#93a1a1",black:"#073642",white:"#93a1a1"}},dark:{colors:{accent:"#268bd2",background:"#002b36",foreground:"#93a1a1"},hues:{red:"#dc322f",green:"#859900",yellow:"#b58900",blue:"#268bd2",magenta:"#d33682",cyan:"#2aa198",orange:"#cb4b16",comment:"#586e75",black:"#073642",white:"#eee8d5"}}},{id:"nord",label:"Nord",light:{colors:{accent:"#5e81ac",background:"#eceff4",foreground:"#2e3440"},hues:{red:"#bf616a",green:"#7a9a5e",yellow:"#a98a45",blue:"#5e81ac",magenta:"#b48ead",cyan:"#4c8f98",orange:"#c0795a",comment:"#7b88a1",black:"#3b4252",white:"#7b88a1"}},dark:{colors:{accent:"#88c0d0",background:"#2e3440",foreground:"#d8dee9"},hues:{red:"#bf616a",green:"#a3be8c",yellow:"#ebcb8b",blue:"#81a1c1",magenta:"#b48ead",cyan:"#88c0d0",orange:"#d08770",comment:"#616e88",black:"#3b4252",white:"#e5e9f0"}}},{id:"catppuccin",label:"Catppuccin",light:{colors:{accent:"#8839ef",background:"#eff1f5",foreground:"#4c4f69"},hues:{red:"#d20f39",green:"#40a02b",yellow:"#df8e1d",blue:"#1e66f5",magenta:"#ea76cb",cyan:"#179299",orange:"#fe640b",comment:"#8c8fa1",black:"#5c5f77",white:"#acb0be"}},dark:{colors:{accent:"#cba6f7",background:"#1e1e2e",foreground:"#cdd6f4"},hues:{red:"#f38ba8",green:"#a6e3a1",yellow:"#f9e2af",blue:"#89b4fa",magenta:"#f5c2e7",cyan:"#94e2d5",orange:"#fab387",comment:"#6c7086",black:"#45475a",white:"#bac2de"}}}];function Nee(t){return XE.find(e=>e.id===t)??XE[0]}const x_="band-appearance",vg="band-theme",YBe="band-theme-vars",XBe=16,byn=13,KBe={min:11,max:22},JBe={min:9,max:24},_yn='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',Ree=[{id:"system",label:"System",stack:null},{id:"inter",label:"Inter",stack:`Inter, ${_yn}`},{id:"helvetica",label:"Helvetica Neue",stack:'"Helvetica Neue", Helvetica, Arial, sans-serif'},{id:"serif",label:"Georgia",stack:'Georgia, "Times New Roman", serif'}],Lee=[{id:"system",label:"System",stack:null},{id:"sf-mono",label:"SF Mono",stack:'"SF Mono", SFMono-Regular, ui-monospace, Menlo, Monaco, monospace'},{id:"menlo",label:"Menlo",stack:'Menlo, Monaco, "Courier New", monospace'},{id:"jetbrains-mono",label:"JetBrains Mono",stack:'"JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace'},{id:"fira-code",label:"Fira Code",stack:'"Fira Code", ui-monospace, SFMono-Regular, Menlo, monospace'},{id:"consolas",label:"Consolas",stack:'Consolas, "Liberation Mono", Menlo, monospace'}],eHe=["accent","background","foreground"],y_={preset:jee,overrides:{},uiFont:"system",codeFont:"system",uiFontSize:null,codeFontSize:null};function Tpe(t,e){return typeof t!="number"||!Number.isFinite(t)?null:Math.min(e.max,Math.max(e.min,Math.round(t)))}function Mpe(t){if(!t||typeof t!="object")return;const e={};for(const n of eHe){const r=t[n];typeof r=="string"&&hyn(r)&&(e[n]=ZBe(r))}return Object.keys(e).length>0?e:void 0}function Iee(t){if(!t)return y_;try{const e=JSON.parse(t),n=Mpe(e.overrides?.light),r=Mpe(e.overrides?.dark),o=typeof e.preset=="string"?Nee(e.preset).id:jee,i=Ree.some(a=>a.id===e.uiFont)?e.uiFont:"system",s=Lee.some(a=>a.id===e.codeFont)?e.codeFont:"system";return{preset:o,overrides:{...n?{light:n}:{},...r?{dark:r}:{}},uiFont:i,codeFont:s,uiFontSize:Tpe(e.uiFontSize,KBe),codeFontSize:Tpe(e.codeFontSize,JBe)}}catch{return y_}}function KE(t){return JSON.stringify(t)}function xyn(t){return KE(yyn(t))===KE(y_)}function yyn(t){return Iee(KE(t))}function tHe(t,e){const n=Nee(t.preset);return{...(e==="dark"?n.dark:n.light)?.colors??vyn[e],...t.overrides[e]??{}}}function tU(t,e){return Object.keys(t.overrides[e]??{}).length>0}function wyn(t){return tU(t,"light")||tU(t,"dark")}function kyn(t,e){const n=Nee(t.preset),r=e==="dark"?n.dark:n.light,o=tU(t,e);if(!r&&!o)return{};const i=tHe(t,e),s=myn(i);return r&&Object.assign(s,gyn(r.hues,i.background,i.foreground)),s}function Oyn(t){const e={},n=Ree.find(o=>o.id===t.uiFont)?.stack,r=Lee.find(o=>o.id===t.codeFont)?.stack;return n&&(e["--font-ui"]=n),r&&(e["--font-code"]=r),t.uiFontSize&&t.uiFontSize!==XBe&&(e["--font-size-ui"]=`${t.uiFontSize}px`),t.codeFontSize&&(e["--code-font-size"]=`${t.codeFontSize}px`),e}function E$(t,e){return{...kyn(t,e),...Oyn(t)}}function Syn(t){return t==="light"||t==="system"?t:"dark"}const w_="band-theme-changed",tO=new Set;let Ppe=!1;function Cyn(t){return t==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t}function Dee(){try{return Syn(localStorage.getItem(vg))}catch{return"dark"}}function Ayn(){try{return Iee(Hn.getItem(x_))}catch{return y_}}function Eyn(t){const e=document.documentElement.style;if(!Ppe){Ppe=!0;for(let n=0;n<e.length;n++){const r=e.item(n);r.startsWith("--")&&tO.add(r)}}for(const n of tO)n in t||e.removeProperty(n);tO.clear();for(const[n,r]of Object.entries(t))e.setProperty(n,r),tO.add(n)}function Y9(){const t=Dee(),e=Ayn(),n=Cyn(t);document.documentElement.classList.toggle("dark",n==="dark"),Eyn(E$(e,n));try{localStorage.setItem(YBe,JSON.stringify({light:E$(e,"light"),dark:E$(e,"dark")}))}catch{}window.dispatchEvent(new CustomEvent(w_,{detail:{mode:n}}))}function Tyn(t){try{localStorage.setItem(vg,t)}catch{}Y9()}let T$=0;function Myn(){T$||(T$=requestAnimationFrame(()=>{T$=0,Y9()}))}function nHe(t){const e=KE(t);Hn.getItem(x_)!==e&&(Hn.setItem(x_,e),Myn())}function Pyn(){nHe(y_)}function jyn(){Y9();const t=window.matchMedia("(prefers-color-scheme: dark)"),e=()=>{Dee()==="system"&&Y9()},n=r=>{(r.key===null||r.key===vg||r.key===x_)&&Y9()};return t.addEventListener("change",e),window.addEventListener("storage",n),()=>{t.removeEventListener("change",e),window.removeEventListener("storage",n)}}function b6(t){return getComputedStyle(document.documentElement).getPropertyValue(t).trim()}let a2;function jpe(t,e,n="#808080"){if(a2===void 0&&(a2=document.createElement("canvas").getContext("2d",{willReadFrequently:!0})),!a2||!t)return n;a2.clearRect(0,0,1,1),e&&(a2.fillStyle=e,a2.fillRect(0,0,1,1)),a2.fillStyle=t,a2.fillRect(0,0,1,1);const[r=0,o=0,i=0]=a2.getImageData(0,0,1,1).data;return`#${[r,o,i].map(s=>s.toString(16).padStart(2,"0")).join("")}`}function M$(t){return window.addEventListener(w_,t),window.addEventListener("storage",t),()=>{window.removeEventListener(w_,t),window.removeEventListener("storage",t)}}function Nyn(){const t=v.useSyncExternalStore(M$,()=>Hn.getItem(x_),()=>null),e=v.useSyncExternalStore(M$,Dee,()=>"dark"),n=v.useMemo(()=>Iee(t),[t]),r=v.useSyncExternalStore(M$,()=>document.documentElement.classList.contains("dark")?"dark":"light",()=>"dark");return{appearance:n,mode:e,resolvedMode:r}}const Npe={page:"#ffffff",side:"#f4f4f5",line:"#d4d4d8",accent:"#3b82f6"},Rpe={page:"#1e1e1e",side:"#2a2a2c",line:"#4a4a4f",accent:"#60a5fa"};function P$({palette:t}){return f.jsxs("div",{className:"flex h-full w-full",style:{background:t.page},children:[f.jsx("div",{className:"w-1/4",style:{background:t.side}}),f.jsxs("div",{className:"flex flex-1 flex-col gap-1 p-1.5",children:[f.jsx("div",{className:"h-1 w-3/4 rounded-full",style:{background:t.accent}}),f.jsx("div",{className:"h-1 w-full rounded-full",style:{background:t.line}}),f.jsx("div",{className:"h-1 w-2/3 rounded-full",style:{background:t.line}}),f.jsx("div",{className:"mt-auto h-2 rounded-full",style:{background:t.side}})]})]})}function Ryn({mode:t,selected:e}){return f.jsx("div",{className:Ze("h-14 w-20 overflow-hidden rounded-lg border-2 transition-colors",e?"border-highlight":"border-border"),children:t==="system"?f.jsxs("div",{className:"flex h-full",children:[f.jsx("div",{className:"w-1/2 overflow-hidden",children:f.jsx("div",{className:"h-full w-[160%]",children:f.jsx(P$,{palette:Npe})})}),f.jsx("div",{className:"w-1/2 overflow-hidden",children:f.jsx("div",{className:"-ml-[60%] h-full w-[160%]",children:f.jsx(P$,{palette:Rpe})})})]}):f.jsx(P$,{palette:t==="dark"?Rpe:Npe})})}const rHe=v.createContext(!1);function wi({title:t,description:e,action:n,children:r,className:o}){const i=v.useContext(rHe);return f.jsxs("section",{className:Ze("space-y-2",o),children:[(t&&!i||n)&&f.jsxs("div",{className:"flex items-center justify-between gap-2 px-1",children:[t&&!i?f.jsx("h3",{className:"text-sm font-medium text-foreground/90",children:t}):f.jsx("span",{}),n?f.jsx("div",{className:"shrink-0",children:n}):null]}),e&&!i?f.jsx("p",{className:"px-1 text-xs text-muted-foreground",children:e}):null,f.jsx("div",{"data-slot":"settings-section-card","data-testid":"settings__section-card",className:Ze("overflow-hidden rounded-xl border border-border","[&>*+*]:border-t [&>*+*]:border-border"),children:r})]})}const Lyn=[{id:"system",label:"System"},{id:"light",label:"Light"},{id:"dark",label:"Dark"}],nU={accent:"Accent",background:"Background",foreground:"Foreground"},j$="custom";function Iyn({id:t,value:e,onCommit:n}){const[r,o]=v.useState(e.toUpperCase());v.useEffect(()=>o(e.toUpperCase()),[e]);const i=s=>{const a=ZBe(s);a?n(a):o(e.toUpperCase())};return f.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-border px-2 py-1",children:[f.jsx("label",{className:"relative size-5 shrink-0 cursor-pointer overflow-hidden rounded-full border border-border",style:{backgroundColor:e},children:f.jsx("input",{type:"color","aria-label":`${nU[t]} color picker`,"data-testid":`appearance__${t}-picker`,value:e,onChange:s=>n(s.target.value),className:"absolute inset-0 size-full cursor-pointer opacity-0"})}),f.jsx("input",{"aria-label":`${nU[t]} hex`,"data-testid":`appearance__${t}-hex`,value:r,maxLength:7,spellCheck:!1,onChange:s=>o(s.target.value),onBlur:s=>i(s.target.value),onKeyDown:s=>{s.key==="Enter"&&i(s.currentTarget.value)},className:"w-[4.5rem] bg-transparent font-mono text-sm uppercase outline-none"})]})}function Lpe({id:t,value:e,fallback:n,range:r,onCommit:o}){const i=e??n,[s,a]=v.useState(String(i));v.useEffect(()=>a(String(i)),[i]);const l=()=>{const c=Number.parseInt(s,10);if(!Number.isFinite(c)){a(String(i));return}const u=Math.min(r.max,Math.max(r.min,c));a(String(u)),u!==e&&o(u)};return f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Sn,{id:t,"data-testid":t,inputMode:"numeric",value:s,onChange:c=>a(c.target.value),onBlur:l,onKeyDown:c=>{c.key==="Enter"&&l()},className:"h-8 w-16 text-center text-sm"}),f.jsx("span",{className:"text-sm text-muted-foreground",children:"px"})]})}function Dyn({translucentSidebarAvailable:t,translucentSidebar:e,onTranslucentSidebarChange:n}){const{appearance:r,mode:o,resolvedMode:i}=Nyn(),s=tHe(r,i),a=wyn(r),l=h=>nHe({...r,...h}),c=(h,p)=>{l({overrides:{...r.overrides,[i]:{...r.overrides[i]??{},[h]:p}}})},u=h=>{h!==j$&&l({preset:h,overrides:{}})},d=XE.find(h=>h.id===r.preset)?.label??"Band";return f.jsxs("div",{className:"flex flex-col gap-6","data-testid":"appearance",children:[f.jsx(wi,{title:"Visual style",children:f.jsx(_n,{variant:"responsive",label:"Mode",children:f.jsx("div",{className:"flex gap-3",role:"radiogroup","aria-label":"Mode",children:Lyn.map(h=>f.jsxs("button",{type:"button",role:"radio","aria-checked":o===h.id,"aria-label":h.label,"data-testid":`appearance__mode-${h.id}`,onClick:()=>Tyn(h.id),className:"flex flex-col items-center gap-1 rounded-lg focus-visible:outline-2 focus-visible:outline-focus-ring",children:[f.jsx(Ryn,{mode:h.id,selected:o===h.id}),f.jsx("span",{className:Ze("text-xs",o===h.id?"text-foreground":"text-muted-foreground"),children:h.label})]},h.id))})})}),f.jsxs(wi,{children:[f.jsx(_n,{variant:"responsive",label:"Theme",description:`The colors below are for ${i} mode. Switch the mode to edit the other.`,children:f.jsxs(ja,{value:a?j$:r.preset,onValueChange:u,children:[f.jsx(Ra,{className:"h-8 w-full text-sm sm:w-44","aria-label":"Theme","data-testid":"appearance__preset",children:f.jsx(Na,{})}),f.jsxs(La,{children:[a?f.jsxs(ni,{value:j$,disabled:!0,children:["Custom (",d,")"]}):null,XE.map(h=>f.jsx(ni,{value:h.id,children:h.label},h.id))]})]})}),eHe.map(h=>f.jsx(_n,{label:nU[h],children:f.jsx(Iyn,{id:h,value:s[h],onCommit:p=>c(h,p)})},h)),f.jsx(_n,{variant:"responsive",label:"UI font",children:f.jsxs(ja,{value:r.uiFont,onValueChange:h=>l({uiFont:h}),children:[f.jsx(Ra,{className:"h-8 w-full text-sm sm:w-44","aria-label":"UI font","data-testid":"appearance__ui-font",children:f.jsx(Na,{})}),f.jsx(La,{children:Ree.map(h=>f.jsx(ni,{value:h.id,children:h.label},h.id))})]})}),f.jsx(_n,{variant:"responsive",label:"Code font",children:f.jsxs(ja,{value:r.codeFont,onValueChange:h=>l({codeFont:h}),children:[f.jsx(Ra,{className:"h-8 w-full text-sm sm:w-44","aria-label":"Code font","data-testid":"appearance__code-font",children:f.jsx(Na,{})}),f.jsx(La,{children:Lee.map(h=>f.jsx(ni,{value:h.id,children:h.label},h.id))})]})})]}),f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsx("div",{className:"flex items-center justify-end px-1",children:f.jsx(Ce,{type:"button",variant:"ghost",size:"sm","data-testid":"appearance__reset",disabled:xyn(r),onClick:Pyn,children:"Reset to default"})}),f.jsxs(wi,{children:[f.jsx(_n,{htmlFor:"appearance__ui-size",label:"UI font size",description:"The base size for the interface.",children:f.jsx(Lpe,{id:"appearance__ui-size",value:r.uiFontSize,fallback:XBe,range:KBe,onCommit:h=>l({uiFontSize:h})})}),f.jsx(_n,{htmlFor:"appearance__code-size",label:"Code font size",description:"The size for code in chats, the editor, diffs and the terminal.",children:f.jsx(Lpe,{id:"appearance__code-size",value:r.codeFontSize,fallback:byn,range:JBe,onCommit:h=>l({codeFontSize:h})})}),t&&f.jsx(_n,{htmlFor:"translucent-sidebar",label:"Translucent sidebar",description:"Show the desktop through the repo list, blurred and tinted.",children:f.jsx(Hi,{id:"translucent-sidebar",checked:e,onCheckedChange:n})})]})]})]})}const zyn=Object.freeze([]),$yn=Object.freeze({});function zee(){const t=Rr(),{data:e,isFetched:n}=It({queryKey:Un.browserProfiles,queryFn:()=>t.listBrowserProfiles?.()??Promise.resolve([]),retry:1});return{profiles:e??zyn,isLoaded:n}}function Byn(){const t=Rr(),{data:e}=It({queryKey:Un.repoBrowserProfiles,queryFn:()=>t.listRepoBrowserProfiles?.()??Promise.resolve({})});return e??$yn}function Hyn(){const t=Rr(),e=Rn();return $s({mutationFn:({repoName:n,profileId:r})=>t.setRepoBrowserProfile?.(n,r)??Promise.resolve(),onSettled:()=>e.invalidateQueries({queryKey:Un.repoBrowserProfiles})})}function Fyn(){const t=Rr(),e=Rn();return $s({mutationFn:n=>t.removeBrowserProfile?.(n)??Promise.resolve(),onSettled:()=>Promise.all([e.invalidateQueries({queryKey:Un.browserProfiles}),e.invalidateQueries({queryKey:Un.repoBrowserProfiles})])})}function qyn(){const t=Rn();return()=>Promise.all([t.invalidateQueries({queryKey:Un.browserProfiles}),t.invalidateQueries({queryKey:Un.repoBrowserProfiles})])}const N$="__default__";function Vyn(t){return t==="chrome"?"Imported from Chrome":"No cookies imported"}function Qyn(){const{profiles:t}=zee(),e=Fyn();return f.jsx(_n,{variant:"stacked",label:"Browser profiles",description:"Each profile keeps its own cookies. Import a Chrome profile from the profile menu in a browser tab's toolbar. Deleting a profile signs you out of every site in it.",children:f.jsxs("ul",{className:"divide-y divide-border rounded-md border border-border",children:[f.jsxs("li",{className:"flex items-center justify-between px-3 py-2 text-sm",children:[f.jsx("span",{children:"Default"}),f.jsx("span",{className:"text-xs text-muted-foreground",children:"Built in"})]}),t.map(n=>f.jsxs("li",{className:"flex items-center justify-between gap-2 px-3 py-2 text-sm","data-testid":"settings__browser-profile",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsx("div",{className:"truncate",children:n.name}),f.jsx("div",{className:"text-xs text-muted-foreground",children:Vyn(n.source)})]}),f.jsx(Ce,{variant:"ghost",size:"icon",className:"size-7 shrink-0","aria-label":`Delete browser profile ${n.name}`,disabled:e.isPending,onClick:()=>e.mutate(n.id),children:f.jsx(Kl,{className:"size-3.5"})})]},n.id))]})})}function Uyn({repoName:t}){const{profiles:e}=zee(),n=Byn(),r=Hyn();return f.jsxs(ja,{value:n[t]??N$,onValueChange:o=>r.mutate({repoName:t,profileId:o===N$?null:o}),children:[f.jsx(Ra,{className:"h-8 w-full text-sm sm:w-48","aria-label":`Browser profile for ${t}`,"data-testid":"settings-repo__browser-profile",children:f.jsx(Na,{})}),f.jsxs(La,{children:[f.jsx(ni,{value:N$,children:"Default"}),e.map(o=>f.jsx(ni,{value:o.id,children:o.name},o.id))]})]})}const Ipe=["vault.list"],Wyn={api_key:"API key",env:"Environment variable",oauth:"OAuth",git:"Git credential"};function Zyn(t){return t==null?"Never":new Date(t).toLocaleString()}function Gyn(t){const e=typeof t.metadata.account=="string"?t.metadata.account:null,n=typeof t.metadata.scopes=="string"?t.metadata.scopes:null;return[e?`Account ${e}`:null,n?`Scopes ${n}`:null].filter(Boolean).join(" · ")}function Yyn(){const t=Rn(),e=It({queryKey:Ipe,queryFn:()=>Se.vault.list.query()}),[n,r]=v.useState(""),[o,i]=v.useState("api_key"),[s,a]=v.useState("github.com"),[l,c]=v.useState(""),[u,d]=v.useState(""),[h,p]=v.useState(null),[g,_]=v.useState(!1),x=()=>t.invalidateQueries({queryKey:Ipe}),y=C=>p(C instanceof Error?C.message:String(C)),k=async()=>{_(!0),p(null);try{await Se.vault.put.mutate({name:n.trim(),kind:o,value:u,scope:"global",...o==="git"&&{host:s.trim(),pathPattern:l.trim()}}),r(""),d(""),await x()}catch(C){y(C)}finally{_(!1)}},O=async C=>{p(null);try{await Se.vault.delete.mutate({id:C.id})}catch(A){y(A)}await x()};return f.jsxs(f.Fragment,{children:[f.jsxs(_n,{variant:"stacked",label:"Stored credentials",description:"Encrypted on the hub. A value cannot be read back, only replaced or deleted. The hub refreshes OAuth tokens before they expire.",children:[e.isError?f.jsx("p",{role:"alert",className:"text-xs text-muted-foreground","data-testid":"settings__credentials-denied",children:"Managing credentials needs an admin token."}):null,f.jsx("ul",{className:"divide-y divide-border rounded-md border border-border",children:(e.data?.items??[]).map(C=>f.jsxs("li",{"data-testid":"settings__credential","data-kind":C.kind,className:"flex items-center justify-between gap-2 px-3 py-2 text-sm",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsx("div",{className:"truncate","data-testid":"settings__credential-name",children:C.name}),f.jsxs("div",{className:"text-xs text-muted-foreground",children:[Wyn[C.kind]," · ",C.scope," · Last used ",Zyn(C.lastUsedAt)]}),C.kind==="oauth"?f.jsx("div",{className:"truncate text-xs text-muted-foreground","data-testid":"settings__credential-oauth",children:Gyn(C)}):null]}),f.jsx(Ce,{type:"button",variant:"outline",size:"sm",className:"shrink-0","aria-label":`Delete credential ${C.name}`,onClick:()=>{O(C)},children:"Delete"})]},C.id))})]}),f.jsx(_n,{variant:"stacked",label:"Add a key",description:"An API key or an environment variable value. The value is sent once and is not shown again.",children:f.jsxs("div",{className:"space-y-2",children:[f.jsx(Sn,{"aria-label":"Credential name",placeholder:"Name (for an environment variable, its name)",value:n,onChange:C=>r(C.target.value),className:"h-8 text-sm"}),f.jsxs("select",{"aria-label":"Credential kind",value:o,onChange:C=>i(C.target.value),className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm",children:[f.jsx("option",{value:"api_key",children:"API key"}),f.jsx("option",{value:"env",children:"Environment variable"}),f.jsx("option",{value:"git",children:"Git credential (access token)"})]}),o==="git"&&f.jsxs(f.Fragment,{children:[f.jsx(Sn,{"aria-label":"Git host",placeholder:"Host, such as github.com",value:s,onChange:C=>a(C.target.value),className:"h-8 text-sm"}),f.jsx(Sn,{"aria-label":"Git path pattern",placeholder:"Repositories, such as owner/* or owner/repo",value:l,onChange:C=>c(C.target.value),className:"h-8 text-sm"})]}),f.jsx(Sn,{"aria-label":"Credential value",type:"password",autoComplete:"off",placeholder:"Value",value:u,onChange:C=>d(C.target.value),className:"h-8 text-sm"}),f.jsx(Ce,{type:"button",size:"sm","data-testid":"settings__credential-add",disabled:g||n.trim()===""||u===""||o==="git"&&l.trim()==="",onClick:()=>{k()},children:"Add credential"})]})}),h?f.jsx("p",{role:"alert",className:"text-xs text-destructive","data-testid":"settings__credential-error",children:h}):null]})}function Xyn(t,e){const n=t.trim();return n?e.some(r=>r.name.trim().toLowerCase()===n.toLowerCase())?"A group with this name already exists.":null:"The name is empty."}function oHe({initial:t,others:e,editing:n,onStart:r,onCommit:o,onCancel:i,testId:s}){const[a,l]=v.useState(t),c=v.useRef(null),u=v.useRef(!1);if(v.useEffect(()=>{n&&(l(t),u.current=!1,c.current?.focus(),c.current?.select())},[n,t]),!n)return f.jsx("button",{type:"button","data-testid":s,onClick:r,className:"min-w-0 flex-1 truncate rounded px-1 py-0.5 text-left text-sm hover:bg-accent/50",children:t});const d=a.trim()===t?null:Xyn(a,e),h=a.trim()===t,p=g=>{u.current||(u.current=!0,g())};return f.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:[f.jsx(Sn,{ref:c,"aria-label":`Name of group ${t}`,"aria-invalid":d!==null,"data-testid":`${s}-input`,"data-settings-inline-edit":!0,value:a,onChange:g=>l(g.target.value),onKeyDown:g=>{g.key==="Escape"?p(i):g.key==="Enter"&&(h?p(i):d||p(()=>o(a.trim())))},onBlur:()=>{!d&&!h&&a.trim()?p(()=>o(a.trim())):p(i)},className:"h-7 min-w-24 flex-1 text-sm"}),d?f.jsxs(Or,{children:[f.jsx(Sr,{asChild:!0,children:f.jsx("span",{role:"img","aria-label":d,"data-testid":"settings-groups__name-error",className:"text-destructive",children:f.jsx(_u,{className:"size-4"})})}),f.jsx(Cr,{children:d})]}):null]})}function Kyn({group:t,groups:e,index:n,onRename:r,onColor:o,onMove:i,onDelete:s}){const{attributes:a,listeners:l,setNodeRef:c,transform:u,transition:d,isDragging:h}=kee({id:t.id}),[p,g]=v.useState(!1);return f.jsxs("div",{ref:c,"data-slot":"settings-row","data-testid":"settings-groups__row","data-group-id":t.id,tabIndex:0,onKeyDown:_=>{!_.altKey||p||(_.key==="ArrowUp"?(_.preventDefault(),i(-1)):_.key==="ArrowDown"&&(_.preventDefault(),i(1)))},style:{transform:du.Translate.toString(u),transition:d},className:`flex items-center gap-2 bg-background px-3 py-2 outline-none focus-visible:ring-1 focus-visible:ring-ring ${h?"relative z-10 opacity-70 shadow-lg":""}`,children:[f.jsx("button",{type:"button","aria-label":`Drag ${t.name} to reorder`,"data-testid":"settings-groups__handle",className:"flex size-6 shrink-0 cursor-grab items-center justify-center rounded text-muted-foreground hover:bg-accent/50",...a,...l,children:f.jsx(_ot,{className:"size-4"})}),f.jsx(N_n,{color:t.color,onChange:o,label:`Colour of ${t.name}`,testId:"settings-groups__color",dotTestId:"settings-groups__dot"}),f.jsx(oHe,{initial:t.name,others:e.filter(_=>_.id!==t.id),editing:p,onStart:()=>g(!0),onCommit:_=>{g(!1),r(_)},onCancel:()=>g(!1),testId:"settings-groups__name"}),f.jsxs(Us,{children:[f.jsx(Ws,{asChild:!0,children:f.jsx(Ce,{variant:"ghost",size:"icon-xs","aria-label":`Actions for ${t.name}`,"data-testid":"settings-groups__menu",children:f.jsx(hZ,{className:"size-4"})})}),f.jsxs(Zs,{align:"end",onCloseAutoFocus:_=>_.preventDefault(),children:[f.jsxs(dr,{"data-testid":"settings-groups__rename",onClick:()=>g(!0),children:[f.jsx(y4,{}),"Rename"]}),f.jsxs(dr,{"data-testid":"settings-groups__move-up",disabled:n===0,onClick:()=>i(-1),children:[f.jsx(z7e,{}),"Move up"]}),f.jsxs(dr,{"data-testid":"settings-groups__move-down",disabled:n===e.length-1,onClick:()=>i(1),children:[f.jsx(uZ,{}),"Move down"]}),f.jsx(A4,{}),f.jsxs(dr,{"data-testid":"settings-groups__delete",onClick:s,children:[f.jsx(Kl,{}),"Delete…"]})]})]})]})}function Jyn({color:t,groups:e,onCreate:n,onCancel:r}){return f.jsxs("div",{"data-slot":"settings-row","data-testid":"settings-groups__new-row",className:"flex items-center gap-2 px-3 py-2",children:[f.jsx("span",{className:"size-6 shrink-0"}),f.jsx("span",{className:"flex size-6 shrink-0 items-center justify-center",children:f.jsx("span",{className:"size-3 rounded-full",style:{backgroundColor:t}})}),f.jsx(oHe,{initial:"",others:e,editing:!0,onStart:()=>{},onCommit:n,onCancel:r,testId:"settings-groups__new-name"})]})}function ewn(){const t=rX(),{repos:e}=xs(),{create:n,update:r,remove:o,reorder:i}=oX(),[s,a]=v.useState(!1),[l,c]=v.useState(null),u=Zj(Gf(bee,{activationConstraint:{distance:4}}),Gf(Yj,{coordinateGetter:tBe})),d=t.map(x=>x.id),h=x=>e.reduce((y,k)=>y+k.worktrees.filter(O=>O.groupId===x).length,0),p=QQ.find(x=>!t.some(y=>y.color.toLowerCase()===x.value))?.value??QQ[0].value,g=x=>{if(!x.over)return;const y=S_n(d,String(x.active.id),String(x.over.id));y&&i.mutate({ids:y})},_=(x,y)=>{const k=iBe(d,x,y);k&&i.mutate({ids:k})};return f.jsxs(wi,{title:"Groups",description:"Sort worktrees in the sidebar. A worktree is in one group.",action:f.jsxs(Ce,{variant:"outline",size:"sm","data-testid":"settings-groups__add",onClick:()=>a(!0),children:[f.jsx(wl,{className:"size-3"}),"New group"]}),children:[f.jsxs("div",{"data-testid":"settings-groups",children:[t.length===0&&!s?f.jsx("p",{"data-slot":"settings-row","data-testid":"settings-groups__empty",className:"px-4 py-3 text-sm text-muted-foreground",children:"No groups yet"}):null,f.jsx(eN,{sensors:u,collisionDetection:qE,onDragEnd:g,children:f.jsx(wee,{items:d,strategy:yee,children:t.map((x,y)=>f.jsx(Kyn,{group:x,groups:t,index:y,onRename:k=>r.mutate({id:x.id,name:k}),onColor:k=>r.mutate({id:x.id,color:k}),onMove:k=>_(x.id,k),onDelete:()=>{h(x.id)===0?o.mutate({id:x.id}):c(x)}},x.id))})}),s?f.jsx(Jyn,{color:p,groups:t,onCreate:x=>{a(!1),n.mutate({name:x,color:p})},onCancel:()=>a(!1)}):null]}),f.jsx(P$e,{open:l!==null,onOpenChange:x=>{x||c(null)},groupName:l?.name??"",onConfirm:()=>{l&&o.mutate({id:l.id})}})]})}const twn=t=>t instanceof Error?t.message:String(t);function nwn({open:t,onOpenChange:e,from:n,hosts:r}){const o=Rn(),i=Aee(),s=r.filter(A=>A.id!==n.id&&A.id!=="local"&&A.status==="online"),[a,l]=v.useState(""),[c,u]=v.useState(!1),[d,h]=v.useState(!1),[p,g]=v.useState(null),[_,x]=v.useState(null),y=a||s[0]?.id||"",k=It({queryKey:["checkpoints.evacuable",n.id],queryFn:async()=>(await Se.checkpoints.evacuable.query({hostId:n.id})).worktrees,enabled:t}),O=async()=>{h(!0),g(null);try{x(await Se.checkpoints.evacuate.mutate({fromHostId:n.id,toHostId:y,...c?{addHost:!0}:{}})),await o.invalidateQueries({queryKey:["repos"]})}catch(A){g(twn(A))}finally{h(!1)}},C=k.data?.length??0;return f.jsx(nr,{open:t,onOpenChange:e,children:f.jsxs(rr,{className:"sm:max-w-[520px]","data-testid":"evacuate__dialog",children:[f.jsxs(hr,{children:[f.jsxs(or,{children:["Move all worktrees on ",n.name]}),f.jsx(Nr,{children:n.status==="online"?"Each worktree gets a fresh checkpoint, is recreated on the target worker, and is then removed here. One at a time.":`${n.name} is offline, so each worktree is restored from its last checkpoint. The copies on ${n.name} stay untouched and are listed as superseded when it comes back.`})]}),_?f.jsxs("ul",{className:"space-y-1 text-sm","data-testid":"evacuate__summary",children:[_.results.length===0?f.jsx("li",{children:"There was nothing to move."}):null,_.results.map(A=>f.jsxs("li",{"data-testid":"evacuate__result","data-worktree":A.worktreeId,"data-ok":A.ok?"true":"false",children:[f.jsx("span",{className:"font-mono",children:i(A.worktreeId).label}),":"," ",A.ok?`${A.mode==="move"?"moved":"restored"} as ${i(A.newWorktreeId??"").label}`:`failed. ${A.error}`]},A.worktreeId))]}):f.jsxs("div",{className:"space-y-3",children:[f.jsx("p",{className:"text-sm","data-testid":"evacuate__count",children:k.isLoading?"Counting worktrees…":`${C} worktree${C===1?"":"s"} will move.`}),f.jsx("ul",{className:"max-h-32 overflow-auto text-xs text-muted-foreground",children:(k.data??[]).map(A=>f.jsx("li",{"data-testid":"evacuate__worktree",children:i(A.worktreeId).label},A.worktreeId))}),s.length===0?f.jsx("p",{className:"text-sm text-muted-foreground",children:"No other worker is online."}):f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(To,{htmlFor:"evacuate-target",children:"Target worker"}),f.jsx("select",{id:"evacuate-target","data-testid":"evacuate__target",className:"h-8 w-full rounded-md border border-border bg-transparent px-2 text-sm",value:y,disabled:d,onChange:A=>l(A.target.value),children:s.map(A=>f.jsx("option",{value:A.id,children:A.name||A.id},A.id))})]}),f.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[f.jsx("input",{type:"checkbox",checked:c,disabled:d,"data-testid":"evacuate__add-host",onChange:A=>u(A.target.checked)}),"Add the target worker to the allowed workers of repos that need it"]}),p?f.jsx("p",{role:"alert",className:"text-xs text-destructive","data-testid":"evacuate__error",children:p}):null,f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>e(!1),children:"Cancel"}),f.jsxs(Ce,{size:"sm","data-testid":"evacuate__submit",disabled:d||y===""||C===0,onClick:()=>{O()},children:[d?f.jsx(wo,{className:"size-3"}):null,"Move all"]})]})]}),_?f.jsx("div",{className:"flex justify-end",children:f.jsx(Ce,{size:"sm",variant:"ghost",onClick:()=>e(!1),children:"Close"})}):null]})})}function rwn({host:t,state:e,editable:n,onChanged:r}){const[o,i]=v.useState(e.override??""),[s,a]=v.useState(null),l=async d=>{a(null);try{await Se.workers.setAgentCommand.mutate({hostId:t.id,agentId:e.agentId,command:d}),d===null&&i(""),r()}catch(h){a(h instanceof Error?h.message:String(h))}},c=`settings__host-agent-command-${e.agentId}`,u=e.found===!1;return f.jsxs(jxe,{value:e.agentId,className:"border-b-0",children:[f.jsxs(Pxe,{className:"flex items-center gap-3 px-3 py-2",children:[f.jsx("span",{"data-testid":`${c}-status`,"data-state":e.found===!0?"found":u?"missing":"unknown",className:Ze("size-2 shrink-0 rounded-full",u?"bg-destructive":"bg-success")}),f.jsx(D3,{type:e.type,className:"size-4 shrink-0"}),f.jsx(RC,{"data-testid":`${c}-toggle`,"aria-label":`Command of ${e.label} on ${t.name}`,className:"flex-1 rounded-md text-left text-sm font-medium text-foreground",children:e.label}),f.jsx("span",{"data-testid":`${c}-effective`,"data-effective":e.effective??"",className:Ze("truncate text-xs",u?"text-destructive":"text-muted-foreground"),title:u?`${e.effective} not found on ${t.name}`:void 0,children:e.effective??""}),u?f.jsxs("span",{role:"alert",className:"sr-only","data-testid":`${c}-not-found`,children:[e.effective," not found on ",t.name]}):null,f.jsx(RC,{"aria-label":`Toggle command settings for ${e.label}`,className:"-mr-1 inline-flex size-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground [&[data-state=open]>svg]:rotate-180",children:f.jsx(Pi,{className:"size-4 shrink-0 transition-transform duration-200"})})]}),f.jsxs(Nxe,{className:"space-y-1 px-3 pb-2 pl-11",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Sn,{"aria-label":`${e.label} command on ${t.name}`,"data-testid":`${c}-input`,className:"h-8 flex-1 text-xs",placeholder:"Default binary",disabled:!n,value:o,onChange:d=>i(d.target.value)}),n?f.jsxs(f.Fragment,{children:[f.jsx(Ce,{type:"button",variant:"outline",size:"sm","data-testid":`${c}-save`,disabled:o.trim()===(e.override??"")||o.trim()==="",onClick:()=>{l(o.trim())},children:"Save"}),e.override?f.jsx(Ce,{type:"button",variant:"ghost",size:"sm","data-testid":`${c}-clear`,onClick:()=>{l(null)},children:"Clear"}):null]}):null]}),s?f.jsx("div",{role:"alert",className:"text-xs text-destructive","data-testid":`${c}-error`,children:s}):null]})]})}function own({host:t,isAdmin:e,onChanged:n}){return t.agentCommandStates.length===0?null:f.jsx(Mxe,{type:"multiple",className:"mt-2 w-full rounded-md border border-border","data-testid":"settings__host-agents-commands",children:t.agentCommandStates.map(r=>f.jsx(rwn,{host:t,state:r,editable:e,onChanged:n},`${r.agentId}:${r.override??""}`))})}const iwn=["hosts.updateStatus"],JE=["hosts.list"],swn=10*6e4;function iHe(){return It({queryKey:iwn,queryFn:()=>Se.workers.updateStatus.query(),refetchInterval:swn,retry:!1})}function g8(t=!0){const e=Rr(),n=Rn();return v.useEffect(()=>{if(t)return e.subscribeStatusEvents(r=>{r.kind==="host-status-changed"&&n.invalidateQueries({queryKey:JE})})},[e,n,t]),It({queryKey:JE,queryFn:async()=>(await Se.workers.list.query()).hosts,enabled:t})}function rU({command:t,testId:e,label:n}){const[r,o]=v.useState(!1),i=v.useRef(void 0);v.useEffect(()=>()=>clearTimeout(i.current),[]);const s=async()=>{await Vs(t)&&(o(!0),clearTimeout(i.current),i.current=setTimeout(()=>o(!1),1500))};return f.jsxs("div",{className:"flex items-start gap-2",children:[f.jsx("code",{"data-testid":`${e}-command`,className:"min-w-0 flex-1 break-all rounded bg-muted px-2 py-1 font-mono text-xs",children:t}),f.jsx(Ce,{type:"button",variant:"outline",size:"sm","aria-label":n,"data-testid":`${e}-copy`,onClick:()=>{s()},children:r?f.jsx(Ji,{className:"size-3"}):f.jsx(z0,{className:"size-3"})})]})}function sHe({host:t}){const e=Rn(),[n,r]=v.useState(!1),[o,i]=v.useState(!1),[s,a]=v.useState(null),l=It({queryKey:["hosts.interruptions",t.id],queryFn:()=>Se.workers.interruptions.query({hostId:t.id}),enabled:n,gcTime:0}),c=t.update?.state,u=c==="installing"||c==="restarting",d=async()=>{i(!0),a(null);try{await Se.workers.update.mutate({hostId:t.id}),r(!1)}catch(p){a(p instanceof Error?p.message:String(p))}finally{i(!1),await e.invalidateQueries({queryKey:JE})}},h=l.data?.agents??[];return f.jsxs(f.Fragment,{children:[f.jsx(Ce,{type:"button",variant:"outline",size:"sm","aria-label":`Update ${t.name}`,"data-testid":"update-worker__button",disabled:u,onClick:()=>{a(null),r(!0)},children:c==="installing"?"Installing…":c==="restarting"?"Restarting…":c==="failed"?"Retry update":"Update"}),f.jsx(nr,{open:n,onOpenChange:p=>!o&&r(p),children:f.jsxs(rr,{className:"sm:max-w-[460px]","data-testid":"update-worker__dialog",children:[f.jsxs(hr,{children:[f.jsxs(or,{children:["Update ",t.name," to ",t.updateTarget,"?"]}),f.jsx(Nr,{children:"The worker installs the new version and restarts. Restarting ends every agent running on this worker, and a turn in progress is lost."})]}),f.jsx("div",{className:"text-sm","data-testid":"update-worker__agents","data-state":l.isLoading?"loading":l.isError?"error":h.length===0?"none":"some",children:l.isLoading?f.jsx("span",{className:"text-muted-foreground",children:"Checking running agents…"}):l.isError?f.jsx("span",{className:"text-destructive","data-testid":"update-worker__agents-error",children:"Could not check which agents are running on this worker."}):h.length===0?f.jsx("span",{className:"text-muted-foreground",children:"No agents are running on this worker."}):f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"mb-1 font-medium",children:[h.length===1?"1 agent":`${h.length} agents`," will be interrupted:"]}),f.jsx("ul",{className:"list-disc pl-5",children:h.map(p=>f.jsxs("li",{"data-testid":"update-worker__agent",children:[p.worktreeId," (",p.busy?"working":"idle",")"]},p.chatId))})]})}),s?f.jsx("p",{role:"alert","data-testid":"update-worker__error",className:"text-sm text-destructive",children:s}):null,f.jsxs(ii,{children:[f.jsx(Ce,{variant:"ghost",onClick:()=>r(!1),disabled:o,children:"Cancel"}),f.jsx(Ce,{variant:"destructive","data-testid":"update-worker__confirm",onClick:()=>{d()},disabled:o||l.isLoading||l.isError,children:o?"Installing…":"Update and restart"})]})]})})]})}const awn={current:null,ahead:"ahead of the hub",behind:"behind the hub",unknown:"version unknown, update recommended",refused:"update required"};function Dpe({label:t,testId:e,message:n,onDismiss:r}){return f.jsxs(t0,{children:[f.jsx(ku,{asChild:!0,children:f.jsx("button",{type:"button","aria-label":t,"data-testid":`${e}-icon`,className:"shrink-0 rounded-sm text-destructive",children:f.jsx(_u,{className:"size-3.5","aria-hidden":"true"})})}),f.jsxs(n0,{align:"start",className:"w-72 space-y-2 text-xs",children:[f.jsx("p",{role:"alert","data-testid":e,className:"break-words text-destructive",children:n}),r?f.jsx(Ce,{type:"button",variant:"outline",size:"sm","data-testid":"settings__host-update-dismiss",onClick:r,children:"Dismiss"}):null]})]})}function lwn({host:t,isAdmin:e}){const n=Rn(),r=awn[t.versionState],o=t.canUpdate&&e;return f.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground","data-testid":"settings__host-version-block",children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f.jsxs("span",{"data-testid":"settings__host-version","data-version":t.workerVersion??"unknown",children:["Version: ",t.workerVersion??"unknown"]}),r?f.jsx("span",{"data-testid":"settings__host-version-state","data-state":t.versionState,className:"rounded bg-warning-bg px-1.5 py-0.5 text-warning",children:r}):null,t.updateRequired?f.jsx(Dpe,{label:"Update required",testId:"settings__host-update-required",message:t.updateRequired}):null,t.update?.state==="failed"?f.jsx(Dpe,{label:"Update failed",testId:"settings__host-update-error",message:t.update.error,onDismiss:()=>{Se.workers.dismissUpdate.mutate({hostId:t.id}).then(()=>n.invalidateQueries({queryKey:JE}))}}):null,o?f.jsx(sHe,{host:t}):null]}),t.update&&t.update.state!=="failed"?f.jsxs("div",{"data-testid":"settings__host-update-progress",children:[t.update.state==="installing"?"Installing":"Restarting"," ",t.update.target,"…"]}):null,t.updateTarget&&!o&&t.manualCommand?f.jsxs("div",{className:"space-y-1",children:[f.jsx("div",{children:"Run on the worker, then restart it:"}),f.jsx(rU,{command:t.manualCommand,testId:"settings__host-manual",label:`Copy the update command for ${t.name}`})]}):null]})}const cwn={waiting:"Waiting for the command to run",provisioning:"Provisioning",online:"Online",failed:"Failed",expired:"Expired"};function uwn(){return i1()?.origin??window.location.origin}function zpe(t){navigator.clipboard?.writeText(t).catch(()=>{})}function dwn(){const t=fu(),e=It({queryKey:["provisioning","settings"],queryFn:()=>Se.provisioning.settings.query(),enabled:t}),[n,r]=v.useState(""),[o,i]=v.useState(""),[s,a]=v.useState(""),[l,c]=v.useState(""),[u,d]=v.useState(null),[h,p]=v.useState(null),[g,_]=v.useState(null),[x,y]=v.useState(null),[k,O]=v.useState(!1),C=v.useRef(!1);v.useEffect(()=>{!e.data||C.current||(C.current=!0,r(e.data.repoUrl),i(e.data.branch),a(e.data.command))},[e.data]);const A=u?.id;if(v.useEffect(()=>{if(!A)return;let L=!1,D=!1,I;const z=async()=>{if(!D)try{const{commands:Y}=await Se.provisioning.status.query({id:A}),Q=Y[0]??null;if(L)return;p(Q),Q&&["online","failed","expired"].includes(Q.status)&&(D=!0,clearInterval(I))}catch{}};return z(),I=setInterval(()=>{z()},2e3),()=>{L=!0,I&&clearInterval(I)}},[A]),!t)return null;const E=async()=>{_(null),y(null);try{await Se.provisioning.updateSettings.mutate({repoUrl:n.trim(),branch:o.trim(),command:s.trim()||void 0}),y("Saved. New commands use this repo."),await e.refetch()}catch(L){_(L instanceof Error?L.message:String(L))}},M=async()=>{O(!0),_(null),y(null);try{p(null),d(await Se.provisioning.createCommand.mutate({hubUrl:uwn(),hostName:l.trim()||void 0})),c("")}catch(L){_(L instanceof Error?L.message:String(L))}finally{O(!1)}},P=h?.status??"waiting";return f.jsx(_n,{variant:"stacked",label:"Add a worker",description:"Paste one command on a blank Linux or macOS computer. It works once and expires in an hour.",children:f.jsxs("div",{className:"space-y-2","data-testid":"settings__provision",children:[f.jsxs("details",{children:[f.jsx("summary",{className:"cursor-pointer text-xs font-medium",children:"Provisioning repo"}),f.jsxs("div",{className:"mt-2 space-y-2",children:[f.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. The hub fetches this repo with its git credential and the computer runs the start command from it before the worker starts. Leave it empty for the built-in install."}),f.jsx(Sn,{"aria-label":"Provisioning repo URL",placeholder:"https://github.com/you/dotfiles.git",value:n,onChange:L=>r(L.target.value),className:"h-8 text-sm"}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx(Sn,{"aria-label":"Provisioning repo branch",placeholder:"Branch (default branch if empty)",value:o,onChange:L=>i(L.target.value),className:"h-8 text-sm"}),f.jsx(Sn,{"aria-label":"Provisioning start command",placeholder:"band/provision.sh",value:s,onChange:L=>a(L.target.value),className:"h-8 text-sm"})]}),f.jsx(Ce,{type:"button",variant:"outline",size:"sm","data-testid":"settings__provision-save",onClick:()=>{E()},children:"Save repo"})]})]}),u?f.jsxs("div",{className:"space-y-2","data-testid":"settings__provision-result",children:[f.jsx("textarea",{"aria-label":"Provisioning command",readOnly:!0,rows:3,value:u.command,"data-testid":"settings__provision-command",className:"w-full rounded-md border border-border bg-transparent p-2 font-mono text-xs"}),f.jsxs("p",{className:"text-xs text-muted-foreground","data-testid":"settings__provision-expiry","data-expires-at":u.expiresAt,children:["Expires ",new Date(u.expiresAt).toLocaleString(),". It works once.",u.commitSha?` Repo pinned at ${u.commitSha.slice(0,12)}.`:""]}),f.jsxs("div",{className:"flex flex-wrap gap-2",children:[f.jsxs(Ce,{type:"button",variant:"outline",size:"sm","data-testid":"settings__provision-copy",onClick:()=>zpe(u.command),children:[f.jsx(z0,{className:"size-3"}),"Copy command"]}),f.jsxs(Ce,{type:"button",variant:"outline",size:"sm","data-testid":"settings__provision-copy-cloud-init",onClick:()=>zpe(u.cloudInit),children:[f.jsx(z0,{className:"size-3"}),"Copy as cloud-init"]}),f.jsx(Ce,{type:"button",variant:"ghost",size:"sm",onClick:()=>d(null),children:"Done"})]}),f.jsxs("div",{className:"text-xs","data-testid":"settings__provision-status","data-status":P,children:[cwn[P]??P,h?.hostId?` (${h.hostId})`:""]}),h?.log?f.jsx("pre",{"data-testid":"settings__provision-log",className:"max-h-64 overflow-auto rounded-md border border-border p-2 font-mono text-xs",children:h.log}):null]}):f.jsxs("div",{className:"flex gap-2",children:[f.jsx(Sn,{"aria-label":"Name for the new worker",placeholder:"Worker name (optional)",value:l,onChange:L=>c(L.target.value),className:"h-8 text-sm"}),f.jsxs(Ce,{type:"button",size:"sm",disabled:k,"data-testid":"settings__provision-create",onClick:()=>{M()},children:[f.jsx(xM,{className:"size-3"}),"Get provisioning command"]})]}),x?f.jsx("p",{className:"text-xs text-muted-foreground",children:x}):null,g?f.jsx("p",{role:"alert",className:"text-xs text-destructive","data-testid":"settings__provision-error",children:g}):null]})})}function aHe(){return Ho("pick_folder")}function lHe(){const[t,e]=v.useState(null),[n,r]=v.useState(!1),[o,i]=v.useState(null),[s,a]=v.useState(null),l=v.useCallback(async()=>{if(On)try{e(await Ho("worker_status"))}catch{e(null)}},[]);v.useEffect(()=>{l()},[l]);const c=v.useCallback(async(u,d)=>{r(!0),i(null),a(null);try{const h=await Ho(u,d);return h.ok?(h.note&&a(h.note),!0):(i(h.error),!1)}catch(h){return i(h instanceof Error?h.message:String(h)),!1}finally{r(!1),await l()}},[l]);return{status:t,busy:n,error:o,note:s,refresh:l,run:c}}function fwn(){const{status:t,busy:e,error:n,note:r,run:o}=lHe(),[i,s]=v.useState(""),[a,l]=v.useState([]);if(v.useEffect(()=>{t&&i===""&&s(t.defaultName)},[t,i]),!On||!t?.supported)return null;const c=async()=>{const d=await aHe().catch(()=>null);d&&!a.includes(d)&&l([...a,d])};let u;if(!t.remoteHub&&!t.installed)u=f.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"this-computer__local-hub",children:"This app runs its own hub, which already covers this computer."});else if(t.installed){const d=t.forThisHub?t.hostStatus??"unknown":"connected to another hub";u=f.jsxs("div",{className:"space-y-2 text-sm",children:[f.jsxs("div",{"data-testid":"this-computer__state","data-status":d,children:[t.name??"This computer",": ",d,t.bundled?` · worker ${t.version}`:" · installed from npm"]}),t.roots.length>0?f.jsxs("div",{className:"text-xs text-muted-foreground",children:["Folders: ",t.roots.join(", ")]}):null,f.jsxs("div",{className:"flex gap-2",children:[t.bundled?null:f.jsx(Ce,{type:"button",size:"sm","data-testid":"this-computer__switch",disabled:e,onClick:()=>{o("worker_switch_bundled")},children:"Switch to the worker in this app"}),f.jsx(Ce,{type:"button",variant:"outline",size:"sm","data-testid":"this-computer__remove",disabled:e,onClick:()=>{o("worker_remove")},children:e?"Working…":"Remove this computer"})]})]})}else u=f.jsxs("div",{className:"space-y-2",children:[f.jsx(Sn,{"aria-label":"Computer name","data-testid":"this-computer__name",value:i,maxLength:100,disabled:e,onChange:d=>s(d.target.value)}),a.map(d=>f.jsx("div",{className:"font-mono text-xs",children:d},d)),f.jsxs("div",{className:"flex gap-2",children:[f.jsx(Ce,{type:"button",variant:"outline",size:"sm",disabled:e,onClick:()=>{c()},children:"Add folder"}),f.jsx(Ce,{type:"button",size:"sm","data-testid":"this-computer__add",disabled:e||i.trim()==="",onClick:()=>{o("worker_add",{name:i,roots:a})},children:e?"Setting up…":"Add this computer"})]})]});return f.jsx(_n,{variant:"stacked",label:"Use this computer as a worker",description:"Run worktrees and agents on this Mac from the hub the app is connected to. The service runs the worker bundled in this app, so an app update updates it.",children:f.jsxs("div",{"data-testid":"this-computer",children:[u,r?f.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:r}):null,n?f.jsx("p",{role:"alert","data-testid":"this-computer__error",className:"mt-2 text-xs text-destructive",children:n}):null]})})}const $pe=[{id:"service",label:"npm service",hint:"Linux and macOS. Installs @band-app/worker (Node 22.5 or newer), then registers it as a systemd user unit on Linux or a launchd agent on macOS, so it starts at login and restarts on failure."},{id:"foreground",label:"npm foreground",hint:"Runs the worker in this terminal until you stop it. Needs @band-app/worker installed (npm install -g @band-app/worker)."},{id:"docker",label:"Docker run",hint:"Runs the published worker image. The volumes keep the worker's repositories and its identity across restarts."},{id:"compose",label:"Docker compose",hint:"Save as compose.yml on the worker machine and run docker compose up -d."}],hwn=new Set(["localhost","127.0.0.1","[::1]"]);function Bpe(t){try{return hwn.has(new URL(t).hostname)}catch{return!1}}function pwn(t,e){const{hubUrl:n,hostId:r,token:o}=e;switch(t){case"service":return["npm install -g @band-app/worker &&",`band-worker install-service --hub ${n} --worker-id ${r} --token ${o}`].join(" ");case"foreground":return[`BAND_HUB_URL=${n}`,`BAND_WORKER_ID=${r}`,`BAND_BOOTSTRAP_TOKEN=${o}`,"band-worker"].join(" ");case"docker":return["docker run -d --name band-worker --restart unless-stopped",...Bpe(n)?["--network host"]:[],"-v band-work:/work -v band-worker-state:/home/worker/.band/worker",`-e BAND_HUB_URL=${n} -e BAND_WORKER_ID=${r} -e BAND_WORKER_TOKEN=${o}`,"ghcr.io/band-app/band-worker:latest"].join(" ");case"compose":return["services:"," band-worker:"," image: ghcr.io/band-app/band-worker:latest"," restart: unless-stopped",...Bpe(n)?[" network_mode: host"]:[]," environment:",` BAND_HUB_URL: ${n}`,` BAND_WORKER_ID: ${r}`,` BAND_WORKER_TOKEN: ${o}`," volumes:"," - band-work:/work"," - band-worker-state:/home/worker/.band/worker","volumes:"," band-work:"," band-worker-state:",""].join(`
886
886
  `)}}function mwn(t){const e=t.report;return e?e.agents.length===0?"none found":e.agents.map(n=>{if(!n.installed)return`${n.type} not installed`;const r=n.loggedIn===!1?"not logged in":n.loggedIn?"logged in":"login unknown";return`${n.type}${n.version?` ${n.version}`:""} ${r}`}).join(", "):t.agents.length>0?t.agents.join(", "):"none found"}const gwn={desktop:"Desktop",git:"Git",gh:"GitHub CLI",pty:"Terminals",acp:"Agents",lsp:"Language servers",search:"Search",fsWatch:"File watching"};function vwn(t){return t.capabilities.length===0?"none reported":t.capabilities.map(e=>gwn[e]??e).join(", ")}function bwn(t){const e=t.info;return typeof e?.os!="string"?"unknown":typeof e.arch=="string"?`${e.os} ${e.arch}`:e.os}const _wn={online:"bg-success-bg text-success",lost:"bg-warning-bg text-warning"},xwn=["restricted","standard","admin"],Hpe={restricted:"Restricted",standard:"Standard",admin:"Admin"},Fpe={restricted:"Agents on this worker can only use their own worktrees.",standard:"Agents on this worker work on their own worker, and start worktrees elsewhere when Settings > Agents allows it.",admin:"Agents on this worker can work on any worker, change hub settings and manage repos and cronjobs. Tokens, the vault and trust levels stay out of reach."},R$=["hosts.list"],qpe=["hosts.audit"],Vpe=["tokens.list"],Qpe={device:"Device",worker_bootstrap:"Worker bootstrap",worker_session:"Worker session",device_pairing:"Pairing code"};function oU(t){return t==null?"Never":new Date(t).toLocaleString()}function ywn(){return i1()?.origin??window.location.origin}function wwn({host:t}){return f.jsxs(t0,{children:[f.jsx(ku,{asChild:!0,children:f.jsx("button",{type:"button","aria-label":`Details of ${t.name}`,"data-testid":`settings__host-details--${t.id}`,className:"shrink-0 rounded-sm text-muted-foreground hover:text-foreground",children:f.jsx(G7e,{className:"size-3.5","aria-hidden":"true"})})}),f.jsxs(n0,{align:"start",className:"w-80 space-y-1.5 text-xs","data-testid":"settings__host-details",children:[f.jsxs("div",{children:[f.jsx("span",{className:"text-muted-foreground",children:"ID "}),f.jsx("span",{"data-testid":"settings__host-id",className:"break-all",children:t.id})]}),f.jsxs("div",{children:[f.jsx("span",{className:"text-muted-foreground",children:"Labels "}),t.labels.length>0?t.labels.join(", "):"None"]}),f.jsxs("div",{children:[f.jsx("span",{className:"text-muted-foreground",children:"Last seen "}),oU(t.lastSeenAt)]}),t.usable?f.jsxs(f.Fragment,{children:[f.jsxs("div",{"data-testid":"settings__host-agents",children:[f.jsx("span",{className:"text-muted-foreground",children:"Agents "}),mwn(t)]}),f.jsxs("div",{"data-testid":"settings__host-roots",className:"break-all",children:[f.jsx("span",{className:"text-muted-foreground",children:"Roots "}),t.roots.length>0?t.roots.join(", "):"any path"]}),f.jsxs("div",{"data-testid":"settings__host-os",children:[f.jsx("span",{className:"text-muted-foreground",children:"OS "}),bwn(t)]}),f.jsxs("div",{"data-testid":"settings__host-capabilities",children:[f.jsx("span",{className:"text-muted-foreground",children:"Capabilities "}),vwn(t)]})]}):null]})]})}function kwn(){const t=Rn(),e=Rr(),n=v.useCallback(async N=>{await t.cancelQueries({queryKey:N}),await t.invalidateQueries({queryKey:N})},[t]);v.useEffect(()=>e.subscribeStatusEvents(N=>{N.kind==="host-status-changed"&&n(R$)}),[e,n]);const r=fu(),o=It({queryKey:R$,queryFn:async()=>(await Se.workers.list.query()).hosts}),i=It({queryKey:Vpe,queryFn:async()=>(await Se.tokens.list.query()).tokens,select:N=>N.filter(V=>V.kind!=="device")}),s=fu(),a=It({queryKey:qpe,queryFn:async()=>(await Se.workers.audit.query({limit:50})).entries,enabled:s}),[l,c]=v.useState(null),[u,d]=v.useState(!1),[h,p]=v.useState(""),[g,_]=v.useState(""),[x,y]=v.useState(null),[k,O]=v.useState("service"),[C,A]=v.useState(null),[E,M]=v.useState(!1),P=()=>Promise.all([n(R$),n(Vpe),n(qpe)]),L=async()=>{M(!0),A(null);try{const N=await Se.tokens.issueWorkerBootstrap.mutate({hostName:h.trim(),labels:g.split(",").map(V=>V.trim()).filter(Boolean)});y({hostId:N.hostId,token:N.token,expiresAt:N.view.expiresAt}),p(""),_(""),await P()}catch(N){A(N instanceof Error?N.message:String(N))}finally{M(!1)}},D=async N=>{A(null);try{await Se.tokens.revoke.mutate({tokenId:N.id})}catch(V){A(V instanceof Error?V.message:String(V))}await P()},I=async(N,V)=>{A(null);try{await Se.workers.setTrust.mutate({hostId:N.id,trust:V})}catch(G){A(G instanceof Error?G.message:String(G))}await P()},z=async N=>{A(null);try{await Se.workers.remove.mutate({hostId:N.id})}catch(V){A(V instanceof Error?V.message:String(V))}await P()},Y=N=>{navigator.clipboard?.writeText(N).catch(()=>{})},Q=()=>{d(!1),O("service"),y(null),A(null)},H=x?pwn(k,{hubUrl:ywn(),hostId:x.hostId,token:x.token}):"";return f.jsxs(f.Fragment,{children:[f.jsx(fwn,{}),f.jsx(_n,{variant:"stacked",label:"Workers",description:"Computers that run worktrees. Workers connect to the hub and appear here. The hub's own machine is the built-in worker. On a hub started with BAND_LOCAL_WORKER=off it runs no worktrees and is not listed.",children:f.jsx("ul",{className:"divide-y divide-border rounded-md border border-border",children:(o.data??[]).map(N=>f.jsxs("li",{"data-testid":"settings__host","data-status":N.status,className:"px-3 py-2 text-sm",children:[f.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-x-3 gap-y-2",children:[f.jsxs("div",{className:"min-w-0 flex-1 basis-24",children:[f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:"truncate","data-testid":"settings__host-name",children:N.name}),f.jsx(wwn,{host:N})]}),N.usable?f.jsx(lwn,{host:N,isAdmin:r}):null]}),f.jsxs("div",{className:"flex max-w-full shrink-0 flex-wrap items-center gap-2",children:[f.jsx("span",{"data-testid":"settings__host-status",className:`rounded-full px-2.5 py-0.5 text-xs ${_wn[N.status]??"bg-muted text-muted-foreground"}`,children:N.status}),N.id!=="local"&&(s?f.jsx("select",{"aria-label":`Trust level of ${N.name}`,"data-testid":"settings__host-trust-select",title:Fpe[N.trust],value:N.trust,onChange:V=>{I(N,V.target.value)},className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs",children:xwn.map(V=>f.jsx("option",{value:V,children:Hpe[V]},V))}):f.jsx("span",{"data-testid":"settings__host-trust",title:Fpe[N.trust],className:"rounded-md border border-border px-1.5 py-0.5 text-xs text-muted-foreground",children:Hpe[N.trust]})),N.capabilities.includes("desktop")&&N.status==="online"&&f.jsx(Ce,{type:"button",variant:"outline",size:"sm","aria-label":`Open desktop of ${N.name}`,"data-testid":"settings__host-open-desktop",onClick:()=>T$e(N.id),children:"Open desktop"}),N.id!=="local"&&s&&N.status!=="disposed"&&f.jsxs(Us,{children:[f.jsx(Ws,{asChild:!0,children:f.jsx(Ce,{type:"button",variant:"ghost",size:"sm","aria-label":`More actions for ${N.name}`,"data-testid":"settings__host-menu",children:f.jsx(hZ,{className:"size-4"})})}),f.jsx(Zs,{align:"end",children:f.jsx(dr,{"data-testid":"settings__host-evacuate",onClick:()=>c(N.id),children:"Move all worktrees on this worker…"})})]}),N.id!=="local"&&f.jsx(Ce,{type:"button",variant:"outline",size:"sm","aria-label":`Remove worker ${N.name}`,title:"Remove worker","data-testid":"settings__host-remove",disabled:N.status==="online"||N.status==="lost",onClick:()=>{z(N)},children:f.jsx(Kl,{className:"size-4"})})]})]}),N.usable?f.jsx(own,{host:N,isAdmin:r,onChanged:()=>{P()}}):null]},N.id))})}),(o.data??[]).filter(N=>N.id===l).map(N=>f.jsx(nwn,{open:!0,onOpenChange:V=>{V||c(null)},from:N,hosts:o.data??[]},N.id)),s?f.jsx(_n,{variant:"stacked",label:"Cross-worker activity",description:"What agents on admin workers did across workers or as an admin: the newest calls first.",children:(a.data??[]).length===0?f.jsx("p",{className:"text-xs text-muted-foreground","data-testid":"settings__audit-empty",children:"Nothing yet."}):f.jsx("ul",{className:"divide-y divide-border rounded-md border border-border",children:(a.data??[]).map(N=>f.jsxs("li",{"data-testid":"settings__audit-entry","data-procedure":N.procedure,className:"px-3 py-2 text-xs",children:[f.jsx("span",{className:"font-medium",children:N.procedure})," · from ",N.callerHostId,N.targetHostId?` to ${N.targetHostId}`:"",N.target?` (${N.target})`:"",N.chatId?` · chat ${N.chatId}`:""," · ",oU(N.at)]},N.id))})}):null,f.jsx(dwn,{}),f.jsxs(_n,{variant:"stacked",label:"Manual install",description:"Create a one-time token for a worker on another computer. It works once and expires in an hour.",children:[u?x?f.jsxs("div",{className:"space-y-2","data-testid":"settings__bootstrap-result",children:[f.jsx("p",{className:"text-xs text-muted-foreground",children:"Copy this now. The hub keeps only a hash of the token and cannot show it again."}),f.jsx("label",{className:"block text-xs font-medium",htmlFor:"bootstrap-token",children:"Bootstrap token"}),f.jsx(Sn,{id:"bootstrap-token",readOnly:!0,value:x.token,"data-testid":"settings__bootstrap-token",className:"h-8 font-mono text-xs"}),f.jsx("div",{className:"text-xs font-medium",children:"Run on the worker"}),f.jsx("div",{role:"tablist","aria-label":"Install method",className:"flex flex-wrap gap-1",children:$pe.map(N=>f.jsx(Ce,{type:"button",role:"tab","aria-selected":k===N.id,"data-testid":`settings__install-tab-${N.id}`,variant:k===N.id?"secondary":"ghost",size:"sm",onClick:()=>O(N.id),children:N.label},N.id))}),f.jsx("p",{className:"text-xs text-muted-foreground",children:$pe.find(N=>N.id===k)?.hint}),f.jsx("textarea",{"aria-label":"Worker install command",readOnly:!0,rows:k==="compose"?14:4,value:H,"data-testid":"settings__worker-command","data-tab":k,className:"w-full rounded-md border border-border bg-transparent p-2 font-mono text-xs"}),f.jsxs(Ce,{type:"button",variant:"outline",size:"sm","data-testid":"settings__copy-worker-command",onClick:()=>Y(H),children:[f.jsx(z0,{className:"size-3"}),"Copy command"]}),f.jsx(Ce,{type:"button",variant:"outline",size:"sm",onClick:Q,children:"Done"})]}):f.jsxs("div",{className:"space-y-2",children:[f.jsx(Sn,{"aria-label":"Worker name",placeholder:"Worker name",value:h,onChange:N=>p(N.target.value),className:"h-8 text-sm"}),f.jsx(Sn,{"aria-label":"Labels",placeholder:"Labels, comma separated (optional)",value:g,onChange:N=>_(N.target.value),className:"h-8 text-sm"}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx(Ce,{type:"button",size:"sm",disabled:E||h.trim()==="",onClick:()=>{L()},children:"Create token"}),f.jsx(Ce,{type:"button",variant:"ghost",size:"sm",onClick:Q,children:"Cancel"})]})]}):f.jsxs(Ce,{type:"button",variant:"outline",size:"sm","data-testid":"settings__add-worker",onClick:()=>d(!0),children:[f.jsx(wl,{className:"size-3"}),"Add worker"]}),C?f.jsx("p",{role:"alert",className:"mt-2 text-xs text-destructive",children:C}):null]}),f.jsxs(_n,{variant:"stacked",label:"Worker tokens",description:"Revoking a worker token disconnects that worker. Device tokens are in Settings > Devices.",children:[i.isError?f.jsx("p",{role:"alert",className:"text-xs text-muted-foreground","data-testid":"settings__tokens-denied",children:"Managing worker tokens needs an admin token."}):null,f.jsx("ul",{className:"divide-y divide-border rounded-md border border-border",children:(i.data??[]).map(N=>f.jsxs("li",{"data-testid":"settings__token","data-token-id":N.id,"data-state":N.state,className:"flex items-center justify-between gap-2 px-3 py-2 text-sm",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsx("div",{className:"truncate",children:N.label||Qpe[N.kind]}),f.jsxs("div",{className:"text-xs text-muted-foreground",children:[Qpe[N.kind],N.admin?" (admin)":""," · ",N.state," · Last used"," ",oU(N.lastUsedAt)]})]}),f.jsx(Ce,{type:"button",variant:"outline",size:"sm",className:"shrink-0","aria-label":`Revoke token ${N.label||N.id}`,disabled:N.state!=="active",onClick:()=>{D(N)},children:"Revoke"})]},N.id))})]})]})}function Own(){const[t,e]=v.useState("local"),[n,r]=v.useState(""),[o,i]=v.useState(""),[s,a]=v.useState(null),[l,c]=v.useState(null),[u,d]=v.useState(!1);if(v.useEffect(()=>{let _=!1;return Ho("hub_get_choice").then(x=>{_||(a(x),e(x.mode),r(x.url))}).catch(()=>{}),()=>{_=!0}},[]),!s)return null;const h=s.hasToken&&t===s.mode&&n.trim()===s.url,p=t===s.mode&&(t==="local"||n.trim()===s.url&&o===""),g=async()=>{d(!0),c(null);try{const _=await Ho("hub_set_choice",{mode:t,url:n,token:o});_.ok||c(_.error)}catch(_){c(_ instanceof Error?_.message:String(_))}finally{d(!1)}};return f.jsxs(f.Fragment,{children:[f.jsx(_n,{htmlFor:"hub-mode",label:"Hub",description:"Local runs the hub bundled with this app. Remote connects to a hub on another machine and starts nothing here.",children:f.jsxs("select",{id:"hub-mode","data-testid":"settings__hub-mode",className:"h-8 rounded-md border border-border bg-background px-2 text-sm",value:t,onChange:_=>e(_.target.value),children:[f.jsx("option",{value:"local",children:"Local"}),f.jsx("option",{value:"remote",children:"Remote"})]})}),t==="remote"?f.jsx(_n,{variant:"stacked",label:"Remote hub",description:"The hub's URL and its token. Use https:// unless the hub is on this machine.",children:f.jsxs("div",{className:"space-y-2",children:[f.jsx(Sn,{"data-testid":"settings__hub-url","aria-label":"Hub URL",placeholder:"https://hub.example.com",value:n,onChange:_=>r(_.target.value)}),f.jsx(Sn,{"data-testid":"settings__hub-token","aria-label":"Hub token",type:"password",autoComplete:"off",placeholder:h?"Token (saved, type to replace)":"Token",value:o,onChange:_=>i(_.target.value)})]})}):null,f.jsx(_n,{variant:"stacked",children:f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx(Ce,{type:"button",size:"sm","data-testid":"settings__hub-apply",disabled:u||p,onClick:()=>{g()},children:u?"Connecting…":"Apply and reload"}),l?f.jsx("p",{role:"alert","data-testid":"settings__hub-error",className:"text-xs text-destructive",children:l}):null]})})]})}const Upe=["mcp.list"],Wpe=["mcp.vault-items"],Zpe=20,Swn=1e3,Cwn={editing:null,name:"",transport:"http",url:"",hostId:"",command:"",args:"",cwd:"",env:[],vaultItemId:"",headerName:"Authorization",headerPrefix:"Bearer ",allowAll:!0,allowed:[],readOnly:!1,enabled:!0,scopeMode:"all",scopeRepos:[],scopeHosts:[]};function Awn(t){return{editing:t.name,name:t.name,transport:t.transport,url:t.url,hostId:t.hostId??"",command:t.command??"",args:t.args.join(`
887
887
  `),cwd:t.cwd??"",env:t.env.map(e=>"vaultItemId"in e?{name:e.name,source:"vault",value:"",vaultItemId:e.vaultItemId}:{name:e.name,source:"value",value:e.value,vaultItemId:""}),vaultItemId:t.vaultItemId??"",headerName:t.headerName,headerPrefix:t.headerPrefix,allowAll:t.allowTools===null,allowed:t.allowTools??[],readOnly:t.readOnly,enabled:t.enabled,scopeMode:t.scopeRepos?"repos":t.scopeHosts?"hosts":"all",scopeRepos:t.scopeRepos??[],scopeHosts:t.scopeHosts??[]}}function Ewn(t){return t.scopeRepos?`Repos: ${t.scopeRepos.join(", ")||"none"}`:t.scopeHosts?`Workers: ${t.scopeHosts.join(", ")||"none"}`:"All worktrees"}function Gpe(t){return{hostId:t.hostId,command:t.command.trim(),args:t.args.split(`
888
888
  `).filter(e=>e!==""),cwd:t.cwd.trim()===""?null:t.cwd.trim(),env:t.env.filter(e=>e.name.trim()!=="").map(e=>e.source==="vault"?{name:e.name.trim(),vaultItemId:e.vaultItemId}:{name:e.name.trim(),value:e.value})}}function Ype(t){return!t.editing&&t.name.trim()===""?!1:t.transport==="stdio"?t.hostId!==""&&t.command.trim()!=="":t.url.trim()!==""}function Twn(t,e,n){return t.enabled?t.transport==="stdio"?n==="online"?"ok":"other":typeof e=="object"&&e.ok?"ok":"other":"disabled"}function L$(t,e,n){return n?[...new Set([...t,e])]:t.filter(r=>r!==e)}function Mwn(t){return t?t==="checking"?"Checking":t.ok?`Reachable, ${t.tools.length} tools`:t.reason==="auth"?"Reachable, credential refused":"Unreachable":"Not checked"}function Pwn(){const t=Rn(),[e,n]=v.useState(null),r=It({queryKey:Upe,queryFn:()=>Se.mcp.list.query()}),o=It({queryKey:Wpe,queryFn:async()=>(await Se.vault.list.query()).items,enabled:r.isSuccess&&e!==null}),i=It({queryKey:["mcp.repos"],queryFn:async()=>(await Se.repos.list.query()).repos.map(B=>B.name),enabled:e?.scopeMode==="repos"}),s=It({queryKey:["mcp.hosts"],queryFn:async()=>(await Se.workers.list.query()).hosts,enabled:r.isSuccess,refetchInterval:5e3}),[a,l]=v.useState(null),[c,u]=v.useState(null),[d,h]=v.useState(!1),[p,g]=v.useState({}),[_,x]=v.useState(null),[y,k]=v.useState(null),[O,C]=v.useState(null),[A,E]=v.useState(!1),M=v.useRef(null);v.useEffect(()=>()=>{M.current&&clearInterval(M.current)},[]);const P=()=>{M.current&&clearInterval(M.current),M.current=null,C(null)},L=()=>t.invalidateQueries({queryKey:Upe}),D=B=>k(B instanceof Error?B.message:String(B)),I=B=>n(ee=>ee&&{...ee,...B}),z=async B=>{g(ee=>({...ee,[B.name]:"checking"}));try{const ee=await Se.mcp.test.mutate({name:B.name});g(te=>({...te,[B.name]:ee}))}catch(ee){g(te=>({...te,[B.name]:{ok:!1,reason:"error",message:ee instanceof Error?ee.message:String(ee)}}))}},Y=v.useRef(!1);v.useEffect(()=>{if(!(!r.data||Y.current)){Y.current=!0;for(const B of r.data.servers)B.enabled&&B.transport==="http"&&z(B)}},[r.data]);const Q=B=>{P(),o.refetch(),s.refetch(),n(B),l(null),u(null),k(null),C(null)},H=async()=>{if(e){E(!0),k(null),u(null);try{const B=await Se.mcp.test.mutate(e.transport==="stdio"?{transport:"stdio",...Gpe(e)}:{url:e.url.trim(),vaultItemId:e.vaultItemId||null,headerName:e.headerName,headerPrefix:e.headerPrefix});B.ok?(l(B.tools),h(!0),u(`Connected. ${B.tools.length} tools.`)):(l(null),h(!1),u(B.message))}catch(B){D(B)}finally{E(!1)}}},N=async()=>{if(!e)return;E(!0),k(null);const ee={...e.transport==="stdio"?Gpe(e):{url:e.url.trim(),vaultItemId:e.vaultItemId||null,headerName:e.headerName,headerPrefix:e.headerPrefix},allowTools:e.allowAll?null:e.allowed,readOnly:e.readOnly,enabled:e.enabled,scopeRepos:e.scopeMode==="repos"?e.scopeRepos:null,scopeHosts:e.scopeMode==="hosts"?e.scopeHosts:null};try{e.editing?await Se.mcp.update.mutate({name:e.editing,...ee}):await Se.mcp.add.mutate({name:e.name.trim(),transport:e.transport,...ee});const te=e.editing??e.name.trim();P(),n(null),await L(),e.enabled&&e.transport==="http"&&z({name:te})}catch(te){D(te)}finally{E(!1)}},V=async B=>{k(null);try{await Se.mcp.remove.mutate({name:B.name})}catch(ee){D(ee)}_===B.name&&x(null),await L()},G=async()=>{if(!e)return;E(!0),k(null),C(null);const B=window.open("about:blank","_blank");B&&(B.opener=null);try{const{flowId:ee,authorizationUrl:te}=await Se.vault.startOAuth.mutate({name:e.name.trim()||"mcp-oauth",serverUrl:e.url.trim(),scope:"global",redirectBase:i1()?.origin??window.location.origin});B?B.location.href=te:window.open(te,"_blank"),C("Waiting for you to approve the connection in the new window."),M.current&&clearInterval(M.current);const se=Date.now(),ae=setInterval(()=>{(async()=>{try{const he=await Se.vault.oauthStatus.query({flowId:ee});if(M.current!==ae||(he.status==="pending"||he.status==="exchanging")&&Date.now()-se<10*6e4)return;M.current&&clearInterval(M.current),M.current=null,C(null),he.status==="connected"?(await t.invalidateQueries({queryKey:Wpe}),await t.invalidateQueries({queryKey:["vault.list"]}),he.item&&I({vaultItemId:he.item.id})):k(he.error??"The connection was not completed.")}catch(he){M.current&&clearInterval(M.current),M.current=null,C(null),D(he)}})()},Swn);M.current=ae}catch(ee){B?.close(),D(ee)}finally{E(!1)}};if(r.isError)return f.jsx(_n,{variant:"stacked",label:"MCP servers",children:f.jsx("p",{role:"alert",className:"text-xs text-muted-foreground","data-testid":"settings__mcp-denied",children:"Managing MCP servers needs an admin token."})});const K=B=>B.hostId?(s.data??[]).find(ee=>ee.id===B.hostId)?.status:void 0,q=(o.data??[]).filter(B=>B.kind==="api_key"||B.kind==="oauth"),Z=o.data??[],U=new Set([...(a??[]).map(B=>B.name),...e?.allowed??[]]);return f.jsxs(f.Fragment,{children:[f.jsxs(_n,{variant:"stacked",label:"MCP servers",description:"MCP servers the hub proxies to coding agents, over HTTP or as a process on a worker. The hub adds the credential, so an agent never holds it.",children:[f.jsx("ul",{className:"divide-y divide-border rounded-md border border-border",children:(r.data?.servers??[]).map(B=>f.jsxs("li",{"data-testid":"settings__mcp-server",className:"flex items-center justify-between gap-2 px-3 py-2 text-sm",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsx("div",{className:"truncate","data-testid":"settings__mcp-server-name",children:B.name}),f.jsx("div",{className:"truncate text-xs text-muted-foreground",children:B.transport==="stdio"?`${B.command??""} ${B.args.join(" ")} on ${B.hostId?s.data?.find(ee=>ee.id===B.hostId)?.name??B.hostId:"no worker"}`:B.url}),f.jsxs("div",{className:"text-xs text-muted-foreground",children:[f.jsx("span",{"data-testid":"settings__mcp-server-scope",children:Ewn(B)})," · ",B.enabled?"Enabled":"Disabled",B.readOnly?" · Read-only":"",B.allowTools?` · ${B.allowTools.length} tools allowed`:""]}),f.jsx("div",{className:"text-xs text-muted-foreground","data-testid":"settings__mcp-status","data-state":Twn(B,p[B.name],K(B)),children:B.enabled?B.transport==="stdio"?`Worker ${K(B)??"unknown"}`:Mwn(p[B.name]):"Disabled"})]}),f.jsxs("div",{className:"flex shrink-0 gap-1",children:[f.jsx(Ce,{type:"button",variant:"outline",size:"sm","aria-label":`Audit log of ${B.name}`,onClick:()=>x(_===B.name?null:B.name),children:"Audit"}),f.jsx(Ce,{type:"button",variant:"outline",size:"sm","aria-label":`Edit MCP server ${B.name}`,onClick:()=>Q(Awn(B)),children:"Edit"}),f.jsx(Ce,{type:"button",variant:"outline",size:"sm","aria-label":`Remove MCP server ${B.name}`,onClick:()=>{V(B)},children:"Remove"})]})]},B.id))}),e?null:f.jsx(Ce,{type:"button",size:"sm",className:"mt-2","data-testid":"settings__mcp-add",onClick:()=>Q(Cwn),children:"Add server"})]}),e?f.jsx(_n,{variant:"stacked",label:e.editing?`Edit ${e.editing}`:"Add a server",children:f.jsxs("div",{className:"space-y-2","data-testid":"settings__mcp-form",children:[f.jsx(Sn,{"aria-label":"MCP server name",placeholder:"Name (lowercase letters, digits, - and _)",value:e.name,disabled:e.editing!==null,onChange:B=>I({name:B.target.value}),className:"h-8 text-sm"}),f.jsxs("select",{"aria-label":"MCP transport",value:e.transport,disabled:e.editing!==null,onChange:B=>I({transport:B.target.value}),className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm",children:[f.jsx("option",{value:"http",children:"HTTP server"}),f.jsx("option",{value:"stdio",children:"Process on a worker (stdio)"})]}),e.transport==="stdio"?f.jsxs("div",{className:"space-y-2","data-testid":"settings__mcp-stdio",children:[f.jsxs("select",{"aria-label":"MCP worker",value:e.hostId,onChange:B=>I({hostId:B.target.value}),className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm",children:[f.jsx("option",{value:"",children:"Choose a worker"}),(s.data??[]).filter(B=>B.usable).map(B=>f.jsxs("option",{value:B.id,children:[B.name," (",B.id,", ",B.status,")"]},B.id))]}),f.jsx(Sn,{"aria-label":"MCP command",placeholder:"Executable, for example npx",value:e.command,onChange:B=>I({command:B.target.value}),className:"h-8 text-sm"}),f.jsx("textarea",{"aria-label":"MCP arguments",placeholder:"Arguments, one per line",value:e.args,onChange:B=>I({args:B.target.value}),rows:3,className:"w-full rounded-md border border-border bg-background px-2 py-1 font-mono text-sm"}),f.jsx(Sn,{"aria-label":"MCP working directory",placeholder:"Working directory (optional, inside the worker's roots)",value:e.cwd,onChange:B=>I({cwd:B.target.value}),className:"h-8 text-sm"}),f.jsxs("div",{className:"space-y-1","data-testid":"settings__mcp-env",children:[e.env.map((B,ee)=>f.jsxs("div",{className:"flex gap-2",children:[f.jsx(Sn,{"aria-label":`Environment variable ${ee+1} name`,placeholder:"NAME",value:B.name,onChange:te=>I({env:e.env.map((se,ae)=>ae===ee?{...se,name:te.target.value}:se)}),className:"h-8 text-sm"}),f.jsxs("select",{"aria-label":`Environment variable ${ee+1} source`,value:B.source,onChange:te=>I({env:e.env.map((se,ae)=>ae===ee?{...se,source:te.target.value}:se)}),className:"h-8 rounded-md border border-border bg-background px-2 text-sm",children:[f.jsx("option",{value:"value",children:"Value"}),f.jsx("option",{value:"vault",children:"Vault item"})]}),B.source==="vault"?f.jsxs("select",{"aria-label":`Environment variable ${ee+1} vault item`,value:B.vaultItemId,onChange:te=>I({env:e.env.map((se,ae)=>ae===ee?{...se,vaultItemId:te.target.value}:se)}),className:"h-8 rounded-md border border-border bg-background px-2 text-sm",children:[f.jsx("option",{value:"",children:"Choose an item"}),Z.filter(te=>te.kind==="api_key"||te.kind==="env").map(te=>f.jsx("option",{value:te.id,children:te.name},te.id))]}):f.jsx(Sn,{"aria-label":`Environment variable ${ee+1} value`,placeholder:"value",value:B.value,onChange:te=>I({env:e.env.map((se,ae)=>ae===ee?{...se,value:te.target.value}:se)}),className:"h-8 text-sm"}),f.jsx(Ce,{type:"button",variant:"outline",size:"sm","aria-label":`Remove environment variable ${ee+1}`,onClick:()=>I({env:e.env.filter((te,se)=>se!==ee)}),children:"Remove"})]},ee)),f.jsx(Ce,{type:"button",variant:"outline",size:"sm","data-testid":"settings__mcp-env-add",onClick:()=>I({env:[...e.env,{name:"",source:"value",value:"",vaultItemId:""}]}),children:"Add environment variable"})]})]}):f.jsxs(f.Fragment,{children:[f.jsx(Sn,{"aria-label":"MCP server URL",placeholder:"https://mcp.example.com/mcp",value:e.url,onChange:B=>I({url:B.target.value}),className:"h-8 text-sm"}),f.jsxs("select",{"aria-label":"MCP credential",value:e.vaultItemId,onChange:B=>I({vaultItemId:B.target.value}),className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm",children:[f.jsx("option",{value:"",children:"No credential"}),q.map(B=>f.jsxs("option",{value:B.id,children:[B.name," (",B.kind==="oauth"?"OAuth":"API key",")"]},B.id))]}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx(Sn,{"aria-label":"MCP header name",value:e.headerName,onChange:B=>I({headerName:B.target.value}),className:"h-8 text-sm"}),f.jsx(Sn,{"aria-label":"MCP header prefix",value:e.headerPrefix,onChange:B=>I({headerPrefix:B.target.value}),className:"h-8 text-sm"})]}),f.jsx(Ce,{type:"button",variant:"outline",size:"sm","data-testid":"settings__mcp-connect-oauth",disabled:A||e.url.trim()==="",onClick:()=>{G()},children:"Connect with OAuth"}),O?f.jsx("p",{className:"text-xs text-muted-foreground","data-testid":"settings__mcp-notice",children:O}):null]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Ce,{type:"button",variant:"outline",size:"sm","data-testid":"settings__mcp-test",disabled:A||!Ype({...e,name:e.name||"x"}),onClick:()=>{H()},children:"Test connection"}),c?f.jsx("span",{className:"text-xs text-muted-foreground","data-testid":"settings__mcp-test-result","data-ok":d?"true":"false",children:c}):null]}),f.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[f.jsx("input",{type:"checkbox",checked:e.allowAll,onChange:B=>I({allowAll:B.target.checked})}),"Allow every tool"]}),e.allowAll?null:f.jsxs("ul",{className:"space-y-1","data-testid":"settings__mcp-tools",children:[U.size===0?f.jsx("li",{className:"text-xs text-muted-foreground",children:"Test the connection to list the server's tools."}):null,[...U].map(B=>{const ee=a?.find(te=>te.name===B);return f.jsxs("li",{className:"text-sm",children:[f.jsxs("label",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"checkbox","aria-label":`Allow tool ${B}`,checked:e.allowed.includes(B),onChange:te=>I({allowed:L$(e.allowed,B,te.target.checked)})}),f.jsx("span",{children:B}),ee?.readOnly?f.jsx("span",{className:"text-xs text-muted-foreground",children:"read-only"}):null]}),ee?.description?f.jsx("p",{className:"ml-6 truncate text-xs text-muted-foreground",children:ee.description}):null]},B)})]}),f.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[f.jsx("input",{type:"checkbox",checked:e.readOnly,onChange:B=>I({readOnly:B.target.checked})}),"Read-only (only tools marked read-only)"]}),f.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[f.jsx("input",{type:"checkbox",checked:e.enabled,onChange:B=>I({enabled:B.target.checked})}),"Enabled"]}),f.jsxs("fieldset",{className:"space-y-1","data-testid":"settings__mcp-scope",children:[f.jsx("legend",{className:"text-sm font-medium",children:"Scope"}),[["all","All worktrees"],["repos","Selected repos"],["hosts","Selected workers"]].map(([B,ee])=>f.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[f.jsx("input",{type:"radio",name:"mcp-scope","aria-label":`Scope: ${ee}`,checked:e.scopeMode===B,onChange:()=>I({scopeMode:B})}),ee]},B)),f.jsxs("label",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[f.jsx("input",{type:"radio",name:"mcp-scope",disabled:!0,"aria-label":"Scope: Missions"}),"Missions (not available yet)"]}),e.scopeMode==="repos"?(i.data??[]).map(B=>f.jsxs("label",{className:"ml-6 flex items-center gap-2 text-sm",children:[f.jsx("input",{type:"checkbox","aria-label":`Repo ${B}`,checked:e.scopeRepos.includes(B),onChange:ee=>I({scopeRepos:L$(e.scopeRepos,B,ee.target.checked)})}),B]},B)):null,e.scopeMode==="hosts"?(s.data??[]).map(B=>f.jsxs("label",{className:"ml-6 flex items-center gap-2 text-sm",children:[f.jsx("input",{type:"checkbox","aria-label":`Worker ${B.id}`,checked:e.scopeHosts.includes(B.id),onChange:ee=>I({scopeHosts:L$(e.scopeHosts,B.id,ee.target.checked)})}),B.id]},B.id)):null]}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx(Ce,{type:"button",size:"sm","data-testid":"settings__mcp-save",disabled:A||!Ype(e),onClick:()=>{N()},children:"Save"}),f.jsx(Ce,{type:"button",variant:"outline",size:"sm",onClick:()=>{P(),n(null)},children:"Cancel"})]})]})}):null,_?f.jsx(jwn,{server:_}):null,y?f.jsx("p",{role:"alert",className:"text-xs text-destructive","data-testid":"settings__mcp-error",children:y}):null]})}function jwn({server:t}){const e=Dye({queryKey:["mcp.audit",t],initialPageParam:0,queryFn:({pageParam:r})=>Se.mcp.audit.query({server:t,limit:Zpe,offset:r}),getNextPageParam:(r,o)=>r.hasMore?o.length*Zpe:void 0,refetchInterval:5e3}),n=e.data?.pages.flatMap(r=>r.entries)??[];return f.jsxs(_n,{variant:"stacked",label:`Audit log of ${t}`,description:"Tool calls made through the proxy. Arguments and results are not stored.",children:[f.jsxs("ul",{className:"divide-y divide-border rounded-md border border-border",children:[n.length===0?f.jsx("li",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No calls yet."}):null,n.map(r=>f.jsxs("li",{"data-testid":"settings__mcp-audit-entry","data-ok":r.ok?"true":"false",className:"px-3 py-2 text-xs",children:[f.jsx("span",{"data-testid":"settings__mcp-audit-tool",className:"text-sm",children:r.tool})," ",f.jsx("span",{children:r.ok?"ok":`failed: ${r.error??"error"}`}),f.jsxs("div",{className:"text-muted-foreground",children:["Session ",f.jsx("span",{"data-testid":"settings__mcp-audit-session",children:r.sessionId})," ·"," ",new Date(r.at).toLocaleString()]})]},r.id))]}),e.hasNextPage?f.jsx(Ce,{type:"button",variant:"outline",size:"sm",className:"mt-2",disabled:e.isFetchingNextPage,onClick:()=>{e.fetchNextPage()},children:"Load more"}):null]})}function cHe(t,e){const n=Rn(),[r,o]=v.useState(null),[i,s]=v.useState(!1);return{error:r,saving:i,change:async l=>{o(null),s(!0);try{await Se.repos.update.mutate({name:t,[e]:l}),await n.invalidateQueries({queryKey:["repos"]})}catch(c){o(Zx(c))}finally{s(!1)}}}}function Nwn({repo:t}){const e=fu(),{error:n,saving:r,change:o}=cHe(t.name,"checkpointsEnabled"),i=t.checkpointsEnabled??!t.allowedHostIds,s=(t.checkpointsSetting??null)===null,a=`settings-repo-${t.name}-checkpoints`;return f.jsxs(Fc,{htmlFor:a,label:"Checkpoints on the hub",description:"Recent snapshots of each worktree, so another worker can continue it.",children:[f.jsx(Hi,{id:a,checked:i,disabled:!e||r,"aria-label":`Checkpoints on the hub for ${t.name}`,"data-testid":"settings-repo__checkpoints-switch",onCheckedChange:l=>{o(l)}}),f.jsx("span",{className:"text-xs text-muted-foreground","data-testid":"settings-repo__checkpoints-note","data-default":s?i?"all-workers":"limited":"stored",children:s?i?"On by default for a repo allowed on all workers":"Off by default for a limited repo, so its code stays on its workers":i?"On":"Off"}),e?null:f.jsx(W0,{children:"Changing this needs an admin token."}),n?f.jsx("p",{role:"alert",className:"w-full text-xs text-destructive","data-testid":"settings-repo__checkpoints-error",children:n}):null]})}function Rwn({repo:t}){const e=fu(),{error:n,saving:r,change:o}=cHe(t.name,"autoContinue"),i=t.allowedHostIds?.length===1,s=!i&&(t.autoContinue??!1),a=`settings-repo-${t.name}-auto-continue`;return f.jsxs(Fc,{htmlFor:a,label:"Continue automatically",description:i?"Needs another allowed worker.":"Move a worktree to another worker when its worker is offline, if the checkpoint is under 30 minutes old.",children:[f.jsx(Hi,{id:a,checked:s,disabled:!e||r||i,"aria-label":`Continue on another worker automatically for ${t.name}`,"data-testid":"settings-repo__auto-continue-switch",onCheckedChange:l=>{o(l)}}),i?f.jsx(W0,{testId:"settings-repo__auto-continue-unavailable",children:"Unavailable"}):null,e||i?null:f.jsx(W0,{children:"Changing this needs an admin token."}),n?f.jsx("p",{role:"alert",className:"w-full text-xs text-destructive","data-testid":"settings-repo__auto-continue-error",children:n}):null]})}const _3=(t,e)=>`${t} ${e}${t===1?"":"s"}`;function Lwn(t){const e=Math.round((Date.now()-t)/6e4);if(e<1)return"just now";if(e<60)return`${_3(e,"minute")} ago`;const n=Math.round(e/60);return n<24?`${_3(n,"hour")} ago`:`${_3(Math.round(n/24),"day")} ago`}function Iwn(t){const e=[],n=t.build;n?.devcontainer?e.push("devcontainer"):n?.dockerfile?e.push("Dockerfile"):n?.image&&e.push(`image ${n.image}`),t.install&&e.push("install"),t.start&&e.push("start"),t.teardown&&e.push("teardown"),t.terminals?.length&&e.push(_3(t.terminals.length,"terminal"));const r=Object.keys(t.services??{}).length;r&&e.push(_3(r,"service")),t.secrets?.length&&e.push(_3(t.secrets.length,"secret")),t.isolation&&e.push(`${t.isolation} isolation`);const o=Object.entries(t.requires??{}).map(([i,s])=>`${i} ${s}`).join(", ");return o&&e.push(`requires ${o}`),e.join(", ")||"nothing"}function Dwn(t){return[t.install?`install: ${t.install}`:"",t.start?`start: ${t.start}`:"",t.teardown?`teardown: ${t.teardown}`:"",...(t.terminals??[]).map(e=>`${e.name}: ${e.command}`)].filter(Boolean).join(`
@@ -965,7 +965,7 @@ ${t}</tr>
965
965
  `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${T1(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){const r=this.parser.parseInline(n),o=H3e(t);if(o===null)return r;t=o;let i='<a href="'+t+'"';return e&&(i+=' title="'+T1(e)+'"'),i+=">"+r+"</a>",i}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));const o=H3e(t);if(o===null)return T1(n);t=o;let i=`<img src="${t}" alt="${n}"`;return e&&(i+=` title="${T1(e)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:T1(t.text)}},nte=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}},A2=class vU{options;renderer;textRenderer;constructor(e){this.options=e||Z4,this.options.renderer=this.options.renderer||new iT,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new nte}static parse(e,n){return new vU(n).parse(e)}static parseInline(e,n){return new vU(n).parseInline(e)}parse(e,n=!0){let r="";for(let o=0;o<e.length;o++){const i=e[o];if(this.options.extensions?.renderers?.[i.type]){const a=i,l=this.options.extensions.renderers[a.type].call({parser:this},a);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(a.type)){r+=l||"";continue}}const s=i;switch(s.type){case"space":{r+=this.renderer.space(s);continue}case"hr":{r+=this.renderer.hr(s);continue}case"heading":{r+=this.renderer.heading(s);continue}case"code":{r+=this.renderer.code(s);continue}case"table":{r+=this.renderer.table(s);continue}case"blockquote":{r+=this.renderer.blockquote(s);continue}case"list":{r+=this.renderer.list(s);continue}case"html":{r+=this.renderer.html(s);continue}case"paragraph":{r+=this.renderer.paragraph(s);continue}case"text":{let a=s,l=this.renderer.text(a);for(;o+1<e.length&&e[o+1].type==="text";)a=e[++o],l+=`
966
966
  `+this.renderer.text(a);n?r+=this.renderer.paragraph({type:"paragraph",raw:l,text:l,tokens:[{type:"text",raw:l,text:l,escaped:!0}]}):r+=l;continue}default:{const a='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return r}parseInline(e,n=this.renderer){let r="";for(let o=0;o<e.length;o++){const i=e[o];if(this.options.extensions?.renderers?.[i.type]){const a=this.options.extensions.renderers[i.type].call({parser:this},i);if(a!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){r+=a||"";continue}}const s=i;switch(s.type){case"escape":{r+=n.text(s);break}case"html":{r+=n.html(s);break}case"link":{r+=n.link(s);break}case"image":{r+=n.image(s);break}case"strong":{r+=n.strong(s);break}case"em":{r+=n.em(s);break}case"codespan":{r+=n.codespan(s);break}case"br":{r+=n.br(s);break}case"del":{r+=n.del(s);break}case"text":{r+=n.text(s);break}default:{const a='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return r}},FS=class{options;block;constructor(t){this.options=t||Z4}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?C2.lex:C2.lexInline}provideParser(){return this.block?A2.parse:A2.parseInline}},aFe=class{defaults=Zee();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=A2;Renderer=iT;TextRenderer=nte;Lexer=C2;Tokenizer=oT;Hooks=FS;constructor(...t){this.use(...t)}walkTokens(t,e){let n=[];for(const r of t)switch(n=n.concat(e.call(this,r)),r.type){case"table":{const o=r;for(const i of o.header)n=n.concat(this.walkTokens(i.tokens,e));for(const i of o.rows)for(const s of i)n=n.concat(this.walkTokens(s.tokens,e));break}case"list":{const o=r;n=n.concat(this.walkTokens(o.items,e));break}default:{const o=r;this.defaults.extensions?.childTokens?.[o.type]?this.defaults.extensions.childTokens[o.type].forEach(i=>{const s=o[i].flat(1/0);n=n.concat(this.walkTokens(s,e))}):o.tokens&&(n=n.concat(this.walkTokens(o.tokens,e)))}}return n}use(...t){const e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{const r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if("renderer"in o){const i=e.renderers[o.name];i?e.renderers[o.name]=function(...s){let a=o.renderer.apply(this,s);return a===!1&&(a=i.apply(this,s)),a}:e.renderers[o.name]=o.renderer}if("tokenizer"in o){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const i=e[o.level];i?i.unshift(o.tokenizer):e[o.level]=[o.tokenizer],o.start&&(o.level==="block"?e.startBlock?e.startBlock.push(o.start):e.startBlock=[o.start]:o.level==="inline"&&(e.startInline?e.startInline.push(o.start):e.startInline=[o.start]))}"childTokens"in o&&o.childTokens&&(e.childTokens[o.name]=o.childTokens)}),r.extensions=e),n.renderer){const o=this.defaults.renderer||new iT(this.defaults);for(const i in n.renderer){if(!(i in o))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;const s=i,a=n.renderer[s],l=o[s];o[s]=(...c)=>{let u=a.apply(o,c);return u===!1&&(u=l.apply(o,c)),u||""}}r.renderer=o}if(n.tokenizer){const o=this.defaults.tokenizer||new oT(this.defaults);for(const i in n.tokenizer){if(!(i in o))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;const s=i,a=n.tokenizer[s],l=o[s];o[s]=(...c)=>{let u=a.apply(o,c);return u===!1&&(u=l.apply(o,c)),u}}r.tokenizer=o}if(n.hooks){const o=this.defaults.hooks||new FS;for(const i in n.hooks){if(!(i in o))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;const s=i,a=n.hooks[s],l=o[s];FS.passThroughHooks.has(i)?o[s]=c=>{if(this.defaults.async)return Promise.resolve(a.call(o,c)).then(d=>l.call(o,d));const u=a.call(o,c);return l.call(o,u)}:o[s]=(...c)=>{let u=a.apply(o,c);return u===!1&&(u=l.apply(o,c)),u}}r.hooks=o}if(n.walkTokens){const o=this.defaults.walkTokens,i=n.walkTokens;r.walkTokens=function(s){let a=[];return a.push(i.call(this,s)),o&&(a=a.concat(o.call(this,s))),a}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return C2.lex(t,e??this.defaults)}parser(t,e){return A2.parse(t,e??this.defaults)}parseMarkdown(t){return(n,r)=>{const o={...r},i={...this.defaults,...o},s=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&o.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));i.hooks&&(i.hooks.options=i,i.hooks.block=t);const a=i.hooks?i.hooks.provideLexer():t?C2.lex:C2.lexInline,l=i.hooks?i.hooks.provideParser():t?A2.parse:A2.parseInline;if(i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(n):n).then(c=>a(c,i)).then(c=>i.hooks?i.hooks.processAllTokens(c):c).then(c=>i.walkTokens?Promise.all(this.walkTokens(c,i.walkTokens)).then(()=>c):c).then(c=>l(c,i)).then(c=>i.hooks?i.hooks.postprocess(c):c).catch(s);try{i.hooks&&(n=i.hooks.preprocess(n));let c=a(n,i);i.hooks&&(c=i.hooks.processAllTokens(c)),i.walkTokens&&this.walkTokens(c,i.walkTokens);let u=l(c,i);return i.hooks&&(u=i.hooks.postprocess(u)),u}catch(c){return s(c)}}}onError(t,e){return n=>{if(n.message+=`
967
967
  Please report this to https://github.com/markedjs/marked.`,t){const r="<p>An error occurred:</p><pre>"+T1(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},a4=new aFe;function co(t,e){return a4.parse(t,e)}co.options=co.setOptions=function(t){return a4.setOptions(t),co.defaults=a4.defaults,YHe(co.defaults),co};co.getDefaults=Zee;co.defaults=Z4;co.use=function(...t){return a4.use(...t),co.defaults=a4.defaults,YHe(co.defaults),co};co.walkTokens=function(t,e){return a4.walkTokens(t,e)};co.parseInline=a4.parseInline;co.Parser=A2;co.parser=A2.parse;co.Renderer=iT;co.TextRenderer=nte;co.Lexer=C2;co.lexer=C2.lex;co.Tokenizer=oT;co.Hooks=FS;co.parse=co;co.options;co.setOptions;co.use;co.walkTokens;co.parseInline;A2.parse;C2.lex;class V3e{constructor(e,n,r){this.from=e,this.to=n,this.diagnostic=r}}class Vp{constructor(e,n,r){this.diagnostics=e,this.panel=n,this.selected=r}static init(e,n,r){let o=r.facet(k_).markerFilter;o&&(e=o(e,r));let i=e.slice().sort((p,g)=>p.from-g.from||p.to-g.to),s=new Ua,a=[],l=0,c=r.doc.iter(),u=0,d=r.doc.length;for(let p=0;;){let g=p==i.length?null:i[p];if(!g&&!a.length)break;let _,x;if(a.length)_=l,x=a.reduce((O,C)=>Math.min(O,C.to),g&&g.from>_?g.from:1e8);else{if(_=g.from,_>d)break;x=g.to,a.push(g),p++}for(;p<i.length;){let O=i[p];if(O.from==_&&(O.to>O.from||O.to==_))a.push(O),p++,x=Math.min(O.to,x);else{x=Math.min(O.from,x);break}}x=Math.min(x,d);let y=!1;if(a.some(O=>O.from==_&&(O.to==x||x==d))&&(y=_==x,!y&&x-_<10)){let O=_-(u+c.value.length);O>0&&(c.next(O),u=_);for(let C=_;;){if(C>=x){y=!0;break}if(!c.lineBreak&&u+c.value.length>C)break;C=u+c.value.length,u+=c.value.length,c.next()}}let k=XSn(a);if(y)s.add(_,_,yt.widget({widget:new WSn(k),diagnostics:a.slice()}));else{let O=a.reduce((C,A)=>A.markClass?C+" "+A.markClass:C,"");s.add(_,x,yt.mark({class:"cm-lintRange cm-lintRange-"+k+O,diagnostics:a.slice(),inclusiveEnd:a.some(C=>C.to>x)}))}if(l=x,l==d)break;for(let O=0;O<a.length;O++)a[O].to<=l&&a.splice(O--,1)}let h=s.finish();return new Vp(h,n,xg(h))}}function xg(t,e=null,n=0){let r=null;return t.between(n,1e9,(o,i,{spec:s})=>{if(!(e&&s.diagnostics.indexOf(e)<0))if(!r)r=new V3e(o,i,e||s.diagnostics[0]);else{if(s.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new V3e(r.from,i,r.diagnostic)}}),r}function HSn(t,e){let n=e.pos,r=e.end||n,o=t.state.facet(k_).hideOn(t,n,r);if(o!=null)return o;let i=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(s=>s.is(rte))||t.changes.touchesRange(i.from,Math.max(i.to,r)))}function FSn(t,e){return t.field(N0,!1)?e:e.concat(xn.appendConfig.of(KSn))}function qSn(t,e){return{effects:FSn(t,[rte.of(e)])}}const rte=xn.define(),lFe=xn.define(),cFe=xn.define(),N0=to.define({create(){return new Vp(yt.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let n=t.diagnostics.map(e.changes),r=null,o=t.panel;if(t.selected){let i=e.changes.mapPos(t.selected.from,1);r=xg(n,t.selected.diagnostic,i)||xg(n,null,i)}!n.size&&o&&e.state.facet(k_).autoPanel&&(o=null),t=new Vp(n,o,r)}for(let n of e.effects)if(n.is(rte)){let r=e.state.facet(k_).autoPanel?n.value.length?sT.open:null:t.panel;t=Vp.init(n.value,r,e.state)}else n.is(lFe)?t=new Vp(t.diagnostics,n.value?sT.open:null,t.selected):n.is(cFe)&&(t=new Vp(t.diagnostics,t.panel,n.value));return t},provide:t=>[Ob.from(t,e=>e.panel),ft.decorations.from(t,e=>e.diagnostics)]}),VSn=yt.mark({class:"cm-lintRange cm-lintRange-active"});function QSn(t,e,n){let{diagnostics:r}=t.state.field(N0),o,i=-1,s=-1;r.between(e-(n<0?1:0),e+(n>0?1:0),(l,c,{spec:u})=>{if(e>=l&&e<=c&&(l==c||(e>l||n>0)&&(e<c||n<0)))return o=u.diagnostics,i=l,s=c,!1});let a=t.state.facet(k_).tooltipFilter;return o&&a&&(o=a(o,t.state)),o?{pos:i,end:s,above:t.state.doc.lineAt(i).to<s,create(){return{dom:USn(t,o)}}}:null}function USn(t,e){return oa("ul",{class:"cm-tooltip-lint"},e.map(n=>dFe(t,n,!1)))}const Q3e=t=>{let e=t.state.field(N0,!1);return!e||!e.panel?!1:(t.dispatch({effects:lFe.of(!1)}),!0)},k_=Ft.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...M4(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:U3e,tooltipFilter:U3e,needsRefresh:(e,n)=>e?n?r=>e(r)||n(r):e:n,hideOn:(e,n)=>e?n?(r,o,i)=>e(r,o,i)||n(r,o,i):e:n,autoPanel:(e,n)=>e||n})}}});function U3e(t,e){return t?e?(n,r)=>e(t(n,r),r):t:e}function uFe(t){let e=[];if(t)e:for(let{name:n}of t){for(let r=0;r<n.length;r++){let o=n[r];if(/[a-zA-Z]/.test(o)&&!e.some(i=>i.toLowerCase()==o.toLowerCase())){e.push(o);continue e}}e.push("")}return e}function dFe(t,e,n){var r;let o=n?uFe(e.actions):[];return oa("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},oa("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(r=e.actions)===null||r===void 0?void 0:r.map((i,s)=>{let a=!1,l=p=>{if(p.preventDefault(),a)return;a=!0;let g=xg(t.state.field(N0).diagnostics,e);g&&i.apply(t,g.from,g.to)},{name:c}=i,u=o[s]?c.indexOf(o[s]):-1,d=u<0?c:[c.slice(0,u),oa("u",c.slice(u,u+1)),c.slice(u+1)],h=i.markClass?" "+i.markClass:"";return oa("button",{type:"button",class:"cm-diagnosticAction"+h,onclick:l,onmousedown:l,"aria-label":` Action: ${c}${u<0?"":` (access key "${o[s]})"`}.`},d)}),e.source&&oa("div",{class:"cm-diagnosticSource"},e.source))}class WSn extends rs{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return oa("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class W3e{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=dFe(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class sT{constructor(e){this.view=e,this.items=[];let n=o=>{if(!(o.ctrlKey||o.altKey||o.metaKey)){if(o.keyCode==27)Q3e(this.view),this.view.focus();else if(o.keyCode==38||o.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(o.keyCode==40||o.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(o.keyCode==36)this.moveSelection(0);else if(o.keyCode==35)this.moveSelection(this.items.length-1);else if(o.keyCode==13)this.view.focus();else if(o.keyCode>=65&&o.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:i}=this.items[this.selectedIndex],s=uFe(i.actions);for(let a=0;a<s.length;a++)if(s[a].toUpperCase().charCodeAt(0)==o.keyCode){let l=xg(this.view.state.field(N0).diagnostics,i);l&&i.actions[a].apply(e,l.from,l.to)}}else return;o.preventDefault()}},r=o=>{for(let i=0;i<this.items.length;i++)this.items[i].dom.contains(o.target)&&this.moveSelection(i)};this.list=oa("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:r}),this.dom=oa("div",{class:"cm-panel-lint"},this.list,oa("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>Q3e(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(N0).selected;if(!e)return-1;for(let n=0;n<this.items.length;n++)if(this.items[n].diagnostic==e.diagnostic)return n;return-1}update(){let{diagnostics:e,selected:n}=this.view.state.field(N0),r=0,o=!1,i=null,s=new Set;for(e.between(0,this.view.state.doc.length,(a,l,{spec:c})=>{for(let u of c.diagnostics){if(s.has(u))continue;s.add(u);let d=-1,h;for(let p=r;p<this.items.length;p++)if(this.items[p].diagnostic==u){d=p;break}d<0?(h=new W3e(this.view,u),this.items.splice(r,0,h),o=!0):(h=this.items[d],d>r&&(this.items.splice(r,d-r),o=!0)),n&&h.diagnostic==n.diagnostic?h.dom.hasAttribute("aria-selected")||(h.dom.setAttribute("aria-selected","true"),i=h):h.dom.hasAttribute("aria-selected")&&h.dom.removeAttribute("aria-selected"),r++}});r<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)o=!0,this.items.pop();this.items.length==0&&(this.items.push(new W3e(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),o=!0),i?(this.list.setAttribute("aria-activedescendant",i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:a,panel:l})=>{let c=l.height/this.list.offsetHeight;a.top<l.top?this.list.scrollTop-=(l.top-a.top)/c:a.bottom>l.bottom&&(this.list.scrollTop+=(a.bottom-l.bottom)/c)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),o&&this.sync()}sync(){let e=this.list.firstChild;function n(){let r=e;e=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;e!=r.dom;)n();e=r.dom.nextSibling}else this.list.insertBefore(r.dom,e);for(;e;)n()}moveSelection(e){if(this.selectedIndex<0)return;let n=this.view.state.field(N0),r=xg(n.diagnostics,this.items[e].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:cFe.of(r)})}static open(e){return new sT(e)}}function ZSn(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function uO(t){return ZSn(`<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"')}const GSn=ft.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:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:uO("#d11")},".cm-lintRange-warning":{backgroundImage:uO("orange")},".cm-lintRange-info":{backgroundImage:uO("#999")},".cm-lintRange-hint":{backgroundImage:uO("#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 YSn(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function XSn(t){let e="hint",n=1;for(let r of t){let o=YSn(r.severity);o>n&&(n=o,e=r.severity)}return e}const KSn=[N0,ft.decorations.compute([N0],t=>{let{selected:e,panel:n}=t.field(N0);return!e||!n||e.from==e.to?yt.none:yt.set([VSn.range(e.from,e.to)])}),tke(QSn,{hideOn:HSn}),GSn];let Af=null;function JSn(t,e,n){let r=Af;try{return Af={view:t,language:e},n()}finally{Af=r}}const eCn=new aFe({walkTokens(t){if(!Af||t.type!="code")return;let e=Af.language&&Af.language(t.lang);if(!e){let o=Af.view.state.facet(Qc);o&&o.name==t.lang&&(e=o)}if(!e)return;let n={style:o=>oY(Af.view.state,o)},r="";gke(t.text,e.parser.parse(t.text),n,(o,i)=>{r+=i?`<span class="${i}">${_6(o)}</span>`:_6(o)},()=>{r+="<br>"}),t.escaped=!0,t.text=r}});function _6(t){return t.replace(/[\n<&]/g,e=>e==`
968
- `?"<br>":e=="<"?"&lt;":"&amp;")}function tCn(t,e){let n=e,r=t;return typeof r!="string"&&(n=r.kind,r=r.value),n=="plaintext"?_6(r):eCn.parse(r,{async:!1})}function bU(t,e){let n=t.lineAt(e);return{line:n.number-1,character:e-n.from}}function aT(t,e){return t.line(e.line+1).from+e.character}class ws{constructor(e,{client:n,uri:r,languageID:o}){if(this.view=e,this.client=n,this.uri=r,!o){let i=e.state.facet(Qc);o=i?i.name:""}n.workspace.openFile(r,o,e),this.syncedDoc=e.state.doc,this.unsyncedChanges=Do.empty(e.state.doc.length)}docToHTML(e,n="plaintext"){let r=JSn(this.view,this.client.config.highlightLanguage,()=>tCn(e,n));return this.client.config.sanitizeHTML?this.client.config.sanitizeHTML(r):r}toPosition(e,n=this.view.state.doc){return bU(n,e)}fromPosition(e,n=this.view.state.doc){return aT(n,e)}reportError(e,n){WG(this.view,{label:this.view.state.phrase(e)+": "+(n.message||n),class:"cm-lsp-message cm-lsp-message-error",top:!0})}clear(){this.syncedDoc=this.view.state.doc,this.unsyncedChanges=Do.empty(this.view.state.doc.length)}update(e){e.docChanged&&(this.unsyncedChanges=this.unsyncedChanges.compose(e.changes))}destroy(){this.client.workspace.closeFile(this.uri,this.view)}static get(e){return e.plugin(fFe)}static create(e,n,r){return e.plugin(n,r)}}const fFe=oi.fromClass(ws);class hFe{constructor(e){this.client=e}getFile(e){return this.files.find(n=>n.uri==e)||null}requestFile(e){return Promise.resolve(this.getFile(e))}connected(){for(let e of this.files)this.client.didOpen(e)}disconnected(){}updateFile(e,n){var r;let o=this.getFile(e);o&&((r=o.getView())===null||r===void 0||r.dispatch(n))}displayFile(e){let n=this.getFile(e);return Promise.resolve(n?n.getView():null)}}class nCn{constructor(e,n,r,o,i){this.uri=e,this.languageId=n,this.version=r,this.doc=o,this.view=i}getView(){return this.view}}class rCn extends hFe{constructor(){super(...arguments),this.files=[],this.fileVersions=Object.create(null)}nextFileVersion(e){var n;return this.fileVersions[e]=((n=this.fileVersions[e])!==null&&n!==void 0?n:-1)+1}syncFiles(){let e=[];for(let n of this.files){let r=ws.get(n.view);if(!r)continue;let o=r.unsyncedChanges;o.empty||(e.push({changes:o,file:n,prevDoc:n.doc}),n.doc=n.view.state.doc,n.version=this.nextFileVersion(n.uri),r.clear())}return e}openFile(e,n,r){if(this.getFile(e))throw new Error("Default workspace implementation doesn't support multiple views on the same file");let o=new nCn(e,n,this.nextFileVersion(e),r.state.doc,r);this.files.push(o),this.client.didOpen(o)}closeFile(e){let n=this.getFile(e);n&&(this.files=this.files.filter(r=>r!=n),this.client.didClose(e))}}const oCn=ft.baseTheme({".cm-lsp-documentation":{padding:"0 7px","& p, & pre":{margin:"2px 0"}},".cm-lsp-signature-tooltip":{padding:"2px 6px",borderRadius:"2.5px",position:"relative",maxWidth:"30em",maxHeight:"10em",overflowY:"scroll","& .cm-lsp-documentation":{padding:"0",fontSize:"80%"},"& .cm-lsp-signature-num":{fontFamily:"monospace",position:"absolute",left:"2px",top:"4px",fontSize:"70%",lineHeight:"1.3"},"& .cm-lsp-signature":{fontFamily:"monospace",textIndent:"1em hanging"},"& .cm-lsp-active-parameter":{fontWeight:"bold"}},".cm-lsp-signature-multiple":{paddingLeft:"1.5em"},".cm-panel.cm-lsp-rename-panel":{padding:"2px 6px 4px",position:"relative","& label":{fontSize:"80%"},"& [name=close]":{position:"absolute",top:"0",bottom:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:"0"}},".cm-lsp-message button[type=submit]":{display:"block"},".cm-lsp-reference-panel":{fontFamily:"monospace",whiteSpace:"pre",padding:"3px 6px",maxHeight:"120px",overflow:"auto","& .cm-lsp-reference-file":{fontWeight:"bold"},"& .cm-lsp-reference":{cursor:"pointer","&[aria-selected]":{backgroundColor:"#0077ee44"}},"& .cm-lsp-reference-line":{opacity:"0.7"}}});class iCn{constructor(e,n,r){this.id=e,this.params=n,this.timeout=r,this.promise=new Promise((o,i)=>{this.resolve=o,this.reject=i})}}const sCn={general:{markdown:{parser:"marked"}},textDocument:{completion:{completionItem:{snippetSupport:!0,documentationFormat:["plaintext","markdown"],insertReplaceSupport:!1},completionList:{itemDefaults:["commitCharacters","editRange","insertTextFormat"]},completionItemKind:{valueSet:[]},contextSupport:!0},hover:{contentFormat:["markdown","plaintext"]},formatting:{},rename:{},signatureHelp:{contextSupport:!0,signatureInformation:{documentationFormat:["markdown","plaintext"],parameterInformation:{labelOffsetSupport:!0},activeParameterSupport:!0}},definition:{},declaration:{},implementation:{},typeDefinition:{},references:{},diagnostic:{}},window:{showMessage:{}}};class aCn{constructor(e){this.client=e,this.mappings=new Map,this.startDocs=new Map;for(let n of e.workspace.files)this.mappings.set(n.uri,Do.empty(n.doc.length)),this.startDocs.set(n.uri,n.doc)}addChanges(e,n){let r=this.mappings.get(e);r&&this.mappings.set(e,r.composeDesc(n))}getMapping(e){let n=this.mappings.get(e);if(!n)return null;let r=this.client.workspace.getFile(e),o=r?.getView(),i=o&&ws.get(o);return i?n.composeDesc(i.unsyncedChanges):n}mapPos(e,n,r=-1,o=Zi.Simple){let i=this.getMapping(e);return i?i.mapPos(n,r,o):n}mapPosition(e,n,r=-1,o=Zi.Simple){let i=this.startDocs.get(e);if(!i)throw new Error("Cannot map from a file that's not in the workspace");let s=aT(i,n),a=this.getMapping(e);return a?a.mapPos(s,r,o):s}destroy(){this.client.activeMappings=this.client.activeMappings.filter(e=>e!=this)}}const lCn={"window/logMessage":(t,e)=>{e.type==1?console.error("[lsp] "+e.message):e.type==2&&console.warn("[lsp] "+e.message)},"window/showMessage":(t,e)=>{if(e.type>3)return;let n;for(let r of t.workspace.files)if(n=r.getView())break;n&&WG(n,{label:e.message,class:"cm-lsp-message cm-lsp-message-"+(e.type==1?"error":e.type==2?"warning":"info"),top:!0})}};class cCn{constructor(e={}){var n;if(this.config=e,this.transport=null,this.nextReqID=0,this.requests=[],this.activeMappings=[],this.serverCapabilities=null,this.supportSync=-1,this.extensions=[],this.receiveMessage=this.receiveMessage.bind(this),this.initializing=new Promise((r,o)=>this.init={resolve:r,reject:o}),this.timeout=(n=e.timeout)!==null&&n!==void 0?n:3e3,this.workspace=e.workspace?e.workspace(this):new rCn(this),e.extensions)for(let r of e.extensions)Array.isArray(r)||r.extension?this.extensions.push(r):r.editorExtension&&this.extensions.push(r.editorExtension)}get connected(){return!!this.transport}connect(e){this.transport&&this.transport.unsubscribe(this.receiveMessage),this.transport=e,e.subscribe(this.receiveMessage);let n=sCn;if(this.config.extensions)for(let r of this.config.extensions){let{clientCapabilities:o}=r;o&&(n=pFe(n,o))}return this.requestInner("initialize",{processId:null,clientInfo:{name:"@codemirror/lsp-client"},rootUri:this.config.rootUri||null,capabilities:n}).promise.then(r=>{var o;this.serverCapabilities=r.capabilities;let i=r.capabilities.textDocumentSync;this.supportSync=i==null?0:typeof i=="number"?i:(o=i.change)!==null&&o!==void 0?o:0,e.send(JSON.stringify({jsonrpc:"2.0",method:"initialized",params:{}})),this.init.resolve(null)},this.init.reject),this.workspace.connected(),this}disconnect(){this.transport&&this.transport.unsubscribe(this.receiveMessage),this.serverCapabilities=null,this.initializing=new Promise((e,n)=>this.init={resolve:e,reject:n}),this.workspace.disconnected()}plugin(e,n){return[fFe.of({client:this,uri:e,languageID:n}),oCn,this.extensions]}didOpen(e){this.notification("textDocument/didOpen",{textDocument:{uri:e.uri,languageId:e.languageId,text:e.doc.toString(),version:e.version}})}didClose(e){this.notification("textDocument/didClose",{textDocument:{uri:e}})}receiveMessage(e){var n;const r=JSON.parse(e);if("id"in r&&!("method"in r)){let o=this.requests.findIndex(i=>i.id==r.id);if(o<0)console.warn(`[lsp] Received a response for non-existent request ${r.id}`);else{let i=this.requests[o];clearTimeout(i.timeout),this.requests.splice(o,1),r.error?i.reject(r.error):i.resolve(r.result)}}else if("id"in r){let o={jsonrpc:"2.0",id:r.id,error:{code:-32601,message:"Method not implemented"}};this.transport.send(JSON.stringify(o))}else{let o=(n=this.config.notificationHandlers)===null||n===void 0?void 0:n[r.method];if(o&&o(this,r.params))return;if(this.config.extensions)for(let s of this.config.extensions){let{notificationHandlers:a}=s,l=a?.[r.method];if(l&&l(this,r.params))return}let i=lCn[r.method];i?i(this,r.params):this.config.unhandledNotification&&this.config.unhandledNotification(this,r.method,r.params)}}request(e,n){return this.transport?this.initializing.then(()=>this.requestInner(e,n).promise):Promise.reject(new Error("Client not connected"))}requestInner(e,n,r=!1){let o=++this.nextReqID,i={jsonrpc:"2.0",id:o,method:e,params:n},s=new iCn(o,n,setTimeout(()=>this.timeoutRequest(s),this.timeout));this.requests.push(s);try{this.transport.send(JSON.stringify(i))}catch(a){s.reject(a)}return s}notification(e,n){this.transport&&this.initializing.then(()=>{let r={jsonrpc:"2.0",method:e,params:n};this.transport.send(JSON.stringify(r))})}cancelRequest(e){let n=this.requests.find(r=>r.params===e);n&&this.notification("$/cancelRequest",{id:n.id})}hasCapability(e){return this.serverCapabilities?!!this.serverCapabilities[e]:null}workspaceMapping(){let e=new aCn(this);return this.activeMappings.push(e),e}withMapping(e){let n=this.workspaceMapping();return e(n).finally(()=>n.destroy())}sync(){for(let{file:e,changes:n,prevDoc:r}of this.workspace.syncFiles()){for(let o of this.activeMappings)o.addChanges(e.uri,n);this.supportSync&&this.notification("textDocument/didChange",{textDocument:{uri:e.uri,version:e.version},contentChanges:uCn(e,r,n,this.supportSync==2)})}}timeoutRequest(e){let n=this.requests.indexOf(e);n>-1&&(e.reject(new Error("Request timed out")),this.requests.splice(n,1))}}function uCn(t,e,n,r){if(!r||t.doc.length<1024)return[{text:t.doc.toString()}];let o=[];return n.iterChanges((i,s,a,l,c)=>{o.push({range:{start:bU(e,i),end:bU(e,s)},text:c.toString()})}),o.reverse()}function pFe(t,e){if(e==null)return t;if(typeof t!="object"||typeof e!="object")return e;let n={},r=Object.keys(t),o=Object.keys(e);for(let i of r)n[i]=o.indexOf(i)>-1?pFe(t[i],e[i]):t[i];for(let i of o)r.indexOf(i)<0&&(n[i]=e[i]);return n}function dCn(t={}){let e;if(t.override)e=[Yce({override:[Z3e]})];else{let n=[{autocomplete:Z3e}];e=[Yce(),Gn.languageData.of(()=>n)]}return t.validFor&&e.push(mFe.of({validFor:t.validFor})),e}const mFe=Ft.define({combine:t=>t.length?t[0]:{validFor:null}});function fCn(t,e,n,r){if(t.client.hasCapability("completionProvider")===!1)return Promise.resolve(null);t.client.sync();let o={position:t.toPosition(e),textDocument:{uri:t.uri},context:n};return r&&r.addEventListener("abort",()=>t.client.cancelRequest(o)),t.client.request("textDocument/completion",o)}function hCn(t){var e;let n=Math.ceil(t.length/50),r=[];for(let o=0;o<t.length;o+=n){let i=t[o],s=((e=i.textEdit)===null||e===void 0?void 0:e.newText)||i.textEditText||i.insertText||i.label;if(!/^\w/.test(s)){let a=/^[^\w]*/.exec(s)[0];r.indexOf(a)<0&&r.push(a)}}return r.length?new RegExp("^(?:"+r.map(RegExp.escape||(o=>o.replace(/[^\w\s]/g,"\\$&"))).join("|")+")?\\w*$"):/^\w*$/}const Z3e=t=>{var e,n;const r=t.view&&ws.get(t.view);if(!r)return null;let o="";if(!t.explicit){o=t.view.state.sliceDoc(t.pos-1,t.pos);let i=(n=(e=r.client.serverCapabilities)===null||e===void 0?void 0:e.completionProvider)===null||n===void 0?void 0:n.triggerCharacters;if(!/[a-zA-Z_]/.test(o)&&!(i&&i.indexOf(o)>-1))return null}return fCn(r,t.pos,{triggerCharacter:o,triggerKind:t.explicit?1:2},t).then(i=>{var s,a;if(!i)return null;Array.isArray(i)&&(i={items:i});let{from:l,to:c}=pCn(t,i),u=(s=i.itemDefaults)===null||s===void 0?void 0:s.commitCharacters,d=t.state.facet(mFe);return{from:l,to:c,options:i.items.map(h=>{var p;let g=((p=h.textEdit)===null||p===void 0?void 0:p.newText)||h.textEditText||h.insertText||h.label,_={label:g,type:h.kind&&gCn[h.kind]};return h.commitCharacters&&h.commitCharacters!=u&&(_.commitCharacters=h.commitCharacters),h.detail&&(_.detail=h.detail),h.sortText&&(_.sortText=h.sortText),h.insertTextFormat==2&&(_.apply=(x,y,k,O)=>Qke(g.replace(/\$(\d+)/g,"${$1}"))(x,y,k,O),_.label=h.label),h.documentation&&(_.info=()=>mCn(r,h.documentation)),_}),commitCharacters:u,validFor:(a=d.validFor)!==null&&a!==void 0?a:hCn(i.items),map:(h,p)=>({...h,from:p.mapPos(h.from)})}},i=>{if("code"in i&&i.code==-32800)return null;throw i})};function pCn(t,e){var n;if(!e.items.length)return{from:t.pos,to:t.pos};let r=(n=e.itemDefaults)===null||n===void 0?void 0:n.editRange,o=e.items[0],i=r?"insert"in r?r.insert:r:o.textEdit?"range"in o.textEdit?o.textEdit.range:o.textEdit.insert:null;if(!i)return t.state.wordAt(t.pos)||{from:t.pos,to:t.pos};let s=t.state.doc.lineAt(t.pos);return{from:s.from+i.start.character,to:s.from+i.end.character}}function mCn(t,e){let n=document.createElement("div");return n.className="cm-lsp-documentation cm-lsp-completion-documentation",n.innerHTML=t.docToHTML(e),n}const gCn={1:"text",2:"method",3:"function",4:"class",5:"property",6:"variable",7:"class",8:"interface",9:"namespace",10:"property",11:"keyword",12:"constant",13:"constant",14:"keyword",16:"constant",20:"constant",21:"constant",22:"class",25:"type"};function vCn(t={}){return tke(_Cn,{hideOn:e=>e.docChanged,hoverTime:t.hoverTime})}function bCn(t,e){return t.client.hasCapability("hoverProvider")===!1?Promise.resolve(null):(t.client.sync(),t.client.request("textDocument/hover",{position:t.toPosition(e),textDocument:{uri:t.uri}}))}function _Cn(t,e){const n=ws.get(t);return n?bCn(n,e).then(r=>r?{pos:r.range?aT(t.state.doc,r.range.start):e,end:r.range?aT(t.state.doc,r.range.end):e,create(){let o=document.createElement("div");return o.className="cm-lsp-hover-tooltip cm-lsp-documentation",o.innerHTML=xCn(n,r.contents),{dom:o}},above:!0}:null):Promise.resolve(null)}function xCn(t,e){return Array.isArray(e)?e.map(n=>G3e(t,n)).join("<br>"):typeof e=="string"||typeof e=="object"&&"language"in e?G3e(t,e):t.docToHTML(e)}function G3e(t,e){if(typeof e=="string")return t.docToHTML(e,"markdown");let{language:n,value:r}=e,o=t.client.config.highlightLanguage&&t.client.config.highlightLanguage(n||"");if(!o){let s=t.view.state.facet(Qc);s&&(!n||s.name==n)&&(o=s)}if(!o)return _6(r);let i="";return gke(r,o.parser.parse(r),{style:s=>oY(t.view.state,s)},(s,a)=>{i+=a?`<span class="${a}">${_6(s)}</span>`:_6(s)},()=>{i+="<br>"}),i}function yCn(t,e){return t.client.request("textDocument/formatting",{options:e,textDocument:{uri:t.uri}})}const wCn=t=>{const e=ws.get(t);return e?(e.client.sync(),e.client.withMapping(n=>yCn(e,{tabSize:ah(t.state),insertSpaces:t.state.facet(Rh).indexOf(" ")<0}).then(r=>{if(!r)return;let o=n.getMapping(e.uri),i=[];for(let s of r){let a=n.mapPosition(e.uri,s.range.start),l=n.mapPosition(e.uri,s.range.end);if(o){if(o.touchesRange(a,l))return;a=o.mapPos(a,1),l=o.mapPos(l,-1)}i.push({from:a,to:l,insert:s.newText})}t.dispatch({changes:i,userEvent:"format"})},r=>{e.reportError("Formatting request failed",r)})),!0):!1},kCn=[{key:"Shift-Alt-f",run:wCn,preventDefault:!0}];function OCn(t,e,n){return t.client.request("textDocument/rename",{newName:n,position:t.toPosition(e),textDocument:{uri:t.uri}})}const SCn=t=>{let e=t.state.wordAt(t.state.selection.main.head),n=ws.get(t);if(!e||!n||n.client.hasCapability("renameProvider")===!1)return!1;const r=t.state.sliceDoc(e.from,e.to);let o=ajt(t,"cm-lsp-rename-panel");if(o){let i=o.dom.querySelector("[name=name]");i.value=r,i.select()}else{let{close:i,result:s}=WG(t,{label:t.state.phrase("New name"),input:{name:"name",value:r},focus:!0,submitLabel:t.state.phrase("rename"),class:"cm-lsp-rename-panel"});s.then(a=>{t.dispatch({effects:i}),a&&CCn(t,a.elements.namedItem("name").value)})}return!0};function CCn(t,e){const n=ws.get(t),r=t.state.wordAt(t.state.selection.main.head);if(!n||!r)return!1;n.client.sync(),n.client.withMapping(o=>OCn(n,r.from,e).then(i=>{if(i)for(let s in i.changes){let a=i.changes[s],l=n.client.workspace.getFile(s);!a.length||!l||n.client.workspace.updateFile(s,{changes:a.map(c=>({from:o.mapPosition(s,c.range.start),to:o.mapPosition(s,c.range.end),insert:c.newText})),userEvent:"rename"})}},i=>{n.reportError("Rename request failed",i)}))}const ACn=[{key:"F2",run:SCn,preventDefault:!0}];function ECn(t,e,n){return t.client.hasCapability("signatureHelpProvider")===!1?Promise.resolve(null):(t.client.sync(),t.client.request("textDocument/signatureHelp",{context:n,position:t.toPosition(e),textDocument:{uri:t.uri}}))}const qS=oi.fromClass(class{constructor(){this.activeRequest=null,this.delayedRequest=0}update(t){var e;this.activeRequest&&(t.selectionSet?(this.activeRequest.drop=!0,this.activeRequest=null):t.docChanged&&(this.activeRequest.pos=t.changes.mapPos(this.activeRequest.pos)));const n=ws.get(t.view);if(!n)return;const r=t.view.state.field(Yf);let o="";if(t.docChanged&&t.transactions.some(i=>i.isUserEvent("input.type"))){const i=(e=n.client.serverCapabilities)===null||e===void 0?void 0:e.signatureHelpProvider,s=(i?.triggerCharacters||[]).concat(r&&i?.retriggerCharacters||[]);s&&t.changes.iterChanges((a,l,c,u,d)=>{let h=d.toString();if(h)for(let p of s)h.indexOf(p)>-1&&(o=p)})}o?this.startRequest(n,{triggerKind:2,isRetrigger:!!r,triggerCharacter:o,activeSignatureHelp:r?r.data:void 0}):r&&t.selectionSet&&(this.delayedRequest&&clearTimeout(this.delayedRequest),this.delayedRequest=setTimeout(()=>{this.startRequest(n,{triggerKind:3,isRetrigger:!0,activeSignatureHelp:r.data})},250))}startRequest(t,e){this.delayedRequest&&clearTimeout(this.delayedRequest);let{view:n}=t,r=n.state.selection.main.head;this.activeRequest&&(this.activeRequest.drop=!0);let o=this.activeRequest={pos:r,drop:!1};ECn(t,r,e).then(i=>{var s;if(!o.drop)if(i&&i.signatures.length){let a=n.state.field(Yf),l=a&&TCn(a.data,i),c=l&&e.triggerKind==3?a.active:(s=i.activeSignature)!==null&&s!==void 0?s:0;if(l&&MCn(a.data,i,c))return;n.dispatch({effects:O_.of({data:i,active:c,pos:l?a.tooltip.pos:o.pos})})}else n.state.field(Yf)&&n.dispatch({effects:O_.of(null)})},e.triggerKind==1?i=>t.reportError("Signature request failed",i):void 0)}destroy(){this.delayedRequest&&clearTimeout(this.delayedRequest),this.activeRequest&&(this.activeRequest.drop=!0)}});function TCn(t,e){return t.signatures.length!=e.signatures.length?!1:t.signatures.every((n,r)=>n.label==e.signatures[r].label)}function MCn(t,e,n){var r,o;return((r=t.signatures[n].activeParameter)!==null&&r!==void 0?r:t.activeParameter)==((o=e.signatures[n].activeParameter)!==null&&o!==void 0?o:e.activeParameter)}class Y3e{constructor(e,n,r){this.data=e,this.active=n,this.tooltip=r}}const Yf=to.define({create(){return null},update(t,e){for(let n of e.effects)if(n.is(O_))return n.value?new Y3e(n.value.data,n.value.active,PCn(n.value.data,n.value.active,n.value.pos)):null;return t&&e.docChanged?new Y3e(t.data,t.active,{...t.tooltip,pos:e.changes.mapPos(t.tooltip.pos)}):t},provide:t=>dP.from(t,e=>e&&e.tooltip)}),O_=xn.define();function PCn(t,e,n){return{pos:n,above:!0,create:r=>jCn(r,t,e)}}function jCn(t,e,n){var r;let o=document.createElement("div");if(o.className="cm-lsp-signature-tooltip",e.signatures.length>1){o.classList.add("cm-lsp-signature-multiple");let d=o.appendChild(document.createElement("div"));d.className="cm-lsp-signature-num",d.textContent=`${n+1}/${e.signatures.length}`}let i=e.signatures[n],s=o.appendChild(document.createElement("div"));s.className="cm-lsp-signature";let a=0,l=0,c=(r=i.activeParameter)!==null&&r!==void 0?r:e.activeParameter,u=c!=null&&i.parameters?i.parameters[c]:null;if(u&&Array.isArray(u.label))[a,l]=u.label;else if(u){let d=i.label.indexOf(u.label);d>-1&&(a=d,l=d+u.label.length)}if(l){s.appendChild(document.createTextNode(i.label.slice(0,a)));let d=s.appendChild(document.createElement("span"));d.className="cm-lsp-active-parameter",d.textContent=i.label.slice(a,l),s.appendChild(document.createTextNode(i.label.slice(l)))}else s.textContent=i.label;if(i.documentation){let d=ws.get(t);if(d){let h=o.appendChild(document.createElement("div"));h.className="cm-lsp-signature-documentation cm-lsp-documentation",h.innerHTML=d.docToHTML(i.documentation)}}return{dom:o}}const NCn=t=>{let e=t.plugin(qS);e||(t.dispatch({effects:xn.appendConfig.of([Yf,qS])}),e=t.plugin(qS));let n=t.state.field(Yf);if(!e||n===void 0)return!1;let r=ws.get(t);return r?(e.startRequest(r,{triggerKind:1,activeSignatureHelp:n?n.data:void 0,isRetrigger:!!n}),!0):!1},RCn=t=>{let e=t.state.field(Yf);return e?(e.active<e.data.signatures.length-1&&t.dispatch({effects:O_.of({data:e.data,active:e.active+1,pos:e.tooltip.pos})}),!0):!1},LCn=t=>{let e=t.state.field(Yf);return e?(e.active>0&&t.dispatch({effects:O_.of({data:e.data,active:e.active-1,pos:e.tooltip.pos})}),!0):!1},ICn=[{key:"Mod-Shift-Space",run:NCn},{key:"Mod-Shift-ArrowUp",run:LCn},{key:"Mod-Shift-ArrowDown",run:RCn}];function DCn(t={}){return[Yf,qS,t.keymap===!1?[]:r0.high(dd.of(ICn))]}function zCn(t,e){return t.client.request("textDocument/definition",{textDocument:{uri:t.uri},position:t.toPosition(e)})}function $Cn(t,e){const n=ws.get(t);return!n||n.client.hasCapability(e.capability)===!1?!1:(n.client.sync(),n.client.withMapping(r=>e.get(n,t.state.selection.main.head).then(o=>{let i=Array.isArray(o)?o[0]:o;if(i)return(i.uri==n.uri?Promise.resolve(t):n.client.workspace.displayFile(i.uri)).then(s=>{if(!s)return;let a=r.getMapping(i.uri)?r.mapPosition(i.uri,i.range.start):n.fromPosition(i.range.start,s.state.doc);s.dispatch({selection:{anchor:a},scrollIntoView:!0,userEvent:"select.definition"})})},o=>n.reportError("Find definition failed",o))),!0)}const gFe=t=>$Cn(t,{get:zCn,capability:"definitionProvider"}),BCn=[{key:"F12",run:gFe,preventDefault:!0}];function HCn(t,e){return t.client.request("textDocument/references",{textDocument:{uri:t.uri},position:t.toPosition(e),context:{includeDeclaration:!0}})}const FCn=t=>{const e=ws.get(t);if(!e||e.client.hasCapability("referencesProvider")===!1)return!1;e.client.sync();let n=e.client.workspaceMapping(),r=!1;return HCn(e,t.state.selection.main.head).then(o=>{if(o)return Promise.all(o.map(i=>e.client.workspace.requestFile(i.uri).then(s=>s?{file:s,range:i.range}:null))).then(i=>{let s=i.filter(a=>a);s.length&&(qCn(e.view,s,n),r=!0)})},o=>e.reportError("Finding references failed",o)).finally(()=>{r||n.destroy()}),!0},_U=t=>t.state.field(xU,!1)?(t.dispatch({effects:ote.of(null)}),!0):!1,xU=to.define({create(){return null},update(t,e){for(let n of e.effects)if(n.is(ote))return n.value;return t},provide:t=>Ob.from(t)}),ote=xn.define();function qCn(t,e,n){let r=VCn(e,n),o=t.state.field(xU,!1)===void 0?xn.appendConfig.of(xU.init(()=>r)):ote.of(r);t.dispatch({effects:o})}function VCn(t,e){let n=!1;return setTimeout(()=>{n||e.destroy()},500),r=>{n=!0;let o=QCn(t.map(p=>p.file.uri)),i=document.createElement("div"),s=null;i.className="cm-lsp-reference-panel",i.tabIndex=0,i.role="listbox",i.setAttribute("aria-label",r.state.phrase("Reference list"));let a=[];for(let{file:p,range:g}of t){let _=p.uri.slice(o);if(_!=s){s=_;let P=i.appendChild(document.createElement("div"));P.className="cm-lsp-reference-file",P.textContent=_}let x=i.appendChild(document.createElement("div"));x.className="cm-lsp-reference",x.role="option";let y=e.mapPosition(p.uri,g.start,1),k=e.mapPosition(p.uri,g.end,-1),O=p.getView(),C=(O?O.state.doc:p.doc).lineAt(y),A=x.appendChild(document.createElement("span"));A.className="cm-lsp-reference-line",A.textContent=(C.number+": ").padStart(5," ");let E=C.text.slice(Math.max(0,y-C.from-50),y-C.from);E&&x.appendChild(document.createTextNode(E)),x.appendChild(document.createElement("strong")).textContent=C.text.slice(y-C.from,k-C.from);let M=C.text.slice(k-C.from,Math.min(C.length,100-E.length));M&&x.appendChild(document.createTextNode(M)),a.length||x.setAttribute("aria-selected","true"),a.push(x)}function l(){for(let p=0;p<a.length;p++)if(a[p].hasAttribute("aria-selected"))return p;return 0}function c(p){for(let g=0;g<a.length;g++)g==p?a[g].setAttribute("aria-selected","true"):a[g].removeAttribute("aria-selected")}function u(p){let{file:g,range:_}=t[p],x=ws.get(r);x&&Promise.resolve(g.uri==x.uri?r:x.client.workspace.displayFile(g.uri)).then(y=>{if(!y)return;let k=e.mapPosition(g.uri,_.start,1);y.focus(),y.dispatch({selection:{anchor:k},scrollIntoView:!0})})}i.addEventListener("keydown",p=>{if(p.keyCode==27)_U(r),r.focus();else if(p.keyCode==38||p.keyCode==33)c((l()-1+t.length)%t.length);else if(p.keyCode==40||p.keyCode==34)c((l()+1)%t.length);else if(p.keyCode==36)c(0);else if(p.keyCode==35)c(a.length-1);else if(p.keyCode==13||p.keyCode==10)u(l());else return;p.preventDefault()}),i.addEventListener("click",p=>{for(let g=0;g<a.length;g++)a[g].contains(p.target)&&(c(g),u(g),p.preventDefault())});let d=document.createElement("div");d.appendChild(i);let h=d.appendChild(document.createElement("button"));return h.className="cm-dialog-close",h.textContent="×",h.addEventListener("click",()=>_U(r)),h.setAttribute("aria-label",r.state.phrase("close")),{dom:d,destroy:()=>e.destroy(),mount:()=>i.focus()}}}function QCn(t){let e=t[0],n=e.length;for(let r=1;r<t.length;r++){let o=t[r],i=0;for(let s=Math.min(n,o.length);i<s&&e[i]==o[i];i++);n=i}for(;n&&e[n-1]!="/";)n--;return n}const UCn=[{key:"Shift-F12",run:FCn,preventDefault:!0},{key:"Escape",run:_U}];function WCn(t){return t==1?"error":t==2?"warning":t==3?"info":"hint"}const ZCn=oi.fromClass(class{constructor(){this.pending=-1}update(t){t.docChanged&&(this.pending>-1&&clearTimeout(this.pending),this.pending=setTimeout(()=>{this.pending=-1;let e=ws.get(t.view);e&&e.client.sync()},500))}destroy(){this.pending>-1&&clearTimeout(this.pending)}});function GCn(){return{clientCapabilities:{textDocument:{publishDiagnostics:{versionSupport:!0}}},notificationHandlers:{"textDocument/publishDiagnostics":(t,e)=>{let n=t.workspace.getFile(e.uri);if(!n||e.version!=null&&e.version!=n.version)return!1;const r=n.getView(),o=r&&ws.get(r);return!r||!o?!1:(r.dispatch(qSn(r.state,e.diagnostics.map(i=>{var s;return{from:o.unsyncedChanges.mapPos(o.fromPosition(i.range.start,o.syncedDoc)),to:o.unsyncedChanges.mapPos(o.fromPosition(i.range.end,o.syncedDoc)),severity:WCn((s=i.severity)!==null&&s!==void 0?s:1),message:i.message}}))),!0)}},editorExtension:ZCn}}function YCn(){return[dCn(),vCn(),dd.of([...kCn,...ACn,...BCn,...UCn]),DCn(),GCn()]}const vFe={typescript:"typescript",tsx:"typescriptreact",javascript:"javascript",jsx:"javascriptreact"};new Set(Object.keys(vFe));function XCn(t){switch(t){case"typescript":case"tsx":case"javascript":case"jsx":return"typescript";default:return null}}let Xm=null;class KCn{constructor(e,n,r,o,i){this.uri=e,this.languageId=n,this.version=r,this.doc=o,this.view=i}getView(){return this.view}}class JCn extends hFe{files=[];fileVersions=Object.create(null);diffDocs=new Map;diffOpen=new Set;rootUri;worktreeId;constructor(e,n,r){super(e),this.rootUri=n,this.worktreeId=r}nextFileVersion(e){const n=(this.fileVersions[e]??-1)+1;return this.fileVersions[e]=n,n}syncFiles(){const e=[];for(const n of this.files){const r=n.getView();if(!r)continue;const o=ws.get(r);if(!o)continue;const i=o.unsyncedChanges;i.empty||(e.push({changes:i,file:n,prevDoc:n.doc}),n.doc=r.state.doc,n.version=this.nextFileVersion(n.uri),o.clear())}return e}openFile(e,n,r){const o=this.files.find(s=>s.uri===e);if(o){o.view=r;return}this.diffOpen.delete(e)&&this.client.didClose(e);const i=new KCn(e,n,this.nextFileVersion(e),r.state.doc,r);this.files.push(i),this.client.didOpen(i)}closeFile(e){const n=this.getFile(e);n&&(this.files=this.files.filter(r=>r!==n),this.client.didClose(e),this.diffDocs.has(e)&&this.openDiffOnServer(e))}openDiffDoc(e,n,r){const o=this.diffDocs.get(e),i=!o||!o.doc.eq(r);o?(o.count++,o.languageId=n,o.doc=r):this.diffDocs.set(e,{languageId:n,doc:r,count:1}),!this.getFile(e)&&(i||!this.diffOpen.has(e))&&this.openDiffOnServer(e)}closeDiffDoc(e){const n=this.diffDocs.get(e);n&&(--n.count>0||(this.diffDocs.delete(e),this.diffOpen.delete(e)&&this.client.didClose(e)))}serverDoc(e){const n=this.getFile(e);return n?(this.client.sync(),n.doc):this.diffOpen.has(e)?this.diffDocs.get(e)?.doc??null:null}openDiffOnServer(e){const n=this.diffDocs.get(e);n&&(this.diffOpen.has(e)&&this.client.didClose(e),this.client.didOpen({uri:e,languageId:n.languageId,version:this.nextFileVersion(e),doc:n.doc,getView:()=>null}),this.diffOpen.add(e))}displayFile(e){const n=this.getFile(e);if(n){const o=n.getView();if(o)return Promise.resolve(o)}const r=this.uriToWorktreePath(e);return new Promise(o=>{Xm&&(clearTimeout(Xm.timer),Xm.resolve(null));const i=setTimeout(()=>{Xm&&(Xm=null,o(null))},5e3);Xm={resolve:o,timer:i},window.dispatchEvent(new CustomEvent("band:lsp-navigate",{detail:{filePath:r,worktreeId:this.worktreeId}}))})}uriToWorktreePath(e){const n=yU(e),r=this.rootUri.endsWith("/")?this.rootUri:`${this.rootUri}/`;if(n.startsWith(r))return n.slice(r.length);const o=n.replace(/^file:\/\//,""),i=r.replace(/^file:\/\//,"");return o.startsWith(i)?o.slice(i.length):o}}function eAn(t){return new Promise((e,n)=>{const r=new JY(t);let o=[];r.onopen=()=>{e({send(i){r.readyState===WebSocket.OPEN&&r.send(i)},subscribe(i){o.push(i)},unsubscribe(i){o=o.filter(s=>s!==i)},close(){r.close()}})},r.onmessage=i=>{const s=typeof i.data=="string"?i.data:i.data.toString();for(const a of o)a(s)},r.onerror=()=>{n(new Error(`WebSocket connection failed: ${t}`))},r.onclose=()=>{o=[]}})}const D5=new Map;async function bFe(t,e,n){let r=D5.get(t);if(r)r.refCount++;else{const i=new cCn({rootUri:e,workspace:a=>new JCn(a,e,n),extensions:YCn(),timeout:1e4});r={ready:eAn(t).then(a=>(i.connect(a),{client:i,transport:a})),refCount:1},D5.set(t,r)}const o=r;try{return(await o.ready).client}catch(i){throw o.refCount--,D5.get(t)===o&&D5.delete(t),i}}function tAn(t){const e=D5.get(t);e&&(e.refCount--,!(e.refCount>0)&&(D5.delete(t),e.ready.then(({client:n,transport:r})=>n.request("shutdown",null).then(()=>{r.send(JSON.stringify({jsonrpc:"2.0",method:"exit",params:null}))}).catch(()=>{}).finally(()=>{n.disconnect(),r.close()})).catch(()=>{})))}function nAn(t,e){const{doc:n}=t.state;if(e<0||e>n.length)return null;const r=n.lineAt(e),o=r.text,i=e-r.from,s=/[\w$]/;if(i>=o.length||!s.test(o[i]))return null;let a=i,l=i;for(;a>0&&s.test(o[a-1]);)a--;for(;l<o.length-1&&s.test(o[l+1]);)l++;return{from:r.from+a,to:r.from+l+1}}function yU(t){try{return decodeURIComponent(t)}catch{return t}}function rAn(t){const e=Array.isArray(t)?t[0]:t;return e?"targetUri"in e?{uri:e.targetUri,range:e.targetSelectionRange}:e:null}const oAn=80,_Fe=xn.define(),iAn=yt.mark({class:"cm-lsp-cmd-link",attributes:{"data-testid":"code-editor__definition-link"}}),X3e=to.define({create:()=>yt.none,update(t,e){for(const n of e.effects)if(n.is(_Fe))return n.value?yt.set([iAn.range(n.value.from,n.value.to)]):yt.none;return e.docChanged?yt.none:t},provide:t=>ft.decorations.from(t)}),sAn=ft.baseTheme({".cm-lsp-cmd-link, .cm-lsp-cmd-link *":{color:"var(--link) !important",textDecoration:"underline",cursor:"pointer"}});function xFe(t){const e=oi.fromClass(class{constructor(n){this.view=n,this.checkedDoc=n.state.doc,this.onKeyDown=this.onKeyDown.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.onBlur=this.onBlur.bind(this),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp),n.dom.addEventListener("mousemove",this.onMouseMove),n.dom.addEventListener("mouseleave",this.onMouseLeave),window.addEventListener("blur",this.onBlur)}modDown=!1;mouseX=-1;mouseY=-1;current=null;navigable=new Set;timer;checkedDoc;destroy(){clearTimeout(this.timer),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),this.view.dom.removeEventListener("mousemove",this.onMouseMove),this.view.dom.removeEventListener("mouseleave",this.onMouseLeave),window.removeEventListener("blur",this.onBlur)}onKeyDown(n){(n.key==="Meta"||n.key==="Control")&&(this.modDown=!0,this.recompute())}onKeyUp(n){(n.key==="Meta"||n.key==="Control")&&(this.modDown=!1,this.navigable.clear(),this.show(null))}onMouseMove(n){this.mouseX=n.clientX,this.mouseY=n.clientY,this.modDown=n.metaKey||n.ctrlKey,this.recompute()}onMouseLeave(){this.mouseX=-1,this.show(null)}onBlur(){this.modDown=!1,this.navigable.clear(),this.show(null)}recompute(){if(!this.modDown||this.mouseX<0)return this.show(null);const n=this.view.posAtCoords({x:this.mouseX,y:this.mouseY}),r=n==null?null:nAn(this.view,n);if(!r)return this.show(null);const o=`${r.from}:${r.to}`;if(o===this.current)return;this.show(null),this.current=o;const i=this.view.state.doc;if(i!==this.checkedDoc&&(this.checkedDoc=i,this.navigable.clear()),this.navigable.has(o))return this.show(r,o);this.timer=setTimeout(()=>{t(this.view,r.from).catch(()=>!1).then(s=>{!s||this.view.state.doc!==i||(this.navigable.add(o),this.current===o&&this.show(r,o))})},oAn)}show(n,r=null){clearTimeout(this.timer),this.current=r;const o=this.view.state.field(X3e,!1);!n&&(!o||o.size===0)||this.view.dispatch({effects:_Fe.of(n)})}});return[X3e,e,sAn]}function yFe(t){return ft.domEventHandlers({click(e,n){if(!(e.metaKey||e.ctrlKey))return!1;const r=n.posAtCoords({x:e.clientX,y:e.clientY});return r==null?!1:(n.dispatch({selection:{anchor:r}}),t(n,r))}})}function wFe(t,e,n){const r=t.serverCapabilities;return r&&!r.definitionProvider?Promise.resolve(null):t.request("textDocument/definition",{textDocument:{uri:e},position:n}).then(rAn)}async function aAn(t,e,n,r,o){const i=await bFe(t,e,o);return[i.plugin(n,r),yFe(s=>gFe(s)),xFe((s,a)=>{const l=ws.get(s);return l?(i.sync(),wFe(i,l.uri,l.toPosition(a)).then(c=>!!c)):Promise.resolve(!1)})]}async function lAn(t,e,n,r,o){const i=await bFe(t,e,o),s=i.workspace,a=oi.fromClass(class{constructor(u){this.view=u,s.openDiffDoc(n,r,u.state.doc)}destroy(){s.closeDiffDoc(n)}}),l=(u,d)=>{const h=u.state.doc.lineAt(d),p=s.serverDoc(n);return!p||h.number>p.lines||p.line(h.number).text!==h.text?Promise.resolve(null):wFe(i,n,{line:h.number-1,character:d-h.from})};return[a,yFe((u,d)=>(l(u,d).then(h=>{if(!h)return;const{line:p,character:g}=h.range.start;if(yU(h.uri)===yU(n)&&p<u.state.doc.lines){const _=Math.min(u.state.doc.line(p+1).from+g,u.state.doc.length);u.dispatch({selection:{anchor:_},effects:ft.scrollIntoView(_,{y:"center"})});return}window.dispatchEvent(new CustomEvent("band:lsp-navigate",{detail:{filePath:s.uriToWorktreePath(h.uri),worktreeId:o,line:p+1,column:g+1}}))}).catch(h=>console.warn("[diff] go to definition failed:",h)),!0)),xFe((u,d)=>l(u,d).then(h=>!!h))]}function cAn(t,e){return`${px("/lsp")}?worktreeId=${encodeURIComponent(t)}&lang=${encodeURIComponent(e)}`}function K3e(t,e){const n=`file://${t}`;return e?`${n}/${e}`:n}function uAn(t){return vFe[t]}function J3e(t){return t.webserver&&t.tunnel}const dAn=FCe({url:()=>px("/trpc"),WebSocket:JY});class kFe{trpc=VCe({links:[KCe(),CCe({condition:e=>e.type==="subscription",true:qCe({client:dAn}),false:DCe({url:vA("/trpc"),maxURLLength:2e3,fetch:(e,n)=>j4(String(e),n)})})]});async listRepos(){return(await this.trpc.repos.list.query()).repos.map(n=>({...n,kind:n.kind??"git"}))}async removeRepo(e){await this.trpc.repos.remove.mutate({name:e})}async reorderRepos(e){await this.trpc.repos.reorder.mutate({names:e})}async gitInit(e){await this.trpc.repos.gitInit.mutate({path:e})}async promoteRepoToGit(e){await this.trpc.repos.promoteToGit.mutate({name:e})}async createWorktree(e,n,r,o,i,s,a){return{hostId:(await this.trpc.worktrees.create.mutate({repo:e,branch:n,base:r,prompt:o,agentMode:i,hostId:s?.hostId,hostRepoPath:s?.hostRepoPath,...a!==void 0?{groupId:a}:{}})).hostId}}async removeWorktree(e,n,r){await this.trpc.worktrees.remove.mutate({repo:e,name:n,hostId:r})}async setWorktreePinned(e,n,r,o){await this.trpc.worktrees.setPinned.mutate({repo:e,name:n,pinned:r,hostId:o})}async reorderWorktrees(e){await this.trpc.worktrees.reorder.mutate(e)}async clearNeedsAttention(e){await this.trpc.statuses.clearNeedsAttention.mutate({worktreeId:e})}async refreshBranchStatus(e){await this.trpc.statuses.refreshBranchStatus.mutate({worktreeId:e})}async runScript(e,n){await this.trpc.worktrees.runScript.mutate({path:e,scriptType:n})}gitPull(e,n,r){return this.trpc.worktrees.gitPull.mutate({repo:e,name:n,hostId:r})}gitPush(e,n,r){return this.trpc.worktrees.gitPush.mutate({repo:e,name:n,hostId:r})}async listBrowserProfiles(){return(await this.trpc.browserProfiles.list.query()).profiles}async removeBrowserProfile(e){await this.trpc.browserProfiles.remove.mutate({profileId:e})}async listRepoBrowserProfiles(){const e=await this.trpc.browserProfiles.repoDefaults.query(),n={};for(const r of e.defaults)n[r.repoName]=r.profileId;return n}async setRepoBrowserProfile(e,n){await this.trpc.browserProfiles.setRepoDefault.mutate({repoName:e,profileId:n})}async getSettings(){return await this.trpc.settings.get.query()}async updateSettings(e){await this.trpc.settings.update.mutate(e)}async listModels(e){return await this.trpc.models.list.query({agentId:e})}async listAllModels(){return await this.trpc.models.listAll.query()}async refreshModels(e,n){return await this.trpc.models.refresh.mutate({agentId:e,hostId:n})}statusHandlers=new Set;statusSubscription=null;reconnectTimer=null;latestBranchStatuses=new Map;createStatusSubscription(){this.latestBranchStatuses.clear(),this.statusSubscription=this.trpc.status.stream.subscribe(void 0,{onData:e=>{e.kind==="branch-status"&&e.worktreeId?this.latestBranchStatuses.set(e.worktreeId,e):e.kind==="remove"&&e.worktreeId&&this.latestBranchStatuses.delete(e.worktreeId);for(const n of this.statusHandlers)n(e)},onError:()=>{this.statusSubscription=null,this.scheduleReconnect()},onComplete:()=>{this.statusSubscription=null,this.scheduleReconnect()}})}scheduleReconnect(){this.reconnectTimer||this.statusHandlers.size!==0&&(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.statusHandlers.size>0&&!this.statusSubscription&&this.createStatusSubscription()},2e3))}subscribeStatusStream(e){return this.statusHandlers.add(e),this.statusSubscription||this.createStatusSubscription(),()=>{this.statusHandlers.delete(e),this.statusHandlers.size===0&&(this.statusSubscription&&(this.statusSubscription.unsubscribe(),this.statusSubscription=null),this.latestBranchStatuses.clear(),this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null))}}subscribeStatusEvents(e){return this.subscribeStatusStream(e)}lastActiveWorktreeId=void 0;async setActiveWorktree(e){if(this.lastActiveWorktreeId!==e){this.lastActiveWorktreeId=e;try{await this.trpc.editor.setActiveWorktree.mutate({worktreeId:e})}catch{this.lastActiveWorktreeId=void 0}}}subscribeAgentStatus(e,n,r){return this.subscribeStatusStream(o=>{o.kind==="snapshot"&&o.statuses?e(o.statuses):o.kind==="update"&&o.status?n(o.status):o.kind==="remove"&&o.worktreeId&&r(o.worktreeId)})}subscribeBranchStatus(e,n){const r=o=>{o.kind==="branch-status"&&o.worktreeId&&(o.git&&e(o.worktreeId,o.git),o.ci&&n(o.worktreeId,o.ci))};for(const o of this.latestBranchStatuses.values())r(o);return this.subscribeStatusStream(r)}subscribeFileChanges(e,n){let r=!0,o=null,i=null,s=0;const a=3e4,l=()=>{if(o=null,r&&!i){const u=Math.min(2**s*500,a);s+=1,i=setTimeout(()=>{i=null,r&&c()},u)}},c=()=>{o=this.trpc.worktree.fileChanges.subscribe({worktreeId:e},{onData:u=>{s=0,n(u.path)},onStopped:l,onError:l})};return c(),()=>{r=!1,i&&(clearTimeout(i),i=null),o?.unsubscribe(),o=null}}async checkCli(){return(await this.trpc.cli.check.query()).status}async installCli(e){await this.trpc.cli.install.mutate(e)}async getWorktreeDiff(e,n,r,o){return await this.trpc.worktree.getDiff.query({worktreeId:e,contextLines:n,diffMode:r,compareBranch:o})}async listWorktreeBranches(e,n){return await this.trpc.worktree.listBranches.query({worktreeId:e,...n})}async listWorktreeFiles(e,n){return await this.trpc.worktree.listFiles.query({worktreeId:e,path:n})}async getWorktreeFile(e,n){return await this.trpc.worktree.getFile.query({worktreeId:e,path:n})}async saveWorktreeFile(e,n,r){await this.trpc.worktree.saveFile.mutate({worktreeId:e,path:n,content:r})}async readExternalFile(e){return await this.trpc.host.readFile.query({absolutePath:e})}async resolveWorktreePath(e,n){return await this.trpc.worktree.resolvePath.query({worktreeId:e,path:n})}async saveExternalFile(e,n){await this.trpc.host.saveFile.mutate({absolutePath:e,content:n})}async formatWorktreeFile(e,n,r){return await this.trpc.worktree.formatFile.mutate({worktreeId:e,filePath:n,content:r})}async createWorktreeFile(e,n,r=""){await this.trpc.worktree.createFile.mutate({worktreeId:e,path:n,content:r})}async createWorktreeDirectory(e,n){await this.trpc.worktree.createDirectory.mutate({worktreeId:e,path:n})}async deleteWorktreePath(e,n){return await this.trpc.worktree.deletePath.mutate({worktreeId:e,path:n})}async renameWorktreePath(e,n,r){return await this.trpc.worktree.renamePath.mutate({worktreeId:e,fromPath:n,toPath:r})}async copyWorktreePath(e,n,r){return await this.trpc.worktree.copyPath.mutate({worktreeId:e,fromPath:n,toPath:r})}getWorktreeFileUrl(e,n){return lh(`/api/worktree-file/${encodeURIComponent(e)}/${n.split("/").map(encodeURIComponent).join("/")}`)}async getWorktreePreviewUrl(e,n){const{url:r}=await this.trpc.worktree.previewUrl.query({worktreeId:e,path:n});return vA(r)}async searchWorktreeFiles(e,n,r){return await this.trpc.worktree.searchFiles.query({worktreeId:e,query:n,limit:r})}async searchWorktreeContent(e,n,r){return await this.trpc.worktree.searchContent.query({worktreeId:e,query:n,caseSensitive:r?.caseSensitive,wholeWord:r?.wholeWord,regex:r?.regex,limit:r?.limit})}}class OFe{copyPath=!1;navigate;getWorktreeHref(e){return`/worktree/${encodeURIComponent(e)}`}async openUrl(e){window.open(e,"_blank")}}function SFe(){return typeof window<"u"&&"__BAND_DESKTOP__"in window}function pf(){return SFe()}function CFe(){return SFe()?window.__BAND_DESKTOP__??null:null}async function Cc(t,e){const n=CFe();if(n)return await n.invoke(t,e);throw new Error(`desktopInvoke('${t}') called outside the desktop shell`)}class fAn extends kFe{async removeBrowserProfile(e){await super.removeBrowserProfile(e),await Cc("browser_profile_clear_data",{profileId:e})}async installCli(e){try{await super.installCli();return}catch(n){const r=n instanceof Error?n.message:String(n);if(e?.allowPrompt&&pf()&&r.includes("elevation-required")){const o=await this.trpc.cli.resolve.query();if(!o)throw new Error("Could not resolve CLI binary path - try reinstalling Band or restarting the app");await Cc("install_cli",{binaryPath:o.binaryPath,symlinkPath:o.symlinkPath});return}throw n}}async getUpdateStatus(){return Cc("updater_status")}subscribeUpdateStatus(e){const n=CFe();if(!n)throw new Error("subscribeUpdateStatus called outside the desktop shell");return n.on("updater-status-changed",r=>e(r))}async checkForUpdates(){await Cc("updater_check")}async downloadUpdate(){await Cc("updater_download")}async restartToUpdate(){await Cc("updater_restart")}async dismissUpdate(){await Cc("updater_dismiss")}}class hAn{web=new OFe;navigate;get copyPath(){return pf()}get translucentSidebar(){return pf()&&/Mac/.test(navigator.userAgent)}getWorktreeHref(e){return this.web.getWorktreeHref(e)}async revealInFinder(e){pf()&&await Cc("reveal_in_finder",{path:e})}async pickFolder(){return pf()?Cc("pick_folder"):null}async pickFile(){return pf()?Cc("pick_file"):null}async pickSaveFile(e){return pf()?Cc("pick_save_file",{content:e.content,defaultName:e.defaultName,defaultPath:e.defaultPath}):null}async openUrl(e){if(!pf()){window.open(e,"_blank");return}await Cc("open_external",{url:e})}}function fN({testId:t,onClose:e,children:n}){return f.jsxs("output",{"aria-live":"polite","data-testid":t,className:"pointer-events-auto relative block rounded-lg border bg-popover p-3 text-sm text-popover-foreground shadow-lg animate-in fade-in-0 slide-in-from-bottom-2 duration-200",children:[e&&f.jsx("button",{type:"button","aria-label":"Close",onClick:e,className:"absolute top-2 right-2 rounded-sm p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:f.jsx(pa,{className:"size-3.5"})}),n]})}const W$="band:hub-older-notice-dismissed";function pAn(){const e=It({queryKey:["hub-version"],queryFn:()=>Se.services.health.query(),staleTime:Number.POSITIVE_INFINITY,retry:!1}).data?.version,n=e?MTt("0.54.1",e)==="newer":!1,[r,o]=v.useState(()=>{try{return localStorage.getItem(W$)===e}catch{return!1}});if(v.useEffect(()=>{if(jTt(n),!n)return;const s=a=>{$ye(a.reason)&&a.preventDefault()};return window.addEventListener("unhandledrejection",s),()=>window.removeEventListener("unhandledrejection",s)},[n]),v.useEffect(()=>{try{o(localStorage.getItem(W$)===e)}catch{}},[e]),!n||r)return null;const i=()=>{o(!0);try{localStorage.setItem(W$,e??"")}catch{}};return f.jsxs(fN,{testId:"hub-version-notice",onClose:i,children:[f.jsxs("div",{className:"flex gap-2.5 pr-6",children:[f.jsx(_u,{className:"mt-0.5 size-4 shrink-0 text-warning"}),f.jsxs("div",{className:"min-w-0",children:[f.jsx("p",{className:"font-medium",children:"Update the hub"}),f.jsxs("p",{className:"mt-0.5 text-xs text-muted-foreground",children:["The hub runs ",e,", this app is ","0.54.1",". Some features need a newer hub."]})]})]}),f.jsx("div",{className:"mt-3 flex justify-end",children:f.jsx(Ce,{variant:"ghost",size:"xs",onClick:i,children:"Dismiss"})})]})}const e4e="band:reinstall-home-screen-dismissed";function mAn(){const t=document.createElement("div");t.style.cssText="position:fixed;visibility:hidden;pointer-events:none;padding-top:env(safe-area-inset-top)",document.body.appendChild(t);const e=Number.parseFloat(getComputedStyle(t).paddingTop)||0;return t.remove(),e}function gAn(){return navigator.standalone===!0}function vAn(){const[t,e]=v.useState(!1);if(v.useEffect(()=>{if(!gAn())return;try{if(localStorage.getItem(e4e))return}catch{}const r=()=>{mAn()<=0||(e(!0),window.removeEventListener("resize",r))};return window.addEventListener("resize",r),r(),()=>window.removeEventListener("resize",r)},[]),!t)return null;const n=()=>{e(!1);try{localStorage.setItem(e4e,"1")}catch{}};return f.jsxs(fN,{testId:"reinstall-home-screen-notice",onClose:n,children:[f.jsxs("div",{className:"flex gap-2.5 pr-6",children:[f.jsx(_u,{className:"mt-0.5 size-4 shrink-0 text-warning"}),f.jsxs("div",{className:"min-w-0",children:[f.jsx("p",{className:"font-medium",children:"Add Band to your Home Screen again"}),f.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"This copy was added with an older setup, so it doesn't fit the screen. Remove it from the Home Screen, then open Band in Safari and choose Share, Add to Home Screen."})]})]}),f.jsx("div",{className:"mt-3 flex justify-end",children:f.jsx(Ce,{variant:"ghost",size:"xs",onClick:n,children:"Got it"})})]})}function bAn(){const{status:t,busy:e,error:n,run:r}=lHe(),[o,i]=v.useState(!1),[s,a]=v.useState(""),[l,c]=v.useState([]);if(v.useEffect(()=>{t&&s===""&&a(t.defaultName)},[t,s]),!t?.promptPending||o)return null;const u=()=>{i(!0),Ho("worker_dismiss_prompt").catch(()=>{})},d=async()=>{const p=await aHe().catch(()=>null);p&&!l.includes(p)&&c([...l,p])},h=async()=>{await r("worker_add",{name:s,roots:l})&&i(!0)};return f.jsx(nr,{open:!0,onOpenChange:p=>!p&&!e&&u(),children:f.jsxs(rr,{"data-testid":"this-computer-prompt",children:[f.jsxs(hr,{children:[f.jsx(or,{children:"Use this Mac as a worker?"}),f.jsx(Nr,{children:"The hub can then run worktrees and agents on this computer. Band installs a background service that keeps running after you quit the app. You can remove it in Settings > Workers."})]}),f.jsxs("div",{className:"space-y-3 text-sm",children:[f.jsxs("div",{className:"space-y-1",children:[f.jsx("span",{className:"text-xs text-muted-foreground",children:"Computer name"}),f.jsx(Sn,{"aria-label":"Computer name","data-testid":"this-computer-prompt__name",value:s,maxLength:100,disabled:e,onChange:p=>a(p.target.value)})]}),f.jsxs("div",{className:"space-y-1",children:[f.jsx("span",{className:"text-xs text-muted-foreground",children:"Folders it may use. Add none now: choosing a repo later adds its folder."}),f.jsx("ul",{children:l.map(p=>f.jsxs("li",{className:"flex items-center justify-between gap-2",children:[f.jsx("span",{className:"truncate font-mono text-xs",children:p}),f.jsx(Ce,{type:"button",variant:"ghost",size:"xs","aria-label":`Remove ${p}`,disabled:e,onClick:()=>c(l.filter(g=>g!==p)),children:f.jsx(pa,{className:"size-3"})})]},p))}),f.jsx(Ce,{type:"button",variant:"outline",size:"sm","data-testid":"this-computer-prompt__add-folder",disabled:e,onClick:()=>{d()},children:"Add folder"})]}),n?f.jsx("p",{role:"alert","data-testid":"this-computer-prompt__error",className:"text-xs text-destructive",children:n}):null]}),f.jsxs(ii,{children:[f.jsx(Ce,{type:"button",variant:"ghost",size:"sm","data-testid":"this-computer-prompt__not-now",disabled:e,onClick:u,children:"Not now"}),f.jsx(Ce,{type:"button",size:"sm","data-testid":"this-computer-prompt__yes",disabled:e||s.trim()==="",onClick:()=>{h()},children:e?"Setting up…":n?"Retry":"Yes, use this Mac"})]})]})})}const _An=4e3;function xAn(){const t=Rr(),[e,n]=v.useState({state:"idle"});v.useEffect(()=>{if(!t.getUpdateStatus||!t.subscribeUpdateStatus)return;let i=!1,s=!1;const a=t.subscribeUpdateStatus(l=>{s=!0,n(l)});return t.getUpdateStatus().then(l=>{!i&&!s&&n(l)}).catch(()=>{}),()=>{i=!0,a()}},[t]);const r=v.useCallback(()=>{n({state:"idle"}),t.dismissUpdate?.().catch(hv)},[t]);v.useEffect(()=>{if(e.state!=="up-to-date")return;const i=setTimeout(r,_An);return()=>clearTimeout(i)},[e,r]);const o=v.useCallback(()=>{e.state==="error"&&(e.phase==="download"?t.downloadUpdate?.().catch(hv):t.checkForUpdates?.().catch(hv))},[t,e]);return{status:yAn(e)?e:null,download:v.useCallback(()=>t.downloadUpdate?.().catch(hv),[t]),restart:v.useCallback(()=>t.restartToUpdate?.().catch(hv),[t]),retry:o,dismiss:r}}function hv(){}function yAn(t){switch(t.state){case"idle":return!1;case"checking":case"up-to-date":case"error":return t.userInitiated;case"available":case"downloading":case"downloaded":return!0}}function wAn(){const{status:t,download:e,restart:n,retry:r,dismiss:o}=xAn();if(!t)return null;let i,s=!0;switch(t.state){case"checking":s=!1,i=f.jsx(Km,{icon:f.jsx(wo,{className:"size-4"}),title:"Checking for updates…"});break;case"up-to-date":i=f.jsx(Km,{icon:f.jsx(cb,{className:"size-4 text-success"}),title:"You're on the latest version",detail:`Band v${t.currentVersion}`});break;case"available":i=f.jsxs(f.Fragment,{children:[f.jsx(Km,{icon:f.jsx(N6,{className:"size-4 text-info"}),title:`Band v${t.version} is available`,detail:`You have v${t.currentVersion}.`}),f.jsx(kAn,{release:t}),f.jsxs(Z$,{children:[f.jsx(Ce,{variant:"ghost",size:"xs",onClick:o,children:"Later"}),f.jsx(Ce,{size:"xs",onClick:e,children:"Update"})]})]});break;case"downloading":s=!1,i=f.jsxs(f.Fragment,{children:[f.jsx(Km,{icon:f.jsx(wo,{className:"size-4"}),title:`Downloading Band v${t.version}…`,detail:`${t.percent}%`}),f.jsx("div",{role:"progressbar","aria-label":"Update download","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t.percent,className:"mt-2.5 h-1.5 overflow-hidden rounded-full bg-muted",children:f.jsx("div",{className:"h-full rounded-full bg-primary transition-[width] duration-300 ease-out",style:{width:`${t.percent}%`}})})]});break;case"downloaded":i=f.jsxs(f.Fragment,{children:[f.jsx(Km,{icon:f.jsx(cb,{className:"size-4 text-success"}),title:`Band v${t.version} is ready`,detail:"Restart Band to finish updating. It also installs when you quit."}),f.jsxs(Z$,{children:[f.jsx(Ce,{variant:"ghost",size:"xs",onClick:o,children:"Later"}),f.jsxs(Ce,{size:"xs",onClick:n,children:[f.jsx(bM,{}),"Restart to update"]})]})]});break;case"error":i=f.jsxs(f.Fragment,{children:[f.jsx(Km,{icon:f.jsx(_u,{className:"size-4 text-destructive"}),title:t.phase==="download"?"Couldn't download the update":"Couldn't check for updates",detail:t.message}),f.jsx(Z$,{children:f.jsx(Ce,{variant:"outline",size:"xs",onClick:r,children:"Retry"})})]});break}return f.jsx(fN,{testId:"update-toast",onClose:s?o:void 0,children:i})}function Km({icon:t,title:e,detail:n}){return f.jsxs("div",{className:"flex gap-2.5 pr-6",children:[f.jsx("span",{className:"mt-0.5 shrink-0",children:t}),f.jsxs("div",{className:"min-w-0",children:[f.jsx("p",{className:"font-medium",children:e}),n&&f.jsx("p",{className:"mt-0.5 line-clamp-3 break-words text-xs text-muted-foreground",children:n})]})]})}function kAn({release:t}){return f.jsxs("div",{className:"mt-2 pl-6.5",children:[t.releaseNotes&&f.jsx("p",{className:"max-h-28 overflow-y-auto whitespace-pre-line text-xs text-muted-foreground",children:t.releaseNotes}),f.jsx("button",{type:"button",onClick:()=>N4(t.releaseUrl),className:"mt-1.5 text-xs text-primary underline-offset-4 hover:underline",children:"Release notes on GitHub"})]})}function Z$({children:t}){return f.jsx("div",{className:"mt-3 flex justify-end gap-2",children:t})}const OAn=8;function SAn(){const t=v.useRef(null),e=AAn(t),n=Cn(r=>r.notices);return f.jsxs("section",{ref:t,"aria-label":"Notifications","data-testid":"toast-host",style:e===null?void 0:{bottom:e},className:"pointer-events-none fixed right-4 bottom-[calc(1rem+env(safe-area-inset-bottom))] left-4 z-50 flex flex-col-reverse gap-2 sm:left-auto sm:w-80",children:[f.jsx(wAn,{}),f.jsx(pAn,{}),f.jsx(bAn,{}),f.jsx(vAn,{}),n.map(r=>f.jsx(CAn,{notice:r},r.id))]})}function CAn({notice:t}){const e=Cn(i=>i.dismissNotice),[n,r]=v.useState(!1),o=t.tone==="error";return v.useEffect(()=>{if(o)return;const i=setTimeout(()=>e(t.id),NTt);return()=>clearTimeout(i)},[o,t.id,e]),f.jsxs(fN,{testId:`toast-host__notice--${t.tone}`,onClose:()=>e(t.id),children:[f.jsxs("div",{className:"flex gap-2.5 pr-6",children:[o?f.jsx(_u,{className:"mt-0.5 size-4 shrink-0 text-destructive"}):f.jsx(G7e,{className:"mt-0.5 size-4 shrink-0 text-info"}),f.jsx("p",{className:"min-w-0 line-clamp-4 break-words",children:t.message})]}),o&&f.jsx("div",{className:"mt-2 flex justify-end",children:f.jsx(Ce,{variant:"ghost",size:"xs",onClick:()=>r(!0),children:"Details"})}),f.jsx(nr,{open:n,onOpenChange:r,children:f.jsxs(rr,{children:[f.jsxs(hr,{children:[f.jsx(or,{className:"text-destructive",children:"Error"}),f.jsx(Nr,{children:"Click the error text to select it."})]}),f.jsx("pre",{className:"max-h-64 cursor-text overflow-auto whitespace-pre-wrap break-words rounded-md bg-muted/50 p-3 text-sm select-all",children:t.message}),f.jsxs(ii,{children:[f.jsx(Ce,{variant:"outline",size:"sm",onClick:()=>navigator.clipboard.writeText(t.message),children:"Copy"}),f.jsx(Ce,{size:"sm",onClick:()=>{r(!1),e(t.id)},children:"Dismiss"})]})]})})]})}function AAn(t){const[e,n]=v.useState(null),r=Cn(i=>i.activeWorktreeId),o=v.useRef(()=>{});return v.useEffect(()=>{const i=t.current;if(!i)return;let s=0;const a=()=>{s=0;const p=i.getBoundingClientRect(),g=window.innerHeight;let _=Number.POSITIVE_INFINITY;for(const y of h1e()){if(y.checkVisibility&&!y.checkVisibility({visibilityProperty:!0}))continue;const k=y.getBoundingClientRect();k.width===0||k.height===0||k.right<=p.left||k.left>=p.right||k.top<g/2||k.top>=g||(_=Math.min(_,k.top))}const x=Number.isFinite(_)?g-_+OAn:null;n(y=>y===x?y:x)},l=()=>{s||(s=requestAnimationFrame(a))};o.current=l;const c=new ResizeObserver(l),u=()=>{c.disconnect();for(const p of h1e())c.observe(p);l()};u();const d=CBt(u),h=window.visualViewport;return window.addEventListener("resize",l),h?.addEventListener("resize",l),h?.addEventListener("scroll",l),()=>{s&&cancelAnimationFrame(s),d(),c.disconnect(),window.removeEventListener("resize",l),h?.removeEventListener("resize",l),h?.removeEventListener("scroll",l),o.current=()=>{}}},[t]),v.useEffect(()=>{o.current()},[r]),e}function EAn(){const{settings:t}=Qh(),e=t.webBrowserCdpEnabled??!1;return v.useEffect(()=>{if(!On||!e)return;const n=Se.browserHost.ensureView.subscribe(void 0,{onData(o){(async()=>{try{await Ho("browser_ensure",{browserId:o.bandTabId,url:o.url,profileId:o.profileId??null});const i=await Ho("browser_get_cdp_target",{browserId:o.bandTabId});await Se.browserHost.targetReady.mutate({bandTabId:o.bandTabId,cdpTargetId:i})}catch(i){console.error("[BrowserHostBridge] ensureView failed:",i)}})()},onError(o){console.warn("[BrowserHostBridge] ensureView subscription error:",o)}});let r;return Qf("browser-view-destroyed",o=>{const i=o.payload.browser_id;i&&Se.browserHost.viewDestroyed.mutate({bandTabId:i}).catch(s=>console.warn("[BrowserHostBridge] viewDestroyed mutate failed:",s))}).then(o=>{r=o}),()=>{n.unsubscribe(),r?.()}},[e]),null}function TAn(){return Ho("browser_chrome_profiles")}function MAn(){return Ho("browser_chrome_running")}function PAn(t){return Ho("browser_chrome_import",{...t})}function t4e(t){return Ho("browser_profile_clear_data",{profileId:t})}function jAn(t){return Ho("browser_profile_prune",{keep:t})}function G$(t){const e=t instanceof Error?t.message:String(t);return/Error invoking remote method '[^']+': (?:\w*Error: )?(.*)$/s.exec(e)?.[1]??e}let n4e=!1;function NAn(){return v.useEffect(()=>{!On||n4e||(n4e=!0,Se.browserProfiles.list.query().then(({profiles:t})=>jAn(t.map(e=>e.id))).catch(t=>console.error("Failed to prune deleted browser profiles:",t)))},[]),null}const RAn="/assets/android-studio-t3zZ7G0e.svg",LAn="/assets/antigravity-m-mWKI7R.svg",IAn="data:image/svg+xml,%3csvg%20width='40'%20height='40'%20viewBox='0%200%2040%2040'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_5436_78947)'%3e%3cmask%20id='mask0_5436_78947'%20style='mask-type:luminance'%20maskUnits='userSpaceOnUse'%20x='4'%20y='4'%20width='32'%20height='32'%3e%3cpath%20d='M4%204H36V36H4V4Z'%20fill='white'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_5436_78947)'%3e%3cpath%20d='M28.375%204H11.625C7.41383%204%204%207.41383%204%2011.625V28.375C4%2032.5862%207.41383%2036%2011.625%2036H28.375C32.5862%2036%2036%2032.5862%2036%2028.375V11.625C36%207.41383%2032.5862%204%2028.375%204Z'%20fill='black'/%3e%3c/g%3e%3cpath%20d='M29.6214%2014.2072L20.9502%209.12249C20.6718%208.95917%2020.3282%208.95917%2020.0498%209.12249L11.3786%2014.2072C11.1445%2014.3445%2011%2014.5984%2011%2014.8733V25.1267C11%2025.4012%2011.1445%2025.6555%2011.3786%2025.7928L20.0498%2030.8775C20.3282%2031.0408%2020.6718%2031.0408%2020.9502%2030.8775L29.6214%2025.7928C29.8555%2025.6555%2030%2025.4016%2030%2025.1267V14.8733C30%2014.5988%2029.8555%2014.3445%2029.6214%2014.2072ZM29.0767%2015.2843L20.706%2030.0101C20.6494%2030.1093%2020.5%2030.0688%2020.5%2029.9538V20.3115C20.5%2020.1189%2020.3986%2019.9407%2020.2342%2019.8439L12.0124%2015.0226C11.9147%2014.9651%2011.9546%2014.8134%2012.0678%2014.8134H28.8093C29.047%2014.8134%2029.1956%2015.0751%2029.0767%2015.2843Z'%20fill='white'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_5436_78947'%3e%3crect%20width='32'%20height='32'%20fill='white'%20transform='translate(4%204)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",DAn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAAB8pJREFUeAHtWG+MXFUV/9375s3szNDturKbLpt0aZo2fvAfpEBEss2iMZJaFTBdG1BrUfGLmohWaGvaQtYYU2miJsRKTQikkhDRIKmRNcEPJGgw1hJFcetu2mJcKrPbmZ2dP++9e6/n3PtmdnbelJnlC3zobc++mXvPu+d3z/87wJVxZby9Q3RZl0T65Pnzu2f94S/Pl70tQYhBpWG0Mn3odRgSJBFIAeOnxKWBPvWvTVj66Vc2DT0ZYzB4CwDlaWN2H5tRT1QvKONJCCHxlodpE6Y1EAxI3PtefOvjvn+Mp7AGgN7vjPnxT6Yr916VScmuem4FQkjq0uDGDR5ky3ukdAQK+O+ywflFjZyU8D3iDZXaMd73m3t8eSc6gOwkWp4xZvLA76uPr0t7nunA+GZz7xkROLTFR7fx4lKEQy8qDGUFqnWjvnSr/8AOz3uYllQ3gNhztm5qF7DmUagCz92W7pm/SHTnbwMCCVTyEtefmvIOHz68SosJr3rif6VPFF/VUBHWTCP9K3uzSRukWoi/N7S9nujALRLVmoB/SZsNu/Z8sR1PAuDZcuqbkqdZloJ7tpLqME/fdSRw+xbP7uFYBJRxpFsoYqL1KH51+7oUqhFx0/+z9Wv2tONJtU/Ml/wt2tA5I6xpXKoaTAz5Tfws/XK5Q5tYM9IB2DggsFACLpb01q4Aq1U9yMcza4hcHumUxnohUINLITwum9xoQQsHkgEMU6AUFiiiA5FvZ02YWIXwKRGjlXRMlAnxnz8+Q2/J5lyD5yObPQTEEpnY6i1rGQIzPf0CKLm7d4ybZ142VIr2s3JCk+0KMAwofZGNROTIajN++jkfp394F/lbABO6OeapVoA7CKD1K3qXXMqC0DHNzL2G3ZN7kPbiAzNA48DyYaR2SFUkEkpPmJjB8CaN+tP6VAyKtVeNXUC6+eXQYCwrUWJgVqpsiVXmFfBkhtYMQgZD34U1iIFHnwwHE81LBXQHSIzaBogTIOJUyScN6xr5a7fByCyZI4LwlNXGB0eBMjGE1oR0APonmilWYGTDED40fgOW6ORUNB04uykBN6wU7cgT3QFacJHbwmB1DQ2LEW7+7h8QVuvkB9JqKiDeyQ9QcJCA0PolQWOhTQ0a1E0Kj508wRUDkjNRbEnJlpVw5og8KE93B8inUrqhM4FEQQsiO6dj9IsVhfcPZVCiZMuHcyLk6hCmz7VYNvuoIBPztlq6Q7HV6HxIqx40yJLJWel9GZ80lmRisCKWyERzo1QOaqGwuLU7mTvaZXOM24q38eiDlM4HWSuqQz+TAKj4FI082J4Mm53bil9+6sMpStLaaU6sYGdTv0kmdLLYETgwKN9oCkDZiw8aZSz10mJxa1WhzOxT38RyuL2q1Fwi1BxszVOtesv+lfEKR7LlZ7kdqleHNGOcqnusJCef13jqhSpVEthy9ctvZ7FAVSEigGaVLzfAiSZsjjMmEyd0T/cYJDbLrsqClxsCGQ5FJSk508ECY7UacLpRaAZScg9jgUlyIRE4SwirwaRWEpWETcN+YcgXm0/tobJ4jlY9ilQZr4kEnyagmqQFFJL1yFigAbf2MaVzXHPnqYum1EPmrNt17bohKwfdAXJisqdvIZlJ429Ht2Hmmf2QaQZpEjyWCBi3VGEoQXkcETl+RFqh8ol3DXo4vO97+OrkXvh90s5HBDQIXWtn9+wJoDFRowFt1OBwsYobpsoonHkKfz12o/UCqJQriy18SklbsuramZk1RIUDIZZx984vYHZmBo89dwpvFAKnZeJnHvY/awnTg4k9Qa1C3E02uhUuXEGpim3fmUN20078+WAOs6e+jqBeRCqdIQdKkeac6e2mFM45akRLxUX8aGoKd39sByZ23IGpR45jocANmW81HFKWDimH1mvamlcaU2vHkwgSX+pFpZCDbqshnP2XA2y85QGMjR/Av6fvx5mHt6Ivm0V+9Cb0Db+PTLceU4ckzs1dwOw/XyaNGtz6yc/hZ88+j6ViBTUS73lpq102g+QAo2oy/4azRMY3y10BXp3HzLlIjwqZjD3bbAgOhghj2x+C99GjqJfnUXrtNOoL/0C5UEb/wGaM3zaOz3/tQfTlcqgu17BcipDyszZ5s0VcN21s3hxcB/x9VqHPF7hmUM51BTiWff3Rl6Lh7Z4n4qLW6GpW/rpPJCysUdAMYHBsAmbjBApFhbv25vHKTGhTR40qDGvM3kc4hZg479j2i4KHoFaqkU1TIa3dfO2lx0+04Ul4pSFP3Xp/qPuNWkmrLXk2MdcyXywDvzji4y+vknY413Vwes2as5cnjevokvXZQ3W8m35hkOslXtqfSbyQCBLqNMQ3PuPtq1Yibt5sZTHkzCY0ca/eNhfFpZGeA1mNI8cDjA1zbyhsjgu0aRJXF67vV1ODMUIXpcmDNQz104WrFOnj92GqIx50HnL/tH766V+Xd2bT3pp+kWHHqFNWnrg+hXym0VkLeyOuU6WZLwi8PKesi/TRHX+ppvXRg/lnPz0qb0ePP300QZ54Jbzv+z/XP8hz9yzQc31ujE5VjrewdxIlTGbIE4/uSx25Lus9iDX+eNS6bh761cV7zpzL7y0UsbkWiKvIn7N8dV4LYOqkBdmiksua+tiInLlp08Un+1//0yO7du1qXqWvjCvjnTj+D8SthzamBKAPAAAAAElFTkSuQmCC",zAn="data:image/svg+xml,%3csvg%20width='40'%20height='40'%20viewBox='0%200%2040%2040'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_5437_79067)'%3e%3cpath%20d='M27.395%2036C26.1435%2035.9986%2024.9203%2035.6274%2023.879%2034.933C22.8374%2035.6273%2021.6139%2035.9985%2020.362%2036C19.113%2036%2017.882%2035.625%2016.846%2034.933C15.8189%2035.6241%2014.61%2035.9954%2013.372%2036H13.334C12.4944%2036.0006%2011.6633%2035.8321%2010.8902%2035.5047C10.1171%2035.1772%209.41781%2034.6975%208.83405%2034.094C7.65642%2032.8996%206.99679%2031.2893%206.99805%2029.612V17.362C7.00005%209.995%2012.994%204%2020.362%204C27.731%204%2033.725%209.994%2033.725%2017.363V29.616C33.725%2033.009%2031.099%2035.808%2027.747%2035.991C27.63%2035.998%2027.513%2036%2027.395%2036Z'%20fill='%233551F3'/%3e%3cpath%20d='M27.395%2034.5932C26.2752%2034.5924%2025.1889%2034.2104%2024.315%2033.5102C24.1961%2033.4145%2024.0476%2033.3632%2023.895%2033.3652C23.7174%2033.367%2023.5457%2033.4291%2023.408%2033.5412C22.5392%2034.2237%2021.4668%2034.5951%2020.362%2034.5962C19.2576%2034.5949%2018.1855%2034.2234%2017.317%2033.5412C17.1835%2033.4338%2017.0174%2033.3752%2016.846%2033.3752C16.6747%2033.3752%2016.5085%2033.4338%2016.375%2033.5412C15.518%2034.2199%2014.4581%2034.5914%2013.365%2034.5962H13.332C12.6806%2034.5961%2012.0359%2034.4649%2011.4362%2034.2102C10.8366%2033.9556%2010.2945%2033.5829%209.84201%2033.1142C8.92225%2032.1822%208.40639%2030.9256%208.40601%2029.6162V17.3672C8.40601%2010.7702%2013.77%205.40723%2020.363%205.40723C26.955%205.40723%2032.319%2010.7702%2032.319%2017.3632V29.6162C32.319%2032.2612%2030.277%2034.4432%2027.669%2034.5862C27.5777%2034.5909%2027.4864%2034.5932%2027.395%2034.5932Z'%20fill='black'/%3e%3cpath%20d='M30.912%2017.3635V29.6165C30.912%2031.4925%2029.465%2033.0795%2027.592%2033.1825C26.725%2033.2323%2025.8704%2032.9582%2025.194%2032.4135C24.416%2031.7875%2023.321%2031.8155%2022.536%2032.4345C21.9163%2032.9237%2021.1495%2033.1891%2020.36%2033.1875C19.5714%2033.1889%2018.8056%2032.9235%2018.187%2032.4345C17.8057%2032.1306%2017.3326%2031.9651%2016.845%2031.9651C16.3574%2031.9651%2015.8843%2032.1306%2015.503%2032.4345C14.8904%2032.9183%2014.1336%2033.1834%2013.353%2033.1875C11.405%2033.2015%209.81299%2031.5605%209.81299%2029.6125V17.3625C9.81299%2011.5375%2014.537%206.81348%2020.363%206.81348C26.188%206.81348%2030.912%2011.5375%2030.912%2017.3635Z'%20fill='white'/%3e%3cpath%20d='M18.28%2016.4366L14.35%2014.1666C14.104%2014.0248%2013.8117%2013.9865%2013.5374%2014.06C13.2632%2014.1335%2013.0292%2014.3128%2012.887%2014.5586C12.7452%2014.8045%2012.7067%2015.0966%2012.78%2015.3709C12.8533%2015.6452%2013.0324%2015.8792%2013.278%2016.0216L15.604%2017.3646L13.278%2018.7076C13.045%2018.8559%2012.8783%2019.0886%2012.8126%2019.3569C12.7469%2019.6252%2012.7873%2019.9085%2012.9255%2020.1478C13.0636%2020.387%2013.2887%2020.5637%2013.554%2020.641C13.8192%2020.7183%2014.104%2020.6902%2014.349%2020.5626L18.281%2018.2926C18.4436%2018.1985%2018.5786%2018.0633%2018.6724%2017.9006C18.7662%2017.7379%2018.8156%2017.5534%2018.8156%2017.3656C18.8156%2017.1777%2018.7662%2016.9932%2018.6724%2016.8305C18.5786%2016.6678%2018.4436%2016.5326%2018.281%2016.4386V16.4366H18.28ZM27.182%2016.2906H22.018C21.7338%2016.2906%2021.4613%2016.4034%2021.2604%2016.6044C21.0594%2016.8053%2020.9465%2017.0779%2020.9465%2017.3621C20.9465%2017.6462%2021.0594%2017.9188%2021.2604%2018.1197C21.4613%2018.3207%2021.7338%2018.4336%2022.018%2018.4336H27.182C27.4662%2018.4336%2027.7387%2018.3207%2027.9397%2018.1197C28.1406%2017.9188%2028.2535%2017.6462%2028.2535%2017.3621C28.2535%2017.0779%2028.1406%2016.8053%2027.9397%2016.6044C27.7387%2016.4034%2027.4662%2016.2906%2027.182%2016.2906Z'%20fill='black'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_5437_79067'%3e%3crect%20width='27'%20height='32'%20fill='white'%20transform='translate(7%204)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",$An="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTYgMjU2Ij4KICA8ZGVmcz4KICAgIDxsaW5lYXJHcmFkaWVudCBpZD0iYSIgeDE9IjAiIHkxPSIwIiB4Mj0iMjU2IiB5Mj0iMjU2IiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+CiAgICAgIDxzdG9wIG9mZnNldD0iMCIgc3RvcC1jb2xvcj0iI0Y5N0ExMiIvPgogICAgICA8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiNGQzI5QjgiLz4KICAgIDwvbGluZWFyR3JhZGllbnQ+CiAgPC9kZWZzPgogIDxyZWN0IHdpZHRoPSIyNTYiIGhlaWdodD0iMjU2IiByeD0iNDgiIGZpbGw9InVybCgjYSkiLz4KICA8cmVjdCB4PSI0OCIgeT0iNDgiIHdpZHRoPSIxNjAiIGhlaWdodD0iMTYwIiByeD0iNCIgZmlsbD0iIzAwMCIvPgogIDx0ZXh0IHg9IjYwIiB5PSIxNzgiIGZpbGw9IiNmZmYiIGZvbnQtZmFtaWx5PSJBcmlhbCxIZWx2ZXRpY2Esc2Fucy1zZXJpZiIgZm9udC13ZWlnaHQ9ImJvbGQiIGZvbnQtc2l6ZT0iNTYiPklKPC90ZXh0Pgo8L3N2Zz4K",BAn="data:image/svg+xml,%3csvg%20width='40'%20height='40'%20viewBox='0%200%2040%2040'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20x='4'%20y='4'%20width='32'%20height='32'%20rx='6.4'%20fill='url(%23paint0_linear_5437_79079)'/%3e%3crect%20x='4.80005'%20y='4.7998'%20width='30.4'%20height='30.4'%20rx='5.6'%20fill='black'/%3e%3crect%20x='7.19995'%20y='7.2002'%20width='25.6'%20height='25.6'%20rx='3.2'%20fill='%23202A2F'/%3e%3cpath%20d='M25.2454%208.85742H19.2454V20.8574H25.2454V8.85742Z'%20fill='%230EE827'%20fill-opacity='0.35'/%3e%3cpath%20d='M11.7895%2018.9218C11.4758%2018.8949%2011.1817%2018.85%2010.9072%2018.7872C10.6424%2018.7154%2010.3973%2018.6392%2010.1718%2018.5584C9.95613%2018.4776%209.76496%2018.4014%209.59829%2018.3296C9.44145%2018.2488%209.32378%2018.186%209.24536%2018.1412L9.87771%2016.9567C9.94631%2017.0016%2010.064%2017.0644%2010.2306%2017.1452C10.3973%2017.2259%2010.5836%2017.3111%2010.7895%2017.4009C11.0052%2017.4816%2011.2257%2017.5534%2011.4513%2017.6162C11.6768%2017.679%2011.8875%2017.7105%2012.0836%2017.7105C13.064%2017.7105%2013.5542%2017.3381%2013.5542%2016.5933C13.5542%2016.4138%2013.5199%2016.2658%2013.4512%2016.1492C13.3925%2016.0325%2013.2993%2015.9338%2013.1719%2015.853C13.0542%2015.7633%2012.9071%2015.687%2012.7307%2015.6242C12.564%2015.5525%2012.3729%2015.4806%2012.1571%2015.4089C11.7453%2015.2653%2011.3777%2015.1172%2011.0542%2014.9647C10.7405%2014.8032%2010.4708%2014.6237%2010.2454%2014.4263C10.0199%2014.2289%209.8483%2014.0046%209.73063%2013.7534C9.61303%2013.5021%209.5542%2013.2149%209.5542%2012.8919C9.5542%2012.6407%209.60812%2012.3984%209.71596%2012.1651C9.82379%2011.9318%209.97572%2011.7254%2010.1718%2011.546C10.3679%2011.3576%2010.6032%2011.2005%2010.8777%2011.0749C11.1522%2010.9403%2011.4562%2010.8461%2011.7895%2010.7922V8.85742H12.9954V10.7653C13.2503%2010.7922%2013.4954%2010.8326%2013.7307%2010.8865C13.966%2010.9403%2014.1767%2010.9986%2014.363%2011.0614C14.5493%2011.1242%2014.7062%2011.1871%2014.8336%2011.2499C14.9709%2011.3037%2015.0689%2011.3441%2015.1278%2011.371L14.5395%2012.4747C14.4611%2012.4388%2014.3483%2012.3939%2014.2012%2012.3401C14.064%2012.2773%2013.9072%2012.2144%2013.7307%2012.1517C13.5542%2012.0888%2013.363%2012.035%2013.1571%2011.9901C12.9513%2011.9453%2012.7454%2011.9228%2012.5395%2011.9228C12.2062%2011.9228%2011.9071%2011.9856%2011.6424%2012.1112C11.3875%2012.2279%2011.2601%2012.4298%2011.2601%2012.7169C11.2601%2012.8964%2011.2944%2013.058%2011.363%2013.2015C11.4414%2013.3361%2011.5493%2013.4573%2011.6865%2013.5649C11.8336%2013.6726%2012.0101%2013.7758%2012.2159%2013.8745C12.4316%2013.9642%2012.6768%2014.054%2012.9513%2014.1437C13.314%2014.2782%2013.6376%2014.4173%2013.9218%2014.5609C14.2062%2014.7045%2014.4463%2014.866%2014.6424%2015.0455C14.8385%2015.2249%2014.9856%2015.4313%2015.0836%2015.6646C15.1914%2015.8979%2015.2454%2016.1715%2015.2454%2016.4856C15.2454%2016.7548%2015.1964%2017.015%2015.0983%2017.2662C15.0101%2017.5175%2014.8679%2017.7508%2014.6718%2017.9661C14.4856%2018.1815%2014.2503%2018.3699%2013.966%2018.5315C13.6915%2018.684%2013.3679%2018.7962%2012.9954%2018.8679V20.8574H11.7895V18.9218Z'%20fill='%230EE827'/%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_5437_79079'%20x1='20'%20y1='4'%20x2='20'%20y2='36'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23D4E6E8'/%3e%3cstop%20offset='1'%20stop-color='%23767573'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",HAn="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTYgMjU2Ij4KICA8ZGVmcz4KICAgIDxsaW5lYXJHcmFkaWVudCBpZD0iYSIgeDE9IjAiIHkxPSIwIiB4Mj0iMjU2IiB5Mj0iMjU2IiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+CiAgICAgIDxzdG9wIG9mZnNldD0iMCIgc3RvcC1jb2xvcj0iI0ZGOTkwMCIvPgogICAgICA8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiNGRjY2MDAiLz4KICAgIDwvbGluZWFyR3JhZGllbnQ+CiAgPC9kZWZzPgogIDxyZWN0IHdpZHRoPSIyNTYiIGhlaWdodD0iMjU2IiByeD0iNDgiIGZpbGw9InVybCgjYSkiLz4KICA8dGV4dCB4PSI1NiIgeT0iMTc4IiBmaWxsPSIjZmZmIiBmb250LWZhbWlseT0iQXJpYWwsSGVsdmV0aWNhLHNhbnMtc2VyaWYiIGZvbnQtd2VpZ2h0PSJib2xkIiBmb250LXNpemU9IjcyIj5LPC90ZXh0Pgo8L3N2Zz4K",FAn="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTYgMjU2Ij4KICA8ZGVmcz4KICAgIDxsaW5lYXJHcmFkaWVudCBpZD0iYSIgeDE9IjAiIHkxPSIwIiB4Mj0iMjU2IiB5Mj0iMjU2IiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+CiAgICAgIDxzdG9wIG9mZnNldD0iMCIgc3RvcC1jb2xvcj0iI0ZDODAxRCIvPgogICAgICA8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiNCNzRDRjAiLz4KICAgIDwvbGluZWFyR3JhZGllbnQ+CiAgPC9kZWZzPgogIDxyZWN0IHdpZHRoPSIyNTYiIGhlaWdodD0iMjU2IiByeD0iNDgiIGZpbGw9InVybCgjYSkiLz4KICA8cmVjdCB4PSI0OCIgeT0iNDgiIHdpZHRoPSIxNjAiIGhlaWdodD0iMTYwIiByeD0iNCIgZmlsbD0iIzAwMCIvPgogIDx0ZXh0IHg9IjYwIiB5PSIxNzgiIGZpbGw9IiNmZmYiIGZvbnQtZmFtaWx5PSJBcmlhbCxIZWx2ZXRpY2Esc2Fucy1zZXJpZiIgZm9udC13ZWlnaHQ9ImJvbGQiIGZvbnQtc2l6ZT0iNTYiPlJSPC90ZXh0Pgo8L3N2Zz4K",qAn="data:image/svg+xml,%3csvg%20width='40'%20height='40'%20viewBox='0%200%2040%2040'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_5436_78897)'%3e%3cpath%20d='M35.911%2020.0773C35.911%2019.7026%2035.552%2019.4866%2035.1114%2019.5939L4.79962%2027.0055C4.35812%2027.1135%204%2027.5052%204%2027.8792V35.4541C4%2035.8288%204.35812%2036.0455%204.79962%2035.9375L35.1114%2028.5266C35.552%2028.4187%2035.911%2028.0269%2035.911%2027.6523V20.0774V20.0773Z'%20fill='url(%23paint0_linear_5436_78897)'/%3e%3cpath%20d='M4%2019.8353C4%2020.21%204.35812%2020.6016%204.79962%2020.7097L35.1159%2028.1219C35.5573%2028.2299%2035.9155%2028.0133%2035.9155%2027.6393V20.0637C35.9155%2019.6897%2035.5573%2019.298%2035.1159%2019.19L4.79962%2011.7778C4.35812%2011.6699%204%2011.8858%204%2012.2603V19.8353V19.8353Z'%20fill='%23FF9800'/%3e%3cpath%20d='M35.911%204.51106C35.911%204.1365%2035.552%203.91973%2035.1114%204.02778L4.79962%2011.4387C4.35812%2011.5466%204%2011.9383%204%2012.313V19.8879C4%2020.2626%204.35812%2020.4786%204.79962%2020.3712L35.1114%2012.9596C35.552%2012.8517%2035.911%2012.46%2035.911%2012.086V4.51106Z'%20fill='%23FF9800'/%3e%3c/g%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_5436_78897'%20x1='1762.84'%20y1='981.852'%20x2='1845.15'%20y2='624.882'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23FF9700'/%3e%3cstop%20offset='0.53'%20stop-color='%23F48E00'/%3e%3cstop%20offset='1'%20stop-color='%23D06F00'/%3e%3c/linearGradient%3e%3cclipPath%20id='clip0_5436_78897'%3e%3crect%20width='32'%20height='32'%20fill='white'%20transform='translate(4%204)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",VAn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAAA0RJREFUeAHtmM9PE0EUx18pJCRaugUhQkuqXgi3eqDVpJFK+g9w8Ejkohcg4I8DFynECxdEAlz0gA0nNYF4kkODRDQmNQQ8NRhjbd1FrQHankja3XFm7DbN7rQMyS7l0E+y3dmZt/u+mffednYAatSoLpZKg9s//wawRUhKJj2/90QBLNgcocJt+EyvAQo/UBwv2qkeCm7o2P/ri+3OtOuSewcpEL7quvACTsJ2PC5sJf8sPQw9Rh2dnaigwPCjw9WJJmfm0FYyNUt8Ai+f4+Ls3dEHpgnTHndG76NoXFpiaanXdnz8Gh988+rl2LO5GXrd2NgILS0tUFdXB0aSy+Vgf3+fnp/PPYFztvODn2Lx8PXuyxuldroc/BD79u5WMBD4JYnQ0NAAbrfbcHEqiqKAKIpwdHQE7U4XvI683/B3X7lZaqPzLCV+eIg4Qmtrq2niqHP8bBIdAvEpJr57dDbajj1RLCar1Wot9i8vL0MwGAQzRKpgkXbduLZDlmVg4XQ6YXFxkR6kbQZKXtalnE4gwnnBYmhoCKLRKJ3F9fV1mJ6eNlwozkkExwlU5Dzz5lgsBgMDAzA+Pg6SJEF/fz8VOjw8DMYJ1EePO8Qqq6ur0NfXR2eT4PP5wChknhArZUKs4vV6acGQczabhUgkAkbBil693kguK2xkZISeCSsrK7CwsEDDbRSs/OcWqBYFCe38/HwxxEbCSi+9QIUtkAgis1ZO2O7uLpSjq6sLeGD51gnEicq8mVSv2XDNIFIqV3E5eGepEkjmeM0cV8VmIvMILBfi00DhmkFURYFIHz3GX10VBeZ5ZrCaApUzLhAXCcdqpopVjF9xxy8WZPmMVzGqqkCOKrbZbGm1fRqzWZpS2Pehdlwn0C7YdxwOB20fHByYmpPk2alUirYF7FMQhC9aG/1iQZanfNd8gbW3a/R7NZFIQFtbm+Gfn0Sc+uFOCAQCkM/nwlw3PwqFlnp7e09t6+MG9jUxMfGUpaWe1Wm1WO75/f40zomxzc1NyGQyYAaCYIeeHi9ZpYdxhCZZNhW33/AacBBvmd3OpA896WxW/aBHFry/hkr24TTXWrT7dNSmydaUdjQ37+DmFF6tb0CNGmeUfwIH0sS3Pm7dAAAAAElFTkSuQmCC",QAn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAACs9JREFUeAHtWHmMVdUZ/93tvXffPjvzZpiFwswILkEpIIqMWlAWjVpBTTXGYk1tivoHWhurorVp2miiMRUaW7FWkSaS2IoLdYPUBkXBBkZRUdaZgWHWN2+767n9zrlvGJlhebX/td6bk3lz3z3n+53f9/uW84Bvr//xS/pPXm5vb1d7e3tlfMMrFAp5V2y/wl2FVazUOacCKC+dtDR275U///PU1NT5AUkLecwDH6PTRj6X/kySJRoyXOZae47seXvZ80uXfdL7Sa74UskA5Z0rdv6ipbZtVWY4RxO9b8zaqS7P81gkqct9ff0PNz428SF6xEoBKO29a/9D8WDiPpex0oB5xwyKJSXpFKuf4NJkxT2Q2ffI9KemPzwW5DgATcmmRGWy6n7bdmXmejjdcB0Gx6XhOAjODCA4S6PPbvEZQylrmLajtFaf8cDihsWJsXjG7XH7rR+/WR1JXSJDHgeeMyRuiz5bDHJMFuwxj8BkHDStSUFSJOy7tQtqXIUs0fdEpzPgQA7RirokTMrSeGpdEndndv+mOc/MWnhKBlsq2trhYhx7nA3XJWZMhtg1YVTcXQYWBSzbESN8UQjMoHeyLsLzQvTMhkWsMp2hcU0talaWwy64tJbrM8uOX19iknR29VkXj8UzDmAQAZXWIDCeP5j/lzEGmxY2LQtSUII7xFB+XQKWbMGwDKgTFXqHswmoDSo9M2HYJurvrYbTx2iODKNgiTX4Wq7jHWeDg9QQCGKMV8cCDFqkH9dl/hAL+Z8doTXaPd2Z3TnBgENsNayow+DhNByPdkWu5sPxHAx0DqHt8WY4tBEKVqR3ZuBqLgF0it4oAi3aEJq1PTShKXhSgKlUSmG26zNB9pgQOU0k11ikMcdyhNv2bexEMKkJMFa/ibJ5CRTShgg/PoxhA+WXJIg5hysXalLG7qf30lxLBJOdp7UMH5hvA8KmS+QUagrKSQGSxiROBAflFiPRSDvkpipM/nUK1VdVIDeQh605OLSlm9zpCUDfuaoR3R8fId94AlDXh0cwbcUUeCKAPBze0gdHsWhuAckL40jdXomqW5Iws46wwXXJXD/iT6vBEea4LrgrjJwBvSkgojExPYzz152N1lua8d6j2xCu1IlEhgIZVnQVkkoRGpAhhSTYg46I+lCthtfv3IyJl6dw7m+nITqV5pDK+HMzZxal4zPJySkBIBeuD5K7A5SZdtz5BdQyWcjXGWComJbADz9divU3v4xIlS42VXdOijKuJErZlAXNYDaDVq7g2Xkv4cZNV6N8WhnMQUuA1hIqdj+xn7KAJ2yMBExJDPoR7O+K/7UtG5m+LN666QNoVSrtnhYhEMZhGzf9/WrsfGU3tJAKPRZEYbAg3o3VxqGGFWx/ugPXrb0S2Z4CUHS/XhXC1gf/hUx3FpblHLMjotkpycXF3MRGJ/Jd8vTy3Oy/YscfOxCq0SATW2a/i+k3TsXBjkPk/ghiZTEkqwhchYRPX9uDyXMnIdefJ9dDMP3Zxi/x0vWvwcgbsF2nqLuv58Rx+KCOY9Apvgw/FxbILdVLyhFtoURMGbwwbOLVu99FIKrhzCVtiNWE0bKoWYCQSXtcqyzvonXJZPTvGER+yMS+jw7ANm3Un5fCrNnnQPEU5L8y0bMxDSXKN+uzy3jQ95wWIIq5yUHVZXHM+nELrGFH5DKv2BVMXtRAwUBgZA+de7sxUW+El6TkPeIhlRxj0mZSGUy8oA71C6rI+Kj7JH7PldD2k2YcerEXPRvSBFIlT53OxT0oupS0R2J0OSjH350YYn5xEe4WEny2kCFWGTJZIGsDOarTw1mPciGQHkqLxmHUijfa9XEpyzxveiJ5i8zhsBJc7Po1l7N44G89+OS5r1B/TSUSrWHqCj3kKSEf3NZJLlUwZWYjDKosufoczLwGtTzgR3q/BT1P0eqq6P94CB2kx8KggUlzGqAndSJexvCeHA6+1IdoPEzFNQiJ2zxBFJ8AYDHVMB+kFAH2vt4F6xUTA4cH0bq4GZffMY+iNQ/ToLRhuFi/4U+4ev6N8I5SlFOSk6nUvfDGWixb/n3E9Sgu/un50KsD2PyrbXj3mW2obKxAQA4gEA5RWWRQiBTZY8L22Ou4wlyDmsjmRZ9njxhdop5ajAq+a8D0KOro87K1C5DtNUSE8xEuD+Gddf9Ew2WV6OjYhe6hLpEH40Y5pk45E4NUsxf9rB0WlTxZUUQjq9cGsG7h65AMFUEliKAcQkAJUQpVMSFUh/bXWqM96MmdWIPAsXBnLq1GDbUsKdDjOq79w3wMUz4TZxKSSrIuhkcXP43LVl6EhF6G+kQTZs6ejZnnz0ZNsA5lkTJceO0M/PLspxBOhahKMDGv0G1h2YYFSDTEiB1yIFPgl1eUWOocv3CD+QALPQ4uf2IW8n0meI2KUHk7tPMIVrb9Bqs+vwOFXhPxRBwH3utBc+MkNKWa0LNrEPF4DPlBE/e9dTtWxB7Bns0HoFWqouGxqcNZ+Oxs5DtNSJ5vRzQLpeRBAW7kRZqsBVUMHchCDSg4RE3Au7/7gDpjYPmaa5HvKkBVVCQnxGAM2NADupimaRol7KRoDgY7M1j+5DK8/ej7eOPBrVj0wFw0XZqC9aVFuZSCypUFTSJPsNNoMIVU+NWLOnJHzcPkDb+v49rLFXLIWzl4IXoGG+neDO757GaYfZZY+Z3V7yPeFMZZ17SI/3e9vAddW3tx6Y/mcLOIEetPLvkLIjGdGCFO8grCwQiikSgFSxAq6U+GgqpQLRZuOePkGqS4ouOFNFqCRMnzKInKCOhBUQEk0szC+y+A2euQ6MnlE0PY8vvtiJRFBZuqqiFaFsGujV8gQVWGv5PtMzD/rjlirkx9czBCoALqMd35DQr3sUSpuMc9qQb3Y781ooeRptXjgcLIsKfSHgNwM8Ck79WBn4e0MhWPz3kRVakKfhQiMLIApNCdrCnHk1etR7RaF+WvceYEsAyFhafRRgOkPUXonNsQLf+otMyTAuQStG3LPNY8evwwQwA9DjAIjRbmqcGmVl9PBfDCdZvIqEdwVBzdNSBOa1wzRzoGiCfuzACev2UTRXxEVKcApRQNfASgMK0IEhhpkg3eso/5hWHc+W9N68Z3Jqj17RQfEhPvMtHDUdr2NemZyAwPI5POIprSRTLn7+TTJu459ANRsh5rWQ89HOScivyX6zERiYQRjcVEglYlahCKt2Cdo/Ik1ud0/+O2zxe1fx2PMhbgfuOrN66vvG1lxsmIDt77Winm/3BNStRqBaNBwS53J89nqkqaouNn14d96NuRoV8LCAhxJZPu9Agl40BAMCqe0Rxe7kRrTYPbmKDVSsv3Xjq34BSGTwnwqN1VaNPPK6tUamcwLkC+AJP8QzvzD+miH/Ek4VqZBg8ebrT7g34c/mhQ1FYBhpji7yhFhyskFS4XicBx93JBcHCkS9aR37765d7n1o/FMw4g5+nNoQ1vnhu5sHZK8KwZw84wE/zzX7Y4SO573olw7oRBbogzQu6UFQHKDyhNfC+AcZZHgImk50uf1vOqlVrsyG1dfc/BG+7ECX7hOtXPO0oiVNPwUOXqdWeEvjuDTKs8C3ItjvSFfvfF4N+OYNcTEAi+pBzT2KgxP8I5q47kWh359z9cO7Dqho5CRzdGy0PJAEeuEQtaAomwGw1p+C8uJWvYaaT5IcUsru3i2+v/+fo3XDNIGH8X+FsAAAAASUVORK5CYII=",UAn="/assets/vscode-C5BXgFjm.svg",WAn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAACSFJREFUeAHtWG2MXFUZfs+Ze+/M7uwnLNhiqd1dWknaBETS+EO0JRWllRCjjSY2EhP/GP2BMSZG40fU4A/RRIs/FA1iJNaQaAKCiiG1dGu7okVKCK6lFWrb3a3b/ZiZnY/7ca7v855zZ2d3Z5chJIQfPcnZO3vuvec87/N+X6Ir48p4aw/V6TP79+/XpVKpv2twsC+uVHzj+4oaRMbUlDG+Mr5R+SCQFxphSL38O451SrwULUap1nGKe55XNPl8V3jq1PjcxMREmZc0z9TN9UGsc09974EH7v7oRz7+8ziOBiuVCimspnx+Pk9a56hULpHHV8/zyGdwURQxeEM9vT2U8lUxjlq9xr9TynmacjmPYn4mKOT5nqLJixfGv/qlL9w5NjZW4p0Tep1ABc4Lp185UyktbDGGCdFMYCMk3/cYVMAHatI8G/UGU8EgGGwQ+MxiwjOiYpGBpgYyUbVWlfuel+P3cpQw6LBRpyiOIZR5x+br9Zmzr3xuz23v+SmfG7cDpNcASv959fy/5i7PbE6M0dg8x4wVi0W5BnlfDtRMryfAPVJaZfLJ+5kecfX5vhymPdGCh/2YWdzM5/N6cmqarhq86uBDj/zmDn4s1w6P1w78gw8/ctdseXFrsdirw7Aum3qek4nl1UqTYbYUA8XBJjECCSqXTT2fIacCMmHWUqcjrUlYxj+JSRhkwLPAvw3V6zV95969T9AaWm6HPv3Bjw7+tV6rd+dyAKIdG+59BgkI1lRTmQJQkVyzNc0swi4zWmHbEAwzSawpejloRvF7iQi8MD9vRrZuPf/0U3/650pQbdFPzy6k5y9cdCDtIyY17tCMuUzN9iC24+YVQgVBQbQQcgTI1qAZAIbdglnYumag9VrNaobfZ0Ge23nzjltWYlql+l27dg1VGw2xOwvIsiJAmAnYYsKqNknMv7UwFEexPAdHkk3ZbuMYaxYogOFZD4yLaEqAJwmcSYndY++Ao8bQNVcPU5uxCmgvjzjkDYS5VNSMMAM7SqyXyqGwS8X3ARzPJHEijHR3F+m+b32denp6RAjTVLsW54NZ9Pb10Wc/fy+VywscRXwLhMFqZjyndb4joIVCIYfNEOtgj1Aw2MmAivbBDE+Yhkq1qBFCxQz+8swMPTt+QoBmppPZJoTCFV7/2G8fpSeePkqVcllCnhU+5hAY6Y6AVuMYLisGn6YOmAMHlhEfhVXccF6vhTlDU5MX6cTxMWa1u+lkSmVhC94m1FLM9/r6B+jFF07R9Zs385pPEZuInKW06ggo25Gq1+tyEBjKvLvY00df+/IXaeyZI8JIkyU3GxzA//zMOB09fNiBW2ss3bPgVOaTrDn2CdP+La/9Vto5Rioqj5nd3/3iZ/TcP/4uQX8lSMwbt2+neqNG/554SewUNkltnlsWptLE2neSiHnBXo2JOwMaaw2LE6+MokTsD1569MhhYXat8d7b3k8zl/5nYw85QLT+QOKASSHl4mmchUTQ9tm2i2zY2oWeLIjDFjGEjRYHwQG1apXedetOOvX8Seou9pDqpCYjK4jk+9TGWQlja2T1VasMTCEuQvXKBekskyw7IfupbDLYMjxCY0f+so59LhdO0qjzAZBi3F7pGka6CqjmGtIG4kRSIDZG+ZY6la46nu9ve+eN9PbrrmMvft7l9fa22SqczVBZik0FCLQXhXFnQMEoJM3KNclOqbXZ5YctgfjQ3g/TpelpKQMzvjoZYl5uGpdUdPvotLaNKmczArhF9RaczoigxcUK3f6BD9Lfxo9zbOxfJkDrO00pW9YTF48lRhtb6GQV2GsC9TiQIlRkhYMEthWNQnYWpEcuR9B+6g9PSo3aOloBq+z/lnUU0onL/+RsV3XKKG+QIqCjSDCpZQ32SsscYemwYXYiONz48WPrhi9qZZUsCYibSrmAn1o2tOrQ6+NcLuWSXqT1clpYUlltRrQq9OzecwddujTNJrBIayCkpnBNzIqq/PyW0RtsLHUg8bdZTq4YqwK+jqLUuIKD5MW0WQAvy9s8uCqn9+2+nS789xx98lP3UBbos5grlRe/b9sWG5ex0+DgIH3iwD2cxSY4i3VZ+3TnJUmHQLkUlU7SplAuIDhUjYyO0jDPi1x0SGdpKxIO9DXavuMmmp2doQOf/gwVuK0AIyFvslSUaGkEUcah7kQ9Bo2hWN62bZtoDt3t5NSUCIPQ2BFQ3tDYQxLRNvofjPt/+GPasXWLjXmuXCt0FWj76KamrWHedPMt9MtDj8rhNS5uuL60DSHHYszWwhnaiji5oDbo7xugcqXEewVpR0C7unQD9aF2DoUaNAwb4t0nX5ygsy+/LEzhPsxDCl6Ubq6wQB1aZaYD1+NDaJ9bDk86Udu+4FkT8R7KFswoc4eGruZrCEGSjoBOT08voDMsl0q0YcNG6ufYGEWhgJifm2MWu+S3AOErF9oysbYwvyCRYrG6SF2FLnQLYkJQL0BCYHxFESvXupk+OdAw+JSrrwblqtX5joAeO3asHHAbC7uUbAHpXTOXZ0BwFKgVRo9POAUGBKBSv7psxuqTjxMAn5lOxOvQjm1nbH+Slw8WRlgtl8oI2emrZ8+cbAe0bdCanpx6lu1I3E/6d20/D8G2wM7AQL/05AAC9aI0AzCw38f9EGzO93wBxN+raH5hXp7DCIJ8M/uE8vknkW4VLUlQCNInH3v8G+0wtUsDat++fQP3H/zJbIHB2BaYPZmNXhKBtLS2T5pnVYNBsIb2o7vYLQ4C/Ye8HnLuD3xrm9K9smBQPT7v4GQ4oe+aOnauuKfgz2689pq3tQPa9vPJ6dOno9179py/YXRkXxjGCpIvsrozBvGNCQP/25kIq7776JDZIjwbawCknU3CQbNat1mUsAMNb9roDfSyJy593Xtt1fNIPnbX3od+fejQ3Zs2XisMYNMqO0mZAc/MXBa7AosDA4O2PeGXoGb0Wwg5AXt6pn5bENvjss5UshB/LSsW8umGof65+77zbZAG+k2nql8piHnw4V8d2Hnru+/1C8URPqILVepAX48EcrsL2hYjwVo78/BYnYG/lKFg37V6yETqlL08btQalXMXzp34/eN//Mr3v/vNlxwWQ29wdFpivtX2vjKujDdt/B9Vn+PpjUxyeAAAAABJRU5ErkJggg==",ZAn="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTYgMjU2Ij4KICA8ZGVmcz4KICAgIDxsaW5lYXJHcmFkaWVudCBpZD0iYSIgeDE9IjAiIHkxPSIwIiB4Mj0iMjU2IiB5Mj0iMjU2IiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+CiAgICAgIDxzdG9wIG9mZnNldD0iMCIgc3RvcC1jb2xvcj0iIzA3QzNGMiIvPgogICAgICA8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiMwODdDRkEiLz4KICAgIDwvbGluZWFyR3JhZGllbnQ+CiAgPC9kZWZzPgogIDxyZWN0IHdpZHRoPSIyNTYiIGhlaWdodD0iMjU2IiByeD0iNDgiIGZpbGw9InVybCgjYSkiLz4KICA8cmVjdCB4PSI0OCIgeT0iNDgiIHdpZHRoPSIxNjAiIGhlaWdodD0iMTYwIiByeD0iNCIgZmlsbD0iIzAwMCIvPgogIDx0ZXh0IHg9IjYwIiB5PSIxNzgiIGZpbGw9IiNmZmYiIGZvbnQtZmFtaWx5PSJBcmlhbCxIZWx2ZXRpY2Esc2Fucy1zZXJpZiIgZm9udC13ZWlnaHQ9ImJvbGQiIGZvbnQtc2l6ZT0iNTYiPldTPC90ZXh0Pgo8L3N2Zz4K",GAn="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20256%20256'%3e%3cdefs%3e%3clinearGradient%20id='a'%20x1='0'%20y1='0'%20x2='256'%20y2='256'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%230ACF83'/%3e%3cstop%20offset='1'%20stop-color='%2305A2C2'/%3e%3c/linearGradient%3e%3c/defs%3e%3crect%20width='256'%20height='256'%20rx='48'%20fill='url(%23a)'/%3e%3cpath%20d='M80%2080%20L176%20128%20L80%20176Z'%20fill='%23fff'/%3e%3c/svg%3e",YAn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAADQlJREFUeAHlWAtwXOV1/u5r3w/tQytpVyvLdoRlG+M4Ia4NxMZ2SELo4IRX6qEtbmEST6epoU3K0EIKZZpCmk7JNCRpaSkJEFJahhhSY9pJggfHJiHYxg2OJSzr4dV7tbvSah939z7y/XfltwyaSTLJTO7Mr6u797///f7vnPOdcy7wG35I+NUcyvbtO9Ldy5bdl2pftDHIY2JivDQ9XejPZDLPvfLK3l1vvnlgeCEL/WoAJpO+jcvfe7KnpyeqV6vw+QK44qoN6OpsR80wEAqF7ZaWNimXzT5+zz07b5/DYeOXAJDz7+d4S8LVk2eeLRbPXecN548n6UVElf1d4ebWW2o1/Y5auFXe8sF1UFUXNFWDbVtWKpWWPW73C3fd9emtfEjhMM974UUPGStXqi13/suj2nvf90nJ7Q3CsM48YV/kKduGVTVhTZdhFSZgl4uw9QoqhmV1PvOAjGoRy7uXw+P2QFEUqJoGRZbNLZs/otxy87XSPIzMeyixr/5wm/+qtU/WTxbtbBnS+6IKVjSpCKu8Kc/h4x/5vBVsy4ZRraA6nYPOUSvNoF4pQy+XoLu86P+ne+EO+hCLxWnqJprfB5fbjRXd3VY+Vxx7+OH7UmeTNB9AKfHo/j/Qlq/+93y2qj59ZQAjVQuPHNMxxnPdmkN2GhAB81LRQLPJ3LGNerUGvVIhc1XIdo3nMt0gT1azWPyTXZg8/Ar8/gBCTU0E2ox4cwInB/pw7bXXGZcsW6Nqqic7NTWhvfTSCxvnBZg+WLdyPTMYuiGC5mdzaAsrOI1rzp2rZOryqOpcZioWsjqB2Y17btkm0zY6vIRrWTiYrUKtzMDKjsB36GWUX34Cer1GE6vweLwo5KeguHwwayV8/IZtWL58pbNuMBidUs5HF//yvqclO7TysfUB6fIXC2gLqsKtnBeLh2ZrNtbHVFSIpnfGQoHAygbg4k3igir8gzMrpoRsTcJARUaz14VVUS+OFy0sG/wREl4NsiyjpuvoTKfxmZ33ohRKIZcrojg1gtdeexWlyiw6O7r/RD4foPvS1TdMztrySNlGUoAjU+CQOSSONU0K9o3XUSLQmCqhTJu7uYONzSqSHmCxT8b7OcfHuZWahYjc2NT+KWBpsgWr5CKSqTRWrLwMiZAPxpW34kAuj71yC5If345MScVoZhgfeP8Hcffdd3xDPR+g7Ap41kYMfO2njEJr7jcOP8EI/zteMOGTJAfgUr59kVdFhPQdmjRw6xIPWTUQ5vXaiBu7RwyaGziUM+AjvRNHDsH2h2DPFKFKFqTNd+CEbmHYDmBJQsbxumx95vprdv2scv0n2hLxnfMFidr+PaN+jauCZ/t0hNwSiMUZLr6IhDiggwTgI+ChkoUNZO4HI3W0hxRcGlGwoUXFnuE6JBLv5Zz/5b0Ov4wyI3XzM3+GbKWGUDiIob5+7F9+PbyhCKpqCFvaXTgwZSP71x/yptPp6MmTJ7PEUzvfxDLoT01c2BQeTzBlHUh5ZOg1XvJeG//XeKtQFqYFvp+p4aG1fswwwj+cdOGJXh390xa2LSGDx3XQ6sjOGhjf/ypa0x3UPRXmTBaDq7dCCcSoZx0wo51ILVoCpXmxE6QENyLAnbLeWUenLGRDElFhNsaKEKmniYQfkggUGLH5is2U1fDNADfzyMEy4nz65UEdFb3hr48eLiPokZxN6p4Atmeew/HMCNKpJPqydWQQRFcqBTmUgOShHgYjUCKtXKX9PMbOOQwJ4sUiank2yOLoLJliVFZr4sUMIhHQvGcbOD3GZ0x84YoAfjxmcBMSnt4UxBs0rWBcqhuwv/8s2rtXMXu4MD06gCNd1yEQiCCrRGDKPm5CobNxaC5cEBMX/GKeGrZjzpmy5TAlzNzulZGl39m8J4bYhGBrXauG+/bPIkmfDVK41n0jh23dXmdDJVcUOz1H0NPXh0XpFH5ysop4tAmSL4YyfEj5XA1riYCcJ31eCJC7FpPteoMdsSdqKupk81jWgGKdtQn+P5U3cdN7PMhzI29Rfja0aVjGQLmE4p4t2GjZ80VEl65CiOltYqAXb3d9DKYWhMWhKS6YXMeqNdzl3DLhnQDaDQZn6G/CnF5eRjWKL68dF5gbCud89nf8+Ku9RYQ1GVsZGAMELPz08Tdn8beXjcH942fw1Leeou+14wfMTqoviFk5Ah/9EpaMIufKpxg0FgqQOxHmqdUa5mWadSLX8RBrLoB4ztH3Juij3RTmYxOG85IJ6mShYMHyhfHYHTfDHWmGz+vB8//1DDLt66G6QkJr4RXJ25KoDpYjSQ2/XyhAkTXMhqyIa+FnGTIjWWc2oDNaH7sujN09VQzmTHxpUwDfOVzBvsEa/uFDAczu/jcEYjG4KCsqy6rx8Ukg0eVErKwwMGzFsYJVb7iKY94FATQbAIVpMRcIAuxs9Yx5JY5Omvwrr5VoWsmRnyf2l+BnceBRJNz7mozwvkecotTl0lCrljDZvhmqzWpHDVAT5lLo3Fqn/H7hDM7JjAAmAkWItl5tyI4Ys9MmPrU+gCpFfJzM7qQfHuW5Tmc3LBXub30KnlgbNIJTWTwODw5BX7oJJjOGSemuMT9YdaEEcPK7XbcuGiTqhQAb/mXXbEfTciUT928Ks6KxnVQndqQpQhct7PgApYR8TM2aeOiaIMr8zTIKePxfD0KLNzvmrdcqGAlfjgeviaDgbUFHawzThoIwJelzu2cQZXGRn8taCwDIIs5qTBbMUfpwyyov7mbZFaEdxS2RQVqZd6eohzEuXuLiIj9HfARqemF+/ZOIhaME12Cvvz8D39W3Y6Dkx3eOMbNoZQQ8CsYYYDdf5sUPB2qOpJ1657sAHDgdBNJctB7qr7GWU9HPKqVIk5oEWCrZTuWcL8xRSnYnczY8hYNodRnMt25omkJ3qCLr7YZf8eDJIyr+cVscO/+7jLxaR5qif3So5tSQkmWfUYd3MbFtn+WD45SMCBfyM+BWxDUEGQQJn0KtM5AnyC3L3TiUqTcaG38EJx74MJSmuGNa0RANDQ5g9e/ei/+fCSAaDOLr+6q4cY0Ho2RvjH48Rokq6tZZQXIhwIvoYMOBBfoIE/4Qgb4+oOPGy3zYdaSCo6N13H6FH1/9vyIOk4VDlJY3v/0wXMyvmqpwqDBqVUzIHTg85sZ9W9OsflyUIwubuzz40du6I1txbl6eI8NhcKEyY5qnqhmgl0l/aUTFapr5/l0FtDPZRhg8//w/08wGUmO+EkC490n2uwTnsCdjfGSUtN8IF7vVv3/JxKUtHqe5+otn89jAjLOE6/WM1hqBQRcxF6iDFthLTLPc12zJKQiErvWNG/jjTSHk2FP0ksk7P8KqmBVsuSq274Jnz6eh+GNOreewV9cxYcaheKKoS2G0JfzYtj6ICvO1iN7tV/pxYqzOIJQcIhiamGbQNXwwY50N6IKuLvU3dTuFSQfMrJAbAYEgNe7wxvV+luYq/vSbOQToj6vTGkanZqB9lynNH4bX64ab2jeaGcRgxw50LOlCrLUTb016UWbn+cJnW3CCrcEXny+I1g9Vo4ElSqBR1p0DdgLDD6jSO5rY0kvlg6yK7/pYqJEjTTgCrNMMX6JuffPVWQTIgijne6d8qO66jUwFHNOqp9irBhGJt2FkNoDjWRVeRrSP/vbQi9O4k5urM+iqIjjmeuodHw3hQI9O7Z2tv5uJoR/fuzseVa0kvyKMn6g19EkEGv0jxV0eYUCs7XQjxFxv9O9F0G05ZhX+p5CJyYlxmO+5CbrhIaMhAlHZ28hYt9iF19kCtIVlZibHmZxMNXpCRwd7mURUtmr9r3/vfDwXNu6RJeHUjqOF3NsjyPzHIsR+bwBtnS6KsX3OQ1U1jtY9l8NFefF4XM6wTAO9/ePQ13weibYU0skkK2YPDnNTXpd0Tj0q3G98oI7J/+xE+o8GEelqxvBXknF+iJo6G86FqS5/olg5/O3PNS297uH0Hw7Kz32+FcPsSb5G8wxRGgSTIu0l8l+G7A07zIkhGvHsxATyiRuglBUMDlFW6G+SVnWWrc6h41S0UhXuuj6E9piG9tsGEW4LmpW39jxIcPl3Z7BxKJGPPvGXvlU3fcHIT1mTk6a87hI3lpHJMFOe1+/B03++Bk3Mt6LPEEOwd6znbVx9+6MINCUQiiVZLHhPe5EIN9GLFRitR5ne3uitIpZQLTXULFeOPv9g7qVbH8A82fidPr8JdmOxrS8+5e64cqOkBjWRZkRa0oa/C/XI31k+v08OBPxO5hgbyZiF1G2KEb+C2YQtpCdEbPK5fcapt7FBglnV9cG9r1YP3PP7pYmfCrMa84FYyAdMFY3X8Ntb2EdnVDyyHFrU3tU32PczKxJtluPxGIplEwPHJ/wIzPgvupJEXeC3QExPV9Doe+WLAftFD6Wpqanzqi2fGI4n2u1IPGmnFi+7GfNlpl/zoXq93lQwmBR9u4rfxuPnTjEKD0h39egAAAAASUVORK5CYII=",XAn="data:image/svg+xml,%3csvg%20width='40'%20height='40'%20viewBox='0%200%2040%2040'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_5437_79109)'%3e%3cmask%20id='mask0_5437_79109'%20style='mask-type:luminance'%20maskUnits='userSpaceOnUse'%20x='5'%20y='5'%20width='30'%20height='30'%3e%3cpath%20d='M5.6001%205.59961H34.4001V34.3996H5.6001V5.59961Z'%20fill='white'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_5437_79109)'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M8.3001%207.39961C8.0614%207.39961%207.83248%207.49443%207.6637%207.66321C7.49492%207.832%207.4001%208.06091%207.4001%208.29961V28.0996H5.6001V8.29961C5.6001%207.58352%205.88456%206.89677%206.39091%206.39042C6.89726%205.88407%207.58401%205.59961%208.3001%205.59961H32.4138C33.6165%205.59961%2034.2186%207.05371%2033.3684%207.90421L18.5166%2022.7557H22.7001V20.8996H24.5001V23.206C24.5001%2023.5641%2024.3579%2023.9074%2024.1047%2024.1606C23.8515%2024.4138%2023.5081%2024.556%2023.1501%2024.556H16.7166L13.623%2027.6496H27.6501V16.3996H29.4501V27.6496C29.4501%2028.127%2029.2605%2028.5848%2028.9229%2028.9224C28.5853%2029.26%2028.1275%2029.4496%2027.6501%2029.4496H11.823L8.673%2032.5996H31.7001C31.9388%2032.5996%2032.1677%2032.5048%2032.3365%2032.336C32.5053%2032.1672%2032.6001%2031.9383%2032.6001%2031.6996V11.8996H34.4001V31.6996C34.4001%2032.4157%2034.1156%2033.1024%2033.6093%2033.6088C33.1029%2034.1151%2032.4162%2034.3996%2031.7001%2034.3996H7.5864C6.3837%2034.3996%205.7816%2032.9455%206.6318%2032.095L21.4272%2017.2996H17.3001V19.0996H15.5001V16.8496C15.5001%2016.4916%2015.6423%2016.1482%2015.8955%2015.895C16.1487%2015.6418%2016.4921%2015.4996%2016.8501%2015.4996H23.2272L26.3772%2012.3496H12.3501V23.5996H10.5501V12.3496C10.5501%2011.8722%2010.7397%2011.4144%2011.0773%2011.0768C11.4149%2010.7393%2011.8727%2010.5496%2012.3501%2010.5496H28.1772L31.3272%207.39961H8.3001Z'%20fill='black'/%3e%3c/g%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_5437_79109'%3e%3crect%20width='28.8'%20height='28.8'%20fill='white'%20transform='translate(5.6001%205.59961)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",KAn="data:image/svg+xml,%3csvg%20width='40'%20height='40'%20viewBox='0%200%2040%2040'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_5437_79100)'%3e%3cmask%20id='mask0_5437_79100'%20style='mask-type:luminance'%20maskUnits='userSpaceOnUse'%20x='5'%20y='5'%20width='30'%20height='30'%3e%3cpath%20d='M5.6001%205.59961H34.4001V34.3996H5.6001V5.59961Z'%20fill='white'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_5437_79100)'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M8.3001%207.39961C8.0614%207.39961%207.83248%207.49443%207.6637%207.66321C7.49492%207.832%207.4001%208.06091%207.4001%208.29961V28.0996H5.6001V8.29961C5.6001%207.58352%205.88456%206.89677%206.39091%206.39042C6.89726%205.88407%207.58401%205.59961%208.3001%205.59961H32.4138C33.6165%205.59961%2034.2186%207.05371%2033.3684%207.90421L18.5166%2022.7557H22.7001V20.8996H24.5001V23.206C24.5001%2023.5641%2024.3579%2023.9074%2024.1047%2024.1606C23.8515%2024.4138%2023.5081%2024.556%2023.1501%2024.556H16.7166L13.623%2027.6496H27.6501V16.3996H29.4501V27.6496C29.4501%2028.127%2029.2605%2028.5848%2028.9229%2028.9224C28.5853%2029.26%2028.1275%2029.4496%2027.6501%2029.4496H11.823L8.673%2032.5996H31.7001C31.9388%2032.5996%2032.1677%2032.5048%2032.3365%2032.336C32.5053%2032.1672%2032.6001%2031.9383%2032.6001%2031.6996V11.8996H34.4001V31.6996C34.4001%2032.4157%2034.1156%2033.1024%2033.6093%2033.6088C33.1029%2034.1151%2032.4162%2034.3996%2031.7001%2034.3996H7.5864C6.3837%2034.3996%205.7816%2032.9455%206.6318%2032.095L21.4272%2017.2996H17.3001V19.0996H15.5001V16.8496C15.5001%2016.4916%2015.6423%2016.1482%2015.8955%2015.895C16.1487%2015.6418%2016.4921%2015.4996%2016.8501%2015.4996H23.2272L26.3772%2012.3496H12.3501V23.5996H10.5501V12.3496C10.5501%2011.8722%2010.7397%2011.4144%2011.0773%2011.0768C11.4149%2010.7393%2011.8727%2010.5496%2012.3501%2010.5496H28.1772L31.3272%207.39961H8.3001Z'%20fill='white'/%3e%3c/g%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_5437_79100'%3e%3crect%20width='28.8'%20height='28.8'%20fill='white'%20transform='translate(5.6001%205.59961)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",r4e={vscode:UAn,cursor:IAn,zed:XAn,"zed-dark":KAn,finder:DAn,terminal:VAn,iterm2:BAn,ghostty:zAn,warp:WAn,xcode:YAn,"android-studio":RAn,antigravity:LAn,textmate:QAn,"sublime-text":qAn,intellij:$An,webstorm:ZAn,rustrover:FAn,windsurf:GAn,kiro:HAn};function o4e(){return document.documentElement.classList.contains("dark")}function i4e({id:t,className:e}){const[n,r]=v.useState(o4e);v.useEffect(()=>{const i=new MutationObserver(()=>r(o4e()));return i.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>i.disconnect()},[]);let o=r4e[t];return t==="zed"&&n&&(o=r4e["zed-dark"]),o?f.jsx("img",{src:o,alt:"",draggable:!1,className:e??"size-5"}):null}const s4e=[{id:"vscode",label:"VS Code",icon:"vscode",openWith:"Visual Studio Code"},{id:"cursor",label:"Cursor",icon:"cursor",openWith:"Cursor"},{id:"zed",label:"Zed",icon:"zed",openWith:"Zed"},{id:"windsurf",label:"Windsurf",icon:"windsurf",openWith:"Windsurf"},{id:"kiro",label:"Kiro",icon:"kiro",openWith:"Kiro"},{id:"xcode",label:"Xcode",icon:"xcode",openWith:"Xcode"},{id:"antigravity",label:"Antigravity",icon:"antigravity",openWith:"Antigravity"},{id:"textmate",label:"TextMate",icon:"textmate",openWith:"TextMate"},{id:"sublime-text",label:"Sublime Text",icon:"sublime-text",openWith:"Sublime Text"},{id:"intellij",label:"IntelliJ IDEA",icon:"intellij",openWith:"IntelliJ IDEA"},{id:"webstorm",label:"WebStorm",icon:"webstorm",openWith:"WebStorm"},{id:"rustrover",label:"RustRover",icon:"rustrover",openWith:"RustRover"},{id:"iterm2",label:"iTerm2",icon:"iterm2",openWith:"iTerm"},{id:"terminal",label:"Terminal",icon:"terminal",openWith:"Terminal"},{id:"ghostty",label:"Ghostty",icon:"ghostty",openWith:"Ghostty"},{id:"warp",label:"Warp",icon:"warp",openWith:"Warp"},{id:"android-studio",label:"Android Studio",icon:"android-studio",openWith:"Android Studio"}];function JAn({worktreePath:t,onCopyPath:e}){const{settings:n}=Qh(),r=HBe(),[o,i]=v.useState({finder:!0});v.useEffect(()=>{if(!On)return;let h=!1;return Promise.all(s4e.map(p=>Ho("check_app_exists",{appName:p.openWith}).then(g=>[p.id,g]).catch(()=>[p.id,!1]))).then(p=>{if(h)return;const g={finder:!0};for(const[_,x]of p)g[_]=x;i(g)}),()=>{h=!0}},[]);const s=v.useMemo(()=>{const h={id:"finder",label:"Finder",icon:"finder",openWith:"Finder"},p=s4e.filter(g=>o[g.id]);return[h,...p]},[o]),a=n.defaultOpenApp,l=v.useMemo(()=>s.find(h=>h.id===a)??s[0],[s,a]),c=v.useCallback(h=>{r.mutate({...n,defaultOpenApp:h})},[n,r]),u=v.useCallback(async h=>{if(On){if(h.id==="finder"){Ho("reveal_in_finder",{path:t}).catch(()=>{});return}Ho("open_with_app",{path:t,appName:h.openWith}).catch(()=>{})}},[t]),d=v.useCallback(()=>{u(l)},[l,u]);return f.jsxs("div",{className:"flex items-center rounded-md overflow-hidden border border-border/40",children:[f.jsx("button",{type:"button",onClick:d,onMouseDown:h=>h.stopPropagation(),className:"flex items-center justify-center px-1 py-0.5 hover:bg-accent/50 transition-colors",title:`Open in ${l.label}`,children:f.jsx(i4e,{id:l.icon,className:"size-5"})}),f.jsxs(Us,{children:[f.jsx(Ws,{asChild:!0,children:f.jsx("button",{type:"button",onMouseDown:h=>h.stopPropagation(),className:"flex items-center justify-center px-0.5 py-0.5 hover:bg-accent/50 transition-colors border-l border-border/40",children:f.jsx(Pi,{className:"size-3.5 text-muted-foreground"})})}),f.jsxs(Zs,{align:"end",className:"min-w-[180px]",children:[f.jsx(Zxe,{children:"Open in"}),s.map(h=>f.jsxs(dr,{onClick:()=>{c(h.id),u(h)},className:"gap-2",children:[f.jsx(i4e,{id:h.icon,className:"size-5 shrink-0"}),f.jsx("span",{className:"flex-1",children:h.label}),l.id===h.id&&f.jsx(Ji,{className:"size-3.5 text-muted-foreground"})]},h.id)),e&&f.jsxs(f.Fragment,{children:[f.jsx(A4,{}),f.jsxs(dr,{onClick:e,className:"gap-2",children:[f.jsx(z0,{className:"size-4 shrink-0 ml-0.5"}),f.jsx("span",{className:"flex-1",children:"Copy path"})]})]})]})]})]})}const hN={WebkitAppRegion:"drag"},ite={WebkitAppRegion:"no-drag"},AFe=v.createContext(!0);function eEn(){return v.useContext(AFe)}const EFe=v.createContext(null);function pN(){return v.useContext(EFe)}function ste({onToggle:t,visible:e}){return f.jsxs(Or,{children:[f.jsx(Sr,{asChild:!0,children:f.jsx("button",{type:"button","aria-label":"Toggle Explorer / Changes panel","aria-pressed":e,onClick:t,className:"flex items-center justify-center rounded-md p-1 text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",children:f.jsx(ait,{className:"size-5"})})}),f.jsxs(Cr,{side:"bottom",className:"text-xs",children:["Toggle Explorer / Changes"," ",f.jsx("kbd",{className:"ml-1.5 rounded border border-popover-foreground/25 bg-popover-foreground/10 px-1 py-0.5 font-mono text-[14px]",children:Vf("Cmd+Shift+E")})]})]})}function tEn({worktreePath:t,onCopyPath:e,onToggleRightPanel:n}){const r=On&&!!t;return!r&&!n?null:f.jsxs("div",{className:"flex shrink-0 items-center gap-1 self-center",style:ite,"data-testid":"right-sidepanel__header-actions",children:[r&&f.jsx(JAn,{worktreePath:t,onCopyPath:e}),n&&f.jsx(ste,{onToggle:n,visible:!0})]})}function nEn({onToggleSidebar:t,sidebarVisible:e,onGoBack:n,onGoForward:r,canGoBack:o,canGoForward:i}){return f.jsxs("div",{className:"flex items-center gap-0.5 pointer-events-auto",style:ite,children:[t&&f.jsxs(Or,{children:[f.jsx(Sr,{asChild:!0,children:f.jsx("button",{type:"button",onClick:t,"aria-label":"Toggle sidebar","aria-pressed":e??!1,"data-testid":"desktop-title-bar__sidebar-toggle",className:"flex items-center justify-center rounded p-1 text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",children:f.jsx(iit,{className:"size-5"})})}),f.jsxs(Cr,{side:"bottom",className:"text-xs",children:["Toggle Sidebar"," ",f.jsx("kbd",{className:"ml-1.5 rounded border border-popover-foreground/25 bg-popover-foreground/10 px-1 py-0.5 font-mono text-[14px]",children:Vf("Cmd+B")})]})]}),(n||r)&&f.jsxs(f.Fragment,{children:[f.jsxs(Or,{children:[f.jsx(Sr,{asChild:!0,children:f.jsx("button",{type:"button",onClick:n,disabled:!o,"aria-label":"Back","data-testid":"desktop-title-bar__back",className:"flex items-center justify-center rounded p-1 text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:text-muted-foreground",children:f.jsx(fM,{className:"size-5"})})}),f.jsxs(Cr,{side:"bottom",className:"text-xs",children:["Back"," ",f.jsx("kbd",{className:"ml-1.5 rounded border border-popover-foreground/25 bg-popover-foreground/10 px-1 py-0.5 font-mono text-[14px]",children:Vf("Cmd+Alt+←")})]})]}),f.jsxs(Or,{children:[f.jsx(Sr,{asChild:!0,children:f.jsx("button",{type:"button",onClick:r,disabled:!i,"aria-label":"Forward","data-testid":"desktop-title-bar__forward",className:"flex items-center justify-center rounded p-1 text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:text-muted-foreground",children:f.jsx(bo,{className:"size-5"})})}),f.jsxs(Cr,{side:"bottom",className:"text-xs",children:["Forward"," ",f.jsx("kbd",{className:"ml-1.5 rounded border border-popover-foreground/25 bg-popover-foreground/10 px-1 py-0.5 font-mono text-[14px]",children:Vf("Cmd+Alt+→")})]})]})]})]})}function rEn(){return f.jsx("div",{"data-testid":"desktop-title-bar__sidebar-surface",className:"h-[38px] shrink-0 flex items-center border-b border-border",style:hN})}function TFe(){const t=pN(),e=eEn();return!t||t.sidebarVisible?null:f.jsx("div",{"data-testid":"worktree-center__sidebar-gutter",className:"h-full shrink-0",style:{...e?hN:void 0,width:t.navOverlayWidth}})}function MFe({className:t=""}){const e=pN(),n=e?.onToggleRightPanel;return f.jsxs("div",{"data-testid":"worktree-center__drag-bar",className:`flex h-[38px] shrink-0 items-center border-b border-border bg-background pr-2 ${t}`,children:[f.jsx(TFe,{}),n&&!e.rightPanelVisible&&f.jsx("div",{className:"ml-auto flex shrink-0 items-center",children:f.jsx(ste,{onToggle:n,visible:!1})})]})}function oEn(){return f.jsx("div",{className:"h-[38px] shrink-0",style:hN})}const PFe=v.createContext(null),jFe=PFe.Provider;function Uh(){const t=v.useContext(PFe);if(!t)throw new Error("useClientPluginHost must be used inside ClientPluginHostProvider");return t}const mN=["conflicts","unstaged","staged","untracked","branch"],gN={conflicts:"Conflicts",unstaged:"Changes",staged:"Staged Changes",untracked:"Untracked Files",branch:"Committed on Branch"};function Xx(t,e={}){const{compareBranch:n}=GHe(t),r=Rn(),o=!!t&&(e.enabled??!0),i=See(e.refetchInterval??!1),s=It({queryKey:["worktreeChanges",t,n],queryFn:()=>Se.worktree.getChanges.query({worktreeId:t,compareBranch:n??void 0}),enabled:o});return v.useEffect(()=>{if(!o||!i)return;const a=["worktreeChanges",t,n],l=setInterval(()=>{const c=r.getQueryState(a);c?.fetchStatus!=="fetching"&&(c&&Date.now()-c.dataUpdatedAt<i*.8||r.refetchQueries({queryKey:a,exact:!0}))},i);return()=>clearInterval(l)},[r,o,i,t,n]),s}function NFe(t,e){return t.invalidateQueries({queryKey:["worktreeChanges",e]})}function RFe(t,e){if(!t)return null;for(const n of mN){const r=t[n].find(o=>o.path===e);if(r)return{section:n,entry:r}}return null}function LFe(t){if(!t)return 0;const e=new Set;for(const n of mN)for(const r of t[n])e.add(r.path);return e.size}function v8(t){const e=t.match(/^\/worktree\/([^/]+)/);return e?decodeURIComponent(e[1]):null}class IFe extends v.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e){console.error(`[plugin:${this.props.pluginId}] render failed:`,e)}render(){return this.state.error?f.jsxs("div",{className:"px-3 py-4 text-xs text-muted-foreground","data-testid":"plugin-slot__error","data-plugin-id":this.props.pluginId,children:["The ",this.props.pluginId," plugin failed to render: ",this.state.error.message]}):this.props.children}}const DFe={failure:{label:"Failed",icon:F7e,className:"text-danger"},running:{label:"In progress",icon:H2,className:"text-warning",spin:!0},pending:{label:"Queued",icon:_rt,className:"text-warning"},cancelled:{label:"Cancelled",icon:wrt,className:"text-muted-foreground"},success:{label:"Successful",icon:cb,className:"text-success"},neutral:{label:"Neutral",icon:ZH,className:"text-muted-foreground"},skipped:{label:"Skipped",icon:ZH,className:"text-muted-foreground"}};function iEn(t){return DFe[t].label}function zFe({state:t,className:e}){const{icon:n,className:r,spin:o}=DFe[t];return f.jsx(n,{"aria-hidden":!0,className:Ze("size-4 shrink-0",r,o&&"animate-spin",e)})}function sEn(t){const e={passing:0,failing:0,pending:0};for(const n of t)n.state==="success"||n.state==="neutral"?e.passing++:n.state==="failure"?e.failing++:ate(n)&&e.pending++;return e}const aEn={open:{label:"Open",className:"border-success/40 bg-success-bg text-success"},draft:{label:"Draft",className:"border-border bg-muted text-muted-foreground"},merged:{label:"Merged",className:"border-merged/40 bg-merged-bg text-merged"},closed:{label:"Closed",className:"border-danger/40 bg-danger-bg text-danger"}};function lEn({state:t}){const{label:e,className:n}=aEn[t];return f.jsx("span",{"data-testid":"pr-checks__state","data-review-state":t,className:Ze("inline-flex h-5 items-center rounded border px-1.5 text-[10px] font-semibold tracking-wide uppercase",n),children:e})}function $Fe(t){if(Number.isNaN(t))return null;const e=Math.max(0,Math.floor(t/1e3)),n=Math.floor(e/60);return n>0?`${n}m ${e%60}s`:`${e}s`}function cEn(t){return!t.startedAt||!t.completedAt?null:$Fe(Date.parse(t.completedAt)-Date.parse(t.startedAt))}function ate(t){return t.state==="running"||t.state==="pending"}function wU(t){return ate(t)&&!!t.startedAt&&!t.completedAt}function uEn(t,e){if(wU(t)){const n=$Fe(e-Date.parse(t.startedAt));return n&&`Running for ${n}`}return ate(t)&&!t.startedAt?"Queued":null}const BFe="band:pr-checks-sections";function a4e(){try{const t=JSON.parse(localStorage.getItem(BFe)??"{}");return t&&typeof t=="object"?t:{}}catch{return{}}}function HFe(t){const[e,n]=v.useState(()=>a4e()[t]!==!1),r=v.useCallback(o=>{n(o);try{localStorage.setItem(BFe,JSON.stringify({...a4e(),[t]:o}))}catch{}},[t]);return[e,r]}function dEn(t,e,n){const r=e?`pull request #${e.number} (${e.title})`:`branch ${t}`,o=n.map(i=>`- ${i.workflowName?`${i.workflowName} / ${i.name}`:i.name}${i.url?`: ${i.url}`:""}`);return[`These CI checks are failing on ${r}:`,...o,"","Read the failing job logs (for example with `gh run view <run-id> --log-failed`), fix the causes, run the relevant checks locally, and push the fix."].join(`
968
+ `?"<br>":e=="<"?"&lt;":"&amp;")}function tCn(t,e){let n=e,r=t;return typeof r!="string"&&(n=r.kind,r=r.value),n=="plaintext"?_6(r):eCn.parse(r,{async:!1})}function bU(t,e){let n=t.lineAt(e);return{line:n.number-1,character:e-n.from}}function aT(t,e){return t.line(e.line+1).from+e.character}class ws{constructor(e,{client:n,uri:r,languageID:o}){if(this.view=e,this.client=n,this.uri=r,!o){let i=e.state.facet(Qc);o=i?i.name:""}n.workspace.openFile(r,o,e),this.syncedDoc=e.state.doc,this.unsyncedChanges=Do.empty(e.state.doc.length)}docToHTML(e,n="plaintext"){let r=JSn(this.view,this.client.config.highlightLanguage,()=>tCn(e,n));return this.client.config.sanitizeHTML?this.client.config.sanitizeHTML(r):r}toPosition(e,n=this.view.state.doc){return bU(n,e)}fromPosition(e,n=this.view.state.doc){return aT(n,e)}reportError(e,n){WG(this.view,{label:this.view.state.phrase(e)+": "+(n.message||n),class:"cm-lsp-message cm-lsp-message-error",top:!0})}clear(){this.syncedDoc=this.view.state.doc,this.unsyncedChanges=Do.empty(this.view.state.doc.length)}update(e){e.docChanged&&(this.unsyncedChanges=this.unsyncedChanges.compose(e.changes))}destroy(){this.client.workspace.closeFile(this.uri,this.view)}static get(e){return e.plugin(fFe)}static create(e,n,r){return e.plugin(n,r)}}const fFe=oi.fromClass(ws);class hFe{constructor(e){this.client=e}getFile(e){return this.files.find(n=>n.uri==e)||null}requestFile(e){return Promise.resolve(this.getFile(e))}connected(){for(let e of this.files)this.client.didOpen(e)}disconnected(){}updateFile(e,n){var r;let o=this.getFile(e);o&&((r=o.getView())===null||r===void 0||r.dispatch(n))}displayFile(e){let n=this.getFile(e);return Promise.resolve(n?n.getView():null)}}class nCn{constructor(e,n,r,o,i){this.uri=e,this.languageId=n,this.version=r,this.doc=o,this.view=i}getView(){return this.view}}class rCn extends hFe{constructor(){super(...arguments),this.files=[],this.fileVersions=Object.create(null)}nextFileVersion(e){var n;return this.fileVersions[e]=((n=this.fileVersions[e])!==null&&n!==void 0?n:-1)+1}syncFiles(){let e=[];for(let n of this.files){let r=ws.get(n.view);if(!r)continue;let o=r.unsyncedChanges;o.empty||(e.push({changes:o,file:n,prevDoc:n.doc}),n.doc=n.view.state.doc,n.version=this.nextFileVersion(n.uri),r.clear())}return e}openFile(e,n,r){if(this.getFile(e))throw new Error("Default workspace implementation doesn't support multiple views on the same file");let o=new nCn(e,n,this.nextFileVersion(e),r.state.doc,r);this.files.push(o),this.client.didOpen(o)}closeFile(e){let n=this.getFile(e);n&&(this.files=this.files.filter(r=>r!=n),this.client.didClose(e))}}const oCn=ft.baseTheme({".cm-lsp-documentation":{padding:"0 7px","& p, & pre":{margin:"2px 0"}},".cm-lsp-signature-tooltip":{padding:"2px 6px",borderRadius:"2.5px",position:"relative",maxWidth:"30em",maxHeight:"10em",overflowY:"scroll","& .cm-lsp-documentation":{padding:"0",fontSize:"80%"},"& .cm-lsp-signature-num":{fontFamily:"monospace",position:"absolute",left:"2px",top:"4px",fontSize:"70%",lineHeight:"1.3"},"& .cm-lsp-signature":{fontFamily:"monospace",textIndent:"1em hanging"},"& .cm-lsp-active-parameter":{fontWeight:"bold"}},".cm-lsp-signature-multiple":{paddingLeft:"1.5em"},".cm-panel.cm-lsp-rename-panel":{padding:"2px 6px 4px",position:"relative","& label":{fontSize:"80%"},"& [name=close]":{position:"absolute",top:"0",bottom:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:"0"}},".cm-lsp-message button[type=submit]":{display:"block"},".cm-lsp-reference-panel":{fontFamily:"monospace",whiteSpace:"pre",padding:"3px 6px",maxHeight:"120px",overflow:"auto","& .cm-lsp-reference-file":{fontWeight:"bold"},"& .cm-lsp-reference":{cursor:"pointer","&[aria-selected]":{backgroundColor:"#0077ee44"}},"& .cm-lsp-reference-line":{opacity:"0.7"}}});class iCn{constructor(e,n,r){this.id=e,this.params=n,this.timeout=r,this.promise=new Promise((o,i)=>{this.resolve=o,this.reject=i})}}const sCn={general:{markdown:{parser:"marked"}},textDocument:{completion:{completionItem:{snippetSupport:!0,documentationFormat:["plaintext","markdown"],insertReplaceSupport:!1},completionList:{itemDefaults:["commitCharacters","editRange","insertTextFormat"]},completionItemKind:{valueSet:[]},contextSupport:!0},hover:{contentFormat:["markdown","plaintext"]},formatting:{},rename:{},signatureHelp:{contextSupport:!0,signatureInformation:{documentationFormat:["markdown","plaintext"],parameterInformation:{labelOffsetSupport:!0},activeParameterSupport:!0}},definition:{},declaration:{},implementation:{},typeDefinition:{},references:{},diagnostic:{}},window:{showMessage:{}}};class aCn{constructor(e){this.client=e,this.mappings=new Map,this.startDocs=new Map;for(let n of e.workspace.files)this.mappings.set(n.uri,Do.empty(n.doc.length)),this.startDocs.set(n.uri,n.doc)}addChanges(e,n){let r=this.mappings.get(e);r&&this.mappings.set(e,r.composeDesc(n))}getMapping(e){let n=this.mappings.get(e);if(!n)return null;let r=this.client.workspace.getFile(e),o=r?.getView(),i=o&&ws.get(o);return i?n.composeDesc(i.unsyncedChanges):n}mapPos(e,n,r=-1,o=Zi.Simple){let i=this.getMapping(e);return i?i.mapPos(n,r,o):n}mapPosition(e,n,r=-1,o=Zi.Simple){let i=this.startDocs.get(e);if(!i)throw new Error("Cannot map from a file that's not in the workspace");let s=aT(i,n),a=this.getMapping(e);return a?a.mapPos(s,r,o):s}destroy(){this.client.activeMappings=this.client.activeMappings.filter(e=>e!=this)}}const lCn={"window/logMessage":(t,e)=>{e.type==1?console.error("[lsp] "+e.message):e.type==2&&console.warn("[lsp] "+e.message)},"window/showMessage":(t,e)=>{if(e.type>3)return;let n;for(let r of t.workspace.files)if(n=r.getView())break;n&&WG(n,{label:e.message,class:"cm-lsp-message cm-lsp-message-"+(e.type==1?"error":e.type==2?"warning":"info"),top:!0})}};class cCn{constructor(e={}){var n;if(this.config=e,this.transport=null,this.nextReqID=0,this.requests=[],this.activeMappings=[],this.serverCapabilities=null,this.supportSync=-1,this.extensions=[],this.receiveMessage=this.receiveMessage.bind(this),this.initializing=new Promise((r,o)=>this.init={resolve:r,reject:o}),this.timeout=(n=e.timeout)!==null&&n!==void 0?n:3e3,this.workspace=e.workspace?e.workspace(this):new rCn(this),e.extensions)for(let r of e.extensions)Array.isArray(r)||r.extension?this.extensions.push(r):r.editorExtension&&this.extensions.push(r.editorExtension)}get connected(){return!!this.transport}connect(e){this.transport&&this.transport.unsubscribe(this.receiveMessage),this.transport=e,e.subscribe(this.receiveMessage);let n=sCn;if(this.config.extensions)for(let r of this.config.extensions){let{clientCapabilities:o}=r;o&&(n=pFe(n,o))}return this.requestInner("initialize",{processId:null,clientInfo:{name:"@codemirror/lsp-client"},rootUri:this.config.rootUri||null,capabilities:n}).promise.then(r=>{var o;this.serverCapabilities=r.capabilities;let i=r.capabilities.textDocumentSync;this.supportSync=i==null?0:typeof i=="number"?i:(o=i.change)!==null&&o!==void 0?o:0,e.send(JSON.stringify({jsonrpc:"2.0",method:"initialized",params:{}})),this.init.resolve(null)},this.init.reject),this.workspace.connected(),this}disconnect(){this.transport&&this.transport.unsubscribe(this.receiveMessage),this.serverCapabilities=null,this.initializing=new Promise((e,n)=>this.init={resolve:e,reject:n}),this.workspace.disconnected()}plugin(e,n){return[fFe.of({client:this,uri:e,languageID:n}),oCn,this.extensions]}didOpen(e){this.notification("textDocument/didOpen",{textDocument:{uri:e.uri,languageId:e.languageId,text:e.doc.toString(),version:e.version}})}didClose(e){this.notification("textDocument/didClose",{textDocument:{uri:e}})}receiveMessage(e){var n;const r=JSON.parse(e);if("id"in r&&!("method"in r)){let o=this.requests.findIndex(i=>i.id==r.id);if(o<0)console.warn(`[lsp] Received a response for non-existent request ${r.id}`);else{let i=this.requests[o];clearTimeout(i.timeout),this.requests.splice(o,1),r.error?i.reject(r.error):i.resolve(r.result)}}else if("id"in r){let o={jsonrpc:"2.0",id:r.id,error:{code:-32601,message:"Method not implemented"}};this.transport.send(JSON.stringify(o))}else{let o=(n=this.config.notificationHandlers)===null||n===void 0?void 0:n[r.method];if(o&&o(this,r.params))return;if(this.config.extensions)for(let s of this.config.extensions){let{notificationHandlers:a}=s,l=a?.[r.method];if(l&&l(this,r.params))return}let i=lCn[r.method];i?i(this,r.params):this.config.unhandledNotification&&this.config.unhandledNotification(this,r.method,r.params)}}request(e,n){return this.transport?this.initializing.then(()=>this.requestInner(e,n).promise):Promise.reject(new Error("Client not connected"))}requestInner(e,n,r=!1){let o=++this.nextReqID,i={jsonrpc:"2.0",id:o,method:e,params:n},s=new iCn(o,n,setTimeout(()=>this.timeoutRequest(s),this.timeout));this.requests.push(s);try{this.transport.send(JSON.stringify(i))}catch(a){s.reject(a)}return s}notification(e,n){this.transport&&this.initializing.then(()=>{let r={jsonrpc:"2.0",method:e,params:n};this.transport.send(JSON.stringify(r))})}cancelRequest(e){let n=this.requests.find(r=>r.params===e);n&&this.notification("$/cancelRequest",{id:n.id})}hasCapability(e){return this.serverCapabilities?!!this.serverCapabilities[e]:null}workspaceMapping(){let e=new aCn(this);return this.activeMappings.push(e),e}withMapping(e){let n=this.workspaceMapping();return e(n).finally(()=>n.destroy())}sync(){for(let{file:e,changes:n,prevDoc:r}of this.workspace.syncFiles()){for(let o of this.activeMappings)o.addChanges(e.uri,n);this.supportSync&&this.notification("textDocument/didChange",{textDocument:{uri:e.uri,version:e.version},contentChanges:uCn(e,r,n,this.supportSync==2)})}}timeoutRequest(e){let n=this.requests.indexOf(e);n>-1&&(e.reject(new Error("Request timed out")),this.requests.splice(n,1))}}function uCn(t,e,n,r){if(!r||t.doc.length<1024)return[{text:t.doc.toString()}];let o=[];return n.iterChanges((i,s,a,l,c)=>{o.push({range:{start:bU(e,i),end:bU(e,s)},text:c.toString()})}),o.reverse()}function pFe(t,e){if(e==null)return t;if(typeof t!="object"||typeof e!="object")return e;let n={},r=Object.keys(t),o=Object.keys(e);for(let i of r)n[i]=o.indexOf(i)>-1?pFe(t[i],e[i]):t[i];for(let i of o)r.indexOf(i)<0&&(n[i]=e[i]);return n}function dCn(t={}){let e;if(t.override)e=[Yce({override:[Z3e]})];else{let n=[{autocomplete:Z3e}];e=[Yce(),Gn.languageData.of(()=>n)]}return t.validFor&&e.push(mFe.of({validFor:t.validFor})),e}const mFe=Ft.define({combine:t=>t.length?t[0]:{validFor:null}});function fCn(t,e,n,r){if(t.client.hasCapability("completionProvider")===!1)return Promise.resolve(null);t.client.sync();let o={position:t.toPosition(e),textDocument:{uri:t.uri},context:n};return r&&r.addEventListener("abort",()=>t.client.cancelRequest(o)),t.client.request("textDocument/completion",o)}function hCn(t){var e;let n=Math.ceil(t.length/50),r=[];for(let o=0;o<t.length;o+=n){let i=t[o],s=((e=i.textEdit)===null||e===void 0?void 0:e.newText)||i.textEditText||i.insertText||i.label;if(!/^\w/.test(s)){let a=/^[^\w]*/.exec(s)[0];r.indexOf(a)<0&&r.push(a)}}return r.length?new RegExp("^(?:"+r.map(RegExp.escape||(o=>o.replace(/[^\w\s]/g,"\\$&"))).join("|")+")?\\w*$"):/^\w*$/}const Z3e=t=>{var e,n;const r=t.view&&ws.get(t.view);if(!r)return null;let o="";if(!t.explicit){o=t.view.state.sliceDoc(t.pos-1,t.pos);let i=(n=(e=r.client.serverCapabilities)===null||e===void 0?void 0:e.completionProvider)===null||n===void 0?void 0:n.triggerCharacters;if(!/[a-zA-Z_]/.test(o)&&!(i&&i.indexOf(o)>-1))return null}return fCn(r,t.pos,{triggerCharacter:o,triggerKind:t.explicit?1:2},t).then(i=>{var s,a;if(!i)return null;Array.isArray(i)&&(i={items:i});let{from:l,to:c}=pCn(t,i),u=(s=i.itemDefaults)===null||s===void 0?void 0:s.commitCharacters,d=t.state.facet(mFe);return{from:l,to:c,options:i.items.map(h=>{var p;let g=((p=h.textEdit)===null||p===void 0?void 0:p.newText)||h.textEditText||h.insertText||h.label,_={label:g,type:h.kind&&gCn[h.kind]};return h.commitCharacters&&h.commitCharacters!=u&&(_.commitCharacters=h.commitCharacters),h.detail&&(_.detail=h.detail),h.sortText&&(_.sortText=h.sortText),h.insertTextFormat==2&&(_.apply=(x,y,k,O)=>Qke(g.replace(/\$(\d+)/g,"${$1}"))(x,y,k,O),_.label=h.label),h.documentation&&(_.info=()=>mCn(r,h.documentation)),_}),commitCharacters:u,validFor:(a=d.validFor)!==null&&a!==void 0?a:hCn(i.items),map:(h,p)=>({...h,from:p.mapPos(h.from)})}},i=>{if("code"in i&&i.code==-32800)return null;throw i})};function pCn(t,e){var n;if(!e.items.length)return{from:t.pos,to:t.pos};let r=(n=e.itemDefaults)===null||n===void 0?void 0:n.editRange,o=e.items[0],i=r?"insert"in r?r.insert:r:o.textEdit?"range"in o.textEdit?o.textEdit.range:o.textEdit.insert:null;if(!i)return t.state.wordAt(t.pos)||{from:t.pos,to:t.pos};let s=t.state.doc.lineAt(t.pos);return{from:s.from+i.start.character,to:s.from+i.end.character}}function mCn(t,e){let n=document.createElement("div");return n.className="cm-lsp-documentation cm-lsp-completion-documentation",n.innerHTML=t.docToHTML(e),n}const gCn={1:"text",2:"method",3:"function",4:"class",5:"property",6:"variable",7:"class",8:"interface",9:"namespace",10:"property",11:"keyword",12:"constant",13:"constant",14:"keyword",16:"constant",20:"constant",21:"constant",22:"class",25:"type"};function vCn(t={}){return tke(_Cn,{hideOn:e=>e.docChanged,hoverTime:t.hoverTime})}function bCn(t,e){return t.client.hasCapability("hoverProvider")===!1?Promise.resolve(null):(t.client.sync(),t.client.request("textDocument/hover",{position:t.toPosition(e),textDocument:{uri:t.uri}}))}function _Cn(t,e){const n=ws.get(t);return n?bCn(n,e).then(r=>r?{pos:r.range?aT(t.state.doc,r.range.start):e,end:r.range?aT(t.state.doc,r.range.end):e,create(){let o=document.createElement("div");return o.className="cm-lsp-hover-tooltip cm-lsp-documentation",o.innerHTML=xCn(n,r.contents),{dom:o}},above:!0}:null):Promise.resolve(null)}function xCn(t,e){return Array.isArray(e)?e.map(n=>G3e(t,n)).join("<br>"):typeof e=="string"||typeof e=="object"&&"language"in e?G3e(t,e):t.docToHTML(e)}function G3e(t,e){if(typeof e=="string")return t.docToHTML(e,"markdown");let{language:n,value:r}=e,o=t.client.config.highlightLanguage&&t.client.config.highlightLanguage(n||"");if(!o){let s=t.view.state.facet(Qc);s&&(!n||s.name==n)&&(o=s)}if(!o)return _6(r);let i="";return gke(r,o.parser.parse(r),{style:s=>oY(t.view.state,s)},(s,a)=>{i+=a?`<span class="${a}">${_6(s)}</span>`:_6(s)},()=>{i+="<br>"}),i}function yCn(t,e){return t.client.request("textDocument/formatting",{options:e,textDocument:{uri:t.uri}})}const wCn=t=>{const e=ws.get(t);return e?(e.client.sync(),e.client.withMapping(n=>yCn(e,{tabSize:ah(t.state),insertSpaces:t.state.facet(Rh).indexOf(" ")<0}).then(r=>{if(!r)return;let o=n.getMapping(e.uri),i=[];for(let s of r){let a=n.mapPosition(e.uri,s.range.start),l=n.mapPosition(e.uri,s.range.end);if(o){if(o.touchesRange(a,l))return;a=o.mapPos(a,1),l=o.mapPos(l,-1)}i.push({from:a,to:l,insert:s.newText})}t.dispatch({changes:i,userEvent:"format"})},r=>{e.reportError("Formatting request failed",r)})),!0):!1},kCn=[{key:"Shift-Alt-f",run:wCn,preventDefault:!0}];function OCn(t,e,n){return t.client.request("textDocument/rename",{newName:n,position:t.toPosition(e),textDocument:{uri:t.uri}})}const SCn=t=>{let e=t.state.wordAt(t.state.selection.main.head),n=ws.get(t);if(!e||!n||n.client.hasCapability("renameProvider")===!1)return!1;const r=t.state.sliceDoc(e.from,e.to);let o=ajt(t,"cm-lsp-rename-panel");if(o){let i=o.dom.querySelector("[name=name]");i.value=r,i.select()}else{let{close:i,result:s}=WG(t,{label:t.state.phrase("New name"),input:{name:"name",value:r},focus:!0,submitLabel:t.state.phrase("rename"),class:"cm-lsp-rename-panel"});s.then(a=>{t.dispatch({effects:i}),a&&CCn(t,a.elements.namedItem("name").value)})}return!0};function CCn(t,e){const n=ws.get(t),r=t.state.wordAt(t.state.selection.main.head);if(!n||!r)return!1;n.client.sync(),n.client.withMapping(o=>OCn(n,r.from,e).then(i=>{if(i)for(let s in i.changes){let a=i.changes[s],l=n.client.workspace.getFile(s);!a.length||!l||n.client.workspace.updateFile(s,{changes:a.map(c=>({from:o.mapPosition(s,c.range.start),to:o.mapPosition(s,c.range.end),insert:c.newText})),userEvent:"rename"})}},i=>{n.reportError("Rename request failed",i)}))}const ACn=[{key:"F2",run:SCn,preventDefault:!0}];function ECn(t,e,n){return t.client.hasCapability("signatureHelpProvider")===!1?Promise.resolve(null):(t.client.sync(),t.client.request("textDocument/signatureHelp",{context:n,position:t.toPosition(e),textDocument:{uri:t.uri}}))}const qS=oi.fromClass(class{constructor(){this.activeRequest=null,this.delayedRequest=0}update(t){var e;this.activeRequest&&(t.selectionSet?(this.activeRequest.drop=!0,this.activeRequest=null):t.docChanged&&(this.activeRequest.pos=t.changes.mapPos(this.activeRequest.pos)));const n=ws.get(t.view);if(!n)return;const r=t.view.state.field(Yf);let o="";if(t.docChanged&&t.transactions.some(i=>i.isUserEvent("input.type"))){const i=(e=n.client.serverCapabilities)===null||e===void 0?void 0:e.signatureHelpProvider,s=(i?.triggerCharacters||[]).concat(r&&i?.retriggerCharacters||[]);s&&t.changes.iterChanges((a,l,c,u,d)=>{let h=d.toString();if(h)for(let p of s)h.indexOf(p)>-1&&(o=p)})}o?this.startRequest(n,{triggerKind:2,isRetrigger:!!r,triggerCharacter:o,activeSignatureHelp:r?r.data:void 0}):r&&t.selectionSet&&(this.delayedRequest&&clearTimeout(this.delayedRequest),this.delayedRequest=setTimeout(()=>{this.startRequest(n,{triggerKind:3,isRetrigger:!0,activeSignatureHelp:r.data})},250))}startRequest(t,e){this.delayedRequest&&clearTimeout(this.delayedRequest);let{view:n}=t,r=n.state.selection.main.head;this.activeRequest&&(this.activeRequest.drop=!0);let o=this.activeRequest={pos:r,drop:!1};ECn(t,r,e).then(i=>{var s;if(!o.drop)if(i&&i.signatures.length){let a=n.state.field(Yf),l=a&&TCn(a.data,i),c=l&&e.triggerKind==3?a.active:(s=i.activeSignature)!==null&&s!==void 0?s:0;if(l&&MCn(a.data,i,c))return;n.dispatch({effects:O_.of({data:i,active:c,pos:l?a.tooltip.pos:o.pos})})}else n.state.field(Yf)&&n.dispatch({effects:O_.of(null)})},e.triggerKind==1?i=>t.reportError("Signature request failed",i):void 0)}destroy(){this.delayedRequest&&clearTimeout(this.delayedRequest),this.activeRequest&&(this.activeRequest.drop=!0)}});function TCn(t,e){return t.signatures.length!=e.signatures.length?!1:t.signatures.every((n,r)=>n.label==e.signatures[r].label)}function MCn(t,e,n){var r,o;return((r=t.signatures[n].activeParameter)!==null&&r!==void 0?r:t.activeParameter)==((o=e.signatures[n].activeParameter)!==null&&o!==void 0?o:e.activeParameter)}class Y3e{constructor(e,n,r){this.data=e,this.active=n,this.tooltip=r}}const Yf=to.define({create(){return null},update(t,e){for(let n of e.effects)if(n.is(O_))return n.value?new Y3e(n.value.data,n.value.active,PCn(n.value.data,n.value.active,n.value.pos)):null;return t&&e.docChanged?new Y3e(t.data,t.active,{...t.tooltip,pos:e.changes.mapPos(t.tooltip.pos)}):t},provide:t=>dP.from(t,e=>e&&e.tooltip)}),O_=xn.define();function PCn(t,e,n){return{pos:n,above:!0,create:r=>jCn(r,t,e)}}function jCn(t,e,n){var r;let o=document.createElement("div");if(o.className="cm-lsp-signature-tooltip",e.signatures.length>1){o.classList.add("cm-lsp-signature-multiple");let d=o.appendChild(document.createElement("div"));d.className="cm-lsp-signature-num",d.textContent=`${n+1}/${e.signatures.length}`}let i=e.signatures[n],s=o.appendChild(document.createElement("div"));s.className="cm-lsp-signature";let a=0,l=0,c=(r=i.activeParameter)!==null&&r!==void 0?r:e.activeParameter,u=c!=null&&i.parameters?i.parameters[c]:null;if(u&&Array.isArray(u.label))[a,l]=u.label;else if(u){let d=i.label.indexOf(u.label);d>-1&&(a=d,l=d+u.label.length)}if(l){s.appendChild(document.createTextNode(i.label.slice(0,a)));let d=s.appendChild(document.createElement("span"));d.className="cm-lsp-active-parameter",d.textContent=i.label.slice(a,l),s.appendChild(document.createTextNode(i.label.slice(l)))}else s.textContent=i.label;if(i.documentation){let d=ws.get(t);if(d){let h=o.appendChild(document.createElement("div"));h.className="cm-lsp-signature-documentation cm-lsp-documentation",h.innerHTML=d.docToHTML(i.documentation)}}return{dom:o}}const NCn=t=>{let e=t.plugin(qS);e||(t.dispatch({effects:xn.appendConfig.of([Yf,qS])}),e=t.plugin(qS));let n=t.state.field(Yf);if(!e||n===void 0)return!1;let r=ws.get(t);return r?(e.startRequest(r,{triggerKind:1,activeSignatureHelp:n?n.data:void 0,isRetrigger:!!n}),!0):!1},RCn=t=>{let e=t.state.field(Yf);return e?(e.active<e.data.signatures.length-1&&t.dispatch({effects:O_.of({data:e.data,active:e.active+1,pos:e.tooltip.pos})}),!0):!1},LCn=t=>{let e=t.state.field(Yf);return e?(e.active>0&&t.dispatch({effects:O_.of({data:e.data,active:e.active-1,pos:e.tooltip.pos})}),!0):!1},ICn=[{key:"Mod-Shift-Space",run:NCn},{key:"Mod-Shift-ArrowUp",run:LCn},{key:"Mod-Shift-ArrowDown",run:RCn}];function DCn(t={}){return[Yf,qS,t.keymap===!1?[]:r0.high(dd.of(ICn))]}function zCn(t,e){return t.client.request("textDocument/definition",{textDocument:{uri:t.uri},position:t.toPosition(e)})}function $Cn(t,e){const n=ws.get(t);return!n||n.client.hasCapability(e.capability)===!1?!1:(n.client.sync(),n.client.withMapping(r=>e.get(n,t.state.selection.main.head).then(o=>{let i=Array.isArray(o)?o[0]:o;if(i)return(i.uri==n.uri?Promise.resolve(t):n.client.workspace.displayFile(i.uri)).then(s=>{if(!s)return;let a=r.getMapping(i.uri)?r.mapPosition(i.uri,i.range.start):n.fromPosition(i.range.start,s.state.doc);s.dispatch({selection:{anchor:a},scrollIntoView:!0,userEvent:"select.definition"})})},o=>n.reportError("Find definition failed",o))),!0)}const gFe=t=>$Cn(t,{get:zCn,capability:"definitionProvider"}),BCn=[{key:"F12",run:gFe,preventDefault:!0}];function HCn(t,e){return t.client.request("textDocument/references",{textDocument:{uri:t.uri},position:t.toPosition(e),context:{includeDeclaration:!0}})}const FCn=t=>{const e=ws.get(t);if(!e||e.client.hasCapability("referencesProvider")===!1)return!1;e.client.sync();let n=e.client.workspaceMapping(),r=!1;return HCn(e,t.state.selection.main.head).then(o=>{if(o)return Promise.all(o.map(i=>e.client.workspace.requestFile(i.uri).then(s=>s?{file:s,range:i.range}:null))).then(i=>{let s=i.filter(a=>a);s.length&&(qCn(e.view,s,n),r=!0)})},o=>e.reportError("Finding references failed",o)).finally(()=>{r||n.destroy()}),!0},_U=t=>t.state.field(xU,!1)?(t.dispatch({effects:ote.of(null)}),!0):!1,xU=to.define({create(){return null},update(t,e){for(let n of e.effects)if(n.is(ote))return n.value;return t},provide:t=>Ob.from(t)}),ote=xn.define();function qCn(t,e,n){let r=VCn(e,n),o=t.state.field(xU,!1)===void 0?xn.appendConfig.of(xU.init(()=>r)):ote.of(r);t.dispatch({effects:o})}function VCn(t,e){let n=!1;return setTimeout(()=>{n||e.destroy()},500),r=>{n=!0;let o=QCn(t.map(p=>p.file.uri)),i=document.createElement("div"),s=null;i.className="cm-lsp-reference-panel",i.tabIndex=0,i.role="listbox",i.setAttribute("aria-label",r.state.phrase("Reference list"));let a=[];for(let{file:p,range:g}of t){let _=p.uri.slice(o);if(_!=s){s=_;let P=i.appendChild(document.createElement("div"));P.className="cm-lsp-reference-file",P.textContent=_}let x=i.appendChild(document.createElement("div"));x.className="cm-lsp-reference",x.role="option";let y=e.mapPosition(p.uri,g.start,1),k=e.mapPosition(p.uri,g.end,-1),O=p.getView(),C=(O?O.state.doc:p.doc).lineAt(y),A=x.appendChild(document.createElement("span"));A.className="cm-lsp-reference-line",A.textContent=(C.number+": ").padStart(5," ");let E=C.text.slice(Math.max(0,y-C.from-50),y-C.from);E&&x.appendChild(document.createTextNode(E)),x.appendChild(document.createElement("strong")).textContent=C.text.slice(y-C.from,k-C.from);let M=C.text.slice(k-C.from,Math.min(C.length,100-E.length));M&&x.appendChild(document.createTextNode(M)),a.length||x.setAttribute("aria-selected","true"),a.push(x)}function l(){for(let p=0;p<a.length;p++)if(a[p].hasAttribute("aria-selected"))return p;return 0}function c(p){for(let g=0;g<a.length;g++)g==p?a[g].setAttribute("aria-selected","true"):a[g].removeAttribute("aria-selected")}function u(p){let{file:g,range:_}=t[p],x=ws.get(r);x&&Promise.resolve(g.uri==x.uri?r:x.client.workspace.displayFile(g.uri)).then(y=>{if(!y)return;let k=e.mapPosition(g.uri,_.start,1);y.focus(),y.dispatch({selection:{anchor:k},scrollIntoView:!0})})}i.addEventListener("keydown",p=>{if(p.keyCode==27)_U(r),r.focus();else if(p.keyCode==38||p.keyCode==33)c((l()-1+t.length)%t.length);else if(p.keyCode==40||p.keyCode==34)c((l()+1)%t.length);else if(p.keyCode==36)c(0);else if(p.keyCode==35)c(a.length-1);else if(p.keyCode==13||p.keyCode==10)u(l());else return;p.preventDefault()}),i.addEventListener("click",p=>{for(let g=0;g<a.length;g++)a[g].contains(p.target)&&(c(g),u(g),p.preventDefault())});let d=document.createElement("div");d.appendChild(i);let h=d.appendChild(document.createElement("button"));return h.className="cm-dialog-close",h.textContent="×",h.addEventListener("click",()=>_U(r)),h.setAttribute("aria-label",r.state.phrase("close")),{dom:d,destroy:()=>e.destroy(),mount:()=>i.focus()}}}function QCn(t){let e=t[0],n=e.length;for(let r=1;r<t.length;r++){let o=t[r],i=0;for(let s=Math.min(n,o.length);i<s&&e[i]==o[i];i++);n=i}for(;n&&e[n-1]!="/";)n--;return n}const UCn=[{key:"Shift-F12",run:FCn,preventDefault:!0},{key:"Escape",run:_U}];function WCn(t){return t==1?"error":t==2?"warning":t==3?"info":"hint"}const ZCn=oi.fromClass(class{constructor(){this.pending=-1}update(t){t.docChanged&&(this.pending>-1&&clearTimeout(this.pending),this.pending=setTimeout(()=>{this.pending=-1;let e=ws.get(t.view);e&&e.client.sync()},500))}destroy(){this.pending>-1&&clearTimeout(this.pending)}});function GCn(){return{clientCapabilities:{textDocument:{publishDiagnostics:{versionSupport:!0}}},notificationHandlers:{"textDocument/publishDiagnostics":(t,e)=>{let n=t.workspace.getFile(e.uri);if(!n||e.version!=null&&e.version!=n.version)return!1;const r=n.getView(),o=r&&ws.get(r);return!r||!o?!1:(r.dispatch(qSn(r.state,e.diagnostics.map(i=>{var s;return{from:o.unsyncedChanges.mapPos(o.fromPosition(i.range.start,o.syncedDoc)),to:o.unsyncedChanges.mapPos(o.fromPosition(i.range.end,o.syncedDoc)),severity:WCn((s=i.severity)!==null&&s!==void 0?s:1),message:i.message}}))),!0)}},editorExtension:ZCn}}function YCn(){return[dCn(),vCn(),dd.of([...kCn,...ACn,...BCn,...UCn]),DCn(),GCn()]}const vFe={typescript:"typescript",tsx:"typescriptreact",javascript:"javascript",jsx:"javascriptreact"};new Set(Object.keys(vFe));function XCn(t){switch(t){case"typescript":case"tsx":case"javascript":case"jsx":return"typescript";default:return null}}let Xm=null;class KCn{constructor(e,n,r,o,i){this.uri=e,this.languageId=n,this.version=r,this.doc=o,this.view=i}getView(){return this.view}}class JCn extends hFe{files=[];fileVersions=Object.create(null);diffDocs=new Map;diffOpen=new Set;rootUri;worktreeId;constructor(e,n,r){super(e),this.rootUri=n,this.worktreeId=r}nextFileVersion(e){const n=(this.fileVersions[e]??-1)+1;return this.fileVersions[e]=n,n}syncFiles(){const e=[];for(const n of this.files){const r=n.getView();if(!r)continue;const o=ws.get(r);if(!o)continue;const i=o.unsyncedChanges;i.empty||(e.push({changes:i,file:n,prevDoc:n.doc}),n.doc=r.state.doc,n.version=this.nextFileVersion(n.uri),o.clear())}return e}openFile(e,n,r){const o=this.files.find(s=>s.uri===e);if(o){o.view=r;return}this.diffOpen.delete(e)&&this.client.didClose(e);const i=new KCn(e,n,this.nextFileVersion(e),r.state.doc,r);this.files.push(i),this.client.didOpen(i)}closeFile(e){const n=this.getFile(e);n&&(this.files=this.files.filter(r=>r!==n),this.client.didClose(e),this.diffDocs.has(e)&&this.openDiffOnServer(e))}openDiffDoc(e,n,r){const o=this.diffDocs.get(e),i=!o||!o.doc.eq(r);o?(o.count++,o.languageId=n,o.doc=r):this.diffDocs.set(e,{languageId:n,doc:r,count:1}),!this.getFile(e)&&(i||!this.diffOpen.has(e))&&this.openDiffOnServer(e)}closeDiffDoc(e){const n=this.diffDocs.get(e);n&&(--n.count>0||(this.diffDocs.delete(e),this.diffOpen.delete(e)&&this.client.didClose(e)))}serverDoc(e){const n=this.getFile(e);return n?(this.client.sync(),n.doc):this.diffOpen.has(e)?this.diffDocs.get(e)?.doc??null:null}openDiffOnServer(e){const n=this.diffDocs.get(e);n&&(this.diffOpen.has(e)&&this.client.didClose(e),this.client.didOpen({uri:e,languageId:n.languageId,version:this.nextFileVersion(e),doc:n.doc,getView:()=>null}),this.diffOpen.add(e))}displayFile(e){const n=this.getFile(e);if(n){const o=n.getView();if(o)return Promise.resolve(o)}const r=this.uriToWorktreePath(e);return new Promise(o=>{Xm&&(clearTimeout(Xm.timer),Xm.resolve(null));const i=setTimeout(()=>{Xm&&(Xm=null,o(null))},5e3);Xm={resolve:o,timer:i},window.dispatchEvent(new CustomEvent("band:lsp-navigate",{detail:{filePath:r,worktreeId:this.worktreeId}}))})}uriToWorktreePath(e){const n=yU(e),r=this.rootUri.endsWith("/")?this.rootUri:`${this.rootUri}/`;if(n.startsWith(r))return n.slice(r.length);const o=n.replace(/^file:\/\//,""),i=r.replace(/^file:\/\//,"");return o.startsWith(i)?o.slice(i.length):o}}function eAn(t){return new Promise((e,n)=>{const r=new JY(t);let o=[];r.onopen=()=>{e({send(i){r.readyState===WebSocket.OPEN&&r.send(i)},subscribe(i){o.push(i)},unsubscribe(i){o=o.filter(s=>s!==i)},close(){r.close()}})},r.onmessage=i=>{const s=typeof i.data=="string"?i.data:i.data.toString();for(const a of o)a(s)},r.onerror=()=>{n(new Error(`WebSocket connection failed: ${t}`))},r.onclose=()=>{o=[]}})}const D5=new Map;async function bFe(t,e,n){let r=D5.get(t);if(r)r.refCount++;else{const i=new cCn({rootUri:e,workspace:a=>new JCn(a,e,n),extensions:YCn(),timeout:1e4});r={ready:eAn(t).then(a=>(i.connect(a),{client:i,transport:a})),refCount:1},D5.set(t,r)}const o=r;try{return(await o.ready).client}catch(i){throw o.refCount--,D5.get(t)===o&&D5.delete(t),i}}function tAn(t){const e=D5.get(t);e&&(e.refCount--,!(e.refCount>0)&&(D5.delete(t),e.ready.then(({client:n,transport:r})=>n.request("shutdown",null).then(()=>{r.send(JSON.stringify({jsonrpc:"2.0",method:"exit",params:null}))}).catch(()=>{}).finally(()=>{n.disconnect(),r.close()})).catch(()=>{})))}function nAn(t,e){const{doc:n}=t.state;if(e<0||e>n.length)return null;const r=n.lineAt(e),o=r.text,i=e-r.from,s=/[\w$]/;if(i>=o.length||!s.test(o[i]))return null;let a=i,l=i;for(;a>0&&s.test(o[a-1]);)a--;for(;l<o.length-1&&s.test(o[l+1]);)l++;return{from:r.from+a,to:r.from+l+1}}function yU(t){try{return decodeURIComponent(t)}catch{return t}}function rAn(t){const e=Array.isArray(t)?t[0]:t;return e?"targetUri"in e?{uri:e.targetUri,range:e.targetSelectionRange}:e:null}const oAn=80,_Fe=xn.define(),iAn=yt.mark({class:"cm-lsp-cmd-link",attributes:{"data-testid":"code-editor__definition-link"}}),X3e=to.define({create:()=>yt.none,update(t,e){for(const n of e.effects)if(n.is(_Fe))return n.value?yt.set([iAn.range(n.value.from,n.value.to)]):yt.none;return e.docChanged?yt.none:t},provide:t=>ft.decorations.from(t)}),sAn=ft.baseTheme({".cm-lsp-cmd-link, .cm-lsp-cmd-link *":{color:"var(--link) !important",textDecoration:"underline",cursor:"pointer"}});function xFe(t){const e=oi.fromClass(class{constructor(n){this.view=n,this.checkedDoc=n.state.doc,this.onKeyDown=this.onKeyDown.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.onBlur=this.onBlur.bind(this),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp),n.dom.addEventListener("mousemove",this.onMouseMove),n.dom.addEventListener("mouseleave",this.onMouseLeave),window.addEventListener("blur",this.onBlur)}modDown=!1;mouseX=-1;mouseY=-1;current=null;navigable=new Set;timer;checkedDoc;destroy(){clearTimeout(this.timer),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),this.view.dom.removeEventListener("mousemove",this.onMouseMove),this.view.dom.removeEventListener("mouseleave",this.onMouseLeave),window.removeEventListener("blur",this.onBlur)}onKeyDown(n){(n.key==="Meta"||n.key==="Control")&&(this.modDown=!0,this.recompute())}onKeyUp(n){(n.key==="Meta"||n.key==="Control")&&(this.modDown=!1,this.navigable.clear(),this.show(null))}onMouseMove(n){this.mouseX=n.clientX,this.mouseY=n.clientY,this.modDown=n.metaKey||n.ctrlKey,this.recompute()}onMouseLeave(){this.mouseX=-1,this.show(null)}onBlur(){this.modDown=!1,this.navigable.clear(),this.show(null)}recompute(){if(!this.modDown||this.mouseX<0)return this.show(null);const n=this.view.posAtCoords({x:this.mouseX,y:this.mouseY}),r=n==null?null:nAn(this.view,n);if(!r)return this.show(null);const o=`${r.from}:${r.to}`;if(o===this.current)return;this.show(null),this.current=o;const i=this.view.state.doc;if(i!==this.checkedDoc&&(this.checkedDoc=i,this.navigable.clear()),this.navigable.has(o))return this.show(r,o);this.timer=setTimeout(()=>{t(this.view,r.from).catch(()=>!1).then(s=>{!s||this.view.state.doc!==i||(this.navigable.add(o),this.current===o&&this.show(r,o))})},oAn)}show(n,r=null){clearTimeout(this.timer),this.current=r;const o=this.view.state.field(X3e,!1);!n&&(!o||o.size===0)||this.view.dispatch({effects:_Fe.of(n)})}});return[X3e,e,sAn]}function yFe(t){return ft.domEventHandlers({click(e,n){if(!(e.metaKey||e.ctrlKey))return!1;const r=n.posAtCoords({x:e.clientX,y:e.clientY});return r==null?!1:(n.dispatch({selection:{anchor:r}}),t(n,r))}})}function wFe(t,e,n){const r=t.serverCapabilities;return r&&!r.definitionProvider?Promise.resolve(null):t.request("textDocument/definition",{textDocument:{uri:e},position:n}).then(rAn)}async function aAn(t,e,n,r,o){const i=await bFe(t,e,o);return[i.plugin(n,r),yFe(s=>gFe(s)),xFe((s,a)=>{const l=ws.get(s);return l?(i.sync(),wFe(i,l.uri,l.toPosition(a)).then(c=>!!c)):Promise.resolve(!1)})]}async function lAn(t,e,n,r,o){const i=await bFe(t,e,o),s=i.workspace,a=oi.fromClass(class{constructor(u){this.view=u,s.openDiffDoc(n,r,u.state.doc)}destroy(){s.closeDiffDoc(n)}}),l=(u,d)=>{const h=u.state.doc.lineAt(d),p=s.serverDoc(n);return!p||h.number>p.lines||p.line(h.number).text!==h.text?Promise.resolve(null):wFe(i,n,{line:h.number-1,character:d-h.from})};return[a,yFe((u,d)=>(l(u,d).then(h=>{if(!h)return;const{line:p,character:g}=h.range.start;if(yU(h.uri)===yU(n)&&p<u.state.doc.lines){const _=Math.min(u.state.doc.line(p+1).from+g,u.state.doc.length);u.dispatch({selection:{anchor:_},effects:ft.scrollIntoView(_,{y:"center"})});return}window.dispatchEvent(new CustomEvent("band:lsp-navigate",{detail:{filePath:s.uriToWorktreePath(h.uri),worktreeId:o,line:p+1,column:g+1}}))}).catch(h=>console.warn("[diff] go to definition failed:",h)),!0)),xFe((u,d)=>l(u,d).then(h=>!!h))]}function cAn(t,e){return`${px("/lsp")}?worktreeId=${encodeURIComponent(t)}&lang=${encodeURIComponent(e)}`}function K3e(t,e){const n=`file://${t}`;return e?`${n}/${e}`:n}function uAn(t){return vFe[t]}function J3e(t){return t.webserver&&t.tunnel}const dAn=FCe({url:()=>px("/trpc"),WebSocket:JY});class kFe{trpc=VCe({links:[KCe(),CCe({condition:e=>e.type==="subscription",true:qCe({client:dAn}),false:DCe({url:vA("/trpc"),maxURLLength:2e3,fetch:(e,n)=>j4(String(e),n)})})]});async listRepos(){return(await this.trpc.repos.list.query()).repos.map(n=>({...n,kind:n.kind??"git"}))}async removeRepo(e){await this.trpc.repos.remove.mutate({name:e})}async reorderRepos(e){await this.trpc.repos.reorder.mutate({names:e})}async gitInit(e){await this.trpc.repos.gitInit.mutate({path:e})}async promoteRepoToGit(e){await this.trpc.repos.promoteToGit.mutate({name:e})}async createWorktree(e,n,r,o,i,s,a){return{hostId:(await this.trpc.worktrees.create.mutate({repo:e,branch:n,base:r,prompt:o,agentMode:i,hostId:s?.hostId,hostRepoPath:s?.hostRepoPath,...a!==void 0?{groupId:a}:{}})).hostId}}async removeWorktree(e,n,r){await this.trpc.worktrees.remove.mutate({repo:e,name:n,hostId:r})}async setWorktreePinned(e,n,r,o){await this.trpc.worktrees.setPinned.mutate({repo:e,name:n,pinned:r,hostId:o})}async reorderWorktrees(e){await this.trpc.worktrees.reorder.mutate(e)}async clearNeedsAttention(e){await this.trpc.statuses.clearNeedsAttention.mutate({worktreeId:e})}async refreshBranchStatus(e){await this.trpc.statuses.refreshBranchStatus.mutate({worktreeId:e})}async runScript(e,n){await this.trpc.worktrees.runScript.mutate({path:e,scriptType:n})}gitPull(e,n,r){return this.trpc.worktrees.gitPull.mutate({repo:e,name:n,hostId:r})}gitPush(e,n,r){return this.trpc.worktrees.gitPush.mutate({repo:e,name:n,hostId:r})}async listBrowserProfiles(){return(await this.trpc.browserProfiles.list.query()).profiles}async removeBrowserProfile(e){await this.trpc.browserProfiles.remove.mutate({profileId:e})}async listRepoBrowserProfiles(){const e=await this.trpc.browserProfiles.repoDefaults.query(),n={};for(const r of e.defaults)n[r.repoName]=r.profileId;return n}async setRepoBrowserProfile(e,n){await this.trpc.browserProfiles.setRepoDefault.mutate({repoName:e,profileId:n})}async getSettings(){return await this.trpc.settings.get.query()}async updateSettings(e){await this.trpc.settings.update.mutate(e)}async listModels(e){return await this.trpc.models.list.query({agentId:e})}async listAllModels(){return await this.trpc.models.listAll.query()}async refreshModels(e,n){return await this.trpc.models.refresh.mutate({agentId:e,hostId:n})}statusHandlers=new Set;statusSubscription=null;reconnectTimer=null;latestBranchStatuses=new Map;createStatusSubscription(){this.latestBranchStatuses.clear(),this.statusSubscription=this.trpc.status.stream.subscribe(void 0,{onData:e=>{e.kind==="branch-status"&&e.worktreeId?this.latestBranchStatuses.set(e.worktreeId,e):e.kind==="remove"&&e.worktreeId&&this.latestBranchStatuses.delete(e.worktreeId);for(const n of this.statusHandlers)n(e)},onError:()=>{this.statusSubscription=null,this.scheduleReconnect()},onComplete:()=>{this.statusSubscription=null,this.scheduleReconnect()}})}scheduleReconnect(){this.reconnectTimer||this.statusHandlers.size!==0&&(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.statusHandlers.size>0&&!this.statusSubscription&&this.createStatusSubscription()},2e3))}subscribeStatusStream(e){return this.statusHandlers.add(e),this.statusSubscription||this.createStatusSubscription(),()=>{this.statusHandlers.delete(e),this.statusHandlers.size===0&&(this.statusSubscription&&(this.statusSubscription.unsubscribe(),this.statusSubscription=null),this.latestBranchStatuses.clear(),this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null))}}subscribeStatusEvents(e){return this.subscribeStatusStream(e)}lastActiveWorktreeId=void 0;async setActiveWorktree(e){if(this.lastActiveWorktreeId!==e){this.lastActiveWorktreeId=e;try{await this.trpc.editor.setActiveWorktree.mutate({worktreeId:e})}catch{this.lastActiveWorktreeId=void 0}}}subscribeAgentStatus(e,n,r){return this.subscribeStatusStream(o=>{o.kind==="snapshot"&&o.statuses?e(o.statuses):o.kind==="update"&&o.status?n(o.status):o.kind==="remove"&&o.worktreeId&&r(o.worktreeId)})}subscribeBranchStatus(e,n){const r=o=>{o.kind==="branch-status"&&o.worktreeId&&(o.git&&e(o.worktreeId,o.git),o.ci&&n(o.worktreeId,o.ci))};for(const o of this.latestBranchStatuses.values())r(o);return this.subscribeStatusStream(r)}subscribeFileChanges(e,n){let r=!0,o=null,i=null,s=0;const a=3e4,l=()=>{if(o=null,r&&!i){const u=Math.min(2**s*500,a);s+=1,i=setTimeout(()=>{i=null,r&&c()},u)}},c=()=>{o=this.trpc.worktree.fileChanges.subscribe({worktreeId:e},{onData:u=>{s=0,n(u.path)},onStopped:l,onError:l})};return c(),()=>{r=!1,i&&(clearTimeout(i),i=null),o?.unsubscribe(),o=null}}async checkCli(){return(await this.trpc.cli.check.query()).status}async installCli(e){await this.trpc.cli.install.mutate(e)}async getWorktreeDiff(e,n,r,o){return await this.trpc.worktree.getDiff.query({worktreeId:e,contextLines:n,diffMode:r,compareBranch:o})}async listWorktreeBranches(e,n){return await this.trpc.worktree.listBranches.query({worktreeId:e,...n})}async listWorktreeFiles(e,n){return await this.trpc.worktree.listFiles.query({worktreeId:e,path:n})}async getWorktreeFile(e,n){return await this.trpc.worktree.getFile.query({worktreeId:e,path:n})}async saveWorktreeFile(e,n,r){await this.trpc.worktree.saveFile.mutate({worktreeId:e,path:n,content:r})}async readExternalFile(e){return await this.trpc.host.readFile.query({absolutePath:e})}async resolveWorktreePath(e,n){return await this.trpc.worktree.resolvePath.query({worktreeId:e,path:n})}async saveExternalFile(e,n){await this.trpc.host.saveFile.mutate({absolutePath:e,content:n})}async formatWorktreeFile(e,n,r){return await this.trpc.worktree.formatFile.mutate({worktreeId:e,filePath:n,content:r})}async createWorktreeFile(e,n,r=""){await this.trpc.worktree.createFile.mutate({worktreeId:e,path:n,content:r})}async createWorktreeDirectory(e,n){await this.trpc.worktree.createDirectory.mutate({worktreeId:e,path:n})}async deleteWorktreePath(e,n){return await this.trpc.worktree.deletePath.mutate({worktreeId:e,path:n})}async renameWorktreePath(e,n,r){return await this.trpc.worktree.renamePath.mutate({worktreeId:e,fromPath:n,toPath:r})}async copyWorktreePath(e,n,r){return await this.trpc.worktree.copyPath.mutate({worktreeId:e,fromPath:n,toPath:r})}getWorktreeFileUrl(e,n){return lh(`/api/worktree-file/${encodeURIComponent(e)}/${n.split("/").map(encodeURIComponent).join("/")}`)}async getWorktreePreviewUrl(e,n){const{url:r}=await this.trpc.worktree.previewUrl.query({worktreeId:e,path:n});return vA(r)}async searchWorktreeFiles(e,n,r){return await this.trpc.worktree.searchFiles.query({worktreeId:e,query:n,limit:r})}async searchWorktreeContent(e,n,r){return await this.trpc.worktree.searchContent.query({worktreeId:e,query:n,caseSensitive:r?.caseSensitive,wholeWord:r?.wholeWord,regex:r?.regex,limit:r?.limit})}}class OFe{copyPath=!1;navigate;getWorktreeHref(e){return`/worktree/${encodeURIComponent(e)}`}async openUrl(e){window.open(e,"_blank")}}function SFe(){return typeof window<"u"&&"__BAND_DESKTOP__"in window}function pf(){return SFe()}function CFe(){return SFe()?window.__BAND_DESKTOP__??null:null}async function Cc(t,e){const n=CFe();if(n)return await n.invoke(t,e);throw new Error(`desktopInvoke('${t}') called outside the desktop shell`)}class fAn extends kFe{async removeBrowserProfile(e){await super.removeBrowserProfile(e),await Cc("browser_profile_clear_data",{profileId:e})}async installCli(e){try{await super.installCli();return}catch(n){const r=n instanceof Error?n.message:String(n);if(e?.allowPrompt&&pf()&&r.includes("elevation-required")){const o=await this.trpc.cli.resolve.query();if(!o)throw new Error("Could not resolve CLI binary path - try reinstalling Band or restarting the app");await Cc("install_cli",{binaryPath:o.binaryPath,symlinkPath:o.symlinkPath});return}throw n}}async getUpdateStatus(){return Cc("updater_status")}subscribeUpdateStatus(e){const n=CFe();if(!n)throw new Error("subscribeUpdateStatus called outside the desktop shell");return n.on("updater-status-changed",r=>e(r))}async checkForUpdates(){await Cc("updater_check")}async downloadUpdate(){await Cc("updater_download")}async restartToUpdate(){await Cc("updater_restart")}async dismissUpdate(){await Cc("updater_dismiss")}}class hAn{web=new OFe;navigate;get copyPath(){return pf()}get translucentSidebar(){return pf()&&/Mac/.test(navigator.userAgent)}getWorktreeHref(e){return this.web.getWorktreeHref(e)}async revealInFinder(e){pf()&&await Cc("reveal_in_finder",{path:e})}async pickFolder(){return pf()?Cc("pick_folder"):null}async pickFile(){return pf()?Cc("pick_file"):null}async pickSaveFile(e){return pf()?Cc("pick_save_file",{content:e.content,defaultName:e.defaultName,defaultPath:e.defaultPath}):null}async openUrl(e){if(!pf()){window.open(e,"_blank");return}await Cc("open_external",{url:e})}}function fN({testId:t,onClose:e,children:n}){return f.jsxs("output",{"aria-live":"polite","data-testid":t,className:"pointer-events-auto relative block rounded-lg border bg-popover p-3 text-sm text-popover-foreground shadow-lg animate-in fade-in-0 slide-in-from-bottom-2 duration-200",children:[e&&f.jsx("button",{type:"button","aria-label":"Close",onClick:e,className:"absolute top-2 right-2 rounded-sm p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:f.jsx(pa,{className:"size-3.5"})}),n]})}const W$="band:hub-older-notice-dismissed";function pAn(){const e=It({queryKey:["hub-version"],queryFn:()=>Se.services.health.query(),staleTime:Number.POSITIVE_INFINITY,retry:!1}).data?.version,n=e?MTt("0.54.2",e)==="newer":!1,[r,o]=v.useState(()=>{try{return localStorage.getItem(W$)===e}catch{return!1}});if(v.useEffect(()=>{if(jTt(n),!n)return;const s=a=>{$ye(a.reason)&&a.preventDefault()};return window.addEventListener("unhandledrejection",s),()=>window.removeEventListener("unhandledrejection",s)},[n]),v.useEffect(()=>{try{o(localStorage.getItem(W$)===e)}catch{}},[e]),!n||r)return null;const i=()=>{o(!0);try{localStorage.setItem(W$,e??"")}catch{}};return f.jsxs(fN,{testId:"hub-version-notice",onClose:i,children:[f.jsxs("div",{className:"flex gap-2.5 pr-6",children:[f.jsx(_u,{className:"mt-0.5 size-4 shrink-0 text-warning"}),f.jsxs("div",{className:"min-w-0",children:[f.jsx("p",{className:"font-medium",children:"Update the hub"}),f.jsxs("p",{className:"mt-0.5 text-xs text-muted-foreground",children:["The hub runs ",e,", this app is ","0.54.2",". Some features need a newer hub."]})]})]}),f.jsx("div",{className:"mt-3 flex justify-end",children:f.jsx(Ce,{variant:"ghost",size:"xs",onClick:i,children:"Dismiss"})})]})}const e4e="band:reinstall-home-screen-dismissed";function mAn(){const t=document.createElement("div");t.style.cssText="position:fixed;visibility:hidden;pointer-events:none;padding-top:env(safe-area-inset-top)",document.body.appendChild(t);const e=Number.parseFloat(getComputedStyle(t).paddingTop)||0;return t.remove(),e}function gAn(){return navigator.standalone===!0}function vAn(){const[t,e]=v.useState(!1);if(v.useEffect(()=>{if(!gAn())return;try{if(localStorage.getItem(e4e))return}catch{}const r=()=>{mAn()<=0||(e(!0),window.removeEventListener("resize",r))};return window.addEventListener("resize",r),r(),()=>window.removeEventListener("resize",r)},[]),!t)return null;const n=()=>{e(!1);try{localStorage.setItem(e4e,"1")}catch{}};return f.jsxs(fN,{testId:"reinstall-home-screen-notice",onClose:n,children:[f.jsxs("div",{className:"flex gap-2.5 pr-6",children:[f.jsx(_u,{className:"mt-0.5 size-4 shrink-0 text-warning"}),f.jsxs("div",{className:"min-w-0",children:[f.jsx("p",{className:"font-medium",children:"Add Band to your Home Screen again"}),f.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"This copy was added with an older setup, so it doesn't fit the screen. Remove it from the Home Screen, then open Band in Safari and choose Share, Add to Home Screen."})]})]}),f.jsx("div",{className:"mt-3 flex justify-end",children:f.jsx(Ce,{variant:"ghost",size:"xs",onClick:n,children:"Got it"})})]})}function bAn(){const{status:t,busy:e,error:n,run:r}=lHe(),[o,i]=v.useState(!1),[s,a]=v.useState(""),[l,c]=v.useState([]);if(v.useEffect(()=>{t&&s===""&&a(t.defaultName)},[t,s]),!t?.promptPending||o)return null;const u=()=>{i(!0),Ho("worker_dismiss_prompt").catch(()=>{})},d=async()=>{const p=await aHe().catch(()=>null);p&&!l.includes(p)&&c([...l,p])},h=async()=>{await r("worker_add",{name:s,roots:l})&&i(!0)};return f.jsx(nr,{open:!0,onOpenChange:p=>!p&&!e&&u(),children:f.jsxs(rr,{"data-testid":"this-computer-prompt",children:[f.jsxs(hr,{children:[f.jsx(or,{children:"Use this Mac as a worker?"}),f.jsx(Nr,{children:"The hub can then run worktrees and agents on this computer. Band installs a background service that keeps running after you quit the app. You can remove it in Settings > Workers."})]}),f.jsxs("div",{className:"space-y-3 text-sm",children:[f.jsxs("div",{className:"space-y-1",children:[f.jsx("span",{className:"text-xs text-muted-foreground",children:"Computer name"}),f.jsx(Sn,{"aria-label":"Computer name","data-testid":"this-computer-prompt__name",value:s,maxLength:100,disabled:e,onChange:p=>a(p.target.value)})]}),f.jsxs("div",{className:"space-y-1",children:[f.jsx("span",{className:"text-xs text-muted-foreground",children:"Folders it may use. Add none now: choosing a repo later adds its folder."}),f.jsx("ul",{children:l.map(p=>f.jsxs("li",{className:"flex items-center justify-between gap-2",children:[f.jsx("span",{className:"truncate font-mono text-xs",children:p}),f.jsx(Ce,{type:"button",variant:"ghost",size:"xs","aria-label":`Remove ${p}`,disabled:e,onClick:()=>c(l.filter(g=>g!==p)),children:f.jsx(pa,{className:"size-3"})})]},p))}),f.jsx(Ce,{type:"button",variant:"outline",size:"sm","data-testid":"this-computer-prompt__add-folder",disabled:e,onClick:()=>{d()},children:"Add folder"})]}),n?f.jsx("p",{role:"alert","data-testid":"this-computer-prompt__error",className:"text-xs text-destructive",children:n}):null]}),f.jsxs(ii,{children:[f.jsx(Ce,{type:"button",variant:"ghost",size:"sm","data-testid":"this-computer-prompt__not-now",disabled:e,onClick:u,children:"Not now"}),f.jsx(Ce,{type:"button",size:"sm","data-testid":"this-computer-prompt__yes",disabled:e||s.trim()==="",onClick:()=>{h()},children:e?"Setting up…":n?"Retry":"Yes, use this Mac"})]})]})})}const _An=4e3;function xAn(){const t=Rr(),[e,n]=v.useState({state:"idle"});v.useEffect(()=>{if(!t.getUpdateStatus||!t.subscribeUpdateStatus)return;let i=!1,s=!1;const a=t.subscribeUpdateStatus(l=>{s=!0,n(l)});return t.getUpdateStatus().then(l=>{!i&&!s&&n(l)}).catch(()=>{}),()=>{i=!0,a()}},[t]);const r=v.useCallback(()=>{n({state:"idle"}),t.dismissUpdate?.().catch(hv)},[t]);v.useEffect(()=>{if(e.state!=="up-to-date")return;const i=setTimeout(r,_An);return()=>clearTimeout(i)},[e,r]);const o=v.useCallback(()=>{e.state==="error"&&(e.phase==="download"?t.downloadUpdate?.().catch(hv):t.checkForUpdates?.().catch(hv))},[t,e]);return{status:yAn(e)?e:null,download:v.useCallback(()=>t.downloadUpdate?.().catch(hv),[t]),restart:v.useCallback(()=>t.restartToUpdate?.().catch(hv),[t]),retry:o,dismiss:r}}function hv(){}function yAn(t){switch(t.state){case"idle":return!1;case"checking":case"up-to-date":case"error":return t.userInitiated;case"available":case"downloading":case"downloaded":return!0}}function wAn(){const{status:t,download:e,restart:n,retry:r,dismiss:o}=xAn();if(!t)return null;let i,s=!0;switch(t.state){case"checking":s=!1,i=f.jsx(Km,{icon:f.jsx(wo,{className:"size-4"}),title:"Checking for updates…"});break;case"up-to-date":i=f.jsx(Km,{icon:f.jsx(cb,{className:"size-4 text-success"}),title:"You're on the latest version",detail:`Band v${t.currentVersion}`});break;case"available":i=f.jsxs(f.Fragment,{children:[f.jsx(Km,{icon:f.jsx(N6,{className:"size-4 text-info"}),title:`Band v${t.version} is available`,detail:`You have v${t.currentVersion}.`}),f.jsx(kAn,{release:t}),f.jsxs(Z$,{children:[f.jsx(Ce,{variant:"ghost",size:"xs",onClick:o,children:"Later"}),f.jsx(Ce,{size:"xs",onClick:e,children:"Update"})]})]});break;case"downloading":s=!1,i=f.jsxs(f.Fragment,{children:[f.jsx(Km,{icon:f.jsx(wo,{className:"size-4"}),title:`Downloading Band v${t.version}…`,detail:`${t.percent}%`}),f.jsx("div",{role:"progressbar","aria-label":"Update download","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t.percent,className:"mt-2.5 h-1.5 overflow-hidden rounded-full bg-muted",children:f.jsx("div",{className:"h-full rounded-full bg-primary transition-[width] duration-300 ease-out",style:{width:`${t.percent}%`}})})]});break;case"downloaded":i=f.jsxs(f.Fragment,{children:[f.jsx(Km,{icon:f.jsx(cb,{className:"size-4 text-success"}),title:`Band v${t.version} is ready`,detail:"Restart Band to finish updating. It also installs when you quit."}),f.jsxs(Z$,{children:[f.jsx(Ce,{variant:"ghost",size:"xs",onClick:o,children:"Later"}),f.jsxs(Ce,{size:"xs",onClick:n,children:[f.jsx(bM,{}),"Restart to update"]})]})]});break;case"error":i=f.jsxs(f.Fragment,{children:[f.jsx(Km,{icon:f.jsx(_u,{className:"size-4 text-destructive"}),title:t.phase==="download"?"Couldn't download the update":"Couldn't check for updates",detail:t.message}),f.jsx(Z$,{children:f.jsx(Ce,{variant:"outline",size:"xs",onClick:r,children:"Retry"})})]});break}return f.jsx(fN,{testId:"update-toast",onClose:s?o:void 0,children:i})}function Km({icon:t,title:e,detail:n}){return f.jsxs("div",{className:"flex gap-2.5 pr-6",children:[f.jsx("span",{className:"mt-0.5 shrink-0",children:t}),f.jsxs("div",{className:"min-w-0",children:[f.jsx("p",{className:"font-medium",children:e}),n&&f.jsx("p",{className:"mt-0.5 line-clamp-3 break-words text-xs text-muted-foreground",children:n})]})]})}function kAn({release:t}){return f.jsxs("div",{className:"mt-2 pl-6.5",children:[t.releaseNotes&&f.jsx("p",{className:"max-h-28 overflow-y-auto whitespace-pre-line text-xs text-muted-foreground",children:t.releaseNotes}),f.jsx("button",{type:"button",onClick:()=>N4(t.releaseUrl),className:"mt-1.5 text-xs text-primary underline-offset-4 hover:underline",children:"Release notes on GitHub"})]})}function Z$({children:t}){return f.jsx("div",{className:"mt-3 flex justify-end gap-2",children:t})}const OAn=8;function SAn(){const t=v.useRef(null),e=AAn(t),n=Cn(r=>r.notices);return f.jsxs("section",{ref:t,"aria-label":"Notifications","data-testid":"toast-host",style:e===null?void 0:{bottom:e},className:"pointer-events-none fixed right-4 bottom-[calc(1rem+env(safe-area-inset-bottom))] left-4 z-50 flex flex-col-reverse gap-2 sm:left-auto sm:w-80",children:[f.jsx(wAn,{}),f.jsx(pAn,{}),f.jsx(bAn,{}),f.jsx(vAn,{}),n.map(r=>f.jsx(CAn,{notice:r},r.id))]})}function CAn({notice:t}){const e=Cn(i=>i.dismissNotice),[n,r]=v.useState(!1),o=t.tone==="error";return v.useEffect(()=>{if(o)return;const i=setTimeout(()=>e(t.id),NTt);return()=>clearTimeout(i)},[o,t.id,e]),f.jsxs(fN,{testId:`toast-host__notice--${t.tone}`,onClose:()=>e(t.id),children:[f.jsxs("div",{className:"flex gap-2.5 pr-6",children:[o?f.jsx(_u,{className:"mt-0.5 size-4 shrink-0 text-destructive"}):f.jsx(G7e,{className:"mt-0.5 size-4 shrink-0 text-info"}),f.jsx("p",{className:"min-w-0 line-clamp-4 break-words",children:t.message})]}),o&&f.jsx("div",{className:"mt-2 flex justify-end",children:f.jsx(Ce,{variant:"ghost",size:"xs",onClick:()=>r(!0),children:"Details"})}),f.jsx(nr,{open:n,onOpenChange:r,children:f.jsxs(rr,{children:[f.jsxs(hr,{children:[f.jsx(or,{className:"text-destructive",children:"Error"}),f.jsx(Nr,{children:"Click the error text to select it."})]}),f.jsx("pre",{className:"max-h-64 cursor-text overflow-auto whitespace-pre-wrap break-words rounded-md bg-muted/50 p-3 text-sm select-all",children:t.message}),f.jsxs(ii,{children:[f.jsx(Ce,{variant:"outline",size:"sm",onClick:()=>navigator.clipboard.writeText(t.message),children:"Copy"}),f.jsx(Ce,{size:"sm",onClick:()=>{r(!1),e(t.id)},children:"Dismiss"})]})]})})]})}function AAn(t){const[e,n]=v.useState(null),r=Cn(i=>i.activeWorktreeId),o=v.useRef(()=>{});return v.useEffect(()=>{const i=t.current;if(!i)return;let s=0;const a=()=>{s=0;const p=i.getBoundingClientRect(),g=window.innerHeight;let _=Number.POSITIVE_INFINITY;for(const y of h1e()){if(y.checkVisibility&&!y.checkVisibility({visibilityProperty:!0}))continue;const k=y.getBoundingClientRect();k.width===0||k.height===0||k.right<=p.left||k.left>=p.right||k.top<g/2||k.top>=g||(_=Math.min(_,k.top))}const x=Number.isFinite(_)?g-_+OAn:null;n(y=>y===x?y:x)},l=()=>{s||(s=requestAnimationFrame(a))};o.current=l;const c=new ResizeObserver(l),u=()=>{c.disconnect();for(const p of h1e())c.observe(p);l()};u();const d=CBt(u),h=window.visualViewport;return window.addEventListener("resize",l),h?.addEventListener("resize",l),h?.addEventListener("scroll",l),()=>{s&&cancelAnimationFrame(s),d(),c.disconnect(),window.removeEventListener("resize",l),h?.removeEventListener("resize",l),h?.removeEventListener("scroll",l),o.current=()=>{}}},[t]),v.useEffect(()=>{o.current()},[r]),e}function EAn(){const{settings:t}=Qh(),e=t.webBrowserCdpEnabled??!1;return v.useEffect(()=>{if(!On||!e)return;const n=Se.browserHost.ensureView.subscribe(void 0,{onData(o){(async()=>{try{await Ho("browser_ensure",{browserId:o.bandTabId,url:o.url,profileId:o.profileId??null});const i=await Ho("browser_get_cdp_target",{browserId:o.bandTabId});await Se.browserHost.targetReady.mutate({bandTabId:o.bandTabId,cdpTargetId:i})}catch(i){console.error("[BrowserHostBridge] ensureView failed:",i)}})()},onError(o){console.warn("[BrowserHostBridge] ensureView subscription error:",o)}});let r;return Qf("browser-view-destroyed",o=>{const i=o.payload.browser_id;i&&Se.browserHost.viewDestroyed.mutate({bandTabId:i}).catch(s=>console.warn("[BrowserHostBridge] viewDestroyed mutate failed:",s))}).then(o=>{r=o}),()=>{n.unsubscribe(),r?.()}},[e]),null}function TAn(){return Ho("browser_chrome_profiles")}function MAn(){return Ho("browser_chrome_running")}function PAn(t){return Ho("browser_chrome_import",{...t})}function t4e(t){return Ho("browser_profile_clear_data",{profileId:t})}function jAn(t){return Ho("browser_profile_prune",{keep:t})}function G$(t){const e=t instanceof Error?t.message:String(t);return/Error invoking remote method '[^']+': (?:\w*Error: )?(.*)$/s.exec(e)?.[1]??e}let n4e=!1;function NAn(){return v.useEffect(()=>{!On||n4e||(n4e=!0,Se.browserProfiles.list.query().then(({profiles:t})=>jAn(t.map(e=>e.id))).catch(t=>console.error("Failed to prune deleted browser profiles:",t)))},[]),null}const RAn="/assets/android-studio-t3zZ7G0e.svg",LAn="/assets/antigravity-m-mWKI7R.svg",IAn="data:image/svg+xml,%3csvg%20width='40'%20height='40'%20viewBox='0%200%2040%2040'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_5436_78947)'%3e%3cmask%20id='mask0_5436_78947'%20style='mask-type:luminance'%20maskUnits='userSpaceOnUse'%20x='4'%20y='4'%20width='32'%20height='32'%3e%3cpath%20d='M4%204H36V36H4V4Z'%20fill='white'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_5436_78947)'%3e%3cpath%20d='M28.375%204H11.625C7.41383%204%204%207.41383%204%2011.625V28.375C4%2032.5862%207.41383%2036%2011.625%2036H28.375C32.5862%2036%2036%2032.5862%2036%2028.375V11.625C36%207.41383%2032.5862%204%2028.375%204Z'%20fill='black'/%3e%3c/g%3e%3cpath%20d='M29.6214%2014.2072L20.9502%209.12249C20.6718%208.95917%2020.3282%208.95917%2020.0498%209.12249L11.3786%2014.2072C11.1445%2014.3445%2011%2014.5984%2011%2014.8733V25.1267C11%2025.4012%2011.1445%2025.6555%2011.3786%2025.7928L20.0498%2030.8775C20.3282%2031.0408%2020.6718%2031.0408%2020.9502%2030.8775L29.6214%2025.7928C29.8555%2025.6555%2030%2025.4016%2030%2025.1267V14.8733C30%2014.5988%2029.8555%2014.3445%2029.6214%2014.2072ZM29.0767%2015.2843L20.706%2030.0101C20.6494%2030.1093%2020.5%2030.0688%2020.5%2029.9538V20.3115C20.5%2020.1189%2020.3986%2019.9407%2020.2342%2019.8439L12.0124%2015.0226C11.9147%2014.9651%2011.9546%2014.8134%2012.0678%2014.8134H28.8093C29.047%2014.8134%2029.1956%2015.0751%2029.0767%2015.2843Z'%20fill='white'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_5436_78947'%3e%3crect%20width='32'%20height='32'%20fill='white'%20transform='translate(4%204)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",DAn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAAB8pJREFUeAHtWG+MXFUV/9375s3szNDturKbLpt0aZo2fvAfpEBEss2iMZJaFTBdG1BrUfGLmohWaGvaQtYYU2miJsRKTQikkhDRIKmRNcEPJGgw1hJFcetu2mJcKrPbmZ2dP++9e6/n3PtmdnbelJnlC3zobc++mXvPu+d3z/87wJVxZby9Q3RZl0T65Pnzu2f94S/Pl70tQYhBpWG0Mn3odRgSJBFIAeOnxKWBPvWvTVj66Vc2DT0ZYzB4CwDlaWN2H5tRT1QvKONJCCHxlodpE6Y1EAxI3PtefOvjvn+Mp7AGgN7vjPnxT6Yr916VScmuem4FQkjq0uDGDR5ky3ukdAQK+O+ywflFjZyU8D3iDZXaMd73m3t8eSc6gOwkWp4xZvLA76uPr0t7nunA+GZz7xkROLTFR7fx4lKEQy8qDGUFqnWjvnSr/8AOz3uYllQ3gNhztm5qF7DmUagCz92W7pm/SHTnbwMCCVTyEtefmvIOHz68SosJr3rif6VPFF/VUBHWTCP9K3uzSRukWoi/N7S9nujALRLVmoB/SZsNu/Z8sR1PAuDZcuqbkqdZloJ7tpLqME/fdSRw+xbP7uFYBJRxpFsoYqL1KH51+7oUqhFx0/+z9Wv2tONJtU/Ml/wt2tA5I6xpXKoaTAz5Tfws/XK5Q5tYM9IB2DggsFACLpb01q4Aq1U9yMcza4hcHumUxnohUINLITwum9xoQQsHkgEMU6AUFiiiA5FvZ02YWIXwKRGjlXRMlAnxnz8+Q2/J5lyD5yObPQTEEpnY6i1rGQIzPf0CKLm7d4ybZ142VIr2s3JCk+0KMAwofZGNROTIajN++jkfp394F/lbABO6OeapVoA7CKD1K3qXXMqC0DHNzL2G3ZN7kPbiAzNA48DyYaR2SFUkEkpPmJjB8CaN+tP6VAyKtVeNXUC6+eXQYCwrUWJgVqpsiVXmFfBkhtYMQgZD34U1iIFHnwwHE81LBXQHSIzaBogTIOJUyScN6xr5a7fByCyZI4LwlNXGB0eBMjGE1oR0APonmilWYGTDED40fgOW6ORUNB04uykBN6wU7cgT3QFacJHbwmB1DQ2LEW7+7h8QVuvkB9JqKiDeyQ9QcJCA0PolQWOhTQ0a1E0Kj508wRUDkjNRbEnJlpVw5og8KE93B8inUrqhM4FEQQsiO6dj9IsVhfcPZVCiZMuHcyLk6hCmz7VYNvuoIBPztlq6Q7HV6HxIqx40yJLJWel9GZ80lmRisCKWyERzo1QOaqGwuLU7mTvaZXOM24q38eiDlM4HWSuqQz+TAKj4FI082J4Mm53bil9+6sMpStLaaU6sYGdTv0kmdLLYETgwKN9oCkDZiw8aZSz10mJxa1WhzOxT38RyuL2q1Fwi1BxszVOtesv+lfEKR7LlZ7kdqleHNGOcqnusJCef13jqhSpVEthy9ctvZ7FAVSEigGaVLzfAiSZsjjMmEyd0T/cYJDbLrsqClxsCGQ5FJSk508ECY7UacLpRaAZScg9jgUlyIRE4SwirwaRWEpWETcN+YcgXm0/tobJ4jlY9ilQZr4kEnyagmqQFFJL1yFigAbf2MaVzXHPnqYum1EPmrNt17bohKwfdAXJisqdvIZlJ429Ht2Hmmf2QaQZpEjyWCBi3VGEoQXkcETl+RFqh8ol3DXo4vO97+OrkXvh90s5HBDQIXWtn9+wJoDFRowFt1OBwsYobpsoonHkKfz12o/UCqJQriy18SklbsuramZk1RIUDIZZx984vYHZmBo89dwpvFAKnZeJnHvY/awnTg4k9Qa1C3E02uhUuXEGpim3fmUN20078+WAOs6e+jqBeRCqdIQdKkeac6e2mFM45akRLxUX8aGoKd39sByZ23IGpR45jocANmW81HFKWDimH1mvamlcaU2vHkwgSX+pFpZCDbqshnP2XA2y85QGMjR/Av6fvx5mHt6Ivm0V+9Cb0Db+PTLceU4ckzs1dwOw/XyaNGtz6yc/hZ88+j6ViBTUS73lpq102g+QAo2oy/4azRMY3y10BXp3HzLlIjwqZjD3bbAgOhghj2x+C99GjqJfnUXrtNOoL/0C5UEb/wGaM3zaOz3/tQfTlcqgu17BcipDyszZ5s0VcN21s3hxcB/x9VqHPF7hmUM51BTiWff3Rl6Lh7Z4n4qLW6GpW/rpPJCysUdAMYHBsAmbjBApFhbv25vHKTGhTR40qDGvM3kc4hZg479j2i4KHoFaqkU1TIa3dfO2lx0+04Ul4pSFP3Xp/qPuNWkmrLXk2MdcyXywDvzji4y+vknY413Vwes2as5cnjevokvXZQ3W8m35hkOslXtqfSbyQCBLqNMQ3PuPtq1Yibt5sZTHkzCY0ca/eNhfFpZGeA1mNI8cDjA1zbyhsjgu0aRJXF67vV1ODMUIXpcmDNQz104WrFOnj92GqIx50HnL/tH766V+Xd2bT3pp+kWHHqFNWnrg+hXym0VkLeyOuU6WZLwi8PKesi/TRHX+ppvXRg/lnPz0qb0ePP300QZ54Jbzv+z/XP8hz9yzQc31ujE5VjrewdxIlTGbIE4/uSx25Lus9iDX+eNS6bh761cV7zpzL7y0UsbkWiKvIn7N8dV4LYOqkBdmiksua+tiInLlp08Un+1//0yO7du1qXqWvjCvjnTj+D8SthzamBKAPAAAAAElFTkSuQmCC",zAn="data:image/svg+xml,%3csvg%20width='40'%20height='40'%20viewBox='0%200%2040%2040'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_5437_79067)'%3e%3cpath%20d='M27.395%2036C26.1435%2035.9986%2024.9203%2035.6274%2023.879%2034.933C22.8374%2035.6273%2021.6139%2035.9985%2020.362%2036C19.113%2036%2017.882%2035.625%2016.846%2034.933C15.8189%2035.6241%2014.61%2035.9954%2013.372%2036H13.334C12.4944%2036.0006%2011.6633%2035.8321%2010.8902%2035.5047C10.1171%2035.1772%209.41781%2034.6975%208.83405%2034.094C7.65642%2032.8996%206.99679%2031.2893%206.99805%2029.612V17.362C7.00005%209.995%2012.994%204%2020.362%204C27.731%204%2033.725%209.994%2033.725%2017.363V29.616C33.725%2033.009%2031.099%2035.808%2027.747%2035.991C27.63%2035.998%2027.513%2036%2027.395%2036Z'%20fill='%233551F3'/%3e%3cpath%20d='M27.395%2034.5932C26.2752%2034.5924%2025.1889%2034.2104%2024.315%2033.5102C24.1961%2033.4145%2024.0476%2033.3632%2023.895%2033.3652C23.7174%2033.367%2023.5457%2033.4291%2023.408%2033.5412C22.5392%2034.2237%2021.4668%2034.5951%2020.362%2034.5962C19.2576%2034.5949%2018.1855%2034.2234%2017.317%2033.5412C17.1835%2033.4338%2017.0174%2033.3752%2016.846%2033.3752C16.6747%2033.3752%2016.5085%2033.4338%2016.375%2033.5412C15.518%2034.2199%2014.4581%2034.5914%2013.365%2034.5962H13.332C12.6806%2034.5961%2012.0359%2034.4649%2011.4362%2034.2102C10.8366%2033.9556%2010.2945%2033.5829%209.84201%2033.1142C8.92225%2032.1822%208.40639%2030.9256%208.40601%2029.6162V17.3672C8.40601%2010.7702%2013.77%205.40723%2020.363%205.40723C26.955%205.40723%2032.319%2010.7702%2032.319%2017.3632V29.6162C32.319%2032.2612%2030.277%2034.4432%2027.669%2034.5862C27.5777%2034.5909%2027.4864%2034.5932%2027.395%2034.5932Z'%20fill='black'/%3e%3cpath%20d='M30.912%2017.3635V29.6165C30.912%2031.4925%2029.465%2033.0795%2027.592%2033.1825C26.725%2033.2323%2025.8704%2032.9582%2025.194%2032.4135C24.416%2031.7875%2023.321%2031.8155%2022.536%2032.4345C21.9163%2032.9237%2021.1495%2033.1891%2020.36%2033.1875C19.5714%2033.1889%2018.8056%2032.9235%2018.187%2032.4345C17.8057%2032.1306%2017.3326%2031.9651%2016.845%2031.9651C16.3574%2031.9651%2015.8843%2032.1306%2015.503%2032.4345C14.8904%2032.9183%2014.1336%2033.1834%2013.353%2033.1875C11.405%2033.2015%209.81299%2031.5605%209.81299%2029.6125V17.3625C9.81299%2011.5375%2014.537%206.81348%2020.363%206.81348C26.188%206.81348%2030.912%2011.5375%2030.912%2017.3635Z'%20fill='white'/%3e%3cpath%20d='M18.28%2016.4366L14.35%2014.1666C14.104%2014.0248%2013.8117%2013.9865%2013.5374%2014.06C13.2632%2014.1335%2013.0292%2014.3128%2012.887%2014.5586C12.7452%2014.8045%2012.7067%2015.0966%2012.78%2015.3709C12.8533%2015.6452%2013.0324%2015.8792%2013.278%2016.0216L15.604%2017.3646L13.278%2018.7076C13.045%2018.8559%2012.8783%2019.0886%2012.8126%2019.3569C12.7469%2019.6252%2012.7873%2019.9085%2012.9255%2020.1478C13.0636%2020.387%2013.2887%2020.5637%2013.554%2020.641C13.8192%2020.7183%2014.104%2020.6902%2014.349%2020.5626L18.281%2018.2926C18.4436%2018.1985%2018.5786%2018.0633%2018.6724%2017.9006C18.7662%2017.7379%2018.8156%2017.5534%2018.8156%2017.3656C18.8156%2017.1777%2018.7662%2016.9932%2018.6724%2016.8305C18.5786%2016.6678%2018.4436%2016.5326%2018.281%2016.4386V16.4366H18.28ZM27.182%2016.2906H22.018C21.7338%2016.2906%2021.4613%2016.4034%2021.2604%2016.6044C21.0594%2016.8053%2020.9465%2017.0779%2020.9465%2017.3621C20.9465%2017.6462%2021.0594%2017.9188%2021.2604%2018.1197C21.4613%2018.3207%2021.7338%2018.4336%2022.018%2018.4336H27.182C27.4662%2018.4336%2027.7387%2018.3207%2027.9397%2018.1197C28.1406%2017.9188%2028.2535%2017.6462%2028.2535%2017.3621C28.2535%2017.0779%2028.1406%2016.8053%2027.9397%2016.6044C27.7387%2016.4034%2027.4662%2016.2906%2027.182%2016.2906Z'%20fill='black'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_5437_79067'%3e%3crect%20width='27'%20height='32'%20fill='white'%20transform='translate(7%204)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",$An="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTYgMjU2Ij4KICA8ZGVmcz4KICAgIDxsaW5lYXJHcmFkaWVudCBpZD0iYSIgeDE9IjAiIHkxPSIwIiB4Mj0iMjU2IiB5Mj0iMjU2IiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+CiAgICAgIDxzdG9wIG9mZnNldD0iMCIgc3RvcC1jb2xvcj0iI0Y5N0ExMiIvPgogICAgICA8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiNGQzI5QjgiLz4KICAgIDwvbGluZWFyR3JhZGllbnQ+CiAgPC9kZWZzPgogIDxyZWN0IHdpZHRoPSIyNTYiIGhlaWdodD0iMjU2IiByeD0iNDgiIGZpbGw9InVybCgjYSkiLz4KICA8cmVjdCB4PSI0OCIgeT0iNDgiIHdpZHRoPSIxNjAiIGhlaWdodD0iMTYwIiByeD0iNCIgZmlsbD0iIzAwMCIvPgogIDx0ZXh0IHg9IjYwIiB5PSIxNzgiIGZpbGw9IiNmZmYiIGZvbnQtZmFtaWx5PSJBcmlhbCxIZWx2ZXRpY2Esc2Fucy1zZXJpZiIgZm9udC13ZWlnaHQ9ImJvbGQiIGZvbnQtc2l6ZT0iNTYiPklKPC90ZXh0Pgo8L3N2Zz4K",BAn="data:image/svg+xml,%3csvg%20width='40'%20height='40'%20viewBox='0%200%2040%2040'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20x='4'%20y='4'%20width='32'%20height='32'%20rx='6.4'%20fill='url(%23paint0_linear_5437_79079)'/%3e%3crect%20x='4.80005'%20y='4.7998'%20width='30.4'%20height='30.4'%20rx='5.6'%20fill='black'/%3e%3crect%20x='7.19995'%20y='7.2002'%20width='25.6'%20height='25.6'%20rx='3.2'%20fill='%23202A2F'/%3e%3cpath%20d='M25.2454%208.85742H19.2454V20.8574H25.2454V8.85742Z'%20fill='%230EE827'%20fill-opacity='0.35'/%3e%3cpath%20d='M11.7895%2018.9218C11.4758%2018.8949%2011.1817%2018.85%2010.9072%2018.7872C10.6424%2018.7154%2010.3973%2018.6392%2010.1718%2018.5584C9.95613%2018.4776%209.76496%2018.4014%209.59829%2018.3296C9.44145%2018.2488%209.32378%2018.186%209.24536%2018.1412L9.87771%2016.9567C9.94631%2017.0016%2010.064%2017.0644%2010.2306%2017.1452C10.3973%2017.2259%2010.5836%2017.3111%2010.7895%2017.4009C11.0052%2017.4816%2011.2257%2017.5534%2011.4513%2017.6162C11.6768%2017.679%2011.8875%2017.7105%2012.0836%2017.7105C13.064%2017.7105%2013.5542%2017.3381%2013.5542%2016.5933C13.5542%2016.4138%2013.5199%2016.2658%2013.4512%2016.1492C13.3925%2016.0325%2013.2993%2015.9338%2013.1719%2015.853C13.0542%2015.7633%2012.9071%2015.687%2012.7307%2015.6242C12.564%2015.5525%2012.3729%2015.4806%2012.1571%2015.4089C11.7453%2015.2653%2011.3777%2015.1172%2011.0542%2014.9647C10.7405%2014.8032%2010.4708%2014.6237%2010.2454%2014.4263C10.0199%2014.2289%209.8483%2014.0046%209.73063%2013.7534C9.61303%2013.5021%209.5542%2013.2149%209.5542%2012.8919C9.5542%2012.6407%209.60812%2012.3984%209.71596%2012.1651C9.82379%2011.9318%209.97572%2011.7254%2010.1718%2011.546C10.3679%2011.3576%2010.6032%2011.2005%2010.8777%2011.0749C11.1522%2010.9403%2011.4562%2010.8461%2011.7895%2010.7922V8.85742H12.9954V10.7653C13.2503%2010.7922%2013.4954%2010.8326%2013.7307%2010.8865C13.966%2010.9403%2014.1767%2010.9986%2014.363%2011.0614C14.5493%2011.1242%2014.7062%2011.1871%2014.8336%2011.2499C14.9709%2011.3037%2015.0689%2011.3441%2015.1278%2011.371L14.5395%2012.4747C14.4611%2012.4388%2014.3483%2012.3939%2014.2012%2012.3401C14.064%2012.2773%2013.9072%2012.2144%2013.7307%2012.1517C13.5542%2012.0888%2013.363%2012.035%2013.1571%2011.9901C12.9513%2011.9453%2012.7454%2011.9228%2012.5395%2011.9228C12.2062%2011.9228%2011.9071%2011.9856%2011.6424%2012.1112C11.3875%2012.2279%2011.2601%2012.4298%2011.2601%2012.7169C11.2601%2012.8964%2011.2944%2013.058%2011.363%2013.2015C11.4414%2013.3361%2011.5493%2013.4573%2011.6865%2013.5649C11.8336%2013.6726%2012.0101%2013.7758%2012.2159%2013.8745C12.4316%2013.9642%2012.6768%2014.054%2012.9513%2014.1437C13.314%2014.2782%2013.6376%2014.4173%2013.9218%2014.5609C14.2062%2014.7045%2014.4463%2014.866%2014.6424%2015.0455C14.8385%2015.2249%2014.9856%2015.4313%2015.0836%2015.6646C15.1914%2015.8979%2015.2454%2016.1715%2015.2454%2016.4856C15.2454%2016.7548%2015.1964%2017.015%2015.0983%2017.2662C15.0101%2017.5175%2014.8679%2017.7508%2014.6718%2017.9661C14.4856%2018.1815%2014.2503%2018.3699%2013.966%2018.5315C13.6915%2018.684%2013.3679%2018.7962%2012.9954%2018.8679V20.8574H11.7895V18.9218Z'%20fill='%230EE827'/%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_5437_79079'%20x1='20'%20y1='4'%20x2='20'%20y2='36'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23D4E6E8'/%3e%3cstop%20offset='1'%20stop-color='%23767573'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",HAn="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTYgMjU2Ij4KICA8ZGVmcz4KICAgIDxsaW5lYXJHcmFkaWVudCBpZD0iYSIgeDE9IjAiIHkxPSIwIiB4Mj0iMjU2IiB5Mj0iMjU2IiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+CiAgICAgIDxzdG9wIG9mZnNldD0iMCIgc3RvcC1jb2xvcj0iI0ZGOTkwMCIvPgogICAgICA8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiNGRjY2MDAiLz4KICAgIDwvbGluZWFyR3JhZGllbnQ+CiAgPC9kZWZzPgogIDxyZWN0IHdpZHRoPSIyNTYiIGhlaWdodD0iMjU2IiByeD0iNDgiIGZpbGw9InVybCgjYSkiLz4KICA8dGV4dCB4PSI1NiIgeT0iMTc4IiBmaWxsPSIjZmZmIiBmb250LWZhbWlseT0iQXJpYWwsSGVsdmV0aWNhLHNhbnMtc2VyaWYiIGZvbnQtd2VpZ2h0PSJib2xkIiBmb250LXNpemU9IjcyIj5LPC90ZXh0Pgo8L3N2Zz4K",FAn="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTYgMjU2Ij4KICA8ZGVmcz4KICAgIDxsaW5lYXJHcmFkaWVudCBpZD0iYSIgeDE9IjAiIHkxPSIwIiB4Mj0iMjU2IiB5Mj0iMjU2IiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+CiAgICAgIDxzdG9wIG9mZnNldD0iMCIgc3RvcC1jb2xvcj0iI0ZDODAxRCIvPgogICAgICA8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiNCNzRDRjAiLz4KICAgIDwvbGluZWFyR3JhZGllbnQ+CiAgPC9kZWZzPgogIDxyZWN0IHdpZHRoPSIyNTYiIGhlaWdodD0iMjU2IiByeD0iNDgiIGZpbGw9InVybCgjYSkiLz4KICA8cmVjdCB4PSI0OCIgeT0iNDgiIHdpZHRoPSIxNjAiIGhlaWdodD0iMTYwIiByeD0iNCIgZmlsbD0iIzAwMCIvPgogIDx0ZXh0IHg9IjYwIiB5PSIxNzgiIGZpbGw9IiNmZmYiIGZvbnQtZmFtaWx5PSJBcmlhbCxIZWx2ZXRpY2Esc2Fucy1zZXJpZiIgZm9udC13ZWlnaHQ9ImJvbGQiIGZvbnQtc2l6ZT0iNTYiPlJSPC90ZXh0Pgo8L3N2Zz4K",qAn="data:image/svg+xml,%3csvg%20width='40'%20height='40'%20viewBox='0%200%2040%2040'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_5436_78897)'%3e%3cpath%20d='M35.911%2020.0773C35.911%2019.7026%2035.552%2019.4866%2035.1114%2019.5939L4.79962%2027.0055C4.35812%2027.1135%204%2027.5052%204%2027.8792V35.4541C4%2035.8288%204.35812%2036.0455%204.79962%2035.9375L35.1114%2028.5266C35.552%2028.4187%2035.911%2028.0269%2035.911%2027.6523V20.0774V20.0773Z'%20fill='url(%23paint0_linear_5436_78897)'/%3e%3cpath%20d='M4%2019.8353C4%2020.21%204.35812%2020.6016%204.79962%2020.7097L35.1159%2028.1219C35.5573%2028.2299%2035.9155%2028.0133%2035.9155%2027.6393V20.0637C35.9155%2019.6897%2035.5573%2019.298%2035.1159%2019.19L4.79962%2011.7778C4.35812%2011.6699%204%2011.8858%204%2012.2603V19.8353V19.8353Z'%20fill='%23FF9800'/%3e%3cpath%20d='M35.911%204.51106C35.911%204.1365%2035.552%203.91973%2035.1114%204.02778L4.79962%2011.4387C4.35812%2011.5466%204%2011.9383%204%2012.313V19.8879C4%2020.2626%204.35812%2020.4786%204.79962%2020.3712L35.1114%2012.9596C35.552%2012.8517%2035.911%2012.46%2035.911%2012.086V4.51106Z'%20fill='%23FF9800'/%3e%3c/g%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_5436_78897'%20x1='1762.84'%20y1='981.852'%20x2='1845.15'%20y2='624.882'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23FF9700'/%3e%3cstop%20offset='0.53'%20stop-color='%23F48E00'/%3e%3cstop%20offset='1'%20stop-color='%23D06F00'/%3e%3c/linearGradient%3e%3cclipPath%20id='clip0_5436_78897'%3e%3crect%20width='32'%20height='32'%20fill='white'%20transform='translate(4%204)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",VAn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAAA0RJREFUeAHtmM9PE0EUx18pJCRaugUhQkuqXgi3eqDVpJFK+g9w8Ejkohcg4I8DFynECxdEAlz0gA0nNYF4kkODRDQmNQQ8NRhjbd1FrQHankja3XFm7DbN7rQMyS7l0E+y3dmZt/u+mffednYAatSoLpZKg9s//wawRUhKJj2/90QBLNgcocJt+EyvAQo/UBwv2qkeCm7o2P/ri+3OtOuSewcpEL7quvACTsJ2PC5sJf8sPQw9Rh2dnaigwPCjw9WJJmfm0FYyNUt8Ai+f4+Ls3dEHpgnTHndG76NoXFpiaanXdnz8Gh988+rl2LO5GXrd2NgILS0tUFdXB0aSy+Vgf3+fnp/PPYFztvODn2Lx8PXuyxuldroc/BD79u5WMBD4JYnQ0NAAbrfbcHEqiqKAKIpwdHQE7U4XvI683/B3X7lZaqPzLCV+eIg4Qmtrq2niqHP8bBIdAvEpJr57dDbajj1RLCar1Wot9i8vL0MwGAQzRKpgkXbduLZDlmVg4XQ6YXFxkR6kbQZKXtalnE4gwnnBYmhoCKLRKJ3F9fV1mJ6eNlwozkkExwlU5Dzz5lgsBgMDAzA+Pg6SJEF/fz8VOjw8DMYJ1EePO8Qqq6ur0NfXR2eT4PP5wChknhArZUKs4vV6acGQczabhUgkAkbBil693kguK2xkZISeCSsrK7CwsEDDbRSs/OcWqBYFCe38/HwxxEbCSi+9QIUtkAgis1ZO2O7uLpSjq6sLeGD51gnEicq8mVSv2XDNIFIqV3E5eGepEkjmeM0cV8VmIvMILBfi00DhmkFURYFIHz3GX10VBeZ5ZrCaApUzLhAXCcdqpopVjF9xxy8WZPmMVzGqqkCOKrbZbGm1fRqzWZpS2Pehdlwn0C7YdxwOB20fHByYmpPk2alUirYF7FMQhC9aG/1iQZanfNd8gbW3a/R7NZFIQFtbm+Gfn0Sc+uFOCAQCkM/nwlw3PwqFlnp7e09t6+MG9jUxMfGUpaWe1Wm1WO75/f40zomxzc1NyGQyYAaCYIeeHi9ZpYdxhCZZNhW33/AacBBvmd3OpA896WxW/aBHFry/hkr24TTXWrT7dNSmydaUdjQ37+DmFF6tb0CNGmeUfwIH0sS3Pm7dAAAAAElFTkSuQmCC",QAn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAACs9JREFUeAHtWHmMVdUZ/93tvXffPjvzZpiFwswILkEpIIqMWlAWjVpBTTXGYk1tivoHWhurorVp2miiMRUaW7FWkSaS2IoLdYPUBkXBBkZRUdaZgWHWN2+767n9zrlvGJlhebX/td6bk3lz3z3n+53f9/uW84Bvr//xS/pPXm5vb1d7e3tlfMMrFAp5V2y/wl2FVazUOacCKC+dtDR275U///PU1NT5AUkLecwDH6PTRj6X/kySJRoyXOZae47seXvZ80uXfdL7Sa74UskA5Z0rdv6ipbZtVWY4RxO9b8zaqS7P81gkqct9ff0PNz428SF6xEoBKO29a/9D8WDiPpex0oB5xwyKJSXpFKuf4NJkxT2Q2ffI9KemPzwW5DgATcmmRGWy6n7bdmXmejjdcB0Gx6XhOAjODCA4S6PPbvEZQylrmLajtFaf8cDihsWJsXjG7XH7rR+/WR1JXSJDHgeeMyRuiz5bDHJMFuwxj8BkHDStSUFSJOy7tQtqXIUs0fdEpzPgQA7RirokTMrSeGpdEndndv+mOc/MWnhKBlsq2trhYhx7nA3XJWZMhtg1YVTcXQYWBSzbESN8UQjMoHeyLsLzQvTMhkWsMp2hcU0talaWwy64tJbrM8uOX19iknR29VkXj8UzDmAQAZXWIDCeP5j/lzEGmxY2LQtSUII7xFB+XQKWbMGwDKgTFXqHswmoDSo9M2HYJurvrYbTx2iODKNgiTX4Wq7jHWeDg9QQCGKMV8cCDFqkH9dl/hAL+Z8doTXaPd2Z3TnBgENsNayow+DhNByPdkWu5sPxHAx0DqHt8WY4tBEKVqR3ZuBqLgF0it4oAi3aEJq1PTShKXhSgKlUSmG26zNB9pgQOU0k11ikMcdyhNv2bexEMKkJMFa/ibJ5CRTShgg/PoxhA+WXJIg5hysXalLG7qf30lxLBJOdp7UMH5hvA8KmS+QUagrKSQGSxiROBAflFiPRSDvkpipM/nUK1VdVIDeQh605OLSlm9zpCUDfuaoR3R8fId94AlDXh0cwbcUUeCKAPBze0gdHsWhuAckL40jdXomqW5Iws46wwXXJXD/iT6vBEea4LrgrjJwBvSkgojExPYzz152N1lua8d6j2xCu1IlEhgIZVnQVkkoRGpAhhSTYg46I+lCthtfv3IyJl6dw7m+nITqV5pDK+HMzZxal4zPJySkBIBeuD5K7A5SZdtz5BdQyWcjXGWComJbADz9divU3v4xIlS42VXdOijKuJErZlAXNYDaDVq7g2Xkv4cZNV6N8WhnMQUuA1hIqdj+xn7KAJ2yMBExJDPoR7O+K/7UtG5m+LN666QNoVSrtnhYhEMZhGzf9/WrsfGU3tJAKPRZEYbAg3o3VxqGGFWx/ugPXrb0S2Z4CUHS/XhXC1gf/hUx3FpblHLMjotkpycXF3MRGJ/Jd8vTy3Oy/YscfOxCq0SATW2a/i+k3TsXBjkPk/ghiZTEkqwhchYRPX9uDyXMnIdefJ9dDMP3Zxi/x0vWvwcgbsF2nqLuv58Rx+KCOY9Apvgw/FxbILdVLyhFtoURMGbwwbOLVu99FIKrhzCVtiNWE0bKoWYCQSXtcqyzvonXJZPTvGER+yMS+jw7ANm3Un5fCrNnnQPEU5L8y0bMxDSXKN+uzy3jQ95wWIIq5yUHVZXHM+nELrGFH5DKv2BVMXtRAwUBgZA+de7sxUW+El6TkPeIhlRxj0mZSGUy8oA71C6rI+Kj7JH7PldD2k2YcerEXPRvSBFIlT53OxT0oupS0R2J0OSjH350YYn5xEe4WEny2kCFWGTJZIGsDOarTw1mPciGQHkqLxmHUijfa9XEpyzxveiJ5i8zhsBJc7Po1l7N44G89+OS5r1B/TSUSrWHqCj3kKSEf3NZJLlUwZWYjDKosufoczLwGtTzgR3q/BT1P0eqq6P94CB2kx8KggUlzGqAndSJexvCeHA6+1IdoPEzFNQiJ2zxBFJ8AYDHVMB+kFAH2vt4F6xUTA4cH0bq4GZffMY+iNQ/ToLRhuFi/4U+4ev6N8I5SlFOSk6nUvfDGWixb/n3E9Sgu/un50KsD2PyrbXj3mW2obKxAQA4gEA5RWWRQiBTZY8L22Ou4wlyDmsjmRZ9njxhdop5ajAq+a8D0KOro87K1C5DtNUSE8xEuD+Gddf9Ew2WV6OjYhe6hLpEH40Y5pk45E4NUsxf9rB0WlTxZUUQjq9cGsG7h65AMFUEliKAcQkAJUQpVMSFUh/bXWqM96MmdWIPAsXBnLq1GDbUsKdDjOq79w3wMUz4TZxKSSrIuhkcXP43LVl6EhF6G+kQTZs6ejZnnz0ZNsA5lkTJceO0M/PLspxBOhahKMDGv0G1h2YYFSDTEiB1yIFPgl1eUWOocv3CD+QALPQ4uf2IW8n0meI2KUHk7tPMIVrb9Bqs+vwOFXhPxRBwH3utBc+MkNKWa0LNrEPF4DPlBE/e9dTtWxB7Bns0HoFWqouGxqcNZ+Oxs5DtNSJ5vRzQLpeRBAW7kRZqsBVUMHchCDSg4RE3Au7/7gDpjYPmaa5HvKkBVVCQnxGAM2NADupimaRol7KRoDgY7M1j+5DK8/ej7eOPBrVj0wFw0XZqC9aVFuZSCypUFTSJPsNNoMIVU+NWLOnJHzcPkDb+v49rLFXLIWzl4IXoGG+neDO757GaYfZZY+Z3V7yPeFMZZ17SI/3e9vAddW3tx6Y/mcLOIEetPLvkLIjGdGCFO8grCwQiikSgFSxAq6U+GgqpQLRZuOePkGqS4ouOFNFqCRMnzKInKCOhBUQEk0szC+y+A2euQ6MnlE0PY8vvtiJRFBZuqqiFaFsGujV8gQVWGv5PtMzD/rjlirkx9czBCoALqMd35DQr3sUSpuMc9qQb3Y781ooeRptXjgcLIsKfSHgNwM8Ck79WBn4e0MhWPz3kRVakKfhQiMLIApNCdrCnHk1etR7RaF+WvceYEsAyFhafRRgOkPUXonNsQLf+otMyTAuQStG3LPNY8evwwQwA9DjAIjRbmqcGmVl9PBfDCdZvIqEdwVBzdNSBOa1wzRzoGiCfuzACev2UTRXxEVKcApRQNfASgMK0IEhhpkg3eso/5hWHc+W9N68Z3Jqj17RQfEhPvMtHDUdr2NemZyAwPI5POIprSRTLn7+TTJu459ANRsh5rWQ89HOScivyX6zERiYQRjcVEglYlahCKt2Cdo/Ik1ud0/+O2zxe1fx2PMhbgfuOrN66vvG1lxsmIDt77Winm/3BNStRqBaNBwS53J89nqkqaouNn14d96NuRoV8LCAhxJZPu9Agl40BAMCqe0Rxe7kRrTYPbmKDVSsv3Xjq34BSGTwnwqN1VaNPPK6tUamcwLkC+AJP8QzvzD+miH/Ek4VqZBg8ebrT7g34c/mhQ1FYBhpji7yhFhyskFS4XicBx93JBcHCkS9aR37765d7n1o/FMw4g5+nNoQ1vnhu5sHZK8KwZw84wE/zzX7Y4SO573olw7oRBbogzQu6UFQHKDyhNfC+AcZZHgImk50uf1vOqlVrsyG1dfc/BG+7ECX7hOtXPO0oiVNPwUOXqdWeEvjuDTKs8C3ItjvSFfvfF4N+OYNcTEAi+pBzT2KgxP8I5q47kWh359z9cO7Dqho5CRzdGy0PJAEeuEQtaAomwGw1p+C8uJWvYaaT5IcUsru3i2+v/+fo3XDNIGH8X+FsAAAAASUVORK5CYII=",UAn="/assets/vscode-C5BXgFjm.svg",WAn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAACSFJREFUeAHtWG2MXFUZfs+Ze+/M7uwnLNhiqd1dWknaBETS+EO0JRWllRCjjSY2EhP/GP2BMSZG40fU4A/RRIs/FA1iJNaQaAKCiiG1dGu7okVKCK6lFWrb3a3b/ZiZnY/7ca7v855zZ2d3Z5chJIQfPcnZO3vuvec87/N+X6Ir48p4aw/V6TP79+/XpVKpv2twsC+uVHzj+4oaRMbUlDG+Mr5R+SCQFxphSL38O451SrwULUap1nGKe55XNPl8V3jq1PjcxMREmZc0z9TN9UGsc09974EH7v7oRz7+8ziOBiuVCimspnx+Pk9a56hULpHHV8/zyGdwURQxeEM9vT2U8lUxjlq9xr9TynmacjmPYn4mKOT5nqLJixfGv/qlL9w5NjZW4p0Tep1ABc4Lp185UyktbDGGCdFMYCMk3/cYVMAHatI8G/UGU8EgGGwQ+MxiwjOiYpGBpgYyUbVWlfuel+P3cpQw6LBRpyiOIZR5x+br9Zmzr3xuz23v+SmfG7cDpNcASv959fy/5i7PbE6M0dg8x4wVi0W5BnlfDtRMryfAPVJaZfLJ+5kecfX5vhymPdGCh/2YWdzM5/N6cmqarhq86uBDj/zmDn4s1w6P1w78gw8/ctdseXFrsdirw7Aum3qek4nl1UqTYbYUA8XBJjECCSqXTT2fIacCMmHWUqcjrUlYxj+JSRhkwLPAvw3V6zV95969T9AaWm6HPv3Bjw7+tV6rd+dyAKIdG+59BgkI1lRTmQJQkVyzNc0swi4zWmHbEAwzSawpejloRvF7iQi8MD9vRrZuPf/0U3/650pQbdFPzy6k5y9cdCDtIyY17tCMuUzN9iC24+YVQgVBQbQQcgTI1qAZAIbdglnYumag9VrNaobfZ0Ge23nzjltWYlql+l27dg1VGw2xOwvIsiJAmAnYYsKqNknMv7UwFEexPAdHkk3ZbuMYaxYogOFZD4yLaEqAJwmcSYndY++Ao8bQNVcPU5uxCmgvjzjkDYS5VNSMMAM7SqyXyqGwS8X3ARzPJHEijHR3F+m+b32denp6RAjTVLsW54NZ9Pb10Wc/fy+VywscRXwLhMFqZjyndb4joIVCIYfNEOtgj1Aw2MmAivbBDE+Yhkq1qBFCxQz+8swMPTt+QoBmppPZJoTCFV7/2G8fpSeePkqVcllCnhU+5hAY6Y6AVuMYLisGn6YOmAMHlhEfhVXccF6vhTlDU5MX6cTxMWa1u+lkSmVhC94m1FLM9/r6B+jFF07R9Zs385pPEZuInKW06ggo25Gq1+tyEBjKvLvY00df+/IXaeyZI8JIkyU3GxzA//zMOB09fNiBW2ss3bPgVOaTrDn2CdP+La/9Vto5Rioqj5nd3/3iZ/TcP/4uQX8lSMwbt2+neqNG/554SewUNkltnlsWptLE2neSiHnBXo2JOwMaaw2LE6+MokTsD1569MhhYXat8d7b3k8zl/5nYw85QLT+QOKASSHl4mmchUTQ9tm2i2zY2oWeLIjDFjGEjRYHwQG1apXedetOOvX8Seou9pDqpCYjK4jk+9TGWQlja2T1VasMTCEuQvXKBekskyw7IfupbDLYMjxCY0f+so59LhdO0qjzAZBi3F7pGka6CqjmGtIG4kRSIDZG+ZY6la46nu9ve+eN9PbrrmMvft7l9fa22SqczVBZik0FCLQXhXFnQMEoJM3KNclOqbXZ5YctgfjQ3g/TpelpKQMzvjoZYl5uGpdUdPvotLaNKmczArhF9RaczoigxcUK3f6BD9Lfxo9zbOxfJkDrO00pW9YTF48lRhtb6GQV2GsC9TiQIlRkhYMEthWNQnYWpEcuR9B+6g9PSo3aOloBq+z/lnUU0onL/+RsV3XKKG+QIqCjSDCpZQ32SsscYemwYXYiONz48WPrhi9qZZUsCYibSrmAn1o2tOrQ6+NcLuWSXqT1clpYUlltRrQq9OzecwddujTNJrBIayCkpnBNzIqq/PyW0RtsLHUg8bdZTq4YqwK+jqLUuIKD5MW0WQAvy9s8uCqn9+2+nS789xx98lP3UBbos5grlRe/b9sWG5ex0+DgIH3iwD2cxSY4i3VZ+3TnJUmHQLkUlU7SplAuIDhUjYyO0jDPi1x0SGdpKxIO9DXavuMmmp2doQOf/gwVuK0AIyFvslSUaGkEUcah7kQ9Bo2hWN62bZtoDt3t5NSUCIPQ2BFQ3tDYQxLRNvofjPt/+GPasXWLjXmuXCt0FWj76KamrWHedPMt9MtDj8rhNS5uuL60DSHHYszWwhnaiji5oDbo7xugcqXEewVpR0C7unQD9aF2DoUaNAwb4t0nX5ygsy+/LEzhPsxDCl6Ubq6wQB1aZaYD1+NDaJ9bDk86Udu+4FkT8R7KFswoc4eGruZrCEGSjoBOT08voDMsl0q0YcNG6ufYGEWhgJifm2MWu+S3AOErF9oysbYwvyCRYrG6SF2FLnQLYkJQL0BCYHxFESvXupk+OdAw+JSrrwblqtX5joAeO3asHHAbC7uUbAHpXTOXZ0BwFKgVRo9POAUGBKBSv7psxuqTjxMAn5lOxOvQjm1nbH+Slw8WRlgtl8oI2emrZ8+cbAe0bdCanpx6lu1I3E/6d20/D8G2wM7AQL/05AAC9aI0AzCw38f9EGzO93wBxN+raH5hXp7DCIJ8M/uE8vknkW4VLUlQCNInH3v8G+0wtUsDat++fQP3H/zJbIHB2BaYPZmNXhKBtLS2T5pnVYNBsIb2o7vYLQ4C/Ye8HnLuD3xrm9K9smBQPT7v4GQ4oe+aOnauuKfgz2689pq3tQPa9vPJ6dOno9179py/YXRkXxjGCpIvsrozBvGNCQP/25kIq7776JDZIjwbawCknU3CQbNat1mUsAMNb9roDfSyJy593Xtt1fNIPnbX3od+fejQ3Zs2XisMYNMqO0mZAc/MXBa7AosDA4O2PeGXoGb0Wwg5AXt6pn5bENvjss5UshB/LSsW8umGof65+77zbZAG+k2nql8piHnw4V8d2Hnru+/1C8URPqILVepAX48EcrsL2hYjwVo78/BYnYG/lKFg37V6yETqlL08btQalXMXzp34/eN//Mr3v/vNlxwWQ29wdFpivtX2vjKujDdt/B9Vn+PpjUxyeAAAAABJRU5ErkJggg==",ZAn="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTYgMjU2Ij4KICA8ZGVmcz4KICAgIDxsaW5lYXJHcmFkaWVudCBpZD0iYSIgeDE9IjAiIHkxPSIwIiB4Mj0iMjU2IiB5Mj0iMjU2IiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+CiAgICAgIDxzdG9wIG9mZnNldD0iMCIgc3RvcC1jb2xvcj0iIzA3QzNGMiIvPgogICAgICA8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiMwODdDRkEiLz4KICAgIDwvbGluZWFyR3JhZGllbnQ+CiAgPC9kZWZzPgogIDxyZWN0IHdpZHRoPSIyNTYiIGhlaWdodD0iMjU2IiByeD0iNDgiIGZpbGw9InVybCgjYSkiLz4KICA8cmVjdCB4PSI0OCIgeT0iNDgiIHdpZHRoPSIxNjAiIGhlaWdodD0iMTYwIiByeD0iNCIgZmlsbD0iIzAwMCIvPgogIDx0ZXh0IHg9IjYwIiB5PSIxNzgiIGZpbGw9IiNmZmYiIGZvbnQtZmFtaWx5PSJBcmlhbCxIZWx2ZXRpY2Esc2Fucy1zZXJpZiIgZm9udC13ZWlnaHQ9ImJvbGQiIGZvbnQtc2l6ZT0iNTYiPldTPC90ZXh0Pgo8L3N2Zz4K",GAn="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20256%20256'%3e%3cdefs%3e%3clinearGradient%20id='a'%20x1='0'%20y1='0'%20x2='256'%20y2='256'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%230ACF83'/%3e%3cstop%20offset='1'%20stop-color='%2305A2C2'/%3e%3c/linearGradient%3e%3c/defs%3e%3crect%20width='256'%20height='256'%20rx='48'%20fill='url(%23a)'/%3e%3cpath%20d='M80%2080%20L176%20128%20L80%20176Z'%20fill='%23fff'/%3e%3c/svg%3e",YAn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAADQlJREFUeAHlWAtwXOV1/u5r3w/tQytpVyvLdoRlG+M4Ia4NxMZ2SELo4IRX6qEtbmEST6epoU3K0EIKZZpCmk7JNCRpaSkJEFJahhhSY9pJggfHJiHYxg2OJSzr4dV7tbvSah939z7y/XfltwyaSTLJTO7Mr6u797///f7vnPOdcy7wG35I+NUcyvbtO9Ldy5bdl2pftDHIY2JivDQ9XejPZDLPvfLK3l1vvnlgeCEL/WoAJpO+jcvfe7KnpyeqV6vw+QK44qoN6OpsR80wEAqF7ZaWNimXzT5+zz07b5/DYeOXAJDz7+d4S8LVk2eeLRbPXecN548n6UVElf1d4ebWW2o1/Y5auFXe8sF1UFUXNFWDbVtWKpWWPW73C3fd9emtfEjhMM974UUPGStXqi13/suj2nvf90nJ7Q3CsM48YV/kKduGVTVhTZdhFSZgl4uw9QoqhmV1PvOAjGoRy7uXw+P2QFEUqJoGRZbNLZs/otxy87XSPIzMeyixr/5wm/+qtU/WTxbtbBnS+6IKVjSpCKu8Kc/h4x/5vBVsy4ZRraA6nYPOUSvNoF4pQy+XoLu86P+ne+EO+hCLxWnqJprfB5fbjRXd3VY+Vxx7+OH7UmeTNB9AKfHo/j/Qlq/+93y2qj59ZQAjVQuPHNMxxnPdmkN2GhAB81LRQLPJ3LGNerUGvVIhc1XIdo3nMt0gT1azWPyTXZg8/Ar8/gBCTU0E2ox4cwInB/pw7bXXGZcsW6Nqqic7NTWhvfTSCxvnBZg+WLdyPTMYuiGC5mdzaAsrOI1rzp2rZOryqOpcZioWsjqB2Y17btkm0zY6vIRrWTiYrUKtzMDKjsB36GWUX34Cer1GE6vweLwo5KeguHwwayV8/IZtWL58pbNuMBidUs5HF//yvqclO7TysfUB6fIXC2gLqsKtnBeLh2ZrNtbHVFSIpnfGQoHAygbg4k3igir8gzMrpoRsTcJARUaz14VVUS+OFy0sG/wREl4NsiyjpuvoTKfxmZ33ohRKIZcrojg1gtdeexWlyiw6O7r/RD4foPvS1TdMztrySNlGUoAjU+CQOSSONU0K9o3XUSLQmCqhTJu7uYONzSqSHmCxT8b7OcfHuZWahYjc2NT+KWBpsgWr5CKSqTRWrLwMiZAPxpW34kAuj71yC5If345MScVoZhgfeP8Hcffdd3xDPR+g7Ap41kYMfO2njEJr7jcOP8EI/zteMOGTJAfgUr59kVdFhPQdmjRw6xIPWTUQ5vXaiBu7RwyaGziUM+AjvRNHDsH2h2DPFKFKFqTNd+CEbmHYDmBJQsbxumx95vprdv2scv0n2hLxnfMFidr+PaN+jauCZ/t0hNwSiMUZLr6IhDiggwTgI+ChkoUNZO4HI3W0hxRcGlGwoUXFnuE6JBLv5Zz/5b0Ov4wyI3XzM3+GbKWGUDiIob5+7F9+PbyhCKpqCFvaXTgwZSP71x/yptPp6MmTJ7PEUzvfxDLoT01c2BQeTzBlHUh5ZOg1XvJeG//XeKtQFqYFvp+p4aG1fswwwj+cdOGJXh390xa2LSGDx3XQ6sjOGhjf/ypa0x3UPRXmTBaDq7dCCcSoZx0wo51ILVoCpXmxE6QENyLAnbLeWUenLGRDElFhNsaKEKmniYQfkggUGLH5is2U1fDNADfzyMEy4nz65UEdFb3hr48eLiPokZxN6p4Atmeew/HMCNKpJPqydWQQRFcqBTmUgOShHgYjUCKtXKX9PMbOOQwJ4sUiank2yOLoLJliVFZr4sUMIhHQvGcbOD3GZ0x84YoAfjxmcBMSnt4UxBs0rWBcqhuwv/8s2rtXMXu4MD06gCNd1yEQiCCrRGDKPm5CobNxaC5cEBMX/GKeGrZjzpmy5TAlzNzulZGl39m8J4bYhGBrXauG+/bPIkmfDVK41n0jh23dXmdDJVcUOz1H0NPXh0XpFH5ysop4tAmSL4YyfEj5XA1riYCcJ31eCJC7FpPteoMdsSdqKupk81jWgGKdtQn+P5U3cdN7PMhzI29Rfja0aVjGQLmE4p4t2GjZ80VEl65CiOltYqAXb3d9DKYWhMWhKS6YXMeqNdzl3DLhnQDaDQZn6G/CnF5eRjWKL68dF5gbCud89nf8+Ku9RYQ1GVsZGAMELPz08Tdn8beXjcH942fw1Leeou+14wfMTqoviFk5Ah/9EpaMIufKpxg0FgqQOxHmqdUa5mWadSLX8RBrLoB4ztH3Juij3RTmYxOG85IJ6mShYMHyhfHYHTfDHWmGz+vB8//1DDLt66G6QkJr4RXJ25KoDpYjSQ2/XyhAkTXMhqyIa+FnGTIjWWc2oDNaH7sujN09VQzmTHxpUwDfOVzBvsEa/uFDAczu/jcEYjG4KCsqy6rx8Ukg0eVErKwwMGzFsYJVb7iKY94FATQbAIVpMRcIAuxs9Yx5JY5Omvwrr5VoWsmRnyf2l+BnceBRJNz7mozwvkecotTl0lCrljDZvhmqzWpHDVAT5lLo3Fqn/H7hDM7JjAAmAkWItl5tyI4Ys9MmPrU+gCpFfJzM7qQfHuW5Tmc3LBXub30KnlgbNIJTWTwODw5BX7oJJjOGSemuMT9YdaEEcPK7XbcuGiTqhQAb/mXXbEfTciUT928Ks6KxnVQndqQpQhct7PgApYR8TM2aeOiaIMr8zTIKePxfD0KLNzvmrdcqGAlfjgeviaDgbUFHawzThoIwJelzu2cQZXGRn8taCwDIIs5qTBbMUfpwyyov7mbZFaEdxS2RQVqZd6eohzEuXuLiIj9HfARqemF+/ZOIhaME12Cvvz8D39W3Y6Dkx3eOMbNoZQQ8CsYYYDdf5sUPB2qOpJ1657sAHDgdBNJctB7qr7GWU9HPKqVIk5oEWCrZTuWcL8xRSnYnczY8hYNodRnMt25omkJ3qCLr7YZf8eDJIyr+cVscO/+7jLxaR5qif3So5tSQkmWfUYd3MbFtn+WD45SMCBfyM+BWxDUEGQQJn0KtM5AnyC3L3TiUqTcaG38EJx74MJSmuGNa0RANDQ5g9e/ei/+fCSAaDOLr+6q4cY0Ho2RvjH48Rokq6tZZQXIhwIvoYMOBBfoIE/4Qgb4+oOPGy3zYdaSCo6N13H6FH1/9vyIOk4VDlJY3v/0wXMyvmqpwqDBqVUzIHTg85sZ9W9OsflyUIwubuzz40du6I1txbl6eI8NhcKEyY5qnqhmgl0l/aUTFapr5/l0FtDPZRhg8//w/08wGUmO+EkC490n2uwTnsCdjfGSUtN8IF7vVv3/JxKUtHqe5+otn89jAjLOE6/WM1hqBQRcxF6iDFthLTLPc12zJKQiErvWNG/jjTSHk2FP0ksk7P8KqmBVsuSq274Jnz6eh+GNOreewV9cxYcaheKKoS2G0JfzYtj6ICvO1iN7tV/pxYqzOIJQcIhiamGbQNXwwY50N6IKuLvU3dTuFSQfMrJAbAYEgNe7wxvV+luYq/vSbOQToj6vTGkanZqB9lynNH4bX64ab2jeaGcRgxw50LOlCrLUTb016UWbn+cJnW3CCrcEXny+I1g9Vo4ElSqBR1p0DdgLDD6jSO5rY0kvlg6yK7/pYqJEjTTgCrNMMX6JuffPVWQTIgijne6d8qO66jUwFHNOqp9irBhGJt2FkNoDjWRVeRrSP/vbQi9O4k5urM+iqIjjmeuodHw3hQI9O7Z2tv5uJoR/fuzseVa0kvyKMn6g19EkEGv0jxV0eYUCs7XQjxFxv9O9F0G05ZhX+p5CJyYlxmO+5CbrhIaMhAlHZ28hYt9iF19kCtIVlZibHmZxMNXpCRwd7mURUtmr9r3/vfDwXNu6RJeHUjqOF3NsjyPzHIsR+bwBtnS6KsX3OQ1U1jtY9l8NFefF4XM6wTAO9/ePQ13weibYU0skkK2YPDnNTXpd0Tj0q3G98oI7J/+xE+o8GEelqxvBXknF+iJo6G86FqS5/olg5/O3PNS297uH0Hw7Kz32+FcPsSb5G8wxRGgSTIu0l8l+G7A07zIkhGvHsxATyiRuglBUMDlFW6G+SVnWWrc6h41S0UhXuuj6E9piG9tsGEW4LmpW39jxIcPl3Z7BxKJGPPvGXvlU3fcHIT1mTk6a87hI3lpHJMFOe1+/B03++Bk3Mt6LPEEOwd6znbVx9+6MINCUQiiVZLHhPe5EIN9GLFRitR5ne3uitIpZQLTXULFeOPv9g7qVbH8A82fidPr8JdmOxrS8+5e64cqOkBjWRZkRa0oa/C/XI31k+v08OBPxO5hgbyZiF1G2KEb+C2YQtpCdEbPK5fcapt7FBglnV9cG9r1YP3PP7pYmfCrMa84FYyAdMFY3X8Ntb2EdnVDyyHFrU3tU32PczKxJtluPxGIplEwPHJ/wIzPgvupJEXeC3QExPV9Doe+WLAftFD6Wpqanzqi2fGI4n2u1IPGmnFi+7GfNlpl/zoXq93lQwmBR9u4rfxuPnTjEKD0h39egAAAAASUVORK5CYII=",XAn="data:image/svg+xml,%3csvg%20width='40'%20height='40'%20viewBox='0%200%2040%2040'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_5437_79109)'%3e%3cmask%20id='mask0_5437_79109'%20style='mask-type:luminance'%20maskUnits='userSpaceOnUse'%20x='5'%20y='5'%20width='30'%20height='30'%3e%3cpath%20d='M5.6001%205.59961H34.4001V34.3996H5.6001V5.59961Z'%20fill='white'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_5437_79109)'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M8.3001%207.39961C8.0614%207.39961%207.83248%207.49443%207.6637%207.66321C7.49492%207.832%207.4001%208.06091%207.4001%208.29961V28.0996H5.6001V8.29961C5.6001%207.58352%205.88456%206.89677%206.39091%206.39042C6.89726%205.88407%207.58401%205.59961%208.3001%205.59961H32.4138C33.6165%205.59961%2034.2186%207.05371%2033.3684%207.90421L18.5166%2022.7557H22.7001V20.8996H24.5001V23.206C24.5001%2023.5641%2024.3579%2023.9074%2024.1047%2024.1606C23.8515%2024.4138%2023.5081%2024.556%2023.1501%2024.556H16.7166L13.623%2027.6496H27.6501V16.3996H29.4501V27.6496C29.4501%2028.127%2029.2605%2028.5848%2028.9229%2028.9224C28.5853%2029.26%2028.1275%2029.4496%2027.6501%2029.4496H11.823L8.673%2032.5996H31.7001C31.9388%2032.5996%2032.1677%2032.5048%2032.3365%2032.336C32.5053%2032.1672%2032.6001%2031.9383%2032.6001%2031.6996V11.8996H34.4001V31.6996C34.4001%2032.4157%2034.1156%2033.1024%2033.6093%2033.6088C33.1029%2034.1151%2032.4162%2034.3996%2031.7001%2034.3996H7.5864C6.3837%2034.3996%205.7816%2032.9455%206.6318%2032.095L21.4272%2017.2996H17.3001V19.0996H15.5001V16.8496C15.5001%2016.4916%2015.6423%2016.1482%2015.8955%2015.895C16.1487%2015.6418%2016.4921%2015.4996%2016.8501%2015.4996H23.2272L26.3772%2012.3496H12.3501V23.5996H10.5501V12.3496C10.5501%2011.8722%2010.7397%2011.4144%2011.0773%2011.0768C11.4149%2010.7393%2011.8727%2010.5496%2012.3501%2010.5496H28.1772L31.3272%207.39961H8.3001Z'%20fill='black'/%3e%3c/g%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_5437_79109'%3e%3crect%20width='28.8'%20height='28.8'%20fill='white'%20transform='translate(5.6001%205.59961)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",KAn="data:image/svg+xml,%3csvg%20width='40'%20height='40'%20viewBox='0%200%2040%2040'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_5437_79100)'%3e%3cmask%20id='mask0_5437_79100'%20style='mask-type:luminance'%20maskUnits='userSpaceOnUse'%20x='5'%20y='5'%20width='30'%20height='30'%3e%3cpath%20d='M5.6001%205.59961H34.4001V34.3996H5.6001V5.59961Z'%20fill='white'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_5437_79100)'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M8.3001%207.39961C8.0614%207.39961%207.83248%207.49443%207.6637%207.66321C7.49492%207.832%207.4001%208.06091%207.4001%208.29961V28.0996H5.6001V8.29961C5.6001%207.58352%205.88456%206.89677%206.39091%206.39042C6.89726%205.88407%207.58401%205.59961%208.3001%205.59961H32.4138C33.6165%205.59961%2034.2186%207.05371%2033.3684%207.90421L18.5166%2022.7557H22.7001V20.8996H24.5001V23.206C24.5001%2023.5641%2024.3579%2023.9074%2024.1047%2024.1606C23.8515%2024.4138%2023.5081%2024.556%2023.1501%2024.556H16.7166L13.623%2027.6496H27.6501V16.3996H29.4501V27.6496C29.4501%2028.127%2029.2605%2028.5848%2028.9229%2028.9224C28.5853%2029.26%2028.1275%2029.4496%2027.6501%2029.4496H11.823L8.673%2032.5996H31.7001C31.9388%2032.5996%2032.1677%2032.5048%2032.3365%2032.336C32.5053%2032.1672%2032.6001%2031.9383%2032.6001%2031.6996V11.8996H34.4001V31.6996C34.4001%2032.4157%2034.1156%2033.1024%2033.6093%2033.6088C33.1029%2034.1151%2032.4162%2034.3996%2031.7001%2034.3996H7.5864C6.3837%2034.3996%205.7816%2032.9455%206.6318%2032.095L21.4272%2017.2996H17.3001V19.0996H15.5001V16.8496C15.5001%2016.4916%2015.6423%2016.1482%2015.8955%2015.895C16.1487%2015.6418%2016.4921%2015.4996%2016.8501%2015.4996H23.2272L26.3772%2012.3496H12.3501V23.5996H10.5501V12.3496C10.5501%2011.8722%2010.7397%2011.4144%2011.0773%2011.0768C11.4149%2010.7393%2011.8727%2010.5496%2012.3501%2010.5496H28.1772L31.3272%207.39961H8.3001Z'%20fill='white'/%3e%3c/g%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_5437_79100'%3e%3crect%20width='28.8'%20height='28.8'%20fill='white'%20transform='translate(5.6001%205.59961)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",r4e={vscode:UAn,cursor:IAn,zed:XAn,"zed-dark":KAn,finder:DAn,terminal:VAn,iterm2:BAn,ghostty:zAn,warp:WAn,xcode:YAn,"android-studio":RAn,antigravity:LAn,textmate:QAn,"sublime-text":qAn,intellij:$An,webstorm:ZAn,rustrover:FAn,windsurf:GAn,kiro:HAn};function o4e(){return document.documentElement.classList.contains("dark")}function i4e({id:t,className:e}){const[n,r]=v.useState(o4e);v.useEffect(()=>{const i=new MutationObserver(()=>r(o4e()));return i.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>i.disconnect()},[]);let o=r4e[t];return t==="zed"&&n&&(o=r4e["zed-dark"]),o?f.jsx("img",{src:o,alt:"",draggable:!1,className:e??"size-5"}):null}const s4e=[{id:"vscode",label:"VS Code",icon:"vscode",openWith:"Visual Studio Code"},{id:"cursor",label:"Cursor",icon:"cursor",openWith:"Cursor"},{id:"zed",label:"Zed",icon:"zed",openWith:"Zed"},{id:"windsurf",label:"Windsurf",icon:"windsurf",openWith:"Windsurf"},{id:"kiro",label:"Kiro",icon:"kiro",openWith:"Kiro"},{id:"xcode",label:"Xcode",icon:"xcode",openWith:"Xcode"},{id:"antigravity",label:"Antigravity",icon:"antigravity",openWith:"Antigravity"},{id:"textmate",label:"TextMate",icon:"textmate",openWith:"TextMate"},{id:"sublime-text",label:"Sublime Text",icon:"sublime-text",openWith:"Sublime Text"},{id:"intellij",label:"IntelliJ IDEA",icon:"intellij",openWith:"IntelliJ IDEA"},{id:"webstorm",label:"WebStorm",icon:"webstorm",openWith:"WebStorm"},{id:"rustrover",label:"RustRover",icon:"rustrover",openWith:"RustRover"},{id:"iterm2",label:"iTerm2",icon:"iterm2",openWith:"iTerm"},{id:"terminal",label:"Terminal",icon:"terminal",openWith:"Terminal"},{id:"ghostty",label:"Ghostty",icon:"ghostty",openWith:"Ghostty"},{id:"warp",label:"Warp",icon:"warp",openWith:"Warp"},{id:"android-studio",label:"Android Studio",icon:"android-studio",openWith:"Android Studio"}];function JAn({worktreePath:t,onCopyPath:e}){const{settings:n}=Qh(),r=HBe(),[o,i]=v.useState({finder:!0});v.useEffect(()=>{if(!On)return;let h=!1;return Promise.all(s4e.map(p=>Ho("check_app_exists",{appName:p.openWith}).then(g=>[p.id,g]).catch(()=>[p.id,!1]))).then(p=>{if(h)return;const g={finder:!0};for(const[_,x]of p)g[_]=x;i(g)}),()=>{h=!0}},[]);const s=v.useMemo(()=>{const h={id:"finder",label:"Finder",icon:"finder",openWith:"Finder"},p=s4e.filter(g=>o[g.id]);return[h,...p]},[o]),a=n.defaultOpenApp,l=v.useMemo(()=>s.find(h=>h.id===a)??s[0],[s,a]),c=v.useCallback(h=>{r.mutate({...n,defaultOpenApp:h})},[n,r]),u=v.useCallback(async h=>{if(On){if(h.id==="finder"){Ho("reveal_in_finder",{path:t}).catch(()=>{});return}Ho("open_with_app",{path:t,appName:h.openWith}).catch(()=>{})}},[t]),d=v.useCallback(()=>{u(l)},[l,u]);return f.jsxs("div",{className:"flex items-center rounded-md overflow-hidden border border-border/40",children:[f.jsx("button",{type:"button",onClick:d,onMouseDown:h=>h.stopPropagation(),className:"flex items-center justify-center px-1 py-0.5 hover:bg-accent/50 transition-colors",title:`Open in ${l.label}`,children:f.jsx(i4e,{id:l.icon,className:"size-5"})}),f.jsxs(Us,{children:[f.jsx(Ws,{asChild:!0,children:f.jsx("button",{type:"button",onMouseDown:h=>h.stopPropagation(),className:"flex items-center justify-center px-0.5 py-0.5 hover:bg-accent/50 transition-colors border-l border-border/40",children:f.jsx(Pi,{className:"size-3.5 text-muted-foreground"})})}),f.jsxs(Zs,{align:"end",className:"min-w-[180px]",children:[f.jsx(Zxe,{children:"Open in"}),s.map(h=>f.jsxs(dr,{onClick:()=>{c(h.id),u(h)},className:"gap-2",children:[f.jsx(i4e,{id:h.icon,className:"size-5 shrink-0"}),f.jsx("span",{className:"flex-1",children:h.label}),l.id===h.id&&f.jsx(Ji,{className:"size-3.5 text-muted-foreground"})]},h.id)),e&&f.jsxs(f.Fragment,{children:[f.jsx(A4,{}),f.jsxs(dr,{onClick:e,className:"gap-2",children:[f.jsx(z0,{className:"size-4 shrink-0 ml-0.5"}),f.jsx("span",{className:"flex-1",children:"Copy path"})]})]})]})]})]})}const hN={WebkitAppRegion:"drag"},ite={WebkitAppRegion:"no-drag"},AFe=v.createContext(!0);function eEn(){return v.useContext(AFe)}const EFe=v.createContext(null);function pN(){return v.useContext(EFe)}function ste({onToggle:t,visible:e}){return f.jsxs(Or,{children:[f.jsx(Sr,{asChild:!0,children:f.jsx("button",{type:"button","aria-label":"Toggle Explorer / Changes panel","aria-pressed":e,onClick:t,className:"flex items-center justify-center rounded-md p-1 text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",children:f.jsx(ait,{className:"size-5"})})}),f.jsxs(Cr,{side:"bottom",className:"text-xs",children:["Toggle Explorer / Changes"," ",f.jsx("kbd",{className:"ml-1.5 rounded border border-popover-foreground/25 bg-popover-foreground/10 px-1 py-0.5 font-mono text-[14px]",children:Vf("Cmd+Shift+E")})]})]})}function tEn({worktreePath:t,onCopyPath:e,onToggleRightPanel:n}){const r=On&&!!t;return!r&&!n?null:f.jsxs("div",{className:"flex shrink-0 items-center gap-1 self-center",style:ite,"data-testid":"right-sidepanel__header-actions",children:[r&&f.jsx(JAn,{worktreePath:t,onCopyPath:e}),n&&f.jsx(ste,{onToggle:n,visible:!0})]})}function nEn({onToggleSidebar:t,sidebarVisible:e,onGoBack:n,onGoForward:r,canGoBack:o,canGoForward:i}){return f.jsxs("div",{className:"flex items-center gap-0.5 pointer-events-auto",style:ite,children:[t&&f.jsxs(Or,{children:[f.jsx(Sr,{asChild:!0,children:f.jsx("button",{type:"button",onClick:t,"aria-label":"Toggle sidebar","aria-pressed":e??!1,"data-testid":"desktop-title-bar__sidebar-toggle",className:"flex items-center justify-center rounded p-1 text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",children:f.jsx(iit,{className:"size-5"})})}),f.jsxs(Cr,{side:"bottom",className:"text-xs",children:["Toggle Sidebar"," ",f.jsx("kbd",{className:"ml-1.5 rounded border border-popover-foreground/25 bg-popover-foreground/10 px-1 py-0.5 font-mono text-[14px]",children:Vf("Cmd+B")})]})]}),(n||r)&&f.jsxs(f.Fragment,{children:[f.jsxs(Or,{children:[f.jsx(Sr,{asChild:!0,children:f.jsx("button",{type:"button",onClick:n,disabled:!o,"aria-label":"Back","data-testid":"desktop-title-bar__back",className:"flex items-center justify-center rounded p-1 text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:text-muted-foreground",children:f.jsx(fM,{className:"size-5"})})}),f.jsxs(Cr,{side:"bottom",className:"text-xs",children:["Back"," ",f.jsx("kbd",{className:"ml-1.5 rounded border border-popover-foreground/25 bg-popover-foreground/10 px-1 py-0.5 font-mono text-[14px]",children:Vf("Cmd+Alt+←")})]})]}),f.jsxs(Or,{children:[f.jsx(Sr,{asChild:!0,children:f.jsx("button",{type:"button",onClick:r,disabled:!i,"aria-label":"Forward","data-testid":"desktop-title-bar__forward",className:"flex items-center justify-center rounded p-1 text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:text-muted-foreground",children:f.jsx(bo,{className:"size-5"})})}),f.jsxs(Cr,{side:"bottom",className:"text-xs",children:["Forward"," ",f.jsx("kbd",{className:"ml-1.5 rounded border border-popover-foreground/25 bg-popover-foreground/10 px-1 py-0.5 font-mono text-[14px]",children:Vf("Cmd+Alt+→")})]})]})]})]})}function rEn(){return f.jsx("div",{"data-testid":"desktop-title-bar__sidebar-surface",className:"h-[38px] shrink-0 flex items-center border-b border-border",style:hN})}function TFe(){const t=pN(),e=eEn();return!t||t.sidebarVisible?null:f.jsx("div",{"data-testid":"worktree-center__sidebar-gutter",className:"h-full shrink-0",style:{...e?hN:void 0,width:t.navOverlayWidth}})}function MFe({className:t=""}){const e=pN(),n=e?.onToggleRightPanel;return f.jsxs("div",{"data-testid":"worktree-center__drag-bar",className:`flex h-[38px] shrink-0 items-center border-b border-border bg-background pr-2 ${t}`,children:[f.jsx(TFe,{}),n&&!e.rightPanelVisible&&f.jsx("div",{className:"ml-auto flex shrink-0 items-center",children:f.jsx(ste,{onToggle:n,visible:!1})})]})}function oEn(){return f.jsx("div",{className:"h-[38px] shrink-0",style:hN})}const PFe=v.createContext(null),jFe=PFe.Provider;function Uh(){const t=v.useContext(PFe);if(!t)throw new Error("useClientPluginHost must be used inside ClientPluginHostProvider");return t}const mN=["conflicts","unstaged","staged","untracked","branch"],gN={conflicts:"Conflicts",unstaged:"Changes",staged:"Staged Changes",untracked:"Untracked Files",branch:"Committed on Branch"};function Xx(t,e={}){const{compareBranch:n}=GHe(t),r=Rn(),o=!!t&&(e.enabled??!0),i=See(e.refetchInterval??!1),s=It({queryKey:["worktreeChanges",t,n],queryFn:()=>Se.worktree.getChanges.query({worktreeId:t,compareBranch:n??void 0}),enabled:o});return v.useEffect(()=>{if(!o||!i)return;const a=["worktreeChanges",t,n],l=setInterval(()=>{const c=r.getQueryState(a);c?.fetchStatus!=="fetching"&&(c&&Date.now()-c.dataUpdatedAt<i*.8||r.refetchQueries({queryKey:a,exact:!0}))},i);return()=>clearInterval(l)},[r,o,i,t,n]),s}function NFe(t,e){return t.invalidateQueries({queryKey:["worktreeChanges",e]})}function RFe(t,e){if(!t)return null;for(const n of mN){const r=t[n].find(o=>o.path===e);if(r)return{section:n,entry:r}}return null}function LFe(t){if(!t)return 0;const e=new Set;for(const n of mN)for(const r of t[n])e.add(r.path);return e.size}function v8(t){const e=t.match(/^\/worktree\/([^/]+)/);return e?decodeURIComponent(e[1]):null}class IFe extends v.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e){console.error(`[plugin:${this.props.pluginId}] render failed:`,e)}render(){return this.state.error?f.jsxs("div",{className:"px-3 py-4 text-xs text-muted-foreground","data-testid":"plugin-slot__error","data-plugin-id":this.props.pluginId,children:["The ",this.props.pluginId," plugin failed to render: ",this.state.error.message]}):this.props.children}}const DFe={failure:{label:"Failed",icon:F7e,className:"text-danger"},running:{label:"In progress",icon:H2,className:"text-warning",spin:!0},pending:{label:"Queued",icon:_rt,className:"text-warning"},cancelled:{label:"Cancelled",icon:wrt,className:"text-muted-foreground"},success:{label:"Successful",icon:cb,className:"text-success"},neutral:{label:"Neutral",icon:ZH,className:"text-muted-foreground"},skipped:{label:"Skipped",icon:ZH,className:"text-muted-foreground"}};function iEn(t){return DFe[t].label}function zFe({state:t,className:e}){const{icon:n,className:r,spin:o}=DFe[t];return f.jsx(n,{"aria-hidden":!0,className:Ze("size-4 shrink-0",r,o&&"animate-spin",e)})}function sEn(t){const e={passing:0,failing:0,pending:0};for(const n of t)n.state==="success"||n.state==="neutral"?e.passing++:n.state==="failure"?e.failing++:ate(n)&&e.pending++;return e}const aEn={open:{label:"Open",className:"border-success/40 bg-success-bg text-success"},draft:{label:"Draft",className:"border-border bg-muted text-muted-foreground"},merged:{label:"Merged",className:"border-merged/40 bg-merged-bg text-merged"},closed:{label:"Closed",className:"border-danger/40 bg-danger-bg text-danger"}};function lEn({state:t}){const{label:e,className:n}=aEn[t];return f.jsx("span",{"data-testid":"pr-checks__state","data-review-state":t,className:Ze("inline-flex h-5 items-center rounded border px-1.5 text-[10px] font-semibold tracking-wide uppercase",n),children:e})}function $Fe(t){if(Number.isNaN(t))return null;const e=Math.max(0,Math.floor(t/1e3)),n=Math.floor(e/60);return n>0?`${n}m ${e%60}s`:`${e}s`}function cEn(t){return!t.startedAt||!t.completedAt?null:$Fe(Date.parse(t.completedAt)-Date.parse(t.startedAt))}function ate(t){return t.state==="running"||t.state==="pending"}function wU(t){return ate(t)&&!!t.startedAt&&!t.completedAt}function uEn(t,e){if(wU(t)){const n=$Fe(e-Date.parse(t.startedAt));return n&&`Running for ${n}`}return ate(t)&&!t.startedAt?"Queued":null}const BFe="band:pr-checks-sections";function a4e(){try{const t=JSON.parse(localStorage.getItem(BFe)??"{}");return t&&typeof t=="object"?t:{}}catch{return{}}}function HFe(t){const[e,n]=v.useState(()=>a4e()[t]!==!1),r=v.useCallback(o=>{n(o);try{localStorage.setItem(BFe,JSON.stringify({...a4e(),[t]:o}))}catch{}},[t]);return[e,r]}function dEn(t,e,n){const r=e?`pull request #${e.number} (${e.title})`:`branch ${t}`,o=n.map(i=>`- ${i.workflowName?`${i.workflowName} / ${i.name}`:i.name}${i.url?`: ${i.url}`:""}`);return[`These CI checks are failing on ${r}:`,...o,"","Read the failing job logs (for example with `gh run view <run-id> --log-failed`), fix the causes, run the relevant checks locally, and push the fix."].join(`
969
969
  `)}function fEn(t){const[e,n]=v.useState(()=>Date.now());return v.useEffect(()=>{if(!t)return;n(Date.now());const r=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(r)},[t]),e}const hEn=5e3;function VS(t){return!!t.rerun&&t.state!=="running"&&t.state!=="pending"}function l4e(t){return t instanceof Error?t.message:String(t)}function pEn({worktreeId:t,branch:e,review:n,checks:r,visible:o,refetch:i}){const s=Uh(),[a,l]=HFe("checks"),c=fEn(o&&a&&r.checks.some(wU)),[u,d]=v.useState("idle"),[h,p]=v.useState(null),[g,_]=v.useState(null),[x,y]=v.useState(new Set),[k,O]=v.useState(new Set),[C,A]=v.useState({}),[E,M]=v.useState(null);v.useEffect(()=>{if(k.size===0)return;const K=new Set(r.checks.filter(q=>k.has(q.id)&&VS(q)).map(q=>q.id));K.size!==k.size&&O(K)},[r,k]);const P=k.size>0;v.useEffect(()=>{if(!P||!o)return;const K=setInterval(i,hEn);return()=>clearInterval(K)},[P,o,i]);const L=s.rerunChecks,D=v.useCallback(async(K,q)=>{const Z=K.map(U=>U.id);y(U=>new Set([...U,...Z]));try{await L(t,q),O(U=>new Set([...U,...Z])),A(U=>Object.fromEntries(Object.entries(U).filter(([B])=>!Z.includes(B))))}finally{y(U=>new Set([...U].filter(B=>!Z.includes(B))))}},[L,t]),I=v.useCallback(async K=>{if(K.rerun)try{await D([K],[{runId:K.rerun.runId,jobId:K.rerun.jobId}])}catch(q){A(Z=>({...Z,[K.id]:l4e(q)}))}},[D]);if(r.checks.length===0)return f.jsx("p",{className:"px-3 py-4 text-xs text-muted-foreground","data-testid":"pr-checks__empty",children:n?"No checks reported for this pull request.":"No GitHub Actions jobs ran on this branch."});const z=sEn(r.checks),Y=r.checks.filter(K=>K.state==="failure"),Q=[...new Set(Y.flatMap(K=>K.rerun&&VS(K)?[K.rerun.runId]:[]))],H=Y.filter(K=>K.rerun&&VS(K)),N=async()=>{M(null);try{await D(H,Q.map(K=>({runId:K,failedOnly:!0})))}catch(K){M(l4e(K))}},V=H.some(K=>x.has(K.id)),G=async()=>{d("starting"),_(null);try{const K=await s.startAgent(t,dEn(e,n,Y));p(K.chatId??K.terminalId??null),d("started")}catch(K){d("idle"),_(K instanceof Error?K.message:String(K))}};return f.jsxs("div",{className:"flex flex-col",children:[Y.length>0&&f.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-3 py-2.5","data-testid":"pr-checks__failing-banner",children:[f.jsx(F7e,{className:"size-4 shrink-0 text-danger","aria-hidden":!0}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsxs("p",{className:"text-xs font-semibold","data-testid":"pr-checks__failing-count","data-count":Y.length,children:[Y.length," failing ",Y.length===1?"check":"checks"]}),f.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[E??g??(u==="started"?"An agent is fixing these checks":"Inspect details or start an AI fix pass."),!g&&u==="started"&&h&&f.jsxs(f.Fragment,{children:[" · ",f.jsx("button",{type:"button",onClick:()=>s.openPane(t,h),"data-testid":"pr-checks__open-agent",className:"underline hover:text-foreground",children:"Open"})]})]})]}),Q.length>0&&f.jsxs("button",{type:"button",onClick:()=>{N()},disabled:V,"data-testid":"pr-checks__rerun-failed",className:"inline-flex h-7 items-center gap-1 rounded-md border border-border px-2 text-xs font-medium hover:bg-accent disabled:opacity-50",children:[V?f.jsx(H2,{className:"size-3.5 animate-spin","aria-hidden":!0}):f.jsx(bM,{className:"size-3.5","aria-hidden":!0}),"Re-run failed"]}),f.jsxs("button",{type:"button",onClick:()=>{G()},disabled:u==="starting","data-testid":"pr-checks__fix",className:"inline-flex h-7 items-center gap-1 rounded-md border border-border px-2 text-xs font-medium hover:bg-accent disabled:opacity-50",children:[f.jsx(sve,{className:"size-3.5","aria-hidden":!0}),"Fix"]})]}),f.jsxs(su,{open:a,onOpenChange:l,children:[f.jsx(Ph,{asChild:!0,children:f.jsxs("button",{type:"button",className:"flex w-full flex-wrap items-center gap-x-3 gap-y-1 border-b border-border px-3 py-2 text-[11px] text-muted-foreground hover:bg-accent/50","data-testid":"pr-checks__summary","aria-expanded":a,children:[a?f.jsx(Pi,{className:"size-3.5"}):f.jsx(bo,{className:"size-3.5"}),f.jsx("span",{className:"font-semibold text-foreground",children:"Checks"}),z.passing>0&&f.jsx(Y$,{state:"success",count:z.passing,label:"passing"}),z.failing>0&&f.jsx(Y$,{state:"failure",count:z.failing,label:"failing"}),z.pending>0&&f.jsx(Y$,{state:"running",count:z.pending,label:"pending"})]})}),f.jsx(au,{children:f.jsx("ul",{"data-testid":"pr-checks__list",children:r.checks.map(K=>f.jsx(gEn,{check:k.has(K.id)?mEn(K):K,rerunning:x.has(K.id),rerunError:C[K.id]??null,onRerun:I,now:wU(K)?c:0},K.id))})})]})]})}function mEn(t){return{...t,state:"pending",startedAt:null,completedAt:null,description:null}}function Y$({state:t,count:e,label:n}){return f.jsxs("span",{className:"inline-flex items-center gap-1 whitespace-nowrap","data-testid":`pr-checks__summary-${n}`,"data-count":e,children:[f.jsx(zFe,{state:t,className:Ze("size-3.5",t==="running"&&"animate-none")}),e," ",n]})}const gEn=v.memo(function({check:e,now:n,rerunning:r,rerunError:o,onRerun:i}){const s=Uh(),[a,l]=v.useState(!1),c=cEn(e)??uEn(e,n);return f.jsx("li",{className:"border-b border-border/60","data-testid":"pr-checks__check","data-check-state":e.state,children:f.jsxs(su,{open:a,onOpenChange:l,children:[f.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 hover:bg-accent/50",children:[f.jsx(Ph,{asChild:!0,children:f.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-2 text-left","aria-expanded":a,"data-testid":"pr-checks__check-toggle",children:[a?f.jsx(Pi,{className:"size-3.5 shrink-0 text-muted-foreground"}):f.jsx(bo,{className:"size-3.5 shrink-0 text-muted-foreground"}),f.jsx(zFe,{state:e.state}),f.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px]","data-testid":"pr-checks__check-name",children:e.name}),f.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground","data-testid":"pr-checks__check-state",children:iEn(e.state)})]})}),(VS(e)||r)&&f.jsx("button",{type:"button","aria-label":`Re-run ${e.name}`,title:"Re-run job",disabled:r,onClick:()=>i(e),"data-testid":"pr-checks__check-rerun",className:"inline-flex size-5 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:bg-accent hover:text-foreground disabled:opacity-50",children:r?f.jsx(H2,{className:"size-3.5 animate-spin"}):f.jsx(bM,{className:"size-3.5"})}),e.url&&f.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer","aria-label":`Open ${e.name} on GitHub`,"data-testid":"pr-checks__check-link",onClick:u=>{u.preventDefault(),s.openUrl(e.url)},className:"inline-flex size-5 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:bg-accent hover:text-foreground",children:f.jsx(gM,{className:"size-3.5"})})]}),o&&f.jsx("p",{className:"px-3 pb-2 pl-[42px] text-[11px] text-danger",role:"alert","data-testid":"pr-checks__check-rerun-error",children:o}),f.jsx(au,{children:f.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 px-3 pb-2.5 pl-[42px] text-[11px]","data-testid":"pr-checks__check-details",children:[e.workflowName&&f.jsxs(f.Fragment,{children:[f.jsx("dt",{className:"text-muted-foreground",children:"Workflow"}),f.jsx("dd",{className:"min-w-0 truncate",children:e.workflowName})]}),e.description&&f.jsxs(f.Fragment,{children:[f.jsx("dt",{className:"text-muted-foreground",children:"Result"}),f.jsx("dd",{className:"min-w-0",children:e.description})]}),e.startedAt&&f.jsxs(f.Fragment,{children:[f.jsx("dt",{className:"text-muted-foreground",children:"Started"}),f.jsx("dd",{children:new Date(e.startedAt).toLocaleString()})]}),c&&f.jsxs(f.Fragment,{children:[f.jsx("dt",{className:"text-muted-foreground",children:"Duration"}),f.jsx("dd",{"data-testid":"pr-checks__check-duration",children:c})]})]})})]})})}),FFe=[{method:"squash",label:"Squash and merge"},{method:"merge",label:"Create a merge commit"},{method:"rebase",label:"Rebase and merge"}];function vEn(t){if(t.state==="merged")return{label:"Merged",canMerge:!1,hint:""};if(t.state==="closed")return{label:"Closed",canMerge:!1,hint:""};switch(t.mergeState){case"clean":case"has_hooks":return{label:"Squash and merge",canMerge:!0,hint:""};case"unstable":return{label:"Squash and merge",canMerge:!0,hint:"Some checks that are not required are failing."};case"blocked":return{label:"Blocked",canMerge:!1,hint:"Required reviews or checks are missing."};case"behind":return{label:"Behind base",canMerge:!1,hint:"The branch is out of date."};case"dirty":return{label:"Conflicts",canMerge:!1,hint:"The branch has merge conflicts."};case"draft":return{label:"Draft",canMerge:!1,hint:"Mark the PR ready for review first."};default:return{label:"Checking mergeability",canMerge:!1,hint:""}}}function bEn(t){return FFe.find(e=>e.method===t)?.label??t}const _En={approved:"approved",changes_requested:"requested changes",commented:"reviewed",pending:"reviewed",dismissed:"review dismissed"};function xEn(t,e=Date.now()){const n=new Date(t).getTime();if(Number.isNaN(n))return t;const r=Math.max(0,Math.round((e-n)/1e3));if(r<1)return"now";const o=[[60,"second",""],[60,"minute",""],[24,"hour",""],[30,"day","yesterday"],[12,"month","last month"],[Number.POSITIVE_INFINITY,"year","last year"]];let i=r;for(const[s,a,l]of o){if(i<s)return i===1&&l?l:`${i} ${a}${i===1?"":"s"} ago`;i=Math.floor(i/s)}return t}function qFe({id:t,title:e,summary:n,children:r}){const[o,i]=HFe(t);return f.jsxs(su,{open:o,onOpenChange:i,"data-testid":`pr-${t}`,children:[f.jsx(Ph,{asChild:!0,children:f.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 border-b border-border px-3 py-2 text-left text-[11px] text-muted-foreground hover:bg-accent/50","aria-expanded":o,"data-testid":`pr-${t}__header`,children:[o?f.jsx(Pi,{className:"size-3.5"}):f.jsx(bo,{className:"size-3.5"}),f.jsx("span",{className:"font-semibold text-foreground",children:e}),f.jsx("span",{"data-testid":`pr-${t}__summary`,children:n})]})}),f.jsx(au,{children:r})]})}const c4e={approved:"Approved",changes_requested:"Changes requested",commented:"Commented",pending:"Pending",dismissed:"Dismissed"},yEn={approved:"text-success",changes_requested:"text-danger",commented:"text-muted-foreground",pending:"text-warning",dismissed:"text-muted-foreground"},wEn={approved:f.jsx(Ji,{className:"size-3.5","aria-hidden":!0}),changes_requested:f.jsx(Yrt,{className:"size-3.5","aria-hidden":!0}),commented:f.jsx(Q_,{className:"size-3.5","aria-hidden":!0}),pending:f.jsx(hM,{className:"size-2.5 fill-current","aria-hidden":!0}),dismissed:f.jsx(ZH,{className:"size-3.5","aria-hidden":!0})};function VFe({login:t,url:e}){const[n,r]=v.useState(null);return e&&n!==e?f.jsx("img",{src:e,alt:"",loading:"lazy",referrerPolicy:"no-referrer",onError:()=>r(e),className:"size-5 shrink-0 rounded-full","data-testid":"pr-avatar__image"}):f.jsx("span",{"aria-hidden":!0,className:"inline-flex size-5 shrink-0 items-center justify-center rounded-full bg-muted text-[10px] uppercase","data-testid":"pr-avatar__fallback",children:t.slice(0,1)})}function kEn({reviewers:t}){const e=t.filter(n=>n.state==="approved").length;return f.jsx(qFe,{id:"reviewers",title:"Reviewers",summary:t.length===0?"none":`${e}/${t.length} approved`,children:t.length===0?f.jsx("p",{className:"px-3 py-3 text-xs text-muted-foreground","data-testid":"pr-reviewers__empty",children:"No reviewers requested yet."}):f.jsx("ul",{"data-testid":"pr-reviewers__list",children:t.map(n=>f.jsxs("li",{className:"flex items-center gap-2 border-b border-border/60 px-3 py-2","data-testid":"pr-reviewers__reviewer","data-reviewer-state":n.state,children:[f.jsx(VFe,{login:n.login,url:n.avatarUrl}),f.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px]",children:n.login}),n.required&&f.jsx("span",{role:"img","aria-label":"Required",title:"Required",className:"inline-flex shrink-0 text-muted-foreground","data-testid":"pr-reviewers__required",children:f.jsx(Gnt,{className:"size-3.5","aria-hidden":!0})}),f.jsx("span",{role:"img","aria-label":c4e[n.state],title:c4e[n.state],className:`inline-flex size-4 shrink-0 items-center justify-center ${yEn[n.state]}`,"data-testid":"pr-reviewers__state",children:wEn[n.state]})]},n.login))})})}function OEn({worktreeId:t,discussion:e}){const n=e.items.length+e.threads.length,r=e.threads.filter(s=>!s.isResolved).length,o=n===0?"none":`${n}${e.threads.length>0?`, ${r} unresolved`:""}`,i=[...e.items.map(s=>({key:s.id,at:s.createdAt,node:f.jsx(SEn,{item:s},s.id)})),...e.threads.map(s=>({key:s.id,at:s.comments[0].createdAt,node:f.jsx(CEn,{worktreeId:t,thread:s},s.id)}))].sort((s,a)=>s.at.localeCompare(a.at));return f.jsxs(qFe,{id:"comments",title:"Comments",summary:o,children:[i.length===0?f.jsx("p",{className:"px-3 py-3 text-xs text-muted-foreground","data-testid":"pr-comments__empty",children:"No comments yet."}):f.jsx("ul",{"data-testid":"pr-comments__list",children:i.map(s=>s.node)}),e.truncated&&f.jsx("p",{className:"px-3 py-2 text-[11px] text-muted-foreground","data-testid":"pr-comments__more",children:"Older comments are on GitHub."})]})}function SEn({item:t}){return f.jsxs("li",{className:"border-b border-border/60 px-3 py-2.5","data-testid":"pr-comments__item","data-kind":t.kind,children:[f.jsx(QFe,{comment:t,verb:t.kind==="review"&&t.reviewState?_En[t.reviewState]:null}),f.jsx(UFe,{comment:t})]})}function CEn({worktreeId:t,thread:e}){const n=Uh(),r=e.isResolved?"Resolved":e.isOutdated?"Outdated":null,[o,i]=v.useState(r===null),s=e.line?`${e.path}:${e.line}`:e.path;return f.jsx("li",{className:"border-b border-border/60","data-testid":"pr-comments__thread","data-resolved":e.isResolved,"data-outdated":e.isOutdated,children:f.jsxs(su,{open:o,onOpenChange:i,children:[f.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[f.jsx(Ph,{asChild:!0,children:f.jsx("button",{type:"button","aria-expanded":o,"aria-label":o?"Collapse thread":"Expand thread","data-testid":"pr-comments__thread-toggle",className:"inline-flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:o?f.jsx(Pi,{className:"size-3.5"}):f.jsx(bo,{className:"size-3.5"})})}),f.jsx("button",{type:"button",className:"min-w-0 flex-1 truncate text-left font-mono text-[11px] hover:underline",title:`Open ${s}`,onClick:()=>n.openFile(t,e.path,e.line),"data-testid":"pr-comments__thread-location",children:s}),r&&f.jsx("span",{className:"shrink-0 rounded-sm bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground","data-testid":"pr-comments__thread-label",children:r})]}),f.jsxs(au,{children:[f.jsx("ul",{className:"pb-1 pl-5","data-testid":"pr-comments__thread-messages",children:e.comments.map(a=>f.jsxs("li",{className:"px-3 py-1.5","data-testid":"pr-comments__message",children:[f.jsx(QFe,{comment:a,verb:null}),f.jsx(UFe,{comment:a})]},a.id))}),e.truncated&&f.jsx("p",{className:"px-8 pb-2 text-[11px] text-muted-foreground",children:"More replies on GitHub."})]})]})})}function QFe({comment:t,verb:e}){const n=Uh();return f.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[f.jsx(VFe,{login:t.author.login,url:t.author.avatarUrl}),f.jsx("span",{className:"min-w-0 truncate text-[12px] font-semibold",children:t.author.login}),e&&f.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:e}),f.jsx("time",{className:"shrink-0 text-[11px] text-muted-foreground",dateTime:t.createdAt,title:new Date(t.createdAt).toLocaleString(),children:xEn(t.createdAt)}),t.url&&f.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer","aria-label":"Open comment on GitHub","data-testid":"pr-comments__link",onClick:r=>{r.preventDefault(),n.openUrl(t.url)},className:"ml-auto inline-flex size-5 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:bg-accent hover:text-foreground",children:f.jsx(gM,{className:"size-3.5"})})]})}function UFe({comment:t}){const{Markdown:e}=Uh();return f.jsx("div",{className:"pl-7","data-testid":"pr-comments__body",children:f.jsx(e,{children:t.body})})}function AEn({worktreeId:t,review:e}){const n=Uh(),[r,o]=v.useState(null),[i,s]=v.useState(!1),[a,l]=v.useState(null),c=v.useRef(null),u=vEn(e),d=e.state==="merged",h=async g=>{s(!0),l(null);try{await n.mergeReview(t,g),o(null)}catch(_){l(_ instanceof Error?_.message:String(_))}finally{s(!1)}};v.useEffect(()=>{if(!r)return;c.current?.focus();const g=_=>{_.key==="Escape"&&!i&&o(null)};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[r,i]);const p=d?"bg-merged text-merged-foreground":u.canMerge?"bg-success text-success-foreground hover:bg-success/90":"bg-success/50 text-success-foreground/80";return f.jsxs("div",{className:"flex flex-col gap-1.5",children:[r?f.jsxs("div",{className:"flex h-8 items-center overflow-hidden rounded-md border border-border bg-accent","data-testid":"pr-checks__merge-confirm",children:[f.jsxs("span",{className:"min-w-0 flex-1 truncate whitespace-nowrap px-2.5 text-xs",children:[bEn(r)," #",e.number,"?"]}),f.jsx("button",{type:"button",className:"px-2 text-xs text-muted-foreground hover:text-foreground disabled:cursor-default",onClick:()=>o(null),disabled:i,"data-testid":"pr-checks__merge-cancel",children:"Cancel"}),f.jsx("button",{ref:c,type:"button",className:"h-full bg-success px-3.5 text-xs font-semibold text-success-foreground hover:bg-success/90 disabled:cursor-default",onClick:()=>{h(r)},disabled:i,"data-testid":"pr-checks__merge-confirm-button",children:i?"Merging…":"Confirm"})]}):f.jsxs("div",{className:"flex h-8 overflow-hidden rounded-md",title:u.hint||void 0,children:[f.jsxs("button",{type:"button",disabled:!u.canMerge||i,onClick:()=>o("squash"),"data-testid":"pr-checks__merge","data-merge-state":e.mergeState,className:Ze("flex flex-1 items-center justify-center gap-1.5 text-xs font-medium disabled:cursor-default",p),children:[f.jsx(Z7e,{className:"size-3.5","aria-hidden":!0}),u.label]}),f.jsxs(Us,{children:[f.jsx(Ws,{asChild:!0,children:f.jsx("button",{type:"button","aria-label":"Merge options","data-testid":"pr-checks__merge-menu",className:Ze("flex w-8 items-center justify-center border-l border-scrim",d?"bg-merged text-merged-foreground":"bg-success text-success-foreground hover:bg-success/90"),children:f.jsx(Pi,{className:"size-3.5"})})}),f.jsxs(Zs,{align:"end",children:[FFe.map(({method:g,label:_})=>f.jsx(dr,{disabled:!u.canMerge,onSelect:()=>o(g),"data-testid":`pr-checks__merge-method--${g}`,children:_},g)),f.jsx(A4,{}),f.jsx(dr,{onSelect:()=>n.openUrl(e.url),children:"Open on GitHub"})]})]})]}),u.hint&&!u.canMerge&&f.jsx("p",{className:"text-[11px] text-muted-foreground","data-testid":"pr-checks__merge-hint",children:u.hint}),a&&f.jsx("p",{className:"text-[11px] text-danger","data-testid":"pr-checks__merge-error",children:a})]})}const EEn=3e4,TEn=12e4;function MEn(t){return t?.status==="ok"&&(t.checks.state==="running"||t.checks.state==="pending")?EEn:TEn}function PEn({worktreeId:t,visible:e}){const r=Uh().useWorktreeReview(t,{enabled:e,refetchInterval:e?MEn:!1}),o=r.data;if(!o)return r.error?f.jsx(X$,{testid:"pr-checks__error",message:r.error.message,onRetry:r.refetch}):f.jsx("div",{className:"flex flex-1 items-center justify-center py-8","data-testid":"pr-checks__loading",children:f.jsx(H2,{className:"size-4 animate-spin text-muted-foreground","aria-hidden":!0})});if(o.status==="unavailable")return f.jsx(X$,{testid:"pr-checks__unavailable",message:o.message});if(o.status==="error")return f.jsx(X$,{testid:"pr-checks__error",message:o.message,onRetry:r.refetch});const i=f.jsx(REn,{label:"Refresh",testid:"pr-checks__refresh",onClick:r.refetch,icon:f.jsx($0,{className:Ze("size-3.5",r.isFetching&&"animate-spin")})});return f.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-auto","data-testid":"pr-checks",children:[o.review?f.jsx(jEn,{worktreeId:t,review:o.review,refresh:i}):f.jsx(NEn,{branch:o.branch,checks:o.checks,refresh:i}),o.review?.reviewers&&f.jsx(kEn,{reviewers:o.review.reviewers}),f.jsx(pEn,{worktreeId:t,branch:o.branch,review:o.review,checks:o.checks,visible:e,refetch:r.refetch}),o.review?.discussion&&f.jsx(OEn,{worktreeId:t,discussion:o.review.discussion})]})}function jEn({worktreeId:t,review:e,refresh:n}){const r=Uh();return f.jsxs("div",{className:"flex flex-col gap-2 border-b border-border px-3 py-3","data-testid":"pr-checks__header",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(mZ,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),f.jsxs("button",{type:"button",className:"text-sm font-semibold hover:underline",onClick:()=>r.openUrl(e.url),"data-testid":"pr-checks__number",children:["#",e.number]}),f.jsx(lEn,{state:e.state}),f.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[n,f.jsxs(Us,{children:[f.jsx(Ws,{asChild:!0,children:f.jsx("button",{type:"button","aria-label":"More actions","data-testid":"pr-checks__menu",className:"inline-flex size-6 items-center justify-center rounded-sm text-muted-foreground hover:bg-accent hover:text-foreground",children:f.jsx(hZ,{className:"size-3.5"})})}),f.jsxs(Zs,{align:"end",children:[f.jsx(dr,{onSelect:()=>r.openUrl(e.url),"data-testid":"pr-checks__menu-open",children:"Open on GitHub"}),f.jsx(dr,{onSelect:()=>{navigator.clipboard?.writeText(e.url)},"data-testid":"pr-checks__menu-copy",children:"Copy link"})]})]})]})]}),f.jsx("p",{className:"text-sm leading-snug","data-testid":"pr-checks__title",children:e.title}),f.jsxs("p",{className:"text-[11px] text-muted-foreground","data-testid":"pr-checks__updated",children:["PR updated ",new Date(e.updatedAt).toLocaleString()]}),f.jsx(AEn,{worktreeId:t,review:e})]})}function NEn({branch:t,checks:e,refresh:n}){return f.jsxs("div",{className:"flex flex-col gap-1.5 border-b border-border px-3 py-3","data-testid":"pr-checks__header",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(ub,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),f.jsx("span",{className:"min-w-0 truncate text-sm font-semibold","data-testid":"pr-checks__branch",children:t}),f.jsx("div",{className:"ml-auto flex items-center gap-0.5",children:n})]}),f.jsxs("p",{className:"text-[11px] text-muted-foreground","data-testid":"pr-checks__no-review",children:["No pull request for this branch.",e.headSha?` GitHub Actions jobs on ${e.headSha.slice(0,7)}.`:""]})]})}function REn({label:t,icon:e,onClick:n,testid:r}){return f.jsx("button",{type:"button","aria-label":t,title:t,onClick:n,"data-testid":r,className:"inline-flex size-6 items-center justify-center rounded-sm text-muted-foreground hover:bg-accent hover:text-foreground",children:e})}function X$({message:t,testid:e,onRetry:n}){return f.jsxs("div",{className:"flex flex-col items-center gap-2 px-6 py-8 text-center","data-testid":e,children:[f.jsx(mZ,{className:"size-6 text-muted-foreground/30","aria-hidden":!0}),f.jsx("p",{className:"text-xs text-muted-foreground",children:t}),n&&f.jsx("button",{type:"button",onClick:n,className:"rounded-md border border-border px-2 py-1 text-xs hover:bg-accent","data-testid":`${e}-retry`,children:"Try again"})]})}const LEn={id:"github",contributions:{"worktree.sideTabs":[{id:"pull-request",label:"Checks",icon:mZ,component:PEn}]}},IEn=[LEn];function WFe(){const t=It({queryKey:["plugins"],queryFn:()=>Se.plugins.list.query(),staleTime:Number.POSITIVE_INFINITY});return v.useMemo(()=>{if(!t.data)return[];const e=new Set(t.data.filter(n=>n.status!=="disabled").map(n=>n.id));return IEn.filter(n=>e.has(n.id)).flatMap(n=>(n.contributions["worktree.sideTabs"]??[]).map(r=>({key:`${n.id}.${r.id}`,slug:`${n.id}-${r.id}`,pluginId:n.id,tab:r})))},[t.data])}const ZFe="band:changes-collapsed-sections";function DEn(){try{const t=localStorage.getItem(ZFe),e=t?JSON.parse(t):[];if(Array.isArray(e))return new Set(e.filter(n=>mN.includes(n)))}catch{}return new Set}function zEn(t){try{Hn.setItem(ZFe,JSON.stringify([...t]))}catch{}}function GFe({worktreeId:t,changes:e,onOpen:n,onViewAll:r,editable:o=!1,activeFile:i,worktreePath:s}){const a=Rn(),[l,c]=v.useState(()=>DEn()),[u,d]=v.useState(null),[h,p]=v.useState(!1),[g,_]=v.useState(null),x=v.useCallback(M=>{c(P=>{const L=new Set(P);return L.has(M)?L.delete(M):L.add(M),zEn(L),L})},[]),y=v.useCallback(async(M,P)=>{_(null);try{await P()}catch(L){_(`${M} failed: ${L instanceof Error?L.message:String(L)}`)}finally{await NFe(a,t)}},[a,t]),k=v.useCallback(M=>y("Stage",()=>Se.worktree.stageFiles.mutate({worktreeId:t,paths:M.map(P=>P.path)})),[y,t]),O=v.useCallback(M=>y("Unstage",()=>Se.worktree.unstageFiles.mutate({worktreeId:t,paths:M.flatMap(P=>P.oldPath?[P.path,P.oldPath]:[P.path])})),[y,t]),C=v.useCallback(async()=>{if(!u)return;p(!0);const{section:M,entries:P}=u;await y("Discard",()=>Se.worktree.discardChanges.mutate({worktreeId:t,section:M,paths:P.flatMap(L=>M==="staged"&&L.oldPath?[L.path,L.oldPath]:[L.path])})),p(!1),d(null)},[u,y,t]),A=v.useMemo(()=>{const M=I=>({id:"discard",label:I==="untracked"?"Delete untracked file":"Discard changes",icon:I==="untracked"?Kl:Zit,destructive:!0,run:z=>d({section:I,entries:z})}),P={id:"stage",label:"Stage",icon:wl,run:k},L={id:"unstage",label:"Unstage",icon:Wot,run:O},D=[];return{conflicts:o?[{...P,label:"Mark as resolved"}]:D,unstaged:o?[M("unstaged"),P]:D,staged:o?[M("staged"),L]:D,untracked:o?[M("untracked"),P]:D,branch:D}},[o,k,O]),E=mN.filter(M=>(e?.[M].length??0)>0);return f.jsxs("div",{"data-testid":"changes-sections",children:[g&&f.jsx("p",{className:"px-3 py-1.5 text-[11px] break-words text-destructive","data-testid":"changes-sections__error",children:g}),e&&E.length===0&&f.jsx("p",{className:"px-3 py-2 text-xs text-muted-foreground","data-testid":"changes-sections__empty",children:"No changes"}),e&&e.branch.length===0&&e.branchStatus!=="ready"&&f.jsx("p",{className:"px-3 py-1.5 text-[11px] text-muted-foreground","data-testid":"changes-sections__branch-unavailable",children:qEn(e)}),e&&E.map(M=>{const P=e[M],L=l.has(M),D=A[M],I=D.map(z=>({id:`${z.id}-all`,label:HEn(M,z.id),icon:z.icon,run:()=>z.run(z.appliesTo?P.filter(z.appliesTo):P)}));return f.jsxs("section",{"data-testid":`changes-section--${M}`,children:[f.jsx($En,{section:M,count:P.length,countTitle:M==="branch"?`${P.length} file${P.length===1?"":"s"} changed vs ${e.compareBranch}`:void 0,collapsed:L,onToggle:()=>x(M),actions:I,onViewAll:r?()=>r(M):void 0}),!L&&f.jsx(FEt,{entries:P,actions:D,onSelectFile:z=>n(M,z,!1),onSelectFilePinned:z=>n(M,z,!0),worktreePath:s,activeFile:i})]},M)}),f.jsx(nr,{open:u!==null,onOpenChange:M=>{!M&&!h&&d(null)},children:f.jsxs(rr,{className:"sm:max-w-[425px]","data-testid":"changes-sections__discard-dialog",children:[f.jsxs(hr,{children:[f.jsx(or,{children:u?.section==="untracked"?"Delete files":"Discard changes"}),f.jsx(Nr,{children:u&&FEn(u)})]}),f.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-warning/30 bg-warning-bg p-3 text-sm",children:[f.jsx(Mc,{className:"mt-0.5 size-4 shrink-0 text-warning"}),f.jsx("span",{children:u&&YFe(u.section)})]}),f.jsxs(ii,{children:[f.jsx(Ce,{variant:"ghost",onClick:()=>d(null),disabled:h,children:"Cancel"}),f.jsx(Ce,{variant:"destructive",onClick:()=>{C()},disabled:h,"data-testid":"changes-sections__discard-confirm",children:u?.section==="untracked"?"Delete":"Discard"})]})]})})]})}function $En({section:t,count:e,countTitle:n,collapsed:r,onToggle:o,actions:i,onViewAll:s}){const a=r?bo:Pi;return f.jsxs("div",{className:"group flex h-7 items-center gap-1 pr-2 pl-1",children:[f.jsxs("button",{type:"button",onClick:o,"aria-expanded":!r,"data-testid":"changes-section__toggle",className:"flex h-full min-w-0 flex-1 items-center gap-1 text-left text-[11px] font-semibold tracking-wide text-muted-foreground uppercase",children:[f.jsx(a,{className:"size-3.5 shrink-0"}),f.jsx("span",{className:"truncate",children:gN[t]}),f.jsx("span",{className:"text-[10px] font-medium tabular-nums",title:n,"data-testid":"changes-section__count",children:e})]}),i.length>0&&f.jsx("div",{className:"hidden shrink-0 items-center gap-0.5 group-focus-within:flex group-hover:flex [@media(hover:none)]:flex",children:i.map(l=>f.jsx(BEn,{label:l.label,icon:l.icon,onClick:l.run,testid:`changes-section__action--${l.id}`},l.id))}),s&&f.jsx("button",{type:"button",onClick:s,"data-testid":"changes-section__view-all",className:"shrink-0 rounded-sm px-1 text-[11px] text-muted-foreground hover:bg-accent hover:text-foreground",children:"View all"})]})}function BEn({label:t,icon:e,onClick:n,testid:r}){return f.jsx("button",{type:"button","aria-label":t,title:t,onClick:n,"data-testid":r,className:"inline-flex size-5 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:bg-accent hover:text-foreground",children:f.jsx(e,{className:"size-3.5"})})}function HEn(t,e){switch(e){case"discard":return t==="untracked"?"Delete all untracked files":"Discard all";case"stage":return t==="conflicts"?"Mark all as resolved":"Stage all";case"unstage":return"Unstage all";default:return e}}function FEn({section:t,entries:e}){const n=e.length===1?e[0].path:`${e.length} files`;return t==="untracked"?`Delete ${n}?`:t==="staged"?`Discard the staged changes to ${n}?`:`Discard the changes to ${n}?`}function YFe(t){switch(t){case"untracked":return"Untracked files are deleted from disk. This cannot be undone.";case"staged":return"The files go back to their last committed version, including any unstaged edits. Files added in the index are deleted. This cannot be undone.";case"unstaged":return"Unstaged edits are thrown away; staged changes are kept. This cannot be undone."}}function qEn(t){switch(t.branchStatus){case"invalid-base":return`Can't compare with ${t.compareBranch}: the branch doesn't exist.`;case"no-merge-base":return`${t.headBranch} shares no history with ${t.compareBranch}.`;case"unborn-head":return"No commits on this branch yet.";default:return""}}let K9=0;const kU=new Set;function VEn(){return K9>0}function u4e(){K9++,typeof document<"u"&&document.documentElement.setAttribute("data-band-layout-resizing","")}function d4e(){if(K9!==0&&(K9--,!(K9>0))){typeof document<"u"&&document.documentElement.removeAttribute("data-band-layout-resizing");for(const t of[...kU])t()}}function QEn(t){return kU.add(t),()=>kU.delete(t)}const UEn=new Set(["ts","tsx","js","jsx","mjs","cjs","py","rb","go","rs","java","kt","swift","c","cpp","h","hpp","cs","php","r","lua","zig","mts","cts","ex","exs","erl","hs","scala","clj","dart","vue","svelte","html","htm","css","scss","less","sass","json","jsonc","json5","yaml","yml","toml","ini","xml","csv","graphql","gql","tf","hcl","env","proto","md","mdx","txt","rst","tex","log","sh","bash","zsh","fish","ps1","bat","cmd","png","jpg","jpeg","gif","svg","webp","ico","bmp","avif","sql","sqlite","db","editorconfig","prettierrc","eslintrc","lock","zip","tar","gz","tgz","wasm","diff","patch"]),WEn=new Set(["dockerfile","docker-compose.yml","docker-compose.yaml","makefile","rakefile","procfile","gemfile","vagrantfile",".gitignore",".gitattributes",".npmrc",".nvmrc",".prettierrc",".eslintrc",".editorconfig",".env",".env.local",".env.development",".env.production"]);function lte(t){const e=t.trim();if(!e||/^[a-z][a-z0-9+.-]*:\/\//i.test(e))return!1;const n=X5(e),r=n.filePath;if(!r)return!1;const o=r.split("/").pop()??r,i=o.toLowerCase(),s=o.lastIndexOf("."),a=s>=0?o.slice(s+1).toLowerCase():"",l=UEn.has(a),c=WEn.has(i);if(!l&&!c)return!1;const u=r.includes("/"),d=n.line!=null;return!(!u&&!d&&!c)}const K$=new RegExp("(?:^|(?<=[\\s(,[\\]]))(?:\\.{0,2}\\/)?(?:[a-zA-Z0-9_@./-]*\\/)?[a-zA-Z0-9_.-]+\\.[a-zA-Z0-9]+:\\d+(?:[-:]\\d+)?(?=$|[\\s),.\\]!?;])","g");function ZEn(t){const e=/[A-Za-z0-9._/@~+-]+(?::\d+(?:[-:]\d+)?)?/g,n=[];for(const r of t.matchAll(e)){const o=r[0];lte(o)&&n.push({text:o,startIndex:r.index,endIndex:r.index+o.length})}return n}function XFe(t,e){const n=[],r=[];let o=0,i;for(let s=0;s<t.cols;s++){if(i=e.getCell(s,i),!i||i.getWidth()===0)continue;const a=i.getChars(),l=a.length>0?a:" ";r[o]=s+1,n.push(l),o+=l.length}return{text:n.join(""),columnForIndex:r}}function GEn(t,e){return{provideLinks(n,r){const o=t.buffer.active.getLine(n-1);if(!o){r(void 0);return}const{text:i,columnForIndex:s}=XFe(t,o),a=ZEn(i);if(a.length===0){r(void 0);return}const l=a.map(c=>{const u=s[c.startIndex]??1,d=s[c.endIndex-1]??t.cols;return{text:c.text,range:{start:{x:u,y:n},end:{x:d,y:n}},decorations:{pointerCursor:!0,underline:!0},activate:h=>{h.preventDefault(),e(c.text)}}});r(l)}}}const f4e=4096;let dO=null;const h4e=[];function p4e(t){dO||(dO=new MessageChannel,dO.port1.onmessage=()=>h4e.shift()?.()),h4e.push(t),dO.port2.postMessage(null)}function YEn(t){let e=[],n=!1;const r=(s,a)=>{if(t(s))for(const l of a)l.onSent?.()},o=()=>{const s=e;e=[];let a=[],l="";const c=()=>{a.length!==0&&(r(l,a),a=[],l="")};for(const u of s){if(u.data.length>f4e){c(),r(u.data,[u]);continue}l.length+u.data.length>f4e&&c(),a.push(u),l+=u.data}c()},i=()=>{if(e.length===0){n=!1;return}o(),p4e(i)};return{write(s,a){if(n){e.push({data:s,onSent:a});return}r(s,[{data:s,onSent:a}]),n=!0,p4e(i)}}}const OU="band:terminal-link-menu",SU="band:open-in-band-browser",XEn=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform);function KFe(t){try{const{protocol:e}=new URL(t);return e==="http:"||e==="https:"}catch{return!1}}function CU(t){return On&&KFe(t)}function JFe(t){window.dispatchEvent(new CustomEvent(SU,{detail:t}))}function KEn(t,e,n){if(!(XEn?t.metaKey:t.ctrlKey)){window.dispatchEvent(new CustomEvent(OU,{detail:{...n,url:e,x:t.clientX,y:t.clientY}}));return}if(t.shiftKey||!CU(e)){N4(e);return}JFe({worktreeId:n.worktreeId,terminalId:n.terminalId,url:e})}const QS="\x1B",JEn=8,eTn=16;function tTn(t){let e="default";const n=o=>i=>{for(const s of i)s===1006?e=o?"sgr":"default":s===1016&&(e=o?"sgr-pixels":"default");return!1},r=[t.parser.registerCsiHandler({prefix:"?",final:"h"},n(!0)),t.parser.registerCsiHandler({prefix:"?",final:"l"},n(!1)),t.parser.registerEscHandler({final:"c"},()=>(e="default",!1))];return{current:()=>e,reset(){e="default"},dispose(){for(const o of r)o.dispose()}}}function fO(t){return Number.isInteger(t)&&t>=0&&t<=9999}function eqe(t){const e=t.modes.mouseTrackingMode;return e==="vt200"||e==="drag"||e==="any"}function nTn(t){return t.buffer.active.type==="alternate"}function AU(t,e){const n=t.modes.applicationCursorKeysMode?"O":"[";return QS+n+(e<0?"A":"B")}function tqe(t,e,n,r=0){const o=(t<0?64:65)+r;if(n==="sgr-pixels")return!fO(e.x)||!fO(e.y)?"":`${QS}[<${o};${e.x};${e.y}M`;const i=e.col+1,s=e.row+1;if(n==="sgr")return!fO(i)||!fO(s)?"":`${QS}[<${o};${i};${s}M`;const a=[o+32,i+32,s+32];return a.some(l=>!Number.isInteger(l)||l>126)?"":`${QS}[M${String.fromCharCode(...a)}`}function nqe(t,e,n,r,o){if(!e||t.cols<=0||t.rows<=0||!(o.width>0&&o.height>0)||!Number.isFinite(n)||!Number.isFinite(r))return null;const i=Math.min(Math.max((n-o.left)/o.width,0),1-1e-9),s=Math.min(Math.max((r-o.top)/o.height,0),1-1e-9);return{col:Math.floor(i*t.cols),row:Math.floor(s*t.rows),x:Math.floor(i*e.offsetWidth),y:Math.floor(s*e.offsetHeight)}}const cte=0,rTn=1,oTn=2,iTn=50,sTn=100,aTn=120,lTn=16,cTn=1.6,uTn=6,m4e=16,J$=45,dTn=3,g4e=4,fTn=.85,hTn=9;function rqe(t){return typeof t.wheelDeltaY=="number"&&Number.isFinite(t.wheelDeltaY)?t.wheelDeltaY:typeof t.wheelDelta=="number"&&Number.isFinite(t.wheelDelta)?t.wheelDelta:null}function ute(t){const e=rqe(t);return e!==null&&Math.abs(e)>=sTn}function pTn(t){return t.deltaMode!==cte||Math.abs(t.deltaY)>=iTn||ute(t)}function mTn(t,e,n){const r=Math.abs(t.deltaY),o=t.deltaMode===rTn?r:t.deltaMode===oTn?r*Math.max(1,n):r/e,i=rqe(t),s=i===null?0:Math.abs(i)/aTn,a=Math.max(o,s);return pTn(t)?Math.max(1,a):a}function gTn(t){return t<=1?t:Math.min(uTn,1+Math.log2(t)*cTn)}function oqe(t){t.fastStreak=0,t.lastDistanceRows=null,t.lastInputAt=null}function vTn(t,e,n){if(!(t.deltaMode!==cte||ute(t))||!Number.isFinite(t.timeStamp))return oqe(e),0;const o=e.lastInputAt===null?null:t.timeStamp-e.lastInputAt,i=e.lastDistanceRows!==null&&n<e.lastDistanceRows*fTn;if(e.lastDistanceRows=n,e.lastInputAt=t.timeStamp,i||o===null||o<0||o>J$)return e.fastStreak=0,0;const s=o<=m4e?1:(J$-o)/(J$-m4e);return e.fastStreak=Math.min(g4e,e.fastStreak+1),dTn*s*(e.fastStreak/g4e)}function bTn(t,e,n,r){const o=t.deltaY<0?-1:1;e.direction!==o&&(oqe(e),e.pendingRows=0),e.direction=o;const i=mTn(t,n,r),s=t.deltaMode===cte&&!ute(t)?i:Math.min(hTn,gTn(i)+vTn(t,e,i)),a=e.pendingRows+s,l=Math.trunc(a);return e.pendingRows=a-l,l}function _Tn(t,e,n){const r=t.querySelector(".xterm-screen"),o={fastStreak:0,lastDistanceRows:null,lastInputAt:null,direction:0,pendingRows:0};e.attachCustomWheelEventHandler(i=>{if(!eqe(e)||i.shiftKey||i.deltaY===0||!Number.isFinite(i.deltaY))return!0;const s=r?.getBoundingClientRect(),a=s&&s.height>0&&e.rows>0?s.height/e.rows:lTn,l=bTn(i,o,a,e.rows);if(l===0)return!1;const c=i.deltaY<0?-l:l,u=s?nqe(e,r,i.clientX,i.clientY,s):null,d=(i.altKey?JEn:0)|(i.ctrlKey?eTn:0),h=u?tqe(c,u,n.current(),d):"";return e.input((h||AU(e,c)).repeat(l),!0),!1})}const Jv=[27,91,63,50,48,50,54],xTn=104,yTn=108,EU=Jv.length+1,wTn=100,kTn=64*1024,OTn=50,STn=50,hO=16*1024,CTn=6,ATn=8,iqe=8,ETn=128*1024,TTn=2*1024*1024;function MTn(t){const e={last:null,beginAt:-1,partialAt:t.byteLength};for(let n=t.indexOf(27);n!==-1;n=t.indexOf(27,n+1)){const r=Math.min(EU,t.byteLength-n);let o=1;for(;o<r&&o<Jv.length&&t[n+o]===Jv[o];)o++;if(o<Math.min(r,Jv.length))continue;if(r<EU){e.partialAt=n;break}const i=t[n+Jv.length];i===xTn?(e.last="begin",e.beginAt=n):i===yTn&&(e.last="end")}return e}function sqe(){return F_n()}const w0=new Set;let TU=null;const E2=new Set;let MU=!1,pO=null;function aqe(t){TU!==null||w0.size===0||(TU=setTimeout(jTn,t))}function lT(){MU||E2.size===0||(MU=!0,pO||(pO=new MessageChannel,pO.port1.onmessage=NTn),pO.port2.postMessage(null))}function dte(t){return typeof t=="string"?t.length:t.byteLength}function lqe(t){const e=t.chunks[0];if(typeof e.data=="string"||e.data.byteLength<=hO)return t.chunks.shift(),t.bytes-=dte(e.data),{data:e.data,done:e.callbacks};const n=e.data.subarray(0,hO);return e.data=e.data.subarray(hO),t.bytes-=hO,{data:n,done:void 0}}function PTn(t,e,n){if(!n?.onParsed&&!n?.onConsumed){t.write(e);return}t.write(e,()=>{n.onParsed?.(),n.onConsumed?.()})}function jTn(){if(TU=null,sqe()){for(const n of w0)n.overflow?.();w0.clear();return}const t=performance.now();let e=0;for(;e<CTn&&w0.size>0;){const n=w0.values().next().value;w0.delete(n);const{data:r,done:o}=lqe(n);if(PTn(n,r,o),e++,n.chunks.length>0&&w0.add(n),performance.now()-t>=iqe)break}aqe(STn)}function x6(t){return t.chunks.length>0&&t.inFlight<ETn}function PU(t){const{data:e,done:n}=lqe(t),r=dte(e);t.inFlight+=r,t.write(e,()=>{t.inFlight-=r,n?.onParsed?.(),n?.onConsumed?.(),x6(t)&&(E2.add(t),lT())})}function NTn(){MU=!1;const t=performance.now();let e=0;for(;e<ATn&&E2.size>0;){const n=E2.values().next().value;if(E2.delete(n),!!x6(n)&&(PU(n),e++,x6(n)&&E2.add(n),performance.now()-t>=iqe))break}lT()}function RTn(t){const e={write:t,chunks:[],bytes:0,overflowed:!1,inFlight:0,held:[],heldBytes:0,frameOpen:!1,holdTimer:null},n=()=>{e.holdTimer!==null&&clearTimeout(e.holdTimer),e.holdTimer=null;const u=e.held;return e.held=[],e.heldBytes=0,e.frameOpen=!1,u},r=()=>{w0.delete(e),E2.delete(e);const u=[...e.chunks,...n()];e.chunks=[],e.bytes=0;for(const d of u)d.callbacks?.onConsumed?.()};e.overflow=()=>{r(),e.overflowed=!0};const o=(u,d)=>{e.chunks.push({data:u,callbacks:d}),e.bytes+=dte(u)},i=()=>{const u=Math.min(EU-1,e.heldBytes),d=new Uint8Array(u);let h=u;for(let p=e.held.length-1;p>=0&&h>0;p--){const g=e.held[p].data,_=Math.min(h,g.byteLength);d.set(g.subarray(g.byteLength-_),h-_),h-=_}return d},s=()=>{for(const u of n())o(u.data,u.callbacks)},a=()=>{x6(e)&&PU(e),x6(e)&&(E2.add(e),lT())},l=(u,d)=>{e.held.push({data:u,callbacks:d}),e.heldBytes+=u.byteLength,e.holdTimer??=setTimeout(()=>{e.holdTimer=null,s(),a()},wTn)},c=(u,d)=>{if(u.byteLength===0){o(u,d);return}const h=i();let p=u;h.byteLength>0&&(p=new Uint8Array(h.byteLength+u.byteLength),p.set(h),p.set(u,h.byteLength));const g=h.byteLength,_=MTn(p);let x;_.last==="begin"?(x=Math.max(0,_.beginAt-g),_.beginAt>=g&&s(),e.frameOpen=!0):_.last===null&&_.partialAt<g?x=0:_.last==="end"||!e.frameOpen?(s(),x=Math.max(0,_.partialAt-g)):x=0,x>0&&o(u.subarray(0,x),x===u.byteLength?d:void 0),x<u.byteLength&&(l(u.subarray(x),d),e.heldBytes>kTn&&s())};return{push(u,d,h){if(d){w0.has(e)&&this.flush(),typeof u=="string"?(s(),o(u,h)):c(u,h),a();return}if(e.overflowed||sqe()){for(const p of n())p.callbacks?.onConsumed?.();e.overflowed||(r(),e.overflowed=!0),h?.onConsumed?.();return}if(s(),o(u,h),e.bytes>TTn){r(),e.overflowed=!0;return}w0.add(e),aqe(OTn)},pushNotice(u){if(e.held.length>0){s(),o(u,void 0),a();return}if(e.chunks.length===0){t(u);return}o(u,void 0)},flush(){if(e.overflowed)return!1;if(!w0.delete(e))return!0;for(;x6(e);)PU(e);return e.chunks.length>0&&(E2.add(e),lT()),!0},clear(){r(),e.overflowed=!1},dispose(){r()}}}const LTn=3e4,ITn=5*6e4,DTn=4,zTn=3e4,$Tn=5*6e4,BTn=6,HTn=1e4,FTn=6e4;function cqe(t,e){return e?Math.min(t,HTn):t}function uqe(t,e){return e?Math.min(t,FTn):t}function dqe(t,e){if(t.hiddenSinceMs!==e.hiddenSinceMs)return e.hiddenSinceMs-t.hiddenSinceMs;const n=(e.lastActivatedSeq??-1)-(t.lastActivatedSeq??-1);return n===0?t.id.localeCompare(e.id):n}function qTn(t){let e=null;for(const n of t)(e===null||dqe(n,e)<0)&&(e=n);return e?.id??null}function fqe(t,e){const n=qTn(t),r=new Set,o=[];for(const s of t)s.id!==n&&(e.nowMs-s.hiddenSinceMs>=e.hotRetainMs?r.add(s.id):o.push(s));o.sort(dqe);const i=n===null?e.hotRetainLimit:e.hotRetainLimit-1;for(const s of o.slice(Math.max(0,i)))r.add(s.id);return r}const VTn=800,QTn=600,v4e="__bandTerminalParking__";function b4e(){const t=globalThis,e=t[v4e];if(e?.isConnected)return e;const n=document.createElement("div");return n.dataset.testid="terminal-parking",Object.assign(n.style,{position:"fixed",left:"-9999px",top:"-9999px",width:`${VTn}px`,height:`${QTn}px`,overflow:"hidden",pointerEvents:"none"}),n.inert=!0,n.setAttribute("inert",""),n.setAttribute("aria-hidden","true"),document.body.appendChild(n),t[v4e]=n,n}const eB=/[A-Za-z0-9_./:\-+@~]/;function UTn(t,e,n,r){const o=r.getBoundingClientRect();if(o.width<=0||o.height<=0||n.cols<=0||n.rows<=0)return{col:0,row:n.buffer.active.viewportY};const i=o.width/n.cols,s=o.height/n.rows,a=jU(Math.floor((t-o.left)/i),0,n.cols-1),l=jU(Math.floor((e-o.top)/s),0,n.rows-1);return{col:a,row:n.buffer.active.viewportY+l}}function WTn(t,e){if(e<0||e>=t.length||!eB.test(t[e])){const o=jU(e,0,Math.max(0,t.length));return{start:o,end:o+1}}let n=e;for(;n>0&&eB.test(t[n-1]);)n--;let r=e+1;for(;r<t.length&&eB.test(t[r]);)r++;return{start:n,end:r}}function ZTn(t,e){return t.buffer.active.getLine(e)?.translateToString(!1)??""}function GTn(t,e,n){const r=n.cols,o=Math.max(0,n.buffer.active.length-1);switch(e){case"left":return t.col>0?{col:t.col-1,row:t.row}:t.row>0?{col:r-1,row:t.row-1}:t;case"right":return t.col<r-1?{col:t.col+1,row:t.row}:t.row<o?{col:0,row:t.row+1}:t;case"up":return t.row>0?{col:t.col,row:t.row-1}:t;case"down":return t.row<o?{col:t.col,row:t.row+1}:t}}function mO(t,e,n){const r=t.cols;if(r<=0)return;const o=e.row*r+e.col,i=n.row*r+n.col,s=Math.min(o,i),l=Math.max(o,i)-s+1,c=Math.floor(s/r),u=s-c*r;t.select(u,c,l)}function YTn(t,e){const{start:n,end:r}=WTn(e,t.col);return{anchor:{col:n,row:t.row},head:{col:Math.max(n,r-1),row:t.row}}}function jU(t,e,n){return t<e?e:t>n?n:t}const id=new Map;function tB(t,e){id.set(t,e)}function NU(t){id.delete(t)}function XTn(t){for(const[e,n]of id)n===t&&id.delete(e)}function cT(t){return id.get(t)}function _4e(t){return id.has(t)}function x4e(t){const e=[];for(const[n,r]of id)r===t&&e.push(n);return e}function KTn(t,e){for(const n of e)if(id.get(n)===t)return!0;return!1}const J9=new Map;function JTn(t,e,n){const r={containerEl:t,api:e,leafId:n};return J9.set(n,r),()=>{J9.get(n)===r&&J9.delete(n)}}function y4e(){const t=document.activeElement;if(!t)return null;for(const e of J9.values())if(e.containerEl.contains(t))return e.api;return null}function hqe(t){return J9.get(t)?.api}const pqe="band:term-split:";function fte(t,e){return`${pqe}${t}:${e}`}function eMn(t,e){try{const n=localStorage.getItem(fte(t,e));return n?JSON.parse(n):null}catch{return null}}function tMn(t,e,n){try{Hn.setItem(fte(t,e),JSON.stringify(n))}catch{}}function nMn(t,e){try{Hn.removeItem(fte(t,e))}catch{}}function rMn(t){const e=`${pqe}${t}:`;let n=0;try{for(let r=0;r<localStorage.length;r++){const o=localStorage.key(r);if(!o||!o.startsWith(e))continue;const i=o.slice(e.length),s=localStorage.getItem(o);if(!s)continue;let a;try{a=JSON.parse(s)}catch{continue}const l=a&&typeof a=="object"?a.panels:void 0;if(l&&typeof l=="object")for(const c of Object.keys(l))id.set(c,i),n++}}catch{}return n}const oMn=32,iMn=.972,w4e=.012,nB=16,k4e=5,sMn=4,aMn=100;function lMn(t,e,n){const r=t.querySelector(".xterm-screen"),o=E=>E.height>0&&e.rows>0?E.height/e.rows:0,i=(E,M)=>{const P=Math.min(Math.abs(M),oMn);e.input(E.repeat(P),!0)},s=(E,M,P,L)=>{if(E===0)return!0;if(eqe(e)){const z=nqe(e,r,M,P,L),Y=z?tqe(E,z,n.current()):"";return i(Y||AU(e,E),E),!0}if(nTn(e))return i(AU(e,E),E),!0;const D=e.buffer.active,I=D.viewportY;return e.scrollLines(E),D.viewportY!==I};let a=0,l=0,c=0,u=0,d=0,h=0,p=0,g=!1,_=null;const x=()=>{_!==null&&(cancelAnimationFrame(_),_=null)},y=E=>{if(!r)return!1;const M=r.getBoundingClientRect(),P=o(M);if(P<=0)return!1;p+=E;const L=Math.trunc(p/P);return L===0?!0:(p-=L*P,s(L,a,l,M))},k=E=>{x(),g=E.touches.length===1,g&&(a=E.touches[0].clientX,l=E.touches[0].clientY,c=E.timeStamp,u=l,d=c,h=0,p=0)},O=E=>{if(E.stopPropagation(),E.touches.length!==1||!g)return;E.preventDefault();const M=E.touches[0].clientX,P=E.touches[0].clientY,L=l-P,D=E.timeStamp-d;if(D>=sMn){const I=(u-P)/D;if(Number.isFinite(I)){const z=h===0?I:h*.55+I*.45;h=Math.min(Math.max(z,-k4e),k4e)}u=P,d=E.timeStamp}a=M,l=P,c=E.timeStamp,y(L)||(h=0)},C=E=>{if(!g||E.touches.length>0)return;g=!1;let M=E.timeStamp-c>aMn?0:h;if(Math.abs(M)<=w4e)return;let P=null;const L=D=>{const I=P===null?nB:Math.min(D-P,4*nB);if(P=D,M*=iMn**(I/nB),Math.abs(M)<w4e||!y(M*I)){_=null;return}_=requestAnimationFrame(L)};_=requestAnimationFrame(L)},A=()=>{g=!1};return t.addEventListener("touchstart",k,{capture:!0,passive:!0}),t.addEventListener("touchmove",O,{capture:!0,passive:!1}),t.addEventListener("touchend",C,{capture:!0,passive:!0}),t.addEventListener("touchcancel",A,{capture:!0,passive:!0}),{dispose(){x(),t.removeEventListener("touchstart",k,{capture:!0}),t.removeEventListener("touchmove",O,{capture:!0}),t.removeEventListener("touchend",C,{capture:!0}),t.removeEventListener("touchcancel",A,{capture:!0})}}}const cMn=2e3,uMn=5e3;let l4=!1,mqe=!1,y6=[],vN=0;const ru=new Map;function dMn(t){let e=ru.get(t);return e||(e=[],ru.set(t,e)),e}function fMn(t,e){for(;t.length>0&&e-t[0].inputAt>cMn;)t.shift(),vN++}function hMn(t,e,n){const r=i=>{if(!l4||i.key.length!==1||i.metaKey||i.ctrlKey||i.altKey)return;const s=dMn(t);fMn(s,performance.now());const a=i.key.charCodeAt(0);s.push({byte:a<128?a:0,inputAt:i.timeStamp,dispatchAt:null,arrivalAt:null,parsedAt:null})};n.addEventListener("keydown",r,!0);const o=e.onRender(()=>{if(!l4)return;const i=ru.get(t);if(!i||!i.some(a=>a.parsedAt!==null))return;const s=performance.now();for(const a of i)a.dispatchAt===null||a.arrivalAt===null||a.parsedAt===null||(y6.push({inputToDispatch:a.dispatchAt-a.inputAt,dispatchToArrival:a.arrivalAt-a.dispatchAt,arrivalToParsed:a.parsedAt-a.arrivalAt,parsedToPaint:s-a.parsedAt,inputToPaint:s-a.inputAt}),y6.length>uMn&&y6.shift());ru.set(t,i.filter(a=>a.parsedAt===null))});return()=>{n.removeEventListener("keydown",r,!0),o.dispose(),ru.delete(t)}}function pMn(t){if(!l4)return;const e=ru.get(t)?.find(n=>n.dispatchAt===null);e&&(e.dispatchAt=performance.now())}function mMn(t,e,n,r){const o=new Map;for(const a of n)a.byte!==0&&r.includes(a.byte)&&o.set(a.byte,a);const i=new Set(o.values()),s=n.filter(a=>o.has(a.byte)&&!i.has(a));return s.length>0&&(vN+=s.length,ru.set(t,e.filter(a=>!s.includes(a)))),[...i]}function gMn(t,e){if(!l4)return;const n=ru.get(t)??[],r=n.filter(s=>s.dispatchAt!==null&&s.arrivalAt===null),o=mqe?mMn(t,n,r,e):r.slice(0,1);if(o.length===0)return;const i=performance.now();for(const s of o)s.arrivalAt=i;return()=>{const s=performance.now();for(const a of o)a.parsedAt=s}}function vMn(t){if(t.length===0)return{p50:0,p90:0,p99:0,max:0};const e=[...t].sort((r,o)=>r-o),n=r=>Math.round(e[Math.min(e.length-1,Math.floor(r*e.length))]*10)/10;return{p50:n(.5),p90:n(.9),p99:n(.99),max:n(1)}}function O4e(){const t=e=>vMn(y6.map(n=>n[e]));return{running:l4,samples:y6.length,unmatched:vN,inputToDispatchMs:t("inputToDispatch"),dispatchToArrivalMs:t("dispatchToArrival"),arrivalToParsedMs:t("arrivalToParsed"),parsedToPaintMs:t("parsedToPaint"),inputToPaintMs:t("inputToPaint")}}const bMn={start(t){mqe=t?.matchEcho===!0,y6=[],vN=0,ru.clear(),l4=!0},stop(){return l4=!1,ru.clear(),O4e()},report(){const t=O4e();return console.table({inputToDispatch:t.inputToDispatchMs,dispatchToArrival:t.dispatchToArrivalMs,arrivalToParsed:t.arrivalToParsedMs,parsedToPaint:t.parsedToPaintMs,inputToPaint:t.inputToPaintMs}),t}};typeof window<"u"&&(window.__bandTypingLatency=bMn);const _Mn=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\^<>`]*[^\s"':,.!?{}|\\^~[\]`()<>]/g,xMn=2,S4e=16,yMn=8*1024,wMn=/^(?:[-*+•>❯›$#]\s|\d+[.)]\s)/;function kMn(t){try{const e=new URL(t),n=e.username?`${e.protocol}//${e.username}${e.password?`:${e.password}`:""}@${e.host}`:`${e.protocol}//${e.host}`;return t.toLowerCase().startsWith(n.toLowerCase())}catch{return!1}}function OMn(t,e){const n=t.text.trimEnd();return n.length===0?!1:(t.columnForIndex[n.length-1]??0)>=e-xMn}function C4e(t,e,n){if(e.wrapped)return!0;if(!OMn(t,n))return!1;const r=e.text.trimStart();return!(r.length===0||wMn.test(r))}function SMn(t,e){const n=r=>{const o=t.buffer.active.getLine(r-1);if(!o)return;const{text:i,columnForIndex:s}=XFe(t,o);return{text:i,columnForIndex:s,wrapped:o.isWrapped}};return{provideLinks(r,o){const i=n(r);if(!i){o(void 0);return}const s=new Map([[r,i]]),a=p=>{if(!s.has(p)){const g=n(p);if(!g)return;s.set(p,g)}return s.get(p)};let l=r;for(let p=0;p<S4e;p++){const g=a(l-1),_=a(l);if(!g||!_||!C4e(g,_,t.cols))break;l--}let c=r;for(let p=0;p<S4e;p++){const g=a(c+1),_=a(c);if(!g||!_||!C4e(_,g,t.cols))break;c++}let u="";const d=[];for(let p=l;p<=c;p++){const g=a(p);if(!g)break;const y=!(p===l)&&!g.wrapped?g.text.length-g.text.trimStart().length:0,C=(p<c&&a(p+1)?.wrapped===!0?g.text:g.text.trimEnd()).slice(y);if(u.length+C.length>yMn)break;d.push({y:p,start:u.length,text:C,columnForIndex:g.columnForIndex,offset:y}),u+=C}const h=[];for(const p of u.matchAll(_Mn)){const g=p[0];if(!kMn(g))continue;const _=p.index,x=_+g.length-1,y=A4e(d,_),k=A4e(d,x);if(!y||!k||r<y.y||r>k.y)continue;const O=y.columnForIndex[y.offset+_-y.start]??1,C=k.columnForIndex[k.offset+x-k.start]??t.cols;h.push({text:g,range:{start:{x:O,y:y.y},end:{x:C,y:k.y}},decorations:{pointerCursor:!0,underline:!0},activate:A=>e(A,g)})}o(h.length>0?h:void 0)}}}function A4e(t,e){for(let n=t.length-1;n>=0;n--){const r=t[n];if(r&&e>=r.start)return r.start+r.text.length>e?r:void 0}}const E4e="__bandWorktreeColdPark__";function Kx(){const t=globalThis;return t[E4e]??={activeWorktreeId:null,hiddenSince:new Map,cold:new Set,listeners:new Set,timer:null},t[E4e]}function CMn(t){const e=Kx(),n=e.activeWorktreeId;n!==t&&(n!==null&&e.hiddenSince.set(n,Date.now()),t!==null&&e.hiddenSince.delete(t),e.activeWorktreeId=t,bN())}function AMn(t){const e=Kx();let n=!1;for(const r of e.hiddenSince.keys())t.has(r)||(e.hiddenSince.delete(r),n=!0);n&&bN()}let T4e=!1;function EMn(){if(T4e||typeof window>"u")return;T4e=!0;let t=U0().onBattery;Wx(()=>{const e=U0().onBattery;e!==t&&(t=e,bN())})}EMn();function gqe(t){return Kx().cold.has(t)}function vqe(t){const{listeners:e}=Kx();return e.add(t),()=>e.delete(t)}function bN(){const t=Kx();t.timer!==null&&(clearTimeout(t.timer),t.timer=null);const e=Date.now();let n=Number.POSITIVE_INFINITY;const r=[],o=U0().onBattery,i=cqe(LTn,o),s=uqe(ITn,o);for(const[c,u]of t.hiddenSince){for(const d of[u+i,u+s])d>e&&d<n&&(n=d);e-u>=i&&r.push({id:c,hiddenSinceMs:u})}const a=fqe(r,{nowMs:e,hotRetainMs:s,hotRetainLimit:DTn});n!==Number.POSITIVE_INFINITY&&(t.timer=setTimeout(bN,n-e));let l=a.size!==t.cold.size;for(const c of a){if(l)break;t.cold.has(c)||(l=!0)}if(l){t.cold=a;for(const c of[...t.listeners])c()}}const bqe="band:zoom-level",_qe=1,b8=.5,_8=2,uT=.1,xqe="--app-zoom",RU="band:zoom-changed";function _N(){try{const t=localStorage.getItem(bqe);if(t){const e=Number.parseFloat(t);if(!Number.isNaN(e)&&e>=b8&&e<=_8)return e}}catch{}return _qe}function TMn(t){const e=Math.min(_8,Math.max(b8,t)),n=Math.round(e*100)/100;try{Hn.setItem(bqe,String(n))}catch{}}function yqe(t){const e=Math.min(_8,Math.max(b8,t)),n=Math.round(e*100)/100,r=document.documentElement;return r.style.zoom=String(n),r.style.setProperty(xqe,String(n)),window.dispatchEvent(new CustomEvent(RU,{detail:n})),n}function xN(t){const e=Math.min(_8,Math.max(b8,t)),n=Math.round(e*100)/100;TMn(n),yqe(n)}function M4e(){if(typeof document<"u"){const t=document.documentElement.style.getPropertyValue(xqe);if(t){const e=Number.parseFloat(t);if(!Number.isNaN(e)&&e>=b8&&e<=_8)return e}}return _N()}function MMn(t){if(typeof window>"u")return()=>{};const e=n=>{const r=n.detail;typeof r=="number"&&t(r)};return window.addEventListener(RU,e),()=>window.removeEventListener(RU,e)}function wqe(){xN(_N()+uT)}function kqe(){xN(_N()-uT)}function Oqe(){xN(_qe)}const PMn=13,jMn=500,P4e=10;function NMn(){const t=b6("--terminal-background"),e=jpe(b6("--search-match"),t),n=jpe(b6("--search-match-current"),t);return{matchBackground:e,activeMatchBackground:n,matchOverviewRuler:e,activeMatchColorOverviewRuler:n}}const RMn={caseSensitive:!1,wholeWord:!1,regex:!1};function gO(t){return{caseSensitive:t.caseSensitive,wholeWord:t.wholeWord,regex:t.regex,decorations:NMn()}}function j4e(){const t=n=>b6(n),e=t("--terminal-background");return{background:e,foreground:t("--terminal-foreground"),cursor:t("--terminal-foreground"),cursorAccent:e,selectionBackground:t("--terminal-selection"),black:t("--ansi-0"),red:t("--ansi-1"),green:t("--ansi-2"),yellow:t("--ansi-3"),blue:t("--ansi-4"),magenta:t("--ansi-5"),cyan:t("--ansi-6"),white:t("--ansi-7"),brightBlack:t("--ansi-8"),brightRed:t("--ansi-9"),brightGreen:t("--ansi-10"),brightYellow:t("--ansi-11"),brightBlue:t("--ansi-12"),brightMagenta:t("--ansi-13"),brightCyan:t("--ansi-14"),brightWhite:t("--ansi-15")}}function N4e(){return b6("--font-code")||"'SF Mono', Menlo, Monaco, 'Courier New', monospace"}function R4e(){const t=Number.parseFloat(b6("--code-font-size"));return Number.isFinite(t)&&t>0?t:PMn}const LMn=1e4,IMn=2e4,DMn=500,L4e=1e4,I4e=3e3,zMn=5,$Mn={ready:!1,searchOpen:!1,searchQuery:"",searchOptions:RMn,matchInfo:{total:0,current:0},selectionMode:!1,pendingCtrl:!1,terminated:!1},rB="__bandTerminalCache__";function Jx(){const t=globalThis;return t[rB]||(t[rB]=new Map),t[rB]}function BMn(t,e){const{worktreeId:n,paneMetadata:r,useWebGL:o,autoFocus:i}=e,s=document.createElement("div");s.dataset.testid="terminal-wrapper",s.dataset.terminalId=t,s.dataset.worktreeId=n,s.style.position="absolute",s.style.inset="0",s.style.overflow="hidden",s.style.setProperty("zoom","calc(1 / var(--app-zoom, 1))"),b4e().appendChild(s);let a=$Mn;const l=new Set,c=()=>{for(const Z of l)Z()},u=Z=>{a={...a,...Z},c()},d=new Set;let h=null,p=null;const g=Z=>{p=Z,h?.(Z)};let _=null,x=null,y=null,k=null;const O=YEn(Z=>!k||k.readyState!==WebSocket.OPEN?!1:(k.send(Z),!0));let C=null,A=!1,E=i??r?.focus??!1,M=Date.now(),P=0,L=!1,D=0,I=null,z=null,Y=!1,Q=null;Promise.all([re(()=>import("./xterm-EbFzQDSP.js"),[]),re(()=>import("./addon-fit-tyBwD3Sv.js"),[]),re(()=>import("./addon-search-BvnuewQv.js"),[]),re(()=>import("./addon-webgl-D9URxm_b.js"),[]),re(()=>import("./addon-unicode11-C7S6GMMR.js"),[])]).then(([Z,U,B,ee,te])=>{if(Y)return;const{Terminal:se}=Z,{FitAddon:ae}=U,{SearchAddon:he}=B,{WebglAddon:fe}=ee,{Unicode11Addon:be}=te;re(()=>Promise.resolve({}),__vite__mapDeps([141]));const me=new se({allowProposedApi:!0,cursorBlink:!UQ(U0()),fontSize:R4e()*M4e(),fontFamily:N4e(),lineHeight:o?1.2:1,macOptionIsMeta:!0,scrollback:1e4,theme:j4e(),scrollSensitivity:1.15,linkHandler:{activate:(st,Fn)=>bt(st,Fn)}});_=me;const le=RTn((st,Fn)=>me.write(st,Fn)),Be=Wx(()=>{me.options.cursorBlink=!UQ(U0())});me.loadAddon(new be),me.unicode.activeVersion="11";const Xe=new ae;me.loadAddon(Xe);let ot=null;const Qe=()=>{Xe.fit(),ot=C?{width:C.clientWidth,height:C.clientHeight}:null},lt=()=>!ot||!C||C.clientWidth!==ot.width||C.clientHeight!==ot.height,bt=(st,Fn)=>{if(!KFe(Fn)){N4(Fn);return}KEn(st,Fn,{worktreeId:n,terminalId:t,focusTerminal:()=>me.focus()})},ve=me.registerLinkProvider(SMn(me,bt)),Te=me.registerLinkProvider(GEn(me,st=>{window.dispatchEvent(new CustomEvent("band:open-file",{detail:{filename:st,worktreeId:n}}))}));me.open(s);let pe;const Ne=()=>{try{const st=new fe({customGlyphs:!0});me.loadAddon(st);const mr=s.querySelector(".xterm-screen")?.querySelector(":scope > canvas:last-of-type");return mr&&(mr.style.pointerEvents="none",mr.style.touchAction="none"),y=st,D=Date.now(),pe?.dispose(),pe=st.onContextLoss(()=>{console.warn("[terminal-cache] WebGL context lost, reattaching addon"),st.dispose(),y=null,A&&H()?Ne():L=!0}),!0}catch(st){return console.warn("[terminal-cache] WebGL renderer unavailable, falling back to DOM",st),!1}};o&&Ne();const $e=new he;x=$e,me.loadAddon($e);const De=$e.onDidChangeResults(st=>{u({matchInfo:{total:st.resultCount,current:st.resultIndex>=0?st.resultIndex+1:0}})});me.attachCustomKeyEventHandler(st=>{if(st.key==="Tab"&&st.ctrlKey&&!st.metaKey&&!st.altKey)return!1;if(st.type==="keydown"){if(a.pendingCtrl&&st.key.length===1&&!st.metaKey&&!st.altKey&&!st.ctrlKey){const mr=st.key.toLowerCase().charCodeAt(0);if(mr>=97&&mr<=122)return me.input(String.fromCharCode(mr-96)),u({pendingCtrl:!1}),st.preventDefault(),!1;u({pendingCtrl:!1})}if((st.metaKey||st.ctrlKey)&&!st.shiftKey&&!st.altKey&&st.key.toLowerCase()==="f")return st.preventDefault(),q.openSearch(),!1;if(st.key==="Enter"&&st.shiftKey&&!st.altKey&&!st.metaKey&&!st.ctrlKey)return st.preventDefault(),me.input(`
970
970
  `),!1;if(st.altKey&&!st.metaKey&&!st.ctrlKey){if(st.key==="ArrowLeft")return me.input("\x1Bb"),!1;if(st.key==="ArrowRight")return me.input("\x1Bf"),!1}}return!0});const ct=tTn(me),ue=lMn(s,me,ct);_Tn(s,me,ct);let Pe=null,Ee=null;const Le=()=>{Pe!==null&&(window.clearTimeout(Pe),Pe=null),Ee=null},et=st=>{if(Le(),st.touches.length!==1)return;const Fn=st.touches[0];Ee={x:Fn.clientX,y:Fn.clientY},Pe=window.setTimeout(()=>{Pe=null;const mr=Ee;if(!mr)return;const Zo=s.querySelector(".xterm-screen");if(!Zo)return;const El=UTn(mr.x,mr.y,me,Zo),X4=ZTn(me,El.row),{anchor:Lu,head:Ur}=YTn(El,X4);if(mO(me,Lu,Ur),I=Lu,z=Ur,u({selectionMode:!0}),tn=null,Kt=null,me.blur(),typeof navigator.vibrate=="function")try{navigator.vibrate(15)}catch{}},jMn)},kt=st=>{if(!Ee||st.touches.length!==1)return;const Fn=st.touches[0],mr=Math.abs(Fn.clientX-Ee.x),Zo=Math.abs(Fn.clientY-Ee.y);(mr>P4e||Zo>P4e)&&Le()};s.addEventListener("touchstart",et,{passive:!0}),s.addEventListener("touchmove",kt,{capture:!0,passive:!0}),s.addEventListener("touchend",Le,{passive:!0}),s.addEventListener("touchcancel",Le,{passive:!0});let tn=null,Kt=null;const Dn=st=>{st.touches.length===1?(tn=st.touches[0].clientX,Kt=st.touches[0].clientY):(tn=null,Kt=null)},Qt=st=>{const Fn=tn,mr=Kt;if(tn=null,Kt=null,Fn===null||mr===null||st.changedTouches.length!==1)return;const Zo=Math.abs(st.changedTouches[0].clientX-Fn),El=Math.abs(st.changedTouches[0].clientY-mr);Zo<10&&El<10&&(I!==null&&(I=null,z=null,u({selectionMode:!1}),me.clearSelection()),me.focus())},Ve=()=>{tn=null,Kt=null};s.addEventListener("touchstart",Dn,{passive:!0}),s.addEventListener("touchend",Qt,{passive:!0}),s.addEventListener("touchcancel",Ve,{passive:!0});const Ct=`${px("/terminal")}?worktreeId=${encodeURIComponent(n)}&terminalId=${encodeURIComponent(t)}`;let Mt=!1,Ye=!1,Pt=!1,Dt=0,Ut=null,kn=null,jt=0,pn=!1,ke=!1,Ke=null;const dt=()=>{Ut!==null&&(clearTimeout(Ut),Ut=null)},sn=()=>{kn!==null&&(clearInterval(kn),kn=null)},Yt=()=>{const st=k;if(!(!st||st.readyState!==WebSocket.OPEN)){if(Date.now()-jt>IMn){st.close();return}try{st.send(JSON.stringify({type:"ping"}))}catch{st.close()}}},Wt=()=>{if(Mt||Ye||Ut!==null)return;const st=Math.min(DMn*2**Dt,L4e);st<L4e&&(Dt+=1),Ut=setTimeout(()=>{Ut=null,Nt()},st)};let ir=0;function Nt(){if(Mt||Ye||Y)return;dt(),k=null;const st=++ir;(!Pt&&!!(r&&(r.command||r.cwd||r.env))?Promise.resolve(null):nFt(n,t)).then(mr=>{st===ir&&Xt(mr)},()=>{st===ir&&Xt(null)})}function Xt(st){if(Mt||Ye||Y)return;const Fn=Pt,mr=st?new WebSocket(st.url,st.protocols):new JY(Ct);k=mr;let Zo=!1;mr.binaryType="arraybuffer";let El=0;const X4=()=>{const Ur=El;El=0,k===mr&&mr.readyState===WebSocket.OPEN&&mr.send(JSON.stringify({type:"ack",bytes:Ur}))},Lu=Ur=>{k!==mr||Ur===0||(El===0&&queueMicrotask(X4),El+=Ur)};mr.onopen=()=>{Zo=!0,Dt=0,jt=Date.now(),pn=!1,Ae=0,ht=0,no(),Fn&&(le.clear(),me.reset(),ct.reset());const Ur=Yn();if(!Pt&&r&&(r.command||r.cwd||r.env)){const _o={type:"init",flow:!0};r.command&&(_o.command=r.command),r.cwd&&(_o.cwd=r.cwd),r.env&&(_o.env=r.env),Ur&&(_o.cols=Ur.cols,_o.rows=Ur.rows,Ae=Ur.cols,ht=Ur.rows,pn=!0,ke=!0,Ke=setTimeout(no,I4e)),mr.send(JSON.stringify(_o))}else ai();Pt=!0,Ur&&E&&!Fn&&(document.activeElement?.closest('[role="dialog"], [role="alertdialog"]')||me.focus(),E=!1),sn(),kn=setInterval(Yt,LMn);for(const _o of d)_o()},mr.onmessage=Ur=>{if(k===mr)if(Ur.data instanceof ArrayBuffer){Ss();const _o=new Uint8Array(Ur.data),Yh=gMn(t,_o);A&&!document.hidden?le.push(_o,!0,{onParsed:Yh,onConsumed:()=>Lu(_o.byteLength)}):(Lu(_o.byteLength),le.push(_o,!1,{onParsed:Yh}))}else try{const _o=JSON.parse(Ur.data);if(_o.type==="pong")jt=Date.now();else if(_o.type==="attached")Ss();else if(_o.type==="title"&&typeof _o.title=="string")g(_o.title);else if(_o.type==="error"&&typeof _o.message=="string"){const Yh=_o.message.replace(new RegExp("\\p{Cc}","gu"),"");le.pushNotice(`\r
971
971
  \x1B[31m${Yh}\x1B[0m\r
@@ -1032,7 +1032,7 @@ Please report this to https://github.com/markedjs/marked.`,t){const r="<p>An err
1032
1032
  `+Oe[S].replace(" at new "," at ");return m.displayName&&nt.includes("<anonymous>")&&(nt=nt.replace("<anonymous>",m.displayName)),nt}while(1<=S&&0<=j);break}}}finally{ot=!1,Error.prepareStackTrace=w}return(w=m?m.displayName||m.name:"")?Xe(w):""}function lt(m,b){switch(m.tag){case 26:case 27:case 5:return Xe(m.type);case 16:return Xe("Lazy");case 13:return m.child!==b&&b!==null?Xe("Suspense Fallback"):Xe("Suspense");case 19:return Xe("SuspenseList");case 0:case 15:return Qe(m.type,!1);case 11:return Qe(m.type.render,!1);case 1:return Qe(m.type,!0);case 31:return Xe("Activity");default:return""}}function bt(m){try{var b="",w=null;do b+=lt(m,w),w=m,m=m.return;while(m);return b}catch(S){return`
1033
1033
  Error generating stack: `+S.message+`
1034
1034
  `+S.stack}}var ve=Object.prototype.hasOwnProperty,Te=t.unstable_scheduleCallback,pe=t.unstable_cancelCallback,Ne=t.unstable_shouldYield,$e=t.unstable_requestPaint,De=t.unstable_now,ct=t.unstable_getCurrentPriorityLevel,ue=t.unstable_ImmediatePriority,Pe=t.unstable_UserBlockingPriority,Ee=t.unstable_NormalPriority,Le=t.unstable_LowPriority,et=t.unstable_IdlePriority,kt=t.log,tn=t.unstable_setDisableYieldValue,Kt=null,Dn=null;function Qt(m){if(typeof kt=="function"&&tn(m),Dn&&typeof Dn.setStrictMode=="function")try{Dn.setStrictMode(Kt,m)}catch{}}var Ve=Math.clz32?Math.clz32:Ye,Ct=Math.log,Mt=Math.LN2;function Ye(m){return m>>>=0,m===0?32:31-(Ct(m)/Mt|0)|0}var Pt=256,Dt=262144,Ut=4194304;function kn(m){var b=m&42;if(b!==0)return b;switch(m&-m){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return m&261888;case 262144:case 524288:case 1048576:case 2097152:return m&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return m&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return m}}function jt(m,b,w){var S=m.pendingLanes;if(S===0)return 0;var j=0,R=m.suspendedLanes,J=m.pingedLanes;m=m.warmLanes;var oe=S&134217727;return oe!==0?(S=oe&~R,S!==0?j=kn(S):(J&=oe,J!==0?j=kn(J):w||(w=oe&~m,w!==0&&(j=kn(w))))):(oe=S&~R,oe!==0?j=kn(oe):J!==0?j=kn(J):w||(w=S&~m,w!==0&&(j=kn(w)))),j===0?0:b!==0&&b!==j&&(b&R)===0&&(R=j&-j,w=b&-b,R>=w||R===32&&(w&4194048)!==0)?b:j}function pn(m,b){return(m.pendingLanes&~(m.suspendedLanes&~m.pingedLanes)&b)===0}function ke(m,b){switch(m){case 1:case 2:case 4:case 8:case 64:return b+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return b+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Ke(){var m=Ut;return Ut<<=1,(Ut&62914560)===0&&(Ut=4194304),m}function dt(m){for(var b=[],w=0;31>w;w++)b.push(m);return b}function sn(m,b){m.pendingLanes|=b,b!==268435456&&(m.suspendedLanes=0,m.pingedLanes=0,m.warmLanes=0)}function Yt(m,b,w,S,j,R){var J=m.pendingLanes;m.pendingLanes=w,m.suspendedLanes=0,m.pingedLanes=0,m.warmLanes=0,m.expiredLanes&=w,m.entangledLanes&=w,m.errorRecoveryDisabledLanes&=w,m.shellSuspendCounter=0;var oe=m.entanglements,Oe=m.expirationTimes,qe=m.hiddenUpdates;for(w=J&~w;0<w;){var nt=31-Ve(w),at=1<<nt;oe[nt]=0,Oe[nt]=-1;var Ue=qe[nt];if(Ue!==null)for(qe[nt]=null,nt=0;nt<Ue.length;nt++){var Ge=Ue[nt];Ge!==null&&(Ge.lane&=-536870913)}w&=~at}S!==0&&Wt(m,S,0),R!==0&&j===0&&m.tag!==0&&(m.suspendedLanes|=R&~(J&~b))}function Wt(m,b,w){m.pendingLanes|=b,m.suspendedLanes&=~b;var S=31-Ve(b);m.entangledLanes|=b,m.entanglements[S]=m.entanglements[S]|1073741824|w&261930}function ir(m,b){var w=m.entangledLanes|=b;for(m=m.entanglements;w;){var S=31-Ve(w),j=1<<S;j&b|m[S]&b&&(m[S]|=b),w&=~j}}function Nt(m,b){var w=b&-b;return w=(w&42)!==0?1:Xt(w),(w&(m.suspendedLanes|b))!==0?0:w}function Xt(m){switch(m){case 2:m=1;break;case 8:m=4;break;case 32:m=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:m=128;break;case 268435456:m=134217728;break;default:m=0}return m}function dn(m){return m&=-m,2<m?8<m?(m&134217727)!==0?32:268435456:8:2}function Kn(){var m=V.p;return m!==0?m:(m=window.event,m===void 0?32:sse(m.type))}function Ie(m,b){var w=V.p;try{return V.p=m,b()}finally{V.p=w}}var gt=Math.random().toString(36).slice(2),At="__reactFiber$"+gt,qt="__reactProps$"+gt,yr="__reactContainer$"+gt,Mn="__reactEvents$"+gt,Kr="__reactListeners$"+gt,as="__reactHandles$"+gt,Xs="__reactResources$"+gt,Zt="__reactMarker$"+gt;function Ae(m){delete m[At],delete m[qt],delete m[Mn],delete m[Kr],delete m[as]}function ht(m){var b=m[At];if(b)return b;for(var w=m.parentNode;w;){if(b=w[yr]||w[At]){if(w=b.alternate,b.child!==null||w!==null&&w.child!==null)for(m=Vie(m);m!==null;){if(w=m[At])return w;m=Vie(m)}return b}m=w,w=m.parentNode}return null}function zt(m){if(m=m[At]||m[yr]){var b=m.tag;if(b===5||b===6||b===13||b===31||b===26||b===27||b===3)return m}return null}function pr(m){var b=m.tag;if(b===5||b===26||b===27||b===6)return m.stateNode;throw Error(r(33))}function no(m){var b=m[Xs];return b||(b=m[Xs]={hoistableStyles:new Map,hoistableScripts:new Map}),b}function Yn(m){m[Zt]=!0}var ai=new Set,Ri={};function Ss(m,b){Ja(m,b),Ja(m+"Capture",b)}function Ja(m,b){for(Ri[m]=b,m=0;m<b.length;m++)ai.add(b[m])}var Qo=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Od={},Sd={};function oR(m){return ve.call(Sd,m)?!0:ve.call(Od,m)?!1:Qo.test(m)?Sd[m]=!0:(Od[m]=!0,!1)}function l0(m,b,w){if(oR(b))if(w===null)m.removeAttribute(b);else{switch(typeof w){case"undefined":case"function":case"symbol":m.removeAttribute(b);return;case"boolean":var S=b.toLowerCase().slice(0,5);if(S!=="data-"&&S!=="aria-"){m.removeAttribute(b);return}}m.setAttribute(b,""+w)}}function Zh(m,b,w){if(w===null)m.removeAttribute(b);else{switch(typeof w){case"undefined":case"function":case"symbol":case"boolean":m.removeAttribute(b);return}m.setAttribute(b,""+w)}}function c0(m,b,w,S){if(S===null)m.removeAttribute(w);else{switch(typeof S){case"undefined":case"function":case"symbol":case"boolean":m.removeAttribute(w);return}m.setAttributeNS(b,w,""+S)}}function ka(m){switch(typeof m){case"bigint":case"boolean":case"number":case"string":case"undefined":return m;case"object":return m;default:return""}}function Gh(m){var b=m.type;return(m=m.nodeName)&&m.toLowerCase()==="input"&&(b==="checkbox"||b==="radio")}function M8(m,b,w){var S=Object.getOwnPropertyDescriptor(m.constructor.prototype,b);if(!m.hasOwnProperty(b)&&typeof S<"u"&&typeof S.get=="function"&&typeof S.set=="function"){var j=S.get,R=S.set;return Object.defineProperty(m,b,{configurable:!0,get:function(){return j.call(this)},set:function(J){w=""+J,R.call(this,J)}}),Object.defineProperty(m,b,{enumerable:S.enumerable}),{getValue:function(){return w},setValue:function(J){w=""+J},stopTracking:function(){m._valueTracker=null,delete m[b]}}}}function Y4(m){if(!m._valueTracker){var b=Gh(m)?"checked":"value";m._valueTracker=M8(m,b,""+m[b])}}function st(m){if(!m)return!1;var b=m._valueTracker;if(!b)return!0;var w=b.getValue(),S="";return m&&(S=Gh(m)?m.checked?"true":"false":m.value),m=S,m!==w?(b.setValue(m),!0):!1}function Fn(m){if(m=m||(typeof document<"u"?document:void 0),typeof m>"u")return null;try{return m.activeElement||m.body}catch{return m.body}}var mr=/[\n"\\]/g;function Zo(m){return m.replace(mr,function(b){return"\\"+b.charCodeAt(0).toString(16)+" "})}function El(m,b,w,S,j,R,J,oe){m.name="",J!=null&&typeof J!="function"&&typeof J!="symbol"&&typeof J!="boolean"?m.type=J:m.removeAttribute("type"),b!=null?J==="number"?(b===0&&m.value===""||m.value!=b)&&(m.value=""+ka(b)):m.value!==""+ka(b)&&(m.value=""+ka(b)):J!=="submit"&&J!=="reset"||m.removeAttribute("value"),b!=null?Lu(m,J,ka(b)):w!=null?Lu(m,J,ka(w)):S!=null&&m.removeAttribute("value"),j==null&&R!=null&&(m.defaultChecked=!!R),j!=null&&(m.checked=j&&typeof j!="function"&&typeof j!="symbol"),oe!=null&&typeof oe!="function"&&typeof oe!="symbol"&&typeof oe!="boolean"?m.name=""+ka(oe):m.removeAttribute("name")}function X4(m,b,w,S,j,R,J,oe){if(R!=null&&typeof R!="function"&&typeof R!="symbol"&&typeof R!="boolean"&&(m.type=R),b!=null||w!=null){if(!(R!=="submit"&&R!=="reset"||b!=null)){Y4(m);return}w=w!=null?""+ka(w):"",b=b!=null?""+ka(b):w,oe||b===m.value||(m.value=b),m.defaultValue=b}S=S??j,S=typeof S!="function"&&typeof S!="symbol"&&!!S,m.checked=oe?m.checked:!!S,m.defaultChecked=!!S,J!=null&&typeof J!="function"&&typeof J!="symbol"&&typeof J!="boolean"&&(m.name=J),Y4(m)}function Lu(m,b,w){b==="number"&&Fn(m.ownerDocument)===m||m.defaultValue===""+w||(m.defaultValue=""+w)}function Ur(m,b,w,S){if(m=m.options,b){b={};for(var j=0;j<w.length;j++)b["$"+w[j]]=!0;for(w=0;w<m.length;w++)j=b.hasOwnProperty("$"+m[w].value),m[w].selected!==j&&(m[w].selected=j),j&&S&&(m[w].defaultSelected=!0)}else{for(w=""+ka(w),b=null,j=0;j<m.length;j++){if(m[j].value===w){m[j].selected=!0,S&&(m[j].defaultSelected=!0);return}b!==null||m[j].disabled||(b=m[j])}b!==null&&(b.selected=!0)}}function _o(m,b,w){if(b!=null&&(b=""+ka(b),b!==m.value&&(m.value=b),w==null)){m.defaultValue!==b&&(m.defaultValue=b);return}m.defaultValue=w!=null?""+ka(w):""}function Yh(m,b,w,S){if(b==null){if(S!=null){if(w!=null)throw Error(r(92));if(H(S)){if(1<S.length)throw Error(r(93));S=S[0]}w=S}w==null&&(w=""),b=w}w=ka(b),m.defaultValue=w,S=m.textContent,S===w&&S!==""&&S!==null&&(m.value=S),Y4(m)}function K4(m,b){if(b){var w=m.firstChild;if(w&&w===m.lastChild&&w.nodeType===3){w.nodeValue=b;return}}m.textContent=b}var JZe=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Nne(m,b,w){var S=b.indexOf("--")===0;w==null||typeof w=="boolean"||w===""?S?m.setProperty(b,""):b==="float"?m.cssFloat="":m[b]="":S?m.setProperty(b,w):typeof w!="number"||w===0||JZe.has(b)?b==="float"?m.cssFloat=w:m[b]=(""+w).trim():m[b]=w+"px"}function Rne(m,b,w){if(b!=null&&typeof b!="object")throw Error(r(62));if(m=m.style,w!=null){for(var S in w)!w.hasOwnProperty(S)||b!=null&&b.hasOwnProperty(S)||(S.indexOf("--")===0?m.setProperty(S,""):S==="float"?m.cssFloat="":m[S]="");for(var j in b)S=b[j],b.hasOwnProperty(j)&&w[j]!==S&&Nne(m,j,S)}else for(var R in b)b.hasOwnProperty(R)&&Nne(m,R,b[R])}function iR(m){if(m.indexOf("-")===-1)return!1;switch(m){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var eGe=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),tGe=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function hy(m){return tGe.test(""+m)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":m}function Iu(){}var sR=null;function aR(m){return m=m.target||m.srcElement||window,m.correspondingUseElement&&(m=m.correspondingUseElement),m.nodeType===3?m.parentNode:m}var J4=null,em=null;function Lne(m){var b=zt(m);if(b&&(m=b.stateNode)){var w=m[qt]||null;e:switch(m=b.stateNode,b.type){case"input":if(El(m,w.value,w.defaultValue,w.defaultValue,w.checked,w.defaultChecked,w.type,w.name),b=w.name,w.type==="radio"&&b!=null){for(w=m;w.parentNode;)w=w.parentNode;for(w=w.querySelectorAll('input[name="'+Zo(""+b)+'"][type="radio"]'),b=0;b<w.length;b++){var S=w[b];if(S!==m&&S.form===m.form){var j=S[qt]||null;if(!j)throw Error(r(90));El(S,j.value,j.defaultValue,j.defaultValue,j.checked,j.defaultChecked,j.type,j.name)}}for(b=0;b<w.length;b++)S=w[b],S.form===m.form&&st(S)}break e;case"textarea":_o(m,w.value,w.defaultValue);break e;case"select":b=w.value,b!=null&&Ur(m,!!w.multiple,b,!1)}}}var lR=!1;function Ine(m,b,w){if(lR)return m(b,w);lR=!0;try{var S=m(b);return S}finally{if(lR=!1,(J4!==null||em!==null)&&(ew(),J4&&(b=J4,m=em,em=J4=null,Lne(b),m)))for(b=0;b<m.length;b++)Lne(m[b])}}function P8(m,b){var w=m.stateNode;if(w===null)return null;var S=w[qt]||null;if(S===null)return null;w=S[b];e:switch(b){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(S=!S.disabled)||(m=m.type,S=!(m==="button"||m==="input"||m==="select"||m==="textarea")),m=!S;break e;default:m=!1}if(m)return null;if(w&&typeof w!="function")throw Error(r(231,b,typeof w));return w}var Du=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),cR=!1;if(Du)try{var j8={};Object.defineProperty(j8,"passive",{get:function(){cR=!0}}),window.addEventListener("test",j8,j8),window.removeEventListener("test",j8,j8)}catch{cR=!1}var Cd=null,uR=null,py=null;function Dne(){if(py)return py;var m,b=uR,w=b.length,S,j="value"in Cd?Cd.value:Cd.textContent,R=j.length;for(m=0;m<w&&b[m]===j[m];m++);var J=w-m;for(S=1;S<=J&&b[w-S]===j[R-S];S++);return py=j.slice(m,1<S?1-S:void 0)}function my(m){var b=m.keyCode;return"charCode"in m?(m=m.charCode,m===0&&b===13&&(m=13)):m=b,m===10&&(m=13),32<=m||m===13?m:0}function gy(){return!0}function zne(){return!1}function el(m){function b(w,S,j,R,J){this._reactName=w,this._targetInst=j,this.type=S,this.nativeEvent=R,this.target=J,this.currentTarget=null;for(var oe in m)m.hasOwnProperty(oe)&&(w=m[oe],this[oe]=w?w(R):R[oe]);return this.isDefaultPrevented=(R.defaultPrevented!=null?R.defaultPrevented:R.returnValue===!1)?gy:zne,this.isPropagationStopped=zne,this}return d(b.prototype,{preventDefault:function(){this.defaultPrevented=!0;var w=this.nativeEvent;w&&(w.preventDefault?w.preventDefault():typeof w.returnValue!="unknown"&&(w.returnValue=!1),this.isDefaultPrevented=gy)},stopPropagation:function(){var w=this.nativeEvent;w&&(w.stopPropagation?w.stopPropagation():typeof w.cancelBubble!="unknown"&&(w.cancelBubble=!0),this.isPropagationStopped=gy)},persist:function(){},isPersistent:gy}),b}var Xh={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(m){return m.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},vy=el(Xh),N8=d({},Xh,{view:0,detail:0}),nGe=el(N8),dR,fR,R8,by=d({},N8,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:pR,button:0,buttons:0,relatedTarget:function(m){return m.relatedTarget===void 0?m.fromElement===m.srcElement?m.toElement:m.fromElement:m.relatedTarget},movementX:function(m){return"movementX"in m?m.movementX:(m!==R8&&(R8&&m.type==="mousemove"?(dR=m.screenX-R8.screenX,fR=m.screenY-R8.screenY):fR=dR=0,R8=m),dR)},movementY:function(m){return"movementY"in m?m.movementY:fR}}),$ne=el(by),rGe=d({},by,{dataTransfer:0}),oGe=el(rGe),iGe=d({},N8,{relatedTarget:0}),hR=el(iGe),sGe=d({},Xh,{animationName:0,elapsedTime:0,pseudoElement:0}),aGe=el(sGe),lGe=d({},Xh,{clipboardData:function(m){return"clipboardData"in m?m.clipboardData:window.clipboardData}}),cGe=el(lGe),uGe=d({},Xh,{data:0}),Bne=el(uGe),dGe={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},fGe={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},hGe={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function pGe(m){var b=this.nativeEvent;return b.getModifierState?b.getModifierState(m):(m=hGe[m])?!!b[m]:!1}function pR(){return pGe}var mGe=d({},N8,{key:function(m){if(m.key){var b=dGe[m.key]||m.key;if(b!=="Unidentified")return b}return m.type==="keypress"?(m=my(m),m===13?"Enter":String.fromCharCode(m)):m.type==="keydown"||m.type==="keyup"?fGe[m.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:pR,charCode:function(m){return m.type==="keypress"?my(m):0},keyCode:function(m){return m.type==="keydown"||m.type==="keyup"?m.keyCode:0},which:function(m){return m.type==="keypress"?my(m):m.type==="keydown"||m.type==="keyup"?m.keyCode:0}}),gGe=el(mGe),vGe=d({},by,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Hne=el(vGe),bGe=d({},N8,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:pR}),_Ge=el(bGe),xGe=d({},Xh,{propertyName:0,elapsedTime:0,pseudoElement:0}),yGe=el(xGe),wGe=d({},by,{deltaX:function(m){return"deltaX"in m?m.deltaX:"wheelDeltaX"in m?-m.wheelDeltaX:0},deltaY:function(m){return"deltaY"in m?m.deltaY:"wheelDeltaY"in m?-m.wheelDeltaY:"wheelDelta"in m?-m.wheelDelta:0},deltaZ:0,deltaMode:0}),kGe=el(wGe),OGe=d({},Xh,{newState:0,oldState:0}),SGe=el(OGe),CGe=[9,13,27,32],mR=Du&&"CompositionEvent"in window,L8=null;Du&&"documentMode"in document&&(L8=document.documentMode);var AGe=Du&&"TextEvent"in window&&!L8,Fne=Du&&(!mR||L8&&8<L8&&11>=L8),qne=" ",Vne=!1;function Qne(m,b){switch(m){case"keyup":return CGe.indexOf(b.keyCode)!==-1;case"keydown":return b.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Une(m){return m=m.detail,typeof m=="object"&&"data"in m?m.data:null}var tm=!1;function EGe(m,b){switch(m){case"compositionend":return Une(b);case"keypress":return b.which!==32?null:(Vne=!0,qne);case"textInput":return m=b.data,m===qne&&Vne?null:m;default:return null}}function TGe(m,b){if(tm)return m==="compositionend"||!mR&&Qne(m,b)?(m=Dne(),py=uR=Cd=null,tm=!1,m):null;switch(m){case"paste":return null;case"keypress":if(!(b.ctrlKey||b.altKey||b.metaKey)||b.ctrlKey&&b.altKey){if(b.char&&1<b.char.length)return b.char;if(b.which)return String.fromCharCode(b.which)}return null;case"compositionend":return Fne&&b.locale!=="ko"?null:b.data;default:return null}}var MGe={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Wne(m){var b=m&&m.nodeName&&m.nodeName.toLowerCase();return b==="input"?!!MGe[m.type]:b==="textarea"}function Zne(m,b,w,S){J4?em?em.push(S):em=[S]:J4=S,b=aw(b,"onChange"),0<b.length&&(w=new vy("onChange","change",null,w,S),m.push({event:w,listeners:b}))}var I8=null,D8=null;function PGe(m){Mie(m,0)}function _y(m){var b=pr(m);if(st(b))return m}function Gne(m,b){if(m==="change")return b}var Yne=!1;if(Du){var gR;if(Du){var vR="oninput"in document;if(!vR){var Xne=document.createElement("div");Xne.setAttribute("oninput","return;"),vR=typeof Xne.oninput=="function"}gR=vR}else gR=!1;Yne=gR&&(!document.documentMode||9<document.documentMode)}function Kne(){I8&&(I8.detachEvent("onpropertychange",Jne),D8=I8=null)}function Jne(m){if(m.propertyName==="value"&&_y(D8)){var b=[];Zne(b,D8,m,aR(m)),Ine(PGe,b)}}function jGe(m,b,w){m==="focusin"?(Kne(),I8=b,D8=w,I8.attachEvent("onpropertychange",Jne)):m==="focusout"&&Kne()}function NGe(m){if(m==="selectionchange"||m==="keyup"||m==="keydown")return _y(D8)}function RGe(m,b){if(m==="click")return _y(b)}function LGe(m,b){if(m==="input"||m==="change")return _y(b)}function IGe(m,b){return m===b&&(m!==0||1/m===1/b)||m!==m&&b!==b}var Tl=typeof Object.is=="function"?Object.is:IGe;function z8(m,b){if(Tl(m,b))return!0;if(typeof m!="object"||m===null||typeof b!="object"||b===null)return!1;var w=Object.keys(m),S=Object.keys(b);if(w.length!==S.length)return!1;for(S=0;S<w.length;S++){var j=w[S];if(!ve.call(b,j)||!Tl(m[j],b[j]))return!1}return!0}function ere(m){for(;m&&m.firstChild;)m=m.firstChild;return m}function tre(m,b){var w=ere(m);m=0;for(var S;w;){if(w.nodeType===3){if(S=m+w.textContent.length,m<=b&&S>=b)return{node:w,offset:b-m};m=S}e:{for(;w;){if(w.nextSibling){w=w.nextSibling;break e}w=w.parentNode}w=void 0}w=ere(w)}}function nre(m,b){return m&&b?m===b?!0:m&&m.nodeType===3?!1:b&&b.nodeType===3?nre(m,b.parentNode):"contains"in m?m.contains(b):m.compareDocumentPosition?!!(m.compareDocumentPosition(b)&16):!1:!1}function rre(m){m=m!=null&&m.ownerDocument!=null&&m.ownerDocument.defaultView!=null?m.ownerDocument.defaultView:window;for(var b=Fn(m.document);b instanceof m.HTMLIFrameElement;){try{var w=typeof b.contentWindow.location.href=="string"}catch{w=!1}if(w)m=b.contentWindow;else break;b=Fn(m.document)}return b}function bR(m){var b=m&&m.nodeName&&m.nodeName.toLowerCase();return b&&(b==="input"&&(m.type==="text"||m.type==="search"||m.type==="tel"||m.type==="url"||m.type==="password")||b==="textarea"||m.contentEditable==="true")}var DGe=Du&&"documentMode"in document&&11>=document.documentMode,nm=null,_R=null,$8=null,xR=!1;function ore(m,b,w){var S=w.window===w?w.document:w.nodeType===9?w:w.ownerDocument;xR||nm==null||nm!==Fn(S)||(S=nm,"selectionStart"in S&&bR(S)?S={start:S.selectionStart,end:S.selectionEnd}:(S=(S.ownerDocument&&S.ownerDocument.defaultView||window).getSelection(),S={anchorNode:S.anchorNode,anchorOffset:S.anchorOffset,focusNode:S.focusNode,focusOffset:S.focusOffset}),$8&&z8($8,S)||($8=S,S=aw(_R,"onSelect"),0<S.length&&(b=new vy("onSelect","select",null,b,w),m.push({event:b,listeners:S}),b.target=nm)))}function Kh(m,b){var w={};return w[m.toLowerCase()]=b.toLowerCase(),w["Webkit"+m]="webkit"+b,w["Moz"+m]="moz"+b,w}var rm={animationend:Kh("Animation","AnimationEnd"),animationiteration:Kh("Animation","AnimationIteration"),animationstart:Kh("Animation","AnimationStart"),transitionrun:Kh("Transition","TransitionRun"),transitionstart:Kh("Transition","TransitionStart"),transitioncancel:Kh("Transition","TransitionCancel"),transitionend:Kh("Transition","TransitionEnd")},yR={},ire={};Du&&(ire=document.createElement("div").style,"AnimationEvent"in window||(delete rm.animationend.animation,delete rm.animationiteration.animation,delete rm.animationstart.animation),"TransitionEvent"in window||delete rm.transitionend.transition);function Jh(m){if(yR[m])return yR[m];if(!rm[m])return m;var b=rm[m],w;for(w in b)if(b.hasOwnProperty(w)&&w in ire)return yR[m]=b[w];return m}var sre=Jh("animationend"),are=Jh("animationiteration"),lre=Jh("animationstart"),zGe=Jh("transitionrun"),$Ge=Jh("transitionstart"),BGe=Jh("transitioncancel"),cre=Jh("transitionend"),ure=new Map,wR="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");wR.push("scrollEnd");function u0(m,b){ure.set(m,b),Ss(b,[m])}var xy=typeof reportError=="function"?reportError:function(m){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var b=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof m=="object"&&m!==null&&typeof m.message=="string"?String(m.message):String(m),error:m});if(!window.dispatchEvent(b))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",m);return}console.error(m)},cc=[],om=0,kR=0;function yy(){for(var m=om,b=kR=om=0;b<m;){var w=cc[b];cc[b++]=null;var S=cc[b];cc[b++]=null;var j=cc[b];cc[b++]=null;var R=cc[b];if(cc[b++]=null,S!==null&&j!==null){var J=S.pending;J===null?j.next=j:(j.next=J.next,J.next=j),S.pending=j}R!==0&&dre(w,j,R)}}function wy(m,b,w,S){cc[om++]=m,cc[om++]=b,cc[om++]=w,cc[om++]=S,kR|=S,m.lanes|=S,m=m.alternate,m!==null&&(m.lanes|=S)}function OR(m,b,w,S){return wy(m,b,w,S),ky(m)}function ep(m,b){return wy(m,null,null,b),ky(m)}function dre(m,b,w){m.lanes|=w;var S=m.alternate;S!==null&&(S.lanes|=w);for(var j=!1,R=m.return;R!==null;)R.childLanes|=w,S=R.alternate,S!==null&&(S.childLanes|=w),R.tag===22&&(m=R.stateNode,m===null||m._visibility&1||(j=!0)),m=R,R=R.return;return m.tag===3?(R=m.stateNode,j&&b!==null&&(j=31-Ve(w),m=R.hiddenUpdates,S=m[j],S===null?m[j]=[b]:S.push(b),b.lane=w|536870912),R):null}function ky(m){if(50<a7)throw a7=0,NL=null,Error(r(185));for(var b=m.return;b!==null;)m=b,b=m.return;return m.tag===3?m.stateNode:null}var im={};function HGe(m,b,w,S){this.tag=m,this.key=w,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=b,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=S,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ml(m,b,w,S){return new HGe(m,b,w,S)}function SR(m){return m=m.prototype,!(!m||!m.isReactComponent)}function zu(m,b){var w=m.alternate;return w===null?(w=Ml(m.tag,b,m.key,m.mode),w.elementType=m.elementType,w.type=m.type,w.stateNode=m.stateNode,w.alternate=m,m.alternate=w):(w.pendingProps=b,w.type=m.type,w.flags=0,w.subtreeFlags=0,w.deletions=null),w.flags=m.flags&65011712,w.childLanes=m.childLanes,w.lanes=m.lanes,w.child=m.child,w.memoizedProps=m.memoizedProps,w.memoizedState=m.memoizedState,w.updateQueue=m.updateQueue,b=m.dependencies,w.dependencies=b===null?null:{lanes:b.lanes,firstContext:b.firstContext},w.sibling=m.sibling,w.index=m.index,w.ref=m.ref,w.refCleanup=m.refCleanup,w}function fre(m,b){m.flags&=65011714;var w=m.alternate;return w===null?(m.childLanes=0,m.lanes=b,m.child=null,m.subtreeFlags=0,m.memoizedProps=null,m.memoizedState=null,m.updateQueue=null,m.dependencies=null,m.stateNode=null):(m.childLanes=w.childLanes,m.lanes=w.lanes,m.child=w.child,m.subtreeFlags=0,m.deletions=null,m.memoizedProps=w.memoizedProps,m.memoizedState=w.memoizedState,m.updateQueue=w.updateQueue,m.type=w.type,b=w.dependencies,m.dependencies=b===null?null:{lanes:b.lanes,firstContext:b.firstContext}),m}function Oy(m,b,w,S,j,R){var J=0;if(S=m,typeof m=="function")SR(m)&&(J=1);else if(typeof m=="string")J=UYe(m,w,ee.current)?26:m==="html"||m==="head"||m==="body"?27:5;else e:switch(m){case L:return m=Ml(31,w,b,j),m.elementType=L,m.lanes=R,m;case _:return tp(w.children,j,R,b);case x:J=8,j|=24;break;case y:return m=Ml(12,w,b,j|2),m.elementType=y,m.lanes=R,m;case A:return m=Ml(13,w,b,j),m.elementType=A,m.lanes=R,m;case E:return m=Ml(19,w,b,j),m.elementType=E,m.lanes=R,m;default:if(typeof m=="object"&&m!==null)switch(m.$$typeof){case O:J=10;break e;case k:J=9;break e;case C:J=11;break e;case M:J=14;break e;case P:J=16,S=null;break e}J=29,w=Error(r(130,m===null?"null":typeof m,"")),S=null}return b=Ml(J,w,b,j),b.elementType=m,b.type=S,b.lanes=R,b}function tp(m,b,w,S){return m=Ml(7,m,S,b),m.lanes=w,m}function CR(m,b,w){return m=Ml(6,m,null,b),m.lanes=w,m}function hre(m){var b=Ml(18,null,null,0);return b.stateNode=m,b}function AR(m,b,w){return b=Ml(4,m.children!==null?m.children:[],m.key,b),b.lanes=w,b.stateNode={containerInfo:m.containerInfo,pendingChildren:null,implementation:m.implementation},b}var pre=new WeakMap;function uc(m,b){if(typeof m=="object"&&m!==null){var w=pre.get(m);return w!==void 0?w:(b={value:m,source:b,stack:bt(b)},pre.set(m,b),b)}return{value:m,source:b,stack:bt(b)}}var sm=[],am=0,Sy=null,B8=0,dc=[],fc=0,Ad=null,c1=1,u1="";function $u(m,b){sm[am++]=B8,sm[am++]=Sy,Sy=m,B8=b}function mre(m,b,w){dc[fc++]=c1,dc[fc++]=u1,dc[fc++]=Ad,Ad=m;var S=c1;m=u1;var j=32-Ve(S)-1;S&=~(1<<j),w+=1;var R=32-Ve(b)+j;if(30<R){var J=j-j%5;R=(S&(1<<J)-1).toString(32),S>>=J,j-=J,c1=1<<32-Ve(b)+j|w<<j|S,u1=R+m}else c1=1<<R|w<<j|S,u1=m}function ER(m){m.return!==null&&($u(m,1),mre(m,1,0))}function TR(m){for(;m===Sy;)Sy=sm[--am],sm[am]=null,B8=sm[--am],sm[am]=null;for(;m===Ad;)Ad=dc[--fc],dc[fc]=null,u1=dc[--fc],dc[fc]=null,c1=dc[--fc],dc[fc]=null}function gre(m,b){dc[fc++]=c1,dc[fc++]=u1,dc[fc++]=Ad,c1=b.id,u1=b.overflow,Ad=m}var Cs=null,Oo=null,Er=!1,Ed=null,hc=!1,MR=Error(r(519));function Td(m){var b=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw H8(uc(b,m)),MR}function vre(m){var b=m.stateNode,w=m.type,S=m.memoizedProps;switch(b[At]=m,b[qt]=S,w){case"dialog":vr("cancel",b),vr("close",b);break;case"iframe":case"object":case"embed":vr("load",b);break;case"video":case"audio":for(w=0;w<c7.length;w++)vr(c7[w],b);break;case"source":vr("error",b);break;case"img":case"image":case"link":vr("error",b),vr("load",b);break;case"details":vr("toggle",b);break;case"input":vr("invalid",b),X4(b,S.value,S.defaultValue,S.checked,S.defaultChecked,S.type,S.name,!0);break;case"select":vr("invalid",b);break;case"textarea":vr("invalid",b),Yh(b,S.value,S.defaultValue,S.children)}w=S.children,typeof w!="string"&&typeof w!="number"&&typeof w!="bigint"||b.textContent===""+w||S.suppressHydrationWarning===!0||Rie(b.textContent,w)?(S.popover!=null&&(vr("beforetoggle",b),vr("toggle",b)),S.onScroll!=null&&vr("scroll",b),S.onScrollEnd!=null&&vr("scrollend",b),S.onClick!=null&&(b.onclick=Iu),b=!0):b=!1,b||Td(m,!0)}function bre(m){for(Cs=m.return;Cs;)switch(Cs.tag){case 5:case 31:case 13:hc=!1;return;case 27:case 3:hc=!0;return;default:Cs=Cs.return}}function lm(m){if(m!==Cs)return!1;if(!Er)return bre(m),Er=!0,!1;var b=m.tag,w;if((w=b!==3&&b!==27)&&((w=b===5)&&(w=m.type,w=!(w!=="form"&&w!=="button")||ZL(m.type,m.memoizedProps)),w=!w),w&&Oo&&Td(m),bre(m),b===13){if(m=m.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));Oo=qie(m)}else if(b===31){if(m=m.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));Oo=qie(m)}else b===27?(b=Oo,qd(m.type)?(m=JL,JL=null,Oo=m):Oo=b):Oo=Cs?mc(m.stateNode.nextSibling):null;return!0}function np(){Oo=Cs=null,Er=!1}function PR(){var m=Ed;return m!==null&&(ol===null?ol=m:ol.push.apply(ol,m),Ed=null),m}function H8(m){Ed===null?Ed=[m]:Ed.push(m)}var jR=Z(null),rp=null,Bu=null;function Md(m,b,w){B(jR,b._currentValue),b._currentValue=w}function Hu(m){m._currentValue=jR.current,U(jR)}function NR(m,b,w){for(;m!==null;){var S=m.alternate;if((m.childLanes&b)!==b?(m.childLanes|=b,S!==null&&(S.childLanes|=b)):S!==null&&(S.childLanes&b)!==b&&(S.childLanes|=b),m===w)break;m=m.return}}function RR(m,b,w,S){var j=m.child;for(j!==null&&(j.return=m);j!==null;){var R=j.dependencies;if(R!==null){var J=j.child;R=R.firstContext;e:for(;R!==null;){var oe=R;R=j;for(var Oe=0;Oe<b.length;Oe++)if(oe.context===b[Oe]){R.lanes|=w,oe=R.alternate,oe!==null&&(oe.lanes|=w),NR(R.return,w,m),S||(J=null);break e}R=oe.next}}else if(j.tag===18){if(J=j.return,J===null)throw Error(r(341));J.lanes|=w,R=J.alternate,R!==null&&(R.lanes|=w),NR(J,w,m),J=null}else J=j.child;if(J!==null)J.return=j;else for(J=j;J!==null;){if(J===m){J=null;break}if(j=J.sibling,j!==null){j.return=J.return,J=j;break}J=J.return}j=J}}function cm(m,b,w,S){m=null;for(var j=b,R=!1;j!==null;){if(!R){if((j.flags&524288)!==0)R=!0;else if((j.flags&262144)!==0)break}if(j.tag===10){var J=j.alternate;if(J===null)throw Error(r(387));if(J=J.memoizedProps,J!==null){var oe=j.type;Tl(j.pendingProps.value,J.value)||(m!==null?m.push(oe):m=[oe])}}else if(j===ae.current){if(J=j.alternate,J===null)throw Error(r(387));J.memoizedState.memoizedState!==j.memoizedState.memoizedState&&(m!==null?m.push(p7):m=[p7])}j=j.return}m!==null&&RR(b,m,w,S),b.flags|=262144}function Cy(m){for(m=m.firstContext;m!==null;){if(!Tl(m.context._currentValue,m.memoizedValue))return!0;m=m.next}return!1}function op(m){rp=m,Bu=null,m=m.dependencies,m!==null&&(m.firstContext=null)}function As(m){return _re(rp,m)}function Ay(m,b){return rp===null&&op(m),_re(m,b)}function _re(m,b){var w=b._currentValue;if(b={context:b,memoizedValue:w,next:null},Bu===null){if(m===null)throw Error(r(308));Bu=b,m.dependencies={lanes:0,firstContext:b},m.flags|=524288}else Bu=Bu.next=b;return w}var FGe=typeof AbortController<"u"?AbortController:function(){var m=[],b=this.signal={aborted:!1,addEventListener:function(w,S){m.push(S)}};this.abort=function(){b.aborted=!0,m.forEach(function(w){return w()})}},qGe=t.unstable_scheduleCallback,VGe=t.unstable_NormalPriority,bi={$$typeof:O,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function LR(){return{controller:new FGe,data:new Map,refCount:0}}function F8(m){m.refCount--,m.refCount===0&&qGe(VGe,function(){m.controller.abort()})}var q8=null,IR=0,um=0,dm=null;function QGe(m,b){if(q8===null){var w=q8=[];IR=0,um=$L(),dm={status:"pending",value:void 0,then:function(S){w.push(S)}}}return IR++,b.then(xre,xre),b}function xre(){if(--IR===0&&q8!==null){dm!==null&&(dm.status="fulfilled");var m=q8;q8=null,um=0,dm=null;for(var b=0;b<m.length;b++)(0,m[b])()}}function UGe(m,b){var w=[],S={status:"pending",value:null,reason:null,then:function(j){w.push(j)}};return m.then(function(){S.status="fulfilled",S.value=b;for(var j=0;j<w.length;j++)(0,w[j])(b)},function(j){for(S.status="rejected",S.reason=j,j=0;j<w.length;j++)(0,w[j])(void 0)}),S}var yre=N.S;N.S=function(m,b){oie=De(),typeof b=="object"&&b!==null&&typeof b.then=="function"&&QGe(m,b),yre!==null&&yre(m,b)};var ip=Z(null);function DR(){var m=ip.current;return m!==null?m:ho.pooledCache}function Ey(m,b){b===null?B(ip,ip.current):B(ip,b.pool)}function wre(){var m=DR();return m===null?null:{parent:bi._currentValue,pool:m}}var fm=Error(r(460)),zR=Error(r(474)),Ty=Error(r(542)),My={then:function(){}};function kre(m){return m=m.status,m==="fulfilled"||m==="rejected"}function Ore(m,b,w){switch(w=m[w],w===void 0?m.push(b):w!==b&&(b.then(Iu,Iu),b=w),b.status){case"fulfilled":return b.value;case"rejected":throw m=b.reason,Cre(m),m;default:if(typeof b.status=="string")b.then(Iu,Iu);else{if(m=ho,m!==null&&100<m.shellSuspendCounter)throw Error(r(482));m=b,m.status="pending",m.then(function(S){if(b.status==="pending"){var j=b;j.status="fulfilled",j.value=S}},function(S){if(b.status==="pending"){var j=b;j.status="rejected",j.reason=S}})}switch(b.status){case"fulfilled":return b.value;case"rejected":throw m=b.reason,Cre(m),m}throw ap=b,fm}}function sp(m){try{var b=m._init;return b(m._payload)}catch(w){throw w!==null&&typeof w=="object"&&typeof w.then=="function"?(ap=w,fm):w}}var ap=null;function Sre(){if(ap===null)throw Error(r(459));var m=ap;return ap=null,m}function Cre(m){if(m===fm||m===Ty)throw Error(r(483))}var hm=null,V8=0;function Py(m){var b=V8;return V8+=1,hm===null&&(hm=[]),Ore(hm,m,b)}function Q8(m,b){b=b.props.ref,m.ref=b!==void 0?b:null}function jy(m,b){throw b.$$typeof===h?Error(r(525)):(m=Object.prototype.toString.call(b),Error(r(31,m==="[object Object]"?"object with keys {"+Object.keys(b).join(", ")+"}":m)))}function Are(m){function b(Re,Me){if(m){var Fe=Re.deletions;Fe===null?(Re.deletions=[Me],Re.flags|=16):Fe.push(Me)}}function w(Re,Me){if(!m)return null;for(;Me!==null;)b(Re,Me),Me=Me.sibling;return null}function S(Re){for(var Me=new Map;Re!==null;)Re.key!==null?Me.set(Re.key,Re):Me.set(Re.index,Re),Re=Re.sibling;return Me}function j(Re,Me){return Re=zu(Re,Me),Re.index=0,Re.sibling=null,Re}function R(Re,Me,Fe){return Re.index=Fe,m?(Fe=Re.alternate,Fe!==null?(Fe=Fe.index,Fe<Me?(Re.flags|=67108866,Me):Fe):(Re.flags|=67108866,Me)):(Re.flags|=1048576,Me)}function J(Re){return m&&Re.alternate===null&&(Re.flags|=67108866),Re}function oe(Re,Me,Fe,rt){return Me===null||Me.tag!==6?(Me=CR(Fe,Re.mode,rt),Me.return=Re,Me):(Me=j(Me,Fe),Me.return=Re,Me)}function Oe(Re,Me,Fe,rt){var yn=Fe.type;return yn===_?nt(Re,Me,Fe.props.children,rt,Fe.key):Me!==null&&(Me.elementType===yn||typeof yn=="object"&&yn!==null&&yn.$$typeof===P&&sp(yn)===Me.type)?(Me=j(Me,Fe.props),Q8(Me,Fe),Me.return=Re,Me):(Me=Oy(Fe.type,Fe.key,Fe.props,null,Re.mode,rt),Q8(Me,Fe),Me.return=Re,Me)}function qe(Re,Me,Fe,rt){return Me===null||Me.tag!==4||Me.stateNode.containerInfo!==Fe.containerInfo||Me.stateNode.implementation!==Fe.implementation?(Me=AR(Fe,Re.mode,rt),Me.return=Re,Me):(Me=j(Me,Fe.children||[]),Me.return=Re,Me)}function nt(Re,Me,Fe,rt,yn){return Me===null||Me.tag!==7?(Me=tp(Fe,Re.mode,rt,yn),Me.return=Re,Me):(Me=j(Me,Fe),Me.return=Re,Me)}function at(Re,Me,Fe){if(typeof Me=="string"&&Me!==""||typeof Me=="number"||typeof Me=="bigint")return Me=CR(""+Me,Re.mode,Fe),Me.return=Re,Me;if(typeof Me=="object"&&Me!==null){switch(Me.$$typeof){case p:return Fe=Oy(Me.type,Me.key,Me.props,null,Re.mode,Fe),Q8(Fe,Me),Fe.return=Re,Fe;case g:return Me=AR(Me,Re.mode,Fe),Me.return=Re,Me;case P:return Me=sp(Me),at(Re,Me,Fe)}if(H(Me)||z(Me))return Me=tp(Me,Re.mode,Fe,null),Me.return=Re,Me;if(typeof Me.then=="function")return at(Re,Py(Me),Fe);if(Me.$$typeof===O)return at(Re,Ay(Re,Me),Fe);jy(Re,Me)}return null}function Ue(Re,Me,Fe,rt){var yn=Me!==null?Me.key:null;if(typeof Fe=="string"&&Fe!==""||typeof Fe=="number"||typeof Fe=="bigint")return yn!==null?null:oe(Re,Me,""+Fe,rt);if(typeof Fe=="object"&&Fe!==null){switch(Fe.$$typeof){case p:return Fe.key===yn?Oe(Re,Me,Fe,rt):null;case g:return Fe.key===yn?qe(Re,Me,Fe,rt):null;case P:return Fe=sp(Fe),Ue(Re,Me,Fe,rt)}if(H(Fe)||z(Fe))return yn!==null?null:nt(Re,Me,Fe,rt,null);if(typeof Fe.then=="function")return Ue(Re,Me,Py(Fe),rt);if(Fe.$$typeof===O)return Ue(Re,Me,Ay(Re,Fe),rt);jy(Re,Fe)}return null}function Ge(Re,Me,Fe,rt,yn){if(typeof rt=="string"&&rt!==""||typeof rt=="number"||typeof rt=="bigint")return Re=Re.get(Fe)||null,oe(Me,Re,""+rt,yn);if(typeof rt=="object"&&rt!==null){switch(rt.$$typeof){case p:return Re=Re.get(rt.key===null?Fe:rt.key)||null,Oe(Me,Re,rt,yn);case g:return Re=Re.get(rt.key===null?Fe:rt.key)||null,qe(Me,Re,rt,yn);case P:return rt=sp(rt),Ge(Re,Me,Fe,rt,yn)}if(H(rt)||z(rt))return Re=Re.get(Fe)||null,nt(Me,Re,rt,yn,null);if(typeof rt.then=="function")return Ge(Re,Me,Fe,Py(rt),yn);if(rt.$$typeof===O)return Ge(Re,Me,Fe,Ay(Me,rt),yn);jy(Me,rt)}return null}function en(Re,Me,Fe,rt){for(var yn=null,Br=null,hn=Me,Jn=Me=0,kr=null;hn!==null&&Jn<Fe.length;Jn++){hn.index>Jn?(kr=hn,hn=null):kr=hn.sibling;var Hr=Ue(Re,hn,Fe[Jn],rt);if(Hr===null){hn===null&&(hn=kr);break}m&&hn&&Hr.alternate===null&&b(Re,hn),Me=R(Hr,Me,Jn),Br===null?yn=Hr:Br.sibling=Hr,Br=Hr,hn=kr}if(Jn===Fe.length)return w(Re,hn),Er&&$u(Re,Jn),yn;if(hn===null){for(;Jn<Fe.length;Jn++)hn=at(Re,Fe[Jn],rt),hn!==null&&(Me=R(hn,Me,Jn),Br===null?yn=hn:Br.sibling=hn,Br=hn);return Er&&$u(Re,Jn),yn}for(hn=S(hn);Jn<Fe.length;Jn++)kr=Ge(hn,Re,Jn,Fe[Jn],rt),kr!==null&&(m&&kr.alternate!==null&&hn.delete(kr.key===null?Jn:kr.key),Me=R(kr,Me,Jn),Br===null?yn=kr:Br.sibling=kr,Br=kr);return m&&hn.forEach(function(Zd){return b(Re,Zd)}),Er&&$u(Re,Jn),yn}function Pn(Re,Me,Fe,rt){if(Fe==null)throw Error(r(151));for(var yn=null,Br=null,hn=Me,Jn=Me=0,kr=null,Hr=Fe.next();hn!==null&&!Hr.done;Jn++,Hr=Fe.next()){hn.index>Jn?(kr=hn,hn=null):kr=hn.sibling;var Zd=Ue(Re,hn,Hr.value,rt);if(Zd===null){hn===null&&(hn=kr);break}m&&hn&&Zd.alternate===null&&b(Re,hn),Me=R(Zd,Me,Jn),Br===null?yn=Zd:Br.sibling=Zd,Br=Zd,hn=kr}if(Hr.done)return w(Re,hn),Er&&$u(Re,Jn),yn;if(hn===null){for(;!Hr.done;Jn++,Hr=Fe.next())Hr=at(Re,Hr.value,rt),Hr!==null&&(Me=R(Hr,Me,Jn),Br===null?yn=Hr:Br.sibling=Hr,Br=Hr);return Er&&$u(Re,Jn),yn}for(hn=S(hn);!Hr.done;Jn++,Hr=Fe.next())Hr=Ge(hn,Re,Jn,Hr.value,rt),Hr!==null&&(m&&Hr.alternate!==null&&hn.delete(Hr.key===null?Jn:Hr.key),Me=R(Hr,Me,Jn),Br===null?yn=Hr:Br.sibling=Hr,Br=Hr);return m&&hn.forEach(function(rXe){return b(Re,rXe)}),Er&&$u(Re,Jn),yn}function io(Re,Me,Fe,rt){if(typeof Fe=="object"&&Fe!==null&&Fe.type===_&&Fe.key===null&&(Fe=Fe.props.children),typeof Fe=="object"&&Fe!==null){switch(Fe.$$typeof){case p:e:{for(var yn=Fe.key;Me!==null;){if(Me.key===yn){if(yn=Fe.type,yn===_){if(Me.tag===7){w(Re,Me.sibling),rt=j(Me,Fe.props.children),rt.return=Re,Re=rt;break e}}else if(Me.elementType===yn||typeof yn=="object"&&yn!==null&&yn.$$typeof===P&&sp(yn)===Me.type){w(Re,Me.sibling),rt=j(Me,Fe.props),Q8(rt,Fe),rt.return=Re,Re=rt;break e}w(Re,Me);break}else b(Re,Me);Me=Me.sibling}Fe.type===_?(rt=tp(Fe.props.children,Re.mode,rt,Fe.key),rt.return=Re,Re=rt):(rt=Oy(Fe.type,Fe.key,Fe.props,null,Re.mode,rt),Q8(rt,Fe),rt.return=Re,Re=rt)}return J(Re);case g:e:{for(yn=Fe.key;Me!==null;){if(Me.key===yn)if(Me.tag===4&&Me.stateNode.containerInfo===Fe.containerInfo&&Me.stateNode.implementation===Fe.implementation){w(Re,Me.sibling),rt=j(Me,Fe.children||[]),rt.return=Re,Re=rt;break e}else{w(Re,Me);break}else b(Re,Me);Me=Me.sibling}rt=AR(Fe,Re.mode,rt),rt.return=Re,Re=rt}return J(Re);case P:return Fe=sp(Fe),io(Re,Me,Fe,rt)}if(H(Fe))return en(Re,Me,Fe,rt);if(z(Fe)){if(yn=z(Fe),typeof yn!="function")throw Error(r(150));return Fe=yn.call(Fe),Pn(Re,Me,Fe,rt)}if(typeof Fe.then=="function")return io(Re,Me,Py(Fe),rt);if(Fe.$$typeof===O)return io(Re,Me,Ay(Re,Fe),rt);jy(Re,Fe)}return typeof Fe=="string"&&Fe!==""||typeof Fe=="number"||typeof Fe=="bigint"?(Fe=""+Fe,Me!==null&&Me.tag===6?(w(Re,Me.sibling),rt=j(Me,Fe),rt.return=Re,Re=rt):(w(Re,Me),rt=CR(Fe,Re.mode,rt),rt.return=Re,Re=rt),J(Re)):w(Re,Me)}return function(Re,Me,Fe,rt){try{V8=0;var yn=io(Re,Me,Fe,rt);return hm=null,yn}catch(hn){if(hn===fm||hn===Ty)throw hn;var Br=Ml(29,hn,null,Re.mode);return Br.lanes=rt,Br.return=Re,Br}}}var lp=Are(!0),Ere=Are(!1),Pd=!1;function $R(m){m.updateQueue={baseState:m.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function BR(m,b){m=m.updateQueue,b.updateQueue===m&&(b.updateQueue={baseState:m.baseState,firstBaseUpdate:m.firstBaseUpdate,lastBaseUpdate:m.lastBaseUpdate,shared:m.shared,callbacks:null})}function jd(m){return{lane:m,tag:0,payload:null,callback:null,next:null}}function Nd(m,b,w){var S=m.updateQueue;if(S===null)return null;if(S=S.shared,(Wr&2)!==0){var j=S.pending;return j===null?b.next=b:(b.next=j.next,j.next=b),S.pending=b,b=ky(m),dre(m,null,w),b}return wy(m,S,b,w),ky(m)}function U8(m,b,w){if(b=b.updateQueue,b!==null&&(b=b.shared,(w&4194048)!==0)){var S=b.lanes;S&=m.pendingLanes,w|=S,b.lanes=w,ir(m,w)}}function HR(m,b){var w=m.updateQueue,S=m.alternate;if(S!==null&&(S=S.updateQueue,w===S)){var j=null,R=null;if(w=w.firstBaseUpdate,w!==null){do{var J={lane:w.lane,tag:w.tag,payload:w.payload,callback:null,next:null};R===null?j=R=J:R=R.next=J,w=w.next}while(w!==null);R===null?j=R=b:R=R.next=b}else j=R=b;w={baseState:S.baseState,firstBaseUpdate:j,lastBaseUpdate:R,shared:S.shared,callbacks:S.callbacks},m.updateQueue=w;return}m=w.lastBaseUpdate,m===null?w.firstBaseUpdate=b:m.next=b,w.lastBaseUpdate=b}var FR=!1;function W8(){if(FR){var m=dm;if(m!==null)throw m}}function Z8(m,b,w,S){FR=!1;var j=m.updateQueue;Pd=!1;var R=j.firstBaseUpdate,J=j.lastBaseUpdate,oe=j.shared.pending;if(oe!==null){j.shared.pending=null;var Oe=oe,qe=Oe.next;Oe.next=null,J===null?R=qe:J.next=qe,J=Oe;var nt=m.alternate;nt!==null&&(nt=nt.updateQueue,oe=nt.lastBaseUpdate,oe!==J&&(oe===null?nt.firstBaseUpdate=qe:oe.next=qe,nt.lastBaseUpdate=Oe))}if(R!==null){var at=j.baseState;J=0,nt=qe=Oe=null,oe=R;do{var Ue=oe.lane&-536870913,Ge=Ue!==oe.lane;if(Ge?(wr&Ue)===Ue:(S&Ue)===Ue){Ue!==0&&Ue===um&&(FR=!0),nt!==null&&(nt=nt.next={lane:0,tag:oe.tag,payload:oe.payload,callback:null,next:null});e:{var en=m,Pn=oe;Ue=b;var io=w;switch(Pn.tag){case 1:if(en=Pn.payload,typeof en=="function"){at=en.call(io,at,Ue);break e}at=en;break e;case 3:en.flags=en.flags&-65537|128;case 0:if(en=Pn.payload,Ue=typeof en=="function"?en.call(io,at,Ue):en,Ue==null)break e;at=d({},at,Ue);break e;case 2:Pd=!0}}Ue=oe.callback,Ue!==null&&(m.flags|=64,Ge&&(m.flags|=8192),Ge=j.callbacks,Ge===null?j.callbacks=[Ue]:Ge.push(Ue))}else Ge={lane:Ue,tag:oe.tag,payload:oe.payload,callback:oe.callback,next:null},nt===null?(qe=nt=Ge,Oe=at):nt=nt.next=Ge,J|=Ue;if(oe=oe.next,oe===null){if(oe=j.shared.pending,oe===null)break;Ge=oe,oe=Ge.next,Ge.next=null,j.lastBaseUpdate=Ge,j.shared.pending=null}}while(!0);nt===null&&(Oe=at),j.baseState=Oe,j.firstBaseUpdate=qe,j.lastBaseUpdate=nt,R===null&&(j.shared.lanes=0),zd|=J,m.lanes=J,m.memoizedState=at}}function Tre(m,b){if(typeof m!="function")throw Error(r(191,m));m.call(b)}function Mre(m,b){var w=m.callbacks;if(w!==null)for(m.callbacks=null,m=0;m<w.length;m++)Tre(w[m],b)}var pm=Z(null),Ny=Z(0);function Pre(m,b){m=Yu,B(Ny,m),B(pm,b),Yu=m|b.baseLanes}function qR(){B(Ny,Yu),B(pm,pm.current)}function VR(){Yu=Ny.current,U(pm),U(Ny)}var Pl=Z(null),pc=null;function Rd(m){var b=m.alternate;B(li,li.current&1),B(Pl,m),pc===null&&(b===null||pm.current!==null||b.memoizedState!==null)&&(pc=m)}function QR(m){B(li,li.current),B(Pl,m),pc===null&&(pc=m)}function jre(m){m.tag===22?(B(li,li.current),B(Pl,m),pc===null&&(pc=m)):Ld()}function Ld(){B(li,li.current),B(Pl,Pl.current)}function jl(m){U(Pl),pc===m&&(pc=null),U(li)}var li=Z(0);function Ry(m){for(var b=m;b!==null;){if(b.tag===13){var w=b.memoizedState;if(w!==null&&(w=w.dehydrated,w===null||XL(w)||KL(w)))return b}else if(b.tag===19&&(b.memoizedProps.revealOrder==="forwards"||b.memoizedProps.revealOrder==="backwards"||b.memoizedProps.revealOrder==="unstable_legacy-backwards"||b.memoizedProps.revealOrder==="together")){if((b.flags&128)!==0)return b}else if(b.child!==null){b.child.return=b,b=b.child;continue}if(b===m)break;for(;b.sibling===null;){if(b.return===null||b.return===m)return null;b=b.return}b.sibling.return=b.return,b=b.sibling}return null}var Fu=0,Xn=null,ro=null,_i=null,Ly=!1,mm=!1,cp=!1,Iy=0,G8=0,gm=null,WGe=0;function Go(){throw Error(r(321))}function UR(m,b){if(b===null)return!1;for(var w=0;w<b.length&&w<m.length;w++)if(!Tl(m[w],b[w]))return!1;return!0}function WR(m,b,w,S,j,R){return Fu=R,Xn=b,b.memoizedState=null,b.updateQueue=null,b.lanes=0,N.H=m===null||m.memoizedState===null?moe:lL,cp=!1,R=w(S,j),cp=!1,mm&&(R=Rre(b,w,S,j)),Nre(m),R}function Nre(m){N.H=K8;var b=ro!==null&&ro.next!==null;if(Fu=0,_i=ro=Xn=null,Ly=!1,G8=0,gm=null,b)throw Error(r(300));m===null||xi||(m=m.dependencies,m!==null&&Cy(m)&&(xi=!0))}function Rre(m,b,w,S){Xn=m;var j=0;do{if(mm&&(gm=null),G8=0,mm=!1,25<=j)throw Error(r(301));if(j+=1,_i=ro=null,m.updateQueue!=null){var R=m.updateQueue;R.lastEffect=null,R.events=null,R.stores=null,R.memoCache!=null&&(R.memoCache.index=0)}N.H=goe,R=b(w,S)}while(mm);return R}function ZGe(){var m=N.H,b=m.useState()[0];return b=typeof b.then=="function"?Y8(b):b,m=m.useState()[0],(ro!==null?ro.memoizedState:null)!==m&&(Xn.flags|=1024),b}function ZR(){var m=Iy!==0;return Iy=0,m}function GR(m,b,w){b.updateQueue=m.updateQueue,b.flags&=-2053,m.lanes&=~w}function YR(m){if(Ly){for(m=m.memoizedState;m!==null;){var b=m.queue;b!==null&&(b.pending=null),m=m.next}Ly=!1}Fu=0,_i=ro=Xn=null,mm=!1,G8=Iy=0,gm=null}function Oa(){var m={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return _i===null?Xn.memoizedState=_i=m:_i=_i.next=m,_i}function ci(){if(ro===null){var m=Xn.alternate;m=m!==null?m.memoizedState:null}else m=ro.next;var b=_i===null?Xn.memoizedState:_i.next;if(b!==null)_i=b,ro=m;else{if(m===null)throw Xn.alternate===null?Error(r(467)):Error(r(310));ro=m,m={memoizedState:ro.memoizedState,baseState:ro.baseState,baseQueue:ro.baseQueue,queue:ro.queue,next:null},_i===null?Xn.memoizedState=_i=m:_i=_i.next=m}return _i}function Dy(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Y8(m){var b=G8;return G8+=1,gm===null&&(gm=[]),m=Ore(gm,m,b),b=Xn,(_i===null?b.memoizedState:_i.next)===null&&(b=b.alternate,N.H=b===null||b.memoizedState===null?moe:lL),m}function zy(m){if(m!==null&&typeof m=="object"){if(typeof m.then=="function")return Y8(m);if(m.$$typeof===O)return As(m)}throw Error(r(438,String(m)))}function XR(m){var b=null,w=Xn.updateQueue;if(w!==null&&(b=w.memoCache),b==null){var S=Xn.alternate;S!==null&&(S=S.updateQueue,S!==null&&(S=S.memoCache,S!=null&&(b={data:S.data.map(function(j){return j.slice()}),index:0})))}if(b==null&&(b={data:[],index:0}),w===null&&(w=Dy(),Xn.updateQueue=w),w.memoCache=b,w=b.data[b.index],w===void 0)for(w=b.data[b.index]=Array(m),S=0;S<m;S++)w[S]=D;return b.index++,w}function qu(m,b){return typeof b=="function"?b(m):b}function $y(m){var b=ci();return KR(b,ro,m)}function KR(m,b,w){var S=m.queue;if(S===null)throw Error(r(311));S.lastRenderedReducer=w;var j=m.baseQueue,R=S.pending;if(R!==null){if(j!==null){var J=j.next;j.next=R.next,R.next=J}b.baseQueue=j=R,S.pending=null}if(R=m.baseState,j===null)m.memoizedState=R;else{b=j.next;var oe=J=null,Oe=null,qe=b,nt=!1;do{var at=qe.lane&-536870913;if(at!==qe.lane?(wr&at)===at:(Fu&at)===at){var Ue=qe.revertLane;if(Ue===0)Oe!==null&&(Oe=Oe.next={lane:0,revertLane:0,gesture:null,action:qe.action,hasEagerState:qe.hasEagerState,eagerState:qe.eagerState,next:null}),at===um&&(nt=!0);else if((Fu&Ue)===Ue){qe=qe.next,Ue===um&&(nt=!0);continue}else at={lane:0,revertLane:qe.revertLane,gesture:null,action:qe.action,hasEagerState:qe.hasEagerState,eagerState:qe.eagerState,next:null},Oe===null?(oe=Oe=at,J=R):Oe=Oe.next=at,Xn.lanes|=Ue,zd|=Ue;at=qe.action,cp&&w(R,at),R=qe.hasEagerState?qe.eagerState:w(R,at)}else Ue={lane:at,revertLane:qe.revertLane,gesture:qe.gesture,action:qe.action,hasEagerState:qe.hasEagerState,eagerState:qe.eagerState,next:null},Oe===null?(oe=Oe=Ue,J=R):Oe=Oe.next=Ue,Xn.lanes|=at,zd|=at;qe=qe.next}while(qe!==null&&qe!==b);if(Oe===null?J=R:Oe.next=oe,!Tl(R,m.memoizedState)&&(xi=!0,nt&&(w=dm,w!==null)))throw w;m.memoizedState=R,m.baseState=J,m.baseQueue=Oe,S.lastRenderedState=R}return j===null&&(S.lanes=0),[m.memoizedState,S.dispatch]}function JR(m){var b=ci(),w=b.queue;if(w===null)throw Error(r(311));w.lastRenderedReducer=m;var S=w.dispatch,j=w.pending,R=b.memoizedState;if(j!==null){w.pending=null;var J=j=j.next;do R=m(R,J.action),J=J.next;while(J!==j);Tl(R,b.memoizedState)||(xi=!0),b.memoizedState=R,b.baseQueue===null&&(b.baseState=R),w.lastRenderedState=R}return[R,S]}function Lre(m,b,w){var S=Xn,j=ci(),R=Er;if(R){if(w===void 0)throw Error(r(407));w=w()}else w=b();var J=!Tl((ro||j).memoizedState,w);if(J&&(j.memoizedState=w,xi=!0),j=j.queue,nL(zre.bind(null,S,j,m),[m]),j.getSnapshot!==b||J||_i!==null&&_i.memoizedState.tag&1){if(S.flags|=2048,vm(9,{destroy:void 0},Dre.bind(null,S,j,w,b),null),ho===null)throw Error(r(349));R||(Fu&127)!==0||Ire(S,b,w)}return w}function Ire(m,b,w){m.flags|=16384,m={getSnapshot:b,value:w},b=Xn.updateQueue,b===null?(b=Dy(),Xn.updateQueue=b,b.stores=[m]):(w=b.stores,w===null?b.stores=[m]:w.push(m))}function Dre(m,b,w,S){b.value=w,b.getSnapshot=S,$re(b)&&Bre(m)}function zre(m,b,w){return w(function(){$re(b)&&Bre(m)})}function $re(m){var b=m.getSnapshot;m=m.value;try{var w=b();return!Tl(m,w)}catch{return!0}}function Bre(m){var b=ep(m,2);b!==null&&il(b,m,2)}function eL(m){var b=Oa();if(typeof m=="function"){var w=m;if(m=w(),cp){Qt(!0);try{w()}finally{Qt(!1)}}}return b.memoizedState=b.baseState=m,b.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:qu,lastRenderedState:m},b}function Hre(m,b,w,S){return m.baseState=w,KR(m,ro,typeof S=="function"?S:qu)}function GGe(m,b,w,S,j){if(Fy(m))throw Error(r(485));if(m=b.action,m!==null){var R={payload:j,action:m,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(J){R.listeners.push(J)}};N.T!==null?w(!0):R.isTransition=!1,S(R),w=b.pending,w===null?(R.next=b.pending=R,Fre(b,R)):(R.next=w.next,b.pending=w.next=R)}}function Fre(m,b){var w=b.action,S=b.payload,j=m.state;if(b.isTransition){var R=N.T,J={};N.T=J;try{var oe=w(j,S),Oe=N.S;Oe!==null&&Oe(J,oe),qre(m,b,oe)}catch(qe){tL(m,b,qe)}finally{R!==null&&J.types!==null&&(R.types=J.types),N.T=R}}else try{R=w(j,S),qre(m,b,R)}catch(qe){tL(m,b,qe)}}function qre(m,b,w){w!==null&&typeof w=="object"&&typeof w.then=="function"?w.then(function(S){Vre(m,b,S)},function(S){return tL(m,b,S)}):Vre(m,b,w)}function Vre(m,b,w){b.status="fulfilled",b.value=w,Qre(b),m.state=w,b=m.pending,b!==null&&(w=b.next,w===b?m.pending=null:(w=w.next,b.next=w,Fre(m,w)))}function tL(m,b,w){var S=m.pending;if(m.pending=null,S!==null){S=S.next;do b.status="rejected",b.reason=w,Qre(b),b=b.next;while(b!==S)}m.action=null}function Qre(m){m=m.listeners;for(var b=0;b<m.length;b++)(0,m[b])()}function Ure(m,b){return b}function Wre(m,b){if(Er){var w=ho.formState;if(w!==null){e:{var S=Xn;if(Er){if(Oo){t:{for(var j=Oo,R=hc;j.nodeType!==8;){if(!R){j=null;break t}if(j=mc(j.nextSibling),j===null){j=null;break t}}R=j.data,j=R==="F!"||R==="F"?j:null}if(j){Oo=mc(j.nextSibling),S=j.data==="F!";break e}}Td(S)}S=!1}S&&(b=w[0])}}return w=Oa(),w.memoizedState=w.baseState=b,S={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ure,lastRenderedState:b},w.queue=S,w=foe.bind(null,Xn,S),S.dispatch=w,S=eL(!1),R=aL.bind(null,Xn,!1,S.queue),S=Oa(),j={state:b,dispatch:null,action:m,pending:null},S.queue=j,w=GGe.bind(null,Xn,j,R,w),j.dispatch=w,S.memoizedState=m,[b,w,!1]}function Zre(m){var b=ci();return Gre(b,ro,m)}function Gre(m,b,w){if(b=KR(m,b,Ure)[0],m=$y(qu)[0],typeof b=="object"&&b!==null&&typeof b.then=="function")try{var S=Y8(b)}catch(J){throw J===fm?Ty:J}else S=b;b=ci();var j=b.queue,R=j.dispatch;return w!==b.memoizedState&&(Xn.flags|=2048,vm(9,{destroy:void 0},YGe.bind(null,j,w),null)),[S,R,m]}function YGe(m,b){m.action=b}function Yre(m){var b=ci(),w=ro;if(w!==null)return Gre(b,w,m);ci(),b=b.memoizedState,w=ci();var S=w.queue.dispatch;return w.memoizedState=m,[b,S,!1]}function vm(m,b,w,S){return m={tag:m,create:w,deps:S,inst:b,next:null},b=Xn.updateQueue,b===null&&(b=Dy(),Xn.updateQueue=b),w=b.lastEffect,w===null?b.lastEffect=m.next=m:(S=w.next,w.next=m,m.next=S,b.lastEffect=m),m}function Xre(){return ci().memoizedState}function By(m,b,w,S){var j=Oa();Xn.flags|=m,j.memoizedState=vm(1|b,{destroy:void 0},w,S===void 0?null:S)}function Hy(m,b,w,S){var j=ci();S=S===void 0?null:S;var R=j.memoizedState.inst;ro!==null&&S!==null&&UR(S,ro.memoizedState.deps)?j.memoizedState=vm(b,R,w,S):(Xn.flags|=m,j.memoizedState=vm(1|b,R,w,S))}function Kre(m,b){By(8390656,8,m,b)}function nL(m,b){Hy(2048,8,m,b)}function XGe(m){Xn.flags|=4;var b=Xn.updateQueue;if(b===null)b=Dy(),Xn.updateQueue=b,b.events=[m];else{var w=b.events;w===null?b.events=[m]:w.push(m)}}function Jre(m){var b=ci().memoizedState;return XGe({ref:b,nextImpl:m}),function(){if((Wr&2)!==0)throw Error(r(440));return b.impl.apply(void 0,arguments)}}function eoe(m,b){return Hy(4,2,m,b)}function toe(m,b){return Hy(4,4,m,b)}function noe(m,b){if(typeof b=="function"){m=m();var w=b(m);return function(){typeof w=="function"?w():b(null)}}if(b!=null)return m=m(),b.current=m,function(){b.current=null}}function roe(m,b,w){w=w!=null?w.concat([m]):null,Hy(4,4,noe.bind(null,b,m),w)}function rL(){}function ooe(m,b){var w=ci();b=b===void 0?null:b;var S=w.memoizedState;return b!==null&&UR(b,S[1])?S[0]:(w.memoizedState=[m,b],m)}function ioe(m,b){var w=ci();b=b===void 0?null:b;var S=w.memoizedState;if(b!==null&&UR(b,S[1]))return S[0];if(S=m(),cp){Qt(!0);try{m()}finally{Qt(!1)}}return w.memoizedState=[S,b],S}function oL(m,b,w){return w===void 0||(Fu&1073741824)!==0&&(wr&261930)===0?m.memoizedState=b:(m.memoizedState=w,m=sie(),Xn.lanes|=m,zd|=m,w)}function soe(m,b,w,S){return Tl(w,b)?w:pm.current!==null?(m=oL(m,w,S),Tl(m,b)||(xi=!0),m):(Fu&42)===0||(Fu&1073741824)!==0&&(wr&261930)===0?(xi=!0,m.memoizedState=w):(m=sie(),Xn.lanes|=m,zd|=m,b)}function aoe(m,b,w,S,j){var R=V.p;V.p=R!==0&&8>R?R:8;var J=N.T,oe={};N.T=oe,aL(m,!1,b,w);try{var Oe=j(),qe=N.S;if(qe!==null&&qe(oe,Oe),Oe!==null&&typeof Oe=="object"&&typeof Oe.then=="function"){var nt=UGe(Oe,S);X8(m,b,nt,Ll(m))}else X8(m,b,S,Ll(m))}catch(at){X8(m,b,{then:function(){},status:"rejected",reason:at},Ll())}finally{V.p=R,J!==null&&oe.types!==null&&(J.types=oe.types),N.T=J}}function KGe(){}function iL(m,b,w,S){if(m.tag!==5)throw Error(r(476));var j=loe(m).queue;aoe(m,j,b,G,w===null?KGe:function(){return coe(m),w(S)})}function loe(m){var b=m.memoizedState;if(b!==null)return b;b={memoizedState:G,baseState:G,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:qu,lastRenderedState:G},next:null};var w={};return b.next={memoizedState:w,baseState:w,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:qu,lastRenderedState:w},next:null},m.memoizedState=b,m=m.alternate,m!==null&&(m.memoizedState=b),b}function coe(m){var b=loe(m);b.next===null&&(b=m.alternate.memoizedState),X8(m,b.next.queue,{},Ll())}function sL(){return As(p7)}function uoe(){return ci().memoizedState}function doe(){return ci().memoizedState}function JGe(m){for(var b=m.return;b!==null;){switch(b.tag){case 24:case 3:var w=Ll();m=jd(w);var S=Nd(b,m,w);S!==null&&(il(S,b,w),U8(S,b,w)),b={cache:LR()},m.payload=b;return}b=b.return}}function eYe(m,b,w){var S=Ll();w={lane:S,revertLane:0,gesture:null,action:w,hasEagerState:!1,eagerState:null,next:null},Fy(m)?hoe(b,w):(w=OR(m,b,w,S),w!==null&&(il(w,m,S),poe(w,b,S)))}function foe(m,b,w){var S=Ll();X8(m,b,w,S)}function X8(m,b,w,S){var j={lane:S,revertLane:0,gesture:null,action:w,hasEagerState:!1,eagerState:null,next:null};if(Fy(m))hoe(b,j);else{var R=m.alternate;if(m.lanes===0&&(R===null||R.lanes===0)&&(R=b.lastRenderedReducer,R!==null))try{var J=b.lastRenderedState,oe=R(J,w);if(j.hasEagerState=!0,j.eagerState=oe,Tl(oe,J))return wy(m,b,j,0),ho===null&&yy(),!1}catch{}if(w=OR(m,b,j,S),w!==null)return il(w,m,S),poe(w,b,S),!0}return!1}function aL(m,b,w,S){if(S={lane:2,revertLane:$L(),gesture:null,action:S,hasEagerState:!1,eagerState:null,next:null},Fy(m)){if(b)throw Error(r(479))}else b=OR(m,w,S,2),b!==null&&il(b,m,2)}function Fy(m){var b=m.alternate;return m===Xn||b!==null&&b===Xn}function hoe(m,b){mm=Ly=!0;var w=m.pending;w===null?b.next=b:(b.next=w.next,w.next=b),m.pending=b}function poe(m,b,w){if((w&4194048)!==0){var S=b.lanes;S&=m.pendingLanes,w|=S,b.lanes=w,ir(m,w)}}var K8={readContext:As,use:zy,useCallback:Go,useContext:Go,useEffect:Go,useImperativeHandle:Go,useLayoutEffect:Go,useInsertionEffect:Go,useMemo:Go,useReducer:Go,useRef:Go,useState:Go,useDebugValue:Go,useDeferredValue:Go,useTransition:Go,useSyncExternalStore:Go,useId:Go,useHostTransitionStatus:Go,useFormState:Go,useActionState:Go,useOptimistic:Go,useMemoCache:Go,useCacheRefresh:Go};K8.useEffectEvent=Go;var moe={readContext:As,use:zy,useCallback:function(m,b){return Oa().memoizedState=[m,b===void 0?null:b],m},useContext:As,useEffect:Kre,useImperativeHandle:function(m,b,w){w=w!=null?w.concat([m]):null,By(4194308,4,noe.bind(null,b,m),w)},useLayoutEffect:function(m,b){return By(4194308,4,m,b)},useInsertionEffect:function(m,b){By(4,2,m,b)},useMemo:function(m,b){var w=Oa();b=b===void 0?null:b;var S=m();if(cp){Qt(!0);try{m()}finally{Qt(!1)}}return w.memoizedState=[S,b],S},useReducer:function(m,b,w){var S=Oa();if(w!==void 0){var j=w(b);if(cp){Qt(!0);try{w(b)}finally{Qt(!1)}}}else j=b;return S.memoizedState=S.baseState=j,m={pending:null,lanes:0,dispatch:null,lastRenderedReducer:m,lastRenderedState:j},S.queue=m,m=m.dispatch=eYe.bind(null,Xn,m),[S.memoizedState,m]},useRef:function(m){var b=Oa();return m={current:m},b.memoizedState=m},useState:function(m){m=eL(m);var b=m.queue,w=foe.bind(null,Xn,b);return b.dispatch=w,[m.memoizedState,w]},useDebugValue:rL,useDeferredValue:function(m,b){var w=Oa();return oL(w,m,b)},useTransition:function(){var m=eL(!1);return m=aoe.bind(null,Xn,m.queue,!0,!1),Oa().memoizedState=m,[!1,m]},useSyncExternalStore:function(m,b,w){var S=Xn,j=Oa();if(Er){if(w===void 0)throw Error(r(407));w=w()}else{if(w=b(),ho===null)throw Error(r(349));(wr&127)!==0||Ire(S,b,w)}j.memoizedState=w;var R={value:w,getSnapshot:b};return j.queue=R,Kre(zre.bind(null,S,R,m),[m]),S.flags|=2048,vm(9,{destroy:void 0},Dre.bind(null,S,R,w,b),null),w},useId:function(){var m=Oa(),b=ho.identifierPrefix;if(Er){var w=u1,S=c1;w=(S&~(1<<32-Ve(S)-1)).toString(32)+w,b="_"+b+"R_"+w,w=Iy++,0<w&&(b+="H"+w.toString(32)),b+="_"}else w=WGe++,b="_"+b+"r_"+w.toString(32)+"_";return m.memoizedState=b},useHostTransitionStatus:sL,useFormState:Wre,useActionState:Wre,useOptimistic:function(m){var b=Oa();b.memoizedState=b.baseState=m;var w={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return b.queue=w,b=aL.bind(null,Xn,!0,w),w.dispatch=b,[m,b]},useMemoCache:XR,useCacheRefresh:function(){return Oa().memoizedState=JGe.bind(null,Xn)},useEffectEvent:function(m){var b=Oa(),w={impl:m};return b.memoizedState=w,function(){if((Wr&2)!==0)throw Error(r(440));return w.impl.apply(void 0,arguments)}}},lL={readContext:As,use:zy,useCallback:ooe,useContext:As,useEffect:nL,useImperativeHandle:roe,useInsertionEffect:eoe,useLayoutEffect:toe,useMemo:ioe,useReducer:$y,useRef:Xre,useState:function(){return $y(qu)},useDebugValue:rL,useDeferredValue:function(m,b){var w=ci();return soe(w,ro.memoizedState,m,b)},useTransition:function(){var m=$y(qu)[0],b=ci().memoizedState;return[typeof m=="boolean"?m:Y8(m),b]},useSyncExternalStore:Lre,useId:uoe,useHostTransitionStatus:sL,useFormState:Zre,useActionState:Zre,useOptimistic:function(m,b){var w=ci();return Hre(w,ro,m,b)},useMemoCache:XR,useCacheRefresh:doe};lL.useEffectEvent=Jre;var goe={readContext:As,use:zy,useCallback:ooe,useContext:As,useEffect:nL,useImperativeHandle:roe,useInsertionEffect:eoe,useLayoutEffect:toe,useMemo:ioe,useReducer:JR,useRef:Xre,useState:function(){return JR(qu)},useDebugValue:rL,useDeferredValue:function(m,b){var w=ci();return ro===null?oL(w,m,b):soe(w,ro.memoizedState,m,b)},useTransition:function(){var m=JR(qu)[0],b=ci().memoizedState;return[typeof m=="boolean"?m:Y8(m),b]},useSyncExternalStore:Lre,useId:uoe,useHostTransitionStatus:sL,useFormState:Yre,useActionState:Yre,useOptimistic:function(m,b){var w=ci();return ro!==null?Hre(w,ro,m,b):(w.baseState=m,[m,w.queue.dispatch])},useMemoCache:XR,useCacheRefresh:doe};goe.useEffectEvent=Jre;function cL(m,b,w,S){b=m.memoizedState,w=w(S,b),w=w==null?b:d({},b,w),m.memoizedState=w,m.lanes===0&&(m.updateQueue.baseState=w)}var uL={enqueueSetState:function(m,b,w){m=m._reactInternals;var S=Ll(),j=jd(S);j.payload=b,w!=null&&(j.callback=w),b=Nd(m,j,S),b!==null&&(il(b,m,S),U8(b,m,S))},enqueueReplaceState:function(m,b,w){m=m._reactInternals;var S=Ll(),j=jd(S);j.tag=1,j.payload=b,w!=null&&(j.callback=w),b=Nd(m,j,S),b!==null&&(il(b,m,S),U8(b,m,S))},enqueueForceUpdate:function(m,b){m=m._reactInternals;var w=Ll(),S=jd(w);S.tag=2,b!=null&&(S.callback=b),b=Nd(m,S,w),b!==null&&(il(b,m,w),U8(b,m,w))}};function voe(m,b,w,S,j,R,J){return m=m.stateNode,typeof m.shouldComponentUpdate=="function"?m.shouldComponentUpdate(S,R,J):b.prototype&&b.prototype.isPureReactComponent?!z8(w,S)||!z8(j,R):!0}function boe(m,b,w,S){m=b.state,typeof b.componentWillReceiveProps=="function"&&b.componentWillReceiveProps(w,S),typeof b.UNSAFE_componentWillReceiveProps=="function"&&b.UNSAFE_componentWillReceiveProps(w,S),b.state!==m&&uL.enqueueReplaceState(b,b.state,null)}function up(m,b){var w=b;if("ref"in b){w={};for(var S in b)S!=="ref"&&(w[S]=b[S])}if(m=m.defaultProps){w===b&&(w=d({},w));for(var j in m)w[j]===void 0&&(w[j]=m[j])}return w}function _oe(m){xy(m)}function xoe(m){console.error(m)}function yoe(m){xy(m)}function qy(m,b){try{var w=m.onUncaughtError;w(b.value,{componentStack:b.stack})}catch(S){setTimeout(function(){throw S})}}function woe(m,b,w){try{var S=m.onCaughtError;S(w.value,{componentStack:w.stack,errorBoundary:b.tag===1?b.stateNode:null})}catch(j){setTimeout(function(){throw j})}}function dL(m,b,w){return w=jd(w),w.tag=3,w.payload={element:null},w.callback=function(){qy(m,b)},w}function koe(m){return m=jd(m),m.tag=3,m}function Ooe(m,b,w,S){var j=w.type.getDerivedStateFromError;if(typeof j=="function"){var R=S.value;m.payload=function(){return j(R)},m.callback=function(){woe(b,w,S)}}var J=w.stateNode;J!==null&&typeof J.componentDidCatch=="function"&&(m.callback=function(){woe(b,w,S),typeof j!="function"&&($d===null?$d=new Set([this]):$d.add(this));var oe=S.stack;this.componentDidCatch(S.value,{componentStack:oe!==null?oe:""})})}function tYe(m,b,w,S,j){if(w.flags|=32768,S!==null&&typeof S=="object"&&typeof S.then=="function"){if(b=w.alternate,b!==null&&cm(b,w,j,!0),w=Pl.current,w!==null){switch(w.tag){case 31:case 13:return pc===null?tw():w.alternate===null&&Yo===0&&(Yo=3),w.flags&=-257,w.flags|=65536,w.lanes=j,S===My?w.flags|=16384:(b=w.updateQueue,b===null?w.updateQueue=new Set([S]):b.add(S),IL(m,S,j)),!1;case 22:return w.flags|=65536,S===My?w.flags|=16384:(b=w.updateQueue,b===null?(b={transitions:null,markerInstances:null,retryQueue:new Set([S])},w.updateQueue=b):(w=b.retryQueue,w===null?b.retryQueue=new Set([S]):w.add(S)),IL(m,S,j)),!1}throw Error(r(435,w.tag))}return IL(m,S,j),tw(),!1}if(Er)return b=Pl.current,b!==null?((b.flags&65536)===0&&(b.flags|=256),b.flags|=65536,b.lanes=j,S!==MR&&(m=Error(r(422),{cause:S}),H8(uc(m,w)))):(S!==MR&&(b=Error(r(423),{cause:S}),H8(uc(b,w))),m=m.current.alternate,m.flags|=65536,j&=-j,m.lanes|=j,S=uc(S,w),j=dL(m.stateNode,S,j),HR(m,j),Yo!==4&&(Yo=2)),!1;var R=Error(r(520),{cause:S});if(R=uc(R,w),s7===null?s7=[R]:s7.push(R),Yo!==4&&(Yo=2),b===null)return!0;S=uc(S,w),w=b;do{switch(w.tag){case 3:return w.flags|=65536,m=j&-j,w.lanes|=m,m=dL(w.stateNode,S,m),HR(w,m),!1;case 1:if(b=w.type,R=w.stateNode,(w.flags&128)===0&&(typeof b.getDerivedStateFromError=="function"||R!==null&&typeof R.componentDidCatch=="function"&&($d===null||!$d.has(R))))return w.flags|=65536,j&=-j,w.lanes|=j,j=koe(j),Ooe(j,m,w,S),HR(w,j),!1}w=w.return}while(w!==null);return!1}var fL=Error(r(461)),xi=!1;function Es(m,b,w,S){b.child=m===null?Ere(b,null,w,S):lp(b,m.child,w,S)}function Soe(m,b,w,S,j){w=w.render;var R=b.ref;if("ref"in S){var J={};for(var oe in S)oe!=="ref"&&(J[oe]=S[oe])}else J=S;return op(b),S=WR(m,b,w,J,R,j),oe=ZR(),m!==null&&!xi?(GR(m,b,j),Vu(m,b,j)):(Er&&oe&&ER(b),b.flags|=1,Es(m,b,S,j),b.child)}function Coe(m,b,w,S,j){if(m===null){var R=w.type;return typeof R=="function"&&!SR(R)&&R.defaultProps===void 0&&w.compare===null?(b.tag=15,b.type=R,Aoe(m,b,R,S,j)):(m=Oy(w.type,null,S,b,b.mode,j),m.ref=b.ref,m.return=b,b.child=m)}if(R=m.child,!xL(m,j)){var J=R.memoizedProps;if(w=w.compare,w=w!==null?w:z8,w(J,S)&&m.ref===b.ref)return Vu(m,b,j)}return b.flags|=1,m=zu(R,S),m.ref=b.ref,m.return=b,b.child=m}function Aoe(m,b,w,S,j){if(m!==null){var R=m.memoizedProps;if(z8(R,S)&&m.ref===b.ref)if(xi=!1,b.pendingProps=S=R,xL(m,j))(m.flags&131072)!==0&&(xi=!0);else return b.lanes=m.lanes,Vu(m,b,j)}return hL(m,b,w,S,j)}function Eoe(m,b,w,S){var j=S.children,R=m!==null?m.memoizedState:null;if(m===null&&b.stateNode===null&&(b.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),S.mode==="hidden"){if((b.flags&128)!==0){if(R=R!==null?R.baseLanes|w:w,m!==null){for(S=b.child=m.child,j=0;S!==null;)j=j|S.lanes|S.childLanes,S=S.sibling;S=j&~R}else S=0,b.child=null;return Toe(m,b,R,w,S)}if((w&536870912)!==0)b.memoizedState={baseLanes:0,cachePool:null},m!==null&&Ey(b,R!==null?R.cachePool:null),R!==null?Pre(b,R):qR(),jre(b);else return S=b.lanes=536870912,Toe(m,b,R!==null?R.baseLanes|w:w,w,S)}else R!==null?(Ey(b,R.cachePool),Pre(b,R),Ld(),b.memoizedState=null):(m!==null&&Ey(b,null),qR(),Ld());return Es(m,b,j,w),b.child}function J8(m,b){return m!==null&&m.tag===22||b.stateNode!==null||(b.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),b.sibling}function Toe(m,b,w,S,j){var R=DR();return R=R===null?null:{parent:bi._currentValue,pool:R},b.memoizedState={baseLanes:w,cachePool:R},m!==null&&Ey(b,null),qR(),jre(b),m!==null&&cm(m,b,S,!0),b.childLanes=j,null}function Vy(m,b){return b=Uy({mode:b.mode,children:b.children},m.mode),b.ref=m.ref,m.child=b,b.return=m,b}function Moe(m,b,w){return lp(b,m.child,null,w),m=Vy(b,b.pendingProps),m.flags|=2,jl(b),b.memoizedState=null,m}function nYe(m,b,w){var S=b.pendingProps,j=(b.flags&128)!==0;if(b.flags&=-129,m===null){if(Er){if(S.mode==="hidden")return m=Vy(b,S),b.lanes=536870912,J8(null,m);if(QR(b),(m=Oo)?(m=Fie(m,hc),m=m!==null&&m.data==="&"?m:null,m!==null&&(b.memoizedState={dehydrated:m,treeContext:Ad!==null?{id:c1,overflow:u1}:null,retryLane:536870912,hydrationErrors:null},w=hre(m),w.return=b,b.child=w,Cs=b,Oo=null)):m=null,m===null)throw Td(b);return b.lanes=536870912,null}return Vy(b,S)}var R=m.memoizedState;if(R!==null){var J=R.dehydrated;if(QR(b),j)if(b.flags&256)b.flags&=-257,b=Moe(m,b,w);else if(b.memoizedState!==null)b.child=m.child,b.flags|=128,b=null;else throw Error(r(558));else if(xi||cm(m,b,w,!1),j=(w&m.childLanes)!==0,xi||j){if(S=ho,S!==null&&(J=Nt(S,w),J!==0&&J!==R.retryLane))throw R.retryLane=J,ep(m,J),il(S,m,J),fL;tw(),b=Moe(m,b,w)}else m=R.treeContext,Oo=mc(J.nextSibling),Cs=b,Er=!0,Ed=null,hc=!1,m!==null&&gre(b,m),b=Vy(b,S),b.flags|=4096;return b}return m=zu(m.child,{mode:S.mode,children:S.children}),m.ref=b.ref,b.child=m,m.return=b,m}function Qy(m,b){var w=b.ref;if(w===null)m!==null&&m.ref!==null&&(b.flags|=4194816);else{if(typeof w!="function"&&typeof w!="object")throw Error(r(284));(m===null||m.ref!==w)&&(b.flags|=4194816)}}function hL(m,b,w,S,j){return op(b),w=WR(m,b,w,S,void 0,j),S=ZR(),m!==null&&!xi?(GR(m,b,j),Vu(m,b,j)):(Er&&S&&ER(b),b.flags|=1,Es(m,b,w,j),b.child)}function Poe(m,b,w,S,j,R){return op(b),b.updateQueue=null,w=Rre(b,S,w,j),Nre(m),S=ZR(),m!==null&&!xi?(GR(m,b,R),Vu(m,b,R)):(Er&&S&&ER(b),b.flags|=1,Es(m,b,w,R),b.child)}function joe(m,b,w,S,j){if(op(b),b.stateNode===null){var R=im,J=w.contextType;typeof J=="object"&&J!==null&&(R=As(J)),R=new w(S,R),b.memoizedState=R.state!==null&&R.state!==void 0?R.state:null,R.updater=uL,b.stateNode=R,R._reactInternals=b,R=b.stateNode,R.props=S,R.state=b.memoizedState,R.refs={},$R(b),J=w.contextType,R.context=typeof J=="object"&&J!==null?As(J):im,R.state=b.memoizedState,J=w.getDerivedStateFromProps,typeof J=="function"&&(cL(b,w,J,S),R.state=b.memoizedState),typeof w.getDerivedStateFromProps=="function"||typeof R.getSnapshotBeforeUpdate=="function"||typeof R.UNSAFE_componentWillMount!="function"&&typeof R.componentWillMount!="function"||(J=R.state,typeof R.componentWillMount=="function"&&R.componentWillMount(),typeof R.UNSAFE_componentWillMount=="function"&&R.UNSAFE_componentWillMount(),J!==R.state&&uL.enqueueReplaceState(R,R.state,null),Z8(b,S,R,j),W8(),R.state=b.memoizedState),typeof R.componentDidMount=="function"&&(b.flags|=4194308),S=!0}else if(m===null){R=b.stateNode;var oe=b.memoizedProps,Oe=up(w,oe);R.props=Oe;var qe=R.context,nt=w.contextType;J=im,typeof nt=="object"&&nt!==null&&(J=As(nt));var at=w.getDerivedStateFromProps;nt=typeof at=="function"||typeof R.getSnapshotBeforeUpdate=="function",oe=b.pendingProps!==oe,nt||typeof R.UNSAFE_componentWillReceiveProps!="function"&&typeof R.componentWillReceiveProps!="function"||(oe||qe!==J)&&boe(b,R,S,J),Pd=!1;var Ue=b.memoizedState;R.state=Ue,Z8(b,S,R,j),W8(),qe=b.memoizedState,oe||Ue!==qe||Pd?(typeof at=="function"&&(cL(b,w,at,S),qe=b.memoizedState),(Oe=Pd||voe(b,w,Oe,S,Ue,qe,J))?(nt||typeof R.UNSAFE_componentWillMount!="function"&&typeof R.componentWillMount!="function"||(typeof R.componentWillMount=="function"&&R.componentWillMount(),typeof R.UNSAFE_componentWillMount=="function"&&R.UNSAFE_componentWillMount()),typeof R.componentDidMount=="function"&&(b.flags|=4194308)):(typeof R.componentDidMount=="function"&&(b.flags|=4194308),b.memoizedProps=S,b.memoizedState=qe),R.props=S,R.state=qe,R.context=J,S=Oe):(typeof R.componentDidMount=="function"&&(b.flags|=4194308),S=!1)}else{R=b.stateNode,BR(m,b),J=b.memoizedProps,nt=up(w,J),R.props=nt,at=b.pendingProps,Ue=R.context,qe=w.contextType,Oe=im,typeof qe=="object"&&qe!==null&&(Oe=As(qe)),oe=w.getDerivedStateFromProps,(qe=typeof oe=="function"||typeof R.getSnapshotBeforeUpdate=="function")||typeof R.UNSAFE_componentWillReceiveProps!="function"&&typeof R.componentWillReceiveProps!="function"||(J!==at||Ue!==Oe)&&boe(b,R,S,Oe),Pd=!1,Ue=b.memoizedState,R.state=Ue,Z8(b,S,R,j),W8();var Ge=b.memoizedState;J!==at||Ue!==Ge||Pd||m!==null&&m.dependencies!==null&&Cy(m.dependencies)?(typeof oe=="function"&&(cL(b,w,oe,S),Ge=b.memoizedState),(nt=Pd||voe(b,w,nt,S,Ue,Ge,Oe)||m!==null&&m.dependencies!==null&&Cy(m.dependencies))?(qe||typeof R.UNSAFE_componentWillUpdate!="function"&&typeof R.componentWillUpdate!="function"||(typeof R.componentWillUpdate=="function"&&R.componentWillUpdate(S,Ge,Oe),typeof R.UNSAFE_componentWillUpdate=="function"&&R.UNSAFE_componentWillUpdate(S,Ge,Oe)),typeof R.componentDidUpdate=="function"&&(b.flags|=4),typeof R.getSnapshotBeforeUpdate=="function"&&(b.flags|=1024)):(typeof R.componentDidUpdate!="function"||J===m.memoizedProps&&Ue===m.memoizedState||(b.flags|=4),typeof R.getSnapshotBeforeUpdate!="function"||J===m.memoizedProps&&Ue===m.memoizedState||(b.flags|=1024),b.memoizedProps=S,b.memoizedState=Ge),R.props=S,R.state=Ge,R.context=Oe,S=nt):(typeof R.componentDidUpdate!="function"||J===m.memoizedProps&&Ue===m.memoizedState||(b.flags|=4),typeof R.getSnapshotBeforeUpdate!="function"||J===m.memoizedProps&&Ue===m.memoizedState||(b.flags|=1024),S=!1)}return R=S,Qy(m,b),S=(b.flags&128)!==0,R||S?(R=b.stateNode,w=S&&typeof w.getDerivedStateFromError!="function"?null:R.render(),b.flags|=1,m!==null&&S?(b.child=lp(b,m.child,null,j),b.child=lp(b,null,w,j)):Es(m,b,w,j),b.memoizedState=R.state,m=b.child):m=Vu(m,b,j),m}function Noe(m,b,w,S){return np(),b.flags|=256,Es(m,b,w,S),b.child}var pL={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function mL(m){return{baseLanes:m,cachePool:wre()}}function gL(m,b,w){return m=m!==null?m.childLanes&~w:0,b&&(m|=Rl),m}function Roe(m,b,w){var S=b.pendingProps,j=!1,R=(b.flags&128)!==0,J;if((J=R)||(J=m!==null&&m.memoizedState===null?!1:(li.current&2)!==0),J&&(j=!0,b.flags&=-129),J=(b.flags&32)!==0,b.flags&=-33,m===null){if(Er){if(j?Rd(b):Ld(),(m=Oo)?(m=Fie(m,hc),m=m!==null&&m.data!=="&"?m:null,m!==null&&(b.memoizedState={dehydrated:m,treeContext:Ad!==null?{id:c1,overflow:u1}:null,retryLane:536870912,hydrationErrors:null},w=hre(m),w.return=b,b.child=w,Cs=b,Oo=null)):m=null,m===null)throw Td(b);return KL(m)?b.lanes=32:b.lanes=536870912,null}var oe=S.children;return S=S.fallback,j?(Ld(),j=b.mode,oe=Uy({mode:"hidden",children:oe},j),S=tp(S,j,w,null),oe.return=b,S.return=b,oe.sibling=S,b.child=oe,S=b.child,S.memoizedState=mL(w),S.childLanes=gL(m,J,w),b.memoizedState=pL,J8(null,S)):(Rd(b),vL(b,oe))}var Oe=m.memoizedState;if(Oe!==null&&(oe=Oe.dehydrated,oe!==null)){if(R)b.flags&256?(Rd(b),b.flags&=-257,b=bL(m,b,w)):b.memoizedState!==null?(Ld(),b.child=m.child,b.flags|=128,b=null):(Ld(),oe=S.fallback,j=b.mode,S=Uy({mode:"visible",children:S.children},j),oe=tp(oe,j,w,null),oe.flags|=2,S.return=b,oe.return=b,S.sibling=oe,b.child=S,lp(b,m.child,null,w),S=b.child,S.memoizedState=mL(w),S.childLanes=gL(m,J,w),b.memoizedState=pL,b=J8(null,S));else if(Rd(b),KL(oe)){if(J=oe.nextSibling&&oe.nextSibling.dataset,J)var qe=J.dgst;J=qe,S=Error(r(419)),S.stack="",S.digest=J,H8({value:S,source:null,stack:null}),b=bL(m,b,w)}else if(xi||cm(m,b,w,!1),J=(w&m.childLanes)!==0,xi||J){if(J=ho,J!==null&&(S=Nt(J,w),S!==0&&S!==Oe.retryLane))throw Oe.retryLane=S,ep(m,S),il(J,m,S),fL;XL(oe)||tw(),b=bL(m,b,w)}else XL(oe)?(b.flags|=192,b.child=m.child,b=null):(m=Oe.treeContext,Oo=mc(oe.nextSibling),Cs=b,Er=!0,Ed=null,hc=!1,m!==null&&gre(b,m),b=vL(b,S.children),b.flags|=4096);return b}return j?(Ld(),oe=S.fallback,j=b.mode,Oe=m.child,qe=Oe.sibling,S=zu(Oe,{mode:"hidden",children:S.children}),S.subtreeFlags=Oe.subtreeFlags&65011712,qe!==null?oe=zu(qe,oe):(oe=tp(oe,j,w,null),oe.flags|=2),oe.return=b,S.return=b,S.sibling=oe,b.child=S,J8(null,S),S=b.child,oe=m.child.memoizedState,oe===null?oe=mL(w):(j=oe.cachePool,j!==null?(Oe=bi._currentValue,j=j.parent!==Oe?{parent:Oe,pool:Oe}:j):j=wre(),oe={baseLanes:oe.baseLanes|w,cachePool:j}),S.memoizedState=oe,S.childLanes=gL(m,J,w),b.memoizedState=pL,J8(m.child,S)):(Rd(b),w=m.child,m=w.sibling,w=zu(w,{mode:"visible",children:S.children}),w.return=b,w.sibling=null,m!==null&&(J=b.deletions,J===null?(b.deletions=[m],b.flags|=16):J.push(m)),b.child=w,b.memoizedState=null,w)}function vL(m,b){return b=Uy({mode:"visible",children:b},m.mode),b.return=m,m.child=b}function Uy(m,b){return m=Ml(22,m,null,b),m.lanes=0,m}function bL(m,b,w){return lp(b,m.child,null,w),m=vL(b,b.pendingProps.children),m.flags|=2,b.memoizedState=null,m}function Loe(m,b,w){m.lanes|=b;var S=m.alternate;S!==null&&(S.lanes|=b),NR(m.return,b,w)}function _L(m,b,w,S,j,R){var J=m.memoizedState;J===null?m.memoizedState={isBackwards:b,rendering:null,renderingStartTime:0,last:S,tail:w,tailMode:j,treeForkCount:R}:(J.isBackwards=b,J.rendering=null,J.renderingStartTime=0,J.last=S,J.tail=w,J.tailMode=j,J.treeForkCount=R)}function Ioe(m,b,w){var S=b.pendingProps,j=S.revealOrder,R=S.tail;S=S.children;var J=li.current,oe=(J&2)!==0;if(oe?(J=J&1|2,b.flags|=128):J&=1,B(li,J),Es(m,b,S,w),S=Er?B8:0,!oe&&m!==null&&(m.flags&128)!==0)e:for(m=b.child;m!==null;){if(m.tag===13)m.memoizedState!==null&&Loe(m,w,b);else if(m.tag===19)Loe(m,w,b);else if(m.child!==null){m.child.return=m,m=m.child;continue}if(m===b)break e;for(;m.sibling===null;){if(m.return===null||m.return===b)break e;m=m.return}m.sibling.return=m.return,m=m.sibling}switch(j){case"forwards":for(w=b.child,j=null;w!==null;)m=w.alternate,m!==null&&Ry(m)===null&&(j=w),w=w.sibling;w=j,w===null?(j=b.child,b.child=null):(j=w.sibling,w.sibling=null),_L(b,!1,j,w,R,S);break;case"backwards":case"unstable_legacy-backwards":for(w=null,j=b.child,b.child=null;j!==null;){if(m=j.alternate,m!==null&&Ry(m)===null){b.child=j;break}m=j.sibling,j.sibling=w,w=j,j=m}_L(b,!0,w,null,R,S);break;case"together":_L(b,!1,null,null,void 0,S);break;default:b.memoizedState=null}return b.child}function Vu(m,b,w){if(m!==null&&(b.dependencies=m.dependencies),zd|=b.lanes,(w&b.childLanes)===0)if(m!==null){if(cm(m,b,w,!1),(w&b.childLanes)===0)return null}else return null;if(m!==null&&b.child!==m.child)throw Error(r(153));if(b.child!==null){for(m=b.child,w=zu(m,m.pendingProps),b.child=w,w.return=b;m.sibling!==null;)m=m.sibling,w=w.sibling=zu(m,m.pendingProps),w.return=b;w.sibling=null}return b.child}function xL(m,b){return(m.lanes&b)!==0?!0:(m=m.dependencies,!!(m!==null&&Cy(m)))}function rYe(m,b,w){switch(b.tag){case 3:he(b,b.stateNode.containerInfo),Md(b,bi,m.memoizedState.cache),np();break;case 27:case 5:be(b);break;case 4:he(b,b.stateNode.containerInfo);break;case 10:Md(b,b.type,b.memoizedProps.value);break;case 31:if(b.memoizedState!==null)return b.flags|=128,QR(b),null;break;case 13:var S=b.memoizedState;if(S!==null)return S.dehydrated!==null?(Rd(b),b.flags|=128,null):(w&b.child.childLanes)!==0?Roe(m,b,w):(Rd(b),m=Vu(m,b,w),m!==null?m.sibling:null);Rd(b);break;case 19:var j=(m.flags&128)!==0;if(S=(w&b.childLanes)!==0,S||(cm(m,b,w,!1),S=(w&b.childLanes)!==0),j){if(S)return Ioe(m,b,w);b.flags|=128}if(j=b.memoizedState,j!==null&&(j.rendering=null,j.tail=null,j.lastEffect=null),B(li,li.current),S)break;return null;case 22:return b.lanes=0,Eoe(m,b,w,b.pendingProps);case 24:Md(b,bi,m.memoizedState.cache)}return Vu(m,b,w)}function Doe(m,b,w){if(m!==null)if(m.memoizedProps!==b.pendingProps)xi=!0;else{if(!xL(m,w)&&(b.flags&128)===0)return xi=!1,rYe(m,b,w);xi=(m.flags&131072)!==0}else xi=!1,Er&&(b.flags&1048576)!==0&&mre(b,B8,b.index);switch(b.lanes=0,b.tag){case 16:e:{var S=b.pendingProps;if(m=sp(b.elementType),b.type=m,typeof m=="function")SR(m)?(S=up(m,S),b.tag=1,b=joe(null,b,m,S,w)):(b.tag=0,b=hL(null,b,m,S,w));else{if(m!=null){var j=m.$$typeof;if(j===C){b.tag=11,b=Soe(null,b,m,S,w);break e}else if(j===M){b.tag=14,b=Coe(null,b,m,S,w);break e}}throw b=Q(m)||m,Error(r(306,b,""))}}return b;case 0:return hL(m,b,b.type,b.pendingProps,w);case 1:return S=b.type,j=up(S,b.pendingProps),joe(m,b,S,j,w);case 3:e:{if(he(b,b.stateNode.containerInfo),m===null)throw Error(r(387));S=b.pendingProps;var R=b.memoizedState;j=R.element,BR(m,b),Z8(b,S,null,w);var J=b.memoizedState;if(S=J.cache,Md(b,bi,S),S!==R.cache&&RR(b,[bi],w,!0),W8(),S=J.element,R.isDehydrated)if(R={element:S,isDehydrated:!1,cache:J.cache},b.updateQueue.baseState=R,b.memoizedState=R,b.flags&256){b=Noe(m,b,S,w);break e}else if(S!==j){j=uc(Error(r(424)),b),H8(j),b=Noe(m,b,S,w);break e}else for(m=b.stateNode.containerInfo,m.nodeType===9?m=m.body:m=m.nodeName==="HTML"?m.ownerDocument.body:m,Oo=mc(m.firstChild),Cs=b,Er=!0,Ed=null,hc=!0,w=Ere(b,null,S,w),b.child=w;w;)w.flags=w.flags&-3|4096,w=w.sibling;else{if(np(),S===j){b=Vu(m,b,w);break e}Es(m,b,S,w)}b=b.child}return b;case 26:return Qy(m,b),m===null?(w=Zie(b.type,null,b.pendingProps,null))?b.memoizedState=w:Er||(w=b.type,m=b.pendingProps,S=lw(se.current).createElement(w),S[At]=b,S[qt]=m,Ts(S,w,m),Yn(S),b.stateNode=S):b.memoizedState=Zie(b.type,m.memoizedProps,b.pendingProps,m.memoizedState),null;case 27:return be(b),m===null&&Er&&(S=b.stateNode=Qie(b.type,b.pendingProps,se.current),Cs=b,hc=!0,j=Oo,qd(b.type)?(JL=j,Oo=mc(S.firstChild)):Oo=j),Es(m,b,b.pendingProps.children,w),Qy(m,b),m===null&&(b.flags|=4194304),b.child;case 5:return m===null&&Er&&((j=S=Oo)&&(S=NYe(S,b.type,b.pendingProps,hc),S!==null?(b.stateNode=S,Cs=b,Oo=mc(S.firstChild),hc=!1,j=!0):j=!1),j||Td(b)),be(b),j=b.type,R=b.pendingProps,J=m!==null?m.memoizedProps:null,S=R.children,ZL(j,R)?S=null:J!==null&&ZL(j,J)&&(b.flags|=32),b.memoizedState!==null&&(j=WR(m,b,ZGe,null,null,w),p7._currentValue=j),Qy(m,b),Es(m,b,S,w),b.child;case 6:return m===null&&Er&&((m=w=Oo)&&(w=RYe(w,b.pendingProps,hc),w!==null?(b.stateNode=w,Cs=b,Oo=null,m=!0):m=!1),m||Td(b)),null;case 13:return Roe(m,b,w);case 4:return he(b,b.stateNode.containerInfo),S=b.pendingProps,m===null?b.child=lp(b,null,S,w):Es(m,b,S,w),b.child;case 11:return Soe(m,b,b.type,b.pendingProps,w);case 7:return Es(m,b,b.pendingProps,w),b.child;case 8:return Es(m,b,b.pendingProps.children,w),b.child;case 12:return Es(m,b,b.pendingProps.children,w),b.child;case 10:return S=b.pendingProps,Md(b,b.type,S.value),Es(m,b,S.children,w),b.child;case 9:return j=b.type._context,S=b.pendingProps.children,op(b),j=As(j),S=S(j),b.flags|=1,Es(m,b,S,w),b.child;case 14:return Coe(m,b,b.type,b.pendingProps,w);case 15:return Aoe(m,b,b.type,b.pendingProps,w);case 19:return Ioe(m,b,w);case 31:return nYe(m,b,w);case 22:return Eoe(m,b,w,b.pendingProps);case 24:return op(b),S=As(bi),m===null?(j=DR(),j===null&&(j=ho,R=LR(),j.pooledCache=R,R.refCount++,R!==null&&(j.pooledCacheLanes|=w),j=R),b.memoizedState={parent:S,cache:j},$R(b),Md(b,bi,j)):((m.lanes&w)!==0&&(BR(m,b),Z8(b,null,null,w),W8()),j=m.memoizedState,R=b.memoizedState,j.parent!==S?(j={parent:S,cache:S},b.memoizedState=j,b.lanes===0&&(b.memoizedState=b.updateQueue.baseState=j),Md(b,bi,S)):(S=R.cache,Md(b,bi,S),S!==j.cache&&RR(b,[bi],w,!0))),Es(m,b,b.pendingProps.children,w),b.child;case 29:throw b.pendingProps}throw Error(r(156,b.tag))}function Qu(m){m.flags|=4}function yL(m,b,w,S,j){if((b=(m.mode&32)!==0)&&(b=!1),b){if(m.flags|=16777216,(j&335544128)===j)if(m.stateNode.complete)m.flags|=8192;else if(uie())m.flags|=8192;else throw ap=My,zR}else m.flags&=-16777217}function zoe(m,b){if(b.type!=="stylesheet"||(b.state.loading&4)!==0)m.flags&=-16777217;else if(m.flags|=16777216,!Jie(b))if(uie())m.flags|=8192;else throw ap=My,zR}function Wy(m,b){b!==null&&(m.flags|=4),m.flags&16384&&(b=m.tag!==22?Ke():536870912,m.lanes|=b,ym|=b)}function e7(m,b){if(!Er)switch(m.tailMode){case"hidden":b=m.tail;for(var w=null;b!==null;)b.alternate!==null&&(w=b),b=b.sibling;w===null?m.tail=null:w.sibling=null;break;case"collapsed":w=m.tail;for(var S=null;w!==null;)w.alternate!==null&&(S=w),w=w.sibling;S===null?b||m.tail===null?m.tail=null:m.tail.sibling=null:S.sibling=null}}function So(m){var b=m.alternate!==null&&m.alternate.child===m.child,w=0,S=0;if(b)for(var j=m.child;j!==null;)w|=j.lanes|j.childLanes,S|=j.subtreeFlags&65011712,S|=j.flags&65011712,j.return=m,j=j.sibling;else for(j=m.child;j!==null;)w|=j.lanes|j.childLanes,S|=j.subtreeFlags,S|=j.flags,j.return=m,j=j.sibling;return m.subtreeFlags|=S,m.childLanes=w,b}function oYe(m,b,w){var S=b.pendingProps;switch(TR(b),b.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return So(b),null;case 1:return So(b),null;case 3:return w=b.stateNode,S=null,m!==null&&(S=m.memoizedState.cache),b.memoizedState.cache!==S&&(b.flags|=2048),Hu(bi),fe(),w.pendingContext&&(w.context=w.pendingContext,w.pendingContext=null),(m===null||m.child===null)&&(lm(b)?Qu(b):m===null||m.memoizedState.isDehydrated&&(b.flags&256)===0||(b.flags|=1024,PR())),So(b),null;case 26:var j=b.type,R=b.memoizedState;return m===null?(Qu(b),R!==null?(So(b),zoe(b,R)):(So(b),yL(b,j,null,S,w))):R?R!==m.memoizedState?(Qu(b),So(b),zoe(b,R)):(So(b),b.flags&=-16777217):(m=m.memoizedProps,m!==S&&Qu(b),So(b),yL(b,j,m,S,w)),null;case 27:if(me(b),w=se.current,j=b.type,m!==null&&b.stateNode!=null)m.memoizedProps!==S&&Qu(b);else{if(!S){if(b.stateNode===null)throw Error(r(166));return So(b),null}m=ee.current,lm(b)?vre(b):(m=Qie(j,S,w),b.stateNode=m,Qu(b))}return So(b),null;case 5:if(me(b),j=b.type,m!==null&&b.stateNode!=null)m.memoizedProps!==S&&Qu(b);else{if(!S){if(b.stateNode===null)throw Error(r(166));return So(b),null}if(R=ee.current,lm(b))vre(b);else{var J=lw(se.current);switch(R){case 1:R=J.createElementNS("http://www.w3.org/2000/svg",j);break;case 2:R=J.createElementNS("http://www.w3.org/1998/Math/MathML",j);break;default:switch(j){case"svg":R=J.createElementNS("http://www.w3.org/2000/svg",j);break;case"math":R=J.createElementNS("http://www.w3.org/1998/Math/MathML",j);break;case"script":R=J.createElement("div"),R.innerHTML="<script><\/script>",R=R.removeChild(R.firstChild);break;case"select":R=typeof S.is=="string"?J.createElement("select",{is:S.is}):J.createElement("select"),S.multiple?R.multiple=!0:S.size&&(R.size=S.size);break;default:R=typeof S.is=="string"?J.createElement(j,{is:S.is}):J.createElement(j)}}R[At]=b,R[qt]=S;e:for(J=b.child;J!==null;){if(J.tag===5||J.tag===6)R.appendChild(J.stateNode);else if(J.tag!==4&&J.tag!==27&&J.child!==null){J.child.return=J,J=J.child;continue}if(J===b)break e;for(;J.sibling===null;){if(J.return===null||J.return===b)break e;J=J.return}J.sibling.return=J.return,J=J.sibling}b.stateNode=R;e:switch(Ts(R,j,S),j){case"button":case"input":case"select":case"textarea":S=!!S.autoFocus;break e;case"img":S=!0;break e;default:S=!1}S&&Qu(b)}}return So(b),yL(b,b.type,m===null?null:m.memoizedProps,b.pendingProps,w),null;case 6:if(m&&b.stateNode!=null)m.memoizedProps!==S&&Qu(b);else{if(typeof S!="string"&&b.stateNode===null)throw Error(r(166));if(m=se.current,lm(b)){if(m=b.stateNode,w=b.memoizedProps,S=null,j=Cs,j!==null)switch(j.tag){case 27:case 5:S=j.memoizedProps}m[At]=b,m=!!(m.nodeValue===w||S!==null&&S.suppressHydrationWarning===!0||Rie(m.nodeValue,w)),m||Td(b,!0)}else m=lw(m).createTextNode(S),m[At]=b,b.stateNode=m}return So(b),null;case 31:if(w=b.memoizedState,m===null||m.memoizedState!==null){if(S=lm(b),w!==null){if(m===null){if(!S)throw Error(r(318));if(m=b.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(557));m[At]=b}else np(),(b.flags&128)===0&&(b.memoizedState=null),b.flags|=4;So(b),m=!1}else w=PR(),m!==null&&m.memoizedState!==null&&(m.memoizedState.hydrationErrors=w),m=!0;if(!m)return b.flags&256?(jl(b),b):(jl(b),null);if((b.flags&128)!==0)throw Error(r(558))}return So(b),null;case 13:if(S=b.memoizedState,m===null||m.memoizedState!==null&&m.memoizedState.dehydrated!==null){if(j=lm(b),S!==null&&S.dehydrated!==null){if(m===null){if(!j)throw Error(r(318));if(j=b.memoizedState,j=j!==null?j.dehydrated:null,!j)throw Error(r(317));j[At]=b}else np(),(b.flags&128)===0&&(b.memoizedState=null),b.flags|=4;So(b),j=!1}else j=PR(),m!==null&&m.memoizedState!==null&&(m.memoizedState.hydrationErrors=j),j=!0;if(!j)return b.flags&256?(jl(b),b):(jl(b),null)}return jl(b),(b.flags&128)!==0?(b.lanes=w,b):(w=S!==null,m=m!==null&&m.memoizedState!==null,w&&(S=b.child,j=null,S.alternate!==null&&S.alternate.memoizedState!==null&&S.alternate.memoizedState.cachePool!==null&&(j=S.alternate.memoizedState.cachePool.pool),R=null,S.memoizedState!==null&&S.memoizedState.cachePool!==null&&(R=S.memoizedState.cachePool.pool),R!==j&&(S.flags|=2048)),w!==m&&w&&(b.child.flags|=8192),Wy(b,b.updateQueue),So(b),null);case 4:return fe(),m===null&&qL(b.stateNode.containerInfo),So(b),null;case 10:return Hu(b.type),So(b),null;case 19:if(U(li),S=b.memoizedState,S===null)return So(b),null;if(j=(b.flags&128)!==0,R=S.rendering,R===null)if(j)e7(S,!1);else{if(Yo!==0||m!==null&&(m.flags&128)!==0)for(m=b.child;m!==null;){if(R=Ry(m),R!==null){for(b.flags|=128,e7(S,!1),m=R.updateQueue,b.updateQueue=m,Wy(b,m),b.subtreeFlags=0,m=w,w=b.child;w!==null;)fre(w,m),w=w.sibling;return B(li,li.current&1|2),Er&&$u(b,S.treeForkCount),b.child}m=m.sibling}S.tail!==null&&De()>Ky&&(b.flags|=128,j=!0,e7(S,!1),b.lanes=4194304)}else{if(!j)if(m=Ry(R),m!==null){if(b.flags|=128,j=!0,m=m.updateQueue,b.updateQueue=m,Wy(b,m),e7(S,!0),S.tail===null&&S.tailMode==="hidden"&&!R.alternate&&!Er)return So(b),null}else 2*De()-S.renderingStartTime>Ky&&w!==536870912&&(b.flags|=128,j=!0,e7(S,!1),b.lanes=4194304);S.isBackwards?(R.sibling=b.child,b.child=R):(m=S.last,m!==null?m.sibling=R:b.child=R,S.last=R)}return S.tail!==null?(m=S.tail,S.rendering=m,S.tail=m.sibling,S.renderingStartTime=De(),m.sibling=null,w=li.current,B(li,j?w&1|2:w&1),Er&&$u(b,S.treeForkCount),m):(So(b),null);case 22:case 23:return jl(b),VR(),S=b.memoizedState!==null,m!==null?m.memoizedState!==null!==S&&(b.flags|=8192):S&&(b.flags|=8192),S?(w&536870912)!==0&&(b.flags&128)===0&&(So(b),b.subtreeFlags&6&&(b.flags|=8192)):So(b),w=b.updateQueue,w!==null&&Wy(b,w.retryQueue),w=null,m!==null&&m.memoizedState!==null&&m.memoizedState.cachePool!==null&&(w=m.memoizedState.cachePool.pool),S=null,b.memoizedState!==null&&b.memoizedState.cachePool!==null&&(S=b.memoizedState.cachePool.pool),S!==w&&(b.flags|=2048),m!==null&&U(ip),null;case 24:return w=null,m!==null&&(w=m.memoizedState.cache),b.memoizedState.cache!==w&&(b.flags|=2048),Hu(bi),So(b),null;case 25:return null;case 30:return null}throw Error(r(156,b.tag))}function iYe(m,b){switch(TR(b),b.tag){case 1:return m=b.flags,m&65536?(b.flags=m&-65537|128,b):null;case 3:return Hu(bi),fe(),m=b.flags,(m&65536)!==0&&(m&128)===0?(b.flags=m&-65537|128,b):null;case 26:case 27:case 5:return me(b),null;case 31:if(b.memoizedState!==null){if(jl(b),b.alternate===null)throw Error(r(340));np()}return m=b.flags,m&65536?(b.flags=m&-65537|128,b):null;case 13:if(jl(b),m=b.memoizedState,m!==null&&m.dehydrated!==null){if(b.alternate===null)throw Error(r(340));np()}return m=b.flags,m&65536?(b.flags=m&-65537|128,b):null;case 19:return U(li),null;case 4:return fe(),null;case 10:return Hu(b.type),null;case 22:case 23:return jl(b),VR(),m!==null&&U(ip),m=b.flags,m&65536?(b.flags=m&-65537|128,b):null;case 24:return Hu(bi),null;case 25:return null;default:return null}}function $oe(m,b){switch(TR(b),b.tag){case 3:Hu(bi),fe();break;case 26:case 27:case 5:me(b);break;case 4:fe();break;case 31:b.memoizedState!==null&&jl(b);break;case 13:jl(b);break;case 19:U(li);break;case 10:Hu(b.type);break;case 22:case 23:jl(b),VR(),m!==null&&U(ip);break;case 24:Hu(bi)}}function t7(m,b){try{var w=b.updateQueue,S=w!==null?w.lastEffect:null;if(S!==null){var j=S.next;w=j;do{if((w.tag&m)===m){S=void 0;var R=w.create,J=w.inst;S=R(),J.destroy=S}w=w.next}while(w!==j)}}catch(oe){eo(b,b.return,oe)}}function Id(m,b,w){try{var S=b.updateQueue,j=S!==null?S.lastEffect:null;if(j!==null){var R=j.next;S=R;do{if((S.tag&m)===m){var J=S.inst,oe=J.destroy;if(oe!==void 0){J.destroy=void 0,j=b;var Oe=w,qe=oe;try{qe()}catch(nt){eo(j,Oe,nt)}}}S=S.next}while(S!==R)}}catch(nt){eo(b,b.return,nt)}}function Boe(m){var b=m.updateQueue;if(b!==null){var w=m.stateNode;try{Mre(b,w)}catch(S){eo(m,m.return,S)}}}function Hoe(m,b,w){w.props=up(m.type,m.memoizedProps),w.state=m.memoizedState;try{w.componentWillUnmount()}catch(S){eo(m,b,S)}}function n7(m,b){try{var w=m.ref;if(w!==null){switch(m.tag){case 26:case 27:case 5:var S=m.stateNode;break;case 30:S=m.stateNode;break;default:S=m.stateNode}typeof w=="function"?m.refCleanup=w(S):w.current=S}}catch(j){eo(m,b,j)}}function d1(m,b){var w=m.ref,S=m.refCleanup;if(w!==null)if(typeof S=="function")try{S()}catch(j){eo(m,b,j)}finally{m.refCleanup=null,m=m.alternate,m!=null&&(m.refCleanup=null)}else if(typeof w=="function")try{w(null)}catch(j){eo(m,b,j)}else w.current=null}function Foe(m){var b=m.type,w=m.memoizedProps,S=m.stateNode;try{e:switch(b){case"button":case"input":case"select":case"textarea":w.autoFocus&&S.focus();break e;case"img":w.src?S.src=w.src:w.srcSet&&(S.srcset=w.srcSet)}}catch(j){eo(m,m.return,j)}}function wL(m,b,w){try{var S=m.stateNode;AYe(S,m.type,w,b),S[qt]=b}catch(j){eo(m,m.return,j)}}function qoe(m){return m.tag===5||m.tag===3||m.tag===26||m.tag===27&&qd(m.type)||m.tag===4}function kL(m){e:for(;;){for(;m.sibling===null;){if(m.return===null||qoe(m.return))return null;m=m.return}for(m.sibling.return=m.return,m=m.sibling;m.tag!==5&&m.tag!==6&&m.tag!==18;){if(m.tag===27&&qd(m.type)||m.flags&2||m.child===null||m.tag===4)continue e;m.child.return=m,m=m.child}if(!(m.flags&2))return m.stateNode}}function OL(m,b,w){var S=m.tag;if(S===5||S===6)m=m.stateNode,b?(w.nodeType===9?w.body:w.nodeName==="HTML"?w.ownerDocument.body:w).insertBefore(m,b):(b=w.nodeType===9?w.body:w.nodeName==="HTML"?w.ownerDocument.body:w,b.appendChild(m),w=w._reactRootContainer,w!=null||b.onclick!==null||(b.onclick=Iu));else if(S!==4&&(S===27&&qd(m.type)&&(w=m.stateNode,b=null),m=m.child,m!==null))for(OL(m,b,w),m=m.sibling;m!==null;)OL(m,b,w),m=m.sibling}function Zy(m,b,w){var S=m.tag;if(S===5||S===6)m=m.stateNode,b?w.insertBefore(m,b):w.appendChild(m);else if(S!==4&&(S===27&&qd(m.type)&&(w=m.stateNode),m=m.child,m!==null))for(Zy(m,b,w),m=m.sibling;m!==null;)Zy(m,b,w),m=m.sibling}function Voe(m){var b=m.stateNode,w=m.memoizedProps;try{for(var S=m.type,j=b.attributes;j.length;)b.removeAttributeNode(j[0]);Ts(b,S,w),b[At]=m,b[qt]=w}catch(R){eo(m,m.return,R)}}var Uu=!1,yi=!1,SL=!1,Qoe=typeof WeakSet=="function"?WeakSet:Set,ls=null;function sYe(m,b){if(m=m.containerInfo,UL=mw,m=rre(m),bR(m)){if("selectionStart"in m)var w={start:m.selectionStart,end:m.selectionEnd};else e:{w=(w=m.ownerDocument)&&w.defaultView||window;var S=w.getSelection&&w.getSelection();if(S&&S.rangeCount!==0){w=S.anchorNode;var j=S.anchorOffset,R=S.focusNode;S=S.focusOffset;try{w.nodeType,R.nodeType}catch{w=null;break e}var J=0,oe=-1,Oe=-1,qe=0,nt=0,at=m,Ue=null;t:for(;;){for(var Ge;at!==w||j!==0&&at.nodeType!==3||(oe=J+j),at!==R||S!==0&&at.nodeType!==3||(Oe=J+S),at.nodeType===3&&(J+=at.nodeValue.length),(Ge=at.firstChild)!==null;)Ue=at,at=Ge;for(;;){if(at===m)break t;if(Ue===w&&++qe===j&&(oe=J),Ue===R&&++nt===S&&(Oe=J),(Ge=at.nextSibling)!==null)break;at=Ue,Ue=at.parentNode}at=Ge}w=oe===-1||Oe===-1?null:{start:oe,end:Oe}}else w=null}w=w||{start:0,end:0}}else w=null;for(WL={focusedElem:m,selectionRange:w},mw=!1,ls=b;ls!==null;)if(b=ls,m=b.child,(b.subtreeFlags&1028)!==0&&m!==null)m.return=b,ls=m;else for(;ls!==null;){switch(b=ls,R=b.alternate,m=b.flags,b.tag){case 0:if((m&4)!==0&&(m=b.updateQueue,m=m!==null?m.events:null,m!==null))for(w=0;w<m.length;w++)j=m[w],j.ref.impl=j.nextImpl;break;case 11:case 15:break;case 1:if((m&1024)!==0&&R!==null){m=void 0,w=b,j=R.memoizedProps,R=R.memoizedState,S=w.stateNode;try{var en=up(w.type,j);m=S.getSnapshotBeforeUpdate(en,R),S.__reactInternalSnapshotBeforeUpdate=m}catch(Pn){eo(w,w.return,Pn)}}break;case 3:if((m&1024)!==0){if(m=b.stateNode.containerInfo,w=m.nodeType,w===9)YL(m);else if(w===1)switch(m.nodeName){case"HEAD":case"HTML":case"BODY":YL(m);break;default:m.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((m&1024)!==0)throw Error(r(163))}if(m=b.sibling,m!==null){m.return=b.return,ls=m;break}ls=b.return}}function Uoe(m,b,w){var S=w.flags;switch(w.tag){case 0:case 11:case 15:Zu(m,w),S&4&&t7(5,w);break;case 1:if(Zu(m,w),S&4)if(m=w.stateNode,b===null)try{m.componentDidMount()}catch(J){eo(w,w.return,J)}else{var j=up(w.type,b.memoizedProps);b=b.memoizedState;try{m.componentDidUpdate(j,b,m.__reactInternalSnapshotBeforeUpdate)}catch(J){eo(w,w.return,J)}}S&64&&Boe(w),S&512&&n7(w,w.return);break;case 3:if(Zu(m,w),S&64&&(m=w.updateQueue,m!==null)){if(b=null,w.child!==null)switch(w.child.tag){case 27:case 5:b=w.child.stateNode;break;case 1:b=w.child.stateNode}try{Mre(m,b)}catch(J){eo(w,w.return,J)}}break;case 27:b===null&&S&4&&Voe(w);case 26:case 5:Zu(m,w),b===null&&S&4&&Foe(w),S&512&&n7(w,w.return);break;case 12:Zu(m,w);break;case 31:Zu(m,w),S&4&&Goe(m,w);break;case 13:Zu(m,w),S&4&&Yoe(m,w),S&64&&(m=w.memoizedState,m!==null&&(m=m.dehydrated,m!==null&&(w=mYe.bind(null,w),LYe(m,w))));break;case 22:if(S=w.memoizedState!==null||Uu,!S){b=b!==null&&b.memoizedState!==null||yi,j=Uu;var R=yi;Uu=S,(yi=b)&&!R?Gu(m,w,(w.subtreeFlags&8772)!==0):Zu(m,w),Uu=j,yi=R}break;case 30:break;default:Zu(m,w)}}function Woe(m){var b=m.alternate;b!==null&&(m.alternate=null,Woe(b)),m.child=null,m.deletions=null,m.sibling=null,m.tag===5&&(b=m.stateNode,b!==null&&Ae(b)),m.stateNode=null,m.return=null,m.dependencies=null,m.memoizedProps=null,m.memoizedState=null,m.pendingProps=null,m.stateNode=null,m.updateQueue=null}var Po=null,tl=!1;function Wu(m,b,w){for(w=w.child;w!==null;)Zoe(m,b,w),w=w.sibling}function Zoe(m,b,w){if(Dn&&typeof Dn.onCommitFiberUnmount=="function")try{Dn.onCommitFiberUnmount(Kt,w)}catch{}switch(w.tag){case 26:yi||d1(w,b),Wu(m,b,w),w.memoizedState?w.memoizedState.count--:w.stateNode&&(w=w.stateNode,w.parentNode.removeChild(w));break;case 27:yi||d1(w,b);var S=Po,j=tl;qd(w.type)&&(Po=w.stateNode,tl=!1),Wu(m,b,w),d7(w.stateNode),Po=S,tl=j;break;case 5:yi||d1(w,b);case 6:if(S=Po,j=tl,Po=null,Wu(m,b,w),Po=S,tl=j,Po!==null)if(tl)try{(Po.nodeType===9?Po.body:Po.nodeName==="HTML"?Po.ownerDocument.body:Po).removeChild(w.stateNode)}catch(R){eo(w,b,R)}else try{Po.removeChild(w.stateNode)}catch(R){eo(w,b,R)}break;case 18:Po!==null&&(tl?(m=Po,Bie(m.nodeType===9?m.body:m.nodeName==="HTML"?m.ownerDocument.body:m,w.stateNode),Tm(m)):Bie(Po,w.stateNode));break;case 4:S=Po,j=tl,Po=w.stateNode.containerInfo,tl=!0,Wu(m,b,w),Po=S,tl=j;break;case 0:case 11:case 14:case 15:Id(2,w,b),yi||Id(4,w,b),Wu(m,b,w);break;case 1:yi||(d1(w,b),S=w.stateNode,typeof S.componentWillUnmount=="function"&&Hoe(w,b,S)),Wu(m,b,w);break;case 21:Wu(m,b,w);break;case 22:yi=(S=yi)||w.memoizedState!==null,Wu(m,b,w),yi=S;break;default:Wu(m,b,w)}}function Goe(m,b){if(b.memoizedState===null&&(m=b.alternate,m!==null&&(m=m.memoizedState,m!==null))){m=m.dehydrated;try{Tm(m)}catch(w){eo(b,b.return,w)}}}function Yoe(m,b){if(b.memoizedState===null&&(m=b.alternate,m!==null&&(m=m.memoizedState,m!==null&&(m=m.dehydrated,m!==null))))try{Tm(m)}catch(w){eo(b,b.return,w)}}function aYe(m){switch(m.tag){case 31:case 13:case 19:var b=m.stateNode;return b===null&&(b=m.stateNode=new Qoe),b;case 22:return m=m.stateNode,b=m._retryCache,b===null&&(b=m._retryCache=new Qoe),b;default:throw Error(r(435,m.tag))}}function Gy(m,b){var w=aYe(m);b.forEach(function(S){if(!w.has(S)){w.add(S);var j=gYe.bind(null,m,S);S.then(j,j)}})}function nl(m,b){var w=b.deletions;if(w!==null)for(var S=0;S<w.length;S++){var j=w[S],R=m,J=b,oe=J;e:for(;oe!==null;){switch(oe.tag){case 27:if(qd(oe.type)){Po=oe.stateNode,tl=!1;break e}break;case 5:Po=oe.stateNode,tl=!1;break e;case 3:case 4:Po=oe.stateNode.containerInfo,tl=!0;break e}oe=oe.return}if(Po===null)throw Error(r(160));Zoe(R,J,j),Po=null,tl=!1,R=j.alternate,R!==null&&(R.return=null),j.return=null}if(b.subtreeFlags&13886)for(b=b.child;b!==null;)Xoe(b,m),b=b.sibling}var d0=null;function Xoe(m,b){var w=m.alternate,S=m.flags;switch(m.tag){case 0:case 11:case 14:case 15:nl(b,m),rl(m),S&4&&(Id(3,m,m.return),t7(3,m),Id(5,m,m.return));break;case 1:nl(b,m),rl(m),S&512&&(yi||w===null||d1(w,w.return)),S&64&&Uu&&(m=m.updateQueue,m!==null&&(S=m.callbacks,S!==null&&(w=m.shared.hiddenCallbacks,m.shared.hiddenCallbacks=w===null?S:w.concat(S))));break;case 26:var j=d0;if(nl(b,m),rl(m),S&512&&(yi||w===null||d1(w,w.return)),S&4){var R=w!==null?w.memoizedState:null;if(S=m.memoizedState,w===null)if(S===null)if(m.stateNode===null){e:{S=m.type,w=m.memoizedProps,j=j.ownerDocument||j;t:switch(S){case"title":R=j.getElementsByTagName("title")[0],(!R||R[Zt]||R[At]||R.namespaceURI==="http://www.w3.org/2000/svg"||R.hasAttribute("itemprop"))&&(R=j.createElement(S),j.head.insertBefore(R,j.querySelector("head > title"))),Ts(R,S,w),R[At]=m,Yn(R),S=R;break e;case"link":var J=Xie("link","href",j).get(S+(w.href||""));if(J){for(var oe=0;oe<J.length;oe++)if(R=J[oe],R.getAttribute("href")===(w.href==null||w.href===""?null:w.href)&&R.getAttribute("rel")===(w.rel==null?null:w.rel)&&R.getAttribute("title")===(w.title==null?null:w.title)&&R.getAttribute("crossorigin")===(w.crossOrigin==null?null:w.crossOrigin)){J.splice(oe,1);break t}}R=j.createElement(S),Ts(R,S,w),j.head.appendChild(R);break;case"meta":if(J=Xie("meta","content",j).get(S+(w.content||""))){for(oe=0;oe<J.length;oe++)if(R=J[oe],R.getAttribute("content")===(w.content==null?null:""+w.content)&&R.getAttribute("name")===(w.name==null?null:w.name)&&R.getAttribute("property")===(w.property==null?null:w.property)&&R.getAttribute("http-equiv")===(w.httpEquiv==null?null:w.httpEquiv)&&R.getAttribute("charset")===(w.charSet==null?null:w.charSet)){J.splice(oe,1);break t}}R=j.createElement(S),Ts(R,S,w),j.head.appendChild(R);break;default:throw Error(r(468,S))}R[At]=m,Yn(R),S=R}m.stateNode=S}else Kie(j,m.type,m.stateNode);else m.stateNode=Yie(j,S,m.memoizedProps);else R!==S?(R===null?w.stateNode!==null&&(w=w.stateNode,w.parentNode.removeChild(w)):R.count--,S===null?Kie(j,m.type,m.stateNode):Yie(j,S,m.memoizedProps)):S===null&&m.stateNode!==null&&wL(m,m.memoizedProps,w.memoizedProps)}break;case 27:nl(b,m),rl(m),S&512&&(yi||w===null||d1(w,w.return)),w!==null&&S&4&&wL(m,m.memoizedProps,w.memoizedProps);break;case 5:if(nl(b,m),rl(m),S&512&&(yi||w===null||d1(w,w.return)),m.flags&32){j=m.stateNode;try{K4(j,"")}catch(en){eo(m,m.return,en)}}S&4&&m.stateNode!=null&&(j=m.memoizedProps,wL(m,j,w!==null?w.memoizedProps:j)),S&1024&&(SL=!0);break;case 6:if(nl(b,m),rl(m),S&4){if(m.stateNode===null)throw Error(r(162));S=m.memoizedProps,w=m.stateNode;try{w.nodeValue=S}catch(en){eo(m,m.return,en)}}break;case 3:if(dw=null,j=d0,d0=cw(b.containerInfo),nl(b,m),d0=j,rl(m),S&4&&w!==null&&w.memoizedState.isDehydrated)try{Tm(b.containerInfo)}catch(en){eo(m,m.return,en)}SL&&(SL=!1,Koe(m));break;case 4:S=d0,d0=cw(m.stateNode.containerInfo),nl(b,m),rl(m),d0=S;break;case 12:nl(b,m),rl(m);break;case 31:nl(b,m),rl(m),S&4&&(S=m.updateQueue,S!==null&&(m.updateQueue=null,Gy(m,S)));break;case 13:nl(b,m),rl(m),m.child.flags&8192&&m.memoizedState!==null!=(w!==null&&w.memoizedState!==null)&&(Xy=De()),S&4&&(S=m.updateQueue,S!==null&&(m.updateQueue=null,Gy(m,S)));break;case 22:j=m.memoizedState!==null;var Oe=w!==null&&w.memoizedState!==null,qe=Uu,nt=yi;if(Uu=qe||j,yi=nt||Oe,nl(b,m),yi=nt,Uu=qe,rl(m),S&8192)e:for(b=m.stateNode,b._visibility=j?b._visibility&-2:b._visibility|1,j&&(w===null||Oe||Uu||yi||dp(m)),w=null,b=m;;){if(b.tag===5||b.tag===26){if(w===null){Oe=w=b;try{if(R=Oe.stateNode,j)J=R.style,typeof J.setProperty=="function"?J.setProperty("display","none","important"):J.display="none";else{oe=Oe.stateNode;var at=Oe.memoizedProps.style,Ue=at!=null&&at.hasOwnProperty("display")?at.display:null;oe.style.display=Ue==null||typeof Ue=="boolean"?"":(""+Ue).trim()}}catch(en){eo(Oe,Oe.return,en)}}}else if(b.tag===6){if(w===null){Oe=b;try{Oe.stateNode.nodeValue=j?"":Oe.memoizedProps}catch(en){eo(Oe,Oe.return,en)}}}else if(b.tag===18){if(w===null){Oe=b;try{var Ge=Oe.stateNode;j?Hie(Ge,!0):Hie(Oe.stateNode,!1)}catch(en){eo(Oe,Oe.return,en)}}}else if((b.tag!==22&&b.tag!==23||b.memoizedState===null||b===m)&&b.child!==null){b.child.return=b,b=b.child;continue}if(b===m)break e;for(;b.sibling===null;){if(b.return===null||b.return===m)break e;w===b&&(w=null),b=b.return}w===b&&(w=null),b.sibling.return=b.return,b=b.sibling}S&4&&(S=m.updateQueue,S!==null&&(w=S.retryQueue,w!==null&&(S.retryQueue=null,Gy(m,w))));break;case 19:nl(b,m),rl(m),S&4&&(S=m.updateQueue,S!==null&&(m.updateQueue=null,Gy(m,S)));break;case 30:break;case 21:break;default:nl(b,m),rl(m)}}function rl(m){var b=m.flags;if(b&2){try{for(var w,S=m.return;S!==null;){if(qoe(S)){w=S;break}S=S.return}if(w==null)throw Error(r(160));switch(w.tag){case 27:var j=w.stateNode,R=kL(m);Zy(m,R,j);break;case 5:var J=w.stateNode;w.flags&32&&(K4(J,""),w.flags&=-33);var oe=kL(m);Zy(m,oe,J);break;case 3:case 4:var Oe=w.stateNode.containerInfo,qe=kL(m);OL(m,qe,Oe);break;default:throw Error(r(161))}}catch(nt){eo(m,m.return,nt)}m.flags&=-3}b&4096&&(m.flags&=-4097)}function Koe(m){if(m.subtreeFlags&1024)for(m=m.child;m!==null;){var b=m;Koe(b),b.tag===5&&b.flags&1024&&b.stateNode.reset(),m=m.sibling}}function Zu(m,b){if(b.subtreeFlags&8772)for(b=b.child;b!==null;)Uoe(m,b.alternate,b),b=b.sibling}function dp(m){for(m=m.child;m!==null;){var b=m;switch(b.tag){case 0:case 11:case 14:case 15:Id(4,b,b.return),dp(b);break;case 1:d1(b,b.return);var w=b.stateNode;typeof w.componentWillUnmount=="function"&&Hoe(b,b.return,w),dp(b);break;case 27:d7(b.stateNode);case 26:case 5:d1(b,b.return),dp(b);break;case 22:b.memoizedState===null&&dp(b);break;case 30:dp(b);break;default:dp(b)}m=m.sibling}}function Gu(m,b,w){for(w=w&&(b.subtreeFlags&8772)!==0,b=b.child;b!==null;){var S=b.alternate,j=m,R=b,J=R.flags;switch(R.tag){case 0:case 11:case 15:Gu(j,R,w),t7(4,R);break;case 1:if(Gu(j,R,w),S=R,j=S.stateNode,typeof j.componentDidMount=="function")try{j.componentDidMount()}catch(qe){eo(S,S.return,qe)}if(S=R,j=S.updateQueue,j!==null){var oe=S.stateNode;try{var Oe=j.shared.hiddenCallbacks;if(Oe!==null)for(j.shared.hiddenCallbacks=null,j=0;j<Oe.length;j++)Tre(Oe[j],oe)}catch(qe){eo(S,S.return,qe)}}w&&J&64&&Boe(R),n7(R,R.return);break;case 27:Voe(R);case 26:case 5:Gu(j,R,w),w&&S===null&&J&4&&Foe(R),n7(R,R.return);break;case 12:Gu(j,R,w);break;case 31:Gu(j,R,w),w&&J&4&&Goe(j,R);break;case 13:Gu(j,R,w),w&&J&4&&Yoe(j,R);break;case 22:R.memoizedState===null&&Gu(j,R,w),n7(R,R.return);break;case 30:break;default:Gu(j,R,w)}b=b.sibling}}function CL(m,b){var w=null;m!==null&&m.memoizedState!==null&&m.memoizedState.cachePool!==null&&(w=m.memoizedState.cachePool.pool),m=null,b.memoizedState!==null&&b.memoizedState.cachePool!==null&&(m=b.memoizedState.cachePool.pool),m!==w&&(m!=null&&m.refCount++,w!=null&&F8(w))}function AL(m,b){m=null,b.alternate!==null&&(m=b.alternate.memoizedState.cache),b=b.memoizedState.cache,b!==m&&(b.refCount++,m!=null&&F8(m))}function f0(m,b,w,S){if(b.subtreeFlags&10256)for(b=b.child;b!==null;)Joe(m,b,w,S),b=b.sibling}function Joe(m,b,w,S){var j=b.flags;switch(b.tag){case 0:case 11:case 15:f0(m,b,w,S),j&2048&&t7(9,b);break;case 1:f0(m,b,w,S);break;case 3:f0(m,b,w,S),j&2048&&(m=null,b.alternate!==null&&(m=b.alternate.memoizedState.cache),b=b.memoizedState.cache,b!==m&&(b.refCount++,m!=null&&F8(m)));break;case 12:if(j&2048){f0(m,b,w,S),m=b.stateNode;try{var R=b.memoizedProps,J=R.id,oe=R.onPostCommit;typeof oe=="function"&&oe(J,b.alternate===null?"mount":"update",m.passiveEffectDuration,-0)}catch(Oe){eo(b,b.return,Oe)}}else f0(m,b,w,S);break;case 31:f0(m,b,w,S);break;case 13:f0(m,b,w,S);break;case 23:break;case 22:R=b.stateNode,J=b.alternate,b.memoizedState!==null?R._visibility&2?f0(m,b,w,S):r7(m,b):R._visibility&2?f0(m,b,w,S):(R._visibility|=2,bm(m,b,w,S,(b.subtreeFlags&10256)!==0||!1)),j&2048&&CL(J,b);break;case 24:f0(m,b,w,S),j&2048&&AL(b.alternate,b);break;default:f0(m,b,w,S)}}function bm(m,b,w,S,j){for(j=j&&((b.subtreeFlags&10256)!==0||!1),b=b.child;b!==null;){var R=m,J=b,oe=w,Oe=S,qe=J.flags;switch(J.tag){case 0:case 11:case 15:bm(R,J,oe,Oe,j),t7(8,J);break;case 23:break;case 22:var nt=J.stateNode;J.memoizedState!==null?nt._visibility&2?bm(R,J,oe,Oe,j):r7(R,J):(nt._visibility|=2,bm(R,J,oe,Oe,j)),j&&qe&2048&&CL(J.alternate,J);break;case 24:bm(R,J,oe,Oe,j),j&&qe&2048&&AL(J.alternate,J);break;default:bm(R,J,oe,Oe,j)}b=b.sibling}}function r7(m,b){if(b.subtreeFlags&10256)for(b=b.child;b!==null;){var w=m,S=b,j=S.flags;switch(S.tag){case 22:r7(w,S),j&2048&&CL(S.alternate,S);break;case 24:r7(w,S),j&2048&&AL(S.alternate,S);break;default:r7(w,S)}b=b.sibling}}var o7=8192;function _m(m,b,w){if(m.subtreeFlags&o7)for(m=m.child;m!==null;)eie(m,b,w),m=m.sibling}function eie(m,b,w){switch(m.tag){case 26:_m(m,b,w),m.flags&o7&&m.memoizedState!==null&&WYe(w,d0,m.memoizedState,m.memoizedProps);break;case 5:_m(m,b,w);break;case 3:case 4:var S=d0;d0=cw(m.stateNode.containerInfo),_m(m,b,w),d0=S;break;case 22:m.memoizedState===null&&(S=m.alternate,S!==null&&S.memoizedState!==null?(S=o7,o7=16777216,_m(m,b,w),o7=S):_m(m,b,w));break;default:_m(m,b,w)}}function tie(m){var b=m.alternate;if(b!==null&&(m=b.child,m!==null)){b.child=null;do b=m.sibling,m.sibling=null,m=b;while(m!==null)}}function i7(m){var b=m.deletions;if((m.flags&16)!==0){if(b!==null)for(var w=0;w<b.length;w++){var S=b[w];ls=S,rie(S,m)}tie(m)}if(m.subtreeFlags&10256)for(m=m.child;m!==null;)nie(m),m=m.sibling}function nie(m){switch(m.tag){case 0:case 11:case 15:i7(m),m.flags&2048&&Id(9,m,m.return);break;case 3:i7(m);break;case 12:i7(m);break;case 22:var b=m.stateNode;m.memoizedState!==null&&b._visibility&2&&(m.return===null||m.return.tag!==13)?(b._visibility&=-3,Yy(m)):i7(m);break;default:i7(m)}}function Yy(m){var b=m.deletions;if((m.flags&16)!==0){if(b!==null)for(var w=0;w<b.length;w++){var S=b[w];ls=S,rie(S,m)}tie(m)}for(m=m.child;m!==null;){switch(b=m,b.tag){case 0:case 11:case 15:Id(8,b,b.return),Yy(b);break;case 22:w=b.stateNode,w._visibility&2&&(w._visibility&=-3,Yy(b));break;default:Yy(b)}m=m.sibling}}function rie(m,b){for(;ls!==null;){var w=ls;switch(w.tag){case 0:case 11:case 15:Id(8,w,b);break;case 23:case 22:if(w.memoizedState!==null&&w.memoizedState.cachePool!==null){var S=w.memoizedState.cachePool.pool;S!=null&&S.refCount++}break;case 24:F8(w.memoizedState.cache)}if(S=w.child,S!==null)S.return=w,ls=S;else e:for(w=m;ls!==null;){S=ls;var j=S.sibling,R=S.return;if(Woe(S),S===w){ls=null;break e}if(j!==null){j.return=R,ls=j;break e}ls=R}}}var lYe={getCacheForType:function(m){var b=As(bi),w=b.data.get(m);return w===void 0&&(w=m(),b.data.set(m,w)),w},cacheSignal:function(){return As(bi).controller.signal}},cYe=typeof WeakMap=="function"?WeakMap:Map,Wr=0,ho=null,gr=null,wr=0,Jr=0,Nl=null,Dd=!1,xm=!1,EL=!1,Yu=0,Yo=0,zd=0,fp=0,TL=0,Rl=0,ym=0,s7=null,ol=null,ML=!1,Xy=0,oie=0,Ky=1/0,Jy=null,$d=null,Li=0,Bd=null,wm=null,Xu=0,PL=0,jL=null,iie=null,a7=0,NL=null;function Ll(){return(Wr&2)!==0&&wr!==0?wr&-wr:N.T!==null?$L():Kn()}function sie(){if(Rl===0)if((wr&536870912)===0||Er){var m=Dt;Dt<<=1,(Dt&3932160)===0&&(Dt=262144),Rl=m}else Rl=536870912;return m=Pl.current,m!==null&&(m.flags|=32),Rl}function il(m,b,w){(m===ho&&(Jr===2||Jr===9)||m.cancelPendingCommit!==null)&&(km(m,0),Hd(m,wr,Rl,!1)),sn(m,w),((Wr&2)===0||m!==ho)&&(m===ho&&((Wr&2)===0&&(fp|=w),Yo===4&&Hd(m,wr,Rl,!1)),f1(m))}function aie(m,b,w){if((Wr&6)!==0)throw Error(r(327));var S=!w&&(b&127)===0&&(b&m.expiredLanes)===0||pn(m,b),j=S?fYe(m,b):LL(m,b,!0),R=S;do{if(j===0){xm&&!S&&Hd(m,b,0,!1);break}else{if(w=m.current.alternate,R&&!uYe(w)){j=LL(m,b,!1),R=!1;continue}if(j===2){if(R=b,m.errorRecoveryDisabledLanes&R)var J=0;else J=m.pendingLanes&-536870913,J=J!==0?J:J&536870912?536870912:0;if(J!==0){b=J;e:{var oe=m;j=s7;var Oe=oe.current.memoizedState.isDehydrated;if(Oe&&(km(oe,J).flags|=256),J=LL(oe,J,!1),J!==2){if(EL&&!Oe){oe.errorRecoveryDisabledLanes|=R,fp|=R,j=4;break e}R=ol,ol=j,R!==null&&(ol===null?ol=R:ol.push.apply(ol,R))}j=J}if(R=!1,j!==2)continue}}if(j===1){km(m,0),Hd(m,b,0,!0);break}e:{switch(S=m,R=j,R){case 0:case 1:throw Error(r(345));case 4:if((b&4194048)!==b)break;case 6:Hd(S,b,Rl,!Dd);break e;case 2:ol=null;break;case 3:case 5:break;default:throw Error(r(329))}if((b&62914560)===b&&(j=Xy+300-De(),10<j)){if(Hd(S,b,Rl,!Dd),jt(S,0,!0)!==0)break e;Xu=b,S.timeoutHandle=zie(lie.bind(null,S,w,ol,Jy,ML,b,Rl,fp,ym,Dd,R,"Throttled",-0,0),j);break e}lie(S,w,ol,Jy,ML,b,Rl,fp,ym,Dd,R,null,-0,0)}}break}while(!0);f1(m)}function lie(m,b,w,S,j,R,J,oe,Oe,qe,nt,at,Ue,Ge){if(m.timeoutHandle=-1,at=b.subtreeFlags,at&8192||(at&16785408)===16785408){at={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Iu},eie(b,R,at);var en=(R&62914560)===R?Xy-De():(R&4194048)===R?oie-De():0;if(en=ZYe(at,en),en!==null){Xu=R,m.cancelPendingCommit=en(gie.bind(null,m,b,R,w,S,j,J,oe,Oe,nt,at,null,Ue,Ge)),Hd(m,R,J,!qe);return}}gie(m,b,R,w,S,j,J,oe,Oe)}function uYe(m){for(var b=m;;){var w=b.tag;if((w===0||w===11||w===15)&&b.flags&16384&&(w=b.updateQueue,w!==null&&(w=w.stores,w!==null)))for(var S=0;S<w.length;S++){var j=w[S],R=j.getSnapshot;j=j.value;try{if(!Tl(R(),j))return!1}catch{return!1}}if(w=b.child,b.subtreeFlags&16384&&w!==null)w.return=b,b=w;else{if(b===m)break;for(;b.sibling===null;){if(b.return===null||b.return===m)return!0;b=b.return}b.sibling.return=b.return,b=b.sibling}}return!0}function Hd(m,b,w,S){b&=~TL,b&=~fp,m.suspendedLanes|=b,m.pingedLanes&=~b,S&&(m.warmLanes|=b),S=m.expirationTimes;for(var j=b;0<j;){var R=31-Ve(j),J=1<<R;S[R]=-1,j&=~J}w!==0&&Wt(m,w,b)}function ew(){return(Wr&6)===0?(l7(0),!1):!0}function RL(){if(gr!==null){if(Jr===0)var m=gr.return;else m=gr,Bu=rp=null,YR(m),hm=null,V8=0,m=gr;for(;m!==null;)$oe(m.alternate,m),m=m.return;gr=null}}function km(m,b){var w=m.timeoutHandle;w!==-1&&(m.timeoutHandle=-1,MYe(w)),w=m.cancelPendingCommit,w!==null&&(m.cancelPendingCommit=null,w()),Xu=0,RL(),ho=m,gr=w=zu(m.current,null),wr=b,Jr=0,Nl=null,Dd=!1,xm=pn(m,b),EL=!1,ym=Rl=TL=fp=zd=Yo=0,ol=s7=null,ML=!1,(b&8)!==0&&(b|=b&32);var S=m.entangledLanes;if(S!==0)for(m=m.entanglements,S&=b;0<S;){var j=31-Ve(S),R=1<<j;b|=m[j],S&=~R}return Yu=b,yy(),w}function cie(m,b){Xn=null,N.H=K8,b===fm||b===Ty?(b=Sre(),Jr=3):b===zR?(b=Sre(),Jr=4):Jr=b===fL?8:b!==null&&typeof b=="object"&&typeof b.then=="function"?6:1,Nl=b,gr===null&&(Yo=1,qy(m,uc(b,m.current)))}function uie(){var m=Pl.current;return m===null?!0:(wr&4194048)===wr?pc===null:(wr&62914560)===wr||(wr&536870912)!==0?m===pc:!1}function die(){var m=N.H;return N.H=K8,m===null?K8:m}function fie(){var m=N.A;return N.A=lYe,m}function tw(){Yo=4,Dd||(wr&4194048)!==wr&&Pl.current!==null||(xm=!0),(zd&134217727)===0&&(fp&134217727)===0||ho===null||Hd(ho,wr,Rl,!1)}function LL(m,b,w){var S=Wr;Wr|=2;var j=die(),R=fie();(ho!==m||wr!==b)&&(Jy=null,km(m,b)),b=!1;var J=Yo;e:do try{if(Jr!==0&&gr!==null){var oe=gr,Oe=Nl;switch(Jr){case 8:RL(),J=6;break e;case 3:case 2:case 9:case 6:Pl.current===null&&(b=!0);var qe=Jr;if(Jr=0,Nl=null,Om(m,oe,Oe,qe),w&&xm){J=0;break e}break;default:qe=Jr,Jr=0,Nl=null,Om(m,oe,Oe,qe)}}dYe(),J=Yo;break}catch(nt){cie(m,nt)}while(!0);return b&&m.shellSuspendCounter++,Bu=rp=null,Wr=S,N.H=j,N.A=R,gr===null&&(ho=null,wr=0,yy()),J}function dYe(){for(;gr!==null;)hie(gr)}function fYe(m,b){var w=Wr;Wr|=2;var S=die(),j=fie();ho!==m||wr!==b?(Jy=null,Ky=De()+500,km(m,b)):xm=pn(m,b);e:do try{if(Jr!==0&&gr!==null){b=gr;var R=Nl;t:switch(Jr){case 1:Jr=0,Nl=null,Om(m,b,R,1);break;case 2:case 9:if(kre(R)){Jr=0,Nl=null,pie(b);break}b=function(){Jr!==2&&Jr!==9||ho!==m||(Jr=7),f1(m)},R.then(b,b);break e;case 3:Jr=7;break e;case 4:Jr=5;break e;case 7:kre(R)?(Jr=0,Nl=null,pie(b)):(Jr=0,Nl=null,Om(m,b,R,7));break;case 5:var J=null;switch(gr.tag){case 26:J=gr.memoizedState;case 5:case 27:var oe=gr;if(J?Jie(J):oe.stateNode.complete){Jr=0,Nl=null;var Oe=oe.sibling;if(Oe!==null)gr=Oe;else{var qe=oe.return;qe!==null?(gr=qe,nw(qe)):gr=null}break t}}Jr=0,Nl=null,Om(m,b,R,5);break;case 6:Jr=0,Nl=null,Om(m,b,R,6);break;case 8:RL(),Yo=6;break e;default:throw Error(r(462))}}hYe();break}catch(nt){cie(m,nt)}while(!0);return Bu=rp=null,N.H=S,N.A=j,Wr=w,gr!==null?0:(ho=null,wr=0,yy(),Yo)}function hYe(){for(;gr!==null&&!Ne();)hie(gr)}function hie(m){var b=Doe(m.alternate,m,Yu);m.memoizedProps=m.pendingProps,b===null?nw(m):gr=b}function pie(m){var b=m,w=b.alternate;switch(b.tag){case 15:case 0:b=Poe(w,b,b.pendingProps,b.type,void 0,wr);break;case 11:b=Poe(w,b,b.pendingProps,b.type.render,b.ref,wr);break;case 5:YR(b);default:$oe(w,b),b=gr=fre(b,Yu),b=Doe(w,b,Yu)}m.memoizedProps=m.pendingProps,b===null?nw(m):gr=b}function Om(m,b,w,S){Bu=rp=null,YR(b),hm=null,V8=0;var j=b.return;try{if(tYe(m,j,b,w,wr)){Yo=1,qy(m,uc(w,m.current)),gr=null;return}}catch(R){if(j!==null)throw gr=j,R;Yo=1,qy(m,uc(w,m.current)),gr=null;return}b.flags&32768?(Er||S===1?m=!0:xm||(wr&536870912)!==0?m=!1:(Dd=m=!0,(S===2||S===9||S===3||S===6)&&(S=Pl.current,S!==null&&S.tag===13&&(S.flags|=16384))),mie(b,m)):nw(b)}function nw(m){var b=m;do{if((b.flags&32768)!==0){mie(b,Dd);return}m=b.return;var w=oYe(b.alternate,b,Yu);if(w!==null){gr=w;return}if(b=b.sibling,b!==null){gr=b;return}gr=b=m}while(b!==null);Yo===0&&(Yo=5)}function mie(m,b){do{var w=iYe(m.alternate,m);if(w!==null){w.flags&=32767,gr=w;return}if(w=m.return,w!==null&&(w.flags|=32768,w.subtreeFlags=0,w.deletions=null),!b&&(m=m.sibling,m!==null)){gr=m;return}gr=m=w}while(m!==null);Yo=6,gr=null}function gie(m,b,w,S,j,R,J,oe,Oe){m.cancelPendingCommit=null;do rw();while(Li!==0);if((Wr&6)!==0)throw Error(r(327));if(b!==null){if(b===m.current)throw Error(r(177));if(R=b.lanes|b.childLanes,R|=kR,Yt(m,w,R,J,oe,Oe),m===ho&&(gr=ho=null,wr=0),wm=b,Bd=m,Xu=w,PL=R,jL=j,iie=S,(b.subtreeFlags&10256)!==0||(b.flags&10256)!==0?(m.callbackNode=null,m.callbackPriority=0,vYe(Ee,function(){return yie(),null})):(m.callbackNode=null,m.callbackPriority=0),S=(b.flags&13878)!==0,(b.subtreeFlags&13878)!==0||S){S=N.T,N.T=null,j=V.p,V.p=2,J=Wr,Wr|=4;try{sYe(m,b,w)}finally{Wr=J,V.p=j,N.T=S}}Li=1,vie(),bie(),_ie()}}function vie(){if(Li===1){Li=0;var m=Bd,b=wm,w=(b.flags&13878)!==0;if((b.subtreeFlags&13878)!==0||w){w=N.T,N.T=null;var S=V.p;V.p=2;var j=Wr;Wr|=4;try{Xoe(b,m);var R=WL,J=rre(m.containerInfo),oe=R.focusedElem,Oe=R.selectionRange;if(J!==oe&&oe&&oe.ownerDocument&&nre(oe.ownerDocument.documentElement,oe)){if(Oe!==null&&bR(oe)){var qe=Oe.start,nt=Oe.end;if(nt===void 0&&(nt=qe),"selectionStart"in oe)oe.selectionStart=qe,oe.selectionEnd=Math.min(nt,oe.value.length);else{var at=oe.ownerDocument||document,Ue=at&&at.defaultView||window;if(Ue.getSelection){var Ge=Ue.getSelection(),en=oe.textContent.length,Pn=Math.min(Oe.start,en),io=Oe.end===void 0?Pn:Math.min(Oe.end,en);!Ge.extend&&Pn>io&&(J=io,io=Pn,Pn=J);var Re=tre(oe,Pn),Me=tre(oe,io);if(Re&&Me&&(Ge.rangeCount!==1||Ge.anchorNode!==Re.node||Ge.anchorOffset!==Re.offset||Ge.focusNode!==Me.node||Ge.focusOffset!==Me.offset)){var Fe=at.createRange();Fe.setStart(Re.node,Re.offset),Ge.removeAllRanges(),Pn>io?(Ge.addRange(Fe),Ge.extend(Me.node,Me.offset)):(Fe.setEnd(Me.node,Me.offset),Ge.addRange(Fe))}}}}for(at=[],Ge=oe;Ge=Ge.parentNode;)Ge.nodeType===1&&at.push({element:Ge,left:Ge.scrollLeft,top:Ge.scrollTop});for(typeof oe.focus=="function"&&oe.focus(),oe=0;oe<at.length;oe++){var rt=at[oe];rt.element.scrollLeft=rt.left,rt.element.scrollTop=rt.top}}mw=!!UL,WL=UL=null}finally{Wr=j,V.p=S,N.T=w}}m.current=b,Li=2}}function bie(){if(Li===2){Li=0;var m=Bd,b=wm,w=(b.flags&8772)!==0;if((b.subtreeFlags&8772)!==0||w){w=N.T,N.T=null;var S=V.p;V.p=2;var j=Wr;Wr|=4;try{Uoe(m,b.alternate,b)}finally{Wr=j,V.p=S,N.T=w}}Li=3}}function _ie(){if(Li===4||Li===3){Li=0,$e();var m=Bd,b=wm,w=Xu,S=iie;(b.subtreeFlags&10256)!==0||(b.flags&10256)!==0?Li=5:(Li=0,wm=Bd=null,xie(m,m.pendingLanes));var j=m.pendingLanes;if(j===0&&($d=null),dn(w),b=b.stateNode,Dn&&typeof Dn.onCommitFiberRoot=="function")try{Dn.onCommitFiberRoot(Kt,b,void 0,(b.current.flags&128)===128)}catch{}if(S!==null){b=N.T,j=V.p,V.p=2,N.T=null;try{for(var R=m.onRecoverableError,J=0;J<S.length;J++){var oe=S[J];R(oe.value,{componentStack:oe.stack})}}finally{N.T=b,V.p=j}}(Xu&3)!==0&&rw(),f1(m),j=m.pendingLanes,(w&261930)!==0&&(j&42)!==0?m===NL?a7++:(a7=0,NL=m):a7=0,l7(0)}}function xie(m,b){(m.pooledCacheLanes&=b)===0&&(b=m.pooledCache,b!=null&&(m.pooledCache=null,F8(b)))}function rw(){return vie(),bie(),_ie(),yie()}function yie(){if(Li!==5)return!1;var m=Bd,b=PL;PL=0;var w=dn(Xu),S=N.T,j=V.p;try{V.p=32>w?32:w,N.T=null,w=jL,jL=null;var R=Bd,J=Xu;if(Li=0,wm=Bd=null,Xu=0,(Wr&6)!==0)throw Error(r(331));var oe=Wr;if(Wr|=4,nie(R.current),Joe(R,R.current,J,w),Wr=oe,l7(0,!1),Dn&&typeof Dn.onPostCommitFiberRoot=="function")try{Dn.onPostCommitFiberRoot(Kt,R)}catch{}return!0}finally{V.p=j,N.T=S,xie(m,b)}}function wie(m,b,w){b=uc(w,b),b=dL(m.stateNode,b,2),m=Nd(m,b,2),m!==null&&(sn(m,2),f1(m))}function eo(m,b,w){if(m.tag===3)wie(m,m,w);else for(;b!==null;){if(b.tag===3){wie(b,m,w);break}else if(b.tag===1){var S=b.stateNode;if(typeof b.type.getDerivedStateFromError=="function"||typeof S.componentDidCatch=="function"&&($d===null||!$d.has(S))){m=uc(w,m),w=koe(2),S=Nd(b,w,2),S!==null&&(Ooe(w,S,b,m),sn(S,2),f1(S));break}}b=b.return}}function IL(m,b,w){var S=m.pingCache;if(S===null){S=m.pingCache=new cYe;var j=new Set;S.set(b,j)}else j=S.get(b),j===void 0&&(j=new Set,S.set(b,j));j.has(w)||(EL=!0,j.add(w),m=pYe.bind(null,m,b,w),b.then(m,m))}function pYe(m,b,w){var S=m.pingCache;S!==null&&S.delete(b),m.pingedLanes|=m.suspendedLanes&w,m.warmLanes&=~w,ho===m&&(wr&w)===w&&(Yo===4||Yo===3&&(wr&62914560)===wr&&300>De()-Xy?(Wr&2)===0&&km(m,0):TL|=w,ym===wr&&(ym=0)),f1(m)}function kie(m,b){b===0&&(b=Ke()),m=ep(m,b),m!==null&&(sn(m,b),f1(m))}function mYe(m){var b=m.memoizedState,w=0;b!==null&&(w=b.retryLane),kie(m,w)}function gYe(m,b){var w=0;switch(m.tag){case 31:case 13:var S=m.stateNode,j=m.memoizedState;j!==null&&(w=j.retryLane);break;case 19:S=m.stateNode;break;case 22:S=m.stateNode._retryCache;break;default:throw Error(r(314))}S!==null&&S.delete(b),kie(m,w)}function vYe(m,b){return Te(m,b)}var ow=null,Sm=null,DL=!1,iw=!1,zL=!1,Fd=0;function f1(m){m!==Sm&&m.next===null&&(Sm===null?ow=Sm=m:Sm=Sm.next=m),iw=!0,DL||(DL=!0,_Ye())}function l7(m,b){if(!zL&&iw){zL=!0;do for(var w=!1,S=ow;S!==null;){if(m!==0){var j=S.pendingLanes;if(j===0)var R=0;else{var J=S.suspendedLanes,oe=S.pingedLanes;R=(1<<31-Ve(42|m)+1)-1,R&=j&~(J&~oe),R=R&201326741?R&201326741|1:R?R|2:0}R!==0&&(w=!0,Aie(S,R))}else R=wr,R=jt(S,S===ho?R:0,S.cancelPendingCommit!==null||S.timeoutHandle!==-1),(R&3)===0||pn(S,R)||(w=!0,Aie(S,R));S=S.next}while(w);zL=!1}}function bYe(){Oie()}function Oie(){iw=DL=!1;var m=0;Fd!==0&&TYe()&&(m=Fd);for(var b=De(),w=null,S=ow;S!==null;){var j=S.next,R=Sie(S,b);R===0?(S.next=null,w===null?ow=j:w.next=j,j===null&&(Sm=w)):(w=S,(m!==0||(R&3)!==0)&&(iw=!0)),S=j}Li!==0&&Li!==5||l7(m),Fd!==0&&(Fd=0)}function Sie(m,b){for(var w=m.suspendedLanes,S=m.pingedLanes,j=m.expirationTimes,R=m.pendingLanes&-62914561;0<R;){var J=31-Ve(R),oe=1<<J,Oe=j[J];Oe===-1?((oe&w)===0||(oe&S)!==0)&&(j[J]=ke(oe,b)):Oe<=b&&(m.expiredLanes|=oe),R&=~oe}if(b=ho,w=wr,w=jt(m,m===b?w:0,m.cancelPendingCommit!==null||m.timeoutHandle!==-1),S=m.callbackNode,w===0||m===b&&(Jr===2||Jr===9)||m.cancelPendingCommit!==null)return S!==null&&S!==null&&pe(S),m.callbackNode=null,m.callbackPriority=0;if((w&3)===0||pn(m,w)){if(b=w&-w,b===m.callbackPriority)return b;switch(S!==null&&pe(S),dn(w)){case 2:case 8:w=Pe;break;case 32:w=Ee;break;case 268435456:w=et;break;default:w=Ee}return S=Cie.bind(null,m),w=Te(w,S),m.callbackPriority=b,m.callbackNode=w,b}return S!==null&&S!==null&&pe(S),m.callbackPriority=2,m.callbackNode=null,2}function Cie(m,b){if(Li!==0&&Li!==5)return m.callbackNode=null,m.callbackPriority=0,null;var w=m.callbackNode;if(rw()&&m.callbackNode!==w)return null;var S=wr;return S=jt(m,m===ho?S:0,m.cancelPendingCommit!==null||m.timeoutHandle!==-1),S===0?null:(aie(m,S,b),Sie(m,De()),m.callbackNode!=null&&m.callbackNode===w?Cie.bind(null,m):null)}function Aie(m,b){if(rw())return null;aie(m,b,!0)}function _Ye(){PYe(function(){(Wr&6)!==0?Te(ue,bYe):Oie()})}function $L(){if(Fd===0){var m=um;m===0&&(m=Pt,Pt<<=1,(Pt&261888)===0&&(Pt=256)),Fd=m}return Fd}function Eie(m){return m==null||typeof m=="symbol"||typeof m=="boolean"?null:typeof m=="function"?m:hy(""+m)}function Tie(m,b){var w=b.ownerDocument.createElement("input");return w.name=b.name,w.value=b.value,m.id&&w.setAttribute("form",m.id),b.parentNode.insertBefore(w,b),m=new FormData(m),w.parentNode.removeChild(w),m}function xYe(m,b,w,S,j){if(b==="submit"&&w&&w.stateNode===j){var R=Eie((j[qt]||null).action),J=S.submitter;J&&(b=(b=J[qt]||null)?Eie(b.formAction):J.getAttribute("formAction"),b!==null&&(R=b,J=null));var oe=new vy("action","action",null,S,j);m.push({event:oe,listeners:[{instance:null,listener:function(){if(S.defaultPrevented){if(Fd!==0){var Oe=J?Tie(j,J):new FormData(j);iL(w,{pending:!0,data:Oe,method:j.method,action:R},null,Oe)}}else typeof R=="function"&&(oe.preventDefault(),Oe=J?Tie(j,J):new FormData(j),iL(w,{pending:!0,data:Oe,method:j.method,action:R},R,Oe))},currentTarget:j}]})}}for(var BL=0;BL<wR.length;BL++){var HL=wR[BL],yYe=HL.toLowerCase(),wYe=HL[0].toUpperCase()+HL.slice(1);u0(yYe,"on"+wYe)}u0(sre,"onAnimationEnd"),u0(are,"onAnimationIteration"),u0(lre,"onAnimationStart"),u0("dblclick","onDoubleClick"),u0("focusin","onFocus"),u0("focusout","onBlur"),u0(zGe,"onTransitionRun"),u0($Ge,"onTransitionStart"),u0(BGe,"onTransitionCancel"),u0(cre,"onTransitionEnd"),Ja("onMouseEnter",["mouseout","mouseover"]),Ja("onMouseLeave",["mouseout","mouseover"]),Ja("onPointerEnter",["pointerout","pointerover"]),Ja("onPointerLeave",["pointerout","pointerover"]),Ss("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Ss("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Ss("onBeforeInput",["compositionend","keypress","textInput","paste"]),Ss("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Ss("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Ss("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var c7="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),kYe=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(c7));function Mie(m,b){b=(b&4)!==0;for(var w=0;w<m.length;w++){var S=m[w],j=S.event;S=S.listeners;e:{var R=void 0;if(b)for(var J=S.length-1;0<=J;J--){var oe=S[J],Oe=oe.instance,qe=oe.currentTarget;if(oe=oe.listener,Oe!==R&&j.isPropagationStopped())break e;R=oe,j.currentTarget=qe;try{R(j)}catch(nt){xy(nt)}j.currentTarget=null,R=Oe}else for(J=0;J<S.length;J++){if(oe=S[J],Oe=oe.instance,qe=oe.currentTarget,oe=oe.listener,Oe!==R&&j.isPropagationStopped())break e;R=oe,j.currentTarget=qe;try{R(j)}catch(nt){xy(nt)}j.currentTarget=null,R=Oe}}}}function vr(m,b){var w=b[Mn];w===void 0&&(w=b[Mn]=new Set);var S=m+"__bubble";w.has(S)||(Pie(b,m,2,!1),w.add(S))}function FL(m,b,w){var S=0;b&&(S|=4),Pie(w,m,S,b)}var sw="_reactListening"+Math.random().toString(36).slice(2);function qL(m){if(!m[sw]){m[sw]=!0,ai.forEach(function(w){w!=="selectionchange"&&(kYe.has(w)||FL(w,!1,m),FL(w,!0,m))});var b=m.nodeType===9?m:m.ownerDocument;b===null||b[sw]||(b[sw]=!0,FL("selectionchange",!1,b))}}function Pie(m,b,w,S){switch(sse(b)){case 2:var j=XYe;break;case 8:j=KYe;break;default:j=oI}w=j.bind(null,b,w,m),j=void 0,!cR||b!=="touchstart"&&b!=="touchmove"&&b!=="wheel"||(j=!0),S?j!==void 0?m.addEventListener(b,w,{capture:!0,passive:j}):m.addEventListener(b,w,!0):j!==void 0?m.addEventListener(b,w,{passive:j}):m.addEventListener(b,w,!1)}function VL(m,b,w,S,j){var R=S;if((b&1)===0&&(b&2)===0&&S!==null)e:for(;;){if(S===null)return;var J=S.tag;if(J===3||J===4){var oe=S.stateNode.containerInfo;if(oe===j)break;if(J===4)for(J=S.return;J!==null;){var Oe=J.tag;if((Oe===3||Oe===4)&&J.stateNode.containerInfo===j)return;J=J.return}for(;oe!==null;){if(J=ht(oe),J===null)return;if(Oe=J.tag,Oe===5||Oe===6||Oe===26||Oe===27){S=R=J;continue e}oe=oe.parentNode}}S=S.return}Ine(function(){var qe=R,nt=aR(w),at=[];e:{var Ue=ure.get(m);if(Ue!==void 0){var Ge=vy,en=m;switch(m){case"keypress":if(my(w)===0)break e;case"keydown":case"keyup":Ge=gGe;break;case"focusin":en="focus",Ge=hR;break;case"focusout":en="blur",Ge=hR;break;case"beforeblur":case"afterblur":Ge=hR;break;case"click":if(w.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ge=$ne;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ge=oGe;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ge=_Ge;break;case sre:case are:case lre:Ge=aGe;break;case cre:Ge=yGe;break;case"scroll":case"scrollend":Ge=nGe;break;case"wheel":Ge=kGe;break;case"copy":case"cut":case"paste":Ge=cGe;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ge=Hne;break;case"toggle":case"beforetoggle":Ge=SGe}var Pn=(b&4)!==0,io=!Pn&&(m==="scroll"||m==="scrollend"),Re=Pn?Ue!==null?Ue+"Capture":null:Ue;Pn=[];for(var Me=qe,Fe;Me!==null;){var rt=Me;if(Fe=rt.stateNode,rt=rt.tag,rt!==5&&rt!==26&&rt!==27||Fe===null||Re===null||(rt=P8(Me,Re),rt!=null&&Pn.push(u7(Me,rt,Fe))),io)break;Me=Me.return}0<Pn.length&&(Ue=new Ge(Ue,en,null,w,nt),at.push({event:Ue,listeners:Pn}))}}if((b&7)===0){e:{if(Ue=m==="mouseover"||m==="pointerover",Ge=m==="mouseout"||m==="pointerout",Ue&&w!==sR&&(en=w.relatedTarget||w.fromElement)&&(ht(en)||en[yr]))break e;if((Ge||Ue)&&(Ue=nt.window===nt?nt:(Ue=nt.ownerDocument)?Ue.defaultView||Ue.parentWindow:window,Ge?(en=w.relatedTarget||w.toElement,Ge=qe,en=en?ht(en):null,en!==null&&(io=i(en),Pn=en.tag,en!==io||Pn!==5&&Pn!==27&&Pn!==6)&&(en=null)):(Ge=null,en=qe),Ge!==en)){if(Pn=$ne,rt="onMouseLeave",Re="onMouseEnter",Me="mouse",(m==="pointerout"||m==="pointerover")&&(Pn=Hne,rt="onPointerLeave",Re="onPointerEnter",Me="pointer"),io=Ge==null?Ue:pr(Ge),Fe=en==null?Ue:pr(en),Ue=new Pn(rt,Me+"leave",Ge,w,nt),Ue.target=io,Ue.relatedTarget=Fe,rt=null,ht(nt)===qe&&(Pn=new Pn(Re,Me+"enter",en,w,nt),Pn.target=Fe,Pn.relatedTarget=io,rt=Pn),io=rt,Ge&&en)t:{for(Pn=OYe,Re=Ge,Me=en,Fe=0,rt=Re;rt;rt=Pn(rt))Fe++;rt=0;for(var yn=Me;yn;yn=Pn(yn))rt++;for(;0<Fe-rt;)Re=Pn(Re),Fe--;for(;0<rt-Fe;)Me=Pn(Me),rt--;for(;Fe--;){if(Re===Me||Me!==null&&Re===Me.alternate){Pn=Re;break t}Re=Pn(Re),Me=Pn(Me)}Pn=null}else Pn=null;Ge!==null&&jie(at,Ue,Ge,Pn,!1),en!==null&&io!==null&&jie(at,io,en,Pn,!0)}}e:{if(Ue=qe?pr(qe):window,Ge=Ue.nodeName&&Ue.nodeName.toLowerCase(),Ge==="select"||Ge==="input"&&Ue.type==="file")var Br=Gne;else if(Wne(Ue))if(Yne)Br=LGe;else{Br=NGe;var hn=jGe}else Ge=Ue.nodeName,!Ge||Ge.toLowerCase()!=="input"||Ue.type!=="checkbox"&&Ue.type!=="radio"?qe&&iR(qe.elementType)&&(Br=Gne):Br=RGe;if(Br&&(Br=Br(m,qe))){Zne(at,Br,w,nt);break e}hn&&hn(m,Ue,qe),m==="focusout"&&qe&&Ue.type==="number"&&qe.memoizedProps.value!=null&&Lu(Ue,"number",Ue.value)}switch(hn=qe?pr(qe):window,m){case"focusin":(Wne(hn)||hn.contentEditable==="true")&&(nm=hn,_R=qe,$8=null);break;case"focusout":$8=_R=nm=null;break;case"mousedown":xR=!0;break;case"contextmenu":case"mouseup":case"dragend":xR=!1,ore(at,w,nt);break;case"selectionchange":if(DGe)break;case"keydown":case"keyup":ore(at,w,nt)}var Jn;if(mR)e:{switch(m){case"compositionstart":var kr="onCompositionStart";break e;case"compositionend":kr="onCompositionEnd";break e;case"compositionupdate":kr="onCompositionUpdate";break e}kr=void 0}else tm?Qne(m,w)&&(kr="onCompositionEnd"):m==="keydown"&&w.keyCode===229&&(kr="onCompositionStart");kr&&(Fne&&w.locale!=="ko"&&(tm||kr!=="onCompositionStart"?kr==="onCompositionEnd"&&tm&&(Jn=Dne()):(Cd=nt,uR="value"in Cd?Cd.value:Cd.textContent,tm=!0)),hn=aw(qe,kr),0<hn.length&&(kr=new Bne(kr,m,null,w,nt),at.push({event:kr,listeners:hn}),Jn?kr.data=Jn:(Jn=Une(w),Jn!==null&&(kr.data=Jn)))),(Jn=AGe?EGe(m,w):TGe(m,w))&&(kr=aw(qe,"onBeforeInput"),0<kr.length&&(hn=new Bne("onBeforeInput","beforeinput",null,w,nt),at.push({event:hn,listeners:kr}),hn.data=Jn)),xYe(at,m,qe,w,nt)}Mie(at,b)})}function u7(m,b,w){return{instance:m,listener:b,currentTarget:w}}function aw(m,b){for(var w=b+"Capture",S=[];m!==null;){var j=m,R=j.stateNode;if(j=j.tag,j!==5&&j!==26&&j!==27||R===null||(j=P8(m,w),j!=null&&S.unshift(u7(m,j,R)),j=P8(m,b),j!=null&&S.push(u7(m,j,R))),m.tag===3)return S;m=m.return}return[]}function OYe(m){if(m===null)return null;do m=m.return;while(m&&m.tag!==5&&m.tag!==27);return m||null}function jie(m,b,w,S,j){for(var R=b._reactName,J=[];w!==null&&w!==S;){var oe=w,Oe=oe.alternate,qe=oe.stateNode;if(oe=oe.tag,Oe!==null&&Oe===S)break;oe!==5&&oe!==26&&oe!==27||qe===null||(Oe=qe,j?(qe=P8(w,R),qe!=null&&J.unshift(u7(w,qe,Oe))):j||(qe=P8(w,R),qe!=null&&J.push(u7(w,qe,Oe)))),w=w.return}J.length!==0&&m.push({event:b,listeners:J})}var SYe=/\r\n?/g,CYe=/\u0000|\uFFFD/g;function Nie(m){return(typeof m=="string"?m:""+m).replace(SYe,`
1035
- `).replace(CYe,"")}function Rie(m,b){return b=Nie(b),Nie(m)===b}function oo(m,b,w,S,j,R){switch(w){case"children":typeof S=="string"?b==="body"||b==="textarea"&&S===""||K4(m,S):(typeof S=="number"||typeof S=="bigint")&&b!=="body"&&K4(m,""+S);break;case"className":Zh(m,"class",S);break;case"tabIndex":Zh(m,"tabindex",S);break;case"dir":case"role":case"viewBox":case"width":case"height":Zh(m,w,S);break;case"style":Rne(m,S,R);break;case"data":if(b!=="object"){Zh(m,"data",S);break}case"src":case"href":if(S===""&&(b!=="a"||w!=="href")){m.removeAttribute(w);break}if(S==null||typeof S=="function"||typeof S=="symbol"||typeof S=="boolean"){m.removeAttribute(w);break}S=hy(""+S),m.setAttribute(w,S);break;case"action":case"formAction":if(typeof S=="function"){m.setAttribute(w,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof R=="function"&&(w==="formAction"?(b!=="input"&&oo(m,b,"name",j.name,j,null),oo(m,b,"formEncType",j.formEncType,j,null),oo(m,b,"formMethod",j.formMethod,j,null),oo(m,b,"formTarget",j.formTarget,j,null)):(oo(m,b,"encType",j.encType,j,null),oo(m,b,"method",j.method,j,null),oo(m,b,"target",j.target,j,null)));if(S==null||typeof S=="symbol"||typeof S=="boolean"){m.removeAttribute(w);break}S=hy(""+S),m.setAttribute(w,S);break;case"onClick":S!=null&&(m.onclick=Iu);break;case"onScroll":S!=null&&vr("scroll",m);break;case"onScrollEnd":S!=null&&vr("scrollend",m);break;case"dangerouslySetInnerHTML":if(S!=null){if(typeof S!="object"||!("__html"in S))throw Error(r(61));if(w=S.__html,w!=null){if(j.children!=null)throw Error(r(60));m.innerHTML=w}}break;case"multiple":m.multiple=S&&typeof S!="function"&&typeof S!="symbol";break;case"muted":m.muted=S&&typeof S!="function"&&typeof S!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(S==null||typeof S=="function"||typeof S=="boolean"||typeof S=="symbol"){m.removeAttribute("xlink:href");break}w=hy(""+S),m.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",w);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":S!=null&&typeof S!="function"&&typeof S!="symbol"?m.setAttribute(w,""+S):m.removeAttribute(w);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":S&&typeof S!="function"&&typeof S!="symbol"?m.setAttribute(w,""):m.removeAttribute(w);break;case"capture":case"download":S===!0?m.setAttribute(w,""):S!==!1&&S!=null&&typeof S!="function"&&typeof S!="symbol"?m.setAttribute(w,S):m.removeAttribute(w);break;case"cols":case"rows":case"size":case"span":S!=null&&typeof S!="function"&&typeof S!="symbol"&&!isNaN(S)&&1<=S?m.setAttribute(w,S):m.removeAttribute(w);break;case"rowSpan":case"start":S==null||typeof S=="function"||typeof S=="symbol"||isNaN(S)?m.removeAttribute(w):m.setAttribute(w,S);break;case"popover":vr("beforetoggle",m),vr("toggle",m),l0(m,"popover",S);break;case"xlinkActuate":c0(m,"http://www.w3.org/1999/xlink","xlink:actuate",S);break;case"xlinkArcrole":c0(m,"http://www.w3.org/1999/xlink","xlink:arcrole",S);break;case"xlinkRole":c0(m,"http://www.w3.org/1999/xlink","xlink:role",S);break;case"xlinkShow":c0(m,"http://www.w3.org/1999/xlink","xlink:show",S);break;case"xlinkTitle":c0(m,"http://www.w3.org/1999/xlink","xlink:title",S);break;case"xlinkType":c0(m,"http://www.w3.org/1999/xlink","xlink:type",S);break;case"xmlBase":c0(m,"http://www.w3.org/XML/1998/namespace","xml:base",S);break;case"xmlLang":c0(m,"http://www.w3.org/XML/1998/namespace","xml:lang",S);break;case"xmlSpace":c0(m,"http://www.w3.org/XML/1998/namespace","xml:space",S);break;case"is":l0(m,"is",S);break;case"innerText":case"textContent":break;default:(!(2<w.length)||w[0]!=="o"&&w[0]!=="O"||w[1]!=="n"&&w[1]!=="N")&&(w=eGe.get(w)||w,l0(m,w,S))}}function QL(m,b,w,S,j,R){switch(w){case"style":Rne(m,S,R);break;case"dangerouslySetInnerHTML":if(S!=null){if(typeof S!="object"||!("__html"in S))throw Error(r(61));if(w=S.__html,w!=null){if(j.children!=null)throw Error(r(60));m.innerHTML=w}}break;case"children":typeof S=="string"?K4(m,S):(typeof S=="number"||typeof S=="bigint")&&K4(m,""+S);break;case"onScroll":S!=null&&vr("scroll",m);break;case"onScrollEnd":S!=null&&vr("scrollend",m);break;case"onClick":S!=null&&(m.onclick=Iu);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Ri.hasOwnProperty(w))e:{if(w[0]==="o"&&w[1]==="n"&&(j=w.endsWith("Capture"),b=w.slice(2,j?w.length-7:void 0),R=m[qt]||null,R=R!=null?R[w]:null,typeof R=="function"&&m.removeEventListener(b,R,j),typeof S=="function")){typeof R!="function"&&R!==null&&(w in m?m[w]=null:m.hasAttribute(w)&&m.removeAttribute(w)),m.addEventListener(b,S,j);break e}w in m?m[w]=S:S===!0?m.setAttribute(w,""):l0(m,w,S)}}}function Ts(m,b,w){switch(b){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":vr("error",m),vr("load",m);var S=!1,j=!1,R;for(R in w)if(w.hasOwnProperty(R)){var J=w[R];if(J!=null)switch(R){case"src":S=!0;break;case"srcSet":j=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,b));default:oo(m,b,R,J,w,null)}}j&&oo(m,b,"srcSet",w.srcSet,w,null),S&&oo(m,b,"src",w.src,w,null);return;case"input":vr("invalid",m);var oe=R=J=j=null,Oe=null,qe=null;for(S in w)if(w.hasOwnProperty(S)){var nt=w[S];if(nt!=null)switch(S){case"name":j=nt;break;case"type":J=nt;break;case"checked":Oe=nt;break;case"defaultChecked":qe=nt;break;case"value":R=nt;break;case"defaultValue":oe=nt;break;case"children":case"dangerouslySetInnerHTML":if(nt!=null)throw Error(r(137,b));break;default:oo(m,b,S,nt,w,null)}}X4(m,R,oe,Oe,qe,J,j,!1);return;case"select":vr("invalid",m),S=J=R=null;for(j in w)if(w.hasOwnProperty(j)&&(oe=w[j],oe!=null))switch(j){case"value":R=oe;break;case"defaultValue":J=oe;break;case"multiple":S=oe;default:oo(m,b,j,oe,w,null)}b=R,w=J,m.multiple=!!S,b!=null?Ur(m,!!S,b,!1):w!=null&&Ur(m,!!S,w,!0);return;case"textarea":vr("invalid",m),R=j=S=null;for(J in w)if(w.hasOwnProperty(J)&&(oe=w[J],oe!=null))switch(J){case"value":S=oe;break;case"defaultValue":j=oe;break;case"children":R=oe;break;case"dangerouslySetInnerHTML":if(oe!=null)throw Error(r(91));break;default:oo(m,b,J,oe,w,null)}Yh(m,S,j,R);return;case"option":for(Oe in w)w.hasOwnProperty(Oe)&&(S=w[Oe],S!=null)&&(Oe==="selected"?m.selected=S&&typeof S!="function"&&typeof S!="symbol":oo(m,b,Oe,S,w,null));return;case"dialog":vr("beforetoggle",m),vr("toggle",m),vr("cancel",m),vr("close",m);break;case"iframe":case"object":vr("load",m);break;case"video":case"audio":for(S=0;S<c7.length;S++)vr(c7[S],m);break;case"image":vr("error",m),vr("load",m);break;case"details":vr("toggle",m);break;case"embed":case"source":case"link":vr("error",m),vr("load",m);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(qe in w)if(w.hasOwnProperty(qe)&&(S=w[qe],S!=null))switch(qe){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,b));default:oo(m,b,qe,S,w,null)}return;default:if(iR(b)){for(nt in w)w.hasOwnProperty(nt)&&(S=w[nt],S!==void 0&&QL(m,b,nt,S,w,void 0));return}}for(oe in w)w.hasOwnProperty(oe)&&(S=w[oe],S!=null&&oo(m,b,oe,S,w,null))}function AYe(m,b,w,S){switch(b){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var j=null,R=null,J=null,oe=null,Oe=null,qe=null,nt=null;for(Ge in w){var at=w[Ge];if(w.hasOwnProperty(Ge)&&at!=null)switch(Ge){case"checked":break;case"value":break;case"defaultValue":Oe=at;default:S.hasOwnProperty(Ge)||oo(m,b,Ge,null,S,at)}}for(var Ue in S){var Ge=S[Ue];if(at=w[Ue],S.hasOwnProperty(Ue)&&(Ge!=null||at!=null))switch(Ue){case"type":R=Ge;break;case"name":j=Ge;break;case"checked":qe=Ge;break;case"defaultChecked":nt=Ge;break;case"value":J=Ge;break;case"defaultValue":oe=Ge;break;case"children":case"dangerouslySetInnerHTML":if(Ge!=null)throw Error(r(137,b));break;default:Ge!==at&&oo(m,b,Ue,Ge,S,at)}}El(m,J,oe,Oe,qe,nt,R,j);return;case"select":Ge=J=oe=Ue=null;for(R in w)if(Oe=w[R],w.hasOwnProperty(R)&&Oe!=null)switch(R){case"value":break;case"multiple":Ge=Oe;default:S.hasOwnProperty(R)||oo(m,b,R,null,S,Oe)}for(j in S)if(R=S[j],Oe=w[j],S.hasOwnProperty(j)&&(R!=null||Oe!=null))switch(j){case"value":Ue=R;break;case"defaultValue":oe=R;break;case"multiple":J=R;default:R!==Oe&&oo(m,b,j,R,S,Oe)}b=oe,w=J,S=Ge,Ue!=null?Ur(m,!!w,Ue,!1):!!S!=!!w&&(b!=null?Ur(m,!!w,b,!0):Ur(m,!!w,w?[]:"",!1));return;case"textarea":Ge=Ue=null;for(oe in w)if(j=w[oe],w.hasOwnProperty(oe)&&j!=null&&!S.hasOwnProperty(oe))switch(oe){case"value":break;case"children":break;default:oo(m,b,oe,null,S,j)}for(J in S)if(j=S[J],R=w[J],S.hasOwnProperty(J)&&(j!=null||R!=null))switch(J){case"value":Ue=j;break;case"defaultValue":Ge=j;break;case"children":break;case"dangerouslySetInnerHTML":if(j!=null)throw Error(r(91));break;default:j!==R&&oo(m,b,J,j,S,R)}_o(m,Ue,Ge);return;case"option":for(var en in w)Ue=w[en],w.hasOwnProperty(en)&&Ue!=null&&!S.hasOwnProperty(en)&&(en==="selected"?m.selected=!1:oo(m,b,en,null,S,Ue));for(Oe in S)Ue=S[Oe],Ge=w[Oe],S.hasOwnProperty(Oe)&&Ue!==Ge&&(Ue!=null||Ge!=null)&&(Oe==="selected"?m.selected=Ue&&typeof Ue!="function"&&typeof Ue!="symbol":oo(m,b,Oe,Ue,S,Ge));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Pn in w)Ue=w[Pn],w.hasOwnProperty(Pn)&&Ue!=null&&!S.hasOwnProperty(Pn)&&oo(m,b,Pn,null,S,Ue);for(qe in S)if(Ue=S[qe],Ge=w[qe],S.hasOwnProperty(qe)&&Ue!==Ge&&(Ue!=null||Ge!=null))switch(qe){case"children":case"dangerouslySetInnerHTML":if(Ue!=null)throw Error(r(137,b));break;default:oo(m,b,qe,Ue,S,Ge)}return;default:if(iR(b)){for(var io in w)Ue=w[io],w.hasOwnProperty(io)&&Ue!==void 0&&!S.hasOwnProperty(io)&&QL(m,b,io,void 0,S,Ue);for(nt in S)Ue=S[nt],Ge=w[nt],!S.hasOwnProperty(nt)||Ue===Ge||Ue===void 0&&Ge===void 0||QL(m,b,nt,Ue,S,Ge);return}}for(var Re in w)Ue=w[Re],w.hasOwnProperty(Re)&&Ue!=null&&!S.hasOwnProperty(Re)&&oo(m,b,Re,null,S,Ue);for(at in S)Ue=S[at],Ge=w[at],!S.hasOwnProperty(at)||Ue===Ge||Ue==null&&Ge==null||oo(m,b,at,Ue,S,Ge)}function Lie(m){switch(m){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function EYe(){if(typeof performance.getEntriesByType=="function"){for(var m=0,b=0,w=performance.getEntriesByType("resource"),S=0;S<w.length;S++){var j=w[S],R=j.transferSize,J=j.initiatorType,oe=j.duration;if(R&&oe&&Lie(J)){for(J=0,oe=j.responseEnd,S+=1;S<w.length;S++){var Oe=w[S],qe=Oe.startTime;if(qe>oe)break;var nt=Oe.transferSize,at=Oe.initiatorType;nt&&Lie(at)&&(Oe=Oe.responseEnd,J+=nt*(Oe<oe?1:(oe-qe)/(Oe-qe)))}if(--S,b+=8*(R+J)/(j.duration/1e3),m++,10<m)break}}if(0<m)return b/m/1e6}return navigator.connection&&(m=navigator.connection.downlink,typeof m=="number")?m:5}var UL=null,WL=null;function lw(m){return m.nodeType===9?m:m.ownerDocument}function Iie(m){switch(m){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Die(m,b){if(m===0)switch(b){case"svg":return 1;case"math":return 2;default:return 0}return m===1&&b==="foreignObject"?0:m}function ZL(m,b){return m==="textarea"||m==="noscript"||typeof b.children=="string"||typeof b.children=="number"||typeof b.children=="bigint"||typeof b.dangerouslySetInnerHTML=="object"&&b.dangerouslySetInnerHTML!==null&&b.dangerouslySetInnerHTML.__html!=null}var GL=null;function TYe(){var m=window.event;return m&&m.type==="popstate"?m===GL?!1:(GL=m,!0):(GL=null,!1)}var zie=typeof setTimeout=="function"?setTimeout:void 0,MYe=typeof clearTimeout=="function"?clearTimeout:void 0,$ie=typeof Promise=="function"?Promise:void 0,PYe=typeof queueMicrotask=="function"?queueMicrotask:typeof $ie<"u"?function(m){return $ie.resolve(null).then(m).catch(jYe)}:zie;function jYe(m){setTimeout(function(){throw m})}function qd(m){return m==="head"}function Bie(m,b){var w=b,S=0;do{var j=w.nextSibling;if(m.removeChild(w),j&&j.nodeType===8)if(w=j.data,w==="/$"||w==="/&"){if(S===0){m.removeChild(j),Tm(b);return}S--}else if(w==="$"||w==="$?"||w==="$~"||w==="$!"||w==="&")S++;else if(w==="html")d7(m.ownerDocument.documentElement);else if(w==="head"){w=m.ownerDocument.head,d7(w);for(var R=w.firstChild;R;){var J=R.nextSibling,oe=R.nodeName;R[Zt]||oe==="SCRIPT"||oe==="STYLE"||oe==="LINK"&&R.rel.toLowerCase()==="stylesheet"||w.removeChild(R),R=J}}else w==="body"&&d7(m.ownerDocument.body);w=j}while(w);Tm(b)}function Hie(m,b){var w=m;m=0;do{var S=w.nextSibling;if(w.nodeType===1?b?(w._stashedDisplay=w.style.display,w.style.display="none"):(w.style.display=w._stashedDisplay||"",w.getAttribute("style")===""&&w.removeAttribute("style")):w.nodeType===3&&(b?(w._stashedText=w.nodeValue,w.nodeValue=""):w.nodeValue=w._stashedText||""),S&&S.nodeType===8)if(w=S.data,w==="/$"){if(m===0)break;m--}else w!=="$"&&w!=="$?"&&w!=="$~"&&w!=="$!"||m++;w=S}while(w)}function YL(m){var b=m.firstChild;for(b&&b.nodeType===10&&(b=b.nextSibling);b;){var w=b;switch(b=b.nextSibling,w.nodeName){case"HTML":case"HEAD":case"BODY":YL(w),Ae(w);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(w.rel.toLowerCase()==="stylesheet")continue}m.removeChild(w)}}function NYe(m,b,w,S){for(;m.nodeType===1;){var j=w;if(m.nodeName.toLowerCase()!==b.toLowerCase()){if(!S&&(m.nodeName!=="INPUT"||m.type!=="hidden"))break}else if(S){if(!m[Zt])switch(b){case"meta":if(!m.hasAttribute("itemprop"))break;return m;case"link":if(R=m.getAttribute("rel"),R==="stylesheet"&&m.hasAttribute("data-precedence"))break;if(R!==j.rel||m.getAttribute("href")!==(j.href==null||j.href===""?null:j.href)||m.getAttribute("crossorigin")!==(j.crossOrigin==null?null:j.crossOrigin)||m.getAttribute("title")!==(j.title==null?null:j.title))break;return m;case"style":if(m.hasAttribute("data-precedence"))break;return m;case"script":if(R=m.getAttribute("src"),(R!==(j.src==null?null:j.src)||m.getAttribute("type")!==(j.type==null?null:j.type)||m.getAttribute("crossorigin")!==(j.crossOrigin==null?null:j.crossOrigin))&&R&&m.hasAttribute("async")&&!m.hasAttribute("itemprop"))break;return m;default:return m}}else if(b==="input"&&m.type==="hidden"){var R=j.name==null?null:""+j.name;if(j.type==="hidden"&&m.getAttribute("name")===R)return m}else return m;if(m=mc(m.nextSibling),m===null)break}return null}function RYe(m,b,w){if(b==="")return null;for(;m.nodeType!==3;)if((m.nodeType!==1||m.nodeName!=="INPUT"||m.type!=="hidden")&&!w||(m=mc(m.nextSibling),m===null))return null;return m}function Fie(m,b){for(;m.nodeType!==8;)if((m.nodeType!==1||m.nodeName!=="INPUT"||m.type!=="hidden")&&!b||(m=mc(m.nextSibling),m===null))return null;return m}function XL(m){return m.data==="$?"||m.data==="$~"}function KL(m){return m.data==="$!"||m.data==="$?"&&m.ownerDocument.readyState!=="loading"}function LYe(m,b){var w=m.ownerDocument;if(m.data==="$~")m._reactRetry=b;else if(m.data!=="$?"||w.readyState!=="loading")b();else{var S=function(){b(),w.removeEventListener("DOMContentLoaded",S)};w.addEventListener("DOMContentLoaded",S),m._reactRetry=S}}function mc(m){for(;m!=null;m=m.nextSibling){var b=m.nodeType;if(b===1||b===3)break;if(b===8){if(b=m.data,b==="$"||b==="$!"||b==="$?"||b==="$~"||b==="&"||b==="F!"||b==="F")break;if(b==="/$"||b==="/&")return null}}return m}var JL=null;function qie(m){m=m.nextSibling;for(var b=0;m;){if(m.nodeType===8){var w=m.data;if(w==="/$"||w==="/&"){if(b===0)return mc(m.nextSibling);b--}else w!=="$"&&w!=="$!"&&w!=="$?"&&w!=="$~"&&w!=="&"||b++}m=m.nextSibling}return null}function Vie(m){m=m.previousSibling;for(var b=0;m;){if(m.nodeType===8){var w=m.data;if(w==="$"||w==="$!"||w==="$?"||w==="$~"||w==="&"){if(b===0)return m;b--}else w!=="/$"&&w!=="/&"||b++}m=m.previousSibling}return null}function Qie(m,b,w){switch(b=lw(w),m){case"html":if(m=b.documentElement,!m)throw Error(r(452));return m;case"head":if(m=b.head,!m)throw Error(r(453));return m;case"body":if(m=b.body,!m)throw Error(r(454));return m;default:throw Error(r(451))}}function d7(m){for(var b=m.attributes;b.length;)m.removeAttributeNode(b[0]);Ae(m)}var gc=new Map,Uie=new Set;function cw(m){return typeof m.getRootNode=="function"?m.getRootNode():m.nodeType===9?m:m.ownerDocument}var Ku=V.d;V.d={f:IYe,r:DYe,D:zYe,C:$Ye,L:BYe,m:HYe,X:qYe,S:FYe,M:VYe};function IYe(){var m=Ku.f(),b=ew();return m||b}function DYe(m){var b=zt(m);b!==null&&b.tag===5&&b.type==="form"?coe(b):Ku.r(m)}var Cm=typeof document>"u"?null:document;function Wie(m,b,w){var S=Cm;if(S&&typeof b=="string"&&b){var j=Zo(b);j='link[rel="'+m+'"][href="'+j+'"]',typeof w=="string"&&(j+='[crossorigin="'+w+'"]'),Uie.has(j)||(Uie.add(j),m={rel:m,crossOrigin:w,href:b},S.querySelector(j)===null&&(b=S.createElement("link"),Ts(b,"link",m),Yn(b),S.head.appendChild(b)))}}function zYe(m){Ku.D(m),Wie("dns-prefetch",m,null)}function $Ye(m,b){Ku.C(m,b),Wie("preconnect",m,b)}function BYe(m,b,w){Ku.L(m,b,w);var S=Cm;if(S&&m&&b){var j='link[rel="preload"][as="'+Zo(b)+'"]';b==="image"&&w&&w.imageSrcSet?(j+='[imagesrcset="'+Zo(w.imageSrcSet)+'"]',typeof w.imageSizes=="string"&&(j+='[imagesizes="'+Zo(w.imageSizes)+'"]')):j+='[href="'+Zo(m)+'"]';var R=j;switch(b){case"style":R=Am(m);break;case"script":R=Em(m)}gc.has(R)||(m=d({rel:"preload",href:b==="image"&&w&&w.imageSrcSet?void 0:m,as:b},w),gc.set(R,m),S.querySelector(j)!==null||b==="style"&&S.querySelector(f7(R))||b==="script"&&S.querySelector(h7(R))||(b=S.createElement("link"),Ts(b,"link",m),Yn(b),S.head.appendChild(b)))}}function HYe(m,b){Ku.m(m,b);var w=Cm;if(w&&m){var S=b&&typeof b.as=="string"?b.as:"script",j='link[rel="modulepreload"][as="'+Zo(S)+'"][href="'+Zo(m)+'"]',R=j;switch(S){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":R=Em(m)}if(!gc.has(R)&&(m=d({rel:"modulepreload",href:m},b),gc.set(R,m),w.querySelector(j)===null)){switch(S){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(w.querySelector(h7(R)))return}S=w.createElement("link"),Ts(S,"link",m),Yn(S),w.head.appendChild(S)}}}function FYe(m,b,w){Ku.S(m,b,w);var S=Cm;if(S&&m){var j=no(S).hoistableStyles,R=Am(m);b=b||"default";var J=j.get(R);if(!J){var oe={loading:0,preload:null};if(J=S.querySelector(f7(R)))oe.loading=5;else{m=d({rel:"stylesheet",href:m,"data-precedence":b},w),(w=gc.get(R))&&eI(m,w);var Oe=J=S.createElement("link");Yn(Oe),Ts(Oe,"link",m),Oe._p=new Promise(function(qe,nt){Oe.onload=qe,Oe.onerror=nt}),Oe.addEventListener("load",function(){oe.loading|=1}),Oe.addEventListener("error",function(){oe.loading|=2}),oe.loading|=4,uw(J,b,S)}J={type:"stylesheet",instance:J,count:1,state:oe},j.set(R,J)}}}function qYe(m,b){Ku.X(m,b);var w=Cm;if(w&&m){var S=no(w).hoistableScripts,j=Em(m),R=S.get(j);R||(R=w.querySelector(h7(j)),R||(m=d({src:m,async:!0},b),(b=gc.get(j))&&tI(m,b),R=w.createElement("script"),Yn(R),Ts(R,"link",m),w.head.appendChild(R)),R={type:"script",instance:R,count:1,state:null},S.set(j,R))}}function VYe(m,b){Ku.M(m,b);var w=Cm;if(w&&m){var S=no(w).hoistableScripts,j=Em(m),R=S.get(j);R||(R=w.querySelector(h7(j)),R||(m=d({src:m,async:!0,type:"module"},b),(b=gc.get(j))&&tI(m,b),R=w.createElement("script"),Yn(R),Ts(R,"link",m),w.head.appendChild(R)),R={type:"script",instance:R,count:1,state:null},S.set(j,R))}}function Zie(m,b,w,S){var j=(j=se.current)?cw(j):null;if(!j)throw Error(r(446));switch(m){case"meta":case"title":return null;case"style":return typeof w.precedence=="string"&&typeof w.href=="string"?(b=Am(w.href),w=no(j).hoistableStyles,S=w.get(b),S||(S={type:"style",instance:null,count:0,state:null},w.set(b,S)),S):{type:"void",instance:null,count:0,state:null};case"link":if(w.rel==="stylesheet"&&typeof w.href=="string"&&typeof w.precedence=="string"){m=Am(w.href);var R=no(j).hoistableStyles,J=R.get(m);if(J||(j=j.ownerDocument||j,J={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},R.set(m,J),(R=j.querySelector(f7(m)))&&!R._p&&(J.instance=R,J.state.loading=5),gc.has(m)||(w={rel:"preload",as:"style",href:w.href,crossOrigin:w.crossOrigin,integrity:w.integrity,media:w.media,hrefLang:w.hrefLang,referrerPolicy:w.referrerPolicy},gc.set(m,w),R||QYe(j,m,w,J.state))),b&&S===null)throw Error(r(528,""));return J}if(b&&S!==null)throw Error(r(529,""));return null;case"script":return b=w.async,w=w.src,typeof w=="string"&&b&&typeof b!="function"&&typeof b!="symbol"?(b=Em(w),w=no(j).hoistableScripts,S=w.get(b),S||(S={type:"script",instance:null,count:0,state:null},w.set(b,S)),S):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,m))}}function Am(m){return'href="'+Zo(m)+'"'}function f7(m){return'link[rel="stylesheet"]['+m+"]"}function Gie(m){return d({},m,{"data-precedence":m.precedence,precedence:null})}function QYe(m,b,w,S){m.querySelector('link[rel="preload"][as="style"]['+b+"]")?S.loading=1:(b=m.createElement("link"),S.preload=b,b.addEventListener("load",function(){return S.loading|=1}),b.addEventListener("error",function(){return S.loading|=2}),Ts(b,"link",w),Yn(b),m.head.appendChild(b))}function Em(m){return'[src="'+Zo(m)+'"]'}function h7(m){return"script[async]"+m}function Yie(m,b,w){if(b.count++,b.instance===null)switch(b.type){case"style":var S=m.querySelector('style[data-href~="'+Zo(w.href)+'"]');if(S)return b.instance=S,Yn(S),S;var j=d({},w,{"data-href":w.href,"data-precedence":w.precedence,href:null,precedence:null});return S=(m.ownerDocument||m).createElement("style"),Yn(S),Ts(S,"style",j),uw(S,w.precedence,m),b.instance=S;case"stylesheet":j=Am(w.href);var R=m.querySelector(f7(j));if(R)return b.state.loading|=4,b.instance=R,Yn(R),R;S=Gie(w),(j=gc.get(j))&&eI(S,j),R=(m.ownerDocument||m).createElement("link"),Yn(R);var J=R;return J._p=new Promise(function(oe,Oe){J.onload=oe,J.onerror=Oe}),Ts(R,"link",S),b.state.loading|=4,uw(R,w.precedence,m),b.instance=R;case"script":return R=Em(w.src),(j=m.querySelector(h7(R)))?(b.instance=j,Yn(j),j):(S=w,(j=gc.get(R))&&(S=d({},w),tI(S,j)),m=m.ownerDocument||m,j=m.createElement("script"),Yn(j),Ts(j,"link",S),m.head.appendChild(j),b.instance=j);case"void":return null;default:throw Error(r(443,b.type))}else b.type==="stylesheet"&&(b.state.loading&4)===0&&(S=b.instance,b.state.loading|=4,uw(S,w.precedence,m));return b.instance}function uw(m,b,w){for(var S=w.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),j=S.length?S[S.length-1]:null,R=j,J=0;J<S.length;J++){var oe=S[J];if(oe.dataset.precedence===b)R=oe;else if(R!==j)break}R?R.parentNode.insertBefore(m,R.nextSibling):(b=w.nodeType===9?w.head:w,b.insertBefore(m,b.firstChild))}function eI(m,b){m.crossOrigin==null&&(m.crossOrigin=b.crossOrigin),m.referrerPolicy==null&&(m.referrerPolicy=b.referrerPolicy),m.title==null&&(m.title=b.title)}function tI(m,b){m.crossOrigin==null&&(m.crossOrigin=b.crossOrigin),m.referrerPolicy==null&&(m.referrerPolicy=b.referrerPolicy),m.integrity==null&&(m.integrity=b.integrity)}var dw=null;function Xie(m,b,w){if(dw===null){var S=new Map,j=dw=new Map;j.set(w,S)}else j=dw,S=j.get(w),S||(S=new Map,j.set(w,S));if(S.has(m))return S;for(S.set(m,null),w=w.getElementsByTagName(m),j=0;j<w.length;j++){var R=w[j];if(!(R[Zt]||R[At]||m==="link"&&R.getAttribute("rel")==="stylesheet")&&R.namespaceURI!=="http://www.w3.org/2000/svg"){var J=R.getAttribute(b)||"";J=m+J;var oe=S.get(J);oe?oe.push(R):S.set(J,[R])}}return S}function Kie(m,b,w){m=m.ownerDocument||m,m.head.insertBefore(w,b==="title"?m.querySelector("head > title"):null)}function UYe(m,b,w){if(w===1||b.itemProp!=null)return!1;switch(m){case"meta":case"title":return!0;case"style":if(typeof b.precedence!="string"||typeof b.href!="string"||b.href==="")break;return!0;case"link":if(typeof b.rel!="string"||typeof b.href!="string"||b.href===""||b.onLoad||b.onError)break;return b.rel==="stylesheet"?(m=b.disabled,typeof b.precedence=="string"&&m==null):!0;case"script":if(b.async&&typeof b.async!="function"&&typeof b.async!="symbol"&&!b.onLoad&&!b.onError&&b.src&&typeof b.src=="string")return!0}return!1}function Jie(m){return!(m.type==="stylesheet"&&(m.state.loading&3)===0)}function WYe(m,b,w,S){if(w.type==="stylesheet"&&(typeof S.media!="string"||matchMedia(S.media).matches!==!1)&&(w.state.loading&4)===0){if(w.instance===null){var j=Am(S.href),R=b.querySelector(f7(j));if(R){b=R._p,b!==null&&typeof b=="object"&&typeof b.then=="function"&&(m.count++,m=fw.bind(m),b.then(m,m)),w.state.loading|=4,w.instance=R,Yn(R);return}R=b.ownerDocument||b,S=Gie(S),(j=gc.get(j))&&eI(S,j),R=R.createElement("link"),Yn(R);var J=R;J._p=new Promise(function(oe,Oe){J.onload=oe,J.onerror=Oe}),Ts(R,"link",S),w.instance=R}m.stylesheets===null&&(m.stylesheets=new Map),m.stylesheets.set(w,b),(b=w.state.preload)&&(w.state.loading&3)===0&&(m.count++,w=fw.bind(m),b.addEventListener("load",w),b.addEventListener("error",w))}}var nI=0;function ZYe(m,b){return m.stylesheets&&m.count===0&&pw(m,m.stylesheets),0<m.count||0<m.imgCount?function(w){var S=setTimeout(function(){if(m.stylesheets&&pw(m,m.stylesheets),m.unsuspend){var R=m.unsuspend;m.unsuspend=null,R()}},6e4+b);0<m.imgBytes&&nI===0&&(nI=62500*EYe());var j=setTimeout(function(){if(m.waitingForImages=!1,m.count===0&&(m.stylesheets&&pw(m,m.stylesheets),m.unsuspend)){var R=m.unsuspend;m.unsuspend=null,R()}},(m.imgBytes>nI?50:800)+b);return m.unsuspend=w,function(){m.unsuspend=null,clearTimeout(S),clearTimeout(j)}}:null}function fw(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)pw(this,this.stylesheets);else if(this.unsuspend){var m=this.unsuspend;this.unsuspend=null,m()}}}var hw=null;function pw(m,b){m.stylesheets=null,m.unsuspend!==null&&(m.count++,hw=new Map,b.forEach(GYe,m),hw=null,fw.call(m))}function GYe(m,b){if(!(b.state.loading&4)){var w=hw.get(m);if(w)var S=w.get(null);else{w=new Map,hw.set(m,w);for(var j=m.querySelectorAll("link[data-precedence],style[data-precedence]"),R=0;R<j.length;R++){var J=j[R];(J.nodeName==="LINK"||J.getAttribute("media")!=="not all")&&(w.set(J.dataset.precedence,J),S=J)}S&&w.set(null,S)}j=b.instance,J=j.getAttribute("data-precedence"),R=w.get(J)||S,R===S&&w.set(null,j),w.set(J,j),this.count++,S=fw.bind(this),j.addEventListener("load",S),j.addEventListener("error",S),R?R.parentNode.insertBefore(j,R.nextSibling):(m=m.nodeType===9?m.head:m,m.insertBefore(j,m.firstChild)),b.state.loading|=4}}var p7={$$typeof:O,Provider:null,Consumer:null,_currentValue:G,_currentValue2:G,_threadCount:0};function YYe(m,b,w,S,j,R,J,oe,Oe){this.tag=1,this.containerInfo=m,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=dt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=dt(0),this.hiddenUpdates=dt(null),this.identifierPrefix=S,this.onUncaughtError=j,this.onCaughtError=R,this.onRecoverableError=J,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Oe,this.incompleteTransitions=new Map}function ese(m,b,w,S,j,R,J,oe,Oe,qe,nt,at){return m=new YYe(m,b,w,J,Oe,qe,nt,at,oe),b=1,R===!0&&(b|=24),R=Ml(3,null,null,b),m.current=R,R.stateNode=m,b=LR(),b.refCount++,m.pooledCache=b,b.refCount++,R.memoizedState={element:S,isDehydrated:w,cache:b},$R(R),m}function tse(m){return m?(m=im,m):im}function nse(m,b,w,S,j,R){j=tse(j),S.context===null?S.context=j:S.pendingContext=j,S=jd(b),S.payload={element:w},R=R===void 0?null:R,R!==null&&(S.callback=R),w=Nd(m,S,b),w!==null&&(il(w,m,b),U8(w,m,b))}function rse(m,b){if(m=m.memoizedState,m!==null&&m.dehydrated!==null){var w=m.retryLane;m.retryLane=w!==0&&w<b?w:b}}function rI(m,b){rse(m,b),(m=m.alternate)&&rse(m,b)}function ose(m){if(m.tag===13||m.tag===31){var b=ep(m,67108864);b!==null&&il(b,m,67108864),rI(m,67108864)}}function ise(m){if(m.tag===13||m.tag===31){var b=Ll();b=Xt(b);var w=ep(m,b);w!==null&&il(w,m,b),rI(m,b)}}var mw=!0;function XYe(m,b,w,S){var j=N.T;N.T=null;var R=V.p;try{V.p=2,oI(m,b,w,S)}finally{V.p=R,N.T=j}}function KYe(m,b,w,S){var j=N.T;N.T=null;var R=V.p;try{V.p=8,oI(m,b,w,S)}finally{V.p=R,N.T=j}}function oI(m,b,w,S){if(mw){var j=iI(S);if(j===null)VL(m,b,S,gw,w),ase(m,S);else if(eXe(j,m,b,w,S))S.stopPropagation();else if(ase(m,S),b&4&&-1<JYe.indexOf(m)){for(;j!==null;){var R=zt(j);if(R!==null)switch(R.tag){case 3:if(R=R.stateNode,R.current.memoizedState.isDehydrated){var J=kn(R.pendingLanes);if(J!==0){var oe=R;for(oe.pendingLanes|=2,oe.entangledLanes|=2;J;){var Oe=1<<31-Ve(J);oe.entanglements[1]|=Oe,J&=~Oe}f1(R),(Wr&6)===0&&(Ky=De()+500,l7(0))}}break;case 31:case 13:oe=ep(R,2),oe!==null&&il(oe,R,2),ew(),rI(R,2)}if(R=iI(S),R===null&&VL(m,b,S,gw,w),R===j)break;j=R}j!==null&&S.stopPropagation()}else VL(m,b,S,null,w)}}function iI(m){return m=aR(m),sI(m)}var gw=null;function sI(m){if(gw=null,m=ht(m),m!==null){var b=i(m);if(b===null)m=null;else{var w=b.tag;if(w===13){if(m=s(b),m!==null)return m;m=null}else if(w===31){if(m=a(b),m!==null)return m;m=null}else if(w===3){if(b.stateNode.current.memoizedState.isDehydrated)return b.tag===3?b.stateNode.containerInfo:null;m=null}else b!==m&&(m=null)}}return gw=m,null}function sse(m){switch(m){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(ct()){case ue:return 2;case Pe:return 8;case Ee:case Le:return 32;case et:return 268435456;default:return 32}default:return 32}}var aI=!1,Vd=null,Qd=null,Ud=null,m7=new Map,g7=new Map,Wd=[],JYe="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function ase(m,b){switch(m){case"focusin":case"focusout":Vd=null;break;case"dragenter":case"dragleave":Qd=null;break;case"mouseover":case"mouseout":Ud=null;break;case"pointerover":case"pointerout":m7.delete(b.pointerId);break;case"gotpointercapture":case"lostpointercapture":g7.delete(b.pointerId)}}function v7(m,b,w,S,j,R){return m===null||m.nativeEvent!==R?(m={blockedOn:b,domEventName:w,eventSystemFlags:S,nativeEvent:R,targetContainers:[j]},b!==null&&(b=zt(b),b!==null&&ose(b)),m):(m.eventSystemFlags|=S,b=m.targetContainers,j!==null&&b.indexOf(j)===-1&&b.push(j),m)}function eXe(m,b,w,S,j){switch(b){case"focusin":return Vd=v7(Vd,m,b,w,S,j),!0;case"dragenter":return Qd=v7(Qd,m,b,w,S,j),!0;case"mouseover":return Ud=v7(Ud,m,b,w,S,j),!0;case"pointerover":var R=j.pointerId;return m7.set(R,v7(m7.get(R)||null,m,b,w,S,j)),!0;case"gotpointercapture":return R=j.pointerId,g7.set(R,v7(g7.get(R)||null,m,b,w,S,j)),!0}return!1}function lse(m){var b=ht(m.target);if(b!==null){var w=i(b);if(w!==null){if(b=w.tag,b===13){if(b=s(w),b!==null){m.blockedOn=b,Ie(m.priority,function(){ise(w)});return}}else if(b===31){if(b=a(w),b!==null){m.blockedOn=b,Ie(m.priority,function(){ise(w)});return}}else if(b===3&&w.stateNode.current.memoizedState.isDehydrated){m.blockedOn=w.tag===3?w.stateNode.containerInfo:null;return}}}m.blockedOn=null}function vw(m){if(m.blockedOn!==null)return!1;for(var b=m.targetContainers;0<b.length;){var w=iI(m.nativeEvent);if(w===null){w=m.nativeEvent;var S=new w.constructor(w.type,w);sR=S,w.target.dispatchEvent(S),sR=null}else return b=zt(w),b!==null&&ose(b),m.blockedOn=w,!1;b.shift()}return!0}function cse(m,b,w){vw(m)&&w.delete(b)}function tXe(){aI=!1,Vd!==null&&vw(Vd)&&(Vd=null),Qd!==null&&vw(Qd)&&(Qd=null),Ud!==null&&vw(Ud)&&(Ud=null),m7.forEach(cse),g7.forEach(cse)}function bw(m,b){m.blockedOn===b&&(m.blockedOn=null,aI||(aI=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,tXe)))}var _w=null;function use(m){_w!==m&&(_w=m,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){_w===m&&(_w=null);for(var b=0;b<m.length;b+=3){var w=m[b],S=m[b+1],j=m[b+2];if(typeof S!="function"){if(sI(S||w)===null)continue;break}var R=zt(w);R!==null&&(m.splice(b,3),b-=3,iL(R,{pending:!0,data:j,method:w.method,action:S},S,j))}}))}function Tm(m){function b(Oe){return bw(Oe,m)}Vd!==null&&bw(Vd,m),Qd!==null&&bw(Qd,m),Ud!==null&&bw(Ud,m),m7.forEach(b),g7.forEach(b);for(var w=0;w<Wd.length;w++){var S=Wd[w];S.blockedOn===m&&(S.blockedOn=null)}for(;0<Wd.length&&(w=Wd[0],w.blockedOn===null);)lse(w),w.blockedOn===null&&Wd.shift();if(w=(m.ownerDocument||m).$$reactFormReplay,w!=null)for(S=0;S<w.length;S+=3){var j=w[S],R=w[S+1],J=j[qt]||null;if(typeof R=="function")J||use(w);else if(J){var oe=null;if(R&&R.hasAttribute("formAction")){if(j=R,J=R[qt]||null)oe=J.formAction;else if(sI(j)!==null)continue}else oe=J.action;typeof oe=="function"?w[S+1]=oe:(w.splice(S,3),S-=3),use(w)}}}function dse(){function m(R){R.canIntercept&&R.info==="react-transition"&&R.intercept({handler:function(){return new Promise(function(J){return j=J})},focusReset:"manual",scroll:"manual"})}function b(){j!==null&&(j(),j=null),S||setTimeout(w,20)}function w(){if(!S&&!navigation.transition){var R=navigation.currentEntry;R&&R.url!=null&&navigation.navigate(R.url,{state:R.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var S=!1,j=null;return navigation.addEventListener("navigate",m),navigation.addEventListener("navigatesuccess",b),navigation.addEventListener("navigateerror",b),setTimeout(w,100),function(){S=!0,navigation.removeEventListener("navigate",m),navigation.removeEventListener("navigatesuccess",b),navigation.removeEventListener("navigateerror",b),j!==null&&(j(),j=null)}}}function lI(m){this._internalRoot=m}xw.prototype.render=lI.prototype.render=function(m){var b=this._internalRoot;if(b===null)throw Error(r(409));var w=b.current,S=Ll();nse(w,S,m,b,null,null)},xw.prototype.unmount=lI.prototype.unmount=function(){var m=this._internalRoot;if(m!==null){this._internalRoot=null;var b=m.containerInfo;nse(m.current,2,null,m,null,null),ew(),b[yr]=null}};function xw(m){this._internalRoot=m}xw.prototype.unstable_scheduleHydration=function(m){if(m){var b=Kn();m={blockedOn:null,target:m,priority:b};for(var w=0;w<Wd.length&&b!==0&&b<Wd[w].priority;w++);Wd.splice(w,0,m),w===0&&lse(m)}};var fse=e.version;if(fse!=="19.2.4")throw Error(r(527,fse,"19.2.4"));V.findDOMNode=function(m){var b=m._reactInternals;if(b===void 0)throw typeof m.render=="function"?Error(r(188)):(m=Object.keys(m).join(","),Error(r(268,m)));return m=c(b),m=m!==null?u(m):null,m=m===null?null:m.stateNode,m};var nXe={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:N,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var yw=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!yw.isDisabled&&yw.supportsFiber)try{Kt=yw.inject(nXe),Dn=yw}catch{}}return kv.createRoot=function(m,b){if(!o(m))throw Error(r(299));var w=!1,S="",j=_oe,R=xoe,J=yoe;return b!=null&&(b.unstable_strictMode===!0&&(w=!0),b.identifierPrefix!==void 0&&(S=b.identifierPrefix),b.onUncaughtError!==void 0&&(j=b.onUncaughtError),b.onCaughtError!==void 0&&(R=b.onCaughtError),b.onRecoverableError!==void 0&&(J=b.onRecoverableError)),b=ese(m,1,!1,null,null,w,S,null,j,R,J,dse),m[yr]=b.current,qL(m),new lI(b)},kv.hydrateRoot=function(m,b,w){if(!o(m))throw Error(r(299));var S=!1,j="",R=_oe,J=xoe,oe=yoe,Oe=null;return w!=null&&(w.unstable_strictMode===!0&&(S=!0),w.identifierPrefix!==void 0&&(j=w.identifierPrefix),w.onUncaughtError!==void 0&&(R=w.onUncaughtError),w.onCaughtError!==void 0&&(J=w.onCaughtError),w.onRecoverableError!==void 0&&(oe=w.onRecoverableError),w.formState!==void 0&&(Oe=w.formState)),b=ese(m,1,!0,b,w??null,S,j,Oe,R,J,oe,dse),b.context=tse(null),w=b.current,S=Ll(),S=Xt(S),j=jd(S),j.callback=null,Nd(w,j,S),w=S,b.current.lanes=w,sn(b,w),f1(b),m[yr]=b.current,qL(m),new xw(b)},kv.version="19.2.4",kv}var t8e;function uYn(){if(t8e)return TH.exports;t8e=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),TH.exports=cYn(),TH.exports}var kZe=uYn();const dYn=({source:t},e)=>{const n=kZe.createRoot(e);return n.render(f.jsx(QP,{className:"size-full break-words leading-relaxed [overflow-wrap:anywhere] [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",plugins:uee,components:cee,children:t})),()=>queueMicrotask(()=>n.unmount())};function OZe(){const{settings:t}=Qh(),e=t.codingAgents??[],n=t.defaultCodingAgent??e[0]?.id;return{agents:[...e].sort((o,i)=>+(i.id===n)-+(o.id===n)),defaultAgentId:n}}function SZe({agents:t,defaultAgentId:e,onPick:n}){return t.length===0?f.jsxs(dr,{onClick:()=>n(void 0),"data-testid":"worktree-center__new-agent",children:[f.jsx(dM,{className:"size-4"}),"Default agent"]}):t.map(r=>f.jsxs(dr,{onClick:()=>n(r.id===e?void 0:r.id),"data-testid":`worktree-center__new-agent--${r.id}`,"data-default":r.id===e?"true":void 0,children:[f.jsx(D3,{type:r.type,className:"size-4"}),r.label,r.id===e&&f.jsx(pF,{className:"tracking-normal",children:"Default"})]},r.id))}function fYn({onPick:t}){const{agents:e,defaultAgentId:n}=OZe();return f.jsxs(rP,{children:[f.jsxs(oP,{"data-testid":"worktree-center__new-tab--agent",children:[f.jsx(dM,{className:"size-4"}),"New agent"]}),f.jsx(nP,{children:f.jsx(iP,{"data-testid":"worktree-center__new-agent-menu",children:f.jsx(SZe,{agents:e,defaultAgentId:n,onPick:t})})})]})}function hYn({className:t,onPick:e}){const{agents:n,defaultAgentId:r}=OZe();return f.jsxs(Us,{children:[f.jsx(Ws,{asChild:!0,children:f.jsxs("button",{type:"button",className:t,"data-testid":"worktree-center__empty-new-agent",children:[f.jsx(dM,{className:"size-4"}),"New agent"]})}),f.jsx(Zs,{align:"start","data-testid":"worktree-center__new-agent-menu",children:f.jsx(SZe,{agents:n,defaultAgentId:r,onPick:e})})]})}const Cne=v.createContext({visible:!0,wsActive:!0});function Wh(){return v.useContext(Cne)}function pYn(t){return t.subarray(0,8e3).includes(0)}function mYn(t,e){const[n,r]=v.useState({state:"loading"});return v.useEffect(()=>{if(!e)return;let o=!1;return r({state:"loading"}),j4(t).then(async i=>{if(!i.ok)throw new Error(String(i.status));const s=new Uint8Array(await i.arrayBuffer());o||r(pYn(s)?{state:"binary"}:{state:"text",text:new TextDecoder().decode(s)})}).catch(()=>{o||r({state:"error"})}),()=>{o=!0}},[t,e]),n}function gYn({name:t}){return f.jsxs(t0,{children:[f.jsx(ku,{asChild:!0,children:f.jsx(Ce,{variant:"ghost",size:"icon","aria-label":`Could not load ${t}`,"data-testid":"shared-file__error",className:"text-destructive",children:f.jsx(_u,{className:"size-5"})})}),f.jsx(n0,{className:"text-sm",children:"The file could not be loaded. It may be gone."})]})}function vYn({worktreeId:t,filePath:e}){const n=KQn(t,e),r=e.split("/").pop()??e,o=Uee(r),i=/\.html?$/i.test(r),a=mYn(n??"",!!n&&o!=="image"&&o!=="pdf");if(!n)return null;const l=lh(n);let c;return o==="image"?c=f.jsx("div",{className:"flex h-full items-center justify-center overflow-auto p-4",children:f.jsx("img",{src:l,alt:r,"data-testid":"shared-file__image",className:"max-h-full max-w-full object-contain"})}):o==="pdf"?c=f.jsx("iframe",{src:l,title:r,"data-testid":"shared-file__pdf",className:"size-full border-0"}):i&&a.state==="text"?c=f.jsx("iframe",{srcDoc:a.text,title:r,sandbox:"allow-scripts","data-testid":"shared-file__html",className:"size-full border-0 bg-white"}):a.state==="loading"?c=f.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading…"}):a.state==="error"?c=f.jsx("div",{className:"flex h-full items-center justify-center",children:f.jsx(gYn,{name:r})}):a.state==="binary"?c=f.jsxs("div",{"data-testid":"shared-file__binary",className:"flex h-full flex-col items-center justify-center gap-3 text-muted-foreground",children:[f.jsx(Oh,{className:"size-8"}),f.jsx("p",{className:"text-sm",children:"No preview for this file type"}),f.jsxs(Ce,{variant:"outline",size:"sm","data-testid":"shared-file__binary-download",onClick:()=>ZT(l,r),children:[f.jsx(N6,{className:"size-4"}),"Download"]})]}):o==="markdown"?c=f.jsx("div",{"data-testid":"shared-file__markdown",className:"h-full overflow-auto p-4",children:f.jsx(g4,{children:a.text})}):c=f.jsx("div",{"data-testid":"shared-file__code",className:"h-full",children:f.jsx(XY,{content:a.text,language:rZe(r),className:"h-full"})}),f.jsxs("div",{tabIndex:-1,"data-band-leaf-root":"",className:"flex h-full w-full flex-col overflow-hidden outline-none","data-testid":"shared-file",children:[f.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-3 py-1.5",children:[f.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-sm",children:r}),f.jsx(Ce,{variant:"ghost",size:"sm","aria-label":"Download file","data-testid":"shared-file__download",onClick:()=>ZT(l,r),children:f.jsx(N6,{className:"size-4"})})]}),f.jsx("div",{className:"min-h-0 flex-1",children:c})]})}const n8e=50,CZe=new Map;function jW(t){return CZe.get(t)??[]}function bYn(t,e){const n=jW(t).filter(r=>r!==e);return n.unshift(e),n.length>n8e&&(n.length=n8e),CZe.set(t,n),n}function _Yn(t){const[e,n]=v.useState(()=>jW(t));v.useEffect(()=>{n(jW(t))},[t]);const r=v.useCallback(o=>{if(!o)return;const i=bYn(t,o);n(i)},[t]);return{recentFiles:e,trackFile:r}}const $1={onOpenFile:()=>{},onSelectFile:()=>{},onFileOpened:()=>{},onFindInFile:()=>{},onActivateFilesPanel:()=>{},onActivateTerminalPanel:()=>{}};function Ep(t,e){const n=Tf(t),r=n?jZe(n,e):void 0;return r?(r.api.setActive(),!0):!1}function Ov(t,e){const n=Tf(t),r=n?.activeGroup??n?.groups[0];Io(t)?.onAdd(e,r?.id)}function r8e(t){const e=Tf(t)?.activeGroup;e&&(e.api.isMaximized()?e.api.exitMaximized():e.api.maximize())}function o8e(t){t&&window.dispatchEvent(new CustomEvent("band:focus-active-leaf",{detail:{worktreeId:t}}))}function Sv(t){window.dispatchEvent(new CustomEvent("band:show-right-panel")),t&&window.dispatchEvent(new CustomEvent("band:right-sidepanel-set-tab",{detail:{tab:t}}))}function xYn(){return f.jsx("div",{className:"flex h-full items-center justify-center",children:f.jsxs("div",{className:"flex flex-col items-center gap-3 text-center px-8",children:[f.jsx(ld,{className:"size-8 text-muted-foreground/30"}),f.jsx("p",{className:"text-sm text-muted-foreground",children:"Select a worktree to get started"})]})})}function yYn(){const t=Mo({select:H=>H.location.pathname}),e=v8(t),n=v.useRef(e);n.current=e,v.useEffect(()=>{e&&UHe(e)},[e]);const{recentFiles:r,trackFile:o}=_Yn(e??""),s=Gs().pickFile,a=v.useRef(void 0),l=v.useRef(new Map),[c,u]=v.useState(!1),[d,h]=v.useState(void 0),[p,g]=v.useState(!1),[_,x]=v.useState(!1),[y,k]=v.useState(!1),[O,C]=v.useState(""),[A,E]=v.useState(void 0);v.useEffect(()=>{if(!e){E(void 0),a.current=void 0;return}const H=dT(e);return E(H.currentFile),a.current=H.currentFile,Cqe(e,()=>{const V=dT(e).currentFile;E(V),a.current=V})},[e]);const M=v.useCallback((H,N)=>{const V=X5(N);o(V.filePath),Io(H)?.openFile(V.filePath,{line:V.line,column:V.column})},[o]),P=v.useCallback(H=>{},[]),L=v.useCallback((H,N)=>{const V=X5(N);Io(H)?.openFile(V.filePath,{line:V.line,column:V.column,external:!0})},[]),D=v.useCallback((H,N)=>{N&&o(N)},[o]),I=v.useCallback((H,N)=>{N?l.current.set(H,N):l.current.delete(H)},[]),z=v.useCallback(H=>{Sv("explorer")},[]),Y=v.useCallback(H=>{H===n.current&&(Ep(H,"term"),queueMicrotask(()=>window.dispatchEvent(new CustomEvent("band:focus-terminal"))))},[]);$1.onOpenFile=M,$1.onFileOpened=P,$1.onSelectFile=D,$1.onFindInFile=I,$1.onActivateFilesPanel=z,$1.onActivateTerminalPanel=Y;const Q=v.useMemo(()=>kBt({getApi:()=>{const H=Tf(n.current);return H?{getPanel:N=>{if(N==="files"||N==="changes")return;const G=jZe(H,N==="terminal"?"term":N);return G?{api:{setActive:()=>G.api.setActive()}}:void 0}}:null},getHiddenPanels:()=>[],openQuickOpen:()=>u(!0),openSearchFiles:()=>g(!0),findInFile:()=>{const H=n.current,N=H?l.current.get(H):void 0;N?N():window.dispatchEvent(new CustomEvent("band:find-in-file"))},formatCurrentFile:()=>{const H=n.current;H&&window.dispatchEvent(new CustomEvent("band:format-current-file",{detail:{worktreeId:H,filePath:a.current}}))},newUntitledTab:()=>window.dispatchEvent(new CustomEvent("band:new-untitled-tab")),changeLanguageMode:()=>{const H=n.current;H&&window.dispatchEvent(new CustomEvent("band:open-language-picker",{detail:{worktreeId:H,filePath:a.current}}))},editorGoBack:()=>{const H=n.current;H&&window.dispatchEvent(new CustomEvent("band:editor-go-back",{detail:{worktreeId:H}}))},editorGoForward:()=>{const H=n.current;H&&window.dispatchEvent(new CustomEvent("band:editor-go-forward",{detail:{worktreeId:H}}))},newLeaf:H=>Ov(n.current,H),openWorktreePicker:()=>x(!0),closeActiveTab:()=>{const H=n.current,N=Tf(H)?.activePanel;N&&Io(H)?.onClose(N.id,N.api.component)},splitActiveTab:H=>{const N=n.current,V=Tf(N),G=V?.activePanel,K=V?.activeGroup?.id;if(!G||!K)return;const q=G.api.component;q==="term"?window.dispatchEvent(new CustomEvent("band:split-terminal-pane",{detail:{leafId:G.id,direction:H}})):(q==="chat"||q==="browser")&&Io(N)?.onSplit(q,K,H)},cycleTabs:H=>{const N=n.current;qWe(Tf(N)??null,H,()=>o8e(N))},cycleGroups:H=>{const N=n.current;wne(Tf(N)??null,H,()=>o8e(N))},toggleMaximize:()=>r8e(n.current),openFileExternal:()=>{const H=n.current;H&&window.dispatchEvent(new CustomEvent("band:open-file-external",{detail:{worktreeId:H}}))}}),[]);return v.useEffect(()=>{const H=N=>{const V=n.current,G=document.activeElement?.closest(".xterm")!=null;if(N.metaKey&&!N.ctrlKey&&!N.shiftKey&&N.key.toLowerCase()==="k"){N.preventDefault(),N.stopPropagation(),x(!0);return}if(N.ctrlKey&&!N.metaKey&&!N.shiftKey&&N.key.toLowerCase()==="k"){if(G)return;N.preventDefault(),N.stopPropagation(),x(!0);return}if(N.ctrlKey&&!N.metaKey&&N.key==="`"){N.preventDefault(),N.stopPropagation(),Ep(V,"term")||Io(V)?.onAdd("term"),queueMicrotask(()=>window.dispatchEvent(new CustomEvent("band:focus-terminal")));return}if(N.ctrlKey&&!N.metaKey&&N.key==="0"){N.preventDefault(),N.stopPropagation(),window.dispatchEvent(new CustomEvent("band:show-sidebar")),queueMicrotask(()=>window.dispatchEvent(new CustomEvent("band:focus-repos")));return}if(N.code==="KeyF"&&N.altKey&&N.shiftKey&&!N.metaKey&&!N.ctrlKey){if(G||(N.preventDefault(),!V))return;window.dispatchEvent(new CustomEvent("band:format-current-file",{detail:{worktreeId:V,filePath:a.current}}));return}if(!(N.metaKey||N.ctrlKey))return;const q=N.key.toLowerCase(),Z=!Y2()&&(N.shiftKey&&!N.altKey&&(q==="n"||q==="b"||q==="p"||q==="m")||N.altKey&&!N.shiftKey&&N.code==="KeyI");if(!(G&&!N.metaKey&&!Z)){if(q==="t"&&!N.shiftKey&&!N.altKey){N.preventDefault(),N.stopPropagation(),Ov(V,"term");return}if(N.code==="KeyT"&&N.altKey&&N.metaKey&&!N.ctrlKey&&!N.shiftKey){N.preventDefault(),N.stopPropagation(),Ov(V,"chat");return}if(q==="n"&&N.shiftKey)N.preventDefault(),N.stopPropagation(),Ov(V,"chat");else if(q==="n"&&!N.shiftKey&&!N.altKey)N.preventDefault(),window.dispatchEvent(new CustomEvent("band:new-untitled-tab"));else if(q==="p"&&N.shiftKey)N.preventDefault(),k(!0);else if(q==="p"&&!N.shiftKey)N.preventDefault(),u(!0);else if(q==="f"&&N.shiftKey&&!N.altKey)N.preventDefault(),g(!0);else if(q==="f"&&!N.shiftKey&&!N.altKey){if(G||document.activeElement?.closest("[data-chat-pane]"))return;N.preventDefault();const U=V?l.current.get(V):void 0;U?U():window.dispatchEvent(new CustomEvent("band:find-in-file"))}else if(q==="o"&&!N.shiftKey&&!N.altKey){if(N.preventDefault(),!V)return;window.dispatchEvent(new CustomEvent("band:open-file-external",{detail:{worktreeId:V}}))}else N.code==="KeyI"&&(Y2()?N.ctrlKey&&N.metaKey:N.ctrlKey&&N.altKey&&!N.metaKey&&q==="i")?(N.preventDefault(),Ep(V,"chat"),queueMicrotask(()=>window.dispatchEvent(new CustomEvent("band:focus-chat")))):q==="g"&&N.shiftKey?(N.preventDefault(),Sv("changes")):q==="e"&&N.shiftKey?(N.preventDefault(),Sv("explorer")):q==="b"&&N.shiftKey?(N.preventDefault(),Ov(V,"browser")):q==="b"&&!N.shiftKey&&!N.altKey?(N.preventDefault(),window.dispatchEvent(new CustomEvent("band:toggle-sidebar"))):N.code==="KeyB"&&N.altKey&&!N.shiftKey?(N.preventDefault(),window.dispatchEvent(new CustomEvent("band:toggle-right-panel"))):q==="m"&&N.shiftKey&&(N.preventDefault(),r8e(V))}};return window.addEventListener("keydown",H,!0),()=>window.removeEventListener("keydown",H,!0)},[]),v.useEffect(()=>{const H=N=>{const V=N.detail;V?.filename&&(V.worktreeId&&V.worktreeId!==e||(h(V.filename),u(!0)))};return window.addEventListener("band:open-file",H),()=>window.removeEventListener("band:open-file",H)},[e]),v.useEffect(()=>{const H=N=>{const V=N.detail;V?.filePath&&Io(V.worktreeId??e)?.openFile(V.filePath,{preview:!1,line:V.line,column:V.column})};return window.addEventListener("band:lsp-navigate",H),()=>window.removeEventListener("band:lsp-navigate",H)},[e]),v.useEffect(()=>{const H=()=>u(!0),N=()=>g(!0);return window.addEventListener("band:open-quick-open",H),window.addEventListener("band:open-search-files",N),()=>{window.removeEventListener("band:open-quick-open",H),window.removeEventListener("band:open-search-files",N)}},[]),v.useEffect(()=>{const H=N=>{const V=N.detail?.panelId;if(!V)return;if(V==="files"){Sv("explorer");return}if(V==="changes"){Sv("changes");return}const G=V==="terminal"?"term":V;Ep(n.current,G)};return window.addEventListener("band:activate-panel",H),()=>window.removeEventListener("band:activate-panel",H)},[]),v.useEffect(()=>{const H=N=>{const V=N.detail?.reference,G=n.current;!V||!G||(Ep(G,"term"),(async()=>{let K;try{K=(await Se.panelFocus.get.query({worktreeId:G})).terminal}catch{}window.dispatchEvent(new CustomEvent("band:terminal-insert",{detail:{reference:V,worktreeId:G,terminalId:K}}))})())};return window.addEventListener("band:add-to-terminal",H),()=>window.removeEventListener("band:add-to-terminal",H)},[]),v.useEffect(()=>{const H=N=>{const V=N.detail;if(!V?.worktreeId||!V.text)return;const{worktreeId:G,text:K,done:q}=V;(async()=>{try{let Z;try{Z=(await Se.panelFocus.get.query({worktreeId:G})).chat}catch{}if(!Z){const{chats:B}=await Se.chats.list.query({worktreeId:G});Z=B[0]?.id}Z||(Z=(await Se.chats.create.mutate({worktreeId:G})).chat.id),Ep(G,"chat");const U=await oC(()=>G,Z)(`/api/chats/${encodeURIComponent(Z)}/messages`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreeId:G,text:K})});q(U.ok)}catch{q(!1)}})()};return window.addEventListener("band:send-to-chat",H),()=>window.removeEventListener("band:send-to-chat",H)},[]),v.useEffect(()=>{const H=N=>{const V=N.detail,G=n.current;!V||!G||(Ep(G,"chat"),(async()=>{let K;try{K=(await Se.panelFocus.get.query({worktreeId:G})).chat}catch{}const q="text"in V?{text:V.text,worktreeId:G,chatId:K}:{filePath:V.filePath,startLine:V.startLine,endLine:V.endLine,worktreeId:G,chatId:K};window.dispatchEvent(new CustomEvent("band:chat-insert",{detail:q}))})())};return window.addEventListener("band:add-to-chat",H),()=>window.removeEventListener("band:add-to-chat",H)},[]),v.useEffect(()=>{const H=()=>{const N=n.current;if(!N)return;const V=qYn(N);Io(N)?.openFile(V,{untitled:!0,preview:!1})};return window.addEventListener("band:new-untitled-tab",H),()=>window.removeEventListener("band:new-untitled-tab",H)},[]),v.useEffect(()=>{if(!s)return;const H=N=>{const V=N.detail,G=V?.worktreeId??n.current;!G||V?.worktreeId&&V.worktreeId!==n.current||(async()=>{const K=await s();if(!K)return;const q=X5(K);Io(G)?.openFile(q.filePath,{line:q.line,column:q.column,external:!0,preview:!1})})()};return window.addEventListener("band:open-file-external",H),()=>window.removeEventListener("band:open-file-external",H)},[s]),f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"absolute inset-0",children:f.jsx(Aqe,{emptyState:f.jsx(xYn,{}),children:(H,N)=>f.jsx(AFe.Provider,{value:N,children:f.jsxs("div",{className:"flex h-full w-full flex-col",children:[f.jsx(Mqe,{worktreeId:H,active:N}),f.jsx("div",{className:"relative min-h-0 flex-1",children:f.jsx(FZe,{worktreeId:H,visible:N,wsActive:N})})]})})})}),f.jsx(qHe,{worktreeId:e??"",open:c,onOpenChange:H=>{u(H),H||h(void 0)},onOpenFile:H=>{e&&M(e,H)},onOpenExternalFile:H=>{e&&L(e,H)},currentFile:A,initialQuery:d,autoOpen:d!=null,recentFiles:r,lastQuery:O,onQueryChange:C}),f.jsx(VHe,{worktreeId:e??"",open:p,onOpenChange:g,onOpenFile:H=>{e&&M(e,H)}}),f.jsx(ZHe,{open:_,onOpenChange:x}),f.jsx(SBt,{open:y,onOpenChange:k,commands:Q})]})}const i8e={question:5,failed:4,working:3,monitoring:2,done:1};function Ane({status:t,testId:e}){return t==="working"?f.jsx(Fo,{role:"img","aria-label":gb.working.label,"data-testid":e,"data-status":t,className:"size-3 animate-spin text-muted-foreground"}):f.jsx(bG,{status:t,testId:e,withTitle:!0})}function AZe(t,e){return Cn(n=>n.statuses.get(t)?.tabStatuses?.find(r=>r.chatId===e)?.status)}function EZe(t,e){return Cn(n=>{let r;for(const o of n.statuses.get(t)?.tabStatuses??[])!o.terminalId||(cT(o.terminalId)??o.terminalId)!==e||(!r||i8e[o.status]>i8e[r])&&(r=o.status);return r})}function Ene(t){if(!t)return{};try{const e=sessionStorage.getItem(`band:chat-tab-meta:${t}`);return e?JSON.parse(e):{}}catch{return{}}}function s8e(t,e){if(t)try{const n=Ene(t);sessionStorage.setItem(`band:chat-tab-meta:${t}`,JSON.stringify({...n,...e}))}catch{}}function wYn({item:t}){const e="size-4 shrink-0 text-muted-foreground";switch(t.kind){case"chat":{const n=Ene(t.params?.chatId??"").agentType;return n?f.jsx(D3,{type:n,className:"size-4 shrink-0"}):f.jsx(Q_,{className:e})}case"term":return f.jsx(_M,{className:e});case"browser":return f.jsx(xu,{className:e});case"diff":return f.jsx(B2,{className:e});default:{const n=U2(t.title);return f.jsx(n,{className:e})}}}function kYn({item:t}){const e=t.params?.worktreeId??"",n=AZe(e,t.params?.chatId??""),r=EZe(e,t.params?.terminalId??""),o=t.kind==="chat"?n:t.kind==="term"?r:void 0;return o?f.jsx(Ane,{status:o,testId:`tab-switcher__status--${t.id}`}):null}function OYn(t){return f.jsx("div",{className:"pointer-events-none absolute inset-0 z-50 flex items-center justify-center",children:f.jsx("div",{"data-testid":"tab-switcher",className:"max-h-[60%] w-80 max-w-[90%] overflow-y-auto rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-lg",children:t.items.map((e,n)=>f.jsxs("div",{"aria-current":n===t.index,"data-testid":"tab-switcher__item",className:Ze("flex items-center gap-2 rounded-sm px-2 py-1.5 text-sm",n===t.index&&"bg-foreground/15 font-medium text-foreground"),children:[f.jsx(wYn,{item:e}),f.jsx("span",{className:"min-w-0 flex-1 truncate",children:e.title}),f.jsx(kYn,{item:e})]},e.id))})})}const SYn=1500,jH=/Mac|iPhone|iPad/.test(navigator.platform)?"⌘":"Ctrl",a8e="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-sm hover:bg-accent focus-visible:bg-accent focus-visible:outline-hidden";function CYn({worktreeId:t}){const[e,n]=v.useState(null),[r,o]=v.useState(!1);if(v.useEffect(()=>{const a=l=>{const c=l.detail;c.worktreeId===t&&(o(!1),n(c))};return window.addEventListener(OU,a),()=>window.removeEventListener(OU,a)},[t]),v.useEffect(()=>{if(!r)return;const a=window.setTimeout(()=>o(!1),SYn);return()=>window.clearTimeout(a)},[r]),!e)return null;const{url:i}=e,s=()=>n(null);return f.jsxs(t0,{open:!0,onOpenChange:a=>!a&&s(),children:[f.jsx(Lxe,{asChild:!0,children:f.jsx("span",{"aria-hidden":!0,className:"pointer-events-none fixed size-0",style:{left:e.x,top:e.y}})}),f.jsxs(n0,{align:"start",className:"w-80 p-1","data-testid":"terminal-link-popover","aria-label":"Link actions",onCloseAutoFocus:a=>{a.preventDefault(),e.focusTerminal()},children:[f.jsxs("div",{className:"flex items-center gap-1 px-2 py-1",children:[f.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-muted-foreground",title:i,"data-testid":"terminal-link-popover__url",children:i}),f.jsx("button",{type:"button","aria-label":r?"Copied":"Copy link","data-testid":"terminal-link-popover__copy",onClick:()=>{Vs(i).then(a=>o(a))},className:"rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground",children:r?f.jsx(Ji,{className:"size-3.5"}):f.jsx(z0,{className:"size-3.5"})})]}),CU(i)&&f.jsxs("button",{type:"button",className:a8e,"data-testid":"terminal-link-popover__open-band",onClick:()=>{s(),JFe({worktreeId:t,terminalId:e.terminalId,url:i})},children:[f.jsx(xu,{className:"size-4 shrink-0"}),f.jsx("span",{className:"flex-1",children:"Open in Band browser"}),f.jsxs("kbd",{className:"text-xs text-muted-foreground",children:[jH," Click"]})]}),f.jsxs("button",{type:"button",className:a8e,"data-testid":"terminal-link-popover__open-system",onClick:()=>{s(),N4(i)},children:[f.jsx(gM,{className:"size-4 shrink-0"}),f.jsx("span",{className:"flex-1",children:"Open in system browser"}),f.jsx("kbd",{className:"text-xs text-muted-foreground",children:CU(i)?`⇧ ${jH} Click`:`${jH} Click`})]})]})]})}function AYn(t,e){let n;const r=()=>{n?.dispose(),n=t.activePanel?.api.onDidTitleChange(e),e()},o=t.onDidActivePanelChange(r);return r(),{dispose(){o.dispose(),n?.dispose()}}}const EYn=v.lazy(()=>re(()=>import("./TerminalPanel-CfzL015Z.js"),[]).then(t=>({default:t.TerminalPanel}))),TYn="band-layout--split",NW=new Map;function MYn({params:t,api:e}){const{visible:n}=Wh(),r=v.useCallback(i=>e.setTitle(i),[e]);if(!t.worktreeId||!t.terminalId)return null;const o=t.command||t.cwd||t.env?{command:t.command,cwd:t.cwd,env:t.env}:void 0;return f.jsx("div",{className:"flex h-full w-full flex-col overflow-hidden","data-testid":`term-pane__${t.terminalId}`,children:f.jsx(v.Suspense,{fallback:null,children:f.jsx(EYn,{worktreeId:t.worktreeId,terminalId:t.terminalId,visible:n,paneMetadata:o,autoFocus:t.autoFocus,onTitleChange:r})})})}function TZe(t){const e=t.containerApi.id,n=t.params.terminalId,r=s=>a=>{a.stopPropagation(),a.preventDefault();const l=NW.get(e)?.current;l&&s(l)},o=s=>s.stopPropagation(),i=Cn(s=>s.statuses.get(t.params.worktreeId)?.tabStatuses?.find(a=>a.terminalId===n)?.status);return f.jsxs("div",{className:"term-pane-header","data-testid":`term-pane-header__${n}`,children:[i?f.jsx("span",{className:"term-pane-header__status",children:f.jsx(bG,{status:i,testId:`term-pane__status--${n}`,withTitle:!0})}):null,f.jsxs("div",{className:"term-pane-header__actions","data-testid":`term-pane-actions__${n}`,children:[f.jsx("button",{type:"button",onMouseDown:o,onClick:r(s=>s.split(n,"right")),title:"Split right","aria-label":"Split right","data-testid":`term-pane-split-right__${n}`,children:f.jsx(U7e,{className:"size-3"})}),f.jsx("button",{type:"button",onMouseDown:o,onClick:r(s=>s.split(n,"below")),title:"Split down","aria-label":"Split down","data-testid":`term-pane-split-down__${n}`,children:f.jsx(Cit,{className:"size-3"})}),f.jsx("button",{type:"button",className:"term-pane-header__close",onMouseDown:o,onClick:r(s=>s.close(n)),title:"Close pane","aria-label":"Close pane","data-testid":`term-pane-close__${n}`,children:f.jsx(pa,{className:"size-3"})})]})]})}const PYn={pane:MYn},jYn={pane:TZe};function NYn(t){if(typeof t!="object"||t===null)return!1;const e=t;return typeof e.grid=="object"&&typeof e.panels=="object"}function RYn(t){const e=JSON.parse(JSON.stringify(t)),n=e?.panels;if(n)for(const r of Object.keys(n))n[r].params={};return e}function LYn(t,e){const n=JSON.parse(JSON.stringify(t)),r=n?.panels;if(r)for(const o of Object.keys(r))r[o].params={worktreeId:e,terminalId:o};return n}function NH(t,e,n,r){t.addPanel({id:e.terminalId,component:"pane",tabComponent:"pane",title:"Terminal",params:e,...n?{position:n}:{},...r?{inactive:!0}:{}})}function IYn({worktreeId:t,leafId:e,primaryTerminalId:n,command:r,cwd:o,env:i,autoFocus:s,visible:a,mobile:l,onActivePaneTitleChange:c,onCloseLeaf:u}){const d=v.useRef(null),h=v.useRef(null),p=v.useRef(!1),g=v.useRef(!1),_=v.useRef(null),x=v.useRef(null),y=v.useRef(c);y.current=c;const k=v.useRef(u);k.current=u;const O=v.useRef(a);O.current=a;const C=v.useCallback(()=>{if(l||p.current)return;x.current&&(clearTimeout(x.current),x.current=null);const Z=d.current;Z&&tMn(t,e,RYn(Z.toJSON()))},[t,e,l]),A=v.useCallback(()=>{l||p.current||(x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{x.current=null,C()},400))},[l,C]),E=v.useCallback(()=>{const Z=h.current,U=d.current;!Z||!U||Z.classList.toggle("band-layout-split--single",U.groups.length<=1)},[]),M=v.useRef(null),P=v.useCallback(()=>{const Z=d.current?.activePanel;y.current(Z?.title??"Terminal")},[]),L=v.useCallback(Z=>{const U=d.current;if(!U)return;if(U.panels.length<=1){k.current();return}QWe(U,Z);const B=U.getPanel(Z);B&&U.removePanel(B),yg(Z),Se.terminal.kill.mutate({terminalId:Z}).catch(()=>{}),NU(Z),requestAnimationFrame(()=>{U.activePanel?.element.querySelector(".xterm-helper-textarea")?.focus()})},[]),D=v.useRef(L);D.current=L;const I=v.useCallback((Z,U)=>{const B=d.current;if(!B||l)return;const ee=B.getPanel(Z)?.group?.id;if(!ee)return;const te=P5();tB(te,e),NH(B,{worktreeId:t,terminalId:te,autoFocus:!0},{referenceGroup:ee,direction:U}),Se.terminal.create.mutate({worktreeId:t,id:te}).catch(HS)},[t,e,l]),z=v.useRef(I);z.current=I;const Y=v.useCallback(Z=>{const U=d.current?.activePanel?.id;U&&I(U,Z)},[I]),Q=v.useCallback(()=>{if(g.current)return;const Z=d.current;if(!Z)return;const U=Z.groups.find(B=>B.panels.length>1);if(U){g.current=!0;try{for(const B of U.panels.slice(1)){const ee=Z.addGroup({referenceGroup:U,direction:"right"});B.api.moveTo({group:ee})}}catch{}finally{g.current=!1}}},[]),H=v.useCallback(Z=>{d.current=Z,NW.set(Z.id,{current:{close:ee=>D.current(ee),split:(ee,te)=>z.current(ee,te)}}),p.current=!0;const U=l?null:eMn(t,e);let B=!1;if(U&&NYn(U))try{Z.fromJSON(LYn(U,t)),B=Z.panels.length>0}catch{Z.clear()}Z.panels.length===0&&(NH(Z,{worktreeId:t,terminalId:n,command:r,cwd:o,env:i,autoFocus:s},void 0,!s),s||Z.getPanel(n)?.api.setActive());for(const ee of Z.panels)tB(ee.id,e);if(B&&(async()=>{try{const{terminals:ee}=await Se.terminal.list.query({worktreeId:t}),te=new Set(ee.map(se=>se.terminalId));for(const se of[...Z.panels])te.has(se.id)||(Z.removePanel(se),yg(se.id),NU(se.id));Z.panels.length===0&&(tB(n,e),NH(Z,{worktreeId:t,terminalId:n},void 0,!0),Z.getPanel(n)?.api.setActive(),Se.terminal.create.mutate({worktreeId:t,id:n}).catch(()=>{}))}catch{}})(),setTimeout(()=>{p.current=!1},0),_.current?.(),h.current&&(_.current=JTn(h.current,Z,e)),E(),P(),Z.onDidLayoutChange(()=>A()),Z.onDidAddPanel(()=>{Q(),E(),C()}),Z.onDidRemovePanel(()=>{E(),C()}),Z.onDidMovePanel(()=>{Q(),E(),C()}),Z.onDidAddGroup(E),Z.onDidRemoveGroup(E),M.current?.dispose(),M.current=AYn(Z,P),O.current&&h.current){const ee=h.current.getBoundingClientRect();ee.width>0&&ee.height>0&&Z.layout(Math.round(ee.width),Math.round(ee.height),!0)}},[t,e,n,r,o,i,s,l,A,C,E,P,Q]);v.useEffect(()=>{if(!a)return;const Z=()=>{d.current?.activePanel?.element.querySelector(".xterm-helper-textarea")?.focus()},U=B=>{if(!h.current?.contains(document.activeElement))return;const ee=d.current;if(!ee)return;const te=B.key.toLowerCase(),se=l?null:UWe(B,Y2());if(se){B.preventDefault(),B.stopPropagation(),Y(se);return}if(B.metaKey||B.ctrlKey){if(!B.shiftKey&&(te==="["||te==="]")){B.preventDefault(),B.stopPropagation(),wne(ee,te==="]"?1:-1,()=>requestAnimationFrame(Z));return}if(te==="w"&&!B.shiftKey){B.preventDefault(),B.stopPropagation(),ee.panels.length<=1?k.current():ee.activePanel&&D.current(ee.activePanel.id);return}te==="d"&&(B.ctrlKey&&!B.metaKey&&!B.shiftKey?ee.panels.length>1&&ee.activePanel&&(B.preventDefault(),B.stopPropagation(),D.current(ee.activePanel.id)):(B.metaKey||B.ctrlKey)&&(B.preventDefault(),B.stopPropagation()))}};return window.addEventListener("keydown",U,!0),()=>window.removeEventListener("keydown",U,!0)},[a,l,Y]),v.useEffect(()=>{if(l)return;const Z=U=>{const B=U.detail;B?.leafId===e&&Y(B.direction)};return window.addEventListener("band:split-terminal-pane",Z),()=>window.removeEventListener("band:split-terminal-pane",Z)},[e,l,Y]);const N=v.useRef(C);N.current=C,v.useEffect(()=>()=>{const Z=d.current;Z&&NW.delete(Z.id),_.current?.(),_.current=null,M.current?.dispose(),x.current&&N.current()},[]);const[V,G]=v.useState(!1);v.useLayoutEffect(()=>{if(!a){G(!1);return}const Z=d.current,U=h.current;if(!Z||!U){G(!0);return}let B=0,ee=0;const te=(he,fe)=>{const be=Math.round(he),me=Math.round(fe);be<=0||me<=0||be===B&&me===ee||(B=be,ee=me,Z.layout(be,me,!0))},se=U.getBoundingClientRect();te(se.width,se.height),G(!0);const ae=new ResizeObserver(he=>{const fe=he[0];fe&&te(fe.contentRect.width,fe.contentRect.height)});return ae.observe(U),()=>ae.disconnect()},[a]);const K=a&&V,q=v.useMemo(()=>({visible:K,wsActive:K}),[K]);return f.jsx("div",{ref:h,className:"flex h-full w-full flex-col overflow-hidden",children:f.jsx(Cne.Provider,{value:q,children:f.jsx(xZe,{kind:"split",className:TYn,components:PYn,tabComponents:jYn,defaultTabComponent:TZe,onReady:H,disableDnd:l,paneMode:!0})})})}const DYn={chat:Q_,term:xM,browser:xu},zYn={},v4="min-w-0 flex-1 truncate text-xs",Cg="flex min-w-0 flex-1 items-center gap-1.5",b4="band-layout-tab-root group flex w-full items-center gap-1.5",$Yn="absolute inset-0 inline-flex items-center justify-center rounded-sm transition-opacity hover:bg-accent";function BYn(t,e){return`${$Yn} ${t&&!e?"opacity-70 hover:opacity-100":"opacity-0 group-hover:opacity-100"}`}function Ag({isActive:t,indicator:e,onClose:n,closeTitle:r,closeTestId:o}){return f.jsxs("span",{className:"relative ml-0.5 inline-flex size-4 shrink-0 items-center justify-center",children:[e?f.jsx("span",{className:"inline-flex items-center justify-center transition-opacity group-hover:opacity-0",children:e}):null,f.jsx("button",{type:"button",className:BYn(t,!!e),onClick:n,title:r,"aria-label":r,"data-testid":o,children:f.jsx(pa,{className:"size-3"})})]})}function dy(t){const[e,n]=v.useState(t.isActive);return v.useEffect(()=>{const r=t.onDidActiveChange(o=>n(o.isActive));return()=>r.dispose()},[t]),e}function MZe(t,e){const[n,r]=v.useState(()=>t.getParameters().preview??e);return v.useEffect(()=>{const o=t.onDidParametersChange(()=>{r(t.getParameters().preview)});return()=>o.dispose()},[t]),n===!0}function RW(t,e){const n={...e,...t.getParameters()};n.preview!==!1&&t.updateParameters({...n,preview:!1})}const PZe="band-layout--center",HYn=`${PZe} band-layout--desktop`,FYn=`${PZe} band-layout--mobile`,iC=new Map;function Tf(t){return t?iC.get(t):void 0}function jZe(t,e){return t.panels.find(n=>n.api.component===e)}const LW=new Map;function Io(t){return t?LW.get(t)?.current:void 0}const sC=new Map,IW="band:leaf-header-actions-changed";function l8e(t){window.dispatchEvent(new CustomEvent(IW,{detail:t}))}function NZe(t,e,n){const r=v.useRef(e);r.current=e,v.useEffect(()=>{const o=r.current;return o?sC.set(t,o):sC.delete(t),l8e(t),()=>{sC.delete(t),l8e(t)}},[t,...n])}const c8e=new Map;function qYn(t){let e=c8e.get(t)??0;for(const n of VT(t)?.tabs??[]){if(!n.id.startsWith(`file:${eC}`))continue;const r=Number(n.id.slice(`file:${eC}`.length));Number.isInteger(r)&&(e=Math.max(e,r))}return e+=1,c8e.set(t,e),`${eC}${e}`}const VYn="band:dockview-layout-v9:",QYn=new Set(["chat","term","browser","file","diff"]);function DW(t){return`${VYn}${t}`}function UYn(t,e,n){const r=JSON.parse(JSON.stringify(t)),o=r.panels;if(o)for(const[i,s]of Object.entries(o)){const a=s.contentComponent;a==="chat"?s.params={worktreeId:e,chatId:i}:a==="term"?s.params={worktreeId:e,terminalId:i}:a==="browser"?(s.params={worktreeId:e,browserId:i,initialUrl:n.get(i)},s.renderer="always"):a==="file"||a==="diff"?s.params=RZe(a,i,e):s.params={worktreeId:e}}return r}function RZe(t,e,n){if(t==="file")return{worktreeId:n,filePath:e.slice(5)};const r=KYn.exec(e),o=JYn.exec(e);return r?{worktreeId:n,filePath:r[2],commit:r[1]}:o?{worktreeId:n,filePath:"",allOf:o[1]}:{worktreeId:n,filePath:e.slice(5)}}function fy(t){const e=t.groups[0];return e?{referenceGroup:e.id}:{direction:"within"}}function DO(t){const e=t.activeGroup;return e?{referenceGroup:e.id}:fy(t)}function WYn(t){const e=t.groups;if(e.length<=1)return;const n=e[0];for(const r of e.slice(1))for(const o of[...r.panels])try{o.api.moveTo({group:n})}catch{}}function ZYn(t){try{const e=localStorage.getItem(DW(t));if(!e)return null;const n=JSON.parse(e);return rYn(n)?n:null}catch{return null}}let zO=null,u8e=0;const GYn=5e3;function YYn(){const t=Date.now();return(!zO||t-u8e>GYn)&&(u8e=t,zO=Se.settings.get.query().catch(()=>(zO=null,null))),zO}function XYn(t){return["worktreeCenterLayout",t]}const KYn=/^diff@([0-9a-f]{7,40}):(.+)$/i,JYn=/^diffs:(conflicts|unstaged|staged|untracked|branch)$/;function eXn(t,e){return`diff@${t}:${e}`}function tXn(t){return`diffs:${t}`}function nXn({params:t,api:e}){const[n,r]=v.useState(e.isActive),{visible:o,wsActive:i,worktreeId:s}=Wh(),a=s??t.worktreeId;return v.useEffect(()=>{const l=e.onDidActiveChange(c=>r(c.isActive));return()=>l.dispose()},[e]),!a||!t.chatId?null:f.jsx(rXn,{worktreeId:a,chatId:t.chatId,visible:o&&n,wsActive:i,setTitle:l=>e.setTitle(l)})}function rXn({worktreeId:t,chatId:e,visible:n,wsActive:r,setTitle:o}){const i=NGn(t,e),s=v.useRef(o);return s.current=o,v.useEffect(()=>{if(!i.sessionQueryDone)return;const a=zQn({name:i.chatName,summary:i.activeSessionSummary,agentLabel:i.agentLabel,agentId:i.codingAgentId});s.current(a)},[i.sessionQueryDone,i.chatName,i.activeSessionSummary,i.agentLabel,i.codingAgentId]),f.jsx("div",{className:"flex h-full w-full flex-col overflow-hidden outline-none",tabIndex:-1,"data-band-leaf-root":"","data-testid":`center-chat-leaf__visible-${n?"true":"false"}`,children:f.jsx(RGn,{worktreeId:t,chatId:e,visible:n,wsActive:r,state:i})})}function oXn({params:t,api:e,containerApi:n}){const{visible:r,worktreeId:o}=Wh(),[i,s]=v.useState(e.isVisible);v.useEffect(()=>{const p=e.onDidVisibilityChange(g=>s(g.isVisible));return()=>p.dispose()},[e]);const a=r&&i,l=v.useCallback(p=>e.setTitle(p),[e]),c=o??t.worktreeId,u=t.terminalId,d=v.useCallback(()=>{c&&u&&Io(c)?.onClose(u,"term")},[c,u]),h=F_.has(n.id);return!c||!u?null:f.jsx("div",{className:"flex h-full w-full flex-col overflow-hidden outline-none",tabIndex:-1,"data-band-leaf-root":"","data-testid":`center-term-leaf__visible-${a?"true":"false"}`,children:f.jsx(IYn,{worktreeId:c,leafId:u,primaryTerminalId:u,command:t.command,cwd:t.cwd,env:t.env,autoFocus:t.autoFocus,visible:a,mobile:h,onActivePaneTitleChange:l,onCloseLeaf:d})})}function iXn({params:t,api:e}){const{visible:n,worktreeId:r}=Wh(),o=r??t.worktreeId;if(!o||!t.browserId)return null;const i={worktreeId:o,browserId:t.browserId,wsActive:n,initialUrl:t.initialUrl};return f.jsx("div",{className:"flex h-full w-full flex-col overflow-hidden outline-none",tabIndex:-1,"data-band-leaf-root":"","data-testid":`center-browser-leaf__visible-${n?"true":"false"}`,children:f.jsx(BUn,{params:i,api:e})})}function R0(t){const e=t.split(/[\\/]/);return e[e.length-1]||t}const Tne=t=>`band-tab-state:${t}`;function T8(t){try{const e=localStorage.getItem(Tne(t));if(!e)return{};const n=JSON.parse(e);return typeof n!="object"||n===null?{}:sXn(t,n)}catch{return{}}}function sXn(t,e){let n=!1;for(const[r,o]of Object.entries(e))!o||typeof o!="object"||("editorState"in o&&(delete o.editorState,n=!0),"editedContent"in o&&(typeof o.editedContent=="string"&&Eg(t,r)===null&&Tg(t,r,o.editedContent),delete o.editedContent,n=!0));return n&&rR(t,e),e}let d8e=!1;function aXn(){if(!d8e){d8e=!0;try{const t=Tne(""),e=[];for(let n=0;n<localStorage.length;n++){const r=localStorage.key(n);r?.startsWith(t)&&e.push(r)}for(const n of e){const r=localStorage.getItem(n);!r?.includes('"editorState"')&&!r?.includes('"editedContent"')||T8(n.slice(t.length))}}catch{}}}function rR(t,e){try{Hn.setItem(Tne(t),JSON.stringify(e))}catch{}}function $O(t,e){return T8(t)[e]}function Cv(t,e,n){const r=T8(t);r[e]={...r[e]??{},...n},rR(t,r)}const lXn="band-unsaved:",B_=(t,e)=>`${lXn}${t}:${e}`;function Eg(t,e){return Hn.getItem(B_(t,e))}function Tg(t,e,n){n===null?Hn.removeItem(B_(t,e)):Hn.setItem(B_(t,e),n)}const zW=new Set,$W=(t,e)=>`${t}\0${e}`;function Mne(t,e){return zW.has($W(t,e))}function H_(t,e,n){n?zW.add($W(t,e)):zW.delete($W(t,e))}function KT(t,e){return T8(t),Eg(t,e)!==null}const BW=new Set,HW=(t,e)=>`${t}\0${e}`;function FW(t,e){const n=T8(t);e in n&&(delete n[e],rR(t,n)),Eg(t,e)!==null&&Tg(t,e,null),H_(t,e,!1)}function LZe(t,e,n=!1){const r=v.useRef(null),o=v.useRef([]),i=v.useCallback(()=>o.current,[]),s=v.useMemo(()=>e?u=>$1.onFindInFile(t,u):null,[e,t]),a=iSn({getViews:i,onFindInFile:s,registerGlobalFindKey:!1}),l=v.useCallback(u=>{o.current=u,u.length>0&&a.dispatchToViews(u)},[a.dispatchToViews]);v.useEffect(()=>{if(!e)return;const u=d=>{!(d.metaKey||d.ctrlKey)||d.shiftKey||d.key.toLowerCase()!=="f"||r.current?.contains(document.activeElement)&&(d.preventDefault(),d.stopPropagation(),a.handleOpenSearch())};return window.addEventListener("keydown",u,!0),()=>window.removeEventListener("keydown",u,!0)},[e,a.handleOpenSearch]);const c=a.searchOpen?f.jsx(cN,{ref:a.searchBarRef,variant:"floating",query:a.searchQuery,onQueryChange:a.setSearchQuery,options:a.searchOptions,onOptionsChange:a.setSearchOptions,placeholder:n?"Find in preview...":"Find in file...",matchInfo:a.matchInfo,onNext:a.handleNext,onPrevious:a.handlePrevious,onClose:a.handleCloseSearch}):void 0;return{containerRef:r,setViews:l,searchBar:c}}const cXn={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",mts:"typescript",cts:"typescript",mjs:"javascript",cjs:"javascript"};function f8e(t){const e=t.split(".").pop()?.toLowerCase();return e?cXn[e]:void 0}function IZe(t,e,n,r){const{settings:o}=Qh(),i=Gx(t),[s,a]=v.useState(null),l=HWe(t),c=v.useMemo(()=>{if(!o.enableLSP||l||n)return null;const d=f8e(e);return d?XCn(d):null},[e,n,o.enableLSP,l]),u=v.useMemo(()=>c?cAn(t,c):null,[t,c]);return v.useEffect(()=>{if(a(null),!u||!i)return;let d=!1;const h=f8e(e),p=r(u,K3e(i),K3e(i,e),h&&uAn(h)||"",t);return p.then(g=>{d||a(g)}).catch(g=>console.warn("[leaf] LSP extension creation failed:",g)),()=>{d=!0,p.then(()=>tAn(u),()=>{})}},[u,i,e,t,r]),s}function DZe(t,e,n,r){const[o,i]=v.useState(t.isActive);v.useEffect(()=>{const s=t.onDidActiveChange(a=>i(a.isActive));return()=>s.dispose()},[t]),v.useEffect(()=>{!r||!o||!e||!n||VMn(e,{currentFile:n})},[r,o,e,n])}function uXn(t){const{worktreeId:e}=Wh(),n=t.params.filePath??"";return ZWe(n)?f.jsx(vYn,{worktreeId:e??t.params.worktreeId??"",filePath:n}):f.jsx(dXn,{...t})}function dXn({params:t,api:e}){const{visible:n,worktreeId:r}=Wh(),o=r??t.worktreeId??"",i=t.filePath??"",[s,a]=v.useState(()=>$O(o,i)?.viewMode),l=Uee(i)==="markdown"&&s!=="source",{containerRef:c,setViews:u,searchBar:d}=LZe(o,n,l);DZe(e,o,i,n);const h=Gs(),p=t.untitled===!0||$Qn(i),g=p?!1:t.external??i.startsWith("/"),_=IZe(o,i,g||p,aAn),x=HWe(o),y=Gx(o),[k,O]=v.useState(!1),[C,A]=v.useState(()=>$O(o,i)?.language),[E,M]=v.useState(null),[P,L]=v.useState(0),[D,I]=v.useState(!1),z=v.useRef(null),Y=v.useRef(!1),Q=v.useCallback(()=>{H_(o,i,!1);const me=H.current;if(!me){L(Be=>Be+1);return}const le=Eg(o,i);Y.current=!0;try{if(le===null)L(Be=>Be+1);else{const Be=Math.min(me.state.selection.main.head,le.length);me.dispatch({changes:{from:0,to:me.state.doc.length,insert:le},selection:{anchor:Be}})}}finally{Y.current=!1}},[o,i]);v.useEffect(()=>{if(!o||!i)return;const me=B_(o,i);return bA(le=>{le.key===me&&(Mne(o,i)?I(!0):Q())})},[o,i,Q]);const H=v.useRef(null),N=v.useCallback(me=>{if(H.current=me,u(me?[me]:[]),V.current?.(),V.current=null,me){const le=me.scrollDOM;let Be=0;const Xe=()=>{Be||(Be=requestAnimationFrame(()=>{Be=0,K.current()}))};le.addEventListener("scroll",Xe,{passive:!0});let ot=0;const Qe=bt=>{const ve=$O(o,i)?.scrollTop;!ve||le.clientHeight===0||(le.scrollTop=ve,Math.abs(le.scrollTop-ve)>1&&bt<30&&(ot=requestAnimationFrame(()=>Qe(bt+1))))},lt=new ResizeObserver(()=>{le.clientHeight>0&&le.scrollTop===0&&(cancelAnimationFrame(ot),Qe(0))});lt.observe(le),V.current=()=>{le.removeEventListener("scroll",Xe),cancelAnimationFrame(Be),lt.disconnect(),cancelAnimationFrame(ot)}}},[u,o,i]),V=v.useRef(null),G=v.useCallback(()=>{const me=H.current;if(!(!me||me.scrollDOM.clientHeight===0))try{const{selection:le,scrollTop:Be}=lIt(me);Cv(o,i,{selection:le,scrollTop:Be})}catch{}},[o,i]),K=v.useRef(G);K.current=G,v.useEffect(()=>{const me=()=>K.current();return window.addEventListener("pagehide",me),()=>{window.removeEventListener("pagehide",me),!BW.delete(HW(o,i))&&K.current()}},[o,i]);const q=h.pickSaveFile,Z=v.useCallback(async me=>{if(!q)return null;const le=await q({content:me,defaultPath:y??void 0});if(!le)return null;const Be=le.replace(/\\/g,"/"),Xe=y!=null?GQn(y,Be):null,ot=Xe===null,Qe=Xe??Be,lt=Io(o);return FW(o,i),lt?.openFile(Qe,{external:ot,preview:!1}),lt?.onClose(`file:${i}`,"file"),window.dispatchEvent(new CustomEvent("band:dirty-change")),Be},[q,y,o,i]),U=!p&&!g,B=Xx(o,{enabled:U&&n,refetchInterval:n?15e3:!1}),ee=U&&!!RFe(B.data,i),te=B.refetch,se=v.useRef(!1),ae=E?.isDirty??!1;if(v.useEffect(()=>{se.current&&!ae&&U&&te(),se.current=ae},[ae,U,te]),NZe(e.id,o&&i?()=>f.jsxs("div",{className:"flex items-center gap-0.5",children:[(E?.showMarkdownToggle||E?.showVisualToggle)&&f.jsxs(f.Fragment,{children:[f.jsx("button",{type:"button",onClick:()=>{a("preview"),Cv(o,i,{viewMode:"preview"})},title:E?.showVisualToggle?"Visual":"Preview","data-testid":"center-file-leaf__view--preview",className:`inline-flex size-7 items-center justify-center rounded transition-colors hover:bg-accent ${(E?.showVisualToggle?s==="preview":s!=="source")?"bg-accent text-foreground":"text-muted-foreground"}`,children:f.jsx(pZ,{className:"size-3.5"})}),E?.showVisualToggle&&s==="preview"&&f.jsx("button",{type:"button",onClick:()=>O(me=>!me),"aria-pressed":k,title:"Edit text","data-testid":"center-file-leaf__html-edit",className:`inline-flex size-7 items-center justify-center rounded transition-colors hover:bg-accent ${k?"bg-accent text-foreground":"text-muted-foreground"}`,children:f.jsx(y4,{className:"size-3.5"})}),f.jsx("button",{type:"button",onClick:()=>{a("source"),Cv(o,i,{viewMode:"source"})},title:"Source","data-testid":"center-file-leaf__view--source",className:`inline-flex size-7 items-center justify-center rounded transition-colors hover:bg-accent ${(E?.showVisualToggle?s!=="preview":s==="source")?"bg-accent text-foreground":"text-muted-foreground"}`,children:f.jsx(Q7e,{className:"size-3.5"})}),E?.showMarkdownToggle&&s!=="source"&&f.jsx(sYn,{})]}),On&&!g&&!p&&BHe(i)&&f.jsx("button",{type:"button",onClick:()=>zOn({worktreeId:o,path:i}),title:"Preview in a browser tab","data-testid":"center-file-leaf__html-preview",className:"inline-flex size-7 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:f.jsx(xu,{className:"size-3.5"})}),E?.canSave&&E.isDirty&&f.jsx("button",{type:"button",onClick:()=>E.save(),disabled:E.saving,title:"Save (Cmd+S)","data-testid":"center-file-leaf__save",className:"inline-flex size-7 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-50",children:E.saving?f.jsx(Fo,{className:"size-3.5 animate-spin"}):f.jsx(eve,{className:"size-3.5"})}),ee&&f.jsx("button",{type:"button",onClick:()=>Io(o)?.openDiff(i,{preview:!1}),title:"View changes","data-testid":"center-file-leaf__view-diff",className:"inline-flex size-7 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:f.jsx(B2,{className:"size-3.5"})})]}):null,[E,s,k,ee,o,i]),!t.worktreeId||!t.filePath)return null;const he=t.worktreeId,fe=t.filePath,be=$O(he,fe);return f.jsxs("div",{ref:c,tabIndex:-1,"data-band-leaf-root":"",className:"flex h-full w-full flex-col overflow-hidden outline-none","data-testid":`center-file-leaf__visible-${n?"true":"false"}`,children:[D&&f.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border bg-muted px-3 py-1.5 text-xs","data-testid":"center-file-leaf__remote-edit",children:[f.jsx("span",{className:"min-w-0 flex-1",children:"Another device changed the unsaved edits to this file."}),f.jsx(Ce,{size:"sm",variant:"outline","data-testid":"center-file-leaf__remote-edit-load",onClick:()=>{I(!1),Q(),window.dispatchEvent(new CustomEvent("band:dirty-change"))},children:"Load theirs"}),f.jsx(Ce,{size:"sm",variant:"ghost","data-testid":"center-file-leaf__remote-edit-keep",onClick:()=>{I(!1),Tg(he,fe,z.current),window.dispatchEvent(new CustomEvent("band:dirty-change"))},children:"Keep mine"})]}),f.jsx(KOn,{worktreeId:he,filePath:fe,line:t.line,column:t.column,editable:!0,external:g,untitled:p,lspExtension:_,watchFileChanges:!x,onSaveAs:p&&q?Z:void 0,hideTitleBar:!0,onActionsChange:M,onLoadError:me=>{/ENOENT|no such file|not found/i.test(me.message)&&(FW(he,fe),Io(he)?.onClose(`file:${fe}`,"file"))},renderMarkdownBlock:dYn,htmlVisual:!0,htmlEditing:k,onEditorView:N,overlay:d,savedSelection:be?.selection,savedScrollTop:be?.scrollTop,initialEditedContent:Eg(he,fe),onEditedContentChange:me=>{Y.current||(I(!1),z.current=me,H_(he,fe,me!==null),Tg(he,fe,me))},viewMode:s,onViewModeChange:me=>{a(me),Cv(he,fe,{viewMode:me})},languageOverride:C,onLanguageOverrideChange:me=>{A(me??void 0),Cv(he,fe,{language:me})}},P)]})}const h8e=99999;function fXn(t){return t.params.allOf?f.jsx(mXn,{...t,section:t.params.allOf}):f.jsx(pXn,{...t})}function hXn(t){return t==="unstaged"||t==="staged"||t==="untracked"?t:null}function pXn({params:t,api:e,containerApi:n}){const r=F_.has(n.id),{visible:o}=Wh(),{worktreeId:i,filePath:s,commit:a}=t,l=Rn(),{containerRef:c,setViews:u,searchBar:d}=LZe(i??"",o),h=Xx(i??"",{enabled:!!s&&!a,refetchInterval:o?15e3:!1}),p=RFe(h.data,s),_=!!t.section&&!!h.data?.[t.section].some(G=>G.path===s)||!p?t.section:p.section,x=(_===t.section?t.oldPath:void 0)??(_?h.data?.[_].find(G=>G.path===s)?.oldPath:void 0),y=_==="branch"?h.data?.mergeBase??void 0:void 0;DZe(e,i??"",a?"":s??"",o);const k=IZe(i??"",s??"",!!a||_==="staged"||_==="branch",lAn),[O,C]=v.useState(()=>xOn()),[A,E]=v.useState(!1),M=v.useRef(null),[P,L]=v.useState([]),D=v.useCallback(G=>{u(G),L(G)},[u]),I=v.useCallback(G=>{C(G),yOn(G)},[]),z=It({queryKey:["diffLeafFile",i,s,_,y,x],queryFn:()=>Se.worktree.getFileDiff.query({worktreeId:i,filePath:s,section:_??"unstaged",mergeBase:y,oldPath:x,contextLines:h8e}),enabled:!!i&&!!s&&!!_&&(_!=="branch"||!!y)&&!a,refetchInterval:See(o?1e4:!1)}),Y=It({queryKey:["diffLeafCommitFile",i,a,s],queryFn:()=>Se.worktree.getCommitFileDiff.query({worktreeId:i,sha:a??"",filePath:s,contextLines:h8e}),enabled:!!i&&!!s&&!!a,staleTime:Number.POSITIVE_INFINITY}),Q=a?null:hXn(_),H=Q!==null;if(NZe(e.id,i&&s?()=>f.jsxs("div",{className:"flex items-center gap-0.5",children:[!r&&f.jsxs(f.Fragment,{children:[f.jsx("button",{type:"button",onClick:()=>I("unified"),"aria-pressed":O==="unified",title:"Unified view","data-testid":"center-diff-leaf__view--unified",className:`inline-flex size-7 items-center justify-center rounded transition-colors hover:bg-accent ${O==="unified"?"bg-accent text-foreground":"text-muted-foreground"}`,children:f.jsx(Fit,{className:"size-3.5"})}),f.jsx("button",{type:"button",onClick:()=>I("split"),"aria-pressed":O==="split",title:"Side-by-side view","data-testid":"center-diff-leaf__view--split",className:`inline-flex size-7 items-center justify-center rounded transition-colors hover:bg-accent ${O==="split"?"bg-accent text-foreground":"text-muted-foreground"}`,children:f.jsx(U7e,{className:"size-3.5"})})]}),!a&&f.jsx("button",{type:"button",onClick:()=>Io(i)?.openFile(s,{preview:!1}),title:"Open file for editing","data-testid":"center-diff-leaf__open-file",className:"inline-flex size-7 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:f.jsx(Lit,{className:"size-3.5"})}),H&&f.jsx("button",{type:"button",onClick:()=>E(!0),title:"Revert file","data-testid":"center-diff-leaf__revert",className:"inline-flex size-7 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:f.jsx(kit,{className:"size-3.5"})})]}):null,[O,i,s,H,a]),!i||!s)return null;const N=a?Y.data?.diff:z.data?.diff,V=a?Y.isLoading:h.isLoading||z.isLoading;return f.jsxs("div",{ref:c,className:"flex h-full w-full flex-col overflow-hidden outline-none",tabIndex:-1,"data-band-leaf-root":"","data-testid":`center-diff-leaf__visible-${o?"true":"false"}`,children:[f.jsxs("div",{className:"relative min-h-0 flex-1",children:[d,f.jsx("div",{ref:M,tabIndex:-1,"data-band-leaf-focus":"","data-testid":"center-diff-leaf__scroller",className:`h-full overflow-auto outline-none ${N?"pr-3 [scrollbar-width:none]":""}`,children:N?f.jsx(IHe,{hunks:N,filename:s,viewMode:r?"unified":O,onEditorViews:D,lspNavigation:k}):f.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:V?"Loading diff…":a&&Y.isError?Y.error instanceof Error?Y.error.message:"Failed to load the diff":"No changes"})}),N&&f.jsx(POn,{views:P,scrollerRef:M})]}),f.jsx(nr,{open:A,onOpenChange:E,children:f.jsxs(rr,{children:[f.jsxs(hr,{children:[f.jsx(or,{children:"Revert file"}),f.jsxs(Nr,{children:["Discard the changes to ",f.jsx("span",{className:"font-mono",children:R0(s)}),"?"," ",Q&&YFe(Q)]})]}),f.jsxs(ii,{children:[f.jsx(Ce,{variant:"ghost",onClick:()=>E(!1),children:"Cancel"}),f.jsx(Ce,{variant:"destructive","data-testid":"center-diff-leaf__revert-confirm",onClick:()=>{Q&&Se.worktree.discardChanges.mutate({worktreeId:i,section:Q,paths:Q==="staged"&&x?[s,x]:[s]}).then(()=>{E(!1),z.refetch(),NFe(l,i)}).catch(G=>console.error("[DiffLeaf] revert failed:",G))},children:"Revert"})]})]})})]})}function mXn({params:t,section:e}){const{worktreeId:n}=t,{visible:r}=Wh(),o=Xx(n,{refetchInterval:r?15e3:!1}),i=o.data?.[e]??[],s=o.data?.mergeBase??void 0;return f.jsx("div",{className:"h-full w-full overflow-auto outline-none",tabIndex:-1,"data-band-leaf-focus":"","data-testid":`center-section-diffs--${e}`,children:i.length===0?f.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:o.isLoading?"Loading diff…":"No changes"}):i.map(a=>f.jsx(gXn,{worktreeId:n,section:e,entry:a,mergeBase:s},a.path))})}function gXn({worktreeId:t,section:e,entry:n,mergeBase:r}){const o=v.useRef(null),[i,s]=v.useState(!1),[a,l]=v.useState(!1);v.useEffect(()=>{const d=o.current;if(!d||i)return;const h=new IntersectionObserver(p=>{p.some(g=>g.isIntersecting)&&s(!0)},{rootMargin:"600px 0px"});return h.observe(d),()=>h.disconnect()},[i]);const c=It({queryKey:["sectionDiffFile",t,e,n.path,n.oldPath,r,n.additions,n.deletions],queryFn:()=>Se.worktree.getFileDiff.query({worktreeId:t,filePath:n.path,section:e,mergeBase:e==="branch"?r:void 0,oldPath:n.oldPath}),enabled:i&&(e!=="branch"||!!r)}),u=a?bo:Pi;return f.jsxs("div",{ref:o,className:"border-b border-border","data-testid":`center-section-diffs__file--${n.path}`,children:[f.jsxs("div",{className:"sticky top-0 z-10 flex h-8 items-center gap-1.5 border-b border-border bg-background px-2 text-xs",children:[f.jsxs("button",{type:"button",onClick:()=>l(d=>!d),"aria-expanded":!a,className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[f.jsx(u,{className:"size-3.5 shrink-0 text-muted-foreground"}),f.jsx("span",{className:"truncate font-medium",title:n.path,children:n.oldPath?`${n.oldPath} → ${n.path}`:n.path}),!!n.additions&&f.jsxs("span",{className:"shrink-0 text-success",children:["+",n.additions]}),!!n.deletions&&f.jsxs("span",{className:"shrink-0 text-danger",children:["-",n.deletions]})]}),f.jsx("button",{type:"button",title:"Open diff","data-testid":"center-section-diffs__open",onClick:()=>Io(t)?.openDiff(n.path,{preview:!1,section:e,oldPath:n.oldPath}),className:"inline-flex size-6 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground",children:f.jsx(B2,{className:"size-3.5"})})]}),!a&&(c.data?.diff?f.jsx(IHe,{hunks:c.data.diff,filename:n.path,viewMode:"unified"}):f.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:c.data?"No textual changes":"Loading diff…"}))]})}const xh=new Map,F_=new Set;function zZe(t){const e=t.api.component,n=DYn[e],r=zYn[e],[o,i]=v.useState(t.api.title??""),[s,a]=v.useState(t.params?.badge);v.useEffect(()=>{const u=t.api.onDidTitleChange(()=>i(t.api.title??""));return()=>u.dispose()},[t.api]),v.useEffect(()=>{const u=t.api.onDidParametersChange(()=>{a(t.api.getParameters().badge)});return()=>u.dispose()},[t.api]);const l=s!=null&&s>0,c=f.jsxs("div",{className:b4,"data-testid":`center-tab--${e}`,children:[n?f.jsx(n,{className:"size-4 shrink-0"}):f.jsx("span",{className:"inline-block size-4 shrink-0","aria-hidden":!0}),f.jsx("span",{className:v4,children:o}),l&&f.jsx("span",{className:"inline-flex h-5 min-w-5 shrink-0 items-center justify-center rounded-full bg-info-bg px-1.5 text-xs font-medium text-info",children:s})]});return r?f.jsxs(Or,{children:[f.jsx(Sr,{asChild:!0,children:c}),f.jsxs(Cr,{children:[o," (",r,")"]})]}):c}const vXn=new Set(["claude-code","codex","opencode"]);function bXn(t){const e=t.params.chatId,n=t.params.worktreeId,r=Ene(e),[o,i]=v.useState(r.title??t.api.title??"Chat"),[s,a]=v.useState(r.agentType),[l,c]=v.useState(void 0),u=dy(t.api),d=AZe(n,e);v.useEffect(()=>{const M=t.api.onDidTitleChange(()=>{const P=t.api.title??"Chat";i(P),s8e(e,{title:P})});return()=>M.dispose()},[t.api,e]);const h=v.useRef(!0);v.useEffect(()=>()=>{h.current=!1},[]);const p=v.useRef([]),g=v.useRef(void 0),_=v.useCallback(M=>{if(!h.current)return;c(M?.activeSessionId??void 0);const P=M?.agent??g.current??"",L=p.current.find(D=>D.id===P);L&&(a(L.type),s8e(e,{agentType:L.type}))},[e]),x=v.useCallback(()=>{!e||!n||Promise.all([YYn(),Se.chats.get.query({chatId:e}).catch(()=>({chat:null}))]).then(([M,P])=>{if(!h.current)return;const L=M?.codingAgents;p.current=Array.isArray(L)?L:[],g.current=M?.defaultCodingAgent,_(P.chat)}).catch(()=>{})},[e,n,_]),y=v.useCallback(()=>{e&&Se.chats.get.query({chatId:e}).then(M=>_(M.chat)).catch(()=>{})},[e,_]);v.useEffect(()=>{x()},[x]);const k=!!l&&!!s&&vXn.has(s),O=v.useCallback(()=>{Se.chats.continueInTerminal.mutate({chatId:e}).then(()=>$1.onActivateTerminalPanel(n)).catch(M=>console.error("[ChatTab] continue in terminal failed:",M))},[e,n]),C=v.useCallback(()=>{l&&Vs(l)},[l]),A=t.containerApi,E=v.useCallback(M=>{M.stopPropagation(),xh.get(A.id)?.current?.onClose(e,"chat")},[A,e]);return f.jsxs(J0,{onOpenChange:M=>M&&y(),children:[f.jsx(e1,{asChild:!0,children:f.jsxs("div",{className:b4,"data-testid":`center-chat-tab--${e}`,children:[f.jsxs("div",{className:Cg,children:[f.jsx("span",{className:"inline-flex size-3.5 shrink-0 items-center justify-center transition-opacity duration-150",style:{opacity:s?1:0},children:s&&f.jsx(D3,{type:s,className:"size-3.5"})}),f.jsx("span",{className:v4,title:o,children:o})]}),f.jsx(Ag,{isActive:u,indicator:d&&f.jsx(Ane,{status:d,testId:`center-chat-tab__status--${e}`}),onClose:E,closeTitle:"Close tab"})]})}),f.jsxs(t1,{"data-testid":"center-chat-tab__context-menu",children:[f.jsxs(Qn,{disabled:!k,onClick:O,"data-testid":"center-chat-tab__context-menu-item--continue-in-terminal",children:[f.jsx(_M,{className:"size-4"}),"Continue in terminal"]}),f.jsxs(Qn,{disabled:!l,onClick:C,"data-testid":"center-chat-tab__context-menu-item--copy-session-id",children:[f.jsx(Kf,{className:"size-4"}),"Copy session ID"]})]})]})}function _Xn(t){const[e,n]=v.useState(t.api.title??"Terminal"),r=t.params.terminalId,o=t.containerApi,i=dy(t.api),s=EZe(t.params.worktreeId,r);v.useEffect(()=>{const c=t.api.onDidTitleChange(()=>n(t.api.title??"Terminal"));return()=>c.dispose()},[t.api]);const a=v.useCallback(c=>{c.stopPropagation(),xh.get(o.id)?.current?.onClose(r,"term")},[o,r]),l=v.useCallback(()=>{Vs(r)},[r]);return f.jsxs(J0,{children:[f.jsx(e1,{asChild:!0,children:f.jsxs("div",{className:b4,"data-testid":`center-term-tab--${r}`,children:[f.jsxs("div",{className:Cg,children:[f.jsx(_M,{className:"size-3.5 shrink-0 text-muted-foreground"}),f.jsx("span",{className:v4,title:e,children:e})]}),f.jsx(Ag,{isActive:i,indicator:s&&f.jsx(Ane,{status:s,testId:`center-term-tab__status--${r}`}),onClose:a,closeTitle:"Close terminal"})]})}),f.jsx(t1,{"data-testid":"center-term-tab__context-menu",children:f.jsxs(Qn,{onClick:l,"data-testid":"center-term-tab__context-menu-item--copy-terminal-id",children:[f.jsx(Kf,{className:"size-4"}),"Copy terminal ID"]})})]})}function xXn(t){const[e,n]=v.useState(t.api.title??"New Tab"),[r,o]=v.useState(!1),i=t.params.browserId,s=t.containerApi,a=dy(t.api),l=zUn(i),c=v.useRef(l);l!==c.current&&(c.current=l,r&&o(!1)),v.useEffect(()=>{const h=t.api.onDidTitleChange(()=>n(t.api.title??"New Tab"));return()=>h.dispose()},[t.api]);const u=v.useCallback(h=>{h.stopPropagation(),xh.get(s.id)?.current?.onClose(i,"browser")},[s,i]),d=l&&!r;return f.jsxs("div",{className:b4,"data-testid":`center-browser-tab--${i}`,children:[f.jsxs("div",{className:Cg,children:[d?f.jsx("img",{src:l,alt:"",className:"size-3.5 shrink-0",onError:()=>o(!0)}):f.jsx(xu,{className:"size-3.5 shrink-0 text-muted-foreground"}),f.jsx("span",{className:v4,title:e,children:e})]}),f.jsx(Ag,{isActive:a,onClose:u,closeTitle:"Close tab"})]})}function $Ze({worktreeId:t,filePath:e,testidPrefix:n,children:r}){const o=Gx(t),s=e.startsWith("/")?e:o?`${o.replace(/\/+$/,"")}/${e}`:null;return f.jsxs(J0,{children:[f.jsx(e1,{asChild:!0,children:r}),f.jsxs(t1,{"data-testid":`${n}__context-menu`,children:[f.jsxs(Qn,{onClick:()=>{Vs(e)},"data-testid":`${n}__context-menu-item--copy-relative-path`,children:[f.jsx(Kf,{className:"size-4"}),"Copy relative path"]}),f.jsxs(Qn,{disabled:!s,onClick:()=>s&&void Vs(s),"data-testid":`${n}__context-menu-item--copy-absolute-path`,children:[f.jsx(Kf,{className:"size-4"}),"Copy absolute path"]})]})]})}function yXn(t){const{worktreeId:e,filePath:n}=t.params,r=t.containerApi,o=dy(t.api),i=MZe(t.api,t.params.preview),s=R0(n),a=U2(s),[l,c]=v.useState(()=>KT(e,n)),u=t.api,d=t.params;v.useEffect(()=>{const p=()=>{const g=KT(e,n);c(g),g&&RW(u,d)};return window.addEventListener("band:dirty-change",p),()=>window.removeEventListener("band:dirty-change",p)},[e,n,u,d]);const h=v.useCallback(p=>{p.stopPropagation(),xh.get(r.id)?.current?.onClose(`file:${n}`,"file")},[r,n]);return f.jsx($Ze,{worktreeId:e,filePath:n,testidPrefix:`center-file-tab--${n}`,children:f.jsxs("div",{className:b4,"data-testid":`center-file-tab--${n}`,onDoubleClick:()=>RW(u,d),children:[f.jsxs("div",{className:Cg,children:[f.jsx(a,{className:"size-3.5 shrink-0 text-muted-foreground"}),f.jsx("span",{className:`${v4}${i?" italic":""}`,title:n,children:s})]}),f.jsx(Ag,{isActive:o,indicator:l&&f.jsx("span",{"aria-hidden":!0,"data-testid":`center-file-tab__dirty--${n}`,className:"size-2 rounded-full bg-foreground/70"}),onClose:h,closeTitle:"Close file",closeTestId:`center-file-tab__close--${n}`})]})})}function wXn(t){const{worktreeId:e,filePath:n,commit:r,section:o,allOf:i}=t.params,s=t.containerApi,a=t.api.id,l=dy(t.api),c=MZe(t.api,t.params.preview),u=r?`${R0(n)} @ ${r.slice(0,7)}`:o==="staged"?`${R0(n)} (Staged)`:o==="branch"?`${R0(n)} (Committed)`:R0(n),d=v.useCallback(h=>{h.stopPropagation(),xh.get(s.id)?.current?.onClose(a,"diff")},[s,a]);return i?f.jsxs("div",{className:b4,"data-testid":`center-section-diffs-tab--${i}`,children:[f.jsxs("div",{className:Cg,children:[f.jsx(B2,{className:"size-3.5 shrink-0 text-muted-foreground"}),f.jsx("span",{className:v4,children:gN[i]})]}),f.jsx(Ag,{isActive:l,onClose:d,closeTitle:"Close diff"})]}):f.jsx($Ze,{worktreeId:e,filePath:n,testidPrefix:`center-diff-tab--${n}`,children:f.jsxs("div",{className:b4,"data-testid":`center-diff-tab--${n}`,"data-commit":r,onDoubleClick:()=>RW(t.api,t.params),children:[f.jsxs("div",{className:Cg,children:[f.jsx(B2,{className:"size-3.5 shrink-0 text-muted-foreground"}),f.jsx("span",{className:`${v4}${c?" italic":""}`,title:n,children:u})]}),f.jsx(Ag,{isActive:l,onClose:d,closeTitle:"Close diff"})]})})}const qW={top:!1,left:!1,right:!1},p8e=new WeakMap;function kXn(t){const e=p8e.get(t.group);if(e)return e;const n=t.group,r=t.containerApi,o=new Set;let i=null;const s=()=>{const l=n.element,c=l.closest("[data-layout-root]");if(!c)return;const u=l.getBoundingClientRect(),d=c.getBoundingClientRect(),h={top:u.top-d.top<2,left:u.left-d.left<2,right:d.right-u.right<2};l.toggleAttribute("data-band-top-row",h.top);const p=a.edges;if(!(p.top===h.top&&p.left===h.left&&p.right===h.right)){a.edges=h;for(const g of o)g()}},a={edges:qW,subscribe(l){if(o.add(l),!i){const c=n.element;s();const u=new ResizeObserver(s);u.observe(c);const d=r.onDidLayoutChange(s);i=()=>{u.disconnect(),d.dispose(),c.removeAttribute("data-band-top-row"),a.edges=qW}}return()=>{o.delete(l),o.size===0&&i&&(i(),i=null)}}};return p8e.set(n,a),a}const OXn=()=>()=>{};function BZe(t,e){const n=e?kXn(t):null;return v.useSyncExternalStore(n?n.subscribe:OXn,()=>n?.edges??qW)}const SXn=v.memo(function(e){const n=pN(),r=BZe(e,!!n);return!r.top||!r.left?null:f.jsx(TFe,{})}),CXn=v.memo(function(e){return f.jsx("div",{className:"flex h-full items-center px-0.5",children:f.jsx(EXn,{apiId:e.containerApi.id,groupId:e.group.id})})}),AXn=v.memo(function(e){const n=pN(),r=BZe(e,!!n),[,o]=v.useReducer(l=>l+1,0);v.useEffect(()=>{const l=e.containerApi.onDidActivePanelChange(()=>o()),c=u=>{const d=u.detail;e.group.panels.some(h=>h.id===d)&&o()};return window.addEventListener(IW,c),()=>{l.dispose(),window.removeEventListener(IW,c)}},[e.containerApi,e.group]);const i=e.group.activePanel?.id,s=i?sC.get(i):void 0;if(F_.has(e.containerApi.id))return s?f.jsx("div",{className:"flex h-full items-center px-1","data-testid":"worktree-center__toolbar",children:f.jsxs(Us,{children:[f.jsx(Ws,{asChild:!0,children:f.jsx("button",{type:"button","aria-label":"Tab actions","data-testid":"worktree-center__tab-actions-button",className:"inline-flex size-7 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:f.jsx(mM,{className:"size-3.5"})})}),f.jsx(Zs,{align:"end",className:"min-w-0 p-1",children:f.jsx("div",{className:"flex items-center gap-0.5",children:s()})})]})}):null;const a=e.group.activePanel?.params?.worktreeId;return f.jsxs("div",{className:"flex h-full items-center gap-0.5 px-1","data-testid":"worktree-center__toolbar",children:[s?.(),a&&f.jsx(LGn,{worktreeId:a}),r.top&&r.right&&n?.onToggleRightPanel&&!n.rightPanelVisible&&f.jsx(ste,{onToggle:n.onToggleRightPanel,visible:!1})]})});function EXn({apiId:t,groupId:e}){const n=(r,o)=>xh.get(t)?.current?.onAdd(r,e,o);return f.jsxs(Us,{children:[f.jsx(Ws,{asChild:!0,children:f.jsx("button",{type:"button","aria-label":"New tab",className:"inline-flex size-7 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground","data-testid":"worktree-center__new-tab-button",children:f.jsx(wl,{className:"size-4"})})}),f.jsxs(Zs,{align:"start",side:"bottom","data-testid":"worktree-center__new-tab-menu",children:[f.jsx(fYn,{onPick:r=>n("chat",r)}),f.jsxs(dr,{onClick:()=>n("term"),"data-testid":"worktree-center__new-tab--term",children:[f.jsx(xM,{className:"size-4"}),"New terminal",f.jsx(pF,{children:Vf("Cmd+T")})]}),On&&f.jsxs(dr,{onClick:()=>n("browser"),"data-testid":"worktree-center__new-tab--browser",children:[f.jsx(xu,{className:"size-4"}),"New browser",f.jsx(pF,{children:Vf("Cmd+Shift+B")})]})]})]})}const TXn={chat:nXn,term:oXn,browser:iXn,file:uXn,diff:fXn},MXn={chat:bXn,term:_Xn,browser:xXn,file:yXn,diff:wXn,icon:zZe},RH="flex w-56 items-center gap-3 rounded-md border border-border px-3 py-2 text-sm text-muted-foreground transition-colors hover:bg-accent hover:text-foreground";function l5(t,e,n,r){t.addPanel({id:n,component:"chat",tabComponent:"chat",title:"Chat",params:{worktreeId:e,chatId:n},position:r??fy(t)})}function of(t,e,n,r,o){t.addPanel({id:n,component:"term",tabComponent:"term",title:"Terminal",params:{worktreeId:e,terminalId:n,...r},position:o??fy(t),renderer:"always"})}function zp(t,e,n,r,o){t.addPanel({id:n,component:"browser",tabComponent:"browser",title:"New Tab",params:{worktreeId:e,browserId:n,...r?{initialUrl:r}:{}},position:o??fy(t),renderer:"always"})}function m8e(t,e,n,r){const o=pS();mS(o),zp(t,e,o,n,r),Se.browsers.create.mutate({worktreeId:e,id:o,url:n}).catch(i=>{console.error("[WorktreeCenter] browser create failed:",i)})}function g8e(t){return t.kind!=="browser"||On}function v8e(t,e,n){const r=VT(e),o=FWe(t);BQn(e,n&&r?IQn(r,o,g8e):LQn(o,r,g8e))}function PXn(t,e,n,r){const o=RZe(n.kind,n.id,e),i=o.allOf;t.addPanel({id:n.id,component:n.kind,tabComponent:n.kind,title:i?gN[i]:R0(o.filePath),params:o,position:r&&t.getPanel(r)?{referencePanel:r,direction:"within"}:fy(t),inactive:!0})}function VW(t){return t.kind==="file"||t.kind==="diff"}function HZe(t,e,n,r,o){let i=!1;for(const s of o){if(!VW(s))continue;const a=t.getPanel(s.id);!a||s.kind==="file"&&Mne(e,s.id.slice(5))||(t.removePanel(a),i=!0)}for(const s of r){if(!VW(s)||t.getPanel(s.id))continue;const a=n.tabs.findIndex(c=>c.id===s.id);let l=null;for(let c=a-1;c>=0;c--)if(t.getPanel(n.tabs[c].id)){l=n.tabs[c].id;break}PXn(t,e,s,l),i=!0}return i}function LH(t,e,n){const r=new Set(n.tabs.map(c=>c.id)),o=t.panels.map(c=>({id:c.id,kind:c.api.component})).filter(c=>VW(c)&&!r.has(c.id)),i=new Set(t.panels.map(c=>c.id));let s=HZe(t,e,n,n.tabs.filter(c=>!i.has(c.id)),o);const a=new Map(n.tabs.map((c,u)=>[c.id,u]));for(const c of t.groups){const u=[...c.panels].sort((p,g)=>(a.get(p.id)??Number.MAX_SAFE_INTEGER)-(a.get(g.id)??Number.MAX_SAFE_INTEGER)),d=c.activePanel;let h=!1;u.forEach((p,g)=>{if(c.panels.indexOf(p)!==g)try{p.api.moveTo({group:c,index:g,skipSetActive:!0}),h=!0}catch{}}),h&&(s=!0,d?.api.setActive())}const l=n.active?t.getPanel(n.active):void 0;return l&&(t.activePanel?.id!==l.id&&(s=!0),l.api.setActive()),s}function jXn(t,e){if(t.active!==e.active)return!0;const n=new Set(e.tabs.map(s=>s.id)),r=new Set(t.tabs.map(s=>s.id)),o=t.tabs.filter(s=>n.has(s.id)).map(s=>s.id),i=e.tabs.filter(s=>r.has(s.id)).map(s=>s.id);return o.join(`
1035
+ `).replace(CYe,"")}function Rie(m,b){return b=Nie(b),Nie(m)===b}function oo(m,b,w,S,j,R){switch(w){case"children":typeof S=="string"?b==="body"||b==="textarea"&&S===""||K4(m,S):(typeof S=="number"||typeof S=="bigint")&&b!=="body"&&K4(m,""+S);break;case"className":Zh(m,"class",S);break;case"tabIndex":Zh(m,"tabindex",S);break;case"dir":case"role":case"viewBox":case"width":case"height":Zh(m,w,S);break;case"style":Rne(m,S,R);break;case"data":if(b!=="object"){Zh(m,"data",S);break}case"src":case"href":if(S===""&&(b!=="a"||w!=="href")){m.removeAttribute(w);break}if(S==null||typeof S=="function"||typeof S=="symbol"||typeof S=="boolean"){m.removeAttribute(w);break}S=hy(""+S),m.setAttribute(w,S);break;case"action":case"formAction":if(typeof S=="function"){m.setAttribute(w,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof R=="function"&&(w==="formAction"?(b!=="input"&&oo(m,b,"name",j.name,j,null),oo(m,b,"formEncType",j.formEncType,j,null),oo(m,b,"formMethod",j.formMethod,j,null),oo(m,b,"formTarget",j.formTarget,j,null)):(oo(m,b,"encType",j.encType,j,null),oo(m,b,"method",j.method,j,null),oo(m,b,"target",j.target,j,null)));if(S==null||typeof S=="symbol"||typeof S=="boolean"){m.removeAttribute(w);break}S=hy(""+S),m.setAttribute(w,S);break;case"onClick":S!=null&&(m.onclick=Iu);break;case"onScroll":S!=null&&vr("scroll",m);break;case"onScrollEnd":S!=null&&vr("scrollend",m);break;case"dangerouslySetInnerHTML":if(S!=null){if(typeof S!="object"||!("__html"in S))throw Error(r(61));if(w=S.__html,w!=null){if(j.children!=null)throw Error(r(60));m.innerHTML=w}}break;case"multiple":m.multiple=S&&typeof S!="function"&&typeof S!="symbol";break;case"muted":m.muted=S&&typeof S!="function"&&typeof S!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(S==null||typeof S=="function"||typeof S=="boolean"||typeof S=="symbol"){m.removeAttribute("xlink:href");break}w=hy(""+S),m.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",w);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":S!=null&&typeof S!="function"&&typeof S!="symbol"?m.setAttribute(w,""+S):m.removeAttribute(w);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":S&&typeof S!="function"&&typeof S!="symbol"?m.setAttribute(w,""):m.removeAttribute(w);break;case"capture":case"download":S===!0?m.setAttribute(w,""):S!==!1&&S!=null&&typeof S!="function"&&typeof S!="symbol"?m.setAttribute(w,S):m.removeAttribute(w);break;case"cols":case"rows":case"size":case"span":S!=null&&typeof S!="function"&&typeof S!="symbol"&&!isNaN(S)&&1<=S?m.setAttribute(w,S):m.removeAttribute(w);break;case"rowSpan":case"start":S==null||typeof S=="function"||typeof S=="symbol"||isNaN(S)?m.removeAttribute(w):m.setAttribute(w,S);break;case"popover":vr("beforetoggle",m),vr("toggle",m),l0(m,"popover",S);break;case"xlinkActuate":c0(m,"http://www.w3.org/1999/xlink","xlink:actuate",S);break;case"xlinkArcrole":c0(m,"http://www.w3.org/1999/xlink","xlink:arcrole",S);break;case"xlinkRole":c0(m,"http://www.w3.org/1999/xlink","xlink:role",S);break;case"xlinkShow":c0(m,"http://www.w3.org/1999/xlink","xlink:show",S);break;case"xlinkTitle":c0(m,"http://www.w3.org/1999/xlink","xlink:title",S);break;case"xlinkType":c0(m,"http://www.w3.org/1999/xlink","xlink:type",S);break;case"xmlBase":c0(m,"http://www.w3.org/XML/1998/namespace","xml:base",S);break;case"xmlLang":c0(m,"http://www.w3.org/XML/1998/namespace","xml:lang",S);break;case"xmlSpace":c0(m,"http://www.w3.org/XML/1998/namespace","xml:space",S);break;case"is":l0(m,"is",S);break;case"innerText":case"textContent":break;default:(!(2<w.length)||w[0]!=="o"&&w[0]!=="O"||w[1]!=="n"&&w[1]!=="N")&&(w=eGe.get(w)||w,l0(m,w,S))}}function QL(m,b,w,S,j,R){switch(w){case"style":Rne(m,S,R);break;case"dangerouslySetInnerHTML":if(S!=null){if(typeof S!="object"||!("__html"in S))throw Error(r(61));if(w=S.__html,w!=null){if(j.children!=null)throw Error(r(60));m.innerHTML=w}}break;case"children":typeof S=="string"?K4(m,S):(typeof S=="number"||typeof S=="bigint")&&K4(m,""+S);break;case"onScroll":S!=null&&vr("scroll",m);break;case"onScrollEnd":S!=null&&vr("scrollend",m);break;case"onClick":S!=null&&(m.onclick=Iu);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Ri.hasOwnProperty(w))e:{if(w[0]==="o"&&w[1]==="n"&&(j=w.endsWith("Capture"),b=w.slice(2,j?w.length-7:void 0),R=m[qt]||null,R=R!=null?R[w]:null,typeof R=="function"&&m.removeEventListener(b,R,j),typeof S=="function")){typeof R!="function"&&R!==null&&(w in m?m[w]=null:m.hasAttribute(w)&&m.removeAttribute(w)),m.addEventListener(b,S,j);break e}w in m?m[w]=S:S===!0?m.setAttribute(w,""):l0(m,w,S)}}}function Ts(m,b,w){switch(b){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":vr("error",m),vr("load",m);var S=!1,j=!1,R;for(R in w)if(w.hasOwnProperty(R)){var J=w[R];if(J!=null)switch(R){case"src":S=!0;break;case"srcSet":j=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,b));default:oo(m,b,R,J,w,null)}}j&&oo(m,b,"srcSet",w.srcSet,w,null),S&&oo(m,b,"src",w.src,w,null);return;case"input":vr("invalid",m);var oe=R=J=j=null,Oe=null,qe=null;for(S in w)if(w.hasOwnProperty(S)){var nt=w[S];if(nt!=null)switch(S){case"name":j=nt;break;case"type":J=nt;break;case"checked":Oe=nt;break;case"defaultChecked":qe=nt;break;case"value":R=nt;break;case"defaultValue":oe=nt;break;case"children":case"dangerouslySetInnerHTML":if(nt!=null)throw Error(r(137,b));break;default:oo(m,b,S,nt,w,null)}}X4(m,R,oe,Oe,qe,J,j,!1);return;case"select":vr("invalid",m),S=J=R=null;for(j in w)if(w.hasOwnProperty(j)&&(oe=w[j],oe!=null))switch(j){case"value":R=oe;break;case"defaultValue":J=oe;break;case"multiple":S=oe;default:oo(m,b,j,oe,w,null)}b=R,w=J,m.multiple=!!S,b!=null?Ur(m,!!S,b,!1):w!=null&&Ur(m,!!S,w,!0);return;case"textarea":vr("invalid",m),R=j=S=null;for(J in w)if(w.hasOwnProperty(J)&&(oe=w[J],oe!=null))switch(J){case"value":S=oe;break;case"defaultValue":j=oe;break;case"children":R=oe;break;case"dangerouslySetInnerHTML":if(oe!=null)throw Error(r(91));break;default:oo(m,b,J,oe,w,null)}Yh(m,S,j,R);return;case"option":for(Oe in w)w.hasOwnProperty(Oe)&&(S=w[Oe],S!=null)&&(Oe==="selected"?m.selected=S&&typeof S!="function"&&typeof S!="symbol":oo(m,b,Oe,S,w,null));return;case"dialog":vr("beforetoggle",m),vr("toggle",m),vr("cancel",m),vr("close",m);break;case"iframe":case"object":vr("load",m);break;case"video":case"audio":for(S=0;S<c7.length;S++)vr(c7[S],m);break;case"image":vr("error",m),vr("load",m);break;case"details":vr("toggle",m);break;case"embed":case"source":case"link":vr("error",m),vr("load",m);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(qe in w)if(w.hasOwnProperty(qe)&&(S=w[qe],S!=null))switch(qe){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,b));default:oo(m,b,qe,S,w,null)}return;default:if(iR(b)){for(nt in w)w.hasOwnProperty(nt)&&(S=w[nt],S!==void 0&&QL(m,b,nt,S,w,void 0));return}}for(oe in w)w.hasOwnProperty(oe)&&(S=w[oe],S!=null&&oo(m,b,oe,S,w,null))}function AYe(m,b,w,S){switch(b){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var j=null,R=null,J=null,oe=null,Oe=null,qe=null,nt=null;for(Ge in w){var at=w[Ge];if(w.hasOwnProperty(Ge)&&at!=null)switch(Ge){case"checked":break;case"value":break;case"defaultValue":Oe=at;default:S.hasOwnProperty(Ge)||oo(m,b,Ge,null,S,at)}}for(var Ue in S){var Ge=S[Ue];if(at=w[Ue],S.hasOwnProperty(Ue)&&(Ge!=null||at!=null))switch(Ue){case"type":R=Ge;break;case"name":j=Ge;break;case"checked":qe=Ge;break;case"defaultChecked":nt=Ge;break;case"value":J=Ge;break;case"defaultValue":oe=Ge;break;case"children":case"dangerouslySetInnerHTML":if(Ge!=null)throw Error(r(137,b));break;default:Ge!==at&&oo(m,b,Ue,Ge,S,at)}}El(m,J,oe,Oe,qe,nt,R,j);return;case"select":Ge=J=oe=Ue=null;for(R in w)if(Oe=w[R],w.hasOwnProperty(R)&&Oe!=null)switch(R){case"value":break;case"multiple":Ge=Oe;default:S.hasOwnProperty(R)||oo(m,b,R,null,S,Oe)}for(j in S)if(R=S[j],Oe=w[j],S.hasOwnProperty(j)&&(R!=null||Oe!=null))switch(j){case"value":Ue=R;break;case"defaultValue":oe=R;break;case"multiple":J=R;default:R!==Oe&&oo(m,b,j,R,S,Oe)}b=oe,w=J,S=Ge,Ue!=null?Ur(m,!!w,Ue,!1):!!S!=!!w&&(b!=null?Ur(m,!!w,b,!0):Ur(m,!!w,w?[]:"",!1));return;case"textarea":Ge=Ue=null;for(oe in w)if(j=w[oe],w.hasOwnProperty(oe)&&j!=null&&!S.hasOwnProperty(oe))switch(oe){case"value":break;case"children":break;default:oo(m,b,oe,null,S,j)}for(J in S)if(j=S[J],R=w[J],S.hasOwnProperty(J)&&(j!=null||R!=null))switch(J){case"value":Ue=j;break;case"defaultValue":Ge=j;break;case"children":break;case"dangerouslySetInnerHTML":if(j!=null)throw Error(r(91));break;default:j!==R&&oo(m,b,J,j,S,R)}_o(m,Ue,Ge);return;case"option":for(var en in w)Ue=w[en],w.hasOwnProperty(en)&&Ue!=null&&!S.hasOwnProperty(en)&&(en==="selected"?m.selected=!1:oo(m,b,en,null,S,Ue));for(Oe in S)Ue=S[Oe],Ge=w[Oe],S.hasOwnProperty(Oe)&&Ue!==Ge&&(Ue!=null||Ge!=null)&&(Oe==="selected"?m.selected=Ue&&typeof Ue!="function"&&typeof Ue!="symbol":oo(m,b,Oe,Ue,S,Ge));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Pn in w)Ue=w[Pn],w.hasOwnProperty(Pn)&&Ue!=null&&!S.hasOwnProperty(Pn)&&oo(m,b,Pn,null,S,Ue);for(qe in S)if(Ue=S[qe],Ge=w[qe],S.hasOwnProperty(qe)&&Ue!==Ge&&(Ue!=null||Ge!=null))switch(qe){case"children":case"dangerouslySetInnerHTML":if(Ue!=null)throw Error(r(137,b));break;default:oo(m,b,qe,Ue,S,Ge)}return;default:if(iR(b)){for(var io in w)Ue=w[io],w.hasOwnProperty(io)&&Ue!==void 0&&!S.hasOwnProperty(io)&&QL(m,b,io,void 0,S,Ue);for(nt in S)Ue=S[nt],Ge=w[nt],!S.hasOwnProperty(nt)||Ue===Ge||Ue===void 0&&Ge===void 0||QL(m,b,nt,Ue,S,Ge);return}}for(var Re in w)Ue=w[Re],w.hasOwnProperty(Re)&&Ue!=null&&!S.hasOwnProperty(Re)&&oo(m,b,Re,null,S,Ue);for(at in S)Ue=S[at],Ge=w[at],!S.hasOwnProperty(at)||Ue===Ge||Ue==null&&Ge==null||oo(m,b,at,Ue,S,Ge)}function Lie(m){switch(m){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function EYe(){if(typeof performance.getEntriesByType=="function"){for(var m=0,b=0,w=performance.getEntriesByType("resource"),S=0;S<w.length;S++){var j=w[S],R=j.transferSize,J=j.initiatorType,oe=j.duration;if(R&&oe&&Lie(J)){for(J=0,oe=j.responseEnd,S+=1;S<w.length;S++){var Oe=w[S],qe=Oe.startTime;if(qe>oe)break;var nt=Oe.transferSize,at=Oe.initiatorType;nt&&Lie(at)&&(Oe=Oe.responseEnd,J+=nt*(Oe<oe?1:(oe-qe)/(Oe-qe)))}if(--S,b+=8*(R+J)/(j.duration/1e3),m++,10<m)break}}if(0<m)return b/m/1e6}return navigator.connection&&(m=navigator.connection.downlink,typeof m=="number")?m:5}var UL=null,WL=null;function lw(m){return m.nodeType===9?m:m.ownerDocument}function Iie(m){switch(m){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Die(m,b){if(m===0)switch(b){case"svg":return 1;case"math":return 2;default:return 0}return m===1&&b==="foreignObject"?0:m}function ZL(m,b){return m==="textarea"||m==="noscript"||typeof b.children=="string"||typeof b.children=="number"||typeof b.children=="bigint"||typeof b.dangerouslySetInnerHTML=="object"&&b.dangerouslySetInnerHTML!==null&&b.dangerouslySetInnerHTML.__html!=null}var GL=null;function TYe(){var m=window.event;return m&&m.type==="popstate"?m===GL?!1:(GL=m,!0):(GL=null,!1)}var zie=typeof setTimeout=="function"?setTimeout:void 0,MYe=typeof clearTimeout=="function"?clearTimeout:void 0,$ie=typeof Promise=="function"?Promise:void 0,PYe=typeof queueMicrotask=="function"?queueMicrotask:typeof $ie<"u"?function(m){return $ie.resolve(null).then(m).catch(jYe)}:zie;function jYe(m){setTimeout(function(){throw m})}function qd(m){return m==="head"}function Bie(m,b){var w=b,S=0;do{var j=w.nextSibling;if(m.removeChild(w),j&&j.nodeType===8)if(w=j.data,w==="/$"||w==="/&"){if(S===0){m.removeChild(j),Tm(b);return}S--}else if(w==="$"||w==="$?"||w==="$~"||w==="$!"||w==="&")S++;else if(w==="html")d7(m.ownerDocument.documentElement);else if(w==="head"){w=m.ownerDocument.head,d7(w);for(var R=w.firstChild;R;){var J=R.nextSibling,oe=R.nodeName;R[Zt]||oe==="SCRIPT"||oe==="STYLE"||oe==="LINK"&&R.rel.toLowerCase()==="stylesheet"||w.removeChild(R),R=J}}else w==="body"&&d7(m.ownerDocument.body);w=j}while(w);Tm(b)}function Hie(m,b){var w=m;m=0;do{var S=w.nextSibling;if(w.nodeType===1?b?(w._stashedDisplay=w.style.display,w.style.display="none"):(w.style.display=w._stashedDisplay||"",w.getAttribute("style")===""&&w.removeAttribute("style")):w.nodeType===3&&(b?(w._stashedText=w.nodeValue,w.nodeValue=""):w.nodeValue=w._stashedText||""),S&&S.nodeType===8)if(w=S.data,w==="/$"){if(m===0)break;m--}else w!=="$"&&w!=="$?"&&w!=="$~"&&w!=="$!"||m++;w=S}while(w)}function YL(m){var b=m.firstChild;for(b&&b.nodeType===10&&(b=b.nextSibling);b;){var w=b;switch(b=b.nextSibling,w.nodeName){case"HTML":case"HEAD":case"BODY":YL(w),Ae(w);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(w.rel.toLowerCase()==="stylesheet")continue}m.removeChild(w)}}function NYe(m,b,w,S){for(;m.nodeType===1;){var j=w;if(m.nodeName.toLowerCase()!==b.toLowerCase()){if(!S&&(m.nodeName!=="INPUT"||m.type!=="hidden"))break}else if(S){if(!m[Zt])switch(b){case"meta":if(!m.hasAttribute("itemprop"))break;return m;case"link":if(R=m.getAttribute("rel"),R==="stylesheet"&&m.hasAttribute("data-precedence"))break;if(R!==j.rel||m.getAttribute("href")!==(j.href==null||j.href===""?null:j.href)||m.getAttribute("crossorigin")!==(j.crossOrigin==null?null:j.crossOrigin)||m.getAttribute("title")!==(j.title==null?null:j.title))break;return m;case"style":if(m.hasAttribute("data-precedence"))break;return m;case"script":if(R=m.getAttribute("src"),(R!==(j.src==null?null:j.src)||m.getAttribute("type")!==(j.type==null?null:j.type)||m.getAttribute("crossorigin")!==(j.crossOrigin==null?null:j.crossOrigin))&&R&&m.hasAttribute("async")&&!m.hasAttribute("itemprop"))break;return m;default:return m}}else if(b==="input"&&m.type==="hidden"){var R=j.name==null?null:""+j.name;if(j.type==="hidden"&&m.getAttribute("name")===R)return m}else return m;if(m=mc(m.nextSibling),m===null)break}return null}function RYe(m,b,w){if(b==="")return null;for(;m.nodeType!==3;)if((m.nodeType!==1||m.nodeName!=="INPUT"||m.type!=="hidden")&&!w||(m=mc(m.nextSibling),m===null))return null;return m}function Fie(m,b){for(;m.nodeType!==8;)if((m.nodeType!==1||m.nodeName!=="INPUT"||m.type!=="hidden")&&!b||(m=mc(m.nextSibling),m===null))return null;return m}function XL(m){return m.data==="$?"||m.data==="$~"}function KL(m){return m.data==="$!"||m.data==="$?"&&m.ownerDocument.readyState!=="loading"}function LYe(m,b){var w=m.ownerDocument;if(m.data==="$~")m._reactRetry=b;else if(m.data!=="$?"||w.readyState!=="loading")b();else{var S=function(){b(),w.removeEventListener("DOMContentLoaded",S)};w.addEventListener("DOMContentLoaded",S),m._reactRetry=S}}function mc(m){for(;m!=null;m=m.nextSibling){var b=m.nodeType;if(b===1||b===3)break;if(b===8){if(b=m.data,b==="$"||b==="$!"||b==="$?"||b==="$~"||b==="&"||b==="F!"||b==="F")break;if(b==="/$"||b==="/&")return null}}return m}var JL=null;function qie(m){m=m.nextSibling;for(var b=0;m;){if(m.nodeType===8){var w=m.data;if(w==="/$"||w==="/&"){if(b===0)return mc(m.nextSibling);b--}else w!=="$"&&w!=="$!"&&w!=="$?"&&w!=="$~"&&w!=="&"||b++}m=m.nextSibling}return null}function Vie(m){m=m.previousSibling;for(var b=0;m;){if(m.nodeType===8){var w=m.data;if(w==="$"||w==="$!"||w==="$?"||w==="$~"||w==="&"){if(b===0)return m;b--}else w!=="/$"&&w!=="/&"||b++}m=m.previousSibling}return null}function Qie(m,b,w){switch(b=lw(w),m){case"html":if(m=b.documentElement,!m)throw Error(r(452));return m;case"head":if(m=b.head,!m)throw Error(r(453));return m;case"body":if(m=b.body,!m)throw Error(r(454));return m;default:throw Error(r(451))}}function d7(m){for(var b=m.attributes;b.length;)m.removeAttributeNode(b[0]);Ae(m)}var gc=new Map,Uie=new Set;function cw(m){return typeof m.getRootNode=="function"?m.getRootNode():m.nodeType===9?m:m.ownerDocument}var Ku=V.d;V.d={f:IYe,r:DYe,D:zYe,C:$Ye,L:BYe,m:HYe,X:qYe,S:FYe,M:VYe};function IYe(){var m=Ku.f(),b=ew();return m||b}function DYe(m){var b=zt(m);b!==null&&b.tag===5&&b.type==="form"?coe(b):Ku.r(m)}var Cm=typeof document>"u"?null:document;function Wie(m,b,w){var S=Cm;if(S&&typeof b=="string"&&b){var j=Zo(b);j='link[rel="'+m+'"][href="'+j+'"]',typeof w=="string"&&(j+='[crossorigin="'+w+'"]'),Uie.has(j)||(Uie.add(j),m={rel:m,crossOrigin:w,href:b},S.querySelector(j)===null&&(b=S.createElement("link"),Ts(b,"link",m),Yn(b),S.head.appendChild(b)))}}function zYe(m){Ku.D(m),Wie("dns-prefetch",m,null)}function $Ye(m,b){Ku.C(m,b),Wie("preconnect",m,b)}function BYe(m,b,w){Ku.L(m,b,w);var S=Cm;if(S&&m&&b){var j='link[rel="preload"][as="'+Zo(b)+'"]';b==="image"&&w&&w.imageSrcSet?(j+='[imagesrcset="'+Zo(w.imageSrcSet)+'"]',typeof w.imageSizes=="string"&&(j+='[imagesizes="'+Zo(w.imageSizes)+'"]')):j+='[href="'+Zo(m)+'"]';var R=j;switch(b){case"style":R=Am(m);break;case"script":R=Em(m)}gc.has(R)||(m=d({rel:"preload",href:b==="image"&&w&&w.imageSrcSet?void 0:m,as:b},w),gc.set(R,m),S.querySelector(j)!==null||b==="style"&&S.querySelector(f7(R))||b==="script"&&S.querySelector(h7(R))||(b=S.createElement("link"),Ts(b,"link",m),Yn(b),S.head.appendChild(b)))}}function HYe(m,b){Ku.m(m,b);var w=Cm;if(w&&m){var S=b&&typeof b.as=="string"?b.as:"script",j='link[rel="modulepreload"][as="'+Zo(S)+'"][href="'+Zo(m)+'"]',R=j;switch(S){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":R=Em(m)}if(!gc.has(R)&&(m=d({rel:"modulepreload",href:m},b),gc.set(R,m),w.querySelector(j)===null)){switch(S){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(w.querySelector(h7(R)))return}S=w.createElement("link"),Ts(S,"link",m),Yn(S),w.head.appendChild(S)}}}function FYe(m,b,w){Ku.S(m,b,w);var S=Cm;if(S&&m){var j=no(S).hoistableStyles,R=Am(m);b=b||"default";var J=j.get(R);if(!J){var oe={loading:0,preload:null};if(J=S.querySelector(f7(R)))oe.loading=5;else{m=d({rel:"stylesheet",href:m,"data-precedence":b},w),(w=gc.get(R))&&eI(m,w);var Oe=J=S.createElement("link");Yn(Oe),Ts(Oe,"link",m),Oe._p=new Promise(function(qe,nt){Oe.onload=qe,Oe.onerror=nt}),Oe.addEventListener("load",function(){oe.loading|=1}),Oe.addEventListener("error",function(){oe.loading|=2}),oe.loading|=4,uw(J,b,S)}J={type:"stylesheet",instance:J,count:1,state:oe},j.set(R,J)}}}function qYe(m,b){Ku.X(m,b);var w=Cm;if(w&&m){var S=no(w).hoistableScripts,j=Em(m),R=S.get(j);R||(R=w.querySelector(h7(j)),R||(m=d({src:m,async:!0},b),(b=gc.get(j))&&tI(m,b),R=w.createElement("script"),Yn(R),Ts(R,"link",m),w.head.appendChild(R)),R={type:"script",instance:R,count:1,state:null},S.set(j,R))}}function VYe(m,b){Ku.M(m,b);var w=Cm;if(w&&m){var S=no(w).hoistableScripts,j=Em(m),R=S.get(j);R||(R=w.querySelector(h7(j)),R||(m=d({src:m,async:!0,type:"module"},b),(b=gc.get(j))&&tI(m,b),R=w.createElement("script"),Yn(R),Ts(R,"link",m),w.head.appendChild(R)),R={type:"script",instance:R,count:1,state:null},S.set(j,R))}}function Zie(m,b,w,S){var j=(j=se.current)?cw(j):null;if(!j)throw Error(r(446));switch(m){case"meta":case"title":return null;case"style":return typeof w.precedence=="string"&&typeof w.href=="string"?(b=Am(w.href),w=no(j).hoistableStyles,S=w.get(b),S||(S={type:"style",instance:null,count:0,state:null},w.set(b,S)),S):{type:"void",instance:null,count:0,state:null};case"link":if(w.rel==="stylesheet"&&typeof w.href=="string"&&typeof w.precedence=="string"){m=Am(w.href);var R=no(j).hoistableStyles,J=R.get(m);if(J||(j=j.ownerDocument||j,J={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},R.set(m,J),(R=j.querySelector(f7(m)))&&!R._p&&(J.instance=R,J.state.loading=5),gc.has(m)||(w={rel:"preload",as:"style",href:w.href,crossOrigin:w.crossOrigin,integrity:w.integrity,media:w.media,hrefLang:w.hrefLang,referrerPolicy:w.referrerPolicy},gc.set(m,w),R||QYe(j,m,w,J.state))),b&&S===null)throw Error(r(528,""));return J}if(b&&S!==null)throw Error(r(529,""));return null;case"script":return b=w.async,w=w.src,typeof w=="string"&&b&&typeof b!="function"&&typeof b!="symbol"?(b=Em(w),w=no(j).hoistableScripts,S=w.get(b),S||(S={type:"script",instance:null,count:0,state:null},w.set(b,S)),S):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,m))}}function Am(m){return'href="'+Zo(m)+'"'}function f7(m){return'link[rel="stylesheet"]['+m+"]"}function Gie(m){return d({},m,{"data-precedence":m.precedence,precedence:null})}function QYe(m,b,w,S){m.querySelector('link[rel="preload"][as="style"]['+b+"]")?S.loading=1:(b=m.createElement("link"),S.preload=b,b.addEventListener("load",function(){return S.loading|=1}),b.addEventListener("error",function(){return S.loading|=2}),Ts(b,"link",w),Yn(b),m.head.appendChild(b))}function Em(m){return'[src="'+Zo(m)+'"]'}function h7(m){return"script[async]"+m}function Yie(m,b,w){if(b.count++,b.instance===null)switch(b.type){case"style":var S=m.querySelector('style[data-href~="'+Zo(w.href)+'"]');if(S)return b.instance=S,Yn(S),S;var j=d({},w,{"data-href":w.href,"data-precedence":w.precedence,href:null,precedence:null});return S=(m.ownerDocument||m).createElement("style"),Yn(S),Ts(S,"style",j),uw(S,w.precedence,m),b.instance=S;case"stylesheet":j=Am(w.href);var R=m.querySelector(f7(j));if(R)return b.state.loading|=4,b.instance=R,Yn(R),R;S=Gie(w),(j=gc.get(j))&&eI(S,j),R=(m.ownerDocument||m).createElement("link"),Yn(R);var J=R;return J._p=new Promise(function(oe,Oe){J.onload=oe,J.onerror=Oe}),Ts(R,"link",S),b.state.loading|=4,uw(R,w.precedence,m),b.instance=R;case"script":return R=Em(w.src),(j=m.querySelector(h7(R)))?(b.instance=j,Yn(j),j):(S=w,(j=gc.get(R))&&(S=d({},w),tI(S,j)),m=m.ownerDocument||m,j=m.createElement("script"),Yn(j),Ts(j,"link",S),m.head.appendChild(j),b.instance=j);case"void":return null;default:throw Error(r(443,b.type))}else b.type==="stylesheet"&&(b.state.loading&4)===0&&(S=b.instance,b.state.loading|=4,uw(S,w.precedence,m));return b.instance}function uw(m,b,w){for(var S=w.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),j=S.length?S[S.length-1]:null,R=j,J=0;J<S.length;J++){var oe=S[J];if(oe.dataset.precedence===b)R=oe;else if(R!==j)break}R?R.parentNode.insertBefore(m,R.nextSibling):(b=w.nodeType===9?w.head:w,b.insertBefore(m,b.firstChild))}function eI(m,b){m.crossOrigin==null&&(m.crossOrigin=b.crossOrigin),m.referrerPolicy==null&&(m.referrerPolicy=b.referrerPolicy),m.title==null&&(m.title=b.title)}function tI(m,b){m.crossOrigin==null&&(m.crossOrigin=b.crossOrigin),m.referrerPolicy==null&&(m.referrerPolicy=b.referrerPolicy),m.integrity==null&&(m.integrity=b.integrity)}var dw=null;function Xie(m,b,w){if(dw===null){var S=new Map,j=dw=new Map;j.set(w,S)}else j=dw,S=j.get(w),S||(S=new Map,j.set(w,S));if(S.has(m))return S;for(S.set(m,null),w=w.getElementsByTagName(m),j=0;j<w.length;j++){var R=w[j];if(!(R[Zt]||R[At]||m==="link"&&R.getAttribute("rel")==="stylesheet")&&R.namespaceURI!=="http://www.w3.org/2000/svg"){var J=R.getAttribute(b)||"";J=m+J;var oe=S.get(J);oe?oe.push(R):S.set(J,[R])}}return S}function Kie(m,b,w){m=m.ownerDocument||m,m.head.insertBefore(w,b==="title"?m.querySelector("head > title"):null)}function UYe(m,b,w){if(w===1||b.itemProp!=null)return!1;switch(m){case"meta":case"title":return!0;case"style":if(typeof b.precedence!="string"||typeof b.href!="string"||b.href==="")break;return!0;case"link":if(typeof b.rel!="string"||typeof b.href!="string"||b.href===""||b.onLoad||b.onError)break;return b.rel==="stylesheet"?(m=b.disabled,typeof b.precedence=="string"&&m==null):!0;case"script":if(b.async&&typeof b.async!="function"&&typeof b.async!="symbol"&&!b.onLoad&&!b.onError&&b.src&&typeof b.src=="string")return!0}return!1}function Jie(m){return!(m.type==="stylesheet"&&(m.state.loading&3)===0)}function WYe(m,b,w,S){if(w.type==="stylesheet"&&(typeof S.media!="string"||matchMedia(S.media).matches!==!1)&&(w.state.loading&4)===0){if(w.instance===null){var j=Am(S.href),R=b.querySelector(f7(j));if(R){b=R._p,b!==null&&typeof b=="object"&&typeof b.then=="function"&&(m.count++,m=fw.bind(m),b.then(m,m)),w.state.loading|=4,w.instance=R,Yn(R);return}R=b.ownerDocument||b,S=Gie(S),(j=gc.get(j))&&eI(S,j),R=R.createElement("link"),Yn(R);var J=R;J._p=new Promise(function(oe,Oe){J.onload=oe,J.onerror=Oe}),Ts(R,"link",S),w.instance=R}m.stylesheets===null&&(m.stylesheets=new Map),m.stylesheets.set(w,b),(b=w.state.preload)&&(w.state.loading&3)===0&&(m.count++,w=fw.bind(m),b.addEventListener("load",w),b.addEventListener("error",w))}}var nI=0;function ZYe(m,b){return m.stylesheets&&m.count===0&&pw(m,m.stylesheets),0<m.count||0<m.imgCount?function(w){var S=setTimeout(function(){if(m.stylesheets&&pw(m,m.stylesheets),m.unsuspend){var R=m.unsuspend;m.unsuspend=null,R()}},6e4+b);0<m.imgBytes&&nI===0&&(nI=62500*EYe());var j=setTimeout(function(){if(m.waitingForImages=!1,m.count===0&&(m.stylesheets&&pw(m,m.stylesheets),m.unsuspend)){var R=m.unsuspend;m.unsuspend=null,R()}},(m.imgBytes>nI?50:800)+b);return m.unsuspend=w,function(){m.unsuspend=null,clearTimeout(S),clearTimeout(j)}}:null}function fw(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)pw(this,this.stylesheets);else if(this.unsuspend){var m=this.unsuspend;this.unsuspend=null,m()}}}var hw=null;function pw(m,b){m.stylesheets=null,m.unsuspend!==null&&(m.count++,hw=new Map,b.forEach(GYe,m),hw=null,fw.call(m))}function GYe(m,b){if(!(b.state.loading&4)){var w=hw.get(m);if(w)var S=w.get(null);else{w=new Map,hw.set(m,w);for(var j=m.querySelectorAll("link[data-precedence],style[data-precedence]"),R=0;R<j.length;R++){var J=j[R];(J.nodeName==="LINK"||J.getAttribute("media")!=="not all")&&(w.set(J.dataset.precedence,J),S=J)}S&&w.set(null,S)}j=b.instance,J=j.getAttribute("data-precedence"),R=w.get(J)||S,R===S&&w.set(null,j),w.set(J,j),this.count++,S=fw.bind(this),j.addEventListener("load",S),j.addEventListener("error",S),R?R.parentNode.insertBefore(j,R.nextSibling):(m=m.nodeType===9?m.head:m,m.insertBefore(j,m.firstChild)),b.state.loading|=4}}var p7={$$typeof:O,Provider:null,Consumer:null,_currentValue:G,_currentValue2:G,_threadCount:0};function YYe(m,b,w,S,j,R,J,oe,Oe){this.tag=1,this.containerInfo=m,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=dt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=dt(0),this.hiddenUpdates=dt(null),this.identifierPrefix=S,this.onUncaughtError=j,this.onCaughtError=R,this.onRecoverableError=J,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Oe,this.incompleteTransitions=new Map}function ese(m,b,w,S,j,R,J,oe,Oe,qe,nt,at){return m=new YYe(m,b,w,J,Oe,qe,nt,at,oe),b=1,R===!0&&(b|=24),R=Ml(3,null,null,b),m.current=R,R.stateNode=m,b=LR(),b.refCount++,m.pooledCache=b,b.refCount++,R.memoizedState={element:S,isDehydrated:w,cache:b},$R(R),m}function tse(m){return m?(m=im,m):im}function nse(m,b,w,S,j,R){j=tse(j),S.context===null?S.context=j:S.pendingContext=j,S=jd(b),S.payload={element:w},R=R===void 0?null:R,R!==null&&(S.callback=R),w=Nd(m,S,b),w!==null&&(il(w,m,b),U8(w,m,b))}function rse(m,b){if(m=m.memoizedState,m!==null&&m.dehydrated!==null){var w=m.retryLane;m.retryLane=w!==0&&w<b?w:b}}function rI(m,b){rse(m,b),(m=m.alternate)&&rse(m,b)}function ose(m){if(m.tag===13||m.tag===31){var b=ep(m,67108864);b!==null&&il(b,m,67108864),rI(m,67108864)}}function ise(m){if(m.tag===13||m.tag===31){var b=Ll();b=Xt(b);var w=ep(m,b);w!==null&&il(w,m,b),rI(m,b)}}var mw=!0;function XYe(m,b,w,S){var j=N.T;N.T=null;var R=V.p;try{V.p=2,oI(m,b,w,S)}finally{V.p=R,N.T=j}}function KYe(m,b,w,S){var j=N.T;N.T=null;var R=V.p;try{V.p=8,oI(m,b,w,S)}finally{V.p=R,N.T=j}}function oI(m,b,w,S){if(mw){var j=iI(S);if(j===null)VL(m,b,S,gw,w),ase(m,S);else if(eXe(j,m,b,w,S))S.stopPropagation();else if(ase(m,S),b&4&&-1<JYe.indexOf(m)){for(;j!==null;){var R=zt(j);if(R!==null)switch(R.tag){case 3:if(R=R.stateNode,R.current.memoizedState.isDehydrated){var J=kn(R.pendingLanes);if(J!==0){var oe=R;for(oe.pendingLanes|=2,oe.entangledLanes|=2;J;){var Oe=1<<31-Ve(J);oe.entanglements[1]|=Oe,J&=~Oe}f1(R),(Wr&6)===0&&(Ky=De()+500,l7(0))}}break;case 31:case 13:oe=ep(R,2),oe!==null&&il(oe,R,2),ew(),rI(R,2)}if(R=iI(S),R===null&&VL(m,b,S,gw,w),R===j)break;j=R}j!==null&&S.stopPropagation()}else VL(m,b,S,null,w)}}function iI(m){return m=aR(m),sI(m)}var gw=null;function sI(m){if(gw=null,m=ht(m),m!==null){var b=i(m);if(b===null)m=null;else{var w=b.tag;if(w===13){if(m=s(b),m!==null)return m;m=null}else if(w===31){if(m=a(b),m!==null)return m;m=null}else if(w===3){if(b.stateNode.current.memoizedState.isDehydrated)return b.tag===3?b.stateNode.containerInfo:null;m=null}else b!==m&&(m=null)}}return gw=m,null}function sse(m){switch(m){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(ct()){case ue:return 2;case Pe:return 8;case Ee:case Le:return 32;case et:return 268435456;default:return 32}default:return 32}}var aI=!1,Vd=null,Qd=null,Ud=null,m7=new Map,g7=new Map,Wd=[],JYe="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function ase(m,b){switch(m){case"focusin":case"focusout":Vd=null;break;case"dragenter":case"dragleave":Qd=null;break;case"mouseover":case"mouseout":Ud=null;break;case"pointerover":case"pointerout":m7.delete(b.pointerId);break;case"gotpointercapture":case"lostpointercapture":g7.delete(b.pointerId)}}function v7(m,b,w,S,j,R){return m===null||m.nativeEvent!==R?(m={blockedOn:b,domEventName:w,eventSystemFlags:S,nativeEvent:R,targetContainers:[j]},b!==null&&(b=zt(b),b!==null&&ose(b)),m):(m.eventSystemFlags|=S,b=m.targetContainers,j!==null&&b.indexOf(j)===-1&&b.push(j),m)}function eXe(m,b,w,S,j){switch(b){case"focusin":return Vd=v7(Vd,m,b,w,S,j),!0;case"dragenter":return Qd=v7(Qd,m,b,w,S,j),!0;case"mouseover":return Ud=v7(Ud,m,b,w,S,j),!0;case"pointerover":var R=j.pointerId;return m7.set(R,v7(m7.get(R)||null,m,b,w,S,j)),!0;case"gotpointercapture":return R=j.pointerId,g7.set(R,v7(g7.get(R)||null,m,b,w,S,j)),!0}return!1}function lse(m){var b=ht(m.target);if(b!==null){var w=i(b);if(w!==null){if(b=w.tag,b===13){if(b=s(w),b!==null){m.blockedOn=b,Ie(m.priority,function(){ise(w)});return}}else if(b===31){if(b=a(w),b!==null){m.blockedOn=b,Ie(m.priority,function(){ise(w)});return}}else if(b===3&&w.stateNode.current.memoizedState.isDehydrated){m.blockedOn=w.tag===3?w.stateNode.containerInfo:null;return}}}m.blockedOn=null}function vw(m){if(m.blockedOn!==null)return!1;for(var b=m.targetContainers;0<b.length;){var w=iI(m.nativeEvent);if(w===null){w=m.nativeEvent;var S=new w.constructor(w.type,w);sR=S,w.target.dispatchEvent(S),sR=null}else return b=zt(w),b!==null&&ose(b),m.blockedOn=w,!1;b.shift()}return!0}function cse(m,b,w){vw(m)&&w.delete(b)}function tXe(){aI=!1,Vd!==null&&vw(Vd)&&(Vd=null),Qd!==null&&vw(Qd)&&(Qd=null),Ud!==null&&vw(Ud)&&(Ud=null),m7.forEach(cse),g7.forEach(cse)}function bw(m,b){m.blockedOn===b&&(m.blockedOn=null,aI||(aI=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,tXe)))}var _w=null;function use(m){_w!==m&&(_w=m,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){_w===m&&(_w=null);for(var b=0;b<m.length;b+=3){var w=m[b],S=m[b+1],j=m[b+2];if(typeof S!="function"){if(sI(S||w)===null)continue;break}var R=zt(w);R!==null&&(m.splice(b,3),b-=3,iL(R,{pending:!0,data:j,method:w.method,action:S},S,j))}}))}function Tm(m){function b(Oe){return bw(Oe,m)}Vd!==null&&bw(Vd,m),Qd!==null&&bw(Qd,m),Ud!==null&&bw(Ud,m),m7.forEach(b),g7.forEach(b);for(var w=0;w<Wd.length;w++){var S=Wd[w];S.blockedOn===m&&(S.blockedOn=null)}for(;0<Wd.length&&(w=Wd[0],w.blockedOn===null);)lse(w),w.blockedOn===null&&Wd.shift();if(w=(m.ownerDocument||m).$$reactFormReplay,w!=null)for(S=0;S<w.length;S+=3){var j=w[S],R=w[S+1],J=j[qt]||null;if(typeof R=="function")J||use(w);else if(J){var oe=null;if(R&&R.hasAttribute("formAction")){if(j=R,J=R[qt]||null)oe=J.formAction;else if(sI(j)!==null)continue}else oe=J.action;typeof oe=="function"?w[S+1]=oe:(w.splice(S,3),S-=3),use(w)}}}function dse(){function m(R){R.canIntercept&&R.info==="react-transition"&&R.intercept({handler:function(){return new Promise(function(J){return j=J})},focusReset:"manual",scroll:"manual"})}function b(){j!==null&&(j(),j=null),S||setTimeout(w,20)}function w(){if(!S&&!navigation.transition){var R=navigation.currentEntry;R&&R.url!=null&&navigation.navigate(R.url,{state:R.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var S=!1,j=null;return navigation.addEventListener("navigate",m),navigation.addEventListener("navigatesuccess",b),navigation.addEventListener("navigateerror",b),setTimeout(w,100),function(){S=!0,navigation.removeEventListener("navigate",m),navigation.removeEventListener("navigatesuccess",b),navigation.removeEventListener("navigateerror",b),j!==null&&(j(),j=null)}}}function lI(m){this._internalRoot=m}xw.prototype.render=lI.prototype.render=function(m){var b=this._internalRoot;if(b===null)throw Error(r(409));var w=b.current,S=Ll();nse(w,S,m,b,null,null)},xw.prototype.unmount=lI.prototype.unmount=function(){var m=this._internalRoot;if(m!==null){this._internalRoot=null;var b=m.containerInfo;nse(m.current,2,null,m,null,null),ew(),b[yr]=null}};function xw(m){this._internalRoot=m}xw.prototype.unstable_scheduleHydration=function(m){if(m){var b=Kn();m={blockedOn:null,target:m,priority:b};for(var w=0;w<Wd.length&&b!==0&&b<Wd[w].priority;w++);Wd.splice(w,0,m),w===0&&lse(m)}};var fse=e.version;if(fse!=="19.2.4")throw Error(r(527,fse,"19.2.4"));V.findDOMNode=function(m){var b=m._reactInternals;if(b===void 0)throw typeof m.render=="function"?Error(r(188)):(m=Object.keys(m).join(","),Error(r(268,m)));return m=c(b),m=m!==null?u(m):null,m=m===null?null:m.stateNode,m};var nXe={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:N,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var yw=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!yw.isDisabled&&yw.supportsFiber)try{Kt=yw.inject(nXe),Dn=yw}catch{}}return kv.createRoot=function(m,b){if(!o(m))throw Error(r(299));var w=!1,S="",j=_oe,R=xoe,J=yoe;return b!=null&&(b.unstable_strictMode===!0&&(w=!0),b.identifierPrefix!==void 0&&(S=b.identifierPrefix),b.onUncaughtError!==void 0&&(j=b.onUncaughtError),b.onCaughtError!==void 0&&(R=b.onCaughtError),b.onRecoverableError!==void 0&&(J=b.onRecoverableError)),b=ese(m,1,!1,null,null,w,S,null,j,R,J,dse),m[yr]=b.current,qL(m),new lI(b)},kv.hydrateRoot=function(m,b,w){if(!o(m))throw Error(r(299));var S=!1,j="",R=_oe,J=xoe,oe=yoe,Oe=null;return w!=null&&(w.unstable_strictMode===!0&&(S=!0),w.identifierPrefix!==void 0&&(j=w.identifierPrefix),w.onUncaughtError!==void 0&&(R=w.onUncaughtError),w.onCaughtError!==void 0&&(J=w.onCaughtError),w.onRecoverableError!==void 0&&(oe=w.onRecoverableError),w.formState!==void 0&&(Oe=w.formState)),b=ese(m,1,!0,b,w??null,S,j,Oe,R,J,oe,dse),b.context=tse(null),w=b.current,S=Ll(),S=Xt(S),j=jd(S),j.callback=null,Nd(w,j,S),w=S,b.current.lanes=w,sn(b,w),f1(b),m[yr]=b.current,qL(m),new xw(b)},kv.version="19.2.4",kv}var t8e;function uYn(){if(t8e)return TH.exports;t8e=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),TH.exports=cYn(),TH.exports}var kZe=uYn();const dYn=({source:t},e)=>{const n=kZe.createRoot(e);return n.render(f.jsx(QP,{className:"size-full break-words leading-relaxed [overflow-wrap:anywhere] [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",plugins:uee,components:cee,children:t})),()=>queueMicrotask(()=>n.unmount())};function OZe(){const{settings:t}=Qh(),e=t.codingAgents??[],n=t.defaultCodingAgent??e[0]?.id;return{agents:[...e].sort((o,i)=>+(i.id===n)-+(o.id===n)),defaultAgentId:n}}function SZe({agents:t,defaultAgentId:e,onPick:n}){return t.length===0?f.jsxs(dr,{onClick:()=>n(void 0),"data-testid":"worktree-center__new-agent",children:[f.jsx(dM,{className:"size-4"}),"Default agent"]}):t.map(r=>f.jsxs(dr,{onClick:()=>n(r.id===e?void 0:r.id),"data-testid":`worktree-center__new-agent--${r.id}`,"data-default":r.id===e?"true":void 0,children:[f.jsx(D3,{type:r.type,className:"size-4"}),r.label,r.id===e&&f.jsx(pF,{className:"tracking-normal",children:"Default"})]},r.id))}function fYn({onPick:t}){const{agents:e,defaultAgentId:n}=OZe();return f.jsxs(rP,{children:[f.jsxs(oP,{"data-testid":"worktree-center__new-tab--agent",children:[f.jsx(dM,{className:"size-4"}),"New agent"]}),f.jsx(nP,{children:f.jsx(iP,{"data-testid":"worktree-center__new-agent-menu",children:f.jsx(SZe,{agents:e,defaultAgentId:n,onPick:t})})})]})}function hYn({className:t,onPick:e}){const{agents:n,defaultAgentId:r}=OZe();return f.jsxs(Us,{children:[f.jsx(Ws,{asChild:!0,children:f.jsxs("button",{type:"button",className:t,"data-testid":"worktree-center__empty-new-agent",children:[f.jsx(dM,{className:"size-4"}),"New agent"]})}),f.jsx(Zs,{align:"start","data-testid":"worktree-center__new-agent-menu",children:f.jsx(SZe,{agents:n,defaultAgentId:r,onPick:e})})]})}const Cne=v.createContext({visible:!0,wsActive:!0});function Wh(){return v.useContext(Cne)}function pYn(t){return t.subarray(0,8e3).includes(0)}function mYn(t,e){const[n,r]=v.useState({state:"loading"});return v.useEffect(()=>{if(!e)return;let o=!1;return r({state:"loading"}),j4(t).then(async i=>{if(!i.ok)throw new Error(String(i.status));const s=new Uint8Array(await i.arrayBuffer());o||r(pYn(s)?{state:"binary"}:{state:"text",text:new TextDecoder().decode(s)})}).catch(()=>{o||r({state:"error"})}),()=>{o=!0}},[t,e]),n}function gYn({name:t}){return f.jsxs(t0,{children:[f.jsx(ku,{asChild:!0,children:f.jsx(Ce,{variant:"ghost",size:"icon","aria-label":`Could not load ${t}`,"data-testid":"shared-file__error",className:"text-destructive",children:f.jsx(_u,{className:"size-5"})})}),f.jsx(n0,{className:"text-sm",children:"The file could not be loaded. It may be gone."})]})}function vYn({worktreeId:t,filePath:e}){const n=KQn(t,e),r=e.split("/").pop()??e,o=Uee(r),i=/\.html?$/i.test(r),a=mYn(n??"",!!n&&o!=="image"&&o!=="pdf");if(!n)return null;const l=lh(n);let c;return o==="image"?c=f.jsx("div",{className:"flex h-full items-center justify-center overflow-auto p-4",children:f.jsx("img",{src:l,alt:r,"data-testid":"shared-file__image",className:"max-h-full max-w-full object-contain"})}):o==="pdf"?c=f.jsx("iframe",{src:l,title:r,"data-testid":"shared-file__pdf",className:"size-full border-0"}):i&&a.state==="text"?c=f.jsx("iframe",{srcDoc:a.text,title:r,sandbox:"allow-scripts","data-testid":"shared-file__html",className:"size-full border-0 bg-white"}):a.state==="loading"?c=f.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading…"}):a.state==="error"?c=f.jsx("div",{className:"flex h-full items-center justify-center",children:f.jsx(gYn,{name:r})}):a.state==="binary"?c=f.jsxs("div",{"data-testid":"shared-file__binary",className:"flex h-full flex-col items-center justify-center gap-3 text-muted-foreground",children:[f.jsx(Oh,{className:"size-8"}),f.jsx("p",{className:"text-sm",children:"No preview for this file type"}),f.jsxs(Ce,{variant:"outline",size:"sm","data-testid":"shared-file__binary-download",onClick:()=>ZT(l,r),children:[f.jsx(N6,{className:"size-4"}),"Download"]})]}):o==="markdown"?c=f.jsx("div",{"data-testid":"shared-file__markdown",className:"h-full overflow-auto p-4",children:f.jsx(g4,{children:a.text})}):c=f.jsx("div",{"data-testid":"shared-file__code",className:"h-full",children:f.jsx(XY,{content:a.text,language:rZe(r),className:"h-full"})}),f.jsxs("div",{tabIndex:-1,"data-band-leaf-root":"",className:"flex h-full w-full flex-col overflow-hidden outline-none","data-testid":"shared-file",children:[f.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-3 py-1.5",children:[f.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-sm",children:r}),f.jsx(Ce,{variant:"ghost",size:"sm","aria-label":"Download file","data-testid":"shared-file__download",onClick:()=>ZT(l,r),children:f.jsx(N6,{className:"size-4"})})]}),f.jsx("div",{className:"min-h-0 flex-1",children:c})]})}const n8e=50,CZe=new Map;function jW(t){return CZe.get(t)??[]}function bYn(t,e){const n=jW(t).filter(r=>r!==e);return n.unshift(e),n.length>n8e&&(n.length=n8e),CZe.set(t,n),n}function _Yn(t){const[e,n]=v.useState(()=>jW(t));v.useEffect(()=>{n(jW(t))},[t]);const r=v.useCallback(o=>{if(!o)return;const i=bYn(t,o);n(i)},[t]);return{recentFiles:e,trackFile:r}}const $1={onOpenFile:()=>{},onSelectFile:()=>{},onFileOpened:()=>{},onFindInFile:()=>{},onActivateFilesPanel:()=>{},onActivateTerminalPanel:()=>{}};function Ep(t,e){const n=Tf(t),r=n?jZe(n,e):void 0;return r?(r.api.setActive(),!0):!1}function Ov(t,e){const n=Tf(t),r=n?.activeGroup??n?.groups[0];Io(t)?.onAdd(e,r?.id)}function r8e(t){const e=Tf(t)?.activeGroup;e&&(e.api.isMaximized()?e.api.exitMaximized():e.api.maximize())}function o8e(t){t&&window.dispatchEvent(new CustomEvent("band:focus-active-leaf",{detail:{worktreeId:t}}))}function Sv(t){window.dispatchEvent(new CustomEvent("band:show-right-panel")),t&&window.dispatchEvent(new CustomEvent("band:right-sidepanel-set-tab",{detail:{tab:t}}))}function xYn(){return f.jsx("div",{className:"flex h-full items-center justify-center",children:f.jsxs("div",{className:"flex flex-col items-center gap-3 text-center px-8",children:[f.jsx(ld,{className:"size-8 text-muted-foreground/30"}),f.jsx("p",{className:"text-sm text-muted-foreground",children:"Select a worktree to get started"})]})})}function yYn(){const t=Mo({select:H=>H.location.pathname}),e=v8(t),n=v.useRef(e);n.current=e,v.useEffect(()=>{e&&UHe(e)},[e]);const{recentFiles:r,trackFile:o}=_Yn(e??""),s=Gs().pickFile,a=v.useRef(void 0),l=v.useRef(new Map),[c,u]=v.useState(!1),[d,h]=v.useState(void 0),[p,g]=v.useState(!1),[_,x]=v.useState(!1),[y,k]=v.useState(!1),[O,C]=v.useState(""),[A,E]=v.useState(void 0);v.useEffect(()=>{if(!e){E(void 0),a.current=void 0;return}const H=dT(e);return E(H.currentFile),a.current=H.currentFile,Cqe(e,()=>{const V=dT(e).currentFile;E(V),a.current=V})},[e]);const M=v.useCallback((H,N)=>{const V=X5(N);o(V.filePath),Io(H)?.openFile(V.filePath,{line:V.line,column:V.column})},[o]),P=v.useCallback(H=>{},[]),L=v.useCallback((H,N)=>{const V=X5(N);Io(H)?.openFile(V.filePath,{line:V.line,column:V.column,external:!0})},[]),D=v.useCallback((H,N)=>{N&&o(N)},[o]),I=v.useCallback((H,N)=>{N?l.current.set(H,N):l.current.delete(H)},[]),z=v.useCallback(H=>{Sv("explorer")},[]),Y=v.useCallback(H=>{H===n.current&&(Ep(H,"term"),queueMicrotask(()=>window.dispatchEvent(new CustomEvent("band:focus-terminal"))))},[]);$1.onOpenFile=M,$1.onFileOpened=P,$1.onSelectFile=D,$1.onFindInFile=I,$1.onActivateFilesPanel=z,$1.onActivateTerminalPanel=Y;const Q=v.useMemo(()=>kBt({getApi:()=>{const H=Tf(n.current);return H?{getPanel:N=>{if(N==="files"||N==="changes")return;const G=jZe(H,N==="terminal"?"term":N);return G?{api:{setActive:()=>G.api.setActive()}}:void 0}}:null},getHiddenPanels:()=>[],openQuickOpen:()=>u(!0),openSearchFiles:()=>g(!0),findInFile:()=>{const H=n.current,N=H?l.current.get(H):void 0;N?N():window.dispatchEvent(new CustomEvent("band:find-in-file"))},formatCurrentFile:()=>{const H=n.current;H&&window.dispatchEvent(new CustomEvent("band:format-current-file",{detail:{worktreeId:H,filePath:a.current}}))},newUntitledTab:()=>window.dispatchEvent(new CustomEvent("band:new-untitled-tab")),changeLanguageMode:()=>{const H=n.current;H&&window.dispatchEvent(new CustomEvent("band:open-language-picker",{detail:{worktreeId:H,filePath:a.current}}))},editorGoBack:()=>{const H=n.current;H&&window.dispatchEvent(new CustomEvent("band:editor-go-back",{detail:{worktreeId:H}}))},editorGoForward:()=>{const H=n.current;H&&window.dispatchEvent(new CustomEvent("band:editor-go-forward",{detail:{worktreeId:H}}))},newLeaf:H=>Ov(n.current,H),openWorktreePicker:()=>x(!0),closeActiveTab:()=>{const H=n.current,N=Tf(H)?.activePanel;N&&Io(H)?.onClose(N.id,N.api.component)},splitActiveTab:H=>{const N=n.current,V=Tf(N),G=V?.activePanel,K=V?.activeGroup?.id;if(!G||!K)return;const q=G.api.component;q==="term"?window.dispatchEvent(new CustomEvent("band:split-terminal-pane",{detail:{leafId:G.id,direction:H}})):(q==="chat"||q==="browser")&&Io(N)?.onSplit(q,K,H)},cycleTabs:H=>{const N=n.current;qWe(Tf(N)??null,H,()=>o8e(N))},cycleGroups:H=>{const N=n.current;wne(Tf(N)??null,H,()=>o8e(N))},toggleMaximize:()=>r8e(n.current),openFileExternal:()=>{const H=n.current;H&&window.dispatchEvent(new CustomEvent("band:open-file-external",{detail:{worktreeId:H}}))}}),[]);return v.useEffect(()=>{const H=N=>{const V=n.current,G=document.activeElement?.closest(".xterm")!=null;if(N.metaKey&&!N.ctrlKey&&!N.shiftKey&&N.key.toLowerCase()==="k"){N.preventDefault(),N.stopPropagation(),x(!0);return}if(N.ctrlKey&&!N.metaKey&&!N.shiftKey&&N.key.toLowerCase()==="k"){if(G)return;N.preventDefault(),N.stopPropagation(),x(!0);return}if(N.ctrlKey&&!N.metaKey&&N.key==="`"){N.preventDefault(),N.stopPropagation(),Ep(V,"term")||Io(V)?.onAdd("term"),queueMicrotask(()=>window.dispatchEvent(new CustomEvent("band:focus-terminal")));return}if(N.ctrlKey&&!N.metaKey&&N.key==="0"){N.preventDefault(),N.stopPropagation(),window.dispatchEvent(new CustomEvent("band:show-sidebar")),queueMicrotask(()=>window.dispatchEvent(new CustomEvent("band:focus-repos")));return}if(N.code==="KeyF"&&N.altKey&&N.shiftKey&&!N.metaKey&&!N.ctrlKey){if(G||(N.preventDefault(),!V))return;window.dispatchEvent(new CustomEvent("band:format-current-file",{detail:{worktreeId:V,filePath:a.current}}));return}if(!(N.metaKey||N.ctrlKey))return;const q=N.key.toLowerCase(),Z=!Y2()&&(N.shiftKey&&!N.altKey&&(q==="n"||q==="b"||q==="p"||q==="m")||N.altKey&&!N.shiftKey&&N.code==="KeyI");if(!(G&&!N.metaKey&&!Z)){if(q==="t"&&!N.shiftKey&&!N.altKey){N.preventDefault(),N.stopPropagation(),Ov(V,"term");return}if(N.code==="KeyT"&&N.altKey&&N.metaKey&&!N.ctrlKey&&!N.shiftKey){N.preventDefault(),N.stopPropagation(),Ov(V,"chat");return}if(q==="n"&&N.shiftKey)N.preventDefault(),N.stopPropagation(),Ov(V,"chat");else if(q==="n"&&!N.shiftKey&&!N.altKey)N.preventDefault(),window.dispatchEvent(new CustomEvent("band:new-untitled-tab"));else if(q==="p"&&N.shiftKey)N.preventDefault(),k(!0);else if(q==="p"&&!N.shiftKey)N.preventDefault(),u(!0);else if(q==="f"&&N.shiftKey&&!N.altKey)N.preventDefault(),g(!0);else if(q==="f"&&!N.shiftKey&&!N.altKey){if(G||document.activeElement?.closest("[data-chat-pane]"))return;N.preventDefault();const U=V?l.current.get(V):void 0;U?U():window.dispatchEvent(new CustomEvent("band:find-in-file"))}else if(q==="o"&&!N.shiftKey&&!N.altKey){if(N.preventDefault(),!V)return;window.dispatchEvent(new CustomEvent("band:open-file-external",{detail:{worktreeId:V}}))}else N.code==="KeyI"&&(Y2()?N.ctrlKey&&N.metaKey:N.ctrlKey&&N.altKey&&!N.metaKey&&q==="i")?(N.preventDefault(),Ep(V,"chat"),queueMicrotask(()=>window.dispatchEvent(new CustomEvent("band:focus-chat")))):q==="g"&&N.shiftKey?(N.preventDefault(),Sv("changes")):q==="e"&&N.shiftKey?(N.preventDefault(),Sv("explorer")):q==="b"&&N.shiftKey?(N.preventDefault(),Ov(V,"browser")):q==="b"&&!N.shiftKey&&!N.altKey?(N.preventDefault(),window.dispatchEvent(new CustomEvent("band:toggle-sidebar"))):N.code==="KeyB"&&N.altKey&&!N.shiftKey?(N.preventDefault(),window.dispatchEvent(new CustomEvent("band:toggle-right-panel"))):q==="m"&&N.shiftKey&&(N.preventDefault(),r8e(V))}};return window.addEventListener("keydown",H,!0),()=>window.removeEventListener("keydown",H,!0)},[]),v.useEffect(()=>{const H=N=>{const V=N.detail;V?.filename&&(V.worktreeId&&V.worktreeId!==e||(h(V.filename),u(!0)))};return window.addEventListener("band:open-file",H),()=>window.removeEventListener("band:open-file",H)},[e]),v.useEffect(()=>{const H=N=>{const V=N.detail;V?.filePath&&Io(V.worktreeId??e)?.openFile(V.filePath,{preview:!1,line:V.line,column:V.column})};return window.addEventListener("band:lsp-navigate",H),()=>window.removeEventListener("band:lsp-navigate",H)},[e]),v.useEffect(()=>{const H=()=>u(!0),N=()=>g(!0);return window.addEventListener("band:open-quick-open",H),window.addEventListener("band:open-search-files",N),()=>{window.removeEventListener("band:open-quick-open",H),window.removeEventListener("band:open-search-files",N)}},[]),v.useEffect(()=>{const H=N=>{const V=N.detail?.panelId;if(!V)return;if(V==="files"){Sv("explorer");return}if(V==="changes"){Sv("changes");return}const G=V==="terminal"?"term":V;Ep(n.current,G)};return window.addEventListener("band:activate-panel",H),()=>window.removeEventListener("band:activate-panel",H)},[]),v.useEffect(()=>{const H=N=>{const V=N.detail?.reference,G=n.current;!V||!G||(Ep(G,"term"),(async()=>{let K;try{K=(await Se.panelFocus.get.query({worktreeId:G})).terminal}catch{}window.dispatchEvent(new CustomEvent("band:terminal-insert",{detail:{reference:V,worktreeId:G,terminalId:K}}))})())};return window.addEventListener("band:add-to-terminal",H),()=>window.removeEventListener("band:add-to-terminal",H)},[]),v.useEffect(()=>{const H=N=>{const V=N.detail;if(!V?.worktreeId||!V.text)return;const{worktreeId:G,text:K,done:q}=V;(async()=>{try{let Z;try{Z=(await Se.panelFocus.get.query({worktreeId:G})).chat}catch{}if(!Z){const{chats:B}=await Se.chats.list.query({worktreeId:G});Z=B[0]?.id}Z||(Z=(await Se.chats.create.mutate({worktreeId:G})).chat.id),Ep(G,"chat");const U=await oC(()=>G,Z)(`/api/chats/${encodeURIComponent(Z)}/messages`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreeId:G,text:K})});q(U.ok)}catch{q(!1)}})()};return window.addEventListener("band:send-to-chat",H),()=>window.removeEventListener("band:send-to-chat",H)},[]),v.useEffect(()=>{const H=N=>{const V=N.detail,G=n.current;!V||!G||(Ep(G,"chat"),(async()=>{let K;try{K=(await Se.panelFocus.get.query({worktreeId:G})).chat}catch{}const q="text"in V?{text:V.text,worktreeId:G,chatId:K}:{filePath:V.filePath,startLine:V.startLine,endLine:V.endLine,worktreeId:G,chatId:K};window.dispatchEvent(new CustomEvent("band:chat-insert",{detail:q}))})())};return window.addEventListener("band:add-to-chat",H),()=>window.removeEventListener("band:add-to-chat",H)},[]),v.useEffect(()=>{const H=()=>{const N=n.current;if(!N)return;const V=qYn(N);Io(N)?.openFile(V,{untitled:!0,preview:!1})};return window.addEventListener("band:new-untitled-tab",H),()=>window.removeEventListener("band:new-untitled-tab",H)},[]),v.useEffect(()=>{if(!s)return;const H=N=>{const V=N.detail,G=V?.worktreeId??n.current;!G||V?.worktreeId&&V.worktreeId!==n.current||(async()=>{const K=await s();if(!K)return;const q=X5(K);Io(G)?.openFile(q.filePath,{line:q.line,column:q.column,external:!0,preview:!1})})()};return window.addEventListener("band:open-file-external",H),()=>window.removeEventListener("band:open-file-external",H)},[s]),f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"absolute inset-0",children:f.jsx(Aqe,{emptyState:f.jsx(xYn,{}),children:(H,N)=>f.jsx(AFe.Provider,{value:N,children:f.jsxs("div",{className:"flex h-full w-full flex-col",children:[f.jsx(Mqe,{worktreeId:H,active:N}),f.jsx("div",{className:"relative min-h-0 flex-1",children:f.jsx(FZe,{worktreeId:H,visible:N,wsActive:N})})]})})})}),f.jsx(qHe,{worktreeId:e??"",open:c,onOpenChange:H=>{u(H),H||h(void 0)},onOpenFile:H=>{e&&M(e,H)},onOpenExternalFile:H=>{e&&L(e,H)},currentFile:A,initialQuery:d,autoOpen:d!=null,recentFiles:r,lastQuery:O,onQueryChange:C}),f.jsx(VHe,{worktreeId:e??"",open:p,onOpenChange:g,onOpenFile:H=>{e&&M(e,H)}}),f.jsx(ZHe,{open:_,onOpenChange:x}),f.jsx(SBt,{open:y,onOpenChange:k,commands:Q})]})}const i8e={question:5,failed:4,working:3,monitoring:2,done:1};function Ane({status:t,testId:e}){return t==="working"?f.jsx(Fo,{role:"img","aria-label":gb.working.label,"data-testid":e,"data-status":t,className:"size-3 animate-spin text-muted-foreground"}):f.jsx(bG,{status:t,testId:e,withTitle:!0})}function AZe(t,e){return Cn(n=>n.statuses.get(t)?.tabStatuses?.find(r=>r.chatId===e)?.status)}function EZe(t,e){return Cn(n=>{let r;for(const o of n.statuses.get(t)?.tabStatuses??[])!o.terminalId||(cT(o.terminalId)??o.terminalId)!==e||(!r||i8e[o.status]>i8e[r])&&(r=o.status);return r})}function Ene(t){if(!t)return{};try{const e=sessionStorage.getItem(`band:chat-tab-meta:${t}`);return e?JSON.parse(e):{}}catch{return{}}}function s8e(t,e){if(t)try{const n=Ene(t);sessionStorage.setItem(`band:chat-tab-meta:${t}`,JSON.stringify({...n,...e}))}catch{}}function wYn({item:t}){const e="size-4 shrink-0 text-muted-foreground";switch(t.kind){case"chat":{const n=Ene(t.params?.chatId??"").agentType;return n?f.jsx(D3,{type:n,className:"size-4 shrink-0"}):f.jsx(Q_,{className:e})}case"term":return f.jsx(_M,{className:e});case"browser":return f.jsx(xu,{className:e});case"diff":return f.jsx(B2,{className:e});default:{const n=U2(t.title);return f.jsx(n,{className:e})}}}function kYn({item:t}){const e=t.params?.worktreeId??"",n=AZe(e,t.params?.chatId??""),r=EZe(e,t.params?.terminalId??""),o=t.kind==="chat"?n:t.kind==="term"?r:void 0;return o?f.jsx(Ane,{status:o,testId:`tab-switcher__status--${t.id}`}):null}function OYn(t){return f.jsx("div",{className:"pointer-events-none absolute inset-0 z-50 flex items-center justify-center",children:f.jsx("div",{"data-testid":"tab-switcher",className:"max-h-[60%] w-80 max-w-[90%] overflow-y-auto rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-lg",children:t.items.map((e,n)=>f.jsxs("div",{"aria-current":n===t.index,"data-testid":"tab-switcher__item",className:Ze("flex items-center gap-2 rounded-sm px-2 py-1.5 text-sm",n===t.index&&"bg-foreground/15 font-medium text-foreground"),children:[f.jsx(wYn,{item:e}),f.jsx("span",{className:"min-w-0 flex-1 truncate",children:e.title}),f.jsx(kYn,{item:e})]},e.id))})})}const SYn=1500,jH=/Mac|iPhone|iPad/.test(navigator.platform)?"⌘":"Ctrl",a8e="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-sm hover:bg-accent focus-visible:bg-accent focus-visible:outline-hidden";function CYn({worktreeId:t}){const[e,n]=v.useState(null),[r,o]=v.useState(!1);if(v.useEffect(()=>{const a=l=>{const c=l.detail;c.worktreeId===t&&(o(!1),n(c))};return window.addEventListener(OU,a),()=>window.removeEventListener(OU,a)},[t]),v.useEffect(()=>{if(!r)return;const a=window.setTimeout(()=>o(!1),SYn);return()=>window.clearTimeout(a)},[r]),!e)return null;const{url:i}=e,s=()=>n(null);return f.jsxs(t0,{open:!0,onOpenChange:a=>!a&&s(),children:[f.jsx(Lxe,{asChild:!0,children:f.jsx("span",{"aria-hidden":!0,className:"pointer-events-none fixed size-0",style:{left:e.x,top:e.y}})}),f.jsxs(n0,{align:"start",className:"w-80 p-1","data-testid":"terminal-link-popover","aria-label":"Link actions",onCloseAutoFocus:a=>{a.preventDefault(),e.focusTerminal()},children:[f.jsxs("div",{className:"flex items-center gap-1 px-2 py-1",children:[f.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-muted-foreground",title:i,"data-testid":"terminal-link-popover__url",children:i}),f.jsx("button",{type:"button","aria-label":r?"Copied":"Copy link","data-testid":"terminal-link-popover__copy",onClick:()=>{Vs(i).then(a=>o(a))},className:"rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground",children:r?f.jsx(Ji,{className:"size-3.5"}):f.jsx(z0,{className:"size-3.5"})})]}),CU(i)&&f.jsxs("button",{type:"button",className:a8e,"data-testid":"terminal-link-popover__open-band",onClick:()=>{s(),JFe({worktreeId:t,terminalId:e.terminalId,url:i})},children:[f.jsx(xu,{className:"size-4 shrink-0"}),f.jsx("span",{className:"flex-1",children:"Open in Band browser"}),f.jsxs("kbd",{className:"text-xs text-muted-foreground",children:[jH," Click"]})]}),f.jsxs("button",{type:"button",className:a8e,"data-testid":"terminal-link-popover__open-system",onClick:()=>{s(),N4(i)},children:[f.jsx(gM,{className:"size-4 shrink-0"}),f.jsx("span",{className:"flex-1",children:"Open in system browser"}),f.jsx("kbd",{className:"text-xs text-muted-foreground",children:CU(i)?`⇧ ${jH} Click`:`${jH} Click`})]})]})]})}function AYn(t,e){let n;const r=()=>{n?.dispose(),n=t.activePanel?.api.onDidTitleChange(e),e()},o=t.onDidActivePanelChange(r);return r(),{dispose(){o.dispose(),n?.dispose()}}}const EYn=v.lazy(()=>re(()=>import("./TerminalPanel-zm8MgtWD.js"),[]).then(t=>({default:t.TerminalPanel}))),TYn="band-layout--split",NW=new Map;function MYn({params:t,api:e}){const{visible:n}=Wh(),r=v.useCallback(i=>e.setTitle(i),[e]);if(!t.worktreeId||!t.terminalId)return null;const o=t.command||t.cwd||t.env?{command:t.command,cwd:t.cwd,env:t.env}:void 0;return f.jsx("div",{className:"flex h-full w-full flex-col overflow-hidden","data-testid":`term-pane__${t.terminalId}`,children:f.jsx(v.Suspense,{fallback:null,children:f.jsx(EYn,{worktreeId:t.worktreeId,terminalId:t.terminalId,visible:n,paneMetadata:o,autoFocus:t.autoFocus,onTitleChange:r})})})}function TZe(t){const e=t.containerApi.id,n=t.params.terminalId,r=s=>a=>{a.stopPropagation(),a.preventDefault();const l=NW.get(e)?.current;l&&s(l)},o=s=>s.stopPropagation(),i=Cn(s=>s.statuses.get(t.params.worktreeId)?.tabStatuses?.find(a=>a.terminalId===n)?.status);return f.jsxs("div",{className:"term-pane-header","data-testid":`term-pane-header__${n}`,children:[i?f.jsx("span",{className:"term-pane-header__status",children:f.jsx(bG,{status:i,testId:`term-pane__status--${n}`,withTitle:!0})}):null,f.jsxs("div",{className:"term-pane-header__actions","data-testid":`term-pane-actions__${n}`,children:[f.jsx("button",{type:"button",onMouseDown:o,onClick:r(s=>s.split(n,"right")),title:"Split right","aria-label":"Split right","data-testid":`term-pane-split-right__${n}`,children:f.jsx(U7e,{className:"size-3"})}),f.jsx("button",{type:"button",onMouseDown:o,onClick:r(s=>s.split(n,"below")),title:"Split down","aria-label":"Split down","data-testid":`term-pane-split-down__${n}`,children:f.jsx(Cit,{className:"size-3"})}),f.jsx("button",{type:"button",className:"term-pane-header__close",onMouseDown:o,onClick:r(s=>s.close(n)),title:"Close pane","aria-label":"Close pane","data-testid":`term-pane-close__${n}`,children:f.jsx(pa,{className:"size-3"})})]})]})}const PYn={pane:MYn},jYn={pane:TZe};function NYn(t){if(typeof t!="object"||t===null)return!1;const e=t;return typeof e.grid=="object"&&typeof e.panels=="object"}function RYn(t){const e=JSON.parse(JSON.stringify(t)),n=e?.panels;if(n)for(const r of Object.keys(n))n[r].params={};return e}function LYn(t,e){const n=JSON.parse(JSON.stringify(t)),r=n?.panels;if(r)for(const o of Object.keys(r))r[o].params={worktreeId:e,terminalId:o};return n}function NH(t,e,n,r){t.addPanel({id:e.terminalId,component:"pane",tabComponent:"pane",title:"Terminal",params:e,...n?{position:n}:{},...r?{inactive:!0}:{}})}function IYn({worktreeId:t,leafId:e,primaryTerminalId:n,command:r,cwd:o,env:i,autoFocus:s,visible:a,mobile:l,onActivePaneTitleChange:c,onCloseLeaf:u}){const d=v.useRef(null),h=v.useRef(null),p=v.useRef(!1),g=v.useRef(!1),_=v.useRef(null),x=v.useRef(null),y=v.useRef(c);y.current=c;const k=v.useRef(u);k.current=u;const O=v.useRef(a);O.current=a;const C=v.useCallback(()=>{if(l||p.current)return;x.current&&(clearTimeout(x.current),x.current=null);const Z=d.current;Z&&tMn(t,e,RYn(Z.toJSON()))},[t,e,l]),A=v.useCallback(()=>{l||p.current||(x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{x.current=null,C()},400))},[l,C]),E=v.useCallback(()=>{const Z=h.current,U=d.current;!Z||!U||Z.classList.toggle("band-layout-split--single",U.groups.length<=1)},[]),M=v.useRef(null),P=v.useCallback(()=>{const Z=d.current?.activePanel;y.current(Z?.title??"Terminal")},[]),L=v.useCallback(Z=>{const U=d.current;if(!U)return;if(U.panels.length<=1){k.current();return}QWe(U,Z);const B=U.getPanel(Z);B&&U.removePanel(B),yg(Z),Se.terminal.kill.mutate({terminalId:Z}).catch(()=>{}),NU(Z),requestAnimationFrame(()=>{U.activePanel?.element.querySelector(".xterm-helper-textarea")?.focus()})},[]),D=v.useRef(L);D.current=L;const I=v.useCallback((Z,U)=>{const B=d.current;if(!B||l)return;const ee=B.getPanel(Z)?.group?.id;if(!ee)return;const te=P5();tB(te,e),NH(B,{worktreeId:t,terminalId:te,autoFocus:!0},{referenceGroup:ee,direction:U}),Se.terminal.create.mutate({worktreeId:t,id:te}).catch(HS)},[t,e,l]),z=v.useRef(I);z.current=I;const Y=v.useCallback(Z=>{const U=d.current?.activePanel?.id;U&&I(U,Z)},[I]),Q=v.useCallback(()=>{if(g.current)return;const Z=d.current;if(!Z)return;const U=Z.groups.find(B=>B.panels.length>1);if(U){g.current=!0;try{for(const B of U.panels.slice(1)){const ee=Z.addGroup({referenceGroup:U,direction:"right"});B.api.moveTo({group:ee})}}catch{}finally{g.current=!1}}},[]),H=v.useCallback(Z=>{d.current=Z,NW.set(Z.id,{current:{close:ee=>D.current(ee),split:(ee,te)=>z.current(ee,te)}}),p.current=!0;const U=l?null:eMn(t,e);let B=!1;if(U&&NYn(U))try{Z.fromJSON(LYn(U,t)),B=Z.panels.length>0}catch{Z.clear()}Z.panels.length===0&&(NH(Z,{worktreeId:t,terminalId:n,command:r,cwd:o,env:i,autoFocus:s},void 0,!s),s||Z.getPanel(n)?.api.setActive());for(const ee of Z.panels)tB(ee.id,e);if(B&&(async()=>{try{const{terminals:ee}=await Se.terminal.list.query({worktreeId:t}),te=new Set(ee.map(se=>se.terminalId));for(const se of[...Z.panels])te.has(se.id)||(Z.removePanel(se),yg(se.id),NU(se.id));Z.panels.length===0&&(tB(n,e),NH(Z,{worktreeId:t,terminalId:n},void 0,!0),Z.getPanel(n)?.api.setActive(),Se.terminal.create.mutate({worktreeId:t,id:n}).catch(()=>{}))}catch{}})(),setTimeout(()=>{p.current=!1},0),_.current?.(),h.current&&(_.current=JTn(h.current,Z,e)),E(),P(),Z.onDidLayoutChange(()=>A()),Z.onDidAddPanel(()=>{Q(),E(),C()}),Z.onDidRemovePanel(()=>{E(),C()}),Z.onDidMovePanel(()=>{Q(),E(),C()}),Z.onDidAddGroup(E),Z.onDidRemoveGroup(E),M.current?.dispose(),M.current=AYn(Z,P),O.current&&h.current){const ee=h.current.getBoundingClientRect();ee.width>0&&ee.height>0&&Z.layout(Math.round(ee.width),Math.round(ee.height),!0)}},[t,e,n,r,o,i,s,l,A,C,E,P,Q]);v.useEffect(()=>{if(!a)return;const Z=()=>{d.current?.activePanel?.element.querySelector(".xterm-helper-textarea")?.focus()},U=B=>{if(!h.current?.contains(document.activeElement))return;const ee=d.current;if(!ee)return;const te=B.key.toLowerCase(),se=l?null:UWe(B,Y2());if(se){B.preventDefault(),B.stopPropagation(),Y(se);return}if(B.metaKey||B.ctrlKey){if(!B.shiftKey&&(te==="["||te==="]")){B.preventDefault(),B.stopPropagation(),wne(ee,te==="]"?1:-1,()=>requestAnimationFrame(Z));return}if(te==="w"&&!B.shiftKey){B.preventDefault(),B.stopPropagation(),ee.panels.length<=1?k.current():ee.activePanel&&D.current(ee.activePanel.id);return}te==="d"&&(B.ctrlKey&&!B.metaKey&&!B.shiftKey?ee.panels.length>1&&ee.activePanel&&(B.preventDefault(),B.stopPropagation(),D.current(ee.activePanel.id)):(B.metaKey||B.ctrlKey)&&(B.preventDefault(),B.stopPropagation()))}};return window.addEventListener("keydown",U,!0),()=>window.removeEventListener("keydown",U,!0)},[a,l,Y]),v.useEffect(()=>{if(l)return;const Z=U=>{const B=U.detail;B?.leafId===e&&Y(B.direction)};return window.addEventListener("band:split-terminal-pane",Z),()=>window.removeEventListener("band:split-terminal-pane",Z)},[e,l,Y]);const N=v.useRef(C);N.current=C,v.useEffect(()=>()=>{const Z=d.current;Z&&NW.delete(Z.id),_.current?.(),_.current=null,M.current?.dispose(),x.current&&N.current()},[]);const[V,G]=v.useState(!1);v.useLayoutEffect(()=>{if(!a){G(!1);return}const Z=d.current,U=h.current;if(!Z||!U){G(!0);return}let B=0,ee=0;const te=(he,fe)=>{const be=Math.round(he),me=Math.round(fe);be<=0||me<=0||be===B&&me===ee||(B=be,ee=me,Z.layout(be,me,!0))},se=U.getBoundingClientRect();te(se.width,se.height),G(!0);const ae=new ResizeObserver(he=>{const fe=he[0];fe&&te(fe.contentRect.width,fe.contentRect.height)});return ae.observe(U),()=>ae.disconnect()},[a]);const K=a&&V,q=v.useMemo(()=>({visible:K,wsActive:K}),[K]);return f.jsx("div",{ref:h,className:"flex h-full w-full flex-col overflow-hidden",children:f.jsx(Cne.Provider,{value:q,children:f.jsx(xZe,{kind:"split",className:TYn,components:PYn,tabComponents:jYn,defaultTabComponent:TZe,onReady:H,disableDnd:l,paneMode:!0})})})}const DYn={chat:Q_,term:xM,browser:xu},zYn={},v4="min-w-0 flex-1 truncate text-xs",Cg="flex min-w-0 flex-1 items-center gap-1.5",b4="band-layout-tab-root group flex w-full items-center gap-1.5",$Yn="absolute inset-0 inline-flex items-center justify-center rounded-sm transition-opacity hover:bg-accent";function BYn(t,e){return`${$Yn} ${t&&!e?"opacity-70 hover:opacity-100":"opacity-0 group-hover:opacity-100"}`}function Ag({isActive:t,indicator:e,onClose:n,closeTitle:r,closeTestId:o}){return f.jsxs("span",{className:"relative ml-0.5 inline-flex size-4 shrink-0 items-center justify-center",children:[e?f.jsx("span",{className:"inline-flex items-center justify-center transition-opacity group-hover:opacity-0",children:e}):null,f.jsx("button",{type:"button",className:BYn(t,!!e),onClick:n,title:r,"aria-label":r,"data-testid":o,children:f.jsx(pa,{className:"size-3"})})]})}function dy(t){const[e,n]=v.useState(t.isActive);return v.useEffect(()=>{const r=t.onDidActiveChange(o=>n(o.isActive));return()=>r.dispose()},[t]),e}function MZe(t,e){const[n,r]=v.useState(()=>t.getParameters().preview??e);return v.useEffect(()=>{const o=t.onDidParametersChange(()=>{r(t.getParameters().preview)});return()=>o.dispose()},[t]),n===!0}function RW(t,e){const n={...e,...t.getParameters()};n.preview!==!1&&t.updateParameters({...n,preview:!1})}const PZe="band-layout--center",HYn=`${PZe} band-layout--desktop`,FYn=`${PZe} band-layout--mobile`,iC=new Map;function Tf(t){return t?iC.get(t):void 0}function jZe(t,e){return t.panels.find(n=>n.api.component===e)}const LW=new Map;function Io(t){return t?LW.get(t)?.current:void 0}const sC=new Map,IW="band:leaf-header-actions-changed";function l8e(t){window.dispatchEvent(new CustomEvent(IW,{detail:t}))}function NZe(t,e,n){const r=v.useRef(e);r.current=e,v.useEffect(()=>{const o=r.current;return o?sC.set(t,o):sC.delete(t),l8e(t),()=>{sC.delete(t),l8e(t)}},[t,...n])}const c8e=new Map;function qYn(t){let e=c8e.get(t)??0;for(const n of VT(t)?.tabs??[]){if(!n.id.startsWith(`file:${eC}`))continue;const r=Number(n.id.slice(`file:${eC}`.length));Number.isInteger(r)&&(e=Math.max(e,r))}return e+=1,c8e.set(t,e),`${eC}${e}`}const VYn="band:dockview-layout-v9:",QYn=new Set(["chat","term","browser","file","diff"]);function DW(t){return`${VYn}${t}`}function UYn(t,e,n){const r=JSON.parse(JSON.stringify(t)),o=r.panels;if(o)for(const[i,s]of Object.entries(o)){const a=s.contentComponent;a==="chat"?s.params={worktreeId:e,chatId:i}:a==="term"?s.params={worktreeId:e,terminalId:i}:a==="browser"?(s.params={worktreeId:e,browserId:i,initialUrl:n.get(i)},s.renderer="always"):a==="file"||a==="diff"?s.params=RZe(a,i,e):s.params={worktreeId:e}}return r}function RZe(t,e,n){if(t==="file")return{worktreeId:n,filePath:e.slice(5)};const r=KYn.exec(e),o=JYn.exec(e);return r?{worktreeId:n,filePath:r[2],commit:r[1]}:o?{worktreeId:n,filePath:"",allOf:o[1]}:{worktreeId:n,filePath:e.slice(5)}}function fy(t){const e=t.groups[0];return e?{referenceGroup:e.id}:{direction:"within"}}function DO(t){const e=t.activeGroup;return e?{referenceGroup:e.id}:fy(t)}function WYn(t){const e=t.groups;if(e.length<=1)return;const n=e[0];for(const r of e.slice(1))for(const o of[...r.panels])try{o.api.moveTo({group:n})}catch{}}function ZYn(t){try{const e=localStorage.getItem(DW(t));if(!e)return null;const n=JSON.parse(e);return rYn(n)?n:null}catch{return null}}let zO=null,u8e=0;const GYn=5e3;function YYn(){const t=Date.now();return(!zO||t-u8e>GYn)&&(u8e=t,zO=Se.settings.get.query().catch(()=>(zO=null,null))),zO}function XYn(t){return["worktreeCenterLayout",t]}const KYn=/^diff@([0-9a-f]{7,40}):(.+)$/i,JYn=/^diffs:(conflicts|unstaged|staged|untracked|branch)$/;function eXn(t,e){return`diff@${t}:${e}`}function tXn(t){return`diffs:${t}`}function nXn({params:t,api:e}){const[n,r]=v.useState(e.isActive),{visible:o,wsActive:i,worktreeId:s}=Wh(),a=s??t.worktreeId;return v.useEffect(()=>{const l=e.onDidActiveChange(c=>r(c.isActive));return()=>l.dispose()},[e]),!a||!t.chatId?null:f.jsx(rXn,{worktreeId:a,chatId:t.chatId,visible:o&&n,wsActive:i,setTitle:l=>e.setTitle(l)})}function rXn({worktreeId:t,chatId:e,visible:n,wsActive:r,setTitle:o}){const i=NGn(t,e),s=v.useRef(o);return s.current=o,v.useEffect(()=>{if(!i.sessionQueryDone)return;const a=zQn({name:i.chatName,summary:i.activeSessionSummary,agentLabel:i.agentLabel,agentId:i.codingAgentId});s.current(a)},[i.sessionQueryDone,i.chatName,i.activeSessionSummary,i.agentLabel,i.codingAgentId]),f.jsx("div",{className:"flex h-full w-full flex-col overflow-hidden outline-none",tabIndex:-1,"data-band-leaf-root":"","data-testid":`center-chat-leaf__visible-${n?"true":"false"}`,children:f.jsx(RGn,{worktreeId:t,chatId:e,visible:n,wsActive:r,state:i})})}function oXn({params:t,api:e,containerApi:n}){const{visible:r,worktreeId:o}=Wh(),[i,s]=v.useState(e.isVisible);v.useEffect(()=>{const p=e.onDidVisibilityChange(g=>s(g.isVisible));return()=>p.dispose()},[e]);const a=r&&i,l=v.useCallback(p=>e.setTitle(p),[e]),c=o??t.worktreeId,u=t.terminalId,d=v.useCallback(()=>{c&&u&&Io(c)?.onClose(u,"term")},[c,u]),h=F_.has(n.id);return!c||!u?null:f.jsx("div",{className:"flex h-full w-full flex-col overflow-hidden outline-none",tabIndex:-1,"data-band-leaf-root":"","data-testid":`center-term-leaf__visible-${a?"true":"false"}`,children:f.jsx(IYn,{worktreeId:c,leafId:u,primaryTerminalId:u,command:t.command,cwd:t.cwd,env:t.env,autoFocus:t.autoFocus,visible:a,mobile:h,onActivePaneTitleChange:l,onCloseLeaf:d})})}function iXn({params:t,api:e}){const{visible:n,worktreeId:r}=Wh(),o=r??t.worktreeId;if(!o||!t.browserId)return null;const i={worktreeId:o,browserId:t.browserId,wsActive:n,initialUrl:t.initialUrl};return f.jsx("div",{className:"flex h-full w-full flex-col overflow-hidden outline-none",tabIndex:-1,"data-band-leaf-root":"","data-testid":`center-browser-leaf__visible-${n?"true":"false"}`,children:f.jsx(BUn,{params:i,api:e})})}function R0(t){const e=t.split(/[\\/]/);return e[e.length-1]||t}const Tne=t=>`band-tab-state:${t}`;function T8(t){try{const e=localStorage.getItem(Tne(t));if(!e)return{};const n=JSON.parse(e);return typeof n!="object"||n===null?{}:sXn(t,n)}catch{return{}}}function sXn(t,e){let n=!1;for(const[r,o]of Object.entries(e))!o||typeof o!="object"||("editorState"in o&&(delete o.editorState,n=!0),"editedContent"in o&&(typeof o.editedContent=="string"&&Eg(t,r)===null&&Tg(t,r,o.editedContent),delete o.editedContent,n=!0));return n&&rR(t,e),e}let d8e=!1;function aXn(){if(!d8e){d8e=!0;try{const t=Tne(""),e=[];for(let n=0;n<localStorage.length;n++){const r=localStorage.key(n);r?.startsWith(t)&&e.push(r)}for(const n of e){const r=localStorage.getItem(n);!r?.includes('"editorState"')&&!r?.includes('"editedContent"')||T8(n.slice(t.length))}}catch{}}}function rR(t,e){try{Hn.setItem(Tne(t),JSON.stringify(e))}catch{}}function $O(t,e){return T8(t)[e]}function Cv(t,e,n){const r=T8(t);r[e]={...r[e]??{},...n},rR(t,r)}const lXn="band-unsaved:",B_=(t,e)=>`${lXn}${t}:${e}`;function Eg(t,e){return Hn.getItem(B_(t,e))}function Tg(t,e,n){n===null?Hn.removeItem(B_(t,e)):Hn.setItem(B_(t,e),n)}const zW=new Set,$W=(t,e)=>`${t}\0${e}`;function Mne(t,e){return zW.has($W(t,e))}function H_(t,e,n){n?zW.add($W(t,e)):zW.delete($W(t,e))}function KT(t,e){return T8(t),Eg(t,e)!==null}const BW=new Set,HW=(t,e)=>`${t}\0${e}`;function FW(t,e){const n=T8(t);e in n&&(delete n[e],rR(t,n)),Eg(t,e)!==null&&Tg(t,e,null),H_(t,e,!1)}function LZe(t,e,n=!1){const r=v.useRef(null),o=v.useRef([]),i=v.useCallback(()=>o.current,[]),s=v.useMemo(()=>e?u=>$1.onFindInFile(t,u):null,[e,t]),a=iSn({getViews:i,onFindInFile:s,registerGlobalFindKey:!1}),l=v.useCallback(u=>{o.current=u,u.length>0&&a.dispatchToViews(u)},[a.dispatchToViews]);v.useEffect(()=>{if(!e)return;const u=d=>{!(d.metaKey||d.ctrlKey)||d.shiftKey||d.key.toLowerCase()!=="f"||r.current?.contains(document.activeElement)&&(d.preventDefault(),d.stopPropagation(),a.handleOpenSearch())};return window.addEventListener("keydown",u,!0),()=>window.removeEventListener("keydown",u,!0)},[e,a.handleOpenSearch]);const c=a.searchOpen?f.jsx(cN,{ref:a.searchBarRef,variant:"floating",query:a.searchQuery,onQueryChange:a.setSearchQuery,options:a.searchOptions,onOptionsChange:a.setSearchOptions,placeholder:n?"Find in preview...":"Find in file...",matchInfo:a.matchInfo,onNext:a.handleNext,onPrevious:a.handlePrevious,onClose:a.handleCloseSearch}):void 0;return{containerRef:r,setViews:l,searchBar:c}}const cXn={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",mts:"typescript",cts:"typescript",mjs:"javascript",cjs:"javascript"};function f8e(t){const e=t.split(".").pop()?.toLowerCase();return e?cXn[e]:void 0}function IZe(t,e,n,r){const{settings:o}=Qh(),i=Gx(t),[s,a]=v.useState(null),l=HWe(t),c=v.useMemo(()=>{if(!o.enableLSP||l||n)return null;const d=f8e(e);return d?XCn(d):null},[e,n,o.enableLSP,l]),u=v.useMemo(()=>c?cAn(t,c):null,[t,c]);return v.useEffect(()=>{if(a(null),!u||!i)return;let d=!1;const h=f8e(e),p=r(u,K3e(i),K3e(i,e),h&&uAn(h)||"",t);return p.then(g=>{d||a(g)}).catch(g=>console.warn("[leaf] LSP extension creation failed:",g)),()=>{d=!0,p.then(()=>tAn(u),()=>{})}},[u,i,e,t,r]),s}function DZe(t,e,n,r){const[o,i]=v.useState(t.isActive);v.useEffect(()=>{const s=t.onDidActiveChange(a=>i(a.isActive));return()=>s.dispose()},[t]),v.useEffect(()=>{!r||!o||!e||!n||VMn(e,{currentFile:n})},[r,o,e,n])}function uXn(t){const{worktreeId:e}=Wh(),n=t.params.filePath??"";return ZWe(n)?f.jsx(vYn,{worktreeId:e??t.params.worktreeId??"",filePath:n}):f.jsx(dXn,{...t})}function dXn({params:t,api:e}){const{visible:n,worktreeId:r}=Wh(),o=r??t.worktreeId??"",i=t.filePath??"",[s,a]=v.useState(()=>$O(o,i)?.viewMode),l=Uee(i)==="markdown"&&s!=="source",{containerRef:c,setViews:u,searchBar:d}=LZe(o,n,l);DZe(e,o,i,n);const h=Gs(),p=t.untitled===!0||$Qn(i),g=p?!1:t.external??i.startsWith("/"),_=IZe(o,i,g||p,aAn),x=HWe(o),y=Gx(o),[k,O]=v.useState(!1),[C,A]=v.useState(()=>$O(o,i)?.language),[E,M]=v.useState(null),[P,L]=v.useState(0),[D,I]=v.useState(!1),z=v.useRef(null),Y=v.useRef(!1),Q=v.useCallback(()=>{H_(o,i,!1);const me=H.current;if(!me){L(Be=>Be+1);return}const le=Eg(o,i);Y.current=!0;try{if(le===null)L(Be=>Be+1);else{const Be=Math.min(me.state.selection.main.head,le.length);me.dispatch({changes:{from:0,to:me.state.doc.length,insert:le},selection:{anchor:Be}})}}finally{Y.current=!1}},[o,i]);v.useEffect(()=>{if(!o||!i)return;const me=B_(o,i);return bA(le=>{le.key===me&&(Mne(o,i)?I(!0):Q())})},[o,i,Q]);const H=v.useRef(null),N=v.useCallback(me=>{if(H.current=me,u(me?[me]:[]),V.current?.(),V.current=null,me){const le=me.scrollDOM;let Be=0;const Xe=()=>{Be||(Be=requestAnimationFrame(()=>{Be=0,K.current()}))};le.addEventListener("scroll",Xe,{passive:!0});let ot=0;const Qe=bt=>{const ve=$O(o,i)?.scrollTop;!ve||le.clientHeight===0||(le.scrollTop=ve,Math.abs(le.scrollTop-ve)>1&&bt<30&&(ot=requestAnimationFrame(()=>Qe(bt+1))))},lt=new ResizeObserver(()=>{le.clientHeight>0&&le.scrollTop===0&&(cancelAnimationFrame(ot),Qe(0))});lt.observe(le),V.current=()=>{le.removeEventListener("scroll",Xe),cancelAnimationFrame(Be),lt.disconnect(),cancelAnimationFrame(ot)}}},[u,o,i]),V=v.useRef(null),G=v.useCallback(()=>{const me=H.current;if(!(!me||me.scrollDOM.clientHeight===0))try{const{selection:le,scrollTop:Be}=lIt(me);Cv(o,i,{selection:le,scrollTop:Be})}catch{}},[o,i]),K=v.useRef(G);K.current=G,v.useEffect(()=>{const me=()=>K.current();return window.addEventListener("pagehide",me),()=>{window.removeEventListener("pagehide",me),!BW.delete(HW(o,i))&&K.current()}},[o,i]);const q=h.pickSaveFile,Z=v.useCallback(async me=>{if(!q)return null;const le=await q({content:me,defaultPath:y??void 0});if(!le)return null;const Be=le.replace(/\\/g,"/"),Xe=y!=null?GQn(y,Be):null,ot=Xe===null,Qe=Xe??Be,lt=Io(o);return FW(o,i),lt?.openFile(Qe,{external:ot,preview:!1}),lt?.onClose(`file:${i}`,"file"),window.dispatchEvent(new CustomEvent("band:dirty-change")),Be},[q,y,o,i]),U=!p&&!g,B=Xx(o,{enabled:U&&n,refetchInterval:n?15e3:!1}),ee=U&&!!RFe(B.data,i),te=B.refetch,se=v.useRef(!1),ae=E?.isDirty??!1;if(v.useEffect(()=>{se.current&&!ae&&U&&te(),se.current=ae},[ae,U,te]),NZe(e.id,o&&i?()=>f.jsxs("div",{className:"flex items-center gap-0.5",children:[(E?.showMarkdownToggle||E?.showVisualToggle)&&f.jsxs(f.Fragment,{children:[f.jsx("button",{type:"button",onClick:()=>{a("preview"),Cv(o,i,{viewMode:"preview"})},title:E?.showVisualToggle?"Visual":"Preview","data-testid":"center-file-leaf__view--preview",className:`inline-flex size-7 items-center justify-center rounded transition-colors hover:bg-accent ${(E?.showVisualToggle?s==="preview":s!=="source")?"bg-accent text-foreground":"text-muted-foreground"}`,children:f.jsx(pZ,{className:"size-3.5"})}),E?.showVisualToggle&&s==="preview"&&f.jsx("button",{type:"button",onClick:()=>O(me=>!me),"aria-pressed":k,title:"Edit text","data-testid":"center-file-leaf__html-edit",className:`inline-flex size-7 items-center justify-center rounded transition-colors hover:bg-accent ${k?"bg-accent text-foreground":"text-muted-foreground"}`,children:f.jsx(y4,{className:"size-3.5"})}),f.jsx("button",{type:"button",onClick:()=>{a("source"),Cv(o,i,{viewMode:"source"})},title:"Source","data-testid":"center-file-leaf__view--source",className:`inline-flex size-7 items-center justify-center rounded transition-colors hover:bg-accent ${(E?.showVisualToggle?s!=="preview":s==="source")?"bg-accent text-foreground":"text-muted-foreground"}`,children:f.jsx(Q7e,{className:"size-3.5"})}),E?.showMarkdownToggle&&s!=="source"&&f.jsx(sYn,{})]}),On&&!g&&!p&&BHe(i)&&f.jsx("button",{type:"button",onClick:()=>zOn({worktreeId:o,path:i}),title:"Preview in a browser tab","data-testid":"center-file-leaf__html-preview",className:"inline-flex size-7 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:f.jsx(xu,{className:"size-3.5"})}),E?.canSave&&E.isDirty&&f.jsx("button",{type:"button",onClick:()=>E.save(),disabled:E.saving,title:"Save (Cmd+S)","data-testid":"center-file-leaf__save",className:"inline-flex size-7 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-50",children:E.saving?f.jsx(Fo,{className:"size-3.5 animate-spin"}):f.jsx(eve,{className:"size-3.5"})}),ee&&f.jsx("button",{type:"button",onClick:()=>Io(o)?.openDiff(i,{preview:!1}),title:"View changes","data-testid":"center-file-leaf__view-diff",className:"inline-flex size-7 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:f.jsx(B2,{className:"size-3.5"})})]}):null,[E,s,k,ee,o,i]),!t.worktreeId||!t.filePath)return null;const he=t.worktreeId,fe=t.filePath,be=$O(he,fe);return f.jsxs("div",{ref:c,tabIndex:-1,"data-band-leaf-root":"",className:"flex h-full w-full flex-col overflow-hidden outline-none","data-testid":`center-file-leaf__visible-${n?"true":"false"}`,children:[D&&f.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border bg-muted px-3 py-1.5 text-xs","data-testid":"center-file-leaf__remote-edit",children:[f.jsx("span",{className:"min-w-0 flex-1",children:"Another device changed the unsaved edits to this file."}),f.jsx(Ce,{size:"sm",variant:"outline","data-testid":"center-file-leaf__remote-edit-load",onClick:()=>{I(!1),Q(),window.dispatchEvent(new CustomEvent("band:dirty-change"))},children:"Load theirs"}),f.jsx(Ce,{size:"sm",variant:"ghost","data-testid":"center-file-leaf__remote-edit-keep",onClick:()=>{I(!1),Tg(he,fe,z.current),window.dispatchEvent(new CustomEvent("band:dirty-change"))},children:"Keep mine"})]}),f.jsx(KOn,{worktreeId:he,filePath:fe,line:t.line,column:t.column,editable:!0,external:g,untitled:p,lspExtension:_,watchFileChanges:!x,onSaveAs:p&&q?Z:void 0,hideTitleBar:!0,onActionsChange:M,onLoadError:me=>{/ENOENT|no such file|not found/i.test(me.message)&&(FW(he,fe),Io(he)?.onClose(`file:${fe}`,"file"))},renderMarkdownBlock:dYn,htmlVisual:!0,htmlEditing:k,onEditorView:N,overlay:d,savedSelection:be?.selection,savedScrollTop:be?.scrollTop,initialEditedContent:Eg(he,fe),onEditedContentChange:me=>{Y.current||(I(!1),z.current=me,H_(he,fe,me!==null),Tg(he,fe,me))},viewMode:s,onViewModeChange:me=>{a(me),Cv(he,fe,{viewMode:me})},languageOverride:C,onLanguageOverrideChange:me=>{A(me??void 0),Cv(he,fe,{language:me})}},P)]})}const h8e=99999;function fXn(t){return t.params.allOf?f.jsx(mXn,{...t,section:t.params.allOf}):f.jsx(pXn,{...t})}function hXn(t){return t==="unstaged"||t==="staged"||t==="untracked"?t:null}function pXn({params:t,api:e,containerApi:n}){const r=F_.has(n.id),{visible:o}=Wh(),{worktreeId:i,filePath:s,commit:a}=t,l=Rn(),{containerRef:c,setViews:u,searchBar:d}=LZe(i??"",o),h=Xx(i??"",{enabled:!!s&&!a,refetchInterval:o?15e3:!1}),p=RFe(h.data,s),_=!!t.section&&!!h.data?.[t.section].some(G=>G.path===s)||!p?t.section:p.section,x=(_===t.section?t.oldPath:void 0)??(_?h.data?.[_].find(G=>G.path===s)?.oldPath:void 0),y=_==="branch"?h.data?.mergeBase??void 0:void 0;DZe(e,i??"",a?"":s??"",o);const k=IZe(i??"",s??"",!!a||_==="staged"||_==="branch",lAn),[O,C]=v.useState(()=>xOn()),[A,E]=v.useState(!1),M=v.useRef(null),[P,L]=v.useState([]),D=v.useCallback(G=>{u(G),L(G)},[u]),I=v.useCallback(G=>{C(G),yOn(G)},[]),z=It({queryKey:["diffLeafFile",i,s,_,y,x],queryFn:()=>Se.worktree.getFileDiff.query({worktreeId:i,filePath:s,section:_??"unstaged",mergeBase:y,oldPath:x,contextLines:h8e}),enabled:!!i&&!!s&&!!_&&(_!=="branch"||!!y)&&!a,refetchInterval:See(o?1e4:!1)}),Y=It({queryKey:["diffLeafCommitFile",i,a,s],queryFn:()=>Se.worktree.getCommitFileDiff.query({worktreeId:i,sha:a??"",filePath:s,contextLines:h8e}),enabled:!!i&&!!s&&!!a,staleTime:Number.POSITIVE_INFINITY}),Q=a?null:hXn(_),H=Q!==null;if(NZe(e.id,i&&s?()=>f.jsxs("div",{className:"flex items-center gap-0.5",children:[!r&&f.jsxs(f.Fragment,{children:[f.jsx("button",{type:"button",onClick:()=>I("unified"),"aria-pressed":O==="unified",title:"Unified view","data-testid":"center-diff-leaf__view--unified",className:`inline-flex size-7 items-center justify-center rounded transition-colors hover:bg-accent ${O==="unified"?"bg-accent text-foreground":"text-muted-foreground"}`,children:f.jsx(Fit,{className:"size-3.5"})}),f.jsx("button",{type:"button",onClick:()=>I("split"),"aria-pressed":O==="split",title:"Side-by-side view","data-testid":"center-diff-leaf__view--split",className:`inline-flex size-7 items-center justify-center rounded transition-colors hover:bg-accent ${O==="split"?"bg-accent text-foreground":"text-muted-foreground"}`,children:f.jsx(U7e,{className:"size-3.5"})})]}),!a&&f.jsx("button",{type:"button",onClick:()=>Io(i)?.openFile(s,{preview:!1}),title:"Open file for editing","data-testid":"center-diff-leaf__open-file",className:"inline-flex size-7 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:f.jsx(Lit,{className:"size-3.5"})}),H&&f.jsx("button",{type:"button",onClick:()=>E(!0),title:"Revert file","data-testid":"center-diff-leaf__revert",className:"inline-flex size-7 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:f.jsx(kit,{className:"size-3.5"})})]}):null,[O,i,s,H,a]),!i||!s)return null;const N=a?Y.data?.diff:z.data?.diff,V=a?Y.isLoading:h.isLoading||z.isLoading;return f.jsxs("div",{ref:c,className:"flex h-full w-full flex-col overflow-hidden outline-none",tabIndex:-1,"data-band-leaf-root":"","data-testid":`center-diff-leaf__visible-${o?"true":"false"}`,children:[f.jsxs("div",{className:"relative min-h-0 flex-1",children:[d,f.jsx("div",{ref:M,tabIndex:-1,"data-band-leaf-focus":"","data-testid":"center-diff-leaf__scroller",className:`h-full overflow-auto outline-none ${N?"pr-3 [scrollbar-width:none]":""}`,children:N?f.jsx(IHe,{hunks:N,filename:s,viewMode:r?"unified":O,onEditorViews:D,lspNavigation:k}):f.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:V?"Loading diff…":a&&Y.isError?Y.error instanceof Error?Y.error.message:"Failed to load the diff":"No changes"})}),N&&f.jsx(POn,{views:P,scrollerRef:M})]}),f.jsx(nr,{open:A,onOpenChange:E,children:f.jsxs(rr,{children:[f.jsxs(hr,{children:[f.jsx(or,{children:"Revert file"}),f.jsxs(Nr,{children:["Discard the changes to ",f.jsx("span",{className:"font-mono",children:R0(s)}),"?"," ",Q&&YFe(Q)]})]}),f.jsxs(ii,{children:[f.jsx(Ce,{variant:"ghost",onClick:()=>E(!1),children:"Cancel"}),f.jsx(Ce,{variant:"destructive","data-testid":"center-diff-leaf__revert-confirm",onClick:()=>{Q&&Se.worktree.discardChanges.mutate({worktreeId:i,section:Q,paths:Q==="staged"&&x?[s,x]:[s]}).then(()=>{E(!1),z.refetch(),NFe(l,i)}).catch(G=>console.error("[DiffLeaf] revert failed:",G))},children:"Revert"})]})]})})]})}function mXn({params:t,section:e}){const{worktreeId:n}=t,{visible:r}=Wh(),o=Xx(n,{refetchInterval:r?15e3:!1}),i=o.data?.[e]??[],s=o.data?.mergeBase??void 0;return f.jsx("div",{className:"h-full w-full overflow-auto outline-none",tabIndex:-1,"data-band-leaf-focus":"","data-testid":`center-section-diffs--${e}`,children:i.length===0?f.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:o.isLoading?"Loading diff…":"No changes"}):i.map(a=>f.jsx(gXn,{worktreeId:n,section:e,entry:a,mergeBase:s},a.path))})}function gXn({worktreeId:t,section:e,entry:n,mergeBase:r}){const o=v.useRef(null),[i,s]=v.useState(!1),[a,l]=v.useState(!1);v.useEffect(()=>{const d=o.current;if(!d||i)return;const h=new IntersectionObserver(p=>{p.some(g=>g.isIntersecting)&&s(!0)},{rootMargin:"600px 0px"});return h.observe(d),()=>h.disconnect()},[i]);const c=It({queryKey:["sectionDiffFile",t,e,n.path,n.oldPath,r,n.additions,n.deletions],queryFn:()=>Se.worktree.getFileDiff.query({worktreeId:t,filePath:n.path,section:e,mergeBase:e==="branch"?r:void 0,oldPath:n.oldPath}),enabled:i&&(e!=="branch"||!!r)}),u=a?bo:Pi;return f.jsxs("div",{ref:o,className:"border-b border-border","data-testid":`center-section-diffs__file--${n.path}`,children:[f.jsxs("div",{className:"sticky top-0 z-10 flex h-8 items-center gap-1.5 border-b border-border bg-background px-2 text-xs",children:[f.jsxs("button",{type:"button",onClick:()=>l(d=>!d),"aria-expanded":!a,className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[f.jsx(u,{className:"size-3.5 shrink-0 text-muted-foreground"}),f.jsx("span",{className:"truncate font-medium",title:n.path,children:n.oldPath?`${n.oldPath} → ${n.path}`:n.path}),!!n.additions&&f.jsxs("span",{className:"shrink-0 text-success",children:["+",n.additions]}),!!n.deletions&&f.jsxs("span",{className:"shrink-0 text-danger",children:["-",n.deletions]})]}),f.jsx("button",{type:"button",title:"Open diff","data-testid":"center-section-diffs__open",onClick:()=>Io(t)?.openDiff(n.path,{preview:!1,section:e,oldPath:n.oldPath}),className:"inline-flex size-6 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground",children:f.jsx(B2,{className:"size-3.5"})})]}),!a&&(c.data?.diff?f.jsx(IHe,{hunks:c.data.diff,filename:n.path,viewMode:"unified"}):f.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:c.data?"No textual changes":"Loading diff…"}))]})}const xh=new Map,F_=new Set;function zZe(t){const e=t.api.component,n=DYn[e],r=zYn[e],[o,i]=v.useState(t.api.title??""),[s,a]=v.useState(t.params?.badge);v.useEffect(()=>{const u=t.api.onDidTitleChange(()=>i(t.api.title??""));return()=>u.dispose()},[t.api]),v.useEffect(()=>{const u=t.api.onDidParametersChange(()=>{a(t.api.getParameters().badge)});return()=>u.dispose()},[t.api]);const l=s!=null&&s>0,c=f.jsxs("div",{className:b4,"data-testid":`center-tab--${e}`,children:[n?f.jsx(n,{className:"size-4 shrink-0"}):f.jsx("span",{className:"inline-block size-4 shrink-0","aria-hidden":!0}),f.jsx("span",{className:v4,children:o}),l&&f.jsx("span",{className:"inline-flex h-5 min-w-5 shrink-0 items-center justify-center rounded-full bg-info-bg px-1.5 text-xs font-medium text-info",children:s})]});return r?f.jsxs(Or,{children:[f.jsx(Sr,{asChild:!0,children:c}),f.jsxs(Cr,{children:[o," (",r,")"]})]}):c}const vXn=new Set(["claude-code","codex","opencode"]);function bXn(t){const e=t.params.chatId,n=t.params.worktreeId,r=Ene(e),[o,i]=v.useState(r.title??t.api.title??"Chat"),[s,a]=v.useState(r.agentType),[l,c]=v.useState(void 0),u=dy(t.api),d=AZe(n,e);v.useEffect(()=>{const M=t.api.onDidTitleChange(()=>{const P=t.api.title??"Chat";i(P),s8e(e,{title:P})});return()=>M.dispose()},[t.api,e]);const h=v.useRef(!0);v.useEffect(()=>()=>{h.current=!1},[]);const p=v.useRef([]),g=v.useRef(void 0),_=v.useCallback(M=>{if(!h.current)return;c(M?.activeSessionId??void 0);const P=M?.agent??g.current??"",L=p.current.find(D=>D.id===P);L&&(a(L.type),s8e(e,{agentType:L.type}))},[e]),x=v.useCallback(()=>{!e||!n||Promise.all([YYn(),Se.chats.get.query({chatId:e}).catch(()=>({chat:null}))]).then(([M,P])=>{if(!h.current)return;const L=M?.codingAgents;p.current=Array.isArray(L)?L:[],g.current=M?.defaultCodingAgent,_(P.chat)}).catch(()=>{})},[e,n,_]),y=v.useCallback(()=>{e&&Se.chats.get.query({chatId:e}).then(M=>_(M.chat)).catch(()=>{})},[e,_]);v.useEffect(()=>{x()},[x]);const k=!!l&&!!s&&vXn.has(s),O=v.useCallback(()=>{Se.chats.continueInTerminal.mutate({chatId:e}).then(()=>$1.onActivateTerminalPanel(n)).catch(M=>console.error("[ChatTab] continue in terminal failed:",M))},[e,n]),C=v.useCallback(()=>{l&&Vs(l)},[l]),A=t.containerApi,E=v.useCallback(M=>{M.stopPropagation(),xh.get(A.id)?.current?.onClose(e,"chat")},[A,e]);return f.jsxs(J0,{onOpenChange:M=>M&&y(),children:[f.jsx(e1,{asChild:!0,children:f.jsxs("div",{className:b4,"data-testid":`center-chat-tab--${e}`,children:[f.jsxs("div",{className:Cg,children:[f.jsx("span",{className:"inline-flex size-3.5 shrink-0 items-center justify-center transition-opacity duration-150",style:{opacity:s?1:0},children:s&&f.jsx(D3,{type:s,className:"size-3.5"})}),f.jsx("span",{className:v4,title:o,children:o})]}),f.jsx(Ag,{isActive:u,indicator:d&&f.jsx(Ane,{status:d,testId:`center-chat-tab__status--${e}`}),onClose:E,closeTitle:"Close tab"})]})}),f.jsxs(t1,{"data-testid":"center-chat-tab__context-menu",children:[f.jsxs(Qn,{disabled:!k,onClick:O,"data-testid":"center-chat-tab__context-menu-item--continue-in-terminal",children:[f.jsx(_M,{className:"size-4"}),"Continue in terminal"]}),f.jsxs(Qn,{disabled:!l,onClick:C,"data-testid":"center-chat-tab__context-menu-item--copy-session-id",children:[f.jsx(Kf,{className:"size-4"}),"Copy session ID"]})]})]})}function _Xn(t){const[e,n]=v.useState(t.api.title??"Terminal"),r=t.params.terminalId,o=t.containerApi,i=dy(t.api),s=EZe(t.params.worktreeId,r);v.useEffect(()=>{const c=t.api.onDidTitleChange(()=>n(t.api.title??"Terminal"));return()=>c.dispose()},[t.api]);const a=v.useCallback(c=>{c.stopPropagation(),xh.get(o.id)?.current?.onClose(r,"term")},[o,r]),l=v.useCallback(()=>{Vs(r)},[r]);return f.jsxs(J0,{children:[f.jsx(e1,{asChild:!0,children:f.jsxs("div",{className:b4,"data-testid":`center-term-tab--${r}`,children:[f.jsxs("div",{className:Cg,children:[f.jsx(_M,{className:"size-3.5 shrink-0 text-muted-foreground"}),f.jsx("span",{className:v4,title:e,children:e})]}),f.jsx(Ag,{isActive:i,indicator:s&&f.jsx(Ane,{status:s,testId:`center-term-tab__status--${r}`}),onClose:a,closeTitle:"Close terminal"})]})}),f.jsx(t1,{"data-testid":"center-term-tab__context-menu",children:f.jsxs(Qn,{onClick:l,"data-testid":"center-term-tab__context-menu-item--copy-terminal-id",children:[f.jsx(Kf,{className:"size-4"}),"Copy terminal ID"]})})]})}function xXn(t){const[e,n]=v.useState(t.api.title??"New Tab"),[r,o]=v.useState(!1),i=t.params.browserId,s=t.containerApi,a=dy(t.api),l=zUn(i),c=v.useRef(l);l!==c.current&&(c.current=l,r&&o(!1)),v.useEffect(()=>{const h=t.api.onDidTitleChange(()=>n(t.api.title??"New Tab"));return()=>h.dispose()},[t.api]);const u=v.useCallback(h=>{h.stopPropagation(),xh.get(s.id)?.current?.onClose(i,"browser")},[s,i]),d=l&&!r;return f.jsxs("div",{className:b4,"data-testid":`center-browser-tab--${i}`,children:[f.jsxs("div",{className:Cg,children:[d?f.jsx("img",{src:l,alt:"",className:"size-3.5 shrink-0",onError:()=>o(!0)}):f.jsx(xu,{className:"size-3.5 shrink-0 text-muted-foreground"}),f.jsx("span",{className:v4,title:e,children:e})]}),f.jsx(Ag,{isActive:a,onClose:u,closeTitle:"Close tab"})]})}function $Ze({worktreeId:t,filePath:e,testidPrefix:n,children:r}){const o=Gx(t),s=e.startsWith("/")?e:o?`${o.replace(/\/+$/,"")}/${e}`:null;return f.jsxs(J0,{children:[f.jsx(e1,{asChild:!0,children:r}),f.jsxs(t1,{"data-testid":`${n}__context-menu`,children:[f.jsxs(Qn,{onClick:()=>{Vs(e)},"data-testid":`${n}__context-menu-item--copy-relative-path`,children:[f.jsx(Kf,{className:"size-4"}),"Copy relative path"]}),f.jsxs(Qn,{disabled:!s,onClick:()=>s&&void Vs(s),"data-testid":`${n}__context-menu-item--copy-absolute-path`,children:[f.jsx(Kf,{className:"size-4"}),"Copy absolute path"]})]})]})}function yXn(t){const{worktreeId:e,filePath:n}=t.params,r=t.containerApi,o=dy(t.api),i=MZe(t.api,t.params.preview),s=R0(n),a=U2(s),[l,c]=v.useState(()=>KT(e,n)),u=t.api,d=t.params;v.useEffect(()=>{const p=()=>{const g=KT(e,n);c(g),g&&RW(u,d)};return window.addEventListener("band:dirty-change",p),()=>window.removeEventListener("band:dirty-change",p)},[e,n,u,d]);const h=v.useCallback(p=>{p.stopPropagation(),xh.get(r.id)?.current?.onClose(`file:${n}`,"file")},[r,n]);return f.jsx($Ze,{worktreeId:e,filePath:n,testidPrefix:`center-file-tab--${n}`,children:f.jsxs("div",{className:b4,"data-testid":`center-file-tab--${n}`,onDoubleClick:()=>RW(u,d),children:[f.jsxs("div",{className:Cg,children:[f.jsx(a,{className:"size-3.5 shrink-0 text-muted-foreground"}),f.jsx("span",{className:`${v4}${i?" italic":""}`,title:n,children:s})]}),f.jsx(Ag,{isActive:o,indicator:l&&f.jsx("span",{"aria-hidden":!0,"data-testid":`center-file-tab__dirty--${n}`,className:"size-2 rounded-full bg-foreground/70"}),onClose:h,closeTitle:"Close file",closeTestId:`center-file-tab__close--${n}`})]})})}function wXn(t){const{worktreeId:e,filePath:n,commit:r,section:o,allOf:i}=t.params,s=t.containerApi,a=t.api.id,l=dy(t.api),c=MZe(t.api,t.params.preview),u=r?`${R0(n)} @ ${r.slice(0,7)}`:o==="staged"?`${R0(n)} (Staged)`:o==="branch"?`${R0(n)} (Committed)`:R0(n),d=v.useCallback(h=>{h.stopPropagation(),xh.get(s.id)?.current?.onClose(a,"diff")},[s,a]);return i?f.jsxs("div",{className:b4,"data-testid":`center-section-diffs-tab--${i}`,children:[f.jsxs("div",{className:Cg,children:[f.jsx(B2,{className:"size-3.5 shrink-0 text-muted-foreground"}),f.jsx("span",{className:v4,children:gN[i]})]}),f.jsx(Ag,{isActive:l,onClose:d,closeTitle:"Close diff"})]}):f.jsx($Ze,{worktreeId:e,filePath:n,testidPrefix:`center-diff-tab--${n}`,children:f.jsxs("div",{className:b4,"data-testid":`center-diff-tab--${n}`,"data-commit":r,onDoubleClick:()=>RW(t.api,t.params),children:[f.jsxs("div",{className:Cg,children:[f.jsx(B2,{className:"size-3.5 shrink-0 text-muted-foreground"}),f.jsx("span",{className:`${v4}${c?" italic":""}`,title:n,children:u})]}),f.jsx(Ag,{isActive:l,onClose:d,closeTitle:"Close diff"})]})})}const qW={top:!1,left:!1,right:!1},p8e=new WeakMap;function kXn(t){const e=p8e.get(t.group);if(e)return e;const n=t.group,r=t.containerApi,o=new Set;let i=null;const s=()=>{const l=n.element,c=l.closest("[data-layout-root]");if(!c)return;const u=l.getBoundingClientRect(),d=c.getBoundingClientRect(),h={top:u.top-d.top<2,left:u.left-d.left<2,right:d.right-u.right<2};l.toggleAttribute("data-band-top-row",h.top);const p=a.edges;if(!(p.top===h.top&&p.left===h.left&&p.right===h.right)){a.edges=h;for(const g of o)g()}},a={edges:qW,subscribe(l){if(o.add(l),!i){const c=n.element;s();const u=new ResizeObserver(s);u.observe(c);const d=r.onDidLayoutChange(s);i=()=>{u.disconnect(),d.dispose(),c.removeAttribute("data-band-top-row"),a.edges=qW}}return()=>{o.delete(l),o.size===0&&i&&(i(),i=null)}}};return p8e.set(n,a),a}const OXn=()=>()=>{};function BZe(t,e){const n=e?kXn(t):null;return v.useSyncExternalStore(n?n.subscribe:OXn,()=>n?.edges??qW)}const SXn=v.memo(function(e){const n=pN(),r=BZe(e,!!n);return!r.top||!r.left?null:f.jsx(TFe,{})}),CXn=v.memo(function(e){return f.jsx("div",{className:"flex h-full items-center px-0.5",children:f.jsx(EXn,{apiId:e.containerApi.id,groupId:e.group.id})})}),AXn=v.memo(function(e){const n=pN(),r=BZe(e,!!n),[,o]=v.useReducer(l=>l+1,0);v.useEffect(()=>{const l=e.containerApi.onDidActivePanelChange(()=>o()),c=u=>{const d=u.detail;e.group.panels.some(h=>h.id===d)&&o()};return window.addEventListener(IW,c),()=>{l.dispose(),window.removeEventListener(IW,c)}},[e.containerApi,e.group]);const i=e.group.activePanel?.id,s=i?sC.get(i):void 0;if(F_.has(e.containerApi.id))return s?f.jsx("div",{className:"flex h-full items-center px-1","data-testid":"worktree-center__toolbar",children:f.jsxs(Us,{children:[f.jsx(Ws,{asChild:!0,children:f.jsx("button",{type:"button","aria-label":"Tab actions","data-testid":"worktree-center__tab-actions-button",className:"inline-flex size-7 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:f.jsx(mM,{className:"size-3.5"})})}),f.jsx(Zs,{align:"end",className:"min-w-0 p-1",children:f.jsx("div",{className:"flex items-center gap-0.5",children:s()})})]})}):null;const a=e.group.activePanel?.params?.worktreeId;return f.jsxs("div",{className:"flex h-full items-center gap-0.5 px-1","data-testid":"worktree-center__toolbar",children:[s?.(),a&&f.jsx(LGn,{worktreeId:a}),r.top&&r.right&&n?.onToggleRightPanel&&!n.rightPanelVisible&&f.jsx(ste,{onToggle:n.onToggleRightPanel,visible:!1})]})});function EXn({apiId:t,groupId:e}){const n=(r,o)=>xh.get(t)?.current?.onAdd(r,e,o);return f.jsxs(Us,{children:[f.jsx(Ws,{asChild:!0,children:f.jsx("button",{type:"button","aria-label":"New tab",className:"inline-flex size-7 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground","data-testid":"worktree-center__new-tab-button",children:f.jsx(wl,{className:"size-4"})})}),f.jsxs(Zs,{align:"start",side:"bottom","data-testid":"worktree-center__new-tab-menu",children:[f.jsx(fYn,{onPick:r=>n("chat",r)}),f.jsxs(dr,{onClick:()=>n("term"),"data-testid":"worktree-center__new-tab--term",children:[f.jsx(xM,{className:"size-4"}),"New terminal",f.jsx(pF,{children:Vf("Cmd+T")})]}),On&&f.jsxs(dr,{onClick:()=>n("browser"),"data-testid":"worktree-center__new-tab--browser",children:[f.jsx(xu,{className:"size-4"}),"New browser",f.jsx(pF,{children:Vf("Cmd+Shift+B")})]})]})]})}const TXn={chat:nXn,term:oXn,browser:iXn,file:uXn,diff:fXn},MXn={chat:bXn,term:_Xn,browser:xXn,file:yXn,diff:wXn,icon:zZe},RH="flex w-56 items-center gap-3 rounded-md border border-border px-3 py-2 text-sm text-muted-foreground transition-colors hover:bg-accent hover:text-foreground";function l5(t,e,n,r){t.addPanel({id:n,component:"chat",tabComponent:"chat",title:"Chat",params:{worktreeId:e,chatId:n},position:r??fy(t)})}function of(t,e,n,r,o){t.addPanel({id:n,component:"term",tabComponent:"term",title:"Terminal",params:{worktreeId:e,terminalId:n,...r},position:o??fy(t),renderer:"always"})}function zp(t,e,n,r,o){t.addPanel({id:n,component:"browser",tabComponent:"browser",title:"New Tab",params:{worktreeId:e,browserId:n,...r?{initialUrl:r}:{}},position:o??fy(t),renderer:"always"})}function m8e(t,e,n,r){const o=pS();mS(o),zp(t,e,o,n,r),Se.browsers.create.mutate({worktreeId:e,id:o,url:n}).catch(i=>{console.error("[WorktreeCenter] browser create failed:",i)})}function g8e(t){return t.kind!=="browser"||On}function v8e(t,e,n){const r=VT(e),o=FWe(t);BQn(e,n&&r?IQn(r,o,g8e):LQn(o,r,g8e))}function PXn(t,e,n,r){const o=RZe(n.kind,n.id,e),i=o.allOf;t.addPanel({id:n.id,component:n.kind,tabComponent:n.kind,title:i?gN[i]:R0(o.filePath),params:o,position:r&&t.getPanel(r)?{referencePanel:r,direction:"within"}:fy(t),inactive:!0})}function VW(t){return t.kind==="file"||t.kind==="diff"}function HZe(t,e,n,r,o){let i=!1;for(const s of o){if(!VW(s))continue;const a=t.getPanel(s.id);!a||s.kind==="file"&&Mne(e,s.id.slice(5))||(t.removePanel(a),i=!0)}for(const s of r){if(!VW(s)||t.getPanel(s.id))continue;const a=n.tabs.findIndex(c=>c.id===s.id);let l=null;for(let c=a-1;c>=0;c--)if(t.getPanel(n.tabs[c].id)){l=n.tabs[c].id;break}PXn(t,e,s,l),i=!0}return i}function LH(t,e,n){const r=new Set(n.tabs.map(c=>c.id)),o=t.panels.map(c=>({id:c.id,kind:c.api.component})).filter(c=>VW(c)&&!r.has(c.id)),i=new Set(t.panels.map(c=>c.id));let s=HZe(t,e,n,n.tabs.filter(c=>!i.has(c.id)),o);const a=new Map(n.tabs.map((c,u)=>[c.id,u]));for(const c of t.groups){const u=[...c.panels].sort((p,g)=>(a.get(p.id)??Number.MAX_SAFE_INTEGER)-(a.get(g.id)??Number.MAX_SAFE_INTEGER)),d=c.activePanel;let h=!1;u.forEach((p,g)=>{if(c.panels.indexOf(p)!==g)try{p.api.moveTo({group:c,index:g,skipSetActive:!0}),h=!0}catch{}}),h&&(s=!0,d?.api.setActive())}const l=n.active?t.getPanel(n.active):void 0;return l&&(t.activePanel?.id!==l.id&&(s=!0),l.api.setActive()),s}function jXn(t,e){if(t.active!==e.active)return!0;const n=new Set(e.tabs.map(s=>s.id)),r=new Set(t.tabs.map(s=>s.id)),o=t.tabs.filter(s=>n.has(s.id)).map(s=>s.id),i=e.tabs.filter(s=>r.has(s.id)).map(s=>s.id);return o.join(`
1036
1036
  `)!==i.join(`
1037
1037
  `)}const FZe=v.memo(function({worktreeId:e,visible:n,wsActive:r,mobile:o=!1}){const i=Rr(),s=v.useRef(null),a=v.useRef(null),l=v.useRef(new Map),c=v.useRef(null),[u,d]=v.useState(null),h=v.useRef(!1),p=v.useRef(!1),g=v.useRef(!1),_=v.useRef(!1),x=v.useRef(r);x.current=r;const y=v.useRef(n);y.current=n;const k=v.useRef(null),O=v.useRef(null),C=v.useRef(null),A=v.useRef({stack:[],index:-1}),[E,M]=v.useState(null),[P,L]=v.useState(!1),{data:D}=It({queryKey:XYn(e),queryFn:async()=>{const ve=new Set,[Te,pe,Ne]=await Promise.all([Se.chats.list.query({worktreeId:e}).catch(()=>(ve.add("chat"),{chats:[]})),Se.terminal.list.query({worktreeId:e}).catch(()=>(ve.add("term"),{terminals:[]})),On?Se.browsers.list.query({worktreeId:e}).catch(()=>(ve.add("browser"),{browsers:[]})):Promise.resolve({browsers:[]}),_Ft(e)]),$e=new Map;for(const De of Ne.browsers)De.url&&De.url!=="about:blank"&&$e.set(De.id,De.url);return{chatIds:new Set(Te.chats.map(De=>De.id)),terminalIds:new Set(pe.terminals.map(De=>De.terminalId)),browserIds:new Set(Ne.browsers.map(De=>De.id)),urls:$e,unlisted:ve}},staleTime:Number.POSITIVE_INFINITY}),I=v.useRef(null);I.current=D??null;const z=v.useCallback(()=>{const ve=s.current;if(ve)try{const Te=ve.groups.find(Ne=>Ne.api.isMaximized())?.id;p.current=!0;const pe=Xge(ve.toJSON());Te&&(pe.maximizedGroup=Te),Hn.setItem(DW(e),JSON.stringify(pe)),v8e(ve,e,_.current)}catch{}finally{p.current=!1}},[e]),Y=v.useCallback(()=>{h.current||g.current||!s.current||(k.current&&clearTimeout(k.current),k.current=setTimeout(()=>{k.current=null,z()},400))},[z]),Q=v.useCallback(()=>{h.current||g.current||!s.current||(k.current&&(clearTimeout(k.current),k.current=null),z())},[z]);v.useEffect(()=>{aXn()},[]);const H=v.useRef(Q);H.current=Q,v.useEffect(()=>{const ve=()=>{k.current&&H.current()};return window.addEventListener("pagehide",ve),()=>window.removeEventListener("pagehide",ve)},[]);const N=v.useCallback(()=>{if(h.current||x.current===!1)return;const ve=s.current?.activePanel;if(!ve)return;const Te=ve.api.component,pe=Te==="chat"?"chat":Te==="term"?"terminal":Te==="browser"?"browser":null;pe&&Se.panelFocus.set.mutate({worktreeId:e,panelType:pe,panelId:ve.id}).catch(()=>{})},[e]),V=v.useRef(new Map),G=v.useRef(new NFt),K=v.useCallback((ve,Te)=>{const pe=Fb(),Ne=V.current,$e=dAe(),De=P5();pe!=="tui"&&hAe($e),Ne.set($e,ve),Ne.set(De,ve),Se.agentSessions.launch.mutate({worktreeId:e,agentId:Te,mode:pe,chatId:$e,terminalId:De}).then(ct=>{const ue=s.current;ue&&(ct.mode==="tui"&&ct.terminalId?ue.getPanel(ct.terminalId)||of(ue,e,ct.terminalId,{autoFocus:!0},ve):ct.chatId&&!ue.getPanel(ct.chatId)&&l5(ue,e,ct.chatId,ve),ct.notice&&console.warn("[WorktreeCenter]",ct.notice),k$(e,ct.worktreeId))}).catch(ct=>{console.error("[WorktreeCenter] agent launch failed:",ct),HS(ct);const ue=s.current;pe!=="tui"&&!Te&&ue&&!ue.getPanel($e)&&l5(ue,e,$e,ve)}).finally(()=>{Ne.delete($e),Ne.delete(De)})},[e]),q=v.useCallback((ve,Te,pe)=>{const Ne=s.current;if(!Ne)return;const $e=Te?{referenceGroup:Te}:void 0;if(ve==="term"){const De=P5();of(Ne,e,De,{autoFocus:!0},$e),Se.terminal.create.mutate({worktreeId:e,id:De}).then(ct=>k$(e,ct.worktreeId)).catch(ct=>{console.error("[WorktreeCenter] terminal create failed:",ct),HS(ct)})}else if(ve==="chat")K($e,pe);else if(ve==="browser"){if(!On)return;const De=pS();mS(De),zp(Ne,e,De,void 0,$e),Se.browsers.create.mutate({worktreeId:e,id:De}).catch(ct=>{console.error("[WorktreeCenter] browser create failed:",ct)})}},[e,K]),Z=v.useCallback((ve,Te,pe)=>{const Ne=s.current;if(!Ne)return;const $e={referenceGroup:Te,direction:pe};if(ve==="term"){const De=P5();of(Ne,e,De,{autoFocus:!0},$e),Se.terminal.create.mutate({worktreeId:e,id:De}).then(ct=>k$(e,ct.worktreeId)).catch(HS)}else if(ve==="chat")K($e);else if(ve==="browser"&&On){const De=pS();mS(De),zp(Ne,e,De,void 0,$e),Se.browsers.create.mutate({worktreeId:e,id:De}).catch(()=>{})}},[e,K]),U=v.useCallback((ve,Te)=>{const pe=s.current;if(!pe)return;QWe(pe,ve);const Ne=pe.getPanel(ve);if(Ne&&pe.removePanel(Ne),Te==="term"){const $e=x4e(ve);for(const De of $e.length?$e:[ve])yg(De),Se.terminal.kill.mutate({terminalId:De}).catch(()=>{});XTn(ve),nMn(e,ve)}else Te==="chat"?Se.chats.remove.mutate({chatId:ve}).catch(()=>{}):Te==="browser"?Se.browsers.remove.mutate({browserId:ve}).catch(()=>{}):Te==="file"&&(BW.add(HW(e,ve.slice(5))),FW(e,ve.slice(5)))},[e]),B=v.useCallback((ve,Te)=>{if(s.current){if(Te==="file"){const Ne=ve.slice(5);if(KT(e,Ne)){M({id:ve,path:Ne});return}}U(ve,Te)}},[e,U]),ee=v.useCallback((ve,Te)=>{const pe=s.current;if(!pe)return;if(!Te?.fromHistory){const Pe=A.current;Pe.stack[Pe.index]!==ve&&(Pe.stack=Pe.stack.slice(0,Pe.index+1),Pe.stack.push(ve),Pe.index=Pe.stack.length-1)}const Ne=Te?.preview??!1,$e=`file:${ve}`,De=pe.getPanel($e);if(De){!Ne&&O.current===$e&&(O.current=null);const Pe=De.api.getParameters();De.api.updateParameters({...Pe,line:Te?.line,column:Te?.column,preview:Ne?Pe.preview:!1}),De.api.setActive();return}let ct=DO(pe),ue=null;if(Ne&&O.current&&O.current!==$e){const Pe=pe.getPanel(O.current);Pe&&Pe.api.getParameters().preview!==!1&&(ct={referenceGroup:Pe.group.id},ue=Pe)}pe.addPanel({id:$e,component:"file",tabComponent:"file",title:R0(ve),params:{worktreeId:e,filePath:ve,line:Te?.line,column:Te?.column,external:Te?.external,untitled:Te?.untitled,preview:Ne},position:ct}),ue&&pe.removePanel(ue),O.current=Ne?$e:O.current},[e]),te=v.useCallback((ve,Te,pe)=>{const Ne=s.current;if(!Ne)return;const $e=pe?.preview??!1,De=Te?eXn(Te,ve):`diff:${ve}`,ct=Ne.getPanel(De);if(ct){!$e&&C.current===De&&(C.current=null);const Ee=ct.api.getParameters(),Le=pe?.section!==Ee.section||pe?.oldPath!==Ee.oldPath;!Te&&(!$e||Le)?ct.api.updateParameters({...Ee,...$e?{}:{preview:!1},section:pe?.section,oldPath:pe?.oldPath}):$e||ct.api.updateParameters({...Ee,preview:!1}),ct.api.setActive();return}let ue=DO(Ne),Pe=null;if($e&&C.current&&C.current!==De){const Ee=Ne.getPanel(C.current);Ee&&Ee.api.getParameters().preview!==!1&&(ue={referenceGroup:Ee.group.id},Pe=Ee)}Ne.addPanel({id:De,component:"diff",tabComponent:"diff",title:R0(ve),params:{worktreeId:e,filePath:ve,preview:$e,commit:Te,section:pe?.section,oldPath:pe?.oldPath},position:ue}),Pe&&Ne.removePanel(Pe),C.current=$e?De:C.current},[e]),se=v.useCallback((ve,Te)=>te(ve,void 0,Te),[te]),ae=v.useCallback(ve=>{const Te=s.current;if(!Te)return;const pe=tXn(ve),Ne=Te.getPanel(pe);if(Ne){Ne.api.setActive();return}Te.addPanel({id:pe,component:"diff",tabComponent:"diff",title:gN[ve],params:{worktreeId:e,filePath:"",allOf:ve},position:DO(Te)})},[e]),he=v.useCallback((ve,Te,pe)=>te(Te,ve,pe),[te]),fe=v.useCallback((ve,Te)=>{const pe=s.current;if(!pe)return;const Ne=ue=>ue===ve?Te:ue.startsWith(`${ve}/`)?Te+ue.slice(ve.length):null,$e=[];for(const ue of pe.panels){const Pe=ue.id.startsWith("file:")?"file":ue.id.startsWith("diff:")?"diff":null;if(!Pe)continue;const Ee=ue.params??{};if(Pe==="file"&&(Ee.external||Ee.untitled))continue;const Le=Ne(ue.id.slice(5));Le!=null&&$e.push({panel:ue,prefix:Pe,nextPath:Le})}if($e.length===0)return;const De=T8(e);let ct=!1;for(const{panel:ue,prefix:Pe,nextPath:Ee}of $e){if(Pe!=="file")continue;const Le=ue.id.slice(5);Le in De&&(De[Ee]=De[Le],delete De[Le],ct=!0);const et=Eg(e,Le);et!==null&&(Tg(e,Ee,et),Tg(e,Le,null)),Mne(e,Le)&&(H_(e,Ee,!0),H_(e,Le,!1)),BW.add(HW(e,Le))}ct&&rR(e,De);for(const{panel:ue,prefix:Pe,nextPath:Ee}of $e){const Le=`${Pe}:${Ee}`,et=ue.api.isVisible,kt=pe.getPanel(Le);kt?et&&kt.api.setActive():pe.addPanel({id:Le,component:Pe,tabComponent:Pe,title:R0(Ee),params:{...ue.params,worktreeId:e,filePath:Ee},position:{referenceGroup:ue.group.id,index:ue.group.panels.indexOf(ue)},inactive:!et}),pe.removePanel(ue),O.current===ue.id&&(O.current=Le),C.current===ue.id&&(C.current=Le)}},[e]),be=v.useCallback(ve=>{const Te=s.current;if(Te)for(const pe of[...Te.panels]){const Ne=pe.id.startsWith("file:")?"file":pe.id.startsWith("diff:")?"diff":null;if(!Ne)continue;const $e=pe.params??{};if(Ne==="file"&&$e.external)continue;const De=pe.id.slice(5);De!==ve&&!De.startsWith(`${ve}/`)||Ne==="file"&&KT(e,De)||U(pe.id,Ne)}},[e,U]),me=v.useRef({onAdd:()=>{},onSplit:()=>{},onClose:()=>{},openFile:()=>{},openDiff:()=>{},openSectionDiffs:()=>{},openCommitDiff:()=>{},onPathMoved:()=>{},onPathRemoved:()=>{}});me.current={onAdd:q,onSplit:Z,onClose:B,openFile:ee,openDiff:se,openSectionDiffs:ae,openCommitDiff:he,onPathMoved:fe,onPathRemoved:be};const le=v.useCallback((ve,Te)=>{let pe=null,Ne=null;const $e=()=>pe?{referencePanel:pe,direction:"within"}:void 0,De=[...Te.terminalIds];if(De.length>0||Te.chatIds.size>0||On&&Te.browserIds.size>0){for(const ue of De)of(ve,e,ue,void 0,$e()),pe??=ue,Ne??=ue;for(const ue of Te.chatIds)l5(ve,e,ue,$e()),pe??=ue,Ne??=ue;if(On)for(const ue of[...Te.browserIds])zp(ve,e,ue,Te.urls.get(ue),$e()),pe??=ue,Ne??=ue}else{const ue=P5();of(ve,e,ue,{autoFocus:!0},$e()),pe=ue,Ne=ue,Se.terminal.create.mutate({worktreeId:e,id:ue}).catch(()=>{})}if(Ne)try{ve.getPanel(Ne)?.api.setActive()}catch{}},[e]),Be=v.useCallback((ve,Te)=>{for(const pe of[...ve.panels]){const Ne=pe.api.component;if(!Te.unlisted.has(Ne))if(Ne==="chat"&&!Te.chatIds.has(pe.id))ve.removePanel(pe);else if(Ne==="term"){const $e=Te.terminalIds.has(pe.id)||D4e(pe.id),De=KTn(pe.id,Te.terminalIds)||x4e(pe.id).some(D4e);!$e&&!De&&ve.removePanel(pe)}else Ne==="browser"&&!Te.browserIds.has(pe.id)&&ve.removePanel(pe)}for(const pe of Te.chatIds)ve.getPanel(pe)||l5(ve,e,pe);for(const pe of Te.terminalIds)!_4e(pe)&&!ve.getPanel(pe)&&of(ve,e,pe);if(On)for(const pe of Te.browserIds)ve.getPanel(pe)||zp(ve,e,pe,Te.urls.get(pe))},[e]),Xe=v.useRef(()=>{}),ot=v.useCallback((ve=!1)=>{const Te=s.current,pe=a.current;!Te||!pe||(Xe.current(),Xe.current=ZQn(Te,{container:pe,force:ve,isCurrent:()=>y.current&&x.current!==!1}))},[]),Qe=v.useCallback(ve=>{const Te=s.current?.activePanel?.api.component;Te&&(!o||Te==="term"||Te==="browser")&&ot(ve)},[o,ot]),lt=v.useCallback(ve=>{s.current=ve,iC.set(e,ve),LW.set(e,me),xh.set(ve.id,me),o&&F_.add(ve.id);const Te=I.current??{chatIds:new Set,terminalIds:new Set,browserIds:new Set,urls:new Map,unlisted:new Set};rMn(e),h.current=!0;const pe=ZYn(e),Ne=VT(e);let $e=!1;if(pe)try{ve.fromJSON(UYn(iYn(pe,QYn),e,Te.urls)),Be(ve,Te)}catch(ue){console.error("[WorktreeCenter] fromJSON failed, rebuilding:",ue);for(const Pe of[...ve.panels])ve.removePanel(Pe);le(ve,Te),$e=!0}else Ne?(Be(ve,Te),$e=!0):(le(ve,Te),$e=!0);if(pe&&!Ne&&typeof pe.maximizedGroup!="string"&&($e=!0),o&&WYn(ve),Ne&&LH(ve,e,Ne)&&($e=!0),!o&&pe&&typeof pe.maximizedGroup=="string"){const ue=pe.maximizedGroup;requestAnimationFrame(()=>{try{ve.groups.find(Pe=>Pe.id===ue)?.api.maximize()}catch{}})}const De=()=>L(ve.panels.length===0);ve.onDidLayoutChange(()=>Y()),ve.onDidAddPanel(()=>{De(),Q()}),ve.onDidRemovePanel(ue=>{O.current===ue.id&&(O.current=null),C.current===ue.id&&(C.current=null),De(),Q()}),ve.onDidAddGroup(()=>Q()),ve.onDidRemoveGroup(ue=>{l.current.delete(ue.id),Q()}),ve.onDidMaximizedGroupChange(()=>{p.current||Q()});const ct=()=>{const ue=ve.activePanel;ue&&eUn(l.current,ue.group.id,ue.id)};if(ct(),ve.onDidActivePanelChange(()=>{ct(),!g.current&&!h.current&&(_.current=!1),Y(),N(),y.current&&!g.current&&!h.current&&Qe(!1)}),ve.onDidMovePanel(()=>{!g.current&&!h.current&&(_.current=!1)}),setTimeout(()=>{h.current=!1,y.current&&Qe(!0),$e&&Q()},0),L(ve.panels.length===0),y.current&&a.current){const ue=a.current.getBoundingClientRect();ue.width>0&&ue.height>0&&ve.layout(Math.round(ue.width),Math.round(ue.height),!0)}},[e,o,le,Be,Y,Q,N,Qe]);v.useEffect(()=>{const ve=G.current,Te=Ne=>{const $e=Ne.detail;$e.worktreeId===e&&ve.expect($e.chatId,$e.terminalId)},pe=Ne=>{const $e=Ne.detail,De=s.current;if(!($e.worktreeId!==e||!De)){if(!De.getPanel($e.paneId))if($e.kind==="chat")l5(De,e,$e.paneId);else if($e.kind==="term")of(De,e,$e.paneId,{autoFocus:!0});else return;De.getPanel($e.paneId)?.api.setActive(),ve.expect($e.paneId),ve.activate($e.paneId,ct=>De.getPanel(ct))}};return window.addEventListener(jq,Te),window.addEventListener(_A,pe),()=>{window.removeEventListener(jq,Te),window.removeEventListener(_A,pe)}},[e]),v.useEffect(()=>i.subscribeStatusEvents(ve=>{if(ve.worktreeId!==e)return;const Te=s.current;if(!Te)return;const pe=V.current;if(ve.kind==="chat-created"&&typeof ve.chatId=="string")Te.getPanel(ve.chatId)||l5(Te,e,ve.chatId,pe.get(ve.chatId)),G.current.activate(ve.chatId,Ne=>Te.getPanel(Ne));else if(ve.kind==="chat-removed"&&typeof ve.chatId=="string"){const Ne=Te.getPanel(ve.chatId);Ne&&Te.removePanel(Ne)}else if(ve.kind==="terminal-created"&&typeof ve.terminalId=="string"){if(!_4e(ve.terminalId)&&!Te.getPanel(ve.terminalId)){const Ne=pe.has(ve.terminalId)||G.current.has(ve.terminalId);of(Te,e,ve.terminalId,Ne?{autoFocus:!0}:void 0,pe.get(ve.terminalId)),G.current.activate(ve.terminalId,$e=>Te.getPanel($e))}}else if(ve.kind==="terminal-killed"&&typeof ve.terminalId=="string"){yg(ve.terminalId);const Ne=ve.terminalId,$e=cT(Ne)??(Te.getPanel(Ne)?Ne:void 0);if($e){const De=hqe($e),ct=De?.getPanel(Ne);if(De&&ct&&De.removePanel(ct),!De||De.panels.length===0){const ue=Te.getPanel($e);ue&&Te.removePanel(ue)}}NU(Ne)}else if(On&&ve.kind==="browser-created"&&typeof ve.browserId=="string")Te.getPanel(ve.browserId)||zp(Te,e,ve.browserId);else if(ve.kind==="browser-removed"&&typeof ve.browserId=="string"){const Ne=Te.getPanel(ve.browserId);Ne&&Te.removePanel(Ne)}}),[i,e]),v.useEffect(()=>{const ve=yne(e);return bA(Te=>{if(Te.key!==ve)return;const pe=s.current,Ne=_W(Te.value);if(!pe||!Ne||h.current)return;g.current=!0;let $e;try{if(!y.current)_.current=!1,$e=LH(pe,e,Ne);else{jXn(FWe(pe),Ne)&&(_.current=!0);const{added:De,removed:ct}=DQn(_W(Te.previous),Ne);$e=HZe(pe,e,Ne,De,ct)}}finally{g.current=!1}($e||Te.source==="conflict")&&Q()})},[e,Q]),v.useEffect(()=>{const ve=B_(e,"");return bA(Te=>{Te.key.startsWith(ve)&&window.dispatchEvent(new CustomEvent("band:dirty-change"))})},[e]),v.useEffect(()=>{if(!n||!_.current)return;_.current=!1;const ve=s.current,Te=VT(e);if(!ve||!Te)return;g.current=!0;let pe;try{pe=LH(ve,e,Te)}finally{g.current=!1}pe&&Q()},[n,e,Q]),v.useEffect(()=>{if(!On)return;let ve,Te=!1;return Qf("browser-open-window",pe=>{const Ne=s.current,$e=Ne?.getPanel(pe.payload.browser_id);!Ne||!$e||m8e(Ne,e,pe.payload.url,{referenceGroup:$e.group.id})}).then(pe=>{Te?pe():ve=pe}),()=>{Te=!0,ve?.()}},[e]),v.useEffect(()=>{if(!On)return;const ve=Te=>{const pe=Te.detail,Ne=s.current;if(!Ne||pe.worktreeId!==e)return;const $e=pe.terminalId?Ne.getPanel(cT(pe.terminalId)??pe.terminalId):void 0;m8e(Ne,e,pe.url,$e?{referenceGroup:$e.group.id}:DO(Ne))};return window.addEventListener(SU,ve),()=>window.removeEventListener(SU,ve)},[e]),v.useEffect(()=>{if(!On)return;const ve=Te=>{const pe=Te.detail;!pe||pe.worktreeId!==e||(async()=>{const Ne=s.current;if(Ne)try{const{url:$e}=await Se.worktree.previewUrl.query({worktreeId:e,path:pe.path}),De=new URL(vA($e),window.location.href).toString(),{browsers:ct}=await Se.browsers.list.query({worktreeId:e}),ue=ct.find(Le=>Le.url&&$On(Le.url,e,pe.path))?.id,Pe=ue?Ne.getPanel(ue):void 0;if(ue&&Pe){Pe.api.setActive(),await Se.browsers.navigate.mutate({browserId:ue,url:De}),window.dispatchEvent(new CustomEvent(fU,{detail:{browserId:ue,url:De}}));return}const Ee=pS();mS(Ee),zp(Ne,e,Ee,De);try{await Se.browsers.create.mutate({worktreeId:e,id:Ee,url:De})}catch(Le){throw Ne.getPanel(Ee)?.api.close(),Le}}catch($e){console.error("[WorktreeCenter] html preview failed:",$e)}})()};return window.addEventListener(dU,ve),()=>window.removeEventListener(dU,ve)},[e]),v.useEffect(()=>{const ve=pe=>{const Ne=pe.detail;!Ne?.chatId||Ne.worktreeId!==e||s.current?.getPanel(Ne.chatId)?.api.setActive()},Te=pe=>{const Ne=pe.detail;!Ne?.terminalId||Ne.worktreeId!==e||s.current?.getPanel(Ne.terminalId)?.api.setActive()};return window.addEventListener("band:chat-insert",ve),window.addEventListener("band:terminal-insert",Te),()=>{window.removeEventListener("band:chat-insert",ve),window.removeEventListener("band:terminal-insert",Te)}},[e]),v.useEffect(()=>{const ve=Ne=>$e=>{const De=$e.detail;if(De?.worktreeId?De.worktreeId!==e:!x.current)return;const ct=A.current,ue=ct.index+Ne;ue<0||ue>=ct.stack.length||(ct.index=ue,me.current.openFile(ct.stack[ue],{fromHistory:!0}))},Te=ve(-1),pe=ve(1);return window.addEventListener("band:editor-go-back",Te),window.addEventListener("band:editor-go-forward",pe),()=>{window.removeEventListener("band:editor-go-back",Te),window.removeEventListener("band:editor-go-forward",pe)}},[e]),v.useEffect(()=>{if(!n)return;const ve=()=>Qe(!0),Te=De=>{c.current=De,d(De)},pe=De=>{const ct=c.current;if(!ct||De.key!=="Control")return;Te(null);const ue=ct.items[ct.index],Pe=ue&&s.current?.getPanel(ue.id);Pe&&(Pe.api.setActive(),ve())},Ne=()=>{c.current&&Te(null)},$e=De=>{const ct=s.current;if(!ct)return;const ue=De.key.toLowerCase(),Pe=document.activeElement;if(De.ctrlKey&&!De.metaKey&&!De.altKey&&ue==="tab"){if(!c.current&&!a.current?.contains(Pe)&&Pe&&Pe!==document.body)return;De.preventDefault(),De.stopPropagation();const et=c.current;if(et){Te({items:et.items,index:rUn(et.index,et.items.length,De.shiftKey)});return}const kt=ct.activeGroup;if(!kt)return;const tn=new Map(kt.panels.map(Qt=>[Qt.id,Qt])),Kt=tUn(l.current,kt.id,kt.panels.map(Qt=>Qt.id),kt.activePanel?.id);if(Kt.length<=1)return;const Dn=Kt.map(Qt=>({id:Qt,title:tn.get(Qt)?.title??Qt,kind:tn.get(Qt)?.api.component??"",params:tn.get(Qt)?.params}));Te({items:Dn,index:nUn(Dn.length,De.shiftKey)});return}if(c.current&&De.key==="Escape"){De.preventDefault(),De.stopPropagation(),Te(null);return}if(!a.current?.contains(Pe))return;const Ee=UWe(De,Y2());if(Ee){if(y4e())return;const et=ct.activeGroup?.id,kt=ct.activePanel?.api.component;De.preventDefault(),De.stopPropagation(),et&&(kt==="chat"||kt==="browser")&&Z(kt,et,Ee);return}if((De.metaKey||De.ctrlKey)&&!(y4e()&&(ue==="d"||ue==="w"||(ue==="["||ue==="]")&&!De.shiftKey))){if(De.shiftKey&&(ue==="["||ue==="]")){De.preventDefault(),De.stopPropagation(),qWe(ct,ue==="]"?1:-1,ve);return}if(!De.shiftKey&&(ue==="["||ue==="]")){De.preventDefault(),De.stopPropagation(),wne(ct,ue==="]"?1:-1,ve);return}if(ue==="w"&&!De.shiftKey){const et=ct.activePanel,kt=et?.api.component;if(!et||!kt)return;De.preventDefault(),De.stopPropagation(),B(et.id,kt)}}};return window.addEventListener("keydown",$e,!0),window.addEventListener("keyup",pe,!0),window.addEventListener("blur",Ne),()=>{window.removeEventListener("keydown",$e,!0),window.removeEventListener("keyup",pe,!0),window.removeEventListener("blur",Ne),Te(null)}},[n,B,Z,Qe]),v.useEffect(()=>{if(!n)return;const ve=requestAnimationFrame(()=>{Qe(!0),N()});return()=>{cancelAnimationFrame(ve),Xe.current()}},[n,N,Qe]),v.useEffect(()=>{const ve=Te=>{Te.detail?.worktreeId!==e||!y.current||Qe(!0)};return window.addEventListener("band:focus-active-leaf",ve),()=>window.removeEventListener("band:focus-active-leaf",ve)},[e,Qe]),v.useLayoutEffect(()=>{if(!n)return;const ve=s.current,Te=a.current;if(!ve||!Te)return;let pe=0,Ne=0;const $e=(ue,Pe)=>{const Ee=Math.round(ue),Le=Math.round(Pe);Ee<=0||Le<=0||Ee===pe&&Le===Ne||(pe=Ee,Ne=Le,ve.layout(Ee,Le,!0))},De=Te.getBoundingClientRect();$e(De.width,De.height);const ct=new ResizeObserver(ue=>{const Pe=ue[0];Pe&&$e(Pe.contentRect.width,Pe.contentRect.height)});return ct.observe(Te),()=>ct.disconnect()},[n]),v.useEffect(()=>()=>{const ve=s.current;if(ve&&(xh.delete(ve.id),F_.delete(ve.id),iC.get(e)===ve&&(iC.delete(e),LW.delete(e))),k.current&&ve){clearTimeout(k.current),k.current=null;try{Hn.setItem(DW(e),JSON.stringify(Xge(ve.toJSON()))),v8e(ve,e,_.current)}catch{}}},[e]);const bt=v.useMemo(()=>({visible:n&&r!==!1,wsActive:r!==!1,worktreeId:e}),[n,r,e]);return D?f.jsxs("div",{ref:a,className:"relative flex h-full w-full flex-col overflow-hidden",children:[f.jsx(Cne.Provider,{value:bt,children:f.jsx(xZe,{kind:"center",className:o?FYn:HYn,components:TXn,tabComponents:MXn,defaultTabComponent:zZe,prefixHeaderActionsComponent:SXn,leftHeaderActionsComponent:CXn,rightHeaderActionsComponent:AXn,disableDnd:o,onReady:lt})}),f.jsx(CYn,{worktreeId:e}),u&&f.jsx(OYn,{items:u.items,index:u.index}),P&&f.jsxs("div",{className:"absolute inset-0 z-10 flex items-center justify-center","data-testid":"worktree-center__empty-state",children:[!o&&f.jsx(MFe,{className:"absolute inset-x-0 top-0"}),f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsx(hYn,{className:RH,onPick:ve=>q("chat",void 0,ve)}),f.jsxs("button",{type:"button",onClick:()=>q("term"),className:RH,"data-testid":"worktree-center__empty-new-term",children:[f.jsx(xM,{className:"size-4"}),"New terminal"]}),On&&f.jsxs("button",{type:"button",onClick:()=>q("browser"),className:RH,"data-testid":"worktree-center__empty-new-browser",children:[f.jsx(xu,{className:"size-4"}),"New browser"]})]})]}),f.jsx(nr,{open:E!==null,onOpenChange:ve=>!ve&&M(null),children:f.jsxs(rr,{showCloseButton:!1,children:[f.jsxs(hr,{children:[f.jsx(or,{children:"Unsaved changes"}),f.jsxs(Nr,{children:[E?R0(E.path):""," has unsaved changes. Close without saving?"]})]}),f.jsxs(ii,{children:[f.jsx(Ce,{variant:"outline",onClick:()=>M(null),children:"Cancel"}),f.jsx(Ce,{variant:"destructive",onClick:()=>{E&&U(E.id,"file"),M(null)},children:"Close without saving"})]})]})})]}):f.jsx("div",{className:"flex h-full w-full items-center justify-center"})}),NXn=120;function RXn(){const[t,e]=v.useState(null),[n,r]=v.useState(0),[o,i]=v.useState(!1);return v.useLayoutEffect(()=>{const s=window.visualViewport,a=()=>{(window.scrollX!==0||window.scrollY!==0)&&!document.body.hasAttribute("data-scroll-locked")&&window.scrollTo(0,0),e(s?s.height:window.innerHeight),r(s?s.offsetTop:0),i(s?window.innerHeight-s.height>NXn:!1)};a(),s&&(s.addEventListener("resize",a),s.addEventListener("scroll",a)),window.addEventListener("resize",a),window.addEventListener("scroll",a);const l=new MutationObserver(a);return l.observe(document.body,{attributeFilter:["data-scroll-locked"]}),()=>{l.disconnect(),s&&(s.removeEventListener("resize",a),s.removeEventListener("scroll",a)),window.removeEventListener("resize",a),window.removeEventListener("scroll",a)}},[]),{height:t,offsetTop:n,keyboardOpen:o}}function LXn(t){const e=Xx(t,{refetchInterval:15e3});return{changes:e.data,changeCount:LFe(e.data)}}function IXn(t){const{repos:e}=xs();return v.useMemo(()=>{for(const n of e)for(const r of n.worktrees)if(jr(n.name,r.name,r.hostId)===t)return{name:r.name,repoName:n.name};return{name:t,repoName:""}},[e,t])}function DXn(t){return t==="explorer"||t==="changes"||typeof t=="string"&&t.startsWith("plugin:")}const zXn={height:"100dvh",visibility:"hidden",pointerEvents:"none"};function $Xn(){const t=Mo({select:d=>d.location.pathname}),e=v8(t),{height:n,offsetTop:r,keyboardOpen:o}=RXn(),[i,s]=v.useState(!1);v.useLayoutEffect(()=>{s(!0)},[]);const a=v.useRef(e);a.current=e;const[l,c]=v.useState(null);v.useEffect(()=>{const d=h=>{const p=h.detail,g=p?.worktreeId??a.current;!g||!DXn(p?.tab)||c({worktreeId:g,view:p.tab})};return window.addEventListener("band:right-sidepanel-set-tab",d),()=>window.removeEventListener("band:right-sidepanel-set-tab",d)},[]),v.useEffect(()=>{c(d=>d&&d.worktreeId!==e?null:d)},[e]);const u=v.useCallback(()=>c(null),[]);return i?f.jsxs("div",{"data-testid":"mobile-worktree",className:"fixed inset-x-0 top-0 flex flex-col overflow-hidden",style:e?{height:n?`${n}px`:"100dvh",transform:r?`translateY(${r}px)`:void 0}:zXn,inert:!e,children:[On&&f.jsx(oEn,{}),e&&f.jsx(FXn,{worktreeId:e,requestedView:l?.worktreeId===e?l.view:null,onRequestedViewShown:u},e),f.jsx("main",{"data-testid":"mobile-worktree__main",className:`flex min-h-0 flex-1 flex-col ${o?"":"pb-[env(safe-area-inset-bottom)]"}`,children:f.jsx(Aqe,{emptyState:null,children:(d,h)=>f.jsxs("div",{className:"flex h-full w-full flex-col",children:[f.jsx(Mqe,{worktreeId:d,active:h}),f.jsx("div",{className:"relative min-h-0 flex-1",children:f.jsx(FZe,{worktreeId:d,visible:h,wsActive:h,mobile:!0})})]})})})]}):null}function BXn({count:t,testid:e}){return f.jsx("span",{"data-testid":e,className:"inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-info-bg px-1 text-[9px] font-medium text-info",children:t})}function HXn({item:t,onSelect:e}){const{label:n,icon:r,badge:o,testid:i}=t;return f.jsxs("button",{type:"button",onClick:e,"aria-label":o?`${n}, ${o}`:n,"data-testid":i,className:"flex h-12 w-full items-center gap-3 px-4 text-left text-sm transition-colors hover:bg-accent active:bg-accent",children:[f.jsx(r,{className:"size-[18px] shrink-0 text-muted-foreground"}),f.jsx("span",{className:"min-w-0 flex-1 truncate",children:n}),o!=null&&o>0&&f.jsx(BXn,{count:o,testid:`${i}-badge`})]})}function BO({open:t,onOpenChange:e,title:n,description:r,testid:o,className:i="h-[75dvh]",children:s}){return f.jsx(Gxe,{open:t,onOpenChange:e,children:f.jsxs(Yxe,{side:"bottom",className:`${i} p-0`,"data-testid":`${o}-sheet`,children:[f.jsx(Xxe,{className:"border-b border-border/50 px-4 py-3 text-sm",children:n}),f.jsx(Kxe,{className:"sr-only",children:r}),f.jsx("div",{"data-testid":`${o}-body`,className:"min-h-0 flex-1 overflow-auto pb-[env(safe-area-inset-bottom)]",children:s})]})})}function FXn({worktreeId:t,requestedView:e,onRequestedViewShown:n}){const r=Gx(t),{changes:o,changeCount:i}=LXn(t),{name:s,repoName:a}=IXn(t),l=WFe(),[c,u]=v.useState("editor"),d=D=>I=>u(I?D:"editor"),h=[{view:"explorer",label:"Explorer",icon:ld,testid:"mobile-worktree__menu-explorer"},{view:"changes",label:"Changes",icon:B2,badge:i,testid:"mobile-worktree__menu-changes"},...l.map(({key:D,slug:I,tab:z})=>({view:`plugin:${D}`,label:z.label,icon:z.icon,testid:`mobile-worktree__menu-${I}`}))],p=v.useCallback((D,I)=>{Io(t)?.openFile(D,I),u("editor")},[t]),g=v.useCallback((D,I)=>{Io(t)?.openDiff(I.path,{section:D,oldPath:I.oldPath}),u("editor")},[t]),[_,x]=v.useState(!1),[y,k]=v.useState(!1);v.useEffect(()=>{e&&(u(e),k(!1),x(!1),n())},[e,n]);const[O,C]=v.useState(!1),[A,E]=v.useState(void 0),[M,P]=v.useState(!1),L=v.useCallback(D=>{const{filePath:I,line:z,column:Y}=X5(D);p(I,{line:z,column:Y})},[p]);return v.useEffect(()=>{const D=I=>{const z=I.detail;z?.filename&&(z.worktreeId&&z.worktreeId!==t||(E(z.filename),C(!0)))};return window.addEventListener("band:open-file",D),()=>window.removeEventListener("band:open-file",D)},[t]),v.useEffect(()=>{const D=I=>{const z=I.detail;z?.filePath&&(z.worktreeId&&z.worktreeId!==t||p(z.filePath,{line:z.line,column:z.column}))};return window.addEventListener("band:lsp-navigate",D),()=>window.removeEventListener("band:lsp-navigate",D)},[t,p]),v.useEffect(()=>{const D=()=>C(!0),I=()=>P(!0);return window.addEventListener("band:open-quick-open",D),window.addEventListener("band:open-search-files",I),()=>{window.removeEventListener("band:open-quick-open",D),window.removeEventListener("band:open-search-files",I)}},[]),f.jsxs(f.Fragment,{children:[f.jsxs("header",{"data-testid":"mobile-worktree__header",className:"flex h-[calc(3rem+env(safe-area-inset-top))] shrink-0 items-center gap-1 border-b border-border/50 px-2 pt-[env(safe-area-inset-top)]",children:[f.jsx("button",{type:"button",onClick:()=>k(!0),"aria-label":"Open repo list","aria-haspopup":"dialog","data-testid":"mobile-worktree__repo-list-trigger",className:"inline-flex size-9 shrink-0 items-center justify-center rounded-md hover:bg-accent",children:f.jsx(Bot,{className:"size-4"})}),f.jsxs("button",{type:"button",onClick:()=>x(!0),"aria-haspopup":"dialog","aria-label":"Switch worktree","data-testid":"mobile-worktree__switcher",className:"inline-flex min-w-0 flex-1 items-center justify-center gap-1.5 rounded-md px-2 py-1 text-center hover:bg-accent active:bg-accent",children:[f.jsx("span",{"aria-hidden":!0,className:"size-3.5 shrink-0"}),f.jsx(Tee,{name:s,repoName:a,isActive:!0}),f.jsx(H7e,{className:"size-3.5 shrink-0 text-muted-foreground"})]}),f.jsx("button",{type:"button",onClick:()=>u("menu"),"aria-label":"Worktree panels","aria-haspopup":"dialog","data-testid":"mobile-worktree__header-menu",className:"inline-flex size-9 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent active:bg-accent",children:f.jsx(mM,{className:"size-[18px]"})})]}),f.jsx(BO,{open:c==="menu",onOpenChange:d("menu"),title:"Worktree",description:"Open a worktree panel",testid:"mobile-worktree__menu",className:"h-auto",children:f.jsx("ul",{children:h.map(D=>f.jsx("li",{children:f.jsx(HXn,{item:D,onSelect:()=>u(D.view)})},D.view))})}),f.jsx(BO,{open:c==="explorer",onOpenChange:d("explorer"),title:"Explorer",description:"Browse worktree files and open one in the editor",testid:"mobile-worktree__explorer",children:f.jsx($He,{worktreeId:t,worktreePath:r,onOpenFile:D=>p(D),onOpenFilePinned:D=>p(D),compact:!0})}),f.jsx(BO,{open:c==="changes",onOpenChange:d("changes"),title:"Changes",description:"Browse changed files and open one as a diff",testid:"mobile-worktree__changes",children:f.jsx(GFe,{worktreeId:t,changes:o,onOpen:g,worktreePath:r})}),l.map(({key:D,slug:I,pluginId:z,tab:Y})=>{const Q=c===`plugin:${D}`;return f.jsx(BO,{open:Q,onOpenChange:d(`plugin:${D}`),title:Y.label,description:`The ${Y.label} tab of this worktree`,testid:`mobile-worktree__plugin--${I}`,children:f.jsx("div",{className:"flex h-full flex-col overflow-hidden",children:f.jsx(IFe,{pluginId:z,children:f.jsx(jFe,{value:x$e,children:f.jsx(Y.component,{worktreeId:t,visible:Q})})})})},D)}),f.jsx(qHe,{worktreeId:t,open:O,onOpenChange:D=>{C(D),D||E(void 0)},onOpenFile:L,initialQuery:A,autoOpen:A!=null}),f.jsx(VHe,{worktreeId:t,open:M,onOpenChange:P,onOpenFile:L}),f.jsx(ZHe,{open:_,onOpenChange:x}),f.jsx(Gxe,{open:y,onOpenChange:k,children:f.jsxs(Yxe,{side:"left",showCloseButton:!1,"data-testid":"repo-list-flyout",onOpenAutoFocus:D=>{D.preventDefault(),D.currentTarget?.focus()},children:[f.jsx(Xxe,{className:"sr-only",children:"Repos"}),f.jsx(Kxe,{className:"sr-only",children:"Browse repos and open a worktree"}),f.jsx(zWe,{children:f.jsx(pHe,{bottomActions:f.jsx($We,{}),hideTitleBar:!0,padBottomInset:!0,matchMobileHeader:!0})})]})})]})}const JT="var(--info)",b8e=["var(--git-added)","var(--merged)","var(--git-diverged)","var(--git-renamed)","var(--git-ahead)"];function IH(t){return t.refs.some(e=>e.kind==="head")?JT:void 0}function qXn(t,e){let n=-1;const r=[];let o;for(const i of t){const s=(r.at(-1)?.outputSwimlanes??[]).map(c=>({...c})),a=[];let l=!1;if(i.parents.length>0)for(const c of s){if(c.id===i.sha){l||(a.push({id:i.parents[0],color:IH(i)??c.color}),l=!0);continue}a.push({...c})}for(let c=l?1:0;c<i.parents.length;c++){let u;if(c===0)u=IH(i);else{if(!o){o=new Map;for(const h of t)o.has(h.sha)||o.set(h.sha,h)}const d=o.get(i.parents[c]);u=d?IH(d):void 0}u||(n=(n+1)%b8e.length,u=b8e[n]),a.push({id:i.parents[c],color:u})}r.push({commit:i,inputSwimlanes:s,outputSwimlanes:a,isHead:i.sha===e})}return r}function VXn(t){const e=t.inputSwimlanes.findIndex(n=>n.id===t.commit.sha);return e!==-1?e:t.inputSwimlanes.length}function QXn(t,e){for(let n=t.outputSwimlanes.length-1;n>=0;n--)if(t.outputSwimlanes[n].id===e)return n;return-1}const UXn=50,WXn=5e3,_8e="band:commits-panel-collapsed",x8e="band:commits-panel-height",ZXn=256,GXn=96,YXn=640;function y8e(t){try{return localStorage.getItem(t)}catch{return null}}function w8e(t,e){try{Hn.setItem(t,e)}catch{}}function k8e(t){return Math.min(YXn,Math.max(GXn,Math.round(t)))}const $p=24,Jo=11,Tp=5,_c=$p/2,HO=3.5;function c5({d:t,color:e}){return f.jsx("path",{d:t,fill:"none",stroke:e,strokeLinecap:"round",strokeWidth:1})}function XXn({row:t}){const{commit:e,inputSwimlanes:n,outputSwimlanes:r}=t,o=n.findIndex(h=>h.id===e.sha),i=VXn(t),s=r[i]?.color??n[i]?.color??JT,a=[];let l=0;for(let h=0;h<n.length;h++){const p=n[h];if(p.id===e.sha){h!==i?a.push(f.jsx(c5,{color:p.color,d:`M ${Jo*(h+1)} 0 A ${Jo} ${Jo} 0 0 1 ${Jo*h} ${_c} H ${Jo*(i+1)}`},`base-${h}`)):l++;continue}l<r.length&&p.id===r[l].id&&(h===l?a.push(f.jsx(c5,{color:p.color,d:`M ${Jo*(h+1)} 0 V ${$p}`},`v-${h}`)):a.push(f.jsx(c5,{color:p.color,d:[`M ${Jo*(h+1)} 0`,"V 6",`A ${Tp} ${Tp} 0 0 1 ${Jo*(h+1)-Tp} ${_c}`,`H ${Jo*(l+1)+Tp}`,`A ${Tp} ${Tp} 0 0 0 ${Jo*(l+1)} ${_c+Tp}`,`V ${$p}`].join(" ")},`shift-${h}`)),l++)}for(let h=1;h<e.parents.length;h++){const p=QXn(t,e.parents[h]);p!==-1&&a.push(f.jsx(c5,{color:r[p].color,d:`M ${Jo*p} ${_c} A ${Jo} ${Jo} 0 0 1 ${Jo*(p+1)} ${$p} M ${Jo*p} ${_c} H ${Jo*(i+1)}`},`merge-${h}`))}const c=Jo*(i+1);o!==-1&&a.push(f.jsx(c5,{color:n[o].color,d:`M ${c} 0 V ${_c}`},"in")),e.parents.length>0&&a.push(f.jsx(c5,{color:s,d:`M ${c} ${_c} V ${$p}`},"out"));const u=Jo*(Math.max(n.length,r.length,1)+1),d=e.parents.length>1;return f.jsxs("svg",{"aria-hidden":"true",className:"shrink-0 overflow-visible",width:u,height:$p,viewBox:`0 0 ${u} ${$p}`,children:[a,t.isHead?f.jsxs(f.Fragment,{children:[f.jsx("circle",{cx:c,cy:_c,r:HO+3,fill:s,stroke:"var(--background)",strokeWidth:1.5}),f.jsx("circle",{cx:c,cy:_c,r:1.5,fill:"var(--background)"})]}):d?f.jsxs(f.Fragment,{children:[f.jsx("circle",{cx:c,cy:_c,r:HO+1,fill:s}),f.jsx("circle",{cx:c,cy:_c,r:HO-1.5,fill:"var(--background)"})]}):f.jsx("circle",{cx:c,cy:_c,r:HO,fill:s})]})}function KXn({itemRef:t}){const e=t.kind==="head";return f.jsx("span",{title:`${t.name} (${t.kind==="head"?"current branch":t.kind})`,"data-testid":`commits-panel__ref--${t.name}`,"data-ref-kind":t.kind,className:`max-w-[8rem] truncate rounded-full border px-1.5 py-0.5 text-[10px] leading-none ${e?"":"border-border text-muted-foreground"}`,style:e?{borderColor:JT,color:JT}:void 0,children:t.name})}const JXn=new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric"}),eKn=v.memo(function({row:e,expanded:n,onToggle:r}){const{commit:o}=e,i=o.refs.slice(0,2),s=o.refs.slice(2),a=n?Pi:bo;return f.jsxs("button",{type:"button",onClick:()=>r(o.sha),"aria-expanded":n,title:`${o.subject}
1038
- ${o.sha.slice(0,7)} · ${o.author}`,"data-testid":`commits-panel__row--${o.sha}`,"data-head":e.isHead?"true":void 0,className:"grid h-6 w-full min-w-0 cursor-pointer grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-x-1.5 pr-3 pl-1 text-left text-xs hover:bg-accent/50",children:[f.jsx(XXn,{row:e}),f.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[f.jsx(a,{className:"size-3 shrink-0 text-muted-foreground"}),f.jsx("span",{className:"truncate text-foreground",children:o.subject})]}),o.refs.length>0&&f.jsxs("span",{className:"flex shrink-0 items-center gap-1 overflow-hidden",children:[i.map(l=>f.jsx(KXn,{itemRef:l},`${l.kind}:${l.name}`)),s.length>0&&f.jsxs("span",{className:"shrink-0 text-[10px] leading-none text-muted-foreground",title:s.map(l=>l.name).join(", "),"data-testid":"commits-panel__more-refs",children:["+",s.length]})]})]})});function tKn(t){return t==="A"||t==="D"||t==="R"?t:"M"}function nKn({lanes:t}){return f.jsx("svg",{"aria-hidden":"true",className:"pointer-events-none absolute top-0 left-1 z-10 h-full",width:Jo*(t.length+1),children:t.map((e,n)=>f.jsx("line",{x1:Jo*(n+1),x2:Jo*(n+1),y1:"0",y2:"100%",stroke:e.color,strokeWidth:1},n))})}function rKn({worktreeId:t,row:e,onOpenFile:n}){const{commit:r,outputSwimlanes:o}=e,i={paddingLeft:4+Jo*(Math.max(o.length,1)+1)+6},s=It({queryKey:["commitDetails",t,r.sha],queryFn:()=>Se.worktree.getCommitDetails.query({worktreeId:t,sha:r.sha}),staleTime:Number.POSITIVE_INFINITY}),a=[r.author,JXn.format(r.ts*1e3),r.sha.slice(0,7)].join(" · "),l=s.data?.files;return f.jsxs("div",{className:"relative bg-muted/20","data-testid":`commits-panel__files--${r.sha}`,children:[f.jsx(nKn,{lanes:o}),f.jsx("div",{className:"truncate py-1 pr-3 text-[11px] text-muted-foreground",style:i,children:a}),s.isError?f.jsx("div",{className:"py-1 pr-3 text-[11px] text-destructive",style:i,children:s.error instanceof Error?s.error.message:"Failed to load files"}):l?l.length===0?f.jsx("div",{className:"py-1 pr-3 text-[11px] text-muted-foreground",style:i,children:"No file changes"}):l.map(c=>{const u=c.path.split("/").pop()??c.path,d=c.path.slice(0,c.path.length-u.length).replace(/\/$/,""),h=U2(u);return f.jsxs("button",{type:"button",title:c.oldPath?`${c.oldPath} → ${c.path}`:c.path,onClick:()=>n(r.sha,c.path,!1),onDoubleClick:()=>n(r.sha,c.path,!0),"data-testid":`commits-panel__file--${c.path}`,style:i,className:"flex h-6 w-full min-w-0 items-center gap-1.5 pr-3 text-left text-xs hover:bg-accent/50",children:[f.jsx(h,{className:"size-3.5 shrink-0"}),f.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[f.jsx("span",{className:"text-foreground",children:u}),d&&f.jsx("span",{className:"ml-1.5 text-[11px] text-muted-foreground",children:d})]}),f.jsx(xye,{status:tKn(c.status)})]},c.path)}):f.jsx("div",{className:"py-1 pr-3 text-[11px] text-muted-foreground",style:i,children:"Loading files…"})]})}function oKn({worktreeId:t,visible:e,onOpenFile:n}){const[r,o]=v.useState(()=>y8e(_8e)==="true"),[i,s]=v.useState(()=>{const N=Number(y8e(x8e));return N>0?k8e(N):ZXn}),[a,l]=v.useState(()=>new Set),c=e&&!r,u=v.useCallback(()=>{o(N=>(w8e(_8e,String(!N)),!N))},[]),d=Dye({queryKey:["commitHistory",t],queryFn:({pageParam:N})=>Se.worktree.getCommitHistory.query({worktreeId:t,skip:N,limit:UXn}),initialPageParam:0,getNextPageParam:(N,V)=>N.hasMore?V.reduce((G,K)=>G+K.commits.length,0):void 0,enabled:c,refetchOnWindowFocus:!1}),h=It({queryKey:["commitHistorySignature",t],queryFn:()=>Se.worktree.getCommitHistorySignature.query({worktreeId:t}),enabled:c,refetchInterval:c?WXn:!1}),p=d.data?.pages[0]?.signature,{isFetching:g}=d,_=Rn(),{refetch:x}=d,y=v.useCallback(()=>(_.setQueryData(["commitHistory",t],N=>N&&{pages:N.pages.slice(0,1),pageParams:N.pageParams.slice(0,1)}),x()),[_,t,x]),{refetch:k}=h,O=v.useRef(null);v.useEffect(()=>{const N=h.data;N===void 0||p===void 0||g||N===p||O.current===N||(O.current=N,y())},[h.data,p,g,y]);const C=d.data?.pages,A=v.useMemo(()=>C?qXn(C.flatMap(N=>N.commits),C[0]?.head??null):[],[C]),E=d.hasNextPage,M=v.useCallback(N=>{l(V=>{const G=new Set(V);return G.has(N)?G.delete(N):G.add(N),G})},[]),[P,L]=v.useState(null),{fetchNextPage:D,isFetchingNextPage:I}=d;v.useEffect(()=>{const N=P?.parentElement;if(!P||!N||!E)return;const V=new IntersectionObserver(G=>{G.some(K=>K.isIntersecting)&&!I&&D()},{root:N,rootMargin:"96px"});return V.observe(P),()=>V.disconnect()},[P,E,I,D]);const z=v.useCallback(N=>{N.preventDefault();const V=N.clientY,G=i;let K=G;const q=U=>{K=k8e(G+V-U.clientY),s(K)},Z=()=>{window.removeEventListener("pointermove",q),window.removeEventListener("pointerup",Z),w8e(x8e,String(K))};window.addEventListener("pointermove",q),window.addEventListener("pointerup",Z)},[i]),Y=v.useCallback(()=>{if(r){u();return}k(),y()},[r,u,k,y]),Q=A.length,H=r?bo:Pi;return f.jsxs("div",{className:"relative shrink-0 border-t border-border","data-testid":"commits-panel",children:[!r&&f.jsx("div",{className:"absolute inset-x-0 -top-1 z-10 h-2 cursor-row-resize",onPointerDown:z,"data-testid":"commits-panel__resize"}),f.jsxs("div",{className:"flex h-7 items-center gap-1 pr-2 pl-1",children:[f.jsxs("button",{type:"button",onClick:u,"aria-expanded":!r,"data-testid":"commits-panel__toggle",className:"flex h-full min-w-0 flex-1 items-center gap-1 text-left text-[11px] font-semibold tracking-wide text-muted-foreground uppercase",children:[f.jsx(H,{className:"size-3.5 shrink-0"}),f.jsx("span",{children:"Commits"}),C&&f.jsxs("span",{className:"text-[10px] font-medium tabular-nums","data-testid":"commits-panel__count",children:[Q,E?"+":""]})]}),f.jsx("button",{type:"button",onClick:Y,"aria-label":"Refresh commits",title:"Refresh commits","data-testid":"commits-panel__refresh",className:"inline-flex size-5 items-center justify-center rounded-sm text-muted-foreground hover:bg-accent hover:text-foreground",children:f.jsx($0,{className:`size-3.5 ${d.isFetching?"animate-spin":""}`})})]}),!r&&f.jsx("div",{className:"overflow-y-auto",style:{height:`min(${i}px, 50vh)`},"data-testid":"commits-panel__list",children:d.isError&&!C?f.jsx("p",{className:"px-3 py-2 text-[11px] text-destructive",children:d.error instanceof Error?d.error.message:"Failed to load commits"}):C?A.length===0?f.jsx("p",{className:"px-3 py-2 text-[11px] text-muted-foreground",children:"No commits yet"}):f.jsxs(f.Fragment,{children:[A.map(N=>{const V=a.has(N.commit.sha);return f.jsxs("div",{children:[f.jsx(eKn,{row:N,expanded:V,onToggle:M}),V&&f.jsx(rKn,{worktreeId:t,row:N,onOpenFile:n})]},N.commit.sha)}),E&&f.jsx("div",{ref:L,className:"px-3 py-1",children:f.jsx("button",{type:"button",onClick:()=>{D()},disabled:I,"data-testid":"commits-panel__load-more",className:"text-[11px] text-muted-foreground hover:text-foreground",children:I?"Loading…":"Load more"})})]}):f.jsx("p",{className:"px-3 py-2 text-[11px] text-muted-foreground",children:"Loading commits…"})})]})}const O8e=50,iKn=150;function sKn({worktreeId:t,headBranch:e,defaultBranch:n,compareBranch:r,onSelectBranch:o}){const i=Rr(),[s,a]=v.useState(!1),[l,c]=v.useState(""),[u,d]=v.useState(""),[h,p]=v.useState("");v.useEffect(()=>{const E=setTimeout(()=>d(l.trim()),iKn);return()=>clearTimeout(E)},[l]),v.useEffect(()=>{s||(c(""),d(""))},[s]);const g=It({queryKey:["diffTargetBranches",t,u],queryFn:()=>i.listWorktreeBranches?.(t,{query:u||void 0,limit:O8e})??null,enabled:s&&!!i.listWorktreeBranches,placeholderData:Sye}),_=g.data?.branches??[],x=r??n,y=x??"",k=l.trim()!=="";v.useEffect(()=>{s&&p(y)},[s,y]);const O=l.trim()!==u||g.isPlaceholderData,C=g.data;v.useEffect(()=>{if(O&&k){p("");return}if(!C)return;const E=C.branches;p(M=>k||!E.includes(M)?E[0]??"":M)},[C,k,O]);const A=E=>{o(E),a(!1)};return f.jsxs("div",{className:"shrink-0 border-b border-border px-2 py-1.5 text-xs","data-testid":"right-sidepanel__diff-target",children:[f.jsxs("div",{className:"flex h-5 min-w-0 items-center gap-1.5 px-1.5 font-medium text-foreground",title:e,children:[f.jsx(ub,{className:"size-3.5 shrink-0 text-muted-foreground"}),f.jsx("span",{className:"truncate","data-testid":"right-sidepanel__head-branch",children:e??""})]}),f.jsxs(t0,{open:s,onOpenChange:a,children:[f.jsx(ku,{asChild:!0,children:f.jsxs("button",{type:"button","data-testid":"right-sidepanel__diff-target-select",title:x?`Compare with ${x}`:void 0,className:"flex h-6 w-full min-w-0 items-center gap-1.5 rounded-md px-1.5 text-left text-muted-foreground hover:bg-accent hover:text-foreground",children:[f.jsx(D7e,{className:"size-3.5 shrink-0"}),f.jsx("span",{className:"truncate",children:x??""}),f.jsx(Pi,{className:"ml-auto size-3.5 shrink-0"})]})}),f.jsx(n0,{align:"start",className:"w-80 p-0","data-testid":"right-sidepanel__diff-target-picker",children:f.jsxs(S4,{shouldFilter:!1,value:h,onValueChange:p,children:[f.jsx(zg,{value:l,onValueChange:c,placeholder:"Search branches","data-testid":"right-sidepanel__diff-target-search"}),n&&f.jsx("div",{className:"border-b border-border p-1",children:f.jsxs(Ce,{size:"sm",variant:"ghost",className:"h-7 w-full justify-start gap-2 px-2 text-xs",title:n,"data-testid":"right-sidepanel__diff-target-default",onClick:()=>A(n),children:[f.jsx(ub,{className:"size-3.5"}),"Default branch",f.jsx("span",{className:"ml-auto truncate text-muted-foreground",children:n})]})}),f.jsxs(jh,{"data-testid":"right-sidepanel__diff-target-list",children:[!g.isFetching&&f.jsx(C4,{className:"py-4 text-center text-xs text-muted-foreground","data-testid":"right-sidepanel__diff-target-empty",children:"No matching branches"}),f.jsx("div",{className:"p-1",children:_.map(E=>f.jsxs(M0,{value:E,onSelect:A,"data-testid":"right-sidepanel__diff-target-option",className:"text-xs",children:[f.jsx(aKn,{visible:y===E}),f.jsx("span",{className:"truncate",children:E})]},E))}),g.data?.truncated&&f.jsxs("p",{className:"px-3 pb-2 text-[11px] text-muted-foreground","data-testid":"right-sidepanel__diff-target-truncated",children:["Showing the first ",O8e," matches. Type to narrow the list."]})]})]})})]})]})}function aKn({visible:t}){return f.jsx(Ji,{className:t?"size-3.5":"size-3.5 invisible"})}const qZe="band:right-sidepanel-tab";function Pne(t){return t==="explorer"||t==="changes"||typeof t=="string"&&t.startsWith("plugin:")}function lKn(){try{const t=localStorage.getItem(qZe);return Pne(t)?t:"explorer"}catch{return"explorer"}}function VZe(t){try{Hn.setItem(qZe,t)}catch{}}const QZe=v.createContext(!1),cKn=8;function DH({label:t,icon:e,active:n,onClick:r,badge:o,testid:i,tooltip:s}){const a=v.useContext(QZe);return f.jsxs("button",{type:"button",role:"tab","aria-selected":n,onClick:r,title:s??t,"aria-label":s??t,"data-testid":i,style:ite,className:`flex h-7 shrink-0 items-center justify-center gap-1 rounded-md px-1.5 text-xs font-medium transition-colors ${n?"bg-accent text-foreground shadow-[inset_0_0_0_1px_var(--border)]":"text-muted-foreground hover:bg-accent/50 hover:text-foreground hover:shadow-[inset_0_0_0_1px_var(--border)]"}`,children:[f.jsx(e,{className:"size-3.5 shrink-0"}),!a&&f.jsx("span",{className:"whitespace-nowrap",children:t}),o!=null&&o>0&&f.jsx("span",{className:"inline-flex h-4 min-w-4 shrink-0 items-center justify-center rounded-full bg-info-bg px-1 text-[10px] font-medium text-info",children:o})]})}function FO({label:t,icon:e,onClick:n,testid:r}){return f.jsx("button",{type:"button","aria-label":t,title:t,onClick:n,"data-testid":r,className:"inline-flex size-5 items-center justify-center rounded-sm text-muted-foreground hover:bg-accent hover:text-foreground",children:f.jsx(e,{className:"size-3.5"})})}function uKn({folderName:t,browserRef:e}){return f.jsxs("div",{className:"group flex h-7 shrink-0 items-center gap-1 pr-2 pl-3",children:[f.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-semibold tracking-wide text-muted-foreground uppercase",children:t}),f.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100 [@media(hover:none)]:opacity-100",children:[f.jsx(FO,{label:"New File",icon:tot,onClick:()=>e.current?.startNewFile(),testid:"explorer-header__new-file"}),f.jsx(FO,{label:"New Folder",icon:vM,onClick:()=>e.current?.startNewFolder(),testid:"explorer-header__new-folder"}),f.jsx(FO,{label:"Refresh Explorer",icon:$0,onClick:()=>{e.current?.refresh()},testid:"explorer-header__refresh"}),f.jsx(FO,{label:"Collapse Folders in Explorer",icon:B7e,onClick:()=>e.current?.collapseAll(),testid:"explorer-header__collapse-all"})]})]})}function QW({children:t,actions:e}){const n=v.useRef(null),[r,o]=v.useState(!1),i=v.useRef(!1),s=v.useRef(0),a=v.useRef(()=>{});a.current=()=>{const c=n.current;c&&(i.current?c.clientWidth>=s.current+cKn&&(i.current=!1,o(!1)):c.scrollWidth>c.clientWidth&&(s.current=c.scrollWidth,i.current=!0,o(!0)))};const l=!!t;return v.useLayoutEffect(()=>{a.current()}),v.useLayoutEffect(()=>{const c=n.current;if(!l||!c)return;const u=new ResizeObserver(()=>a.current());return u.observe(c),()=>u.disconnect()},[l]),f.jsxs("div",{className:"flex h-[38px] shrink-0 items-stretch gap-1 border-b border-border pr-2",style:hN,"data-testid":"right-sidepanel__header",children:[t?f.jsx("div",{ref:n,role:"tablist",className:"flex min-w-0 flex-1 items-center gap-0.5 overflow-x-auto pl-1.5 [scrollbar-width:none]",children:f.jsx(QZe.Provider,{value:r,children:t})}):f.jsx("div",{className:"flex-1"}),e]})}function dKn({visible:t=!0,headerActions:e}){const n=Mo({select:o=>o.location.pathname}),r=v8(n);return v.useEffect(()=>{const o=i=>{const s=i.detail?.tab;Pne(s)&&VZe(s)};return window.addEventListener("band:right-sidepanel-set-tab",o),()=>window.removeEventListener("band:right-sidepanel-set-tab",o)},[]),r?f.jsx(fKn,{worktreeId:r,visible:t,headerActions:e},r):f.jsxs("div",{className:"flex h-full flex-col","data-testid":"right-sidepanel",children:[f.jsx(QW,{actions:e}),f.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center px-6 text-center",children:f.jsxs("div",{className:"flex flex-col items-center gap-2",children:[f.jsx(ld,{className:"size-6 text-muted-foreground/30"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"No worktree selected"})]})})]})}function fKn({worktreeId:t,visible:e,headerActions:n}){const[r,o]=v.useState(()=>lKn()),i=WFe(),s=i.find(P=>`plugin:${P.key}`===r),a=r.startsWith("plugin:")&&!s?"explorer":r;v.useEffect(()=>{VZe(r)},[r]),v.useEffect(()=>{const P=L=>{const D=L.detail?.tab;Pne(D)&&o(D)};return window.addEventListener("band:right-sidepanel-set-tab",P),()=>window.removeEventListener("band:right-sidepanel-set-tab",P)},[]);const l=Gx(t),c=v.useRef(null),u=l?.replace(/[/\\]+$/,"").split(/[/\\]/).pop()||"Explorer",{compareBranch:d,setCompareBranch:h}=GHe(t),{currentFile:p}=UMn(t),g=GMn(t),_=Xx(t,{enabled:e&&!g.offline,refetchInterval:e&&!g.offline?15e3:!1}),[x,y]=v.useState(null);v.useEffect(()=>{const P=_.data;P&&y({worktreeId:t,headBranch:P.headBranch,defaultBranch:P.defaultBranch})},[_.data,t]);const k=_.data??(x?.worktreeId===t?x:void 0),O=LFe(_.data),C=v.useCallback((P,L)=>Io(t)?.openFile(P,{preview:!L}),[t]),A=v.useCallback((P,L,D)=>Io(t)?.openDiff(L.path,{preview:!D,section:P,oldPath:L.oldPath}),[t]),E=v.useCallback(P=>Io(t)?.openSectionDiffs(P),[t]),M=v.useCallback((P,L,D)=>Io(t)?.openCommitDiff(P,L,{preview:!D}),[t]);return g.offline?f.jsxs("div",{className:"flex h-full flex-col overflow-hidden","data-testid":"right-sidepanel",children:[f.jsx(QW,{actions:n}),f.jsx("div",{className:"min-h-0 flex-1",children:g.active?f.jsx(ePn,{worktreeId:t}):f.jsx(KMn,{worktreeId:t})})]}):f.jsxs("div",{className:"flex h-full flex-col overflow-hidden","data-testid":"right-sidepanel",children:[f.jsxs(QW,{actions:n,children:[f.jsx(DH,{label:"Explorer",icon:ld,active:a==="explorer",onClick:()=>o("explorer"),testid:"right-sidepanel__tab--explorer"}),f.jsx(DH,{label:"Changes",icon:B2,badge:O,active:r==="changes",onClick:()=>o("changes"),testid:"right-sidepanel__tab--changes"}),i.map(({key:P,slug:L,tab:D})=>f.jsx(DH,{label:D.label,icon:D.icon,active:r===`plugin:${P}`,onClick:()=>o(`plugin:${P}`),testid:`right-sidepanel__tab--${L}`},P))]}),f.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:s?f.jsx("div",{className:"flex h-full flex-col overflow-hidden","data-testid":`right-sidepanel__plugin--${s.slug}`,children:f.jsx(IFe,{pluginId:s.pluginId,children:f.jsx(jFe,{value:x$e,children:f.jsx(s.tab.component,{worktreeId:t,visible:e})})})}):a==="explorer"?f.jsxs("div",{className:"flex h-full flex-col","data-testid":"right-sidepanel__explorer",children:[f.jsx(uKn,{folderName:u,browserRef:c}),f.jsx("div",{className:"min-h-0 flex-1",children:f.jsx($He,{ref:c,worktreeId:t,worktreePath:l,onOpenFile:P=>C(P,!1),onOpenFilePinned:P=>C(P,!0),selectedFile:p,onPathRenamed:(P,L)=>Io(t)?.onPathMoved(P,L),onPathDeleted:P=>Io(t)?.onPathRemoved(P),compact:!0})})]}):f.jsxs("div",{className:"flex h-full flex-col overflow-hidden","data-testid":"right-sidepanel__changes",children:[f.jsx(sKn,{worktreeId:t,headBranch:k?.headBranch,defaultBranch:k?.defaultBranch,compareBranch:d,onSelectBranch:h}),f.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:f.jsx(GFe,{worktreeId:t,changes:_.data,onOpen:A,onViewAll:E,editable:!0,worktreePath:l,activeFile:p})}),f.jsx(oKn,{worktreeId:t,visible:e,onOpenFile:M})]})})]})}const hKn={stack:[],cursor:-1};function pKn(t,e){const n=Mo({select:c=>c.location.pathname}),r=v8(n),[o,i]=v.useState(hKn),s=v.useRef(!1);v.useEffect(()=>{const c=s.current;s.current=!1,!(!r||c)&&i(u=>{if(u.cursor>=0&&u.stack[u.cursor]===r)return u;const d=[...u.stack.slice(0,u.cursor+1),r];return{stack:d,cursor:d.length-1}})},[r]);const a=v.useCallback(()=>{let c=!1,u;if(i(d=>{if(d.cursor<=0)return d;c=!0;const h=d.cursor-1;return u=d.stack[h],{stack:d.stack,cursor:h}}),c&&u){s.current=!0;const d=e.getWorktreeHref?.(u);d&&t(d)}},[t,e]),l=v.useCallback(()=>{let c=!1,u;if(i(d=>{if(d.cursor>=d.stack.length-1)return d;c=!0;const h=d.cursor+1;return u=d.stack[h],{stack:d.stack,cursor:h}}),c&&u){s.current=!0;const d=e.getWorktreeHref?.(u);d&&t(d)}},[t,e]);return{goBack:a,goForward:l,canGoBack:o.cursor>0,canGoForward:o.cursor>=0&&o.cursor<o.stack.length-1}}function mKn(){v.useEffect(()=>{if(On)return;const t=e=>{if(e.metaKey||e.ctrlKey){if(e.key==="="||e.key==="+"){e.preventDefault(),e.stopPropagation(),wqe();return}if(e.key==="-"){e.preventDefault(),e.stopPropagation(),kqe();return}e.shiftKey&&e.code==="Digit0"&&(e.preventDefault(),e.stopPropagation(),Oqe())}};return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)},[])}const gKn=6e4,vKn=250;function bKn(t){return t.focused&&!t.onBattery?"active":!t.focused&&t.onBattery?"background":"idle"}let S8e=!1;function _Kn(){if(S8e||typeof window>"u")return;S8e=!0;const t=typeof crypto.randomUUID=="function"?crypto.randomUUID():`c${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;let e=null;const n=()=>{e=null,Se.services.setActivity.mutate({activity:bKn(U0()),clientId:t}).catch(()=>{})};Wx(()=>{e||(e=setTimeout(n,vKn))}),setInterval(n,gKn),window.addEventListener("pagehide",()=>{j4(vA("/trpc/services.releaseActivity"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clientId:t}),keepalive:!0}).catch(()=>{})}),n()}const xKn=new Map,yKn=new Set;function wKn(t,e){xKn.set(t,{filePath:e});for(const n of yKn)n()}function kKn(t,e){if(t.kind!=="open-file")return{handled:!1,reason:"not-open-file"};const n=typeof t.worktreeId=="string"?t.worktreeId:void 0;if(!n)return{handled:!1,reason:"missing-worktree-id"};const r=typeof t.filePath=="string"?t.filePath:void 0;return r?t.external===!0?(wKn(n,r),e.onActivateFilesPanel(n),{handled:!0,kind:"external"}):(e.onOpenFile(n,r),{handled:!0,kind:"in-worktree"}):{handled:!1,reason:"missing-file-path"}}const aC="band:last-worktree";let UW=!1;function OKn(){UW=!0}function SKn(t){UW&&(UW=!1,!t)||Hn.getItem(aC)!==t&&(t?Hn.setItem(aC,t):Hn.removeItem(aC))}function CKn(t){const e=new Map;for(const o of t)for(const i of o.worktrees)e.set(jr(o.name,i.name,i.hostId),i.groupId);const n=Hn.getItem(aC),r=Hn.getItem(Hb);if(!n)return null;if(r&&e.get(n)!==r){const o=Mq()[r];if(o&&e.get(o)===r)return o}return e.has(n)?n:null}function AKn(t){if(t instanceof Error)return{message:t.message||t.name,stack:t.stack??""};if(typeof t=="string")return{message:t,stack:""};try{return{message:JSON.stringify(t)??String(t),stack:""}}catch{return{message:String(t),stack:""}}}function EKn(t,e=TKn()){if(!e)return()=>{};const n=()=>t.location?.href??"",r=(s,a)=>{try{e({kind:s,...AKn(a),url:n()})}catch{}},o=s=>r("error",s.error??s.message??"Unknown error"),i=s=>r("unhandledrejection",s.reason);return t.addEventListener("error",o),t.addEventListener("unhandledrejection",i),()=>{t.removeEventListener("error",o),t.removeEventListener("unhandledrejection",i)}}function TKn(){const t=EP();return t?e=>{t.invoke("report_renderer_error",e).catch(()=>{})}:null}const UZe="band:sidebar-width";function MKn(){try{const t=localStorage.getItem(UZe);if(t){const e=Number.parseFloat(t);if(!Number.isNaN(e)&&e>0&&e<100)return e}}catch{}return null}function PKn(t){try{Hn.setItem(UZe,String(t))}catch{}}const WZe="band:sidebar-collapsed";function jKn(){try{return localStorage.getItem(WZe)==="1"}catch{return!1}}function NKn(t){try{Hn.setItem(WZe,t?"1":"0")}catch{}}const C8e="15rem",RKn="60%",ZZe="band:right-panel-width";function LKn(){try{const t=localStorage.getItem(ZZe);if(t){const e=Number.parseFloat(t);if(!Number.isNaN(e)&&e>0&&e<100)return e}}catch{}return null}function IKn(t){try{Hn.setItem(ZZe,String(t))}catch{}}const GZe="band:right-panel-collapsed";function DKn(){try{return localStorage.getItem(GZe)==="1"}catch{return!1}}function zKn(t){try{Hn.setItem(GZe,t?"1":"0")}catch{}}const A8e="15rem",$Kn="60%",BKn=`(function(){var d=document.documentElement;try{var t=localStorage.getItem(${JSON.stringify(vg)})||"dark";var dark=t==="dark"||(t==="system"&&window.matchMedia("(prefers-color-scheme:dark)").matches);if(dark)d.classList.add("dark");else d.classList.remove("dark");try{var c=JSON.parse(localStorage.getItem(${JSON.stringify(YBe)})||"null");var v=c&&c[dark?"dark":"light"];if(v)for(var k in v)if(k.slice(0,2)==="--"&&typeof v[k]==="string")d.style.setProperty(k,v[k])}catch(e){}}catch(e){d.classList.add("dark")}})()`,YZe="data-translucent-sidebar",XZe="band:translucent-sidebar",HKn=On&&typeof navigator<"u"&&/Mac/.test(navigator.userAgent),FKn=`(function(){try{if(!("__BAND_DESKTOP__" in window)||!/Mac/.test(navigator.userAgent))return;if(localStorage.getItem(${JSON.stringify(XZe)})==="0")return;document.documentElement.setAttribute(${JSON.stringify(YZe)},"")}catch(e){}})()`;function qKn(t){const e=t&&HKn;document.documentElement.toggleAttribute(YZe,e);try{localStorage.setItem(XZe,t?"1":"0")}catch{}}const q_=On?new fAn:new kFe,lC=On?new hAn:new OFe,jne=Xtt({head:()=>({meta:[{charSet:"utf-8"},{name:"viewport",content:"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover, interactive-widget=resizes-content"},{title:"Band"},{name:"apple-mobile-web-app-capable",content:"yes"},{name:"apple-mobile-web-app-status-bar-style",content:"black"},{name:"theme-color",content:"#1e1e1e"}],links:[{rel:"manifest",href:"/manifest.webmanifest"},{rel:"apple-touch-icon",href:"/icons/apple-touch-icon.png"}]}),shellComponent:eJn,component:tJn,notFoundComponent:VKn});function VKn(){return f.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-4 p-8 text-center",children:[f.jsx("p",{className:"text-4xl font-bold",children:"404"}),f.jsx("p",{className:"text-sm text-muted-foreground",children:"Page not found"}),f.jsx(cZ,{to:"/",className:"text-sm text-primary underline",children:"Back to dashboard"})]})}const QKn='(function(){try{var z=localStorage.getItem("band:zoom-level");var n=1;if(z){var p=parseFloat(z);if(!isNaN(p)&&p>=0.5&&p<=2)n=p;}var d=document.documentElement;d.style.zoom=String(n);d.style.setProperty("--app-zoom",String(n));}catch(e){}})()';function UKn(){const{settings:t}=Qh(),e=t.theme;return v.useEffect(()=>{try{e&&localStorage.getItem(vg)===null&&localStorage.setItem(vg,e)}catch{}return jyn()},[e]),null}function WKn(){const{settings:t,isLoading:e,error:n}=Qh(),r=t.translucentSidebar??!0,o=!e&&!n;return v.useEffect(()=>{o&&qKn(r)},[r,o]),null}typeof window<"u"&&EKn(window);function ZKn(){return v.useEffect(()=>{try{W_n(),_Kn()}catch(t){console.error("power saver failed to start",t)}},[]),null}function KZe(){const n=document.activeElement?.closest("[data-band-browser-pane]")?.dataset.bandBrowserPaneKey;return n?xUn(n):null}function GKn(){return v.useEffect(()=>{const t="__bandReload",e=window,n=()=>{const r=KZe();if(r){try{r.reload()}catch{}return}window.location.reload()};return e[t]=n,()=>{e[t]===n&&delete e[t]}},[]),null}function YKn(){return v.useEffect(()=>(xN(_N()),window.__bandZoom=t=>{const e=KZe();if(e&&(t==="in"||t==="out"||t==="reset")){yUn(e,t);return}t==="in"?wqe():t==="out"?kqe():Oqe()},()=>{delete window.__bandZoom}),[]),v.useEffect(()=>{const t=e=>{if(e.key!=="band:zoom-level"||!e.newValue)return;const n=Number.parseFloat(e.newValue);!Number.isNaN(n)&&n>=.5&&n<=2&&yqe(n)};return window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)},[]),null}function XKn({children:t}){const[e,n]=v.useState(!1),r=ns();return v.useEffect(()=>{xFt(s=>q_.subscribeStatusEvents(s));let o=!1;const i=lu.fetchQuery({queryKey:Un.repos,queryFn:()=>q_.listRepos()}).catch(()=>null);return(async()=>{if(await gFt(),r.state.location.pathname==="/"){const s=await KKn(i,tX);s||OKn();const a=s?CKn(s):null;a&&!o&&await r.navigate({to:"/worktree/$worktreeId",params:{worktreeId:a},replace:!0})}o||n(!0)})(),()=>{o=!0}},[r]),e?t:null}function KKn(t,e){let n;const r=new Promise(o=>{n=setTimeout(()=>o(null),e)});return Promise.race([t,r]).finally(()=>clearTimeout(n))}function JKn(){const e=eAe()||On,n=ns(),r=Mo({select:le=>le.location.pathname});v.useEffect(()=>{lC.navigate||(lC.navigate=le=>{n.navigate({to:le})})},[n]);const o=v.useCallback(le=>n.navigate({to:le}),[n]),i=pKn(o,lC),{goBack:s,goForward:a}=i;v.useEffect(()=>{const le=Be=>{Be.key!=="ArrowLeft"&&Be.key!=="ArrowRight"||!(Y2()?Be.metaKey&&!Be.ctrlKey:Be.ctrlKey&&!Be.metaKey)||!Be.altKey||Be.shiftKey||(Be.preventDefault(),Be.stopPropagation(),Be.key==="ArrowLeft"?s():a())};return window.addEventListener("keydown",le,!0),window.addEventListener("band:worktree-go-back",s),window.addEventListener("band:worktree-go-forward",a),()=>{window.removeEventListener("keydown",le,!0),window.removeEventListener("band:worktree-go-back",s),window.removeEventListener("band:worktree-go-forward",a)}},[s,a]),mKn();const l=v8(r);v.useEffect(()=>{CMn(l),vUn(l),SKn(l)},[l]),SFt(l);const c=Cn(le=>l?le.statuses.get(l)?.worktreePath:void 0);v.useEffect(()=>{q_.setActiveWorktree(l)},[l]);const u=v.useRef(e);u.current=e,v.useEffect(()=>q_.subscribeStatusEvents(Be=>{u.current&&kKn(Be,{onOpenFile:$1.onOpenFile,onActivateFilesPanel:$1.onActivateFilesPanel})}),[]);const d=v.useCallback(()=>{c&&navigator.clipboard.writeText(c).catch(()=>{})},[c]),h=lle(),p=v.useRef(null),g=v.useRef(null),_=lle(),x=v.useRef(null),y=v.useRef(null),k=v.useRef({collapsed:DKn(),width:LKn()}),[O,C]=v.useState(()=>!k.current.collapsed),A=v.useRef({collapsed:jKn(),width:MKn()}),[E,M]=v.useState(()=>!A.current.collapsed),P=v.useMemo(()=>A.current.collapsed?{sidebar:0,main:100}:A.current.width?{sidebar:A.current.width,main:100-A.current.width}:void 0,[]),L=v.useMemo(()=>{if(k.current.collapsed)return{center:100,rightpanel:0};if(k.current.width!=null)return{center:100-k.current.width,rightpanel:k.current.width}},[]),D=v.useRef(!0),I=v.useRef(null),z=v.useRef(null),Y=v.useCallback(le=>{if(D.current){D.current=!1;return}le.sidebar==null||le.sidebar<=0||(I.current=le.sidebar,z.current==null&&(z.current=requestAnimationFrame(()=>{z.current=null,I.current!=null&&(PKn(I.current),I.current=null)})))},[]),Q=v.useRef(!0),H=v.useRef(null),N=v.useRef(null),V=v.useCallback(le=>{if(Q.current){Q.current=!1;return}le.rightpanel==null||le.rightpanel<=0||(H.current=le.rightpanel,N.current==null&&(N.current=requestAnimationFrame(()=>{N.current=null,H.current!=null&&(IKn(H.current),H.current=null)})))},[]),G=v.useRef(!A.current.collapsed),K=v.useCallback((le,Be,Xe)=>{if(Xe===void 0)return;const ot=le.asPercentage>0;ot!==G.current&&(G.current=ot,M(ot),NKn(!ot))},[]),q=v.useRef(!k.current.collapsed),Z=v.useCallback((le,Be,Xe)=>{if(Xe===void 0)return;const ot=le.asPercentage>0;ot!==q.current&&(q.current=ot,C(ot),zKn(!ot))},[]),U=v.useCallback(()=>{const le=p.current;if(!le||window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;const Be=[le,g.current];for(const Qe of Be)Qe&&(Qe.style.transition="flex-grow 200ms cubic-bezier(0.77, 0, 0.175, 1), flex-basis 200ms cubic-bezier(0.77, 0, 0.175, 1)");let Xe=0;const ot=Qe=>{if(!(Qe&&(Qe.target!==le||Qe.propertyName!=="flex-grow"))){for(const lt of Be)lt&&(lt.style.transition="");le.removeEventListener("transitionend",ot),Xe&&window.clearTimeout(Xe)}};Xe=window.setTimeout(ot,280),le.addEventListener("transitionend",ot)},[]),B=v.useCallback(()=>{const le=h.current;le&&(U(),le.isCollapsed()?le.expand():le.collapse())},[h,U]),ee=v.useCallback(()=>{const le=x.current;if(!le||window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;const Be=[le,y.current];for(const Qe of Be)Qe&&(Qe.style.transition="flex-grow 200ms cubic-bezier(0.77, 0, 0.175, 1), flex-basis 200ms cubic-bezier(0.77, 0, 0.175, 1)");let Xe=0;const ot=Qe=>{if(!(Qe&&(Qe.target!==le||Qe.propertyName!=="flex-grow"))){for(const lt of Be)lt&&(lt.style.transition="");le.removeEventListener("transitionend",ot),Xe&&window.clearTimeout(Xe)}};Xe=window.setTimeout(ot,280),le.addEventListener("transitionend",ot)},[]),te=v.useCallback(()=>{const le=_.current;le&&(ee(),le.isCollapsed()?le.expand():le.collapse())},[_,ee]);v.useEffect(()=>{const le=()=>B(),Be=()=>{h.current?.isCollapsed()&&(U(),h.current.expand())};return window.addEventListener("band:toggle-sidebar",le),window.addEventListener("band:show-sidebar",Be),()=>{window.removeEventListener("band:toggle-sidebar",le),window.removeEventListener("band:show-sidebar",Be)}},[B,h,U]),v.useEffect(()=>{const le=()=>te(),Be=()=>{_.current?.isCollapsed()&&(ee(),_.current.expand())};return window.addEventListener("band:toggle-right-panel",le),window.addEventListener("band:show-right-panel",Be),()=>{window.removeEventListener("band:toggle-right-panel",le),window.removeEventListener("band:show-right-panel",Be)}},[te,_,ee]),v.useEffect(()=>()=>{z.current!=null&&cancelAnimationFrame(z.current),N.current!=null&&cancelAnimationFrame(N.current)},[]);const se=v.useMemo(()=>({onGoBack:i.goBack,onGoForward:i.goForward,canGoBack:i.canGoBack,canGoForward:i.canGoForward,onToggleSidebar:B,sidebarVisible:E}),[i.goBack,i.goForward,i.canGoBack,i.canGoForward,B,E]),ae=BBe(),[he,fe]=v.useState(0),be=v.useCallback(le=>{if(!le)return;const Be=new ResizeObserver(()=>fe(le.offsetWidth));return Be.observe(le),()=>Be.disconnect()},[]),me=v.useMemo(()=>({sidebarVisible:E,navOverlayWidth:he,rightPanelVisible:O,onToggleRightPanel:l?te:void 0}),[E,he,O,l,te]);return e?f.jsx(zWe,{children:f.jsx(EFe.Provider,{value:me,children:f.jsxs("div",{className:"relative flex flex-col h-full w-full overflow-hidden bg-background text-foreground translucent-sidebar:bg-transparent",children:[f.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:f.jsxs(vF,{orientation:"horizontal",defaultLayout:P,onLayoutChanged:Y,className:"h-full w-full",children:[f.jsx(Pv,{id:"sidebar",panelRef:h,elementRef:p,defaultSize:C8e,minSize:C8e,maxSize:RKn,collapsible:!0,collapsedSize:"0%",onResize:K,children:f.jsxs("div",{className:"h-full flex flex-col overflow-hidden border-r border-border bg-sidebar translucent-sidebar:bg-(--sidebar-translucent) pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)]","data-testid":"app-shell__sidebar",children:[f.jsx(rEn,{}),f.jsx("div",{className:"flex-1 min-h-0",children:f.jsx(pHe,{hideTitleBar:!0,bottomActions:f.jsx($We,{})})})]})}),f.jsx(bF,{id:"app-shell__sidebar-separator",className:"w-[3px] bg-background hover:bg-[color-mix(in_srgb,var(--accent-foreground)_20%,var(--background))] active:bg-[color-mix(in_srgb,var(--accent-foreground)_30%,var(--background))] transition-colors cursor-col-resize"}),f.jsx(Pv,{id:"main",elementRef:g,minSize:"20%",children:f.jsx("div",{className:"relative h-full min-w-0 overflow-hidden bg-background pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)]","data-testid":"app-shell__main",children:f.jsxs(vF,{orientation:"horizontal",defaultLayout:L,onLayoutChanged:V,className:"h-full w-full",children:[f.jsx(Pv,{id:"center",elementRef:y,minSize:"30%",children:f.jsxs("div",{className:"h-full flex flex-col min-w-0 overflow-hidden",children:[!l&&f.jsx(MFe,{}),f.jsxs("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden relative",children:[f.jsx(UH,{}),f.jsx(yYn,{}),f.jsx(EAn,{}),f.jsx(NAn,{})]})]})}),f.jsx(bF,{className:"w-[3px] bg-transparent hover:bg-accent-foreground/20 active:bg-accent-foreground/30 transition-colors cursor-col-resize"}),f.jsx(Pv,{id:"rightpanel",panelRef:_,elementRef:x,defaultSize:A8e,minSize:A8e,maxSize:$Kn,collapsible:!0,collapsedSize:"0%",onResize:Z,children:f.jsx("div",{className:"h-full flex flex-col overflow-hidden border-l border-border bg-background","data-testid":"app-shell__right-panel","data-visible":O?"true":"false",children:f.jsx(dKn,{visible:O,headerActions:f.jsx(tEn,{worktreePath:l?c:void 0,onCopyPath:l?d:void 0,onToggleRightPanel:l&&O?te:void 0})})})})]})})})]})}),f.jsx("div",{ref:be,"data-testid":"app-shell__nav-overlay",className:`pointer-events-none absolute top-[env(safe-area-inset-top)] left-0 z-10 flex h-[38px] items-center ${ae}`,children:f.jsx(nEn,{...se})})]})})}):f.jsxs(f.Fragment,{children:[f.jsx(UH,{}),f.jsx($Xn,{})]})}function eJn({children:t}){return f.jsxs("html",{lang:"en",children:[f.jsxs("head",{children:[f.jsx(fnt,{}),f.jsx("script",{dangerouslySetInnerHTML:{__html:BKn}}),f.jsx("script",{dangerouslySetInnerHTML:{__html:QKn}}),f.jsx("script",{dangerouslySetInnerHTML:{__html:FKn}})]}),f.jsxs("body",{children:[t,f.jsx(hnt,{})]})]})}function tJn(){return f.jsxs(ITt,{adapter:q_,capabilities:lC,children:[f.jsx(UKn,{}),f.jsx(WKn,{}),f.jsx(ZKn,{}),f.jsx(YKn,{}),f.jsx(GKn,{}),f.jsxs(jdt,{children:[f.jsx(XKn,{children:f.jsx(JKn,{})}),f.jsx(SAn,{}),f.jsx(ixn,{})]})]})}const nJn=()=>re(()=>import("./index-DIelkckr.js"),[]),rJn=xC("/")({component:QH(nJn,"component")}),oJn=()=>re(()=>import("./worktree._worktreeId-C2psBRXR.js"),[]),iJn=()=>re(()=>import("./worktree._worktreeId-CVx6cyp5.js"),[]),sJn=xC("/worktree/$worktreeId")({component:QH(iJn,"component"),notFoundComponent:QH(oJn,"notFoundComponent")}),aJn=rJn.update({id:"/",path:"/",getParentRoute:()=>jne}),lJn=sJn.update({id:"/worktree/$worktreeId",path:"/worktree/$worktreeId",getParentRoute:()=>jne}),cJn={IndexRoute:aJn,WorktreeWorktreeIdRoute:lJn},uJn=jne._addFileChildren(cJn);function dJn(){return int({routeTree:uJn,scrollRestoration:!0,defaultPendingMinMs:0})}async function fJn(){const t=await dJn();let e;return e=[],window.__TSS_START_OPTIONS__={serializationAdapters:e},e.push(jnt),t.options.serializationAdapters&&e.push(...t.options.serializationAdapters),t.update({basepath:"",serializationAdapters:e}),t.state.matches.length||await mnt(t),t}async function hJn(){const t=await fJn();return window.$_TSR?.h(),t}let zH;function pJn(){return zH||(zH=hJn()),f.jsx(Stt,{promise:zH,children:t=>f.jsx(lnt,{router:t})})}let E8e=!1;function mJn(){return document.querySelectorAll("webview")}function gJn(){if(E8e||typeof document>"u")return;E8e=!0;const t=r=>{!(r instanceof HTMLElement)||r.tagName!=="WEBVIEW"||r.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,composed:!0,pointerType:"mouse",isPrimary:!0,button:0,buttons:1}))};document.addEventListener("focusin",r=>t(r.target),!0),window.addEventListener("blur",()=>t(document.activeElement));const e=new Map,n=()=>{window.removeEventListener("pointermove",n,!0);for(const[r,o]of e)r.style.pointerEvents=o;e.clear()};window.addEventListener("dragstart",()=>{for(const r of mJn())e.has(r)||e.set(r,r.style.pointerEvents),r.style.pointerEvents="none";window.addEventListener("pointermove",n,!0)},!0),window.addEventListener("dragend",n,!0),window.addEventListener("drop",n,!0)}gJn();kZe.hydrateRoot(document,f.jsx(pJn,{}));const vJn=Object.freeze(Object.defineProperty({__proto__:null,Mermaid:cMe},Symbol.toStringTag,{value:"Module"}));export{Icn as $,r3n as A,Vmn as B,i8 as C,wIe as D,ac as E,Px as F,ger as G,Fer as H,Her as I,A0 as J,aer as K,js as L,e1n as M,DJn as N,t1n as O,Ypn as P,Oen as Q,sJn as R,Gpn as S,V6n as T,Ter as U,G0n as V,ver as W,B9 as X,$n as Y,cu as Z,W as _,q6 as a,ZSe as a$,r1n as a0,VJ as a1,$je as a2,da as a3,Hmn as a4,qhn as a5,Vde as a6,JNe as a7,Gfe as a8,Zfe as a9,Q0n as aA,Mx as aB,rn as aC,wn as aD,Zje as aE,C6n as aF,wze as aG,$er as aH,Xpn as aI,ts as aJ,Fh as aK,RJ as aL,ZIe as aM,Q4 as aN,xIe as aO,Cn as aP,lSe as aQ,Zjt as aR,fke as aS,Zr as aT,ul as aU,ft as aV,it as aW,Rke as aX,hke as aY,dA as aZ,Gjt as a_,Cer as aa,yer as ab,Oer as ac,ker as ad,_er as ae,fJ as af,Ser as ag,xer as ah,ei as ai,Eer as aj,Aer as ak,wer as al,TNe as am,b0n as an,YK as ao,t6n as ap,pJ as aq,sg as ar,mer as as,Rj as at,jmn as au,D0n as av,NK as aw,nfe as ax,q9 as ay,Bmn as az,yke as b,yj as b$,Emn as b0,x4n as b1,ymn as b2,LJ as b3,Zhe as b4,vgn as b5,zer as b6,Ber as b7,Ier as b8,fn as b9,D7e as bA,Kf as bB,pa as bC,pM as bD,W7e as bE,Qh as bF,Qer as bG,cN as bH,eer as bI,per as bJ,Y0 as bK,Hx as bL,J5n as bM,K5n as bN,xl as bO,u2n as bP,FK as bQ,dNe as bR,Rx as bS,pNe as bT,ber as bU,Ehn as bV,lfe as bW,afe as bX,Lcn as bY,VNe as bZ,aJ as b_,Der as ba,J6n as bb,Z6n as bc,W6n as bd,MKn as be,PKn as bf,vF as bg,Pv as bh,RKn as bi,C8e as bj,pHe as bk,bF as bl,Q_ as bm,eAe as bn,zWe as bo,$We as bp,On as bq,hJ as br,GK as bs,tt as bt,xCe as bu,Vs as bv,mye as bw,dZ as bx,z7e as by,uZ as bz,iS as c,gfn as c0,mfn as c1,ug as c2,pfn as c3,hfn as c4,dE as c5,Ix as c6,iJ as c7,rJ as c8,i3 as c9,smn as cA,iIe as cB,u4n as cC,d4n as cD,Lp as cE,mhe as cF,f4n as cG,DJ as cH,c4n as cI,m4n as cJ,c8 as cK,Hh as cL,uhe as cM,zJ as cN,aIe as cO,NQ as cP,Mmn as cQ,jj as cR,bJn as cS,re as cT,uE as ca,F4 as cb,Tmn as cc,fIe as cd,Tj as ce,Nj as cf,SE as cg,pIe as ch,dIe as ci,imn as cj,ZK as ck,un as cl,eIe as cm,Amn as cn,xmn as co,a4n as cp,IJ as cq,tmn as cr,Pmn as cs,$x as ct,l8 as cu,wE as cv,fmn as cw,Bgn as cx,zx as cy,OE as cz,OSe as d,U6 as e,qg as f,MNt as g,Hke as h,Fg as i,f as j,Dr as k,Uc as l,K0n as m,J0n as n,X0n as o,Y0n as p,Gr as q,v as r,Hg as s,_e as t,Ir as u,ut as v,Wje as w,Gi as x,rd as y,Yc as z};
1038
+ ${o.sha.slice(0,7)} · ${o.author}`,"data-testid":`commits-panel__row--${o.sha}`,"data-head":e.isHead?"true":void 0,className:"grid h-6 w-full min-w-0 cursor-pointer grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-x-1.5 pr-3 pl-1 text-left text-xs hover:bg-accent/50",children:[f.jsx(XXn,{row:e}),f.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[f.jsx(a,{className:"size-3 shrink-0 text-muted-foreground"}),f.jsx("span",{className:"truncate text-foreground",children:o.subject})]}),o.refs.length>0&&f.jsxs("span",{className:"flex shrink-0 items-center gap-1 overflow-hidden",children:[i.map(l=>f.jsx(KXn,{itemRef:l},`${l.kind}:${l.name}`)),s.length>0&&f.jsxs("span",{className:"shrink-0 text-[10px] leading-none text-muted-foreground",title:s.map(l=>l.name).join(", "),"data-testid":"commits-panel__more-refs",children:["+",s.length]})]})]})});function tKn(t){return t==="A"||t==="D"||t==="R"?t:"M"}function nKn({lanes:t}){return f.jsx("svg",{"aria-hidden":"true",className:"pointer-events-none absolute top-0 left-1 z-10 h-full",width:Jo*(t.length+1),children:t.map((e,n)=>f.jsx("line",{x1:Jo*(n+1),x2:Jo*(n+1),y1:"0",y2:"100%",stroke:e.color,strokeWidth:1},n))})}function rKn({worktreeId:t,row:e,onOpenFile:n}){const{commit:r,outputSwimlanes:o}=e,i={paddingLeft:4+Jo*(Math.max(o.length,1)+1)+6},s=It({queryKey:["commitDetails",t,r.sha],queryFn:()=>Se.worktree.getCommitDetails.query({worktreeId:t,sha:r.sha}),staleTime:Number.POSITIVE_INFINITY}),a=[r.author,JXn.format(r.ts*1e3),r.sha.slice(0,7)].join(" · "),l=s.data?.files;return f.jsxs("div",{className:"relative bg-muted/20","data-testid":`commits-panel__files--${r.sha}`,children:[f.jsx(nKn,{lanes:o}),f.jsx("div",{className:"truncate py-1 pr-3 text-[11px] text-muted-foreground",style:i,children:a}),s.isError?f.jsx("div",{className:"py-1 pr-3 text-[11px] text-destructive",style:i,children:s.error instanceof Error?s.error.message:"Failed to load files"}):l?l.length===0?f.jsx("div",{className:"py-1 pr-3 text-[11px] text-muted-foreground",style:i,children:"No file changes"}):l.map(c=>{const u=c.path.split("/").pop()??c.path,d=c.path.slice(0,c.path.length-u.length).replace(/\/$/,""),h=U2(u);return f.jsxs("button",{type:"button",title:c.oldPath?`${c.oldPath} → ${c.path}`:c.path,onClick:()=>n(r.sha,c.path,!1),onDoubleClick:()=>n(r.sha,c.path,!0),"data-testid":`commits-panel__file--${c.path}`,style:i,className:"flex h-6 w-full min-w-0 items-center gap-1.5 pr-3 text-left text-xs hover:bg-accent/50",children:[f.jsx(h,{className:"size-3.5 shrink-0"}),f.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[f.jsx("span",{className:"text-foreground",children:u}),d&&f.jsx("span",{className:"ml-1.5 text-[11px] text-muted-foreground",children:d})]}),f.jsx(xye,{status:tKn(c.status)})]},c.path)}):f.jsx("div",{className:"py-1 pr-3 text-[11px] text-muted-foreground",style:i,children:"Loading files…"})]})}function oKn({worktreeId:t,visible:e,onOpenFile:n}){const[r,o]=v.useState(()=>y8e(_8e)==="true"),[i,s]=v.useState(()=>{const N=Number(y8e(x8e));return N>0?k8e(N):ZXn}),[a,l]=v.useState(()=>new Set),c=e&&!r,u=v.useCallback(()=>{o(N=>(w8e(_8e,String(!N)),!N))},[]),d=Dye({queryKey:["commitHistory",t],queryFn:({pageParam:N})=>Se.worktree.getCommitHistory.query({worktreeId:t,skip:N,limit:UXn}),initialPageParam:0,getNextPageParam:(N,V)=>N.hasMore?V.reduce((G,K)=>G+K.commits.length,0):void 0,enabled:c,refetchOnWindowFocus:!1}),h=It({queryKey:["commitHistorySignature",t],queryFn:()=>Se.worktree.getCommitHistorySignature.query({worktreeId:t}),enabled:c,refetchInterval:c?WXn:!1}),p=d.data?.pages[0]?.signature,{isFetching:g}=d,_=Rn(),{refetch:x}=d,y=v.useCallback(()=>(_.setQueryData(["commitHistory",t],N=>N&&{pages:N.pages.slice(0,1),pageParams:N.pageParams.slice(0,1)}),x()),[_,t,x]),{refetch:k}=h,O=v.useRef(null);v.useEffect(()=>{const N=h.data;N===void 0||p===void 0||g||N===p||O.current===N||(O.current=N,y())},[h.data,p,g,y]);const C=d.data?.pages,A=v.useMemo(()=>C?qXn(C.flatMap(N=>N.commits),C[0]?.head??null):[],[C]),E=d.hasNextPage,M=v.useCallback(N=>{l(V=>{const G=new Set(V);return G.has(N)?G.delete(N):G.add(N),G})},[]),[P,L]=v.useState(null),{fetchNextPage:D,isFetchingNextPage:I}=d;v.useEffect(()=>{const N=P?.parentElement;if(!P||!N||!E)return;const V=new IntersectionObserver(G=>{G.some(K=>K.isIntersecting)&&!I&&D()},{root:N,rootMargin:"96px"});return V.observe(P),()=>V.disconnect()},[P,E,I,D]);const z=v.useCallback(N=>{N.preventDefault();const V=N.clientY,G=i;let K=G;const q=U=>{K=k8e(G+V-U.clientY),s(K)},Z=()=>{window.removeEventListener("pointermove",q),window.removeEventListener("pointerup",Z),w8e(x8e,String(K))};window.addEventListener("pointermove",q),window.addEventListener("pointerup",Z)},[i]),Y=v.useCallback(()=>{if(r){u();return}k(),y()},[r,u,k,y]),Q=A.length,H=r?bo:Pi;return f.jsxs("div",{className:"relative shrink-0 border-t border-border","data-testid":"commits-panel",children:[!r&&f.jsx("div",{className:"absolute inset-x-0 -top-1 z-10 h-2 cursor-row-resize",onPointerDown:z,"data-testid":"commits-panel__resize"}),f.jsxs("div",{className:"flex h-7 items-center gap-1 pr-2 pl-1",children:[f.jsxs("button",{type:"button",onClick:u,"aria-expanded":!r,"data-testid":"commits-panel__toggle",className:"flex h-full min-w-0 flex-1 items-center gap-1 text-left text-[11px] font-semibold tracking-wide text-muted-foreground uppercase",children:[f.jsx(H,{className:"size-3.5 shrink-0"}),f.jsx("span",{children:"Commits"}),C&&f.jsxs("span",{className:"text-[10px] font-medium tabular-nums","data-testid":"commits-panel__count",children:[Q,E?"+":""]})]}),f.jsx("button",{type:"button",onClick:Y,"aria-label":"Refresh commits",title:"Refresh commits","data-testid":"commits-panel__refresh",className:"inline-flex size-5 items-center justify-center rounded-sm text-muted-foreground hover:bg-accent hover:text-foreground",children:f.jsx($0,{className:`size-3.5 ${d.isFetching?"animate-spin":""}`})})]}),!r&&f.jsx("div",{className:"overflow-y-auto",style:{height:`min(${i}px, 50vh)`},"data-testid":"commits-panel__list",children:d.isError&&!C?f.jsx("p",{className:"px-3 py-2 text-[11px] text-destructive",children:d.error instanceof Error?d.error.message:"Failed to load commits"}):C?A.length===0?f.jsx("p",{className:"px-3 py-2 text-[11px] text-muted-foreground",children:"No commits yet"}):f.jsxs(f.Fragment,{children:[A.map(N=>{const V=a.has(N.commit.sha);return f.jsxs("div",{children:[f.jsx(eKn,{row:N,expanded:V,onToggle:M}),V&&f.jsx(rKn,{worktreeId:t,row:N,onOpenFile:n})]},N.commit.sha)}),E&&f.jsx("div",{ref:L,className:"px-3 py-1",children:f.jsx("button",{type:"button",onClick:()=>{D()},disabled:I,"data-testid":"commits-panel__load-more",className:"text-[11px] text-muted-foreground hover:text-foreground",children:I?"Loading…":"Load more"})})]}):f.jsx("p",{className:"px-3 py-2 text-[11px] text-muted-foreground",children:"Loading commits…"})})]})}const O8e=50,iKn=150;function sKn({worktreeId:t,headBranch:e,defaultBranch:n,compareBranch:r,onSelectBranch:o}){const i=Rr(),[s,a]=v.useState(!1),[l,c]=v.useState(""),[u,d]=v.useState(""),[h,p]=v.useState("");v.useEffect(()=>{const E=setTimeout(()=>d(l.trim()),iKn);return()=>clearTimeout(E)},[l]),v.useEffect(()=>{s||(c(""),d(""))},[s]);const g=It({queryKey:["diffTargetBranches",t,u],queryFn:()=>i.listWorktreeBranches?.(t,{query:u||void 0,limit:O8e})??null,enabled:s&&!!i.listWorktreeBranches,placeholderData:Sye}),_=g.data?.branches??[],x=r??n,y=x??"",k=l.trim()!=="";v.useEffect(()=>{s&&p(y)},[s,y]);const O=l.trim()!==u||g.isPlaceholderData,C=g.data;v.useEffect(()=>{if(O&&k){p("");return}if(!C)return;const E=C.branches;p(M=>k||!E.includes(M)?E[0]??"":M)},[C,k,O]);const A=E=>{o(E),a(!1)};return f.jsxs("div",{className:"shrink-0 border-b border-border px-2 py-1.5 text-xs","data-testid":"right-sidepanel__diff-target",children:[f.jsxs("div",{className:"flex h-5 min-w-0 items-center gap-1.5 px-1.5 font-medium text-foreground",title:e,children:[f.jsx(ub,{className:"size-3.5 shrink-0 text-muted-foreground"}),f.jsx("span",{className:"truncate","data-testid":"right-sidepanel__head-branch",children:e??""})]}),f.jsxs(t0,{open:s,onOpenChange:a,children:[f.jsx(ku,{asChild:!0,children:f.jsxs("button",{type:"button","data-testid":"right-sidepanel__diff-target-select",title:x?`Compare with ${x}`:void 0,className:"flex h-6 w-full min-w-0 items-center gap-1.5 rounded-md px-1.5 text-left text-muted-foreground hover:bg-accent hover:text-foreground",children:[f.jsx(D7e,{className:"size-3.5 shrink-0"}),f.jsx("span",{className:"truncate",children:x??""}),f.jsx(Pi,{className:"ml-auto size-3.5 shrink-0"})]})}),f.jsx(n0,{align:"start",className:"w-80 p-0","data-testid":"right-sidepanel__diff-target-picker",children:f.jsxs(S4,{shouldFilter:!1,value:h,onValueChange:p,children:[f.jsx(zg,{value:l,onValueChange:c,placeholder:"Search branches","data-testid":"right-sidepanel__diff-target-search"}),n&&f.jsx("div",{className:"border-b border-border p-1",children:f.jsxs(Ce,{size:"sm",variant:"ghost",className:"h-7 w-full justify-start gap-2 px-2 text-xs",title:n,"data-testid":"right-sidepanel__diff-target-default",onClick:()=>A(n),children:[f.jsx(ub,{className:"size-3.5"}),"Default branch",f.jsx("span",{className:"ml-auto truncate text-muted-foreground",children:n})]})}),f.jsxs(jh,{"data-testid":"right-sidepanel__diff-target-list",children:[!g.isFetching&&f.jsx(C4,{className:"py-4 text-center text-xs text-muted-foreground","data-testid":"right-sidepanel__diff-target-empty",children:"No matching branches"}),f.jsx("div",{className:"p-1",children:_.map(E=>f.jsxs(M0,{value:E,onSelect:A,"data-testid":"right-sidepanel__diff-target-option",className:"text-xs",children:[f.jsx(aKn,{visible:y===E}),f.jsx("span",{className:"truncate",children:E})]},E))}),g.data?.truncated&&f.jsxs("p",{className:"px-3 pb-2 text-[11px] text-muted-foreground","data-testid":"right-sidepanel__diff-target-truncated",children:["Showing the first ",O8e," matches. Type to narrow the list."]})]})]})})]})]})}function aKn({visible:t}){return f.jsx(Ji,{className:t?"size-3.5":"size-3.5 invisible"})}const qZe="band:right-sidepanel-tab";function Pne(t){return t==="explorer"||t==="changes"||typeof t=="string"&&t.startsWith("plugin:")}function lKn(){try{const t=localStorage.getItem(qZe);return Pne(t)?t:"explorer"}catch{return"explorer"}}function VZe(t){try{Hn.setItem(qZe,t)}catch{}}const QZe=v.createContext(!1),cKn=8;function DH({label:t,icon:e,active:n,onClick:r,badge:o,testid:i,tooltip:s}){const a=v.useContext(QZe);return f.jsxs("button",{type:"button",role:"tab","aria-selected":n,onClick:r,title:s??t,"aria-label":s??t,"data-testid":i,style:ite,className:`flex h-7 shrink-0 items-center justify-center gap-1 rounded-md px-1.5 text-xs font-medium transition-colors ${n?"bg-accent text-foreground shadow-[inset_0_0_0_1px_var(--border)]":"text-muted-foreground hover:bg-accent/50 hover:text-foreground hover:shadow-[inset_0_0_0_1px_var(--border)]"}`,children:[f.jsx(e,{className:"size-3.5 shrink-0"}),!a&&f.jsx("span",{className:"whitespace-nowrap",children:t}),o!=null&&o>0&&f.jsx("span",{className:"inline-flex h-4 min-w-4 shrink-0 items-center justify-center rounded-full bg-info-bg px-1 text-[10px] font-medium text-info",children:o})]})}function FO({label:t,icon:e,onClick:n,testid:r}){return f.jsx("button",{type:"button","aria-label":t,title:t,onClick:n,"data-testid":r,className:"inline-flex size-5 items-center justify-center rounded-sm text-muted-foreground hover:bg-accent hover:text-foreground",children:f.jsx(e,{className:"size-3.5"})})}function uKn({folderName:t,browserRef:e}){return f.jsxs("div",{className:"group flex h-7 shrink-0 items-center gap-1 pr-2 pl-3",children:[f.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-semibold tracking-wide text-muted-foreground uppercase",children:t}),f.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100 [@media(hover:none)]:opacity-100",children:[f.jsx(FO,{label:"New File",icon:tot,onClick:()=>e.current?.startNewFile(),testid:"explorer-header__new-file"}),f.jsx(FO,{label:"New Folder",icon:vM,onClick:()=>e.current?.startNewFolder(),testid:"explorer-header__new-folder"}),f.jsx(FO,{label:"Refresh Explorer",icon:$0,onClick:()=>{e.current?.refresh()},testid:"explorer-header__refresh"}),f.jsx(FO,{label:"Collapse Folders in Explorer",icon:B7e,onClick:()=>e.current?.collapseAll(),testid:"explorer-header__collapse-all"})]})]})}function QW({children:t,actions:e}){const n=v.useRef(null),[r,o]=v.useState(!1),i=v.useRef(!1),s=v.useRef(0),a=v.useRef(()=>{});a.current=()=>{const c=n.current;c&&(i.current?c.clientWidth>=s.current+cKn&&(i.current=!1,o(!1)):c.scrollWidth>c.clientWidth&&(s.current=c.scrollWidth,i.current=!0,o(!0)))};const l=!!t;return v.useLayoutEffect(()=>{a.current()}),v.useLayoutEffect(()=>{const c=n.current;if(!l||!c)return;const u=new ResizeObserver(()=>a.current());return u.observe(c),()=>u.disconnect()},[l]),f.jsxs("div",{className:"flex h-[38px] shrink-0 items-stretch gap-1 border-b border-border pr-2",style:hN,"data-testid":"right-sidepanel__header",children:[t?f.jsx("div",{ref:n,role:"tablist",className:"flex min-w-0 flex-1 items-center gap-0.5 overflow-x-auto pl-1.5 [scrollbar-width:none]",children:f.jsx(QZe.Provider,{value:r,children:t})}):f.jsx("div",{className:"flex-1"}),e]})}function dKn({visible:t=!0,headerActions:e}){const n=Mo({select:o=>o.location.pathname}),r=v8(n);return v.useEffect(()=>{const o=i=>{const s=i.detail?.tab;Pne(s)&&VZe(s)};return window.addEventListener("band:right-sidepanel-set-tab",o),()=>window.removeEventListener("band:right-sidepanel-set-tab",o)},[]),r?f.jsx(fKn,{worktreeId:r,visible:t,headerActions:e},r):f.jsxs("div",{className:"flex h-full flex-col","data-testid":"right-sidepanel",children:[f.jsx(QW,{actions:e}),f.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center px-6 text-center",children:f.jsxs("div",{className:"flex flex-col items-center gap-2",children:[f.jsx(ld,{className:"size-6 text-muted-foreground/30"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"No worktree selected"})]})})]})}function fKn({worktreeId:t,visible:e,headerActions:n}){const[r,o]=v.useState(()=>lKn()),i=WFe(),s=i.find(P=>`plugin:${P.key}`===r),a=r.startsWith("plugin:")&&!s?"explorer":r;v.useEffect(()=>{VZe(r)},[r]),v.useEffect(()=>{const P=L=>{const D=L.detail?.tab;Pne(D)&&o(D)};return window.addEventListener("band:right-sidepanel-set-tab",P),()=>window.removeEventListener("band:right-sidepanel-set-tab",P)},[]);const l=Gx(t),c=v.useRef(null),u=l?.replace(/[/\\]+$/,"").split(/[/\\]/).pop()||"Explorer",{compareBranch:d,setCompareBranch:h}=GHe(t),{currentFile:p}=UMn(t),g=GMn(t),_=Xx(t,{enabled:e&&!g.offline,refetchInterval:e&&!g.offline?15e3:!1}),[x,y]=v.useState(null);v.useEffect(()=>{const P=_.data;P&&y({worktreeId:t,headBranch:P.headBranch,defaultBranch:P.defaultBranch})},[_.data,t]);const k=_.data??(x?.worktreeId===t?x:void 0),O=LFe(_.data),C=v.useCallback((P,L)=>Io(t)?.openFile(P,{preview:!L}),[t]),A=v.useCallback((P,L,D)=>Io(t)?.openDiff(L.path,{preview:!D,section:P,oldPath:L.oldPath}),[t]),E=v.useCallback(P=>Io(t)?.openSectionDiffs(P),[t]),M=v.useCallback((P,L,D)=>Io(t)?.openCommitDiff(P,L,{preview:!D}),[t]);return g.offline?f.jsxs("div",{className:"flex h-full flex-col overflow-hidden","data-testid":"right-sidepanel",children:[f.jsx(QW,{actions:n}),f.jsx("div",{className:"min-h-0 flex-1",children:g.active?f.jsx(ePn,{worktreeId:t}):f.jsx(KMn,{worktreeId:t})})]}):f.jsxs("div",{className:"flex h-full flex-col overflow-hidden","data-testid":"right-sidepanel",children:[f.jsxs(QW,{actions:n,children:[f.jsx(DH,{label:"Explorer",icon:ld,active:a==="explorer",onClick:()=>o("explorer"),testid:"right-sidepanel__tab--explorer"}),f.jsx(DH,{label:"Changes",icon:B2,badge:O,active:r==="changes",onClick:()=>o("changes"),testid:"right-sidepanel__tab--changes"}),i.map(({key:P,slug:L,tab:D})=>f.jsx(DH,{label:D.label,icon:D.icon,active:r===`plugin:${P}`,onClick:()=>o(`plugin:${P}`),testid:`right-sidepanel__tab--${L}`},P))]}),f.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:s?f.jsx("div",{className:"flex h-full flex-col overflow-hidden","data-testid":`right-sidepanel__plugin--${s.slug}`,children:f.jsx(IFe,{pluginId:s.pluginId,children:f.jsx(jFe,{value:x$e,children:f.jsx(s.tab.component,{worktreeId:t,visible:e})})})}):a==="explorer"?f.jsxs("div",{className:"flex h-full flex-col","data-testid":"right-sidepanel__explorer",children:[f.jsx(uKn,{folderName:u,browserRef:c}),f.jsx("div",{className:"min-h-0 flex-1",children:f.jsx($He,{ref:c,worktreeId:t,worktreePath:l,onOpenFile:P=>C(P,!1),onOpenFilePinned:P=>C(P,!0),selectedFile:p,onPathRenamed:(P,L)=>Io(t)?.onPathMoved(P,L),onPathDeleted:P=>Io(t)?.onPathRemoved(P),compact:!0})})]}):f.jsxs("div",{className:"flex h-full flex-col overflow-hidden","data-testid":"right-sidepanel__changes",children:[f.jsx(sKn,{worktreeId:t,headBranch:k?.headBranch,defaultBranch:k?.defaultBranch,compareBranch:d,onSelectBranch:h}),f.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:f.jsx(GFe,{worktreeId:t,changes:_.data,onOpen:A,onViewAll:E,editable:!0,worktreePath:l,activeFile:p})}),f.jsx(oKn,{worktreeId:t,visible:e,onOpenFile:M})]})})]})}const hKn={stack:[],cursor:-1};function pKn(t,e){const n=Mo({select:c=>c.location.pathname}),r=v8(n),[o,i]=v.useState(hKn),s=v.useRef(!1);v.useEffect(()=>{const c=s.current;s.current=!1,!(!r||c)&&i(u=>{if(u.cursor>=0&&u.stack[u.cursor]===r)return u;const d=[...u.stack.slice(0,u.cursor+1),r];return{stack:d,cursor:d.length-1}})},[r]);const a=v.useCallback(()=>{let c=!1,u;if(i(d=>{if(d.cursor<=0)return d;c=!0;const h=d.cursor-1;return u=d.stack[h],{stack:d.stack,cursor:h}}),c&&u){s.current=!0;const d=e.getWorktreeHref?.(u);d&&t(d)}},[t,e]),l=v.useCallback(()=>{let c=!1,u;if(i(d=>{if(d.cursor>=d.stack.length-1)return d;c=!0;const h=d.cursor+1;return u=d.stack[h],{stack:d.stack,cursor:h}}),c&&u){s.current=!0;const d=e.getWorktreeHref?.(u);d&&t(d)}},[t,e]);return{goBack:a,goForward:l,canGoBack:o.cursor>0,canGoForward:o.cursor>=0&&o.cursor<o.stack.length-1}}function mKn(){v.useEffect(()=>{if(On)return;const t=e=>{if(e.metaKey||e.ctrlKey){if(e.key==="="||e.key==="+"){e.preventDefault(),e.stopPropagation(),wqe();return}if(e.key==="-"){e.preventDefault(),e.stopPropagation(),kqe();return}e.shiftKey&&e.code==="Digit0"&&(e.preventDefault(),e.stopPropagation(),Oqe())}};return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)},[])}const gKn=6e4,vKn=250;function bKn(t){return t.focused&&!t.onBattery?"active":!t.focused&&t.onBattery?"background":"idle"}let S8e=!1;function _Kn(){if(S8e||typeof window>"u")return;S8e=!0;const t=typeof crypto.randomUUID=="function"?crypto.randomUUID():`c${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;let e=null;const n=()=>{e=null,Se.services.setActivity.mutate({activity:bKn(U0()),clientId:t}).catch(()=>{})};Wx(()=>{e||(e=setTimeout(n,vKn))}),setInterval(n,gKn),window.addEventListener("pagehide",()=>{j4(vA("/trpc/services.releaseActivity"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clientId:t}),keepalive:!0}).catch(()=>{})}),n()}const xKn=new Map,yKn=new Set;function wKn(t,e){xKn.set(t,{filePath:e});for(const n of yKn)n()}function kKn(t,e){if(t.kind!=="open-file")return{handled:!1,reason:"not-open-file"};const n=typeof t.worktreeId=="string"?t.worktreeId:void 0;if(!n)return{handled:!1,reason:"missing-worktree-id"};const r=typeof t.filePath=="string"?t.filePath:void 0;return r?t.external===!0?(wKn(n,r),e.onActivateFilesPanel(n),{handled:!0,kind:"external"}):(e.onOpenFile(n,r),{handled:!0,kind:"in-worktree"}):{handled:!1,reason:"missing-file-path"}}const aC="band:last-worktree";let UW=!1;function OKn(){UW=!0}function SKn(t){UW&&(UW=!1,!t)||Hn.getItem(aC)!==t&&(t?Hn.setItem(aC,t):Hn.removeItem(aC))}function CKn(t){const e=new Map;for(const o of t)for(const i of o.worktrees)e.set(jr(o.name,i.name,i.hostId),i.groupId);const n=Hn.getItem(aC),r=Hn.getItem(Hb);if(!n)return null;if(r&&e.get(n)!==r){const o=Mq()[r];if(o&&e.get(o)===r)return o}return e.has(n)?n:null}function AKn(t){if(t instanceof Error)return{message:t.message||t.name,stack:t.stack??""};if(typeof t=="string")return{message:t,stack:""};try{return{message:JSON.stringify(t)??String(t),stack:""}}catch{return{message:String(t),stack:""}}}function EKn(t,e=TKn()){if(!e)return()=>{};const n=()=>t.location?.href??"",r=(s,a)=>{try{e({kind:s,...AKn(a),url:n()})}catch{}},o=s=>r("error",s.error??s.message??"Unknown error"),i=s=>r("unhandledrejection",s.reason);return t.addEventListener("error",o),t.addEventListener("unhandledrejection",i),()=>{t.removeEventListener("error",o),t.removeEventListener("unhandledrejection",i)}}function TKn(){const t=EP();return t?e=>{t.invoke("report_renderer_error",e).catch(()=>{})}:null}const UZe="band:sidebar-width";function MKn(){try{const t=localStorage.getItem(UZe);if(t){const e=Number.parseFloat(t);if(!Number.isNaN(e)&&e>0&&e<100)return e}}catch{}return null}function PKn(t){try{Hn.setItem(UZe,String(t))}catch{}}const WZe="band:sidebar-collapsed";function jKn(){try{return localStorage.getItem(WZe)==="1"}catch{return!1}}function NKn(t){try{Hn.setItem(WZe,t?"1":"0")}catch{}}const C8e="15rem",RKn="60%",ZZe="band:right-panel-width";function LKn(){try{const t=localStorage.getItem(ZZe);if(t){const e=Number.parseFloat(t);if(!Number.isNaN(e)&&e>0&&e<100)return e}}catch{}return null}function IKn(t){try{Hn.setItem(ZZe,String(t))}catch{}}const GZe="band:right-panel-collapsed";function DKn(){try{return localStorage.getItem(GZe)==="1"}catch{return!1}}function zKn(t){try{Hn.setItem(GZe,t?"1":"0")}catch{}}const A8e="15rem",$Kn="60%",BKn=`(function(){var d=document.documentElement;try{var t=localStorage.getItem(${JSON.stringify(vg)})||"dark";var dark=t==="dark"||(t==="system"&&window.matchMedia("(prefers-color-scheme:dark)").matches);if(dark)d.classList.add("dark");else d.classList.remove("dark");try{var c=JSON.parse(localStorage.getItem(${JSON.stringify(YBe)})||"null");var v=c&&c[dark?"dark":"light"];if(v)for(var k in v)if(k.slice(0,2)==="--"&&typeof v[k]==="string")d.style.setProperty(k,v[k])}catch(e){}}catch(e){d.classList.add("dark")}})()`,YZe="data-translucent-sidebar",XZe="band:translucent-sidebar",HKn=On&&typeof navigator<"u"&&/Mac/.test(navigator.userAgent),FKn=`(function(){try{if(!("__BAND_DESKTOP__" in window)||!/Mac/.test(navigator.userAgent))return;if(localStorage.getItem(${JSON.stringify(XZe)})==="0")return;document.documentElement.setAttribute(${JSON.stringify(YZe)},"")}catch(e){}})()`;function qKn(t){const e=t&&HKn;document.documentElement.toggleAttribute(YZe,e);try{localStorage.setItem(XZe,t?"1":"0")}catch{}}const q_=On?new fAn:new kFe,lC=On?new hAn:new OFe,jne=Xtt({head:()=>({meta:[{charSet:"utf-8"},{name:"viewport",content:"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover, interactive-widget=resizes-content"},{title:"Band"},{name:"apple-mobile-web-app-capable",content:"yes"},{name:"apple-mobile-web-app-status-bar-style",content:"black"},{name:"theme-color",content:"#1e1e1e"}],links:[{rel:"manifest",href:"/manifest.webmanifest"},{rel:"apple-touch-icon",href:"/icons/apple-touch-icon.png"}]}),shellComponent:eJn,component:tJn,notFoundComponent:VKn});function VKn(){return f.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-4 p-8 text-center",children:[f.jsx("p",{className:"text-4xl font-bold",children:"404"}),f.jsx("p",{className:"text-sm text-muted-foreground",children:"Page not found"}),f.jsx(cZ,{to:"/",className:"text-sm text-primary underline",children:"Back to dashboard"})]})}const QKn='(function(){try{var z=localStorage.getItem("band:zoom-level");var n=1;if(z){var p=parseFloat(z);if(!isNaN(p)&&p>=0.5&&p<=2)n=p;}var d=document.documentElement;d.style.zoom=String(n);d.style.setProperty("--app-zoom",String(n));}catch(e){}})()';function UKn(){const{settings:t}=Qh(),e=t.theme;return v.useEffect(()=>{try{e&&localStorage.getItem(vg)===null&&localStorage.setItem(vg,e)}catch{}return jyn()},[e]),null}function WKn(){const{settings:t,isLoading:e,error:n}=Qh(),r=t.translucentSidebar??!0,o=!e&&!n;return v.useEffect(()=>{o&&qKn(r)},[r,o]),null}typeof window<"u"&&EKn(window);function ZKn(){return v.useEffect(()=>{try{W_n(),_Kn()}catch(t){console.error("power saver failed to start",t)}},[]),null}function KZe(){const n=document.activeElement?.closest("[data-band-browser-pane]")?.dataset.bandBrowserPaneKey;return n?xUn(n):null}function GKn(){return v.useEffect(()=>{const t="__bandReload",e=window,n=()=>{const r=KZe();if(r){try{r.reload()}catch{}return}window.location.reload()};return e[t]=n,()=>{e[t]===n&&delete e[t]}},[]),null}function YKn(){return v.useEffect(()=>(xN(_N()),window.__bandZoom=t=>{const e=KZe();if(e&&(t==="in"||t==="out"||t==="reset")){yUn(e,t);return}t==="in"?wqe():t==="out"?kqe():Oqe()},()=>{delete window.__bandZoom}),[]),v.useEffect(()=>{const t=e=>{if(e.key!=="band:zoom-level"||!e.newValue)return;const n=Number.parseFloat(e.newValue);!Number.isNaN(n)&&n>=.5&&n<=2&&yqe(n)};return window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)},[]),null}function XKn({children:t}){const[e,n]=v.useState(!1),r=ns();return v.useEffect(()=>{xFt(s=>q_.subscribeStatusEvents(s));let o=!1;const i=lu.fetchQuery({queryKey:Un.repos,queryFn:()=>q_.listRepos()}).catch(()=>null);return(async()=>{if(await gFt(),r.state.location.pathname==="/"){const s=await KKn(i,tX);s||OKn();const a=s?CKn(s):null;a&&!o&&await r.navigate({to:"/worktree/$worktreeId",params:{worktreeId:a},replace:!0})}o||n(!0)})(),()=>{o=!0}},[r]),e?t:null}function KKn(t,e){let n;const r=new Promise(o=>{n=setTimeout(()=>o(null),e)});return Promise.race([t,r]).finally(()=>clearTimeout(n))}function JKn(){const e=eAe()||On,n=ns(),r=Mo({select:le=>le.location.pathname});v.useEffect(()=>{lC.navigate||(lC.navigate=le=>{n.navigate({to:le})})},[n]);const o=v.useCallback(le=>n.navigate({to:le}),[n]),i=pKn(o,lC),{goBack:s,goForward:a}=i;v.useEffect(()=>{const le=Be=>{Be.key!=="ArrowLeft"&&Be.key!=="ArrowRight"||!(Y2()?Be.metaKey&&!Be.ctrlKey:Be.ctrlKey&&!Be.metaKey)||!Be.altKey||Be.shiftKey||(Be.preventDefault(),Be.stopPropagation(),Be.key==="ArrowLeft"?s():a())};return window.addEventListener("keydown",le,!0),window.addEventListener("band:worktree-go-back",s),window.addEventListener("band:worktree-go-forward",a),()=>{window.removeEventListener("keydown",le,!0),window.removeEventListener("band:worktree-go-back",s),window.removeEventListener("band:worktree-go-forward",a)}},[s,a]),mKn();const l=v8(r);v.useEffect(()=>{CMn(l),vUn(l),SKn(l)},[l]),SFt(l);const c=Cn(le=>l?le.statuses.get(l)?.worktreePath:void 0);v.useEffect(()=>{q_.setActiveWorktree(l)},[l]);const u=v.useRef(e);u.current=e,v.useEffect(()=>q_.subscribeStatusEvents(Be=>{u.current&&kKn(Be,{onOpenFile:$1.onOpenFile,onActivateFilesPanel:$1.onActivateFilesPanel})}),[]);const d=v.useCallback(()=>{c&&navigator.clipboard.writeText(c).catch(()=>{})},[c]),h=lle(),p=v.useRef(null),g=v.useRef(null),_=lle(),x=v.useRef(null),y=v.useRef(null),k=v.useRef({collapsed:DKn(),width:LKn()}),[O,C]=v.useState(()=>!k.current.collapsed),A=v.useRef({collapsed:jKn(),width:MKn()}),[E,M]=v.useState(()=>!A.current.collapsed),P=v.useMemo(()=>A.current.collapsed?{sidebar:0,main:100}:A.current.width?{sidebar:A.current.width,main:100-A.current.width}:void 0,[]),L=v.useMemo(()=>{if(k.current.collapsed)return{center:100,rightpanel:0};if(k.current.width!=null)return{center:100-k.current.width,rightpanel:k.current.width}},[]),D=v.useRef(!0),I=v.useRef(null),z=v.useRef(null),Y=v.useCallback(le=>{if(D.current){D.current=!1;return}le.sidebar==null||le.sidebar<=0||(I.current=le.sidebar,z.current==null&&(z.current=requestAnimationFrame(()=>{z.current=null,I.current!=null&&(PKn(I.current),I.current=null)})))},[]),Q=v.useRef(!0),H=v.useRef(null),N=v.useRef(null),V=v.useCallback(le=>{if(Q.current){Q.current=!1;return}le.rightpanel==null||le.rightpanel<=0||(H.current=le.rightpanel,N.current==null&&(N.current=requestAnimationFrame(()=>{N.current=null,H.current!=null&&(IKn(H.current),H.current=null)})))},[]),G=v.useRef(!A.current.collapsed),K=v.useCallback((le,Be,Xe)=>{if(Xe===void 0)return;const ot=le.asPercentage>0;ot!==G.current&&(G.current=ot,M(ot),NKn(!ot))},[]),q=v.useRef(!k.current.collapsed),Z=v.useCallback((le,Be,Xe)=>{if(Xe===void 0)return;const ot=le.asPercentage>0;ot!==q.current&&(q.current=ot,C(ot),zKn(!ot))},[]),U=v.useCallback(()=>{const le=p.current;if(!le||window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;const Be=[le,g.current];for(const Qe of Be)Qe&&(Qe.style.transition="flex-grow 200ms cubic-bezier(0.77, 0, 0.175, 1), flex-basis 200ms cubic-bezier(0.77, 0, 0.175, 1)");let Xe=0;const ot=Qe=>{if(!(Qe&&(Qe.target!==le||Qe.propertyName!=="flex-grow"))){for(const lt of Be)lt&&(lt.style.transition="");le.removeEventListener("transitionend",ot),Xe&&window.clearTimeout(Xe)}};Xe=window.setTimeout(ot,280),le.addEventListener("transitionend",ot)},[]),B=v.useCallback(()=>{const le=h.current;le&&(U(),le.isCollapsed()?le.expand():le.collapse())},[h,U]),ee=v.useCallback(()=>{const le=x.current;if(!le||window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;const Be=[le,y.current];for(const Qe of Be)Qe&&(Qe.style.transition="flex-grow 200ms cubic-bezier(0.77, 0, 0.175, 1), flex-basis 200ms cubic-bezier(0.77, 0, 0.175, 1)");let Xe=0;const ot=Qe=>{if(!(Qe&&(Qe.target!==le||Qe.propertyName!=="flex-grow"))){for(const lt of Be)lt&&(lt.style.transition="");le.removeEventListener("transitionend",ot),Xe&&window.clearTimeout(Xe)}};Xe=window.setTimeout(ot,280),le.addEventListener("transitionend",ot)},[]),te=v.useCallback(()=>{const le=_.current;le&&(ee(),le.isCollapsed()?le.expand():le.collapse())},[_,ee]);v.useEffect(()=>{const le=()=>B(),Be=()=>{h.current?.isCollapsed()&&(U(),h.current.expand())};return window.addEventListener("band:toggle-sidebar",le),window.addEventListener("band:show-sidebar",Be),()=>{window.removeEventListener("band:toggle-sidebar",le),window.removeEventListener("band:show-sidebar",Be)}},[B,h,U]),v.useEffect(()=>{const le=()=>te(),Be=()=>{_.current?.isCollapsed()&&(ee(),_.current.expand())};return window.addEventListener("band:toggle-right-panel",le),window.addEventListener("band:show-right-panel",Be),()=>{window.removeEventListener("band:toggle-right-panel",le),window.removeEventListener("band:show-right-panel",Be)}},[te,_,ee]),v.useEffect(()=>()=>{z.current!=null&&cancelAnimationFrame(z.current),N.current!=null&&cancelAnimationFrame(N.current)},[]);const se=v.useMemo(()=>({onGoBack:i.goBack,onGoForward:i.goForward,canGoBack:i.canGoBack,canGoForward:i.canGoForward,onToggleSidebar:B,sidebarVisible:E}),[i.goBack,i.goForward,i.canGoBack,i.canGoForward,B,E]),ae=BBe(),[he,fe]=v.useState(0),be=v.useCallback(le=>{if(!le)return;const Be=new ResizeObserver(()=>fe(le.offsetWidth));return Be.observe(le),()=>Be.disconnect()},[]),me=v.useMemo(()=>({sidebarVisible:E,navOverlayWidth:he,rightPanelVisible:O,onToggleRightPanel:l?te:void 0}),[E,he,O,l,te]);return e?f.jsx(zWe,{children:f.jsx(EFe.Provider,{value:me,children:f.jsxs("div",{className:"relative flex flex-col h-full w-full overflow-hidden bg-background text-foreground translucent-sidebar:bg-transparent",children:[f.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:f.jsxs(vF,{orientation:"horizontal",defaultLayout:P,onLayoutChanged:Y,className:"h-full w-full",children:[f.jsx(Pv,{id:"sidebar",panelRef:h,elementRef:p,defaultSize:C8e,minSize:C8e,maxSize:RKn,collapsible:!0,collapsedSize:"0%",onResize:K,children:f.jsxs("div",{className:"h-full flex flex-col overflow-hidden border-r border-border bg-sidebar translucent-sidebar:bg-(--sidebar-translucent) pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)]","data-testid":"app-shell__sidebar",children:[f.jsx(rEn,{}),f.jsx("div",{className:"flex-1 min-h-0",children:f.jsx(pHe,{hideTitleBar:!0,bottomActions:f.jsx($We,{})})})]})}),f.jsx(bF,{id:"app-shell__sidebar-separator",className:"w-[3px] bg-background hover:bg-[color-mix(in_srgb,var(--accent-foreground)_20%,var(--background))] active:bg-[color-mix(in_srgb,var(--accent-foreground)_30%,var(--background))] transition-colors cursor-col-resize"}),f.jsx(Pv,{id:"main",elementRef:g,minSize:"20%",children:f.jsx("div",{className:"relative h-full min-w-0 overflow-hidden bg-background pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)]","data-testid":"app-shell__main",children:f.jsxs(vF,{orientation:"horizontal",defaultLayout:L,onLayoutChanged:V,className:"h-full w-full",children:[f.jsx(Pv,{id:"center",elementRef:y,minSize:"30%",children:f.jsxs("div",{className:"h-full flex flex-col min-w-0 overflow-hidden",children:[!l&&f.jsx(MFe,{}),f.jsxs("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden relative",children:[f.jsx(UH,{}),f.jsx(yYn,{}),f.jsx(EAn,{}),f.jsx(NAn,{})]})]})}),f.jsx(bF,{className:"w-[3px] bg-transparent hover:bg-accent-foreground/20 active:bg-accent-foreground/30 transition-colors cursor-col-resize"}),f.jsx(Pv,{id:"rightpanel",panelRef:_,elementRef:x,defaultSize:A8e,minSize:A8e,maxSize:$Kn,collapsible:!0,collapsedSize:"0%",onResize:Z,children:f.jsx("div",{className:"h-full flex flex-col overflow-hidden border-l border-border bg-background","data-testid":"app-shell__right-panel","data-visible":O?"true":"false",children:f.jsx(dKn,{visible:O,headerActions:f.jsx(tEn,{worktreePath:l?c:void 0,onCopyPath:l?d:void 0,onToggleRightPanel:l&&O?te:void 0})})})})]})})})]})}),f.jsx("div",{ref:be,"data-testid":"app-shell__nav-overlay",className:`pointer-events-none absolute top-[env(safe-area-inset-top)] left-0 z-10 flex h-[38px] items-center ${ae}`,children:f.jsx(nEn,{...se})})]})})}):f.jsxs(f.Fragment,{children:[f.jsx(UH,{}),f.jsx($Xn,{})]})}function eJn({children:t}){return f.jsxs("html",{lang:"en",children:[f.jsxs("head",{children:[f.jsx(fnt,{}),f.jsx("script",{dangerouslySetInnerHTML:{__html:BKn}}),f.jsx("script",{dangerouslySetInnerHTML:{__html:QKn}}),f.jsx("script",{dangerouslySetInnerHTML:{__html:FKn}})]}),f.jsxs("body",{children:[t,f.jsx(hnt,{})]})]})}function tJn(){return f.jsxs(ITt,{adapter:q_,capabilities:lC,children:[f.jsx(UKn,{}),f.jsx(WKn,{}),f.jsx(ZKn,{}),f.jsx(YKn,{}),f.jsx(GKn,{}),f.jsxs(jdt,{children:[f.jsx(XKn,{children:f.jsx(JKn,{})}),f.jsx(SAn,{}),f.jsx(ixn,{})]})]})}const nJn=()=>re(()=>import("./index-D2wFO-D3.js"),[]),rJn=xC("/")({component:QH(nJn,"component")}),oJn=()=>re(()=>import("./worktree._worktreeId-DsTjUoT9.js"),[]),iJn=()=>re(()=>import("./worktree._worktreeId-C3DGXQD8.js"),[]),sJn=xC("/worktree/$worktreeId")({component:QH(iJn,"component"),notFoundComponent:QH(oJn,"notFoundComponent")}),aJn=rJn.update({id:"/",path:"/",getParentRoute:()=>jne}),lJn=sJn.update({id:"/worktree/$worktreeId",path:"/worktree/$worktreeId",getParentRoute:()=>jne}),cJn={IndexRoute:aJn,WorktreeWorktreeIdRoute:lJn},uJn=jne._addFileChildren(cJn);function dJn(){return int({routeTree:uJn,scrollRestoration:!0,defaultPendingMinMs:0})}async function fJn(){const t=await dJn();let e;return e=[],window.__TSS_START_OPTIONS__={serializationAdapters:e},e.push(jnt),t.options.serializationAdapters&&e.push(...t.options.serializationAdapters),t.update({basepath:"",serializationAdapters:e}),t.state.matches.length||await mnt(t),t}async function hJn(){const t=await fJn();return window.$_TSR?.h(),t}let zH;function pJn(){return zH||(zH=hJn()),f.jsx(Stt,{promise:zH,children:t=>f.jsx(lnt,{router:t})})}let E8e=!1;function mJn(){return document.querySelectorAll("webview")}function gJn(){if(E8e||typeof document>"u")return;E8e=!0;const t=r=>{!(r instanceof HTMLElement)||r.tagName!=="WEBVIEW"||r.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,composed:!0,pointerType:"mouse",isPrimary:!0,button:0,buttons:1}))};document.addEventListener("focusin",r=>t(r.target),!0),window.addEventListener("blur",()=>t(document.activeElement));const e=new Map,n=()=>{window.removeEventListener("pointermove",n,!0);for(const[r,o]of e)r.style.pointerEvents=o;e.clear()};window.addEventListener("dragstart",()=>{for(const r of mJn())e.has(r)||e.set(r,r.style.pointerEvents),r.style.pointerEvents="none";window.addEventListener("pointermove",n,!0)},!0),window.addEventListener("dragend",n,!0),window.addEventListener("drop",n,!0)}gJn();kZe.hydrateRoot(document,f.jsx(pJn,{}));const vJn=Object.freeze(Object.defineProperty({__proto__:null,Mermaid:cMe},Symbol.toStringTag,{value:"Module"}));export{Icn as $,r3n as A,Vmn as B,i8 as C,wIe as D,ac as E,Px as F,ger as G,Fer as H,Her as I,A0 as J,aer as K,js as L,e1n as M,DJn as N,t1n as O,Ypn as P,Oen as Q,sJn as R,Gpn as S,V6n as T,Ter as U,G0n as V,ver as W,B9 as X,$n as Y,cu as Z,W as _,q6 as a,ZSe as a$,r1n as a0,VJ as a1,$je as a2,da as a3,Hmn as a4,qhn as a5,Vde as a6,JNe as a7,Gfe as a8,Zfe as a9,Q0n as aA,Mx as aB,rn as aC,wn as aD,Zje as aE,C6n as aF,wze as aG,$er as aH,Xpn as aI,ts as aJ,Fh as aK,RJ as aL,ZIe as aM,Q4 as aN,xIe as aO,Cn as aP,lSe as aQ,Zjt as aR,fke as aS,Zr as aT,ul as aU,ft as aV,it as aW,Rke as aX,hke as aY,dA as aZ,Gjt as a_,Cer as aa,yer as ab,Oer as ac,ker as ad,_er as ae,fJ as af,Ser as ag,xer as ah,ei as ai,Eer as aj,Aer as ak,wer as al,TNe as am,b0n as an,YK as ao,t6n as ap,pJ as aq,sg as ar,mer as as,Rj as at,jmn as au,D0n as av,NK as aw,nfe as ax,q9 as ay,Bmn as az,yke as b,yj as b$,Emn as b0,x4n as b1,ymn as b2,LJ as b3,Zhe as b4,vgn as b5,zer as b6,Ber as b7,Ier as b8,fn as b9,D7e as bA,Kf as bB,pa as bC,pM as bD,W7e as bE,Qh as bF,Qer as bG,cN as bH,eer as bI,per as bJ,Y0 as bK,Hx as bL,J5n as bM,K5n as bN,xl as bO,u2n as bP,FK as bQ,dNe as bR,Rx as bS,pNe as bT,ber as bU,Ehn as bV,lfe as bW,afe as bX,Lcn as bY,VNe as bZ,aJ as b_,Der as ba,J6n as bb,Z6n as bc,W6n as bd,MKn as be,PKn as bf,vF as bg,Pv as bh,RKn as bi,C8e as bj,pHe as bk,bF as bl,Q_ as bm,eAe as bn,zWe as bo,$We as bp,On as bq,hJ as br,GK as bs,tt as bt,xCe as bu,Vs as bv,mye as bw,dZ as bx,z7e as by,uZ as bz,iS as c,gfn as c0,mfn as c1,ug as c2,pfn as c3,hfn as c4,dE as c5,Ix as c6,iJ as c7,rJ as c8,i3 as c9,smn as cA,iIe as cB,u4n as cC,d4n as cD,Lp as cE,mhe as cF,f4n as cG,DJ as cH,c4n as cI,m4n as cJ,c8 as cK,Hh as cL,uhe as cM,zJ as cN,aIe as cO,NQ as cP,Mmn as cQ,jj as cR,bJn as cS,re as cT,uE as ca,F4 as cb,Tmn as cc,fIe as cd,Tj as ce,Nj as cf,SE as cg,pIe as ch,dIe as ci,imn as cj,ZK as ck,un as cl,eIe as cm,Amn as cn,xmn as co,a4n as cp,IJ as cq,tmn as cr,Pmn as cs,$x as ct,l8 as cu,wE as cv,fmn as cw,Bgn as cx,zx as cy,OE as cz,OSe as d,U6 as e,qg as f,MNt as g,Hke as h,Fg as i,f as j,Dr as k,Uc as l,K0n as m,J0n as n,X0n as o,Y0n as p,Gr as q,v as r,Hg as s,_e as t,Ir as u,ut as v,Wje as w,Gi as x,rd as y,Yc as z};