@bryanhu/codexly 0.11.2 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/README.md +10 -6
- package/README.zh-CN.md +9 -5
- package/dist/{chunk-2NJ4CTQP.js → chunk-G4BIMVEW.js} +1024 -740
- package/dist/{chunk-NPICM42L.js → chunk-HHFZB7H6.js} +17782 -4402
- package/dist/{chunk-GUHYAMAQ.js → chunk-OVQSIEIK.js} +1 -1
- package/dist/{chunk-YMFGL4ZR.js → chunk-TVRHN6RY.js} +586 -131
- package/dist/cli.js +51 -9
- package/dist/client/index.js +147 -4
- package/dist/protocol/index.js +1 -1
- package/dist/providers/codex/index.js +2 -2
- package/dist/server/index.js +4 -4
- package/dist/sqlite-state-worker.js +88 -5
- package/dist/web/.vite/manifest.json +476 -280
- package/dist/web/.vite/manifest.json.br +0 -0
- package/dist/web/.vite/manifest.json.gz +0 -0
- package/dist/web/assets/button-group-CaIXhcq-.js +1 -0
- package/dist/web/assets/button-group-CaIXhcq-.js.br +0 -0
- package/dist/web/assets/button-group-CaIXhcq-.js.gz +0 -0
- package/dist/web/assets/{chunk-BO2N2NFS-ng4dbem1.js → chunk-BO2N2NFS-CiutqNGv.js} +7 -7
- package/dist/web/assets/chunk-BO2N2NFS-CiutqNGv.js.br +0 -0
- package/dist/web/assets/chunk-BO2N2NFS-CiutqNGv.js.gz +0 -0
- package/dist/web/assets/{code-highlighter-BMwFeSBd.js → code-highlighter-Bp23lvQ1.js} +1 -1
- package/dist/web/assets/code-highlighter-Bp23lvQ1.js.br +0 -0
- package/dist/web/assets/code-highlighter-Bp23lvQ1.js.gz +0 -0
- package/dist/web/assets/code-languages-DVcuYjhn.js +2 -0
- package/dist/web/assets/code-languages-DVcuYjhn.js.br +0 -0
- package/dist/web/assets/code-languages-DVcuYjhn.js.gz +0 -0
- package/dist/web/assets/context-menu-C6o4ShKC.js +1 -0
- package/dist/web/assets/context-menu-C6o4ShKC.js.br +0 -0
- package/dist/web/assets/context-menu-C6o4ShKC.js.gz +0 -0
- package/dist/web/assets/dist-Czw-hil0.js +1 -0
- package/dist/web/assets/dist-Czw-hil0.js.br +0 -0
- package/dist/web/assets/dist-Czw-hil0.js.gz +0 -0
- package/dist/web/assets/download-iHkzQYEd.js +1 -0
- package/dist/web/assets/download-iHkzQYEd.js.br +0 -0
- package/dist/web/assets/download-iHkzQYEd.js.gz +0 -0
- package/dist/web/assets/{engine-compile-Bqjaa_8Z.js → engine-compile-DcaAFSGO.js} +1 -1
- package/dist/web/assets/engine-compile-DcaAFSGO.js.br +0 -0
- package/dist/web/assets/engine-compile-DcaAFSGO.js.gz +0 -0
- package/dist/web/assets/external-link-xbPJFZkP.js +1 -0
- package/dist/web/assets/external-link-xbPJFZkP.js.br +0 -0
- package/dist/web/assets/external-link-xbPJFZkP.js.gz +0 -0
- package/dist/web/assets/file-code-corner-CYF-BidF.js +1 -0
- package/dist/web/assets/file-code-corner-CYF-BidF.js.br +0 -0
- package/dist/web/assets/file-code-corner-CYF-BidF.js.gz +0 -0
- package/dist/web/assets/file-navigation-view-preference-BRWa_l_a.js +1 -0
- package/dist/web/assets/file-navigation-view-preference-BRWa_l_a.js.br +0 -0
- package/dist/web/assets/file-navigation-view-preference-BRWa_l_a.js.gz +0 -0
- package/dist/web/assets/file-pen-line-B05lVjWh.js +1 -0
- package/dist/web/assets/file-pen-line-B05lVjWh.js.br +0 -0
- package/dist/web/assets/file-pen-line-B05lVjWh.js.gz +0 -0
- package/dist/web/assets/file-review-dialog-Cd_FWDJj.js +2 -0
- package/dist/web/assets/file-review-dialog-Cd_FWDJj.js.br +0 -0
- package/dist/web/assets/file-review-dialog-Cd_FWDJj.js.gz +0 -0
- package/dist/web/assets/git-commit-horizontal-CV-KjCHw.js +1 -0
- package/dist/web/assets/git-commit-horizontal-CV-KjCHw.js.br +0 -0
- package/dist/web/assets/git-commit-horizontal-CV-KjCHw.js.gz +0 -0
- package/dist/web/assets/git-history-panel-CkQhJ-Tz.js +2 -0
- package/dist/web/assets/git-history-panel-CkQhJ-Tz.js.br +0 -0
- package/dist/web/assets/git-history-panel-CkQhJ-Tz.js.gz +0 -0
- package/dist/web/assets/global-settings-dialog-B9ACq0CT.js +1 -0
- package/dist/web/assets/global-settings-dialog-B9ACq0CT.js.br +0 -0
- package/dist/web/assets/global-settings-dialog-B9ACq0CT.js.gz +0 -0
- package/dist/web/assets/{highlighted-body-OFNGDK62-UIjGvJpu.js → highlighted-body-OFNGDK62-jfqTT7Zz.js} +1 -1
- package/dist/web/assets/highlighted-body-OFNGDK62-jfqTT7Zz.js.br +0 -0
- package/dist/web/assets/highlighted-body-OFNGDK62-jfqTT7Zz.js.gz +0 -0
- package/dist/web/assets/index-CergXz2m.js +4 -0
- package/dist/web/assets/index-CergXz2m.js.br +0 -0
- package/dist/web/assets/index-CergXz2m.js.gz +0 -0
- package/dist/web/assets/index-jg-dNJI1.css +2 -0
- package/dist/web/assets/index-jg-dNJI1.css.br +0 -0
- package/dist/web/assets/index-jg-dNJI1.css.gz +0 -0
- package/dist/web/assets/info-whxTXvIJ.js +1 -0
- package/dist/web/assets/info-whxTXvIJ.js.br +0 -0
- package/dist/web/assets/info-whxTXvIJ.js.gz +0 -0
- package/dist/web/assets/initial-deps-BsEyuMB0.js +1 -0
- package/dist/web/assets/initial-deps-BsEyuMB0.js.br +0 -0
- package/dist/web/assets/initial-deps-BsEyuMB0.js.gz +0 -0
- package/dist/web/assets/initial-deps-Bx4af_YG.js +1 -0
- package/dist/web/assets/initial-deps-Bx4af_YG.js.br +0 -0
- package/dist/web/assets/initial-deps-Bx4af_YG.js.gz +0 -0
- package/dist/web/assets/initial-deps-CNK9MBOP.js +1 -0
- package/dist/web/assets/initial-deps-CNK9MBOP.js.br +0 -0
- package/dist/web/assets/initial-deps-CNK9MBOP.js.gz +0 -0
- package/dist/web/assets/initial-deps-CQxWMuPh.js +1 -0
- package/dist/web/assets/initial-deps-CQxWMuPh.js.br +0 -0
- package/dist/web/assets/initial-deps-CQxWMuPh.js.gz +0 -0
- package/dist/web/assets/initial-deps-CTprc_pY.js +1 -0
- package/dist/web/assets/initial-deps-CTprc_pY.js.br +0 -0
- package/dist/web/assets/initial-deps-CTprc_pY.js.gz +0 -0
- package/dist/web/assets/initial-deps-Cq4pSOi-.js +1 -0
- package/dist/web/assets/initial-deps-Cq4pSOi-.js.br +0 -0
- package/dist/web/assets/initial-deps-Cq4pSOi-.js.gz +0 -0
- package/dist/web/assets/initial-deps-DqJTHr9A.js +41 -0
- package/dist/web/assets/initial-deps-DqJTHr9A.js.br +0 -0
- package/dist/web/assets/initial-deps-DqJTHr9A.js.gz +0 -0
- package/dist/web/assets/initial-deps-Ds-edw-P.js +1 -0
- package/dist/web/assets/initial-deps-Ds-edw-P.js.br +0 -0
- package/dist/web/assets/initial-deps-Ds-edw-P.js.gz +0 -0
- package/dist/web/assets/installed-skills-pane-BmjTd0Qn.js +1 -0
- package/dist/web/assets/installed-skills-pane-BmjTd0Qn.js.br +0 -0
- package/dist/web/assets/installed-skills-pane-BmjTd0Qn.js.gz +0 -0
- package/dist/web/assets/lazy-message-response-Cnc-bbSf.js +2 -0
- package/dist/web/assets/lazy-message-response-Cnc-bbSf.js.br +0 -0
- package/dist/web/assets/lazy-message-response-Cnc-bbSf.js.gz +0 -0
- package/dist/web/assets/{lib-DrPFkMXk.js → lib-DE0ZEvGM.js} +1 -1
- package/dist/web/assets/lib-DE0ZEvGM.js.br +0 -0
- package/dist/web/assets/lib-DE0ZEvGM.js.gz +0 -0
- package/dist/web/assets/mcp-management-pane-CQPXfAO3.js +1 -0
- package/dist/web/assets/mcp-management-pane-CQPXfAO3.js.br +0 -0
- package/dist/web/assets/mcp-management-pane-CQPXfAO3.js.gz +0 -0
- package/dist/web/assets/mermaid-GHXKKRXX-BNLLThfI.js +1 -0
- package/dist/web/assets/mermaid-GHXKKRXX-BNLLThfI.js.br +0 -0
- package/dist/web/assets/mermaid-GHXKKRXX-BNLLThfI.js.gz +0 -0
- package/dist/web/assets/message-response-CamC0ebm.js +7 -0
- package/dist/web/assets/message-response-CamC0ebm.js.br +0 -0
- package/dist/web/assets/message-response-CamC0ebm.js.gz +0 -0
- package/dist/web/assets/official-plugins-pane-BCxHJLaj.css +1 -0
- package/dist/web/assets/official-plugins-pane-BCxHJLaj.css.br +0 -0
- package/dist/web/assets/official-plugins-pane-BCxHJLaj.css.gz +0 -0
- package/dist/web/assets/official-plugins-pane-BqGBX0cD.js +1 -0
- package/dist/web/assets/official-plugins-pane-BqGBX0cD.js.br +0 -0
- package/dist/web/assets/official-plugins-pane-BqGBX0cD.js.gz +0 -0
- package/dist/web/assets/{patch-diff-viewer-BnoOysqK.js → patch-diff-viewer-CwDRm5oN.js} +3 -3
- package/dist/web/assets/patch-diff-viewer-CwDRm5oN.js.br +0 -0
- package/dist/web/assets/patch-diff-viewer-CwDRm5oN.js.gz +0 -0
- package/dist/web/assets/{project-file-popup-page-C5dOvxw_.js → project-file-popup-page-DCct78Pu.js} +1 -1
- package/dist/web/assets/project-file-popup-page-DCct78Pu.js.br +0 -0
- package/dist/web/assets/project-file-popup-page-DCct78Pu.js.gz +0 -0
- package/dist/web/assets/project-source-panel-BC6YVLSp.js +3 -0
- package/dist/web/assets/project-source-panel-BC6YVLSp.js.br +0 -0
- package/dist/web/assets/project-source-panel-BC6YVLSp.js.gz +0 -0
- package/dist/web/assets/prompt-input-FNZNBIXc.js +1 -0
- package/dist/web/assets/prompt-input-FNZNBIXc.js.br +0 -0
- package/dist/web/assets/prompt-input-FNZNBIXc.js.gz +0 -0
- package/dist/web/assets/prompt-input-controls-BTOpD8Y-.js +1 -0
- package/dist/web/assets/prompt-input-controls-BTOpD8Y-.js.br +0 -0
- package/dist/web/assets/prompt-input-controls-BTOpD8Y-.js.gz +0 -0
- package/dist/web/assets/prompt-reference-token-Cxx6C-IR.js +1 -0
- package/dist/web/assets/prompt-reference-token-Cxx6C-IR.js.br +0 -0
- package/dist/web/assets/prompt-reference-token-Cxx6C-IR.js.gz +0 -0
- package/dist/web/assets/{react-runtime-CVaUQXZF.js → react-runtime-DaCTDC27.js} +1 -1
- package/dist/web/assets/react-runtime-DaCTDC27.js.br +0 -0
- package/dist/web/assets/react-runtime-DaCTDC27.js.gz +0 -0
- package/dist/web/assets/rolldown-runtime-CNC7AqOf.js +1 -0
- package/dist/web/assets/rolldown-runtime-CNC7AqOf.js.br +0 -0
- package/dist/web/assets/rolldown-runtime-CNC7AqOf.js.gz +0 -0
- package/dist/web/assets/scheduled-task-date-time-picker-CL9Xb-R5.js +1 -0
- package/dist/web/assets/scheduled-task-date-time-picker-CL9Xb-R5.js.br +0 -0
- package/dist/web/assets/scheduled-task-date-time-picker-CL9Xb-R5.js.gz +0 -0
- package/dist/web/assets/scheduled-task-date-time-picker-Wk3Ob2xl.css +1 -0
- package/dist/web/assets/scheduled-task-date-time-picker-Wk3Ob2xl.css.br +0 -0
- package/dist/web/assets/scheduled-task-date-time-picker-Wk3Ob2xl.css.gz +0 -0
- package/dist/web/assets/scheduled-task-floating-ui~index~workbench-shell~workbench-inspector-changes~project-file-p~olri0nvu-DAfditVv.js +1 -0
- package/dist/web/assets/scheduled-task-floating-ui~index~workbench-shell~workbench-inspector-changes~project-file-p~olri0nvu-DAfditVv.js.br +0 -0
- package/dist/web/assets/scheduled-task-floating-ui~index~workbench-shell~workbench-inspector-changes~project-file-p~olri0nvu-DAfditVv.js.gz +0 -0
- package/dist/web/assets/scheduled-task-floating-ui~scheduled-task-date-time-picker-BischM2-.js +1 -0
- package/dist/web/assets/scheduled-task-floating-ui~scheduled-task-date-time-picker-BischM2-.js.br +0 -0
- package/dist/web/assets/scheduled-task-floating-ui~scheduled-task-date-time-picker-BischM2-.js.gz +0 -0
- package/dist/web/assets/scheduled-task-schedule-DfXHCkgb.js +1 -0
- package/dist/web/assets/scheduled-task-schedule-DfXHCkgb.js.br +0 -0
- package/dist/web/assets/scheduled-task-schedule-DfXHCkgb.js.gz +0 -0
- package/dist/web/assets/scheduled-tasks-container-Bn6tqtCc.js +2 -0
- package/dist/web/assets/scheduled-tasks-container-Bn6tqtCc.js.br +0 -0
- package/dist/web/assets/scheduled-tasks-container-Bn6tqtCc.js.gz +0 -0
- package/dist/web/assets/scheduled-tasks-container-xtJWjMjU.css +1 -0
- package/dist/web/assets/scheduled-tasks-container-xtJWjMjU.css.br +0 -0
- package/dist/web/assets/scheduled-tasks-container-xtJWjMjU.css.gz +0 -0
- package/dist/web/assets/sheet-CJD6cMoi.js +1 -0
- package/dist/web/assets/sheet-CJD6cMoi.js.br +0 -0
- package/dist/web/assets/sheet-CJD6cMoi.js.gz +0 -0
- package/dist/web/assets/{shiki-bundle-CGkIRfLa.js → shiki-bundle-DdeD2OLK.js} +1 -1
- package/dist/web/assets/shiki-bundle-DdeD2OLK.js.br +0 -0
- package/dist/web/assets/shiki-bundle-DdeD2OLK.js.gz +0 -0
- package/dist/web/assets/skills-market-container-B8Mss3fh.js +2 -0
- package/dist/web/assets/skills-market-container-B8Mss3fh.js.br +0 -0
- package/dist/web/assets/skills-market-container-B8Mss3fh.js.gz +0 -0
- package/dist/web/assets/skills-market-container-C8okZy75.css +1 -0
- package/dist/web/assets/skills-market-container-C8okZy75.css.br +0 -0
- package/dist/web/assets/skills-market-container-C8okZy75.css.gz +0 -0
- package/dist/web/assets/sparkles-BLY9rqMO.js +1 -0
- package/dist/web/assets/sparkles-BLY9rqMO.js.br +0 -0
- package/dist/web/assets/sparkles-BLY9rqMO.js.gz +0 -0
- package/dist/web/assets/third-party-marketplace-pane-BsSxaqQR.js +1 -0
- package/dist/web/assets/third-party-marketplace-pane-BsSxaqQR.js.br +0 -0
- package/dist/web/assets/third-party-marketplace-pane-BsSxaqQR.js.gz +0 -0
- package/dist/web/assets/upload-D_8Uk8f-.js +1 -0
- package/dist/web/assets/upload-D_8Uk8f-.js.br +0 -0
- package/dist/web/assets/upload-D_8Uk8f-.js.gz +0 -0
- package/dist/web/assets/workbench-composer-Co9mAWP_.js +10 -0
- package/dist/web/assets/workbench-composer-Co9mAWP_.js.br +0 -0
- package/dist/web/assets/workbench-composer-Co9mAWP_.js.gz +0 -0
- package/dist/web/assets/workbench-inspector-changes-DcJkQFAH.js +2 -0
- package/dist/web/assets/workbench-inspector-changes-DcJkQFAH.js.br +0 -0
- package/dist/web/assets/workbench-inspector-changes-DcJkQFAH.js.gz +0 -0
- package/dist/web/assets/workbench-pet-canvas-BR5AhUVL.js +1 -0
- package/dist/web/assets/workbench-pet-canvas-BR5AhUVL.js.br +0 -0
- package/dist/web/assets/workbench-pet-canvas-BR5AhUVL.js.gz +0 -0
- package/dist/web/assets/workbench-shell-5F-GWLMO.js +8 -0
- package/dist/web/assets/workbench-shell-5F-GWLMO.js.br +0 -0
- package/dist/web/assets/workbench-shell-5F-GWLMO.js.gz +0 -0
- package/dist/web/index.html +13 -15
- package/dist/web/index.html.br +0 -0
- package/dist/web/index.html.gz +0 -0
- package/package.json +2 -2
- package/dist/web/assets/bundle-mjs-rHxsej31.js +0 -1
- package/dist/web/assets/bundle-mjs-rHxsej31.js.br +0 -0
- package/dist/web/assets/bundle-mjs-rHxsej31.js.gz +0 -0
- package/dist/web/assets/button-group-Bt_Rr9-f.js +0 -1
- package/dist/web/assets/button-group-Bt_Rr9-f.js.br +0 -0
- package/dist/web/assets/button-group-Bt_Rr9-f.js.gz +0 -0
- package/dist/web/assets/check-C92ZHwwX.js +0 -1
- package/dist/web/assets/check-C92ZHwwX.js.br +0 -0
- package/dist/web/assets/check-C92ZHwwX.js.gz +0 -0
- package/dist/web/assets/checkbox-BBHD70U-.js +0 -1
- package/dist/web/assets/checkbox-BBHD70U-.js.br +0 -0
- package/dist/web/assets/checkbox-BBHD70U-.js.gz +0 -0
- package/dist/web/assets/chunk-BO2N2NFS-ng4dbem1.js.br +0 -0
- package/dist/web/assets/chunk-BO2N2NFS-ng4dbem1.js.gz +0 -0
- package/dist/web/assets/code-highlighter-BMwFeSBd.js.br +0 -0
- package/dist/web/assets/code-highlighter-BMwFeSBd.js.gz +0 -0
- package/dist/web/assets/code-languages-rKSHZYzu.js +0 -2
- package/dist/web/assets/code-languages-rKSHZYzu.js.br +0 -0
- package/dist/web/assets/code-languages-rKSHZYzu.js.gz +0 -0
- package/dist/web/assets/context-menu-03SuSeWI.js +0 -1
- package/dist/web/assets/context-menu-03SuSeWI.js.br +0 -0
- package/dist/web/assets/context-menu-03SuSeWI.js.gz +0 -0
- package/dist/web/assets/dist-B_DB3jSu.js +0 -1
- package/dist/web/assets/dist-B_DB3jSu.js.br +0 -0
- package/dist/web/assets/dist-B_DB3jSu.js.gz +0 -0
- package/dist/web/assets/dist-DBbCRukl.js +0 -1
- package/dist/web/assets/dist-DBbCRukl.js.br +0 -0
- package/dist/web/assets/dist-DBbCRukl.js.gz +0 -0
- package/dist/web/assets/engine-compile-Bqjaa_8Z.js.br +0 -0
- package/dist/web/assets/engine-compile-Bqjaa_8Z.js.gz +0 -0
- package/dist/web/assets/es2015-BUwabepB.js +0 -41
- package/dist/web/assets/es2015-BUwabepB.js.br +0 -0
- package/dist/web/assets/es2015-BUwabepB.js.gz +0 -0
- package/dist/web/assets/file-code-corner-CJDhFrYy.js +0 -1
- package/dist/web/assets/file-code-corner-CJDhFrYy.js.br +0 -3
- package/dist/web/assets/file-code-corner-CJDhFrYy.js.gz +0 -0
- package/dist/web/assets/file-navigation-view-preference-DeIXQ8c4.js +0 -1
- package/dist/web/assets/file-navigation-view-preference-DeIXQ8c4.js.br +0 -0
- package/dist/web/assets/file-navigation-view-preference-DeIXQ8c4.js.gz +0 -0
- package/dist/web/assets/file-review-dialog-L7snJJP8.js +0 -2
- package/dist/web/assets/file-review-dialog-L7snJJP8.js.br +0 -0
- package/dist/web/assets/file-review-dialog-L7snJJP8.js.gz +0 -0
- package/dist/web/assets/file-tree-DvTv0Re2.js +0 -1
- package/dist/web/assets/file-tree-DvTv0Re2.js.br +0 -0
- package/dist/web/assets/file-tree-DvTv0Re2.js.gz +0 -0
- package/dist/web/assets/git-commit-horizontal-hgIO8zJZ.js +0 -1
- package/dist/web/assets/git-commit-horizontal-hgIO8zJZ.js.br +0 -0
- package/dist/web/assets/git-commit-horizontal-hgIO8zJZ.js.gz +0 -0
- package/dist/web/assets/git-history-panel-DZY20FzY.js +0 -2
- package/dist/web/assets/git-history-panel-DZY20FzY.js.br +0 -0
- package/dist/web/assets/git-history-panel-DZY20FzY.js.gz +0 -0
- package/dist/web/assets/global-settings-dialog-cA1SWDdi.js +0 -1
- package/dist/web/assets/global-settings-dialog-cA1SWDdi.js.br +0 -0
- package/dist/web/assets/global-settings-dialog-cA1SWDdi.js.gz +0 -0
- package/dist/web/assets/highlighted-body-OFNGDK62-UIjGvJpu.js.br +0 -0
- package/dist/web/assets/highlighted-body-OFNGDK62-UIjGvJpu.js.gz +0 -0
- package/dist/web/assets/index-CldcNq0q.css +0 -2
- package/dist/web/assets/index-CldcNq0q.css.br +0 -0
- package/dist/web/assets/index-CldcNq0q.css.gz +0 -0
- package/dist/web/assets/index-WZ8-8oYp.js +0 -4
- package/dist/web/assets/index-WZ8-8oYp.js.br +0 -0
- package/dist/web/assets/index-WZ8-8oYp.js.gz +0 -0
- package/dist/web/assets/lazy-message-response-SjU6ZsaR.js +0 -2
- package/dist/web/assets/lazy-message-response-SjU6ZsaR.js.br +0 -0
- package/dist/web/assets/lazy-message-response-SjU6ZsaR.js.gz +0 -0
- package/dist/web/assets/lib-DrPFkMXk.js.br +0 -0
- package/dist/web/assets/lib-DrPFkMXk.js.gz +0 -0
- package/dist/web/assets/loader-circle-CJOhkEC8.js +0 -1
- package/dist/web/assets/loader-circle-CJOhkEC8.js.br +0 -0
- package/dist/web/assets/loader-circle-CJOhkEC8.js.gz +0 -0
- package/dist/web/assets/mermaid-GHXKKRXX-CDYc39nv.js +0 -1
- package/dist/web/assets/mermaid-GHXKKRXX-CDYc39nv.js.br +0 -0
- package/dist/web/assets/mermaid-GHXKKRXX-CDYc39nv.js.gz +0 -0
- package/dist/web/assets/message-response-BXln58hx.js +0 -7
- package/dist/web/assets/message-response-BXln58hx.js.br +0 -0
- package/dist/web/assets/message-response-BXln58hx.js.gz +0 -0
- package/dist/web/assets/patch-diff-viewer-BnoOysqK.js.br +0 -0
- package/dist/web/assets/patch-diff-viewer-BnoOysqK.js.gz +0 -0
- package/dist/web/assets/project-file-popup-page-C5dOvxw_.js.br +0 -0
- package/dist/web/assets/project-file-popup-page-C5dOvxw_.js.gz +0 -0
- package/dist/web/assets/project-source-panel-CDrU5_qN.js +0 -3
- package/dist/web/assets/project-source-panel-CDrU5_qN.js.br +0 -0
- package/dist/web/assets/project-source-panel-CDrU5_qN.js.gz +0 -0
- package/dist/web/assets/prompt-input-controls-C_Zm2pL8.js +0 -1
- package/dist/web/assets/prompt-input-controls-C_Zm2pL8.js.br +0 -0
- package/dist/web/assets/prompt-input-controls-C_Zm2pL8.js.gz +0 -0
- package/dist/web/assets/prompt-reference-token-XDhhAENk.js +0 -1
- package/dist/web/assets/prompt-reference-token-XDhhAENk.js.br +0 -0
- package/dist/web/assets/prompt-reference-token-XDhhAENk.js.gz +0 -0
- package/dist/web/assets/provider-connection-queries-BBs1XjP6.js +0 -1
- package/dist/web/assets/provider-connection-queries-BBs1XjP6.js.br +0 -0
- package/dist/web/assets/provider-connection-queries-BBs1XjP6.js.gz +0 -0
- package/dist/web/assets/react-runtime-CVaUQXZF.js.br +0 -0
- package/dist/web/assets/react-runtime-CVaUQXZF.js.gz +0 -0
- package/dist/web/assets/rolldown-runtime-QTnfLwEv.js +0 -1
- package/dist/web/assets/rolldown-runtime-QTnfLwEv.js.br +0 -0
- package/dist/web/assets/rolldown-runtime-QTnfLwEv.js.gz +0 -0
- package/dist/web/assets/shiki-bundle-CGkIRfLa.js.br +0 -0
- package/dist/web/assets/shiki-bundle-CGkIRfLa.js.gz +0 -0
- package/dist/web/assets/tooltip-BPVbHVEF.js +0 -1
- package/dist/web/assets/tooltip-BPVbHVEF.js.br +0 -0
- package/dist/web/assets/tooltip-BPVbHVEF.js.gz +0 -0
- package/dist/web/assets/upload-Bz26q2Ar.js +0 -1
- package/dist/web/assets/upload-Bz26q2Ar.js.br +0 -0
- package/dist/web/assets/upload-Bz26q2Ar.js.gz +0 -0
- package/dist/web/assets/useInfiniteQuery-DJg78OO5.js +0 -1
- package/dist/web/assets/useInfiniteQuery-DJg78OO5.js.br +0 -0
- package/dist/web/assets/useInfiniteQuery-DJg78OO5.js.gz +0 -0
- package/dist/web/assets/workbench-inspector-changes-B4eOJNJh.js +0 -2
- package/dist/web/assets/workbench-inspector-changes-B4eOJNJh.js.br +0 -0
- package/dist/web/assets/workbench-inspector-changes-B4eOJNJh.js.gz +0 -0
- package/dist/web/assets/workbench-pet-canvas-C_XAi7ez.js +0 -1
- package/dist/web/assets/workbench-pet-canvas-C_XAi7ez.js.br +0 -0
- package/dist/web/assets/workbench-pet-canvas-C_XAi7ez.js.gz +0 -0
- package/dist/web/assets/workbench-shell-DQbj_ooS.js +0 -15
- package/dist/web/assets/workbench-shell-DQbj_ooS.js.br +0 -0
- package/dist/web/assets/workbench-shell-DQbj_ooS.js.gz +0 -0
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/global-settings-dialog-cA1SWDdi.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-runtime-CVaUQXZF.js","assets/dist-DBbCRukl.js","assets/bundle-mjs-rHxsej31.js","assets/tooltip-BPVbHVEF.js","assets/checkbox-BBHD70U-.js","assets/check-C92ZHwwX.js","assets/loader-circle-CJOhkEC8.js","assets/workbench-pet-canvas-C_XAi7ez.js","assets/prompt-input-controls-C_Zm2pL8.js","assets/provider-connection-queries-BBs1XjP6.js","assets/git-commit-horizontal-hgIO8zJZ.js","assets/lazy-message-response-SjU6ZsaR.js","assets/upload-Bz26q2Ar.js","assets/workbench-shell-DQbj_ooS.js","assets/dist-B_DB3jSu.js","assets/es2015-BUwabepB.js","assets/file-tree-DvTv0Re2.js","assets/project-source-panel-CDrU5_qN.js","assets/useInfiniteQuery-DJg78OO5.js","assets/file-code-corner-CJDhFrYy.js","assets/code-languages-rKSHZYzu.js","assets/prompt-reference-token-XDhhAENk.js","assets/button-group-Bt_Rr9-f.js","assets/file-review-dialog-L7snJJP8.js","assets/file-navigation-view-preference-DeIXQ8c4.js","assets/file-change-D7aZLgtG.js","assets/context-menu-03SuSeWI.js","assets/project-file-popup-page-C5dOvxw_.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e,t}from"./rolldown-runtime-QTnfLwEv.js";import{i as n,n as r,r as i,t as a}from"./react-runtime-CVaUQXZF.js";import{A as o,D as s,F as c,I as l,L as u,M as d,N as f,O as p,P as m,R as h,S as g,_,a as v,b as y,d as b,f as x,g as S,i as C,j as w,k as T,l as E,m as D,n as O,o as k,p as A,r as j,s as M,t as N,u as P,v as F,w as I,y as L}from"./dist-DBbCRukl.js";import{$ as R,A as z,B,D as V,E as H,F as ee,G as te,I as ne,J as re,K as U,L as ie,M as ae,N as oe,P as se,Q as ce,R as le,T as W,Y as ue,_ as G,a as de,at as fe,c as pe,et as me,i as he,j as ge,k as _e,l as K,n as ve,nt as ye,o as be,ot as xe,q as Se,r as Ce,rt as we,s as Te,st as Ee,t as De,tt as Oe,u as ke,z as Ae}from"./tooltip-BPVbHVEF.js";import{t as je}from"./useInfiniteQuery-DJg78OO5.js";import{a as Me,c as Ne,i as Pe,l as q,n as Fe,o as Ie,r as Le,s as Re,t as ze,u as Be}from"./checkbox-BBHD70U-.js";import{n as Ve,r as He,t as Ue}from"./loader-circle-CJOhkEC8.js";import{t as We}from"./check-C92ZHwwX.js";import{_ as Ge,a as Ke,c as qe,d as Je,f as Ye,g as Xe,h as Ze,i as Qe,l as $e,m as et,n as tt,o as nt,p as rt,r as it,s as at,t as ot,u as st,y as ct}from"./dist-B_DB3jSu.js";import{i as lt,l as ut,s as dt,t as ft}from"./file-tree-DvTv0Re2.js";import{a as pt,c as mt,i as ht,l as gt,n as _t,o as vt,r as yt,s as bt,t as xt,u as St}from"./provider-connection-queries-BBs1XjP6.js";import{i as Ct,n as wt,r as Tt,t as Et}from"./es2015-BUwabepB.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var J=e(n(),1),Dt=typeof window<`u`?J.useLayoutEffect:J.useEffect;function Ot(e){let t=J.useRef({value:e,prev:null}),n=t.current.value;return e!==n&&(t.current={value:e,prev:n}),t.current.prev}function kt(e,t,n={},r={}){J.useEffect(()=>{if(!e.current||r.disabled||typeof IntersectionObserver!=`function`)return;let i=new IntersectionObserver(([e])=>{t(e)},n);return i.observe(e.current),()=>{i.disconnect()}},[t,n,r.disabled,e])}function At(e){let t=J.useRef(null);return J.useImperativeHandle(e,()=>t.current,[]),t}function jt(e){return e[e.length-1]}function Mt(e){return typeof e==`function`}function Nt(e,t){return Mt(e)?e(t):e}var Pt=Object.prototype.hasOwnProperty,Ft=Object.prototype.propertyIsEnumerable;function It(e){for(let t in e)if(Pt.call(e,t))return!0;return!1}var Lt=()=>Object.create(null),Rt=(e,t)=>zt(e,t,Lt);function zt(e,t,n=()=>({}),r=0){if(e===t)return e;if(r>500)return t;let i=t,a=Ut(e)&&Ut(i);if(!a&&!(Vt(e)&&Vt(i)))return i;let o=a?e:Bt(e);if(!o)return i;let s=a?i:Bt(i);if(!s)return i;let c=o.length,l=s.length,u=a?Array(l):n(),d=0;for(let t=0;t<l;t++){let o=a?t:s[t],l=e[o],f=i[o];if(l===f){u[o]=l,(a?t<c:Pt.call(e,o))&&d++;continue}if(l===null||f===null||typeof l!=`object`||typeof f!=`object`){u[o]=f;continue}let p=zt(l,f,n,r+1);u[o]=p,p===l&&d++}return c===l&&d===c?e:u}function Bt(e){let t=Object.getOwnPropertyNames(e);for(let n of t)if(!Ft.call(e,n))return!1;let n=Object.getOwnPropertySymbols(e);if(n.length===0)return t;let r=t;for(let t of n){if(!Ft.call(e,t))return!1;r.push(t)}return r}function Vt(e){if(!Ht(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Ht(n)||!n.hasOwnProperty(`isPrototypeOf`))}function Ht(e){return Object.prototype.toString.call(e)===`[object Object]`}function Ut(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Wt(e,t,n){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0,i=e.length;r<i;r++)if(!Wt(e[r],t[r],n))return!1;return!0}if(Vt(e)&&Vt(t)){let r=n?.ignoreUndefined??!0;if(n?.partial){for(let i in t)if((!r||t[i]!==void 0)&&!Wt(e[i],t[i],n))return!1;return!0}let i=0;if(!r)i=Object.keys(e).length;else for(let t in e)e[t]!==void 0&&i++;let a=0;for(let o in t)if((!r||t[o]!==void 0)&&(a++,a>i||!Wt(e[o],t[o],n)))return!1;return i===a}return!1}function Gt(e){let t,n,r=new Promise((e,r)=>{t=e,n=r});return r.status=`pending`,r.resolve=n=>{r.status=`resolved`,r.value=n,t(n),e?.(n)},r.reject=e=>{r.status=`rejected`,n(e)},r}function Kt(e){return!!(e&&typeof e==`object`&&typeof e.then==`function`)}var qt=/[\x00-\x1f\x7f"<>`{}]/g;function Jt(e){return e.replace(qt,e=>`%`+e.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`))}function Yt(e){let t;try{t=decodeURI(e)}catch{t=e.replaceAll(/%[0-9A-F]{2}/gi,e=>{try{return decodeURI(e)}catch{return e}})}return Jt(t)}var Xt=[`http:`,`https:`,`mailto:`,`tel:`];function Zt(e,t){if(!e)return!1;try{let n=new URL(e);return!t.has(n.protocol)}catch{return!1}}function Qt(e){if(!e||!/[%\\\x00-\x1f\x7f]/.test(e)&&!e.startsWith(`//`))return{path:e,handledProtocolRelativeURL:!1};let t=/%25|%5C/gi,n=0,r=``,i;for(;(i=t.exec(e))!==null;)r+=Yt(e.slice(n,i.index))+i[0],n=t.lastIndex;r+=Yt(n?e.slice(n):e);let a=!1;return r.startsWith(`//`)&&(a=!0,r=`/`+r.replace(/^\/+/,``)),{path:r,handledProtocolRelativeURL:a}}function $t(e){return/\s|[^\u0000-\u007F]/.test(e)?e.replace(/\s|[^\u0000-\u007F]/gu,encodeURIComponent):e}function en(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function tn(){throw Error(`Invariant failed`)}function nn(e){let t=new Map,n,r,i=e=>{e.next&&(e.prev?(e.prev.next=e.next,e.next.prev=e.prev,e.next=void 0,r&&(r.next=e,e.prev=r)):(e.next.prev=void 0,n=e.next,e.next=void 0,r&&(e.prev=r,r.next=e)),r=e)};return{get(e){let n=t.get(e);if(n)return i(n),n.value},set(a,o){if(t.size>=e&&n){let e=n;t.delete(e.key),e.next&&(n=e.next,e.next.prev=void 0),e===r&&(r=void 0)}let s=t.get(a);if(s)s.value=o,i(s);else{let e={key:a,value:o,prev:r};r&&(r.next=e),r=e,n||=e,t.set(a,e)}},clear(){t.clear(),n=void 0,r=void 0}}}var rn=4,an=5;function on(e){let t=e.indexOf(`{`);if(t===-1)return null;let n=e.indexOf(`}`,t);return n===-1||t+1>=e.length?null:[t,n]}function sn(e,t,n=new Uint16Array(6)){let r=e.indexOf(`/`,t),i=r===-1?e.length:r,a=e.substring(t,i);if(!a||!a.includes(`$`))return n[0]=0,n[1]=t,n[2]=t,n[3]=i,n[4]=i,n[5]=i,n;if(a===`$`){let r=e.length;return n[0]=2,n[1]=t,n[2]=t,n[3]=r,n[4]=r,n[5]=r,n}if(a.charCodeAt(0)===36)return n[0]=1,n[1]=t,n[2]=t+1,n[3]=i,n[4]=i,n[5]=i,n;let o=on(a);if(o){let[r,s]=o,c=a.charCodeAt(r+1);if(c===45){if(r+2<a.length&&a.charCodeAt(r+2)===36){let e=r+3,a=s;if(e<a)return n[0]=3,n[1]=t+r,n[2]=t+e,n[3]=t+a,n[4]=t+s+1,n[5]=i,n}}else if(c===36){let a=r+1,o=r+2;return o===s?(n[0]=2,n[1]=t+r,n[2]=t+a,n[3]=t+o,n[4]=t+s+1,n[5]=e.length,n):(n[0]=1,n[1]=t+r,n[2]=t+o,n[3]=t+s,n[4]=t+s+1,n[5]=i,n)}}return n[0]=0,n[1]=t,n[2]=t,n[3]=i,n[4]=i,n[5]=i,n}function cn(e,t,n,r,i,a,o){o?.(n);let s=r;{let r=n.fullPath??n.from,o=r.length,c=n.options?.caseSensitive??e,l=n.options?.params?.parse??n.options?.parseParams;for(;s<o;){let e=sn(r,s,t),o,u=s,d=e[5];switch(s=d+1,a++,e[0]){case 0:{let t=r.substring(e[2],e[3]);if(c){let e=i.static?.get(t);if(e)o=e;else{i.static??=new Map;let e=dn(n.fullPath??n.from);e.parent=i,e.depth=a,o=e,i.static.set(t,e)}}else{let e=t.toLowerCase(),r=i.staticInsensitive?.get(e);if(r)o=r;else{i.staticInsensitive??=new Map;let t=dn(n.fullPath??n.from);t.parent=i,t.depth=a,o=t,i.staticInsensitive.set(e,t)}}break}case 1:{let t=r.substring(u,e[1]),s=r.substring(e[4],d),f=c&&!!(t||s),p=t?f?t:t.toLowerCase():void 0,m=s?f?s:s.toLowerCase():void 0,h=!l&&i.dynamic?.find(e=>!e.parse&&e.caseSensitive===f&&e.prefix===p&&e.suffix===m);if(h)o=h;else{let e=fn(1,n.fullPath??n.from,f,p,m);o=e,e.depth=a,e.parent=i,i.dynamic??=[],i.dynamic.push(e)}break}case 3:{let t=r.substring(u,e[1]),s=r.substring(e[4],d),f=c&&!!(t||s),p=t?f?t:t.toLowerCase():void 0,m=s?f?s:s.toLowerCase():void 0,h=!l&&i.optional?.find(e=>!e.parse&&e.caseSensitive===f&&e.prefix===p&&e.suffix===m);if(h)o=h;else{let e=fn(3,n.fullPath??n.from,f,p,m);o=e,e.parent=i,e.depth=a,i.optional??=[],i.optional.push(e)}break}case 2:{let t=r.substring(u,e[1]),s=r.substring(e[4],d),l=c&&!!(t||s),f=t?l?t:t.toLowerCase():void 0,p=s?l?s:s.toLowerCase():void 0,m=fn(2,n.fullPath??n.from,l,f,p);o=m,m.parent=i,m.depth=a,i.wildcard??=[],i.wildcard.push(m)}}i=o}if(l&&n.children&&!n.isRoot&&n.id&&n.id.charCodeAt(n.id.lastIndexOf(`/`)+1)===95){let e=dn(n.fullPath??n.from);e.kind=an,e.parent=i,a++,e.depth=a,i.pathless??=[],i.pathless.push(e),i=e}let u=(n.path||!n.children)&&!n.isRoot;if(u&&r.endsWith(`/`)){let e=dn(n.fullPath??n.from);e.kind=rn,e.parent=i,a++,e.depth=a,i.index=e,i=e}i.parse=l??null,i.priority=n.options?.params?.priority??0,u&&!i.route&&(i.route=n,i.fullPath=n.fullPath??n.from)}if(n.children)for(let r of n.children)cn(e,t,r,s,i,a,o)}function ln(e,t){if(e.parse&&!t.parse)return-1;if(!e.parse&&t.parse)return 1;if(e.parse&&t.parse&&(e.priority||t.priority))return t.priority-e.priority;if(e.prefix&&t.prefix&&e.prefix!==t.prefix){if(e.prefix.startsWith(t.prefix))return-1;if(t.prefix.startsWith(e.prefix))return 1}if(e.suffix&&t.suffix&&e.suffix!==t.suffix){if(e.suffix.endsWith(t.suffix))return-1;if(t.suffix.endsWith(e.suffix))return 1}return e.prefix&&!t.prefix?-1:!e.prefix&&t.prefix?1:e.suffix&&!t.suffix?-1:!e.suffix&&t.suffix?1:e.caseSensitive&&!t.caseSensitive?-1:!e.caseSensitive&&t.caseSensitive?1:0}function un(e){if(e.pathless)for(let t of e.pathless)un(t);if(e.static)for(let t of e.static.values())un(t);if(e.staticInsensitive)for(let t of e.staticInsensitive.values())un(t);if(e.dynamic?.length){e.dynamic.sort(ln);for(let t of e.dynamic)un(t)}if(e.optional?.length){e.optional.sort(ln);for(let t of e.optional)un(t)}if(e.wildcard?.length){e.wildcard.sort(ln);for(let t of e.wildcard)un(t)}}function dn(e){return{kind:0,depth:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:e,parent:null,parse:null,priority:0}}function fn(e,t,n,r,i){return{kind:e,depth:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:t,parent:null,parse:null,priority:0,caseSensitive:n,prefix:r,suffix:i}}function pn(e,t){let n=dn(`/`),r=new Uint16Array(6);for(let t of e)cn(!1,r,t,1,n,0);un(n),t.masksTree=n,t.flatCache=nn(1e3)}function mn(e,t){e||=`/`;let n=t.flatCache.get(e);if(n)return n;let r=yn(e,t.masksTree);return t.flatCache.set(e,r),r}function hn(e,t,n,r,i){e||=`/`,r||=`/`;let a=t?`case\0${e}`:e,o=i.singleCache.get(a);return o||(o=dn(`/`),cn(t,new Uint16Array(6),{from:e},1,o,0),i.singleCache.set(a,o)),yn(r,o,n)}function gn(e,t,n=!1){let r=n?e:`nofuzz\0${e}`,i=t.matchCache.get(r);if(i!==void 0)return i;e||=`/`;let a;try{a=yn(e,t.segmentTree,n)}catch(e){if(e instanceof URIError)a=null;else throw e}return a&&(a.branch=xn(a.route)),t.matchCache.set(r,a),a}function _n(e){return e===`/`?e:e.replace(/\/{1,}$/,``)}function vn(e,t=!1,n){let r=dn(e.fullPath),i=new Uint16Array(6),a={},o={},s=0;return cn(t,i,e,1,r,0,e=>{if(n?.(e,s),e.id in a&&tn(),a[e.id]=e,s!==0&&e.path){let t=_n(e.fullPath);(!o[t]||e.fullPath.endsWith(`/`))&&(o[t]=e)}s++}),un(r),{processedTree:{segmentTree:r,singleCache:nn(1e3),matchCache:nn(1e3),flatCache:null,masksTree:null},routesById:a,routesByPath:o}}function yn(e,t,n=!1){let r=e.split(`/`),i=Cn(e,r,t,n);if(!i)return null;let[a]=bn(e,r,i);return{route:i.node.route,rawParams:a}}function bn(e,t,n){let r=Sn(n.node),i=null,a=Object.create(null),o=n.extract?.part??0,s=n.extract?.node??0,c=n.extract?.path??0,l=n.extract?.segment??0;for(;s<r.length;o++,s++,c++,l++){let u=r[s];if(u.kind===rn)break;if(u.kind===an){l--,o--,c--;continue}let d=t[o],f=c;if(d&&(c+=d.length),u.kind===1){i??=n.node.fullPath.split(`/`);let e=i[l],t=u.prefix?.length??0;if(e.charCodeAt(t)===123){let n=u.suffix?.length??0,r=e.substring(t+2,e.length-n-1),i=d.substring(t,d.length-n);a[r]=decodeURIComponent(i)}else{let t=e.substring(1);a[t]=decodeURIComponent(d)}}else if(u.kind===3){if(n.skipped&1<<s){o--,c=f-1;continue}i??=n.node.fullPath.split(`/`);let e=i[l],t=u.prefix?.length??0,r=u.suffix?.length??0,p=e.substring(t+3,e.length-r-1),m=u.suffix||u.prefix?d.substring(t,d.length-r):d;m&&(a[p]=decodeURIComponent(m))}else if(u.kind===2){let t=u,n=e.substring(f+(t.prefix?.length??0),e.length-(t.suffix?.length??0)),r=decodeURIComponent(n);a[`*`]=r,a._splat=r;break}}return n.rawParams&&Object.assign(a,n.rawParams),[a,{part:o,node:s,path:c,segment:l}]}function xn(e){let t=[e];for(;e.parentRoute;)e=e.parentRoute,t.push(e);return t.reverse(),t}function Sn(e){let t=Array(e.depth+1);do t[e.depth]=e,e=e.parent;while(e);return t}function Cn(e,t,n,r){if(e===`/`&&n.index)return{node:n.index,skipped:0};let i=!jt(t),a=i&&e!==`/`,o=t.length-+!!i,s=[{node:n,index:1,skipped:0,depth:1,statics:0,dynamics:0,optionals:0}],c=null,l=null;for(;s.length;){let n=s.pop(),{node:i,index:u,skipped:d,depth:f,statics:p,dynamics:m,optionals:h}=n,{extract:g,rawParams:_}=n;if(i.kind===2&&i.route&&!Dn(l,n))continue;if(i.parse){if(!En(e,t,n))continue;_=n.rawParams,g=n.extract}r&&i.route&&i.kind!==rn&&Dn(c,n)&&(c=n);let v=u===o;if(v&&(i.route&&(!a||i.kind===rn||i.kind===2)&&Dn(l,n)&&(l=n),!i.optional&&!i.wildcard&&!i.index&&!i.pathless))continue;let y=v?void 0:t[u],b;if(v&&i.index){let n={node:i.index,index:u,skipped:d,depth:f+1,statics:p,dynamics:m,optionals:h,extract:g,rawParams:_},r=!0;if(i.index.parse&&(En(e,t,n)||(r=!1)),r){if(!m&&!h&&!d&&Tn(p,o))return n;Dn(l,n)&&(l=n)}}if(i.wildcard)for(let e=i.wildcard.length-1;e>=0;e--){let n=i.wildcard[e],{prefix:r,suffix:a}=n;if(!(r&&(v||!(n.caseSensitive?y:b??=y.toLowerCase()).startsWith(r)))){if(a){if(v)continue;let e=t.slice(u).join(`/`).slice(-a.length);if((n.caseSensitive?e:e.toLowerCase())!==a)continue}s.push({node:n,index:o,skipped:d,depth:f+1,statics:p,dynamics:m,optionals:h,extract:g,rawParams:_})}}if(i.optional){let e=d|1<<f,t=f+1;for(let n=i.optional.length-1;n>=0;n--){let r=i.optional[n];s.push({node:r,index:u,skipped:e,depth:t,statics:p,dynamics:m,optionals:h,extract:g,rawParams:_})}if(!v)for(let e=i.optional.length-1;e>=0;e--){let n=i.optional[e],{prefix:r,suffix:a}=n;if(r||a){let e=n.caseSensitive?y:b??=y.toLowerCase();if(r&&!e.startsWith(r)||a&&!e.endsWith(a))continue}s.push({node:n,index:u+1,skipped:d,depth:t,statics:p,dynamics:m,optionals:h+wn(o,u),extract:g,rawParams:_})}}if(!v&&i.dynamic&&y)for(let e=i.dynamic.length-1;e>=0;e--){let t=i.dynamic[e],{prefix:n,suffix:r}=t;if(n||r){let e=t.caseSensitive?y:b??=y.toLowerCase();if(n&&!e.startsWith(n)||r&&!e.endsWith(r))continue}s.push({node:t,index:u+1,skipped:d,depth:f+1,statics:p,dynamics:m+wn(o,u),optionals:h,extract:g,rawParams:_})}if(!v&&i.staticInsensitive){let e=i.staticInsensitive.get(b??=y.toLowerCase());e&&s.push({node:e,index:u+1,skipped:d,depth:f+1,statics:p+wn(o,u),dynamics:m,optionals:h,extract:g,rawParams:_})}if(!v&&i.static){let e=i.static.get(y);e&&s.push({node:e,index:u+1,skipped:d,depth:f+1,statics:p+wn(o,u),dynamics:m,optionals:h,extract:g,rawParams:_})}if(i.pathless){let e=f+1;for(let t=i.pathless.length-1;t>=0;t--){let n=i.pathless[t];s.push({node:n,index:u,skipped:d,depth:e,statics:p,dynamics:m,optionals:h,extract:g,rawParams:_})}}}if(l)return l;if(r&&c){let n=c.index;for(let e=0;e<c.index;e++)n+=t[e].length;let r=n===e.length?`/`:e.slice(n);return c.rawParams??=Object.create(null),c.rawParams[`**`]=decodeURIComponent(r),c}return null}function wn(e,t){return 2**(e-t-1)}function Tn(e,t){return e===2**(t-1)-1}function En(e,t,n){let r,i;try{[r,i]=bn(e,t,n)}catch{return null}if(n.rawParams=r,n.extract=i,!n.node.parse)return!0;try{if(n.node.parse(r)===!1)return null}catch{}return!0}function Dn(e,t){return!e||t.statics>e.statics||t.statics===e.statics&&(t.dynamics>e.dynamics||t.dynamics===e.dynamics&&(t.optionals>e.optionals||t.optionals===e.optionals&&((t.node.kind===rn)>(e.node.kind===rn)||t.node.kind===rn==(e.node.kind===rn)&&t.depth>e.depth)))}function On(e){return kn(e.filter(e=>e!==void 0).join(`/`))}function kn(e){return e.replace(/\/{2,}/g,`/`)}function An(e){return e===`/`?e:e.replace(/^\/{1,}/,``)}function jn(e){let t=e.length;return t>1&&e[t-1]===`/`?e.replace(/\/{1,}$/,``):e}function Mn(e){return jn(An(e))}function Nn(e,t){return e?.endsWith(`/`)&&e!==`/`&&e!==`${t}/`?e.slice(0,-1):e}function Pn(e,t,n){return Nn(e,n)===Nn(t,n)}function Fn({base:e,to:t,trailingSlash:n=`never`,cache:r}){let i=t.startsWith(`/`),a=!i&&t===`.`,o;if(r){o=i?t:a?e:e+`\0`+t;let n=r.get(o);if(n)return n}let s;if(a)s=e.split(`/`);else if(i)s=t.split(`/`);else{for(s=e.split(`/`);s.length>1&&jt(s)===``;)s.pop();let n=t.split(`/`);for(let e=0,t=n.length;e<t;e++){let r=n[e];r===``?e?e===t-1&&s.push(r):s=[r]:r===`..`?s.pop():r===`.`||s.push(r)}}s.length>1&&(jt(s)===``?n===`never`&&s.pop():n===`always`&&s.push(``));let c=kn(s.join(`/`))||`/`;return o&&r&&r.set(o,c),c}function In(e){let t=new Map(e.map(e=>[encodeURIComponent(e),e])),n=Array.from(t.keys()).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`),r=new RegExp(n,`g`);return e=>e.replace(r,e=>t.get(e)??e)}function Ln(e,t,n){let r=t[e];return typeof r==`string`?e===`_splat`?/^[a-zA-Z0-9\-._~!/]*$/.test(r)?r:r.split(`/`).map(e=>zn(e,n)).join(`/`):zn(r,n):r}function Rn({path:e,params:t,decoder:n,...r}){let i=!1,a=Object.create(null);if(!e||e===`/`)return{interpolatedPath:`/`,usedParams:a,isMissingParams:i};if(!e.includes(`$`))return{interpolatedPath:e,usedParams:a,isMissingParams:i};let o=e.length,s=0,c,l=``;for(;s<o;){let r=s;c=sn(e,r,c);let o=c[5];if(s=o+1,r===o)continue;let u=c[0];if(u===0){l+=`/`+e.substring(r,o);continue}if(u===2){let s=t._splat;a._splat=s,a[`*`]=s;let u=e.substring(r,c[1]),d=e.substring(c[4],o);if(!s){i=!0,(u||d)&&(l+=`/`+u+d);continue}let f=Ln(`_splat`,t,n);l+=`/`+u+f+d;continue}if(u===1){let s=e.substring(c[2],c[3]);!i&&!(s in t)&&(i=!0),a[s]=t[s];let u=e.substring(r,c[1]),d=e.substring(c[4],o),f=Ln(s,t,n)??`undefined`;l+=`/`+u+f+d;continue}if(u===3){let i=e.substring(c[2],c[3]),s=t[i];if(s==null)continue;a[i]=s;let u=e.substring(r,c[1]),d=e.substring(c[4],o),f=Ln(i,t,n)??``;l+=`/`+u+f+d;continue}}return e.endsWith(`/`)&&(l+=`/`),{usedParams:a,interpolatedPath:l||`/`,isMissingParams:i}}function zn(e,t){let n=encodeURIComponent(e);return t?.(n)??n}function Y(e){return e?.isNotFound===!0}function Bn(){try{return sessionStorage}catch{return}}var Vn=`tsr-scroll-restoration-v1_3`,Hn=Bn();function Un(){try{return JSON.parse(Hn?.getItem(`tsr-scroll-restoration-v1_3`)||`{}`)}catch{return{}}}function Wn(){try{Hn?.setItem(Vn,JSON.stringify(Gn))}catch{}}var Gn=Un(),Kn=`data-scroll-restoration-id`,qn=e=>e.state.__TSR_key||e.href;function Jn(e){let t=e.getAttribute(Kn);if(t)return`[${Kn}="${t}"]`;let n=``,r=e,i;for(;i=r.parentNode;){let e=1,t=r;for(;t=t.previousElementSibling;)e++;let a=`${r.localName}:nth-child(${e})`;n=n?`${a} > ${n}`:a,r=i}return n}var Yn=!1,Xn=`window`;function Zn(e){try{return typeof e==`function`?e():document.querySelector(e)}catch{}}function Qn(e){let t=new Set;for(let n of e){if(n===Xn)continue;let e=Zn(n);e&&t.add(e)}return t}function $n(e,t){let n=t??e.options.scrollRestoration,r=e._scroll;n&&(r.restoring=!0);let i=e.options.getScrollRestorationKey||qn,a=new Set,o=e=>{let t=Gn[e]||={};for(let e of a)e===document?t[Xn]={scrollX,scrollY}:e.isConnected&&(t[Jn(e)]={scrollX:e.scrollLeft,scrollY:e.scrollTop})};n&&!r.restoration&&(r.restoration=!0,Yn=!1,history.scrollRestoration=`manual`,document.addEventListener(`scroll`,e=>{Yn||a.add(e.target)},!0),e.subscribe(`onBeforeLoad`,e=>{e.fromLocation&&o(i(e.fromLocation)),a.clear()}),addEventListener(`pagehide`,()=>{o(i(e.stores.resolvedLocation.get()??e.stores.location.get())),Wn()})),!r.reset&&(r.reset=!0,e.subscribe(`onRendered`,t=>{let n=e.options.scrollRestorationBehavior,o=e.options.scrollToTopSelectors,s=r.next,c=r.hash,l;if(a.clear(),r.next=!0,r.hash=!1,typeof e.options.scrollRestoration==`function`&&!e.options.scrollRestoration({location:e.latestLocation}))return;let u=i(t.toLocation),d=t.fromLocation&&i(t.fromLocation);if(r.restoring&&d&&d!==u){let e=Gn[d];if(e){let t=Gn[u];for(let n in e){if(n===Xn){if(s)continue}else{let e=Zn(n);if(!e||s&&o&&(l??=Qn(o),l.has(e)))continue}t||=Gn[u]={},t[n]??=e[n]}}}Yn=!0;try{let e=t.toLocation.hash,i=t.toLocation.state.__hashScrollIntoViewOptions??!0,a=!1;if(s){!e&&o&&(l??=Qn(o));let t=e&&i&&c,s=r.restoring?Gn[u]:void 0;if(s)for(let e in s){let{scrollX:r,scrollY:i}=s[e];if(e===Xn){if(t)continue;scrollTo({top:i,left:r,behavior:n}),a=!0}else{let t=Zn(e);t&&(t.scrollLeft=r,t.scrollTop=i,l?.delete(t))}}if(!e){let e={top:0,left:0,behavior:n};if(a||scrollTo(e),l)for(let t of l)t.scrollTo(e)}}!a&&e&&i&&document.getElementById(e)?.scrollIntoView(i)}finally{Yn=!1}}))}function er(e,t=String){let n=new URLSearchParams;for(let r in e){let i=e[r];i!==void 0&&n.set(r,t(i))}return n.toString()}function tr(e){return e?e===`false`?!1:e===`true`?!0:e*0==0&&+e+``===e?+e:e:``}function nr(e){let t=new URLSearchParams(e),n=Object.create(null);for(let[e,r]of t.entries()){let t=n[e];t==null?n[e]=tr(r):Array.isArray(t)?t.push(tr(r)):n[e]=[t,tr(r)]}return n}var rr=ar(JSON.parse),ir=or(JSON.stringify,JSON.parse);function ar(e){return t=>{t[0]===`?`&&(t=t.substring(1));let n=nr(t);for(let t in n){let r=n[t];if(typeof r==`string`)try{n[t]=e(r)}catch{}}return n}}function or(e,t){let n=typeof t==`function`;function r(r){if(typeof r==`object`&&r)try{return e(r)}catch{}else if(n&&typeof r==`string`)try{return t(r),e(r)}catch{}return r}return e=>{let t=er(e,r);return t?`?${t}`:``}}var sr=`__root__`;function cr(e){if(e.statusCode=e.statusCode||e.code||307,!e._builtLocation&&!e.reloadDocument&&typeof e.href==`string`)try{new URL(e.href),e.reloadDocument=!0}catch{}let t=new Headers(e.headers);e.href&&t.get(`Location`)===null&&t.set(`Location`,e.href);let n=new Response(null,{status:e.statusCode,headers:t});if(n.options=e,e.throw)throw n;return n}function lr(e){return e instanceof Response&&!!e.options}function ur(e){return{input:({url:t})=>{for(let n of e)t=fr(n,t);return t},output:({url:t})=>{for(let n=e.length-1;n>=0;n--)t=pr(e[n],t);return t}}}function dr(e){let t=Mn(e.basepath),n=`/${t}`,r=e.caseSensitive?n:n.toLowerCase(),i=`${r}/`;return{input:({url:t})=>{let a=e.caseSensitive?t.pathname:t.pathname.toLowerCase();return a===r?t.pathname=`/`:a.startsWith(i)&&(t.pathname=t.pathname.slice(n.length)),t},output:({url:e})=>(e.pathname=On([`/`,t,e.pathname]),e)}}function fr(e,t){let n=e?.input?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function pr(e,t){let n=e?.output?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function mr(e,t){let{createMutableStore:n,createReadonlyStore:r,batch:i,init:a}=t,o=new Map,s=new Map,c=new Map,l=n(e.status),u=n(e.loadedAt),d=n(e.isLoading),f=n(e.isTransitioning),p=n(e.location),m=n(e.resolvedLocation),h=n(e.statusCode),g=n(e.redirect),_=n([]),v=n([]),y=n([]),b=r(()=>hr(o,_.get())),x=r(()=>hr(s,v.get())),S=r(()=>hr(c,y.get())),C=r(()=>_.get()[0]),w=r(()=>_.get().some(e=>o.get(e)?.get().status===`pending`)),T=r(()=>({locationHref:p.get().href,resolvedLocationHref:m.get()?.href,status:l.get()})),E=r(()=>({status:l.get(),loadedAt:u.get(),isLoading:d.get(),isTransitioning:f.get(),matches:b.get(),location:p.get(),resolvedLocation:m.get(),statusCode:h.get(),redirect:g.get()})),D=nn(64);function O(e){let t=D.get(e);return t||(t=r(()=>{let t=_.get();for(let n of t){let t=o.get(n);if(t&&t.routeId===e)return t.get()}}),D.set(e,t)),t}let k={status:l,loadedAt:u,isLoading:d,isTransitioning:f,location:p,resolvedLocation:m,statusCode:h,redirect:g,matchesId:_,pendingIds:v,cachedIds:y,matches:b,pendingMatches:x,cachedMatches:S,firstId:C,hasPending:w,matchRouteDeps:T,matchStores:o,pendingMatchStores:s,cachedMatchStores:c,__store:E,getRouteMatchStore:O,setMatches:A,setPending:j,setCached:M};A(e.matches),a?.(k);function A(e){gr(e,o,_,n,i)}function j(e){gr(e,s,v,n,i)}function M(e){gr(e,c,y,n,i)}return k}function hr(e,t){let n=[];for(let r of t){let t=e.get(r);t&&n.push(t.get())}return n}function gr(e,t,n,r,i){let a=e.map(e=>e.id),o=new Set(a);i(()=>{for(let e of t.keys())o.has(e)||t.delete(e);for(let n of e){let e=t.get(n.id);if(!e){let e=r(n);e.routeId=n.routeId,t.set(n.id,e);continue}e.routeId=n.routeId,e.get()!==n&&e.set(n)}en(n.get(),a)||n.set(a)})}var _r=e=>{if(!e.rendered)return e.rendered=!0,e.onReady?.()},vr=e=>e.stores.matchesId.get().some(t=>e.stores.matchStores.get(t)?.get()._forcePending),yr=(e,t)=>!!(e.preload&&!e.router.stores.matchStores.has(t)),br=(e,t,n=!0)=>{let r={...e.router.options.context??{}},i=n?t:t-1;for(let t=0;t<=i;t++){let n=e.matches[t];if(!n)continue;let i=e.router.getMatch(n.id);i&&Object.assign(r,i.__routeContext,i.__beforeLoadContext)}return r},xr=(e,t)=>{if(!e.matches.length)return;let n=t.routeId,r=e.matches.findIndex(t=>t.routeId===e.router.routeTree.id),i=r>=0?r:0,a=n?e.matches.findIndex(e=>e.routeId===n):e.firstBadMatchIndex??e.matches.length-1;a<0&&(a=i);for(let t=a;t>=0;t--){let n=e.matches[t];if(e.router.looseRoutesById[n.routeId].options.notFoundComponent)return t}return n?a:i},Sr=(e,t,n)=>{if(!(!lr(n)&&!Y(n)))throw lr(n)&&n.redirectHandled&&!n.options.reloadDocument?n:(t&&(t._nonReactive.beforeLoadPromise?.resolve(),t._nonReactive.loaderPromise?.resolve(),t._nonReactive.beforeLoadPromise=void 0,t._nonReactive.loaderPromise=void 0,t._nonReactive.error=n,e.updateMatch(t.id,r=>({...r,status:lr(n)?`redirected`:Y(n)?`notFound`:r.status===`pending`?`success`:r.status,context:br(e,t.index),isFetching:!1,error:n})),Y(n)&&!n.routeId&&(n.routeId=t.routeId),t._nonReactive.loadPromise?.resolve()),lr(n)&&(e.rendered=!0,n.options._fromLocation=e.location,n.redirectHandled=!0,n=e.router.resolveRedirect(n)),n)},Cr=(e,t)=>{let n=e.router.getMatch(t);return!!(!n||n._nonReactive.dehydrated)},wr=(e,t,n)=>{let r=br(e,n);e.updateMatch(t,e=>({...e,context:r}))},Tr=(e,t,n)=>{let{id:r,routeId:i}=e.matches[t],a=e.router.looseRoutesById[i];if(n instanceof Promise)throw n;e.firstBadMatchIndex??=t,Sr(e,e.router.getMatch(r),n);try{a.options.onError?.(n)}catch(t){n=t,Sr(e,e.router.getMatch(r),n)}e.updateMatch(r,e=>(e._nonReactive.beforeLoadPromise?.resolve(),e._nonReactive.beforeLoadPromise=void 0,e._nonReactive.loadPromise?.resolve(),{...e,error:n,status:`error`,isFetching:!1,updatedAt:Date.now(),abortController:new AbortController})),!e.preload&&!lr(n)&&!Y(n)&&(e.serialError??=n)},Er=(e,t,n,r)=>{if(r._nonReactive.pendingTimeout!==void 0)return;let i=n.options.pendingMs??e.router.options.defaultPendingMs;if(e.onReady&&!yr(e,t)&&(n.options.loader||n.options.beforeLoad||Lr(n))&&typeof i==`number`&&i!==1/0&&(n.options.pendingComponent??e.router.options?.defaultPendingComponent)){let t=setTimeout(()=>{_r(e)},i);r._nonReactive.pendingTimeout=t}},Dr=(e,t,n)=>{let r=e.router.getMatch(t);if(!r._nonReactive.beforeLoadPromise&&!r._nonReactive.loaderPromise)return;Er(e,t,n,r);let i=()=>{let n=e.router.getMatch(t);n.preload&&(n.status===`redirected`||n.status===`notFound`)&&Sr(e,n,n.error)};return r._nonReactive.beforeLoadPromise?r._nonReactive.beforeLoadPromise.then(i):i()},Or=(e,t,n,r)=>{let i=e.router.getMatch(t),a=i._nonReactive.loadPromise;i._nonReactive.loadPromise=Gt(()=>{a?.resolve(),a=void 0});let{paramsError:o,searchError:s}=i;o&&Tr(e,n,o),s&&Tr(e,n,s),Er(e,t,r,i);let c=new AbortController,l=!1,u=()=>{l||(l=!0,e.updateMatch(t,e=>({...e,isFetching:`beforeLoad`,fetchCount:e.fetchCount+1,abortController:c})))},d=()=>{i._nonReactive.beforeLoadPromise?.resolve(),i._nonReactive.beforeLoadPromise=void 0,e.updateMatch(t,e=>({...e,isFetching:!1}))};if(!r.options.beforeLoad){e.router.batch(()=>{u(),d()});return}i._nonReactive.beforeLoadPromise=Gt();let f={...br(e,n,!1),...i.__routeContext},{search:p,params:m,cause:h}=i,g=yr(e,t),_={search:p,abortController:c,params:m,preload:g,context:f,location:e.location,navigate:t=>e.router.navigate({...t,_fromLocation:e.location}),buildLocation:e.router.buildLocation,cause:g?`preload`:h,matches:e.matches,routeId:r.id,...e.router.options.additionalContext},v=r=>{if(r===void 0){e.router.batch(()=>{u(),d()});return}(lr(r)||Y(r))&&(u(),Tr(e,n,r)),e.router.batch(()=>{u(),e.updateMatch(t,e=>({...e,__beforeLoadContext:r})),d()})},y;try{if(y=r.options.beforeLoad(_),Kt(y))return u(),y.catch(t=>{Tr(e,n,t)}).then(v)}catch(t){u(),Tr(e,n,t)}v(y)},kr=(e,t)=>{let{id:n,routeId:r}=e.matches[t],i=e.router.looseRoutesById[r],a=()=>s(),o=()=>Or(e,n,t,i),s=()=>{if(Cr(e,n))return;let t=Dr(e,n,i);return Kt(t)?t.then(o):o()};return a()},Ar=(e,t,n)=>{let r=e.router.getMatch(t);if(!r||!n.options.head&&!n.options.scripts&&!n.options.headers)return;let i={ssr:e.router.options.ssr,matches:e.matches,match:r,params:r.params,loaderData:r.loaderData};return Promise.all([n.options.head?.(i),n.options.scripts?.(i),n.options.headers?.(i)]).then(([e,t,n])=>({meta:e?.meta,links:e?.links,headScripts:e?.scripts,headers:n,scripts:t,styles:e?.styles}))},jr=(e,t,n,r,i)=>{let a=t[r-1],{params:o,loaderDeps:s,abortController:c,cause:l}=e.router.getMatch(n),u=br(e,r),d=yr(e,n);return{params:o,deps:s,preload:!!d,parentMatchPromise:a,abortController:c,context:u,location:e.location,navigate:t=>e.router.navigate({...t,_fromLocation:e.location}),cause:d?`preload`:l,route:i,...e.router.options.additionalContext}},Mr=async(e,t,n,r,i)=>{try{let a=e.router.getMatch(n);try{Ir(i);let o=i.options.loader,s=typeof o==`function`?o:o?.handler,c=s?.(jr(e,t,n,r,i)),l=!!s&&Kt(c);if((l||i._lazyPromise||i._componentsPromise||i.options.head||i.options.scripts||i.options.headers||a._nonReactive.minPendingPromise)&&e.updateMatch(n,e=>({...e,isFetching:`loader`})),s){let t=l?await c:c;Sr(e,e.router.getMatch(n),t),t!==void 0&&e.updateMatch(n,e=>({...e,loaderData:t}))}i._lazyPromise&&await i._lazyPromise;let u=a._nonReactive.minPendingPromise;u&&await u,i._componentsPromise&&await i._componentsPromise,e.updateMatch(n,t=>({...t,error:void 0,context:br(e,r),status:`success`,isFetching:!1,updatedAt:Date.now()}))}catch(t){let o=t;if(o?.name===`AbortError`){if(a.abortController.signal.aborted){a._nonReactive.loaderPromise?.resolve(),a._nonReactive.loaderPromise=void 0;return}e.updateMatch(n,t=>({...t,status:t.status===`pending`?`success`:t.status,isFetching:!1,context:br(e,r)}));return}let s=a._nonReactive.minPendingPromise;s&&await s,Y(t)&&await i.options.notFoundComponent?.preload?.(),Sr(e,e.router.getMatch(n),t);try{i.options.onError?.(t)}catch(t){o=t,Sr(e,e.router.getMatch(n),t)}!lr(o)&&!Y(o)&&await Ir(i,[`errorComponent`]),e.updateMatch(n,t=>({...t,error:o,context:br(e,r),status:`error`,isFetching:!1}))}}catch(t){let r=e.router.getMatch(n);r&&(r._nonReactive.loaderPromise=void 0),Sr(e,r,t)}},Nr=async(e,t,n)=>{async function r(r,a,c,l,d){let f=Date.now()-a.updatedAt,p=r?d.options.preloadStaleTime??e.router.options.defaultPreloadStaleTime??3e4:d.options.staleTime??e.router.options.defaultStaleTime??0,m=d.options.shouldReload,h=typeof m==`function`?m(jr(e,t,i,n,d)):m,{status:g,invalid:_}=l,v=f>=p&&(!!e.forceStaleReload||l.cause===`enter`||c!==void 0&&c!==l.id);o=g===`success`&&(_||(h??v)),r&&d.options.preload===!1||(o&&!e.sync&&u?(s=!0,(async()=>{try{await Mr(e,t,i,n,d);let r=e.router.getMatch(i);r._nonReactive.loaderPromise?.resolve(),r._nonReactive.loadPromise?.resolve(),r._nonReactive.loaderPromise=void 0,r._nonReactive.loadPromise=void 0}catch(t){lr(t)&&await e.router.navigate(t.options)}})()):g!==`success`||o?await Mr(e,t,i,n,d):wr(e,i,n))}let{id:i,routeId:a}=e.matches[n],o=!1,s=!1,c=e.router.looseRoutesById[a],l=c.options.loader,u=((typeof l==`function`?void 0:l?.staleReloadMode)??e.router.options.defaultStaleReloadMode)!==`blocking`;if(Cr(e,i)){if(!e.router.getMatch(i))return e.matches[n];wr(e,i,n)}else{let t=e.router.getMatch(i),o=e.router.stores.matchesId.get()[n],s=(o&&e.router.stores.matchStores.get(o)||null)?.routeId===a?o:e.router.stores.matches.get().find(e=>e.routeId===a)?.id,l=yr(e,i);if(t._nonReactive.loaderPromise){if(t.status===`success`&&!e.sync&&!t.preload&&u)return t;await t._nonReactive.loaderPromise;let n=e.router.getMatch(i),a=n._nonReactive.error||n.error;a&&Sr(e,n,a),n.status===`pending`&&await r(l,t,s,n,c)}else{let n=l&&!e.router.stores.matchStores.has(i),a=e.router.getMatch(i);a._nonReactive.loaderPromise=Gt(),n!==a.preload&&e.updateMatch(i,e=>({...e,preload:n})),await r(l,t,s,a,c)}}let d=e.router.getMatch(i);s||(d._nonReactive.loaderPromise?.resolve(),d._nonReactive.loadPromise?.resolve(),d._nonReactive.loadPromise=void 0),clearTimeout(d._nonReactive.pendingTimeout),d._nonReactive.pendingTimeout=void 0,s||(d._nonReactive.loaderPromise=void 0),d._nonReactive.dehydrated=void 0;let f=s?d.isFetching:!1;return f!==d.isFetching||d.invalid!==!1?(e.updateMatch(i,e=>({...e,isFetching:f,invalid:!1})),e.router.getMatch(i)):d};async function Pr(e){let t=e,n=[];vr(t.router)&&_r(t);let r;for(let e=0;e<t.matches.length;e++){try{let n=kr(t,e);Kt(n)&&await n}catch(e){if(lr(e))throw e;if(Y(e))r=e;else if(!t.preload)throw e;break}if(t.serialError||t.firstBadMatchIndex!=null)break}let i=t.firstBadMatchIndex??t.matches.length,a=r&&!t.preload?xr(t,r):void 0,o=r&&t.preload?0:a===void 0?i:Math.min(a+1,i),s,c;for(let e=0;e<o;e++)n.push(Nr(t,n,e));try{await Promise.all(n)}catch{let e=await Promise.allSettled(n);for(let t of e){if(t.status!==`rejected`)continue;let e=t.reason;if(lr(e))throw e;Y(e)?s??=e:c??=e}if(c!==void 0)throw c}let l=s??(r&&!t.preload?r:void 0),u=t.firstBadMatchIndex===void 0?t.matches.length-1:t.firstBadMatchIndex;if(!l&&r&&t.preload)return t.matches;if(l){let e=xr(t,l);e===void 0&&tn();let n=t.matches[e],r=t.router.looseRoutesById[n.routeId],i=t.router.options?.defaultNotFoundComponent;!r.options.notFoundComponent&&i&&(r.options.notFoundComponent=i),l.routeId=n.routeId;let a=n.routeId===t.router.routeTree.id;t.updateMatch(n.id,e=>({...e,...a?{status:`success`,globalNotFound:!0,error:void 0}:{status:`notFound`,error:l},isFetching:!1})),u=e,await Ir(r,[`notFoundComponent`])}else if(!t.preload){let e=t.matches[0];e.globalNotFound||t.router.getMatch(e.id)?.globalNotFound&&t.updateMatch(e.id,e=>({...e,globalNotFound:!1,error:void 0}))}if(t.serialError&&t.firstBadMatchIndex!==void 0){let e=t.router.looseRoutesById[t.matches[t.firstBadMatchIndex].routeId];await Ir(e,[`errorComponent`])}for(let e=0;e<=u;e++){let{id:n,routeId:r}=t.matches[e],i=t.router.looseRoutesById[r];try{let e=Ar(t,n,i);if(e){let r=await e;t.updateMatch(n,e=>({...e,...r}))}}catch(e){console.error(`Error executing head for route ${r}:`,e)}}let d=_r(t);if(Kt(d)&&await d,l)throw l;if(t.serialError&&!t.preload&&!t.onReady)throw t.serialError;return t.matches}function Fr(e,t){let n=t.map(t=>e.options[t]?.preload?.()).filter(Boolean);if(n.length!==0)return Promise.all(n)}function Ir(e,t=Rr){!e._lazyLoaded&&e._lazyPromise===void 0&&(e.lazyFn?e._lazyPromise=e.lazyFn().then(t=>{let{id:n,...r}=t.options;Object.assign(e.options,r),e._lazyLoaded=!0,e._lazyPromise=void 0}):e._lazyLoaded=!0);let n=()=>e._componentsLoaded?void 0:t===Rr?(()=>{if(e._componentsPromise===void 0){let t=Fr(e,Rr);t?e._componentsPromise=t.then(()=>{e._componentsLoaded=!0,e._componentsPromise=void 0}):e._componentsLoaded=!0}return e._componentsPromise})():Fr(e,t);return e._lazyPromise?e._lazyPromise.then(n):n()}function Lr(e){for(let t of Rr)if(e.options[t]?.preload)return!0;return!1}var Rr=[`component`,`errorComponent`,`pendingComponent`,`notFoundComponent`],zr=`__TSR_index`,Br=`popstate`,Vr=`beforeunload`;function Hr(e){let t=e.getLocation(),n=new Set,r=r=>{t=e.getLocation(),n.forEach(e=>e({location:t,action:r}))},i=n=>{e.notifyOnIndexChange??!0?r(n):t=e.getLocation()},a=async({task:n,navigateOpts:r,...i})=>{if(r?.ignoreBlocker??!1){n();return}let a=e.getBlockers?.()??[],o=i.type===`PUSH`||i.type===`REPLACE`;if(typeof document<`u`&&a.length&&o)for(let n of a){let r=Kr(i.path,i.state);if(await n.blockerFn({currentLocation:t,nextLocation:r,action:i.type})){e.onBlocked?.();return}}n()};return{get location(){return t},get length(){return e.getLength()},subscribers:n,subscribe:e=>(n.add(e),()=>{n.delete(e)}),push:(n,i,o)=>{let s=t.state[zr];i=Ur(s+1,i),a({task:()=>{e.pushState(n,i),r({type:`PUSH`})},navigateOpts:o,type:`PUSH`,path:n,state:i})},replace:(n,i,o)=>{let s=t.state[zr];i=Ur(s,i),a({task:()=>{e.replaceState(n,i),r({type:`REPLACE`})},navigateOpts:o,type:`REPLACE`,path:n,state:i})},go:(t,n)=>{a({task:()=>{e.go(t),i({type:`GO`,index:t})},navigateOpts:n,type:`GO`})},back:t=>{a({task:()=>{e.back(t?.ignoreBlocker??!1),i({type:`BACK`})},navigateOpts:t,type:`BACK`})},forward:t=>{a({task:()=>{e.forward(t?.ignoreBlocker??!1),i({type:`FORWARD`})},navigateOpts:t,type:`FORWARD`})},canGoBack:()=>t.state[zr]!==0,createHref:t=>e.createHref(t),block:t=>{if(!e.setBlockers)return()=>{};let n=e.getBlockers?.()??[];return e.setBlockers([...n,t]),()=>{let n=e.getBlockers?.()??[];e.setBlockers?.(n.filter(e=>e!==t))}},flush:()=>e.flush?.(),destroy:()=>e.destroy?.(),notify:r}}function Ur(e,t){t||={};let n=qr();return{...t,key:n,__TSR_key:n,[zr]:e}}function Wr(e){let t=e?.window??(typeof document<`u`?window:void 0),n=t.history.pushState,r=t.history.replaceState,i=[],a=()=>i,o=e=>i=e,s=e?.createHref??(e=>e),c=e?.parseLocation??(()=>Kr(`${t.location.pathname}${t.location.search}${t.location.hash}`,t.history.state));if(!t.history.state?.__TSR_key&&!t.history.state?.key){let e=qr();t.history.replaceState({[zr]:0,key:e,__TSR_key:e},``)}let l=c(),u,d=!1,f=!1,p=!1,m=!1,h=()=>l,g,_,v=()=>{g&&(C._ignoreSubscribers=!0,(g.isPush?t.history.pushState:t.history.replaceState)(g.state,``,g.href),C._ignoreSubscribers=!1,g=void 0,_=void 0,u=void 0)},y=(e,t,n)=>{let r=s(t);_||(u=l),l=Kr(t,n),g={href:r,state:n,isPush:g?.isPush||e===`push`},_||=Promise.resolve().then(()=>v())},b=e=>{l=c(),C.notify({type:e})},x=async()=>{if(f){f=!1;return}let e=c(),n=e.state[zr]-l.state[zr],r=n===1,i=n===-1,o=!r&&!i||d;d=!1;let s=o?`GO`:i?`BACK`:`FORWARD`,u=o?{type:`GO`,index:n}:{type:i?`BACK`:`FORWARD`};if(p)p=!1;else{let n=a();if(typeof document<`u`&&n.length){for(let r of n)if(await r.blockerFn({currentLocation:l,nextLocation:e,action:s})){f=!0,t.history.go(1),C.notify(u);return}}}l=c(),C.notify(u)},S=e=>{if(m){m=!1;return}let t=!1,n=a();if(typeof document<`u`&&n.length)for(let e of n){let n=e.enableBeforeUnload??!0;if(n===!0){t=!0;break}if(typeof n==`function`&&n()===!0){t=!0;break}}if(t)return e.preventDefault(),e.returnValue=``},C=Hr({getLocation:h,getLength:()=>t.history.length,pushState:(e,t)=>y(`push`,e,t),replaceState:(e,t)=>y(`replace`,e,t),back:e=>(e&&(p=!0),m=!0,t.history.back()),forward:e=>{e&&(p=!0),m=!0,t.history.forward()},go:e=>{d=!0,t.history.go(e)},createHref:e=>s(e),flush:v,destroy:()=>{t.history.pushState=n,t.history.replaceState=r,t.removeEventListener(Vr,S,{capture:!0}),t.removeEventListener(Br,x)},onBlocked:()=>{u&&l!==u&&(l=u)},getBlockers:a,setBlockers:o,notifyOnIndexChange:!1});return t.addEventListener(Vr,S,{capture:!0}),t.addEventListener(Br,x),t.history.pushState=function(...e){let r=n.apply(t.history,e);return C._ignoreSubscribers||b(`PUSH`),r},t.history.replaceState=function(...e){let n=r.apply(t.history,e);return C._ignoreSubscribers||b(`REPLACE`),n},C}function Gr(e){let t=e.replace(/[\x00-\x1f\x7f]/g,``);return t.startsWith(`//`)&&(t=`/`+t.replace(/^\/+/,``)),t}function Kr(e,t){let n=Gr(e),r=n.indexOf(`#`),i=n.indexOf(`?`),a=qr();return{href:n,pathname:n.substring(0,r>0?i>0?Math.min(r,i):r:i>0?i:n.length),hash:r>-1?n.substring(r):``,search:i>-1?n.slice(i,r===-1?void 0:r):``,state:t||{[zr]:0,key:a,__TSR_key:a}}}function qr(){return(Math.random()+1).toString(36).substring(7)}function Jr(e,t){let n=t,r=e;return{fromLocation:n,toLocation:r,pathChanged:n?.pathname!==r.pathname,hrefChanged:n?.href!==r.href,hashChanged:n?.hash!==r.hash}}var Yr=class{constructor(e,t){this.tempLocationKey=`${Math.round(Math.random()*1e7)}`,this._scroll={next:!0},this.shouldViewTransition=void 0,this.isViewTransitionTypesSupported=void 0,this.subscribers=new Set,this.routeBranchCache=new WeakMap,this.lightweightCache=new WeakMap,this.startTransition=e=>e(),this.update=e=>{let t=this.options,n=this.basepath??t?.basepath??`/`,r=this.basepath===void 0,i=t?.rewrite;if(this.options={...t,...e},this.isServer=this.options.isServer??typeof document>`u`,this.protocolAllowlist=new Set(this.options.protocolAllowlist),this.options.pathParamsAllowedCharacters&&(this.pathParamsDecoder=In(this.options.pathParamsAllowedCharacters)),(!this.history||this.options.history&&this.options.history!==this.history)&&(this.options.history?this.history=this.options.history:this.history=Wr()),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 e;this.resolvePathCache=nn(1e3),e=this.buildRouteTree(),this.setRoutes(e)}if(!this.stores&&this.latestLocation){let e=this.getStoreConfig(this);this.batch=e.batch,this.stores=mr(Qr(this.latestLocation),e),$n(this)}let a=!1,o=this.options.basepath??`/`,s=this.options.rewrite;if(r||n!==o||i!==s){this.basepath=o;let e=[],t=Mn(o);t&&t!==`/`&&e.push(dr({basepath:o})),s&&e.push(s),this.rewrite=e.length===0?void 0:e.length===1?e[0]:ur(e),this.history&&this.updateLatestLocation(),a=!0}a&&this.stores&&this.stores.location.set(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=()=>{let e=vn(this.routeTree,this.options.caseSensitive,(e,t)=>{e.init({originalIndex:t})});return this.options.routeMasks&&pn(this.options.routeMasks,e.processedTree),e},this.subscribe=(e,t)=>{let n={eventType:e,fn:t};return this.subscribers.add(n),()=>{this.subscribers.delete(n)}},this.emit=e=>{this.subscribers.forEach(t=>{t.eventType===e.type&&t.fn(e)})},this.parseLocation=(e,t)=>{let n=({pathname:e,search:n,hash:r,href:i,state:a})=>{if(!this.rewrite&&!/[ \x00-\x1f\x7f\u0080-\uffff]/.test(e)){let i=this.options.parseSearch(n),o=this.options.stringifySearch(i);return{href:e+o+r,publicHref:e+o+r,pathname:Qt(e).path,external:!1,searchStr:o,search:Rt(t?.search,i),hash:Qt(r.slice(1)).path,state:zt(t?.state,a)}}let o=new URL(i,this.origin),s=fr(this.rewrite,o),c=this.options.parseSearch(s.search),l=this.options.stringifySearch(c);return s.search=l,{href:s.href.replace(s.origin,``),publicHref:i,pathname:Qt(s.pathname).path,external:!!this.rewrite&&s.origin!==this.origin,searchStr:l,search:Rt(t?.search,c),hash:Qt(s.hash.slice(1)).path,state:zt(t?.state,a)}},r=n(e),{__tempLocation:i,__tempKey:a}=r.state;if(i&&(!a||a===this.tempLocationKey)){let e=n(i);return e.state.key=r.state.key,e.state.__TSR_key=r.state.__TSR_key,delete e.state.__tempLocation,{...e,maskedLocation:r}}return r},this.resolvePathWithBase=(e,t)=>Fn({base:e,to:t.includes(`//`)?kn(t):t,trailingSlash:this.options.trailingSlash,cache:this.resolvePathCache}),this.matchRoutes=(e,t,n)=>typeof e==`string`?this.matchRoutesInternal({pathname:e,search:t},n):this.matchRoutesInternal(e,t),this.getMatchedRoutes=e=>ei({pathname:e,routesById:this.routesById,processedTree:this.processedTree}),this.cancelMatch=e=>{let t=this.getMatch(e);t&&(t.abortController.abort(),clearTimeout(t._nonReactive.pendingTimeout),t._nonReactive.pendingTimeout=void 0)},this.cancelMatches=()=>{this.stores.pendingIds.get().forEach(e=>{this.cancelMatch(e)}),this.stores.matchesId.get().forEach(e=>{if(this.stores.pendingMatchStores.has(e))return;let t=this.stores.matchStores.get(e)?.get();t&&(t.status===`pending`||t.isFetching===`loader`)&&this.cancelMatch(e)})},this.buildLocation=e=>{let t=(t={})=>{let n=t._fromLocation||this.pendingBuiltLocation||this.latestLocation,r=this.matchRoutesLightweight(n);t.from;let i=t.unsafeRelative===`path`?n.pathname:t.from??r.fullPath,a=t.to?`${t.to}`:void 0,o=r.search,s=Object.assign(Object.create(null),r.params),c=a?.charCodeAt(0)===47?`/`:this.resolvePathWithBase(i,`.`),l=a?this.resolvePathWithBase(c,a):c,u=t.params===!1||t.params===null?Object.create(null):(t.params??!0)===!0?s:Object.assign(s,Nt(t.params,s)),d=this.routesByPath[jn(l)],f;if(d)f=this.getRouteBranch(d);else if(l.includes(`$`))f=[];else{let e=this.getMatchedRoutes(l);f=e.matchedRoutes,this.options.notFoundRoute&&(!e.foundRoute||e.foundRoute.path!==`/`&&e.routeParams[`**`])&&(f=[...f,this.options.notFoundRoute])}if(f.length&&It(u))for(let e of f){let t=e.options.params?.stringify??e.options.stringifyParams;if(t)try{Object.assign(u,t(u))}catch{}}let p=e.leaveParams?l:Qt(Rn({path:l,params:u,decoder:this.pathParamsDecoder,server:this.isServer}).interpolatedPath).path,m=o;if(e._includeValidateSearch&&this.options.search?.strict){let e={};f.forEach(t=>{if(t.options.validateSearch)try{Object.assign(e,$r(t.options.validateSearch,{...e,...m}))}catch{}}),m=e}m=ti({search:m,dest:t,destRoutes:f,_includeValidateSearch:e._includeValidateSearch}),m=Rt(o,m);let h=this.options.stringifySearch(m),g=t.hash===!0?n.hash:t.hash?Nt(t.hash,n.hash):void 0,_=g?`#${g}`:``,v=t.state===!0?n.state:t.state?Nt(t.state,n.state):{};v=zt(n.state,v);let y=`${p}${h}${_}`,b,x,S=!1;if(this.rewrite){let e=new URL(y,this.origin),t=pr(this.rewrite,e);b=e.href.replace(e.origin,``),t.origin===this.origin?x=t.pathname+t.search+t.hash:(x=t.href,S=!0)}else b=$t(y),x=b;return{publicHref:x,href:b,pathname:p,search:m,searchStr:h,state:v,hash:g??``,external:S,unmaskOnReload:t.unmaskOnReload}},n=(n={},r)=>{let i=t(n),a=r?t(r):void 0;if(!a){let n=Object.create(null);if(this.options.routeMasks){let o=mn(i.pathname,this.processedTree);if(o){Object.assign(n,o.rawParams);let{from:i,params:s,...c}=o.route,l=s===!1||s===null?Object.create(null):(s??!0)===!0?n:Object.assign(n,Nt(s,n));r={from:e.from,...c,params:l},a=t(r)}}}return a&&(i.maskedLocation=a),i};return e.mask?n(e,{from:e.from,...e.mask}):n(e)},this.commitLocation=async({viewTransition:e,ignoreBlocker:t,...n})=>{let r,i=()=>{let e=[`key`,`__TSR_key`,`__TSR_index`,`__hashScrollIntoViewOptions`];e.forEach(e=>{n.state[e]=this.latestLocation.state[e]});let t=Wt(n.state,this.latestLocation.state);return e.forEach(e=>{delete n.state[e]}),t},a=jn(this.latestLocation.href)===jn(n.href),o=this.commitLocationPromise;if(this.commitLocationPromise=Gt(()=>{o?.resolve(),o=void 0}),a&&i())this.load();else{let{maskedLocation:i,hashScrollIntoView:a,...o}=n;i&&(o={...i,state:{...i.state,__tempKey:void 0,__tempLocation:{...o,search:o.searchStr,state:{...o.state,__tempKey:void 0,__tempLocation:void 0,__TSR_key:void 0,key:void 0}}}},(o.unmaskOnReload??this.options.unmaskOnReload??!1)&&(o.state.__tempKey=this.tempLocationKey)),o.state.__hashScrollIntoViewOptions=a??this.options.defaultHashScrollIntoView??!0,this.shouldViewTransition=e,r=n.replace?`REPLACE`:`PUSH`,this.history[r===`REPLACE`?`replace`:`push`](o.publicHref,o.state,{ignoreBlocker:t})}return this._scroll.next=n.resetScroll??!0,this.history.subscribers.size||this.load(r?{action:{type:r}}:void 0),this.commitLocationPromise},this.buildAndCommitLocation=({replace:e,resetScroll:t,hashScrollIntoView:n,viewTransition:r,ignoreBlocker:i,href:a,...o}={})=>{if(a){let t=this.history.location.state.__TSR_index,n=Kr(a,{__TSR_index:e?t:t+1}),r=new URL(n.pathname,this.origin);o.to=fr(this.rewrite,r).pathname,o.search=this.options.parseSearch(n.search),o.hash=n.hash.slice(1)}let s=this.buildLocation({...o,_includeValidateSearch:!0});this.pendingBuiltLocation=s;let c=this.commitLocation({...s,viewTransition:r,replace:e,resetScroll:t,hashScrollIntoView:n,ignoreBlocker:i});return queueMicrotask(()=>{this.pendingBuiltLocation===s&&(this.pendingBuiltLocation=void 0)}),c},this.navigate=async({to:e,reloadDocument:t,href:n,publicHref:r,...i})=>{let a=!1;if(n)try{new URL(`${n}`),a=!0}catch{}if(a&&!t&&(t=!0),t){if(e!==void 0||!n){let t=this.buildLocation({to:e,...i});n??=t.publicHref,r??=t.publicHref}let t=!a&&r?r:n;if(Zt(t,this.protocolAllowlist))return;if(!i.ignoreBlocker){let e=this.history.getBlockers?.()??[];for(let t of e)if(t?.blockerFn&&await t.blockerFn({currentLocation:this.latestLocation,nextLocation:this.latestLocation,action:`PUSH`}))return}i.replace?window.location.replace(t):window.location.href=t;return}return this.buildAndCommitLocation({...i,href:n,to:e,_isNavigate:!0})},this.beforeLoad=()=>{this.cancelMatches(),this.updateLatestLocation();let e=this.matchRoutes(this.latestLocation),t=this.stores.cachedMatches.get().filter(t=>!e.some(e=>e.id===t.id));this.batch(()=>{this.stores.status.set(`pending`),this.stores.statusCode.set(200),this.stores.isLoading.set(!0),this.stores.location.set(this.latestLocation),this.stores.setPending(e),this.stores.setCached(t)})},this.load=async e=>{let t=e?.action?.type,n,r,i,a=this.stores.resolvedLocation.get()??this.stores.location.get();for(i=new Promise(o=>{this.startTransition(async()=>{try{this.beforeLoad(),t&&(this._scroll.hash=t===`PUSH`||t===`REPLACE`);let n=this.latestLocation,r=Jr(n,this.stores.resolvedLocation.get());this.stores.redirect.get()||this.emit({type:`onBeforeNavigate`,...r}),this.emit({type:`onBeforeLoad`,...r}),await Pr({router:this,sync:e?.sync,forceStaleReload:a.href===n.href,matches:this.stores.pendingMatches.get(),location:n,updateMatch:this.updateMatch,onReady:async()=>{this.startTransition(()=>{this.startViewTransition(async()=>{let e=null,t=null,n=null,r=null;this.batch(()=>{let i=this.stores.pendingMatches.get(),a=i.length,o=this.stores.matches.get();e=a?o.filter(e=>!this.stores.pendingMatchStores.has(e.id)):null;let s=new Set;for(let e of this.stores.pendingMatchStores.values())e.routeId&&s.add(e.routeId);let c=new Set;for(let e of this.stores.matchStores.values())e.routeId&&c.add(e.routeId);t=a?o.filter(e=>!s.has(e.routeId)):null,n=a?i.filter(e=>!c.has(e.routeId)):null,r=a?i.filter(e=>c.has(e.routeId)):o,this.stores.isLoading.set(!1),this.stores.loadedAt.set(Date.now()),a&&(this.stores.setMatches(i),this.stores.setPending([]),this.stores.setCached([...this.stores.cachedMatches.get(),...e.filter(e=>e.status!==`error`&&e.status!==`notFound`&&e.status!==`redirected`)]),this.clearExpiredCache())});for(let[e,i]of[[t,`onLeave`],[n,`onEnter`],[r,`onStay`]])if(e)for(let t of e)this.looseRoutesById[t.routeId].options[i]?.(t)})})}})}catch(e){lr(e)?(n=e,this.navigate({...n.options,replace:!0,ignoreBlocker:!0})):Y(e)&&(r=e);let t=n?n.status:r?404:this.stores.matches.get().some(e=>e.status===`error`)?500:200;this.batch(()=>{this.stores.statusCode.set(t),this.stores.redirect.set(n)})}this.latestLoadPromise===i&&(this.commitLocationPromise?.resolve(),this.latestLoadPromise=void 0,this.commitLocationPromise=void 0),o()})}),this.latestLoadPromise=i,await i;this.latestLoadPromise&&i!==this.latestLoadPromise;)await this.latestLoadPromise;let o;this.hasNotFoundMatch()?o=404:this.stores.matches.get().some(e=>e.status===`error`)&&(o=500),o!==void 0&&this.stores.statusCode.set(o)},this.startViewTransition=e=>{let t=this.shouldViewTransition??this.options.defaultViewTransition;if(this.shouldViewTransition=void 0,t&&typeof document<`u`&&`startViewTransition`in document&&typeof document.startViewTransition==`function`){let n;if(typeof t==`object`&&this.isViewTransitionTypesSupported){let r=this.latestLocation,i=this.stores.resolvedLocation.get(),a=typeof t.types==`function`?t.types(Jr(r,i)):t.types;if(a===!1){e();return}n={update:e,types:a}}else n=e;document.startViewTransition(n)}else e()},this.updateMatch=(e,t)=>{this.startTransition(()=>{let n=this.stores.pendingMatchStores.get(e);if(n){n.set(t);return}let r=this.stores.matchStores.get(e);if(r){r.set(t);return}let i=this.stores.cachedMatchStores.get(e);if(i){let n=t(i.get());n.status===`redirected`?this.stores.cachedMatchStores.delete(e)&&this.stores.cachedIds.set(t=>t.filter(t=>t!==e)):i.set(n)}})},this.getMatch=e=>this.stores.cachedMatchStores.get(e)?.get()??this.stores.pendingMatchStores.get(e)?.get()??this.stores.matchStores.get(e)?.get(),this.invalidate=e=>{let t=t=>e?.filter?.(t)??!0?{...t,invalid:!0,...e?.forcePending||t.status===`error`||t.status===`notFound`?{status:`pending`,error:void 0}:void 0}:t;return this.batch(()=>{this.stores.setMatches(this.stores.matches.get().map(t)),this.stores.setCached(this.stores.cachedMatches.get().map(t)),this.stores.setPending(this.stores.pendingMatches.get().map(t))}),this.shouldViewTransition=!1,this.load({sync:e?.sync})},this.getParsedLocationHref=e=>e.publicHref||`/`,this.resolveRedirect=e=>{let t=e.headers.get(`Location`);if(!e.options.href||e.options._builtLocation){let t=e.options._builtLocation??this.buildLocation(e.options),n=this.getParsedLocationHref(t);e.options.href=n,e.headers.set(`Location`,n)}else if(t)try{let n=new URL(t);if(this.origin&&n.origin===this.origin){let t=n.pathname+n.search+n.hash;e.options.href=t,e.headers.set(`Location`,t)}}catch{}if(e.options.href&&!e.options._builtLocation&&Zt(e.options.href,this.protocolAllowlist))throw Error(`Redirect blocked: unsafe protocol`);return e.headers.get(`Location`)||e.headers.set(`Location`,e.options.href),e},this.clearCache=e=>{let t=e?.filter;t===void 0?this.stores.setCached([]):this.stores.setCached(this.stores.cachedMatches.get().filter(e=>!t(e)))},this.clearExpiredCache=()=>{let e=Date.now();this.clearCache({filter:t=>{let n=this.looseRoutesById[t.routeId];if(!n.options.loader)return!0;let r=(t.preload?n.options.preloadGcTime??this.options.defaultPreloadGcTime:n.options.gcTime??this.options.defaultGcTime)??300*1e3;return t.status===`error`||e-t.updatedAt>=r}})},this.loadRouteChunk=Ir,this.preloadRoute=async e=>{let t=e._builtLocation??this.buildLocation(e),n=this.matchRoutes(t,{throwOnError:!0,preload:!0,dest:e}),r=new Set([...this.stores.matchesId.get(),...this.stores.pendingIds.get()]),i=new Set([...r,...this.stores.cachedIds.get()]),a=n.filter(e=>!i.has(e.id));if(a.length){let e=this.stores.cachedMatches.get();this.stores.setCached([...e,...a])}try{return n=await Pr({router:this,matches:n,location:t,preload:!0,updateMatch:(e,t)=>{r.has(e)?n=n.map(n=>n.id===e?t(n):n):this.updateMatch(e,t)}}),n}catch(e){if(lr(e))return e.options.reloadDocument?void 0:await this.preloadRoute({...e.options,_fromLocation:t});Y(e)||console.error(e);return}},this.matchRoute=(e,t)=>{let n={...e,to:e.to?this.resolvePathWithBase(e.from||``,e.to):void 0,params:e.params||{},leaveParams:!0},r=this.buildLocation(n);if(t?.pending&&this.stores.status.get()!==`pending`)return!1;let i=(t?.pending===void 0?!this.stores.isLoading.get():t.pending)?this.latestLocation:this.stores.resolvedLocation.get()||this.stores.location.get(),a=hn(r.pathname,t?.caseSensitive??!1,t?.fuzzy??!1,i.pathname,this.processedTree);return!a||e.params&&!Wt(a.rawParams,e.params,{partial:!0})?!1:t?.includeSearch??!0?Wt(i.search,r.search,{partial:!0})?a.rawParams:!1:a.rawParams},this.hasNotFoundMatch=()=>this.stores.matches.get().some(e=>e.status===`notFound`||e.globalNotFound),this.getStoreConfig=t,this.update({defaultPreloadDelay:50,defaultPendingMs:1e3,defaultPendingMinMs:500,context:void 0,...e,caseSensitive:e.caseSensitive??!1,notFoundMode:e.notFoundMode??`fuzzy`,stringifySearch:e.stringifySearch??ir,parseSearch:e.parseSearch??rr,protocolAllowlist:e.protocolAllowlist??Xt}),typeof document<`u`&&(self.__TSR_ROUTER__=this)}isShell(){return!!this.options.isShell}isPrerendering(){return!!this.options.isPrerendering}get state(){return this.stores.__store.get()}setRoutes({routesById:e,routesByPath:t,processedTree:n}){this.routesById=e,this.routesByPath=t,this.processedTree=n;let r=this.options.notFoundRoute;r&&(r.init({originalIndex:99999999999}),this.routesById[r.id]=r)}getRouteBranch(e){let t=this.routeBranchCache.get(e);return t||(t=xn(e),this.routeBranchCache.set(e,t)),t}get looseRoutesById(){return this.routesById}getParentContext(e){return e?.id?e.context??this.options.context??void 0:this.options.context??void 0}matchRoutesInternal(e,t){let n=this.getMatchedRoutes(e.pathname),{foundRoute:r,routeParams:i}=n,{matchedRoutes:a}=n,o=!1;(r?r.path!==`/`&&i[`**`]:jn(e.pathname))&&(this.options.notFoundRoute?a=[...a,this.options.notFoundRoute]:o=!0);let s=o?ri(this.options.notFoundMode,a):void 0,c=Array(a.length),l=new Map;for(let e of this.stores.matchStores.values())e.routeId&&l.set(e.routeId,e.get());for(let n=0;n<a.length;n++){let r=a[n],o=c[n-1],u,d,f;{let n=o?.search??e.search,i=o?._strictSearch??void 0;try{let e=$r(r.options.validateSearch,{...n})??void 0;u={...n,...e},d={...i,...e},f=void 0}catch(e){let r=e;if(e instanceof Xr||(r=new Xr(e.message,{cause:e})),t?.throwOnError)throw r;u=n,d={},f=r}}let p=r.options.loaderDeps?.({search:u})??``,m=p?JSON.stringify(p):``,{interpolatedPath:h,usedParams:g}=Rn({path:r.fullPath,params:i,decoder:this.pathParamsDecoder,server:this.isServer}),_=r.id+h+m,v=this.getMatch(_),y=l.get(r.id),b=v?._strictParams??g,x;if(!v)try{ii(r,b)}catch(e){if(x=Y(e)||lr(e)?e:new Zr(e.message,{cause:e}),t?.throwOnError)throw x}Object.assign(i,b);let S=y?`stay`:`enter`,C;if(v)C={...v,cause:S,params:y?.params??i,_strictParams:b,search:Rt(y?y.search:v.search,u),_strictSearch:d};else{let e=r.options.loader||r.options.beforeLoad||r.lazyFn||Lr(r)?`pending`:`success`;C={id:_,ssr:r.options.ssr,index:n,routeId:r.id,params:y?.params??i,_strictParams:b,pathname:h,updatedAt:Date.now(),search:y?Rt(y.search,u):u,_strictSearch:d,searchError:void 0,status:e,isFetching:!1,error:void 0,paramsError:x,__routeContext:void 0,_nonReactive:{loadPromise:Gt()},__beforeLoadContext:void 0,context:{},abortController:new AbortController,fetchCount:0,cause:S,loaderDeps:y?zt(y.loaderDeps,p):p,invalid:!1,preload:!1,links:void 0,scripts:void 0,headScripts:void 0,meta:void 0,staticData:r.options.staticData||{},fullPath:r.fullPath}}t?.preload||(C.globalNotFound=s===r.id),C.searchError=f;let w=this.getParentContext(o);C.context={...w,...C.__routeContext,...C.__beforeLoadContext},c[n]=C}for(let t=0;t<c.length;t++){let n=c[t],r=this.looseRoutesById[n.routeId],a=this.getMatch(n.id),o=l.get(n.routeId);if(n.params=o?Rt(o.params,i):i,!a){let i=c[t-1],a=this.getParentContext(i);if(r.options.context){let t={deps:n.loaderDeps,params:n.params,context:a??{},location:e,navigate:t=>this.navigate({...t,_fromLocation:e}),buildLocation:this.buildLocation,cause:n.cause,abortController:n.abortController,preload:!!n.preload,matches:c,routeId:r.id};n.__routeContext=r.options.context(t)??void 0}n.context={...a,...n.__routeContext,...n.__beforeLoadContext}}}return c}matchRoutesLightweight(e){let t=jt(this.stores.matchesId.get()),n=this.lightweightCache.get(e);if(n&&n[0]===t)return n[1];let{matchedRoutes:r,routeParams:i}=this.getMatchedRoutes(e.pathname),a=jt(r),o={...e.search};for(let e of r)try{Object.assign(o,$r(e.options.validateSearch,o))}catch{}let s=t&&this.stores.matchStores.get(t)?.get(),c=s&&s.routeId===a.id&&s.pathname===e.pathname,l;if(c)l=s.params;else{let e=Object.assign(Object.create(null),i);for(let t of r)try{ii(t,e)}catch{}l=e}let u={matchedRoutes:r,fullPath:a.fullPath,search:o,params:l};return this.lightweightCache.set(e,[t,u]),u}},Xr=class extends Error{},Zr=class extends Error{};function Qr(e){return{loadedAt:0,isLoading:!1,isTransitioning:!1,status:`idle`,resolvedLocation:void 0,location:e,matches:[],statusCode:200}}function $r(e,t){if(e==null)return{};if(`~standard`in e){let n=e[`~standard`].validate(t);if(n instanceof Promise)throw new Xr(`Async validation not supported`);if(n.issues)throw new Xr(JSON.stringify(n.issues,void 0,2),{cause:n});return n.value}return`parse`in e?e.parse(t):typeof e==`function`?e(t):{}}function ei({pathname:e,routesById:t,processedTree:n}){let r=Object.create(null),i=jn(e),a,o=gn(i,n,!0);return o&&(a=o.route,Object.assign(r,o.rawParams)),{matchedRoutes:o?.branch||[t.__root__],routeParams:r,foundRoute:a}}function ti({search:e,dest:t,destRoutes:n,_includeValidateSearch:r}){return ni(n)(e,t,r??!1)}function ni(e){let t,n,r=[];for(let t of e){let e=t.options;`search`in e?e.search?.middlewares&&r.push(...e.search.middlewares):(e.preSearchFilters||e.postSearchFilters)&&r.push(({search:t,next:n})=>{let r=n(e.preSearchFilters?e.preSearchFilters.reduce((e,t)=>t(e),t):t);return e.postSearchFilters?e.postSearchFilters.reduce((e,t)=>t(e),r):r});let i=e.validateSearch;i&&r.push(({search:e,next:t,meta:r})=>{let a=t(e);if(n)try{let e=$r(i,a);if(r&&e)for(let t in e)t in a||(r.defaulted||=new Map).set(t,e[t]);return{...a,...e}}catch{}return a})}let i=(e,n,a)=>{if(e>=r.length){if(!t.search)return{};if(t.search===!0)return n;let e=Nt(t.search,n);return a&&(a.explicit=e),e}return r[e]({search:n,next:(t,n)=>{if(n){let n=a||{};return{search:i(e+1,t,n),meta:n}}return i(e+1,t,a)},meta:a})};return function(e,r,a){return t=r,n=a,i(0,e)}}function ri(e,t){if(e!==`root`)for(let e=t.length-1;e>=0;e--){let n=t[e];if(n.children)return n.id}return sr}function ii(e,t){let n=e.options.params?.parse??e.options.parseParams;if(n){let e=n(t);if(e===!1)throw Error(`Route params.parse returned false for a matched route`);Object.assign(t,e)}}var ai=`Error preloading route! ☝️`,oi=class{get to(){return this._to}get id(){return this._id}get path(){return this._path}get fullPath(){return this._fullPath}constructor(e){if(this.init=e=>{this.originalIndex=e.originalIndex;let t=this.options,n=!t?.path&&!t?.id;this.parentRoute=this.options.getParentRoute?.(),n?this._path=sr:this.parentRoute||tn();let r=n?sr:t?.path;r&&r!==`/`&&(r=An(r));let i=t?.id||r,a=n?sr:On([this.parentRoute.id===`__root__`?``:this.parentRoute.id,i]);r===`__root__`&&(r=`/`),a!==`__root__`&&(a=On([`/`,a]));let o=a===`__root__`?`/`:On([this.parentRoute.fullPath,r]);this._path=r,this._id=a,this._fullPath=o,this._to=jn(o)},this.addChildren=e=>this._addFileChildren(e),this._addFileChildren=e=>(Array.isArray(e)&&(this.children=e),typeof e==`object`&&e&&(this.children=Object.values(e)),this),this._addFileTypes=()=>this,this.updateLoader=e=>(Object.assign(this.options,e),this),this.update=e=>(Object.assign(this.options,e),this),this.lazy=e=>(this.lazyFn=e,this),this.redirect=e=>cr({from:this.fullPath,...e}),this.options=e||{},this.isRoot=!e?.getParentRoute,e?.id&&e?.path)throw Error(`Route cannot have both an 'id' and a 'path' option.`)}},si=class extends oi{constructor(e){super(e)}},X=a();function ci(e){let t=e.errorComponent??ui;return(0,X.jsx)(li,{getResetKey:e.getResetKey,onCatch:e.onCatch,children:({error:n,reset:r})=>n?J.createElement(t,{error:n,reset:r}):e.children})}var li=class extends J.Component{constructor(...e){super(...e),this.state={error:null}}static getDerivedStateFromProps(e,t){let n=e.getResetKey();return t.error&&t.resetKey!==n?{resetKey:n,error:null}:{resetKey:n}}static getDerivedStateFromError(e){return{error:e}}reset(){this.setState({error:null})}componentDidCatch(e,t){this.props.onCatch&&this.props.onCatch(e,t)}render(){return this.props.children({error:this.state.error,reset:()=>{this.reset()}})}};function ui({error:e}){let[t,n]=J.useState(!1);return(0,X.jsxs)(`div`,{style:{padding:`.5rem`,maxWidth:`100%`},children:[(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`.5rem`},children:[(0,X.jsx)(`strong`,{style:{fontSize:`1rem`},children:`Something went wrong!`}),(0,X.jsx)(`button`,{style:{appearance:`none`,fontSize:`.6em`,border:`1px solid currentColor`,padding:`.1rem .2rem`,fontWeight:`bold`,borderRadius:`.25rem`},onClick:()=>n(e=>!e),children:t?`Hide Error`:`Show Error`})]}),(0,X.jsx)(`div`,{style:{height:`.25rem`}}),t?(0,X.jsx)(`div`,{children:(0,X.jsx)(`pre`,{style:{fontSize:`.7em`,border:`1px solid red`,borderRadius:`.25rem`,padding:`.3rem`,color:`red`,overflow:`auto`},children:e.message?(0,X.jsx)(`code`,{children:e.message}):null})}):null]})}function di({children:e,fallback:t=null}){return fi()?(0,X.jsx)(J.Fragment,{children:e}):(0,X.jsx)(J.Fragment,{children:t})}function fi(){return J.useSyncExternalStore(pi,()=>!0,()=>!1)}function pi(){return()=>{}}var mi=J.createContext(null);function hi(e){return J.useContext(mi)}var gi=J.createContext(void 0),_i=J.createContext(void 0),Z=(e=>(e[e.None=0]=`None`,e[e.Mutable=1]=`Mutable`,e[e.Watching=2]=`Watching`,e[e.RecursedCheck=4]=`RecursedCheck`,e[e.Recursed=8]=`Recursed`,e[e.Dirty=16]=`Dirty`,e[e.Pending=32]=`Pending`,e))(Z||{});function vi({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&60?a&12?a&4?!(a&48)&&c(e,i)?(i.flags=a|40,a&=1):a=0:i.flags=a&-9|32:a=0:i.flags=a|32,a&2&&t(i),a&1){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0){n=e.nextSub;continue}for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}while(!0)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&16)a=!0;else if((c&17)==17){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&33)==33){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=-33;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(!0)}function s(e){do{let n=e.sub,r=n.flags;(r&48)==32&&(n.flags=r|16,(r&6)==2&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function yi(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var bi=[],xi=0,{link:Si,unlink:Ci,propagate:wi,checkDirty:Ti,shallowPropagate:Ei}=vi({update(e){return e._update()},notify(e){bi[Oi++]=e,e.flags&=~Z.Watching},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=Z.Mutable|Z.Dirty,Mi(e))}}),Di=0,Oi=0,ki,Ai=0;function ji(e){try{++Ai,e()}finally{--Ai||Ni()}}function Mi(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=Ci(n,e)}function Ni(){if(!(Ai>0)){for(;Di<Oi;){let e=bi[Di];bi[Di++]=void 0,e.notify()}Di=0,Oi=0}}function Pi(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:n?Z.None:Z.Mutable,get(){return ki!==void 0&&Si(i,ki,xi),i._snapshot},subscribe(e){let t=yi(e),n={current:!1},r=Fi(()=>{i.get(),n.current?t.next?.(i._snapshot):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=ki,o=t?.compare??Object.is;if(n)ki=i,++xi,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=Z.Mutable|Z.RecursedCheck);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{ki=a,n&&(i.flags&=~Z.RecursedCheck),Mi(i)}}};return n?(i.flags=Z.Mutable|Z.Dirty,i.get=function(){let e=i.flags;if(e&Z.Dirty||e&Z.Pending&&Ti(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&Ei(e)}}else e&Z.Pending&&(i.flags=e&~Z.Pending);return ki!==void 0&&Si(i,ki,xi),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(wi(e),Ei(e),Ni())}},i}function Fi(e){let t=()=>{let t=ki;ki=n,++xi,n.depsTail=void 0,n.flags=Z.Watching|Z.RecursedCheck;try{return e()}finally{ki=t,n.flags&=~Z.RecursedCheck,Mi(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:Z.Watching|Z.RecursedCheck,notify(){let e=this.flags;e&Z.Dirty||e&Z.Pending&&Ti(this.deps,this)?t():this.flags=Z.Watching},stop(){this.flags=Z.None,this.depsTail=void 0,Mi(this)}};return t(),n}var Ii=t((e=>{var t=n(),r=h();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=r.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),Li=t(((e,t)=>{t.exports=Ii()}))();function Ri(e,t){return e===t}function zi(e,t,n=Ri){let r=(0,J.useCallback)(t=>{if(!e)return()=>{};let{unsubscribe:n}=e.subscribe(t);return n},[e]),i=(0,J.useCallback)(()=>e?.get(),[e]);return(0,Li.useSyncExternalStoreWithSelector)(r,i,i,t,n)}var Bi={get(){},subscribe(){return{unsubscribe(){}}}};function Vi(e,t){let n=J.useRef();return r=>{let i=e?.select?e.select(r):r;return e?.structuralSharing??t.options.defaultStructuralSharing?n.current=zt(n.current,i):i}}function Hi(e){let t=hi(),n=J.useContext(e.from?_i:gi),r=e.from?t.stores.getRouteMatchStore(e.from):t.stores.matchStores.get(n),i=Vi(e,t),a=zi(r??Bi,e=>e?i(e):Bi);if(a!==Bi)return a;(e.shouldThrow??!0)&&tn()}function Ui(e){return Hi({from:e.from,strict:e.strict,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.loaderData):t.loaderData})}function Wi(e){let{select:t,...n}=e;return Hi({...n,select:e=>t?t(e.loaderDeps):e.loaderDeps})}function Gi(e){return Hi({from:e.from,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,strict:e.strict,select:t=>{let n=e.strict===!1?t.params:t._strictParams;return e.select?e.select(n):n}})}function Ki(e){return Hi({from:e.from,strict:e.strict,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.search):t.search})}function qi(e){let t=hi();return J.useCallback(n=>t.navigate({...n,from:n.from??e?.from}),[e?.from,t])}function Ji(e){return Hi({...e,select:t=>e.select?e.select(t.context):t.context})}var Yi=e(i(),1);function Xi(e,t){let n=hi(),r=At(t),{activeProps:i,inactiveProps:a,activeOptions:o,to:s,preload:c,preloadDelay:l,preloadIntentProximity:u,hashScrollIntoView:d,replace:f,startTransition:p,resetScroll:m,viewTransition:h,children:g,target:_,disabled:v,style:y,className:b,onClick:x,onBlur:S,onFocus:C,onMouseEnter:w,onMouseLeave:T,onTouchStart:E,ignoreBlocker:D,params:O,search:k,hash:A,state:j,mask:M,reloadDocument:N,unsafeRelative:P,from:F,_fromLocation:I,...L}=e,R=fi(),z=J.useMemo(()=>e,[n,e.from,e._fromLocation,e.hash,e.to,e.search,e.params,e.state,e.mask,e.unsafeRelative]),B=zi(n.stores.location,e=>e,(e,t)=>e.href===t.href),V=J.useMemo(()=>{let e={_fromLocation:B,...z};return n.buildLocation(e)},[n,B,z]),H=V.maskedLocation?V.maskedLocation.publicHref:V.publicHref,ee=V.maskedLocation?V.maskedLocation.external:V.external,te=J.useMemo(()=>aa(H,ee,n.history,v),[v,ee,H,n.history]),ne=J.useMemo(()=>{if(te?.external)return Zt(te.href,n.protocolAllowlist)?void 0:te.href;if(!oa(s)&&!(typeof s!=`string`||s.indexOf(`:`)===-1))try{return new URL(s),Zt(s,n.protocolAllowlist)?void 0:s}catch{}},[s,te,n.protocolAllowlist]),re=J.useMemo(()=>{if(ne)return!1;if(o?.exact){if(!Pn(B.pathname,V.pathname,n.basepath))return!1}else{let e=Nn(B.pathname,n.basepath),t=Nn(V.pathname,n.basepath);if(!(e.startsWith(t)&&(e.length===t.length||e[t.length]===`/`)))return!1}return(o?.includeSearch??!0)&&!Wt(B.search,V.search,{partial:!o?.exact,ignoreUndefined:!o?.explicitUndefined})?!1:!o?.includeHash||R&&B.hash===V.hash},[o?.exact,o?.explicitUndefined,o?.includeHash,o?.includeSearch,B,ne,R,V.hash,V.pathname,V.search,n.basepath]),U=re?Nt(i,{})??Qi:Zi,ie=re?Zi:Nt(a,{})??Zi,ae=[b,U.className,ie.className].filter(Boolean).join(` `),oe=(y||U.style||ie.style)&&{...y,...U.style,...ie.style},[se,ce]=J.useState(!1),le=J.useRef(!1),W=e.reloadDocument||ne?!1:c??n.options.defaultPreload,ue=l??n.options.defaultPreloadDelay??0,G=J.useCallback(()=>{n.preloadRoute({...z,_builtLocation:V}).catch(e=>{console.warn(e),console.warn(ai)})},[n,z,V]);kt(r,J.useCallback(e=>{e?.isIntersecting&&G()},[G]),ra,{disabled:!!v||W!==`viewport`}),J.useEffect(()=>{le.current||!v&&W===`render`&&(G(),le.current=!0)},[v,G,W]);let de=e=>{let t=e.currentTarget.getAttribute(`target`),r=_===void 0?t:_;if(!v&&!ca(e)&&!e.defaultPrevented&&(!r||r===`_self`)&&e.button===0){e.preventDefault(),(0,Yi.flushSync)(()=>{ce(!0)});let t=n.subscribe(`onResolved`,()=>{t(),ce(!1)});n.navigate({...z,replace:f,resetScroll:m,hashScrollIntoView:d,startTransition:p,viewTransition:h,ignoreBlocker:D})}};if(ne)return{...L,ref:r,href:ne,...g&&{children:g},..._&&{target:_},...v&&{disabled:v},...y&&{style:y},...b&&{className:b},...x&&{onClick:x},...S&&{onBlur:S},...C&&{onFocus:C},...w&&{onMouseEnter:w},...T&&{onMouseLeave:T},...E&&{onTouchStart:E}};let fe=e=>{if(v||W!==`intent`)return;if(!ue){G();return}let t=e.currentTarget;if(na.has(t))return;let n=setTimeout(()=>{na.delete(t),G()},ue);na.set(t,n)},pe=e=>{v||W!==`intent`||G()},me=e=>{if(v||!W||!ue)return;let t=e.currentTarget,n=na.get(t);n&&(clearTimeout(n),na.delete(t))};return{...L,...U,...ie,href:te?.href,ref:r,onClick:ia([x,de]),onBlur:ia([S,me]),onFocus:ia([C,fe]),onMouseEnter:ia([w,fe]),onMouseLeave:ia([T,me]),onTouchStart:ia([E,pe]),disabled:!!v,target:_,...oe&&{style:oe},...ae&&{className:ae},...v&&$i,...re&&ea,...R&&se&&ta}}var Zi={},Qi={className:`active`},$i={role:`link`,"aria-disabled":!0},ea={"data-status":`active`,"aria-current":`page`},ta={"data-transitioning":`transitioning`},na=new WeakMap,ra={rootMargin:`100px`},ia=e=>t=>{for(let n of e)if(n){if(t.defaultPrevented)return;n(t)}};function aa(e,t,n,r){if(!r)return t?{href:e,external:!0}:{href:n.createHref(e)||`/`,external:!1}}function oa(e){if(typeof e!=`string`)return!1;let t=e.charCodeAt(0);return t===47?e.charCodeAt(1)!==47:t===46}var sa=J.forwardRef((e,t)=>{let{_asChild:n,...r}=e,{type:i,...a}=Xi(r,t),o=typeof r.children==`function`?r.children({isActive:a[`data-status`]===`active`}):r.children;if(!n){let{disabled:e,...t}=a;return J.createElement(`a`,t,o)}return J.createElement(n,a,o)});function ca(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}var la=class extends oi{constructor(e){super(e),this.useMatch=e=>Hi({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>Ji({...e,from:this.id}),this.useSearch=e=>Ki({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>Gi({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>Wi({...e,from:this.id}),this.useLoaderData=e=>Ui({...e,from:this.id}),this.useNavigate=()=>qi({from:this.fullPath}),this.Link=J.forwardRef((e,t)=>(0,X.jsx)(sa,{ref:t,from:this.fullPath,...e}))}};function ua(e){return new la(e)}var da=class extends si{constructor(e){super(e),this.useMatch=e=>Hi({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>Ji({...e,from:this.id}),this.useSearch=e=>Ki({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>Gi({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>Wi({...e,from:this.id}),this.useLoaderData=e=>Ui({...e,from:this.id}),this.useNavigate=()=>qi({from:this.fullPath}),this.Link=J.forwardRef((e,t)=>(0,X.jsx)(sa,{ref:t,from:this.fullPath,...e}))}};function fa(e){return new da(e)}function pa(e){let t=hi(),n=`not-found-${zi(t.stores.location,e=>e.pathname)}-${zi(t.stores.status,e=>e)}`;return(0,X.jsx)(ci,{getResetKey:()=>n,onCatch:(t,n)=>{if(Y(t))e.onCatch?.(t,n);else throw t},errorComponent:({error:t})=>{if(Y(t))return e.fallback?.(t);throw t},children:e.children})}function ma(){return(0,X.jsx)(`p`,{children:`Not Found`})}function ha(e){return(0,X.jsx)(X.Fragment,{children:e.children})}function ga(e,t,n){return t.options.notFoundComponent?(0,X.jsx)(t.options.notFoundComponent,{...n}):e.options.defaultNotFoundComponent?(0,X.jsx)(e.options.defaultNotFoundComponent,{...n}):(0,X.jsx)(ma,{})}var _a=(e,t)=>e.routeId===t.routeId&&e._displayPending===t._displayPending,va=(e,t)=>e[0]===t[0]&&e[1]===t[1],ya=J.memo(function({matchId:e}){let t=hi(),n=t.stores.matchStores.get(e);n||tn();let r=zi(t.stores.loadedAt,e=>e),i=zi(n,e=>e,_a);return(0,X.jsx)(ba,{router:t,matchId:e,resetKey:r,matchState:J.useMemo(()=>{let e=i.routeId,n=t.routesById[e].parentRoute?.id;return{routeId:e,ssr:i.ssr,_displayPending:i._displayPending,parentRouteId:n}},[i._displayPending,i.routeId,i.ssr,t.routesById])})});function ba({router:e,matchId:t,resetKey:n,matchState:r}){let i=e.routesById[r.routeId],a=i.options.pendingComponent??e.options.defaultPendingComponent,o=a?(0,X.jsx)(a,{}):null,s=i.options.errorComponent??e.options.defaultErrorComponent,c=i.options.onCatch??e.options.defaultOnCatch,l=i.isRoot?i.options.notFoundComponent??e.options.notFoundRoute?.options.component:i.options.notFoundComponent,u=r.ssr===!1||r.ssr===`data-only`,d=(!i.isRoot||i.options.wrapInSuspense||u)&&(i.options.wrapInSuspense??a??(i.options.errorComponent?.preload||u))?J.Suspense:ha,f=s?ci:ha,p=l?pa:ha;return(0,X.jsxs)(i.isRoot?i.options.shellComponent??ha:ha,{children:[(0,X.jsx)(gi.Provider,{value:t,children:(0,X.jsx)(d,{fallback:o,children:(0,X.jsx)(f,{getResetKey:()=>n,errorComponent:s||ui,onCatch:(e,t)=>{if(Y(e))throw e.routeId??=r.routeId,e;c?.(e,t)},children:(0,X.jsx)(p,{fallback:e=>{if(e.routeId??=r.routeId,!l||e.routeId&&e.routeId!==r.routeId||!e.routeId&&!i.isRoot)throw e;return J.createElement(l,e)},children:u||r._displayPending?(0,X.jsx)(di,{fallback:o,children:(0,X.jsx)(Sa,{matchId:t})}):(0,X.jsx)(Sa,{matchId:t})})})})}),r.parentRouteId===`__root__`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(xa,{}),(e.options.scrollRestoration,null)]}):null]})}function xa(){let e=hi(),t=J.useRef();return Dt(()=>{let n=e.stores.resolvedLocation.get(),r=t.current;n&&(!r||r.href!==n.href)&&e.emit({type:`onRendered`,...Jr(e.stores.location.get(),r??n)}),t.current=n},[zi(e.stores.resolvedLocation,e=>e?.state.__TSR_key),e]),null}var Sa=J.memo(function({matchId:e}){let t=hi(),n=(e,n)=>t.getMatch(e.id)?._nonReactive[n]??e._nonReactive[n],r=t.stores.matchStores.get(e);r||tn();let i=zi(r,e=>e),a=i.routeId,o=t.routesById[a],s=J.useMemo(()=>{let e=(t.routesById[a].options.remountDeps??t.options.defaultRemountDeps)?.({routeId:a,loaderDeps:i.loaderDeps,params:i._strictParams,search:i._strictSearch});return e?JSON.stringify(e):void 0},[a,i.loaderDeps,i._strictParams,i._strictSearch,t.options.defaultRemountDeps,t.routesById]),c=J.useMemo(()=>{let e=o.options.component??t.options.defaultComponent;return e?(0,X.jsx)(e,{},s):(0,X.jsx)(Ca,{})},[s,o.options.component,t.options.defaultComponent]);if(i._displayPending)throw n(i,`displayPendingPromise`);if(i._forcePending)throw n(i,`minPendingPromise`);if(i.status===`pending`){let e=o.options.pendingMinMs??t.options.defaultPendingMinMs;if(e){let n=t.getMatch(i.id);if(n&&!n._nonReactive.minPendingPromise){let t=Gt();n._nonReactive.minPendingPromise=t,setTimeout(()=>{t.resolve(),n._nonReactive.minPendingPromise=void 0},e)}}throw n(i,`loadPromise`)}if(i.status===`notFound`)return Y(i.error)||tn(),ga(t,o,i.error);if(i.status===`redirected`)throw lr(i.error)||tn(),n(i,`loadPromise`);if(i.status===`error`)throw i.error;return c}),Ca=J.memo(function(){let e=hi(),t=J.useContext(gi),n,r=!1,i;{let a=t?e.stores.matchStores.get(t):void 0;[n,r]=zi(a,e=>[e?.routeId,e?.globalNotFound??!1],va),i=zi(e.stores.matchesId,e=>e[e.findIndex(e=>e===t)+1])}let a=n?e.routesById[n]:void 0,o=e.options.defaultPendingComponent?(0,X.jsx)(e.options.defaultPendingComponent,{}):null;if(r)return a||tn(),ga(e,a,void 0);if(!i)return null;let s=(0,X.jsx)(ya,{matchId:i});return n===`__root__`?(0,X.jsx)(J.Suspense,{fallback:o,children:s}):s});function wa(){let e=hi(),t=J.useRef({router:e,mounted:!1}),[n,r]=J.useState(!1),i=zi(e.stores.isLoading,e=>e),a=zi(e.stores.hasPending,e=>e),o=Ot(i),s=i||n||a,c=Ot(s),l=i||a,u=Ot(l);return e.startTransition=e=>{r(!0),J.startTransition(()=>{e(),r(!1)})},J.useEffect(()=>{let t=e.history.subscribe(e.load),n=e.buildLocation({to:e.latestLocation.pathname,search:!0,params:!0,hash:!0,state:!0,_includeValidateSearch:!0});return jn(e.latestLocation.publicHref)!==jn(n.publicHref)&&e.commitLocation({...n,replace:!0}),()=>{t()}},[e,e.history]),Dt(()=>{typeof window<`u`&&e.ssr||t.current.router===e&&t.current.mounted||(t.current={router:e,mounted:!0},(async()=>{try{await e.load()}catch(e){console.error(e)}})())},[e]),Dt(()=>{o&&!i&&e.emit({type:`onLoad`,...Jr(e.stores.location.get(),e.stores.resolvedLocation.get())})},[o,e,i]),Dt(()=>{u&&!l&&e.emit({type:`onBeforeRouteMount`,...Jr(e.stores.location.get(),e.stores.resolvedLocation.get())})},[l,u,e]),Dt(()=>{if(c&&!s){let t=Jr(e.stores.location.get(),e.stores.resolvedLocation.get());e.emit({type:`onResolved`,...t}),ji(()=>{e.stores.status.set(`idle`),e.stores.resolvedLocation.set(e.stores.location.get())})}},[s,c,e]),null}function Ta(){let e=hi(),t=e.routesById.__root__.options.pendingComponent??e.options.defaultPendingComponent,n=t?(0,X.jsx)(t,{}):null,r=(0,X.jsxs)(typeof document<`u`&&e.ssr?ha:J.Suspense,{fallback:n,children:[(0,X.jsx)(wa,{}),(0,X.jsx)(Ea,{})]});return e.options.InnerWrap?(0,X.jsx)(e.options.InnerWrap,{children:r}):r}function Ea(){let e=hi(),t=zi(e.stores.firstId,e=>e),n=zi(e.stores.loadedAt,e=>e),r=t?(0,X.jsx)(ya,{matchId:t}):null;return(0,X.jsx)(gi.Provider,{value:t,children:e.options.disableGlobalCatchBoundary?r:(0,X.jsx)(ci,{getResetKey:()=>n,errorComponent:ui,onCatch:void 0,children:r})})}var Da=e=>({createMutableStore:Pi,createReadonlyStore:Pi,batch:ji}),Oa=e=>new ka(e),ka=class extends Yr{constructor(e){super(e,Da)}};function Aa({router:e,children:t,...n}){It(n)&&e.update({...e.options,...n,context:{...e.options.context,...n.context}});let r=(0,X.jsx)(mi.Provider,{value:e,children:t});return e.options.Wrap?(0,X.jsx)(e.options.Wrap,{children:r}):r}function ja({router:e,...t}){return(0,X.jsx)(Aa,{router:e,...t,children:(0,X.jsx)(Ta,{})})}function Ma(e){let t=hi({warn:e?.router===void 0}),n=e?.router||t;return zi(n.stores.__store,Vi(e,n))}function Na(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Pa(e,t,n){let r=e.slice(0);return r[t]=n,r}var Fa=class extends Ee{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,U.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!we(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Na(e,n).forEach(e=>{e.destroy()}),Na(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=Oe(this.#a,t(e))),this.#a}return e}#f(){return this.#r?.combine!==void 0&&this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new Ae(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Pa(this.#t,n,t),this.#h())}#h(){if(this.hasListeners()){let e=this.#u(this.#t,this.#l),t=this.#f(),n=this.#a,r=t?n:this.#d(e,this.#r?.combine);(t||n!==r)&&U.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},Ia=class extends Ee{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??ue(r,t),a=this.get(i);return a||(a=new B({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){U.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>ce(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>ce(e,t)):t}notify(e){U.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){U.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){U.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},La=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Ia,this.#t=e.mutationCache||new Be,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=xe.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=te.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(ye(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=Se(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return U.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;U.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return U.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=U.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(R).catch(R)}invalidateQueries(e,t={}){return U.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=U.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(R)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(R)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(ye(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(R).catch(R)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(R).catch(R)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return te.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(re(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{me(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(re(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{me(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=ue(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===fe&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};function Ra({queries:e,...t},n){let r=le(n),i=ne(),a=ee(),o=J.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{_e(e);let t=r.getQueryCache().get(e.queryHash);ae(e,a,t)}),se(a);let[s]=J.useState(()=>new Fa(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),d=!i&&t.subscribed!==!1;J.useSyncExternalStore(J.useCallback(e=>d?s.subscribe(U.batchCalls(e)):R,[s,d]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),J.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let f=c.some((e,t)=>ge(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&ge(n,e)?z(n,new Ae(r,n),a):[]}):[];if(f.length>0)throw Promise.all(f);let p=c.find((e,t)=>{let n=o[t];return n&&oe({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(p?.error)throw p.error;return l(u())}function za(e){return e}var Ba=r();function Va(e=K){return V({queryFn:({signal:t})=>e.getAppInfo({signal:t}),queryKey:[`app-info`],staleTime:5*6e4})}function Ha(e=K,t=!1){return V({enabled:t,queryFn:({signal:t})=>e.getAppUpdateProgress({signal:t}),queryKey:[`app-update`,`progress`],refetchInterval:t?250:!1})}function Ua(e=K){return H({mutationFn:t=>e.installAppUpdate(t),mutationKey:[`app-update`,`install`],scope:{id:`app-update`}})}var Wa={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,"!doctype":!0,"!DOCTYPE":!0},Ga=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?("[^"]*"|'[^']*')/g;function Ka(e){let t={type:`tag`,name:``,voidElement:!1,attrs:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(Wa[n[1]]||e.charAt(e.length-2)===`/`)&&(t.voidElement=!0),t.name.startsWith(`!--`))){let t=e.indexOf(`-->`);return{type:`comment`,comment:t===-1?``:e.slice(4,t)}}let r=new RegExp(Ga),i=null;for(;i=r.exec(e),i!==null;)if(i[0].trim())if(i[1]){let e=i[1].trim(),n=[e,null],a=e.indexOf(`=`);a>-1&&(n=[e.slice(0,a),e.slice(a+1)]),t.attrs[n[0]]=n[1],r.lastIndex--}else i[2]&&(t.attrs[i[2]]=i[3].trim().substring(1,i[3].length-1));return t}var qa=/<!--[\s\S]*?-->|<[a-zA-Z0-9\-!/](?:"[^"]*"|'[^']*'|[^'">])*>/g,Ja=/<\/?([^\s]+?)[/\s>]/,Ya=/^\s*$/,Xa=/^(script|style)$/i,Za=`\0`,Qa=Object.create(null);function $a(e){e.forEach(function(e){if(e.type===`text`){e.content=e.content.split(Za).join(`<`);return}if(e.type===`comment`){e.comment=e.comment.split(Za).join(`<`);return}for(let t in e.attrs){let n=e.attrs[t];typeof n==`string`&&n.indexOf(Za)>-1&&(e.attrs[t]=n.split(Za).join(`<`))}e.children.length&&$a(e.children)})}function eo(e,t){let n=t&&t.components||Qa,r=t&&t.allowedTags,i=!1;if(r){let t=typeof r==`function`?r:function(e){return r.indexOf(e)>-1},n=``,a=0;qa.lastIndex=0;let o;for(;o=qa.exec(e);){let r=o[0];n+=e.slice(a,o.index);let s=r.match(Ja);r.startsWith(`<!--`)||s&&t(s[1])?(n+=r,a=o.index+r.length):(i=!0,n+=Za,a=o.index+1,qa.lastIndex=a)}e=n+e.slice(a)}let a=[],o=[],s,c=-1,l=!1,u=0,d;if(e.indexOf(`<`)!==0){let t=e.indexOf(`<`);a.push({type:`text`,content:t===-1?e:e.substring(0,t)})}let f=[],p;for(;p=qa.exec(e);)f.push(p);return f.forEach(function(e,t){let n=e[0];if(!n||n.startsWith(`<!--`))return;let r=0,i=0,a=-1,o=null;for(let e=0;e<n.length;e++){let t=n.charAt(e);o?t===o&&(o=null):t===`"`||t===`'`?o=t:t===`<`?(r++,r===2&&(a=e)):t===`>`&&i++}let s=a>-1&&/[a-zA-Z0-9\-!/]/.test(n.charAt(a+1));if(r>i&&s){let e=n.substring(0,a),r=n.substring(e.length);f[t][0]=r,f[t].index+=e.length}}),f.forEach(function(t,r){let i=t[0];if(!i)return;let p=t.index;if(p<u)return;if(l){if(i!==`</`+s.name+`>`)return;l=!1}let m=i.charAt(1)!==`/`,h=i.startsWith(`<!--`),g=p+i.length,_=e.charAt(g),v=f[r+1],y;if(_===`<`&&v){let t=e.substring(g,v.index);y=t.split(`<`).length>t.split(`>`).length}let b;if(h){let t=Ka(i);if(c<0)return a.push(t),a;b=o[c],b.children.push(t);let n=e.slice(g,v?v.index:void 0);return n.length>0&&b.children.push({type:`text`,content:n}),a}if(m){c++,s=Ka(i),s.type===`tag`&&n[s.name]&&(s.type=`component`,l=!0);let t=!1;if(!l&&!s.voidElement&&Xa.test(s.name)){t=!0,d||=e.toLowerCase();let n=d.indexOf(`</`+s.name.toLowerCase()+`>`,g),r=n===-1?e.length:n,i=e.slice(g,r);i&&s.children.push({type:`text`,content:i}),u=r}!s.voidElement&&!l&&!t&&_&&_!==`<`&&s.children.push({type:`text`,content:e.slice(g,v?v.index:void 0)}),c===0&&a.push(s),b=o[c-1],b&&b.children.push(s),o[c]=s}if((!m||s.voidElement)&&(c>-1&&(s.voidElement||s.name===i.slice(2,-1))&&(c--,s=c===-1?a:o[c]),!l&&(_!==`<`||y)&&_)){b=c===-1?a:o[c].children;let t=v?v.index:-1,n=e.slice(g,t===-1?void 0:t);Ya.test(n)&&(n=` `),(t>-1&&c+b.length>=0||n!==` `)&&b.push({type:`text`,content:n})}}),i&&$a(a),a}function to(e){let t=[];for(let n in e)e[n]===null?t.push(n):t.push(n+`="`+String(e[n]).replace(/"/g,`"`)+`"`);return t.length?` `+t.join(` `):``}function no(e,t){switch(t.type){case`text`:return e+t.content;case`tag`:{let n=t.voidElement&&t.name.toLowerCase()!==`!doctype`?`/>`:`>`;return e+=`<`+t.name+(t.attrs?to(t.attrs):``)+n,t.voidElement?e:e+t.children.reduce(no,``)+`</`+t.name+`>`}case`comment`:return e+=`<!--`+t.comment+`-->`,e}}function ro(e){return e.reduce(function(e,t){return e+no(``,t)},``)}var io={parse:eo,stringify:ro},ao=(e,t)=>{if(!e)return!1;let n=e.props?.children??e.children;return t?n.length>0:!!n},oo=e=>{if(!e)return[];let t=e.props?.children??e.children;return e.props?.i18nIsDynamicList?co(t):t},so=e=>Array.isArray(e)&&e.every(J.isValidElement),co=e=>Array.isArray(e)?e:[e],lo=(e,t)=>{let n={...t};return n.props={...t.props,...e.props},n},uo=e=>{let t={};if(!e)return t;let n=e=>{co(e).forEach(e=>{f(e)||(ao(e)?n(oo(e)):d(e)&&!(0,J.isValidElement)(e)&&Object.assign(t,e))})};return n(e),t},fo=(e,t,n,r)=>{if(!e)return``;let i=``,a=co(e),o=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return a.forEach((e,a)=>{if(f(e)){i+=`${e}`;return}if((0,J.isValidElement)(e)){let{props:s,type:c}=e,l=Object.keys(s).length,u=o.indexOf(c)>-1,d=s.children;if(!d&&u&&!l){i+=`<${c}/>`;return}if(!d&&(!u||l)||s.i18nIsDynamicList){i+=`<${a}></${a}>`;return}if(u&&l<=1){let e=f(d)?d:fo(d,t,n,r);i+=`<${c}>${e}</${c}>`;return}let p=fo(d,t,n,r);i+=`<${a}>${p}</${a}>`;return}if(e===null){m(n,`TRANS_NULL_VALUE`,`Passed in a null value as child`,{i18nKey:r});return}if(d(e)){let{format:t,...a}=e,o=Object.keys(a);if(o.length===1){let e=t?`${o[0]}, ${t}`:o[0];i+=`{{${e}}}`;return}m(n,`TRANS_INVALID_OBJ`,`Invalid child - Object should only have keys {{ value, format }} (format is optional).`,{i18nKey:r,child:e});return}m(n,`TRANS_INVALID_VAR`,`Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`,{i18nKey:r,child:e})}),i},po=(e,t,n,r,i,a,s)=>{if(n===``)return[];let c=i.transKeepBasicHtmlNodesFor||[],l=n&&new RegExp(c.map(e=>`<${e}`).join(`|`)).test(n);if(!e&&!t&&!l&&!s)return[n];let u=t??{},p=e=>{co(e).forEach(e=>{f(e)||(ao(e)?p(oo(e)):d(e)&&!(0,J.isValidElement)(e)&&Object.assign(u,e))})};p(e);let m=Object.keys(u),h=io.parse(`<0>${n}</0>`,{allowedTags:e=>/^\d+$/.test(e)||c.indexOf(e)>-1||m.indexOf(e)>-1}),g={...u,...a},_=(e,t,n)=>{let r=oo(e),i=y(r,t.children,n);return so(r)&&i.length===0||e.props?.i18nIsDynamicList?r:i},v=(e,t,n,r,i)=>{e.dummy?(e.children=t,n.push((0,J.cloneElement)(e,{key:r},i?void 0:t))):n.push(...J.Children.map([e],e=>{if(e.type===J.Fragment||e.props?.i18nIsDynamicList!==void 0){let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t===`children`||t===`i18nIsDynamicList`||(n[t]=e.props[t])}),(0,J.createElement)(e.type,n,i?null:t)}let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t===`ref`||t===`children`||(n[t]=e.props[t])}),(0,J.cloneElement)(e,n,i?null:t)}))},y=(e,n,a)=>{let u=co(e),p=co(n),m={};return p.reduce((e,n,p)=>{let h=n.children?.[0]?.content&&r.services.interpolator.interpolate(n.children[0].content,g,r.language);if(n.type===`tag`){let o=u[parseInt(n.name,10)];!o&&t&&(o=t[n.name]),a.length===1&&!o&&(o=a[0][n.name]),o||={};let b={...n.attrs};s&&Object.keys(b).forEach(e=>{let t=b[e];f(t)&&(b[e]=w(t))});let x=Object.keys(b).length===0?o:lo({props:b},o),S=(0,J.isValidElement)(x),C=S&&ao(n,!0)&&!n.voidElement,T=l&&d(x)&&x.dummy&&!S,E=d(t)&&Object.hasOwnProperty.call(t,n.name);if(f(x)){let t=r.services.interpolator.interpolate(x,g,r.language);e.push(t)}else if(ao(x)||C){let t=_(x,n,a);v(x,t,e,p)}else if(T){let t=y(u,n.children,a);v(x,t,e,p)}else if(Number.isNaN(parseFloat(n.name)))if(E){let t=_(x,n,a);v(x,t,e,p,n.voidElement)}else if(i.transSupportBasicHtmlNodes&&c.indexOf(n.name)>-1)if(n.voidElement)e.push((0,J.createElement)(n.name,{key:`${n.name}-${p}`}));else{let t=m[n.name]||0;m[n.name]=t+1;let r,i=0;for(let e=0;e<u.length;e+=1){let a=u[e];if((0,J.isValidElement)(a)&&a.type===n.name){if(i===t){r=a;break}i+=1}}let o=r?co(oo(r)):u,s=y(o,n.children,a);e.push((0,J.createElement)(n.name,{key:`${n.name}-${p}`},s))}else if(n.voidElement)e.push(`<${n.name} />`);else{let t=y(u,n.children,a);e.push(`<${n.name}>${t}</${n.name}>`)}else if(d(x)&&!S){let t=n.children[0]?h:null;t&&e.push(t)}else v(x,h,e,p,n.children.length!==1||!h)}else if(n.type===`text`){let t=i.transWrapTextNodes,a=typeof i.unescape==`function`?i.unescape:o().unescape,c=s?a(r.services.interpolator.interpolate(n.content,g,r.language)):r.services.interpolator.interpolate(n.content,g,r.language);t?e.push((0,J.createElement)(t,{key:`${n.name}-${p}`},c)):e.push(c)}return e},[])};return oo(y([{dummy:!0,children:e||[]}],h,co(e||[]))[0])},mo=(e,t,n)=>{let r=e.key||t,i=(0,J.cloneElement)(e,{key:r});if(!i.props||!i.props.children||n.indexOf(`${t}/>`)<0&&n.indexOf(`${t} />`)<0)return i;function a(){return(0,J.createElement)(J.Fragment,null,i)}return(0,J.createElement)(a,{key:r})},ho=(e,t)=>e.map((e,n)=>mo(e,n,t)),go=(e,t)=>{let n={};return Object.keys(e).forEach(r=>{Object.assign(n,{[r]:mo(e[r],r,t)})}),n},_o=(e,t,n,r)=>e?Array.isArray(e)?ho(e,t):d(e)?go(e,t):(c(n,`TRANS_INVALID_COMPONENTS`,`<Trans /> "components" prop expects an object or array`,{i18nKey:r}),null):null,vo=e=>!d(e)||Array.isArray(e)?!1:Object.keys(e).reduce((e,t)=>e&&Number.isNaN(Number.parseFloat(t)),!0);function yo({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a={},values:s,defaults:l,components:d,ns:p,i18n:m,t:h,shouldUnescape:g,..._}){let v=m||T();if(!v)return c(v,`NO_I18NEXT_INSTANCE`,`Trans: You need to pass in an i18next instance using initReactI18next or by passing it via props or context. In monorepo setups, make sure there is only one instance of react-i18next.`,{i18nKey:r}),e;let y=h||v.t.bind(v)||(e=>e),b={...o(),...v.options?.react},x=p||y.ns||v.options?.defaultNS;x=f(x)?[x]:x||[`translation`];let{transDefaultProps:S}=b,C=S?.tOptions?{...S.tOptions,...a}:a,w=g??S?.shouldUnescape,E=S?.values?{...S.values,...s}:s,D=S?.components?{...S.components,...d}:d,O=fo(e,b,v,r),k=l||C?.defaultValue||O||b.transEmptyNodeValue||(typeof r==`function`?u(r):r),{hashTransKey:A}=b,j=r||(A?A(O||k):O||k);s=v.options?.interpolation?.defaultVariables?E&&Object.keys(E).length>0?{...E,...v.options.interpolation.defaultVariables}:{...v.options.interpolation.defaultVariables}:E;let M=uo(e);M&&typeof M.count==`number`&&t===void 0&&(t=M.count);let N=s||t!==void 0&&!v.options?.interpolation?.alwaysFormat||!e?C.interpolation:{interpolation:{...C.interpolation,prefix:`#$?`,suffix:`?$#`}},P={...C,context:i||C.context,count:t,...s,...N,defaultValue:k,ns:x},F=j?y(j,P):k;F===j&&k&&(F=k);let I=_o(D,F,v,r),L=I||e,R=null;vo(I)&&(R=I,L=e);let z=po(L,R,F,v,b,P,w),B=n??b.defaultTransParent;return B?(0,J.createElement)(B,_,z):z}function bo({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a={},values:o,defaults:s,components:c,ns:l,i18n:u,t:d,shouldUnescape:f,...m}){let{i18n:h,defaultNS:g}=(0,J.useContext)(p)||{},_=u||h||T(),v=d||_?.t.bind(_);return yo({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a,values:o,defaults:s,components:c,ns:l||v?.ns||g||_?.options?.defaultNS,i18n:_,t:d,shouldUnescape:f,...m})}function xo({i18n:e,defaultNS:t,children:n}){let r=(0,J.useMemo)(()=>({i18n:e,defaultNS:t}),[e,t]);return(0,J.createElement)(p.Provider,{value:r},n)}function So(e,t,n){return e.invalidateQueries({exact:!0,queryKey:ke(t,n)})}function Co(e){let t=new Map;for(let n of e?.pages??[])for(let e of n.data)t.has(e.id)||t.set(e.id,e);return[...t.values()]}function wo(e,t){if(e===void 0)return{data:[t],nextCursor:null};let n=e.data.findIndex(e=>e.id===t.id);return n<0?{...e,data:[...e.data,t]}:{...e,data:e.data.map((e,r)=>r===n?t:e)}}function To(e,t){if(e===void 0||e.pages.length===0)return{pageParams:[void 0],pages:[{data:[t],nextCursor:null}]};let n=e.pages.map(e=>({...e,data:e.data.filter(e=>e.id!==t.id)})),r=n[0];return{...e,pages:[{...r,data:[t,...r?.data??[]],nextCursor:r?.nextCursor??null},...n.slice(1)]}}function Eo(e,t){return e===void 0?{pageParams:[void 0],pages:[{data:[t],nextCursor:null}]}:{...e,pages:e.pages.map(e=>({...e,data:e.data.map(e=>e.id===t.id?t:e)}))}}function Do(e,t){e.setQueryData([`projects`,t.projectId,`tasks`],e=>Eo(e,t)),e.setQueryData([`projects`,t.projectId,`tasks`,be],e=>e===void 0?void 0:t.pinned?[t,...e.filter(e=>e.id!==t.id)]:e.filter(e=>e.id!==t.id)),e.setQueryData([`projects`,t.projectId,`tasks`,Te],e=>e?.map(e=>e.id===t.id?t:e))}function Oo(e,t={}){if(t.assistantReplyStarted===!0||e.turns.some(e=>e.items.some(e=>e.type===`message`&&e.role===`assistant`))){if(e.title!==`新聊天`)return e.title;for(let t of e.turns)for(let e of t.items){if(e.type!==`message`||e.role!==`user`)continue;let t=e.text.trim().split(/\r?\n/u)[0]?.trim();if(t)return t;let n=e.skills?.[0]?.name;if(n!==void 0)return n;let r=e.attachments?.[0]?.name;if(r!==void 0)return r}return l.t(`taskTitle.replying`,{ns:`conversation`})}}function ko(e,t,n={}){if(e===void 0)return;let r=e.pages.map(e=>{let r=Ao(e.data,t,n);return r===e.data?e:{...e,data:r}});return r.some((t,n)=>t!==e.pages[n])?{...e,pages:r}:e}function Ao(e,t,n={}){let r=Oo(t,n);if(r===void 0)return e;let i=e.findIndex(e=>e.id===t.id&&e.projectId===t.projectId&&e.title===`新聊天`);return i<0?e:e.map((e,n)=>n===i?{...e,title:r,updatedAt:t.updatedAt}:e)}function jo(e,t,n){e.setQueryData([`projects`,t.projectId,`tasks`],e=>ko(e,t,n));for(let r of[be,Te])e.setQueryData([`projects`,t.projectId,`tasks`,r],e=>e===void 0?void 0:Ao(e,t,n))}function Mo(e,t){if(e!==void 0)return{...e,pages:e.pages.map(e=>({...e,data:e.data.filter(e=>e.id!==t)}))}}async function No(e,t,n,r){let i=new Map,a=new Set,o;for(;;){let s={...o===void 0?{}:{cursor:o},limit:100,...n},c=r===void 0?await t.listTasks(e,s):await t.listTasks(e,s,{signal:r});for(let e of c.data)i.has(e.id)||i.set(e.id,e);if(c.nextCursor===null||a.has(c.nextCursor))return[...i.values()];a.add(c.nextCursor),o=c.nextCursor}}function Po(e,t,n){return No(e,t,{},n)}function Fo(e,t,n){return No(e,t,{pinned:!0},n)}function Io(e,t=K){return V({queryFn:({signal:n})=>Fo(e,t,n),queryKey:[`projects`,e,`tasks`,be]})}function Lo(e,t,n=K){return V({enabled:t,queryFn:({signal:t})=>Po(e,n,t),queryKey:[`projects`,e,`tasks`,Te]})}async function Ro(e,t,n){let r=[`projects`,t,`tasks`];e.setQueryData(r,e=>Mo(e,n)),e.setQueryData([...r,be],e=>e?.filter(e=>e.id!==n)),e.setQueryData([...r,Te],e=>e?.filter(e=>e.id!==n)),await e.invalidateQueries({exact:!0,queryKey:r})}function zo(e,t){if(e===void 0||e.data.length!==t.length||new Set(t).size!==t.length)return;let n=new Map(e.data.map(e=>[e.id,e])),r=t.flatMap(e=>{let t=n.get(e);return t===void 0?[]:[t]});if(r.length===e.data.length)return{...e,data:r}}function Bo(e=K){return H({mutationFn:({pinned:t,projectId:n,taskId:r})=>e.pinTask(n,r,t),mutationKey:[`tasks`,`pin`]})}function Vo(e=K){return H({mutationFn:({projectId:t,taskId:n,title:r})=>e.renameTask(t,n,r),mutationKey:[`tasks`,`rename`]})}function Ho(e=K){return H({mutationFn:({projectId:t,taskId:n})=>e.archiveTask(t,n),mutationKey:[`tasks`,`archive`]})}function Uo(e=K){return H({mutationFn:({projectId:t,taskId:n})=>e.unarchiveTask(t,n),mutationKey:[`tasks`,`unarchive`]})}function Wo(e=K){return H({mutationFn:({projectId:t,taskId:n})=>e.deleteTask(t,n),mutationKey:[`tasks`,`delete`]})}function Go(e=K){return H({mutationFn:({name:t,projectId:n})=>e.renameProject(n,t),mutationKey:[`projects`,`rename`],scope:{id:`projects:actions`}})}function Ko(e=K){return H({mutationFn:t=>e.removeProject(t),mutationKey:[`projects`,`remove`],scope:{id:`projects:actions`}})}function qo(e=K){return V({queryFn:({signal:t})=>e.getCapabilities({signal:t}),queryKey:[`capabilities`]})}function Jo(e=K){return V({queryFn:({signal:t})=>e.listModels({signal:t}),queryKey:[`models`],staleTime:5*6e4})}function Yo(e=K){return V({queryFn:({signal:t})=>e.getGlobalSettings({signal:t}),queryKey:[`settings`]})}function Xo(e=K){return H({mutationFn:t=>e.updateGlobalSettings(t),mutationKey:[`settings`,`update`],scope:{id:`global-settings`}})}function Zo(e,t=K,n=!0){return V({enabled:n,queryFn:({signal:n})=>t.getProjectOpenCapabilities(e,{signal:n}),queryKey:[`projects`,e,`open-capabilities`],staleTime:6e4})}function Qo(e,t=K,n=!0){return V({enabled:n,queryFn:({signal:n})=>t.listSkills(e,{signal:n}),queryKey:[`projects`,e,`skills`]})}function $o(e,t,n=K,r=!0){return V({enabled:r&&t!==void 0,queryFn:async({signal:r})=>t===void 0?{data:[]}:n.listMcpServers(e,t,{signal:r}),queryKey:[`projects`,e,`tasks`,t??null,`mcp-servers`]})}function es(e,t,n=K){return H({mutationFn:async()=>{if(t===void 0)throw Error(`Cannot reload MCP servers without a task`);return n.retryMcpServers(e,t)},mutationKey:[`projects`,e,`tasks`,t??null,`mcp-servers`,`reload`],scope:{id:`task-mcp:${e}:${t??`none`}`}})}function ts(e,t=K,n=!0){return V({enabled:n,queryFn:({signal:n})=>t.getProjectDefaults(e,{signal:n}),queryKey:[`projects`,e,`defaults`]})}function ns(e,t=K){return H({meta:{actionNotification:{successMessage:!1}},mutationFn:n=>t.updateProjectDefaults(e,n),mutationKey:[`projects`,e,`defaults`,`update`],scope:{id:`project-defaults:${e}`}})}function rs(e,t,n=K){return H({meta:{actionNotification:{successMessage:!1}},mutationFn:r=>n.updateTaskSettings(e,t,r),mutationKey:[`projects`,e,`tasks`,t,`settings`,`update`],scope:{id:`task-settings:${e}:${t}`}})}function is(e=K){return V({queryFn:({signal:t})=>e.listProjects({signal:t}),queryKey:[`projects`]})}function as(e=K){return H({mutationFn:t=>e.reorderProjects(t),mutationKey:[`projects`,`reorder`],scope:{id:`projects:reorder`}})}function os(e,t,n=K,r=!0){return V({enabled:r,queryFn:({signal:r})=>n.getProjectGitStatus(e,{rootPath:t},{signal:r}),queryKey:[`projects`,e,t,`git-status`],retry:1})}function ss(e,t,n,r,i,a=K){return V({enabled:i,queryFn:({signal:r})=>a.getProjectGitStatus(e,{includeDiff:!0,rootPath:t,...n===null?{}:{repository:n}},{signal:r}),queryKey:[`projects`,e,t,`git-status-detail`,n,r],retry:1})}function cs(e,t,n,r,i=K){return V({enabled:r&&n!==null,queryFn:({signal:r})=>n===null?Promise.reject(Error(`Git repository is not selected`)):i.getProjectGitStatus(e,{includeDiff:!0,repository:n,rootPath:t},{signal:r}),queryKey:[`projects`,e,t,`git-status`,n],retry:1})}function ls(e,t,n,r,i=K){return za({enabled:r,getNextPageParam:(e,t,n)=>e.nextCursor===null||e.nextCursor===n?void 0:e.nextCursor,initialPageParam:void 0,queryFn:({pageParam:r,signal:a})=>i.getProjectGitHistory(e,{...r===void 0?{}:{cursor:r},...n===void 0?{}:{repository:n},rootPath:t},{signal:a}),queryKey:[`projects`,e,t,`git-history`,n??null]})}function us(e,t,n,r,i,a=K){return za({enabled:i,getNextPageParam:(e,t,n)=>e.nextCursor===null||e.nextCursor===n?void 0:e.nextCursor,initialPageParam:void 0,queryFn:({pageParam:i,signal:o})=>a.getProjectGitCommitFiles(e,{...i===void 0?{}:{cursor:i},...n===void 0?{}:{repository:n},rootPath:t,sha:r},{signal:o}),queryKey:[`projects`,e,t,`git-commit-files`,n??null,r]})}function ds(e,t,n,r,i,a,o=K){return V({enabled:a,gcTime:3e4,queryFn:({signal:a})=>o.getProjectGitCommitFileDiff(e,{path:i,...n===void 0?{}:{repository:n},rootPath:t,sha:r},{signal:a}),queryKey:[`projects`,e,t,`git-commit-diff`,n??null,r,i],staleTime:1/0})}function fs(e,t,n=K){return H({meta:{actionNotification:{successMessage:!1}},mutationFn:r=>n.generateCommitMessage(e,t,r),mutationKey:[`projects`,e,t,`git`,`commit-message`],scope:{id:`project-git-message:${e}:${t}`}})}function ps(e,t,n=K){return H({mutationFn:r=>n.commitProjectChanges(e,t,r),mutationKey:[`projects`,e,t,`git`,`commit`],scope:{id:`project-git-mutation:${e}:${t}`}})}function ms(e,t,n,r=K,i=!0){return V({enabled:i,queryFn:({signal:i})=>r.listProjectFiles(e,t,n,{signal:i}),queryKey:[`projects`,e,t,`file-tree`,n],staleTime:3e4})}function hs(e,t,n,r=K){return V({queryFn:({signal:i})=>r.listTasks(e,{archived:!0,...t===void 0?{}:{cursor:t},limit:20,...n.length===0?{}:{searchTerm:n}},{signal:i}),queryKey:[`projects`,e,`archived-tasks`,n,t??null],refetchOnMount:`always`})}function gs(e,t=K){return za({getNextPageParam:(e,t,n)=>e.nextCursor===null||e.nextCursor===n?void 0:e.nextCursor,initialPageParam:void 0,queryFn:({pageParam:n,signal:r})=>t.listTasks(e,{...n===void 0?{}:{cursor:n},limit:5},{signal:r}),queryKey:[`projects`,e,`tasks`]})}function _s(e,t,n=K){return V({gcTime:pe,queryFn:({signal:r})=>n.readTask(e,t,{signal:r}),queryKey:[`projects`,e,`tasks`,t]})}var vs=[],ys={error:null,hasNextPage:!1,isFetchingNextPage:!1,isPending:!0};async function bs(e,t){await e.get(t)?.fetchNextPage()}var xs=(0,J.createContext)(void 0),Ss=(0,J.createContext)(void 0),Cs=(0,J.createContext)(void 0),ws=(0,J.createContext)(void 0);function Ts({client:e,onRemove:t,onUpdate:n,projectId:r}){let i=je(gs(r,e)),a=(0,J.useMemo)(()=>Co(i.data),[i.data]);return(0,J.useEffect)(()=>{n(r,{controller:{fetchNextPage:i.fetchNextPage},state:{error:i.error,hasNextPage:i.hasNextPage,isFetchingNextPage:i.isFetchingNextPage,isPending:i.isPending},tasks:a})},[n,r,i.error,i.fetchNextPage,i.hasNextPage,i.isFetchingNextPage,i.isPending,a]),(0,J.useEffect)(()=>()=>{t(r)},[t,r]),null}function Es(e,t){let n=e.flatMap(e=>t.get(e)?.tasks??vs);return{projectTaskStates:new Map(e.map(e=>[e,t.get(e)?.state??ys])),tasks:n}}function Ds(){let e=(0,J.useContext)(xs);if(e===void 0)throw Error(`useProjectData must be used inside ProjectProvider`);return e}function Os(){let e=(0,J.useContext)(Ss);if(e===void 0)throw Error(`useProjectActions must be used inside ProjectProvider`);return e}function ks(){let e=(0,J.useContext)(Cs);if(e===void 0)throw Error(`useProjectActivity must be used inside ProjectProvider`);return e}function As(){let e=(0,J.useContext)(ws);if(e===void 0)throw Error(`useProjectRootSelection must be used inside ProjectProvider`);return e}function js(e){let{client:t,projects:n}=Ds(),r=e.length>0,i=Ra({queries:[G,...n.map(e=>e.id)].map(e=>Lo(e,r,t))}),a=r&&i.some(e=>e.isPending),o=i.find(e=>e.error!==null)?.error??null;return{error:o,isPending:a,tasks:a||o!==null?vs:i.flatMap(e=>e.data??vs).filter(t=>t.title.toLocaleLowerCase().includes(e))}}function Ms(){let{client:e,projects:t}=Ds(),n=Ra({queries:[G,...t.map(e=>e.id)].map(t=>Io(t,e))});return{error:n.find(e=>e.error!==null)?.error??null,isPending:n.some(e=>e.isPending),tasks:n.flatMap(e=>e.data??vs)}}function Ns(e){return e instanceof Error&&e.message.trim().length>0?e.message:typeof e==`string`&&e.trim().length>0?e:`Unknown internal error`}function Ps(e,t,n={}){console.warn(`Codexly internal warning`,{diagnosticCode:e,errorMessage:Ns(t),...n})}var Fs=256;function Is(){if(globalThis.Notification===void 0)return;let e=globalThis.Notification;return{getPermission:()=>e.permission,requestPermission:()=>e.requestPermission(),show(t,n){let r=new e(t,n);return{addClickListener(e){r.addEventListener(`click`,e)},close(){r.close()}}}}}function Ls(e){return`${e.taskId}:${e.turnId}`}function Rs(e,t){switch(t.type){case`turn.completed`:{let n=t.payload.turn.status===`completed`?l.t(`notification.completed`,{ns:`conversation`}):t.payload.turn.status===`interrupted`?l.t(`notification.interrupted`,{ns:`conversation`}):t.payload.turn.status===`failed`?l.t(`notification.failed`,{ns:`conversation`}):void 0;return n===void 0?void 0:{body:n,tag:`${e}:${t.taskId}:${t.turnId}:terminal`}}case`provider.error`:return t.payload.willRetry?void 0:{body:l.t(`notification.failedWithMessage`,{message:t.payload.message,ns:`conversation`}),tag:`${e}:${t.taskId}:${t.turnId}:terminal`};case`pending_request.created`:return{body:t.payload.request.type===`user_input`?l.t(`notification.waitingInput`,{ns:`conversation`}):l.t(`notification.waitingApproval`,{ns:`conversation`}),tag:`${e}:${t.taskId}:${t.payload.request.requestId}:request`};default:return}}var zs=class{#e;#t=new Set;#n;#r;#i;#a;#o;constructor(e){this.#e=e.api,this.#n=e.focusPage??(()=>{globalThis.window.focus()}),this.#r=e.isEnabled??(()=>!0),this.#i=e.isPageForeground??(()=>globalThis.document.visibilityState===`visible`&&globalThis.document.hasFocus()),this.#a=e.navigateToTask??(()=>void 0)}notify(e,t,n){if(!this.#r()||this.#e?.getPermission()!==`granted`||this.#i())return;if(t.type===`provider.error`&&!t.payload.willRetry){let e=Ls(t);if(this.#t.has(e))return;if(this.#t.size>=Fs){let e=this.#t.values().next().value;e!==void 0&&this.#t.delete(e)}this.#t.add(e)}else if(t.type===`turn.completed`&&this.#t.delete(Ls(t)))return;let r=Rs(e,t);if(r!==void 0)try{let i=n.trim()||`Task`,a=this.#e.show(`Codexly · ${i}`,{body:r.body,data:{projectId:e,taskId:t.taskId},tag:r.tag});a.addClickListener(()=>{a.close(),this.#n(),this.#a(e,t.taskId)})}catch(n){Ps(`browser_notification_show_failed`,n,{projectId:e,taskId:t.taskId})}}requestPermission(){if(!this.#r()||this.#e===void 0)return Promise.resolve();if(this.#o!==void 0)return this.#o;let e;try{if(this.#e.getPermission()!=="default")return Promise.resolve();e=this.#e.requestPermission()}catch(e){return Ps(`notification_permission_failed`,e),Promise.resolve()}return this.#o=e.then(()=>void 0).catch(e=>{Ps(`notification_permission_failed`,e)}).finally(()=>{this.#o=void 0}),this.#o}};function Bs(e={}){return new zs({...e,api:e.api??Is()})}var Vs={attention:null,isAwaitingApproval:!1,isRunning:!1};function Hs(e,t){return`${e}\u0000${t}`}function Us(e){return e.type===`command_approval`||e.type===`file_change_approval`||e.type===`permissions_approval`||e.type===`mcp_elicitation`}function Ws(e){return new Set(e.filter(e=>e.status===`pending`&&Us(e)).map(e=>e.requestId))}function Gs(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function Ks(e,t,n,r){let i=Hs(t,n),a=e.get(i);if(a?.attention===r.attention&&a.isRunning===r.isRunning&&Gs(a.pendingApprovalRequestIds,r.pendingApprovalRequestIds))return e;let o=new Map(e);return o.set(i,r),o}function qs(e,t,n){return Ks(e,t,n,{attention:null,isRunning:!0,pendingApprovalRequestIds:e.get(Hs(t,n))?.pendingApprovalRequestIds??new Set,projectId:t,taskId:n})}function Js(e,t,n){let r=e.get(Hs(t,n));return r===void 0?Vs:{attention:r.attention,isAwaitingApproval:r.pendingApprovalRequestIds.size>0,isRunning:r.isRunning}}function Ys(e,t,n){let r=e.get(Hs(t,n));return r?.attention===void 0||r.attention===null?e:Ks(e,t,n,{...r,attention:null})}function Xs(e,t){for(let n of e.values())if(n.projectId===t&&(n.isRunning||n.pendingApprovalRequestIds.size>0))return!0;return!1}function Zs(e,t){let n=[];for(let r of e.values())r.projectId===t&&(r.isRunning||r.pendingApprovalRequestIds.size>0)&&n.push(r.taskId);return n}function Qs(e,t,n){let r=Hs(t,n);if(!e.has(r))return e;let i=new Map(e);return i.delete(r),i}function $s(e,t,n=!1){let r=e.get(Hs(t.projectId,t.id)),i=Ws(t.pendingRequests),a=n?null:i.size>0?`approval`:t.status===`running`?null:r?.attention===`completed`||r?.attention===`failed`?r.attention:null;return Ks(e,t.projectId,t.id,{attention:a,isRunning:t.status===`running`,pendingApprovalRequestIds:i,projectId:t.projectId,taskId:t.id})}function ec(e,t,n,r=!1){let i=Hs(t,n.taskId),a=e.get(i)??{attention:null,isRunning:!1,pendingApprovalRequestIds:new Set,projectId:t,taskId:n.taskId},o=a.attention,s=a.isRunning,c=a.pendingApprovalRequestIds;switch(n.type){case`turn.started`:o=null,s=!0;break;case`task.status_updated`:s=n.payload.status===`running`,s&&(o=null);break;case`turn.completed`:o=r?null:n.payload.turn.status===`failed`||n.payload.turn.status===`interrupted`?`failed`:`completed`,s=!1,c=new Set;break;case`provider.error`:n.payload.willRetry||(o=r?null:`failed`,s=!1,c=new Set);break;case`pending_request.created`:Us(n.payload.request)&&(o=r?null:`approval`,c=new Set(c).add(n.payload.request.requestId));break;case`pending_request.resolved`:case`pending_request.expired`:if(c.has(n.payload.request.requestId)){let e=new Set(c);e.delete(n.payload.request.requestId),c=e,e.size===0&&o===`approval`&&(o=null)}break;default:return e}return Ks(e,t,n.taskId,{attention:o,isRunning:s,pendingApprovalRequestIds:c,projectId:t,taskId:n.taskId})}var tc=new TextEncoder,nc=32,rc=8,ic=48,ac=16,oc=16;function sc(e){return tc.encode(e).byteLength}function Q(e){let t=new WeakSet;function n(e){if(e==null)return 8;if(typeof e==`string`)return oc+sc(e);if(typeof e==`number`||typeof e==`bigint`)return 8;if(typeof e==`boolean`)return 4;if(typeof e==`symbol`||typeof e==`function`)return 16;if(t.has(e))return 0;if(t.add(e),Array.isArray(e)){let t=nc+e.length*rc;for(let r of e)t+=n(r);return t}let r=ic;for(let[t,i]of Object.entries(e))r+=ac+sc(t)+n(i);return r}return n(e)}var cc=class{#e=new Map;#t;#n;#r;#i;#a=0;constructor(e){if(!Number.isSafeInteger(e.maxBytes)||e.maxBytes<0)throw RangeError(`Byte LRU maxBytes must be a non-negative safe integer`);let t=e.maxEntries??2**53-1;if(!Number.isSafeInteger(t)||t<0)throw RangeError(`Byte LRU maxEntries must be a non-negative safe integer`);this.#t=e.getRetainedBytes,this.#n=e.maxBytes,this.#r=t,this.#i=e.onEvict}get retainedBytes(){return this.#a}get size(){return this.#e.size}delete(e){let t=this.#e.get(e);return t===void 0?!1:(this.#e.delete(e),this.#a-=t.retainedBytes,!0)}get(e){let t=this.#e.get(e);if(t!==void 0)return this.#e.delete(e),this.#e.set(e,t),t.value}peek(e){return this.#e.get(e)?.value}set(e,t){let n=this.#t(e,t);if(!Number.isSafeInteger(n)||n<0)throw RangeError(`Byte LRU entry size must be a non-negative safe integer`);let r=this.#e.get(e);return r!==void 0&&(this.#e.delete(e),this.#a-=r.retainedBytes,this.#i?.(e,r.value,`replaced`)),n>this.#n||this.#r===0?!1:(this.#e.set(e,{retainedBytes:n,value:t}),this.#a+=n,this.#o(),this.#e.has(e))}#o(){for(;this.#e.size>this.#r||this.#a>this.#n;){let e=this.#e.entries().next().value;if(e===void 0)return;let[t,n]=e;this.#e.delete(t),this.#a-=n.retainedBytes,this.#i?.(t,n.value,this.#e.size>=this.#r?`entries`:`bytes`)}}},lc=1e3,uc=3e4,dc=class{#e=0;#t;#n=0;#r;#i;#a=0;#o=0;constructor(e){if(!Number.isSafeInteger(e.maxBytes)||e.maxBytes<0)throw RangeError(`Project Event history maxBytes must be non-negative`);if(!Number.isSafeInteger(e.maxEvents)||e.maxEvents<0)throw RangeError(`Project Event history maxEvents must be non-negative`);this.#r=e.maxBytes,this.#i=e.maxEvents,this.#t=Array(e.maxEvents)}get floorSequence(){return this.#n}append(e){let t=Q(e);if(t>this.#r||this.#i===0){this.reset(e.sequence);return}this.#e===this.#i&&this.#s();let n=(this.#o+this.#e)%this.#i;for(this.#t[n]={event:e,retainedBytes:t},this.#e+=1,this.#a+=t;this.#a>this.#r;)this.#s()}forEachAfter(e,t){for(let n=0;n<this.#e;n+=1){let r=this.#t[(this.#o+n)%this.#i];r!==void 0&&r.event.sequence>e&&t(r.event)}}reset(e=this.#n){this.#t=Array(this.#i),this.#e=0,this.#n=e,this.#a=0,this.#o=0}#s(){let e=this.#t[this.#o];e!==void 0&&(this.#t[this.#o]=void 0,this.#o=(this.#o+1)%this.#i,--this.#e,this.#a-=e.retainedBytes,this.#n=e.event.sequence)}};function fc(e){return e.type===`message.delta`||e.type===`plan.delta`||e.type===`reasoning.delta`||e.type===`command.output_delta`}function pc(e,t){return`${e}\u0000${t}`}function mc(e,t,n){return`${pc(e,t)}\u0000${n}`}var hc=1048576,gc=1e3,_c=new TextEncoder;function vc(e){let t=e.items.map(e=>{if(e.type!==`message`||e.role!==`user`||(e.skills?.length??0)===0)return e;let t=W(e.text,e.skills??[]);return t===e.text?e:{...e,text:t}});return t.some((t,n)=>t!==e.items[n])?{...e,items:t}:e}function yc(e,t,n){let r=vc(t),i=r.items.find(e=>e.type===`message`&&e.role===`user`);if(n.text.length===0&&n.skills.length===0&&n.attachments.length===0&&i===void 0)return e;let a=e.turns.findIndex(e=>e.id===r.id),o=e.turns[a],s=vc(o??r),c=s.items.findIndex(e=>e.type===`message`&&e.role===`user`),l=s.items[c],u=c>=0;if(a>=0&&l?.type===`message`){if((l.attachments?.length??0)>0||(n.messageAttachments?.length??0)===0){if(s===o)return e;let t=[...e.turns];return t[a]=s,{...e,turns:t}}let t=[...e.turns],r=[...s.items];return r[c]={...l,attachments:[...n.messageAttachments??[]],...n.text.length===0?{text:``}:{}},t[a]={...s,items:r},{...e,turns:t}}let d=u?s:{...s,items:[i??{id:`submitted-user-${t.id}`,role:`user`,...n.skills.length===0?{}:{skills:n.skills.map(e=>({name:e.name}))},...(n.messageAttachments?.length??0)===0?{}:{attachments:[...n.messageAttachments??[]]},text:n.text,type:`message`},...s.items]};if(a<0)return{...e,status:`running`,turns:[...e.turns,d]};let f=[...e.turns];return f[a]=d,{...e,turns:f}}function bc(e){return e.type===`message.delta`||e.type===`plan.delta`||e.type===`reasoning.delta`||e.type===`command.output_delta`}function xc(e){let t=e.type===`reasoning.delta`?`${e.payload.field}:${String(e.payload.sectionIndex??-1)}`:`value`;return`${e.taskId}:${e.turnId}:${e.itemId}:${e.type}:${t}`}var Sc=class{#e;#t;#n=[];#r=0;constructor(e={}){if(this.#e=e.maxBytes??hc,this.#t=e.maxEvents??gc,!Number.isInteger(this.#e)||this.#e<=0)throw RangeError(`Agent Event buffer maxBytes must be a positive integer`);if(!Number.isInteger(this.#t)||this.#t<=0)throw RangeError(`Agent Event buffer maxEvents must be a positive integer`)}push(e){if(!bc(e))throw TypeError(`Only Agent Event deltas can be buffered`);let t=xc(e),n=this.#n.at(-1),r=n?.event,i=r!==void 0&&xc(r)===t,a=_c.encode(e.payload.delta).byteLength;return this.#n.length+ +!i>this.#t||this.#r+a>this.#e?(this.#n.length=0,this.#r=0,!1):(this.#r+=a,i?(this.#n[this.#n.length-1]={event:{...e,payload:{...e.payload,delta:`${r.payload.delta}${e.payload.delta}`}},retainedBytes:(n?.retainedBytes??0)+a},!0):(this.#n.push({event:e,retainedBytes:a}),!0))}drain(){return this.flushThrough(1/0)}flushThrough(e){let t=this.#n.findIndex(({event:t})=>t.sequence>=e),n=t<0?this.#n.length:t,r=this.#n.splice(0,n);for(let e of r)this.#r-=e.retainedBytes;return r.map(({event:e})=>e)}},Cc=4,wc=class{#e;#t=new Set;#n;#r=!1;#i=0;#a=!1;#o;constructor(e,t){this.#n=e,this.#e=t}dispose(){this.#r=!0,this.#t.clear(),this.#s()}forgetTask(e){this.#t.delete(e),this.#c()}markRecovered(e){this.#t.delete(e),this.#c()}requestRecovery(e){if(!this.#r){for(let t of e)t.length>0&&this.#t.add(t);this.#t.size>0&&!this.#a&&this.#o===void 0&&this.#u()}}#s(){this.#o!==void 0&&(clearTimeout(this.#o),this.#o=void 0)}#c(){this.#t.size>0||this.#a||(this.#s(),this.#i=0)}#l(){if(this.#r||this.#t.size===0){this.#c();return}let e=Math.min(lc*2**this.#i,uc);this.#i+=1,this.#o=setTimeout(()=>{this.#o=void 0,this.#u()},e)}#u(){if(this.#r||this.#a||this.#t.size===0)return;this.#a=!0;let e=[...this.#t],t=0,n=async()=>{for(;!this.#r;){let n=e[t];if(t+=1,n===void 0)return;if(!this.#t.has(n))continue;let r;try{r=await this.#n(n)}catch(e){Ps(`snapshot_recovery_failed`,e);continue}if(!(r===void 0||!this.#t.delete(n)))try{this.#e(n,r)}catch(e){this.#t.add(n),Ps(`snapshot_recovery_failed`,e)}}},r=Math.min(Cc,e.length);Promise.all(Array.from({length:r},n)).then(()=>{if(this.#a=!1,!this.#r){if(this.#t.size===0){this.#i=0;return}this.#l()}})}},Tc=class{#e;#t;#n;#r=0;#i=0;#a=`ready`;#o;constructor(e,t,n=()=>void 0){this.#n=e,this.#e=t,this.#t=n}get isReady(){return this.#a===`ready`}dispose(){this.#a=`disposed`,this.#i+=1,this.#s()}requestRecovery(){this.#a===`ready`&&this.#l()}reset(){this.#a!==`disposed`&&(this.#s(),this.#r=0,this.#i+=1,this.#a=`ready`)}#s(){this.#o!==void 0&&(clearTimeout(this.#o),this.#o=void 0)}#c(){if(this.#a===`disposed`)return;this.#a=`waiting_to_retry`;let e=Math.min(lc*2**this.#r,uc);this.#r+=1,this.#o=setTimeout(()=>{this.#o=void 0,this.#l()},e)}#l(){if(this.#a===`disposed`)return;this.#a=`recovering`,this.#t();let e=this.#i,t;try{t=Promise.resolve(this.#n())}catch(t){Ps(`snapshot_recovery_failed`,t),e===this.#i&&this.#c();return}t.then(t=>{if(!(this.#a!==`recovering`||e!==this.#i)){if(t===void 0){this.#c();return}this.#e(t)}}).catch(t=>{Ps(`snapshot_recovery_failed`,t),this.#a===`recovering`&&e===this.#i&&this.#c()})}},Ec=class{#e=new Sc;#t;#n=new Set;#r;#i;#a;constructor(e,t,n){this.#i=e,this.#n.add(t),this.#t=n,this.#r=new Tc(async()=>this.#n.values().next().value?.(),e=>{this.#t(e,this)},()=>{this.#i.getState().setConnectionState(`reconnecting`)})}get sessionId(){return this.#i.getState().checkpoint?.sessionId}get taskId(){return this.#i.getState().taskId}addConsumer(e){this.#n.add(e)}removeConsumer(e){return this.#n.delete(e),this.#n.size}resetForSnapshot(){this.#a!==void 0&&(cancelAnimationFrame(this.#a),this.#a=void 0),this.#e.drain(),this.#r.reset()}apply(e){if(this.#r.isReady){if(fc(e)){if(this.#a===void 0){this.#a=requestAnimationFrame(()=>{this.#a=void 0;let e=this.#e.drain();e.length>0&&this.#i.getState().applyEvents(e)}),this.#i.getState().applyEvents([e]);return}if(!this.#e.push(e)){this.requestRecovery();return}return}this.#o(e.sequence),this.#i.getState().applyEvents([e])}}dispose(){this.#r.dispose(),this.#a!==void 0&&(cancelAnimationFrame(this.#a),this.#a=void 0),this.#e.drain()}requestRecovery(){this.#r.isReady&&(this.#a!==void 0&&(cancelAnimationFrame(this.#a),this.#a=void 0),this.#e.drain(),this.#r.requestRecovery())}setConnectionState(e){let t=e===`connected`&&!this.#r.isReady?`reconnecting`:e;this.#i.getState().setConnectionState(t),t===`connected`&&this.#i.getState().setError(null)}#o(e){this.#a!==void 0&&(cancelAnimationFrame(this.#a),this.#a=void 0),this.#i.getState().applyEvents(this.#e.flushThrough(e))}},Dc=1e3,Oc=3e4,kc=class{#e;#t=new Map;#n;#r;#i=!1;constructor(e,t,n){this.#e=t,this.#n=n,this.#r=e}cancel(e){let t=this.#t.get(e);t?.timer!==void 0&&clearTimeout(t.timer),this.#t.delete(e)}dispose(){this.#i=!0;for(let e of this.#t.keys())this.cancel(e)}request(e){if(this.#i||this.#t.has(e))return;let t={attempt:0,timer:void 0};this.#t.set(e,t),this.#a(e,t)}async#a(e,t){try{let n=await this.#e.unsubscribeTask(this.#r,e);if(this.#i||this.#t.get(e)!==t)return;if(n.status!==`busy`){this.#t.delete(e);return}let r=Math.min(Dc*2**t.attempt,Oc);t.attempt+=1,t.timer=setTimeout(()=>{t.timer=void 0,this.#a(e,t)},r)}catch(n){this.#t.get(e)===t&&(this.#t.delete(e),this.#n(n,e))}}},Ac=class{#e;#t;#n;#r;#i;#a;#o;#s=new Map;#c;#l=`closed`;#u=!1;#d;#f=Date.now();#p=0;#m;#h=!1;constructor(e,t,n,r){this.#i=e,this.#t=t,this.#e=n,this.#r=r.idleTimeoutMs,this.#n=new dc({maxBytes:r.maxEventHistoryBytes,maxEvents:r.maxEventHistoryEvents}),this.#a=new wc(async e=>this.#t.readTask(this.#i,e),(e,t)=>{this.#e.onSnapshot(t)}),this.#o=new kc(e,t,(t,n)=>{Ps(`task_unsubscribe_failed`,t,{projectId:e,taskId:n})})}attachTaskStore(e,t,n){this.#_(e),this.#o.cancel(e.snapshot.id);let r=t.getState();if(r.projectId!==this.#i||r.taskId!==e.snapshot.id)throw Error(`Task store identity does not match the Project Runtime snapshot`);this.#D(),r.reconcile(e);let i=this.#s.get(t);i===void 0?(i=new Ec(t,n,(e,n)=>{this.#S(e,t,n)}),this.#s.set(t,i)):i.addConsumer(n),i.resetForSnapshot(),i.setConnectionState(this.#l===`closed`?`connecting`:this.#l),this.observeSnapshot(e),this.#w(e.checkpoint,i);let a=!0;return()=>{if(!a)return;a=!1;let e=this.#s.get(t);e!==i||e.removeConsumer(n)>0||(e.dispose(),this.#s.delete(t),this.#o.request(t.getState().taskId),this.#D(),this.#C())}}dispose(){if(!this.#u){this.#u=!0,this.#y(),this.#a.dispose(),this.#o.dispose(),this.#E();for(let e of this.#s.values())e.dispose();this.#s.clear(),this.#v()}}forgetTask(e){this.#o.cancel(e),this.#a.forgetTask(e),this.#C()}markAccess(){this.#D(),this.#C()}observeSnapshot(e){this.#_(e),this.#a.markRecovered(e.snapshot.id),this.#h=!1,this.#D(),this.#b(e.checkpoint);for(let t of this.#s.values())t.sessionId===e.checkpoint.sessionId?t.setConnectionState(this.#l):t.requestRecovery();this.#C()}reconcileTaskSnapshot(e){this.#_(e);let t=[];for(let[n,r]of this.#s)n.getState().taskId===e.snapshot.id&&(n.getState().reconcile(e),r.resetForSnapshot(),t.push(r));this.observeSnapshot(e);for(let n of t)n.setConnectionState(this.#l),this.#w(e.checkpoint,n)}#g(e){this.#n.append(e)}#_(e){if(e.snapshot.projectId!==this.#i)throw Error(`Snapshot Project does not match the Project Runtime`)}#v(){this.#n.reset()}#y(){this.#d!==void 0&&(clearTimeout(this.#d),this.#d=void 0)}#b(e){if(this.#u||this.#c!==void 0&&this.#m===e.sessionId)return;this.#E(),this.#m=e.sessionId,this.#p=e.sequence,this.#n.reset(e.sequence);let t=this.#t.subscribeEvents({afterSequence:e.sequence,onConnectionState:e=>{this.#l=e,e===`reconnecting`&&(this.#h=!0);let t=e===`closed`&&this.#h?`reconnecting`:e;for(let e of this.#s.values())e.setConnectionState(t);e===`reconnecting`&&this.#T()},onError:e=>{Ps(`event_connection_failed`,e,{projectId:this.#i})},onEvent:e=>{this.#p=e.sequence,this.#g(e),this.#e.onActivityEvent(this.#i,e);for(let[t,n]of this.#s)t.getState().taskId===e.taskId&&n.apply(e);e.type===`turn.completed`&&!this.#x(e.taskId)&&this.#o.request(e.taskId),this.#C()},onResyncRequired:()=>{this.#h=!0,this.#E(),this.#l=`reconnecting`;for(let e of this.#s.values())e.setConnectionState(`reconnecting`);this.#T()},projectId:this.#i,sessionId:e.sessionId});this.#c=t}#x(e){for(let t of this.#s.keys())if(t.getState().taskId===e)return!0;return!1}#S(e,t,n){if(this.#s.get(t)!==n)return;this.#_(e);let r=t.getState();if(r.projectId!==this.#i||r.taskId!==e.snapshot.id)throw Error(`Task store identity does not match the recovered snapshot`);r.reconcile(e),n.resetForSnapshot(),this.#e.onSnapshot(e),this.#w(e.checkpoint,n)}#C(){if(this.#y(),this.#u||this.#c===void 0||this.#s.size>0||Xs(this.#e.getTaskActivity(),this.#i))return;let e=this.#r-(Date.now()-this.#f);if(e<=0){this.dispose(),this.#e.onIdle(this);return}this.#d=setTimeout(()=>{this.#d=void 0,this.#C()},e)}#w(e,t){if(e.sessionId!==this.#m){t.requestRecovery();return}if(e.sequence<this.#n.floorSequence&&e.sequence<this.#p){t.requestRecovery();return}this.#n.forEachAfter(e.sequence,e=>{e.taskId===t.taskId&&t.apply(e)})}#T(){let e=new Set;for(let t of this.#s.values())e.add(t.taskId),t.requestRecovery();let t=Zs(this.#e.getTaskActivity(),this.#i).filter(t=>!e.has(t));this.#a.requestRecovery(t)}#E(){let e=this.#c;this.#c=void 0;try{e?.()}catch(e){Ps(`event_connection_cleanup_failed`,e,{projectId:this.#i})}this.#l=`closed`}#D(){this.#f=Date.now(),this.#y()}},jc=class{#e=new Set;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d=new Map;#f;#p=new Map;#m=new Map;#h=new Map;#g=new Set;#_;client;constructor(e,t={}){if(this.client=e,this.#t=t.idleTimeoutMs??12e4,this.#n=t.maxEventHistoryBytes??4194304,this.#r=t.maxEventHistoryEvents??2048,this.#i=t.onMcpServerStatusChanged??(()=>void 0),this.#a=t.onProjectGitActivity??(()=>void 0),this.#o=t.onProjectGitMetadataChanged??(()=>void 0),this.#s=t.onQueueChanged??(()=>void 0),this.#c=t.onSkillsChanged??(()=>void 0),this.#l=t.onTaskRemoved??(()=>void 0),this.#u=t.onTaskMetadataChanged??(()=>void 0),this.#f=t.taskNotifier??Bs(),!Number.isSafeInteger(this.#t)||this.#t<0)throw RangeError(`Project Runtime idleTimeoutMs must be non-negative`);if(!Number.isSafeInteger(this.#n)||this.#n<0)throw RangeError(`Project Runtime maxEventHistoryBytes must be non-negative`);if(!Number.isSafeInteger(this.#r)||this.#r<0)throw RangeError(`Project Runtime maxEventHistoryEvents must be non-negative`)}attachTaskStore(e,t,n){return this.#S(e.snapshot),this.#x(e),this.#v(e.snapshot.projectId).attachTaskStore(e,t,n)}dispose(){for(let e of this.#d.values())e.dispose();this.#d.clear(),this.#e.clear(),this.#m.clear(),this.#h.clear(),this.#g.clear()}forgetTask(e,t){this.#y(Qs(this.#p,e,t)),this.#m.delete(pc(e,t)),this.#h.delete(pc(e,t)),this.#d.get(e)?.forgetTask(t)}forgetProject(e){this.#d.get(e)?.dispose(),this.#d.delete(e);let t=this.#p;for(let n of this.#p.values())n.projectId===e&&(t=Qs(t,e,n.taskId));this.#y(t);let n=`${e}\u0000`;for(let e of this.#m.keys())e.startsWith(n)&&this.#m.delete(e);for(let e of this.#h.keys())e.startsWith(n)&&this.#h.delete(e);for(let e of this.#g)e.startsWith(n)&&this.#g.delete(e);this.#_?.projectId===e&&(this.#_=void 0)}getTaskActivity(){return this.#p}markTaskRunning(e,t){this.#y(qs(this.#p,e,t)),this.#a(e,t,`turn_started`),this.#d.get(e)?.markAccess()}observeSnapshot(e){this.#S(e.snapshot),this.#x(e),this.#v(e.snapshot.projectId).observeSnapshot(e)}requestNotificationPermission(){return this.#f.requestPermission().catch(e=>{Ps(`notification_permission_failed`,e)})}reconcileTaskSnapshot(e){this.#S(e.snapshot),this.#x(e),this.#v(e.snapshot.projectId).reconcileTaskSnapshot(e)}async refreshTaskSnapshot(e,t){let n=await this.client.readTask(e,t);return this.reconcileTaskSnapshot(n),n}rememberTaskTitles(e){for(let t of e)this.#S(t)}viewTask(e,t){this.#_=t===void 0?void 0:{projectId:e,taskId:t},t!==void 0&&this.#y(Ys(this.#p,e,t)),this.#d.get(e)?.markAccess()}subscribeTaskActivity(e){return this.#e.add(e),()=>{this.#e.delete(e)}}#v(e){let t=this.#d.get(e);return t===void 0?(t=new Ac(e,this.client,{getTaskActivity:()=>this.#p,onActivityEvent:(e,t)=>{if(t.type===`project.git_metadata_changed`){this.#o(e,t.payload.rootPath);return}if(t.type===`skills.changed`?this.#c(e):t.type===`queue.changed`?this.#s(e,t.taskId):t.type===`task.metadata_changed`?this.#u(e,t.taskId,`native_notification`):t.type===`task.removed`?(this.#l(e,t.taskId),this.forgetTask(e,t.taskId)):t.type===`mcp_server.status_updated`?this.#i(e,t.taskId):t.type===`turn.started`?this.#a(e,t.taskId,`turn_started`):t.type===`item.completed`&&t.payload.item.type===`file_change`&&t.payload.item.status===`completed`&&this.#a(e,t.taskId,`file_changed`),t.type===`message.delta`){let n=mc(e,t.taskId,t.turnId);if(!this.#g.has(n)){if(this.#g.add(n),this.#g.size>2048){let e=this.#g.values().next().value;e!==void 0&&this.#g.delete(e)}this.#u(e,t.taskId,`assistant_reply_started`)}}if(t.type===`turn.completed`){let n=mc(e,t.taskId,t.turnId);this.#g.delete(n),this.#a(e,t.taskId,`turn_completed`),this.#u(e,t.taskId,`turn_completed`)}try{this.#f.notify(e,t,this.#h.get(pc(e,t.taskId))??`Task`)}catch(n){Ps(`task_notification_failed`,n,{projectId:e,taskId:t.taskId})}t.type!==`task.removed`&&this.#m.set(pc(e,t.taskId),{sequence:t.sequence,sessionId:t.sessionId}),this.#y(ec(this.#p,e,t,this.#b(e,t.taskId)))},onIdle:t=>{this.#d.get(e)===t&&this.#d.delete(e)},onSnapshot:e=>{this.observeSnapshot(e)}},{idleTimeoutMs:this.#t,maxEventHistoryBytes:this.#n,maxEventHistoryEvents:this.#r}),this.#d.set(e,t),t):t}#y(e){if(e!==this.#p){this.#p=e;for(let e of this.#e)e()}}#b(e,t){return this.#_?.projectId===e&&this.#_.taskId===t}#x(e){let{checkpoint:t,snapshot:n}=e,r=pc(n.projectId,n.id),i=this.#m.get(r);if(i?.sessionId===t.sessionId&&i.sequence>t.sequence)return;this.#m.set(r,t);let a=Js(this.#p,n.projectId,n.id).isRunning,o=n.status===`running`;o!==a&&this.#a(n.projectId,n.id,o?`turn_started`:`turn_completed`),this.#y($s(this.#p,n,this.#b(n.projectId,n.id)))}#S(e){let t=pc(e.projectId,e.id);if(this.#h.delete(t),this.#h.set(t,e.title),this.#h.size>2048){let e=this.#h.keys().next().value;e!==void 0&&this.#h.delete(e)}}};function Mc(e,t={}){return new jc(e,t)}function Nc(){return typeof document>`u`||document.visibilityState===`visible`}var Pc=class{#e;#t;#n;#r;#i=new Map;#a;#o;#s;#c;#l=!1;constructor(e,t,n={}){this.#a=e,this.#e=t,this.#t=n.fileChangeDebounceMs??300,this.#n=n.isPageVisible??Nc,this.#r=n.pollIntervalMs??3e5,this.#o=n.random??Math.random,this.#s=n.retryBaseMs??1e3,this.#c=n.retryMaxMs??3e4}dispose(){if(!this.#l){this.#l=!0;for(let e of this.#i.values())this.#p(e);this.#i.clear()}}forgetProject(e){for(let[t,n]of this.#i)n.projectId===e&&(this.#p(n),this.#i.delete(t))}handleActivity(e,t,n,r){if(this.#l)return;let i=this.#h(e,t);if(r===`turn_started`){let e=i.activeTaskIds.size===0,t=i.consecutiveFailures>0||i.retryTimer!==void 0;if(i.activeTaskIds.add(n),i.isGitProject===!1)return;e||t?(this.#f(i),this.#v(i)):this.#m(i);return}if(r===`file_changed`){if(i.activeTaskIds.add(n),this.#f(i),i.isGitProject===!1)return;this.#y(i);return}if(i.activeTaskIds.delete(n),this.#u(i),this.#f(i),i.activeTaskIds.size===0&&this.#d(i),i.isGitProject===!1){i.activeTaskIds.size===0&&this.#i.delete(this.#g(i.projectId,i.rootPath));return}this.#v(i)}handleGitMetadataChanged(e,t){if(this.#l)return;let n=this.#h(e,t);this.#f(n),this.#y(n)}async refreshProject(e,t){if(this.#l)return;let n=this.#h(e,t);this.#f(n),await this.#_(n,`manual`)}#u(e){e.fileChangeTimer!==void 0&&(clearTimeout(e.fileChangeTimer),e.fileChangeTimer=void 0)}#d(e){e.pollingTimer!==void 0&&(clearInterval(e.pollingTimer),e.pollingTimer=void 0)}#f(e){e.retryTimer!==void 0&&(clearTimeout(e.retryTimer),e.retryTimer=void 0)}#p(e){e.closed=!0,e.refreshPending=void 0,this.#u(e),this.#d(e),this.#f(e)}#m(e){e.closed||e.isGitProject!==!0||e.consecutiveFailures>0||e.activeTaskIds.size===0||e.pollingTimer!==void 0||e.retryTimer!==void 0||(e.pollingTimer=setInterval(()=>{this.#n()&&this.#v(e)},this.#r))}#h(e,t){let n=this.#g(e,t),r=this.#i.get(n);if(r!==void 0)return r;let i={activeTaskIds:new Set,closed:!1,consecutiveFailures:0,fileChangeTimer:void 0,inFlight:void 0,isGitProject:void 0,pollingTimer:void 0,projectId:e,rootPath:t,refreshPending:void 0,retryTimer:void 0};return this.#i.set(n,i),i}#g(e,t){return`${e}\u0000${t}`}#_(e,t){if(e.closed||this.#l)return Promise.resolve();if(e.inFlight!==void 0)return e.refreshPending=t===`manual`||e.refreshPending===`manual`?`manual`:`background`,e.inFlight;let n=os(e.projectId,e.rootPath,this.#e),r=this.#e.getProjectGitStatus(e.projectId,{rootPath:e.rootPath}).then(t=>{this.#a.setQueryData(n.queryKey,t),e.consecutiveFailures=0,e.isGitProject=t.repositoryMode!==`none`,e.isGitProject||(this.#u(e),this.#d(e),this.#f(e))}).catch(t=>{throw e.consecutiveFailures+=1,this.#d(e),t}).finally(()=>{if(e.closed||this.#l)return;e.inFlight=void 0;let t=e.refreshPending;if(e.refreshPending=void 0,t!==void 0&&(t===`manual`||e.isGitProject!==!1)){this.#v(e,t);return}if(e.activeTaskIds.size>0){e.consecutiveFailures>0?e.isGitProject!==!1&&this.#b(e):this.#m(e);return}e.activeTaskIds.size===0&&e.fileChangeTimer===void 0&&this.#i.delete(this.#g(e.projectId,e.rootPath))});return e.inFlight=r,r}#v(e,t=`background`){this.#_(e,t).catch(t=>{Ps(`git_status_poll_failed`,t,{projectId:e.projectId,rootPath:e.rootPath})})}#y(e){this.#u(e),e.fileChangeTimer=setTimeout(()=>{e.fileChangeTimer=void 0,this.#v(e)},this.#t)}#b(e){if(e.closed||e.isGitProject===!1||e.activeTaskIds.size===0||e.retryTimer!==void 0)return;let t=Math.min(this.#c,this.#s*2**Math.min(e.consecutiveFailures-1,30)),n=Math.min(this.#c,Math.round(t*(.8+this.#o()*.4)));e.retryTimer=setTimeout(()=>{e.retryTimer=void 0,this.#n()?this.#v(e):this.#b(e)},n)}};function Fc(e,t){if(e!==void 0)return e.roots.find(n=>t?.projectId===e.id&&n.id===t.rootId)??e.roots[0]}function Ic(e,t){if(e===void 0)return;let n=t.get(e.id);return Fc(e,n===void 0?void 0:{projectId:e.id,rootId:n})}function Lc(e,t,n){return n?e.includes(t)?e:[...e,t]:e.filter(e=>e!==t)}function Rc(e){let t=t=>Ic(e.getProject(t),e.getSelectedRootIds());return{onProjectGitActivity(n,r,i){if(n===`temporary`)return;let a=t(n);a!==void 0&&e.coordinator.handleActivity(n,a.path,r,i)},onProjectGitMetadataChanged(n,r){t(n)?.path===r&&e.coordinator.handleGitMetadataChanged(n,r)}}}function zc({actions:e,activity:t,children:n,client:r,data:i,onRemoveTaskQuery:a,onUpdateTaskQuery:o,projects:s,rootSelection:c}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ts,{client:r,onRemove:a,onUpdate:o,projectId:G}),s.map(e=>(0,X.jsx)(Ts,{client:r,onRemove:a,onUpdate:o,projectId:e.id},e.id)),(0,X.jsx)(xs.Provider,{value:i,children:(0,X.jsx)(Ss.Provider,{value:e,children:(0,X.jsx)(ws.Provider,{value:c,children:(0,X.jsx)(Cs.Provider,{value:t,children:n})})})})]})}var Bc=[];function Vc({children:e,client:t=K,taskNotifier:n}){let r=le(),[i,a]=(0,J.useState)(()=>new Map),o=(0,J.useRef)(i);o.current=i;let s=(0,J.useCallback)((e,t)=>{a(n=>{if(n.get(e)===t)return n;let r=new Map(n);return r.set(e,t),r})},[]),c=(0,J.useMemo)(()=>new Pc(r,t),[t,r]),u=(0,J.useMemo)(()=>{let e=new Map;return Mc(t,{...n===void 0?{}:{taskNotifier:n},...Rc({coordinator:c,getProject:e=>r.getQueryData([`projects`])?.data.find(t=>t.id===e),getSelectedRootIds:()=>o.current}),onMcpServerStatusChanged(e,t){r.invalidateQueries({exact:!0,queryKey:[`projects`,e,`tasks`,t,`mcp-servers`]})},onQueueChanged(e,t){So(r,e,t)},onSkillsChanged(e){r.invalidateQueries({exact:!0,queryKey:[`projects`,e,`skills`]})},onTaskRemoved(e,t){Ro(r,e,t),r.removeQueries({exact:!0,queryKey:[`projects`,e,`tasks`,t]})},onTaskMetadataChanged(n,i,a){let o=async()=>{(a===`turn_completed`||a===`native_notification`)&&await Promise.all([r.invalidateQueries({exact:!0,queryKey:[`projects`,n,`tasks`]}),r.invalidateQueries({exact:!0,queryKey:[`projects`,n,`tasks`,Te]}),r.invalidateQueries({exact:!0,queryKey:[`projects`,n,`tasks`,be]})]),r.removeQueries({exact:!0,queryKey:[`projects`,n,`tasks`,i]});let e=await t.readTask(n,i);u.reconcileTaskSnapshot(e),jo(r,e.snapshot,{assistantReplyStarted:a===`assistant_reply_started`})},s=`${n}\u0000${i}`,c=(e.get(s)??Promise.resolve()).catch(()=>void 0).then(o);e.set(s,c);let l=()=>{e.get(s)===c&&e.delete(s)};c.then(l,l)}})},[t,c,r,n]),[d,f]=(0,J.useState)(!1),[p,m]=(0,J.useState)(()=>new Map),[h,g]=(0,J.useState)(),[_,v]=(0,J.useState)(()=>new Set),y=(0,J.useSyncExternalStore)((0,J.useCallback)(e=>u.subscribeTaskActivity(e),[u]),(0,J.useCallback)(()=>u.getTaskActivity(),[u]),(0,J.useCallback)(()=>u.getTaskActivity(),[u])),b=He(qo(t)),x=He(is(t)),{isPending:S,mutateAsync:C}=q(as(t)),{isPending:w,mutateAsync:T}=q(Go(t)),{isPending:E,mutateAsync:D}=q(Ko(t)),O=(0,J.useRef)(Ne()),k=(0,J.useRef)(Ne()),A=(0,J.useRef)(Ne()),j=x.data?.data??Bc,M=(0,J.useMemo)(()=>{let e=new Set(_);return h!==void 0&&e.add(h),e},[h,_]),N=(0,J.useMemo)(()=>j.filter(e=>M.has(e.id)),[j,M]),P=(0,J.useMemo)(()=>[G,...N.map(e=>e.id)],[N]),F=(0,J.useRef)(p);F.current=p;let I=(0,J.useCallback)((e,t)=>{u.rememberTaskTitles(t.tasks),m(n=>{let r=n.get(e);if(r?.tasks===t.tasks&&r.state.error===t.state.error&&r.state.hasNextPage===t.state.hasNextPage&&r.state.isFetchingNextPage===t.state.isFetchingNextPage&&r.state.isPending===t.state.isPending)return n;let i=new Map(n);return i.set(e,t),i})},[u]),L=(0,J.useCallback)(e=>{m(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),{projectTaskStates:R,tasks:z}=(0,J.useMemo)(()=>Es(P,p),[p,P]),B=(0,J.useCallback)(async e=>{await bs(new Map([...F.current].map(([e,t])=>[e,t.controller])),e)},[]),V=x.isPending,H=(0,J.useCallback)((e,t)=>{u.markTaskRunning(e,t)},[u]),ee=(0,J.useCallback)((e,t)=>{u.forgetTask(e,t)},[u]),te=(0,J.useCallback)((e,t)=>{g(t=>t===e?t:e),u.viewTask(e,t)},[u]),ne=(0,J.useCallback)(e=>{v(t=>t.size===e.size&&[...t].every(t=>e.has(t))?t:new Set(e))},[]),re=(0,J.useCallback)(()=>{u.requestNotificationPermission()},[u]),U=(0,J.useCallback)(e=>O.current.run(async()=>{f(!0);try{let n=await t.addProject(e);return r.setQueryData([`projects`],e=>{if(e===void 0)return{data:[n.project],nextCursor:null};let t=e.data.findIndex(e=>e.id===n.project.id);return t<0?{...e,data:[...e.data,n.project]}:{...e,data:e.data.map((e,r)=>r===t?n.project:e)}}),Ie(),n.project}catch(e){Me(e);return}finally{f(!1)}}),[t,r]),ie=(0,J.useCallback)(async e=>await A.current.run(async()=>{let t=r.getQueryData([`projects`]),n=zo(t,e);if(n===void 0)return Me(Error(l.t(`errors.reorderProjectChanged`,{ns:`conversation`}))),!1;r.setQueryData([`projects`],n);try{let t=await C(e);return r.setQueryData([`projects`],t),!0}catch{return r.setQueryData([`projects`],t),!1}})??!1,[C,r]),ae=(0,J.useCallback)(async(e,t)=>await k.current.run(async()=>{try{let n=await T({name:t,projectId:e});return r.setQueryData([`projects`],t=>t===void 0?void 0:{...t,data:t.data.map(t=>t.id===e?n.project:t)}),!0}catch{return!1}})??!1,[T,r]),oe=(0,J.useCallback)(e=>k.current.run(async()=>{try{await D(e),await r.cancelQueries({queryKey:[`projects`,e]}),r.removeQueries({queryKey:[`projects`,e]}),c.forgetProject(e),u.forgetProject(e);let t=r.getQueryData([`projects`]),n=t?.data.filter(t=>t.id!==e)??Bc;return a(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n}),r.setQueryData([`projects`],t===void 0?void 0:{...t,data:n}),n}catch{return}}),[c,D,u,r]),se=(0,J.useCallback)(async(e,t)=>{try{await c.refreshProject(e,t),Ie()}catch(e){Me(e)}},[c]),ce=(0,J.useCallback)(async()=>{await r.invalidateQueries()},[r]);(0,J.useEffect)(()=>()=>{u.dispose(),c.dispose()},[c,u]);let W=(0,J.useMemo)(()=>({capabilities:b.data,client:t,error:b.error??x.error,isPending:V,projectTaskStates:R,projects:j,tasks:z}),[b.data,b.error,t,V,R,j,x.error,z]);return(0,X.jsx)(zc,{actions:(0,J.useMemo)(()=>({addProject:U,fetchNextProjectTaskPage:B,forgetTask:ee,markTaskRunning:H,projectRuntime:u,refreshProjectGitStatus:se,removeProject:oe,renameProject:ae,reorderProjects:ie,requestNotificationPermission:re,retry:ce,setExpandedProjectTaskIds:ne,viewTask:te}),[U,B,ee,H,u,se,oe,ae,ie,re,ce,ne,te]),activity:(0,J.useMemo)(()=>({isProjectActionPending:w||E,isProjectOrderPending:S,isProjectAddPending:d,taskActivity:y}),[d,S,E,w,y]),client:t,data:W,onRemoveTaskQuery:L,onUpdateTaskQuery:I,projects:N,rootSelection:(0,J.useMemo)(()=>({selectedRootIds:i,setSelectedProjectRoot:s}),[i,s]),children:e})}var Hc=`modulepreload`,Uc=function(e){return`/`+e},Wc={},Gc=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Uc(t,n),t=s(t),t in Wc)return;Wc[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Hc,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function Kc(){return Gc(()=>import(`./global-settings-dialog-cA1SWDdi.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))}var qc={error:null,loading:!0,pairing:!1},Jc=class{#e;#t=new Set;#n;#r=0;#i=qc;#a;constructor(e,t){this.#e=e,this.#n=t}getSnapshot=()=>this.#i;subscribe=e=>(this.#t.add(e),()=>this.#t.delete(e));start(){this.#a===void 0&&(this.#a=this.#e.subscribeUnauthorized(()=>{this.#r+=1,this.#o()}),this.load())}stop(){this.#r+=1,this.#a?.(),this.#a=void 0}async load(){let e=this.#r+=1;this.#s({...this.#i,error:null,loading:!0});try{let t=await this.#e.getAccessStatus();e===this.#r&&this.#s({error:null,loading:!1,pairing:!1,status:t})}catch{e===this.#r&&this.#s({...this.#i,error:`load`,loading:!1})}}async pair(e){this.#s({...this.#i,error:null,pairing:!0});try{let t=await this.#e.pairAccess(e);this.#s({error:null,loading:!1,pairing:!1,status:t}),Ie()}catch(e){this.#s({...this.#i,error:null,pairing:!1}),Me(e)}}async logout(){try{let e=await this.#e.logoutAccess();this.#n.clear(),this.#s({error:null,loading:!1,pairing:!1,status:e}),Ie()}catch(e){throw Me(e),e}}#o(){this.#n.clear(),this.#s({error:null,loading:!1,pairing:!1,status:{authenticated:!1,mode:`lan`,version:1}})}#s(e){this.#i=e;for(let e of this.#t)e()}},Yc=(0,J.createContext)(void 0);function Xc({children:e,client:t,queryClient:n}){let[r]=(0,J.useState)(()=>new Jc(t,n)),i=(0,J.useSyncExternalStore)(r.subscribe,r.getSnapshot,r.getSnapshot);(0,J.useEffect)(()=>(r.start(),()=>{r.stop()}),[r]);let a=(0,J.useMemo)(()=>({...i,logout:()=>r.logout(),pair:e=>r.pair(e),retry:()=>{r.load()}}),[r,i]);return(0,X.jsx)(Yc.Provider,{value:a,children:e})}function Zc(){let e=(0,J.useContext)(Yc);if(e===void 0)throw Error(`useAccess must be used inside AccessProvider`);return e}var Qc=I(`archive-restore`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]),$c=I(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),el=I(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),tl=I(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),nl=I(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),rl=I(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),il=I(`circle-arrow-up`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]]),al=I(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),ol=I(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),sl=I(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),cl=I(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),ll=I(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),ul=I(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),dl=I(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),fl=I(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),pl=I(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),ml=I(`panel-left-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]]),hl=I(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),gl=I(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),_l=I(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),vl=I(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),yl=I(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),bl=I(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),xl=I(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),Sl=I(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Cl=I(`wifi`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M2 8.82a15 15 0 0 1 20 0`,key:`dnpr2z`}],[`path`,{d:`M5 12.859a10 10 0 0 1 14 0`,key:`1x1e6c`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}]]),wl=I(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);function Tl({onRetry:e}){let{t}=s(`common`);return(0,X.jsx)(`section`,{className:`grid min-h-0 flex-1 place-items-center bg-content px-6 py-10 text-center`,"aria-labelledby":`runtime-unavailable-title`,children:(0,X.jsxs)(`div`,{className:`max-w-md`,children:[(0,X.jsx)(rl,{className:`mx-auto size-8 text-danger`,"aria-hidden":`true`,strokeWidth:1.6}),(0,X.jsx)(`h1`,{id:`runtime-unavailable-title`,className:`mt-4 text-xl font-semibold`,children:t(`errors.runtimeUnavailableTitle`)}),(0,X.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-muted-foreground`,children:(0,X.jsx)(bo,{components:{command:(0,X.jsx)(`code`,{className:`font-mono text-foreground`})},i18nKey:`errors.runtimeUnavailableDescription`,ns:`common`})}),(0,X.jsxs)(F,{className:`mx-auto mt-5`,onClick:e,size:`lg`,type:`button`,children:[(0,X.jsx)(gt,{className:`size-4`,"aria-hidden":`true`}),t(`actions.retry`)]})]})})}function El(e){return e.filter(e=>e.pinned)}function Dl(e,t){return t||e.length<=5?{hasMore:!1,tasks:e}:{hasMore:!0,tasks:e.slice(0,5)}}function Ol(e){let t=Math.max(1,Math.floor((Date.now()-Date.parse(e))/6e4));if(t<60)return`${String(t)}m`;let n=Math.floor(t/60);return n<24?`${String(n)}h`:`${String(Math.floor(n/24))}d`}var kl=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},Al=(e=>e?kl(e):kl),jl=e=>e;function Ml(e,t=jl){let n=J.useSyncExternalStore(e.subscribe,J.useCallback(()=>t(e.getState()),[e,t]),J.useCallback(()=>t(e.getInitialState()),[e,t]));return J.useDebugValue(n),n}var Nl=1048576,Pl=1e4,Fl=16*1024,Il=256,Ll=new TextDecoder,Rl=new TextEncoder,zl=class{#e;#t;#n=()=>this.materialize();#r;#i;#a=0;#o=[];#s=!1;#c=0;#l=!1;#u=``;#d=-1;#f=1;#p={bytes:0,lines:0};#m=0;#h=[];#g=0;#_=0;#v=0;#y=[];#b=-1;constructor(e,t,n={}){let r=n.maxBytes??Nl,i=Math.max(1,n.maxLines??Pl),a=Math.ceil(i/2),o=i-a;this.#e=Math.ceil(r/2),this.#r=r-this.#e,this.#t=a,this.#i=Math.max(0,o-1),this.replace(e,t)}append(e){this.#l=!0,this.#x(Rl.encode(e)),this.#v+=1}getView(){return{chunks:this.#E(),hasOutput:this.#l,materialize:this.#n,outputBytes:this.#a+this.#m,outputLines:this.#c+this.#_,outputOmitted:this.#p,startIndex:0,version:this.#v}}materialize(){if(this.#d===this.#v)return this.#u;let e=this.#E().map(e=>e.text).join(``);return this.#u=e,this.#d=this.#v,e}replace(e,t){this.#a=0,this.#o=[],this.#s=!1,this.#c=0,this.#l=e!==void 0,this.#p=t,this.#m=0,this.#h=[],this.#g=0,this.#_=0,e!==void 0&&e.length>0&&this.#x(Rl.encode(e)),this.#v+=1}#x(e){let t=0;if(!this.#s){let n=Bl(e,this.#e-this.#a,this.#t-this.#c);if(n>0){let t=this.#S(this.#o,e.subarray(0,n));this.#a+=t.bytes,this.#c+=t.newlines}t=n,this.#s=n<e.byteLength}if(t<e.byteLength){let n=this.#S(this.#h,e.subarray(t),this.#g);this.#m+=n.bytes,this.#_+=n.newlines,this.#T()}}#S(e,t,n=0){let r=0,i=0;for(;r<t.byteLength;){let a=r,o=0;for(;a<t.byteLength;){let e=t[a]??0,n=Hl(e);if(a>r&&a+n-r>Fl||(a+=n,e===10&&(o+=1,o>=Il)))break}let s=t.subarray(r,a).slice();e.push(this.#C(s,o)),i+=o,this.#w(e,n),r=a}return{bytes:t.byteLength,newlines:i}}#C(e,t,n=0){let r={byteLength:e.byteLength,encodedValue:e,id:this.#f,mergeLevel:n,newlineCount:t,text:Ll.decode(e)};return this.#f+=1,r}#w(e,t){for(;e.length-t>=2;){let t=e.at(-1),n=e.at(-2);if(t===void 0||n?.mergeLevel!==t.mergeLevel||n.byteLength+t.byteLength>Fl||n.newlineCount+t.newlineCount>Il)return;let r=new Uint8Array(n.byteLength+t.byteLength);r.set(n.encodedValue),r.set(t.encodedValue,n.byteLength),e.splice(-2,2,this.#C(r,n.newlineCount+t.newlineCount,n.mergeLevel+1))}}#T(){for(;this.#m>this.#r||this.#_>this.#i;){let e=this.#h[this.#g];if(e===void 0)break;let t=Vl(e.encodedValue,this.#m-this.#r,this.#_-this.#i);if(this.#m-=t.bytes,this.#_-=t.newlines,this.#p={bytes:this.#p.bytes+t.bytes,lines:this.#p.lines+t.newlines},t.bytes===e.byteLength)this.#g+=1;else{let n=e.encodedValue.subarray(t.bytes).slice();this.#h[this.#g]=this.#C(n,e.newlineCount-t.newlines)}}this.#g>=128&&this.#g*2>=this.#h.length&&(this.#h=this.#h.slice(this.#g),this.#g=0)}#E(){return this.#b!==this.#v&&(this.#y=[...this.#o,...this.#h.slice(this.#g)],this.#b=this.#v),this.#y}};function Bl(e,t,n){let r=0,i=0;for(;r<e.byteLength&&!(i>=n);){let a=e[r]??0,o=Hl(a);if(r+o>t||a===10&&i>=n)break;r+=o,a===10&&(i+=1)}return r}function Vl(e,t,n){let r=0,i=0;for(;r<e.byteLength&&(r<t||i<n);){let t=e[r]??0;r+=Hl(t),t===10&&(i+=1)}return{bytes:r,newlines:i}}function Hl(e){return e&128?(e&224)==192?2:(e&240)==224?3:4:1}var Ul=`__CODEXLY_PENDING_COMMAND__`,Wl=`__CODEXLY_RETAINED_COMMAND_OUTPUT__`,Gl=new TextEncoder().encode(Wl).byteLength;function Kl(e){if(e.type!==`command`||e.output===`__CODEXLY_RETAINED_COMMAND_OUTPUT__`)return e;let t={...e};return delete t.output,t}function ql(e){let t=Kl(e),n=new Map,r=0,i=e.type===`command`?-1:0,a=t,o,s=e.type===`reasoning`?e.summary.length:0,c=e.type===`command`?new zl(e.output,e.outputOmitted):void 0,l=Q(t)+(c?.getView().outputBytes??0),u=Al()(()=>({revision:0}));function d(e,t){let i=n.get(e);i===void 0?n.set(e,[t]):i.push(t),e===`summary`&&(s+=t.length),l+=sc(t),r+=1}return Object.assign(u,{appendDelta(e){if(e.type===`message.delta`)return t.type!==`message`||t.role!==`assistant`?!1:(d(`text`,e.payload.delta),!0);if(e.type===`reasoning.delta`)return t.type===`reasoning`?(e.payload.field===`summary`&&e.payload.sectionIndex!==void 0&&((o===void 0?e.payload.sectionIndex>0:e.payload.sectionIndex!==o)&&s>0&&d(`summary`,`
|
|
3
|
-
|
|
4
|
-
`),o=e.payload.sectionIndex),d(e.payload.field,e.payload.delta),!0):!1;if(e.type===`plan.delta`)return t.type===`plan`?(d(`plan`,e.payload.delta),!0):!1;if(t.type!==`command`)return!1;let n=c?.getView().outputBytes??0;return c?.append(e.payload.delta),l+=(c?.getView().outputBytes??0)-n,r+=1,!0},getRetainedBytes:()=>l,peek:()=>t,publish(){u.setState(e=>({revision:e.revision+1}))},read(){if(i===r)return a;let e=t;if(t.type===`message`){let r=n.get(`text`);r!==void 0&&(e={...t,text:[t.text,...r].join(``)})}else if(t.type===`reasoning`){let r=n.get(`content`),i=n.get(`summary`);(r!==void 0||i!==void 0)&&(e={...t,content:r===void 0?t.content:[t.content,...r].join(``),summary:i===void 0?t.summary:[t.summary,...i].join(``)})}else if(t.type===`command`){let n=c?.getView();n!==void 0&&(e={...t,...n.hasOutput?{output:n.materialize()}:{},outputOmitted:n.outputOmitted})}else if(t.type===`plan`){let r=n.get(`plan`);r!==void 0&&(e={...t,text:[t.text,...r].join(``)})}return a=e,i=r,a},readCommandOutput(){return c?.getView()},replace(e){t=Kl(e),n.clear(),o=void 0,s=e.type===`reasoning`?e.summary.length:0,c=e.type===`command`?new zl(e.output,e.outputOmitted):void 0,l=Q(t)+(c?.getView().outputBytes??0),r+=1}})}function Jl(e,t){let n=e.pendingRequestsById[t.requestId]!==void 0,r=e.pendingRequestIds;t.status===`pending`?n||(r=[...e.pendingRequestIds,t.requestId]):r=[...e.pendingRequestIds.filter(e=>e!==t.requestId),t.requestId];let i={...e.pendingRequestsById,[t.requestId]:t},a=r.filter(e=>i[e]?.status!==`pending`),o=new Set(a.slice(0,-20));return o.size===0?{pendingRequestIds:r,pendingRequestsById:i}:{pendingRequestIds:r.filter(e=>!o.has(e)),pendingRequestsById:Object.fromEntries(Object.entries(i).filter(([e])=>!o.has(e)))}}function Yl(e,t){return JSON.stringify([e,t])}function Xl(e,t){return e.itemStoresByKey.get(t)?.read()}function Zl(e){let{pendingRequests:t,turns:n,turnsNextCursor:r,...i}=e.snapshot,a=[],o={},s={},c=new Map;for(let e of n){let{items:t,...n}=e;a.push(e.id),o[e.id]=n,s[e.id]=t.map(t=>Yl(e.id,t.id));for(let n of t){let t=Yl(e.id,n.id);c.set(t,ql(n))}}let l={pendingRequestIds:[],pendingRequestsById:{}};for(let e of t)l=Jl(l,e);let{budget:u}=Ql({previousBudget:{commandOutputAccessByItemKey:new Map,commandOutputAccessSequence:0,commandOutputBytes:0,commandOutputBytesByItemKey:new Map},sourceItemStoresByKey:c,touchedItemKeys:[...c.keys()]}),d=Q(e.checkpoint)+Q(i)+Q(r);for(let e of a){d+=Q(o[e]);for(let t of s[e]??[])d+=c.get(t)?.getRetainedBytes()??0}for(let e of l.pendingRequestIds)d+=Q(l.pendingRequestsById[e]);return{checkpoint:e.checkpoint,...u,itemKeysByTurnId:s,itemStoresByKey:c,itemStructureRevision:0,notices:[],...l,retainedBytes:d,snapshotMetadata:i,turnIds:a,turnsNextCursor:r,turnsById:o}}function Ql(e){let t=e.previousBudget.commandOutputAccessByItemKey,n=e.previousBudget.commandOutputBytesByItemKey,r=e.previousBudget.commandOutputAccessSequence,i=e.previousBudget.commandOutputBytes,a=new Map;for(let a of new Set(e.touchedItemKeys)){let o=n.get(a)??0,s=e.sourceItemStoresByKey.get(a)?.readCommandOutput();if(!s?.hasOutput){t.delete(a),n.delete(a),i-=o;continue}r+=1,t.set(a,r),n.set(a,s.outputBytes),i+=s.outputBytes-o}if(i<=8388608)return{budget:{commandOutputAccessByItemKey:t,commandOutputAccessSequence:r,commandOutputBytes:i,commandOutputBytesByItemKey:n},retainedBytesDeltaByItemKey:a};let o=[...t.keys()].toSorted((e,n)=>(t.get(e)??0)-(t.get(n)??0));for(let t of o){if(i<=8388608)break;let r=e.sourceItemStoresByKey.get(t),o=r?.peek();if(r===void 0||o?.type!==`command`)continue;let s=n.get(t)??0,c=r.getRetainedBytes(),l=r.readCommandOutput();r.replace({...o,output:Wl,outputOmitted:{bytes:(l?.outputOmitted.bytes??o.outputOmitted.bytes)+s,lines:(l?.outputOmitted.lines??o.outputOmitted.lines)+(l?.outputLines??0)}}),e.changedItemStores?.add(r),n.set(t,Gl),i-=s-Gl,a.set(t,r.getRetainedBytes()-c)}return{budget:{commandOutputAccessByItemKey:t,commandOutputAccessSequence:r,commandOutputBytes:i,commandOutputBytesByItemKey:n},retainedBytesDeltaByItemKey:a}}function $l(e,t){if(e?.type!==`message`||e.role!==`user`||t.type!==`message`||t.role!==`user`||t.text.length>0||(t.skills?.length??0)===0)return;let n=new Set((e.skills??[]).map(e=>e.name)),r=[...e.skills??[]];for(let e of t.skills??[])n.has(e.name)||(n.add(e.name),r.push(e));return{...e,skills:r,text:W(e.text,r)}}function eu(e,t,n){if(n.type===`command.output_delta`)return[Yl(n.turnId,n.itemId)];if(n.type===`item.started`||n.type===`item.completed`){let t=Yl(n.turnId,n.itemId);return n.payload.item.type===`command`||e.commandOutputBytesByItemKey.has(t)?[t]:void 0}if(n.type===`turn.started`||n.type===`turn.completed`)return[...e.itemKeysByTurnId[n.turnId]??[],...t.itemKeysByTurnId[n.turnId]??[]]}function tu(e){switch(e.type){case`message.delta`:return{id:e.itemId,role:`assistant`,text:``,type:`message`};case`reasoning.delta`:return{content:``,id:e.itemId,summary:``,type:`reasoning`};case`plan.delta`:return{id:e.itemId,text:``,type:`plan`};case`command.output_delta`:return{command:Ul,cwd:``,id:e.itemId,output:``,outputOmitted:{bytes:0,lines:0},status:`running`,type:`command`};default:return}}function nu(e,t,n,r){let i=e.itemKeysByTurnId[t]??[],a=new Set(n.map(e=>Yl(t,e.id)));for(let t of i)a.has(t)||e.itemStoresByKey.delete(t);for(let i of n){let n=Yl(t,i.id),a=e.itemStoresByKey.get(n);a===void 0?e.itemStoresByKey.set(n,ql(i)):(a.replace(i),r.add(a))}return{itemKeysByTurnId:{...e.itemKeysByTurnId,[t]:[...a]}}}function ru(e,t,n){let r=`submitted-user-${t}`,i=n.find(e=>e.type===`message`&&e.role===`user`),a=[],o=new Set;for(let n of e.itemKeysByTurnId[t]??[]){let t=Xl(e,n);if(t===void 0)continue;let s=t.id===r&&i!==void 0?i:t;o.has(s.id)||(o.add(s.id),a.push(s))}let s=new Set(a.map(e=>e.id)),c=new Map(n.map(e=>[e.id,e])),l=new Map,u=[];for(let e of n){if(!s.has(e.id)){u.push(e);continue}u.length>0&&(l.set(e.id,u),u=[])}return[...a.flatMap(e=>[...l.get(e.id)??[],c.get(e.id)??e]),...u]}function iu(e,t,n){let r=e.snapshotMetadata;if(r===null)return{};let i={sequence:t.sequence,sessionId:t.sessionId};switch(t.type){case`project.git_metadata_changed`:return{};case`turn.started`:{let{items:a,...o}=t.payload.turn;return{checkpoint:i,...nu(e,t.turnId,a,n),snapshotMetadata:{...r,status:`running`,updatedAt:t.timestamp},itemStructureRevision:e.itemStructureRevision+1,turnIds:[...e.turnIds.filter(e=>e!==t.turnId),t.turnId],turnsById:{...e.turnsById,[t.turnId]:o}}}case`message.delta`:case`plan.delta`:case`reasoning.delta`:case`command.output_delta`:{let a=e.turnsById[t.turnId];if(a===void 0)return{checkpoint:i,snapshotMetadata:{...r,updatedAt:t.timestamp}};let o=a.status===`running`&&a.error!==null?{...e.turnsById,[t.turnId]:{...a,error:null}}:e.turnsById,s=Yl(t.turnId,t.itemId),c=e.itemStoresByKey.get(s);if(c!==void 0)return c.appendDelta(t)&&n.add(c),{checkpoint:i,snapshotMetadata:{...r,updatedAt:t.timestamp},turnsById:o};let l=tu(t);if(l===void 0)return{checkpoint:i};let u=ql(l);return u.appendDelta(t),e.itemStoresByKey.set(s,u),n.add(u),{checkpoint:i,itemKeysByTurnId:{...e.itemKeysByTurnId,[t.turnId]:[...e.itemKeysByTurnId[t.turnId]??[],s]},itemStructureRevision:e.itemStructureRevision+1,snapshotMetadata:{...r,updatedAt:t.timestamp},turnsById:o}}case`tool.progress`:{let a=Yl(t.turnId,t.itemId),o=e.itemStoresByKey.get(a);if(o===void 0)return{checkpoint:i,snapshotMetadata:{...r,updatedAt:t.timestamp}};let s=o.read();return s.type===`tool`?(o.replace({...s,progress:t.payload.message}),n.add(o),{checkpoint:i,snapshotMetadata:{...r,updatedAt:t.timestamp}}):{checkpoint:i}}case`file_change.updated`:{let a=Yl(t.turnId,t.itemId),o=e.itemStoresByKey.get(a);if(o!==void 0){let e=o.read();return e.type===`file_change`?(o.replace({...e,changes:t.payload.changes,status:`running`}),n.add(o),{checkpoint:i,snapshotMetadata:{...r,updatedAt:t.timestamp}}):{checkpoint:i}}if(e.turnsById[t.turnId]===void 0)return{checkpoint:i};let s=ql({changes:t.payload.changes,id:t.itemId,status:`running`,type:`file_change`});return e.itemStoresByKey.set(a,s),n.add(s),{checkpoint:i,itemKeysByTurnId:{...e.itemKeysByTurnId,[t.turnId]:[...e.itemKeysByTurnId[t.turnId]??[],a]},itemStructureRevision:e.itemStructureRevision+1,snapshotMetadata:{...r,updatedAt:t.timestamp}}}case`task.notice`:return{checkpoint:i,notices:t.payload.code===`guardian_warning`?e.notices:[...e.notices,t].slice(-20),snapshotMetadata:{...r,updatedAt:t.timestamp}};case`mcp_server.status_updated`:return{checkpoint:i};case`goal.updated`:return{checkpoint:i,snapshotMetadata:{...r,goal:t.payload.goal,updatedAt:t.timestamp}};case`goal.cleared`:return{checkpoint:i,snapshotMetadata:{...r,goal:null,updatedAt:t.timestamp}};case`queue.changed`:return{checkpoint:i};case`task.status_updated`:return{checkpoint:i,snapshotMetadata:{...r,status:t.payload.status,updatedAt:t.timestamp}};case`skills.changed`:case`task.metadata_changed`:case`task.removed`:return{checkpoint:i};case`item.started`:case`item.completed`:{if(e.turnsById[t.turnId]===void 0)return{checkpoint:i,snapshotMetadata:{...r,updatedAt:t.timestamp}};let a=Yl(t.turnId,t.itemId),o=e.itemStoresByKey.get(a),s=o!==void 0,c=e.itemKeysByTurnId[t.turnId]??[],l=c.at(-1),u=l===void 0?void 0:e.itemStoresByKey.get(l),d=$l(u?.read(),t.payload.item);if(d!==void 0&&u!==void 0)return u.replace(d),n.add(u),{checkpoint:i,snapshotMetadata:{...r,updatedAt:t.timestamp}};let f=`submitted-user-${t.turnId}`,p=Yl(t.turnId,f),m=t.payload.item.type===`message`&&t.payload.item.role===`user`&&c.includes(p),h=m?c.filter(e=>e!==p).concat(s?[]:a):s?c:[...c,a];return m&&e.itemStoresByKey.delete(p),o===void 0?e.itemStoresByKey.set(a,ql(t.payload.item)):(o.replace(t.payload.item),n.add(o)),{checkpoint:i,itemKeysByTurnId:h===c?e.itemKeysByTurnId:{...e.itemKeysByTurnId,[t.turnId]:h},itemStructureRevision:e.itemStructureRevision+1,snapshotMetadata:{...r,updatedAt:t.timestamp}}}case`turn.completed`:{let a=e.turnsById[t.turnId],o=a?.status===`failed`?a.error:null,s=t.payload.turn.error===null&&o!==null?{...t.payload.turn,error:o}:t.payload.turn,{items:c,...l}=s,u=ru(e,t.turnId,c);return{checkpoint:i,...a===void 0?{}:nu(e,t.turnId,u,n),notices:[],snapshotMetadata:{...r,status:s.status===`failed`?`failed`:`idle`,updatedAt:t.timestamp},itemStructureRevision:e.itemStructureRevision+1,turnsById:a===void 0?e.turnsById:{...e.turnsById,[t.turnId]:l}}}case`plan.updated`:return{checkpoint:i,snapshotMetadata:{...r,plan:t.payload.plan,updatedAt:t.timestamp}};case`usage.updated`:return{checkpoint:i,snapshotMetadata:{...r,contextUsage:t.payload.usage,updatedAt:t.timestamp}};case`provider.error`:{let n=e.turnsById[t.turnId],a=n===void 0?e.turnsById:{...e.turnsById,[t.turnId]:{...n,error:t.payload.message,status:t.payload.willRetry?n.status:`failed`}};return{checkpoint:i,snapshotMetadata:t.payload.willRetry?r:{...r,status:`failed`,updatedAt:t.timestamp},turnsById:a}}case`pending_request.created`:case`pending_request.resolved`:case`pending_request.expired`:{let n=t.payload.request;return{checkpoint:i,...Jl(e,n),snapshotMetadata:{...r,updatedAt:t.timestamp}}}}}function au(e){if(e.snapshotMetadata!==null)return{...e.snapshotMetadata,pendingRequests:e.pendingRequestIds.flatMap(t=>{let n=e.pendingRequestsById[t];return n?.status===`pending`?[n]:[]}),turnsNextCursor:e.turnsNextCursor,turns:e.turnIds.flatMap(t=>{let n=e.turnsById[t];if(n===void 0)return[];let r=(e.itemKeysByTurnId[t]??[]).flatMap(t=>{let n=Xl(e,t);return n===void 0?[]:[n]});return[{...n,items:r}]})}}function ou(e,t){if(e.role!==`user`||t.role!==`user`||e.text.length>0||t.text.length>0)return!1;let n=e.attachments??[],r=t.attachments??[];return n.length===0||n.length!==r.length?!1:n.every((e,t)=>{let n=r[t];return e.kind===`image`&&n?.kind===`image`&&e.mediaType===n.mediaType&&e.size===n.size})}function su(e,t){let n=new Map(t.items.map(e=>[e.id,e])),r=new Map,i=e.items.filter(e=>e.type===`message`),a=t.items.filter(e=>e.type===`message`),o=new Map(i.map(e=>[e.id,e])),s=new Set,c=new Set,l=(e,t)=>{s.add(e.id),c.add(t.id),n.delete(t.id),r.set(e.id,{...t,id:e.id})};for(let e of a){let t=o.get(e.id);t!==void 0&&l(t,e)}let u=i.filter(e=>!s.has(e.id)),d=a.filter(e=>!c.has(e.id)),f=new Map,p=new Map;for(let e of d){let t=u.filter(t=>t.role===e.role&&(t.text.length>0&&e.text.length>0&&(t.text.startsWith(e.text)||e.text.startsWith(t.text))||ou(t,e)));f.set(e.id,t);for(let e of t)p.set(e.id,(p.get(e.id)??0)+1)}for(let e of d){let t=f.get(e.id)??[],n=t.length===1?t[0]:void 0;n!==void 0&&p.get(n.id)===1&&l(n,e)}return[...e.items.flatMap(e=>{let t=r.get(e.id);if(t!==void 0)return[t];let i=n.get(e.id);return i===void 0?[e]:(n.delete(e.id),[i])}),...n.values()]}function cu(e,t){let n=au(e);if(n===void 0)return t;let r=new Map(n.turns.map(e=>[e.id,e])),i=new Set(t.snapshot.turns.map(e=>e.id)),a=n.turns.flatMap((e,t)=>i.has(e.id)?[t]:[]),o=a.at(0),s=a.at(-1),c=t.snapshot.turnsNextCursor!==null&&o!==void 0&&s!==void 0,l=c?n.turns.slice(0,o).filter(e=>!i.has(e.id)):[],u=c?n.turns.slice(s+1).filter(e=>!i.has(e.id)):[];return{...t,snapshot:{...t.snapshot,turns:[...l,...t.snapshot.turns.map(e=>{let t=r.get(e.id);return t===void 0?e:{...e,items:su(t,e)}}),...u],turnsNextCursor:l.length>0?n.turnsNextCursor:t.snapshot.turnsNextCursor}}}function lu(e,t){let n=t===void 0?{checkpoint:null,commandOutputAccessByItemKey:new Map,commandOutputAccessSequence:0,commandOutputBytesByItemKey:new Map,commandOutputBytes:0,itemKeysByTurnId:{},itemStoresByKey:new Map,itemStructureRevision:0,notices:[],pendingRequestIds:[],pendingRequestsById:{},retainedBytes:0,snapshotMetadata:null,turnIds:[],turnsNextCursor:null,turnsById:{}}:Zl(t);if(t!==void 0&&(t.snapshot.projectId!==e.projectId||t.snapshot.id!==e.taskId))throw Error(`Task store identity does not match the initial snapshot`);return Al()((t,r)=>({...n,applyEvents(e){if(e.length===0)return;let n=new Set;t(t=>{let r=t;for(let t of e){let e=r.checkpoint,i=e!==null&&t.sessionId===e.sessionId&&t.sequence>e.sequence;if(t.taskId!==r.taskId||!i)continue;let a=r,o=du(a,t),s=pu(a,t);r={...r,...iu(r,t,n)};let c=eu(a,r,t),l=new Map;if(c!==void 0){let e=Ql({previousBudget:a,changedItemStores:n,sourceItemStoresByKey:r.itemStoresByKey,touchedItemKeys:c});({retainedBytesDeltaByItemKey:l}=e),r={...r,...e.budget}}let u=new Set([...s.keys(),...fu(r,t)]),d=mu(r,u)-hu(s),f=[...l].reduce((e,[t,n])=>e+(u.has(t)?0:n),0);r={...r,retainedBytes:r.retainedBytes+du(r,t)-o+d+f}}return r});for(let e of n)e.publish()},connectionState:`connecting`,error:null,hydrate(n){if(n.snapshot.projectId!==e.projectId||n.snapshot.id!==e.taskId)throw Error(`Task store identity does not match the snapshot`);t(e=>({...Zl(n),itemStructureRevision:e.itemStructureRevision+1,connectionState:`connecting`,error:null}))},projectId:e.projectId,prependHistory(n){if(n.snapshot.projectId!==e.projectId||n.snapshot.id!==e.taskId)throw Error(`Task store identity does not match the history page`);let r=new Set;t(e=>uu(e,n,r));for(let e of r)e.publish()},reconcile(n){if(n.snapshot.projectId!==e.projectId||n.snapshot.id!==e.taskId)throw Error(`Task store identity does not match the snapshot`);t(e=>{let t=e.checkpoint;return t!==null&&t.sessionId===n.checkpoint.sessionId&&t.sequence>n.checkpoint.sequence?e:{...Zl(cu(e,n)),itemStructureRevision:e.itemStructureRevision+1,connectionState:`connecting`,error:null}})},getItem:(e,t)=>r().itemStoresByKey.get(Yl(t,e))?.read(),getItemByKey:e=>r().itemStoresByKey.get(e)?.read(),reconstructSnapshot:()=>au(r()),setConnectionState(e){t({connectionState:e})},setError(e){t({error:e})},setTaskSettings(e){t(t=>t.snapshotMetadata===null?t:{snapshotMetadata:{...t.snapshotMetadata,settings:e}})},taskId:e.taskId}))}function uu(e,t,n){let r=Zl(t),i=r.turnIds.filter(t=>e.turnsById[t]===void 0),a=new Set(i.flatMap(e=>r.itemKeysByTurnId[e]??[])),o=new Map(e.itemStoresByKey);for(let e of a){let t=r.itemStoresByKey.get(e);t!==void 0&&o.set(e,t)}let s={...e.itemKeysByTurnId},c={...e.turnsById};for(let e of i){s[e]=r.itemKeysByTurnId[e]??[];let t=r.turnsById[e];t!==void 0&&(c[e]=t)}let{budget:l,retainedBytesDeltaByItemKey:u}=Ql({previousBudget:{commandOutputAccessByItemKey:new Map,commandOutputAccessSequence:0,commandOutputBytes:0,commandOutputBytesByItemKey:new Map},changedItemStores:n,sourceItemStoresByKey:o,touchedItemKeys:[...a,...e.itemStoresByKey.keys()]}),d=e.retainedBytes-Q(e.turnsNextCursor)+Q(t.snapshot.turnsNextCursor);for(let e of i){d+=Q(c[e]);for(let t of s[e]??[])d+=o.get(t)?.getRetainedBytes()??0}for(let[e,t]of u)a.has(e)||(d+=t);return{...e,...l,checkpoint:e.checkpoint??t.checkpoint,itemKeysByTurnId:s,itemStoresByKey:o,itemStructureRevision:e.itemStructureRevision+1,retainedBytes:d,turnIds:[...i,...e.turnIds],turnsNextCursor:t.snapshot.turnsNextCursor,turnsById:c}}function du(e,t){let n=0;if((t.type===`turn.started`||t.type===`turn.completed`||t.type===`provider.error`)&&(n+=Q(e.turnsById[t.turnId])),(t.type===`task.notice`||t.type===`turn.completed`)&&(n+=e.notices.reduce((e,t)=>e+Q(t),0)),(t.type===`goal.updated`||t.type===`goal.cleared`||t.type===`plan.updated`||t.type===`provider.error`||t.type===`task.status_updated`||t.type===`turn.started`||t.type===`turn.completed`||t.type===`usage.updated`)&&(n+=Q(e.snapshotMetadata)),t.type===`pending_request.created`||t.type===`pending_request.resolved`||t.type===`pending_request.expired`)for(let t of e.pendingRequestIds)n+=Q(e.pendingRequestsById[t]);return n}function fu(e,t){if(t.type===`turn.started`||t.type===`turn.completed`)return e.itemKeysByTurnId[t.turnId]??[];if(!(`itemId`in t)||!(`turnId`in t))return[];let n=[Yl(t.turnId,t.itemId)];if(t.type===`item.started`||t.type===`item.completed`){let r=(e.itemKeysByTurnId[t.turnId]??[]).at(-1);r!==void 0&&n.push(r),n.push(Yl(t.turnId,`submitted-user-${t.turnId}`))}return n}function pu(e,t){return new Map(fu(e,t).map(t=>[t,e.itemStoresByKey.get(t)?.getRetainedBytes()??0]))}function mu(e,t){let n=0;for(let r of t)n+=e.itemStoresByKey.get(r)?.getRetainedBytes()??0;return n}function hu(e){let t=0;for(let n of e.values())t+=n;return t}var gu=class{#e;#t=new Map;#n=new Map;#r;#i;#a;#o=0;constructor(e={}){if(this.#r=e.maxRetainedBytes??67108864,!Number.isSafeInteger(this.#r)||this.#r<0)throw RangeError(`Task store registry maxRetainedBytes must be non-negative`);if(this.#i=e.maxRetainedStores??20,!Number.isInteger(this.#i)||this.#i<0)throw RangeError(`Task store registry maxRetainedStores must be a non-negative integer`);this.#e=e.createStore??(e=>lu(e)),this.#a=e.onEvict}acquire(e,t){let n=_u(e,t),r=this.#t.get(n);return r===void 0?(r={consumers:0,identity:{projectId:e,taskId:t},retainedBytes:0,store:this.#e({projectId:e,taskId:t})},this.#t.set(n,r)):r.consumers===0&&this.#c(n,r),r.consumers+=1,r.store}release(e,t){let n=this.#t.get(_u(e,t));return n===void 0||n.consumers===0?!1:(--n.consumers,n.consumers===0&&(n.retainedBytes=n.store.getState().retainedBytes,this.#n.set(_u(e,t),n),this.#o+=n.retainedBytes,this.#s()),n.consumers===0)}get retainedBytes(){return this.#o}get size(){return this.#t.size}peek(e,t){return this.#t.get(_u(e,t))?.store}remove(e,t){let n=_u(e,t),r=this.#t.get(n);return r===void 0||r.consumers>0?!1:(this.#c(n,r),this.#t.delete(n),this.#a?.(r.identity,r.store),!0)}#s(){for(;this.#n.size>this.#i||this.#o>this.#r;){let e=this.#n.entries().next().value;if(e===void 0)return;let[t,n]=e;this.#c(t,n),this.#t.delete(t),this.#a?.(n.identity,n.store)}}#c(e,t){this.#n.delete(e)&&(this.#o-=t.retainedBytes,t.retainedBytes=0)}};function _u(e,t){return JSON.stringify([e,t])}function vu(e={}){return new gu(e)}var yu=vu({maxRetainedStores:20}),bu=lu({projectId:``,taskId:``});function xu(e,t,n){let r=le(),i=n.client,a=`${e}\u0000${t??``}`,[o,s]=(0,J.useState)({error:null,isPending:t!==void 0,scope:a}),[c,l]=(0,J.useState)(),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(null),m=(0,J.useRef)(null),h=c??bu,g=Ml(h,e=>e.turnIds.findLast(t=>e.turnsById[t]?.status===`running`)),_=Ml(h,e=>e.connectionState),v=Ml(h,e=>e.error),y=Ml(h,e=>e.snapshotMetadata??void 0),b=Ml(h,e=>e.itemStructureRevision),x=Ml(h,e=>e.turnsNextCursor);(0,J.useEffect)(()=>{m.current=null,d(!1),p(null)},[e,t]),(0,J.useEffect)(()=>{if(t===void 0){l(void 0);return}let n=yu.acquire(e,t);return l(n),()=>{yu.release(e,t)}},[e,t]),(0,J.useEffect)(()=>{if(c===void 0||t===void 0)return;let o=c.getState();if(o.projectId!==e||o.taskId!==t)return;let l=new AbortController,u=_s(e,t,i).queryKey,d,f=!1;s({error:null,isPending:!0,scope:a});let p=Su(r,u);return(p===void 0?i.readTask(e,t,{signal:l.signal}):Promise.resolve(p)).then(o=>{f||(d=n.attachTaskStore(o,c,()=>i.readTask(e,t)),r.removeQueries({exact:!0,queryKey:u}),s({error:null,isPending:!1,scope:a}))}).catch(e=>{!f&&!l.signal.aborted&&s({error:e instanceof Error?e:Error(String(e)),isPending:!1,scope:a})}),()=>{f=!0,l.abort(),d?.()}},[i,e,n,r,c,t,a]);let S=c===void 0?void 0:wu(c,e,t),C=(0,J.useCallback)(async()=>{if(S===void 0||t===void 0||x===null||m.current!==null)return;let n={};m.current=n,d(!0),p(null);try{let n=await i.readTask(e,t,{cursor:x});S.getState().prependHistory(n)}catch(e){m.current===n&&p(e instanceof Error?e:Error(String(e)))}finally{m.current===n&&(m.current=null,d(!1))}},[S,i,e,t,x]),w=S?.getState().snapshotMetadata!==null,T=o.scope===a?o.error:null,E=t!==void 0&&(o.scope!==a||o.isPending),D=S===void 0||!w?T:_===`closed`?v:null,O=(0,J.useCallback)(()=>S?.getState().reconstructSnapshot(),[S]),k=Tu({error:D,hasActiveRuntime:S!==void 0,hasHydratedSnapshot:w,snapshotPending:E});return(0,J.useMemo)(()=>({activeTurnId:g,connectionState:S===void 0?`connecting`:_,error:D,hasOlderHistory:x!==null,isLoadingOlderHistory:u,isPending:k,itemStructureRevision:b,loadOlderHistory:C,metadata:y,olderHistoryError:f,readSnapshot:O,store:S}),[S,g,_,D,u,k,b,C,y,f,O,x])}function Su(e,t){let n=e.getQueryData(t);return n!==void 0&&e.removeQueries({exact:!0,queryKey:t}),n}function Cu(e,t){return yu.remove(e,t)}function wu(e,t,n){let r=e?.getState();return n!==void 0&&r?.projectId===t&&r.taskId===n?e:void 0}function Tu(e){return e.error!==null||e.hasHydratedSnapshot?!1:e.snapshotPending||!e.hasActiveRuntime}var Eu=8;function Du(e,t,n,r){if(t===n||!e.includes(t))return e;let i=e.filter(e=>e!==t),a=i.indexOf(n);if(a===-1)return e;let o=r===`after`?a+1:a;return i.toSpliced(o,0,t)}function Ou(e,t,n){let r=e.indexOf(t),i=r+n;return r===-1||i<0||i>=e.length?e:e.toSpliced(r,1).toSpliced(i,0,t)}function ku(e,t){if(t===null)return e;let n=new Map(e.map(e=>[e.id,e])),r=t.flatMap(e=>{let t=n.get(e);return t===void 0?[]:[t]}),i=new Set(r.map(e=>e.id));return[...r,...e.filter(e=>!i.has(e.id))]}function Au({disabled:e=!1,onReorder:t,projects:n}){let{t:r}=s(`conversation`),[i,a]=(0,J.useState)(null),[o,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(null),d=(0,J.useRef)(null),f=(0,J.useRef)(null),p=ku(n,l),m=(0,J.useRef)(p);m.current=p;let h=e=>{let t=d.current;t!==null&&(t.removeGlobalListeners(),e&&t.element.hasPointerCapture(t.pointerId)&&t.element.releasePointerCapture(t.pointerId),d.current=null)};(0,J.useEffect)(()=>()=>{h(!1)},[]);let g=async(e,i)=>{let a=await t(e);if(u(null),a){let t=n.find(e=>e.id===i),a=e.indexOf(i)+1;c(r(`reorder.moved`,{name:t?.name??r(`reorder.projectFallback`),position:a}))}},_=(t,n)=>{if(e||t.button!==0)return;h(!0),t.currentTarget.setPointerCapture(t.pointerId);let r=t.currentTarget,i=e=>{y(e.pointerId)},a=e=>{b(e.pointerId)},o={activated:!1,element:r,pointerId:t.pointerId,projectId:n,removeGlobalListeners:()=>{window.removeEventListener(`pointercancel`,a),window.removeEventListener(`pointerup`,i)},startClientX:t.clientX,startClientY:t.clientY};d.current=o,window.addEventListener(`pointercancel`,a),window.addEventListener(`pointerup`,i)},v=e=>{let t=d.current;if(t?.pointerId!==e.pointerId)return;let n=Math.hypot(e.clientX-t.startClientX,e.clientY-t.startClientY);if(!t.activated){if(n<=Eu)return;t.activated=!0,t.element.hasPointerCapture(t.pointerId)&&t.element.releasePointerCapture(t.pointerId),u(m.current.map(e=>e.id)),a(t.projectId),c(r(`reorder.started`))}e.preventDefault();let i=document.elementFromPoint(e.clientX,e.clientY)?.closest(`[data-project-reorder-id]`)??null;if(i===null)return;let o=i.dataset.projectReorderId;if(o===void 0)return;let s=i.getBoundingClientRect(),l=e.clientY<s.top+s.height/2?`before`:`after`;u(e=>e===null?e:Du(e,t.projectId,o,l))},y=e=>{let t=d.current;if(t?.pointerId!==e)return;let n=t.activated;if(h(!0),!n)return;f.current=t.projectId,a(null);let r=m.current.map(e=>e.id);g(r,t.projectId)},b=e=>{d.current?.pointerId===e&&(h(!1),a(null),u(null),c(r(`reorder.cancelled`)))},x=e=>{y(e.pointerId)},S=e=>{b(e.pointerId)},C=(e,t)=>{f.current===t&&(f.current=null,e.preventDefault(),e.stopPropagation())},w=(t,n)=>{if(e||!t.altKey||t.key!==`ArrowUp`&&t.key!==`ArrowDown`)return;t.preventDefault();let r=m.current.map(e=>e.id),i=Ou(r,n,t.key===`ArrowUp`?-1:1);i!==r&&(u(i),g(i,n))};return{activeProjectId:i,announcement:o,getProjectReorderProps:e=>({"aria-keyshortcuts":`Alt+ArrowUp Alt+ArrowDown`,"data-project-reorder-id":e,onClickCapture:t=>{C(t,e)},onKeyDown:t=>{w(t,e)},onPointerCancel:S,onPointerDown:t=>{_(t,e)},onPointerMove:v,onPointerUp:x,title:r(`reorder.title`)}),orderedProjects:p}}function ju({actionLock:e,activeProjectId:t,activeTaskId:n}){let{client:r}=Ds(),{forgetTask:i}=Os(),a=qi(),o=le(),[s,c]=(0,J.useState)(null),l=q(Wo(r));return{closeTaskDeletion:()=>{l.isPending||c(null)},confirmTaskDeletion:()=>{let u=s;return u===null?Promise.resolve(void 0):e.run(async()=>{try{await l.mutateAsync({projectId:u.projectId,taskId:u.id}),c(null),await Ro(o,u.projectId,u.id).catch(()=>void 0),o.removeQueries({exact:!0,queryKey:[`projects`,u.projectId,`tasks`,u.id]}),i(u.projectId,u.id),Cu(u.projectId,u.id),u.projectId===t&&u.id===n&&await(u.projectId===`temporary`?a({to:`/temporary`}):a({params:{projectId:u.projectId},to:`/p/$projectId`})),r.unsubscribeTask(u.projectId,u.id).catch(()=>void 0)}catch{}})},deletingTask:s,isDeletePending:l.isPending,requestTaskDeletion:c}}var Mu=`codexly:project-sidebar:expanded-projects:v1`,Nu=`codexly:project-sidebar:temporary-tasks-expanded:v1`;function Pu(){try{return typeof window>`u`?void 0:window.localStorage}catch{return}}function Fu(e){if(e===void 0)return null;try{let t=e.getItem(Mu);if(t===null)return null;let n=JSON.parse(t);return Vu(n)?new Set(n.expandedProjectIds):null}catch{return null}}function Iu(e,t){if(e===void 0)return;let n={expandedProjectIds:[...t],version:1};try{e.setItem(Mu,JSON.stringify(n))}catch{}}function Lu(e){if(e===void 0)return!0;try{let t=e.getItem(Nu);if(t===null)return!0;let n=JSON.parse(t);return!Hu(n)||n.expanded}catch{return!0}}function Ru(e,t){if(e===void 0)return;let n={expanded:t,version:1};try{e.setItem(Nu,JSON.stringify(n))}catch{}}function zu(e,t){if(t===null){let t=e[0];return t===void 0?new Set:new Set([t])}return new Set(e.filter(e=>t.has(e)))}function Bu(e,t){let n=zu(e,t);return e.find(e=>n.has(e))??e[0]}function Vu(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.version===1&&Array.isArray(t.expandedProjectIds)&&t.expandedProjectIds.every(e=>typeof e==`string`)}function Hu(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.version===1&&typeof t.expanded==`boolean`}var Uu=Object.defineProperty,Wu=(e,t)=>Uu(e,`name`,{value:t,configurable:!0}),Gu=`Dialog`,[Ku,qu]=S(Gu),[Ju,Yu]=Ku(Gu),Xu=Wu(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=J.useRef(null),c=J.useRef(null),[l,u]=N({prop:r,defaultProp:i??!1,onChange:a,caller:Gu}),[d,f]=J.useState(0),[p,m]=J.useState(0);return(0,X.jsx)(Ju,{scope:t,triggerRef:s,contentRef:c,contentId:E(),titleId:E(),descriptionId:E(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:m,open:l,onOpenChange:u,onOpenToggle:J.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),Zu=`DialogTrigger`,Qu=J.forwardRef(Wu(function(e,t){let{__scopeDialog:n,...r}=e,i=Yu(Zu,n),a=g(t,i.triggerRef);return(0,X.jsx)(D.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":gd(i.open),...r,ref:a,onClick:_(e.onClick,i.onOpenToggle)})},`DialogTrigger`)),$u=`DialogPortal`,[ed,td]=Ku($u,{forceMount:void 0}),nd=Wu(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=Yu($u,t);return(0,X.jsx)(ed,{scope:t,forceMount:n,children:J.Children.map(r,e=>(0,X.jsx)(O,{present:n||a.open,children:(0,X.jsx)(j,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),rd=`DialogOverlay`,id=J.forwardRef(Wu(function(e,t){let n=td(rd,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Yu(rd,e.__scopeDialog);return a.modal?(0,X.jsx)(O,{present:r||a.open,children:(0,X.jsx)(od,{...i,ref:t})}):null},`DialogOverlay`)),ad=y(`DialogOverlay.RemoveScroll`),od=J.forwardRef(Wu(function(e,t){let{__scopeDialog:n,...r}=e,i=Yu(rd,n),a=g(t,x());return(0,X.jsx)(wt,{as:ad,allowPinchZoom:!0,shards:[i.contentRef],children:(0,X.jsx)(D.div,{"data-state":gd(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),sd=`DialogContent`,cd=J.forwardRef(Wu(function(e,t){let n=td(sd,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Yu(sd,e.__scopeDialog);return(0,X.jsx)(O,{present:r||a.open,children:a.modal?(0,X.jsx)(ld,{...i,ref:t}):(0,X.jsx)(ud,{...i,ref:t})})},`DialogContent`)),ld=J.forwardRef(Wu(function(e,t){let n=Yu(sd,e.__scopeDialog),r=J.useRef(null),i=g(t,n.contentRef,r);return J.useEffect(()=>{let e=r.current;if(e)return Et(e)},[]),(0,X.jsx)(dd,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:_(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:_(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:_(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),ud=J.forwardRef(Wu(function(e,t){let n=Yu(sd,e.__scopeDialog),r=J.useRef(!1),i=J.useRef(!1);return(0,X.jsx)(dd,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),dd=J.forwardRef(Wu(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=Yu(sd,n);return Tt(),(0,X.jsx)(X.Fragment,{children:(0,X.jsx)(Ct,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,X.jsx)(b,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":gd(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),fd=`DialogTitle`,pd=J.forwardRef(Wu(function(e,t){let{__scopeDialog:n,...r}=e,i=Yu(fd,n),{setTitleCount:a}=i;return P(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,X.jsx)(D.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),md=`DialogDescription`,hd=J.forwardRef(Wu(function(e,t){let{__scopeDialog:n,...r}=e,i=Yu(md,n),{setDescriptionCount:a}=i;return P(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,X.jsx)(D.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`));function gd(e){return e?`open`:`closed`}Wu(gd,`getState`);var _d=Object.defineProperty,vd=(e,t)=>_d(e,`name`,{value:t,configurable:!0}),yd=`DropdownMenu`,[bd,xd]=S(yd,[Ze]),Sd=Ze(),[Cd,wd]=bd(yd),Td=vd(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=Sd(t),l=J.useRef(null),[u,d]=N({prop:i,defaultProp:a??!1,onChange:o,caller:yd});return(0,X.jsx)(Cd,{scope:t,triggerId:E(),triggerRef:l,contentId:E(),open:u,onOpenChange:d,onOpenToggle:J.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,X.jsx)(st,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})},`DropdownMenu`),Ed=`DropdownMenuTrigger`,Dd=J.forwardRef(vd(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=wd(Ed,n),o=Sd(n),s=g(t,a.triggerRef);return(0,X.jsx)(ot,{asChild:!0,...o,children:(0,X.jsx)(D.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:_(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:_(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),Od=vd(e=>{let{__scopeDropdownMenu:t,...n}=e,r=Sd(t);return(0,X.jsx)(at,{...r,...n})},`DropdownMenuPortal`),kd=`DropdownMenuContent`,Ad=J.forwardRef(vd(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=wd(kd,n),a=Sd(n),o=J.useRef(!1);return(0,X.jsx)(tt,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:_(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:_(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),jd=J.forwardRef(vd(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Sd(n);return(0,X.jsx)(it,{...i,...r,ref:t})},`DropdownMenuGroup`)),Md=J.forwardRef(vd(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Sd(n);return(0,X.jsx)(nt,{...i,...r,ref:t})},`DropdownMenuLabel`)),Nd=J.forwardRef(vd(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Sd(n);return(0,X.jsx)(Qe,{...i,...r,ref:t})},`DropdownMenuItem`)),Pd=J.forwardRef(vd(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Sd(n);return(0,X.jsx)(qe,{...i,...r,ref:t})},`DropdownMenuRadioGroup`)),Fd=J.forwardRef(vd(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Sd(n);return(0,X.jsx)($e,{...i,...r,ref:t})},`DropdownMenuRadioItem`)),Id=J.forwardRef(vd(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Sd(n);return(0,X.jsx)(Ke,{...i,...r,ref:t})},`DropdownMenuItemIndicator`)),Ld=J.forwardRef(vd(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Sd(n);return(0,X.jsx)(Je,{...i,...r,ref:t})},`DropdownMenuSeparator`)),Rd=vd(e=>{let{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:a}=e,o=Sd(t),[s,c]=N({prop:r,defaultProp:a??!1,onChange:i,caller:`DropdownMenuSub`});return(0,X.jsx)(Ye,{...o,open:s,onOpenChange:c,children:n})},`DropdownMenuSub`),zd=J.forwardRef(vd(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Sd(n);return(0,X.jsx)(et,{...i,...r,ref:t})},`DropdownMenuSubTrigger`)),Bd=J.forwardRef(vd(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Sd(n);return(0,X.jsx)(rt,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuSubContent`)),Vd=Td,Hd=Dd,Ud=Od,Wd=Ad,Gd=jd,Kd=Md,qd=Nd,Jd=Pd,Yd=Fd,Xd=Id,Zd=Ld,Qd=Rd,$d=zd,ef=Bd,tf=Object.defineProperty,nf=(e,t)=>tf(e,`name`,{value:t,configurable:!0});function rf(e){let t=J.useRef({value:e,previous:e});return J.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}nf(rf,`usePrevious`);var af=Object.defineProperty,of=(e,t)=>af(e,`name`,{value:t,configurable:!0});function sf(e,[t,n]){return Math.min(n,Math.max(t,e))}of(sf,`clamp`);var cf=Object.defineProperty,$=(e,t)=>cf(e,`name`,{value:t,configurable:!0}),lf=[` `,`Enter`,`ArrowUp`,`ArrowDown`],uf=[` `,`Enter`],df=`Select`,[ff,pf,mf]=Ge(df),[hf,gf]=S(df,[mf,M]),_f=M(),[vf,yf]=hf(df),[bf,xf]=hf(df);function Sf(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m,internal_do_not_use_render:h}=e,g=_f(t),[_,v]=J.useState(null),[y,b]=J.useState(null),[x,S]=J.useState(!1),C=Xe(l),[w,T]=N({prop:r,defaultProp:i??!1,onChange:a,caller:df}),[D,O]=N({prop:o,defaultProp:s,onChange:c,caller:df}),A=J.useRef(null),j=J.useRef(D);J.useEffect(()=>{let e=m?_?.ownerDocument.getElementById(m):_?.form;if(e instanceof HTMLFormElement){let t=$(()=>O(j.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[m,_,O]);let M=!_||!!m||!!_.closest(`form`),[P,F]=J.useState(new Set),I=E(),L=Array.from(P).map(e=>e.props.value).join(`;`),R=J.useCallback(e=>{F(t=>new Set(t).add(e))},[]),z=J.useCallback(e=>{F(t=>{let n=new Set(t);return n.delete(e),n})},[]),B={required:p,trigger:_,onTriggerChange:v,valueNode:y,onValueNodeChange:b,valueNodeHasChildren:x,onValueNodeHasChildrenChange:S,contentId:I,value:D,onValueChange:O,open:w,onOpenChange:T,dir:C,triggerPointerDownPosRef:A,disabled:f,name:u,autoComplete:d,form:m,nativeOptions:P,nativeSelectKey:L,isFormControl:M};return(0,X.jsx)(k,{...g,children:(0,X.jsx)(vf,{scope:t,...B,children:(0,X.jsx)(ff.Provider,{scope:t,children:(0,X.jsx)(bf,{scope:t,onNativeOptionAdd:R,onNativeOptionRemove:z,children:up(h)?h(B):n})})})})}$(Sf,`SelectProvider`);var Cf=$(e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,X.jsx)(Sf,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,X.jsxs)(X.Fragment,{children:[n,e?(0,X.jsx)(lp,{__scopeSelect:t}):null]})})},`Select`),wf=`SelectTrigger`,Tf=J.forwardRef($(function(e,t){let{__scopeSelect:n,disabled:r=!1,...i}=e,a=_f(n),o=yf(wf,n),s=o.disabled||r,c=g(t,o.onTriggerChange),l=pf(n),u=J.useRef(`touch`),[d,f,p]=fp(e=>{let t=l().filter(e=>!e.disabled),n=pp(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=$(e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},`handleOpen`);return(0,X.jsx)(C,{asChild:!0,...a,children:(0,X.jsx)(D.button,{type:`button`,role:`combobox`,"aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":dp(o.value)?``:void 0,...i,ref:c,onClick:_(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:_(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:_(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&lf.includes(e.key)&&(m(),e.preventDefault())})})})},`SelectTrigger`)),Ef=`SelectValue`,Df=J.forwardRef($(function(e,t){let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=yf(Ef,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=g(t,c.onValueNodeChange);P(()=>{l(u)},[l,u]);let f=dp(c.value);return(0,X.jsx)(D.span,{...s,asChild:!f&&s.asChild,ref:d,style:{pointerEvents:`none`},children:(0,X.jsx)(J.Fragment,{children:f?o:a},f?`placeholder`:`value`)})},`SelectValue`)),Of=J.forwardRef($(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,X.jsx)(D.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})},`SelectIcon`)),[kf,Af]=hf(`SelectPortal`,{forceMount:void 0}),jf=$(e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,X.jsx)(kf,{scope:e.__scopeSelect,forceMount:n,children:(0,X.jsx)(j,{asChild:!0,...r})})},`SelectPortal`),Mf=`SelectContent`,Nf=J.forwardRef($(function(e,t){let n=Af(Mf,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=yf(Mf,e.__scopeSelect),[o,s]=J.useState();return P(()=>{s(new DocumentFragment)},[]),(0,X.jsx)(O,{present:r||a.open,children:({present:e})=>e?(0,X.jsx)(zf,{...i,ref:t}):(0,X.jsx)(Pf,{...i,fragment:o})})},`SelectContent`)),Pf=J.forwardRef($(function(e,t){let{__scopeSelect:n,children:r,fragment:i}=e;return i?Yi.createPortal((0,X.jsx)(If,{scope:n,children:(0,X.jsx)(ff.Slot,{scope:n,children:(0,X.jsx)(`div`,{ref:t,children:r})})}),i):null},`SelectContentFragment`)),Ff=10,[If,Lf]=hf(Mf),Rf=y(`SelectContent.RemoveScroll`),zf=J.forwardRef($(function(e,t){let{__scopeSelect:n}=e,{position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:v,...y}=e,x=yf(Mf,n),[S,C]=J.useState(null),[w,T]=J.useState(null),E=g(t,C),[D,O]=J.useState(null),[k,A]=J.useState(null),j=pf(n),[M,N]=J.useState(!1),P=J.useRef(!1);J.useEffect(()=>{if(S)return Et(S)},[S]),Tt();let F=J.useCallback(e=>{let[t,...n]=j().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&w&&(w.scrollTop=0),n===r&&w&&(w.scrollTop=w.scrollHeight),n?.focus(),document.activeElement!==i))return},[j,w]),I=J.useCallback(()=>F([D,S]),[F,D,S]);J.useEffect(()=>{M&&I()},[M,I]);let{onOpenChange:L,triggerPointerDownPosRef:R}=x;J.useEffect(()=>{if(S){let e={x:0,y:0},t=$(t=>{e={x:Math.abs(Math.round(t.pageX)-(R.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(R.current?.y??0))}},`handlePointerMove`),n=$(n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(S)||L(!1),document.removeEventListener(`pointermove`,t),R.current=null},`handlePointerUp`);return R.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[S,L,R]),J.useEffect(()=>{let e=$(()=>L(!1),`close`);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[L]);let[z,B]=fp(e=>{let t=j().filter(e=>!e.disabled),n=pp(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),V=J.useCallback((e,t,n)=>{let r=!P.current&&!n;(x.value!==void 0&&x.value===t||r)&&(O(e),r&&(P.current=!0))},[x.value]),H=J.useCallback(()=>S?.focus(),[S]),ee=J.useCallback((e,t,n)=>{let r=!P.current&&!n;(x.value!==void 0&&x.value===t||r)&&A(e)},[x.value]),te=r===`popper`?Vf:Bf,ne=te===Vf?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:v}:{};return(0,X.jsx)(If,{scope:n,content:S,viewport:w,onViewportChange:T,itemRefCallback:V,selectedItem:D,onItemLeave:H,itemTextRefCallback:ee,focusSelectedItem:I,selectedItemText:k,position:r,isPositioned:M,searchRef:z,children:(0,X.jsx)(wt,{as:Rf,allowPinchZoom:!0,children:(0,X.jsx)(Ct,{asChild:!0,trapped:x.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:_(i,e=>{x.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,X.jsx)(b,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>x.onOpenChange(!1),children:(0,X.jsx)(te,{role:`listbox`,id:x.contentId,"data-state":x.open?`open`:`closed`,dir:x.dir,onContextMenu:e=>e.preventDefault(),...y,...ne,onPlaced:()=>N(!0),ref:E,style:{display:`flex`,flexDirection:`column`,outline:`none`,...y.style},onKeyDown:_(y.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&B(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=j().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>F(t)),e.preventDefault()}})})})})})})},`SelectContentImpl`)),Bf=J.forwardRef($(function(e,t){let{__scopeSelect:n,onPlaced:r,...i}=e,a=yf(Mf,n),o=Lf(Mf,n),[s,c]=J.useState(null),[l,u]=J.useState(null),d=g(t,u),f=pf(n),p=J.useRef(!1),m=J.useRef(!0),{viewport:h,selectedItem:_,selectedItemText:v,focusSelectedItem:y}=o,b=J.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&_&&v){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=v.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-Ff,d=sf(a,[Ff,Math.max(Ff,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-Ff,d=sf(a,[Ff,Math.max(Ff,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-Ff*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),g=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+g+u+b+y,S=Math.min(_.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-Ff,D=c-E,O=_.offsetHeight/2,k=_.offsetTop+O,A=m+g+k,j=x-A;if(A<=E){let e=o.length>0&&_===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&_===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+j;s.style.height=t+`px`,h.scrollTop=A-E+h.offsetTop}s.style.margin=`${Ff}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,_,v,a.dir,r]);P(()=>b(),[b]);let[x,S]=J.useState();return P(()=>{l&&S(window.getComputedStyle(l).zIndex)},[l]),(0,X.jsx)(Hf,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:J.useCallback(e=>{e&&m.current===!0&&(b(),y?.(),m.current=!1)},[b,y]),children:(0,X.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:x},children:(0,X.jsx)(D.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})},`SelectItemAlignedPosition`)),Vf=J.forwardRef($(function(e,t){let{__scopeSelect:n,align:r=`start`,collisionPadding:i=Ff,...a}=e,o=_f(n);return(0,X.jsx)(v,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})},`SelectPopperPosition`)),[Hf,Uf]=hf(Mf,{}),Wf=`SelectViewport`,Gf=J.forwardRef($(function(e,t){let{__scopeSelect:n,nonce:r,...i}=e,a=Lf(Wf,n),o=Uf(Wf,n),s=g(t,a.onViewportChange),c=J.useRef(0);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,X.jsx)(ff.Slot,{scope:n,children:(0,X.jsx)(D.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:_(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-Ff*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})},`SelectViewport`)),[Kf,qf]=hf(`SelectGroup`),Jf=J.forwardRef($(function(e,t){let{__scopeSelect:n,...r}=e,i=E();return(0,X.jsx)(Kf,{scope:n,id:i,children:(0,X.jsx)(D.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})},`SelectGroup`)),Yf=`SelectItem`,[Xf,Zf]=hf(Yf),Qf=J.forwardRef($(function(e,t){let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=yf(Yf,n),c=Lf(Yf,n),l=s.value===r,[u,d]=J.useState(a??``),[f,p]=J.useState(!1),m=g(t,A(e=>c.itemRefCallback?.(e,r,i))),h=E(),v=J.useRef(`touch`),y=$(()=>{i||(s.onValueChange(r),s.onOpenChange(!1))},`handleSelect`);return(0,X.jsx)(Xf,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:J.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,X.jsx)(ff.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,X.jsx)(D.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:_(o.onFocus,()=>p(!0)),onBlur:_(o.onBlur,()=>p(!1)),onClick:_(o.onClick,()=>{v.current!==`mouse`&&y()}),onPointerUp:_(o.onPointerUp,()=>{v.current===`mouse`&&y()}),onPointerDown:_(o.onPointerDown,e=>{v.current=e.pointerType}),onPointerMove:_(o.onPointerMove,e=>{v.current=e.pointerType,i?c.onItemLeave?.():v.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:_(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:_(o.onKeyDown,e=>{i||e.target!==e.currentTarget||c.searchRef?.current!==``&&e.key===` `||(uf.includes(e.key)&&y(),e.key===` `&&e.preventDefault())})})})})},`SelectItem`)),$f=`SelectItemText`,ep=J.forwardRef($(function(e,t){let{__scopeSelect:n,className:r,style:i,...a}=e,o=yf($f,n),s=Lf($f,n),c=Zf($f,n),l=xf($f,n),[u,d]=J.useState(null),f=A(e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=g(t,d,c.onItemTextChange,f),m=u?.textContent,h=J.useMemo(()=>(0,X.jsx)(`option`,{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:_,onNativeOptionRemove:v}=l;return P(()=>(_(h),()=>v(h)),[_,v,h]),(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(D.span,{id:c.textId,...a,ref:p}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!dp(o.value)?Yi.createPortal(a.children,o.valueNode):null]})},`SelectItemText`)),tp=`SelectItemIndicator`,np=J.forwardRef($(function(e,t){let{__scopeSelect:n,...r}=e;return Zf(tp,n).isSelected?(0,X.jsx)(D.span,{"aria-hidden":!0,...r,ref:t}):null},`SelectItemIndicator`)),rp=`SelectScrollUpButton`,ip=J.forwardRef($(function(e,t){let n=Lf(rp,e.__scopeSelect),r=Uf(rp,e.__scopeSelect),[i,a]=J.useState(!1),o=g(t,r.onScrollButtonChange);return P(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)};$(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,X.jsx)(sp,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null},`SelectScrollUpButton`)),ap=`SelectScrollDownButton`,op=J.forwardRef($(function(e,t){let n=Lf(ap,e.__scopeSelect),r=Uf(ap,e.__scopeSelect),[i,a]=J.useState(!1),o=g(t,r.onScrollButtonChange);return P(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)};$(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,X.jsx)(sp,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null},`SelectScrollDownButton`)),sp=J.forwardRef($(function(e,t){let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=Lf(`SelectScrollButton`,n),o=J.useRef(null),s=pf(n),c=J.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return J.useEffect(()=>()=>c(),[c]),P(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,X.jsx)(D.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:_(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:_(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:_(i.onPointerLeave,()=>{c()})})},`SelectScrollButtonImpl`)),cp=`SelectBubbleInput`,lp=J.forwardRef($(function({__scopeSelect:e,...t},n){let r=yf(cp,e),{value:i,onValueChange:a,required:o,disabled:s,name:c,autoComplete:l,form:u}=r,{nativeOptions:d,nativeSelectKey:f}=r,p=J.useRef(null),m=g(n,p),h=i??``,_=rf(h),v=Array.from(d).some(e=>(e.props.value??``)===``);return J.useEffect(()=>{let e=p.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set;if(_!==h&&n){let t=new Event(`change`,{bubbles:!0});n.call(e,h),e.dispatchEvent(t)}},[_,h]),(0,X.jsxs)(D.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:c,autoComplete:l,disabled:s,form:u,onChange:e=>a(e.target.value),...t,style:{...de,...t.style},ref:m,defaultValue:h,children:[dp(i)&&!v?(0,X.jsx)(`option`,{value:``}):null,Array.from(d)]},f)},`SelectBubbleInput`));function up(e){return typeof e==`function`}$(up,`isFunction`);function dp(e){return e===``||e===void 0}$(dp,`shouldShowPlaceholder`);function fp(e){let t=A(e),n=J.useRef(``),r=J.useRef(0),i=J.useCallback(e=>{let i=n.current+e;t(i),$((function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(i)},[t]),a=J.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return J.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}$(fp,`useTypeaheadSearch`);function pp(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=mp(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}$(pp,`findNextItem`);function mp(e,t){return e.map((n,r)=>e[(t+r)%e.length])}$(mp,`wrapArray`);function hp(e){return(0,X.jsx)(Xu,{"data-slot":`dialog`,...e})}function gp(e){return(0,X.jsx)(Qu,{"data-slot":`dialog-trigger`,...e})}function _p({children:e,...t}){return typeof document>`u`?(0,X.jsx)(X.Fragment,{children:e}):(0,X.jsx)(nd,{"data-slot":`dialog-portal`,...t,children:e})}function vp({className:e,...t}){return(0,X.jsx)(id,{className:L(`fixed inset-0 z-50 bg-scrim data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),"data-slot":`dialog-overlay`,...t})}function yp({children:e,className:t,...n}){return(0,X.jsxs)(_p,{children:[(0,X.jsx)(vp,{}),(0,X.jsx)(cd,{className:L(`fixed left-1/2 top-1/2 z-50 grid min-w-0 max-h-[calc(100dvh-2rem)] w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 overflow-auto rounded-surface bg-dialog p-5 text-foreground shadow-panel outline-none duration-180 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,t),"data-slot":`dialog-content`,...n,children:e})]})}function bp({className:e,...t}){return(0,X.jsx)(`div`,{className:L(`flex flex-col gap-1 text-left`,e),"data-slot":`dialog-header`,...t})}function xp({className:e,...t}){return(0,X.jsx)(`div`,{className:L(`flex justify-end gap-2`,e),"data-slot":`dialog-footer`,...t})}function Sp({className:e,...t}){return(0,X.jsx)(pd,{className:L(`text-heading font-semibold leading-tight`,e),"data-slot":`dialog-title`,...t})}function Cp({className:e,...t}){return(0,X.jsx)(hd,{className:L(`text-body-small text-muted-foreground`,e),"data-slot":`dialog-description`,...t})}function wp({draftPath:e,isPathValidated:t,requestedPath:n,selectedPaths:r,submittedPath:i,validatedPath:a}){return r.length>0?r:!t||e!==void 0||i===void 0||n!==i||a===void 0?[]:[a]}var Tp=`flex cursor-default items-center justify-center py-1 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`;function Ep({...e}){return(0,X.jsx)(Cf,{"data-slot":`select`,...e})}function Dp({...e}){return(0,X.jsx)(Jf,{"data-slot":`select-group`,...e})}function Op({...e}){return(0,X.jsx)(Df,{"data-slot":`select-value`,...e})}function kp({className:e,size:t=`default`,children:n,...r}){return(0,X.jsxs)(Tf,{"data-slot":`select-trigger`,"data-size":t,className:L(`flex w-fit items-center justify-between gap-2 whitespace-nowrap rounded-control border border-separator-strong bg-panel px-3 py-2 text-label outline-none transition-colors focus:border-brand focus:shadow-focus disabled:cursor-not-allowed disabled:opacity-50 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg]:text-muted-foreground [&_svg:not([class*='size-'])]:size-4`,t===`toolbar`&&`h-6 gap-1 px-1 text-caption [&_svg:not([class*='size-'])]:size-3`,e),...r,children:[n,(0,X.jsx)(Of,{asChild:!0,children:(0,X.jsx)(Ve,{className:`opacity-50`})})]})}function Ap({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...i}){return(0,X.jsx)(jf,{children:(0,X.jsxs)(Nf,{"data-slot":`select-content`,className:L(`relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-control border border-separator bg-raised text-foreground shadow-panel data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...i,children:[(0,X.jsx)(Mp,{}),(0,X.jsx)(Gf,{className:L(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,X.jsx)(Np,{})]})})}function jp({className:e,children:t,...n}){return(0,X.jsxs)(Qf,{"data-slot":`select-item`,className:L(`relative flex w-full cursor-default items-center gap-2 rounded-control py-1.5 pr-8 pl-2 text-label outline-hidden select-none focus:bg-control-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg]:text-muted-foreground [&_svg:not([class*='size-'])]:size-3.5`,e),...n,children:[(0,X.jsx)(`span`,{"data-slot":`select-item-indicator`,className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,X.jsx)(np,{children:(0,X.jsx)(We,{})})}),(0,X.jsx)(ep,{children:t})]})}function Mp({className:e,...t}){return(0,X.jsx)(ip,{"data-slot":`select-scroll-up-button`,className:L(Tp,e),...t,children:(0,X.jsx)(ut,{})})}function Np({className:e,...t}){return(0,X.jsx)(op,{"data-slot":`select-scroll-down-button`,className:L(Tp,e),...t,children:(0,X.jsx)(Ve,{})})}function Pp(e,t){let n=t.toLowerCase();return e.find(e=>n.startsWith(e.path.toLowerCase()))}function Fp({disabled:e,includeHidden:t,labels:n,listing:r,onNavigateParent:i,onNavigatePath:a,onNavigateRoot:o,onPathChange:s,onToggleHidden:c,path:l}){let u=r===void 0?void 0:Pp(r.roots,r.path)?.path,d=t?n.hideHidden:n.showHidden;return(0,X.jsxs)(`div`,{className:`flex min-h-10 items-center gap-2 border-y border-separator bg-panel px-3 sm:px-4`,children:[r===void 0||r.roots.length<2?null:(0,X.jsxs)(Ep,{disabled:e,onValueChange:o,...u===void 0?{}:{value:u},children:[(0,X.jsx)(kp,{"aria-label":n.filesystemRoot,className:`h-8 min-w-20 px-2 font-mono`,size:`sm`,children:(0,X.jsx)(Op,{placeholder:n.filesystemRoot})}),(0,X.jsx)(Ap,{position:`popper`,children:r.roots.map(e=>(0,X.jsx)(jp,{value:e.path,children:e.name},e.path))})]}),(0,X.jsxs)(De,{children:[(0,X.jsx)(he,{asChild:!0,children:(0,X.jsx)(F,{"aria-label":n.parent,disabled:r?.parentPath===null||r===void 0||e,onClick:i,size:`icon-sm`,type:`button`,variant:`ghost`,children:(0,X.jsx)(Le,{"aria-hidden":`true`})})}),(0,X.jsx)(ve,{children:n.parent})]}),(0,X.jsxs)(`form`,{className:`flex min-w-0 flex-1 items-center gap-1`,onSubmit:e=>{e.preventDefault(),a()},children:[(0,X.jsx)(vt,{"aria-label":n.pathLabel,autoComplete:`off`,className:`h-8 min-w-0 px-2 font-mono text-caption max-workbench:h-11`,disabled:e,onChange:e=>{s(e.target.value)},placeholder:n.pathPlaceholder,spellCheck:!1,value:l,variant:`compact`}),(0,X.jsxs)(De,{children:[(0,X.jsx)(he,{asChild:!0,children:(0,X.jsx)(F,{"aria-label":n.goToPath,disabled:l.trim().length===0||e,size:`icon-sm`,type:`submit`,variant:`ghost`,children:(0,X.jsx)(tl,{"aria-hidden":`true`})})}),(0,X.jsx)(ve,{children:n.goToPath})]})]}),(0,X.jsxs)(De,{children:[(0,X.jsx)(he,{asChild:!0,children:(0,X.jsx)(F,{"aria-label":d,"aria-pressed":t,disabled:e,onClick:c,size:`icon-sm`,type:`button`,variant:`ghost`,children:t?(0,X.jsx)(sl,{"aria-hidden":`true`}):(0,X.jsx)(cl,{"aria-hidden":`true`})})}),(0,X.jsx)(ve,{children:d})]})]})}function Ip({directoryStates:e,entries:t,expandedPaths:n,onRetry:r,onRootCheckedChange:i,selectedPaths:a,selectionDisabled:o=!1}){let{t:c}=s(`workbench`);return t.map(t=>{let s=e.get(t.path),l=n.has(t.path);return(0,X.jsx)(lt,{name:t.name,path:t.path,selectionControl:(0,X.jsx)(ze,{"aria-label":c(`projectPicker.selectRoot`,{name:t.name}),checked:a.has(t.path),disabled:o,onCheckedChange:e=>{i(t.path,e===!0)}}),trailing:l&&s?.isFetching===!0?(0,X.jsx)(Ue,{"aria-hidden":`true`,className:`size-3.5 animate-spin text-muted-foreground`}):void 0,children:l?s?.error!==null&&s?.error!==void 0?(0,X.jsxs)(`div`,{className:`flex min-h-9 items-center justify-between gap-2 px-2 py-1`,children:[(0,X.jsx)(`p`,{className:`min-w-0 text-caption text-danger`,role:`alert`,children:c(`projectPicker.loadBranchError`)}),(0,X.jsxs)(F,{className:`shrink-0`,onClick:()=>{r(t.path)},size:`sm`,type:`button`,variant:`ghost`,children:[(0,X.jsx)(_l,{"aria-hidden":`true`,"data-icon":`inline-start`}),c(`actions.retry`)]})]}):s?.data===void 0?(0,X.jsx)(`p`,{className:`px-2 py-1.5 text-caption text-muted-foreground`,role:`status`,children:c(`projectPicker.loadingBranch`)}):s.data.entries.length===0?(0,X.jsx)(`p`,{className:`px-2 py-1.5 text-caption text-muted-foreground`,children:c(`projectPicker.empty`)}):(0,X.jsx)(Ip,{directoryStates:e,entries:s.data.entries,expandedPaths:n,onRetry:r,onRootCheckedChange:i,selectedPaths:a,selectionDisabled:o}):null},t.path)})}function Lp({directoryStates:e,expandedPaths:t,listing:n,onExpandedChange:r,onRetry:i,onRootCheckedChange:a,selectedPaths:o,selectionDisabled:c=!1}){let{t:l}=s(`workbench`),u=(0,J.useMemo)(()=>new Map(e.map(e=>[e.path,e])),[e]);return(0,X.jsx)(ft,{"aria-label":l(`projectPicker.treeLabel`),expanded:t,onExpandedChange:r,children:(0,X.jsx)(Ip,{directoryStates:u,entries:n.entries,expandedPaths:t,onRetry:i,onRootCheckedChange:a,selectedPaths:o,selectionDisabled:c})})}function Rp({client:e,isAdding:t,onAdd:n,onClose:r}){let{t:i}=s(`workbench`),[a,o]=(0,J.useState)(),[c,l]=(0,J.useState)(),[u,d]=(0,J.useState)(),[f,p]=(0,J.useState)(!1),[m,h]=(0,J.useState)(()=>new Set),[g,_]=(0,J.useState)([]),v=He({queryFn:({signal:t})=>e.listProjectDirectories(a,{includeHidden:f,signal:t}),queryKey:[`project-directories`,a??null,f],staleTime:3e4}),y=v.data,b=wp({draftPath:c,isPathValidated:v.isSuccess,requestedPath:a,selectedPaths:g,submittedPath:u,validatedPath:y?.path}),x=b.length>0,S=g.length===0&&b.length===1,C=(0,J.useMemo)(()=>new Set(g),[g]),w=S?b[0]??``:g.map((e,t)=>t===0?i(`projectPicker.primaryRootSummary`,{path:e}):e).join(i(`projectPicker.rootSeparator`)),T=(0,J.useMemo)(()=>[...m],[m]),E=Ra({queries:T.map(t=>({queryFn:({signal:n})=>e.listProjectDirectories(t,{includeHidden:f,signal:n}),queryKey:[`project-directories`,t,f],staleTime:3e4}))}),D=T.map((e,t)=>{let n=E[t];return{...n?.data===void 0?{}:{data:n.data},error:n?.error??null,isFetching:n?.isFetching??!1,path:e}}),O=c??a??y?.path??``;return(0,X.jsx)(hp,{onOpenChange:e=>{!e&&!t&&r()},open:!0,children:(0,X.jsxs)(yp,{"aria-labelledby":`project-directory-picker-title`,className:`grid h-[min(84dvh,42rem)] max-w-2xl grid-rows-[auto_auto_minmax(0,1fr)_auto] gap-0 overflow-hidden p-0`,onEscapeKeyDown:e=>{t&&e.preventDefault()},onInteractOutside:e=>{t&&e.preventDefault()},children:[(0,X.jsxs)(bp,{className:`px-4 pb-3 pt-4 sm:px-5 sm:pt-5`,children:[(0,X.jsx)(Sp,{id:`project-directory-picker-title`,children:i(`projectPicker.title`)}),(0,X.jsx)(Cp,{className:`sr-only`,children:i(`projectPicker.description`)})]}),(0,X.jsx)(Fp,{disabled:t,includeHidden:f,labels:{filesystemRoot:i(`projectPicker.filesystemRoot`),goToPath:i(`projectPicker.goToPath`),hideHidden:i(`projectPicker.hideHidden`),parent:i(`projectPicker.parent`),pathLabel:i(`projectPicker.pathLabel`),pathPlaceholder:i(`projectPicker.pathPlaceholder`),showHidden:i(`projectPicker.showHidden`)},listing:y,onNavigateParent:()=>{let e=y?.parentPath;e!=null&&(o(e),l(void 0),d(void 0),h(new Set),_([]))},onNavigatePath:()=>{let e=O.trim();e.length!==0&&(o(e),l(void 0),d(e),h(new Set),_([]))},onNavigateRoot:e=>{o(e),l(void 0),d(void 0),h(new Set),_([])},onPathChange:e=>{l(e),d(void 0)},onToggleHidden:()=>{p(e=>!e),_([])},path:O}),(0,X.jsx)(`div`,{className:`min-h-0 overflow-y-auto px-3 py-2 sm:px-4`,children:v.isPending?(0,X.jsxs)(`p`,{className:`flex min-h-32 items-center justify-center gap-2 text-body-small text-muted-foreground`,role:`status`,children:[(0,X.jsx)(Ue,{"aria-hidden":`true`,className:`size-4 animate-spin`}),i(`projectPicker.loading`)]}):v.error===null?y===void 0?null:y.entries.length===0?(0,X.jsx)(`p`,{className:`grid min-h-32 place-items-center text-body-small text-muted-foreground`,children:i(`projectPicker.empty`)}):(0,X.jsx)(Lp,{directoryStates:D,expandedPaths:m,listing:y,onExpandedChange:h,onRetry:e=>{let t=T.indexOf(e);E[t]?.refetch()},onRootCheckedChange:(e,t)=>{d(void 0),_(n=>Lc(n,e,t))},selectedPaths:C,selectionDisabled:t}):(0,X.jsxs)(`div`,{className:`flex min-h-32 flex-col items-center justify-center gap-3 text-center`,children:[(0,X.jsx)(`p`,{className:`text-body-small text-danger`,role:`alert`,children:i(`projectPicker.loadError`)}),(0,X.jsxs)(F,{onClick:()=>void v.refetch(),type:`button`,variant:`outline`,children:[(0,X.jsx)(_l,{"aria-hidden":`true`,"data-icon":`inline-start`}),i(`actions.retry`)]})]})}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 border-t border-separator bg-raised px-4 py-3 sm:flex-row sm:items-center sm:px-5`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,X.jsx)(`p`,{"aria-live":`polite`,className:`text-caption text-muted-foreground`,children:S?i(`projectPicker.directPathReady`):i(`projectPicker.selectedRoots`,{count:g.length})}),S?null:(0,X.jsx)(`p`,{className:`ml-auto text-right text-caption text-muted-foreground`,children:i(`projectPicker.primaryRootHint`)})]}),w.length===0?null:(0,X.jsx)(`p`,{className:`min-w-0 break-words font-mono text-caption text-foreground [overflow-wrap:anywhere]`,children:w})]}),(0,X.jsxs)(xp,{className:`w-full flex-col-reverse sm:w-auto sm:flex-row`,children:[(0,X.jsx)(F,{className:`h-10 w-full sm:h-8 sm:w-auto`,disabled:t,onClick:r,type:`button`,variant:`outline`,children:i(`actions.cancel`)}),(0,X.jsxs)(F,{className:`h-10 w-full sm:h-8 sm:w-auto`,disabled:!x||t,onClick:()=>{b.length>0&&n(b)},type:`button`,children:[t?(0,X.jsx)(Ue,{"aria-hidden":`true`,className:`animate-spin`,"data-icon":`inline-start`}):(0,X.jsx)(ll,{"aria-hidden":`true`,"data-icon":`inline-start`}),i(t?`projectPicker.adding`:`projectPicker.add`)]})]})]})]})})}function zp({isPending:e,onClose:t,onRemove:n,project:r}){let{t:i}=s(`workbench`);return(0,X.jsx)(hp,{onOpenChange:n=>{!n&&!e&&t()},open:!0,children:(0,X.jsxs)(yp,{"aria-labelledby":`project-remove-title`,className:`max-w-96 p-4`,onEscapeKeyDown:t=>{e&&t.preventDefault()},onInteractOutside:t=>{e&&t.preventDefault()},children:[(0,X.jsxs)(bp,{children:[(0,X.jsx)(Sp,{id:`project-remove-title`,children:i(`projectDialog.remove`)}),(0,X.jsx)(Cp,{children:i(`projectDialog.removeDescription`,{name:r.name})})]}),(0,X.jsxs)(xp,{children:[(0,X.jsx)(F,{className:`h-8 rounded-control px-3 text-body-small text-muted-foreground hover:bg-control-hover hover:text-foreground`,disabled:e,onClick:t,type:`button`,variant:`ghost`,children:i(`actions.cancel`)}),(0,X.jsx)(F,{disabled:e,onClick:n,type:`button`,variant:`destructive`,children:i(`projectDialog.delete`)})]})]})})}function Bp({initialName:e,isPending:t,onClose:n,onRename:r}){let{t:i}=s(`workbench`),[a,o]=(0,J.useState)(e),c=a.trim();return(0,X.jsx)(hp,{onOpenChange:e=>{!e&&!t&&n()},open:!0,children:(0,X.jsx)(yp,{"aria-labelledby":`project-rename-title`,className:`max-w-96 p-4`,onEscapeKeyDown:e=>{t&&e.preventDefault()},onInteractOutside:e=>{t&&e.preventDefault()},children:(0,X.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault(),c.length>0&&r(c)},children:[(0,X.jsxs)(bp,{children:[(0,X.jsx)(Sp,{id:`project-rename-title`,children:i(`projectDialog.rename`)}),(0,X.jsx)(Cp,{children:i(`projectDialog.renameDescription`)})]}),(0,X.jsx)(vt,{"aria-label":i(`projectDialog.name`),autoFocus:!0,disabled:t,maxLength:200,onChange:e=>{o(e.currentTarget.value)},value:a}),(0,X.jsxs)(xp,{children:[(0,X.jsx)(F,{disabled:t,onClick:n,type:`button`,variant:`ghost`,children:i(`actions.cancel`)}),(0,X.jsx)(F,{disabled:t||c.length===0||c===e,type:`submit`,children:i(`actions.save`)})]})]})})})}function Vp({initialTitle:e,isPending:t,onClose:n,onRename:r}){let{t:i}=s(`workbench`),[a,o]=(0,J.useState)(e);return(0,X.jsx)(hp,{onOpenChange:e=>{!e&&!t&&n()},open:!0,children:(0,X.jsx)(yp,{"aria-labelledby":`task-rename-title`,className:`max-w-96 p-4`,onEscapeKeyDown:e=>{t&&e.preventDefault()},onInteractOutside:e=>{t&&e.preventDefault()},children:(0,X.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault();let t=a.trim();t.length>0&&r(t)},children:[(0,X.jsx)(bp,{children:(0,X.jsx)(Sp,{id:`task-rename-title`,children:i(`taskDialog.rename`)})}),(0,X.jsx)(vt,{"aria-label":i(`taskDialog.name`),autoFocus:!0,disabled:t,maxLength:200,onChange:e=>{o(e.currentTarget.value)},value:a}),(0,X.jsxs)(xp,{children:[(0,X.jsx)(F,{disabled:t,onClick:n,type:`button`,variant:`ghost`,children:i(`actions.cancel`)}),(0,X.jsx)(F,{disabled:t||a.trim().length===0,type:`submit`,children:i(`actions.save`)})]})]})})})}function Hp({client:e,isProjectActionPending:t,isProjectAddPending:n,isProjectPickerOpen:r,onAddProject:i,onCloseProjectDialog:a,onCloseProjectPicker:o,onCloseTaskRename:s,onRemoveProject:c,onRenameProject:l,onRenameTask:u,removingProject:d,renamingProject:f,renamingTask:p,taskRenamePending:m}){return(0,X.jsxs)(X.Fragment,{children:[p===null?null:(0,X.jsx)(Vp,{initialTitle:p.title,isPending:m,onClose:s,onRename:e=>{u(p,e)}},p.id),r?(0,X.jsx)(Rp,{client:e,isAdding:n,onAdd:i,onClose:o}):null,f===null?null:(0,X.jsx)(Bp,{initialName:f.name,isPending:t,onClose:()=>{a(f.id)},onRename:e=>{l(f,e)}},f.id),d===null?null:(0,X.jsx)(zp,{isPending:t,onClose:()=>{a(d.id)},onRemove:()=>{c(d)},project:d},d.id)]})}var Up=4,Wp=100;async function Gp(e,t){let n=new Set,r=new Set,i;for(;;){let a=await e.listTasks(t,{archived:!0,...i===void 0?{}:{cursor:i},limit:Wp});for(let e of a.data)n.add(e.id);if(a.nextCursor===null)break;if(r.has(a.nextCursor))throw Error(`Archived task pagination returned a repeated cursor`);r.add(a.nextCursor),i=a.nextCursor}return[...n]}async function Kp(e,t){let n=await Gp(e,t),r;for(let i=0;i<n.length;i+=Up){let a=n.slice(i,i+Up),o=await Promise.allSettled(a.map(n=>e.deleteTask(t,n)));for(let e of o)e.status===`rejected`&&r===void 0&&(r=e.reason instanceof Error?e.reason:Error(String(e.reason)))}if(r!==void 0)throw r}function qp({confirmLabel:e,description:t,isPending:n,onClose:r,onConfirm:i,title:a}){let{t:o}=s(`workbench`);return(0,X.jsx)(hp,{onOpenChange:e=>{!e&&!n&&r()},open:!0,children:(0,X.jsxs)(yp,{"aria-labelledby":`task-delete-confirmation-title`,className:`max-w-96 p-4`,onEscapeKeyDown:e=>{n&&e.preventDefault()},onInteractOutside:e=>{n&&e.preventDefault()},children:[(0,X.jsxs)(bp,{children:[(0,X.jsx)(Sp,{id:`task-delete-confirmation-title`,children:a}),(0,X.jsx)(Cp,{children:t})]}),(0,X.jsxs)(xp,{children:[(0,X.jsx)(F,{disabled:n,onClick:r,type:`button`,variant:`ghost`,children:o(`actions.cancel`)}),(0,X.jsx)(F,{disabled:n,onClick:i,type:`button`,variant:`destructive`,children:e})]})]})})}function Jp({isPending:e,onClose:t,onDelete:n,task:r}){let{t:i}=s(`workbench`);return(0,X.jsx)(qp,{confirmLabel:i(`sidebar.deletePermanently`),description:i(`sidebar.deleteTaskDescription`,{task:r.title}),isPending:e,onClose:t,onConfirm:n,title:i(`sidebar.deleteTaskTitle`)})}function Yp({error:e,isPending:t,mutationPending:n,onDelete:r,onDeleteAll:i,onNext:a,onPrevious:o,onRestore:c,onRetry:l,page:u,pageNumber:d}){let{t:f}=s(`workbench`);return t?(0,X.jsxs)(`div`,{className:`flex min-h-48 items-center justify-center`,role:`status`,children:[(0,X.jsx)(Ue,{className:`size-5 animate-spin text-muted-foreground`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`sr-only`,children:f(`archivedTasks.loading`)})]}):e===null?(0,X.jsxs)(`div`,{className:`grid min-h-0 grid-rows-[minmax(0,1fr)_auto]`,children:[u?.data.length===0?(0,X.jsx)(`p`,{className:`flex min-h-48 items-center justify-center px-4 text-body-small text-muted-foreground`,children:f(`archivedTasks.empty`)}):(0,X.jsx)(`ul`,{className:`min-h-0 overflow-y-auto`,children:u?.data.map(e=>(0,X.jsxs)(`li`,{className:`flex min-h-14 min-w-0 items-center gap-3 px-4 py-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`p`,{className:`truncate text-body-small font-medium text-foreground`,children:e.title}),(0,X.jsx)(`p`,{className:`text-caption text-muted-foreground`,children:f(`archivedTasks.updatedAt`,{date:new Date(e.updatedAt).toLocaleString()})})]}),(0,X.jsxs)(De,{children:[(0,X.jsx)(he,{asChild:!0,children:(0,X.jsx)(F,{"aria-label":f(`archivedTasks.restoreTask`,{task:e.title}),disabled:n,onClick:()=>{c(e)},size:`icon-sm`,type:`button`,variant:`ghost`,children:(0,X.jsx)(Qc,{"aria-hidden":`true`})})}),(0,X.jsx)(ve,{children:f(`archivedTasks.restore`)})]}),(0,X.jsxs)(De,{children:[(0,X.jsx)(he,{asChild:!0,children:(0,X.jsx)(F,{"aria-label":f(`archivedTasks.deleteTask`,{task:e.title}),disabled:n,onClick:()=>{r(e)},size:`icon-sm`,type:`button`,variant:`ghost`,children:(0,X.jsx)(bt,{"aria-hidden":`true`})})}),(0,X.jsx)(ve,{children:f(`archivedTasks.delete`)})]})]},e.id))}),(0,X.jsxs)(`div`,{className:`flex min-h-12 items-center justify-between gap-2 px-4`,children:[(0,X.jsxs)(F,{className:`text-danger hover:text-danger`,disabled:n,onClick:i,size:`sm`,type:`button`,variant:`ghost`,children:[(0,X.jsx)(bt,{"aria-hidden":`true`}),f(`archivedTasks.deleteAll`)]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsxs)(De,{children:[(0,X.jsx)(he,{asChild:!0,children:(0,X.jsx)(F,{"aria-label":f(`archivedTasks.previous`),className:`size-11 sm:size-8`,disabled:n||d===1,onClick:o,size:`icon-sm`,type:`button`,variant:`ghost`,children:(0,X.jsx)(nl,{"aria-hidden":`true`})})}),(0,X.jsx)(ve,{children:f(`archivedTasks.previous`)})]}),(0,X.jsx)(`span`,{className:`min-w-16 text-center text-caption text-muted-foreground`,children:f(`archivedTasks.page`,{page:d})}),(0,X.jsxs)(De,{children:[(0,X.jsx)(he,{asChild:!0,children:(0,X.jsx)(F,{"aria-label":f(`archivedTasks.next`),className:`size-11 sm:size-8`,disabled:n||u?.nextCursor===null,onClick:a,size:`icon-sm`,type:`button`,variant:`ghost`,children:(0,X.jsx)(ct,{"aria-hidden":`true`})})}),(0,X.jsx)(ve,{children:f(`archivedTasks.next`)})]})]})]})]}):(0,X.jsxs)(`div`,{className:`flex min-h-48 flex-col items-center justify-center gap-3 px-4 text-center`,children:[(0,X.jsx)(`p`,{className:`text-body-small text-danger`,role:`alert`,children:f(`archivedTasks.loadError`)}),(0,X.jsx)(F,{onClick:l,size:`sm`,type:`button`,variant:`outline`,children:f(`actions.retry`)})]})}function Xp({client:e,onClose:t,project:n}){let{t:r}=s(`workbench`),i=le(),[a,o]=(0,J.useState)(``),[c,l]=(0,J.useState)(``),[u,d]=(0,J.useState)([void 0]),[f,p]=(0,J.useState)(0),[m,h]=(0,J.useState)(null),[g,_]=(0,J.useState)(!1),v=(0,J.useRef)(Ne()),y=u[f],b=He(hs(n.id,y,c,e)),x=q(Uo(e)),S=q(Wo(e)),C=q({mutationFn:()=>Kp(e,n.id),mutationKey:[`tasks`,`delete-all-archived`,n.id]}),w=x.isPending||S.isPending||C.isPending;(0,J.useEffect)(()=>{let e=window.setTimeout(()=>{l(a.trim()),d([void 0]),p(0)},250);return()=>{window.clearTimeout(e)}},[a]);let T=()=>{d([void 0]),p(0),i.removeQueries({queryKey:[`projects`,n.id,`archived-tasks`]})},E=e=>v.current.run(async()=>{try{let t=await x.mutateAsync({projectId:n.id,taskId:e.id});i.setQueryData([`projects`,n.id,`tasks`],e=>To(e,t.task)),Do(i,t.task),T()}catch{}}),D=e=>v.current.run(async()=>{try{await S.mutateAsync({projectId:n.id,taskId:e.id}),h(null),T()}catch{}}),O=()=>v.current.run(async()=>{try{await C.mutateAsync(),_(!1)}catch{}finally{T()}});return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(hp,{onOpenChange:e=>{!e&&!w&&t()},open:!0,children:(0,X.jsxs)(yp,{className:`grid h-[min(42rem,calc(100dvh-2rem))] max-w-2xl grid-rows-[auto_auto_minmax(0,1fr)] gap-0 overflow-hidden p-0`,children:[(0,X.jsx)(bp,{className:`px-4 pb-3 pt-4 sm:px-5 sm:pt-5`,children:(0,X.jsx)(Sp,{children:r(`archivedTasks.title`,{project:n.name})})}),(0,X.jsxs)(`div`,{className:`relative px-4 pb-3 sm:px-5`,children:[(0,X.jsx)(yl,{"aria-hidden":`true`,className:`pointer-events-none absolute left-7 top-2.5 size-4 text-muted-foreground sm:left-8`}),(0,X.jsx)(vt,{"aria-label":r(`archivedTasks.search`),className:`h-9 w-full pl-8`,onChange:e=>{o(e.currentTarget.value)},placeholder:r(`archivedTasks.search`),value:a})]}),(0,X.jsx)(Yp,{error:b.error,isPending:b.isPending,mutationPending:w,onDelete:h,onDeleteAll:()=>{_(!0)},onNext:()=>{let e=b.data?.nextCursor;e!=null&&(d(t=>[...t.slice(0,f+1),e]),p(e=>e+1))},onPrevious:()=>{p(e=>Math.max(0,e-1))},onRestore:e=>{E(e)},onRetry:()=>{b.refetch()},page:b.data,pageNumber:f+1})]})}),m===null?null:(0,X.jsx)(qp,{confirmLabel:r(`archivedTasks.confirmDelete`),description:r(`archivedTasks.deleteDescription`,{task:m.title}),isPending:S.isPending,onClose:()=>{h(null)},onConfirm:()=>{D(m)},title:r(`archivedTasks.deleteTitle`)}),g?(0,X.jsx)(qp,{confirmLabel:r(`archivedTasks.confirmDeleteAll`),description:r(`archivedTasks.deleteAllDescription`,{project:n.name}),isPending:C.isPending,onClose:()=>{_(!1)},onConfirm:()=>{O()},title:r(`archivedTasks.deleteAllTitle`)}):null]})}function Zp(e){return(0,X.jsx)(Vd,{"data-slot":`dropdown-menu`,...e})}function Qp(e){return(0,X.jsx)(Hd,{"data-slot":`dropdown-menu-trigger`,...e})}function $p(e){return(0,X.jsx)(Qd,{"data-slot":`dropdown-menu-sub`,...e})}function em({children:e,...t}){return typeof document>`u`?(0,X.jsx)(X.Fragment,{children:e}):(0,X.jsx)(Ud,{"data-slot":`dropdown-menu-portal`,...t,children:e})}function tm({children:e,className:t,collisionPadding:n=8,sideOffset:r=2,...i}){return(0,X.jsx)(em,{children:(0,X.jsx)(Wd,{className:L(`z-50 min-w-32 overflow-hidden rounded-surface bg-raised p-1 text-foreground shadow-floating outline-none`,t),collisionPadding:n,"data-slot":`dropdown-menu-content`,sideOffset:r,...i,children:e})})}function nm({className:e,...t}){return(0,X.jsx)(qd,{className:L(`flex cursor-default select-none items-center gap-2 rounded-control px-2 py-1.5 text-body-small outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[highlighted]:bg-control-hover [&_svg]:pointer-events-none [&_svg]:shrink-0`,e),"data-slot":`dropdown-menu-item`,...t})}function rm({children:e,className:t,...n}){return(0,X.jsxs)($d,{className:L(`flex cursor-default select-none items-center gap-2 rounded-control px-2 py-1.5 text-body-small outline-none transition-colors data-[state=open]:bg-control-hover data-[highlighted]:bg-control-hover [&_svg]:pointer-events-none [&_svg]:shrink-0`,t),"data-slot":`dropdown-menu-sub-trigger`,...n,children:[e,(0,X.jsx)(ct,{"aria-hidden":`true`,className:`ml-auto size-3.5 text-muted-foreground`})]})}function im({children:e,className:t,collisionPadding:n=8,sideOffset:r=2,...i}){return(0,X.jsx)(em,{children:(0,X.jsx)(ef,{className:L(`z-50 min-w-40 max-h-[calc(100dvh-1rem)] overflow-y-auto rounded-surface bg-raised p-1 text-foreground shadow-floating outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,t),collisionPadding:n,"data-slot":`dropdown-menu-sub-content`,sideOffset:r,...i,children:e})})}function am(e){return(0,X.jsx)(Gd,{"data-slot":`dropdown-menu-group`,...e})}function om({className:e,...t}){return(0,X.jsx)(Kd,{className:L(`px-2 py-1 text-label font-medium text-foreground`,e),"data-slot":`dropdown-menu-label`,...t})}function sm({className:e,...t}){return(0,X.jsx)(Zd,{className:L(`-mx-1 my-1 h-px bg-separator`,e),"data-slot":`dropdown-menu-separator`,...t})}function cm(e){return(0,X.jsx)(Jd,{"data-slot":`dropdown-menu-radio-group`,...e})}function lm({children:e,className:t,indicator:n=`radio`,...r}){return(0,X.jsxs)(Yd,{className:L(`relative flex cursor-default select-none items-center gap-2.5 rounded-control py-1.5 text-body-small outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[highlighted]:bg-control-hover [&_svg]:pointer-events-none [&_svg]:shrink-0`,n===`check`?`pl-2 pr-8`:`pl-8 pr-2`,t),"data-indicator":n,"data-indicator-position":n===`check`?`end`:`start`,"data-slot":`dropdown-menu-radio-item`,...r,children:[(0,X.jsx)(`span`,{className:L(`pointer-events-none absolute flex size-3.5 items-center justify-center`,n===`check`?`right-2`:`left-2`),children:(0,X.jsx)(Xd,{children:n===`check`?(0,X.jsx)(We,{"aria-hidden":`true`,className:`size-3.5`}):(0,X.jsx)(al,{"aria-hidden":`true`,className:`size-2 fill-current text-brand`})})}),e]})}function um(e){let t=new Map;for(let n of e){let e=t.get(n.projectId);e===void 0?t.set(n.projectId,[n]):e.push(n)}return t}function dm({error:e,hasHiddenLoadedTasks:t,hasNextPage:n,isExpanded:r,isFetchingNextPage:i}){return r?n?{action:`load`,disabled:i,label:i?l.t(`sidebar.expandLoading`,{ns:`workbench`}):e===null?l.t(`sidebar.expand`,{ns:`workbench`}):l.t(`sidebar.expandRetry`,{ns:`workbench`})}:t?{action:`collapse`,disabled:!1,label:l.t(`sidebar.collapse`,{ns:`workbench`})}:null:n?{action:`expand-and-load`,disabled:!1,label:l.t(`sidebar.expand`,{ns:`workbench`})}:t?{action:`expand`,disabled:!1,label:l.t(`sidebar.expand`,{ns:`workbench`})}:null}function fm({hasActiveTask:e,projectDataFailed:t,projectDataPending:n,taskConnectionState:r}){return e?r:t?`closed`:n?`connecting`:`connected`}function pm(e){switch(e){case`connected`:return{labelKey:`sidebar.connection.online`,toneClassName:`text-diff-added`};case`connecting`:return{labelKey:`sidebar.connection.connecting`,toneClassName:`text-warning`};case`reconnecting`:return{labelKey:`sidebar.connection.reconnecting`,toneClassName:`text-warning`};case`closed`:return{labelKey:`sidebar.connection.offline`,toneClassName:`text-danger`}}}function mm({disabled:e,onOpen:t}){let{t:n}=s(`workbench`);return(0,X.jsxs)(De,{children:[(0,X.jsx)(he,{asChild:!0,children:(0,X.jsx)(F,{"aria-label":n(`sidebar.addProject`),disabled:e,onClick:t,size:`icon-sm`,type:`button`,variant:`ghost`,children:(0,X.jsx)(Fe,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,X.jsx)(ve,{children:n(`sidebar.addProject`)})]})}function hm({isPending:e,onOpenArchived:t,onRemove:n,onRename:r,project:i}){let{t:a}=s(`workbench`);return(0,X.jsx)(`div`,{className:`relative shrink-0`,children:(0,X.jsxs)(Zp,{modal:!1,children:[(0,X.jsx)(Qp,{asChild:!0,children:(0,X.jsx)(F,{variant:`ghost`,"aria-label":a(`sidebar.openProjectActions`,{project:i.name}),className:`grid size-7 place-items-center rounded-control text-muted-foreground opacity-0 transition-[color,background-color,opacity] hover:bg-control-hover hover:text-foreground focus-visible:opacity-100 focus-visible:shadow-focus group-hover/project:opacity-100 data-[state=open]:opacity-100`,disabled:e,id:`project-actions-${i.id}`,type:`button`,children:(0,X.jsx)(ol,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,X.jsx)(_m,{isPending:e,onOpenArchived:()=>{t(i)},onRemove:()=>{n(i)},onRename:()=>{r(i)},project:i})]})})}var gm=`h-8 w-full text-left text-foreground`;function _m({isPending:e,onOpenArchived:t,onRemove:n,onRename:r,project:i}){let{t:a}=s(`workbench`);return(0,X.jsxs)(tm,{align:`start`,"aria-label":a(`sidebar.projectActions`,{project:i.name}),"aria-labelledby":void 0,className:`w-32`,children:[(0,X.jsxs)(nm,{className:gm,disabled:e,onSelect:r,children:[(0,X.jsx)(hl,{className:`size-3.5`,"aria-hidden":`true`}),a(`sidebar.rename`)]}),(0,X.jsxs)(nm,{className:gm,disabled:e,onSelect:t,children:[(0,X.jsx)($c,{className:`size-3.5`,"aria-hidden":`true`}),a(`sidebar.archived`)]}),(0,X.jsxs)(nm,{className:`${gm} text-danger`,disabled:e,onSelect:n,children:[(0,X.jsx)(bt,{className:`size-3.5`,"aria-hidden":`true`}),a(`sidebar.remove`)]})]})}function vm({appInfo:e,connectionState:t,onOpen:n}){let{t:r}=s(`workbench`),i=pm(t),a=r(i.labelKey),o=e?.appVersion??`…`,c=e?.updateAvailable===!0;return(0,X.jsxs)(`div`,{className:`flex h-9 w-full items-stretch text-body-small text-muted-foreground`,children:[(0,X.jsxs)(F,{"aria-label":r(`sidebar.settings`),className:`h-full min-w-0 flex-1 gap-2.5 rounded-r-none px-2.5`,contentAlign:`start`,id:`global-settings-trigger`,onClick:()=>{n(`appearance`)},type:`button`,variant:`ghost`,children:[(0,X.jsx)(mt,{className:`size-4`,"aria-hidden":`true`}),r(`sidebar.settings`)]}),(0,X.jsx)(F,{"aria-label":r(`sidebar.aboutStatus`,{status:a,update:c?r(`sidebar.updateAvailableLabel`):``,version:o}),className:`h-full gap-1 rounded-l-none px-2.5 text-caption`,id:`global-settings-about-trigger`,onClick:()=>{n(`about`)},type:`button`,variant:`ghost`,children:(0,X.jsxs)(`span`,{"aria-live":`polite`,className:`inline-flex items-center gap-1`,children:[(0,X.jsxs)(`span`,{className:c?`text-warning`:`text-muted-foreground`,children:[c?(0,X.jsx)(il,{"aria-hidden":`true`,className:`mr-1 inline size-3`}):null,`v`,o]}),(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`text-muted-foreground`,children:`·`}),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 ${i.toneClassName}`,children:[(0,X.jsx)(ym,{connectionState:t}),a]})]})})]})}function ym({connectionState:e}){return e===`connected`?(0,X.jsx)(Cl,{className:`size-3`,"aria-hidden":`true`}):e===`closed`?(0,X.jsx)(Sl,{className:`size-3`,"aria-hidden":`true`}):(0,X.jsx)(`span`,{className:`inline-flex animate-spin`,"aria-hidden":`true`,children:(0,X.jsx)(Ue,{className:`size-3`})})}function bm(e,t){return e===`temporary`?{params:{taskId:t},to:`/temporary/t/$taskId`}:{params:{projectId:e,taskId:t},to:`/p/$projectId/t/$taskId`}}function xm({active:e,attention:t,icon:n,isActionPending:r,isAwaitingApproval:i,isRunning:a,onArchive:o,onDelete:c,onPin:l,onRename:u,task:d}){let{t:f}=s(`workbench`),p=bm(d.projectId,d.id);return(0,X.jsxs)(`div`,{className:`group relative min-w-0`,children:[(0,X.jsxs)(sa,{"aria-current":e?`page`:void 0,className:`flex h-8 min-w-0 items-center gap-2 rounded-control px-2 text-body-small transition-colors ${e?`bg-control-active font-medium text-foreground`:`text-muted-foreground hover:bg-control-hover hover:text-foreground`}`,...p,children:[n===void 0?null:(0,X.jsx)(`span`,{className:`shrink-0 text-subtle-foreground`,children:n}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:d.title}),(0,X.jsx)(Sm,{attention:t,isAwaitingApproval:i,isRunning:a,updatedAt:d.updatedAt})]}),(0,X.jsxs)(Zp,{modal:!1,children:[(0,X.jsx)(Qp,{asChild:!0,children:(0,X.jsx)(F,{variant:`ghost`,"aria-label":f(`sidebar.openTaskActions`,{task:d.title}),className:`task-actions absolute right-1 top-1 grid size-6 place-items-center rounded-control text-muted-foreground transition-colors hover:bg-control-hover hover:text-foreground focus-visible:opacity-100 focus-visible:shadow-focus`,disabled:r,type:`button`,children:(0,X.jsx)(ol,{className:`size-4`,"aria-hidden":`true`})})}),(0,X.jsx)(wm,{isPending:r,onArchive:()=>{o(d)},onDelete:()=>{c(d)},onPin:()=>{l(d)},onRename:()=>{u(d)},task:d})]})]})}function Sm({attention:e,isAwaitingApproval:t,isRunning:n,updatedAt:r}){let{t:i}=s(`workbench`),a;return a=t||e===`approval`?{animated:!0,label:i(`sidebar.taskApproval`),tone:`text-task-waiting`}:n?{animated:!0,label:i(`sidebar.taskRunning`),tone:`text-task-running`}:e===`completed`?{animated:!1,label:i(`sidebar.taskComplete`),tone:`text-task-completed`}:e===`failed`?{animated:!1,label:i(`sidebar.taskIncomplete`),tone:`text-task-failed`}:null,a===null?(0,X.jsx)(`span`,{className:`task-age task-status ml-auto shrink-0 text-caption text-subtle-foreground`,children:Ol(r)}):(0,X.jsx)(`span`,{"aria-label":a.label,className:`task-status ml-auto inline-grid size-3.5 shrink-0 place-items-center ${a.tone}`,role:`status`,children:(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`task-status-dot block size-2 rounded-full bg-current ${a.animated?`task-status-dot--breathing`:``}`})})}var Cm=`h-8 w-full text-left text-foreground`;function wm({isPending:e,onArchive:t,onDelete:n,onPin:r,onRename:i,task:a}){let{t:o}=s(`workbench`);return(0,X.jsxs)(tm,{align:`start`,"aria-label":o(`sidebar.taskActions`,{task:a.title}),"aria-labelledby":void 0,className:`w-40`,children:[(0,X.jsxs)(nm,{className:Cm,disabled:e,onSelect:r,children:[(0,X.jsx)(gl,{className:`size-3.5`,"aria-hidden":`true`}),a.pinned?o(`sidebar.unpin`):o(`sidebar.pin`)]}),(0,X.jsxs)(nm,{className:Cm,disabled:e,onSelect:i,children:[(0,X.jsx)(hl,{className:`size-3.5`,"aria-hidden":`true`}),o(`sidebar.rename`)]}),(0,X.jsxs)(nm,{className:`${Cm} text-danger`,disabled:e,onSelect:t,children:[(0,X.jsx)($c,{className:`size-3.5`,"aria-hidden":`true`}),o(`sidebar.archive`)]}),(0,X.jsxs)(nm,{className:`${Cm} text-danger`,disabled:e,onSelect:n,children:[(0,X.jsx)(bt,{className:`size-3.5`,"aria-hidden":`true`}),o(`sidebar.deletePermanently`)]})]})}function Tm({expanded:e,onCreate:t,onOpenArchived:n,onToggle:r}){let{t:i}=s(`workbench`),a=i(`sidebar.temporaryTasks`),o=`opacity-0 transition-[color,background-color,opacity] focus-visible:opacity-100 group-hover/temporary:opacity-100`;return(0,X.jsxs)(`div`,{className:`group/temporary flex h-8 items-center gap-0.5 text-muted-foreground`,children:[(0,X.jsxs)(F,{"aria-controls":`temporary-tasks-content`,"aria-expanded":e,className:`h-8 min-w-0 flex-1 gap-2 rounded-control px-2 text-body-small font-medium`,contentAlign:`start`,id:`temporary-tasks-title`,onClick:r,type:`button`,variant:`ghost`,children:[(0,X.jsx)(pl,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`truncate`,children:a})]}),(0,X.jsxs)(De,{children:[(0,X.jsx)(he,{asChild:!0,children:(0,X.jsx)(F,{"aria-label":i(`sidebar.archived`),className:o,id:`project-actions-${G}`,onClick:()=>{n({id:G,name:a})},size:`icon-sm`,type:`button`,variant:`ghost`,children:(0,X.jsx)($c,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,X.jsx)(ve,{children:i(`sidebar.archived`)})]}),(0,X.jsxs)(De,{children:[(0,X.jsx)(he,{asChild:!0,children:(0,X.jsx)(F,{"aria-label":i(`sidebar.newTask`),className:o,onClick:t,size:`icon-sm`,type:`button`,variant:`ghost`,children:(0,X.jsx)(Fe,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,X.jsx)(ve,{children:i(`sidebar.newTask`)})]})]})}var Em=[];function Dm({archiveTask:e,deleteTask:t,error:n,expandedProjects:r,expandedTaskProjects:i,fetchNextProjectTaskPage:a,getProjectReorderProps:o,hasTaskError:c,isPending:l,isProjectActionPending:u,isProjectAddPending:d,normalizedQuery:f,onOpenTemporaryDraft:p,onOpenProjectDraft:m,onOpenArchived:h,onOpenProjectPicker:g,onRemoveProject:_,onRenameProject:v,orderedProjects:y,pinTask:b,pinnedTasks:x,projectId:S,projectOrderAnnouncement:C,projectTaskStates:w,reorderingProjectId:T,setExpandedTaskProjects:E,setRenamingTask:D,taskActionPending:O,taskActivity:k,taskId:A,taskSearch:j,tasksByProjectId:M,toggleProject:N}){let{t:P}=s(`workbench`),[I]=(0,J.useState)(Pu),[L,R]=(0,J.useState)(()=>Lu(I)),z=M.get(`temporary`)??Em,B=w.get(G),V=i.has(G),H=Dl(z,V),ee=dm({error:B?.error??null,hasHiddenLoadedTasks:z.length>5,hasNextPage:f.length===0?B?.hasNextPage??!1:!1,isExpanded:V,isFetchingNextPage:B?.isFetchingNextPage??!1});return(0,X.jsx)(X.Fragment,{children:(0,X.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-col overflow-hidden px-2 pt-5`,children:[x.length>0?(0,X.jsxs)(`section`,{className:`mb-4 max-h-40 shrink-0 overflow-y-auto`,"aria-labelledby":`pinned-title`,children:[(0,X.jsx)(`h2`,{className:`px-2 pb-2 text-meta font-semibold text-muted-foreground`,id:`pinned-title`,children:P(`sidebar.pinned`)}),(0,X.jsx)(`div`,{className:`space-y-0.5`,children:x.map(n=>{let r=Js(k,n.projectId,n.id);return(0,X.jsx)(xm,{active:n.projectId===S&&n.id===A,attention:r.attention,icon:(0,X.jsx)(gl,{className:`size-3.5`,"aria-hidden":`true`}),isActionPending:O,isAwaitingApproval:r.isAwaitingApproval,isRunning:r.isRunning,onArchive:t=>void e(t),onDelete:e=>void t(e),onPin:e=>void b(e),onRename:D,task:n},`${n.projectId}:${n.id}`)})})]}):null,(0,X.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,"aria-labelledby":`projects-title`,children:[(0,X.jsxs)(`div`,{className:`flex h-8 min-w-0 w-full shrink-0 items-center justify-between pl-2`,children:[(0,X.jsx)(`h2`,{className:`text-body-small font-semibold text-foreground`,id:`projects-title`,children:P(`sidebar.projects`)}),(0,X.jsx)(mm,{disabled:d,onOpen:()=>{g()}})]}),l?(0,X.jsx)(`p`,{className:`px-2 py-1.5 text-meta text-subtle-foreground`,children:P(`sidebar.taskLoading`)}):null,j.isPending?(0,X.jsx)(`p`,{className:`px-2 py-1.5 text-meta text-subtle-foreground`,children:P(`sidebar.searchAll`)}):null,n===null&&!c?null:(0,X.jsx)(`p`,{className:`px-2 py-1.5 text-meta leading-5 text-danger`,role:`alert`,children:P(`sidebar.errorLoadTasks`)}),j.error===null?null:(0,X.jsx)(`p`,{className:`px-2 py-1.5 text-meta leading-5 text-danger`,role:`alert`,children:P(`sidebar.errorSearchTasks`)}),(0,X.jsx)(`p`,{"aria-live":`polite`,className:`sr-only`,children:C}),(0,X.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-x-hidden overflow-y-auto pb-3`,"data-testid":`project-tree-scroll`,children:[(0,X.jsxs)(`section`,{className:`min-w-0`,"aria-labelledby":`temporary-tasks-title`,children:[(0,X.jsx)(Tm,{expanded:L,onCreate:p,onOpenArchived:h,onToggle:()=>{R(e=>{let t=!e;return Ru(I,t),t})}}),L?(0,X.jsxs)(`div`,{className:`min-w-0 space-y-0.5 pl-5`,id:`temporary-tasks-content`,children:[H.tasks.map(n=>{let r=Js(k,n.projectId,n.id);return(0,X.jsx)(xm,{active:S===`temporary`&&n.id===A,attention:r.attention,isActionPending:O,isAwaitingApproval:r.isAwaitingApproval,isRunning:r.isRunning,onArchive:t=>void e(t),onDelete:e=>void t(e),onPin:e=>void b(e),onRename:D,task:n},`${n.projectId}:${n.id}`)}),B?.isPending===!0?(0,X.jsx)(`p`,{className:`px-2 py-1.5 text-meta text-subtle-foreground`,children:P(`sidebar.taskLoading`)}):null,ee===null?null:(0,X.jsx)(F,{variant:`ghost`,"aria-expanded":V,className:`flex h-7 w-full items-center rounded-control px-2 text-left text-meta font-medium text-subtle-foreground transition-colors hover:bg-control-hover hover:text-foreground`,contentAlign:`start`,disabled:ee.disabled,onClick:()=>{ee.action===`expand`||ee.action===`expand-and-load`?E(e=>new Set(e).add(G)):ee.action===`collapse`&&E(e=>{let t=new Set(e);return t.delete(G),t}),(ee.action===`expand-and-load`||ee.action===`load`)&&a(G).catch(()=>void 0)},type:`button`,children:ee.label}),z.length===0&&f.length===0&&B?.isPending!==!0?(0,X.jsx)(`p`,{className:`px-2 py-1.5 text-meta text-subtle-foreground`,children:P(`sidebar.noTemporaryTasks`)}):null,z.length===0&&f.length>0&&!j.isPending&&j.error===null?(0,X.jsx)(`p`,{className:`px-2 py-1.5 text-meta text-subtle-foreground`,children:P(`sidebar.noMatchingTasks`)}):null]}):null]}),y.map(n=>{let s=M.get(n.id)??Em,c=r.has(n.id),l=i.has(n.id),d=Dl(s,l),p=w.get(n.id),g=dm({error:p?.error??null,hasHiddenLoadedTasks:s.length>5,hasNextPage:f.length===0?p?.hasNextPage??!1:!1,isExpanded:l,isFetchingNextPage:p?.isFetchingNextPage??!1});return(0,X.jsxs)(`div`,{className:`min-w-0 transition-[opacity,transform] ${T===n.id?`relative z-10 opacity-80`:``}`,"data-project-reordering":T===n.id?`true`:`false`,children:[(0,X.jsxs)(`div`,{className:`group/project flex min-w-0 items-center gap-0.5`,children:[(0,X.jsxs)(F,{variant:`ghost`,"aria-expanded":c,"aria-label":P(`sidebar.toggleProject`,{project:n.name}),className:`flex h-8 min-w-0 flex-1 touch-pan-y select-none items-center gap-2 rounded-control px-2 text-body-small font-medium transition-colors hover:bg-control-hover hover:text-foreground ${T===n.id?`cursor-grabbing bg-control-active text-foreground shadow-sm`:`cursor-grab text-muted-foreground`}`,contentAlign:`start`,onClick:()=>{N(n.id)},type:`button`,...o(n.id),children:[(0,X.jsx)(dt,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`truncate`,children:n.name})]}),(0,X.jsx)(hm,{isPending:u,onOpenArchived:h,onRemove:e=>{_(e)},onRename:e=>{v(e)},project:n}),(0,X.jsxs)(De,{children:[(0,X.jsx)(he,{asChild:!0,children:(0,X.jsx)(F,{"aria-label":P(`sidebar.createInProject`,{project:n.name}),className:`opacity-0 transition-[color,background-color,opacity] focus-visible:opacity-100 group-hover/project:opacity-100`,onClick:()=>{m(n.id)},size:`icon-sm`,type:`button`,variant:`ghost`,children:(0,X.jsx)(Fe,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,X.jsx)(ve,{children:P(`sidebar.createInProject`,{project:n.name})})]})]}),c?(0,X.jsxs)(`div`,{className:`mt-0.5 min-w-0 space-y-0.5 pl-5`,children:[d.tasks.map(r=>{let i=Js(k,r.projectId,r.id);return(0,X.jsx)(xm,{active:n.id===S&&r.id===A,attention:i.attention,isActionPending:O,isAwaitingApproval:i.isAwaitingApproval,isRunning:i.isRunning,onArchive:t=>void e(t),onDelete:e=>void t(e),onPin:e=>void b(e),onRename:D,task:r},`${r.projectId}:${r.id}`)}),p?.isPending===!0?(0,X.jsx)(`p`,{className:`px-2 py-1.5 text-meta text-subtle-foreground`,children:P(`sidebar.taskLoading`)}):null,g===null?null:(0,X.jsx)(F,{variant:`ghost`,"aria-expanded":l,className:`flex h-7 w-full items-center rounded-control px-2 text-left text-meta font-medium text-subtle-foreground transition-colors hover:bg-control-hover hover:text-foreground`,contentAlign:`start`,disabled:g.disabled,onClick:()=>{g.action===`expand`||g.action===`expand-and-load`?E(e=>new Set(e).add(n.id)):g.action===`collapse`&&E(e=>{let t=new Set(e);return t.delete(n.id),t}),(g.action===`expand-and-load`||g.action===`load`)&&a(n.id).catch(()=>void 0)},type:`button`,children:g.label}),s.length===0&&f.length===0&&p?.isPending!==!0?(0,X.jsx)(`p`,{className:`px-2 py-1.5 text-meta text-subtle-foreground`,children:P(`sidebar.noTasks`)}):null,s.length===0&&f.length>0&&!j.isPending&&j.error===null?(0,X.jsx)(`p`,{className:`px-2 py-1.5 text-meta text-subtle-foreground`,children:P(`sidebar.noMatchingTasks`)}):null]}):null]},n.id)})]})]})]})})}var Om=`flex h-9 w-full items-center gap-2.5 rounded-control px-2.5 text-body-small font-medium text-foreground transition-colors hover:bg-control-hover`,km=`size-4 shrink-0 text-muted-foreground`;function Am({appInfo:e,connectionState:t,onClose:n,onOpenSettings:r,projectId:i,taskId:a}){let{t:o}=s(`workbench`),{client:c,error:l,isPending:u,projects:d,projectTaskStates:f,tasks:p}=Ds(),{addProject:m,fetchNextProjectTaskPage:h,forgetTask:g,reorderProjects:_,removeProject:v,renameProject:y,setExpandedProjectTaskIds:b}=Os(),{isProjectActionPending:x,isProjectOrderPending:S,isProjectAddPending:C,taskActivity:w}=ks(),T=qi(),E=le(),[D]=(0,J.useState)(Pu),[O]=(0,J.useState)(()=>Fu(D)),k=(0,J.useRef)(O),A=(0,J.useRef)(d.length>0),[j,M]=(0,J.useState)(()=>zu(d.map(e=>e.id),O)),N=(0,J.useRef)(j),[P,I]=(0,J.useState)(``),[L,R]=(0,J.useState)(()=>new Set),[z,B]=(0,J.useState)(null),[V,H]=(0,J.useState)(null),[ee,te]=(0,J.useState)(null),[ne,re]=(0,J.useState)(null),[U,ie]=(0,J.useState)(!1),ae=q(Bo(c)),oe=q(Vo(c)),se=q(Ho(c)),ce=(0,J.useRef)(Ne()),W=ju({actionLock:ce.current,activeProjectId:i,activeTaskId:a}),ue=P.trim().toLocaleLowerCase(),G=js(ue),de=Ms(),fe=ue.length===0?p:G.tasks,pe=(0,J.useMemo)(()=>um(fe),[fe]),me=El(ue.length===0?de.tasks:fe),ge=de.error!==null||[...f.values()].some(e=>e.error!==null),_e=ae.isPending||oe.isPending||se.isPending||W.isDeletePending,{activeProjectId:K,announcement:ye,getProjectReorderProps:be,orderedProjects:xe}=Au({disabled:S,onReorder:_,projects:d});(0,J.useEffect)(()=>{if(u||i===void 0||i===`temporary`||d.some(e=>e.id===i))return;let e=d[0];T(e===void 0?{replace:!0,to:`/`}:{params:{projectId:e.id},replace:!0,to:`/p/$projectId`})},[u,T,i,d]),(0,J.useEffect)(()=>{let e=d.map(e=>e.id);if(!A.current&&e.length>0){A.current=!0;let t=zu(e,k.current);N.current=t,M(t);return}let t=new Set(e),n=N.current,r=new Set([...n].filter(e=>t.has(e)));r.size!==n.size&&(N.current=r,M(r))},[d]),(0,J.useEffect)(()=>{b(j)},[j,b]);let Se=(0,J.useCallback)(e=>{let t=e(N.current);N.current=t,k.current=t,Iu(D,t),M(t)},[D]),Ce=e=>{Se(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},we=async e=>{await m(e)!==void 0&&ie(!1)},Te=async e=>{Se(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n}),await T({params:{projectId:e},to:`/p/$projectId`})},Ee=e=>{Do(E,e)},Oe=e=>ce.current.run(async()=>{try{let t=await ae.mutateAsync({pinned:!e.pinned,projectId:e.projectId,taskId:e.id});Ee(t.task)}catch{}}),ke=(e,t)=>ce.current.run(async()=>{try{let n=await oe.mutateAsync({projectId:e.projectId,taskId:e.id,title:t});Ee(n.task),B(null)}catch{}}),Ae=e=>ce.current.run(async()=>{try{await se.mutateAsync({projectId:e.projectId,taskId:e.id}),await Ro(E,e.projectId,e.id),E.removeQueries({exact:!0,queryKey:[`projects`,e.projectId,`tasks`,e.id]}),g(e.projectId,e.id),e.projectId===i&&e.id===a&&await(e.projectId===`temporary`?T({to:`/temporary`}):T({params:{projectId:e.projectId},to:`/p/$projectId`})),Cu(e.projectId,e.id),c.unsubscribeTask(e.projectId,e.id).catch(()=>void 0)}catch{}}),je=e=>{re(null),H(null),te(null),requestAnimationFrame(()=>{document.getElementById(`project-actions-${e}`)?.focus()})},Me=async(e,t)=>{await y(e.id,t)&&je(e.id)},Pe=async e=>{await v(e.id)!==void 0&&te(null)};return(0,X.jsxs)(`aside`,{"aria-label":o(`sidebar.landmark`),className:`workbench-sidebar z-30 grid min-h-0 grid-rows-[auto_auto_minmax(0,1fr)_auto] bg-sidebar shadow-divider`,children:[(0,X.jsxs)(`div`,{className:`flex h-workbench-header items-center gap-2 px-3`,children:[(0,X.jsx)(jm,{}),(0,X.jsxs)(De,{children:[(0,X.jsx)(he,{asChild:!0,children:(0,X.jsx)(F,{"aria-label":o(`sidebar.close`),className:`min-workbench:hidden`,onClick:n,size:`icon-sm`,type:`button`,variant:`ghost`,children:(0,X.jsx)(ml,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,X.jsx)(ve,{children:o(`sidebar.close`)})]})]}),(0,X.jsxs)(`nav`,{className:`space-y-0.5 px-2`,"aria-label":o(`sidebar.agentNavigation`),children:[(0,X.jsxs)(`div`,{className:`relative px-1 pb-1`,children:[(0,X.jsx)(yl,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-2.5 size-4 text-muted-foreground`}),(0,X.jsx)(vt,{"aria-label":o(`sidebar.search`),className:`h-9 w-full rounded-control bg-control pl-8 pr-2.5 text-body-small text-foreground shadow-sm outline-none placeholder:text-muted-foreground focus:shadow-focus`,onChange:e=>{I(e.currentTarget.value)},placeholder:o(`sidebar.search`),value:P})]}),(0,X.jsxs)(sa,{className:Om,to:`/temporary`,children:[(0,X.jsx)(bl,{className:km,"aria-hidden":`true`}),o(`sidebar.newTask`)]})]}),(0,X.jsx)(Dm,{archiveTask:Ae,deleteTask:W.requestTaskDeletion,error:l,expandedProjects:j,expandedTaskProjects:L,fetchNextProjectTaskPage:h,getProjectReorderProps:be,hasTaskError:ge,isPending:u,isProjectActionPending:x,isProjectAddPending:C,normalizedQuery:ue,onOpenTemporaryDraft:()=>{T({to:`/temporary`})},onOpenProjectDraft:Te,onOpenArchived:re,onOpenProjectPicker:()=>{ie(!0)},onRemoveProject:e=>{te(e)},onRenameProject:e=>{H(e)},orderedProjects:xe,pinTask:Oe,pinnedTasks:me,...i===void 0?{}:{projectId:i},projectOrderAnnouncement:ye,projectTaskStates:f,reorderingProjectId:K,setExpandedTaskProjects:R,setRenamingTask:B,taskActionPending:_e,taskActivity:w,...a===void 0?{}:{taskId:a},taskSearch:G,tasksByProjectId:pe,toggleProject:Ce}),ne===null?null:(0,X.jsx)(Xp,{client:c,onClose:()=>{je(ne.id)},project:ne}),W.deletingTask===null?null:(0,X.jsx)(Jp,{isPending:W.isDeletePending,onClose:W.closeTaskDeletion,onDelete:()=>{W.confirmTaskDeletion()},task:W.deletingTask}),(0,X.jsx)(Hp,{client:c,isProjectActionPending:x,isProjectAddPending:C,isProjectPickerOpen:U,onAddProject:we,onCloseProjectDialog:je,onCloseProjectPicker:()=>{C||ie(!1)},onCloseTaskRename:()=>{B(null)},onRemoveProject:e=>{Pe(e)},onRenameProject:(e,t)=>{Me(e,t)},onRenameTask:(e,t)=>{ke(e,t)},removingProject:ee,renamingProject:V,renamingTask:z,taskRenamePending:oe.isPending}),(0,X.jsx)(`div`,{className:`p-2`,children:(0,X.jsx)(vm,{...e===void 0?{}:{appInfo:e},connectionState:t,onOpen:r})})]})}function jm(){return(0,X.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:(0,X.jsx)(`img`,{alt:`Codexly`,className:`h-7 w-auto max-w-full`,height:`28`,src:`/brand/codexly-logo.svg`,width:`116`})})}function Mm(){let{t:e}=s(`common`);return(0,X.jsx)(`main`,{className:`grid h-full place-items-center bg-window px-6`,"aria-labelledby":`not-found-title`,children:(0,X.jsxs)(`section`,{className:`w-full max-w-md rounded-surface bg-raised p-6 shadow-panel`,children:[(0,X.jsx)(`p`,{className:`mb-2 font-mono text-xs text-warning`,children:`404`}),(0,X.jsx)(`h1`,{id:`not-found-title`,className:`text-xl font-semibold`,children:e(`errors.notFoundTitle`)}),(0,X.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-muted-foreground`,children:e(`errors.notFoundDescription`)}),(0,X.jsxs)(sa,{className:`mt-5 inline-flex items-center gap-2 text-sm font-medium text-brand-strong`,to:`/`,children:[(0,X.jsx)(el,{className:`size-4`,"aria-hidden":`true`}),e(`actions.backToWorkbench`)]})]})})}var Nm=fa({component:Fm,errorComponent:Pm,notFoundComponent:Mm});function Pm({error:e,reset:t}){let{t:n}=s(`common`);return(0,X.jsx)(`main`,{className:`grid h-full place-items-center bg-window px-6`,"aria-labelledby":`route-error-title`,children:(0,X.jsxs)(`section`,{className:`w-full max-w-lg rounded-surface bg-raised p-6 shadow-panel`,children:[(0,X.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-danger uppercase`,children:n(`errors.routeErrorLabel`)}),(0,X.jsx)(`h1`,{id:`route-error-title`,className:`text-xl font-semibold text-foreground`,children:n(`errors.routeErrorTitle`)}),(0,X.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:e.message}),(0,X.jsx)(F,{variant:`ghost`,className:`mt-5 rounded-control bg-control px-3 py-2 text-body font-medium text-foreground shadow-sm transition-colors hover:bg-control-hover`,onClick:t,type:`button`,children:n(`actions.retry`)})]})})}function Fm(){return(0,X.jsx)(`div`,{className:`h-full min-h-0 bg-window text-foreground`,"data-testid":`app-root`,children:(0,X.jsx)(Ca,{})})}var Im=(0,J.lazy)(()=>Kc().then(e=>({default:e.GlobalSettingsDialog}))),Lm=ua({component:Rm,getParentRoute:()=>Nm,path:`/`});function Rm(){let{t:e}=s(`common`),t=Zc(),{client:n,error:r,isPending:i,projects:a}=Ds(),{retry:o}=Os(),c=qi(),l=le(),u=He(Va(n)),d=q({...Ua(n),onSuccess(e){l.setQueryData([`app-info`],e)}}),f=He(Yo(n)),p=He(Jo(n)),m=q({...Xo(n),onSuccess(e){l.setQueryData([`settings`],e)}}),[h,g]=(0,J.useState)(null),[_]=(0,J.useState)(()=>Fu(Pu())),v=Bu(a.map(e=>e.id),_);return(0,J.useEffect)(()=>{if(v!==void 0){c({params:{projectId:v},replace:!0,to:`/p/$projectId`});return}!i&&a.length===0&&c({replace:!0,to:`/temporary`})},[v,i,c,a.length]),r===null?i||v!==void 0||a.length===0?(0,X.jsx)(`main`,{className:`grid h-full place-items-center text-sm text-muted-foreground`,children:e(`app.loadingProjects`)}):(0,X.jsxs)(`div`,{className:`workbench-shell h-full min-h-0 overflow-hidden bg-window`,"data-inspector-open":`false`,"data-sidebar-open":`true`,children:[(0,X.jsx)(Am,{...u.data===void 0?{}:{appInfo:u.data},connectionState:`connected`,onClose:()=>void 0,onOpenSettings:e=>{g(e)}}),(0,X.jsx)(`main`,{className:`grid min-h-0 min-w-0 place-items-center bg-content text-sm text-muted-foreground`,children:e(`app.noProjects`)}),h===null?null:(0,X.jsx)(J.Suspense,{fallback:null,children:(0,X.jsx)(Im,{...t.status===void 0?{}:{accessMode:t.status.mode},...u.data===void 0?{}:{appInfo:u.data},appInfoError:u.error,initialSection:h,apps:[],error:f.error??p.error,isPending:f.isPending||p.isPending,isAppInfoPending:u.isPending,isAppUpdatePending:d.isPending,models:p.data?.data??[],onClose:()=>{let e=h===`about`?`#global-settings-about-trigger`:`#global-settings-trigger`;g(null),requestAnimationFrame(()=>{document.querySelector(e)?.focus()})},onLogoutAccess:t.logout,onRetry:()=>Promise.all([f.refetch(),p.refetch()]),onRetryAppInfo:()=>u.refetch(),onSave:e=>m.mutateAsync(e).then(()=>void 0),onUpdate:e=>d.mutateAsync(e).then(()=>void 0),...f.data===void 0?{}:{settings:f.data.settings}})})]}):(0,X.jsx)(`main`,{className:`flex h-full min-h-0`,children:(0,X.jsx)(Tl,{onRetry:()=>void o()})})}var zm={blurPercentage:0,mode:`none`,overlayOpacity:60,selectedCustomImageId:null},Bm=`codexly:workbench-background-changed`,Vm=`codexly.workbench-background-preference`,Hm=3,Um=`codexly-workbench`,Wm=2,Gm=`background-images`,Km=20*1024*1024,qm=new Set([`image/gif`,`image/jpeg`,`image/png`,`image/webp`]);function Jm(e){return e===`none`||e===`custom`||e===`bing`}function Ym(e){try{let t=JSON.parse(e.getItem(Vm)??`null`);if(typeof t==`object`&&t&&`version`in t&&t.version===Hm&&`blurPercentage`in t&&typeof t.blurPercentage==`number`&&Number.isInteger(t.blurPercentage)&&t.blurPercentage>=0&&t.blurPercentage<=95&&`mode`in t&&Jm(t.mode)&&`overlayOpacity`in t&&typeof t.overlayOpacity==`number`&&Number.isInteger(t.overlayOpacity)&&t.overlayOpacity>=0&&t.overlayOpacity<=95&&`selectedCustomImageId`in t&&(t.selectedCustomImageId===null||typeof t.selectedCustomImageId==`string`))return{blurPercentage:t.blurPercentage,mode:t.mode,overlayOpacity:t.overlayOpacity,selectedCustomImageId:t.selectedCustomImageId}}catch{}return zm}function Xm(e,t){try{t.setItem(Vm,JSON.stringify({...e,version:Hm}))}catch{}}function Zm(e){return e.size>0&&e.size<=Km&&qm.has(e.type)}function Qm(e,t=crypto.randomUUID()){return{blob:e,createdAt:Date.now(),id:t,name:e.name}}function $m(e,t,n){let r=e.filter(e=>e.id!==t);return{images:r,selectedCustomImageId:n===t?r[0]?.id??null:n}}function eh(){return new Promise((e,t)=>{let n=window.indexedDB.open(Um,Wm);n.onerror=()=>{t(n.error??Error(`Unable to open background image storage`))},n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(Gm)&&e.deleteObjectStore(Gm),e.createObjectStore(Gm,{keyPath:`id`})},n.onsuccess=()=>{e(n.result)}})}function th(e){return typeof e==`object`&&!!e&&`blob`in e&&e.blob instanceof Blob&&`createdAt`in e&&typeof e.createdAt==`number`&&`id`in e&&typeof e.id==`string`&&`name`in e&&typeof e.name==`string`}async function nh(){let e=await eh();return new Promise((t,n)=>{let r=e.transaction(Gm,`readonly`),i=r.objectStore(Gm).getAll();i.onerror=()=>{e.close(),n(i.error??Error(`Unable to read custom background images`))},i.onsuccess=()=>{t(i.result.filter(th).sort((e,t)=>e.createdAt-t.createdAt))},r.oncomplete=()=>{e.close()}})}async function rh(e){let t=await eh();return new Promise((n,r)=>{let i=t.transaction(Gm,`readonly`),a=i.objectStore(Gm).get(e);a.onerror=()=>{t.close(),r(a.error??Error(`Unable to read custom background image`))},a.onsuccess=()=>{n(th(a.result)?a.result.blob:null)},i.oncomplete=()=>{t.close()}})}async function ih(e){if(e.deletedImageIds.length===0&&e.imagesToSave.length===0)return;let t=await eh();return new Promise((n,r)=>{let i=t.transaction(Gm,`readwrite`),a=i.objectStore(Gm);e.deletedImageIds.forEach(e=>a.delete(e)),e.imagesToSave.forEach(e=>a.put(e)),i.onerror=()=>{r(i.error??Error(`Unable to update custom background images`))},i.onabort=()=>{t.close()},i.oncomplete=()=>{t.close(),n()}})}async function ah(e,t){await ih(t),Xm(e,window.localStorage),window.dispatchEvent(new CustomEvent(Bm,{detail:e}))}function oh(e,t,n){return{height:Math.max(1,Math.round(t*n)),width:Math.max(1,Math.round(e*n))}}function sh(e){return[e.source,e.width,e.height,e.devicePixelRatio,e.blurRadius].join(`\0`)}function ch(e,t,n,r,i){let a=n+i*2,o=r+i*2,s=Math.max(a/e,o/t),c=e*s,l=t*s;return{height:l,width:c,x:(n-c)/2,y:(r-l)/2}}function lh(e){let t=new Image;return t.decoding=`async`,t.src=e,t.decode().then(()=>t)}async function uh(e,t){let n=await lh(t.source);if(n.naturalWidth===0||n.naturalHeight===0)throw Error(`Decoded workbench background has no dimensions`);let r=oh(t.width,t.height,t.devicePixelRatio);e.width=r.width,e.height=r.height;let i=e.getContext(`2d`);if(i===null)throw Error(`Canvas 2D context is unavailable`);let a=ch(n.naturalWidth,n.naturalHeight,t.width,t.height,t.blurRadius),o=t.devicePixelRatio;i.clearRect(0,0,r.width,r.height),i.save(),t.blurRadius>0&&(i.filter=`blur(${String(t.blurRadius*o)}px)`),i.drawImage(n,a.x*o,a.y*o,a.width*o,a.height*o),i.restore()}function dh(e){try{let t=document.createElement(`canvas`);t.width=32,t.height=32;let n=t.getContext(`2d`,{willReadFrequently:!0});return n===null?null:(n.drawImage(e,0,0,t.width,t.height),n.getImageData(0,0,t.width,t.height).data)}catch{return null}}var fh=Math.sqrt(1.05*.05)-.05,ph=120;function mh(e){let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function hh(e){let t=[];for(let n=0;n+3<e.length;n+=4){if(e[n+3]===0)continue;let r=mh(e[n]??0),i=mh(e[n+1]??0),a=mh(e[n+2]??0);t.push(.2126*r+.7152*i+.0722*a)}return t.length===0?null:(t.sort((e,t)=>e-t),(t[Math.floor(t.length/2)]??0)>fh?`light`:`dark`)}function gh(e){return String(e).padStart(2,`0`)}function _h(e){return`/v1/workbench-background/bing?day=${`${String(e.getFullYear())}-${gh(e.getMonth()+1)}-${gh(e.getDate())}`}`}function vh(e){let t=new Date(e.getFullYear(),e.getMonth(),e.getDate()+1);return Math.max(1e3,t.getTime()-e.getTime()+1e3)}function yh(e){return Math.round((e/95*20+2**-52)*100)/100}function bh({backgroundTone:e,canvasRef:t,children:n,imageLoaded:r,preference:i}){return(0,X.jsxs)(`div`,{className:`workbench-background h-full min-h-0 overflow-hidden`,"data-background-mode":i.mode,"data-background-tone":e??void 0,"data-has-image":r,"data-workbench-background":`true`,children:[i.mode===`none`?null:(0,X.jsx)(`canvas`,{"aria-hidden":`true`,className:`workbench-background__canvas`,"data-workbench-background-canvas":`true`,ref:t,style:{opacity:+!!r}}),r?(0,X.jsx)(`div`,{"aria-hidden":`true`,className:`workbench-background__overlay`,"data-workbench-background-overlay":`true`,style:{opacity:i.overlayOpacity/100}}):null,n]})}function xh({children:e}){let[t,n]=(0,J.useState)(null),[r,i]=(0,J.useState)(()=>typeof window>`u`?zm:Ym(window.localStorage)),[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(()=>_h(new Date)),[l,u]=(0,J.useState)(!1),d=(0,J.useRef)(null),f=(0,J.useRef)(null);(0,J.useEffect)(()=>{let e=e=>{if(e instanceof CustomEvent){let t=e.detail;i(t)}};return window.addEventListener(Bm,e),()=>{window.removeEventListener(Bm,e)}},[]),(0,J.useEffect)(()=>{if(r.mode!==`custom`){o(null);return}let e=!1,t=null,n=r.selectedCustomImageId;if(n===null){o(null);return}return rh(n).then(n=>{e||n===null||(t=URL.createObjectURL(n),o(t))}).catch(()=>{e||o(null)}),()=>{e=!0,t!==null&&URL.revokeObjectURL(t)}},[r.mode,r.selectedCustomImageId]),(0,J.useEffect)(()=>{if(r.mode!==`bing`)return;let e,t=()=>{e=setTimeout(()=>{c(_h(new Date)),t()},vh(new Date))};return t(),()=>{clearTimeout(e)}},[r.mode]);let p=r.mode===`custom`?a:r.mode===`bing`?s:null;return(0,J.useEffect)(()=>{u(!1),n(null),f.current=null},[p]),(0,J.useEffect)(()=>{if(p===null)return;let e=!1,t,i=0,a,o=()=>{let t=d.current;if(t===null||t.clientWidth===0||t.clientHeight===0)return;let a=t.getBoundingClientRect(),o={blurRadius:yh(r.blurPercentage),devicePixelRatio:Math.max(1,window.devicePixelRatio||1),height:a.height,source:p,width:a.width},s=sh(o);if(f.current===s)return;let c=++i;uh(t,o).then(()=>{if(e||c!==i)return;f.current=s;let r=dh(t);n(r===null?null:hh(r)),u(!0)}).catch(()=>{e||c!==i||(f.current=null,n(null),u(!1))})},s=()=>{clearTimeout(t),t=setTimeout(o,ph)},c=()=>{a?.removeEventListener(`change`,l),a=window.matchMedia(`(resolution: ${String(window.devicePixelRatio)}dppx)`),a.addEventListener(`change`,l)};function l(){c(),s()}return o(),c(),window.addEventListener(`resize`,s),()=>{e=!0,i+=1,clearTimeout(t),window.removeEventListener(`resize`,s),a?.removeEventListener(`change`,l)}},[p,r.blurPercentage]),(0,X.jsx)(bh,{backgroundTone:t,canvasRef:d,imageLoaded:l,preference:r,children:e})}var Sh=ua({component:Ch,getParentRoute:()=>Nm,id:`workbench`});function Ch(){let e=Ma({select:e=>{let t=e.matches.at(-1)?.params;return{projectId:t!==void 0&&`projectId`in t?t.projectId:void 0,taskId:t!==void 0&&`taskId`in t?t.taskId:void 0}}});return(0,X.jsx)(xh,{children:(0,X.jsx)(Eh,{projectId:e.projectId??`temporary`,temporary:e.projectId===void 0,...e.taskId===void 0?{}:{taskId:e.taskId}})})}function wh(){return Gc(()=>import(`./workbench-shell-DQbj_ooS.js`),__vite__mapDeps([15,1,2,3,4,5,6,7,8,9,10,16,17,18,11,19,20,21,13,22,23,24,25,26,27,12,28]))}var Th=(0,J.lazy)(()=>wh().then(e=>({default:e.WorkbenchShell})));function Eh(e){let{t}=s(`common`);return(0,X.jsx)(J.Suspense,{fallback:(0,X.jsx)(`main`,{className:`grid h-full place-items-center text-sm text-muted-foreground`,role:`status`,children:t(`app.loadingProjects`)}),children:(0,X.jsx)(Th,{...e})})}var Dh=ua({getParentRoute:()=>Sh,path:`p/$projectId`}),Oh=1024*1024,kh=new Set([`gif`,`jpeg`,`jpg`,`png`,`webp`]),Ah=new Set(`7z.avi.dmg.doc.docm.docx.exe.gz.key.mov.mp3.mp4.numbers.odp.ods.odt.pages.pdf.pkg.ppt.pptm.pptx.rar.tar.tgz.wav.xls.xlsb.xlsm.xlsx.zip`.split(`.`));function jh(e){let t=e.split(/[\\/]/u).at(-1)?.toLowerCase()??``,n=t.includes(`.`)?t.split(`.`).at(-1)??``:``;return kh.has(n)?`image`:Ah.has(n)?`system`:`source`}function Mh(e){return e.kind===`image`?`image`:e.kind===`text`?`source`:e.size>1048576?`system`:jh(e.name)===`source`?`source`:`system`}var Nh=`codexly-project-file-popup`,Ph=`popup,width=1100,height=800,resizable=yes,scrollbars=yes`;function Fh(e){if(e==null||e===``)return null;let t=typeof e==`number`?e:Number(e);if(!Number.isSafeInteger(t)||t<1)throw TypeError(`Project file popup lineNumber must be a positive integer`);return t}function Ih(e){let t=e.path,n=e.previewKind,r=e.rootPath;if(typeof t!=`string`||t.length===0)throw TypeError(`Project file popup path is required`);if(n!==`image`&&n!==`source`)throw TypeError(`Project file popup previewKind is invalid`);if(r!==void 0&&typeof r!=`string`)throw TypeError(`Project file popup rootPath is invalid`);return{lineNumber:Fh(e.lineNumber),path:t,previewKind:n,...r===void 0?{}:{rootPath:r}}}function Lh(e,t,n,r){let i=jh(n.path);if(i===`system`)throw TypeError(`System-default files do not have an internal popup URL`);let a=new URL(`/p/${encodeURIComponent(t)}/file`,e);return a.searchParams.set(`path`,n.path),a.searchParams.set(`previewKind`,i),n.lineNumber!==null&&a.searchParams.set(`lineNumber`,String(n.lineNumber)),r!==void 0&&a.searchParams.set(`rootPath`,r),a.href}function Rh({onOpenSystemDefault:e,projectId:t,reference:n,rootPath:r}){if(jh(n.path)===`system`){e(n.path);return}let i=Lh(window.location.href,t,n,r);window.open(i,Nh,Ph)}var zh=ua({component:Hh,getParentRoute:()=>Nm,path:`p/$projectId/file`,validateSearch:Ih});function Bh(){return Gc(()=>import(`./project-file-popup-page-C5dOvxw_.js`),__vite__mapDeps([29,1,2,19,3,4,5,20,7,21,13,22]))}var Vh=(0,J.lazy)(()=>Bh().then(e=>({default:e.ProjectFilePopupPage})));function Hh(){let{projectId:e}=zh.useParams(),t=zh.useSearch();return(0,X.jsx)(J.Suspense,{fallback:null,children:(0,X.jsx)(Vh,{projectId:e,search:t})})}var Uh=ua({getParentRoute:()=>Sh,path:`p/$projectId/t/$taskId`}),Wh=ua({getParentRoute:()=>Sh,path:`temporary`}),Gh=ua({getParentRoute:()=>Sh,path:`temporary/t/$taskId`}),Kh=Oa({defaultPreload:`intent`,routeTree:Nm.addChildren([Lm,zh,Sh.addChildren([Dh,Uh,Wh,Gh])]),scrollRestoration:!0});function qh(){return(0,X.jsx)(ja,{router:Kh})}function Jh({error:e,loading:t,onPair:n,onRetry:r,pairing:i}){let{t:a}=s(`common`),[o,c]=(0,J.useState)(``);return(0,X.jsx)(`main`,{className:`access-gate grid h-full min-h-0 place-items-center overflow-y-auto bg-window px-5 py-10 text-foreground`,children:(0,X.jsxs)(`section`,{"aria-labelledby":`access-gate-title`,className:`w-full max-w-sm`,children:[(0,X.jsx)(`h1`,{className:`mb-8`,id:`access-gate-title`,children:(0,X.jsx)(`img`,{alt:`Codexly`,className:`h-10 w-auto`,height:`40`,src:`/brand/codexly-logo.svg`,width:`165`})}),t?(0,X.jsx)(`p`,{className:`text-body-small text-muted-foreground`,role:`status`,children:a(`access.checking`)}):e===`load`?(0,X.jsxs)(`div`,{className:`space-y-4`,role:`alert`,children:[(0,X.jsx)(`p`,{className:`text-body-small text-danger`,children:a(`access.loadError`)}),(0,X.jsxs)(F,{onClick:r,size:`lg`,type:`button`,variant:`secondary`,children:[(0,X.jsx)(vl,{"aria-hidden":`true`,className:`size-4`}),a(`actions.retry`)]})]}):(0,X.jsxs)(`form`,{className:`space-y-5`,onSubmit:e=>{e.preventDefault();let t=o.trim();t.length>0&&!i&&n(t)},children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`text-heading font-semibold`,children:a(`access.pairingTitle`)}),(0,X.jsx)(`p`,{className:`mt-1 text-body-small text-muted-foreground`,children:a(`access.pairingDescription`)})]}),(0,X.jsx)(`label`,{className:`block text-body-small font-medium`,htmlFor:`access-pairing-code`,children:a(`access.codeLabel`)}),(0,X.jsxs)(`div`,{className:`flex h-10 items-center rounded-control border border-separator-strong bg-panel focus-within:border-brand focus-within:shadow-focus`,children:[(0,X.jsx)(ul,{"aria-hidden":`true`,className:`ml-3 size-4 shrink-0 text-muted-foreground`}),(0,X.jsx)(vt,{"aria-label":a(`access.codeLabel`),autoComplete:`current-password`,className:`access-code-input min-w-0 flex-1 bg-transparent px-3 font-mono text-body`,id:`access-pairing-code`,onChange:e=>{c(e.currentTarget.value)},spellCheck:!1,type:`password`,value:o,variant:`embedded`}),(0,X.jsx)(F,{"aria-label":a(`access.pair`),className:`mr-1`,disabled:i||o.trim().length===0,title:a(`access.pair`),type:`submit`,size:`icon-compact`,children:(0,X.jsx)(tl,{"aria-hidden":`true`,className:`size-4`})})]}),i?(0,X.jsx)(`p`,{className:`text-meta text-muted-foreground`,role:`status`,children:a(`access.pairing`)}):null]})]})})}function Yh({disabled:e,models:t,onAdd:n,onChange:r,onRemove:i}){let{t:a}=s(`settings`);return(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[t.length===0?null:(0,X.jsxs)(`div`,{className:`hidden grid-cols-[minmax(0,1fr)_minmax(0,1fr)_2rem] gap-2 px-1 text-meta font-medium text-muted-foreground sm:grid`,children:[(0,X.jsx)(`span`,{children:a(`provider.modelId`)}),(0,X.jsx)(`span`,{children:a(`provider.modelName`)}),(0,X.jsx)(`span`,{})]}),t.map(t=>(0,X.jsxs)(`div`,{className:`grid gap-2 border-b border-separator pb-3 sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_2rem] sm:items-end`,children:[(0,X.jsxs)(`label`,{className:`grid min-w-0 gap-1`,children:[(0,X.jsx)(`span`,{className:`text-meta font-medium text-muted-foreground sm:sr-only`,children:a(`provider.modelId`)}),(0,X.jsx)(vt,{autoCapitalize:`none`,autoComplete:`off`,disabled:e,maxLength:256,onChange:e=>{r(t.key,`id`,e.currentTarget.value)},spellCheck:!1,value:t.id,variant:`outline`})]}),(0,X.jsxs)(`label`,{className:`grid min-w-0 gap-1`,children:[(0,X.jsx)(`span`,{className:`text-meta font-medium text-muted-foreground sm:sr-only`,children:a(`provider.modelName`)}),(0,X.jsx)(vt,{autoComplete:`off`,disabled:e,maxLength:256,onChange:e=>{r(t.key,`name`,e.currentTarget.value)},value:t.name,variant:`outline`})]}),(0,X.jsxs)(De,{children:[(0,X.jsx)(he,{asChild:!0,children:(0,X.jsx)(F,{"aria-label":a(`provider.removeModel`),className:`justify-self-end sm:justify-self-auto`,disabled:e,onClick:()=>{i(t.key)},size:`icon-compact`,type:`button`,variant:`ghost`,children:(0,X.jsx)(bt,{"aria-hidden":`true`,className:`size-4`})})}),(0,X.jsx)(ve,{children:a(`provider.removeModel`)})]})]},t.key)),(0,X.jsxs)(F,{className:`justify-self-start`,disabled:e||t.length>=1e3,onClick:n,type:`button`,variant:`outline`,children:[(0,X.jsx)(Fe,{"aria-hidden":`true`,className:`size-4`}),a(`provider.addModel`)]})]})}function Xh({apiKey:e,baseUrl:t,error:n,isBusy:r,mode:i,models:a,onAddModel:o,onApiKeyChange:c,onBaseUrlChange:l,onCancelLogin:u,onConfigureCustom:d,onLogout:f,onModelChange:p,onModeChange:m,onRetry:h,onRemoveModel:g,onStartOfficialLogin:_,status:v}){let{t:y}=s(`settings`),b=v?.mode===i&&v.state===`connected`,x=v?.mode===`official`&&v.state===`pending`;return(0,X.jsxs)(`div`,{className:`w-full max-w-[38rem]`,children:[(0,X.jsxs)(`div`,{"aria-label":y(`provider.mode`),className:`grid grid-cols-2 rounded-control bg-control p-1`,role:`group`,children:[(0,X.jsxs)(F,{"aria-pressed":i===`official`,className:L(`inline-flex h-10 items-center justify-center gap-2 rounded-[5px] text-body-small font-medium sm:h-9`,i===`official`?`bg-raised text-foreground shadow-control`:`text-muted-foreground hover:text-foreground`),onClick:()=>{m(`official`)},type:`button`,variant:`ghost`,children:[(0,X.jsx)(dl,{"aria-hidden":`true`,"data-icon":`inline-start`}),y(`provider.official`)]}),(0,X.jsxs)(F,{"aria-pressed":i===`custom`,className:L(`inline-flex h-10 items-center justify-center gap-2 rounded-[5px] text-body-small font-medium sm:h-9`,i===`custom`?`bg-raised text-foreground shadow-control`:`text-muted-foreground hover:text-foreground`),onClick:()=>{m(`custom`)},type:`button`,variant:`ghost`,children:[(0,X.jsx)(xl,{"aria-hidden":`true`,"data-icon":`inline-start`}),y(`provider.custom`)]})]}),(0,X.jsx)(`div`,{className:`mt-5`,children:i===`official`?(0,X.jsxs)(`div`,{className:`grid gap-4`,children:[(0,X.jsxs)(`div`,{className:`flex min-h-12 items-center gap-3 border-b border-separator pb-4`,children:[b?(0,X.jsx)(St,{"aria-hidden":`true`,className:`size-5 shrink-0 text-brand`}):x?(0,X.jsx)(Ue,{"aria-hidden":`true`,className:`size-5 shrink-0 animate-spin text-brand`}):(0,X.jsx)(dl,{"aria-hidden":`true`,className:`size-5 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`text-body-small font-medium text-foreground`,children:y(b?`provider.connected`:x?`provider.waiting`:`provider.disconnected`)}),v?.account?.type===`chatgpt`&&v.account.email!==null?(0,X.jsx)(`p`,{className:`truncate text-meta text-muted-foreground`,children:v.account.email}):null]})]}),x?(0,X.jsxs)(F,{className:`h-11 justify-self-start sm:h-9`,disabled:r,onClick:u,type:`button`,variant:`outline`,children:[(0,X.jsx)(wl,{"aria-hidden":`true`,className:`size-4`}),y(`provider.cancelLogin`)]}):b?(0,X.jsxs)(F,{className:`h-11 justify-self-start sm:h-9`,disabled:r,onClick:f,type:`button`,variant:`outline`,children:[(0,X.jsx)(fl,{"aria-hidden":`true`,className:`size-4`}),y(`provider.logout`)]}):(0,X.jsxs)(F,{className:`h-11 justify-self-start sm:h-9`,disabled:r,onClick:_,type:`button`,children:[r?(0,X.jsx)(Ue,{"aria-hidden":`true`,className:`size-4 animate-spin`}):(0,X.jsx)(dl,{"aria-hidden":`true`,className:`size-4`}),y(`provider.login`)]})]}):(0,X.jsxs)(`div`,{className:`grid gap-4`,children:[(0,X.jsxs)(`label`,{className:`grid gap-1.5 text-body-small font-medium text-foreground`,children:[y(`provider.baseUrl`),(0,X.jsx)(vt,{autoCapitalize:`none`,autoComplete:`url`,disabled:r,inputMode:`url`,maxLength:2048,onChange:e=>{l(e.currentTarget.value)},placeholder:`https://api.example.com/v1`,spellCheck:!1,type:`url`,value:t,variant:`outline`})]}),(0,X.jsxs)(`label`,{className:`grid gap-1.5 text-body-small font-medium text-foreground`,children:[y(`provider.apiKey`),(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(ul,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,X.jsx)(vt,{autoComplete:`new-password`,className:`pl-9`,disabled:r,maxLength:16384,onChange:e=>{c(e.currentTarget.value)},spellCheck:!1,type:`password`,value:e,variant:`outline`})]})]}),(0,X.jsxs)(`div`,{className:`grid gap-1.5 text-body-small font-medium text-foreground`,children:[(0,X.jsx)(`span`,{children:y(`provider.models`)}),(0,X.jsx)(Yh,{disabled:r,models:a,onAdd:o,onChange:p,onRemove:g})]}),b?(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small text-brand`,children:[(0,X.jsx)(St,{"aria-hidden":`true`,className:`size-4`}),(0,X.jsx)(`span`,{children:y(`provider.connected`)})]}):null,(0,X.jsxs)(F,{className:`h-11 justify-self-start sm:h-9`,disabled:r||t.trim().length===0||Zh(a),onClick:d,type:`button`,children:[r?(0,X.jsx)(Ue,{"aria-hidden":`true`,className:`size-4 animate-spin`}):(0,X.jsx)(xl,{"aria-hidden":`true`,className:`size-4`}),y(b?`provider.reconnect`:`provider.connect`)]})]})}),n===null?null:(0,X.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-3 text-body-small`,role:`alert`,children:[(0,X.jsx)(`p`,{className:`min-w-0 text-danger`,children:n}),(0,X.jsx)(F,{"aria-label":y(`provider.retry`),className:`shrink-0`,onClick:h,size:`icon-sm`,type:`button`,variant:`ghost`,children:(0,X.jsx)(gt,{"aria-hidden":`true`,className:`size-4`})})]})]})}function Zh(e){return e.some(e=>e.id.trim().length===0||e.name.trim().length===0)}function Qh({apiKey:e,baseUrl:t,models:n}){let r=n.map(({id:e,name:t})=>({id:e.trim(),name:t.trim()}));return{...e.length===0?{}:{apiKey:e},baseUrl:t.trim(),...r.length===0?{}:{models:r}}}function $h(e){let t=new URL(e);if(t.protocol!==`https:`)throw Error(`Official login URL must use HTTPS`);window.open(t,`_blank`,`noopener,noreferrer`)}function eg(){let e=le(),t=He(ht()),n=q(pt(e)),r=q(xt(e)),i=q(yt(e)),[a,o]=(0,J.useState)(`official`),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(``),[d,f]=(0,J.useState)([]),p=(0,J.useRef)(1),[m,h]=(0,J.useState)(!1),g=t.data;(0,J.useEffect)(()=>{g!==void 0&&(o(g.mode),g.customBaseUrl!==null&&c(g.customBaseUrl))},[g]);let _=n.isPending||r.isPending||i.isPending||m;return(0,X.jsx)(Xh,{apiKey:l,baseUrl:s,error:t.error?.message??null,isBusy:_,mode:a,models:d,onAddModel:()=>{let e=`custom-model-${String(p.current)}`;p.current+=1,f(t=>[...t,{id:``,key:e,name:``}])},onApiKeyChange:u,onBaseUrlChange:c,onCancelLogin:()=>{let e=g?.pendingLogin?.loginId;e!==void 0&&r.mutateAsync(e).catch(()=>void 0)},onConfigureCustom:()=>{h(!0),_t(Qh({apiKey:l,baseUrl:s,models:d}),e).then(()=>{u(``),Ie()}).catch(e=>{Me(e)}).finally(()=>{u(``),h(!1)})},onLogout:()=>{i.mutateAsync().catch(()=>void 0)},onModelChange:(e,t,n)=>{f(r=>r.map(r=>r.key===e?{...r,[t]:n}:r))},onModeChange:e=>{o(e)},onRetry:()=>{t.refetch()},onRemoveModel:e=>{f(t=>t.filter(t=>t.key!==e))},onStartOfficialLogin:()=>{n.mutateAsync().then(e=>{try{$h(e.authUrl)}catch(e){Me(e)}}).catch(()=>void 0)},status:g})}function tg({children:e}){let{t}=s(`settings`),n=He(ht());return n.data?.state===`connected`?e:n.isPending?(0,X.jsx)(`main`,{className:`grid h-full min-h-0 place-items-center bg-window text-body-small text-muted-foreground`,children:t(`provider.loading`)}):(0,X.jsx)(`main`,{className:`h-full min-h-0 overflow-y-auto bg-window px-5 py-8 sm:px-8 sm:py-12`,children:(0,X.jsxs)(`div`,{className:`mx-auto w-full max-w-[42rem]`,children:[(0,X.jsxs)(`header`,{className:`mb-8 border-b border-separator pb-5`,children:[(0,X.jsx)(`h1`,{className:`text-xl font-semibold text-foreground`,children:`Codexly`}),(0,X.jsx)(`p`,{className:`mt-1 text-body-small text-muted-foreground`,children:t(`provider.title`)})]}),n.error===null?(0,X.jsx)(eg,{}):(0,X.jsxs)(`div`,{className:`grid justify-items-start gap-3`,role:`alert`,children:[(0,X.jsx)(`p`,{className:`text-body-small text-danger`,children:t(`provider.errors.load`)}),(0,X.jsx)(F,{onClick:()=>void n.refetch(),type:`button`,variant:`outline`,children:t(`provider.retry`)})]})]})})}var ng={attachments:[],content:[]},rg=`codexly:composer-draft:v1:`,ig=(0,J.createContext)(void 0);function ag(e,t){return JSON.stringify([e,t??`draft`])}function og(e){return e.content.length===0&&e.attachments.length===0}function sg(e){return e.attachments.map(e=>e.previewUrl)}function cg(e){for(let t of new Set(sg(e)))t.startsWith(`blob:`)&&URL.revokeObjectURL(t)}function lg(e,t){let n=new Set(sg(t));for(let t of new Set(sg(e)))!n.has(t)&&t.startsWith(`blob:`)&&URL.revokeObjectURL(t)}function ug(){try{return globalThis.localStorage}catch{return}}function dg(e,t){try{let n=JSON.parse(e?.getItem(`${rg}${t}`)??`null`);if(typeof n!=`object`||!n)return;let r=n;return!Array.isArray(r.content)||!Array.isArray(r.attachments)?void 0:r}catch{return}}function fg(e,t,n){if(e===void 0)return;let r=`${rg}${t}`;if(n===void 0){e.removeItem(r);return}e.setItem(r,JSON.stringify({attachments:n.attachments.filter(e=>e.source===`host`),content:n.content}))}function pg(e=ug()){let t=new Map,n=n=>{let r=t.get(n);if(r!==void 0)return r;let i=dg(e,n);return i!==void 0&&t.set(n,i),i??ng};return{clear:n=>{let r=t.get(n);r!==void 0&&(cg(r),t.delete(n)),fg(e,n,void 0)},dispose:()=>{t.forEach(cg),t.clear()},read:n,update:(r,i)=>{let a=n(r),o=i(a);lg(a,o),og(o)?(t.delete(r),fg(e,r,void 0)):(t.set(r,o),fg(e,r,o))}}}function mg({children:e}){let t=(0,J.useRef)(pg()).current;return(0,J.useEffect)(()=>()=>{t.dispose()},[t]),(0,X.jsx)(ig.Provider,{value:t,children:e})}function hg(){let e=(0,J.useContext)(ig);if(e===void 0)throw Error(`useComposerDraftStore must be used inside ComposerDraftProvider`);return e}var gg=`codexly.notification-preference`,_g=1;function vg(e){try{let t=JSON.parse(e.getItem(gg)??`null`);if(typeof t==`object`&&t&&`version`in t&&t.version===_g&&`enabled`in t&&typeof t.enabled==`boolean`)return t.enabled}catch{}return!0}function yg(e,t){try{t.setItem(gg,JSON.stringify({enabled:e,version:_g}))}catch{}}function bg(){try{return typeof window>`u`||vg(window.localStorage)}catch{return!0}}function xg(e){try{typeof window<`u`&&yg(e,window.localStorage)}catch{}}var Sg=48*1048576;function Cg(e){return Array.isArray(e)&&e.length===4&&e[0]===`projects`&&typeof e[1]==`string`&&e[2]===`tasks`&&typeof e[3]==`string`}function wg(e,t=Sg,n=12){let r=new cc({getRetainedBytes:(e,t)=>t.retainedBytes,maxBytes:t,maxEntries:n,onEvict(t,n,r){r!==`replaced`&&e.getQueryCache().find({exact:!0,queryKey:n.queryKey})?.getObserversCount()===0&&e.removeQueries({exact:!0,queryKey:n.queryKey})}});return e.getQueryCache().subscribe(e=>{let t=e.query,n=t.queryKey,i=t.queryHash,a=t.state.data;if(!(!Cg(n)||typeof i!=`string`)){if(e.type===`removed`||t.getObserversCount()>0||a===void 0){r.delete(i);return}r.set(i,{queryKey:n,retainedBytes:Q(a)})}})}var Tg=2*6e4;function Eg(){let e=new La({mutationCache:Pe(),defaultOptions:{queries:{gcTime:Tg,refetchOnWindowFocus:!1,retry:1,staleTime:3e4}}});return wg(e),e}var Dg=Eg();function Og(e,t){e===`temporary`?Kh.navigate({params:{taskId:t},to:`/temporary/t/$taskId`}):Kh.navigate({params:{projectId:e,taskId:t},to:`/p/$projectId/t/$taskId`})}var kg=Bs({isEnabled:bg,navigateToTask:Og});function Ag({access:e,children:t}){return e.status?.authenticated===!0?t:(0,X.jsx)(Jh,{error:e.error,loading:e.loading,onPair:e.pair,onRetry:e.retry,pairing:e.pairing})}function jg({children:e}){let t=Zc(),{t:n}=s(`common`);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ag,{access:t,children:(0,X.jsx)(tg,{children:(0,X.jsx)(Vc,{taskNotifier:kg,children:(0,X.jsx)(mg,{children:e})})})}),(0,X.jsx)(Re,{containerAriaLabel:n(`app.notificationRegion`),duration:5e3,position:`top-center`,richColors:!0,theme:`system`})]})}function Mg({children:e}){return(0,X.jsx)(xo,{i18n:l,children:(0,X.jsx)(Ce,{children:(0,X.jsx)(ie,{client:Dg,children:(0,X.jsx)(Xc,{client:K,queryClient:Dg,children:(0,X.jsx)(jg,{children:e})})})})})}var Ng=`codexly.theme-preference`,Pg=1,Fg=`(prefers-color-scheme: dark)`,Ig;function Lg(e){try{let t=JSON.parse(e.getItem(Ng)??`null`);if(typeof t==`object`&&t&&`version`in t&&t.version===Pg&&`theme`in t&&(t.theme===`dark`||t.theme===`light`||t.theme===`system`))return t.theme}catch{}return`system`}function Rg(e,t){try{t.setItem(Ng,JSON.stringify({theme:e,version:Pg}))}catch{}}function zg(e,t,n=!1){t.dataset.theme=e===`system`?n?`dark`:`light`:e}function Bg(e){Ig?.(),Ig=void 0;let t=window.matchMedia(Fg),n=()=>{zg(e,document.documentElement,t.matches)};n(),e===`system`&&(t.addEventListener(`change`,n),Ig=()=>{t.removeEventListener(`change`,n)})}function Vg(e){Rg(e,window.localStorage),Bg(e)}function Hg(){let e=Lg(window.localStorage);return Bg(e),e}var Ug=document.querySelector(`#root`);if(!(Ug instanceof HTMLElement))throw Error(`Missing #root element`);Hg(),(0,Ba.createRoot)(Ug).render((0,X.jsx)(J.StrictMode,{children:(0,X.jsx)(Mg,{children:(0,X.jsx)(qh,{})})}));export{Tl as $,im as A,ts as At,Op as B,Vo as Bt,am as C,Yo as Ct,lm as D,ps as Dt,cm as E,Jo as Et,Ep as F,ls as Ft,bp as G,To as Gt,yp as H,Do as Ht,Ap as I,cs as It,xu as J,Ha as Jt,Sp as K,Va as Kt,Dp as L,os as Lt,Qp as M,ds as Mt,Vp as N,us as Nt,sm as O,fs as Ot,Fp as P,ss as Pt,Ml as Q,jp as R,Zo as Rt,tm as S,Xo as St,om as T,es as Tt,Cp as U,ko as Ut,hp as V,rs as Vt,xp as W,wo as Wt,Ul as X,qi as Xt,lu as Y,Ra as Yt,Wl as Z,Ym as _,Os as _t,ag as a,cl as at,fm as b,As as bt,Rh as c,rl as ct,jh as d,Gc as dt,wl as et,zm as f,Ic as ft,nh as g,sc as gt,Zm as h,Q as ht,xg as i,fl as it,rm as j,ms as jt,$p as k,ns as kt,Oh as l,Zc as lt,Qm as m,cc as mt,Vg as n,hl as nt,hg as o,ol as ot,ah as p,yc as pt,gp as q,Ua as qt,bg as r,pl as rt,eg as s,al as st,Lg as t,_l as tt,Mh as u,Kc as ut,$m as v,ks as vt,nm as w,$o as wt,Zp as x,_s as xt,Am as y,Ds as yt,kp as z,Qo as zt};
|