decocms 2.366.5 → 2.366.6
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-DOvZp6Xh.js → AlertCircle-CwzMuMpf.js} +1 -1
- package/dist/client/assets/{ArrowNarrowLeft-Dh4fwURb.js → ArrowNarrowLeft-anbyHmy5.js} +1 -1
- package/dist/client/assets/{ArrowUpRight-D2uLabZX.js → ArrowUpRight-Cb1zJjWa.js} +1 -1
- package/dist/client/assets/{Check-BZ9qj3cZ.js → Check-DGona5mE.js} +1 -1
- package/dist/client/assets/{CheckCircle-BxsQJQ95.js → CheckCircle-DxcUmiZK.js} +1 -1
- package/dist/client/assets/{ChevronDown-DnD7PuzL.js → ChevronDown-BVIdiaZm.js} +1 -1
- package/dist/client/assets/{ChevronRight-DAyRIU_p.js → ChevronRight-Bd356dAz.js} +1 -1
- package/dist/client/assets/{ChevronUp-DJT6cH5l.js → ChevronUp-BjZdqIHm.js} +1 -1
- package/dist/client/assets/{Container-BL5e7-Xm.js → Container-kvfa4KPY.js} +1 -1
- package/dist/client/assets/{DotsVertical-DerAla1q.js → DotsVertical-CZUbDG6o.js} +1 -1
- package/dist/client/assets/{FilterLines-Dh0201WX.js → FilterLines-D9AUiBON.js} +1 -1
- package/dist/client/assets/{HardDrive-D9yTrs1G.js → HardDrive-alRWMahn.js} +1 -1
- package/dist/client/assets/{Key01-CkoO7YfJ.js → Key01-BkAMUOVt.js} +1 -1
- package/dist/client/assets/{LayoutLeft-CDXIJiPR.js → LayoutLeft-BSIyuROS.js} +1 -1
- package/dist/client/assets/{LinkExternal01-CbtLJuKv.js → LinkExternal01-BazomJ3X.js} +1 -1
- package/dist/client/assets/{Lock01-CDOK99rz.js → Lock01-D1c1Oism.js} +1 -1
- package/dist/client/assets/{Monitor01-CV0t1kIU.js → Monitor01-Dkri72GI.js} +1 -1
- package/dist/client/assets/{Palette-DdFj_Myw.js → Palette-Dm4bElxY.js} +1 -1
- package/dist/client/assets/{Play-U3hCwq_K.js → Play-BhMjD9gq.js} +1 -1
- package/dist/client/assets/{Plus-BAo3x5u-.js → Plus-c0eRr9wH.js} +1 -1
- package/dist/client/assets/{RefreshCcw01-Dkl9mWJw.js → RefreshCcw01-Dk0BVwdj.js} +1 -1
- package/dist/client/assets/{SearchMd-CxYi9WND.js → SearchMd-J5wL3p8r.js} +1 -1
- package/dist/client/assets/{Settings02-C75RADbP.js → Settings02-VcBAg_yI.js} +1 -1
- package/dist/client/assets/{Shield01-CyIwhsdF.js → Shield01-WjtNpAUl.js} +1 -1
- package/dist/client/assets/{Star01-DjjYjM_l.js → Star01-DjF7bglG.js} +1 -1
- package/dist/client/assets/{Stars02-D-BWfEGX.js → Stars02-BNllf8d9.js} +1 -1
- package/dist/client/assets/{Sun-CrmrdQ92.js → Sun-BrzkGIAp.js} +1 -1
- package/dist/client/assets/{SwitchHorizontal01-DA93dKCT.js → SwitchHorizontal01-C5pWsPo5.js} +1 -1
- package/dist/client/assets/{Tool01-BsYSycC4.js → Tool01-Cgvg-fFF.js} +1 -1
- package/dist/client/assets/{Trash01-jNGoJGGT.js → Trash01-CtaV1KCh.js} +1 -1
- package/dist/client/assets/{Upload01-DMgmIwWG.js → Upload01-BvZfJrrC.js} +1 -1
- package/dist/client/assets/{User01-DCfiQMzf.js → User01-D0Cbg2TN.js} +1 -1
- package/dist/client/assets/{Users01-oaTMxQSe.js → Users01-CWCsgm-8.js} +1 -1
- package/dist/client/assets/{Users03-CEzSrtvF.js → Users03-DJL_L7hj.js} +1 -1
- package/dist/client/assets/{X-2LD1f3UL.js → X-HlbQgOk5.js} +1 -1
- package/dist/client/assets/{XCircle-C6RRY1PP.js → XCircle-46an_vpE.js} +1 -1
- package/dist/client/assets/{XClose-B6xsNtEi.js → XClose-BBhl7TDc.js} +1 -1
- package/dist/client/assets/{Zap-DJi8JZsj.js → Zap-CPG79cp8.js} +1 -1
- package/dist/client/assets/{ZapSquare-ifezTSJe.js → ZapSquare-BYFC2xpk.js} +1 -1
- package/dist/client/assets/{accordion-CKqE1b4i.js → accordion-BhYZkZFT.js} +1 -1
- package/dist/client/assets/{add-connection-dialog-BaMkLoP_.js → add-connection-dialog-r0iOKxIk.js} +1 -1
- package/dist/client/assets/{agent-icon-CizHG4l0.js → agent-icon-C_-SJvZj.js} +1 -1
- package/dist/client/assets/{agent-icons-e2YdIEpV.js → agent-icons-CDsUfnuX.js} +1 -1
- package/dist/client/assets/{agents-list-VqS5CxLl.js → agents-list-BLTZybUi.js} +1 -1
- package/dist/client/assets/{ai-providers-nReZVRRY.js → ai-providers-DJ6YlhcS.js} +1 -1
- package/dist/client/assets/{alert-CAUgsWeu.js → alert-DFf3NtCO.js} +1 -1
- package/dist/client/assets/{alert-dialog-D2Pm0JQx.js → alert-dialog-CZ4KuCkJ.js} +1 -1
- package/dist/client/assets/{auth-catchall-BUBNm1an.js → auth-catchall-B_J4SD6z.js} +1 -1
- package/dist/client/assets/{auth-split-layout-CCknN4ME.js → auth-split-layout-CWCcYByM.js} +1 -1
- package/dist/client/assets/{automation-list-row-B6-dxb4_.js → automation-list-row-CMOLOW55.js} +1 -1
- package/dist/client/assets/{automations-DoLsgpcb.js → automations-CVf-y96d.js} +1 -1
- package/dist/client/assets/{avatar-Dh1gBZp-.js → avatar-Dmp_G5Ry.js} +1 -1
- package/dist/client/assets/{badge-Cjy_Yz9X.js → badge-Dhqk1439.js} +1 -1
- package/dist/client/assets/{brand-context-CcZxMzP3.js → brand-context-CUwCdwgi.js} +1 -1
- package/dist/client/assets/{card-sB_hdFFr.js → card-_x010Gt4.js} +1 -1
- package/dist/client/assets/{chat-context-BepFuto8.js → chat-context-6MP1sdo4.js} +1 -1
- package/dist/client/assets/{checkbox-BBZ8ZIEJ.js → checkbox-CxMozNlp.js} +1 -1
- package/dist/client/assets/{cli-auth-success-BjtliP0k.js → cli-auth-success-CorV3YMK.js} +1 -1
- package/dist/client/assets/{collection-detail-BQ9KFG7o.js → collection-detail-C9OvFDe3.js} +1 -1
- package/dist/client/assets/{collection-display-button-Cu9JM0Ha.js → collection-display-button-LiA4ZCU1.js} +1 -1
- package/dist/client/assets/{collection-search-3s1cVDET.js → collection-search-2ffGJwV3.js} +1 -1
- package/dist/client/assets/{collection-search-BYE1nPAZ.js → collection-search-P-Jsgn90.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-C7w5CUBJ.js → collection-table-wrapper-B4SaFXaw.js} +1 -1
- package/dist/client/assets/{collection-tabs-DWMIif13.js → collection-tabs-zYvEPyVu.js} +1 -1
- package/dist/client/assets/{collections-DKrxkjJk.js → collections-CMWUgWO4.js} +1 -1
- package/dist/client/assets/{command-CeVP-zGK.js → command-PltV2vRF.js} +1 -1
- package/dist/client/assets/{connect-desktop-dialog-CAjsJmIq.js → connect-desktop-dialog-Bn3-kqkd.js} +1 -1
- package/dist/client/assets/{connection-card-BBJD2xL2.js → connection-card-BzBZi7XR.js} +1 -1
- package/dist/client/assets/{connection-detail-Bc5rHa5E.js → connection-detail-B6Zc_2XI.js} +1 -1
- package/dist/client/assets/{connection-form-helpers-CKogW-2E.js → connection-form-helpers-pLnjCctP.js} +1 -1
- package/dist/client/assets/{connections-ccnZ5rJ2.js → connections--FuYfcE1.js} +1 -1
- package/dist/client/assets/{constants-nXI979GK.js → constants-BNWk3vY4.js} +1 -1
- package/dist/client/assets/{decopilot-sse-pool-DsmFNQBe.js → decopilot-sse-pool-CYUb1xc3.js} +1 -1
- package/dist/client/assets/{dialog-CBRTHbV0.js → dialog-CFmU9mg5.js} +1 -1
- package/dist/client/assets/{domain-settings-D5JWGZSy.js → domain-settings-CQT_VqFx.js} +1 -1
- package/dist/client/assets/{drawer-xDZWqcMn.js → drawer-f2-LbcZU.js} +1 -1
- package/dist/client/assets/{dropdown-menu-Dooq8MCB.js → dropdown-menu-C-3EGUEu.js} +1 -1
- package/dist/client/assets/{dynamic-plugin-layout-lCKeXU9n.js → dynamic-plugin-layout-BRn5TolT.js} +1 -1
- package/dist/client/assets/{empty-state-Dxut4oJq.js → empty-state-Cr8w0yDi.js} +1 -1
- package/dist/client/assets/{empty-state-BWmdCRpI.js → empty-state-YZLDNNT9.js} +1 -1
- package/dist/client/assets/{extract-connection-data-D4fAh8rw.js → extract-connection-data-BHnuRVIs.js} +1 -1
- package/dist/client/assets/{features-C-ixroCe.js → features-C_gJ1Hnh.js} +1 -1
- package/dist/client/assets/{file-explorer-DB2RMOmR.js → file-explorer-Bzt-HVWR.js} +1 -1
- package/dist/client/assets/{files-DrqG1Qil.js → files-cT9oHPBr.js} +1 -1
- package/dist/client/assets/{form-DI3Xad_g.js → form-BLSBgSlG.js} +1 -1
- package/dist/client/assets/{general-NCUVY6WB.js → general-BEp8NXC8.js} +1 -1
- package/dist/client/assets/{generate-id-C384A_Ms.js → generate-id-uphy-ahq.js} +1 -1
- package/dist/client/assets/{github-repo-picker-D2C3i2og.js → github-repo-picker-DovapSuy.js} +1 -1
- package/dist/client/assets/{hooks-Ch7tH1sn.js → hooks-C8YLRuOb.js} +1 -1
- package/dist/client/assets/{hover-card-Y6ov_3SU.js → hover-card-vzSZUxhq.js} +1 -1
- package/dist/client/assets/{import-from-deco-dialog-CPRVLjNn.js → import-from-deco-dialog-IL7Fm2Iy.js} +1 -1
- package/dist/client/assets/{index-A1CzbNLf.js → index-3iXRS0r4.js} +1 -1
- package/dist/client/assets/{index-DFM08g8-.js → index-BF8TFmOX.js} +1 -1
- package/dist/client/assets/{index-BAQ67b0G.js → index-BJFpgh03.js} +1 -1
- package/dist/client/assets/{index-BEzZsj1A.js → index-BgVMU6Xy.js} +1 -1
- package/dist/client/assets/{index-CbShlpPX.js → index-CAuk1Kfg.js} +1 -1
- package/dist/client/assets/{index-BYBws0wj.js → index-CNgrhrjp.js} +1 -1
- package/dist/client/assets/{index-D2eqwiV-.js → index-CPVwAODD.js} +1 -1
- package/dist/client/assets/{index-BKOzLkVh.js → index-CmzX1mYT.js} +4 -4
- package/dist/client/assets/{index-xeDJGyut.js → index-DIrSWTTQ.js} +1 -1
- package/dist/client/assets/{index-COHDvqim.js → index-DMk4r8Ch.js} +1 -1
- package/dist/client/assets/{index-CjGXQHFr.js → index-DQBtGb6t.js} +1 -1
- package/dist/client/assets/{index-BnLPnaHy.js → index-Dflh5WdW.js} +1 -1
- package/dist/client/assets/{index-BmzEUbiE.js → index-DmZfQaD-.js} +2 -2
- package/dist/client/assets/{index-CoorNXlK.js → index-J9vAkQt7.js} +1 -1
- package/dist/client/assets/{index-B0S6yoGD.js → index-LXVBfdMf.js} +1 -1
- package/dist/client/assets/{index-BtFU-Rss.js → index-S-Vi2aBj.js} +1 -1
- package/dist/client/assets/{infiniteQueryObserver-Cx5kTfLE.js → infiniteQueryObserver-ByGhYUFT.js} +1 -1
- package/dist/client/assets/{input-BS7jE0m3.js → input-LBycuk-Q.js} +1 -1
- package/dist/client/assets/{integration-icon-DuApDDsI.js → integration-icon-DtCf-GLI.js} +1 -1
- package/dist/client/assets/{label-C3yI3o29.js → label-xxaAQ94S.js} +1 -1
- package/dist/client/assets/{layout-BWS-OLJb.js → layout-CoRrSFBg.js} +1 -1
- package/dist/client/assets/{login-BwrqoKoS.js → login-9G2u6Vcs.js} +1 -1
- package/dist/client/assets/{members-DwKWeLr7.js → members-BkkUlLs2.js} +1 -1
- package/dist/client/assets/{monaco-editor-Bv_YLKQe.js → monaco-editor-BDwYwChW.js} +1 -1
- package/dist/client/assets/{monitoring-stats-row-B82ikU1f.js → monitoring-stats-row-Cpb3-P2i.js} +1 -1
- package/dist/client/assets/{oauth-callback-ai-provider-CSdewqIb.js → oauth-callback-ai-provider-OHwnOi_W.js} +1 -1
- package/dist/client/assets/{oauth-callback-BhNziByM.js → oauth-callback-huprhNvG.js} +1 -1
- package/dist/client/assets/{onboarding-BmqtEsmj.js → onboarding-D0WghFjD.js} +1 -1
- package/dist/client/assets/{org-layout-BfUxZt7U.js → org-layout-BudcfNQy.js} +1 -1
- package/dist/client/assets/{org-plugin-layout-UF2b-njq.js → org-plugin-layout-C-OOyi3c.js} +1 -1
- package/dist/client/assets/{pair-Cd9ooEF8.js → pair-DOTz8CiV.js} +1 -1
- package/dist/client/assets/{plugin-empty-state-nBsXNUXm.js → plugin-empty-state-9urBLlvA.js} +1 -1
- package/dist/client/assets/{plugin-header-BMSLhLEw.js → plugin-header-DpO6gSMJ.js} +1 -1
- package/dist/client/assets/{plugin-layout-C87gs0Hs.js → plugin-layout-DxyyJ77h.js} +1 -1
- package/dist/client/assets/{popover-CStWnE7A.js → popover-BZvYlx-e.js} +1 -1
- package/dist/client/assets/{profile-CF7DQ8mu.js → profile-Dhdru_gi.js} +1 -1
- package/dist/client/assets/{project-app-view-BAuYCSaY.js → project-app-view-Bk-35e4q.js} +1 -1
- package/dist/client/assets/registry-BJLSs8mI.js +2 -0
- package/dist/client/assets/{registry-layout-DlpFe0pG.js → registry-layout-Xin95QUs.js} +1 -1
- package/dist/client/assets/{required-auth-layout-bXkoChl2.js → required-auth-layout-3nZToecj.js} +1 -1
- package/dist/client/assets/{reset-password-Mgy2rUmK.js → reset-password-Bhnsh_Jm.js} +1 -1
- package/dist/client/assets/{roles-D1bA3Mar.js → roles-Bt85oCAa.js} +1 -1
- package/dist/client/assets/{search-input-hPcYlBZu.js → search-input-hHZ7bOI8.js} +1 -1
- package/dist/client/assets/{secrets-DLyTON5e.js → secrets-A2y9X_7t.js} +1 -1
- package/dist/client/assets/{sections-editor-BaR1msLz.js → sections-editor-CT7Vp1k1.js} +1 -1
- package/dist/client/assets/{select-DqoZr-sQ.js → select-COYVRAvf.js} +1 -1
- package/dist/client/assets/{settings-layout-B4VozgVj.js → settings-layout-AMglN190.js} +1 -1
- package/dist/client/assets/{settings-section-DIHa9ACH.js → settings-section-CvUdnvHo.js} +1 -1
- package/dist/client/assets/{shell-controls-CjV4fZIy.js → shell-controls-C8TKUg7F.js} +1 -1
- package/dist/client/assets/{shell-layout-D-wA7hGq.js → shell-layout-BQiN2_dH.js} +1 -1
- package/dist/client/assets/{sidebar-Q7T53BbB.js → sidebar-DDhNiQmf.js} +1 -1
- package/dist/client/assets/{skeleton-Dj7zWNd-.js → skeleton-De826Bp4.js} +1 -1
- package/dist/client/assets/{sortable.esm-DoEW2UnN.js → sortable.esm--NDulp9A.js} +1 -1
- package/dist/client/assets/{spinner-CD8znsYa.js → spinner-aWkRS-qf.js} +1 -1
- package/dist/client/assets/{sso-DgD3S504.js → sso-Dwz9x-5L.js} +1 -1
- package/dist/client/assets/{store-C8jLcQiK.js → store-BsA0H-oK.js} +1 -1
- package/dist/client/assets/store-registry-CxxsirnM.js +2 -0
- package/dist/client/assets/{switch-DMUyHRMq.js → switch-Cmz_NhXm.js} +1 -1
- package/dist/client/assets/{table-B_Dp8FO2.js → table-DZHPjC_4.js} +1 -1
- package/dist/client/assets/{tabs-Bh3oiEMm.js → tabs-CozIPTAA.js} +1 -1
- package/dist/client/assets/{task-status-BEXQOENQ.js → task-status-Bm6cE2vl.js} +1 -1
- package/dist/client/assets/{textarea-BxqMslcX.js → textarea-CdaHW1-E.js} +1 -1
- package/dist/client/assets/{toggle-group-ncyLTPv1.js → toggle-group-uYe932ea.js} +1 -1
- package/dist/client/assets/{toolbar-BDTT5tuG.js → toolbar-DTECgCHe.js} +1 -1
- package/dist/client/assets/{tools-list-C7nj60Uy.js → tools-list--glS5MjS.js} +1 -1
- package/dist/client/assets/{tooltip-Ds9kbMl5.js → tooltip-PHPuJMK6.js} +1 -1
- package/dist/client/assets/{types-BKj9BekL.js → types-BcJnlpKC.js} +1 -1
- package/dist/client/assets/{use-ai-providers-ChGtpRz1.js → use-ai-providers-9O0qMpCv.js} +1 -1
- package/dist/client/assets/{use-collections-LvNvrA4A.js → use-collections-MMy3tGV8.js} +1 -1
- package/dist/client/assets/{use-connection-BX7GcHF8.js → use-connection-CXkgxjx7.js} +1 -1
- package/dist/client/assets/{use-copy-D0bJKDe4.js → use-copy-BCZtNoNP.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-zSnCO6BS.js → use-create-virtual-mcp-D3-vWJlc.js} +1 -1
- package/dist/client/assets/{use-debounced-autosave-PFKqNDl5.js → use-debounced-autosave-Czr8puWw.js} +1 -1
- package/dist/client/assets/{use-delete-connection-25Plxk4s.js → use-delete-connection-xhnDY9YU.js} +1 -1
- package/dist/client/assets/{use-file-configs-DnMyRSYs.js → use-file-configs-C25S803h.js} +1 -1
- package/dist/client/assets/{use-infinite-scroll-G3Q2ih4Q.js → use-infinite-scroll-xBBc18Pi.js} +1 -1
- package/dist/client/assets/{use-list-state-CA7uQm-c.js → use-list-state-D7plvWWp.js} +1 -1
- package/dist/client/assets/{use-mcp-prompts-BtS7zlWf.js → use-mcp-prompts-Cxu5Gqkp.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-x0yVR6vI.js → use-mcp-tools-C5gUP503.js} +1 -1
- package/dist/client/assets/{use-members-B21IVrKx.js → use-members-yUJ-bFnT.js} +1 -1
- package/dist/client/assets/{use-navigate-to-agent-DVTw1toP.js → use-navigate-to-agent-S-7lONzg.js} +1 -1
- package/dist/client/assets/{use-org-auth-client-B-HFcBUg.js → use-org-auth-client-BZ5KVR08.js} +1 -1
- package/dist/client/assets/{use-org-sso-CJpg6yVr.js → use-org-sso-BU7YElAe.js} +1 -1
- package/dist/client/assets/{use-organization-roles--MVNq9jj.js → use-organization-roles-D1DoBsv2.js} +1 -1
- package/dist/client/assets/{use-organization-settings-C556Fx5-.js → use-organization-settings-CTSrXAT6.js} +1 -1
- package/dist/client/assets/{use-registry-connections-BMvk-FTD.js → use-registry-connections-BtJD3GbW.js} +1 -1
- package/dist/client/assets/{use-secrets-BQQyRSGs.js → use-secrets--HY-PJBE.js} +1 -1
- package/dist/client/assets/{use-status-sounds-UzP4b9M9.js → use-status-sounds-BtwQHpIn.js} +1 -1
- package/dist/client/assets/{use-view-mode-Dqxlfua3.js → use-view-mode-gBmBle3L.js} +1 -1
- package/dist/client/assets/{use-virtual-mcp-EW_AL6Wa.js → use-virtual-mcp-aFEyYbrv.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-d4Y-q2-f.js +1 -0
- package/dist/client/assets/{useRouterState-Crt4q8HW.js → useRouterState-CsqSaCr4.js} +1 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-Ccz7tT5r.js +1 -0
- package/dist/client/assets/{user-CEhYFaOI.js → user-LB-FZ4W_.js} +1 -1
- package/dist/client/assets/{view-mode-toggle-CWXaBL22.js → view-mode-toggle-BUR8EnzD.js} +1 -1
- package/dist/client/assets/workflow-detail-cXpO7MiL.js +1 -0
- package/dist/client/assets/{workflow-BjXow_ap.js → workflow-n1ew70ne.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/server/cli.js +1 -1
- package/dist/server/node_modules/@opentelemetry/core/LICENSE +201 -0
- package/dist/server/node_modules/@opentelemetry/core/README.md +73 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/ExportResult.d.ts +9 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/ExportResult.js +21 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/ExportResult.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/baggage/constants.d.ts +8 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/baggage/constants.js +27 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/baggage/constants.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/baggage/propagation/W3CBaggagePropagator.d.ts +13 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/baggage/propagation/W3CBaggagePropagator.js +72 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/baggage/propagation/W3CBaggagePropagator.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/baggage/utils.d.ts +16 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/baggage/utils.js +69 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/baggage/utils.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/anchored-clock.d.ts +41 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/anchored-clock.js +57 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/anchored-clock.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/attributes.d.ts +5 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/attributes.js +87 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/attributes.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/global-error-handler.d.ts +13 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/global-error-handler.js +36 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/global-error-handler.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/logging-error-handler.d.ts +7 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/logging-error-handler.js +59 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/logging-error-handler.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/time.d.ts +59 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/time.js +156 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/time.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/timer-util.d.ts +8 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/timer-util.js +25 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/timer-util.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/types.d.ts +33 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/types.js +17 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/types.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/index.d.ts +30 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/index.js +40 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/index.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/internal/exporter.d.ts +10 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/internal/exporter.js +32 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/internal/exporter.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/internal/validators.d.ts +15 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/internal/validators.js +41 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/internal/validators.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/browser/environment.d.ts +5 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/browser/environment.js +28 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/browser/environment.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/browser/globalThis.d.ts +10 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/browser/globalThis.js +35 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/browser/globalThis.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/browser/index.d.ts +5 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/browser/index.js +20 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/browser/index.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/browser/performance.d.ts +5 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/browser/performance.js +17 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/browser/performance.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/browser/sdk-info.d.ts +8 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/browser/sdk-info.js +26 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/browser/sdk-info.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/index.d.ts +2 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/index.js +17 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/index.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/node/environment.d.ts +40 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/node/environment.js +97 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/node/environment.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/node/globalThis.d.ts +3 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/node/globalThis.js +19 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/node/globalThis.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/node/index.d.ts +5 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/node/index.js +20 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/node/index.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/node/performance.d.ts +5 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/node/performance.js +18 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/node/performance.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/node/sdk-info.d.ts +8 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/node/sdk-info.js +26 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/node/sdk-info.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/propagation/composite.d.ts +43 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/propagation/composite.js +77 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/propagation/composite.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/semconv.d.ts +9 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/semconv.js +29 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/semconv.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/trace/TraceState.d.ts +22 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/trace/TraceState.js +99 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/trace/TraceState.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/trace/W3CTraceContextPropagator.d.ts +26 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/trace/W3CTraceContextPropagator.js +99 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/trace/W3CTraceContextPropagator.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/trace/rpc-metadata.d.ts +18 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/trace/rpc-metadata.js +31 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/trace/rpc-metadata.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/trace/suppress-tracing.d.ts +5 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/trace/suppress-tracing.js +27 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/trace/suppress-tracing.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/callback.d.ts +14 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/callback.js +48 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/callback.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/configuration.d.ts +7 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/configuration.js +42 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/configuration.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/lodash.merge.d.ts +30 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/lodash.merge.js +153 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/lodash.merge.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/merge.d.ts +6 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/merge.js +158 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/merge.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/promise.d.ts +10 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/promise.js +36 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/promise.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/timeout.d.ts +17 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/timeout.js +51 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/timeout.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/url.d.ts +8 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/url.js +40 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/url.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/version.d.ts +2 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/version.js +18 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esm/version.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/ExportResult.d.ts +9 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/ExportResult.js +21 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/ExportResult.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/baggage/constants.d.ts +8 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/baggage/constants.js +27 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/baggage/constants.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/baggage/propagation/W3CBaggagePropagator.d.ts +13 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/baggage/propagation/W3CBaggagePropagator.js +72 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/baggage/propagation/W3CBaggagePropagator.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/baggage/utils.d.ts +16 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/baggage/utils.js +69 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/baggage/utils.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/anchored-clock.d.ts +41 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/anchored-clock.js +57 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/anchored-clock.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/attributes.d.ts +5 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/attributes.js +87 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/attributes.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/global-error-handler.d.ts +13 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/global-error-handler.js +36 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/global-error-handler.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/logging-error-handler.d.ts +7 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/logging-error-handler.js +59 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/logging-error-handler.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/time.d.ts +59 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/time.js +156 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/time.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/timer-util.d.ts +8 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/timer-util.js +25 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/timer-util.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/types.d.ts +33 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/types.js +17 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/types.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/index.d.ts +30 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/index.js +40 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/index.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/internal/exporter.d.ts +10 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/internal/exporter.js +32 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/internal/exporter.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/internal/validators.d.ts +15 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/internal/validators.js +41 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/internal/validators.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/browser/environment.d.ts +5 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/browser/environment.js +28 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/browser/environment.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/browser/globalThis.d.ts +10 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/browser/globalThis.js +35 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/browser/globalThis.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/browser/index.d.ts +5 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/browser/index.js +20 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/browser/index.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/browser/performance.d.ts +5 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/browser/performance.js +17 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/browser/performance.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/browser/sdk-info.d.ts +8 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/browser/sdk-info.js +26 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/browser/sdk-info.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/index.d.ts +2 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/index.js +17 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/index.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/node/environment.d.ts +40 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/node/environment.js +97 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/node/environment.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/node/globalThis.d.ts +3 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/node/globalThis.js +19 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/node/globalThis.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/node/index.d.ts +5 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/node/index.js +20 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/node/index.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/node/performance.d.ts +5 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/node/performance.js +18 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/node/performance.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/node/sdk-info.d.ts +8 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/node/sdk-info.js +26 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/node/sdk-info.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/propagation/composite.d.ts +43 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/propagation/composite.js +77 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/propagation/composite.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/semconv.d.ts +9 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/semconv.js +29 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/semconv.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/trace/TraceState.d.ts +22 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/trace/TraceState.js +99 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/trace/TraceState.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/trace/W3CTraceContextPropagator.d.ts +26 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/trace/W3CTraceContextPropagator.js +99 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/trace/W3CTraceContextPropagator.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/trace/rpc-metadata.d.ts +18 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/trace/rpc-metadata.js +31 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/trace/rpc-metadata.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/trace/suppress-tracing.d.ts +5 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/trace/suppress-tracing.js +27 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/trace/suppress-tracing.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/callback.d.ts +14 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/callback.js +48 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/callback.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/configuration.d.ts +7 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/configuration.js +42 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/configuration.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/lodash.merge.d.ts +30 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/lodash.merge.js +153 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/lodash.merge.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/merge.d.ts +6 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/merge.js +158 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/merge.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/promise.d.ts +10 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/promise.js +36 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/promise.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/timeout.d.ts +17 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/timeout.js +51 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/timeout.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/url.d.ts +8 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/url.js +40 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/url.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/version.d.ts +2 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/version.js +18 -0
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/version.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/ExportResult.d.ts +9 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/ExportResult.js +24 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/ExportResult.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/baggage/constants.d.ts +8 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/baggage/constants.js +30 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/baggage/constants.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/baggage/propagation/W3CBaggagePropagator.d.ts +13 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/baggage/propagation/W3CBaggagePropagator.js +76 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/baggage/propagation/W3CBaggagePropagator.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/baggage/utils.d.ts +16 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/baggage/utils.js +76 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/baggage/utils.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/anchored-clock.d.ts +41 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/anchored-clock.js +61 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/anchored-clock.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/attributes.d.ts +5 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/attributes.js +93 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/attributes.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/global-error-handler.d.ts +13 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/global-error-handler.js +41 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/global-error-handler.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/logging-error-handler.d.ts +7 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/logging-error-handler.js +63 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/logging-error-handler.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/time.d.ts +59 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/time.js +171 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/time.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/timer-util.d.ts +8 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/timer-util.js +29 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/timer-util.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/types.d.ts +33 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/types.js +18 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/types.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/index.d.ts +30 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/index.js +92 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/index.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/internal/exporter.d.ts +10 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/internal/exporter.js +36 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/internal/exporter.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/internal/validators.d.ts +15 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/internal/validators.js +46 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/internal/validators.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/browser/environment.d.ts +5 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/browser/environment.js +35 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/browser/environment.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/browser/globalThis.d.ts +10 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/browser/globalThis.js +38 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/browser/globalThis.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/browser/index.d.ts +5 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/browser/index.js +30 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/browser/index.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/browser/performance.d.ts +5 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/browser/performance.js +20 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/browser/performance.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/browser/sdk-info.d.ts +8 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/browser/sdk-info.js +29 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/browser/sdk-info.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/index.d.ts +2 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/index.js +27 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/index.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/node/environment.d.ts +40 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/node/environment.js +104 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/node/environment.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/node/globalThis.d.ts +3 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/node/globalThis.js +22 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/node/globalThis.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/node/index.d.ts +5 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/node/index.js +30 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/node/index.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/node/performance.d.ts +5 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/node/performance.js +21 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/node/performance.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/node/sdk-info.d.ts +8 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/node/sdk-info.js +29 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/node/sdk-info.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/propagation/composite.d.ts +43 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/propagation/composite.js +81 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/propagation/composite.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/semconv.d.ts +9 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/semconv.js +32 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/semconv.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/trace/TraceState.d.ts +22 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/trace/TraceState.js +103 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/trace/TraceState.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/trace/W3CTraceContextPropagator.d.ts +26 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/trace/W3CTraceContextPropagator.js +104 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/trace/W3CTraceContextPropagator.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/trace/rpc-metadata.d.ts +18 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/trace/rpc-metadata.js +37 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/trace/rpc-metadata.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/trace/suppress-tracing.d.ts +5 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/trace/suppress-tracing.js +33 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/trace/suppress-tracing.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/callback.d.ts +14 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/callback.js +52 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/callback.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/configuration.d.ts +7 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/configuration.js +46 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/configuration.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/lodash.merge.d.ts +30 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/lodash.merge.js +157 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/lodash.merge.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/merge.d.ts +6 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/merge.js +162 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/merge.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/promise.d.ts +10 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/promise.js +40 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/promise.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/timeout.d.ts +17 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/timeout.js +56 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/timeout.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/url.d.ts +8 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/url.js +45 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/url.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/version.d.ts +2 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/version.js +21 -0
- package/dist/server/node_modules/@opentelemetry/core/build/src/version.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/core/package.json +93 -0
- package/dist/server/node_modules/@opentelemetry/otlp-transformer/build/esm/generated/root.js +6 -36
- package/dist/server/node_modules/@opentelemetry/otlp-transformer/build/esm/generated/root.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-transformer/build/esm/trace/internal.js +0 -15
- package/dist/server/node_modules/@opentelemetry/otlp-transformer/build/esm/trace/internal.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-transformer/build/esnext/generated/root.js +6 -36
- package/dist/server/node_modules/@opentelemetry/otlp-transformer/build/esnext/generated/root.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-transformer/build/esnext/trace/internal.js +0 -15
- package/dist/server/node_modules/@opentelemetry/otlp-transformer/build/esnext/trace/internal.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-transformer/build/src/generated/root.js +6 -36
- package/dist/server/node_modules/@opentelemetry/otlp-transformer/build/src/generated/root.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-transformer/build/src/trace/internal.js +0 -15
- package/dist/server/node_modules/@opentelemetry/otlp-transformer/build/src/trace/internal.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-transformer/package.json +14 -12
- package/dist/server/node_modules/get-east-asian-width/index.d.ts +60 -0
- package/dist/server/node_modules/get-east-asian-width/index.js +30 -0
- package/dist/server/node_modules/get-east-asian-width/lookup-data.js +18 -0
- package/dist/server/node_modules/get-east-asian-width/lookup.js +135 -0
- package/dist/server/node_modules/get-east-asian-width/package.json +71 -0
- package/dist/server/node_modules/get-east-asian-width/readme.md +65 -0
- package/dist/server/node_modules/get-east-asian-width/utilities.js +24 -0
- package/package.json +1 -1
- package/dist/client/assets/registry-CNIjRu_K.js +0 -2
- package/dist/client/assets/store-registry-BY9W-N3z.js +0 -2
- package/dist/client/assets/useInfiniteQuery-1O-BDmQo.js +0 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-1fzDjk80.js +0 -1
- package/dist/client/assets/workflow-detail-mtpXz9OO.js +0 -1
- package/dist/server/node_modules/@protobufjs/aspromise/LICENSE +0 -26
- package/dist/server/node_modules/@protobufjs/aspromise/README.md +0 -13
- package/dist/server/node_modules/@protobufjs/aspromise/index.d.ts +0 -13
- package/dist/server/node_modules/@protobufjs/aspromise/index.js +0 -52
- package/dist/server/node_modules/@protobufjs/aspromise/package.json +0 -21
- package/dist/server/node_modules/@protobufjs/aspromise/tests/index.js +0 -130
- package/dist/server/node_modules/@protobufjs/base64/LICENSE +0 -26
- package/dist/server/node_modules/@protobufjs/base64/README.md +0 -19
- package/dist/server/node_modules/@protobufjs/base64/index.d.ts +0 -32
- package/dist/server/node_modules/@protobufjs/base64/index.js +0 -139
- package/dist/server/node_modules/@protobufjs/base64/package.json +0 -21
- package/dist/server/node_modules/@protobufjs/base64/tests/index.js +0 -46
- package/dist/server/node_modules/@protobufjs/eventemitter/LICENSE +0 -26
- package/dist/server/node_modules/@protobufjs/eventemitter/README.md +0 -22
- package/dist/server/node_modules/@protobufjs/eventemitter/index.d.ts +0 -43
- package/dist/server/node_modules/@protobufjs/eventemitter/index.js +0 -76
- package/dist/server/node_modules/@protobufjs/eventemitter/package.json +0 -21
- package/dist/server/node_modules/@protobufjs/eventemitter/tests/index.js +0 -47
- package/dist/server/node_modules/@protobufjs/float/LICENSE +0 -26
- package/dist/server/node_modules/@protobufjs/float/README.md +0 -102
- package/dist/server/node_modules/@protobufjs/float/bench/index.js +0 -87
- package/dist/server/node_modules/@protobufjs/float/bench/suite.js +0 -46
- package/dist/server/node_modules/@protobufjs/float/index.d.ts +0 -83
- package/dist/server/node_modules/@protobufjs/float/index.js +0 -335
- package/dist/server/node_modules/@protobufjs/float/package.json +0 -26
- package/dist/server/node_modules/@protobufjs/float/tests/index.js +0 -100
- package/dist/server/node_modules/@protobufjs/inquire/LICENSE +0 -26
- package/dist/server/node_modules/@protobufjs/inquire/README.md +0 -13
- package/dist/server/node_modules/@protobufjs/inquire/index.d.ts +0 -9
- package/dist/server/node_modules/@protobufjs/inquire/index.js +0 -37
- package/dist/server/node_modules/@protobufjs/inquire/package.json +0 -21
- package/dist/server/node_modules/@protobufjs/inquire/tests/data/array.js +0 -1
- package/dist/server/node_modules/@protobufjs/inquire/tests/data/emptyArray.js +0 -1
- package/dist/server/node_modules/@protobufjs/inquire/tests/data/emptyObject.js +0 -1
- package/dist/server/node_modules/@protobufjs/inquire/tests/data/object.js +0 -1
- package/dist/server/node_modules/@protobufjs/inquire/tests/index.js +0 -20
- package/dist/server/node_modules/@protobufjs/pool/LICENSE +0 -26
- package/dist/server/node_modules/@protobufjs/pool/README.md +0 -13
- package/dist/server/node_modules/@protobufjs/pool/index.d.ts +0 -32
- package/dist/server/node_modules/@protobufjs/pool/index.js +0 -48
- package/dist/server/node_modules/@protobufjs/pool/package.json +0 -21
- package/dist/server/node_modules/@protobufjs/pool/tests/index.js +0 -33
- package/dist/server/node_modules/@protobufjs/utf8/LICENSE +0 -26
- package/dist/server/node_modules/@protobufjs/utf8/README.md +0 -20
- package/dist/server/node_modules/@protobufjs/utf8/index.d.ts +0 -24
- package/dist/server/node_modules/@protobufjs/utf8/index.js +0 -104
- package/dist/server/node_modules/@protobufjs/utf8/package.json +0 -21
- package/dist/server/node_modules/@protobufjs/utf8/tests/data/surrogate_pair_bug.txt +0 -207
- package/dist/server/node_modules/@protobufjs/utf8/tests/data/utf8.txt +0 -216
- package/dist/server/node_modules/@protobufjs/utf8/tests/index.js +0 -74
- package/dist/server/node_modules/ansi-styles/index.d.ts +0 -236
- package/dist/server/node_modules/ansi-styles/index.js +0 -223
- package/dist/server/node_modules/ansi-styles/package.json +0 -54
- package/dist/server/node_modules/ansi-styles/readme.md +0 -173
- package/dist/server/node_modules/deepmerge/.editorconfig +0 -7
- package/dist/server/node_modules/deepmerge/.eslintcache +0 -1
- package/dist/server/node_modules/deepmerge/changelog.md +0 -167
- package/dist/server/node_modules/deepmerge/dist/cjs.js +0 -133
- package/dist/server/node_modules/deepmerge/dist/umd.js +0 -139
- package/dist/server/node_modules/deepmerge/index.d.ts +0 -20
- package/dist/server/node_modules/deepmerge/index.js +0 -106
- package/dist/server/node_modules/deepmerge/license.txt +0 -21
- package/dist/server/node_modules/deepmerge/package.json +0 -42
- package/dist/server/node_modules/deepmerge/readme.md +0 -264
- package/dist/server/node_modules/deepmerge/rollup.config.js +0 -22
- package/dist/server/node_modules/figures/index.d.ts +0 -279
- package/dist/server/node_modules/figures/index.js +0 -292
- package/dist/server/node_modules/figures/license +0 -9
- package/dist/server/node_modules/figures/package.json +0 -49
- package/dist/server/node_modules/figures/readme.md +0 -337
- package/dist/server/node_modules/xtend/.jshintrc +0 -30
- package/dist/server/node_modules/xtend/LICENSE +0 -20
- package/dist/server/node_modules/xtend/README.md +0 -32
- package/dist/server/node_modules/xtend/immutable.js +0 -19
- package/dist/server/node_modules/xtend/mutable.js +0 -17
- package/dist/server/node_modules/xtend/package.json +0 -55
- package/dist/server/node_modules/xtend/test.js +0 -103
- /package/dist/server/node_modules/{ansi-styles → get-east-asian-width}/license +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sections-editor-
|
|
2
|
-
import{e as F,r as D,c as te,j as n,l as Se,E as It,q as ke,f as Kt,d as Kn,g as cl,s as Eh,K as rs,o as ae,B as Q,v as Xs,V as Th,t as Ee,b as ir,w as hl,x as Rh,y as rr,z as ns,C as at,D as Vn,F as dl,G as Ph,H as Dh,I as Bo,n as nr,L as Ah,a as qn,J as Oi,M as Us,P as mt,_ as Gn,Q as Yn,R as Ih,T as Mh,p as ul,U as fl}from"./index-BmzEUbiE.js";import{C as Le,u as Bh,w as Lh,a as ml,b as Oh,s as jr,T as $h,t as zh,r as Fh,c as Hh,d as Wh,g as Uh}from"./index-DFM08g8-.js";import{I as cs}from"./integration-icon-DuApDDsI.js";import{g as Xn,u as Je,S as Ns,a as pl}from"./constants-nXI979GK.js";import{u as Mt,a as Kh}from"./use-virtual-mcp-EW_AL6Wa.js";import{a as Vh}from"./Users03-CEzSrtvF.js";import{u as hs,a as ds,b as or,c as ar,h as qh,d as _l,g as oi,t as Gh,e as Lo,f as Yh}from"./chat-context-BepFuto8.js";import{i as Jn}from"./AlertCircle-DOvZp6Xh.js";import{i as Xh}from"./CheckCircle-BxsQJQ95.js";import{n as Oo}from"./ZapSquare-ifezTSJe.js";import{i as Jh,a as Zn,b as Zh}from"./XCircle-C6RRY1PP.js";import{s as ks}from"./XClose-B6xsNtEi.js";import{c as Qh,r as ed,a as td,p as gl,f as $o,b as sd,F as id,t as Nr,M as Qn,G as rd,i as nd,d as od,e as ad,g as ld,h as cd}from"./pair-Cd9ooEF8.js";import{u as hd}from"./use-ai-providers-ChGtpRz1.js";import{u as dd}from"./connect-desktop-dialog-CAjsJmIq.js";import{r as ud,u as eo,i as fd}from"./shell-layout-D-wA7hGq.js";import{b as md,a as pd}from"./index-xeDJGyut.js";import{u as _d,c as gd,d as vd,e as xd}from"./sidebar-Q7T53BbB.js";import{u as vl,T as Te,a as Re,b as Pe,c as xl}from"./tooltip-Ds9kbMl5.js";import{i as to,a as bd,b as Sd,p as lr,g as cr,c as so,d as bl,h as Vr,e as Er,f as zo,A as Fo,j as io,k as yd,l as wd,n as Cd,m as kd,o as jd,t as Nd,q as Ed,s as Td,r as Sl,u as qr,v as yl,w as wl,x as Ho,y as Rd,z as Pd,B as ro,C as Wo,D as Js,E as Cl,F as kl,G as Dd,H as Ad}from"./agent-icon-CizHG4l0.js";import{u as Id}from"./use-status-sounds-UzP4b9M9.js";import{E as qi}from"./empty-state-BWmdCRpI.js";import{u as Md,a as jl}from"./hooks-Ch7tH1sn.js";import{T as Uo,a as Gr}from"./toolbar-BDTT5tuG.js";import{A as Bd,a as Ld,b as Od,c as $d,R as Nl,d as zd,e as Fd}from"./accordion-CKqE1b4i.js";import{u as hr,a as no,b as Hd}from"./use-connection-BX7GcHF8.js";import{g as Wd}from"./generate-id-C384A_Ms.js";import{u as Ud,g as Kd}from"./types-BKj9BekL.js";import{U as El}from"./user-CEhYFaOI.js";import{T as Vd,u as Tl}from"./tools-list-C7nj60Uy.js";import{u as qd}from"./unwrap-tool-result-BYXdCQMg.js";import{s as Rl,g as Gd}from"./connection-slug-eyAPH6o3.js";import{A as Yr,a as Xr,b as Jr,c as Zr,d as Qr,e as en,f as tn,g as sn}from"./alert-dialog-D2Pm0JQx.js";import{D as dr,a as us,b as fs,c as ai,d as li,e as Pl}from"./dialog-CBRTHbV0.js";import{C as Dl,a as rn}from"./card-sB_hdFFr.js";import{I as it}from"./input-BS7jE0m3.js";import{L as lt}from"./label-C3yI3o29.js";import{S as yt,a as wt,b as Ct,c as kt,d as Qe}from"./select-DqoZr-sQ.js";import{S as nn}from"./switch-DMUyHRMq.js";import{T as Gi}from"./textarea-BxqMslcX.js";import{i as os}from"./Play-U3hCwq_K.js";import{s as Ut}from"./Plus-BAo3x5u-.js";import{a as Yd}from"./Settings02-C75RADbP.js";import{t as oo,i as Xd}from"./Tool01-BsYSycC4.js";import{s as Yi}from"./Trash01-jNGoJGGT.js";import{u as Xi}from"./use-debounced-autosave-PFKqNDl5.js";import{P as ci,a as hi,b as di}from"./popover-CStWnE7A.js";import{S as Al,M as Jd,l as Zd,w as Qd}from"./monaco-editor-Bv_YLKQe.js";import{i as Il}from"./SearchMd-CxYi9WND.js";import{i as eu}from"./Upload01-DMgmIwWG.js";import{i as tu}from"./LayoutLeft-CDXIJiPR.js";import{P as pt}from"./index-BtFU-Rss.js";import{A as su}from"./add-connection-dialog-BaMkLoP_.js";import{C as iu}from"./collection-tabs-DWMIif13.js";import{C as Ml}from"./checkbox-BBZ8ZIEJ.js";import{u as ru,a as ui}from"./use-mcp-tools-x0yVR6vI.js";import{u as nu}from"./use-mcp-prompts-BtS7zlWf.js";import{D as ou,a as au,b as lu}from"./drawer-xDZWqcMn.js";import{i as fi}from"./Check-BZ9qj3cZ.js";import{a as es,i as cu,s as hu}from"./RefreshCcw01-Dkl9mWJw.js";import{i as Bl}from"./Key01-CkoO7YfJ.js";import{S as ys}from"./skeleton-Dj7zWNd-.js";import{i as du}from"./Lock01-CDOK99rz.js";import{s as uu}from"./User01-DCfiQMzf.js";import{t as fu}from"./Users01-oaTMxQSe.js";import{u as mu,a as pu}from"./use-secrets-BQQyRSGs.js";import{G as _u}from"./github-repo-picker-D2C3i2og.js";import{n as ms}from"./LinkExternal01-CbtLJuKv.js";import{T as ts,a as ao,b as lo,c as Zs}from"./tabs-Bh3oiEMm.js";import{S as Ll}from"./spinner-CD8znsYa.js";import{D as mi,a as pi,b as _i,c as Dt,d as gu,e as vu,f as xu}from"./dropdown-menu-Dooq8MCB.js";import{t as co}from"./ChevronDown-DnD7PuzL.js";import{i as bu}from"./ChevronRight-DAyRIU_p.js";import{s as Su}from"./Star01-DjjYjM_l.js";import{V as yu}from"./view-mode-toggle-CWXaBL22.js";import{i as wu}from"./X-2LD1f3UL.js";import{u as gi,a as Cu,b as ku,c as ju,A as Nu,d as Eu}from"./automation-list-row-B6-dxb4_.js";import{i as Tu}from"./SwitchHorizontal01-DA93dKCT.js";import{i as ti}from"./Zap-DJi8JZsj.js";import{S as Ru}from"./search-input-hPcYlBZu.js";function Bs(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function Ko(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 Pu(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function Du(t){const e=F.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Au),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 Au(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 Iu(t){const e=F.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,h=o>0?r/o*100:0;let c;e[0]!==a?(c=a>0&&n.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=c):c=e[1];let d;e[2]!==l?(d=l>0&&n.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=d):d=e[3];let u;e[4]!==h?(u=h>0&&n.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${h}%`}}),e[4]=h,e[5]=u):u=e[5];let f;e[6]!==c||e[7]!==d||e[8]!==u?(f=n.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[c,d,u]}),e[6]=c,e[7]=d,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 _;e[13]!==p?(_=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]=_):_=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=g):g=e[15];let x;e[16]!==l?(x=l.toFixed(1),e[16]=l,e[17]=x):x=e[17];let S;e[18]!==x?(S=n.jsxs("div",{className:"flex items-center gap-1.5",children:[g,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",x,"%"]})]}),e[18]=x,e[19]=S):S=e[19];let v;e[20]!==h||e[21]!==r?(v=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 ",h.toFixed(1),"%"]})]}),e[20]=h,e[21]=r,e[22]=v):v=e[22];let b;e[23]!==S||e[24]!==v||e[25]!==_?(b=n.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[_,S,v]}),e[23]=S,e[24]=v,e[25]=_,e[26]=b):b=e[26];let y;return e[27]!==b||e[28]!==f?(y=n.jsxs("div",{className:"flex flex-col gap-2",children:[f,b]}),e[27]=b,e[28]=f,e[29]=y):y=e[29],y}function Mu(t){const e=F.c(11),{agentId:s,isError:i}=t,r=Mt(s),o=r?.title??"Subtask",a=r?.icon??null;let l;e[0]!==a||e[1]!==o?(l=n.jsx(cs,{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 h=i?"text-destructive":"text-foreground";let c;e[3]!==h?(c=te("shrink-0 font-medium",h),e[3]=h,e[4]=c):c=e[4];let d;e[5]!==o||e[6]!==c?(d=n.jsx("span",{className:c,children:o}),e[5]=o,e[6]=c,e[7]=d):d=e[7];let u;return e[8]!==l||e[9]!==d?(u=n.jsxs(n.Fragment,{children:[l,d]}),e[8]=l,e[9]=d,e[10]=u):u=e[10],u}function Bu(t){const e=F.c(5),{isError:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(cs,{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=te("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 Lu(t){const e=F.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(Bu,{isError:o}),e[0]=o,e[1]=l):l=e[1];let h;e[2]!==i||e[3]!==o?(h=n.jsx(Mu,{agentId:i,isError:o}),e[2]=i,e[3]=o,e[4]=h):h=e[4];let c;e[5]!==l||e[6]!==h?(c=n.jsx(D.Suspense,{fallback:l,children:h}),e[5]=l,e[6]=h,e[7]=c):c=e[7];let d;e[8]!==s.input?(d=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]=d):d=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(Se,{size:12,className:"animate-spin text-muted-foreground"}):o?n.jsx(Jh,{size:12,className:"text-destructive"}):a?n.jsx(Jn,{size:12,className:"text-warning"}):n.jsx(Xh,{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]!==c||e[15]!==d||e[16]!==u?(f=n.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[c,d,u]}),e[14]=c,e[15]=d,e[16]=u,e[17]=f):f=e[17],f}function Ou(t){const e=F.c(55),{onClose:s,back:i,className:r}=t,[o,a]=D.useState(null),{messages:l}=hs(),{activeTask:h}=ds(),{selectedModel:c,selectedVirtualMcp:d}=or();let u,f,m,p,_,g,x,S;if(e[0]!==h||e[1]!==i||e[2]!==r||e[3]!==l||e[4]!==s||e[5]!==o?.id||e[6]!==c||e[7]!==d?.title){S=Symbol.for("react.early_return_sentinel");e:{const y=Qh(l),w=[...l].reverse().find(Yu),k=w?.metadata?.usage,j=w?.metadata?.modelLimits?.contextWindow??c?.limits?.contextWindow??null,T=k?.contextTokens??0,P=j&&j>0?(T/j*100).toFixed(1):null,R=l;let C;e[16]!==R?(C=R.filter(Gu).reduce(qu,0),e[16]=R,e[17]=C):C=e[17];const N=C,B=l;let I;e[18]!==B?(I=B.filter(Vu).reduce(Ku,0),e[18]=B,e[19]=I):I=e[19];const E=I,M=Math.max(0,y.totalTokens-N-E),A=l[0],L=l.at(-1),H=A?.metadata?.created_at??h?.created_at,$=L?.metadata?.created_at??h?.updated_at,z=l.filter(Uu),V=l.flatMap(Hu),q=c?.modelId?Pu(c.modelId):"—",ee=d?.title??"Decopilot",G=[{label:"Session",value:h?.title??"New chat"},{label:"Messages",value:z.length},{label:"Agent",value:ee},{label:"Model",value:q},{label:"Context Limit",value:j?Bs(j):"—"},{label:"Session Tokens (billed)",value:y.totalTokens>0?Bs(y.totalTokens):"0"},{label:"Usage",value:P!==null?`${P}%`:"—"},{label:"Input Tokens",value:y.inputTokens>0?Bs(y.inputTokens):"0"},{label:"Output Tokens",value:y.outputTokens>0?Bs(y.outputTokens):"0"},{label:"Reasoning Tokens",value:y.reasoningTokens>0?Bs(y.reasoningTokens):"0"},{label:"Cost",value:y.cost>0?`$${y.cost<.001?y.cost.toFixed(6):y.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:Ko(H)},{label:"Last Activity",value:Ko($)}];if(!h&&z.length===0){let J;e[20]!==r?(J=te("flex flex-col h-full w-full border-l border-border bg-background",r),e[20]=r,e[21]=J):J=e[21];let ie;e[22]===Symbol.for("react.memo_cache_sentinel")?(ie=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[22]=ie):ie=e[22];let oe;e[23]!==i?(oe=i?n.jsx(Oo,{size:14,className:"text-muted-foreground"}):n.jsx(ks,{size:14,className:"text-muted-foreground"}),e[23]=i,e[24]=oe):oe=e[24];let W;e[25]!==s||e[26]!==oe?(W=n.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[ie,n.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:oe})]}),e[25]=s,e[26]=oe,e[27]=W):W=e[27];let ne;e[28]===Symbol.for("react.memo_cache_sentinel")?(ne=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]=ne):ne=e[28];let me;e[29]!==J||e[30]!==W?(me=n.jsxs("div",{className:J,children:[W,ne]}),e[29]=J,e[30]=W,e[31]=me):me=e[31],S=me;break e}e[32]!==r?(g=te("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",r),e[32]=r,e[33]=g):g=e[33];let Y;e[34]===Symbol.for("react.memo_cache_sentinel")?(Y=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[34]=Y):Y=e[34];let O;e[35]!==i?(O=i?n.jsx(Oo,{size:14}):n.jsx(ks,{size:14}),e[35]=i,e[36]=O):O=e[36],e[37]!==s||e[38]!==O?(x=n.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[Y,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:O})]}),e[37]=s,e[38]=O,e[39]=x):x=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(Fu)})]}),m=n.jsx(Du,{items:G});let X;e[40]===Symbol.for("react.memo_cache_sentinel")?(X=n.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[40]=X):X=e[40],e[41]!==E||e[42]!==M||e[43]!==N?(p=n.jsxs("div",{className:"flex flex-col gap-3",children:[X,n.jsx(Iu,{userTokens:N,assistantTokens:E,otherTokens:M})]}),e[41]=E,e[42]=M,e[43]=N,e[44]=p):p=e[44],_=z.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:z.map(J=>{const ie=J.metadata?.created_at,oe=o?.id===J.id;return n.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[n.jsxs("button",{type:"button",onClick:()=>a(oe?null:J),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:te("shrink-0 font-medium",J.role==="user"?"text-chart-1":"text-chart-2"),children:J.role}),n.jsx("span",{className:"text-muted-foreground",children:"•"}),n.jsx("span",{className:"truncate text-muted-foreground font-mono",children:J.id})]}),ie&&n.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(ie).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),oe&&n.jsxs(n.Fragment,{children:[J.role==="assistant"&&(()=>{const W=J.metadata?._request;if(!W)return null;const ne=W.systemSections??[],me=Math.max(1,...ne.map(zu)),_e=ne.reduce($u,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:[W.activeTools??0," / ",W.tools??0," ","tools active"]})]}),ne.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(_e/4).toLocaleString()," ","tok"]})]}),ne.map((pe,xe)=>{const le=pe.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${xe}`,re=pe.chars/me*100,ce=Math.round(pe.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:le}),n.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",ce.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:`${re}%`}})})]},xe)})]})]})})(),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(J,null,2)})]})]},J.id)})})]})}e[0]=h,e[1]=i,e[2]=r,e[3]=l,e[4]=s,e[5]=o?.id,e[6]=c,e[7]=d?.title,e[8]=u,e[9]=f,e[10]=m,e[11]=p,e[12]=_,e[13]=g,e[14]=x,e[15]=S}else u=e[8],f=e[9],m=e[10],p=e[11],_=e[12],g=e[13],x=e[14],S=e[15];if(S!==Symbol.for("react.early_return_sentinel"))return S;let v;e[45]!==u||e[46]!==f||e[47]!==m||e[48]!==p||e[49]!==_?(v=n.jsxs("div",{className:u,children:[f,m,p,_]}),e[45]=u,e[46]=f,e[47]=m,e[48]=p,e[49]=_,e[50]=v):v=e[50];let b;return e[51]!==g||e[52]!==x||e[53]!==v?(b=n.jsxs("div",{className:g,children:[x,v]}),e[51]=g,e[52]=x,e[53]=v,e[54]=b):b=e[54],b}function $u(t,e){return t+e.chars}function zu(t){return t.chars}function Fu(t,e){return n.jsx(Lu,{part:t},e)}function Hu(t){return(t.parts??[]).filter(Wu)}function Wu(t){return t.type==="tool-subtask"}function Uu(t){return t.role!=="system"}function Ku(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function Vu(t){return t.role==="assistant"}function qu(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function Gu(t){return t.role==="user"}function Yu(t){return t.role==="assistant"&&t.metadata?.usage}function Xu(){const t=F.c(17),{selectedVirtualMcp:e}=or(),{org:s}=ke();let i;t[0]!==s.id?(i=Xn(s.id),t[0]=s.id,t[1]=i):i=t[1];const o=e??i;let a;t[2]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(Vh,{size:32}),t[2]=a):a=t[2];let l;t[3]!==o.icon||t[4]!==o.title?(l=n.jsx(cs,{icon:o.icon,name:o.title,size:"lg",fallbackIcon:a,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),t[3]=o.icon,t[4]=o.title,t[5]=l):l=t[5];let h;t[6]!==o.title?(h=n.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:o.title}),t[6]=o.title,t[7]=h):h=t[7];const c=o.description??"Ask anything about configuring model providers or using MCP Mesh.";let d;t[8]!==c?(d=n.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:c}),t[8]=c,t[9]=d):d=t[9];let u;t[10]!==l||t[11]!==h||t[12]!==d?(u=n.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[l,h,d]}),t[10]=l,t[11]=h,t[12]=d,t[13]=u):u=t[13];let f;t[14]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx("div",{className:"w-full max-w-3xl mx-auto",children:n.jsx(Le.IceBreakers,{})}),t[14]=f):f=t[14];let m;return t[15]!==u?(m=n.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-6 px-4",children:[u,f]}),t[15]=u,t[16]=m):m=t[16],m}function Ju(){const t=F.c(29),{org:e}=ke(),s=hd(),{isChatEmpty:i}=hs(),[r,o]=D.useState("chat"),a=Bh(),{selectedVirtualMcp:l}=or();let h;t[0]!==e.id?(h=Xn(e.id),t[0]=e.id,t[1]=h):h=t[1];const u=Mt((l??h).id),f=dd(),m=ar(u?.metadata);if(s.length===0&&!(m&&qh(f))){let C;return t[2]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(Le,{className:"animate-in fade-in-0 duration-200",children:n.jsx(Le.Main,{className:"flex flex-col items-center",children:n.jsx(Le.EmptyState,{children:n.jsx(Le.NoAiProviderEmptyState,{})})})}),t[2]=C):C=t[2],C}let _;t[3]!==a.hasDecoKey||t[4]!==a.hasOnlyDecoProvider||t[5]!==a.isLoading||t[6]!==a.isZeroBalance||t[7]!==i||t[8]!==e.id?(_=a.hasDecoKey&&a.isZeroBalance&&a.hasOnlyDecoProvider&&!a.isLoading&&i&&!Lh(e.id),t[3]=a.hasDecoKey,t[4]=a.hasOnlyDecoProvider,t[5]=a.isLoading,t[6]=a.isZeroBalance,t[7]=i,t[8]=e.id,t[9]=_):_=t[9];const g=_;let x;t[10]!==g?(x=g&&n.jsx(Le.CreditsEmptyState,{}),t[10]=g,t[11]=x):x=t[11];const S=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let v;t[12]!==S?(v=te("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",S),t[12]=S,t[13]=v):v=t[13];let b;t[14]!==i?(b=n.jsx(Le.Main,{children:i?n.jsx(Xu,{}):n.jsx(Le.Messages,{})}),t[14]=i,t[15]=b):b=t[15];let y;t[16]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(Le.Footer,{children:n.jsx(Le.Input,{onOpenContextPanel:()=>o("context")})}),t[16]=y):y=t[16];let w;t[17]!==v||t[18]!==b?(w=n.jsxs("div",{className:v,children:[b,y]}),t[17]=v,t[18]=b,t[19]=w):w=t[19];const k=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let j;t[20]!==k?(j=te("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",k),t[20]=k,t[21]=j):j=t[21];let T;t[22]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx(Ou,{back:!0,onClose:()=>o("chat")}),t[22]=T):T=t[22];let P;t[23]!==j?(P=n.jsx("div",{className:j,children:T}),t[23]=j,t[24]=P):P=t[24];let R;return t[25]!==P||t[26]!==x||t[27]!==w?(R=n.jsxs(Le,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[x,w,P]}),t[25]=P,t[26]=x,t[27]=w,t[28]=R):R=t[28],R}function Ol(){const t=F.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Le.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(It,{fallback:e,children:n.jsx(D.Suspense,{fallback:n.jsx(Le.Skeleton,{}),children:n.jsx(Ju,{})})}),t[1]=s):s=t[1],s}function Zu(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 Vo(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 Qu(t,e){return t===1?!0:t===0?!1:e}function ef(t,e){const s=Kt(),i=Kn({strict:!1}),r=cl({strict:!1}),{create:o}=Md(),{locator:a}=ke(),{virtualMcpId:l,orgSlug:h,isAgentRoute:c}=e,d=Zu({entityMetadata:t,mainParamPresent:i.main!==void 0,mainParamValue:i.main}),u=Qu(i.chat,d.chatOpen),f=d.mainOpen,m=D.useRef(crypto.randomUUID()),p=r.taskId??m.current,_="/$org/$taskId",g=T=>({org:h,taskId:T}),x=c?{virtualmcpid:l}:{},S=(T,P)=>{s({to:_,params:g(p),search:R=>({...R,...T}),replace:P?.replace??!1})},v=(T,P)=>{s({to:_,params:g(T),search:R=>{const C={};return P?C.virtualmcpid=P:c&&(C.virtualmcpid=l),C}})},b=()=>{f?S({main:"0"},{replace:!0}):S({main:ed(t)},{replace:!0})},y=()=>{S({chat:u?0:1},{replace:!0})},w=()=>{u||S({chat:1},{replace:!0})},k=async()=>{const T=crypto.randomUUID(),P=ud(h,a,p);try{await o({id:T,virtual_mcp_id:l,...P?{branch:P}:{}})}catch{}s({to:_,params:g(T),search:R=>({...x,chat:1})})},j=T=>{S({main:T},{replace:!0})};return{taskId:p,mainOpen:f,chatOpen:u,mainParam:i.main,setTaskId:v,toggleMain:b,toggleChat:y,openChat:w,createNewTask:k,openTab:j}}const tf={settings:Sd,automations:bd,preview:Zn,git:to};function qo(t){const e=lr(t);if(e.type==="icon"){const s=cr(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function Tr(t){if(t.kind==="system")return{kind:"component",Component:tf[t.tabId]};const e=qo(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=qo(s.icon);return i||{kind:"fallback"}}function sf(t){const{org:e}=ke(),s=Je({connectionId:Ns,orgId:e.id,orgSlug:e.slug}),i=jl(),r=D.useSyncExternalStore(i.threads.subscribe,i.threads.get),o=t?r.find(l=>l.id===t)??null:null,{data:a}=Eh({queryKey:rs.ensureTask(e.id,t),queryFn:async()=>{if(!t||!s)return null;try{const l=await s.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}});return(l.structuredContent??l).item??null}catch{return null}},select:l=>l?.metadata??null,staleTime:3e4});return o?.metadata??a??null}function $l(t){const e=F.c(8),s=Kt();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const r=Kn(i),o=Mt(t.virtualMcpId),a=sf(t.taskId),{currentBranch:l}=ds(),h=o?.metadata?.ui??null,c=h?.layout??null,d=c?.tabs??[],u=h?.pinnedViews??[],f=a?.expanded_tools??[],m=_l(o),p=ar(o?.metadata);let _;e[1]===Symbol.for("react.memo_cache_sentinel")?(_={includeVirtual:!0},e[1]=_):_=e[1];const g=hr(_),{activeTab:x,mainOpen:S}=td({mainParam:r.main,metadata:c?{defaultMainView:c.defaultMainView??null,tabs:d.map(rf)}:null}),v=gl(x),b=[];p&&b.push({id:"preview",title:"Preview"}),m&&b.push({id:"git",title:l??"git"}),b.push({id:"settings",title:"Settings"}),b.push({id:"automations",title:"Automations"});const y=new Map;for(const P of f){const R=$o(P.appId,P.toolName);y.set(R,{id:R,title:P.toolName,appId:P.appId,iconKey:P.toolName})}for(const P of u){const R=$o(P.connectionId,P.toolName);y.set(R,{id:R,title:P.label||P.toolName,appId:P.connectionId,iconKey:P.toolName,iconUrl:P.icon??null})}let w;e[2]!==g?(w=P=>({id:P.id,title:P.title,kind:"agent",icon:Tr({tabId:P.id,kind:"agent",appId:P.view.appId,connections:g})}),e[2]=g,e[3]=w):w=e[3];const k=[...d.map(w),...Array.from(y.values()).map(P=>({id:P.id,title:P.title,kind:"expanded",icon:Tr({tabId:P.iconKey,kind:"expanded",appId:P.appId,iconUrl:P.iconUrl,connections:g})})),...b.map(P=>({id:P.id,title:P.title,kind:"system",icon:Tr({tabId:P.id,kind:"system",connections:g})}))];let j;return e[4]!==x||e[5]!==S||e[6]!==s?(j=P=>{const R=sd({clickedId:P,activeTab:x,mainOpen:S});s({to:".",search:C=>({...C,main:R}),replace:!0})},e[4]=x,e[5]=S,e[6]=s,e[7]=j):j=e[7],{activeTab:x,mainOpen:S,setActiveTab:j,systemTabs:b,layoutTabs:d,expandedTools:f,automationTabParsed:v,tabs:k}}function rf(t){return{id:t.id}}function zl(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.
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sections-editor-CT7Vp1k1.js","assets/index-DmZfQaD-.js","assets/index-DzRaXx8g.css","assets/ChevronRight-Bd356dAz.js","assets/monaco-editor-BDwYwChW.js","assets/select-COYVRAvf.js","assets/tooltip-PHPuJMK6.js","assets/Check-DGona5mE.js","assets/ChevronDown-BVIdiaZm.js","assets/ChevronUp-BjZdqIHm.js","assets/spinner-aWkRS-qf.js","assets/RefreshCcw01-Dk0BVwdj.js","assets/agent-icon-C_-SJvZj.js","assets/AlertCircle-CwzMuMpf.js","assets/Tool01-Cgvg-fFF.js","assets/Stars02-BNllf8d9.js","assets/SwitchHorizontal01-C5pWsPo5.js","assets/ArrowNarrowLeft-anbyHmy5.js","assets/XCircle-46an_vpE.js","assets/ArrowUpRight-Cb1zJjWa.js","assets/ZapSquare-BYFC2xpk.js","assets/Users03-DJL_L7hj.js","assets/CheckCircle-DxcUmiZK.js","assets/DotsVertical-CZUbDG6o.js","assets/Container-kvfa4KPY.js","assets/FilterLines-D9AUiBON.js","assets/Star01-DjF7bglG.js","assets/Palette-Dm4bElxY.js","assets/HardDrive-alRWMahn.js","assets/Key01-BkAMUOVt.js","assets/LayoutLeft-BSIyuROS.js","assets/LinkExternal01-BazomJ3X.js","assets/Lock01-D1c1Oism.js","assets/Monitor01-Dkri72GI.js","assets/Sun-BrzkGIAp.js","assets/Play-BhMjD9gq.js","assets/Plus-c0eRr9wH.js","assets/SearchMd-J5wL3p8r.js","assets/Settings02-VcBAg_yI.js","assets/Shield01-WjtNpAUl.js","assets/Trash01-CtaV1KCh.js","assets/Upload01-BvZfJrrC.js","assets/User01-D0Cbg2TN.js","assets/Users01-CWCsgm-8.js","assets/XClose-BBhl7TDc.js","assets/X-HlbQgOk5.js","assets/Zap-CPG79cp8.js","assets/dropdown-menu-C-3EGUEu.js","assets/sortable.esm--NDulp9A.js","assets/input-LBycuk-Q.js","assets/textarea-CdaHW1-E.js","assets/label-xxaAQ94S.js","assets/switch-Cmz_NhXm.js","assets/dialog-CFmU9mg5.js","assets/skeleton-De826Bp4.js","assets/tabs-CozIPTAA.js","assets/use-file-configs-C25S803h.js","assets/constants-BNWk3vY4.js","assets/unwrap-tool-result-BYXdCQMg.js","assets/useInfiniteQuery-d4Y-q2-f.js","assets/infiniteQueryObserver-ByGhYUFT.js","assets/command-PltV2vRF.js","assets/index-CAuk1Kfg.js","assets/index-BF8TFmOX.js","assets/chat-context-6MP1sdo4.js","assets/hooks-C8YLRuOb.js","assets/decopilot-sse-pool-CYUb1xc3.js","assets/create-sse-subscription-CjI9SUTI.js","assets/use-virtual-mcp-aFEyYbrv.js","assets/use-collections-MMy3tGV8.js","assets/use-ai-providers-9O0qMpCv.js","assets/use-organization-settings-CTSrXAT6.js","assets/pair-DOTz8CiV.js","assets/index-DMk4r8Ch.js","assets/use-copy-BCZtNoNP.js","assets/format-time-GeUngI9C.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/content-blocks-o63cs2vh.js","assets/types-BcJnlpKC.js","assets/shell-layout-BQiN2_dH.js","assets/avatar-Dmp_G5Ry.js","assets/required-auth-layout-3nZToecj.js","assets/useRouterState-CsqSaCr4.js","assets/use-org-sso-BU7YElAe.js","assets/integration-icon-DtCf-GLI.js","assets/use-mcp-prompts-Cxu5Gqkp.js","assets/form-BLSBgSlG.js","assets/drawer-f2-LbcZU.js","assets/collection-search-2ffGJwV3.js","assets/toggle-group-uYe932ea.js","assets/agent-icons-CDsUfnuX.js","assets/checkbox-CxMozNlp.js","assets/ai-providers-logos-DD3qZ33J.js","assets/settings-section-CvUdnvHo.js","assets/card-_x010Gt4.js","assets/connect-desktop-dialog-Bn3-kqkd.js","assets/popover-BZvYlx-e.js","assets/index-Dflh5WdW.js","assets/question-004-sINsf4GQ.js","assets/add-connection-dialog-r0iOKxIk.js","assets/connection-slug-eyAPH6o3.js","assets/connection-card-BzBZi7XR.js","assets/use-registry-connections-BtJD3GbW.js","assets/use-connection-CXkgxjx7.js","assets/extract-connection-data-BHnuRVIs.js","assets/generate-id-uphy-ahq.js","assets/collections-CMWUgWO4.js","assets/collection-tabs-zYvEPyVu.js","assets/badge-Dhqk1439.js","assets/connection-form-helpers-pLnjCctP.js","assets/use-infinite-scroll-xBBc18Pi.js","assets/useSuspenseInfiniteQuery-Ccz7tT5r.js","assets/index-DIrSWTTQ.js","assets/sidebar-DDhNiQmf.js","assets/toolbar-DTECgCHe.js","assets/collection-search-P-Jsgn90.js","assets/use-navigate-to-agent-S-7lONzg.js","assets/use-create-virtual-mcp-D3-vWJlc.js","assets/github-repo-picker-DovapSuy.js","assets/use-mcp-tools-C5gUP503.js","assets/import-from-deco-dialog-IL7Fm2Iy.js","assets/alert-dialog-CZ4KuCkJ.js","assets/index-3iXRS0r4.js","assets/hover-card-vzSZUxhq.js","assets/task-status-Bm6cE2vl.js","assets/use-status-sounds-BtwQHpIn.js","assets/empty-state-YZLDNNT9.js","assets/accordion-BhYZkZFT.js","assets/user-LB-FZ4W_.js","assets/tools-list--glS5MjS.js","assets/use-debounced-autosave-Czr8puWw.js","assets/index-S-Vi2aBj.js","assets/use-secrets--HY-PJBE.js","assets/view-mode-toggle-BUR8EnzD.js","assets/automation-list-row-CMOLOW55.js","assets/search-input-hHZ7bOI8.js","assets/file-explorer-Bzt-HVWR.js","assets/project-app-view-Bk-35e4q.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{e as F,r as D,c as te,j as n,l as Se,E as It,q as ke,f as Kt,d as Kn,g as cl,s as Eh,K as rs,o as ae,B as Q,v as Xs,V as Th,t as Ee,b as ir,w as hl,x as Rh,y as rr,z as ns,C as at,D as Vn,F as dl,G as Ph,H as Dh,I as Bo,n as nr,L as Ah,a as qn,J as Oi,M as Us,P as mt,_ as Gn,Q as Yn,R as Ih,T as Mh,p as ul,U as fl}from"./index-DmZfQaD-.js";import{C as Le,u as Bh,w as Lh,a as ml,b as Oh,s as jr,T as $h,t as zh,r as Fh,c as Hh,d as Wh,g as Uh}from"./index-BF8TFmOX.js";import{I as cs}from"./integration-icon-DtCf-GLI.js";import{g as Xn,u as Je,S as Ns,a as pl}from"./constants-BNWk3vY4.js";import{u as Mt,a as Kh}from"./use-virtual-mcp-aFEyYbrv.js";import{a as Vh}from"./Users03-DJL_L7hj.js";import{u as hs,a as ds,b as or,c as ar,h as qh,d as _l,g as oi,t as Gh,e as Lo,f as Yh}from"./chat-context-6MP1sdo4.js";import{i as Jn}from"./AlertCircle-CwzMuMpf.js";import{i as Xh}from"./CheckCircle-DxcUmiZK.js";import{n as Oo}from"./ZapSquare-BYFC2xpk.js";import{i as Jh,a as Zn,b as Zh}from"./XCircle-46an_vpE.js";import{s as ks}from"./XClose-BBhl7TDc.js";import{c as Qh,r as ed,a as td,p as gl,f as $o,b as sd,F as id,t as Nr,M as Qn,G as rd,i as nd,d as od,e as ad,g as ld,h as cd}from"./pair-DOTz8CiV.js";import{u as hd}from"./use-ai-providers-9O0qMpCv.js";import{u as dd}from"./connect-desktop-dialog-Bn3-kqkd.js";import{r as ud,u as eo,i as fd}from"./shell-layout-BQiN2_dH.js";import{b as md,a as pd}from"./index-DIrSWTTQ.js";import{u as _d,c as gd,d as vd,e as xd}from"./sidebar-DDhNiQmf.js";import{u as vl,T as Te,a as Re,b as Pe,c as xl}from"./tooltip-PHPuJMK6.js";import{i as to,a as bd,b as Sd,p as lr,g as cr,c as so,d as bl,h as Vr,e as Er,f as zo,A as Fo,j as io,k as yd,l as wd,n as Cd,m as kd,o as jd,t as Nd,q as Ed,s as Td,r as Sl,u as qr,v as yl,w as wl,x as Ho,y as Rd,z as Pd,B as ro,C as Wo,D as Js,E as Cl,F as kl,G as Dd,H as Ad}from"./agent-icon-C_-SJvZj.js";import{u as Id}from"./use-status-sounds-BtwQHpIn.js";import{E as qi}from"./empty-state-YZLDNNT9.js";import{u as Md,a as jl}from"./hooks-C8YLRuOb.js";import{T as Uo,a as Gr}from"./toolbar-DTECgCHe.js";import{A as Bd,a as Ld,b as Od,c as $d,R as Nl,d as zd,e as Fd}from"./accordion-BhYZkZFT.js";import{u as hr,a as no,b as Hd}from"./use-connection-CXkgxjx7.js";import{g as Wd}from"./generate-id-uphy-ahq.js";import{u as Ud,g as Kd}from"./types-BcJnlpKC.js";import{U as El}from"./user-LB-FZ4W_.js";import{T as Vd,u as Tl}from"./tools-list--glS5MjS.js";import{u as qd}from"./unwrap-tool-result-BYXdCQMg.js";import{s as Rl,g as Gd}from"./connection-slug-eyAPH6o3.js";import{A as Yr,a as Xr,b as Jr,c as Zr,d as Qr,e as en,f as tn,g as sn}from"./alert-dialog-CZ4KuCkJ.js";import{D as dr,a as us,b as fs,c as ai,d as li,e as Pl}from"./dialog-CFmU9mg5.js";import{C as Dl,a as rn}from"./card-_x010Gt4.js";import{I as it}from"./input-LBycuk-Q.js";import{L as lt}from"./label-xxaAQ94S.js";import{S as yt,a as wt,b as Ct,c as kt,d as Qe}from"./select-COYVRAvf.js";import{S as nn}from"./switch-Cmz_NhXm.js";import{T as Gi}from"./textarea-CdaHW1-E.js";import{i as os}from"./Play-BhMjD9gq.js";import{s as Ut}from"./Plus-c0eRr9wH.js";import{a as Yd}from"./Settings02-VcBAg_yI.js";import{t as oo,i as Xd}from"./Tool01-Cgvg-fFF.js";import{s as Yi}from"./Trash01-CtaV1KCh.js";import{u as Xi}from"./use-debounced-autosave-Czr8puWw.js";import{P as ci,a as hi,b as di}from"./popover-BZvYlx-e.js";import{S as Al,M as Jd,l as Zd,w as Qd}from"./monaco-editor-BDwYwChW.js";import{i as Il}from"./SearchMd-J5wL3p8r.js";import{i as eu}from"./Upload01-BvZfJrrC.js";import{i as tu}from"./LayoutLeft-BSIyuROS.js";import{P as pt}from"./index-S-Vi2aBj.js";import{A as su}from"./add-connection-dialog-r0iOKxIk.js";import{C as iu}from"./collection-tabs-zYvEPyVu.js";import{C as Ml}from"./checkbox-CxMozNlp.js";import{u as ru,a as ui}from"./use-mcp-tools-C5gUP503.js";import{u as nu}from"./use-mcp-prompts-Cxu5Gqkp.js";import{D as ou,a as au,b as lu}from"./drawer-f2-LbcZU.js";import{i as fi}from"./Check-DGona5mE.js";import{a as es,i as cu,s as hu}from"./RefreshCcw01-Dk0BVwdj.js";import{i as Bl}from"./Key01-BkAMUOVt.js";import{S as ys}from"./skeleton-De826Bp4.js";import{i as du}from"./Lock01-D1c1Oism.js";import{s as uu}from"./User01-D0Cbg2TN.js";import{t as fu}from"./Users01-CWCsgm-8.js";import{u as mu,a as pu}from"./use-secrets--HY-PJBE.js";import{G as _u}from"./github-repo-picker-DovapSuy.js";import{n as ms}from"./LinkExternal01-BazomJ3X.js";import{T as ts,a as ao,b as lo,c as Zs}from"./tabs-CozIPTAA.js";import{S as Ll}from"./spinner-aWkRS-qf.js";import{D as mi,a as pi,b as _i,c as Dt,d as gu,e as vu,f as xu}from"./dropdown-menu-C-3EGUEu.js";import{t as co}from"./ChevronDown-BVIdiaZm.js";import{i as bu}from"./ChevronRight-Bd356dAz.js";import{s as Su}from"./Star01-DjF7bglG.js";import{V as yu}from"./view-mode-toggle-BUR8EnzD.js";import{i as wu}from"./X-HlbQgOk5.js";import{u as gi,a as Cu,b as ku,c as ju,A as Nu,d as Eu}from"./automation-list-row-CMOLOW55.js";import{i as Tu}from"./SwitchHorizontal01-C5pWsPo5.js";import{i as ti}from"./Zap-CPG79cp8.js";import{S as Ru}from"./search-input-hHZ7bOI8.js";function Bs(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function Ko(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 Pu(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function Du(t){const e=F.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Au),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 Au(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 Iu(t){const e=F.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,h=o>0?r/o*100:0;let c;e[0]!==a?(c=a>0&&n.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=c):c=e[1];let d;e[2]!==l?(d=l>0&&n.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=d):d=e[3];let u;e[4]!==h?(u=h>0&&n.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${h}%`}}),e[4]=h,e[5]=u):u=e[5];let f;e[6]!==c||e[7]!==d||e[8]!==u?(f=n.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[c,d,u]}),e[6]=c,e[7]=d,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 _;e[13]!==p?(_=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]=_):_=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=g):g=e[15];let x;e[16]!==l?(x=l.toFixed(1),e[16]=l,e[17]=x):x=e[17];let S;e[18]!==x?(S=n.jsxs("div",{className:"flex items-center gap-1.5",children:[g,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",x,"%"]})]}),e[18]=x,e[19]=S):S=e[19];let v;e[20]!==h||e[21]!==r?(v=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 ",h.toFixed(1),"%"]})]}),e[20]=h,e[21]=r,e[22]=v):v=e[22];let b;e[23]!==S||e[24]!==v||e[25]!==_?(b=n.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[_,S,v]}),e[23]=S,e[24]=v,e[25]=_,e[26]=b):b=e[26];let y;return e[27]!==b||e[28]!==f?(y=n.jsxs("div",{className:"flex flex-col gap-2",children:[f,b]}),e[27]=b,e[28]=f,e[29]=y):y=e[29],y}function Mu(t){const e=F.c(11),{agentId:s,isError:i}=t,r=Mt(s),o=r?.title??"Subtask",a=r?.icon??null;let l;e[0]!==a||e[1]!==o?(l=n.jsx(cs,{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 h=i?"text-destructive":"text-foreground";let c;e[3]!==h?(c=te("shrink-0 font-medium",h),e[3]=h,e[4]=c):c=e[4];let d;e[5]!==o||e[6]!==c?(d=n.jsx("span",{className:c,children:o}),e[5]=o,e[6]=c,e[7]=d):d=e[7];let u;return e[8]!==l||e[9]!==d?(u=n.jsxs(n.Fragment,{children:[l,d]}),e[8]=l,e[9]=d,e[10]=u):u=e[10],u}function Bu(t){const e=F.c(5),{isError:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(cs,{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=te("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 Lu(t){const e=F.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(Bu,{isError:o}),e[0]=o,e[1]=l):l=e[1];let h;e[2]!==i||e[3]!==o?(h=n.jsx(Mu,{agentId:i,isError:o}),e[2]=i,e[3]=o,e[4]=h):h=e[4];let c;e[5]!==l||e[6]!==h?(c=n.jsx(D.Suspense,{fallback:l,children:h}),e[5]=l,e[6]=h,e[7]=c):c=e[7];let d;e[8]!==s.input?(d=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]=d):d=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(Se,{size:12,className:"animate-spin text-muted-foreground"}):o?n.jsx(Jh,{size:12,className:"text-destructive"}):a?n.jsx(Jn,{size:12,className:"text-warning"}):n.jsx(Xh,{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]!==c||e[15]!==d||e[16]!==u?(f=n.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[c,d,u]}),e[14]=c,e[15]=d,e[16]=u,e[17]=f):f=e[17],f}function Ou(t){const e=F.c(55),{onClose:s,back:i,className:r}=t,[o,a]=D.useState(null),{messages:l}=hs(),{activeTask:h}=ds(),{selectedModel:c,selectedVirtualMcp:d}=or();let u,f,m,p,_,g,x,S;if(e[0]!==h||e[1]!==i||e[2]!==r||e[3]!==l||e[4]!==s||e[5]!==o?.id||e[6]!==c||e[7]!==d?.title){S=Symbol.for("react.early_return_sentinel");e:{const y=Qh(l),w=[...l].reverse().find(Yu),k=w?.metadata?.usage,j=w?.metadata?.modelLimits?.contextWindow??c?.limits?.contextWindow??null,T=k?.contextTokens??0,P=j&&j>0?(T/j*100).toFixed(1):null,R=l;let C;e[16]!==R?(C=R.filter(Gu).reduce(qu,0),e[16]=R,e[17]=C):C=e[17];const N=C,B=l;let I;e[18]!==B?(I=B.filter(Vu).reduce(Ku,0),e[18]=B,e[19]=I):I=e[19];const E=I,M=Math.max(0,y.totalTokens-N-E),A=l[0],L=l.at(-1),H=A?.metadata?.created_at??h?.created_at,$=L?.metadata?.created_at??h?.updated_at,z=l.filter(Uu),V=l.flatMap(Hu),q=c?.modelId?Pu(c.modelId):"—",ee=d?.title??"Decopilot",G=[{label:"Session",value:h?.title??"New chat"},{label:"Messages",value:z.length},{label:"Agent",value:ee},{label:"Model",value:q},{label:"Context Limit",value:j?Bs(j):"—"},{label:"Session Tokens (billed)",value:y.totalTokens>0?Bs(y.totalTokens):"0"},{label:"Usage",value:P!==null?`${P}%`:"—"},{label:"Input Tokens",value:y.inputTokens>0?Bs(y.inputTokens):"0"},{label:"Output Tokens",value:y.outputTokens>0?Bs(y.outputTokens):"0"},{label:"Reasoning Tokens",value:y.reasoningTokens>0?Bs(y.reasoningTokens):"0"},{label:"Cost",value:y.cost>0?`$${y.cost<.001?y.cost.toFixed(6):y.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:Ko(H)},{label:"Last Activity",value:Ko($)}];if(!h&&z.length===0){let J;e[20]!==r?(J=te("flex flex-col h-full w-full border-l border-border bg-background",r),e[20]=r,e[21]=J):J=e[21];let ie;e[22]===Symbol.for("react.memo_cache_sentinel")?(ie=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[22]=ie):ie=e[22];let oe;e[23]!==i?(oe=i?n.jsx(Oo,{size:14,className:"text-muted-foreground"}):n.jsx(ks,{size:14,className:"text-muted-foreground"}),e[23]=i,e[24]=oe):oe=e[24];let W;e[25]!==s||e[26]!==oe?(W=n.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[ie,n.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:oe})]}),e[25]=s,e[26]=oe,e[27]=W):W=e[27];let ne;e[28]===Symbol.for("react.memo_cache_sentinel")?(ne=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]=ne):ne=e[28];let me;e[29]!==J||e[30]!==W?(me=n.jsxs("div",{className:J,children:[W,ne]}),e[29]=J,e[30]=W,e[31]=me):me=e[31],S=me;break e}e[32]!==r?(g=te("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",r),e[32]=r,e[33]=g):g=e[33];let Y;e[34]===Symbol.for("react.memo_cache_sentinel")?(Y=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[34]=Y):Y=e[34];let O;e[35]!==i?(O=i?n.jsx(Oo,{size:14}):n.jsx(ks,{size:14}),e[35]=i,e[36]=O):O=e[36],e[37]!==s||e[38]!==O?(x=n.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[Y,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:O})]}),e[37]=s,e[38]=O,e[39]=x):x=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(Fu)})]}),m=n.jsx(Du,{items:G});let X;e[40]===Symbol.for("react.memo_cache_sentinel")?(X=n.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[40]=X):X=e[40],e[41]!==E||e[42]!==M||e[43]!==N?(p=n.jsxs("div",{className:"flex flex-col gap-3",children:[X,n.jsx(Iu,{userTokens:N,assistantTokens:E,otherTokens:M})]}),e[41]=E,e[42]=M,e[43]=N,e[44]=p):p=e[44],_=z.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:z.map(J=>{const ie=J.metadata?.created_at,oe=o?.id===J.id;return n.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[n.jsxs("button",{type:"button",onClick:()=>a(oe?null:J),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:te("shrink-0 font-medium",J.role==="user"?"text-chart-1":"text-chart-2"),children:J.role}),n.jsx("span",{className:"text-muted-foreground",children:"•"}),n.jsx("span",{className:"truncate text-muted-foreground font-mono",children:J.id})]}),ie&&n.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(ie).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),oe&&n.jsxs(n.Fragment,{children:[J.role==="assistant"&&(()=>{const W=J.metadata?._request;if(!W)return null;const ne=W.systemSections??[],me=Math.max(1,...ne.map(zu)),_e=ne.reduce($u,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:[W.activeTools??0," / ",W.tools??0," ","tools active"]})]}),ne.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(_e/4).toLocaleString()," ","tok"]})]}),ne.map((pe,xe)=>{const le=pe.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${xe}`,re=pe.chars/me*100,ce=Math.round(pe.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:le}),n.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",ce.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:`${re}%`}})})]},xe)})]})]})})(),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(J,null,2)})]})]},J.id)})})]})}e[0]=h,e[1]=i,e[2]=r,e[3]=l,e[4]=s,e[5]=o?.id,e[6]=c,e[7]=d?.title,e[8]=u,e[9]=f,e[10]=m,e[11]=p,e[12]=_,e[13]=g,e[14]=x,e[15]=S}else u=e[8],f=e[9],m=e[10],p=e[11],_=e[12],g=e[13],x=e[14],S=e[15];if(S!==Symbol.for("react.early_return_sentinel"))return S;let v;e[45]!==u||e[46]!==f||e[47]!==m||e[48]!==p||e[49]!==_?(v=n.jsxs("div",{className:u,children:[f,m,p,_]}),e[45]=u,e[46]=f,e[47]=m,e[48]=p,e[49]=_,e[50]=v):v=e[50];let b;return e[51]!==g||e[52]!==x||e[53]!==v?(b=n.jsxs("div",{className:g,children:[x,v]}),e[51]=g,e[52]=x,e[53]=v,e[54]=b):b=e[54],b}function $u(t,e){return t+e.chars}function zu(t){return t.chars}function Fu(t,e){return n.jsx(Lu,{part:t},e)}function Hu(t){return(t.parts??[]).filter(Wu)}function Wu(t){return t.type==="tool-subtask"}function Uu(t){return t.role!=="system"}function Ku(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function Vu(t){return t.role==="assistant"}function qu(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function Gu(t){return t.role==="user"}function Yu(t){return t.role==="assistant"&&t.metadata?.usage}function Xu(){const t=F.c(17),{selectedVirtualMcp:e}=or(),{org:s}=ke();let i;t[0]!==s.id?(i=Xn(s.id),t[0]=s.id,t[1]=i):i=t[1];const o=e??i;let a;t[2]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(Vh,{size:32}),t[2]=a):a=t[2];let l;t[3]!==o.icon||t[4]!==o.title?(l=n.jsx(cs,{icon:o.icon,name:o.title,size:"lg",fallbackIcon:a,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),t[3]=o.icon,t[4]=o.title,t[5]=l):l=t[5];let h;t[6]!==o.title?(h=n.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:o.title}),t[6]=o.title,t[7]=h):h=t[7];const c=o.description??"Ask anything about configuring model providers or using MCP Mesh.";let d;t[8]!==c?(d=n.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:c}),t[8]=c,t[9]=d):d=t[9];let u;t[10]!==l||t[11]!==h||t[12]!==d?(u=n.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[l,h,d]}),t[10]=l,t[11]=h,t[12]=d,t[13]=u):u=t[13];let f;t[14]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx("div",{className:"w-full max-w-3xl mx-auto",children:n.jsx(Le.IceBreakers,{})}),t[14]=f):f=t[14];let m;return t[15]!==u?(m=n.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-6 px-4",children:[u,f]}),t[15]=u,t[16]=m):m=t[16],m}function Ju(){const t=F.c(29),{org:e}=ke(),s=hd(),{isChatEmpty:i}=hs(),[r,o]=D.useState("chat"),a=Bh(),{selectedVirtualMcp:l}=or();let h;t[0]!==e.id?(h=Xn(e.id),t[0]=e.id,t[1]=h):h=t[1];const u=Mt((l??h).id),f=dd(),m=ar(u?.metadata);if(s.length===0&&!(m&&qh(f))){let C;return t[2]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(Le,{className:"animate-in fade-in-0 duration-200",children:n.jsx(Le.Main,{className:"flex flex-col items-center",children:n.jsx(Le.EmptyState,{children:n.jsx(Le.NoAiProviderEmptyState,{})})})}),t[2]=C):C=t[2],C}let _;t[3]!==a.hasDecoKey||t[4]!==a.hasOnlyDecoProvider||t[5]!==a.isLoading||t[6]!==a.isZeroBalance||t[7]!==i||t[8]!==e.id?(_=a.hasDecoKey&&a.isZeroBalance&&a.hasOnlyDecoProvider&&!a.isLoading&&i&&!Lh(e.id),t[3]=a.hasDecoKey,t[4]=a.hasOnlyDecoProvider,t[5]=a.isLoading,t[6]=a.isZeroBalance,t[7]=i,t[8]=e.id,t[9]=_):_=t[9];const g=_;let x;t[10]!==g?(x=g&&n.jsx(Le.CreditsEmptyState,{}),t[10]=g,t[11]=x):x=t[11];const S=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let v;t[12]!==S?(v=te("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",S),t[12]=S,t[13]=v):v=t[13];let b;t[14]!==i?(b=n.jsx(Le.Main,{children:i?n.jsx(Xu,{}):n.jsx(Le.Messages,{})}),t[14]=i,t[15]=b):b=t[15];let y;t[16]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(Le.Footer,{children:n.jsx(Le.Input,{onOpenContextPanel:()=>o("context")})}),t[16]=y):y=t[16];let w;t[17]!==v||t[18]!==b?(w=n.jsxs("div",{className:v,children:[b,y]}),t[17]=v,t[18]=b,t[19]=w):w=t[19];const k=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let j;t[20]!==k?(j=te("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",k),t[20]=k,t[21]=j):j=t[21];let T;t[22]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx(Ou,{back:!0,onClose:()=>o("chat")}),t[22]=T):T=t[22];let P;t[23]!==j?(P=n.jsx("div",{className:j,children:T}),t[23]=j,t[24]=P):P=t[24];let R;return t[25]!==P||t[26]!==x||t[27]!==w?(R=n.jsxs(Le,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[x,w,P]}),t[25]=P,t[26]=x,t[27]=w,t[28]=R):R=t[28],R}function Ol(){const t=F.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Le.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(It,{fallback:e,children:n.jsx(D.Suspense,{fallback:n.jsx(Le.Skeleton,{}),children:n.jsx(Ju,{})})}),t[1]=s):s=t[1],s}function Zu(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 Vo(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 Qu(t,e){return t===1?!0:t===0?!1:e}function ef(t,e){const s=Kt(),i=Kn({strict:!1}),r=cl({strict:!1}),{create:o}=Md(),{locator:a}=ke(),{virtualMcpId:l,orgSlug:h,isAgentRoute:c}=e,d=Zu({entityMetadata:t,mainParamPresent:i.main!==void 0,mainParamValue:i.main}),u=Qu(i.chat,d.chatOpen),f=d.mainOpen,m=D.useRef(crypto.randomUUID()),p=r.taskId??m.current,_="/$org/$taskId",g=T=>({org:h,taskId:T}),x=c?{virtualmcpid:l}:{},S=(T,P)=>{s({to:_,params:g(p),search:R=>({...R,...T}),replace:P?.replace??!1})},v=(T,P)=>{s({to:_,params:g(T),search:R=>{const C={};return P?C.virtualmcpid=P:c&&(C.virtualmcpid=l),C}})},b=()=>{f?S({main:"0"},{replace:!0}):S({main:ed(t)},{replace:!0})},y=()=>{S({chat:u?0:1},{replace:!0})},w=()=>{u||S({chat:1},{replace:!0})},k=async()=>{const T=crypto.randomUUID(),P=ud(h,a,p);try{await o({id:T,virtual_mcp_id:l,...P?{branch:P}:{}})}catch{}s({to:_,params:g(T),search:R=>({...x,chat:1})})},j=T=>{S({main:T},{replace:!0})};return{taskId:p,mainOpen:f,chatOpen:u,mainParam:i.main,setTaskId:v,toggleMain:b,toggleChat:y,openChat:w,createNewTask:k,openTab:j}}const tf={settings:Sd,automations:bd,preview:Zn,git:to};function qo(t){const e=lr(t);if(e.type==="icon"){const s=cr(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function Tr(t){if(t.kind==="system")return{kind:"component",Component:tf[t.tabId]};const e=qo(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=qo(s.icon);return i||{kind:"fallback"}}function sf(t){const{org:e}=ke(),s=Je({connectionId:Ns,orgId:e.id,orgSlug:e.slug}),i=jl(),r=D.useSyncExternalStore(i.threads.subscribe,i.threads.get),o=t?r.find(l=>l.id===t)??null:null,{data:a}=Eh({queryKey:rs.ensureTask(e.id,t),queryFn:async()=>{if(!t||!s)return null;try{const l=await s.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}});return(l.structuredContent??l).item??null}catch{return null}},select:l=>l?.metadata??null,staleTime:3e4});return o?.metadata??a??null}function $l(t){const e=F.c(8),s=Kt();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const r=Kn(i),o=Mt(t.virtualMcpId),a=sf(t.taskId),{currentBranch:l}=ds(),h=o?.metadata?.ui??null,c=h?.layout??null,d=c?.tabs??[],u=h?.pinnedViews??[],f=a?.expanded_tools??[],m=_l(o),p=ar(o?.metadata);let _;e[1]===Symbol.for("react.memo_cache_sentinel")?(_={includeVirtual:!0},e[1]=_):_=e[1];const g=hr(_),{activeTab:x,mainOpen:S}=td({mainParam:r.main,metadata:c?{defaultMainView:c.defaultMainView??null,tabs:d.map(rf)}:null}),v=gl(x),b=[];p&&b.push({id:"preview",title:"Preview"}),m&&b.push({id:"git",title:l??"git"}),b.push({id:"settings",title:"Settings"}),b.push({id:"automations",title:"Automations"});const y=new Map;for(const P of f){const R=$o(P.appId,P.toolName);y.set(R,{id:R,title:P.toolName,appId:P.appId,iconKey:P.toolName})}for(const P of u){const R=$o(P.connectionId,P.toolName);y.set(R,{id:R,title:P.label||P.toolName,appId:P.connectionId,iconKey:P.toolName,iconUrl:P.icon??null})}let w;e[2]!==g?(w=P=>({id:P.id,title:P.title,kind:"agent",icon:Tr({tabId:P.id,kind:"agent",appId:P.view.appId,connections:g})}),e[2]=g,e[3]=w):w=e[3];const k=[...d.map(w),...Array.from(y.values()).map(P=>({id:P.id,title:P.title,kind:"expanded",icon:Tr({tabId:P.iconKey,kind:"expanded",appId:P.appId,iconUrl:P.iconUrl,connections:g})})),...b.map(P=>({id:P.id,title:P.title,kind:"system",icon:Tr({tabId:P.id,kind:"system",connections:g})}))];let j;return e[4]!==x||e[5]!==S||e[6]!==s?(j=P=>{const R=sd({clickedId:P,activeTab:x,mainOpen:S});s({to:".",search:C=>({...C,main:R}),replace:!0})},e[4]=x,e[5]=S,e[6]=s,e[7]=j):j=e[7],{activeTab:x,mainOpen:S,setActiveTab:j,systemTabs:b,layoutTabs:d,expandedTools:f,automationTabParsed:v,tabs:k}}function rf(t){return{id:t.id}}function zl(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.
|
|
3
3
|
<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 nf(t){const e=F.c(84),{value:s,onChange:i,onColorChange:r,name:o,size:a,className:l,avatarClassName:h,showHoverOverlay:c,disabled:d}=t,u=a===void 0?"lg":a,f=c===void 0?!0:c,m=d===void 0?!1:d,[p,_]=D.useState(!1),[g,x]=D.useState("icons"),[S,v]=D.useState(""),[b,y]=D.useState("blue");let w;e[0]!==s?(w=lr(s),e[0]=s,e[1]=w):w=e[1];const k=w,j=k.type==="icon"||k.type==="url"&&k.color?k.color:b;let T;e[2]!==i||e[3]!==j?(T=be=>{i(Er(be,j))},e[2]=i,e[3]=j,e[4]=T):T=e[4];const P=T;let R;e[5]!==i||e[6]!==r||e[7]!==k.name||e[8]!==k.type||e[9]!==k.url?(R=be=>{y(be),r?.(be),k.type==="icon"?i(Er(k.name,be)):k.type==="url"&&i(zo(k.url,be))},e[5]=i,e[6]=r,e[7]=k.name,e[8]=k.type,e[9]=k.url,e[10]=R):R=e[10];const C=R;let N;e[11]!==i||e[12]!==j?(N=be=>{i(zo(be,j)),_(!1)},e[11]=i,e[12]=j,e[13]=N):N=e[13];const B=N;let I;e[14]!==i||e[15]!==j?(I=()=>{const be=so(),qe=be[Math.floor(Math.random()*be.length)];i(Er(qe,j))},e[14]=i,e[15]=j,e[16]=I):I=e[16];const E=I;let M,A,L,H,$,z,V,q;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"};A=ci,z=m?!1:p,V=_,M=hi,$=!0,q="button",L=m,H=te("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]=M,e[22]=A,e[23]=L,e[24]=H,e[25]=$,e[26]=z,e[27]=V,e[28]=q}else M=e[21],A=e[22],L=e[23],H=e[24],$=e[25],z=e[26],V=e[27],q=e[28];let ee;e[29]!==h||e[30]!==o||e[31]!==u||e[32]!==s?(ee=n.jsx(Fo,{icon:s,name:o,size:u,className:h}),e[29]=h,e[30]=o,e[31]=u,e[32]=s,e[33]=ee):ee=e[33];let G;e[34]!==m||e[35]!==f?(G=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(io,{size:16,className:"text-white"})}),e[34]=m,e[35]=f,e[36]=G):G=e[36];let Y;e[37]!==L||e[38]!==H||e[39]!==ee||e[40]!==G||e[41]!==q?(Y=n.jsxs("button",{type:q,disabled:L,className:H,children:[ee,G]}),e[37]=L,e[38]=H,e[39]=ee,e[40]=G,e[41]=q,e[42]=Y):Y=e[42];let O;e[43]!==M||e[44]!==$||e[45]!==Y?(O=n.jsx(M,{asChild:$,children:Y}),e[43]=M,e[44]=$,e[45]=Y,e[46]=O):O=e[46];let X;e[47]!==o||e[48]!==s?(X=n.jsx("div",{className:"flex items-center justify-center py-4",children:n.jsx(Fo,{icon:s,name:o,size:"xl"})}),e[47]=o,e[48]=s,e[49]=X):X=e[49];let J;e[50]===Symbol.for("react.memo_cache_sentinel")?(J=()=>x("icons"),e[50]=J):J=e[50];const ie=g==="icons"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let oe;e[51]!==ie?(oe=te("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",ie),e[51]=ie,e[52]=oe):oe=e[52];let W;e[53]!==oe?(W=n.jsx("button",{type:"button",onClick:J,className:oe,children:"Icons"}),e[53]=oe,e[54]=W):W=e[54];let ne;e[55]===Symbol.for("react.memo_cache_sentinel")?(ne=()=>x("upload"),e[55]=ne):ne=e[55];const me=g==="upload"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let _e;e[56]!==me?(_e=te("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",me),e[56]=me,e[57]=_e):_e=e[57];let pe;e[58]!==_e?(pe=n.jsx("button",{type:"button",onClick:ne,className:_e,children:"Upload"}),e[58]=_e,e[59]=pe):pe=e[59];let xe;e[60]===Symbol.for("react.memo_cache_sentinel")?(xe=n.jsx("div",{className:"flex-1"}),e[60]=xe):xe=e[60];let le;e[61]!==W||e[62]!==pe?(le=n.jsxs("div",{className:"flex items-center border-b border-border px-3",children:[W,pe,xe]}),e[61]=W,e[62]=pe,e[63]=le):le=e[63];let re;e[64]!==C||e[65]!==E||e[66]!==P||e[67]!==B||e[68]!==k.name||e[69]!==k.type||e[70]!==S||e[71]!==j||e[72]!==g?(re=g==="icons"?n.jsx(cf,{search:S,onSearchChange:v,selectedColor:j,onColorChange:C,onSelectIcon:P,onRandom:E,currentIconName:k.type==="icon"?k.name:null}):n.jsx(hf,{onUpload:B}),e[64]=C,e[65]=E,e[66]=P,e[67]=B,e[68]=k.name,e[69]=k.type,e[70]=S,e[71]=j,e[72]=g,e[73]=re):re=e[73];let ce;e[74]!==X||e[75]!==le||e[76]!==re?(ce=n.jsx(di,{align:"start",className:"w-80 p-0",onOpenAutoFocus:of,children:n.jsxs("div",{className:"flex flex-col",children:[X,le,re]})}),e[74]=X,e[75]=le,e[76]=re,e[77]=ce):ce=e[77];let ge;return e[78]!==A||e[79]!==z||e[80]!==V||e[81]!==O||e[82]!==ce?(ge=n.jsxs(A,{open:z,onOpenChange:V,children:[O,ce]}),e[78]=A,e[79]=z,e[80]=V,e[81]=O,e[82]=ce,e[83]=ge):ge=e[83],ge}function of(t){return t.preventDefault()}function af(t){const e=F.c(27),{selectedColor:s,onColorChange:i}=t,[r,o]=D.useState(!1);let a,l,h,c,d,u,f;if(e[0]!==r||e[1]!==s){const S=bl(s);l=ci,u=r,f=o,a=hi,d=!0,h="button",c=te("h-6 w-6 rounded-full shrink-0 ring-2 ring-offset-2 ring-offset-background transition-all cursor-pointer hover:scale-110",S.dot,"ring-foreground/20"),e[0]=r,e[1]=s,e[2]=a,e[3]=l,e[4]=h,e[5]=c,e[6]=d,e[7]=u,e[8]=f}else a=e[2],l=e[3],h=e[4],c=e[5],d=e[6],u=e[7],f=e[8];let m;e[9]!==h||e[10]!==c?(m=n.jsx("button",{type:h,className:c,title:"Change color"}),e[9]=h,e[10]=c,e[11]=m):m=e[11];let p;e[12]!==a||e[13]!==d||e[14]!==m?(p=n.jsx(a,{asChild:d,children:m}),e[12]=a,e[13]=d,e[14]=m,e[15]=p):p=e[15];let _;e[16]!==i||e[17]!==s?(_=wd.map(S=>n.jsx("button",{type:"button",onClick:()=>{i(S.name),o(!1)},className:te("h-5 w-5 rounded-full transition-all shrink-0 cursor-pointer",S.dot,s===S.name?"ring-2 ring-offset-1 ring-offset-background ring-foreground/30 scale-110":"hover:scale-110"),title:S.name},S.name)),e[16]=i,e[17]=s,e[18]=_):_=e[18];let g;e[19]!==_?(g=n.jsx(di,{align:"start",side:"right",sideOffset:8,className:"w-auto p-2",onOpenAutoFocus:lf,children:n.jsx("div",{className:"grid grid-cols-4 gap-1",children:_})}),e[19]=_,e[20]=g):g=e[20];let x;return e[21]!==l||e[22]!==u||e[23]!==f||e[24]!==p||e[25]!==g?(x=n.jsxs(l,{open:u,onOpenChange:f,children:[p,g]}),e[21]=l,e[22]=u,e[23]=f,e[24]=p,e[25]=g,e[26]=x):x=e[26],x}function lf(t){return t.preventDefault()}function cf(t){const e=F.c(44),{search:s,onSearchChange:i,selectedColor:r,onColorChange:o,onSelectIcon:a,onRandom:l,currentIconName:h}=t;let c,d,u,f,m,p,_;if(e[0]!==h||e[1]!==o||e[2]!==l||e[3]!==i||e[4]!==a||e[5]!==s||e[6]!==r){const b=so(),y=bl(r);d=s.trim()?b.filter(C=>{const N=Vr(C),B=s.toLowerCase();return N.includes(B)||C.toLowerCase().includes(B)}):b,p="flex flex-col";let w;e[14]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(Il,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[14]=w):w=e[14];let k;e[15]!==i?(k=C=>i(C.target.value),e[15]=i,e[16]=k):k=e[16];let j;e[17]!==s||e[18]!==k?(j=n.jsxs("div",{className:"relative flex-1",children:[w,n.jsx(it,{value:s,onChange:k,placeholder:"Filter...",className:"h-8 text-xs pl-7"})]}),e[17]=s,e[18]=k,e[19]=j):j=e[19];let T;e[20]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx(yd,{size:14,className:"text-muted-foreground"}),e[20]=T):T=e[20];let P;e[21]!==l?(P=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:T}),e[21]=l,e[22]=P):P=e[22];let R;e[23]!==o||e[24]!==r?(R=n.jsx(af,{selectedColor:r,onColorChange:o}),e[23]=o,e[24]=r,e[25]=R):R=e[25],e[26]!==P||e[27]!==R||e[28]!==j?(_=n.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[j,P,R]}),e[26]=P,e[27]=R,e[28]=j,e[29]=_):_=e[29],c=Al,m="h-56",u="grid grid-cols-9 gap-0.5 px-2 pb-2",f=d.map(C=>{const N=cr(C);return N?n.jsx("button",{type:"button",onClick:()=>a(C),className:te("h-8 w-8 flex items-center justify-center rounded-md transition-colors cursor-pointer",h===C?te(y.bg,y.text):te(y.text,"hover:bg-accent")),title:C,children:n.jsx(N,{size:18})},C):null}),e[0]=h,e[1]=o,e[2]=l,e[3]=i,e[4]=a,e[5]=s,e[6]=r,e[7]=c,e[8]=d,e[9]=u,e[10]=f,e[11]=m,e[12]=p,e[13]=_}else c=e[7],d=e[8],u=e[9],f=e[10],m=e[11],p=e[12],_=e[13];let g;e[30]!==u||e[31]!==f?(g=n.jsx("div",{className:u,children:f}),e[30]=u,e[31]=f,e[32]=g):g=e[32];let x;e[33]!==d.length?(x=d.length===0&&n.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No icons found"}),e[33]=d.length,e[34]=x):x=e[34];let S;e[35]!==c||e[36]!==m||e[37]!==g||e[38]!==x?(S=n.jsxs(c,{className:m,children:[g,x]}),e[35]=c,e[36]=m,e[37]=g,e[38]=x,e[39]=S):S=e[39];let v;return e[40]!==p||e[41]!==_||e[42]!==S?(v=n.jsxs("div",{className:p,children:[_,S]}),e[40]=p,e[41]=_,e[42]=S,e[43]=v):v=e[43],v}function hf(t){const e=F.c(27),{onUpload:s}=t,i=D.useRef(null);let r;e[0]!==s?(r=w=>{const k=w.target.files?.[0];if(!k)return;if(k.size>2097152){ae.error("Image must be smaller than 2MB"),w.target.value="";return}const j=new FileReader;j.onerror=()=>{ae.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(k)},e[0]=s,e[1]=r):r=e[1];const o=r,[a,l]=D.useState("");let h;e[2]!==s||e[3]!==a?(h=()=>{const w=a.trim();w&&(s(w),l(""))},e[2]=s,e[3]=a,e[4]=h):h=e[4];const c=h;let d;e[5]!==o?(d=n.jsx("input",{type:"file",ref:i,className:"hidden",accept:"image/*",onChange:o}),e[5]=o,e[6]=d):d=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(eu,{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=w=>l(w.target.value),e[10]=p):p=e[10];let _;e[11]!==c?(_=w=>{w.key==="Enter"&&(w.preventDefault(),c())},e[11]=c,e[12]=_):_=e[12];let g;e[13]!==a||e[14]!==_?(g=n.jsx(it,{value:a,onChange:p,placeholder:"Paste image URL...",className:"h-8 text-xs flex-1",onKeyDown:_}),e[13]=a,e[14]=_,e[15]=g):g=e[15];let x;e[16]!==a?(x=a.trim(),e[16]=a,e[17]=x):x=e[17];const S=!x;let v;e[18]!==c||e[19]!==S?(v=n.jsx(Q,{variant:"outline",size:"sm",className:"h-8 px-3 text-xs shrink-0",onClick:c,disabled:S,children:"Apply"}),e[18]=c,e[19]=S,e[20]=v):v=e[20];let b;e[21]!==v||e[22]!==g?(b=n.jsxs("div",{className:"flex items-center gap-1.5",children:[g,v]}),e[21]=v,e[22]=g,e[23]=b):b=e[23];let y;return e[24]!==b||e[25]!==d?(y=n.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[d,f,m,b]}),e[24]=b,e[25]=d,e[26]=y):y=e[26],y}function df(t){const e=F.c(5),{value:s}=t;let i;if(e[0]!==s){i=Symbol.for("react.early_return_sentinel");e:{const o=lr(s);if(o.type==="icon"){const a=cr(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(tu,{size:16,className:"text-muted-foreground"}),e[4]=r):r=e[4],r}function uf(t){const e=F.c(66),{value:s,onChange:i,className:r,disabled:o}=t,[a,l]=D.useState(!1),[h,c]=D.useState("");let d;e[0]!==s?(d=lr(s),e[0]=s,e[1]=d):d=e[1];const u=d,f=u.type==="icon"?u.name:null;let m,p,_,g,x,S,v,b,y,w,k,j,T,P,R;if(e[2]!==r||e[3]!==f||e[4]!==o||e[5]!==i||e[6]!==a||e[7]!==h||e[8]!==s){const A=so();g=h.trim()?A.filter(ee=>{const G=h.toLowerCase();return Vr(ee).includes(G)||ee.toLowerCase().includes(G)}):A,_=ci,x=o?!1:a,S=l;const L=o?"cursor-default opacity-50":"cursor-pointer hover:bg-accent";let H;e[24]!==r||e[25]!==L?(H=te("size-7 shrink-0 rounded-md transition-colors flex items-center justify-center",L,r),e[24]=r,e[25]=L,e[26]=H):H=e[26];let $;e[27]!==s?($=n.jsx(df,{value:s}),e[27]=s,e[28]=$):$=e[28],e[29]!==o||e[30]!==H||e[31]!==$?(v=n.jsx(hi,{asChild:!0,children:n.jsx("button",{type:"button",disabled:o,className:H,children:$})}),e[29]=o,e[30]=H,e[31]=$,e[32]=v):v=e[32],p=di,T="start",P="w-64 p-0",R=ff,k="flex flex-col";let z;e[33]===Symbol.for("react.memo_cache_sentinel")?(z=n.jsx(Il,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[33]=z):z=e[33];let V;e[34]===Symbol.for("react.memo_cache_sentinel")?(V=ee=>c(ee.target.value),e[34]=V):V=e[34],e[35]!==h?(j=n.jsx("div",{className:"px-2 py-2",children:n.jsxs("div",{className:"relative",children:[z,n.jsx(it,{value:h,onChange:V,placeholder:"Filter...",className:"h-7 text-xs pl-7"})]})}),e[35]=h,e[36]=j):j=e[36],m=Al,w="h-48",b="grid grid-cols-8 gap-0.5 px-2 pb-2";let q;e[37]!==f||e[38]!==i?(q=ee=>{const G=cr(ee);return G?n.jsx("button",{type:"button",onClick:()=>{i(`icon://${ee}`),l(!1)},className:te("h-7 w-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",f===ee?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),title:Vr(ee),children:n.jsx(G,{size:16})},ee):null},e[37]=f,e[38]=i,e[39]=q):q=e[39],y=g.map(q),e[2]=r,e[3]=f,e[4]=o,e[5]=i,e[6]=a,e[7]=h,e[8]=s,e[9]=m,e[10]=p,e[11]=_,e[12]=g,e[13]=x,e[14]=S,e[15]=v,e[16]=b,e[17]=y,e[18]=w,e[19]=k,e[20]=j,e[21]=T,e[22]=P,e[23]=R}else m=e[9],p=e[10],_=e[11],g=e[12],x=e[13],S=e[14],v=e[15],b=e[16],y=e[17],w=e[18],k=e[19],j=e[20],T=e[21],P=e[22],R=e[23];let C;e[40]!==b||e[41]!==y?(C=n.jsx("div",{className:b,children:y}),e[40]=b,e[41]=y,e[42]=C):C=e[42];let N;e[43]!==g.length?(N=g.length===0&&n.jsx("div",{className:"flex items-center justify-center py-6 text-xs text-muted-foreground",children:"No icons found"}),e[43]=g.length,e[44]=N):N=e[44];let B;e[45]!==m||e[46]!==C||e[47]!==N||e[48]!==w?(B=n.jsxs(m,{className:w,children:[C,N]}),e[45]=m,e[46]=C,e[47]=N,e[48]=w,e[49]=B):B=e[49];let I;e[50]!==B||e[51]!==k||e[52]!==j?(I=n.jsxs("div",{className:k,children:[j,B]}),e[50]=B,e[51]=k,e[52]=j,e[53]=I):I=e[53];let E;e[54]!==p||e[55]!==I||e[56]!==T||e[57]!==P||e[58]!==R?(E=n.jsx(p,{align:T,className:P,onOpenAutoFocus:R,children:I}),e[54]=p,e[55]=I,e[56]=T,e[57]=P,e[58]=R,e[59]=E):E=e[59];let M;return e[60]!==_||e[61]!==x||e[62]!==S||e[63]!==v||e[64]!==E?(M=n.jsxs(_,{open:x,onOpenChange:S,children:[v,E]}),e[60]=_,e[61]=x,e[62]=S,e[63]=v,e[64]=E,e[65]=M):M=e[65],M}function ff(t){return t.preventDefault()}function $i(){const t=F.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(Se,{className:"animate-spin text-muted-foreground",size:24})}),t[0]=e):e=t[0],e}function Rr(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(Xs,{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 mf(t){const e=F.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 h;e[0]!==a||e[1]!==l?(h=te("flex items-start gap-3 p-4 rounded-lg transition-colors",a,l),e[0]=a,e[1]=l,e[2]=h):h=e[2];let c;e[3]!==s.name?(c=n.jsx("p",{className:"text-sm font-medium leading-none truncate",children:s.name}),e[3]=s.name,e[4]=c):c=e[4];let d;e[5]!==s.tags?(d=s.tags&&n.jsx("span",{className:"shrink-0",children:s.tags}),e[5]=s.tags,e[6]=d):d=e[6];let u;e[7]!==c||e[8]!==d?(u=n.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[c,d]}),e[7]=c,e[8]=d,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(Ml,{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 _;return e[19]!==h||e[20]!==m||e[21]!==p?(_=n.jsxs("label",{className:h,children:[m,p]}),e[19]=h,e[20]=m,e[21]=p,e[22]=_):_=e[22],_}function ho(t){const e=F.c(13),{items:s,selections:i,onToggle:r,emptyMessage:o,disabled:a}=t;let l,h,c;if(e[0]!==a||e[1]!==o||e[2]!==s||e[3]!==r||e[4]!==i){c=Symbol.for("react.early_return_sentinel");e:{const u=s.map(pf);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],c=f;break e}l="flex-1 overflow-auto px-4 py-3 space-y-1",h=s.map(f=>n.jsx(mf,{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]=h,e[7]=c}else l=e[5],h=e[6],c=e[7];if(c!==Symbol.for("react.early_return_sentinel"))return c;let d;return e[10]!==l||e[11]!==h?(d=n.jsx("div",{className:l,children:h}),e[10]=l,e[11]=h,e[12]=d):d=e[12],d}function pf(t){return t.id}function _f(t){const e=F.c(13),{connectionId:s,selections:i,onToggle:r,disabled:o}=t,{org:a}=ke();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 h=Je(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:d}=ru(c);let u;e[6]!==d.tools?(u=d.tools.map(gf),e[6]=d.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(ho,{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 gf(t){return{id:t.name,name:t.name,description:t.description,tags:n.jsx(Vd,{annotations:t.annotations,_meta:t._meta})}}function vf(t){const e=F.c(13),{connectionId:s,selections:i,onToggle:r,disabled:o}=t,{org:a}=ke();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 h=Je(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:d}=Ud(c);let u;e[6]!==d.resources?(u=d.resources.map(xf),e[6]=d.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(ho,{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 xf(t){return{id:t.name||t.uri,name:t.name||t.uri,description:t.description}}function bf(t){const e=F.c(13),{connectionId:s,selections:i,onToggle:r,disabled:o}=t,{org:a}=ke();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 h=Je(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:d}=nu(c);let u;e[6]!==d.prompts?(u=d.prompts.map(Sf),e[6]=d.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(ho,{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 Sf(t){return{id:t.name,name:t.name,description:t.description}}function yf(t){const e=F.c(54),{currentConnection:s,activeTab:i,selectedId:r,formData:o,toggleTool:a,toggleResource:l,togglePrompt:h,toggleAllTools:c,toggleAllResources:d,toggleAllPrompts:u,onTabChange:f}=t,m=o[r],p=i==="tools"?m?.tools===null:i==="resources"?m?.resources===null:m?.prompts===null;let _;e[0]!==i||e[1]!==r||e[2]!==u||e[3]!==d||e[4]!==c?(_=()=>{i==="tools"?c(r):i==="resources"?d(r):u(r)},e[0]=i,e[1]=r,e[2]=u,e[3]=d,e[4]=c,e[5]=_):_=e[5];const g=_;let x;e[6]!==s.icon||e[7]!==s.title?(x=n.jsx(cs,{icon:s.icon,name:s.title,size:"sm",className:"shrink-0"}),e[6]=s.icon,e[7]=s.title,e[8]=x):x=e[8];let S;e[9]!==s.title?(S=n.jsx("h2",{className:"text-base font-semibold truncate",children:s.title}),e[9]=s.title,e[10]=S):S=e[10];let v;e[11]!==s.description?(v=s.description&&n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.description}),e[11]=s.description,e[12]=v):v=e[12];let b;e[13]!==S||e[14]!==v?(b=n.jsxs("div",{className:"flex-1 min-w-0",children:[S,v]}),e[13]=S,e[14]=v,e[15]=b):b=e[15];let y;e[16]!==x||e[17]!==b?(y=n.jsx("div",{className:"px-6 pt-5 pb-4 shrink-0",children:n.jsxs("div",{className:"flex items-center gap-3",children:[x,b]})}),e[16]=x,e[17]=b,e[18]=y):y=e[18];let w;e[19]===Symbol.for("react.memo_cache_sentinel")?(w=[{id:"tools",label:"Tools"},{id:"resources",label:"Resources"},{id:"prompts",label:"Prompts"}],e[19]=w):w=e[19];let k;e[20]!==f?(k=M=>f(M),e[20]=f,e[21]=k):k=e[21];let j;e[22]!==i||e[23]!==k?(j=n.jsx(iu,{tabs:w,activeTab:i,onTabChange:k}),e[22]=i,e[23]=k,e[24]=j):j=e[24];const T=p?"Deselect all":"Select all";let P;e[25]!==g||e[26]!==T?(P=n.jsx("button",{type:"button",onClick:g,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:T}),e[25]=g,e[26]=T,e[27]=P):P=e[27];let R;e[28]!==P||e[29]!==j?(R=n.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-t border-border shrink-0",children:[j,P]}),e[28]=P,e[29]=j,e[30]=R):R=e[30];let C;e[31]!==i||e[32]!==o||e[33]!==r||e[34]!==a?(C=i==="tools"&&n.jsx(It,{fallback:Rr("Tools not supported by this server"),children:n.jsx(D.Suspense,{fallback:n.jsx($i,{}),children:n.jsx(_f,{connectionId:r,selections:o[r]?o[r].tools:[],onToggle:(M,A)=>a(r,M,A)})})}),e[31]=i,e[32]=o,e[33]=r,e[34]=a,e[35]=C):C=e[35];let N;e[36]!==i||e[37]!==o||e[38]!==r||e[39]!==l?(N=i==="resources"&&n.jsx(It,{fallback:Rr("Resources not supported by this server"),children:n.jsx(D.Suspense,{fallback:n.jsx($i,{}),children:n.jsx(vf,{connectionId:r,selections:o[r]?o[r].resources:[],onToggle:(M,A)=>l(r,M,A)})})}),e[36]=i,e[37]=o,e[38]=r,e[39]=l,e[40]=N):N=e[40];let B;e[41]!==i||e[42]!==o||e[43]!==r||e[44]!==h?(B=i==="prompts"&&n.jsx(It,{fallback:Rr("Prompts not supported by this server"),children:n.jsx(D.Suspense,{fallback:n.jsx($i,{}),children:n.jsx(bf,{connectionId:r,selections:o[r]?o[r].prompts:[],onToggle:(M,A)=>h(r,M,A)})})}),e[41]=i,e[42]=o,e[43]=r,e[44]=h,e[45]=B):B=e[45];let I;e[46]!==C||e[47]!==N||e[48]!==B?(I=n.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[C,N,B]}),e[46]=C,e[47]=N,e[48]=B,e[49]=I):I=e[49];let E;return e[50]!==R||e[51]!==I||e[52]!==y?(E=n.jsxs(n.Fragment,{children:[y,R,I]}),e[50]=R,e[51]=I,e[52]=y,e[53]=E):E=e[53],E}function wf(t){const e=F.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=Tl(o);if(a.supportsOAuth&&!a.isAuthenticated){let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("div",{className:"flex items-center justify-center size-12 rounded-full bg-muted",children:n.jsx(Cd,{size:22,className:"text-muted-foreground"})}),e[2]=c):c=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=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]=d):d=e[3];let u;e[4]!==s||e[5]!==i?(u=i&&n.jsx(Q,{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:[c,d,u]}),e[7]=u,e[8]=f):f=e[8],f}let h;return e[9]!==r?(h=n.jsx(n.Fragment,{children:r}),e[9]=r,e[10]=h):h=e[10],h}function Cf(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 Go(t){return Object.entries(t).map(([e,s])=>({connection_id:e,selected_tools:s.tools,selected_resources:s.resources,selected_prompts:s.prompts}))}function kf(t,e){return e.type==="SET_ACTIVE_TAB"?{...t,activeTab:e.payload}:t}function jf(t){const e=F.c(49),{open:s,onOpenChange:i,selectedId:r,form:o,connections:a,onAuthenticate:l}=t;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h={activeTab:"tools"},e[0]=h):h=e[0];const[c,d]=D.useReducer(kf,h),u=no(r??"");let f;e[1]!==a?(f=a??[],e[1]=a,e[2]=f):f=e[2];let m;e[3]!==f?(m=Cf(f),e[3]=f,e[4]=m):m=e[4];const p=m;let _;e[5]!==o||e[6]!==p?(_=(z,V,q,ee)=>{const G=p[z]?.[V];let Y;G===null?Y=ee.filter(X=>X!==q):G?.includes(q)?Y=G.filter(X=>X!==q):(Y=[...G??[],q],Y.length===ee.length&&(Y=null));const O={...p};O[z]?O[z]={...O[z]}:O[z]={tools:null,resources:null,prompts:null},O[z][V]=Y,o.setValue("connections",Go(O),{shouldDirty:!0,shouldTouch:!0})},e[5]=o,e[6]=p,e[7]=_):_=e[7];const g=_;let x;e[8]!==o||e[9]!==p?(x=(z,V)=>{const ee=p[z]?.[V]===null?[]:null,G={...p};G[z]?G[z]={...G[z]}:G[z]={tools:null,resources:null,prompts:null},G[z][V]=ee,o.setValue("connections",Go(G),{shouldDirty:!0,shouldTouch:!0})},e[8]=o,e[9]=p,e[10]=x):x=e[10];const S=x;let v;e[11]!==g?(v=(z,V,q)=>g(z,"tools",V,q),e[11]=g,e[12]=v):v=e[12];const b=v;let y;e[13]!==g?(y=(z,V,q)=>g(z,"resources",V,q),e[13]=g,e[14]=y):y=e[14];const w=y;let k;e[15]!==g?(k=(z,V,q)=>g(z,"prompts",V,q),e[15]=g,e[16]=k):k=e[16];const j=k;let T;e[17]!==S?(T=z=>S(z,"tools"),e[17]=S,e[18]=T):T=e[18];const P=T;let R;e[19]!==S?(R=z=>S(z,"resources"),e[19]=S,e[20]=R):R=e[20];const C=R;let N;e[21]!==S?(N=z=>S(z,"prompts"),e[21]=S,e[22]=N):N=e[22];const B=N;if(!r||!u)return null;let I;e[23]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx($i,{}),e[23]=I):I=e[23];let E;e[24]===Symbol.for("react.memo_cache_sentinel")?(E=z=>d({type:"SET_ACTIVE_TAB",payload:z}),e[24]=E):E=e[24];let M;e[25]!==u||e[26]!==c.activeTab||e[27]!==p||e[28]!==r||e[29]!==B||e[30]!==C||e[31]!==P||e[32]!==j||e[33]!==w||e[34]!==b?(M=n.jsx(yf,{currentConnection:u,activeTab:c.activeTab,selectedId:r,formData:p,toggleTool:b,toggleResource:w,togglePrompt:j,toggleAllTools:P,toggleAllResources:C,toggleAllPrompts:B,onTabChange:E},r),e[25]=u,e[26]=c.activeTab,e[27]=p,e[28]=r,e[29]=B,e[30]=C,e[31]=P,e[32]=j,e[33]=w,e[34]=b,e[35]=M):M=e[35];let A;e[36]!==l||e[37]!==r||e[38]!==M?(A=n.jsx(D.Suspense,{fallback:I,children:n.jsx(wf,{connectionId:r,onAuthenticate:l,children:M})}),e[36]=l,e[37]=r,e[38]=M,e[39]=A):A=e[39];let L;e[40]!==i?(L=n.jsx(dr,{className:"px-6 py-4 border-t border-border shrink-0",children:n.jsx(Q,{variant:"outline",onClick:()=>i(!1),children:"Done"})}),e[40]=i,e[41]=L):L=e[41];let H;e[42]!==A||e[43]!==L?(H=n.jsxs(us,{className:"sm:max-w-2xl h-[75vh] max-h-[75vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[A,L]}),e[42]=A,e[43]=L,e[44]=H):H=e[44];let $;return e[45]!==i||e[46]!==s||e[47]!==H?($=n.jsx(fs,{open:s,onOpenChange:i,children:H}),e[45]=i,e[46]=s,e[47]=H,e[48]=$):$=e[48],$}const Pr={tools:null,resources:null,prompts:null},Nf=Th.pick({status:!0,title:!0,description:!0,icon:!0,metadata:!0,connections:!0});function Ef(t){const s=new TextEncoder().encode(t),i=Array.from(s,r=>String.fromCharCode(r)).join("");return btoa(i)}function Tf(t){const e=F.c(11),{url:s,agentId:i}=t,[r,o]=D.useState(!1);let a;e[0]!==i||e[1]!==s?(a=async()=>{Ee("agent_connect_action",{agent_id:i,action:"copy_url"}),await navigator.clipboard.writeText(s),o(!0),ae.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 h;e[3]!==r?(h=r?n.jsx(fi,{size:20,className:"text-green-600"}):n.jsx(es,{size:20}),e[3]=r,e[4]=h):h=e[4];const c=r?"Copied!":"Copy URL";let d;e[5]!==c?(d=n.jsx("span",{className:"text-xs font-medium",children:c}),e[5]=c,e[6]=d):d=e[6];let u;return e[7]!==l||e[8]!==h||e[9]!==d?(u=n.jsxs(Q,{type:"button",variant:"outline",onClick:l,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[h,d]}),e[7]=l,e[8]=h,e[9]=d,e[10]=u):u=e[10],u}function Rf(t){const e=F.c(8),{url:s,serverName:i,agentId:r}=t;let o;e[0]!==r||e[1]!==i||e[2]!==s?(o=()=>{Ee("agent_connect_action",{agent_id:r,action:"install_cursor"});const d=Rl(i),f=Ef(JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Cursor"}},null,2)),m=`cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(d)}&config=${encodeURIComponent(f)}`;window.open(m,"_blank"),ae.success("Opening Cursor...")},e[0]=r,e[1]=i,e[2]=s,e[3]=o):o=e[3];const a=o;let l,h;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%)"}}),h=n.jsx("span",{className:"text-xs font-medium",children:"Install on Cursor"}),e[4]=l,e[5]=h):(l=e[4],h=e[5]);let c;return e[6]!==a?(c=n.jsxs(Q,{type:"button",variant:"outline",onClick:a,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[l,h]}),e[6]=a,e[7]=c):c=e[7],c}function Pf(t){const e=F.c(12),{url:s,serverName:i,agentId:r}=t,[o,a]=D.useState(!1);let l;e[0]!==r||e[1]!==i||e[2]!==s?(l=async()=>{Ee("agent_connect_action",{agent_id:r,action:"install_claude_code"});const m=Rl(i),_=JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Claude Code"}},null,2),g=`claude mcp add-json "${m}" '${_.replace(/'/g,"'\\''")}' --scope user`;await navigator.clipboard.writeText(g),a(!0),ae.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 h=l;let c;e[4]!==o?(c=o?n.jsx(fi,{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]=c):c=e[5];const d=o?"Copied!":"Install on Claude Code";let u;e[6]!==d?(u=n.jsx("span",{className:"text-xs font-medium",children:d}),e[6]=d,e[7]=u):u=e[7];let f;return e[8]!==h||e[9]!==c||e[10]!==u?(f=n.jsxs(Q,{type:"button",variant:"outline",onClick:h,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[c,u]}),e[8]=h,e[9]=c,e[10]=u,e[11]=f):f=e[11],f}function Df({virtualMcp:t}){const{org:e}=ke(),s=Je({connectionId:Ns,orgId:e.id,orgSlug:e.slug}),[i,r]=D.useState(null),[o,a]=D.useState(!1),[l,h]=D.useState(!1),c=t.id,d=t.title||`agent-${c.slice(0,8)}`,u=i?`bunx @decocms/typegen@latest --mcp ${c} --key ${i} --output client.ts`:`bunx @decocms/typegen@latest --mcp ${c} --key <api-key> --output client.ts`,f=async()=>{a(!0);try{const _=(await s.callTool({name:"API_KEY_CREATE",arguments:{name:`typegen-${d}`,permissions:{[c]:["*"]}}})).structuredContent?.key;if(!_)throw new Error("No key in response");r(_),Ee("agent_typegen_key_generated",{agent_id:c})}catch{Ee("agent_typegen_key_failed",{agent_id:c}),ae.error("Failed to generate API key")}finally{a(!1)}},m=async()=>{Ee("agent_connect_action",{agent_id:c,action:"typegen_copy_command",has_api_key:!!i}),await navigator.clipboard.writeText(u),h(!0),ae.success("Command copied to clipboard"),setTimeout(()=>h(!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."]})]}),!i&&n.jsxs(Q,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:f,disabled:o,children:[o?n.jsx(Se,{size:14,className:"animate-spin"}):n.jsx(Bl,{size:14}),n.jsx("span",{children:o?"Generating…":"Generate 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:"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:u}),n.jsx(Q,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:m,children:l?n.jsx(fi,{size:12,className:"text-green-600"}):n.jsx(es,{size:12})})]})}),n.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Runtime variables"}),n.jsx(Af,{apiKey:i,agentId:c})]})}function Af(t){const e=F.c(21),{apiKey:s,agentId:i}=t,[r,o]=D.useState(!1),a=window.location.origin,l=s?`MESH_API_KEY=${s}`:"MESH_API_KEY=<api-key>",h=`MESH_BASE_URL=${a}`,c=`${l}
|
|
4
4
|
${h}`;let d;e[0]!==i||e[1]!==s||e[2]!==c?(d=async()=>{Ee("agent_connect_action",{agent_id:i,action:"typegen_copy_env",has_api_key:!!s}),await navigator.clipboard.writeText(c),o(!0),setTimeout(()=>o(!1),2e3)},e[0]=i,e[1]=s,e[2]=c,e[3]=d):d=e[3];const u=d,f=!s;let m;e[4]!==f?(m=te({"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;e[9]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx("br",{}),g=n.jsx("span",{children:h}),e[9]=_,e[10]=g):(_=e[9],g=e[10]);let x;e[11]!==p?(x=n.jsxs("code",{className:"min-w-0 flex-1 font-mono text-xs text-muted-foreground",children:[p,_,g]}),e[11]=p,e[12]=x):x=e[12];let S;e[13]!==r?(S=r?n.jsx(fi,{size:12,className:"text-green-600"}):n.jsx(es,{size:12}),e[13]=r,e[14]=S):S=e[14];let v;e[15]!==u||e[16]!==S?(v=n.jsx(Q,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:u,children:S}),e[15]=u,e[16]=S,e[17]=v):v=e[17];let b;return e[18]!==x||e[19]!==v?(b=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:[x,v]})}),e[18]=x,e[19]=v,e[20]=b):b=e[20],b}function If(t){const e=F.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(D.Suspense,{fallback:i,children:n.jsx(Df,{virtualMcp:s})}),e[1]=s,e[2]=r):r=e[2],r}function Mf(t){const e=F.c(37),{open:s,onOpenChange:i,virtualMcp:r}=t,{org:o}=ke(),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 h=l;let c;e[2]!==r.id||e[3]!==r.title?(c=r.title||`agent-${r.id?.slice(0,8)??"default"}`,e[2]=r.id,e[3]=r.title,e[4]=c):c=e[4];const d=c,u=vl();let f;e[5]!==r.id||e[6]!==h.href?(f=n.jsx(Tf,{url:h.href,agentId:r.id}),e[5]=r.id,e[6]=h.href,e[7]=f):f=e[7];let m,p;e[8]!==d||e[9]!==r.id||e[10]!==h.href?(m=n.jsx(Rf,{url:h.href,serverName:d,agentId:r.id}),p=n.jsx(Pf,{url:h.href,serverName:d,agentId:r.id}),e[8]=d,e[9]=r.id,e[10]=h.href,e[11]=m,e[12]=p):(m=e[11],p=e[12]);let _;e[13]!==f||e[14]!==m||e[15]!==p?(_=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]=_):_=e[16];let g;e[17]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("div",{className:"border-t border-border"}),e[17]=g):g=e[17];let x;e[18]!==r?(x=n.jsx(If,{virtualMcp:r}),e[18]=r,e[19]=x):x=e[19];let S;e[20]!==_||e[21]!==x?(S=n.jsxs("div",{className:"flex flex-col gap-6",children:[_,g,x]}),e[20]=_,e[21]=x,e[22]=S):S=e[22];const v=S;if(u){let k;e[23]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(ou,{className:"mt-4 mb-4 text-base font-semibold",children:"Connect"}),e[23]=k):k=e[23];let j;e[24]!==v?(j=n.jsx(au,{children:n.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-6 [touch-action:pan-y]",children:[k,v]})}),e[24]=v,e[25]=j):j=e[25];let T;return e[26]!==i||e[27]!==s||e[28]!==j?(T=n.jsx(lu,{open:s,onOpenChange:i,children:j}),e[26]=i,e[27]=s,e[28]=j,e[29]=T):T=e[29],T}let b;e[30]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(ai,{children:n.jsx(li,{children:"Connect"})}),e[30]=b):b=e[30];let y;e[31]!==v?(y=n.jsxs(us,{className:"max-h-[80vh] overflow-y-auto sm:max-w-2xl",children:[b,v]}),e[31]=v,e[32]=y):y=e[32];let w;return e[33]!==i||e[34]!==s||e[35]!==y?(w=n.jsx(fs,{open:s,onOpenChange:i,children:y}),e[33]=i,e[34]=s,e[35]=y,e[36]=w):w=e[36],w}const Bf=/^[A-Za-z_][A-Za-z0-9_]*$/;function Lf(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(!Bf.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 Of=/^[A-Za-z0-9_.-]+$/;function $f(t){const e=F.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(lt,{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 h;e[2]!==s||e[3]!==i||e[4]!==o||e[5]!==r?(h=n.jsx(Ff,{control:s,form:i,virtualMcpId:r,orgSlug:o}),e[2]=s,e[3]=i,e[4]=o,e[5]=r,e[6]=h):h=e[6];let c;e[7]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(ys,{className:"h-9 w-full"}),e[7]=c):c=e[7];let d;e[8]!==s||e[9]!==i?(d=n.jsx(It,{fallback:zf,children:n.jsx(D.Suspense,{fallback:c,children:n.jsx(Wf,{control:s,form:i})})}),e[8]=s,e[9]=i,e[10]=d):d=e[10];let u;return e[11]!==h||e[12]!==d?(u=n.jsxs("div",{className:"space-y-2",children:[a,l,h,d]}),e[11]=h,e[12]=d,e[13]=u):u=e[13],u}function zf(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 Ff(t){const e=F.c(24),{control:s,form:i,virtualMcpId:r,orgSlug:o}=t,l=ir.useSession().data?.user?.id,h="metadata.runtime.env",c="metadata.sandboxMap";let d;e[0]!==i?(d=()=>JSON.stringify(Yo(i.getValues(h))),e[0]=i,e[1]=d):d=e[1];const[u,f]=D.useState(d);let m;e[2]!==s?(m={control:s,name:h},e[2]=s,e[3]=m):m=e[3];const p=hl(m);let _;e[4]!==p?(_=JSON.stringify(Yo(p)),e[4]=p,e[5]=_):_=e[5];const g=_,x=g!==u;let S;e[6]!==i?(S=i.getValues(c),e[6]=i,e[7]=S):S=e[7];const v=S;let b;e[8]!==v||e[9]!==l?(b=l?Object.keys(v?.[l]??{}):[],e[8]=v,e[9]=l,e[10]=b):b=e[10];const y=b,w=y.length>0,[k,j]=D.useState(!1);if(!x||!w)return null;let T;e[11]!==g||e[12]!==o||e[13]!==y||e[14]!==r?(T=async()=>{j(!0);const I=await Promise.allSettled(y.map(async M=>{const A=`/api/${encodeURIComponent(o)}/sandbox/${encodeURIComponent(r)}/${encodeURIComponent(M)}/setup/start`,L=await fetch(A,{method:"POST"});if(!L.ok){const H=await L.text().catch(()=>L.statusText);throw new Error(H||L.statusText)}}));j(!1);const E=I.filter(Hf).length;E===0?(f(g),ae.success(y.length===1?"Restarted dev with new env":`Restarted ${y.length} branches with new env`)):ae.error(`Failed to restart ${E} of ${y.length} branch(es)`)},e[11]=g,e[12]=o,e[13]=y,e[14]=r,e[15]=T):T=e[15];const P=T;let R;e[16]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-amber-900 dark:text-amber-200",children:[n.jsx(Xs,{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]=R):R=e[16];let C;e[17]!==k?(C=k?n.jsx(Se,{className:"size-3.5 animate-spin"}):n.jsx(ns,{className:"size-3.5"}),e[17]=k,e[18]=C):C=e[18];const N=k?"Restarting…":"Restart dev";let B;return e[19]!==P||e[20]!==k||e[21]!==C||e[22]!==N?(B=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:[R,n.jsxs(Q,{type:"button",variant:"outline",size:"sm",onClick:P,disabled:k,className:"shrink-0",children:[C,N]})]}),e[19]=P,e[20]=k,e[21]=C,e[22]=N,e[23]=B):B=e[23],B}function Hf(t){return t.status==="rejected"}function Wf(t){const e=F.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=Rh(o),{fields:l,append:h,remove:c}=a;let d;e[2]!==i?(d=(I,E)=>{i.setValue(`${r}.${I}`,E,{shouldDirty:!0,shouldTouch:!0})},e[2]=i,e[3]=d):d=e[3];const u=d,f=mu();let m;if(e[4]!==f){m=new Map;for(const I of f)m.set(I.id,I);e[4]=f,e[5]=m}else m=e[5];const[p,_]=D.useState(null);let g;e[6]!==h?(g=()=>{h({key:"",kind:"literal",value:""})},e[6]=h,e[7]=g):g=e[7];const x=g;let S;e[8]!==h||e[9]!==i?(S=async()=>{let I;try{I=await navigator.clipboard.readText()}catch{ae.error("Couldn't read clipboard");return}if(!I.trim()){ae.error("Clipboard is empty");return}let E;try{E=Lf(I)}catch(z){const V=z;ae.error(V.message);return}const M=Object.entries(E);if(M.length===0){ae.error("Nothing to add");return}const A=i.getValues(r)??[],L=new Set;for(const z of A){const V=(z.key??"").trim();V&&L.add(V)}let H=0,$=0;for(const[z,V]of M){if(L.has(z)){$++;continue}h({key:z,kind:"literal",value:V}),L.add(z),H++}H===0&&$>0?ae.message(`All ${$} key${$===1?"":"s"} already exist`):ae.success($>0?`Added ${H} var${H===1?"":"s"} (${$} already existed)`:`Added ${H} var${H===1?"":"s"}`)},e[8]=h,e[9]=i,e[10]=S):S=e[10];const v=S;let b;if(e[11]!==s||e[12]!==l||e[13]!==i||e[14]!==c||e[15]!==m||e[16]!==f||e[17]!==u){let I;e[19]!==s||e[20]!==i||e[21]!==c||e[22]!==m||e[23]!==f||e[24]!==u?(I=(E,M)=>n.jsx("li",{className:"rounded-md border border-border bg-background",children:n.jsx(Uf,{index:M,control:s,form:i,onUpdateEntry:u,fieldPath:r,secrets:f,secretById:m,onSaveAsSecret:(A,L)=>_({kind:"save-literal",index:M,presetKey:A,presetValue:L}),onCreateNewSecret:A=>_({kind:"create-new",index:M,presetKey:A}),onRemove:()=>c(M)})},E.id),e[19]=s,e[20]=i,e[21]=c,e[22]=m,e[23]=f,e[24]=u,e[25]=I):I=e[25],b=l.map(I),e[11]=s,e[12]=l,e[13]=i,e[14]=c,e[15]=m,e[16]=f,e[17]=u,e[18]=b}else b=e[18];let y;e[26]!==b?(y=n.jsx("ul",{className:"space-y-2",children:b}),e[26]=b,e[27]=y):y=e[27];let w;e[28]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(Ut,{className:"size-3.5"}),e[28]=w):w=e[28];let k;e[29]!==x?(k=n.jsxs(Q,{type:"button",variant:"outline",size:"sm",onClick:x,className:"flex-1",children:[w,"Add env var"]}),e[29]=x,e[30]=k):k=e[30];let j;e[31]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(kd,{className:"size-3.5"}),e[31]=j):j=e[31];let T;e[32]!==v?(T=n.jsx(Te,{asChild:!0,children:n.jsxs(Q,{type:"button",variant:"outline",size:"sm",onClick:v,"aria-label":"Paste .env",children:[j,"Paste .env"]})}),e[32]=v,e[33]=T):T=e[33];let P;e[34]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx(Re,{children:"Read a .env blob from the clipboard. Each pair is staged as a literal — save individual rows as secrets after."}),e[34]=P):P=e[34];let R;e[35]!==T?(R=n.jsxs(Pe,{children:[T,P]}),e[35]=T,e[36]=R):R=e[36];let C;e[37]!==R||e[38]!==k?(C=n.jsxs("div",{className:"flex items-center gap-2",children:[k,R]}),e[37]=R,e[38]=k,e[39]=C):C=e[39];let N;e[40]!==p||e[41]!==i||e[42]!==u?(N=p!==null?n.jsx(qf,{mode:p,onClose:()=>_(null),onSaved:I=>{const E=i.getValues(`${r}.${p.index}.key`)?.trim()??"";u(p.index,{key:E,kind:"secret",secretId:I}),_(null)}}):null,e[40]=p,e[41]=i,e[42]=u,e[43]=N):N=e[43];let B;return e[44]!==C||e[45]!==N||e[46]!==y?(B=n.jsxs("div",{className:"space-y-2",children:[y,C,N]}),e[44]=C,e[45]=N,e[46]=y,e[47]=B):B=e[47],B}function Uf(t){const e=F.c(55),{index:s,control:i,form:r,onUpdateEntry:o,fieldPath:a,secrets:l,secretById:h,onSaveAsSecret:c,onCreateNewSecret:d,onRemove:u}=t,f=`${a}.${s}.key`,m=`${a}.${s}.value`,p=`${a}.${s}.secretId`,_=`${a}.${s}.kind`;let g;e[0]!==i||e[1]!==_?(g={control:i,name:_},e[0]=i,e[1]=_,e[2]=g):g=e[2];const S=hl(g)==="secret"?"secret":"literal";let v;e[3]!==r||e[4]!==s||e[5]!==f||e[6]!==c||e[7]!==o||e[8]!==m?(v=H=>{const $=r.getValues(f)?.trim()??"";if(H==="literal"){o(s,{key:$,kind:"literal",value:""});return}const z=r.getValues(m)??"";if(z.length>0){c($,z);return}o(s,{key:$,kind:"secret",secretId:""})},e[3]=r,e[4]=s,e[5]=f,e[6]=c,e[7]=o,e[8]=m,e[9]=v):v=e[9];const b=v;let y;e[10]!==s?(y=H=>{const{field:$}=H,z=($.value??"").trim(),V=z.length>0&&!rr.test(z);return n.jsxs("div",{className:"space-y-1",children:[n.jsx(it,{...$,value:$.value??"",placeholder:"KEY",spellCheck:!1,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",className:te("font-mono",V&&"border-destructive focus-visible:ring-destructive"),"aria-invalid":V,"aria-label":`Env var ${s+1} key`,onBlur:q=>{const ee=q.target.value.trim();$.onChange(ee),$.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]=y):y=e[11];let w;e[12]!==i||e[13]!==f||e[14]!==y?(w=n.jsx("div",{className:"flex-1 min-w-0",children:n.jsx(at,{control:i,name:f,render:y})}),e[12]=i,e[13]=f,e[14]=y,e[15]=w):w=e[15];let k;e[16]!==b?(k=H=>b(H),e[16]=b,e[17]=k):k=e[17];let j;e[18]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(wt,{className:"h-9 w-[110px]",children:n.jsx(Ct,{})}),e[18]=j):j=e[18];let T;e[19]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx(Qe,{value:"literal",children:n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx(Bl,{className:"size-3.5"}),"Literal"]})}),e[19]=T):T=e[19];let P;e[20]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsxs(kt,{children:[T,n.jsx(Qe,{value:"secret",children:n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx(du,{className:"size-3.5"}),"Secret"]})})]}),e[20]=P):P=e[20];let R;e[21]!==S||e[22]!==k?(R=n.jsx("div",{className:"shrink-0",children:n.jsxs(yt,{value:S,onValueChange:k,children:[j,P]})}),e[21]=S,e[22]=k,e[23]=R):R=e[23];let C;e[24]!==i||e[25]!==r||e[26]!==s||e[27]!==f||e[28]!==S||e[29]!==d||e[30]!==h||e[31]!==p||e[32]!==l||e[33]!==m?(C=n.jsx("div",{className:"flex flex-[2] min-w-0 items-center gap-1",children:S==="literal"?n.jsx(at,{control:i,name:m,render:H=>{const{field:$}=H;return n.jsx(it,{...$,value:$.value??"",type:"password",placeholder:"value",spellCheck:!1,autoComplete:"off",className:"font-mono","aria-label":`Env var ${s+1} value`,onBlur:z=>{$.onChange(z.target.value),$.onBlur()}})}}):n.jsxs(n.Fragment,{children:[n.jsx(at,{control:i,name:p,render:H=>{const{field:$}=H;return n.jsxs(yt,{value:$.value||"",onValueChange:z=>$.onChange(z),children:[n.jsx(wt,{className:te("h-9 w-full",!$.value&&"text-muted-foreground"),children:n.jsx(Ct,{placeholder:"Pick a secret…",children:n.jsx(Vf,{field:$,secretById:h})})}),n.jsx(kt,{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(Kf)})]})}}),n.jsxs(Pe,{children:[n.jsx(Te,{asChild:!0,children:n.jsx(Q,{type:"button",variant:"ghost",size:"icon","aria-label":"Create new secret",onClick:()=>{const H=r.getValues(f)?.trim()??"";d(H)},children:n.jsx(Ut,{className:"size-3.5"})})}),n.jsx(Re,{children:"Create new secret"})]})]})}),e[24]=i,e[25]=r,e[26]=s,e[27]=f,e[28]=S,e[29]=d,e[30]=h,e[31]=p,e[32]=l,e[33]=m,e[34]=C):C=e[34];let N;e[35]!==r||e[36]!==f||e[37]!==S||e[38]!==c||e[39]!==m?(N=S==="literal"?n.jsxs(Pe,{children:[n.jsx(Te,{asChild:!0,children:n.jsx(Q,{type:"button",variant:"ghost",size:"icon","aria-label":"Save value as secret",onClick:()=>{const H=r.getValues(f)?.trim()??"",$=r.getValues(m)??"";c(H,$)},children:n.jsx(jd,{className:"size-3.5"})})}),n.jsx(Re,{children:"Save value as secret"})]}):null,e[35]=r,e[36]=f,e[37]=S,e[38]=c,e[39]=m,e[40]=N):N=e[40];let B;e[41]===Symbol.for("react.memo_cache_sentinel")?(B=n.jsx(Yi,{className:"size-3.5"}),e[41]=B):B=e[41];let I;e[42]!==u?(I=n.jsx(Te,{asChild:!0,children:n.jsx(Q,{type:"button",variant:"ghost",size:"icon","aria-label":"Remove env var",onClick:u,children:B})}),e[42]=u,e[43]=I):I=e[43];let E;e[44]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx(Re,{children:"Remove"}),e[44]=E):E=e[44];let M;e[45]!==I?(M=n.jsxs(Pe,{children:[I,E]}),e[45]=I,e[46]=M):M=e[46];let A;e[47]!==N||e[48]!==M?(A=n.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[N,M]}),e[47]=N,e[48]=M,e[49]=A):A=e[49];let L;return e[50]!==C||e[51]!==A||e[52]!==w||e[53]!==R?(L=n.jsxs("div",{className:"flex flex-col gap-2 p-2 sm:flex-row sm:items-center",children:[w,R,C,A]}),e[50]=C,e[51]=A,e[52]=w,e[53]=R,e[54]=L):L=e[54],L}function Kf(t){return n.jsx(Qe,{value:t.id,children:n.jsxs("span",{className:"inline-flex items-center gap-2",children:[n.jsx(Fl,{scope:t.scope}),n.jsx("span",{className:"font-mono",children:t.name})]})},t.id)}function Vf(t){const e=F.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 d;return e[3]!==r?(d=n.jsxs("span",{className:"text-destructive",children:["Missing secret (",r,")"]}),e[3]=r,e[4]=d):d=e[4],d}let l;e[5]!==a.scope?(l=n.jsx(Fl,{scope:a.scope}),e[5]=a.scope,e[6]=l):l=e[6];let h;e[7]!==a.name?(h=n.jsx("span",{className:"truncate font-mono",children:a.name}),e[7]=a.name,e[8]=h):h=e[8];let c;return e[9]!==l||e[10]!==h?(c=n.jsxs("span",{className:"inline-flex items-center gap-1.5 truncate",children:[l,h]}),e[9]=l,e[10]=h,e[11]=c):c=e[11],c}function Fl(t){const e=F.c(2),{scope:s}=t,i=s==="user"?uu:fu;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 qf({mode:t,onClose:e,onSaved:s}){const i=t.kind==="save-literal"?t.presetValue:"",r=t.presetKey,[o,a]=D.useState(()=>Gf(r)),[l,h]=D.useState("organization"),[c,d]=D.useState(i),[u,f]=D.useState(""),m=pu(),p=o.trim(),_=c.length>0&&p.length>0&&Of.test(p),g=async v=>{if(v.preventDefault(),!!_)try{const b=await m.mutateAsync({scope:l,name:p,value:c,description:u.trim()||void 0});ae.success(`Saved secret "${b.name}"`),s(b.id)}catch(b){ae.error(b instanceof Error?b.message:"Failed to save")}},x=t.kind==="save-literal"?"Save value as secret":"Create new secret",S=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(fs,{open:!0,onOpenChange:v=>{v||e()},children:n.jsxs(us,{className:"sm:max-w-md",children:[n.jsxs(ai,{children:[n.jsx(li,{children:x}),n.jsx(Pl,{children:S})]}),n.jsxs("form",{onSubmit:g,className:"space-y-4",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(lt,{htmlFor:"save-secret-scope",children:"Scope"}),n.jsxs(yt,{value:l,onValueChange:v=>h(v),children:[n.jsx(wt,{id:"save-secret-scope",children:n.jsx(Ct,{})}),n.jsxs(kt,{children:[n.jsx(Qe,{value:"organization",children:"Organization — visible to all members"}),n.jsx(Qe,{value:"user",children:"Private — only visible to me"})]})]})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(lt,{htmlFor:"save-secret-name",children:"Name"}),n.jsx(it,{id:"save-secret-name",value:o,onChange:v=>a(v.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(lt,{htmlFor:"save-secret-value",children:"Value"}),n.jsx(it,{id:"save-secret-value",type:"password",value:c,onChange:v=>d(v.target.value),placeholder:"secret value",autoComplete:"new-password",required:!0})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(lt,{htmlFor:"save-secret-description",children:"Description (optional)"}),n.jsx(Gi,{id:"save-secret-description",value:u,onChange:v=>f(v.target.value),rows:2,placeholder:"What is this secret used for?"})]}),n.jsxs(dr,{children:[n.jsx(Q,{type:"button",variant:"outline",onClick:e,disabled:m.isPending,children:"Cancel"}),n.jsx(Q,{type:"submit",disabled:!_||m.isPending,children:m.isPending?"Saving…":"Save secret"})]})]})]})})}function Yo(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||!rr.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 Gf(t){const e=t.trim();return e&&rr.test(e)?e:""}function Yf(t){const e=F.c(12),{repo:s,className:i}=t;let r;e[0]!==i?(r=te("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(lt,{children:"Repository"}),e[2]=o):o=e[2];let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(_u,{size:20,className:"shrink-0 text-foreground/60"}),e[3]=a):a=e[3];let l;e[4]!==s?(l=n.jsx(Te,{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 h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Re,{children:"The connected GitHub repository for this agent. Manage in Connections."}),e[6]=h):h=e[6];let c;e[7]!==l?(c=n.jsxs(Pe,{children:[l,h]}),e[7]=l,e[8]=c):c=e[8];let d;return e[9]!==r||e[10]!==c?(d=n.jsxs("div",{className:r,children:[o,c]}),e[9]=r,e[10]=c,e[11]=d):d=e[11],d}const Xf={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 Jf(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 Zf=Object.keys(Xf),Dr="__none__";function Qf(t){const e=F.c(20),{control:s}=t,i=D.useRef(null);let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(lt,{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(at,{control:s,name:"metadata.runtime.selected",render:tm})]}),e[1]=s,e[2]=o):o=e[2];let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(lt,{htmlFor:"runtime-path",children:"Package path"}),e[3]=a):a=e[3];let l;e[4]!==s?(l=n.jsx(at,{control:s,name:"metadata.runtime.path",render:em}),e[4]=s,e[5]=l):l=e[5];let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=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]=h):h=e[6];let c;e[7]!==l?(c=n.jsxs("div",{className:"space-y-2",children:[a,l,h]}),e[7]=l,e[8]=c):c=e[8];let d;e[9]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(lt,{htmlFor:"runtime-port",children:"Dev server port"}),e[9]=d):d=e[9];let u;e[10]===Symbol.for("react.memo_cache_sentinel")?(u=g=>{const{field:x}=g;return n.jsx(it,{ref:i,id:"runtime-port",inputMode:"numeric",placeholder:"Auto",defaultValue:x.value??"",onBlur:S=>{const v=Jf(S.target.value);v.ok?x.onChange(v.value):i.current&&(i.current.value=x.value??"")}})},e[10]=u):u=e[10];let f;e[11]!==s?(f=n.jsx(at,{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:[d,f,m]}),e[14]=f,e[15]=p):p=e[15];let _;return e[16]!==p||e[17]!==o||e[18]!==c?(_=n.jsxs("div",{className:"space-y-5",children:[o,c,p]}),e[16]=p,e[17]=o,e[18]=c,e[19]=_):_=e[19],_}function em(t){const{field:e}=t;return n.jsx(it,{id:"runtime-path",placeholder:".",defaultValue:e.value??"",onBlur:s=>{const i=s.target.value.trim();e.onChange(i===""?null:i)}})}function tm(t){const{field:e}=t;return n.jsxs(yt,{value:e.value??Dr,onValueChange:s=>e.onChange(s===Dr?null:s),children:[n.jsx(wt,{id:"runtime-pm",children:n.jsx(Ct,{placeholder:"Auto-detect"})}),n.jsxs(kt,{children:[n.jsx(Qe,{value:Dr,children:"Auto-detect"}),Zf.map(sm)]})]})}function sm(t){return n.jsx(Qe,{value:t,children:t},t)}function im(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 rm(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 nm(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||!rr.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 om(t){const e=F.c(22),{connection_id:s,usedConnectionIds:i,onOpenSettings:r,onRemove:o,onAuthenticate:a,onSwitchInstance:l,onNewInstance:h}=t,c=no(s),{org:d}=ke();if(!c)return null;let u;e[0]!==c?(u=Gd(c),e[0]=c,e[1]=u):u=e[1];const f=u;let m;e[2]!==s?(m=n.jsx(hm,{connection_id:s}),e[2]=s,e[3]=m):m=e[3];let p;e[4]!==c.app_name||e[5]!==c.connection_type||e[6]!==c.description||e[7]!==c.icon||e[8]!==c.title||e[9]!==s||e[10]!==a||e[11]!==h||e[12]!==r||e[13]!==o||e[14]!==l||e[15]!==d.slug||e[16]!==f||e[17]!==i?(p=n.jsx(cm,{connection_id:s,connectionTitle:c.title,connectionDescription:c.description,connectionIcon:c.icon,connectionType:c.connection_type,slug:f,orgSlug:d.slug,appName:c.app_name,usedConnectionIds:i,onOpenSettings:r,onRemove:o,onAuthenticate:a,onSwitchInstance:l,onNewInstance:h}),e[4]=c.app_name,e[5]=c.connection_type,e[6]=c.description,e[7]=c.icon,e[8]=c.title,e[9]=s,e[10]=a,e[11]=h,e[12]=r,e[13]=o,e[14]=l,e[15]=d.slug,e[16]=f,e[17]=i,e[18]=p):p=e[18];let _;return e[19]!==m||e[20]!==p?(_=n.jsx(D.Suspense,{fallback:m,children:p}),e[19]=m,e[20]=p,e[21]=_):_=e[21],_}const Xo="__new_instance__";async function am(t,e){const s=t?.idToken??null;if(s){const r=Jo(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 Jo(e)}function Jo(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 lm(t){const e=F.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 h=hr(l);if(h.length<=1)return null;let c;e[2]!==i||e[3]!==a||e[4]!==o?(c=_=>{_===Xo?a?.():o(i,_)},e[2]=i,e[3]=a,e[4]=o,e[5]=c):c=e[5];let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(wt,{size:"sm",className:"w-auto text-xs gap-1 px-2 shadow-none",children:n.jsx(Ct,{})}),e[6]=d):d=e[6];let u;if(e[7]!==i||e[8]!==h||e[9]!==r){let _;e[11]!==i||e[12]!==r?(_=g=>n.jsx(Qe,{value:g.id,className:"text-xs",disabled:g.id!==i&&r.has(g.id),children:g.title},g.id),e[11]=i,e[12]=r,e[13]=_):_=e[13],u=h.map(_),e[7]=i,e[8]=h,e[9]=r,e[10]=u}else u=e[10];let f;e[14]!==a?(f=a&&n.jsx(Qe,{value:Xo,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(kt,{children:[u,f]}),e[16]=u,e[17]=f,e[18]=m):m=e[18];let p;return e[19]!==i||e[20]!==c||e[21]!==m?(p=n.jsxs(yt,{value:i,onValueChange:c,children:[d,m]}),e[19]=i,e[20]=c,e[21]=m,e[22]=p):p=e[22],p}function cm(t){const e=F.c(55),{connection_id:s,connectionTitle:i,connectionDescription:r,connectionIcon:o,connectionType:a,slug:l,orgSlug:h,appName:c,usedConnectionIds:d,onOpenSettings:u,onRemove:f,onAuthenticate:m,onSwitchInstance:p,onNewInstance:_}=t;let g;e[0]!==s?(g={connectionId:s},e[0]=s,e[1]=g):g=e[1];const x=Tl(g),v=!(a==="VIRTUAL")&&x.supportsOAuth&&!x.isAuthenticated,b=v?"border-destructive/50 bg-destructive/5":"border-border";let y;e[2]!==b?(y=te("rounded-xl border overflow-hidden transition-colors",b),e[2]=b,e[3]=y):y=e[3];let w;e[4]!==h||e[5]!==l?(w={org:h,appSlug:l},e[4]=h,e[5]=l,e[6]=w):w=e[6];let k;e[7]!==o||e[8]!==i?(k=n.jsx(cs,{icon:o,name:i,size:"sm",className:"shrink-0"}),e[7]=o,e[8]=i,e[9]=k):k=e[9];let j;e[10]!==i?(j=n.jsx("p",{className:"text-sm font-medium truncate",children:i}),e[10]=i,e[11]=j):j=e[11];let T;e[12]!==r||e[13]!==v?(T=v?n.jsx("span",{className:"text-xs text-destructive font-medium",children:"Needs authorization"}):r&&n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r}),e[12]=r,e[13]=v,e[14]=T):T=e[14];let P;e[15]!==j||e[16]!==T?(P=n.jsxs("div",{className:"flex-1 min-w-0",children:[j,T]}),e[15]=j,e[16]=T,e[17]=P):P=e[17];let R;e[18]!==s||e[19]!==v||e[20]!==m?(R=v?n.jsx(Q,{variant:"outline",size:"sm",className:"h-7 text-xs shrink-0",onClick:ee=>{ee.preventDefault(),ee.stopPropagation(),m(s)},children:"Authorize"}):n.jsxs(Pe,{delayDuration:0,children:[n.jsx(Te,{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(Yd,{size:16})})}),n.jsx(Re,{side:"bottom",children:"Connection settings"})]}),e[18]=s,e[19]=v,e[20]=m,e[21]=R):R=e[21];let C;e[22]!==w||e[23]!==k||e[24]!==P||e[25]!==R?(C=n.jsxs(Ah,{to:"/$org/settings/connections/$appSlug",params:w,className:"flex items-center gap-3 px-4 py-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[k,P,R]}),e[22]=w,e[23]=k,e[24]=P,e[25]=R,e[26]=C):C=e[26];let N;e[27]!==c||e[28]!==s||e[29]!==_||e[30]!==p||e[31]!==d?(N=c&&n.jsx(lm,{appName:c,connectionId:s,usedConnectionIds:d,onSwitchInstance:p,onNewInstance:_}),e[27]=c,e[28]=s,e[29]=_,e[30]=p,e[31]=d,e[32]=N):N=e[32];let B;e[33]===Symbol.for("react.memo_cache_sentinel")?(B=n.jsx(Ed,{size:13}),e[33]=B):B=e[33];let I;e[34]!==u?(I=n.jsx(Te,{asChild:!0,children:n.jsx(Q,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:u,"aria-label":"Configure resources",children:B})}),e[34]=u,e[35]=I):I=e[35];let E;e[36]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx(Re,{side:"bottom",children:"Configure resources"}),e[36]=E):E=e[36];let M;e[37]!==I?(M=n.jsxs(Pe,{delayDuration:0,children:[I,E]}),e[37]=I,e[38]=M):M=e[38];let A;e[39]===Symbol.for("react.memo_cache_sentinel")?(A=n.jsx(ks,{size:13}),e[39]=A):A=e[39];let L;e[40]!==f?(L=n.jsx(Te,{asChild:!0,children:n.jsx(Q,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:f,"aria-label":"Remove connection",children:A})}),e[40]=f,e[41]=L):L=e[41];let H;e[42]===Symbol.for("react.memo_cache_sentinel")?(H=n.jsx(Re,{side:"bottom",children:"Remove"}),e[42]=H):H=e[42];let $;e[43]!==L?($=n.jsxs(Pe,{delayDuration:0,children:[L,H]}),e[43]=L,e[44]=$):$=e[44];let z;e[45]!==M||e[46]!==$?(z=n.jsxs("div",{className:"flex items-center gap-0.5 ml-auto",children:[M,$]}),e[45]=M,e[46]=$,e[47]=z):z=e[47];let V;e[48]!==N||e[49]!==z?(V=n.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-t border-border bg-muted/25",children:[N,z]}),e[48]=N,e[49]=z,e[50]=V):V=e[50];let q;return e[51]!==C||e[52]!==V||e[53]!==y?(q=n.jsxs("div",{className:y,children:[C,V]}),e[51]=C,e[52]=V,e[53]=y,e[54]=q):q=e[54],q}function hm(t){const e=F.c(17),{connection_id:s}=t,i=no(s);if(!i){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(Hl,{}),e[0]=u):u=e[0],u}let r;e[1]!==i.icon||e[2]!==i.title?(r=n.jsx(cs,{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 h;e[11]!==r||e[12]!==l?(h=n.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[r,l]}),e[11]=r,e[12]=l,e[13]=h):h=e[13];let c;e[14]===Symbol.for("react.memo_cache_sentinel")?(c=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]=c):c=e[14];let d;return e[15]!==h?(d=n.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[h,c]}),e[15]=h,e[16]=d):d=e[16],d}function Hl(){const t=F.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 dm({virtualMcpId:t,form:e,flushAndSave:s}){const{org:i}=ke(),r=Je({connectionId:Ns,orgId:i.id,orgSlug:i.slug}),o=Mt(t),a=(o?.connections??[]).map(E=>E.connection_id).sort(),{data:l}=nr({queryKey:rs.projectConnectionDetails(t,a),enabled:a.length>0,queryFn:async()=>await Promise.all(a.map(async M=>{try{const A=await r.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:M}}),{item:L}=qd(A),H=(L?.tools??[]).flatMap($=>{const z=Kd($._meta);return z?[{name:$.name,description:$.description,resourceUri:z}]:[]});return{fetchOk:!0,id:M,title:L?.title??M,icon:L?.icon??null,uiTools:H}}catch{return{fetchOk:!1,id:M,title:M,icon:null,uiTools:[]}}}))}),h=(l??[]).filter(E=>E.uiTools.length>0),c=new Set(id),d=e.watch("metadata.ui.pinnedViews")??[],u=e.watch("metadata.ui.layout")??null,f=u?.defaultMainView??null,m=u?.chatDefaultOpen??!1,p=e.watch("metadata.ui.homeTile")??null,_=!f||f.type==="chat"?"chat":f.type==="instructions"||f.type==="connections"||f.type==="layout"?"settings":c.has(f.type)?f.type:`${f.type}:${f.id??""}:${f.toolName??""}`,g=E=>{const[M,A,L]=E.split(":");return M?M==="chat"?{type:M}:c.has(M)?{type:M}:M==="ext-apps"&&A?{type:"ext-apps",id:A,toolName:L||void 0}:null:null},x=E=>{e.setValue("metadata.ui.pinnedViews",E,{shouldDirty:!0})},S=E=>{e.setValue("metadata.ui.layout",{...u,...E},{shouldDirty:!0})},v=D.useRef(!1);if(l&&l.length>0&&!v.current){v.current=!0;const E=new Set((l??[]).filter(L=>L.fetchOk).map(L=>L.id)),M=new Set(h.flatMap(L=>L.uiTools.map(H=>`${L.id}:${H.name}`))),A=d.filter(L=>!E.has(L.connectionId)||M.has(`${L.connectionId}:${L.toolName}`));A.length!==d.length&&(x(A),f?.type==="ext-apps"&&!A.some(L=>L.connectionId===f.id&&L.toolName===f.toolName)&&S({defaultMainView:{type:"chat"}}))}const b=(E,M)=>{if(d.some(L=>L.connectionId===E&&L.toolName===M)){const L=d.filter($=>!($.connectionId===E&&$.toolName===M));x(L);const H=`ext-apps:${E}:${M}`;_===H&&S({defaultMainView:{type:"chat"}})}else x([...d,{connectionId:E,toolName:M,label:Nr(M),icon:null}]);s()},y=(E,M,A)=>{x(d.map(L=>L.connectionId===E&&L.toolName===M?{...L,label:A}:L))},w=()=>{s()},k=(E,M,A)=>{x(d.map(L=>L.connectionId===E&&L.toolName===M?{...L,icon:A}:L)),s()},j=E=>{S({defaultMainView:g(E)}),s()},T=h.flatMap(E=>E.uiTools.map(M=>({resourceUri:M.resourceUri,connectionId:E.id,label:`${E.title} — ${Nr(M.name)}`}))),P=E=>{if(E==="none")e.setValue("metadata.ui.homeTile",null,{shouldDirty:!0});else{const M=T.find(A=>A.resourceUri===E);if(!M)return;e.setValue("metadata.ui.homeTile",{resourceUri:M.resourceUri,connectionId:M.connectionId},{shouldDirty:!0})}s()},R=a.length===0,C=l&&h.length===0,N=ar(o?.metadata),B=[{value:"chat",label:"Chat"},{value:"settings",label:"Settings"},{value:"automations",label:"Automations"}];N&&B.push({value:"preview",label:"Preview"});for(const E of d)B.push({value:`ext-apps:${E.connectionId}:${E.toolName}`,label:E.label||E.toolName});const I=h.length>0||R||C;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(Dl,{className:"p-6 gap-5",children:[n.jsxs(rn,{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(lt,{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(yt,{value:_,onValueChange:j,children:[n.jsx(wt,{className:"w-44 h-8 text-sm capitalize shrink-0",children:n.jsx(Ct,{})}),n.jsx(kt,{children:B.map(E=>n.jsx(Qe,{value:E.value,className:"capitalize",children:E.label},E.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(lt,{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(Te,{asChild:!0,children:n.jsx("span",{className:"shrink-0",children:n.jsx(nn,{checked:_==="chat"?!0:m,disabled:_==="chat",onCheckedChange:E=>{S({chatDefaultOpen:E}),s()}})})}),_==="chat"&&n.jsx(Re,{side:"top",children:"Chat is always shown when it is the default view"})]})]}),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(lt,{className:"font-normal text-foreground",children:"Home tile"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Render an interactive tool UI inside this agent's tile on the org home page. Only takes effect when the agent is in the org's default home agents."})]}),n.jsxs(yt,{value:p?.resourceUri??"none",onValueChange:P,disabled:T.length===0,children:[n.jsx(wt,{className:"w-56 h-8 text-sm shrink-0",children:n.jsx(Ct,{placeholder:T.length===0?"No interactive tools":"None"})}),n.jsxs(kt,{children:[n.jsx(Qe,{value:"none",children:"None"}),T.map(E=>n.jsx(Qe,{value:E.resourceUri,children:E.label},E.resourceUri))]})]})]})]}),I&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"border-t border-border -mx-6"}),n.jsxs(rn,{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(lt,{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."})]})}),R&&n.jsx("p",{className:"text-xs text-muted-foreground",children:"Add a connection above to configure pinned views."}),C&&!R&&n.jsx("p",{className:"text-xs text-muted-foreground",children:"None of the connected servers expose interactive tools."}),h.length>0&&n.jsx("div",{className:"space-y-4 pt-1",children:h.map((E,M)=>n.jsxs("div",{children:[M>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(cs,{icon:E.icon,name:E.title,size:"xs",className:"shrink-0"}),n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:E.title})]}),n.jsx("div",{className:"space-y-1.5",children:E.uiTools.map(A=>{const L=d.some($=>$.connectionId===E.id&&$.toolName===A.name),H=d.find($=>$.connectionId===E.id&&$.toolName===A.name);return n.jsxs("div",{className:te("flex items-center justify-between gap-3 px-3 py-2 rounded-lg border transition-colors",L?"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(uf,{value:H?.icon??null,onChange:$=>k(E.id,A.name,$),disabled:!L}),n.jsx(it,{value:L&&H?H.label:Nr(A.name),onChange:$=>y(E.id,A.name,$.target.value),onBlur:w,className:"h-7 text-sm w-40",disabled:!L,readOnly:!L})]}),n.jsx(nn,{checked:L,onCheckedChange:()=>b(E.id,A.name)})]},A.name)})})]},E.id))})]})]})]})]})}function um({virtualMcp:t,hideOwnTitle:e}){const{org:s}=ke(),i=Kh(),r=Hd(),o=Vn(),a=Je({connectionId:Ns,orgId:s.id,orgSlug:s.slug}),l=dl({resolver:Ph(Nf),defaultValues:t}),h=l.watch("connections"),c=_l(t),d=oi(t),u=d?{owner:d.owner,name:d.name,url:d.url}:null,[f,m]=D.useReducer(im,{shareDialogOpen:!1,addDialogOpen:!1,settingsDialogOpen:!1,settingsConnectionId:null}),[p,_]=D.useState(!1),[g,x]=D.useState(!1),{createNewTask:S,setChatOpen:v}=eo(),{sendMessage:b}=hs(),y=async()=>{if(g)return;const O=l.getValues("metadata.instructions");if(O?.trim()){x(!0);try{R(),Ee("agent_instructions_improve_clicked",{agent_id:t.id,instructions_length:O.length}),v(!0),await b({tiptapDoc:zl({managerAgentId:pl.AGENT_MANAGER(s.id),managerName:"Agent Manager",kind:"agent",id:t.id,instructions:O})})}finally{x(!1)}}},w=()=>{R(),Ee("agent_test_clicked",{agent_id:t.id}),S()},[k,j]=D.useReducer(rm,null),T=()=>{k!==null&&(Ee("agent_updated",{agent_id:t.id,fields:Array.from(k.fields),instructions_length:k.instructionsLength,save_count:k.saveCount,edit_duration_ms:Date.now()-k.start}),j({type:"reset"}))},{schedule:P,flush:R}=Xi({delayMs:3e4,save:async()=>T()}),C=async()=>{const O=Object.keys(l.control._formState.dirtyFields);if(O.length===0)return;const X=O.includes("metadata"),J=l.getValues();l.reset(J,{keepValues:!0});const ie=nm(J);await i.update.mutateAsync({id:t.id,data:ie}),j({type:"accumulate",now:Date.now(),fields:O,instructionsLength:X?J.metadata?.instructions?.length??0:null}),P()},{schedule:N,flush:B}=Xi({save:C});D.useEffect(()=>{const O=l.watch(()=>N());return()=>O.unsubscribe()},[]);const I=()=>{Ee("connections_dialog_opened",{source:"agent_settings",mode:"add"}),m({type:"SET_ADD_DIALOG_OPEN",payload:!0})},E=async O=>{const X=l.getValues("connections");if(X.some(oe=>oe.connection_id===O))return;l.setValue("connections",[...X,{connection_id:O,selected_tools:Pr.tools,selected_resources:Pr.resources,selected_prompts:Pr.prompts}],{shouldDirty:!0}),m({type:"SET_ADD_DIALOG_OPEN",payload:!1});const J=new URL(`/api/${s.slug}/mcp/${O}`,window.location.origin),ie=await Bo({url:J.href,token:null,orgId:s.id});ie.supportsOAuth&&!ie.isAuthenticated&&await $(O)},M=O=>{const J=l.getValues("connections").filter(ie=>ie.connection_id!==O);l.setValue("connections",J,{shouldDirty:!0})},A=(O,X)=>{const J=l.getValues("connections");if(J.some(ie=>ie.connection_id===X)){ae.error("This instance is already added to the agent");return}l.setValue("connections",J.map(ie=>ie.connection_id===O?{...ie,connection_id:X}:ie),{shouldDirty:!0})},L=async O=>{if(l.getValues("connections").find(J=>J.connection_id===O))try{const J=await a.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:O}}),{item:ie}=J.structuredContent??{};if(!ie)return;const oe=ie.title.replace(/\s*\(.*?\)\s*$/,""),W=Wd("conn"),ne=`${oe} (${Date.now().toString(36).slice(-4)})`;await r.create.mutateAsync({id:W,title:ne,description:ie.description??null,connection_type:ie.connection_type,connection_url:ie.connection_url??null,connection_token:null,icon:ie.icon??null,app_name:ie.app_name??null,app_id:ie.app_id??null,connection_headers:ie.connection_headers??null});const me=new URL(`/api/${s.slug}/mcp/${W}`,window.location.origin),_e=await Bo({url:me.href,token:null,orgId:s.id});if(_e.supportsOAuth&&!_e.isAuthenticated){const pe=await $(W);if(!pe){await r.delete.mutateAsync(W);return}await r.update.mutateAsync({id:W,data:{title:`${oe} (${pe})`}})}A(O,W),ae.success("New instance created")}catch(J){console.error("Failed to create instance:",J),ae.error("Failed to create instance")}},H=O=>{m({type:"OPEN_SETTINGS",payload:O})},$=async O=>{const{token:X,tokenInfo:J,error:ie}=await Dh({connectionId:O,orgSlug:s.slug,scope:"offline_access"});if(ie||!X)return ae.error(`Authentication failed: ${ie}`),null;if(J)try{const W=await fetch(`/api/${s.slug}/connections/${O}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:J.accessToken,refreshToken:J.refreshToken,expiresIn:J.expiresIn,scope:J.scope,clientId:J.clientId,clientSecret:J.clientSecret,tokenEndpoint:J.tokenEndpoint})});if(!W.ok)console.error("Failed to save OAuth token:",await W.text()),await r.update.mutateAsync({id:O,data:{connection_token:X}});else try{await r.update.mutateAsync({id:O,data:{}})}catch(ne){console.warn("Failed to refresh connection tools after OAuth:",ne)}}catch(W){console.error("Error saving OAuth token:",W),await r.update.mutateAsync({id:O,data:{connection_token:X}})}else await r.update.mutateAsync({id:O,data:{connection_token:X}});const oe=new URL(`/api/${s.slug}/mcp/${O}`,window.location.origin);return await o.invalidateQueries({queryKey:rs.isMCPAuthenticated(oe.href,null)}),ae.success("Authentication successful"),am(J,X)},z=()=>{const O=l.getValues("metadata.instructions")??"",X=`<role>
|
|
5
5
|
Define who this agent is and what it specializes in.
|
|
@@ -283,7 +283,7 @@ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){t
|
|
|
283
283
|
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(t){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Co&&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=Na(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=wo(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,-$r),$r),e/=$r,e/Math.abs(e)+Math.round(e*(_v-1)))}shouldForceSelection(t){return er?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(),gv)}_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&&!(er&&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<vv&&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=lv(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]),h=l,c=t[0]-l,d=0,u=0,f=0,m=0;if(a.charAt(l)===" "){for(;l>0&&a.charAt(l-1)===" ";)l--;for(;h<a.length&&a.charAt(h+1)===" ";)h++}else{let g=t[0],x=t[0];o.getWidth(g)===0&&(d++,g--),o.getWidth(x)===2&&(u++,x++);let S=o.getString(x).length;for(S>1&&(m+=S-1,h+=S-1);g>0&&l>0&&!this._isCharWordSeparator(o.loadCell(g-1,this._workCell));){o.loadCell(g-1,this._workCell);let v=this._workCell.getChars().length;this._workCell.getWidth()===0?(d++,g--):v>1&&(f+=v-1,l-=v-1),l--,g--}for(;x<o.length&&h+1<a.length&&!this._isCharWordSeparator(o.loadCell(x+1,this._workCell));){o.loadCell(x+1,this._workCell);let v=this._workCell.getChars().length;this._workCell.getWidth()===2?(u++,x++):v>1&&(m+=v-1,h+=v-1),h++,x++}}h++;let p=l+c-d+f,_=Math.min(this._bufferService.cols,h-l+d+u-f-m);if(!(!e&&a.slice(l,h).trim()==="")){if(s&&p===0&&o.getCodePoint(0)!==32){let g=r.lines.get(t[1]-1);if(g&&o.isWrapped&&g.getCodePoint(this._bufferService.cols-1)!==32){let x=this._getWordAt([this._bufferService.cols-1,t[1]-1],!1,!0,!1);if(x){let S=this._bufferService.cols-x.start;p-=S,_+=S}}}if(i&&p+_===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let g=r.lines.get(t[1]+1);if(g?.isWrapped&&g.getCodePoint(0)!==32){let x=this._getWordAt([0,t[1]+1],!1,!1,!0);x&&(_+=x.length)}}return{start:p,length:_}}}_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=Na(s,this._bufferService.cols)}};Mn=Ie([se(3,et),se(4,gs),se(5,_o),se(6,tt),se(7,Lt),se(8,Bt)],Mn);var Ea=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={}}},Ta=class{constructor(){this._color=new Ea,this._css=new Ea}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()}},$e=Object.freeze((()=>{let t=[Ne.toColor("#2e3436"),Ne.toColor("#cc0000"),Ne.toColor("#4e9a06"),Ne.toColor("#c4a000"),Ne.toColor("#3465a4"),Ne.toColor("#75507b"),Ne.toColor("#06989a"),Ne.toColor("#d3d7cf"),Ne.toColor("#555753"),Ne.toColor("#ef2929"),Ne.toColor("#8ae234"),Ne.toColor("#fce94f"),Ne.toColor("#729fcf"),Ne.toColor("#ad7fa8"),Ne.toColor("#34e2e2"),Ne.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:Oe.toCss(i,r,o),rgba:Oe.toRgba(i,r,o)})}for(let s=0;s<24;s++){let i=8+s*10;t.push({css:Oe.toCss(i,i,i),rgba:Oe.toRgba(i,i,i)})}return t})()),Jt=Ne.toColor("#ffffff"),Vs=Ne.toColor("#000000"),Ra=Ne.toColor("#ffffff"),Pa=Vs,$s={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Sv=Jt,Bn=class extends fe{constructor(t){super(),this._optionsService=t,this._contrastCache=new Ta,this._halfContrastCache=new Ta,this._onChangeColors=this._register(new Z),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Jt,background:Vs,cursor:Ra,cursorAccent:Pa,selectionForeground:void 0,selectionBackgroundTransparent:$s,selectionBackgroundOpaque:ye.blend(Vs,$s),selectionInactiveBackgroundTransparent:$s,selectionInactiveBackgroundOpaque:ye.blend(Vs,$s),scrollbarSliderBackground:ye.opacity(Jt,.2),scrollbarSliderHoverBackground:ye.opacity(Jt,.4),scrollbarSliderActiveBackground:ye.opacity(Jt,.5),overviewRulerBorder:Jt,ansi:$e.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=ve(t.foreground,Jt),e.background=ve(t.background,Vs),e.cursor=ye.blend(e.background,ve(t.cursor,Ra)),e.cursorAccent=ye.blend(e.background,ve(t.cursorAccent,Pa)),e.selectionBackgroundTransparent=ve(t.selectionBackground,$s),e.selectionBackgroundOpaque=ye.blend(e.background,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundTransparent=ve(t.selectionInactiveBackground,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundOpaque=ye.blend(e.background,e.selectionInactiveBackgroundTransparent),e.selectionForeground=t.selectionForeground?ve(t.selectionForeground,Ca):void 0,e.selectionForeground===Ca&&(e.selectionForeground=void 0),ye.isOpaque(e.selectionBackgroundTransparent)&&(e.selectionBackgroundTransparent=ye.opacity(e.selectionBackgroundTransparent,.3)),ye.isOpaque(e.selectionInactiveBackgroundTransparent)&&(e.selectionInactiveBackgroundTransparent=ye.opacity(e.selectionInactiveBackgroundTransparent,.3)),e.scrollbarSliderBackground=ve(t.scrollbarSliderBackground,ye.opacity(e.foreground,.2)),e.scrollbarSliderHoverBackground=ve(t.scrollbarSliderHoverBackground,ye.opacity(e.foreground,.4)),e.scrollbarSliderActiveBackground=ve(t.scrollbarSliderActiveBackground,ye.opacity(e.foreground,.5)),e.overviewRulerBorder=ve(t.overviewRulerBorder,Sv),e.ansi=$e.slice(),e.ansi[0]=ve(t.black,$e[0]),e.ansi[1]=ve(t.red,$e[1]),e.ansi[2]=ve(t.green,$e[2]),e.ansi[3]=ve(t.yellow,$e[3]),e.ansi[4]=ve(t.blue,$e[4]),e.ansi[5]=ve(t.magenta,$e[5]),e.ansi[6]=ve(t.cyan,$e[6]),e.ansi[7]=ve(t.white,$e[7]),e.ansi[8]=ve(t.brightBlack,$e[8]),e.ansi[9]=ve(t.brightRed,$e[9]),e.ansi[10]=ve(t.brightGreen,$e[10]),e.ansi[11]=ve(t.brightYellow,$e[11]),e.ansi[12]=ve(t.brightBlue,$e[12]),e.ansi[13]=ve(t.brightMagenta,$e[13]),e.ansi[14]=ve(t.brightCyan,$e[14]),e.ansi[15]=ve(t.brightWhite,$e[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]=ve(t.extendedAnsi[i],$e[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()}}};Bn=Ie([se(0,tt)],Bn);function ve(t,e){if(t!==void 0)try{return Ne.toColor(t)}catch{}return e}var yv=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)}},wv=class{constructor(){this._services=new yv,this._services.set(po,this)}setService(t,e){this._services.set(t,e)}getService(t){return this._services.get(t)}createInstance(t,...e){let s=__(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)}},Cv={trace:0,debug:1,info:2,warn:3,error:4,off:5},kv="xterm.js: ",Ln=class extends fe{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=Cv[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?"":kv)+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)}};Ln=Ie([se(0,tt)],Ln);var Da=class extends fe{constructor(t){super(),this._maxLength=t,this.onDeleteEmitter=this._register(new Z),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Z),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Z),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}},ue=3,Be=Object.freeze(new vi),Bi=0,zr=2,qs=class Yc{constructor(e,s,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*ue);let r=s||ft.fromCharData([0,mc,1,0]);for(let o=0;o<e;++o)this.setCell(o,r);this.length=e}get(e){let s=this._data[e*ue+0],i=s&2097151;return[this._data[e*ue+1],s&2097152?this._combined[e]:i?Ft(i):"",s>>22,s&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):i]}set(e,s){this._data[e*ue+1]=s[0],s[1].length>1?(this._combined[e]=s[1],this._data[e*ue+0]=e|2097152|s[2]<<22):this._data[e*ue+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(e){return this._data[e*ue+0]>>22}hasWidth(e){return this._data[e*ue+0]&12582912}getFg(e){return this._data[e*ue+1]}getBg(e){return this._data[e*ue+2]}hasContent(e){return this._data[e*ue+0]&4194303}getCodePoint(e){let s=this._data[e*ue+0];return s&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):s&2097151}isCombined(e){return this._data[e*ue+0]&2097152}getString(e){let s=this._data[e*ue+0];return s&2097152?this._combined[e]:s&2097151?Ft(s&2097151):""}isProtected(e){return this._data[e*ue+2]&536870912}loadCell(e,s){return Bi=e*ue,s.content=this._data[Bi+0],s.fg=this._data[Bi+1],s.bg=this._data[Bi+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*ue+0]=s.content,this._data[e*ue+1]=s.fg,this._data[e*ue+2]=s.bg}setCellFromCodepoint(e,s,i,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*ue+0]=s|i<<22,this._data[e*ue+1]=r.fg,this._data[e*ue+2]=r.bg}addCodepointToCell(e,s,i){let r=this._data[e*ue+0];r&2097152?this._combined[e]+=Ft(s):r&2097151?(this._combined[e]=Ft(r&2097151)+Ft(s),r&=-2097152,r|=2097152):r=s|1<<22,i&&(r&=-12582913,r|=i<<22),this._data[e*ue+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 ft;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 ft;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*zr<this._data.buffer.byteLength;let i=e*ue;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*zr<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*zr<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 Yc(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*ue+0]&4194303)return e+(this._data[e*ue+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*ue+0]&4194303||this._data[e*ue+2]&50331648)return e+(this._data[e*ue+0]>>22);return 0}copyCellsFrom(e,s,i,r,o){let a=e._data;if(o)for(let h=r-1;h>=0;h--){for(let c=0;c<ue;c++)this._data[(i+h)*ue+c]=a[(s+h)*ue+c];a[(s+h)*ue+2]&268435456&&(this._extendedAttrs[i+h]=e._extendedAttrs[s+h])}else for(let h=0;h<r;h++){for(let c=0;c<ue;c++)this._data[(i+h)*ue+c]=a[(s+h)*ue+c];a[(s+h)*ue+2]&268435456&&(this._extendedAttrs[i+h]=e._extendedAttrs[s+h])}let l=Object.keys(e._combined);for(let h=0;h<l.length;h++){let c=parseInt(l[h],10);c>=s&&(this._combined[c-s+i]=e._combined[c])}}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*ue+0],l=a&2097151,h=a&2097152?this._combined[s]:l?Ft(l):Ht;if(o+=h,r)for(let c=0;c<h.length;++c)r.push(s);s+=a>>22||1}return r&&r.push(s),o}};function jv(t,e,s,i,r,o){let a=[];for(let l=0;l<t.length-1;l++){let h=l,c=t.get(++h);if(!c.isWrapped)continue;let d=[t.get(l)];for(;h<t.length&&c.isWrapped;)d.push(c),c=t.get(++h);if(!o&&i>=l&&i<h){l+=d.length-1;continue}let u=0,f=ni(d,u,e),m=1,p=0;for(;m<d.length;){let g=ni(d,m,e),x=g-p,S=s-f,v=Math.min(x,S);d[u].copyCellsFrom(d[m],p,f,v,!1),f+=v,f===s&&(u++,f=0),p+=v,p===g&&(m++,p=0),f===0&&u!==0&&d[u-1].getWidth(s-1)===2&&(d[u].copyCellsFrom(d[u-1],s-1,f++,1,!1),d[u-1].setCell(s-1,r))}d[u].replaceCells(f,s,r);let _=0;for(let g=d.length-1;g>0&&(g>u||d[g].getTrimmedLength()===0);g--)_++;_>0&&(a.push(l+d.length-_),a.push(_)),l+=d.length-1}return a}function Nv(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 Ev(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 Tv(t,e,s){let i=[],r=t.map((h,c)=>ni(t,c,e)).reduce((h,c)=>h+c),o=0,a=0,l=0;for(;l<r;){if(r-l<s){i.push(r-l);break}o+=s;let h=ni(t,a,e);o>h&&(o-=h,a++);let c=t[a].getWidth(o-1)===2;c&&o--;let d=c?s-1:s;i.push(d),l+=d}return i}function ni(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 Xc=class Jc{constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=Jc._nextId++,this._onDispose=this.register(new Z),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),as(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};Xc._nextId=1;var Rv=Xc,Fe={},Zt=Fe.B;Fe[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Fe.A={"#":"£"};Fe.B=void 0;Fe[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Fe.C=Fe[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Fe.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Fe.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Fe.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Fe.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Fe.E=Fe[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Fe.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Fe.H=Fe[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Fe["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Aa=4294967295,Ia=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=Be.clone(),this.savedCharset=Zt,this.markers=[],this._nullCell=ft.fromCharData([0,mc,1,0]),this._whitespaceCell=ft.fromCharData([0,Ht,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new tr,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Da(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 Ji),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 Ji),this._whitespaceCell}getBlankLine(t,e){return new qs(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>Aa?Aa:e}fillViewportRows(t){if(this.lines.length===0){t===void 0&&(t=Be);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 Da(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,e){let s=this.getNullCell(Be),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 qs(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 qs(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=jv(this.lines,this._cols,t,this.ybase+this.y,this.getNullCell(Be),s);if(i.length>0){let r=Nv(this.lines,i);Ev(this.lines,r.layout),this._reflowLargerAdjustViewport(t,e,r.countRemoved)}}_reflowLargerAdjustViewport(t,e,s){let i=this.getNullCell(Be),r=s;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<e&&this.lines.push(new qs(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(Be),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 h=[l];for(;l.isWrapped&&a>0;)l=this.lines.get(--a),h.unshift(l);if(!s){let v=this.ybase+this.y;if(v>=a&&v<a+h.length)continue}let c=h[h.length-1].getTrimmedLength(),d=Tv(h,this._cols,t),u=d.length-h.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 v=0;v<u;v++){let b=this.getBlankLine(Be,!0);m.push(b)}m.length>0&&(r.push({start:a+h.length+o,newLines:m}),o+=m.length),h.push(...m);let p=d.length-1,_=d[p];_===0&&(p--,_=d[p]);let g=h.length-u-1,x=c;for(;g>=0;){let v=Math.min(x,_);if(h[p]===void 0)break;if(h[p].copyCellsFrom(h[g],x-v,_-v,v,!0),_-=v,_===0&&(p--,_=d[p]),x-=v,x===0){g--;let b=Math.max(g,0);x=ni(h,b,this._cols)}}for(let v=0;v<h.length;v++)d[v]<t&&h[v].setCell(d[v],i);let S=u-f;for(;S-- >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 _=0;_<this.lines.length;_++)l.push(this.lines.get(_));let h=this.lines.length,c=h-1,d=0,u=r[d];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let f=0;for(let _=Math.min(this.lines.maxLength-1,h+o-1);_>=0;_--)if(u&&u.start>c+f){for(let g=u.newLines.length-1;g>=0;g--)this.lines.set(_--,u.newLines[g]);_++,a.push({index:c+1,amount:u.newLines.length}),f+=u.newLines.length,u=r[++d]}else this.lines.set(_,l[c--]);let m=0;for(let _=a.length-1;_>=0;_--)a[_].index+=m,this.lines.onInsertEmitter.fire(a[_]),m+=a[_].amount;let p=Math.max(0,h+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 Rv(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)}},Pv=class extends fe{constructor(t,e){super(),this._optionsService=t,this._bufferService=e,this._onBufferActivate=this._register(new Z),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 Ia(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Ia(!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)}},Zc=2,Qc=1,On=class extends fe{constructor(t){super(),this.isUserScrolling=!1,this._onResize=this._register(new Z),this.onResize=this._onResize.event,this._onScroll=this._register(new Z),this.onScroll=this._onScroll.event,this.cols=Math.max(t.rawOptions.cols||0,Zc),this.rows=Math.max(t.rawOptions.rows||0,Qc),this.buffers=this._register(new Pv(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))}};On=Ie([se(0,tt)],On);var bs={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:er,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},Dv=["normal","bold","100","200","300","400","500","600","700","800","900"],Av=class extends fe{constructor(t){super(),this._onOptionChange=this._register(new Z),this.onOptionChange=this._onOptionChange.event;let e={...bs};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(Ce(()=>{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 bs))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},e=(s,i)=>{if(!(s in bs))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=bs[t]),!Iv(e))throw new Error(`"${e}" is not a valid value for ${t}`);break;case"wordSeparator":e||(e=bs[t]);break;case"fontWeight":case"fontWeightBold":if(typeof e=="number"&&1<=e&&e<=1e3)break;e=Dv.includes(e)?e:bs[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 Iv(t){return t==="block"||t==="underline"||t==="bar"}function Gs(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]&&Gs(t[i],e-1);return s}var Ma=Object.freeze({insertMode:!1}),Ba=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),$n=class extends fe{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 Z),this.onData=this._onData.event,this._onUserInput=this._register(new Z),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Z),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Z),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Gs(Ma),this.decPrivateModes=Gs(Ba)}reset(){this.modes=Gs(Ma),this.decPrivateModes=Gs(Ba)}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))}};$n=Ie([se(0,et),se(1,xc),se(2,tt)],$n);var La={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 Fr(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 Hr=String.fromCharCode,Oa={DEFAULT:t=>{let e=[Fr(t,!1)+32,t.col+32,t.row+32];return e[0]>255||e[1]>255||e[2]>255?"":`\x1B[M${Hr(e[0])}${Hr(e[1])}${Hr(e[2])}`},SGR:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${Fr(t,!0)};${t.col};${t.row}${e}`},SGR_PIXELS:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${Fr(t,!0)};${t.x};${t.y}${e}`}},zn=class extends fe{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 Z),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(La))this.addProtocol(i,La[i]);for(let i of Object.keys(Oa))this.addEncoding(i,Oa[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)}};zn=Ie([se(0,et),se(1,gs),se(2,tt)],zn);var Wr=[[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]],Mv=[[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]],ze;function Bv(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 Lv=class{constructor(){if(this.version="6",!ze){ze=new Uint8Array(65536),ze.fill(1),ze[0]=0,ze.fill(0,1,32),ze.fill(0,127,160),ze.fill(2,4352,4448),ze[9001]=2,ze[9002]=2,ze.fill(2,11904,42192),ze[12351]=1,ze.fill(2,44032,55204),ze.fill(2,63744,64256),ze.fill(2,65040,65050),ze.fill(2,65072,65136),ze.fill(2,65280,65377),ze.fill(2,65504,65511);for(let t=0;t<Wr.length;++t)ze.fill(0,Wr[t][0],Wr[t][1]+1)}}wcwidth(t){return t<32?0:t<127?1:t<65536?ze[t]:Bv(t,Mv)?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=Qt.extractWidth(e);r===0?i=!1:r>s&&(s=r)}return Qt.createPropertyValue(0,s,i)}},Qt=class Ki{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Z,this.onChange=this._onChange.event;let e=new Lv;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 c=e.charCodeAt(o);56320<=c&&c<=57343?a=(a-55296)*1024+c-56320+65536:s+=this.wcwidth(c)}let l=this.charProperties(a,i),h=Ki.extractWidth(l);Ki.extractShouldJoin(l)&&(h-=Ki.extractWidth(i)),s+=h,i=l}return s}charProperties(e,s){return this._activeProvider.charProperties(e,s)}},Ov=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 $a(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 zs=2147483647,$v=256,eh=class Fn{constructor(e=32,s=32){if(this.maxLength=e,this.maxSubParamsLength=s,s>$v)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 Fn;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 Fn(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>zs?zs: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>zs?zs: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,zs):e}},Fs=[],zv=class{constructor(){this._state=0,this._active=Fs,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=Fs}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=Fs,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Fs,!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",pr(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=Fs,this._id=-1,this._state=0}}},nt=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+=pr(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}},Hs=[],Fv=class{constructor(){this._handlers=Object.create(null),this._active=Hs,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Hs}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=Hs,this._ident=0}hook(t,e){if(this.reset(),this._ident=t,this._active=this._handlers[t]||Hs,!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",pr(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=Hs,this._ident=0}},Ys=new eh;Ys.addParam(0);var za=class{constructor(t){this._handler=t,this._data="",this._params=Ys,this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():Ys,this._data="",this._hitLimit=!1}put(t,e,s){this._hitLimit||(this._data+=pr(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=Ys,this._data="",this._hitLimit=!1,s));return this._params=Ys,this._data="",this._hitLimit=!1,e}},Hv=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}},ut=160,Wv=(function(){let t=new Hv(4095),e=Array.apply(null,Array(256)).map((l,h)=>h),s=(l,h)=>e.slice(l,h),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(ut,0,2,0),t.add(ut,8,5,8),t.add(ut,6,0,6),t.add(ut,11,0,11),t.add(ut,13,13,13),t})(),Uv=class extends fe{constructor(t=Wv){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 eh,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(Ce(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new zv),this._dcsParser=this._register(new Fv),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,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](this._params),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 4:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,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:ut)],r>>4){case 2:for(let f=l+1;;++f){if(f>=e||(i=t[f])<32||i>126&&i<ut){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(i=t[f])<32||i>126&&i<ut){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(i=t[f])<32||i>126&&i<ut){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(i=t[f])<32||i>126&&i<ut){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 h=this._csiHandlers[this._collect<<8|i],c=h?h.length-1:-1;for(;c>=0&&(a=h[c](this._params),a!==!0);c--)if(a instanceof Promise)return this._preserveStack(3,h,c,r,l),a;c<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 d=this._escHandlers[this._collect<<8|i],u=d?d.length-1:-1;for(;u>=0&&(a=d[u](),a!==!0);u--)if(a instanceof Promise)return this._preserveStack(4,d,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<ut){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<ut){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}}},Kv=/^([\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})$/,Vv=/^[\da-f]+$/;function Fa(t){if(!t)return;let e=t.toLowerCase();if(e.indexOf("rgb:")===0){e=e.slice(4);let s=Kv.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),Vv.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 Ur(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 qv(t,e=16){let[s,i,r]=t;return`rgb:${Ur(s,e)}/${Ur(i,e)}/${Ur(r,e)}`}var Gv={"(":0,")":1,"*":2,"+":3,"-":1,".":2},zt=131072,Ha=10;function Wa(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 Ua=5e3,Ka=0,Yv=class extends fe{constructor(t,e,s,i,r,o,a,l,h=new Uv){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=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new m_,this._utf8Decoder=new p_,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Be.clone(),this._eraseAttrDataInternal=Be.clone(),this._onRequestBell=this._register(new Z),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Z),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Z),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Z),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Z),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Z),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Z),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Z),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Z),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Z),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Z),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Z),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Z),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 Hn(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(c=>this._activeBuffer=c.activeBuffer)),this._parser.setCsiHandlerFallback((c,d)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(c),params:d.toArray()})}),this._parser.setEscHandlerFallback(c=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(c)})}),this._parser.setExecuteHandlerFallback(c=>{this._logService.debug("Unknown EXECUTE code: ",{code:c})}),this._parser.setOscHandlerFallback((c,d,u)=>{this._logService.debug("Unknown OSC code: ",{identifier:c,action:d,data:u})}),this._parser.setDcsHandlerFallback((c,d,u)=>{d==="HOOK"&&(u=u.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(c),action:d,payload:u})}),this._parser.setPrintHandler((c,d,u)=>this.print(c,d,u)),this._parser.registerCsiHandler({final:"@"},c=>this.insertChars(c)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},c=>this.scrollLeft(c)),this._parser.registerCsiHandler({final:"A"},c=>this.cursorUp(c)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},c=>this.scrollRight(c)),this._parser.registerCsiHandler({final:"B"},c=>this.cursorDown(c)),this._parser.registerCsiHandler({final:"C"},c=>this.cursorForward(c)),this._parser.registerCsiHandler({final:"D"},c=>this.cursorBackward(c)),this._parser.registerCsiHandler({final:"E"},c=>this.cursorNextLine(c)),this._parser.registerCsiHandler({final:"F"},c=>this.cursorPrecedingLine(c)),this._parser.registerCsiHandler({final:"G"},c=>this.cursorCharAbsolute(c)),this._parser.registerCsiHandler({final:"H"},c=>this.cursorPosition(c)),this._parser.registerCsiHandler({final:"I"},c=>this.cursorForwardTab(c)),this._parser.registerCsiHandler({final:"J"},c=>this.eraseInDisplay(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},c=>this.eraseInDisplay(c,!0)),this._parser.registerCsiHandler({final:"K"},c=>this.eraseInLine(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},c=>this.eraseInLine(c,!0)),this._parser.registerCsiHandler({final:"L"},c=>this.insertLines(c)),this._parser.registerCsiHandler({final:"M"},c=>this.deleteLines(c)),this._parser.registerCsiHandler({final:"P"},c=>this.deleteChars(c)),this._parser.registerCsiHandler({final:"S"},c=>this.scrollUp(c)),this._parser.registerCsiHandler({final:"T"},c=>this.scrollDown(c)),this._parser.registerCsiHandler({final:"X"},c=>this.eraseChars(c)),this._parser.registerCsiHandler({final:"Z"},c=>this.cursorBackwardTab(c)),this._parser.registerCsiHandler({final:"`"},c=>this.charPosAbsolute(c)),this._parser.registerCsiHandler({final:"a"},c=>this.hPositionRelative(c)),this._parser.registerCsiHandler({final:"b"},c=>this.repeatPrecedingCharacter(c)),this._parser.registerCsiHandler({final:"c"},c=>this.sendDeviceAttributesPrimary(c)),this._parser.registerCsiHandler({prefix:">",final:"c"},c=>this.sendDeviceAttributesSecondary(c)),this._parser.registerCsiHandler({final:"d"},c=>this.linePosAbsolute(c)),this._parser.registerCsiHandler({final:"e"},c=>this.vPositionRelative(c)),this._parser.registerCsiHandler({final:"f"},c=>this.hVPosition(c)),this._parser.registerCsiHandler({final:"g"},c=>this.tabClear(c)),this._parser.registerCsiHandler({final:"h"},c=>this.setMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"h"},c=>this.setModePrivate(c)),this._parser.registerCsiHandler({final:"l"},c=>this.resetMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"l"},c=>this.resetModePrivate(c)),this._parser.registerCsiHandler({final:"m"},c=>this.charAttributes(c)),this._parser.registerCsiHandler({final:"n"},c=>this.deviceStatus(c)),this._parser.registerCsiHandler({prefix:"?",final:"n"},c=>this.deviceStatusPrivate(c)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},c=>this.softReset(c)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},c=>this.setCursorStyle(c)),this._parser.registerCsiHandler({final:"r"},c=>this.setScrollRegion(c)),this._parser.registerCsiHandler({final:"s"},c=>this.saveCursor(c)),this._parser.registerCsiHandler({final:"t"},c=>this.windowOptions(c)),this._parser.registerCsiHandler({final:"u"},c=>this.restoreCursor(c)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},c=>this.insertColumns(c)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},c=>this.deleteColumns(c)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},c=>this.selectProtected(c)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},c=>this.requestMode(c,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},c=>this.requestMode(c,!1)),this._parser.setExecuteHandler(U.BEL,()=>this.bell()),this._parser.setExecuteHandler(U.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(U.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(U.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(U.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(U.BS,()=>this.backspace()),this._parser.setExecuteHandler(U.HT,()=>this.tab()),this._parser.setExecuteHandler(U.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(U.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Wi.IND,()=>this.index()),this._parser.setExecuteHandler(Wi.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Wi.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new nt(c=>(this.setTitle(c),this.setIconName(c),!0))),this._parser.registerOscHandler(1,new nt(c=>this.setIconName(c))),this._parser.registerOscHandler(2,new nt(c=>this.setTitle(c))),this._parser.registerOscHandler(4,new nt(c=>this.setOrReportIndexedColor(c))),this._parser.registerOscHandler(8,new nt(c=>this.setHyperlink(c))),this._parser.registerOscHandler(10,new nt(c=>this.setOrReportFgColor(c))),this._parser.registerOscHandler(11,new nt(c=>this.setOrReportBgColor(c))),this._parser.registerOscHandler(12,new nt(c=>this.setOrReportCursorColor(c))),this._parser.registerOscHandler(104,new nt(c=>this.restoreIndexedColor(c))),this._parser.registerOscHandler(110,new nt(c=>this.restoreFgColor(c))),this._parser.registerOscHandler(111,new nt(c=>this.restoreBgColor(c))),this._parser.registerOscHandler(112,new nt(c=>this.restoreCursorColor(c))),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 c in Fe)this._parser.registerEscHandler({intermediates:"(",final:c},()=>this.selectCharset("("+c)),this._parser.registerEscHandler({intermediates:")",final:c},()=>this.selectCharset(")"+c)),this._parser.registerEscHandler({intermediates:"*",final:c},()=>this.selectCharset("*"+c)),this._parser.registerEscHandler({intermediates:"+",final:c},()=>this.selectCharset("+"+c)),this._parser.registerEscHandler({intermediates:"-",final:c},()=>this.selectCharset("-"+c)),this._parser.registerEscHandler({intermediates:".",final:c},()=>this.selectCharset("."+c)),this._parser.registerEscHandler({intermediates:"/",final:c},()=>this.selectCharset("/"+c));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(c=>(this._logService.error("Parsing error: ",c),c)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new za((c,d)=>this.requestStatusString(c,d)))}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"),Ua))]).catch(e=>{if(e!=="#SLOW_TIMEOUT")throw e;console.warn(`async parser handler taking longer than ${Ua} 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>zt&&(o=this._parseStack.position+zt)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof t=="string"?` "${t}"`:` "${Array.prototype.map.call(t,c=>String.fromCharCode(c)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof t=="string"?t.split("").map(c=>c.charCodeAt(0)):t),this._parseBuffer.length<t.length&&this._parseBuffer.length<zt&&(this._parseBuffer=new Uint32Array(Math.min(t.length,zt))),a||this._dirtyRowTracker.clearRange(),t.length>zt)for(let c=o;c<t.length;c+=zt){let d=c+zt<t.length?c+zt:t.length,u=typeof t=="string"?this._stringDecoder.decode(t.substring(c,d),this._parseBuffer):this._utf8Decoder.decode(t.subarray(c,d),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,u))return this._preserveStack(i,r,u,c),this._logSlowResolvingAsync(s),s}else if(!a){let c=typeof t=="string"?this._stringDecoder.decode(t,this._parseBuffer):this._utf8Decoder.decode(t,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,c))return this._preserveStack(i,r,c,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),h=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);h<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(h,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,h=this._coreService.decPrivateModes.wraparound,c=this._coreService.modes.insertMode,d=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,d);let f=this._parser.precedingJoinState;for(let m=e;m<s;++m){if(i=t[m],i<127&&o){let x=o[String.fromCharCode(i)];x&&(i=x.charCodeAt(0))}let p=this._unicodeService.charProperties(i,f);r=Qt.extractWidth(p);let _=Qt.extractShouldJoin(p),g=_?Qt.extractWidth(f):0;if(f=p,a&&this._onA11yChar.fire(Ft(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-g>l){if(h){let x=u,S=this._activeBuffer.x-g;for(this._activeBuffer.x=g,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),g>0&&u instanceof qs&&u.copyCellsFrom(x,S,0,g,!1);S<l;)x.setCellFromCodepoint(S++,0,1,d)}else if(this._activeBuffer.x=l-1,r===2)continue}if(_&&this._activeBuffer.x){let x=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-x,i,r);for(let S=r-g;--S>=0;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d);continue}if(c&&(u.insertCells(this._activeBuffer.x,r-g,this._activeBuffer.getNullCell(d)),u.getWidth(l-1)===2&&u.setCellFromCodepoint(l-1,0,1,d)),u.setCellFromCodepoint(this._activeBuffer.x++,i,r,d),r>0)for(;--r;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d)}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,d),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(t,e){return t.final==="t"&&!t.prefix&&!t.intermediates?this._parser.registerCsiHandler(t,s=>Wa(s.params[0],this._optionsService.rawOptions.windowOptions)?e(s):!0):this._parser.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._parser.registerDcsHandler(t,new za(e))}registerEscHandler(t,e){return this._parser.registerEscHandler(t,e)}registerOscHandler(t,e){return this._parser.registerOscHandler(t,new nt(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(Be));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=Qt.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 c=0;c<o.length;){let d=o.codePointAt(c)||0;a[l++]=d,c+=d>65535?2:1}let h=l;for(let c=1;c<s;++c)a.copyWithin(h,0,l),h+=l;return this.print(a,0,h),!0}sendDeviceAttributesPrimary(t){return t.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(U.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(U.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(t){return t.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(U.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(U.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(t.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(U.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,Zt),this._charsetService.setgCharset(1,Zt),this._charsetService.setgCharset(2,Zt),this._charsetService.setgCharset(3,Zt);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;(_=>(_[_.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",_[_.SET=1]="SET",_[_.RESET=2]="RESET",_[_.PERMANENTLY_SET=3]="PERMANENTLY_SET",_[_.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(s||={});let i=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:o}=this._coreMouseService,a=this._coreService,{buffers:l,cols:h}=this._bufferService,{active:c,alt:d}=l,u=this._optionsService.rawOptions,f=(_,g)=>(a.triggerDataEvent(`${U.ESC}[${e?"":"?"}${_};${g}$y`),!0),m=_=>_?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?h===80?2:h===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(c===d)):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|=vi.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=Be.fg,t.bg=Be.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|=Be.fg&16777215):s===49?(i.bg&=-67108864,i.bg|=Be.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|=Be.fg&16777215,i.bg&=-67108864,i.bg|=Be.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(t){switch(t.params[0]){case 5:this._coreService.triggerDataEvent(`${U.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${U.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(`${U.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=Be.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(!Wa(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(`${U.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(e===0||e===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Ha&&this._windowTitleStack.shift()),(e===0||e===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Ha&&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(Va(o))if(r==="?")e.push({type:0,index:o});else{let a=Fa(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=Fa(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]);Va(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,Zt),!0}selectCharset(t){return t.length!==2?(this.selectDefaultCharset(),!0):(t[0]==="/"||this._charsetService.setgCharset(Gv[t[0]],Fe[t[1]]||Zt),!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=Be.clone(),this._eraseAttrDataInternal=Be.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 ft;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(`${U.ESC}${a}${U.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)}},Hn=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&&(Ka=t,t=e,e=Ka),t<this.start&&(this.start=t),e>this.end&&(this.end=e)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Hn=Ie([se(0,et)],Hn);function Va(t){return 0<=t&&t<256}var Xv=5e7,qa=12,Jv=50,Zv=class extends fe{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 Z),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>Xv)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>=qa?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>=qa)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>Jv&&(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()}},Wn=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),h={data:t,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(h,l)),this._dataByLinkId.set(h.id,h),h.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)))}};Wn=Ie([se(0,et)],Wn);var Ga=!1,Qv=class extends fe{constructor(t){super(),this._windowsWrappingHeuristics=this._register(new js),this._onBinary=this._register(new Z),this.onBinary=this._onBinary.event,this._onData=this._register(new Z),this.onData=this._onData.event,this._onLineFeed=this._register(new Z),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Z),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Z),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Z),this._instantiationService=new wv,this.optionsService=this._register(new Av(t)),this._instantiationService.setService(tt,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(On)),this._instantiationService.setService(et,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Ln)),this._instantiationService.setService(xc,this._logService),this.coreService=this._register(this._instantiationService.createInstance($n)),this._instantiationService.setService(gs,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(zn)),this._instantiationService.setService(vc,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Qt)),this._instantiationService.setService(x_,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Ov),this._instantiationService.setService(v_,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Wn),this._instantiationService.setService(bc,this._oscLinkService),this._inputHandler=this._register(new Yv(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ye.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ye.forward(this._bufferService.onResize,this._onResize)),this._register(Ye.forward(this.coreService.onData,this._onData)),this._register(Ye.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 Zv((e,s)=>this._inputHandler.parse(e,s))),this._register(Ye.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Z),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&&!Ga&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Ga=!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,Zc),e=Math.max(e,Qc),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($a.bind(null,this._bufferService))),t.push(this.registerCsiHandler({final:"H"},()=>($a(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Ce(()=>{for(let e of t)e.dispose()})}}},e1={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 t1(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=U.ESC+"OA":r.key=U.ESC+"[A":t.key==="UIKeyInputLeftArrow"?e?r.key=U.ESC+"OD":r.key=U.ESC+"[D":t.key==="UIKeyInputRightArrow"?e?r.key=U.ESC+"OC":r.key=U.ESC+"[C":t.key==="UIKeyInputDownArrow"&&(e?r.key=U.ESC+"OB":r.key=U.ESC+"[B");break;case 8:r.key=t.ctrlKey?"\b":U.DEL,t.altKey&&(r.key=U.ESC+r.key);break;case 9:if(t.shiftKey){r.key=U.ESC+"[Z";break}r.key=U.HT,r.cancel=!0;break;case 13:r.key=t.altKey?U.ESC+U.CR:U.CR,r.cancel=!0;break;case 27:r.key=U.ESC,t.altKey&&(r.key=U.ESC+U.ESC),r.cancel=!0;break;case 37:if(t.metaKey)break;o?r.key=U.ESC+"[1;"+(o+1)+"D":e?r.key=U.ESC+"OD":r.key=U.ESC+"[D";break;case 39:if(t.metaKey)break;o?r.key=U.ESC+"[1;"+(o+1)+"C":e?r.key=U.ESC+"OC":r.key=U.ESC+"[C";break;case 38:if(t.metaKey)break;o?r.key=U.ESC+"[1;"+(o+1)+"A":e?r.key=U.ESC+"OA":r.key=U.ESC+"[A";break;case 40:if(t.metaKey)break;o?r.key=U.ESC+"[1;"+(o+1)+"B":e?r.key=U.ESC+"OB":r.key=U.ESC+"[B";break;case 45:!t.shiftKey&&!t.ctrlKey&&(r.key=U.ESC+"[2~");break;case 46:o?r.key=U.ESC+"[3;"+(o+1)+"~":r.key=U.ESC+"[3~";break;case 36:o?r.key=U.ESC+"[1;"+(o+1)+"H":e?r.key=U.ESC+"OH":r.key=U.ESC+"[H";break;case 35:o?r.key=U.ESC+"[1;"+(o+1)+"F":e?r.key=U.ESC+"OF":r.key=U.ESC+"[F";break;case 33:t.shiftKey?r.type=2:t.ctrlKey?r.key=U.ESC+"[5;"+(o+1)+"~":r.key=U.ESC+"[5~";break;case 34:t.shiftKey?r.type=3:t.ctrlKey?r.key=U.ESC+"[6;"+(o+1)+"~":r.key=U.ESC+"[6~";break;case 112:o?r.key=U.ESC+"[1;"+(o+1)+"P":r.key=U.ESC+"OP";break;case 113:o?r.key=U.ESC+"[1;"+(o+1)+"Q":r.key=U.ESC+"OQ";break;case 114:o?r.key=U.ESC+"[1;"+(o+1)+"R":r.key=U.ESC+"OR";break;case 115:o?r.key=U.ESC+"[1;"+(o+1)+"S":r.key=U.ESC+"OS";break;case 116:o?r.key=U.ESC+"[15;"+(o+1)+"~":r.key=U.ESC+"[15~";break;case 117:o?r.key=U.ESC+"[17;"+(o+1)+"~":r.key=U.ESC+"[17~";break;case 118:o?r.key=U.ESC+"[18;"+(o+1)+"~":r.key=U.ESC+"[18~";break;case 119:o?r.key=U.ESC+"[19;"+(o+1)+"~":r.key=U.ESC+"[19~";break;case 120:o?r.key=U.ESC+"[20;"+(o+1)+"~":r.key=U.ESC+"[20~";break;case 121:o?r.key=U.ESC+"[21;"+(o+1)+"~":r.key=U.ESC+"[21~";break;case 122:o?r.key=U.ESC+"[23;"+(o+1)+"~":r.key=U.ESC+"[23~";break;case 123:o?r.key=U.ESC+"[24;"+(o+1)+"~":r.key=U.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=U.NUL:t.keyCode>=51&&t.keyCode<=55?r.key=String.fromCharCode(t.keyCode-51+27):t.keyCode===56?r.key=U.DEL:t.keyCode===219?r.key=U.ESC:t.keyCode===220?r.key=U.FS:t.keyCode===221&&(r.key=U.GS);else if((!s||i)&&t.altKey&&!t.metaKey){let a=e1[t.keyCode]?.[t.shiftKey?1:0];if(a)r.key=U.ESC+a;else if(t.keyCode>=65&&t.keyCode<=90){let l=t.ctrlKey?t.keyCode-64:t.keyCode+32,h=String.fromCharCode(l);t.shiftKey&&(h=h.toUpperCase()),r.key=U.ESC+h}else if(t.keyCode===32)r.key=U.ESC+(t.ctrlKey?U.NUL:" ");else if(t.key==="Dead"&&t.code.startsWith("Key")){let l=t.code.slice(3,4);t.shiftKey||(l=l.toLowerCase()),r.key=U.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=U.US),t.key==="@"&&(r.key=U.NUL));break}return r}var Me=0,s1=class{constructor(t){this._getKey=t,this._array=[],this._insertedValues=[],this._flushInsertedTask=new tr,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new tr,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||(Me=this._search(e),Me===-1)||this._getKey(this._array[Me])!==e)return!1;do if(this._array[Me]===t)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Me),!0;while(++Me<this._array.length&&this._getKey(this._array[Me])===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&&(Me=this._search(t),!(Me<0||Me>=this._array.length)&&this._getKey(this._array[Me])===t))do yield this._array[Me];while(++Me<this._array.length&&this._getKey(this._array[Me])===t)}forEachByKey(t,e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Me=this._search(t),!(Me<0||Me>=this._array.length)&&this._getKey(this._array[Me])===t))do e(this._array[Me]);while(++Me<this._array.length&&this._getKey(this._array[Me])===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}},Kr=0,Ya=0,i1=class extends fe{constructor(){super(),this._decorations=new s1(t=>t?.marker.line),this._onDecorationRegistered=this._register(new Z),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Z),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Ce(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(t){if(t.marker.isDisposed)return;let e=new r1(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=>{Kr=r.options.x??0,Ya=Kr+(r.options.width??1),t>=Kr&&t<Ya&&(!s||(r.options.layer??"bottom")===s)&&i(r)})}},r1=class extends Wt{constructor(t){super(),this.options=t,this.onRenderEmitter=this.add(new Z),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Z),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=Ne.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Ne.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},n1=1e3,o1=class{constructor(t,e=n1){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)}},Xa=20,sr=class extends fe{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 o1(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(`
|
|
284
284
|
`))),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(de(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Ce(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(t){for(let e=0;e<t;e++)this._handleChar(" ")}_handleChar(t){this._liveRegionLineCount<Xa+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==t&&(this._charsToAnnounce+=t):this._charsToAnnounce+=t,t===`
|
|
285
285
|
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Xa+1&&(this._liveRegion.textContent+=cn.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)||"",h=(s.ydisp+r+1).toString(),c=this._rowElements[r];c&&(l.length===0?(c.textContent=" ",this._rowColumns.set(c,[0,1])):(c.textContent=l,this._rowColumns.set(c,a)),c.setAttribute("aria-posinset",h),c.setAttribute("aria-setsize",i),this._alignRowWidth(c))}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 h=this._createAccessibilityTreeNode();this._rowElements.unshift(h),this._rowContainer.insertAdjacentElement("afterbegin",h)}else{let h=this._createAccessibilityTreeNode();this._rowElements.push(h),this._rowContainer.appendChild(h)}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:h})=>{let c=l instanceof Text?l.parentNode:l,d=parseInt(c?.getAttribute("aria-posinset"),10)-1;if(isNaN(d))return console.warn("row is invalid. Race condition?"),null;let u=this._rowColumns.get(c);if(!u)return console.warn("columns is null. Race condition?"),null;let f=h<u.length?u[h]:u.slice(-1)[0]+1;return f>=this._terminal.cols&&(++d,f=0),{row:d,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})`}};sr=Ie([se(1,po),se(2,Bt),se(3,Lt)],sr);var Un=class extends fe{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 Z),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Z),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Ce(()=>{as(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(de(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(de(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(de(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(de(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,h=a.link.range.end.y>t?this._bufferService.cols:a.link.range.end.x;for(let c=l;c<=h;c++){if(s.has(c)){r.splice(o--,1);break}s.add(c)}}}}_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&&a1(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,as(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}}};Un=Ie([se(1,_o),se(2,Lt),se(3,et),se(4,yc)],Un);function a1(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 l1=class extends Qv{constructor(t={}){super(t),this._linkifier=this._register(new js),this.browser=Fc,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new js),this._onCursorMove=this._register(new Z),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Z),this.onKey=this._onKey.event,this._onRender=this._register(new Z),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Z),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Z),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Z),this.onBell=this._onBell.event,this._onFocus=this._register(new Z),this._onBlur=this._register(new Z),this._onA11yCharEmitter=this._register(new Z),this._onA11yTabEmitter=this._register(new Z),this._onWillOpen=this._register(new Z),this._setup(),this._decorationService=this._instantiationService.createInstance(i1),this._instantiationService.setService(xi,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Jg),this._instantiationService.setService(yc,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(dn)),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(Ye.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ye.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ye.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ye.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(Ce(()=>{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=ye.toColorRGB(s==="ansi"?this._themeService.colors.ansi[e.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${U.ESC}]${i};${qv(r)}${$c.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[e.index]=Oe.toColor(...e.color));else{let o=s;this._themeService.modifyColors(a=>a[o]=Oe.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(sr,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(t){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(U.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(U.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(de(this.element,"copy",e=>{this.hasSelection()&&u_(e,this._selectionService)}));let t=e=>f_(e,this.textarea,this.coreService,this.optionsService);this._register(de(this.textarea,"paste",t)),this._register(de(this.element,"paste",t)),Hc?this._register(de(this.element,"mousedown",e=>{e.button===2&&oa(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(de(this.element,"contextmenu",e=>{oa(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Co&&this._register(de(this.element,"auxclick",e=>{e.button===1&&fc(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(de(this.textarea,"keyup",t=>this._keyUp(t),!0)),this._register(de(this.textarea,"keydown",t=>this._keyDown(t),!0)),this._register(de(this.textarea,"keypress",t=>this._keyPress(t),!0)),this._register(de(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(de(this.textarea,"compositionupdate",t=>this._compositionHelper.compositionupdate(t))),this._register(de(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(de(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(de(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",ln.get()),Kc||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(Yg,this.textarea,t.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Bt,this._coreBrowserService),this._register(de(this.textarea,"focus",r=>this._handleTextAreaFocus(r))),this._register(de(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Dn,this._document,this._helperContainer),this._instantiationService.setService(_r,this._charSizeService),this._themeService=this._instantiationService.createInstance(Bn),this._instantiationService.setService(Ts,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Qi),this._instantiationService.setService(Sc,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(In,this.rows,this.screenElement)),this._instantiationService.setService(Lt,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(Tn,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(An),this._instantiationService.setService(_o,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(Un,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(Nn,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(Mn,this.element,this.screenElement,i)),this._instantiationService.setService(S_,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(Ye.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(En,this.screenElement)),this._register(de(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(sr,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",r=>this._handleScreenReaderModeOptionChange(r))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Zi,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",r=>{!this._overviewRulerRenderer&&r&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Zi,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Pn,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,h;switch(o.overrideType||o.type){case"mousemove":h=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":h=0,l=o.button<3?o.button:3;break;case"mousedown":h=1,l=o.button<3?o.button:3;break;case"wheel":if(t._customWheelEventHandler&&t._customWheelEventHandler(o)===!1)return!1;let c=o.deltaY;if(c===0||t.coreMouseService.consumeWheelEvent(o,t._renderService?.dimensions?.device?.cell?.height,t._coreBrowserService?.dpr)===0)return!1;h=c<0?0:1,l=4;break;default:return!1}return h===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:h,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(de(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(de(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=U.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){uc(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=t1(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===U.ETX||s.key===U.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)&&(c1(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(Be));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(U.ESC+"[I"):this.coreService.triggerDataEvent(U.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(`${U.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(`${U.ESC}[6;${r};${i}t`);break}}cancel(t,e){if(!(!this.options.cancelEvents&&!e))return t.preventDefault(),t.stopPropagation(),!1}};function c1(t){return t.keyCode===16||t.keyCode===17||t.keyCode===18}var h1=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)}},d1=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 ft)}translateToString(t,e,s){return this._line.translateToString(t,e,s)}},Ja=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 d1(e)}getNullCell(){return new ft}},u1=class extends fe{constructor(t){super(),this._core=t,this._onBufferChange=this._register(new Z),this.onBufferChange=this._onBufferChange.event,this._normal=new Ja(this._core.buffers.normal,"normal"),this._alternate=new Ja(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)}},f1=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)}},m1=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}},p1=["cols","rows"],vt=0,_1=class extends fe{constructor(t){super(),this._core=this._register(new l1(t)),this._addonManager=this._register(new h1),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(p1.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 f1(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new m1(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 u1(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
|
|
286
|
-
`,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 ln.get()},set promptLabel(t){ln.set(t)},get tooMuchOutput(){return cn.get()},set tooMuchOutput(t){cn.set(t)}}}_verifyIntegers(...t){for(vt of t)if(vt===1/0||isNaN(vt)||vt%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(vt of t)if(vt&&(vt===1/0||isNaN(vt)||vt%1!==0||vt<0))throw new Error("This API only accepts positive integers")}};var g1=2,v1=1,x1=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,h=a.right+a.left,c=i-l,d=r-h-e;return{cols:Math.max(g1,Math.floor(d/t.css.cell.width)),rows:Math.max(v1,Math.floor(c/t.css.cell.height))}}};function th({source:t,onReady:e,onSelectionChange:s,className:i}){const r=D.useRef(null),o=D.useRef(null),a=D.useRef(s);a.current=s;const l=Es(),h=D.useRef(t);return h.current=t,Wp((c,d)=>{c===h.current&&o.current?.write(d)}),D.useEffect(()=>{const c=r.current;if(!c)return;const d=getComputedStyle(document.documentElement),u=x=>d.getPropertyValue(x).trim()||void 0,f=new _1({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 x1;f.loadAddon(m),f.open(c),m.fit();const p=l.getBuffer(t);p&&f.write(p),o.current=f,e?.(f);const _=f.onSelectionChange(()=>{const x=!!f.getSelection();a.current?.(x,()=>f.getSelection())}),g=new ResizeObserver(()=>{m.fit()});return g.observe(c),()=>{_.dispose(),g.disconnect(),o.current=null,f.dispose()}},[]),n.jsx("div",{className:te("h-full bg-sidebar p-3",i),children:n.jsx("div",{ref:r,className:"h-full"})})}function Ss(t){const e=F.c(24);if(t.kind==="starting-now"){let c;return e[0]!==t.claimPhase||e[1]!==t.progress?(c=n.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:n.jsx(t_,{progress:t.progress,claimPhase:t.claimPhase})}),e[0]=t.claimPhase,e[1]=t.progress,e[2]=c):c=e[2],c}let s,i;e[3]!==t.kind?(s=n.jsx(b1,{kind:t.kind}),i=n.jsx(S1,{kind:t.kind}),e[3]=t.kind,e[4]=s,e[5]=i):(s=e[4],i=e[5]);let r;e[6]!==t?(r=n.jsx(y1,{...t}),e[6]=t,e[7]=r):r=e[7];let o;e[8]!==t.kind||e[9]!==t.progress?(o=(t.kind==="errored"||t.kind==="dev-script-failed")&&n.jsx(w1,{progress:t.progress}),e[8]=t.kind,e[9]=t.progress,e[10]=o):o=e[10];let a;e[11]!==t.drawerOpen||e[12]!==t.kind||e[13]!==t.logSource?(a=(t.kind==="errored"||t.kind==="dev-script-failed")&&!t.drawerOpen&&n.jsx(C1,{source:t.logSource}),e[11]=t.drawerOpen,e[12]=t.kind,e[13]=t.logSource,e[14]=a):a=e[14];let l;e[15]!==t?(l=n.jsx(k1,{...t}),e[15]=t,e[16]=l):l=e[16];let h;return e[17]!==s||e[18]!==i||e[19]!==r||e[20]!==o||e[21]!==a||e[22]!==l?(h=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,o,a,l]})}),e[17]=s,e[18]=i,e[19]=r,e[20]=o,e[21]=a,e[22]=l,e[23]=h):h=e[23],h}function b1(t){const e=F.c(5),{kind:s}=t;switch(s){case"never-started":{let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Sl,{className:te("size-12","text-muted-foreground/60")}),e[0]=i):i=e[0],i}case"errored":{let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Xs,{className:te("size-12","text-destructive")}),e[1]=i):i=e[1],i}case"dev-script-failed":{let i;return e[2]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Xs,{className:te("size-12","text-destructive")}),e[2]=i):i=e[2],i}case"suspended":{let i;return e[3]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Td,{className:te("size-12","text-blue-500")}),e[3]=i):i=e[3],i}case"crashed":{let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Xs,{className:te("size-12","text-amber-500")}),e[4]=i):i=e[4],i}}}function S1(t){const e=F.c(4),{kind:s}=t;let i;e[0]!==s?(i=Gp(s),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=n.jsx("h3",{className:"text-lg font-medium",children:i}),e[2]=i,e[3]=r):r=e[3],r}function y1(t){const e=F.c(7);switch(t.kind){case"never-started":{let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:"Start the sandbox to launch your dev environment."}),e[0]=s):s=e[0],s}case"errored":{let s;return e[1]!==t.errorLine?(s=n.jsx("p",{role:"alert",className:"max-w-sm break-words text-sm text-destructive/80",children:t.errorLine}),e[1]=t.errorLine,e[2]=s):s=e[2],s}case"dev-script-failed":{let s;return e[3]!==t.errorLine?(s=n.jsx("p",{role:"alert",className:"max-w-sm break-words text-sm text-destructive/80",children:t.errorLine}),e[3]=t.errorLine,e[4]=s):s=e[4],s}case"suspended":{let s;return e[5]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:"Suspended after 30 min idle to conserve resources. Resume to continue where you left off."}),e[5]=s):s=e[5],s}case"crashed":{let s;return e[6]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:"The dev server stopped responding. Open the terminal to inspect the logs and restart it."}),e[6]=s):s=e[6],s}}}function w1(t){const e=F.c(21),{progress:s}=t;let i;e[0]!==s?(i=Ti(s,"provision"),e[0]=s,e[1]=i):i=e[1];let r;e[2]!==i?(r=n.jsx(Li,{label:"provision",status:i}),e[2]=i,e[3]=r):r=e[3];let o;e[4]!==s?(o=Ti(s,"cloning"),e[4]=s,e[5]=o):o=e[5];let a;e[6]!==o?(a=n.jsx(Li,{label:"cloning",status:o}),e[6]=o,e[7]=a):a=e[7];let l;e[8]!==s?(l=Ti(s,"install"),e[8]=s,e[9]=l):l=e[9];let h;e[10]!==l?(h=n.jsx(Li,{label:"install",status:l}),e[10]=l,e[11]=h):h=e[11];let c;e[12]!==s?(c=Ti(s,"dev"),e[12]=s,e[13]=c):c=e[13];let d;e[14]!==c?(d=n.jsx(Li,{label:"dev",status:c}),e[14]=c,e[15]=d):d=e[15];let u;return e[16]!==r||e[17]!==a||e[18]!==h||e[19]!==d?(u=n.jsx("div",{className:"flex w-full flex-col gap-1 rounded-lg border border-border bg-muted/30 px-4 py-3 text-left",children:n.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs font-medium",children:[r,a,h,d]})}),e[16]=r,e[17]=a,e[18]=h,e[19]=d,e[20]=u):u=e[20],u}function Li(t){const e=F.c(12),{label:s,status:i}=t;let r;e[0]!==i?(r=qp(i),e[0]=i,e[1]=r):r=e[1];const o=r,a=i==="done"?"text-emerald-600":i==="failed"?"text-destructive":i==="doing"?"text-amber-500":"text-muted-foreground/60";let l;e[2]!==a?(l=te("flex items-center gap-1.5",a),e[2]=a,e[3]=l):l=e[3];let h;e[4]!==o?(h=n.jsx("span",{"aria-hidden":!0,children:o}),e[4]=o,e[5]=h):h=e[5];let c;e[6]!==s?(c=n.jsx("span",{children:s}),e[6]=s,e[7]=c):c=e[7];let d;return e[8]!==l||e[9]!==h||e[10]!==c?(d=n.jsxs("span",{className:l,children:[h,c]}),e[8]=l,e[9]=h,e[10]=c,e[11]=d):d=e[11],d}function C1(t){const e=F.c(2),{source:s}=t;let i;return e[0]!==s?(i=n.jsx("div",{className:"flex w-[min(78%,560px)] flex-col items-stretch gap-1.5",children:n.jsx("div",{className:"h-32 overflow-hidden rounded-md [&_.xterm-viewport::-webkit-scrollbar]:hidden [&_.xterm-viewport]:!overflow-hidden",children:n.jsx(th,{source:s,className:"h-full"})})}),e[0]=s,e[1]=i):i=e[1],i}function k1(t){const e=F.c(25);switch(t.kind){case"never-started":{let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(os,{className:"size-4"}),e[0]=s):s=e[0];let i;return e[1]!==t.onStart?(i=n.jsxs(Q,{onClick:t.onStart,className:"mt-2",children:[s," Start sandbox"]}),e[1]=t.onStart,e[2]=i):i=e[2],i}case"errored":{let s;e[3]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(ns,{className:"size-4"}),e[3]=s):s=e[3];let i;return e[4]!==t.onRetry?(i=n.jsxs(Q,{size:"sm",onClick:t.onRetry,className:"mt-2",children:[s," Retry"]}),e[4]=t.onRetry,e[5]=i):i=e[5],i}case"dev-script-failed":{let s;e[6]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(ns,{className:"size-4"}),e[6]=s):s=e[6];let i;e[7]!==t.onRetry?(i=n.jsxs(Q,{size:"sm",onClick:t.onRetry,children:[s," Retry"]}),e[7]=t.onRetry,e[8]=i):i=e[8];let r;e[9]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(yl,{className:"size-4"}),e[9]=r):r=e[9];let o;e[10]!==t.onBrowseFiles?(o=n.jsxs(Q,{size:"sm",variant:"outline",onClick:t.onBrowseFiles,children:[r," Browse files"]}),e[10]=t.onBrowseFiles,e[11]=o):o=e[11];let a;e[12]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(qr,{className:"size-4"}),e[12]=a):a=e[12];let l;e[13]!==t.onOpenTerminal?(l=n.jsxs(Q,{size:"sm",variant:"outline",onClick:t.onOpenTerminal,children:[a," View logs"]}),e[13]=t.onOpenTerminal,e[14]=l):l=e[14];let h;return e[15]!==i||e[16]!==o||e[17]!==l?(h=n.jsxs("div",{className:"mt-2 flex flex-wrap items-center justify-center gap-2",children:[i,o,l]}),e[15]=i,e[16]=o,e[17]=l,e[18]=h):h=e[18],h}case"suspended":{let s;e[19]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(os,{className:"size-4"}),e[19]=s):s=e[19];let i;return e[20]!==t.onResume?(i=n.jsxs(Q,{onClick:t.onResume,className:"mt-2",children:[s," Resume"]}),e[20]=t.onResume,e[21]=i):i=e[21],i}case"crashed":{let s;e[22]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(qr,{className:"size-4"}),e[22]=s):s=e[22];let i;return e[23]!==t.onOpenTerminal?(i=n.jsxs(Q,{onClick:t.onOpenTerminal,className:"mt-2",children:[s," Open terminal"]}),e[23]=t.onOpenTerminal,e[24]=i):i=e[24],i}}}const j1=["dev","start"],is="setup";function N1(t){const e=F.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===is?t.onToggle():t.onSelectTab(is)},e[5]=t,e[6]=r):r=e[6];const o=r,a=t.active===is;let l;e[7]!==o||e[8]!==t.open||e[9]!==a?(l=n.jsx(E1,{active:a,open:t.open,onClick:o}),e[7]=o,e[8]=t.open,e[9]=a,e[10]=l):l=e[10];let h;e[11]!==t?(h=t.scriptTabs.map(m=>n.jsx(R1,{active:t.active===m,onClick:()=>t.onSelectTab(m),onClose:()=>t.onCloseScript(m),children:m},m)),e[11]=t,e[12]=h):h=e[12];let c;e[13]!==i||e[14]!==t.onAddScript?(c=n.jsx(P1,{scripts:i,onRun:t.onAddScript}),e[13]=i,e[14]=t.onAddScript,e[15]=c):c=e[15];let d;e[16]!==l||e[17]!==h||e[18]!==c?(d=n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:[l,h,c]}),e[16]=l,e[17]=h,e[18]=c,e[19]=d):d=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(D1,{isRunning:t.scriptIsRunning,isKilling:t.scriptIsKilling,onRun:t.onRunActiveScript,onStop:t.onStopActiveScript}):n.jsx(T1,{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]!==d||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:[d,u]}),e[32]=d,e[33]=u,e[34]=f):f=e[34],f}function E1(t){const e=F.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 h;e[0]!==l?(h=te("flex h-7 items-center gap-1.5 rounded-md border px-2.5 text-xs",l),e[0]=l,e[1]=h):h=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(qr,{className:"size-3.5"}),e[2]=c):c=e[2];let d;return e[3]!==r||e[4]!==o||e[5]!==a||e[6]!==h?(d=n.jsxs("button",{type:"button","aria-pressed":o,"aria-expanded":a,onClick:r,className:h,children:[c,"sandbox"]}),e[3]=r,e[4]=o,e[5]=a,e[6]=h,e[7]=d):d=e[7],d}function T1(t){const e=F.c(24),{status:s,onStart:i,onStop:r,onRestart:o,onResume:a,onRetry:l}=t;if(s==="idle"&&i){let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(os,{className:"size-3.5"}),e[0]=h):h=e[0];let c;return e[1]!==i?(c=n.jsxs(Q,{variant:"outline",size:"sm",onClick:i,children:[h," Start"]}),e[1]=i,e[2]=c):c=e[2],c}if(s==="suspended"&&a){let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(os,{className:"size-3.5"}),e[3]=h):h=e[3];let c;return e[4]!==a?(c=n.jsxs(Q,{variant:"outline",size:"sm",onClick:a,children:[h," Resume"]}),e[4]=a,e[5]=c):c=e[5],c}if(s==="errored"&&l){let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(ns,{className:"size-3.5"}),e[6]=h):h=e[6];let c;return e[7]!==l?(c=n.jsxs(Q,{variant:"outline",size:"sm",onClick:l,children:[h," Retry"]}),e[7]=l,e[8]=c):c=e[8],c}if(s==="starting"||s==="running"){const h=s==="running"&&!!o,c=h?"rounded-r-none border-r-0":void 0;let d;e[9]!==c?(d=te(c),e[9]=c,e[10]=d):d=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(wl,{className:"size-3.5"}),e[11]=u):u=e[11];let f;e[12]!==r||e[13]!==d?(f=n.jsx(Te,{asChild:!0,children:n.jsxs(Q,{variant:"outline",size:"sm",onClick:r,className:d,children:[u," Stop"]})}),e[12]=r,e[13]=d,e[14]=f):f=e[14];let m;e[15]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(Re,{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 _;e[18]!==o||e[19]!==h?(_=h&&n.jsxs(mi,{children:[n.jsx(pi,{asChild:!0,children:n.jsx(Q,{variant:"outline",size:"sm",className:"rounded-l-none px-1",children:n.jsx(co,{className:"size-3"})})}),n.jsx(_i,{align:"end",children:n.jsxs(Dt,{onClick:o,children:[n.jsx(ns,{className:"size-3.5"})," Restart"]})})]}),e[18]=o,e[19]=h,e[20]=_):_=e[20];let g;return e[21]!==p||e[22]!==_?(g=n.jsxs("div",{className:"flex items-center",children:[p,_]}),e[21]=p,e[22]=_,e[23]=g):g=e[23],g}return null}function R1(t){const e=F.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=te("flex h-7 items-center rounded-md border text-xs",a),e[0]=a,e[1]=l):l=e[1];const h=r?"pl-2.5 pr-1":"px-2.5",c=s?"font-medium text-foreground":"text-muted-foreground hover:text-foreground";let d;e[2]!==h||e[3]!==c?(d=te("flex h-full items-center",h,c),e[2]=h,e[3]=c,e[4]=d):d=e[4];let u;e[5]!==o||e[6]!==i||e[7]!==d?(u=n.jsx("button",{type:"button",onClick:i,className:d,children:o}),e[5]=o,e[6]=i,e[7]=d,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(wu,{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 P1(t){const e=F.c(10),{scripts:s,onRun:i}=t,[r,o]=D.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs(Pe,{children:[n.jsx(Te,{asChild:!0,children:n.jsx(hi,{asChild:!0,children:n.jsx(Q,{variant:"ghost",size:"sm","aria-label":"Run script",children:n.jsx(Ut,{className:"size-3.5"})})})}),n.jsx(Re,{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 h;e[2]!==i||e[3]!==s?(h=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]=h):h=e[4];let c;e[5]!==h?(c=n.jsxs(di,{align:"start",className:"p-1 w-56",children:[l,h]}),e[5]=h,e[6]=c):c=e[6];let d;return e[7]!==r||e[8]!==c?(d=n.jsxs(ci,{open:r,onOpenChange:o,children:[a,c]}),e[7]=r,e[8]=c,e[9]=d):d=e[9],d}function D1(t){const e=F.c(13),{isRunning:s,isKilling:i,onRun:r,onStop:o}=t;if(i){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsxs(Q,{variant:"outline",size:"sm",disabled:!0,children:[n.jsx(Se,{className:"size-3.5 animate-spin"})," Stopping…"]}),e[0]=d):d=e[0],d}if(!s){let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(os,{className:"size-3.5"}),e[1]=d):d=e[1];let u;e[2]!==r?(u=n.jsx(Te,{asChild:!0,children:n.jsxs(Q,{variant:"outline",size:"sm",onClick:r,children:[d," Run"]})}),e[2]=r,e[3]=u):u=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(Re,{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(wl,{className:"size-3.5"}),e[7]=a):a=e[7];let l;e[8]!==o?(l=n.jsx(Te,{asChild:!0,children:n.jsxs(Q,{variant:"outline",size:"sm",onClick:o,children:[a," Stop"]})}),e[8]=o,e[9]=l):l=e[9];let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Re,{children:"Stop process"}),e[10]=h):h=e[10];let c;return e[11]!==l?(c=n.jsxs(Pe,{children:[l,h]}),e[11]=l,e[12]=c):c=e[12],c}function A1(t){const e=Es(),[s,i]=D.useState(is),[r,o]=D.useState([]),[a,l]=D.useState(new Set),h=D.useRef(!1);if(!h.current&&e.scripts.length>0){const b=j1.find(y=>e.scripts.includes(y));b&&(h.current=!0,o(y=>y.includes(b)?y:[...y,b]),i(b))}if(a.size>0){let b=!1;const y=new Set(a);for(const w of a)e.activeProcesses.includes(w)||(y.delete(w),b=!0);b&&l(y)}const c=()=>t.onOpenChange(!t.open),d=b=>{i(b),t.open||t.onOpenChange(!0)},u=b=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(`/api/${encodeURIComponent(t.orgSlug)}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/exec/${encodeURIComponent(b)}`,{method:"POST"}),f=b=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(`/api/${encodeURIComponent(t.orgSlug)}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/exec/${encodeURIComponent(b)}/kill`,{method:"POST"}),m=async b=>{o(y=>y.includes(b)?y:[...y,b]),i(b),t.onOpenChange(!0);try{const y=await u(b);if(y===null)return;if(!y.ok)throw new Error(`Exec failed: ${y.statusText}`)}catch{ae.error("Failed to run "+b)}},p=async b=>{await f(b),o(y=>y.filter(w=>w!==b)),s===b&&i(is)},_=async()=>{const b=e.activeProcesses.includes(s);try{const y=await u(s);if(y===null)return;if(!y.ok)throw new Error(`Exec failed: ${y.statusText}`)}catch{ae.error((b?"Failed to restart ":"Failed to run ")+s)}},g=async()=>{if(!a.has(s)){l(b=>new Set(b).add(s));try{const b=await f(s);if(b===null){l(y=>{const w=new Set(y);return w.delete(s),w});return}if(!b.ok)throw new Error(`Kill failed: ${b.statusText}`)}catch{l(b=>{const y=new Set(b);return y.delete(s),y}),ae.error("Failed to stop "+s)}}},x=s!==is&&r.includes(s),S=x&&e.activeProcesses.includes(s),v=x&&a.has(s);return n.jsxs("div",{className:"flex shrink-0 flex-col",style:{height:t.open?"50%":"auto"},children:[n.jsx(N1,{status:t.status,open:t.open,onToggle:c,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:d,onAddScript:m,onCloseScript:p,showScriptControls:x,scriptIsRunning:S,scriptIsKilling:v,onRunActiveScript:_,onStopActiveScript:g}),t.open&&n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(I1,{vmId:t.vmId,active:s,hasData:e.hasData(s),onRunActive:_})})]})}function I1(t){const e=F.c(10),{vmId:s,active:i,hasData:r,onRunActive:o}=t;if(!s)return null;if(i===is||r){let d;return e[0]!==i?(d=n.jsx(th,{source:i,className:"h-full"},i),e[0]=i,e[1]=d):d=e[1],d}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(os,{className:"size-3.5"}),e[4]=l):l=e[4];let h;e[5]!==o?(h=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]=h):h=e[6];let c;return e[7]!==a||e[8]!==h?(c=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 text-sm text-muted-foreground",children:[a,h]}),e[7]=a,e[8]=h,e[9]=c):c=e[9],c}const sh=t=>`preview-drawer:${t}`;function M1(t){try{const e=localStorage.getItem(sh(t));return e?!!JSON.parse(e).open:!1}catch{return!1}}function B1(t,e){try{localStorage.setItem(sh(t),JSON.stringify({open:e}))}catch{}}const L1=D.lazy(()=>Gn(()=>import("./sections-editor-BaR1msLz.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])).then(t=>({default:t.SectionsEditor}))),O1=D.lazy(()=>Gn(()=>import("./file-explorer-DB2RMOmR.js"),__vite__mapDeps([136,1,2,4,5,6,7,8,9,10,3,12,13,14,15,16,11,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,64,65,57,66,67,68,69,70,71,79,80,53,81,82,83,63,72,73,74,75,76,77,78,84,85,86,51,49,87,88,55,89,90,91,54,92,93,94,95,58,61,62,96,59,60,97,47,98,99,100,101,102,103,104,105,106,107,108,50,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,52,130,131,132,133,134,135])).then(t=>({default:t.FileExplorer}))),Za=500;function $1(t,e){return t.kind==="errored"?"errored":t.kind==="suspended"?"suspended":t.kind==="starting-now"||e?"starting":t.kind==="iframe"||t.kind==="no-html"||t.kind==="crashed"?"running":"idle"}function z1(){const t=uh(),{data:e}=ir.useSession(),{taskId:s,currentBranch:i,setCurrentTaskBranch:r}=ds(),[o,a]=D.useState("preview"),[l,h]=D.useState(null),c=D.useRef(null),d=o==="cms",[u,f]=D.useState(null),[m,p]=D.useState(384),_=D.useRef(!1),g=D.useRef(0),x=D.useRef(0),S=D.useRef(null),[v,b]=D.useState(!1),[y,w]=D.useState(""),k=D.useRef(null),[j,T]=D.useState(!1),[P,R]=D.useState(),[C,N]=D.useState(null),[B,I]=D.useState(null),[E,M]=D.useState("/"),A=e?.user?.id,L=t?.entity?.metadata,H=A&&i?Yn(L?.sandboxMap?.[A]?.[i]):{},$=Object.values(H),z=$.find(K=>K.sandboxProviderKind!=="user-desktop")??$[0],V=z?.previewUrl??null,q=t?.entity?.id??null,{org:ee}=ke(),G=Es(),Y=G.lifecycle.phase,O=Y==="running",X=q&&i&&O?{orgSlug:ee.slug,virtualMcpId:q,branch:i}:null,{data:J}=sp(X),{data:ie}=rp(X),oe=q&&i?{orgSlug:ee.slug,virtualMcpId:q,branch:i}:null,W=jp(oe),ne=J?_p(J).sort((K,he)=>K.name.localeCompare(he.name)):[],me=J&&ie?vp(J,ie):[],_e=xp,pe=ne.filter(K=>{if(!y)return!0;const he=y.toLowerCase();return K.name.toLowerCase().includes(he)||K.path.toLowerCase().includes(he)}),xe=me.filter(K=>{if(!y)return!0;const he=y.toLowerCase();return K.name.toLowerCase().includes(he)||K.key.toLowerCase().includes(he)||K.resolveType.toLowerCase().includes(he)}),le=C?C.name:ne.find(K=>_e(K.path)===_e(E))?.name,re=D.useRef(null),ce=D.useRef(null);Up(()=>{const K=c.current,he=re.current;!K||!he||(K.src=he)});const ge=D.useRef({url:"",value:!1});V&&ge.current.url!==V&&(ge.current={url:V,value:!1}),G.lifecycle.phase==="running"&&(ge.current.value=G.lifecycle.htmlSupport);const be=ge.current.value,qe=Y==="running"?"online":Y==="crashed"?"offline":"booting",yi=G.suspended,Vt=G.status.state==="paused",qt=Je({connectionId:Ns,orgId:t?.entity?.organization_id??"",orgSlug:ee.slug}),Et=ml(qt),Gt=Et.error?.message??null,wi=Oh(q??void 0,i??void 0),Yt=D.useRef(null),xr=D.useRef(null),Ci=G.phase,br=Vp({claimPhase:Ci,lifecycle:G.lifecycle}),ki=!!q&&!!i&&jr.isStopped(q,i),jo=Y==="start-failed"||Y==="install-failed"||Y==="clone-failed"?Y:null,fh=jo&&"error"in G.lifecycle?G.lifecycle.error??null:null,we=Kp({previewUrl:V,status:qe,htmlSupport:be,suspended:yi,appPaused:Vt,vmStartPending:wi,lastStartError:Gt,lifecycleFailure:jo,lifecycleFailureError:fh,claimPhase:Ci,notFound:G.notFound,userStopped:ki}),_t=we.kind==="iframe"?B??new URL(E,we.previewUrl).href:null,[No,mh]=D.useState(null);if(we.kind==="iframe"&&No!==we.previewUrl){const K=No!==null;mh(we.previewUrl),K&&(ce.current=null,M("/"),I(null),N(null))}re.current=_t;const Sr=!!q&&!!i&&!G.notFound&&!ki&&!yi&&!Vt&&(Ci?.kind==="ready"||Y!=="idle"),yr=we.kind!=="iframe"&&(o==="visual"||o==="cms")?"preview":o,ji=K=>{if(!q)return;const he={virtualMcpId:q};i&&(he.branch=i),Et.mutate(he,{onSuccess:De=>{De?.branch&&!i&&r(De.branch)},onError:De=>{console.error(`[preview] ${K} SANDBOX_START failed`,De)}})},Is=D.useRef(ji);Is.current=ji,s&&z&&Yt.current!==s&&(Yt.current=s);const Eo=!!s&&!!q&&!!A&&!!i&&!z&&!Gt&&!ki&&!Et.isPending&&Yt.current!==s;D.useEffect(()=>{!Eo||!s||(Yt.current=s,Is.current("auto-start"))},[Eo,s,ki]);const Ni=G.notFound?z?.sandboxHandle??null:null;D.useEffect(()=>{!Ni||!q||Gt||Et.isPending||xr.current!==Ni&&(i&&jr.isStopped(q,i)||(xr.current=Ni,Is.current("self-heal")))},[Ni,q,Gt,Et.isPending,i]);const Ms=()=>{Yt.current=null,xr.current=null,Et.reset(),Is.current("auto-start")},ph=Vn(),Ei=q??"__no-vmcp__",[_h,To]=D.useState(null),Ro=D.useRef(null);Ro.current!==Ei&&(Ro.current=Ei,To(M1(Ei)));const wr=we.kind==="never-started"?!1:_h??!1,Cr=K=>{To(K),B1(Ei,K)},kr=()=>Cr(!0),Po=async()=>{if(!q)return;const K=i;if(!K)return;const he=z?.sandboxProviderKind;if(he){jr.mark(q,K);try{await qt.callTool({name:"SANDBOX_DELETE",arguments:{virtualMcpId:q,branch:K,sandboxProviderKind:he}})}catch{}Ih(ph)}},gh=async()=>{await Po(),Is.current("auto-start")};D.useEffect(()=>{if(!V)return;let K;try{K=new URL(V,window.location.href).origin}catch{return}const he=De=>{if(De.origin===K){if(De.data?.type==="visual-editor::element-clicked"){const Ge=Ep.safeParse(De.data.payload);Ge.success&&h(Ge.data)}else if(De.data?.type==="cms-editor::section-clicked"){const Ge=Rp.safeParse(De.data.payload);Ge.success&&f(Ge.data.sectionIndex)}}};return window.addEventListener("message",he),()=>window.removeEventListener("message",he)},[V]),D.useEffect(()=>{if(!v)return;const K=he=>{k.current?.contains(he.target)||(b(!1),w(""))};return document.addEventListener("pointerdown",K),()=>document.removeEventListener("pointerdown",K)},[v]),D.useEffect(()=>{if(!d)return;const K=De=>{const Ge=De.target;Ge&&Ge!==c.current&&(S.current=Ge)},he=()=>{requestAnimationFrame(()=>{const De=document.activeElement;(De===document.body||De===c.current)&&S.current&&S.current.focus()})};return document.addEventListener("focusin",K),document.addEventListener("blur",he,!0),()=>{document.removeEventListener("focusin",K),document.removeEventListener("blur",he,!0)}},[d]);const Do=()=>{const K=c.current?.contentWindow;K&&K.postMessage({type:"visual-editor::activate",script:Tp},"*")},vh=()=>{const K=c.current?.contentWindow;K&&K.postMessage({type:"visual-editor::deactivate"},"*")},Ao=()=>{const K=c.current?.contentWindow;K&&K.postMessage({type:"visual-editor::activate",script:Pp},"*")},xh=()=>{const K=c.current?.contentWindow;K&&K.postMessage({type:"cms-editor::deactivate"},"*")},Io=K=>{const he=o;a(K),h(null),K!=="cms"&&f(null),he==="visual"&&vh(),he==="cms"&&xh(),K==="visual"&&Do(),K==="cms"&&Ao()},bh=()=>{if(!c.current||!_t)return;const K=c.current;K.src=_t},Sh=()=>{if(!c.current||!_t)return;const K=_t.includes("?")?"&":"?";c.current.src=`${_t}${K}_r=${Date.now()}`},yh=()=>{const K=c.current?.contentWindow?.location?.href??_t??V;K&&navigator.clipboard.writeText(K)},wh=(()=>{if(!V)return"No server running";if(C)return C.name;try{const K=new URL(V),he=E==="/"?"":E;return`${K.host}${he}`}catch{return V}})(),Mo=K=>{ce.current=K,N(null),I(null),M(K),f(null)},Ch=K=>{if(!V||!ie){ae.error("Preview metadata not ready yet");return}ce.current=null;const he=ic(ie),De=Sp(V,he,K.key);N(K),I(De),f(null)},kh=async({name:K,path:he})=>{if(!q||!i)return;const De=nc(he);if(De){R(De);return}const Ge=he.trim().startsWith("/")?he.trim():`/${he.trim()}`;if(ne.some(Tt=>_e(Tt.path)===_e(Ge))){R(`A page with path "${Ge}" already exists.`);return}R(void 0);try{const Tt=await W.mutateAsync({name:K,path:Ge});T(!1),ae.success(`Page "${K}" created`),await new Promise(Nh=>setTimeout(Nh,Za)),Mo(Tt.path),Io("cms")}catch(Tt){R(Tt instanceof Error?Tt.message:"Failed to create page")}},jh=[{value:"preview",icon:n.jsx(Sl,{size:14}),tooltip:"Interactive"},...we.kind==="iframe"?[{value:"visual",icon:n.jsx(Ho,{size:14}),tooltip:"Visual editor"}]:[],...we.kind==="iframe"&&(ne.length>0||me.length>0)?[{value:"cms",icon:n.jsx(Rd,{size:14}),tooltip:"Sections editor"}]:[],{value:"code",icon:n.jsx(yl,{size:14}),tooltip:"Code editor"}];return n.jsxs("div",{className:"flex flex-col w-full h-full",children:[Sr&&n.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-4 border-b border-border/60 px-3 md:px-4",children:[n.jsx("div",{className:"flex shrink-0 items-center gap-1",children:n.jsx(yu,{value:yr,onValueChange:Io,options:jh,size:"sm",className:"shrink-0 bg-foreground/4.5"})}),we.kind==="iframe"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:te("flex min-w-0 flex-1 items-center gap-0.5",o==="code"&&"hidden"),children:[n.jsxs(Pe,{children:[n.jsx(Te,{asChild:!0,children:n.jsx(Q,{variant:"ghost",size:"icon",onClick:bh,children:n.jsx(ns,{size:14})})}),n.jsx(Re,{side:"bottom",children:"Refresh"})]}),n.jsxs("div",{ref:k,className:"relative min-w-0 flex-1",children:[n.jsxs("button",{type:"button",className:"flex h-8 w-full min-w-0 items-center gap-1 rounded-md bg-background px-2 transition-colors duration-200 hover:bg-accent",onClick:()=>b(K=>!K),children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-left text-[12px] text-foreground/88",children:wh}),le&&!C&&n.jsx("span",{className:"shrink-0 text-[12px] text-muted-foreground",children:le}),n.jsx(co,{size:12,className:te("shrink-0 text-muted-foreground transition-transform",v&&"rotate-180")})]}),v&&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.jsx("div",{className:"px-2 pt-2 pb-1",children:n.jsx("input",{type:"text",value:y,onChange:K=>w(K.target.value),placeholder:"Search pages and components...",className:"w-full rounded-md border border-input bg-transparent px-2.5 py-1.5 text-xs outline-none placeholder:text-muted-foreground focus:ring-1 focus:ring-ring",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:K=>{K.preventDefault(),b(!1),w(""),R(void 0),T(!0)},children:[n.jsx(Ut,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"flex-1 font-medium",children:"Create new page"})]})}),pe.length===0&&xe.length===0?n.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:ne.length===0&&me.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:[pe.length>0&&n.jsx("div",{className:"p-1.5",children:pe.map(K=>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:he=>{he.preventDefault(),b(!1),w(""),Mo(K.path)},children:[n.jsx(Pd,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:K.name}),n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:K.path})]},K.key))}),xe.length>0&&n.jsxs("div",{className:te("p-1.5",pe.length>0&&"border-t"),children:[n.jsx("div",{className:"px-3 py-2 text-xs font-medium text-muted-foreground",children:"Global components"}),xe.map(K=>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:he=>{he.preventDefault(),b(!1),w(""),Ch(K)},children:[n.jsx(Su,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:K.name}),n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:K.resolveType.split("/").pop()?.replace(/\.tsx?$/,"")})]},K.key))]})]})]})]})]}),n.jsxs("div",{className:te("flex shrink-0 items-center gap-0.5",o==="code"&&"hidden"),children:[n.jsxs(Pe,{children:[n.jsx(Te,{asChild:!0,children:n.jsx(Q,{variant:"ghost",size:"icon",onClick:()=>{const K=_t??we.previewUrl;K&&window.open(K,"_blank","noopener")},children:n.jsx(ms,{size:14})})}),n.jsx(Re,{side:"bottom",children:"Open in new tab"})]}),n.jsxs(mi,{children:[n.jsx(pi,{asChild:!0,children:n.jsx(Q,{variant:"ghost",size:"icon",children:n.jsx(ro,{size:14})})}),n.jsxs(_i,{align:"end",children:[n.jsx(Dt,{onClick:Sh,children:"Hard Reload"}),n.jsx(Dt,{onClick:yh,children:"Copy Current URL"})]})]})]})]})]}),n.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[d&&V&&i&&q&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"shrink-0 border-r overflow-hidden",style:{width:m},children:n.jsx(D.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(Se,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(L1,{orgSlug:ee.slug,virtualMcpId:q,branch:i,previewReady:O,previewUrl:V,currentPath:E,activeGlobalBlockKey:C?.key??null,externalSelectedIndex:C?null:u,onSaved:()=>{setTimeout(()=>{const K=c.current;if(!K)return;const he=document.activeElement,De=K.tabIndex;K.tabIndex=-1,K.style.pointerEvents="none",K.blur();try{K.contentWindow?.location.reload()}catch{const Tt=re.current;Tt&&(K.src=Tt)}const Ge=()=>{K.tabIndex=De,K.style.pointerEvents="",he?.focus(),K.removeEventListener("load",Ge)};K.addEventListener("load",Ge),setTimeout(Ge,3e3)},Za)}})})}),n.jsx("div",{className:"w-1 shrink-0 cursor-col-resize bg-transparent hover:bg-border transition-colors",onPointerDown:K=>{_.current=!0,g.current=K.clientX,x.current=m,K.currentTarget.setPointerCapture(K.pointerId)},onPointerMove:K=>{if(!_.current)return;const he=K.clientX-g.current;p(Math.max(240,Math.min(640,x.current+he)))},onPointerUp:()=>{_.current=!1}})]}),n.jsxs("div",{className:"flex-1 relative overflow-hidden",children:[we.kind==="never-started"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Ss,{kind:"never-started",onStart:()=>{Cr(!1),ji("auto-start")}})}),we.kind==="starting-now"&&!(o==="code"&&Sr)&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Ss,{kind:"starting-now",progress:br,claimPhase:Ci})}),we.kind==="errored"&&n.jsx("div",{className:"absolute inset-0 z-40",children:n.jsx(Ss,{kind:"errored",progress:br,logSource:"setup",errorLine:we.error.split(`
|
|
286
|
+
`,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 ln.get()},set promptLabel(t){ln.set(t)},get tooMuchOutput(){return cn.get()},set tooMuchOutput(t){cn.set(t)}}}_verifyIntegers(...t){for(vt of t)if(vt===1/0||isNaN(vt)||vt%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(vt of t)if(vt&&(vt===1/0||isNaN(vt)||vt%1!==0||vt<0))throw new Error("This API only accepts positive integers")}};var g1=2,v1=1,x1=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,h=a.right+a.left,c=i-l,d=r-h-e;return{cols:Math.max(g1,Math.floor(d/t.css.cell.width)),rows:Math.max(v1,Math.floor(c/t.css.cell.height))}}};function th({source:t,onReady:e,onSelectionChange:s,className:i}){const r=D.useRef(null),o=D.useRef(null),a=D.useRef(s);a.current=s;const l=Es(),h=D.useRef(t);return h.current=t,Wp((c,d)=>{c===h.current&&o.current?.write(d)}),D.useEffect(()=>{const c=r.current;if(!c)return;const d=getComputedStyle(document.documentElement),u=x=>d.getPropertyValue(x).trim()||void 0,f=new _1({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 x1;f.loadAddon(m),f.open(c),m.fit();const p=l.getBuffer(t);p&&f.write(p),o.current=f,e?.(f);const _=f.onSelectionChange(()=>{const x=!!f.getSelection();a.current?.(x,()=>f.getSelection())}),g=new ResizeObserver(()=>{m.fit()});return g.observe(c),()=>{_.dispose(),g.disconnect(),o.current=null,f.dispose()}},[]),n.jsx("div",{className:te("h-full bg-sidebar p-3",i),children:n.jsx("div",{ref:r,className:"h-full"})})}function Ss(t){const e=F.c(24);if(t.kind==="starting-now"){let c;return e[0]!==t.claimPhase||e[1]!==t.progress?(c=n.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:n.jsx(t_,{progress:t.progress,claimPhase:t.claimPhase})}),e[0]=t.claimPhase,e[1]=t.progress,e[2]=c):c=e[2],c}let s,i;e[3]!==t.kind?(s=n.jsx(b1,{kind:t.kind}),i=n.jsx(S1,{kind:t.kind}),e[3]=t.kind,e[4]=s,e[5]=i):(s=e[4],i=e[5]);let r;e[6]!==t?(r=n.jsx(y1,{...t}),e[6]=t,e[7]=r):r=e[7];let o;e[8]!==t.kind||e[9]!==t.progress?(o=(t.kind==="errored"||t.kind==="dev-script-failed")&&n.jsx(w1,{progress:t.progress}),e[8]=t.kind,e[9]=t.progress,e[10]=o):o=e[10];let a;e[11]!==t.drawerOpen||e[12]!==t.kind||e[13]!==t.logSource?(a=(t.kind==="errored"||t.kind==="dev-script-failed")&&!t.drawerOpen&&n.jsx(C1,{source:t.logSource}),e[11]=t.drawerOpen,e[12]=t.kind,e[13]=t.logSource,e[14]=a):a=e[14];let l;e[15]!==t?(l=n.jsx(k1,{...t}),e[15]=t,e[16]=l):l=e[16];let h;return e[17]!==s||e[18]!==i||e[19]!==r||e[20]!==o||e[21]!==a||e[22]!==l?(h=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,o,a,l]})}),e[17]=s,e[18]=i,e[19]=r,e[20]=o,e[21]=a,e[22]=l,e[23]=h):h=e[23],h}function b1(t){const e=F.c(5),{kind:s}=t;switch(s){case"never-started":{let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Sl,{className:te("size-12","text-muted-foreground/60")}),e[0]=i):i=e[0],i}case"errored":{let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Xs,{className:te("size-12","text-destructive")}),e[1]=i):i=e[1],i}case"dev-script-failed":{let i;return e[2]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Xs,{className:te("size-12","text-destructive")}),e[2]=i):i=e[2],i}case"suspended":{let i;return e[3]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Td,{className:te("size-12","text-blue-500")}),e[3]=i):i=e[3],i}case"crashed":{let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Xs,{className:te("size-12","text-amber-500")}),e[4]=i):i=e[4],i}}}function S1(t){const e=F.c(4),{kind:s}=t;let i;e[0]!==s?(i=Gp(s),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=n.jsx("h3",{className:"text-lg font-medium",children:i}),e[2]=i,e[3]=r):r=e[3],r}function y1(t){const e=F.c(7);switch(t.kind){case"never-started":{let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:"Start the sandbox to launch your dev environment."}),e[0]=s):s=e[0],s}case"errored":{let s;return e[1]!==t.errorLine?(s=n.jsx("p",{role:"alert",className:"max-w-sm break-words text-sm text-destructive/80",children:t.errorLine}),e[1]=t.errorLine,e[2]=s):s=e[2],s}case"dev-script-failed":{let s;return e[3]!==t.errorLine?(s=n.jsx("p",{role:"alert",className:"max-w-sm break-words text-sm text-destructive/80",children:t.errorLine}),e[3]=t.errorLine,e[4]=s):s=e[4],s}case"suspended":{let s;return e[5]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:"Suspended after 30 min idle to conserve resources. Resume to continue where you left off."}),e[5]=s):s=e[5],s}case"crashed":{let s;return e[6]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:"The dev server stopped responding. Open the terminal to inspect the logs and restart it."}),e[6]=s):s=e[6],s}}}function w1(t){const e=F.c(21),{progress:s}=t;let i;e[0]!==s?(i=Ti(s,"provision"),e[0]=s,e[1]=i):i=e[1];let r;e[2]!==i?(r=n.jsx(Li,{label:"provision",status:i}),e[2]=i,e[3]=r):r=e[3];let o;e[4]!==s?(o=Ti(s,"cloning"),e[4]=s,e[5]=o):o=e[5];let a;e[6]!==o?(a=n.jsx(Li,{label:"cloning",status:o}),e[6]=o,e[7]=a):a=e[7];let l;e[8]!==s?(l=Ti(s,"install"),e[8]=s,e[9]=l):l=e[9];let h;e[10]!==l?(h=n.jsx(Li,{label:"install",status:l}),e[10]=l,e[11]=h):h=e[11];let c;e[12]!==s?(c=Ti(s,"dev"),e[12]=s,e[13]=c):c=e[13];let d;e[14]!==c?(d=n.jsx(Li,{label:"dev",status:c}),e[14]=c,e[15]=d):d=e[15];let u;return e[16]!==r||e[17]!==a||e[18]!==h||e[19]!==d?(u=n.jsx("div",{className:"flex w-full flex-col gap-1 rounded-lg border border-border bg-muted/30 px-4 py-3 text-left",children:n.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs font-medium",children:[r,a,h,d]})}),e[16]=r,e[17]=a,e[18]=h,e[19]=d,e[20]=u):u=e[20],u}function Li(t){const e=F.c(12),{label:s,status:i}=t;let r;e[0]!==i?(r=qp(i),e[0]=i,e[1]=r):r=e[1];const o=r,a=i==="done"?"text-emerald-600":i==="failed"?"text-destructive":i==="doing"?"text-amber-500":"text-muted-foreground/60";let l;e[2]!==a?(l=te("flex items-center gap-1.5",a),e[2]=a,e[3]=l):l=e[3];let h;e[4]!==o?(h=n.jsx("span",{"aria-hidden":!0,children:o}),e[4]=o,e[5]=h):h=e[5];let c;e[6]!==s?(c=n.jsx("span",{children:s}),e[6]=s,e[7]=c):c=e[7];let d;return e[8]!==l||e[9]!==h||e[10]!==c?(d=n.jsxs("span",{className:l,children:[h,c]}),e[8]=l,e[9]=h,e[10]=c,e[11]=d):d=e[11],d}function C1(t){const e=F.c(2),{source:s}=t;let i;return e[0]!==s?(i=n.jsx("div",{className:"flex w-[min(78%,560px)] flex-col items-stretch gap-1.5",children:n.jsx("div",{className:"h-32 overflow-hidden rounded-md [&_.xterm-viewport::-webkit-scrollbar]:hidden [&_.xterm-viewport]:!overflow-hidden",children:n.jsx(th,{source:s,className:"h-full"})})}),e[0]=s,e[1]=i):i=e[1],i}function k1(t){const e=F.c(25);switch(t.kind){case"never-started":{let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(os,{className:"size-4"}),e[0]=s):s=e[0];let i;return e[1]!==t.onStart?(i=n.jsxs(Q,{onClick:t.onStart,className:"mt-2",children:[s," Start sandbox"]}),e[1]=t.onStart,e[2]=i):i=e[2],i}case"errored":{let s;e[3]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(ns,{className:"size-4"}),e[3]=s):s=e[3];let i;return e[4]!==t.onRetry?(i=n.jsxs(Q,{size:"sm",onClick:t.onRetry,className:"mt-2",children:[s," Retry"]}),e[4]=t.onRetry,e[5]=i):i=e[5],i}case"dev-script-failed":{let s;e[6]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(ns,{className:"size-4"}),e[6]=s):s=e[6];let i;e[7]!==t.onRetry?(i=n.jsxs(Q,{size:"sm",onClick:t.onRetry,children:[s," Retry"]}),e[7]=t.onRetry,e[8]=i):i=e[8];let r;e[9]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(yl,{className:"size-4"}),e[9]=r):r=e[9];let o;e[10]!==t.onBrowseFiles?(o=n.jsxs(Q,{size:"sm",variant:"outline",onClick:t.onBrowseFiles,children:[r," Browse files"]}),e[10]=t.onBrowseFiles,e[11]=o):o=e[11];let a;e[12]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(qr,{className:"size-4"}),e[12]=a):a=e[12];let l;e[13]!==t.onOpenTerminal?(l=n.jsxs(Q,{size:"sm",variant:"outline",onClick:t.onOpenTerminal,children:[a," View logs"]}),e[13]=t.onOpenTerminal,e[14]=l):l=e[14];let h;return e[15]!==i||e[16]!==o||e[17]!==l?(h=n.jsxs("div",{className:"mt-2 flex flex-wrap items-center justify-center gap-2",children:[i,o,l]}),e[15]=i,e[16]=o,e[17]=l,e[18]=h):h=e[18],h}case"suspended":{let s;e[19]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(os,{className:"size-4"}),e[19]=s):s=e[19];let i;return e[20]!==t.onResume?(i=n.jsxs(Q,{onClick:t.onResume,className:"mt-2",children:[s," Resume"]}),e[20]=t.onResume,e[21]=i):i=e[21],i}case"crashed":{let s;e[22]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(qr,{className:"size-4"}),e[22]=s):s=e[22];let i;return e[23]!==t.onOpenTerminal?(i=n.jsxs(Q,{onClick:t.onOpenTerminal,className:"mt-2",children:[s," Open terminal"]}),e[23]=t.onOpenTerminal,e[24]=i):i=e[24],i}}}const j1=["dev","start"],is="setup";function N1(t){const e=F.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===is?t.onToggle():t.onSelectTab(is)},e[5]=t,e[6]=r):r=e[6];const o=r,a=t.active===is;let l;e[7]!==o||e[8]!==t.open||e[9]!==a?(l=n.jsx(E1,{active:a,open:t.open,onClick:o}),e[7]=o,e[8]=t.open,e[9]=a,e[10]=l):l=e[10];let h;e[11]!==t?(h=t.scriptTabs.map(m=>n.jsx(R1,{active:t.active===m,onClick:()=>t.onSelectTab(m),onClose:()=>t.onCloseScript(m),children:m},m)),e[11]=t,e[12]=h):h=e[12];let c;e[13]!==i||e[14]!==t.onAddScript?(c=n.jsx(P1,{scripts:i,onRun:t.onAddScript}),e[13]=i,e[14]=t.onAddScript,e[15]=c):c=e[15];let d;e[16]!==l||e[17]!==h||e[18]!==c?(d=n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:[l,h,c]}),e[16]=l,e[17]=h,e[18]=c,e[19]=d):d=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(D1,{isRunning:t.scriptIsRunning,isKilling:t.scriptIsKilling,onRun:t.onRunActiveScript,onStop:t.onStopActiveScript}):n.jsx(T1,{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]!==d||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:[d,u]}),e[32]=d,e[33]=u,e[34]=f):f=e[34],f}function E1(t){const e=F.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 h;e[0]!==l?(h=te("flex h-7 items-center gap-1.5 rounded-md border px-2.5 text-xs",l),e[0]=l,e[1]=h):h=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(qr,{className:"size-3.5"}),e[2]=c):c=e[2];let d;return e[3]!==r||e[4]!==o||e[5]!==a||e[6]!==h?(d=n.jsxs("button",{type:"button","aria-pressed":o,"aria-expanded":a,onClick:r,className:h,children:[c,"sandbox"]}),e[3]=r,e[4]=o,e[5]=a,e[6]=h,e[7]=d):d=e[7],d}function T1(t){const e=F.c(24),{status:s,onStart:i,onStop:r,onRestart:o,onResume:a,onRetry:l}=t;if(s==="idle"&&i){let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(os,{className:"size-3.5"}),e[0]=h):h=e[0];let c;return e[1]!==i?(c=n.jsxs(Q,{variant:"outline",size:"sm",onClick:i,children:[h," Start"]}),e[1]=i,e[2]=c):c=e[2],c}if(s==="suspended"&&a){let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(os,{className:"size-3.5"}),e[3]=h):h=e[3];let c;return e[4]!==a?(c=n.jsxs(Q,{variant:"outline",size:"sm",onClick:a,children:[h," Resume"]}),e[4]=a,e[5]=c):c=e[5],c}if(s==="errored"&&l){let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(ns,{className:"size-3.5"}),e[6]=h):h=e[6];let c;return e[7]!==l?(c=n.jsxs(Q,{variant:"outline",size:"sm",onClick:l,children:[h," Retry"]}),e[7]=l,e[8]=c):c=e[8],c}if(s==="starting"||s==="running"){const h=s==="running"&&!!o,c=h?"rounded-r-none border-r-0":void 0;let d;e[9]!==c?(d=te(c),e[9]=c,e[10]=d):d=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(wl,{className:"size-3.5"}),e[11]=u):u=e[11];let f;e[12]!==r||e[13]!==d?(f=n.jsx(Te,{asChild:!0,children:n.jsxs(Q,{variant:"outline",size:"sm",onClick:r,className:d,children:[u," Stop"]})}),e[12]=r,e[13]=d,e[14]=f):f=e[14];let m;e[15]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(Re,{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 _;e[18]!==o||e[19]!==h?(_=h&&n.jsxs(mi,{children:[n.jsx(pi,{asChild:!0,children:n.jsx(Q,{variant:"outline",size:"sm",className:"rounded-l-none px-1",children:n.jsx(co,{className:"size-3"})})}),n.jsx(_i,{align:"end",children:n.jsxs(Dt,{onClick:o,children:[n.jsx(ns,{className:"size-3.5"})," Restart"]})})]}),e[18]=o,e[19]=h,e[20]=_):_=e[20];let g;return e[21]!==p||e[22]!==_?(g=n.jsxs("div",{className:"flex items-center",children:[p,_]}),e[21]=p,e[22]=_,e[23]=g):g=e[23],g}return null}function R1(t){const e=F.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=te("flex h-7 items-center rounded-md border text-xs",a),e[0]=a,e[1]=l):l=e[1];const h=r?"pl-2.5 pr-1":"px-2.5",c=s?"font-medium text-foreground":"text-muted-foreground hover:text-foreground";let d;e[2]!==h||e[3]!==c?(d=te("flex h-full items-center",h,c),e[2]=h,e[3]=c,e[4]=d):d=e[4];let u;e[5]!==o||e[6]!==i||e[7]!==d?(u=n.jsx("button",{type:"button",onClick:i,className:d,children:o}),e[5]=o,e[6]=i,e[7]=d,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(wu,{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 P1(t){const e=F.c(10),{scripts:s,onRun:i}=t,[r,o]=D.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs(Pe,{children:[n.jsx(Te,{asChild:!0,children:n.jsx(hi,{asChild:!0,children:n.jsx(Q,{variant:"ghost",size:"sm","aria-label":"Run script",children:n.jsx(Ut,{className:"size-3.5"})})})}),n.jsx(Re,{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 h;e[2]!==i||e[3]!==s?(h=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]=h):h=e[4];let c;e[5]!==h?(c=n.jsxs(di,{align:"start",className:"p-1 w-56",children:[l,h]}),e[5]=h,e[6]=c):c=e[6];let d;return e[7]!==r||e[8]!==c?(d=n.jsxs(ci,{open:r,onOpenChange:o,children:[a,c]}),e[7]=r,e[8]=c,e[9]=d):d=e[9],d}function D1(t){const e=F.c(13),{isRunning:s,isKilling:i,onRun:r,onStop:o}=t;if(i){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsxs(Q,{variant:"outline",size:"sm",disabled:!0,children:[n.jsx(Se,{className:"size-3.5 animate-spin"})," Stopping…"]}),e[0]=d):d=e[0],d}if(!s){let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(os,{className:"size-3.5"}),e[1]=d):d=e[1];let u;e[2]!==r?(u=n.jsx(Te,{asChild:!0,children:n.jsxs(Q,{variant:"outline",size:"sm",onClick:r,children:[d," Run"]})}),e[2]=r,e[3]=u):u=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(Re,{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(wl,{className:"size-3.5"}),e[7]=a):a=e[7];let l;e[8]!==o?(l=n.jsx(Te,{asChild:!0,children:n.jsxs(Q,{variant:"outline",size:"sm",onClick:o,children:[a," Stop"]})}),e[8]=o,e[9]=l):l=e[9];let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Re,{children:"Stop process"}),e[10]=h):h=e[10];let c;return e[11]!==l?(c=n.jsxs(Pe,{children:[l,h]}),e[11]=l,e[12]=c):c=e[12],c}function A1(t){const e=Es(),[s,i]=D.useState(is),[r,o]=D.useState([]),[a,l]=D.useState(new Set),h=D.useRef(!1);if(!h.current&&e.scripts.length>0){const b=j1.find(y=>e.scripts.includes(y));b&&(h.current=!0,o(y=>y.includes(b)?y:[...y,b]),i(b))}if(a.size>0){let b=!1;const y=new Set(a);for(const w of a)e.activeProcesses.includes(w)||(y.delete(w),b=!0);b&&l(y)}const c=()=>t.onOpenChange(!t.open),d=b=>{i(b),t.open||t.onOpenChange(!0)},u=b=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(`/api/${encodeURIComponent(t.orgSlug)}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/exec/${encodeURIComponent(b)}`,{method:"POST"}),f=b=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(`/api/${encodeURIComponent(t.orgSlug)}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/exec/${encodeURIComponent(b)}/kill`,{method:"POST"}),m=async b=>{o(y=>y.includes(b)?y:[...y,b]),i(b),t.onOpenChange(!0);try{const y=await u(b);if(y===null)return;if(!y.ok)throw new Error(`Exec failed: ${y.statusText}`)}catch{ae.error("Failed to run "+b)}},p=async b=>{await f(b),o(y=>y.filter(w=>w!==b)),s===b&&i(is)},_=async()=>{const b=e.activeProcesses.includes(s);try{const y=await u(s);if(y===null)return;if(!y.ok)throw new Error(`Exec failed: ${y.statusText}`)}catch{ae.error((b?"Failed to restart ":"Failed to run ")+s)}},g=async()=>{if(!a.has(s)){l(b=>new Set(b).add(s));try{const b=await f(s);if(b===null){l(y=>{const w=new Set(y);return w.delete(s),w});return}if(!b.ok)throw new Error(`Kill failed: ${b.statusText}`)}catch{l(b=>{const y=new Set(b);return y.delete(s),y}),ae.error("Failed to stop "+s)}}},x=s!==is&&r.includes(s),S=x&&e.activeProcesses.includes(s),v=x&&a.has(s);return n.jsxs("div",{className:"flex shrink-0 flex-col",style:{height:t.open?"50%":"auto"},children:[n.jsx(N1,{status:t.status,open:t.open,onToggle:c,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:d,onAddScript:m,onCloseScript:p,showScriptControls:x,scriptIsRunning:S,scriptIsKilling:v,onRunActiveScript:_,onStopActiveScript:g}),t.open&&n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(I1,{vmId:t.vmId,active:s,hasData:e.hasData(s),onRunActive:_})})]})}function I1(t){const e=F.c(10),{vmId:s,active:i,hasData:r,onRunActive:o}=t;if(!s)return null;if(i===is||r){let d;return e[0]!==i?(d=n.jsx(th,{source:i,className:"h-full"},i),e[0]=i,e[1]=d):d=e[1],d}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(os,{className:"size-3.5"}),e[4]=l):l=e[4];let h;e[5]!==o?(h=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]=h):h=e[6];let c;return e[7]!==a||e[8]!==h?(c=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 text-sm text-muted-foreground",children:[a,h]}),e[7]=a,e[8]=h,e[9]=c):c=e[9],c}const sh=t=>`preview-drawer:${t}`;function M1(t){try{const e=localStorage.getItem(sh(t));return e?!!JSON.parse(e).open:!1}catch{return!1}}function B1(t,e){try{localStorage.setItem(sh(t),JSON.stringify({open:e}))}catch{}}const L1=D.lazy(()=>Gn(()=>import("./sections-editor-CT7Vp1k1.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])).then(t=>({default:t.SectionsEditor}))),O1=D.lazy(()=>Gn(()=>import("./file-explorer-Bzt-HVWR.js"),__vite__mapDeps([136,1,2,4,5,6,7,8,9,10,3,12,13,14,15,16,11,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,64,65,57,66,67,68,69,70,71,79,80,53,81,82,83,63,72,73,74,75,76,77,78,84,85,86,51,49,87,88,55,89,90,91,54,92,93,94,95,58,61,62,96,59,60,97,47,98,99,100,101,102,103,104,105,106,107,108,50,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,52,130,131,132,133,134,135])).then(t=>({default:t.FileExplorer}))),Za=500;function $1(t,e){return t.kind==="errored"?"errored":t.kind==="suspended"?"suspended":t.kind==="starting-now"||e?"starting":t.kind==="iframe"||t.kind==="no-html"||t.kind==="crashed"?"running":"idle"}function z1(){const t=uh(),{data:e}=ir.useSession(),{taskId:s,currentBranch:i,setCurrentTaskBranch:r}=ds(),[o,a]=D.useState("preview"),[l,h]=D.useState(null),c=D.useRef(null),d=o==="cms",[u,f]=D.useState(null),[m,p]=D.useState(384),_=D.useRef(!1),g=D.useRef(0),x=D.useRef(0),S=D.useRef(null),[v,b]=D.useState(!1),[y,w]=D.useState(""),k=D.useRef(null),[j,T]=D.useState(!1),[P,R]=D.useState(),[C,N]=D.useState(null),[B,I]=D.useState(null),[E,M]=D.useState("/"),A=e?.user?.id,L=t?.entity?.metadata,H=A&&i?Yn(L?.sandboxMap?.[A]?.[i]):{},$=Object.values(H),z=$.find(K=>K.sandboxProviderKind!=="user-desktop")??$[0],V=z?.previewUrl??null,q=t?.entity?.id??null,{org:ee}=ke(),G=Es(),Y=G.lifecycle.phase,O=Y==="running",X=q&&i&&O?{orgSlug:ee.slug,virtualMcpId:q,branch:i}:null,{data:J}=sp(X),{data:ie}=rp(X),oe=q&&i?{orgSlug:ee.slug,virtualMcpId:q,branch:i}:null,W=jp(oe),ne=J?_p(J).sort((K,he)=>K.name.localeCompare(he.name)):[],me=J&&ie?vp(J,ie):[],_e=xp,pe=ne.filter(K=>{if(!y)return!0;const he=y.toLowerCase();return K.name.toLowerCase().includes(he)||K.path.toLowerCase().includes(he)}),xe=me.filter(K=>{if(!y)return!0;const he=y.toLowerCase();return K.name.toLowerCase().includes(he)||K.key.toLowerCase().includes(he)||K.resolveType.toLowerCase().includes(he)}),le=C?C.name:ne.find(K=>_e(K.path)===_e(E))?.name,re=D.useRef(null),ce=D.useRef(null);Up(()=>{const K=c.current,he=re.current;!K||!he||(K.src=he)});const ge=D.useRef({url:"",value:!1});V&&ge.current.url!==V&&(ge.current={url:V,value:!1}),G.lifecycle.phase==="running"&&(ge.current.value=G.lifecycle.htmlSupport);const be=ge.current.value,qe=Y==="running"?"online":Y==="crashed"?"offline":"booting",yi=G.suspended,Vt=G.status.state==="paused",qt=Je({connectionId:Ns,orgId:t?.entity?.organization_id??"",orgSlug:ee.slug}),Et=ml(qt),Gt=Et.error?.message??null,wi=Oh(q??void 0,i??void 0),Yt=D.useRef(null),xr=D.useRef(null),Ci=G.phase,br=Vp({claimPhase:Ci,lifecycle:G.lifecycle}),ki=!!q&&!!i&&jr.isStopped(q,i),jo=Y==="start-failed"||Y==="install-failed"||Y==="clone-failed"?Y:null,fh=jo&&"error"in G.lifecycle?G.lifecycle.error??null:null,we=Kp({previewUrl:V,status:qe,htmlSupport:be,suspended:yi,appPaused:Vt,vmStartPending:wi,lastStartError:Gt,lifecycleFailure:jo,lifecycleFailureError:fh,claimPhase:Ci,notFound:G.notFound,userStopped:ki}),_t=we.kind==="iframe"?B??new URL(E,we.previewUrl).href:null,[No,mh]=D.useState(null);if(we.kind==="iframe"&&No!==we.previewUrl){const K=No!==null;mh(we.previewUrl),K&&(ce.current=null,M("/"),I(null),N(null))}re.current=_t;const Sr=!!q&&!!i&&!G.notFound&&!ki&&!yi&&!Vt&&(Ci?.kind==="ready"||Y!=="idle"),yr=we.kind!=="iframe"&&(o==="visual"||o==="cms")?"preview":o,ji=K=>{if(!q)return;const he={virtualMcpId:q};i&&(he.branch=i),Et.mutate(he,{onSuccess:De=>{De?.branch&&!i&&r(De.branch)},onError:De=>{console.error(`[preview] ${K} SANDBOX_START failed`,De)}})},Is=D.useRef(ji);Is.current=ji,s&&z&&Yt.current!==s&&(Yt.current=s);const Eo=!!s&&!!q&&!!A&&!!i&&!z&&!Gt&&!ki&&!Et.isPending&&Yt.current!==s;D.useEffect(()=>{!Eo||!s||(Yt.current=s,Is.current("auto-start"))},[Eo,s,ki]);const Ni=G.notFound?z?.sandboxHandle??null:null;D.useEffect(()=>{!Ni||!q||Gt||Et.isPending||xr.current!==Ni&&(i&&jr.isStopped(q,i)||(xr.current=Ni,Is.current("self-heal")))},[Ni,q,Gt,Et.isPending,i]);const Ms=()=>{Yt.current=null,xr.current=null,Et.reset(),Is.current("auto-start")},ph=Vn(),Ei=q??"__no-vmcp__",[_h,To]=D.useState(null),Ro=D.useRef(null);Ro.current!==Ei&&(Ro.current=Ei,To(M1(Ei)));const wr=we.kind==="never-started"?!1:_h??!1,Cr=K=>{To(K),B1(Ei,K)},kr=()=>Cr(!0),Po=async()=>{if(!q)return;const K=i;if(!K)return;const he=z?.sandboxProviderKind;if(he){jr.mark(q,K);try{await qt.callTool({name:"SANDBOX_DELETE",arguments:{virtualMcpId:q,branch:K,sandboxProviderKind:he}})}catch{}Ih(ph)}},gh=async()=>{await Po(),Is.current("auto-start")};D.useEffect(()=>{if(!V)return;let K;try{K=new URL(V,window.location.href).origin}catch{return}const he=De=>{if(De.origin===K){if(De.data?.type==="visual-editor::element-clicked"){const Ge=Ep.safeParse(De.data.payload);Ge.success&&h(Ge.data)}else if(De.data?.type==="cms-editor::section-clicked"){const Ge=Rp.safeParse(De.data.payload);Ge.success&&f(Ge.data.sectionIndex)}}};return window.addEventListener("message",he),()=>window.removeEventListener("message",he)},[V]),D.useEffect(()=>{if(!v)return;const K=he=>{k.current?.contains(he.target)||(b(!1),w(""))};return document.addEventListener("pointerdown",K),()=>document.removeEventListener("pointerdown",K)},[v]),D.useEffect(()=>{if(!d)return;const K=De=>{const Ge=De.target;Ge&&Ge!==c.current&&(S.current=Ge)},he=()=>{requestAnimationFrame(()=>{const De=document.activeElement;(De===document.body||De===c.current)&&S.current&&S.current.focus()})};return document.addEventListener("focusin",K),document.addEventListener("blur",he,!0),()=>{document.removeEventListener("focusin",K),document.removeEventListener("blur",he,!0)}},[d]);const Do=()=>{const K=c.current?.contentWindow;K&&K.postMessage({type:"visual-editor::activate",script:Tp},"*")},vh=()=>{const K=c.current?.contentWindow;K&&K.postMessage({type:"visual-editor::deactivate"},"*")},Ao=()=>{const K=c.current?.contentWindow;K&&K.postMessage({type:"visual-editor::activate",script:Pp},"*")},xh=()=>{const K=c.current?.contentWindow;K&&K.postMessage({type:"cms-editor::deactivate"},"*")},Io=K=>{const he=o;a(K),h(null),K!=="cms"&&f(null),he==="visual"&&vh(),he==="cms"&&xh(),K==="visual"&&Do(),K==="cms"&&Ao()},bh=()=>{if(!c.current||!_t)return;const K=c.current;K.src=_t},Sh=()=>{if(!c.current||!_t)return;const K=_t.includes("?")?"&":"?";c.current.src=`${_t}${K}_r=${Date.now()}`},yh=()=>{const K=c.current?.contentWindow?.location?.href??_t??V;K&&navigator.clipboard.writeText(K)},wh=(()=>{if(!V)return"No server running";if(C)return C.name;try{const K=new URL(V),he=E==="/"?"":E;return`${K.host}${he}`}catch{return V}})(),Mo=K=>{ce.current=K,N(null),I(null),M(K),f(null)},Ch=K=>{if(!V||!ie){ae.error("Preview metadata not ready yet");return}ce.current=null;const he=ic(ie),De=Sp(V,he,K.key);N(K),I(De),f(null)},kh=async({name:K,path:he})=>{if(!q||!i)return;const De=nc(he);if(De){R(De);return}const Ge=he.trim().startsWith("/")?he.trim():`/${he.trim()}`;if(ne.some(Tt=>_e(Tt.path)===_e(Ge))){R(`A page with path "${Ge}" already exists.`);return}R(void 0);try{const Tt=await W.mutateAsync({name:K,path:Ge});T(!1),ae.success(`Page "${K}" created`),await new Promise(Nh=>setTimeout(Nh,Za)),Mo(Tt.path),Io("cms")}catch(Tt){R(Tt instanceof Error?Tt.message:"Failed to create page")}},jh=[{value:"preview",icon:n.jsx(Sl,{size:14}),tooltip:"Interactive"},...we.kind==="iframe"?[{value:"visual",icon:n.jsx(Ho,{size:14}),tooltip:"Visual editor"}]:[],...we.kind==="iframe"&&(ne.length>0||me.length>0)?[{value:"cms",icon:n.jsx(Rd,{size:14}),tooltip:"Sections editor"}]:[],{value:"code",icon:n.jsx(yl,{size:14}),tooltip:"Code editor"}];return n.jsxs("div",{className:"flex flex-col w-full h-full",children:[Sr&&n.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-4 border-b border-border/60 px-3 md:px-4",children:[n.jsx("div",{className:"flex shrink-0 items-center gap-1",children:n.jsx(yu,{value:yr,onValueChange:Io,options:jh,size:"sm",className:"shrink-0 bg-foreground/4.5"})}),we.kind==="iframe"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:te("flex min-w-0 flex-1 items-center gap-0.5",o==="code"&&"hidden"),children:[n.jsxs(Pe,{children:[n.jsx(Te,{asChild:!0,children:n.jsx(Q,{variant:"ghost",size:"icon",onClick:bh,children:n.jsx(ns,{size:14})})}),n.jsx(Re,{side:"bottom",children:"Refresh"})]}),n.jsxs("div",{ref:k,className:"relative min-w-0 flex-1",children:[n.jsxs("button",{type:"button",className:"flex h-8 w-full min-w-0 items-center gap-1 rounded-md bg-background px-2 transition-colors duration-200 hover:bg-accent",onClick:()=>b(K=>!K),children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-left text-[12px] text-foreground/88",children:wh}),le&&!C&&n.jsx("span",{className:"shrink-0 text-[12px] text-muted-foreground",children:le}),n.jsx(co,{size:12,className:te("shrink-0 text-muted-foreground transition-transform",v&&"rotate-180")})]}),v&&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.jsx("div",{className:"px-2 pt-2 pb-1",children:n.jsx("input",{type:"text",value:y,onChange:K=>w(K.target.value),placeholder:"Search pages and components...",className:"w-full rounded-md border border-input bg-transparent px-2.5 py-1.5 text-xs outline-none placeholder:text-muted-foreground focus:ring-1 focus:ring-ring",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:K=>{K.preventDefault(),b(!1),w(""),R(void 0),T(!0)},children:[n.jsx(Ut,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"flex-1 font-medium",children:"Create new page"})]})}),pe.length===0&&xe.length===0?n.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:ne.length===0&&me.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:[pe.length>0&&n.jsx("div",{className:"p-1.5",children:pe.map(K=>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:he=>{he.preventDefault(),b(!1),w(""),Mo(K.path)},children:[n.jsx(Pd,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:K.name}),n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:K.path})]},K.key))}),xe.length>0&&n.jsxs("div",{className:te("p-1.5",pe.length>0&&"border-t"),children:[n.jsx("div",{className:"px-3 py-2 text-xs font-medium text-muted-foreground",children:"Global components"}),xe.map(K=>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:he=>{he.preventDefault(),b(!1),w(""),Ch(K)},children:[n.jsx(Su,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:K.name}),n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:K.resolveType.split("/").pop()?.replace(/\.tsx?$/,"")})]},K.key))]})]})]})]})]}),n.jsxs("div",{className:te("flex shrink-0 items-center gap-0.5",o==="code"&&"hidden"),children:[n.jsxs(Pe,{children:[n.jsx(Te,{asChild:!0,children:n.jsx(Q,{variant:"ghost",size:"icon",onClick:()=>{const K=_t??we.previewUrl;K&&window.open(K,"_blank","noopener")},children:n.jsx(ms,{size:14})})}),n.jsx(Re,{side:"bottom",children:"Open in new tab"})]}),n.jsxs(mi,{children:[n.jsx(pi,{asChild:!0,children:n.jsx(Q,{variant:"ghost",size:"icon",children:n.jsx(ro,{size:14})})}),n.jsxs(_i,{align:"end",children:[n.jsx(Dt,{onClick:Sh,children:"Hard Reload"}),n.jsx(Dt,{onClick:yh,children:"Copy Current URL"})]})]})]})]})]}),n.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[d&&V&&i&&q&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"shrink-0 border-r overflow-hidden",style:{width:m},children:n.jsx(D.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(Se,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(L1,{orgSlug:ee.slug,virtualMcpId:q,branch:i,previewReady:O,previewUrl:V,currentPath:E,activeGlobalBlockKey:C?.key??null,externalSelectedIndex:C?null:u,onSaved:()=>{setTimeout(()=>{const K=c.current;if(!K)return;const he=document.activeElement,De=K.tabIndex;K.tabIndex=-1,K.style.pointerEvents="none",K.blur();try{K.contentWindow?.location.reload()}catch{const Tt=re.current;Tt&&(K.src=Tt)}const Ge=()=>{K.tabIndex=De,K.style.pointerEvents="",he?.focus(),K.removeEventListener("load",Ge)};K.addEventListener("load",Ge),setTimeout(Ge,3e3)},Za)}})})}),n.jsx("div",{className:"w-1 shrink-0 cursor-col-resize bg-transparent hover:bg-border transition-colors",onPointerDown:K=>{_.current=!0,g.current=K.clientX,x.current=m,K.currentTarget.setPointerCapture(K.pointerId)},onPointerMove:K=>{if(!_.current)return;const he=K.clientX-g.current;p(Math.max(240,Math.min(640,x.current+he)))},onPointerUp:()=>{_.current=!1}})]}),n.jsxs("div",{className:"flex-1 relative overflow-hidden",children:[we.kind==="never-started"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Ss,{kind:"never-started",onStart:()=>{Cr(!1),ji("auto-start")}})}),we.kind==="starting-now"&&!(o==="code"&&Sr)&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Ss,{kind:"starting-now",progress:br,claimPhase:Ci})}),we.kind==="errored"&&n.jsx("div",{className:"absolute inset-0 z-40",children:n.jsx(Ss,{kind:"errored",progress:br,logSource:"setup",errorLine:we.error.split(`
|
|
287
287
|
`)[0]??"Failed to start",onRetry:Ms,drawerOpen:wr})}),we.kind==="dev-script-failed"&&o!=="code"&&n.jsx("div",{className:"absolute inset-0 z-40",children:n.jsx(Ss,{kind:"dev-script-failed",progress:br,logSource:we.failure==="start-failed"?"dev":"setup",errorLine:we.error.split(`
|
|
288
288
|
`)[0]??"Dev script exited",onRetry:Ms,onOpenTerminal:kr,onBrowseFiles:()=>a("code"),drawerOpen:wr})}),we.kind==="suspended"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Ss,{kind:"suspended",onResume:Ms})}),we.kind==="crashed"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Ss,{kind:"crashed",onOpenTerminal:kr})}),we.kind==="no-html"&&n.jsxs("div",{className:"absolute inset-0 z-30 flex flex-col items-center justify-center gap-4 bg-background",children:[n.jsx(Wo,{size:48,className:"text-muted-foreground/40"}),n.jsx("h3",{className:"text-lg font-medium",children:"No web page at this URL"}),n.jsx("p",{className:"text-sm text-muted-foreground text-center max-w-sm",children:"The server is running, but doesn't serve a web page at /. This preview only renders web pages."}),n.jsxs(Q,{onClick:kr,children:[n.jsx(Wo,{size:14}),"View Logs"]})]}),yr==="visual"&&!l&&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(Ho,{size:12}),"Click any element to ask the AI"]}),yr==="visual"&&l&&n.jsx(Ip,{element:l,onDismiss:()=>h(null)}),o==="code"&&Sr&&q&&i&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(D.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(Se,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(O1,{orgSlug:ee.slug,virtualMcpId:q,branch:i})})}),we.kind==="iframe"&&_t&&n.jsx("iframe",{ref:c,src:_t,className:te("w-full h-full border-0",o==="code"&&"invisible"),title:"Dev Server Preview",tabIndex:d?-1:void 0,onLoad:()=>{if(Ee("vm_preview_loaded",{view_mode:o,vm_id:z?.sandboxHandle??null}),!C)try{const K=c.current?.contentWindow?.location?.pathname;if(!K)return;const he=ce.current;if(he!==null){ce.current=null,_e(K)===_e(he)&&M(K);return}M(K)}catch{}o==="visual"&&Do(),o==="cms"&&Ao()}},we.previewUrl)]})]}),n.jsx(A1,{vmId:z?.sandboxHandle??null,orgSlug:ee.slug,virtualMcpId:q,branch:i,status:$1(we,wi),scripts:G.scripts,open:wr,onOpenChange:Cr,onStart:()=>ji("auto-start"),onStop:Po,onRestart:gh,onResume:Ms,onRetry:Ms},z?.sandboxHandle??"no-vm"),n.jsx(Np,{open:j,onOpenChange:T,isPending:W.isPending,error:P,onSubmit:kh})]})}function F1(t){const e=F.c(2),{virtualMcpId:s}=t,i=Mt(s);if(!ar(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(Jn,{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(z1,{}),e[1]=o):o=e[1],o}function H1(t){const e=F.c(3),{tier:s,onSelect:i}=t;let r;return e[0]!==i||e[1]!==s?(r=n.jsx($h,{tier:s,subtitleFor:W1,iconFor:zh,onSelect:i}),e[0]=i,e[1]=s,e[2]=r):r=e[2],r}function W1(t){return Fh("cloud-decopilot",t)}function ei(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function U1(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"),h=(o[1]??"0").padStart(2,"0");return`Every day at ${l}:${h} UTC`}const a=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+(\d)$/);if(a){const h=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][parseInt(a[3]??"0")]??"day",c=(a[2]??"0").padStart(2,"0"),d=(a[1]??"0").padStart(2,"0");return`Every ${h} at ${c}:${d} UTC`}return t}function K1(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 V1(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+\*$/);if(r){const o=parseInt(r[1]);return o%7===0?{count:o/7,unit:"weeks"}:{count:o,unit:"days"}}return null}function q1(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const G1=[{label:"5 minutes",cron:"*/5 * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function Y1({automationId:t,open:e,onOpenChange:s,onCustomSelect:i,onEventSelect:r,onWebhookCreated:o}){const{triggerAdd:a}=gi(),[l,h]=D.useState(!1),c=e??l,d=m=>{s?s(m):h(m)},u=async m=>{try{await a.mutateAsync({automation_id:t,type:"cron",cron_expression:m}),ae.success("Starter added"),d(!1)}catch(p){const _=p instanceof Error?p.message:"Failed to add starter";ae.error(_)}},f=async()=>{try{const m=await a.mutateAsync({automation_id:t,type:"webhook"});d(!1),m.webhook?o?.(m.webhook):ae.success("Webhook starter added")}catch(m){const p=m instanceof Error?m.message:"Failed to add webhook starter";ae.error(p)}};return n.jsxs(mi,{open:c,onOpenChange:d,children:[n.jsx(pi,{asChild:!0,children:n.jsxs(Q,{variant:"outline",size:"sm",children:[n.jsx(Ut,{size:14}),"Add Starter"]})}),n.jsxs(_i,{align:"end",className:"w-[200px]",children:[n.jsxs(gu,{children:[n.jsxs(vu,{className:"gap-2.5",children:[n.jsx(Js,{size:14,className:"text-muted-foreground shrink-0"}),"Every..."]}),n.jsx(xu,{className:"w-[160px]",children:G1.map(m=>n.jsxs(Dt,{className:"gap-2.5",onSelect:()=>u(m.cron),disabled:a.isPending,children:[n.jsx(Js,{size:14,className:"text-muted-foreground shrink-0"}),"Every ",m.label]},m.cron))})]}),n.jsxs(Dt,{className:"gap-2.5",onSelect:()=>{d(!1),i?.()},children:[n.jsx(Js,{size:14,className:"text-muted-foreground shrink-0"}),"Custom (cron)"]}),n.jsxs(Dt,{className:"gap-2.5",onSelect:()=>{d(!1),r?.()},children:[n.jsx(ti,{size:14,className:"text-muted-foreground shrink-0"}),"Event"]}),n.jsxs(Dt,{className:"gap-2.5",onSelect:()=>{f()},disabled:a.isPending,children:[n.jsx(Zn,{size:14,className:"text-muted-foreground shrink-0"}),"Webhook"]})]})]})}function ih(t){const e=F.c(31),{open:s,onOpenChange:i,url:r,token:o,title:a,description:l}=t,h=a===void 0?"Webhook ready":a,c=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,[d,u]=D.useState(null),[f,m]=D.useState("curl"),[p,_]=D.useState("header"),g=D.useId();let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=async(I,E)=>{try{await navigator.clipboard.writeText(I),u(E),ae.success("Copied"),setTimeout(()=>u(null),1500)}catch{ae.error("Failed to copy")}},e[0]=x):x=e[0];const S=x;let v;e[1]!==p||e[2]!==o||e[3]!==r?(v=r&&o&&p==="url"?`${r.replace(/\/$/,"")}/${o}`:r??"",e[1]=p,e[2]=o,e[3]=r,e[4]=v):v=e[4];const b=v,y=r&&o?p==="header"?`curl -X POST "${b}" \\
|
|
289
289
|
-H "Authorization: Bearer ${o}" \\
|
|
@@ -304,7 +304,7 @@ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){t
|
|
|
304
304
|
},
|
|
305
305
|
body: JSON.stringify({ hello: "world" }),
|
|
306
306
|
});`:"",k=f==="curl"?y:w;let j;e[5]!==h?(j=n.jsx(li,{children:h}),e[5]=h,e[6]=j):j=e[6];let T;e[7]!==c?(T=n.jsx(Pl,{children:c}),e[7]=c,e[8]=T):T=e[8];let P;e[9]!==j||e[10]!==T?(P=n.jsxs(ai,{children:[j,T]}),e[9]=j,e[10]=T,e[11]=P):P=e[11];let R;e[12]!==p||e[13]!==d||e[14]!==b||e[15]!==f||e[16]!==k||e[17]!==o||e[18]!==g||e[19]!==r?(R=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:b}),n.jsxs(Q,{size:"sm",variant:"outline",onClick:()=>S(b,"url"),children:[n.jsx(es,{size:13}),d==="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(Q,{size:"sm",variant:"outline",onClick:()=>S(o,"token"),children:[n.jsx(es,{size:13}),d==="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(ao,{value:f,onValueChange:I=>m(I),children:n.jsxs(lo,{className:"h-8 p-[2px]",children:[n.jsx(ts,{value:"curl",className:"h-7 px-2.5 text-xs",children:"curl"}),n.jsx(ts,{value:"fetch",className:"h-7 px-2.5 text-xs",children:"fetch"})]})}),n.jsxs("label",{htmlFor:g,className:"flex items-center gap-1.5 text-xs text-muted-foreground cursor-pointer select-none",children:[n.jsx(Ml,{id:g,checked:p==="url",onCheckedChange:I=>_(I?"url":"header")}),"Token in URL"]})]}),n.jsxs(Q,{size:"sm",variant:"outline",onClick:()=>S(k,"example"),children:[n.jsx(es,{size:13}),d==="example"?"Copied":"Copy"]})]}),n.jsx("div",{className:"rounded-md border overflow-hidden min-w-0",children:n.jsx(Jd,{code:k,language:f==="curl"?"shell":"typescript",readOnly:!0,disableDiagnostics:!0,height:180})})]})]}):null,e[12]=p,e[13]=d,e[14]=b,e[15]=f,e[16]=k,e[17]=o,e[18]=g,e[19]=r,e[20]=R):R=e[20];let C;e[21]!==i?(C=n.jsx(dr,{children:n.jsx(Q,{onClick:()=>i(!1),children:"Done"})}),e[21]=i,e[22]=C):C=e[22];let N;e[23]!==P||e[24]!==R||e[25]!==C?(N=n.jsxs(us,{className:"max-w-lg",children:[P,R,C]}),e[23]=P,e[24]=R,e[25]=C,e[26]=N):N=e[26];let B;return e[27]!==i||e[28]!==s||e[29]!==N?(B=n.jsx(fs,{open:s,onOpenChange:i,children:N}),e[27]=i,e[28]=s,e[29]=N,e[30]=B):B=e[30],B}function X1(t){const e=F.c(83),{trigger:s,automationId:i,connectionName:r}=t,{triggerAdd:o,triggerRemove:a,triggerRotateToken:l}=gi(),[h,c]=D.useState(!1),[d,u]=D.useState(!1),[f,m]=D.useState(null);let p;e[0]!==s.cron_expression?(p=s.cron_expression?V1(s.cron_expression):null,e[0]=s.cron_expression,e[1]=p):p=e[1];const _=p,[g,x]=D.useState(_?.count??1),[S,v]=D.useState(!1),[b,y]=D.useState(s.cron_expression??""),w=a.isPending||o.isPending||l.isPending,k=s.type==="cron",j=s.type==="webhook";let T;e[2]!==i||e[3]!==a||e[4]!==s.id?(T=async()=>{try{await a.mutateAsync({trigger_id:s.id,automation_id:i}),ae.success("Starter removed")}catch{ae.error("Failed to remove starter")}c(!1)},e[2]=i,e[3]=a,e[4]=s.id,e[5]=T):T=e[5];const P=T;let R;e[6]!==o||e[7]!==i||e[8]!==b||e[9]!==a||e[10]!==s.cron_expression||e[11]!==s.id?(R=async()=>{const le=b.trim();if(!le||!ei(le)||le===s.cron_expression){v(!1),y(s.cron_expression??"");return}try{await o.mutateAsync({automation_id:i,type:"cron",cron_expression:le}),await a.mutateAsync({trigger_id:s.id,automation_id:i}),v(!1)}catch{ae.error("Failed to update starter"),y(s.cron_expression??""),v(!1)}},e[6]=o,e[7]=i,e[8]=b,e[9]=a,e[10]=s.cron_expression,e[11]=s.id,e[12]=R):R=e[12];const C=R;let N;e[13]!==i||e[14]!==l||e[15]!==s.id?(N=async()=>{u(!1);try{const le=await l.mutateAsync({trigger_id:s.id,automation_id:i});m({url:le.url,token:le.token})}catch(le){const re=le,ce=re instanceof Error?re.message:"Failed to rotate token";ae.error(ce)}},e[13]=i,e[14]=l,e[15]=s.id,e[16]=N):N=e[16];const B=N;let I;e[17]!==o||e[18]!==i||e[19]!==_||e[20]!==a||e[21]!==s.cron_expression||e[22]!==s.id?(I=async le=>{if(!_)return;const re=_.unit==="minutes"?5:1,ce=Math.max(re,le);ce!==le&&x(ce);const ge=K1(ce,_.unit);if(ge!==s.cron_expression)try{await o.mutateAsync({automation_id:i,type:"cron",cron_expression:ge}),await a.mutateAsync({trigger_id:s.id,automation_id:i})}catch{ae.error("Failed to update starter"),x(_.count)}},e[17]=o,e[18]=i,e[19]=_,e[20]=a,e[21]=s.cron_expression,e[22]=s.id,e[23]=I):I=e[23];const E=I;let M;e[24]!==k||e[25]!==j?(M=k?n.jsx(Js,{size:14,className:"text-muted-foreground shrink-0"}):j?n.jsx(Zn,{size:14,className:"text-muted-foreground shrink-0"}):n.jsx(ti,{size:14,className:"text-muted-foreground shrink-0"}),e[24]=k,e[25]=j,e[26]=M):M=e[26];let A;e[27]!==r||e[28]!==g||e[29]!==b||e[30]!==E||e[31]!==C||e[32]!==_||e[33]!==k||e[34]!==S||e[35]!==w||e[36]!==j||e[37]!==s.cron_expression||e[38]!==s.event_type||e[39]!==s.params?(A=_&&k?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-sm text-muted-foreground",children:"Every"}),n.jsx("input",{type:"number",min:_.unit==="minutes"?5:1,value:g,onChange:le=>x(parseInt(le.target.value)||1),onBlur:()=>E(g),onKeyDown:le=>{le.key==="Enter"&&le.target.blur(),le.key==="Escape"&&x(_.count)},disabled:w,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:q1(_.unit,g)})]}):k&&S?n.jsxs(n.Fragment,{children:[n.jsx("input",{type:"text",value:b,onChange:le=>y(le.target.value),onBlur:C,onKeyDown:le=>{le.key==="Enter"&&le.target.blur(),le.key==="Escape"&&(v(!1),y(s.cron_expression??""))},className:"flex-1 text-sm font-mono bg-transparent outline-none",autoFocus:!0}),b&&!ei(b)&&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:k?U1(s.cron_expression??""):j?"Webhook · POST to fire":`${s.event_type}${r?` · ${r}`:""}`}),!k&&!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(J1).join(", ")})]}),e[27]=r,e[28]=g,e[29]=b,e[30]=E,e[31]=C,e[32]=_,e[33]=k,e[34]=S,e[35]=w,e[36]=j,e[37]=s.cron_expression,e[38]=s.event_type,e[39]=s.params,e[40]=A):A=e[40];let L;e[41]!==w?(L=w&&n.jsx(Se,{size:13,className:"animate-spin text-muted-foreground"}),e[41]=w,e[42]=L):L=e[42];let H;e[43]!==_||e[44]!==k||e[45]!==S||e[46]!==s.cron_expression?(H=k&&!_&&!S&&n.jsx(Q,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{y(s.cron_expression??""),v(!0)},children:n.jsx(Xd,{size:13,className:"text-muted-foreground"})}),e[43]=_,e[44]=k,e[45]=S,e[46]=s.cron_expression,e[47]=H):H=e[47];let $;e[48]!==j?($=j&&n.jsx(Q,{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(ns,{size:13,className:"text-muted-foreground"})}),e[48]=j,e[49]=$):$=e[49];let z;e[50]===Symbol.for("react.memo_cache_sentinel")?(z=n.jsx(Q,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>c(!0),children:n.jsx(ks,{size:13,className:"text-muted-foreground"})}),e[50]=z):z=e[50];let V;e[51]!==$||e[52]!==L||e[53]!==H?(V=n.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[L,H,$,z]}),e[51]=$,e[52]=L,e[53]=H,e[54]=V):V=e[54];let q;e[55]!==V||e[56]!==M||e[57]!==A?(q=n.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[M,A,V]}),e[55]=V,e[56]=M,e[57]=A,e[58]=q):q=e[58];let ee;e[59]===Symbol.for("react.memo_cache_sentinel")?(ee=n.jsxs(Jr,{children:[n.jsx(Zr,{children:"Remove Starter"}),n.jsx(Qr,{children:"Are you sure you want to remove this starter?"})]}),e[59]=ee):ee=e[59];let G;e[60]===Symbol.for("react.memo_cache_sentinel")?(G=n.jsx(tn,{children:"Cancel"}),e[60]=G):G=e[60];let Y;e[61]!==P?(Y=n.jsxs(Xr,{children:[ee,n.jsxs(en,{children:[G,n.jsx(sn,{onClick:P,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]}),e[61]=P,e[62]=Y):Y=e[62];let O;e[63]!==h||e[64]!==Y?(O=n.jsx(Yr,{open:h,onOpenChange:c,children:Y}),e[63]=h,e[64]=Y,e[65]=O):O=e[65];let X;e[66]===Symbol.for("react.memo_cache_sentinel")?(X=n.jsxs(Jr,{children:[n.jsx(Zr,{children:"Rotate webhook token"}),n.jsx(Qr,{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]=X):X=e[66];let J;e[67]===Symbol.for("react.memo_cache_sentinel")?(J=n.jsx(tn,{children:"Cancel"}),e[67]=J):J=e[67];let ie;e[68]!==B?(ie=n.jsxs(Xr,{children:[X,n.jsxs(en,{children:[J,n.jsx(sn,{onClick:B,children:"Rotate"})]})]}),e[68]=B,e[69]=ie):ie=e[69];let oe;e[70]!==d||e[71]!==ie?(oe=n.jsx(Yr,{open:d,onOpenChange:u,children:ie}),e[70]=d,e[71]=ie,e[72]=oe):oe=e[72];const W=f!==null;let ne;e[73]===Symbol.for("react.memo_cache_sentinel")?(ne=le=>{le||m(null)},e[73]=ne):ne=e[73];const me=f?.url??null,_e=f?.token??null;let pe;e[74]!==W||e[75]!==me||e[76]!==_e?(pe=n.jsx(ih,{open:W,onOpenChange:ne,url:me,token:_e,title:"New webhook token",description:"The previous token has been revoked. Copy the new token now — it will not be shown again."}),e[74]=W,e[75]=me,e[76]=_e,e[77]=pe):pe=e[77];let xe;return e[78]!==q||e[79]!==O||e[80]!==oe||e[81]!==pe?(xe=n.jsxs(n.Fragment,{children:[q,O,oe,pe]}),e[78]=q,e[79]=O,e[80]=oe,e[81]=pe,e[82]=xe):xe=e[82],xe}function J1(t){const[e,s]=t;return`${e}: ${s}`}function Z1(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 Q1(t){const e=F.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=hr(r),[a,l]=D.useState(),[h,c]=D.useState();let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d={},e[1]=d):d=e[1];const[u,f]=D.useState(d),{triggerAdd:m}=gi(),{data:p,isLoading:_}=Cu(a);let g,x,S,v,b,y;if(e[2]!==m||e[3]!==s||e[4]!==a||e[5]!==h||e[6]!==_||e[7]!==i||e[8]!==u||e[9]!==o||e[10]!==p){const j=p?.find(A=>A.type===h);let T;e[17]!==m||e[18]!==s||e[19]!==a||e[20]!==h||e[21]!==i||e[22]!==u?(T=async()=>{if(!(!a||!h))try{await m.mutateAsync({automation_id:s,type:"event",event_type:h,connection_id:a,params:u}),Ee("automation_trigger_added",{automation_id:s,trigger_type:"event",connection_id:a,event_type:h}),ae.success("Event trigger added"),i()}catch{ae.error("Failed to add event trigger")}},e[17]=m,e[18]=s,e[19]=a,e[20]=h,e[21]=i,e[22]=u,e[23]=T):T=e[23],g=T,x="flex flex-col gap-3 px-3 py-3 rounded-lg border border-border bg-background";let P,R;e[24]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(ti,{size:14,className:"text-muted-foreground shrink-0"}),P=n.jsx("span",{className:"text-sm font-medium",children:"Event trigger"}),e[24]=P,e[25]=R):(P=e[24],R=e[25]);let C;e[26]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(ks,{size:13}),e[26]=C):C=e[26],e[27]!==i?(S=n.jsxs("div",{className:"flex items-center gap-2",children:[R,P,n.jsx("button",{type:"button",className:"ml-auto shrink-0 p-0.5 rounded text-muted-foreground hover:text-foreground",onClick:i,children:C})]}),e[27]=i,e[28]=S):S=e[28];const N=a??"";let B;e[29]===Symbol.for("react.memo_cache_sentinel")?(B=A=>{l(A),c(void 0),f({})},e[29]=B):B=e[29];let I;e[30]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx(wt,{className:"w-full",children:n.jsx(Ct,{placeholder:"Select connection..."})}),e[30]=I):I=e[30];let E;e[31]!==o?(E=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(sx),e[31]=o,e[32]=E):E=e[32];let M;e[33]!==E?(M=n.jsx(kt,{children:E}),e[33]=E,e[34]=M):M=e[34],e[35]!==N||e[36]!==M?(v=n.jsxs(yt,{value:N,onValueChange:B,children:[I,M]}),e[35]=N,e[36]=M,e[37]=v):v=e[37],e[38]!==a||e[39]!==h||e[40]!==_||e[41]!==p?(b=a&&n.jsxs(yt,{value:h??"",onValueChange:A=>{c(A),f({})},children:[n.jsx(wt,{className:"w-full",children:_?n.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[n.jsx(Se,{size:13,className:"animate-spin"}),"Loading events..."]}):n.jsx(Ct,{placeholder:"Select event type...",children:h??"Select event type..."})}),n.jsx(kt,{children:p?.map(tx)})]}),e[38]=a,e[39]=h,e[40]=_,e[41]=p,e[42]=b):b=e[42],y=j?.paramsSchema&&Object.keys(j.paramsSchema).length>0&&n.jsx("div",{className:"flex flex-col gap-2",children:Object.entries(j.paramsSchema).map(A=>{const[L,H]=A;return n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsxs("label",{className:"text-xs text-muted-foreground",children:[L,H.description&&n.jsxs("span",{className:"text-muted-foreground/60",children:[" ","— ",H.description]})]}),H.enum?n.jsxs(yt,{value:u[L]??"",onValueChange:$=>f(z=>({...z,[L]:$})),children:[n.jsx(wt,{className:"w-full",children:n.jsx(Ct,{placeholder:`Select ${L}...`})}),n.jsx(kt,{children:H.enum.map(ex)})]}):n.jsx("input",{type:"text",value:u[L]??"",onChange:$=>f(z=>({...z,[L]:$.target.value})),placeholder:H.description??L,className:"text-sm border border-border rounded-md bg-background px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-ring"})]},L)})}),e[2]=m,e[3]=s,e[4]=a,e[5]=h,e[6]=_,e[7]=i,e[8]=u,e[9]=o,e[10]=p,e[11]=g,e[12]=x,e[13]=S,e[14]=v,e[15]=b,e[16]=y}else g=e[11],x=e[12],S=e[13],v=e[14],b=e[15],y=e[16];let w;e[43]!==m||e[44]!==a||e[45]!==h||e[46]!==g?(w=a&&h&&n.jsx(Q,{size:"sm",onClick:g,disabled:m.isPending,children:m.isPending?n.jsx(Se,{size:13,className:"animate-spin"}):"Add trigger"}),e[43]=m,e[44]=a,e[45]=h,e[46]=g,e[47]=w):w=e[47];let k;return e[48]!==x||e[49]!==S||e[50]!==v||e[51]!==b||e[52]!==y||e[53]!==w?(k=n.jsxs("div",{className:x,children:[S,v,b,y,w]}),e[48]=x,e[49]=S,e[50]=v,e[51]=b,e[52]=y,e[53]=w,e[54]=k):k=e[54],k}function ex(t){return n.jsx(Qe,{value:t,children:t},t)}function tx(t){return n.jsx(Qe,{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 sx(t){return n.jsx(Qe,{value:t.id,children:t.title},t.id)}function ix({automationId:t,automation:e,onBack:s,onDelete:i}){const r=e.virtual_mcp_id,{org:o}=ke(),{update:a,triggerAdd:l}=gi(),h=hr(),c=new Map(h.map(W=>[W.id,W.title])),{createTaskWithMessage:d}=ds(),{setSimpleModeTier:u}=or(),{setChatOpen:f}=eo(),{sendMessage:m}=hs(),[p,_]=Mh(),g=e.messages?.[0]?.metadata?.tiptapDoc??void 0,[x,S]=D.useState(g),[v,b]=D.useState(!1),[y,w]=D.useState(!1),[k,j]=D.useState(""),[T,P]=D.useState(!1),[R,C]=D.useState(null),[N,B]=D.useState(!1),[I,E]=D.useState(!1),[M,A]=D.useState(!1),L=async()=>{if(N)return;const ne=Lo(x).filter(me=>me.type==="text").map(me=>me.text).join(`
|
|
307
|
-
`);if(ne.trim()){B(!0);try{J(),Ee("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:ne.length}),f(!0),await m({tiptapDoc:zl({managerAgentId:pl.AUTOMATION_MANAGER(o.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:ne})})}finally{B(!1)}}},H=e.models?.tier??"smart",$=dl({defaultValues:{name:e.name,active:e.active,tier:H}}),z=$.watch("active"),[V,q]=D.useReducer(Z1,null),ee=()=>{V!==null&&(Ee("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(V.fields),save_count:V.saveCount,edit_duration_ms:Date.now()-V.start}),q({type:"reset"}))},G=async()=>{const W=$.control._formState.dirtyFields,ne=Object.keys(W);if(ne.length===0&&!M)return!0;const me=$.getValues(),_e=$.control._defaultValues;$.reset(me,{keepValues:!0});const pe=M;A(!1);const xe={id:t,name:me.name,active:me.active,models:{tier:me.tier},messages:Gh(x),temperature:0};try{await a.mutateAsync(xe)}catch{return $.reset(_e,{keepValues:!0}),pe&&A(!0),!1}const le=[...ne];return pe&&le.push("messages"),q({type:"accumulate",now:Date.now(),fields:le}),X(),!0},{schedule:Y,flush:O}=Xi({save:G}),{schedule:X,flush:J}=Xi({delayMs:3e4,save:async()=>ee()});D.useEffect(()=>{const W=$.watch(()=>Y());return()=>W.unsubscribe()},[]);const ie=W=>{if(S(W),!I){E(!0);return}A(!0),Y()},oe=async()=>{Ee("automation_test_clicked",{automation_id:t,agent_id:r});const W=await O();if(J(),!W)return;if(!x){ae.error("No instructions configured for this automation");return}u($.getValues("tier")),f(!0),_({...p,toolApprovalLevel:"auto"});const ne=Lo(x);d({message:{tiptapDoc:x,parts:ne},virtualMcpId:r||void 0})};return n.jsxs(n.Fragment,{children:[s&&n.jsx("div",{className:"flex items-center pb-4 shrink-0",children:n.jsxs(Q,{variant:"ghost",size:"sm",onClick:s,children:[n.jsx(cu,{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(at,{control:$.control,name:"name",render:({field:W})=>n.jsx(it,{...W,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(Q,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:i,children:n.jsx(Yi,{size:14})})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(at,{control:$.control,name:"active",render:({field:W})=>n.jsx(nn,{checked:W.value,onCheckedChange:ne=>{W.onChange(ne),O()},className:"cursor-pointer"})}),n.jsx("span",{className:"text-sm text-muted-foreground",children:z?"Active":"Inactive"}),n.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),n.jsx(El,{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(Y1,{automationId:t,open:v,onOpenChange:b,onCustomSelect:()=>{w(!0),P(!1),j("")},onEventSelect:()=>{P(!0),w(!1)},onWebhookCreated:W=>{Ee("automation_trigger_added",{automation_id:t,trigger_type:"webhook"}),C(W)}})]}),e.triggers.length===0&&!y?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:()=>b(!0),children:"Add a starter"})," ","to get going."]})}):n.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(W=>n.jsx(X1,{trigger:W,automationId:t,connectionName:W.connection_id?c.get(W.connection_id):void 0},W.id))}),y&&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(Js,{size:14,className:"text-muted-foreground shrink-0"}),n.jsx("input",{type:"text",value:k,onChange:W=>j(W.target.value),onBlur:async()=>{const W=k.trim();if(!(!W||!ei(W)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:W}),Ee("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),ae.success("Starter added"),w(!1),j("")}catch{ae.error("Failed to add starter")}},onKeyDown:async W=>{const ne=k.trim();W.key==="Enter"&&ne&&ei(ne)&&W.target.blur(),W.key==="Escape"&&(w(!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}),k&&!ei(k)&&n.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&n.jsx(Se,{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:()=>{w(!1),j("")},children:n.jsx(ks,{size:13})})]}),T&&n.jsx(D.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(Se,{size:13,className:"animate-spin text-muted-foreground"}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:n.jsx(Q1,{automationId:t,onDone:()=>P(!1)})}),n.jsx(ih,{open:R!==null,onOpenChange:W=>{W||C(null)},url:R?.url??null,token:R?.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(Q,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:N||!x,onClick:L,children:[n.jsx(oo,{size:13}),"Improve"]})]}),n.jsx(Hh,{tiptapDoc:x,setTiptapDoc:ie,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(Wh,{virtualMcpId:r||null,className:"max-h-[45vh]"}),n.jsxs("div",{className:"@container/chat-bottom flex items-center justify-end gap-1.5 p-2.5",children:[n.jsx(H1,{tier:$.watch("tier"),onSelect:W=>$.setValue("tier",W,{shouldDirty:!0})}),n.jsxs(Pe,{children:[n.jsx(Te,{asChild:!0,children:n.jsxs(Q,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:oe,disabled:!r,children:[n.jsx(Tu,{size:16}),"Test"]})}),n.jsx(Re,{children:"Test Automation"})]})]})]})})]})]})]})}function rx(t){const e=F.c(5),{tabId:s}=t;let i;e[0]!==s?(i=gl(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("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(Se,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=o):o=e[2];let a;return e[3]!==r.id?(a=n.jsx(pt,{children:n.jsx(pt.Content,{children:n.jsx(pt.Body,{children:n.jsx(D.Suspense,{fallback:o,children:n.jsx(nx,{id:r.id})})})})}),e[3]=r.id,e[4]=a):a=e[4],a}function nx(t){const e=F.c(8),{id:s}=t,i=Kt(),{data:r,isLoading:o}=ku(s);let a;e[0]!==i?(a=()=>{i({to:".",search:ox,replace:!0})},e[0]=i,e[1]=a):a=e[1];const l=a;if(o){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(Se,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=c):c=e[2],c}if(!r){let c;return e[3]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=c):c=e[3],c}let h;return e[4]!==r||e[5]!==s||e[6]!==l?(h=n.jsx(ix,{automationId:s,automation:r,onBack:l}),e[4]=r,e[5]=s,e[6]=l,e[7]=h):h=e[7],h}function ox(t){return{...t,main:"automations"}}function ax(t){const e=F.c(20),{virtualMcpId:s}=t,i=Kt(),{data:r}=ju(s),o=r===void 0?[]:r,{create:a}=gi(),[l,h]=D.useState(""),c=l.toLowerCase(),d=o.filter(R=>R.name.toLowerCase().includes(c));let u;e[0]!==i?(u=R=>i({to:".",search:C=>({...C,main:"automation:"+R}),replace:!0}),e[0]=i,e[1]=u):u=e[1];const f=u,m=async()=>{if(a.isPending)return;Ee("automation_new_clicked",{virtual_mcp_id:s,existing_count:o.length});const R=await a.mutateAsync(Eu(s));f(R.id)};let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(Ut,{size:14}),e[2]=p):p=e[2];let _;e[3]!==a.isPending||e[4]!==m?(_=n.jsxs(Q,{size:"sm",onClick:m,disabled:a.isPending,children:[p,"New automation"]}),e[3]=a.isPending,e[4]=m,e[5]=_):_=e[5];const g=_,x=pt,S=pt,v=pt;let b;e[6]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(pt.Title,{children:"Automations"}),e[6]=b):b=e[6];const y=o.length>0&&n.jsx(Ru,{value:l,onChange:h,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let w;e[7]!==g||e[8]!==y?(w=n.jsxs("div",{className:"flex flex-col gap-6",children:[b,n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[y,g]})]}),e[7]=g,e[8]=y,e[9]=w):w=e[9];const k=o.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(qi,{image:n.jsx(ti,{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:g})}):d.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(qi,{image:n.jsx(ti,{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:d.map(R=>n.jsx(Nu,{automation:R,onClick:()=>f(R.id)},R.id))});let j;e[10]!==k||e[11]!==v.Body||e[12]!==w?(j=n.jsxs(v.Body,{children:[w,k]}),e[10]=k,e[11]=v.Body,e[12]=w,e[13]=j):j=e[13];let T;e[14]!==j||e[15]!==S.Content?(T=n.jsx(S.Content,{children:j}),e[14]=j,e[15]=S.Content,e[16]=T):T=e[16];let P;return e[17]!==x||e[18]!==T?(P=n.jsx(x,{children:T}),e[17]=x,e[18]=T,e[19]=P):P=e[19],P}function lx(t){const e=F.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(Se,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx(D.Suspense,{fallback:i,children:n.jsx(ax,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const Qa=300;function rh(){const t=F.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(ys,{className:"h-6 w-2/3"}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:"flex h-full w-full items-center justify-center bg-white",children:n.jsxs("div",{className:"flex w-3/4 max-w-md flex-col gap-3 p-6",children:[e,n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsx(ys,{className:"h-3 w-full"}),n.jsx(ys,{className:"h-3 w-5/6"}),n.jsx(ys,{className:"h-3 w-2/3"})]}),n.jsx(ys,{className:"mt-2 h-8 w-24"})]})}),t[1]=s):s=t[1],s}function cx(t){const e=F.c(14),{url:s,title:i}=t,[r,o]=D.useState(!1),[a,l]=D.useState(!0);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=()=>o(!0),e[0]=h):h=e[0];const c=r?"opacity-100":"opacity-0";let d;e[1]!==c?(d=te("absolute inset-0 block w-full h-full bg-white","transition-opacity ease-out",c),e[1]=c,e[2]=d):d=e[2];let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u={transitionDuration:`${Qa}ms`},e[3]=u):u=e[3];let f;e[4]!==d||e[5]!==i||e[6]!==s?(f=n.jsx("iframe",{src:s,onLoad:h,sandbox:"allow-scripts",className:d,style:u,title:i}),e[4]=d,e[5]=i,e[6]=s,e[7]=f):f=e[7];let m;e[8]!==r||e[9]!==a?(m=a&&n.jsx("div",{className:te("absolute inset-0 transition-opacity ease-out",r?"opacity-0 pointer-events-none":"opacity-100"),style:{transitionDuration:`${Qa}ms`},onTransitionEnd:_=>{_.propertyName==="opacity"&&r&&l(!1)},children:n.jsx(rh,{})}),e[8]=r,e[9]=a,e[10]=m):m=e[10];let p;return e[11]!==f||e[12]!==m?(p=n.jsxs("div",{className:"relative h-full w-full bg-background",children:[f,m]}),e[11]=f,e[12]=m,e[13]=p):p=e[13],p}function hx(t,e){for(let s=t.length-1;s>=0;s--){const i=t[s]?.parts;if(i)for(let r=i.length-1;r>=0;r--){const o=i[r];if(!o||o.type!=="data-html-page-published")continue;const a=o.data;if(a&&a.slug===e)return a}}return null}function dx(t){const e=F.c(32),{url:s}=t,[i,r]=D.useState(!1);let o;e[0]!==s?(o=()=>{navigator.clipboard.writeText(s),r(!0),window.setTimeout(()=>r(!1),1500)},e[0]=s,e[1]=o):o=e[1];const a=o;let l;e[2]!==s?(l=()=>window.open(s,"_blank","noopener"),e[2]=s,e[3]=l):l=e[3];let h;e[4]!==s?(h=n.jsx("span",{className:"truncate",children:s}),e[4]=s,e[5]=h):h=e[5];let c;e[6]!==l||e[7]!==h||e[8]!==s?(c=n.jsx("button",{type:"button",onClick:l,className:"flex min-w-0 flex-1 items-center rounded-md px-2 py-1 text-left text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",title:s,children:h}),e[6]=l,e[7]=h,e[8]=s,e[9]=c):c=e[9];let d;e[10]!==i?(d=i?n.jsx(fi,{size:14}):n.jsx(es,{size:14}),e[10]=i,e[11]=d):d=e[11];let u;e[12]!==a||e[13]!==d?(u=n.jsx(Te,{asChild:!0,children:n.jsx(Q,{variant:"ghost",size:"icon",onClick:a,children:d})}),e[12]=a,e[13]=d,e[14]=u):u=e[14];const f=i?"Copied":"Copy URL";let m;e[15]!==f?(m=n.jsx(Re,{side:"bottom",children:f}),e[15]=f,e[16]=m):m=e[16];let p;e[17]!==u||e[18]!==m?(p=n.jsxs(Pe,{children:[u,m]}),e[17]=u,e[18]=m,e[19]=p):p=e[19];let _;e[20]!==s?(_=()=>window.open(s,"_blank","noopener"),e[20]=s,e[21]=_):_=e[21];let g;e[22]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(ms,{size:14}),e[22]=g):g=e[22];let x;e[23]!==_?(x=n.jsx(Te,{asChild:!0,children:n.jsx(Q,{variant:"ghost",size:"icon",onClick:_,children:g})}),e[23]=_,e[24]=x):x=e[24];let S;e[25]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(Re,{side:"bottom",children:"Open in new tab"}),e[25]=S):S=e[25];let v;e[26]!==x?(v=n.jsxs(Pe,{children:[x,S]}),e[26]=x,e[27]=v):v=e[27];let b;return e[28]!==v||e[29]!==c||e[30]!==p?(b=n.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-b border-border/60 px-2",children:[c,p,v]}),e[28]=v,e[29]=c,e[30]=p,e[31]=b):b=e[31],b}function ux(t){const e=F.c(15),{slug:s}=t,i=Yh();let r,o,a,l;if(e[0]!==s||e[1]!==i?.messages){l=Symbol.for("react.early_return_sentinel");e:{const m=i?.messages??[];if(r=hx(m,s),!r){let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx("div",{className:"h-full w-full bg-background",children:n.jsx(rh,{})}),e[6]=p):p=e[6],l=p;break e}o=r.url,a=r.url.includes("?")?"&":"?"}e[0]=s,e[1]=i?.messages,e[2]=r,e[3]=o,e[4]=a,e[5]=l}else r=e[2],o=e[3],a=e[4],l=e[5];if(l!==Symbol.for("react.early_return_sentinel"))return l;const h=`${o}${a}v=${r.bytes}`;let c;e[7]!==r.url?(c=n.jsx(dx,{url:r.url}),e[7]=r.url,e[8]=c):c=e[8];const d=`${s}.html`;let u;e[9]!==h||e[10]!==d?(u=n.jsx("div",{className:"relative flex-1",children:n.jsx(cx,{url:h,title:d})}),e[9]=h,e[10]=d,e[11]=u):u=e[11];let f;return e[12]!==c||e[13]!==u?(f=n.jsxs("div",{className:"flex h-full w-full flex-col bg-background",children:[c,u]}),e[12]=c,e[13]=u,e[14]=f):f=e[14],f}const el=D.lazy(()=>Gn(()=>import("./project-app-view-BAuYCSaY.js"),__vite__mapDeps([137,1,2,72,12,13,14,15,16,11,17,18,19,20,21,22,7,8,3,9,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,73,74,6,75,76,53,77,78,57,64,65,66,67,68,69,70,71,79,80,81,82,83,84,85,86,51,49,10,119])).then(t=>({default:t.AppViewContent})));function nh(t){const e=F.c(45),{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:h}=$l(r);if(nd(o)){let g;return e[3]!==i?(g=n.jsx(Zo,{virtualMcpId:i}),e[3]=i,e[4]=g):g=e[4],g}if(o==="git"){let g;return e[5]!==i?(g=n.jsx(Qm,{virtualMcpId:i}),e[5]=i,e[6]=g):g=e[6],g}if(o==="automations"){let g;return e[7]!==i?(g=n.jsx(lx,{virtualMcpId:i}),e[7]=i,e[8]=g):g=e[8],g}if(o==="preview"){let g;return e[9]!==i?(g=n.jsx(F1,{virtualMcpId:i}),e[9]=i,e[10]=g):g=e[10],g}if(h){let g;return e[11]!==o?(g=n.jsx(rx,{tabId:o}),e[11]=o,e[12]=g):g=e[12],g}let c;e[13]!==o?(c=od(o),e[13]=o,e[14]=c):c=e[14];const d=c;if(d){let g;return e[15]!==d.slug?(g=n.jsx(ux,{slug:d.slug}),e[15]=d.slug,e[16]=g):g=e[16],g}let u;e[17]!==o?(u=ad(o),e[17]=o,e[18]=u):u=e[18];const f=u;if(f){let g;if(e[19]!==l||e[20]!==f.connectionId||e[21]!==f.toolName){let y;e[23]!==f.connectionId||e[24]!==f.toolName?(y=w=>w.appId===f.connectionId&&w.toolName===f.toolName,e[23]=f.connectionId,e[24]=f.toolName,e[25]=y):y=e[25],g=l.find(y),e[19]=l,e[20]=f.connectionId,e[21]=f.toolName,e[22]=g}else g=e[22];const x=g;let S;e[26]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(Se,{size:20,className:"animate-spin text-muted-foreground"})}),e[26]=S):S=e[26];const v=x?.args;let b;return e[27]!==o||e[28]!==f.connectionId||e[29]!==f.toolName||e[30]!==v?(b=n.jsx(D.Suspense,{fallback:S,children:n.jsx(el,{connectionId:f.connectionId,toolName:f.toolName,args:v},o)}),e[27]=o,e[28]=f.connectionId,e[29]=f.toolName,e[30]=v,e[31]=b):b=e[31],b}let m;if(e[32]!==o||e[33]!==a){let g;e[35]!==o?(g=x=>x.id===o,e[35]=o,e[36]=g):g=e[36],m=a.find(g),e[32]=o,e[33]=a,e[34]=m}else m=e[34];const p=m;if(p){let g;e[37]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(Se,{size:20,className:"animate-spin text-muted-foreground"})}),e[37]=g):g=e[37];let x;return e[38]!==o||e[39]!==p.id||e[40]!==p.view.appId||e[41]!==p.view.args?(x=n.jsx(D.Suspense,{fallback:g,children:n.jsx(el,{connectionId:p.view.appId,toolName:p.id,args:p.view.args},o)}),e[38]=o,e[39]=p.id,e[40]=p.view.appId,e[41]=p.view.args,e[42]=x):x=e[42],x}let _;return e[43]!==i?(_=n.jsx(Zo,{virtualMcpId:i}),e[43]=i,e[44]=_):_=e[44],_}function fx(t){const e=F.c(10),{children:s,defaultSize:i,chatOpen:r}=t,[,o]=D.useTransition();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=fl.decoChatPanelWidth(),e[0]=a):a=e[0];const[l,h]=ul(a,45),c=i>0&&i<100?l:i;let d;e[1]!==h?(d=_=>o(()=>{_>0&&_<100&&h(_)}),e[1]=h,e[2]=d):d=e[2];const u=d,f=r?"min-w-[348px]":"min-w-0";let m;e[3]!==f?(m=te("overflow-hidden bg-sidebar",f),e[3]=f,e[4]=m):m=e[4];let p;return e[5]!==s||e[6]!==c||e[7]!==u||e[8]!==m?(p=n.jsx(Nl,{defaultSize:c,minSize:20,collapsible:!0,collapsedSize:0,className:m,onResize:u,order:1,children:s}),e[5]=s,e[6]=c,e[7]=u,e[8]=m,e[9]=p):p=e[9],p}function mx(t){const e=F.c(31),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:o,chatContent:a}=t;let l;e[0]!==r||e[1]!==o?(l=Vo(r,o),e[0]=r,e[1]=o,e[2]=l):l=e[2];const h=l;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=fl.decoChatPanelWidth(),e[3]=c):c=e[3];const[d]=ul(c,45),u=D.useRef(null);let f,m;e[4]!==r||e[5]!==o||e[6]!==d?(f=()=>{const P=u.current;if(!P)return;const R=Vo(r,o),C=R.chat>0&&R.chat<100?d:R.chat,N=R.chat>0&&R.chat<100?100-d:R.main;P.setLayout([C,N])},m=[r,o,d],e[4]=r,e[5]=o,e[6]=d,e[7]=f,e[8]=m):(f=e[7],m=e[8]),D.useEffect(f,m);const p=`${s}-${i}`;let _;e[9]===Symbol.for("react.memo_cache_sentinel")?(_={overflow:"visible"},e[9]=_):_=e[9];let g;e[10]!==a?(g=a??n.jsx(Ol,{}),e[10]=a,e[11]=g):g=e[11];let x;e[12]!==g?(x=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:g})}),e[12]=g,e[13]=x):x=e[13];let S;e[14]!==r||e[15]!==h.chat||e[16]!==x?(S=n.jsx(fx,{defaultSize:h.chat,chatOpen:r,children:x}),e[14]=r,e[15]=h.chat,e[16]=x,e[17]=S):S=e[17];let v;e[18]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(zd,{className:"bg-sidebar"}),e[18]=v):v=e[18];const b=h.main;let y;e[19]===Symbol.for("react.memo_cache_sentinel")?(y={overflow:"visible"},e[19]=y):y=e[19];let w;e[20]===Symbol.for("react.memo_cache_sentinel")?(w=te("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]"),e[20]=w):w=e[20];let k;e[21]!==i||e[22]!==s?(k=n.jsx("div",{className:"h-full p-0.5 pt-0.25",children:n.jsx("div",{className:w,children:n.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.jsx(It,{children:n.jsx(nh,{taskId:i,virtualMcpId:s})})})})}),e[21]=i,e[22]=s,e[23]=k):k=e[23];let j;e[24]!==h.main||e[25]!==k?(j=n.jsx(Nl,{className:"min-w-0 flex flex-col",order:2,defaultSize:b,style:y,collapsible:!0,collapsedSize:0,minSize:20,children:k}),e[24]=h.main,e[25]=k,e[26]=j):j=e[26];let T;return e[27]!==j||e[28]!==p||e[29]!==S?(T=n.jsxs(Fd,{ref:u,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:_,children:[S,v,j]},p),e[27]=j,e[28]=p,e[29]=S,e[30]=T):T=e[30],T}function px(t){const e=F.c(15),{chatOpen:s,toggleChat:i,onNewTask:r}=t;let o;e[0]!==s||e[1]!==i?(o=()=>{Ee("agent_toolbar_toggled",{button:"chat",next_state:s?"closed":"open"}),i()},e[0]=s,e[1]=i,e[2]=o):o=e[2];let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(Cl,{size:16}),e[3]=a):a=e[3];let l;e[4]!==s||e[5]!==o?(l=n.jsx(Te,{asChild:!0,children:n.jsx(Uo,{onClick:o,"aria-pressed":s,"aria-label":"Chat",active:s,children:a})}),e[4]=s,e[5]=o,e[6]=l):l=e[6];let h;e[7]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Re,{side:"bottom",children:"Chat"}),e[7]=h):h=e[7];let c;e[8]!==l?(c=n.jsxs(Pe,{delayDuration:300,children:[l,h]}),e[8]=l,e[9]=c):c=e[9];let d;e[10]!==r?(d=r&&n.jsxs(Pe,{delayDuration:300,children:[n.jsx(Te,{asChild:!0,children:n.jsx(Uo,{onClick:r,"aria-label":"New task",children:n.jsx(io,{size:16})})}),n.jsx(Re,{side:"bottom",children:"New task"})]}),e[10]=r,e[11]=d):d=e[11];let u;return e[12]!==c||e[13]!==d?(u=n.jsxs(n.Fragment,{children:[c,d]}),e[12]=c,e[13]=d,e[14]=u):u=e[14],u}function _x(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],h=r[a],c=[...i.slice(0,-1),h],d=[l,...r.slice(0,a),...r.slice(a+1)];return{visible:c,overflow:d}}function gx(t){const e=F.c(13),{title:s,icon:i,active:r,onClick:o}=t,a=r?"bg-sidebar-accent text-sidebar-foreground":"text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";let l;e[0]!==a?(l=te("shrink-0 flex items-center gap-1.5 h-8 rounded-md px-2","[transition:background-color_180ms_ease,color_180ms_ease]",a),e[0]=a,e[1]=l):l=e[1];let h;e[2]!==i?(h=n.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:n.jsx(vx,{icon:i})}),e[2]=i,e[3]=h):h=e[3];let c;e[4]!==s?(c=n.jsx("span",{className:"whitespace-nowrap text-sm font-medium leading-none",children:s}),e[4]=s,e[5]=c):c=e[5];let d;return e[6]!==r||e[7]!==o||e[8]!==l||e[9]!==h||e[10]!==c||e[11]!==s?(d=n.jsxs("button",{type:"button",onClick:o,"aria-pressed":r,"aria-label":s,className:l,children:[h,c]}),e[6]=r,e[7]=o,e[8]=l,e[9]=h,e[10]=c,e[11]=s,e[12]=d):d=e[12],d}function vx(t){const e=F.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let o;return e[0]!==r?(o=n.jsx(r,{className:"size-4"}),e[0]=r,e[1]=o):o=e[1],o}if(s.kind==="url"){let r;return e[2]!==s.src?(r=n.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(kl,{className:"size-4"}),e[4]=i):i=e[4],i}function xx(t){const e=F.c(13),{overflow:s,onSelect:i}=t,[r,o]=D.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 h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(hi,{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(ro,{className:"size-4"})})}),e[2]=h):h=e[2];let c;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(bx,{icon:m.icon})}),n.jsx("span",{className:"truncate",children:m.title})]})},m.id),e[6]=l,e[7]=f):f=e[7],c=s.map(f),e[3]=l,e[4]=s,e[5]=c}else c=e[5];let d;e[8]!==c?(d=n.jsx(di,{align:"end",className:"w-56 p-1",children:n.jsx("ul",{className:"flex flex-col",children:c})}),e[8]=c,e[9]=d):d=e[9];let u;return e[10]!==r||e[11]!==d?(u=n.jsxs(ci,{open:r,onOpenChange:o,children:[h,d]}),e[10]=r,e[11]=d,e[12]=u):u=e[12],u}function bx(t){const e=F.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let o;return e[0]!==r?(o=n.jsx(r,{className:"size-4"}),e[0]=r,e[1]=o):o=e[1],o}if(s.kind==="url"){let r;return e[2]!==s.src?(r=n.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(kl,{className:"size-4"}),e[4]=i):i=e[4],i}const Sx=6;function oh(t){const e=F.c(20),{virtualMcpId:s,taskId:i}=t,r=Kt();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:h,setActiveTab:c}=$l(o);let d,u,f,m;if(e[3]!==l||e[4]!==h||e[5]!==r||e[6]!==c||e[7]!==a||e[8]!==s){const g=ld({activeTab:l,mainOpen:h}),x=w=>w.id==="automations"?g:h&&w.id===l,v=a.find(w=>x(w))?.id??null,{visible:b,overflow:y}=_x(a,v,Sx);u=y,d=w=>{const k=a.find(T=>T.id===w),j=v===w&&h;if(Ee("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:w,tab_kind:k?.kind??null,was_active:j}),w==="automations"){const T=cd({activeTab:l,mainOpen:h});r({to:".",search:P=>({...P,main:T}),replace:!0});return}c(w)},f="flex items-center min-w-0 gap-0.5",m=b.map(w=>n.jsx(gx,{title:w.title,icon:w.icon,active:x(w),onClick:()=>d(w.id)},w.id)),e[3]=l,e[4]=h,e[5]=r,e[6]=c,e[7]=a,e[8]=s,e[9]=d,e[10]=u,e[11]=f,e[12]=m}else d=e[9],u=e[10],f=e[11],m=e[12];let p;e[13]!==d||e[14]!==u?(p=u.length>0&&n.jsx(xx,{overflow:u,onSelect:d}),e[13]=d,e[14]=u,e[15]=p):p=e[15];let _;return e[16]!==f||e[17]!==m||e[18]!==p?(_=n.jsxs("div",{className:f,children:[m,p]}),e[16]=f,e[17]=m,e[18]=p,e[19]=_):_=e[19],_}function Ps(t,e,s,i){return`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/git/${i}`}async function Ds(t){const e=await t.json();if(!t.ok)throw new Error(typeof e.error=="string"?e.error:`Request failed (${t.status})`);return e}function As(t,e){return fetch(t,{cache:"no-store",...e})}async function Vi(t,e,s){const i=await As(Ps(t,e,s,"status"));return Ds(i)}async function yx(t,e,s){const i=await As(Ps(t,e,s,"diff"),{method:"POST"});return Ds(i)}async function tl(t,e,s,i){const r=await As(Ps(t,e,s,"suggest-commit"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i??{})});return Ds(r)}async function sl(t,e,s,i){const r=await As(Ps(t,e,s,"publish"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({message:i})});await Ds(r)}async function wx(t,e,s,i){const r=await As(Ps(t,e,s,"rebase"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({base:i})});await Ds(r)}function il(t){if(!t)return!1;const e=Object.keys(t.diffs);return e.length===0?!1:e.every(s=>s===".deco"||s.startsWith(".deco/"))}const Cx="Code changes can't be published directly — use Submit for review";async function rl(t,e,s,i){const r=await As(Ps(t,e,s,"discard"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({filepaths:i})});await Ds(r)}const kx="current";function ko(t){return t?.[kx]??null}function jx(t,e,s){return["sandbox-git-status",t,e,s]}function ah(t){return t?t.modified.length+t.created.length+t.deleted.length+t.not_added.length+t.renamed.length:0}function lh(t){return t?ah(t)>0||t.staged.length>0||t.conflicted.length>0:!1}function Nx(t,e){return t?lh(t)||t.ahead>0||e!=null&&Object.keys(e.diffs).length>0:!1}function Ex(t,e){if(!e)return t;const s=lh(e),i=ko(e);return t.kind==="ready"?{...t,branch:i??t.branch,workingTreeDirty:s,unpushed:Math.max(t.unpushed,e.ahead)}:!i&&!s?t:{kind:"ready",branch:i??"",base:"main",workingTreeDirty:s,unpushed:e.ahead,aheadOfBase:0,behindBase:e.behind,headSha:""}}function Tx(t){const e=F.c(12),{orgSlug:s,virtualMcpId:i,branch:r,enabled:o}=t,a=o===void 0?!0:o,l=r??"";let h;e[0]!==s||e[1]!==l||e[2]!==i?(h=jx(s,i,l),e[0]=s,e[1]=l,e[2]=i,e[3]=h):h=e[3];let c;e[4]!==r||e[5]!==s||e[6]!==i?(c=()=>Vi(s,i,r),e[4]=r,e[5]=s,e[6]=i,e[7]=c):c=e[7];const d=a&&!!r;let u;return e[8]!==h||e[9]!==c||e[10]!==d?(u={queryKey:h,queryFn:c,enabled:d,refetchInterval:3e3,staleTime:1e3},e[8]=h,e[9]=c,e[10]=d,e[11]=u):u=e[11],nr(u)}function Rx(t){const e=F.c(21),{disabled:s,loading:i,onPublish:r,onReview:o}=t,a=i===void 0?!1:i;let l;e[0]!==r?(l=()=>{r()},e[0]=r,e[1]=l):l=e[1];let h;e[2]!==a?(h=a?n.jsx(Ll,{size:"xs",variant:"default"}):null,e[2]=a,e[3]=h):h=e[3];let c;e[4]!==s||e[5]!==l||e[6]!==h?(c=n.jsxs(Q,{size:"sm",variant:"success",className:"rounded-r-none border-r border-success-foreground/20",disabled:s,onClick:l,children:[h,"Publish"]}),e[4]=s,e[5]=l,e[6]=h,e[7]=c):c=e[7];let d;e[8]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(co,{className:"h-3.5 w-3.5"}),e[8]=d):d=e[8];let u;e[9]!==s?(u=n.jsx(pi,{asChild:!0,children:n.jsx(Q,{size:"sm",variant:"success",className:"rounded-l-none px-2",disabled:s,"aria-label":"More actions",children:d})}),e[9]=s,e[10]=u):u=e[10];let f;e[11]!==o?(f=o?n.jsx(Dt,{onClick:o,children:"Review"}):null,e[11]=o,e[12]=f):f=e[12];let m;e[13]!==f?(m=n.jsx(_i,{align:"end",children:f}),e[13]=f,e[14]=m):m=e[14];let p;e[15]!==u||e[16]!==m?(p=n.jsxs(mi,{children:[u,m]}),e[15]=u,e[16]=m,e[17]=p):p=e[17];let _;return e[18]!==c||e[19]!==p?(_=n.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[c,p]}),e[18]=c,e[19]=p,e[20]=_):_=e[20],_}function ch(t){return t.trim()?(t.startsWith("/")?t:`/${t}`).replace(/\/+/g,"/"):"/"}function Px(t){if(!t)return"plaintext";const e=t.toLowerCase();return e.endsWith(".tsx")||e.endsWith(".ts")?"typescript":e.endsWith(".jsx")||e.endsWith(".js")||e.endsWith(".mjs")||e.endsWith(".cjs")?"javascript":e.endsWith(".json")?"json":e.endsWith(".md")||e.endsWith(".mdx")?"markdown":e.endsWith(".css")?"css":e.endsWith(".scss")?"scss":e.endsWith(".html")?"html":e.endsWith(".yaml")||e.endsWith(".yml")?"yaml":e.endsWith(".xml")||e.endsWith(".svg")?"xml":e.endsWith(".py")?"python":e.endsWith(".sql")?"sql":e.endsWith(".sh")?"shell":"plaintext"}function L0(t){const e=ch(t).split("/").filter(Boolean),s=["/"];let i="";for(const r of e.slice(0,-1))i+=`/${r}`,s.push(i);return s}function O0(t){const e={children:[]};for(const i of t){const o=ch(i).split("/").filter(Boolean);let a=e,l="";o.forEach((h,c)=>{l+=`/${h}`;const d=c===o.length-1;let u=a.children.find(f=>f.name===h);u||(u={name:h,path:l,kind:d?"file":"directory",children:[]},a.children.push(u)),a=u})}const s=i=>{i.sort((r,o)=>r.kind!==o.kind?r.kind==="directory"?-1:1:r.name.localeCompare(o.name));for(const r of i)r.children.length>0&&s(r.children)};return s(e.children),e.children}function Dx(t,e,s=0){const i=[];for(const r of t)i.push({node:r,depth:s}),r.kind==="directory"&&r.children.length>0&&e.has(r.path)&&i.push(...Dx(r.children,e,s+1));return i}function $0(t){return t.split(`
|
|
307
|
+
`);if(ne.trim()){B(!0);try{J(),Ee("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:ne.length}),f(!0),await m({tiptapDoc:zl({managerAgentId:pl.AUTOMATION_MANAGER(o.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:ne})})}finally{B(!1)}}},H=e.models?.tier??"smart",$=dl({defaultValues:{name:e.name,active:e.active,tier:H}}),z=$.watch("active"),[V,q]=D.useReducer(Z1,null),ee=()=>{V!==null&&(Ee("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(V.fields),save_count:V.saveCount,edit_duration_ms:Date.now()-V.start}),q({type:"reset"}))},G=async()=>{const W=$.control._formState.dirtyFields,ne=Object.keys(W);if(ne.length===0&&!M)return!0;const me=$.getValues(),_e=$.control._defaultValues;$.reset(me,{keepValues:!0});const pe=M;A(!1);const xe={id:t,name:me.name,active:me.active,models:{tier:me.tier},messages:Gh(x),temperature:0};try{await a.mutateAsync(xe)}catch{return $.reset(_e,{keepValues:!0}),pe&&A(!0),!1}const le=[...ne];return pe&&le.push("messages"),q({type:"accumulate",now:Date.now(),fields:le}),X(),!0},{schedule:Y,flush:O}=Xi({save:G}),{schedule:X,flush:J}=Xi({delayMs:3e4,save:async()=>ee()});D.useEffect(()=>{const W=$.watch(()=>Y());return()=>W.unsubscribe()},[]);const ie=W=>{if(S(W),!I){E(!0);return}A(!0),Y()},oe=async()=>{Ee("automation_test_clicked",{automation_id:t,agent_id:r});const W=await O();if(J(),!W)return;if(!x){ae.error("No instructions configured for this automation");return}u($.getValues("tier")),f(!0),_({...p,toolApprovalLevel:"auto"});const ne=Lo(x);d({message:{tiptapDoc:x,parts:ne},virtualMcpId:r||void 0})};return n.jsxs(n.Fragment,{children:[s&&n.jsx("div",{className:"flex items-center pb-4 shrink-0",children:n.jsxs(Q,{variant:"ghost",size:"sm",onClick:s,children:[n.jsx(cu,{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(at,{control:$.control,name:"name",render:({field:W})=>n.jsx(it,{...W,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(Q,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:i,children:n.jsx(Yi,{size:14})})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(at,{control:$.control,name:"active",render:({field:W})=>n.jsx(nn,{checked:W.value,onCheckedChange:ne=>{W.onChange(ne),O()},className:"cursor-pointer"})}),n.jsx("span",{className:"text-sm text-muted-foreground",children:z?"Active":"Inactive"}),n.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),n.jsx(El,{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(Y1,{automationId:t,open:v,onOpenChange:b,onCustomSelect:()=>{w(!0),P(!1),j("")},onEventSelect:()=>{P(!0),w(!1)},onWebhookCreated:W=>{Ee("automation_trigger_added",{automation_id:t,trigger_type:"webhook"}),C(W)}})]}),e.triggers.length===0&&!y?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:()=>b(!0),children:"Add a starter"})," ","to get going."]})}):n.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(W=>n.jsx(X1,{trigger:W,automationId:t,connectionName:W.connection_id?c.get(W.connection_id):void 0},W.id))}),y&&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(Js,{size:14,className:"text-muted-foreground shrink-0"}),n.jsx("input",{type:"text",value:k,onChange:W=>j(W.target.value),onBlur:async()=>{const W=k.trim();if(!(!W||!ei(W)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:W}),Ee("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),ae.success("Starter added"),w(!1),j("")}catch{ae.error("Failed to add starter")}},onKeyDown:async W=>{const ne=k.trim();W.key==="Enter"&&ne&&ei(ne)&&W.target.blur(),W.key==="Escape"&&(w(!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}),k&&!ei(k)&&n.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&n.jsx(Se,{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:()=>{w(!1),j("")},children:n.jsx(ks,{size:13})})]}),T&&n.jsx(D.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(Se,{size:13,className:"animate-spin text-muted-foreground"}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:n.jsx(Q1,{automationId:t,onDone:()=>P(!1)})}),n.jsx(ih,{open:R!==null,onOpenChange:W=>{W||C(null)},url:R?.url??null,token:R?.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(Q,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:N||!x,onClick:L,children:[n.jsx(oo,{size:13}),"Improve"]})]}),n.jsx(Hh,{tiptapDoc:x,setTiptapDoc:ie,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(Wh,{virtualMcpId:r||null,className:"max-h-[45vh]"}),n.jsxs("div",{className:"@container/chat-bottom flex items-center justify-end gap-1.5 p-2.5",children:[n.jsx(H1,{tier:$.watch("tier"),onSelect:W=>$.setValue("tier",W,{shouldDirty:!0})}),n.jsxs(Pe,{children:[n.jsx(Te,{asChild:!0,children:n.jsxs(Q,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:oe,disabled:!r,children:[n.jsx(Tu,{size:16}),"Test"]})}),n.jsx(Re,{children:"Test Automation"})]})]})]})})]})]})]})}function rx(t){const e=F.c(5),{tabId:s}=t;let i;e[0]!==s?(i=gl(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("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(Se,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=o):o=e[2];let a;return e[3]!==r.id?(a=n.jsx(pt,{children:n.jsx(pt.Content,{children:n.jsx(pt.Body,{children:n.jsx(D.Suspense,{fallback:o,children:n.jsx(nx,{id:r.id})})})})}),e[3]=r.id,e[4]=a):a=e[4],a}function nx(t){const e=F.c(8),{id:s}=t,i=Kt(),{data:r,isLoading:o}=ku(s);let a;e[0]!==i?(a=()=>{i({to:".",search:ox,replace:!0})},e[0]=i,e[1]=a):a=e[1];const l=a;if(o){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(Se,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=c):c=e[2],c}if(!r){let c;return e[3]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=c):c=e[3],c}let h;return e[4]!==r||e[5]!==s||e[6]!==l?(h=n.jsx(ix,{automationId:s,automation:r,onBack:l}),e[4]=r,e[5]=s,e[6]=l,e[7]=h):h=e[7],h}function ox(t){return{...t,main:"automations"}}function ax(t){const e=F.c(20),{virtualMcpId:s}=t,i=Kt(),{data:r}=ju(s),o=r===void 0?[]:r,{create:a}=gi(),[l,h]=D.useState(""),c=l.toLowerCase(),d=o.filter(R=>R.name.toLowerCase().includes(c));let u;e[0]!==i?(u=R=>i({to:".",search:C=>({...C,main:"automation:"+R}),replace:!0}),e[0]=i,e[1]=u):u=e[1];const f=u,m=async()=>{if(a.isPending)return;Ee("automation_new_clicked",{virtual_mcp_id:s,existing_count:o.length});const R=await a.mutateAsync(Eu(s));f(R.id)};let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(Ut,{size:14}),e[2]=p):p=e[2];let _;e[3]!==a.isPending||e[4]!==m?(_=n.jsxs(Q,{size:"sm",onClick:m,disabled:a.isPending,children:[p,"New automation"]}),e[3]=a.isPending,e[4]=m,e[5]=_):_=e[5];const g=_,x=pt,S=pt,v=pt;let b;e[6]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(pt.Title,{children:"Automations"}),e[6]=b):b=e[6];const y=o.length>0&&n.jsx(Ru,{value:l,onChange:h,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let w;e[7]!==g||e[8]!==y?(w=n.jsxs("div",{className:"flex flex-col gap-6",children:[b,n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[y,g]})]}),e[7]=g,e[8]=y,e[9]=w):w=e[9];const k=o.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(qi,{image:n.jsx(ti,{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:g})}):d.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(qi,{image:n.jsx(ti,{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:d.map(R=>n.jsx(Nu,{automation:R,onClick:()=>f(R.id)},R.id))});let j;e[10]!==k||e[11]!==v.Body||e[12]!==w?(j=n.jsxs(v.Body,{children:[w,k]}),e[10]=k,e[11]=v.Body,e[12]=w,e[13]=j):j=e[13];let T;e[14]!==j||e[15]!==S.Content?(T=n.jsx(S.Content,{children:j}),e[14]=j,e[15]=S.Content,e[16]=T):T=e[16];let P;return e[17]!==x||e[18]!==T?(P=n.jsx(x,{children:T}),e[17]=x,e[18]=T,e[19]=P):P=e[19],P}function lx(t){const e=F.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(Se,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx(D.Suspense,{fallback:i,children:n.jsx(ax,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const Qa=300;function rh(){const t=F.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(ys,{className:"h-6 w-2/3"}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:"flex h-full w-full items-center justify-center bg-white",children:n.jsxs("div",{className:"flex w-3/4 max-w-md flex-col gap-3 p-6",children:[e,n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsx(ys,{className:"h-3 w-full"}),n.jsx(ys,{className:"h-3 w-5/6"}),n.jsx(ys,{className:"h-3 w-2/3"})]}),n.jsx(ys,{className:"mt-2 h-8 w-24"})]})}),t[1]=s):s=t[1],s}function cx(t){const e=F.c(14),{url:s,title:i}=t,[r,o]=D.useState(!1),[a,l]=D.useState(!0);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=()=>o(!0),e[0]=h):h=e[0];const c=r?"opacity-100":"opacity-0";let d;e[1]!==c?(d=te("absolute inset-0 block w-full h-full bg-white","transition-opacity ease-out",c),e[1]=c,e[2]=d):d=e[2];let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u={transitionDuration:`${Qa}ms`},e[3]=u):u=e[3];let f;e[4]!==d||e[5]!==i||e[6]!==s?(f=n.jsx("iframe",{src:s,onLoad:h,sandbox:"allow-scripts",className:d,style:u,title:i}),e[4]=d,e[5]=i,e[6]=s,e[7]=f):f=e[7];let m;e[8]!==r||e[9]!==a?(m=a&&n.jsx("div",{className:te("absolute inset-0 transition-opacity ease-out",r?"opacity-0 pointer-events-none":"opacity-100"),style:{transitionDuration:`${Qa}ms`},onTransitionEnd:_=>{_.propertyName==="opacity"&&r&&l(!1)},children:n.jsx(rh,{})}),e[8]=r,e[9]=a,e[10]=m):m=e[10];let p;return e[11]!==f||e[12]!==m?(p=n.jsxs("div",{className:"relative h-full w-full bg-background",children:[f,m]}),e[11]=f,e[12]=m,e[13]=p):p=e[13],p}function hx(t,e){for(let s=t.length-1;s>=0;s--){const i=t[s]?.parts;if(i)for(let r=i.length-1;r>=0;r--){const o=i[r];if(!o||o.type!=="data-html-page-published")continue;const a=o.data;if(a&&a.slug===e)return a}}return null}function dx(t){const e=F.c(32),{url:s}=t,[i,r]=D.useState(!1);let o;e[0]!==s?(o=()=>{navigator.clipboard.writeText(s),r(!0),window.setTimeout(()=>r(!1),1500)},e[0]=s,e[1]=o):o=e[1];const a=o;let l;e[2]!==s?(l=()=>window.open(s,"_blank","noopener"),e[2]=s,e[3]=l):l=e[3];let h;e[4]!==s?(h=n.jsx("span",{className:"truncate",children:s}),e[4]=s,e[5]=h):h=e[5];let c;e[6]!==l||e[7]!==h||e[8]!==s?(c=n.jsx("button",{type:"button",onClick:l,className:"flex min-w-0 flex-1 items-center rounded-md px-2 py-1 text-left text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",title:s,children:h}),e[6]=l,e[7]=h,e[8]=s,e[9]=c):c=e[9];let d;e[10]!==i?(d=i?n.jsx(fi,{size:14}):n.jsx(es,{size:14}),e[10]=i,e[11]=d):d=e[11];let u;e[12]!==a||e[13]!==d?(u=n.jsx(Te,{asChild:!0,children:n.jsx(Q,{variant:"ghost",size:"icon",onClick:a,children:d})}),e[12]=a,e[13]=d,e[14]=u):u=e[14];const f=i?"Copied":"Copy URL";let m;e[15]!==f?(m=n.jsx(Re,{side:"bottom",children:f}),e[15]=f,e[16]=m):m=e[16];let p;e[17]!==u||e[18]!==m?(p=n.jsxs(Pe,{children:[u,m]}),e[17]=u,e[18]=m,e[19]=p):p=e[19];let _;e[20]!==s?(_=()=>window.open(s,"_blank","noopener"),e[20]=s,e[21]=_):_=e[21];let g;e[22]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(ms,{size:14}),e[22]=g):g=e[22];let x;e[23]!==_?(x=n.jsx(Te,{asChild:!0,children:n.jsx(Q,{variant:"ghost",size:"icon",onClick:_,children:g})}),e[23]=_,e[24]=x):x=e[24];let S;e[25]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(Re,{side:"bottom",children:"Open in new tab"}),e[25]=S):S=e[25];let v;e[26]!==x?(v=n.jsxs(Pe,{children:[x,S]}),e[26]=x,e[27]=v):v=e[27];let b;return e[28]!==v||e[29]!==c||e[30]!==p?(b=n.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-b border-border/60 px-2",children:[c,p,v]}),e[28]=v,e[29]=c,e[30]=p,e[31]=b):b=e[31],b}function ux(t){const e=F.c(15),{slug:s}=t,i=Yh();let r,o,a,l;if(e[0]!==s||e[1]!==i?.messages){l=Symbol.for("react.early_return_sentinel");e:{const m=i?.messages??[];if(r=hx(m,s),!r){let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx("div",{className:"h-full w-full bg-background",children:n.jsx(rh,{})}),e[6]=p):p=e[6],l=p;break e}o=r.url,a=r.url.includes("?")?"&":"?"}e[0]=s,e[1]=i?.messages,e[2]=r,e[3]=o,e[4]=a,e[5]=l}else r=e[2],o=e[3],a=e[4],l=e[5];if(l!==Symbol.for("react.early_return_sentinel"))return l;const h=`${o}${a}v=${r.bytes}`;let c;e[7]!==r.url?(c=n.jsx(dx,{url:r.url}),e[7]=r.url,e[8]=c):c=e[8];const d=`${s}.html`;let u;e[9]!==h||e[10]!==d?(u=n.jsx("div",{className:"relative flex-1",children:n.jsx(cx,{url:h,title:d})}),e[9]=h,e[10]=d,e[11]=u):u=e[11];let f;return e[12]!==c||e[13]!==u?(f=n.jsxs("div",{className:"flex h-full w-full flex-col bg-background",children:[c,u]}),e[12]=c,e[13]=u,e[14]=f):f=e[14],f}const el=D.lazy(()=>Gn(()=>import("./project-app-view-Bk-35e4q.js"),__vite__mapDeps([137,1,2,72,12,13,14,15,16,11,17,18,19,20,21,22,7,8,3,9,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,73,74,6,75,76,53,77,78,57,64,65,66,67,68,69,70,71,79,80,81,82,83,84,85,86,51,49,10,119])).then(t=>({default:t.AppViewContent})));function nh(t){const e=F.c(45),{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:h}=$l(r);if(nd(o)){let g;return e[3]!==i?(g=n.jsx(Zo,{virtualMcpId:i}),e[3]=i,e[4]=g):g=e[4],g}if(o==="git"){let g;return e[5]!==i?(g=n.jsx(Qm,{virtualMcpId:i}),e[5]=i,e[6]=g):g=e[6],g}if(o==="automations"){let g;return e[7]!==i?(g=n.jsx(lx,{virtualMcpId:i}),e[7]=i,e[8]=g):g=e[8],g}if(o==="preview"){let g;return e[9]!==i?(g=n.jsx(F1,{virtualMcpId:i}),e[9]=i,e[10]=g):g=e[10],g}if(h){let g;return e[11]!==o?(g=n.jsx(rx,{tabId:o}),e[11]=o,e[12]=g):g=e[12],g}let c;e[13]!==o?(c=od(o),e[13]=o,e[14]=c):c=e[14];const d=c;if(d){let g;return e[15]!==d.slug?(g=n.jsx(ux,{slug:d.slug}),e[15]=d.slug,e[16]=g):g=e[16],g}let u;e[17]!==o?(u=ad(o),e[17]=o,e[18]=u):u=e[18];const f=u;if(f){let g;if(e[19]!==l||e[20]!==f.connectionId||e[21]!==f.toolName){let y;e[23]!==f.connectionId||e[24]!==f.toolName?(y=w=>w.appId===f.connectionId&&w.toolName===f.toolName,e[23]=f.connectionId,e[24]=f.toolName,e[25]=y):y=e[25],g=l.find(y),e[19]=l,e[20]=f.connectionId,e[21]=f.toolName,e[22]=g}else g=e[22];const x=g;let S;e[26]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(Se,{size:20,className:"animate-spin text-muted-foreground"})}),e[26]=S):S=e[26];const v=x?.args;let b;return e[27]!==o||e[28]!==f.connectionId||e[29]!==f.toolName||e[30]!==v?(b=n.jsx(D.Suspense,{fallback:S,children:n.jsx(el,{connectionId:f.connectionId,toolName:f.toolName,args:v},o)}),e[27]=o,e[28]=f.connectionId,e[29]=f.toolName,e[30]=v,e[31]=b):b=e[31],b}let m;if(e[32]!==o||e[33]!==a){let g;e[35]!==o?(g=x=>x.id===o,e[35]=o,e[36]=g):g=e[36],m=a.find(g),e[32]=o,e[33]=a,e[34]=m}else m=e[34];const p=m;if(p){let g;e[37]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(Se,{size:20,className:"animate-spin text-muted-foreground"})}),e[37]=g):g=e[37];let x;return e[38]!==o||e[39]!==p.id||e[40]!==p.view.appId||e[41]!==p.view.args?(x=n.jsx(D.Suspense,{fallback:g,children:n.jsx(el,{connectionId:p.view.appId,toolName:p.id,args:p.view.args},o)}),e[38]=o,e[39]=p.id,e[40]=p.view.appId,e[41]=p.view.args,e[42]=x):x=e[42],x}let _;return e[43]!==i?(_=n.jsx(Zo,{virtualMcpId:i}),e[43]=i,e[44]=_):_=e[44],_}function fx(t){const e=F.c(10),{children:s,defaultSize:i,chatOpen:r}=t,[,o]=D.useTransition();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=fl.decoChatPanelWidth(),e[0]=a):a=e[0];const[l,h]=ul(a,45),c=i>0&&i<100?l:i;let d;e[1]!==h?(d=_=>o(()=>{_>0&&_<100&&h(_)}),e[1]=h,e[2]=d):d=e[2];const u=d,f=r?"min-w-[348px]":"min-w-0";let m;e[3]!==f?(m=te("overflow-hidden bg-sidebar",f),e[3]=f,e[4]=m):m=e[4];let p;return e[5]!==s||e[6]!==c||e[7]!==u||e[8]!==m?(p=n.jsx(Nl,{defaultSize:c,minSize:20,collapsible:!0,collapsedSize:0,className:m,onResize:u,order:1,children:s}),e[5]=s,e[6]=c,e[7]=u,e[8]=m,e[9]=p):p=e[9],p}function mx(t){const e=F.c(31),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:o,chatContent:a}=t;let l;e[0]!==r||e[1]!==o?(l=Vo(r,o),e[0]=r,e[1]=o,e[2]=l):l=e[2];const h=l;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=fl.decoChatPanelWidth(),e[3]=c):c=e[3];const[d]=ul(c,45),u=D.useRef(null);let f,m;e[4]!==r||e[5]!==o||e[6]!==d?(f=()=>{const P=u.current;if(!P)return;const R=Vo(r,o),C=R.chat>0&&R.chat<100?d:R.chat,N=R.chat>0&&R.chat<100?100-d:R.main;P.setLayout([C,N])},m=[r,o,d],e[4]=r,e[5]=o,e[6]=d,e[7]=f,e[8]=m):(f=e[7],m=e[8]),D.useEffect(f,m);const p=`${s}-${i}`;let _;e[9]===Symbol.for("react.memo_cache_sentinel")?(_={overflow:"visible"},e[9]=_):_=e[9];let g;e[10]!==a?(g=a??n.jsx(Ol,{}),e[10]=a,e[11]=g):g=e[11];let x;e[12]!==g?(x=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:g})}),e[12]=g,e[13]=x):x=e[13];let S;e[14]!==r||e[15]!==h.chat||e[16]!==x?(S=n.jsx(fx,{defaultSize:h.chat,chatOpen:r,children:x}),e[14]=r,e[15]=h.chat,e[16]=x,e[17]=S):S=e[17];let v;e[18]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(zd,{className:"bg-sidebar"}),e[18]=v):v=e[18];const b=h.main;let y;e[19]===Symbol.for("react.memo_cache_sentinel")?(y={overflow:"visible"},e[19]=y):y=e[19];let w;e[20]===Symbol.for("react.memo_cache_sentinel")?(w=te("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]"),e[20]=w):w=e[20];let k;e[21]!==i||e[22]!==s?(k=n.jsx("div",{className:"h-full p-0.5 pt-0.25",children:n.jsx("div",{className:w,children:n.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.jsx(It,{children:n.jsx(nh,{taskId:i,virtualMcpId:s})})})})}),e[21]=i,e[22]=s,e[23]=k):k=e[23];let j;e[24]!==h.main||e[25]!==k?(j=n.jsx(Nl,{className:"min-w-0 flex flex-col",order:2,defaultSize:b,style:y,collapsible:!0,collapsedSize:0,minSize:20,children:k}),e[24]=h.main,e[25]=k,e[26]=j):j=e[26];let T;return e[27]!==j||e[28]!==p||e[29]!==S?(T=n.jsxs(Fd,{ref:u,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:_,children:[S,v,j]},p),e[27]=j,e[28]=p,e[29]=S,e[30]=T):T=e[30],T}function px(t){const e=F.c(15),{chatOpen:s,toggleChat:i,onNewTask:r}=t;let o;e[0]!==s||e[1]!==i?(o=()=>{Ee("agent_toolbar_toggled",{button:"chat",next_state:s?"closed":"open"}),i()},e[0]=s,e[1]=i,e[2]=o):o=e[2];let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(Cl,{size:16}),e[3]=a):a=e[3];let l;e[4]!==s||e[5]!==o?(l=n.jsx(Te,{asChild:!0,children:n.jsx(Uo,{onClick:o,"aria-pressed":s,"aria-label":"Chat",active:s,children:a})}),e[4]=s,e[5]=o,e[6]=l):l=e[6];let h;e[7]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Re,{side:"bottom",children:"Chat"}),e[7]=h):h=e[7];let c;e[8]!==l?(c=n.jsxs(Pe,{delayDuration:300,children:[l,h]}),e[8]=l,e[9]=c):c=e[9];let d;e[10]!==r?(d=r&&n.jsxs(Pe,{delayDuration:300,children:[n.jsx(Te,{asChild:!0,children:n.jsx(Uo,{onClick:r,"aria-label":"New task",children:n.jsx(io,{size:16})})}),n.jsx(Re,{side:"bottom",children:"New task"})]}),e[10]=r,e[11]=d):d=e[11];let u;return e[12]!==c||e[13]!==d?(u=n.jsxs(n.Fragment,{children:[c,d]}),e[12]=c,e[13]=d,e[14]=u):u=e[14],u}function _x(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],h=r[a],c=[...i.slice(0,-1),h],d=[l,...r.slice(0,a),...r.slice(a+1)];return{visible:c,overflow:d}}function gx(t){const e=F.c(13),{title:s,icon:i,active:r,onClick:o}=t,a=r?"bg-sidebar-accent text-sidebar-foreground":"text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";let l;e[0]!==a?(l=te("shrink-0 flex items-center gap-1.5 h-8 rounded-md px-2","[transition:background-color_180ms_ease,color_180ms_ease]",a),e[0]=a,e[1]=l):l=e[1];let h;e[2]!==i?(h=n.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:n.jsx(vx,{icon:i})}),e[2]=i,e[3]=h):h=e[3];let c;e[4]!==s?(c=n.jsx("span",{className:"whitespace-nowrap text-sm font-medium leading-none",children:s}),e[4]=s,e[5]=c):c=e[5];let d;return e[6]!==r||e[7]!==o||e[8]!==l||e[9]!==h||e[10]!==c||e[11]!==s?(d=n.jsxs("button",{type:"button",onClick:o,"aria-pressed":r,"aria-label":s,className:l,children:[h,c]}),e[6]=r,e[7]=o,e[8]=l,e[9]=h,e[10]=c,e[11]=s,e[12]=d):d=e[12],d}function vx(t){const e=F.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let o;return e[0]!==r?(o=n.jsx(r,{className:"size-4"}),e[0]=r,e[1]=o):o=e[1],o}if(s.kind==="url"){let r;return e[2]!==s.src?(r=n.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(kl,{className:"size-4"}),e[4]=i):i=e[4],i}function xx(t){const e=F.c(13),{overflow:s,onSelect:i}=t,[r,o]=D.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 h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(hi,{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(ro,{className:"size-4"})})}),e[2]=h):h=e[2];let c;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(bx,{icon:m.icon})}),n.jsx("span",{className:"truncate",children:m.title})]})},m.id),e[6]=l,e[7]=f):f=e[7],c=s.map(f),e[3]=l,e[4]=s,e[5]=c}else c=e[5];let d;e[8]!==c?(d=n.jsx(di,{align:"end",className:"w-56 p-1",children:n.jsx("ul",{className:"flex flex-col",children:c})}),e[8]=c,e[9]=d):d=e[9];let u;return e[10]!==r||e[11]!==d?(u=n.jsxs(ci,{open:r,onOpenChange:o,children:[h,d]}),e[10]=r,e[11]=d,e[12]=u):u=e[12],u}function bx(t){const e=F.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let o;return e[0]!==r?(o=n.jsx(r,{className:"size-4"}),e[0]=r,e[1]=o):o=e[1],o}if(s.kind==="url"){let r;return e[2]!==s.src?(r=n.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(kl,{className:"size-4"}),e[4]=i):i=e[4],i}const Sx=6;function oh(t){const e=F.c(20),{virtualMcpId:s,taskId:i}=t,r=Kt();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:h,setActiveTab:c}=$l(o);let d,u,f,m;if(e[3]!==l||e[4]!==h||e[5]!==r||e[6]!==c||e[7]!==a||e[8]!==s){const g=ld({activeTab:l,mainOpen:h}),x=w=>w.id==="automations"?g:h&&w.id===l,v=a.find(w=>x(w))?.id??null,{visible:b,overflow:y}=_x(a,v,Sx);u=y,d=w=>{const k=a.find(T=>T.id===w),j=v===w&&h;if(Ee("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:w,tab_kind:k?.kind??null,was_active:j}),w==="automations"){const T=cd({activeTab:l,mainOpen:h});r({to:".",search:P=>({...P,main:T}),replace:!0});return}c(w)},f="flex items-center min-w-0 gap-0.5",m=b.map(w=>n.jsx(gx,{title:w.title,icon:w.icon,active:x(w),onClick:()=>d(w.id)},w.id)),e[3]=l,e[4]=h,e[5]=r,e[6]=c,e[7]=a,e[8]=s,e[9]=d,e[10]=u,e[11]=f,e[12]=m}else d=e[9],u=e[10],f=e[11],m=e[12];let p;e[13]!==d||e[14]!==u?(p=u.length>0&&n.jsx(xx,{overflow:u,onSelect:d}),e[13]=d,e[14]=u,e[15]=p):p=e[15];let _;return e[16]!==f||e[17]!==m||e[18]!==p?(_=n.jsxs("div",{className:f,children:[m,p]}),e[16]=f,e[17]=m,e[18]=p,e[19]=_):_=e[19],_}function Ps(t,e,s,i){return`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/git/${i}`}async function Ds(t){const e=await t.json();if(!t.ok)throw new Error(typeof e.error=="string"?e.error:`Request failed (${t.status})`);return e}function As(t,e){return fetch(t,{cache:"no-store",...e})}async function Vi(t,e,s){const i=await As(Ps(t,e,s,"status"));return Ds(i)}async function yx(t,e,s){const i=await As(Ps(t,e,s,"diff"),{method:"POST"});return Ds(i)}async function tl(t,e,s,i){const r=await As(Ps(t,e,s,"suggest-commit"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i??{})});return Ds(r)}async function sl(t,e,s,i){const r=await As(Ps(t,e,s,"publish"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({message:i})});await Ds(r)}async function wx(t,e,s,i){const r=await As(Ps(t,e,s,"rebase"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({base:i})});await Ds(r)}function il(t){if(!t)return!1;const e=Object.keys(t.diffs);return e.length===0?!1:e.every(s=>s===".deco"||s.startsWith(".deco/"))}const Cx="Code changes can't be published directly — use Submit for review";async function rl(t,e,s,i){const r=await As(Ps(t,e,s,"discard"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({filepaths:i})});await Ds(r)}const kx="current";function ko(t){return t?.[kx]??null}function jx(t,e,s){return["sandbox-git-status",t,e,s]}function ah(t){return t?t.modified.length+t.created.length+t.deleted.length+t.not_added.length+t.renamed.length:0}function lh(t){return t?ah(t)>0||t.staged.length>0||t.conflicted.length>0:!1}function Nx(t,e){return t?lh(t)||t.ahead>0||e!=null&&Object.keys(e.diffs).length>0:!1}function Ex(t,e){if(!e)return t;const s=lh(e),i=ko(e);return t.kind==="ready"?{...t,branch:i??t.branch,workingTreeDirty:s,unpushed:Math.max(t.unpushed,e.ahead)}:!i&&!s?t:{kind:"ready",branch:i??"",base:"main",workingTreeDirty:s,unpushed:e.ahead,aheadOfBase:0,behindBase:e.behind,headSha:""}}function Tx(t){const e=F.c(12),{orgSlug:s,virtualMcpId:i,branch:r,enabled:o}=t,a=o===void 0?!0:o,l=r??"";let h;e[0]!==s||e[1]!==l||e[2]!==i?(h=jx(s,i,l),e[0]=s,e[1]=l,e[2]=i,e[3]=h):h=e[3];let c;e[4]!==r||e[5]!==s||e[6]!==i?(c=()=>Vi(s,i,r),e[4]=r,e[5]=s,e[6]=i,e[7]=c):c=e[7];const d=a&&!!r;let u;return e[8]!==h||e[9]!==c||e[10]!==d?(u={queryKey:h,queryFn:c,enabled:d,refetchInterval:3e3,staleTime:1e3},e[8]=h,e[9]=c,e[10]=d,e[11]=u):u=e[11],nr(u)}function Rx(t){const e=F.c(21),{disabled:s,loading:i,onPublish:r,onReview:o}=t,a=i===void 0?!1:i;let l;e[0]!==r?(l=()=>{r()},e[0]=r,e[1]=l):l=e[1];let h;e[2]!==a?(h=a?n.jsx(Ll,{size:"xs",variant:"default"}):null,e[2]=a,e[3]=h):h=e[3];let c;e[4]!==s||e[5]!==l||e[6]!==h?(c=n.jsxs(Q,{size:"sm",variant:"success",className:"rounded-r-none border-r border-success-foreground/20",disabled:s,onClick:l,children:[h,"Publish"]}),e[4]=s,e[5]=l,e[6]=h,e[7]=c):c=e[7];let d;e[8]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(co,{className:"h-3.5 w-3.5"}),e[8]=d):d=e[8];let u;e[9]!==s?(u=n.jsx(pi,{asChild:!0,children:n.jsx(Q,{size:"sm",variant:"success",className:"rounded-l-none px-2",disabled:s,"aria-label":"More actions",children:d})}),e[9]=s,e[10]=u):u=e[10];let f;e[11]!==o?(f=o?n.jsx(Dt,{onClick:o,children:"Review"}):null,e[11]=o,e[12]=f):f=e[12];let m;e[13]!==f?(m=n.jsx(_i,{align:"end",children:f}),e[13]=f,e[14]=m):m=e[14];let p;e[15]!==u||e[16]!==m?(p=n.jsxs(mi,{children:[u,m]}),e[15]=u,e[16]=m,e[17]=p):p=e[17];let _;return e[18]!==c||e[19]!==p?(_=n.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[c,p]}),e[18]=c,e[19]=p,e[20]=_):_=e[20],_}function ch(t){return t.trim()?(t.startsWith("/")?t:`/${t}`).replace(/\/+/g,"/"):"/"}function Px(t){if(!t)return"plaintext";const e=t.toLowerCase();return e.endsWith(".tsx")||e.endsWith(".ts")?"typescript":e.endsWith(".jsx")||e.endsWith(".js")||e.endsWith(".mjs")||e.endsWith(".cjs")?"javascript":e.endsWith(".json")?"json":e.endsWith(".md")||e.endsWith(".mdx")?"markdown":e.endsWith(".css")?"css":e.endsWith(".scss")?"scss":e.endsWith(".html")?"html":e.endsWith(".yaml")||e.endsWith(".yml")?"yaml":e.endsWith(".xml")||e.endsWith(".svg")?"xml":e.endsWith(".py")?"python":e.endsWith(".sql")?"sql":e.endsWith(".sh")?"shell":"plaintext"}function L0(t){const e=ch(t).split("/").filter(Boolean),s=["/"];let i="";for(const r of e.slice(0,-1))i+=`/${r}`,s.push(i);return s}function O0(t){const e={children:[]};for(const i of t){const o=ch(i).split("/").filter(Boolean);let a=e,l="";o.forEach((h,c)=>{l+=`/${h}`;const d=c===o.length-1;let u=a.children.find(f=>f.name===h);u||(u={name:h,path:l,kind:d?"file":"directory",children:[]},a.children.push(u)),a=u})}const s=i=>{i.sort((r,o)=>r.kind!==o.kind?r.kind==="directory"?-1:1:r.name.localeCompare(o.name));for(const r of i)r.children.length>0&&s(r.children)};return s(e.children),e.children}function Dx(t,e,s=0){const i=[];for(const r of t)i.push({node:r,depth:s}),r.kind==="directory"&&r.children.length>0&&e.has(r.path)&&i.push(...Dx(r.children,e,s+1));return i}function $0(t){return t.split(`
|
|
308
308
|
`).map(e=>{const s=e.match(/^\d+\t(.*)/);return s?s[1]:e}).join(`
|
|
309
309
|
`)}Zd.config({paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.52.0/min/vs"}});function Ax(){return document.documentElement.classList.contains("dark")?"vs-dark":"vs"}class Ws extends Error{constructor(e,s,i){super(e),this.step=s,this.pr=i,this.name="PublishFlowError"}step;pr}function Ix(t){const e=F.c(10),[s,i]=D.useState(0);let r;e[0]!==t?(r=h=>{h&&i(Mx),t.onOpenChange(h)},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(Bx,{...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(fs,{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 Mx(t){return t+1}function Bx({onOpenChange:t,orgSlug:e,orgId:s,virtualMcpId:i,branch:r,baseBranch:o,githubConnectionId:a,owner:l,repo:h,previewUrl:c,onPullRequestChanged:d,onPublished:u}){const f=Je({connectionId:a,orgId:s,orgSlug:e}),[m,p]=D.useState(null),[_,g]=D.useState(null),[x,S]=D.useState(!0),[v,b]=D.useState(null),[y,w]=D.useState(!1),[k,j]=D.useState(""),[T,P]=D.useState(""),[R,C]=D.useState(),[N,B]=D.useState(!1),[I,E]=D.useState(),[M,A]=D.useState(null),[L,H]=D.useState(!1),[$,z]=D.useState(!1),[V,q]=D.useState(!1),ee=D.useRef(!1);ee.current||(ee.current=!0,(async()=>{S(!0),C(void 0),b(null),g(null),j(""),P(""),E(void 0);try{const[re,ce]=await Promise.all([Vi(e,i,r),yx(e,i,r)]);p(re),g(ce),j(`Changes from ${re.current??r}`),q(!0),tl(e,i,r,{status:re,diff:ce}).then(ge=>{j(ge.title),P(ge.body)}).catch(()=>{}).finally(()=>q(!1))}catch(re){C(re instanceof Error?re.message:"Failed to load changes.")}finally{S(!1)}})());const G=ko(m)??r,Y=()=>{!m||!_||(q(!0),tl(e,i,r,{status:m,diff:_}).then(re=>{j(re.title),P(re.body)}).catch(()=>{}).finally(()=>q(!1)))},O=ah(m),X=_?Object.keys(_.diffs).length:O,J=Ax(),ie=!x&&Nx(m,_),oe=ie&&il(_),W=ie&&!il(_)?Cx:null,ne=()=>[k.trim(),T.trim()].filter(Boolean).join(`
|
|
310
310
|
|