decocms 4.11.14 → 4.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{AlertCircle-CqwVKs4c.js → AlertCircle-ClgAhfOn.js} +1 -1
- package/dist/client/assets/{ArrowUpRight-CED6ndCh.js → ArrowUpRight-B862Up1l.js} +1 -1
- package/dist/client/assets/{CheckCircle-BeClS62J.js → CheckCircle-D6Zd00g5.js} +1 -1
- package/dist/client/assets/{ChevronDown-D5ZAHq8C.js → ChevronDown-CavzOb2e.js} +1 -1
- package/dist/client/assets/{ChevronRight-p1IOWwCq.js → ChevronRight-DgXTGSyd.js} +1 -1
- package/dist/client/assets/{ChevronUp-qi2zlJbj.js → ChevronUp-DWl02poJ.js} +1 -1
- package/dist/client/assets/{DotsVertical-CPX0ApPY.js → DotsVertical-BXUN7i-s.js} +1 -1
- package/dist/client/assets/{Eye-ChyuimlO.js → Eye-BfxF3_NG.js} +1 -1
- package/dist/client/assets/{FilterLines-B7RIEUU-.js → FilterLines-CHINsit0.js} +1 -1
- package/dist/client/assets/{Globe01-CSbQaAOU.js → Globe01-7w14Dv0L.js} +1 -1
- package/dist/client/assets/{Globe04-CKX2tmjZ.js → Globe04-BmVvGcdk.js} +1 -1
- package/dist/client/assets/{HardDrive-BTgncQXB.js → HardDrive-C3esngx2.js} +1 -1
- package/dist/client/assets/{Key01-BW4SKvZI.js → Key01-D84zmw8T.js} +1 -1
- package/dist/client/assets/{LayoutLeft-BdaRkmaX.js → LayoutLeft-BzG5LgFk.js} +1 -1
- package/dist/client/assets/{LinkExternal01-Cy4W-B6b.js → LinkExternal01-DwRUHK9K.js} +1 -1
- package/dist/client/assets/{Monitor01-DSc7ZJBq.js → Monitor01-D6j19kcU.js} +1 -1
- package/dist/client/assets/{Palette-Brgn8aWM.js → Palette-DVeyHPSn.js} +1 -1
- package/dist/client/assets/{Play-DaV1T59S.js → Play-DnC6BFen.js} +1 -1
- package/dist/client/assets/{Plus-BvTTNpUi.js → Plus-DE2oM9NP.js} +1 -1
- package/dist/client/assets/{SearchLg-BV0AuFFU.js → SearchLg-wiFmsHKn.js} +1 -1
- package/dist/client/assets/{SearchMd-c8C4u1L7.js → SearchMd-3hwS3MeL.js} +1 -1
- package/dist/client/assets/{Settings02-CzYVBYwk.js → Settings02-D77UEQ2p.js} +1 -1
- package/dist/client/assets/{Shield01-Cycg2C0o.js → Shield01-DGllkrSj.js} +1 -1
- package/dist/client/assets/{Star01-B7zb2THr.js → Star01-tqRKmSvv.js} +1 -1
- package/dist/client/assets/{Stars01-3V3ei1I8.js → Stars01-BcSQPbwD.js} +1 -1
- package/dist/client/assets/{Stars02-DZEKLUYU.js → Stars02-C-4lNJ_k.js} +1 -1
- package/dist/client/assets/{Sun-CF88ih-f.js → Sun-CWsRADe_.js} +1 -1
- package/dist/client/assets/{SwitchHorizontal01-CVIT3pvO.js → SwitchHorizontal01-DcPy-VUg.js} +1 -1
- package/dist/client/assets/{Tool01-Dqm9uO5c.js → Tool01-Cl2bl9JY.js} +1 -1
- package/dist/client/assets/{Trash01-Pm6WJfx3.js → Trash01-D75-03uB.js} +1 -1
- package/dist/client/assets/{Upload01-_1bkJo-2.js → Upload01-Z-VVijrs.js} +1 -1
- package/dist/client/assets/{User01-KxyCL87Z.js → User01-BgkBgTes.js} +1 -1
- package/dist/client/assets/{Users01-CgqlpnWe.js → Users01-Cmsl-eTQ.js} +1 -1
- package/dist/client/assets/{Users03-BzdZqGuX.js → Users03-DT08k8_1.js} +1 -1
- package/dist/client/assets/{X-QnL1_jwj.js → X-BVAUYa_T.js} +1 -1
- package/dist/client/assets/{XCircle-DdtQjEIT.js → XCircle-QoSkb3Jx.js} +1 -1
- package/dist/client/assets/{XClose-CXvUnVsl.js → XClose-CPn-2iye.js} +1 -1
- package/dist/client/assets/{Zap-Bp3kazzB.js → Zap-B36bkz1F.js} +1 -1
- package/dist/client/assets/{ZapSquare-D_EJc_wK.js → ZapSquare-ogfO4bZI.js} +1 -1
- package/dist/client/assets/{ZoomOut-Bk81Ty3E.js → ZoomOut-5HsDnkoy.js} +1 -1
- package/dist/client/assets/{access-gate-ySaA-OuX.js → access-gate-BRNjXWYe.js} +1 -1
- package/dist/client/assets/{add-section-modal-BYBx1539.js → add-section-modal-BOqz-964.js} +1 -1
- package/dist/client/assets/{agent-icon-D9w3KE0I.js → agent-icon-aNPmoaPd.js} +1 -1
- package/dist/client/assets/{agents-list-arY9mxO1.js → agents-list-B7j1GcyH.js} +1 -1
- package/dist/client/assets/{ai-providers-AFOaklAD.js → ai-providers-CYCuk9h-.js} +1 -1
- package/dist/client/assets/{alert-2EurlPTk.js → alert-CuDjX_qg.js} +1 -1
- package/dist/client/assets/{alert-dialog-D3kFS9Xx.js → alert-dialog-ac9d9PM5.js} +1 -1
- package/dist/client/assets/{app-editor-Cqa11QpG.js → app-editor-0CPOfgpn.js} +1 -1
- package/dist/client/assets/{auth-BS0r-1X4.js → auth-CiRpWlv5.js} +1 -1
- package/dist/client/assets/{auth-catchall-C1oph0JF.js → auth-catchall-DOctWB-A.js} +1 -1
- package/dist/client/assets/{auth-entry-h3rQxTSq.js → auth-entry-Am18NSNg.js} +1 -1
- package/dist/client/assets/{auth-split-layout-hPtSSLhE.js → auth-split-layout-CO3AbWz1.js} +1 -1
- package/dist/client/assets/{authenticate-and-persist-oauth-CsZcEHyY.js → authenticate-and-persist-oauth-C7yk75O_.js} +1 -1
- package/dist/client/assets/{automation-list-row-Cu7XHsno.js → automation-list-row-D2B_rh4A.js} +1 -1
- package/dist/client/assets/{automation-runs-BGVlA6Ga.js → automation-runs-8_dybPHZ.js} +1 -1
- package/dist/client/assets/{automations-CSc3sYoT.js → automations-CeEWyIs5.js} +1 -1
- package/dist/client/assets/{avatar-D86BabR9.js → avatar-BjKWRNVB.js} +1 -1
- package/dist/client/assets/{badge-Cq5_vU6x.js → badge-BJNy0wyL.js} +1 -1
- package/dist/client/assets/{block-document-CFJQWoq6.js → block-document-Bq8rRDx4.js} +1 -1
- package/dist/client/assets/{brand-context-CQL2xUHS.js → brand-context-BIrrLjGn.js} +1 -1
- package/dist/client/assets/{buckets-xc2BWhax.js → buckets-obXQMBpg.js} +1 -1
- package/dist/client/assets/{bulk-category-panel-Cyw3TrSE.js → bulk-category-panel-Cod4y6Ks.js} +1 -1
- package/dist/client/assets/{capability-load-error-B3VG435f.js → capability-load-error-D8MHuUCF.js} +1 -1
- package/dist/client/assets/{card-JmDifMtn.js → card-BmW79tCv.js} +1 -1
- package/dist/client/assets/{category-editor-CjO8y5jo.js → category-editor-BJepbxNv.js} +1 -1
- package/dist/client/assets/{chat-context-BQLW9kkK.js → chat-context-B5hrLcwj.js} +1 -1
- package/dist/client/assets/{checkbox-ClHoRUlZ.js → checkbox-Kg4LLU9D.js} +1 -1
- package/dist/client/assets/{cli-auth-success-DWHv9nh5.js → cli-auth-success-gObPiJa8.js} +1 -1
- package/dist/client/assets/{collection-detail-BWX6FJtv.js → collection-detail-B0-T4ILL.js} +1 -1
- package/dist/client/assets/{collection-display-button-BYNS0JNz.js → collection-display-button-BvXYTAAP.js} +1 -1
- package/dist/client/assets/{collection-search-C_1AD6YQ.js → collection-search-DwhBerSk.js} +1 -1
- package/dist/client/assets/{collection-tabs-7Ft93VyB.js → collection-tabs-BQDCpcYC.js} +1 -1
- package/dist/client/assets/{command-BH_mb2ud.js → command-SyxeX2nl.js} +1 -1
- package/dist/client/assets/commerce-onboarding-DGsLAJMy.js +1 -0
- package/dist/client/assets/{connect-desktop-dialog-DX-5ff0q.js → connect-desktop-dialog-DlP4AIXL.js} +1 -1
- package/dist/client/assets/{connection-card-DQxW9rgJ.js → connection-card-C4oOxnQb.js} +1 -1
- package/dist/client/assets/{connection-detail-BYcW_pPO.js → connection-detail-DBJW-Pxx.js} +1 -1
- package/dist/client/assets/{connection-form-helpers-e83YdLh2.js → connection-form-helpers-FkUfzqP1.js} +1 -1
- package/dist/client/assets/{connections-C1O7v-tW.js → connections-CM5IOfmS.js} +1 -1
- package/dist/client/assets/{context-menu-CYyv2p0M.js → context-menu-NrhGe5Oj.js} +1 -1
- package/dist/client/assets/{decopilot-DpuV-Swz.js → decopilot-Cj_SKATh.js} +1 -1
- package/dist/client/assets/{decopilot-sse-pool-DWRDxmrh.js → decopilot-sse-pool-Bxsm1x-g.js} +1 -1
- package/dist/client/assets/{dialog-blJw2JGa.js → dialog-DsOssLqX.js} +1 -1
- package/dist/client/assets/{domain-settings-DgqGYvaA.js → domain-settings-Dkt1DWnP.js} +1 -1
- package/dist/client/assets/{drawer-VlXqa2RL.js → drawer-AyckCMmd.js} +1 -1
- package/dist/client/assets/{dropdown-menu-W43dsA5C.js → dropdown-menu-wQ-uELKw.js} +1 -1
- package/dist/client/assets/{empty-state-sTDUBWfL.js → empty-state-CNU5O4hk.js} +1 -1
- package/dist/client/assets/{extract-connection-data-xmb7h_DD.js → extract-connection-data-wL-0uC4r.js} +1 -1
- package/dist/client/assets/{file-explorer-DkK3gDL2.js → file-explorer-BEoaplFh.js} +1 -1
- package/dist/client/assets/{file-type-icon-B8mbw-yE.js → file-type-icon-B0qdUvEN.js} +1 -1
- package/dist/client/assets/{files-CGe3iDxV.js → files-dNTrWuZj.js} +1 -1
- package/dist/client/assets/{form-BXg3zbwg.js → form-BHvZi-GZ.js} +1 -1
- package/dist/client/assets/{general-tzR9GMuH.js → general-Dp9n9ALL.js} +1 -1
- package/dist/client/assets/{github-repo-picker-BGtEhImx.js → github-repo-picker-B2FKQ_5-.js} +1 -1
- package/dist/client/assets/{hooks-b-ZTOz-h.js → hooks-5_uPY02P.js} +1 -1
- package/dist/client/assets/{import-from-deco-dialog-CfjmUkKE.js → import-from-deco-dialog-CtmOo7gy.js} +1 -1
- package/dist/client/assets/index-18VPlu9_.js +513 -0
- package/dist/client/assets/{index-BUGw9YhO.js → index-5GIHeL-g.js} +1 -1
- package/dist/client/assets/{index-DKby5VWi.js → index-B3Ofs7GR.js} +1 -1
- package/dist/client/assets/{index-Cn7rcOpx.js → index-BD6No7__.js} +1 -1
- package/dist/client/assets/{index-DT3yu7Zl.js → index-BP3Art5K.js} +1 -1
- package/dist/client/assets/index-BihoOK2W.js +1 -0
- package/dist/client/assets/{index-Zxf1K2Y0.js → index-BkMvO6br.js} +1 -1
- package/dist/client/assets/{index-DqSOj5mm.js → index-C74-7rC_.js} +3 -3
- package/dist/client/assets/{index-C2OyMQ9A.js → index-CIxzNHgu.js} +1 -1
- package/dist/client/assets/{index-CG_U30LC.js → index-D0eNritY.js} +1 -1
- package/dist/client/assets/{index-D4dzqiiy.js → index-DPOBsX9s.js} +1 -1
- package/dist/client/assets/index-DS7PxLny.css +1 -0
- package/dist/client/assets/{index-DYxlhice.js → index-Dj_tbWDC.js} +1 -1
- package/dist/client/assets/{index-CFtT-a2U.js → index-GxYhZPOH.js} +1 -1
- package/dist/client/assets/{index-DjMaa3g6.js → index-laMg9IJJ.js} +1 -1
- package/dist/client/assets/{index-redirect-BAeaDYeT.js → index-redirect-qJTq73AQ.js} +1 -1
- package/dist/client/assets/{input-H9MW7QWS.js → input-ClQQvwn8.js} +1 -1
- package/dist/client/assets/{integration-icon-CD6ASMsi.js → integration-icon-CXTBoi-C.js} +1 -1
- package/dist/client/assets/{label-CHE1Rjd0.js → label-DtyPJXbW.js} +1 -1
- package/dist/client/assets/{login-D-WEUgAk.js → login-DpEp4bzD.js} +1 -1
- package/dist/client/assets/{mcp-oauth-BsNEq7j-.js → mcp-oauth-BZR_sfsi.js} +1 -1
- package/dist/client/assets/{members-dgTZNPJD.js → members-Da-N4F4w.js} +1 -1
- package/dist/client/assets/{monaco-editor-i-UEBrYO.js → monaco-editor-C0-ORVvv.js} +1 -1
- package/dist/client/assets/{monitoring-stats-row-BzK-ej_j.js → monitoring-stats-row-DaKaZFWH.js} +1 -1
- package/dist/client/assets/{oauth-callback-BaMTMXBx.js → oauth-callback-C1VskdWn.js} +1 -1
- package/dist/client/assets/{oauth-callback-ai-provider-2q9rs429.js → oauth-callback-ai-provider-DJ_dLXG7.js} +1 -1
- package/dist/client/assets/{onboarding-ClD0PSXC.js → onboarding-CUBIxT9d.js} +1 -1
- package/dist/client/assets/{org-install-B0eUnxaI.js → org-install-Badols3M.js} +1 -1
- package/dist/client/assets/{org-layout-BV3vhFpx.js → org-layout-UVOciCax.js} +1 -1
- package/dist/client/assets/{organization-choice-BYeFep5g.js → organization-choice-BzwxXw2g.js} +1 -1
- package/dist/client/assets/{page-seo-form-a2n9u9WD.js → page-seo-form-C_2RUxxC.js} +1 -1
- package/dist/client/assets/page-seo-sheet-fhZUZgqS.js +1 -0
- package/dist/client/assets/{popover-Fbn06PH6.js → popover-DESq8MlY.js} +1 -1
- package/dist/client/assets/{post-editor-PIZGyh-D.js → post-editor-C6yPagcF.js} +1 -1
- package/dist/client/assets/{primitives-BWdCEsVr.js → primitives-BDfut_pc.js} +1 -1
- package/dist/client/assets/{profile-DWgf1Z7F.js → profile-D5pYQlzN.js} +1 -1
- package/dist/client/assets/project-app-view-DngS6f9y.js +1 -0
- package/dist/client/assets/record-editor-BkB44FqU.js +1 -0
- package/dist/client/assets/{registry-layout-BiBXTSzF.js → registry-layout-ewdPobS9.js} +1 -1
- package/dist/client/assets/registry-oa3OK8EB.js +2 -0
- package/dist/client/assets/{require-capability-D9gIE_ZJ.js → require-capability-b5F_i--f.js} +1 -1
- package/dist/client/assets/{required-auth-layout-BhVpIG1h.js → required-auth-layout-FfHfv0VI.js} +1 -1
- package/dist/client/assets/{reset-password-2_KyA_Kq.js → reset-password-_ID0Jmb1.js} +1 -1
- package/dist/client/assets/{roles-CN2J3exe.js → roles-D4aPzPCN.js} +1 -1
- package/dist/client/assets/{scroll-area-B5NHjKLX.js → scroll-area-Dt0A9lzL.js} +1 -1
- package/dist/client/assets/{search-input-DcubuUYj.js → search-input-mkU8caHs.js} +1 -1
- package/dist/client/assets/{secrets-Dd7XuiVm.js → secrets-DZHFxUYN.js} +1 -1
- package/dist/client/assets/{sections-editor-BHAVZ3MF.js → sections-editor-BhbIeS6T.js} +1 -1
- package/dist/client/assets/{select-CJrhnL-C.js → select-CFMmW9o-.js} +1 -1
- package/dist/client/assets/{select-model-eUIW2KGK.js → select-model-oC-ZbdSY.js} +1 -1
- package/dist/client/assets/{seo-editor-QlGbBbQX.js → seo-editor-Cu1RCBm-.js} +1 -1
- package/dist/client/assets/settings-layout-iHEQZNRo.js +1 -0
- package/dist/client/assets/{settings-section-pMV9nure.js → settings-section-CCA_rQPu.js} +1 -1
- package/dist/client/assets/{sheet-Dw9i9F7S.js → sheet-DpVVe07a.js} +1 -1
- package/dist/client/assets/{shell-controls-S0QX5jz6.js → shell-controls-0GymUxsw.js} +1 -1
- package/dist/client/assets/{shell-layout-4psNcld3.js → shell-layout-B6CDg-cg.js} +1 -1
- package/dist/client/assets/{shell-route-loading-CwWGp-mW.js → shell-route-loading-Dfj-cl4w.js} +1 -1
- package/dist/client/assets/{sidebar-CetSdIX7.js → sidebar-DUnL0V4N.js} +1 -1
- package/dist/client/assets/{skeleton-C9x-eD5W.js → skeleton-Biz6Vvdi.js} +1 -1
- package/dist/client/assets/{sortable.esm-PVWJdQMY.js → sortable.esm-4-bXuIBY.js} +1 -1
- package/dist/client/assets/{sso-Dewmma_U.js → sso-C3HkmRoG.js} +1 -1
- package/dist/client/assets/{store-BJYr0tu2.js → store-DY5TOVQx.js} +1 -1
- package/dist/client/assets/store-registry-o7Mh0_Kv.js +2 -0
- package/dist/client/assets/{studio-tools-Csrq0noH.js → studio-tools-BnbQl4Xy.js} +1 -1
- package/dist/client/assets/{switch-CSpDOth3.js → switch-dyBEm-xz.js} +1 -1
- package/dist/client/assets/{table-D7QTL3iL.js → table-DAb40UnL.js} +1 -1
- package/dist/client/assets/{tabs-CUrSGe4N.js → tabs-Y-yEKkZ4.js} +1 -1
- package/dist/client/assets/{task-status-Dzx1hMGJ.js → task-status-CmHRRegX.js} +1 -1
- package/dist/client/assets/{textarea-D9ZTYO9h.js → textarea-CZ6lZT55.js} +1 -1
- package/dist/client/assets/{toggle-group-hEPpfOCP.js → toggle-group-BDe3fVGm.js} +1 -1
- package/dist/client/assets/{toolbar-DAE7D1Z-.js → toolbar-DcLfNsL6.js} +1 -1
- package/dist/client/assets/{toolbar-icon-button-Cabsgb2p.js → toolbar-icon-button-BK4dVDIq.js} +1 -1
- package/dist/client/assets/{tools-list-CyWqwUjs.js → tools-list-5V41Fj5o.js} +1 -1
- package/dist/client/assets/{tooltip-BI4JAesz.js → tooltip-BETVAZty.js} +1 -1
- package/dist/client/assets/{types-B86fAgmL.js → types-CbtfOW36.js} +1 -1
- package/dist/client/assets/{use-ai-providers-CXGsIF5s.js → use-ai-providers-BC-Unv9B.js} +1 -1
- package/dist/client/assets/{use-automations-Byo9LHaD.js → use-automations-DM4xNubt.js} +1 -1
- package/dist/client/assets/{use-capability-Cc1kwETV.js → use-capability-Buq2jVbm.js} +1 -1
- package/dist/client/assets/{use-clock-tick-DX6bwXXg.js → use-clock-tick-CVyOhRb1.js} +1 -1
- package/dist/client/assets/{use-collections-BY0VCTKx.js → use-collections-DJbkAyuY.js} +1 -1
- package/dist/client/assets/{use-connection-DMkBQMW3.js → use-connection-C7H28tUm.js} +1 -1
- package/dist/client/assets/{use-copy-CwiwooYq.js → use-copy-DwhmZgzz.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-DV3G_x5h.js → use-create-virtual-mcp-DIJXVLDA.js} +1 -1
- package/dist/client/assets/{use-debounced-autosave-B0Eaei6z.js → use-debounced-autosave-xRcrGDGN.js} +1 -1
- package/dist/client/assets/{use-debounced-value-AYp4scFQ.js → use-debounced-value-dGP0T3Z6.js} +1 -1
- package/dist/client/assets/{use-decopilot-events-BnAzjCBz.js → use-decopilot-events-ZViPJ0gD.js} +1 -1
- package/dist/client/assets/{use-delete-connection-vR8DgKsc.js → use-delete-connection-B1HsoB0C.js} +1 -1
- package/dist/client/assets/{use-file-configs-CG51ehnE.js → use-file-configs-BqeK5-ZL.js} +1 -1
- package/dist/client/assets/{use-infinite-scroll-Bc3GiiLN.js → use-infinite-scroll-DKD-IrVC.js} +1 -1
- package/dist/client/assets/{use-join-requests-Amr2JFrV.js → use-join-requests-D02lKKeN.js} +1 -1
- package/dist/client/assets/{use-mcp-client-DRxe70DE.js → use-mcp-client-A_C0OXe_.js} +1 -1
- package/dist/client/assets/{use-mcp-prompts-BcNdCz5u.js → use-mcp-prompts-BdtnL2tp.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-DM4p0S4B.js → use-mcp-tools-D5KEYf26.js} +1 -1
- package/dist/client/assets/{use-members-Bl7Xx5D5.js → use-members-S8u6cgH3.js} +1 -1
- package/dist/client/assets/{use-mobile-Bkr-XUk_.js → use-mobile-DB_HbZdV.js} +1 -1
- package/dist/client/assets/{use-navigate-to-agent-CNTO5dJ5.js → use-navigate-to-agent-Cpj0q3sa.js} +1 -1
- package/dist/client/assets/{use-org-auth-client-BuAxqUju.js → use-org-auth-client-1ug5pqiq.js} +1 -1
- package/dist/client/assets/{use-org-fs-Bjm_nCQR.js → use-org-fs-B8S0kCYo.js} +1 -1
- package/dist/client/assets/{use-org-sso-bvR5bpNX.js → use-org-sso-CTXVLokg.js} +1 -1
- package/dist/client/assets/{use-organization-roles-BLOHOn8M.js → use-organization-roles-BG3L6PMl.js} +1 -1
- package/dist/client/assets/{use-organization-settings-DgP8V2A9.js → use-organization-settings-D13sMxOQ.js} +1 -1
- package/dist/client/assets/{use-registry-connections-Cb0z-xBU.js → use-registry-connections-PtpSZeVH.js} +1 -1
- package/dist/client/assets/{use-secrets-CDhjRrZi.js → use-secrets-5DqxCpWf.js} +1 -1
- package/dist/client/assets/{use-status-sounds-CykfwUMF.js → use-status-sounds-C-U8Pnl-.js} +1 -1
- package/dist/client/assets/{use-view-mode-BtxJUuVE.js → use-view-mode-B1BnO7yA.js} +1 -1
- package/dist/client/assets/{use-virtual-mcp-CKgo4VLO.js → use-virtual-mcp-De67qc1-.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-WHDQHpmx.js +1 -0
- package/dist/client/assets/useSuspenseInfiniteQuery-CFE7ta84.js +1 -0
- package/dist/client/assets/{useSuspenseQueries-DHag6W5K.js → useSuspenseQueries-BrkAIOFb.js} +1 -1
- package/dist/client/assets/{variant-calendar-BGmazWqY.js → variant-calendar-CGx_HG0U.js} +1 -1
- package/dist/client/assets/{view-mode-toggle-BBm3czYp.js → view-mode-toggle-az73HV8a.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/server/cli.js +375 -375
- package/dist/server/server.js +1 -1
- package/package.json +1 -1
- package/dist/client/assets/commerce-onboarding-CeZCD-Yf.js +0 -1
- package/dist/client/assets/index-BxnP05yO.css +0 -1
- package/dist/client/assets/index-DV75GtWn.js +0 -513
- package/dist/client/assets/index-DXrMr0Lv.js +0 -1
- package/dist/client/assets/page-seo-sheet--MdUX-61.js +0 -1
- package/dist/client/assets/project-app-view-CF9uQXSH.js +0 -1
- package/dist/client/assets/record-editor-CKpLUFyW.js +0 -1
- package/dist/client/assets/registry-o1K6JD7D.js +0 -2
- package/dist/client/assets/settings-layout-Bv7O84XZ.js +0 -1
- package/dist/client/assets/store-registry-DQP6YVZo.js +0 -2
- package/dist/client/assets/useInfiniteQuery-BTeqoEKr.js +0 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-BFWffvcs.js +0 -1
|
@@ -1,513 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sections-editor-BHAVZ3MF.js","assets/index-DqSOj5mm.js","assets/index-BxnP05yO.css","assets/ChevronDown-D5ZAHq8C.js","assets/agent-icon-D9w3KE0I.js","assets/AlertCircle-CqwVKs4c.js","assets/Tool01-Dqm9uO5c.js","assets/SwitchHorizontal01-CVIT3pvO.js","assets/Settings02-CzYVBYwk.js","assets/XCircle-DdtQjEIT.js","assets/ArrowUpRight-CED6ndCh.js","assets/ZapSquare-D_EJc_wK.js","assets/Users03-BzdZqGuX.js","assets/CheckCircle-BeClS62J.js","assets/ChevronUp-qi2zlJbj.js","assets/ChevronRight-p1IOWwCq.js","assets/DotsVertical-CPX0ApPY.js","assets/Stars02-DZEKLUYU.js","assets/Eye-ChyuimlO.js","assets/ZoomOut-Bk81Ty3E.js","assets/Globe01-CSbQaAOU.js","assets/FilterLines-B7RIEUU-.js","assets/Star01-B7zb2THr.js","assets/Globe04-CKX2tmjZ.js","assets/HardDrive-BTgncQXB.js","assets/Key01-BW4SKvZI.js","assets/LayoutLeft-BdaRkmaX.js","assets/LinkExternal01-Cy4W-B6b.js","assets/Monitor01-DSc7ZJBq.js","assets/Sun-CF88ih-f.js","assets/Palette-Brgn8aWM.js","assets/Play-DaV1T59S.js","assets/Plus-BvTTNpUi.js","assets/SearchLg-BV0AuFFU.js","assets/SearchMd-c8C4u1L7.js","assets/Shield01-Cycg2C0o.js","assets/Stars01-3V3ei1I8.js","assets/Trash01-Pm6WJfx3.js","assets/Upload01-_1bkJo-2.js","assets/User01-KxyCL87Z.js","assets/Users01-CgqlpnWe.js","assets/XClose-CXvUnVsl.js","assets/X-QnL1_jwj.js","assets/Zap-Bp3kazzB.js","assets/scroll-area-B5NHjKLX.js","assets/use-clock-tick-DX6bwXXg.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/use-copy-CwiwooYq.js","assets/tooltip-BI4JAesz.js","assets/file-type-icon-B8mbw-yE.js","assets/dialog-blJw2JGa.js","assets/use-mobile-Bkr-XUk_.js","assets/tab-id-AX1D_RMI.js","assets/content-blocks-o63cs2vh.js","assets/types-B86fAgmL.js","assets/use-mcp-client-DRxe70DE.js","assets/auth-BS0r-1X4.js","assets/chat-context-BQLW9kkK.js","assets/hooks-b-ZTOz-h.js","assets/decopilot-sse-pool-DWRDxmrh.js","assets/backoff-CrEUbyZT.js","assets/delay-CnY5UFtP.js","assets/use-virtual-mcp-CKgo4VLO.js","assets/use-collections-BY0VCTKx.js","assets/use-ai-providers-CXGsIF5s.js","assets/studio-tools-Csrq0noH.js","assets/use-decopilot-events-BnAzjCBz.js","assets/use-organization-settings-DgP8V2A9.js","assets/shell-layout-4psNcld3.js","assets/avatar-D86BabR9.js","assets/alert-dialog-D3kFS9Xx.js","assets/required-auth-layout-BhVpIG1h.js","assets/use-org-sso-bvR5bpNX.js","assets/sheet-Dw9i9F7S.js","assets/integration-icon-CD6ASMsi.js","assets/use-navigate-to-agent-CNTO5dJ5.js","assets/use-connection-DMkBQMW3.js","assets/use-mcp-prompts-BcNdCz5u.js","assets/form-BXg3zbwg.js","assets/label-CHE1Rjd0.js","assets/input-H9MW7QWS.js","assets/select-CJrhnL-C.js","assets/dropdown-menu-W43dsA5C.js","assets/sortable.esm-PVWJdQMY.js","assets/connection-slug-eyAPH6o3.js","assets/connection-card-DQxW9rgJ.js","assets/use-registry-connections-Cb0z-xBU.js","assets/useInfiniteQuery-BTeqoEKr.js","assets/use-infinite-scroll-Bc3GiiLN.js","assets/extract-connection-data-xmb7h_DD.js","assets/card-JmDifMtn.js","assets/collection-search-C_1AD6YQ.js","assets/collection-tabs-7Ft93VyB.js","assets/badge-Cq5_vU6x.js","assets/drawer-VlXqa2RL.js","assets/textarea-D9ZTYO9h.js","assets/connection-form-helpers-e83YdLh2.js","assets/authenticate-and-persist-oauth-CsZcEHyY.js","assets/mcp-oauth-BsNEq7j-.js","assets/useSuspenseInfiniteQuery-BFWffvcs.js","assets/page-seo-form-a2n9u9WD.js","assets/switch-CSpDOth3.js","assets/add-section-modal-BYBx1539.js","assets/index-D4dzqiiy.js","assets/tabs-CUrSGe4N.js","assets/toggle-group-hEPpfOCP.js","assets/connect-desktop-dialog-DX-5ff0q.js","assets/decopilot-DpuV-Swz.js","assets/checkbox-ClHoRUlZ.js","assets/skeleton-C9x-eD5W.js","assets/ai-providers-logos-DD3qZ33J.js","assets/settings-section-pMV9nure.js","assets/popover-Fbn06PH6.js","assets/command-BH_mb2ud.js","assets/index-C2OyMQ9A.js","assets/use-org-fs-Bjm_nCQR.js","assets/question-004-sINsf4GQ.js","assets/shell-route-loading-CwWGp-mW.js","assets/task-status-Dzx1hMGJ.js","assets/use-status-sounds-CykfwUMF.js","assets/empty-state-sTDUBWfL.js","assets/toolbar-DAE7D1Z-.js","assets/index-Zxf1K2Y0.js","assets/use-debounced-value-AYp4scFQ.js","assets/index-CFtT-a2U.js","assets/toolbar-icon-button-Cabsgb2p.js","assets/use-mcp-tools-DM4p0S4B.js","assets/use-capability-Cc1kwETV.js","assets/tools-list-CyWqwUjs.js","assets/use-debounced-autosave-B0Eaei6z.js","assets/index-Cn7rcOpx.js","assets/sidebar-CetSdIX7.js","assets/search-input-DcubuUYj.js","assets/github-repo-picker-BGtEhImx.js","assets/github-installations-DzN1UQ4x.js","assets/use-secrets-CDhjRrZi.js","assets/formatDistanceToNow-Cb2QZZJn.js","assets/automation-runs-BGVlA6Ga.js","assets/table-D7QTL3iL.js","assets/use-members-Bl7Xx5D5.js","assets/use-org-auth-client-BuAxqUju.js","assets/use-automations-Byo9LHaD.js","assets/use-file-configs-CG51ehnE.js","assets/monaco-editor-i-UEBrYO.js","assets/select-model-eUIW2KGK.js","assets/automation-list-row-Cu7XHsno.js","assets/page-seo-sheet--MdUX-61.js","assets/file-explorer-DkK3gDL2.js","assets/context-menu-CYyv2p0M.js","assets/app-editor-Cqa11QpG.js","assets/post-editor-PIZGyh-D.js","assets/block-document-CFJQWoq6.js","assets/primitives-BWdCEsVr.js","assets/record-editor-CKpLUFyW.js","assets/category-editor-CjO8y5jo.js","assets/bulk-category-panel-Cyw3TrSE.js","assets/index-DT3yu7Zl.js","assets/seo-editor-QlGbBbQX.js","assets/variant-calendar-BGmazWqY.js","assets/view-mode-toggle-BBm3czYp.js","assets/project-app-view-CF9uQXSH.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{c as U,r as R,l as ce,j as n,i as Ue,D as Ge,a as an,E as es,b as Vt,u as Co,e as Sd,C as Uf,L as Kf,k as si,K as Et,m as Ni,a4 as jo,a5 as Wf,q as Vf,t as me,B as re,a6 as Ml,a7 as Gf,a8 as qf,v as Ze,a9 as wd,aa as Yf,ab as ko,ac as Xi,ad as Ut,ae as Jf,p as Cd,n as Xf,G as jd,af as Kt,U as kd,ag as Zf,X as Qf,a2 as Nd,Z as e2,ah as t2,V as s2,ai as i2,d as ii,o as zr,aj as En,s as hs,ak as as,al as n2,F as r2}from"./index-DqSOj5mm.js";import{C as lt,a as o2,w as a2,u as Bl,s as Ma,T as l2,b as c2,g as d2,c as h2}from"./index-D4dzqiiy.js";import{u as Ti,a as $s,b as $l,c as u2,S as zl,t as f2,d as m2,e as p2}from"./chat-context-BQLW9kkK.js";import{i as Ei}from"./AlertCircle-CqwVKs4c.js";import{i as Td}from"./CheckCircle-BeClS62J.js";import{n as o9,g as No,f as Ed,h as Ad,j as g2,p as To,k as Ai,l as Fl,m as Pd,o as Ba,q as sa,r as a9,A as l9,u as _2,v as L2,w as v2,x as x2,y as y2,z as Hl,B as Rd,C as b2,D as S2,E as w2,F as ln,G as C2,H as j2,I as k2,J as Vi,K as Jr,L as nr,M as c9,N as N2,O as T2,P as E2,Q as A2,R as P2,S as R2,T as D2,U as I2,V as O2,W as M2,X as Dd,Y as Zi,Z as d9,_ as Id,$ as B2,a0 as Xr,a1 as $2,a2 as z2,a3 as Od,t as F2,a4 as H2,a5 as U2,a6 as K2,a7 as W2,a8 as V2,a9 as G2,aa as q2,ab as Y2,ac as Md,ad as J2}from"./agent-icon-D9w3KE0I.js";import{a as X2,b as Z2,i as Q2}from"./XCircle-DdtQjEIT.js";import{s as ti}from"./XClose-CXvUnVsl.js";import{a as Ts,u as Ul,b as Bd,c as em}from"./use-virtual-mcp-CKgo4VLO.js";import{c as tm,u as sm,a as $d,O as im,t as $a,S as ni,T as nm,b as zd,R as rm,C as om,G as am,d as lm,i as cm,E as dm,g as hm,s as um,e as fm,f as mm,h as pm}from"./scroll-area-B5NHjKLX.js";import{I as Es}from"./integration-icon-CD6ASMsi.js";import{b as gm,u as Fd,a as Hd}from"./hooks-b-ZTOz-h.js";import{b as Eo,r as _m,i as Lm}from"./shell-layout-4psNcld3.js";import{T as vm,S as xm}from"./shell-route-loading-CwWGp-mW.js";import{a as Ud,u as Dt,S as Kl,b as ym,c as bm,i as Sm,d as Kd}from"./use-mcp-client-DRxe70DE.js";import{a as wm}from"./Users03-BzdZqGuX.js";import{t as ls}from"./ChevronDown-D5ZAHq8C.js";import{u as Cm,h as jm,f as Ao,i as Wd,j as vi,g as km,A as Nm,a as Vd,b as Zr,K as Gd,P as qd,D as Yd,c as Jd,S as Xd,v as Zd,k as Qd,l as za,d as eh,C as th,s as sh,r as Tm,m as Em,n as Am}from"./sortable.esm-PVWJdQMY.js";import{u as ih}from"./use-ai-providers-CXGsIF5s.js";import{u as Pm}from"./connect-desktop-dialog-DX-5ff0q.js";import{u as Wl}from"./use-mobile-Bkr-XUk_.js";import{u as Rm}from"./use-status-sounds-CykfwUMF.js";import{E as Qr}from"./empty-state-sTDUBWfL.js";import{r as Fa,a as Dm,p as nh,f as h9,b as rh,c as oh,d as ah,e as Im,F as Om,g as Mm,i as Bm,h as $m,j as lh,k as ch}from"./tab-id-AX1D_RMI.js";import{T as Ui}from"./toolbar-DAE7D1Z-.js";import{g as zm,d as dh,a as u9,b as Fm,F as Hm,c as Um,f as Km,e as Wm,H as Vm,L as Gm,h as qm,S as Ym,B as Jm,R as Xm,i as Zm,j as hh,T as Vl,k as Qm,l as e3}from"./index-Zxf1K2Y0.js";import{a as Ee,b as Ae,T as Pe,c as uh}from"./tooltip-BI4JAesz.js";import{T as An}from"./toolbar-icon-button-Cabsgb2p.js";import{i as Pi,n as t3}from"./Globe01-CSbQaAOU.js";import{i as fh}from"./Monitor01-DSc7ZJBq.js";import{u as rr,a as Gl,b as mh}from"./use-connection-DMkBQMW3.js";import{u as Po,a as ph,b as gh}from"./use-mcp-tools-DM4p0S4B.js";import{g as _h}from"./types-B86fAgmL.js";import{u as Ri}from"./studio-tools-Csrq0noH.js";import{e as Lh}from"./backoff-CrEUbyZT.js";import{u as s3}from"./use-capability-Cc1kwETV.js";import{F as Qi,M as ql,O as i3}from"./file-type-icon-B8mbw-yE.js";import{a as en,i as vh,b as Yl,c as n3,d as r3}from"./ZoomOut-Bk81Ty3E.js";import{P as ms,a as ps,b as gs}from"./popover-Fbn06PH6.js";import{a as kt,b as Rt,c as Nt,d as ot,S as Tt}from"./select-CJrhnL-C.js";import{D as is,a as ns,b as rs,c as We,d as Ha,e as Ua,f as Ka,g as zn,h as vr,i as Ro,j as f9}from"./dropdown-menu-W43dsA5C.js";import{e as Gt,d as qt,c as _s,a as Ls,D as Di,b as or}from"./dialog-blJw2JGa.js";import{I as Ke}from"./input-H9MW7QWS.js";import{b as Js,a as Do,c as Gi,T as Io}from"./tabs-CUrSGe4N.js";import{T as Yn}from"./textarea-D9ZTYO9h.js";import{a as ts,s as xh}from"./Eye-ChyuimlO.js";import{t as gi}from"./Stars01-3V3ei1I8.js";import{l as o3,w as a3}from"./index-CFtT-a2U.js";import{i as Ms}from"./ChevronRight-p1IOWwCq.js";import{a as l3}from"./extract-connection-data-xmb7h_DD.js";import{A as ia}from"./avatar-D86BabR9.js";import{T as yh,u as bh}from"./tools-list-CyWqwUjs.js";import{a as c3,i as m9}from"./mcp-oauth-BsNEq7j-.js";import{s as Sh,g as d3}from"./connection-slug-eyAPH6o3.js";import{f as eo,a as to,b as so,c as io,d as no,e as ro,A as oo,g as ao}from"./alert-dialog-D3kFS9Xx.js";import{C as Jl,a as lo}from"./card-JmDifMtn.js";import{L as Ve}from"./label-CHE1Rjd0.js";import{S as Jn}from"./switch-CSpDOth3.js";import{i as xi}from"./Play-DaV1T59S.js";import{s as It}from"./Plus-BvTTNpUi.js";import{a as h3,i as u3,b as Xl}from"./Settings02-CzYVBYwk.js";import{s as os}from"./Trash01-Pm6WJfx3.js";import{u as co}from"./use-debounced-autosave-B0Eaei6z.js";import{i as Xn}from"./SearchMd-c8C4u1L7.js";import{i as ar}from"./Upload01-_1bkJo-2.js";import{i as f3}from"./LayoutLeft-BdaRkmaX.js";import{P as fs}from"./index-Cn7rcOpx.js";import{u as m3,a as p3,b as g3,c as _3,d as L3,e as v3,f as x3}from"./use-org-fs-Bjm_nCQR.js";import{C as cn}from"./checkbox-ClHoRUlZ.js";import{S as Zl}from"./search-input-DcubuUYj.js";import{C as wh}from"./collection-tabs-7Ft93VyB.js";import{u as y3}from"./use-mcp-prompts-BcNdCz5u.js";import{b as b3,a as S3,D as w3}from"./drawer-VlXqa2RL.js";import{i as Wt}from"./ChevronUp-qi2zlJbj.js";import{i as Ql}from"./Key01-BW4SKvZI.js";import{a as Ch,G as C3}from"./github-repo-picker-BGtEhImx.js";import{S as ec}from"./skeleton-C9x-eD5W.js";import{s as j3}from"./User01-KxyCL87Z.js";import{t as tc}from"./Users01-CgqlpnWe.js";import{u as k3,a as N3}from"./use-secrets-CDhjRrZi.js";import{f as T3}from"./formatDistanceToNow-Cb2QZZJn.js";import{n as ri}from"./LinkExternal01-Cy4W-B6b.js";import{s as yi}from"./Star01-B7zb2THr.js";import{i as sc}from"./SearchLg-BV0AuFFU.js";import{i as ic,a as bi,b as nc,c as rc}from"./Tool01-Dqm9uO5c.js";import{b as lr,C as cr,a as Xs,d as Oo,c as dr,e as Si,f as E3}from"./command-BH_mb2ud.js";import{n as ho}from"./ZapSquare-D_EJc_wK.js";import{i as A3,c as jh,a as P3}from"./SwitchHorizontal01-CVIT3pvO.js";import{i as dn}from"./X-QnL1_jwj.js";import{i as wi}from"./Zap-Bp3kazzB.js";import{C as R3,A as D3}from"./automation-runs-BGVlA6Ga.js";import{i as I3}from"./DotsVertical-CPX0ApPY.js";import{u as O3}from"./use-debounced-value-AYp4scFQ.js";import{u as M3,a as kh}from"./use-file-configs-CG51ehnE.js";import{u as B3}from"./useInfiniteQuery-BTeqoEKr.js";import{i as $3}from"./FilterLines-B7RIEUU-.js";import{M as Mo}from"./monaco-editor-i-UEBrYO.js";import{B as z3}from"./badge-Cq5_vU6x.js";import{M as F3}from"./select-model-eUIW2KGK.js";import{u as hr,a as H3,b as U3,c as K3,d as W3}from"./use-automations-Byo9LHaD.js";import{s as Fn}from"./Stars02-DZEKLUYU.js";import{A as V3}from"./automation-list-row-Cu7XHsno.js";function vn(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function p9(t){if(!t)return"—";const e=typeof t=="string"?new Date(t):t;return isNaN(e.getTime())?"—":e.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function G3(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function q3(t){const e=U.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Y3),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=n.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:i}),e[2]=i,e[3]=r):r=e[3],r}function Y3(t){return n.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[n.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),n.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function J3(t){const e=U.c(30),{userTokens:s,assistantTokens:i,otherTokens:r}=t,o=s+i+r,a=o>0?s/o*100:0,l=o>0?i/o*100:0,c=o>0?r/o*100:0;let d;e[0]!==a?(d=a>0&&n.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=d):d=e[1];let h;e[2]!==l?(h=l>0&&n.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=h):h=e[3];let u;e[4]!==c?(u=c>0&&n.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${c}%`}}),e[4]=c,e[5]=u):u=e[5];let f;e[6]!==d||e[7]!==h||e[8]!==u?(f=n.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[d,h,u]}),e[6]=d,e[7]=h,e[8]=u,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=m):m=e[10];let p;e[11]!==a?(p=a.toFixed(1),e[11]=a,e[12]=p):p=e[12];let g;e[13]!==p?(g=n.jsxs("div",{className:"flex items-center gap-1.5",children:[m,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",p,"%"]})]}),e[13]=p,e[14]=g):g=e[14];let L;e[15]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=L):L=e[15];let v;e[16]!==l?(v=l.toFixed(1),e[16]=l,e[17]=v):v=e[17];let y;e[18]!==v?(y=n.jsxs("div",{className:"flex items-center gap-1.5",children:[L,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",v,"%"]})]}),e[18]=v,e[19]=y):y=e[19];let _;e[20]!==c||e[21]!==r?(_=r>0&&n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",c.toFixed(1),"%"]})]}),e[20]=c,e[21]=r,e[22]=_):_=e[22];let x;e[23]!==y||e[24]!==_||e[25]!==g?(x=n.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[g,y,_]}),e[23]=y,e[24]=_,e[25]=g,e[26]=x):x=e[26];let b;return e[27]!==x||e[28]!==f?(b=n.jsxs("div",{className:"flex flex-col gap-2",children:[f,x]}),e[27]=x,e[28]=f,e[29]=b):b=e[29],b}function X3(t){const e=U.c(11),{agentId:s,isError:i}=t,r=Ts(s),o=r?.title??"Subtask",a=r?.icon??null;let l;e[0]!==a||e[1]!==o?(l=n.jsx(Es,{icon:a,name:o,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=o,e[2]=l):l=e[2];const c=i?"text-destructive":"text-foreground";let d;e[3]!==c?(d=ce("shrink-0 font-medium",c),e[3]=c,e[4]=d):d=e[4];let h;e[5]!==o||e[6]!==d?(h=n.jsx("span",{className:d,children:o}),e[5]=o,e[6]=d,e[7]=h):h=e[7];let u;return e[8]!==l||e[9]!==h?(u=n.jsxs(n.Fragment,{children:[l,h]}),e[8]=l,e[9]=h,e[10]=u):u=e[10],u}function Z3(t){const e=U.c(5),{isError:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Es,{icon:null,name:"Subtask",size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=i):i=e[0];const r=s?"text-destructive":"text-foreground";let o;e[1]!==r?(o=ce("shrink-0 font-medium",r),e[1]=r,e[2]=o):o=e[2];let a;return e[3]!==o?(a=n.jsxs(n.Fragment,{children:[i,n.jsx("span",{className:o,children:"Subtask"})]}),e[3]=o,e[4]=a):a=e[4],a}function Q3(t){const e=U.c(18),{part:s}=t,i=s.input?.agent_id,r=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,o=s.state==="output-error",a=s.state==="approval-requested";let l;e[0]!==o?(l=n.jsx(Z3,{isError:o}),e[0]=o,e[1]=l):l=e[1];let c;e[2]!==i||e[3]!==o?(c=n.jsx(X3,{agentId:i,isError:o}),e[2]=i,e[3]=o,e[4]=c):c=e[4];let d;e[5]!==l||e[6]!==c?(d=n.jsx(R.Suspense,{fallback:l,children:c}),e[5]=l,e[6]=c,e[7]=d):d=e[7];let h;e[8]!==s.input?(h=s.input?.prompt&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-muted-foreground/50",children:"·"}),n.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=h):h=e[9];let u;e[10]!==a||e[11]!==o||e[12]!==r?(u=n.jsx("span",{className:"ml-auto shrink-0",children:r?n.jsx(Ue,{size:12,className:"animate-spin text-muted-foreground"}):o?n.jsx(X2,{size:12,className:"text-destructive"}):a?n.jsx(Ei,{size:12,className:"text-warning"}):n.jsx(Td,{size:12,className:"text-emerald-500"})}),e[10]=a,e[11]=o,e[12]=r,e[13]=u):u=e[13];let f;return e[14]!==d||e[15]!==h||e[16]!==u?(f=n.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[d,h,u]}),e[14]=d,e[15]=h,e[16]=u,e[17]=f):f=e[17],f}function ep(t){const e=U.c(55),{onClose:s,back:i,className:r}=t,[o,a]=R.useState(null),{messages:l}=Ti(),{activeTask:c}=$s(),{selectedModel:d,selectedVirtualMcp:h}=$l();let u,f,m,p,g,L,v,y;if(e[0]!==c||e[1]!==i||e[2]!==r||e[3]!==l||e[4]!==s||e[5]!==o?.id||e[6]!==d||e[7]!==h?.title){y=Symbol.for("react.early_return_sentinel");e:{const b=tm(l),S=[...l].reverse().find(hp),w=S?.metadata?.usage,j=S?.metadata?.modelLimits?.contextWindow??d?.limits?.contextWindow??null,N=w?.contextTokens??0,T=j&&j>0?(N/j*100).toFixed(1):null,A=l;let k;e[16]!==A?(k=A.filter(dp).reduce(cp,0),e[16]=A,e[17]=k):k=e[17];const C=k,I=l;let E;e[18]!==I?(E=I.filter(lp).reduce(ap,0),e[18]=I,e[19]=E):E=e[19];const O=E,P=Math.max(0,b.totalTokens-C-O),D=l[0],M=l.at(-1),z=D?.metadata?.created_at??c?.created_at,F=M?.metadata?.created_at??c?.updated_at,$=l.filter(op),V=l.flatMap(np),J=d?.modelId?G3(d.modelId):"—",Z=h?.title??"Decopilot",G=[{label:"Session",value:c?.title??"New chat"},{label:"Messages",value:$.length},{label:"Agent",value:Z},{label:"Model",value:J},{label:"Context Limit",value:j?vn(j):"—"},{label:"Session Tokens (billed)",value:b.totalTokens>0?vn(b.totalTokens):"0"},{label:"Usage",value:T!==null?`${T}%`:"—"},{label:"Input Tokens",value:b.inputTokens>0?vn(b.inputTokens):"0"},{label:"Output Tokens",value:b.outputTokens>0?vn(b.outputTokens):"0"},{label:"Reasoning Tokens",value:b.reasoningTokens>0?vn(b.reasoningTokens):"0"},{label:"Cost",value:b.cost>0?`$${b.cost<.001?b.cost.toFixed(6):b.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:p9(z)},{label:"Last Activity",value:p9(F)}];if(!c&&$.length===0){let B;e[20]!==r?(B=ce("flex flex-col h-full w-full border-l border-border bg-background",r),e[20]=r,e[21]=B):B=e[21];let X;e[22]===Symbol.for("react.memo_cache_sentinel")?(X=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[22]=X):X=e[22];let W;e[23]!==i?(W=i?n.jsx(o9,{size:14,className:"text-muted-foreground"}):n.jsx(ti,{size:14,className:"text-muted-foreground"}),e[23]=i,e[24]=W):W=e[24];let Y;e[25]!==s||e[26]!==W?(Y=n.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[X,n.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:W})]}),e[25]=s,e[26]=W,e[27]=Y):Y=e[27];let Q;e[28]===Symbol.for("react.memo_cache_sentinel")?(Q=n.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:n.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[28]=Q):Q=e[28];let ie;e[29]!==B||e[30]!==Y?(ie=n.jsxs("div",{className:B,children:[Y,Q]}),e[29]=B,e[30]=Y,e[31]=ie):ie=e[31],y=ie;break e}e[32]!==r?(L=ce("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",r),e[32]=r,e[33]=L):L=e[33];let q;e[34]===Symbol.for("react.memo_cache_sentinel")?(q=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[34]=q):q=e[34];let H;e[35]!==i?(H=i?n.jsx(o9,{size:14}):n.jsx(ti,{size:14}),e[35]=i,e[36]=H):H=e[36],e[37]!==s||e[38]!==H?(v=n.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[q,n.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:H})]}),e[37]=s,e[38]=H,e[39]=v):v=e[39],u="flex flex-col gap-8 p-6",f=V.length>0&&n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),n.jsx("div",{className:"flex flex-col gap-1",children:V.map(ip)})]}),m=n.jsx(q3,{items:G});let K;e[40]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[40]=K):K=e[40],e[41]!==O||e[42]!==P||e[43]!==C?(p=n.jsxs("div",{className:"flex flex-col gap-3",children:[K,n.jsx(J3,{userTokens:C,assistantTokens:O,otherTokens:P})]}),e[41]=O,e[42]=P,e[43]=C,e[44]=p):p=e[44],g=$.length>0&&n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),n.jsx("div",{className:"flex flex-col gap-1",children:$.map(B=>{const X=B.metadata?.created_at,W=o?.id===B.id;return n.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[n.jsxs("button",{type:"button",onClick:()=>a(W?null:B),className:"flex items-center justify-between gap-2 px-3 py-2 text-xs hover:bg-accent/50 w-full text-left cursor-pointer",children:[n.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[n.jsx("span",{className:ce("shrink-0 font-medium",B.role==="user"?"text-chart-1":"text-chart-2"),children:B.role}),n.jsx("span",{className:"text-muted-foreground",children:"•"}),n.jsx("span",{className:"truncate text-muted-foreground font-mono",children:B.id})]}),X&&n.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(X).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),W&&n.jsxs(n.Fragment,{children:[B.role==="assistant"&&(()=>{const Y=B.metadata?._request;if(!Y)return null;const Q=Y.systemSections??[],ie=Math.max(1,...Q.map(sp)),oe=Q.reduce(tp,0);return n.jsxs("div",{className:"border-t border-border/50 px-3 py-2.5 text-xs space-y-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"font-medium text-foreground",children:"Request"}),n.jsxs("span",{className:"text-muted-foreground tabular-nums",children:[Y.activeTools??0," / ",Y.tools??0," ","tools active"]})]}),Q.length>0&&n.jsxs("div",{className:"space-y-1.5",children:[n.jsxs("div",{className:"text-muted-foreground",children:["System prompt"," ",n.jsxs("span",{className:"tabular-nums",children:["~",Math.round(oe/4).toLocaleString()," ","tok"]})]}),Q.map((ue,ee)=>{const te=ue.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${ee}`,fe=ue.chars/ie*100,he=Math.round(ue.chars/4);return n.jsxs("div",{className:"space-y-0.5",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("span",{className:"font-mono text-foreground truncate",children:te}),n.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",he.toLocaleString()," tok"]})]}),n.jsx("div",{className:"h-1 w-full rounded-full bg-muted overflow-hidden",children:n.jsx("div",{className:"h-full rounded-full bg-chart-3",style:{width:`${fe}%`}})})]},ee)})]})]})})(),n.jsx("pre",{className:"text-xs font-mono bg-muted px-3 py-2 overflow-auto whitespace-pre-wrap break-all border-t border-border/50 max-h-64",children:JSON.stringify(B,null,2)})]})]},B.id)})})]})}e[0]=c,e[1]=i,e[2]=r,e[3]=l,e[4]=s,e[5]=o?.id,e[6]=d,e[7]=h?.title,e[8]=u,e[9]=f,e[10]=m,e[11]=p,e[12]=g,e[13]=L,e[14]=v,e[15]=y}else u=e[8],f=e[9],m=e[10],p=e[11],g=e[12],L=e[13],v=e[14],y=e[15];if(y!==Symbol.for("react.early_return_sentinel"))return y;let _;e[45]!==u||e[46]!==f||e[47]!==m||e[48]!==p||e[49]!==g?(_=n.jsxs("div",{className:u,children:[f,m,p,g]}),e[45]=u,e[46]=f,e[47]=m,e[48]=p,e[49]=g,e[50]=_):_=e[50];let x;return e[51]!==L||e[52]!==v||e[53]!==_?(x=n.jsxs("div",{className:L,children:[v,_]}),e[51]=L,e[52]=v,e[53]=_,e[54]=x):x=e[54],x}function tp(t,e){return t+e.chars}function sp(t){return t.chars}function ip(t,e){return n.jsx(Q3,{part:t},e)}function np(t){return(t.parts??[]).filter(rp)}function rp(t){return t.type==="tool-subtask"}function op(t){return t.role!=="system"}function ap(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function lp(t){return t.role==="assistant"}function cp(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function dp(t){return t.role==="user"}function hp(t){return t.role==="assistant"&&t.metadata?.usage}function up(t){const e=U.c(46),{onOpenContextPanel:s}=t,{org:i}=Ge(),{selectedVirtualMcp:r}=$l();let o;e[0]!==i.id?(o=Ud(i.id),e[0]=i.id,e[1]=o):o=e[1];const l=r??o,c=Ts(l.id),{threads:d}=gm(),{data:h}=an.useSession(),u=h?.user?.id,{setTaskId:f}=Eo();let m,p,g,L,v;if(e[2]!==l.icon||e[3]!==l.id||e[4]!==l.title||e[5]!==d||e[6]!==u||e[7]!==f){let N;e[13]!==l.id||e[14]!==u?(N=E=>!E.hidden&&E.virtual_mcp_id===l.id&&E.created_by===u,e[13]=l.id,e[14]=u,e[15]=N):N=e[15];const T=d.filter(N).sort(fp);let A;e[16]===Symbol.for("react.memo_cache_sentinel")?(A=n.jsx(wm,{size:16}),e[16]=A):A=e[16];let k;e[17]!==l.icon||e[18]!==l.title?(k=n.jsx(Es,{icon:l.icon,name:l.title,size:"sm",fallbackIcon:A,className:"size-8 min-w-8 rounded-lg shrink-0"}),e[17]=l.icon,e[18]=l.title,e[19]=k):k=e[19];let C;e[20]!==l.title?(C=n.jsx("span",{className:"font-medium text-base text-foreground truncate",children:l.title}),e[20]=l.title,e[21]=C):C=e[21],e[22]!==k||e[23]!==C?(v=n.jsx("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:n.jsxs("div",{className:"w-full max-w-2xl mx-auto px-4 pt-8 pb-4 flex items-center gap-3",children:[k,C]})}),e[22]=k,e[23]=C,e[24]=v):v=e[24],m=lt.Footer,L="flex-1 min-h-0 overflow-y-auto flex flex-col",p="mt-auto w-full max-w-2xl mx-auto px-2 pb-2 flex flex-col gap-0.5";let I;e[25]!==f?(I=E=>n.jsx(vm,{task:E,isActive:!1,onClick:()=>f(E.id,E.virtual_mcp_id),showAutomationBadge:!!E.trigger_id},E.id),e[25]=f,e[26]=I):I=e[26],g=T.map(I),e[2]=l.icon,e[3]=l.id,e[4]=l.title,e[5]=d,e[6]=u,e[7]=f,e[8]=m,e[9]=p,e[10]=g,e[11]=L,e[12]=v}else m=e[8],p=e[9],g=e[10],L=e[11],v=e[12];let y;e[27]!==p||e[28]!==g?(y=n.jsx("div",{className:p,children:g}),e[27]=p,e[28]=g,e[29]=y):y=e[29];let _;e[30]!==L||e[31]!==y?(_=n.jsx("div",{className:L,children:y}),e[30]=L,e[31]=y,e[32]=_):_=e[32];let x;e[33]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(lt.IceBreakers,{className:"pb-3"}),e[33]=x):x=e[33];let b;e[34]!==c?(b=n.jsx("div",{"data-chat-above-row":"true",className:"@container/chat-bottom pb-1 flex justify-start gap-1",children:n.jsx(o2,{virtualMcp:c,currentBranch:null})}),e[34]=c,e[35]=b):b=e[35];let S;e[36]!==s?(S=n.jsx(lt.Input,{onOpenContextPanel:s}),e[36]=s,e[37]=S):S=e[37];let w;e[38]!==m||e[39]!==S||e[40]!==_||e[41]!==b?(w=n.jsxs(m,{children:[_,x,b,S]}),e[38]=m,e[39]=S,e[40]=_,e[41]=b,e[42]=w):w=e[42];let j;return e[43]!==w||e[44]!==v?(j=n.jsxs(n.Fragment,{children:[v,w]}),e[43]=w,e[44]=v,e[45]=j):j=e[45],j}function fp(t,e){return(e.updated_at??"").localeCompare(t.updated_at??"")}function g9(t){const e=U.c(17),{outputs:s,collapsed:i,onToggle:r,variant:o}=t,a=o==="card"?"rounded-xl border border-border bg-muted/95 shadow-sm backdrop-blur-sm":"border-b border-border bg-background";let l;e[0]!==a?(l=ce(a),e[0]=a,e[1]=l):l=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Files in this task"}),e[2]=c):c=e[2];const d=i&&"-rotate-90";let h;e[3]!==d?(h=ce("size-4 text-muted-foreground transition-transform",d),e[3]=d,e[4]=h):h=e[4];let u;e[5]!==h?(u=n.jsx(ls,{className:h}),e[5]=h,e[6]=u):u=e[6];let f;e[7]!==r||e[8]!==u?(f=n.jsxs("button",{type:"button",onClick:r,className:"flex w-full items-center justify-between px-3 py-2.5 text-left",children:[c,u]}),e[7]=r,e[8]=u,e[9]=f):f=e[9];let m;e[10]!==i||e[11]!==s?(m=!i&&n.jsx("div",{className:"flex max-h-72 flex-col gap-1.5 overflow-y-auto px-2 pb-2",children:s.map(mp)}),e[10]=i,e[11]=s,e[12]=m):m=e[12];let p;return e[13]!==l||e[14]!==f||e[15]!==m?(p=n.jsxs("div",{className:l,children:[f,m]}),e[13]=l,e[14]=f,e[15]=m,e[16]=p):p=e[16],p}function mp(t){return n.jsx(im,{file:t},t.key)}function pp(){const t=U.c(13),e=u2()?.taskId??null,s=sm();let i;t[0]!==s?(i={enabled:s},t[0]=s,t[1]=i):i=t[1];const{data:r}=$d(e,i),[o,a]=R.useState(!1),[l,c]=R.useState(!0);if(!e||!r||r.length===0)return null;let d;t[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>a(_p),t[2]=d):d=t[2];let h;t[3]!==o||t[4]!==r?(h=n.jsx("div",{className:"absolute top-2 right-2 z-10 hidden w-72 @[1280px]:block",children:n.jsx(g9,{variant:"card",outputs:r,collapsed:o,onToggle:d})}),t[3]=o,t[4]=r,t[5]=h):h=t[5];let u;t[6]===Symbol.for("react.memo_cache_sentinel")?(u=()=>c(gp),t[6]=u):u=t[6];let f;t[7]!==l||t[8]!==r?(f=n.jsx("div",{className:"shrink-0 @[1280px]:hidden",children:n.jsx(g9,{variant:"bar",outputs:r,collapsed:l,onToggle:u})}),t[7]=l,t[8]=r,t[9]=f):f=t[9];let m;return t[10]!==h||t[11]!==f?(m=n.jsxs(n.Fragment,{children:[h,f]}),t[10]=h,t[11]=f,t[12]=m):m=t[12],m}function gp(t){return!t}function _p(t){return!t}function Lp(){const t=U.c(26),{org:e}=Ge(),s=ih(),{isChatEmpty:i}=Ti(),[r,o]=R.useState("chat"),a=Cm(),l=Pm();if(s.length===0&&!jm(l)){let b;return t[0]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(lt,{className:"animate-in fade-in-0 duration-200",children:n.jsx(lt.Main,{className:"flex flex-col items-center",children:n.jsx(lt.EmptyState,{children:n.jsx(lt.NoAiProviderEmptyState,{})})})}),t[0]=b):b=t[0],b}let d;t[1]!==a.hasDecoKey||t[2]!==a.hasOnlyDecoProvider||t[3]!==a.isLoading||t[4]!==a.isZeroBalance||t[5]!==i||t[6]!==e?(d=a.hasDecoKey&&a.isZeroBalance&&a.hasOnlyDecoProvider&&!a.isLoading&&i&&!a2(e.id),t[1]=a.hasDecoKey,t[2]=a.hasOnlyDecoProvider,t[3]=a.isLoading,t[4]=a.isZeroBalance,t[5]=i,t[6]=e,t[7]=d):d=t[7];const h=d;let u;t[8]!==h?(u=h&&n.jsx(lt.CreditsEmptyState,{}),t[8]=h,t[9]=u):u=t[9];const f=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let m;t[10]!==f?(m=ce("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",f),t[10]=f,t[11]=m):m=t[11];let p;t[12]!==i?(p=i?n.jsx(up,{onOpenContextPanel:()=>o("context")}):n.jsxs(n.Fragment,{children:[n.jsxs(lt.Main,{className:"relative flex flex-col overflow-hidden @container",children:[n.jsx(pp,{}),n.jsx("div",{className:"min-h-0 flex-1",children:n.jsx(lt.Messages,{})})]}),n.jsx(lt.Footer,{children:n.jsx(lt.Input,{onOpenContextPanel:()=>o("context")})})]}),t[12]=i,t[13]=p):p=t[13];let g;t[14]!==m||t[15]!==p?(g=n.jsx("div",{className:m,children:p}),t[14]=m,t[15]=p,t[16]=g):g=t[16];const L=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let v;t[17]!==L?(v=ce("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",L),t[17]=L,t[18]=v):v=t[18];let y;t[19]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(ep,{back:!0,onClose:()=>o("chat")}),t[19]=y):y=t[19];let _;t[20]!==v?(_=n.jsx("div",{className:v,children:y}),t[20]=v,t[21]=_):_=t[21];let x;return t[22]!==u||t[23]!==g||t[24]!==_?(x=n.jsxs(lt,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[u,g,_]}),t[22]=u,t[23]=g,t[24]=_,t[25]=x):x=t[25],x}function Nh(){const t=U.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(lt.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(es,{fallback:e,children:n.jsx(R.Suspense,{fallback:n.jsx(lt.Skeleton,{}),children:n.jsx(Lp,{})})}),t[1]=s):s=t[1],s}function vp(t){const e=t.entityMetadata?.defaultMainView??null,s=e==null||e.type==="chat",i=t.mainParamPresent?t.mainParamValue!=="0":!s,r=s?!0:t.entityMetadata?.chatDefaultOpen??!1;return{mainOpen:i,chatOpen:r}}function _9(t,e){return t&&e?{chat:45,main:55}:t&&!e?{chat:100,main:0}:!t&&e?{chat:0,main:100}:{chat:0,main:0}}function xp(t,e){return t===1?!0:t===0?!1:e}function yp(t,e){const s=Vt(),i=Co({strict:!1}),r=Sd({strict:!1}),{create:o}=Fd(),{locator:a}=Ge(),{virtualMcpId:l,orgSlug:c,isAgentRoute:d}=e,h=vp({entityMetadata:t,mainParamPresent:i.main!==void 0,mainParamValue:i.main}),u=xp(i.chat,h.chatOpen),f=h.mainOpen,m=R.useRef(crypto.randomUUID()),p=r.taskId??m.current,g="/$org/$taskId",L=N=>({org:c,taskId:N}),v=d?{virtualmcpid:l}:{},y=(N,T)=>{s({to:g,params:L(p),search:A=>({...A,...N}),replace:T?.replace??!1})},_=(N,T)=>{s({to:g,params:L(N),search:A=>{const k={};return T?k.virtualmcpid=T:d&&(k.virtualmcpid=l),k}})},x=()=>{f?y({main:"0"},{replace:!0}):y({main:Fa(t)},{replace:!0})},b=()=>{y({chat:u?0:1},{replace:!0})},S=()=>{u||y({chat:1},{replace:!0})},w=async()=>{const N=crypto.randomUUID(),T=_m(c,a,p);try{await o({id:N,virtual_mcp_id:l,...T?{branch:T}:{}})}catch{}s({to:g,params:L(N),search:A=>({...v,chat:1})})},j=N=>{y({main:N},{replace:!0})};return{taskId:p,mainOpen:f,chatOpen:u,mainParam:i.main,setTaskId:_,toggleMain:x,toggleChat:b,openChat:S,createNewTask:w,openTab:j}}const oc=45;function Th(t,e=oc){const s=typeof t=="number"?t:Number(t);return!Number.isFinite(s)||s<=0||s>=100?e:s}function bp(t){return Th(t,oc)}function Sp(){const t=U.c(6);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=Kf.decoChatPanelWidth(),t[0]=e):e=t[0];const[s,i]=Uf(e,bp);let r;t[1]!==s?(r=Th(s,oc),t[1]=s,t[2]=r):r=t[2];const o=r;let a;return t[3]!==i||t[4]!==o?(a=[o,i],t[3]=i,t[4]=o,t[5]=a):a=t[5],a}function wp(t){try{return JSON.parse(t)}catch{return null}}function Cp(t){if(!t||typeof t!="object")return null;const e=t,s=e.content?.find(o=>o.type==="text")?.text,i=s?wp(s):null,r=e.structuredContent;return r==null?i:typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===0?i??r:r}function Ii(t){const e=Cp(t);return e===null?null:e}function ac(t){if(!t)return null;const e=t.match(/\/pull\/(\d+)\b/);if(!e)return null;const s=Number(e[1]);return Number.isFinite(s)&&s>0?s:null}function jp(t){if(!t||typeof t!="object")return null;const e=t.content?.find(r=>r.type==="text")?.text;if(!e)return null;const s=e.match(/https:\/\/github\.com\/[^\s"]+\/pull\/\d+/)?.[0],i=ac(s);return!i||!s?null:{number:i,htmlUrl:s}}const L9=/[\r\n<>]/,kp=/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/;function ur(t){const e=t?.userName?.trim();if(!e||L9.test(e))return null;const s=t?.userEmail?.trim();return!s||L9.test(s)?{userName:e}:kp.test(s)?{userName:e,userEmail:s}:{userName:e}}function Np(t){return t.split(`
|
|
3
|
-
`).filter(e=>!/^Co-authored-by:\s/i.test(e)).join(`
|
|
4
|
-
`).trimEnd()}function Tp(t){const e=t.userName.trim(),s=t.userEmail?.trim();return s?`Co-authored-by: ${e} <${s}>`:`Co-authored-by: ${e}`}function Eh(t,e){const s=ur(e);if(!s)return t;const i=Np(t),r=Tp(s);if(i.includes(r))return i;const o=i.trimEnd();return o.length>0?`${o}
|
|
5
|
-
|
|
6
|
-
${r}`:r}function Ah(t,e){const s=t?.trim();return s?Eh(s,e):s||void 0}const Ep=["dev","start"];function Ap(t){if(!t||typeof t!="object")return null;const e=t;return e.isError?e.content?.find(i=>i.type==="text")?.text?.trim()||"GitHub MCP tool returned an error":null}function lc(t){const e=Ap(t);if(e)throw new Error(e)}function Ph(t,e){for(const s of e){const i=t[s];if(typeof i=="string"&&i.length>0)return i}}function Rh(t,e){for(const s of e){const i=t[s];if(typeof i=="number"&&Number.isFinite(i)&&i>0)return i;if(typeof i=="string"&&/^\d+$/.test(i)){const r=Number(i);if(r>0)return r}}}function Pp(t){const s=t.head?.ref;return typeof s=="string"&&s.length>0?s:null}function Rp(t,e){return Pp(t)===e}function Dh(t){const e=Ii(t);if(Array.isArray(e))return e.filter(s=>s!=null&&typeof s=="object");if(e&&typeof e=="object"){const s=e;for(const i of["pull_requests","items","data"]){const r=s[i];if(Array.isArray(r))return r.filter(o=>o!=null&&typeof o=="object")}}return[]}function Dp(t){const e=Ph(t,["html_url","htmlUrl","url","URL"]),s=Rh(t,["number","pullNumber"])??ac(e);return!s||!e?null:{number:s,htmlUrl:e}}function Ip(t){lc(t);const e=jp(t);if(e)return e;const s=Ii(t);if(s&&typeof s=="object"){const i=Ph(s,["url","URL","html_url","htmlUrl"]),r=Rh(s,["number","pullNumber"])??ac(i);if(r&&i)return{number:r,htmlUrl:i}}throw new Error("Failed to open pull request")}function Op(t){return/already exists|pull request already/i.test(t)}async function Mp(t,e){const s=await t.callTool({name:"list_pull_requests",arguments:{owner:e.owner,repo:e.repo,state:"open",...e.head?{head:e.head}:{},perPage:10}});return lc(s),Dh(s)}async function v9(t,e){const s=[`${e.owner}:${e.branch}`,e.branch];for(const i of s){const o=(await Mp(t,{owner:e.owner,repo:e.repo,head:i})).find(l=>Rp(l,e.branch)),a=o?Dp(o):null;if(a)return a}return null}async function Bp(t,e){const s=Ah(e.body,ur(e.coAuthor));if(s)try{await t.callTool({name:"update_pull_request",arguments:{owner:e.owner,repo:e.repo,pullNumber:e.pullNumber,body:s}})}catch{}}async function $p(t,e){const s=Ah(e.body,ur(e.coAuthor)),i=await t.callTool({name:"create_pull_request",arguments:{owner:e.owner,repo:e.repo,title:e.title,body:s||void 0,head:e.head,base:e.base}});return Ip(i)}async function x9(t,e){const s=await v9(t,{owner:e.owner,repo:e.repo,branch:e.branch});if(s)return await Bp(t,{owner:e.owner,repo:e.repo,pullNumber:s.number,body:e.body,coAuthor:e.coAuthor}),s;try{return await $p(t,{owner:e.owner,repo:e.repo,title:e.title,body:e.body,head:e.branch,base:e.base,coAuthor:e.coAuthor})}catch(i){const r=i instanceof Error?i.message:String(i);if(!Op(r))throw i;const o=await v9(t,{owner:e.owner,repo:e.repo,branch:e.branch});if(o)return o;throw i}}async function Ih(t,e){const s=ur(e.coAuthor),i=s?Eh(e.commitMessage?.trim()??"",s):e.commitMessage?.trim()||void 0,r=await t.callTool({name:"merge_pull_request",arguments:{owner:e.owner,repo:e.repo,pullNumber:e.pullNumber,merge_method:"squash",...e.commitTitle?{commit_title:e.commitTitle}:{},...i?{commit_message:i}:{}}});lc(r);const o=Ii(r);if(!o||o.merged!==!0)throw new Error(o?.message??"Failed to merge pull request");return{merged:!0,message:o.message??"Pull request merged"}}const cc=6e4,dc=3e4;function hc(t){const e=U.c(15);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=Dt(s);let r;e[4]!==t.branch||e[5]!==t.owner?(r=t.branch?{head:`${t.owner}:${t.branch}`}:{},e[4]=t.branch,e[5]=t.owner,e[6]=r):r=e[6];let o;e[7]!==t.owner||e[8]!==t.repo||e[9]!==r?(o={owner:t.owner,repo:t.repo,state:"all",...r,perPage:1},e[7]=t.owner,e[8]=t.repo,e[9]=r,e[10]=o):o=e[10];const a=!!t.branch&&!!t.connectionId&&!!t.owner&&!!t.repo;let l;return e[11]!==i||e[12]!==o||e[13]!==a?(l={client:i,toolName:"list_pull_requests",toolArguments:o,enabled:a,refetchInterval:cc,refetchIntervalInBackground:!1,staleTime:dc,select:zp},e[11]=i,e[12]=o,e[13]=a,e[14]=l):l=e[14],Po(l)}function zp(t){const e=Dh(t);if(e.length===0)return null;const s=e[0],i=s.base,r=s.head,o=s.user;return{number:s.number??0,title:s.title??"",body:s.body??"",state:s.state==="closed"?"closed":"open",merged:s.merged_at!=null,mergedAt:s.merged_at??null,base:i?.ref??"main",head:r?.ref??"",headSha:r?.sha??"",htmlUrl:s.html_url??"",author:o?.login??""}}function Oh(t){const e=U.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=Dt(s),r=t.prNumber??0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(o={method:"get_check_runs",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=o):o=e[7];const a=!!t.prNumber;let l;return e[8]!==i||e[9]!==o||e[10]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:cc,refetchIntervalInBackground:!1,staleTime:dc,select:Fp},e[8]=i,e[9]=o,e[10]=a,e[11]=l):l=e[11],Po(l)}function Fp(t){const e=Ii(t);return(Array.isArray(e)?e:e?.check_runs??[]).map(Hp)}function Hp(t){const e=t.started_at,s=t.completed_at,i=e&&s?new Date(s).getTime()-new Date(e).getTime():null;return{id:String(t.id??""),name:String(t.name??""),status:t.status??"completed",conclusion:t.conclusion??null,htmlUrl:String(t.html_url??""),durationMs:i}}function Up(t){const e=U.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=Dt(s),r=t.prNumber??0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(o={method:"get_comments",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=o):o=e[7];const a=!!t.prNumber;let l;return e[8]!==i||e[9]!==o||e[10]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:cc,refetchIntervalInBackground:!1,staleTime:dc,select:Kp},e[8]=i,e[9]=o,e[10]=a,e[11]=l):l=e[11],Po(l)}function Kp(t){const e=Ii(t);return Array.isArray(e)?e.map(Wp):[]}function Wp(t){const e=t.user;return{id:Number(t.id??0),author:e?.login??"",body:String(t.body??""),createdAt:String(t.created_at??""),htmlUrl:String(t.html_url??"")}}function Mh(t){try{const{hostname:e}=new URL(t);return e==="localhost"||e.endsWith(".localhost")||e==="127.0.0.1"||e==="::1"}catch{return!1}}function Vp(){if(typeof document>"u")return null;const t=Array.from(document.querySelectorAll("iframe"));for(const e of t){const s=e.getAttribute("src");if(s&&Mh(s))return s}return null}function Gp(t){const e=t.previewUrl??t.getFallbackPreviewUrl?.()??Vp();if(e&&Mh(e))return new URL("/.decofile",e).toString();const s=new URLSearchParams({path:"/.decofile"});return`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/preview-fetch?${s.toString()}`}function uc(t,e){const s=U.c(8),i=t?`${t.orgSlug}/${t.virtualMcpId}/${t.branch}`:"",r=e?.fetchEnabled??!0;let o;s[0]!==i?(o=Et.decofile(i),s[0]=i,s[1]=o):o=s[1];let a;s[2]!==t?(a=async()=>{const d=await fetch(Gp(t),{cache:"no-store"});if(!d.ok){const h=new Error(`Failed to fetch decofile: ${d.status}`);throw h.status=d.status,h}return await d.json()},s[2]=t,s[3]=a):a=s[3];const l=!!t&&r;let c;return s[4]!==o||s[5]!==a||s[6]!==l?(c={queryKey:o,queryFn:a,enabled:l,staleTime:3e4,retry:Yp,retryDelay:qp},s[4]=o,s[5]=a,s[6]=l,s[7]=c):c=s[7],si(c)}function qp(t){return Lh(5e3,1e3,t,2,0)}function Yp(t,e){return e.status!==502&&t<2}function fc(t,e){const s=U.c(9),i=t?`${t.orgSlug}/${t.virtualMcpId}/${t.branch}/${t.previewUrl??""}`:"",r=e?.fetchEnabled??!0,o=t?.previewUrl;let a;s[0]!==i?(a=Et.liveMeta(i),s[0]=i,s[1]=a):a=s[1];let l;s[2]!==o?(l=async()=>{const u=new URL("/live/_meta",o).href,f=await fetch(u,{cache:"no-store"});if(!f.ok){const m=new Error(`Failed to fetch live meta: ${f.status}`);throw m.status=f.status,m}return await f.json()},s[2]=o,s[3]=l):l=s[3];const c=!!t&&!!o&&r,d=e?.refetchInterval;let h;return s[4]!==a||s[5]!==l||s[6]!==c||s[7]!==d?(h={queryKey:a,queryFn:l,enabled:c,refetchInterval:d,refetchIntervalInBackground:!1,staleTime:3e5,retry:Xp,retryDelay:Jp},s[4]=a,s[5]=l,s[6]=c,s[7]=d,s[8]=h):h=s[8],si(h)}function Jp(t){return Lh(5e3,1e3,t,2,0)}function Xp(t,e){return e.status!==502&&t<3}function Zp(t){if(!t.startsWith("#")||!t.includes("@"))return null;const e=t.indexOf("@");return{moduleResolveType:t.slice(1,e),blockId:t.slice(e+1)}}function uo(t){return t.includes("@")}function Wa(t){const e=t.lastIndexOf("@");return e<0||e===t.length-1?null:t.slice(e+1)}function y9(t,e){if(t===e)return!0;const s=Wa(t);return s?e===s||Wa(e)===s:!1}function mc(t,e){const s=t.manifest?.blocks??{};for(const[i,r]of Object.entries(s))if(e in r)return i;return null}function Bh(t,e){const s=mc(t,e);return s!==null&&s.includes("sections")}function Qp(t,e){const s=mc(t,e);return s!==null&&s.includes("apps")}function e4(t,e){const s=mc(t,e);return s!==null&&s.includes("matchers")}function ks(t){return!(/\.\w+$/.test(t)||t==="__proto__"||t==="constructor")}function Bo(t){try{return decodeURIComponent(t).startsWith("Preview ")}catch{return t.startsWith("Preview ")}}const pc="oklch(0.7278 0.151 289)",$h="website/matchers/always.ts",hn="website/matchers/never.ts",Oi="website/flags/multivariate.ts",fr="website/flags/multivariate/section.ts";function tn(){return{__resolveType:$h}}function ut(t){const e=t.split("/");return(e[e.length-1]??t).replace(/\.(tsx?|jsx?)$/,"").replace(/[-_]/g," ").replace(/\b\w/g,i=>i.toUpperCase())||t}const t4=12,xr=8,s4=40;function i4(t){const e=t.type;return e==="array"||Array.isArray(e)&&e.includes("array")}function n4(t,e){let s=t.items;if(!s)return!1;if(typeof s.$ref=="string"&&(s=e(s.$ref)),Array.isArray(s.anyOf)||Array.isArray(s.oneOf))return!0;const r=s.properties?.__resolveType?.enum;return Array.isArray(r)&&typeof r[0]=="string"}const r4="VideoWidget";function zh(t){return typeof btoa=="function"?btoa(t):Buffer.from(t).toString("base64")}function gc(t){const e=t.match(/^site\/apps\/([^/]+)\/([^/.]+)\.tsx?$/);return e?{vendor:e[1],app:e[2]}:null}function _c(t){const e=t.match(/^([^/]+)\/apps\/([^/.]+)\.tsx?$/);return e?{vendor:e[1],app:e[2]}:null}function Fh(t,e){return[`site/apps/${t}/${e}.ts`,`site/apps/${t}/${e}.tsx`,`${t}/apps/${e}.ts`,`${t}/apps/${e}.tsx`]}function Lc(t,e){const s=e.manifest?.blocks??{};for(const l of Object.values(s))if(l[t])return l[t];const i=gc(t)??_c(t);if(i){for(const l of Fh(i.vendor,i.app))for(const c of Object.values(s))if(c[l])return c[l]}const r=zh(t);for(const l of Object.values(s))if(l[r])return l[r];const o=e.schema??{};return(o.$defs??o.definitions??{})[r]?{$ref:`#/definitions/${r}`}:{}}function Hh(t,e){if(Qp(t,e))return!0;const s=gc(e)??_c(e);if(!s)return!1;const i=t.manifest?.blocks?.apps??{};if(Fh(s.vendor,s.app).some(a=>a in i))return!0;const r=zh(e),o=t.schema?.$defs??t.schema?.definitions??{};return r in o}function Uh(t){return t==="site/apps/site.ts"?!1:gc(t)!==null||_c(t)!==null}function Bs(t,e){const s=e.schema??{},i=Lc(t,e),r=s.$defs??s.definitions??{},o=s.root??{},a=v=>{if(v.startsWith("#/root/")){const _=v.slice(7);return o[_]??{}}const y=v.split("/").pop()??"";return r[y]??{}};let l;typeof i.$ref=="string"?l=a(i.$ref):Object.keys(i).length>0?l=i:l=s;const c=v=>typeof v.$ref=="string"?a(v.$ref):v,d=v=>{const _=c(v).properties?.type;if(_){if(typeof _.const=="string")return _.const;if(typeof _.default=="string")return _.default;if(Array.isArray(_.enum)&&typeof _.enum[0]=="string")return _.enum[0]}},h=(v,y)=>{const _=c(v);return typeof _.title=="string"&&!_.title.startsWith("#")?_.title:y},u=(v,y=new Set)=>{if(typeof v.$ref!="string"||v.properties||v.anyOf||v.allOf||v.oneOf||v.type)return v;const _=v.$ref.split("/").pop()??"";return!_||y.has(_)?v:u(a(v.$ref),new Set([...y,_]))},f=v=>{const y=v.hide;return y===!0||y==="true"},m=(v,y=new Set,_=0)=>{if(_>t4)return{};if(typeof v.$ref=="string"){const b=v.$ref.split("/").pop()??"";return y.has(b)?{}:m(a(v.$ref),new Set([...y,b]),_+1)}let x={};if(v.properties&&typeof v.properties=="object"&&(x={...x,...v.properties}),Array.isArray(v.required)){const b=Array.isArray(x.__required)?x.__required:[];x.__required=[...b,...v.required]}for(const b of["allOf","anyOf","oneOf"]){const S=v[b];if(Array.isArray(S))for(const w of S)x={...x,...m(w,y,_+1)}}return x},p=(v,y=0,_=new Set)=>{let x=v,b;if(typeof v.$ref=="string"){x=a(v.$ref);const O=v.$ref.split("/").pop()??"";b=O,O===r4&&!x.format&&(x={...x,format:"video-uri"})}x=u(x);const S=b!==void 0&&_.has(b),w=b!==void 0?new Set([..._,b]):_,j=(O,P,D,M=!0)=>!S&&(!M||D<=s4)&&P<xr?p(O,P,w):void 0;let N;{const O=x.anyOf??x.oneOf;if(Array.isArray(O)){const P=O.filter(M=>!(M.type==="null"||M.type===null)),D=M=>{if(typeof M.const=="string"||typeof M.const=="number")return M.const;if(Array.isArray(M.enum)&&M.enum.length===1&&(typeof M.enum[0]=="string"||typeof M.enum[0]=="number"))return M.enum[0]};P.length>0&&P.every(M=>D(M)!==void 0)&&(N=P.map(M=>D(M)))}}let T,A;if(x.type)T=Array.isArray(x.type)?String(x.type.find(O=>O!=="null")??x.type[0]):String(x.type);else if(x.anyOf||x.allOf||x.oneOf){const P=(x.anyOf??x.allOf??x.oneOf).filter(D=>!(D.type==="null"||D.type===null));if(P.length===0)T="null";else if(P.length===1){const D=P[0];A=D,T=D.type?Array.isArray(D.type)?String(D.type[0]):String(D.type):typeof D.$ref=="string"?"object":"string"}else{if(N)return{type:"string",title:typeof x.title=="string"?x.title:void 0,description:typeof x.description=="string"?x.description:void 0,enum:N};const D=P.filter(G=>{const q=G.properties?.__resolveType?.enum;return Array.isArray(q)&&typeof q[0]=="string"}),M=P.find(i4),z=D.some(G=>{const q=G.properties?.__resolveType?.enum;return Array.isArray(q)&&q[0]===Oi});if(M){if(!n4(M,a)&&P.length>1){const q=p(M,y+1,w);return{...q,type:"array",title:typeof x.title=="string"?x.title:q.title,description:typeof x.description=="string"?x.description:q.description}}if(z){const q=p(M,y+1,w);return{...q,type:"array",title:typeof x.title=="string"?x.title:q.title,description:typeof x.description=="string"?x.description:q.description}}}if(D.length>0){const G=D.map(W=>{const Q=W.properties?.__resolveType?.enum??[],ie=String(Q[0]);return{resolveType:ie,title:typeof W.title=="string"?W.title:ut(ie),description:typeof W.description=="string"?W.description:void 0,schema:j(W,y+1,P.length)}}),q=[];for(const W of P){if(D.includes(W)||typeof W.$ref!="string")continue;const Y=a(W.$ref);let Q;const ie=Y.properties?.__resolveType;if(Array.isArray(ie?.enum)&&typeof ie.enum[0]=="string"&&(Q=ie.enum[0]),!Q&&Array.isArray(Y.allOf))for(const oe of Y.allOf){const ue=oe.properties?.__resolveType?.enum;if(Array.isArray(ue)&&typeof ue[0]=="string"){Q=ue[0];break}}Q&&q.push({resolveType:Q,title:typeof Y.title=="string"&&!Y.title.startsWith("#")?Y.title:ut(Q),description:typeof Y.description=="string"?Y.description:void 0,schema:j(Y,y+1,P.length)})}const H=new Set(G.map(W=>W.resolveType)),K=[...G,...q.filter(W=>!H.has(W.resolveType))],B=P.filter(W=>!D.includes(W)),X=B.length===1?j(B[0],y+1,P.length):void 0;return{type:"block-ref",title:typeof x.title=="string"?x.title:void 0,description:typeof x.description=="string"?x.description:void 0,anyOfRefs:K,plainSchema:X,hidden:f(x)||f(v)?!0:void 0}}const F=P.map(G=>d(G));if(P.length>1&&F.every(G=>typeof G=="string")){const G=P.map((q,H)=>{const K=c(q),B=F[H];return{resolveType:B,title:h(q,B),description:typeof K.description=="string"?K.description:void 0,discriminatorValue:B,schema:j(K,y+1,P.length,!1)}});return{type:"block-ref",title:typeof v.title=="string"?v.title:typeof x.title=="string"?x.title:void 0,description:typeof v.description=="string"?v.description:typeof x.description=="string"?x.description:void 0,discriminatorKey:"type",anyOfRefs:G,hidden:f(x)||f(v)?!0:void 0}}if(P.every(G=>typeof G.$ref=="string")){const G=[];for(const q of P){const H=a(q.$ref);let K,B;if(typeof H.title=="string"){const W=Zp(H.title);W&&(K=W.blockId,B=W.blockId)}if(!K&&Array.isArray(H.allOf))for(const W of H.allOf){const ie=((W.properties??{}).__resolveType??{}).enum;if(Array.isArray(ie)&&typeof ie[0]=="string"){K=ie[0];break}}if(!K){const Y=H.properties?.__resolveType?.enum;Array.isArray(Y)&&typeof Y[0]=="string"&&(K=Y[0])}K||(K=q.$ref.split("/").pop()??"");const X=d(q);!X&&!K.includes("/")||G.push({resolveType:X??K,title:B??(typeof H.title=="string"&&!H.title.startsWith("#")?H.title:ut(K)),description:typeof H.description=="string"?H.description:void 0,discriminatorValue:X,schema:j(H,y+1,P.length)})}return{type:"block-ref",title:typeof x.title=="string"?x.title:void 0,description:typeof x.description=="string"?x.description:void 0,anyOfRefs:G,hidden:f(x)||f(v)?!0:void 0}}const J=Array.isArray(x.anyOf)||Array.isArray(x.oneOf),Z=P.every(G=>typeof G.$ref!="string"&&(G.type==="object"||!!G.properties));if(J&&Z&&y<xr){const G=H=>{if(typeof H.const=="string"||typeof H.const=="number"||typeof H.const=="boolean")return H.const;if(Array.isArray(H.enum)&&H.enum.length===1&&(typeof H.enum[0]=="string"||typeof H.enum[0]=="number"||typeof H.enum[0]=="boolean"))return H.enum[0]},q=P.map((H,K)=>{const B=H.properties??{},X={};for(const[W,Y]of Object.entries(B)){const Q=G(Y);Q!==void 0&&(X[W]=Q)}return{title:h(H,`Option ${K+1}`),schema:p(H,y+1),discriminators:Object.keys(X).length?X:void 0}});return{type:"inline-union",title:typeof v.title=="string"?v.title:typeof x.title=="string"?x.title:void 0,description:typeof x.description=="string"?x.description:void 0,inlineUnionBranches:q,hidden:f(x)||f(v)?!0:void 0}}T="object"}}else typeof v.$ref=="string"&&(T="object");let k;if(y<xr){const O=m(x),P=Object.entries(O).filter(([D])=>!D.startsWith("__")&&D!=="@type");if(P.length>0){k={};for(const[D,M]of P)k[D]=p(M,y+1,w)}}let C;if((T==="array"||x.type==="array")&&y<xr){let O=x.items;O&&(typeof O.$ref=="string"&&(O=a(O.$ref)),C=p(O,y+1,w),typeof O.title=="string"&&O.title.includes("{{")&&(C.titleBy=O.title))}const I=O=>{const P=A?.[O];return typeof P=="string"?P:void 0},E=()=>{if("default"in v)return v.default;if("default"in x)return x.default;if(A&&"default"in A)return A.default};return{type:T??"string",title:typeof v.title=="string"?v.title:typeof x.title=="string"?x.title:I("title"),description:typeof v.description=="string"?v.description:typeof x.description=="string"?x.description:I("description"),default:E(),enum:Array.isArray(x.enum)?x.enum:N??void 0,format:typeof x.format=="string"?x.format:I("format"),properties:k,items:C,hidden:f(x)||f(v)?!0:void 0,titleBy:typeof x.titleBy=="string"?x.titleBy:I("titleBy"),image:typeof x.image=="string"?x.image:I("image"),options:typeof x.options=="string"?x.options:I("options")}},g=m(l),L={};for(const[v,y]of Object.entries(g))v.startsWith("__")||v==="@type"||(L[v]=p(y,0));return Object.keys(L).length===0?null:{type:"object",title:typeof l.title=="string"?l.title:void 0,properties:L}}function o4(t,e){const s=e.schema??{},i=Lc(t,e),r=s.$defs??s.definitions??{},o=typeof i.$ref=="string"?r[i.$ref.split("/").pop()??""]??{}:i,a=o.properties??{};if(Object.keys(a).some(d=>!d.startsWith("__")))return!1;if(o.additionalProperties===!0)return!0;const c=a.__resolveType;return!!c&&Array.isArray(c.enum)&&c.enum[0]===t}function a4(t){const e=i=>{switch(typeof i){case"number":return{type:"number"};case"boolean":return{type:"boolean"};case"object":{if(i===null)return{type:"string"};if(Array.isArray(i))return{type:"array",items:e(i[0])};const r={};for(const[o,a]of Object.entries(i))o.startsWith("__")||(r[o]=e(a));return{type:"object",properties:r}}default:return{type:"string"}}},s={};for(const[i,r]of Object.entries(t))i.startsWith("__")||(s[i]=e(r));return Object.keys(s).length===0?null:{type:"object",properties:s}}function oi(t,e){const s=e.schema??{},i=Lc(t,e),r=s.$defs??s.definitions??{},o=typeof i.$ref=="string"?r[i.$ref.split("/").pop()??""]??{}:Object.keys(i).length>0?i:{...s,...i},a=o.icon,l=o.logo,c=o,d=u=>u===!0||u==="true",h=d(c.hide)||d(c.ignore)||d(c.unlisted);return{title:typeof o.title=="string"?o.title:void 0,description:typeof o.description=="string"?o.description:void 0,icon:typeof a=="string"?a:void 0,logo:typeof l=="string"?l:void 0,hidden:h||void 0}}function qi(t){return t.replace(/\/+$/,"")||"/"}function l4(t){const e=t.trim();return!(!e.startsWith("/")||e.startsWith("//")||e.includes("..")||e.includes("\\"))}function vc(t){const e=t.trim();return e?l4(e)?null:"Path must start with / and must not contain .. or //.":"Path is required."}const Kh=/:([A-Za-z0-9_-]+)|\*/g;function c4(t){const e=[];let s=0;for(const i of t.matchAll(Kh))i.index>s&&e.push({type:"text",text:t.slice(s,i.index)}),e.push({type:"param",name:i[1]??"*"}),s=i.index+i[0].length;return s<t.length&&e.push({type:"text",text:t.slice(s)}),e}function yr(t,e){return t.replace(Kh,(s,i)=>{const r=e[i??"*"]?.trim();return r?i!==void 0?encodeURIComponent(r):r.split("/").filter(Boolean).map(encodeURIComponent).join("/")||s:s})}const d4=["website/sections/Rendering/Lazy.tsx","website/sections/Rendering/SingleDeferred.tsx"],b9="website/sections/Rendering/Lazy.tsx";function At(t){return d4.some(e=>t.endsWith(e))}const Wh=["website/pages/Page.tsx","$live/pages/LivePage.tsx"],Vh=new Set(Wh),h4=new Set(["site/sections/Theme/Theme.tsx"]);function $o(t){return!!(h4.has(t)||At(t)||t.toLowerCase().includes("preview"))}function Gh(t){const e=t.manifest?.blocks??{};for(const s of Object.values(e))for(const i of Object.keys(s))if(Vh.has(i))return i;return Wh[0]}function Va(t){if(!t)return[];if(t.anyOfRefs?.length)return t.anyOfRefs;if(t.items)return Va(t.items);if(t.properties){const e=[];for(const s of Object.values(t.properties))e.push(...Va(s));return e}return[]}function u4(t){const e=t.manifest?.blocks??{},s=[];for(const[i,r]of Object.entries(e))if(i.includes("sections"))for(const o of Object.keys(r)){if($o(o))continue;const a=oi(o,t);s.push({resolveType:o,title:a.title??ut(o),description:a.description,previewBlock:o,isSavedBlock:!1})}return s}function f4(t){const e=t.manifest?.blocks??{},s=[];for(const[i,r]of Object.entries(e))if(i.includes("sections"))for(const o of Object.keys(r))$o(o)||s.push({resolveType:o,title:ut(o)});return s.sort((i,r)=>i.title.localeCompare(r.title))}function qh(t,e){const s=[];for(const[i,r]of Object.entries(e)){if(i.includes("/")||Bo(i)||!r||typeof r!="object"||Array.isArray(r))continue;const o=r,a=o.__resolveType;typeof a=="string"&&(Vh.has(a)||typeof o.path!="string"&&($o(a)||Bh(t,a)&&s.push({resolveType:i,title:i,description:typeof o.name=="string"?o.name:void 0,previewBlock:i,isSavedBlock:!0})))}return s}function m4(t,e){const s=ks(e.resolveType),i=s?{}:oi(e.resolveType,t);return{resolveType:e.resolveType,title:e.title||i.title||ut(e.resolveType),description:e.description??i.description,previewBlock:e.resolveType,isSavedBlock:s}}function uk(t,e){const s=Gh(t),i=Bs(s,t),r=Va(i?.properties?.sections),o=new Map,a=l=>{if(!$o(l.resolveType)){if(ks(l.resolveType)){Bo(l.resolveType)||o.set(l.resolveType,l);return}Bh(t,l.resolveType)&&(o.has(l.resolveType)||o.set(l.resolveType,l))}};for(const l of u4(t))a(l);for(const l of r)a(m4(t,l));for(const l of qh(t,e))a(l);return[...o.values()].sort((l,c)=>l.title.localeCompare(c.title))}function fk(t){const e=t.site;if(!e||typeof e!="object"||Array.isArray(e))return;const s=e.theme;if(!(!s||typeof s!="object"||Array.isArray(s)))return s}function p4(t){let e=t;e.startsWith("pages-")&&(e=e.slice(6)),e=e.replace(/-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,""),e=e.replace(/-[0-9a-f]{8,}$/i,"");try{return decodeURIComponent(e)}catch{return e}}function g4(t,e,s){const i=qi;if(s){const o=t.find(a=>a.key===s);if(o)return o}const r=t.filter(o=>i(o.path)===i(e));return r.length===0?null:r.length===1?r[0]??null:[...r].sort((o,a)=>o.key.localeCompare(a.key))[0]??null}const Yh=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]),Pn="site",xc="site/apps/site.ts";function fo(t,e){return t===Pn?!0:e.__resolveType===xc}function yc(t,e){return t?bc(t).length>0?!0:e?Sc(t,e).length>0||Ga(t,e)?!0:_4(t,e).length>0:!1:!1}function bc(t){const e=[];for(const[s,i]of Object.entries(t))if(i&&typeof i=="object"&&!Array.isArray(i)){const r=i;typeof r.__resolveType=="string"&&Yh.has(r.__resolveType)&&typeof r.path=="string"&&e.push({key:s,name:typeof r.name=="string"?r.name:p4(s),path:r.path})}return e}function zo(t,e){if(typeof e.name=="string"){const s=e.name.trim();if(s)return s}return t.replace(/[-_]/g," ").replace(/\b\w/g,s=>s.toUpperCase())}function mo(t,e,s){const i=typeof e.__resolveType=="string"?e.__resolveType:"",r=i?oi(i,s):{};if(r.title)return r.title;if(typeof e.name=="string"){const o=e.name.trim();if(o)return o}return t.replace(/[-_]/g," ").replace(/\b\w/g,o=>o.toUpperCase())}function Ga(t,e){const s=t[Pn];if(s&&typeof s=="object"&&!Array.isArray(s)){const i=s,r=i.__resolveType;if(typeof r=="string"&&(fo(Pn,i)||Hh(e,r)))return{key:Pn,name:mo(Pn,i,e),resolveType:r}}for(const[i,r]of Object.entries(t)){if(i.includes("/")||!r||typeof r!="object"||Array.isArray(r))continue;const o=r;if(!fo(i,o))continue;const a=typeof o.__resolveType=="string"?o.__resolveType:xc;return{key:i,name:mo(i,o,e),resolveType:a}}return null}function _4(t,e){const s=[];for(const[i,r]of Object.entries(t)){if(i.includes("/")||!r||typeof r!="object"||Array.isArray(r))continue;const o=r,a=o.__resolveType;typeof a=="string"&&(Yh.has(a)||typeof o.path!="string"&&(fo(i,o)||!Hh(e,a)&&!Uh(a)||s.push({key:i,name:mo(i,o,e),resolveType:a})))}return s.sort((i,r)=>i.name.localeCompare(r.name))}function Sc(t,e){return qh(e,t).map(s=>{const i=t[s.resolveType],r=typeof i.__resolveType=="string"?i.__resolveType:"";return{key:s.resolveType,name:s.description??zo(s.resolveType,i),resolveType:r}}).sort((s,i)=>s.name.localeCompare(i.name))}const L4={phase:null,lifecycle:{phase:"idle"},status:{state:"running"},branch:{kind:"unknown"},notFound:!1,scripts:[],activeProcesses:[],getBuffer:()=>"",hasData:()=>!1,subscribeChunks:()=>()=>{},subscribeReload:()=>()=>{}},Jh=R.createContext(L4),S9=16384;class v4{data="";append(e){this.data+=e,this.data.length>S9&&(this.data=this.data.slice(this.data.length-S9))}get(){return this.data}clear(){this.data=""}}const x4=1e3,y4=3e4,b4=3e3,w9=["lifecycle","status","tasks","scripts","branch","reload","file-changed"],C9="log";function S4(t){if(!t)return null;try{return new URL("/_sandbox/events",t).href}catch{return null}}function w4(t){return t===404}async function C4(t){try{const e=await fetch(t,{headers:{Accept:"text/event-stream"},cache:"no-store",signal:AbortSignal.timeout(b4)});return await e.body?.cancel().catch(()=>{}),w4(e.status)}catch{return!1}}function j4({virtualMcpId:t,branch:e,previewUrl:s=null,enabled:i=!0,children:r}){const{org:o}=Ge(),a=Ni(),[l,c]=R.useState(null),[d,h]=R.useState({phase:"idle"}),[u,f]=R.useState({state:"running"}),[m,p]=R.useState({kind:"unknown"}),[g,L]=R.useState(!1),[v,y]=R.useState([]),[_,x]=R.useState([]),[,b]=R.useState(0),S=R.useRef(new Map),w=R.useRef(new Set),j=R.useRef(new Set),N=R.useRef(null),T=S4(s),A=C=>{let I=S.current.get(C);return I||(I=new v4,S.current.set(C,I)),I};R.useEffect(()=>{if(c(null),h({phase:"idle"}),f({state:"running"}),p({kind:"unknown"}),N.current=null,L(!1),y([]),x([]),S.current.clear(),!t||!e||!i)return;const C=`/api/${encodeURIComponent(o.slug)}/sandbox/${encodeURIComponent(t)}/${encodeURIComponent(e)}/events`;let I=!1,E=0,O=null,P=null,D=null,M=null,z=null;const F=K=>{try{const B=JSON.parse(K.data);c(B),B.kind!=="failed"&&(L(!1),E=0),B.kind==="ready"&&G()}catch(B){console.warn("[vm-events] bad phase payload",B)}},$=()=>{L(!0),c(null),h({phase:"idle"}),f({state:"running"}),p({kind:"unknown"}),y([]),x([]),S.current.clear()},V=K=>{try{const B=JSON.parse(K.data);if(typeof B.data!="string")return;E=0;const X=B.data.replace(/\r?\n/g,`\r
|
|
7
|
-
`);A(B.source).append(X);for(const W of w.current)try{W(B.source,X)}catch{}b(W=>W+1)}catch{}},J=K=>{const B=K.type;try{const X=JSON.parse(K.data);switch(E=0,B){case"lifecycle":{const W=X;h(W.state);const Y=W.state.phase==="running"?W.state.port:null,Q=N.current;if(N.current=Y,Q!==null&&Y!==null&&Q!==Y)for(const ie of j.current)try{ie()}catch{}return}case"status":f(X);return;case"tasks":{const Y=X.active.map(Q=>Q.logName??"").filter(Boolean);x(Y);return}case"scripts":y(X.scripts);return;case"branch":{const W=X.meta;p(W);return}case"reload":for(const W of j.current)try{W()}catch{}return;case"file-changed":{const{path:W}=X,Y=`${o.slug}/${t}/${e}`;W.startsWith(".deco/")?(D&&clearTimeout(D),D=setTimeout(()=>{D=null,a.invalidateQueries({queryKey:Et.decofile(Y)})},1e3)):(P&&clearTimeout(P),P=setTimeout(()=>{P=null,a.invalidateQueries({predicate:Q=>{const ie=Q.queryKey;return ie[0]==="live-meta"&&typeof ie[1]=="string"&&ie[1].startsWith(`${Y}/`)}})},1e3));return}}}catch{}};function Z(){if(I)return;const K=new EventSource(C);M=K,K.onopen=()=>{},K.onerror=()=>{M===K&&K.readyState===EventSource.CLOSED&&H("studio")},K.addEventListener("phase",F),K.addEventListener("gone",$),K.addEventListener(C9,V);for(const B of w9)K.addEventListener(B,J)}function G(){if(I||!T||z)return;const K=new EventSource(T);z=K;let B=!1;K.onopen=()=>{if(I||z!==K)return;B=!0,E=0;const X=M;M=null,X?.close()},K.onerror=()=>{z===K&&K.readyState===EventSource.CLOSED&&q(K,B)},K.addEventListener(C9,V);for(const X of w9)K.addEventListener(X,J)}async function q(K,B){const X=T?await C4(T):!1;if(!(I||z!==K)){if(K.close(),z=null,X){$(),M||Z();return}B&&H("direct")}}function H(K){if(I||O)return;const B=Math.min(x4*2**E,y4);E++,O=setTimeout(()=>{if(O=null,!I){if(K==="direct"){z?.close(),z=null,G();return}M?.close(),M=null,Z()}},B)}return Z(),()=>{I=!0,M?.close(),z?.close(),O&&clearTimeout(O),P&&clearTimeout(P),D&&clearTimeout(D)}},[t,e,o.slug,i,T,a]);const k={phase:l,lifecycle:d,status:u,branch:m,notFound:g,scripts:v,activeProcesses:_,getBuffer:C=>S.current.get(C)?.get()??"",hasData:C=>(S.current.get(C)?.get().length??0)>0,subscribeChunks:C=>(w.current.add(C),()=>{w.current.delete(C)}),subscribeReload:C=>(j.current.add(C),()=>{j.current.delete(C)})};return n.jsx(Jh,{value:k,children:r})}function As(){return R.use(Jh)}function Xh(t){const{subscribeChunks:e}=As(),s=R.useRef(t);s.current=t,R.useEffect(()=>e((o,a)=>{s.current?.(o,a)}),[e])}function k4(t){const{subscribeReload:e}=As(),s=R.useRef(t);s.current=t,R.useEffect(()=>e(()=>{s.current?.()}),[e])}function Zh(t){const e=Object.values(t),[s]=e;return s?e.find(i=>i.sandboxProviderKind!=="user-desktop")??s:null}function Qh(t){return t.appPaused||t.userStopped?{kind:"suspended"}:t.startError&&!t.previewUrl?{kind:"errored",error:t.startError}:t.previewUrl?{kind:"iframe",previewUrl:t.previewUrl}:{kind:"starting"}}const eu={githubNotAuthenticated:"GITHUB_NOT_AUTHENTICATED"},j9="::";function tu(t){const e=t.indexOf(j9);if(e>0){const s=t.slice(0,e);if(Object.values(eu).includes(s))return{code:s,message:t.slice(e+j9.length)}}return{code:null,message:t}}function N4(t){return t.hasActiveGithubRepo&&!!t.userId&&!t.vmEntry&&!t.userStopped&&!t.isPending&&!t.attempted}function T4(t){return t.notFound&&!!t.deadVmId&&!t.isPending&&!t.userStopped&&t.deadVmId!==t.lastDeadVmId}function na(t,e,s){const i={virtualMcpId:t};return e&&(i.branch=e),s&&(i.sandboxProviderKind=s),i}function E4(t){switch(t.kind){case"suspended":return"suspended";case"iframe":return"running";case"starting":return"starting";case"errored":return"errored"}}const A4={branch:null,previewState:{kind:"starting"},status:"idle",vmEntry:null,previewUrl:null,userStopped:!1,start:()=>{},stop:async()=>{},restart:async()=>{},retry:()=>{},resume:()=>{}},su=R.createContext(A4);function wc(){return R.use(su)}function P4({virtualMcpId:t,branch:e,userId:s,hasActiveGithubRepo:i,sandboxMap:r,sandboxProviderKind:o,children:a}){const{org:l}=Ge(),{setCurrentTaskBranch:c}=$s(),d=As(),h=Ni(),u=Dt({connectionId:Kl,orgId:l.id,orgSlug:l.slug}),f=Bl(u),{mutate:m,reset:p}=f,g=R.useRef(new Set),L=R.useRef(null),v=s&&e?jo(r?.[s]?.[e]):{},y=o?v[o]??null:Zh(v),_=y?.previewUrl??null,x=!!t&&!!e&&Ma.isStopped(t,e),b=d.status.state==="paused",S=f.isError&&f.error?tu(f.error.message):null,w=Qh({previewUrl:_,appPaused:b,userStopped:x,startError:S}),j=E4(w),N=e??"",T=g.current.has(N),A=N4({hasActiveGithubRepo:i,userId:s,vmEntry:y,userStopped:x,isPending:f.isPending,attempted:T});R.useEffect(()=>{if(!A||!t)return;g.current.add(N);const z=na(t,e,o);m(z,{onSuccess:F=>{F?.branch&&!e&&c(F.branch)},onError:F=>{console.error("[sandbox-lifecycle] auto-start failed:",F)}})},[A,N,e,t,o,m,c]);const k=d.notFound?y?.sandboxHandle??null:null,C=T4({notFound:d.notFound,deadVmId:k,lastDeadVmId:L.current,isPending:f.isPending,userStopped:x});R.useEffect(()=>{if(!C||!k||!t)return;L.current=k;const z=na(t,e,o);m(z,{onSuccess:F=>{F?.branch&&!e&&c(F.branch)},onError:F=>{console.error("[sandbox-lifecycle] self-heal failed:",F)}})},[C,k,t,e,o,m,c]);const I=()=>{if(!t)return;const z=na(t,e,o);m(z,{onSuccess:F=>{F?.branch&&!e&&c(F.branch)},onError:F=>{console.error("[sandbox-lifecycle] user start failed:",F)}})},E=async()=>{if(!t||!e)return;const z=y?.sandboxProviderKind;if(z){Ma.mark(t,e);try{await u.callTool({name:"SANDBOX_DELETE",arguments:{virtualMcpId:t,branch:e,sandboxProviderKind:z}})}catch{}Wf(h)}},O=async()=>{await E(),I()},P=()=>{g.current=new Set,L.current=null,p(),I()},M={branch:e,previewState:w,status:j,vmEntry:y,previewUrl:_,userStopped:x,start:I,stop:E,restart:O,retry:P,resume:P};return n.jsx(su,{value:M,children:a})}const R4={settings:g2,automations:Ad,preview:Pi,content:Ed,git:No,files:en};function k9(t){const e=To(t);if(e.type==="icon"){const s=Ai(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function ra(t){if(t.kind==="system")return{kind:"component",Component:R4[t.tabId]};const e=k9(t.iconUrl);if(e)return e;if(!t.appId)return{kind:"fallback"};const s=t.connections.find(r=>r.id===t.appId);if(!s)return{kind:"fallback"};const i=k9(s.icon);return i||{kind:"fallback"}}function D4(t){const{org:e}=Ge(),s=Ri(),i=Hd(),r=R.useSyncExternalStore(i.threads.subscribe,i.threads.get),o=t?r.find(l=>l.id===t)??null:null,{data:a}=Vf({queryKey:Et.ensureTask(e.id,t),queryFn:async()=>{if(!t)return null;try{const{item:l}=await s.call("COLLECTION_THREADS_GET",{id:t});return l??null}catch{return null}},select:l=>l?.metadata??null,staleTime:3e4});return o?.metadata??a??null}function Cc(t){const e=U.c(35),s=Vt();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const r=Co(i),o=Ts(t.virtualMcpId),a=D4(t.taskId),{org:l}=Ge(),{currentBranch:c}=$s();let d;e[1]!==o?(d=Ao(o),e[1]=o,e[2]=d):d=e[2];const h=d,u=h?.connectionId??"",f=h?.owner??"",m=h?.name??"",p=h?c:null;let g;e[3]!==l.id||e[4]!==l.slug||e[5]!==u||e[6]!==f||e[7]!==m||e[8]!==p?(g={orgId:l.id,orgSlug:l.slug,connectionId:u,owner:f,repo:m,branch:p},e[3]=l.id,e[4]=l.slug,e[5]=u,e[6]=f,e[7]=m,e[8]=p,e[9]=g):g=e[9];const L=hc(g),v=L.data?.state==="open",y=o?.metadata?.ui??null,_=y?.layout??null,x=_?.tabs??[],b=o?.id?ym(o.id):null,S=a?.expanded_tools??[],w=Wd(o),j=o?.metadata;let N;e[10]!==j?(N=vi(j),e[10]=j,e[11]=N):N=e[11];const T=N,{granted:A}=s3("agents:manage");let k;e[12]===Symbol.for("react.memo_cache_sentinel")?(k={includeVirtual:!0},e[12]=k):k=e[12];const C=rr(k),I=As(),{vmEntry:E,previewUrl:O}=wc(),P=I.lifecycle.phase==="running";let D;e[13]!==O||e[14]!==E?.sandboxProviderKind?(D=E?.sandboxProviderKind==="user-desktop"&&O?`${O.replace(/\/+$/,"")}/api/mcp`:void 0,e[13]=O,e[14]=E?.sandboxProviderKind,e[15]=D):D=e[15];const M=D,z=bm({connectionId:b??void 0,orgId:l.id,orgSlug:l.slug,mcpUrl:M}),F=z,$=!!z&&P;let V;e[16]!==F||e[17]!==$?(V={client:F,enabled:$},e[16]=F,e[17]=$,e[18]=V):V=e[18];const{data:J}=ph(V),Z=b&&P?(J?.tools??[]).filter(M4).map(_e=>({connectionId:b,toolName:_e.name,label:$a(_e.name),icon:null})):[],G=Z[0],q=G?Z:y?.pinnedViews??[],H=G&&b?{type:"ext-apps",id:b,toolName:G.toolName}:_?.defaultMainView??null;let K;e[19]!==c||e[20]!==o||e[21]!==T||e[22]!==l.slug||e[23]!==O?(K=T&&o?.id&&c?{orgSlug:l.slug,virtualMcpId:o.id,branch:c,previewUrl:O}:null,e[19]=c,e[20]=o,e[21]=T,e[22]=l.slug,e[23]=O,e[24]=K):K=e[24];const B=K;let X;e[25]!==P?(X={fetchEnabled:P},e[25]=P,e[26]=X):X=e[26];const{data:W}=uc(B,X);let Y;e[27]!==P?(Y={fetchEnabled:P},e[27]=P,e[28]=Y):Y=e[28];const{data:Q}=fc(B,Y),ie=yc(W,Q),{activeTab:oe,mainOpen:ue}=Dm({mainParam:r.main,metadata:H||_?{defaultMainView:H,tabs:x.map(O4)}:null}),ee=w&&(v||L.isPending&&oe==="git"),te=H||_?{defaultMainView:H,tabs:x.map(I4)}:null,fe=oe==="git"&&!ee&&!L.isPending?Fa(te):oe==="content"&&!ie?Fa(te):oe,he=oe==="git"&&!ee&&!L.isPending?!1:ue,ye=nh(fe),ve=[];T&&(ve.push({id:"preview",title:"Preview"}),ie&&ve.push({id:"content",title:"Content"})),ee&&ve.push({id:"git",title:"Review changes"}),A&&ve.push({id:"settings",title:"Settings"}),ve.push({id:"automations",title:"Automations"}),ve.push({id:"files",title:"Library"});const be=new Map;for(const _e of S){const Re=h9(_e.appId,_e.toolName);be.set(Re,{id:Re,title:_e.toolName,appId:_e.appId,iconKey:_e.toolName})}for(const _e of q){const Re=h9(_e.connectionId,_e.toolName);be.set(Re,{id:Re,title:_e.label||_e.toolName,appId:_e.connectionId,iconKey:_e.toolName,iconUrl:_e.icon??null})}const Ne=rh(fe),Oe=Ne?Ne.key.split("/").pop()??Ne.key:null,Fe=Oe?[{id:fe,title:Oe,kind:"file",icon:{kind:"component",Component:_e=>R.createElement(Qi,{filename:Oe,..._e})}}]:[],Me=oh(fe),qe=Me?[{id:fe,title:(Me.path.split("/").pop()??Me.path).replace(/\.html$/i,""),kind:"file",icon:{kind:"component",Component:_e=>R.createElement(Me.path.startsWith("pages/")?Pi:fh,_e)}}]:[],Ie=ah(fe),pe=Ie?Ie.path.split("/").pop()??Ie.path:null,je=pe?[{id:fe,title:pe,kind:"file",icon:{kind:"component",Component:_e=>R.createElement(Qi,{filename:pe,..._e})}}]:[];let Be;e[29]!==C?(Be=_e=>({id:_e.id,title:_e.title,kind:"agent",icon:ra({tabId:_e.id,kind:"agent",appId:_e.view.appId,connections:C})}),e[29]=C,e[30]=Be):Be=e[30];const le=[...Fe,...qe,...je,...x.map(Be),...Array.from(be.values()).map(_e=>({id:_e.id,title:_e.title,kind:"expanded",icon:ra({tabId:_e.iconKey,kind:"expanded",appId:_e.appId,iconUrl:_e.iconUrl,connections:C})})),...ve.map(_e=>({id:_e.id,title:_e.title,kind:"system",icon:ra({tabId:_e.id,kind:"system",connections:C})}))];let Le;return e[31]!==fe||e[32]!==he||e[33]!==s?(Le=_e=>{const Re=Im({clickedId:_e,activeTab:fe,mainOpen:he});s({to:".",search:Je=>({...Je,main:Re}),replace:!0})},e[31]=fe,e[32]=he,e[33]=s,e[34]=Le):Le=e[34],{activeTab:fe,mainOpen:he,setActiveTab:Le,systemTabs:ve,layoutTabs:x,expandedTools:S,automationTabParsed:ye,tabs:le}}function I4(t){return{id:t.id}}function O4(t){return{id:t.id}}function M4(t){return!!_h(t._meta)}function iu(t){const{managerAgentId:e,managerName:s,kind:i,id:r,instructions:o}=t,a=` to improve the instructions of ${i} "${r}". Here are its current instructions.
|
|
8
|
-
<current_instructions>${o}</current_instructions>`;return{type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Use "},{type:"mention",attrs:{id:e,name:s,char:"@",metadata:{agentId:e,title:s}}},{type:"text",text:a}]}]}}function B4(t){const e=U.c(9),s=Ri();let i;e[0]!==t?(i=Et.user(t),e[0]=t,e[1]=i):i=e[1];let r;e[2]!==s||e[3]!==t?(r=async()=>{const{user:l}=await s.call("USER_GET",{id:t});return l},e[2]=s,e[3]=t,e[4]=r):r=e[4];const o=!!t;let a;return e[5]!==i||e[6]!==r||e[7]!==o?(a={queryKey:i,queryFn:r,staleTime:3e5,retry:1,enabled:o},e[5]=i,e[6]=r,e[7]=o,e[8]=a):a=e[8],si(a)}function nu(t){const e=U.c(36),{id:s,size:i,showEmail:r,avatarOnly:o,className:a}=t,l=i===void 0?"xs":i,c=r===void 0?!1:r,d=o===void 0?!1:o,{data:h,isLoading:u,isError:f}=B4(s);if(u){let y;e[0]!==a?(y=ce("flex items-center gap-2",a),e[0]=a,e[1]=y):y=e[1];let _;e[2]!==l?(_=n.jsx(ia.Skeleton,{shape:"circle",size:l}),e[2]=l,e[3]=_):_=e[3];let x;e[4]!==d||e[5]!==c?(x=!d&&n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("div",{className:"h-3 w-24 bg-muted animate-pulse rounded"}),c&&n.jsx("div",{className:"h-2 w-32 bg-muted animate-pulse rounded"})]}),e[4]=d,e[5]=c,e[6]=x):x=e[6];let b;return e[7]!==y||e[8]!==_||e[9]!==x?(b=n.jsxs("div",{className:y,children:[_,x]}),e[7]=y,e[8]=_,e[9]=x,e[10]=b):b=e[10],b}if(f||!h){let y;e[11]!==a?(y=ce("flex items-center gap-2",a),e[11]=a,e[12]=y):y=e[12];let _;e[13]!==l?(_=n.jsx(ia,{shape:"circle",size:l,fallback:"?",muted:!0}),e[13]=l,e[14]=_):_=e[14];let x;e[15]!==d?(x=!d&&n.jsx("div",{className:"flex flex-col",children:n.jsx("div",{className:"text-sm text-muted-foreground",children:"Unknown User"})}),e[15]=d,e[16]=x):x=e[16];let b;return e[17]!==y||e[18]!==_||e[19]!==x?(b=n.jsxs("div",{className:y,children:[_,x]}),e[17]=y,e[18]=_,e[19]=x,e[20]=b):b=e[20],b}let m;e[21]!==a?(m=ce("flex items-center gap-2",a),e[21]=a,e[22]=m):m=e[22];const p=h.image??void 0;let g;e[23]!==l||e[24]!==p||e[25]!==h.name?(g=n.jsx(ia,{shape:"circle",size:l,url:p,fallback:h.name}),e[23]=l,e[24]=p,e[25]=h.name,e[26]=g):g=e[26];let L;e[27]!==d||e[28]!==c||e[29]!==h.email||e[30]!==h.name?(L=!d&&n.jsxs("div",{className:"flex flex-col",children:[n.jsx("div",{className:"text-sm font-medium",children:h.name}),c&&n.jsx("div",{className:"text-xs text-muted-foreground",children:h.email})]}),e[27]=d,e[28]=c,e[29]=h.email,e[30]=h.name,e[31]=L):L=e[31];let v;return e[32]!==m||e[33]!==g||e[34]!==L?(v=n.jsxs("div",{className:m,children:[g,L]}),e[32]=m,e[33]=g,e[34]=L,e[35]=v):v=e[35],v}function $4(t){const e=U.c(86),{value:s,onChange:i,onColorChange:r,name:o,size:a,className:l,avatarClassName:c,showHoverOverlay:d,disabled:h}=t,u=a===void 0?"lg":a,f=d===void 0?!0:d,m=h===void 0?!1:h,[p,g]=R.useState(!1),[L,v]=R.useState("icons"),[y,_]=R.useState(""),[x,b]=R.useState("blue");let S;e[0]!==s?(S=To(s),e[0]=s,e[1]=S):S=e[1];const w=S,j=w.type==="icon"||w.type==="url"&&w.color?w.color:x;let N;e[2]!==i||e[3]!==j?(N=be=>{i(sa(be,j))},e[2]=i,e[3]=j,e[4]=N):N=e[4];const T=N;let A;e[5]!==i||e[6]!==r||e[7]!==w.name||e[8]!==w.type||e[9]!==w.url?(A=be=>{b(be),r?.(be),w.type==="icon"?i(sa(w.name,be)):w.type==="url"&&i(a9(w.url,be))},e[5]=i,e[6]=r,e[7]=w.name,e[8]=w.type,e[9]=w.url,e[10]=A):A=e[10];const k=A;let C;e[11]!==i||e[12]!==j?(C=be=>{i(a9(be,j)),g(!1)},e[11]=i,e[12]=j,e[13]=C):C=e[13];const I=C;let E;e[14]!==i||e[15]!==j?(E=()=>{const be=Fl(),Ne=be[Math.floor(Math.random()*be.length)];i(sa(Ne,j))},e[14]=i,e[15]=j,e[16]=E):E=e[16];const O=E;let P,D,M,z,F,$,V,J,Z;if(e[17]!==l||e[18]!==m||e[19]!==p||e[20]!==u){const be={xs:"rounded-md",sm:"rounded-lg","sm+":"rounded-xl",md:"rounded-xl",lg:"rounded-2xl",xl:"rounded-2xl"};D=ms,V=m?!1:p,J=g,P=ps,$=!0,Z="button",M="icon-picker-trigger",z=m,F=ce("relative group overflow-hidden",m?"cursor-default opacity-50":"cursor-pointer",be[u],l),e[17]=l,e[18]=m,e[19]=p,e[20]=u,e[21]=P,e[22]=D,e[23]=M,e[24]=z,e[25]=F,e[26]=$,e[27]=V,e[28]=J,e[29]=Z}else P=e[21],D=e[22],M=e[23],z=e[24],F=e[25],$=e[26],V=e[27],J=e[28],Z=e[29];let G;e[30]!==c||e[31]!==o||e[32]!==u||e[33]!==s?(G=n.jsx(l9,{icon:s,name:o,size:u,className:c}),e[30]=c,e[31]=o,e[32]=u,e[33]=s,e[34]=G):G=e[34];let q;e[35]!==m||e[36]!==f?(q=f&&!m&&n.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity",children:n.jsx(Ed,{size:16,className:"text-white"})}),e[35]=m,e[36]=f,e[37]=q):q=e[37];let H;e[38]!==M||e[39]!==z||e[40]!==F||e[41]!==G||e[42]!==q||e[43]!==Z?(H=n.jsxs("button",{type:Z,"data-testid":M,disabled:z,className:F,children:[G,q]}),e[38]=M,e[39]=z,e[40]=F,e[41]=G,e[42]=q,e[43]=Z,e[44]=H):H=e[44];let K;e[45]!==P||e[46]!==$||e[47]!==H?(K=n.jsx(P,{asChild:$,children:H}),e[45]=P,e[46]=$,e[47]=H,e[48]=K):K=e[48];let B;e[49]!==o||e[50]!==s?(B=n.jsx("div",{className:"flex items-center justify-center py-4",children:n.jsx(l9,{icon:s,name:o,size:"xl"})}),e[49]=o,e[50]=s,e[51]=B):B=e[51];let X;e[52]===Symbol.for("react.memo_cache_sentinel")?(X=()=>v("icons"),e[52]=X):X=e[52];const W=L==="icons"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let Y;e[53]!==W?(Y=ce("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",W),e[53]=W,e[54]=Y):Y=e[54];let Q;e[55]!==Y?(Q=n.jsx("button",{type:"button",onClick:X,className:Y,children:"Icons"}),e[55]=Y,e[56]=Q):Q=e[56];let ie;e[57]===Symbol.for("react.memo_cache_sentinel")?(ie=()=>v("upload"),e[57]=ie):ie=e[57];const oe=L==="upload"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let ue;e[58]!==oe?(ue=ce("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",oe),e[58]=oe,e[59]=ue):ue=e[59];let ee;e[60]!==ue?(ee=n.jsx("button",{type:"button",onClick:ie,className:ue,children:"Upload"}),e[60]=ue,e[61]=ee):ee=e[61];let te;e[62]===Symbol.for("react.memo_cache_sentinel")?(te=n.jsx("div",{className:"flex-1"}),e[62]=te):te=e[62];let fe;e[63]!==Q||e[64]!==ee?(fe=n.jsxs("div",{className:"flex items-center border-b border-border px-3",children:[Q,ee,te]}),e[63]=Q,e[64]=ee,e[65]=fe):fe=e[65];let he;e[66]!==k||e[67]!==O||e[68]!==T||e[69]!==I||e[70]!==w.name||e[71]!==w.type||e[72]!==y||e[73]!==j||e[74]!==L?(he=L==="icons"?n.jsx(U4,{search:y,onSearchChange:_,selectedColor:j,onColorChange:k,onSelectIcon:T,onRandom:O,currentIconName:w.type==="icon"?w.name:null}):n.jsx(K4,{onUpload:I}),e[66]=k,e[67]=O,e[68]=T,e[69]=I,e[70]=w.name,e[71]=w.type,e[72]=y,e[73]=j,e[74]=L,e[75]=he):he=e[75];let ye;e[76]!==B||e[77]!==fe||e[78]!==he?(ye=n.jsx(gs,{align:"start",className:"w-80 p-0",onOpenAutoFocus:z4,children:n.jsxs("div",{className:"flex flex-col",children:[B,fe,he]})}),e[76]=B,e[77]=fe,e[78]=he,e[79]=ye):ye=e[79];let ve;return e[80]!==D||e[81]!==V||e[82]!==J||e[83]!==K||e[84]!==ye?(ve=n.jsxs(D,{open:V,onOpenChange:J,children:[K,ye]}),e[80]=D,e[81]=V,e[82]=J,e[83]=K,e[84]=ye,e[85]=ve):ve=e[85],ve}function z4(t){return t.preventDefault()}function F4(t){const e=U.c(27),{selectedColor:s,onColorChange:i}=t,[r,o]=R.useState(!1);let a,l,c,d,h,u,f;if(e[0]!==r||e[1]!==s){const y=Pd(s);l=ms,u=r,f=o,a=ps,h=!0,c="button",d=ce("h-6 w-6 rounded-full shrink-0 ring-2 ring-offset-2 ring-offset-background transition-all cursor-pointer hover:scale-110",y.dot,"ring-foreground/20"),e[0]=r,e[1]=s,e[2]=a,e[3]=l,e[4]=c,e[5]=d,e[6]=h,e[7]=u,e[8]=f}else a=e[2],l=e[3],c=e[4],d=e[5],h=e[6],u=e[7],f=e[8];let m;e[9]!==c||e[10]!==d?(m=n.jsx("button",{type:c,className:d,title:"Change color"}),e[9]=c,e[10]=d,e[11]=m):m=e[11];let p;e[12]!==a||e[13]!==h||e[14]!==m?(p=n.jsx(a,{asChild:h,children:m}),e[12]=a,e[13]=h,e[14]=m,e[15]=p):p=e[15];let g;e[16]!==i||e[17]!==s?(g=L2.map(y=>n.jsx("button",{type:"button",onClick:()=>{i(y.name),o(!1)},className:ce("h-5 w-5 rounded-full transition-all shrink-0 cursor-pointer",y.dot,s===y.name?"ring-2 ring-offset-1 ring-offset-background ring-foreground/30 scale-110":"hover:scale-110"),title:y.name},y.name)),e[16]=i,e[17]=s,e[18]=g):g=e[18];let L;e[19]!==g?(L=n.jsx(gs,{align:"start",side:"right",sideOffset:8,className:"w-auto p-2",onOpenAutoFocus:H4,children:n.jsx("div",{className:"grid grid-cols-4 gap-1",children:g})}),e[19]=g,e[20]=L):L=e[20];let v;return e[21]!==l||e[22]!==u||e[23]!==f||e[24]!==p||e[25]!==L?(v=n.jsxs(l,{open:u,onOpenChange:f,children:[p,L]}),e[21]=l,e[22]=u,e[23]=f,e[24]=p,e[25]=L,e[26]=v):v=e[26],v}function H4(t){return t.preventDefault()}function U4(t){const e=U.c(44),{search:s,onSearchChange:i,selectedColor:r,onColorChange:o,onSelectIcon:a,onRandom:l,currentIconName:c}=t;let d,h,u,f,m,p,g;if(e[0]!==c||e[1]!==o||e[2]!==l||e[3]!==i||e[4]!==a||e[5]!==s||e[6]!==r){const x=Fl(),b=Pd(r);h=s.trim()?x.filter(k=>{const C=Ba(k),I=s.toLowerCase();return C.includes(I)||k.toLowerCase().includes(I)}):x,p="flex flex-col";let S;e[14]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(Xn,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[14]=S):S=e[14];let w;e[15]!==i?(w=k=>i(k.target.value),e[15]=i,e[16]=w):w=e[16];let j;e[17]!==s||e[18]!==w?(j=n.jsxs("div",{className:"relative flex-1",children:[S,n.jsx(Ke,{value:s,onChange:w,placeholder:"Filter...",className:"h-8 text-xs pl-7"})]}),e[17]=s,e[18]=w,e[19]=j):j=e[19];let N;e[20]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx(_2,{size:14,className:"text-muted-foreground"}),e[20]=N):N=e[20];let T;e[21]!==l?(T=n.jsx("button",{type:"button",onClick:l,className:"h-8 w-8 flex items-center justify-center rounded-md border border-border hover:bg-accent transition-colors shrink-0",title:"Random icon",children:N}),e[21]=l,e[22]=T):T=e[22];let A;e[23]!==o||e[24]!==r?(A=n.jsx(F4,{selectedColor:r,onColorChange:o}),e[23]=o,e[24]=r,e[25]=A):A=e[25],e[26]!==T||e[27]!==A||e[28]!==j?(g=n.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[j,T,A]}),e[26]=T,e[27]=A,e[28]=j,e[29]=g):g=e[29],d=ni,m="h-56",u="grid grid-cols-9 gap-0.5 px-2 pb-2",f=h.map(k=>{const C=Ai(k);return C?n.jsx("button",{type:"button",onClick:()=>a(k),className:ce("h-8 w-8 flex items-center justify-center rounded-md transition-colors cursor-pointer",c===k?ce(b.bg,b.text):ce(b.text,"hover:bg-accent")),title:k,children:n.jsx(C,{size:18})},k):null}),e[0]=c,e[1]=o,e[2]=l,e[3]=i,e[4]=a,e[5]=s,e[6]=r,e[7]=d,e[8]=h,e[9]=u,e[10]=f,e[11]=m,e[12]=p,e[13]=g}else d=e[7],h=e[8],u=e[9],f=e[10],m=e[11],p=e[12],g=e[13];let L;e[30]!==u||e[31]!==f?(L=n.jsx("div",{className:u,children:f}),e[30]=u,e[31]=f,e[32]=L):L=e[32];let v;e[33]!==h.length?(v=h.length===0&&n.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No icons found"}),e[33]=h.length,e[34]=v):v=e[34];let y;e[35]!==d||e[36]!==m||e[37]!==L||e[38]!==v?(y=n.jsxs(d,{className:m,children:[L,v]}),e[35]=d,e[36]=m,e[37]=L,e[38]=v,e[39]=y):y=e[39];let _;return e[40]!==p||e[41]!==g||e[42]!==y?(_=n.jsxs("div",{className:p,children:[g,y]}),e[40]=p,e[41]=g,e[42]=y,e[43]=_):_=e[43],_}function K4(t){const e=U.c(27),{onUpload:s}=t,i=R.useRef(null);let r;e[0]!==s?(r=S=>{const w=S.target.files?.[0];if(!w)return;if(w.size>2097152){me.error("Image must be smaller than 2MB"),S.target.value="";return}const j=new FileReader;j.onerror=()=>{me.error("Failed to read image file"),i.current&&(i.current.value="")},j.onloadend=()=>{j.readyState===FileReader.DONE&&j.result&&s(j.result),i.current&&(i.current.value="")},j.readAsDataURL(w)},e[0]=s,e[1]=r):r=e[1];const o=r,[a,l]=R.useState("");let c;e[2]!==s||e[3]!==a?(c=()=>{const S=a.trim();S&&(s(S),l(""))},e[2]=s,e[3]=a,e[4]=c):c=e[4];const d=c;let h;e[5]!==o?(h=n.jsx("input",{type:"file",ref:i,className:"hidden",accept:"image/*",onChange:o}),e[5]=o,e[6]=h):h=e[6];let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=()=>i.current?.click(),e[7]=u):u=e[7];let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsxs("button",{type:"button",onClick:u,className:"h-24 rounded-lg border-2 border-dashed border-border hover:border-foreground/50 hover:bg-accent/50 transition-colors flex flex-col items-center justify-center gap-2 text-muted-foreground hover:text-foreground",children:[n.jsx(ar,{size:20}),n.jsx("span",{className:"text-xs",children:"Click to upload an image (max 2MB)"})]}),e[8]=f):f=e[8];let m;e[9]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:"or"}),n.jsx("div",{className:"flex-1 h-px bg-border"})]}),e[9]=m):m=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=S=>l(S.target.value),e[10]=p):p=e[10];let g;e[11]!==d?(g=S=>{S.key==="Enter"&&(S.preventDefault(),d())},e[11]=d,e[12]=g):g=e[12];let L;e[13]!==a||e[14]!==g?(L=n.jsx(Ke,{value:a,onChange:p,placeholder:"Paste image URL...",className:"h-8 text-xs flex-1",onKeyDown:g}),e[13]=a,e[14]=g,e[15]=L):L=e[15];let v;e[16]!==a?(v=a.trim(),e[16]=a,e[17]=v):v=e[17];const y=!v;let _;e[18]!==d||e[19]!==y?(_=n.jsx(re,{variant:"outline",size:"sm",className:"h-8 px-3 text-xs shrink-0",onClick:d,disabled:y,children:"Apply"}),e[18]=d,e[19]=y,e[20]=_):_=e[20];let x;e[21]!==_||e[22]!==L?(x=n.jsxs("div",{className:"flex items-center gap-1.5",children:[L,_]}),e[21]=_,e[22]=L,e[23]=x):x=e[23];let b;return e[24]!==x||e[25]!==h?(b=n.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[h,f,m,x]}),e[24]=x,e[25]=h,e[26]=b):b=e[26],b}function W4(t){const e=U.c(5),{value:s}=t;let i;if(e[0]!==s){i=Symbol.for("react.early_return_sentinel");e:{const o=To(s);if(o.type==="icon"){const a=Ai(o.name);if(a){let l;e[2]!==a?(l=n.jsx(a,{size:16,className:"text-muted-foreground"}),e[2]=a,e[3]=l):l=e[3],i=l;break e}}}e[0]=s,e[1]=i}else i=e[1];if(i!==Symbol.for("react.early_return_sentinel"))return i;let r;return e[4]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(f3,{size:16,className:"text-muted-foreground"}),e[4]=r):r=e[4],r}function V4(t){const e=U.c(66),{value:s,onChange:i,className:r,disabled:o}=t,[a,l]=R.useState(!1),[c,d]=R.useState("");let h;e[0]!==s?(h=To(s),e[0]=s,e[1]=h):h=e[1];const u=h,f=u.type==="icon"?u.name:null;let m,p,g,L,v,y,_,x,b,S,w,j,N,T,A;if(e[2]!==r||e[3]!==f||e[4]!==o||e[5]!==i||e[6]!==a||e[7]!==c||e[8]!==s){const D=Fl();L=c.trim()?D.filter(Z=>{const G=c.toLowerCase();return Ba(Z).includes(G)||Z.toLowerCase().includes(G)}):D,g=ms,v=o?!1:a,y=l;const M=o?"cursor-default opacity-50":"cursor-pointer hover:bg-accent";let z;e[24]!==r||e[25]!==M?(z=ce("size-7 shrink-0 rounded-md transition-colors flex items-center justify-center",M,r),e[24]=r,e[25]=M,e[26]=z):z=e[26];let F;e[27]!==s?(F=n.jsx(W4,{value:s}),e[27]=s,e[28]=F):F=e[28],e[29]!==o||e[30]!==z||e[31]!==F?(_=n.jsx(ps,{asChild:!0,children:n.jsx("button",{type:"button",disabled:o,className:z,children:F})}),e[29]=o,e[30]=z,e[31]=F,e[32]=_):_=e[32],p=gs,N="start",T="w-64 p-0",A=G4,w="flex flex-col";let $;e[33]===Symbol.for("react.memo_cache_sentinel")?($=n.jsx(Xn,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[33]=$):$=e[33];let V;e[34]===Symbol.for("react.memo_cache_sentinel")?(V=Z=>d(Z.target.value),e[34]=V):V=e[34],e[35]!==c?(j=n.jsx("div",{className:"px-2 py-2",children:n.jsxs("div",{className:"relative",children:[$,n.jsx(Ke,{value:c,onChange:V,placeholder:"Filter...",className:"h-7 text-xs pl-7"})]})}),e[35]=c,e[36]=j):j=e[36],m=ni,S="h-48",x="grid grid-cols-8 gap-0.5 px-2 pb-2";let J;e[37]!==f||e[38]!==i?(J=Z=>{const G=Ai(Z);return G?n.jsx("button",{type:"button",onClick:()=>{i(`icon://${Z}`),l(!1)},className:ce("h-7 w-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",f===Z?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),title:Ba(Z),children:n.jsx(G,{size:16})},Z):null},e[37]=f,e[38]=i,e[39]=J):J=e[39],b=L.map(J),e[2]=r,e[3]=f,e[4]=o,e[5]=i,e[6]=a,e[7]=c,e[8]=s,e[9]=m,e[10]=p,e[11]=g,e[12]=L,e[13]=v,e[14]=y,e[15]=_,e[16]=x,e[17]=b,e[18]=S,e[19]=w,e[20]=j,e[21]=N,e[22]=T,e[23]=A}else m=e[9],p=e[10],g=e[11],L=e[12],v=e[13],y=e[14],_=e[15],x=e[16],b=e[17],S=e[18],w=e[19],j=e[20],N=e[21],T=e[22],A=e[23];let k;e[40]!==x||e[41]!==b?(k=n.jsx("div",{className:x,children:b}),e[40]=x,e[41]=b,e[42]=k):k=e[42];let C;e[43]!==L.length?(C=L.length===0&&n.jsx("div",{className:"flex items-center justify-center py-6 text-xs text-muted-foreground",children:"No icons found"}),e[43]=L.length,e[44]=C):C=e[44];let I;e[45]!==m||e[46]!==k||e[47]!==C||e[48]!==S?(I=n.jsxs(m,{className:S,children:[k,C]}),e[45]=m,e[46]=k,e[47]=C,e[48]=S,e[49]=I):I=e[49];let E;e[50]!==I||e[51]!==w||e[52]!==j?(E=n.jsxs("div",{className:w,children:[j,I]}),e[50]=I,e[51]=w,e[52]=j,e[53]=E):E=e[53];let O;e[54]!==p||e[55]!==E||e[56]!==N||e[57]!==T||e[58]!==A?(O=n.jsx(p,{align:N,className:T,onOpenAutoFocus:A,children:E}),e[54]=p,e[55]=E,e[56]=N,e[57]=T,e[58]=A,e[59]=O):O=e[59];let P;return e[60]!==g||e[61]!==v||e[62]!==y||e[63]!==_||e[64]!==O?(P=n.jsxs(g,{open:v,onOpenChange:y,children:[_,O]}),e[60]=g,e[61]=v,e[62]=y,e[63]=_,e[64]=O,e[65]=P):P=e[65],P}function G4(t){return t.preventDefault()}const q4=25*1024*1024,oa="home",aa="knowledge";function N9(t){return t==null?"":t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(0)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function di(t){return t.split("/").pop()??t}function Y4(t){const e=U.c(52),{form:s}=t,{upload:i}=m3(oa),r=p3(),o=R.useRef(null),[a,l]=R.useState(!1),[c,d]=R.useState(""),[h,u]=R.useState(!1);let f;e[0]!==a?(f={enabled:a},e[0]=a,e[1]=f):f=e[1];const{data:m}=g3(60,f),p=m===void 0?[]:m;let g;e[2]!==a?(g={enabled:a},e[2]=a,e[3]=g):g=e[3];const{data:L}=_3(g),v=L===void 0?[]:L;let y;e[4]!==s?(y=()=>s.getValues("metadata.knowledge")??[],e[4]=s,e[5]=y):y=e[5];const[_,x]=R.useState(y);let b;e[6]!==s?(b=ee=>{x(ee),s.setValue("metadata.knowledge",ee,{shouldDirty:!0})},e[6]=s,e[7]=b):b=e[7];const S=b;let w;e[8]!==r||e[9]!==_||e[10]!==S||e[11]!==i?(w=async ee=>{if(!ee||ee.length===0)return;const te=Array.from(ee).filter(e5);if(te.length!==0){try{await i.mutateAsync({dir:aa,files:te})}catch(fe){const he=fe;me.error(he instanceof Error?he.message:"Failed to upload file.");return}S([..._,...te.map(fe=>({id:crypto.randomUUID(),name:fe.name,volume:oa,path:`${aa}/${fe.name}`,url:r(oa,`${aa}/${fe.name}`),contentType:fe.type||null,size:fe.size,addedAt:new Date().toISOString()}))])}},e[8]=r,e[9]=_,e[10]=S,e[11]=i,e[12]=w):w=e[12];const j=w;let N;e[13]!==r||e[14]!==_||e[15]!==S?(N=ee=>{_.some(te=>te.volume===ee.volume&&te.path===ee.path)||(S([..._,{id:crypto.randomUUID(),name:di(ee.path),volume:ee.volume,path:ee.path,url:r(ee.volume,ee.path),contentType:null,size:ee.size??null,addedAt:new Date().toISOString()}]),l(!1))},e[13]=r,e[14]=_,e[15]=S,e[16]=N):N=e[16];const T=N;let A;e[17]!==r||e[18]!==_||e[19]!==S?(A=ee=>{_.some(te=>te.volume===ee.volume&&te.path===ee.path)||(S([..._,{id:crypto.randomUUID(),name:di(ee.path),kind:"skill",volume:ee.volume,path:ee.path,url:r(ee.volume,ee.path),contentType:null,size:null,addedAt:new Date().toISOString()}]),l(!1))},e[17]=r,e[18]=_,e[19]=S,e[20]=A):A=e[20];const k=A;let C;e[21]!==_||e[22]!==S?(C=ee=>{S(_.filter(te=>te.id!==ee))},e[21]=_,e[22]=S,e[23]=C):C=e[23];const I=C;let E;e[24]===Symbol.for("react.memo_cache_sentinel")?(E=ee=>{l(ee),ee&&d("")},e[24]=E):E=e[24];const O=E;let P;e[25]!==_?(P=new Set(_.map(Q4)),e[25]=_,e[26]=P):P=e[26];const D=P,M=c.toLowerCase();let z;e[27]!==D?(z=ee=>!D.has(`${ee.volume}/${ee.path}`),e[27]=D,e[28]=z):z=e[28];const F=p.filter(Z4).filter(z).filter(ee=>di(ee.path).toLowerCase().includes(M)).slice(0,5);let $;e[29]!==D?($=ee=>!D.has(`${ee.volume}/${ee.path}`),e[29]=D,e[30]=$):$=e[30];const V=v.filter($).filter(ee=>di(ee.path).toLowerCase().includes(M)).slice(0,5),J=ee=>n.jsxs(is,{open:a,onOpenChange:O,children:[n.jsx(ns,{asChild:!0,children:ee}),n.jsxs(rs,{align:"end",className:"w-56",children:[n.jsxs(We,{onSelect:()=>{o.current?.click()},children:[n.jsx(v2,{size:16}),"Upload file"]}),n.jsxs(Ha,{children:[n.jsxs(Ua,{className:"gap-2 [&_svg:not([class*='text-'])]:text-muted-foreground",children:[n.jsx(en,{size:16}),"Select file or folder"]}),n.jsxs(Ka,{className:"w-72 p-0",children:[n.jsxs("div",{className:"flex items-center gap-2 border-b px-3",children:[n.jsx(Xn,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("input",{value:c,onChange:te=>d(te.target.value),onKeyDown:X4,placeholder:"Search files...",className:"h-10 w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),n.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:F.length===0?n.jsx("p",{className:"px-2 py-3 text-center text-sm text-muted-foreground",children:"No files found."}):F.map(te=>n.jsxs(We,{onSelect:()=>T(te),children:[n.jsx(Qi,{filename:di(te.path),className:"h-5 w-4 shrink-0"}),n.jsx("span",{className:"flex-1 truncate",children:di(te.path)}),te.size!=null&&n.jsx("span",{className:"text-xs text-muted-foreground",children:N9(te.size)})]},`${te.volume}/${te.path}`))})]})]}),n.jsxs(Ha,{children:[n.jsxs(Ua,{className:"gap-2 [&_svg:not([class*='text-'])]:text-muted-foreground",children:[n.jsx(gi,{size:16}),"Select skill"]}),n.jsxs(Ka,{className:"w-72 p-0",children:[n.jsxs("div",{className:"flex items-center gap-2 border-b px-3",children:[n.jsx(Xn,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("input",{value:c,onChange:te=>d(te.target.value),onKeyDown:J4,placeholder:"Search skills...",className:"h-10 w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),n.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:V.length===0?n.jsx("p",{className:"px-2 py-3 text-center text-sm text-muted-foreground",children:"No skills found."}):V.map(te=>n.jsxs(We,{onSelect:()=>k(te),children:[n.jsx(gi,{size:16,className:"shrink-0"}),n.jsx("span",{className:"flex-1 truncate",children:di(te.path)})]},`${te.volume}/${te.path}`))})]})]})]})]}),Z="flex flex-col gap-3";let G;e[31]===Symbol.for("react.memo_cache_sentinel")?(G=n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Files and skills"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Attach files and skills the agent can always reference."})]}),e[31]=G):G=e[31];const q=_.length>0&&J(n.jsxs(re,{variant:"outline",size:"sm",disabled:i.isPending,children:[i.isPending?n.jsx(zl,{size:"xs"}):n.jsx(It,{size:14}),"Add"]}));let H;e[32]!==q?(H=n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[G,q]}),e[32]=q,e[33]=H):H=e[33];let K;e[34]!==j?(K=n.jsx("input",{ref:o,type:"file",multiple:!0,className:"hidden",onChange:ee=>{j(ee.target.files),ee.target.value=""}}),e[34]=j,e[35]=K):K=e[35];let B,X;e[36]===Symbol.for("react.memo_cache_sentinel")?(B=ee=>{ee.preventDefault(),u(!0)},X=()=>u(!1),e[36]=B,e[37]=X):(B=e[36],X=e[37]);let W;e[38]!==j?(W=ee=>{ee.preventDefault(),u(!1),j(ee.dataTransfer.files)},e[38]=j,e[39]=W):W=e[39];const Y=h&&"outline outline-2 outline-dashed outline-primary";let Q;e[40]!==Y?(Q=ce("flex flex-col gap-2 rounded-lg",Y),e[40]=Y,e[41]=Q):Q=e[41];const ie=_.length===0?J(n.jsxs("button",{type:"button",className:"flex items-center gap-3 px-3 py-2.5 rounded-lg border border-dashed border-border hover:bg-accent/50 transition-colors w-full text-left cursor-pointer",children:[n.jsx("div",{className:"flex items-center justify-center size-8 rounded-md text-muted-foreground/75 border border-dashed border-border shrink-0",children:n.jsx(It,{size:16})}),n.jsx("span",{className:"text-sm text-muted-foreground flex-1",children:"No files or skills yet. Add one or drag and drop here."})]})):_.map(ee=>n.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 rounded-xl border bg-card",children:[ee.kind==="skill"?n.jsx("div",{className:"flex items-center justify-center h-8 w-6.5 shrink-0 rounded-md bg-muted text-muted-foreground",children:n.jsx(gi,{size:16})}):n.jsx(Qi,{filename:ee.name,className:"h-8 w-6.5 shrink-0"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:"text-sm font-medium truncate",children:ee.name}),n.jsx("p",{className:"text-xs text-muted-foreground",children:ee.kind==="skill"?"Skill":ee.size!=null?N9(ee.size):"File"})]}),n.jsx(re,{variant:"ghost",size:"icon",onClick:()=>I(ee.id),"aria-label":`Remove ${ee.name}`,children:n.jsx(os,{size:16})})]},ee.id));let oe;e[42]!==B||e[43]!==X||e[44]!==W||e[45]!==Q||e[46]!==ie?(oe=n.jsx("div",{onDragOver:B,onDragLeave:X,onDrop:W,className:Q,children:ie}),e[42]=B,e[43]=X,e[44]=W,e[45]=Q,e[46]=ie,e[47]=oe):oe=e[47];let ue;return e[48]!==H||e[49]!==K||e[50]!==oe?(ue=n.jsxs("section",{className:Z,children:[H,K,oe]}),e[48]=H,e[49]=K,e[50]=oe,e[51]=ue):ue=e[51],ue}function J4(t){return t.stopPropagation()}function X4(t){return t.stopPropagation()}function Z4(t){return t.kind!=="dir"}function Q4(t){return`${t.volume}/${t.path}`}function e5(t){return t.size<=q4}function t5(t){return t==null?"all":t.length===0?"self":"selected"}function s5(t){const e=U.c(65),{form:s,currentAgentId:i}=t,{org:r}=Ge(),o=Ul(),[a,l]=R.useState(!1);let c;e[0]!==s?(c=s.getValues("metadata.subAgents")??null,e[0]=s,e[1]=c):c=e[1];const d=c;let h;e[2]!==d?(h=()=>t5(d),e[2]=d,e[3]=h):h=e[3];const[u,f]=R.useState(h);let m;e[4]!==d?(m=d??[],e[4]=d,e[5]=m):m=e[5];const[p,g]=R.useState(m);let L,v,y,_,x,b;if(e[6]!==o||e[7]!==i||e[8]!==s||e[9]!==u||e[10]!==r||e[11]!==p){let N;e[18]!==i||e[19]!==r?(N=q=>q.id!==i&&q.id!==r.id&&q.status==="active",e[18]=i,e[19]=r,e[20]=N):N=e[20],L=o.filter(N);let T;e[21]!==p?(T=q=>p.includes(q.id),e[21]=p,e[22]=T):T=e[22];const A=L.filter(T);let k;e[23]!==s?(k=(q,H)=>s.setValue("metadata.subAgents",q==="all"?null:q==="self"?[]:H,{shouldDirty:!0}),e[23]=s,e[24]=k):k=e[24];const C=k;let I;e[25]!==C||e[26]!==p?(I=q=>{f(q),C(q,p)},e[25]=C,e[26]=p,e[27]=I):I=e[27];const E=I;let O;e[28]!==C||e[29]!==p?(O=q=>{const H=p.includes(q)?p.filter(K=>K!==q):[...p,q];g(H),C("selected",H)},e[28]=C,e[29]=p,e[30]=O):O=e[30],v=O,x="flex flex-col gap-3";let P;e[31]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Sub-agents"}),e[31]=P):P=e[31];let D;e[32]!==u?(D=u==="all"&&n.jsx("p",{className:"text-sm text-muted-foreground",children:"Can delegate to any agent in the organization."}),e[32]=u,e[33]=D):D=e[33];let M;e[34]!==u?(M=u==="self"&&n.jsx("p",{className:"text-sm text-muted-foreground",children:"Can only delegate to a fresh copy of itself, no other agents."}),e[34]=u,e[35]=M):M=e[35];let z;e[36]!==D||e[37]!==M?(z=n.jsxs("div",{className:"flex flex-col gap-1",children:[P,D,M]}),e[36]=D,e[37]=M,e[38]=z):z=e[38];const F=u==="selected"&&A.length>0&&n.jsxs(re,{variant:"outline",size:"sm",onClick:()=>l(!0),children:[n.jsx(It,{size:14}),"Add sub-agent"]});let $;e[39]!==E?($=q=>E(q),e[39]=E,e[40]=$):$=e[40];let V;e[41]===Symbol.for("react.memo_cache_sentinel")?(V=n.jsx(kt,{size:"sm",className:"w-auto",children:n.jsx(Rt,{})}),e[41]=V):V=e[41];let J;e[42]===Symbol.for("react.memo_cache_sentinel")?(J=n.jsxs(Nt,{align:"end",children:[n.jsx(ot,{value:"all",children:"Any agent"}),n.jsx(ot,{value:"selected",children:"Specific agents"}),n.jsx(ot,{value:"self",children:"Only itself"})]}),e[42]=J):J=e[42];let Z;e[43]!==u||e[44]!==$?(Z=n.jsxs(Tt,{value:u,onValueChange:$,children:[V,J]}),e[43]=u,e[44]=$,e[45]=Z):Z=e[45];let G;e[46]!==F||e[47]!==Z?(G=n.jsxs("div",{className:"flex items-center gap-2",children:[F,Z]}),e[46]=F,e[47]=Z,e[48]=G):G=e[48],e[49]!==z||e[50]!==G?(b=n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[z,G]}),e[49]=z,e[50]=G,e[51]=b):b=e[51],y="flex flex-col gap-2",_=u==="selected"&&(A.length>0?A.map(q=>n.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 rounded-xl border bg-background",children:[n.jsx(Es,{icon:q.icon,name:q.title,size:"sm",className:"shrink-0"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:"text-sm font-medium truncate",children:q.title}),q.description&&n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:q.description})]}),n.jsx(re,{variant:"ghost",size:"icon",onClick:()=>v(q.id),children:n.jsx(ti,{size:16})})]},q.id)):n.jsxs("button",{type:"button",onClick:()=>l(!0),className:"flex items-center gap-3 px-3 py-2.5 rounded-lg border border-dashed border-border hover:bg-accent/50 transition-colors w-full text-left cursor-pointer",children:[n.jsx("div",{className:"flex items-center justify-center size-8 rounded-md text-muted-foreground/75 border border-dashed border-border shrink-0",children:n.jsx(It,{size:16})}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"No sub-agents selected yet. Add one — until then this agent can only delegate to itself."})]})),e[6]=o,e[7]=i,e[8]=s,e[9]=u,e[10]=r,e[11]=p,e[12]=L,e[13]=v,e[14]=y,e[15]=_,e[16]=x,e[17]=b}else L=e[12],v=e[13],y=e[14],_=e[15],x=e[16],b=e[17];let S;e[52]!==y||e[53]!==_?(S=n.jsx("div",{className:y,children:_}),e[52]=y,e[53]=_,e[54]=S):S=e[54];let w;e[55]!==L||e[56]!==v||e[57]!==a||e[58]!==p?(w=n.jsx(i5,{open:a,onOpenChange:l,candidates:L,selectedIds:p,onToggle:v}),e[55]=L,e[56]=v,e[57]=a,e[58]=p,e[59]=w):w=e[59];let j;return e[60]!==x||e[61]!==b||e[62]!==S||e[63]!==w?(j=n.jsxs("section",{className:x,children:[b,S,w]}),e[60]=x,e[61]=b,e[62]=S,e[63]=w,e[64]=j):j=e[64],j}function i5(t){const e=U.c(32),{open:s,onOpenChange:i,candidates:r,selectedIds:o,onToggle:a}=t,[l,c]=R.useState("");let d,h,u,f,m,p,g,L,v;if(e[0]!==r||e[1]!==i||e[2]!==a||e[3]!==s||e[4]!==l||e[5]!==o){const b=l.toLowerCase(),S=r.filter(w=>w.title.toLowerCase().includes(b)||w.description?.toLowerCase().includes(b));h=Gt,L=s,v=i,d=qt,m="max-w-md",e[15]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(_s,{children:n.jsx(Ls,{children:"Sub-agents"})}),e[15]=p):p=e[15],e[16]!==l?(g=n.jsx(Zl,{value:l,onChange:c,placeholder:"Search agents...",className:"w-full"}),e[16]=l,e[17]=g):g=e[17],u="flex flex-col gap-1 max-h-80 overflow-y-auto",f=S.length===0?n.jsx("p",{className:"text-sm text-muted-foreground px-1 py-4 text-center",children:"No agents found."}):S.map(w=>n.jsxs("button",{type:"button",onClick:()=>a(w.id),className:"flex items-center gap-3 px-2 py-2 rounded-lg hover:bg-accent/50 transition-colors cursor-pointer w-full text-left",children:[n.jsx(cn,{checked:o.includes(w.id),className:"pointer-events-none",tabIndex:-1}),n.jsx(Es,{icon:w.icon,name:w.title,size:"sm",className:"shrink-0"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:"text-sm font-medium truncate",children:w.title}),w.description&&n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:w.description})]})]},w.id)),e[0]=r,e[1]=i,e[2]=a,e[3]=s,e[4]=l,e[5]=o,e[6]=d,e[7]=h,e[8]=u,e[9]=f,e[10]=m,e[11]=p,e[12]=g,e[13]=L,e[14]=v}else d=e[6],h=e[7],u=e[8],f=e[9],m=e[10],p=e[11],g=e[12],L=e[13],v=e[14];let y;e[18]!==u||e[19]!==f?(y=n.jsx("div",{className:u,children:f}),e[18]=u,e[19]=f,e[20]=y):y=e[20];let _;e[21]!==d||e[22]!==m||e[23]!==p||e[24]!==g||e[25]!==y?(_=n.jsxs(d,{className:m,children:[p,g,y]}),e[21]=d,e[22]=m,e[23]=p,e[24]=g,e[25]=y,e[26]=_):_=e[26];let x;return e[27]!==h||e[28]!==L||e[29]!==v||e[30]!==_?(x=n.jsx(h,{open:L,onOpenChange:v,children:_}),e[27]=h,e[28]=L,e[29]=v,e[30]=_,e[31]=x):x=e[31],x}function Rn(){const t=U.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"flex items-center justify-center h-32",children:n.jsx(Ue,{className:"animate-spin text-muted-foreground",size:24})}),t[0]=e):e=t[0],e}function br(t){return({error:e})=>e?.message?.includes("Method not found")||e?.code===-32601?n.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:n.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:t})}):n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center h-full p-6 text-center space-y-4",children:[n.jsx("div",{className:"bg-destructive/10 p-3 rounded-full",children:n.jsx(Ml,{className:"h-6 w-6 text-destructive"})}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("h3",{className:"text-lg font-medium",children:"Something went wrong"}),n.jsx("p",{className:"text-sm text-muted-foreground max-w-xs mx-auto",children:e?.message?e.message.length>200?`${e.message.slice(0,200)}...`:e.message:"An unexpected error occurred"})]})]})}function ru(t){const e=U.c(23),{item:s,isSelected:i,onToggle:r,disabled:o}=t,a=o?"cursor-not-allowed opacity-50":"cursor-pointer",l=i?"bg-accent/25":"hover:bg-muted/50";let c;e[0]!==a||e[1]!==l?(c=ce("flex items-start gap-3 p-4 rounded-lg transition-colors",a,l),e[0]=a,e[1]=l,e[2]=c):c=e[2];let d;e[3]!==s.name?(d=n.jsx("p",{className:"text-sm font-medium leading-none truncate",children:s.name}),e[3]=s.name,e[4]=d):d=e[4];let h;e[5]!==s.tags?(h=s.tags&&n.jsx("span",{className:"shrink-0",children:s.tags}),e[5]=s.tags,e[6]=h):h=e[6];let u;e[7]!==d||e[8]!==h?(u=n.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[d,h]}),e[7]=d,e[8]=h,e[9]=u):u=e[9];let f;e[10]!==s.description?(f=s.description&&n.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:s.description}),e[10]=s.description,e[11]=f):f=e[11];let m;e[12]!==u||e[13]!==f?(m=n.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[u,f]}),e[12]=u,e[13]=f,e[14]=m):m=e[14];let p;e[15]!==o||e[16]!==i||e[17]!==r?(p=n.jsx(cn,{checked:i,onCheckedChange:r,disabled:o,className:"mt-0.5"}),e[15]=o,e[16]=i,e[17]=r,e[18]=p):p=e[18];let g;return e[19]!==c||e[20]!==m||e[21]!==p?(g=n.jsxs("label",{className:c,children:[m,p]}),e[19]=c,e[20]=m,e[21]=p,e[22]=g):g=e[22],g}function jc(t){const e=U.c(13),{items:s,selections:i,onToggle:r,emptyMessage:o,disabled:a}=t;let l,c,d;if(e[0]!==a||e[1]!==o||e[2]!==s||e[3]!==r||e[4]!==i){d=Symbol.for("react.early_return_sentinel");e:{const u=s.map(n5);if(s.length===0){let f;e[8]!==o?(f=n.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:n.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:o})}),e[8]=o,e[9]=f):f=e[9],d=f;break e}l="flex-1 overflow-auto px-4 py-3 space-y-1",c=s.map(f=>n.jsx(ru,{item:f,isSelected:i===null||i?.includes(f.id),onToggle:()=>r(f.id,u),disabled:a},f.id))}e[0]=a,e[1]=o,e[2]=s,e[3]=r,e[4]=i,e[5]=l,e[6]=c,e[7]=d}else l=e[5],c=e[6],d=e[7];if(d!==Symbol.for("react.early_return_sentinel"))return d;let h;return e[10]!==l||e[11]!==c?(h=n.jsx("div",{className:l,children:c}),e[10]=l,e[11]=c,e[12]=h):h=e[12],h}function n5(t){return t.id}function r5(t){const e=U.c(18),{connectionId:s,toolSelections:i,onToggleTool:r}=t,{org:o}=Ge();let a;e[0]!==s||e[1]!==o.id||e[2]!==o.slug?(a={connectionId:s,orgId:o.id,orgSlug:o.slug},e[0]=s,e[1]=o.id,e[2]=o.slug,e[3]=a):a=e[3];const l=Dt(a);let c;e[4]!==l?(c={client:l},e[4]=l,e[5]=c):c=e[5];const{data:d}=gh(c),h=d.tools;let u,f,m;if(e[6]!==d.tools||e[7]!==r||e[8]!==i){m=Symbol.for("react.early_return_sentinel");e:{const g=h.map(a5);let L;e[12]!==i?(L=_=>i===null||i.includes(_.name),e[12]=i,e[13]=L):L=e[13];const y=d.tools.filter(L).map(o5);if(y.length===0){let _;e[14]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:n.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:"No active tools selected"})}),e[14]=_):_=e[14],m=_;break e}u="flex-1 overflow-auto px-4 py-3 space-y-1",f=y.map(_=>n.jsx(ru,{item:_,isSelected:!0,onToggle:()=>r(_.id,g)},_.id))}e[6]=d.tools,e[7]=r,e[8]=i,e[9]=u,e[10]=f,e[11]=m}else u=e[9],f=e[10],m=e[11];if(m!==Symbol.for("react.early_return_sentinel"))return m;let p;return e[15]!==u||e[16]!==f?(p=n.jsx("div",{className:u,children:f}),e[15]=u,e[16]=f,e[17]=p):p=e[17],p}function o5(t){return{id:t.name,name:t.name,description:t.description,tags:n.jsx(yh,{annotations:t.annotations,_meta:t._meta})}}function a5(t){return t.name}function l5(t){const e=U.c(13),{connectionId:s,selections:i,onToggle:r,disabled:o}=t,{org:a}=Ge();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const c=Dt(l);let d;e[4]!==c?(d={client:c},e[4]=c,e[5]=d):d=e[5];const{data:h}=gh(d);let u;e[6]!==h.tools?(u=h.tools.map(c5),e[6]=h.tools,e[7]=u):u=e[7];const f=u;let m;return e[8]!==o||e[9]!==f||e[10]!==r||e[11]!==i?(m=n.jsx(jc,{items:f,selections:i,onToggle:r,emptyMessage:"No tools available",disabled:o}),e[8]=o,e[9]=f,e[10]=r,e[11]=i,e[12]=m):m=e[12],m}function c5(t){return{id:t.name,name:t.name,description:t.description,tags:n.jsx(yh,{annotations:t.annotations,_meta:t._meta})}}function d5(t){const e=U.c(13),{connectionId:s,selections:i,onToggle:r,disabled:o}=t,{org:a}=Ge();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const c=Dt(l);let d;e[4]!==c?(d={client:c},e[4]=c,e[5]=d):d=e[5];const{data:h}=Gf(d);let u;e[6]!==h.resources?(u=h.resources.map(h5),e[6]=h.resources,e[7]=u):u=e[7];const f=u;let m;return e[8]!==o||e[9]!==f||e[10]!==r||e[11]!==i?(m=n.jsx(jc,{items:f,selections:i,onToggle:r,emptyMessage:"No resources available",disabled:o}),e[8]=o,e[9]=f,e[10]=r,e[11]=i,e[12]=m):m=e[12],m}function h5(t){return{id:t.name||t.uri,name:t.name||t.uri,description:t.description}}function u5(t){const e=U.c(13),{connectionId:s,selections:i,onToggle:r,disabled:o}=t,{org:a}=Ge();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const c=Dt(l);let d;e[4]!==c?(d={client:c},e[4]=c,e[5]=d):d=e[5];const{data:h}=y3(d);let u;e[6]!==h.prompts?(u=h.prompts.map(f5),e[6]=h.prompts,e[7]=u):u=e[7];const f=u;let m;return e[8]!==o||e[9]!==f||e[10]!==r||e[11]!==i?(m=n.jsx(jc,{items:f,selections:i,onToggle:r,emptyMessage:"No prompts available",disabled:o}),e[8]=o,e[9]=f,e[10]=r,e[11]=i,e[12]=m):m=e[12],m}function f5(t){return{id:t.name,name:t.name,description:t.description}}function m5(t){const e=U.c(61),{currentConnection:s,activeTab:i,selectedId:r,formData:o,toggleTool:a,toggleResource:l,togglePrompt:c,toggleAllTools:d,toggleAllResources:h,toggleAllPrompts:u,onTabChange:f}=t,m=o[r],p=i==="tools"?m?.tools===null:i==="resources"?m?.resources===null:i==="prompts"?m?.prompts===null:!1,g=i!=="active";let L;e[0]!==i||e[1]!==r||e[2]!==u||e[3]!==h||e[4]!==d?(L=()=>{i==="tools"?d(r):i==="resources"?h(r):i==="prompts"&&u(r)},e[0]=i,e[1]=r,e[2]=u,e[3]=h,e[4]=d,e[5]=L):L=e[5];const v=L;let y;e[6]!==s.icon||e[7]!==s.title?(y=n.jsx(Es,{icon:s.icon,name:s.title,size:"sm",className:"shrink-0"}),e[6]=s.icon,e[7]=s.title,e[8]=y):y=e[8];let _;e[9]!==s.title?(_=n.jsx("h2",{className:"text-base font-semibold truncate",children:s.title}),e[9]=s.title,e[10]=_):_=e[10];let x;e[11]!==s.description?(x=s.description&&n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.description}),e[11]=s.description,e[12]=x):x=e[12];let b;e[13]!==_||e[14]!==x?(b=n.jsxs("div",{className:"flex-1 min-w-0",children:[_,x]}),e[13]=_,e[14]=x,e[15]=b):b=e[15];let S;e[16]!==y||e[17]!==b?(S=n.jsx("div",{className:"px-6 pt-5 pb-4 shrink-0",children:n.jsxs("div",{className:"flex items-center gap-3",children:[y,b]})}),e[16]=y,e[17]=b,e[18]=S):S=e[18];let w;e[19]===Symbol.for("react.memo_cache_sentinel")?(w=[{id:"tools",label:"Tools"},{id:"active",label:"Active"},{id:"resources",label:"Resources"},{id:"prompts",label:"Prompts"}],e[19]=w):w=e[19];let j;e[20]!==f?(j=D=>f(D),e[20]=f,e[21]=j):j=e[21];let N;e[22]!==i||e[23]!==j?(N=n.jsx(wh,{tabs:w,activeTab:i,onTabChange:j}),e[22]=i,e[23]=j,e[24]=N):N=e[24];let T;e[25]!==v||e[26]!==p||e[27]!==g?(T=g&&n.jsx("button",{type:"button",onClick:v,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:p?"Deselect all":"Select all"}),e[25]=v,e[26]=p,e[27]=g,e[28]=T):T=e[28];let A;e[29]!==T||e[30]!==N?(A=n.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-t border-border shrink-0",children:[N,T]}),e[29]=T,e[30]=N,e[31]=A):A=e[31];let k;e[32]!==i||e[33]!==o||e[34]!==r||e[35]!==a?(k=i==="active"&&n.jsx(es,{fallback:br("Tools not supported by this server"),children:n.jsx(R.Suspense,{fallback:n.jsx(Rn,{}),children:n.jsx(r5,{connectionId:r,toolSelections:o[r]?o[r].tools:[],onToggleTool:(D,M)=>a(r,D,M)})})}),e[32]=i,e[33]=o,e[34]=r,e[35]=a,e[36]=k):k=e[36];let C;e[37]!==i||e[38]!==o||e[39]!==r||e[40]!==a?(C=i==="tools"&&n.jsx(es,{fallback:br("Tools not supported by this server"),children:n.jsx(R.Suspense,{fallback:n.jsx(Rn,{}),children:n.jsx(l5,{connectionId:r,selections:o[r]?o[r].tools:[],onToggle:(D,M)=>a(r,D,M)})})}),e[37]=i,e[38]=o,e[39]=r,e[40]=a,e[41]=C):C=e[41];let I;e[42]!==i||e[43]!==o||e[44]!==r||e[45]!==l?(I=i==="resources"&&n.jsx(es,{fallback:br("Resources not supported by this server"),children:n.jsx(R.Suspense,{fallback:n.jsx(Rn,{}),children:n.jsx(d5,{connectionId:r,selections:o[r]?o[r].resources:[],onToggle:(D,M)=>l(r,D,M)})})}),e[42]=i,e[43]=o,e[44]=r,e[45]=l,e[46]=I):I=e[46];let E;e[47]!==i||e[48]!==o||e[49]!==r||e[50]!==c?(E=i==="prompts"&&n.jsx(es,{fallback:br("Prompts not supported by this server"),children:n.jsx(R.Suspense,{fallback:n.jsx(Rn,{}),children:n.jsx(u5,{connectionId:r,selections:o[r]?o[r].prompts:[],onToggle:(D,M)=>c(r,D,M)})})}),e[47]=i,e[48]=o,e[49]=r,e[50]=c,e[51]=E):E=e[51];let O;e[52]!==k||e[53]!==C||e[54]!==I||e[55]!==E?(O=n.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[k,C,I,E]}),e[52]=k,e[53]=C,e[54]=I,e[55]=E,e[56]=O):O=e[56];let P;return e[57]!==A||e[58]!==O||e[59]!==S?(P=n.jsxs(n.Fragment,{children:[S,A,O]}),e[57]=A,e[58]=O,e[59]=S,e[60]=P):P=e[60],P}function p5(t){const e=U.c(11),{connectionId:s,onAuthenticate:i,children:r}=t;let o;e[0]!==s?(o={connectionId:s},e[0]=s,e[1]=o):o=e[1];const a=bh(o);if(a.supportsOAuth&&!a.isAuthenticated){let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("div",{className:"flex items-center justify-center size-12 rounded-full bg-muted",children:n.jsx(x2,{size:22,className:"text-muted-foreground"})}),e[2]=d):d=e[2];let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsxs("div",{className:"space-y-1",children:[n.jsx("p",{className:"text-sm font-medium",children:"Authorization required"}),n.jsx("p",{className:"text-xs text-muted-foreground max-w-xs",children:"This connection needs to be authorized before you can configure its tools and resources."})]}),e[3]=h):h=e[3];let u;e[4]!==s||e[5]!==i?(u=i&&n.jsx(re,{variant:"outline",size:"sm",onClick:()=>i(s),children:"Authorize"}),e[4]=s,e[5]=i,e[6]=u):u=e[6];let f;return e[7]!==u?(f=n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[d,h,u]}),e[7]=u,e[8]=f):f=e[8],f}let c;return e[9]!==r?(c=n.jsx(n.Fragment,{children:r}),e[9]=r,e[10]=c):c=e[10],c}function g5(t){const e={};for(const s of t)e[s.connection_id]={tools:s.selected_tools,resources:s.selected_resources??null,prompts:s.selected_prompts??null};return e}function T9(t){return Object.entries(t).map(([e,s])=>({connection_id:e,selected_tools:s.tools,selected_resources:s.resources,selected_prompts:s.prompts}))}function _5(t,e){return e.type==="SET_ACTIVE_TAB"?{...t,activeTab:e.payload}:t}function L5(t){const e=U.c(49),{open:s,onOpenChange:i,selectedId:r,form:o,connections:a,onAuthenticate:l}=t;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={activeTab:"tools"},e[0]=c):c=e[0];const[d,h]=R.useReducer(_5,c),u=Gl(r??"");let f;e[1]!==a?(f=a??[],e[1]=a,e[2]=f):f=e[2];let m;e[3]!==f?(m=g5(f),e[3]=f,e[4]=m):m=e[4];const p=m;let g;e[5]!==o||e[6]!==p?(g=($,V,J,Z)=>{const G=p[$]?.[V];let q;G===null?q=Z.filter(K=>K!==J):G?.includes(J)?q=G.filter(K=>K!==J):(q=[...G??[],J],q.length===Z.length&&(q=null));const H={...p};H[$]?H[$]={...H[$]}:H[$]={tools:null,resources:null,prompts:null},H[$][V]=q,o.setValue("connections",T9(H),{shouldDirty:!0,shouldTouch:!0})},e[5]=o,e[6]=p,e[7]=g):g=e[7];const L=g;let v;e[8]!==o||e[9]!==p?(v=($,V)=>{const Z=p[$]?.[V]===null?[]:null,G={...p};G[$]?G[$]={...G[$]}:G[$]={tools:null,resources:null,prompts:null},G[$][V]=Z,o.setValue("connections",T9(G),{shouldDirty:!0,shouldTouch:!0})},e[8]=o,e[9]=p,e[10]=v):v=e[10];const y=v;let _;e[11]!==L?(_=($,V,J)=>L($,"tools",V,J),e[11]=L,e[12]=_):_=e[12];const x=_;let b;e[13]!==L?(b=($,V,J)=>L($,"resources",V,J),e[13]=L,e[14]=b):b=e[14];const S=b;let w;e[15]!==L?(w=($,V,J)=>L($,"prompts",V,J),e[15]=L,e[16]=w):w=e[16];const j=w;let N;e[17]!==y?(N=$=>y($,"tools"),e[17]=y,e[18]=N):N=e[18];const T=N;let A;e[19]!==y?(A=$=>y($,"resources"),e[19]=y,e[20]=A):A=e[20];const k=A;let C;e[21]!==y?(C=$=>y($,"prompts"),e[21]=y,e[22]=C):C=e[22];const I=C;if(!r||!u)return null;let E;e[23]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx(Rn,{}),e[23]=E):E=e[23];let O;e[24]===Symbol.for("react.memo_cache_sentinel")?(O=$=>h({type:"SET_ACTIVE_TAB",payload:$}),e[24]=O):O=e[24];let P;e[25]!==u||e[26]!==d.activeTab||e[27]!==p||e[28]!==r||e[29]!==I||e[30]!==k||e[31]!==T||e[32]!==j||e[33]!==S||e[34]!==x?(P=n.jsx(m5,{currentConnection:u,activeTab:d.activeTab,selectedId:r,formData:p,toggleTool:x,toggleResource:S,togglePrompt:j,toggleAllTools:T,toggleAllResources:k,toggleAllPrompts:I,onTabChange:O},r),e[25]=u,e[26]=d.activeTab,e[27]=p,e[28]=r,e[29]=I,e[30]=k,e[31]=T,e[32]=j,e[33]=S,e[34]=x,e[35]=P):P=e[35];let D;e[36]!==l||e[37]!==r||e[38]!==P?(D=n.jsx(R.Suspense,{fallback:E,children:n.jsx(p5,{connectionId:r,onAuthenticate:l,children:P})}),e[36]=l,e[37]=r,e[38]=P,e[39]=D):D=e[39];let M;e[40]!==i?(M=n.jsx(Di,{className:"px-6 py-4 border-t border-border shrink-0",children:n.jsx(re,{variant:"outline",onClick:()=>i(!1),children:"Done"})}),e[40]=i,e[41]=M):M=e[41];let z;e[42]!==D||e[43]!==M?(z=n.jsxs(qt,{className:"sm:max-w-2xl h-[75vh] max-h-[75vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[D,M]}),e[42]=D,e[43]=M,e[44]=z):z=e[44];let F;return e[45]!==i||e[46]!==s||e[47]!==z?(F=n.jsx(Gt,{open:s,onOpenChange:i,children:z}),e[45]=i,e[46]=s,e[47]=z,e[48]=F):F=e[48],F}const la={tools:null,resources:null,prompts:null},v5=qf.pick({status:!0,title:!0,description:!0,icon:!0,metadata:!0,connections:!0});function x5(t){const s=new TextEncoder().encode(t),i=Array.from(s,r=>String.fromCharCode(r)).join("");return btoa(i)}function y5(t){const e=U.c(11),{url:s,agentId:i}=t,[r,o]=R.useState(!1);let a;e[0]!==i||e[1]!==s?(a=async()=>{Ze("agent_connect_action",{agent_id:i,action:"copy_url"}),await navigator.clipboard.writeText(s),o(!0),me.success("Agent URL copied to clipboard"),setTimeout(()=>o(!1),2e3)},e[0]=i,e[1]=s,e[2]=a):a=e[2];const l=a;let c;e[3]!==r?(c=r?n.jsx(Wt,{size:20,className:"text-green-600"}):n.jsx(ts,{size:20}),e[3]=r,e[4]=c):c=e[4];const d=r?"Copied!":"Copy URL";let h;e[5]!==d?(h=n.jsx("span",{className:"text-xs font-medium",children:d}),e[5]=d,e[6]=h):h=e[6];let u;return e[7]!==l||e[8]!==c||e[9]!==h?(u=n.jsxs(re,{type:"button",variant:"outline",onClick:l,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[c,h]}),e[7]=l,e[8]=c,e[9]=h,e[10]=u):u=e[10],u}function b5(t){const e=U.c(8),{url:s,serverName:i,agentId:r}=t;let o;e[0]!==r||e[1]!==i||e[2]!==s?(o=()=>{Ze("agent_connect_action",{agent_id:r,action:"install_cursor"});const h=Sh(i),f=x5(JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Cursor"}},null,2)),m=`cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(h)}&config=${encodeURIComponent(f)}`;window.open(m,"_blank"),me.success("Opening Cursor...")},e[0]=r,e[1]=i,e[2]=s,e[3]=o):o=e[3];const a=o;let l,c;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx("img",{src:"/logos/cursor.svg",alt:"Cursor",className:"h-5 w-5",style:{filter:"brightness(0) saturate(100%) invert(11%) sepia(8%) saturate(785%) hue-rotate(1deg) brightness(95%) contrast(89%)"}}),c=n.jsx("span",{className:"text-xs font-medium",children:"Install on Cursor"}),e[4]=l,e[5]=c):(l=e[4],c=e[5]);let d;return e[6]!==a?(d=n.jsxs(re,{type:"button",variant:"outline",onClick:a,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[l,c]}),e[6]=a,e[7]=d):d=e[7],d}function S5(t){const e=U.c(12),{url:s,serverName:i,agentId:r}=t,[o,a]=R.useState(!1);let l;e[0]!==r||e[1]!==i||e[2]!==s?(l=async()=>{Ze("agent_connect_action",{agent_id:r,action:"install_claude_code"});const m=Sh(i),g=JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Claude Code"}},null,2),L=`claude mcp add-json "${m}" '${g.replace(/'/g,"'\\''")}' --scope user`;await navigator.clipboard.writeText(L),a(!0),me.success("Claude Code command copied to clipboard"),setTimeout(()=>a(!1),2e3)},e[0]=r,e[1]=i,e[2]=s,e[3]=l):l=e[3];const c=l;let d;e[4]!==o?(d=o?n.jsx(Wt,{size:20,className:"text-green-600"}):n.jsx("img",{src:"/logos/Claude Code.svg",alt:"Claude Code",className:"h-5 w-5",style:{filter:"brightness(0) saturate(100%) invert(55%) sepia(31%) saturate(1264%) hue-rotate(331deg) brightness(92%) contrast(86%)"}}),e[4]=o,e[5]=d):d=e[5];const h=o?"Copied!":"Install on Claude Code";let u;e[6]!==h?(u=n.jsx("span",{className:"text-xs font-medium",children:h}),e[6]=h,e[7]=u):u=e[7];let f;return e[8]!==c||e[9]!==d||e[10]!==u?(f=n.jsxs(re,{type:"button",variant:"outline",onClick:c,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[d,u]}),e[8]=c,e[9]=d,e[10]=u,e[11]=f):f=e[11],f}function w5({virtualMcp:t}){const e=Ri(),[s,i]=R.useState(null),[r,o]=R.useState(!1),[a,l]=R.useState(!1),c=t.id,d=t.title||`agent-${c.slice(0,8)}`,h=s?`bunx @decocms/typegen@latest --mcp ${c} --key ${s} --output client.ts`:`bunx @decocms/typegen@latest --mcp ${c} --key <api-key> --output client.ts`,u=async()=>{o(!0);try{const{key:m}=await e.call("API_KEY_CREATE",{name:`typegen-${d}`,permissions:{[c]:["*"]}});if(!m)throw new Error("No key in response");i(m),Ze("agent_typegen_key_generated",{agent_id:c})}catch{Ze("agent_typegen_key_failed",{agent_id:c}),me.error("Failed to generate API key")}finally{o(!1)}},f=async()=>{Ze("agent_connect_action",{agent_id:c,action:"typegen_copy_command",has_api_key:!!s}),await navigator.clipboard.writeText(h),l(!0),me.success("Command copied to clipboard"),setTimeout(()=>l(!1),2e3)};return n.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[n.jsxs("div",{className:"flex items-start justify-between gap-3",children:[n.jsxs("div",{className:"flex flex-col gap-0.5",children:[n.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Generate typed client"}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Introspects this agent and writes a typed"," ",n.jsx("code",{className:"font-mono",children:"client.ts"})," you can import directly."]})]}),!s&&n.jsxs(re,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:u,disabled:r,children:[r?n.jsx(Ue,{size:14,className:"animate-spin"}):n.jsx(Ql,{size:14}),n.jsx("span",{children:r?"Generating…":"Generate API key"})]})]}),s&&n.jsx("p",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-700",children:"Store this key securely — it won't be shown again."}),n.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Generate client"}),n.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx("code",{className:"min-w-0 flex-1 break-all font-mono text-xs text-muted-foreground",children:h}),n.jsx(re,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:f,children:a?n.jsx(Wt,{size:12,className:"text-green-600"}):n.jsx(ts,{size:12})})]})}),n.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Runtime variables"}),n.jsx(C5,{apiKey:s,agentId:c})]})}function C5(t){const e=U.c(21),{apiKey:s,agentId:i}=t,[r,o]=R.useState(!1),a=window.location.origin,l=s?`MESH_API_KEY=${s}`:"MESH_API_KEY=<api-key>",c=`MESH_BASE_URL=${a}`,d=`${l}
|
|
9
|
-
${c}`;let h;e[0]!==i||e[1]!==s||e[2]!==d?(h=async()=>{Ze("agent_connect_action",{agent_id:i,action:"typegen_copy_env",has_api_key:!!s}),await navigator.clipboard.writeText(d),o(!0),setTimeout(()=>o(!1),2e3)},e[0]=i,e[1]=s,e[2]=d,e[3]=h):h=e[3];const u=h,f=!s;let m;e[4]!==f?(m=ce({"opacity-50":f}),e[4]=f,e[5]=m):m=e[5];let p;e[6]!==l||e[7]!==m?(p=n.jsx("span",{className:m,children:l}),e[6]=l,e[7]=m,e[8]=p):p=e[8];let g,L;e[9]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("br",{}),L=n.jsx("span",{children:c}),e[9]=g,e[10]=L):(g=e[9],L=e[10]);let v;e[11]!==p?(v=n.jsxs("code",{className:"min-w-0 flex-1 font-mono text-xs text-muted-foreground",children:[p,g,L]}),e[11]=p,e[12]=v):v=e[12];let y;e[13]!==r?(y=r?n.jsx(Wt,{size:12,className:"text-green-600"}):n.jsx(ts,{size:12}),e[13]=r,e[14]=y):y=e[14];let _;e[15]!==u||e[16]!==y?(_=n.jsx(re,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:u,children:y}),e[15]=u,e[16]=y,e[17]=_):_=e[17];let x;return e[18]!==v||e[19]!==_?(x=n.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:n.jsxs("div",{className:"flex items-start gap-2",children:[v,_]})}),e[18]=v,e[19]=_,e[20]=x):x=e[20],x}function j5(t){const e=U.c(3),{virtualMcp:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"h-20 animate-pulse rounded-md bg-muted"}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx(R.Suspense,{fallback:i,children:n.jsx(w5,{virtualMcp:s})}),e[1]=s,e[2]=r):r=e[2],r}const k5={self:["COLLECTION_THREADS_CREATE","COLLECTION_THREADS_GET","COLLECTION_THREAD_MESSAGES_LIST","COLLECTION_THREADS_LIST"]},N5=3600*24*90;function T5({virtualMcp:t}){const e=Ri(),{org:s}=Ge(),[i,r]=R.useState(null),[o,a]=R.useState(!1),[l,c]=R.useState(!1),d=t.id,h=t.title||`agent-${d.slice(0,8)}`,f=[`MESH_BASE_URL=${window.location.origin}`,`MESH_ORG=${s.slug}`,`MESH_AGENT_ID=${d}`,`MESH_API_KEY=${i??"<api-key>"}`].join(`
|
|
10
|
-
`),m=async()=>{a(!0);try{const{key:g}=await e.call("API_KEY_CREATE",{name:`chat-bridge-${h}`,permissions:k5,expiresIn:N5});if(!g)throw new Error("No key in response");r(g),Ze("agent_chat_bridge_key_generated",{agent_id:d})}catch{Ze("agent_chat_bridge_key_failed",{agent_id:d}),me.error("Failed to create API key")}finally{a(!1)}},p=async()=>{Ze("agent_connect_action",{agent_id:d,action:"chat_bridge_copy_env",has_api_key:!!i}),await navigator.clipboard.writeText(f),c(!0),me.success("Connection details copied to clipboard"),setTimeout(()=>c(!1),2e3)};return n.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[n.jsxs("div",{className:"flex items-start justify-between gap-3",children:[n.jsxs("div",{className:"flex flex-col gap-0.5",children:[n.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Call from your app"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Create a scoped API key to start a thread, run this agent, and stream results from an external system (e.g. a chatbot webhook)."})]}),!i&&n.jsxs(re,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:m,disabled:o,children:[o?n.jsx(Ue,{size:14,className:"animate-spin"}):n.jsx(Ql,{size:14}),n.jsx("span",{children:o?"Creating…":"Create API key"})]})]}),i&&n.jsx("p",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-700",children:"Store this key securely — it won't be shown again."}),n.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Connection details"}),n.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx("code",{className:"min-w-0 flex-1 whitespace-pre-wrap break-all font-mono text-xs text-muted-foreground",children:f}),n.jsx(re,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:p,children:l?n.jsx(Wt,{size:12,className:"text-green-600"}):n.jsx(ts,{size:12})})]})})]})}function E5(t){const e=U.c(3),{virtualMcp:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"h-20 animate-pulse rounded-md bg-muted"}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx(R.Suspense,{fallback:i,children:n.jsx(T5,{virtualMcp:s})}),e[1]=s,e[2]=r):r=e[2],r}function A5(t){const e=U.c(41),{open:s,onOpenChange:i,virtualMcp:r}=t,{org:o}=Ge(),a=`/api/${o.slug}/mcp/virtual-mcp/${r.id}`;let l;e[0]!==a?(l=new URL(a,window.location.origin),e[0]=a,e[1]=l):l=e[1];const c=l;let d;e[2]!==r.id||e[3]!==r.title?(d=r.title||`agent-${r.id?.slice(0,8)??"default"}`,e[2]=r.id,e[3]=r.title,e[4]=d):d=e[4];const h=d,u=Wl();let f;e[5]!==r.id||e[6]!==c.href?(f=n.jsx(y5,{url:c.href,agentId:r.id}),e[5]=r.id,e[6]=c.href,e[7]=f):f=e[7];let m,p;e[8]!==h||e[9]!==r.id||e[10]!==c.href?(m=n.jsx(b5,{url:c.href,serverName:h,agentId:r.id}),p=n.jsx(S5,{url:c.href,serverName:h,agentId:r.id}),e[8]=h,e[9]=r.id,e[10]=c.href,e[11]=m,e[12]=p):(m=e[11],p=e[12]);let g;e[13]!==f||e[14]!==m||e[15]!==p?(g=n.jsx("div",{className:"flex flex-col gap-3 pt-2",children:n.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[f,m,p]})}),e[13]=f,e[14]=m,e[15]=p,e[16]=g):g=e[16];let L;e[17]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx("div",{className:"border-t border-border"}),e[17]=L):L=e[17];let v;e[18]!==r?(v=n.jsx(j5,{virtualMcp:r}),e[18]=r,e[19]=v):v=e[19];let y;e[20]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx("div",{className:"border-t border-border"}),e[20]=y):y=e[20];let _;e[21]!==r?(_=n.jsx(E5,{virtualMcp:r}),e[21]=r,e[22]=_):_=e[22];let x;e[23]!==_||e[24]!==g||e[25]!==v?(x=n.jsxs("div",{className:"flex flex-col gap-6",children:[g,L,v,y,_]}),e[23]=_,e[24]=g,e[25]=v,e[26]=x):x=e[26];const b=x;if(u){let N;e[27]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx(b3,{className:"mt-4 mb-4 text-base font-semibold",children:"Connect"}),e[27]=N):N=e[27];let T;e[28]!==b?(T=n.jsx(S3,{children:n.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-6 [touch-action:pan-y]",children:[N,b]})}),e[28]=b,e[29]=T):T=e[29];let A;return e[30]!==i||e[31]!==s||e[32]!==T?(A=n.jsx(w3,{open:s,onOpenChange:i,children:T}),e[30]=i,e[31]=s,e[32]=T,e[33]=A):A=e[33],A}let S;e[34]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(_s,{children:n.jsx(Ls,{children:"Connect"})}),e[34]=S):S=e[34];let w;e[35]!==b?(w=n.jsxs(qt,{className:"max-h-[80vh] overflow-y-auto sm:max-w-2xl",children:[S,b]}),e[35]=b,e[36]=w):w=e[36];let j;return e[37]!==i||e[38]!==s||e[39]!==w?(j=n.jsx(Gt,{open:s,onOpenChange:i,children:w}),e[37]=i,e[38]=s,e[39]=w,e[40]=j):j=e[40],j}function P5(t){const e=U.c(43),{virtualMcp:s}=t,i=Ul(),r=Bd(),[o,a]=R.useState(!1);let l,c,d,h,u,f,m,p,g;if(e[0]!==r||e[1]!==i||e[2]!==s.id||e[3]!==s.metadata){g=Symbol.for("react.early_return_sentinel");e:{const b=km(i);if(Sm(s.id)||vi(s.metadata)||b.has(s.id)){g=null;break e}let S;e[13]!==i||e[14]!==s.id?(S=(i??[]).find(E=>E.metadata?.liveAgentId===s.id)??null,e[13]=i,e[14]=s.id,e[15]=S):S=e[15];const w=S,j=w?.id??null;let N;e[16]!==r.update?(N=(E,O)=>r.update.mutateAsync({id:E,data:{metadata:{liveAgentId:O}}}).catch(D5),e[16]=r.update,e[17]=N):N=e[17];const T=N;let A;e[18]!==T||e[19]!==s.id?(A=E=>{T(E,s.id)},e[18]=T,e[19]=s.id,e[20]=A):A=e[20],d=A;let k;e[21]!==j||e[22]!==T?(k=()=>{j&&T(j,null)},e[21]=j,e[22]=T,e[23]=k):k=e[23];const C=k,I=(i??[]).filter(E=>E.id!==s.id&&vi(E.metadata)&&!b.has(E.id));m="flex flex-col gap-3",e[24]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Development agent"}),e[24]=p):p=e[24],c=Jl,f="p-6 gap-4",l=lo,h="p-0 space-y-4",u=j?n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[n.jsx("span",{className:"text-sm text-foreground truncate",children:w?w.title:j}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"Linked dev agent — its sandbox dev server powers the Develop/Live toggle in the header."})]}),n.jsx(re,{variant:"outline",size:"sm",className:"shrink-0",onClick:C,children:"Unlink"})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:"Link a GitHub-backed dev agent. Its sandbox dev server powers a Develop/Live toggle so you can develop and test this agent's MCP app."}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsxs(re,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>a(!0),children:[n.jsx(Ch,{className:"size-4"}),"Import from GitHub"]}),I.length>0?n.jsxs(Tt,{onValueChange:d,children:[n.jsx(kt,{size:"sm",className:"w-56",children:n.jsx(Rt,{placeholder:"Or link an existing dev agent…"})}),n.jsx(Nt,{children:I.map(R5)})]}):null]})]})}e[0]=r,e[1]=i,e[2]=s.id,e[3]=s.metadata,e[4]=l,e[5]=c,e[6]=d,e[7]=h,e[8]=u,e[9]=f,e[10]=m,e[11]=p,e[12]=g}else l=e[4],c=e[5],d=e[6],h=e[7],u=e[8],f=e[9],m=e[10],p=e[11],g=e[12];if(g!==Symbol.for("react.early_return_sentinel"))return g;let L;e[25]!==l||e[26]!==h||e[27]!==u?(L=n.jsx(l,{className:h,children:u}),e[25]=l,e[26]=h,e[27]=u,e[28]=L):L=e[28];let v;e[29]!==c||e[30]!==f||e[31]!==L?(v=n.jsx(c,{className:f,children:L}),e[29]=c,e[30]=f,e[31]=L,e[32]=v):v=e[32];let y;e[33]!==d?(y=b=>{const{virtualMcpId:S}=b;a(!1),d(S)},e[33]=d,e[34]=y):y=e[34];let _;e[35]!==o||e[36]!==y?(_=n.jsx(C3,{open:o,onOpenChange:a,title:"Import a dev agent from GitHub",onImportComplete:y}),e[35]=o,e[36]=y,e[37]=_):_=e[37];let x;return e[38]!==_||e[39]!==m||e[40]!==p||e[41]!==v?(x=n.jsxs("div",{className:m,children:[p,v,_]}),e[38]=_,e[39]=m,e[40]=p,e[41]=v,e[42]=x):x=e[42],x}function R5(t){return n.jsx(ot,{value:t.id,children:t.title},t.id)}function D5(){}const I5=/^[A-Za-z_][A-Za-z0-9_]*$/;function O5(t){const e={},s=t.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=(s[i]??"").trim();if(!r||r.startsWith("#"))continue;r.startsWith("export ")&&(r=r.slice(7).trim());const o=r.indexOf("=");if(o<0)throw new Error(`Line ${i+1}: missing '='`);const a=r.slice(0,o).trim();if(!I5.test(a))throw new Error(`Line ${i+1}: invalid key "${a}"`);let l=r.slice(o+1).trim();l.length>=2&&(l.startsWith('"')&&l.endsWith('"')||l.startsWith("'")&&l.endsWith("'"))&&(l=l.slice(1,-1)),e[a]=l}return e}const M5=/^[A-Za-z0-9_.-]+$/;function B5(t){const e=U.c(14),{control:s,form:i,virtualMcpId:r,orgSlug:o}=t;let a,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("div",{className:"flex items-baseline justify-between gap-2",children:n.jsx(Ve,{className:"font-normal text-foreground",children:"Environment variables"})}),l=n.jsx("p",{className:"text-xs text-muted-foreground",children:"Injected into the sandbox on every start. Reference an org/user secret to keep values out of metadata; literals are stored inline."}),e[0]=a,e[1]=l):(a=e[0],l=e[1]);let c;e[2]!==s||e[3]!==i||e[4]!==o||e[5]!==r?(c=n.jsx(z5,{control:s,form:i,virtualMcpId:r,orgSlug:o}),e[2]=s,e[3]=i,e[4]=o,e[5]=r,e[6]=c):c=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(ec,{className:"h-9 w-full"}),e[7]=d):d=e[7];let h;e[8]!==s||e[9]!==i?(h=n.jsx(es,{fallback:$5,children:n.jsx(R.Suspense,{fallback:d,children:n.jsx(H5,{control:s,form:i})})}),e[8]=s,e[9]=i,e[10]=h):h=e[10];let u;return e[11]!==c||e[12]!==h?(u=n.jsxs("div",{className:"space-y-2",children:[a,l,c,h]}),e[11]=c,e[12]=h,e[13]=u):u=e[13],u}function $5(t){const{error:e}=t;return n.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive",children:e?.message??"Failed to load secrets"})}function z5(t){const e=U.c(24),{control:s,form:i,virtualMcpId:r,orgSlug:o}=t,l=an.useSession().data?.user?.id,c="metadata.runtime.env",d="metadata.sandboxMap";let h;e[0]!==i?(h=()=>JSON.stringify(E9(i.getValues(c))),e[0]=i,e[1]=h):h=e[1];const[u,f]=R.useState(h);let m;e[2]!==s?(m={control:s,name:c},e[2]=s,e[3]=m):m=e[3];const p=wd(m);let g;e[4]!==p?(g=JSON.stringify(E9(p)),e[4]=p,e[5]=g):g=e[5];const L=g,v=L!==u;let y;e[6]!==i?(y=i.getValues(d),e[6]=i,e[7]=y):y=e[7];const _=y;let x;e[8]!==_||e[9]!==l?(x=l?Object.keys(_?.[l]??{}):[],e[8]=_,e[9]=l,e[10]=x):x=e[10];const b=x,S=b.length>0,[w,j]=R.useState(!1);if(!v||!S)return null;let N;e[11]!==L||e[12]!==o||e[13]!==b||e[14]!==r?(N=async()=>{j(!0);const E=await Promise.allSettled(b.map(async P=>{const D=`/api/${encodeURIComponent(o)}/sandbox/${encodeURIComponent(r)}/${encodeURIComponent(P)}/setup/start`,M=await fetch(D,{method:"POST"});if(!M.ok){const z=await M.text().catch(()=>M.statusText);throw new Error(z||M.statusText)}}));j(!1);const O=E.filter(F5).length;O===0?(f(L),me.success(b.length===1?"Restarted dev with new env":`Restarted ${b.length} branches with new env`)):me.error(`Failed to restart ${O} of ${b.length} branch(es)`)},e[11]=L,e[12]=o,e[13]=b,e[14]=r,e[15]=N):N=e[15];const T=N;let A;e[16]===Symbol.for("react.memo_cache_sentinel")?(A=n.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-amber-900 dark:text-amber-200",children:[n.jsx(Ml,{className:"size-3.5 shrink-0"}),n.jsx("span",{className:"truncate",children:"Your sandbox is running. Restart the dev script to apply the new env."})]}),e[16]=A):A=e[16];let k;e[17]!==w?(k=w?n.jsx(Ue,{className:"size-3.5 animate-spin"}):n.jsx(Xi,{className:"size-3.5"}),e[17]=w,e[18]=k):k=e[18];const C=w?"Restarting…":"Restart dev";let I;return e[19]!==T||e[20]!==w||e[21]!==k||e[22]!==C?(I=n.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs dark:border-amber-900/40 dark:bg-amber-950/30",children:[A,n.jsxs(re,{type:"button",variant:"outline",size:"sm",onClick:T,disabled:w,className:"shrink-0",children:[k,C]})]}),e[19]=T,e[20]=w,e[21]=k,e[22]=C,e[23]=I):I=e[23],I}function F5(t){return t.status==="rejected"}function H5(t){const e=U.c(48),{control:s,form:i}=t,r="metadata.runtime.env";let o;e[0]!==s?(o={control:s,name:r},e[0]=s,e[1]=o):o=e[1];const a=Yf(o),{fields:l,append:c,remove:d}=a;let h;e[2]!==i?(h=(E,O)=>{i.setValue(`${r}.${E}`,O,{shouldDirty:!0,shouldTouch:!0})},e[2]=i,e[3]=h):h=e[3];const u=h,f=k3();let m;if(e[4]!==f){m=new Map;for(const E of f)m.set(E.id,E);e[4]=f,e[5]=m}else m=e[5];const[p,g]=R.useState(null);let L;e[6]!==c?(L=()=>{c({key:"",kind:"literal",value:""})},e[6]=c,e[7]=L):L=e[7];const v=L;let y;e[8]!==c||e[9]!==i?(y=async()=>{let E;try{E=await navigator.clipboard.readText()}catch{me.error("Couldn't read clipboard");return}if(!E.trim()){me.error("Clipboard is empty");return}let O;try{O=O5(E)}catch($){const V=$;me.error(V.message);return}const P=Object.entries(O);if(P.length===0){me.error("Nothing to add");return}const D=i.getValues(r)??[],M=new Set;for(const $ of D){const V=($.key??"").trim();V&&M.add(V)}let z=0,F=0;for(const[$,V]of P){if(M.has($)){F++;continue}c({key:$,kind:"literal",value:V}),M.add($),z++}z===0&&F>0?me.message(`All ${F} key${F===1?"":"s"} already exist`):me.success(F>0?`Added ${z} var${z===1?"":"s"} (${F} already existed)`:`Added ${z} var${z===1?"":"s"}`)},e[8]=c,e[9]=i,e[10]=y):y=e[10];const _=y;let x;if(e[11]!==s||e[12]!==l||e[13]!==i||e[14]!==d||e[15]!==m||e[16]!==f||e[17]!==u){let E;e[19]!==s||e[20]!==i||e[21]!==d||e[22]!==m||e[23]!==f||e[24]!==u?(E=(O,P)=>n.jsx("li",{className:"rounded-md border border-border bg-background",children:n.jsx(U5,{index:P,control:s,form:i,onUpdateEntry:u,fieldPath:r,secrets:f,secretById:m,onSaveAsSecret:(D,M)=>g({kind:"save-literal",index:P,presetKey:D,presetValue:M}),onCreateNewSecret:D=>g({kind:"create-new",index:P,presetKey:D}),onRemove:()=>d(P)})},O.id),e[19]=s,e[20]=i,e[21]=d,e[22]=m,e[23]=f,e[24]=u,e[25]=E):E=e[25],x=l.map(E),e[11]=s,e[12]=l,e[13]=i,e[14]=d,e[15]=m,e[16]=f,e[17]=u,e[18]=x}else x=e[18];let b;e[26]!==x?(b=n.jsx("ul",{className:"space-y-2",children:x}),e[26]=x,e[27]=b):b=e[27];let S;e[28]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(It,{className:"size-3.5"}),e[28]=S):S=e[28];let w;e[29]!==v?(w=n.jsxs(re,{type:"button",variant:"outline",size:"sm",onClick:v,className:"flex-1",children:[S,"Add env var"]}),e[29]=v,e[30]=w):w=e[30];let j;e[31]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(y2,{className:"size-3.5"}),e[31]=j):j=e[31];let N;e[32]!==_?(N=n.jsx(Ee,{asChild:!0,children:n.jsxs(re,{type:"button",variant:"outline",size:"sm",onClick:_,"aria-label":"Paste .env",children:[j,"Paste .env"]})}),e[32]=_,e[33]=N):N=e[33];let T;e[34]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx(Ae,{children:"Read a .env blob from the clipboard. Each pair is staged as a literal — save individual rows as secrets after."}),e[34]=T):T=e[34];let A;e[35]!==N?(A=n.jsxs(Pe,{children:[N,T]}),e[35]=N,e[36]=A):A=e[36];let k;e[37]!==A||e[38]!==w?(k=n.jsxs("div",{className:"flex items-center gap-2",children:[w,A]}),e[37]=A,e[38]=w,e[39]=k):k=e[39];let C;e[40]!==p||e[41]!==i||e[42]!==u?(C=p!==null?n.jsx(V5,{mode:p,onClose:()=>g(null),onSaved:E=>{const O=i.getValues(`${r}.${p.index}.key`)?.trim()??"";u(p.index,{key:O,kind:"secret",secretId:E}),g(null)}}):null,e[40]=p,e[41]=i,e[42]=u,e[43]=C):C=e[43];let I;return e[44]!==k||e[45]!==C||e[46]!==b?(I=n.jsxs("div",{className:"space-y-2",children:[b,k,C]}),e[44]=k,e[45]=C,e[46]=b,e[47]=I):I=e[47],I}function U5(t){const e=U.c(55),{index:s,control:i,form:r,onUpdateEntry:o,fieldPath:a,secrets:l,secretById:c,onSaveAsSecret:d,onCreateNewSecret:h,onRemove:u}=t,f=`${a}.${s}.key`,m=`${a}.${s}.value`,p=`${a}.${s}.secretId`,g=`${a}.${s}.kind`;let L;e[0]!==i||e[1]!==g?(L={control:i,name:g},e[0]=i,e[1]=g,e[2]=L):L=e[2];const y=wd(L)==="secret"?"secret":"literal";let _;e[3]!==r||e[4]!==s||e[5]!==f||e[6]!==d||e[7]!==o||e[8]!==m?(_=z=>{const F=r.getValues(f)?.trim()??"";if(z==="literal"){o(s,{key:F,kind:"literal",value:""});return}const $=r.getValues(m)??"";if($.length>0){d(F,$);return}o(s,{key:F,kind:"secret",secretId:""})},e[3]=r,e[4]=s,e[5]=f,e[6]=d,e[7]=o,e[8]=m,e[9]=_):_=e[9];const x=_;let b;e[10]!==s?(b=z=>{const{field:F}=z,$=(F.value??"").trim(),V=$.length>0&&!ko.test($);return n.jsxs("div",{className:"space-y-1",children:[n.jsx(Ke,{...F,value:F.value??"",placeholder:"KEY",spellCheck:!1,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",className:ce("font-mono",V&&"border-destructive focus-visible:ring-destructive"),"aria-invalid":V,"aria-label":`Env var ${s+1} key`,onBlur:J=>{const Z=J.target.value.trim();F.onChange(Z),F.onBlur()}}),V?n.jsx("p",{className:"text-[11px] text-destructive",children:"Letters, digits, underscores. Must start with a letter or underscore."}):null]})},e[10]=s,e[11]=b):b=e[11];let S;e[12]!==i||e[13]!==f||e[14]!==b?(S=n.jsx("div",{className:"flex-1 min-w-0",children:n.jsx(Ut,{control:i,name:f,render:b})}),e[12]=i,e[13]=f,e[14]=b,e[15]=S):S=e[15];let w;e[16]!==x?(w=z=>x(z),e[16]=x,e[17]=w):w=e[17];let j;e[18]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(kt,{className:"h-9 w-[110px]",children:n.jsx(Rt,{})}),e[18]=j):j=e[18];let N;e[19]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx(ot,{value:"literal",children:n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx(Ql,{className:"size-3.5"}),"Literal"]})}),e[19]=N):N=e[19];let T;e[20]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsxs(Nt,{children:[N,n.jsx(ot,{value:"secret",children:n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx(Jf,{className:"size-3.5"}),"Secret"]})})]}),e[20]=T):T=e[20];let A;e[21]!==y||e[22]!==w?(A=n.jsx("div",{className:"shrink-0",children:n.jsxs(Tt,{value:y,onValueChange:w,children:[j,T]})}),e[21]=y,e[22]=w,e[23]=A):A=e[23];let k;e[24]!==i||e[25]!==r||e[26]!==s||e[27]!==f||e[28]!==y||e[29]!==h||e[30]!==c||e[31]!==p||e[32]!==l||e[33]!==m?(k=n.jsx("div",{className:"flex flex-[2] min-w-0 items-center gap-1",children:y==="literal"?n.jsx(Ut,{control:i,name:m,render:z=>{const{field:F}=z;return n.jsx(Ke,{...F,value:F.value??"",type:"password",placeholder:"value",spellCheck:!1,autoComplete:"off",className:"font-mono","aria-label":`Env var ${s+1} value`,onBlur:$=>{F.onChange($.target.value),F.onBlur()}})}}):n.jsxs(n.Fragment,{children:[n.jsx(Ut,{control:i,name:p,render:z=>{const{field:F}=z;return n.jsxs(Tt,{value:F.value||"",onValueChange:$=>F.onChange($),children:[n.jsx(kt,{className:ce("h-9 w-full",!F.value&&"text-muted-foreground"),children:n.jsx(Rt,{placeholder:"Pick a secret…",children:n.jsx(W5,{field:F,secretById:c})})}),n.jsx(Nt,{children:l.length===0?n.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:"No secrets yet. Use the “+” to create one."}):l.map(K5)})]})}}),n.jsxs(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsx(re,{type:"button",variant:"ghost",size:"icon","aria-label":"Create new secret",onClick:()=>{const z=r.getValues(f)?.trim()??"";h(z)},children:n.jsx(It,{className:"size-3.5"})})}),n.jsx(Ae,{children:"Create new secret"})]})]})}),e[24]=i,e[25]=r,e[26]=s,e[27]=f,e[28]=y,e[29]=h,e[30]=c,e[31]=p,e[32]=l,e[33]=m,e[34]=k):k=e[34];let C;e[35]!==r||e[36]!==f||e[37]!==y||e[38]!==d||e[39]!==m?(C=y==="literal"?n.jsxs(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsx(re,{type:"button",variant:"ghost",size:"icon","aria-label":"Save value as secret",onClick:()=>{const z=r.getValues(f)?.trim()??"",F=r.getValues(m)??"";d(z,F)},children:n.jsx(Hl,{className:"size-3.5"})})}),n.jsx(Ae,{children:"Save value as secret"})]}):null,e[35]=r,e[36]=f,e[37]=y,e[38]=d,e[39]=m,e[40]=C):C=e[40];let I;e[41]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx(os,{className:"size-3.5"}),e[41]=I):I=e[41];let E;e[42]!==u?(E=n.jsx(Ee,{asChild:!0,children:n.jsx(re,{type:"button",variant:"ghost",size:"icon","aria-label":"Remove env var",onClick:u,children:I})}),e[42]=u,e[43]=E):E=e[43];let O;e[44]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(Ae,{children:"Remove"}),e[44]=O):O=e[44];let P;e[45]!==E?(P=n.jsxs(Pe,{children:[E,O]}),e[45]=E,e[46]=P):P=e[46];let D;e[47]!==C||e[48]!==P?(D=n.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[C,P]}),e[47]=C,e[48]=P,e[49]=D):D=e[49];let M;return e[50]!==k||e[51]!==D||e[52]!==S||e[53]!==A?(M=n.jsxs("div",{className:"flex flex-col gap-2 p-2 sm:flex-row sm:items-center",children:[S,A,k,D]}),e[50]=k,e[51]=D,e[52]=S,e[53]=A,e[54]=M):M=e[54],M}function K5(t){return n.jsx(ot,{value:t.id,children:n.jsxs("span",{className:"inline-flex items-center gap-2",children:[n.jsx(ou,{scope:t.scope}),n.jsx("span",{className:"font-mono",children:t.name})]})},t.id)}function W5(t){const e=U.c(12),{field:s,secretById:i}=t,r=s.value||"";if(!r)return null;let o;e[0]!==r||e[1]!==i?(o=i.get(r),e[0]=r,e[1]=i,e[2]=o):o=e[2];const a=o;if(!a){let h;return e[3]!==r?(h=n.jsxs("span",{className:"text-destructive",children:["Missing secret (",r,")"]}),e[3]=r,e[4]=h):h=e[4],h}let l;e[5]!==a.scope?(l=n.jsx(ou,{scope:a.scope}),e[5]=a.scope,e[6]=l):l=e[6];let c;e[7]!==a.name?(c=n.jsx("span",{className:"truncate font-mono",children:a.name}),e[7]=a.name,e[8]=c):c=e[8];let d;return e[9]!==l||e[10]!==c?(d=n.jsxs("span",{className:"inline-flex items-center gap-1.5 truncate",children:[l,c]}),e[9]=l,e[10]=c,e[11]=d):d=e[11],d}function ou(t){const e=U.c(2),{scope:s}=t,i=s==="user"?j3:tc;let r;return e[0]!==i?(r=n.jsx(i,{className:"size-3 text-muted-foreground"}),e[0]=i,e[1]=r):r=e[1],r}function V5({mode:t,onClose:e,onSaved:s}){const i=t.kind==="save-literal"?t.presetValue:"",r=t.presetKey,[o,a]=R.useState(()=>G5(r)),[l,c]=R.useState("organization"),[d,h]=R.useState(i),[u,f]=R.useState(""),m=N3(),p=o.trim(),g=d.length>0&&p.length>0&&M5.test(p),L=async _=>{if(_.preventDefault(),!!g)try{const x=await m.mutateAsync({scope:l,name:p,value:d,description:u.trim()||void 0});me.success(`Saved secret "${x.name}"`),s(x.id)}catch(x){me.error(x instanceof Error?x.message:"Failed to save")}},v=t.kind==="save-literal"?"Save value as secret":"Create new secret",y=t.kind==="save-literal"?"Move this value into the encrypted vault. The env var will then reference the secret by id — its value never leaves the server.":"Stored encrypted in the credential vault. The env var will reference the new secret by id.";return n.jsx(Gt,{open:!0,onOpenChange:_=>{_||e()},children:n.jsxs(qt,{className:"sm:max-w-md",children:[n.jsxs(_s,{children:[n.jsx(Ls,{children:v}),n.jsx(or,{children:y})]}),n.jsxs("form",{onSubmit:L,className:"space-y-4",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Ve,{htmlFor:"save-secret-scope",children:"Scope"}),n.jsxs(Tt,{value:l,onValueChange:_=>c(_),children:[n.jsx(kt,{id:"save-secret-scope",children:n.jsx(Rt,{})}),n.jsxs(Nt,{children:[n.jsx(ot,{value:"organization",children:"Organization — visible to all members"}),n.jsx(ot,{value:"user",children:"Private — only visible to me"})]})]})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Ve,{htmlFor:"save-secret-name",children:"Name"}),n.jsx(Ke,{id:"save-secret-name",value:o,onChange:_=>a(_.target.value),placeholder:"STRIPE_API_KEY",autoComplete:"off",required:!0}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Letters, digits, underscore, dot, hyphen. Independent of the env var key."})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Ve,{htmlFor:"save-secret-value",children:"Value"}),n.jsx(Ke,{id:"save-secret-value",type:"password",value:d,onChange:_=>h(_.target.value),placeholder:"secret value",autoComplete:"new-password",required:!0})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Ve,{htmlFor:"save-secret-description",children:"Description (optional)"}),n.jsx(Yn,{id:"save-secret-description",value:u,onChange:_=>f(_.target.value),rows:2,placeholder:"What is this secret used for?"})]}),n.jsxs(Di,{children:[n.jsx(re,{type:"button",variant:"outline",onClick:e,disabled:m.isPending,children:"Cancel"}),n.jsx(re,{type:"submit",disabled:!g||m.isPending,children:m.isPending?"Saving…":"Save secret"})]})]})]})})}function E9(t){if(!Array.isArray(t))return[];const e=[];for(const s of t){if(!s||typeof s!="object")continue;const i=s,r=(i.key??"").trim();if(!(!r||!ko.test(r))){if(i.kind==="literal"){e.push({key:r,kind:"literal",value:i.value??""});continue}i.kind==="secret"&&i.secretId&&e.push({key:r,kind:"secret",secretId:i.secretId})}}return e}function G5(t){const e=t.trim();return e&&ko.test(e)?e:""}function q5(t){const e=U.c(12),{repo:s,className:i}=t;let r;e[0]!==i?(r=ce("space-y-2",i),e[0]=i,e[1]=r):r=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(Ve,{children:"Repository"}),e[2]=o):o=e[2];let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(Ch,{size:20,className:"shrink-0 text-foreground/60"}),e[3]=a):a=e[3];let l;e[4]!==s?(l=n.jsx(Ee,{asChild:!0,children:n.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border bg-background px-4 py-3",tabIndex:0,children:[a,n.jsx("div",{className:"min-w-0 flex-1",children:s?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"truncate text-sm font-medium",children:[s.owner,"/",s.name]}),n.jsx("div",{className:"truncate text-xs text-muted-foreground",children:s.url})]}):n.jsx("div",{className:"text-sm text-muted-foreground",children:"No repository connected"})})]})}),e[4]=s,e[5]=l):l=e[5];let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Ae,{children:"The connected GitHub repository for this agent. Manage in Connections."}),e[6]=c):c=e[6];let d;e[7]!==l?(d=n.jsxs(Pe,{children:[l,c]}),e[7]=l,e[8]=d):d=e[8];let h;return e[9]!==r||e[10]!==d?(h=n.jsxs("div",{className:r,children:[o,d]}),e[9]=r,e[10]=d,e[11]=h):h=e[11],h}const Y5={npm:{install:"npm install",run:t=>`npm run ${t}`,runtime:"node"},pnpm:{install:"pnpm install",run:t=>`pnpm run ${t}`,runtime:"node"},yarn:{install:"yarn install",run:t=>`yarn run ${t}`,runtime:"node"},bun:{install:"bun install",run:t=>`bun run ${t}`,runtime:"bun"},deno:{install:"deno install",run:t=>`deno task ${t}`,runtime:"deno"}};function J5(t){const e=t.trim();if(e==="")return{ok:!0,value:null};if(!/^\d+$/.test(e))return{ok:!1};const s=Number(e);return s<1||s>65535?{ok:!1}:{ok:!0,value:String(s)}}const X5=Object.keys(Y5),ca="__none__";function Z5(t){const e=U.c(20),{control:s}=t,i=R.useRef(null);let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(Ve,{htmlFor:"runtime-pm",children:"Package manager"}),e[0]=r):r=e[0];let o;e[1]!==s?(o=n.jsxs("div",{className:"space-y-2",children:[r,n.jsx(Ut,{control:s,name:"metadata.runtime.selected",render:eg})]}),e[1]=s,e[2]=o):o=e[2];let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(Ve,{htmlFor:"runtime-path",children:"Package path"}),e[3]=a):a=e[3];let l;e[4]!==s?(l=n.jsx(Ut,{control:s,name:"metadata.runtime.path",render:Q5}),e[4]=s,e[5]=l):l=e[5];let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("p",{className:"text-xs text-muted-foreground",children:"Path (relative to repo root) to the directory containing package.json. Leave blank for the repo root."}),e[6]=c):c=e[6];let d;e[7]!==l?(d=n.jsxs("div",{className:"space-y-2",children:[a,l,c]}),e[7]=l,e[8]=d):d=e[8];let h;e[9]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Ve,{htmlFor:"runtime-port",children:"Dev server port"}),e[9]=h):h=e[9];let u;e[10]===Symbol.for("react.memo_cache_sentinel")?(u=L=>{const{field:v}=L;return n.jsx(Ke,{ref:i,id:"runtime-port",inputMode:"numeric",placeholder:"Auto",defaultValue:v.value??"",onBlur:y=>{const _=J5(y.target.value);_.ok?v.onChange(_.value):i.current&&(i.current.value=v.value??"")}})},e[10]=u):u=e[10];let f;e[11]!==s?(f=n.jsx(Ut,{control:s,name:"metadata.runtime.port",render:u}),e[11]=s,e[12]=f):f=e[12];let m;e[13]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave blank to let the runner pick."}),e[13]=m):m=e[13];let p;e[14]!==f?(p=n.jsxs("div",{className:"space-y-2",children:[h,f,m]}),e[14]=f,e[15]=p):p=e[15];let g;return e[16]!==p||e[17]!==o||e[18]!==d?(g=n.jsxs("div",{className:"space-y-5",children:[o,d,p]}),e[16]=p,e[17]=o,e[18]=d,e[19]=g):g=e[19],g}function Q5(t){const{field:e}=t;return n.jsx(Ke,{id:"runtime-path",placeholder:".",defaultValue:e.value??"",onBlur:s=>{const i=s.target.value.trim();e.onChange(i===""?null:i)}})}function eg(t){const{field:e}=t;return n.jsxs(Tt,{value:e.value??ca,onValueChange:s=>e.onChange(s===ca?null:s),children:[n.jsx(kt,{id:"runtime-pm",children:n.jsx(Rt,{placeholder:"Auto-detect"})}),n.jsxs(Nt,{children:[n.jsx(ot,{value:ca,children:"Auto-detect"}),X5.map(tg)]})]})}function tg(t){return n.jsx(ot,{value:t,children:t},t)}function sg(t,e){switch(e.type){case"SET_SHARE_DIALOG_OPEN":return{...t,shareDialogOpen:e.payload};case"SET_ADD_DIALOG_OPEN":return{...t,addDialogOpen:e.payload};case"OPEN_SETTINGS":return{...t,settingsDialogOpen:!0,settingsConnectionId:e.payload};case"CLOSE_SETTINGS":return{...t,settingsDialogOpen:!1,settingsConnectionId:null};default:return t}}function ig(t,e){switch(e.type){case"accumulate":{const s=t??{start:e.now,fields:new Set,saveCount:0,instructionsLength:null},i=new Set(s.fields);for(const r of e.fields)i.add(r);return{...s,fields:i,saveCount:s.saveCount+1,instructionsLength:e.instructionsLength??s.instructionsLength}}case"reset":return null}}function ng(t){const e=t.metadata?.runtime?.env;if(!e||e.length===0)return t;const s=e.filter(i=>{if(!i||typeof i!="object")return!1;const r=(i.key??"").trim();return!r||!ko.test(r)?!1:i.kind==="literal"?!0:i.kind==="secret"?!!i.secretId:!1});return s.length===e.length?t:{...t,metadata:{...t.metadata,runtime:{...t.metadata?.runtime??{},env:s}}}}function rg(t){const e=U.c(23),{connection_id:s,usedConnectionIds:i,onOpenSettings:r,onRemove:o,onAuthenticate:a,onSwitchInstance:l,onNewInstance:c}=t,d=Gl(s),{org:h}=Ge();if(!d)return null;let u;e[0]!==d?(u=d3(d),e[0]=d,e[1]=u):u=e[1];const f=u;let m;e[2]!==s?(m=n.jsx(cg,{connection_id:s}),e[2]=s,e[3]=m):m=e[3];let p;e[4]!==d.app_name||e[5]!==d.connection_type||e[6]!==d.description||e[7]!==d.icon||e[8]!==d.status||e[9]!==d.title||e[10]!==s||e[11]!==a||e[12]!==c||e[13]!==r||e[14]!==o||e[15]!==l||e[16]!==h.slug||e[17]!==f||e[18]!==i?(p=n.jsx(lg,{connection_id:s,connectionTitle:d.title,connectionDescription:d.description,connectionIcon:d.icon,connectionType:d.connection_type,connectionStatus:d.status,slug:f,orgSlug:h.slug,appName:d.app_name,usedConnectionIds:i,onOpenSettings:r,onRemove:o,onAuthenticate:a,onSwitchInstance:l,onNewInstance:c}),e[4]=d.app_name,e[5]=d.connection_type,e[6]=d.description,e[7]=d.icon,e[8]=d.status,e[9]=d.title,e[10]=s,e[11]=a,e[12]=c,e[13]=r,e[14]=o,e[15]=l,e[16]=h.slug,e[17]=f,e[18]=i,e[19]=p):p=e[19];let g;return e[20]!==m||e[21]!==p?(g=n.jsx(R.Suspense,{fallback:m,children:p}),e[20]=m,e[21]=p,e[22]=g):g=e[22],g}const A9="__new_instance__";async function og(t,e){const s=t?.idToken??null;if(s){const r=P9(s);if(r)return r}const i=t?.userinfoEndpoint??null;if(i)try{const r=await fetch(i,{headers:{Authorization:`Bearer ${e}`}});if(r.ok){const o=await r.json(),a=typeof o.email=="string"?o.email:typeof o.upn=="string"?o.upn:typeof o.preferred_username=="string"?o.preferred_username:null;if(a)return a}}catch{}return P9(e)}function P9(t){try{const e=t.split(".");if(e.length===3&&e[1]){const s=JSON.parse(atob(e[1].replace(/-/g,"+").replace(/_/g,"/")));if(typeof s.email=="string")return s.email;if(typeof s.upn=="string")return s.upn;if(typeof s.preferred_username=="string")return s.preferred_username}}catch{}return null}function ag(t){const e=U.c(23),{appName:s,connectionId:i,usedConnectionIds:r,onSwitchInstance:o,onNewInstance:a}=t;let l;e[0]!==s?(l={filters:[{column:"app_name",value:s}]},e[0]=s,e[1]=l):l=e[1];const c=rr(l);if(c.length<=1)return null;let d;e[2]!==i||e[3]!==a||e[4]!==o?(d=g=>{g===A9?a?.():o(i,g)},e[2]=i,e[3]=a,e[4]=o,e[5]=d):d=e[5];let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(kt,{size:"sm",className:"w-auto text-xs gap-1 px-2 shadow-none",children:n.jsx(Rt,{})}),e[6]=h):h=e[6];let u;if(e[7]!==i||e[8]!==c||e[9]!==r){let g;e[11]!==i||e[12]!==r?(g=L=>n.jsx(ot,{value:L.id,className:"text-xs",disabled:L.id!==i&&r.has(L.id),children:L.title},L.id),e[11]=i,e[12]=r,e[13]=g):g=e[13],u=c.map(g),e[7]=i,e[8]=c,e[9]=r,e[10]=u}else u=e[10];let f;e[14]!==a?(f=a&&n.jsx(ot,{value:A9,className:"text-xs text-muted-foreground",children:"+ New instance"}),e[14]=a,e[15]=f):f=e[15];let m;e[16]!==u||e[17]!==f?(m=n.jsxs(Nt,{children:[u,f]}),e[16]=u,e[17]=f,e[18]=m):m=e[18];let p;return e[19]!==i||e[20]!==d||e[21]!==m?(p=n.jsxs(Tt,{value:i,onValueChange:d,children:[h,m]}),e[19]=i,e[20]=d,e[21]=m,e[22]=p):p=e[22],p}function lg({connection_id:t,connectionTitle:e,connectionDescription:s,connectionIcon:i,connectionType:r,connectionStatus:o,slug:a,orgSlug:l,appName:c,usedConnectionIds:d,onOpenSettings:h,onRemove:u,onAuthenticate:f,onSwitchInstance:m,onNewInstance:p}){const g=bh({connectionId:t}),L=mh(),y=!(r==="VIRTUAL")&&g.supportsOAuth&&!g.isAuthenticated,_=o!=="active",x=async b=>{try{await L.update.mutateAsync({id:t,data:{status:b}}),me.success(b==="active"?"Connection enabled":"Connection disabled")}catch{me.error("Failed to update connection")}};return n.jsxs("div",{className:ce("rounded-xl border overflow-hidden transition-colors",y||_?"border-destructive/50 bg-destructive/5":"border-border bg-card"),children:[n.jsxs(jd,{to:"/$org/settings/connections/$appSlug",params:{org:l,appSlug:a},className:"flex items-center gap-3 px-4 py-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[n.jsx(Es,{icon:i,name:e,size:"sm",className:"shrink-0"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:"text-sm font-medium truncate",children:e}),y?n.jsx("span",{className:"text-xs text-destructive font-medium",children:"Needs authorization"}):_?n.jsx("span",{className:"text-xs text-destructive font-medium",children:o==="error"?"Disabled (error)":"Disabled"}):s&&n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s})]}),y?n.jsx(re,{variant:"outline",size:"sm",className:"h-7 text-xs shrink-0",onClick:b=>{b.preventDefault(),b.stopPropagation(),f(t)},children:"Authorize"}):_?n.jsxs(re,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1.5 shrink-0",onClick:b=>{b.preventDefault(),b.stopPropagation(),x("active")},children:[n.jsx(b2,{size:13}),"Enable"]}):n.jsxs(Pe,{delayDuration:0,children:[n.jsx(Ee,{asChild:!0,children:n.jsx("span",{className:"inline-flex items-center justify-center rounded-md h-7 w-7 hover:bg-accent text-muted-foreground shrink-0 transition-colors",children:n.jsx(h3,{size:16})})}),n.jsx(Ae,{side:"bottom",children:"Connection settings"})]})]}),n.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-t border-border bg-muted/25",children:[c&&n.jsx(ag,{appName:c,connectionId:t,usedConnectionIds:d,onSwitchInstance:m,onNewInstance:p}),n.jsxs("div",{className:"flex items-center gap-0.5 ml-auto",children:[n.jsxs(Pe,{delayDuration:0,children:[n.jsx(Ee,{asChild:!0,children:n.jsx(re,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:h,"aria-label":"Configure resources",children:n.jsx(S2,{size:13})})}),n.jsx(Ae,{side:"bottom",children:"Configure resources"})]}),!_&&n.jsxs(Pe,{delayDuration:0,children:[n.jsx(Ee,{asChild:!0,children:n.jsx(re,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground",onClick:()=>x("inactive"),"aria-label":"Disable connection",children:n.jsx(w2,{size:13})})}),n.jsx(Ae,{side:"bottom",children:"Disable"})]}),n.jsxs(Pe,{delayDuration:0,children:[n.jsx(Ee,{asChild:!0,children:n.jsx(re,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:u,"aria-label":"Remove connection",children:n.jsx(ti,{size:13})})}),n.jsx(Ae,{side:"bottom",children:"Remove"})]})]})]})]})}function cg(t){const e=U.c(17),{connection_id:s}=t,i=Gl(s);if(!i){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(au,{}),e[0]=u):u=e[0],u}let r;e[1]!==i.icon||e[2]!==i.title?(r=n.jsx(Es,{icon:i.icon,name:i.title,size:"sm",className:"shrink-0"}),e[1]=i.icon,e[2]=i.title,e[3]=r):r=e[3];let o;e[4]!==i.title?(o=n.jsx("p",{className:"text-sm font-medium truncate",children:i.title}),e[4]=i.title,e[5]=o):o=e[5];let a;e[6]!==i.description?(a=i.description&&n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:i.description}),e[6]=i.description,e[7]=a):a=e[7];let l;e[8]!==o||e[9]!==a?(l=n.jsxs("div",{className:"flex-1 min-w-0",children:[o,a]}),e[8]=o,e[9]=a,e[10]=l):l=e[10];let c;e[11]!==r||e[12]!==l?(c=n.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[r,l]}),e[11]=r,e[12]=l,e[13]=c):c=e[13];let d;e[14]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:n.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})}),e[14]=d):d=e[14];let h;return e[15]!==c?(h=n.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[c,d]}),e[15]=c,e[16]=h):h=e[16],h}function au(){const t=U.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"size-8 rounded-md bg-muted animate-pulse shrink-0"}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e,n.jsxs("div",{className:"flex-1 space-y-1.5",children:[n.jsx("div",{className:"h-4 w-32 rounded bg-muted animate-pulse"}),n.jsx("div",{className:"h-3 w-48 rounded bg-muted animate-pulse"})]})]}),t[1]=s):s=t[1];let i;return t[2]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[s,n.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:n.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})})]}),t[2]=i):i=t[2],i}function dg({virtualMcpId:t,form:e,flushAndSave:s}){const i=Ri(),r=Ts(t),o=(r?.connections??[]).map(k=>k.connection_id).sort(),{data:a}=si({queryKey:Et.projectConnectionDetails(t,o),enabled:o.length>0,queryFn:async()=>await Promise.all(o.map(async C=>{try{const{item:I}=await i.call("COLLECTION_CONNECTIONS_GET",{id:C}),E=(I?.tools??[]).flatMap(O=>{const P=_h(O._meta);return P?[{name:O.name,title:O.title,description:O.description,resourceUri:P}]:[]});return{fetchOk:!0,id:C,title:I?.title??C,icon:I?.icon??null,uiTools:E}}catch{return{fetchOk:!1,id:C,title:C,icon:null,uiTools:[]}}}))}),l=(a??[]).filter(k=>k.uiTools.length>0),c=new Set(Om),d=e.watch("metadata.ui.pinnedViews")??[],h=e.watch("metadata.ui.layout")??null,u=h?.defaultMainView??null,f=h?.chatDefaultOpen??!1,m=!u||u.type==="chat"?"chat":u.type==="instructions"||u.type==="connections"||u.type==="layout"?"settings":c.has(u.type)?u.type:`${u.type}:${u.id??""}:${u.toolName??""}`,p=k=>{const[C,I,E]=k.split(":");return C?C==="chat"?{type:C}:c.has(C)?{type:C}:C==="ext-apps"&&I?{type:"ext-apps",id:I,toolName:E||void 0}:null:null},g=k=>{e.setValue("metadata.ui.pinnedViews",k,{shouldDirty:!0})},L=k=>{e.setValue("metadata.ui.layout",{...h,...k},{shouldDirty:!0})},v=R.useRef(!1);if(a&&a.length>0&&!v.current){v.current=!0;const k=new Set((a??[]).filter(E=>E.fetchOk).map(E=>E.id)),C=new Set(l.flatMap(E=>E.uiTools.map(O=>`${E.id}:${O.name}`))),I=d.filter(E=>!k.has(E.connectionId)||C.has(`${E.connectionId}:${E.toolName}`));I.length!==d.length&&(g(I),u?.type==="ext-apps"&&!I.some(E=>E.connectionId===u.id&&E.toolName===u.toolName)&&L({defaultMainView:{type:"chat"}}))}const y=(k,C)=>{if(d.some(E=>E.connectionId===k&&E.toolName===C)){const E=d.filter(P=>!(P.connectionId===k&&P.toolName===C));g(E);const O=`ext-apps:${k}:${C}`;m===O&&L({defaultMainView:{type:"chat"}})}else{const E=l.find(O=>O.id===k)?.uiTools.find(O=>O.name===C)?.title;g([...d,{connectionId:k,toolName:C,label:E??$a(C),icon:null}])}s()},_=(k,C,I)=>{g(d.map(E=>E.connectionId===k&&E.toolName===C?{...E,label:I}:E))},x=()=>{s()},b=(k,C,I)=>{g(d.map(E=>E.connectionId===k&&E.toolName===C?{...E,icon:I}:E)),s()},S=k=>{L({defaultMainView:p(k)}),s()},w=o.length===0,j=a&&l.length===0,N=vi(r?.metadata),T=[{value:"chat",label:"Chat"},{value:"settings",label:"Settings"},{value:"automations",label:"Automations"}];N&&T.push({value:"preview",label:"Preview"});for(const k of d)T.push({value:`ext-apps:${k.connectionId}:${k.toolName}`,label:k.label||k.toolName});const A=l.length>0||w||j;return n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("div",{className:"flex items-center justify-between gap-3",children:n.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Layout"})}),n.jsxs(Jl,{className:"p-6 gap-5",children:[n.jsxs(lo,{className:"p-0 space-y-5",children:[n.jsxs("div",{className:"flex items-center justify-between gap-4",children:[n.jsxs("div",{className:"space-y-0.5 min-w-0",children:[n.jsx(Ve,{className:"font-normal text-foreground",children:"Main view"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"What users see when they first open this agent."})]}),n.jsxs(Tt,{value:m,onValueChange:S,children:[n.jsx(kt,{className:"w-44 h-8 text-sm capitalize shrink-0",children:n.jsx(Rt,{})}),n.jsx(Nt,{children:T.map(k=>n.jsx(ot,{value:k.value,className:"capitalize",children:k.label},k.value))})]})]}),n.jsxs("div",{className:"flex items-center justify-between gap-4",children:[n.jsxs("div",{className:"space-y-0.5 min-w-0",children:[n.jsx(Ve,{className:"font-normal text-foreground",children:"Show chat"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Display the chat panel alongside the main view."})]}),n.jsxs(Pe,{delayDuration:0,children:[n.jsx(Ee,{asChild:!0,children:n.jsx("span",{className:"shrink-0",children:n.jsx(Jn,{checked:m==="chat"?!0:f,disabled:m==="chat",onCheckedChange:k=>{L({chatDefaultOpen:k}),s()}})})}),m==="chat"&&n.jsx(Ae,{side:"top",children:"Chat is always shown when it is the default view"})]})]})]}),A&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"border-t border-border -mx-6"}),n.jsxs(lo,{className:"p-0 space-y-3",children:[n.jsx("div",{className:"flex items-center justify-between gap-4",children:n.jsxs("div",{className:"space-y-0.5 min-w-0",children:[n.jsx(Ve,{className:"font-normal text-foreground",children:"Pinned views"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Surface interactive tools as top-level tabs in the agent."})]})}),w&&n.jsx("p",{className:"text-xs text-muted-foreground",children:"Add a connection above to configure pinned views."}),j&&!w&&n.jsx("p",{className:"text-xs text-muted-foreground",children:"None of the connected servers expose interactive tools."}),l.length>0&&n.jsx("div",{className:"space-y-4 pt-1",children:l.map((k,C)=>n.jsxs("div",{children:[C>0&&n.jsx("div",{className:"border-t border-border -mx-6 mb-4"}),n.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[n.jsx(Es,{icon:k.icon,name:k.title,size:"xs",className:"shrink-0"}),n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:k.title})]}),n.jsx("div",{className:"space-y-1.5",children:k.uiTools.map(I=>{const E=d.some(P=>P.connectionId===k.id&&P.toolName===I.name),O=d.find(P=>P.connectionId===k.id&&P.toolName===I.name);return n.jsxs("div",{className:ce("flex items-center justify-between gap-3 px-3 py-2 rounded-lg border transition-colors",E?"bg-accent/40 border-border":"bg-transparent border-border"),children:[n.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[n.jsx(V4,{value:O?.icon??null,onChange:P=>b(k.id,I.name,P),disabled:!E}),n.jsx(Ke,{value:E&&O?O.label:I.title??$a(I.name),onChange:P=>_(k.id,I.name,P.target.value),onBlur:x,className:"h-7 text-sm w-40",disabled:!E,readOnly:!E})]}),n.jsx(Jn,{checked:E,onCheckedChange:()=>y(k.id,I.name)})]},I.name)})})]},k.id))})]})]})]})]})}function hg({virtualMcp:t,hideOwnTitle:e}){const{org:s}=Ge(),i=Bd(),{data:r}=em([t.id]),o=r?.get(t.id)?.last_used_at,a=mh(),l=Ni(),c=Ri(),d=Cd({resolver:Xf(v5),defaultValues:t}),h=d.watch("connections"),u=Wd(t),f=Ao(t),m=f?{owner:f.owner,name:f.name,url:f.url}:null,[p,g]=R.useReducer(sg,{shareDialogOpen:!1,addDialogOpen:!1,settingsDialogOpen:!1,settingsConnectionId:null}),[L,v]=R.useState(!1),[y,_]=R.useState(!1),{createNewTask:x,setChatOpen:b}=Eo(),{sendMessage:S}=Ti(),w=async()=>{if(y)return;const B=d.getValues("metadata.instructions");if(B?.trim()){_(!0);try{C(),Ze("agent_instructions_improve_clicked",{agent_id:t.id,instructions_length:B.length}),b(!0),await S({tiptapDoc:iu({managerAgentId:Kd.AGENT_MANAGER(s.id),managerName:"Agent Manager",kind:"agent",id:t.id,instructions:B})})}finally{_(!1)}}},j=()=>{C(),Ze("agent_test_clicked",{agent_id:t.id}),x()},[N,T]=R.useReducer(ig,null),A=()=>{N!==null&&(Ze("agent_updated",{agent_id:t.id,fields:Array.from(N.fields),instructions_length:N.instructionsLength,save_count:N.saveCount,edit_duration_ms:Date.now()-N.start}),T({type:"reset"}))},{schedule:k,flush:C}=co({delayMs:3e4,save:async()=>A()}),I=async()=>{const B=Object.keys(d.control._formState.dirtyFields);if(B.length===0)return;const X=B.includes("metadata"),W=d.getValues();d.reset(W,{keepValues:!0});const Y=ng(W);await i.update.mutateAsync({id:t.id,data:Y}),T({type:"accumulate",now:Date.now(),fields:B,instructionsLength:X?W.metadata?.instructions?.length??0:null}),k()},{schedule:E,flush:O}=co({save:I});R.useEffect(()=>{const B=d.watch(()=>E());return()=>B.unsubscribe()},[]);const P=()=>{Ze("connections_dialog_opened",{source:"agent_settings",mode:"add"}),g({type:"SET_ADD_DIALOG_OPEN",payload:!0})},D=async B=>{const X=d.getValues("connections");if(X.some(Q=>Q.connection_id===B))return;d.setValue("connections",[...X,{connection_id:B,selected_tools:la.tools,selected_resources:la.resources,selected_prompts:la.prompts}],{shouldDirty:!0}),g({type:"SET_ADD_DIALOG_OPEN",payload:!1});const W=new URL(`/api/${s.slug}/mcp/${B}`,window.location.origin),Y=await m9({url:W.href,token:null,orgId:s.id});Y.supportsOAuth&&!Y.isAuthenticated&&await V(B)},M=B=>{const W=d.getValues("connections").filter(Y=>Y.connection_id!==B);d.setValue("connections",W,{shouldDirty:!0})},z=(B,X)=>{const W=d.getValues("connections");if(W.some(Y=>Y.connection_id===X)){me.error("This instance is already added to the agent");return}d.setValue("connections",W.map(Y=>Y.connection_id===B?{...Y,connection_id:X}:Y),{shouldDirty:!0})},F=async B=>{if(d.getValues("connections").find(W=>W.connection_id===B))try{const{item:W}=await c.call("COLLECTION_CONNECTIONS_GET",{id:B});if(!W)return;const Y=W.title.replace(/\s*\(.*?\)\s*$/,""),Q=l3("conn"),ie=`${Y} (${Date.now().toString(36).slice(-4)})`;await a.create.mutateAsync({id:Q,title:ie,description:W.description??null,connection_type:W.connection_type,connection_url:W.connection_url??null,connection_token:null,icon:W.icon??null,app_name:W.app_name??null,app_id:W.app_id??null,connection_headers:W.connection_headers??null});const oe=new URL(`/api/${s.slug}/mcp/${Q}`,window.location.origin),ue=await m9({url:oe.href,token:null,orgId:s.id});if(ue.supportsOAuth&&!ue.isAuthenticated){const ee=await V(Q);if(!ee){await a.delete.mutateAsync(Q);return}await a.update.mutateAsync({id:Q,data:{title:`${Y} (${ee})`}})}z(B,Q),me.success("New instance created")}catch(W){console.error("Failed to create instance:",W),me.error("Failed to create instance")}},$=B=>{g({type:"OPEN_SETTINGS",payload:B})},V=async B=>{const{token:X,tokenInfo:W,error:Y}=await c3({connectionId:B,orgSlug:s.slug,scope:"offline_access"});if(Y||!X)return me.error(`Authentication failed: ${Y}`),null;if(W)try{const ie=await fetch(`/api/${s.slug}/connections/${B}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:W.accessToken,refreshToken:W.refreshToken,expiresIn:W.expiresIn,scope:W.scope,clientId:W.clientId,clientSecret:W.clientSecret,tokenEndpoint:W.tokenEndpoint})});if(!ie.ok)console.error("Failed to save OAuth token:",await ie.text()),await a.update.mutateAsync({id:B,data:{connection_token:X}});else try{await a.update.mutateAsync({id:B,data:{}})}catch(oe){console.warn("Failed to refresh connection tools after OAuth:",oe)}}catch(ie){console.error("Error saving OAuth token:",ie),await a.update.mutateAsync({id:B,data:{connection_token:X}})}else await a.update.mutateAsync({id:B,data:{connection_token:X}});const Q=new URL(`/api/${s.slug}/mcp/${B}`,window.location.origin);return await l.invalidateQueries({queryKey:Et.isMCPAuthenticated(Q.href,null)}),me.success("Authentication successful"),og(W,X)},J=()=>{const B=d.getValues("metadata.instructions")??"",X=`<role>
|
|
11
|
-
Define who this agent is and what it specializes in.
|
|
12
|
-
Example: You are a support triage agent for B2B merchants.
|
|
13
|
-
</role>
|
|
14
|
-
|
|
15
|
-
<capabilities>
|
|
16
|
-
List what this agent can do using its connected tools.
|
|
17
|
-
- Investigate issues using connected data sources.
|
|
18
|
-
- Summarize findings and recommend next steps.
|
|
19
|
-
</capabilities>
|
|
20
|
-
|
|
21
|
-
<constraints>
|
|
22
|
-
Set clear boundaries on what the agent must not do.
|
|
23
|
-
- Do not perform destructive actions without confirmation.
|
|
24
|
-
- Escalate to a human when the request is outside your expertise.
|
|
25
|
-
</constraints>
|
|
26
|
-
|
|
27
|
-
<workflows>
|
|
28
|
-
Define step-by-step how the agent should handle requests.
|
|
29
|
-
|
|
30
|
-
## Default workflow
|
|
31
|
-
1. Read the user's request and gather context.
|
|
32
|
-
2. Use the appropriate tools to investigate or act.
|
|
33
|
-
3. Summarize the result and propose next steps.
|
|
34
|
-
4. Ask for confirmation before making any changes.
|
|
35
|
-
</workflows>`,W=B.trim()?`${B}
|
|
36
|
-
|
|
37
|
-
${X}`:X;d.setValue("metadata.instructions",W,{shouldDirty:!0})},Z=new Set(h.map(B=>B.connection_id)),G=Vt(),[q,H]=R.useState(!1),K=async()=>{C();try{await i.delete.mutateAsync(t.id),Ze("agent_deleted",{agent_id:t.id,source:"agent_detail"}),me.success(`Deleted "${t.title}"`),G({to:"/$org",params:{org:s.slug}})}catch{}};return n.jsxs(fs,{children:[n.jsx(fs.Content,{children:n.jsx(fs.Body,{children:n.jsxs("div",{className:"flex flex-col gap-10",children:[!e&&n.jsx(fs.Title,{actions:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(re,{variant:"outline",size:"sm",onClick:j,children:[n.jsx(xi,{size:14,className:"size-[14px]!"}),"Test Agent"]}),n.jsx(re,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive",onClick:()=>H(!0),children:n.jsx(os,{size:14})})]}),children:"Settings"}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(Ut,{name:"icon",control:d.control,render:({field:B})=>n.jsx($4,{value:B.value??null,onChange:X=>{B.onChange(X),O()},onColorChange:X=>{d.setValue("metadata.ui.themeColor",X,{shouldDirty:!0}),O()},name:d.watch("title")||"Agent",size:"md",className:"shrink-0",avatarClassName:"[&_svg]:w-1/2 [&_svg]:h-1/2"})}),n.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[n.jsx(Ut,{name:"title",control:d.control,render:({field:B})=>n.jsx("input",{...B,type:"text",value:B.value??"",onChange:X=>{B.onChange(X)},onBlur:()=>{B.onBlur(),O()},disabled:u,placeholder:"Agent name",className:"text-lg font-medium leading-tight text-foreground bg-transparent border-none outline-none px-1 -mx-1 rounded hover:bg-input/25 focus:bg-input/25 transition-colors w-full truncate disabled:hover:bg-transparent disabled:focus:bg-transparent disabled:opacity-50"})}),n.jsx(Ut,{name:"description",control:d.control,render:({field:B})=>n.jsx("input",{...B,type:"text",value:B.value??"",onChange:X=>{B.onChange(X)},onBlur:()=>{B.onBlur(),O()},disabled:u,placeholder:"Add a description...",className:"text-sm text-muted-foreground bg-transparent border-none outline-none px-1 -mx-1 rounded hover:bg-input/25 focus:bg-input/25 transition-colors w-full truncate disabled:hover:bg-transparent disabled:focus:bg-transparent disabled:opacity-50"})})]}),n.jsxs(re,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>{Ze("agent_connect_modal_opened",{agent_id:t.id}),g({type:"SET_SHARE_DIALOG_OPEN",payload:!0})},children:[n.jsxs("span",{className:"flex items-center -space-x-1.5 mr-0.5",children:[n.jsx("span",{className:"inline-flex items-center justify-center size-4 rounded-full bg-black ring-1 ring-white/20 shrink-0",children:n.jsx("img",{src:"/logos/cursor.svg",alt:"Cursor",className:"size-2.5 brightness-0 invert"})}),n.jsx("span",{className:"relative z-10 inline-flex items-center justify-center size-4 rounded-full ring-1 ring-background shrink-0",style:{backgroundColor:"#D97757"},children:n.jsx("img",{src:"/logos/Claude Code.svg",alt:"Claude",className:"size-2.5 brightness-0 invert"})})]}),"Connect"]})]}),n.jsxs("div",{className:"flex items-center gap-2 -mt-6 text-sm text-muted-foreground",children:[n.jsx(nu,{id:t.created_by,size:"2xs",className:"text-sm text-muted-foreground"}),n.jsx("span",{className:"text-muted-foreground/50",children:"·"}),n.jsxs("span",{children:["Created"," ",new Date(t.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})]}),n.jsx("span",{className:"text-muted-foreground/50",children:"·"}),n.jsx("span",{children:o?`Last used ${T3(new Date(o),{addSuffix:!0})}`:"Never used"})]}),n.jsxs("section",{className:"flex flex-col gap-3",children:[n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Connections"}),h.length>0&&n.jsxs(re,{variant:"outline",size:"sm",onClick:P,children:[n.jsx(It,{size:14}),"Add connection"]})]}),n.jsx("div",{className:"flex flex-col gap-2",children:h.length===0?n.jsxs("button",{type:"button",onClick:P,className:"flex items-center gap-3 px-3 py-2.5 rounded-lg border border-dashed border-border hover:bg-accent/50 transition-colors w-full text-left cursor-pointer",children:[n.jsx("div",{className:"flex items-center justify-center size-8 rounded-md text-muted-foreground/75 border border-dashed border-border shrink-0",children:n.jsx(It,{size:16})}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"No connections yet. Add one to get started."})]}):h.map(B=>n.jsx(es,{fallback:()=>null,children:n.jsx(R.Suspense,{fallback:n.jsx(au,{}),children:n.jsx(rg,{connection_id:B.connection_id,usedConnectionIds:Z,onOpenSettings:()=>$(B.connection_id),onRemove:()=>M(B.connection_id),onAuthenticate:V,onSwitchInstance:z,onNewInstance:()=>F(B.connection_id)})})},B.connection_id))})]}),n.jsxs("section",{className:"flex flex-col gap-3",children:[n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Instructions"}),n.jsxs("div",{className:"flex items-center gap-2",children:[!d.watch("metadata.instructions")?.trim()&&n.jsx(re,{variant:"outline",size:"sm",onClick:J,children:"+ Prompt template"}),n.jsxs(re,{variant:"outline",size:"sm",disabled:y||!d.watch("metadata.instructions")?.trim(),onClick:w,children:[n.jsx(gi,{size:13}),"Improve"]})]})]}),n.jsx(Ut,{name:"metadata.instructions",control:d.control,render:({field:B})=>n.jsxs("div",{className:"relative rounded-xl card-shadow bg-card focus-within:ring-1 focus-within:ring-ring",children:[n.jsx(Yn,{...B,value:B.value??"",onChange:X=>{B.onChange(X)},onBlur:()=>{B.onBlur(),O()},placeholder:"Define how this agent should behave, what tone to use, any constraints or guidelines...",className:"min-h-[200px] max-h-[360px] overflow-auto resize-none text-base text-muted-foreground placeholder:text-muted-foreground/40 leading-relaxed border-0 shadow-none px-4 py-3 pr-11 focus-visible:ring-0 focus-visible:ring-offset-0 bg-transparent",style:{boxShadow:"none"}}),n.jsxs(Pe,{delayDuration:0,children:[n.jsx(Ee,{asChild:!0,children:n.jsx(re,{type:"button",variant:"ghost",size:"icon",className:"absolute top-2 right-2 h-7 w-7 text-muted-foreground",onClick:()=>v(!0),"aria-label":"Open fullscreen editor",children:n.jsx(Rd,{size:14})})}),n.jsx(Ae,{side:"left",children:"Fullscreen"})]})]})})]}),n.jsx(Y4,{form:d}),n.jsx(es,{fallback:()=>null,children:n.jsx(R.Suspense,{fallback:n.jsxs("section",{className:"flex flex-col gap-3",children:[n.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Sub-agents"}),n.jsx("div",{className:"h-16 rounded-lg border border-dashed border-border animate-pulse"})]}),children:n.jsx(s5,{form:d,currentAgentId:t.id})})}),n.jsx(dg,{virtualMcpId:t.id,form:d,flushAndSave:O}),n.jsx(P5,{virtualMcp:t}),n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("div",{className:"flex items-center justify-between gap-3",children:n.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Sandbox"})}),n.jsx(Jl,{className:"p-6 gap-5",children:n.jsxs(lo,{className:"p-0 space-y-5",children:[n.jsx(q5,{repo:m}),n.jsx(Z5,{control:d.control}),n.jsx(B5,{control:d.control,form:d,virtualMcpId:t.id,orgSlug:s.slug})]})})]}),n.jsxs("section",{className:"flex items-center justify-between border-t border-border pt-6",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:"Delete agent"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Permanently delete this agent and all its data."})]}),n.jsxs(re,{variant:"outline",size:"sm",className:"text-destructive border-destructive/40 hover:bg-destructive/10 hover:text-destructive shrink-0",onClick:()=>H(!0),children:[n.jsx(os,{size:14}),"Delete agent"]})]})]})})}),n.jsx(eo,{open:q,onOpenChange:H,children:n.jsxs(to,{children:[n.jsxs(so,{children:[n.jsx(io,{children:"Delete Agent?"}),n.jsxs(no,{children:["This action cannot be undone. This will permanently delete"," ",n.jsx("span",{className:"font-medium text-foreground",children:t.title}),"."]})]}),n.jsxs(ro,{children:[n.jsx(oo,{children:"Cancel"}),n.jsx(ao,{onClick:K,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),n.jsx(Nm,{open:p.addDialogOpen,onOpenChange:B=>g({type:"SET_ADD_DIALOG_OPEN",payload:B}),agentId:t.id,addedConnectionIds:Z,onAdd:D}),n.jsx(L5,{open:p.settingsDialogOpen,onOpenChange:B=>{B||g({type:"CLOSE_SETTINGS"})},selectedId:p.settingsConnectionId,form:d,connections:h,onAuthenticate:V}),n.jsx(A5,{open:p.shareDialogOpen,onOpenChange:B=>g({type:"SET_SHARE_DIALOG_OPEN",payload:B}),virtualMcp:t}),n.jsx(Gt,{open:L,onOpenChange:v,children:n.jsxs(qt,{className:"w-[90vw] sm:max-w-6xl h-[85vh] flex flex-col p-0 gap-0",children:[n.jsx(_s,{className:"px-6 pt-6 pb-3 border-b border-border shrink-0",children:n.jsx(Ls,{children:"Instructions"})}),n.jsx("div",{className:"flex-1 min-h-0 p-6",children:n.jsx(Ut,{name:"metadata.instructions",control:d.control,render:({field:B})=>n.jsx(Yn,{...B,value:B.value??"",onChange:X=>{B.onChange(X)},onBlur:()=>{B.onBlur(),O()},disabled:u,placeholder:"Define how this agent should behave, what tone to use, any constraints or guidelines...",className:"w-full h-full resize-none text-base text-muted-foreground placeholder:text-muted-foreground/40 leading-relaxed rounded-xl card-shadow px-4 py-3 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0 bg-card border-0",style:{boxShadow:"none"}})})})]})})]})}function ug(t){const e=U.c(9),{virtualMcpId:s,hideOwnTitle:i}=t,r=Vt(),{org:o}=Ge(),a=Ts(s);if(!a){let d;return e[0]!==r||e[1]!==o.slug?(d=n.jsx("div",{className:"flex h-full w-full bg-background",children:n.jsx(Qr,{title:"Space not found",description:"This space may have been deleted or you may not have access.",actions:n.jsx(re,{variant:"outline",onClick:()=>r({to:"/$org",params:{org:o.slug}}),children:"Back to spaces"})})}),e[0]=r,e[1]=o.slug,e[2]=d):d=e[2],d}let l;e[3]!==a?(l=Ao(a)?.connectionId??"",e[3]=a,e[4]=l):l=e[4];let c;return e[5]!==i||e[6]!==l||e[7]!==a?(c=n.jsx(hg,{virtualMcp:a,hideOwnTitle:i},l),e[5]=i,e[6]=l,e[7]=a,e[8]=c):c=e[8],c}function R9(t){const e=U.c(2),{virtualMcpId:s}=t;let i;return e[0]!==s?(i=n.jsx(ug,{virtualMcpId:s,hideOwnTitle:!0}),e[0]=s,e[1]=i):i=e[1],i}const fg={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "};function Zn(t){return t?t.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g,(e,s)=>{if(s.startsWith("#x")||s.startsWith("#X")){const i=Number.parseInt(s.slice(2),16);return Number.isFinite(i)?String.fromCodePoint(i):e}if(s.startsWith("#")){const i=Number.parseInt(s.slice(1),10);return Number.isFinite(i)?String.fromCodePoint(i):e}return fg[s]??e}):""}const mg=10;function pg(t){const e=t;if(e.isError)return null;const s=e.content?.find(r=>r.type==="resource"),i=s?.resource?.text??s?.text;if(!i)return null;try{const r=JSON.parse(i);return typeof r=="string"?r:r&&typeof r=="object"&&"content"in r&&typeof r.content=="string"?r.content:JSON.stringify(r,null,2)}catch{return i}}async function Sr(t,e,s){try{const i=await t.callTool({name:"get_file_contents",arguments:{owner:e.owner,repo:e.repo,path:e.path,...s}});return pg(i)}catch{return null}}function gg(t){const e=Ii(t);return Array.isArray(e)?e.map(s=>{const i=Number(s.additions??0),r=Number(s.changes??i),o=Number(s.deletions??Math.max(0,r-i));return{filename:String(s.filename??""),status:s.status??"modified",additions:i,deletions:o,blobUrl:typeof s.blob_url=="string"?s.blob_url:null}}):[]}async function _g(t,e,s){if(t.length===0)return;let i=0;async function r(){for(;i<t.length;){const o=i++;await s(t[o])}}await Promise.all(Array.from({length:Math.min(e,t.length)},()=>r()))}async function D9(t,e){const s=await t.callTool({name:"pull_request_read",arguments:{method:"get_files",owner:e.owner,repo:e.repo,pullNumber:e.pullNumber,perPage:100}}),i=gg(s).filter(a=>a.filename.length>0),r={},o=e.mergeBaseSha?{sha:e.mergeBaseSha}:{ref:e.base};return await _g(i,mg,async a=>{const l=a.filename;if(a.status==="added"){r[l]={from:null,to:await Sr(t,{owner:e.owner,repo:e.repo,path:l},{sha:e.headSha})};return}if(a.status==="removed"){r[l]={from:await Sr(t,{owner:e.owner,repo:e.repo,path:l},o),to:null};return}const[c,d]=await Promise.all([Sr(t,{owner:e.owner,repo:e.repo,path:l},o),Sr(t,{owner:e.owner,repo:e.repo,path:l},{sha:e.headSha})]);r[l]={from:c,to:d}}),{diffs:r}}function lu(t){return t?Object.keys(t.diffs).length:0}function un(t,e,s,i){return`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/git/${i}`}class cu extends Error{constructor(e,s){super(e),this.status=s,this.name="SandboxGitError"}status}function Lg(t){return t instanceof cu&&(t.status===503||t.status===410||t.status===404)}async function fn(t){const e=await t.json();if(!t.ok)throw new cu(typeof e.error=="string"?e.error:`Request failed (${t.status})`,t.status);return e}function mn(t,e){return fetch(t,{cache:"no-store",...e})}async function da(t,e,s){const i=await mn(un(t,e,s,"status"));return fn(i)}async function Fr(t,e,s,i){const r=i?.base||i?.headSha?{...i.base?{base:i.base}:{},...i.headSha?{headSha:i.headSha}:{}}:void 0,o=await mn(un(t,e,s,"diff"),{method:"POST",headers:r?{"content-type":"application/json"}:void 0,body:r?JSON.stringify(r):void 0});return fn(o)}function vg(t){const e={};for(const[s,i]of Object.entries(t.diffs))du(s)||hu(s)||(e[s]=i);return{...t,diffs:e}}async function I9(t,e,s,i){const r=i?{status:i.status,diff:vg(i.diff)}:{},o=await mn(un(t,e,s,"suggest-commit"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(r)});return fn(o)}async function O9(t,e,s,i){const r=await mn(un(t,e,s,"publish"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({message:i})});await fn(r)}async function xg(t,e,s,i){const r=await mn(un(t,e,s,"rebase"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({base:i})});await fn(r)}function du(t){return t==="blocks.gen.json"||t.endsWith("/blocks.gen.json")}function hu(t){return t==="static/tailwind.css"||t.endsWith("/static/tailwind.css")}function yg(t){if(!t)return!1;const e=Object.keys(t.diffs);return e.length===0?!1:e.every(s=>s===".deco"||s.startsWith(".deco/")||du(s)||hu(s))}const bg="Code changes can't be published directly — use Submit for review";async function M9(t,e,s,i){const r=await mn(un(t,e,s,"discard"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({filepaths:i})});await fn(r)}const Sg="current";function wg(t){return t?.[Sg]??null}function mk(t,e,s){return["sandbox-git-status",t,e,s]}function uu(t){return t?t.modified.length+t.created.length+t.deleted.length+t.not_added.length+t.renamed.length:0}function kc(t){return t?uu(t)>0||t.staged.length>0||t.conflicted.length>0:!1}function fu(t){return t?kc(t)||t.ahead>0||(t.unpushed??0)>0?!0:t.unpushed===void 0&&(t.aheadOfBase??0)>0&&t.tracking==null:!1}function Cg(t,e){return t?fu(t)||e!=null&&Object.keys(e.diffs).length>0:!1}function jg(t,e){return kc(t)?!1:e.openPrFromCommits||!e.commitToOpenPr&&(t?.aheadOfBase??0)>0}function kg(t,e){return{diffs:{...t?.diffs??{},...e?.diffs??{}},...t?.mergeBaseSha?{mergeBaseSha:t.mergeBaseSha}:{}}}function Ng(t){return yg(t)?{allowed:!0,reason:null}:{allowed:!1,reason:bg}}function Tg(t,e,s,i,r,o,a){return["pr-diff",t,e,s,i,r,o,a]}function Eg(t){const e=U.c(26),{orgSlug:s,orgId:i,virtualMcpId:r,branch:o,base:a,headSha:l,pullNumber:c,connectionId:d,owner:h,repo:u,enabled:f}=t,m=f===void 0?!0:f;let p;e[0]!==d||e[1]!==i||e[2]!==s?(p={connectionId:d,orgId:i,orgSlug:s},e[0]=d,e[1]=i,e[2]=s,e[3]=p):p=e[3];const g=Dt(p);let L;e[4]!==a||e[5]!==o||e[6]!==d||e[7]!==l||e[8]!==s||e[9]!==c||e[10]!==r?(L=Tg(s,r,o,a,l,c,d),e[4]=a,e[5]=o,e[6]=d,e[7]=l,e[8]=s,e[9]=c,e[10]=r,e[11]=L):L=e[11];let v;e[12]!==a||e[13]!==o||e[14]!==g||e[15]!==l||e[16]!==s||e[17]!==h||e[18]!==c||e[19]!==u||e[20]!==r?(v=async()=>{try{const x=await Fr(s,r,o,{base:a,headSha:l});return lu(x)>0?x:D9(g,{owner:h,repo:u,pullNumber:c,base:a,headSha:l,mergeBaseSha:x.mergeBaseSha})}catch{return D9(g,{owner:h,repo:u,pullNumber:c,base:a,headSha:l})}},e[12]=a,e[13]=o,e[14]=g,e[15]=l,e[16]=s,e[17]=h,e[18]=c,e[19]=u,e[20]=r,e[21]=v):v=e[21];const y=m&&!!o&&!!l&&!!d;let _;return e[22]!==L||e[23]!==v||e[24]!==y?(_={queryKey:L,queryFn:v,enabled:y,refetchInterval:3e4,staleTime:1e4},e[22]=L,e[23]=v,e[24]=y,e[25]=_):_=e[25],si(_)}o3.config({paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.52.0/min/vs"}});function Ag(){return document.documentElement.classList.contains("dark")?"vs-dark":"vs"}function mu(t){const e=U.c(9),{diff:s,emptyMessage:i,rowClassName:r,onDiscardFile:o}=t,a=i===void 0?"No file changes in the working tree":i,l=r===void 0?"px-6":r,[c,d]=R.useState(null),[h,u]=R.useState(null);let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=Ag(),e[0]=f):f=e[0];const m=f;if(!s||Object.keys(s.diffs).length===0){let g;return e[1]!==a?(g=n.jsx("div",{className:"flex items-center justify-center py-10 text-sm text-muted-foreground",children:a}),e[1]=a,e[2]=g):g=e[2],g}let p;return e[3]!==s.diffs||e[4]!==h||e[5]!==c||e[6]!==o||e[7]!==l?(p=n.jsx("div",{className:"divide-y",children:Object.entries(s.diffs).map(g=>{const[L,v]=g,{from:y,to:_}=v,x=c===L,b=y===null,S=_===null,w=L.startsWith("/")?L.slice(1):L,j=w.lastIndexOf("/"),N=j>=0?w.slice(j+1):w,T=j>=0?w.slice(0,j):null,A=zm(L),k=b?"bg-green-500":S?"bg-red-500":"bg-amber-500";return n.jsxs("div",{children:[n.jsxs("div",{className:ce("flex items-center gap-3 py-3 hover:bg-muted/30",l),children:[n.jsx("button",{type:"button",className:"flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground transition-transform hover:text-foreground",onClick:()=>d(x?null:L),children:n.jsx(Ms,{className:ce("h-3.5 w-3.5 transition-transform",x&&"rotate-90")})}),n.jsx("div",{className:ce("h-2.5 w-2.5 shrink-0 rounded-full",k)}),n.jsx(vh,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:N}),T&&n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:T}),o?n.jsxs(is,{children:[n.jsx(ns,{asChild:!0,children:n.jsx("button",{type:"button",className:"flex h-6 w-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground",children:n.jsx(ln,{className:"h-3.5 w-3.5"})})}),n.jsx(rs,{align:"end",children:n.jsx(We,{className:"text-destructive focus:text-destructive",onSelect:()=>u(L),children:"Discard changes"})})]}):null]}),h===L&&o?n.jsxs("div",{className:ce("flex items-center justify-between gap-3 border-t bg-destructive/5 py-2.5",l),children:[n.jsxs("span",{className:"text-xs text-destructive",children:["Discard all changes to"," ",n.jsx("span",{className:"font-medium",children:N}),"? This cannot be undone."]}),n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[n.jsx(re,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>u(null),children:"Cancel"}),n.jsx(re,{type:"button",size:"sm",className:"h-7 bg-destructive px-2 text-xs text-destructive-foreground hover:bg-destructive/90",onClick:()=>{u(null),o(L)},children:"Discard"})]})]}):null,x&&n.jsx("div",{className:"border-t",children:n.jsx(a3,{original:y??"",modified:_??"",language:A,theme:m,height:"380px",options:{readOnly:!0,renderSideBySide:!1,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:12}})})]},L)})}),e[3]=s.diffs,e[4]=h,e[5]=c,e[6]=o,e[7]=l,e[8]=p):p=e[8],p}function Pg(t){const e=U.c(4),{diffQuery:s}=t;if(s.isLoading){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-muted-foreground",children:[n.jsx(Ue,{className:"h-4 w-4 animate-spin"}),n.jsx("span",{className:"text-sm",children:"Loading changes…"})]}),e[0]=r):r=e[0],r}if(s.isError){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("div",{className:"py-10 text-sm text-destructive",children:"Couldn't load PR changes."}),e[1]=r):r=e[1],r}let i;return e[2]!==s.data?(i=n.jsx(mu,{diff:s.data,rowClassName:"px-0",emptyMessage:"No committed changes in this pull request"}),e[2]=s.data,e[3]=i):i=e[3],i}const Mi="The user clicked this action deliberately — execute directly. Do not call user_ask unless you hit an actual problem outside the scope of this intent (missing auth, unresolvable conflict, a check with multiple plausible fixes).";function Rg(t){return`Reopen PR #${t.prNumber}. ${Mi}`}function Dg(t){return`Rebase \`${t.branch}\` on the latest base and force-push with --force-with-lease. ${Mi}`}function Ig(t){return`Re-run the \`${t.checkName}\` check on PR #${t.prNumber}. If an empty commit is needed to retrigger CI, create and push one. ${Mi}`}function Og(t){const e=(t.failingChecks??[]).map(s=>`\`${s}\``).join(", ");return`PR #${t.prNumber} has failing checks: ${e}. For each: read the logs, diagnose the root cause, apply the smallest fix that makes it pass, commit, and push. ${Mi}`}function Mg(t){return`Mark PR #${t.prNumber} ready for review. ${Mi}`}function Bg(t){return`Read the unresolved review threads on PR #${t.prNumber}. For each thread: understand the reviewer's ask, apply the needed changes, commit, push, reply explaining what changed, and resolve the thread. If a comment is a question that doesn't need a code change, reply with the answer and resolve. ${Mi}`}function $g(t){return`Review PR #${t.prNumber}. Read the full diff, analyze every changed file for correctness, security, code quality, and alignment with the repo's patterns. Post specific line-level review comments on concerns, then submit an overall review (approve / request changes / comment) with a concise summary. Do not modify the code — this is a read-and-comment pass. ${Mi}`}function zg(t){const e=U.c(24),{pr:s,connectionId:i,owner:r,repo:o}=t,{org:a}=Ge(),l=Ti();let c;e[0]!==i||e[1]!==a.id||e[2]!==a.slug||e[3]!==r||e[4]!==s.number||e[5]!==o?(c={orgId:a.id,orgSlug:a.slug,connectionId:i,owner:r,repo:o,prNumber:s.number},e[0]=i,e[1]=a.id,e[2]=a.slug,e[3]=r,e[4]=s.number,e[5]=o,e[6]=c):c=e[6];const d=Oh(c);let h;e[7]!==l||e[8]!==s.number?(h=L=>l.sendMessage({parts:[{type:"text",text:Ig({prNumber:s.number,checkName:L})}]}),e[7]=l,e[8]=s.number,e[9]=h):h=e[9];const u=h;if(d.isLoading){let L;return e[10]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading checks…"}),e[10]=L):L=e[10],L}if(d.isError){let L;return e[11]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx("div",{className:"text-sm text-destructive",children:"Couldn't load check runs."}),e[11]=L):L=e[11],L}let f;e[12]!==d.data?(f=d.data??[],e[12]=d.data,e[13]=f):f=e[13];const m=f;if(m.length===0){let L;return e[14]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx("div",{className:"text-sm text-muted-foreground",children:"No check runs on the PR head commit."}),e[14]=L):L=e[14],L}let p;if(e[15]!==l||e[16]!==m||e[17]!==u){let L;e[19]!==l||e[20]!==u?(L=v=>n.jsxs("li",{className:"flex items-center justify-between gap-2 rounded px-2 py-1.5 text-sm hover:bg-muted",children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(Fg,{check:v}),n.jsx("span",{className:"truncate",children:v.name}),v.durationMs!=null&&n.jsx("span",{className:"text-xs text-muted-foreground",children:Hg(v.durationMs)})]}),n.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[v.htmlUrl&&n.jsx("a",{href:v.htmlUrl,target:"_blank",rel:"noreferrer",className:"inline-flex h-7 items-center justify-center rounded px-2 text-xs text-muted-foreground hover:bg-background",title:"View run",children:n.jsx(ri,{className:"h-3.5 w-3.5"})}),v.conclusion==="failure"&&n.jsx(re,{size:"sm",variant:"ghost",disabled:l.isStreaming,onClick:()=>u(v.name),children:"Re-run"})]})]},v.id),e[19]=l,e[20]=u,e[21]=L):L=e[21],p=m.map(L),e[15]=l,e[16]=m,e[17]=u,e[18]=p}else p=e[18];let g;return e[22]!==p?(g=n.jsx("ul",{className:"flex flex-col gap-0.5",children:p}),e[22]=p,e[23]=g):g=e[23],g}function Fg(t){const e=U.c(5),{check:s}=t;if(s.status!=="completed"){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("span",{className:"text-muted-foreground","aria-label":"In progress",children:"○"}),e[0]=o):o=e[0],o}if(s.conclusion==="success"){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("span",{className:"text-success","aria-label":"Success",children:"✓"}),e[1]=o):o=e[1],o}if(s.conclusion==="failure"){let o;return e[2]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("span",{className:"text-destructive","aria-label":"Failure",children:"✗"}),e[2]=o):o=e[2],o}const i=s.conclusion??"—";let r;return e[3]!==i?(r=n.jsx("span",{className:"text-muted-foreground","aria-label":i,children:"—"}),e[3]=i,e[4]=r):r=e[4],r}function Hg(t){const e=Math.round(t/1e3);return e<60?`${e}s`:`${Math.round(e/60)}m`}var vs="Accordion",Ug=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[Nc,Kg,Wg]=Zf(vs),[Fo]=Qf(vs,[Wg,zd]),Tc=zd(),pu=Kt.forwardRef((t,e)=>{const{type:s,...i}=t,r=i,o=i;return n.jsx(Nc.Provider,{scope:t.__scopeAccordion,children:s==="multiple"?n.jsx(Yg,{...o,ref:e}):n.jsx(qg,{...r,ref:e})})});pu.displayName=vs;var[gu,Vg]=Fo(vs),[_u,Gg]=Fo(vs,{collapsible:!1}),qg=Kt.forwardRef((t,e)=>{const{value:s,defaultValue:i,onValueChange:r=()=>{},collapsible:o=!1,...a}=t,[l,c]=Nd({prop:s,defaultProp:i??"",onChange:r,caller:vs});return n.jsx(gu,{scope:t.__scopeAccordion,value:Kt.useMemo(()=>l?[l]:[],[l]),onItemOpen:c,onItemClose:Kt.useCallback(()=>o&&c(""),[o,c]),children:n.jsx(_u,{scope:t.__scopeAccordion,collapsible:o,children:n.jsx(Lu,{...a,ref:e})})})}),Yg=Kt.forwardRef((t,e)=>{const{value:s,defaultValue:i,onValueChange:r=()=>{},...o}=t,[a,l]=Nd({prop:s,defaultProp:i??[],onChange:r,caller:vs}),c=Kt.useCallback(h=>l((u=[])=>[...u,h]),[l]),d=Kt.useCallback(h=>l((u=[])=>u.filter(f=>f!==h)),[l]);return n.jsx(gu,{scope:t.__scopeAccordion,value:a,onItemOpen:c,onItemClose:d,children:n.jsx(_u,{scope:t.__scopeAccordion,collapsible:!0,children:n.jsx(Lu,{...o,ref:e})})})}),[Jg,Ho]=Fo(vs),Lu=Kt.forwardRef((t,e)=>{const{__scopeAccordion:s,disabled:i,dir:r,orientation:o="vertical",...a}=t,l=Kt.useRef(null),c=e2(l,e),d=Kg(s),u=t2(r)==="ltr",f=s2(t.onKeyDown,m=>{if(!Ug.includes(m.key))return;const p=m.target,g=d().filter(j=>!j.ref.current?.disabled),L=g.findIndex(j=>j.ref.current===p),v=g.length;if(L===-1)return;m.preventDefault();let y=L;const _=0,x=v-1,b=()=>{y=L+1,y>x&&(y=_)},S=()=>{y=L-1,y<_&&(y=x)};switch(m.key){case"Home":y=_;break;case"End":y=x;break;case"ArrowRight":o==="horizontal"&&(u?b():S());break;case"ArrowDown":o==="vertical"&&b();break;case"ArrowLeft":o==="horizontal"&&(u?S():b());break;case"ArrowUp":o==="vertical"&&S();break}const w=y%v;g[w].ref.current?.focus()});return n.jsx(Jg,{scope:s,disabled:i,direction:r,orientation:o,children:n.jsx(Nc.Slot,{scope:s,children:n.jsx(kd.div,{...a,"data-orientation":o,ref:c,onKeyDown:i?void 0:f})})})}),po="AccordionItem",[Xg,Ec]=Fo(po),vu=Kt.forwardRef((t,e)=>{const{__scopeAccordion:s,value:i,...r}=t,o=Ho(po,s),a=Vg(po,s),l=Tc(s),c=i2(),d=i&&a.value.includes(i)||!1,h=o.disabled||t.disabled;return n.jsx(Xg,{scope:s,open:d,disabled:h,triggerId:c,children:n.jsx(rm,{"data-orientation":o.orientation,"data-state":Cu(d),...l,...r,ref:e,disabled:h,open:d,onOpenChange:u=>{u?a.onItemOpen(i):a.onItemClose(i)}})})});vu.displayName=po;var xu="AccordionHeader",yu=Kt.forwardRef((t,e)=>{const{__scopeAccordion:s,...i}=t,r=Ho(vs,s),o=Ec(xu,s);return n.jsx(kd.h3,{"data-orientation":r.orientation,"data-state":Cu(o.open),"data-disabled":o.disabled?"":void 0,...i,ref:e})});yu.displayName=xu;var qa="AccordionTrigger",bu=Kt.forwardRef((t,e)=>{const{__scopeAccordion:s,...i}=t,r=Ho(vs,s),o=Ec(qa,s),a=Gg(qa,s),l=Tc(s);return n.jsx(Nc.ItemSlot,{scope:s,children:n.jsx(nm,{"aria-disabled":o.open&&!a.collapsible||void 0,"data-orientation":r.orientation,id:o.triggerId,...l,...i,ref:e})})});bu.displayName=qa;var Su="AccordionContent",wu=Kt.forwardRef((t,e)=>{const{__scopeAccordion:s,...i}=t,r=Ho(vs,s),o=Ec(Su,s),a=Tc(s);return n.jsx(om,{role:"region","aria-labelledby":o.triggerId,"data-orientation":r.orientation,...a,...i,ref:e,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...t.style}})});wu.displayName=Su;function Cu(t){return t?"open":"closed"}var Zg=pu,Qg=vu,e_=yu,t_=bu,s_=wu;function i_(t){const e=U.c(4);let s;e[0]!==t?({...s}=t,e[0]=t,e[1]=s):s=e[1];let i;return e[2]!==s?(i=n.jsx(Zg,{"data-slot":"accordion",...s}),e[2]=s,e[3]=i):i=e[3],i}function n_(t){const e=U.c(8);let s,i;e[0]!==t?({className:s,...i}=t,e[0]=t,e[1]=s,e[2]=i):(s=e[1],i=e[2]);let r;e[3]!==s?(r=ce("border-b last:border-b-0",s),e[3]=s,e[4]=r):r=e[4];let o;return e[5]!==i||e[6]!==r?(o=n.jsx(Qg,{"data-slot":"accordion-item",className:r,...i}),e[5]=i,e[6]=r,e[7]=o):o=e[7],o}function r_(t){const e=U.c(11);let s,i,r;e[0]!==t?({className:i,children:s,...r}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r):(s=e[1],i=e[2],r=e[3]);let o;e[4]!==i?(o=ce("focus-visible:border-ring focus-visible:ring-ring/20 flex flex-1 items-center justify-between gap-4 py-4 text-left text-sm font-medium transition-all outline-none hover:bg-accent/50 focus-visible:ring-[2px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-90",i),e[4]=i,e[5]=o):o=e[5];let a;e[6]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(Ms,{className:"text-muted-foreground pointer-events-none size-4 shrink-0 transition-transform duration-200"}),e[6]=a):a=e[6];let l;return e[7]!==s||e[8]!==r||e[9]!==o?(l=n.jsx(e_,{className:"flex",children:n.jsxs(t_,{"data-slot":"accordion-trigger",className:o,...r,children:[s,a]})}),e[7]=s,e[8]=r,e[9]=o,e[10]=l):l=e[10],l}function o_(t){const e=U.c(12);let s,i,r;e[0]!==t?({className:i,children:s,...r}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r):(s=e[1],i=e[2],r=e[3]);let o;e[4]!==i?(o=ce("pt-0 pb-4",i),e[4]=i,e[5]=o):o=e[5];let a;e[6]!==s||e[7]!==o?(a=n.jsx("div",{className:o,children:s}),e[6]=s,e[7]=o,e[8]=a):a=e[8];let l;return e[9]!==r||e[10]!==a?(l=n.jsx(s_,{"data-slot":"accordion-content",className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm",...r,children:a}),e[9]=r,e[10]=a,e[11]=l):l=e[11],l}function a_(t){const e=U.c(10),{comments:s,isLoading:i,isError:r}=t;if(i||r||!s||s.length===0)return null;const o=s.length===1?"":"s";let a;e[0]!==s.length||e[1]!==o?(a=n.jsxs(r_,{className:"py-3 text-sm font-medium",children:[s.length," comment",o]}),e[0]=s.length,e[1]=o,e[2]=a):a=e[2];let l;e[3]!==s?(l=s.map(l_),e[3]=s,e[4]=l):l=e[4];let c;e[5]!==l?(c=n.jsx(o_,{className:"space-y-3 pb-3",children:l}),e[5]=l,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=n.jsx(i_,{type:"single",collapsible:!0,className:"border-t border-border",children:n.jsxs(n_,{value:"comments",className:"border-b-0",children:[a,c]})}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d}function l_(t){return n.jsxs("div",{className:"rounded-md border border-border p-3",children:[n.jsxs("div",{className:"mb-1 text-xs text-muted-foreground",children:["@",t.author," · ",c_(t.createdAt)]}),n.jsx(ql,{id:`pr-comment-${t.id}`,text:Zn(t.body)})]},t.id)}function c_(t){if(!t)return"";const e=new Date(t).getTime();if(!Number.isFinite(e))return"";const s=Date.now()-e;if(s<0)return"just now";const i=Math.floor(s/864e5);if(i>0)return`${i}d ago`;const r=Math.floor(s/36e5);if(r>0)return`${r}h ago`;const o=Math.floor(s/6e4);return`${Math.max(1,o)}m ago`}function d_(t){const e=U.c(19),{pr:s,connectionId:i,owner:r,repo:o}=t,{org:a}=Ge();let l;e[0]!==i||e[1]!==a.id||e[2]!==a.slug||e[3]!==r||e[4]!==s.number||e[5]!==o?(l={orgId:a.id,orgSlug:a.slug,connectionId:i,owner:r,repo:o,prNumber:s.number},e[0]=i,e[1]=a.id,e[2]=a.slug,e[3]=r,e[4]=s.number,e[5]=o,e[6]=l):l=e[6];const c=Up(l);let d;e[7]!==s.body||e[8]!==s.number?(d=s.body&&n.jsx("div",{className:"text-sm",children:n.jsx(ql,{id:`pr-body-${s.number}`,text:Zn(s.body)})}),e[7]=s.body,e[8]=s.number,e[9]=d):d=e[9];let h;e[10]!==c.data?(h=c.data??[],e[10]=c.data,e[11]=h):h=e[11];let u;e[12]!==c.isError||e[13]!==c.isLoading||e[14]!==h?(u=n.jsx(a_,{comments:h,isLoading:c.isLoading,isError:c.isError}),e[12]=c.isError,e[13]=c.isLoading,e[14]=h,e[15]=u):u=e[15];let f;return e[16]!==d||e[17]!==u?(f=n.jsxs("div",{className:"space-y-8",children:[d,u]}),e[16]=d,e[17]=u,e[18]=f):f=e[18],f}function h_(t){const e=U.c(68),{pr:s,virtualMcpId:i,branch:r,connectionId:o,owner:a,repo:l}=t,{org:c}=Ge();let d;e[0]!==r||e[1]!==o||e[2]!==c.id||e[3]!==c.slug||e[4]!==a||e[5]!==s.base||e[6]!==s.headSha||e[7]!==s.number||e[8]!==l||e[9]!==i?(d={orgSlug:c.slug,orgId:c.id,virtualMcpId:i,branch:r,base:s.base,headSha:s.headSha,pullNumber:s.number,connectionId:o,owner:a,repo:l},e[0]=r,e[1]=o,e[2]=c.id,e[3]=c.slug,e[4]=a,e[5]=s.base,e[6]=s.headSha,e[7]=s.number,e[8]=l,e[9]=i,e[10]=d):d=e[10];const h=Eg(d);let u;e[11]!==h.data?(u=h.data?lu(h.data):void 0,e[11]=h.data,e[12]=u):u=e[12];const f=u,[m,p]=R.useState("changes");let g;e[13]!==s.title?(g=Zn(s.title),e[13]=s.title,e[14]=g):g=e[14];let L;e[15]!==g?(L=n.jsx("h1",{className:"text-lg font-semibold leading-tight",children:g}),e[15]=g,e[16]=L):L=e[16];const v=`Open PR #${s.number} on GitHub`;let y;e[17]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(ri,{className:"h-3.5 w-3.5"}),e[17]=y):y=e[17];let _;e[18]!==s.htmlUrl||e[19]!==s.number||e[20]!==v?(_=n.jsxs("a",{href:s.htmlUrl,target:"_blank",rel:"noreferrer","aria-label":v,className:"inline-flex items-center gap-1 hover:text-foreground",children:["PR #",s.number,y]}),e[18]=s.htmlUrl,e[19]=s.number,e[20]=v,e[21]=_):_=e[21];let x;e[22]!==s.author?(x=s.author?n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"·"}),n.jsxs("span",{children:["@",s.author]})]}):null,e[22]=s.author,e[23]=x):x=e[23];let b;e[24]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx("span",{children:"·"}),e[24]=b):b=e[24];let S;e[25]!==s.base?(S=n.jsx("span",{className:"font-mono text-xs",children:s.base}),e[25]=s.base,e[26]=S):S=e[26];let w;e[27]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx("span",{children:"←"}),e[27]=w):w=e[27];let j;e[28]!==s.head?(j=n.jsx("span",{className:"font-mono text-xs",children:s.head}),e[28]=s.head,e[29]=j):j=e[29];let N;e[30]!==S||e[31]!==j||e[32]!==_||e[33]!==x?(N=n.jsxs("div",{className:"flex flex-wrap items-center gap-x-1.5 text-sm text-muted-foreground",children:[_,x,b,S,w,j]}),e[30]=S,e[31]=j,e[32]=_,e[33]=x,e[34]=N):N=e[34];let T;e[35]!==N||e[36]!==L?(T=n.jsx("div",{className:"shrink-0 space-y-3 pb-4",children:n.jsxs("div",{className:"space-y-1",children:[L,N]})}),e[35]=N,e[36]=L,e[37]=T):T=e[37];let A;e[38]===Symbol.for("react.memo_cache_sentinel")?(A=V=>p(V),e[38]=A):A=e[38];let k;e[39]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(Js,{value:"description",className:"px-3 text-xs",children:"Description"}),e[39]=k):k=e[39];const C=f!==void 0?` ${f}`:"";let I;e[40]!==C?(I=n.jsxs(Js,{value:"changes",className:"px-3 text-xs",children:["Changes",C]}),e[40]=C,e[41]=I):I=e[41];let E;e[42]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx(Js,{value:"checks",className:"px-3 text-xs",children:"Checks"}),e[42]=E):E=e[42];let O;e[43]!==I?(O=n.jsxs(Do,{className:"h-8 w-fit max-w-[600px] shrink-0",variant:"pill",children:[k,I,E]}),e[43]=I,e[44]=O):O=e[44];let P;e[45]!==o||e[46]!==a||e[47]!==s||e[48]!==l?(P=n.jsx(Gi,{value:"description",className:"mt-0",children:n.jsx(d_,{pr:s,connectionId:o,owner:a,repo:l})}),e[45]=o,e[46]=a,e[47]=s,e[48]=l,e[49]=P):P=e[49];let D;e[50]!==h?(D=n.jsx(Gi,{value:"changes",className:"mt-0",children:n.jsx(Pg,{diffQuery:h})}),e[50]=h,e[51]=D):D=e[51];let M;e[52]!==o||e[53]!==a||e[54]!==s||e[55]!==l?(M=n.jsx(Gi,{value:"checks",className:"mt-0",children:n.jsx(zg,{pr:s,connectionId:o,owner:a,repo:l})}),e[52]=o,e[53]=a,e[54]=s,e[55]=l,e[56]=M):M=e[56];let z;e[57]!==P||e[58]!==D||e[59]!==M?(z=n.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto pt-5",children:[P,D,M]}),e[57]=P,e[58]=D,e[59]=M,e[60]=z):z=e[60];let F;e[61]!==m||e[62]!==O||e[63]!==z?(F=n.jsxs(Io,{value:m,onValueChange:A,className:"flex min-h-0 flex-1 flex-col",children:[O,z]}),e[61]=m,e[62]=O,e[63]=z,e[64]=F):F=e[64];let $;return e[65]!==T||e[66]!==F?($=n.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[T,F]}),e[65]=T,e[66]=F,e[67]=$):$=e[67],$}function u_(t){const e=U.c(5),{pr:s}=t,i=`Open PR #${s.number} on GitHub`;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(ri,{className:"h-4 w-4 text-muted-foreground"}),e[0]=r):r=e[0];let o;return e[1]!==s.htmlUrl||e[2]!==s.number||e[3]!==i?(o=n.jsx("div",{className:"flex h-12 items-center border-b border-border px-4 shrink-0",children:n.jsxs("a",{href:s.htmlUrl,target:"_blank",rel:"noreferrer","aria-label":i,className:"inline-flex items-center gap-1.5 text-base font-medium text-foreground hover:underline",children:["PR #",s.number,r]})}),e[1]=s.htmlUrl,e[2]=s.number,e[3]=i,e[4]=o):o=e[4],o}function f_(t){const e=U.c(10),{virtualMcpId:s}=t,{org:i}=Ge(),r=Ts(s),{currentBranch:o}=$s(),a=r?.metadata?.githubRepo??null;if(!a?.connectionId){let c;return e[0]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("div",{className:"flex h-full items-center justify-center p-8 text-sm text-muted-foreground",children:"This virtualmcp is not linked to a GitHub repository."}),e[0]=c):c=e[0],c}if(!o){let c;return e[1]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-8 text-sm",children:[n.jsx(No,{className:"h-6 w-6 text-muted-foreground"}),n.jsx("div",{className:"text-muted-foreground",children:"No branch selected."}),n.jsx("div",{className:"text-xs text-muted-foreground",children:"Pick a branch from the header to see PR status."})]}),e[1]=c):c=e[1],c}let l;return e[2]!==o||e[3]!==a.connectionId||e[4]!==a.name||e[5]!==a.owner||e[6]!==i.id||e[7]!==i.slug||e[8]!==s?(l=n.jsx(m_,{orgId:i.id,orgSlug:i.slug,virtualMcpId:s,connectionId:a.connectionId,owner:a.owner,repo:a.name,branch:o}),e[2]=o,e[3]=a.connectionId,e[4]=a.name,e[5]=a.owner,e[6]=i.id,e[7]=i.slug,e[8]=s,e[9]=l):l=e[9],l}function m_(t){const e=U.c(47),{orgId:s,orgSlug:i,virtualMcpId:r,connectionId:o,owner:a,repo:l,branch:c}=t;let d;e[0]!==c||e[1]!==o||e[2]!==s||e[3]!==i||e[4]!==a||e[5]!==l?(d={orgId:s,orgSlug:i,connectionId:o,owner:a,repo:l,branch:c},e[0]=c,e[1]=o,e[2]=s,e[3]=i,e[4]=a,e[5]=l,e[6]=d):d=e[6];const{data:h,isLoading:u,isError:f}=hc(d),m=p_;if(u){let _;return e[7]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading PR state…"}),e[7]=_):_=e[7],_}if(f){let _;return e[8]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx("div",{className:"p-4 text-sm text-destructive",children:"Couldn't load PR state. The GitHub connection may be broken."}),e[8]=_):_=e[8],_}const p=`https://github.com/${a}/${l}/tree/${c}`;if(h&&h.state==="closed"){let _;e[9]!==h?(_=n.jsx(u_,{pr:h}),e[9]=h,e[10]=_):_=e[10];const x=h.merged?"✓ Merged":"✗ Closed";let b;e[11]!==h.mergedAt?(b=h.mergedAt&&n.jsxs(n.Fragment,{children:[" · ",new Date(h.mergedAt).toLocaleDateString()]}),e[11]=h.mergedAt,e[12]=b):b=e[12];let S;e[13]!==h.author?(S=h.author&&n.jsxs(n.Fragment,{children:[" · by @",h.author]}),e[13]=h.author,e[14]=S):S=e[14];let w;e[15]!==h.base||e[16]!==x||e[17]!==b||e[18]!==S?(w=n.jsxs("div",{className:"text-sm text-success",children:[x," into ",h.base,b,S]}),e[15]=h.base,e[16]=x,e[17]=b,e[18]=S,e[19]=w):w=e[19];let j;e[20]!==h.title?(j=Zn(h.title),e[20]=h.title,e[21]=j):j=e[21];let N;e[22]!==j?(N=n.jsx("h1",{className:"text-lg font-semibold",children:j}),e[22]=j,e[23]=N):N=e[23];let T;e[24]!==h.body||e[25]!==h.number?(T=h.body&&n.jsx("div",{className:"rounded-md border border-border bg-muted/30 p-3 text-sm",children:n.jsx(ql,{id:`pr-body-${h.number}`,text:Zn(h.body)})}),e[24]=h.body,e[25]=h.number,e[26]=T):T=e[26];let A;e[27]!==w||e[28]!==N||e[29]!==T?(A=n.jsxs("div",{className:"flex flex-col gap-4 p-4 overflow-auto",children:[w,N,T]}),e[27]=w,e[28]=N,e[29]=T,e[30]=A):A=e[30];let k;return e[31]!==_||e[32]!==A?(k=n.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[_,A]}),e[31]=_,e[32]=A,e[33]=k):k=e[33],k}if(h&&h.state==="open"){let _;return e[34]!==c||e[35]!==o||e[36]!==a||e[37]!==h||e[38]!==l||e[39]!==r?(_=n.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:n.jsx("div",{className:"flex min-h-0 w-full flex-1 flex-col px-6 py-5",children:n.jsx(h_,{pr:h,virtualMcpId:r,branch:c,connectionId:o,owner:a,repo:l})})}),e[34]=c,e[35]=o,e[36]=a,e[37]=h,e[38]=l,e[39]=r,e[40]=_):_=e[40],_}let g;e[41]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("div",{className:"rounded-md border border-border bg-muted/30 p-4 text-sm",children:`This branch doesn't have an open pull request. Click "Submit for review" in the header to open one; the agent will draft the title and summary from the current state of the branch.`}),e[41]=g):g=e[41];let L;e[42]!==p?(L=()=>m(p),e[42]=p,e[43]=L):L=e[43];let v;e[44]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(ri,{className:"mr-1.5 h-4 w-4"}),e[44]=v):v=e[44];let y;return e[45]!==L?(y=n.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[g,n.jsx("div",{className:"flex items-center gap-2",children:n.jsxs(re,{size:"sm",variant:"outline",onClick:L,children:[v,"Open branch on GitHub"]})})]}),e[45]=L,e[46]=y):y=e[46],y}function p_(t){window.open(t,"_blank","noopener,noreferrer")}const ju=R.createContext(null);function g_(t){const e=U.c(6),{children:s}=t,[i,r]=R.useState(!1),[o,a]=R.useState(null);let l;e[0]!==i||e[1]!==o?(l={open:i,setOpen:r,slotEl:o,setSlotEl:a},e[0]=i,e[1]=o,e[2]=l):l=e[2];let c;return e[3]!==s||e[4]!==l?(c=n.jsx(ju,{value:l,children:s}),e[3]=s,e[4]=l,e[5]=c):c=e[5],c}function ku(){return R.use(ju)}const __=240,L_=640,v_=384;function Nu(t){const e=U.c(12),s=__,i=L_,[r,o]=R.useState(v_),a=R.useRef(!1),l=R.useRef(0),c=R.useRef(0);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{a.current=!1},e[0]=d):d=e[0];const h=d;let u;e[1]!==r?(u=g=>{a.current=!0,l.current=g.clientX,c.current=r,g.currentTarget.setPointerCapture(g.pointerId)},e[1]=r,e[2]=u):u=e[2];let f;e[3]!==i||e[4]!==s?(f=g=>{if(!a.current)return;const L=g.clientX-l.current;o(Math.max(s,Math.min(i,c.current+L)))},e[3]=i,e[4]=s,e[5]=f):f=e[5];let m;e[6]!==u||e[7]!==f?(m={onPointerDown:u,onPointerMove:f,onPointerUp:h,onPointerCancel:h},e[6]=u,e[7]=f,e[8]=m):m=e[8];let p;return e[9]!==m||e[10]!==r?(p={width:r,setWidth:o,dividerProps:m},e[9]=m,e[10]=r,e[11]=p):p=e[11],p}const x_=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function y_(t){return t.includes("matchers")||t.includes("Match")}function Tu(t,e){const s=t.__resolveType;return typeof s!="string"||!s||x_.has(s)?!1:e?e4(e,s):y_(s)}function b_(t,e){const s=[];for(const[i,r]of Object.entries(e)){if(i.includes("/")||!ks(i)||Bo(i)||!r||typeof r!="object"||Array.isArray(r))continue;const o=r;Tu(o,t)&&s.push({blockKey:i,matcherResolveType:o.__resolveType??"",name:typeof o.name=="string"?o.name:void 0})}return s.sort((i,r)=>(i.name??i.blockKey).localeCompare(r.name??r.blockKey))}function pn(t,e,s){if(!t)return!1;const i=t.__resolveType;if(typeof i!="string"||!ks(i)||!Object.hasOwn(e,i))return!1;const r=e[i];return!r||typeof r!="object"||Array.isArray(r)?!1:Tu(r,s)}function S_(t,e,s){return pn(t,e,s)?t?.__resolveType??null:null}function Eu(t,e,s){if(!t)return null;const i=t.__resolveType??"";if(!i)return null;if(pn(t,e,s)){const a=e[i]??{},l=a.__resolveType??i,{__resolveType:c,name:d,...h}=a;return{resolveType:l,data:h,blockKey:i}}const{__resolveType:r,...o}=t;return{resolveType:i,data:o}}function Au(t,e,s){const i=Eu(t,e,s);return i?{__resolveType:i.resolveType,...i.data}:{__resolveType:""}}function pk(t,e,s){if(t)return pn(t,e,s)?Au(t,e,s):t}function w_(t,e,s,i){if(!t)return"Default";if(pn(t,e,i)){const r=t.__resolveType??"",o=e[r];return zo(r,o)}return s(t)}function gk(t,e,s){return{__resolveType:t,...e,name:s}}function C_(t){return{__resolveType:t}}function _k(t,e,s){const i=Eu(t,e,s);return i?{resolveType:i.resolveType,formValue:i.data}:{resolveType:"",formValue:{}}}const B9="x-deco-matchers-override";function Pu({pageKey:t,prefix:e,variants:s,selectedIndex:i,decofile:r,meta:o}){if(!t||i<0||i>=s.length)return[];const a=[];for(let l=0;l<=i;l++){const c=s[l];if(!c)continue;const d=c.rule,h=l===i?"1":"0",f=(pn(d,r,o)?S_(d,r,o):null)??`${t}@${e}.${l}.rule`;a.push(`${f}=${h}`)}return a}function Lk(t,e,s,i){return!e.multivariate||e.variants.length<=1?[]:Pu({pageKey:t,prefix:"sections.variants",variants:e.variants,selectedIndex:e.index,decofile:s,meta:i})}function vk({pageKey:t,page:e,sectionIndex:s,sectionLazy:i,mvObj:r,selectedVariantIndex:o,decofile:a,meta:l}){if(s<0)return[];const d=`${e.multivariate?`sections.variants.${e.index}.value`:"sections"}.${s}${i?".section":""}.variants`,h=Array.isArray(r.variants)?r.variants:[];return Pu({pageKey:t,prefix:d,variants:h,selectedIndex:o,decofile:a,meta:l})}function j_(t,e){if(e.length===0)return t;const s=new URL(t,"http://local");s.searchParams.delete(B9);for(const i of e)s.searchParams.append(B9,i);return t.startsWith("http")?s.toString():`${s.pathname}${s.search}${s.hash}`}function Ru(t,e){return t.map((s,i)=>{const r=s.__resolveType??"",o=At(r);if(!o&&r!==""&&ks(r)&&r in e){const d=e[r],h=typeof d?.name=="string"&&d.name||r.replace(/[-_]/g," ").replace(/\b\w/g,u=>u.toUpperCase())||`Section ${i+1}`;return{index:i,resolveType:r,label:h,isLazy:!1,isSavedBlock:!0}}const a=o?s.section:void 0,l=o?a?.__resolveType??"":r;if(l===Oi||l===fr){const d=o?a:s,h=Array.isArray(d?.variants)?d.variants:[];if(h.length===1&&(h[0]?.rule?.__resolveType??"")===hn){const m=h[0]?.value??{};let p=m.__resolveType??"";const g=At(p);return g&&(p=m.section?.__resolveType??p),{index:i,resolveType:r,label:ut(p)||`Section ${i+1}`,isHidden:!0,isLazy:g}}const u=h[0]?.value?.__resolveType,f=u?ut(u):"Section";return{index:i,resolveType:r,label:`Variants of ${f}`,isMultivariate:!0,isLazy:o}}const c=o?s.section?.__resolveType??r:r;if(o&&c!==""&&ks(c)&&c in e){const d=e[c],h=typeof d?.name=="string"&&d.name||c.replace(/[-_]/g," ").replace(/\b\w/g,u=>u.toUpperCase())||`Section ${i+1}`;return{index:i,resolveType:r,label:h,isLazy:!0,isSavedBlock:!0}}return{index:i,resolveType:r,label:ut(c)||`Section ${i+1}`,isLazy:o}})}const k_="website/sections/Rendering/Lazy.tsx";function Ya(t,e){let s=t,i=typeof s?.__resolveType=="string"?s.__resolveType:"";for(let r=0;i&&r<5;r++){const o=e[i];if(o&&typeof o=="object"&&"__resolveType"in o){const a=o.__resolveType;if(typeof a=="string"&&a&&a!==i){s=o,i=a;continue}}break}if(!i)return[];if(i.includes("flags/multivariate")){const r=Array.isArray(s.variants)?s.variants:[];if(r.length===0||r.every(l=>l?.rule?.__resolveType===hn))return null;const a=[];for(const l of r){const c=l?.value;if(c&&typeof c=="object")for(const d of Ya(c,e)??[])a.includes(d)||a.push(d)}return a}if(i===k_){const r=s.section&&typeof s.section=="object"?Ya(s.section,e):[];return r===null?null:r.length?[i,...r]:[i]}return[i]}function Du(t){const e=t.__resolveType??"";return At(e)?t.section??t:t}function go(t){const r=(At(t.__resolveType??"")?t.section:t)?.variants?.[0];return r?.rule?.__resolveType!==hn?null:r?.value??null}function xk(t){const e=Du(t);return{__resolveType:fr,variants:[{value:e,rule:{__resolveType:hn}}]}}function yk(t){const e=t.__resolveType??"";if(!e)return null;if(At(e))return t.section??null;const s=go(t);return s?At(s.__resolveType??"")?s:{__resolveType:b9,section:Du(s)}:{__resolveType:b9,section:t}}function wr(t){const e=t.__resolveType??"";if(!e)return null;if(At(e)){const s=t.section,i=s?.__resolveType??"";return!i||!s?null:{resolveType:i,data:s}}return{resolveType:e,data:t}}function bk(t){const e=go(t);if(e)return wr(e);if(At(t.__resolveType??"")){const i=t.section;if(!i)return null;const r=go(i);return wr(r||i)}return wr(t)}function Sk(t){return go(t)}const N_=["website/matchers/always.ts","$live/matchers/MatchAlways.ts"];function Ac(t){if(!t)return!1;const e=t.__resolveType??"";return e===""?Object.keys(t).length===0:N_.includes(e)||e.includes("always")}function T_(t){const e=t.variants??[];if(e.length===0)return-1;const s=e.findIndex(i=>Ac(i.rule));return s!==-1?s:e.length-1}function wk(t,e,s){const i=s.variants??[];if(i.length===0)return null;const r=T_(s),o=i[r]?.value;if(!o)return null;const a=structuredClone(o);return e.isLazy?{...t,section:a}:a}function Iu(t,e){return e.isMultivariate?e.isLazy?t.section??null:t:null}function Ck(t,e){return Array.isArray(t.variants)?t.variants.map((s,i)=>({label:e(s.rule)||`Variant ${i+1}`,value:s.value??{},rule:s.rule})):[]}function jk(t,e){const s=t.__resolveType??"";if(!s)return null;if(At(s)){const i=t.section??t,r=i.__resolveType??s;if(!r.includes("/")&&r in e){const o=e[r]??{};return{data:{...o},resolveType:o.__resolveType??r}}return{data:{...i},resolveType:r}}if(!s.includes("/")&&s in e){const i=e[s]??{};return{data:{...i},resolveType:i.__resolveType??s}}return{data:{...t},resolveType:s}}function E_(t,e){const s=t.__resolveType??"";return At(s)?{...t,section:e}:e}function A_(t,e,s){return e.isLazy?{...t,section:s}:s}function kk(t,e,s){const i=[...t.variants??[]],r=i[e];if(!r)return t;const o=r.value??{};return i[e]={...r,value:E_(o,s)},{...t,variants:i}}function Nk(t,e,s){const i=[...t.variants??[]];return i[e]?(i[e]={...i[e],rule:s},{...t,variants:i}):t}function Tk(t,e){const s=[...t.variants??[]],i=s[e];return i?(s.splice(e+1,0,structuredClone(i)),{...t,variants:s}):t}function Ek(t,e,s){const i=[...t.variants??[]];if(e===s||e<0||s<0||e>=i.length||s>=i.length)return t;const[r]=i.splice(e,1);return r?(i.splice(s,0,r),{...t,variants:i}):t}function Ak(t,e){const s=[...t.variants??[]];return s.length<=1?null:(s.splice(e,1),{...t,variants:s})}function Ja(t){return{rule:tn(),value:structuredClone(t)}}function Ou(t,e){return{...e,__resolveType:fr,variants:t}}function Pk(t){return t.isHidden!==!0&&t.isSavedBlock!==!0}function P_(t,e){if(e.isHidden)return null;if(e.isMultivariate){const i=Iu(t,e)?.variants??[],r=i[i.length-1]?.value;return r?structuredClone(r):null}if(e.isLazy){const s=t.section;return s?structuredClone(s):null}return structuredClone(t)}function R_(t,e,s){if(e.isMultivariate||e.isHidden)return null;const i=P_(t,e);if(!i)return null;const r=Ou([Ja(i),Ja(i)]);return e.isLazy?{...t,section:r}:r}function Rk(t,e,s){if(e.isHidden||e.isSavedBlock)return null;if(e.isMultivariate){const r=Iu(t,e);if(!r)return null;const o=r.variants??[],a=o[o.length-1]?.value;if(!a)return null;const l=Ou([...o,Ja(a)],r);return{section:A_(t,e,l),newVariantIndex:o.length}}const i=R_(t,e);return i?{section:i,newVariantIndex:1}:null}const D_=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function Uo(t){return t.anyOfRefs?.some(e=>e.resolveType!==Oi?!1:e.schema?.properties?.variants?.items?.properties?.value?.type==="array")??!1}function _o(t){return!t||typeof t!="object"||Array.isArray(t)?!1:t.__resolveType===Oi}function I_(t){if(!_o(t))return null;const e=t.variants;if(!Array.isArray(e))return null;const s=e[0]?.value;return Array.isArray(s)?s:null}function O_(t,e){if(!_o(t))return e;const s=structuredClone(t),i=[...s.variants??[]];return i.length===0?i.push({rule:tn(),value:e}):i[0]={...i[0],value:e},{...s,variants:i}}function M_(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t;return typeof e.__resolveType=="string"&&D_.has(e.__resolveType)&&typeof e.path=="string"}function Mu(t,e){const i=t[e]?.sections;if(!i||Array.isArray(i))return 1;const r=i;return Array.isArray(r.variants)?r.variants.length:1}function Bu(t,e,s){const r=t[e]?.sections;if(Array.isArray(r))return s===0?r:[];if(r&&typeof r=="object"){const o=r.variants;if(Array.isArray(o)){const a=o[s];return Array.isArray(a?.value)?a.value:[]}}return[]}function Dk(t,e,s){if(Array.isArray(t))return[{label:"Default",sections:t}];if(t&&typeof t=="object"){const i=t;if(Array.isArray(i.variants)){const r=i.variants,o=r.map(c=>w_(c.rule,e,s)),a=o.reduce((c,d)=>(c[d]=(c[d]??0)+1,c),{}),l={};return r.map((c,d)=>{const h=o[d]??`Variant ${d+1}`,u=a[h]??1;let f=h;return u>1&&(l[h]=(l[h]??0)+1,f=`${h} ${l[h]}`),{label:f||`Variant ${d+1}`,sections:Array.isArray(c.value)?c.value:[],rule:c.rule}})}}return[]}function xn(t){return{rule:tn(),value:t}}function Yi(t,e){return{...e,__resolveType:Oi,variants:t}}function B_(t,e){const s=structuredClone(e);if(Array.isArray(t))return Yi([xn(t),xn(s)]);if(t&&typeof t=="object"){const i=t;return Array.isArray(i.variants)?Yi([...i.variants,xn(s)],i):null}return Yi([xn([]),xn(s)])}function Ik(t){const e=t.variants;return Array.isArray(e)?e.length-1:1}function Ok(t,e){const s=t[e];if(!s)return null;const i=[...t];return i.splice(e+1,0,structuredClone(s)),i}function Mk(t,e){if(e.length===0)return Yi([],t);if(e.length===1){const s=e[0],i=s?.rule;if(!Ac(i))return Yi(e,t);if(Array.isArray(s?.value))return s.value}return Yi(e,t)}function $_(t,e){for(const[s,i]of Object.entries(t)){if(!M_(i))continue;const r=i.sections;if(Array.isArray(r)){e(void 0,s,0);continue}if(!r||typeof r!="object")continue;const o=r.variants;if(Array.isArray(o))for(let a=0;a<o.length;a++){const l=o[a];e(l?.rule,s,a)}}}function Bk(t,e,s){let i=0;return $_(t,r=>{if(!r)return;(r.__resolveType??"")===e&&pn(r,t,s)&&i++}),i}function $u(t){return btoa(encodeURIComponent(t))}function z_(t,e,s){const i=new URL(t).origin,r=new URL(`/live/previews/${encodeURIComponent(e)}`,i);return r.searchParams.set("path","/"),r.searchParams.set("pathTemplate","/"),r.searchParams.set("props",$u(JSON.stringify({path:"/",sections:[{__resolveType:s}]}))),r.searchParams.set("__cb",crypto.randomUUID()),r.toString()}function $k(t,e,s,i){const r=new URL(t).origin,o=new URL(`/live/previews/${encodeURIComponent(e)}`,r);o.searchParams.set("__d","");const a=[{__resolveType:"preview",block:s}];return i&&a.push(i),o.searchParams.set("props",$u(JSON.stringify({sections:a}))),o.toString()}const $9={resolveType:"website/pages/Page.tsx",seoResolveType:"website/sections/Seo/SeoV2.tsx"};function Pc(t){return`pages-${encodeURIComponent(t)}-${crypto.randomUUID()}`}function zu(t,e){return{name:t,path:e,sections:[],seo:{__resolveType:$9.seoResolveType},__resolveType:$9.resolveType}}const F_=700;function Ko(t){const e=U.c(21),{orgSlug:s,virtualMcpId:i,branch:r}=t,o=Ni();let a;e[0]!==r||e[1]!==s||e[2]!==i?(a=async u=>{const{blockKey:f,data:m}=u,p=dh(f),g=JSON.stringify(m,null,2),L=await fetch(`/api/${s}/sandbox/${encodeURIComponent(i)}/${encodeURIComponent(r)}/write`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:p,content:g})});if(!L.ok){const v=await L.json().catch(H_);throw new Error(v.error??`Write failed (${L.status})`)}return L.json()},e[0]=r,e[1]=s,e[2]=i,e[3]=a):a=e[3];let l;e[4]!==r||e[5]!==s||e[6]!==o||e[7]!==i?(l=async u=>{const{blockKey:f,data:m}=u,p=`${s}/${i}/${r}`,g=Et.decofile(p);await o.cancelQueries({queryKey:g});const L=o.getQueryData(g);return o.setQueryData(g,v=>({...v??{},[f]:m})),{previous:L,queryKey:g}},e[4]=r,e[5]=s,e[6]=o,e[7]=i,e[8]=l):l=e[8];let c;e[9]!==o?(c=(u,f,m)=>{m?.queryKey&&o.setQueryData(m.queryKey,m.previous)},e[9]=o,e[10]=c):c=e[10];let d;e[11]!==r||e[12]!==s||e[13]!==o||e[14]!==i?(d=(u,f)=>{const{blockKey:m,data:p}=f,g=`${s}/${i}/${r}`;o.setQueryData(Et.decofile(g),L=>({...L??{},[m]:p}))},e[11]=r,e[12]=s,e[13]=o,e[14]=i,e[15]=d):d=e[15];let h;return e[16]!==a||e[17]!==l||e[18]!==c||e[19]!==d?(h={mutationFn:a,onMutate:l,onError:c,onSuccess:d},e[16]=a,e[17]=l,e[18]=c,e[19]=d,e[20]=h):h=e[20],ii(h)}function H_(){return{}}function Fu(t,e){const s=U.c(15),i=Ko(t);let r;s[0]===Symbol.for("react.memo_cache_sentinel")?(r=new Map,s[0]=r):r=s[0];const o=R.useRef(r);let a;s[1]===Symbol.for("react.memo_cache_sentinel")?(a=new Map,s[1]=a):a=s[1];const l=R.useRef(a);let c;s[2]!==e||s[3]!==i?(c=v=>{const y=o.current.get(v);if(!y)return;const _=typeof y=="function"?y():y;o.current.delete(v),_&&i.mutate({blockKey:v,data:_},{onSuccess:()=>e?.onSaved?.(),onError:U_})},s[2]=e,s[3]=i,s[4]=c):c=s[4];const d=c;let h;s[5]!==d?(h=()=>{for(const v of l.current.values())clearTimeout(v);l.current.clear();for(const v of[...o.current.keys()])d(v)},s[5]=d,s[6]=h):h=s[6];const u=h;let f,m;s[7]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{const v=l.current;return()=>{for(const y of v.values())clearTimeout(y)}},m=[],s[7]=f,s[8]=m):(f=s[7],m=s[8]),R.useEffect(f,m);let p;s[9]!==d?(p=(v,y)=>{o.current.set(v,y);const _=l.current.get(v);_&&clearTimeout(_),l.current.set(v,setTimeout(()=>{l.current.delete(v),d(v)},F_))},s[9]=d,s[10]=p):p=s[10];const g=p;let L;return s[11]!==u||s[12]!==g||s[13]!==i.isPending?(L={save:g,flush:u,isPending:i.isPending},s[11]=u,s[12]=g,s[13]=i.isPending,s[14]=L):L=s[14],L}function U_(t){return me.error(`Save failed: ${t.message}`)}function K_(t){const e=U.c(5);let s;e[0]!==t?(s=t??{orgSlug:"",virtualMcpId:"",branch:""},e[0]=t,e[1]=s):s=e[1];const i=Ko(s);let r;return e[2]!==t||e[3]!==i?(r={mutationFn:async o=>{const{name:a,path:l,template:c}=o;if(!t?.virtualMcpId||!t.branch)throw new Error("Sandbox not ready");const d=Pc(a),h=c?{...c,name:a,path:l}:zu(a,l);return await i.mutateAsync({blockKey:d,data:h}),{key:d,name:a,path:l}}},e[2]=t,e[3]=i,e[4]=r):r=e[4],ii(r)}const Zs="__blank__";function Hu(t){const e=U.c(44),{id:s,value:i,onChange:r,templates:o,disabled:a}=t,[l,c]=R.useState(!1);let d;if(e[0]!==o||e[1]!==i){let k;e[3]!==i?(k=C=>C.key===i,e[3]=i,e[4]=k):k=e[4],d=o.find(k),e[0]=o,e[1]=i,e[2]=d}else d=e[2];const h=d,u=h?.name??"Blank page";let f;e[5]!==u?(f=n.jsx("span",{className:"truncate",children:u}),e[5]=u,e[6]=f):f=e[6];let m;e[7]!==h?(m=h?.path?n.jsx("span",{className:"truncate text-muted-foreground",children:h.path}):null,e[7]=h,e[8]=m):m=e[8];let p;e[9]!==f||e[10]!==m?(p=n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[f,m]}),e[9]=f,e[10]=m,e[11]=p):p=e[11];let g;e[12]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(ic,{className:"shrink-0 opacity-50"}),e[12]=g):g=e[12];let L;e[13]!==a||e[14]!==s||e[15]!==l||e[16]!==p?(L=n.jsx(ps,{asChild:!0,children:n.jsxs(re,{id:s,type:"button",variant:"outline",role:"combobox","aria-expanded":l,disabled:a,className:"w-full justify-between font-normal",children:[p,g]})}),e[13]=a,e[14]=s,e[15]=l,e[16]=p,e[17]=L):L=e[17];let v;e[18]===Symbol.for("react.memo_cache_sentinel")?(v={width:"var(--radix-popover-trigger-width)"},e[18]=v):v=e[18];let y;e[19]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(lr,{placeholder:"Search pages…",className:"h-9"}),e[19]=y):y=e[19];let _;e[20]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(cr,{children:"No pages found."}),e[20]=_):_=e[20];let x;e[21]!==r?(x=()=>{r(Zs),c(!1)},e[21]=r,e[22]=x):x=e[22];const b=i===Zs?"opacity-100":"opacity-0";let S;e[23]!==b?(S=ce("ml-auto",b),e[23]=b,e[24]=S):S=e[24];let w;e[25]!==S?(w=n.jsx(Wt,{className:S}),e[25]=S,e[26]=w):w=e[26];let j;e[27]!==x||e[28]!==w?(j=n.jsxs(Xs,{value:"Blank page",onSelect:x,children:["Blank page",w]}),e[27]=x,e[28]=w,e[29]=j):j=e[29];let N;if(e[30]!==r||e[31]!==o||e[32]!==i){let k;e[34]!==r||e[35]!==i?(k=C=>n.jsxs(Xs,{value:`${C.name} ${C.path}`,onSelect:()=>{r(C.key),c(!1)},children:[n.jsxs("div",{className:"flex min-w-0 flex-col",children:[n.jsx("span",{className:"truncate",children:C.name}),n.jsx("span",{className:"truncate text-xs text-muted-foreground",children:C.path})]}),n.jsx(Wt,{className:ce("ml-auto",i===C.key?"opacity-100":"opacity-0")})]},C.key),e[34]=r,e[35]=i,e[36]=k):k=e[36],N=o.map(k),e[30]=r,e[31]=o,e[32]=i,e[33]=N}else N=e[33];let T;e[37]!==j||e[38]!==N?(T=n.jsx(gs,{className:"p-0",style:v,children:n.jsxs(Oo,{children:[y,n.jsxs(dr,{onWheel:W_,children:[_,n.jsxs(Si,{children:[j,N]})]})]})}),e[37]=j,e[38]=N,e[39]=T):T=e[39];let A;return e[40]!==l||e[41]!==T||e[42]!==L?(A=n.jsxs(ms,{open:l,onOpenChange:c,children:[L,T]}),e[40]=l,e[41]=T,e[42]=L,e[43]=A):A=e[43],A}function W_(t){const e=t.deltaMode===1?16:1;t.currentTarget.scrollTop=t.currentTarget.scrollTop+t.deltaY*e}function V_(t){const e=U.c(58),{open:s,onOpenChange:i,isPending:r,error:o,templates:a,onSubmit:l}=t,c=r===void 0?!1:r,[d,h]=R.useState("My New Page"),[u,f]=R.useState("/example-path"),[m,p]=R.useState(Zs),[g,L]=R.useState(null),[v,y]=R.useState(s);s!==v&&(y(s),s&&(h("My New Page"),f("/example-path"),p(Zs),L(null)));const _=!!a?.length;let x;e[0]!==c||e[1]!==i?(x=q=>{!q&&!c&&(L(null),i(!1))},e[0]=c,e[1]=i,e[2]=x):x=e[2];const b=x;let S;e[3]!==c||e[4]!==d||e[5]!==l||e[6]!==u||e[7]!==_||e[8]!==m?(S=async q=>{q.preventDefault();const H=d.trim(),K=u.trim();if(!H||!K||c)return;const B=vc(K);if(B){L(B);return}L(null),await l({name:H,path:K,templateKey:_&&m!==Zs?m:null})},e[3]=c,e[4]=d,e[5]=l,e[6]=u,e[7]=_,e[8]=m,e[9]=S):S=e[9];const w=S,j=g??o;let N;e[10]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx(_s,{children:n.jsx(Ls,{children:"Create new page"})}),e[10]=N):N=e[10];let T;e[11]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx("label",{htmlFor:"new-page-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[11]=T):T=e[11];let A;e[12]===Symbol.for("react.memo_cache_sentinel")?(A=q=>h(q.target.value),e[12]=A):A=e[12];let k;e[13]!==c||e[14]!==d?(k=n.jsxs("div",{className:"space-y-1.5",children:[T,n.jsx(Ke,{id:"new-page-name",value:d,onChange:A,placeholder:"My New Page",autoFocus:!0,disabled:c})]}),e[13]=c,e[14]=d,e[15]=k):k=e[15];let C;e[16]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx("label",{htmlFor:"new-page-path",className:"text-xs font-medium text-muted-foreground",children:"Path"}),e[16]=C):C=e[16];let I;e[17]===Symbol.for("react.memo_cache_sentinel")?(I=q=>f(q.target.value),e[17]=I):I=e[17];let E;e[18]!==c||e[19]!==u?(E=n.jsxs("div",{className:"space-y-1.5",children:[C,n.jsx(Ke,{id:"new-page-path",value:u,onChange:I,placeholder:"/example-path",disabled:c})]}),e[18]=c,e[19]=u,e[20]=E):E=e[20];let O;e[21]!==c||e[22]!==_||e[23]!==m||e[24]!==a?(O=_&&n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("label",{htmlFor:"new-page-template",className:"text-xs font-medium text-muted-foreground",children:"Template"}),n.jsx(Hu,{id:"new-page-template",value:m,onChange:p,templates:a??[],disabled:c})]}),e[21]=c,e[22]=_,e[23]=m,e[24]=a,e[25]=O):O=e[25];let P;e[26]!==j?(P=j&&n.jsx("p",{className:"text-xs text-destructive",children:j}),e[26]=j,e[27]=P):P=e[27];let D;e[28]!==E||e[29]!==O||e[30]!==P||e[31]!==k?(D=n.jsxs("div",{className:"space-y-4 py-4",children:[k,E,O,P]}),e[28]=E,e[29]=O,e[30]=P,e[31]=k,e[32]=D):D=e[32];let M;e[33]!==i?(M=()=>i(!1),e[33]=i,e[34]=M):M=e[34];let z;e[35]!==c||e[36]!==M?(z=n.jsx(re,{type:"button",variant:"outline",onClick:M,disabled:c,children:"Cancel"}),e[35]=c,e[36]=M,e[37]=z):z=e[37];let F;e[38]!==c||e[39]!==d||e[40]!==u?(F=!d.trim()||!u.trim()||c,e[38]=c,e[39]=d,e[40]=u,e[41]=F):F=e[41];let $;e[42]!==c?($=c?n.jsxs(n.Fragment,{children:[n.jsx(Ue,{size:14,className:"animate-spin"}),"Creating…"]}):"Create",e[42]=c,e[43]=$):$=e[43];let V;e[44]!==F||e[45]!==$?(V=n.jsx(re,{type:"submit",disabled:F,children:$}),e[44]=F,e[45]=$,e[46]=V):V=e[46];let J;e[47]!==z||e[48]!==V?(J=n.jsxs(Di,{children:[z,V]}),e[47]=z,e[48]=V,e[49]=J):J=e[49];let Z;e[50]!==w||e[51]!==D||e[52]!==J?(Z=n.jsx(qt,{className:"sm:max-w-md",children:n.jsxs("form",{onSubmit:w,children:[N,D,J]})}),e[50]=w,e[51]=D,e[52]=J,e[53]=Z):Z=e[53];let G;return e[54]!==b||e[55]!==s||e[56]!==Z?(G=n.jsx(Gt,{open:s,onOpenChange:b,children:Z}),e[54]=b,e[55]=s,e[56]=Z,e[57]=G):G=e[57],G}const G_=zr({tag:hs(),id:hs(),classes:hs(),text:hs(),html:hs(),manifestKey:hs().nullable(),componentName:hs().nullable(),parents:hs(),url:hs(),path:hs(),viewport:zr({width:En(),height:En()}),position:zr({x:En(),y:En()})}),q_=`(function() {
|
|
38
|
-
if (window.__visualEditorActive) return;
|
|
39
|
-
window.__visualEditorActive = true;
|
|
40
|
-
|
|
41
|
-
var cursorStyle = document.createElement("style");
|
|
42
|
-
cursorStyle.textContent = "* { cursor: default !important; }";
|
|
43
|
-
document.head.appendChild(cursorStyle);
|
|
44
|
-
|
|
45
|
-
var highlight = document.createElement("div");
|
|
46
|
-
highlight.style.cssText = "position:fixed;pointer-events:none;outline:2px solid #a855f7;background:rgba(168,85,247,0.08);border-radius:2px;z-index:2147483647;display:none;";
|
|
47
|
-
document.body.appendChild(highlight);
|
|
48
|
-
|
|
49
|
-
var badge = document.createElement("div");
|
|
50
|
-
badge.style.cssText = "position:fixed;pointer-events:none;background:#a855f7;color:white;font:11px/1 monospace;padding:2px 6px;border-radius:2px;z-index:2147483647;display:none;white-space:nowrap;max-width:240px;overflow:hidden;text-overflow:ellipsis;";
|
|
51
|
-
document.body.appendChild(badge);
|
|
52
|
-
|
|
53
|
-
var lastTarget = null;
|
|
54
|
-
var rafPending = false;
|
|
55
|
-
var moveHandler = function(e) {
|
|
56
|
-
if (rafPending) return;
|
|
57
|
-
rafPending = true;
|
|
58
|
-
var target = e.target;
|
|
59
|
-
requestAnimationFrame(function() {
|
|
60
|
-
rafPending = false;
|
|
61
|
-
var el = target;
|
|
62
|
-
if (!el || el === highlight || el === badge) return;
|
|
63
|
-
if (el === lastTarget) return;
|
|
64
|
-
lastTarget = el;
|
|
65
|
-
var r = el.getBoundingClientRect();
|
|
66
|
-
highlight.style.display = "block";
|
|
67
|
-
highlight.style.top = r.top + "px";
|
|
68
|
-
highlight.style.left = r.left + "px";
|
|
69
|
-
highlight.style.width = r.width + "px";
|
|
70
|
-
highlight.style.height = r.height + "px";
|
|
71
|
-
var tag = el.tagName.toLowerCase();
|
|
72
|
-
var id = el.id ? "#" + el.id : "";
|
|
73
|
-
var cls = el.className && typeof el.className === "string"
|
|
74
|
-
? "." + el.className.trim().split(/\\s+/).slice(0, 2).join(".")
|
|
75
|
-
: "";
|
|
76
|
-
badge.textContent = tag + id + cls;
|
|
77
|
-
badge.style.display = "block";
|
|
78
|
-
badge.style.top = Math.max(0, r.top - 20) + "px";
|
|
79
|
-
badge.style.left = r.left + "px";
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
document.addEventListener("mousemove", moveHandler, true);
|
|
83
|
-
|
|
84
|
-
var outHandler = function(e) {
|
|
85
|
-
if (!e.relatedTarget || e.relatedTarget === document.documentElement) {
|
|
86
|
-
highlight.style.display = "none";
|
|
87
|
-
badge.style.display = "none";
|
|
88
|
-
lastTarget = null;
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
document.addEventListener("mouseout", outHandler, true);
|
|
92
|
-
|
|
93
|
-
var clickHandler = function(e) {
|
|
94
|
-
e.preventDefault();
|
|
95
|
-
e.stopImmediatePropagation();
|
|
96
|
-
var el = e.target;
|
|
97
|
-
if (!el || el === highlight || el === badge) return;
|
|
98
|
-
|
|
99
|
-
highlight.style.outline = "2px solid #a855f7";
|
|
100
|
-
highlight.style.background = "rgba(168,85,247,0.15)";
|
|
101
|
-
setTimeout(function() {
|
|
102
|
-
highlight.style.outline = "2px solid #a855f7";
|
|
103
|
-
highlight.style.background = "rgba(168,85,247,0.08)";
|
|
104
|
-
}, 400);
|
|
105
|
-
|
|
106
|
-
var tag = el.tagName.toLowerCase();
|
|
107
|
-
var id = el.id || "";
|
|
108
|
-
var classes = el.className && typeof el.className === "string" ? el.className.trim() : "";
|
|
109
|
-
var text = (el.textContent || "").trim().slice(0, 200);
|
|
110
|
-
var html = (el.outerHTML || "").slice(0, 800).replace(/\\svalue=("[^"]*"|'[^']*'|\\S+)/gi, "");
|
|
111
|
-
|
|
112
|
-
var closestSection = el.closest("section[data-manifest-key]");
|
|
113
|
-
var manifestKey = closestSection ? closestSection.getAttribute("data-manifest-key") : null;
|
|
114
|
-
|
|
115
|
-
var ancestor = el;
|
|
116
|
-
var componentName = null;
|
|
117
|
-
for (var i = 0; i < 10 && ancestor; i++) {
|
|
118
|
-
if (ancestor.dataset) componentName = ancestor.dataset.componentName || componentName;
|
|
119
|
-
ancestor = ancestor.parentElement;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
var parents = [];
|
|
123
|
-
var p = el.parentElement;
|
|
124
|
-
for (var j = 0; j < 4 && p && p !== document.body; j++) {
|
|
125
|
-
var pTag = p.tagName ? p.tagName.toLowerCase() : "";
|
|
126
|
-
var pId = p.id ? "#" + p.id : "";
|
|
127
|
-
var pCls = p.className && typeof p.className === "string"
|
|
128
|
-
? "." + p.className.trim().split(/\\s+/)[0]
|
|
129
|
-
: "";
|
|
130
|
-
parents.unshift(pTag + pId + pCls);
|
|
131
|
-
p = p.parentElement;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
window.parent.postMessage({
|
|
135
|
-
type: "visual-editor::element-clicked",
|
|
136
|
-
payload: {
|
|
137
|
-
tag: tag, id: id, classes: classes, text: text, html: html,
|
|
138
|
-
manifestKey: manifestKey, componentName: componentName,
|
|
139
|
-
parents: parents.join(" > "),
|
|
140
|
-
url: window.location.href, path: window.location.pathname,
|
|
141
|
-
viewport: { width: window.innerWidth, height: window.innerHeight },
|
|
142
|
-
position: { x: Math.round(e.clientX), y: Math.round(e.clientY) }
|
|
143
|
-
}
|
|
144
|
-
}, "*");
|
|
145
|
-
};
|
|
146
|
-
document.addEventListener("click", clickHandler, true);
|
|
147
|
-
|
|
148
|
-
window.addEventListener("message", function(e) {
|
|
149
|
-
if (e.data && e.data.type === "visual-editor::deactivate") {
|
|
150
|
-
highlight.remove();
|
|
151
|
-
badge.remove();
|
|
152
|
-
cursorStyle.remove();
|
|
153
|
-
document.removeEventListener("mousemove", moveHandler, true);
|
|
154
|
-
document.removeEventListener("mouseout", outHandler, true);
|
|
155
|
-
document.removeEventListener("click", clickHandler, true);
|
|
156
|
-
window.__visualEditorActive = false;
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
})();`,Y_=zr({sectionIndex:En(),manifestKey:hs()}),J_=`(function() {
|
|
160
|
-
if (window.__cmsEditorActive) return;
|
|
161
|
-
window.__cmsEditorActive = true;
|
|
162
|
-
|
|
163
|
-
// Preserve scroll across variant-override navigations and save-reloads.
|
|
164
|
-
// Selecting a variant rebuilds the iframe src (new x-deco-matchers-override)
|
|
165
|
-
// or reloads it, which would otherwise jump to the top. We persist the scroll
|
|
166
|
-
// offset to sessionStorage (survives reload, same-origin) keyed by pathname
|
|
167
|
-
// (the override only changes the query, so the key is stable), then restore it
|
|
168
|
-
// on the next load — retried for ~1s so it outlasts re-hydration and lazy
|
|
169
|
-
// sections that grow the page after load. The recency guard avoids restoring a
|
|
170
|
-
// stale offset on a genuinely fresh visit.
|
|
171
|
-
var SCROLL_KEY = "__cms_preview_scroll:" + location.pathname;
|
|
172
|
-
var saveScroll = function() {
|
|
173
|
-
try {
|
|
174
|
-
sessionStorage.setItem(SCROLL_KEY, JSON.stringify({
|
|
175
|
-
x: window.scrollX, y: window.scrollY, t: Date.now()
|
|
176
|
-
}));
|
|
177
|
-
} catch (_) {}
|
|
178
|
-
};
|
|
179
|
-
var saveScrollPending = false;
|
|
180
|
-
window.addEventListener("scroll", function() {
|
|
181
|
-
if (saveScrollPending) return;
|
|
182
|
-
saveScrollPending = true;
|
|
183
|
-
requestAnimationFrame(function() { saveScrollPending = false; saveScroll(); });
|
|
184
|
-
}, { passive: true });
|
|
185
|
-
(function restoreScroll() {
|
|
186
|
-
var raw = null;
|
|
187
|
-
try { raw = sessionStorage.getItem(SCROLL_KEY); } catch (_) {}
|
|
188
|
-
if (!raw) return;
|
|
189
|
-
var saved = null;
|
|
190
|
-
try { saved = JSON.parse(raw); } catch (_) { return; }
|
|
191
|
-
if (!saved || (Date.now() - saved.t) > 10000) return;
|
|
192
|
-
if (!saved.x && !saved.y) return;
|
|
193
|
-
var attempts = 0;
|
|
194
|
-
var apply = function() {
|
|
195
|
-
attempts++;
|
|
196
|
-
window.scrollTo(saved.x || 0, saved.y || 0);
|
|
197
|
-
if (attempts < 8) setTimeout(apply, 120);
|
|
198
|
-
};
|
|
199
|
-
apply();
|
|
200
|
-
})();
|
|
201
|
-
|
|
202
|
-
var highlight = document.createElement("div");
|
|
203
|
-
highlight.style.cssText = "position:absolute;pointer-events:none;outline:2px solid #06b6d4;background:rgba(6,182,212,0.06);border-radius:2px;z-index:2147483647;display:none;";
|
|
204
|
-
document.body.appendChild(highlight);
|
|
205
|
-
|
|
206
|
-
var badge = document.createElement("div");
|
|
207
|
-
badge.style.cssText = "position:absolute;pointer-events:none;background:#06b6d4;color:white;font:11px/1 monospace;padding:2px 6px;border-radius:2px;z-index:2147483647;display:none;white-space:nowrap;max-width:240px;overflow:hidden;text-overflow:ellipsis;";
|
|
208
|
-
document.body.appendChild(badge);
|
|
209
|
-
|
|
210
|
-
var isTopLevelSection = function(el) {
|
|
211
|
-
return el && el.parentElement
|
|
212
|
-
? !el.parentElement.closest("section[data-manifest-key]")
|
|
213
|
-
: true;
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
// All top-level page sections in DOM order (deco renders page sections as
|
|
217
|
-
// <section data-manifest-key>; nested islands/sections carry the attribute
|
|
218
|
-
// too, hence the top-level filter). This is the full DOM run, framework
|
|
219
|
-
// sections included — getAllSections() narrows it to the editable window.
|
|
220
|
-
var topLevelSections = function() {
|
|
221
|
-
return Array.from(document.querySelectorAll("section[data-manifest-key]"))
|
|
222
|
-
.filter(isTopLevelSection);
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
// Candidate manifest keys per editable section, sent by the editor. Each
|
|
226
|
-
// entry is an array of acceptable DOM keys: [] = wildcard (e.g. multivariate,
|
|
227
|
-
// whose rendered key we can't predict); null = renders NOTHING (hidden
|
|
228
|
-
// section — multivariate whose variants are all gated by never), so the
|
|
229
|
-
// alignment must not consume a DOM node for it; a Lazy lists both its loader
|
|
230
|
-
// key and the inner section's key, since the classic runtime keeps the Lazy
|
|
231
|
-
// wrapper at top level while TanStack renders the inner section directly.
|
|
232
|
-
var sectionCandidates = [];
|
|
233
|
-
|
|
234
|
-
// Best in-order assignment of editable sections to DOM sections, maximizing
|
|
235
|
-
// key matches (DP / LCS-style). deco injects framework sections (SEO, Theme,
|
|
236
|
-
// Session, …) that may lead, trail, OR interleave with the editable run; this
|
|
237
|
-
// skips whichever don't match, on any runtime — no hardcoded list. Hidden
|
|
238
|
-
// sections (null candidates) have no DOM node: only visible entries are
|
|
239
|
-
// aligned, then scattered back to their decofile positions (null-filled), so
|
|
240
|
-
// returned indexes still match the decofile array.
|
|
241
|
-
var computeAlignment = function(tops) {
|
|
242
|
-
var visible = [], k;
|
|
243
|
-
for (k = 0; k < sectionCandidates.length; k++) {
|
|
244
|
-
if (sectionCandidates[k] !== null) visible.push(k);
|
|
245
|
-
}
|
|
246
|
-
var N = visible.length, M = tops.length;
|
|
247
|
-
var res = new Array(sectionCandidates.length).fill(null);
|
|
248
|
-
if (!N) return res;
|
|
249
|
-
if (M < N) return tops.slice();
|
|
250
|
-
var domKeys = tops.map(function(s) { return s.getAttribute("data-manifest-key"); });
|
|
251
|
-
var match = function(i, j) {
|
|
252
|
-
var c = sectionCandidates[visible[i]];
|
|
253
|
-
if (!c || !c.length) return 1;
|
|
254
|
-
return c.indexOf(domKeys[j]) >= 0 ? 1 : 0;
|
|
255
|
-
};
|
|
256
|
-
var dp = [], bt = [], i, j;
|
|
257
|
-
for (i = 0; i <= N; i++) { dp.push(new Array(M + 1).fill(0)); bt.push(new Array(M + 1).fill(0)); }
|
|
258
|
-
for (i = 1; i <= N; i++) {
|
|
259
|
-
for (j = i; j <= M; j++) {
|
|
260
|
-
var assign = dp[i - 1][j - 1] + match(i - 1, j - 1);
|
|
261
|
-
var skip = dp[i][j - 1];
|
|
262
|
-
if (j - 1 >= i && skip >= assign) { dp[i][j] = skip; bt[i][j] = 0; }
|
|
263
|
-
else { dp[i][j] = assign; bt[i][j] = 1; }
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
i = N; j = M;
|
|
267
|
-
while (i > 0) {
|
|
268
|
-
if (bt[i][j] === 1) { res[visible[i - 1]] = tops[j - 1]; i--; j--; }
|
|
269
|
-
else { j--; }
|
|
270
|
-
}
|
|
271
|
-
return res;
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
// Editable sections, indexed to match the decofile array the panel uses.
|
|
275
|
-
// Recomputed from the live DOM each call (cheap, rAF-throttled) so it
|
|
276
|
-
// self-heals as client-rendered/lazy sections mount. Until the editor sends
|
|
277
|
-
// candidates, fall back to the full top-level run.
|
|
278
|
-
var getAllSections = function() {
|
|
279
|
-
var tops = topLevelSections();
|
|
280
|
-
return sectionCandidates.length ? computeAlignment(tops) : tops;
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
// Resolve to the OUTERMOST page-level section (clicking nested content still
|
|
284
|
-
// maps to the top-level section the panel indexes); null if it isn't in the
|
|
285
|
-
// aligned editable set (a framework section deco injected).
|
|
286
|
-
var findSection = function(el) {
|
|
287
|
-
var node = el;
|
|
288
|
-
var found = null;
|
|
289
|
-
while (node && node !== document.body) {
|
|
290
|
-
if (node.tagName === "SECTION" && node.hasAttribute && node.hasAttribute("data-manifest-key")) {
|
|
291
|
-
found = node;
|
|
292
|
-
}
|
|
293
|
-
node = node.parentElement;
|
|
294
|
-
}
|
|
295
|
-
if (!found) return null;
|
|
296
|
-
return getAllSections().indexOf(found) >= 0 ? found : null;
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
// Lazy sections async-render their real section inside a wrapper, so the
|
|
300
|
-
// wrapper's key is just the loader. Show the inner section's key instead
|
|
301
|
-
// (falling back to the wrapper while the content hasn't loaded yet).
|
|
302
|
-
var LAZY_KEY = "website/sections/Rendering/Lazy.tsx";
|
|
303
|
-
var displayKey = function(section) {
|
|
304
|
-
var key = section.getAttribute("data-manifest-key") || "section";
|
|
305
|
-
if (key === LAZY_KEY) {
|
|
306
|
-
var inner = section.querySelector("section[data-manifest-key]");
|
|
307
|
-
if (inner) return inner.getAttribute("data-manifest-key") || key;
|
|
308
|
-
}
|
|
309
|
-
return key;
|
|
310
|
-
};
|
|
311
|
-
|
|
312
|
-
// Per-section metadata sent by the editor, aligned by index with
|
|
313
|
-
// getAllSections(). labels: names the DOM can't carry (a global section or a
|
|
314
|
-
// global inside async rendering); kinds: section type that drives the color.
|
|
315
|
-
var sectionLabels = [];
|
|
316
|
-
var sectionKinds = [];
|
|
317
|
-
var labelFor = function(section) {
|
|
318
|
-
var idx = getAllSections().indexOf(section);
|
|
319
|
-
if (idx >= 0 && sectionLabels[idx]) return sectionLabels[idx];
|
|
320
|
-
return displayKey(section);
|
|
321
|
-
};
|
|
322
|
-
var kindFor = function(section) {
|
|
323
|
-
var idx = getAllSections().indexOf(section);
|
|
324
|
-
return (idx >= 0 && sectionKinds[idx]) || "normal";
|
|
325
|
-
};
|
|
326
|
-
|
|
327
|
-
// Highlight palette by section kind: global = light purple, variant = green,
|
|
328
|
-
// normal = blue.
|
|
329
|
-
var COLORS = {
|
|
330
|
-
normal: { solid: "#06b6d4", bg: "rgba(6,182,212,0.06)", active: "rgba(6,182,212,0.18)" },
|
|
331
|
-
global: { solid: "#c084fc", bg: "rgba(192,132,252,0.10)", active: "rgba(192,132,252,0.22)" },
|
|
332
|
-
variant: { solid: "#22c55e", bg: "rgba(34,197,94,0.08)", active: "rgba(34,197,94,0.20)" }
|
|
333
|
-
};
|
|
334
|
-
var applyColor = function(kind) {
|
|
335
|
-
var c = COLORS[kind] || COLORS.normal;
|
|
336
|
-
highlight.style.outline = "2px solid " + c.solid;
|
|
337
|
-
highlight.style.background = c.bg;
|
|
338
|
-
badge.style.background = c.solid;
|
|
339
|
-
};
|
|
340
|
-
|
|
341
|
-
var lastSection = null;
|
|
342
|
-
var lastLabel = "";
|
|
343
|
-
var lastKind = "normal";
|
|
344
|
-
var rafPending = false;
|
|
345
|
-
|
|
346
|
-
// Document-relative coordinates (rect + scroll) on absolutely-positioned
|
|
347
|
-
// nodes, so the browser scrolls the highlight together with the page
|
|
348
|
-
// natively — no per-frame JS repositioning, no scroll lag.
|
|
349
|
-
var positionHighlight = function(section) {
|
|
350
|
-
var r = section.getBoundingClientRect();
|
|
351
|
-
var top = r.top + window.scrollY;
|
|
352
|
-
var left = r.left + window.scrollX;
|
|
353
|
-
highlight.style.display = "block";
|
|
354
|
-
highlight.style.top = top + "px";
|
|
355
|
-
highlight.style.left = left + "px";
|
|
356
|
-
highlight.style.width = r.width + "px";
|
|
357
|
-
highlight.style.height = r.height + "px";
|
|
358
|
-
badge.textContent = lastLabel || displayKey(section);
|
|
359
|
-
badge.style.display = "block";
|
|
360
|
-
badge.style.top = Math.max(0, top - 20) + "px";
|
|
361
|
-
badge.style.left = left + "px";
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
var moveHandler = function(e) {
|
|
365
|
-
if (rafPending) return;
|
|
366
|
-
rafPending = true;
|
|
367
|
-
var target = e.target;
|
|
368
|
-
requestAnimationFrame(function() {
|
|
369
|
-
rafPending = false;
|
|
370
|
-
if (!target || target === highlight || target === badge) return;
|
|
371
|
-
var section = findSection(target);
|
|
372
|
-
if (section === lastSection) return;
|
|
373
|
-
lastSection = section;
|
|
374
|
-
if (!section) {
|
|
375
|
-
highlight.style.display = "none";
|
|
376
|
-
badge.style.display = "none";
|
|
377
|
-
return;
|
|
378
|
-
}
|
|
379
|
-
lastLabel = labelFor(section);
|
|
380
|
-
lastKind = kindFor(section);
|
|
381
|
-
applyColor(lastKind);
|
|
382
|
-
positionHighlight(section);
|
|
383
|
-
});
|
|
384
|
-
};
|
|
385
|
-
document.addEventListener("mousemove", moveHandler, true);
|
|
386
|
-
|
|
387
|
-
// Window scroll is handled natively by the absolute positioning above; this
|
|
388
|
-
// only re-syncs on resize and on scrolls inside nested scroll containers
|
|
389
|
-
// (capture=true catches those), where document coordinates do shift.
|
|
390
|
-
var reposition = function() {
|
|
391
|
-
if (!lastSection || highlight.style.display === "none") return;
|
|
392
|
-
if (rafPending) return;
|
|
393
|
-
rafPending = true;
|
|
394
|
-
requestAnimationFrame(function() {
|
|
395
|
-
rafPending = false;
|
|
396
|
-
if (lastSection && highlight.style.display !== "none") positionHighlight(lastSection);
|
|
397
|
-
});
|
|
398
|
-
};
|
|
399
|
-
window.addEventListener("scroll", reposition, { capture: true, passive: true });
|
|
400
|
-
window.addEventListener("resize", reposition, { passive: true });
|
|
401
|
-
|
|
402
|
-
var outHandler = function(e) {
|
|
403
|
-
if (!e.relatedTarget || e.relatedTarget === document.documentElement) {
|
|
404
|
-
highlight.style.display = "none";
|
|
405
|
-
badge.style.display = "none";
|
|
406
|
-
lastSection = null;
|
|
407
|
-
}
|
|
408
|
-
};
|
|
409
|
-
document.addEventListener("mouseout", outHandler, true);
|
|
410
|
-
|
|
411
|
-
var clickHandler = function(e) {
|
|
412
|
-
e.preventDefault();
|
|
413
|
-
e.stopImmediatePropagation();
|
|
414
|
-
var target = e.target;
|
|
415
|
-
if (!target || target === highlight || target === badge) return;
|
|
416
|
-
var section = findSection(target);
|
|
417
|
-
if (!section) return;
|
|
418
|
-
|
|
419
|
-
var sections = getAllSections();
|
|
420
|
-
var sectionIndex = sections.indexOf(section);
|
|
421
|
-
var manifestKey = section.getAttribute("data-manifest-key") || "";
|
|
422
|
-
|
|
423
|
-
var c = COLORS[lastKind] || COLORS.normal;
|
|
424
|
-
highlight.style.outline = "2px solid " + c.solid;
|
|
425
|
-
highlight.style.background = c.active;
|
|
426
|
-
setTimeout(function() {
|
|
427
|
-
highlight.style.background = c.bg;
|
|
428
|
-
}, 400);
|
|
429
|
-
|
|
430
|
-
window.parent.postMessage({
|
|
431
|
-
type: "cms-editor::section-clicked",
|
|
432
|
-
payload: { sectionIndex: sectionIndex, manifestKey: manifestKey }
|
|
433
|
-
}, "*");
|
|
434
|
-
};
|
|
435
|
-
document.addEventListener("click", clickHandler, true);
|
|
436
|
-
|
|
437
|
-
window.addEventListener("message", function(e) {
|
|
438
|
-
if (e.data && e.data.type === "cms-editor::set-labels" && Array.isArray(e.data.labels)) {
|
|
439
|
-
sectionLabels = e.data.labels;
|
|
440
|
-
if (Array.isArray(e.data.kinds)) sectionKinds = e.data.kinds;
|
|
441
|
-
if (Array.isArray(e.data.keys)) sectionCandidates = e.data.keys;
|
|
442
|
-
if (lastSection) {
|
|
443
|
-
lastLabel = labelFor(lastSection);
|
|
444
|
-
lastKind = kindFor(lastSection);
|
|
445
|
-
applyColor(lastKind);
|
|
446
|
-
if (highlight.style.display !== "none") positionHighlight(lastSection);
|
|
447
|
-
}
|
|
448
|
-
return;
|
|
449
|
-
}
|
|
450
|
-
if (e.data && e.data.type === "cms-editor::deactivate") {
|
|
451
|
-
highlight.remove();
|
|
452
|
-
badge.remove();
|
|
453
|
-
document.removeEventListener("mousemove", moveHandler, true);
|
|
454
|
-
document.removeEventListener("mouseout", outHandler, true);
|
|
455
|
-
document.removeEventListener("click", clickHandler, true);
|
|
456
|
-
window.removeEventListener("scroll", reposition, { capture: true });
|
|
457
|
-
window.removeEventListener("resize", reposition);
|
|
458
|
-
window.__cmsEditorActive = false;
|
|
459
|
-
}
|
|
460
|
-
});
|
|
461
|
-
})();`;function $i(t){return t.replace(/[`*_]/g,"\\$&")}function X_(t,e){const s=[`The user selected an element on the live preview and asked: **"${$i(e.trim())}"**`,"","For text content changes, locate the correct source file and apply the change.","For code and CSS changes, understand which component the user is referring to and apply changes to the correct component.",""];t.manifestKey&&s.push(`**Section resolveType:** \`${$i(t.manifestKey)}\``,"","This is a Deco resolveType, not a literal file path. The leading segment is the app name, not a directory — the actual source file lives under a sections directory whose root varies by site (commonly `sections/`, `src/sections/`, or `site/sections/`). Locate the file by searching for the trailing path (e.g. the component filename), don't assume the resolveType is a valid path on disk.","");const i=`<${t.tag}${t.classes?` class="${$i(t.classes)}"`:""}>`;s.push(`**Clicked element:** \`${i}\``),t.parents&&s.push(`**DOM breadcrumb:** ${$i(t.parents)} > ${t.tag}`),t.text&&s.push(`**Text content:** "${$i(t.text)}"`),t.componentName&&s.push(`**Component name:** ${$i(t.componentName)}`);const r=t.html.replace(/```/g,"`` `");return s.push("","**HTML snippet:**","```html",r,"```"),s.push("","Please read the source file, locate the element, and apply the requested change."),s.join(`
|
|
462
|
-
`)}function Z_(t,e,s=320,i=44,r=12){const{x:o,y:a}=t,{width:l,height:c}=e,d=Math.max(r,Math.min(o-s/2,l-s-r)),u=a/c>.68?Math.max(r,a-i-18):Math.min(a+18,c-i-r);return{leftPct:d/l*100,topPct:u/c*100}}function Q_(t){const e=U.c(32),{element:s,onDismiss:i}=t,[r,o]=R.useState(""),a=R.useRef(null),{sendMessage:l}=Ti(),{setChatOpen:c}=Eo();let d;e[0]!==s||e[1]!==r||e[2]!==i||e[3]!==l||e[4]!==c?(d=()=>{if(!r.trim())return;const T=X_(s,r);c(!0),l({parts:[{type:"text",text:T}]}),i()},e[0]=s,e[1]=r,e[2]=i,e[3]=l,e[4]=c,e[5]=d):d=e[5];const h=d;let u;e[6]!==s.position||e[7]!==s.viewport?(u=Z_(s.position,s.viewport),e[6]=s.position,e[7]=s.viewport,e[8]=u):u=e[8];const f=u,m=`${f.leftPct}%`,p=`${f.topPct}%`;let g;e[9]!==m||e[10]!==p?(g={left:m,top:p,width:"320px"},e[9]=m,e[10]=p,e[11]=g):g=e[11];let L;e[12]!==h?(L=T=>{T.preventDefault(),h()},e[12]=h,e[13]=L):L=e[13];let v;e[14]===Symbol.for("react.memo_cache_sentinel")?(v=T=>o(T.target.value),e[14]=v):v=e[14];let y;e[15]!==i?(y=T=>{T.key==="Escape"&&i()},e[15]=i,e[16]=y):y=e[16];let _;e[17]!==r||e[18]!==y?(_=n.jsx("input",{ref:a,autoFocus:!0,type:"text",value:r,onChange:v,onKeyDown:y,placeholder:"Ask the AI...",className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"}),e[17]=r,e[18]=y,e[19]=_):_=e[19];let x;e[20]!==r?(x=r.trim(),e[20]=r,e[21]=x):x=e[21];const b=!x;let S;e[22]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none","aria-hidden":"true",children:[n.jsx("title",{children:"Send"}),n.jsx("path",{d:"M5 9V1M1 5l4-4 4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),e[22]=S):S=e[22];let w;e[23]!==b?(w=n.jsx("button",{type:"submit",disabled:b,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-foreground text-background transition-opacity disabled:opacity-30",title:"Send",children:S}),e[23]=b,e[24]=w):w=e[24];let j;e[25]!==w||e[26]!==L||e[27]!==_?(j=n.jsxs("form",{className:"pointer-events-auto flex w-full items-center gap-1.5 rounded-xl border border-border bg-background/95 px-3 py-1.5 shadow-lg backdrop-blur",onSubmit:L,children:[_,w]}),e[25]=w,e[26]=L,e[27]=_,e[28]=j):j=e[28];let N;return e[29]!==j||e[30]!==g?(N=n.jsx("div",{className:"absolute z-30 pointer-events-none",style:g,children:j}),e[29]=j,e[30]=g,e[31]=N):N=e[31],N}const Uu={claiming:{long:"Reserving sandbox",short:"Reserving sandbox"},"waiting-for-capacity":{long:"Waiting for cluster capacity",short:"Waiting for capacity"},"pulling-image":{long:"Downloading sandbox image",short:"Downloading image"},"starting-container":{long:"Starting your sandbox",short:"Starting container"},"warming-daemon":{long:"Connecting to your sandbox",short:"Connecting to sandbox"}},e6=["provision","cloning","install","dev"];function Ku(t){switch(t.lifecycle.phase){case"cloning":case"checking-out":return{step:"cloning",status:"doing"};case"clone-failed":return{step:"cloning",status:"failed"};case"installing":return{step:"install",status:"doing"};case"install-failed":return{step:"install",status:"failed"};case"starting":return{step:"dev",status:"doing"};case"running":return{step:"dev",status:"done"};case"start-failed":return{step:"dev",status:"failed"};case"crashed":return{step:"dev",status:"failed"};case"idle":return t.claimPhase&&t.claimPhase.kind!=="ready"&&t.claimPhase.kind!=="failed"?{step:"provision",status:"doing"}:{step:"cloning",status:"doing"}}}function z9(t){switch(t){case"starting":return"Starting your sandbox";case"suspended":return"Sandbox is paused";case"errored":return"Couldn't start the sandbox"}}function t6(t){return e6.indexOf(t.step)}const F9=48,Wu=28,Vu=3,s6=(()=>{const t=[];let e=0;for(let s=0;s<F9;s++)s===Wu?t.push(null):(t.push(e/(F9-1)*Vu),e++);return t})(),i6={provision:"Reserving sandbox",cloning:"Cloning your repo",install:"Installing packages",dev:"Starting your preview"};function n6(t,e){return t.step==="provision"&&e!=null&&e.kind!=="ready"&&e.kind!=="failed"?Uu[e.kind].long:i6[t.step]}const Ss="bg-foreground/[0.05]",Zt="bg-foreground/[0.09]",r6=Array.from({length:35},()=>Math.random()*1.8),o6=Array.from({length:35},()=>Math.random()<.4);function a6(t){const e=U.c(30),{progress:s,claimPhase:i}=t;let r;e[0]!==s?(r=t6(s),e[0]=s,e[1]=r):r=e[1];const o=r;let a;e[2]!==i||e[3]!==s?(a=n6(s,i),e[2]=i,e[3]=s,e[4]=a):a=e[4];const l=a;let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(am,{}),e[5]=c):c=e[5];const d=`${s.step}-${l}`;let h;e[6]!==l||e[7]!==d?(h=n.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-foreground/10 bg-background px-3.5 py-1.5 shadow-[0_4px_20px_-4px_rgb(0_0_0_/_0.12)]",children:[c,n.jsxs("span",{className:"animate-in fade-in text-[13px] font-medium text-foreground/85 duration-500",children:[l,"…"]},d)]}),e[6]=l,e[7]=d,e[8]=h):h=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(l6,{}),e[9]=u):u=e[9];let f;e[10]!==o?(f=n.jsx(Cr,{phase:0,current:o,children:u}),e[10]=o,e[11]=f):f=e[11];let m;e[12]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(d6,{}),e[12]=m):m=e[12];let p;e[13]!==o?(p=n.jsx(Cr,{phase:1,current:o,children:m}),e[13]=o,e[14]=p):p=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(h6,{}),e[15]=g):g=e[15];let L;e[16]!==o?(L=n.jsx(Cr,{phase:2,current:o,children:g}),e[16]=o,e[17]=L):L=e[17];let v;e[18]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(f6,{}),e[18]=v):v=e[18];let y;e[19]!==o?(y=n.jsx(Cr,{phase:3,current:o,children:v}),e[19]=o,e[20]=y):y=e[20];let _;e[21]!==L||e[22]!==y||e[23]!==f||e[24]!==p?(_=n.jsxs("div",{className:"relative aspect-[4/3] w-[min(78%,560px)]",children:[f,p,L,y]}),e[21]=L,e[22]=y,e[23]=f,e[24]=p,e[25]=_):_=e[25];let x;e[26]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("style",{children:`
|
|
463
|
-
@keyframes vm-pulse-soft {
|
|
464
|
-
0%, 100% { opacity: 0.25; }
|
|
465
|
-
50% { opacity: 1; }
|
|
466
|
-
}
|
|
467
|
-
@keyframes vm-breathe {
|
|
468
|
-
0%, 100% { opacity: 0.5; }
|
|
469
|
-
50% { opacity: 1; }
|
|
470
|
-
}
|
|
471
|
-
@keyframes vm-rack-scan {
|
|
472
|
-
0%, 100% { opacity: 0; }
|
|
473
|
-
8% { opacity: 1; }
|
|
474
|
-
22% { opacity: 0; }
|
|
475
|
-
}
|
|
476
|
-
`}),e[26]=x):x=e[26];let b;return e[27]!==_||e[28]!==h?(b=n.jsxs("div",{className:"relative flex w-full flex-col items-center justify-center gap-12 select-none [clip-path:inset(-24px_0_-200px_0)]",children:[h,_,x]}),e[27]=_,e[28]=h,e[29]=b):b=e[29],b}function Cr(t){const e=U.c(10),{phase:s,current:i,children:r}=t,o=s-i,a=o<0,l=o===0,c=a?90:o*-22,d=a?.94:1-Math.max(o,0)*.04,h=a?0:l?1:o===1?.8:.55,u=a?10:30-o,f=!l;let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=ce("absolute inset-0 overflow-hidden rounded-xl border border-foreground/10 bg-background shadow-[0_20px_60px_-20px_rgb(0_0_0_/_0.35)] transition-all ease-[cubic-bezier(0.22,1,0.36,1)]"),e[0]=m):m=e[0];const p=`translateY(${c}px) scale(${d})`,g=l?"auto":"none";let L;e[1]!==h||e[2]!==p||e[3]!==g||e[4]!==u?(L={transform:p,opacity:h,zIndex:u,transitionDuration:"1000ms",pointerEvents:g},e[1]=h,e[2]=p,e[3]=g,e[4]=u,e[5]=L):L=e[5];let v;return e[6]!==r||e[7]!==f||e[8]!==L?(v=n.jsx("div",{"aria-hidden":f,className:m,style:L,children:r}),e[6]=r,e[7]=f,e[8]=L,e[9]=v):v=e[9],v}function Wo(t){const e=U.c(7),{showUrl:s}=t,i=s===void 0?!1:s;let r,o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("div",{className:ce("size-2.5 rounded-full",Zt)}),o=n.jsx("div",{className:ce("size-2.5 rounded-full",Zt)}),a=n.jsx("div",{className:ce("size-2.5 rounded-full",Zt)}),e[0]=r,e[1]=o,e[2]=a):(r=e[0],o=e[1],a=e[2]);let l;e[3]!==i?(l=i&&n.jsx("div",{className:ce("ml-3 h-3.5 max-w-[220px] flex-1 rounded-sm",Ss)}),e[3]=i,e[4]=l):l=e[4];let c;return e[5]!==l?(c=n.jsxs("div",{className:"flex h-7 shrink-0 items-center gap-1.5 px-3",children:[r,o,a,l]}),e[5]=l,e[6]=c):c=e[6],c}function l6(){const t=U.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Wo,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsxs("div",{className:"flex h-full flex-col",children:[e,n.jsx("div",{className:"flex flex-1 px-8 py-5",children:n.jsx("div",{className:"grid h-full w-full grid-cols-8 grid-rows-6 gap-2",children:s6.map(c6)})})]}),t[1]=s):s=t[1],s}function c6(t,e){if(e===Wu)return n.jsx("div",{className:"rounded-md bg-chart-1/[0.55]",style:{animation:"vm-breathe 2.4s ease-in-out infinite"}},e);const s=t;return n.jsx("div",{className:ce("relative rounded-md",Zt),children:n.jsx("div",{className:"absolute inset-0 rounded-md bg-chart-1/40 opacity-0",style:{animation:`vm-rack-scan ${Vu}s ease-in-out infinite`,animationDelay:`${s}s`}})},e)}function d6(){const t=U.c(5);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Wo,{}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:ce("w-[18%] rounded-md",Ss),style:{animation:"vm-breathe 3s ease-in-out infinite"}}),t[1]=s):s=t[1];let i;t[2]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"h-[42%] shrink-0 rounded-md bg-chart-3/[0.12]",style:{animation:"vm-breathe 3s ease-in-out 0.4s infinite"}}),t[2]=i):i=t[2];let r;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("div",{className:"col-span-3 rounded-md bg-chart-3/[0.12]",style:{animation:"vm-breathe 3s ease-in-out 0.8s infinite"}}),t[3]=r):r=t[3];let o;return t[4]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsxs("div",{className:"flex h-full flex-col",children:[e,n.jsxs("div",{className:"flex min-h-0 flex-1 gap-1.5 p-3",children:[s,n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[i,n.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-5 gap-1.5",children:[r,n.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-1.5",children:[n.jsx("div",{className:ce("rounded-md",Ss),style:{animation:"vm-breathe 3s ease-in-out 1.2s infinite"}}),n.jsx("div",{className:ce("rounded-md",Ss),style:{animation:"vm-breathe 3s ease-in-out 1.6s infinite"}})]})]})]})]})]}),t[4]=o):o=t[4],o}function h6(){const t=U.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Wo,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsxs("div",{className:"flex h-full flex-col",children:[e,n.jsx("div",{className:"relative flex flex-1 items-center justify-center px-8 py-5",children:n.jsx("div",{className:"grid w-full gap-2",style:{gridTemplateColumns:"repeat(7, minmax(0, 1fr))"},children:r6.map(u6)})})]}),t[1]=s):s=t[1],s}function u6(t,e){return n.jsx("div",{className:ce("aspect-square rounded-md",o6[e]?"bg-chart-2/70":Zt),style:{animation:`vm-pulse-soft 2.2s ease-in-out ${t}s infinite`}},e)}function f6(){const t=U.c(11);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Wo,{showUrl:!0}),t[0]=e):e=t[0];let s,i,r,o,a;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:"mb-2 h-5 rounded-md bg-chart-1/[0.10]"}),i=n.jsx("div",{className:ce("h-1.5 w-[70%] rounded-sm",Zt)}),r=n.jsx("div",{className:ce("h-1.5 w-[55%] rounded-sm",Zt)}),o=n.jsx("div",{className:ce("h-1.5 w-[80%] rounded-sm",Zt)}),a=n.jsx("div",{className:ce("h-1.5 w-[50%] rounded-sm",Zt)}),t[1]=s,t[2]=i,t[3]=r,t[4]=o,t[5]=a):(s=t[1],i=t[2],r=t[3],o=t[4],a=t[5]);let l;t[6]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsxs("div",{className:"flex w-[18%] shrink-0 flex-col gap-1.5 bg-chart-1/[0.05] p-2.5",children:[s,i,r,o,a,n.jsx("div",{className:"mt-auto",children:n.jsx("div",{className:ce("h-4 rounded-md",Zt)})})]}),t[6]=l):l=t[6];let c;t[7]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("div",{className:"relative h-[42%] shrink-0 overflow-hidden bg-chart-1/[0.10]",children:n.jsxs("div",{className:"absolute right-3 bottom-3 left-3 space-y-1.5",children:[n.jsx("div",{className:"h-3 w-[35%] rounded-sm bg-chart-1/[0.15]"}),n.jsx("div",{className:ce("h-1.5 w-[55%] rounded-sm",Ss)})]})}),t[7]=c):c=t[7];let d;t[8]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsxs("div",{className:"flex shrink-0 gap-1.5",children:[n.jsx("div",{className:"h-4 w-12 rounded-full bg-chart-1/[0.12]"}),n.jsx("div",{className:ce("h-4 w-10 rounded-full",Ss)}),n.jsx("div",{className:ce("h-4 w-14 rounded-full",Ss)})]}),t[8]=d):d=t[8];let h;t[9]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsxs("div",{className:ce("col-span-3 flex flex-col justify-end gap-1 rounded-md p-2",Ss),children:[n.jsx("div",{className:ce("h-1.5 w-[50%] rounded-sm",Zt)}),n.jsx("div",{className:ce("h-1 w-[75%] rounded-sm",Zt)})]}),t[9]=h):h=t[9];let u;return t[10]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsxs("div",{className:"flex h-full flex-col",children:[e,n.jsxs("div",{className:"flex min-h-0 flex-1",children:[l,n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[c,n.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2.5 p-3",children:[d,n.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-5 gap-2",children:[h,n.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-2",children:[n.jsx("div",{className:ce("rounded-md",Ss)}),n.jsx("div",{className:ce("rounded-md",Ss)})]})]})]})]})]})]}),t[10]=u):u=t[10],u}function Ji(t){const e=U.c(25);if(t.kind==="starting"){let l;return e[0]!==t.claimPhase||e[1]!==t.progress?(l=n.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:n.jsx(a6,{progress:t.progress,claimPhase:t.claimPhase})}),e[0]=t.claimPhase,e[1]=t.progress,e[2]=l):l=e[2],l}if(t.kind==="errored"){const l=t.error.code===eu.githubNotAuthenticated;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Ml,{className:"size-12 text-destructive"}),e[3]=c):c=e[3];let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("h3",{className:"text-lg font-medium",children:z9("errored")}),e[4]=d):d=e[4];const h=l?"This agent's GitHub repo isn't authenticated. Reconnect it in Connections, then retry.":t.error.message;let u;e[5]!==h?(u=n.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:h}),e[5]=h,e[6]=u):u=e[6];let f;e[7]!==l||e[8]!==t.connectionsHref?(f=l&&t.connectionsHref&&n.jsx(re,{asChild:!0,children:n.jsx("a",{href:t.connectionsHref,children:"Reconnect GitHub"})}),e[7]=l,e[8]=t.connectionsHref,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(Xi,{className:"size-4"}),e[10]=m):m=e[10];let p;e[11]!==t.onRetry?(p=n.jsxs(re,{variant:"outline",onClick:t.onRetry,children:[m," Retry"]}),e[11]=t.onRetry,e[12]=p):p=e[12];let g;e[13]!==f||e[14]!==p?(g=n.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[f,p]}),e[13]=f,e[14]=p,e[15]=g):g=e[15];let L;return e[16]!==u||e[17]!==g?(L=n.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:n.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-4 text-center",children:[c,d,u,g]})}),e[16]=u,e[17]=g,e[18]=L):L=e[18],L}let s;e[19]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(C2,{className:"size-12 text-blue-500"}),e[19]=s):s=e[19];let i,r;e[20]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("h3",{className:"text-lg font-medium",children:z9("suspended")}),r=n.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:"Resume to continue."}),e[20]=i,e[21]=r):(i=e[20],r=e[21]);let o;e[22]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(xi,{className:"size-4"}),e[22]=o):o=e[22];let a;return e[23]!==t.onResume?(a=n.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:n.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-4 text-center",children:[s,i,r,n.jsxs(re,{onClick:t.onResume,className:"mt-2",children:[o," Resume"]})]})}),e[23]=t.onResume,e[24]=a):a=e[24],a}function m6(t,e,s){return`deco:preview:last-page:${t}:${e}:${s}`}function p6(t){if(!t)return null;try{const e=JSON.parse(t);if(!e||typeof e!="object"||Array.isArray(e)||typeof e.path!="string"||!e.path.startsWith("/"))return null;const s=typeof e.pageKey=="string"?e.pageKey:null,i={};if(e.params&&typeof e.params=="object")for(const[r,o]of Object.entries(e.params))typeof o=="string"&&(i[r]=o);return{path:e.path,pageKey:s,params:i}}catch{return null}}function g6(t){try{return p6(localStorage.getItem(t))}catch{return null}}function _6(t,e){try{localStorage.setItem(t,JSON.stringify(e))}catch{}}function L6(t){const e=U.c(12),{orgSlug:s,virtualMcpId:i,branch:r,enabled:o}=t,a=o===void 0?!0:o;let l;e[0]!==r||e[1]!==s||e[2]!==i?(l=Et.sandboxRepoDir(s,i,r),e[0]=r,e[1]=s,e[2]=i,e[3]=l):l=e[3];let c;e[4]!==r||e[5]!==s||e[6]!==i?(c=async()=>{const u=`/api/${s}/sandbox/${encodeURIComponent(i)}/${encodeURIComponent(r)}/config`,f=await fetch(u);return f.ok?(await f.json()).repoDir??null:null},e[4]=r,e[5]=s,e[6]=i,e[7]=c):c=e[7];let d;return e[8]!==a||e[9]!==l||e[10]!==c?(d={queryKey:l,queryFn:c,enabled:a,staleTime:1/0},e[8]=a,e[9]=l,e[10]=c,e[11]=d):d=e[11],si(d).data??null}const H9="https://decoims.com/decocms/01b321bd-4613-4b2c-9348-35058444d210/Visual_Studio_Code_1.35_icon.svg.png",U9="https://decoims.com/decocms/7583d3b5-81d0-4afb-becf-6a59bbb3a68e/cursor-logo-icon-freelogovectors.net_.png",v6=R.lazy(()=>as(()=>import("./sections-editor-BHAVZ3MF.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145])).then(t=>({default:t.SectionsEditor}))),x6=R.lazy(()=>as(()=>import("./page-seo-sheet--MdUX-61.js"),__vite__mapDeps([146,1,2,73,42,44,4,5,6,7,8,9,10,11,12,13,14,3,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,43,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,74,75,76,77,78,79,80,81,100,101,103,94,91,104,105,83,84,85,86,87,88,89,90,92,93,95,96,97,98,99,106,107,108,109,110,111,112,113,114,115,82,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145])).then(t=>({default:t.SeoSheet}))),y6=R.lazy(()=>as(()=>import("./file-explorer-DkK3gDL2.js"),__vite__mapDeps([147,1,2,124,4,5,6,7,8,9,10,11,12,13,14,3,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,148,122,109,121,123,115,82,95,112,103,94,91,104,105,83,84,85,86,87,88,89,90,92,93,96,97,98,99,106,107,108,110,111,113,114,116,117,118,119,120,125,126,127,128,101,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145])).then(t=>({default:t.FileExplorer}))),ha=500,b6={mobile:375,tablet:768,desktop:null},ua=["desktop","mobile","tablet"],K9={mobile:"Mobile (375px)",tablet:"Tablet (768px)",desktop:"Desktop"};function S6(t){const e=U.c(24),{name:s,value:i,onCommit:r}=t,[o,a]=R.useState(i),[l,c]=R.useState(!1),d=R.useRef(!1),h=s==="*"?"*":`:${s}`,u=o||h;let f;e[0]!==u?(f=n.jsx("span",{"aria-hidden":!0,className:"invisible whitespace-pre px-1 py-0.5 text-[12px]",children:u}),e[0]=u,e[1]=f):f=e[1];const m=`Value for ${h}`;let p,g;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=S=>a(S.target.value),g=()=>c(!0),e[2]=p,e[3]=g):(p=e[2],g=e[3]);let L;e[4]!==i?(L=S=>{S.key==="Enter"&&S.currentTarget.blur(),S.key==="Escape"&&(d.current=!0,a(i),S.currentTarget.blur())},e[4]=i,e[5]=L):L=e[5];let v;e[6]!==o||e[7]!==r||e[8]!==i?(v=()=>{if(c(!1),d.current){d.current=!1;return}const S=o.trim();a(S),S!==i&&r(S)},e[6]=o,e[7]=r,e[8]=i,e[9]=v):v=e[9];let y;e[10]!==o||e[11]!==h||e[12]!==m||e[13]!==L||e[14]!==v?(y=n.jsx("input",{type:"text",value:o,placeholder:h,title:m,spellCheck:!1,className:"absolute inset-0 rounded-sm bg-violet-500/15 px-1 text-[12px] text-violet-600 outline-none placeholder:text-violet-500/60 focus:bg-violet-500/25 dark:text-violet-400",onClick:w6,onChange:p,onFocus:g,onKeyDown:L,onBlur:v}),e[10]=o,e[11]=h,e[12]=m,e[13]=L,e[14]=v,e[15]=y):y=e[15];let _;e[16]!==f||e[17]!==y?(_=n.jsxs("span",{className:"relative inline-flex max-w-64 shrink-0 items-center overflow-hidden",children:[f,y]}),e[16]=f,e[17]=y,e[18]=_):_=e[18];let x;e[19]!==l?(x=l&&n.jsxs("span",{className:"pointer-events-none ml-1.5 flex shrink-0 items-center gap-1 whitespace-nowrap rounded-sm border border-border bg-muted px-1 py-0.5 text-[10px] text-muted-foreground",children:[n.jsx(A2,{size:10}),"Enter to go"]}),e[19]=l,e[20]=x):x=e[20];let b;return e[21]!==_||e[22]!==x?(b=n.jsxs(n.Fragment,{children:[_,x]}),e[21]=_,e[22]=x,e[23]=b):b=e[23],b}function w6(t){return t.stopPropagation()}function C6(t,e){const s=new URL(t,window.location.href);return s.searchParams.set("deviceHint",e),s.href}function j6(){const t=li(),{currentBranch:e}=$s(),[s,i]=R.useState("preview"),[r,o]=R.useState("desktop"),[a,l]=R.useState(null),c=R.useRef(null),d=ku(),h=d?.setOpen,u=s==="cms",f=Nu(),[m,p]=R.useState(null),[g,L]=R.useState(null),v=R.useRef(null),[y,_]=R.useState(!1),[x,b]=R.useState(""),S=R.useRef(null),[w,j]=R.useState(!1),[N,T]=R.useState(),[A,k]=R.useState(null),[C,I]=R.useState(null),[E,O]=R.useState("/"),[P,D]=R.useState(null),[M,z]=R.useState({}),[F,$]=R.useState(!1),[V,J]=R.useState(!1),[Z,G]=R.useState(null),q=t?.entity?.id??null,{org:H}=Ge(),K=As(),B=wc(),X=B.vmEntry,W=B.previewUrl,Y=K.lifecycle.phase,Q=Y==="running",ie=X?.sandboxProviderKind==="user-desktop",oe=L6({orgSlug:H.slug,virtualMcpId:q??"",branch:e??"",enabled:ie&&Q&&!!q&&!!e}),ue=ie?oe:null,ee=q&&e&&Q?{orgSlug:H.slug,virtualMcpId:q,branch:e,previewUrl:W}:null,{data:te}=uc(ee,{fetchEnabled:Q}),{data:fe}=fc(ee,{fetchEnabled:Q}),he=q&&e?{orgSlug:H.slug,virtualMcpId:q,branch:e}:null,ye=K_(he),ve=te?bc(te).sort((ne,we)=>ne.name.localeCompare(we.name)):[],be=te&&fe?Sc(te,fe):[],Ne=qi,Oe=ve.filter(ne=>{if(!x)return!0;const we=x.toLowerCase();return ne.name.toLowerCase().includes(we)||ne.path.toLowerCase().includes(we)}),Fe=be.filter(ne=>{if(!x)return!0;const we=x.toLowerCase();return ne.name.toLowerCase().includes(we)||ne.key.toLowerCase().includes(we)||ne.resolveType.toLowerCase().includes(we)}),Me=A?null:g4(ve,E,P),qe=A?A.name:Me?.name,Ie=Me?.key??null,pe=(Ie?M[Ie]:void 0)??{},je=yr(E,pe),Be=te&&Ie?Bu(te,Ie,0):[],le=te?Ru(Be,te):[],Le=le.map(ne=>ne.isSavedBlock?ne.label:""),Ce=le.map(ne=>ne.isSavedBlock?"global":ne.isMultivariate?"variant":"normal"),_e=Be.map(ne=>Ya(ne,te??{})),Re=R.useRef(null),Je=R.useRef(null);k4(()=>{const ne=c.current,we=Re.current;!ne||!we||(ne.src=we)});const $t=K.status.state==="paused",Yt=K.phase,cs=Ku({claimPhase:Yt,lifecycle:K.lifecycle}),ae=B.previewState,He=B.userStopped,it=ae.kind==="starting"||ae.kind==="iframe"&&cs.status==="doing",Lt=ae.kind==="iframe"?j_(C6(C??new URL(je,ae.previewUrl).href,r),u&&g?g:[]):null,se=q&&e?m6(H.slug,q,e):null,Se=ne=>{se&&_6(se,ne)},[Te,De]=R.useState(null);if(ae.kind==="iframe"&&Te!==ae.previewUrl){const ne=Te!==null;De(ae.previewUrl);const we=se?g6(se):null;if(we){if(Je.current=yr(we.path,we.params),O(we.path),D(we.pageKey),I(null),k(null),we.pageKey&&Object.keys(we.params).length>0){const tt=we.pageKey;z(at=>({...at,[tt]:we.params}))}}else ne&&(Je.current=null,O("/"),I(null),D(null),k(null))}Re.current=Lt;const Ye=!!q&&!!e&&!K.notFound&&!He&&!$t&&(Yt?.kind==="ready"||Y!=="idle"),et=ae.kind!=="iframe"&&(s==="visual"||s==="cms")?"preview":s;R.useEffect(()=>{if(!W)return;let ne;try{ne=new URL(W,window.location.href).origin}catch{return}const we=tt=>{if(tt.origin===ne){if(tt.data?.type==="visual-editor::element-clicked"){const at=G_.safeParse(tt.data.payload);at.success&&l(at.data)}else if(tt.data?.type==="cms-editor::section-clicked"){const at=Y_.safeParse(tt.data.payload);at.success&&p(at.data.sectionIndex)}}};return window.addEventListener("message",we),()=>window.removeEventListener("message",we)},[W]),R.useEffect(()=>{if(!y)return;const ne=we=>{S.current?.contains(we.target)||(_(!1),b(""))};return document.addEventListener("pointerdown",ne),()=>document.removeEventListener("pointerdown",ne)},[y]),R.useEffect(()=>{if(!u)return;const ne=tt=>{const at=tt.target;at&&at!==c.current&&(v.current=at)},we=()=>{requestAnimationFrame(()=>{const tt=document.activeElement;(tt===document.body||tt===c.current)&&v.current&&v.current.focus()})};return document.addEventListener("focusin",ne),document.addEventListener("blur",we,!0),()=>{document.removeEventListener("focusin",ne),document.removeEventListener("blur",we,!0)}},[u]);const Ps=()=>{const ne=c.current?.contentWindow;ne&&ne.postMessage({type:"visual-editor::activate",script:q_},"*")},ci=()=>{const ne=c.current?.contentWindow;ne&&ne.postMessage({type:"visual-editor::deactivate"},"*")},s9=()=>{const ne=c.current?.contentWindow;ne&&(ne.postMessage({type:"visual-editor::activate",script:J_},"*"),ne.postMessage({type:"cms-editor::set-labels",labels:Le,kinds:Ce,keys:_e},"*"))},Ef=()=>{const ne=c.current?.contentWindow;ne&&ne.postMessage({type:"cms-editor::deactivate"},"*")},Ln=ne=>{const we=s;i(ne),l(null),ne!=="code"&&G(null),ne!=="cms"&&(p(null),L(null)),we==="visual"&&ci(),we==="cms"&&Ef(),ne==="visual"&&Ps(),ne==="cms"&&s9()},Af=()=>{if(!c.current||!Lt)return;const ne=c.current;ne.src=Lt},Pf=ne=>{L(ne)},Rf=()=>{const ne=c.current;if(!ne)return;const we=document.activeElement,tt=ne.tabIndex;ne.tabIndex=-1,ne.style.pointerEvents="none",ne.blur();try{ne.contentWindow?.location.reload()}catch{const Hs=Re.current;Hs&&(ne.src=Hs)}const at=()=>{ne.tabIndex=tt,ne.style.pointerEvents="",we?.focus(),ne.removeEventListener("load",at)};ne.addEventListener("load",at),setTimeout(at,3e3)},Df=()=>{if(!c.current||!Lt)return;const ne=Lt.includes("?")?"&":"?";c.current.src=`${Lt}${ne}_r=${Date.now()}`},If=()=>{const ne=ua.indexOf(r);o(ua[(ne+1)%ua.length])},Of=()=>{const ne=c.current?.contentWindow?.location?.href??Lt??W;ne&&navigator.clipboard.writeText(ne)},Mf=(()=>{if(!W)return"No server running";if(A)return A.name;try{const ne=new URL(W),we=je==="/"?"":je;return`${ne.host}${we}`}catch{return W}})(),i9=ne=>{const we=M[ne.key]??{};Je.current=yr(ne.path,we),k(null),I(null),D(ne.key),O(ne.path),p(null),$(!1),Se({path:ne.path,pageKey:ne.key,params:we})},Bf=(ne,we)=>{if(!Ie)return;const tt=Ie,at={...pe,[ne]:we};Je.current=yr(E,at),z(Hs=>({...Hs,[tt]:at})),Se({path:E,pageKey:tt,params:at})},$f=ne=>{if(!W||!fe){me.error("Preview metadata not ready yet");return}Je.current=null;const we=Gh(fe),tt=z_(W,we,ne.key);k(ne),I(tt),p(null)},zf=async({name:ne,path:we,templateKey:tt})=>{if(!q||!e)return;const at=vc(we);if(at){T(at);return}const Hs=we.trim().startsWith("/")?we.trim():`/${we.trim()}`;if(ve.some(Us=>Ne(Us.path)===Ne(Hs))){T(`A page with path "${Hs}" already exists.`);return}let ta;if(tt&&(ta=te?.[tt],!ta)){T("Selected template no longer exists.");return}T(void 0);try{const Us=await ye.mutateAsync({name:ne,path:Hs,template:ta});j(!1),me.success(`Page "${ne}" created`),await new Promise(Hf=>setTimeout(Hf,ha)),i9({key:Us.key,name:Us.name,path:Us.path}),Ln("cms")}catch(Us){T(Us instanceof Error?Us.message:"Failed to create page")}},Ff=ae.kind==="iframe",n9=ae.kind==="iframe"&&yc(te,fe),ea=ne=>Ln(s===ne?"preview":ne),r9=u&&n9;R.useEffect(()=>(h?.(r9),()=>h?.(!1)),[r9,h]);const Lr=u&&W&&e&&q?n.jsx(R.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(Ue,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(v6,{orgSlug:H.slug,virtualMcpId:q,branch:e,previewReady:Q,previewUrl:W,currentPath:E,activePageBlockKey:Ie,activeGlobalBlockKey:A?.key??null,externalSelectedIndex:A?null:m,onSaved:()=>{setTimeout(Rf,ha)},initialEditSeo:F,onExitSeo:()=>$(!1),onViewJsonFile:ne=>{try{G(u9(ne)),Ln("code")}catch{me.error("Invalid page block key")}},onVariantPreviewOverride:Pf})}):null;return n.jsxs("div",{className:"flex flex-col w-full h-full",children:[Ye&&n.jsxs(Ui.Toggles,{children:[n9&&n.jsxs(Pe,{delayDuration:300,children:[n.jsx(Ee,{asChild:!0,children:n.jsx(An,{onClick:()=>ea("cms"),"aria-pressed":s==="cms","aria-label":"Sections editor",active:s==="cms",children:n.jsx(j2,{size:16})})}),n.jsx(Ae,{side:"bottom",children:"Sections editor"})]}),n.jsxs(Pe,{delayDuration:300,children:[n.jsx(Ee,{asChild:!0,children:n.jsx(An,{onClick:()=>ea("code"),"aria-pressed":s==="code","aria-label":"Code editor",active:s==="code",children:n.jsx(k2,{size:16})})}),n.jsx(Ae,{side:"bottom",children:"Code editor"})]})]}),Ye&&(ae.kind==="iframe"||s==="code"&&!!ue)&&n.jsxs("div",{className:"relative flex h-12 shrink-0 items-center gap-4 border-b border-border/60 px-3 md:px-4",children:[ae.kind==="iframe"&&n.jsx("div",{className:ce("flex w-full items-center justify-center",s==="code"&&"hidden"),children:n.jsxs("div",{className:"flex w-full max-w-[500px] items-center gap-0.5",children:[n.jsxs(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsx(re,{variant:"ghost",size:"icon",onClick:Af,children:n.jsx(Xi,{size:14})})}),n.jsx(Ae,{side:"bottom",children:"Refresh"})]}),n.jsxs("div",{ref:S,className:"relative min-w-0 flex-1",children:[n.jsxs("div",{className:"flex h-8 w-full min-w-0 items-center rounded-md border border-border bg-background transition-colors duration-200 hover:bg-accent",children:[n.jsxs("div",{className:"flex h-full min-w-0 flex-1 cursor-pointer items-center gap-1 pl-2 pr-1",onClick:()=>_(ne=>!ne),children:[A&&n.jsxs("span",{className:"shrink-0 inline-flex items-center gap-1 rounded bg-global-section/14 px-1.5 py-0.5 text-[11px] font-medium text-global-section-fg dark:text-global-section-fg-dark",children:[n.jsx(yi,{size:11}),"Global"]}),n.jsx("span",{className:"shrink-0 text-[13px] font-medium text-foreground",children:qe??Mf}),!A&&E&&n.jsx("span",{className:"flex min-w-0 flex-1 items-center overflow-hidden whitespace-nowrap text-[12px] text-muted-foreground",children:c4(E).map((ne,we)=>ne.type==="text"?n.jsx("span",{className:ce(we===0?"min-w-0 truncate":"shrink-0"),children:ne.text},`text-${we}`):n.jsx(S6,{name:ne.name,value:pe[ne.name]??"",onCommit:tt=>Bf(ne.name,tt)},`${Ie}:${ne.name}`))})]}),n.jsx("button",{type:"button",className:"flex h-full shrink-0 items-center pl-1 pr-2",onClick:()=>_(ne=>!ne),"aria-label":"Choose page",children:n.jsx(ls,{size:12,className:ce("shrink-0 text-muted-foreground transition-transform",y&&"rotate-180")})})]}),y&&n.jsxs("div",{className:"absolute left-0 right-0 top-full z-50 mt-1.5 overflow-hidden rounded-lg border bg-popover shadow-lg",children:[n.jsxs("div",{className:"px-2 h-10 flex items-center gap-2 border-b",children:[n.jsx(sc,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),n.jsx("input",{type:"text",value:x,onChange:ne=>b(ne.target.value),placeholder:"Search pages and components...",className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground",autoFocus:!0})]}),n.jsx("div",{className:"p-1.5 border-b",children:n.jsxs("button",{type:"button",className:"flex w-full items-center gap-2.5 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:ne=>{ne.preventDefault(),_(!1),b(""),T(void 0),j(!0)},children:[n.jsx(It,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"flex-1 font-medium",children:"Create new page"})]})}),Oe.length===0&&Fe.length===0?n.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:ve.length===0&&be.length===0?"No pages found in this site.":"No results match your search."}):n.jsxs("div",{className:"max-h-80 overflow-y-auto overscroll-contain",children:[Oe.length>0&&n.jsx("div",{className:"p-1.5",children:Oe.map(ne=>n.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:we=>{we.preventDefault(),_(!1),b(""),i9(ne)},children:[n.jsx(Vi,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:ne.name}),n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:ne.path})]},ne.key))}),Fe.length>0&&n.jsxs("div",{className:ce("p-1.5",Oe.length>0&&"border-t"),children:[n.jsx("div",{className:"px-3 py-2 text-xs font-medium text-muted-foreground",children:"Global components"}),Fe.map(ne=>n.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:we=>{we.preventDefault(),_(!1),b(""),$f(ne)},children:[n.jsx(yi,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:ne.name}),n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:ne.resolveType.split("/").pop()?.replace(/\.tsx?$/,"")})]},ne.key))]})]})]})]}),n.jsxs(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsx(re,{variant:"ghost",size:"icon",onClick:()=>{const ne=Lt??ae.previewUrl;ne&&window.open(ne,"_blank","noopener")},children:n.jsx(ri,{size:14})})}),n.jsx(Ae,{side:"bottom",children:"Open in new tab"})]}),n.jsx("div",{className:"absolute inset-y-0 right-3 flex items-center md:right-4",children:n.jsxs(is,{children:[n.jsx(ns,{asChild:!0,children:n.jsx(re,{variant:"ghost",size:"icon",children:n.jsx(ln,{size:14})})}),n.jsxs(rs,{align:"end",className:"w-44",children:[n.jsx(We,{onClick:Df,children:"Hard Reload"}),n.jsx(We,{onClick:Of,children:"Copy Current URL"}),te&&fe&&n.jsxs(n.Fragment,{children:[n.jsx(zn,{}),Ie&&n.jsxs(We,{onClick:()=>{$(!0),Ln("cms")},children:[n.jsx(Jr,{size:14}),"Edit SEO"]}),Ie&&n.jsxs(We,{onClick:()=>{try{G(u9(Ie)),Ln("code")}catch{me.error("Invalid page block key")}},children:[n.jsx(nr,{size:14}),"View JSON"]}),n.jsxs(We,{onClick:()=>J(!0),children:[n.jsx(Jr,{size:14}),"Site SEO"]})]}),ue&&n.jsxs(n.Fragment,{children:[n.jsx(zn,{}),n.jsxs(We,{onClick:()=>window.open(`vscode://file${ue}?windowId=_blank`),children:[n.jsx("img",{src:H9,alt:"VSCode",width:14,height:14}),"Open in VSCode"]}),n.jsxs(We,{onClick:()=>window.open(`cursor://file${ue}?windowId=_blank`),children:[n.jsx("img",{src:U9,alt:"Cursor",width:14,height:14}),"Open in Cursor"]})]})]})]})})]})}),s==="code"&&ue&&n.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-0.5",children:[n.jsxs(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsx(re,{variant:"ghost",size:"icon","aria-label":"Open in VSCode",onClick:()=>window.open(`vscode://file${ue}?windowId=_blank`),children:n.jsx("img",{src:H9,alt:"VSCode",width:14,height:14})})}),n.jsx(Ae,{side:"bottom",children:"Open in VSCode"})]}),n.jsxs(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsx(re,{variant:"ghost",size:"icon","aria-label":"Open in Cursor",onClick:()=>window.open(`cursor://file${ue}?windowId=_blank`),children:n.jsx("img",{src:U9,alt:"Cursor",width:14,height:14})})}),n.jsx(Ae,{side:"bottom",children:"Open in Cursor"})]})]})]}),d?.slotEl&&Lr?n2.createPortal(Lr,d.slotEl):null,n.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[!d&&Lr&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"shrink-0 border-r overflow-hidden",style:{width:f.width},children:Lr}),n.jsx("div",{className:"w-1 shrink-0 cursor-col-resize bg-transparent hover:bg-border transition-colors",...f.dividerProps})]}),n.jsxs("div",{className:ce("flex-1 relative overflow-hidden",r!=="desktop"&&ae.kind==="iframe"&&s!=="code"&&"flex justify-center bg-muted/30"),children:[it&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Ji,{kind:"starting",progress:cs,claimPhase:Yt})}),ae.kind==="suspended"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Ji,{kind:"suspended",onResume:B.resume})}),ae.kind==="errored"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Ji,{kind:"errored",error:ae.error,onRetry:B.retry,connectionsHref:`/${H.slug}/settings/connections`})}),et==="visual"&&!a&&n.jsxs("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-20 flex items-center gap-1.5 rounded-full border border-violet-400/40 bg-violet-500/90 px-3 py-1 text-xs font-medium text-white shadow-md backdrop-blur-sm pointer-events-none select-none",children:[n.jsx(c9,{size:12}),"Click any element to ask the AI"]}),et==="visual"&&a&&n.jsx(Q_,{element:a,onDismiss:()=>l(null)}),Ff&&s!=="code"&&n.jsx("div",{className:"absolute bottom-4 left-1/2 z-20 -translate-x-1/2",children:n.jsxs("div",{className:"flex items-center gap-0.5 rounded-full border bg-background/90 p-1 shadow-lg backdrop-blur-sm",children:[n.jsxs(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsx(An,{onClick:()=>ea("visual"),"aria-pressed":s==="visual","aria-label":"Visual editor",active:s==="visual",children:n.jsx(c9,{size:16})})}),n.jsx(Ae,{side:"top",children:"Visual editor"})]}),n.jsxs(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsx(An,{onClick:If,"aria-label":K9[r],children:n.jsxs("span",{className:"flex items-center justify-center animate-device-icon-pop",children:[r==="mobile"&&n.jsx(N2,{size:16}),r==="tablet"&&n.jsx(T2,{size:16}),r==="desktop"&&n.jsx(E2,{size:16})]},r)})}),n.jsx(Ae,{side:"top",children:K9[r]})]})]})}),s==="code"&&Ye&&q&&e&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(R.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(Ue,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(y6,{orgSlug:H.slug,virtualMcpId:q,branch:e,openPath:Z})})}),ae.kind==="iframe"&&Lt&&n.jsx("div",{className:ce("h-full transition-[width] duration-250 [transition-timing-function:var(--ease-in-out-cubic)]",r!=="desktop"&&s!=="code"&&"w-full max-w-full border-x border-border bg-background shadow-sm"),style:{width:r==="desktop"||s==="code"?"100%":`${b6[r]}px`},children:n.jsx("iframe",{ref:c,src:Lt,className:ce("w-full h-full border-0",s==="code"&&"invisible"),title:"Dev Server Preview",tabIndex:u?-1:void 0,onLoad:()=>{if(Ze("vm_preview_loaded",{view_mode:s,vm_id:X?.sandboxHandle??null}),!A)try{const ne=c.current?.contentWindow?.location?.pathname;if(!ne)return;const we=Je.current;if(we!==null&&(Je.current=null,Ne(ne)!==Ne(we))||Ne(ne)===Ne(je))return;O(ne),Se({path:ne,pageKey:P,params:pe})}catch{}s==="visual"&&Ps(),s==="cms"&&s9()}},ae.previewUrl)})]})]}),n.jsx(V_,{open:w,onOpenChange:j,isPending:ye.isPending,error:N,templates:ve,onSubmit:zf}),V&&te&&fe&&n.jsx(R.Suspense,{fallback:null,children:n.jsx(x6,{open:V,onOpenChange:J,orgSlug:H.slug,virtualMcpId:q??"",branch:e??"",decofile:te,meta:fe,onSaved:()=>{setTimeout(()=>{const ne=c.current;if(ne)try{ne.contentWindow?.location.reload()}catch{const we=Re.current;we&&(ne.src=we)}},ha)},target:{kind:"site"}})})]})}function k6(t){const e=U.c(2),{virtualMcpId:s}=t,i=Ts(s);if(!vi(i?.metadata)){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[n.jsx(Ei,{size:24,className:"text-muted-foreground/60"}),n.jsx("div",{children:"No source to preview."}),n.jsx("div",{className:"text-xs text-muted-foreground/80",children:"Connect a GitHub repository from the Connections tab to enable Preview."})]}),e[0]=a):a=e[0],a}let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(j6,{}),e[1]=o):o=e[1],o}function N6(t,e){if(!t||!e?.length)return t;const s=Object.fromEntries(Object.entries(t.properties??{}).filter(([i])=>!e.includes(i)));return Object.keys(s).length>0?{...t,properties:s}:t}function T6(t,e,s){return typeof t!="string"?null:N6(Bs(t,e),s)}function Gu(t,e,s){if(!e||typeof t!="string")return!1;const i=T6(t,e,s);return!!i&&Object.keys(i.properties??{}).length>0}function E6({orgSlug:t,virtualMcpId:e,branch:s}){const i=Ni();return ii({mutationFn:async({blockKey:r})=>{const o=dh(r),a=await fetch(`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/unlink`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:o})});if(!a.ok){const l=await a.json().catch(()=>({}));throw new Error(l.error??`Delete failed (${a.status})`)}return a.json()},onMutate:async({blockKey:r})=>{const o=`${t}/${e}/${s}`,a=Et.decofile(o);await i.cancelQueries({queryKey:a});const l=i.getQueryData(a);return i.setQueryData(a,c=>{if(!c)return c;const{[r]:d,...h}=c;return h}),{previous:l,queryKey:a}},onError:(r,o,a)=>{a?.queryKey&&i.setQueryData(a.queryKey,a.previous)},onSuccess:()=>{const r=`${t}/${e}/${s}`;i.invalidateQueries({queryKey:Et.liveMeta(r)})}})}function Vo(t,e){return`${t}-${e}`}function qu(t,e){return`site/apps/${t}/${e}.ts`}function Yu(t){const e=t.match(/^site\/apps\/([^/]+)\/([^/.]+)\.tsx?$/);if(e)return{vendor:e[1],app:e[2]};const s=t.match(/^([^/]+)\/apps\/([^/.]+)\.tsx?$/);return s?{vendor:s[1],app:s[2]}:null}function A6(t){const e=t.match(/^([^-]+)-(.+)$/);return e?{vendor:e[1],app:e[2]}:null}function P6(t){return t==="local"?"Custom":"Installed"}function Ju(t,e,s){const i=new Set([Vo(t,e),e].map(o=>o.toLowerCase())),r=qu(t,e);for(const[o,a]of Object.entries(s)){if(o.includes("/")||!a||typeof a!="object"||Array.isArray(a))continue;const l=a;if(i.has(o.toLowerCase())||l.__resolveType===r)return o}return null}function R6(t,e){const s=t.vendor.alias,i=t.name,r=Ju(s,i,e);return{id:Vo(s,i),app:i,vendor:s,title:t.title||t.name,description:t.description,category:t.category??"Other",logo:t.logo||void 0,resolveType:qu(s,i),blockKey:r,installed:r!==null}}function D6(t,e,s){if(t===xc)return null;const i=Yu(t);if(!i)return null;const{vendor:r,app:o}=i,a=Ju(r,o,s),l=oi(t,e);return{id:Vo(r,o),app:o,vendor:r,title:l.title??o,description:l.description??"",category:"Others",logo:l.logo??l.icon,resolveType:t,blockKey:a,installed:a!==null}}function I6(t,e,s){const i=e.__resolveType;if(typeof i!="string"||fo(t,e)||!Uh(i))return null;const r=Yu(i)??A6(t);if(!r)return null;const o=oi(i,s),{vendor:a,app:l}=r;return{id:Vo(a,l),app:l,vendor:a,title:o.title??mo(t,e,s),description:o.description??"",category:P6(a),logo:o.logo??o.icon,resolveType:i,blockKey:t,installed:!0}}function O6(t,e,s){const i=new Map;for(const o of t){const a=R6(o,s);i.set(a.id,a)}const r=e.manifest?.blocks?.apps??{};for(const o of Object.keys(r)){const a=D6(o,e,s);!a||i.has(a.id)||i.set(a.id,a)}for(const[o,a]of Object.entries(s)){if(o.includes("/")||!a||typeof a!="object"||Array.isArray(a))continue;const l=I6(o,a,e);!l||i.has(l.id)||i.set(l.id,l)}return[...i.values()].sort(M6)}function M6(t,e){return t.installed!==e.installed?t.installed?-1:1:t.title.localeCompare(e.title)}async function B6(){const t=await fetch("/api/deco-apps");if(!t.ok)throw new Error(`Failed to fetch deco apps: ${t.status}`);return(await t.json()).apps??[]}function $6(t,e,s){const i=U.c(12),r=s?.enabled??!0;let o;i[0]===Symbol.for("react.memo_cache_sentinel")?(o=Et.decoApps(),i[0]=o):o=i[0];let a;i[1]!==r?(a={queryKey:o,queryFn:B6,staleTime:3e5,retry:1,enabled:r},i[1]=r,i[2]=a):a=i[2];const l=si(a);let c;i[3]!==e||i[4]!==t||i[5]!==l.data?(c=t&&e?O6(l.data??[],t,e):[],i[3]=e,i[4]=t,i[5]=l.data,i[6]=c):c=i[6];const d=c,h=l.isLoading&&!l.isError;let u;return i[7]!==d||i[8]!==l.isError||i[9]!==l.refetch||i[10]!==h?(u={catalog:d,isLoading:h,isError:l.isError,refetch:l.refetch},i[7]=d,i[8]=l.isError,i[9]=l.refetch,i[10]=h,i[11]=u):u=i[11],u}function zk(t,e,s,i,r){const o={...t[e]};if(r.length>1){const a=o.sections,l=[...a?.variants??[]];l[i]&&(l[i]={...l[i],value:s}),o.sections={...a,variants:l}}else o.sections=s;return o}function Fk(t){return structuredClone(t)}function Hk(t){return!t.isSavedBlock&&!t.isMultivariate&&!t.isHidden}function z6(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"");return/^[A-Za-z]/.test(e)?e:e?`Block${e}`:""}function Xu(t,e){const s=t.trim();return s?s.includes("/")?"Block name cannot contain slashes.":Object.hasOwn(e,s)?"A block with this name already exists.":/^[A-Za-z][A-Za-z0-9_-]*$/.test(s)?null:"Use letters, numbers, hyphens, or underscores. Must start with a letter.":"Block name is required."}function Zu(t){return(e,s)=>{Fm(e),t(e,s)}}const F6=new Set(["http:","https:","mailto:","tel:","ftp:"]);function H6(t){if(t.startsWith("/")||t.startsWith(".")||t.startsWith("#"))return!0;try{const e=new URL(t,"https://placeholder.invalid");return F6.has(e.protocol)}catch{return!1}}function Rs(t){const e=U.c(8),{active:s,label:i,onClick:r,children:o}=t,a=s?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground";let l;e[0]!==a?(l=ce("flex h-7 w-7 items-center justify-center rounded transition-colors cursor-pointer",a),e[0]=a,e[1]=l):l=e[1];let c;return e[2]!==s||e[3]!==o||e[4]!==i||e[5]!==r||e[6]!==l?(c=n.jsx("button",{type:"button","aria-label":i,"aria-pressed":s,onMouseDown:U6,onClick:r,className:l,children:o}),e[2]=s,e[3]=o,e[4]=i,e[5]=r,e[6]=l,e[7]=c):c=e[7],c}function U6(t){return t.preventDefault()}function K6({schema:t,value:e,onChange:s,path:i,label:r}){const o=typeof e=="string"?e:"",a=R.useRef(s);a.current=s;const l=lm({extensions:[cm.configure({heading:{levels:[1,2,3]}})],content:o||"",editorProps:{attributes:{class:ce("prose prose-sm dark:prose-invert max-w-none focus:outline-none","min-h-[80px] px-3 py-2")}},onUpdate:({editor:c})=>{const d=c.getHTML();a.current(d==="<p></p>"?"":d)}});return l?n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"space-y-0.5",children:[n.jsx(Ve,{htmlFor:i,children:r}),t.description&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:t.description})]}),n.jsxs("div",{className:"overflow-hidden rounded-md border border-input",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 border-b border-border/60 bg-muted/30 px-1.5 py-1",children:[n.jsx(Rs,{active:l.isActive("bold"),label:"Bold",onClick:()=>l.chain().focus().toggleBold().run(),children:n.jsx(P2,{size:14})}),n.jsx(Rs,{active:l.isActive("italic"),label:"Italic",onClick:()=>l.chain().focus().toggleItalic().run(),children:n.jsx(R2,{size:14})}),n.jsx(Rs,{active:l.isActive("underline"),label:"Underline",onClick:()=>l.chain().focus().toggleUnderline().run(),children:n.jsx(D2,{size:14})}),n.jsx(Rs,{active:l.isActive("strike"),label:"Strikethrough",onClick:()=>l.chain().focus().toggleStrike().run(),children:n.jsx(I2,{size:14})}),n.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),n.jsx(Rs,{active:l.isActive("heading",{level:1}),label:"Heading 1",onClick:()=>l.chain().focus().toggleHeading({level:1}).run(),children:n.jsx(O2,{size:14})}),n.jsx(Rs,{active:l.isActive("heading",{level:2}),label:"Heading 2",onClick:()=>l.chain().focus().toggleHeading({level:2}).run(),children:n.jsx(M2,{size:14})}),n.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),n.jsx(Rs,{active:l.isActive("bulletList"),label:"Bullet list",onClick:()=>l.chain().focus().toggleBulletList().run(),children:n.jsx(A3,{size:14})}),n.jsx(Rs,{active:l.isActive("orderedList"),label:"Ordered list",onClick:()=>l.chain().focus().toggleOrderedList().run(),children:n.jsx("span",{className:"text-[11px] font-semibold leading-none",children:"1."})}),n.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),n.jsx(Rs,{active:l.isActive("link"),label:"Link",onClick:()=>{const c=l.getAttributes("link").href,d=window.prompt("Link URL",c??"https://");d!==null&&(d===""?l.chain().focus().unsetLink().run():H6(d)&&l.chain().focus().setLink({href:d}).run())},children:n.jsx(Z2,{size:14})})]}),n.jsx(dm,{editor:l})]})]}):null}const Ki=t=>String(t).padStart(2,"0"),W6="1900-01-01",V6="2099-12-31",G6="1900-01-01T00:00",q6="2099-12-31T23:59";function Y6(t){if(!t)return"";const e=t.slice(0,10);if(/^\d{4}-\d{2}-\d{2}$/.test(e))return e;const s=new Date(t);return Number.isNaN(s.getTime())?"":`${s.getUTCFullYear()}-${Ki(s.getUTCMonth()+1)}-${Ki(s.getUTCDate())}`}function J6(t){return!t||!/^\d{4}-\d{2}-\d{2}$/.test(t)?"":`${t}T00:00:00.000Z`}function X6(t){if(!t)return"";const e=new Date(t);return Number.isNaN(e.getTime())?"":`${e.getFullYear()}-${Ki(e.getMonth()+1)}-${Ki(e.getDate())}T${Ki(e.getHours())}:${Ki(e.getMinutes())}`}function Z6(t){if(!t)return"";const e=new Date(t);return Number.isNaN(e.getTime())?"":e.toISOString()}function Q6(t){const e=U.c(29),{id:s,withTime:i,value:r,onChange:o}=t,[a,l]=R.useState(!1);let c;e[0]!==r||e[1]!==i?(c=i?X6(r):Y6(r),e[0]=r,e[1]=i,e[2]=c):c=e[2];const d=c;let h;e[3]!==o||e[4]!==i?(h=N=>{o(i?Z6(N.target.value):J6(N.target.value))},e[3]=o,e[4]=i,e[5]=h):h=e[5];const u=h;let f;if(e[6]!==r){const N=r?new Date(r):null;f=N&&!Number.isNaN(N.getTime())?N:null,e[6]=r,e[7]=f}else f=e[7];const m=f;let p;e[8]!==o||e[9]!==m||e[10]!==i?(p=N=>{N&&(i&&m?N.setHours(m.getHours(),m.getMinutes(),0,0):N.setHours(0,0,0,0),o(N.toISOString()),l(!1))},e[8]=o,e[9]=m,e[10]=i,e[11]=p):p=e[11];const g=p,L=i?"datetime-local":"date",v=i?G6:W6,y=i?q6:V6;let _;e[12]!==u||e[13]!==s||e[14]!==d||e[15]!==L||e[16]!==v||e[17]!==y?(_=n.jsx(Ke,{id:s,type:L,min:v,max:y,value:d,onChange:u,className:"h-10 flex-1 [&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:opacity-0"}),e[12]=u,e[13]=s,e[14]=d,e[15]=L,e[16]=v,e[17]=y,e[18]=_):_=e[18];let x;e[19]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(ps,{asChild:!0,children:n.jsx(re,{type:"button",variant:"outline",size:"icon",className:"h-10 w-10 shrink-0","aria-label":"Open calendar",children:n.jsx(Dd,{className:"h-4 w-4"})})}),e[19]=x):x=e[19];const b=m??void 0;let S;e[20]!==g||e[21]!==b?(S=n.jsx(gs,{className:"w-auto p-0",align:"end",children:n.jsx(R3,{mode:"single",selected:b,onSelect:g,initialFocus:!0})}),e[20]=g,e[21]=b,e[22]=S):S=e[22];let w;e[23]!==a||e[24]!==S?(w=n.jsxs(ms,{open:a,onOpenChange:l,children:[x,S]}),e[23]=a,e[24]=S,e[25]=w):w=e[25];let j;return e[26]!==w||e[27]!==_?(j=n.jsxs("div",{className:"flex gap-1",children:[_,w]}),e[26]=w,e[27]=_,e[28]=j):j=e[28],j}function jr(t){const e=U.c(8),{htmlFor:s,label:i,description:r}=t;let o;e[0]!==s||e[1]!==i?(o=n.jsx(Ve,{htmlFor:s,children:i}),e[0]=s,e[1]=i,e[2]=o):o=e[2];let a;e[3]!==r?(a=r&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:r}),e[3]=r,e[4]=a):a=e[4];let l;return e[5]!==o||e[6]!==a?(l=n.jsxs("div",{className:"space-y-0.5",children:[o,a]}),e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function kr(t){const e=U.c(67),{schema:s,value:i,onChange:r,path:o,label:a}=t,l=typeof i=="string"?i:"",c=s.format;if(c==="rich-text"||c==="rich-text-inline"||c==="html"){let g;return e[0]!==a||e[1]!==r||e[2]!==o||e[3]!==s||e[4]!==i?(g=n.jsx(K6,{schema:s,value:i,onChange:r,path:o,label:a}),e[0]=a,e[1]=r,e[2]=o,e[3]=s,e[4]=i,e[5]=g):g=e[5],g}if(c==="textarea"||c==="markdown"){let g;e[6]!==a||e[7]!==o||e[8]!==s.description?(g=n.jsx(jr,{htmlFor:o,label:a,description:s.description}),e[6]=a,e[7]=o,e[8]=s.description,e[9]=g):g=e[9];let L;e[10]!==r?(L=_=>r(_.target.value),e[10]=r,e[11]=L):L=e[11];let v;e[12]!==o||e[13]!==l||e[14]!==L?(v=n.jsx(Yn,{id:o,value:l,onChange:L,rows:4}),e[12]=o,e[13]=l,e[14]=L,e[15]=v):v=e[15];let y;return e[16]!==g||e[17]!==v?(y=n.jsxs("div",{className:"space-y-2",children:[g,v]}),e[16]=g,e[17]=v,e[18]=y):y=e[18],y}if(c==="date"||c==="date-time"){let g;e[19]!==a||e[20]!==o||e[21]!==s.description?(g=n.jsx(jr,{htmlFor:o,label:a,description:s.description}),e[19]=a,e[20]=o,e[21]=s.description,e[22]=g):g=e[22];const L=c==="date-time";let v;e[23]!==r||e[24]!==o||e[25]!==l||e[26]!==L?(v=n.jsx(Q6,{id:o,withTime:L,value:l,onChange:r}),e[23]=r,e[24]=o,e[25]=l,e[26]=L,e[27]=v):v=e[27];let y;return e[28]!==g||e[29]!==v?(y=n.jsxs("div",{className:"space-y-2",children:[g,v]}),e[28]=g,e[29]=v,e[30]=y):y=e[30],y}if(c==="color-input"||c==="color"){let g;e[31]!==a||e[32]!==o||e[33]!==s.description?(g=n.jsx(jr,{htmlFor:o,label:a,description:s.description}),e[31]=a,e[32]=o,e[33]=s.description,e[34]=g):g=e[34];const L=l||"#000000";let v;e[35]!==r?(v=w=>r(w.target.value),e[35]=r,e[36]=v):v=e[36];let y;e[37]!==L||e[38]!==v?(y=n.jsx("input",{type:"color",value:L,onChange:v,className:"h-10 w-10 cursor-pointer rounded-lg border border-border bg-background p-1"}),e[37]=L,e[38]=v,e[39]=y):y=e[39];let _;e[40]!==r?(_=w=>r(w.target.value),e[40]=r,e[41]=_):_=e[41];let x;e[42]!==o||e[43]!==l||e[44]!==_?(x=n.jsx(Ke,{id:o,value:l,onChange:_,placeholder:"#000000",className:"h-10 flex-1"}),e[42]=o,e[43]=l,e[44]=_,e[45]=x):x=e[45];let b;e[46]!==y||e[47]!==x?(b=n.jsxs("div",{className:"flex items-center gap-2",children:[y,x]}),e[46]=y,e[47]=x,e[48]=b):b=e[48];let S;return e[49]!==g||e[50]!==b?(S=n.jsxs("div",{className:"space-y-2",children:[g,b]}),e[49]=g,e[50]=b,e[51]=S):S=e[51],S}let d;e[52]!==a||e[53]!==o||e[54]!==s.description?(d=n.jsx(jr,{htmlFor:o,label:a,description:s.description}),e[52]=a,e[53]=o,e[54]=s.description,e[55]=d):d=e[55];const h=c==="url"?"url":"text";let u;e[56]!==r?(u=g=>r(g.target.value),e[56]=r,e[57]=u):u=e[57];const f=s.default!=null?String(s.default):void 0;let m;e[58]!==o||e[59]!==l||e[60]!==h||e[61]!==u||e[62]!==f?(m=n.jsx(Ke,{id:o,type:h,value:l,onChange:u,placeholder:f,className:"h-10"}),e[58]=o,e[59]=l,e[60]=h,e[61]=u,e[62]=f,e[63]=m):m=e[63];let p;return e[64]!==d||e[65]!==m?(p=n.jsxs("div",{className:"space-y-2",children:[d,m]}),e[64]=d,e[65]=m,e[66]=p):p=e[66],p}const eL=/^[+-]?\d*\.?\d*(?:[eE][+-]?\d*)?$/;function tL(t){const e=U.c(18),{schema:s,value:i,onChange:r,path:o,label:a}=t,l=typeof i=="number"?String(i):"",[c,d]=R.useState(l),[h,u]=R.useState(l);l!==h&&(u(l),c!==""&&l!==""&&Number(c)===Number(l)||d(l));let f;e[0]!==a||e[1]!==o?(f=n.jsx(Ve,{htmlFor:o,children:a}),e[0]=a,e[1]=o,e[2]=f):f=e[2];let m;e[3]!==s.description?(m=s.description&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[3]=s.description,e[4]=m):m=e[4];let p;e[5]!==f||e[6]!==m?(p=n.jsxs("div",{className:"space-y-0.5",children:[f,m]}),e[5]=f,e[6]=m,e[7]=p):p=e[7];const g=s.type==="integer"?"numeric":"decimal";let L;e[8]!==r?(L=_=>{const x=_.target.value;if(x!==""&&!eL.test(x))return;d(x);const b=Number(x);r(x===""||Number.isNaN(b)?void 0:b)},e[8]=r,e[9]=L):L=e[9];let v;e[10]!==o||e[11]!==c||e[12]!==g||e[13]!==L?(v=n.jsx(Ke,{id:o,type:"text",inputMode:g,value:c,onChange:L,className:"h-10"}),e[10]=o,e[11]=c,e[12]=g,e[13]=L,e[14]=v):v=e[14];let y;return e[15]!==p||e[16]!==v?(y=n.jsxs("div",{className:"space-y-2",children:[p,v]}),e[15]=p,e[16]=v,e[17]=y):y=e[17],y}function sL(t){const e=U.c(17),{value:s,onChange:i,path:r,label:o,schema:a}=t,l=typeof s=="boolean"?s:!1;let c;e[0]!==o||e[1]!==r?(c=n.jsx(Ve,{htmlFor:r,children:o}),e[0]=o,e[1]=r,e[2]=c):c=e[2];let d;e[3]!==a.description?(d=a.description&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:a.description}),e[3]=a.description,e[4]=d):d=e[4];let h;e[5]!==c||e[6]!==d?(h=n.jsxs("div",{className:"space-y-0.5",children:[c,d]}),e[5]=c,e[6]=d,e[7]=h):h=e[7];let u;e[8]!==i?(u=p=>i(p),e[8]=i,e[9]=u):u=e[9];let f;e[10]!==l||e[11]!==r||e[12]!==u?(f=n.jsx(Jn,{id:r,checked:l,onCheckedChange:u}),e[10]=l,e[11]=r,e[12]=u,e[13]=f):f=e[13];let m;return e[14]!==h||e[15]!==f?(m=n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[h,f]}),e[14]=h,e[15]=f,e[16]=m):m=e[16],m}const Rc="__enum_empty__";function Dc(t){return t===""?Rc:String(t)}function iL(t,e){if(t===Rc)return"";const s=e.find(i=>Dc(i)===t);return s!==void 0?s:t}function nL(t,e){return t==null?e.some(s=>s==="")?Rc:void 0:Dc(t)}function rL(t){return t===""?"":String(t)}function oL(t){const e=U.c(28),{schema:s,value:i,onChange:r,path:o,label:a}=t;let l;e[0]!==s.enum?(l=s.enum??[],e[0]=s.enum,e[1]=l):l=e[1];const c=l;let d;e[2]!==c||e[3]!==i?(d=nL(i,c),e[2]=c,e[3]=i,e[4]=d):d=e[4];const h=d;let u;e[5]!==a||e[6]!==o?(u=n.jsx(Ve,{htmlFor:o,children:a}),e[5]=a,e[6]=o,e[7]=u):u=e[7];let f;e[8]!==s.description?(f=s.description&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[8]=s.description,e[9]=f):f=e[9];let m;e[10]!==u||e[11]!==f?(m=n.jsxs("div",{className:"space-y-0.5",children:[u,f]}),e[10]=u,e[11]=f,e[12]=m):m=e[12];let p;e[13]!==r||e[14]!==c?(p=x=>r(iL(x,c)),e[13]=r,e[14]=c,e[15]=p):p=e[15];let g;e[16]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(kt,{className:"h-10",children:n.jsx(Rt,{placeholder:"Select..."})}),e[16]=g):g=e[16];let L;e[17]!==c?(L=c.map(aL),e[17]=c,e[18]=L):L=e[18];let v;e[19]!==L?(v=n.jsx(Nt,{children:L}),e[19]=L,e[20]=v):v=e[20];let y;e[21]!==h||e[22]!==p||e[23]!==v?(y=n.jsxs(Tt,{value:h,onValueChange:p,children:[g,v]}),e[21]=h,e[22]=p,e[23]=v,e[24]=y):y=e[24];let _;return e[25]!==y||e[26]!==m?(_=n.jsxs("div",{className:"space-y-2",children:[m,y]}),e[25]=y,e[26]=m,e[27]=_):_=e[27],_}function aL(t){const e=Dc(t);return n.jsx(ot,{value:e,children:rL(t)},e)}function Qu(t){if(!t||typeof t!="object"||Array.isArray(t))return null;const e=t;return Array.isArray(e.variants)?e:null}function Hn(t){return Qu(t)?.variants?.[0]?.rule?.__resolveType===hn}function W9(t){return{__resolveType:Oi,variants:[{value:t,rule:{__resolveType:hn}}]}}function e1(t){return Hn(t)?Qu(t)?.variants?.[0]?.value:t}function Dn(t){return Hn(t)?e1(t):t}function Ic(t){const e=t.__resolveType;if(typeof e!="string")return null;if(At(e)){const i=t.section?.__resolveType;return typeof i=="string"?i:e}return e}function lL(t){return t.includes("flags/multivariate")}function cL(t){return ut(t)}function dL(t,e){const s=[...t],i=new Set(s.map(o=>o.resolveType)),r=(o,a)=>{!o||i.has(o)||(i.add(o),s.push({resolveType:o,title:a??cL(o)}))};if(e.savedBlockKey&&r(e.savedBlockKey,e.savedBlockKey),e.editorValue&&typeof e.editorValue=="object"&&!Array.isArray(e.editorValue)){const o=Ic(e.editorValue);o?.includes("/")&&r(o)}return s}function hL(t,e,s){const i=e[0]?.resolveType??"";if(s)return s;if(!t||typeof t!="object"||Array.isArray(t))return i;const r=t,o=r.__resolveType;if(typeof o=="string"){if(ks(o)){const u=e.find(f=>f.resolveType===o);return u?u.resolveType:o}const d=e.find(u=>y9(u.resolveType,o));if(d)return d.resolveType;const h=e.find(u=>u.resolveType===o);if(h)return h.resolveType;if(o.includes("/"))return o}const a=typeof r.type=="string"?r.type:void 0;if(a){const d=e.find(h=>h.discriminatorValue===a||h.resolveType===a||y9(h.resolveType,a));if(d)return d.resolveType}let l=i,c=-1;for(const d of e){if(!d.schema?.properties)continue;const u=Object.keys(d.schema.properties).filter(f=>!f.startsWith("__")&&f!=="@type"&&f!=="action"&&f!=="alt").filter(f=>r[f]!==void 0).length;u>0&&u>c&&(c=u,l=d.resolveType)}return c>0,l}function V9(t,e,s){if(!t||typeof t!="object"||Array.isArray(t))return s??null;const i=Ic(t);if(!i)return s??null;if(!e)return i.includes("/")?null:s??null;const r=Bs(i,e);return r||(i.includes("/")?null:s??null)}function uL(t,e){if(!t?.properties||!e)return t??null;if(!(e in t.properties))return t;const s={...t.properties};return delete s[e],{...t,properties:s}}function t1(t){if(!t||typeof t!="object"||Array.isArray(t))return null;const e=t;if(typeof e.__resolveType!="string"||!At(e.__resolveType))return null;const s=e.section;return!s||typeof s!="object"||Array.isArray(s)?null:s}function fL(t,e){if(e)return!0;if(!t||typeof t!="object"||Array.isArray(t))return!1;const s=t,i=Ic(s);return i&&lL(i)?Array.isArray(s.variants)&&s.variants.length>0:Object.keys(s).some(r=>!r.startsWith("__")&&r!=="@type")}function Oc(t){if(typeof t=="string")return t;if(!t||typeof t!="object")return"";const e=t;if(Array.isArray(e.variants)){const s=e.variants,i=s.find(o=>o.rule?.__resolveType?.includes("always"));if(typeof i?.value=="string")return i.value;const r=s.find(o=>typeof o.value=="string");if(r)return r.value}return typeof e.src=="string"?e.src:typeof e.url=="string"?e.url:typeof e.value=="string"?e.value:""}function mL(t){if(t?.trim())try{const e=new URL(t);return e.protocol!=="https:"?void 0:e.href}catch{return}}function pL(t){if(Array.isArray(t.variants)){const e=t.variants,s=e.find(r=>r.rule?.__resolveType?.includes("always"));if(typeof s?.value=="string")return s.value;const i=e.find(r=>typeof r.value=="string");if(i)return i.value}if(typeof t.src=="string")return t.src;if(typeof t.url=="string")return t.url;if(typeof t.value=="string")return t.value}function s1(t){if(typeof t=="string"||t==null||typeof t!="object")return t;if(Array.isArray(t))return t.map(s1);const e=t;return e.__resolveType?pL(e)??t:i1(e)}function i1(t){const e={};for(const[s,i]of Object.entries(t))e[s]=s1(i);return e}function gL(t,e){return e.split(".").reduce((s,i)=>{if(!(s==null||typeof s!="object"))return s[i]},t)}function n1(t){return t==null?"":Array.isArray(t)?t.map(n1).filter(Boolean).join(","):typeof t=="object"?"":String(t)}function Mc(t,e){if(!t.includes("{"))return;const s=i1(e);return t.replace(/\{\{\{([^}]+)\}\}\}|\{\{([^}]+)\}\}/g,(r,o,a)=>{const l=(o??a??"").trim();return n1(gL(s,l))}).trim()||void 0}function _L(t){return t.replace(/<[^>]*>/g,"").trim()}function LL(t,e){if(e.includes("{"))return Mc(e,t);const s=t[e];if(typeof s=="string"&&s)return s;if(Array.isArray(s)){const i=s.map(r=>r==null?"":String(r)).filter(Boolean).join(",");if(i)return i}}function mi(t,e,s){if(typeof t=="string")return t.trim()?t:`Item ${e+1}`;if(typeof t=="number"||typeof t=="boolean")return String(t);if(t&&typeof t=="object"&&!Array.isArray(t)){let i=Dn(t);const r=t1(i);if(r&&(i=r),s?.titleBy){const a=LL(i,s.titleBy);if(a)return a}for(const a of["name","label","title","alt","text","href","id","key"]){const l=i[a];if(typeof l=="string"&&l.trim()){const c=s?.properties?.[a]?.format;if(c==="rich-text"||c==="html"){const d=_L(l);if(d)return d;continue}return l}if(Array.isArray(l)){const c=l.map(d=>d==null?"":String(d)).filter(Boolean).join(",");if(c)return c}}const o=i.__resolveType;if(typeof o=="string"&&o)return ut(o);if(s?.title){const a=Mc(s.title,i);if(a)return a;if(!s.title.includes("{"))return s.title}}return`Item ${e+1}`}function vL(t){if(!t)return;if(typeof t.image=="string"&&t.image.includes("{"))return t.image;const e=t.properties?.image;if(!e)return;if(e.format==="image-uri")return"{{{image}}}";const s=e.properties;return s?.mobile?"{{{image.mobile}}}":s?.desktop?"{{{image.desktop}}}":"{{{image}}}"}function G9(t,e){if(!t||typeof t!="object"||Array.isArray(t))return;const s=vL(e);if(!s)return;const i=Mc(s,t);if(!i)return;const r=Oc(i)||i;return mL(r)}function r1(t){return t.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]/g," ").replace(/^\w/,e=>e.toUpperCase())}function Ci(t){return t.normalize("NFC").trim()}function wt(t,e){return Ci(t)===Ci(e)}function q9(t,e){return Ci(t).replace(/\s+/g,"").toLowerCase()===Ci(e).replace(/\s+/g,"").toLowerCase()}function Nr(t,e,s){const i=Ci(s);if(t.some(a=>wt(a,i)||wt(a,s)))return t;const r=[...t];return r.some(a=>wt(a,e))||r.push(e),r.push(s),r}function xL(t,e){return t.slice(0,t.length-e.length)}function yL(t,e,s){if(s.length===0)return s;const i=Un(t,e),r=s[0];return wt(r,i)||wt(r,t)?s.slice(1):s}function Un(t,e){return e.title??r1(t)}function Uk(t,e){return e<=0?[]:t.slice(0,e)}function fa(t,e){const s=Ci(e);return t.findIndex(i=>Ci(i)===s)}function Y9(t,e){return t.type==="array"&&t.items||Uo(t)?!0:Array.isArray(e)}function bL(t){return t!=null&&typeof t=="object"&&!Array.isArray(t)?t:{}}function Qn(t,e,s,i){if(i.length===0)return null;const r=i[0];for(const a of t){const l=e[a];if(!l||!Y9(l,s[a]))continue;const c=Un(a,l);if(wt(r,c)||wt(r,a)||i.some(d=>wt(d,c)||wt(d,a)))return a}for(const a of t){const l=e[a];if(!l||!Y9(l,s[a]))continue;const c=s[a];if(!Array.isArray(c))continue;const d=l.items;for(let h=0;h<c.length;h++){const u=mi(c[h],h,d);if(wt(u,r))return a}}for(const a of t){const l=e[a];if(l?.type!=="object"||!l.properties)continue;const c=Object.keys(l.properties),d=bL(s[a]),h=Un(a,l);if(Qn(c,l.properties,d,i)||(wt(r,h)||wt(r,a))&&Qn(c,l.properties,d,i.slice(1)))return a}let o=null;for(const a of t){const l=e[a];if(l?.type!=="block-ref")continue;const c=Un(a,l);if(!(r!==c&&r!==a)){if(i.length>1){const d=s[a];if(d&&typeof d=="object"&&!Array.isArray(d)){const h=i[1];if(Object.keys(d).some(f=>!f.startsWith("__")&&(q9(r1(f),h)||q9(f,h))))return a}}o||(o=a)}}return o||null}function SL(t,e,s,i){return Qn(t,e,s,i)}function wL(t,e,s,i,r){if(r.length===0||!s.properties)return!1;const o=Object.keys(s.properties);if(Qn(o,s.properties,i,r))return!0;const a=r[0];return!wt(a,e)&&!wt(a,t)?!1:r.length>1||Qn(o,s.properties,i,r.slice(1))!==null}function J9(t,e,s,i){return i!=null&&i>=0&&i<t.length&&wt(mi(t[i],i,e),s)?i:t.findIndex((r,o)=>wt(mi(r,o,e),s))}function CL(t,e,s,i,r){if(e.length===0)return null;for(let a=0;a<e.length;a++){const l=e[a],c=J9(s,i,l,r);if(c>=0)return{index:c,innerPath:e.slice(a+1)}}const o=e.findIndex(a=>wt(a,t));if(o>=0&&e.length>o+1){const a=e[o+1],l=J9(s,i,a,r);if(l>=0)return{index:l,innerPath:e.slice(o+2)}}return null}function ma(t){return t.includes("/sections/")||t.includes("multivariate/section")||t===fr}function jL(t){if(t.type==="block-ref"&&t.anyOfRefs?.length)return t.anyOfRefs.some(s=>ma(s.resolveType));if(t.anyOfRefs?.length)return t.anyOfRefs.some(s=>ma(s.resolveType));const e=t.properties?.__resolveType;return e?.type==="block-ref"&&e.anyOfRefs?.length?e.anyOfRefs.some(s=>ma(s.resolveType)):!1}function kL(t,e){if(e==="global"||e==="sections"||Uo(t))return!0;const s=t.type==="array"?t.items:void 0;return s?jL(s):!1}function X9(t){return Array.from({length:t},(e,s)=>({id:crypto.randomUUID(),index:s}))}function NL(t,e,s,i,r){if(e?.type==="object"&&e.properties&&Object.keys(e.properties).length>0||e?.type==="block-ref"&&e.anyOfRefs?.length)return e;if(t!=null&&typeof t=="object"&&!Array.isArray(t)){const o=t.__resolveType;if(typeof o=="string"&&s){const a=Bs(o,s);if(a?.properties&&Object.keys(a.properties).length>0)return a}}if(s&&i&&r){const a=Bs(i,s)?.properties?.[r]?.items;if(a?.properties&&Object.keys(a.properties).length>0)return{...a,titleBy:a.titleBy??e?.titleBy}}return e}function TL(t){const e=t.split(".").filter(s=>!/^\d+$/.test(s));return e[e.length-1]??t}function o1(t){return t.map((e,s)=>({...e,index:s}))}function EL(t,e){if(e===t.length)return t;if(e<t.length)return o1(t.slice(0,e));const s=Array.from({length:e-t.length},(i,r)=>({id:crypto.randomUUID(),index:t.length+r}));return[...t,...s]}function AL(t){const e=U.c(8),{labelText:s,imageSrc:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(Yl,{className:"size-3.5 shrink-0 text-muted-foreground/40"}),e[0]=r):r=e[0];let o;e[1]!==i?(o=i&&n.jsx("img",{src:i,alt:"",referrerPolicy:"no-referrer",className:"h-12 max-w-[100px] shrink-0 rounded object-cover"}),e[1]=i,e[2]=o):o=e[2];let a;e[3]!==s?(a=n.jsx("span",{className:"min-w-0 truncate",children:s}),e[3]=s,e[4]=a):a=e[4];let l;return e[5]!==o||e[6]!==a?(l=n.jsxs(n.Fragment,{children:[r,n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2.5 text-sm",children:[o,a]})]}),e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function PL(t){const e=U.c(50),{sortableId:s,labelText:i,imageSrc:r,hidden:o,onToggleHidden:a,onOpen:l,onDuplicate:c,onRemove:d}=t;let h;e[0]!==s?(h={id:s,animateLayoutChanges:OL},e[0]=s,e[1]=h):h=e[1];const{attributes:u,listeners:f,setNodeRef:m,transform:p,isDragging:g}=eh(h);let L;e[2]!==p?(L=th.Transform.toString(p?{...p,x:0}:null),e[2]=p,e[3]=L):L=e[3];const v=g?0:void 0;let y;e[4]!==L||e[5]!==v?(y={transform:L,opacity:v},e[4]=L,e[5]=v,e[6]=y):y=e[6];const _=y;let x;e[7]!==l?(x=V=>{(V.key==="Enter"||V.key===" ")&&(V.preventDefault(),l())},e[7]=l,e[8]=x):x=e[8];const b=g?"cursor-grabbing":"cursor-pointer";let S;e[9]!==b?(S=ce("group flex min-w-0 items-center gap-2.5 rounded-lg px-2 py-2.5 hover:bg-accent hover:text-accent-foreground touch-none",b),e[9]=b,e[10]=S):S=e[10];let w;e[11]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(Yl,{className:"size-3.5 shrink-0 text-muted-foreground/40"}),e[11]=w):w=e[11];let j;e[12]!==r?(j=r&&n.jsx("img",{src:r,alt:"",referrerPolicy:"no-referrer",className:"h-12 max-w-[100px] shrink-0 rounded object-cover"}),e[12]=r,e[13]=j):j=e[13];const N=o&&"line-through opacity-50";let T;e[14]!==N?(T=ce("min-w-0 flex-1 truncate text-sm",N),e[14]=N,e[15]=T):T=e[15];let A;e[16]!==i||e[17]!==T?(A=n.jsx("span",{className:T,children:i}),e[16]=i,e[17]=T,e[18]=A):A=e[18];let k;e[19]!==o||e[20]!==a?(k=a&&n.jsxs(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsx(re,{type:"button",variant:"ghost",size:"icon","aria-label":o?"Show item":"Hide item",className:ce("size-6 shrink-0",o?"opacity-100":"opacity-0 transition-opacity group-hover:opacity-100"),onClick:V=>{V.stopPropagation(),a()},onPointerDown:IL,children:o?n.jsx(u3,{size:14}):n.jsx(xh,{size:14})})}),n.jsx(Ae,{side:"bottom",children:o?"Show item":"Hide item"})]}),e[19]=o,e[20]=a,e[21]=k):k=e[21];const C=`Open actions for ${i}`;let I;e[22]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx(ln,{size:14}),e[22]=I):I=e[22];let E;e[23]!==C?(E=n.jsx(ns,{asChild:!0,children:n.jsx(re,{type:"button",variant:"ghost",size:"icon","aria-label":C,className:"size-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",onClick:DL,onPointerDown:RL,children:I})}),e[23]=C,e[24]=E):E=e[24];let O;e[25]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(ts,{size:14}),e[25]=O):O=e[25];let P;e[26]!==c?(P=n.jsxs(We,{onClick:c,children:[O,"Duplicate"]}),e[26]=c,e[27]=P):P=e[27];let D;e[28]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx(os,{size:14}),e[28]=D):D=e[28];let M;e[29]!==d?(M=n.jsxs(We,{className:"text-destructive focus:text-destructive",onClick:d,children:[D,"Delete"]}),e[29]=d,e[30]=M):M=e[30];let z;e[31]!==P||e[32]!==M?(z=n.jsxs(rs,{align:"end",children:[P,M]}),e[31]=P,e[32]=M,e[33]=z):z=e[33];let F;e[34]!==E||e[35]!==z?(F=n.jsxs(is,{children:[E,z]}),e[34]=E,e[35]=z,e[36]=F):F=e[36];let $;return e[37]!==u||e[38]!==i||e[39]!==f||e[40]!==l||e[41]!==m||e[42]!==_||e[43]!==A||e[44]!==k||e[45]!==F||e[46]!==x||e[47]!==S||e[48]!==j?($=n.jsxs("div",{ref:m,style:_,...u,...f,role:"button",tabIndex:0,onClick:l,onKeyDown:x,className:S,title:i,children:[w,j,A,k,F]}),e[37]=u,e[38]=i,e[39]=f,e[40]=l,e[41]=m,e[42]=_,e[43]=A,e[44]=k,e[45]=F,e[46]=x,e[47]=S,e[48]=j,e[49]=$):$=e[49],$}function RL(t){return t.stopPropagation()}function DL(t){return t.stopPropagation()}function IL(t){return t.stopPropagation()}function OL(){return!1}function Tr(t){const e=U.c(24),{schema:s,value:i,onChange:r,path:o,label:a,breadcrumbPath:l,onBreadcrumbChange:c,meta:d,decofile:h,onSaveReferencedBlock:u,containerResolveType:f,previewBaseUrl:m,onAddSectionItem:p,onRequestAddSection:g,sandbox:L}=t,v=l===void 0?[]:l,y=Array.isArray(i)?i:[],_=s.items,x=TL(o),b=kL(s,x),S=!b&&_?.type==="object",[w,j]=R.useState(null),N=CL(a,v,y,_,w),T=N?.index??null;N===null?w!==null&&j(null):N.index!==w&&j(N.index);const[A,k]=R.useState(()=>X9(y.length)),[C,I]=R.useState(null),[E,O]=R.useState(o),[P,D]=R.useState(y.length),M=R.useRef(!1);E!==o?(O(o),D(y.length),k(X9(y.length)),j(null)):P!==y.length&&(D(y.length),k(le=>EL(le,y.length)));let z;e[0]!==_?(z=(le,Le)=>mi(Dn(le),Le,_),e[0]=_,e[1]=z):z=e[1];const F=z,$=le=>{if(M.current)return;const Le=F(y[le],le);j(le),c?.(Nr(v,a,Le))},V=le=>{const Le=[...y,le];r(Le);const Ce=Le.length-1;j(Ce);const _e=mi(le,Ce,_);c?.(Nr(v,a,_e))},J=()=>{const le=_?.type,Le=_?.default!==void 0?_.default:le==="object"?{}:le==="block-ref"?(()=>{const Je=_?.anyOfRefs?.[0]?.resolveType;return typeof Je!="string"||uo(Je)?{}:{__resolveType:Je}})():le==="number"||le==="integer"?0:le==="boolean"?!1:le==="array"?[]:"",Ce=[...y,Le];r(Ce);const _e=Ce.length-1;j(_e);const Re=mi(Le,_e,_);c?.(Nr(v,a,Re))},Z=()=>{if(b){if(!m){me.error("Start the preview dev server to add sections.");return}if(g){g({append:V});return}me.error("Section picker is not available in this editor.");return}J()},G=le=>{const Le=y[le],Ce=typeof structuredClone=="function"?structuredClone(Le):JSON.parse(JSON.stringify(Le??null)),_e=[...y.slice(0,le+1),Ce,...y.slice(le+1)];r(_e)},q=le=>{const Le=y[le],Ce=[...y];Ce[le]=Hn(Le)?e1(Le):W9(Le),r(Ce)},H=le=>{if(r(y.filter((Le,Ce)=>Ce!==le)),T===le){const Le=F(y[le],le),Ce=fa(v,Le);c?.(Ce>=0?v.slice(0,Ce):[])}},K=(le,Le)=>{const Ce=[...y];if(Ce[le]=Hn(y[le])?W9(Le):Le,r(Ce),le===T&&T!==null){const _e=F(y[le],le),Re=mi(Le,le,_);if(_e!==Re){const Je=fa(v,_e);if(Je>=0){const $t=[...v];$t[Je]=Re,c?.($t)}}}};let B;e[2]===Symbol.for("react.memo_cache_sentinel")?(B={activationConstraint:{distance:8}},e[2]=B):B=e[2];let X;e[3]===Symbol.for("react.memo_cache_sentinel")?(X={coordinateGetter:sh},e[3]=X):X=e[3];const W=Vd(Zr(qd,B),Zr(Gd,X)),Y=A.map(ML);let Q;e[4]===Symbol.for("react.memo_cache_sentinel")?(Q=le=>{I(String(le.active.id))},e[4]=Q):Q=e[4];const ie=Q,oe=le=>{I(null);const{active:Le,over:Ce}=le;if(!Ce||Le.id===Ce.id)return;const _e=Y.indexOf(String(Le.id)),Re=Y.indexOf(String(Ce.id));_e===-1||Re===-1||(k(Je=>o1(za([...Je],_e,Re))),r(za([...y],_e,Re)),M.current=!0,requestAnimationFrame(()=>{M.current=!1}))};let ue;e[5]===Symbol.for("react.memo_cache_sentinel")?(ue=()=>{I(null)},e[5]=ue):ue=e[5];const ee=ue,te=C?A.find(le=>le.id===C):null,fe=te!=null?y[te.index]:void 0,he=te!=null&&fe!==void 0?F(fe,te.index):null,ye=te!=null&&fe!==void 0?G9(Dn(fe),_):void 0;if(T!==null&&T<y.length){const le=Dn(y[T]),Le=NL(le,_,d,f,x),Ce=()=>{const _e=F(le,T),Re=Nr(v,a,_e),Je=fa(Re,_e);return Je>=0?Re.slice(0,Je+1):Re};return n.jsx("div",{className:"min-w-0",children:Le?.type==="object"&&Le.properties?n.jsx(ai,{schema:Le,value:le,onChange:_e=>K(T,_e),basePath:`${o}.${T}`,breadcrumbPath:N?.innerPath??[],onBreadcrumbChange:_e=>{c?.([...Ce(),..._e])},meta:d,decofile:h,onSaveReferencedBlock:u,previewBaseUrl:m,onAddSectionItem:p,onRequestAddSection:g,sandbox:L}):Le?Fc({schema:Le,value:le,onChange:_e=>K(T,_e),path:`${o}.${T}`,label:Le.title&&!Le.title.includes("{{")?Le.title:F(le,T),breadcrumbPath:N?.innerPath??[],onBreadcrumbChange:_e=>{c?.([...Ce(),..._e])},meta:d,decofile:h,onSaveReferencedBlock:u,previewBaseUrl:m,onAddSectionItem:p,onRequestAddSection:g,sandbox:L}):null})}const ve="space-y-2";let be;e[6]!==a?(be=n.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:a}),e[6]=a,e[7]=be):be=e[7];const Ne=y.length>0&&n.jsx("span",{className:"rounded-md bg-muted px-1.5 py-0.5 text-xs font-medium text-muted-foreground",children:y.length});let Oe;e[8]!==be||e[9]!==Ne?(Oe=n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[be,Ne]}),e[8]=be,e[9]=Ne,e[10]=Oe):Oe=e[10];let Fe;e[11]!==s.description?(Fe=s.description&&n.jsx("p",{className:"break-words text-xs leading-normal text-muted-foreground",children:s.description}),e[11]=s.description,e[12]=Fe):Fe=e[12];let Me;e[13]!==Oe||e[14]!==Fe?(Me=n.jsxs("div",{className:"min-w-0 space-y-0.5",children:[Oe,Fe]}),e[13]=Oe,e[14]=Fe,e[15]=Me):Me=e[15];const qe=y.length>0&&n.jsx("div",{className:ce(C&&"cursor-grabbing"),children:n.jsxs(Yd,{sensors:W,collisionDetection:Jd,onDragStart:ie,onDragEnd:oe,onDragCancel:ee,children:[n.jsx(Xd,{items:Y,strategy:Zd,children:n.jsx("div",{className:"min-w-0 overflow-hidden rounded-xl border border-border/50 p-1.5",children:A.map(le=>{const Le=y[le.index];if(Le===void 0)return null;const Ce=F(Le,le.index),_e=G9(Dn(Le),_);return n.jsx(PL,{sortableId:le.id,labelText:Ce,imageSrc:_e,hidden:Hn(Le),onToggleHidden:S?()=>q(le.index):void 0,onOpen:()=>$(le.index),onDuplicate:()=>G(le.index),onRemove:()=>H(le.index)},le.id)})})}),n.jsx(Qd,{dropAnimation:null,children:he?n.jsx("div",{className:"flex min-w-0 items-center gap-2.5 rounded-lg border border-border/60 bg-background px-2 py-2.5 shadow-lg ring-1 ring-border/60",children:n.jsx(AL,{labelText:he,imageSrc:ye})}):null})]})});let Ie;e[16]===Symbol.for("react.memo_cache_sentinel")?(Ie=n.jsx(It,{size:14}),e[16]=Ie):Ie=e[16];const pe=b?"Add section":"Add item";let je;e[17]!==Z||e[18]!==pe?(je=n.jsxs("button",{type:"button",onClick:Z,className:"flex w-full items-center justify-center gap-1.5 rounded-xl border border-dashed border-border/60 py-2.5 text-sm text-muted-foreground transition-colors hover:border-border hover:bg-muted/30",children:[Ie,pe]}),e[17]=Z,e[18]=pe,e[19]=je):je=e[19];let Be;return e[20]!==Me||e[21]!==qe||e[22]!==je?(Be=n.jsxs("div",{className:ve,children:[Me,qe,je]}),e[20]=Me,e[21]=qe,e[22]=je,e[23]=Be):Be=e[23],Be}function ML(t){return t.id}function BL(t){const e=U.c(44),{schema:s,value:i,onChange:r,path:o,label:a,breadcrumbPath:l,onBreadcrumbChange:c,meta:d,decofile:h,onSaveReferencedBlock:u,previewBaseUrl:f,onAddSectionItem:m,onRequestAddSection:p,sandbox:g}=t;let L;e[0]!==l?(L=l===void 0?[]:l,e[0]=l,e[1]=L):L=e[1];const v=L,[y,_]=R.useState(!1);let x;e[2]!==i?(x=i!=null&&typeof i=="object"&&!Array.isArray(i)?i:{},e[2]=i,e[3]=x):x=e[3];const b=x;if(!s.properties)return null;let S;e[4]!==o?(S=o.split(".").pop()??o,e[4]=o,e[5]=S):S=e[5];const w=S;let j;e[6]!==v||e[7]!==w||e[8]!==a||e[9]!==b||e[10]!==s?(j=wL(w,a,s,b,v),e[6]=v,e[7]=w,e[8]=a,e[9]=b,e[10]=s,e[11]=j):j=e[11];const T=y||j,A=`${o}-fields`;let k;e[12]===Symbol.for("react.memo_cache_sentinel")?(k=()=>_($L),e[12]=k):k=e[12];let C;e[13]!==T?(C=n.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors group-hover:text-accent-foreground",children:T?n.jsx(ls,{size:16}):n.jsx(Ms,{size:16})}),e[13]=T,e[14]=C):C=e[14];let I;e[15]!==a?(I=n.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:a}),e[15]=a,e[16]=I):I=e[16];let E;e[17]!==A||e[18]!==T||e[19]!==C||e[20]!==I?(E=n.jsxs("button",{type:"button","aria-expanded":T,"aria-controls":A,onClick:k,className:"group flex w-full min-w-0 items-center gap-2 rounded-md py-1.5 pr-2 text-left transition-colors hover:bg-accent hover:text-accent-foreground",children:[C,I]}),e[17]=A,e[18]=T,e[19]=C,e[20]=I,e[21]=E):E=e[21];let O;e[22]!==s.description?(O=s.description&&n.jsx("p",{className:"break-words pl-9 text-xs leading-normal text-muted-foreground",children:s.description}),e[22]=s.description,e[23]=O):O=e[23];let P;e[24]!==v||e[25]!==A||e[26]!==h||e[27]!==T||e[28]!==d||e[29]!==b||e[30]!==m||e[31]!==c||e[32]!==r||e[33]!==p||e[34]!==u||e[35]!==o||e[36]!==f||e[37]!==g||e[38]!==s?(P=T&&n.jsx("div",{id:A,className:"ml-3 min-w-0 max-w-full overflow-hidden border-l border-border/80 pl-5",children:n.jsx(ai,{schema:s,value:b,onChange:r,basePath:o,breadcrumbPath:v,onBreadcrumbChange:c,meta:d,decofile:h,onSaveReferencedBlock:u,previewBaseUrl:f,onAddSectionItem:m,onRequestAddSection:p,sandbox:g})}),e[24]=v,e[25]=A,e[26]=h,e[27]=T,e[28]=d,e[29]=b,e[30]=m,e[31]=c,e[32]=r,e[33]=p,e[34]=u,e[35]=o,e[36]=f,e[37]=g,e[38]=s,e[39]=P):P=e[39];let D;return e[40]!==O||e[41]!==P||e[42]!==E?(D=n.jsxs("div",{className:"min-w-0 space-y-2",children:[E,O,P]}),e[40]=O,e[41]=P,e[42]=E,e[43]=D):D=e[43],D}function $L(t){return!t}function a1(t){return t===fr||t===Oi}function Go(t,e){if(!Object.hasOwn(e,t))return null;const s=e[t]??{},i=s.__resolveType??t;return{data:{...s},resolveType:i}}function Lo(t,e){const s=t.__resolveType??"";if(!s)return null;if(At(s)){const i=t.section??{};return l1(i,e)}if(a1(s)){const i=t.variants?.[0]?.value;return i?Lo(i,e):null}return!ks(s)||!Object.hasOwn(e,s)?{data:{...t},resolveType:s}:Go(s,e)}function l1(t,e){const s=t.__resolveType??"";if(!s)return null;if(a1(s)){const i=t.variants?.[0]?.value;return i?Lo(i,e):null}return!ks(s)||!Object.hasOwn(e,s)?{data:{...t},resolveType:s}:Go(s,e)}function zL(t,e){if(!t||typeof t!="object"||Array.isArray(t))return null;const i=t.__resolveType;if(typeof i!="string"||!ks(i)||!Object.hasOwn(e,i))return null;const r=Go(i,e);return r?{blockKey:i,...r}:null}function FL(t,e,s){if(e.isMultivariate)return null;if(e.isSavedBlock){const i=e.isLazy?t.section?.__resolveType??t.__resolveType:t.__resolveType;return Go(i,s)}if(e.isHidden){const o=(At(t.__resolveType)?t.section:t)?.variants?.[0]?.value??t;return Lo(o,s)}if(e.isLazy||At(t.__resolveType)){const i=t.section??{};return l1(i,s)}return Lo(t,s)}function HL(t){if(!t?.properties)return{};const e={};for(const[s,i]of Object.entries(t.properties))s.startsWith("__")||s==="@type"||(i.default!==void 0?e[s]=i.default:i.type==="boolean"?e[s]=!1:i.type==="string"?e[s]="":i.type==="number"||i.type==="integer"?e[s]=0:i.type==="object"&&(e[s]={}));return e}function UL(t){const e=U.c(3),{blockKey:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Ee,{asChild:!0,children:n.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded bg-global-section/14 px-1.5 py-0.5 text-[11px] font-medium text-global-section-fg dark:text-global-section-fg-dark",children:[n.jsx(Pi,{size:11}),"Global"]})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsxs(Pe,{children:[i,n.jsxs(Ae,{side:"top",className:"max-w-[260px]",children:["Edits the saved block “",s,"”. Changes apply everywhere this loader is referenced on your site."]})]}),e[1]=s,e[2]=r):r=e[2],r}function KL(t){const e=U.c(28),{path:s,open:i,onOpenChange:r,title:o,nested:a,nestedBlockRef:l,globalBlockKey:c}=t,d=`${s}-loader-config`,h=l&&"ml-1";let u;e[0]!==h?(u=ce("rounded-lg border border-border/80 bg-muted/30",h),e[0]=h,e[1]=u):u=e[1];let f;e[2]!==r||e[3]!==i?(f=()=>r(!i),e[2]=r,e[3]=i,e[4]=f):f=e[4];let m;e[5]!==i?(m=n.jsx("span",{className:"flex size-6 shrink-0 items-center justify-center text-muted-foreground transition-colors group-hover:text-foreground",children:i?n.jsx(ls,{size:16}):n.jsx(Ms,{size:16})}),e[5]=i,e[6]=m):m=e[6];let p;e[7]!==o?(p=n.jsx("span",{className:"truncate text-xs font-medium tracking-wide text-muted-foreground uppercase",children:o}),e[7]=o,e[8]=p):p=e[8];let g;e[9]!==c?(g=c&&n.jsx(UL,{blockKey:c}),e[9]=c,e[10]=g):g=e[10];let L;e[11]!==p||e[12]!==g?(L=n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[p,g]}),e[11]=p,e[12]=g,e[13]=L):L=e[13];let v;e[14]!==d||e[15]!==i||e[16]!==f||e[17]!==m||e[18]!==L?(v=n.jsxs("button",{type:"button","aria-expanded":i,"aria-controls":d,onClick:f,className:"group flex w-full min-w-0 items-center gap-2 rounded-lg px-3 py-2.5 text-left transition-colors hover:bg-accent/50",children:[m,L]}),e[14]=d,e[15]=i,e[16]=f,e[17]=m,e[18]=L,e[19]=v):v=e[19];let y;e[20]!==d||e[21]!==a||e[22]!==i?(y=i&&n.jsx("div",{id:d,className:"border-t border-border/60 px-4 pb-4 pt-3",children:n.jsx("div",{className:"border-l border-border/80 pl-4",children:a})}),e[20]=d,e[21]=a,e[22]=i,e[23]=y):y=e[23];let _;return e[24]!==u||e[25]!==v||e[26]!==y?(_=n.jsxs("div",{className:u,children:[v,y]}),e[24]=u,e[25]=v,e[26]=y,e[27]=_):_=e[27],_}function Z9(t){const e=U.c(35),{schema:s,value:i,onChange:r,path:o,label:a,breadcrumbPath:l,onBreadcrumbChange:c,meta:d,decofile:h,onSaveReferencedBlock:u,sandbox:f}=t,m=(s.anyOfRefs??[]).filter(GL),p=h&&i?zL(i,h):null,g=p?.data??i,L=p?null:t1(g),v=L??g,y=dL(m,{savedBlockKey:p?.blockKey,editorValue:g}),_=y.length>0?hL(g,y,p?.blockKey):y[0]?.resolveType??"",b=s.type==="block-ref"&&y.some(VL);let S;e[0]!==a||e[1]!==o?(S=a??(o.includes(".")?o.split(".")[0]:o),e[0]=a,e[1]=o,e[2]=S):S=e[2];const w=S;let j;e[3]!==l?(j=l??[],e[3]=l,e[4]=j):j=e[4];const N=j,T=b&&N[0]===w,A=T?N.slice(1):N,k=T?G=>{c?.([w,...G])}:c,[C,I]=R.useState(_),[E,O]=R.useState(_);E!==_&&(O(_),I(_));const[P,D]=R.useState(()=>fL(g,p?.blockKey));if(y.length>0){const G=C||_;let q;e[5]!==G?(q=he=>he.resolveType===G,e[5]=G,e[6]=q):q=e[6];const H=y.find(q),K=V9(g,d,H?.schema),B=uL(K??H?.schema??null,s.discriminatorKey),X=s.discriminatorKey,W=he=>{I(he);const ye=y.find(Me=>Me.resolveType===he),ve=V9(g,d,ye?.schema),be=new Set(Object.keys((ve??ye?.schema)?.properties??{})),Ne=i!==null&&typeof i=="object"&&!Array.isArray(i)?i:{},Oe=Object.fromEntries(Object.entries(Ne).filter(Me=>{const[qe]=Me;return be.has(qe)})),Fe={...HL(ye?.schema),...Oe};if(X){const Me=ye?.discriminatorValue??he;r({...Fe,[X]:Me});return}if(uo(he)){r(Fe);return}r({...Fe,__resolveType:he})};let Y;e[7]!==G||e[8]!==X||e[9]!==r?(Y=he=>{if(X||!uo(G)||he===null||typeof he!="object"||Array.isArray(he)){r(he);return}const{__resolveType:ye,...ve}=he;r(ve)},e[7]=G,e[8]=X,e[9]=r,e[10]=Y):Y=e[10];const Q=Y,ie=B?.properties?n.jsx(ai,{schema:B,value:v,onChange:he=>{if(p&&u){u(p.blockKey,he);return}if(L){r({...g,section:he});return}Q(he)},basePath:o,breadcrumbPath:A,onBreadcrumbChange:k,meta:d,decofile:h,onSaveReferencedBlock:u,sandbox:f}):null;let oe;e[11]!==o?(oe=o.includes("."),e[11]=o,e[12]=oe):oe=e[12];const ue=oe;let ee;e[13]!==a||e[14]!==o?(ee=n.jsx(Ve,{htmlFor:o,children:a}),e[13]=a,e[14]=o,e[15]=ee):ee=e[15];let te;e[16]===Symbol.for("react.memo_cache_sentinel")?(te=n.jsx(kt,{children:n.jsx(Rt,{placeholder:"Select..."})}),e[16]=te):te=e[16];let fe;return e[17]!==s.description?(fe=s.description&&n.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[17]=s.description,e[18]=fe):fe=e[18],n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"space-y-1.5",children:[ee,n.jsxs(Tt,{value:G||void 0,onValueChange:W,children:[te,n.jsx(Nt,{children:y.map(WL)})]}),fe]}),ie&&(b?n.jsx(KL,{path:o,open:P,onOpenChange:D,title:ue?"Configuration":"Loader configuration",nested:ie,nestedBlockRef:ue,globalBlockKey:p?.blockKey}):ie)]})}if(s.anyOfRefs&&s.anyOfRefs.length>0)return null;let M;e[19]!==a||e[20]!==o?(M=n.jsx(Ve,{htmlFor:o,children:a}),e[19]=a,e[20]=o,e[21]=M):M=e[21];const z=i!=null?String(i):"";let F;e[22]!==r?(F=G=>r(G.target.value),e[22]=r,e[23]=F):F=e[23];const $=s.description??"";let V;e[24]!==o||e[25]!==z||e[26]!==F||e[27]!==$?(V=n.jsx("input",{id:o,type:"text",value:z,onChange:F,className:"w-full rounded-md border bg-background px-3 py-1.5 text-sm",placeholder:$}),e[24]=o,e[25]=z,e[26]=F,e[27]=$,e[28]=V):V=e[28];let J;e[29]!==s.description?(J=s.description&&n.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[29]=s.description,e[30]=J):J=e[30];let Z;return e[31]!==M||e[32]!==V||e[33]!==J?(Z=n.jsxs("div",{className:"space-y-1.5",children:[M,V,J]}),e[31]=M,e[32]=V,e[33]=J,e[34]=Z):Z=e[34],Z}function WL(t){const e=t.title&&!t.title.includes("/")?t.title:Wa(t.resolveType)??ut(t.resolveType);return n.jsx(ot,{value:t.resolveType,children:e},t.resolveType)}function VL(t){return t.resolveType.includes("/")&&!uo(t.resolveType)}function GL(t){return t.resolveType!==""}function qL(t){if(!Array.isArray(t))return[];const e=[];for(const s of t)if(typeof s=="string")e.push({value:s,label:s});else if(s&&typeof s=="object"&&"value"in s){const i=s;e.push({value:String(i.value),label:typeof i.label=="string"?i.label:String(i.value),image:typeof i.image=="string"?i.image:void 0})}return e}async function YL(t,e,s){const i={};s&&(i.term=s);const o=`${t.replace(/\/+$/,"")}/deco/invoke/${e}`,a=await fetch(o,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i)});if(!a.ok)throw new Error(`Failed to fetch dynamic options: ${a.status}`);const l=await a.json();return qL(l)}function Q9(t){const e=U.c(8),{path:s,label:i,description:r}=t;let o;e[0]!==i||e[1]!==s?(o=n.jsx(Ve,{htmlFor:s,children:i}),e[0]=i,e[1]=s,e[2]=o):o=e[2];let a;e[3]!==r?(a=r&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:r}),e[3]=r,e[4]=a):a=e[4];let l;return e[5]!==o||e[6]!==a?(l=n.jsxs("div",{className:"space-y-0.5",children:[o,a]}),e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function JL(t){const e=U.c(71),{schema:s,value:i,onChange:r,path:o,label:a,sandbox:l}=t,c=s.options,d=l?.previewUrl,[h,u]=R.useState(!1),[f,m]=R.useState(""),[p,g]=R.useState(""),L=R.useRef(null);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=H=>{m(H),L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{g(H)},300)},e[0]=v):v=e[0];const y=v,_=l?`${l.orgSlug}/${l.virtualMcpId}/${l.branch}`:"";let x;e[1]!==p||e[2]!==c||e[3]!==_?(x=Et.sandboxInvoke(_,`dynamic-options:${c??""}:${p}`),e[1]=p,e[2]=c,e[3]=_,e[4]=x):x=e[4];let b;e[5]!==p||e[6]!==c||e[7]!==d?(b=()=>YL(d,c,p||void 0),e[5]=p,e[6]=c,e[7]=d,e[8]=b):b=e[8];const S=!!d&&!!c&&h;let w;e[9]!==x||e[10]!==b||e[11]!==S?(w={queryKey:x,queryFn:b,enabled:S,staleTime:6e4,retry:1},e[9]=x,e[10]=b,e[11]=S,e[12]=w):w=e[12];const j=si(w);let N;e[13]!==j.data?(N=j.data??[],e[13]=j.data,e[14]=N):N=e[14];const T=N,A=typeof i=="string"?i:"";let k;if(e[15]!==A||e[16]!==T){let H;e[18]!==A?(H=K=>K.value===A,e[18]=A,e[19]=H):H=e[19],k=T.find(H),e[15]=A,e[16]=T,e[17]=k}else k=e[17];const C=k;if(!d||!c){let H;e[20]!==a||e[21]!==o||e[22]!==s.description?(H=n.jsx(Q9,{path:o,label:a,description:s.description}),e[20]=a,e[21]=o,e[22]=s.description,e[23]=H):H=e[23];let K;e[24]!==r?(K=W=>r(W.target.value),e[24]=r,e[25]=K):K=e[25];let B;e[26]!==A||e[27]!==o||e[28]!==K?(B=n.jsx(Ke,{id:o,type:"text",value:A,onChange:K}),e[26]=A,e[27]=o,e[28]=K,e[29]=B):B=e[29];let X;return e[30]!==B||e[31]!==H?(X=n.jsxs("div",{className:"space-y-2",children:[H,B]}),e[30]=B,e[31]=H,e[32]=X):X=e[32],X}let I;e[33]!==a||e[34]!==o||e[35]!==s.description?(I=n.jsx(Q9,{path:o,label:a,description:s.description}),e[33]=a,e[34]=o,e[35]=s.description,e[36]=I):I=e[36];let E;e[37]!==A||e[38]!==C?(E=C?n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[C.image&&n.jsx("img",{src:C.image,alt:"",referrerPolicy:"no-referrer",className:"h-6 w-6 shrink-0 rounded object-cover"}),n.jsx("span",{className:"truncate",children:C.label??C.value})]}):A?n.jsx("span",{className:"truncate",children:A}):n.jsx("span",{className:"text-muted-foreground",children:"Select..."}),e[37]=A,e[38]=C,e[39]=E):E=e[39];let O;e[40]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(ic,{className:"size-4 shrink-0 opacity-50"}),e[40]=O):O=e[40];let P;e[41]!==h||e[42]!==E?(P=n.jsx(ps,{asChild:!0,children:n.jsxs(re,{variant:"outline",role:"combobox","aria-expanded":h,className:"h-10 w-full justify-between font-normal",children:[E,O]})}),e[41]=h,e[42]=E,e[43]=P):P=e[43];let D;e[44]===Symbol.for("react.memo_cache_sentinel")?(D={width:"var(--radix-popover-trigger-width)"},e[44]=D):D=e[44];let M;e[45]!==f?(M=n.jsx(lr,{placeholder:"Search...",className:"h-9",value:f,onValueChange:y}),e[45]=f,e[46]=M):M=e[46];const z=j.isLoading?"Loading...":"No results found.";let F;e[47]!==z?(F=n.jsx(cr,{children:z}),e[47]=z,e[48]=F):F=e[48];let $;if(e[49]!==A||e[50]!==r||e[51]!==T){let H;e[53]!==A||e[54]!==r?(H=K=>n.jsxs(Xs,{value:K.value,onSelect:()=>{r(K.value===A?"":K.value),u(!1)},children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[K.image&&n.jsx("img",{src:K.image,alt:"",referrerPolicy:"no-referrer",className:"h-9 w-9 shrink-0 rounded object-cover"}),n.jsx("span",{className:"truncate",children:K.label??K.value})]}),n.jsx(Wt,{className:ce("ml-auto size-4 shrink-0",A===K.value?"opacity-100":"opacity-0")})]},K.value),e[53]=A,e[54]=r,e[55]=H):H=e[55],$=T.map(H),e[49]=A,e[50]=r,e[51]=T,e[52]=$}else $=e[52];let V;e[56]!==$?(V=n.jsx(Si,{children:$}),e[56]=$,e[57]=V):V=e[57];let J;e[58]!==F||e[59]!==V?(J=n.jsxs(dr,{children:[F,V]}),e[58]=F,e[59]=V,e[60]=J):J=e[60];let Z;e[61]!==M||e[62]!==J?(Z=n.jsx(gs,{className:"p-0",style:D,children:n.jsxs(Oo,{shouldFilter:!1,children:[M,J]})}),e[61]=M,e[62]=J,e[63]=Z):Z=e[63];let G;e[64]!==h||e[65]!==P||e[66]!==Z?(G=n.jsxs(ms,{open:h,onOpenChange:u,children:[P,Z]}),e[64]=h,e[65]=P,e[66]=Z,e[67]=G):G=e[67];let q;return e[68]!==G||e[69]!==I?(q=n.jsxs("div",{className:"space-y-2",children:[I,G]}),e[68]=G,e[69]=I,e[70]=q):q=e[70],q}function XL(t){const e=U.c(17),{org:s}=Ge(),i=Ri();let r,o,a,l;e[0]!==s.id||e[1]!==t.configId||e[2]!==t.imageOnly||e[3]!==t.search?(o=t.search?.trim()||void 0,r=t.imageOnly??!1,l=B3,a=Et.filePickerObjects(s.id,t.configId,o,r),e[0]=s.id,e[1]=t.configId,e[2]=t.imageOnly,e[3]=t.search,e[4]=r,e[5]=o,e[6]=a,e[7]=l):(r=e[4],o=e[5],a=e[6],l=e[7]);const c=t.enabled!==!1&&!!t.configId;let d;e[8]!==r||e[9]!==t.configId||e[10]!==o||e[11]!==i?(d=async u=>{const{pageParam:f}=u;return await i.call("FILE_OBJECTS_LIST",{configId:t.configId,cursor:f??void 0,search:o,imageOnly:r||void 0})},e[8]=r,e[9]=t.configId,e[10]=o,e[11]=i,e[12]=d):d=e[12];let h;return e[13]!==a||e[14]!==c||e[15]!==d?(h={queryKey:a,enabled:c,staleTime:3e4,initialPageParam:null,queryFn:d,getNextPageParam:ZL},e[13]=a,e[14]=c,e[15]=d,e[16]=h):h=e[16],l(h)}function ZL(t){return t.nextCursor??void 0}function Bc(){const t=U.c(2),{org:e}=Ge();let s;return t[0]!==e?(s={mutationFn:async i=>{const r=i.file.type||"application/octet-stream",o=await fetch(`/api/${encodeURIComponent(e.slug)}/file-configs/${encodeURIComponent(i.configId)}/upload?filename=${encodeURIComponent(i.file.name)}`,{method:"POST",headers:{"Content-Type":r},body:i.file});if(!o.ok){const a=await o.text().catch(QL);let l=`${o.status} ${o.statusText}`;try{const c=JSON.parse(a);c.message&&(l=c.message)}catch{a&&(l=a.slice(0,200))}throw new Error(`Upload failed: ${l}`)}return await o.json()}},t[0]=e,t[1]=s):s=t[1],ii(s)}function QL(){return""}const qo="file-picker:last-config-id";function c1(t){const e=U.c(19),s=t.mode==="image"?"Pick an image":"Pick a file";let i;e[0]!==s?(i=n.jsx(Ls,{children:s}),e[0]=s,e[1]=i):i=e[1];let r;e[2]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(or,{children:"Upload a new file or pick one previously uploaded to a configured bucket."}),e[2]=r):r=e[2];let o;e[3]!==i?(o=n.jsxs(_s,{children:[i,r]}),e[3]=i,e[4]=o):o=e[4];let a;e[5]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(ec,{className:"h-64 w-full"}),e[5]=a):a=e[5];let l;e[6]!==t?(l=u=>{t.onSelect(u),t.onOpenChange(!1)},e[6]=t,e[7]=l):l=e[7];let c;e[8]!==t.lockedConfigId||e[9]!==t.mode||e[10]!==l?(c=n.jsx(es,{fallback:e8,children:n.jsx(R.Suspense,{fallback:a,children:n.jsx(s8,{mode:t.mode,lockedConfigId:t.lockedConfigId,onSelect:l})})}),e[8]=t.lockedConfigId,e[9]=t.mode,e[10]=l,e[11]=c):c=e[11];let d;e[12]!==o||e[13]!==c?(d=n.jsxs(qt,{className:"sm:max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[o,c]}),e[12]=o,e[13]=c,e[14]=d):d=e[14];let h;return e[15]!==t.onOpenChange||e[16]!==t.open||e[17]!==d?(h=n.jsx(Gt,{open:t.open,onOpenChange:t.onOpenChange,children:d}),e[15]=t.onOpenChange,e[16]=t.open,e[17]=d,e[18]=h):h=e[18],h}function e8(t){const{error:e}=t;return n.jsx(t8,{error:e??new Error("Failed to load buckets")})}function t8(t){const e=U.c(3),{error:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Ei,{size:16}),e[0]=i):i=e[0];let r;return e[1]!==s.message?(r=n.jsxs("div",{className:"p-4 rounded-md bg-destructive/10 text-destructive flex items-center gap-2",children:[i,n.jsx("span",{className:"text-sm font-medium",children:s.message})]}),e[1]=s.message,e[2]=r):r=e[2],r}function s8(t){const e=U.c(32),{mode:s,lockedConfigId:i,onSelect:r}=t,o=M3();if(o.length===0){let p;return e[0]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(r8,{}),e[0]=p):p=e[0],p}if(i){let p;if(e[1]!==o||e[2]!==i){let L;e[4]!==i?(L=v=>v.id===i,e[4]=i,e[5]=L):L=e[5],p=o.find(L),e[1]=o,e[2]=i,e[3]=p}else p=e[3];const g=p;if(g){let L;return e[6]!==g||e[7]!==s||e[8]!==r?(L=n.jsx(pa,{config:g,mode:s,onSelect:r}),e[6]=g,e[7]=s,e[8]=r,e[9]=L):L=e[9],L}}if(o.length===1){const p=o[0];let g;return e[10]!==p||e[11]!==s||e[12]!==r?(g=n.jsx(pa,{config:p,mode:s,onSelect:r}),e[10]=p,e[11]=s,e[12]=r,e[13]=g):g=e[13],g}let a;e[14]===Symbol.for("react.memo_cache_sentinel")?(a=typeof window<"u"?window.localStorage.getItem(qo):null,e[14]=a):a=e[14];const l=a;let c;e[15]!==o?(c=o.find(p=>p.id===l)?.id??o[0].id,e[15]=o,e[16]=c):c=e[16];const d=c;let h;e[17]!==o?(h=o.map(i8),e[17]=o,e[18]=h):h=e[18];let u;e[19]!==h?(u=n.jsx(Do,{className:"self-start",children:h}),e[19]=h,e[20]=u):u=e[20];let f;if(e[21]!==o||e[22]!==s||e[23]!==r){let p;e[25]!==s||e[26]!==r?(p=g=>n.jsx(Gi,{value:g.id,className:"min-h-0 flex-1 overflow-hidden",children:n.jsx(pa,{config:g,mode:s,onSelect:r})},g.id),e[25]=s,e[26]=r,e[27]=p):p=e[27],f=o.map(p),e[21]=o,e[22]=s,e[23]=r,e[24]=f}else f=e[24];let m;return e[28]!==d||e[29]!==u||e[30]!==f?(m=n.jsxs(Io,{defaultValue:d,onValueChange:n8,className:"min-h-0 flex-1 flex flex-col",children:[u,f]}),e[28]=d,e[29]=u,e[30]=f,e[31]=m):m=e[31],m}function i8(t){return n.jsx(Js,{value:t.id,children:t.name},t.id)}function n8(t){typeof window<"u"&&window.localStorage.setItem(qo,t)}function r8(){const t=U.c(4),{org:e}=Ge();let s,i;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:"size-12 rounded-full bg-muted flex items-center justify-center",children:n.jsx(ar,{size:20,className:"text-muted-foreground"})}),i=n.jsxs("div",{children:[n.jsx("p",{className:"font-medium text-sm",children:"No bucket configured"}),n.jsx("p",{className:"text-xs text-muted-foreground mt-1 max-w-sm",children:"Add an S3-compatible bucket in Settings before you can upload files."})]}),t[0]=s,t[1]=i):(s=t[0],i=t[1]);let r;return t[2]!==e.slug?(r=n.jsxs("div",{className:"rounded-xl border border-dashed border-border/60 p-10 flex flex-col items-center justify-center text-center gap-3",children:[s,i,n.jsx(re,{asChild:!0,size:"sm",className:"mt-2",children:n.jsx(jd,{to:"/$org/settings/files",params:{org:e.slug},children:"Configure a bucket"})})]}),t[2]=e.slug,t[3]=r):r=t[3],r}function pa({config:t,mode:e,onSelect:s}){const[i,r]=R.useState(""),o=O3(i,300),a=XL({configId:t.id,search:o,imageOnly:e==="image"}),l=Bc(),[c,d]=R.useState(!1),h=R.useRef(null),u=e==="image"?"image/*":void 0;async function f(S){if(!S)return;const w=Array.from(S);if(w.length===0)return;let j=null;const N=[];for(const T of w)try{const A=await l.mutateAsync({configId:t.id,file:T});j??=A.publicUrl}catch(A){N.push(`${T.name} (${A instanceof Error?A.message:"upload failed"})`)}await a.refetch(),N.length>0&&me.error(N.length===w.length?`Upload failed: ${N.join("; ")}`:`Some files failed: ${N.join("; ")}`),j&&s(j)}function m(S){S.preventDefault(),d(!0)}function p(){d(!1)}function g(S){S.preventDefault(),d(!1),f(S.dataTransfer.files)}const v=(a.data?.pages??[]).flatMap(S=>S.items),y=v.filter(S=>e==="image"?d1(S.key):!0),_=o.trim(),x=v.length>0||i.trim().length>0,b=i!==o||a.isFetching&&!a.isFetchingNextPage;return n.jsxs("div",{className:"flex flex-col gap-3 min-h-0 h-full",children:[n.jsxs("button",{type:"button",onClick:()=>h.current?.click(),onDragOver:m,onDragLeave:p,onDrop:g,className:ce("rounded-xl border border-dashed border-border/60 p-6 flex flex-col items-center justify-center gap-2 text-center transition-colors",c&&"border-primary bg-primary/5",l.isPending&&"opacity-60 pointer-events-none"),children:[n.jsx(ar,{size:18,className:"text-muted-foreground"}),n.jsx("p",{className:"text-sm font-medium",children:l.isPending?"Uploading…":"Drop files here or click to upload"}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Up to 100 MB."," ",e==="image"?"Images only (PNG, JPEG, WebP, GIF, SVG, AVIF).":"Common image, video, audio, and document types."]}),n.jsx("input",{ref:h,type:"file",accept:u,multiple:!0,className:"hidden",onChange:S=>{const w=Array.from(S.target.files??[]);S.target.value="",f(w)}})]}),x?n.jsx(Zl,{value:i,onChange:r,isSearching:b,placeholder:e==="image"?"Search images…":"Search files…",className:"shrink-0"}):null,n.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto pr-1",children:[y.length===0?_?n.jsx(l8,{query:_}):e==="image"&&v.length>0?n.jsx(a8,{}):n.jsx(o8,{}):e==="image"?n.jsx(d8,{items:y,onSelect:s}):n.jsx(h8,{items:y,onSelect:s}),a.hasNextPage&&n.jsx("div",{className:"flex justify-center py-4",children:n.jsx(re,{type:"button",variant:"outline",size:"sm",disabled:a.isFetchingNextPage,onClick:()=>a.fetchNextPage(),children:a.isFetchingNextPage?n.jsxs(n.Fragment,{children:[n.jsx(Ue,{size:14,className:"animate-spin"}),"Loading…"]}):"Load more"})})]})]})}function o8(){const t=U.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:"flex h-full min-h-40 flex-col items-center justify-center gap-2 py-8 text-center",children:[n.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted",children:n.jsx(bi,{size:18,className:"text-muted-foreground"})}),n.jsx("p",{className:"text-sm font-medium",children:"No files in this bucket yet"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Drop a file above to get started."})]}),t[0]=e):e=t[0],e}function a8(){const t=U.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:"flex h-full min-h-40 flex-col items-center justify-center gap-2 py-8 text-center",children:[n.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted",children:n.jsx(bi,{size:18,className:"text-muted-foreground"})}),n.jsx("p",{className:"text-sm font-medium",children:"No images in this bucket yet"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"The bucket has other files, but none match common image formats."})]}),t[0]=e):e=t[0],e}function l8(t){const e=U.c(6),{query:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted",children:n.jsx(bi,{size:18,className:"text-muted-foreground"})}),e[0]=i):i=e[0];let r;e[1]!==s?(r=n.jsxs("p",{className:"text-sm font-medium",children:['No matches for "',s,'"']}),e[1]=s,e[2]=r):r=e[2];let o;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("p",{className:"text-xs text-muted-foreground",children:"Try a different search, or load more files below."}),e[3]=o):o=e[3];let a;return e[4]!==r?(a=n.jsxs("div",{className:"flex h-full min-h-40 flex-col items-center justify-center gap-2 py-8 text-center",children:[i,r,o]}),e[4]=r,e[5]=a):a=e[5],a}function d1(t){return/\.(png|jpe?g|gif|webp|svg|avif|bmp)$/i.test(t)}function c8(t){const e=t.lastIndexOf(".");return e<0||e===t.length-1?"file":t.slice(e+1).toLowerCase()}function d8(t){const e=U.c(7),{items:s,onSelect:i}=t;let r;if(e[0]!==s||e[1]!==i){let a;e[3]!==i?(a=l=>n.jsx(h1,{item:l,variant:"image",onSelect:i},l.key),e[3]=i,e[4]=a):a=e[4],r=s.map(a),e[0]=s,e[1]=i,e[2]=r}else r=e[2];let o;return e[5]!==r?(o=n.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3",children:r}),e[5]=r,e[6]=o):o=e[6],o}function h8(t){const e=U.c(7),{items:s,onSelect:i}=t;let r;if(e[0]!==s||e[1]!==i){let a;e[3]!==i?(a=l=>n.jsx("li",{children:n.jsx(h1,{item:l,variant:"row",onSelect:i})},l.key),e[3]=i,e[4]=a):a=e[4],r=s.map(a),e[0]=s,e[1]=i,e[2]=r}else r=e[2];let o;return e[5]!==r?(o=n.jsx("ul",{className:"divide-y divide-border/60 rounded-lg border border-border/60",children:r}),e[5]=r,e[6]=o):o=e[6],o}function h1(t){const e=U.c(58),{item:s,variant:i,onSelect:r}=t;let o;e[0]!==s.key?(o=c8(s.key),e[0]=s.key,e[1]=o):o=e[1];const a=o;if(i==="image"){let _;e[2]!==s.publicUrl||e[3]!==r?(_=()=>r(s.publicUrl),e[2]=s.publicUrl,e[3]=r,e[4]=_):_=e[4];let x;e[5]!==s.key||e[6]!==s.publicUrl?(x=n.jsx("img",{src:s.publicUrl,alt:s.key,loading:"lazy",className:"h-full w-full object-cover",onError:u8}),e[5]=s.key,e[6]=s.publicUrl,e[7]=x):x=e[7];let b;e[8]!==s.key||e[9]!==_||e[10]!==x?(b=n.jsx("button",{type:"button",onClick:_,className:"block h-full w-full transition hover:ring-2 hover:ring-primary",title:s.key,children:x}),e[8]=s.key,e[9]=_,e[10]=x,e[11]=b):b=e[11];let S;e[12]!==a?(S=n.jsx("span",{className:"pointer-events-none absolute left-1.5 top-1.5 rounded bg-background/80 px-1.5 py-0.5 text-[10px] font-medium uppercase text-foreground opacity-0 backdrop-blur-sm transition-opacity group-hover:opacity-100",children:a}),e[12]=a,e[13]=S):S=e[13];let w;e[14]!==s||e[15]!==r?(w=n.jsx("div",{className:"absolute right-1.5 top-1.5 opacity-0 transition-opacity group-hover:opacity-100",children:n.jsx(e0,{item:s,onSelect:r})}),e[14]=s,e[15]=r,e[16]=w):w=e[16];let j;e[17]!==s.key?(j=t0(s.key),e[17]=s.key,e[18]=j):j=e[18];let N;e[19]!==j?(N=n.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/70 to-transparent p-2 opacity-0 transition-opacity group-hover:opacity-100",children:n.jsx("p",{className:"truncate text-xs text-white",children:j})}),e[19]=j,e[20]=N):N=e[20];let T;return e[21]!==b||e[22]!==S||e[23]!==w||e[24]!==N?(T=n.jsxs("div",{className:"group relative aspect-square overflow-hidden rounded-lg border border-border/60 bg-muted",children:[b,S,w,N]}),e[21]=b,e[22]=S,e[23]=w,e[24]=N,e[25]=T):T=e[25],T}let l;e[26]!==s.publicUrl||e[27]!==r?(l=()=>r(s.publicUrl),e[26]=s.publicUrl,e[27]=r,e[28]=l):l=e[28];let c;e[29]!==s.key?(c=n.jsx("div",{className:"flex size-9 shrink-0 items-center justify-center rounded-md bg-muted",children:d1(s.key)?n.jsx(bi,{size:16,className:"text-muted-foreground"}):n.jsx(Zi,{size:16,className:"text-muted-foreground"})}),e[29]=s.key,e[30]=c):c=e[30];let d;e[31]!==s.key?(d=t0(s.key),e[31]=s.key,e[32]=d):d=e[32];let h;e[33]!==d?(h=n.jsx("p",{className:"truncate text-sm font-medium",children:d}),e[33]=d,e[34]=h):h=e[34];let u;e[35]!==s.key?(u=n.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:s.key}),e[35]=s.key,e[36]=u):u=e[36];let f;e[37]!==h||e[38]!==u?(f=n.jsxs("div",{className:"min-w-0 flex-1",children:[h,u]}),e[37]=h,e[38]=u,e[39]=f):f=e[39];let m;e[40]!==a?(m=n.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:a}),e[40]=a,e[41]=m):m=e[41];let p;e[42]!==s.size?(p=g8(s.size),e[42]=s.size,e[43]=p):p=e[43];let g;e[44]!==p?(g=n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:p}),e[44]=p,e[45]=g):g=e[45];let L;e[46]!==g||e[47]!==l||e[48]!==c||e[49]!==f||e[50]!==m?(L=n.jsxs("button",{type:"button",onClick:l,className:"flex min-w-0 flex-1 items-center gap-3 text-left",children:[c,f,m,g]}),e[46]=g,e[47]=l,e[48]=c,e[49]=f,e[50]=m,e[51]=L):L=e[51];let v;e[52]!==s||e[53]!==r?(v=n.jsx(e0,{item:s,onSelect:r}),e[52]=s,e[53]=r,e[54]=v):v=e[54];let y;return e[55]!==L||e[56]!==v?(y=n.jsxs("div",{className:"group flex items-center gap-3 px-3 py-2 transition hover:bg-muted/50",children:[L,v]}),e[55]=L,e[56]=v,e[57]=y):y=e[57],y}function u8(t){t.target.style.display="none"}function e0(t){const e=U.c(22),{item:s,onSelect:i}=t,[r,o]=R.useState(!1);let a;e[0]!==s.publicUrl?(a=async function(_){_.preventDefault(),_.stopPropagation();try{await navigator.clipboard.writeText(s.publicUrl),o(!0),window.setTimeout(()=>o(!1),1500)}catch{me.error("Failed to copy URL")}},e[0]=s.publicUrl,e[1]=a):a=e[1];const l=a;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(ns,{asChild:!0,children:n.jsx(re,{type:"button",variant:"ghost",size:"icon",className:"size-7 rounded-md bg-background/80 backdrop-blur-sm",onClick:p8,"aria-label":"Asset actions",children:n.jsx(I3,{size:14})})}),e[2]=c):c=e[2];let d;e[3]!==s.publicUrl||e[4]!==i?(d=()=>i(s.publicUrl),e[3]=s.publicUrl,e[4]=i,e[5]=d):d=e[5];let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Wt,{size:14}),e[6]=h):h=e[6];let u;e[7]!==d?(u=n.jsxs(We,{onClick:d,children:[h,"Use this"]}),e[7]=d,e[8]=u):u=e[8];let f;e[9]!==r?(f=r?n.jsx(Wt,{size:14}):n.jsx(ts,{size:14}),e[9]=r,e[10]=f):f=e[10];const m=r?"Copied":"Copy URL";let p;e[11]!==l||e[12]!==f||e[13]!==m?(p=n.jsxs(We,{onClick:l,children:[f,m]}),e[11]=l,e[12]=f,e[13]=m,e[14]=p):p=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(ri,{size:14}),e[15]=g):g=e[15];let L;e[16]!==s.publicUrl?(L=n.jsx(We,{asChild:!0,children:n.jsxs("a",{href:s.publicUrl,target:"_blank",rel:"noreferrer",onClick:f8,children:[g,"Open in new tab"]})}),e[16]=s.publicUrl,e[17]=L):L=e[17];let v;return e[18]!==L||e[19]!==u||e[20]!==p?(v=n.jsxs(is,{children:[c,n.jsxs(rs,{align:"end",onClick:m8,children:[u,p,L]})]}),e[18]=L,e[19]=u,e[20]=p,e[21]=v):v=e[21],v}function f8(t){return t.stopPropagation()}function m8(t){return t.stopPropagation()}function p8(t){return t.stopPropagation()}function t0(t){const e=t.split("/");return e[e.length-1]??t}function g8(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function u1(t,e){if(!e)return null;const s=e.toLowerCase();return t.find(i=>{const r=i.bucket.toLowerCase();return i.siteSlug?.toLowerCase()===s||r===s||r===`deco-assets-${s}`})??null}function s0(t){const e=U.c(2),{ext:s}=t;if(!s)return null;let i;return e[0]!==s?(i=n.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:s}),e[0]=s,e[1]=i):i=e[1],i}function _8(t){try{const e=new URL(t).pathname;return decodeURIComponent(e.split("/").pop()??t)}catch{return t.split("/").pop()??t}}function L8(t){const e=t.lastIndexOf(".");return e<0||e===t.length-1?"":t.slice(e+1).toLowerCase()}function v8(t){const e=U.c(79),{schema:s,value:i,onChange:r,path:o,label:a,sandbox:l}=t,c=s.format==="video-uri",d=Oc(i),[h,u]=R.useState(!1),[f,m]=R.useState(!1),p=d?_8(d):"",g=p?L8(p):"",L=kh(),v=Bc();let y;e[0]!==L.data?.configs?(y=L.data?.configs??[],e[0]=L.data?.configs,e[1]=y):y=e[1];const _=l?.siteSlug;let x;e[2]!==y||e[3]!==_?(x=u1(y,_),e[2]=y,e[3]=_,e[4]=x):x=e[4];const b=x;let S;e[5]!==L.data?.configs||e[6]!==b?(S=function(){if(b)return b.id;const ee=L.data?.configs??[];if(ee.length===1)return ee[0].id;if(ee.length===0)return null;const te=typeof window<"u"?window.localStorage.getItem(qo):null;return ee.some(fe=>fe.id===te)?te:null},e[5]=L.data?.configs,e[6]=b,e[7]=S):S=e[7];const w=S;let j;e[8]!==c||e[9]!==r||e[10]!==w||e[11]!==u||e[12]!==v?(j=async function(ee){if(!ee)return;let te=Array.from(ee);if(te.length===0)return;if(c&&(te=te.filter(x8),te.length===0)){me.error("Please drop a video file (mp4, webm, …).");return}const fe=w();if(!fe){u(!0);return}try{const he=await v.mutateAsync({configId:fe,file:te[0]});r(he.publicUrl),te.length>1&&me.info(`Uploaded ${te[0].name}; extra files were ignored (single-select field).`)}catch(he){const ye=he;me.error(ye instanceof Error?ye.message:"Upload failed")}},e[8]=c,e[9]=r,e[10]=w,e[11]=u,e[12]=v,e[13]=j):j=e[13];const N=j;let T;e[14]!==m?(T=function(ee){ee.preventDefault(),ee.dataTransfer.types.includes("Files")&&m(!0)},e[14]=m,e[15]=T):T=e[15];const A=T;let k;e[16]!==m?(k=function(ee){ee.currentTarget===ee.target&&m(!1)},e[16]=m,e[17]=k):k=e[17];const C=k;let I;e[18]!==N||e[19]!==m?(I=function(ee){ee.preventDefault(),m(!1),N(ee.dataTransfer.files)},e[18]=N,e[19]=m,e[20]=I):I=e[20];const E=I;let O;e[21]!==a||e[22]!==o?(O=n.jsx(Ve,{htmlFor:o,className:"text-muted-foreground",children:a}),e[21]=a,e[22]=o,e[23]=O):O=e[23];let P;e[24]!==s.description?(P=s.description&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[24]=s.description,e[25]=P):P=e[25];let D;e[26]!==P||e[27]!==O?(D=n.jsxs("div",{className:"min-w-0 space-y-0.5",children:[O,P]}),e[26]=P,e[27]=O,e[28]=D):D=e[28];const M=f&&"border-primary ring-2 ring-primary/30",z=v.isPending&&"pointer-events-none opacity-60";let F;e[29]!==M||e[30]!==z?(F=ce("group relative w-full overflow-hidden rounded-xl border border-border/60 bg-muted/30 transition",M,z),e[29]=M,e[30]=z,e[31]=F):F=e[31];let $;e[32]!==g||e[33]!==p||e[34]!==c||e[35]!==u||e[36]!==d||e[37]!==v.isPending?($=d?c?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"relative h-40 w-full overflow-hidden bg-black",children:n.jsx("video",{src:d,preload:"metadata",className:"h-full w-full object-contain"},d)}),n.jsxs("div",{className:"flex items-center gap-2 border-t border-border/60 bg-background/50 px-3 py-2",children:[n.jsx(d9,{size:14,className:"shrink-0 text-muted-foreground"}),n.jsx("p",{className:"min-w-0 flex-1 truncate text-xs text-muted-foreground",children:p}),n.jsx(s0,{ext:g})]})]}):n.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5",children:[n.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-md bg-background",children:n.jsx(Zi,{size:18,className:"text-muted-foreground"})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"truncate text-sm font-medium",children:p}),n.jsx("p",{className:"truncate text-xs text-muted-foreground",children:d})]}),n.jsx(s0,{ext:g})]}):n.jsxs("button",{type:"button",onClick:()=>u(!0),className:"flex w-full flex-col items-center justify-center gap-2 py-8 text-sm text-muted-foreground hover:bg-muted/60 hover:text-foreground",children:[c?n.jsx(d9,{size:20}):n.jsx(Zi,{size:20}),n.jsx("span",{className:"text-sm font-medium",children:v.isPending?"Uploading…":c?"Drop a video here or click to browse":"Drop a file or click to browse"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"Up to 100 MB"})]}),e[32]=g,e[33]=p,e[34]=c,e[35]=u,e[36]=d,e[37]=v.isPending,e[38]=$):$=e[38];let V;e[39]!==f?(V=f&&n.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-primary/10 backdrop-blur-[1px]",children:n.jsx("span",{className:"rounded-md bg-background px-3 py-1.5 text-xs font-medium shadow",children:"Drop to upload"})}),e[39]=f,e[40]=V):V=e[40];let J;e[41]!==C||e[42]!==A||e[43]!==E||e[44]!==F||e[45]!==$||e[46]!==V?(J=n.jsxs("div",{onDragOver:A,onDragLeave:C,onDrop:E,className:F,children:[$,V]}),e[41]=C,e[42]=A,e[43]=E,e[44]=F,e[45]=$,e[46]=V,e[47]=J):J=e[47];let Z;e[48]!==r?(Z=ue=>r(ue.target.value),e[48]=r,e[49]=Z):Z=e[49];let G;e[50]!==o||e[51]!==d||e[52]!==Z?(G=n.jsx(Ke,{id:o,type:"url",value:d,onChange:Z,placeholder:"https://...",className:"h-9 min-w-0 flex-1"}),e[50]=o,e[51]=d,e[52]=Z,e[53]=G):G=e[53];let q;e[54]!==u?(q=()=>u(!0),e[54]=u,e[55]=q):q=e[55];let H;e[56]===Symbol.for("react.memo_cache_sentinel")?(H=n.jsx(ar,{size:14}),e[56]=H):H=e[56];const K=d?"Replace":"Browse";let B;e[57]!==q||e[58]!==K?(B=n.jsxs(re,{type:"button",variant:"outline",size:"sm",onClick:q,className:"h-9 shrink-0",children:[H,K]}),e[57]=q,e[58]=K,e[59]=B):B=e[59];let X;e[60]!==r||e[61]!==d?(X=d&&n.jsx(re,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(""),className:"h-9 shrink-0","aria-label":"Remove file",children:n.jsx(os,{size:14})}),e[60]=r,e[61]=d,e[62]=X):X=e[62];let W;e[63]!==G||e[64]!==B||e[65]!==X?(W=n.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[G,B,X]}),e[63]=G,e[64]=B,e[65]=X,e[66]=W):W=e[66];let Y;e[67]!==r?(Y=ue=>r(ue),e[67]=r,e[68]=Y):Y=e[68];const Q=b?.id??null;let ie;e[69]!==h||e[70]!==u||e[71]!==Y||e[72]!==Q?(ie=n.jsx(c1,{open:h,onOpenChange:u,mode:"any",onSelect:Y,lockedConfigId:Q}),e[69]=h,e[70]=u,e[71]=Y,e[72]=Q,e[73]=ie):ie=e[73];let oe;return e[74]!==D||e[75]!==J||e[76]!==W||e[77]!==ie?(oe=n.jsxs("div",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-2",children:[D,J,W,ie]}),e[74]=D,e[75]=J,e[76]=W,e[77]=ie,e[78]=oe):oe=e[78],oe}function x8(t){return t.type.startsWith("video/")}function y8(t){try{const e=new URL(t).pathname;return decodeURIComponent(e.split("/").pop()??t)}catch{return t.split("/").pop()??t}}function b8(t){const e=t.lastIndexOf(".");return e<0||e===t.length-1?"":t.slice(e+1).toLowerCase()}const S8=new Set(["image/png","image/jpeg","image/gif","image/webp","image/svg+xml","image/avif"]);function w8(t){const e=U.c(86),{schema:s,value:i,onChange:r,path:o,label:a,sandbox:l}=t,c=Oc(i),[d,h]=R.useState(!1),[u,f]=R.useState(!1),[m,p]=R.useState(!1),[g,L]=R.useState(!1),v=c?y8(c):"",y=v?b8(v):"",_=kh(),x=Bc();let b;e[0]!==_.data?.configs?(b=_.data?.configs??[],e[0]=_.data?.configs,e[1]=b):b=e[1];const S=l?.siteSlug;let w;e[2]!==b||e[3]!==S?(w=u1(b,S),e[2]=b,e[3]=S,e[4]=w):w=e[4];const j=w;let N;e[5]!==r||e[6]!==L||e[7]!==p?(N=function(ve){p(!1),L(!1),r(ve)},e[5]=r,e[6]=L,e[7]=p,e[8]=N):N=e[8];const T=N;let A;e[9]!==_.data?.configs||e[10]!==j?(A=function(){if(j)return j.id;const ve=_.data?.configs??[];if(ve.length===1)return ve[0].id;if(ve.length===0)return null;const be=typeof window<"u"?window.localStorage.getItem(qo):null;return ve.some(Ne=>Ne.id===be)?be:null},e[9]=_.data?.configs,e[10]=j,e[11]=A):A=e[11];const k=A;let C;e[12]!==k||e[13]!==h||e[14]!==T||e[15]!==x?(C=async function(ve){if(!ve)return;const be=Array.from(ve).filter(C8);if(be.length===0){me.error("Only image files are accepted here.");return}const Ne=k();if(!Ne){h(!0);return}try{const Oe=await x.mutateAsync({configId:Ne,file:be[0]});T(Oe.publicUrl),be.length>1&&me.info(`Uploaded ${be[0].name}; extra files were ignored (single-select field).`)}catch(Oe){const Fe=Oe;me.error(Fe instanceof Error?Fe.message:"Upload failed")}},e[12]=k,e[13]=h,e[14]=T,e[15]=x,e[16]=C):C=e[16];const I=C;let E;e[17]!==f?(E=function(ve){ve.preventDefault(),ve.dataTransfer.types.includes("Files")&&f(!0)},e[17]=f,e[18]=E):E=e[18];const O=E;let P;e[19]!==f?(P=function(ve){ve.currentTarget===ve.target&&f(!1)},e[19]=f,e[20]=P):P=e[20];const D=P;let M;e[21]!==I||e[22]!==f?(M=function(ve){ve.preventDefault(),f(!1),I(ve.dataTransfer.files)},e[21]=I,e[22]=f,e[23]=M):M=e[23];const z=M;let F;e[24]!==a||e[25]!==o?(F=n.jsx(Ve,{htmlFor:o,className:"text-muted-foreground",children:a}),e[24]=a,e[25]=o,e[26]=F):F=e[26];let $;e[27]!==s.description?($=s.description&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[27]=s.description,e[28]=$):$=e[28];let V;e[29]!==F||e[30]!==$?(V=n.jsxs("div",{className:"min-w-0 space-y-0.5",children:[F,$]}),e[29]=F,e[30]=$,e[31]=V):V=e[31];const J=u&&"border-primary ring-2 ring-primary/30",Z=x.isPending&&"pointer-events-none opacity-60";let G;e[32]!==J||e[33]!==Z?(G=ce("group relative w-full overflow-hidden rounded-xl border border-border/60 bg-muted/30 transition",J,Z),e[32]=J,e[33]=Z,e[34]=G):G=e[34];let q;e[35]!==y||e[36]!==v||e[37]!==g||e[38]!==m||e[39]!==a||e[40]!==L||e[41]!==p||e[42]!==h||e[43]!==c||e[44]!==x.isPending?(q=c?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"relative h-40 w-full bg-[image:linear-gradient(45deg,rgba(0,0,0,0.04)_25%,transparent_25%,transparent_75%,rgba(0,0,0,0.04)_75%),linear-gradient(45deg,rgba(0,0,0,0.04)_25%,transparent_25%,transparent_75%,rgba(0,0,0,0.04)_75%)] bg-[position:0_0,8px_8px] [background-size:16px_16px]",children:[!g&&n.jsx("img",{src:c,alt:a,className:ce("h-full w-full object-contain transition-opacity",!m&&"opacity-0"),onLoad:()=>p(!0),onError:()=>L(!0)},c),g&&n.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-1 text-muted-foreground",children:[n.jsx(bi,{size:20}),n.jsx("p",{className:"text-xs",children:"Preview unavailable"})]}),!m&&!g&&n.jsx("div",{className:"absolute inset-0 animate-pulse bg-muted/60"})]}),n.jsxs("div",{className:"flex items-center gap-2 border-t border-border/60 bg-background/50 px-3 py-2",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",children:v}),y&&n.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:y})]})]}):n.jsxs("button",{type:"button",onClick:()=>h(!0),className:"flex h-40 w-full flex-col items-center justify-center gap-2 text-sm text-muted-foreground hover:bg-muted/60 hover:text-foreground",children:[n.jsx(bi,{size:20}),n.jsx("span",{className:"text-sm font-medium",children:x.isPending?"Uploading…":"Drop an image or click to browse"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"PNG, JPEG, WebP, GIF, SVG, AVIF — up to 100 MB"})]}),e[35]=y,e[36]=v,e[37]=g,e[38]=m,e[39]=a,e[40]=L,e[41]=p,e[42]=h,e[43]=c,e[44]=x.isPending,e[45]=q):q=e[45];let H;e[46]!==u?(H=u&&n.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-primary/10 backdrop-blur-[1px]",children:n.jsx("span",{className:"rounded-md bg-background px-3 py-1.5 text-xs font-medium shadow",children:"Drop to upload"})}),e[46]=u,e[47]=H):H=e[47];let K;e[48]!==D||e[49]!==O||e[50]!==z||e[51]!==G||e[52]!==q||e[53]!==H?(K=n.jsxs("div",{onDragOver:O,onDragLeave:D,onDrop:z,className:G,children:[q,H]}),e[48]=D,e[49]=O,e[50]=z,e[51]=G,e[52]=q,e[53]=H,e[54]=K):K=e[54];let B;e[55]!==T?(B=ye=>T(ye.target.value),e[55]=T,e[56]=B):B=e[56];let X;e[57]!==o||e[58]!==c||e[59]!==B?(X=n.jsx(Ke,{id:o,type:"url",value:c,onChange:B,placeholder:"https://...",className:"h-9 min-w-0 flex-1"}),e[57]=o,e[58]=c,e[59]=B,e[60]=X):X=e[60];let W;e[61]!==h?(W=()=>h(!0),e[61]=h,e[62]=W):W=e[62];let Y;e[63]===Symbol.for("react.memo_cache_sentinel")?(Y=n.jsx(ar,{size:14}),e[63]=Y):Y=e[63];const Q=c?"Replace":"Browse";let ie;e[64]!==W||e[65]!==Q?(ie=n.jsxs(re,{type:"button",variant:"outline",size:"sm",onClick:W,className:"h-9 shrink-0",children:[Y,Q]}),e[64]=W,e[65]=Q,e[66]=ie):ie=e[66];let oe;e[67]!==T||e[68]!==c?(oe=c&&n.jsx(re,{type:"button",variant:"ghost",size:"sm",onClick:()=>T(""),className:"h-9 shrink-0","aria-label":"Remove image",children:n.jsx(os,{size:14})}),e[67]=T,e[68]=c,e[69]=oe):oe=e[69];let ue;e[70]!==X||e[71]!==ie||e[72]!==oe?(ue=n.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[X,ie,oe]}),e[70]=X,e[71]=ie,e[72]=oe,e[73]=ue):ue=e[73];let ee;e[74]!==T?(ee=ye=>T(ye),e[74]=T,e[75]=ee):ee=e[75];const te=j?.id??null;let fe;e[76]!==d||e[77]!==h||e[78]!==ee||e[79]!==te?(fe=n.jsx(c1,{open:d,onOpenChange:h,mode:"image",onSelect:ee,lockedConfigId:te}),e[76]=d,e[77]=h,e[78]=ee,e[79]=te,e[80]=fe):fe=e[80];let he;return e[81]!==V||e[82]!==K||e[83]!==ue||e[84]!==fe?(he=n.jsxs("div",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-2",children:[V,K,ue,fe]}),e[81]=V,e[82]=K,e[83]=ue,e[84]=fe,e[85]=he):he=e[85],he}function C8(t){return S8.has(t.type||"")}function f1(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function j8(t,e){if(e.length===0)return 0;const s=f1(t);for(let o=0;o<e.length;o++){const a=e[o].discriminators;if(a&&Object.keys(a).length>0&&Object.entries(a).every(([c,d])=>s[c]===d))return o}let i=0,r=-1;for(let o=0;o<e.length;o++){const a=e[o],l=new Set(Object.keys(a.discriminators??{})),d=a.propertyKeys.filter(h=>!l.has(h)).filter(h=>s[h]!==void 0&&s[h]!==null&&s[h]!=="").length;d>r&&(r=d,i=o)}return i}function k8(t,e){const s=f1(t),i=new Set(e);return Object.fromEntries(Object.entries(s).filter(([r])=>!i.has(r)))}const N8="0 0 1080 1080",T8="matrix(1 0 0 1 540 540)",$c=[{code:"AC",name:"Acre",gTransform:"matrix(1 0 0 1 -248.53 -95.16)",pathTransform:"translate(-57.47, -224.1)",d:"M 30.47 237.77 L 28.39 237.73 L 28.93 235.92 L 28.72 235.09 L 28.47 234.6 L 27.22 233.9 L 27.08 233.45 L 27.35 232.3 L 26.58 230.35 L 25.49 229.71 L 19.89 228.46 L 12.55 228.27 L 12.82 227.71 L 15.31 225.45 L 16.2 224.22 L 16.49 223.02 L 16.27 221.79 L 15.59 220.88 L 14.76 220.44 L 13.08 217.49 L 12.31 217.05 L 11.41 216.86 L 10.28 215.73 L 9.36 213.35 L 7.36 211.82 L 6.38 208.2 L 5.51 206.56 L 3.63 205.48 L 3.55 204.31 L 4.36 204.41 L 4.78 203.89 L 4.85 203.22 L 4.65 202.8 L 2.53 201.87 L 2.17 201.21 L 0 199.32 L 0.04 198.95 L 0.66 198.9 L 1.16 197.58 L 1.15 196.27 L 4.16 195.88 L 4.66 195.49 L 4.44 194.14 L 3.27 192.57 L 3.27 192.57 L 21.22 200.05 L 44.88 205.71 L 57.02 208.85 L 83.46 223.02 L 111.97 235.15 L 111.97 235.15 L 114.94 236.41 L 114.94 236.41 L 114.64 236.89 L 113.07 237.55 L 110.98 239.14 L 108.12 241.93 L 106.47 242.79 L 105.81 242.61 L 104.28 242.79 L 104.23 243.35 L 102.31 244.65 L 100.23 245.64 L 98.79 247.47 L 98.35 248.65 L 97.74 248.93 L 96.57 248.18 L 95.81 248.05 L 93.44 248.1 L 92.76 248.36 L 92.13 248.81 L 91.77 249.67 L 89.33 253.15 L 85.56 254.4 L 84.72 255.09 L 82.78 255.6 L 81.75 255.63 L 81.83 253.52 L 80.47 253.72 L 76.92 252.95 L 71.68 252.48 L 66.59 252.86 L 65.93 252.28 L 63.66 252.11 L 60.1 253.94 L 57.37 254.56 L 55.69 253.89 L 54.29 252.45 L 52.65 253.61 L 52.69 236.06 L 52.74 234.96 L 53.21 234.25 L 53.28 231.9 L 53.02 231.02 L 53.99 229.84 L 54.47 228.7 L 53.31 228.9 L 50.34 231.49 L 48.74 232.5 L 46.68 234.88 L 44.73 235.55 L 44.08 236.63 L 42.27 237.62 z"},{code:"AL",name:"Alagoas",gTransform:"matrix(1 0 0 1 276.36 -86.82)",pathTransform:"translate(-582.36, -232.44)",d:"M 561.91 230.3 L 561.71 229.57 L 560.29 228.79 L 559.84 228.88 L 558.82 228.59 L 558.28 227.19 L 558.28 227.19 L 559.6 226.12 L 560.24 225.03 L 562.41 224.27 L 564.79 220.98 L 564.88 220.29 L 565.7 219.69 L 566.7 220.91 L 568.37 221.21 L 569.45 221.09 L 572 223.11 L 573.9 225.23 L 575.68 226.28 L 577.59 226.76 L 580.09 226.11 L 583.23 226.4 L 584.4 226.29 L 586.26 225.23 L 587.42 225.28 L 589.23 224.17 L 591.41 221.88 L 591.53 221.43 L 593.08 220.19 L 595.08 219.95 L 597.32 220.8 L 599.88 219.51 L 601.35 219.32 L 603.27 220.13 L 606.17 220.4 L 606.44 220.61 L 606.44 220.61 L 603.66 225.57 L 599.11 230.7 L 595.53 234.28 L 592.49 238.86 L 589.16 241.74 L 588.16 243.77 L 586.84 245.56 L 586.84 245.56 L 586.24 244.25 L 582.65 242.02 L 582.19 241.99 L 580.53 241.2 L 578.77 239.75 L 577.47 237.3 L 572.05 234.23 L 568.37 233.28 z"},{code:"AM",name:"Amazonas",gTransform:"matrix(1 0 0 1 -166.8 -178.05)",pathTransform:"translate(-139.2, -141.22)",d:"M 165.82 47.29 L 166.54 48.07 L 167.29 48.41 L 167.9 48.42 L 169.03 48 L 169.66 48.11 L 169.72 49.07 L 170.93 50.24 L 171.9 50.61 L 172.78 50.4 L 174.14 50.51 L 176.09 51.46 L 176.58 52.12 L 175.67 55.44 L 174.96 56.94 L 177.69 60.68 L 179.35 65.44 L 179.54 67.7 L 180.41 68.82 L 180.46 69.27 L 178.84 70.73 L 179.2 72.32 L 179.86 73.9 L 179.09 76.94 L 178.52 77.9 L 178.81 82.88 L 179.69 85.05 L 180.91 85.89 L 181.49 86.79 L 182.62 91.12 L 182.56 91.7 L 181.42 93.02 L 179.58 92.69 L 179.44 93.83 L 184.45 98.25 L 184.97 98.29 L 186.93 99.6 L 188.41 101.25 L 189.45 103.29 L 189.98 103.36 L 191.32 102.94 L 193.68 103.98 L 193.24 101.87 L 193.99 99.58 L 194.24 97.85 L 193.87 96.05 L 194.69 93.08 L 195.71 91.82 L 196.99 91.13 L 199.08 90.42 L 199.63 89.53 L 201.23 89.47 L 204.06 90.4 L 205.93 92.44 L 206.85 94.95 L 208.67 95.18 L 209.92 94.72 L 211.33 93.31 L 213.36 92.76 L 213.78 92.37 L 213.8 91.84 L 212.66 90.43 L 212.43 89.7 L 212.54 89.04 L 213.69 86.4 L 213.76 85.27 L 215.42 82.24 L 217.75 78.98 L 217.72 78.3 L 236.21 78.37 L 236.21 78.37 L 236.61 83.23 L 236.18 84.68 L 236.36 86.95 L 236.6 87.63 L 238.3 88.48 L 238.48 88.89 L 238.13 89.58 L 238.08 91.69 L 239.91 93.68 L 240.27 93.87 L 240.97 93.69 L 242.81 94.92 L 243.36 96.75 L 243.4 97.68 L 243.7 98.13 L 248.34 101.9 L 252.92 104.44 L 253.55 105.34 L 254.9 106.43 L 256.78 107.1 L 259.15 108.41 L 261.41 109.06 L 262.77 109.21 L 264.09 110.03 L 264.17 110.64 L 265.44 111.98 L 268.14 113.42 L 269.24 115.59 L 271.11 116.38 L 271.96 115.77 L 273.34 115.42 L 273.53 115.9 L 273.4 116.68 L 275.21 118.35 L 245.31 182.59 L 244.53 183.9 L 243.08 185.03 L 242.5 186 L 242.47 187.13 L 243.29 189.46 L 243.67 190.03 L 244.74 190.61 L 246.32 192.17 L 246.96 193.43 L 247.11 195.39 L 247.68 195.96 L 247.68 195.96 L 246.5 197.16 L 246.3 197.77 L 246.24 198.53 L 246.58 199.37 L 246.31 200.38 L 245.11 202.2 L 244.25 202.84 L 243.83 203.69 L 243.93 204.54 L 244.59 205.91 L 245.05 207.85 L 243.67 212.07 L 242.49 217.29 L 241.28 218.02 L 193.43 218.34 L 193.43 218.34 L 193.47 217.64 L 193.11 217.26 L 191.72 216.98 L 189.8 218.06 L 189.26 219.8 L 188.58 219.99 L 185.34 218.51 L 184.66 215.63 L 184.04 215.43 L 183.06 215.56 L 182.6 215.35 L 181.35 212.08 L 178.81 211.1 L 177.48 209.83 L 176.68 207.92 L 176.23 207.43 L 174.08 206.3 L 163.29 206.36 L 161.91 208.92 L 160.19 209.42 L 160.28 210.59 L 160.02 210.81 L 157.54 211.34 L 156.35 212.93 L 156.3 213.6 L 157.2 214.3 L 157.37 214.75 L 157.01 215.77 L 156.2 216.92 L 154.14 218.13 L 154.03 219.94 L 154.27 221.4 L 150.4 220.94 L 148.27 221.32 L 147.07 222.39 L 145.28 222.29 L 144.44 221.74 L 143.98 221.72 L 142.23 222.98 L 141.7 223.82 L 141.96 225.57 L 139.42 228.73 L 138.74 228.81 L 138.06 228.28 L 137.42 226.02 L 137.04 225.93 L 135.2 226.95 L 133.9 228.16 L 132.53 228.55 L 131.76 228.42 L 130.68 228.92 L 130.27 229.45 L 130.14 230.17 L 128.92 230.96 L 128.55 230.98 L 126.24 228.65 L 125.52 228.28 L 122.65 228.61 L 118.69 228.35 L 118.85 229.64 L 118.7 230.2 L 117.15 232.01 L 115.23 232.59 L 111.97 235.15 L 111.97 235.15 L 83.46 223.02 L 57.02 208.85 L 44.88 205.71 L 21.22 200.05 L 3.27 192.57 L 3.27 192.57 L 3.2 191.92 L 3.9 189 L 5.12 187.6 L 10.04 184.13 L 12.3 183.89 L 12.77 183.59 L 13.75 182.03 L 13.83 181 L 12.09 176.51 L 12.47 175.32 L 13.65 173.13 L 14.93 171.81 L 15.85 170.56 L 16.27 169.58 L 16.57 167.84 L 16.28 166.52 L 16.95 164.48 L 17.26 162.17 L 17.99 161.42 L 21.65 159.79 L 23.84 158.56 L 24.99 157.52 L 25.43 156.12 L 26.21 155.75 L 27.62 155.64 L 29.27 154.71 L 32.81 151.98 L 35.23 151.55 L 36.74 151.84 L 40.93 150.62 L 42.43 149.85 L 44.25 149.49 L 47.58 149.87 L 48.88 148.28 L 49.51 146.83 L 50.6 146.22 L 52.74 146.42 L 53.38 146.96 L 54.7 146.72 L 55.8 145.98 L 57.51 146.1 L 57.82 146.63 L 57.8 147.81 L 59.41 149.1 L 62.24 149.18 L 62.82 148.78 L 63.28 148 L 63.17 147.61 L 64.34 142.69 L 71.04 105.52 L 72.2 102.6 L 71.21 97.64 L 71.33 97.38 L 70.03 96.33 L 68.55 93.58 L 68.51 93.09 L 69.16 91.7 L 68.64 89.92 L 68.27 89.52 L 66.57 88.93 L 63.54 86.58 L 61.6 84.3 L 61.8 72.79 L 65.69 72.53 L 67.44 71.36 L 70.94 70.44 L 73.62 72.2 L 74.84 72.31 L 76.11 71.88 L 75.62 70.19 L 75.92 68.47 L 74.55 66.37 L 73.98 65.83 L 72.83 65.23 L 71.32 65.76 L 68.53 65.15 L 64.96 65.24 L 64.9 55.34 L 65.86 55.38 L 67.18 54.8 L 69.46 54.2 L 72.3 55.07 L 91.33 55.13 L 90.87 54.47 L 90.08 54.33 L 89.7 53.13 L 90.65 51.2 L 92.08 51.6 L 92.69 53.12 L 93.56 54.44 L 94.22 54.79 L 95.05 54.8 L 96.66 54.19 L 98.6 52.1 L 98.92 51.26 L 100.18 50.02 L 102.73 48.63 L 104.02 49.09 L 105.19 51.67 L 106.81 53.66 L 107.55 54.96 L 108.21 56.74 L 108.44 58.29 L 107.95 61.92 L 108.15 63.68 L 111.35 62.93 L 119.66 69.99 L 120.45 70.27 L 122.95 70.48 L 125.25 69.48 L 126.95 67.78 L 129.06 66.62 L 131.25 66.51 L 131.81 66.8 L 132.58 67.88 L 132.56 68.85 L 131.45 70.55 L 131.82 71.53 L 132.4 71.8 L 133.73 71.08 L 134.29 70.17 L 134.52 68.88 L 135.52 67.72 L 135.99 67.49 L 136.99 67.67 L 137.54 67.49 L 137.95 66.83 L 138.41 64.52 L 138.92 64.15 L 140.43 63.79 L 143.36 62.02 L 144.33 62.57 L 145.26 62.28 L 146.86 61.24 L 147.88 59.63 L 149.99 58.42 L 152.02 58.97 L 154.38 57.32 L 154.93 56.5 L 155.37 53.84 L 155.34 52.55 L 156.11 51.63 L 157.14 51.21 L 158.88 51.19 L 160.22 50.8 L 162.28 49.2 L 163.24 48.83 L 165.52 48.53 z"},{code:"AP",name:"Amapá",gTransform:"matrix(1 0 0 1 32.29 -262.31)",pathTransform:"translate(-338.29, -56.97)",d:"M 344.98 99.7 L 344.04 99.64 L 343.27000000000004 99.98 L 341.97 100.10000000000001 L 339.18 99.42 L 337.73 98.39 L 337.3 96.89 L 335.43 95.5 L 335.32 94.2 L 335.53 93.51 L 335.21999999999997 91.93 L 334.89 91.46000000000001 L 333.94 91.27000000000001 L 333.53 90.33000000000001 L 333.60999999999996 87.9 L 330.67999999999995 84.62 L 329.9 84.98 L 329.08 84.79 L 327.58 81.31 L 327.71 79.73 L 327.12 77.92 L 326.5 77.36 L 325.83 75.85 L 325.64 73.74 L 326.07 70.6 L 325.9 70.27 L 323.33 69.53999999999999 L 321.31 67.27999999999999 L 320.55 64.44999999999999 L 320.74 63.72999999999999 L 321.42 63.49999999999999 L 320.93 62.31999999999999 L 320.25 62.349999999999994 L 317.41 59.69 L 316.47 59.83 L 316.09000000000003 60.25 L 314.76000000000005 60.39 L 313.9200000000001 60.12 L 313.12000000000006 59.14 L 311.9800000000001 58.3 L 310.7900000000001 58.18 L 310.30000000000007 56.9 L 309.63000000000005 56.1 L 307.70000000000005 55.050000000000004 L 306.41 54.56 L 303.02000000000004 54.190000000000005 L 301.94000000000005 54.480000000000004 L 300.77000000000004 54.46 L 300.46000000000004 53.92 L 300.22 52.480000000000004 L 300.47 47.940000000000005 L 301.09000000000003 46.64000000000001 L 300.72 44.34000000000001 L 300.1 43.77000000000001 L 300.1 43.77000000000001 L 300.45000000000005 43.56000000000001 L 301.44000000000005 43.86000000000001 L 301.43000000000006 44.67000000000001 L 301.14000000000004 44.85000000000001 L 301.48 45.82000000000001 L 302.95000000000005 45.760000000000005 L 303.77000000000004 45.99 L 304.12000000000006 46.89 L 304.96000000000004 47.6 L 307.21000000000004 48.38 L 310.50000000000006 49.13 L 313.26000000000005 47.35 L 313.61000000000007 46.59 L 315.3400000000001 45.42 L 316.1700000000001 45.13 L 316.86000000000007 46.07 L 319.57000000000005 47.01 L 320.65000000000003 46.89 L 322.37000000000006 45.88 L 322.49000000000007 45.46 L 322.81000000000006 45.49 L 324.27000000000004 46.79 L 324.07000000000005 47.66 L 326.44000000000005 47.489999999999995 L 326.95000000000005 47.989999999999995 L 327.90000000000003 48.16 L 328.52000000000004 48.15 L 329.43000000000006 47.67 L 331.1000000000001 46.17 L 332.88000000000005 45.07 L 334.63000000000005 42.77 L 335.00000000000006 41.77 L 334.80000000000007 41.230000000000004 L 337.93000000000006 34.730000000000004 L 338.0400000000001 32.910000000000004 L 339.1500000000001 31.610000000000003 L 339.8800000000001 31.42 L 343.48000000000013 25.630000000000003 L 343.71000000000015 24.480000000000004 L 344.5500000000001 23.280000000000005 L 346.34000000000015 21.730000000000004 L 346.97000000000014 20.070000000000004 L 349.08000000000015 18.930000000000003 L 349.5500000000002 18.01 L 350.5900000000002 17.430000000000003 L 351.1500000000002 18.890000000000004 L 352.0300000000002 20.250000000000004 L 350.3600000000002 15.450000000000003 L 350.2900000000002 14.160000000000004 L 350.4700000000002 13.830000000000004 L 353.8400000000002 16.250000000000004 L 354.9800000000002 17.460000000000004 L 355.8900000000002 18.680000000000003 L 356.4100000000002 19.870000000000005 L 356.44000000000017 21.450000000000003 L 356.88000000000017 21.76 L 357.20000000000016 21.28 L 357.58000000000015 21.18 L 357.79000000000013 21.58 L 358.0000000000001 29.47 L 358.66000000000014 33.339999999999996 L 361.3700000000001 39.38999999999999 L 364.03000000000014 48.32999999999999 L 367.35000000000014 53.32999999999999 L 368.3600000000001 53.67999999999999 L 371.6300000000001 53.599999999999994 L 374.4100000000001 54.53999999999999 L 375.7000000000001 55.38999999999999 L 376.4700000000001 58.03999999999999 L 376.31000000000006 61.36999999999999 L 375.02000000000004 62.32999999999999 L 373.29 62.75999999999999 L 372.91 63.08999999999999 L 374.70000000000005 62.93999999999999 L 375.74000000000007 62.51999999999999 L 376.02000000000004 62.749999999999986 L 376.14000000000004 63.33999999999999 L 375.97 64.07 L 370.94000000000005 68.13 L 369.77000000000004 70.22999999999999 L 367.62000000000006 71.63999999999999 L 365.68000000000006 75.35999999999999 L 362.77000000000004 78.85999999999999 L 362.07000000000005 79.31999999999998 L 361.13000000000005 79.22999999999998 L 359.68000000000006 79.74999999999997 L 357.6000000000001 82.72999999999998 L 357.6000000000001 82.72999999999998 L 356.2600000000001 82.79999999999997 L 355.5100000000001 83.69999999999997 L 355.5100000000001 83.69999999999997 L 354.0400000000001 85.37999999999998 L 353.07000000000005 87.59999999999998 L 351.95000000000005 89.46999999999998 L 351.11000000000007 90.11999999999999 L 348.1000000000001 93.57 L 347.74000000000007 95.97 L 347.9100000000001 97.77 L 345.9600000000001 99.58 L 344.98 99.7 z M 368.34 52.71 L 367.89 52.38 L 366.78999999999996 50.52 L 366.85999999999996 49.64 L 367.09 49.230000000000004 L 368.75 48.78 L 369.18 49.17 L 370.01 51.440000000000005 L 369.02 52.540000000000006 L 368.34 52.71 z M 370.83 70.32 L 370.43 70.07 L 370.35 69.36 L 371.46000000000004 68.26 L 372.34000000000003 68.11 L 373.59000000000003 68.35 L 374.05 68.24 L 374.49 67.6 L 374.54 68.19 L 373.57 69.63 L 372.58 70.13 L 370.83 70.32 z M 374.27 67.45 L 373.49 67.22 L 373.49 66.66 L 374.21000000000004 65.61999999999999 L 375.46000000000004 65.52 L 375.64000000000004 65.86999999999999 L 375.54 66.38 L 374.27 67.45 z M 367.08 49.03 L 366.32 48.53 L 366.58 47.7 L 367.46 47.53 L 368.32 47.85 L 368.33 48.58 L 367.08 49.03 z"},{code:"BA",name:"Bahia",gTransform:"matrix(1 0 0 1 193.52 -26.39)",pathTransform:"translate(-499.52, -292.87)",d:"M 527.5 365.33 L 527.14 364.5 L 527.8199999999999 363.15 L 527.81 362.62 L 527.28 361.58 L 523.15 358.53 L 523 358.02 L 523.22 356.51 L 522.65 355.28 L 522 355.52 L 521.8 355.96999999999997 L 521.4599999999999 356.15 L 521.2399999999999 355.9 L 521.7699999999999 351.5 L 522.5899999999999 348.2 L 523.41 347.32 L 525.88 347.56 L 526.9 346.85 L 526.9 346.43 L 526.34 345.41 L 526.5 342.76000000000005 L 531.46 338.54 L 532.9300000000001 335.46000000000004 L 532.5100000000001 334.29 L 531.7300000000001 333.27000000000004 L 530.8400000000001 333.21000000000004 L 530.1100000000001 332.83000000000004 L 527.2800000000001 330.36 L 525.1600000000001 330.38 L 522.97 329.78 L 520.7 328.7 L 517.97 328.14 L 515.99 328 L 514.67 328.99 L 513.1999999999999 329.49 L 510.5899999999999 329.04 L 510.0199999999999 329.25 L 509.5799999999999 325.29 L 503.05999999999995 319.09000000000003 L 502.67999999999995 318.91 L 498.28999999999996 320.14000000000004 L 496.76 318.90000000000003 L 496.25 319.11 L 495.32 318.89 L 492.78 317.66999999999996 L 490.60999999999996 316.04999999999995 L 489.62999999999994 316.22999999999996 L 485.2799999999999 312.59999999999997 L 484.1799999999999 312.05999999999995 L 481.4499999999999 311.30999999999995 L 479.6799999999999 311.55999999999995 L 477.7999999999999 312.4599999999999 L 476.9899999999999 313.5799999999999 L 476.3499999999999 313.75999999999993 L 471.0199999999999 312.2899999999999 L 470.4099999999999 311.7999999999999 L 470.1499999999999 310.2999999999999 L 470.2899999999999 309.4099999999999 L 471.5799999999999 306.6699999999999 L 470.7199999999999 306.2099999999999 L 468.43999999999994 305.68999999999994 L 466.25999999999993 305.6499999999999 L 465.05999999999995 305.1499999999999 L 463.2699999999999 305.06999999999994 L 459.43999999999994 306.6499999999999 L 455.17999999999995 309.6799999999999 L 454.53999999999996 310.7899999999999 L 451.16999999999996 312.6599999999999 L 449.15 313.0599999999999 L 448.2 314.2399999999999 L 446.39 315.7899999999999 L 444.96 316.3099999999999 L 443.96 316.1599999999999 L 442.10999999999996 318.7399999999999 L 441.06999999999994 319.5099999999999 L 438.93999999999994 319.1299999999999 L 438.2199999999999 319.2599999999999 L 437.5299999999999 320.2599999999999 L 436.18999999999994 321.1799999999999 L 435.78999999999996 320.9399999999999 L 437.21999999999997 317.5099999999999 L 436.71 315.09999999999985 L 436.71 315.09999999999985 L 438.19 313.1299999999998 L 438.44 312.35999999999984 L 438.21 311.08999999999986 L 437.53999999999996 309.36999999999983 L 437.64 308.6999999999998 L 438.34999999999997 307.2799999999998 L 438.29999999999995 306.8199999999998 L 435.09 304.1999999999998 L 433.4 300.73999999999984 L 432.78 297.21999999999986 L 432.83 295.66999999999985 L 434.03 291.83999999999986 L 435.61999999999995 290.8099999999999 L 435.84999999999997 290.4299999999999 L 435.90999999999997 289.4899999999999 L 434.28 288.6499999999999 L 434.16999999999996 288.31999999999994 L 434.65 285.79999999999995 L 436.08 284.73999999999995 L 436.06 284.36999999999995 L 433.34 281.90999999999997 L 433.34 281.90999999999997 L 433.29999999999995 280.97999999999996 L 434.65999999999997 278.59999999999997 L 434.61999999999995 277.53 L 434.44999999999993 277.10999999999996 L 432.98999999999995 276.61999999999995 L 432.04999999999995 275.96999999999997 L 431.69999999999993 274.71 L 431.75999999999993 271.78999999999996 L 431.94999999999993 270.93999999999994 L 433.8999999999999 269.2699999999999 L 435.0399999999999 268.8499999999999 L 435.9999999999999 268.1299999999999 L 435.70999999999987 267.4999999999999 L 435.1299999999999 266.9799999999999 L 434.20999999999987 266.6899999999999 L 433.1799999999999 266.8699999999999 L 432.82999999999987 266.5399999999999 L 432.7399999999999 266.0399999999999 L 433.1599999999999 265.0799999999999 L 435.19999999999993 264.25999999999993 L 435.75999999999993 263.80999999999995 L 435.7199999999999 263.04999999999995 L 433.8399999999999 262.06999999999994 L 430.25999999999993 261.3999999999999 L 428.3999999999999 259.43999999999994 L 428.1699999999999 258.5199999999999 L 428.6699999999999 257.3599999999999 L 429.6799999999999 256.6299999999999 L 431.1999999999999 253.1499999999999 L 432.09999999999985 252.53999999999988 L 433.10999999999984 252.26999999999987 L 433.45999999999987 251.88999999999987 L 432.16999999999985 250.08999999999986 L 432.35999999999984 249.71999999999986 L 435.5699999999998 247.09999999999985 L 439.3899999999998 245.07999999999984 L 439.9499999999998 244.60999999999984 L 440.16999999999985 243.62999999999985 L 440.85999999999984 242.97999999999985 L 440.85999999999984 242.97999999999985 L 443.1899999999998 242.95999999999984 L 444.6299999999998 244.29999999999984 L 445.28999999999985 245.33999999999983 L 445.8199999999998 247.54999999999984 L 447.5799999999998 250.03999999999985 L 451.7599999999998 251.89999999999986 L 453.55999999999983 251.37999999999985 L 455.66999999999985 251.55999999999986 L 455.99999999999983 251.34999999999985 L 456.74999999999983 249.89999999999986 L 457.8899999999998 249.52999999999986 L 458.55999999999983 248.65999999999985 L 459.72999999999985 247.76999999999987 L 461.9399999999998 247.01999999999987 L 463.2699999999998 247.18999999999986 L 464.74999999999983 247.71999999999986 L 466.09999999999985 247.29999999999987 L 469.0699999999999 244.87999999999988 L 472.01999999999987 239.82999999999987 L 472.7399999999999 238.96999999999986 L 472.9799999999999 238.04999999999987 L 473.2799999999999 235.48999999999987 L 473.1599999999999 234.32999999999987 L 470.9199999999999 229.89999999999986 L 470.9699999999999 228.96999999999986 L 474.2099999999999 227.31999999999985 L 476.1599999999999 227.29999999999984 L 477.6599999999999 227.75999999999985 L 478.06999999999994 228.68999999999986 L 478.38999999999993 228.86999999999986 L 480.50999999999993 228.43999999999986 L 481.8999999999999 227.89999999999986 L 483.2299999999999 228.27999999999986 L 484.9399999999999 229.26999999999987 L 484.8099999999999 229.91999999999987 L 484.9999999999999 230.20999999999987 L 485.8199999999999 230.48999999999987 L 488.8199999999999 230.37999999999985 L 490.2899999999999 229.73999999999987 L 491.9899999999999 229.63999999999987 L 492.8099999999999 228.41999999999987 L 494.3199999999999 227.07999999999987 L 497.0499999999999 226.73999999999987 L 497.8199999999999 226.37999999999985 L 498.6299999999999 225.39999999999986 L 500.7999999999999 225.40999999999985 L 501.4199999999999 226.03999999999985 L 501.7299999999999 226.08999999999986 L 503.5899999999999 224.27999999999986 L 503.4899999999999 221.87999999999985 L 505.4799999999999 221.49999999999986 L 506.2699999999999 221.67999999999986 L 507.31999999999994 221.01999999999987 L 508.81999999999994 218.70999999999987 L 509.2799999999999 217.55999999999986 L 509.2799999999999 217.55999999999986 L 510.1699999999999 217.95999999999987 L 511.3299999999999 217.68999999999986 L 513.53 217.97999999999985 L 516.35 219.36999999999983 L 516.7900000000001 219.87999999999982 L 516.7300000000001 222.60999999999981 L 517.4500000000002 224.5499999999998 L 519.6600000000002 225.4599999999998 L 519.9300000000002 227.4599999999998 L 519.0100000000002 229.13999999999982 L 520.8400000000003 229.75999999999982 L 521.8000000000003 229.53999999999982 L 522.6200000000003 228.61999999999983 L 525.4900000000004 227.73999999999984 L 526.2600000000003 224.15999999999983 L 526.7600000000003 223.28999999999982 L 527.5100000000003 223.12999999999982 L 528.2900000000003 223.65999999999983 L 528.9200000000003 223.70999999999984 L 531.3100000000003 222.68999999999983 L 532.4100000000003 221.44999999999982 L 532.5800000000003 220.85999999999981 L 532.3300000000003 219.4999999999998 L 532.6200000000002 219.2499999999998 L 534.8600000000002 218.7999999999998 L 535.6300000000002 216.7499999999998 L 537.2800000000002 216.3099999999998 L 539.8100000000002 214.8499999999998 L 540.4000000000002 214.7499999999998 L 541.8900000000002 215.3099999999998 L 542.7200000000003 216.7499999999998 L 544.0800000000003 217.5599999999998 L 546.4400000000003 218.3399999999998 L 549.4300000000003 218.7399999999998 L 551.0100000000003 219.88999999999982 L 551.5500000000003 221.53999999999982 L 551.9400000000003 221.80999999999983 L 552.3700000000002 221.65999999999983 L 552.6600000000002 219.90999999999983 L 553.0900000000001 219.46999999999983 L 554.0900000000001 219.45999999999984 L 554.5400000000002 219.77999999999983 L 554.5600000000002 220.40999999999983 L 553.9400000000002 221.28999999999982 L 554.3900000000002 222.11999999999983 L 554.8900000000002 222.48999999999984 L 556.9900000000002 223.34999999999985 L 557.0100000000002 224.28999999999985 L 558.2300000000002 227.33999999999986 L 558.2300000000002 227.33999999999986 L 558.7700000000002 228.73999999999987 L 559.7900000000002 229.02999999999986 L 560.2400000000002 228.93999999999986 L 561.6700000000002 229.72999999999985 L 561.8700000000002 230.44999999999985 L 561.8700000000002 230.44999999999985 L 561.2000000000003 231.60999999999984 L 561.4100000000003 233.74999999999983 L 562.6900000000003 236.24999999999983 L 564.6800000000003 238.19999999999982 L 565.4300000000003 239.34999999999982 L 565.3500000000003 242.46999999999983 L 564.6900000000003 244.08999999999983 L 564.6000000000003 244.96999999999983 L 565.3600000000002 247.71999999999983 L 565.0600000000003 248.29999999999984 L 564.3700000000002 248.84999999999985 L 561.8200000000003 249.84999999999985 L 560.6900000000003 249.09999999999985 L 558.9800000000002 249.08999999999986 L 558.6600000000002 249.38999999999987 L 558.0700000000002 250.96999999999989 L 558.0900000000001 251.7399999999999 L 559.0400000000002 253.3399999999999 L 560.1400000000002 253.9999999999999 L 560.6600000000002 255.4899999999999 L 562.0900000000001 256.9999999999999 L 562.2400000000001 257.3899999999999 L 562.1100000000001 258.8099999999999 L 561.7700000000001 259.1999999999999 L 561.8900000000001 259.6199999999999 L 562.4800000000001 260.1399999999999 L 564.4100000000001 261.0599999999999 L 564.8900000000001 261.76999999999987 L 565.4300000000001 262.10999999999984 L 566.98 262.74999999999983 L 569.87 261.86999999999983 L 569.87 261.86999999999983 L 570.51 261.84999999999985 L 570.87 262.2599999999999 L 566.79 271.08999999999986 L 562.9599999999999 276.27999999999986 L 561.93 278.60999999999984 L 556.9 284.34999999999985 L 554.4499999999999 285.60999999999984 L 553.5799999999999 285.59999999999985 L 553.8799999999999 284.16999999999985 L 554.2499999999999 284.01999999999987 L 554.3899999999999 282.91999999999985 L 553.9399999999998 280.98999999999984 L 552.0699999999998 280.73999999999984 L 551.6399999999999 279.4399999999998 L 550.9599999999999 278.6899999999998 L 550.5899999999999 279.28999999999985 L 550.1299999999999 281.61999999999983 L 549.6299999999999 282.48999999999984 L 549.0799999999999 282.86999999999983 L 548.52 282.5799999999998 L 548.03 280.8399999999998 L 548.14 280.5199999999998 L 548.4499999999999 280.3899999999998 L 548.42 279.99999999999983 L 547.55 281.28999999999985 L 548.4799999999999 282.97999999999985 L 548.9399999999999 283.20999999999987 L 549.31 283.0599999999999 L 550.4599999999999 283.3199999999999 L 549.9999999999999 285.1299999999999 L 548.7899999999998 286.27999999999986 L 548.5399999999998 288.09999999999985 L 547.2899999999998 289.0699999999999 L 546.9399999999998 289.7399999999999 L 546.7399999999998 290.57999999999987 L 546.9199999999997 291.4299999999999 L 545.5699999999997 291.0399999999999 L 545.3599999999997 291.4299999999999 L 544.9999999999997 293.9499999999999 L 545.3599999999997 293.22999999999985 L 546.1099999999997 293.4399999999998 L 546.3499999999997 293.97999999999985 L 546.1199999999997 294.3899999999999 L 546.1799999999996 295.0099999999999 L 546.4799999999996 295.3099999999999 L 546.8099999999996 296.3099999999999 L 545.7699999999996 298.8199999999999 L 546.3399999999997 302.2599999999999 L 545.7899999999997 302.7499999999999 L 545.2199999999997 302.52999999999986 L 545.0799999999997 303.65999999999985 L 545.6699999999997 304.11999999999983 L 546.8799999999998 302.3999999999998 L 546.4099999999997 300.1899999999998 L 547.2299999999998 299.5799999999998 L 547.4799999999998 300.11999999999983 L 547.4199999999998 301.8799999999998 L 546.4599999999998 304.48999999999984 L 545.7199999999998 309.91999999999985 L 545.2099999999998 311.72999999999985 L 545.4099999999999 314.1999999999999 L 546.1899999999998 317.0499999999999 L 546.3799999999999 321.5899999999999 L 547.2499999999999 327.99999999999994 L 548.2399999999999 331.41999999999996 L 546.0299999999999 338.08 L 544.6799999999998 344.72999999999996 L 544.2099999999998 345.73999999999995 L 544.0499999999998 348.59999999999997 L 542.9899999999999 352.32 L 542.8999999999999 354.65 L 543.2899999999998 359.07 L 544.1799999999998 360.78 L 541.9399999999998 363.76 L 540.1299999999999 364.43 L 539.1899999999998 365.07 L 536.4699999999998 368.96 L 535.9 371 L 535.9 371 L 527.81 365.86 L 527.5 365.33 z M 549.78 287.33 L 549.55 286.13 L 550.29 285.71999999999997 L 551.3499999999999 284.67999999999995 L 551.5099999999999 284.03999999999996 L 551.1399999999999 283.30999999999995 L 551.8999999999999 283.44999999999993 L 552.7199999999999 284.49999999999994 L 552.67 285.0299999999999 L 549.78 287.33 z M 547.25 294.18 L 546.62 294.15000000000003 L 546.63 293.48 L 546.89 293.12 L 546.09 292.9 L 545.6700000000001 292.5 L 545.8000000000001 291.43 L 547.6700000000001 291.28000000000003 L 547.83 291.48 L 547.94 292.61 L 547.25 294.18 z"},{code:"CE",name:"Ceará",gTransform:"matrix(1 0 0 1 235.04 -154.64)",pathTransform:"translate(-541.04, -164.62)",d:"M 573.79 156.85 L 568.9 158.44 L 566.29 160.45 L 562.99 167.14 L 562.15 168.26 L 561.28 168.83 L 560.63 170.5 L 560.78 171.24 L 559.38 173.68 L 557.92 175.19 L 557.35 176.29 L 556.32 176.55 L 555.54 176.04 L 555.03 176.11 L 554.19 176.99 L 552.78 179.24 L 552.44 181.21 L 553.08 181.38 L 553.74 181 L 553.74 181 L 553.66 181.54 L 552.82 182.69 L 551.79 185.69 L 552.31 187 L 551.65 188.31 L 550.56 188.94 L 550.39 189.32 L 550.27 190.25 L 550.51 190.66 L 551.09 190.95 L 551.44 191.67 L 551.42 193.33 L 552.66 194.22 L 553.35 194.3 L 553.69 195.49 L 552.08 198.98 L 550.89 200.1 L 551.06 200.35 L 551.06 200.35 L 549.47 200.84 L 548.4 201.67 L 546.86 203.96 L 545.21 204.01 L 544.58 202.37 L 543.8 201.8 L 542.44 201.32 L 541.43 200.25 L 540.97 199.26 L 539.14 198.43 L 536.29 196.53 L 533.21 196.11 L 531.92 196.21 L 529.78 197.01 L 528.15 197.2 L 527.26 196.96 L 522.33 196.76 L 522.33 196.76 L 522.39 195.44 L 521.71 194.76 L 521.63 193.79 L 522.77 190.68 L 524.27 188.43 L 524.28 187.74 L 523.51 186.58 L 520.95 186.11 L 519.64 185.46 L 518.63 182.79 L 517.58 177.59 L 516.82 175.02 L 517.06 174.57 L 516.12 166.41 L 516.01 166.03 L 515.09 165.34 L 515.89 164.76 L 516.48 163.18 L 515.88 160.19 L 514.88 158.18 L 515.36 156.58 L 514.57 152.71 L 515.31 151.35 L 515.33 150.59 L 513.97 149 L 513.53 147.27 L 510.38 140.85 L 508.58 136.13 L 508.29 134.84 L 508.47 133.38 L 510.05 131.41 L 511.14 129.56 L 511.25 128.76 L 511.25 128.76 L 511.44 128.62 L 511.4 128 L 511 127.34 L 511.65 126.53 L 518.39 126.31 L 521.28 125.88 L 523.35 125.22 L 530.75 126.01 L 532.87 127.13 L 534.81 128.63 L 538.93 130.81 L 540.39 131.33 L 545.21 134.33 L 546.42 134.53 L 548.64 136.82 L 551.63 138.93 L 554.2 139.65 L 556.64 142.56 L 557.86 143.17 L 560.82 146.98 L 564.98 150.06 L 566.44 152.06 L 567.48 153.05 L 568.98 153.87 L 570.13 153.9 L 572.5 154.82 L 573.29 155.49 z"},{code:"DF",name:"Distrito Federal",gTransform:"matrix(1 0 0 1 103.1 10.18)",pathTransform:"translate(-409.11, -329.45)",d:"M 416.71 333.87 L 402.02 333.85 L 401.5 330.59 L 402.42 328.76 L 402.8 325.03 L 414.75 325.04 L 416.58 327.02 L 416.64 329.23 L 416.05 330.42 L 415.84 332.86 z"},{code:"ES",name:"Espírito Santo",gTransform:"matrix(1 0 0 1 212.62 72.56)",pathTransform:"translate(-518.62, -391.82)",d:"M 501.63 411.37 L 501.34 411.23 L 501.78 408.89 L 502.35 407.59 L 501.76 404.47 L 501.92 404.05 L 503.64 401.99 L 508.79 402.02 L 509.34 401.7 L 510.31 398.46 L 511.42 397.19 L 512.3 394.9 L 512.54 393.18 L 512.8 392.74 L 514.04 391.88 L 515.75 389.79 L 516.29 386.82 L 516 384.39 L 514.73 381.58 L 513.63 380.31 L 513.11 380.22 L 512.66 380.51 L 511.9 380.23 L 511.41 379.52 L 511.84 378.97 L 513.32 378.88 L 514.12 379.23 L 515.09 379.26 L 516.04 379.02 L 516.36 378.6 L 516.19 376.88 L 514.88 376.53 L 514.67 376.12 L 514.97 374.58 L 515 372.66 L 514.48 372 L 513.15 371.33 L 512.85 370.63 L 514.02 368.7 L 516.19 367.39 L 516.5 367.37 L 517.55 368.11 L 518.68 368.22 L 518.7 367.41 L 517.03 365.14 L 518.37 365.27 L 520.55 364.98 L 521.39 364.37 L 522.47 364.05 L 524.05 363.97 L 526.59 364.78 L 527.5 365.33 L 527.5 365.33 L 527.5 365.33 L 527.5 365.33 L 527.8 365.86 L 535.9 371 L 535.9 371 L 534.97 374.35 L 534.66 377.21 L 534.78 380.8 L 535.5 386.95 L 535.19 389.42 L 533.7 392.6 L 530.95 393.99 L 530.4 394.59 L 528.73 397.92 L 527.75 401.72 L 526.98 403.19 L 526.15 402.51 L 525.27 402.38 L 524.98 403.66 L 526.33 404.18 L 524.39 408.42 L 520.94 412.26 L 520.7 411.99 L 518.84 412.65 L 518.04 413.88 L 517.98 415.27 L 517.56 416.52 L 515.97 418.54 L 515.68 419.67 L 515.68 419.67 L 514.06 418.61 L 511.07 418.98 L 506.73 417.97 L 504.23 416.84 L 503.56 412.13 z"},{code:"GO",name:"Goiás",gTransform:"matrix(1 0 0 1 75.37 14.13)",pathTransform:"translate(-381.37, -333.38)",d:"M 416.71 333.87 L 415.84 332.86 L 416.05 330.42 L 416.64 329.23 L 416.58 327.02 L 414.75 325.04 L 402.8 325.03 L 402.42 328.76 L 401.5 330.59 L 402.02 333.85 L 416.71 333.87 L 416.71 333.87 L 416.71 333.87 L 416.71 333.87 L 416.18 335.39 L 416.49 336.96 L 415.81 338.55 L 414.77 339.8 L 414.36 341.27 L 415.21 342.48 L 416.06 342.82 L 417.48 343.85 L 419.13 348.41 L 419.13 349.01 L 416.81 351.72 L 413.57 354.73 L 413.14 356.87 L 414.23 357.98 L 415.13 357.51 L 416.71 358.08 L 417.18 358.69 L 417.36 359.69 L 417.19 360.4 L 416.46 361.3 L 415.95 363.19 L 417.14 366.65 L 414.05 368.71 L 412.89 368.91 L 412.03 369.81 L 411.55 370.93 L 406.66 373.67 L 405.96 372.9 L 401.61 371.04 L 401.06 371.52 L 400.48 371.61 L 398.73 371.62 L 397.25 371.34 L 393.39 371.5 L 391.38 370.61 L 387.25 373.25 L 384.34 376.17 L 384.01 376.17 L 382.7 374.75 L 381.18 374.45 L 377.99 376.09 L 374.28 375.47 L 371.8 376.43 L 369.57 376.97 L 368.16 379.07 L 366.95 381.53 L 367.01 382.53 L 366.17 383.83 L 365.35 384.11 L 364.51 383.95 L 364.06 384.09 L 363.12 384.83 L 361.48 386.93 L 360.91 388.83 L 361.47 389.44 L 361.46 389.78 L 361.1 390.01 L 360.24 389.55 L 360.24 389.55 L 360 389.1 L 357.34 386.86 L 354.19 386.25 L 352.57 384.7 L 350.67 384.27 L 349.18 384.23 L 345.83 382.89 L 345.15 382.04 L 342.08 380.48 L 341.41 379.87 L 339.97 379.16 L 338.83 378.99 L 336.13 377.31 L 333.35 377.47 L 329.55 376.77 L 329.42 376.44 L 329.68 375.6 L 330.25 374.43 L 331.56 372.67 L 331.48 372.25 L 329.23 371.35 L 328.09 372.02 L 327.43 371.83 L 327.15 371.42 L 326.92 370.31 L 327.18 367.73 L 326.99 365.96 L 326.99 365.96 L 326.04 363.76 L 325.86 360.33 L 324.45 358.14 L 324.29 357.43 L 324.69 354.02 L 327.24 350.17 L 327.62 347.26 L 328.32 346.49 L 330.34 345.65 L 332.26 343.88 L 333.51 341.86 L 333.84 339.91 L 334.34 338.9 L 335.62 337.86 L 336.44 336.43 L 336.52 334.89 L 338.27 333.92 L 339.67 331.3 L 342.32 331.17 L 345.04 330.31 L 345.36 330.03 L 347.34 325.84 L 348.05 324.88 L 348.69 320.78 L 349.07 320.04 L 350.99 318.1 L 352.64 317.09 L 353.71 316.83 L 354.94 317.51 L 356.15 316.78 L 357.54 315.35 L 358.38 312.42 L 359.55 309.55 L 359.54 308.75 L 359.06 307.61 L 359.64 304.87 L 361.24 301.78 L 361.12 296.6 L 362.33 295.82 L 363.36 293.19 L 365.36 290.02 L 365.75 288.95 L 365.59 286.23 L 365.94 285.33 L 366.91 284.47 L 367.18 283.34 L 367.1 282.71 L 367.1 282.71 L 367.44 282.26 L 367.64 280.38 L 368.3 279.15 L 370.11 277.06 L 370.67 276.76 L 370.64 278.47 L 369.42 280.35 L 368.9 282.69 L 371.3 283.09 L 373.5 284.12 L 377.43 284.52 L 380.52 286.23 L 384.59 287.66 L 385.22 287.43 L 386.85 281.49 L 388.32 279.1 L 389.5 278.13 L 390.65 279.44 L 391.69 281.32 L 392.8 285.03 L 393.41 288.13 L 394.55 288.18 L 395.3 287.43 L 395.6 286.43 L 396.16 285.89 L 398.92 286.23 L 403.45 285.7 L 403.67 286.44 L 403.11 288 L 406.24 289.47 L 409.59 290.15 L 410.28 290.07 L 410.79 286.77 L 411.34 286.8 L 412.85 289.42 L 413.31 289.66 L 415.09 288.76 L 417.61 286.68 L 422.14 285.68 L 423.69 285.68 L 426.25 284.58 L 427.99 283.24 L 433.35 281.82 L 433.35 281.82 L 436.07 284.28 L 436.09 284.66 L 434.66 285.72 L 434.18 288.24 L 434.28 288.57 L 435.91 289.41 L 435.85 290.35 L 435.62 290.73 L 434.03 291.76 L 432.84 295.59 L 432.79 297.14 L 433.41 300.66 L 435.11 304.12 L 438.32 306.74 L 438.37 307.21 L 437.65 308.63 L 437.55 309.3 L 438.22 311.02 L 438.45 312.3 L 438.2 313.07 L 436.72 315.04 L 436.72 315.04 L 435.72 316.05 L 432.49 315.71 L 431.59 313.95 L 429.17 312.47 L 428 313.96 L 428.58 317.73 L 428.01 318.27 L 427.61 318.4 L 424.83 317.26 L 423.66 317.49 L 423.29 317.77 L 422.57 320.95 L 423.29 321.05 L 423.78 322.21 L 423.21 323.15 L 422.48 323.85 L 422.52 325.75 L 422.94 326.36 L 423.47 326.55 L 424.16 330.81 L 423.63 331.34 L 420.27 332.24 L 417.98 333.75 z"},{code:"MA",name:"Maranhão",gTransform:"matrix(1 0 0 1 142.22 -148.63)",pathTransform:"translate(-448.22, -170.64)",d:"M 458.57 128.92 L 458.53 129.25 L 456.48999999999995 131.4 L 456.05999999999995 131.57 L 456.0199999999999 133.01 L 457.98999999999995 131.31 L 458.66999999999996 130.1 L 460.78999999999996 128.51999999999998 L 461.67999999999995 127.37999999999998 L 462.7099999999999 121.04999999999998 L 463.8599999999999 120.34999999999998 L 464.9699999999999 120.22999999999998 L 466.63999999999993 119.30999999999997 L 467.2899999999999 119.17999999999998 L 467.7499999999999 119.29999999999998 L 467.82999999999987 120.92999999999998 L 467.6299999999999 121.37999999999998 L 466.20999999999987 123.24999999999999 L 462.9999999999999 124.99999999999999 L 462.9699999999999 125.71999999999998 L 463.69999999999993 125.83999999999999 L 464.1499999999999 125.02999999999999 L 465.2999999999999 124.71999999999998 L 465.5199999999999 125.54999999999998 L 464.92999999999995 126.05999999999999 L 465.17999999999995 126.35999999999999 L 469.38999999999993 121.38999999999999 L 470.24999999999994 121.71999999999998 L 472.8299999999999 120.78999999999998 L 476.86999999999995 121.21999999999998 L 476.40999999999997 118.80999999999999 L 477.02 118.57999999999998 L 479.44 118.65999999999998 L 481.21999999999997 119.03999999999998 L 483.84999999999997 120.08999999999997 L 484.89 120.19999999999997 L 487.03999999999996 121.57999999999997 L 488.43999999999994 121.60999999999997 L 489.69999999999993 122.90999999999997 L 491.5899999999999 124.22999999999996 L 494.0899999999999 124.80999999999996 L 495.24999999999994 124.61999999999996 L 495.80999999999995 125.37999999999997 L 496.1499999999999 125.42999999999996 L 497.7399999999999 125.33999999999996 L 500.1999999999999 125.99999999999996 L 500.45999999999987 125.09999999999995 L 499.78999999999985 124.62999999999995 L 501.45999999999987 124.24999999999996 L 502.02999999999986 124.35999999999996 L 501.9399999999999 124.77999999999996 L 501.9399999999999 124.77999999999996 L 501.4799999999999 126.20999999999997 L 501.7099999999999 126.92999999999996 L 502.3399999999999 127.46999999999997 L 501.9599999999999 128.99999999999997 L 500.1699999999999 131.26999999999998 L 496.0399999999999 135.23999999999998 L 492.7199999999999 135.7 L 491.9199999999999 135.54 L 488.9999999999999 138.94 L 489.0399999999999 140.74 L 488.1599999999999 142.57000000000002 L 486.2699999999999 144.42000000000002 L 485.44999999999993 146.4 L 484.80999999999995 146.57 L 484.03999999999996 147.62 L 484.4 149.54 L 485.63 150.37 L 486.01 151.65 L 485.73 153.11 L 484.59000000000003 155.98000000000002 L 486.17 158.79000000000002 L 486.72 161.77 L 486.61 164.20000000000002 L 486.40000000000003 164.75000000000003 L 482.3 169.17000000000002 L 482.13 171.65 L 482.25 173.76000000000002 L 482.76 176.06000000000003 L 484.53999999999996 178.10000000000002 L 486.15 179.01000000000002 L 486.32 179.51000000000002 L 486.45 180.35000000000002 L 486.06 182.55 L 485.77 182.99 L 485.65 184.20000000000002 L 485.15 185.66000000000003 L 483.94 186.97000000000003 L 481.65 187.26000000000002 L 481 186.98000000000002 L 480.17 187.02 L 477.74 187.88000000000002 L 476.22 187.99000000000004 L 473.72 186.17000000000004 L 472.71000000000004 185.96000000000004 L 471.25000000000006 186.15000000000003 L 470.24000000000007 186.75000000000003 L 469.12000000000006 187.01000000000002 L 468.89000000000004 186.71 L 468.05000000000007 186.95000000000002 L 467.55000000000007 187.17000000000002 L 465.6500000000001 189.08 L 465.6600000000001 189.54000000000002 L 465.0300000000001 190.41000000000003 L 463.0200000000001 192.41000000000003 L 460.6800000000001 193.32000000000002 L 457.8100000000001 195.88000000000002 L 456.48000000000013 196.41000000000003 L 455.4300000000001 196.45000000000002 L 453.73000000000013 197.98000000000002 L 452.65000000000015 198.34000000000003 L 450.04000000000013 198.66000000000003 L 447.3200000000001 199.42000000000002 L 445.1900000000001 201.37 L 444.2100000000001 204.34 L 443.8200000000001 207.31 L 443.1900000000001 209.63 L 441.7400000000001 212.37 L 441.4400000000001 212.59 L 441.10000000000014 213.41 L 440.97000000000014 214.93 L 439.77000000000015 217.41 L 438.07000000000016 218.81 L 437.34000000000015 220.81 L 438.0500000000001 222.75 L 438.52000000000015 225.93 L 440.25000000000017 228.99 L 440.21000000000015 229.51000000000002 L 439.45000000000016 230.91000000000003 L 439.32000000000016 237.27000000000004 L 438.1700000000002 239.72000000000003 L 437.9100000000002 240.78000000000003 L 437.8600000000002 242.70000000000002 L 437.8600000000002 242.70000000000002 L 436.5800000000002 242.04000000000002 L 435.9700000000002 241.22000000000003 L 435.1500000000002 240.77000000000004 L 434.1600000000002 240.48000000000005 L 432.3800000000002 240.68000000000004 L 431.67000000000024 240.50000000000003 L 430.3200000000002 238.50000000000003 L 429.3300000000002 235.64000000000001 L 427.2000000000002 234.02 L 427.06000000000023 232.37 L 428.7000000000002 230.56 L 428.62000000000023 230.03 L 424.74000000000024 228.08 L 424.12000000000023 227.03 L 424.06000000000023 225.37 L 423.31000000000023 223.78 L 422.37000000000023 223.09 L 420.29000000000025 222.81 L 420.09000000000026 222.39000000000001 L 420.35000000000025 221.68 L 422.98000000000025 219.14000000000001 L 422.61000000000024 217.83 L 423.34000000000026 215.15 L 424.03000000000026 213.72 L 424.60000000000025 213.17 L 425.9400000000002 212.63 L 429.3300000000002 212.28 L 428.9400000000002 210.93 L 429.5800000000002 207.68 L 429.5000000000002 205.92000000000002 L 427.7000000000002 204.71 L 423.43000000000023 205.65 L 421.28000000000026 206.99 L 419.0100000000003 203.97 L 418.10000000000025 203.12 L 415.10000000000025 198.97 L 414.22000000000025 199.04 L 413.3800000000003 197.6 L 413.9900000000003 196.41 L 413.8800000000003 195.53 L 413.6300000000003 195.19 L 412.2600000000003 194.95 L 411.84000000000026 195.22 L 409.91000000000025 193.89 L 410.09000000000026 193.17999999999998 L 411.85000000000025 192.51999999999998 L 413.60000000000025 190.48 L 413.85000000000025 188.89 L 413.5700000000003 187.89 L 413.8800000000003 185.52999999999997 L 415.65000000000026 179.36999999999998 L 415.66000000000025 178.93999999999997 L 414.98000000000025 177.79999999999998 L 414.7500000000002 176.71999999999997 L 414.9600000000002 172.99999999999997 L 414.3200000000002 171.49999999999997 L 413.8500000000002 168.00999999999996 L 413.0100000000002 166.97999999999996 L 409.61000000000024 165.53999999999996 L 408.3900000000002 165.51999999999995 L 408.11000000000024 165.19999999999996 L 408.03000000000026 164.16999999999996 L 407.4400000000003 163.47999999999996 L 405.7000000000003 163.18999999999997 L 404.7400000000003 163.70999999999998 L 403.3400000000003 163.61999999999998 L 400.56000000000034 162.10999999999999 L 399.70000000000033 162.04999999999998 L 397.74000000000035 162.57999999999998 L 395.12000000000035 164.42999999999998 L 394.5900000000004 165.06999999999996 L 394.5900000000004 165.06999999999996 L 394.10000000000036 164.98999999999995 L 408.81000000000034 153.15999999999994 L 411.16000000000037 153.38999999999993 L 412.3300000000004 152.46999999999994 L 413.8800000000004 150.29999999999995 L 414.3100000000004 149.14999999999995 L 415.8600000000004 147.97999999999996 L 416.4800000000004 145.09999999999997 L 417.6000000000004 144.63999999999996 L 420.0400000000004 142.31999999999996 L 420.51000000000045 141.10999999999996 L 420.80000000000047 139.20999999999995 L 422.4000000000005 134.51999999999995 L 424.36000000000047 132.97999999999996 L 425.8400000000005 131.21999999999997 L 426.67000000000047 129.76999999999998 L 427.13000000000045 128.48999999999998 L 426.95000000000044 126.66999999999999 L 427.74000000000046 125.85999999999999 L 426.70000000000044 124.27999999999999 L 430.38000000000045 121.18999999999998 L 430.25000000000045 119.54999999999998 L 430.75000000000045 117.16999999999999 L 432.49000000000046 115.6 L 432.8500000000005 114.89 L 433.75000000000045 111.87 L 433.83000000000044 110.26 L 433.40000000000043 109.73 L 432.4100000000004 109.89 L 432.14000000000044 109.4 L 432.19000000000045 108.78 L 433.33000000000044 108.63 L 433.90000000000043 107.89 L 434.6100000000004 103.5 L 434.4500000000004 102.12 L 434.9200000000004 101.09 L 435.6900000000004 100.64 L 435.6900000000004 100.64 L 436.3200000000004 100.64 L 436.5600000000004 100.4 L 436.5000000000004 99.86 L 436.8400000000004 99.11 L 437.42000000000036 98.58 L 438.76000000000033 99.56 L 439.2100000000003 101.4 L 440.4000000000003 101.52000000000001 L 441.1700000000003 100.16000000000001 L 441.7800000000003 103.09000000000002 L 442.7700000000003 103.13000000000002 L 443.06000000000034 102.64000000000003 L 443.13000000000034 101.70000000000003 L 443.98000000000036 101.66000000000003 L 445.67000000000036 102.19000000000003 L 446.17000000000036 102.88000000000002 L 444.74000000000035 104.58000000000003 L 445.41000000000037 105.28000000000003 L 445.43000000000035 105.83000000000003 L 446.6400000000003 103.79000000000002 L 447.13000000000034 102.25000000000001 L 447.5800000000003 102.25000000000001 L 447.9800000000003 103.27000000000001 L 447.9800000000003 103.85000000000001 L 447.1100000000003 104.77000000000001 L 446.8400000000003 105.76 L 446.9200000000003 108.47 L 447.1800000000003 108.8 L 447.6500000000003 108.92 L 448.2300000000003 108.78 L 449.1900000000003 107.85 L 448.72000000000025 106.85 L 448.86000000000024 106.25 L 450.18000000000023 104.82 L 451.23000000000025 104.57 L 453.36000000000024 105.16 L 454.86000000000024 104.05 L 454.91000000000025 104.97 L 454.55000000000024 105.17999999999999 L 453.42000000000024 106.71 L 454.0100000000002 107.28999999999999 L 454.11000000000024 106.91999999999999 L 455.36000000000024 106.32 L 455.9400000000002 107.11 L 455.80000000000024 108.32 L 457.43000000000023 110.07 L 458.29000000000025 109.63 L 459.87000000000023 110.3 L 460.6400000000002 112.7 L 460.5300000000002 113.65 L 458.3400000000002 116.38000000000001 L 457.9600000000002 117.27000000000001 L 458.06000000000023 117.93 L 458.66000000000025 116.9 L 460.41000000000025 115.22 L 461.24000000000024 115.19 L 462.11000000000024 116 L 462.6300000000002 117.89 L 462.36000000000024 119.12 L 461.3900000000002 119.31 L 460.36000000000024 120.22 L 459.2000000000002 121.71 L 459.2700000000002 122.47999999999999 L 458.1100000000002 124.82999999999998 L 457.4900000000002 128.35 L 457.70000000000016 128.69 L 458.57 128.92 z M 459.09 129.37 L 459.03 128.58 L 459.55999999999995 127.05000000000001 L 459.1499999999999 125.98000000000002 L 459.2799999999999 125.32000000000002 L 460.18999999999994 124.08000000000003 L 460.73999999999995 123.89000000000003 L 460.78999999999996 126.24000000000002 L 460.56999999999994 127.58000000000003 L 459.7699999999999 128.18000000000004 L 459.09 129.37 z M 452.79 103.61 L 452.35 103.15 L 452.27000000000004 102.55000000000001 L 453.07000000000005 101.43 L 453.91 101.4 L 454.59000000000003 101.82000000000001 L 454.69000000000005 102.16000000000001 L 454.50000000000006 102.52000000000001 L 452.79 103.61 z M 456.29 107.79 L 456 107.49000000000001 L 456.06 106.96000000000001 L 457.12 106.07000000000001 L 457.6 106.14 L 458.1 106.99 L 457.96000000000004 107.6 L 457.56000000000006 107.42999999999999 L 456.29 107.79 z M 442.13 102.98 L 441.92 102.93 L 442.87 99.35000000000001 L 443.17 99.44000000000001 L 443.2 99.67000000000002 L 442.78999999999996 102.73000000000002 L 442.13 102.98 z"},{code:"MG",name:"Minas Gerais",gTransform:"matrix(1 0 0 1 139.79 56.66)",pathTransform:"translate(-445.79, -375.93)",d:"M 527.5 365.33 L 526.59 364.78 L 524.05 363.97 L 522.47 364.05 L 521.39 364.37 L 520.55 364.98 L 518.37 365.27 L 517.03 365.14 L 518.7 367.41 L 518.68 368.22 L 517.55 368.11 L 516.5 367.37 L 516.19 367.39 L 514.02 368.7 L 512.85 370.63 L 513.15 371.33 L 514.48 372 L 515 372.66 L 514.97 374.58 L 514.67 376.12 L 514.88 376.53 L 516.19 376.88 L 516.36 378.6 L 516.04 379.02 L 515.09 379.26 L 514.12 379.23 L 513.32 378.88 L 511.84 378.97 L 511.41 379.52 L 511.9 380.23 L 512.66 380.51 L 513.11 380.22 L 513.63 380.31 L 514.73 381.58 L 516 384.39 L 516.29 386.82 L 515.75 389.79 L 514.04 391.88 L 512.8 392.74 L 512.54 393.18 L 512.3 394.9 L 511.42 397.19 L 510.31 398.46 L 509.34 401.7 L 508.79 402.02 L 503.64 401.99 L 501.92 404.05 L 501.76 404.47 L 502.35 407.59 L 501.78 408.89 L 501.34 411.23 L 501.63 411.37 L 501.63 411.37 L 499.1 413.72 L 497.86 413.99 L 497.3 414.49 L 498.04 415.19 L 495.68 421.24 L 493.78 424.95 L 493.69 425.7 L 495.13 425.83 L 495.42 426.44 L 495.21 426.96 L 492.68 427.94 L 483.17 432.47 L 481.8 432.67 L 481.82 432.21 L 481.33 432.04 L 478.8 431.77 L 478.23 431.83 L 476.61 432.77 L 475.36 432.93 L 472.16 433.01 L 471.8 432.69 L 471.29 432.77 L 467.19 434.55 L 466.14 435.32 L 464.43 436.09 L 463.93 435.81 L 461.34 435.98 L 458.43 437.32 L 456.01 438.06 L 455.33 438.55 L 455.33 438.55 L 454.08 439.28 L 451.88 439.5 L 449.95 440.52 L 448.72 441.76 L 446.93 442.43 L 444.55 442.68 L 442.21 442.6 L 442.2 442.11 L 442.55 441.62 L 442.46 441.27 L 441.27 441.6 L 441.09 443.9 L 441.33 444.13 L 441.28 444.97 L 440.53 445.95 L 439.23 446.27 L 438.66 445.84 L 435.05 446.84 L 434.86 446.31 L 432.85 446.55 L 431.73 446.3 L 429.7 442.99 L 430.92 442.28 L 430.4 440.57 L 428.6 439.74 L 426.81 438.51 L 426.1 436.9 L 426.63 435.34 L 426.82 431.89 L 426.56 428.95 L 428.42 426.23 L 429.12 424.05 L 429.17 422.78 L 428.94 422.41 L 425.24 421.09 L 424.24 421.14 L 423.96 421.5 L 423.18 421.81 L 421.57 421.86 L 421.6 421.01 L 420.77 419.02 L 419.47 417.23 L 419.1 415.02 L 418.79 414.4 L 418 413.66 L 418.19 411.72 L 419.71 409.69 L 419.77 409.13 L 419.37 407.58 L 417.49 406.37 L 416.91 405.76 L 417.2 403.39 L 417.77 402.38 L 417.57 401.34 L 414.3 397.99 L 413 398.28 L 412.15 398.92 L 410.5 398.14 L 408.12 398.25 L 407.81 398.86 L 408.01 399.32 L 407.57 400.31 L 404.79 400.99 L 403.68 400.56 L 402.17 399.11 L 401.16 400.36 L 392.98 401.04 L 392.52 401.52 L 392.04 402.71 L 392.31 405.25 L 391.9 405.69 L 390.71 405.17 L 390.7 402.39 L 390.45 401.43 L 390.09 401.04 L 389.53 400.99 L 389.27 401.18 L 388.86 402.31 L 388.19 403.25 L 387.65 403.57 L 387.03 403.55 L 385.82 401.45 L 385.49 400.03 L 385.63 399.12 L 383.95 398.33 L 381.77 396.91 L 379.78 397.5 L 378.16 397.28 L 376.49 397.63 L 372.2 396.67 L 369.65 396.59 L 367.92 395.04 L 367.17 394.9 L 365.67 395.51 L 364.24 397.2 L 362.32 397.57 L 360.17 398.68 L 358.95 399.81 L 358.95 399.81 L 359.26 397.19 L 358.67 393.98 L 359.66 389.8 L 360.24 389.55 L 360.24 389.55 L 361.1 390.01 L 361.46 389.78 L 361.47 389.44 L 360.91 388.83 L 361.48 386.93 L 363.12 384.83 L 364.06 384.09 L 364.51 383.95 L 365.35 384.11 L 366.17 383.83 L 367.01 382.53 L 366.95 381.53 L 368.16 379.07 L 369.57 376.97 L 371.8 376.43 L 374.28 375.47 L 377.99 376.09 L 381.18 374.45 L 382.7 374.75 L 384.01 376.17 L 384.34 376.17 L 387.25 373.25 L 391.38 370.61 L 393.39 371.5 L 397.25 371.34 L 398.73 371.62 L 400.48 371.61 L 401.06 371.52 L 401.61 371.04 L 405.96 372.9 L 406.66 373.67 L 411.55 370.93 L 412.03 369.81 L 412.89 368.91 L 414.05 368.71 L 417.14 366.65 L 415.95 363.19 L 416.46 361.3 L 417.19 360.4 L 417.36 359.69 L 417.18 358.69 L 416.71 358.08 L 415.13 357.51 L 414.23 357.98 L 413.14 356.87 L 413.57 354.73 L 416.81 351.72 L 419.13 349.01 L 419.13 348.41 L 417.48 343.85 L 416.06 342.82 L 415.21 342.48 L 414.36 341.27 L 414.77 339.8 L 415.81 338.55 L 416.49 336.96 L 416.18 335.39 L 416.71 333.87 L 417.98 333.75 L 420.27 332.24 L 423.63 331.34 L 424.16 330.81 L 423.47 326.55 L 422.94 326.36 L 422.52 325.75 L 422.48 323.85 L 423.21 323.15 L 423.78 322.21 L 423.29 321.05 L 422.57 320.95 L 423.29 317.77 L 423.66 317.49 L 424.83 317.26 L 427.61 318.4 L 428.01 318.27 L 428.58 317.73 L 428 313.96 L 429.17 312.47 L 431.59 313.95 L 432.49 315.71 L 435.72 316.05 L 436.72 315.04 L 436.72 315.04 L 437.23 317.45 L 435.8 320.89 L 436.2 321.12 L 437.54 320.21 L 438.24 319.21 L 438.96 319.08 L 441.09 319.46 L 442.13 318.69 L 443.98 316.12 L 444.97 316.27 L 446.4 315.74 L 448.21 314.19 L 449.16 313.02 L 451.18 312.61 L 454.55 310.75 L 455.19 309.64 L 459.46 306.61 L 463.28 305.03 L 465.08 305.12 L 466.28 305.62 L 468.46 305.65 L 470.74 306.18 L 471.59 306.64 L 470.3 309.38 L 470.15 310.27 L 470.41 311.76 L 471.02 312.26 L 476.35 313.72 L 476.99 313.55 L 477.8 312.43 L 479.68 311.54 L 481.45 311.28 L 484.18 312.03 L 485.28 312.57 L 489.63 316.21 L 490.61 316.03 L 492.78 317.65 L 495.31 318.87 L 496.24 319.09 L 496.75 318.88 L 498.28 320.12 L 502.67 318.89 L 503.05 319.07 L 509.57 325.27 L 510.01 329.23 L 510.58 329.02 L 513.19 329.47 L 514.66 328.97 L 515.98 327.98 L 517.97 328.13 L 520.7 328.69 L 522.96 329.77 L 525.15 330.38 L 527.27 330.35 L 530.1 332.82 L 530.83 333.2 L 531.72 333.27 L 532.5 334.29 L 532.92 335.46 L 531.45 338.54 L 526.49 342.76 L 526.34 345.41 L 526.9 346.43 L 526.9 346.85 L 525.88 347.56 L 523.4 347.32 L 522.58 348.2 L 521.76 351.5 L 521.23 355.9 L 521.45 356.15 L 521.8 355.96 L 522 355.51 L 522.64 355.27 L 523.22 356.5 L 523 358.01 L 523.15 358.52 L 527.29 361.58 L 527.82 362.62 L 527.83 363.15 L 527.15 364.5 z"},{code:"MS",name:"Mato Grosso do Sul",gTransform:"matrix(1 0 0 1 -2.22 90.13)",pathTransform:"translate(-303.77, -409.4)",d:"M 358.95 399.81 L 358.55 402.27 L 358.27 402.67 L 356.77 403.45 L 355.45 403.49 L 354.98 403.71 L 353.76 404.74 L 351.77 407.42 L 351.04 408.07 L 350.03 408.37 L 349.41 410.05 L 349.25 412.98 L 346.66 416.62 L 345.7 417.14 L 345.47 417.52 L 345.78 419.45 L 345.7 420.4 L 344.49 422.74 L 342.49 425 L 342.84 425.85 L 342.56 427.06 L 341.12 428.09 L 340.72 429.3 L 338.99 430.99 L 337.73 433.43 L 335.78 435.3 L 328.22 439.83 L 326.96 440.97 L 326.22 442.51 L 325.38 443.59 L 325.38 443.59 L 319.97 445.86 L 318.86 446.68 L 317.93 449.01 L 317.95 450.16 L 316.5 453.72 L 315.83 454.4 L 314.17 455.41 L 313.06 455.73 L 312.73 456.08 L 311.16 464 L 310.8 464.82 L 308.42 466.38 L 308.42 466.38 L 305.87 464.05 L 302.46 462.16 L 298.47 464.13 L 297.79 464.88 L 296.13 465.37 L 293.55 465.8 L 291.19 465.34 L 290.18 464.69 L 289.71 460.42 L 289.39 459.72 L 288.49 458.77 L 288.26 456.3 L 288.77 454.96 L 288.13 454.17 L 288.04 453.73 L 288.04 450.86 L 287.15 448.89 L 286.55 446.15 L 286.5 445.43 L 287.09 444.07 L 287.11 442.46 L 285.54 441.37 L 285.16 440.57 L 285 438.41 L 283.35 436.59 L 281.18 436.33 L 279.67 436.64 L 277.84 436.35 L 275.38 434.39 L 274.82 432.9 L 273.28 433.23 L 271.11 435.97 L 270.11 435.37 L 268.39 436.18 L 267.31 436.34 L 265.57 435.65 L 263.01 435.16 L 259.55 435.39 L 255.89 434.68 L 255.41 433.77 L 253.42 433.64 L 252.53 434.16 L 250.03 433.28 L 250.94 426.01 L 250.51 423.63 L 251.11 422.21 L 252.09 420.75 L 252.69 414.72 L 252.03 412.39 L 251.98 410.66 L 251.22 409.7 L 250.79 409.61 L 250.3 410.26 L 249.66 407 L 248.87 405.13 L 247.66 403.11 L 247.31 401.28 L 251.34 398.98 L 252.1 398.1 L 247.9 394.24 L 253.28 382.82 L 254.4 382.76 L 254.12 380.63 L 253.38 380.5 L 256.61 370.17 L 257.27 369.01 L 254.18 363.16 L 254.21 361.25 L 254.21 361.25 L 254.91 361.45 L 255.93 362.55 L 258.08 364.07 L 263.7 362.1 L 265.75 360.1 L 267.77 357.15 L 267.86 355.98 L 269.26 354.53 L 271.85 354.56 L 273.41 354.34 L 274.18 354.68 L 275.84 354.17 L 277.19 352.92 L 279.21 352.43 L 280.48 352.63 L 281.24 353.78 L 284.03 355.03 L 286.65 355.5 L 287.3 355.85 L 287.57 356.71 L 288.35 357.73 L 291.38 358.89 L 292.64 360 L 293.88 360.57 L 298.4 359.94 L 299.66 359.14 L 300.15 358.29 L 301.58 357.68 L 304.02 357.75 L 305.61 358.79 L 305.91 360.16 L 306.15 360.41 L 307.14 360.45 L 309.27 359.57 L 310.28 359.63 L 315.9 353.62 L 317.24 353.49 L 316.01 360.1 L 314.21 360.8 L 312.55 363.63 L 312.36 364.09 L 312.51 364.62 L 313.81 364.73 L 315.55 366 L 320.17 366.27 L 320.74 365.7 L 323.4 365.62 L 324.27 365.7 L 325.44 366.27 L 326.99 365.96 L 326.99 365.96 L 327.18 367.73 L 326.92 370.31 L 327.15 371.42 L 327.43 371.83 L 328.09 372.02 L 329.23 371.35 L 331.48 372.25 L 331.56 372.67 L 330.25 374.43 L 329.68 375.6 L 329.42 376.44 L 329.55 376.77 L 333.35 377.47 L 336.13 377.31 L 338.83 378.99 L 339.97 379.16 L 341.41 379.87 L 342.08 380.48 L 345.15 382.04 L 345.83 382.89 L 349.18 384.23 L 350.67 384.27 L 352.57 384.7 L 354.19 386.25 L 357.34 386.86 L 360 389.1 L 360.24 389.55 L 360.24 389.55 L 359.66 389.8 L 358.67 393.98 L 359.26 397.19 z"},{code:"MT",name:"Mato Grosso",gTransform:"matrix(1 0 0 1 -23.8 -38.15)",pathTransform:"translate(-282.2, -281.12)",d:"M 206.96 296.05 L 208.43 294.62 L 212.54 292.05 L 213.06 289.6 L 214.49 285.82 L 215.42 284.74 L 217.06 284.21 L 217.49 283.8 L 218.07 282.96 L 218.59 280.71 L 220.25 278.7 L 220.81 276.46 L 220.88 274.75 L 220.3 273.26 L 220.34 271.21 L 218.81 267.87 L 217.91 267.9 L 217.33 267.39 L 216.9 264.14 L 217.04 262.82 L 218.4 261.74 L 219.8 259.99 L 219.97 259.24 L 218.56 255.65 L 217.49 255.22 L 216.38 255.11 L 212.88 255.2 L 211.66 254.09 L 211.9 253.53 L 194.74 253.48 L 195.64 244.48 L 194.14 241.73 L 193.87 239.97 L 193.9 239.17 L 194.9 235.65 L 194.52 233.72 L 195.46 232.05 L 194.63 229.78 L 194.48 228.39 L 194.22 227.78 L 193.44 227.31 L 193.38 226.96 L 194.67 221.97 L 195.43 220.55 L 194.83 219.31 L 193.43 218.34 L 193.43 218.34 L 241.28 218.02 L 242.49 217.29 L 243.67 212.07 L 245.05 207.85 L 244.59 205.91 L 243.93 204.54 L 243.83 203.69 L 244.25 202.84 L 245.11 202.2 L 246.31 200.38 L 246.58 199.37 L 246.24 198.53 L 246.3 197.77 L 246.5 197.16 L 247.68 195.96 L 247.68 195.96 L 248.85 197.04 L 251.3 201.1 L 251.7 202.86 L 253.07 206.82 L 254.39 208.75 L 255.16 210.37 L 254.93 212.81 L 255.41 215.21 L 256.14 217.41 L 257.67 218.52 L 260.67 221.27 L 264.05 222.97 L 264.28 223.91 L 264.24 225.01 L 264.47 225.5 L 265.42 225.9 L 266.24 225.73 L 267.87 226.18 L 268.41 226.9 L 268.61 227.98 L 268.96 228.3 L 270.33 227.85 L 274.02 229.34 L 308.06 231.76 L 371.03 235.24 L 371.03 235.24 L 370.38 236.26 L 369.82 238.15 L 368.72 239.4 L 368.28 242.54 L 367.85 243.39 L 367.48 243.66 L 365.54 248.95 L 365 251.92 L 364.96 254.87 L 363.08 260.86 L 363.14 261.72 L 364.53 263.06 L 364.37 263.93 L 363.55 264.82 L 363.5 265.32 L 364.6 267.57 L 364.13 270.88 L 364.14 272.45 L 364.66 273.03 L 365.1 276.08 L 364.36 278.84 L 365.34 282.18 L 366.3 282.69 L 367.1 282.71 L 367.1 282.71 L 367.18 283.34 L 366.91 284.47 L 365.94 285.33 L 365.59 286.23 L 365.75 288.95 L 365.36 290.02 L 363.36 293.19 L 362.33 295.82 L 361.12 296.6 L 361.24 301.78 L 359.64 304.87 L 359.06 307.61 L 359.54 308.75 L 359.55 309.55 L 358.38 312.42 L 357.54 315.35 L 356.15 316.78 L 354.94 317.51 L 353.71 316.83 L 352.64 317.09 L 350.99 318.1 L 349.07 320.04 L 348.69 320.78 L 348.05 324.88 L 347.34 325.84 L 345.36 330.03 L 345.04 330.31 L 342.32 331.17 L 339.67 331.3 L 338.27 333.92 L 336.52 334.89 L 336.44 336.43 L 335.62 337.86 L 334.34 338.9 L 333.84 339.91 L 333.51 341.86 L 332.26 343.88 L 330.34 345.65 L 328.32 346.49 L 327.62 347.26 L 327.24 350.17 L 324.69 354.02 L 324.29 357.43 L 324.45 358.14 L 325.86 360.33 L 326.04 363.76 L 326.99 365.96 L 326.99 365.96 L 325.44 366.27 L 324.27 365.7 L 323.4 365.62 L 320.74 365.7 L 320.17 366.27 L 315.55 366 L 313.81 364.73 L 312.51 364.62 L 312.36 364.09 L 312.55 363.63 L 314.21 360.8 L 316.01 360.1 L 317.24 353.49 L 315.9 353.62 L 310.28 359.63 L 309.27 359.57 L 307.14 360.45 L 306.15 360.41 L 305.91 360.16 L 305.61 358.79 L 304.02 357.75 L 301.58 357.68 L 300.15 358.29 L 299.66 359.14 L 298.4 359.94 L 293.88 360.57 L 292.64 360 L 291.38 358.89 L 288.35 357.73 L 287.57 356.71 L 287.3 355.85 L 286.65 355.5 L 284.03 355.03 L 281.24 353.78 L 280.48 352.63 L 279.21 352.43 L 277.19 352.92 L 275.84 354.17 L 274.18 354.68 L 273.41 354.34 L 271.85 354.56 L 269.26 354.53 L 267.86 355.98 L 267.77 357.15 L 265.75 360.1 L 263.7 362.1 L 258.08 364.07 L 255.93 362.55 L 254.91 361.45 L 254.21 361.25 L 254.21 361.25 L 253.55 360.58 L 253.23 359.78 L 253.77 359.07 L 251.33 356.92 L 250.05 357.55 L 249.53 357.5 L 248.36 356.82 L 247.91 356.12 L 245.89 354.71 L 244 353.95 L 243.7 353.63 L 243.4 352.51 L 243.17 349.58 L 242.56 347.81 L 242.37 344.15 L 243.25 342.51 L 244.39 341.42 L 244.73 339.64 L 244.68 337.75 L 243.72 337.81 L 243.32 338.41 L 242.94 338.57 L 216.08 337.49 L 215.03 324.84 L 209.66 318.71 L 214.54 318.65 L 214.19 311.1 L 211.55 305.78 L 211.06 303.81 L 211.32 302.75 L 211.93 302.2 L 212.58 300.92 L 211.14 297.99 L 208.03 296.95 z"},{code:"PA",name:"Pará",gTransform:"matrix(1 0 0 1 29.16 -180.48)",pathTransform:"translate(-335.15, -138.78)",d:"M 371.03 235.24 L 308.05999999999995 231.76000000000002 L 274.0199999999999 229.34000000000003 L 270.3299999999999 227.85000000000002 L 268.9599999999999 228.3 L 268.6099999999999 227.99 L 268.4099999999999 226.9 L 267.8599999999999 226.18 L 266.2299999999999 225.73000000000002 L 265.4099999999999 225.9 L 264.4599999999999 225.51000000000002 L 264.2299999999999 225.01000000000002 L 264.2699999999999 223.91000000000003 L 264.0399999999999 222.97000000000003 L 260.6599999999999 221.27000000000004 L 257.6599999999999 218.51000000000005 L 256.1199999999999 217.40000000000003 L 255.3999999999999 215.20000000000005 L 254.9199999999999 212.81000000000006 L 255.1499999999999 210.37000000000006 L 254.37999999999988 208.74000000000007 L 253.04999999999987 206.81000000000006 L 251.67999999999986 202.86000000000007 L 251.28999999999988 201.10000000000008 L 248.8399999999999 197.04000000000008 L 247.65999999999988 195.96000000000006 L 247.65999999999988 195.96000000000006 L 247.0899999999999 195.40000000000006 L 246.93999999999988 193.44000000000005 L 246.2999999999999 192.18000000000006 L 244.7099999999999 190.62000000000006 L 243.6399999999999 190.04000000000005 L 243.2699999999999 189.47000000000006 L 242.43999999999988 187.13000000000005 L 242.46999999999989 186.00000000000006 L 243.0499999999999 185.03000000000006 L 244.4999999999999 183.90000000000006 L 245.2799999999999 182.59000000000006 L 275.1799999999999 118.35000000000007 L 273.3699999999999 116.68000000000006 L 273.4999999999999 115.90000000000006 L 273.3099999999999 115.42000000000006 L 271.9199999999999 115.77000000000005 L 271.0699999999999 116.38000000000005 L 269.1999999999999 115.60000000000005 L 268.09999999999985 113.43000000000005 L 265.40999999999985 111.98000000000005 L 264.1399999999999 110.64000000000004 L 264.0599999999999 110.04000000000005 L 262.7399999999999 109.22000000000006 L 261.3699999999999 109.07000000000005 L 259.1199999999999 108.42000000000004 L 256.7399999999999 107.11000000000004 L 254.8599999999999 106.44000000000004 L 253.5099999999999 105.35000000000004 L 252.8799999999999 104.45000000000003 L 248.2999999999999 101.91000000000003 L 243.6599999999999 98.14000000000003 L 243.3599999999999 97.70000000000003 L 243.3199999999999 96.77000000000002 L 242.7699999999999 94.94000000000003 L 240.9299999999999 93.71000000000002 L 240.2299999999999 93.90000000000002 L 239.8699999999999 93.70000000000002 L 238.03999999999988 91.72000000000001 L 238.0899999999999 89.61000000000001 L 238.43999999999988 88.92000000000002 L 238.25999999999988 88.51000000000002 L 236.56999999999988 87.66000000000003 L 236.32999999999987 86.98000000000002 L 236.14999999999986 84.71000000000002 L 236.57999999999987 83.26000000000002 L 236.17999999999986 78.40000000000002 L 236.17999999999986 78.40000000000002 L 234.58999999999986 61.43000000000002 L 234.58999999999986 61.43000000000002 L 235.33999999999986 61.75000000000002 L 235.76999999999987 62.33000000000002 L 235.74999999999986 62.81000000000002 L 236.19999999999985 63.210000000000015 L 237.11999999999983 63.490000000000016 L 238.48999999999984 62.780000000000015 L 238.95999999999984 61.97000000000001 L 241.66999999999985 62.20000000000001 L 242.47999999999985 61.15000000000001 L 241.93999999999986 59.34000000000001 L 243.72999999999985 58.98000000000001 L 245.13999999999984 57.35000000000001 L 247.77999999999983 58.36000000000001 L 249.65999999999983 58.39000000000001 L 250.19999999999982 56.870000000000005 L 253.52999999999983 55.25000000000001 L 255.49999999999983 55.64000000000001 L 256.65999999999985 55.53000000000001 L 257.14999999999986 55.28000000000001 L 258.34999999999985 53.80000000000001 L 258.74999999999983 52.40000000000001 L 260.2099999999998 51.30000000000001 L 261.0699999999998 51.19000000000001 L 261.7199999999998 51.65000000000001 L 263.8299999999998 50.52000000000001 L 264.23999999999984 50.63000000000001 L 264.60999999999984 51.62000000000001 L 265.33999999999986 52.070000000000014 L 267.36999999999983 52.55000000000001 L 268.97999999999985 52.80000000000001 L 269.53999999999985 52.20000000000001 L 271.20999999999987 51.81000000000001 L 271.98999999999984 52.09000000000001 L 272.80999999999983 52.08000000000001 L 273.66999999999985 51.74000000000001 L 275.90999999999985 52.040000000000006 L 280.57999999999987 53.42000000000001 L 281.53999999999985 53.28000000000001 L 282.53999999999985 52.41000000000001 L 282.5099999999999 50.13000000000001 L 280.4399999999999 47.63000000000001 L 279.1999999999999 47.00000000000001 L 279.6899999999999 45.32000000000001 L 280.9999999999999 43.870000000000005 L 281.27999999999986 42.760000000000005 L 281.58999999999986 42.59 L 282.29999999999984 42.78 L 283.1299999999998 43.54 L 285.47999999999985 44.65 L 297.09999999999985 42.32 L 298.66999999999985 44.01 L 299.6899999999998 44.07 L 300.1299999999998 43.78 L 300.1299999999998 43.78 L 300.74999999999983 44.35 L 301.11999999999983 46.65 L 300.49999999999983 47.949999999999996 L 300.24999999999983 52.489999999999995 L 300.48999999999984 53.92999999999999 L 300.79999999999984 54.46999999999999 L 301.96999999999986 54.489999999999995 L 303.04999999999984 54.199999999999996 L 306.4399999999998 54.56999999999999 L 307.72999999999985 55.059999999999995 L 309.65999999999985 56.10999999999999 L 310.32999999999987 56.90999999999999 L 310.8199999999999 58.18999999999999 L 312.0099999999999 58.30999999999999 L 313.14999999999986 59.14999999999999 L 313.9499999999999 60.12999999999999 L 314.78999999999985 60.39999999999999 L 316.11999999999983 60.25999999999999 L 316.49999999999983 59.83999999999999 L 317.4399999999998 59.69999999999999 L 320.2799999999998 62.359999999999985 L 320.9599999999998 62.329999999999984 L 321.4499999999998 63.509999999999984 L 320.7699999999998 63.73999999999998 L 320.5799999999998 64.45999999999998 L 321.3399999999998 67.28999999999998 L 323.3599999999998 69.54999999999998 L 325.9299999999998 70.27999999999999 L 326.0999999999998 70.60999999999999 L 325.6699999999998 73.74999999999999 L 325.8599999999998 75.85999999999999 L 326.5299999999998 77.36999999999999 L 327.1499999999998 77.92999999999999 L 327.7399999999998 79.74 L 327.6099999999998 81.32 L 329.1099999999998 84.8 L 329.9299999999998 84.99 L 330.70999999999975 84.63 L 333.63999999999976 87.91 L 333.5599999999998 90.34 L 333.9699999999998 91.28 L 334.9199999999998 91.47 L 335.2499999999998 91.94 L 335.5599999999998 93.52 L 335.3499999999998 94.21 L 335.4599999999998 95.50999999999999 L 337.3299999999998 96.89999999999999 L 337.7599999999998 98.39999999999999 L 339.2099999999998 99.42999999999999 L 341.99999999999983 100.11 L 343.29999999999984 99.99 L 344.0699999999998 99.64999999999999 L 345.0099999999998 99.71 L 345.0099999999998 99.71 L 344.47999999999985 100.44999999999999 L 344.76999999999987 102.03999999999999 L 344.59999999999985 102.57 L 343.30999999999983 103.67999999999999 L 341.91999999999985 103.85 L 341.41999999999985 103.66999999999999 L 340.57999999999987 102.87999999999998 L 339.91999999999985 102.72999999999998 L 336.53999999999985 104.30999999999997 L 336.16999999999985 104.84999999999998 L 334.5699999999998 105.56999999999998 L 333.9399999999998 105.54999999999998 L 332.3899999999998 106.13999999999999 L 332.42999999999984 106.71999999999998 L 338.8899999999998 105.65999999999998 L 339.7699999999998 106.31999999999998 L 339.8999999999998 106.77999999999997 L 339.8999999999998 107.43999999999997 L 339.2799999999998 107.93999999999997 L 339.5799999999998 108.29999999999997 L 340.2099999999998 108.09999999999997 L 341.0699999999998 107.09999999999997 L 342.0899999999998 107.08999999999996 L 342.6199999999998 106.81999999999996 L 343.2199999999998 106.93999999999997 L 344.2899999999998 106.51999999999997 L 345.4299999999998 105.94999999999997 L 348.70999999999975 103.60999999999997 L 350.20999999999975 103.25999999999998 L 352.0499999999997 102.44999999999997 L 355.20999999999975 100.60999999999997 L 355.7499999999998 99.60999999999997 L 356.4199999999998 99.08999999999997 L 358.50999999999976 98.07999999999997 L 359.1699999999998 97.35999999999997 L 358.9199999999998 96.68999999999997 L 359.12999999999977 96.27999999999997 L 360.25999999999976 95.99999999999997 L 361.34999999999974 96.05999999999997 L 361.75999999999976 96.26999999999997 L 362.13999999999976 100.06999999999996 L 361.6199999999998 102.64999999999996 L 361.94999999999976 104.26999999999997 L 362.75999999999976 105.86999999999996 L 364.06999999999977 107.21999999999996 L 364.3699999999998 108.85999999999996 L 364.2499999999998 109.32999999999996 L 362.4099999999998 111.16999999999996 L 361.93999999999977 111.29999999999995 L 361.06999999999977 110.77999999999996 L 359.2499999999998 110.25999999999996 L 357.9899999999998 109.94999999999996 L 357.0599999999998 110.08999999999996 L 354.9299999999998 109.04999999999995 L 354.6699999999998 107.92999999999995 L 353.7899999999998 107.39999999999995 L 351.5099999999998 111.21999999999994 L 350.8999999999998 113.58999999999995 L 351.5799999999998 116.55999999999995 L 352.05999999999983 117.19999999999995 L 352.97999999999985 117.81999999999995 L 351.96999999999986 116.67999999999995 L 351.53999999999985 113.98999999999995 L 351.65999999999985 113.46999999999996 L 354.22999999999985 109.24999999999996 L 356.53999999999985 110.42999999999996 L 356.64999999999986 110.87999999999997 L 359.17999999999984 113.32999999999997 L 358.92999999999984 115.34999999999997 L 358.1899999999998 115.89999999999996 L 358.5899999999998 118.22999999999996 L 359.1099999999998 119.35999999999996 L 360.2299999999998 120.10999999999996 L 360.9699999999998 120.25999999999996 L 361.4899999999998 120.74999999999996 L 361.1499999999998 120.10999999999996 L 360.3799999999998 119.86999999999996 L 359.17999999999984 118.82999999999996 L 358.9599999999998 118.14999999999995 L 359.2999999999998 113.94999999999995 L 360.1199999999998 112.75999999999995 L 361.5499999999998 113.48999999999995 L 362.37999999999977 114.68999999999996 L 362.2899999999998 115.47999999999996 L 363.4899999999998 116.33999999999996 L 363.7399999999998 116.04999999999995 L 362.7399999999998 114.78999999999995 L 361.81999999999977 112.68999999999996 L 361.81999999999977 112.24999999999996 L 364.07999999999976 109.92999999999996 L 365.69999999999976 110.01999999999997 L 367.62999999999977 110.65999999999997 L 367.96999999999974 111.21999999999997 L 367.35999999999973 111.80999999999997 L 367.6799999999997 112.08999999999997 L 368.15999999999974 112.11999999999998 L 369.1899999999997 111.94999999999997 L 370.5199999999997 111.04999999999997 L 374.6099999999997 110.08999999999997 L 375.37999999999965 110.28999999999998 L 377.11999999999966 111.34999999999998 L 380.2899999999997 110.92999999999998 L 381.3599999999997 110.51999999999998 L 382.37999999999965 109.50999999999998 L 383.3599999999997 108.91999999999997 L 385.0999999999997 108.40999999999997 L 385.86999999999966 108.47999999999996 L 385.92999999999967 109.22999999999996 L 383.88999999999965 113.24999999999996 L 383.64999999999964 114.74999999999996 L 383.18999999999966 115.81999999999995 L 382.3599999999997 116.84999999999995 L 382.3499999999997 117.72999999999995 L 382.92999999999967 119.14999999999995 L 382.6099999999997 121.61999999999995 L 383.48999999999967 120.42999999999995 L 383.49999999999966 119.02999999999994 L 385.0399999999997 116.02999999999994 L 386.1699999999997 112.83999999999995 L 387.2899999999997 111.27999999999994 L 387.55999999999966 111.00999999999995 L 388.31999999999965 110.95999999999995 L 388.89999999999964 110.60999999999996 L 390.71999999999963 110.37999999999995 L 391.5999999999996 109.02999999999996 L 393.1099999999996 107.33999999999996 L 394.46999999999963 105.07999999999996 L 394.9899999999996 104.61999999999996 L 395.77999999999963 105.10999999999996 L 396.39999999999964 104.64999999999996 L 398.01999999999964 106.98999999999997 L 399.20999999999964 107.57999999999997 L 399.1599999999996 106.83999999999997 L 398.8099999999996 106.08999999999997 L 399.4299999999996 105.07999999999997 L 402.9399999999996 104.56999999999996 L 401.9099999999996 104.24999999999997 L 398.39999999999964 104.70999999999997 L 398.08999999999963 104.49999999999997 L 398.37999999999965 102.06999999999996 L 398.88999999999965 101.77999999999996 L 399.55999999999966 102.15999999999995 L 400.57999999999964 102.26999999999995 L 401.64999999999964 99.16999999999996 L 400.96999999999963 97.77999999999996 L 400.9999999999996 97.09999999999995 L 402.1699999999996 95.28999999999995 L 405.0099999999996 92.80999999999995 L 405.3699999999996 92.72999999999995 L 406.4799999999996 93.86999999999995 L 409.4099999999996 91.77999999999994 L 409.8699999999996 91.70999999999995 L 410.2699999999996 92.15999999999995 L 410.3699999999996 92.72999999999995 L 410.0499999999996 93.39999999999995 L 411.1199999999996 93.23999999999995 L 411.9299999999996 92.65999999999995 L 412.2899999999996 91.87999999999995 L 412.9199999999996 91.68999999999996 L 413.1999999999996 91.83999999999996 L 413.9399999999996 93.22999999999996 L 415.2699999999996 94.42999999999996 L 415.4699999999996 93.86999999999996 L 415.35999999999956 93.48999999999997 L 414.4 93 L 414.26 92.71 L 414.13 91.50999999999999 L 414.3 91.08999999999999 L 414.74 90.89999999999999 L 417.02 91.16 L 418.2 91.81 L 418.82 92.83 L 420.45 93.53999999999999 L 422.09999999999997 92.75999999999999 L 422.62999999999994 94.89999999999999 L 422.12999999999994 95.21 L 422.09999999999997 95.8 L 423.02 95.28 L 424.18 92.93 L 424.56 93.16000000000001 L 424.33 94.49000000000001 L 424.74 94.93 L 427.25 94.67 L 427.7 95.32000000000001 L 428.15999999999997 97.00000000000001 L 427.55999999999995 97.95000000000002 L 428.40999999999997 97.45000000000002 L 428.66999999999996 97.82000000000002 L 430.55999999999995 97.96000000000002 L 434.0899999999999 96.72000000000003 L 433.7799999999999 98.30000000000003 L 433.0299999999999 100.13000000000002 L 434.49999999999994 99.64000000000003 L 435.0899999999999 99.02000000000002 L 435.7199999999999 100.64000000000003 L 435.7199999999999 100.64000000000003 L 434.94999999999993 101.09000000000003 L 434.4799999999999 102.12000000000003 L 434.63999999999993 103.50000000000003 L 433.92999999999995 107.89000000000003 L 433.35999999999996 108.63000000000002 L 432.21999999999997 108.78000000000003 L 432.16999999999996 109.40000000000003 L 432.43999999999994 109.89000000000003 L 433.42999999999995 109.73000000000003 L 433.85999999999996 110.26000000000003 L 433.78 111.87000000000003 L 432.88 114.89000000000003 L 432.52 115.60000000000002 L 430.78 117.17000000000002 L 430.28 119.55000000000001 L 430.40999999999997 121.19000000000001 L 426.72999999999996 124.28000000000002 L 427.77 125.86000000000001 L 426.97999999999996 126.67000000000002 L 427.15999999999997 128.49 L 426.7 129.77 L 425.87 131.22 L 424.39 132.98 L 422.43 134.51999999999998 L 420.83 139.20999999999998 L 420.53999999999996 141.10999999999999 L 420.06999999999994 142.32 L 417.62999999999994 144.64 L 416.50999999999993 145.1 L 415.88999999999993 147.98 L 414.3399999999999 149.14999999999998 L 413.9099999999999 150.29999999999998 L 412.3599999999999 152.46999999999997 L 411.1899999999999 153.38999999999996 L 408.83999999999986 153.15999999999997 L 394.1299999999999 164.98999999999998 L 394.6199999999999 165.07 L 394.6199999999999 165.07 L 396.9099999999999 165.88 L 398.7799999999999 165.64 L 400.06999999999994 165.76 L 401.0899999999999 167.42 L 401.4799999999999 167.73 L 402.3499999999999 167.86999999999998 L 403.6099999999999 169.03999999999996 L 403.5699999999999 169.66999999999996 L 403.1999999999999 170.33999999999995 L 402.47999999999985 170.70999999999995 L 401.5099999999998 170.77999999999994 L 401.2199999999998 171.05999999999995 L 401.3099999999998 172.46999999999994 L 402.31999999999977 173.80999999999995 L 401.39999999999975 176.55999999999995 L 400.75999999999976 177.03999999999994 L 399.2999999999998 177.49999999999994 L 399.0499999999998 177.95999999999995 L 399.3399999999998 179.15999999999994 L 399.1499999999998 180.49999999999994 L 397.8499999999998 180.64999999999995 L 396.3399999999998 181.98999999999995 L 395.4899999999998 183.25999999999996 L 395.63999999999976 184.76999999999995 L 395.39999999999975 185.26999999999995 L 392.89999999999975 186.46999999999994 L 389.4899999999997 187.60999999999993 L 387.0199999999997 189.38999999999993 L 386.8299999999997 189.73999999999992 L 387.2599999999997 191.92999999999992 L 387.3199999999997 194.5999999999999 L 386.03999999999974 196.6999999999999 L 384.6299999999997 198.3799999999999 L 384.47999999999973 198.9499999999999 L 384.64999999999975 199.8299999999999 L 385.2399999999997 200.7899999999999 L 386.90999999999974 202.52999999999992 L 387.65999999999974 202.8499999999999 L 387.8099999999997 203.14999999999992 L 387.1499999999997 207.1899999999999 L 385.3899999999997 212.33999999999992 L 384.3099999999997 213.14999999999992 L 382.60999999999973 216.38999999999993 L 382.4299999999997 217.37999999999994 L 381.4899999999997 218.91999999999993 L 380.7499999999997 219.76999999999992 L 379.6999999999997 219.92999999999992 L 378.3299999999997 220.8499999999999 L 377.2999999999997 222.7699999999999 L 376.08999999999975 224.4499999999999 L 374.90999999999974 225.5399999999999 L 373.75999999999976 227.11999999999992 L 372.62999999999977 231.57999999999993 L 371.03 235.24 z M 392.19 104.93 L 387.67 106.89 L 384.28000000000003 107.41 L 382.26000000000005 107.1 L 381.61000000000007 108.22999999999999 L 379.7700000000001 109.41999999999999 L 379.05000000000007 108.80999999999999 L 378.44000000000005 107.27999999999999 L 378.21000000000004 107.55999999999999 L 378.63000000000005 108.78999999999999 L 378.2900000000001 109.6 L 377.5800000000001 110.00999999999999 L 373.8100000000001 108.36999999999999 L 373.0100000000001 109.08999999999999 L 368.8200000000001 110.35 L 365.6200000000001 109.78 L 364.8100000000001 109.17 L 364.5700000000001 107.32000000000001 L 364.3400000000001 106.91000000000001 L 363.2300000000001 105.89000000000001 L 362.1700000000001 104.29000000000002 L 361.9600000000001 102.51000000000002 L 362.4800000000001 99.76000000000002 L 363.1000000000001 99.38000000000002 L 364.86000000000007 99.74000000000002 L 365.7900000000001 98.99000000000002 L 365.87000000000006 98.43000000000002 L 364.57000000000005 98.86000000000003 L 363.35 98.73000000000003 L 362.41 98.02000000000004 L 362.23 96.97000000000004 L 362.57 91.89000000000004 L 363.3 91.13000000000004 L 363.65000000000003 91.88000000000004 L 365.41 92.48000000000003 L 365.96000000000004 92.42000000000003 L 365.50000000000006 92.00000000000003 L 364.2300000000001 91.78000000000003 L 363.3300000000001 89.62000000000003 L 363.6900000000001 87.94000000000003 L 364.5800000000001 85.97000000000003 L 365.9100000000001 84.64000000000003 L 366.87000000000006 84.07000000000004 L 368.21000000000004 83.58000000000004 L 369.53000000000003 83.45000000000005 L 372.99 83.97000000000004 L 380.2 85.74000000000004 L 383.9 85.28000000000004 L 384.01 84.98000000000005 L 385.15 84.36000000000004 L 387.31 83.99000000000004 L 390.2 84.28000000000004 L 393 85.10000000000004 L 399.48 85.95000000000003 L 400.11 86.42000000000003 L 400.06 87.65000000000003 L 399.36 88.39000000000003 L 398.68 89.89000000000003 L 398.32 92.54000000000003 L 397.46 95.84000000000003 L 396.16999999999996 96.52000000000004 L 395.81999999999994 97.21000000000004 L 396.04999999999995 98.40000000000003 L 394.06999999999994 100.98000000000003 L 392.67999999999995 104.48000000000003 L 392.19 104.93 z M 344.98 104.76 L 344.23 104.25 L 345.33000000000004 102 L 345.24000000000007 100.21 L 345.49000000000007 100 L 347.82000000000005 99.52 L 348.72 98.66 L 348.87 98.16 L 348.67 95.82 L 349.53000000000003 93.24 L 350.79 91.75 L 353.08000000000004 90.28 L 355.95000000000005 90.08 L 356.6700000000001 92.44 L 355.57000000000005 94.63 L 354.72 97.67 L 353.62 98.34 L 352.28000000000003 100.37 L 351.50000000000006 101.09 L 346.56000000000006 104.4 L 344.98 104.76 z M 373.46 81.86 L 372.43 81.61 L 369.98 81.69 L 369.19 81.53 L 368.9 81.27 L 368.52 80.17999999999999 L 368.53 78.94 L 370.03999999999996 78.52 L 371.92999999999995 78.56 L 374.11999999999995 77.27 L 378.92999999999995 76.67 L 379.69999999999993 76.93 L 380.37999999999994 77.61000000000001 L 380.19999999999993 78.63000000000001 L 377.63999999999993 80.02000000000001 L 375.85999999999996 82.50000000000001 L 374.76 83 L 373.46 81.86 z M 378.25 81.86 L 380.11 80.66 L 382.09000000000003 80.69 L 383.74 81.31 L 384.27 82.3 L 384.32 82.92 L 383.44 83.69 L 380.59 83.97 L 379.41999999999996 84.28999999999999 L 377.15999999999997 83.39999999999999 L 376.96 82.86999999999999 L 378.25 81.86 z M 361.27 86.25 L 360.77 85.99 L 360.15999999999997 86.03 L 358.61999999999995 85.34 L 358.8299999999999 84.18 L 359.4699999999999 83.26 L 361.38999999999993 82.86 L 363.74999999999994 81.96 L 365.06999999999994 82.03999999999999 L 365.86999999999995 82.72 L 365.9599999999999 82.85 L 364.0299999999999 84.46 L 362.9599999999999 84.8 L 361.27 86.25 z M 370.69 76.56 L 369.87 76.26 L 369.7 74.60000000000001 L 369.84999999999997 74.00000000000001 L 371.02 72.69000000000001 L 373.46999999999997 71.77000000000001 L 373.71999999999997 71.89000000000001 L 374.24999999999994 72.57000000000002 L 374.28999999999996 73.46000000000002 L 372.34 75.45000000000002 L 370.69 76.56 z M 356.86 96.78 L 356.72 96.37 L 356.91 95.44 L 357.95000000000005 92.63 L 360.54 90.94 L 361.26000000000005 90.66 L 361.95000000000005 90.8 L 361.79 92.59 L 360.23 93.03 L 358.61 95.22 L 356.86 96.78 z M 367.77 79.21 L 366.58 78.89999999999999 L 366.28 78.41999999999999 L 367.15999999999997 77.46 L 367.86999999999995 73.50999999999999 L 368.75999999999993 72.27999999999999 L 369.04999999999995 72.40999999999998 L 369.11999999999995 72.72999999999998 L 369.09999999999997 75.20999999999998 L 369.7 77.07999999999998 L 369.38 77.95999999999998 L 368.35 78.35999999999999 L 367.77 79.21 z M 352.96 89.4 L 352.69 89.21000000000001 L 352.81 88.60000000000001 L 353.36 88.24000000000001 L 354.55 86.53000000000002 L 355.31 84.99000000000001 L 356.04 84.33000000000001 L 357.49 83.79 L 357.29 85.28 L 356.89000000000004 86.28 L 355.17 87.94 L 352.96 89.4 z M 366.83 82.37 L 366.22999999999996 82.22 L 365.39 81.51 L 364.43 79.87 L 364.38 79.49000000000001 L 364.61 79.2 L 365.42 78.62 L 367.27000000000004 79.46000000000001 L 367.56000000000006 79.89000000000001 L 367.80000000000007 81.98000000000002 L 366.83 82.37 z M 361.45 112.93 L 360.8 112.82000000000001 L 359.92 112.30000000000001 L 359.23 112.76 L 358.48 112.48 L 356.8 110.74000000000001 L 356.8 110.13000000000001 L 358.08 110.12 L 361.14 111.44 L 361.45 112.93 z M 340.3 107.39 L 340.34000000000003 106.36 L 340.14000000000004 106.06 L 340.74000000000007 105.07000000000001 L 343.1000000000001 104.19000000000001 L 343.88000000000005 104.57000000000001 L 344.75000000000006 105.43 L 344.46000000000004 105.78 L 343.43000000000006 106.25 L 340.89000000000004 106.66 L 340.3 107.39 z M 353 100.7 L 352.82 100.67 L 352.83 100.32000000000001 L 353.37 99.38000000000001 L 355.16 97.76 L 355.58000000000004 96.52000000000001 L 355.63000000000005 95.22000000000001 L 355.87000000000006 94.92000000000002 L 356.19000000000005 95.36000000000001 L 356.19000000000005 96.87000000000002 L 355.30000000000007 99.60000000000002 L 354.68000000000006 100.25000000000003 L 353 100.7 z M 359.3 90.8 L 360.95 87.84 L 361.83 87.63000000000001 L 362.53999999999996 87.82000000000001 L 362.80999999999995 88.69000000000001 L 362.22999999999996 89.4 L 359.3 90.8 z M 390.72 109.77 L 389.88000000000005 109.42 L 389.5400000000001 108.36 L 390.5800000000001 106.64 L 391.6500000000001 106.31 L 391.8400000000001 106.41 L 391.8200000000001 107.14999999999999 L 391.0800000000001 109.38999999999999 L 390.72 109.77 z M 357.24 90.3 L 356.7 90.1 L 357.02 88.05999999999999 L 358.34999999999997 86.24999999999999 L 358.58 86.28999999999999 L 359.87 87.16999999999999 L 359.86 87.41999999999999 L 358.31 88.05999999999999 L 357.24 90.3 z M 359.47 95.33 L 360.19000000000005 95.36 L 359.7900000000001 95.81 L 358.8500000000001 96.12 L 358.74000000000007 97.24000000000001 L 357.95000000000005 97.95 L 356.26000000000005 98.79 L 356.1 98.61 L 356.37 97.78 L 356.84000000000003 97.15 L 358.57000000000005 95.48 L 359.47 95.33 z M 336.91 105.54 L 336.36 105.35000000000001 L 336.29 105.00000000000001 L 336.72 104.60000000000001 L 340.28000000000003 103.00000000000001 L 340.82000000000005 103.70000000000002 L 340.81000000000006 103.90000000000002 L 339.4100000000001 104.63000000000002 L 336.91 105.54 z M 400.44 100.76 L 399.41 100.57000000000001 L 398.59000000000003 99.78 L 399.46000000000004 98.53 L 400.8 98.52 L 400.99 99.71 L 400.89 100.3 L 400.44 100.76 z M 363.19 81.86 L 360.83 82.56 L 360.24 82.57000000000001 L 360.06 82.36000000000001 L 361.09 81.32000000000001 L 362.13 80.81 L 363.17 80.98 L 363.61 81.32000000000001 L 363.76 81.55000000000001 L 363.61 81.76 L 363.19 81.86 z M 357.92 90.45 L 357.84000000000003 89.69 L 358.09000000000003 89.19 L 360.57000000000005 87.73 L 359.6700000000001 89.73 L 358.86000000000007 90.36 L 357.92 90.45 z M 360.06 94.98 L 359.61 94.86 L 359.54 94.63 L 360.32 93.13 L 361.51 93.14999999999999 L 361.39 94.49999999999999 L 360.06 94.98 z M 388.1 110.81 L 387.82000000000005 110.58 L 388.72 108.98 L 389.40000000000003 108.58 L 389.63000000000005 109.33 L 390.14000000000004 109.7 L 389.88000000000005 110.22 L 389.45000000000005 110.56 L 388.82000000000005 110.38 L 388.1 110.81 z M 361.44 87.49 L 360.55 87.42 L 360.57 87.23 L 362.93 85.39 L 362.97 86.35 L 362.74 86.97999999999999 L 362.49 87.32 L 361.44 87.49 z M 428.9 97.71 L 428.52 97.17999999999999 L 428.71 96.41999999999999 L 429.72999999999996 95.50999999999999 L 429.97999999999996 95.66 L 430.21 97.41 L 428.9 97.71 z"},{code:"PB",name:"Paraíba",gTransform:"matrix(1 0 0 1 275.13 -126.21)",pathTransform:"translate(-581.13, -193.05)",d:"M 610.43 199.15 L 607.93 197.09 L 607.11 196.83 L 604.46 196.62 L 602.15 197.69 L 600.67 198.97 L 600.22 200.77 L 598.32 201.8 L 596.31 202.25 L 595.17 202.23 L 595.17 202.83 L 594.37 203.36 L 592.19 203.65 L 588.31 203.39 L 586.7 204.27 L 586.15 204.91 L 584.33 205.01 L 583.44 205.7 L 582.9 206.46 L 583.29 207.19 L 583.3 207.73 L 582.9 208.21 L 581.12 209.74 L 579.78 209.9 L 578.13 210.74 L 576.53 209.95 L 575.58 209.01 L 575.23 206.77 L 575.47 206.28 L 575.29 205.98 L 574.15 205.66 L 573.71 205.95 L 572.2 206.2 L 572.24 205.75 L 574.77 203.11 L 574.94 202.68 L 574.22 200.81 L 574.18 200.34 L 574.55 199.56 L 577.55 198.49 L 577.66 198.19 L 577.16 196.8 L 573.66 194.88 L 572.18 195.29 L 569.96 196.55 L 569.03 198.06 L 567.55 198.93 L 566.5 199.24 L 563.8 201.12 L 562.28 202.76 L 560.65 202.99 L 558.02 203.96 L 557.25 203.63 L 557.3 202.95 L 556.67 201.71 L 556.29 201.63 L 555.36 202.36 L 553.85 202.68 L 552.86 202.35 L 551.46 200.44 L 551.06 200.35 L 551.06 200.35 L 550.89 200.1 L 552.08 198.98 L 553.69 195.49 L 553.35 194.3 L 552.66 194.22 L 551.42 193.33 L 551.44 191.67 L 551.09 190.95 L 550.51 190.66 L 550.27 190.25 L 550.39 189.32 L 550.56 188.94 L 551.65 188.31 L 552.31 187 L 551.79 185.69 L 552.82 182.69 L 553.66 181.54 L 553.74 181 L 553.74 181 L 554.31 180.54 L 556.24 182.18 L 557.14 182.6 L 560.02 183.21 L 561.18 182.08 L 564.41 180.42 L 565.23 179.71 L 565.33 178.67 L 565.74 177.72 L 568.92 176.51 L 570.35 176.39 L 573.61 175.35 L 574.25 175.43 L 574.78 175.87 L 574.79 177.06 L 571.8 180.27 L 571.36 181.23 L 570.98 182.97 L 570.57 183.35 L 569.72 183.6 L 569.51 183.91 L 569.43 185.63 L 572.96 186.15 L 573.28 186.38 L 573.59 187.76 L 573.88 187.99 L 577.03 186.73 L 578.8 186.65 L 580.75 186.95 L 581.64 188.12 L 581.12 189.66 L 581.95 190.4 L 584.3 189.47 L 584.8 188.73 L 585.35 187.52 L 584.88 186.58 L 584.72 185.16 L 585.2 184.57 L 586.21 184.89 L 585.68 183.36 L 584.96 182.58 L 585.27 181.1 L 587.09 179.75 L 588.47 179.7 L 588.89 180.09 L 588.79 181.09 L 589.41 181.58 L 592.83 181.98 L 593.36 182.33 L 599.19 181.94 L 601.36 182.24 L 603.82 183.34 L 604.86 182.94 L 608.36 183.15 L 609.29 182.91 L 609.29 182.91 L 609.38 185.31 L 610.83 189.7 L 610.89 190.34 L 610.71 191.28 L 610.34 191.73 L 610.31 192.61 L 610.89 191.87 L 611.4 190.37 L 611.41 192.35 L 612 193.36 L 611.73 198.54 L 611.37 199.14 z"},{code:"PE",name:"Pernambuco",gTransform:"matrix(1 0 0 1 254.6 -106.99)",pathTransform:"translate(-560.6, -212.26)",d:"M 558.28 227.19 L 557.06 224.15 L 557.05 223.21 L 554.94 222.35 L 554.44 221.98 L 553.99 221.15 L 554.6 220.26 L 554.58 219.64 L 554.13 219.32 L 553.13 219.33 L 552.7 219.77 L 552.41 221.51 L 551.98 221.66 L 551.59 221.4 L 551.05 219.75 L 549.47 218.6 L 546.48 218.2 L 544.12 217.43 L 542.77 216.62 L 541.94 215.18 L 540.45 214.62 L 539.86 214.73 L 537.33 216.19 L 535.68 216.63 L 534.91 218.68 L 532.68 219.13 L 532.39 219.38 L 532.64 220.74 L 532.47 221.33 L 531.37 222.57 L 528.98 223.6 L 528.34 223.54 L 527.57 223.01 L 526.81 223.18 L 526.31 224.05 L 525.54 227.62 L 522.67 228.5 L 521.85 229.42 L 520.89 229.65 L 519.05 229.03 L 519.97 227.35 L 519.71 225.35 L 517.5 224.44 L 516.78 222.5 L 516.84 219.77 L 516.4 219.26 L 513.59 217.88 L 511.39 217.59 L 510.23 217.85 L 509.33 217.45 L 509.33 217.45 L 511.95 216.18 L 513.92 214.47 L 514.46 213.6 L 516.75 212.27 L 517.72 211.99 L 521.61 208.12 L 522.35 206.36 L 522.41 204.09 L 522.12 203.55 L 520.5 201.97 L 520.57 199.78 L 519.97 198.65 L 519.91 197.7 L 520.02 197.25 L 520.54 196.92 L 522.33 196.76 L 522.33 196.76 L 527.26 196.96 L 528.15 197.2 L 529.78 197.01 L 531.92 196.21 L 533.21 196.11 L 536.29 196.53 L 539.14 198.43 L 540.97 199.26 L 541.43 200.25 L 542.44 201.32 L 543.8 201.8 L 544.58 202.37 L 545.21 204.01 L 546.86 203.96 L 548.4 201.67 L 549.47 200.84 L 551.06 200.35 L 551.06 200.35 L 551.46 200.44 L 552.86 202.35 L 553.85 202.68 L 555.36 202.36 L 556.29 201.63 L 556.67 201.71 L 557.3 202.95 L 557.25 203.63 L 558.02 203.96 L 560.65 202.99 L 562.28 202.76 L 563.8 201.12 L 566.5 199.24 L 567.55 198.93 L 569.03 198.06 L 569.96 196.55 L 572.18 195.29 L 573.66 194.88 L 577.16 196.8 L 577.66 198.19 L 577.55 198.49 L 574.55 199.56 L 574.18 200.34 L 574.22 200.81 L 574.94 202.68 L 574.77 203.11 L 572.24 205.75 L 572.2 206.2 L 573.71 205.95 L 574.15 205.66 L 575.29 205.98 L 575.47 206.28 L 575.23 206.77 L 575.58 209.01 L 576.53 209.95 L 578.13 210.74 L 579.78 209.9 L 581.12 209.74 L 582.9 208.21 L 583.3 207.73 L 583.29 207.19 L 582.9 206.46 L 583.44 205.7 L 584.33 205.01 L 586.15 204.91 L 586.7 204.27 L 588.31 203.39 L 592.19 203.65 L 594.37 203.36 L 595.17 202.83 L 595.17 202.23 L 596.31 202.25 L 598.32 201.8 L 600.22 200.77 L 600.67 198.97 L 602.15 197.69 L 604.46 196.62 L 607.11 196.83 L 607.93 197.09 L 610.43 199.15 L 610.43 199.15 L 611.31 199.38 L 611.86 200.6 L 610.59 202.32 L 610.48 202.87 L 610.49 203.35 L 611.19 203.72 L 611.46 204.22 L 611.65 205.28 L 609.69 211.66 L 606.44 220.61 L 606.44 220.61 L 606.17 220.4 L 603.27 220.13 L 601.35 219.32 L 599.88 219.51 L 597.32 220.8 L 595.08 219.95 L 593.08 220.19 L 591.53 221.43 L 591.41 221.88 L 589.23 224.17 L 587.42 225.28 L 586.26 225.23 L 584.4 226.29 L 583.23 226.4 L 580.09 226.11 L 577.59 226.76 L 575.68 226.28 L 573.9 225.23 L 572 223.11 L 569.45 221.09 L 568.37 221.21 L 566.7 220.91 L 565.7 219.69 L 564.88 220.29 L 564.79 220.98 L 562.41 224.27 L 560.24 225.03 L 559.6 226.12 z"},{code:"PI",name:"Piauí",gTransform:"matrix(1 0 0 1 174.84 -130.97)",pathTransform:"translate(-480.85, -188.29)",d:"M 505.7 126.91 L 507.01 127.03 L 507.7 126.8 L 509.94 127.31 L 510.93 128.16 L 511.25 128.76 L 511.25 128.76 L 511.14 129.56 L 510.05 131.41 L 508.47 133.38 L 508.29 134.84 L 508.58 136.13 L 510.38 140.85 L 513.53 147.27 L 513.97 149 L 515.33 150.59 L 515.31 151.35 L 514.57 152.71 L 515.36 156.58 L 514.88 158.18 L 515.88 160.19 L 516.48 163.18 L 515.89 164.76 L 515.09 165.34 L 516.01 166.03 L 516.12 166.41 L 517.06 174.57 L 516.82 175.02 L 517.58 177.59 L 518.63 182.79 L 519.64 185.46 L 520.95 186.11 L 523.51 186.58 L 524.28 187.74 L 524.27 188.43 L 522.77 190.68 L 521.63 193.79 L 521.71 194.76 L 522.39 195.44 L 522.33 196.76 L 522.33 196.76 L 520.54 196.92 L 520.02 197.25 L 519.91 197.7 L 519.97 198.65 L 520.57 199.78 L 520.5 201.97 L 522.12 203.55 L 522.41 204.09 L 522.35 206.36 L 521.61 208.12 L 517.72 211.99 L 516.75 212.27 L 514.46 213.6 L 513.92 214.47 L 511.95 216.18 L 509.33 217.45 L 509.33 217.45 L 508.88 218.61 L 507.38 220.91 L 506.33 221.58 L 505.54 221.4 L 503.54 221.78 L 503.65 224.18 L 501.79 225.98 L 501.47 225.93 L 500.85 225.31 L 498.69 225.3 L 497.87 226.28 L 497.1 226.64 L 494.37 226.98 L 492.86 228.32 L 492.04 229.54 L 490.34 229.64 L 488.86 230.28 L 485.86 230.39 L 485.04 230.11 L 484.85 229.83 L 484.98 229.17 L 483.27 228.19 L 481.94 227.8 L 480.55 228.35 L 478.42 228.78 L 478.1 228.6 L 477.69 227.67 L 476.19 227.21 L 474.24 227.23 L 471 228.88 L 470.94 229.81 L 473.18 234.25 L 473.3 235.4 L 473.01 237.97 L 472.76 238.88 L 472.04 239.74 L 469.09 244.79 L 466.12 247.21 L 464.77 247.63 L 463.29 247.1 L 461.95 246.93 L 459.75 247.68 L 458.58 248.57 L 457.91 249.44 L 456.77 249.82 L 456.02 251.27 L 455.69 251.48 L 453.58 251.3 L 451.78 251.82 L 447.6 249.97 L 445.83 247.48 L 445.3 245.27 L 444.64 244.23 L 443.2 242.89 L 440.87 242.91 L 440.87 242.91 L 437.93 242.7 L 437.93 242.7 L 437.98 240.78 L 438.24 239.72 L 439.39 237.27 L 439.52 230.91 L 440.28 229.51 L 440.31 229 L 438.58 225.94 L 438.11 222.75 L 437.41 220.81 L 438.14 218.81 L 439.84 217.41 L 441.04 214.93 L 441.17 213.42 L 441.51 212.59 L 441.81 212.38 L 443.25 209.64 L 443.88 207.32 L 444.27 204.35 L 445.25 201.37 L 447.38 199.42 L 450.1 198.66 L 452.71 198.35 L 453.78 197.98 L 455.48 196.45 L 456.53 196.41 L 457.87 195.89 L 460.73 193.32 L 463.07 192.41 L 465.08 190.41 L 465.71 189.54 L 465.71 189.08 L 467.61 187.16 L 468.11 186.94 L 468.95 186.7 L 469.18 187 L 470.3 186.74 L 471.3 186.14 L 472.76 185.95 L 473.77 186.16 L 476.28 187.98 L 477.79 187.88 L 480.23 187.02 L 481.06 186.98 L 481.71 187.26 L 483.99 186.97 L 485.2 185.66 L 485.7 184.2 L 485.82 182.99 L 486.11 182.55 L 486.5 180.35 L 486.37 179.5 L 486.2 179 L 484.59 178.09 L 482.81 176.06 L 482.3 173.76 L 482.19 171.65 L 482.36 169.17 L 486.46 164.74 L 486.67 164.19 L 486.77 161.76 L 486.22 158.78 L 484.64 155.98 L 485.78 153.11 L 486.06 151.64 L 485.68 150.37 L 484.45 149.53 L 484.1 147.61 L 484.87 146.56 L 485.51 146.39 L 486.33 144.41 L 488.22 142.56 L 489.1 140.73 L 489.06 138.94 L 491.98 135.53 L 492.79 135.69 L 496.1 135.23 L 500.23 131.26 L 502.02 128.99 L 502.41 127.46 L 501.77 126.93 L 501.55 126.21 L 502.01 124.77 L 502.01 124.77 L 502.74 124.89 L 504.21 125.76 L 504.72 126.27 L 504.59 126.58 z"},{code:"PR",name:"Paraná",gTransform:"matrix(1 0 0 1 47.59 157)",pathTransform:"translate(-353.59, -476.27)",d:"M 396.75 499.4 L 391.51 499.37 L 391.18 499.81 L 389.44 500.05 L 388.68 499.98 L 388.57 499.59 L 387 500.16 L 385.65 501.59 L 382.3 503.72 L 380.86 503.56 L 379.63 502.94 L 376.5 500.34 L 375.47 499.95 L 374.71 499.94 L 371.87 500.67 L 369.54 500.84 L 368.73 500.81 L 367.31 500.05 L 366.2 500.19 L 364.67 500.84 L 364.08 502.31 L 363.35 503.18 L 361.48 504.16 L 357.91 503.75 L 355.91 504.9 L 355.19 505.67 L 354.5 507.26 L 355.35 510.25 L 354.48 511.11 L 353.56 511.13 L 352.81 511.51 L 352.64 512 L 351.31 510.11 L 347.06 510.24 L 343.3 509.81 L 341.72 508.63 L 341.56 508.22 L 340.53 507.59 L 336.27 507.23 L 330.98 505.55 L 328.64 506.12 L 325.95 506.09 L 323.93 504.68 L 323.61 504.17 L 322.55 503.93 L 322.02 503.92 L 321.31 504.29 L 317.68 504.27 L 317.68 504.27 L 317.46 503.06 L 314.93 498.88 L 314.95 496.29 L 313.96 493.41 L 310.54 491.04 L 309.45 492.17 L 307.33 492.06 L 306.23 492.49 L 305.16 493.39 L 303.7 492.31 L 302.88 492.37 L 302.6 490.17 L 303.26 488.6 L 304.33 487.33 L 305.55 485.15 L 305.61 484.81 L 305.12 484.06 L 305.14 482.82 L 306.04 479.18 L 307.3 476.16 L 307.05 473.86 L 308.33 471.48 L 308.12 470.46 L 307.28 469.58 L 306.97 467.98 L 307.63 466.92 L 308.42 466.38 L 308.42 466.38 L 310.8 464.82 L 311.16 464 L 312.73 456.08 L 313.06 455.73 L 314.17 455.41 L 315.83 454.4 L 316.5 453.72 L 317.95 450.16 L 317.93 449.01 L 318.86 446.68 L 319.97 445.86 L 325.38 443.59 L 325.38 443.59 L 328.64 441.3 L 332.47 441.95 L 336.48 441.84 L 339.75 442.13 L 340.96 441.51 L 341.31 440.91 L 342.04 440.54 L 343.21 440.83 L 344.69 441.61 L 347.21 442.07 L 349.85 443.16 L 351.16 443.29 L 352.23 442.75 L 354.81 442.74 L 355.59 443.74 L 357.34 444.58 L 360.85 445.38 L 361.48 445.89 L 362.19 447.21 L 363.92 447.28 L 364.34 446.94 L 365.99 447.09 L 366.65 447.63 L 371.96 447.76 L 374.93 446.91 L 376.06 448.46 L 379.65 451.29 L 380.54 453.05 L 380.55 455.79 L 380.16 456.37 L 380 457.18 L 380.38 459.02 L 381.68 460.53 L 381.6 462.29 L 381.24 462.85 L 382.73 465.85 L 383.94 467 L 384.61 467.28 L 385.11 467.96 L 385.06 468.85 L 385.98 470.82 L 386.58 471.11 L 386.83 471.55 L 386.58 472.6 L 385.31 474.73 L 385.63 476.77 L 386.23 477.15 L 387.24 477.36 L 389.62 477.24 L 393.04 476.71 L 393.54 477.1 L 395.12 476.91 L 396.71 477.04 L 398.32 478.3 L 398.18 478.71 L 397.29 479.36 L 396.6 482.66 L 396.95 483.44 L 398.02 483.97 L 398.67 483.12 L 399.77 480.36 L 400.53 480.19 L 402.67 480.77 L 402.27 482.72 L 403 486.02 L 404.42 486.6 L 404.58 487.92 L 404.58 487.92 L 403.23 488.94 L 402.62 490.42 L 402.07 490.3 L 402.34 488.36 L 403.78 487.41 L 402.37 487.69 L 401.48 488.18 L 400.61 488.16 L 400.27 487.77 L 399.7 487.6 L 399.16 487.97 L 398.88 488.9 L 399.4 489.7 L 398.67 490.66 L 398.37 490.76 L 395.89 490.23 L 395.1 489.69 L 394.65 489.81 L 394.47 490.71 L 394.81 491.08 L 396.42 491.64 L 397.82 491.39 L 399.95 491.99 L 400.22 492.47 L 399.25 493.15 L 397.71 495.93 L 396.47 496.7 L 394.05 497.27 L 393.85 497.72 L 396.8 497.52 L 396.95 498.71 z"},{code:"RJ",name:"Rio de Janeiro",gTransform:"matrix(1 0 0 1 179.27 113.69)",pathTransform:"translate(-485.28, -432.95)",d:"M 468.35 450.28 L 468.28000000000003 449.5 L 468.66 449.23 L 471.85 449.45000000000005 L 474.44 448.86000000000007 L 471.91 447.31000000000006 L 470.51000000000005 446.81000000000006 L 467.70000000000005 447.49000000000007 L 466.34000000000003 449.0900000000001 L 465.31000000000006 449.4100000000001 L 464.61000000000007 449.36000000000007 L 463.26000000000005 447.2100000000001 L 462.78000000000003 447.2100000000001 L 461.88000000000005 447.6300000000001 L 460.9200000000001 448.6900000000001 L 457.7700000000001 449.4900000000001 L 457.4300000000001 450.40000000000015 L 457.2400000000001 452.3000000000001 L 459.4300000000001 452.4300000000001 L 460.5000000000001 453.4400000000001 L 459.35000000000014 454.5200000000001 L 458.41000000000014 454.3500000000001 L 456.9900000000001 454.5200000000001 L 456.9900000000001 454.5200000000001 L 456.5100000000001 454.2600000000001 L 454.8800000000001 452.5300000000001 L 454.8300000000001 452.12000000000006 L 455.9200000000001 448.62000000000006 L 457.01000000000005 447.4700000000001 L 459.36000000000007 446.4600000000001 L 459.86000000000007 446.61000000000007 L 462.63000000000005 446.25000000000006 L 464.13000000000005 445.5400000000001 L 465.78000000000003 443.3900000000001 L 465.03000000000003 441.7500000000001 L 463.33000000000004 441.7400000000001 L 460.18000000000006 442.2700000000001 L 458.4100000000001 441.8800000000001 L 457.18000000000006 440.29000000000013 L 456.62000000000006 439.1200000000001 L 455.3500000000001 438.5800000000001 L 455.3500000000001 438.5800000000001 L 456.0300000000001 438.0900000000001 L 458.4500000000001 437.3500000000001 L 461.3600000000001 436.0100000000001 L 463.9400000000001 435.8400000000001 L 464.4400000000001 436.11000000000007 L 466.16000000000014 435.3400000000001 L 467.21000000000015 434.5700000000001 L 471.3000000000001 432.7800000000001 L 471.8200000000001 432.7100000000001 L 472.1800000000001 433.0200000000001 L 475.3800000000001 432.9500000000001 L 476.6300000000001 432.7800000000001 L 478.2600000000001 431.8400000000001 L 478.8300000000001 431.7800000000001 L 481.36000000000007 432.05000000000007 L 481.8500000000001 432.2200000000001 L 481.8300000000001 432.6900000000001 L 483.2100000000001 432.4900000000001 L 492.7200000000001 427.96000000000015 L 495.25000000000006 426.97000000000014 L 495.46000000000004 426.45000000000016 L 495.18000000000006 425.84000000000015 L 493.74000000000007 425.71000000000015 L 493.83000000000004 424.96000000000015 L 495.72 421.25000000000017 L 498.08000000000004 415.21000000000015 L 497.35 414.50000000000017 L 497.91 414.01000000000016 L 499.15000000000003 413.7400000000002 L 501.68 411.38000000000017 L 501.68 411.38000000000017 L 503.61 412.14000000000016 L 504.28000000000003 416.85000000000014 L 506.78000000000003 417.98000000000013 L 511.11 418.9900000000001 L 514.1 418.6200000000001 L 515.72 419.6800000000001 L 515.72 419.6800000000001 L 515.64 420.9500000000001 L 514.6999999999999 422.5600000000001 L 514.4799999999999 424.6900000000001 L 515.6199999999999 431.4700000000001 L 515.1199999999999 432.1500000000001 L 512.0399999999998 433.9000000000001 L 506.0699999999998 435.8400000000001 L 503.23999999999984 437.5600000000001 L 499.73999999999984 441.2500000000001 L 499.6299999999998 442.91000000000014 L 499.9399999999998 444.10000000000014 L 499.74999999999983 445.72000000000014 L 499.0199999999998 447.20000000000016 L 497.1999999999998 447.71000000000015 L 490.6499999999998 447.54000000000013 L 484.8599999999998 448.2400000000001 L 482.4699999999998 447.78000000000014 L 481.9799999999998 447.40000000000015 L 481.9199999999998 446.72000000000014 L 482.94999999999976 445.2400000000001 L 483.6199999999998 443.79000000000013 L 483.5299999999998 443.17000000000013 L 482.74999999999983 442.9900000000001 L 479.9599999999998 444.1400000000001 L 479.6999999999998 444.8300000000001 L 480.0099999999998 445.6200000000001 L 481.3899999999998 446.79000000000013 L 481.6399999999998 447.76000000000016 L 481.04999999999984 448.28000000000014 L 479.41999999999985 448.79000000000013 L 477.84999999999985 448.76000000000016 L 469.80999999999983 449.83000000000015 L 468.35 450.28 z M 463.24 452.27 L 462.57 451.29999999999995 L 464.68 449.74999999999994 L 466.54 450.68999999999994 L 466.97 451.38999999999993 L 464.51000000000005 451.88999999999993 L 464.1 451.5399999999999 L 463.63 451.5399999999999 L 463.24 452.27 z"},{code:"RN",name:"Rio Grande do Norte",gTransform:"matrix(1 0 0 1 274.86 -145.63)",pathTransform:"translate(-580.87, -173.63)",d:"M 609.29 182.91 L 608.36 183.15 L 604.86 182.94 L 603.82 183.34 L 601.36 182.24 L 599.19 181.94 L 593.36 182.33 L 592.83 181.98 L 589.41 181.58 L 588.79 181.09 L 588.89 180.09 L 588.47 179.7 L 587.09 179.75 L 585.27 181.1 L 584.96 182.58 L 585.68 183.36 L 586.21 184.89 L 585.2 184.57 L 584.72 185.16 L 584.88 186.58 L 585.35 187.52 L 584.8 188.73 L 584.3 189.47 L 581.95 190.4 L 581.12 189.66 L 581.64 188.12 L 580.75 186.95 L 578.8 186.65 L 577.03 186.73 L 573.88 187.99 L 573.59 187.76 L 573.28 186.38 L 572.96 186.15 L 569.43 185.63 L 569.51 183.91 L 569.72 183.6 L 570.57 183.35 L 570.98 182.97 L 571.36 181.23 L 571.8 180.27 L 574.79 177.06 L 574.78 175.87 L 574.25 175.43 L 573.61 175.35 L 570.35 176.39 L 568.92 176.51 L 565.74 177.72 L 565.33 178.67 L 565.23 179.71 L 564.41 180.42 L 561.18 182.08 L 560.02 183.21 L 557.14 182.6 L 556.24 182.18 L 554.31 180.54 L 553.74 181 L 553.74 181 L 553.08 181.38 L 552.44 181.21 L 552.78 179.24 L 554.19 176.99 L 555.03 176.11 L 555.54 176.04 L 556.32 176.55 L 557.35 176.29 L 557.92 175.19 L 559.38 173.68 L 560.78 171.24 L 560.63 170.5 L 561.28 168.83 L 562.15 168.26 L 562.99 167.14 L 566.29 160.45 L 568.9 158.44 L 573.79 156.85 L 573.79 156.85 L 574.26 157.61 L 575.12 158.36 L 578.25 158.35 L 579.47 158.76 L 581.16 160.51 L 582.48 161.01 L 585.81 160.69 L 588.69 161.21 L 591.23 160.97 L 593.56 160.24 L 598.06 161.16 L 599.33 161.2 L 601.28 162.06 L 602.3 162.88 L 602.94 163.82 L 605.25 168.56 L 605.75 170.35 L 605.71 171.1 L 607.19 176.48 L 607.4 178.16 L 608.12 178.7 L 609.08 181.39 z"},{code:"RO",name:"Rondônia",gTransform:"matrix(1 0 0 1 -139.57 -68.08)",pathTransform:"translate(-166.43, -251.18)",d:"M 187.32 290.95 L 186.03 289.5 L 185.59 287.62 L 184.03 287.1 L 183.17 287.42 L 181.36 287.5 L 177.29 285.69 L 177.28 285.29 L 176.62 284.68 L 175.35 285.27 L 173.37 283.59 L 171.85 282.62 L 170.99 281.16 L 170.71 279.77 L 169.67 279.38 L 167.9 280.5 L 166.68 280.47 L 165.27 279.67 L 164.4 278.34 L 161.27 276.76 L 159.31 276.59 L 158.17 277.13 L 157.27 277.98 L 155.84 277.81 L 155.53 277.51 L 153.39 277 L 150.33 276.72 L 149.57 276.29 L 148.39 275.1 L 148.09 273.13 L 146.51 272.64 L 144.62 271.67 L 143.8 269.95 L 143.51 269.75 L 140.79 269.47 L 140.41 269.12 L 139.57 265.41 L 138.69 264.52 L 138.21 265.68 L 137.55 265.36 L 137.28 264.72 L 137.9 263.19 L 137.06 261.67 L 135.7 261.28 L 134.44 257.81 L 134.27 256.15 L 135.82 253.24 L 135.61 251.58 L 134.45 249.61 L 133.7 247.45 L 133.64 245.16 L 134.26 244.66 L 134.64 243.29 L 135.68 242.24 L 136.04 240.77 L 135.8 239.28 L 135.38 238.39 L 135.29 236.86 L 135.83 235.21 L 134.66 233.03 L 133.64 232.65 L 132.55 233.63 L 132.49 234.14 L 131.65 235.1 L 131.08 235.1 L 128.9 234.08 L 123.72 234.16 L 118.11 235.94 L 116.42 235.93 L 114.94 236.41 L 114.94 236.41 L 111.97 235.15 L 111.97 235.15 L 115.23 232.59 L 117.15 232.01 L 118.7 230.2 L 118.85 229.64 L 118.69 228.35 L 122.65 228.61 L 125.52 228.28 L 126.24 228.65 L 128.55 230.98 L 128.92 230.96 L 130.14 230.17 L 130.27 229.45 L 130.68 228.92 L 131.76 228.42 L 132.53 228.55 L 133.9 228.16 L 135.2 226.95 L 137.04 225.93 L 137.42 226.02 L 138.06 228.28 L 138.74 228.81 L 139.42 228.73 L 141.96 225.57 L 141.7 223.82 L 142.23 222.98 L 143.98 221.72 L 144.44 221.74 L 145.28 222.29 L 147.07 222.39 L 148.27 221.32 L 150.4 220.94 L 154.27 221.4 L 154.03 219.94 L 154.14 218.13 L 156.2 216.92 L 157.01 215.77 L 157.37 214.75 L 157.2 214.3 L 156.3 213.6 L 156.35 212.93 L 157.54 211.34 L 160.02 210.81 L 160.28 210.59 L 160.19 209.42 L 161.91 208.92 L 163.29 206.36 L 174.08 206.3 L 176.23 207.43 L 176.68 207.92 L 177.48 209.83 L 178.81 211.1 L 181.35 212.08 L 182.6 215.35 L 183.06 215.56 L 184.04 215.43 L 184.66 215.63 L 185.34 218.51 L 188.58 219.99 L 189.26 219.8 L 189.8 218.06 L 191.72 216.98 L 193.11 217.26 L 193.47 217.64 L 193.43 218.34 L 193.43 218.34 L 194.83 219.31 L 195.43 220.55 L 194.67 221.97 L 193.38 226.96 L 193.44 227.31 L 194.22 227.78 L 194.48 228.39 L 194.63 229.78 L 195.46 232.05 L 194.52 233.72 L 194.9 235.65 L 193.9 239.17 L 193.87 239.97 L 194.14 241.73 L 195.64 244.48 L 194.74 253.48 L 211.9 253.53 L 211.66 254.09 L 212.88 255.2 L 216.38 255.11 L 217.49 255.22 L 218.56 255.65 L 219.97 259.24 L 219.8 259.99 L 218.4 261.74 L 217.04 262.82 L 216.9 264.14 L 217.33 267.39 L 217.91 267.9 L 218.81 267.87 L 220.34 271.21 L 220.3 273.26 L 220.88 274.75 L 220.81 276.46 L 220.25 278.7 L 218.59 280.71 L 218.07 282.96 L 217.49 283.8 L 217.06 284.21 L 215.42 284.74 L 214.49 285.82 L 213.06 289.6 L 212.54 292.05 L 208.43 294.62 L 206.96 296.05 L 206.96 296.05 L 206.22 296.01 L 203.63 294.46 L 202.36 293.03 L 195.28 293.99 L 193.96 293.56 L 193.71 293.26 L 190.33 293.92 L 189.85 293.76 L 189.33 292.41 z"},{code:"RR",name:"Roraima",gTransform:"matrix(1 0 0 1 -116.08 -267.27)",pathTransform:"translate(-189.92, -51.99)",d:"M 234.61 61.4 L 236.21 78.37 L 236.21 78.37 L 217.72 78.3 L 217.75 78.98 L 215.42 82.24 L 213.76 85.27 L 213.69 86.4 L 212.54 89.04 L 212.43 89.7 L 212.66 90.43 L 213.8 91.84 L 213.78 92.37 L 213.36 92.76 L 211.33 93.31 L 209.92 94.72 L 208.67 95.18 L 206.85 94.95 L 205.93 92.44 L 204.06 90.4 L 201.23 89.47 L 199.63 89.53 L 199.08 90.42 L 196.99 91.13 L 195.71 91.82 L 194.69 93.08 L 193.87 96.05 L 194.24 97.85 L 193.99 99.58 L 193.24 101.87 L 193.68 103.98 L 191.32 102.94 L 189.98 103.36 L 189.45 103.29 L 188.41 101.25 L 186.93 99.6 L 184.97 98.29 L 184.45 98.25 L 179.44 93.83 L 179.58 92.69 L 181.42 93.02 L 182.56 91.7 L 182.62 91.12 L 181.49 86.79 L 180.91 85.89 L 179.69 85.05 L 178.81 82.88 L 178.52 77.9 L 179.09 76.94 L 179.86 73.9 L 179.2 72.32 L 178.84 70.73 L 180.46 69.27 L 180.41 68.82 L 179.54 67.7 L 179.35 65.44 L 177.69 60.68 L 174.96 56.94 L 175.67 55.44 L 176.58 52.12 L 176.09 51.46 L 174.14 50.51 L 172.78 50.4 L 171.9 50.61 L 170.93 50.24 L 169.72 49.07 L 169.66 48.11 L 169.03 48 L 167.9 48.42 L 167.29 48.41 L 166.54 48.07 L 165.82 47.29 L 165.82 47.29 L 166.12 46.83 L 166.35 44.55 L 166.05 44.33 L 162.68 44.1 L 158.93 44.24 L 155.62 43.54 L 155.42 42.94 L 156.22 41.18 L 156.34 39.7 L 155.61 37.93 L 153.67 34.39 L 152.94 32.33 L 152.47 28.61 L 153.26 27.13 L 153.18 26.17 L 151.34 24.17 L 149.18 23.11 L 146.37 20.33 L 145.31 18.52 L 145.02 17.56 L 143.88 16.91 L 143.63 16.52 L 143.66 15.68 L 143.95 15.35 L 144.85 15.42 L 145.97 16.08 L 146.91 17.81 L 147.52 17.9 L 150.91 17.4 L 152.26 17.5 L 154.17 18.09 L 154.78 19.29 L 155.33 21.22 L 155.87 21.57 L 156.83 21.49 L 157.57 20.84 L 158.52 20.44 L 161.7 20.6 L 162.17 20.65 L 163.48 21.86 L 164.08 22.01 L 164.6 21.87 L 165.21 20.31 L 166.52 20.45 L 167.97 21.38 L 171.9 25.95 L 172.95 26.52 L 173.66 26.63 L 175.17 25.95 L 175.91 24.82 L 176.01 23.98 L 175.18 21.22 L 175.54 19.48 L 176 19.2 L 177.93 19.15 L 178.94 18.05 L 180.49 16.96 L 181.24 17.01 L 185.14 18.35 L 185.73 18.18 L 186.53 17.46 L 187.56 17.16 L 188.69 17.51 L 189.72 17.3 L 191.06 16.02 L 192.06 15.77 L 193.21 16 L 194.32 15.93 L 195 15.08 L 195.05 13.73 L 198.08 11.92 L 200.41 12.11 L 203.17 11.72 L 204.06 10.59 L 204.15 9.88 L 204.74 8.76 L 205.49 8.63 L 207.34 7.73 L 208.44 6.69 L 209.55 4.98 L 208.35 1.42 L 207.18 1.06 L 207.82 0.88 L 209.25 0.95 L 210.05 1.27 L 213.62 1.17 L 214.68 0.22 L 215.42 0 L 216.79 0.42 L 217.32 1.73 L 218.36 2.53 L 218.84 3.9 L 218.17 8.8 L 217.45 10.18 L 216.2 10.88 L 216.26 11.71 L 217.87 12.12 L 219.49 11.9 L 221.84 12.71 L 223.66 13.81 L 222.78 15.24 L 222.77 16.39 L 225.11 19.81 L 225.31 21.36 L 223.8 24.28 L 221.92 25.69 L 221.2 27.19 L 221.47 27.58 L 221.53 29.75 L 220.06 32.16 L 219.16 34.93 L 218.85 37.5 L 218.76 40.17 L 219.74 42.04 L 220.25 43.8 L 220.24 45.2 L 221.81 46.23 L 222.71 46.43 L 222.84 47.11 L 222.38 52.26 L 222.5 53 L 224.31 53.29 L 223.65 54.46 L 224.11 54.96 L 226.26 55.7 L 227.72 57.62 L 230.38 60.36 z"},{code:"RS",name:"Rio Grande do Sul",gTransform:"matrix(1 0 0 1 11.62 259.25)",pathTransform:"translate(-317.63, -578.5)",d:"M 321.99 638.52 L 321.63 638.53 L 319.69 637.42 L 319.49 636.96 L 320.01 632.69 L 319.55 628.44 L 319.7 627.37 L 320.33 626.13 L 323.17 623.75 L 324 622.19 L 326.3 619.63 L 324.84 617.98 L 323.77 617.36 L 321.52 616.76 L 319.2 614.51 L 317.99 612.89 L 317.89 611.3 L 317.46 610.12 L 316.23 608.09 L 314.17 605.85 L 313.5 605.26 L 311.11 604.05 L 309.66 604.26 L 307.76 602.75 L 306.24 601.12 L 304.99 600.34 L 304.85 598.64 L 302.95 596.48 L 299.63 596.02 L 298.71 595.55 L 296.98 593.89 L 295.22 594.02 L 293.05 592.64 L 291.14 588.93 L 290.03 587.44 L 287.5 585.32 L 286.8 585.4 L 286.13 587.19 L 283.54 589.43 L 280.87 589.55 L 280.97 586.69 L 281.37 585.41 L 280.98 584.41 L 277.33 580.12 L 274.96 578.35 L 272.78 576.29 L 271.03 574.18 L 268.34 571.97 L 266.44 571.83 L 264.29 572.04 L 263.15 573.4 L 263.09 574.36 L 262.06 575.33 L 260.95 575.35 L 260.37 574.87 L 257.21 575.01 L 256.56 574.53 L 256.4 573.62 L 255.91 573.4 L 256.76 573.18 L 257.8 572.46 L 260.32 569.69 L 260.43 567.85 L 261.03 566.6 L 261.85 566.15 L 263.14 566.08 L 263.78 565.82 L 264.7 564.82 L 270.15 558.34 L 270.78 556.92 L 270.95 555.81 L 271.77 554.74 L 272.97 553.89 L 274.34 553.48 L 276.3 549.26 L 276.4 548.65 L 276.71 548.28 L 278.35 547.42 L 279.98 545.62 L 280.83 544.47 L 281.34 543.18 L 282.68 541.08 L 283.61 540.79 L 285.18 540.97 L 285.73 541.76 L 286.2 540.48 L 285.99 539.9 L 284.64 539.08 L 284.59 538.72 L 284.94 538.39 L 286.02 538.01 L 286.84 537.05 L 289.63 536.1 L 290.68 535.03 L 290.78 534.11 L 291.6 533.2 L 293.81 532.05 L 296.28 531.65 L 298.05 529.84 L 298.2 528.78 L 299.52 526.42 L 299.85 526.38 L 299.9 526.74 L 300.19 526.94 L 301.52 526.77 L 303.96 525.64 L 306.64 525.05 L 307.85 524.48 L 309.95 522.13 L 310.45 522.14 L 311.12 521.75 L 312.13 520.4 L 314.44 519.67 L 314.74 520.05 L 314.74 520.05 L 318.26 520.44 L 321.52 519.29 L 322.08 518.48 L 323.43 519.06 L 323.28 519.98 L 326.36 519.95 L 327.99 520.94 L 330.55 520.57 L 332.47 521.72 L 335.05 521.31 L 336.59 521.49 L 339.39 521.33 L 341.65 522.25 L 344.13 523.65 L 345.13 526.09 L 346.72 526.28 L 346.81 525.8 L 348.62 525.45 L 354.18 528.99 L 355.55 530.54 L 356.26 530.51 L 357.82 531.49 L 360.85 534.98 L 362.49 537.19 L 362.97 538.67 L 365.14 541.33 L 366.31 541.88 L 373 542.94 L 375.11 542.54 L 378.46 542.88 L 379.34 545.22 L 377.26 546.8 L 375.99 547.21 L 375.26 549.07 L 375.48 551.26 L 375.1 552.82 L 374.58 554.12 L 373.4 554.32 L 372.11 556.01 L 372.08 557.42 L 373.88 558.59 L 374.15 558.39 L 373.87 557.42 L 373.88 556.46 L 375.37 555.64 L 376.95 556.28 L 377.68 557.19 L 378.85 558.04 L 379.3 558.01 L 379.3 558.01 L 377.9 559.74 L 374 566.78 L 369.79 578.38 L 363.49 588.86 L 358.05 595.52 L 351.54 601.48 L 345.45 605.16 L 342.35 609.47 L 342.17 609.04 L 342.82 607.46 L 343.16 605.28 L 341.98 603.57 L 342.08 603.15 L 343.01 602.98 L 344.02 603.38 L 344.58 603.96 L 345.6 604 L 348.18 602.59 L 349 601.91 L 351.85 598.2 L 352.6 597.51 L 353.05 597.7 L 354.07 597.51 L 355.12 596.67 L 356.05 595.4 L 356.42 593.92 L 356.6 592.99 L 356.37 590.89 L 356.57 589.52 L 358.14 589.45 L 358.88 589.75 L 359.15 590.58 L 359.5 590.32 L 359.21 588.92 L 359.72 586.85 L 360.2 586.28 L 362.94 584.69 L 363.67 583.61 L 364.14 580.86 L 363.93 578.58 L 364.49 577.9 L 364.99 578.7 L 365.36 578.73 L 365.79 578.31 L 366.26 575.23 L 366.16 574.79 L 365.21 573.57 L 364.54 573.54 L 364.28 574.23 L 364.45 574.62 L 364.31 575.19 L 363.96 575.39 L 362.45 575.37 L 360.44 575.77 L 360.1 577.38 L 359.57 577.43 L 358.76 576.99 L 358.86 575.28 L 358.04 574.39 L 357 574.72 L 356.4 574.24 L 355.67 572.98 L 355.27 571.53 L 355.39 570.96 L 354.75 570.27 L 354.14 572.98 L 354.58 575.23 L 355.83 577.34 L 355.26 578.15 L 354.52 580.69 L 354.9 583.72 L 354.72 584.49 L 354.24 584.12 L 354.5 583.88 L 354.47 583.17 L 354 581.89 L 353.55 581.5 L 353.02 582.16 L 352.99 583.53 L 351.58 586.8 L 351.53 588.69 L 351.75 589.21 L 351.03 589.91 L 349.42 590.55 L 348.81 592.13 L 344.72 593.7 L 344 594.23 L 343.47 595.82 L 343.37 598.09 L 342.4 600.36 L 340.04 601.66 L 339.93 603.42 L 340.41 604.25 L 340.66 605.27 L 339.71 605.83 L 339.46 607.34 L 339.89 607.94 L 340.57 607.8 L 341.87 608.43 L 342.02 609.34 L 339.89 610.99 L 337.57 615.51 L 335.64 622.39 L 333.63 626.88 L 331.95 629.4 L 324.16 636.93 z"},{code:"SC",name:"Santa Catarina",gTransform:"matrix(1 0 0 1 51.41 209.71)",pathTransform:"translate(-357.4, -528.97)",d:"M 379.3 558.01 L 378.85 558.04 L 377.68 557.1899999999999 L 376.95 556.27 L 375.36 555.64 L 373.88 556.46 L 373.87 557.4200000000001 L 374.15 558.3900000000001 L 373.88 558.5900000000001 L 372.08 557.4200000000002 L 372.12 556.0100000000002 L 373.4 554.3200000000002 L 374.58 554.1200000000001 L 375.10999999999996 552.8100000000002 L 375.47999999999996 551.2600000000002 L 375.25999999999993 549.0700000000002 L 375.98999999999995 547.2100000000002 L 377.25999999999993 546.7900000000002 L 379.3399999999999 545.2100000000002 L 378.4599999999999 542.8700000000001 L 375.1099999999999 542.5300000000001 L 372.9999999999999 542.9300000000001 L 366.3099999999999 541.8700000000001 L 365.14999999999986 541.3300000000002 L 362.97999999999985 538.6700000000002 L 362.48999999999984 537.1900000000002 L 360.85999999999984 534.9800000000001 L 357.82999999999987 531.4900000000001 L 356.2599999999999 530.5000000000001 L 355.5499999999999 530.5300000000001 L 354.1799999999999 528.9800000000001 L 348.6199999999999 525.4400000000002 L 346.8099999999999 525.7800000000002 L 346.7199999999999 526.2600000000002 L 345.1199999999999 526.0700000000002 L 344.1199999999999 523.6300000000001 L 341.64999999999986 522.2400000000001 L 339.3799999999999 521.3100000000002 L 336.58999999999986 521.4700000000001 L 335.04999999999984 521.2900000000002 L 332.45999999999987 521.7000000000002 L 330.54999999999984 520.5500000000002 L 327.97999999999985 520.9100000000002 L 326.34999999999985 519.9300000000002 L 323.26999999999987 519.9600000000002 L 323.41999999999985 519.0300000000002 L 322.0699999999998 518.4500000000002 L 321.5099999999998 519.2600000000001 L 318.24999999999983 520.4200000000001 L 314.72999999999985 520.0300000000001 L 314.72999999999985 520.0300000000001 L 316.17999999999984 517.1000000000001 L 316.90999999999985 515.0100000000001 L 316.32999999999987 511.7600000000001 L 316.7399999999999 508.5500000000001 L 316.6999999999999 506.0000000000001 L 317.65999999999985 504.2500000000001 L 317.65999999999985 504.2500000000001 L 321.28999999999985 504.2700000000001 L 321.99999999999983 503.8900000000001 L 322.5299999999998 503.9000000000001 L 323.5899999999998 504.1400000000001 L 323.8999999999998 504.6500000000001 L 325.9299999999998 506.0600000000001 L 328.6099999999998 506.0900000000001 L 330.94999999999976 505.5100000000001 L 336.2399999999998 507.1900000000001 L 340.4999999999998 507.5500000000001 L 341.51999999999975 508.1800000000001 L 341.68999999999977 508.59000000000015 L 343.25999999999976 509.77000000000015 L 347.02999999999975 510.19000000000017 L 351.27999999999975 510.0600000000002 L 352.60999999999973 511.96000000000015 L 352.78999999999974 511.46000000000015 L 353.52999999999975 511.08000000000015 L 354.44999999999976 511.0600000000002 L 355.31999999999977 510.20000000000016 L 354.46999999999974 507.21000000000015 L 355.15999999999974 505.63000000000017 L 355.87999999999977 504.8500000000002 L 357.87999999999977 503.7100000000002 L 361.44999999999976 504.1100000000002 L 363.31999999999977 503.14000000000016 L 364.0499999999998 502.27000000000015 L 364.63999999999976 500.79000000000013 L 366.16999999999973 500.14000000000016 L 367.27999999999975 500.00000000000017 L 368.69999999999976 500.76000000000016 L 369.50999999999976 500.79000000000013 L 371.83999999999975 500.6200000000001 L 374.6799999999997 499.8900000000001 L 375.4299999999997 499.9000000000001 L 376.46999999999974 500.30000000000007 L 379.58999999999975 502.9000000000001 L 380.81999999999977 503.5200000000001 L 382.25999999999976 503.6800000000001 L 385.6099999999998 501.5500000000001 L 386.9599999999998 500.1200000000001 L 388.5199999999998 499.5500000000001 L 388.6399999999998 499.9400000000001 L 389.3999999999998 500.0100000000001 L 391.1399999999998 499.7800000000001 L 391.4699999999998 499.3400000000001 L 396.7099999999998 499.37000000000006 L 396.7099999999998 499.37000000000006 L 396.3199999999998 500.69000000000005 L 396.8299999999998 502.34000000000003 L 396.7599999999998 502.73 L 395.2599999999998 503.87 L 394.2799999999998 503.39 L 393.4599999999998 500.86 L 393.4399999999998 501.98 L 394.0299999999998 504.70000000000005 L 395.7399999999998 506.36000000000007 L 396.2999999999998 507.31000000000006 L 395.2899999999998 509.6000000000001 L 395.12999999999977 511.9200000000001 L 395.2299999999998 512.35 L 395.9899999999998 513.08 L 396.2499999999998 518.94 L 396.5599999999998 519.49 L 396.9899999999998 519.69 L 397.75999999999976 519.1800000000001 L 398.1099999999998 519.9000000000001 L 398.2099999999998 520.7700000000001 L 397.7399999999998 520.83 L 397.3099999999998 520.5500000000001 L 396.1199999999998 521.1800000000001 L 395.7799999999998 525.0200000000001 L 396.3499999999998 527.6100000000001 L 395.7799999999998 528.3600000000001 L 396.0899999999998 530.2900000000001 L 396.99999999999983 532.1700000000001 L 396.1399999999998 534.5100000000001 L 395.61999999999983 538.5200000000001 L 393.90999999999985 543.2 L 393.5699999999999 543.1 L 393.20999999999987 542.34 L 393.41999999999985 541.37 L 392.49999999999983 540.19 L 392.23999999999984 540.5200000000001 L 392.41999999999985 542.95 L 393.57999999999987 543.7800000000001 L 392.65999999999985 545.44 L 391.01999999999987 546.09 L 386.8899999999999 549.13 L 384.08999999999986 551.6899999999999 L 380.33999999999986 556.13 L 379.3 558.01 z M 397.18 531.46 L 397.03000000000003 530.99 L 397.28000000000003 529.24 L 398.04 526.84 L 397.64000000000004 525.6600000000001 L 397.80000000000007 524.6400000000001 L 399.20000000000005 523.8800000000001 L 399.4200000000001 523.94 L 400.0800000000001 524.8800000000001 L 399.5400000000001 527.44 L 398.7200000000001 528.3000000000001 L 398.1300000000001 529.5200000000001 L 398.3300000000001 530.69 L 397.18 531.46 z M 396.73 507.09 L 394.86 505.07 L 397.41 502.63 L 397.66 502.67 L 398.31 503.72 L 397.45 505.04 L 396.73 507.09 z"},{code:"SE",name:"Sergipe",gTransform:"matrix(1 0 0 1 266.49 -72.82)",pathTransform:"translate(-572.49, -246.44)",d:"M 569.94 261.69 L 567.04 262.58 L 565.49 261.94 L 564.95 261.6 L 564.47 260.88 L 562.55 259.96 L 561.95 259.44 L 561.83 259.03 L 562.17 258.64 L 562.3 257.22 L 562.15 256.83 L 560.72 255.32 L 560.2 253.83 L 559.11 253.16 L 558.15 251.56 L 558.13 250.79 L 558.72 249.21 L 559.04 248.91 L 560.74 248.92 L 561.87 249.67 L 564.42 248.68 L 565.11 248.13 L 565.41 247.55 L 564.65 244.8 L 564.73 243.92 L 565.39 242.3 L 565.47 239.19 L 564.72 238.04 L 562.73 236.09 L 561.46 233.59 L 561.24 231.45 L 561.91 230.3 L 561.91 230.3 L 568.37 233.28 L 572.05 234.23 L 577.47 237.3 L 578.77 239.75 L 580.53 241.2 L 582.19 241.99 L 582.65 242.02 L 586.24 244.25 L 586.84 245.56 L 586.84 245.56 L 584.46 246.32 L 579.89 249.26 L 578.92 250.15 L 577.37 252.36 L 577.05 252.34 L 577.16 251.24 L 576.11 249.42 L 575.12 249.58 L 575.46 250.74 L 576.7 250.74 L 576.93 250.98 L 576.41 252.95 L 575.14 255.04 L 574.61 254.69 L 574.24 254.02 L 573.25 253.86 L 573.45 254.54 L 574.58 255.16 L 574.32 256.93 L 573.46 258.08 L 572.53 260.11 L 571.75 260.26 L 571.45 259.8 L 571.93 258.4 L 572.34 258.27 L 572.65 257.84 L 573.02 256.8 L 572.21 256.43 L 572.31 257.11 L 571.86 258.24 L 571.38 258.74 L 571.12 259.83 L 571.4 260.55 L 571.14 261.07 z"},{code:"SP",name:"São Paulo",gTransform:"matrix(1 0 0 1 89.6 122.15)",pathTransform:"translate(-395.6, -441.42)",d:"M 404.58 487.92 L 404.41999999999996 486.59000000000003 L 402.99999999999994 486.02000000000004 L 402.2699999999999 482.72 L 402.6699999999999 480.77000000000004 L 400.5299999999999 480.19000000000005 L 399.7699999999999 480.36000000000007 L 398.6699999999999 483.13000000000005 L 398.0099999999999 483.9800000000001 L 396.9499999999999 483.4500000000001 L 396.59999999999985 482.67000000000013 L 397.28999999999985 479.3700000000001 L 398.17999999999984 478.7100000000001 L 398.3199999999998 478.3100000000001 L 396.7099999999998 477.04000000000013 L 395.11999999999983 476.91000000000014 L 393.53999999999985 477.10000000000014 L 393.03999999999985 476.72000000000014 L 389.6299999999998 477.2500000000001 L 387.24999999999983 477.3700000000001 L 386.23999999999984 477.16000000000014 L 385.6399999999998 476.77000000000015 L 385.30999999999983 474.73000000000013 L 386.5899999999998 472.6100000000001 L 386.8399999999998 471.5600000000001 L 386.5899999999998 471.1200000000001 L 385.9899999999998 470.8200000000001 L 385.06999999999977 468.8500000000001 L 385.12999999999977 467.9600000000001 L 384.62999999999977 467.2800000000001 L 383.95999999999975 466.99000000000007 L 382.7499999999998 465.8500000000001 L 381.25999999999976 462.8400000000001 L 381.6199999999998 462.2900000000001 L 381.69999999999976 460.5300000000001 L 380.39999999999975 459.0100000000001 L 380.01999999999975 457.17000000000013 L 380.18999999999977 456.3600000000001 L 380.57999999999976 455.78000000000014 L 380.5599999999998 453.04000000000013 L 379.6699999999998 451.28000000000014 L 376.0799999999998 448.45000000000016 L 374.9499999999998 446.90000000000015 L 371.9799999999998 447.76000000000016 L 366.6699999999998 447.63000000000017 L 366.00999999999976 447.09000000000015 L 364.3599999999998 446.95000000000016 L 363.93999999999977 447.29000000000013 L 362.21999999999974 447.22000000000014 L 361.4999999999997 445.90000000000015 L 360.8699999999997 445.39000000000016 L 357.35999999999973 444.59000000000015 L 355.60999999999973 443.75000000000017 L 354.82999999999976 442.75000000000017 L 352.2499999999998 442.76000000000016 L 351.1799999999998 443.3000000000002 L 349.8599999999998 443.1700000000002 L 347.2199999999998 442.0800000000002 L 344.6899999999998 441.62000000000023 L 343.2099999999998 440.8300000000002 L 342.0399999999998 440.5400000000002 L 341.3099999999998 440.9100000000002 L 340.9699999999998 441.5100000000002 L 339.7599999999998 442.1300000000002 L 336.47999999999985 441.8400000000002 L 332.46999999999986 441.9500000000002 L 328.6399999999999 441.30000000000024 L 325.3899999999999 443.59000000000026 L 325.3899999999999 443.59000000000026 L 326.22999999999985 442.5100000000003 L 326.95999999999987 440.97000000000025 L 328.21999999999986 439.83000000000027 L 335.77999999999986 435.29000000000025 L 337.72999999999985 433.42000000000024 L 338.98999999999984 430.99000000000024 L 340.71999999999986 429.30000000000024 L 341.11999999999983 428.09000000000026 L 342.55999999999983 427.0600000000003 L 342.8399999999998 425.84000000000026 L 342.4899999999998 425.0000000000003 L 344.4899999999998 422.7400000000003 L 345.69999999999976 420.4000000000003 L 345.76999999999975 419.4600000000003 L 345.45999999999975 417.5300000000003 L 345.68999999999977 417.1400000000003 L 346.64999999999975 416.62000000000035 L 349.2499999999998 412.98000000000036 L 349.4099999999998 410.05000000000035 L 350.0299999999998 408.37000000000035 L 351.0399999999998 408.07000000000033 L 351.7699999999998 407.43000000000035 L 353.7599999999998 404.75000000000034 L 354.97999999999985 403.73000000000036 L 355.4499999999999 403.50000000000034 L 356.7599999999999 403.4600000000003 L 358.2599999999999 402.68000000000035 L 358.53999999999985 402.28000000000037 L 358.9399999999998 399.8200000000004 L 358.9399999999998 399.8200000000004 L 360.15999999999985 398.6900000000004 L 362.30999999999983 397.5800000000004 L 364.22999999999985 397.2100000000004 L 365.65999999999985 395.5200000000004 L 367.15999999999985 394.91000000000037 L 367.90999999999985 395.05000000000035 L 369.6399999999999 396.60000000000036 L 372.1899999999999 396.68000000000035 L 376.4799999999999 397.6400000000003 L 378.1499999999999 397.2800000000003 L 379.7699999999999 397.50000000000034 L 381.7699999999999 396.91000000000037 L 383.94999999999993 398.3300000000004 L 385.61999999999995 399.1200000000004 L 385.48999999999995 400.0400000000004 L 385.81999999999994 401.46000000000043 L 387.0299999999999 403.5500000000004 L 387.6599999999999 403.5800000000004 L 388.19999999999993 403.2600000000004 L 388.86999999999995 402.3200000000004 L 389.28 401.1900000000004 L 389.53999999999996 401.0000000000004 L 390.09 401.0500000000004 L 390.45 401.4400000000004 L 390.7 402.4000000000004 L 390.71 405.18000000000035 L 391.90999999999997 405.7100000000003 L 392.32 405.26000000000033 L 392.05 402.7200000000003 L 392.54 401.5300000000003 L 392.99 401.0500000000003 L 401.17 400.3800000000003 L 402.18 399.1300000000003 L 403.68 400.59000000000026 L 404.8 401.02000000000027 L 407.58 400.33000000000027 L 408.02 399.34000000000026 L 407.82 398.8800000000003 L 408.13 398.27000000000027 L 410.51 398.16000000000025 L 412.17 398.9400000000002 L 413.02000000000004 398.30000000000024 L 414.33000000000004 398.0100000000002 L 417.59000000000003 401.36000000000024 L 417.79 402.40000000000026 L 417.22 403.41000000000025 L 416.93 405.78000000000026 L 417.51 406.39000000000027 L 419.4 407.60000000000025 L 419.79999999999995 409.15000000000026 L 419.73999999999995 409.71000000000026 L 418.21999999999997 411.74000000000024 L 418.03999999999996 413.68000000000023 L 418.83 414.42000000000024 L 419.14 415.03000000000026 L 419.51 417.24000000000024 L 420.81 419.04000000000025 L 421.64 421.03000000000026 L 421.61 421.8800000000003 L 423.22 421.83000000000027 L 424 421.52000000000027 L 424.28 421.16000000000025 L 425.28 421.11000000000024 L 428.97999999999996 422.43000000000023 L 429.21 422.80000000000024 L 429.15999999999997 424.0700000000002 L 428.46 426.2500000000002 L 426.59999999999997 428.97000000000025 L 426.85999999999996 431.91000000000025 L 426.66999999999996 435.36000000000024 L 426.14 436.92000000000024 L 426.86 438.52000000000027 L 428.64 439.7600000000003 L 430.45 440.59000000000026 L 430.96 442.3100000000003 L 429.75 443.0100000000003 L 431.77 446.3200000000003 L 432.9 446.5700000000003 L 434.90999999999997 446.33000000000027 L 435.09 446.86000000000024 L 438.71 445.86000000000024 L 439.27 446.28000000000026 L 440.58 445.96000000000026 L 441.33 444.98000000000025 L 441.38 444.14000000000027 L 441.14 443.90000000000026 L 441.31 441.60000000000025 L 442.5 441.27000000000027 L 442.59 441.6200000000003 L 442.23999999999995 442.1100000000003 L 442.24999999999994 442.5900000000003 L 444.5899999999999 442.6700000000003 L 446.9799999999999 442.4200000000003 L 448.7699999999999 441.7500000000003 L 449.99999999999994 440.5100000000003 L 451.92999999999995 439.4900000000003 L 454.13999999999993 439.27000000000027 L 455.37999999999994 438.54000000000025 L 455.37999999999994 438.54000000000025 L 456.6499999999999 439.08000000000027 L 457.2099999999999 440.2500000000003 L 458.43999999999994 441.84000000000026 L 460.2099999999999 442.23000000000025 L 463.3599999999999 441.7000000000003 L 465.0599999999999 441.71000000000026 L 465.8099999999999 443.35000000000025 L 464.1599999999999 445.5000000000002 L 462.6599999999999 446.2100000000002 L 459.88999999999993 446.5700000000002 L 459.38999999999993 446.42000000000024 L 457.0399999999999 447.43000000000023 L 455.94999999999993 448.5800000000002 L 454.85999999999996 452.0800000000002 L 454.90999999999997 452.49000000000024 L 456.53999999999996 454.22000000000025 L 457.02 454.48000000000025 L 457.02 454.48000000000025 L 456.96 454.68000000000023 L 455.27 455.10000000000025 L 454.21 454.28000000000026 L 452.72999999999996 455.39000000000027 L 452.29999999999995 456.04000000000025 L 452.56999999999994 456.2600000000003 L 451.80999999999995 456.90000000000026 L 448.5899999999999 458.4500000000003 L 446.3399999999999 459.15000000000026 L 446.05999999999995 459.59000000000026 L 446.09999999999997 460.55000000000024 L 446.59999999999997 462.10000000000025 L 446.28 462.52000000000027 L 444.88 462.78000000000026 L 444.18 462.14000000000027 L 442.84000000000003 461.85000000000025 L 439.72 461.35000000000025 L 438.86 461.5000000000002 L 437.54 461.8400000000002 L 435.81 462.6600000000002 L 435.31 463.1700000000002 L 434.1 465.32000000000016 L 432.79 465.89000000000016 L 432.29 465.77000000000015 L 432.87 465.3000000000001 L 432.39 464.0800000000001 L 431.21999999999997 463.2300000000001 L 430.39 464.4600000000001 L 430.65 465.2100000000001 L 430.34999999999997 465.8200000000001 L 422.72999999999996 470.0600000000001 L 421.78 470.8800000000001 L 421.46999999999997 472.04000000000013 L 418.2 475.04000000000013 L 414.95 476.9900000000001 L 413.03 477.5200000000001 L 408.53 480.7300000000001 L 406.2 482.69000000000005 L 405.53 482.77000000000004 L 405.09 483.39000000000004 L 405.98999999999995 483.82000000000005 L 406.65 483.88000000000005 L 407.58 483.52000000000004 L 407.58 484.28000000000003 L 406.96 485.59000000000003 L 405.64 486.44000000000005 L 404.58 487.92 z M 448.89 464.91 L 447.34999999999997 464.26000000000005 L 446.18999999999994 464.44000000000005 L 445.69999999999993 464.06000000000006 L 445.79999999999995 463.2800000000001 L 446.74999999999994 462.6300000000001 L 447.8399999999999 460.7800000000001 L 448.55999999999995 461.0300000000001 L 449.21999999999997 461.68000000000006 L 449.34999999999997 464.5900000000001 L 448.89 464.91 z"},{code:"TO",name:"Tocantins",gTransform:"matrix(1 0 0 1 95.98 -93.17)",pathTransform:"translate(-401.98, -226.09)",d:"M 433.35 281.82 L 427.99 283.24 L 426.25 284.58 L 423.69 285.68 L 422.14 285.68 L 417.61 286.68 L 415.09 288.76 L 413.31 289.66 L 412.85 289.42 L 411.34 286.8 L 410.79 286.77 L 410.28 290.07 L 409.59 290.15 L 406.24 289.47 L 403.11 288 L 403.67 286.44 L 403.45 285.7 L 398.92 286.23 L 396.16 285.89 L 395.6 286.43 L 395.3 287.43 L 394.55 288.18 L 393.41 288.13 L 392.8 285.03 L 391.69 281.32 L 390.65 279.44 L 389.5 278.13 L 388.32 279.1 L 386.85 281.49 L 385.22 287.43 L 384.59 287.66 L 380.52 286.23 L 377.43 284.52 L 373.5 284.12 L 371.3 283.09 L 368.9 282.69 L 369.42 280.35 L 370.64 278.47 L 370.67 276.76 L 370.11 277.06 L 368.3 279.15 L 367.64 280.38 L 367.44 282.26 L 367.1 282.71 L 367.1 282.71 L 366.3 282.69 L 365.34 282.18 L 364.36 278.84 L 365.1 276.08 L 364.66 273.03 L 364.14 272.45 L 364.13 270.88 L 364.6 267.57 L 363.5 265.32 L 363.55 264.82 L 364.37 263.93 L 364.53 263.06 L 363.14 261.72 L 363.08 260.86 L 364.96 254.87 L 365 251.92 L 365.54 248.95 L 367.48 243.66 L 367.85 243.39 L 368.28 242.54 L 368.72 239.4 L 369.82 238.15 L 370.38 236.26 L 371.03 235.24 L 371.03 235.24 L 372.65 231.55 L 373.78 227.1 L 374.93 225.52 L 376.12 224.42 L 377.33 222.74 L 378.36 220.82 L 379.73 219.9 L 380.78 219.74 L 381.51 218.89 L 382.45 217.35 L 382.63 216.36 L 384.33 213.12 L 385.42 212.32 L 387.18 207.17 L 387.84 203.13 L 387.69 202.83 L 386.95 202.51 L 385.28 200.77 L 384.68 199.82 L 384.52 198.94 L 384.66 198.37 L 386.07 196.68 L 387.36 194.58 L 387.3 191.91 L 386.87 189.73 L 387.06 189.38 L 389.53 187.6 L 392.94 186.46 L 395.44 185.25 L 395.68 184.75 L 395.53 183.24 L 396.39 181.97 L 397.9 180.63 L 399.19 180.48 L 399.38 179.14 L 399.09 177.94 L 399.34 177.48 L 400.8 177.02 L 401.44 176.54 L 402.37 173.79 L 401.35 172.45 L 401.26 171.05 L 401.55 170.77 L 402.52 170.69 L 403.24 170.32 L 403.61 169.66 L 403.64 169.02 L 402.38 167.85 L 401.51 167.71 L 401.12 167.4 L 400.1 165.74 L 398.81 165.62 L 396.94 165.87 L 394.65 165.06 L 394.65 165.06 L 395.18 164.42 L 397.8 162.57 L 399.76 162.04 L 400.63 162.09 L 403.41 163.61 L 404.81 163.69 L 405.76 163.17 L 407.5 163.46 L 408.09 164.15 L 408.17 165.18 L 408.45 165.5 L 409.67 165.53 L 413.07 166.96 L 413.91 167.99 L 414.38 171.49 L 415.02 172.99 L 414.81 176.71 L 415.04 177.79 L 415.71 178.92 L 415.7 179.36 L 413.93 185.51 L 413.62 187.88 L 413.9 188.88 L 413.65 190.47 L 411.9 192.51 L 410.14 193.18 L 409.96 193.89 L 411.9 195.21 L 412.32 194.94 L 413.69 195.18 L 413.94 195.53 L 414.05 196.41 L 413.43 197.6 L 414.28 199.04 L 415.16 198.97 L 418.16 203.13 L 419.07 203.98 L 421.35 207 L 423.49 205.66 L 427.76 204.72 L 429.56 205.94 L 429.64 207.69 L 429 210.94 L 429.39 212.29 L 426 212.64 L 424.66 213.18 L 424.09 213.73 L 423.41 215.16 L 422.68 217.84 L 423.05 219.14 L 420.42 221.69 L 420.16 222.39 L 420.36 222.81 L 422.44 223.1 L 423.38 223.79 L 424.12 225.38 L 424.18 227.04 L 424.8 228.08 L 428.68 230.03 L 428.77 230.56 L 427.13 232.37 L 427.26 234.02 L 429.4 235.64 L 430.39 238.51 L 431.73 240.51 L 432.44 240.69 L 434.22 240.48 L 435.22 240.78 L 436.04 241.22 L 436.65 242.04 L 437.93 242.7 L 437.93 242.7 L 440.87 242.91 L 440.87 242.91 L 440.18 243.56 L 439.96 244.54 L 439.4 245.01 L 435.58 247.03 L 432.37 249.65 L 432.18 250.02 L 433.47 251.82 L 433.11 252.21 L 432.1 252.48 L 431.2 253.09 L 429.68 256.58 L 428.67 257.3 L 428.17 258.46 L 428.4 259.38 L 430.26 261.33 L 433.85 262 L 435.72 262.99 L 435.77 263.75 L 435.21 264.2 L 433.17 265.01 L 432.74 265.97 L 432.83 266.47 L 433.18 266.8 L 434.21 266.62 L 435.13 266.91 L 435.71 267.42 L 436 268.06 L 435.04 268.77 L 433.89 269.19 L 431.94 270.86 L 431.75 271.71 L 431.7 274.63 L 432.05 275.88 L 432.99 276.54 L 434.04 276.78 L 434.45 277.03 L 434.62 277.45 L 434.67 278.51 L 433.31 280.89 z"}];function E8({selected:t,onSelect:e}){const[s,i]=R.useState(N8),r=o=>{if(o)try{const a=o.getBBox();if(!a.width||!a.height)return;const l=Math.max(a.width,a.height)*.04,c=`${a.x-l} ${a.y-l} ${a.width+l*2} ${a.height+l*2}`;i(d=>d===c?d:c)}catch{}};return n.jsx("svg",{ref:r,viewBox:s,role:"group","aria-label":"Map of Brazil — select a state",className:"h-72 w-full rounded-md border border-border/60 bg-muted/20",children:n.jsx("g",{transform:T8,children:$c.map(o=>{const a=o.code===t;return n.jsx("g",{transform:o.gTransform,children:n.jsx("path",{d:o.d,transform:o.pathTransform,role:"button",tabIndex:0,"aria-label":o.name,"aria-pressed":a,onClick:()=>e(o.code),onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),e(o.code))},className:ce("cursor-pointer stroke-background outline-none transition-colors [stroke-width:1] [vector-effect:non-scaling-stroke]","hover:fill-primary/50 focus-visible:fill-primary/50",a?"fill-primary":"fill-muted-foreground/40")})},o.code)})})})}const A8=[{code:"AF",name:"Afghanistan"},{code:"AX",name:"Åland Islands"},{code:"AL",name:"Albania"},{code:"DZ",name:"Algeria"},{code:"AS",name:"American Samoa"},{code:"AD",name:"Andorra"},{code:"AO",name:"Angola"},{code:"AI",name:"Anguilla"},{code:"AQ",name:"Antarctica"},{code:"AG",name:"Antigua & Barbuda"},{code:"AR",name:"Argentina"},{code:"AM",name:"Armenia"},{code:"AW",name:"Aruba"},{code:"AU",name:"Australia"},{code:"AT",name:"Austria"},{code:"AZ",name:"Azerbaijan"},{code:"BS",name:"Bahamas"},{code:"BH",name:"Bahrain"},{code:"BD",name:"Bangladesh"},{code:"BB",name:"Barbados"},{code:"BY",name:"Belarus"},{code:"BE",name:"Belgium"},{code:"BZ",name:"Belize"},{code:"BJ",name:"Benin"},{code:"BM",name:"Bermuda"},{code:"BT",name:"Bhutan"},{code:"BO",name:"Bolivia"},{code:"BA",name:"Bosnia & Herzegovina"},{code:"BW",name:"Botswana"},{code:"BV",name:"Bouvet Island"},{code:"BR",name:"Brazil"},{code:"VG",name:"British Virgin Islands"},{code:"BN",name:"Brunei"},{code:"BG",name:"Bulgaria"},{code:"BF",name:"Burkina Faso"},{code:"BI",name:"Burundi"},{code:"KH",name:"Cambodia"},{code:"CM",name:"Cameroon"},{code:"CA",name:"Canada"},{code:"CV",name:"Cape Verde"},{code:"BQ",name:"Caribbean Netherlands"},{code:"KY",name:"Cayman Islands"},{code:"CF",name:"Central African Republic"},{code:"TD",name:"Chad"},{code:"IO",name:"Chagos Archipelago"},{code:"CL",name:"Chile"},{code:"CN",name:"China mainland"},{code:"CX",name:"Christmas Island"},{code:"CC",name:"Cocos (Keeling) Islands"},{code:"CO",name:"Colombia"},{code:"KM",name:"Comoros"},{code:"CG",name:"Congo - Brazzaville"},{code:"CD",name:"Congo - Kinshasa"},{code:"CK",name:"Cook Islands"},{code:"CR",name:"Costa Rica"},{code:"CI",name:"Côte d’Ivoire"},{code:"HR",name:"Croatia"},{code:"CU",name:"Cuba"},{code:"CW",name:"Curaçao"},{code:"CY",name:"Cyprus"},{code:"CZ",name:"Czechia"},{code:"DK",name:"Denmark"},{code:"DJ",name:"Djibouti"},{code:"DM",name:"Dominica"},{code:"DO",name:"Dominican Republic"},{code:"EC",name:"Ecuador"},{code:"EG",name:"Egypt"},{code:"SV",name:"El Salvador"},{code:"GQ",name:"Equatorial Guinea"},{code:"ER",name:"Eritrea"},{code:"EE",name:"Estonia"},{code:"SZ",name:"Eswatini"},{code:"ET",name:"Ethiopia"},{code:"FK",name:"Falkland Islands"},{code:"FO",name:"Faroe Islands"},{code:"FJ",name:"Fiji"},{code:"FI",name:"Finland"},{code:"FR",name:"France"},{code:"GF",name:"French Guiana"},{code:"PF",name:"French Polynesia"},{code:"TF",name:"French Southern Territories"},{code:"GA",name:"Gabon"},{code:"GM",name:"Gambia"},{code:"GE",name:"Georgia"},{code:"DE",name:"Germany"},{code:"GH",name:"Ghana"},{code:"GI",name:"Gibraltar"},{code:"GR",name:"Greece"},{code:"GL",name:"Greenland"},{code:"GD",name:"Grenada"},{code:"GP",name:"Guadeloupe"},{code:"GU",name:"Guam"},{code:"GT",name:"Guatemala"},{code:"GG",name:"Guernsey"},{code:"GN",name:"Guinea"},{code:"GW",name:"Guinea-Bissau"},{code:"GY",name:"Guyana"},{code:"HT",name:"Haiti"},{code:"HM",name:"Heard & McDonald Islands"},{code:"HN",name:"Honduras"},{code:"HK",name:"Hong Kong"},{code:"HU",name:"Hungary"},{code:"IS",name:"Iceland"},{code:"IN",name:"India"},{code:"ID",name:"Indonesia"},{code:"IR",name:"Iran"},{code:"IQ",name:"Iraq"},{code:"IE",name:"Ireland"},{code:"IM",name:"Isle of Man"},{code:"IL",name:"Israel"},{code:"IT",name:"Italy"},{code:"JM",name:"Jamaica"},{code:"JP",name:"Japan"},{code:"JE",name:"Jersey"},{code:"JO",name:"Jordan"},{code:"KZ",name:"Kazakhstan"},{code:"KE",name:"Kenya"},{code:"KI",name:"Kiribati"},{code:"KW",name:"Kuwait"},{code:"KG",name:"Kyrgyzstan"},{code:"LA",name:"Laos"},{code:"LV",name:"Latvia"},{code:"LB",name:"Lebanon"},{code:"LS",name:"Lesotho"},{code:"LR",name:"Liberia"},{code:"LY",name:"Libya"},{code:"LI",name:"Liechtenstein"},{code:"LT",name:"Lithuania"},{code:"LU",name:"Luxembourg"},{code:"MO",name:"Macao"},{code:"MG",name:"Madagascar"},{code:"MW",name:"Malawi"},{code:"MY",name:"Malaysia"},{code:"MV",name:"Maldives"},{code:"ML",name:"Mali"},{code:"MT",name:"Malta"},{code:"MH",name:"Marshall Islands"},{code:"MQ",name:"Martinique"},{code:"MR",name:"Mauritania"},{code:"MU",name:"Mauritius"},{code:"YT",name:"Mayotte"},{code:"MX",name:"Mexico"},{code:"FM",name:"Micronesia"},{code:"MD",name:"Moldova"},{code:"MC",name:"Monaco"},{code:"MN",name:"Mongolia"},{code:"ME",name:"Montenegro"},{code:"MS",name:"Montserrat"},{code:"MA",name:"Morocco"},{code:"MZ",name:"Mozambique"},{code:"MM",name:"Myanmar (Burma)"},{code:"NA",name:"Namibia"},{code:"NR",name:"Nauru"},{code:"NP",name:"Nepal"},{code:"NL",name:"Netherlands"},{code:"NC",name:"New Caledonia"},{code:"NZ",name:"New Zealand"},{code:"NI",name:"Nicaragua"},{code:"NE",name:"Niger"},{code:"NG",name:"Nigeria"},{code:"NU",name:"Niue"},{code:"NF",name:"Norfolk Island"},{code:"KP",name:"North Korea"},{code:"MK",name:"North Macedonia"},{code:"MP",name:"Northern Mariana Islands"},{code:"NO",name:"Norway"},{code:"OM",name:"Oman"},{code:"PK",name:"Pakistan"},{code:"PW",name:"Palau"},{code:"PS",name:"Palestinian Territories"},{code:"PA",name:"Panama"},{code:"PG",name:"Papua New Guinea"},{code:"PY",name:"Paraguay"},{code:"PE",name:"Peru"},{code:"PH",name:"Philippines"},{code:"PN",name:"Pitcairn Islands"},{code:"PL",name:"Poland"},{code:"PT",name:"Portugal"},{code:"PR",name:"Puerto Rico"},{code:"QA",name:"Qatar"},{code:"RE",name:"Réunion"},{code:"RO",name:"Romania"},{code:"RU",name:"Russia"},{code:"RW",name:"Rwanda"},{code:"WS",name:"Samoa"},{code:"SM",name:"San Marino"},{code:"ST",name:"São Tomé & Príncipe"},{code:"SA",name:"Saudi Arabia"},{code:"SN",name:"Senegal"},{code:"RS",name:"Serbia"},{code:"SC",name:"Seychelles"},{code:"SL",name:"Sierra Leone"},{code:"SG",name:"Singapore"},{code:"SX",name:"Sint Maarten"},{code:"SK",name:"Slovakia"},{code:"SI",name:"Slovenia"},{code:"GS",name:"So. Georgia & So. Sandwich Isl."},{code:"SB",name:"Solomon Islands"},{code:"SO",name:"Somalia"},{code:"ZA",name:"South Africa"},{code:"KR",name:"South Korea"},{code:"SS",name:"South Sudan"},{code:"ES",name:"Spain"},{code:"LK",name:"Sri Lanka"},{code:"BL",name:"St. Barthélemy"},{code:"SH",name:"St. Helena"},{code:"KN",name:"St. Kitts & Nevis"},{code:"LC",name:"St. Lucia"},{code:"MF",name:"St. Martin"},{code:"PM",name:"St. Pierre & Miquelon"},{code:"VC",name:"St. Vincent & Grenadines"},{code:"SD",name:"Sudan"},{code:"SR",name:"Suriname"},{code:"SJ",name:"Svalbard & Jan Mayen"},{code:"SE",name:"Sweden"},{code:"CH",name:"Switzerland"},{code:"SY",name:"Syria"},{code:"TW",name:"Taiwan"},{code:"TJ",name:"Tajikistan"},{code:"TZ",name:"Tanzania"},{code:"TH",name:"Thailand"},{code:"TL",name:"Timor-Leste"},{code:"TG",name:"Togo"},{code:"TK",name:"Tokelau"},{code:"TO",name:"Tonga"},{code:"T1",name:"Tor network (Cloudflare)"},{code:"TT",name:"Trinidad & Tobago"},{code:"TN",name:"Tunisia"},{code:"TR",name:"Türkiye"},{code:"TM",name:"Turkmenistan"},{code:"TC",name:"Turks & Caicos Islands"},{code:"TV",name:"Tuvalu"},{code:"UM",name:"U.S. Outlying Islands"},{code:"VI",name:"U.S. Virgin Islands"},{code:"UG",name:"Uganda"},{code:"UA",name:"Ukraine"},{code:"AE",name:"United Arab Emirates"},{code:"GB",name:"United Kingdom"},{code:"US",name:"United States"},{code:"XX",name:"Unknown (Cloudflare could not determine)"},{code:"UY",name:"Uruguay"},{code:"UZ",name:"Uzbekistan"},{code:"VU",name:"Vanuatu"},{code:"VA",name:"Vatican City"},{code:"VE",name:"Venezuela"},{code:"VN",name:"Vietnam"},{code:"WF",name:"Wallis & Futuna"},{code:"EH",name:"Western Sahara"},{code:"YE",name:"Yemen"},{code:"ZM",name:"Zambia"},{code:"ZW",name:"Zimbabwe"}],P8="BR";function R8(t){if(!t)return!1;const e=Object.keys(t).sort();return e.length===3&&e[0]==="city"&&e[1]==="country"&&e[2]==="regionCode"}function D8(t){const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{};return{city:typeof e.city=="string"?e.city:"",regionCode:typeof e.regionCode=="string"?e.regionCode:"",country:typeof e.country=="string"?e.country:""}}function I8(t,e){const s={...t,...e},i={};for(const r of["city","regionCode","country"])s[r]&&(i[r]=s[r]);return i}function i0(t){const e=U.c(37),{id:s,options:i,value:r,placeholder:o,emptyMessage:a,onChange:l}=t,[c,d]=R.useState(!1);let h;if(e[0]!==i||e[1]!==r){let w;e[3]!==r?(w=j=>j.value===r,e[3]=r,e[4]=w):w=e[4],h=i.find(w),e[0]=i,e[1]=r,e[2]=h}else h=e[2];const u=h;let f;e[5]!==o||e[6]!==u?(f=u?n.jsx("span",{className:"truncate",children:u.label}):n.jsx("span",{className:"text-muted-foreground",children:o}),e[5]=o,e[6]=u,e[7]=f):f=e[7];let m;e[8]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(ic,{className:"size-4 shrink-0 opacity-50"}),e[8]=m):m=e[8];let p;e[9]!==s||e[10]!==c||e[11]!==f?(p=n.jsx(ps,{asChild:!0,children:n.jsxs(re,{id:s,variant:"outline",role:"combobox","aria-expanded":c,className:"h-10 w-full justify-between font-normal",children:[f,m]})}),e[9]=s,e[10]=c,e[11]=f,e[12]=p):p=e[12];let g;e[13]===Symbol.for("react.memo_cache_sentinel")?(g={width:"var(--radix-popover-trigger-width)"},e[13]=g):g=e[13];let L;e[14]!==o?(L=n.jsx(lr,{placeholder:o,className:"h-9"}),e[14]=o,e[15]=L):L=e[15];let v;e[16]!==a?(v=n.jsx(cr,{children:a}),e[16]=a,e[17]=v):v=e[17];let y;if(e[18]!==l||e[19]!==i||e[20]!==r){let w;e[22]!==l||e[23]!==r?(w=j=>n.jsxs(Xs,{value:`${j.label} ${j.value}`,onSelect:()=>{l(j.value===r?"":j.value),d(!1)},children:[n.jsx("span",{className:"truncate",children:j.label}),n.jsx(Wt,{className:ce("ml-auto size-4 shrink-0",r===j.value?"opacity-100":"opacity-0")})]},j.value),e[22]=l,e[23]=r,e[24]=w):w=e[24],y=i.map(w),e[18]=l,e[19]=i,e[20]=r,e[21]=y}else y=e[21];let _;e[25]!==y?(_=n.jsx(Si,{children:y}),e[25]=y,e[26]=_):_=e[26];let x;e[27]!==v||e[28]!==_?(x=n.jsxs(dr,{children:[v,_]}),e[27]=v,e[28]=_,e[29]=x):x=e[29];let b;e[30]!==x||e[31]!==L?(b=n.jsx(gs,{className:"p-0",style:g,children:n.jsxs(Oo,{children:[L,x]})}),e[30]=x,e[31]=L,e[32]=b):b=e[32];let S;return e[33]!==c||e[34]!==b||e[35]!==p?(S=n.jsxs(ms,{open:c,onOpenChange:d,children:[p,b]}),e[33]=c,e[34]=b,e[35]=p,e[36]=S):S=e[36],S}const O8=A8.map(t=>({value:t.code,label:`${t.name} (${t.code})`})),M8=$c.map(t=>({value:t.code,label:`${t.name} (${t.code})`}));function m1(t){const e=U.c(49),{schema:s,value:i,onChange:r,path:o}=t;let a;e[0]!==i?(a=D8(i),e[0]=i,e[1]=a):a=e[1];const l=a,{city:c,regionCode:d,country:h}=l;let u;e[2]!==s.properties?(u=s.properties??{},e[2]=s.properties,e[3]=u):u=e[3];const f=u,m=f.country?.title??"Country",p=f.regionCode?.title??"Region",g=f.city?.title??"City";let L;e[4]!==l||e[5]!==r?(L=M=>{r(I8(l,M))},e[4]=l,e[5]=r,e[6]=L):L=e[6];const v=L,y=h===P8;let _;e[7]!==d?(_=$c.find(M=>M.code===d),e[7]=d,e[8]=_):_=e[8];const x=_,b=`${o}.country`,S=s.title??"Location";let w;e[9]!==b||e[10]!==S?(w=n.jsx(Ve,{htmlFor:b,children:S}),e[9]=b,e[10]=S,e[11]=w):w=e[11];let j;e[12]!==s.description?(j=s.description&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[12]=s.description,e[13]=j):j=e[13];let N;e[14]!==w||e[15]!==j?(N=n.jsxs("div",{className:"space-y-0.5",children:[w,j]}),e[14]=w,e[15]=j,e[16]=N):N=e[16];const T=`${o}.country`;let A;e[17]!==m||e[18]!==T?(A=n.jsx(Ve,{htmlFor:T,className:"text-xs",children:m}),e[17]=m,e[18]=T,e[19]=A):A=e[19];const k=`${o}.country`;let C;e[20]!==v?(C=M=>v({country:M,regionCode:"",city:""}),e[20]=v,e[21]=C):C=e[21];let I;e[22]!==h||e[23]!==k||e[24]!==C?(I=n.jsx(i0,{id:k,options:O8,value:h,placeholder:"Select a country…",emptyMessage:"No country found.",onChange:C}),e[22]=h,e[23]=k,e[24]=C,e[25]=I):I=e[25];let E;e[26]!==A||e[27]!==I?(E=n.jsxs("div",{className:"space-y-1.5",children:[A,I]}),e[26]=A,e[27]=I,e[28]=E):E=e[28];let O;e[29]!==h||e[30]!==v||e[31]!==y||e[32]!==o||e[33]!==d||e[34]!==p?(O=h&&n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Ve,{htmlFor:`${o}.regionCode`,className:"text-xs",children:p}),y?n.jsxs("div",{className:"space-y-2",children:[n.jsx(E8,{selected:d,onSelect:M=>v({regionCode:M===d?"":M,city:""})}),n.jsx(i0,{id:`${o}.regionCode`,options:M8,value:d,placeholder:"Select a state…",emptyMessage:"No state found.",onChange:M=>v({regionCode:M,city:""})})]}):n.jsxs(n.Fragment,{children:[n.jsx(Ke,{id:`${o}.regionCode`,type:"text",value:d,placeholder:"e.g. SP",onChange:M=>v({regionCode:M.target.value})}),n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:"ISO 3166-2 subdivision code from cf-region-code."})]})]}),e[29]=h,e[30]=v,e[31]=y,e[32]=o,e[33]=d,e[34]=p,e[35]=O):O=e[35];let P;e[36]!==c||e[37]!==g||e[38]!==h||e[39]!==v||e[40]!==y||e[41]!==o||e[42]!==x?(P=h&&n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Ve,{htmlFor:`${o}.city`,className:"text-xs",children:g}),n.jsx(Ke,{id:`${o}.city`,type:"text",value:c,placeholder:y&&x?`e.g. a city in ${x.name}`:"e.g. Sao Paulo",onChange:M=>v({city:M.target.value})}),n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:"Matched exactly against cf-ipcity."})]}),e[36]=c,e[37]=g,e[38]=h,e[39]=v,e[40]=y,e[41]=o,e[42]=x,e[43]=P):P=e[43];let D;return e[44]!==E||e[45]!==O||e[46]!==P||e[47]!==N?(D=n.jsxs("div",{className:"space-y-4",children:[N,E,O,P]}),e[44]=E,e[45]=O,e[46]=P,e[47]=N,e[48]=D):D=e[48],D}function B8(t){const e=t.schema;if(!e?.properties)return null;const s=new Set(Object.keys(t.discriminators??{}));if(s.size===0)return e;const i={};for(const[r,o]of Object.entries(e.properties))s.has(r)||(i[r]=o);return{...e,properties:i}}function $8(t){const e=U.c(46),{schema:s,value:i,onChange:r,path:o,label:a}=t;let l,c;e[0]!==s.inlineUnionBranches||e[1]!==i?(l=s.inlineUnionBranches??[],c=j8(i,l.map(F8)),e[0]=s.inlineUnionBranches,e[1]=i,e[2]=l,e[3]=c):(l=e[2],c=e[3]);const d=c,[h,u]=R.useState(d),[f,m]=R.useState(d);f!==d&&(m(d),u(d));const p=Math.min(h,l.length-1),g=l[p];let L;e[4]!==l||e[5]!==r?(L=P=>{const D=Number(P);u(D),r({...l[D]?.discriminators??{}})},e[4]=l,e[5]=r,e[6]=L):L=e[6];const v=L;if(l.length===0)return null;let y;e[7]!==g?(y=g?B8(g):null,e[7]=g,e[8]=y):y=e[8];const _=y;let x;if(e[9]!==g?.schema?.properties||e[10]!==i){let P;e[12]!==g?.schema?.properties?(P=g?.schema?.properties??{},e[12]=g?.schema?.properties,e[13]=P):P=e[13],x=k8(i,Object.keys(P)),e[9]=g?.schema?.properties,e[10]=i,e[11]=x}else x=e[11];const b=x;let S;e[14]!==a||e[15]!==o?(S=n.jsx(Ve,{htmlFor:o,children:a}),e[14]=a,e[15]=o,e[16]=S):S=e[16];const w=String(p);let j;e[17]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(Rt,{placeholder:"Select..."}),e[17]=j):j=e[17];let N;e[18]!==o?(N=n.jsx(kt,{id:o,children:j}),e[18]=o,e[19]=N):N=e[19];let T;e[20]!==l?(T=l.map(z8),e[20]=l,e[21]=T):T=e[21];let A;e[22]!==T?(A=n.jsx(Nt,{children:T}),e[22]=T,e[23]=A):A=e[23];let k;e[24]!==v||e[25]!==w||e[26]!==N||e[27]!==A?(k=n.jsxs(Tt,{value:w,onValueChange:v,children:[N,A]}),e[24]=v,e[25]=w,e[26]=N,e[27]=A,e[28]=k):k=e[28];let C;e[29]!==s.description?(C=s.description&&n.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[29]=s.description,e[30]=C):C=e[30];let I;e[31]!==k||e[32]!==C||e[33]!==S?(I=n.jsxs("div",{className:"space-y-1.5",children:[S,k,C]}),e[31]=k,e[32]=C,e[33]=S,e[34]=I):I=e[34];let E;e[35]!==g||e[36]!==_||e[37]!==r||e[38]!==o||e[39]!==b||e[40]!==t||e[41]!==i?(E=g&&(R8(g.schema?.properties)?n.jsx(m1,{...t,schema:g.schema,onChange:P=>r({...b,...P,...g.discriminators??{}})}):_?n.jsx(ai,{schema:_,value:i,onChange:P=>r({...P,...g.discriminators??{}}),basePath:o,breadcrumbPath:t.breadcrumbPath,onBreadcrumbChange:t.onBreadcrumbChange,meta:t.meta,decofile:t.decofile,onSaveReferencedBlock:t.onSaveReferencedBlock,sandbox:t.sandbox,previewBaseUrl:t.previewBaseUrl,onAddSectionItem:t.onAddSectionItem,onRequestAddSection:t.onRequestAddSection}):null),e[35]=g,e[36]=_,e[37]=r,e[38]=o,e[39]=b,e[40]=t,e[41]=i,e[42]=E):E=e[42];let O;return e[43]!==I||e[44]!==E?(O=n.jsxs("div",{className:"space-y-3",children:[I,E]}),e[43]=I,e[44]=E,e[45]=O):O=e[45],O}function z8(t,e){return n.jsx(ot,{value:String(e),children:t.title},t.title)}function F8(t){return{discriminators:t.discriminators,propertyKeys:Object.keys(t.schema?.properties??{})}}const H8={lat:-21.9,lng:-41.42},Xa=1e5;let Er=null;function U8(t){return Er||(Er=new Promise((e,s)=>{if(typeof window>"u"){s(new Error("Google Maps requires a browser environment"));return}const i=window;if(i.google?.maps){e(i.google.maps);return}const r=()=>{const l=window.google?.maps;l?e(l):s(new Error("Google Maps script loaded without google.maps"))},o=document.querySelector("script[data-google-maps-loader]");if(o){o.addEventListener("load",r),o.addEventListener("error",()=>s(new Error("Failed to load Google Maps")));return}const a=document.createElement("script");a.src=`https://maps.googleapis.com/maps/api/js?key=${t}&v=weekly&libraries=maps`,a.async=!0,a.defer=!0,a.dataset.googleMapsLoader="true",a.addEventListener("load",r),a.addEventListener("error",()=>s(new Error("Failed to load Google Maps"))),document.head.appendChild(a)}),Er)}function K8(t){if(typeof t!="string"||!t)return null;const e=t.split(",").map(Number),[s,i,r]=e;return!Number.isFinite(s)||!Number.isFinite(i)?null:{lat:s,lng:i,radius:Number.isFinite(r)?r:Xa}}function W8({schema:t,value:e,onChange:s,path:i,label:r}){const o=r2().googleMapsApiKey,a=R.useRef(s);a.current=s;const l=R.useRef(K8(e)),[c,d]=R.useState(null),h=R.useRef(null),u=f=>{if(!f||!o)return;const m={disposed:!1,circle:null,listeners:[]};return U8(o).then(p=>{if(m.disposed)return;const g=l.current,L=g?{lat:g.lat,lng:g.lng}:H8,v=g?.radius??Xa,y=new p.Map(f,{center:L,zoom:v?Math.round(Math.log2(768e4/v))+1:4,draggable:!0,streetViewControl:!1,mapTypeControl:!1}),_=new p.Circle({strokeColor:"#2E6ED9",strokeOpacity:.8,strokeWeight:2,fillColor:"#2E6ED9",fillOpacity:.35,editable:!0,draggable:!0,map:y,center:L,radius:v});m.circle=_;const x=()=>{const S=_.getCenter(),w=_.getRadius();S&&a.current(`${S.lat()},${S.lng()},${w}`)},b=S=>{S&&m.listeners.push(S)};b(y.addListener("click",S=>{S.latLng&&(_.setCenter({lat:S.latLng.lat(),lng:S.latLng.lng()}),_.getRadius()||_.setRadius(Xa),x())})),b(_.addListener("radius_changed",x)),b(_.addListener("dragend",x))},p=>{m.disposed||d(p instanceof Error?p.message:"Failed to load map")}),()=>{m.disposed=!0;for(const p of m.listeners)try{p?.remove()}catch{}if(m.listeners=[],m.circle){try{m.circle.setMap(null)}catch{}m.circle=null}}};return h.current||(h.current=u),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"space-y-0.5",children:[n.jsx(Ve,{htmlFor:i,children:r}),t.description&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:t.description})]}),o?c?n.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive",children:c}):n.jsx("div",{ref:h.current,id:i,className:"h-72 w-full rounded-md border border-border/60"}):n.jsxs("div",{className:"rounded-md border border-border/60 bg-muted/30 px-3 py-2 text-xs text-muted-foreground",children:["The map picker is unavailable — set"," ",n.jsx("code",{className:"font-mono",children:"GOOGLE_MAPS_API_KEY"})," on the server to enable it."]})]})}const V8="oklch(0.65 0.15 160)",G8="text-[oklch(0.45_0.15_160)] hover:bg-[oklch(0.65_0.15_160/0.12)] dark:text-[oklch(0.78_0.15_160)] dark:hover:bg-[oklch(0.65_0.15_160/0.15)]",p1="text-[oklch(0.45_0.15_160)] bg-[oklch(0.65_0.15_160/0.18)] dark:text-[oklch(0.78_0.15_160)] dark:bg-[oklch(0.65_0.15_160/0.2)]",Kk="text-[oklch(0.45_0.15_160)] focus:bg-[oklch(0.65_0.15_160/0.12)] focus:text-[oklch(0.45_0.15_160)] dark:text-[oklch(0.78_0.15_160)] dark:focus:bg-[oklch(0.65_0.15_160/0.15)] dark:focus:text-[oklch(0.78_0.15_160)]";function n0(t){return t.map(e=>e.label).join(`
|
|
477
|
-
`)}function ga(t){return t.map(e=>({id:crypto.randomUUID(),index:e.index,label:e.label}))}function q8(t){return t.map((e,s)=>({...e,index:s}))}function g1(t){const e=U.c(18),{label:s,canDelete:i,dragging:r,onRename:o,onDuplicate:a,onDelete:l}=t,c=r?"opacity-100":"opacity-0 group-hover:opacity-100";let d;e[0]!==c?(d=ce("h-4 w-4 shrink-0 text-muted-foreground/40 transition-opacity",c),e[0]=c,e[1]=d):d=e[1];let h;e[2]!==d?(h=n.jsx(Yl,{className:d}),e[2]=d,e[3]=h):h=e[3];let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(Vi,{className:"h-4 w-4 shrink-0",style:{color:V8}}),e[4]=u):u=e[4];let f;e[5]!==s?(f=n.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:s}),e[5]=s,e[6]=f):f=e[6];let m;e[7]!==i||e[8]!==r||e[9]!==s||e[10]!==l||e[11]!==a||e[12]!==o?(m=!r&&n.jsxs(is,{children:[n.jsx(ns,{asChild:!0,children:n.jsx(re,{type:"button",variant:"ghost",size:"icon","aria-label":`Open actions for ${s}`,className:"size-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100 data-[state=open]:opacity-100",onClick:J8,onPointerDown:Y8,children:n.jsx(ln,{size:14})})}),n.jsxs(rs,{align:"end",children:[o&&n.jsxs(We,{onClick:g=>{g.stopPropagation(),o()},children:[n.jsx(n3,{size:14}),"Rename"]}),n.jsxs(We,{onClick:g=>{g.stopPropagation(),a?.()},children:[n.jsx(ts,{size:14}),"Duplicate"]}),n.jsxs(We,{variant:"destructive",disabled:!i,onClick:g=>{g.stopPropagation(),l?.()},children:[n.jsx(os,{size:14}),"Delete"]})]})]}),e[7]=i,e[8]=r,e[9]=s,e[10]=l,e[11]=a,e[12]=o,e[13]=m):m=e[13];let p;return e[14]!==h||e[15]!==f||e[16]!==m?(p=n.jsxs(n.Fragment,{children:[h,u,f,m]}),e[14]=h,e[15]=f,e[16]=m,e[17]=p):p=e[17],p}function Y8(t){return t.stopPropagation()}function J8(t){return t.stopPropagation()}function X8(t){const e=U.c(27),{entry:s,selected:i,canDelete:r,onSelect:o,onRename:a,onDuplicate:l,onDelete:c}=t;let d;e[0]!==s.id?(d={id:s.id,animateLayoutChanges:Z8},e[0]=s.id,e[1]=d):d=e[1];const{attributes:h,listeners:u,setNodeRef:f,transform:m,isDragging:p}=eh(d);let g;e[2]!==m?(g=th.Transform.toString(m?{...m,x:0}:null),e[2]=m,e[3]=g):g=e[3];const L=p?0:void 0;let v;e[4]!==g||e[5]!==L?(v={transform:g,opacity:L},e[4]=g,e[5]=L,e[6]=v):v=e[6];const y=v;let _;e[7]!==o?(_=N=>{N.target===N.currentTarget&&(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),o())},e[7]=o,e[8]=_):_=e[8];const x=p?"cursor-grabbing":"cursor-grab",b=i?p1:G8;let S;e[9]!==x||e[10]!==b?(S=ce("group flex select-none items-center gap-2 rounded-md px-2 py-2.5 transition-colors touch-none",x,b),e[9]=x,e[10]=b,e[11]=S):S=e[11];let w;e[12]!==r||e[13]!==s.label||e[14]!==c||e[15]!==l||e[16]!==a?(w=n.jsx(g1,{label:s.label,canDelete:r,onRename:a,onDuplicate:l,onDelete:c}),e[12]=r,e[13]=s.label,e[14]=c,e[15]=l,e[16]=a,e[17]=w):w=e[17];let j;return e[18]!==h||e[19]!==u||e[20]!==o||e[21]!==f||e[22]!==y||e[23]!==_||e[24]!==S||e[25]!==w?(j=n.jsx("div",{ref:f,style:y,...h,...u,onClick:o,onKeyDown:_,className:S,children:w}),e[18]=h,e[19]=u,e[20]=o,e[21]=f,e[22]=y,e[23]=_,e[24]=S,e[25]=w,e[26]=j):j=e[26],j}function Z8(){return!1}function Q8(t){const e=U.c(82),{listKey:s,variants:i,selectedIndex:r,onSelect:o,onRename:a,onDuplicate:l,onDelete:c,onRemoveAll:d,onReorder:h,onAdd:u}=t,f=i.length>1;let m;e[0]!==i?(m=()=>ga(i),e[0]=i,e[1]=m):m=e[1];const[p,g]=R.useState(m),[L,v]=R.useState(null),[y,_]=R.useState(s),[x,b]=R.useState(i.length);let S;e[2]!==i?(S=()=>n0(i),e[2]=i,e[3]=S):S=e[3];const[w,j]=R.useState(S),N=R.useRef(!1),T=n0(i);y!==s?(_(s),b(i.length),j(T),g(ga(i))):x!==i.length?(b(i.length),j(T),g(ga(i))):w!==T&&(j(T),g(he=>i.map((ye,ve)=>({id:he[ve]?.id??crypto.randomUUID(),index:ye.index,label:ye.label}))));let A;e[4]===Symbol.for("react.memo_cache_sentinel")?(A={activationConstraint:{distance:8}},e[4]=A):A=e[4];let k;e[5]===Symbol.for("react.memo_cache_sentinel")?(k={coordinateGetter:sh},e[5]=k):k=e[5];const C=Vd(Zr(qd,A),Zr(Gd,k));let I;e[6]!==p?(I=p.map(ev),e[6]=p,e[7]=I):I=e[7];const E=I;let O;e[8]!==p?(O=he=>{const ye=String(he.active.id);v(p.find(ve=>ve.id===ye)??null)},e[8]=p,e[9]=O):O=e[9];const P=O;let D;e[10]!==E||e[11]!==h?(D=he=>{v(null);const{active:ye,over:ve}=he;if(!ve||ye.id===ve.id)return;const be=E.indexOf(String(ye.id)),Ne=E.indexOf(String(ve.id));be===-1||Ne===-1||(g(Oe=>q8(za([...Oe],be,Ne))),N.current=!0,requestAnimationFrame(()=>{N.current=!1}),h(be,Ne))},e[10]=E,e[11]=h,e[12]=D):D=e[12];const M=D;let z;e[13]===Symbol.for("react.memo_cache_sentinel")?(z=()=>{v(null)},e[13]=z):z=e[13];const F=z;let $,V,J,Z,G,q,H,K,B,X,W,Y,Q;if(e[14]!==f||e[15]!==p||e[16]!==E||e[17]!==M||e[18]!==P||e[19]!==u||e[20]!==c||e[21]!==l||e[22]!==d||e[23]!==a||e[24]!==o||e[25]!==r||e[26]!==C){const he=pe=>{N.current||o(pe)};W="space-y-1 border-b p-2";let ye;e[40]===Symbol.for("react.memo_cache_sentinel")?(ye=n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Variants"}),e[40]=ye):ye=e[40];let ve;e[41]===Symbol.for("react.memo_cache_sentinel")?(ve=n.jsx(It,{size:14}),e[41]=ve):ve=e[41];let be;e[42]!==u?(be=n.jsx(Ee,{asChild:!0,children:n.jsx(re,{type:"button",variant:"ghost",size:"icon","aria-label":"Add variant",className:"size-6",onClick:u,children:ve})}),e[42]=u,e[43]=be):be=e[43];let Ne;e[44]===Symbol.for("react.memo_cache_sentinel")?(Ne=n.jsx(Ae,{children:"Add variant"}),e[44]=Ne):Ne=e[44];let Oe;e[45]!==be?(Oe=n.jsxs(Pe,{children:[be,Ne]}),e[45]=be,e[46]=Oe):Oe=e[46];let Fe;e[47]===Symbol.for("react.memo_cache_sentinel")?(Fe=n.jsx(os,{size:14}),e[47]=Fe):Fe=e[47];let Me;e[48]!==d?(Me=n.jsx(Ee,{asChild:!0,children:n.jsx(re,{type:"button",variant:"ghost",size:"icon","aria-label":"Remove all variants",className:"size-6 text-muted-foreground hover:text-destructive",onClick:d,children:Fe})}),e[48]=d,e[49]=Me):Me=e[49];let qe;e[50]===Symbol.for("react.memo_cache_sentinel")?(qe=n.jsx(Ae,{children:"Remove all variants"}),e[50]=qe):qe=e[50];let Ie;e[51]!==Me?(Ie=n.jsxs(Pe,{children:[Me,qe]}),e[51]=Me,e[52]=Ie):Ie=e[52],e[53]!==Oe||e[54]!==Ie?(Y=n.jsxs("div",{className:"flex items-center justify-between",children:[ye,n.jsxs("div",{className:"flex items-center gap-0.5",children:[Oe,Ie]})]}),e[53]=Oe,e[54]=Ie,e[55]=Y):Y=e[55],V=Yd,q=C,H=Jd,K=P,B=M,X=F,$=Xd,Z=E,G=Zd,Q="space-y-0.5",J=p.map(pe=>n.jsx(X8,{entry:pe,selected:pe.index===r,canDelete:f,onSelect:()=>he(pe.index),onRename:a?()=>a(pe.index):void 0,onDuplicate:()=>l(pe.index),onDelete:()=>c(pe.index)},pe.id)),e[14]=f,e[15]=p,e[16]=E,e[17]=M,e[18]=P,e[19]=u,e[20]=c,e[21]=l,e[22]=d,e[23]=a,e[24]=o,e[25]=r,e[26]=C,e[27]=$,e[28]=V,e[29]=J,e[30]=Z,e[31]=G,e[32]=q,e[33]=H,e[34]=K,e[35]=B,e[36]=X,e[37]=W,e[38]=Y,e[39]=Q}else $=e[27],V=e[28],J=e[29],Z=e[30],G=e[31],q=e[32],H=e[33],K=e[34],B=e[35],X=e[36],W=e[37],Y=e[38],Q=e[39];let ie;e[56]!==J||e[57]!==Q?(ie=n.jsx("div",{className:Q,children:J}),e[56]=J,e[57]=Q,e[58]=ie):ie=e[58];let oe;e[59]!==$||e[60]!==Z||e[61]!==G||e[62]!==ie?(oe=n.jsx($,{items:Z,strategy:G,children:ie}),e[59]=$,e[60]=Z,e[61]=G,e[62]=ie,e[63]=oe):oe=e[63];let ue;e[64]!==L||e[65]!==f?(ue=L?n.jsx("div",{className:ce("flex items-center gap-2 rounded-md px-2 py-2.5 shadow-lg ring-1 ring-border/60 cursor-grabbing",p1),children:n.jsx(g1,{label:L.label,canDelete:f,dragging:!0})}):null,e[64]=L,e[65]=f,e[66]=ue):ue=e[66];let ee;e[67]!==ue?(ee=n.jsx(Qd,{dropAnimation:null,children:ue}),e[67]=ue,e[68]=ee):ee=e[68];let te;e[69]!==V||e[70]!==q||e[71]!==H||e[72]!==K||e[73]!==B||e[74]!==X||e[75]!==oe||e[76]!==ee?(te=n.jsxs(V,{sensors:q,collisionDetection:H,onDragStart:K,onDragEnd:B,onDragCancel:X,children:[oe,ee]}),e[69]=V,e[70]=q,e[71]=H,e[72]=K,e[73]=B,e[74]=X,e[75]=oe,e[76]=ee,e[77]=te):te=e[77];let fe;return e[78]!==W||e[79]!==Y||e[80]!==te?(fe=n.jsxs("div",{className:W,children:[Y,te]}),e[78]=W,e[79]=Y,e[80]=te,e[81]=fe):fe=e[81],fe}function ev(t){return t.id}const tv=[[/always|matchalways/i,"Users03"],[/device|matchdevice/i,"Phone02"],[/date|matchdate/i,"Calendar"],[/random|matchrandom/i,"Shuffle01"],[/host|matchhost/i,"Globe02"],[/location|matchlocation/i,"MarkerPin01"],[/pathname/i,"Link03"],[/cron|matchcron/i,"Clock"],[/multi|matchmulti/i,"FilterLines"],[/never|matchnever/i,"EyeOff"],[/environment|matchenvironment/i,"Cloud01"],[/eq\.ts|\/eq$/i,"Brackets"],[/user|requser|isdecouser/i,"User01"],[/site|template/i,"LayoutAlt01"]],sv={"device-mobile":"Phone02","device-desktop":"Monitor01","device-tablet":"Tablet01","calendar-event":"Calendar","calendar-month":"Calendar",clock:"Clock","current-location":"MarkerPin01","map-2":"MarkerPin01","world-search":"Globe02",shuffle:"Shuffle01",filter:"FilterLines","eye-off":"EyeOff",flask:"Beaker02",link:"Link03","git-merge":"GitBranch01",users:"Users03",flag:"Flag01","cloud-storm":"Cloud01",campaign:"Announcement01",experiment:"Beaker02",language:"Globe02","hand-click":"CursorClick01"};function _a(t){return Ai(t)!==void 0}function zc(t,e){if(e){if(_a(e))return e;const s=sv[e];if(s&&_a(s))return s}for(const[s,i]of tv)if(s.test(t)&&_a(i))return i;return"FilterLines"}function iv(t){return Ai(t)??$3}function La(t){const e=U.c(11),{iconName:s,size:i,className:r}=t,o=i===void 0?"md":i;let a;e[0]!==s?(a=iv(s),e[0]=s,e[1]=a):a=e[1];const l=a,c=o==="sm"?"size-7":"size-9",d=o==="sm"?16:18;let h;e[2]!==c||e[3]!==r?(h=ce("flex shrink-0 items-center justify-center rounded-full bg-muted",c,r),e[2]=c,e[3]=r,e[4]=h):h=e[4];let u;e[5]!==l||e[6]!==d?(u=n.jsx(l,{size:d,className:"text-muted-foreground"}),e[5]=l,e[6]=d,e[7]=u):u=e[7];let f;return e[8]!==h||e[9]!==u?(f=n.jsx("div",{className:h,children:u}),e[8]=h,e[9]=u,e[10]=f):f=e[10],f}const nv=t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase(),rv=5,ov=new Intl.DateTimeFormat("en",{dateStyle:"medium",timeStyle:"short"});function r0(t){const{start:e,end:s}=t,i=typeof e=="string"?e:"",r=typeof s=="string"?s:"";if(!i&&!r)return null;const o=c=>{if(!c)return null;const d=new Date(c);return Number.isNaN(d.getTime())?null:ov.format(d)},a=o(i),l=o(r);return a&&l?`${a} → ${l}`:a?`From ${a}`:l?`Until ${l}`:null}function Yo(t,e=0){if(!t)return"Default";if(e>rv)return"...";const s=t.__resolveType??"";if(["website/matchers/always.ts","$live/matchers/MatchAlways.ts"].includes(s)||s==="")return"Default";switch(s){case"website/matchers/never.ts":return"Hidden";case"website/matchers/device.ts":case"$live/matchers/MatchDevice.ts":{const{mobile:r,tablet:o,desktop:a,devices:l=[]}=t,c=[...l];return r&&c.push("Mobile"),o&&c.push("Tablet"),a&&c.push("Desktop"),c.length>0?c.map(nv).join(" & "):ut(s)}case"website/matchers/date.ts":case"$live/matchers/MatchDate.ts":return r0(t)??ut(s);case"website/matchers/random.ts":case"$live/matchers/MatchRandom.ts":{const{traffic:r}=t;return typeof r=="number"?`${Math.ceil(r*100)}% of sessions`:ut(s)}case"website/matchers/host.ts":case"$live/matchers/MatchHost.ts":{const{includes:r,match:o}=t,a=[];return r&&a.push(r),o&&a.push(o),a.length>0?a.join(" - "):ut(s)}case"website/matchers/pathname.ts":{const r=t.case,{type:o,pathname:a}=r??{};return o&&a?`Pathname ${o} ${a}`:ut(s)}case"website/matchers/location.ts":case"$live/matchers/MatchLocation.ts":{const{includeLocations:r,excludeLocations:o}=t,a=d=>[d.city,d.regionCode,d.country].filter(Boolean).join(" - "),l=r?.[0];if(l){const d=(r?.length??0)-1;return`${a(l)}${d>0?` +${d}`:""}`}const c=o?.[0];if(c){const d=(o?.length??0)-1;return`Except ${a(c)}${d>0?` +${d}`:""}`}return"Any location"}case"website/matchers/multi.ts":case"$live/matchers/MatchMulti.ts":{const{matchers:r,op:o="AND"}=t;if(r&&r.length>0){const a=o==="OR"?"OR":"AND";return r.map(l=>Yo(l,e+1)).join(` ${a} `)}return ut(s)}default:{const r=r0(t);return r||ut(s)||"Default"}}}function Wk(t,e){return b_(t,e).map(s=>{const i=e[s.blockKey]??{},r=Au(C_(s.blockKey),e,t);return{blockKey:s.blockKey,title:zo(s.blockKey,i),description:Yo(r),iconName:zc(s.matcherResolveType)}})}const _1="Users03";function av(t){const e=t.manifest?.blocks??{},s=[];for(const[i,r]of Object.entries(e))if(i.includes("matchers"))for(const o of Object.keys(r)){if(o.includes("always"))continue;const a=oi(o,t);s.push({resolveType:o,title:a.title??ut(o),description:a.description,iconName:zc(o,a.icon)})}return s}function lv(t,e){if(!t)return _1;const s=e.find(i=>i.resolveType===t);return s?s.iconName:zc(t)}function cv(t){const e=U.c(54),{currentRt:s,currentLabel:i,currentGlobalKey:r,matchers:o,globals:a,onSelect:l,onSelectGlobal:c}=t,d=a===void 0?[]:a,[h,u]=R.useState(!1),m=(r?d.find($=>$.blockKey===r):void 0)?.iconName??lv(s,o),p=Ai(m);let g;e[0]!==l||e[1]!==u?(g=$=>{l($),u(!1)},e[0]=l,e[1]=u,e[2]=g):g=e[2];const L=g;let v;e[3]!==c||e[4]!==u?(v=$=>{c?.($),u(!1)},e[3]=c,e[4]=u,e[5]=v):v=e[5];const y=v;let _;e[6]!==u?(_=()=>u(!0),e[6]=u,e[7]=_):_=e[7];let x;e[8]!==p?(x=p&&n.jsx(p,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e[8]=p,e[9]=x):x=e[9];let b;e[10]!==i?(b=n.jsx("span",{className:"flex-1 truncate",children:i}),e[10]=i,e[11]=b):b=e[11];let S;e[12]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(ls,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e[12]=S):S=e[12];let w;e[13]!==_||e[14]!==x||e[15]!==b?(w=n.jsxs("button",{type:"button",onClick:_,className:"flex h-10 w-full items-center gap-2 rounded-md border border-input bg-transparent px-3 text-left text-sm shadow-xs transition-colors hover:bg-accent/40 cursor-pointer",children:[x,b,S]}),e[13]=_,e[14]=x,e[15]=b,e[16]=w):w=e[16];let j;e[17]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(lr,{placeholder:"Search rules..."}),e[17]=j):j=e[17];let N;e[18]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx(cr,{children:"No rules found."}),e[18]=N):N=e[18];let T;e[19]!==L?(T=()=>L(""),e[19]=L,e[20]=T):T=e[20];const A=!s&&!r&&"bg-accent/60";let k;e[21]!==A?(k=ce("gap-2.5",A),e[21]=A,e[22]=k):k=e[22];let C;e[23]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(La,{iconName:_1,size:"sm"}),e[23]=C):C=e[23];let I;e[24]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[n.jsx("span",{className:"text-sm",children:"Always"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"Target all users"})]}),e[24]=I):I=e[24];let E;e[25]!==T||e[26]!==k?(E=n.jsxs(Xs,{value:"always Target all users",onSelect:T,className:k,children:[C,I]}),e[25]=T,e[26]=k,e[27]=E):E=e[27];let O;if(e[28]!==r||e[29]!==s||e[30]!==L||e[31]!==o){let $;e[33]!==r||e[34]!==s||e[35]!==L?($=V=>n.jsxs(Xs,{value:`${V.title} ${V.resolveType} ${V.description??""}`,onSelect:()=>L(V.resolveType),className:ce("gap-2.5",!r&&s===V.resolveType&&"bg-accent/60"),children:[n.jsx(La,{iconName:V.iconName,size:"sm"}),n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[n.jsx("span",{className:"text-sm",children:V.title}),V.description&&n.jsx("span",{className:"truncate text-xs text-muted-foreground",children:V.description})]})]},V.resolveType),e[33]=r,e[34]=s,e[35]=L,e[36]=$):$=e[36],O=o.map($),e[28]=r,e[29]=s,e[30]=L,e[31]=o,e[32]=O}else O=e[32];let P;e[37]!==E||e[38]!==O?(P=n.jsxs(Si,{children:[E,O]}),e[37]=E,e[38]=O,e[39]=P):P=e[39];let D;e[40]!==r||e[41]!==d||e[42]!==y?(D=d.length>0&&n.jsx(Si,{heading:"Saved rules",children:d.map($=>n.jsxs(Xs,{value:`${$.title} ${$.blockKey} ${$.description??""}`,onSelect:()=>y($.blockKey),className:ce("gap-2.5",r===$.blockKey&&"bg-accent/60"),children:[n.jsx(La,{iconName:$.iconName,size:"sm"}),n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[n.jsx("span",{className:"truncate text-sm",children:$.title}),$.description&&n.jsx("span",{className:"truncate text-xs text-muted-foreground",children:$.description})]})]},$.blockKey))}),e[40]=r,e[41]=d,e[42]=y,e[43]=D):D=e[43];let M;e[44]!==P||e[45]!==D?(M=n.jsxs(dr,{children:[N,P,D]}),e[44]=P,e[45]=D,e[46]=M):M=e[46];let z;e[47]!==h||e[48]!==u||e[49]!==M?(z=n.jsxs(E3,{open:h,onOpenChange:u,title:"Choose a rule",description:"Pick how to target users for this variant",className:"sm:max-w-lg",children:[j,M]}),e[47]=h,e[48]=u,e[49]=M,e[50]=z):z=e[50];let F;return e[51]!==z||e[52]!==w?(F=n.jsxs(n.Fragment,{children:[w,z]}),e[51]=z,e[52]=w,e[53]=F):F=e[53],F}function dv(t){if(!t||typeof t!="object")return!1;const e=t;return typeof e.__resolveType=="string"&&Array.isArray(e.variants)}function hv(t,e){return{__resolveType:e,variants:[{rule:tn(),value:structuredClone(t)},{rule:tn(),value:structuredClone(t)}]}}function uv(t){const e=t.variants;if(e.length===0)return;const s=e.find(i=>Ac(i.rule));return s?s.value:e[e.length-1]?.value}function fv(t){const e=[...t.variants],s=e[e.length-1],i={rule:tn(),value:s?structuredClone(s.value):void 0};return{...t,variants:[...e,i]}}function mv(t,e){if(t.variants.length<=1)return null;const s=[...t.variants];return s.splice(e,1),{...t,variants:s}}function pv(t,e){const s=[...t.variants],i=s[e];return i?(s.splice(e+1,0,structuredClone(i)),{...t,variants:s}):t}function gv(t,e,s){const i=[...t.variants];if(e===s||e<0||s<0||e>=i.length||s>=i.length)return t;const[r]=i.splice(e,1);return r?(i.splice(s,0,r),{...t,variants:i}):t}function _v(t,e,s){const i=[...t.variants],r=i[e];return r?(i[e]={...r,value:s},{...t,variants:i}):t}function o0(t,e,s){const i=[...t.variants],r=i[e];return r?(i[e]={...r,rule:s},{...t,variants:i}):t}const a0=new WeakMap,l0=new Map;function Lv(t){let e=a0.get(t);return e||(e=av(t),a0.set(t,e)),e}function vv(t,e){let s=l0.get(t);return s===void 0&&(s=Bs(t,e),l0.set(t,s)),s}function xv(t){const e=U.c(3),{multivariateResolveType:s,renderInnerField:i,...r}=t,{value:o,onChange:a,meta:l,path:c}=r,[d,h]=R.useState(0);if(!dv(o)){let P;e[0]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx(Id,{size:14}),e[0]=P):P=e[0];let D;return e[1]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx(Ae,{children:"Add variant"}),e[1]=D):D=e[1],n.jsxs("div",{className:"relative grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-2",children:[n.jsxs(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsx(re,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 size-6 text-muted-foreground hover:text-foreground","aria-label":"Add variant",onClick:()=>{a(hv(o,s)),h(0)},children:P})}),D]}),i(r)]})}const u=o,f=u.variants,m=Math.min(d,f.length-1),p=f.map(yv),g=f[m],L=g?.rule??{},v=L.__resolveType??"",y=g?.value,_=l?Lv(l):[],x=v&&l?vv(v,l):null,{__resolveType:b,...S}=L,w=()=>{a(uv(u)),h(0)},j=()=>{const P=fv(u);a(P),h(P.variants.length-1)},N=P=>{const D=mv(u,P);D&&(a(D),m>=D.variants.length&&h(D.variants.length-1))},T=P=>{const D=pv(u,P);a(D),h(P+1)},A=(P,D)=>{const M=gv(u,P,D);a(M),m===P&&h(D)},k=P=>{a(o0(u,m,P?{__resolveType:P}:{__resolveType:$h}))},C=P=>{const D=P,M=v?{...D,__resolveType:v}:{...D};a(o0(u,m,M))},I=P=>{a(_v(u,m,P))},E=`${c}-${u.__resolveType}`;let O;return e[2]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(Ve,{className:"text-xs text-muted-foreground",children:"Rule"}),e[2]=O):O=e[2],n.jsxs("div",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-0",children:[n.jsx(Q8,{listKey:E,variants:p,selectedIndex:m,onSelect:h,onDuplicate:T,onDelete:N,onRemoveAll:w,onReorder:A,onAdd:j}),n.jsxs("div",{className:"space-y-4 px-2 pt-3",children:[n.jsxs("div",{className:"space-y-1.5",children:[O,n.jsx(cv,{currentRt:v,currentLabel:Yo(L),matchers:_,onSelect:k}),x&&n.jsx("div",{className:"pt-1",children:n.jsx(ai,{schema:x,value:S,onChange:C,basePath:""})})]}),i({...r,value:y,onChange:I})]})]})}function yv(t,e){return{index:e,label:Yo(t.rule)||`Variant ${e+1}`}}const bv="website/loaders/secret.ts";function Kn(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t.__resolveType;return typeof e=="string"&&(e.endsWith("/secret.ts")||e.includes("loaders/secret"))}function Sv(){return{__resolveType:bv,name:"",encrypted:""}}function wv(t){const{value:e,...s}=t;return s}function va(t){const e=U.c(45),{schema:s,value:i,onChange:r,label:o,path:a}=t;if(typeof i=="string"||i==null&&!Kn(i)){const w=typeof i=="string"?i:"";let j;e[0]!==o||e[1]!==a?(j=n.jsx(Ve,{htmlFor:a,className:"text-sm font-medium",children:o}),e[0]=o,e[1]=a,e[2]=j):j=e[2];let N;e[3]!==s.description?(N=s.description&&n.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[3]=s.description,e[4]=N):N=e[4];let T;e[5]!==r?(T=C=>r(C.target.value),e[5]=r,e[6]=T):T=e[6];let A;e[7]!==a||e[8]!==w||e[9]!==T?(A=n.jsx(Ke,{id:a,type:"password",value:w,autoComplete:"new-password",autoCorrect:"off",spellCheck:!1,placeholder:"Secret value",onChange:T,className:"h-10"}),e[7]=a,e[8]=w,e[9]=T,e[10]=A):A=e[10];let k;return e[11]!==j||e[12]!==N||e[13]!==A?(k=n.jsxs("div",{className:"space-y-2",children:[j,N,A]}),e[11]=j,e[12]=N,e[13]=A,e[14]=k):k=e[14],k}let l;e[15]!==i?(l=Kn(i)?i:Sv(),e[15]=i,e[16]=l):l=e[16];const c=l,d=typeof c.name=="string"?c.name:"",h=typeof c.encrypted=="string"&&c.encrypted,u=`${a}-name`;let f;e[17]!==o||e[18]!==u?(f=n.jsx(Ve,{htmlFor:u,className:"text-sm font-medium",children:o}),e[17]=o,e[18]=u,e[19]=f):f=e[19];let m;e[20]!==s.description?(m=s.description&&n.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[20]=s.description,e[21]=m):m=e[21];const p=`${a}-name`;let g;e[22]!==c||e[23]!==r?(g=w=>r({...c,name:w.target.value}),e[22]=c,e[23]=r,e[24]=g):g=e[24];let L;e[25]!==d||e[26]!==p||e[27]!==g?(L=n.jsx(Ke,{id:p,value:d,placeholder:"Secret name",onChange:g,className:"h-10"}),e[25]=d,e[26]=p,e[27]=g,e[28]=L):L=e[28];const v=`${a}-value`,y=h?"Leave blank to keep current value":"Secret value";let _;e[29]!==c||e[30]!==h||e[31]!==r?(_=w=>{const j=w.target.value;if(!j){r(h?wv(c):c);return}r({...c,value:j})},e[29]=c,e[30]=h,e[31]=r,e[32]=_):_=e[32];let x;e[33]!==_||e[34]!==v||e[35]!==y?(x=n.jsx(Ke,{id:v,type:"password",autoComplete:"new-password",autoCorrect:"off",spellCheck:!1,placeholder:y,onChange:_,className:"h-10"}),e[33]=_,e[34]=v,e[35]=y,e[36]=x):x=e[36];let b;e[37]!==h?(b=h&&n.jsx("p",{className:"text-xs text-muted-foreground",children:"A secret value is stored."}),e[37]=h,e[38]=b):b=e[38];let S;return e[39]!==x||e[40]!==b||e[41]!==f||e[42]!==m||e[43]!==L?(S=n.jsxs("div",{className:"space-y-2",children:[f,m,L,x,b]}),e[39]=x,e[40]=b,e[41]=f,e[42]=m,e[43]=L,e[44]=S):S=e[44],S}function Cv(t){const e=t.length>0?t[0]:void 0;if(e==null||typeof e!="object"||Array.isArray(e))return;const s={};for(const[i,r]of Object.entries(e))i.startsWith("__")||(typeof r=="string"?s[i]={type:"string"}:typeof r=="number"?s[i]={type:"number"}:typeof r=="boolean"&&(s[i]={type:"boolean"}));return Object.keys(s).length>0?{type:"object",properties:s}:void 0}const jv=new Set(["__resolveType","@type"]);function kv(t){if(t.type!=="block-ref"||!t.anyOfRefs?.length||t.anyOfRefs.length!==1)return!1;const e=t.anyOfRefs[0].schema;return!!(e?.properties?.variants||!e&&t.plainSchema)}function Nv(t){if(Uo(t))for(const e of t.anyOfRefs??[]){const r=e.schema?.properties?.variants?.items?.properties?.value;if(r?.type==="array"&&r.items)return r.items}}function c0(t){if(t.type==="array"&&t.items)return t;const e=t.items??Nv(t);return e?{...t,type:"array",items:e}:null}function Tv(t,e){if(e!==void 0)return e;switch(t){case"string":return"";case"number":case"integer":return 0;case"boolean":return!1;case"array":return[];case"object":return{};default:return null}}function Fc(t){const{schema:e,value:s}=t;if(_o(s)){const a=I_(s),l=c0(e);if(a!==null&&l)return n.jsx(Tr,{...t,schema:l,value:a,onChange:c=>t.onChange(O_(s,c))},t.path)}if(Array.isArray(s)&&e.type==="block-ref"&&Uo(e)){const a=c0(e);if(a)return n.jsx(Tr,{...t,schema:a,value:s,onChange:t.onChange},t.path)}if(Array.isArray(s)&&!_o(s)&&e.type==="block-ref"){const a=Cv(s);if(a){const l={...e,type:"array",items:a};return n.jsx(Tr,{...t,schema:l,value:s,onChange:t.onChange},t.path)}}if(e.type==="block-ref"||s!==null&&typeof s=="object"&&!Array.isArray(s)&&typeof s.__resolveType=="string"&&e.anyOfRefs){if(kv(e)){const a=e.anyOfRefs[0],l=a.schema?.properties?.variants?.items?.properties?.value,c=l&&l.type!=="block-ref"?l:e.plainSchema??l?.plainSchema??{type:"string"},d=h=>Fc({...h,schema:c});return n.jsx(xv,{...t,multivariateResolveType:a.resolveType,renderInnerField:d},t.path)}return e.anyOfRefs?n.jsx(Z9,{...t},t.path):null}if(e.type==="inline-union")return n.jsx($8,{...t},t.path);if(e.format==="image-uri")return n.jsx(w8,{...t},t.path);if(e.format==="file-uri"||e.format==="video-uri")return n.jsx(v8,{...t},t.path);if(e.format==="map")return n.jsx(W8,{...t},t.path);if(e.format==="dynamic-options"&&e.options)return n.jsx(JL,{...t},t.path);if(e.format==="location")return n.jsx(m1,{...t},t.path);if(e.enum&&e.enum.length>0)return n.jsx(oL,{...t},t.path);if(e.type==="anyOf")return n.jsx(Z9,{...t},t.path);if(Kn(s)||e.format==="password"||s==null&&e.format==="password")return n.jsx(va,{...t},t.path);const i=s??Tv(e.type,e.default);if(i==null)return Kn(s)?n.jsx(va,{...t},t.path):null;if(Kn(i))return n.jsx(va,{...t,value:i},t.path);const r={...t,value:i},o=s==null?e.type??typeof i:Array.isArray(i)?"array":typeof i;if(o==="array"||Array.isArray(i))return n.jsx(Tr,{...r},t.path);switch(o){case"boolean":return n.jsx(sL,{...r},t.path);case"number":case"integer":return n.jsx(tL,{...r},t.path);case"string":{const a=e.format;return a==="color-input"||a==="color"?n.jsx(kr,{...r},t.path):a==="textarea"||a==="rich-text"||a==="html"?n.jsx(kr,{...r},t.path):n.jsx(kr,{...r},t.path)}case"object":return i!==null&&typeof i=="object"&&!Array.isArray(i)?n.jsx(BL,{...r},t.path):null;default:return n.jsx(kr,{...r},t.path)}}function ai(t){const e=U.c(16),{schema:s,value:i,onChange:r,basePath:o,breadcrumbPath:a,onBreadcrumbChange:l,meta:c,decofile:d,onSaveReferencedBlock:h,previewBaseUrl:u,onAddSectionItem:f,onRequestAddSection:m,sandbox:p}=t;let g,L;if(e[0]!==o||e[1]!==d||e[2]!==c||e[3]!==f||e[4]!==l||e[5]!==r||e[6]!==m||e[7]!==h||e[8]!==u||e[9]!==p||e[10]!==s.properties||e[11]!==a||e[12]!==i){L=Symbol.for("react.early_return_sentinel");e:{const v=a===void 0?[]:a,y=s.properties;if(!y){L=null;break e}const _=i!=null&&typeof i=="object"&&!Array.isArray(i)?i:{},x=Object.keys(y).filter(C=>!jv.has(C)&&y[C]?.hidden!==!0);if(x.length===0){let C;e[15]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"No editable fields on this section."}),e[15]=C):C=e[15],L=C;break e}const b=(C,I)=>{r({..._,[C]:I})},S=typeof _.__resolveType=="string"?_.__resolveType:void 0,w=v.length>0?SL(x,y,_,v):null,j=w?y[w]:null,N=w&&j?[w]:x,T=w&&j?yL(w,j,v):v,A=xL(v,T),k=A.length>0&&l?C=>l([...A,...C]):l;g=n.jsx("div",{className:"min-w-0 space-y-6",children:N.map(C=>{const I=y[C];if(!I)return null;const E=o?`${o}.${C}`:C,O=Un(C,I);return Fc({schema:I,value:_[C],onChange:P=>b(C,P),path:E,label:O,breadcrumbPath:T,onBreadcrumbChange:k,meta:c,decofile:d,onSaveReferencedBlock:h,containerResolveType:S,previewBaseUrl:u,onAddSectionItem:f,onRequestAddSection:m,sandbox:p})})})}e[0]=o,e[1]=d,e[2]=c,e[3]=f,e[4]=l,e[5]=r,e[6]=m,e[7]=h,e[8]=u,e[9]=p,e[10]=s.properties,e[11]=a,e[12]=i,e[13]=g,e[14]=L}else g=e[13],L=e[14];return L!==Symbol.for("react.early_return_sentinel")?L:g}function L1(t){const e=U.c(37),{open:s,onOpenChange:i,defaultBlockId:r,isPending:o,onSubmit:a}=t,l=r===void 0?"":r,c=o===void 0?!1:o,[d,h]=R.useState(l),[u,f]=R.useState(s);s!==u&&(f(s),s&&h(l));let m;e[0]!==c||e[1]!==i?(m=C=>{!C&&!c&&i(!1)},e[0]=c,e[1]=i,e[2]=m):m=e[2];const p=m;let g;e[3]!==d||e[4]!==c||e[5]!==a?(g=async C=>{C.preventDefault();const I=d.trim();!I||c||await a(I)},e[3]=d,e[4]=c,e[5]=a,e[6]=g):g=e[6];const L=g;let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsxs(_s,{children:[n.jsx(Ls,{children:"Save as global"}),n.jsx(or,{children:"Save this section as a global block so it can be reused on other pages."})]}),e[7]=v):v=e[7];let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx("label",{htmlFor:"block-id",className:"text-sm font-medium",children:"Block name"}),e[8]=y):y=e[8];let _;e[9]===Symbol.for("react.memo_cache_sentinel")?(_=C=>h(C.target.value),e[9]=_):_=e[9];let x;e[10]!==d||e[11]!==c?(x=n.jsxs("div",{className:"py-4 space-y-2",children:[y,n.jsx(Ke,{id:"block-id",value:d,onChange:_,placeholder:"MyNewBlock",autoFocus:!0,disabled:c})]}),e[10]=d,e[11]=c,e[12]=x):x=e[12];let b;e[13]!==i?(b=()=>i(!1),e[13]=i,e[14]=b):b=e[14];let S;e[15]!==c||e[16]!==b?(S=n.jsx(re,{type:"button",variant:"outline",onClick:b,disabled:c,children:"Cancel"}),e[15]=c,e[16]=b,e[17]=S):S=e[17];let w;e[18]!==d||e[19]!==c?(w=!d.trim()||c,e[18]=d,e[19]=c,e[20]=w):w=e[20];let j;e[21]!==c?(j=c?n.jsxs(n.Fragment,{children:[n.jsx(Ue,{size:14,className:"animate-spin"}),"Saving…"]}):"Save",e[21]=c,e[22]=j):j=e[22];let N;e[23]!==w||e[24]!==j?(N=n.jsx(re,{type:"submit",disabled:w,children:j}),e[23]=w,e[24]=j,e[25]=N):N=e[25];let T;e[26]!==S||e[27]!==N?(T=n.jsxs(Di,{children:[S,N]}),e[26]=S,e[27]=N,e[28]=T):T=e[28];let A;e[29]!==L||e[30]!==T||e[31]!==x?(A=n.jsx(qt,{className:"sm:max-w-md",children:n.jsxs("form",{onSubmit:L,children:[v,x,T]})}),e[29]=L,e[30]=T,e[31]=x,e[32]=A):A=e[32];let k;return e[33]!==p||e[34]!==s||e[35]!==A?(k=n.jsx(Gt,{open:s,onOpenChange:p,children:A}),e[33]=p,e[34]=s,e[35]=A,e[36]=k):k=e[36],k}function Ev(t){const e=U.c(60),{orgSlug:s,virtualMcpId:i,branch:r,previewUrl:o,meta:a,decofile:l,resolveType:c,title:d,defaultBlockId:h,isCreating:u,onCreate:f,onSaveReferencedBlock:m}=t,p=li(),g=p?.entity?.id===i?p.entity.metadata?.siteSlug??null:null;let L;e[0]===Symbol.for("react.memo_cache_sentinel")?(L={},e[0]=L):L=e[0];const[v,y]=R.useState(L);let _;e[1]===Symbol.for("react.memo_cache_sentinel")?(_=[],e[1]=_):_=e[1];const[x,b]=R.useState(_),[S,w]=R.useState(0),[j,N]=R.useState(!1);let T;e[2]!==a||e[3]!==c?(T=Bs(c,a),e[2]=a,e[3]=c,e[4]=T):T=e[4];const A=T;let k;e[5]!==c?(k=c.split("/").pop()?.replace(/\.tsx?$/,"")??c,e[5]=c,e[6]=k):k=e[6];const C=k,I=o??void 0;let E;e[7]!==g||e[8]!==r||e[9]!==s||e[10]!==I||e[11]!==i?(E={orgSlug:s,virtualMcpId:i,branch:r,previewUrl:I,siteSlug:g},e[7]=g,e[8]=r,e[9]=s,e[10]=I,e[11]=i,e[12]=E):E=e[12];const O=E;let P;e[13]!==x||e[14]!==d?(P=[d,...x],e[13]=x,e[14]=d,e[15]=P):P=e[15];const D=P;let M;e[16]!==x?(M=oe=>{b(x.slice(0,oe)),w(Av)},e[16]=x,e[17]=M):M=e[17];const z=M;let F;e[18]!==l||e[19]!==v||e[20]!==f?(F=async oe=>{const ue=Xu(oe,l);if(ue){me.error(ue);return}await f(oe,v),N(!1)},e[18]=l,e[19]=v,e[20]=f,e[21]=F):F=e[21];const $=F;let V;e[22]!==z||e[23]!==D?(V=n.jsx("nav",{"aria-label":"Editing breadcrumb",className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:D.map((oe,ue)=>{const ee=ue===D.length-1;return n.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[ue>0&&n.jsx(Ms,{className:"size-3 shrink-0 text-muted-foreground/60"}),n.jsx("button",{type:"button",onClick:()=>z(ue),title:oe,className:ce("min-w-0 truncate rounded-md px-1 py-0.5 text-left transition-colors hover:bg-accent hover:text-accent-foreground",ee?"font-medium text-foreground":"text-muted-foreground"),children:oe})]},`${oe}-${ue}`)})}),e[22]=z,e[23]=D,e[24]=V):V=e[24];let J;e[25]===Symbol.for("react.memo_cache_sentinel")?(J=()=>N(!0),e[25]=J):J=e[25];let Z;e[26]===Symbol.for("react.memo_cache_sentinel")?(Z=n.jsx(Hl,{size:14}),e[26]=Z):Z=e[26];let G;e[27]!==u?(G=n.jsx(Ee,{asChild:!0,children:n.jsx(re,{size:"icon",className:"size-8 shrink-0",disabled:u,onClick:J,"aria-label":"Save as global section",children:Z})}),e[27]=u,e[28]=G):G=e[28];let q;e[29]===Symbol.for("react.memo_cache_sentinel")?(q=n.jsx(Ae,{side:"bottom",children:"Save as global section"}),e[29]=q):q=e[29];let H;e[30]!==G?(H=n.jsxs(Pe,{children:[G,q]}),e[30]=G,e[31]=H):H=e[31];let K;e[32]!==V||e[33]!==H?(K=n.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[V,H]}),e[32]=V,e[33]=H,e[34]=K):K=e[34];let B;e[35]!==C?(B=n.jsxs("p",{className:"mt-1.5 py-1 pl-1 text-sm leading-snug text-muted-foreground",children:[C," — edits stay local until you save this as a global section."]}),e[35]=C,e[36]=B):B=e[36];let X;e[37]!==K||e[38]!==B?(X=n.jsxs("div",{className:"shrink-0 border-b px-3 py-2.5",children:[K,B]}),e[37]=K,e[38]=B,e[39]=X):X=e[39];let W;e[40]!==l||e[41]!==x||e[42]!==S||e[43]!==v||e[44]!==a||e[45]!==m||e[46]!==O||e[47]!==A?(W=n.jsx(ni,{className:"min-h-0 flex-1 [&_[data-slot=scroll-area-viewport]>div]:!block",children:n.jsx("div",{className:"min-w-0 max-w-full overflow-x-hidden px-6 py-4",children:n.jsx("div",{className:"mx-auto max-w-2xl",children:A?n.jsx(ai,{schema:A,value:v,onChange:oe=>y(oe),basePath:"",breadcrumbPath:x,onBreadcrumbChange:b,meta:a,decofile:l,onSaveReferencedBlock:m,sandbox:O},S):n.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"No editable fields for this section."})})})}),e[40]=l,e[41]=x,e[42]=S,e[43]=v,e[44]=a,e[45]=m,e[46]=O,e[47]=A,e[48]=W):W=e[48];let Y;e[49]!==X||e[50]!==W?(Y=n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[X,W]}),e[49]=X,e[50]=W,e[51]=Y):Y=e[51];let Q;e[52]!==h||e[53]!==$||e[54]!==u||e[55]!==j?(Q=n.jsx(L1,{open:j,onOpenChange:N,defaultBlockId:h,isPending:u,onSubmit:$}),e[52]=h,e[53]=$,e[54]=u,e[55]=j,e[56]=Q):Q=e[56];let ie;return e[57]!==Y||e[58]!==Q?(ie=n.jsxs("div",{className:"flex h-full w-full min-w-0",children:[Y,Q]}),e[57]=Y,e[58]=Q,e[59]=ie):ie=e[59],ie}function Av(t){return t+1}function Pv(t,e){const s={__resolveType:t},i=Ru([s],e)[0];return i?FL(s,i,e):null}function Rv({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i,meta:r,decofile:o,blockKey:a,onSaveReferencedBlock:l}){const c=li(),d=c?.entity?.id===e?c.entity.metadata?.siteSlug??null:null,[h]=R.useState(()=>Pv(a,o)),[u,f]=R.useState(h?.data??{}),[m,p]=R.useState([]),[g,L]=R.useState(0),[v,y]=R.useState(!1),[_,x]=R.useState(null),b=_!==null,{save:S,flush:w}=Fu({orgSlug:t,virtualMcpId:e,branch:s}),j=h?.resolveType?Bs(h.resolveType,r):null,N=o[a],T=N?zo(a,N):a,A={orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i??void 0,siteSlug:d},k=P=>{f(P),S(a,P)},C=()=>{b?(x(null),y(!1),L(P=>P+1)):x(JSON.stringify(u,null,2))},I=P=>{const D=P??"";try{const M=JSON.parse(D);if(M&&typeof M=="object"&&!Array.isArray(M)){y(!1),k(M);return}y(!0)}catch{y(!0)}},E=[T,...m],O=P=>{p(m.slice(0,P)),L(D=>D+1)};return n.jsx("div",{className:"flex h-full w-full min-w-0",children:n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[n.jsxs("div",{className:"shrink-0 border-b px-3 py-2.5",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[n.jsx("span",{className:"size-2 shrink-0 rounded-full",style:{backgroundColor:pc},"aria-hidden":!0}),n.jsx("nav",{"aria-label":"Editing breadcrumb",className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:E.map((P,D)=>{const M=D===E.length-1;return n.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[D>0&&n.jsx(Ms,{className:"size-3 shrink-0 text-muted-foreground/60"}),n.jsx("button",{type:"button",onClick:()=>O(D),title:P,className:ce("min-w-0 truncate rounded-md px-1 py-0.5 text-left transition-colors hover:bg-accent hover:text-accent-foreground",M?"font-medium text-foreground":"text-muted-foreground"),children:P})]},`${P}-${D}`)})}),n.jsxs(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsx(re,{variant:b?"default":"ghost",size:"icon",className:"size-8 shrink-0",onClick:C,"aria-label":b?"Close JSON editor":"Edit as JSON","aria-pressed":b,children:b?n.jsx(dn,{size:14}):n.jsx(nr,{size:14})})}),n.jsx(Ae,{side:"bottom",children:b?"Close JSON editor":"Edit as JSON"})]})]}),n.jsx("p",{className:"mt-1.5 py-1 pl-1 text-sm leading-snug text-muted-foreground",children:"Global section — changes save automatically and apply everywhere it's used."})]}),n.jsxs("div",{className:"relative min-h-0 flex-1",children:[n.jsx(ni,{className:"h-full [&_[data-slot=scroll-area-viewport]>div]:!block",children:n.jsx("div",{className:"min-w-0 max-w-full overflow-x-hidden px-6 py-4",children:n.jsx("div",{className:"mx-auto max-w-2xl",children:j?n.jsx(ai,{schema:j,value:u,onChange:P=>k(P),basePath:"",breadcrumbPath:m,onBreadcrumbChange:p,meta:r,decofile:o,onSaveReferencedBlock:l,sandbox:A},g):n.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"No editable fields for this section."})})})}),_!==null&&n.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[v&&n.jsx("div",{className:"shrink-0 border-b bg-destructive/10 px-3 py-1.5 text-xs text-destructive",children:"Invalid JSON — changes aren't saved until it parses."}),n.jsx("div",{className:"min-h-0 flex-1",children:n.jsx(Mo,{language:"json",height:"100%",code:_,onChange:I,onSave:P=>{I(P),w()}})})]})]})]})})}function d0(t,e){const s=e.replace(/\s*\(copy(?:\s+\d+)?\)\s*$/,"").trim(),i=`${s} (copy)`;if(!t.has(i))return i;for(let r=2;r<1e3;r++){const o=`${s} (copy ${r})`;if(!t.has(o))return o}return`${s} (copy ${Date.now()})`}function Dv(t,e){const s=qi,i=e.replace(/-copy(?:-\d+)?$/,""),r=`${i}-copy`;if(!t.has(s(r)))return r;for(let o=2;o<1e3;o++){const a=`${i}-copy-${o}`;if(!t.has(s(a)))return a}return`${i}-copy-${Date.now()}`}function Iv(t,e){const s=e.replace(/_copy(?:_\d+)?$/,""),i=`${s}_copy`;if(!Object.hasOwn(t,i))return i;for(let r=2;r<1e3;r++){const o=`${s}_copy_${r}`;if(!Object.hasOwn(t,o))return o}return`${s}_copy_${Date.now()}`}function Ov(t){const e=Pc(t.newName),s={...t.source,name:t.newName,path:t.newPath};return{key:e,data:s}}function Mv(t,e){return zu(t,e)}const Bv=1e3;function $v(t,e){for(let s=0;s<Bv;s++){const i=Pc(e);if(!Object.hasOwn(t,i))return i}throw new Error("Could not generate a unique page block key")}const zv={create:"Create new page",duplicate:"Duplicate page",rename:"Rename page"},Fv={create:"Create",duplicate:"Duplicate",rename:"Save"},Hv={create:"Creating…",duplicate:"Duplicating…",rename:"Saving…"};function Uv(t){const e=U.c(62),{open:s,mode:i,initialName:r,initialPath:o,isPending:a,error:l,templates:c,validate:d,onSubmit:h,onOpenChange:u}=t,f=a===void 0?!1:a,[m,p]=R.useState(r),[g,L]=R.useState(o),[v,y]=R.useState(Zs),[_,x]=R.useState(null),[b,S]=R.useState(s);s!==b&&(S(s),s&&(p(r),L(o),y(Zs),x(null)));const w=i==="create"&&!!c?.length;let j;e[0]!==f||e[1]!==u?(j=W=>{!W&&!f&&(x(null),u(!1))},e[0]=f,e[1]=u,e[2]=j):j=e[2];const N=j;let T;e[3]!==f||e[4]!==m||e[5]!==h||e[6]!==g||e[7]!==w||e[8]!==v||e[9]!==d?(T=async W=>{W.preventDefault();const Y=m.trim(),Q=g.trim();if(!Y||!Q||f)return;const ie=vc(Q);if(ie){x(ie);return}const oe=d?.({name:Y,path:Q});if(oe){x(oe);return}x(null),await h({name:Y,path:Q,templateKey:w&&v!==Zs?v:null})},e[3]=f,e[4]=m,e[5]=h,e[6]=g,e[7]=w,e[8]=v,e[9]=d,e[10]=T):T=e[10];const A=T,k=_??l,C=zv[i];let I;e[11]!==C?(I=n.jsx(_s,{children:n.jsx(Ls,{children:C})}),e[11]=C,e[12]=I):I=e[12];let E;e[13]!==f||e[14]!==w||e[15]!==v||e[16]!==c?(E=w&&n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("label",{htmlFor:"page-form-template",className:"text-xs font-medium text-muted-foreground",children:"Template"}),n.jsx(Hu,{id:"page-form-template",value:v,onChange:y,templates:c??[],disabled:f})]}),e[13]=f,e[14]=w,e[15]=v,e[16]=c,e[17]=E):E=e[17];let O;e[18]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx("label",{htmlFor:"page-form-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[18]=O):O=e[18];let P;e[19]===Symbol.for("react.memo_cache_sentinel")?(P=W=>p(W.target.value),e[19]=P):P=e[19];let D;e[20]!==f||e[21]!==m?(D=n.jsxs("div",{className:"space-y-1.5",children:[O,n.jsx(Ke,{id:"page-form-name",value:m,onChange:P,placeholder:"My page",autoFocus:!0,disabled:f})]}),e[20]=f,e[21]=m,e[22]=D):D=e[22];let M;e[23]===Symbol.for("react.memo_cache_sentinel")?(M=n.jsx("label",{htmlFor:"page-form-path",className:"text-xs font-medium text-muted-foreground",children:"Path"}),e[23]=M):M=e[23];let z;e[24]===Symbol.for("react.memo_cache_sentinel")?(z=W=>L(W.target.value),e[24]=z):z=e[24];let F;e[25]!==f||e[26]!==g?(F=n.jsxs("div",{className:"space-y-1.5",children:[M,n.jsx(Ke,{id:"page-form-path",value:g,onChange:z,placeholder:"/example",disabled:f})]}),e[25]=f,e[26]=g,e[27]=F):F=e[27];let $;e[28]!==k?($=k&&n.jsx("p",{className:"text-xs text-destructive",children:k}),e[28]=k,e[29]=$):$=e[29];let V;e[30]!==F||e[31]!==$||e[32]!==E||e[33]!==D?(V=n.jsxs("div",{className:"space-y-4 py-4",children:[E,D,F,$]}),e[30]=F,e[31]=$,e[32]=E,e[33]=D,e[34]=V):V=e[34];let J;e[35]!==u?(J=()=>u(!1),e[35]=u,e[36]=J):J=e[36];let Z;e[37]!==f||e[38]!==J?(Z=n.jsx(re,{type:"button",variant:"outline",onClick:J,disabled:f,children:"Cancel"}),e[37]=f,e[38]=J,e[39]=Z):Z=e[39];let G;e[40]!==f||e[41]!==m||e[42]!==g?(G=!m.trim()||!g.trim()||f,e[40]=f,e[41]=m,e[42]=g,e[43]=G):G=e[43];let q;e[44]!==f||e[45]!==i?(q=f?n.jsxs(n.Fragment,{children:[n.jsx(Ue,{size:14,className:"animate-spin"}),Hv[i]]}):Fv[i],e[44]=f,e[45]=i,e[46]=q):q=e[46];let H;e[47]!==G||e[48]!==q?(H=n.jsx(re,{type:"submit",disabled:G,children:q}),e[47]=G,e[48]=q,e[49]=H):H=e[49];let K;e[50]!==Z||e[51]!==H?(K=n.jsxs(Di,{children:[Z,H]}),e[50]=Z,e[51]=H,e[52]=K):K=e[52];let B;e[53]!==A||e[54]!==V||e[55]!==K||e[56]!==I?(B=n.jsx(qt,{className:"sm:max-w-md",children:n.jsxs("form",{onSubmit:A,children:[I,V,K]})}),e[53]=A,e[54]=V,e[55]=K,e[56]=I,e[57]=B):B=e[57];let X;return e[58]!==N||e[59]!==s||e[60]!==B?(X=n.jsx(Gt,{open:s,onOpenChange:N,children:B}),e[58]=N,e[59]=s,e[60]=B,e[61]=X):X=e[61],X}function Kv(t){const e=U.c(43),{open:s,blockKey:i,initialName:r,isPending:o,onSubmit:a,onOpenChange:l}=t,c=o===void 0?!1:o,[d,h]=R.useState(r),[u,f]=R.useState(s);s!==u&&(f(s),s&&h(r));let m;e[0]!==c||e[1]!==l?(m=O=>{!O&&!c&&l(!1)},e[0]=c,e[1]=l,e[2]=m):m=e[2];const p=m;let g;e[3]!==c||e[4]!==d||e[5]!==a?(g=async O=>{O.preventDefault();const P=d.trim();!P||c||await a(P)},e[3]=c,e[4]=d,e[5]=a,e[6]=g):g=e[6];const L=g;let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsxs(_s,{children:[n.jsx(Ls,{children:"Rename section"}),n.jsx(or,{children:"Updates the display name. The internal key stays the same so pages referencing this section keep working."})]}),e[7]=v):v=e[7];let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx("label",{htmlFor:"section-rename-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[8]=y):y=e[8];let _;e[9]===Symbol.for("react.memo_cache_sentinel")?(_=O=>h(O.target.value),e[9]=_):_=e[9];let x;e[10]!==c||e[11]!==d?(x=n.jsxs("div",{className:"space-y-1.5",children:[y,n.jsx(Ke,{id:"section-rename-name",value:d,onChange:_,autoFocus:!0,disabled:c})]}),e[10]=c,e[11]=d,e[12]=x):x=e[12];let b;e[13]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Key"}),e[13]=b):b=e[13];let S;e[14]!==i?(S=n.jsxs("div",{className:"space-y-1.5",children:[b,n.jsx(Ke,{value:i,readOnly:!0,disabled:!0,className:"font-mono"})]}),e[14]=i,e[15]=S):S=e[15];let w;e[16]!==x||e[17]!==S?(w=n.jsxs("div",{className:"space-y-4 py-4",children:[x,S]}),e[16]=x,e[17]=S,e[18]=w):w=e[18];let j;e[19]!==l?(j=()=>l(!1),e[19]=l,e[20]=j):j=e[20];let N;e[21]!==c||e[22]!==j?(N=n.jsx(re,{type:"button",variant:"outline",onClick:j,disabled:c,children:"Cancel"}),e[21]=c,e[22]=j,e[23]=N):N=e[23];let T;e[24]!==c||e[25]!==d?(T=!d.trim()||c,e[24]=c,e[25]=d,e[26]=T):T=e[26];let A;e[27]!==c?(A=c?n.jsxs(n.Fragment,{children:[n.jsx(Ue,{size:14,className:"animate-spin"}),"Saving…"]}):"Save",e[27]=c,e[28]=A):A=e[28];let k;e[29]!==T||e[30]!==A?(k=n.jsx(re,{type:"submit",disabled:T,children:A}),e[29]=T,e[30]=A,e[31]=k):k=e[31];let C;e[32]!==N||e[33]!==k?(C=n.jsxs(Di,{children:[N,k]}),e[32]=N,e[33]=k,e[34]=C):C=e[34];let I;e[35]!==L||e[36]!==w||e[37]!==C?(I=n.jsx(qt,{className:"sm:max-w-md",children:n.jsxs("form",{onSubmit:L,children:[v,w,C]})}),e[35]=L,e[36]=w,e[37]=C,e[38]=I):I=e[38];let E;return e[39]!==p||e[40]!==s||e[41]!==I?(E=n.jsx(Gt,{open:s,onOpenChange:p,children:I}),e[39]=p,e[40]=s,e[41]=I,e[42]=E):E=e[42],E}const xa={post:"blog/loaders/Blogpost.ts",author:"blog/loaders/Author.ts",category:"blog/loaders/Category.ts"},Hc=["posts","authors","categories"],Wn={posts:"post",authors:"author",categories:"category"};function Vn(t){return Hc.includes(t)}const Uc={posts:"post",authors:"author",categories:"category"},v1={posts:xa.post,authors:xa.author,categories:xa.category},Wv=Object.fromEntries(Object.entries(v1).map(([t,e])=>[e,t]));function Vv(t){return typeof t=="string"?Wv[t]??null:null}function sn(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function us(t){return typeof t=="string"?t:""}function Gv(t,e){switch(t){case"posts":return{label:us(e.title)||"Untitled post",subtitle:us(e.slug)};case"authors":return{label:us(e.name)||"Unnamed author",subtitle:us(e.email)};case"categories":return{label:us(e.name)||"Unnamed category",subtitle:us(e.slug)};default:{const s=t;throw new Error(`Unhandled blog kind: ${String(s)}`)}}}function x1(t){const e={posts:[],authors:[],categories:[]};for(const[s,i]of Object.entries(t)){const r=sn(i);if(!r)continue;const o=Vv(r.__resolveType);if(!o)continue;const a=sn(r[Uc[o]])??{},{label:l,subtitle:c}=Gv(o,a);e[o].push({key:s,kind:o,label:l,subtitle:c})}for(const s of Hc)e[s].sort((i,r)=>i.label.localeCompare(r.label));return e}function qv(t,e){return x1(t)[e]}function er(t,e){return qv(t,e).map(s=>({key:s.key,payload:Hr(sn(t[s.key])??void 0,e)}))}const h0=Object.freeze({});function Hr(t,e){return t?sn(t[Uc[e]])??h0:h0}function Ar(t,e,s){return{name:t,__resolveType:v1[e],[Uc[e]]:s}}function y1(t){return`.deco/blocks/${encodeURIComponent(t)}.json`}function nn(t){return Array.isArray(t)?t:[]}function Qs(t){if(typeof t=="string")return t;const e=sn(t);return e?us(e.slug):""}function Yv(t){if(typeof t=="string")return t;const e=sn(t);return e?us(e.email):""}function b1(t){return er(t,"posts").map(({key:e,payload:s})=>({key:e,title:us(s.title)||"Untitled post",slug:us(s.slug),date:us(s.date),categorySlugs:nn(s.categories).map(Qs).filter(Boolean),authorEmails:nn(s.authors).map(Yv).filter(Boolean)}))}function Jv(t,e){const s=nn(t.categories);return s.some(i=>Qs(i)===e.slug)?t:{...t,categories:[...s,{name:e.name,slug:e.slug}]}}function Xv(t,e){const s=nn(t.categories);return s.length===1&&Qs(s[0])===e.slug?t:{...t,categories:[{name:e.name,slug:e.slug}]}}function Vk(t,e,s){const i=nn(t.categories);if(!i.some(l=>Qs(l)===e))return t;const r=i.map(l=>{const c=Qs(l);return c===e||c===s.slug?{name:s.name,slug:s.slug}:l}),o=new Set,a=r.filter(l=>{const c=Qs(l);return c?o.has(c)?!1:(o.add(c),!0):!0});return{...t,categories:a}}function Zv(t,e){const s=nn(t.categories);return s.some(i=>Qs(i)===e)?{...t,categories:s.filter(i=>Qs(i)!==e)}:t}function Za(t){const e=new Uint8Array(Math.ceil(t/2));return crypto.getRandomValues(e),Array.from(e,s=>s.toString(16).padStart(2,"0")).join("").slice(0,t)}function u0(t,e){const s=`collections/blog/${e}/${Za(12)}`;if(!Object.hasOwn(t,s))return s;throw new Error("Could not generate a unique blog block key")}function Qv(t){switch(t){case"posts":return{title:"Untitled post",excerpt:"",slug:`untitled-${Za(8)}`,date:new Date().toISOString().slice(0,10),image:"",authors:[],categories:[],sections:[]};case"authors":return{name:"New author",email:"",jobTitle:"",company:"",avatar:""};case"categories":return{name:"New category",slug:`category-${Za(8)}`,description:"",sections:[]};default:{const e=t;throw new Error(`Unhandled blog kind: ${String(e)}`)}}}const ex={Paragraph:{title:"Paragraph",description:"Rich text content",iconName:"Pilcrow01"},Heading:{title:"Heading",description:"Section title (H1–H6)",iconName:"HeadingSquare"},Quote:{title:"Quote",description:"Pull quote",iconName:"MessageTextSquare02"},Code:{title:"Code",description:"Code block with syntax highlighting",iconName:"Code02"},List:{title:"List",description:"Bulleted or numbered list",iconName:"List"},BlockImage:{title:"Image",description:"Image with optional caption",iconName:"Image01"},Video:{title:"Video",description:"Embedded video",iconName:"PlayCircle"},Divider:{title:"Divider",description:"Horizontal divider",iconName:"Divider"},Cta:{title:"Call to action",description:"Button linking to a URL",iconName:"CursorClick01"},Callout:{title:"Callout",description:"Highlighted note, tip or warning",iconName:"Lightbulb02"},Stat:{title:"Stat",description:"Single key metric",iconName:"BarChartSquareUp"},StatGroup:{title:"Stat group",description:"Row of metrics",iconName:"BarChartSquare02"},CardGroup:{title:"Card group",description:"Grid of cards",iconName:"LayoutGrid01"},Checklist:{title:"Checklist",description:"List of check items",iconName:"CheckSquare"},Steps:{title:"Steps",description:"Step-by-step guide",iconName:"LayersThree01"},Comparison:{title:"Comparison",description:"Side-by-side comparison",iconName:"Columns03"},Table:{title:"Table",description:"Rows and columns of structured data",iconName:"Table"},ProductCard:{title:"Product card",description:"Single product",iconName:"Tag01"},ProductShelf:{title:"Product shelf",description:"Row of products",iconName:"ShoppingBag01"}},f0="Box";function tx(t){return t.startsWith("site/")?"site":"app"}function sx(t){return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("data:")||t.startsWith("/")}function yn(...t){for(const e of t)if(e!==void 0)return e}function Gk(t){const e=new Set,s=[],i=t.manifest?.blocks??{};for(const r of Object.values(i))for(const o of Object.keys(r)){if(!rx(o)||e.has(o))continue;e.add(o);const a=oi(o,t),l=ix(o),c=ex[l],d=tx(o),h=(d==="site"?yn(a.title,c?.title):yn(c?.title,a.title))??l,u=d==="site"?yn(a.description,c?.description):yn(c?.description,a.description),f=d==="site"?a.icon:void 0,m=f&&sx(f)?f:void 0,p=m!==void 0?c?.iconName??f0:yn(f,c?.iconName)??f0;s.push({resolveType:o,title:h,description:u,iconName:p,iconUrl:m,source:d})}return s.sort((r,o)=>r.title.localeCompare(o.title))}function ix(t){return(t.split("/").pop()??t).replace(/\.(tsx?|jsx?)$/,"")}const nx=["blog/sections/blocks/","site/sections/Blog/Post/"];function rx(t){return nx.some(e=>t.startsWith(e))}function S1({orgSlug:t,virtualMcpId:e,branch:s}){return Et.decofile(`${t}/${e}/${s}`)}function w1({orgSlug:t,virtualMcpId:e,branch:s},i){return`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/${i}`}function ox(t){const e=U.c(11),s=Ni();let i;e[0]!==t?(i=async l=>{const{blockKey:c,data:d}=l,h=await fetch(w1(t,"write"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:y1(c),content:JSON.stringify(d,null,2)})});if(!h.ok){const u=await h.json().catch(ax);throw new Error(u.error??`Write failed (${h.status})`)}return h.json()},e[0]=t,e[1]=i):i=e[1];let r;e[2]!==t||e[3]!==s?(r=async l=>{const{blockKey:c,data:d}=l,h=S1(t);await s.cancelQueries({queryKey:h});const u=s.getQueryData(h);return s.setQueryData(h,f=>({...f??{},[c]:d})),{previous:u,queryKey:h}},e[2]=t,e[3]=s,e[4]=r):r=e[4];let o;e[5]!==s?(o=(l,c,d)=>{d?.queryKey&&s.setQueryData(d.queryKey,d.previous)},e[5]=s,e[6]=o):o=e[6];let a;return e[7]!==i||e[8]!==r||e[9]!==o?(a={mutationFn:i,onMutate:r,onError:o},e[7]=i,e[8]=r,e[9]=o,e[10]=a):a=e[10],ii(a)}function ax(){return{}}function lx(t){const e=Ni();return ii({mutationFn:async({blockKey:s})=>{const i=await fetch(w1(t,"unlink"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:y1(s)})});if(!i.ok){const r=await i.json().catch(()=>({}));throw new Error(r.error??`Delete failed (${i.status})`)}return i.json()},onMutate:async({blockKey:s})=>{const i=S1(t);await e.cancelQueries({queryKey:i});const r=e.getQueryData(i);return e.setQueryData(i,o=>{if(!o)return o;const{[s]:a,...l}=o;return l}),{previous:r,queryKey:i}},onError:(s,i,r)=>{r?.queryKey&&e.setQueryData(r.queryKey,r.previous)}})}function cx(t){const e=U.c(20),{open:s,onOpenChange:i,pageKey:r,decofile:o}=t,[a,l]=R.useState(!1),c=o[r];let d;e[0]!==c?(d=c===void 0?"// Page not found.":JSON.stringify(c,null,2),e[0]=c,e[1]=d):d=e[1];const h=d;let u;e[2]!==h?(u=()=>{navigator.clipboard.writeText(h).then(()=>{l(!0),setTimeout(()=>l(!1),2e3)})},e[2]=h,e[3]=u):u=e[3];const f=u;let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(Ls,{className:"text-sm font-semibold",children:"Page JSON"}),e[4]=m):m=e[4];let p;e[5]!==a?(p=a?n.jsx(Td,{size:12}):n.jsx(ts,{size:12}),e[5]=a,e[6]=p):p=e[6];const g=a?"Copied":"Copy";let L;e[7]!==f||e[8]!==p||e[9]!==g?(L=n.jsxs(_s,{className:"px-4 py-3 border-b flex-row items-center justify-between space-y-0",children:[m,n.jsxs(re,{variant:"ghost",size:"sm",onClick:f,className:"h-7 gap-1.5 text-xs",children:[p,g]})]}),e[7]=f,e[8]=p,e[9]=g,e[10]=L):L=e[10];let v;e[11]!==h?(v=n.jsx(ni,{className:"max-h-[70vh]",children:n.jsx("pre",{className:"p-4 text-xs font-mono text-foreground/90 whitespace-pre overflow-auto",children:h})}),e[11]=h,e[12]=v):v=e[12];let y;e[13]!==L||e[14]!==v?(y=n.jsxs(qt,{className:"max-w-2xl p-0 gap-0",children:[L,v]}),e[13]=L,e[14]=v,e[15]=y):y=e[15];let _;return e[16]!==i||e[17]!==s||e[18]!==y?(_=n.jsx(Gt,{open:s,onOpenChange:i,children:y}),e[16]=i,e[17]=s,e[18]=y,e[19]=_):_=e[19],_}function dx(t){const e=U.c(3),{isPending:s,isError:i}=t;if(i){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-destructive",children:[n.jsx(Ei,{size:13}),"Couldn't save"]}),e[0]=o):o=e[0],o}if(s){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[n.jsx(Ue,{size:13,className:"animate-spin"}),"Saving…"]}),e[1]=o):o=e[1],o}let r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground/70",children:[n.jsx(Wt,{size:13}),"Saved"]}),e[2]=r):r=e[2],r}const hx={loaders:"loader",actions:"action"},C1=new Set(["workflows"]);function j1(t){return hx[t]}function ux(t,e,s){const i=t.manifest?.blocks??{};for(const[r,o]of Object.entries(i))if(r.includes(s)&&e in o)return!0;return!1}function fx(t,e){return/\.tsx?$/.test(t)?!1:e.has(`${t}.ts`)||e.has(`${t}.tsx`)}function k1(t,e){const s=t.manifest?.blocks??{},i=[],r=new Set;for(const[o,a]of Object.entries(s))if(o.includes(e))for(const l of Object.keys(a))r.add(l);for(const o of r){if(o.toLowerCase().includes("preview")||C1.has(Kc(o))||fx(o,r))continue;const a=oi(o,t);if(a.hidden)continue;const l=a.title&&a.title!==o?a.title:ut(o);i.push({resolveType:o,title:l})}return i.sort((o,a)=>o.title.localeCompare(a.title))}function m0(t,e){return k1(t,e).length}function Kc(t){return t.startsWith("deco-sites/")?t.split("/")[1]||"site":t.startsWith("$live")||t.startsWith("deco/")?"deco":t.split("/")[0]||"other"}const mx={deco:"Deco",std:"Deco Standard",website:"Website"};function px(t){return mx[t]??t}function N1(t){const e=Kc(t);let i=t.split("/").filter(Boolean).slice(t.startsWith("deco-sites/")?2:1);return(i[0]==="loaders"||i[0]==="actions")&&(i=i.slice(1)),[e,...i.slice(0,-1)]}function gx(t,e,s){const i=[];for(const[r,o]of Object.entries(e)){if(r.includes("/")||Bo(r)||!o||typeof o!="object"||Array.isArray(o))continue;const a=o,l=a.__resolveType;typeof l=="string"&&(C1.has(Kc(l))||ux(t,l,s)&&i.push({key:r,resolveType:l,title:typeof a.name=="string"&&a.name?a.name:r}))}return i.sort((r,o)=>r.title.localeCompare(o.title))}const p0=3e4;function _x(t){return`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/preview-invoke`}function Lx(t,e,s,i){const r=new URL(`/deco/invoke/${e}`,t);return r.searchParams.set("__cb",i.toString(36)),r.searchParams.set("__decoFBT","0"),r.searchParams.set("__d",`run-${i.toString(36)}`),r.searchParams.set("props",btoa(encodeURIComponent(JSON.stringify(s)))),r.href}async function vx(t,{resolveType:e,props:s}){let i;try{i=await fetch(_x(t),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({__resolveType:e,...s}),signal:AbortSignal.timeout(p0)})}catch(l){throw l instanceof DOMException&&l.name==="TimeoutError"?new Error(`Run timed out after ${p0/1e3}s — the block may be slow or the preview unresponsive.`):l}const r=await i.text();let o=null,a=!1;try{o=r?JSON.parse(r):null,a=!0}catch{}if(!i.ok){const l=a&&o&&typeof o=="object"&&"error"in o&&typeof o.error=="string"?o.error:r||`Run failed (${i.status})`;throw new Error(l)}return a?o:r}function xx(t){const e=U.c(2);let s;return e[0]!==t?(s={mutationFn:i=>vx(t,i)},e[0]=t,e[1]=s):s=e[1],ii(s)}function yx({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i,meta:r,decofile:o,kind:a,target:l,initialValue:c,isCreating:d,onCreate:h,onSaveReferencedBlock:u,onBack:f}){const m=li(),p=m?.entity?.id===e?m.entity.metadata?.siteSlug??null:null,g=Bs(l.resolveType,r),L=!g&&o4(l.resolveType,r),v=L?a4(c):null,y=g??v,[_,x]=R.useState(c),[b,S]=R.useState([]),[w,j]=R.useState(0),[N,T]=R.useState(!1),[A,k]=R.useState(null),[C,I]=R.useState(!1),[E,O]=R.useState(!1),[P,D]=R.useState(!1),M=A!==null,{save:z,flush:F,isPending:$}=Fu({orgSlug:t,virtualMcpId:e,branch:s}),V=xx({orgSlug:t,virtualMcpId:e,branch:s});R.useEffect(()=>()=>{F()},[]);const J=j1(a),Z=l.resolveType.split("/").pop()?.replace(/\.tsx?$/,"")??l.resolveType,G={orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i??void 0,siteSlug:p},q=ie=>{x(ie),l.mode==="saved"&&z(l.blockKey,{__resolveType:l.resolveType,...ie})},H=()=>{M?(k(null),T(!1),j(ie=>ie+1)):k(JSON.stringify(_,null,2))},K=ie=>{const oe=ie??"";try{const ue=JSON.parse(oe);if(ue&&typeof ue=="object"&&!Array.isArray(ue)){T(!1),q(ue);return}T(!0)}catch{T(!0)}},B=async ie=>{const oe=Xu(ie,o);if(oe){me.error(oe);return}await h(ie,{__resolveType:l.resolveType,..._}),I(!1)},X=()=>{O(!0),V.mutate({resolveType:l.resolveType,props:_})},W=()=>{i&&window.open(Lx(i,l.resolveType,_,Date.now()),"_blank","noopener")},Y=[l.title,...b],Q=ie=>{S(b.slice(0,ie)),j(oe=>oe+1)};return n.jsxs("div",{className:"flex h-full w-full min-w-0 flex-col",children:[n.jsxs("div",{className:"shrink-0 border-b px-3 py-2.5",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[f&&n.jsx(re,{variant:"ghost",size:"icon",className:"size-8 shrink-0",onClick:f,"aria-label":"Back to list",children:n.jsx(Xl,{size:14})}),n.jsx("nav",{"aria-label":"Editing breadcrumb",className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:Y.map((ie,oe)=>{const ue=oe===Y.length-1;return n.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[oe>0&&n.jsx(Ms,{className:"size-3 shrink-0 text-muted-foreground/60"}),n.jsx("button",{type:"button",onClick:()=>Q(oe),title:ie,className:ce("min-w-0 truncate rounded-md px-1 py-0.5 text-left transition-colors hover:bg-accent hover:text-accent-foreground",ue?"font-medium text-foreground":"text-muted-foreground"),children:ie})]},`${ie}-${oe}`)})}),l.mode==="saved"&&n.jsx(dx,{isPending:$,isError:!1}),n.jsxs(re,{size:"sm",variant:"outline",className:"h-8 shrink-0 gap-1.5",onClick:X,disabled:V.isPending,"aria-label":`Run ${J}`,children:[V.isPending?n.jsx(Ue,{size:14,className:"animate-spin"}):n.jsx(xi,{size:14}),"Run"]}),l.mode==="available"&&n.jsxs(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsx(re,{size:"icon",className:"size-8 shrink-0",disabled:d,onClick:()=>I(!0),"aria-label":`Save as global ${J}`,children:n.jsx(Hl,{size:14})})}),n.jsxs(Ae,{side:"bottom",children:["Save as global ",J]})]}),n.jsxs(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsx(re,{variant:M?"default":"ghost",size:"icon",className:"size-8 shrink-0",onClick:H,"aria-label":M?"Close JSON editor":"Edit as JSON","aria-pressed":M,children:M?n.jsx(dn,{size:14}):n.jsx(nr,{size:14})})}),n.jsx(Ae,{side:"bottom",children:M?"Close JSON editor":"Edit as JSON"})]})]}),n.jsx("p",{className:"mt-1.5 py-1 pl-1 text-sm leading-snug text-muted-foreground",children:l.mode==="saved"?`Global ${J} — changes save automatically. Run to invoke it against the live preview.`:`${Z} — edits stay local until you save this as a global ${J}. Run to invoke it against the live preview.`})]}),n.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[n.jsxs("div",{className:ce("relative min-h-0 flex-1",E&&P&&"hidden"),children:[n.jsx(ni,{className:"h-full [&_[data-slot=scroll-area-viewport]>div]:!block",children:n.jsx("div",{className:"min-w-0 max-w-full overflow-x-hidden px-6 py-4",children:n.jsxs("div",{className:"mx-auto max-w-2xl",children:[v&&y===v&&n.jsxs("p",{className:"mb-3 rounded-md bg-muted px-3 py-2 text-xs leading-snug text-muted-foreground",children:["This ",J," doesn't publish a props schema — fields below are inferred from its saved values. Use the JSON editor to add props not shown here."]}),y?n.jsx(ai,{schema:y,value:_,onChange:ie=>q(ie),basePath:"",breadcrumbPath:b,onBreadcrumbChange:S,meta:r,decofile:o,onSaveReferencedBlock:u,sandbox:G},w):n.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:L?`This ${J} doesn't publish a props schema. Edit its props as JSON, then run it.`:`This ${J} takes no configurable input. Run it to see its output.`})]})})}),A!==null&&n.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[N&&n.jsx("div",{className:"shrink-0 border-b bg-destructive/10 px-3 py-1.5 text-xs text-destructive",children:"Invalid JSON — changes aren't saved until it parses."}),n.jsx("div",{className:"min-h-0 flex-1",children:n.jsx(Mo,{language:"json",height:"100%",code:A,onChange:K,onSave:ie=>{K(ie),F()}})})]})]}),E&&n.jsx(bx,{singular:J,result:{isPending:V.isPending,error:V.error,data:V.data,hasRun:V.status!=="idle"},expanded:P,onToggleExpand:()=>D(ie=>!ie),onOpenInNewTab:i?W:void 0,onClose:()=>{O(!1),D(!1)}})]}),n.jsx(L1,{open:C,onOpenChange:I,defaultBlockId:"",isPending:d,onSubmit:B})]})}function bx(t){const e=U.c(37),{singular:s,result:i,expanded:r,onToggleExpand:o,onOpenInNewTab:a,onClose:l}=t;let c;e[0]!==i.data?(c=typeof i.data=="string"?i.data:JSON.stringify(i.data??null,null,2),e[0]=i.data,e[1]=c):c=e[1];const d=c,h=r?"flex-1":"h-[45%] shrink-0";let u;e[2]!==h?(u=ce("flex min-h-0 flex-col border-t",h),e[2]=h,e[3]=u):u=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Result"}),e[4]=f):f=e[4];let m;e[5]!==a||e[6]!==s?(m=a&&n.jsxs(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsx(re,{variant:"ghost",size:"icon",className:"size-7",onClick:a,"aria-label":"Open result in new tab",children:n.jsx(ri,{size:14})})}),n.jsxs(Ae,{side:"bottom",children:["Open in new tab (re-runs the ",s,")"]})]}),e[5]=a,e[6]=s,e[7]=m):m=e[7];const p=r?"Collapse result":"Expand result";let g;e[8]!==r?(g=r?n.jsx(B2,{size:14}):n.jsx(Rd,{size:14}),e[8]=r,e[9]=g):g=e[9];let L;e[10]!==r||e[11]!==o||e[12]!==p||e[13]!==g?(L=n.jsx(Ee,{asChild:!0,children:n.jsx(re,{variant:"ghost",size:"icon",className:"size-7",onClick:o,"aria-label":p,"aria-pressed":r,children:g})}),e[10]=r,e[11]=o,e[12]=p,e[13]=g,e[14]=L):L=e[14];const v=r?"Collapse":"Expand";let y;e[15]!==v?(y=n.jsx(Ae,{side:"bottom",children:v}),e[15]=v,e[16]=y):y=e[16];let _;e[17]!==y||e[18]!==L?(_=n.jsxs(Pe,{children:[L,y]}),e[17]=y,e[18]=L,e[19]=_):_=e[19];let x;e[20]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(dn,{size:14}),e[20]=x):x=e[20];let b;e[21]!==l?(b=n.jsx(re,{variant:"ghost",size:"icon",className:"size-7",onClick:l,"aria-label":"Close result",children:x}),e[21]=l,e[22]=b):b=e[22];let S;e[23]!==_||e[24]!==b||e[25]!==m?(S=n.jsxs("div",{className:"flex h-9 shrink-0 items-center justify-between border-b px-3",children:[f,n.jsxs("div",{className:"flex items-center gap-0.5",children:[m,_,b]})]}),e[23]=_,e[24]=b,e[25]=m,e[26]=S):S=e[26];let w;e[27]!==i.error||e[28]!==i.hasRun||e[29]!==i.isPending||e[30]!==d||e[31]!==s?(w=n.jsx("div",{className:"min-h-0 flex-1",children:i.isPending?n.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-xs text-muted-foreground",children:[n.jsx(Ue,{size:16,className:"animate-spin"}),"Running ",s,"…"]}):i.error?n.jsxs("div",{className:"h-full overflow-auto px-4 py-3",children:[n.jsxs("p",{className:"text-xs font-medium text-destructive",children:["Failed to run ",s]}),n.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-words text-xs text-destructive/90",children:i.error.message})]}):i.hasRun?n.jsx(Mo,{language:"json",height:"100%",code:d,readOnly:!0}):n.jsxs("div",{className:"flex h-full items-center justify-center text-xs text-muted-foreground",children:["Press Run to invoke this ",s,"."]})}),e[27]=i.error,e[28]=i.hasRun,e[29]=i.isPending,e[30]=d,e[31]=s,e[32]=w):w=e[32];let j;return e[33]!==S||e[34]!==w||e[35]!==u?(j=n.jsxs("div",{className:u,children:[S,w]}),e[33]=S,e[34]=w,e[35]=u,e[36]=j):j=e[36],j}const Sx={loaders:Xr,actions:wi},wx={loaders:"Loaders",actions:"Actions"},Cx={analytics:z2,blog:ho,commerce:$2,site:r3,website:Pi};function jx(t,e){return e===0?Cx[t.toLowerCase()]??en:en}function Pr(t,e){return e===0?px(t):t}function kx(t){const e=U.c(87),{orgSlug:s,virtualMcpId:i,branch:r,previewUrl:o,meta:a,decofile:l,kind:c}=t;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=[],e[0]=d):d=e[0];const[h,u]=R.useState(d),[f,m]=R.useState(null),[p,g]=R.useState(""),[L,v]=R.useState(Ix),[y,_]=R.useState(c);y!==c&&(_(c),u([]),m(null),g(""),v(new Set));let x;e[1]===Symbol.for("react.memo_cache_sentinel")?(x=V=>{v(J=>{const Z=new Set(J);return Z.has(V)?Z.delete(V):Z.add(V),Z})},e[1]=x):x=e[1];const b=x;let S;e[2]!==r||e[3]!==s||e[4]!==i?(S={orgSlug:s,virtualMcpId:i,branch:r},e[2]=r,e[3]=s,e[4]=i,e[5]=S):S=e[5];const w=Ko(S);let j;e[6]!==w?(j=Zu((V,J)=>w.mutate({blockKey:V,data:J})),e[6]=w,e[7]=j):j=e[7];const N=j;let T;e[8]!==c?(T=j1(c),e[8]=c,e[9]=T):T=e[9];const A=T,k=Sx[c];let C,I,E,O,P,D,M;if(e[10]!==k||e[11]!==r||e[12]!==l||e[13]!==c||e[14]!==a||e[15]!==L||e[16]!==s||e[17]!==h||e[18]!==o||e[19]!==w||e[20]!==N||e[21]!==p||e[22]!==f||e[23]!==A||e[24]!==i){E=Symbol.for("react.early_return_sentinel");e:{const V=[...gx(a,l,c).map(Dx),...k1(a,c).map(Rx)],J=p.trim().toLowerCase(),Z=J.length>0,G=Z?V.filter(pe=>pe.title.toLowerCase().includes(J)||pe.resolveType.toLowerCase().includes(J)):[],q=new Map,H=[],K=new Map;if(!Z){for(const pe of V){const je=pe.folderPath;if(!(je.length<h.length)&&h.every((Be,le)=>je[le]===Be))if(je.length===h.length)if(pe.savedKey!==void 0){const Be=K.get(pe.resolveType);Be?Be.push(pe):K.set(pe.resolveType,[pe])}else H.push(pe);else{const Be=je[h.length],le=q.get(Be)??{count:0,savedCount:0};pe.savedKey!==void 0?le.savedCount=le.savedCount+1:le.count=le.count+1,q.set(Be,le)}}H.sort(Px);for(const pe of K.values())pe.sort(Ax)}const B=[...K.entries()].filter(pe=>{const[je]=pe;return!H.some(Be=>Be.resolveType===je)}).flatMap(Ex).sort(Tx);let X;e[32]!==h?(X=(pe,je)=>Pr(pe.name,h.length).localeCompare(Pr(je.name,h.length)),e[32]=h,e[33]=X):X=e[33];const W=[...q.entries()].map(Nx).sort(X);let Y;e[34]===Symbol.for("react.memo_cache_sentinel")?(Y=pe=>{m(pe.savedKey!==void 0?{mode:"saved",key:pe.savedKey}:{mode:"available",resolveType:pe.resolveType,title:pe.title})},e[34]=Y):Y=e[34];const Q=Y;let ie;e[35]!==w||e[36]!==A?(ie=async(pe,je)=>{await w.mutateAsync({blockKey:pe,data:je}),me.success(`Saved ${A} "${pe}"`),m({mode:"saved",key:pe})},e[35]=w,e[36]=A,e[37]=ie):ie=e[37];const oe=ie;let ue;e[38]!==l||e[39]!==f?(ue=Ox(f,l),e[38]=l,e[39]=f,e[40]=ue):ue=e[40];const ee=ue;if(ee){const pe=`${ee.mode}:${ee.mode==="saved"?ee.blockKey:ee.resolveType}`;let je;e[41]===Symbol.for("react.memo_cache_sentinel")?(je=()=>m(null),e[41]=je):je=e[41];let Be;e[42]!==r||e[43]!==l||e[44]!==oe||e[45]!==c||e[46]!==a||e[47]!==s||e[48]!==o||e[49]!==w.isPending||e[50]!==N||e[51]!==pe||e[52]!==ee.editorTarget||e[53]!==ee.initialValue||e[54]!==i?(Be=n.jsx(yx,{orgSlug:s,virtualMcpId:i,branch:r,previewUrl:o,meta:a,decofile:l,kind:c,target:ee.editorTarget,initialValue:ee.initialValue,isCreating:w.isPending,onCreate:oe,onSaveReferencedBlock:N,onBack:je},pe),e[42]=r,e[43]=l,e[44]=oe,e[45]=c,e[46]=a,e[47]=s,e[48]=o,e[49]=w.isPending,e[50]=N,e[51]=pe,e[52]=ee.editorTarget,e[53]=ee.initialValue,e[54]=i,e[55]=Be):Be=e[55],E=Be;break e}M="flex h-full w-full min-w-0 flex-col";let te;e[56]===Symbol.for("react.memo_cache_sentinel")?(te=()=>u([]),e[56]=te):te=e[56];const fe=h.length===0?"font-medium text-foreground":"text-muted-foreground";let he;e[57]!==fe?(he=ce("min-w-0 truncate rounded-md px-1 py-0.5 transition-colors hover:bg-accent hover:text-accent-foreground",fe),e[57]=fe,e[58]=he):he=e[58];const ye=wx[c];let ve;e[59]!==he||e[60]!==ye?(ve=n.jsx("button",{type:"button",onClick:te,className:he,children:ye}),e[59]=he,e[60]=ye,e[61]=ve):ve=e[61];let be;e[62]!==h?(be=h.map((pe,je)=>{const Be=je===h.length-1;return n.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[n.jsx(Ms,{className:"size-3 shrink-0 text-muted-foreground/60"}),n.jsx("button",{type:"button",onClick:()=>u(h.slice(0,je+1)),className:ce("min-w-0 truncate rounded-md px-1 py-0.5 transition-colors hover:bg-accent hover:text-accent-foreground",Be?"font-medium text-foreground":"text-muted-foreground"),children:Pr(pe,je)})]},`${pe}-${je}`)}),e[62]=h,e[63]=be):be=e[63];let Ne;e[64]!==ve||e[65]!==be?(Ne=n.jsxs("nav",{"aria-label":"Folder breadcrumb",className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:[ve,be]}),e[64]=ve,e[65]=be,e[66]=Ne):Ne=e[66];let Oe;e[67]===Symbol.for("react.memo_cache_sentinel")?(Oe=n.jsx(sc,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),e[67]=Oe):Oe=e[67];let Fe;e[68]===Symbol.for("react.memo_cache_sentinel")?(Fe=pe=>g(pe.target.value),e[68]=Fe):Fe=e[68];const Me=`Search all ${c}…`,qe=`Search all ${c}`;let Ie;e[69]!==p||e[70]!==Me||e[71]!==qe?(Ie=n.jsxs("div",{className:"flex w-56 shrink-0 items-center gap-2",children:[Oe,n.jsx("input",{type:"text",value:p,onChange:Fe,placeholder:Me,"aria-label":qe,className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),e[69]=p,e[70]=Me,e[71]=qe,e[72]=Ie):Ie=e[72],e[73]!==Ne||e[74]!==Ie?(I=n.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-2 border-b px-4",children:[Ne,Ie]}),e[73]=Ne,e[74]=Ie,e[75]=I):I=e[75],C=ni,D="min-h-0 flex-1 [&_[data-slot=scroll-area-viewport]>div]:!block",O="mx-auto w-full max-w-4xl px-6 py-5",P=Z?G.length===0?n.jsx(qs,{title:`No ${c} match "${p.trim()}"`,description:"Search covers every folder — try a different term."}):n.jsx("div",{className:"flex flex-col gap-1",children:G.map(pe=>n.jsx(ws,{icon:k,accent:pe.savedKey!==void 0?"global":void 0,title:pe.title,subtitle:pe.resolveType,active:!1,onClick:()=>Q(pe)},pe.savedKey??pe.resolveType))}):W.length===0&&H.length===0&&B.length===0?n.jsx(qs,{title:`No ${c} here`,description:h.length===0?"Start the preview dev server so its manifest loads.":"This folder is empty."}):n.jsxs(n.Fragment,{children:[W.length>0&&n.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-2",children:W.map(pe=>{const je=jx(pe.name,h.length);return n.jsxs("button",{type:"button",onClick:()=>u([...h,pe.name]),className:"flex items-center gap-2.5 rounded-lg border px-3 py-2.5 text-left transition-colors hover:bg-muted cursor-pointer",children:[n.jsx(je,{size:18,className:"shrink-0 text-muted-foreground"}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"block truncate text-sm font-medium",children:Pr(pe.name,h.length)}),n.jsxs("span",{className:"block truncate text-xs text-muted-foreground",children:[pe.count," ",pe.count===1?A:c,pe.savedCount>0&&n.jsxs(n.Fragment,{children:[" · ",pe.savedCount," saved"]})]})]})]},pe.name)})}),(H.length>0||B.length>0)&&n.jsxs("div",{className:ce("flex flex-col gap-1",W.length>0&&"mt-4"),children:[H.map(pe=>{const je=K.get(pe.resolveType)??[],Be=L.has(pe.resolveType);return n.jsxs("div",{className:"flex flex-col",children:[n.jsx(ws,{icon:k,title:pe.title,subtitle:pe.resolveType,active:!1,onClick:()=>Q(pe)}),je.length>0&&n.jsxs(n.Fragment,{children:[n.jsxs("button",{type:"button",onClick:()=>b(pe.resolveType),"aria-expanded":Be,className:"flex items-center gap-1 self-start rounded-md px-2.5 py-1 text-xs font-medium transition-colors hover:bg-global-section/10 cursor-pointer ml-11",style:{color:pc},children:[Be?n.jsx(ls,{size:12,className:"shrink-0"}):n.jsx(Ms,{size:12,className:"shrink-0"}),Be?"Hide saved":"See saved"," (",je.length,")"]}),Be&&n.jsx("div",{className:"ml-11 flex flex-col gap-1 pb-1",children:je.map(le=>n.jsx(ws,{icon:k,accent:"global",title:le.title,subtitle:le.resolveType,active:!1,onClick:()=>Q(le)},le.savedKey))})]})]},pe.resolveType)}),B.map(pe=>n.jsx(ws,{icon:k,accent:"global",title:pe.title,subtitle:pe.resolveType,active:!1,onClick:()=>Q(pe)},pe.savedKey))]})]})}e[10]=k,e[11]=r,e[12]=l,e[13]=c,e[14]=a,e[15]=L,e[16]=s,e[17]=h,e[18]=o,e[19]=w,e[20]=N,e[21]=p,e[22]=f,e[23]=A,e[24]=i,e[25]=C,e[26]=I,e[27]=E,e[28]=O,e[29]=P,e[30]=D,e[31]=M}else C=e[25],I=e[26],E=e[27],O=e[28],P=e[29],D=e[30],M=e[31];if(E!==Symbol.for("react.early_return_sentinel"))return E;let z;e[76]!==O||e[77]!==P?(z=n.jsx("div",{className:O,children:P}),e[76]=O,e[77]=P,e[78]=z):z=e[78];let F;e[79]!==C||e[80]!==z||e[81]!==D?(F=n.jsx(C,{className:D,children:z}),e[79]=C,e[80]=z,e[81]=D,e[82]=F):F=e[82];let $;return e[83]!==I||e[84]!==F||e[85]!==M?($=n.jsxs("div",{className:M,children:[I,F]}),e[83]=I,e[84]=F,e[85]=M,e[86]=$):$=e[86],$}function Nx(t){const[e,s]=t;return{name:e,...s}}function Tx(t,e){return t.title.localeCompare(e.title)}function Ex(t){const[,e]=t;return e}function Ax(t,e){return t.title.localeCompare(e.title)}function Px(t,e){return t.title.localeCompare(e.title)}function Rx(t){return{resolveType:t.resolveType,title:t.title,folderPath:N1(t.resolveType)}}function Dx(t){return{resolveType:t.resolveType,title:t.title,folderPath:N1(t.resolveType),savedKey:t.key}}function Ix(){return new Set}function Ox(t,e){if(!t)return null;if(t.mode==="available")return{mode:"available",resolveType:t.resolveType,editorTarget:{mode:"available",resolveType:t.resolveType,title:t.title},initialValue:{}};const s=e[t.key],i=s&&typeof s.__resolveType=="string"?s.__resolveType:"",{__resolveType:r,...o}=s??{},a=s&&typeof s.name=="string"&&s.name?s.name:t.key;return{mode:"saved",blockKey:t.key,resolveType:i,editorTarget:{mode:"saved",blockKey:t.key,resolveType:i,title:a},initialValue:o}}const g0=R.lazy(()=>as(()=>import("./app-editor-Cqa11QpG.js"),__vite__mapDeps([149,1,2,15,44,4,5,6,7,8,9,10,11,12,13,14,3,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,102,103,94,91,104,105,83,84,85,86,87,88,89,90,92,93,95,96,97,98,99,106,107,108,109,110,111,112,113,114,115,82,116,117,118,119,120,121,122,123,124,125,126,127,128,101,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145])).then(t=>({default:t.AppEditor}))),Mx=R.lazy(()=>as(()=>import("./post-editor-PIZGyh-D.js"),__vite__mapDeps([150,1,2,27,4,5,6,7,8,9,10,11,12,13,14,3,15,16,17,18,19,20,21,22,23,24,25,26,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,80,79,137,87,88,76,63,55,56,62,90,73,138,120,139,140,118,141,65,99,93,81,48,108,113,114,50,112,69,44,45,46,47,49,51,52,53,54,57,58,59,60,61,64,66,67,68,70,71,72,74,75,77,78,104,95,151,83,84,85,86,89,91,92,94,96,97,98,103,105,106,107,109,110,111,115,82,116,152,117,119,121,122,123,124,125,126,127,128,101,129,130,131,132,133,134,135,136,142,143,144,145])).then(t=>({default:t.PostEditor}))),Bx=R.lazy(()=>as(()=>import("./record-editor-CKpLUFyW.js"),__vite__mapDeps([153,1,2,80,79,95,152,4,5,6,7,8,9,10,11,12,13,14,3,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,103,57,58,55,56,59,60,61,62,63,64,65,66,52,67,44,45,46,47,48,49,50,51,53,54,68,69,70,71,72,73,74,75,76,77,78,81,94,91,104,105,83,84,85,86,87,88,89,90,92,93,96,97,98,99,106,107,108,109,110,111,112,113,114,115,82,116,117,118,119,120,121,122,123,124,125,126,127,128,101,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145])).then(t=>({default:t.RecordEditor}))),$x=R.lazy(()=>as(()=>import("./category-editor-CjO8y5jo.js"),__vite__mapDeps([154,1,2,9,4,5,6,7,8,10,11,12,13,14,3,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,70,80,79,151,83,84,85,86,76,63,55,56,67,65,87,88,89,90,74,91,92,93,50,94,51,78,81,48,95,96,97,98,99,64,113,114,112,44,45,46,47,49,52,53,54,57,58,59,60,61,62,66,68,69,71,72,73,75,77,103,104,105,106,107,108,109,110,111,115,82,116,152,117,118,119,120,121,122,123,124,125,126,127,128,101,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145])).then(t=>({default:t.CategoryEditor}))),zx=R.lazy(()=>as(()=>import("./bulk-category-panel-Cyw3TrSE.js"),__vite__mapDeps([155,1,2,4,5,6,7,8,9,10,11,12,13,14,3,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,79,156,81,48])).then(t=>({default:t.BulkCategoryPanel}))),Fx=R.lazy(()=>as(()=>import("./sections-editor-BHAVZ3MF.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145])).then(t=>({default:t.SectionsEditor}))),Hx=R.lazy(()=>as(()=>import("./seo-editor-QlGbBbQX.js"),__vite__mapDeps([157,1,2,15,4,5,6,7,8,9,10,11,12,13,14,3,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,100,101,103,94,91,104,105,83,84,85,86,87,88,89,90,92,93,95,96,97,98,99,106,107,108,109,110,111,112,113,114,115,82,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145])).then(t=>({default:t.SeoEditor}))),Ux=R.lazy(()=>as(()=>import("./variant-calendar-BGmazWqY.js"),__vite__mapDeps([158,1,2,4,5,6,7,8,9,10,11,12,13,14,3,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,79,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,80,81,101,159])).then(t=>({default:t.VariantCalendar}))),Qa="oklch(0.65 0.15 160)";function Kx(t){return t.split("/").pop()?.replace(/\.tsx?$/,"")||t||"Section"}function Wx(t){const e=new Map;for(const s of t){const i=Kx(s.resolveType),r=e.get(i);r?r.push(s):e.set(i,[s])}return[...e.entries()].map(([s,i])=>({label:s,sections:i})).sort((s,i)=>s.label.localeCompare(i.label))}function Vx(){const t=U.c(19),e=li(),{data:s}=an.useSession(),{currentBranch:i}=$s(),{org:r}=Ge(),o=e?.entity?.id??null,a=s?.user?.id,l=e?.entity?.metadata,c=a&&i?jo(l?.sandboxMap?.[a]?.[i]):{},d=Object.values(c),u=(d.find(Gx)??d[0])?.previewUrl??null,f=As(),m=e?.entity?.organization_id??"";let p;t[0]!==r.slug||t[1]!==m?(p={connectionId:Kl,orgId:m,orgSlug:r.slug},t[0]=r.slug,t[1]=m,t[2]=p):p=t[2];const g=Dt(p),L=Bl(g);let v;t[3]!==i||t[4]!==L||t[5]!==o?(v=()=>{if(!o)return;const S={virtualMcpId:o};i&&(S.branch=i),L.mutate(S)},t[3]=i,t[4]=L,t[5]=o,t[6]=v):v=t[6];const y=v,_=!!o&&!!i&&Ma.isStopped(o,i),x=Qh({previewUrl:u,appPaused:f.status.state==="paused",userStopped:_,startError:L.isError&&L.error?tu(L.error.message):null});if(x.kind!=="iframe"){const S=`/${r.slug}/settings/connections`;let w;return t[7]!==x||t[8]!==S||t[9]!==y||t[10]!==f.lifecycle||t[11]!==f.phase?(w=n.jsx(m7,{state:x,claimPhase:f.phase,lifecycle:f.lifecycle,onStart:y,connectionsHref:S}),t[7]=x,t[8]=S,t[9]=y,t[10]=f.lifecycle,t[11]=f.phase,t[12]=w):w=t[12],w}if(!o||!i){let S;return t[13]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(qs,{title:"Waiting for sandbox context…"}),t[13]=S):S=t[13],S}let b;return t[14]!==i||t[15]!==r.slug||t[16]!==u||t[17]!==o?(b=n.jsx(Yx,{orgSlug:r.slug,virtualMcpId:o,branch:i,previewUrl:u}),t[14]=i,t[15]=r.slug,t[16]=u,t[17]=o,t[18]=b):b=t[18],b}function Gx(t){return t.sandboxProviderKind!=="user-desktop"}const _0=2e3,qx=15;function L0(t,e,s,i){return typeof e!="string"||s&&(Gu(e,s,i)||t.state.dataUpdateCount>=qx)?!1:_0}function Yx({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i}){const r={orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i},{data:o,isLoading:a}=uc(r),[l,c]=R.useState("pages"),[d,h]=R.useState(null),[u,f]=R.useState(null),[m,p]=R.useState(""),[g,L]=R.useState(null),[v,y]=R.useState(null),[_,x]=R.useState("date-desc"),[b,S]=R.useState(()=>new Set),[w,j]=R.useState(null),N=()=>{S(new Set),j(null)},[T,A]=R.useState(l);T!==l&&(A(l),p(""),L(null),y(null),x("date-desc"),S(new Set),j(null));const{data:k,isLoading:C,isFetching:I}=fc(r,{refetchInterval:se=>{const Se=se.state.data;if(l==="apps"&&d&&d.collection==="apps"){const Te=o?.[d.key];return L0(se,typeof Te?.__resolveType=="string"?Te.__resolveType:void 0,Se)}if(l==="site"&&o){const Te=Se?Ga(o,Se):null,De=o.site,Ye=Te?.resolveType??(typeof De?.__resolveType=="string"?De.__resolveType:void 0);return L0(se,Ye,Se,["seo"])}return!1}}),E=(se,Se)=>!Gu(se,k,Se)&&(C||I),{catalog:O,isLoading:P}=$6(k??void 0,o??void 0,{enabled:l==="apps"}),D=Ko(r),M=E6(r),z=ox(r),F=lx(r),[$,V]=R.useState(null),[J,Z]=R.useState(),[G,q]=R.useState(null),[H,K]=R.useState(null),[B,X]=R.useState(null);if(a||C)return n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(Ue,{size:20,className:"animate-spin text-muted-foreground"})});if(!o||!k)return n.jsx(qs,{title:"Could not load site data."});const W=bc(o).sort((se,Se)=>se.name.localeCompare(Se.name)),Y=Sc(o,k),Q=l==="sections"?f4(k):[],ie=Ga(o,k),oe=x1(o),ue=Hc.some(se=>oe[se].length>0),ee=Vn(l)?oe[l]:[],te=(ue?er(o,"categories"):[]).map(({key:se,payload:Se})=>{const Te=typeof Se.slug=="string"?Se.slug:"",De=typeof Se.name=="string"?Se.name:"";return{slug:Te||se,name:De||Te||se}}).filter(se=>se.slug).sort((se,Se)=>se.name.localeCompare(Se.name)),fe=l==="posts"&&(b.size>0||w!==null),he=fe?b1(o).filter(se=>b.has(se.key)):[],ye=m0(k,"loaders"),ve=m0(k,"actions");if(!yc(o,k)&&!ue&&ye===0&&ve===0)return n.jsx(qs,{icon:Ei,title:"No editable content",description:"This project doesn't expose any Deco pages, sections, apps, loaders, or actions."});const be={pages:W.length,sections:Y.length,apps:O.length,loaders:ye,actions:ve,posts:oe.posts.length,authors:oe.authors.length,categories:oe.categories.length},Ne=new Set(W.map(se=>qi(se.path))),Oe=new Set(W.map(se=>se.name)),Fe=new Set(Y.map(se=>se.name)),Me=async se=>{const Se=o[se.key];if(!Se)return;const Te=Mu(o,se.key),De=Bu(o,se.key,Math.max(0,Te-1)),Ye=B_(Se.sections,De);if(Ye)try{await D.mutateAsync({blockKey:se.key,data:{...Se,sections:Ye}}),me.success(`Variant added to "${se.name}"`),h({collection:"pages",key:se.key,path:se.path})}catch(et){me.error(et instanceof Error?et.message:"Could not add variant")}},qe=()=>{Z(void 0),V({mode:"create",sourceKey:null,initialName:"My new page",initialPath:"/example"})},Ie=se=>{Z(void 0),V({mode:"duplicate",sourceKey:se.key,initialName:d0(Oe,se.name),initialPath:Dv(Ne,se.path)})},pe=se=>{Z(void 0),V({mode:"rename",sourceKey:se.key,initialName:se.name,initialPath:se.path})},je=async se=>{if(!$)return;const{mode:Se,sourceKey:Te}=$;try{if(Se==="create"){let De;if(se.templateKey){const et=o[se.templateKey];if(!et)throw new Error("Selected template no longer exists.");De={...et,name:se.name,path:se.path}}else De=Mv(se.name,se.path);const Ye=$v(o,se.name);await D.mutateAsync({blockKey:Ye,data:De}),me.success(`Created "${se.name}"`),h({collection:"pages",key:Ye,path:se.path})}else if(Se==="duplicate"&&Te){const De=o[Te];if(!De)throw new Error("Source page not found");const{key:Ye,data:et}=Ov({source:De,pages:W,newName:se.name,newPath:se.path});await D.mutateAsync({blockKey:Ye,data:et}),me.success(`Duplicated as "${se.name}"`),h({collection:"pages",key:Ye,path:se.path})}else if(Se==="rename"&&Te){const De=o[Te];if(!De)throw new Error("Page not found");const Ye={...De,name:se.name,path:se.path};await D.mutateAsync({blockKey:Te,data:Ye}),me.success("Page updated"),d?.collection==="pages"&&d.key===Te&&h({collection:"pages",key:Te,path:se.path})}V(null)}catch(De){Z(De instanceof Error?De.message:"Save failed")}},Be=({path:se})=>{if(!$)return null;const Se=qi(se);return($.mode==="rename"?qi($.initialPath):null)!==Se&&Ne.has(Se)?`A page with path "${se}" already exists.`:null},le=async(se,Se,Te)=>{await D.mutateAsync({blockKey:Se,data:{...Te,name:Se,__resolveType:se}}),me.success(`Created section "${Se}"`),h({collection:"sections",key:Se})},Le=Zu((se,Se)=>D.mutate({blockKey:se,data:Se})),Ce=async se=>{const Se=o[se.key];if(!Se){me.error("Section not found.");return}const Te=Iv(o,se.key),De=d0(Fe,se.name),Ye={...Se,name:De};try{await D.mutateAsync({blockKey:Te,data:Ye}),me.success(`Duplicated "${se.name}"`),h({collection:"sections",key:Te})}catch(et){me.error(et instanceof Error?et.message:"Duplicate failed")}},_e=async se=>{if(!G)return;const Se=o[G];if(!Se){me.error("Section not found.");return}try{await D.mutateAsync({blockKey:G,data:{...Se,name:se}}),me.success("Section renamed"),q(null)}catch(Te){me.error(Te instanceof Error?Te.message:"Rename failed")}},Re=async se=>{const Se=u0(o,se),Te=Ar(Se,se,Qv(se));try{await z.mutateAsync({blockKey:Se,data:Te}),me.success(`Created ${Wn[se]}`),h({collection:se,key:Se})}catch(De){me.error(De instanceof Error?De.message:"Could not create")}},Je=async se=>{const Se=o[se.key];if(!Se){me.error("Record not found.");return}const Te=u0(o,se.kind),De=se.kind==="posts"?"title":"name",Ye={...structuredClone(Hr(Se,se.kind)),[De]:`${se.label} (copy)`};try{await z.mutateAsync({blockKey:Te,data:Ar(Te,se.kind,Ye)}),me.success(`Duplicated "${se.label}"`),h({collection:se.kind,key:Te})}catch(et){me.error(et instanceof Error?et.message:"Duplicate failed")}},$t=se=>{S(Se=>{const Te=new Set(Se);return Te.has(se)?Te.delete(se):Te.add(se),Te})},Yt=se=>{c("posts"),A("posts"),h(null),f(null),p(""),L(null),y(null),x("date-desc"),S(new Set),j(se||null)},cs=async(se,Se)=>{const Te=[...b];let De=0;for(const Ye of Te){const et=o[Ye],Ps=Hr(et,"posts"),ci=se==="add"?Jv(Ps,Se):Xv(Ps,Se);ci!==Ps&&(await z.mutateAsync({blockKey:Ye,data:Ar(Ye,"posts",ci)}),De+=1)}return De},ae=async(se,Se)=>{const Te=b.size;try{const De=await cs(se,Se),Ye=se==="add"?"Added to":"Moved",et=Te-De;me.success(`${Ye} ${De} ${De===1?"post":"posts"}`+(et>0?` (${et} already set)`:"")),N()}catch(De){me.error(De instanceof Error?De.message:"Bulk update failed")}},He=async()=>{if(H)try{if(H.kind==="blog-bulk"){for(const De of H.keys)await F.mutateAsync({blockKey:De});me.success(`Deleted ${H.count} ${H.count===1?"post":"posts"}`),d&&d.collection!=="available-section"&&H.keys.includes(d.key)&&h(null),N(),K(null);return}const{kind:se,key:Se,label:Te}=H;if(se==="blog"){if(H.blogKind==="categories"){const De=Hr(o[Se],"categories").slug,Ye=typeof De=="string"?De:"";if(Ye)for(const{key:et,payload:Ps}of er(o,"posts")){const ci=Zv(Ps,Ye);ci!==Ps&&await z.mutateAsync({blockKey:et,data:Ar(et,"posts",ci)})}}await F.mutateAsync({blockKey:Se})}else await M.mutateAsync({blockKey:Se});me.success(`Deleted "${Te}"`),d&&d.collection!=="available-section"&&d.key===Se&&h(null),K(null)}catch(se){me.error(se instanceof Error?se.message:"Delete failed")}},it=M.isPending||F.isPending||z.isPending,Lt=H?.kind==="blog"?Wn[H.blogKind]:H?.kind==="blog-bulk"?`${H.count} ${H.count===1?"post":"posts"}`:H?.kind??"item";return n.jsxs("div",{className:"flex h-full w-full",children:[n.jsx(Xx,{active:l,counts:be,showBlog:ue,onSelect:se=>{c(se),h(null),f(null)}}),l!=="seo"&&l!=="site"&&l!=="calendar"&&l!=="loaders"&&l!=="actions"&&n.jsx(Zx,{activeCollection:l,pages:W,sections:Y,availableSections:Q,appCatalog:O,appCatalogLoading:P,blogEntries:ee,decofile:o,searchQuery:m,onSearchChange:p,postCategoryFilter:g,postAuthorFilter:v,postSort:_,onPostCategoryFilterChange:se=>{L(se),S(new Set)},onPostAuthorFilterChange:se=>{y(se),S(new Set)},onPostSortChange:x,selectedPostKeys:b,postBulkPanelOpen:fe,onTogglePostSelect:$t,onSelectAllPosts:se=>S(new Set(se)),onClearPostSelection:()=>S(new Set),onExitPostSelection:N,onBulkDeletePosts:()=>K({kind:"blog-bulk",keys:[...b],count:b.size}),selection:d,onSelect:se=>{h(se),f(null)},onCreate:()=>{l==="pages"?qe():Vn(l)&&Re(l)},onDuplicatePage:Ie,onRenamePage:pe,onAddPageVariant:Me,onDeletePage:se=>K({kind:"page",key:se.key,label:se.name}),onEditPageSeo:se=>{h({collection:"pages",key:se.key,path:se.path}),f(se.key)},onViewPageJson:se=>X(se.key),onDuplicateSection:Ce,onRenameSection:se=>q(se.key),onDeleteSection:se=>K({kind:"section",key:se.key,label:se.name}),onDuplicateBlog:Je,onDeleteBlog:se=>K({kind:"blog",blogKind:se.kind,key:se.key,label:se.label})}),n.jsx("div",{className:"flex-1 min-w-0",children:l==="loaders"||l==="actions"?n.jsx(kx,{orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i,meta:k,decofile:o,kind:l}):n.jsx(R.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(Ue,{size:20,className:"animate-spin text-muted-foreground"})}),children:l==="calendar"?n.jsx(Ux,{decofile:o}):l==="site"?ie?n.jsx(g0,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:ie.key,block:o[ie.key],decofile:o,meta:k,title:"Site",excludeFields:["seo"],schemaPending:E(ie.resolveType,["seo"]),previewBaseUrl:i},`site:${ie.key}`):n.jsx(qs,{title:"Site settings not found",description:"This project doesn't have a site app block (site/apps/site.ts)."}):l==="seo"?n.jsx(Hx,{orgSlug:t,virtualMcpId:e,branch:s,decofile:o,meta:k,target:{kind:"site"},previewBaseUrl:i}):l==="sections"?n.jsx(Jx,{selection:d?.collection==="sections"||d?.collection==="available-section"?d:null,orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i,meta:k,decofile:o,isCreating:D.isPending,onCreateAvailable:le,onSaveReferencedBlock:Le}):fe?n.jsx(zx,{posts:he,categories:te,initialSlug:w,isPending:z.isPending,onApply:(se,Se)=>{ae(se,Se)},onClose:N},w??"selection"):d&&d.collection!=="available-section"?d.collection==="apps"?n.jsx(g0,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:d.key,block:o[d.key],decofile:o,meta:k,previewBaseUrl:i,schemaPending:E(typeof o[d.key]?.__resolveType=="string"?String(o[d.key].__resolveType):void 0)},`app:${d.key}`):d.collection==="posts"?n.jsx(Mx,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:d.key,block:o[d.key],decofile:o,meta:k,previewBaseUrl:i},`post:${d.key}`):d.collection==="categories"?n.jsx($x,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:d.key,block:o[d.key],decofile:o,meta:k,onManagePosts:Yt,onOpenPost:se=>{c("posts"),A("posts"),h({collection:"posts",key:se}),f(null)},previewBaseUrl:i},`category:${d.key}`):d.collection==="authors"?n.jsx(Bx,{orgSlug:t,virtualMcpId:e,branch:s,kind:"authors",blockKey:d.key,block:o[d.key]},`authors:${d.key}`):n.jsx(Fx,{orgSlug:t,virtualMcpId:e,branch:s,previewReady:!0,previewUrl:i??void 0,currentPath:d.collection==="pages"?d.path:"/",activePageBlockKey:d.collection==="pages"?d.key:null,activeGlobalBlockKey:d.collection==="sections"?d.key:null,initialEditSeo:d.collection==="pages"&&u===d.key,onExitSeo:()=>f(null)},d.collection==="pages"?`page:${d.key}`:`section:${d.key}`):n.jsx(qs,{title:`Select ${Vn(l)?`a ${Wn[l]}`:l==="pages"?"a page":l==="apps"?"an app":"a section"} to edit`,description:l==="apps"?"Browse all apps and select an installed one to edit its settings.":'Pick an item from the list, or click "+" to create one.'})})}),$&&n.jsx(Uv,{open:!!$,mode:$.mode,initialName:$.initialName,initialPath:$.initialPath,isPending:D.isPending,error:J,templates:W,validate:Be,onSubmit:je,onOpenChange:se=>{se||(V(null),Z(void 0))}}),G&&n.jsx(Kv,{open:!!G,blockKey:G,initialName:Y.find(se=>se.key===G)?.name??G,isPending:D.isPending,onSubmit:_e,onOpenChange:se=>{se||q(null)}}),B&&n.jsx(cx,{open:!!B,onOpenChange:se=>{se||X(null)},pageKey:B,decofile:o}),n.jsx(eo,{open:!!H,onOpenChange:se=>{!se&&!it&&K(null)},children:n.jsxs(to,{children:[n.jsxs(so,{children:[n.jsx(io,{children:`Delete ${Lt}?`}),n.jsx(no,{children:H?.kind==="section"?`"${H.label}" will be removed. Pages that still reference it will lose this section.`:H?.kind==="blog-bulk"?`${H.count} ${H.count===1?"post":"posts"} will be removed permanently. This can't be undone.`:H?`"${H.label}" will be removed permanently. This can't be undone.`:null})]}),n.jsxs(ro,{children:[n.jsx(oo,{disabled:it,children:"Cancel"}),n.jsx(ao,{onClick:se=>{se.preventDefault(),He()},disabled:it,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:it?n.jsxs(n.Fragment,{children:[n.jsx(Ue,{size:14,className:"animate-spin"}),"Deleting…"]}):"Delete"})]})]})})]})}function Jx(t){const e=U.c(30),{selection:s,orgSlug:i,virtualMcpId:r,branch:o,previewUrl:a,meta:l,decofile:c,isCreating:d,onCreateAvailable:h,onSaveReferencedBlock:u}=t;if(!s){let p;return e[0]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(qs,{title:"Select a section to edit",description:"Pick a saved section to edit it, or an available one to customize and save as global."}),e[0]=p):p=e[0],p}if(s.collection==="available-section"){const p=`available:${s.resolveType}`,g=s.resolveType,L=s.title;let v;e[1]!==s.title?(v=z6(s.title),e[1]=s.title,e[2]=v):v=e[2];let y;e[3]!==h||e[4]!==s.resolveType?(y=(x,b)=>h(s.resolveType,x,b),e[3]=h,e[4]=s.resolveType,e[5]=y):y=e[5];let _;return e[6]!==o||e[7]!==c||e[8]!==d||e[9]!==l||e[10]!==u||e[11]!==i||e[12]!==a||e[13]!==s.resolveType||e[14]!==s.title||e[15]!==p||e[16]!==v||e[17]!==y||e[18]!==r?(_=n.jsx(Ev,{orgSlug:i,virtualMcpId:r,branch:o,previewUrl:a,meta:l,decofile:c,resolveType:g,title:L,defaultBlockId:v,isCreating:d,onCreate:y,onSaveReferencedBlock:u},p),e[6]=o,e[7]=c,e[8]=d,e[9]=l,e[10]=u,e[11]=i,e[12]=a,e[13]=s.resolveType,e[14]=s.title,e[15]=p,e[16]=v,e[17]=y,e[18]=r,e[19]=_):_=e[19],_}const f=`saved:${s.key}`;let m;return e[20]!==o||e[21]!==c||e[22]!==l||e[23]!==u||e[24]!==i||e[25]!==a||e[26]!==s.key||e[27]!==f||e[28]!==r?(m=n.jsx(Rv,{orgSlug:i,virtualMcpId:r,branch:o,previewUrl:a,meta:l,decofile:c,blockKey:s.key,onSaveReferencedBlock:u},f),e[20]=o,e[21]=c,e[22]=l,e[23]=u,e[24]=i,e[25]=a,e[26]=s.key,e[27]=f,e[28]=r,e[29]=m):m=e[29],m}function v0(t){const e=U.c(8),{icon:s,label:i,className:r}=t;let o;e[0]!==r?(o=ce("flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-xs font-medium text-muted-foreground/70",r),e[0]=r,e[1]=o):o=e[1];let a;e[2]!==s?(a=n.jsx(s,{size:13,className:"shrink-0"}),e[2]=s,e[3]=a):a=e[3];let l;return e[4]!==i||e[5]!==o||e[6]!==a?(l=n.jsxs("div",{className:o,children:[a,i]}),e[4]=i,e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function Xx(t){const e=U.c(47),{active:s,counts:i,showBlog:r,onSelect:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("div",{className:"px-3 h-12 flex items-center border-b shrink-0",children:n.jsx("span",{className:"text-sm font-medium",children:"Content"})}),e[0]=a):a=e[0];const l=s==="pages";let c;e[1]!==i.pages||e[2]!==o||e[3]!==l?(c=n.jsx(ds,{id:"pages",icon:Vi,label:"Pages",count:i.pages,active:l,onSelect:o}),e[1]=i.pages,e[2]=o,e[3]=l,e[4]=c):c=e[4];const d=s==="sections";let h;e[5]!==i.sections||e[6]!==o||e[7]!==d?(h=n.jsx(ds,{id:"sections",icon:yi,label:"Sections",count:i.sections,active:d,onSelect:o}),e[5]=i.sections,e[6]=o,e[7]=d,e[8]=h):h=e[8];const u=s==="apps";let f;e[9]!==i.apps||e[10]!==o||e[11]!==u?(f=n.jsx(ds,{id:"apps",icon:jh,label:"Apps",count:i.apps,active:u,onSelect:o}),e[9]=i.apps,e[10]=o,e[11]=u,e[12]=f):f=e[12];const m=s==="loaders";let p;e[13]!==i.loaders||e[14]!==o||e[15]!==m?(p=n.jsx(ds,{id:"loaders",icon:Xr,label:"Loaders",count:i.loaders,active:m,onSelect:o}),e[13]=i.loaders,e[14]=o,e[15]=m,e[16]=p):p=e[16];const g=s==="actions";let L;e[17]!==i.actions||e[18]!==o||e[19]!==g?(L=n.jsx(ds,{id:"actions",icon:wi,label:"Actions",count:i.actions,active:g,onSelect:o}),e[17]=i.actions,e[18]=o,e[19]=g,e[20]=L):L=e[20];const v=s==="site";let y;e[21]!==o||e[22]!==v?(y=n.jsx(ds,{id:"site",icon:F2,label:"Site",active:v,onSelect:o}),e[21]=o,e[22]=v,e[23]=y):y=e[23];const _=s==="seo";let x;e[24]!==o||e[25]!==_?(x=n.jsx(ds,{id:"seo",icon:Jr,label:"SEO",active:_,onSelect:o}),e[24]=o,e[25]=_,e[26]=x):x=e[26];const b=s==="calendar";let S;e[27]!==o||e[28]!==b?(S=n.jsx(ds,{id:"calendar",icon:Dd,label:"Calendar",active:b,onSelect:o}),e[27]=o,e[28]=b,e[29]=S):S=e[29];let w;e[30]!==s||e[31]!==i.authors||e[32]!==i.categories||e[33]!==i.posts||e[34]!==o||e[35]!==r?(w=r&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"mt-3 flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-xs font-medium text-muted-foreground/70",children:[n.jsx(ho,{size:13,className:"shrink-0"}),"Blog"]}),n.jsx(ds,{id:"posts",icon:Zi,label:"Posts",count:i.posts,active:s==="posts",onSelect:o}),n.jsx(ds,{id:"authors",icon:tc,label:"Authors",count:i.authors,active:s==="authors",onSelect:o}),n.jsx(ds,{id:"categories",icon:Od,label:"Categories",count:i.categories,active:s==="categories",onSelect:o})]}),e[30]=s,e[31]=i.authors,e[32]=i.categories,e[33]=i.posts,e[34]=o,e[35]=r,e[36]=w):w=e[36];let j;return e[37]!==L||e[38]!==y||e[39]!==x||e[40]!==S||e[41]!==w||e[42]!==c||e[43]!==h||e[44]!==f||e[45]!==p?(j=n.jsxs("div",{className:"w-[208px] shrink-0 border-r flex flex-col",children:[a,n.jsxs("nav",{className:"flex flex-col p-1.5 gap-0.5",children:[c,h,f,p,L,y,x,S,w]})]}),e[37]=L,e[38]=y,e[39]=x,e[40]=S,e[41]=w,e[42]=c,e[43]=h,e[44]=f,e[45]=p,e[46]=j):j=e[46],j}function ds(t){const e=U.c(18),{id:s,icon:i,label:r,count:o,active:a,onSelect:l}=t;let c;e[0]!==s||e[1]!==l?(c=()=>l(s),e[0]=s,e[1]=l,e[2]=c):c=e[2];const d=a?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground";let h;e[3]!==d?(h=ce("flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors cursor-pointer",d),e[3]=d,e[4]=h):h=e[4];let u;e[5]!==i?(u=n.jsx(i,{size:16,className:"shrink-0"}),e[5]=i,e[6]=u):u=e[6];let f;e[7]!==r?(f=n.jsx("span",{className:"flex-1 truncate",children:r}),e[7]=r,e[8]=f):f=e[8];let m;e[9]!==a||e[10]!==o?(m=o!==void 0&&n.jsx("span",{className:ce("shrink-0 text-xs tabular-nums",a?"text-accent-foreground/70":"text-muted-foreground/70"),children:o}),e[9]=a,e[10]=o,e[11]=m):m=e[11];let p;return e[12]!==c||e[13]!==h||e[14]!==u||e[15]!==f||e[16]!==m?(p=n.jsxs("button",{type:"button",onClick:c,className:h,children:[u,f,m]}),e[12]=c,e[13]=h,e[14]=u,e[15]=f,e[16]=m,e[17]=p):p=e[17],p}function Zx(t){const e=U.c(76),{activeCollection:s,pages:i,sections:r,availableSections:o,appCatalog:a,appCatalogLoading:l,blogEntries:c,decofile:d,searchQuery:h,onSearchChange:u,postCategoryFilter:f,postAuthorFilter:m,postSort:p,onPostCategoryFilterChange:g,onPostAuthorFilterChange:L,onPostSortChange:v,selectedPostKeys:y,postBulkPanelOpen:_,onTogglePostSelect:x,onSelectAllPosts:b,onClearPostSelection:S,onExitPostSelection:w,onBulkDeletePosts:j,selection:N,onSelect:T,onCreate:A,onDuplicatePage:k,onRenamePage:C,onAddPageVariant:I,onDeletePage:E,onEditPageSeo:O,onViewPageJson:P,onDuplicateSection:D,onRenameSection:M,onDeleteSection:z,onDuplicateBlog:F,onDeleteBlog:$}=t;let V,J,Z,G,q,H,K;if(e[0]!==s||e[1]!==a||e[2]!==l||e[3]!==o||e[4]!==c||e[5]!==d||e[6]!==I||e[7]!==j||e[8]!==S||e[9]!==A||e[10]!==$||e[11]!==E||e[12]!==z||e[13]!==F||e[14]!==k||e[15]!==D||e[16]!==O||e[17]!==w||e[18]!==L||e[19]!==g||e[20]!==v||e[21]!==C||e[22]!==M||e[23]!==u||e[24]!==T||e[25]!==b||e[26]!==x||e[27]!==P||e[28]!==i||e[29]!==m||e[30]!==_||e[31]!==f||e[32]!==p||e[33]!==h||e[34]!==r||e[35]!==y||e[36]!==N){const Y=h.toLowerCase(),Q=i.filter(ae=>!Y||ae.name.toLowerCase().includes(Y)||ae.path.toLowerCase().includes(Y)),ie=r.filter(ae=>!Y||ae.name.toLowerCase().includes(Y)||ae.key.toLowerCase().includes(Y)||ae.resolveType.toLowerCase().includes(Y)),oe=o.filter(ae=>!Y||ae.title.toLowerCase().includes(Y)||ae.resolveType.toLowerCase().includes(Y)||(ae.description?.toLowerCase().includes(Y)??!1)),ue=Wx(ie),ee=a.filter(ae=>!Y||ae.title.toLowerCase().includes(Y)||ae.app.toLowerCase().includes(Y)||ae.vendor.toLowerCase().includes(Y)||ae.category.toLowerCase().includes(Y)),te=c.filter(ae=>!Y||ae.label.toLowerCase().includes(Y)||ae.subtitle.toLowerCase().includes(Y)),fe=s==="posts",he=s7,ye=fe?b1(d):[],ve=new Map,be=new Map;for(const ae of ye){for(const He of ae.categorySlugs)ve.set(He,(ve.get(He)??0)+1);for(const He of ae.authorEmails)be.set(He,(be.get(He)??0)+1)}const Ne=(fe?er(d,"categories"):[]).map(ae=>{const{key:He,payload:it}=ae,Lt=he(it.slug)||He;return{slug:Lt,name:he(it.name)||he(it.slug)||He,count:ve.get(Lt)??0}}).filter(t7),Oe=(fe?er(d,"authors"):[]).map(ae=>{const{key:He,payload:it}=ae,Lt=he(it.email);return{email:Lt,name:he(it.name)||he(it.email)||He,count:be.get(Lt)??0}}).filter(e7);let Fe;e[44]!==f?(Fe=ae=>!f||ae.categorySlugs.includes(f),e[44]=f,e[45]=Fe):Fe=e[45];let Me;e[46]!==m?(Me=ae=>!m||ae.authorEmails.includes(m),e[46]=m,e[47]=Me):Me=e[47];let qe;e[48]!==p?(qe=(ae,He)=>{if(p==="az")return ae.title.localeCompare(He.title);if(p==="za")return He.title.localeCompare(ae.title);const it=ae.date.localeCompare(He.date);return p==="date-asc"?it:-it},e[48]=p,e[49]=qe):qe=e[49];const Ie=ye.filter(ae=>!Y||ae.title.toLowerCase().includes(Y)||ae.slug.toLowerCase().includes(Y)).filter(Fe).filter(Me).sort(qe),pe=y.size,je=Ie.map(Qx),Be=je.length>0&&je.every(ae=>y.has(ae)),le=pe>0||_,Le=()=>{Be?S():b(je)},Ce=`Search ${s}…`,_e=Vn(s)?`Create new ${Wn[s]}`:"Create new page",Re=s!=="apps"&&s!=="sections";q="w-[300px] shrink-0 border-r flex flex-col min-h-0";let Je;e[50]===Symbol.for("react.memo_cache_sentinel")?(Je=n.jsx(sc,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),e[50]=Je):Je=e[50];let $t;e[51]!==u?($t=ae=>u(ae.target.value),e[51]=u,e[52]=$t):$t=e[52];let Yt;e[53]!==Ce||e[54]!==h||e[55]!==$t?(Yt=n.jsxs("div",{className:"flex flex-1 items-center gap-2 pl-1",children:[Je,n.jsx("input",{type:"text",value:h,onChange:$t,placeholder:Ce,"aria-label":Ce,className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),e[53]=Ce,e[54]=h,e[55]=$t,e[56]=Yt):Yt=e[56];let cs;e[57]!==_e||e[58]!==A||e[59]!==Re?(cs=Re&&n.jsxs(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsx(re,{variant:"ghost",size:"icon",onClick:A,"aria-label":_e,children:n.jsx(It,{size:14})})}),n.jsx(Ae,{side:"bottom",children:_e})]}),e[57]=_e,e[58]=A,e[59]=Re,e[60]=cs):cs=e[60],e[61]!==Yt||e[62]!==cs?(H=n.jsxs("div",{className:"px-2 h-12 flex items-center gap-1 border-b shrink-0",children:[Yt,cs]}),e[61]=Yt,e[62]=cs,e[63]=H):H=e[63],K=fe&&(le?n.jsx(h7,{count:pe,allSelected:Be,onToggleSelectAll:Le,onDelete:j,onExit:w}):n.jsx(n7,{categories:Ne,authors:Oe,categoryFilter:f,authorFilter:m,sort:p,onCategoryFilterChange:g,onAuthorFilterChange:L,onSortChange:v})),V=ni,G="flex-1 min-h-0 [&_[data-slot=scroll-area-viewport]>div]:!block",J="flex flex-col gap-1 p-1.5",Z=s==="pages"?Q.length===0?n.jsx(bn,{hasItems:i.length>0,emptyLabel:"No pages yet.",emptyHint:'Click "+" to create your first page.'}):Q.map(ae=>{const He=N?.collection==="pages"&&N.key===ae.key,it=Mu(d,ae.key);return n.jsx(ws,{icon:Vi,title:ae.name,subtitle:ae.path,active:He,variantCount:it,onClick:()=>T({collection:"pages",key:ae.key,path:ae.path}),menu:n.jsx(Rr,{onDuplicate:()=>k(ae),onRename:()=>C(ae),onAddVariant:()=>I(ae),onEditSeo:()=>O(ae),onViewJson:()=>P(ae),onDelete:()=>E(ae)})},ae.key)}):s==="sections"?ie.length===0&&oe.length===0?n.jsx(bn,{hasItems:r.length>0||o.length>0,emptyLabel:"No sections yet.",emptyHint:"Save a section from a page, or start the preview dev server."}):n.jsxs(n.Fragment,{children:[ue.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(v0,{icon:yi,label:"Saved sections"}),ue.map(ae=>n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("div",{className:"px-2.5 pt-1 pb-0.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground/60",children:ae.label}),ae.sections.map(He=>{const it=N?.collection==="sections"&&N.key===He.key;return n.jsx(ws,{icon:yi,accent:"global",title:He.name,subtitle:ae.label,active:it,onClick:()=>T({collection:"sections",key:He.key}),menu:n.jsx(Rr,{onDuplicate:()=>D(He),onRename:()=>M(He),onDelete:()=>z(He)})},He.key)})]},ae.label))]}),oe.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(v0,{icon:Vi,label:"Available sections",className:ce(ue.length>0&&"mt-3")}),oe.map(ae=>{const He=N?.collection==="available-section"&&N.resolveType===ae.resolveType,it=ae.resolveType.split("/").pop()?.replace(/\.tsx?$/,"");return n.jsx(ws,{icon:Vi,title:ae.title,subtitle:it??ae.resolveType,active:He,onClick:()=>T({collection:"available-section",resolveType:ae.resolveType,title:ae.title})},ae.resolveType)})]})]}):s==="apps"?l?n.jsx("div",{className:"flex items-center justify-center py-8",children:n.jsx(Ue,{size:18,className:"animate-spin text-muted-foreground"})}):ee.length===0?n.jsx(bn,{hasItems:a.length>0,emptyLabel:"No apps found.",emptyHint:"Try a different search term."}):ee.map(ae=>{const He=N?.collection==="apps"&&ae.blockKey!==null&&N.key===ae.blockKey;return n.jsx(ws,{icon:jh,logoUrl:ae.logo,title:ae.title,subtitle:ae.category,active:He,trailing:ae.installed?n.jsx("span",{className:"shrink-0 rounded-full bg-emerald-500/15 px-1.5 py-0.5 text-[10px] font-medium text-emerald-700 dark:text-emerald-400",children:"Installed"}):void 0,onClick:()=>{if(!ae.installed||!ae.blockKey){me.message(`${ae.title} is not installed on this site.`);return}T({collection:"apps",key:ae.blockKey})}},ae.id)}):fe?Ie.length===0?n.jsx(bn,{hasItems:ye.length>0,emptyLabel:"No posts yet.",emptyHint:'Click "+" to create your first post.'}):Ie.map(ae=>{const He={key:ae.key,kind:"posts",label:ae.title,subtitle:ae.slug};return n.jsx(ws,{icon:Zi,title:ae.title,subtitle:ae.slug,active:N?.collection==="posts"&&N.key===ae.key,selectable:!0,selectionActive:le,selected:y.has(ae.key),onToggleSelect:()=>x(ae.key),onClick:()=>le?x(ae.key):T({collection:"posts",key:ae.key}),menu:n.jsx(Rr,{onDuplicate:()=>F(He),onDelete:()=>$(He)})},ae.key)}):te.length===0?n.jsx(bn,{hasItems:c.length>0,emptyLabel:`No ${s} yet.`,emptyHint:`Click "+" to create your first ${Vn(s)?Wn[s]:"item"}.`}):te.map(ae=>{const He=N?.collection===ae.kind&&N.key===ae.key;return n.jsx(ws,{icon:ae.kind==="posts"?Zi:ae.kind==="authors"?tc:Od,title:ae.label,subtitle:ae.subtitle,active:He,onClick:()=>T({collection:ae.kind,key:ae.key}),menu:n.jsx(Rr,{onDuplicate:()=>F(ae),onDelete:()=>$(ae)})},ae.key)}),e[0]=s,e[1]=a,e[2]=l,e[3]=o,e[4]=c,e[5]=d,e[6]=I,e[7]=j,e[8]=S,e[9]=A,e[10]=$,e[11]=E,e[12]=z,e[13]=F,e[14]=k,e[15]=D,e[16]=O,e[17]=w,e[18]=L,e[19]=g,e[20]=v,e[21]=C,e[22]=M,e[23]=u,e[24]=T,e[25]=b,e[26]=x,e[27]=P,e[28]=i,e[29]=m,e[30]=_,e[31]=f,e[32]=p,e[33]=h,e[34]=r,e[35]=y,e[36]=N,e[37]=V,e[38]=J,e[39]=Z,e[40]=G,e[41]=q,e[42]=H,e[43]=K}else V=e[37],J=e[38],Z=e[39],G=e[40],q=e[41],H=e[42],K=e[43];let B;e[64]!==J||e[65]!==Z?(B=n.jsx("div",{className:J,children:Z}),e[64]=J,e[65]=Z,e[66]=B):B=e[66];let X;e[67]!==V||e[68]!==G||e[69]!==B?(X=n.jsx(V,{className:G,children:B}),e[67]=V,e[68]=G,e[69]=B,e[70]=X):X=e[70];let W;return e[71]!==q||e[72]!==H||e[73]!==K||e[74]!==X?(W=n.jsxs("div",{className:q,children:[H,K,X]}),e[71]=q,e[72]=H,e[73]=K,e[74]=X,e[75]=W):W=e[75],W}function Qx(t){return t.key}function e7(t){return t.email}function t7(t){return t.slug}function s7(t){return typeof t=="string"?t:""}const x0="__all__",T1={"date-desc":"Newest first","date-asc":"Oldest first",az:"Title A–Z",za:"Title Z–A"},i7={"date-desc":"Newest","date-asc":"Oldest",az:"A–Z",za:"Z–A"},y0=R.forwardRef(function(e,s){const i=U.c(20);let r,o,a,l,c;i[0]!==e?({icon:r,active:o,value:c,className:a,...l}=e,i[0]=e,i[1]=r,i[2]=o,i[3]=a,i[4]=l,i[5]=c):(r=i[1],o=i[2],a=i[3],l=i[4],c=i[5]);const d=o?"text-foreground":"text-muted-foreground";let h;i[6]!==a||i[7]!==d?(h=ce("h-7 gap-1 px-1.5 text-xs",d,a),i[6]=a,i[7]=d,i[8]=h):h=i[8];let u;i[9]!==r?(u=n.jsx(r,{size:14,className:"shrink-0"}),i[9]=r,i[10]=u):u=i[10];let f;i[11]!==c?(f=c&&n.jsx("span",{className:"min-w-0 flex-1 truncate",children:c}),i[11]=c,i[12]=f):f=i[12];let m;i[13]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(ls,{size:12,className:"shrink-0 opacity-60"}),i[13]=m):m=i[13];let p;return i[14]!==l||i[15]!==s||i[16]!==h||i[17]!==u||i[18]!==f?(p=n.jsxs(re,{ref:s,type:"button",variant:"ghost",size:"sm",className:h,...l,children:[u,f,m]}),i[14]=l,i[15]=s,i[16]=h,i[17]=u,i[18]=f,i[19]=p):p=i[19],p});function E1(t){const e=U.c(2),{count:s}=t;let i;return e[0]!==s?(i=n.jsx("span",{className:"ml-auto pl-3 text-xs text-muted-foreground tabular-nums",children:s}),e[0]=s,e[1]=i):i=e[1],i}function n7(t){const e=U.c(60),{categories:s,authors:i,categoryFilter:r,authorFilter:o,sort:a,onCategoryFilterChange:l,onAuthorFilterChange:c,onSortChange:d}=t;let h;if(e[0]!==s||e[1]!==r){let J;e[3]!==r?(J=Z=>Z.slug===r,e[3]=r,e[4]=J):J=e[4],h=s.find(J),e[0]=s,e[1]=r,e[2]=h}else h=e[2];const u=h;let f;if(e[5]!==o||e[6]!==i){let J;e[8]!==o?(J=Z=>Z.email===o,e[8]=o,e[9]=J):J=e[9],f=i.find(J),e[5]=o,e[6]=i,e[7]=f}else f=e[7];const m=f,p=!!(r||o),g=u?.name??m?.name??"Filter",L=r?`cat:${r}`:o?`author:${o}`:x0;let v;e[10]!==c||e[11]!==l?(v=()=>{l(null),c(null)},e[10]=c,e[11]=l,e[12]=v):v=e[12];const y=v;let _;e[13]!==y||e[14]!==c||e[15]!==l?(_=J=>{J.startsWith("cat:")?(c(null),l(J.slice(4))):J.startsWith("author:")?(l(null),c(J.slice(7))):y()},e[13]=y,e[14]=c,e[15]=l,e[16]=_):_=e[16];const x=_;let b;e[17]!==g||e[18]!==p?(b=n.jsx(ns,{asChild:!0,children:n.jsx(y0,{icon:H2,active:p,value:g,className:"min-w-0 shrink"})}),e[17]=g,e[18]=p,e[19]=b):b=e[19];let S;e[20]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(vr,{children:"Filter by"}),e[20]=S):S=e[20];let w;e[21]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(Ro,{value:x0,children:"All posts"}),e[21]=w):w=e[21];let j;e[22]!==s.length?(j=s.length>0&&n.jsx(vr,{className:"text-muted-foreground/70",children:"Category"}),e[22]=s.length,e[23]=j):j=e[23];let N;e[24]!==s?(N=s.map(a7),e[24]=s,e[25]=N):N=e[25];let T;e[26]!==i.length?(T=i.length>0&&n.jsx(vr,{className:"text-muted-foreground/70",children:"Author"}),e[26]=i.length,e[27]=T):T=e[27];let A;e[28]!==i?(A=i.map(o7),e[28]=i,e[29]=A):A=e[29];let k;e[30]!==L||e[31]!==x||e[32]!==T||e[33]!==A||e[34]!==j||e[35]!==N?(k=n.jsxs(rs,{align:"start",className:"max-h-96 w-60 overflow-y-auto",children:[S,n.jsxs(f9,{value:L,onValueChange:x,children:[w,j,N,T,A]})]}),e[30]=L,e[31]=x,e[32]=T,e[33]=A,e[34]=j,e[35]=N,e[36]=k):k=e[36];let C;e[37]!==k||e[38]!==b?(C=n.jsxs(is,{children:[b,k]}),e[37]=k,e[38]=b,e[39]=C):C=e[39];let I;e[40]!==y||e[41]!==p?(I=p&&n.jsx(l7,{label:"Clear filter",onClick:y}),e[40]=y,e[41]=p,e[42]=I):I=e[42];const E=i7[a];let O;e[43]!==E?(O=n.jsx(ns,{asChild:!0,children:n.jsx(y0,{icon:U2,active:!0,value:E})}),e[43]=E,e[44]=O):O=e[44];let P;e[45]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx(vr,{children:"Sort by"}),e[45]=P):P=e[45];let D;e[46]!==d?(D=J=>d(J),e[46]=d,e[47]=D):D=e[47];let M;e[48]===Symbol.for("react.memo_cache_sentinel")?(M=Object.keys(T1),e[48]=M):M=e[48];let z;e[49]===Symbol.for("react.memo_cache_sentinel")?(z=M.map(r7),e[49]=z):z=e[49];let F;e[50]!==a||e[51]!==D?(F=n.jsxs(rs,{align:"end",className:"w-44",children:[P,n.jsx(f9,{value:a,onValueChange:D,children:z})]}),e[50]=a,e[51]=D,e[52]=F):F=e[52];let $;e[53]!==O||e[54]!==F?($=n.jsx("div",{className:"ml-auto shrink-0",children:n.jsxs(is,{children:[O,F]})}),e[53]=O,e[54]=F,e[55]=$):$=e[55];let V;return e[56]!==C||e[57]!==I||e[58]!==$?(V=n.jsxs("div",{className:"flex min-w-0 items-center gap-1 overflow-hidden border-b px-2 py-1.5",children:[C,I,$]}),e[56]=C,e[57]=I,e[58]=$,e[59]=V):V=e[59],V}function r7(t){return n.jsx(Ro,{value:t,children:T1[t]},t)}function o7(t){return n.jsxs(Ro,{value:`author:${t.email}`,children:[n.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.name}),n.jsx(E1,{count:t.count})]},`author:${t.email}`)}function a7(t){return n.jsxs(Ro,{value:`cat:${t.slug}`,children:[n.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.name}),n.jsx(E1,{count:t.count})]},`cat:${t.slug}`)}function l7(t){const e=U.c(4),{label:s,onClick:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(dn,{size:12}),e[0]=r):r=e[0];let o;return e[1]!==s||e[2]!==i?(o=n.jsx("button",{type:"button","aria-label":s,onClick:i,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground cursor-pointer",children:r}),e[1]=s,e[2]=i,e[3]=o):o=e[3],o}function c7(t){const e=U.c(12),{checked:s,disabled:i,onToggle:r}=t;let o;e[0]!==r?(o=()=>r(),e[0]=r,e[1]=o):o=e[1];const a=s?"Deselect all posts":"Select all posts";let l;e[2]!==s||e[3]!==i||e[4]!==o||e[5]!==a?(l=n.jsx(Ee,{asChild:!0,children:n.jsx("span",{className:"flex shrink-0 items-center px-1.5",onClick:d7,children:n.jsx(cn,{checked:s,disabled:i,onCheckedChange:o,"aria-label":a})})}),e[2]=s,e[3]=i,e[4]=o,e[5]=a,e[6]=l):l=e[6];const c=s?"Deselect all":"Select all";let d;e[7]!==c?(d=n.jsx(Ae,{side:"bottom",children:c}),e[7]=c,e[8]=d):d=e[8];let h;return e[9]!==l||e[10]!==d?(h=n.jsxs(Pe,{children:[l,d]}),e[9]=l,e[10]=d,e[11]=h):h=e[11],h}function d7(t){return t.stopPropagation()}function h7(t){const e=U.c(25),{count:s,allSelected:i,onToggleSelectAll:r,onDelete:o,onExit:a}=t;let l;e[0]!==i||e[1]!==r?(l=n.jsx(c7,{checked:i,onToggle:r}),e[0]=i,e[1]=r,e[2]=l):l=e[2];let c;e[3]!==s?(c=n.jsxs("span",{className:"text-xs font-medium tabular-nums",children:[s," selected"]}),e[3]=s,e[4]=c):c=e[4];const d=s===0;let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(os,{size:14}),e[5]=h):h=e[5];let u;e[6]!==o||e[7]!==d?(u=n.jsx(Ee,{asChild:!0,children:n.jsx(re,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive",disabled:d,onClick:o,"aria-label":"Delete selected posts",children:h})}),e[6]=o,e[7]=d,e[8]=u):u=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(Ae,{side:"bottom",children:"Delete selected"}),e[9]=f):f=e[9];let m;e[10]!==u?(m=n.jsxs(Pe,{children:[u,f]}),e[10]=u,e[11]=m):m=e[11];let p;e[12]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(dn,{size:14}),e[12]=p):p=e[12];let g;e[13]!==a?(g=n.jsx(Ee,{asChild:!0,children:n.jsx(re,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:a,"aria-label":"Exit selection",children:p})}),e[13]=a,e[14]=g):g=e[14];let L;e[15]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx(Ae,{side:"bottom",children:"Exit selection"}),e[15]=L):L=e[15];let v;e[16]!==g?(v=n.jsxs(Pe,{children:[g,L]}),e[16]=g,e[17]=v):v=e[17];let y;e[18]!==v||e[19]!==m?(y=n.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[m,v]}),e[18]=v,e[19]=m,e[20]=y):y=e[20];let _;return e[21]!==l||e[22]!==y||e[23]!==c?(_=n.jsxs("div",{className:"flex items-center gap-0.5 border-b bg-accent/40 px-2 py-1.5",children:[l,c,y]}),e[21]=l,e[22]=y,e[23]=c,e[24]=_):_=e[24],_}function ws(t){const e=U.c(37),{icon:s,logoUrl:i,title:r,subtitle:o,active:a,accent:l,variantCount:c,trailing:d,selectable:h,selectionActive:u,selected:f,onToggleSelect:m,onClick:p,menu:g}=t,L=l==="global";let v;e[0]!==s||e[1]!==a||e[2]!==L||e[3]!==i||e[4]!==c?(v=c&&c>1?n.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center",children:n.jsxs(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsx(s,{size:16,className:"shrink-0",style:{color:Qa}})}),n.jsxs(Ae,{side:"right",children:[c," variants"]})]})}):i?n.jsx("img",{src:i,alt:"",className:"size-8 shrink-0 rounded-lg object-cover bg-muted"}):n.jsx("span",{className:ce("flex size-8 shrink-0 items-center justify-center rounded-lg",L?"bg-global-section/15":"bg-muted"),children:n.jsx(s,{size:16,className:ce("shrink-0",!L&&(a?"text-accent-foreground":"text-muted-foreground")),style:L?{color:pc}:void 0})}),e[0]=s,e[1]=a,e[2]=L,e[3]=i,e[4]=c,e[5]=v):v=e[5];const y=v,_=a?L?"bg-global-section/15 text-global-section-fg dark:text-global-section-fg-dark":"bg-accent text-accent-foreground":L?"hover:bg-global-section/10":"hover:bg-muted";let x;e[6]!==_?(x=ce("group relative flex min-w-0 items-center rounded-md transition-colors",_),e[6]=_,e[7]=x):x=e[7];let b;e[8]!==m||e[9]!==h||e[10]!==f||e[11]!==u||e[12]!==r?(b=h&&n.jsx("span",{className:ce("flex shrink-0 items-center pl-2.5 transition-opacity",f||u?"opacity-100":"opacity-0 group-hover:opacity-100 focus-within:opacity-100"),onClick:u7,children:n.jsx(cn,{checked:f,onCheckedChange:()=>m?.(),"aria-label":`Select ${r}`})}),e[8]=m,e[9]=h,e[10]=f,e[11]=u,e[12]=r,e[13]=b):b=e[13];let S;e[14]!==r?(S=n.jsx("span",{className:"block truncate text-sm font-medium",children:r}),e[14]=r,e[15]=S):S=e[15];const w=a?"text-accent-foreground/70":"text-muted-foreground";let j;e[16]!==w?(j=ce("block truncate text-xs",w),e[16]=w,e[17]=j):j=e[17];let N;e[18]!==o||e[19]!==j?(N=n.jsx("span",{className:j,children:o}),e[18]=o,e[19]=j,e[20]=N):N=e[20];let T;e[21]!==S||e[22]!==N?(T=n.jsxs("span",{className:"min-w-0 flex-1",children:[S,N]}),e[21]=S,e[22]=N,e[23]=T):T=e[23];let A;e[24]!==p||e[25]!==y||e[26]!==T||e[27]!==d?(A=n.jsxs("button",{type:"button",onClick:p,className:"flex min-w-0 flex-1 items-center gap-2.5 rounded-md px-2.5 py-2 text-left cursor-pointer",children:[y,T,d]}),e[24]=p,e[25]=y,e[26]=T,e[27]=d,e[28]=A):A=e[28];let k;e[29]!==a||e[30]!==g?(k=g&&n.jsx("div",{className:ce("pr-1 opacity-0 transition-opacity group-hover:opacity-100",a&&"opacity-100"),children:g}),e[29]=a,e[30]=g,e[31]=k):k=e[31];let C;return e[32]!==A||e[33]!==k||e[34]!==x||e[35]!==b?(C=n.jsxs("div",{className:x,children:[b,A,k]}),e[32]=A,e[33]=k,e[34]=x,e[35]=b,e[36]=C):C=e[36],C}function u7(t){return t.stopPropagation()}function Rr(t){const e=U.c(21),{onDuplicate:s,onRename:i,onAddVariant:r,onEditSeo:o,onViewJson:a,onDelete:l}=t;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(ns,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":"More actions",className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-background hover:text-foreground cursor-pointer",onClick:f7,children:n.jsx(ln,{size:14})})}),e[0]=c):c=e[0];let d;e[1]!==i?(d=i&&n.jsxs(We,{onClick:i,children:[n.jsx(nc,{size:14}),"Rename"]}),e[1]=i,e[2]=d):d=e[2];let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(ts,{size:14}),e[3]=h):h=e[3];let u;e[4]!==s?(u=n.jsxs(We,{onClick:s,children:[h,"Duplicate"]}),e[4]=s,e[5]=u):u=e[5];let f;e[6]!==r?(f=r&&n.jsxs(n.Fragment,{children:[n.jsx(zn,{}),n.jsxs(We,{onClick:r,className:"cursor-pointer",style:{color:Qa},children:[n.jsx(Id,{size:14,style:{color:Qa}}),"Add variant"]})]}),e[6]=r,e[7]=f):f=e[7];let m;e[8]!==o||e[9]!==a?(m=(o||a)&&n.jsxs(n.Fragment,{children:[n.jsx(zn,{}),o&&n.jsxs(We,{onClick:o,children:[n.jsx(Jr,{size:14}),"Edit SEO"]}),a&&n.jsxs(We,{onClick:a,children:[n.jsx(nr,{size:14}),"View JSON"]})]}),e[8]=o,e[9]=a,e[10]=m):m=e[10];let p;e[11]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(zn,{}),e[11]=p):p=e[11];let g;e[12]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(os,{size:14}),e[12]=g):g=e[12];let L;e[13]!==l?(L=n.jsxs(We,{onClick:l,className:"text-destructive focus:text-destructive",children:[g,"Delete"]}),e[13]=l,e[14]=L):L=e[14];let v;return e[15]!==d||e[16]!==u||e[17]!==f||e[18]!==m||e[19]!==L?(v=n.jsxs(is,{children:[c,n.jsxs(rs,{align:"end",className:"w-44",children:[d,u,f,m,p,L]})]}),e[15]=d,e[16]=u,e[17]=f,e[18]=m,e[19]=L,e[20]=v):v=e[20],v}function f7(t){return t.stopPropagation()}function bn(t){const e=U.c(6),{hasItems:s,emptyLabel:i,emptyHint:r}=t;let o;e[0]!==r||e[1]!==i||e[2]!==s?(o=s?"No results match your search.":n.jsxs(n.Fragment,{children:[n.jsx("div",{children:i}),n.jsx("div",{className:"mt-1 text-muted-foreground/80",children:r})]}),e[0]=r,e[1]=i,e[2]=s,e[3]=o):o=e[3];let a;return e[4]!==o?(a=n.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o}),e[4]=o,e[5]=a):a=e[5],a}function m7(t){const e=U.c(12),{state:s,claimPhase:i,lifecycle:r,onStart:o,connectionsHref:a}=t;switch(s.kind){case"starting":{let l;e[0]!==i||e[1]!==r?(l=Ku({claimPhase:i,lifecycle:r}),e[0]=i,e[1]=r,e[2]=l):l=e[2];let c;return e[3]!==i||e[4]!==l?(c=n.jsx(Ji,{kind:"starting",progress:l,claimPhase:i}),e[3]=i,e[4]=l,e[5]=c):c=e[5],c}case"suspended":{let l;return e[6]!==o?(l=n.jsx(Ji,{kind:"suspended",onResume:o}),e[6]=o,e[7]=l):l=e[7],l}case"errored":{let l;return e[8]!==a||e[9]!==o||e[10]!==s.error?(l=n.jsx(Ji,{kind:"errored",error:s.error,onRetry:o,connectionsHref:a}),e[8]=a,e[9]=o,e[10]=s.error,e[11]=l):l=e[11],l}}}function qs(t){const e=U.c(10),{icon:s,title:i,description:r}=t;let o;e[0]!==s?(o=s&&n.jsx(s,{size:24,className:"text-muted-foreground/60"}),e[0]=s,e[1]=o):o=e[1];let a;e[2]!==i?(a=n.jsx("div",{children:i}),e[2]=i,e[3]=a):a=e[3];let l;e[4]!==r?(l=r&&n.jsx("div",{className:"text-xs text-muted-foreground/80 max-w-sm",children:r}),e[4]=r,e[5]=l):l=e[5];let c;return e[6]!==o||e[7]!==a||e[8]!==l?(c=n.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 p-6 text-center text-sm text-muted-foreground",children:[o,a,l]}),e[6]=o,e[7]=a,e[8]=l,e[9]=c):c=e[9],c}function p7(t){const e=U.c(2),{virtualMcpId:s}=t,i=Ts(s);if(!vi(i?.metadata)){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[n.jsx(Ei,{size:24,className:"text-muted-foreground/60"}),n.jsx("div",{children:"No content to edit."}),n.jsx("div",{className:"text-xs text-muted-foreground/80",children:"Connect a GitHub repository from the Settings tab to enable Content."})]}),e[0]=a):a=e[0],a}let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(Vx,{}),e[1]=o):o=e[1],o}const ya={fast:{label:"Fast",subtitle:"Quick responses for simple tasks",icon:Ad},smart:{label:"Smart",subtitle:"Balanced quality and speed",icon:gi},thinking:{label:"Thinking",subtitle:"Deeper reasoning for hard tasks",icon:G2}},g7=["fast","smart","thinking"];function _7(t){const e=U.c(15),{tier:s,onSelect:i}=t,[r,o]=R.useState(!1),a=ya[s].icon;let l;e[0]!==a?(l=n.jsx(a,{size:14,className:"text-muted-foreground"}),e[0]=a,e[1]=l):l=e[1];const c=ya[s];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(ls,{size:14,className:"text-muted-foreground"}),e[2]=d):d=e[2];let h;e[3]!==l||e[4]!==c.label?(h=n.jsx(ps,{asChild:!0,children:n.jsxs(re,{variant:"outline",size:"sm",className:"w-fit gap-1.5",children:[l,c.label,d]})}),e[3]=l,e[4]=c.label,e[5]=h):h=e[5];let u;e[6]!==i||e[7]!==s?(u=g7.map(p=>{const g=ya[p],L=g.icon;return n.jsxs("button",{type:"button",onClick:()=>{i(p),o(!1)},className:ce("flex items-start gap-2 px-2 py-1.5 rounded-md text-left hover:bg-muted"),children:[n.jsx(L,{size:16,className:"shrink-0 text-muted-foreground mt-0.5"}),n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:"text-sm",children:g.label}),n.jsx("div",{className:"text-xs text-muted-foreground",children:g.subtitle})]}),p===s&&n.jsx(Wt,{size:14,className:"text-foreground mt-0.5"})]},p)}),e[6]=i,e[7]=s,e[8]=u):u=e[8];let f;e[9]!==u?(f=n.jsx(gs,{align:"start",className:"p-1 w-64",children:n.jsx("div",{className:"flex flex-col",children:u})}),e[9]=u,e[10]=f):f=e[10];let m;return e[11]!==r||e[12]!==h||e[13]!==f?(m=n.jsxs(ms,{open:r,onOpenChange:o,children:[h,f]}),e[11]=r,e[12]=h,e[13]=f,e[14]=m):m=e[14],m}function L7(t){const e=U.c(15),{tier:s,onTierChange:i,override:r,onOverrideChange:o}=t,[a,l]=R.useState(r!==null);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Model"}),e[0]=c):c=e[0];let d;e[1]!==o||e[2]!==i||e[3]!==r||e[4]!==s||e[5]!==a?(d=a?n.jsx(R.Suspense,{fallback:n.jsx(re,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:"Loading models…"}),children:n.jsx(v7,{override:r,onOverrideChange:o})}):n.jsx(_7,{tier:s,onSelect:i}),e[1]=o,e[2]=i,e[3]=r,e[4]=s,e[5]=a,e[6]=d):d=e[6];let h;e[7]!==o?(h=m=>{l(m),m||o(null)},e[7]=o,e[8]=h):h=e[8];let u;e[9]!==h||e[10]!==a?(u=n.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground cursor-pointer select-none",children:[n.jsx(Jn,{checked:a,onCheckedChange:h,className:"cursor-pointer"}),"Specific model"]}),e[9]=h,e[10]=a,e[11]=u):u=e[11];let f;return e[12]!==d||e[13]!==u?(f=n.jsxs("div",{className:"flex flex-col gap-2",children:[c,n.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[d,u]})]}),e[12]=d,e[13]=u,e[14]=f):f=e[14],f}function v7(t){const e=U.c(10),{override:s,onOverrideChange:i}=t,r=ih(),o=r[0]?.id??null,[a,l]=R.useState(s?.credentialId??o);let c;e[0]!==s?(c=s?{modelId:s.modelId,title:s.title||s.modelId,keyId:s.credentialId,providerId:"deco",description:null,logo:null,capabilities:[],limits:null,costs:null}:null,e[0]=s,e[1]=c):c=e[1];const d=c;if(r.length===0){let f;return e[2]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Connect an AI provider in settings to pick a specific model."}),e[2]=f):f=e[2],f}let h;e[3]!==a||e[4]!==i?(h=f=>{const m=f.keyId??a??"";l(m),i({modelId:f.modelId,credentialId:m,title:f.title??f.modelId})},e[3]=a,e[4]=i,e[5]=h):h=e[5];let u;return e[6]!==a||e[7]!==d||e[8]!==h?(u=n.jsx("div",{className:"w-fit max-w-full [&_button]:rounded-md",children:n.jsx(F3,{variant:"bordered",placeholder:"Pick a model",model:d,credentialId:a,onCredentialChange:l,onModelChange:h})}),e[6]=a,e[7]=d,e[8]=h,e[9]=u):u=e[9],u}const A1=[{key:"capabilities",heading:"Built-in capabilities",icon:rc,tools:[{name:"web_search",title:"Web search",description:"Look up current information on the web",icon:Pi},{name:"generate_image",title:"Generate image",description:"Create images from a text prompt",icon:bi},{name:"subtask",title:"Subtask",description:"Spawn a focused sub-agent to handle part of the work",icon:No},{name:"user_ask",title:"Ask the user",description:"Pause to ask the user a clarifying question",icon:K2}]},{key:"files",heading:"Files & code",icon:en,tools:[{name:"read",title:"Read File",description:"Read a file from the workspace",icon:vh},{name:"write",title:"Write File",description:"Create or overwrite a file",icon:nc},{name:"edit",title:"Edit File",description:"Make targeted edits to an existing file",icon:W2},{name:"grep",title:"Search Content",description:"Search file contents by pattern",icon:Xn},{name:"glob",title:"Find Files",description:"Find files by name pattern",icon:en},{name:"bash",title:"Run Command",description:"Run shell commands in the sandbox",icon:V2}]},{key:"context",heading:"Context",icon:Xr,tools:[{name:"read_resource",title:"Read Resource",description:"Read an MCP resource by URI",icon:Xr},{name:"read_prompt",title:"Read Prompt",description:"Read an MCP prompt definition",icon:ho},{name:"skill",title:"Load Skill",description:"Load a skill's full instructions (SKILL.md) by id",icon:ho}]},{key:"browser",heading:"Browser",icon:yi,tools:[{name:"take_screenshot",title:"Take Screenshot",description:"Capture a screenshot of a web page",icon:fh},{name:"scrape_url",title:"Scrape URL",description:"Fetch and extract content from a URL",icon:yi},{name:"inspect_page",title:"Inspect Page",description:"Inspect a web page's structure",icon:nr}]}],x7=A1.flatMap(t=>t.tools.map(e=>e.name));function y7(t){const e=t.replace(/[_-]+/g," ").trim();return e?e.toLowerCase().replace(/\b\w/g,s=>s.toUpperCase()):t}function b7(t){const e=U.c(5),{agentId:s,value:i,onChange:r}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Tools"}),e[0]=o):o=e[0];let a;return e[1]!==s||e[2]!==r||e[3]!==i?(a=n.jsxs("div",{className:"flex flex-col gap-2",children:[o,s?n.jsx(R.Suspense,{fallback:n.jsxs(re,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:[n.jsx(rc,{size:14}),"Loading tools…"]}),children:n.jsx(S7,{agentId:s,value:i,onChange:r})}):n.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Pick an agent first"})]}),e[1]=s,e[2]=r,e[3]=i,e[4]=a):a=e[4],a}function b0(t){const e=U.c(17),{value:s,checked:i,onToggle:r,title:o,description:a,leading:l}=t;let c;e[0]!==i?(c=n.jsx(cn,{checked:i,className:"pointer-events-none mt-0.5"}),e[0]=i,e[1]=c):c=e[1];let d;e[2]!==l?(d=l&&n.jsx("span",{className:"mt-px shrink-0",children:l}),e[2]=l,e[3]=d):d=e[3];let h;e[4]!==o?(h=n.jsx("span",{className:"truncate text-sm leading-tight",children:o}),e[4]=o,e[5]=h):h=e[5];let u;e[6]!==a?(u=a&&n.jsx("span",{className:"line-clamp-2 text-xs leading-snug text-muted-foreground",children:a}),e[6]=a,e[7]=u):u=e[7];let f;e[8]!==h||e[9]!==u?(f=n.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[h,u]}),e[8]=h,e[9]=u,e[10]=f):f=e[10];let m;return e[11]!==r||e[12]!==c||e[13]!==d||e[14]!==f||e[15]!==s?(m=n.jsxs(Xs,{value:s,onSelect:r,className:"items-start gap-2.5 py-2",children:[c,d,f]}),e[11]=r,e[12]=c,e[13]=d,e[14]=f,e[15]=s,e[16]=m):m=e[16],m}function S0(t){const e=U.c(20),{conn:s,label:i,icon:r,on:o,total:a,onToggle:l}=t,c=o===a;let d;e[0]!==r||e[1]!==s?(d=s?n.jsx(Es,{icon:s.icon,name:s.title,size:"2xs"}):r?n.jsx(r,{size:14,className:"text-muted-foreground"}):n.jsx(q2,{size:14,className:"text-muted-foreground"}),e[0]=r,e[1]=s,e[2]=d):d=e[2];const h=s?.title??i??"Other tools";let u;e[3]!==h?(u=n.jsx("span",{className:"truncate",children:h}),e[3]=h,e[4]=u):u=e[4];let f;e[5]!==o||e[6]!==a?(f=n.jsxs("span",{className:"text-[11px] font-normal tabular-nums text-muted-foreground/70",children:[o,"/",a]}),e[5]=o,e[6]=a,e[7]=f):f=e[7];let m;e[8]!==l?(m=y=>{y.stopPropagation(),l()},e[8]=l,e[9]=m):m=e[9];const p=c?"None":"All";let g;e[10]!==m||e[11]!==p?(g=n.jsx("button",{type:"button",onClick:m,className:"text-[11px] font-medium text-primary hover:underline",children:p}),e[10]=m,e[11]=p,e[12]=g):g=e[12];let L;e[13]!==f||e[14]!==g?(L=n.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[f,g]}),e[13]=f,e[14]=g,e[15]=L):L=e[15];let v;return e[16]!==d||e[17]!==u||e[18]!==L?(v=n.jsxs("div",{className:"flex items-center gap-2",children:[d,u,L]}),e[16]=d,e[17]=u,e[18]=L,e[19]=v):v=e[19],v}function S7(t){const e=U.c(70),{agentId:s,value:i,onChange:r}=t,{org:o}=Ge(),[a,l]=R.useState(!1);let c;e[0]!==s||e[1]!==o.id||e[2]!==o.slug?(c={connectionId:s,orgId:o.id,orgSlug:o.slug},e[0]=s,e[1]=o.id,e[2]=o.slug,e[3]=c):c=e[3];const d=Dt(c);let h;e[4]!==d?(h={client:d},e[4]=d,e[5]=h):h=e[5];const{data:u,isLoading:f}=ph(h),m=rr();let p,g,L,v,y,_,x,b,S,w,j,N,T;if(e[6]!==m||e[7]!==u?.tools||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==i){const E=new Map(m.map(N7)),O=new Map;for(const ee of u?.tools??[]){const te=hm(ee._meta)??"__other__",fe=um(ee.name,te==="__other__"?void 0:te),he=ee.title,ye=he&&he!==ee.name?he:y7(fe);O.has(te)||O.set(te,{clientId:te,conn:E.get(te),tools:[]}),O.get(te).tools.push({name:ee.name,display:ye,description:ee.description})}const P=[...O.values()].sort(k7),D=(u?.tools??[]).map(j7),M=[...x7,...D],z=i===null?new Set(M):new Set(i),F=M.every(ee=>z.has(ee)),$=ee=>r(M.every(te=>ee.has(te))?null:[...ee]),V=ee=>{const te=new Set(z);te.has(ee)?te.delete(ee):te.add(ee),$(te)},J=(ee,te)=>{const fe=new Set(z);for(const he of ee)te?fe.add(he):fe.delete(he);$(fe)};v=ms,T=a,y=l;let Z;e[25]===Symbol.for("react.memo_cache_sentinel")?(Z=n.jsx(rc,{size:14,className:"text-muted-foreground"}),e[25]=Z):Z=e[25];const G=F?"All tools":"Tools",q=!F&&n.jsxs(z3,{variant:"secondary",className:"ml-0.5 h-5 px-1.5 text-[11px] tabular-nums",children:[z.size,"/",M.length]});let H;e[26]===Symbol.for("react.memo_cache_sentinel")?(H=n.jsx(ls,{size:14,className:"text-muted-foreground"}),e[26]=H):H=e[26],e[27]!==G||e[28]!==q?(_=n.jsx(ps,{asChild:!0,children:n.jsxs(re,{variant:"outline",size:"sm",className:"w-fit gap-1.5",children:[Z,G,q,H]})}),e[27]=G,e[28]=q,e[29]=_):_=e[29],L=gs,j="p-0 w-80",N="start",g=Oo,e[30]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(lr,{placeholder:"Search tools..."}),e[30]=S):S=e[30];const K=F?`All ${M.length} tools enabled`:`${z.size} of ${M.length} enabled`;let B;e[31]!==K?(B=n.jsx("span",{className:"text-xs text-muted-foreground",children:K}),e[31]=K,e[32]=B):B=e[32];let X;e[33]!==r?(X=()=>r(null),e[33]=r,e[34]=X):X=e[34];let W;e[35]!==F||e[36]!==X?(W=n.jsx("button",{type:"button",onClick:X,disabled:F,className:"text-xs font-medium text-primary hover:underline disabled:cursor-default disabled:opacity-40 disabled:no-underline",children:"Select all"}),e[35]=F,e[36]=X,e[37]=W):W=e[37];let Y;e[38]===Symbol.for("react.memo_cache_sentinel")?(Y=n.jsx("span",{className:"text-muted-foreground/30",children:"·"}),e[38]=Y):Y=e[38];let Q;e[39]!==r?(Q=()=>r([]),e[39]=r,e[40]=Q):Q=e[40];const ie=z.size===0;let oe;e[41]!==Q||e[42]!==ie?(oe=n.jsx("button",{type:"button",onClick:Q,disabled:ie,className:"text-xs font-medium text-muted-foreground hover:underline disabled:cursor-default disabled:opacity-40 disabled:no-underline",children:"Clear"}),e[41]=Q,e[42]=ie,e[43]=oe):oe=e[43];let ue;e[44]!==W||e[45]!==oe?(ue=n.jsxs("div",{className:"flex items-center gap-2",children:[W,Y,oe]}),e[44]=W,e[45]=oe,e[46]=ue):ue=e[46],e[47]!==B||e[48]!==ue?(w=n.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[B,ue]}),e[47]=B,e[48]=ue,e[49]=w):w=e[49],p=dr,x="max-h-80",b=f?n.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"Loading tools…"}):n.jsxs(n.Fragment,{children:[n.jsx(cr,{children:"No tools found"}),A1.map(ee=>{const te=ee.tools.map(C7),fe=te.filter(he=>z.has(he)).length;return n.jsx(Si,{heading:n.jsx(S0,{label:ee.heading,icon:ee.icon,on:fe,total:te.length,onToggle:()=>J(te,fe!==te.length)}),children:ee.tools.map(he=>n.jsx(b0,{value:`${he.title} ${he.name}`,checked:z.has(he.name),onToggle:()=>V(he.name),title:he.title,description:he.description,leading:n.jsx(he.icon,{size:16,className:"text-muted-foreground"})},he.name))},ee.key)}),P.map(ee=>{const te=ee.tools.map(w7),fe=te.filter(he=>z.has(he)).length;return n.jsx(Si,{heading:n.jsx(S0,{conn:ee.conn,on:fe,total:te.length,onToggle:()=>J(te,fe!==te.length)}),children:ee.tools.map(he=>n.jsx(b0,{value:`${he.display} ${he.name} ${ee.conn?.title??""}`,checked:z.has(he.name),onToggle:()=>V(he.name),title:he.display,description:he.description},he.name))},ee.clientId)})]}),e[6]=m,e[7]=u?.tools,e[8]=f,e[9]=r,e[10]=a,e[11]=i,e[12]=p,e[13]=g,e[14]=L,e[15]=v,e[16]=y,e[17]=_,e[18]=x,e[19]=b,e[20]=S,e[21]=w,e[22]=j,e[23]=N,e[24]=T}else p=e[12],g=e[13],L=e[14],v=e[15],y=e[16],_=e[17],x=e[18],b=e[19],S=e[20],w=e[21],j=e[22],N=e[23],T=e[24];let A;e[50]!==p||e[51]!==x||e[52]!==b?(A=n.jsx(p,{className:x,children:b}),e[50]=p,e[51]=x,e[52]=b,e[53]=A):A=e[53];let k;e[54]!==g||e[55]!==A||e[56]!==S||e[57]!==w?(k=n.jsxs(g,{children:[S,w,A]}),e[54]=g,e[55]=A,e[56]=S,e[57]=w,e[58]=k):k=e[58];let C;e[59]!==L||e[60]!==k||e[61]!==j||e[62]!==N?(C=n.jsx(L,{className:j,align:N,children:k}),e[59]=L,e[60]=k,e[61]=j,e[62]=N,e[63]=C):C=e[63];let I;return e[64]!==v||e[65]!==y||e[66]!==_||e[67]!==C||e[68]!==T?(I=n.jsxs(v,{open:T,onOpenChange:y,children:[_,C]}),e[64]=v,e[65]=y,e[66]=_,e[67]=C,e[68]=T,e[69]=I):I=e[69],I}function w7(t){return t.name}function C7(t){return t.name}function j7(t){return t.name}function k7(t,e){return(t.conn?.title??t.clientId).localeCompare(e.conn?.title??e.clientId)}function N7(t){return[t.id,t]}function Gn(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function T7(t){if(!t)return"Unknown schedule";const e=t.trim();if(e==="* * * * *")return"Every minute";if(e==="0 * * * *")return"Every hour";if(e==="0 0 * * *")return"Every day";if(e==="0 0 * * 1")return"Every week";const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return`Every ${s[1]} minutes`;const i=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(i)return`Every ${i[1]} hours`;const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(r){const l=parseInt(r[1]??"1");return l%7===0?`Every ${l/7} weeks`:`Every ${l} days`}const o=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+\*$/);if(o){const l=(o[2]??"0").padStart(2,"0"),c=(o[1]??"0").padStart(2,"0");return`Every day at ${l}:${c} UTC`}const a=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+(\d)$/);if(a){const c=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][parseInt(a[3]??"0")]??"day",d=(a[2]??"0").padStart(2,"0"),h=(a[1]??"0").padStart(2,"0");return`Every ${c} at ${d}:${h} UTC`}return t}function E7(t,e){const s=Math.max(1,t);switch(e){case"minutes":return s===1?"* * * * *":`*/${s} * * * *`;case"hours":return s===1?"0 * * * *":`0 */${s} * * *`;case"days":return s===1?"0 0 * * *":`0 0 */${s} * *`;case"weeks":return s===1?"0 0 * * 1":`0 0 */${s*7} * *`}}function A7(t){const e=t.trim();if(e==="* * * * *")return{count:1,unit:"minutes"};if(e==="0 * * * *")return{count:1,unit:"hours"};if(e==="0 0 * * *")return{count:1,unit:"days"};if(e==="0 0 * * 1")return{count:1,unit:"weeks"};const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return{count:parseInt(s[1]),unit:"minutes"};const i=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(i)return{count:parseInt(i[1]),unit:"hours"};const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);return r?{count:parseInt(r[1]),unit:"days"}:null}function P7(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const R7=[{label:"5 minutes",cron:"*/5 * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function D7({automationId:t,open:e,onOpenChange:s,onCustomSelect:i,onEventSelect:r,onWebhookCreated:o}){const{triggerAdd:a}=hr(),[l,c]=R.useState(!1),d=e??l,h=m=>{s?s(m):c(m)},u=async m=>{try{await a.mutateAsync({automation_id:t,type:"cron",cron_expression:m}),me.success("Starter added"),h(!1)}catch(p){const g=p instanceof Error?p.message:"Failed to add starter";me.error(g)}},f=async()=>{try{const m=await a.mutateAsync({automation_id:t,type:"webhook"});h(!1),m.webhook?o?.(m.webhook):me.success("Webhook starter added")}catch(m){const p=m instanceof Error?m.message:"Failed to add webhook starter";me.error(p)}};return n.jsxs(is,{open:d,onOpenChange:h,children:[n.jsx(ns,{asChild:!0,children:n.jsxs(re,{variant:"outline",size:"sm",children:[n.jsx(It,{size:14}),"Add Starter"]})}),n.jsxs(rs,{align:"end",className:"w-[200px]",children:[n.jsxs(Ha,{children:[n.jsxs(Ua,{className:"gap-2.5",children:[n.jsx(Fn,{size:14,className:"text-muted-foreground shrink-0"}),"Every..."]}),n.jsx(Ka,{className:"w-[160px]",children:R7.map(m=>n.jsxs(We,{className:"gap-2.5",onSelect:()=>u(m.cron),disabled:a.isPending,children:[n.jsx(Fn,{size:14,className:"text-muted-foreground shrink-0"}),"Every ",m.label]},m.cron))})]}),n.jsxs(We,{className:"gap-2.5",onSelect:()=>{h(!1),i?.()},children:[n.jsx(Fn,{size:14,className:"text-muted-foreground shrink-0"}),"Custom (cron)"]}),n.jsxs(We,{className:"gap-2.5",onSelect:()=>{h(!1),r?.()},children:[n.jsx(wi,{size:14,className:"text-muted-foreground shrink-0"}),"Event"]}),n.jsxs(We,{className:"gap-2.5",onSelect:()=>{f()},disabled:a.isPending,children:[n.jsx(Pi,{size:14,className:"text-muted-foreground shrink-0"}),"Webhook"]})]})]})}function P1(t){const e=U.c(31),{open:s,onOpenChange:i,url:r,token:o,title:a,description:l}=t,c=a===void 0?"Webhook ready":a,d=l===void 0?"Send a POST to this URL with the bearer token to fire the automation. The token is shown once — copy it now.":l,[h,u]=R.useState(null),[f,m]=R.useState("curl"),[p,g]=R.useState("header"),L=R.useId();let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=async(E,O)=>{try{await navigator.clipboard.writeText(E),u(O),me.success("Copied"),setTimeout(()=>u(null),1500)}catch{me.error("Failed to copy")}},e[0]=v):v=e[0];const y=v;let _;e[1]!==p||e[2]!==o||e[3]!==r?(_=r&&o&&p==="url"?`${r.replace(/\/$/,"")}/${o}`:r??"",e[1]=p,e[2]=o,e[3]=r,e[4]=_):_=e[4];const x=_,b=r&&o?p==="header"?`curl -X POST "${x}" \\
|
|
478
|
-
-H "Authorization: Bearer ${o}" \\
|
|
479
|
-
-H "Content-Type: application/json" \\
|
|
480
|
-
-d '{"hello":"world"}'`:`curl -X POST "${x}" \\
|
|
481
|
-
-H "Content-Type: application/json" \\
|
|
482
|
-
-d '{"hello":"world"}'`:"",S=r&&o?p==="header"?`await fetch("${x}", {
|
|
483
|
-
method: "POST",
|
|
484
|
-
headers: {
|
|
485
|
-
Authorization: "Bearer ${o}",
|
|
486
|
-
"Content-Type": "application/json",
|
|
487
|
-
},
|
|
488
|
-
body: JSON.stringify({ hello: "world" }),
|
|
489
|
-
});`:`await fetch("${x}", {
|
|
490
|
-
method: "POST",
|
|
491
|
-
headers: {
|
|
492
|
-
"Content-Type": "application/json",
|
|
493
|
-
},
|
|
494
|
-
body: JSON.stringify({ hello: "world" }),
|
|
495
|
-
});`:"",w=f==="curl"?b:S;let j;e[5]!==c?(j=n.jsx(Ls,{children:c}),e[5]=c,e[6]=j):j=e[6];let N;e[7]!==d?(N=n.jsx(or,{children:d}),e[7]=d,e[8]=N):N=e[8];let T;e[9]!==j||e[10]!==N?(T=n.jsxs(_s,{children:[j,N]}),e[9]=j,e[10]=N,e[11]=T):T=e[11];let A;e[12]!==p||e[13]!==h||e[14]!==x||e[15]!==f||e[16]!==w||e[17]!==o||e[18]!==L||e[19]!==r?(A=r&&o?n.jsxs("div",{className:"flex flex-col gap-3 min-w-0",children:[n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"URL"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("code",{className:"flex-1 min-w-0 text-xs font-mono bg-muted rounded-md px-2 py-1.5 truncate",children:x}),n.jsxs(re,{size:"sm",variant:"outline",onClick:()=>y(x,"url"),children:[n.jsx(ts,{size:13}),h==="url"?"Copied":"Copy"]})]})]}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"Token (shown once)"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("code",{className:"flex-1 min-w-0 text-xs font-mono bg-muted rounded-md px-2 py-1.5 truncate",children:o}),n.jsxs(re,{size:"sm",variant:"outline",onClick:()=>y(o,"token"),children:[n.jsx(ts,{size:13}),h==="token"?"Copied":"Copy"]})]})]}),n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"Snippet"}),n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(Io,{value:f,onValueChange:E=>m(E),children:n.jsxs(Do,{className:"h-8 p-[2px]",children:[n.jsx(Js,{value:"curl",className:"h-7 px-2.5 text-xs",children:"curl"}),n.jsx(Js,{value:"fetch",className:"h-7 px-2.5 text-xs",children:"fetch"})]})}),n.jsxs("label",{htmlFor:L,className:"flex items-center gap-1.5 text-xs text-muted-foreground cursor-pointer select-none",children:[n.jsx(cn,{id:L,checked:p==="url",onCheckedChange:E=>g(E?"url":"header")}),"Token in URL"]})]}),n.jsxs(re,{size:"sm",variant:"outline",onClick:()=>y(w,"example"),children:[n.jsx(ts,{size:13}),h==="example"?"Copied":"Copy"]})]}),n.jsx("div",{className:"rounded-md border overflow-hidden min-w-0",children:n.jsx(Mo,{code:w,language:f==="curl"?"shell":"typescript",readOnly:!0,disableDiagnostics:!0,height:180})})]})]}):null,e[12]=p,e[13]=h,e[14]=x,e[15]=f,e[16]=w,e[17]=o,e[18]=L,e[19]=r,e[20]=A):A=e[20];let k;e[21]!==i?(k=n.jsx(Di,{children:n.jsx(re,{onClick:()=>i(!1),children:"Done"})}),e[21]=i,e[22]=k):k=e[22];let C;e[23]!==T||e[24]!==A||e[25]!==k?(C=n.jsxs(qt,{className:"max-w-lg",children:[T,A,k]}),e[23]=T,e[24]=A,e[25]=k,e[26]=C):C=e[26];let I;return e[27]!==i||e[28]!==s||e[29]!==C?(I=n.jsx(Gt,{open:s,onOpenChange:i,children:C}),e[27]=i,e[28]=s,e[29]=C,e[30]=I):I=e[30],I}function I7(t){const e=U.c(83),{trigger:s,automationId:i,connectionName:r}=t,{triggerAdd:o,triggerRemove:a,triggerRotateToken:l}=hr(),[c,d]=R.useState(!1),[h,u]=R.useState(!1),[f,m]=R.useState(null);let p;e[0]!==s.cron_expression?(p=s.cron_expression?A7(s.cron_expression):null,e[0]=s.cron_expression,e[1]=p):p=e[1];const g=p,[L,v]=R.useState(g?.count??1),[y,_]=R.useState(!1),[x,b]=R.useState(s.cron_expression??""),S=a.isPending||o.isPending||l.isPending,w=s.type==="cron",j=s.type==="webhook";let N;e[2]!==i||e[3]!==a||e[4]!==s.id?(N=async()=>{try{await a.mutateAsync({trigger_id:s.id,automation_id:i}),me.success("Starter removed")}catch{me.error("Failed to remove starter")}d(!1)},e[2]=i,e[3]=a,e[4]=s.id,e[5]=N):N=e[5];const T=N;let A;e[6]!==o||e[7]!==i||e[8]!==x||e[9]!==a||e[10]!==s.cron_expression||e[11]!==s.id?(A=async()=>{const te=x.trim();if(!te||!Gn(te)||te===s.cron_expression){_(!1),b(s.cron_expression??"");return}try{await o.mutateAsync({automation_id:i,type:"cron",cron_expression:te}),await a.mutateAsync({trigger_id:s.id,automation_id:i}),_(!1)}catch{me.error("Failed to update starter"),b(s.cron_expression??""),_(!1)}},e[6]=o,e[7]=i,e[8]=x,e[9]=a,e[10]=s.cron_expression,e[11]=s.id,e[12]=A):A=e[12];const k=A;let C;e[13]!==i||e[14]!==l||e[15]!==s.id?(C=async()=>{u(!1);try{const te=await l.mutateAsync({trigger_id:s.id,automation_id:i});m({url:te.url,token:te.token})}catch(te){const fe=te,he=fe instanceof Error?fe.message:"Failed to rotate token";me.error(he)}},e[13]=i,e[14]=l,e[15]=s.id,e[16]=C):C=e[16];const I=C;let E;e[17]!==o||e[18]!==i||e[19]!==g||e[20]!==a||e[21]!==s.cron_expression||e[22]!==s.id?(E=async te=>{if(!g)return;const fe=g.unit==="minutes"?5:1,he=Math.max(fe,te);he!==te&&v(he);const ye=E7(he,g.unit);if(ye!==s.cron_expression)try{await o.mutateAsync({automation_id:i,type:"cron",cron_expression:ye}),await a.mutateAsync({trigger_id:s.id,automation_id:i})}catch{me.error("Failed to update starter"),v(g.count)}},e[17]=o,e[18]=i,e[19]=g,e[20]=a,e[21]=s.cron_expression,e[22]=s.id,e[23]=E):E=e[23];const O=E;let P;e[24]!==w||e[25]!==j?(P=w?n.jsx(Fn,{size:14,className:"text-muted-foreground shrink-0"}):j?n.jsx(Pi,{size:14,className:"text-muted-foreground shrink-0"}):n.jsx(wi,{size:14,className:"text-muted-foreground shrink-0"}),e[24]=w,e[25]=j,e[26]=P):P=e[26];let D;e[27]!==r||e[28]!==L||e[29]!==x||e[30]!==O||e[31]!==k||e[32]!==g||e[33]!==w||e[34]!==y||e[35]!==S||e[36]!==j||e[37]!==s.cron_expression||e[38]!==s.event_type||e[39]!==s.params?(D=g&&w?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-sm text-muted-foreground",children:"Every"}),n.jsx("input",{type:"number",min:g.unit==="minutes"?5:1,value:L,onChange:te=>v(parseInt(te.target.value)||1),onBlur:()=>O(L),onKeyDown:te=>{te.key==="Enter"&&te.target.blur(),te.key==="Escape"&&v(g.count)},disabled:S,className:"w-12 text-center text-sm h-7 border border-border rounded-md bg-background px-1 focus:outline-none focus:ring-1 focus:ring-ring"}),n.jsx("span",{className:"text-sm",children:P7(g.unit,L)})]}):w&&y?n.jsxs(n.Fragment,{children:[n.jsx("input",{type:"text",value:x,onChange:te=>b(te.target.value),onBlur:k,onKeyDown:te=>{te.key==="Enter"&&te.target.blur(),te.key==="Escape"&&(_(!1),b(s.cron_expression??""))},className:"flex-1 text-sm font-mono bg-transparent outline-none",autoFocus:!0}),x&&!Gn(x)&&n.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"})]}):n.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[n.jsx("span",{className:"text-sm font-mono text-xs text-muted-foreground truncate",children:w?T7(s.cron_expression??""):j?"Webhook · POST to fire":`${s.event_type}${r?` · ${r}`:""}`}),!w&&!j&&s.params&&Object.keys(s.params).length>0&&n.jsx("span",{className:"text-xs text-muted-foreground/60 truncate",children:Object.entries(s.params).map(O7).join(", ")})]}),e[27]=r,e[28]=L,e[29]=x,e[30]=O,e[31]=k,e[32]=g,e[33]=w,e[34]=y,e[35]=S,e[36]=j,e[37]=s.cron_expression,e[38]=s.event_type,e[39]=s.params,e[40]=D):D=e[40];let M;e[41]!==S?(M=S&&n.jsx(Ue,{size:13,className:"animate-spin text-muted-foreground"}),e[41]=S,e[42]=M):M=e[42];let z;e[43]!==g||e[44]!==w||e[45]!==y||e[46]!==s.cron_expression?(z=w&&!g&&!y&&n.jsx(re,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{b(s.cron_expression??""),_(!0)},children:n.jsx(nc,{size:13,className:"text-muted-foreground"})}),e[43]=g,e[44]=w,e[45]=y,e[46]=s.cron_expression,e[47]=z):z=e[47];let F;e[48]!==j?(F=j&&n.jsx(re,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",title:"Rotate token",onClick:()=>u(!0),children:n.jsx(Xi,{size:13,className:"text-muted-foreground"})}),e[48]=j,e[49]=F):F=e[49];let $;e[50]===Symbol.for("react.memo_cache_sentinel")?($=n.jsx(re,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>d(!0),children:n.jsx(ti,{size:13,className:"text-muted-foreground"})}),e[50]=$):$=e[50];let V;e[51]!==F||e[52]!==M||e[53]!==z?(V=n.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[M,z,F,$]}),e[51]=F,e[52]=M,e[53]=z,e[54]=V):V=e[54];let J;e[55]!==V||e[56]!==P||e[57]!==D?(J=n.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[P,D,V]}),e[55]=V,e[56]=P,e[57]=D,e[58]=J):J=e[58];let Z;e[59]===Symbol.for("react.memo_cache_sentinel")?(Z=n.jsxs(so,{children:[n.jsx(io,{children:"Remove Starter"}),n.jsx(no,{children:"Are you sure you want to remove this starter?"})]}),e[59]=Z):Z=e[59];let G;e[60]===Symbol.for("react.memo_cache_sentinel")?(G=n.jsx(oo,{children:"Cancel"}),e[60]=G):G=e[60];let q;e[61]!==T?(q=n.jsxs(to,{children:[Z,n.jsxs(ro,{children:[G,n.jsx(ao,{onClick:T,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]}),e[61]=T,e[62]=q):q=e[62];let H;e[63]!==c||e[64]!==q?(H=n.jsx(eo,{open:c,onOpenChange:d,children:q}),e[63]=c,e[64]=q,e[65]=H):H=e[65];let K;e[66]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsxs(so,{children:[n.jsx(io,{children:"Rotate webhook token"}),n.jsx(no,{children:"A new token will be generated and the current token will stop working. Any senders using the old token must be updated."})]}),e[66]=K):K=e[66];let B;e[67]===Symbol.for("react.memo_cache_sentinel")?(B=n.jsx(oo,{children:"Cancel"}),e[67]=B):B=e[67];let X;e[68]!==I?(X=n.jsxs(to,{children:[K,n.jsxs(ro,{children:[B,n.jsx(ao,{onClick:I,children:"Rotate"})]})]}),e[68]=I,e[69]=X):X=e[69];let W;e[70]!==h||e[71]!==X?(W=n.jsx(eo,{open:h,onOpenChange:u,children:X}),e[70]=h,e[71]=X,e[72]=W):W=e[72];const Y=f!==null;let Q;e[73]===Symbol.for("react.memo_cache_sentinel")?(Q=te=>{te||m(null)},e[73]=Q):Q=e[73];const ie=f?.url??null,oe=f?.token??null;let ue;e[74]!==Y||e[75]!==ie||e[76]!==oe?(ue=n.jsx(P1,{open:Y,onOpenChange:Q,url:ie,token:oe,title:"New webhook token",description:"The previous token has been revoked. Copy the new token now — it will not be shown again."}),e[74]=Y,e[75]=ie,e[76]=oe,e[77]=ue):ue=e[77];let ee;return e[78]!==J||e[79]!==H||e[80]!==W||e[81]!==ue?(ee=n.jsxs(n.Fragment,{children:[J,H,W,ue]}),e[78]=J,e[79]=H,e[80]=W,e[81]=ue,e[82]=ee):ee=e[82],ee}function O7(t){const[e,s]=t;return`${e}: ${s}`}const M7=30;function B7(t,e){switch(e.type){case"accumulate":{const s=t??{start:e.now,fields:new Set,saveCount:0},i=new Set(s.fields);for(const r of e.fields)i.add(r);return{...s,fields:i,saveCount:s.saveCount+1}}case"reset":return null}}function $7(t){const e=U.c(55),{automationId:s,onDone:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={binding:"TRIGGER"},e[0]=r):r=e[0];const o=rr(r),[a,l]=R.useState(),[c,d]=R.useState();let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h={},e[1]=h):h=e[1];const[u,f]=R.useState(h),{triggerAdd:m}=hr(),{data:p,isLoading:g}=H3(a);let L,v,y,_,x,b;if(e[2]!==m||e[3]!==s||e[4]!==a||e[5]!==c||e[6]!==g||e[7]!==i||e[8]!==u||e[9]!==o||e[10]!==p){const j=p?.find(D=>D.type===c);let N;e[17]!==m||e[18]!==s||e[19]!==a||e[20]!==c||e[21]!==i||e[22]!==u?(N=async()=>{if(!(!a||!c))try{await m.mutateAsync({automation_id:s,type:"event",event_type:c,connection_id:a,params:u}),Ze("automation_trigger_added",{automation_id:s,trigger_type:"event",connection_id:a,event_type:c}),me.success("Event trigger added"),i()}catch{me.error("Failed to add event trigger")}},e[17]=m,e[18]=s,e[19]=a,e[20]=c,e[21]=i,e[22]=u,e[23]=N):N=e[23],L=N,v="flex flex-col gap-3 px-3 py-3 rounded-lg border border-border bg-background";let T,A;e[24]===Symbol.for("react.memo_cache_sentinel")?(A=n.jsx(wi,{size:14,className:"text-muted-foreground shrink-0"}),T=n.jsx("span",{className:"text-sm font-medium",children:"Event trigger"}),e[24]=T,e[25]=A):(T=e[24],A=e[25]);let k;e[26]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(ti,{size:13}),e[26]=k):k=e[26],e[27]!==i?(y=n.jsxs("div",{className:"flex items-center gap-2",children:[A,T,n.jsx("button",{type:"button",className:"ml-auto shrink-0 p-0.5 rounded text-muted-foreground hover:text-foreground",onClick:i,children:k})]}),e[27]=i,e[28]=y):y=e[28];const C=a??"";let I;e[29]===Symbol.for("react.memo_cache_sentinel")?(I=D=>{l(D),d(void 0),f({})},e[29]=I):I=e[29];let E;e[30]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx(kt,{className:"w-full",children:n.jsx(Rt,{placeholder:"Select connection..."})}),e[30]=E):E=e[30];let O;e[31]!==o?(O=o.length===0?n.jsx("div",{className:"px-2 py-3 text-center text-xs text-muted-foreground",children:"No connections with trigger support"}):o.map(H7),e[31]=o,e[32]=O):O=e[32];let P;e[33]!==O?(P=n.jsx(Nt,{children:O}),e[33]=O,e[34]=P):P=e[34],e[35]!==C||e[36]!==P?(_=n.jsxs(Tt,{value:C,onValueChange:I,children:[E,P]}),e[35]=C,e[36]=P,e[37]=_):_=e[37],e[38]!==a||e[39]!==c||e[40]!==g||e[41]!==p?(x=a&&n.jsxs(Tt,{value:c??"",onValueChange:D=>{d(D),f({})},children:[n.jsx(kt,{className:"w-full",children:g?n.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[n.jsx(Ue,{size:13,className:"animate-spin"}),"Loading events..."]}):n.jsx(Rt,{placeholder:"Select event type...",children:c??"Select event type..."})}),n.jsx(Nt,{children:p?.map(F7)})]}),e[38]=a,e[39]=c,e[40]=g,e[41]=p,e[42]=x):x=e[42],b=j?.paramsSchema&&Object.keys(j.paramsSchema).length>0&&n.jsx("div",{className:"flex flex-col gap-2",children:Object.entries(j.paramsSchema).map(D=>{const[M,z]=D;return n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsxs("label",{className:"text-xs text-muted-foreground",children:[M,z.description&&n.jsxs("span",{className:"text-muted-foreground/60",children:[" ","— ",z.description]})]}),z.enum?n.jsxs(Tt,{value:u[M]??"",onValueChange:F=>f($=>({...$,[M]:F})),children:[n.jsx(kt,{className:"w-full",children:n.jsx(Rt,{placeholder:`Select ${M}...`})}),n.jsx(Nt,{children:z.enum.map(z7)})]}):n.jsx("input",{type:"text",value:u[M]??"",onChange:F=>f($=>({...$,[M]:F.target.value})),placeholder:z.description??M,className:"text-sm border border-border rounded-md bg-background px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-ring"})]},M)})}),e[2]=m,e[3]=s,e[4]=a,e[5]=c,e[6]=g,e[7]=i,e[8]=u,e[9]=o,e[10]=p,e[11]=L,e[12]=v,e[13]=y,e[14]=_,e[15]=x,e[16]=b}else L=e[11],v=e[12],y=e[13],_=e[14],x=e[15],b=e[16];let S;e[43]!==m||e[44]!==a||e[45]!==c||e[46]!==L?(S=a&&c&&n.jsx(re,{size:"sm",onClick:L,disabled:m.isPending,children:m.isPending?n.jsx(Ue,{size:13,className:"animate-spin"}):"Add trigger"}),e[43]=m,e[44]=a,e[45]=c,e[46]=L,e[47]=S):S=e[47];let w;return e[48]!==v||e[49]!==y||e[50]!==_||e[51]!==x||e[52]!==b||e[53]!==S?(w=n.jsxs("div",{className:v,children:[y,_,x,b,S]}),e[48]=v,e[49]=y,e[50]=_,e[51]=x,e[52]=b,e[53]=S,e[54]=w):w=e[54],w}function z7(t){return n.jsx(ot,{value:t,children:t},t)}function F7(t){return n.jsx(ot,{value:t.type,children:n.jsxs("div",{className:"flex flex-col",children:[n.jsx("span",{children:t.type}),n.jsx("span",{className:"text-xs text-muted-foreground",children:t.description})]})},t.type)}function H7(t){return n.jsx(ot,{value:t.id,children:t.title},t.id)}function U7({automationId:t,automation:e,onBack:s,onDelete:i}){const r=e.virtual_mcp_id,{org:o}=Ge(),{update:a,triggerAdd:l,run:c}=hr(),d=rr(),h=new Map(d.map(Q=>[Q.id,Q.title])),{openTask:u}=$s(),{setChatOpen:f}=Eo(),{sendMessage:m}=Ti(),p=e.messages?.[0]?.metadata?.tiptapDoc??void 0,[g,L]=R.useState(p),[v,y]=R.useState(!1),[_,x]=R.useState(!1),[b,S]=R.useState(!1),[w,j]=R.useState(""),[N,T]=R.useState(!1),[A,k]=R.useState(null),[C,I]=R.useState(!1),[E,O]=R.useState(!1),[P,D]=R.useState(!1),M=async()=>{if(C)return;const ie=m2(g).filter(oe=>oe.type==="text").map(oe=>oe.text).join(`
|
|
496
|
-
`);if(ie.trim()){I(!0);try{X(),Ze("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:ie.length}),f(!0),await m({tiptapDoc:iu({managerAgentId:Kd.AUTOMATION_MANAGER(o.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:ie})})}finally{I(!1)}}},z=e.models?.tier??"smart",F=e.models?.modelId&&e.models?.credentialId?{modelId:e.models.modelId,credentialId:e.models.credentialId,title:e.models.modelTitle??e.models.modelId}:null,$=Cd({defaultValues:{name:e.name,active:e.active,tier:z,modelOverride:F,tools:e.tools??null,maxAgentSteps:e.maxAgentSteps??null}}),V=$.watch("active"),[J,Z]=R.useReducer(B7,null),G=()=>{J!==null&&(Ze("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(J.fields),save_count:J.saveCount,edit_duration_ms:Date.now()-J.start}),Z({type:"reset"}))},q=async()=>{const Q=$.control._formState.dirtyFields,ie=Object.keys(Q);if(ie.length===0&&!P)return!0;const oe=$.getValues(),ue=$.control._defaultValues;$.reset(oe,{keepValues:!0});const ee=P;D(!1);const te={tier:oe.tier,...oe.modelOverride?{modelId:oe.modelOverride.modelId,credentialId:oe.modelOverride.credentialId,modelTitle:oe.modelOverride.title}:{}},fe={id:t,name:oe.name,active:oe.active,models:te,tools:oe.tools,maxAgentSteps:oe.maxAgentSteps,messages:f2(g),temperature:0};try{await a.mutateAsync(fe)}catch{return $.reset(ue,{keepValues:!0}),ee&&D(!0),!1}const he=[...ie];return ee&&he.push("messages"),Z({type:"accumulate",now:Date.now(),fields:he}),B(),!0},{schedule:H,flush:K}=co({save:q}),{schedule:B,flush:X}=co({delayMs:3e4,save:async()=>G()});R.useEffect(()=>{const Q=$.watch(()=>H());return()=>Q.unsubscribe()},[]);const W=Q=>{if(L(Q),!E){O(!0);return}D(!0),H()},Y=async()=>{Ze("automation_test_clicked",{automation_id:t,agent_id:r});const Q=await K();if(X(),!!Q){if(!g){me.error("No instructions configured for this automation");return}try{const ie=await c.mutateAsync(t);ie.threadId&&(f(!0),u(ie.threadId))}catch{}}};return n.jsxs(n.Fragment,{children:[s&&n.jsx("div",{className:"flex items-center pb-4 shrink-0",children:n.jsxs(re,{variant:"ghost",size:"sm",onClick:s,children:[n.jsx(Xl,{size:14}),"Back to list"]})}),n.jsxs("div",{className:"flex flex-col gap-8",children:[n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs("div",{className:"flex items-center justify-between gap-4",children:[n.jsx(Ut,{control:$.control,name:"name",render:({field:Q})=>n.jsx(Ke,{...Q,placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}})}),i&&n.jsx(re,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:i,children:n.jsx(os,{size:14})})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Ut,{control:$.control,name:"active",render:({field:Q})=>n.jsx(Jn,{checked:Q.value,onCheckedChange:ie=>{Q.onChange(ie),K()},className:"cursor-pointer"})}),n.jsx("span",{className:"text-sm text-muted-foreground",children:V?"Active":"Inactive"}),n.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),n.jsx(nu,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),n.jsxs("div",{className:"flex flex-col gap-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),n.jsx(D7,{automationId:t,open:v,onOpenChange:y,onCustomSelect:()=>{S(!0),T(!1),j("")},onEventSelect:()=>{T(!0),S(!1)},onWebhookCreated:Q=>{Ze("automation_trigger_added",{automation_id:t,trigger_type:"webhook"}),k(Q)}})]}),e.triggers.length===0&&!b?n.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:n.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",n.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>y(!0),children:"Add a starter"})," ","to get going."]})}):n.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(Q=>n.jsx(I7,{trigger:Q,automationId:t,connectionName:Q.connection_id?h.get(Q.connection_id):void 0},Q.id))}),b&&n.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[n.jsx(Fn,{size:14,className:"text-muted-foreground shrink-0"}),n.jsx("input",{type:"text",value:w,onChange:Q=>j(Q.target.value),onBlur:async()=>{const Q=w.trim();if(!(!Q||!Gn(Q)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:Q}),Ze("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),me.success("Starter added"),S(!1),j("")}catch{me.error("Failed to add starter")}},onKeyDown:async Q=>{const ie=w.trim();Q.key==="Enter"&&ie&&Gn(ie)&&Q.target.blur(),Q.key==="Escape"&&(S(!1),j(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),w&&!Gn(w)&&n.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&n.jsx(Ue,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),n.jsx("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity",onClick:()=>{S(!1),j("")},children:n.jsx(ti,{size:13})})]}),N&&n.jsx(R.Suspense,{fallback:n.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[n.jsx(Ue,{size:13,className:"animate-spin text-muted-foreground"}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:n.jsx($7,{automationId:t,onDone:()=>T(!1)})}),n.jsx(P1,{open:A!==null,onOpenChange:Q=>{Q||k(null)},url:A?.url??null,token:A?.token??null})]}),n.jsxs("div",{className:"flex flex-col gap-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),n.jsxs(re,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:C||!g,onClick:M,children:[n.jsx(gi,{size:13}),"Improve"]})]}),n.jsx(l2,{tiptapDoc:g,setTiptapDoc:W,placeholder:"What should this automation do?",children:n.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[n.jsx(c2,{virtualMcpId:r||null,className:"max-h-[45vh]"}),n.jsx("div",{className:"@container/chat-bottom flex items-center justify-end gap-1.5 p-2.5",children:n.jsxs(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsxs(re,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:Y,disabled:!r,children:[n.jsx(P3,{size:16}),"Test"]})}),n.jsx(Ae,{children:"Test Automation"})]})})]})})]}),n.jsxs(fm,{open:_,onOpenChange:x,className:"flex flex-col gap-2.5",children:[n.jsxs(mm,{className:"group flex w-fit cursor-pointer items-center gap-1.5",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Advanced"}),n.jsx(ls,{size:14,className:"text-muted-foreground/60 transition-transform group-data-[state=open]:rotate-180"})]}),n.jsxs(pm,{className:"flex flex-col gap-5 pt-0.5",children:[n.jsx(L7,{tier:$.watch("tier"),onTierChange:Q=>$.setValue("tier",Q,{shouldDirty:!0}),override:$.watch("modelOverride"),onOverrideChange:Q=>$.setValue("modelOverride",Q,{shouldDirty:!0})}),n.jsx(b7,{agentId:r||null,value:$.watch("tools"),onChange:Q=>$.setValue("tools",Q,{shouldDirty:!0})}),n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Max steps"}),n.jsx(Ke,{type:"number",min:1,max:100,className:"w-40",placeholder:`${M7} (default)`,value:$.watch("maxAgentSteps")??"",onChange:Q=>{const ie=Q.target.value.trim(),oe=ie===""?null:Number(ie);$.setValue("maxAgentSteps",oe===null||Number.isNaN(oe)?null:oe,{shouldDirty:!0})}})]})]})]})]})]})}function rn(){const t=U.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{"data-testid":"main-panel-loading",className:"flex h-full w-full items-center justify-center",children:n.jsx(Ue,{size:20,className:"animate-spin text-muted-foreground"})}),t[0]=e):e=t[0],e}const R1=[{key:"24h",label:"Last 24 hours",ms:1440*60*1e3},{key:"7d",label:"Last 7 days",ms:10080*60*1e3},{key:"30d",label:"Last 30 days",ms:720*60*60*1e3}];function D1(t){const e=R1.find(i=>i.key===t).ms,s=Date.now();return{startDate:new Date(s-e).toISOString(),endDate:new Date(s).toISOString()}}function K7(t){const e=U.c(12),{automationId:s,triggerIds:i}=t,[r,o]=R.useState("30d"),[a,l]=R.useState(V7);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=p=>{const g=p;o(g),l(D1(g))},e[0]=c):c=e[0];let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(kt,{className:"w-44",children:n.jsx(Rt,{})}),e[1]=d):d=e[1];let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Nt,{children:R1.map(W7)}),e[2]=h):h=e[2];let u;e[3]!==r?(u=n.jsx("div",{className:"flex items-center justify-end",children:n.jsxs(Tt,{value:r,onValueChange:c,children:[d,h]})}),e[3]=r,e[4]=u):u=e[4];let f;e[5]!==s||e[6]!==a||e[7]!==i?(f=n.jsx(D3,{automationId:s,triggerIds:i,range:a}),e[5]=s,e[6]=a,e[7]=i,e[8]=f):f=e[8];let m;return e[9]!==u||e[10]!==f?(m=n.jsxs("div",{className:"flex flex-col gap-5",children:[u,f]}),e[9]=u,e[10]=f,e[11]=m):m=e[11],m}function W7(t){return n.jsx(ot,{value:t.key,children:t.label},t.key)}function V7(){return D1("30d")}function G7(t){const e=U.c(5),{tabId:s}=t;let i;e[0]!==s?(i=nh(s),e[0]=s,e[1]=i):i=e[1];const r=i;if(!r)return null;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(rn,{}),e[2]=o):o=e[2];let a;return e[3]!==r.id?(a=n.jsx(R.Suspense,{fallback:o,children:n.jsx(q7,{id:r.id})}),e[3]=r.id,e[4]=a):a=e[4],a}function q7(t){const e=U.c(24),{id:s}=t,i=Vt(),{data:r,isLoading:o}=U3(s),[a,l]=R.useState("settings");let c;e[0]!==i?(c=()=>{i({to:".",search:J7,replace:!0})},e[0]=i,e[1]=c):c=e[1];const d=c;if(o){let x;return e[2]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(rn,{}),e[2]=x):x=e[2],x}if(!r){let x;return e[3]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=x):x=e[3],x}let h;e[4]!==r.triggers?(h=r.triggers.map(Y7),e[4]=r.triggers,e[5]=h):h=e[5];const u=h;let f;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(Xl,{size:14}),e[6]=f):f=e[6];let m;e[7]!==d?(m=n.jsxs(re,{variant:"ghost",size:"sm",onClick:d,children:[f,"Back to list"]}),e[7]=d,e[8]=m):m=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=[{id:"settings",label:"Settings"},{id:"runs",label:"Runs"}],e[9]=p):p=e[9];let g;e[10]===Symbol.for("react.memo_cache_sentinel")?(g=x=>l(x),e[10]=g):g=e[10];let L;e[11]!==a?(L=n.jsx(wh,{tabs:p,activeTab:a,onTabChange:g}),e[11]=a,e[12]=L):L=e[12];let v;e[13]!==m||e[14]!==L?(v=n.jsxs("div",{className:"flex items-center justify-between pb-4 shrink-0",children:[m,L]}),e[13]=m,e[14]=L,e[15]=v):v=e[15];let y;e[16]!==r||e[17]!==s||e[18]!==a||e[19]!==u?(y=a==="settings"?n.jsx(U7,{automationId:s,automation:r}):n.jsx(K7,{automationId:s,triggerIds:u}),e[16]=r,e[17]=s,e[18]=a,e[19]=u,e[20]=y):y=e[20];let _;return e[21]!==v||e[22]!==y?(_=n.jsx(fs,{children:n.jsx(fs.Content,{children:n.jsxs(fs.Body,{children:[v,y]})})}),e[21]=v,e[22]=y,e[23]=_):_=e[23],_}function Y7(t){return t.id}function J7(t){return{...t,main:"automations"}}function X7(t){const e=U.c(20),{virtualMcpId:s}=t,i=Vt(),{data:r}=K3(s),o=r===void 0?[]:r,{create:a}=hr(),[l,c]=R.useState(""),d=l.toLowerCase(),h=o.filter(A=>A.name.toLowerCase().includes(d));let u;e[0]!==i?(u=A=>i({to:".",search:k=>({...k,main:"automation:"+A}),replace:!0}),e[0]=i,e[1]=u):u=e[1];const f=u,m=async()=>{if(a.isPending)return;Ze("automation_new_clicked",{virtual_mcp_id:s,existing_count:o.length});const A=await a.mutateAsync(W3(s));f(A.id)};let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(It,{size:14}),e[2]=p):p=e[2];let g;e[3]!==a.isPending||e[4]!==m?(g=n.jsxs(re,{size:"sm",onClick:m,disabled:a.isPending,children:[p,"New automation"]}),e[3]=a.isPending,e[4]=m,e[5]=g):g=e[5];const L=g,v=fs,y=fs,_=fs;let x;e[6]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(fs.Title,{children:"Automations"}),e[6]=x):x=e[6];const b=o.length>0&&n.jsx(Zl,{value:l,onChange:c,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let S;e[7]!==L||e[8]!==b?(S=n.jsxs("div",{className:"flex flex-col gap-6",children:[x,n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[b,L]})]}),e[7]=L,e[8]=b,e[9]=S):S=e[9];const w=o.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(Qr,{image:n.jsx(wi,{size:48,className:"text-muted-foreground"}),title:"No automations yet",description:"Create your first automation to run this agent on a schedule or in response to events.",actions:L})}):h.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(Qr,{image:n.jsx(wi,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):n.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:h.map(A=>n.jsx(V3,{automation:A,onClick:()=>f(A.id)},A.id))});let j;e[10]!==w||e[11]!==_.Body||e[12]!==S?(j=n.jsxs(_.Body,{children:[S,w]}),e[10]=w,e[11]=_.Body,e[12]=S,e[13]=j):j=e[13];let N;e[14]!==j||e[15]!==y.Content?(N=n.jsx(y.Content,{children:j}),e[14]=j,e[15]=y.Content,e[16]=N):N=e[16];let T;return e[17]!==v||e[18]!==N?(T=n.jsx(v,{children:N}),e[17]=v,e[18]=N,e[19]=T):T=e[19],T}function Z7(t){const e=U.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(rn,{}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx(R.Suspense,{fallback:i,children:n.jsx(X7,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}function Q7(t){const e=U.c(37),{file:s,onClose:i}=t;let r,o;e[0]!==s.filename?(r=n.jsx(Qi,{filename:s.filename,className:"h-4.5 w-3.5 shrink-0"}),o=n.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:s.filename}),e[0]=s.filename,e[1]=r,e[2]=o):(r=e[1],o=e[2]);let a;e[3]!==s.size?(a=Km(s.size),e[3]=s.size,e[4]=a):a=e[4];let l;e[5]!==a?(l=n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:a}),e[5]=a,e[6]=l):l=e[6];let c;e[7]!==r||e[8]!==o||e[9]!==l?(c=n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-2",children:[r,o,l]}),e[7]=r,e[8]=o,e[9]=l,e[10]=c):c=e[10];let d;e[11]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(t3,{size:14}),e[11]=d):d=e[11];let h;e[12]!==s.downloadUrl||e[13]!==s.filename?(h=n.jsx(Ee,{asChild:!0,children:n.jsx(re,{variant:"ghost",size:"icon",asChild:!0,children:n.jsx("a",{href:s.downloadUrl,download:s.filename,children:d})})}),e[12]=s.downloadUrl,e[13]=s.filename,e[14]=h):h=e[14];let u;e[15]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(Ae,{side:"bottom",children:"Download"}),e[15]=u):u=e[15];let f;e[16]!==h?(f=n.jsxs(Pe,{children:[h,u]}),e[16]=h,e[17]=f):f=e[17];let m;e[18]!==s.downloadUrl?(m=()=>window.open(s.downloadUrl,"_blank","noopener"),e[18]=s.downloadUrl,e[19]=m):m=e[19];let p;e[20]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(ri,{size:14}),e[20]=p):p=e[20];let g;e[21]!==m?(g=n.jsx(Ee,{asChild:!0,children:n.jsx(re,{variant:"ghost",size:"icon",onClick:m,children:p})}),e[21]=m,e[22]=g):g=e[22];let L;e[23]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx(Ae,{side:"bottom",children:"Open in new tab"}),e[23]=L):L=e[23];let v;e[24]!==g?(v=n.jsxs(Pe,{children:[g,L]}),e[24]=g,e[25]=v):v=e[25];let y;e[26]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(ti,{size:14}),e[26]=y):y=e[26];let _;e[27]!==i?(_=n.jsx(Ee,{asChild:!0,children:n.jsx(re,{variant:"ghost",size:"icon",onClick:i,children:y})}),e[27]=i,e[28]=_):_=e[28];let x;e[29]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(Ae,{side:"bottom",children:"Close"}),e[29]=x):x=e[29];let b;e[30]!==_?(b=n.jsxs(Pe,{children:[_,x]}),e[30]=_,e[31]=b):b=e[31];let S;return e[32]!==v||e[33]!==b||e[34]!==c||e[35]!==f?(S=n.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-b border-border/60 px-2",children:[c,f,v,b]}),e[32]=v,e[33]=b,e[34]=c,e[35]=f,e[36]=S):S=e[36],S}function ey(t){const e=U.c(24),{fileKey:s,taskId:i}=t,r=Vt(),{data:o,isPending:a}=$d(i);let l;e[0]!==s||e[1]!==o?(l=o?.find(p=>p.key===s)??null,e[0]=s,e[1]=o,e[2]=l):l=e[2];const c=l;let d;e[3]!==r?(d=()=>r({to:".",search:ty,replace:!0}),e[3]=r,e[4]=d):d=e[4];const h=d;if(!c){if(a){let _;return e[5]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx("div",{className:"h-full w-full bg-background",children:n.jsx(Hm,{})}),e[5]=_):_=e[5],_}let p;e[6]!==s?(p=s.split("/").pop()??s,e[6]=s,e[7]=p):p=e[7];let g;e[8]!==p?(g=n.jsx(Qi,{filename:p,className:"h-7.5 w-6"}),e[8]=p,e[9]=g):g=e[9];let L;e[10]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx("span",{className:"text-sm text-muted-foreground",children:"This file is no longer available."}),e[10]=L):L=e[10];let v;e[11]!==h?(v=n.jsx(re,{variant:"ghost",size:"sm",onClick:h,children:"Close"}),e[11]=h,e[12]=v):v=e[12];let y;return e[13]!==g||e[14]!==v?(y=n.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 bg-background",children:[g,L,v]}),e[13]=g,e[14]=v,e[15]=y):y=e[15],y}let u;e[16]!==c||e[17]!==h?(u=n.jsx(Q7,{file:c,onClose:h}),e[16]=c,e[17]=h,e[18]=u):u=e[18];let f;e[19]!==c?(f=n.jsx("div",{className:"relative min-h-0 flex-1",children:n.jsx(Um,{file:c})}),e[19]=c,e[20]=f):f=e[20];let m;return e[21]!==u||e[22]!==f?(m=n.jsxs("div",{className:"flex h-full w-full flex-col bg-background",children:[u,f]}),e[21]=u,e[22]=f,e[23]=m):m=e[23],m}function ty(t){return{...t,main:"0"}}const ba="home";function sy(t){const e=U.c(5),{label:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(ec,{className:"aspect-video w-2/3 max-w-xl"}),e[0]=i):i=e[0];let r;e[1]!==s?(r=s&&n.jsx("p",{className:"text-xs text-muted-foreground",children:s}),e[1]=s,e[2]=r):r=e[2];let o;return e[3]!==r?(o=n.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 bg-background",children:[i,r]}),e[3]=r,e[4]=o):o=e[4],o}function iy(t){const e=U.c(15),{path:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={refetchIntervalWhenAbsent:2e3},e[0]=i):i=e[0];const r=L3(ba,s,i),o=v3(ba)(s);if(r.isPending||!r.data){const f=!r.isPending&&!r.data?"Waiting for the deck to sync…":void 0;let m;return e[1]!==f?(m=n.jsx(sy,{label:f}),e[1]=f,e[2]=m):m=e[2],m}let a;e[3]!==r.data?(a=x3(r.data),e[3]=r.data,e[4]=a):a=e[4];const l=r.data.shareMode??"private",c=r.data.effectivePublic??!1,d=window.location.origin+o;let h;e[5]!==s||e[6]!==l||e[7]!==c||e[8]!==d?(h=n.jsx(Wm,{volume:ba,path:s,shareMode:l,effectivePublic:c,url:d}),e[5]=s,e[6]=l,e[7]=c,e[8]=d,e[9]=h):h=e[9];let u;return e[10]!==s||e[11]!==o||e[12]!==a||e[13]!==h?(u=n.jsx(Vm,{readUrl:o,marker:a,title:s,savePath:s,trailing:h}),e[10]=s,e[11]=o,e[12]=a,e[13]=h,e[14]=u):u=e[14],u}function ny(t){const e=U.c(5),{path:s}=t,i=Vt();let r;e[0]!==i?(r=()=>i({to:".",search:ry,replace:!0}),e[0]=i,e[1]=r):r=e[1];const o=r;let a;return e[2]!==o||e[3]!==s?(a=n.jsx(Gm,{previewPath:s,onClose:o,showSeeInLibrary:!0}),e[2]=o,e[3]=s,e[4]=a):a=e[4],a}function ry(t){return{...t,main:"0"}}function oy(){const t=U.c(12),e=Vt(),[s,i]=R.useState(null),[r,o]=R.useState(null);let a;t[0]!==e?(a=f=>e({to:".",search:m=>({...m,main:f}),replace:!0}),t[0]=e,t[1]=a):a=t[1];const l=a;let c;t[2]!==l?(c=n.jsx(qm,{onOpenFile:f=>l(Mm(f)),onOpenSkill:i,onOpenBrand:o}),t[2]=l,t[3]=c):c=t[3];let d;t[4]!==s?(d=s&&n.jsx(Ym,{skillPath:s,onClose:()=>i(null)},s),t[4]=s,t[5]=d):d=t[5];let h;t[6]!==r?(h=r&&n.jsx(Jm,{brandPath:r,onClose:()=>o(null)},r),t[6]=r,t[7]=h):h=t[7];let u;return t[8]!==c||t[9]!==d||t[10]!==h?(u=n.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[c,d,h]}),t[8]=c,t[9]=d,t[10]=h,t[11]=u):u=t[11],u}const w0=R.lazy(()=>as(()=>import("./project-app-view-CF9uQXSH.js"),__vite__mapDeps([160,1,2,44,4,5,6,7,8,9,10,11,12,13,14,3,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,126,103,94,91,104,105,83,84,85,86,87,88,89,90,92,93,95,96,97,98,99,106,107,108,109,110,111,112,113,114,115,82,116,117,118,119,120,121,122,123,124,125,127,128,101,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145])).then(t=>({default:t.AppViewContent})));function ay(t){const e=U.c(54),{activeTab:s,virtualMcpId:i,taskId:r,layoutTabs:o,expandedTools:a,automationTabParsed:l}=t;if(Bm(s)){let _;return e[0]!==i?(_=n.jsx(R9,{virtualMcpId:i}),e[0]=i,e[1]=_):_=e[1],_}if(s==="git"){let _;return e[2]!==i?(_=n.jsx(f_,{virtualMcpId:i}),e[2]=i,e[3]=_):_=e[3],_}if(s==="automations"){let _;return e[4]!==i?(_=n.jsx(Z7,{virtualMcpId:i}),e[4]=i,e[5]=_):_=e[5],_}if(s==="preview"){let _;return e[6]!==i?(_=n.jsx(k6,{virtualMcpId:i}),e[6]=i,e[7]=_):_=e[7],_}if(s==="content"){let _;return e[8]!==i?(_=n.jsx(p7,{virtualMcpId:i}),e[8]=i,e[9]=_):_=e[9],_}if(s==="files"){let _;return e[10]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(oy,{}),e[10]=_):_=e[10],_}if(l){let _;return e[11]!==s?(_=n.jsx(G7,{tabId:s}),e[11]=s,e[12]=_):_=e[12],_}let c;e[13]!==s?(c=oh(s),e[13]=s,e[14]=c):c=e[14];const d=c;if(d){let _;return e[15]!==d.path?(_=n.jsx(iy,{path:d.path},d.path),e[15]=d.path,e[16]=_):_=e[16],_}let h;e[17]!==s?(h=rh(s),e[17]=s,e[18]=h):h=e[18];const u=h;if(u){let _;return e[19]!==u.key||e[20]!==r?(_=n.jsx(ey,{fileKey:u.key,taskId:r}),e[19]=u.key,e[20]=r,e[21]=_):_=e[21],_}let f;e[22]!==s?(f=ah(s),e[22]=s,e[23]=f):f=e[23];const m=f;if(m){let _;return e[24]!==m.path?(_=n.jsx(ny,{path:m.path},m.path),e[24]=m.path,e[25]=_):_=e[25],_}let p;e[26]!==s?(p=$m(s),e[26]=s,e[27]=p):p=e[27];const g=p;if(g){let _;if(e[28]!==a||e[29]!==g.connectionId||e[30]!==g.toolName){let j;e[32]!==g.connectionId||e[33]!==g.toolName?(j=N=>N.appId===g.connectionId&&N.toolName===g.toolName,e[32]=g.connectionId,e[33]=g.toolName,e[34]=j):j=e[34],_=a.find(j),e[28]=a,e[29]=g.connectionId,e[30]=g.toolName,e[31]=_}else _=e[31];const x=_;let b;e[35]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(rn,{}),e[35]=b):b=e[35];const S=x?.args;let w;return e[36]!==s||e[37]!==g.connectionId||e[38]!==g.toolName||e[39]!==S?(w=n.jsx(R.Suspense,{fallback:b,children:n.jsx(w0,{connectionId:g.connectionId,toolName:g.toolName,args:S},s)}),e[36]=s,e[37]=g.connectionId,e[38]=g.toolName,e[39]=S,e[40]=w):w=e[40],w}let L;if(e[41]!==s||e[42]!==o){let _;e[44]!==s?(_=x=>x.id===s,e[44]=s,e[45]=_):_=e[45],L=o.find(_),e[41]=s,e[42]=o,e[43]=L}else L=e[43];const v=L;if(v){let _;e[46]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(rn,{}),e[46]=_):_=e[46];let x;return e[47]!==s||e[48]!==v.id||e[49]!==v.view.appId||e[50]!==v.view.args?(x=n.jsx(R.Suspense,{fallback:_,children:n.jsx(w0,{connectionId:v.view.appId,toolName:v.id,args:v.view.args},s)}),e[47]=s,e[48]=v.id,e[49]=v.view.appId,e[50]=v.view.args,e[51]=x):x=e[51],x}let y;return e[52]!==i?(y=n.jsx(R9,{virtualMcpId:i}),e[52]=i,e[53]=y):y=e[53],y}function ly(t){const e=U.c(14),{taskId:s,virtualMcpId:i}=t;let r;e[0]!==s||e[1]!==i?(r={virtualMcpId:i,taskId:s},e[0]=s,e[1]=i,e[2]=r):r=e[2];const{activeTab:o,layoutTabs:a,expandedTools:l,automationTabParsed:c}=Cc(r);let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(rn,{}),e[3]=d):d=e[3];let h;e[4]!==o||e[5]!==c||e[6]!==l||e[7]!==a||e[8]!==s||e[9]!==i?(h=n.jsx(R.Suspense,{fallback:d,children:n.jsx(ay,{activeTab:o,virtualMcpId:i,taskId:s,layoutTabs:a,expandedTools:l,automationTabParsed:c})}),e[4]=o,e[5]=c,e[6]=l,e[7]=a,e[8]=s,e[9]=i,e[10]=h):h=e[10];let u;return e[11]!==o||e[12]!==h?(u=n.jsx(es,{children:h},o),e[11]=o,e[12]=h,e[13]=u):u=e[13],u}const _i="setup";function cy(t){const e=U.c(35);let s;if(e[0]!==t.scriptTabs||e[1]!==t.scripts){let m;e[3]!==t.scriptTabs?(m=p=>!t.scriptTabs.includes(p),e[3]=t.scriptTabs,e[4]=m):m=e[4],s=t.scripts.filter(m),e[0]=t.scriptTabs,e[1]=t.scripts,e[2]=s}else s=e[2];const i=s;let r;e[5]!==t?(r=()=>{t.active===_i?t.onToggle():t.onSelectTab(_i)},e[5]=t,e[6]=r):r=e[6];const o=r,a=t.active===_i;let l;e[7]!==o||e[8]!==t.open||e[9]!==a?(l=n.jsx(dy,{active:a,open:t.open,onClick:o}),e[7]=o,e[8]=t.open,e[9]=a,e[10]=l):l=e[10];let c;e[11]!==t?(c=t.scriptTabs.map(m=>n.jsx(uy,{active:t.active===m,onClick:()=>{t.active===m?t.onToggle():t.onSelectTab(m)},onClose:()=>t.onCloseScript(m),children:m},m)),e[11]=t,e[12]=c):c=e[12];let d;e[13]!==i||e[14]!==t.onAddScript?(d=n.jsx(fy,{scripts:i,onRun:t.onAddScript}),e[13]=i,e[14]=t.onAddScript,e[15]=d):d=e[15];let h;e[16]!==l||e[17]!==c||e[18]!==d?(h=n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:[l,c,d]}),e[16]=l,e[17]=c,e[18]=d,e[19]=h):h=e[19];let u;e[20]!==t.onRestart||e[21]!==t.onResume||e[22]!==t.onRetry||e[23]!==t.onRunActiveScript||e[24]!==t.onStart||e[25]!==t.onStop||e[26]!==t.onStopActiveScript||e[27]!==t.scriptIsKilling||e[28]!==t.scriptIsRunning||e[29]!==t.showScriptControls||e[30]!==t.status?(u=t.showScriptControls?n.jsx(my,{isRunning:t.scriptIsRunning,isKilling:t.scriptIsKilling,onRun:t.onRunActiveScript,onStop:t.onStopActiveScript}):n.jsx(hy,{status:t.status,onStart:t.onStart,onStop:t.onStop,onRestart:t.onRestart,onResume:t.onResume,onRetry:t.onRetry}),e[20]=t.onRestart,e[21]=t.onResume,e[22]=t.onRetry,e[23]=t.onRunActiveScript,e[24]=t.onStart,e[25]=t.onStop,e[26]=t.onStopActiveScript,e[27]=t.scriptIsKilling,e[28]=t.scriptIsRunning,e[29]=t.showScriptControls,e[30]=t.status,e[31]=u):u=e[31];let f;return e[32]!==h||e[33]!==u?(f=n.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-t border-b border-border bg-muted/60 px-3",children:[h,u]}),e[32]=h,e[33]=u,e[34]=f):f=e[34],f}function dy(t){const e=U.c(8),{active:s,open:i,onClick:r}=t,o=s&&i,a=s&&i,l=s?"border-border bg-background font-medium text-foreground shadow-sm":"border-transparent text-muted-foreground hover:bg-background/50 hover:text-foreground";let c;e[0]!==l?(c=ce("flex h-7 items-center gap-1.5 rounded-md border px-2.5 text-xs",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Y2,{className:"size-3.5"}),e[2]=d):d=e[2];let h;return e[3]!==r||e[4]!==o||e[5]!==a||e[6]!==c?(h=n.jsxs("button",{type:"button","aria-pressed":o,"aria-expanded":a,onClick:r,className:c,children:[d,"sandbox"]}),e[3]=r,e[4]=o,e[5]=a,e[6]=c,e[7]=h):h=e[7],h}function hy(t){const e=U.c(24),{status:s,onStart:i,onStop:r,onRestart:o,onResume:a,onRetry:l}=t;if(s==="idle"&&i){let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(xi,{className:"size-3.5"}),e[0]=c):c=e[0];let d;return e[1]!==i?(d=n.jsxs(re,{variant:"outline",size:"sm",onClick:i,children:[c," Start"]}),e[1]=i,e[2]=d):d=e[2],d}if(s==="suspended"&&a){let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(xi,{className:"size-3.5"}),e[3]=c):c=e[3];let d;return e[4]!==a?(d=n.jsxs(re,{variant:"outline",size:"sm",onClick:a,children:[c," Resume"]}),e[4]=a,e[5]=d):d=e[5],d}if(s==="errored"&&l){let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Xi,{className:"size-3.5"}),e[6]=c):c=e[6];let d;return e[7]!==l?(d=n.jsxs(re,{variant:"outline",size:"sm",onClick:l,children:[c," Retry"]}),e[7]=l,e[8]=d):d=e[8],d}if(s==="starting"||s==="running"){const c=s==="running"&&!!o,d=c?"rounded-r-none border-r-0":void 0;let h;e[9]!==d?(h=ce(d),e[9]=d,e[10]=h):h=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(Md,{className:"size-3.5"}),e[11]=u):u=e[11];let f;e[12]!==r||e[13]!==h?(f=n.jsx(Ee,{asChild:!0,children:n.jsxs(re,{variant:"outline",size:"sm",onClick:r,className:h,children:[u," Stop"]})}),e[12]=r,e[13]=h,e[14]=f):f=e[14];let m;e[15]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(Ae,{children:"Stop sandbox"}),e[15]=m):m=e[15];let p;e[16]!==f?(p=n.jsxs(Pe,{children:[f,m]}),e[16]=f,e[17]=p):p=e[17];let g;e[18]!==o||e[19]!==c?(g=c&&n.jsxs(is,{children:[n.jsx(ns,{asChild:!0,children:n.jsx(re,{variant:"outline",size:"sm",className:"rounded-l-none px-1",children:n.jsx(ls,{className:"size-3"})})}),n.jsx(rs,{align:"end",children:n.jsxs(We,{onClick:o,children:[n.jsx(Xi,{className:"size-3.5"})," Restart"]})})]}),e[18]=o,e[19]=c,e[20]=g):g=e[20];let L;return e[21]!==p||e[22]!==g?(L=n.jsxs("div",{className:"flex items-center",children:[p,g]}),e[21]=p,e[22]=g,e[23]=L):L=e[23],L}return null}function uy(t){const e=U.c(16),{active:s,onClick:i,onClose:r,children:o}=t,a=s?"border-border bg-background shadow-sm":"border-transparent hover:bg-background/50";let l;e[0]!==a?(l=ce("flex h-7 items-center rounded-md border text-xs",a),e[0]=a,e[1]=l):l=e[1];const c=r?"pl-2.5 pr-1":"px-2.5",d=s?"font-medium text-foreground":"text-muted-foreground hover:text-foreground";let h;e[2]!==c||e[3]!==d?(h=ce("flex h-full items-center",c,d),e[2]=c,e[3]=d,e[4]=h):h=e[4];let u;e[5]!==o||e[6]!==i||e[7]!==h?(u=n.jsx("button",{type:"button",onClick:i,className:h,children:o}),e[5]=o,e[6]=i,e[7]=h,e[8]=u):u=e[8];let f;e[9]!==o||e[10]!==r?(f=r&&n.jsx("button",{type:"button","aria-label":`Close ${o}`,onClick:r,className:"pr-1.5 text-muted-foreground hover:text-foreground",children:n.jsx(dn,{className:"size-3"})}),e[9]=o,e[10]=r,e[11]=f):f=e[11];let m;return e[12]!==l||e[13]!==u||e[14]!==f?(m=n.jsxs("div",{className:l,children:[u,f]}),e[12]=l,e[13]=u,e[14]=f,e[15]=m):m=e[15],m}function fy(t){const e=U.c(10),{scripts:s,onRun:i}=t,[r,o]=R.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsx(ps,{asChild:!0,children:n.jsx(re,{variant:"ghost",size:"sm","aria-label":"Run script",children:n.jsx(It,{className:"size-3.5"})})})}),n.jsx(Ae,{children:"Run script"})]}),e[0]=a):a=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wide text-muted-foreground",children:"run a script"}),e[1]=l):l=e[1];let c;e[2]!==i||e[3]!==s?(c=s.length===0?n.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:"No scripts found"}):s.map(u=>n.jsxs("button",{type:"button",onClick:()=>{o(!1),i(u)},className:"w-full rounded-md px-2 py-1.5 text-left text-xs hover:bg-accent",children:["▸ ",u]},u)),e[2]=i,e[3]=s,e[4]=c):c=e[4];let d;e[5]!==c?(d=n.jsxs(gs,{align:"start",className:"p-1 w-56",children:[l,c]}),e[5]=c,e[6]=d):d=e[6];let h;return e[7]!==r||e[8]!==d?(h=n.jsxs(ms,{open:r,onOpenChange:o,children:[a,d]}),e[7]=r,e[8]=d,e[9]=h):h=e[9],h}function my(t){const e=U.c(13),{isRunning:s,isKilling:i,onRun:r,onStop:o}=t;if(i){let h;return e[0]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsxs(re,{variant:"outline",size:"sm",disabled:!0,children:[n.jsx(Ue,{className:"size-3.5 animate-spin"})," Stopping…"]}),e[0]=h):h=e[0],h}if(!s){let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(xi,{className:"size-3.5"}),e[1]=h):h=e[1];let u;e[2]!==r?(u=n.jsx(Ee,{asChild:!0,children:n.jsxs(re,{variant:"outline",size:"sm",onClick:r,children:[h," Run"]})}),e[2]=r,e[3]=u):u=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(Ae,{children:"Start process"}),e[4]=f):f=e[4];let m;return e[5]!==u?(m=n.jsxs(Pe,{children:[u,f]}),e[5]=u,e[6]=m):m=e[6],m}let a;e[7]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(Md,{className:"size-3.5"}),e[7]=a):a=e[7];let l;e[8]!==o?(l=n.jsx(Ee,{asChild:!0,children:n.jsxs(re,{variant:"outline",size:"sm",onClick:o,children:[a," Stop"]})}),e[8]=o,e[9]=l):l=e[9];let c;e[10]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Ae,{children:"Stop process"}),e[10]=c):c=e[10];let d;return e[11]!==l?(d=n.jsxs(Pe,{children:[l,c]}),e[11]=l,e[12]=d):d=e[12],d}var I1=Object.defineProperty,py=Object.getOwnPropertyDescriptor,gy=(t,e)=>{for(var s in e)I1(t,s,{get:e[s],enumerable:!0})},dt=(t,e,s,i)=>{for(var r=i>1?void 0:i?py(e,s):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(i?a(e,s,r):a(r))||r);return i&&r&&I1(e,s,r),r},xe=(t,e)=>(s,i)=>e(s,i,t),C0="Terminal input",el={get:()=>C0,set:t=>C0=t},j0="Too much output to announce, navigate to rows manually to read",tl={get:()=>j0,set:t=>j0=t};function _y(t){return t.replace(/\r?\n/g,"\r")}function Ly(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function vy(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function xy(t,e,s,i){if(t.stopPropagation(),t.clipboardData){let r=t.clipboardData.getData("text/plain");O1(r,e,s,i)}}function O1(t,e,s,i){t=_y(t),t=Ly(t,s.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(t,!0),e.value=""}function M1(t,e,s){let i=s.getBoundingClientRect(),r=t.clientX-i.left-10,o=t.clientY-i.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${r}px`,e.style.top=`${o}px`,e.style.zIndex="1000",e.focus()}function k0(t,e,s,i,r){M1(t,e,s),r&&i.rightClickSelect(t),e.value=i.selectionText,e.select()}function Gs(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function Jo(t,e=0,s=t.length){let i="";for(let r=e;r<s;++r){let o=t[r];o>65535?(o-=65536,i+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):i+=String.fromCharCode(o)}return i}var yy=class{constructor(){this._interim=0}clear(){this._interim=0}decode(t,e){let s=t.length;if(!s)return 0;let i=0,r=0;if(this._interim){let o=t.charCodeAt(r++);56320<=o&&o<=57343?e[i++]=(this._interim-55296)*1024+o-56320+65536:(e[i++]=this._interim,e[i++]=o),this._interim=0}for(let o=r;o<s;++o){let a=t.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=s)return this._interim=a,i;let l=t.charCodeAt(o);56320<=l&&l<=57343?e[i++]=(a-55296)*1024+l-56320+65536:(e[i++]=a,e[i++]=l);continue}a!==65279&&(e[i++]=a)}return i}},by=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(t,e){let s=t.length;if(!s)return 0;let i=0,r,o,a,l,c=0,d=0;if(this.interim[0]){let f=!1,m=this.interim[0];m&=(m&224)===192?31:(m&240)===224?15:7;let p=0,g;for(;(g=this.interim[++p]&63)&&p<4;)m<<=6,m|=g;let L=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,v=L-p;for(;d<v;){if(d>=s)return 0;if(g=t[d++],(g&192)!==128){d--,f=!0;break}else this.interim[p++]=g,m<<=6,m|=g&63}f||(L===2?m<128?d--:e[i++]=m:L===3?m<2048||m>=55296&&m<=57343||m===65279||(e[i++]=m):m<65536||m>1114111||(e[i++]=m)),this.interim.fill(0)}let h=s-4,u=d;for(;u<s;){for(;u<h&&!((r=t[u])&128)&&!((o=t[u+1])&128)&&!((a=t[u+2])&128)&&!((l=t[u+3])&128);)e[i++]=r,e[i++]=o,e[i++]=a,e[i++]=l,u+=4;if(r=t[u++],r<128)e[i++]=r;else if((r&224)===192){if(u>=s)return this.interim[0]=r,i;if(o=t[u++],(o&192)!==128){u--;continue}if(c=(r&31)<<6|o&63,c<128){u--;continue}e[i++]=c}else if((r&240)===224){if(u>=s)return this.interim[0]=r,i;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,i;if(a=t[u++],(a&192)!==128){u--;continue}if(c=(r&15)<<12|(o&63)<<6|a&63,c<2048||c>=55296&&c<=57343||c===65279)continue;e[i++]=c}else if((r&248)===240){if(u>=s)return this.interim[0]=r,i;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,i;if(a=t[u++],(a&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,this.interim[2]=a,i;if(l=t[u++],(l&192)!==128){u--;continue}if(c=(r&7)<<18|(o&63)<<12|(a&63)<<6|l&63,c<65536||c>1114111)continue;e[i++]=c}}return i}},B1="",Ys=" ",mr=class $1{constructor(){this.fg=0,this.bg=0,this.extended=new vo}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new $1;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},vo=class z1{constructor(e=0,s=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=s}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new z1(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},ss=class F1 extends mr{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new vo,this.combinedData=""}static fromCharData(e){let s=new F1;return s.setFromCharData(e),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Gs(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let s=!1;if(e[1].length>2)s=!0;else if(e[1].length===2){let i=e[1].charCodeAt(0);if(55296<=i&&i<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(i-55296)*1024+r-56320+65536|e[2]<<22:s=!0}else s=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;s&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},N0="di$target",sl="di$dependencies",Sa=new Map;function Sy(t){return t[sl]||[]}function St(t){if(Sa.has(t))return Sa.get(t);let e=function(s,i,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");wy(e,s,r)};return e._id=t,Sa.set(t,e),e}function wy(t,e,s){e[N0]===e?e[sl].push({id:t,index:s}):(e[sl]=[{id:t,index:s}],e[N0]=e)}var Ot=St("BufferService"),H1=St("CoreMouseService"),Bi=St("CoreService"),Cy=St("CharsetService"),Wc=St("InstantiationService"),U1=St("LogService"),Mt=St("OptionsService"),K1=St("OscLinkService"),jy=St("UnicodeService"),pr=St("DecorationService"),il=class{constructor(t,e,s){this._bufferService=t,this._optionsService=e,this._oscLinkService=s}provideLinks(t,e){let s=this._bufferService.buffer.lines.get(t-1);if(!s){e(void 0);return}let i=[],r=this._optionsService.rawOptions.linkHandler,o=new ss,a=s.getTrimmedLength(),l=-1,c=-1,d=!1;for(let h=0;h<a;h++)if(!(c===-1&&!s.hasContent(h))){if(s.loadCell(h,o),o.hasExtendedAttrs()&&o.extended.urlId)if(c===-1){c=h,l=o.extended.urlId;continue}else d=o.extended.urlId!==l;else c!==-1&&(d=!0);if(d||c!==-1&&h===a-1){let u=this._oscLinkService.getLinkData(l)?.uri;if(u){let f={start:{x:c+1,y:t},end:{x:h+(!d&&h===a-1?1:0),y:t}},m=!1;if(!r?.allowNonHttpProtocols)try{let p=new URL(u);["http:","https:"].includes(p.protocol)||(m=!0)}catch{m=!0}m||i.push({text:u,range:f,activate:(p,g)=>r?r.activate(p,g,f):ky(p,g),hover:(p,g)=>r?.hover?.(p,g,f),leave:(p,g)=>r?.leave?.(p,g,f)})}d=!1,o.hasExtendedAttrs()&&o.extended.urlId?(c=h,l=o.extended.urlId):(c=-1,l=-1)}}e(i)}};il=dt([xe(0,Ot),xe(1,Mt),xe(2,K1)],il);function ky(t,e){if(confirm(`Do you want to navigate to ${e}?
|
|
497
|
-
|
|
498
|
-
WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=e}else console.warn("Opening link blocked as opener could not be cleared")}}var Xo=St("CharSizeService"),zs=St("CoreBrowserService"),Vc=St("MouseService"),Fs=St("RenderService"),Ny=St("SelectionService"),W1=St("CharacterJoinerService"),gn=St("ThemeService"),V1=St("LinkProviderService"),Ty=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?T0.isErrorNoTelemetry(t)?new T0(t.message+`
|
|
499
|
-
|
|
500
|
-
`+t.stack):new Error(t.message+`
|
|
501
|
-
|
|
502
|
-
`+t.stack):t},0)}}addListener(t){return this.listeners.push(t),()=>{this._removeListener(t)}}emit(t){this.listeners.forEach(e=>{e(t)})}_removeListener(t){this.listeners.splice(this.listeners.indexOf(t),1)}setUnexpectedErrorHandler(t){this.unexpectedErrorHandler=t}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(t){this.unexpectedErrorHandler(t),this.emit(t)}onUnexpectedExternalError(t){this.unexpectedErrorHandler(t)}},Ey=new Ty;function Ur(t){Ay(t)||Ey.onUnexpectedError(t)}var nl="Canceled";function Ay(t){return t instanceof Py?!0:t instanceof Error&&t.name===nl&&t.message===nl}var Py=class extends Error{constructor(){super(nl),this.name=this.message}};function Ry(t){return new Error(`Illegal argument: ${t}`)}var T0=class rl extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof rl)return e;let s=new rl;return s.message=e.message,s.stack=e.stack,s}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},ol=class G1 extends Error{constructor(e){super(e||"An unexpected bug occurred."),Object.setPrototypeOf(this,G1.prototype)}};function zt(t,e=0){return t[t.length-(1+e)]}var Dy;(t=>{function e(o){return o<0}t.isLessThan=e;function s(o){return o<=0}t.isLessThanOrEqual=s;function i(o){return o>0}t.isGreaterThan=i;function r(o){return o===0}t.isNeitherLessOrGreaterThan=r,t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(Dy||={});function Iy(t,e){let s=this,i=!1,r;return function(){return i||(i=!0,e||(r=t.apply(s,arguments))),r}}var q1;(t=>{function e(x){return x&&typeof x=="object"&&typeof x[Symbol.iterator]=="function"}t.is=e;let s=Object.freeze([]);function i(){return s}t.empty=i;function*r(x){yield x}t.single=r;function o(x){return e(x)?x:r(x)}t.wrap=o;function a(x){return x||s}t.from=a;function*l(x){for(let b=x.length-1;b>=0;b--)yield x[b]}t.reverse=l;function c(x){return!x||x[Symbol.iterator]().next().done===!0}t.isEmpty=c;function d(x){return x[Symbol.iterator]().next().value}t.first=d;function h(x,b){let S=0;for(let w of x)if(b(w,S++))return!0;return!1}t.some=h;function u(x,b){for(let S of x)if(b(S))return S}t.find=u;function*f(x,b){for(let S of x)b(S)&&(yield S)}t.filter=f;function*m(x,b){let S=0;for(let w of x)yield b(w,S++)}t.map=m;function*p(x,b){let S=0;for(let w of x)yield*b(w,S++)}t.flatMap=p;function*g(...x){for(let b of x)yield*b}t.concat=g;function L(x,b,S){let w=S;for(let j of x)w=b(w,j);return w}t.reduce=L;function*v(x,b,S=x.length){for(b<0&&(b+=x.length),S<0?S+=x.length:S>x.length&&(S=x.length);b<S;b++)yield x[b]}t.slice=v;function y(x,b=Number.POSITIVE_INFINITY){let S=[];if(b===0)return[S,x];let w=x[Symbol.iterator]();for(let j=0;j<b;j++){let N=w.next();if(N.done)return[S,t.empty()];S.push(N.value)}return[S,{[Symbol.iterator](){return w}}]}t.consume=y;async function _(x){let b=[];for await(let S of x)b.push(S);return Promise.resolve(b)}t.asyncToArray=_})(q1||={});function ji(t){if(q1.is(t)){let e=[];for(let s of t)if(s)try{s.dispose()}catch(i){e.push(i)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}else if(t)return t.dispose(),t}function Oy(...t){return st(()=>ji(t))}function st(t){return{dispose:Iy(()=>{t()})}}var Y1=class J1{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{ji(this._toDispose)}finally{this._toDispose.clear()}}add(e){if(!e)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?J1.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(e),e}delete(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),void 0)}};Y1.DISABLE_DISPOSED_WARNING=!1;var ei=Y1,ze=class{constructor(){this._store=new ei,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};ze.None=Object.freeze({dispose(){}});var on=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(t){this._isDisposed||t===this._value||(this._value?.dispose(),this._value=t)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}clearAndLeak(){let t=this._value;return this._value=void 0,t}},Os=typeof window=="object"?window:globalThis,al=class ll{constructor(e){this.element=e,this.next=ll.Undefined,this.prev=ll.Undefined}};al.Undefined=new al(void 0);var nt=al,E0=class{constructor(){this._first=nt.Undefined,this._last=nt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===nt.Undefined}clear(){let t=this._first;for(;t!==nt.Undefined;){let e=t.next;t.prev=nt.Undefined,t.next=nt.Undefined,t=e}this._first=nt.Undefined,this._last=nt.Undefined,this._size=0}unshift(t){return this._insert(t,!1)}push(t){return this._insert(t,!0)}_insert(t,e){let s=new nt(t);if(this._first===nt.Undefined)this._first=s,this._last=s;else if(e){let r=this._last;this._last=s,s.prev=r,r.next=s}else{let r=this._first;this._first=s,s.next=r,r.prev=s}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(s))}}shift(){if(this._first!==nt.Undefined){let t=this._first.element;return this._remove(this._first),t}}pop(){if(this._last!==nt.Undefined){let t=this._last.element;return this._remove(this._last),t}}_remove(t){if(t.prev!==nt.Undefined&&t.next!==nt.Undefined){let e=t.prev;e.next=t.next,t.next.prev=e}else t.prev===nt.Undefined&&t.next===nt.Undefined?(this._first=nt.Undefined,this._last=nt.Undefined):t.next===nt.Undefined?(this._last=this._last.prev,this._last.next=nt.Undefined):t.prev===nt.Undefined&&(this._first=this._first.next,this._first.prev=nt.Undefined);this._size-=1}*[Symbol.iterator](){let t=this._first;for(;t!==nt.Undefined;)yield t.element,t=t.next}},My=globalThis.performance&&typeof globalThis.performance.now=="function",By=class X1{static create(e){return new X1(e)}constructor(e){this._now=My&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Ct;(t=>{t.None=()=>ze.None;function e(k,C){return u(k,()=>{},0,void 0,!0,void 0,C)}t.defer=e;function s(k){return(C,I=null,E)=>{let O=!1,P;return P=k(D=>{if(!O)return P?P.dispose():O=!0,C.call(I,D)},null,E),O&&P.dispose(),P}}t.once=s;function i(k,C,I){return d((E,O=null,P)=>k(D=>E.call(O,C(D)),null,P),I)}t.map=i;function r(k,C,I){return d((E,O=null,P)=>k(D=>{C(D),E.call(O,D)},null,P),I)}t.forEach=r;function o(k,C,I){return d((E,O=null,P)=>k(D=>C(D)&&E.call(O,D),null,P),I)}t.filter=o;function a(k){return k}t.signal=a;function l(...k){return(C,I=null,E)=>{let O=Oy(...k.map(P=>P(D=>C.call(I,D))));return h(O,E)}}t.any=l;function c(k,C,I,E){let O=I;return i(k,P=>(O=C(O,P),O),E)}t.reduce=c;function d(k,C){let I,E={onWillAddFirstListener(){I=k(O.fire,O)},onDidRemoveLastListener(){I?.dispose()}},O=new ge(E);return C?.add(O),O.event}function h(k,C){return C instanceof Array?C.push(k):C&&C.add(k),k}function u(k,C,I=100,E=!1,O=!1,P,D){let M,z,F,$=0,V,J={leakWarningThreshold:P,onWillAddFirstListener(){M=k(G=>{$++,z=C(z,G),E&&!F&&(Z.fire(z),z=void 0),V=()=>{let q=z;z=void 0,F=void 0,(!E||$>1)&&Z.fire(q),$=0},typeof I=="number"?(clearTimeout(F),F=setTimeout(V,I)):F===void 0&&(F=0,queueMicrotask(V))})},onWillRemoveListener(){O&&$>0&&V?.()},onDidRemoveLastListener(){V=void 0,M.dispose()}},Z=new ge(J);return D?.add(Z),Z.event}t.debounce=u;function f(k,C=0,I){return t.debounce(k,(E,O)=>E?(E.push(O),E):[O],C,void 0,!0,void 0,I)}t.accumulate=f;function m(k,C=(E,O)=>E===O,I){let E=!0,O;return o(k,P=>{let D=E||!C(P,O);return E=!1,O=P,D},I)}t.latch=m;function p(k,C,I){return[t.filter(k,C,I),t.filter(k,E=>!C(E),I)]}t.split=p;function g(k,C=!1,I=[],E){let O=I.slice(),P=k(z=>{O?O.push(z):M.fire(z)});E&&E.add(P);let D=()=>{O?.forEach(z=>M.fire(z)),O=null},M=new ge({onWillAddFirstListener(){P||(P=k(z=>M.fire(z)),E&&E.add(P))},onDidAddFirstListener(){O&&(C?setTimeout(D):D())},onDidRemoveLastListener(){P&&P.dispose(),P=null}});return E&&E.add(M),M.event}t.buffer=g;function L(k,C){return(I,E,O)=>{let P=C(new y);return k(function(D){let M=P.evaluate(D);M!==v&&I.call(E,M)},void 0,O)}}t.chain=L;let v=Symbol("HaltChainable");class y{constructor(){this.steps=[]}map(C){return this.steps.push(C),this}forEach(C){return this.steps.push(I=>(C(I),I)),this}filter(C){return this.steps.push(I=>C(I)?I:v),this}reduce(C,I){let E=I;return this.steps.push(O=>(E=C(E,O),E)),this}latch(C=(I,E)=>I===E){let I=!0,E;return this.steps.push(O=>{let P=I||!C(O,E);return I=!1,E=O,P?O:v}),this}evaluate(C){for(let I of this.steps)if(C=I(C),C===v)break;return C}}function _(k,C,I=E=>E){let E=(...M)=>D.fire(I(...M)),O=()=>k.on(C,E),P=()=>k.removeListener(C,E),D=new ge({onWillAddFirstListener:O,onDidRemoveLastListener:P});return D.event}t.fromNodeEventEmitter=_;function x(k,C,I=E=>E){let E=(...M)=>D.fire(I(...M)),O=()=>k.addEventListener(C,E),P=()=>k.removeEventListener(C,E),D=new ge({onWillAddFirstListener:O,onDidRemoveLastListener:P});return D.event}t.fromDOMEventEmitter=x;function b(k){return new Promise(C=>s(k)(C))}t.toPromise=b;function S(k){let C=new ge;return k.then(I=>{C.fire(I)},()=>{C.fire(void 0)}).finally(()=>{C.dispose()}),C.event}t.fromPromise=S;function w(k,C){return k(I=>C.fire(I))}t.forward=w;function j(k,C,I){return C(I),k(E=>C(E))}t.runAndSubscribe=j;class N{constructor(C,I){this._observable=C,this._counter=0,this._hasChanged=!1;let E={onWillAddFirstListener:()=>{C.addObserver(this)},onDidRemoveLastListener:()=>{C.removeObserver(this)}};this.emitter=new ge(E),I&&I.add(this.emitter)}beginUpdate(C){this._counter++}handlePossibleChange(C){}handleChange(C,I){this._hasChanged=!0}endUpdate(C){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function T(k,C){return new N(k,C).emitter.event}t.fromObservable=T;function A(k){return(C,I,E)=>{let O=0,P=!1,D={beginUpdate(){O++},endUpdate(){O--,O===0&&(k.reportChanges(),P&&(P=!1,C.call(I)))},handlePossibleChange(){},handleChange(){P=!0}};k.addObserver(D),k.reportChanges();let M={dispose(){k.removeObserver(D)}};return E instanceof ei?E.add(M):Array.isArray(E)&&E.push(M),M}}t.fromObservableLight=A})(Ct||={});var cl=class dl{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${dl._idPool++}`,dl.all.add(this)}start(e){this._stopWatch=new By,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};cl.all=new Set,cl._idPool=0;var $y=cl,zy=-1,Z1=class Q1{constructor(e,s,i=(Q1._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e,this.threshold=s,this.name=i,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,s){let i=this.threshold;if(i<=0||s<i)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=i*.5;let[o,a]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${a}):`;console.warn(l),console.warn(o);let c=new Uy(l,o);this._errorHandler(c)}return()=>{let o=this._stacks.get(e.value)||0;this._stacks.set(e.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,s=0;for(let[i,r]of this._stacks)(!e||s<r)&&(e=[i,r],s=r);return e}};Z1._idPool=1;var Fy=Z1,Hy=class ef{constructor(e){this.value=e}static create(){let e=new Error;return new ef(e.stack??"")}print(){console.warn(this.value.split(`
|
|
503
|
-
`).slice(2).join(`
|
|
504
|
-
`))}},Uy=class extends Error{constructor(t,e){super(t),this.name="ListenerLeakError",this.stack=e}},Ky=class extends Error{constructor(t,e){super(t),this.name="ListenerRefusalError",this.stack=e}},Wy=0,wa=class{constructor(t){this.value=t,this.id=Wy++}},Vy=2,Gy,ge=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new Fy(t?.onListenerError??Ur,this._options?.leakWarningThreshold??zy):void 0,this._perfMon=this._options?._profName?new $y(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(t,e,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let a=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(a);let l=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],c=new Ky(`${a}. HINT: Stack shows most frequent listener (${l[1]}-times)`,l[0]);return(this._options?.onListenerError||Ur)(c),ze.None}if(this._disposed)return ze.None;e&&(t=t.bind(e));let i=new wa(t),r;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(i.stack=Hy.create(),r=this._leakageMon.check(i.stack,this._size+1)),this._listeners?this._listeners instanceof wa?(this._deliveryQueue??=new qy,this._listeners=[this._listeners,i]):this._listeners.push(i):(this._options?.onWillAddFirstListener?.(this),this._listeners=i,this._options?.onDidAddFirstListener?.(this)),this._size++;let o=st(()=>{r?.(),this._removeListener(i)});return s instanceof ei?s.add(o):Array.isArray(s)&&s.push(o),o},this._event}_removeListener(t){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let e=this._listeners,s=e.indexOf(t);if(s===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,e[s]=void 0;let i=this._deliveryQueue.current===this;if(this._size*Vy<=e.length){let r=0;for(let o=0;o<e.length;o++)e[o]?e[r++]=e[o]:i&&(this._deliveryQueue.end--,r<this._deliveryQueue.i&&this._deliveryQueue.i--);e.length=r}}_deliver(t,e){if(!t)return;let s=this._options?.onListenerError||Ur;if(!s){t.value(e);return}try{t.value(e)}catch(i){s(i)}}_deliverQueue(t){let e=t.current._listeners;for(;t.i<t.end;)this._deliver(e[t.i++],t.value);t.reset()}fire(t){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof wa)this._deliver(this._listeners,t);else{let e=this._deliveryQueue;e.enqueue(this,t,this._listeners.length),this._deliverQueue(e)}this._perfMon?.stop()}hasListeners(){return this._size>0}},qy=class{constructor(){this.i=-1,this.end=0}enqueue(t,e,s){this.i=0,this.end=s,this.current=t,this.value=e}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},hl=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new ge,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new ge,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,s){if(this.getZoomLevel(s)===e)return;let i=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(i,e),this._onDidChangeZoomLevel.fire(i)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),e)}setFullscreen(e,s){if(this.isFullscreen(s)===e)return;let i=this.getWindowId(s);this.mapWindowIdToFullScreen.set(i,e),this._onDidChangeFullscreen.fire(i)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};hl.INSTANCE=new hl;var Gc=hl;function Yy(t,e,s){typeof e=="string"&&(e=t.matchMedia(e)),e.addEventListener("change",s)}Gc.INSTANCE.onDidChangeZoomLevel;function Jy(t){return Gc.INSTANCE.getZoomFactor(t)}Gc.INSTANCE.onDidChangeFullscreen;var _n=typeof navigator=="object"?navigator.userAgent:"",ul=_n.indexOf("Firefox")>=0,Xy=_n.indexOf("AppleWebKit")>=0,qc=_n.indexOf("Chrome")>=0,Zy=!qc&&_n.indexOf("Safari")>=0;_n.indexOf("Electron/")>=0;_n.indexOf("Android")>=0;var Ca=!1;if(typeof Os.matchMedia=="function"){let t=Os.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=Os.matchMedia("(display-mode: fullscreen)");Ca=t.matches,Yy(Os,t,({matches:s})=>{Ca&&e.matches||(Ca=s)})}var Wi="en",fl=!1,ml=!1,Kr=!1,tf=!1,Dr,Wr=Wi,A0=Wi,Qy,Is,Li=globalThis,Ht;typeof Li.vscode<"u"&&typeof Li.vscode.process<"u"?Ht=Li.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(Ht=process);var eb=typeof Ht?.versions?.electron=="string",tb=eb&&Ht?.type==="renderer";if(typeof Ht=="object"){fl=Ht.platform==="win32",ml=Ht.platform==="darwin",Kr=Ht.platform==="linux",Kr&&Ht.env.SNAP&&Ht.env.SNAP_REVISION,Ht.env.CI||Ht.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Dr=Wi,Wr=Wi;let t=Ht.env.VSCODE_NLS_CONFIG;if(t)try{let e=JSON.parse(t);Dr=e.userLocale,A0=e.osLocale,Wr=e.resolvedLanguage||Wi,Qy=e.languagePack?.translationsConfigFile}catch{}tf=!0}else typeof navigator=="object"&&!tb?(Is=navigator.userAgent,fl=Is.indexOf("Windows")>=0,ml=Is.indexOf("Macintosh")>=0,(Is.indexOf("Macintosh")>=0||Is.indexOf("iPad")>=0||Is.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Kr=Is.indexOf("Linux")>=0,Is?.indexOf("Mobi")>=0,Wr=globalThis._VSCODE_NLS_LANGUAGE||Wi,Dr=navigator.language.toLowerCase(),A0=Dr):console.error("Unable to resolve platform.");var sf=fl,js=ml,sb=Kr,P0=tf,Ns=Is,Ks=Wr,ib;(t=>{function e(){return Ks}t.value=e;function s(){return Ks.length===2?Ks==="en":Ks.length>=3?Ks[0]==="e"&&Ks[1]==="n"&&Ks[2]==="-":!1}t.isDefaultVariant=s;function i(){return Ks==="en"}t.isDefault=i})(ib||={});var nb=typeof Li.postMessage=="function"&&!Li.importScripts;(()=>{if(nb){let t=[];Li.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let i=0,r=t.length;i<r;i++){let o=t[i];if(o.id===s.data.vscodeScheduleAsyncWork){t.splice(i,1),o.callback();return}}});let e=0;return s=>{let i=++e;t.push({id:i,callback:s}),Li.postMessage({vscodeScheduleAsyncWork:i},"*")}}return t=>setTimeout(t)})();var rb=!!(Ns&&Ns.indexOf("Chrome")>=0);Ns&&Ns.indexOf("Firefox")>=0;!rb&&Ns&&Ns.indexOf("Safari")>=0;Ns&&Ns.indexOf("Edg/")>=0;Ns&&Ns.indexOf("Android")>=0;var zi=typeof navigator=="object"?navigator:{};P0||document.queryCommandSupported&&document.queryCommandSupported("copy")||zi&&zi.clipboard&&zi.clipboard.writeText,P0||zi&&zi.clipboard&&zi.clipboard.readText;var Yc=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(t,e){this._keyCodeToStr[t]=e,this._strToKeyCode[e.toLowerCase()]=t}keyCodeToStr(t){return this._keyCodeToStr[t]}strToKeyCode(t){return this._strToKeyCode[t.toLowerCase()]||0}},ja=new Yc,R0=new Yc,D0=new Yc,ob=new Array(230),nf;(t=>{function e(l){return ja.keyCodeToStr(l)}t.toString=e;function s(l){return ja.strToKeyCode(l)}t.fromString=s;function i(l){return R0.keyCodeToStr(l)}t.toUserSettingsUS=i;function r(l){return D0.keyCodeToStr(l)}t.toUserSettingsGeneral=r;function o(l){return R0.strToKeyCode(l)||D0.strToKeyCode(l)}t.fromUserSettings=o;function a(l){if(l>=98&&l<=113)return null;switch(l){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return ja.keyCodeToStr(l)}t.toElectronAccelerator=a})(nf||={});var ab=class rf{constructor(e,s,i,r,o){this.ctrlKey=e,this.shiftKey=s,this.altKey=i,this.metaKey=r,this.keyCode=o}equals(e){return e instanceof rf&&this.ctrlKey===e.ctrlKey&&this.shiftKey===e.shiftKey&&this.altKey===e.altKey&&this.metaKey===e.metaKey&&this.keyCode===e.keyCode}getHashCode(){let e=this.ctrlKey?"1":"0",s=this.shiftKey?"1":"0",i=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${e}${s}${i}${r}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new lb([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},lb=class{constructor(t){if(t.length===0)throw Ry("chords");this.chords=t}getHashCode(){let t="";for(let e=0,s=this.chords.length;e<s;e++)e!==0&&(t+=";"),t+=this.chords[e].getHashCode();return t}equals(t){if(t===null||this.chords.length!==t.chords.length)return!1;for(let e=0;e<this.chords.length;e++)if(!this.chords[e].equals(t.chords[e]))return!1;return!0}};function cb(t){if(t.charCode){let s=String.fromCharCode(t.charCode).toUpperCase();return nf.fromString(s)}let e=t.keyCode;if(e===3)return 7;if(ul)switch(e){case 59:return 85;case 60:if(sb)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(js)return 57;break}else if(Xy&&(js&&e===93||!js&&e===92))return 57;return ob[e]||0}var db=js?256:2048,hb=512,ub=1024,fb=js?2048:256,I0=class{constructor(t){this._standardKeyboardEventBrand=!0;let e=t;this.browserEvent=e,this.target=e.target,this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,this.altGraphKey=e.getModifierState?.("AltGraph"),this.keyCode=cb(e),this.code=e.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(t){return this._asKeybinding===t}_computeKeybinding(){let t=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode);let e=0;return this.ctrlKey&&(e|=db),this.altKey&&(e|=hb),this.shiftKey&&(e|=ub),this.metaKey&&(e|=fb),e|=t,e}_computeKeyCodeChord(){let t=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode),new ab(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,t)}},O0=new WeakMap;function mb(t){if(!t.parent||t.parent===t)return null;try{let e=t.location,s=t.parent.location;if(e.origin!=="null"&&s.origin!=="null"&&e.origin!==s.origin)return null}catch{return null}return t.parent}var pb=class{static getSameOriginWindowChain(t){let e=O0.get(t);if(!e){e=[],O0.set(t,e);let s=t,i;do i=mb(s),i?e.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):e.push({window:new WeakRef(s),iframeElement:null}),s=i;while(s)}return e.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(t,e){if(!e||t===e)return{top:0,left:0};let s=0,i=0,r=this.getSameOriginWindowChain(t);for(let o of r){let a=o.window.deref();if(s+=a?.scrollY??0,i+=a?.scrollX??0,a===e||!o.iframeElement)break;let l=o.iframeElement.getBoundingClientRect();s+=l.top,i+=l.left}return{top:s,left:i}}},Ir=class{constructor(t,e){this.timestamp=Date.now(),this.browserEvent=e,this.leftButton=e.button===0,this.middleButton=e.button===1,this.rightButton=e.button===2,this.buttons=e.buttons,this.target=e.target,this.detail=e.detail||1,e.type==="dblclick"&&(this.detail=2),this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,typeof e.pageX=="number"?(this.posx=e.pageX,this.posy=e.pageY):(this.posx=e.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=e.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=pb.getPositionOfChildWindowRelativeToAncestorWindow(t,e.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},M0=class{constructor(t,e=0,s=0){this.browserEvent=t||null,this.target=t?t.target||t.targetNode||t.srcElement:null,this.deltaY=s,this.deltaX=e;let i=!1;if(qc){let r=navigator.userAgent.match(/Chrome\/(\d+)/);i=(r?parseInt(r[1]):123)<=122}if(t){let r=t,o=t,a=t.view?.devicePixelRatio||1;if(typeof r.wheelDeltaY<"u")i?this.deltaY=r.wheelDeltaY/(120*a):this.deltaY=r.wheelDeltaY/120;else if(typeof o.VERTICAL_AXIS<"u"&&o.axis===o.VERTICAL_AXIS)this.deltaY=-o.detail/3;else if(t.type==="wheel"){let l=t;l.deltaMode===l.DOM_DELTA_LINE?ul&&!js?this.deltaY=-t.deltaY/3:this.deltaY=-t.deltaY:this.deltaY=-t.deltaY/40}if(typeof r.wheelDeltaX<"u")Zy&&sf?this.deltaX=-(r.wheelDeltaX/120):i?this.deltaX=r.wheelDeltaX/(120*a):this.deltaX=r.wheelDeltaX/120;else if(typeof o.HORIZONTAL_AXIS<"u"&&o.axis===o.HORIZONTAL_AXIS)this.deltaX=-t.detail/3;else if(t.type==="wheel"){let l=t;l.deltaMode===l.DOM_DELTA_LINE?ul&&!js?this.deltaX=-t.deltaX/3:this.deltaX=-t.deltaX:this.deltaX=-t.deltaX/40}this.deltaY===0&&this.deltaX===0&&t.wheelDelta&&(i?this.deltaY=t.wheelDelta/(120*a):this.deltaY=t.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},of=Object.freeze(function(t,e){let s=setTimeout(t.bind(e),0);return{dispose(){clearTimeout(s)}}}),gb;(t=>{function e(s){return s===t.None||s===t.Cancelled||s instanceof _b?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}t.isCancellationToken=e,t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ct.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:of})})(gb||={});var _b=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?of:(this._emitter||(this._emitter=new ge),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Jc=class{constructor(t,e){this._isDisposed=!1,this._token=-1,typeof t=="function"&&typeof e=="number"&&this.setIfNotSet(t,e)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(t,e){if(this._isDisposed)throw new ol("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,t()},e)}setIfNotSet(t,e){if(this._isDisposed)throw new ol("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,t()},e))}},Lb=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(t,e,s=globalThis){if(this.isDisposed)throw new ol("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let i=s.setInterval(()=>{t()},e);this.disposable=st(()=>{s.clearInterval(i),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},vb;(t=>{async function e(i){let r,o=await Promise.all(i.map(a=>a.then(l=>l,l=>{r||(r=l)})));if(typeof r<"u")throw r;return o}t.settled=e;function s(i){return new Promise(async(r,o)=>{try{await i(r,o)}catch(a){o(a)}})}t.withAsyncBody=s})(vb||={});var B0=class Xt{static fromArray(e){return new Xt(s=>{s.emitMany(e)})}static fromPromise(e){return new Xt(async s=>{s.emitMany(await e)})}static fromPromises(e){return new Xt(async s=>{await Promise.all(e.map(async i=>s.emitOne(await i)))})}static merge(e){return new Xt(async s=>{await Promise.all(e.map(async i=>{for await(let r of i)s.emitOne(r)}))})}constructor(e,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new ge,queueMicrotask(async()=>{let i={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(e(i)),this.resolve()}catch(r){this.reject(r)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await Ct.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(e,s){return new Xt(async i=>{for await(let r of e)i.emitOne(s(r))})}map(e){return Xt.map(this,e)}static filter(e,s){return new Xt(async i=>{for await(let r of e)s(r)&&i.emitOne(r)})}filter(e){return Xt.filter(this,e)}static coalesce(e){return Xt.filter(e,s=>!!s)}coalesce(){return Xt.coalesce(this)}static async toPromise(e){let s=[];for await(let i of e)s.push(i);return s}toPromise(){return Xt.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};B0.EMPTY=B0.fromArray([]);var{getWindow:Cs,getWindowId:xb,onDidRegisterWindow:yb}=(function(){let t=new Map,e={window:Os,disposables:new ei};t.set(Os.vscodeWindowId,e);let s=new ge,i=new ge,r=new ge;function o(a,l){return(typeof a=="number"?t.get(a):void 0)??(l?e:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:i.event,registerWindow(a){if(t.has(a.vscodeWindowId))return ze.None;let l=new ei,c={window:a,disposables:l.add(new ei)};return t.set(a.vscodeWindowId,c),l.add(st(()=>{t.delete(a.vscodeWindowId),i.fire(a)})),l.add(ke(a,vt.BEFORE_UNLOAD,()=>{r.fire(a)})),s.fire(c),l},getWindows(){return t.values()},getWindowsCount(){return t.size},getWindowId(a){return a.vscodeWindowId},hasWindow(a){return t.has(a)},getWindowById:o,getWindow(a){let l=a;if(l?.ownerDocument?.defaultView)return l.ownerDocument.defaultView.window;let c=a;return c?.view?c.view.window:Os},getDocument(a){return Cs(a).document}}})(),bb=class{constructor(t,e,s,i){this._node=t,this._type=e,this._handler=s,this._options=i||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function ke(t,e,s,i){return new bb(t,e,s,i)}var $0=function(t,e,s,i){return ke(t,e,s,i)},Xc,Sb=class extends Lb{constructor(t){super(),this.defaultTarget=t&&Cs(t)}cancelAndSet(t,e,s){return super.cancelAndSet(t,e,s??this.defaultTarget)}},z0=class{constructor(t,e=0){this._runner=t,this.priority=e,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(t){Ur(t)}}static sort(t,e){return e.priority-t.priority}};(function(){let t=new Map,e=new Map,s=new Map,i=new Map,r=o=>{s.set(o,!1);let a=t.get(o)??[];for(e.set(o,a),t.set(o,[]),i.set(o,!0);a.length>0;)a.sort(z0.sort),a.shift().execute();i.set(o,!1)};Xc=(o,a,l=0)=>{let c=xb(o),d=new z0(a,l),h=t.get(c);return h||(h=[],t.set(c,h)),h.push(d),s.get(c)||(s.set(c,!0),o.requestAnimationFrame(()=>r(c))),d}})();function wb(t){let e=t.getBoundingClientRect(),s=Cs(t);return{left:e.left+s.scrollX,top:e.top+s.scrollY,width:e.width,height:e.height}}var vt={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},Cb=class{constructor(t){this.domNode=t,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(t){let e=Bt(t);this._maxWidth!==e&&(this._maxWidth=e,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let e=Bt(t);this._width!==e&&(this._width=e,this.domNode.style.width=this._width)}setHeight(t){let e=Bt(t);this._height!==e&&(this._height=e,this.domNode.style.height=this._height)}setTop(t){let e=Bt(t);this._top!==e&&(this._top=e,this.domNode.style.top=this._top)}setLeft(t){let e=Bt(t);this._left!==e&&(this._left=e,this.domNode.style.left=this._left)}setBottom(t){let e=Bt(t);this._bottom!==e&&(this._bottom=e,this.domNode.style.bottom=this._bottom)}setRight(t){let e=Bt(t);this._right!==e&&(this._right=e,this.domNode.style.right=this._right)}setPaddingTop(t){let e=Bt(t);this._paddingTop!==e&&(this._paddingTop=e,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let e=Bt(t);this._paddingLeft!==e&&(this._paddingLeft=e,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let e=Bt(t);this._paddingBottom!==e&&(this._paddingBottom=e,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let e=Bt(t);this._paddingRight!==e&&(this._paddingRight=e,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(t){let e=Bt(t);this._fontSize!==e&&(this._fontSize=e,this.domNode.style.fontSize=this._fontSize)}setFontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(t){this._fontFeatureSettings!==t&&(this._fontFeatureSettings=t,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(t){this._fontVariationSettings!==t&&(this._fontVariationSettings=t,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(t){this._textDecoration!==t&&(this._textDecoration=t,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(t){let e=Bt(t);this._lineHeight!==e&&(this._lineHeight=e,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let e=Bt(t);this._letterSpacing!==e&&(this._letterSpacing=e,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(t){this._className!==t&&(this._className=t,this.domNode.className=this._className)}toggleClassName(t,e){this.domNode.classList.toggle(t,e),this._className=this.domNode.className}setDisplay(t){this._display!==t&&(this._display=t,this.domNode.style.display=this._display)}setPosition(t){this._position!==t&&(this._position=t,this.domNode.style.position=this._position)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this.domNode.style.visibility=this._visibility)}setColor(t){this._color!==t&&(this._color=t,this.domNode.style.color=this._color)}setBackgroundColor(t){this._backgroundColor!==t&&(this._backgroundColor=t,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(t){this._layerHint!==t&&(this._layerHint=t,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(t){this._boxShadow!==t&&(this._boxShadow=t,this.domNode.style.boxShadow=t)}setContain(t){this._contain!==t&&(this._contain=t,this.domNode.style.contain=this._contain)}setAttribute(t,e){this.domNode.setAttribute(t,e)}removeAttribute(t){this.domNode.removeAttribute(t)}appendChild(t){this.domNode.appendChild(t.domNode)}removeChild(t){this.domNode.removeChild(t.domNode)}};function Bt(t){return typeof t=="number"?`${t}px`:t}function qn(t){return new Cb(t)}var af=class{constructor(){this._hooks=new ei,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(t,e){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,t&&s&&s(e)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(t,e,s,i,r){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=i,this._onStopCallback=r;let o=t;try{t.setPointerCapture(e),this._hooks.add(st(()=>{try{t.releasePointerCapture(e)}catch{}}))}catch{o=Cs(t)}this._hooks.add(ke(o,vt.POINTER_MOVE,a=>{if(a.buttons!==s){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(ke(o,vt.POINTER_UP,a=>this.stopMonitoring(!0)))}};function jb(t,e,s){let i=null,r=null;if(typeof s.value=="function"?(i="value",r=s.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(i="get",r=s.get),!r)throw new Error("not supported");let o=`$memoize$${e}`;s[i]=function(...a){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,a)}),this[o]}}var bs;(t=>(t.Tap="-xterm-gesturetap",t.Change="-xterm-gesturechange",t.Start="-xterm-gesturestart",t.End="-xterm-gesturesend",t.Contextmenu="-xterm-gesturecontextmenu"))(bs||={});var In=class jt extends ze{constructor(){super(),this.dispatched=!1,this.targets=new E0,this.ignoreTargets=new E0,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Ct.runAndSubscribe(yb,({window:e,disposables:s})=>{s.add(ke(e.document,"touchstart",i=>this.onTouchStart(i),{passive:!1})),s.add(ke(e.document,"touchend",i=>this.onTouchEnd(e,i))),s.add(ke(e.document,"touchmove",i=>this.onTouchMove(i),{passive:!1}))},{window:Os,disposables:this._store}))}static addTarget(e){if(!jt.isTouchDevice())return ze.None;jt.INSTANCE||(jt.INSTANCE=new jt);let s=jt.INSTANCE.targets.push(e);return st(s)}static ignoreTarget(e){if(!jt.isTouchDevice())return ze.None;jt.INSTANCE||(jt.INSTANCE=new jt);let s=jt.INSTANCE.ignoreTargets.push(e);return st(s)}static isTouchDevice(){return"ontouchstart"in Os||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(e){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let i=0,r=e.targetTouches.length;i<r;i++){let o=e.targetTouches.item(i);this.activeTouches[o.identifier]={id:o.identifier,initialTarget:o.target,initialTimeStamp:s,initialPageX:o.pageX,initialPageY:o.pageY,rollingTimestamps:[s],rollingPageX:[o.pageX],rollingPageY:[o.pageY]};let a=this.newGestureEvent(bs.Start,o.target);a.pageX=o.pageX,a.pageY=o.pageY,this.dispatchEvent(a)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}onTouchEnd(e,s){let i=Date.now(),r=Object.keys(this.activeTouches).length;for(let o=0,a=s.changedTouches.length;o<a;o++){let l=s.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("move of an UNKNOWN touch",l);continue}let c=this.activeTouches[l.identifier],d=Date.now()-c.initialTimeStamp;if(d<jt.HOLD_DELAY&&Math.abs(c.initialPageX-zt(c.rollingPageX))<30&&Math.abs(c.initialPageY-zt(c.rollingPageY))<30){let h=this.newGestureEvent(bs.Tap,c.initialTarget);h.pageX=zt(c.rollingPageX),h.pageY=zt(c.rollingPageY),this.dispatchEvent(h)}else if(d>=jt.HOLD_DELAY&&Math.abs(c.initialPageX-zt(c.rollingPageX))<30&&Math.abs(c.initialPageY-zt(c.rollingPageY))<30){let h=this.newGestureEvent(bs.Contextmenu,c.initialTarget);h.pageX=zt(c.rollingPageX),h.pageY=zt(c.rollingPageY),this.dispatchEvent(h)}else if(r===1){let h=zt(c.rollingPageX),u=zt(c.rollingPageY),f=zt(c.rollingTimestamps)-c.rollingTimestamps[0],m=h-c.rollingPageX[0],p=u-c.rollingPageY[0],g=[...this.targets].filter(L=>c.initialTarget instanceof Node&&L.contains(c.initialTarget));this.inertia(e,g,i,Math.abs(m)/f,m>0?1:-1,h,Math.abs(p)/f,p>0?1:-1,u)}this.dispatchEvent(this.newGestureEvent(bs.End,c.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(e,s){let i=document.createEvent("CustomEvent");return i.initEvent(e,!1,!0),i.initialTarget=s,i.tapCount=0,i}dispatchEvent(e){if(e.type===bs.Tap){let s=new Date().getTime(),i=0;s-this._lastSetTapCountTime>jt.CLEAR_TAP_COUNT_TIME?i=1:i=2,this._lastSetTapCountTime=s,e.tapCount=i}else(e.type===bs.Change||e.type===bs.Contextmenu)&&(this._lastSetTapCountTime=0);if(e.initialTarget instanceof Node){for(let i of this.ignoreTargets)if(i.contains(e.initialTarget))return;let s=[];for(let i of this.targets)if(i.contains(e.initialTarget)){let r=0,o=e.initialTarget;for(;o&&o!==i;)r++,o=o.parentElement;s.push([r,i])}s.sort((i,r)=>i[0]-r[0]);for(let[i,r]of s)r.dispatchEvent(e),this.dispatched=!0}}inertia(e,s,i,r,o,a,l,c,d){this.handle=Xc(e,()=>{let h=Date.now(),u=h-i,f=0,m=0,p=!0;r+=jt.SCROLL_FRICTION*u,l+=jt.SCROLL_FRICTION*u,r>0&&(p=!1,f=o*r*u),l>0&&(p=!1,m=c*l*u);let g=this.newGestureEvent(bs.Change);g.translationX=f,g.translationY=m,s.forEach(L=>L.dispatchEvent(g)),p||this.inertia(e,s,h,r,o,a+f,l,c,d+m)})}onTouchMove(e){let s=Date.now();for(let i=0,r=e.changedTouches.length;i<r;i++){let o=e.changedTouches.item(i);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn("end of an UNKNOWN touch",o);continue}let a=this.activeTouches[o.identifier],l=this.newGestureEvent(bs.Change,a.initialTarget);l.translationX=o.pageX-zt(a.rollingPageX),l.translationY=o.pageY-zt(a.rollingPageY),l.pageX=o.pageX,l.pageY=o.pageY,this.dispatchEvent(l),a.rollingPageX.length>3&&(a.rollingPageX.shift(),a.rollingPageY.shift(),a.rollingTimestamps.shift()),a.rollingPageX.push(o.pageX),a.rollingPageY.push(o.pageY),a.rollingTimestamps.push(s)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};In.SCROLL_FRICTION=-.005,In.HOLD_DELAY=700,In.CLEAR_TAP_COUNT_TIME=400,dt([jb],In,"isTouchDevice",1);var kb=In,Zc=class extends ze{onclick(t,e){this._register(ke(t,vt.CLICK,s=>e(new Ir(Cs(t),s))))}onmousedown(t,e){this._register(ke(t,vt.MOUSE_DOWN,s=>e(new Ir(Cs(t),s))))}onmouseover(t,e){this._register(ke(t,vt.MOUSE_OVER,s=>e(new Ir(Cs(t),s))))}onmouseleave(t,e){this._register(ke(t,vt.MOUSE_LEAVE,s=>e(new Ir(Cs(t),s))))}onkeydown(t,e){this._register(ke(t,vt.KEY_DOWN,s=>e(new I0(s))))}onkeyup(t,e){this._register(ke(t,vt.KEY_UP,s=>e(new I0(s))))}oninput(t,e){this._register(ke(t,vt.INPUT,e))}onblur(t,e){this._register(ke(t,vt.BLUR,e))}onfocus(t,e){this._register(ke(t,vt.FOCUS,e))}onchange(t,e){this._register(ke(t,vt.CHANGE,e))}ignoreGesture(t){return kb.ignoreTarget(t)}},F0=11,Nb=class extends Zc{constructor(t){super(),this._onActivate=t.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=t.bgWidth+"px",this.bgDomNode.style.height=t.bgHeight+"px",typeof t.top<"u"&&(this.bgDomNode.style.top="0px"),typeof t.left<"u"&&(this.bgDomNode.style.left="0px"),typeof t.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof t.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=t.className,this.domNode.style.position="absolute",this.domNode.style.width=F0+"px",this.domNode.style.height=F0+"px",typeof t.top<"u"&&(this.domNode.style.top=t.top+"px"),typeof t.left<"u"&&(this.domNode.style.left=t.left+"px"),typeof t.bottom<"u"&&(this.domNode.style.bottom=t.bottom+"px"),typeof t.right<"u"&&(this.domNode.style.right=t.right+"px"),this._pointerMoveMonitor=this._register(new af),this._register($0(this.bgDomNode,vt.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register($0(this.domNode,vt.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new Sb),this._pointerdownScheduleRepeatTimer=this._register(new Jc)}_arrowPointerDown(t){if(!t.target||!(t.target instanceof Element))return;let e=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Cs(t))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(e,200),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),t.preventDefault()}},Tb=class pl{constructor(e,s,i,r,o,a,l){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,i=i|0,r=r|0,o=o|0,a=a|0,l=l|0),this.rawScrollLeft=r,this.rawScrollTop=l,s<0&&(s=0),r+s>i&&(r=i-s),r<0&&(r=0),o<0&&(o=0),l+o>a&&(l=a-o),l<0&&(l=0),this.width=s,this.scrollWidth=i,this.scrollLeft=r,this.height=o,this.scrollHeight=a,this.scrollTop=l}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(e,s){return new pl(this._forceIntegerValues,typeof e.width<"u"?e.width:this.width,typeof e.scrollWidth<"u"?e.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof e.height<"u"?e.height:this.height,typeof e.scrollHeight<"u"?e.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(e){return new pl(this._forceIntegerValues,this.width,this.scrollWidth,typeof e.scrollLeft<"u"?e.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof e.scrollTop<"u"?e.scrollTop:this.rawScrollTop)}createScrollEvent(e,s){let i=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,o=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,l=this.scrollHeight!==e.scrollHeight,c=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:s,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:i,scrollWidthChanged:r,scrollLeftChanged:o,heightChanged:a,scrollHeightChanged:l,scrollTopChanged:c}}},Eb=class extends ze{constructor(t){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new ge),this.onScroll=this._onScroll.event,this._smoothScrollDuration=t.smoothScrollDuration,this._scheduleAtNextAnimationFrame=t.scheduleAtNextAnimationFrame,this._state=new Tb(t.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(t){this._smoothScrollDuration=t}validateScrollPosition(t){return this._state.withScrollPosition(t)}getScrollDimensions(){return this._state}setScrollDimensions(t,e){let s=this._state.withScrollDimensions(t,e);this._setState(s,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(t){let e=this._state.withScrollPosition(t);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(e,!1)}setScrollPositionSmooth(t,e){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(t);if(this._smoothScrolling){t={scrollLeft:typeof t.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:t.scrollLeft,scrollTop:typeof t.scrollTop>"u"?this._smoothScrolling.to.scrollTop:t.scrollTop};let s=this._state.withScrollPosition(t);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let i;e?i=new U0(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):i=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=i}else{let s=this._state.withScrollPosition(t);this._smoothScrolling=U0.start(this._state,s,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let t=this._smoothScrolling.tick(),e=this._state.withScrollPosition(t);if(this._setState(e,!0),!!this._smoothScrolling){if(t.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(t,e){let s=this._state;s.equals(t)||(this._state=t,this._onScroll.fire(this._state.createScrollEvent(s,e)))}},H0=class{constructor(t,e,s){this.scrollLeft=t,this.scrollTop=e,this.isDone=s}};function ka(t,e){let s=e-t;return function(i){return t+s*Rb(i)}}function Ab(t,e,s){return function(i){return i<s?t(i/s):e((i-s)/(1-s))}}var U0=class gl{constructor(e,s,i,r){this.from=e,this.to=s,this.duration=r,this.startTime=i,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,s,i){if(Math.abs(e-s)>2.5*i){let r,o;return e<s?(r=e+.75*i,o=s-.75*i):(r=e-.75*i,o=s+.75*i),Ab(ka(e,r),ka(o,s),.33)}return ka(e,s)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let s=(e-this.startTime)/this.duration;if(s<1){let i=this.scrollLeft(s),r=this.scrollTop(s);return new H0(i,r,!1)}return new H0(this.to.scrollLeft,this.to.scrollTop,!0)}combine(e,s,i){return gl.start(e,s,i)}static start(e,s,i){i=i+10;let r=Date.now()-10;return new gl(e,s,r,i)}};function Pb(t){return Math.pow(t,3)}function Rb(t){return 1-Pb(1-t)}var Db=class extends ze{constructor(t,e,s){super(),this._visibility=t,this._visibleClassName=e,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Jc)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this._updateShouldBeVisible())}setShouldBeVisible(t){this._rawShouldBeVisible=t,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let t=this._applyVisibilitySetting();this._shouldBeVisible!==t&&(this._shouldBeVisible=t,this.ensureVisibility())}setIsNeeded(t){this._isNeeded!==t&&(this._isNeeded=t,this.ensureVisibility())}setDomNode(t){this._domNode=t,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(t){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(t?" fade":"")))}},Ib=140,lf=class extends Zc{constructor(t){super(),this._lazyRender=t.lazyRender,this._host=t.host,this._scrollable=t.scrollable,this._scrollByPage=t.scrollByPage,this._scrollbarState=t.scrollbarState,this._visibilityController=this._register(new Db(t.visibility,"visible scrollbar "+t.extraScrollbarClassName,"invisible scrollbar "+t.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new af),this._shouldRender=!0,this.domNode=qn(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(ke(this.domNode.domNode,vt.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(t){let e=this._register(new Nb(t));this.domNode.domNode.appendChild(e.bgDomNode),this.domNode.domNode.appendChild(e.domNode)}_createSlider(t,e,s,i){this.slider=qn(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(t),this.slider.setLeft(e),typeof s=="number"&&this.slider.setWidth(s),typeof i=="number"&&this.slider.setHeight(i),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(ke(this.slider.domNode,vt.POINTER_DOWN,r=>{r.button===0&&(r.preventDefault(),this._sliderPointerDown(r))})),this.onclick(this.slider.domNode,r=>{r.leftButton&&r.stopPropagation()})}_onElementSize(t){return this._scrollbarState.setVisibleSize(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(t){return this._scrollbarState.setScrollSize(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(t){return this._scrollbarState.setScrollPosition(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(t){t.target===this.domNode.domNode&&this._onPointerDown(t)}delegatePointerDown(t){let e=this.domNode.domNode.getClientRects()[0].top,s=e+this._scrollbarState.getSliderPosition(),i=e+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),r=this._sliderPointerPosition(t);s<=r&&r<=i?t.button===0&&(t.preventDefault(),this._sliderPointerDown(t)):this._onPointerDown(t)}_onPointerDown(t){let e,s;if(t.target===this.domNode.domNode&&typeof t.offsetX=="number"&&typeof t.offsetY=="number")e=t.offsetX,s=t.offsetY;else{let r=wb(this.domNode.domNode);e=t.pageX-r.left,s=t.pageY-r.top}let i=this._pointerDownRelativePosition(e,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(i):this._scrollbarState.getDesiredScrollPositionFromOffset(i)),t.button===0&&(t.preventDefault(),this._sliderPointerDown(t))}_sliderPointerDown(t){if(!t.target||!(t.target instanceof Element))return;let e=this._sliderPointerPosition(t),s=this._sliderOrthogonalPointerPosition(t),i=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,r=>{let o=this._sliderOrthogonalPointerPosition(r),a=Math.abs(o-s);if(sf&&a>Ib){this._setDesiredScrollPositionNow(i.getScrollPosition());return}let l=this._sliderPointerPosition(r)-e;this._setDesiredScrollPositionNow(i.getDesiredScrollPositionFromDelta(l))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(t){let e={};this.writeScrollPosition(e,t),this._scrollable.setScrollPositionNow(e)}updateScrollbarSize(t){this._updateScrollbarSize(t),this._scrollbarState.setScrollbarSize(t),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},cf=class _l{constructor(e,s,i,r,o,a){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(i),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=o,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new _l(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let s=Math.round(e);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(e){let s=Math.round(e);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(e){let s=Math.round(e);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,s,i,r,o){let a=Math.max(0,i-e),l=Math.max(0,a-2*s),c=r>0&&r>i;if(!c)return{computedAvailableSize:Math.round(a),computedIsNeeded:c,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let d=Math.round(Math.max(20,Math.floor(i*l/r))),h=(l-d)/(r-i),u=o*h;return{computedAvailableSize:Math.round(a),computedIsNeeded:c,computedSliderSize:Math.round(d),computedSliderRatio:h,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let e=_l._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=e.computedAvailableSize,this._computedIsNeeded=e.computedIsNeeded,this._computedSliderSize=e.computedSliderSize,this._computedSliderRatio=e.computedSliderRatio,this._computedSliderPosition=e.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){if(!this._computedIsNeeded)return 0;let s=e-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let s=e-this._arrowSize,i=this._scrollPosition;return s<this._computedSliderPosition?i-=this._visibleSize:i+=this._visibleSize,i}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let s=this._computedSliderPosition+e;return Math.round(s/this._computedSliderRatio)}},Ob=class extends lf{constructor(t,e,s){let i=t.getScrollDimensions(),r=t.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:s,scrollbarState:new cf(e.horizontalHasArrows?e.arrowSize:0,e.horizontal===2?0:e.horizontalScrollbarSize,e.vertical===2?0:e.verticalScrollbarSize,i.width,i.scrollWidth,r.scrollLeft),visibility:e.horizontal,extraScrollbarClassName:"horizontal",scrollable:t,scrollByPage:e.scrollByPage}),e.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((e.horizontalScrollbarSize-e.horizontalSliderSize)/2),0,void 0,e.horizontalSliderSize)}_updateSlider(t,e){this.slider.setWidth(t),this.slider.setLeft(e)}_renderDomNode(t,e){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(t){return this._shouldRender=this._onElementScrollSize(t.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(t.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(t.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(t,e){return t}_sliderPointerPosition(t){return t.pageX}_sliderOrthogonalPointerPosition(t){return t.pageY}_updateScrollbarSize(t){this.slider.setHeight(t)}writeScrollPosition(t,e){t.scrollLeft=e}updateOptions(t){this.updateScrollbarSize(t.horizontal===2?0:t.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(t.vertical===2?0:t.verticalScrollbarSize),this._visibilityController.setVisibility(t.horizontal),this._scrollByPage=t.scrollByPage}},Mb=class extends lf{constructor(t,e,s){let i=t.getScrollDimensions(),r=t.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:s,scrollbarState:new cf(e.verticalHasArrows?e.arrowSize:0,e.vertical===2?0:e.verticalScrollbarSize,0,i.height,i.scrollHeight,r.scrollTop),visibility:e.vertical,extraScrollbarClassName:"vertical",scrollable:t,scrollByPage:e.scrollByPage}),e.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((e.verticalScrollbarSize-e.verticalSliderSize)/2),e.verticalSliderSize,void 0)}_updateSlider(t,e){this.slider.setHeight(t),this.slider.setTop(e)}_renderDomNode(t,e){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(t){return this._shouldRender=this._onElementScrollSize(t.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(t.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(t.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(t,e){return e}_sliderPointerPosition(t){return t.pageY}_sliderOrthogonalPointerPosition(t){return t.pageX}_updateScrollbarSize(t){this.slider.setWidth(t)}writeScrollPosition(t,e){t.scrollTop=e}updateOptions(t){this.updateScrollbarSize(t.vertical===2?0:t.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(t.vertical),this._scrollByPage=t.scrollByPage}},Bb=500,K0=50,$b=class{constructor(t,e,s){this.timestamp=t,this.deltaX=e,this.deltaY=s,this.score=0}},Ll=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,s=0,i=1,r=this._rear;do{let o=r===this._front?e:Math.pow(2,-i);if(e-=o,s+=this._memory[r].score*o,r===this._front)break;r=(this._capacity+r-1)%this._capacity,i++}while(!0);return s<=.5}acceptStandardWheelEvent(e){if(qc){let s=Cs(e.browserEvent),i=Jy(s);this.accept(Date.now(),e.deltaX*i,e.deltaY*i)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,s,i){let r=null,o=new $b(e,s,i);this._front===-1&&this._rear===-1?(this._memory[0]=o,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=o),o.score=this._computeScore(o,r)}_computeScore(e,s){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let i=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(i+=.25),s){let r=Math.abs(e.deltaX),o=Math.abs(e.deltaY),a=Math.abs(s.deltaX),l=Math.abs(s.deltaY),c=Math.max(Math.min(r,a),1),d=Math.max(Math.min(o,l),1),h=Math.max(r,a),u=Math.max(o,l);h%c===0&&u%d===0&&(i-=.5)}return Math.min(Math.max(i,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};Ll.INSTANCE=new Ll;var zb=Ll,Fb=class extends Zc{constructor(t,e,s){super(),this._onScroll=this._register(new ge),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new ge),this.onWillScroll=this._onWillScroll.event,this._options=Ub(e),this._scrollable=s,this._register(this._scrollable.onScroll(r=>{this._onWillScroll.fire(r),this._onDidScroll(r),this._onScroll.fire(r)}));let i={onMouseWheel:r=>this._onMouseWheel(r),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new Mb(this._scrollable,this._options,i)),this._horizontalScrollbar=this._register(new Ob(this._scrollable,this._options,i)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(t),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=qn(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=qn(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=qn(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,r=>this._onMouseOver(r)),this.onmouseleave(this._listenOnDomNode,r=>this._onMouseLeave(r)),this._hideTimeout=this._register(new Jc),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=ji(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(t){this._verticalScrollbar.delegatePointerDown(t)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(t){this._scrollable.setScrollDimensions(t,!1)}updateClassName(t){this._options.className=t,js&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(t){typeof t.handleMouseWheel<"u"&&(this._options.handleMouseWheel=t.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof t.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=t.mouseWheelScrollSensitivity),typeof t.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=t.fastScrollSensitivity),typeof t.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=t.scrollPredominantAxis),typeof t.horizontal<"u"&&(this._options.horizontal=t.horizontal),typeof t.vertical<"u"&&(this._options.vertical=t.vertical),typeof t.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=t.horizontalScrollbarSize),typeof t.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=t.verticalScrollbarSize),typeof t.scrollByPage<"u"&&(this._options.scrollByPage=t.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(t){this._revealOnScroll=t}delegateScrollFromMouseWheelEvent(t){this._onMouseWheel(new M0(t))}_setListeningToMouseWheel(t){if(this._mouseWheelToDispose.length>0!==t&&(this._mouseWheelToDispose=ji(this._mouseWheelToDispose),t)){let e=s=>{this._onMouseWheel(new M0(s))};this._mouseWheelToDispose.push(ke(this._listenOnDomNode,vt.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(t){if(t.browserEvent?.defaultPrevented)return;let e=zb.INSTANCE;e.acceptStandardWheelEvent(t);let s=!1;if(t.deltaY||t.deltaX){let r=t.deltaY*this._options.mouseWheelScrollSensitivity,o=t.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+r===0?o=r=0:Math.abs(r)>=Math.abs(o)?o=0:r=0),this._options.flipAxes&&([r,o]=[o,r]);let a=!js&&t.browserEvent&&t.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!o&&(o=r,r=0),t.browserEvent&&t.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,r=r*this._options.fastScrollSensitivity);let l=this._scrollable.getFutureScrollPosition(),c={};if(r){let d=K0*r,h=l.scrollTop-(d<0?Math.floor(d):Math.ceil(d));this._verticalScrollbar.writeScrollPosition(c,h)}if(o){let d=K0*o,h=l.scrollLeft-(d<0?Math.floor(d):Math.ceil(d));this._horizontalScrollbar.writeScrollPosition(c,h)}c=this._scrollable.validateScrollPosition(c),(l.scrollLeft!==c.scrollLeft||l.scrollTop!==c.scrollTop)&&(this._options.mouseWheelSmoothScroll&&e.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(c):this._scrollable.setScrollPositionNow(c),s=!0)}let i=s;!i&&this._options.alwaysConsumeMouseWheel&&(i=!0),!i&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(i=!0),i&&(t.preventDefault(),t.stopPropagation())}_onDidScroll(t){this._shouldRender=this._horizontalScrollbar.onDidScroll(t)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(t)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let t=this._scrollable.getCurrentScrollPosition(),e=t.scrollTop>0,s=t.scrollLeft>0,i=s?" left":"",r=e?" top":"",o=s||e?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${i}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${r}${i}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(t){this._mouseIsOver=!1,this._hide()}_onMouseOver(t){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),Bb)}},Hb=class extends Fb{constructor(t,e,s){super(t,e,s)}setScrollPosition(t){t.reuseAnimation?this._scrollable.setScrollPositionSmooth(t,t.reuseAnimation):this._scrollable.setScrollPositionNow(t)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function Ub(t){let e={lazyRender:typeof t.lazyRender<"u"?t.lazyRender:!1,className:typeof t.className<"u"?t.className:"",useShadows:typeof t.useShadows<"u"?t.useShadows:!0,handleMouseWheel:typeof t.handleMouseWheel<"u"?t.handleMouseWheel:!0,flipAxes:typeof t.flipAxes<"u"?t.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof t.consumeMouseWheelIfScrollbarIsNeeded<"u"?t.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof t.alwaysConsumeMouseWheel<"u"?t.alwaysConsumeMouseWheel:!1,scrollYToX:typeof t.scrollYToX<"u"?t.scrollYToX:!1,mouseWheelScrollSensitivity:typeof t.mouseWheelScrollSensitivity<"u"?t.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof t.fastScrollSensitivity<"u"?t.fastScrollSensitivity:5,scrollPredominantAxis:typeof t.scrollPredominantAxis<"u"?t.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof t.mouseWheelSmoothScroll<"u"?t.mouseWheelSmoothScroll:!0,arrowSize:typeof t.arrowSize<"u"?t.arrowSize:11,listenOnDomNode:typeof t.listenOnDomNode<"u"?t.listenOnDomNode:null,horizontal:typeof t.horizontal<"u"?t.horizontal:1,horizontalScrollbarSize:typeof t.horizontalScrollbarSize<"u"?t.horizontalScrollbarSize:10,horizontalSliderSize:typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:0,horizontalHasArrows:typeof t.horizontalHasArrows<"u"?t.horizontalHasArrows:!1,vertical:typeof t.vertical<"u"?t.vertical:1,verticalScrollbarSize:typeof t.verticalScrollbarSize<"u"?t.verticalScrollbarSize:10,verticalHasArrows:typeof t.verticalHasArrows<"u"?t.verticalHasArrows:!1,verticalSliderSize:typeof t.verticalSliderSize<"u"?t.verticalSliderSize:0,scrollByPage:typeof t.scrollByPage<"u"?t.scrollByPage:!1};return e.horizontalSliderSize=typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:e.horizontalScrollbarSize,e.verticalSliderSize=typeof t.verticalSliderSize<"u"?t.verticalSliderSize:e.verticalScrollbarSize,js&&(e.className+=" mac"),e}var vl=class extends ze{constructor(t,e,s,i,r,o,a,l){super(),this._bufferService=s,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new ge),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new Eb({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:d=>Xc(i.window,d)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new Hb(e,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(r.onProtocolChange(d=>{this._scrollableElement.updateOptions({handleMouseWheel:!(d&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Ct.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),t.appendChild(this._scrollableElement.getDomNode()),this._register(st(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=i.mainDocument.createElement("style"),e.appendChild(this._styleElement),this._register(st(()=>this._styleElement.remove())),this._register(Ct.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
505
|
-
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(d=>this._handleScroll(d)))}scrollLines(t){let e=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:e.scrollTop+t*this._renderService.dimensions.css.cell.height})}scrollToLine(t,e){e&&(this._latestYDisp=t),this._scrollableElement.setScrollPosition({reuseAnimation:!e,scrollTop:t*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(t){t!==void 0&&(this._latestYDisp=t),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(t=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,t!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:t*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(t){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let e=Math.round(t.scrollTop/this._renderService.dimensions.css.cell.height),s=e-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=e,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};vl=dt([xe(2,Ot),xe(3,zs),xe(4,H1),xe(5,gn),xe(6,Mt),xe(7,Fs)],vl);var xl=class extends ze{constructor(t,e,s,i,r){super(),this._screenElement=t,this._bufferService=e,this._coreBrowserService=s,this._decorationService=i,this._renderService=r,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(o=>this._removeDecoration(o))),this._register(st(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let t of this._decorationService.decorations)this._renderDecoration(t);this._dimensionsChanged=!1}_renderDecoration(t){this._refreshStyle(t),this._dimensionsChanged&&this._refreshXPosition(t)}_createElement(t){let e=this._coreBrowserService.mainDocument.createElement("div");e.classList.add("xterm-decoration"),e.classList.toggle("xterm-decoration-top-layer",t?.options?.layer==="top"),e.style.width=`${Math.round((t.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,e.style.height=`${(t.options.height||1)*this._renderService.dimensions.css.cell.height}px`,e.style.top=`${(t.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,e.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=t.options.x??0;return s&&s>this._bufferService.cols&&(e.style.display="none"),this._refreshXPosition(t,e),e}_refreshStyle(t){let e=t.marker.line-this._bufferService.buffers.active.ydisp;if(e<0||e>=this._bufferService.rows)t.element&&(t.element.style.display="none",t.onRenderEmitter.fire(t.element));else{let s=this._decorationElements.get(t);s||(s=this._createElement(t),t.element=s,this._decorationElements.set(t,s),this._container.appendChild(s),t.onDispose(()=>{this._decorationElements.delete(t),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((t.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(t.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${e*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),t.onRenderEmitter.fire(s)}}_refreshXPosition(t,e=t.element){if(!e)return;let s=t.options.x??0;(t.options.anchor||"left")==="right"?e.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":e.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(t){this._decorationElements.get(t)?.remove(),this._decorationElements.delete(t),t.dispose()}};xl=dt([xe(1,Ot),xe(2,zs),xe(3,pr),xe(4,Fs)],xl);var Kb=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(t){if(t.options.overviewRulerOptions){for(let e of this._zones)if(e.color===t.options.overviewRulerOptions.color&&e.position===t.options.overviewRulerOptions.position){if(this._lineIntersectsZone(e,t.marker.line))return;if(this._lineAdjacentToZone(e,t.marker.line,t.options.overviewRulerOptions.position)){this._addLineToZone(e,t.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=t.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=t.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=t.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=t.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:t.options.overviewRulerOptions.color,position:t.options.overviewRulerOptions.position,startBufferLine:t.marker.line,endBufferLine:t.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(t){this._linePadding=t}_lineIntersectsZone(t,e){return e>=t.startBufferLine&&e<=t.endBufferLine}_lineAdjacentToZone(t,e,s){return e>=t.startBufferLine-this._linePadding[s||"full"]&&e<=t.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(t,e){t.startBufferLine=Math.min(t.startBufferLine,e),t.endBufferLine=Math.max(t.endBufferLine,e)}},xs={full:0,left:0,center:0,right:0},Ws={full:0,left:0,center:0,right:0},Sn={full:0,left:0,center:0,right:0},xo=class extends ze{constructor(t,e,s,i,r,o,a,l){super(),this._viewportElement=t,this._screenElement=e,this._bufferService=s,this._decorationService=i,this._renderService=r,this._optionsService=o,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new Kb,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(st(()=>this._canvas?.remove()));let c=this._canvas.getContext("2d");if(c)this._ctx=c;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let t=Math.floor((this._canvas.width-1)/3),e=Math.ceil((this._canvas.width-1)/3);Ws.full=this._canvas.width,Ws.left=t,Ws.center=e,Ws.right=t,this._refreshDrawHeightConstants(),Sn.full=1,Sn.left=1,Sn.center=1+Ws.left,Sn.right=1+Ws.left+Ws.center}_refreshDrawHeightConstants(){xs.full=Math.round(2*this._coreBrowserService.dpr);let t=this._canvas.height/this._bufferService.buffer.lines.length,e=Math.round(Math.max(Math.min(t,12),6)*this._coreBrowserService.dpr);xs.left=e,xs.center=e,xs.right=e}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*xs.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*xs.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*xs.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*xs.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let t=this._colorZoneStore.zones;for(let e of t)e.position!=="full"&&this._renderColorZone(e);for(let e of t)e.position==="full"&&this._renderColorZone(e);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(t){this._ctx.fillStyle=t.color,this._ctx.fillRect(Sn[t.position||"full"],Math.round((this._canvas.height-1)*(t.startBufferLine/this._bufferService.buffers.active.lines.length)-xs[t.position||"full"]/2),Ws[t.position||"full"],Math.round((this._canvas.height-1)*((t.endBufferLine-t.startBufferLine)/this._bufferService.buffers.active.lines.length)+xs[t.position||"full"]))}_queueRefresh(t,e){this._shouldUpdateDimensions=t||this._shouldUpdateDimensions,this._shouldUpdateAnchor=e||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};xo=dt([xe(2,Ot),xe(3,pr),xe(4,Fs),xe(5,Mt),xe(6,gn),xe(7,zs)],xo);var de;(t=>(t.NUL="\0",t.SOH="",t.STX="",t.ETX="",t.EOT="",t.ENQ="",t.ACK="",t.BEL="\x07",t.BS="\b",t.HT=" ",t.LF=`
|
|
506
|
-
`,t.VT="\v",t.FF="\f",t.CR="\r",t.SO="",t.SI="",t.DLE="",t.DC1="",t.DC2="",t.DC3="",t.DC4="",t.NAK="",t.SYN="",t.ETB="",t.CAN="",t.EM="",t.SUB="",t.ESC="\x1B",t.FS="",t.GS="",t.RS="",t.US="",t.SP=" ",t.DEL=""))(de||={});var Vr;(t=>(t.PAD="",t.HOP="",t.BPH="",t.NBH="",t.IND="",t.NEL="
",t.SSA="",t.ESA="",t.HTS="",t.HTJ="",t.VTS="",t.PLD="",t.PLU="",t.RI="",t.SS2="",t.SS3="",t.DCS="",t.PU1="",t.PU2="",t.STS="",t.CCH="",t.MW="",t.SPA="",t.EPA="",t.SOS="",t.SGCI="",t.SCI="",t.CSI="",t.ST="",t.OSC="",t.PM="",t.APC=""))(Vr||={});var df;(t=>t.ST=`${de.ESC}\\`)(df||={});var yl=class{constructor(t,e,s,i,r,o){this._textarea=t,this._compositionView=e,this._bufferService=s,this._optionsService=i,this._coreService=r,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(t){this._compositionView.textContent=t.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(t){if(this._isComposing||this._isSendingComposition){if(t.keyCode===20||t.keyCode===229||t.keyCode===16||t.keyCode===17||t.keyCode===18)return!1;this._finalizeComposition(!1)}return t.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(t){if(this._compositionView.classList.remove("active"),this._isComposing=!1,t){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;e.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(e.start,this._compositionPosition.start):s=this._textarea.value.substring(e.start),s.length>0&&this._coreService.triggerDataEvent(s,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let t=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let e=this._textarea.value,s=e.replace(t,"");this._dataAlreadySent=s,e.length>t.length?this._coreService.triggerDataEvent(s,!0):e.length<t.length?this._coreService.triggerDataEvent(`${de.DEL}`,!0):e.length===t.length&&e!==t&&this._coreService.triggerDataEvent(e,!0)}},0)}updateCompositionElements(t){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),s=this._renderService.dimensions.css.cell.height,i=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+"px",this._compositionView.style.top=i+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let o=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+"px",this._textarea.style.top=i+"px",this._textarea.style.width=Math.max(o.width,1)+"px",this._textarea.style.height=Math.max(o.height,1)+"px",this._textarea.style.lineHeight=o.height+"px"}t||setTimeout(()=>this.updateCompositionElements(!0),0)}}};yl=dt([xe(2,Ot),xe(3,Mt),xe(4,Bi),xe(5,Fs)],yl);var xt=0,yt=0,bt=0,ct=0,W0={css:"#00000000",rgba:0},mt;(t=>{function e(r,o,a,l){return l!==void 0?`#${hi(r)}${hi(o)}${hi(a)}${hi(l)}`:`#${hi(r)}${hi(o)}${hi(a)}`}t.toCss=e;function s(r,o,a,l=255){return(r<<24|o<<16|a<<8|l)>>>0}t.toRgba=s;function i(r,o,a,l){return{css:t.toCss(r,o,a,l),rgba:t.toRgba(r,o,a,l)}}t.toColor=i})(mt||={});var Qe;(t=>{function e(c,d){if(ct=(d.rgba&255)/255,ct===1)return{css:d.css,rgba:d.rgba};let h=d.rgba>>24&255,u=d.rgba>>16&255,f=d.rgba>>8&255,m=c.rgba>>24&255,p=c.rgba>>16&255,g=c.rgba>>8&255;xt=m+Math.round((h-m)*ct),yt=p+Math.round((u-p)*ct),bt=g+Math.round((f-g)*ct);let L=mt.toCss(xt,yt,bt),v=mt.toRgba(xt,yt,bt);return{css:L,rgba:v}}t.blend=e;function s(c){return(c.rgba&255)===255}t.isOpaque=s;function i(c,d,h){let u=Gr.ensureContrastRatio(c.rgba,d.rgba,h);if(u)return mt.toColor(u>>24&255,u>>16&255,u>>8&255)}t.ensureContrastRatio=i;function r(c){let d=(c.rgba|255)>>>0;return[xt,yt,bt]=Gr.toChannels(d),{css:mt.toCss(xt,yt,bt),rgba:d}}t.opaque=r;function o(c,d){return ct=Math.round(d*255),[xt,yt,bt]=Gr.toChannels(c.rgba),{css:mt.toCss(xt,yt,bt,ct),rgba:mt.toRgba(xt,yt,bt,ct)}}t.opacity=o;function a(c,d){return ct=c.rgba&255,o(c,ct*d/255)}t.multiplyOpacity=a;function l(c){return[c.rgba>>24&255,c.rgba>>16&255,c.rgba>>8&255]}t.toColorRGB=l})(Qe||={});var rt;(t=>{let e,s;try{let r=document.createElement("canvas");r.width=1,r.height=1;let o=r.getContext("2d",{willReadFrequently:!0});o&&(e=o,e.globalCompositeOperation="copy",s=e.createLinearGradient(0,0,1,1))}catch{}function i(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return xt=parseInt(r.slice(1,2).repeat(2),16),yt=parseInt(r.slice(2,3).repeat(2),16),bt=parseInt(r.slice(3,4).repeat(2),16),mt.toColor(xt,yt,bt);case 5:return xt=parseInt(r.slice(1,2).repeat(2),16),yt=parseInt(r.slice(2,3).repeat(2),16),bt=parseInt(r.slice(3,4).repeat(2),16),ct=parseInt(r.slice(4,5).repeat(2),16),mt.toColor(xt,yt,bt,ct);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let o=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return xt=parseInt(o[1]),yt=parseInt(o[2]),bt=parseInt(o[3]),ct=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),mt.toColor(xt,yt,bt,ct);if(!e||!s)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=s,e.fillStyle=r,typeof e.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[xt,yt,bt,ct]=e.getImageData(0,0,1,1).data,ct!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:mt.toRgba(xt,yt,bt,ct),css:r}}t.toColor=i})(rt||={});var Pt;(t=>{function e(i){return s(i>>16&255,i>>8&255,i&255)}t.relativeLuminance=e;function s(i,r,o){let a=i/255,l=r/255,c=o/255,d=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),h=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),u=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4);return d*.2126+h*.7152+u*.0722}t.relativeLuminance2=s})(Pt||={});var Gr;(t=>{function e(a,l){if(ct=(l&255)/255,ct===1)return l;let c=l>>24&255,d=l>>16&255,h=l>>8&255,u=a>>24&255,f=a>>16&255,m=a>>8&255;return xt=u+Math.round((c-u)*ct),yt=f+Math.round((d-f)*ct),bt=m+Math.round((h-m)*ct),mt.toRgba(xt,yt,bt)}t.blend=e;function s(a,l,c){let d=Pt.relativeLuminance(a>>8),h=Pt.relativeLuminance(l>>8);if(Ds(d,h)<c){if(h<d){let m=i(a,l,c),p=Ds(d,Pt.relativeLuminance(m>>8));if(p<c){let g=r(a,l,c),L=Ds(d,Pt.relativeLuminance(g>>8));return p>L?m:g}return m}let u=r(a,l,c),f=Ds(d,Pt.relativeLuminance(u>>8));if(f<c){let m=i(a,l,c),p=Ds(d,Pt.relativeLuminance(m>>8));return f>p?u:m}return u}}t.ensureContrastRatio=s;function i(a,l,c){let d=a>>24&255,h=a>>16&255,u=a>>8&255,f=l>>24&255,m=l>>16&255,p=l>>8&255,g=Ds(Pt.relativeLuminance2(f,m,p),Pt.relativeLuminance2(d,h,u));for(;g<c&&(f>0||m>0||p>0);)f-=Math.max(0,Math.ceil(f*.1)),m-=Math.max(0,Math.ceil(m*.1)),p-=Math.max(0,Math.ceil(p*.1)),g=Ds(Pt.relativeLuminance2(f,m,p),Pt.relativeLuminance2(d,h,u));return(f<<24|m<<16|p<<8|255)>>>0}t.reduceLuminance=i;function r(a,l,c){let d=a>>24&255,h=a>>16&255,u=a>>8&255,f=l>>24&255,m=l>>16&255,p=l>>8&255,g=Ds(Pt.relativeLuminance2(f,m,p),Pt.relativeLuminance2(d,h,u));for(;g<c&&(f<255||m<255||p<255);)f=Math.min(255,f+Math.ceil((255-f)*.1)),m=Math.min(255,m+Math.ceil((255-m)*.1)),p=Math.min(255,p+Math.ceil((255-p)*.1)),g=Ds(Pt.relativeLuminance2(f,m,p),Pt.relativeLuminance2(d,h,u));return(f<<24|m<<16|p<<8|255)>>>0}t.increaseLuminance=r;function o(a){return[a>>24&255,a>>16&255,a>>8&255,a&255]}t.toChannels=o})(Gr||={});function hi(t){let e=t.toString(16);return e.length<2?"0"+e:e}function Ds(t,e){return t<e?(e+.05)/(t+.05):(t+.05)/(e+.05)}var Wb=class extends mr{constructor(t,e,s){super(),this.content=0,this.combinedData="",this.fg=t.fg,this.bg=t.bg,this.combinedData=e,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(t){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},yo=class{constructor(t){this._bufferService=t,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new ss}register(t){let e={id:this._nextCharacterJoinerId++,handler:t};return this._characterJoiners.push(e),e.id}deregister(t){for(let e=0;e<this._characterJoiners.length;e++)if(this._characterJoiners[e].id===t)return this._characterJoiners.splice(e,1),!0;return!1}getJoinedCharacters(t){if(this._characterJoiners.length===0)return[];let e=this._bufferService.buffer.lines.get(t);if(!e||e.length===0)return[];let s=[],i=e.translateToString(!0),r=0,o=0,a=0,l=e.getFg(0),c=e.getBg(0);for(let d=0;d<e.getTrimmedLength();d++)if(e.loadCell(d,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==l||this._workCell.bg!==c){if(d-r>1){let h=this._getJoinedRanges(i,a,o,e,r);for(let u=0;u<h.length;u++)s.push(h[u])}r=d,a=o,l=this._workCell.fg,c=this._workCell.bg}o+=this._workCell.getChars().length||Ys.length}if(this._bufferService.cols-r>1){let d=this._getJoinedRanges(i,a,o,e,r);for(let h=0;h<d.length;h++)s.push(d[h])}return s}_getJoinedRanges(t,e,s,i,r){let o=t.substring(e,s),a=[];try{a=this._characterJoiners[0].handler(o)}catch(l){console.error(l)}for(let l=1;l<this._characterJoiners.length;l++)try{let c=this._characterJoiners[l].handler(o);for(let d=0;d<c.length;d++)yo._mergeRanges(a,c[d])}catch(c){console.error(c)}return this._stringRangesToCellRanges(a,i,r),a}_stringRangesToCellRanges(t,e,s){let i=0,r=!1,o=0,a=t[i];if(a){for(let l=s;l<this._bufferService.cols;l++){let c=e.getWidth(l),d=e.getString(l).length||Ys.length;if(c!==0){if(!r&&a[0]<=o&&(a[0]=l,r=!0),a[1]<=o){if(a[1]=l,a=t[++i],!a)break;a[0]<=o?(a[0]=l,r=!0):r=!1}o+=d}}a&&(a[1]=this._bufferService.cols)}}static _mergeRanges(t,e){let s=!1;for(let i=0;i<t.length;i++){let r=t[i];if(s){if(e[1]<=r[0])return t[i-1][1]=e[1],t;if(e[1]<=r[1])return t[i-1][1]=Math.max(e[1],r[1]),t.splice(i,1),t;t.splice(i,1),i--}else{if(e[1]<=r[0])return t.splice(i,0,e),t;if(e[1]<=r[1])return r[0]=Math.min(e[0],r[0]),t;e[0]<r[1]&&(r[0]=Math.min(e[0],r[0]),s=!0);continue}}return s?t[t.length-1][1]=e[1]:t.push(e),t}};yo=dt([xe(0,Ot)],yo);function Vb(t){return 57508<=t&&t<=57558}function Gb(t){return 9472<=t&&t<=9631}function qb(t){return Vb(t)||Gb(t)}function Yb(){return{css:{canvas:Or(),cell:Or()},device:{canvas:Or(),cell:Or(),char:{width:0,height:0,left:0,top:0}}}}function Or(){return{width:0,height:0}}var bl=class{constructor(t,e,s,i,r,o,a){this._document=t,this._characterJoinerService=e,this._optionsService=s,this._coreBrowserService=i,this._coreService=r,this._decorationService=o,this._themeService=a,this._workCell=new ss,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(t,e,s){this._selectionStart=t,this._selectionEnd=e,this._columnSelectMode=s}createRow(t,e,s,i,r,o,a,l,c,d,h){let u=[],f=this._characterJoinerService.getJoinedCharacters(e),m=this._themeService.colors,p=t.getNoBgTrimmedLength();s&&p<o+1&&(p=o+1);let g,L=0,v="",y=0,_=0,x=0,b=0,S=!1,w=0,j=!1,N=0,T=0,A=[],k=d!==-1&&h!==-1;for(let C=0;C<p;C++){t.loadCell(C,this._workCell);let I=this._workCell.getWidth();if(I===0)continue;let E=!1,O=C>=T,P=C,D=this._workCell;if(f.length>0&&C===f[0][0]&&O){let Y=f.shift(),Q=this._isCellInSelection(Y[0],e);for(y=Y[0]+1;y<Y[1];y++)O&&=Q===this._isCellInSelection(y,e);O&&=!s||o<Y[0]||o>=Y[1],O?(E=!0,D=new Wb(this._workCell,t.translateToString(!0,Y[0],Y[1]),Y[1]-Y[0]),P=Y[1]-1,I=D.getWidth()):T=Y[1]}let M=this._isCellInSelection(C,e),z=s&&C===o,F=k&&C>=d&&C<=h,$=!1;this._decorationService.forEachDecorationAtCell(C,e,void 0,Y=>{$=!0});let V=D.getChars()||Ys;if(V===" "&&(D.isUnderline()||D.isOverline())&&(V=" "),N=I*l-c.get(V,D.isBold(),D.isItalic()),!g)g=this._document.createElement("span");else if(L&&(M&&j||!M&&!j&&D.bg===_)&&(M&&j&&m.selectionForeground||D.fg===x)&&D.extended.ext===b&&F===S&&N===w&&!z&&!E&&!$&&O){D.isInvisible()?v+=Ys:v+=V,L++;continue}else L&&(g.textContent=v),g=this._document.createElement("span"),L=0,v="";if(_=D.bg,x=D.fg,b=D.extended.ext,S=F,w=N,j=M,E&&o>=C&&o<=P&&(o=C),!this._coreService.isCursorHidden&&z&&this._coreService.isCursorInitialized){if(A.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&A.push("xterm-cursor-blink"),A.push(i==="bar"?"xterm-cursor-bar":i==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":A.push("xterm-cursor-outline");break;case"block":A.push("xterm-cursor-block");break;case"bar":A.push("xterm-cursor-bar");break;case"underline":A.push("xterm-cursor-underline");break}}if(D.isBold()&&A.push("xterm-bold"),D.isItalic()&&A.push("xterm-italic"),D.isDim()&&A.push("xterm-dim"),D.isInvisible()?v=Ys:v=D.getChars()||Ys,D.isUnderline()&&(A.push(`xterm-underline-${D.extended.underlineStyle}`),v===" "&&(v=" "),!D.isUnderlineColorDefault()))if(D.isUnderlineColorRGB())g.style.textDecorationColor=`rgb(${mr.toColorRGB(D.getUnderlineColor()).join(",")})`;else{let Y=D.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&D.isBold()&&Y<8&&(Y+=8),g.style.textDecorationColor=m.ansi[Y].css}D.isOverline()&&(A.push("xterm-overline"),v===" "&&(v=" ")),D.isStrikethrough()&&A.push("xterm-strikethrough"),F&&(g.style.textDecoration="underline");let J=D.getFgColor(),Z=D.getFgColorMode(),G=D.getBgColor(),q=D.getBgColorMode(),H=!!D.isInverse();if(H){let Y=J;J=G,G=Y;let Q=Z;Z=q,q=Q}let K,B,X=!1;this._decorationService.forEachDecorationAtCell(C,e,void 0,Y=>{Y.options.layer!=="top"&&X||(Y.backgroundColorRGB&&(q=50331648,G=Y.backgroundColorRGB.rgba>>8&16777215,K=Y.backgroundColorRGB),Y.foregroundColorRGB&&(Z=50331648,J=Y.foregroundColorRGB.rgba>>8&16777215,B=Y.foregroundColorRGB),X=Y.options.layer==="top")}),!X&&M&&(K=this._coreBrowserService.isFocused?m.selectionBackgroundOpaque:m.selectionInactiveBackgroundOpaque,G=K.rgba>>8&16777215,q=50331648,X=!0,m.selectionForeground&&(Z=50331648,J=m.selectionForeground.rgba>>8&16777215,B=m.selectionForeground)),X&&A.push("xterm-decoration-top");let W;switch(q){case 16777216:case 33554432:W=m.ansi[G],A.push(`xterm-bg-${G}`);break;case 50331648:W=mt.toColor(G>>16,G>>8&255,G&255),this._addStyle(g,`background-color:#${V0((G>>>0).toString(16),"0",6)}`);break;default:H?(W=m.foreground,A.push("xterm-bg-257")):W=m.background}switch(K||D.isDim()&&(K=Qe.multiplyOpacity(W,.5)),Z){case 16777216:case 33554432:D.isBold()&&J<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(J+=8),this._applyMinimumContrast(g,W,m.ansi[J],D,K,void 0)||A.push(`xterm-fg-${J}`);break;case 50331648:let Y=mt.toColor(J>>16&255,J>>8&255,J&255);this._applyMinimumContrast(g,W,Y,D,K,B)||this._addStyle(g,`color:#${V0(J.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(g,W,m.foreground,D,K,B)||H&&A.push("xterm-fg-257")}A.length&&(g.className=A.join(" "),A.length=0),!z&&!E&&!$&&O?L++:g.textContent=v,N!==this.defaultSpacing&&(g.style.letterSpacing=`${N}px`),u.push(g),C=P}return g&&L&&(g.textContent=v),u}_applyMinimumContrast(t,e,s,i,r,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||qb(i.getCode()))return!1;let a=this._getContrastCache(i),l;if(!r&&!o&&(l=a.getColor(e.rgba,s.rgba)),l===void 0){let c=this._optionsService.rawOptions.minimumContrastRatio/(i.isDim()?2:1);l=Qe.ensureContrastRatio(r||e,o||s,c),a.setColor((r||e).rgba,(o||s).rgba,l??null)}return l?(this._addStyle(t,`color:${l.css}`),!0):!1}_getContrastCache(t){return t.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(t,e){t.setAttribute("style",`${t.getAttribute("style")||""}${e};`)}_isCellInSelection(t,e){let s=this._selectionStart,i=this._selectionEnd;return!s||!i?!1:this._columnSelectMode?s[0]<=i[0]?t>=s[0]&&e>=s[1]&&t<i[0]&&e<=i[1]:t<s[0]&&e>=s[1]&&t>=i[0]&&e<=i[1]:e>s[1]&&e<i[1]||s[1]===i[1]&&e===s[1]&&t>=s[0]&&t<i[0]||s[1]<i[1]&&e===i[1]&&t<i[0]||s[1]<i[1]&&e===s[1]&&t>=s[0]}};bl=dt([xe(1,W1),xe(2,Mt),xe(3,zs),xe(4,Bi),xe(5,pr),xe(6,gn)],bl);function V0(t,e,s){for(;t.length<s;)t=e+t;return t}var Jb=class{constructor(t,e){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=t.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=t.createElement("span");s.classList.add("xterm-char-measure-element");let i=t.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontWeight="bold";let r=t.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontStyle="italic";let o=t.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[s,i,r,o],this._container.appendChild(s),this._container.appendChild(i),this._container.appendChild(r),this._container.appendChild(o),e.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(t,e,s,i){t===this._font&&e===this._fontSize&&s===this._weight&&i===this._weightBold||(this._font=t,this._fontSize=e,this._weight=s,this._weightBold=i,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${i}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${i}`,this.clear())}get(t,e,s){let i=0;if(!e&&!s&&t.length===1&&(i=t.charCodeAt(0))<256){if(this._flat[i]!==-9999)return this._flat[i];let a=this._measure(t,0);return a>0&&(this._flat[i]=a),a}let r=t;e&&(r+="B"),s&&(r+="I");let o=this._holey.get(r);if(o===void 0){let a=0;e&&(a|=1),s&&(a|=2),o=this._measure(t,a),o>0&&this._holey.set(r,o)}return o}_measure(t,e){let s=this._measureElements[e];return s.textContent=t.repeat(32),s.offsetWidth/32}},Xb=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(t,e,s,i=!1){if(this.selectionStart=e,this.selectionEnd=s,!e||!s||e[0]===s[0]&&e[1]===s[1]){this.clear();return}let r=t.buffers.active.ydisp,o=e[1]-r,a=s[1]-r,l=Math.max(o,0),c=Math.min(a,t.rows-1);if(l>=t.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=c,this.startCol=e[0],this.endCol=s[0]}isCellSelected(t,e,s){return this.hasSelection?(s-=t.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?e>=this.startCol&&s>=this.viewportCappedStartRow&&e<this.endCol&&s<=this.viewportCappedEndRow:e<this.startCol&&s>=this.viewportCappedStartRow&&e>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&e>=this.startCol&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&e>=this.startCol):!1}};function Zb(){return new Xb}var Na="xterm-dom-renderer-owner-",Jt="xterm-rows",Mr="xterm-fg-",G0="xterm-bg-",wn="xterm-focus",Br="xterm-selection",Qb=1,Sl=class extends ze{constructor(t,e,s,i,r,o,a,l,c,d,h,u,f,m){super(),this._terminal=t,this._document=e,this._element=s,this._screenElement=i,this._viewportElement=r,this._helperContainer=o,this._linkifier2=a,this._charSizeService=c,this._optionsService=d,this._bufferService=h,this._coreService=u,this._coreBrowserService=f,this._themeService=m,this._terminalClass=Qb++,this._rowElements=[],this._selectionRenderModel=Zb(),this.onRequestRedraw=this._register(new ge).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Jt),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Br),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=Yb(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(p=>this._injectCss(p))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(bl,document),this._element.classList.add(Na+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(p=>this._handleLinkHover(p))),this._register(this._linkifier2.onHideLinkUnderline(p=>this._handleLinkLeave(p))),this._register(st(()=>{this._element.classList.remove(Na+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Jb(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let t=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*t,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*t),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/t),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/t),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let e=`${this._terminalSelector} .${Jt} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=e,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(t){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let e=`${this._terminalSelector} .${Jt} { pointer-events: none; color: ${t.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;e+=`${this._terminalSelector} .${Jt} .xterm-dim { color: ${Qe.multiplyOpacity(t.foreground,.5).css};}`,e+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,i=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;e+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,e+=`@keyframes ${i} { 50% { box-shadow: none; }}`,e+=`@keyframes ${r} { 0% { background-color: ${t.cursor.css}; color: ${t.cursorAccent.css}; } 50% { background-color: inherit; color: ${t.cursor.css}; }}`,e+=`${this._terminalSelector} .${Jt}.${wn} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Jt}.${wn} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Jt}.${wn} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Jt} .xterm-cursor.xterm-cursor-block { background-color: ${t.cursor.css}; color: ${t.cursorAccent.css};}${this._terminalSelector} .${Jt} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${t.cursor.css} !important; color: ${t.cursorAccent.css} !important;}${this._terminalSelector} .${Jt} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${t.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Jt} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${t.cursor.css} inset;}${this._terminalSelector} .${Jt} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${t.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,e+=`${this._terminalSelector} .${Br} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Br} div { position: absolute; background-color: ${t.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Br} div { position: absolute; background-color: ${t.selectionInactiveBackgroundOpaque.css};}`;for(let[o,a]of t.ansi.entries())e+=`${this._terminalSelector} .${Mr}${o} { color: ${a.css}; }${this._terminalSelector} .${Mr}${o}.xterm-dim { color: ${Qe.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${G0}${o} { background-color: ${a.css}; }`;e+=`${this._terminalSelector} .${Mr}257 { color: ${Qe.opaque(t.background).css}; }${this._terminalSelector} .${Mr}257.xterm-dim { color: ${Qe.multiplyOpacity(Qe.opaque(t.background),.5).css}; }${this._terminalSelector} .${G0}257 { background-color: ${t.foreground.css}; }`,this._themeStyleElement.textContent=e}_setDefaultSpacing(){let t=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${t}px`,this._rowFactory.defaultSpacing=t}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(t,e){for(let s=this._rowElements.length;s<=e;s++){let i=this._document.createElement("div");this._rowContainer.appendChild(i),this._rowElements.push(i)}for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(t,e){this._refreshRowElements(t,e),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(wn),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(wn),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(t,e,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(t,e,s),this.renderRows(0,this._bufferService.rows-1),!t||!e||(this._selectionRenderModel.update(this._terminal,t,e,s),!this._selectionRenderModel.hasSelection))return;let i=this._selectionRenderModel.viewportStartRow,r=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let c=t[0]>e[0];l.appendChild(this._createSelectionElement(o,c?e[0]:t[0],c?t[0]:e[0],a-o+1))}else{let c=i===o?t[0]:0,d=o===r?e[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,c,d));let h=a-o-1;if(l.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,h)),o!==a){let u=r===a?e[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,u))}}this._selectionContainer.appendChild(l)}_createSelectionElement(t,e,s,i=1){let r=this._document.createElement("div"),o=e*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(s-e);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),r.style.height=`${i*this.dimensions.css.cell.height}px`,r.style.top=`${t*this.dimensions.css.cell.height}px`,r.style.left=`${o}px`,r.style.width=`${a}px`,r}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let t of this._rowElements)t.replaceChildren()}renderRows(t,e){let s=this._bufferService.buffer,i=s.ybase+s.y,r=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=t;c<=e;c++){let d=c+s.ydisp,h=this._rowElements[c],u=s.lines.get(d);if(!h||!u)break;h.replaceChildren(...this._rowFactory.createRow(u,d,d===i,a,l,r,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Na}${this._terminalClass}`}_handleLinkHover(t){this._setCellUnderline(t.x1,t.x2,t.y1,t.y2,t.cols,!0)}_handleLinkLeave(t){this._setCellUnderline(t.x1,t.x2,t.y1,t.y2,t.cols,!1)}_setCellUnderline(t,e,s,i,r,o){s<0&&(t=0),i<0&&(e=0);let a=this._bufferService.rows-1;s=Math.max(Math.min(s,a),0),i=Math.max(Math.min(i,a),0),r=Math.min(r,this._bufferService.cols);let l=this._bufferService.buffer,c=l.ybase+l.y,d=Math.min(l.x,r-1),h=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let m=s;m<=i;++m){let p=m+l.ydisp,g=this._rowElements[m],L=l.lines.get(p);if(!g||!L)break;g.replaceChildren(...this._rowFactory.createRow(L,p,p===c,u,f,d,h,this.dimensions.css.cell.width,this._widthCache,o?m===s?t:0:-1,o?(m===i?e:r)-1:-1))}}};Sl=dt([xe(7,Wc),xe(8,Xo),xe(9,Mt),xe(10,Ot),xe(11,Bi),xe(12,zs),xe(13,gn)],Sl);var wl=class extends ze{constructor(t,e,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new ge),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new tS(this._optionsService))}catch{this._measureStrategy=this._register(new eS(t,e,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let t=this._measureStrategy.measure();(t.width!==this.width||t.height!==this.height)&&(this.width=t.width,this.height=t.height,this._onCharSizeChange.fire())}};wl=dt([xe(2,Mt)],wl);var hf=class extends ze{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(t,e){t!==void 0&&t>0&&e!==void 0&&e>0&&(this._result.width=t,this._result.height=e)}},eS=class extends hf{constructor(t,e,s){super(),this._document=t,this._parentElement=e,this._optionsService=s,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},tS=class extends hf{constructor(t){super(),this._optionsService=t,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let e=this._ctx.measureText("W");if(!("width"in e&&"fontBoundingBoxAscent"in e&&"fontBoundingBoxDescent"in e))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let t=this._ctx.measureText("W");return this._validateAndSet(t.width,t.fontBoundingBoxAscent+t.fontBoundingBoxDescent),this._result}},sS=class extends ze{constructor(t,e,s){super(),this._textarea=t,this._window=e,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new iS(this._window)),this._onDprChange=this._register(new ge),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new ge),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(i=>this._screenDprMonitor.setWindow(i))),this._register(Ct.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(ke(this._textarea,"focus",()=>this._isFocused=!0)),this._register(ke(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(t){this._window!==t&&(this._window=t,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},iS=class extends ze{constructor(t){super(),this._parentWindow=t,this._windowResizeListener=this._register(new on),this._onDprChange=this._register(new ge),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(st(()=>this.clearListener()))}setWindow(t){this._parentWindow=t,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=ke(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},nS=class extends ze{constructor(){super(),this.linkProviders=[],this._register(st(()=>this.linkProviders.length=0))}registerLinkProvider(t){return this.linkProviders.push(t),{dispose:()=>{let e=this.linkProviders.indexOf(t);e!==-1&&this.linkProviders.splice(e,1)}}}};function Qc(t,e,s){let i=s.getBoundingClientRect(),r=t.getComputedStyle(s),o=parseInt(r.getPropertyValue("padding-left")),a=parseInt(r.getPropertyValue("padding-top"));return[e.clientX-i.left-o,e.clientY-i.top-a]}function rS(t,e,s,i,r,o,a,l,c){if(!o)return;let d=Qc(t,e,s);if(d)return d[0]=Math.ceil((d[0]+(c?a/2:0))/a),d[1]=Math.ceil(d[1]/l),d[0]=Math.min(Math.max(d[0],1),i+(c?1:0)),d[1]=Math.min(Math.max(d[1],1),r),d}var Cl=class{constructor(t,e){this._renderService=t,this._charSizeService=e}getCoords(t,e,s,i,r){return rS(window,t,e,s,i,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(t,e){let s=Qc(window,t,e);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};Cl=dt([xe(0,Fs),xe(1,Xo)],Cl);var oS=class{constructor(t,e){this._renderCallback=t,this._coreBrowserService=e,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(t){return this._refreshCallbacks.push(t),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(t,e,s){this._rowCount=s,t=t!==void 0?t:0,e=e!==void 0?e:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,t):t,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,e):e,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let t=Math.max(this._rowStart,0),e=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(t,e),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let t of this._refreshCallbacks)t(0);this._refreshCallbacks=[]}},uf={};gy(uf,{getSafariVersion:()=>lS,isChromeOS:()=>gf,isFirefox:()=>ff,isIpad:()=>cS,isIphone:()=>dS,isLegacyEdge:()=>aS,isLinux:()=>e9,isMac:()=>bo,isNode:()=>Zo,isSafari:()=>mf,isWindows:()=>pf});var Zo=typeof process<"u"&&"title"in process,gr=Zo?"node":navigator.userAgent,_r=Zo?"node":navigator.platform,ff=gr.includes("Firefox"),aS=gr.includes("Edge"),mf=/^((?!chrome|android).)*safari/i.test(gr);function lS(){if(!mf)return 0;let t=gr.match(/Version\/(\d+)/);return t===null||t.length<2?0:parseInt(t[1])}var bo=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(_r),cS=_r==="iPad",dS=_r==="iPhone",pf=["Windows","Win16","Win32","WinCE"].includes(_r),e9=_r.indexOf("Linux")>=0,gf=/\bCrOS\b/.test(gr),_f=class{constructor(){this._tasks=[],this._i=0}enqueue(t){this._tasks.push(t),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(t){this._idleCallback=void 0;let e=0,s=0,i=t.timeRemaining(),r=0;for(;this._i<this._tasks.length;){if(e=performance.now(),this._tasks[this._i]()||this._i++,e=Math.max(1,performance.now()-e),s=Math.max(e,s),r=t.timeRemaining(),s*1.5>r){i-e<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-e))}ms`),this._start();return}i=r}this.clear()}},hS=class extends _f{_requestCallback(t){return setTimeout(()=>t(this._createDeadline(16)))}_cancelCallback(t){clearTimeout(t)}_createDeadline(t){let e=performance.now()+t;return{timeRemaining:()=>Math.max(0,e-performance.now())}}},uS=class extends _f{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},So=!Zo&&"requestIdleCallback"in window?uS:hS,fS=class{constructor(){this._queue=new So}set(t){this._queue.clear(),this._queue.enqueue(t)}flush(){this._queue.flush()}},jl=class extends ze{constructor(t,e,s,i,r,o,a,l,c){super(),this._rowCount=t,this._optionsService=s,this._charSizeService=i,this._coreService=r,this._coreBrowserService=l,this._renderer=this._register(new on),this._pausedResizeTask=new fS,this._observerDisposable=this._register(new on),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new ge),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new ge),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new ge),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new ge),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new oS((d,h)=>this._renderRows(d,h),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new mS(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(st(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,e),this._register(this._coreBrowserService.onWindowChange(d=>this._registerIntersectionObserver(d,e)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(t,e){if("IntersectionObserver"in t){let s=new t.IntersectionObserver(i=>this._handleIntersectionChange(i[i.length-1]),{threshold:0});s.observe(e),this._observerDisposable.value=st(()=>s.disconnect())}}_handleIntersectionChange(t){this._isPaused=t.isIntersecting===void 0?t.intersectionRatio===0:!t.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(t,e,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(t,e);return}let i=this._syncOutputHandler.flush();i&&(t=Math.min(t,i.start),e=Math.max(e,i.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(t,e,this._rowCount)}_renderRows(t,e){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(t,e);return}t=Math.min(t,this._rowCount-1),e=Math.min(e,this._rowCount-1),this._renderer.value.renderRows(t,e),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:t,end:e}),this._onRender.fire({start:t,end:e}),this._isNextRenderRedrawOnly=!0}}resize(t,e){this._rowCount=e,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(t){this._renderer.value=t,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(t){return this._renderDebouncer.addRefreshCallback(t)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(t,e){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(t,e)):this._renderer.value.handleResize(t,e),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(t,e,s){this._selectionState.start=t,this._selectionState.end=e,this._selectionState.columnSelectMode=s,this._renderer.value?.handleSelectionChanged(t,e,s)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};jl=dt([xe(2,Mt),xe(3,Xo),xe(4,Bi),xe(5,pr),xe(6,Ot),xe(7,zs),xe(8,gn)],jl);var mS=class{constructor(t,e,s){this._coreBrowserService=t,this._coreService=e,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(t,e){this._isBuffering?(this._start=Math.min(this._start,t),this._end=Math.max(this._end,e)):(this._start=t,this._end=e,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let t={start:this._start,end:this._end};return this._isBuffering=!1,t}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function pS(t,e,s,i){let r=s.buffer.x,o=s.buffer.y;if(!s.buffer.hasScrollback)return LS(r,o,t,e,s,i)+Qo(o,e,s,i)+vS(r,o,t,e,s,i);let a;if(o===e)return a=r>t?"D":"C",sr(Math.abs(r-t),tr(a,i));a=o>e?"D":"C";let l=Math.abs(o-e),c=_S(o>e?t:r,s)+(l-1)*s.cols+1+gS(o>e?r:t);return sr(c,tr(a,i))}function gS(t,e){return t-1}function _S(t,e){return e.cols-t}function LS(t,e,s,i,r,o){return Qo(e,i,r,o).length===0?"":sr(vf(t,e,t,e-ki(e,r),!1,r).length,tr("D",o))}function Qo(t,e,s,i){let r=t-ki(t,s),o=e-ki(e,s),a=Math.abs(r-o)-xS(t,e,s);return sr(a,tr(Lf(t,e),i))}function vS(t,e,s,i,r,o){let a;Qo(e,i,r,o).length>0?a=i-ki(i,r):a=e;let l=i,c=yS(t,e,s,i,r,o);return sr(vf(t,a,s,l,c==="C",r).length,tr(c,o))}function xS(t,e,s){let i=0,r=t-ki(t,s),o=e-ki(e,s);for(let a=0;a<Math.abs(r-o);a++){let l=Lf(t,e)==="A"?-1:1;s.buffer.lines.get(r+l*a)?.isWrapped&&i++}return i}function ki(t,e){let s=0,i=e.buffer.lines.get(t),r=i?.isWrapped;for(;r&&t>=0&&t<e.rows;)s++,i=e.buffer.lines.get(--t),r=i?.isWrapped;return s}function yS(t,e,s,i,r,o){let a;return Qo(s,i,r,o).length>0?a=i-ki(i,r):a=e,t<s&&a<=i||t>=s&&a<i?"C":"D"}function Lf(t,e){return t>e?"A":"B"}function vf(t,e,s,i,r,o){let a=t,l=e,c="";for(;(a!==s||l!==i)&&l>=0&&l<o.buffer.lines.length;)a+=r?1:-1,r&&a>o.cols-1?(c+=o.buffer.translateBufferLineToString(l,!1,t,a),a=0,t=0,l++):!r&&a<0&&(c+=o.buffer.translateBufferLineToString(l,!1,0,t+1),a=o.cols-1,t=a,l--);return c+o.buffer.translateBufferLineToString(l,!1,t,a)}function tr(t,e){let s=e?"O":"[";return de.ESC+s+t}function sr(t,e){t=Math.floor(t);let s="";for(let i=0;i<t;i++)s+=e;return s}var bS=class{constructor(t){this._bufferService=t,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?t%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)-1]:[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[t,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[Math.max(t,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let t=this.selectionStart,e=this.selectionEnd;return!t||!e?!1:t[1]>e[1]||t[1]===e[1]&&t[0]>e[0]}handleTrim(t){return this.selectionStart&&(this.selectionStart[1]-=t),this.selectionEnd&&(this.selectionEnd[1]-=t),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function q0(t,e){if(t.start.y>t.end.y)throw new Error(`Buffer range end (${t.end.x}, ${t.end.y}) cannot be before start (${t.start.x}, ${t.start.y})`);return e*(t.end.y-t.start.y)+(t.end.x-t.start.x+1)}var Ta=50,SS=15,wS=50,CS=500,jS=" ",kS=new RegExp(jS,"g"),kl=class extends ze{constructor(t,e,s,i,r,o,a,l,c){super(),this._element=t,this._screenElement=e,this._linkifier=s,this._bufferService=i,this._coreService=r,this._mouseService=o,this._optionsService=a,this._renderService=l,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new ss,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new ge),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new ge),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new ge),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new ge),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=d=>this._handleMouseMove(d),this._mouseUpListener=d=>this._handleMouseUp(d),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(d=>this._handleTrim(d)),this._register(this._bufferService.buffers.onBufferActivate(d=>this._handleBufferActivate(d))),this.enable(),this._model=new bS(this._bufferService),this._activeSelectionMode=0,this._register(st(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(d=>{d.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let t=this._model.finalSelectionStart,e=this._model.finalSelectionEnd;return!t||!e?!1:t[0]!==e[0]||t[1]!==e[1]}get selectionText(){let t=this._model.finalSelectionStart,e=this._model.finalSelectionEnd;if(!t||!e)return"";let s=this._bufferService.buffer,i=[];if(this._activeSelectionMode===3){if(t[0]===e[0])return"";let r=t[0]<e[0]?t[0]:e[0],o=t[0]<e[0]?e[0]:t[0];for(let a=t[1];a<=e[1];a++){let l=s.translateBufferLineToString(a,!0,r,o);i.push(l)}}else{let r=t[1]===e[1]?e[0]:void 0;i.push(s.translateBufferLineToString(t[1],!0,t[0],r));for(let o=t[1]+1;o<=e[1]-1;o++){let a=s.lines.get(o),l=s.translateBufferLineToString(o,!0);a?.isWrapped?i[i.length-1]+=l:i.push(l)}if(t[1]!==e[1]){let o=s.lines.get(e[1]),a=s.translateBufferLineToString(e[1],!0,0,e[0]);o&&o.isWrapped?i[i.length-1]+=a:i.push(a)}}return i.map(r=>r.replace(kS," ")).join(pf?`\r
|
|
507
|
-
`:`
|
|
508
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(t){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),e9&&t&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(t){let e=this._getMouseBufferCoords(t),s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i||!e?!1:this._areCoordsInSelection(e,s,i)}isCellInSelection(t,e){let s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i?!1:this._areCoordsInSelection([t,e],s,i)}_areCoordsInSelection(t,e,s){return t[1]>e[1]&&t[1]<s[1]||e[1]===s[1]&&t[1]===e[1]&&t[0]>=e[0]&&t[0]<s[0]||e[1]<s[1]&&t[1]===s[1]&&t[0]<s[0]||e[1]<s[1]&&t[1]===e[1]&&t[0]>=e[0]}_selectWordAtCursor(t,e){let s=this._linkifier.currentLink?.link?.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=q0(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let i=this._getMouseBufferCoords(t);return i?(this._selectWordAt(i,e),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(t,e){this._model.clearSelection(),t=Math.max(t,0),e=Math.min(e,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,t],this._model.selectionEnd=[this._bufferService.cols,e],this.refresh(),this._onSelectionChange.fire()}_handleTrim(t){this._model.handleTrim(t)&&this.refresh()}_getMouseBufferCoords(t){let e=this._mouseService.getCoords(t,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(e)return e[0]--,e[1]--,e[1]+=this._bufferService.buffer.ydisp,e}_getMouseEventScrollAmount(t){let e=Qc(this._coreBrowserService.window,t,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return e>=0&&e<=s?0:(e>s&&(e-=s),e=Math.min(Math.max(e,-Ta),Ta),e/=Ta,e/Math.abs(e)+Math.round(e*(SS-1)))}shouldForceSelection(t){return bo?t.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:t.shiftKey}handleMouseDown(t){if(this._mouseDownTimeStamp=t.timeStamp,!(t.button===2&&this.hasSelection)&&t.button===0){if(!this._enabled){if(!this.shouldForceSelection(t))return;t.stopPropagation()}t.preventDefault(),this._dragScrollAmount=0,this._enabled&&t.shiftKey?this._handleIncrementalClick(t):t.detail===1?this._handleSingleClick(t):t.detail===2?this._handleDoubleClick(t):t.detail===3&&this._handleTripleClick(t),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),wS)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(t){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(t))}_handleSingleClick(t){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(t)?3:0,this._model.selectionStart=this._getMouseBufferCoords(t),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let e=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);e&&e.length!==this._model.selectionStart[0]&&e.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(t){this._selectWordAtCursor(t,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(t){let e=this._getMouseBufferCoords(t);e&&(this._activeSelectionMode=2,this._selectLineAt(e[1]))}shouldColumnSelect(t){return t.altKey&&!(bo&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(t){if(t.stopImmediatePropagation(),!this._model.selectionStart)return;let e=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(t),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(t),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let i=s.lines.get(this._model.selectionEnd[1]);i&&i.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!e||e[0]!==this._model.selectionEnd[0]||e[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let t=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(t.ydisp+this._bufferService.rows,t.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=t.ydisp),this.refresh()}}_handleMouseUp(t){let e=t.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&e<CS&&t.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let s=this._mouseService.getCoords(t,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(s&&s[0]!==void 0&&s[1]!==void 0){let i=pS(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(i,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let t=this._model.finalSelectionStart,e=this._model.finalSelectionEnd,s=!!t&&!!e&&(t[0]!==e[0]||t[1]!==e[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(t,e,s);return}!t||!e||(!this._oldSelectionStart||!this._oldSelectionEnd||t[0]!==this._oldSelectionStart[0]||t[1]!==this._oldSelectionStart[1]||e[0]!==this._oldSelectionEnd[0]||e[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(t,e,s)}_fireOnSelectionChange(t,e,s){this._oldSelectionStart=t,this._oldSelectionEnd=e,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(t){this.clearSelection(),this._trimListener.dispose(),this._trimListener=t.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(t,e){let s=e;for(let i=0;e>=i;i++){let r=t.loadCell(i,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:r>1&&e!==i&&(s+=r-1)}return s}setSelection(t,e,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[t,e],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(t){this._isClickInSelection(t)||(this._selectWordAtCursor(t,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(t,e,s=!0,i=!0){if(t[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,o=r.lines.get(t[1]);if(!o)return;let a=r.translateBufferLineToString(t[1],!1),l=this._convertViewportColToCharacterIndex(o,t[0]),c=l,d=t[0]-l,h=0,u=0,f=0,m=0;if(a.charAt(l)===" "){for(;l>0&&a.charAt(l-1)===" ";)l--;for(;c<a.length&&a.charAt(c+1)===" ";)c++}else{let L=t[0],v=t[0];o.getWidth(L)===0&&(h++,L--),o.getWidth(v)===2&&(u++,v++);let y=o.getString(v).length;for(y>1&&(m+=y-1,c+=y-1);L>0&&l>0&&!this._isCharWordSeparator(o.loadCell(L-1,this._workCell));){o.loadCell(L-1,this._workCell);let _=this._workCell.getChars().length;this._workCell.getWidth()===0?(h++,L--):_>1&&(f+=_-1,l-=_-1),l--,L--}for(;v<o.length&&c+1<a.length&&!this._isCharWordSeparator(o.loadCell(v+1,this._workCell));){o.loadCell(v+1,this._workCell);let _=this._workCell.getChars().length;this._workCell.getWidth()===2?(u++,v++):_>1&&(m+=_-1,c+=_-1),c++,v++}}c++;let p=l+d-h+f,g=Math.min(this._bufferService.cols,c-l+h+u-f-m);if(!(!e&&a.slice(l,c).trim()==="")){if(s&&p===0&&o.getCodePoint(0)!==32){let L=r.lines.get(t[1]-1);if(L&&o.isWrapped&&L.getCodePoint(this._bufferService.cols-1)!==32){let v=this._getWordAt([this._bufferService.cols-1,t[1]-1],!1,!0,!1);if(v){let y=this._bufferService.cols-v.start;p-=y,g+=y}}}if(i&&p+g===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let L=r.lines.get(t[1]+1);if(L?.isWrapped&&L.getCodePoint(0)!==32){let v=this._getWordAt([0,t[1]+1],!1,!1,!0);v&&(g+=v.length)}}return{start:p,length:g}}}_selectWordAt(t,e){let s=this._getWordAt(t,e);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,t[1]--;this._model.selectionStart=[s.start,t[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(t){let e=this._getWordAt(t,!0);if(e){let s=t[1];for(;e.start<0;)e.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;e.start+e.length>this._bufferService.cols;)e.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?e.start:e.start+e.length,s]}}_isCharWordSeparator(t){return t.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(t.getChars())>=0}_selectLineAt(t){let e=this._bufferService.buffer.getWrappedRangeForLine(t),s={start:{x:0,y:e.first},end:{x:this._bufferService.cols-1,y:e.last}};this._model.selectionStart=[0,e.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=q0(s,this._bufferService.cols)}};kl=dt([xe(3,Ot),xe(4,Bi),xe(5,Vc),xe(6,Mt),xe(7,Fs),xe(8,zs)],kl);var Y0=class{constructor(){this._data={}}set(t,e,s){this._data[t]||(this._data[t]={}),this._data[t][e]=s}get(t,e){return this._data[t]?this._data[t][e]:void 0}clear(){this._data={}}},J0=class{constructor(){this._color=new Y0,this._css=new Y0}setCss(t,e,s){this._css.set(t,e,s)}getCss(t,e){return this._css.get(t,e)}setColor(t,e,s){this._color.set(t,e,s)}getColor(t,e){return this._color.get(t,e)}clear(){this._color.clear(),this._css.clear()}},pt=Object.freeze((()=>{let t=[rt.toColor("#2e3436"),rt.toColor("#cc0000"),rt.toColor("#4e9a06"),rt.toColor("#c4a000"),rt.toColor("#3465a4"),rt.toColor("#75507b"),rt.toColor("#06989a"),rt.toColor("#d3d7cf"),rt.toColor("#555753"),rt.toColor("#ef2929"),rt.toColor("#8ae234"),rt.toColor("#fce94f"),rt.toColor("#729fcf"),rt.toColor("#ad7fa8"),rt.toColor("#34e2e2"),rt.toColor("#eeeeec")],e=[0,95,135,175,215,255];for(let s=0;s<216;s++){let i=e[s/36%6|0],r=e[s/6%6|0],o=e[s%6];t.push({css:mt.toCss(i,r,o),rgba:mt.toRgba(i,r,o)})}for(let s=0;s<24;s++){let i=8+s*10;t.push({css:mt.toCss(i,i,i),rgba:mt.toRgba(i,i,i)})}return t})()),ui=rt.toColor("#ffffff"),On=rt.toColor("#000000"),X0=rt.toColor("#ffffff"),Z0=On,Cn={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},NS=ui,Nl=class extends ze{constructor(t){super(),this._optionsService=t,this._contrastCache=new J0,this._halfContrastCache=new J0,this._onChangeColors=this._register(new ge),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:ui,background:On,cursor:X0,cursorAccent:Z0,selectionForeground:void 0,selectionBackgroundTransparent:Cn,selectionBackgroundOpaque:Qe.blend(On,Cn),selectionInactiveBackgroundTransparent:Cn,selectionInactiveBackgroundOpaque:Qe.blend(On,Cn),scrollbarSliderBackground:Qe.opacity(ui,.2),scrollbarSliderHoverBackground:Qe.opacity(ui,.4),scrollbarSliderActiveBackground:Qe.opacity(ui,.5),overviewRulerBorder:ui,ansi:pt.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(t={}){let e=this._colors;if(e.foreground=Xe(t.foreground,ui),e.background=Xe(t.background,On),e.cursor=Qe.blend(e.background,Xe(t.cursor,X0)),e.cursorAccent=Qe.blend(e.background,Xe(t.cursorAccent,Z0)),e.selectionBackgroundTransparent=Xe(t.selectionBackground,Cn),e.selectionBackgroundOpaque=Qe.blend(e.background,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundTransparent=Xe(t.selectionInactiveBackground,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundOpaque=Qe.blend(e.background,e.selectionInactiveBackgroundTransparent),e.selectionForeground=t.selectionForeground?Xe(t.selectionForeground,W0):void 0,e.selectionForeground===W0&&(e.selectionForeground=void 0),Qe.isOpaque(e.selectionBackgroundTransparent)&&(e.selectionBackgroundTransparent=Qe.opacity(e.selectionBackgroundTransparent,.3)),Qe.isOpaque(e.selectionInactiveBackgroundTransparent)&&(e.selectionInactiveBackgroundTransparent=Qe.opacity(e.selectionInactiveBackgroundTransparent,.3)),e.scrollbarSliderBackground=Xe(t.scrollbarSliderBackground,Qe.opacity(e.foreground,.2)),e.scrollbarSliderHoverBackground=Xe(t.scrollbarSliderHoverBackground,Qe.opacity(e.foreground,.4)),e.scrollbarSliderActiveBackground=Xe(t.scrollbarSliderActiveBackground,Qe.opacity(e.foreground,.5)),e.overviewRulerBorder=Xe(t.overviewRulerBorder,NS),e.ansi=pt.slice(),e.ansi[0]=Xe(t.black,pt[0]),e.ansi[1]=Xe(t.red,pt[1]),e.ansi[2]=Xe(t.green,pt[2]),e.ansi[3]=Xe(t.yellow,pt[3]),e.ansi[4]=Xe(t.blue,pt[4]),e.ansi[5]=Xe(t.magenta,pt[5]),e.ansi[6]=Xe(t.cyan,pt[6]),e.ansi[7]=Xe(t.white,pt[7]),e.ansi[8]=Xe(t.brightBlack,pt[8]),e.ansi[9]=Xe(t.brightRed,pt[9]),e.ansi[10]=Xe(t.brightGreen,pt[10]),e.ansi[11]=Xe(t.brightYellow,pt[11]),e.ansi[12]=Xe(t.brightBlue,pt[12]),e.ansi[13]=Xe(t.brightMagenta,pt[13]),e.ansi[14]=Xe(t.brightCyan,pt[14]),e.ansi[15]=Xe(t.brightWhite,pt[15]),t.extendedAnsi){let s=Math.min(e.ansi.length-16,t.extendedAnsi.length);for(let i=0;i<s;i++)e.ansi[i+16]=Xe(t.extendedAnsi[i],pt[i+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(t){this._restoreColor(t),this._onChangeColors.fire(this.colors)}_restoreColor(t){if(t===void 0){for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];return}switch(t){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[t]=this._restoreColors.ansi[t]}}modifyColors(t){t(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};Nl=dt([xe(0,Mt)],Nl);function Xe(t,e){if(t!==void 0)try{return rt.toColor(t)}catch{}return e}var TS=class{constructor(...t){this._entries=new Map;for(let[e,s]of t)this.set(e,s)}set(t,e){let s=this._entries.get(t);return this._entries.set(t,e),s}forEach(t){for(let[e,s]of this._entries.entries())t(e,s)}has(t){return this._entries.has(t)}get(t){return this._entries.get(t)}},ES=class{constructor(){this._services=new TS,this._services.set(Wc,this)}setService(t,e){this._services.set(t,e)}getService(t){return this._services.get(t)}createInstance(t,...e){let s=Sy(t).sort((o,a)=>o.index-a.index),i=[];for(let o of s){let a=this._services.get(o.id);if(!a)throw new Error(`[createInstance] ${t.name} depends on UNKNOWN service ${o.id._id}.`);i.push(a)}let r=s.length>0?s[0].index:e.length;if(e.length!==r)throw new Error(`[createInstance] First service dependency of ${t.name} at position ${r+1} conflicts with ${e.length} static arguments`);return new t(...e,...i)}},AS={trace:0,debug:1,info:2,warn:3,error:4,off:5},PS="xterm.js: ",Tl=class extends ze{constructor(t){super(),this._optionsService=t,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=AS[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(t){for(let e=0;e<t.length;e++)typeof t[e]=="function"&&(t[e]=t[e]())}_log(t,e,s){this._evalLazyOptionalParams(s),t.call(console,(this._optionsService.options.logger?"":PS)+e,...s)}trace(t,...e){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,t,e)}debug(t,...e){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,t,e)}info(t,...e){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,t,e)}warn(t,...e){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,t,e)}error(t,...e){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,t,e)}};Tl=dt([xe(0,Mt)],Tl);var Q0=class extends ze{constructor(t){super(),this._maxLength=t,this.onDeleteEmitter=this._register(new ge),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new ge),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new ge),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(t){if(this._maxLength===t)return;let e=new Array(t);for(let s=0;s<Math.min(t,this.length);s++)e[s]=this._array[this._getCyclicIndex(s)];this._array=e,this._maxLength=t,this._startIndex=0}get length(){return this._length}set length(t){if(t>this._length)for(let e=this._length;e<t;e++)this._array[e]=void 0;this._length=t}get(t){return this._array[this._getCyclicIndex(t)]}set(t,e){this._array[this._getCyclicIndex(t)]=e}push(t){this._array[this._getCyclicIndex(this._length)]=t,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(t,e,...s){if(e){for(let i=t;i<this._length-e;i++)this._array[this._getCyclicIndex(i)]=this._array[this._getCyclicIndex(i+e)];this._length-=e,this.onDeleteEmitter.fire({index:t,amount:e})}for(let i=this._length-1;i>=t;i--)this._array[this._getCyclicIndex(i+s.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<s.length;i++)this._array[this._getCyclicIndex(t+i)]=s[i];if(s.length&&this.onInsertEmitter.fire({index:t,amount:s.length}),this._length+s.length>this._maxLength){let i=this._length+s.length-this._maxLength;this._startIndex+=i,this._length=this._maxLength,this.onTrimEmitter.fire(i)}else this._length+=s.length}trimStart(t){t>this._length&&(t=this._length),this._startIndex+=t,this._length-=t,this.onTrimEmitter.fire(t)}shiftElements(t,e,s){if(!(e<=0)){if(t<0||t>=this._length)throw new Error("start argument out of range");if(t+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let r=e-1;r>=0;r--)this.set(t+r+s,this.get(t+r));let i=t+e+s-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i<e;i++)this.set(t+i+s,this.get(t+i))}}_getCyclicIndex(t){return(this._startIndex+t)%this._maxLength}},$e=3,ft=Object.freeze(new mr),$r=0,Ea=2,Mn=class xf{constructor(e,s,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*$e);let r=s||ss.fromCharData([0,B1,1,0]);for(let o=0;o<e;++o)this.setCell(o,r);this.length=e}get(e){let s=this._data[e*$e+0],i=s&2097151;return[this._data[e*$e+1],s&2097152?this._combined[e]:i?Gs(i):"",s>>22,s&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):i]}set(e,s){this._data[e*$e+1]=s[0],s[1].length>1?(this._combined[e]=s[1],this._data[e*$e+0]=e|2097152|s[2]<<22):this._data[e*$e+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(e){return this._data[e*$e+0]>>22}hasWidth(e){return this._data[e*$e+0]&12582912}getFg(e){return this._data[e*$e+1]}getBg(e){return this._data[e*$e+2]}hasContent(e){return this._data[e*$e+0]&4194303}getCodePoint(e){let s=this._data[e*$e+0];return s&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):s&2097151}isCombined(e){return this._data[e*$e+0]&2097152}getString(e){let s=this._data[e*$e+0];return s&2097152?this._combined[e]:s&2097151?Gs(s&2097151):""}isProtected(e){return this._data[e*$e+2]&536870912}loadCell(e,s){return $r=e*$e,s.content=this._data[$r+0],s.fg=this._data[$r+1],s.bg=this._data[$r+2],s.content&2097152&&(s.combinedData=this._combined[e]),s.bg&268435456&&(s.extended=this._extendedAttrs[e]),s}setCell(e,s){s.content&2097152&&(this._combined[e]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[e]=s.extended),this._data[e*$e+0]=s.content,this._data[e*$e+1]=s.fg,this._data[e*$e+2]=s.bg}setCellFromCodepoint(e,s,i,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*$e+0]=s|i<<22,this._data[e*$e+1]=r.fg,this._data[e*$e+2]=r.bg}addCodepointToCell(e,s,i){let r=this._data[e*$e+0];r&2097152?this._combined[e]+=Gs(s):r&2097151?(this._combined[e]=Gs(r&2097151)+Gs(s),r&=-2097152,r|=2097152):r=s|1<<22,i&&(r&=-12582913,r|=i<<22),this._data[e*$e+0]=r}insertCells(e,s,i){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,i),s<this.length-e){let r=new ss;for(let o=this.length-e-s-1;o>=0;--o)this.setCell(e+s+o,this.loadCell(e+o,r));for(let o=0;o<s;++o)this.setCell(e+o,i)}else for(let r=e;r<this.length;++r)this.setCell(r,i);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,i)}deleteCells(e,s,i){if(e%=this.length,s<this.length-e){let r=new ss;for(let o=0;o<this.length-e-s;++o)this.setCell(e+o,this.loadCell(e+s+o,r));for(let o=this.length-s;o<this.length;++o)this.setCell(o,i)}else for(let r=e;r<this.length;++r)this.setCell(r,i);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,i),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,i)}replaceCells(e,s,i,r=!1){if(r){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&!this.isProtected(s)&&this.setCellFromCodepoint(s,0,1,i);e<s&&e<this.length;)this.isProtected(e)||this.setCell(e,i),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s,0,1,i);e<s&&e<this.length;)this.setCell(e++,i)}resize(e,s){if(e===this.length)return this._data.length*4*Ea<this._data.buffer.byteLength;let i=e*$e;if(e>this.length){if(this._data.buffer.byteLength>=i*4)this._data=new Uint32Array(this._data.buffer,0,i);else{let r=new Uint32Array(i);r.set(this._data),this._data=r}for(let r=this.length;r<e;++r)this.setCell(r,s)}else{this._data=this._data.subarray(0,i);let r=Object.keys(this._combined);for(let a=0;a<r.length;a++){let l=parseInt(r[a],10);l>=e&&delete this._combined[l]}let o=Object.keys(this._extendedAttrs);for(let a=0;a<o.length;a++){let l=parseInt(o[a],10);l>=e&&delete this._extendedAttrs[l]}}return this.length=e,i*4*Ea<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Ea<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,s=!1){if(s){for(let i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,e);return}this._combined={},this._extendedAttrs={};for(let i=0;i<this.length;++i)this.setCell(i,e)}copyFrom(e){this.length!==e.length?this._data=new Uint32Array(e._data):this._data.set(e._data),this.length=e.length,this._combined={};for(let s in e._combined)this._combined[s]=e._combined[s];this._extendedAttrs={};for(let s in e._extendedAttrs)this._extendedAttrs[s]=e._extendedAttrs[s];this.isWrapped=e.isWrapped}clone(){let e=new xf(0);e._data=new Uint32Array(this._data),e.length=this.length;for(let s in this._combined)e._combined[s]=this._combined[s];for(let s in this._extendedAttrs)e._extendedAttrs[s]=this._extendedAttrs[s];return e.isWrapped=this.isWrapped,e}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*$e+0]&4194303)return e+(this._data[e*$e+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*$e+0]&4194303||this._data[e*$e+2]&50331648)return e+(this._data[e*$e+0]>>22);return 0}copyCellsFrom(e,s,i,r,o){let a=e._data;if(o)for(let c=r-1;c>=0;c--){for(let d=0;d<$e;d++)this._data[(i+c)*$e+d]=a[(s+c)*$e+d];a[(s+c)*$e+2]&268435456&&(this._extendedAttrs[i+c]=e._extendedAttrs[s+c])}else for(let c=0;c<r;c++){for(let d=0;d<$e;d++)this._data[(i+c)*$e+d]=a[(s+c)*$e+d];a[(s+c)*$e+2]&268435456&&(this._extendedAttrs[i+c]=e._extendedAttrs[s+c])}let l=Object.keys(e._combined);for(let c=0;c<l.length;c++){let d=parseInt(l[c],10);d>=s&&(this._combined[d-s+i]=e._combined[d])}}translateToString(e,s,i,r){s=s??0,i=i??this.length,e&&(i=Math.min(i,this.getTrimmedLength())),r&&(r.length=0);let o="";for(;s<i;){let a=this._data[s*$e+0],l=a&2097151,c=a&2097152?this._combined[s]:l?Gs(l):Ys;if(o+=c,r)for(let d=0;d<c.length;++d)r.push(s);s+=a>>22||1}return r&&r.push(s),o}};function RS(t,e,s,i,r,o){let a=[];for(let l=0;l<t.length-1;l++){let c=l,d=t.get(++c);if(!d.isWrapped)continue;let h=[t.get(l)];for(;c<t.length&&d.isWrapped;)h.push(d),d=t.get(++c);if(!o&&i>=l&&i<c){l+=h.length-1;continue}let u=0,f=ir(h,u,e),m=1,p=0;for(;m<h.length;){let L=ir(h,m,e),v=L-p,y=s-f,_=Math.min(v,y);h[u].copyCellsFrom(h[m],p,f,_,!1),f+=_,f===s&&(u++,f=0),p+=_,p===L&&(m++,p=0),f===0&&u!==0&&h[u-1].getWidth(s-1)===2&&(h[u].copyCellsFrom(h[u-1],s-1,f++,1,!1),h[u-1].setCell(s-1,r))}h[u].replaceCells(f,s,r);let g=0;for(let L=h.length-1;L>0&&(L>u||h[L].getTrimmedLength()===0);L--)g++;g>0&&(a.push(l+h.length-g),a.push(g)),l+=h.length-1}return a}function DS(t,e){let s=[],i=0,r=e[i],o=0;for(let a=0;a<t.length;a++)if(r===a){let l=e[++i];t.onDeleteEmitter.fire({index:a-o,amount:l}),a+=l-1,o+=l,r=e[++i]}else s.push(a);return{layout:s,countRemoved:o}}function IS(t,e){let s=[];for(let i=0;i<e.length;i++)s.push(t.get(e[i]));for(let i=0;i<s.length;i++)t.set(i,s[i]);t.length=e.length}function OS(t,e,s){let i=[],r=t.map((c,d)=>ir(t,d,e)).reduce((c,d)=>c+d),o=0,a=0,l=0;for(;l<r;){if(r-l<s){i.push(r-l);break}o+=s;let c=ir(t,a,e);o>c&&(o-=c,a++);let d=t[a].getWidth(o-1)===2;d&&o--;let h=d?s-1:s;i.push(h),l+=h}return i}function ir(t,e,s){if(e===t.length-1)return t[e].getTrimmedLength();let i=!t[e].hasContent(s-1)&&t[e].getWidth(s-1)===1,r=t[e+1].getWidth(0)===2;return i&&r?s-1:s}var yf=class bf{constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=bf._nextId++,this._onDispose=this.register(new ge),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ji(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};yf._nextId=1;var MS=yf,_t={},fi=_t.B;_t[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};_t.A={"#":"£"};_t.B=void 0;_t[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};_t.C=_t[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};_t.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};_t.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};_t.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};_t.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};_t.E=_t[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};_t.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};_t.H=_t[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};_t["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var ed=4294967295,td=class{constructor(t,e,s){this._hasScrollback=t,this._optionsService=e,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=ft.clone(),this.savedCharset=fi,this.markers=[],this._nullCell=ss.fromCharData([0,B1,1,0]),this._whitespaceCell=ss.fromCharData([0,Ys,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new So,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Q0(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(t){return t?(this._nullCell.fg=t.fg,this._nullCell.bg=t.bg,this._nullCell.extended=t.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new vo),this._nullCell}getWhitespaceCell(t){return t?(this._whitespaceCell.fg=t.fg,this._whitespaceCell.bg=t.bg,this._whitespaceCell.extended=t.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new vo),this._whitespaceCell}getBlankLine(t,e){return new Mn(this._bufferService.cols,this.getNullCell(t),e)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let t=this.ybase+this.y-this.ydisp;return t>=0&&t<this._rows}_getCorrectBufferLength(t){if(!this._hasScrollback)return t;let e=t+this._optionsService.rawOptions.scrollback;return e>ed?ed:e}fillViewportRows(t){if(this.lines.length===0){t===void 0&&(t=ft);let e=this._rows;for(;e--;)this.lines.push(this.getBlankLine(t))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new Q0(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,e){let s=this.getNullCell(ft),i=0,r=this._getCorrectBufferLength(e);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<t)for(let a=0;a<this.lines.length;a++)i+=+this.lines.get(a).resize(t,s);let o=0;if(this._rows<e)for(let a=this._rows;a<e;a++)this.lines.length<e+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new Mn(t,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new Mn(t,s)));else for(let a=this._rows;a>e;a--)this.lines.length>e+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r<this.lines.maxLength){let a=this.lines.length-r;a>0&&(this.lines.trimStart(a),this.ybase=Math.max(this.ybase-a,0),this.ydisp=Math.max(this.ydisp-a,0),this.savedY=Math.max(this.savedY-a,0)),this.lines.maxLength=r}this.x=Math.min(this.x,t-1),this.y=Math.min(this.y,e-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,t-1),this.scrollTop=0}if(this.scrollBottom=e-1,this._isReflowEnabled&&(this._reflow(t,e),this._cols>t))for(let o=0;o<this.lines.length;o++)i+=+this.lines.get(o).resize(t,s);this._cols=t,this._rows=e,this._memoryCleanupQueue.clear(),i>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let t=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,t=!1);let e=0;for(;this._memoryCleanupPosition<this.lines.length;)if(e+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),e>100)return!0;return t}get _isReflowEnabled(){let t=this._optionsService.rawOptions.windowsPty;return t&&t.buildNumber?this._hasScrollback&&t.backend==="conpty"&&t.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(t,e){this._cols!==t&&(t>this._cols?this._reflowLarger(t,e):this._reflowSmaller(t,e))}_reflowLarger(t,e){let s=this._optionsService.rawOptions.reflowCursorLine,i=RS(this.lines,this._cols,t,this.ybase+this.y,this.getNullCell(ft),s);if(i.length>0){let r=DS(this.lines,i);IS(this.lines,r.layout),this._reflowLargerAdjustViewport(t,e,r.countRemoved)}}_reflowLargerAdjustViewport(t,e,s){let i=this.getNullCell(ft),r=s;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<e&&this.lines.push(new Mn(t,i))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(t,e){let s=this._optionsService.rawOptions.reflowCursorLine,i=this.getNullCell(ft),r=[],o=0;for(let a=this.lines.length-1;a>=0;a--){let l=this.lines.get(a);if(!l||!l.isWrapped&&l.getTrimmedLength()<=t)continue;let c=[l];for(;l.isWrapped&&a>0;)l=this.lines.get(--a),c.unshift(l);if(!s){let _=this.ybase+this.y;if(_>=a&&_<a+c.length)continue}let d=c[c.length-1].getTrimmedLength(),h=OS(c,this._cols,t),u=h.length-c.length,f;this.ybase===0&&this.y!==this.lines.length-1?f=Math.max(0,this.y-this.lines.maxLength+u):f=Math.max(0,this.lines.length-this.lines.maxLength+u);let m=[];for(let _=0;_<u;_++){let x=this.getBlankLine(ft,!0);m.push(x)}m.length>0&&(r.push({start:a+c.length+o,newLines:m}),o+=m.length),c.push(...m);let p=h.length-1,g=h[p];g===0&&(p--,g=h[p]);let L=c.length-u-1,v=d;for(;L>=0;){let _=Math.min(v,g);if(c[p]===void 0)break;if(c[p].copyCellsFrom(c[L],v-_,g-_,_,!0),g-=_,g===0&&(p--,g=h[p]),v-=_,v===0){L--;let x=Math.max(L,0);v=ir(c,x,this._cols)}}for(let _=0;_<c.length;_++)h[_]<t&&c[_].setCell(h[_],i);let y=u-f;for(;y-- >0;)this.ybase===0?this.y<e-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-e&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+u,this.ybase+e-1)}if(r.length>0){let a=[],l=[];for(let g=0;g<this.lines.length;g++)l.push(this.lines.get(g));let c=this.lines.length,d=c-1,h=0,u=r[h];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let f=0;for(let g=Math.min(this.lines.maxLength-1,c+o-1);g>=0;g--)if(u&&u.start>d+f){for(let L=u.newLines.length-1;L>=0;L--)this.lines.set(g--,u.newLines[L]);g++,a.push({index:d+1,amount:u.newLines.length}),f+=u.newLines.length,u=r[++h]}else this.lines.set(g,l[d--]);let m=0;for(let g=a.length-1;g>=0;g--)a[g].index+=m,this.lines.onInsertEmitter.fire(a[g]),m+=a[g].amount;let p=Math.max(0,c+o-this.lines.maxLength);p>0&&this.lines.onTrimEmitter.fire(p)}}translateBufferLineToString(t,e,s=0,i){let r=this.lines.get(t);return r?r.translateToString(e,s,i):""}getWrappedRangeForLine(t){let e=t,s=t;for(;e>0&&this.lines.get(e).isWrapped;)e--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:e,last:s}}setupTabStops(t){for(t!=null?this.tabs[t]||(t=this.prevStop(t)):(this.tabs={},t=0);t<this._cols;t+=this._optionsService.rawOptions.tabStopWidth)this.tabs[t]=!0}prevStop(t){for(t==null&&(t=this.x);!this.tabs[--t]&&t>0;);return t>=this._cols?this._cols-1:t<0?0:t}nextStop(t){for(t==null&&(t=this.x);!this.tabs[++t]&&t<this._cols;);return t>=this._cols?this._cols-1:t<0?0:t}clearMarkers(t){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].line===t&&(this.markers[e].dispose(),this.markers.splice(e--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].dispose();this.markers.length=0,this._isClearing=!1}addMarker(t){let e=new MS(t);return this.markers.push(e),e.register(this.lines.onTrim(s=>{e.line-=s,e.line<0&&e.dispose()})),e.register(this.lines.onInsert(s=>{e.line>=s.index&&(e.line+=s.amount)})),e.register(this.lines.onDelete(s=>{e.line>=s.index&&e.line<s.index+s.amount&&e.dispose(),e.line>s.index&&(e.line-=s.amount)})),e.register(e.onDispose(()=>this._removeMarker(e))),e}_removeMarker(t){this._isClearing||this.markers.splice(this.markers.indexOf(t),1)}},BS=class extends ze{constructor(t,e){super(),this._optionsService=t,this._bufferService=e,this._onBufferActivate=this._register(new ge),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new td(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new td(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(t){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(t),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(t,e){this._normal.resize(t,e),this._alt.resize(t,e),this.setupTabStops(t)}setupTabStops(t){this._normal.setupTabStops(t),this._alt.setupTabStops(t)}},Sf=2,wf=1,El=class extends ze{constructor(t){super(),this.isUserScrolling=!1,this._onResize=this._register(new ge),this.onResize=this._onResize.event,this._onScroll=this._register(new ge),this.onScroll=this._onScroll.event,this.cols=Math.max(t.rawOptions.cols||0,Sf),this.rows=Math.max(t.rawOptions.rows||0,wf),this.buffers=this._register(new BS(t,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(t,e){let s=this.cols!==t,i=this.rows!==e;this.cols=t,this.rows=e,this.buffers.resize(t,e),this._onResize.fire({cols:t,rows:e,colsChanged:s,rowsChanged:i})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(t,e=!1){let s=this.buffer,i;i=this._cachedBlankLine,(!i||i.length!==this.cols||i.getFg(0)!==t.fg||i.getBg(0)!==t.bg)&&(i=s.getBlankLine(t,e),this._cachedBlankLine=i),i.isWrapped=e;let r=s.ybase+s.scrollTop,o=s.ybase+s.scrollBottom;if(s.scrollTop===0){let a=s.lines.isFull;o===s.lines.length-1?a?s.lines.recycle().copyFrom(i):s.lines.push(i.clone()):s.lines.splice(o+1,0,i.clone()),a?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let a=o-r+1;s.lines.shiftElements(r+1,a-1,-1),s.lines.set(o,i.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(t,e){let s=this.buffer;if(t<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else t+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let i=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+t,s.ybase),0),i!==s.ydisp&&(e||this._onScroll.fire(s.ydisp))}};El=dt([xe(0,Mt)],El);var Fi={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:bo,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},$S=["normal","bold","100","200","300","400","500","600","700","800","900"],zS=class extends ze{constructor(t){super(),this._onOptionChange=this._register(new ge),this.onOptionChange=this._onOptionChange.event;let e={...Fi};for(let s in t)if(s in e)try{let i=t[s];e[s]=this._sanitizeAndValidateOption(s,i)}catch(i){console.error(i)}this.rawOptions=e,this.options={...e},this._setupOptions(),this._register(st(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(t,e){return this.onOptionChange(s=>{s===t&&e(this.rawOptions[t])})}onMultipleOptionChange(t,e){return this.onOptionChange(s=>{t.indexOf(s)!==-1&&e()})}_setupOptions(){let t=s=>{if(!(s in Fi))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},e=(s,i)=>{if(!(s in Fi))throw new Error(`No option with key "${s}"`);i=this._sanitizeAndValidateOption(s,i),this.rawOptions[s]!==i&&(this.rawOptions[s]=i,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let i={get:t.bind(this,s),set:e.bind(this,s)};Object.defineProperty(this.options,s,i)}}_sanitizeAndValidateOption(t,e){switch(t){case"cursorStyle":if(e||(e=Fi[t]),!FS(e))throw new Error(`"${e}" is not a valid value for ${t}`);break;case"wordSeparator":e||(e=Fi[t]);break;case"fontWeight":case"fontWeightBold":if(typeof e=="number"&&1<=e&&e<=1e3)break;e=$S.includes(e)?e:Fi[t];break;case"cursorWidth":e=Math.floor(e);case"lineHeight":case"tabStopWidth":if(e<1)throw new Error(`${t} cannot be less than 1, value: ${e}`);break;case"minimumContrastRatio":e=Math.max(1,Math.min(21,Math.round(e*10)/10));break;case"scrollback":if(e=Math.min(e,4294967295),e<0)throw new Error(`${t} cannot be less than 0, value: ${e}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(e<=0)throw new Error(`${t} cannot be less than or equal to 0, value: ${e}`);break;case"rows":case"cols":if(!e&&e!==0)throw new Error(`${t} must be numeric, value: ${e}`);break;case"windowsPty":e=e??{};break}return e}};function FS(t){return t==="block"||t==="underline"||t==="bar"}function Bn(t,e=5){if(typeof t!="object")return t;let s=Array.isArray(t)?[]:{};for(let i in t)s[i]=e<=1?t[i]:t[i]&&Bn(t[i],e-1);return s}var sd=Object.freeze({insertMode:!1}),id=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Al=class extends ze{constructor(t,e,s){super(),this._bufferService=t,this._logService=e,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new ge),this.onData=this._onData.event,this._onUserInput=this._register(new ge),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new ge),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new ge),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Bn(sd),this.decPrivateModes=Bn(id)}reset(){this.modes=Bn(sd),this.decPrivateModes=Bn(id)}triggerDataEvent(t,e=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;e&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),e&&this._onUserInput.fire(),this._logService.debug(`sending data "${t}"`),this._logService.trace("sending data (codes)",()=>t.split("").map(i=>i.charCodeAt(0))),this._onData.fire(t)}triggerBinaryEvent(t){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${t}"`),this._logService.trace("sending binary (codes)",()=>t.split("").map(e=>e.charCodeAt(0))),this._onBinary.fire(t))}};Al=dt([xe(0,Ot),xe(1,U1),xe(2,Mt)],Al);var nd={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:t=>t.button===4||t.action!==1?!1:(t.ctrl=!1,t.alt=!1,t.shift=!1,!0)},VT200:{events:19,restrict:t=>t.action!==32},DRAG:{events:23,restrict:t=>!(t.action===32&&t.button===3)},ANY:{events:31,restrict:t=>!0}};function Aa(t,e){let s=(t.ctrl?16:0)|(t.shift?4:0)|(t.alt?8:0);return t.button===4?(s|=64,s|=t.action):(s|=t.button&3,t.button&4&&(s|=64),t.button&8&&(s|=128),t.action===32?s|=32:t.action===0&&!e&&(s|=3)),s}var Pa=String.fromCharCode,rd={DEFAULT:t=>{let e=[Aa(t,!1)+32,t.col+32,t.row+32];return e[0]>255||e[1]>255||e[2]>255?"":`\x1B[M${Pa(e[0])}${Pa(e[1])}${Pa(e[2])}`},SGR:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${Aa(t,!0)};${t.col};${t.row}${e}`},SGR_PIXELS:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${Aa(t,!0)};${t.x};${t.y}${e}`}},Pl=class extends ze{constructor(t,e,s){super(),this._bufferService=t,this._coreService=e,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new ge),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(nd))this.addProtocol(i,nd[i]);for(let i of Object.keys(rd))this.addEncoding(i,rd[i]);this.reset()}addProtocol(t,e){this._protocols[t]=e}addEncoding(t,e){this._encodings[t]=e}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(t){if(!this._protocols[t])throw new Error(`unknown protocol "${t}"`);this._activeProtocol=t,this._onProtocolChange.fire(this._protocols[t].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(t){if(!this._encodings[t])throw new Error(`unknown encoding "${t}"`);this._activeEncoding=t}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(t,e,s){if(t.deltaY===0||t.shiftKey||e===void 0||s===void 0)return 0;let i=e/s,r=this._applyScrollModifier(t.deltaY,t);return t.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=i+0,Math.abs(t.deltaY)<50&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):t.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_applyScrollModifier(t,e){return e.altKey||e.ctrlKey||e.shiftKey?t*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:t*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(t){if(t.col<0||t.col>=this._bufferService.cols||t.row<0||t.row>=this._bufferService.rows||t.button===4&&t.action===32||t.button===3&&t.action!==32||t.button!==4&&(t.action===2||t.action===3)||(t.col++,t.row++,t.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,t,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(t))return!1;let e=this._encodings[this._activeEncoding](t);return e&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(e):this._coreService.triggerDataEvent(e,!0)),this._lastEvent=t,!0}explainEvents(t){return{down:!!(t&1),up:!!(t&2),drag:!!(t&4),move:!!(t&8),wheel:!!(t&16)}}_equalEvents(t,e,s){if(s){if(t.x!==e.x||t.y!==e.y)return!1}else if(t.col!==e.col||t.row!==e.row)return!1;return!(t.button!==e.button||t.action!==e.action||t.ctrl!==e.ctrl||t.alt!==e.alt||t.shift!==e.shift)}};Pl=dt([xe(0,Ot),xe(1,Bi),xe(2,Mt)],Pl);var Ra=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],HS=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],gt;function US(t,e){let s=0,i=e.length-1,r;if(t<e[0][0]||t>e[i][1])return!1;for(;i>=s;)if(r=s+i>>1,t>e[r][1])s=r+1;else if(t<e[r][0])i=r-1;else return!0;return!1}var KS=class{constructor(){if(this.version="6",!gt){gt=new Uint8Array(65536),gt.fill(1),gt[0]=0,gt.fill(0,1,32),gt.fill(0,127,160),gt.fill(2,4352,4448),gt[9001]=2,gt[9002]=2,gt.fill(2,11904,42192),gt[12351]=1,gt.fill(2,44032,55204),gt.fill(2,63744,64256),gt.fill(2,65040,65050),gt.fill(2,65072,65136),gt.fill(2,65280,65377),gt.fill(2,65504,65511);for(let t=0;t<Ra.length;++t)gt.fill(0,Ra[t][0],Ra[t][1]+1)}}wcwidth(t){return t<32?0:t<127?1:t<65536?gt[t]:US(t,HS)?0:t>=131072&&t<=196605||t>=196608&&t<=262141?2:1}charProperties(t,e){let s=this.wcwidth(t),i=s===0&&e!==0;if(i){let r=pi.extractWidth(e);r===0?i=!1:r>s&&(s=r)}return pi.createPropertyValue(0,s,i)}},pi=class qr{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new ge,this.onChange=this._onChange.event;let e=new KS;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(e&1)!==0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,s,i=!1){return(e&16777215)<<3|(s&3)<<1|(i?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw new Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(e){let s=0,i=0,r=e.length;for(let o=0;o<r;++o){let a=e.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=r)return s+this.wcwidth(a);let d=e.charCodeAt(o);56320<=d&&d<=57343?a=(a-55296)*1024+d-56320+65536:s+=this.wcwidth(d)}let l=this.charProperties(a,i),c=qr.extractWidth(l);qr.extractShouldJoin(l)&&(c-=qr.extractWidth(i)),s+=c,i=l}return s}charProperties(e,s){return this._activeProvider.charProperties(e,s)}},WS=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(t){this.glevel=t,this.charset=this._charsets[t]}setgCharset(t,e){this._charsets[t]=e,this.glevel===t&&(this.charset=e)}};function od(t){let e=t.buffer.lines.get(t.buffer.ybase+t.buffer.y-1)?.get(t.cols-1),s=t.buffer.lines.get(t.buffer.ybase+t.buffer.y);s&&e&&(s.isWrapped=e[3]!==0&&e[3]!==32)}var jn=2147483647,VS=256,Cf=class Rl{constructor(e=32,s=32){if(this.maxLength=e,this.maxSubParamsLength=s,s>VS)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(e){let s=new Rl;if(!e.length)return s;for(let i=Array.isArray(e[0])?1:0;i<e.length;++i){let r=e[i];if(Array.isArray(r))for(let o=0;o<r.length;++o)s.addSubParam(r[o]);else s.addParam(r)}return s}clone(){let e=new Rl(this.maxLength,this.maxSubParamsLength);return e.params.set(this.params),e.length=this.length,e._subParams.set(this._subParams),e._subParamsLength=this._subParamsLength,e._subParamsIdx.set(this._subParamsIdx),e._rejectDigits=this._rejectDigits,e._rejectSubDigits=this._rejectSubDigits,e._digitIsSub=this._digitIsSub,e}toArray(){let e=[];for(let s=0;s<this.length;++s){e.push(this.params[s]);let i=this._subParamsIdx[s]>>8,r=this._subParamsIdx[s]&255;r-i>0&&e.push(Array.prototype.slice.call(this._subParams,i,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>jn?jn:e}addSubParam(e){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=e>jn?jn:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let s=this._subParamsIdx[e]>>8,i=this._subParamsIdx[e]&255;return i-s>0?this._subParams.subarray(s,i):null}getSubParamsAll(){let e={};for(let s=0;s<this.length;++s){let i=this._subParamsIdx[s]>>8,r=this._subParamsIdx[s]&255;r-i>0&&(e[s]=this._subParams.slice(i,r))}return e}addDigit(e){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let i=this._digitIsSub?this._subParams:this.params,r=i[s-1];i[s-1]=~r?Math.min(r*10+e,jn):e}},kn=[],GS=class{constructor(){this._state=0,this._active=kn,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(t,e){this._handlers[t]===void 0&&(this._handlers[t]=[]);let s=this._handlers[t];return s.push(e),{dispose:()=>{let i=s.indexOf(e);i!==-1&&s.splice(i,1)}}}clearHandler(t){this._handlers[t]&&delete this._handlers[t]}setHandlerFallback(t){this._handlerFb=t}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=kn}reset(){if(this._state===2)for(let t=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;t>=0;--t)this._active[t].end(!1);this._stack.paused=!1,this._active=kn,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||kn,!this._active.length)this._handlerFb(this._id,"START");else for(let t=this._active.length-1;t>=0;t--)this._active[t].start()}_put(t,e,s){if(!this._active.length)this._handlerFb(this._id,"PUT",Jo(t,e,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(t,e,s)}start(){this.reset(),this._state=1}put(t,e,s){if(this._state!==3){if(this._state===1)for(;e<s;){let i=t[e++];if(i===59){this._state=2,this._start();break}if(i<48||57<i){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+i-48}this._state===2&&s-e>0&&this._put(t,e,s)}}end(t,e=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",t);else{let s=!1,i=this._active.length-1,r=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=e,r=this._stack.fallThrough,this._stack.paused=!1),!r&&s===!1){for(;i>=0&&(s=this._active[i].end(t),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=kn,this._id=-1,this._state=0}}},Ft=class{constructor(t){this._handler=t,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(t,e,s){this._hitLimit||(this._data+=Jo(t,e,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(t){let e=!1;if(this._hitLimit)e=!1;else if(t&&(e=this._handler(this._data),e instanceof Promise))return e.then(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,e}},Nn=[],qS=class{constructor(){this._handlers=Object.create(null),this._active=Nn,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Nn}registerHandler(t,e){this._handlers[t]===void 0&&(this._handlers[t]=[]);let s=this._handlers[t];return s.push(e),{dispose:()=>{let i=s.indexOf(e);i!==-1&&s.splice(i,1)}}}clearHandler(t){this._handlers[t]&&delete this._handlers[t]}setHandlerFallback(t){this._handlerFb=t}reset(){if(this._active.length)for(let t=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;t>=0;--t)this._active[t].unhook(!1);this._stack.paused=!1,this._active=Nn,this._ident=0}hook(t,e){if(this.reset(),this._ident=t,this._active=this._handlers[t]||Nn,!this._active.length)this._handlerFb(this._ident,"HOOK",e);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(e)}put(t,e,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",Jo(t,e,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(t,e,s)}unhook(t,e=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",t);else{let s=!1,i=this._active.length-1,r=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=e,r=this._stack.fallThrough,this._stack.paused=!1),!r&&s===!1){for(;i>=0&&(s=this._active[i].unhook(t),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=Nn,this._ident=0}},$n=new Cf;$n.addParam(0);var ad=class{constructor(t){this._handler=t,this._data="",this._params=$n,this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():$n,this._data="",this._hitLimit=!1}put(t,e,s){this._hitLimit||(this._data+=Jo(t,e,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(t){let e=!1;if(this._hitLimit)e=!1;else if(t&&(e=this._handler(this._data,this._params),e instanceof Promise))return e.then(s=>(this._params=$n,this._data="",this._hitLimit=!1,s));return this._params=$n,this._data="",this._hitLimit=!1,e}},YS=class{constructor(t){this.table=new Uint8Array(t)}setDefault(t,e){this.table.fill(t<<4|e)}add(t,e,s,i){this.table[e<<8|t]=s<<4|i}addMany(t,e,s,i){for(let r=0;r<t.length;r++)this.table[e<<8|t[r]]=s<<4|i}},Qt=160,JS=(function(){let t=new YS(4095),e=Array.apply(null,Array(256)).map((l,c)=>c),s=(l,c)=>e.slice(l,c),i=s(32,127),r=s(0,24);r.push(25),r.push.apply(r,s(28,32));let o=s(0,14),a;t.setDefault(1,0),t.addMany(i,0,2,0);for(a in o)t.addMany([24,26,153,154],a,3,0),t.addMany(s(128,144),a,3,0),t.addMany(s(144,152),a,3,0),t.add(156,a,0,0),t.add(27,a,11,1),t.add(157,a,4,8),t.addMany([152,158,159],a,0,7),t.add(155,a,11,3),t.add(144,a,11,9);return t.addMany(r,0,3,0),t.addMany(r,1,3,1),t.add(127,1,0,1),t.addMany(r,8,0,8),t.addMany(r,3,3,3),t.add(127,3,0,3),t.addMany(r,4,3,4),t.add(127,4,0,4),t.addMany(r,6,3,6),t.addMany(r,5,3,5),t.add(127,5,0,5),t.addMany(r,2,3,2),t.add(127,2,0,2),t.add(93,1,4,8),t.addMany(i,8,5,8),t.add(127,8,5,8),t.addMany([156,27,24,26,7],8,6,0),t.addMany(s(28,32),8,0,8),t.addMany([88,94,95],1,0,7),t.addMany(i,7,0,7),t.addMany(r,7,0,7),t.add(156,7,0,0),t.add(127,7,0,7),t.add(91,1,11,3),t.addMany(s(64,127),3,7,0),t.addMany(s(48,60),3,8,4),t.addMany([60,61,62,63],3,9,4),t.addMany(s(48,60),4,8,4),t.addMany(s(64,127),4,7,0),t.addMany([60,61,62,63],4,0,6),t.addMany(s(32,64),6,0,6),t.add(127,6,0,6),t.addMany(s(64,127),6,0,0),t.addMany(s(32,48),3,9,5),t.addMany(s(32,48),5,9,5),t.addMany(s(48,64),5,0,6),t.addMany(s(64,127),5,7,0),t.addMany(s(32,48),4,9,5),t.addMany(s(32,48),1,9,2),t.addMany(s(32,48),2,9,2),t.addMany(s(48,127),2,10,0),t.addMany(s(48,80),1,10,0),t.addMany(s(81,88),1,10,0),t.addMany([89,90,92],1,10,0),t.addMany(s(96,127),1,10,0),t.add(80,1,11,9),t.addMany(r,9,0,9),t.add(127,9,0,9),t.addMany(s(28,32),9,0,9),t.addMany(s(32,48),9,9,12),t.addMany(s(48,60),9,8,10),t.addMany([60,61,62,63],9,9,10),t.addMany(r,11,0,11),t.addMany(s(32,128),11,0,11),t.addMany(s(28,32),11,0,11),t.addMany(r,10,0,10),t.add(127,10,0,10),t.addMany(s(28,32),10,0,10),t.addMany(s(48,60),10,8,10),t.addMany([60,61,62,63],10,0,11),t.addMany(s(32,48),10,9,12),t.addMany(r,12,0,12),t.add(127,12,0,12),t.addMany(s(28,32),12,0,12),t.addMany(s(32,48),12,9,12),t.addMany(s(48,64),12,0,11),t.addMany(s(64,127),12,12,13),t.addMany(s(64,127),10,12,13),t.addMany(s(64,127),9,12,13),t.addMany(r,13,13,13),t.addMany(i,13,13,13),t.add(127,13,0,13),t.addMany([27,156,24,26],13,14,0),t.add(Qt,0,2,0),t.add(Qt,8,5,8),t.add(Qt,6,0,6),t.add(Qt,11,0,11),t.add(Qt,13,13,13),t})(),XS=class extends ze{constructor(t=JS){super(),this._transitions=t,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new Cf,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,s,i)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,s)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(st(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new GS),this._dcsParser=this._register(new qS),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(t,e=[64,126]){let s=0;if(t.prefix){if(t.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=t.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(t.intermediates){if(t.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let r=0;r<t.intermediates.length;++r){let o=t.intermediates.charCodeAt(r);if(32>o||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=o}}if(t.final.length!==1)throw new Error("final must be a single byte");let i=t.final.charCodeAt(0);if(e[0]>i||i>e[1])throw new Error(`final must be in range ${e[0]} .. ${e[1]}`);return s<<=8,s|=i,s}identToString(t){let e=[];for(;t;)e.push(String.fromCharCode(t&255)),t>>=8;return e.reverse().join("")}setPrintHandler(t){this._printHandler=t}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(t,e){let s=this._identifier(t,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let i=this._escHandlers[s];return i.push(e),{dispose:()=>{let r=i.indexOf(e);r!==-1&&i.splice(r,1)}}}clearEscHandler(t){this._escHandlers[this._identifier(t,[48,126])]&&delete this._escHandlers[this._identifier(t,[48,126])]}setEscHandlerFallback(t){this._escHandlerFb=t}setExecuteHandler(t,e){this._executeHandlers[t.charCodeAt(0)]=e}clearExecuteHandler(t){this._executeHandlers[t.charCodeAt(0)]&&delete this._executeHandlers[t.charCodeAt(0)]}setExecuteHandlerFallback(t){this._executeHandlerFb=t}registerCsiHandler(t,e){let s=this._identifier(t);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let i=this._csiHandlers[s];return i.push(e),{dispose:()=>{let r=i.indexOf(e);r!==-1&&i.splice(r,1)}}}clearCsiHandler(t){this._csiHandlers[this._identifier(t)]&&delete this._csiHandlers[this._identifier(t)]}setCsiHandlerFallback(t){this._csiHandlerFb=t}registerDcsHandler(t,e){return this._dcsParser.registerHandler(this._identifier(t),e)}clearDcsHandler(t){this._dcsParser.clearHandler(this._identifier(t))}setDcsHandlerFallback(t){this._dcsParser.setHandlerFallback(t)}registerOscHandler(t,e){return this._oscParser.registerHandler(t,e)}clearOscHandler(t){this._oscParser.clearHandler(t)}setOscHandlerFallback(t){this._oscParser.setHandlerFallback(t)}setErrorHandler(t){this._errorHandler=t}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(t,e,s,i,r){this._parseStack.state=t,this._parseStack.handlers=e,this._parseStack.handlerPos=s,this._parseStack.transition=i,this._parseStack.chunkPos=r}parse(t,e,s){let i=0,r=0,o=0,a;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let l=this._parseStack.handlers,c=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&c>-1){for(;c>=0&&(a=l[c](this._params),a!==!0);c--)if(a instanceof Promise)return this._parseStack.handlerPos=c,a}this._parseStack.handlers=[];break;case 4:if(s===!1&&c>-1){for(;c>=0&&(a=l[c](),a!==!0);c--)if(a instanceof Promise)return this._parseStack.handlerPos=c,a}this._parseStack.handlers=[];break;case 6:if(i=t[this._parseStack.chunkPos],a=this._dcsParser.unhook(i!==24&&i!==26,s),a)return a;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=t[this._parseStack.chunkPos],a=this._oscParser.end(i!==24&&i!==26,s),a)return a;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let l=o;l<e;++l){switch(i=t[l],r=this._transitions.table[this.currentState<<8|(i<160?i:Qt)],r>>4){case 2:for(let f=l+1;;++f){if(f>=e||(i=t[f])<32||i>126&&i<Qt){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(i=t[f])<32||i>126&&i<Qt){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(i=t[f])<32||i>126&&i<Qt){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(i=t[f])<32||i>126&&i<Qt){this._printHandler(t,l,f),l=f-1;break}}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:l,code:i,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let c=this._csiHandlers[this._collect<<8|i],d=c?c.length-1:-1;for(;d>=0&&(a=c[d](this._params),a!==!0);d--)if(a instanceof Promise)return this._preserveStack(3,c,d,r,l),a;d<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingJoinState=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++l<e&&(i=t[l])>47&&i<60);l--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let h=this._escHandlers[this._collect<<8|i],u=h?h.length-1:-1;for(;u>=0&&(a=h[u](),a!==!0);u--)if(a instanceof Promise)return this._preserveStack(4,h,u,r,l),a;u<0&&this._escHandlerFb(this._collect<<8|i),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|i,this._params);break;case 13:for(let f=l+1;;++f)if(f>=e||(i=t[f])===24||i===26||i===27||i>127&&i<Qt){this._dcsParser.put(t,l,f),l=f-1;break}break;case 14:if(a=this._dcsParser.unhook(i!==24&&i!==26),a)return this._preserveStack(6,[],0,r,l),a;i===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let f=l+1;;f++)if(f>=e||(i=t[f])<32||i>127&&i<Qt){this._oscParser.put(t,l,f),l=f-1;break}break;case 6:if(a=this._oscParser.end(i!==24&&i!==26),a)return this._preserveStack(5,[],0,r,l),a;i===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=r&15}}},ZS=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,QS=/^[\da-f]+$/;function ld(t){if(!t)return;let e=t.toLowerCase();if(e.indexOf("rgb:")===0){e=e.slice(4);let s=ZS.exec(e);if(s){let i=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/i*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/i*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/i*255)]}}else if(e.indexOf("#")===0&&(e=e.slice(1),QS.exec(e)&&[3,6,9,12].includes(e.length))){let s=e.length/3,i=[0,0,0];for(let r=0;r<3;++r){let o=parseInt(e.slice(s*r,s*r+s),16);i[r]=s===1?o<<4:s===2?o:s===3?o>>4:o>>8}return i}}function Da(t,e){let s=t.toString(16),i=s.length<2?"0"+s:s;switch(e){case 4:return s[0];case 8:return i;case 12:return(i+i).slice(0,3);default:return i+i}}function ew(t,e=16){let[s,i,r]=t;return`rgb:${Da(s,e)}/${Da(i,e)}/${Da(r,e)}`}var tw={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Vs=131072,cd=10;function dd(t,e){if(t>24)return e.setWinLines||!1;switch(t){case 1:return!!e.restoreWin;case 2:return!!e.minimizeWin;case 3:return!!e.setWinPosition;case 4:return!!e.setWinSizePixels;case 5:return!!e.raiseWin;case 6:return!!e.lowerWin;case 7:return!!e.refreshWin;case 8:return!!e.setWinSizeChars;case 9:return!!e.maximizeWin;case 10:return!!e.fullscreenWin;case 11:return!!e.getWinState;case 13:return!!e.getWinPosition;case 14:return!!e.getWinSizePixels;case 15:return!!e.getScreenSizePixels;case 16:return!!e.getCellSizePixels;case 18:return!!e.getWinSizeChars;case 19:return!!e.getScreenSizeChars;case 20:return!!e.getIconTitle;case 21:return!!e.getWinTitle;case 22:return!!e.pushTitle;case 23:return!!e.popTitle;case 24:return!!e.setWinLines}return!1}var hd=5e3,ud=0,sw=class extends ze{constructor(t,e,s,i,r,o,a,l,c=new XS){super(),this._bufferService=t,this._charsetService=e,this._coreService=s,this._logService=i,this._optionsService=r,this._oscLinkService=o,this._coreMouseService=a,this._unicodeService=l,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new yy,this._utf8Decoder=new by,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=ft.clone(),this._eraseAttrDataInternal=ft.clone(),this._onRequestBell=this._register(new ge),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new ge),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new ge),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new ge),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new ge),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new ge),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new ge),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new ge),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new ge),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new ge),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new ge),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new ge),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new ge),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new Dl(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(d=>this._activeBuffer=d.activeBuffer)),this._parser.setCsiHandlerFallback((d,h)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(d),params:h.toArray()})}),this._parser.setEscHandlerFallback(d=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(d)})}),this._parser.setExecuteHandlerFallback(d=>{this._logService.debug("Unknown EXECUTE code: ",{code:d})}),this._parser.setOscHandlerFallback((d,h,u)=>{this._logService.debug("Unknown OSC code: ",{identifier:d,action:h,data:u})}),this._parser.setDcsHandlerFallback((d,h,u)=>{h==="HOOK"&&(u=u.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(d),action:h,payload:u})}),this._parser.setPrintHandler((d,h,u)=>this.print(d,h,u)),this._parser.registerCsiHandler({final:"@"},d=>this.insertChars(d)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},d=>this.scrollLeft(d)),this._parser.registerCsiHandler({final:"A"},d=>this.cursorUp(d)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},d=>this.scrollRight(d)),this._parser.registerCsiHandler({final:"B"},d=>this.cursorDown(d)),this._parser.registerCsiHandler({final:"C"},d=>this.cursorForward(d)),this._parser.registerCsiHandler({final:"D"},d=>this.cursorBackward(d)),this._parser.registerCsiHandler({final:"E"},d=>this.cursorNextLine(d)),this._parser.registerCsiHandler({final:"F"},d=>this.cursorPrecedingLine(d)),this._parser.registerCsiHandler({final:"G"},d=>this.cursorCharAbsolute(d)),this._parser.registerCsiHandler({final:"H"},d=>this.cursorPosition(d)),this._parser.registerCsiHandler({final:"I"},d=>this.cursorForwardTab(d)),this._parser.registerCsiHandler({final:"J"},d=>this.eraseInDisplay(d,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},d=>this.eraseInDisplay(d,!0)),this._parser.registerCsiHandler({final:"K"},d=>this.eraseInLine(d,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},d=>this.eraseInLine(d,!0)),this._parser.registerCsiHandler({final:"L"},d=>this.insertLines(d)),this._parser.registerCsiHandler({final:"M"},d=>this.deleteLines(d)),this._parser.registerCsiHandler({final:"P"},d=>this.deleteChars(d)),this._parser.registerCsiHandler({final:"S"},d=>this.scrollUp(d)),this._parser.registerCsiHandler({final:"T"},d=>this.scrollDown(d)),this._parser.registerCsiHandler({final:"X"},d=>this.eraseChars(d)),this._parser.registerCsiHandler({final:"Z"},d=>this.cursorBackwardTab(d)),this._parser.registerCsiHandler({final:"`"},d=>this.charPosAbsolute(d)),this._parser.registerCsiHandler({final:"a"},d=>this.hPositionRelative(d)),this._parser.registerCsiHandler({final:"b"},d=>this.repeatPrecedingCharacter(d)),this._parser.registerCsiHandler({final:"c"},d=>this.sendDeviceAttributesPrimary(d)),this._parser.registerCsiHandler({prefix:">",final:"c"},d=>this.sendDeviceAttributesSecondary(d)),this._parser.registerCsiHandler({final:"d"},d=>this.linePosAbsolute(d)),this._parser.registerCsiHandler({final:"e"},d=>this.vPositionRelative(d)),this._parser.registerCsiHandler({final:"f"},d=>this.hVPosition(d)),this._parser.registerCsiHandler({final:"g"},d=>this.tabClear(d)),this._parser.registerCsiHandler({final:"h"},d=>this.setMode(d)),this._parser.registerCsiHandler({prefix:"?",final:"h"},d=>this.setModePrivate(d)),this._parser.registerCsiHandler({final:"l"},d=>this.resetMode(d)),this._parser.registerCsiHandler({prefix:"?",final:"l"},d=>this.resetModePrivate(d)),this._parser.registerCsiHandler({final:"m"},d=>this.charAttributes(d)),this._parser.registerCsiHandler({final:"n"},d=>this.deviceStatus(d)),this._parser.registerCsiHandler({prefix:"?",final:"n"},d=>this.deviceStatusPrivate(d)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},d=>this.softReset(d)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},d=>this.setCursorStyle(d)),this._parser.registerCsiHandler({final:"r"},d=>this.setScrollRegion(d)),this._parser.registerCsiHandler({final:"s"},d=>this.saveCursor(d)),this._parser.registerCsiHandler({final:"t"},d=>this.windowOptions(d)),this._parser.registerCsiHandler({final:"u"},d=>this.restoreCursor(d)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},d=>this.insertColumns(d)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},d=>this.deleteColumns(d)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},d=>this.selectProtected(d)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},d=>this.requestMode(d,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},d=>this.requestMode(d,!1)),this._parser.setExecuteHandler(de.BEL,()=>this.bell()),this._parser.setExecuteHandler(de.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(de.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(de.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(de.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(de.BS,()=>this.backspace()),this._parser.setExecuteHandler(de.HT,()=>this.tab()),this._parser.setExecuteHandler(de.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(de.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Vr.IND,()=>this.index()),this._parser.setExecuteHandler(Vr.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Vr.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Ft(d=>(this.setTitle(d),this.setIconName(d),!0))),this._parser.registerOscHandler(1,new Ft(d=>this.setIconName(d))),this._parser.registerOscHandler(2,new Ft(d=>this.setTitle(d))),this._parser.registerOscHandler(4,new Ft(d=>this.setOrReportIndexedColor(d))),this._parser.registerOscHandler(8,new Ft(d=>this.setHyperlink(d))),this._parser.registerOscHandler(10,new Ft(d=>this.setOrReportFgColor(d))),this._parser.registerOscHandler(11,new Ft(d=>this.setOrReportBgColor(d))),this._parser.registerOscHandler(12,new Ft(d=>this.setOrReportCursorColor(d))),this._parser.registerOscHandler(104,new Ft(d=>this.restoreIndexedColor(d))),this._parser.registerOscHandler(110,new Ft(d=>this.restoreFgColor(d))),this._parser.registerOscHandler(111,new Ft(d=>this.restoreBgColor(d))),this._parser.registerOscHandler(112,new Ft(d=>this.restoreCursorColor(d))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let d in _t)this._parser.registerEscHandler({intermediates:"(",final:d},()=>this.selectCharset("("+d)),this._parser.registerEscHandler({intermediates:")",final:d},()=>this.selectCharset(")"+d)),this._parser.registerEscHandler({intermediates:"*",final:d},()=>this.selectCharset("*"+d)),this._parser.registerEscHandler({intermediates:"+",final:d},()=>this.selectCharset("+"+d)),this._parser.registerEscHandler({intermediates:"-",final:d},()=>this.selectCharset("-"+d)),this._parser.registerEscHandler({intermediates:".",final:d},()=>this.selectCharset("."+d)),this._parser.registerEscHandler({intermediates:"/",final:d},()=>this.selectCharset("/"+d));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(d=>(this._logService.error("Parsing error: ",d),d)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new ad((d,h)=>this.requestStatusString(d,h)))}getAttrData(){return this._curAttrData}_preserveStack(t,e,s,i){this._parseStack.paused=!0,this._parseStack.cursorStartX=t,this._parseStack.cursorStartY=e,this._parseStack.decodedLength=s,this._parseStack.position=i}_logSlowResolvingAsync(t){this._logService.logLevel<=3&&Promise.race([t,new Promise((e,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),hd))]).catch(e=>{if(e!=="#SLOW_TIMEOUT")throw e;console.warn(`async parser handler taking longer than ${hd} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(t,e){let s,i=this._activeBuffer.x,r=this._activeBuffer.y,o=0,a=this._parseStack.paused;if(a){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,e))return this._logSlowResolvingAsync(s),s;i=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,t.length>Vs&&(o=this._parseStack.position+Vs)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof t=="string"?` "${t}"`:` "${Array.prototype.map.call(t,d=>String.fromCharCode(d)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof t=="string"?t.split("").map(d=>d.charCodeAt(0)):t),this._parseBuffer.length<t.length&&this._parseBuffer.length<Vs&&(this._parseBuffer=new Uint32Array(Math.min(t.length,Vs))),a||this._dirtyRowTracker.clearRange(),t.length>Vs)for(let d=o;d<t.length;d+=Vs){let h=d+Vs<t.length?d+Vs:t.length,u=typeof t=="string"?this._stringDecoder.decode(t.substring(d,h),this._parseBuffer):this._utf8Decoder.decode(t.subarray(d,h),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,u))return this._preserveStack(i,r,u,d),this._logSlowResolvingAsync(s),s}else if(!a){let d=typeof t=="string"?this._stringDecoder.decode(t,this._parseBuffer):this._utf8Decoder.decode(t,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,d))return this._preserveStack(i,r,d,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==i||this._activeBuffer.y!==r)&&this._onCursorMove.fire();let l=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(l,this._bufferService.rows-1)})}print(t,e,s){let i,r,o=this._charsetService.charset,a=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,d=this._coreService.modes.insertMode,h=this._curAttrData,u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-e>0&&u.getWidth(this._activeBuffer.x-1)===2&&u.setCellFromCodepoint(this._activeBuffer.x-1,0,1,h);let f=this._parser.precedingJoinState;for(let m=e;m<s;++m){if(i=t[m],i<127&&o){let v=o[String.fromCharCode(i)];v&&(i=v.charCodeAt(0))}let p=this._unicodeService.charProperties(i,f);r=pi.extractWidth(p);let g=pi.extractShouldJoin(p),L=g?pi.extractWidth(f):0;if(f=p,a&&this._onA11yChar.fire(Gs(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-L>l){if(c){let v=u,y=this._activeBuffer.x-L;for(this._activeBuffer.x=L,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),L>0&&u instanceof Mn&&u.copyCellsFrom(v,y,0,L,!1);y<l;)v.setCellFromCodepoint(y++,0,1,h)}else if(this._activeBuffer.x=l-1,r===2)continue}if(g&&this._activeBuffer.x){let v=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-v,i,r);for(let y=r-L;--y>=0;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,h);continue}if(d&&(u.insertCells(this._activeBuffer.x,r-L,this._activeBuffer.getNullCell(h)),u.getWidth(l-1)===2&&u.setCellFromCodepoint(l-1,0,1,h)),u.setCellFromCodepoint(this._activeBuffer.x++,i,r,h),r>0)for(;--r;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,h)}this._parser.precedingJoinState=f,this._activeBuffer.x<l&&s-e>0&&u.getWidth(this._activeBuffer.x)===0&&!u.hasContent(this._activeBuffer.x)&&u.setCellFromCodepoint(this._activeBuffer.x,0,1,h),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(t,e){return t.final==="t"&&!t.prefix&&!t.intermediates?this._parser.registerCsiHandler(t,s=>dd(s.params[0],this._optionsService.rawOptions.windowOptions)?e(s):!0):this._parser.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._parser.registerDcsHandler(t,new ad(e))}registerEscHandler(t,e){return this._parser.registerEscHandler(t,e)}registerOscHandler(t,e){return this._parser.registerOscHandler(t,new Ft(e))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-t),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(t=this._bufferService.cols-1){this._activeBuffer.x=Math.min(t,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(t,e){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=t,this._activeBuffer.y=this._activeBuffer.scrollTop+e):(this._activeBuffer.x=t,this._activeBuffer.y=e),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(t,e){this._restrictCursor(),this._setCursor(this._activeBuffer.x+t,this._activeBuffer.y+e)}cursorUp(t){let e=this._activeBuffer.y-this._activeBuffer.scrollTop;return e>=0?this._moveCursor(0,-Math.min(e,t.params[0]||1)):this._moveCursor(0,-(t.params[0]||1)),!0}cursorDown(t){let e=this._activeBuffer.scrollBottom-this._activeBuffer.y;return e>=0?this._moveCursor(0,Math.min(e,t.params[0]||1)):this._moveCursor(0,t.params[0]||1),!0}cursorForward(t){return this._moveCursor(t.params[0]||1,0),!0}cursorBackward(t){return this._moveCursor(-(t.params[0]||1),0),!0}cursorNextLine(t){return this.cursorDown(t),this._activeBuffer.x=0,!0}cursorPrecedingLine(t){return this.cursorUp(t),this._activeBuffer.x=0,!0}cursorCharAbsolute(t){return this._setCursor((t.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(t){return this._setCursor(t.length>=2?(t.params[1]||1)-1:0,(t.params[0]||1)-1),!0}charPosAbsolute(t){return this._setCursor((t.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(t){return this._moveCursor(t.params[0]||1,0),!0}linePosAbsolute(t){return this._setCursor(this._activeBuffer.x,(t.params[0]||1)-1),!0}vPositionRelative(t){return this._moveCursor(0,t.params[0]||1),!0}hVPosition(t){return this.cursorPosition(t),!0}tabClear(t){let e=t.params[0];return e===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:e===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=t.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=t.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(t){let e=t.params[0];return e===1&&(this._curAttrData.bg|=536870912),(e===2||e===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(t,e,s,i=!1,r=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);o.replaceCells(e,s,this._activeBuffer.getNullCell(this._eraseAttrData()),r),i&&(o.isWrapped=!1)}_resetBufferLine(t,e=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),e),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+t),s.isWrapped=!1)}eraseInDisplay(t,e=!1){this._restrictCursor(this._bufferService.cols);let s;switch(t.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);s<this._bufferService.rows;s++)this._resetBufferLine(s,e);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,e),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,e);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+s)?.getTrimmedLength(););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,e);this._dirtyRowTracker.markDirty(0)}break;case 3:let i=this._activeBuffer.lines.length-this._bufferService.rows;i>0&&(this._activeBuffer.lines.trimStart(i),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-i,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-i,0),this._onScroll.fire(0));break}return!0}eraseInLine(t,e=!1){switch(this._restrictCursor(this._bufferService.cols),t.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,e);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,e);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(t){this._restrictCursor();let e=t.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-i+1;for(;e--;)this._activeBuffer.lines.splice(r-1,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(t){this._restrictCursor();let e=t.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i;for(i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-i;e--;)this._activeBuffer.lines.splice(s,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.insertCells(this._activeBuffer.x,t.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.deleteCells(this._activeBuffer.x,t.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(t){let e=t.params[0]||1;for(;e--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(t){let e=t.params[0]||1;for(;e--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(ft));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(t.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(t){let e=this._parser.precedingJoinState;if(!e)return!0;let s=t.params[0]||1,i=pi.extractWidth(e),r=this._activeBuffer.x-i,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),a=new Uint32Array(o.length*s),l=0;for(let d=0;d<o.length;){let h=o.codePointAt(d)||0;a[l++]=h,d+=h>65535?2:1}let c=l;for(let d=1;d<s;++d)a.copyWithin(c,0,l),c+=l;return this.print(a,0,c),!0}sendDeviceAttributesPrimary(t){return t.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(de.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(de.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(t){return t.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(de.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(de.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(t.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(de.ESC+"[>83;40003;0c")),!0}_is(t){return(this._optionsService.rawOptions.termName+"").indexOf(t)===0}setMode(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,fi),this._charsetService.setgCharset(1,fi),this._charsetService.setgCharset(2,fi),this._charsetService.setgCharset(3,fi);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),t.params[e]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(t,e){let s;(g=>(g[g.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",g[g.SET=1]="SET",g[g.RESET=2]="RESET",g[g.PERMANENTLY_SET=3]="PERMANENTLY_SET",g[g.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(s||={});let i=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:o}=this._coreMouseService,a=this._coreService,{buffers:l,cols:c}=this._bufferService,{active:d,alt:h}=l,u=this._optionsService.rawOptions,f=(g,L)=>(a.triggerDataEvent(`${de.ESC}[${e?"":"?"}${g};${L}$y`),!0),m=g=>g?1:2,p=t.params[0];return e?p===2?f(p,4):p===4?f(p,m(a.modes.insertMode)):p===12?f(p,3):p===20?f(p,m(u.convertEol)):f(p,0):p===1?f(p,m(i.applicationCursorKeys)):p===3?f(p,u.windowOptions.setWinLines?c===80?2:c===132?1:0:0):p===6?f(p,m(i.origin)):p===7?f(p,m(i.wraparound)):p===8?f(p,3):p===9?f(p,m(r==="X10")):p===12?f(p,m(u.cursorBlink)):p===25?f(p,m(!a.isCursorHidden)):p===45?f(p,m(i.reverseWraparound)):p===66?f(p,m(i.applicationKeypad)):p===67?f(p,4):p===1e3?f(p,m(r==="VT200")):p===1002?f(p,m(r==="DRAG")):p===1003?f(p,m(r==="ANY")):p===1004?f(p,m(i.sendFocus)):p===1005?f(p,4):p===1006?f(p,m(o==="SGR")):p===1015?f(p,4):p===1016?f(p,m(o==="SGR_PIXELS")):p===1048?f(p,1):p===47||p===1047||p===1049?f(p,m(d===h)):p===2004?f(p,m(i.bracketedPasteMode)):p===2026?f(p,m(i.synchronizedOutput)):f(p,0)}_updateAttrColor(t,e,s,i,r){return e===2?(t|=50331648,t&=-16777216,t|=mr.fromColorRGB([s,i,r])):e===5&&(t&=-50331904,t|=33554432|s&255),t}_extractColor(t,e,s){let i=[0,0,-1,0,0,0],r=0,o=0;do{if(i[o+r]=t.params[e+o],t.hasSubParams(e+o)){let a=t.getSubParams(e+o),l=0;do i[1]===5&&(r=1),i[o+l+1+r]=a[l];while(++l<a.length&&l+o+1+r<i.length);break}if(i[1]===5&&o+r>=2||i[1]===2&&o+r>=5)break;i[1]&&(r=1)}while(++o+e<t.length&&o+r<i.length);for(let a=2;a<i.length;++a)i[a]===-1&&(i[a]=0);switch(i[0]){case 38:s.fg=this._updateAttrColor(s.fg,i[1],i[3],i[4],i[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,i[1],i[3],i[4],i[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,i[1],i[3],i[4],i[5])}return o}_processUnderline(t,e){e.extended=e.extended.clone(),(!~t||t>5)&&(t=1),e.extended.underlineStyle=t,e.fg|=268435456,t===0&&(e.fg&=-268435457),e.updateExtended()}_processSGR0(t){t.fg=ft.fg,t.bg=ft.bg,t.extended=t.extended.clone(),t.extended.underlineStyle=0,t.extended.underlineColor&=-67108864,t.updateExtended()}charAttributes(t){if(t.length===1&&t.params[0]===0)return this._processSGR0(this._curAttrData),!0;let e=t.length,s,i=this._curAttrData;for(let r=0;r<e;r++)s=t.params[r],s>=30&&s<=37?(i.fg&=-50331904,i.fg|=16777216|s-30):s>=40&&s<=47?(i.bg&=-50331904,i.bg|=16777216|s-40):s>=90&&s<=97?(i.fg&=-50331904,i.fg|=16777216|s-90|8):s>=100&&s<=107?(i.bg&=-50331904,i.bg|=16777216|s-100|8):s===0?this._processSGR0(i):s===1?i.fg|=134217728:s===3?i.bg|=67108864:s===4?(i.fg|=268435456,this._processUnderline(t.hasSubParams(r)?t.getSubParams(r)[0]:1,i)):s===5?i.fg|=536870912:s===7?i.fg|=67108864:s===8?i.fg|=1073741824:s===9?i.fg|=2147483648:s===2?i.bg|=134217728:s===21?this._processUnderline(2,i):s===22?(i.fg&=-134217729,i.bg&=-134217729):s===23?i.bg&=-67108865:s===24?(i.fg&=-268435457,this._processUnderline(0,i)):s===25?i.fg&=-536870913:s===27?i.fg&=-67108865:s===28?i.fg&=-1073741825:s===29?i.fg&=2147483647:s===39?(i.fg&=-67108864,i.fg|=ft.fg&16777215):s===49?(i.bg&=-67108864,i.bg|=ft.bg&16777215):s===38||s===48||s===58?r+=this._extractColor(t,r,i):s===53?i.bg|=1073741824:s===55?i.bg&=-1073741825:s===59?(i.extended=i.extended.clone(),i.extended.underlineColor=-1,i.updateExtended()):s===100?(i.fg&=-67108864,i.fg|=ft.fg&16777215,i.bg&=-67108864,i.bg|=ft.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(t){switch(t.params[0]){case 5:this._coreService.triggerDataEvent(`${de.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${de.ESC}[${e};${s}R`);break}return!0}deviceStatusPrivate(t){if(t.params[0]===6){let e=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${de.ESC}[?${e};${s}R`)}return!0}softReset(t){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=ft.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(t){let e=t.length===0?1:t.params[0];if(e===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(e){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let s=e%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(t){let e=t.params[0]||1,s;return(t.length<2||(s=t.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>e&&(this._activeBuffer.scrollTop=e-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(t){if(!dd(t.params[0],this._optionsService.rawOptions.windowOptions))return!0;let e=t.length>1?t.params[1]:0;switch(t.params[0]){case 14:e!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${de.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(e===0||e===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>cd&&this._windowTitleStack.shift()),(e===0||e===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>cd&&this._iconNameStack.shift());break;case 23:(e===0||e===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(e===0||e===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(t){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(t){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(t){return this._windowTitle=t,this._onTitleChange.fire(t),!0}setIconName(t){return this._iconName=t,!0}setOrReportIndexedColor(t){let e=[],s=t.split(";");for(;s.length>1;){let i=s.shift(),r=s.shift();if(/^\d+$/.exec(i)){let o=parseInt(i);if(fd(o))if(r==="?")e.push({type:0,index:o});else{let a=ld(r);a&&e.push({type:1,index:o,color:a})}}}return e.length&&this._onColor.fire(e),!0}setHyperlink(t){let e=t.indexOf(";");if(e===-1)return!0;let s=t.slice(0,e).trim(),i=t.slice(e+1);return i?this._createHyperlink(s,i):s.trim()?!1:this._finishHyperlink()}_createHyperlink(t,e){this._getCurrentLinkId()&&this._finishHyperlink();let s=t.split(":"),i,r=s.findIndex(o=>o.startsWith("id="));return r!==-1&&(i=s[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i,uri:e}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(t,e){let s=t.split(";");for(let i=0;i<s.length&&!(e>=this._specialColors.length);++i,++e)if(s[i]==="?")this._onColor.fire([{type:0,index:this._specialColors[e]}]);else{let r=ld(s[i]);r&&this._onColor.fire([{type:1,index:this._specialColors[e],color:r}])}return!0}setOrReportFgColor(t){return this._setOrReportSpecialColor(t,0)}setOrReportBgColor(t){return this._setOrReportSpecialColor(t,1)}setOrReportCursorColor(t){return this._setOrReportSpecialColor(t,2)}restoreIndexedColor(t){if(!t)return this._onColor.fire([{type:2}]),!0;let e=[],s=t.split(";");for(let i=0;i<s.length;++i)if(/^\d+$/.exec(s[i])){let r=parseInt(s[i]);fd(r)&&e.push({type:2,index:r})}return e.length&&this._onColor.fire(e),!0}restoreFgColor(t){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(t){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(t){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,fi),!0}selectCharset(t){return t.length!==2?(this.selectDefaultCharset(),!0):(t[0]==="/"||this._charsetService.setgCharset(tw[t[0]],_t[t[1]]||fi),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let t=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,t,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=ft.clone(),this._eraseAttrDataInternal=ft.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(t){return this._charsetService.setgLevel(t),!0}screenAlignmentPattern(){let t=new ss;t.content=1<<22|69,t.fg=this._curAttrData.fg,t.bg=this._curAttrData.bg,this._setCursor(0,0);for(let e=0;e<this._bufferService.rows;++e){let s=this._activeBuffer.ybase+this._activeBuffer.y+e,i=this._activeBuffer.lines.get(s);i&&(i.fill(t),i.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(t,e){let s=a=>(this._coreService.triggerDataEvent(`${de.ESC}${a}${de.ESC}\\`),!0),i=this._bufferService.buffer,r=this._optionsService.rawOptions;return s(t==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:t==='"p'?'P1$r61;1"p':t==="r"?`P1$r${i.scrollTop+1};${i.scrollBottom+1}r`:t==="m"?"P1$r0m":t===" q"?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-(r.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(t,e){this._dirtyRowTracker.markRangeDirty(t,e)}},Dl=class{constructor(t){this._bufferService=t,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(t){t<this.start?this.start=t:t>this.end&&(this.end=t)}markRangeDirty(t,e){t>e&&(ud=t,t=e,e=ud),t<this.start&&(this.start=t),e>this.end&&(this.end=e)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Dl=dt([xe(0,Ot)],Dl);function fd(t){return 0<=t&&t<256}var iw=5e7,md=12,nw=50,rw=class extends ze{constructor(t){super(),this._action=t,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new ge),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(t,e){if(e!==void 0&&this._syncCalls>e){this._syncCalls=0;return}if(this._pendingData+=t.length,this._writeBuffer.push(t),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let s;for(;s=this._writeBuffer.shift();){this._action(s);let i=this._callbacks.shift();i&&i()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(t,e){if(this._pendingData>iw)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=t.length,this._writeBuffer.push(t),this._callbacks.push(e),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=t.length,this._writeBuffer.push(t),this._callbacks.push(e)}_innerWrite(t=0,e=!0){let s=t||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let i=this._writeBuffer[this._bufferOffset],r=this._action(i,e);if(r){let a=l=>performance.now()-s>=md?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(s,l);r.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(a);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=i.length,performance.now()-s>=md)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>nw&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},Il=class{constructor(t){this._bufferService=t,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(t){let e=this._bufferService.buffer;if(t.id===void 0){let l=e.addMarker(e.ybase+e.y),c={data:t,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(c,l)),this._dataByLinkId.set(c.id,c),c.id}let s=t,i=this._getEntryIdKey(s),r=this._entriesWithId.get(i);if(r)return this.addLineToLink(r.id,e.ybase+e.y),r.id;let o=e.addMarker(e.ybase+e.y),a={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(a,o)),this._entriesWithId.set(a.key,a),this._dataByLinkId.set(a.id,a),a.id}addLineToLink(t,e){let s=this._dataByLinkId.get(t);if(s&&s.lines.every(i=>i.line!==e)){let i=this._bufferService.buffer.addMarker(e);s.lines.push(i),i.onDispose(()=>this._removeMarkerFromLink(s,i))}}getLinkData(t){return this._dataByLinkId.get(t)?.data}_getEntryIdKey(t){return`${t.id};;${t.uri}`}_removeMarkerFromLink(t,e){let s=t.lines.indexOf(e);s!==-1&&(t.lines.splice(s,1),t.lines.length===0&&(t.data.id!==void 0&&this._entriesWithId.delete(t.key),this._dataByLinkId.delete(t.id)))}};Il=dt([xe(0,Ot)],Il);var pd=!1,ow=class extends ze{constructor(t){super(),this._windowsWrappingHeuristics=this._register(new on),this._onBinary=this._register(new ge),this.onBinary=this._onBinary.event,this._onData=this._register(new ge),this.onData=this._onData.event,this._onLineFeed=this._register(new ge),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new ge),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new ge),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new ge),this._instantiationService=new ES,this.optionsService=this._register(new zS(t)),this._instantiationService.setService(Mt,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(El)),this._instantiationService.setService(Ot,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Tl)),this._instantiationService.setService(U1,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Al)),this._instantiationService.setService(Bi,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Pl)),this._instantiationService.setService(H1,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(pi)),this._instantiationService.setService(jy,this.unicodeService),this._charsetService=this._instantiationService.createInstance(WS),this._instantiationService.setService(Cy,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Il),this._instantiationService.setService(K1,this._oscLinkService),this._inputHandler=this._register(new sw(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ct.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ct.forward(this._bufferService.onResize,this._onResize)),this._register(Ct.forward(this.coreService.onData,this._onData)),this._register(Ct.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new rw((e,s)=>this._inputHandler.parse(e,s))),this._register(Ct.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new ge),this._onScroll.event(t=>{this._onScrollApi?.fire(t.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(t){for(let e in t)this.optionsService.options[e]=t[e]}write(t,e){this._writeBuffer.write(t,e)}writeSync(t,e){this._logService.logLevel<=3&&!pd&&(this._logService.warn("writeSync is unreliable and will be removed soon."),pd=!0),this._writeBuffer.writeSync(t,e)}input(t,e=!0){this.coreService.triggerDataEvent(t,e)}resize(t,e){isNaN(t)||isNaN(e)||(t=Math.max(t,Sf),e=Math.max(e,wf),this._bufferService.resize(t,e))}scroll(t,e=!1){this._bufferService.scroll(t,e)}scrollLines(t,e){this._bufferService.scrollLines(t,e)}scrollPages(t){this.scrollLines(t*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(t){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(t){let e=t-this._bufferService.buffer.ydisp;e!==0&&this.scrollLines(e)}registerEscHandler(t,e){return this._inputHandler.registerEscHandler(t,e)}registerDcsHandler(t,e){return this._inputHandler.registerDcsHandler(t,e)}registerCsiHandler(t,e){return this._inputHandler.registerCsiHandler(t,e)}registerOscHandler(t,e){return this._inputHandler.registerOscHandler(t,e)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let t=!1,e=this.optionsService.rawOptions.windowsPty;e&&e.buildNumber!==void 0&&e.buildNumber!==void 0?t=e.backend==="conpty"&&e.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(t=!0),t?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let t=[];t.push(this.onLineFeed(od.bind(null,this._bufferService))),t.push(this.registerCsiHandler({final:"H"},()=>(od(this._bufferService),!1))),this._windowsWrappingHeuristics.value=st(()=>{for(let e of t)e.dispose()})}}},aw={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function lw(t,e,s,i){let r={type:0,cancel:!1,key:void 0},o=(t.shiftKey?1:0)|(t.altKey?2:0)|(t.ctrlKey?4:0)|(t.metaKey?8:0);switch(t.keyCode){case 0:t.key==="UIKeyInputUpArrow"?e?r.key=de.ESC+"OA":r.key=de.ESC+"[A":t.key==="UIKeyInputLeftArrow"?e?r.key=de.ESC+"OD":r.key=de.ESC+"[D":t.key==="UIKeyInputRightArrow"?e?r.key=de.ESC+"OC":r.key=de.ESC+"[C":t.key==="UIKeyInputDownArrow"&&(e?r.key=de.ESC+"OB":r.key=de.ESC+"[B");break;case 8:r.key=t.ctrlKey?"\b":de.DEL,t.altKey&&(r.key=de.ESC+r.key);break;case 9:if(t.shiftKey){r.key=de.ESC+"[Z";break}r.key=de.HT,r.cancel=!0;break;case 13:r.key=t.altKey?de.ESC+de.CR:de.CR,r.cancel=!0;break;case 27:r.key=de.ESC,t.altKey&&(r.key=de.ESC+de.ESC),r.cancel=!0;break;case 37:if(t.metaKey)break;o?r.key=de.ESC+"[1;"+(o+1)+"D":e?r.key=de.ESC+"OD":r.key=de.ESC+"[D";break;case 39:if(t.metaKey)break;o?r.key=de.ESC+"[1;"+(o+1)+"C":e?r.key=de.ESC+"OC":r.key=de.ESC+"[C";break;case 38:if(t.metaKey)break;o?r.key=de.ESC+"[1;"+(o+1)+"A":e?r.key=de.ESC+"OA":r.key=de.ESC+"[A";break;case 40:if(t.metaKey)break;o?r.key=de.ESC+"[1;"+(o+1)+"B":e?r.key=de.ESC+"OB":r.key=de.ESC+"[B";break;case 45:!t.shiftKey&&!t.ctrlKey&&(r.key=de.ESC+"[2~");break;case 46:o?r.key=de.ESC+"[3;"+(o+1)+"~":r.key=de.ESC+"[3~";break;case 36:o?r.key=de.ESC+"[1;"+(o+1)+"H":e?r.key=de.ESC+"OH":r.key=de.ESC+"[H";break;case 35:o?r.key=de.ESC+"[1;"+(o+1)+"F":e?r.key=de.ESC+"OF":r.key=de.ESC+"[F";break;case 33:t.shiftKey?r.type=2:t.ctrlKey?r.key=de.ESC+"[5;"+(o+1)+"~":r.key=de.ESC+"[5~";break;case 34:t.shiftKey?r.type=3:t.ctrlKey?r.key=de.ESC+"[6;"+(o+1)+"~":r.key=de.ESC+"[6~";break;case 112:o?r.key=de.ESC+"[1;"+(o+1)+"P":r.key=de.ESC+"OP";break;case 113:o?r.key=de.ESC+"[1;"+(o+1)+"Q":r.key=de.ESC+"OQ";break;case 114:o?r.key=de.ESC+"[1;"+(o+1)+"R":r.key=de.ESC+"OR";break;case 115:o?r.key=de.ESC+"[1;"+(o+1)+"S":r.key=de.ESC+"OS";break;case 116:o?r.key=de.ESC+"[15;"+(o+1)+"~":r.key=de.ESC+"[15~";break;case 117:o?r.key=de.ESC+"[17;"+(o+1)+"~":r.key=de.ESC+"[17~";break;case 118:o?r.key=de.ESC+"[18;"+(o+1)+"~":r.key=de.ESC+"[18~";break;case 119:o?r.key=de.ESC+"[19;"+(o+1)+"~":r.key=de.ESC+"[19~";break;case 120:o?r.key=de.ESC+"[20;"+(o+1)+"~":r.key=de.ESC+"[20~";break;case 121:o?r.key=de.ESC+"[21;"+(o+1)+"~":r.key=de.ESC+"[21~";break;case 122:o?r.key=de.ESC+"[23;"+(o+1)+"~":r.key=de.ESC+"[23~";break;case 123:o?r.key=de.ESC+"[24;"+(o+1)+"~":r.key=de.ESC+"[24~";break;default:if(t.ctrlKey&&!t.shiftKey&&!t.altKey&&!t.metaKey)t.keyCode>=65&&t.keyCode<=90?r.key=String.fromCharCode(t.keyCode-64):t.keyCode===32?r.key=de.NUL:t.keyCode>=51&&t.keyCode<=55?r.key=String.fromCharCode(t.keyCode-51+27):t.keyCode===56?r.key=de.DEL:t.keyCode===219?r.key=de.ESC:t.keyCode===220?r.key=de.FS:t.keyCode===221&&(r.key=de.GS);else if((!s||i)&&t.altKey&&!t.metaKey){let a=aw[t.keyCode]?.[t.shiftKey?1:0];if(a)r.key=de.ESC+a;else if(t.keyCode>=65&&t.keyCode<=90){let l=t.ctrlKey?t.keyCode-64:t.keyCode+32,c=String.fromCharCode(l);t.shiftKey&&(c=c.toUpperCase()),r.key=de.ESC+c}else if(t.keyCode===32)r.key=de.ESC+(t.ctrlKey?de.NUL:" ");else if(t.key==="Dead"&&t.code.startsWith("Key")){let l=t.code.slice(3,4);t.shiftKey||(l=l.toLowerCase()),r.key=de.ESC+l,r.cancel=!0}}else s&&!t.altKey&&!t.ctrlKey&&!t.shiftKey&&t.metaKey?t.keyCode===65&&(r.type=1):t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&t.keyCode>=48&&t.key.length===1?r.key=t.key:t.key&&t.ctrlKey&&(t.key==="_"&&(r.key=de.US),t.key==="@"&&(r.key=de.NUL));break}return r}var ht=0,cw=class{constructor(t){this._getKey=t,this._array=[],this._insertedValues=[],this._flushInsertedTask=new So,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new So,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(t){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(t)}_flushInserted(){let t=this._insertedValues.sort((r,o)=>this._getKey(r)-this._getKey(o)),e=0,s=0,i=new Array(this._array.length+this._insertedValues.length);for(let r=0;r<i.length;r++)s>=this._array.length||this._getKey(t[e])<=this._getKey(this._array[s])?(i[r]=t[e],e++):i[r]=this._array[s++];this._array=i,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(t){if(this._flushCleanupInserted(),this._array.length===0)return!1;let e=this._getKey(t);if(e===void 0||(ht=this._search(e),ht===-1)||this._getKey(this._array[ht])!==e)return!1;do if(this._array[ht]===t)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(ht),!0;while(++ht<this._array.length&&this._getKey(this._array[ht])===e);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let t=this._deletedIndices.sort((r,o)=>r-o),e=0,s=new Array(this._array.length-t.length),i=0;for(let r=0;r<this._array.length;r++)t[e]===r?e++:s[i++]=this._array[r];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ht=this._search(t),!(ht<0||ht>=this._array.length)&&this._getKey(this._array[ht])===t))do yield this._array[ht];while(++ht<this._array.length&&this._getKey(this._array[ht])===t)}forEachByKey(t,e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ht=this._search(t),!(ht<0||ht>=this._array.length)&&this._getKey(this._array[ht])===t))do e(this._array[ht]);while(++ht<this._array.length&&this._getKey(this._array[ht])===t)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(t){let e=0,s=this._array.length-1;for(;s>=e;){let i=e+s>>1,r=this._getKey(this._array[i]);if(r>t)s=i-1;else if(r<t)e=i+1;else{for(;i>0&&this._getKey(this._array[i-1])===t;)i--;return i}}return e}},Ia=0,gd=0,dw=class extends ze{constructor(){super(),this._decorations=new cw(t=>t?.marker.line),this._onDecorationRegistered=this._register(new ge),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new ge),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(st(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(t){if(t.marker.isDisposed)return;let e=new hw(t);if(e){let s=e.marker.onDispose(()=>e.dispose()),i=e.onDispose(()=>{i.dispose(),e&&(this._decorations.delete(e)&&this._onDecorationRemoved.fire(e),s.dispose())});this._decorations.insert(e),this._onDecorationRegistered.fire(e)}return e}reset(){for(let t of this._decorations.values())t.dispose();this._decorations.clear()}*getDecorationsAtCell(t,e,s){let i=0,r=0;for(let o of this._decorations.getKeyIterator(e))i=o.options.x??0,r=i+(o.options.width??1),t>=i&&t<r&&(!s||(o.options.layer??"bottom")===s)&&(yield o)}forEachDecorationAtCell(t,e,s,i){this._decorations.forEachByKey(e,r=>{Ia=r.options.x??0,gd=Ia+(r.options.width??1),t>=Ia&&t<gd&&(!s||(r.options.layer??"bottom")===s)&&i(r)})}},hw=class extends ei{constructor(t){super(),this.options=t,this.onRenderEmitter=this.add(new ge),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new ge),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=t.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=rt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=rt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},uw=1e3,fw=class{constructor(t,e=uw){this._renderCallback=t,this._debounceThresholdMS=e,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(t,e,s){this._rowCount=s,t=t!==void 0?t:0,e=e!==void 0?e:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,t):t,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,e):e;let i=performance.now();if(i-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=i,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=i-this._lastRefreshMs,o=this._debounceThresholdMS-r;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let t=Math.max(this._rowStart,0),e=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(t,e)}},_d=20,wo=class extends ze{constructor(t,e,s,i){super(),this._terminal=t,this._coreBrowserService=s,this._renderService=i,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let r=this._coreBrowserService.mainDocument;this._accessibilityContainer=r.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=r.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let o=0;o<this._terminal.rows;o++)this._rowElements[o]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[o]);if(this._topBoundaryFocusListener=o=>this._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=r.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new fw(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
509
|
-
`))),this._register(this._terminal.onA11yTab(o=>this._handleTab(o))),this._register(this._terminal.onKey(o=>this._handleKey(o.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(ke(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(st(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(t){for(let e=0;e<t;e++)this._handleChar(" ")}_handleChar(t){this._liveRegionLineCount<_d+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==t&&(this._charsToAnnounce+=t):this._charsToAnnounce+=t,t===`
|
|
510
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===_d+1&&(this._liveRegion.textContent+=tl.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(t){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(t)||this._charsToConsume.push(t)}_refreshRows(t,e){this._liveRegionDebouncer.refresh(t,e,this._terminal.rows)}_renderRows(t,e){let s=this._terminal.buffer,i=s.lines.length.toString();for(let r=t;r<=e;r++){let o=s.lines.get(s.ydisp+r),a=[],l=o?.translateToString(!0,void 0,void 0,a)||"",c=(s.ydisp+r+1).toString(),d=this._rowElements[r];d&&(l.length===0?(d.textContent=" ",this._rowColumns.set(d,[0,1])):(d.textContent=l,this._rowColumns.set(d,a)),d.setAttribute("aria-posinset",c),d.setAttribute("aria-setsize",i),this._alignRowWidth(d))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(t,e){let s=t.target,i=this._rowElements[e===0?1:this._rowElements.length-2],r=s.getAttribute("aria-posinset"),o=e===0?"1":`${this._terminal.buffer.lines.length}`;if(r===o||t.relatedTarget!==i)return;let a,l;if(e===0?(a=s,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(a=this._rowElements.shift(),l=s,this._rowContainer.removeChild(a)),a.removeEventListener("focus",this._topBoundaryFocusListener),l.removeEventListener("focus",this._bottomBoundaryFocusListener),e===0){let c=this._createAccessibilityTreeNode();this._rowElements.unshift(c),this._rowContainer.insertAdjacentElement("afterbegin",c)}else{let c=this._createAccessibilityTreeNode();this._rowElements.push(c),this._rowContainer.appendChild(c)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(e===0?-1:1),this._rowElements[e===0?1:this._rowElements.length-2].focus(),t.preventDefault(),t.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let t=this._coreBrowserService.mainDocument.getSelection();if(!t)return;if(t.isCollapsed){this._rowContainer.contains(t.anchorNode)&&this._terminal.clearSelection();return}if(!t.anchorNode||!t.focusNode){console.error("anchorNode and/or focusNode are null");return}let e={node:t.anchorNode,offset:t.anchorOffset},s={node:t.focusNode,offset:t.focusOffset};if((e.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||e.node===s.node&&e.offset>s.offset)&&([e,s]=[s,e]),e.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(e={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(e.node))return;let i=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(i)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:i,offset:i.textContent?.length??0}),!this._rowContainer.contains(s.node))return;let r=({node:l,offset:c})=>{let d=l instanceof Text?l.parentNode:l,h=parseInt(d?.getAttribute("aria-posinset"),10)-1;if(isNaN(h))return console.warn("row is invalid. Race condition?"),null;let u=this._rowColumns.get(d);if(!u)return console.warn("columns is null. Race condition?"),null;let f=c<u.length?u[c]:u.slice(-1)[0]+1;return f>=this._terminal.cols&&(++h,f=0),{row:h,column:f}},o=r(e),a=r(s);if(!(!o||!a)){if(o.row>a.row||o.row===a.row&&o.column>=a.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(a.row-o.row)*this._terminal.cols-o.column+a.column)}}_handleResize(t){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let t=this._coreBrowserService.mainDocument.createElement("div");return t.setAttribute("role","listitem"),t.tabIndex=-1,this._refreshRowDimensions(t),t}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let t=0;t<this._terminal.rows;t++)this._refreshRowDimensions(this._rowElements[t]),this._alignRowWidth(this._rowElements[t])}}_refreshRowDimensions(t){t.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(t){t.style.transform="";let e=t.getBoundingClientRect().width,s=this._rowColumns.get(t)?.slice(-1)?.[0];if(!s)return;let i=s*this._renderService.dimensions.css.cell.width;t.style.transform=`scaleX(${i/e})`}};wo=dt([xe(1,Wc),xe(2,zs),xe(3,Fs)],wo);var Ol=class extends ze{constructor(t,e,s,i,r){super(),this._element=t,this._mouseService=e,this._renderService=s,this._bufferService=i,this._linkProviderService=r,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new ge),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new ge),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(st(()=>{ji(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(ke(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(ke(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(ke(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(ke(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(t){this._lastMouseEvent=t;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);if(!e)return;this._isMouseOut=!1;let s=t.composedPath();for(let i=0;i<s.length;i++){let r=s[i];if(r.classList.contains("xterm"))break;if(r.classList.contains("xterm-hover"))return}(!this._lastBufferCell||e.x!==this._lastBufferCell.x||e.y!==this._lastBufferCell.y)&&(this._handleHover(e),this._lastBufferCell=e)}_handleHover(t){if(this._activeLine!==t.y||this._wasResized){this._clearCurrentLink(),this._askForLink(t,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,t)||(this._clearCurrentLink(),this._askForLink(t,!0))}_askForLink(t,e){(!this._activeProviderReplies||!e)&&(this._activeProviderReplies?.forEach(i=>{i?.forEach(r=>{r.link.dispose&&r.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=t.y);let s=!1;for(let[i,r]of this._linkProviderService.linkProviders.entries())e?this._activeProviderReplies?.get(i)&&(s=this._checkLinkProviderResult(i,t,s)):r.provideLinks(t.y,o=>{if(this._isMouseOut)return;let a=o?.map(l=>({link:l}));this._activeProviderReplies?.set(i,a),s=this._checkLinkProviderResult(i,t,s),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(t.y,this._activeProviderReplies)})}_removeIntersectingLinks(t,e){let s=new Set;for(let i=0;i<e.size;i++){let r=e.get(i);if(r)for(let o=0;o<r.length;o++){let a=r[o],l=a.link.range.start.y<t?0:a.link.range.start.x,c=a.link.range.end.y>t?this._bufferService.cols:a.link.range.end.x;for(let d=l;d<=c;d++){if(s.has(d)){r.splice(o--,1);break}s.add(d)}}}}_checkLinkProviderResult(t,e,s){if(!this._activeProviderReplies)return s;let i=this._activeProviderReplies.get(t),r=!1;for(let o=0;o<t;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(r=!0);if(!r&&i){let o=i.find(a=>this._linkAtPosition(a.link,e));o&&(s=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let o=0;o<this._activeProviderReplies.size;o++){let a=this._activeProviderReplies.get(o)?.find(l=>this._linkAtPosition(l.link,e));if(a){s=!0,this._handleNewLink(a);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(t){if(!this._currentLink)return;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);e&&this._mouseDownLink&&mw(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,e)&&this._currentLink.link.activate(t,this._currentLink.link.text)}_clearCurrentLink(t,e){!this._currentLink||!this._lastMouseEvent||(!t||!e||this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=e)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,ji(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(t){if(!this._lastMouseEvent)return;let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._linkAtPosition(t.link,e)&&(this._currentLink=t,this._currentLink.state={decorations:{underline:t.link.decorations===void 0?!0:t.link.decorations.underline,pointerCursor:t.link.decorations===void 0?!0:t.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,t.link,this._lastMouseEvent),t.link.decorations={},Object.defineProperties(t.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:s=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:s=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(t.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let i=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(i,r),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(t,e,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!0),this._currentLink.state.decorations.pointerCursor&&t.classList.add("xterm-cursor-pointer")),e.hover&&e.hover(s,e.text)}_fireUnderlineEvent(t,e){let s=t.range,i=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-i-1,s.end.x,s.end.y-i-1,void 0);(e?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(t,e,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!1),this._currentLink.state.decorations.pointerCursor&&t.classList.remove("xterm-cursor-pointer")),e.leave&&e.leave(s,e.text)}_linkAtPosition(t,e){let s=t.range.start.y*this._bufferService.cols+t.range.start.x,i=t.range.end.y*this._bufferService.cols+t.range.end.x,r=e.y*this._bufferService.cols+e.x;return s<=r&&r<=i}_positionFromMouseEvent(t,e,s){let i=s.getCoords(t,e,this._bufferService.cols,this._bufferService.rows);if(i)return{x:i[0],y:i[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(t,e,s,i,r){return{x1:t,y1:e,x2:s,y2:i,cols:this._bufferService.cols,fg:r}}};Ol=dt([xe(1,Vc),xe(2,Fs),xe(3,Ot),xe(4,V1)],Ol);function mw(t,e){return t.text===e.text&&t.range.start.x===e.range.start.x&&t.range.start.y===e.range.start.y&&t.range.end.x===e.range.end.x&&t.range.end.y===e.range.end.y}var pw=class extends ow{constructor(t={}){super(t),this._linkifier=this._register(new on),this.browser=uf,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new on),this._onCursorMove=this._register(new ge),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new ge),this.onKey=this._onKey.event,this._onRender=this._register(new ge),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new ge),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new ge),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new ge),this.onBell=this._onBell.event,this._onFocus=this._register(new ge),this._onBlur=this._register(new ge),this._onA11yCharEmitter=this._register(new ge),this._onA11yTabEmitter=this._register(new ge),this._onWillOpen=this._register(new ge),this._setup(),this._decorationService=this._instantiationService.createInstance(dw),this._instantiationService.setService(pr,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(nS),this._instantiationService.setService(V1,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(il)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(Ct.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ct.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ct.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ct.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(st(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(t){if(this._themeService)for(let e of t){let s,i="";switch(e.index){case 256:s="foreground",i="10";break;case 257:s="background",i="11";break;case 258:s="cursor",i="12";break;default:s="ansi",i="4;"+e.index}switch(e.type){case 0:let r=Qe.toColorRGB(s==="ansi"?this._themeService.colors.ansi[e.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${de.ESC}]${i};${ew(r)}${df.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[e.index]=mt.toColor(...e.color));else{let o=s;this._themeService.modifyColors(a=>a[o]=mt.toColor(...e.color))}break;case 2:this._themeService.restoreColor(e.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(t){t?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(wo,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(t){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(de.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(de.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let t=this.buffer.ybase+this.buffer.y,e=this.buffer.lines.get(t);if(!e)return;let s=Math.min(this.buffer.x,this.cols-1),i=this._renderService.dimensions.css.cell.height,r=e.getWidth(s),o=this._renderService.dimensions.css.cell.width*r,a=this.buffer.y*this._renderService.dimensions.css.cell.height,l=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=i+"px",this.textarea.style.lineHeight=i+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(ke(this.element,"copy",e=>{this.hasSelection()&&vy(e,this._selectionService)}));let t=e=>xy(e,this.textarea,this.coreService,this.optionsService);this._register(ke(this.textarea,"paste",t)),this._register(ke(this.element,"paste",t)),ff?this._register(ke(this.element,"mousedown",e=>{e.button===2&&k0(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(ke(this.element,"contextmenu",e=>{k0(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),e9&&this._register(ke(this.element,"auxclick",e=>{e.button===1&&M1(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(ke(this.textarea,"keyup",t=>this._keyUp(t),!0)),this._register(ke(this.textarea,"keydown",t=>this._keyDown(t),!0)),this._register(ke(this.textarea,"keypress",t=>this._keyPress(t),!0)),this._register(ke(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(ke(this.textarea,"compositionupdate",t=>this._compositionHelper.compositionupdate(t))),this._register(ke(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(ke(this.textarea,"input",t=>this._inputEvent(t),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(t){if(!t)throw new Error("Terminal requires a parent element.");if(t.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=t.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),t.appendChild(this.element);let e=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),e.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(ke(this.screenElement,"mousemove",r=>this.updateCursorStyle(r))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),e.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",el.get()),gf||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(sS,this.textarea,t.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(zs,this._coreBrowserService),this._register(ke(this.textarea,"focus",r=>this._handleTextAreaFocus(r))),this._register(ke(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(wl,this._document,this._helperContainer),this._instantiationService.setService(Xo,this._charSizeService),this._themeService=this._instantiationService.createInstance(Nl),this._instantiationService.setService(gn,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(yo),this._instantiationService.setService(W1,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(jl,this.rows,this.screenElement)),this._instantiationService.setService(Fs,this._renderService),this._register(this._renderService.onRenderedViewportChange(r=>this._onRender.fire(r))),this.onResize(r=>this._renderService.resize(r.cols,r.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(yl,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Cl),this._instantiationService.setService(Vc,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(Ol,this.screenElement));this.element.appendChild(e);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(vl,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(r=>{super.scrollLines(r,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(kl,this.element,this.screenElement,i)),this._instantiationService.setService(Ny,this._selectionService),this._register(this._selectionService.onRequestScrollLines(r=>this.scrollLines(r.amount,r.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(r=>this._renderService.handleSelectionChanged(r.start,r.end,r.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(r=>{this.textarea.value=r,this.textarea.focus(),this.textarea.select()})),this._register(Ct.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(xl,this.screenElement)),this._register(ke(this.element,"mousedown",r=>this._selectionService.handleMouseDown(r))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(wo,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",r=>this._handleScreenReaderModeOptionChange(r))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(xo,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",r=>{!this._overviewRulerRenderer&&r&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(xo,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Sl,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let t=this,e=this.element;function s(o){let a=t._mouseService.getMouseReportCoords(o,t.screenElement);if(!a)return!1;let l,c;switch(o.overrideType||o.type){case"mousemove":c=32,o.buttons===void 0?(l=3,o.button!==void 0&&(l=o.button<3?o.button:3)):l=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":c=0,l=o.button<3?o.button:3;break;case"mousedown":c=1,l=o.button<3?o.button:3;break;case"wheel":if(t._customWheelEventHandler&&t._customWheelEventHandler(o)===!1)return!1;let d=o.deltaY;if(d===0||t.coreMouseService.consumeWheelEvent(o,t._renderService?.dimensions?.device?.cell?.height,t._coreBrowserService?.dpr)===0)return!1;c=d<0?0:1,l=4;break;default:return!1}return c===void 0||l===void 0||l>4?!1:t.coreMouseService.triggerMouseEvent({col:a.col,row:a.row,x:a.x,y:a.y,button:l,action:c,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let i={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:o=>(s(o),o.buttons||(this._document.removeEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.removeEventListener("mousemove",i.mousedrag)),this.cancel(o)),wheel:o=>(s(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&s(o)},mousemove:o=>{o.buttons||s(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),o&8?i.mousemove||(e.addEventListener("mousemove",r.mousemove),i.mousemove=r.mousemove):(e.removeEventListener("mousemove",i.mousemove),i.mousemove=null),o&16?i.wheel||(e.addEventListener("wheel",r.wheel,{passive:!1}),i.wheel=r.wheel):(e.removeEventListener("wheel",i.wheel),i.wheel=null),o&2?i.mouseup||(i.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",i.mouseup),i.mouseup=null),o&4?i.mousedrag||(i.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",i.mousedrag),i.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(ke(e,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return s(o),i.mouseup&&this._document.addEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.addEventListener("mousemove",i.mousedrag),this.cancel(o)})),this._register(ke(e,"wheel",o=>{if(!i.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(t.coreMouseService.consumeWheelEvent(o,t._renderService?.dimensions?.device?.cell?.height,t._coreBrowserService?.dpr)===0)return this.cancel(o,!0);let a=de.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(a,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(t,e){this._renderService?.refreshRows(t,e)}updateCursorStyle(t){this._selectionService?.shouldColumnSelect(t)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(t,e){this._viewport?this._viewport.scrollLines(t):super.scrollLines(t,e),this.refresh(0,this.rows-1)}scrollPages(t){this.scrollLines(t*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(t){t&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(t){let e=t-this._bufferService.buffer.ydisp;e!==0&&this.scrollLines(e)}paste(t){O1(t,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(t){this._customKeyEventHandler=t}attachCustomWheelEventHandler(t){this._customWheelEventHandler=t}registerLinkProvider(t){return this._linkProviderService.registerLinkProvider(t)}registerCharacterJoiner(t){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let e=this._characterJoinerService.register(t);return this.refresh(0,this.rows-1),e}deregisterCharacterJoiner(t){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(t)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(t){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+t)}registerDecoration(t){return this._decorationService.registerDecoration(t)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(t,e,s){this._selectionService.setSelection(t,e,s)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(t,e){this._selectionService?.selectLines(t,e)}_keyDown(t){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(t)===!1)return!1;let e=this.browser.isMac&&this.options.macOptionIsMeta&&t.altKey;if(!e&&!this._compositionHelper.keydown(t))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!e&&(t.key==="Dead"||t.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let s=lw(t,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(t),s.type===3||s.type===2){let i=this.rows-1;return this.scrollLines(s.type===2?-i:i),this.cancel(t,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,t)||(s.cancel&&this.cancel(t,!0),!s.key)||t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&t.key.length===1&&t.key.charCodeAt(0)>=65&&t.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((s.key===de.ETX||s.key===de.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:t}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||t.altKey||t.ctrlKey)return this.cancel(t,!0);this._keyDownHandled=!0}_isThirdLevelShift(t,e){let s=t.isMac&&!this.options.macOptionIsMeta&&e.altKey&&!e.ctrlKey&&!e.metaKey||t.isWindows&&e.altKey&&e.ctrlKey&&!e.metaKey||t.isWindows&&e.getModifierState("AltGraph");return e.type==="keypress"?s:s&&(!e.keyCode||e.keyCode>47)}_keyUp(t){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(t)===!1)&&(gw(t)||this.focus(),this.updateCursorStyle(t),this._keyPressHandled=!1)}_keyPress(t){let e;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(t)===!1)return!1;if(this.cancel(t),t.charCode)e=t.charCode;else if(t.which===null||t.which===void 0)e=t.keyCode;else if(t.which!==0&&t.charCode!==0)e=t.which;else return!1;return!e||(t.altKey||t.ctrlKey||t.metaKey)&&!this._isThirdLevelShift(this.browser,t)?!1:(e=String.fromCharCode(e),this._onKey.fire({key:e,domEvent:t}),this._showCursor(),this.coreService.triggerDataEvent(e,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(t){if(t.data&&t.inputType==="insertText"&&(!t.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let e=t.data;return this.coreService.triggerDataEvent(e,!0),this.cancel(t),!0}return!1}resize(t,e){if(t===this.cols&&e===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(t,e)}_afterResize(t,e){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let t=1;t<this.rows;t++)this.buffer.lines.push(this.buffer.getBlankLine(ft));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let t=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=t,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(de.ESC+"[I"):this.coreService.triggerDataEvent(de.ESC+"[O")}_reportWindowsOptions(t){if(this._renderService)switch(t){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${de.ESC}[4;${s};${e}t`);break;case 1:let i=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${de.ESC}[6;${r};${i}t`);break}}cancel(t,e){if(!(!this.options.cancelEvents&&!e))return t.preventDefault(),t.stopPropagation(),!1}};function gw(t){return t.keyCode===16||t.keyCode===17||t.keyCode===18}var _w=class{constructor(){this._addons=[]}dispose(){for(let t=this._addons.length-1;t>=0;t--)this._addons[t].instance.dispose()}loadAddon(t,e){let s={instance:e,dispose:e.dispose,isDisposed:!1};this._addons.push(s),e.dispose=()=>this._wrappedAddonDispose(s),e.activate(t)}_wrappedAddonDispose(t){if(t.isDisposed)return;let e=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===t){e=s;break}if(e===-1)throw new Error("Could not dispose an addon that has not been loaded");t.isDisposed=!0,t.dispose.apply(t.instance),this._addons.splice(e,1)}},Lw=class{constructor(t){this._line=t}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(t,e){if(!(t<0||t>=this._line.length))return e?(this._line.loadCell(t,e),e):this._line.loadCell(t,new ss)}translateToString(t,e,s){return this._line.translateToString(t,e,s)}},Ld=class{constructor(t,e){this._buffer=t,this.type=e}init(t){return this._buffer=t,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(t){let e=this._buffer.lines.get(t);if(e)return new Lw(e)}getNullCell(){return new ss}},vw=class extends ze{constructor(t){super(),this._core=t,this._onBufferChange=this._register(new ge),this.onBufferChange=this._onBufferChange.event,this._normal=new Ld(this._core.buffers.normal,"normal"),this._alternate=new Ld(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},xw=class{constructor(t){this._core=t}registerCsiHandler(t,e){return this._core.registerCsiHandler(t,s=>e(s.toArray()))}addCsiHandler(t,e){return this.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._core.registerDcsHandler(t,(s,i)=>e(s,i.toArray()))}addDcsHandler(t,e){return this.registerDcsHandler(t,e)}registerEscHandler(t,e){return this._core.registerEscHandler(t,e)}addEscHandler(t,e){return this.registerEscHandler(t,e)}registerOscHandler(t,e){return this._core.registerOscHandler(t,e)}addOscHandler(t,e){return this.registerOscHandler(t,e)}},yw=class{constructor(t){this._core=t}register(t){this._core.unicodeService.register(t)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(t){this._core.unicodeService.activeVersion=t}},bw=["cols","rows"],ys=0,Sw=class extends ze{constructor(t){super(),this._core=this._register(new pw(t)),this._addonManager=this._register(new _w),this._publicOptions={...this._core.options};let e=i=>this._core.options[i],s=(i,r)=>{this._checkReadonlyOptions(i),this._core.options[i]=r};for(let i in this._core.options){let r={get:e.bind(this,i),set:s.bind(this,i)};Object.defineProperty(this._publicOptions,i,r)}}_checkReadonlyOptions(t){if(bw.includes(t))throw new Error(`Option "${t}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new xw(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new yw(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new vw(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let t=this._core.coreService.decPrivateModes,e="none";switch(this._core.coreMouseService.activeProtocol){case"X10":e="x10";break;case"VT200":e="vt200";break;case"DRAG":e="drag";break;case"ANY":e="any";break}return{applicationCursorKeysMode:t.applicationCursorKeys,applicationKeypadMode:t.applicationKeypad,bracketedPasteMode:t.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:e,originMode:t.origin,reverseWraparoundMode:t.reverseWraparound,sendFocusMode:t.sendFocus,synchronizedOutputMode:t.synchronizedOutput,wraparoundMode:t.wraparound}}get options(){return this._publicOptions}set options(t){for(let e in t)this._publicOptions[e]=t[e]}blur(){this._core.blur()}focus(){this._core.focus()}input(t,e=!0){this._core.input(t,e)}resize(t,e){this._verifyIntegers(t,e),this._core.resize(t,e)}open(t){this._core.open(t)}attachCustomKeyEventHandler(t){this._core.attachCustomKeyEventHandler(t)}attachCustomWheelEventHandler(t){this._core.attachCustomWheelEventHandler(t)}registerLinkProvider(t){return this._core.registerLinkProvider(t)}registerCharacterJoiner(t){return this._checkProposedApi(),this._core.registerCharacterJoiner(t)}deregisterCharacterJoiner(t){this._checkProposedApi(),this._core.deregisterCharacterJoiner(t)}registerMarker(t=0){return this._verifyIntegers(t),this._core.registerMarker(t)}registerDecoration(t){return this._checkProposedApi(),this._verifyPositiveIntegers(t.x??0,t.width??0,t.height??0),this._core.registerDecoration(t)}hasSelection(){return this._core.hasSelection()}select(t,e,s){this._verifyIntegers(t,e,s),this._core.select(t,e,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(t,e){this._verifyIntegers(t,e),this._core.selectLines(t,e)}dispose(){super.dispose()}scrollLines(t){this._verifyIntegers(t),this._core.scrollLines(t)}scrollPages(t){this._verifyIntegers(t),this._core.scrollPages(t)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(t){this._verifyIntegers(t),this._core.scrollToLine(t)}clear(){this._core.clear()}write(t,e){this._core.write(t,e)}writeln(t,e){this._core.write(t),this._core.write(`\r
|
|
511
|
-
`,e)}paste(t){this._core.paste(t)}refresh(t,e){this._verifyIntegers(t,e),this._core.refresh(t,e)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(t){this._addonManager.loadAddon(this,t)}static get strings(){return{get promptLabel(){return el.get()},set promptLabel(t){el.set(t)},get tooMuchOutput(){return tl.get()},set tooMuchOutput(t){tl.set(t)}}}_verifyIntegers(...t){for(ys of t)if(ys===1/0||isNaN(ys)||ys%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(ys of t)if(ys&&(ys===1/0||isNaN(ys)||ys%1!==0||ys<0))throw new Error("This API only accepts positive integers")}};var ww=2,Cw=1,jw=class{activate(t){this._terminal=t}dispose(){}fit(){let t=this.proposeDimensions();if(!t||!this._terminal||isNaN(t.cols)||isNaN(t.rows))return;let e=this._terminal._core;(this._terminal.rows!==t.rows||this._terminal.cols!==t.cols)&&(e._renderService.clear(),this._terminal.resize(t.cols,t.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let t=this._terminal._core._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let e=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),i=parseInt(s.getPropertyValue("height")),r=Math.max(0,parseInt(s.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),a={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},l=a.top+a.bottom,c=a.right+a.left,d=i-l,h=r-c-e;return{cols:Math.max(ww,Math.floor(h/t.css.cell.width)),rows:Math.max(Cw,Math.floor(d/t.css.cell.height))}}};function kw({source:t,onReady:e,onSelectionChange:s,className:i}){const r=R.useRef(null),o=R.useRef(null),a=R.useRef(s);a.current=s;const l=As(),c=R.useRef(t);return c.current=t,Xh((d,h)=>{d===c.current&&o.current?.write(h)}),R.useEffect(()=>{const d=r.current;if(!d)return;const h=getComputedStyle(document.documentElement),u=v=>h.getPropertyValue(v).trim()||void 0,f=new Sw({allowTransparency:!1,fontFamily:u("--font-mono")||"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:12.5,lineHeight:1.5,scrollback:5e3,cursorBlink:!1,disableStdin:!0,theme:{background:u("--sidebar")||u("--card")||u("--background")||"#1e1e1e",cursor:"transparent",foreground:u("--foreground")||"#d4d4d4",selectionBackground:u("--accent"),selectionForeground:u("--accent-foreground"),black:u("--muted"),red:u("--destructive"),green:u("--success"),yellow:u("--warning"),blue:u("--chart-1"),magenta:u("--chart-3"),cyan:u("--chart-5"),white:u("--foreground"),brightBlack:u("--muted-foreground"),brightRed:u("--destructive"),brightGreen:u("--success"),brightYellow:u("--warning"),brightBlue:u("--chart-1"),brightMagenta:u("--chart-3"),brightCyan:u("--chart-5"),brightWhite:u("--foreground")}}),m=new jw;f.loadAddon(m),f.open(d),m.fit();const p=l.getBuffer(t);p&&f.write(p),o.current=f,e?.(f);const g=f.onSelectionChange(()=>{const v=!!f.getSelection();a.current?.(v,()=>f.getSelection())}),L=new ResizeObserver(()=>{m.fit()});return L.observe(d),()=>{g.dispose(),L.disconnect(),o.current=null,f.dispose()}},[]),n.jsx("div",{className:ce("h-full bg-sidebar p-3",i),children:n.jsx("div",{ref:r,className:"h-full"})})}function Nw(t){const e=As(),[s,i]=R.useState(_i),[r,o]=R.useState([]),[a,l]=R.useState(new Set),c=R.useRef(!1);if(!c.current&&e.scripts.length>0){const x=Ep.find(b=>e.scripts.includes(b));x&&(c.current=!0,o(b=>b.includes(x)?b:[...b,x]),i(x))}if(a.size>0){let x=!1;const b=new Set(a);for(const S of a)e.activeProcesses.includes(S)||(b.delete(S),x=!0);x&&l(b)}const d=()=>t.onOpenChange(!t.open),h=x=>{i(x),t.open||t.onOpenChange(!0)},u=x=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(`/api/${encodeURIComponent(t.orgSlug)}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/exec/${encodeURIComponent(x)}`,{method:"POST"}),f=x=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(`/api/${encodeURIComponent(t.orgSlug)}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/exec/${encodeURIComponent(x)}/kill`,{method:"POST"}),m=async x=>{o(b=>b.includes(x)?b:[...b,x]),i(x),t.onOpenChange(!0);try{const b=await u(x);if(b===null)return;if(!b.ok)throw new Error(`Exec failed: ${b.statusText}`)}catch{me.error("Failed to run "+x)}},p=async x=>{await f(x),o(b=>b.filter(S=>S!==x)),s===x&&i(_i)},g=async()=>{const x=e.activeProcesses.includes(s);try{const b=await u(s);if(b===null)return;if(!b.ok)throw new Error(`Exec failed: ${b.statusText}`)}catch{me.error((x?"Failed to restart ":"Failed to run ")+s)}},L=async()=>{if(!a.has(s)){l(x=>new Set(x).add(s));try{const x=await f(s);if(x===null){l(b=>{const S=new Set(b);return S.delete(s),S});return}if(!x.ok)throw new Error(`Kill failed: ${x.statusText}`)}catch{l(x=>{const b=new Set(x);return b.delete(s),b}),me.error("Failed to stop "+s)}}},v=s!==_i&&r.includes(s),y=v&&e.activeProcesses.includes(s),_=v&&a.has(s);return n.jsxs("div",{className:"flex shrink-0 flex-col",style:{height:t.open?"50%":"auto"},children:[n.jsx(cy,{status:t.status,open:t.open,onToggle:d,onStart:t.status==="idle"?t.onStart:void 0,onStop:t.status==="running"||t.status==="starting"?t.onStop:void 0,onRestart:t.status==="running"?t.onRestart:void 0,onResume:t.status==="suspended"?t.onResume:void 0,onRetry:t.status==="errored"?t.onRetry:void 0,scripts:t.scripts,active:s,scriptTabs:r,onSelectTab:h,onAddScript:m,onCloseScript:p,showScriptControls:v,scriptIsRunning:y,scriptIsKilling:_,onRunActiveScript:g,onStopActiveScript:L}),t.open&&n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(Tw,{vmId:t.vmId,active:s,hasData:e.hasData(s),onRunActive:g})})]})}function Tw(t){const e=U.c(10),{vmId:s,active:i,hasData:r,onRunActive:o}=t;if(!s)return null;if(i===_i||r){let h;return e[0]!==i?(h=n.jsx(kw,{source:i,className:"h-full"},i),e[0]=i,e[1]=h):h=e[1],h}let a;e[2]!==i?(a=n.jsxs("p",{children:['Script "',n.jsx("span",{className:"font-mono text-foreground",children:i}),'" not running']}),e[2]=i,e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(xi,{className:"size-3.5"}),e[4]=l):l=e[4];let c;e[5]!==o?(c=n.jsxs("button",{type:"button",onClick:o,className:"flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground hover:bg-accent",children:[l," Run"]}),e[5]=o,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 text-sm text-muted-foreground",children:[a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d}const jf=t=>`preview-drawer:${t}`,Ew=/Authentication failed for|Invalid username or token|Password authentication is not supported/i;function Aw(t){try{const e=localStorage.getItem(jf(t));return e?!!JSON.parse(e).open:!1}catch{return!1}}function Pw(t,e){try{localStorage.setItem(jf(t),JSON.stringify({open:e}))}catch{}}function Rw(){const t=U.c(21),e=li(),{org:s}=Ge(),i=e?.virtualMcpId??null,r=wc(),o=As(),a=R.useRef(null);let l;t[0]!==o||t[1]!==r||t[2]!==i?(l=y=>{y!=="setup"||!i||a.current!==i&&Ew.test(o.getBuffer("setup"))&&(a.current=i,r.restart())},t[0]=o,t[1]=r,t[2]=i,t[3]=l):l=t[3],Xh(l);const c=i??"__no-vmcp__",[d,h]=R.useState(null),u=R.useRef(null);u.current!==c&&(u.current=c,h(Aw(c)));const f=d??!1;let m;t[4]!==c?(m=y=>{h(y),Pw(c,y)},t[4]=c,t[5]=m):m=t[5];const p=m,g=r.vmEntry?.sandboxHandle??"no-vm",L=r.vmEntry?.sandboxHandle??null;let v;return t[6]!==o.scripts||t[7]!==p||t[8]!==r.branch||t[9]!==r.restart||t[10]!==r.resume||t[11]!==r.retry||t[12]!==r.start||t[13]!==r.status||t[14]!==r.stop||t[15]!==f||t[16]!==s.slug||t[17]!==g||t[18]!==L||t[19]!==i?(v=n.jsx(Nw,{vmId:L,orgSlug:s.slug,virtualMcpId:i,branch:r.branch,status:r.status,scripts:o.scripts,open:f,onOpenChange:p,onStart:r.start,onStop:r.stop,onRestart:r.restart,onResume:r.resume,onRetry:r.retry},g),t[6]=o.scripts,t[7]=p,t[8]=r.branch,t[9]=r.restart,t[10]=r.resume,t[11]=r.retry,t[12]=r.start,t[13]=r.status,t[14]=r.stop,t[15]=f,t[16]=s.slug,t[17]=g,t[18]=L,t[19]=i,t[20]=v):v=t[20],v}function kf(t){const e=U.c(10),{virtualMcpId:s,taskId:i}=t,o=li()?.entity?.metadata;let a;e[0]!==o?(a=vi(o),e[0]=o,e[1]=a):a=e[1];const l=a;let c;e[2]!==i||e[3]!==s?(c=n.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.jsx(ly,{taskId:i,virtualMcpId:s})}),e[2]=i,e[3]=s,e[4]=c):c=e[4];let d;e[5]!==l?(d=l&&n.jsx(Rw,{}),e[5]=l,e[6]=d):d=e[6];let h;return e[7]!==c||e[8]!==d?(h=n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[c,d]}),e[7]=c,e[8]=d,e[9]=h):h=e[9],h}function Dw(t){const e=U.c(9),{children:s,defaultSize:i,chatOpen:r,chatPanelWidth:o,onChatPanelResize:a}=t,[,l]=R.useTransition(),c=i>0&&i<100?o:i;let d;e[0]!==a?(d=p=>l(()=>{p>0&&p<100&&a(p)}),e[0]=a,e[1]=d):d=e[1];const h=d,u=r?"min-w-[348px]":"min-w-0";let f;e[2]!==u?(f=ce("overflow-hidden bg-sidebar",u),e[2]=u,e[3]=f):f=e[3];let m;return e[4]!==s||e[5]!==c||e[6]!==h||e[7]!==f?(m=n.jsx(hh,{defaultSize:c,minSize:20,collapsible:!0,collapsedSize:0,className:f,onResize:h,order:1,children:s}),e[4]=s,e[5]=c,e[6]=h,e[7]=f,e[8]=m):m=e[8],m}function Iw(t){const e=U.c(2);let s;return e[0]!==t?(s=n.jsx(g_,{children:n.jsx(Ow,{...t})}),e[0]=t,e[1]=s):s=e[1],s}function Ow({virtualMcpId:t,taskId:e,chatOpen:s,mainOpen:i,chatContent:r}){const o=_9(s,i),[a,l]=Sp(),c=R.useRef(null),d=ku(),{width:h,dividerProps:u}=Nu();return R.useEffect(()=>{const f=c.current;if(!f)return;const m=_9(s,i),p=m.chat>0&&m.chat<100?a:m.chat,g=m.chat>0&&m.chat<100?100-a:m.main;f.setLayout([p,g])},[s,i,a]),n.jsxs(Xm,{ref:c,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:{overflow:"visible"},children:[n.jsx(Dw,{defaultSize:o.chat,chatOpen:s,chatPanelWidth:a,onChatPanelResize:l,children:n.jsx("div",{className:"h-full p-0.5 pt-0.25",children:n.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:r??n.jsx(Nh,{})})})}),n.jsx(Zm,{className:"bg-sidebar"}),n.jsx(hh,{className:"min-w-0 flex flex-col",order:2,defaultSize:o.main,style:{overflow:"visible"},collapsible:!0,collapsedSize:0,minSize:20,children:n.jsxs("div",{className:"h-full flex min-w-0",children:[d?.open&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"h-full shrink-0",style:{width:h},children:n.jsx("div",{className:"h-full p-0.5 pt-0.25",children:n.jsx("div",{ref:d.setSlotEl,className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow"})})}),n.jsx("div",{className:"relative w-0 shrink-0 bg-sidebar hover:bg-border transition-colors",children:n.jsx("div",{className:"absolute inset-y-0 -left-1 -right-1 cursor-col-resize",...u})})]}),n.jsx("div",{className:"h-full flex-1 min-w-0 p-0.5 pt-0.25",children:n.jsx("div",{className:ce("flex flex-col h-full min-h-0 bg-background overflow-hidden","card-shadow","transition-[border-radius] duration-200 ease-[var(--ease-out-quart)]","rounded-[0.75rem]"),children:n.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.jsx(kf,{taskId:e,virtualMcpId:t})})})})]})})]},`${t}-${e}`)}function vd(t){const e=U.c(12),{chatOpen:s,toggleChat:i,disableChatToggle:r}=t,o=r===void 0?!1:r;let a;e[0]!==s||e[1]!==o||e[2]!==i?(a=()=>{o||(Ze("agent_toolbar_toggled",{button:"chat",next_state:s?"closed":"open"}),i())},e[0]=s,e[1]=o,e[2]=i,e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(J2,{size:16}),e[4]=l):l=e[4];let c;e[5]!==s||e[6]!==o||e[7]!==a?(c=n.jsx(Ee,{asChild:!0,children:n.jsx(An,{onClick:a,disabled:o,"aria-pressed":s,"aria-label":"Chat",active:s,children:l})}),e[5]=s,e[6]=o,e[7]=a,e[8]=c):c=e[8];let d;e[9]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Ae,{side:"bottom",children:"Chat"}),e[9]=d):d=e[9];let h;return e[10]!==c?(h=n.jsxs(Pe,{delayDuration:300,children:[c,d]}),e[10]=c,e[11]=h):h=e[11],h}function Mw(t,e,s){if(t.length<=s)return{visible:t,overflow:[]};const i=t.slice(0,s),r=t.slice(s);if(e==null)return{visible:i,overflow:r};if(i.some(u=>u.id===e))return{visible:i,overflow:r};const a=r.findIndex(u=>u.id===e);if(a===-1)return{visible:i,overflow:r};const l=i[i.length-1],c=r[a],d=[...i.slice(0,-1),c],h=[l,...r.slice(0,a),...r.slice(a+1)];return{visible:d,overflow:h}}function Bw(t){const e=U.c(13),{overflow:s,onSelect:i}=t,[r,o]=R.useState(!1);let a;e[0]!==i?(a=f=>{o(!1),i(f)},e[0]=i,e[1]=a):a=e[1];const l=a;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(ps,{asChild:!0,children:n.jsx("button",{type:"button",title:"More tabs","aria-label":"More tabs",className:"shrink-0 flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",children:n.jsx(ln,{className:"size-4"})})}),e[2]=c):c=e[2];let d;if(e[3]!==l||e[4]!==s){let f;e[6]!==l?(f=m=>n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>l(m.id),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md hover:bg-accent text-sm text-foreground",children:[n.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:n.jsx(Vl,{icon:m.icon})}),n.jsx("span",{className:"truncate",children:m.title})]})},m.id),e[6]=l,e[7]=f):f=e[7],d=s.map(f),e[3]=l,e[4]=s,e[5]=d}else d=e[5];let h;e[8]!==d?(h=n.jsx(gs,{align:"end",className:"w-56 p-1",children:n.jsx("ul",{className:"flex flex-col",children:d})}),e[8]=d,e[9]=h):h=e[9];let u;return e[10]!==r||e[11]!==h?(u=n.jsxs(ms,{open:r,onOpenChange:o,children:[c,h]}),e[10]=r,e[11]=h,e[12]=u):u=e[12],u}const $w=6;function zw(t){const e=U.c(20),{virtualMcpId:s,taskId:i}=t,r=Vt();let o;e[0]!==i||e[1]!==s?(o={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=o):o=e[2];const{tabs:a,activeTab:l,mainOpen:c,setActiveTab:d}=Cc(o);let h,u,f,m;if(e[3]!==l||e[4]!==c||e[5]!==r||e[6]!==d||e[7]!==a||e[8]!==s){const L=lh({activeTab:l,mainOpen:c}),v=S=>S.id==="automations"?L:c&&S.id===l,_=a.find(S=>v(S))?.id??null,{visible:x,overflow:b}=Mw(a,_,$w);u=b,h=S=>{const w=a.find(N=>N.id===S),j=_===S&&c;if(Ze("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:S,tab_kind:w?.kind??null,was_active:j}),S==="automations"){const N=ch({activeTab:l,mainOpen:c});r({to:".",search:T=>({...T,main:N}),replace:!0});return}d(S)},f="flex items-center min-w-0 gap-0.5",m=x.map(S=>n.jsx(Qm,{title:S.title,icon:S.icon,active:v(S),onClick:()=>h(S.id)},S.id)),e[3]=l,e[4]=c,e[5]=r,e[6]=d,e[7]=a,e[8]=s,e[9]=h,e[10]=u,e[11]=f,e[12]=m}else h=e[9],u=e[10],f=e[11],m=e[12];let p;e[13]!==h||e[14]!==u?(p=u.length>0&&n.jsx(Bw,{overflow:u,onSelect:h}),e[13]=h,e[14]=u,e[15]=p):p=e[15];let g;return e[16]!==f||e[17]!==m||e[18]!==p?(g=n.jsxs("div",{className:f,children:[m,p]}),e[16]=f,e[17]=m,e[18]=p,e[19]=g):g=e[19],g}const Oa="__mobile-main-panel-tab-select__";function Fw({tabs:t,activeTab:e,mainOpen:s}){const i=t.find(r=>r.id===e);return s?i?.title??"Main view":i?.title??t[0]?.title??"Main view"}function Hw(t){const e=U.c(40),{virtualMcpId:s,taskId:i}=t,r=Vt();let o;e[0]!==i||e[1]!==s?(o={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=o):o=e[2];const{tabs:a,activeTab:l,mainOpen:c,setActiveTab:d}=Cc(o);let h;e[3]!==l||e[4]!==c||e[5]!==a?(h=Fw({tabs:a,activeTab:l,mainOpen:c}),e[3]=l,e[4]=c,e[5]=a,e[6]=h):h=e[6];const u=h;let f;e[7]!==l||e[8]!==c||e[9]!==a?(f=a.find(N=>N.id===l)??(c?null:a[0]),e[7]=l,e[8]=c,e[9]=a,e[10]=f):f=e[10];const m=f;let p;e[11]!==l||e[12]!==c?(p=lh({activeTab:l,mainOpen:c}),e[11]=l,e[12]=c,e[13]=p):p=e[13];const g=p;let L;e[14]!==l||e[15]!==g||e[16]!==c||e[17]!==r||e[18]!==d||e[19]!==a||e[20]!==s?(L=N=>{if(N===Oa)return;const T=a.find(A=>A.id===N);if(Ze("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:N,tab_kind:T?.kind??null,was_active:N==="automations"?g:c&&l===N,source:"mobile_select"}),N==="automations"){const A=ch({activeTab:l,mainOpen:c});r({to:".",search:k=>({...k,main:A}),replace:!0});return}d(N)},e[14]=l,e[15]=g,e[16]=c,e[17]=r,e[18]=d,e[19]=a,e[20]=s,e[21]=L):L=e[21];const v=L;let y;e[22]!==m?(y=m&&n.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:n.jsx(Vl,{icon:m.icon})}),e[22]=m,e[23]=y):y=e[23];let _;e[24]!==u?(_=n.jsx("span",{className:"min-w-0 truncate",children:u}),e[24]=u,e[25]=_):_=e[25];let x;e[26]!==y||e[27]!==_?(x=n.jsx(kt,{"aria-label":"Main panel tab",className:"h-10! w-full min-w-0 max-w-[7.5rem] rounded-md border-0 bg-transparent px-1.5 text-xs shadow-none [--card-shadow:none]",children:n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[y,_]})}),e[26]=y,e[27]=_,e[28]=x):x=e[28];let b;e[29]!==u?(b=n.jsx(ot,{value:Oa,disabled:!0,hideCheck:!0,className:"hidden",children:u}),e[29]=u,e[30]=b):b=e[30];let S;e[31]!==a?(S=a.map(Uw),e[31]=a,e[32]=S):S=e[32];let w;e[33]!==S||e[34]!==b?(w=n.jsxs(Nt,{align:"end",className:"w-56",children:[b,S]}),e[33]=S,e[34]=b,e[35]=w):w=e[35];let j;return e[36]!==v||e[37]!==w||e[38]!==x?(j=n.jsxs(Tt,{value:Oa,onValueChange:v,children:[x,w]}),e[36]=v,e[37]=w,e[38]=x,e[39]=j):j=e[39],j}function Uw(t){return n.jsx(ot,{value:t.id,children:n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center",children:n.jsx(Vl,{icon:t.icon})}),n.jsx("span",{className:"min-w-0 truncate",children:t.title})]})},t.id)}function Nf(t){return ur({userName:t?.name,userEmail:t?.email})??void 0}const Kw=new Set(["main","master"]);function t9(t){return Kw.has(t.trim().toLowerCase())?"Publish to production":"Publish"}function Ww(t){const e=U.c(24),{baseBranch:s,disabled:i,loading:r,onPublish:o,onReview:a}=t,l=r===void 0?!1:r;let c;e[0]!==s?(c=t9(s),e[0]=s,e[1]=c):c=e[1];const d=c;let h;e[2]!==o?(h=()=>{o()},e[2]=o,e[3]=h):h=e[3];let u;e[4]!==l?(u=l?n.jsx(zl,{size:"xs",variant:"default"}):null,e[4]=l,e[5]=u):u=e[5];let f;e[6]!==i||e[7]!==d||e[8]!==h||e[9]!==u?(f=n.jsxs(re,{size:"sm",variant:"success",className:"rounded-r-none border-r border-success-foreground/20",disabled:i,onClick:h,children:[u,d]}),e[6]=i,e[7]=d,e[8]=h,e[9]=u,e[10]=f):f=e[10];let m;e[11]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(ls,{className:"h-3.5 w-3.5"}),e[11]=m):m=e[11];let p;e[12]!==i?(p=n.jsx(ns,{asChild:!0,children:n.jsx(re,{size:"sm",variant:"success",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:m})}),e[12]=i,e[13]=p):p=e[13];let g;e[14]!==a?(g=a?n.jsx(We,{onClick:a,children:"Review"}):null,e[14]=a,e[15]=g):g=e[15];let L;e[16]!==g?(L=n.jsx(rs,{align:"end",children:g}),e[16]=g,e[17]=L):L=e[17];let v;e[18]!==p||e[19]!==L?(v=n.jsxs(is,{children:[p,L]}),e[18]=p,e[19]=L,e[20]=v):v=e[20];let y;return e[21]!==v||e[22]!==f?(y=n.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[f,v]}),e[21]=v,e[22]=f,e[23]=y):y=e[23],y}class Tn extends Error{constructor(e,s,i){super(e),this.step=s,this.pr=i,this.name="PublishFlowError"}step;pr}function Vw(t){const e=U.c(10),[s,i]=R.useState(0);let r;e[0]!==t?(r=c=>{c&&i(Gw),t.onOpenChange(c)},e[0]=t,e[1]=r):r=e[1];const o=r;let a;e[2]!==o||e[3]!==t||e[4]!==s?(a=t.open?n.jsx(qw,{...t,onOpenChange:o},s):null,e[2]=o,e[3]=t,e[4]=s,e[5]=a):a=e[5];let l;return e[6]!==o||e[7]!==t.open||e[8]!==a?(l=n.jsx(Gt,{open:t.open,onOpenChange:o,children:a}),e[6]=o,e[7]=t.open,e[8]=a,e[9]=l):l=e[9],l}function Gw(t){return t+1}function qw({onOpenChange:t,orgSlug:e,orgId:s,virtualMcpId:i,branch:r,baseBranch:o,githubConnectionId:a,owner:l,repo:c,previewUrl:d,dialogIntent:h="open-pr",headSha:u=null,openPullRequest:f=null,onPullRequestChanged:m,onPublished:p}){const g=Dt({connectionId:a,orgId:s,orgSlug:e}),L=Dt({connectionId:Kl,orgId:s,orgSlug:e}),{data:v}=an.useSession(),y=Bl(L),_=Nf(v?.user),x=f?.state==="open",b=h==="open-pr"&&!x,S=h==="publish-only",[w,j]=R.useState(null),[N,T]=R.useState(null),[A,k]=R.useState(!0),[C,I]=R.useState(!1),[E,O]=R.useState(""),[P,D]=R.useState(""),[M,z]=R.useState(),[F,$]=R.useState(!1),[V,J]=R.useState(),[Z,G]=R.useState(!1),[q,H]=R.useState(!1),[K,B]=R.useState(!1),X=R.useRef(!1),W=R.useRef(!1),Y={base:o,...u?{headSha:u}:{}},Q=async le=>{const Le=(le.aheadOfBase??0)>0?await Fr(e,i,r,Y):null,Ce=kc(le)?await Fr(e,i,r):null;return kg(Le,Ce)},ie=async()=>{const le=await da(e,i,r),Le=S?await Q(le):await Fr(e,i,r,jg(le,{openPrFromCommits:b,commitToOpenPr:x})?Y:void 0);j(le),T(Le),O(`Changes from ${le.current??r}`),B(!0),I9(e,i,r,{status:le,diff:Le}).then(Ce=>{O(Ce.title),D(Ce.body)}).catch(()=>{}).finally(()=>B(!1))};X.current||(X.current=!0,(async()=>{k(!0),z(void 0),T(null),O(""),D(""),J(void 0);try{await ie()}catch(le){if(Lg(le)&&!W.current){W.current=!0;try{await y.mutateAsync({virtualMcpId:i,branch:r}),await ie();return}catch(Le){z(Le instanceof Error?Le.message:"Failed to load changes after re-provisioning the sandbox.");return}}z(le instanceof Error?le.message:"Failed to load changes.")}finally{k(!1)}})());const oe=wg(w)??r,ue=t9(o),ee=()=>{!w||!N||(B(!0),I9(e,i,r,{status:w,diff:N}).then(le=>{O(le.title),D(le.body)}).catch(()=>{}).finally(()=>B(!1)))},te=uu(w),fe=N?Object.keys(N.diffs).length:te,he=b?fu(w):Cg(w,N),ye=!A&&(he||b),ve=Ng(N),be=ye&&ve.allowed,Ne=ye?ve.reason:null,Oe=b||!x&&(w?.aheadOfBase??0)>0,Fe=!A&&(Oe||he)&&(fe>0||he),Me=()=>[E.trim(),P.trim()].filter(Boolean).join(`
|
|
512
|
-
|
|
513
|
-
`),qe=le=>{C||F||t(le)},Ie=async()=>{I(!0),z(void 0);let le;try{const Le=E.trim()||`Changes from ${oe}`,Ce=P.trim()||void 0,_e=Me()||Le;try{await O9(e,i,r,_e)}catch(Re){throw new Tn(Re instanceof Error?Re.message:"Failed to push changes","push")}try{await xg(e,i,r,o)}catch(Re){throw new Tn(Re instanceof Error?Re.message:"Failed to rebase onto base","rebase")}try{le=await x9(g,{owner:l,repo:c,branch:oe,title:Le,body:Ce,base:o,coAuthor:_})}catch(Re){throw new Tn(Re instanceof Error?Re.message:"Failed to open pull request","open-pr")}try{await Ih(g,{owner:l,repo:c,pullNumber:le.number,commitTitle:Le,commitMessage:Ce,coAuthor:_})}catch(Re){throw new Tn(Re instanceof Error?Re.message:"Failed to merge pull request","merge",le)}me.success(`Published to ${o}`),qe(!1),T(null),O(""),D(""),await m?.(),await p?.()}catch(Le){if(Le instanceof Tn&&Le.step==="merge"&&Le.pr){const Ce=`Changes were pushed and PR #${Le.pr.number} is open, but merge failed: ${Le.message}`;z(Ce),me.error(Ce,{action:{label:"View PR",onClick:()=>window.open(Le.pr.htmlUrl,"_blank","noopener,noreferrer")}}),await m?.();return}z(Le instanceof Error?Le.message:"Failed to publish")}finally{I(!1)}},pe=async le=>{try{await M9(e,i,r,[le]),me.success(`Discarded changes to ${le}`),T(Ce=>{if(!Ce)return Ce;const _e={...Ce,diffs:{...Ce.diffs}};return delete _e.diffs[le],_e});const Le=await da(e,i,r);j(Le)}catch(Le){me.error(Le instanceof Error?Le.message:"Failed to discard changes")}},je=async()=>{if(N){G(!1),H(!0);try{const le=Object.keys(N.diffs);if(le.length===0)return;await M9(e,i,r,le),me.success("All changes discarded"),T(null);const Le=await da(e,i,r);j(Le),qe(!1)}catch(le){me.error(le instanceof Error?le.message:"Failed to discard changes")}finally{H(!1)}}},Be=async()=>{$(!0),J(void 0);try{const le=E.trim()||`Changes from ${oe}`,Le=P.trim()||void 0,Ce=Me()||le;await O9(e,i,r,Ce);const _e=await x9(g,{owner:l,repo:c,branch:oe,title:le,body:Le,base:o,coAuthor:_});me.success(`Submitted pull request #${_e.number} for review`,{action:{label:"View on GitHub",onClick:()=>window.open(_e.htmlUrl,"_blank","noopener,noreferrer")}}),qe(!1),await m?.()}catch(le){J(le instanceof Error?le.message:"Failed to submit for review")}finally{$(!1)}};return n.jsx(qt,{className:"top-14 left-auto right-4 flex h-[90%] max-h-[85vh] w-[90vw] max-w-[600px] translate-x-0 translate-y-0 flex-col gap-0 overflow-hidden p-0",children:n.jsxs(Io,{defaultValue:"description",className:"flex h-full flex-col gap-0",children:[n.jsxs("div",{className:"shrink-0 space-y-3 px-6 pt-5 pb-4",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:b?"Submit for review":ue}),n.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[n.jsx("span",{className:"inline-block h-2.5 w-2.5 shrink-0 rounded-full bg-green-500"}),fe," ",fe===1?"change":"changes"," ",b?"in this PR":"to publish"]})]}),Z?n.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md bg-destructive/5 px-3 py-2",children:[n.jsx("span",{className:"text-xs text-destructive",children:"Discard all changes? This cannot be undone."}),n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[n.jsx(re,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>G(!1),children:"Cancel"}),n.jsxs(re,{type:"button",size:"sm",className:"h-7 bg-destructive px-2 text-xs text-destructive-foreground hover:bg-destructive/90",onClick:je,disabled:q,children:[q?n.jsx(Ue,{className:"h-3 w-3 animate-spin"}):null,"Discard all"]})]})]}):n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs(Do,{className:"h-8 w-auto",variant:"pill",children:[n.jsx(Js,{value:"description",className:"px-3 text-xs",children:"Description"}),n.jsx(Js,{value:"changes",className:"px-3 text-xs",children:"Changes"})]}),fe>0&&!b&&n.jsx("button",{type:"button",className:"text-xs text-muted-foreground transition-colors hover:text-destructive disabled:opacity-50",onClick:()=>G(!0),disabled:C||q,children:"Discard all"})]})]}),n.jsx("div",{className:"border-t"}),n.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:A?n.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-muted-foreground",children:[n.jsx(Ue,{className:"h-4 w-4 animate-spin"}),n.jsx("span",{className:"text-sm",children:"Loading changes…"})]}):n.jsxs(n.Fragment,{children:[n.jsx(Gi,{value:"description",className:"mt-0 px-6 py-5",children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("p",{className:"text-sm font-medium",children:b?"Pull request":"Commit message"}),n.jsxs("button",{type:"button",className:"flex items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50",disabled:K||C||F,onClick:ee,children:[K?n.jsx(Ue,{className:"h-3 w-3 animate-spin"}):n.jsx(gi,{className:"h-3 w-3"}),K?"Generating…":"Regenerate"]})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("label",{htmlFor:"publish-title",className:"text-xs font-medium text-muted-foreground",children:"Title"}),n.jsx(Ke,{id:"publish-title",value:E,onChange:le=>O(le.target.value),placeholder:K?"Generating…":"Commit title…",disabled:C||F||K,className:"text-sm"})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("label",{htmlFor:"publish-body",className:"text-xs font-medium text-muted-foreground",children:"Description"}),n.jsx(Yn,{id:"publish-body",value:P,onChange:le=>D(le.target.value),placeholder:K?"Generating…":"Description (optional)…",disabled:C||F||K,rows:5,className:"resize-none text-sm"})]}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Branch: ",n.jsx("span",{className:"font-mono",children:r})," → ",n.jsx("span",{className:"font-mono",children:o})," · ",n.jsx("span",{className:"text-foreground/80",children:S?`${ue} squash-merges into ${o}.`:`Opens a pull request into ${o} for review.`})]})]})}),n.jsx(Gi,{value:"changes",className:"mt-0",children:n.jsx(mu,{diff:N,onDiscardFile:pe})})]})}),n.jsx("div",{className:"shrink-0 border-t",children:n.jsxs("button",{type:"button",className:"flex w-full items-center justify-between px-6 py-3.5 text-sm transition-colors hover:bg-muted/50 disabled:opacity-50",onClick:()=>{d&&window.open(d,"_blank","noopener,noreferrer")},disabled:!d,children:[n.jsxs("span",{className:"flex items-center gap-3",children:[n.jsx(xh,{className:"h-4 w-4 text-muted-foreground"}),"Visit preview"]}),n.jsx(Q2,{className:"h-4 w-4 text-muted-foreground"})]})}),n.jsx("div",{className:"shrink-0 border-t px-6 py-3",children:S?n.jsxs(n.Fragment,{children:[n.jsx(Yw,{label:ue,canPublish:be,disabledReason:Ne,isPublishing:C,onPublish:Ie}),M&&n.jsx("p",{className:"mt-2 text-xs text-destructive",children:M})]}):n.jsxs(n.Fragment,{children:[n.jsxs(re,{type:"button",className:"w-full",onClick:Be,disabled:!Fe||F,children:[F?n.jsx(Ue,{className:"h-4 w-4 animate-spin"}):n.jsx(No,{className:"h-4 w-4"}),"Submit for review"]}),V&&n.jsx("p",{className:"mt-2 text-xs text-destructive",children:V})]})})]})})}function Yw(t){const e=U.c(14),{label:s,canPublish:i,disabledReason:r,isPublishing:o,onPublish:a}=t,l=!i||o;let c;e[0]!==o?(c=o?n.jsx(Ue,{className:"h-4 w-4 animate-spin"}):null,e[0]=o,e[1]=c):c=e[1];let d;e[2]!==s||e[3]!==a||e[4]!==l||e[5]!==c?(d=n.jsxs(re,{type:"button",variant:"success",className:"w-full",onClick:a,disabled:l,children:[c,s]}),e[2]=s,e[3]=a,e[4]=l,e[5]=c,e[6]=d):d=e[6];const h=d;if(!r)return h;let u;e[7]!==h?(u=n.jsx(Ee,{asChild:!0,children:n.jsx("span",{className:"flex w-full",children:h})}),e[7]=h,e[8]=u):u=e[8];let f;e[9]!==r?(f=n.jsx(Ae,{children:r}),e[9]=r,e[10]=f):f=e[10];let m;return e[11]!==u||e[12]!==f?(m=n.jsx(uh,{children:n.jsxs(Pe,{children:[u,f]})}),e[11]=u,e[12]=f,e[13]=m):m=e[13],m}function Jw(){return!1}function Tf(t,e){Jw()&&console.log(`[github-header] ${t}`,e??"")}function Xw(t){if(!(t==="claiming"||t==="ready"||t==="failed"))return Uu[t].short}const Zw=new Set(["failure","timed_out","cancelled","action_required"]);function Qw(t){return t.status==="completed"&&Zw.has(t.conclusion)}function eC(t){return t.status==="queued"||t.status==="in_progress"}function tC(t){return t.isPending&&t.fetchStatus!=="idle"}function sC(t){const{lifecycle:e,branch:s,pr:i,checks:r,reviews:o,loading:a}=t;if(a)return{label:"Loading…",disabled:!0,loading:!0,variant:"outline",tooltip:"Loading branch and pull request status"};switch(e.phase){case"idle":return{label:t.claimPhase&&Xw(t.claimPhase.kind)||"Starting sandbox…",disabled:!0,loading:!0,variant:"outline",tooltip:"Waiting for the sandbox daemon to come online"};case"cloning":return{label:"Cloning repo…",disabled:!0,loading:!0,variant:"outline",tooltip:"Cloning the project repository"};case"clone-failed":return{label:"Clone failed",disabled:!0,variant:"outline",tooltip:e.error||"git clone failed — see setup logs"};case"checking-out":return{label:`Switching to ${e.to}…`,disabled:!0,loading:!0,variant:"outline",tooltip:`Checking out ${e.to}`}}if(s.kind!=="ready")return{label:"Loading branch…",disabled:!0,loading:!0,variant:"outline",tooltip:"Waiting for branch metadata from the sandbox daemon"};const l=s;if(l.workingTreeDirty)return{label:"Submit for review",action:"create-pr",variant:"default",tooltip:`Push and open a PR for ${l.branch} → ${l.base}`,showPublishSide:!0};if(l.unpushed>0&&!(i&&l.headSha&&i.headSha&&l.headSha===i.headSha))return i?{label:"Submit for review",action:"create-pr",variant:"default",tooltip:`Push local commits to PR #${i.number}`,showPublishSide:!0}:{label:"Submit for review",action:"create-pr",variant:"default",tooltip:`Push and open a PR for ${l.branch} → ${l.base}`,showPublishSide:!0};if(Tf("no local work — checking PR/sync state",{workingTreeDirty:l.workingTreeDirty,unpushed:l.unpushed,aheadOfBase:l.aheadOfBase,behindBase:l.behindBase,branch:l.branch,base:l.base,prMerged:i?.merged??null,prState:i?.state??null}),i?.merged)return!!l.headSha&&!!i.headSha&&l.headSha!==i.headSha?{label:"Continue",action:"create-pr",variant:"special",tooltip:"Open a new PR with the latest commits",showPublishSide:!0}:{label:"Published",disabled:!0,variant:"outline",tooltip:`PR #${i.number} merged into ${i.base}`};if(l.aheadOfBase>0){if(i&&i.state==="closed"&&!i.merged)return{label:"Reopen",action:"reopen",variant:"default",tooltip:`Reopen PR #${i.number}`};if(!i)return{label:"Submit for review",action:"create-pr",variant:"default",tooltip:`Open a PR for ${l.branch} → ${l.base}`,showPublishSide:!0};if((o?.mergeableState??"unknown")==="dirty")return{label:`Sync with ${i.base}`,action:"rebase",variant:"default",tooltip:`Resolve conflicts with ${i.base} before merging`};const h=r.filter(Qw).map(m=>m.name);if(h.length>0)return{label:"Fix tests",action:"fix-checks",variant:"default",tooltip:`Failing: ${h.join(", ")}`,meta:{failingChecks:h}};const u=r.filter(eC);if(u.length>0)return{label:"Running tests…",disabled:!0,loading:!0,variant:"outline",tooltip:`Waiting on ${u.length} check${u.length===1?"":"s"} to finish`};if(o?.draft)return{label:"Mark ready",action:"mark-ready",variant:"default",tooltip:"Mark draft PR ready for review"};const f=o?.unresolvedConversations??0;return f>0?{label:"Address feedback",action:"resolve-comments",variant:"default",tooltip:`${f} unresolved conversation${f===1?"":"s"}`}:o?.missingRequiredApprovals?{label:"Awaiting review",disabled:!0,variant:"outline",tooltip:"Waiting for required approvals"}:{label:t9(i.base),action:"merge-split",variant:"success",tooltip:`Squash-merge PR #${i.number} into ${i.base}`}}return{label:"Up to date",disabled:!0,variant:"outline",tooltip:`Branch is in sync with ${l.base}`}}function iC(t,e,s){if(!e)return s??null;const i=t?.[e];if(!i)return s??null;if(s&&i[s])return s;for(const[r,o]of Object.entries(i))if(o&&Object.keys(o).length>0)return r;return s??null}const nC=6e4,rC=3e4;function oC(t){const e=U.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=Dt(s),r=t.prNumber??0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(o={method:"get",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=o):o=e[7];const a=!!t.prNumber;let l;return e[8]!==i||e[9]!==o||e[10]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:nC,refetchIntervalInBackground:!1,staleTime:rC,select:aC},e[8]=i,e[9]=o,e[10]=a,e[11]=l):l=e[11],Po(l)}function aC(t){const e=Ii(t);if(!e)return null;const s=e.mergeable_state??"unknown",i=!!(e.draft??!1),r=Number(e.review_comments??0),o=s==="blocked"&&r>0?r:0;return{draft:i,mergeableState:s,unresolvedConversations:o,missingRequiredApprovals:s==="blocked"&&o===0}}const lC={label:"Loading branch…",disabled:!0,loading:!0,variant:"outline",tooltip:"Waiting for sandbox branch"};function cC({virtualMcpId:t}){const{org:e}=Ge(),{data:s}=an.useSession(),i=Ts(t),{currentBranch:r,setCurrentTaskBranch:o}=$s(),a=Ti(),[l,c]=R.useState(!1),[d,h]=R.useState("open-pr"),[u,f]=R.useState(!1),m=R.useRef(""),p=Tm(i),g=p.status==="attached"||p.status==="public-clone"?p.repo:null,L=s?.user?.id,v=Dt({connectionId:g?.connectionId??"",orgId:e.id,orgSlug:e.slug}),{lifecycle:y,branch:_,phase:x}=As(),b=_.kind==="ready"?_.branch:null,S=iC(i?.metadata?.sandboxMap,L,r??b),w=r??b??S??void 0,j=(_.kind==="ready"?_.branch:null)??w??null,N=hc({orgId:e.id,orgSlug:e.slug,connectionId:g?.connectionId??"",owner:g?.owner??"",repo:g?.name??"",branch:j}),T=N.data??null,A=Oh({orgId:e.id,orgSlug:e.slug,connectionId:g?.connectionId??"",owner:g?.owner??"",repo:g?.name??"",prNumber:T&&T.state==="open"?T.number:null}),k=oC({orgId:e.id,orgSlug:e.slug,connectionId:g?.connectionId??"",owner:g?.owner??"",repo:g?.name??"",prNumber:T&&T.state==="open"?T.number:null}),C=_;if(p.status==="detached")return n.jsx(Yr,{label:"GitHub connection was removed — relink the repository in Settings to save changes",children:n.jsx(re,{size:"sm",variant:"outline",disabled:!0,children:"Reconnect GitHub"})});if(!g)return null;const I=L&&j?jo(i?.metadata?.sandboxMap?.[L]?.[j]):{},E=Object.values(I),P=(E.find(B=>B.sandboxProviderKind!=="user-desktop")??E[0])?.previewUrl??null,D=j?sC({lifecycle:y,branch:C,claimPhase:x,pr:T,checks:A.data??[],reviews:k.data??null,loading:tC(N)}):lC,M=JSON.stringify({label:D.label,branchKind:C.kind,workingTreeDirty:C.kind==="ready"?C.workingTreeDirty:null,unpushed:C.kind==="ready"?C.unpushed:null,aheadOfBase:C.kind==="ready"?C.aheadOfBase:null,lifecycle:y.phase,githubHeadBranch:j});m.current!==M&&(m.current=M,Tf("header button",{label:D.label,tooltip:D.tooltip,action:D.action,chatBranch:r,sandboxBranch:b,sandboxMapBranch:S,sandboxRouteBranch:w,githubHeadBranch:j,branchMeta:_,effectiveBranchMeta:C,lifecyclePhase:y.phase,prNumber:T?.number??null,prState:T?.state??null}));const z=B=>a.sendMessage({parts:[{type:"text",text:B}]}),F=a.isStreaming,$=C.kind==="ready"?C.base:"main",V=async()=>{await Promise.all([N.refetch(),A.refetch(),k.refetch()])},J=async()=>{const B=d2(s?.user?.name??s?.user?.email?.split("@")[0]);await o(B)},Z=async B=>{if(!(!g?.connectionId||u)){f(!0);try{const X=Nf(s?.user);await Ih(v,{owner:g.owner,repo:g.name,pullNumber:B,coAuthor:X}),me.success(`Published PR #${B}`),await V(),await J()}catch(X){me.error(X instanceof Error?X.message:"Failed to merge pull request")}finally{f(!1)}}},G=B=>{if(!(!B||!j))switch(B){case"create-pr":h("open-pr"),c(!0);return;case"reopen":if(F)return;T&&z(Rg({prNumber:T.number}));return;case"rebase":if(F)return;z(Dg({branch:j}));return;case"fix-checks":if(F)return;T&&z(Og({prNumber:T.number,failingChecks:D.meta?.failingChecks??[]}));return;case"mark-ready":if(F)return;T&&z(Mg({prNumber:T.number}));return;case"resolve-comments":if(F)return;T&&z(Bg({prNumber:T.number}));return;case"merge-split":return}},q=()=>{h("publish-only"),c(!0)},H=D.showPublishSide??!1,K=u||F;return n.jsxs(n.Fragment,{children:[n.jsx(dC,{button:D,actionBusy:K,githubActionPending:u,onActivate:G,showPublishSide:H,onPublishSide:q,prNumber:T?.number,prBase:T?.base,onSquashMerge:Z,onReview:T?()=>{F||z($g({prNumber:T.number}))}:void 0}),w&&n.jsx(Vw,{open:l,onOpenChange:c,orgSlug:e.slug,orgId:e.id,virtualMcpId:t,branch:w,baseBranch:$,githubConnectionId:g.connectionId??"",owner:g.owner,repo:g.name,previewUrl:P,dialogIntent:d,headSha:C.kind==="ready"?C.headSha:null,openPullRequest:d==="publish-only"?null:T?.state==="open"?T:null,onPullRequestChanged:V,onPublished:J})]})}function dC(t){const e=U.c(32),{button:s,actionBusy:i,githubActionPending:r}=t,o=i&&s.action!=="create-pr"&&s.action!=="merge-split",a=!!s.disabled||o||r&&s.action==="merge-split",l=!!s.loading||r&&s.action==="merge-split",c=o?"Chat is running":s.tooltip??null;if(s.action==="merge-split"&&t.prNumber!=null&&t.prBase!=null){let g;e[0]!==t?(g=()=>t.onSquashMerge(t.prNumber),e[0]=t,e[1]=g):g=e[1];let L;e[2]!==a||e[3]!==l||e[4]!==t.onReview||e[5]!==t.prBase||e[6]!==g?(L=n.jsx(Ww,{baseBranch:t.prBase,disabled:a,loading:l,onPublish:g,onReview:t.onReview}),e[2]=a,e[3]=l,e[4]=t.onReview,e[5]=t.prBase,e[6]=g,e[7]=L):L=e[7];let v;return e[8]!==L||e[9]!==c?(v=n.jsx(Yr,{label:c,children:L}),e[8]=L,e[9]=c,e[10]=v):v=e[10],v}let d;e[11]!==s.action||e[12]!==t?(d=()=>{s.action&&t.onActivate(s.action)},e[11]=s.action,e[12]=t,e[13]=d):d=e[13];let h;e[14]!==l?(h=l?n.jsx(zl,{size:"xs",variant:"default"}):null,e[14]=l,e[15]=h):h=e[15];let u;e[16]!==s.label||e[17]!==s.variant||e[18]!==a||e[19]!==d||e[20]!==h?(u=n.jsxs(re,{size:"sm",variant:s.variant,disabled:a,onClick:d,children:[h,s.label]}),e[16]=s.label,e[17]=s.variant,e[18]=a,e[19]=d,e[20]=h,e[21]=u):u=e[21];let f;e[22]!==u||e[23]!==c?(f=n.jsx(Yr,{label:c,children:u}),e[22]=u,e[23]=c,e[24]=f):f=e[24];let m;e[25]!==t.githubActionPending||e[26]!==t.onPublishSide||e[27]!==t.showPublishSide?(m=t.showPublishSide?n.jsx(Yr,{label:"Publish directly, skipping review",children:n.jsx(re,{size:"sm",variant:"success",disabled:t.githubActionPending,onClick:t.onPublishSide,children:"Publish"})}):null,e[25]=t.githubActionPending,e[26]=t.onPublishSide,e[27]=t.showPublishSide,e[28]=m):m=e[28];let p;return e[29]!==f||e[30]!==m?(p=n.jsxs("div",{className:"flex items-center gap-2",children:[f,m]}),e[29]=f,e[30]=m,e[31]=p):p=e[31],p}function Yr(t){const e=U.c(9),{label:s,children:i}=t;if(!s){let l;return e[0]!==i?(l=n.jsx(n.Fragment,{children:i}),e[0]=i,e[1]=l):l=e[1],l}let r;e[2]!==i?(r=n.jsx(Ee,{asChild:!0,children:n.jsx("span",{children:i})}),e[2]=i,e[3]=r):r=e[3];let o;e[4]!==s?(o=n.jsx(Ae,{children:s}),e[4]=s,e[5]=o):o=e[5];let a;return e[6]!==r||e[7]!==o?(a=n.jsx(uh,{children:n.jsxs(Pe,{children:[r,o]})}),e[6]=r,e[7]=o,e[8]=a):a=e[8],a}function hC(t){const e=U.c(9),{virtualMcp:s}=t,i=Ul(),{navigateToTask:r}=p2(),{create:o}=Fd();let a,l;if(e[0]!==i||e[1]!==o||e[2]!==r||e[3]!==s){l=Symbol.for("react.early_return_sentinel");e:{const c=Em(s,i);if(!c){l=null;break e}const d=c.mode==="dev";let h;e[6]!==o||e[7]!==r?(h=async m=>{const p=crypto.randomUUID();try{await o({id:p,virtual_mcp_id:m})}catch{}r(p,{virtualMcpId:m})},e[6]=o,e[7]=r,e[8]=h):h=e[8];const u=h,f=(m,p)=>n.jsx("button",{type:"button","aria-pressed":p,onClick:()=>{p||u(c.targetId)},className:ce("px-2.5 py-1 rounded-md transition-colors",p?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:m});a=n.jsxs("div",{className:"inline-flex items-center rounded-lg border border-border bg-muted p-0.5 text-xs font-medium",children:[f("Develop",d),f("Live",!d)]})}e[0]=i,e[1]=o,e[2]=r,e[3]=s,e[4]=a,e[5]=l}else a=e[4],l=e[5];return l!==Symbol.for("react.early_return_sentinel")?l:a}function uC(t){const e=U.c(8),{virtualMcp:s,inline:i}=t,r=i===void 0?!1:i;let o,a;e[0]!==s?(o=n.jsx(hC,{virtualMcp:s}),a=Am(s)?n.jsx(cC,{virtualMcpId:s.id}):null,e[0]=s,e[1]=o,e[2]=a):(o=e[1],a=e[2]);let l;e[3]!==o||e[4]!==a?(l=n.jsxs("div",{className:"flex items-center gap-2",children:[o,a]}),e[3]=o,e[4]=a,e[5]=l):l=e[5];const c=l;if(r)return c;let d;return e[6]!==c?(d=n.jsx(Ui.Right,{children:c}),e[6]=c,e[7]=d):d=e[7],d}function fC(t,e){const s=U.c(34),i=Hd(),r=R.useSyncExternalStore(i.threads.subscribe,i.threads.get),o=R.useSyncExternalStore(i.threadsStatus.subscribe,i.threadsStatus.get);let a;s[0]!==t||s[1]!==r?(a=t?r.find(_=>_.id===t)??null:null,s[0]=t,s[1]=r,s[2]=a):a=s[2];const l=a,[c,d]=R.useState(void 0);let h;s[3]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{d(void 0)},s[3]=h):h=s[3];let u;s[4]!==t?(u=[t],s[4]=t,s[5]=u):u=s[5],R.useEffect(h,u);let f,m;s[6]!==c||s[7]!==t||s[8]!==l||s[9]!==i||s[10]!==o.kind?(f=()=>{t&&(l||o.kind!=="loading"&&c===void 0&&(d("pending"),i.fetchThread(t).then(_=>{d(_)})))},m=[t,l,o.kind,c,i],s[6]=c,s[7]=t,s[8]=l,s[9]=i,s[10]=o.kind,s[11]=f,s[12]=m):(f=s[11],m=s[12]),R.useEffect(f,m);let p;s[13]!==i||s[14]!==e?(p={mutationFn:async _=>i.create({id:_,virtual_mcp_id:e})},s[13]=i,s[14]=e,s[15]=p):p=s[15];const g=ii(p);let L,v;if(s[16]!==g||s[17]!==c||s[18]!==t||s[19]!==l||s[20]!==o.kind?(L=()=>{t&&(l||c===null&&o.kind!=="loading"&&(g.isPending||g.variables!==t&&g.mutate(t)))},v=[t,l,c,o.kind,g],s[16]=g,s[17]=c,s[18]=t,s[19]=l,s[20]=o.kind,s[21]=L,s[22]=v):(L=s[21],v=s[22]),R.useEffect(L,v),!t){let _;return s[23]===Symbol.for("react.memo_cache_sentinel")?(_={status:"ready",task:null},s[23]=_):_=s[23],_}if(l){let _;return s[24]!==l?(_={status:"ready",task:l},s[24]=l,s[25]=_):_=s[25],_}if(c&&typeof c=="object"){let _;return s[26]!==c?(_={status:"ready",task:c},s[26]=c,s[27]=_):_=s[27],_}if(g.data){let _;return s[28]!==g.data?(_={status:"ready",task:g.data},s[28]=g.data,s[29]=_):_=s[29],_}if(g.isError){let _;return s[30]!==g.error?(_={status:"error",error:g.error},s[30]=g.error,s[31]=_):_=s[31],_}if(g.isPending||o.kind!=="loading"){let _;return s[32]===Symbol.for("react.memo_cache_sentinel")?(_={status:"creating"},s[32]=_):_=s[32],_}let y;return s[33]===Symbol.for("react.memo_cache_sentinel")?(y={status:"loading"},s[33]=y):y=s[33],y}function mC(){const t=U.c(6),e=Wl(),s=Vt();let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},t[0]=i):i=t[0];const{preview:r}=Co(i);if(!e||!r)return null;let o;t[1]!==s?(o=()=>s({to:".",search:pC}),t[1]=s,t[2]=o):o=t[2];let a;return t[3]!==r||t[4]!==o?(a=n.jsx(e3,{previewPath:r,showSeeInLibrary:!0,onClose:o}),t[3]=r,t[4]=o,t[5]=a):a=t[5],a}function pC(t){const{preview:e,...s}=t;return s}const Hi=R.createContext(null);function li(){return R.use(Hi)}function xd(t){const e=U.c(6),{children:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Something went wrong loading the chat. Try refreshing."}),e[0]=i):i=e[0];let r;e[1]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(lt.Skeleton,{}),e[1]=r):r=e[1];let o;e[2]!==s?(o=s??n.jsx(Nh,{}),e[2]=s,e[3]=o):o=e[3];let a;return e[4]!==o?(a=n.jsx(es,{fallback:i,children:n.jsx(R.Suspense,{fallback:r,children:o})}),e[4]=o,e[5]=a):a=e[5],a}function yd(t){const e=U.c(3),{onNewTaskRef:s,createNewTask:i}=t;let r;return e[0]!==i||e[1]!==s?(r=()=>(s.current=i,()=>{s.current=null}),e[0]=i,e[1]=s,e[2]=r):r=e[2],R.useLayoutEffect(r),null}function bd(t){const e=U.c(23),{virtualMcpId:s,hasActiveGithubRepo:i,sandboxMap:r,children:o}=t,{currentBranch:a}=$s(),{pendingSandboxProviderKind:l}=$l(),{data:c}=an.useSession(),d=c?.user?.id,h=h2(s,a??void 0);let u,f;e[0]!==a||e[1]!==l||e[2]!==r||e[3]!==d?(u=d&&a?jo(r?.[d]?.[a]):{},f=l?u[l]??null:Zh(u),e[0]=a,e[1]=l,e[2]=r,e[3]=d,e[4]=u,e[5]=f):(u=e[4],f=e[5]);const p=f?.previewUrl??null;let g;e[6]!==u||e[7]!==h?(g=Object.keys(u).length>0||h,e[6]=u,e[7]=h,e[8]=g):g=e[8];const L=g,v=a??null,y=a??null,_=d??null;let x;e[9]!==o||e[10]!==i||e[11]!==l||e[12]!==r||e[13]!==y||e[14]!==_||e[15]!==s?(x=n.jsx(P4,{virtualMcpId:s,branch:y,userId:_,hasActiveGithubRepo:i,sandboxMap:r,sandboxProviderKind:l,children:o}),e[9]=o,e[10]=i,e[11]=l,e[12]=r,e[13]=y,e[14]=_,e[15]=s,e[16]=x):x=e[16];let b;return e[17]!==p||e[18]!==L||e[19]!==v||e[20]!==x||e[21]!==s?(b=n.jsx(j4,{virtualMcpId:s,branch:v,previewUrl:p,enabled:L,children:x}),e[17]=p,e[18]=L,e[19]=v,e[20]=x,e[21]=s,e[22]=b):b=e[22],b}function gC(){const t=U.c(104),e=Wl(),s=Vt(),{org:i}=Ge();Rm(i.slug);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={strict:!1},t[0]=r):r=t[0];const o=Sd(r),a=o.org??"";let l;t[1]===Symbol.for("react.memo_cache_sentinel")?(l={strict:!1},t[1]=l):l=t[1];const c=Co(l);let d;t[2]!==i.id||t[3]!==c.virtualmcpid?(d=c.virtualmcpid??Ud(i.id).id,t[2]=i.id,t[3]=c.virtualmcpid,t[4]=d):d=t[4];const h=d,u=fC(o.taskId??"",h),f=Ts(h),m=f?.metadata?.ui?.layout??null;let p;t[5]!==m?(p=m?{defaultMainView:m.defaultMainView??null,chatDefaultOpen:m.chatDefaultOpen??null}:null,t[5]=m,t[6]=p):p=t[6];const g=p;let L;t[7]!==f?(L=f&&Ao(f),t[7]=f,t[8]=L):L=t[8];const v=!!L;let y;t[9]!==a||t[10]!==h?(y={virtualMcpId:h,orgSlug:a,isAgentRoute:!0},t[9]=a,t[10]=h,t[11]=y):y=t[11];const _=yp(g,y),x=R.useRef(null);let b,S;t[12]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{const J=Z=>{Lm(Z)&&Z.shiftKey&&Z.code==="KeyS"&&!Z.repeat&&(Z.preventDefault(),x.current?.())};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)},S=[],t[12]=b,t[13]=S):(b=t[12],S=t[13]),R.useEffect(b,S);const w=h;let j;t[14]!==f||t[15]!==h?(j={virtualMcpId:h,entity:f},t[14]=f,t[15]=h,t[16]=j):j=t[16];const N=j;if(u.status==="creating"||u.status==="loading"){let J;t[17]===Symbol.for("react.memo_cache_sentinel")?(J=n.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:n.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[n.jsx(Ue,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[17]=J):J=t[17];let Z;return t[18]!==N?(Z=n.jsx(Hi,{value:N,children:J}),t[18]=N,t[19]=Z):Z=t[19],Z}if(u.status==="error"){let J;t[20]===Symbol.for("react.memo_cache_sentinel")?(J=n.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[20]=J):J=t[20];let Z;t[21]!==u.error.message?(Z=n.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:n.jsxs("div",{className:"flex flex-col h-full items-center justify-center gap-2 bg-background card-shadow rounded-[0.75rem] p-8 text-sm",children:[J,n.jsx("div",{className:"text-muted-foreground",children:u.error.message})]})}),t[21]=u.error.message,t[22]=Z):Z=t[22];let G;return t[23]!==N||t[24]!==Z?(G=n.jsx(Hi,{value:N,children:Z}),t[23]=N,t[24]=Z,t[25]=G):G=t[25],G}if(!f){let J;t[26]===Symbol.for("react.memo_cache_sentinel")?(J=n.jsx(Ei,{size:48,className:"text-muted-foreground"}),t[26]=J):J=t[26];const Z=`The agent "${h}" does not exist in this organization.`;let G;t[27]!==s||t[28]!==a?(G=n.jsx(re,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:a}}),children:"Go to organization home"}),t[27]=s,t[28]=a,t[29]=G):G=t[29];let q;t[30]!==Z||t[31]!==G?(q=n.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:n.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:n.jsx(Qr,{image:J,title:"Agent not found",description:Z,actions:G})})}),t[30]=Z,t[31]=G,t[32]=q):q=t[32];let H;return t[33]!==N||t[34]!==q?(H=n.jsx(Hi,{value:N,children:q}),t[33]=N,t[34]=q,t[35]=H):H=t[35],H}if(e){const J=u.status==="ready"?u.task:null,Z=f?.metadata?.sandboxMap;let G;t[36]!==_.createNewTask?(G=n.jsx(yd,{onNewTaskRef:x,createNewTask:_.createNewTask}),t[36]=_.createNewTask,t[37]=G):G=t[37];const q=!_.mainOpen;let H;t[38]!==_.toggleMain||t[39]!==q?(H=n.jsx(Ui.Toggles,{children:n.jsx(vd,{chatOpen:q,toggleChat:_.toggleMain})}),t[38]=_.toggleMain,t[39]=q,t[40]=H):H=t[40];let K;t[41]!==w||t[42]!==_.taskId?(K=n.jsx(Ui.Tabs,{children:n.jsx(Hw,{virtualMcpId:w,taskId:_.taskId})}),t[41]=w,t[42]=_.taskId,t[43]=K):K=t[43];let B;t[44]===Symbol.for("react.memo_cache_sentinel")?(B=n.jsx(lt.Skeleton,{}),t[44]=B):B=t[44];let X;t[45]!==w||t[46]!==_.mainOpen||t[47]!==_.taskId?(X=n.jsx(R.Suspense,{fallback:B,children:n.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:_.mainOpen?n.jsx(es,{fallback:n.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Something went wrong. Try refreshing."}),children:n.jsx(R.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(Ue,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(kf,{taskId:_.taskId,virtualMcpId:w})})}):n.jsx(xd,{})})}),t[45]=w,t[46]=_.mainOpen,t[47]=_.taskId,t[48]=X):X=t[48];let W;t[49]!==_.taskId||t[50]!==H||t[51]!==K||t[52]!==X?(W=n.jsxs(lt.ActiveTaskProvider,{taskId:_.taskId,children:[H,K,X]},_.taskId),t[49]=_.taskId,t[50]=H,t[51]=K,t[52]=X,t[53]=W):W=t[53];let Y;t[54]!==v||t[55]!==Z||t[56]!==G||t[57]!==W||t[58]!==h?(Y=n.jsxs(bd,{virtualMcpId:h,hasActiveGithubRepo:v,sandboxMap:Z,children:[G,W]}),t[54]=v,t[55]=Z,t[56]=G,t[57]=W,t[58]=h,t[59]=Y):Y=t[59];let Q;t[60]!==w||t[61]!==Y||t[62]!==J?(Q=n.jsx("div",{className:"flex flex-col flex-1 min-w-0 bg-background min-h-0",children:n.jsx(lt.Provider,{virtualMcpId:w,task:J,children:Y},w)}),t[60]=w,t[61]=Y,t[62]=J,t[63]=Q):Q=t[63];let ie;return t[64]!==N||t[65]!==Q?(ie=n.jsx(Hi,{value:N,children:Q}),t[64]=N,t[65]=Q,t[66]=ie):ie=t[66],ie}const T=_.chatOpen&&!_.mainOpen;let A;t[67]!==_.chatOpen||t[68]!==_.toggleChat||t[69]!==T?(A=n.jsx(Ui.Toggles,{children:n.jsx(vd,{chatOpen:_.chatOpen,toggleChat:_.toggleChat,disableChatToggle:T})}),t[67]=_.chatOpen,t[68]=_.toggleChat,t[69]=T,t[70]=A):A=t[70];const k=u.status==="ready"?u.task:null,C=f?.metadata?.sandboxMap;let I;t[71]!==_.taskId||t[72]!==h?(I=n.jsx(Ui.Tabs,{children:n.jsx(zw,{virtualMcpId:h,taskId:_.taskId})}),t[71]=_.taskId,t[72]=h,t[73]=I):I=t[73];let E;t[74]!==_.createNewTask?(E=n.jsx(yd,{onNewTaskRef:x,createNewTask:_.createNewTask}),t[74]=_.createNewTask,t[75]=E):E=t[75];let O;t[76]!==f?(O=n.jsx(uC,{virtualMcp:f}),t[76]=f,t[77]=O):O=t[77];let P;t[78]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx(lt.Skeleton,{}),t[78]=P):P=t[78];let D;t[79]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx(xd,{}),t[79]=D):D=t[79];let M;t[80]!==_.chatOpen||t[81]!==_.mainOpen||t[82]!==_.taskId||t[83]!==h?(M=n.jsx(R.Suspense,{fallback:P,children:n.jsx(Iw,{virtualMcpId:h,taskId:_.taskId,chatOpen:_.chatOpen,mainOpen:_.mainOpen,chatContent:D})}),t[80]=_.chatOpen,t[81]=_.mainOpen,t[82]=_.taskId,t[83]=h,t[84]=M):M=t[84];let z;t[85]!==_.taskId||t[86]!==O||t[87]!==M?(z=n.jsxs(lt.ActiveTaskProvider,{taskId:_.taskId,children:[O,M]},_.taskId),t[85]=_.taskId,t[86]=O,t[87]=M,t[88]=z):z=t[88];let F;t[89]!==v||t[90]!==C||t[91]!==I||t[92]!==E||t[93]!==z||t[94]!==h?(F=n.jsxs(bd,{virtualMcpId:h,hasActiveGithubRepo:v,sandboxMap:C,children:[I,E,z]}),t[89]=v,t[90]=C,t[91]=I,t[92]=E,t[93]=z,t[94]=h,t[95]=F):F=t[95];let $;t[96]!==w||t[97]!==k||t[98]!==F?($=n.jsx(lt.Provider,{virtualMcpId:w,task:k,children:F},w),t[96]=w,t[97]=k,t[98]=F,t[99]=$):$=t[99];let V;return t[100]!==N||t[101]!==A||t[102]!==$?(V=n.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:n.jsxs(Hi,{value:N,children:[A,$]})}),t[100]=N,t[101]=A,t[102]=$,t[103]=V):V=t[103],V}function _C(){const t=U.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(xm,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(R.Suspense,{fallback:e,children:n.jsxs(i3,{children:[n.jsx(gC,{}),n.jsx(mC,{})]})}),t[1]=s):s=t[1],s}const Jk=Object.freeze(Object.defineProperty({__proto__:null,default:_C,useInsetContext:li},Symbol.toStringTag,{value:"Module"}));export{xk as $,Ck as A,S_ as B,w_ as C,L1 as D,z6 as E,Yo as F,pc as G,pn as H,Dk as I,jk as J,Rk as K,B_ as L,cv as M,Ik as N,Ek as O,cx as P,A_ as Q,wk as R,Q8 as S,Ak as T,Tk as U,Kk as V,Nk as W,zk as X,Zu as Y,yk as Z,Sk as _,Mc as a,Fk as a0,Xu as a1,Au as a2,Eu as a3,gk as a4,C_ as a5,Lk as a6,vk as a7,Bk as a8,F_ as a9,ix as aA,rx as aB,Gk as aC,b1 as aD,Vk as aE,Jk as aF,kk as aa,Mk as ab,ai as ac,$h as ad,Ok as ae,Gh as af,Va as ag,ks as ah,Fc as ai,uk as aj,fk as ak,$k as al,Tf as am,mk as an,da as ao,Iv as ap,T6 as aq,mo as ar,Uk as as,dx as at,ox as au,Hr as av,Ar as aw,w8 as ax,er as ay,kr as az,Hk as b,Pk as c,zc as d,pk as e,uc as f,fc as g,li as h,At as i,Fu as j,Ko as k,E6 as l,bc as m,g4 as n,zo as o,Bs as p,Ru as q,bk as r,mL as s,_o as t,wc as u,FL as v,_k as w,av as x,Wk as y,Iu as z};
|