decocms 2.387.0 → 2.387.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{AlertCircle-D0hoS9-I.js → AlertCircle-B0GNnY3o.js} +1 -1
- package/dist/client/assets/{ArrowUpRight-DXCZlhx-.js → ArrowUpRight-D5UcplCf.js} +1 -1
- package/dist/client/assets/{Check-DBLbs9P4.js → Check-Bf1pls96.js} +1 -1
- package/dist/client/assets/{CheckCircle-DsVzj2dH.js → CheckCircle-7Lf65UH6.js} +1 -1
- package/dist/client/assets/{ChevronDown-pude64DG.js → ChevronDown-TMeEZ-9A.js} +1 -1
- package/dist/client/assets/{ChevronRight-BLZ_KoLZ.js → ChevronRight-CDKzvljX.js} +1 -1
- package/dist/client/assets/{ChevronUp-BgBAJ_gb.js → ChevronUp-eCy1cXbK.js} +1 -1
- package/dist/client/assets/{Container-BNixqvku.js → Container-sqP569CF.js} +1 -1
- package/dist/client/assets/{DotsVertical-679vqAJX.js → DotsVertical-BOt1wiB7.js} +1 -1
- package/dist/client/assets/{FilterLines-nAp8vXOL.js → FilterLines-DkZMnaSL.js} +1 -1
- package/dist/client/assets/{HardDrive-CY6MysUb.js → HardDrive-BHufpGbg.js} +1 -1
- package/dist/client/assets/{Key01-BNOFKCIw.js → Key01-D9cQj8yC.js} +1 -1
- package/dist/client/assets/{LinkExternal01-CQWYL5Ks.js → LinkExternal01-BJD57eXD.js} +1 -1
- package/dist/client/assets/{Lock01-Cr91WndT.js → Lock01-oEtMCFJe.js} +1 -1
- package/dist/client/assets/{Monitor01-GjBGd10Z.js → Monitor01-BGlX8Upy.js} +1 -1
- package/dist/client/assets/{Palette-DOqJurwN.js → Palette-Df_duF6v.js} +1 -1
- package/dist/client/assets/{Play-DlJqoqCl.js → Play-C8j34bHG.js} +1 -1
- package/dist/client/assets/{Plus-T0dRK0PE.js → Plus-DgDZd3Py.js} +1 -1
- package/dist/client/assets/{RefreshCcw01-CKGYkmj9.js → RefreshCcw01-CUc6nkD4.js} +1 -1
- package/dist/client/assets/{SearchMd-C1uEJUxN.js → SearchMd-CVK9lObw.js} +1 -1
- package/dist/client/assets/{Settings02-CKNwJjRD.js → Settings02-D_dC626L.js} +1 -1
- package/dist/client/assets/{Shield01-bwFTx6-X.js → Shield01-Dcl5mREy.js} +1 -1
- package/dist/client/assets/{Star01-Bk9KVZKV.js → Star01-CBrrPcC6.js} +1 -1
- package/dist/client/assets/{Stars02-BX10agt2.js → Stars02-Ckx-WBTD.js} +1 -1
- package/dist/client/assets/{Sun-OIjzqqcm.js → Sun-Qwf06k9f.js} +1 -1
- package/dist/client/assets/{SwitchHorizontal01-D9lcMVQ-.js → SwitchHorizontal01-Dz4Ji_qc.js} +1 -1
- package/dist/client/assets/{Tool01-ZTtA5gQG.js → Tool01-Cnj7wd8K.js} +1 -1
- package/dist/client/assets/{Trash01-C12jahtg.js → Trash01-xomQSD5r.js} +1 -1
- package/dist/client/assets/{Upload01-B_A8Rnki.js → Upload01-DpAmukj3.js} +1 -1
- package/dist/client/assets/{User01-8XwszVG3.js → User01-DaJXp3OF.js} +1 -1
- package/dist/client/assets/{Users01-JDfv8zJp.js → Users01-BsgBLWUa.js} +1 -1
- package/dist/client/assets/{Users03-CCZhWVk0.js → Users03-BJAg49-c.js} +1 -1
- package/dist/client/assets/{X-CxVT8cR5.js → X-CWgRIo1Y.js} +1 -1
- package/dist/client/assets/{XCircle-DFo2M5Ke.js → XCircle-Idqm0Rxs.js} +1 -1
- package/dist/client/assets/{XClose-89OwjHqi.js → XClose-CE3dSxau.js} +1 -1
- package/dist/client/assets/{Zap-DVdO6gQU.js → Zap-D6AgIZNP.js} +1 -1
- package/dist/client/assets/{ZapSquare-Bm5rMnJ8.js → ZapSquare-KfmyA8BQ.js} +1 -1
- package/dist/client/assets/{access-gate-BtwoYEXH.js → access-gate-CEZGXcgw.js} +1 -1
- package/dist/client/assets/{accordion-og-bIaL7.js → accordion-CdAJ_dXT.js} +1 -1
- package/dist/client/assets/{add-section-modal-BVJKB-Mq.js → add-section-modal-BQo99wbw.js} +1 -1
- package/dist/client/assets/{agent-icon-CuVU1Cem.js → agent-icon-CEeT91YN.js} +1 -1
- package/dist/client/assets/{agent-icons-Be2DkZqg.js → agent-icons-CJFOulg8.js} +1 -1
- package/dist/client/assets/{agents-list-D53IfmJH.js → agents-list-DcWf5IXT.js} +1 -1
- package/dist/client/assets/{ai-providers-B_n31Qxk.js → ai-providers-BotvxloY.js} +1 -1
- package/dist/client/assets/{alert-dialog-DJX17wxu.js → alert-dialog-Ci7AlU26.js} +1 -1
- package/dist/client/assets/{alert-NPFpdAYi.js → alert-sGWon-PX.js} +1 -1
- package/dist/client/assets/{auth-catchall-CXTxGmxx.js → auth-catchall-Yy07lMgH.js} +1 -1
- package/dist/client/assets/{auth-split-layout-8ml8GG4y.js → auth-split-layout-BkU6IQ35.js} +1 -1
- package/dist/client/assets/{automation-list-row-DXgzvO17.js → automation-list-row-BDIOPKGN.js} +1 -1
- package/dist/client/assets/{automations-DdWGW12U.js → automations-BZ2c6hwn.js} +1 -1
- package/dist/client/assets/{avatar-CRtatidp.js → avatar-Dh9pKpVF.js} +1 -1
- package/dist/client/assets/{badge-DCpEuaT0.js → badge-BNy0JA2j.js} +1 -1
- package/dist/client/assets/{brand-context-CBUX2Rt2.js → brand-context-CyOVVc9q.js} +1 -1
- package/dist/client/assets/{calendar-CxbWILU3.js → calendar-BeVfpnMh.js} +1 -1
- package/dist/client/assets/{capability-load-error-B0i0xfQx.js → capability-load-error-DtqnPTX9.js} +1 -1
- package/dist/client/assets/{card-DwZ2bTzY.js → card-Bk5j-Pdp.js} +1 -1
- package/dist/client/assets/{chat-context-D31HFvEB.js → chat-context-BsAWyDZi.js} +1 -1
- package/dist/client/assets/{checkbox-D1CZRKMt.js → checkbox-C2B4CGdO.js} +1 -1
- package/dist/client/assets/{cli-auth-success-Mt-LFA3d.js → cli-auth-success-DSG_KnXa.js} +1 -1
- package/dist/client/assets/{collection-detail-CAlnUCg7.js → collection-detail-DXwMzH5w.js} +1 -1
- package/dist/client/assets/{collection-display-button-DXFCzONx.js → collection-display-button-ihbVLfmH.js} +1 -1
- package/dist/client/assets/{collection-search-BHHGkrQF.js → collection-search-Cdm_smEs.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-DxWxlwkw.js → collection-table-wrapper-B4VEVIu_.js} +1 -1
- package/dist/client/assets/{collection-tabs-DBYKhe6d.js → collection-tabs-BWmdHW4j.js} +1 -1
- package/dist/client/assets/{collections-wBL93V2z.js → collections-DEWnJnrS.js} +1 -1
- package/dist/client/assets/{command-DxZXIqVk.js → command-DEHGaU4o.js} +1 -1
- package/dist/client/assets/{connect-desktop-dialog-B0up1Fxi.js → connect-desktop-dialog-CZZJQ3Sq.js} +1 -1
- package/dist/client/assets/{connection-card-C_HAjrG3.js → connection-card-BV8NZ6Yy.js} +1 -1
- package/dist/client/assets/{connection-detail-Br3-hYXT.js → connection-detail-DWFkCKFz.js} +1 -1
- package/dist/client/assets/{connection-form-helpers-pwwzCYX-.js → connection-form-helpers-B7AMdZMB.js} +1 -1
- package/dist/client/assets/{connections-BCQhYoOS.js → connections-CmSqrK71.js} +1 -1
- package/dist/client/assets/{constants-DHDZCumH.js → constants-BL-7A3pB.js} +1 -1
- package/dist/client/assets/{decopilot-sse-pool-DMBzkCwm.js → decopilot-sse-pool-Dw7wtcn-.js} +1 -1
- package/dist/client/assets/{dialog-CZ4PBYXP.js → dialog-Dc6y7vPT.js} +1 -1
- package/dist/client/assets/{domain-settings-BBznmayq.js → domain-settings-rY3wCrEn.js} +1 -1
- package/dist/client/assets/{drawer-C-1SEj3p.js → drawer-DfiiN5b1.js} +1 -1
- package/dist/client/assets/{dropdown-menu-DUcMfwQV.js → dropdown-menu-nWCyMGON.js} +1 -1
- package/dist/client/assets/{dynamic-plugin-layout-ji4QntdL.js → dynamic-plugin-layout-CBHwF2HL.js} +1 -1
- package/dist/client/assets/{empty-state-w0EopEQu.js → empty-state-Dn13vCQw.js} +1 -1
- package/dist/client/assets/{empty-state-v7o_jNLf.js → empty-state-hzVvczoq.js} +1 -1
- package/dist/client/assets/{extract-connection-data-BYFYoCnb.js → extract-connection-data-Bj7gl05J.js} +1 -1
- package/dist/client/assets/{features-CVGVBc6s.js → features-Betwn4Fi.js} +1 -1
- package/dist/client/assets/{file-explorer-Bmg1LFT9.js → file-explorer-DNXKqBDW.js} +1 -1
- package/dist/client/assets/{files-CEfsoxmA.js → files-DA79h_cV.js} +1 -1
- package/dist/client/assets/{form-aV0ziHJK.js → form-6cV6csj4.js} +1 -1
- package/dist/client/assets/{general-Cf2p_yL2.js → general-Bm-CpuKd.js} +1 -1
- package/dist/client/assets/{generate-id-wprWX5PQ.js → generate-id-DwZG6sYA.js} +1 -1
- package/dist/client/assets/{github-repo-picker-CFM9lket.js → github-repo-picker-XOtx61HB.js} +1 -1
- package/dist/client/assets/{hover-card-CrAaL0Ys.js → hover-card-BYiiR87E.js} +1 -1
- package/dist/client/assets/{index-D0uC5sO3.js → index-BWg5yF5M.js} +1 -1
- package/dist/client/assets/{index-C_MtfgxF.js → index-BrQb_5yq.js} +5 -5
- package/dist/client/assets/{index-BN_Il7tc.js → index-CLlxBc3w.js} +1 -1
- package/dist/client/assets/{index-CctUOgF_.js → index-CiJnVXvE.js} +1 -1
- package/dist/client/assets/{index-DxI9_aG4.js → index-CrCpWnVz.js} +1 -1
- package/dist/client/assets/{index-Bn1gtnbd.js → index-DAr2Nda-.js} +1 -1
- package/dist/client/assets/{index-zpOuIhuq.js → index-DDsV_St1.js} +1 -1
- package/dist/client/assets/{index-Cb3l49GO.js → index-DF8Vp58x.js} +1 -1
- package/dist/client/assets/{index-85BaCtFm.js → index-DH1PxCKH.js} +1 -1
- package/dist/client/assets/{index-DFjp0Po0.js → index-D_i-L1eq.js} +1 -1
- package/dist/client/assets/{index-C4Na7PCP.js → index-DeDLXvAd.js} +1 -1
- package/dist/client/assets/{index-N08PF5LM.js → index-Dj4-zrs6.js} +3 -3
- package/dist/client/assets/{index-D2wR43e2.js → index-DmFWtY2s.js} +1 -1
- package/dist/client/assets/{index-CT3CRQRT.js → index-EEG8k-A3.js} +1 -1
- package/dist/client/assets/{index-redirect-CSuuBNKv.js → index-redirect-Do9mg641.js} +1 -1
- package/dist/client/assets/{index-Cs-QIFi_.js → index-u_AL5q1O.js} +1 -1
- package/dist/client/assets/{infiniteQueryObserver-nG4bfzBh.js → infiniteQueryObserver-C2uwxowv.js} +1 -1
- package/dist/client/assets/{input-CCoEN4wj.js → input-C9C2SWkc.js} +1 -1
- package/dist/client/assets/{integration-icon-wKT404sm.js → integration-icon-Bqmq9Rqh.js} +1 -1
- package/dist/client/assets/{label-CjfWrghs.js → label-Ecklj764.js} +1 -1
- package/dist/client/assets/{layout-JuLUmJ8P.js → layout-BGn4zUhT.js} +1 -1
- package/dist/client/assets/{login-MNtgu2op.js → login-H9j77zXb.js} +1 -1
- package/dist/client/assets/{members-DsGBfWrG.js → members-CXApcink.js} +1 -1
- package/dist/client/assets/{monaco-editor-BJPfNAgo.js → monaco-editor-CR7urYlm.js} +1 -1
- package/dist/client/assets/{monitoring-stats-row-atKPXq8Q.js → monitoring-stats-row-BnpZ7SQm.js} +1 -1
- package/dist/client/assets/{oauth-callback-C3NBWdWl.js → oauth-callback-ONMc_ec4.js} +1 -1
- package/dist/client/assets/{oauth-callback-ai-provider-nJ1FO5is.js → oauth-callback-ai-provider-w2wxJyxX.js} +1 -1
- package/dist/client/assets/{onboarding-DFIKGUDf.js → onboarding-BMTIIDYl.js} +1 -1
- package/dist/client/assets/{org-layout-B0jbLadu.js → org-layout-CarL5XPX.js} +1 -1
- package/dist/client/assets/{org-plugin-layout-DQDFIXul.js → org-plugin-layout-kzLUjeIr.js} +1 -1
- package/dist/client/assets/{pair-D7f4zKiq.js → pair-CbRLlxW0.js} +1 -1
- package/dist/client/assets/{plugin-empty-state-BKZGQ-TV.js → plugin-empty-state-BGLY2ZdE.js} +1 -1
- package/dist/client/assets/{plugin-header-CzcI1bhf.js → plugin-header-Ccei7d5p.js} +1 -1
- package/dist/client/assets/{plugin-layout-BjANH5_s.js → plugin-layout-DjfV42Yi.js} +1 -1
- package/dist/client/assets/{popover-VyE2tlsE.js → popover-DoUZKqVh.js} +1 -1
- package/dist/client/assets/{profile-uzoFOse8.js → profile-Djzl20M3.js} +1 -1
- package/dist/client/assets/{project-app-view-Be7QSV7a.js → project-app-view-CNVhgJlW.js} +1 -1
- package/dist/client/assets/registry-b3QvvID1.js +2 -0
- package/dist/client/assets/{registry-layout-DfcADZIB.js → registry-layout-B4UaFC1H.js} +1 -1
- package/dist/client/assets/{require-capability-DwudXHCp.js → require-capability-BBl3SuXE.js} +1 -1
- package/dist/client/assets/{required-auth-layout-C9CMG_qC.js → required-auth-layout-CGP_SUFu.js} +1 -1
- package/dist/client/assets/{reset-password-DtniD6eq.js → reset-password-CSGVPRA0.js} +1 -1
- package/dist/client/assets/{roles-B_2q7InJ.js → roles-LD3J2Ylr.js} +1 -1
- package/dist/client/assets/{scroll-area-DjUfBvEU.js → scroll-area-BHTmdDeg.js} +1 -1
- package/dist/client/assets/{search-input-8DUSJ-oO.js → search-input-C7NqjWfP.js} +1 -1
- package/dist/client/assets/{secrets-DdfJl4DY.js → secrets-e9fW2uGe.js} +1 -1
- package/dist/client/assets/{sections-editor-Dfs3LCeJ.js → sections-editor-DH5JOAp0.js} +1 -1
- package/dist/client/assets/{select-BXYVGbBH.js → select-n1Ny26B8.js} +1 -1
- package/dist/client/assets/{settings-layout-CZVA_--S.js → settings-layout-CJpLmvq8.js} +1 -1
- package/dist/client/assets/{settings-section-oaZCYL0P.js → settings-section-DexNFpN6.js} +1 -1
- package/dist/client/assets/{sheet-BKvcHAtW.js → sheet-C1wM9bZQ.js} +1 -1
- package/dist/client/assets/{shell-controls-DOz9y3uG.js → shell-controls-CiK6l2OB.js} +1 -1
- package/dist/client/assets/{shell-layout-BiZiN5aX.js → shell-layout-euayb4e7.js} +1 -1
- package/dist/client/assets/{sidebar-DvLuJykg.js → sidebar-DxN18qmt.js} +1 -1
- package/dist/client/assets/{skeleton-eRh0AoiO.js → skeleton-CawVhyai.js} +1 -1
- package/dist/client/assets/{sortable.esm-jRATlKvC.js → sortable.esm-CaJ5jMdk.js} +1 -1
- package/dist/client/assets/{spinner-BeqxYFJl.js → spinner-CTR7wptZ.js} +1 -1
- package/dist/client/assets/{sso-DWlLfKtA.js → sso-CCB3K3XR.js} +1 -1
- package/dist/client/assets/{store-BKjctpGZ.js → store-Cx9w3XPj.js} +1 -1
- package/dist/client/assets/store-registry-DQmxWSc1.js +2 -0
- package/dist/client/assets/{switch-w_56-9b5.js → switch-CrTnPTc9.js} +1 -1
- package/dist/client/assets/{tab-id-gly61Jsq.js → tab-id-D_jRge83.js} +6 -6
- package/dist/client/assets/{table-L7vpFYbG.js → table-lrbrdRUx.js} +1 -1
- package/dist/client/assets/{tabs-C_J6FIfi.js → tabs-Duy6-jlC.js} +1 -1
- package/dist/client/assets/{task-status-C766ycKK.js → task-status-DS_Y8i0S.js} +1 -1
- package/dist/client/assets/{textarea-B3WScg2s.js → textarea-DcuuwQHt.js} +1 -1
- package/dist/client/assets/{toggle-group-DZ6eIYG-.js → toggle-group-DSOscY_T.js} +1 -1
- package/dist/client/assets/{toolbar-DUpM1g_1.js → toolbar-Cfl-fyNN.js} +1 -1
- package/dist/client/assets/{tools-list-DlnCkYkX.js → tools-list-BhF3OpOK.js} +1 -1
- package/dist/client/assets/{tooltip-DQaERQs_.js → tooltip-JDpiFtIa.js} +1 -1
- package/dist/client/assets/{types-CjeLaq7a.js → types-Dj9CgGbv.js} +1 -1
- package/dist/client/assets/{use-ai-providers-B1aSayxn.js → use-ai-providers-BvVxStkO.js} +1 -1
- package/dist/client/assets/{use-capability-xT7jaLpL.js → use-capability-B-Jx2jiB.js} +1 -1
- package/dist/client/assets/{use-collections-CtC5QLeR.js → use-collections-D9hFdS86.js} +1 -1
- package/dist/client/assets/{use-connection-BuJIj1Xa.js → use-connection-DBjq9KVP.js} +1 -1
- package/dist/client/assets/{use-copy-D0MT51Gg.js → use-copy-BEMjhay_.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-h5NpImoe.js → use-create-virtual-mcp-Cz4pK0yB.js} +1 -1
- package/dist/client/assets/{use-debounced-autosave-BE9nNPnI.js → use-debounced-autosave-BhHzBpyf.js} +1 -1
- package/dist/client/assets/{use-delete-connection-D_85MGKw.js → use-delete-connection-CW7k-ZpO.js} +1 -1
- package/dist/client/assets/{use-file-configs-CgxY53ke.js → use-file-configs-CGj4WzBd.js} +1 -1
- package/dist/client/assets/{use-infinite-scroll-C0eCXvM3.js → use-infinite-scroll-BEfkuMXD.js} +1 -1
- package/dist/client/assets/{use-list-state-BWLB3Cm6.js → use-list-state-D3LXLRji.js} +1 -1
- package/dist/client/assets/{use-mcp-prompts-BRu6v1IW.js → use-mcp-prompts-mcndCy09.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-DopNqrs7.js → use-mcp-tools-B4A6jd0i.js} +1 -1
- package/dist/client/assets/{use-members-Cf5ms1PG.js → use-members-BhUjoKSg.js} +1 -1
- package/dist/client/assets/{use-navigate-to-agent-Dmnwp45q.js → use-navigate-to-agent-CavOGg9q.js} +1 -1
- package/dist/client/assets/{use-org-auth-client-D9m-yfus.js → use-org-auth-client-uJl3t32_.js} +1 -1
- package/dist/client/assets/{use-org-sso-B8RG_7xr.js → use-org-sso-BtKZj6eM.js} +1 -1
- package/dist/client/assets/{use-organization-roles-BTqbovKD.js → use-organization-roles-E2kK6hnd.js} +1 -1
- package/dist/client/assets/{use-organization-settings-C6V0le2S.js → use-organization-settings-1LMC0Mz_.js} +1 -1
- package/dist/client/assets/{use-registry-connections-aiYNsEE0.js → use-registry-connections-ByZ9hVMl.js} +1 -1
- package/dist/client/assets/{use-secrets-BcQjOQQ5.js → use-secrets-HugubdRW.js} +1 -1
- package/dist/client/assets/{use-status-sounds-B9JCI27b.js → use-status-sounds-DlgUXBkr.js} +1 -1
- package/dist/client/assets/{use-view-mode-CA3fr1db.js → use-view-mode--nnEMuAq.js} +1 -1
- package/dist/client/assets/{use-virtual-mcp-D8BNWNIh.js → use-virtual-mcp-eu3msVHv.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-Bqtfpdpy.js +1 -0
- package/dist/client/assets/{useRouterState-CduA6UYs.js → useRouterState-CglkVopv.js} +1 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-CICgRt5F.js +1 -0
- package/dist/client/assets/{user-zSiF5QW3.js → user-BugqD7JO.js} +1 -1
- package/dist/client/assets/{view-mode-toggle-xd_Ab88H.js → view-mode-toggle-3BcjxS-G.js} +1 -1
- package/dist/client/assets/{workflow-UASQ5PM8.js → workflow-CGH4884r.js} +1 -1
- package/dist/client/assets/workflow-detail-34FmiyEC.js +1 -0
- package/dist/client/index.html +1 -1
- package/dist/server/cli.js +6 -4
- 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-exporter-base/build/esm/OTLPExporterBase.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/OTLPExporterBase.js +2 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/OTLPExporterBase.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/convert-legacy-browser-http-options.js +2 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/convert-legacy-browser-http-options.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/convert-legacy-http-options.d.ts +4 -0
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/convert-legacy-http-options.js +23 -0
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/convert-legacy-http-options.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/convert-legacy-node-http-options.js +2 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/convert-legacy-node-http-options.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/create-legacy-browser-delegate.js +2 -7
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/create-legacy-browser-delegate.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/legacy-base-configuration.d.ts +26 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/legacy-base-configuration.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-http-configuration.d.ts +2 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-http-configuration.js +9 -9
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-http-configuration.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/shared-configuration.d.ts +2 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/shared-configuration.js +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/shared-configuration.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/export-response.d.ts +1 -0
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/export-response.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/index-browser-http.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/index-browser-http.js +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/index-browser-http.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/is-export-retryable.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/is-export-retryable.js +5 -3
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/is-export-retryable.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/otlp-browser-http-export-delegate.d.ts +0 -4
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/otlp-browser-http-export-delegate.js +1 -10
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/otlp-browser-http-export-delegate.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/otlp-export-delegate.js +9 -8
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/otlp-export-delegate.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/retrying-transport.js +17 -5
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/retrying-transport.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/fetch-transport.d.ts +2 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/fetch-transport.js +13 -8
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/fetch-transport.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-exporter-transport.js +5 -4
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-exporter-transport.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-transport-types.d.ts +2 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-transport-types.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-transport-utils.d.ts +1 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-transport-utils.js +37 -14
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-transport-utils.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/send-beacon-transport.d.ts +4 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/send-beacon-transport.js +5 -4
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/send-beacon-transport.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/util.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/util.js +10 -12
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/util.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/version.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/version.js +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/version.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/OTLPExporterBase.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/OTLPExporterBase.js +2 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/OTLPExporterBase.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/convert-legacy-browser-http-options.js +2 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/convert-legacy-browser-http-options.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/convert-legacy-http-options.d.ts +4 -0
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/convert-legacy-http-options.js +23 -0
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/convert-legacy-http-options.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/convert-legacy-node-http-options.js +2 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/convert-legacy-node-http-options.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/create-legacy-browser-delegate.js +2 -7
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/create-legacy-browser-delegate.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/legacy-base-configuration.d.ts +26 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/legacy-base-configuration.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/otlp-http-configuration.d.ts +2 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/otlp-http-configuration.js +9 -9
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/otlp-http-configuration.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/shared-configuration.d.ts +2 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/shared-configuration.js +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/shared-configuration.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/export-response.d.ts +1 -0
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/export-response.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/index-browser-http.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/index-browser-http.js +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/index-browser-http.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/is-export-retryable.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/is-export-retryable.js +5 -3
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/is-export-retryable.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/otlp-browser-http-export-delegate.d.ts +0 -4
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/otlp-browser-http-export-delegate.js +1 -10
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/otlp-browser-http-export-delegate.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/otlp-export-delegate.js +9 -8
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/otlp-export-delegate.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/retrying-transport.js +17 -5
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/retrying-transport.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/fetch-transport.d.ts +2 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/fetch-transport.js +13 -8
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/fetch-transport.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/http-exporter-transport.js +5 -4
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/http-exporter-transport.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/http-transport-types.d.ts +2 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/http-transport-types.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/http-transport-utils.d.ts +1 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/http-transport-utils.js +37 -14
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/http-transport-utils.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/send-beacon-transport.d.ts +4 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/send-beacon-transport.js +5 -4
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/send-beacon-transport.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/util.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/util.js +10 -12
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/util.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/version.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/version.js +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/version.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/OTLPExporterBase.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/OTLPExporterBase.js +2 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/OTLPExporterBase.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/convert-legacy-browser-http-options.js +2 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/convert-legacy-browser-http-options.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/convert-legacy-http-options.d.ts +4 -0
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/convert-legacy-http-options.js +27 -0
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/convert-legacy-http-options.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/convert-legacy-node-http-options.js +2 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/convert-legacy-node-http-options.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/create-legacy-browser-delegate.js +1 -6
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/create-legacy-browser-delegate.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/legacy-base-configuration.d.ts +26 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/legacy-base-configuration.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/otlp-http-configuration.d.ts +2 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/otlp-http-configuration.js +9 -9
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/otlp-http-configuration.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/shared-configuration.d.ts +2 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/shared-configuration.js +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/shared-configuration.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/export-response.d.ts +1 -0
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/export-response.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/index-browser-http.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/index-browser-http.js +1 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/index-browser-http.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/is-export-retryable.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/is-export-retryable.js +7 -5
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/is-export-retryable.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/otlp-browser-http-export-delegate.d.ts +0 -4
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/otlp-browser-http-export-delegate.js +2 -12
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/otlp-browser-http-export-delegate.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/otlp-export-delegate.js +9 -8
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/otlp-export-delegate.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/retrying-transport.js +17 -5
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/retrying-transport.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/fetch-transport.d.ts +2 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/fetch-transport.js +12 -7
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/fetch-transport.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/http-exporter-transport.js +5 -4
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/http-exporter-transport.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/http-transport-types.d.ts +2 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/http-transport-types.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/http-transport-utils.d.ts +1 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/http-transport-utils.js +36 -13
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/http-transport-utils.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/send-beacon-transport.d.ts +4 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/send-beacon-transport.js +5 -4
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/send-beacon-transport.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/util.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/util.js +10 -12
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/util.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/version.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/version.js +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/version.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/package.json +6 -6
- package/dist/server/node_modules/@opentelemetry/otlp-transformer/build/esm/generated/root.js +36 -6
- 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 +15 -0
- 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 +36 -6
- 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 +15 -0
- 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 +36 -6
- 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 +15 -0
- 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 +12 -14
- package/dist/server/node_modules/{xtend → pg}/LICENSE +7 -6
- package/dist/server/node_modules/pg/README.md +89 -0
- package/dist/server/node_modules/pg/lib/client.js +631 -0
- package/dist/server/node_modules/pg/lib/connection-parameters.js +167 -0
- package/dist/server/node_modules/pg/lib/connection.js +223 -0
- package/dist/server/node_modules/pg/lib/crypto/sasl.js +186 -0
- package/dist/server/node_modules/pg/lib/crypto/utils-legacy.js +37 -0
- package/dist/server/node_modules/pg/lib/crypto/utils-webcrypto.js +83 -0
- package/dist/server/node_modules/pg/lib/crypto/utils.js +9 -0
- package/dist/server/node_modules/pg/lib/defaults.js +84 -0
- package/dist/server/node_modules/pg/lib/index.js +58 -0
- package/dist/server/node_modules/pg/lib/native/client.js +307 -0
- package/dist/server/node_modules/pg/lib/native/index.js +2 -0
- package/dist/server/node_modules/pg/lib/native/query.js +165 -0
- package/dist/server/node_modules/pg/lib/query.js +241 -0
- package/dist/server/node_modules/pg/lib/result.js +107 -0
- package/dist/server/node_modules/pg/lib/stream.js +28 -0
- package/dist/server/node_modules/pg/lib/type-overrides.js +35 -0
- package/dist/server/node_modules/pg/lib/utils.js +204 -0
- package/dist/server/node_modules/pg/package.json +64 -0
- package/dist/server/server.js +1 -1
- package/package.json +1 -1
- package/dist/client/assets/registry-M4QttfPT.js +0 -2
- package/dist/client/assets/store-registry-BTcHOBIS.js +0 -2
- package/dist/client/assets/useInfiniteQuery-Bvu8-_i3.js +0 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-BVuZ1GLJ.js +0 -1
- package/dist/client/assets/workflow-detail-BJnM35G9.js +0 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/xhr-transport.d.ts +0 -17
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/xhr-transport.js +0 -86
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/xhr-transport.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/xhr-transport.d.ts +0 -17
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/xhr-transport.js +0 -86
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/xhr-transport.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/xhr-transport.d.ts +0 -17
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/xhr-transport.js +0 -90
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/xhr-transport.js.map +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/license +0 -9
- 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/is-fullwidth-code-point/index.d.ts +0 -17
- package/dist/server/node_modules/is-fullwidth-code-point/index.js +0 -12
- package/dist/server/node_modules/is-fullwidth-code-point/license +0 -9
- package/dist/server/node_modules/is-fullwidth-code-point/package.json +0 -53
- package/dist/server/node_modules/is-fullwidth-code-point/readme.md +0 -31
- package/dist/server/node_modules/xtend/.jshintrc +0 -30
- 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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sections-editor-
|
|
2
|
-
import{e as K,r as A,c as ie,j as n,l as ge,E as $t,q as je,f as Vt,d as co,g as Xl,p as Nd,L as Ed,n as ki,K as Ut,s as Td,o as ae,B as te,v as ui,V as Rd,t as Me,b as ji,w as Jl,x as Pd,y as Er,z as fs,C as dt,D as Tr,F as Zl,G as Dd,H as Ad,I as ca,J as Md,a as Rr,M as Zi,P as oi,Q as wt,_ as Ni,R as vi,T as Bd,U as Id}from"./index-N08PF5LM.js";import{C as ze,u as Ld,w as Od,a as ho,b as uo,s as Qi,T as $d,t as zd,r as Fd,c as Hd,d as Wd}from"./index-CT3CRQRT.js";import{I as gs}from"./integration-icon-wKT404sm.js";import{g as fo,u as Xe,S as vs,a as Ql,K as Ud}from"./constants-DHDZCumH.js";import{u as At,a as Kd,b as Vd}from"./use-virtual-mcp-D8BNWNIh.js";import{a as qd}from"./Users03-CCZhWVk0.js";import{u as xs,a as rs,b as Pr,c as Ei,h as Gd,g as Bs,d as ec,t as Yd,e as ha,f as Xd}from"./chat-context-D31HFvEB.js";import{i as Ti}from"./AlertCircle-D0hoS9-I.js";import{i as Jd}from"./CheckCircle-DsVzj2dH.js";import{n as da}from"./ZapSquare-Bm5rMnJ8.js";import{i as Zd,a as mo,b as Qd}from"./XCircle-DFo2M5Ke.js";import{s as As}from"./XClose-89OwjHqi.js";import{c as eu,t as ua,M as po,G as tu}from"./pair-D7f4zKiq.js";import{u as su}from"./use-ai-providers-B1aSayxn.js";import{u as iu}from"./connect-desktop-dialog-B0up1Fxi.js";import{r as ru,u as _o,i as nu}from"./shell-layout-BiZiN5aX.js";import{b as ou,a as au}from"./index-Cb3l49GO.js";import{u as lu}from"./sidebar-DvLuJykg.js";import{i as cu,S as hu,a as du,b as uu}from"./sheet-BKvcHAtW.js";import{u as tc,T as Se,a as we,b as Ce,c as sc}from"./tooltip-DQaERQs_.js";import{i as Ps,a as Dr,b as fu,c as mu,p as Ar,g as Mr,d as go,e as ic,h as gn,f as Jr,j as fa,A as ma,k as pu,l as _u,n as gu,m as vu,o as xu,t as bu,q as yu,r as Su,s as Br,u as wu,v as rc,w as vn,x as nc,y as oc,z as pa,B as Cu,C as vo,D as _a,E as ku,F as fi,G as ac,H as lc,I as ju}from"./agent-icon-CuVU1Cem.js";import{u as Nu}from"./use-status-sounds-B9JCI27b.js";import{E as hr}from"./empty-state-v7o_jNLf.js";import{u as Eu,r as xn,a as Tu,p as cc,f as ga,b as hc,c as Ru,F as Pu,i as Du,d as Au,e as Mu,g as Bu,h as Iu}from"./tab-id-gly61Jsq.js";import{T as va,a as bn}from"./toolbar-DUpM1g_1.js";import{A as Lu,a as Ou,b as $u,c as zu,R as dc,d as Fu,e as Hu}from"./accordion-og-bIaL7.js";import{u as Ir,a as xo,b as Wu}from"./use-connection-BuJIj1Xa.js";import{u as Lr,a as Uu}from"./use-mcp-tools-DopNqrs7.js";import{g as Ku}from"./generate-id-wprWX5PQ.js";import{u as Vu,g as qu}from"./types-CjeLaq7a.js";import{U as uc}from"./user-zSiF5QW3.js";import{T as Gu,u as fc}from"./tools-list-DlnCkYkX.js";import{u as Yu}from"./unwrap-tool-result-BYXdCQMg.js";import{s as mc,g as Xu}from"./connection-slug-eyAPH6o3.js";import{A as dr,a as ur,b as fr,c as mr,d as pr,e as _r,f as gr,g as vr}from"./alert-dialog-DJX17wxu.js";import{D as Is,a as qt,b as Gt,c as bs,d as ys,e as bo}from"./dialog-CZ4PBYXP.js";import{C as pc,a as yn}from"./card-DwZ2bTzY.js";import{I as Ye}from"./input-CCoEN4wj.js";import{L as bt}from"./label-CjfWrghs.js";import{S as zt,a as Ft,b as Ht,c as Wt,d as ft}from"./select-BXYVGbBH.js";import{S as Sn}from"./switch-w_56-9b5.js";import{T as xr}from"./textarea-B3WScg2s.js";import{i as ms}from"./Play-DlJqoqCl.js";import{s as Kt}from"./Plus-T0dRK0PE.js";import{a as Ju}from"./Settings02-CKNwJjRD.js";import{t as yo,i as _c}from"./Tool01-ZTtA5gQG.js";import{s as xi}from"./Trash01-C12jahtg.js";import{u as br}from"./use-debounced-autosave-BE9nNPnI.js";import{P as Ls,a as Os,b as $s}from"./popover-VyE2tlsE.js";import{S as So}from"./scroll-area-DjUfBvEU.js";import{i as gc}from"./SearchMd-C1uEJUxN.js";import{i as Zu}from"./Upload01-B_A8Rnki.js";import{P as Ct}from"./index-zpOuIhuq.js";import{A as Qu}from"./sortable.esm-jRATlKvC.js";import{C as ef}from"./collection-tabs-DBYKhe6d.js";import{C as vc}from"./checkbox-D1CZRKMt.js";import{u as tf}from"./use-mcp-prompts-BRu6v1IW.js";import{D as sf,a as rf,b as nf}from"./drawer-C-1SEj3p.js";import{i as Ri}from"./Check-DBLbs9P4.js";import{a as ss,i as of,s as af}from"./RefreshCcw01-CKGYkmj9.js";import{i as xc}from"./Key01-BNOFKCIw.js";import{S as Es}from"./skeleton-eRh0AoiO.js";import{i as lf}from"./Lock01-Cr91WndT.js";import{s as cf}from"./User01-8XwszVG3.js";import{t as hf}from"./Users01-JDfv8zJp.js";import{u as df,a as uf}from"./use-secrets-BcQjOQQ5.js";import{G as ff}from"./github-repo-picker-CFM9lket.js";import{f as mf}from"./formatDistanceToNow-Cb2QZZJn.js";import{n as zs}from"./LinkExternal01-CQWYL5Ks.js";import{T as hs,a as wo,b as mi,c as Co}from"./tabs-C_J6FIfi.js";import{l as pf,w as _f,M as gf}from"./monaco-editor-BJPfNAgo.js";import{D as Fs,a as Hs,b as Ws,c as ut,d as xa,e as vf,f as xf,g as bf}from"./dropdown-menu-DUcMfwQV.js";import{i as yf}from"./ChevronRight-BLZ_KoLZ.js";import{S as bc}from"./spinner-BeqxYFJl.js";import{t as Or}from"./ChevronDown-pude64DG.js";import{C as ba,a as ya,b as Sf,c as wf,d as Cf,e as kf,f as jf}from"./command-DxZXIqVk.js";import{u as Nf}from"./useInfiniteQuery-Bvu8-_i3.js";import{s as yr}from"./Star01-Bk9KVZKV.js";import{i as yc}from"./Stars02-BX10agt2.js";import{V as Ef}from"./view-mode-toggle-xd_Ab88H.js";import{i as Tf}from"./X-CxVT8cR5.js";import{u as Pi,a as Rf,b as Pf,c as Df,A as Af,d as Mf}from"./automation-list-row-DXgzvO17.js";import{i as Bf}from"./SwitchHorizontal01-D9lcMVQ-.js";import{i as bi}from"./Zap-DVdO6gQU.js";import{S as If}from"./search-input-8DUSJ-oO.js";function Js(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function Sa(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 Lf(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function Of(t){const e=K.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map($f),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 $f(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 zf(t){const e=K.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 p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=p):p=e[10];let m;e[11]!==a?(m=a.toFixed(1),e[11]=a,e[12]=m):m=e[12];let _;e[13]!==m?(_=n.jsxs("div",{className:"flex items-center gap-1.5",children:[p,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",m,"%"]})]}),e[13]=m,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 k;return e[27]!==b||e[28]!==f?(k=n.jsxs("div",{className:"flex flex-col gap-2",children:[f,b]}),e[27]=b,e[28]=f,e[29]=k):k=e[29],k}function Ff(t){const e=K.c(11),{agentId:s,isError:i}=t,r=At(s),o=r?.title??"Subtask",a=r?.icon??null;let l;e[0]!==a||e[1]!==o?(l=n.jsx(gs,{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=ie("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 Hf(t){const e=K.c(5),{isError:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(gs,{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=ie("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 Wf(t){const e=K.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(Hf,{isError:o}),e[0]=o,e[1]=l):l=e[1];let h;e[2]!==i||e[3]!==o?(h=n.jsx(Ff,{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(A.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(ge,{size:12,className:"animate-spin text-muted-foreground"}):o?n.jsx(Zd,{size:12,className:"text-destructive"}):a?n.jsx(Ti,{size:12,className:"text-warning"}):n.jsx(Jd,{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 Uf(t){const e=K.c(55),{onClose:s,back:i,className:r}=t,[o,a]=A.useState(null),{messages:l}=xs(),{activeTask:h}=rs(),{selectedModel:c,selectedVirtualMcp:d}=Pr();let u,f,p,m,_,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 k=eu(l),w=[...l].reverse().find(tm),N=w?.metadata?.usage,j=w?.metadata?.modelLimits?.contextWindow??c?.limits?.contextWindow??null,R=N?.contextTokens??0,I=j&&j>0?(R/j*100).toFixed(1):null,E=l;let C;e[16]!==E?(C=E.filter(em).reduce(Qf,0),e[16]=E,e[17]=C):C=e[17];const y=C,T=l;let D;e[18]!==T?(D=T.filter(Zf).reduce(Jf,0),e[18]=T,e[19]=D):D=e[19];const P=D,M=Math.max(0,k.totalTokens-y-P),B=l[0],F=l.at(-1),U=B?.metadata?.created_at??h?.created_at,z=F?.metadata?.created_at??h?.updated_at,O=l.filter(Xf),q=l.flatMap(Gf),V=c?.modelId?Lf(c.modelId):"—",Q=d?.title??"Decopilot",G=[{label:"Session",value:h?.title??"New chat"},{label:"Messages",value:O.length},{label:"Agent",value:Q},{label:"Model",value:V},{label:"Context Limit",value:j?Js(j):"—"},{label:"Session Tokens (billed)",value:k.totalTokens>0?Js(k.totalTokens):"0"},{label:"Usage",value:I!==null?`${I}%`:"—"},{label:"Input Tokens",value:k.inputTokens>0?Js(k.inputTokens):"0"},{label:"Output Tokens",value:k.outputTokens>0?Js(k.outputTokens):"0"},{label:"Reasoning Tokens",value:k.reasoningTokens>0?Js(k.reasoningTokens):"0"},{label:"Cost",value:k.cost>0?`$${k.cost<.001?k.cost.toFixed(6):k.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:Sa(U)},{label:"Last Activity",value:Sa(z)}];if(!h&&O.length===0){let L;e[20]!==r?(L=ie("flex flex-col h-full w-full border-l border-border bg-background",r),e[20]=r,e[21]=L):L=e[21];let Y;e[22]===Symbol.for("react.memo_cache_sentinel")?(Y=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[22]=Y):Y=e[22];let X;e[23]!==i?(X=i?n.jsx(da,{size:14,className:"text-muted-foreground"}):n.jsx(As,{size:14,className:"text-muted-foreground"}),e[23]=i,e[24]=X):X=e[24];let H;e[25]!==s||e[26]!==X?(H=n.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[Y,n.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:X})]}),e[25]=s,e[26]=X,e[27]=H):H=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 re;e[29]!==L||e[30]!==H?(re=n.jsxs("div",{className:L,children:[H,ne]}),e[29]=L,e[30]=H,e[31]=re):re=e[31],S=re;break e}e[32]!==r?(g=ie("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 W;e[34]===Symbol.for("react.memo_cache_sentinel")?(W=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[34]=W):W=e[34];let ee;e[35]!==i?(ee=i?n.jsx(da,{size:14}):n.jsx(As,{size:14}),e[35]=i,e[36]=ee):ee=e[36],e[37]!==s||e[38]!==ee?(x=n.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[W,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:ee})]}),e[37]=s,e[38]=ee,e[39]=x):x=e[39],u="flex flex-col gap-8 p-6",f=q.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:q.map(qf)})]}),p=n.jsx(Of,{items:G});let $;e[40]===Symbol.for("react.memo_cache_sentinel")?($=n.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[40]=$):$=e[40],e[41]!==P||e[42]!==M||e[43]!==y?(m=n.jsxs("div",{className:"flex flex-col gap-3",children:[$,n.jsx(zf,{userTokens:y,assistantTokens:P,otherTokens:M})]}),e[41]=P,e[42]=M,e[43]=y,e[44]=m):m=e[44],_=O.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:O.map(L=>{const Y=L.metadata?.created_at,X=o?.id===L.id;return n.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[n.jsxs("button",{type:"button",onClick:()=>a(X?null:L),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:ie("shrink-0 font-medium",L.role==="user"?"text-chart-1":"text-chart-2"),children:L.role}),n.jsx("span",{className:"text-muted-foreground",children:"•"}),n.jsx("span",{className:"truncate text-muted-foreground font-mono",children:L.id})]}),Y&&n.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(Y).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),X&&n.jsxs(n.Fragment,{children:[L.role==="assistant"&&(()=>{const H=L.metadata?._request;if(!H)return null;const ne=H.systemSections??[],re=Math.max(1,...ne.map(Vf)),ce=ne.reduce(Kf,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:[H.activeTools??0," / ",H.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(ce/4).toLocaleString()," ","tok"]})]}),ne.map((de,me)=>{const le=de.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${me}`,ve=de.chars/re*100,xe=Math.round(de.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:["~",xe.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:`${ve}%`}})})]},me)})]})]})})(),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(L,null,2)})]})]},L.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]=p,e[11]=m,e[12]=_,e[13]=g,e[14]=x,e[15]=S}else u=e[8],f=e[9],p=e[10],m=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]!==p||e[48]!==m||e[49]!==_?(v=n.jsxs("div",{className:u,children:[f,p,m,_]}),e[45]=u,e[46]=f,e[47]=p,e[48]=m,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 Kf(t,e){return t+e.chars}function Vf(t){return t.chars}function qf(t,e){return n.jsx(Wf,{part:t},e)}function Gf(t){return(t.parts??[]).filter(Yf)}function Yf(t){return t.type==="tool-subtask"}function Xf(t){return t.role!=="system"}function Jf(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function Zf(t){return t.role==="assistant"}function Qf(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function em(t){return t.role==="user"}function tm(t){return t.role==="assistant"&&t.metadata?.usage}function sm(){const t=K.c(17),{selectedVirtualMcp:e}=Pr(),{org:s}=je();let i;t[0]!==s.id?(i=fo(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(qd,{size:32}),t[2]=a):a=t[2];let l;t[3]!==o.icon||t[4]!==o.title?(l=n.jsx(gs,{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(ze.IceBreakers,{})}),t[14]=f):f=t[14];let p;return t[15]!==u?(p=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]=p):p=t[16],p}function im(){const t=K.c(29),{org:e}=je(),s=su(),{isChatEmpty:i}=xs(),[r,o]=A.useState("chat"),a=Ld(),{selectedVirtualMcp:l}=Pr();let h;t[0]!==e.id?(h=fo(e.id),t[0]=e.id,t[1]=h):h=t[1];const u=At((l??h).id),f=iu(),p=Ei(u?.metadata);if(s.length===0&&!(p&&Gd(f))){let C;return t[2]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(ze,{className:"animate-in fade-in-0 duration-200",children:n.jsx(ze.Main,{className:"flex flex-col items-center",children:n.jsx(ze.EmptyState,{children:n.jsx(ze.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&&!Od(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(ze.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=ie("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(ze.Main,{children:i?n.jsx(sm,{}):n.jsx(ze.Messages,{})}),t[14]=i,t[15]=b):b=t[15];let k;t[16]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(ze.Footer,{children:n.jsx(ze.Input,{onOpenContextPanel:()=>o("context")})}),t[16]=k):k=t[16];let w;t[17]!==v||t[18]!==b?(w=n.jsxs("div",{className:v,children:[b,k]}),t[17]=v,t[18]=b,t[19]=w):w=t[19];const N=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let j;t[20]!==N?(j=ie("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",N),t[20]=N,t[21]=j):j=t[21];let R;t[22]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(Uf,{back:!0,onClose:()=>o("chat")}),t[22]=R):R=t[22];let I;t[23]!==j?(I=n.jsx("div",{className:j,children:R}),t[23]=j,t[24]=I):I=t[24];let E;return t[25]!==I||t[26]!==x||t[27]!==w?(E=n.jsxs(ze,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[x,w,I]}),t[25]=I,t[26]=x,t[27]=w,t[28]=E):E=t[28],E}function Sc(){const t=K.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(ze.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx($t,{fallback:e,children:n.jsx(A.Suspense,{fallback:n.jsx(ze.Skeleton,{}),children:n.jsx(im,{})})}),t[1]=s):s=t[1],s}function rm(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 wa(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 nm(t,e){return t===1?!0:t===0?!1:e}function om(t,e){const s=Vt(),i=co({strict:!1}),r=Xl({strict:!1}),{create:o}=Eu(),{locator:a}=je(),{virtualMcpId:l,orgSlug:h,isAgentRoute:c}=e,d=rm({entityMetadata:t,mainParamPresent:i.main!==void 0,mainParamValue:i.main}),u=nm(i.chat,d.chatOpen),f=d.mainOpen,p=A.useRef(crypto.randomUUID()),m=r.taskId??p.current,_="/$org/$taskId",g=R=>({org:h,taskId:R}),x=c?{virtualmcpid:l}:{},S=(R,I)=>{s({to:_,params:g(m),search:E=>({...E,...R}),replace:I?.replace??!1})},v=(R,I)=>{s({to:_,params:g(R),search:E=>{const C={};return I?C.virtualmcpid=I:c&&(C.virtualmcpid=l),C}})},b=()=>{f?S({main:"0"},{replace:!0}):S({main:xn(t)},{replace:!0})},k=()=>{S({chat:u?0:1},{replace:!0})},w=()=>{u||S({chat:1},{replace:!0})},N=async()=>{const R=crypto.randomUUID(),I=ru(h,a,m);try{await o({id:R,virtual_mcp_id:l,...I?{branch:I}:{}})}catch{}s({to:_,params:g(R),search:E=>({...x,chat:1})})},j=R=>{S({main:R},{replace:!0})};return{taskId:m,mainOpen:f,chatOpen:u,mainParam:i.main,setTaskId:v,toggleMain:b,toggleChat:k,openChat:w,createNewTask:N,openTab:j}}const ko=45;function wc(t,e=ko){const s=typeof t=="number"?t:Number(t);return!Number.isFinite(s)||s<=0||s>=100?e:s}function am(t){return wc(t,ko)}function lm(){const t=K.c(6);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=Ed.decoChatPanelWidth(),t[0]=e):e=t[0];const[s,i]=Nd(e,am);let r;t[1]!==s?(r=wc(s,ko),t[1]=s,t[2]=r):r=t[2];const o=r;let a;return t[3]!==i||t[4]!==o?(a=[o,i],t[3]=i,t[4]=o,t[5]=a):a=t[5],a}function cm(t){try{return JSON.parse(t)}catch{return null}}function hm(t){if(!t||typeof t!="object")return null;const e=t,s=e.content?.find(o=>o.type==="text")?.text,i=s?cm(s):null,r=e.structuredContent;return r==null?i:typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===0?i??r:r}function Ss(t){const e=hm(t);return e===null?null:e}function jo(t){if(!t)return null;const e=t.match(/\/pull\/(\d+)\b/);if(!e)return null;const s=Number(e[1]);return Number.isFinite(s)&&s>0?s:null}function dm(t){if(!t||typeof t!="object")return null;const e=t.content?.find(r=>r.type==="text")?.text;if(!e)return null;const s=e.match(/https:\/\/github\.com\/[^\s"]+\/pull\/\d+/)?.[0],i=jo(s);return!i||!s?null:{number:i,htmlUrl:s}}function um(t){if(!t||typeof t!="object")return null;const e=t;return e.isError?e.content?.find(i=>i.type==="text")?.text?.trim()||"GitHub MCP tool returned an error":null}function No(t){const e=um(t);if(e)throw new Error(e)}function Cc(t,e){for(const s of e){const i=t[s];if(typeof i=="string"&&i.length>0)return i}}function kc(t,e){for(const s of e){const i=t[s];if(typeof i=="number"&&Number.isFinite(i)&&i>0)return i;if(typeof i=="string"&&/^\d+$/.test(i)){const r=Number(i);if(r>0)return r}}}function fm(t){const s=t.head?.ref;return typeof s=="string"&&s.length>0?s:null}function mm(t,e){return fm(t)===e}function jc(t){const e=Ss(t);if(Array.isArray(e))return e.filter(s=>s!=null&&typeof s=="object");if(e&&typeof e=="object"){const s=e;for(const i of["pull_requests","items","data"]){const r=s[i];if(Array.isArray(r))return r.filter(o=>o!=null&&typeof o=="object")}}return[]}function pm(t){const e=Cc(t,["html_url","htmlUrl","url","URL"]),s=kc(t,["number","pullNumber"])??jo(e);return!s||!e?null:{number:s,htmlUrl:e}}function _m(t){No(t);const e=dm(t);if(e)return e;const s=Ss(t);if(s&&typeof s=="object"){const i=Cc(s,["url","URL","html_url","htmlUrl"]),r=kc(s,["number","pullNumber"])??jo(i);if(r&&i)return{number:r,htmlUrl:i}}throw new Error("Failed to open pull request")}function gm(t){return/already exists|pull request already/i.test(t)}async function vm(t,e){const s=await t.callTool({name:"list_pull_requests",arguments:{owner:e.owner,repo:e.repo,state:"open",...e.head?{head:e.head}:{},perPage:10}});return No(s),jc(s)}async function Ca(t,e){const s=[`${e.owner}:${e.branch}`,e.branch];for(const i of s){const o=(await vm(t,{owner:e.owner,repo:e.repo,head:i})).find(l=>mm(l,e.branch)),a=o?pm(o):null;if(a)return a}return null}async function xm(t,e){const s=await t.callTool({name:"create_pull_request",arguments:{owner:e.owner,repo:e.repo,title:e.title,body:e.body,head:e.head,base:e.base}});return _m(s)}async function ka(t,e){const s=await Ca(t,{owner:e.owner,repo:e.repo,branch:e.branch});if(s)return s;try{return await xm(t,{owner:e.owner,repo:e.repo,title:e.title,body:e.body,head:e.branch,base:e.base})}catch(i){const r=i instanceof Error?i.message:String(i);if(!gm(r))throw i;const o=await Ca(t,{owner:e.owner,repo:e.repo,branch:e.branch});if(o)return o;throw i}}async function Nc(t,e){const s=await t.callTool({name:"merge_pull_request",arguments:{owner:e.owner,repo:e.repo,pullNumber:e.pullNumber,merge_method:"squash",...e.commitTitle?{commit_title:e.commitTitle}:{}}});No(s);const i=Ss(s);if(!i||i.merged!==!0)throw new Error(i?.message??"Failed to merge pull request");return{merged:!0,message:i.message??"Pull request merged"}}const Eo=6e4,To=3e4;function Ro(t){const e=K.c(15);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=Xe(s);let r;e[4]!==t.branch||e[5]!==t.owner?(r=t.branch?{head:`${t.owner}:${t.branch}`}:{},e[4]=t.branch,e[5]=t.owner,e[6]=r):r=e[6];let o;e[7]!==t.owner||e[8]!==t.repo||e[9]!==r?(o={owner:t.owner,repo:t.repo,state:"all",...r,perPage:1},e[7]=t.owner,e[8]=t.repo,e[9]=r,e[10]=o):o=e[10];const a=!!t.branch&&!!t.connectionId&&!!t.owner&&!!t.repo;let l;return e[11]!==i||e[12]!==o||e[13]!==a?(l={client:i,toolName:"list_pull_requests",toolArguments:o,enabled:a,refetchInterval:Eo,refetchIntervalInBackground:!1,staleTime:To,select:bm},e[11]=i,e[12]=o,e[13]=a,e[14]=l):l=e[14],Lr(l)}function bm(t){const e=jc(t);if(e.length===0)return null;const s=e[0],i=s.base,r=s.head,o=s.user;return{number:s.number??0,title:s.title??"",body:s.body??"",state:s.state==="closed"?"closed":"open",merged:s.merged_at!=null,mergedAt:s.merged_at??null,base:i?.ref??"main",head:r?.ref??"",headSha:r?.sha??"",htmlUrl:s.html_url??"",author:o?.login??""}}function Ec(t){const e=K.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=Xe(s),r=t.prNumber??0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(o={method:"get_check_runs",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=o):o=e[7];const a=!!t.prNumber;let l;return e[8]!==i||e[9]!==o||e[10]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:Eo,refetchIntervalInBackground:!1,staleTime:To,select:ym},e[8]=i,e[9]=o,e[10]=a,e[11]=l):l=e[11],Lr(l)}function ym(t){const e=Ss(t);return(Array.isArray(e)?e:e?.check_runs??[]).map(Sm)}function Sm(t){const e=t.started_at,s=t.completed_at,i=e&&s?new Date(s).getTime()-new Date(e).getTime():null;return{id:String(t.id??""),name:String(t.name??""),status:t.status??"completed",conclusion:t.conclusion??null,htmlUrl:String(t.html_url??""),durationMs:i}}function wm(t){const e=K.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=Xe(s),r=t.prNumber??0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(o={method:"get_comments",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=o):o=e[7];const a=!!t.prNumber;let l;return e[8]!==i||e[9]!==o||e[10]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:Eo,refetchIntervalInBackground:!1,staleTime:To,select:Cm},e[8]=i,e[9]=o,e[10]=a,e[11]=l):l=e[11],Lr(l)}function Cm(t){const e=Ss(t);return Array.isArray(e)?e.map(km):[]}function km(t){const e=t.user;return{id:Number(t.id??0),author:e?.login??"",body:String(t.body??""),createdAt:String(t.created_at??""),htmlUrl:String(t.html_url??"")}}function Po(t,e){const s=K.c(8),i=t?`${t.orgSlug}/${t.virtualMcpId}/${t.branch}`:"",r=e?.fetchEnabled??!0;let o;s[0]!==i?(o=Ut.decofile(i),s[0]=i,s[1]=o):o=s[1];let a;s[2]!==t?(a=async()=>{const c=new URLSearchParams({path:"/.decofile"}),d=await fetch(`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/preview-fetch?${c.toString()}`);if(!d.ok)throw new Error(`Failed to fetch decofile: ${d.status}`);return await d.json()},s[2]=t,s[3]=a):a=s[3];const l=!!t&&r;let h;return s[4]!==o||s[5]!==a||s[6]!==l?(h={queryKey:o,queryFn:a,enabled:l,staleTime:3e4,retry:3,retryDelay:jm},s[4]=o,s[5]=a,s[6]=l,s[7]=h):h=s[7],ki(h)}function jm(t){return Math.min(1e3*2**t,5e3)}function Do(t,e){const s=K.c(8),i=t?`${t.orgSlug}/${t.virtualMcpId}/${t.branch}`:"",r=e?.fetchEnabled??!0;let o;s[0]!==i?(o=Ut.liveMeta(i),s[0]=i,s[1]=o):o=s[1];let a;s[2]!==t?(a=async()=>{const c=new URLSearchParams({path:"/live/_meta"}),d=await fetch(`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/preview-fetch?${c.toString()}`);if(!d.ok)throw new Error(`Failed to fetch live meta: ${d.status}`);return await d.json()},s[2]=t,s[3]=a):a=s[3];const l=!!t&&r;let h;return s[4]!==o||s[5]!==a||s[6]!==l?(h={queryKey:o,queryFn:a,enabled:l,staleTime:3e5,retry:3,retryDelay:Nm},s[4]=o,s[5]=a,s[6]=l,s[7]=h):h=s[7],ki(h)}function Nm(t){return Math.min(1e3*2**t,5e3)}function Em(t){if(!t.startsWith("#")||!t.includes("@"))return null;const e=t.indexOf("@");return{moduleResolveType:t.slice(1,e),blockId:t.slice(e+1)}}function LS(t){return t.includes("@")}function ja(t){const e=t.lastIndexOf("@");return e<0||e===t.length-1?null:t.slice(e+1)}function OS(t,e){if(t===e)return!0;const s=ja(t);return s?e===s||ja(e)===s:!1}function Tc(t,e){const s=t.manifest?.blocks??{};for(const[i,r]of Object.entries(s))if(e in r)return i;return null}function Rc(t,e){const s=Tc(t,e);return s!==null&&s.includes("sections")}function Tm(t,e){const s=Tc(t,e);return s!==null&&s.includes("matchers")}function Ao(t){return!t.includes("/")}function Pc(t){try{return decodeURIComponent(t).startsWith("Preview ")}catch{return t.startsWith("Preview ")}}const Rm=["website/sections/Rendering/Lazy.tsx","website/sections/Rendering/SingleDeferred.tsx"];function $r(t){return Rm.some(e=>t.endsWith(e))}const Pm="VideoWidget";function Dm(t,e){const s=e.schema??{},i=e.manifest?.blocks??{};let r={};for(const f of Object.values(i))if(f[t]){r=f[t];break}const o={...s,...r},a=o.$defs??o.definitions??{},l=f=>{const p=f.split("/").pop()??"";return a[p]??{}},h=(f,p=new Set,m=0)=>{if(m>5)return{};if(typeof f.$ref=="string"){const g=f.$ref.split("/").pop()??"";return p.has(g)?{}:h(l(f.$ref),new Set([...p,g]),m+1)}let _={};if(f.properties&&typeof f.properties=="object"&&(_={..._,...f.properties}),Array.isArray(f.required)){const g=Array.isArray(_.__required)?_.__required:[];_.__required=[...g,...f.required]}for(const g of["allOf","anyOf","oneOf"]){const x=f[g];if(Array.isArray(x))for(const S of x)_={..._,...h(S,p,m+1)}}return _},c=(f,p=0)=>{let m=f;typeof f.$ref=="string"&&(m=l(f.$ref),(f.$ref.split("/").pop()??"")===Pm&&!m.format&&(m={...m,format:"video-uri"}));let _;{const w=m.anyOf??m.oneOf;if(Array.isArray(w)){const N=w.filter(R=>!(R.type==="null"||R.type===null)),j=R=>{if(typeof R.const=="string"||typeof R.const=="number")return R.const;if(Array.isArray(R.enum)&&R.enum.length===1&&(typeof R.enum[0]=="string"||typeof R.enum[0]=="number"))return R.enum[0]};N.length>0&&N.every(R=>j(R)!==void 0)&&(_=N.map(R=>j(R)))}}let g,x;if(m.type)g=Array.isArray(m.type)?String(m.type.find(w=>w!=="null")??m.type[0]):String(m.type);else if(m.anyOf||m.allOf||m.oneOf){const N=(m.anyOf??m.allOf??m.oneOf).filter(j=>!(j.type==="null"||j.type===null));if(N.length===0)g="null";else if(N.length===1){const j=N[0];x=j,g=j.type?Array.isArray(j.type)?String(j.type[0]):String(j.type):typeof j.$ref=="string"?"object":"string"}else{if(_)return{type:"string",title:typeof m.title=="string"?m.title:void 0,description:typeof m.description=="string"?m.description:void 0,enum:_};const j=N.filter(I=>{const E=I.properties?.__resolveType?.enum;return Array.isArray(E)&&typeof E[0]=="string"});if(j.length>0){const I=j.map(E=>{const y=E.properties?.__resolveType?.enum??[],T=String(y[0]);return{resolveType:T,title:typeof E.title=="string"?E.title:T.split("/").pop()?.replace(/\.tsx?$/,"").replace(/[-_]/g," ")??T,description:typeof E.description=="string"?E.description:void 0,schema:p+1<6?c(E,p+1):void 0}});return{type:"block-ref",title:typeof m.title=="string"?m.title:void 0,description:typeof m.description=="string"?m.description:void 0,anyOfRefs:I}}if(N.every(I=>typeof I.$ref=="string")){const I=[];for(const E of N){const C=l(E.$ref);let y,T;if(typeof C.title=="string"){const D=Em(C.title);D&&(y=D.blockId,T=D.blockId)}if(!y&&Array.isArray(C.allOf))for(const D of C.allOf){const B=((D.properties??{}).__resolveType??{}).enum;if(Array.isArray(B)&&typeof B[0]=="string"){y=B[0];break}}y||(y=E.$ref.split("/").pop()??""),I.push({resolveType:y,title:T??(typeof C.title=="string"&&!C.title.startsWith("#")?C.title:y.split("/").pop()?.replace(/\.tsx?$/,"").replace(/[-_]/g," ")??y),description:typeof C.description=="string"?C.description:void 0,schema:p+1<6?c(C,p+1):void 0})}return{type:"block-ref",title:typeof m.title=="string"?m.title:void 0,description:typeof m.description=="string"?m.description:void 0,anyOfRefs:I}}g="object"}}else typeof f.$ref=="string"&&(g="object");let S;if(p<6){const w=h(m),N=Object.entries(w).filter(([j])=>!j.startsWith("__")&&j!=="@type");if(N.length>0){S={};for(const[j,R]of N)S[j]=c(R,p+1)}}let v;if((g==="array"||m.type==="array")&&p<6){let w=m.items;w&&(typeof w.$ref=="string"&&(w=l(w.$ref)),v=c(w,p+1))}const b=w=>{const N=x?.[w];return typeof N=="string"?N:void 0},k=()=>{if("default"in f)return f.default;if("default"in m)return m.default;if(x&&"default"in x)return x.default};return{type:g??"string",title:typeof f.title=="string"?f.title:typeof m.title=="string"?m.title:b("title"),description:typeof f.description=="string"?f.description:typeof m.description=="string"?m.description:b("description"),default:k(),enum:Array.isArray(m.enum)?m.enum:_??void 0,format:typeof m.format=="string"?m.format:b("format"),properties:S,items:v,titleBy:typeof m.titleBy=="string"?m.titleBy:b("titleBy")}},d=h(o),u={};for(const[f,p]of Object.entries(d))f.startsWith("__")||f==="@type"||(u[f]=c(p,0));return Object.keys(u).length===0?null:{type:"object",title:typeof o.title=="string"?o.title:void 0,properties:u}}function Dc(t,e){const s=e.schema??{},i=e.manifest?.blocks??{};let r={};for(const c of Object.values(i))if(c[t]){r=c[t];break}const o={...s,...r},a=o.$defs??o.definitions??{},l=typeof r.$ref=="string"?a[r.$ref.split("/").pop()??""]??{}:{...s,...r},h=l.icon;return{title:typeof l.title=="string"?l.title:void 0,description:typeof l.description=="string"?l.description:void 0,icon:typeof h=="string"?h:void 0}}const $S="oklch(0.7278 0.151 289)",Am="website/matchers/always.ts",Ac="website/matchers/never.ts",Mm="website/flags/multivariate.ts",Bm="website/flags/multivariate/section.ts";function Mc(t){const e=t.split("/");return(e[e.length-1]??t).replace(/\.(tsx?|jsx?)$/,"").replace(/[-_]/g," ").replace(/\b\w/g,i=>i.toUpperCase())||t}function zS(t){return t.map(e=>`${e.resolveType}|${e.label}|${e.isHidden??!1}|${e.isSavedBlock??!1}|${e.isMultivariate??!1}|${e.isLazy??!1}`).join(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sections-editor-DH5JOAp0.js","assets/index-Dj4-zrs6.js","assets/index-DKkDFkdk.css","assets/ChevronDown-TMeEZ-9A.js","assets/ChevronRight-CDKzvljX.js","assets/ChevronUp-eCy1cXbK.js","assets/agent-icon-CEeT91YN.js","assets/AlertCircle-B0GNnY3o.js","assets/Tool01-Cnj7wd8K.js","assets/Stars02-Ckx-WBTD.js","assets/SwitchHorizontal01-Dz4Ji_qc.js","assets/RefreshCcw01-CUc6nkD4.js","assets/XCircle-Idqm0Rxs.js","assets/ArrowUpRight-D5UcplCf.js","assets/ZapSquare-KfmyA8BQ.js","assets/Users03-BJAg49-c.js","assets/CheckCircle-7Lf65UH6.js","assets/Check-Bf1pls96.js","assets/DotsVertical-BOt1wiB7.js","assets/Container-sqP569CF.js","assets/FilterLines-DkZMnaSL.js","assets/Star01-CBrrPcC6.js","assets/Palette-Df_duF6v.js","assets/HardDrive-BHufpGbg.js","assets/Key01-D9cQj8yC.js","assets/sheet-C1wM9bZQ.js","assets/X-CWgRIo1Y.js","assets/LinkExternal01-BJD57eXD.js","assets/Lock01-oEtMCFJe.js","assets/Monitor01-BGlX8Upy.js","assets/Sun-Qwf06k9f.js","assets/Play-C8j34bHG.js","assets/Plus-DgDZd3Py.js","assets/SearchMd-CVK9lObw.js","assets/Settings02-D_dC626L.js","assets/Shield01-Dcl5mREy.js","assets/Trash01-xomQSD5r.js","assets/Upload01-DpAmukj3.js","assets/User01-DaJXp3OF.js","assets/Users01-BsgBLWUa.js","assets/XClose-CE3dSxau.js","assets/Zap-D6AgIZNP.js","assets/scroll-area-BHTmdDeg.js","assets/select-n1Ny26B8.js","assets/tooltip-JDpiFtIa.js","assets/dialog-Dc6y7vPT.js","assets/input-C9C2SWkc.js","assets/dropdown-menu-nWCyMGON.js","assets/sortable.esm-CaJ5jMdk.js","assets/connection-slug-eyAPH6o3.js","assets/connection-card-BV8NZ6Yy.js","assets/use-registry-connections-ByZ9hVMl.js","assets/use-connection-DBjq9KVP.js","assets/use-collections-D9hFdS86.js","assets/constants-BL-7A3pB.js","assets/use-organization-settings-1LMC0Mz_.js","assets/useInfiniteQuery-Bqtfpdpy.js","assets/infiniteQueryObserver-C2uwxowv.js","assets/extract-connection-data-Bj7gl05J.js","assets/generate-id-DwZG6sYA.js","assets/collections-DEWnJnrS.js","assets/card-Bk5j-Pdp.js","assets/integration-icon-Bqmq9Rqh.js","assets/collection-search-Cdm_smEs.js","assets/collection-tabs-BWmdHW4j.js","assets/badge-BNy0JA2j.js","assets/drawer-DfiiN5b1.js","assets/form-6cV6csj4.js","assets/label-Ecklj764.js","assets/textarea-DcuuwQHt.js","assets/connection-form-helpers-B7AMdZMB.js","assets/use-infinite-scroll-BEfkuMXD.js","assets/useSuspenseInfiniteQuery-CICgRt5F.js","assets/calendar-BeVfpnMh.js","assets/popover-DoUZKqVh.js","assets/switch-CrTnPTc9.js","assets/skeleton-CawVhyai.js","assets/tabs-Duy6-jlC.js","assets/use-file-configs-CGj4WzBd.js","assets/unwrap-tool-result-BYXdCQMg.js","assets/command-DEHGaU4o.js","assets/index-CiJnVXvE.js","assets/add-section-modal-BQo99wbw.js","assets/index-EEG8k-A3.js","assets/chat-context-BsAWyDZi.js","assets/tab-id-D_jRge83.js","assets/decopilot-sse-pool-Dw7wtcn-.js","assets/create-sse-subscription--G7iwTWC.js","assets/use-virtual-mcp-eu3msVHv.js","assets/use-ai-providers-BvVxStkO.js","assets/pair-CbRLlxW0.js","assets/format-time-Cy7tTmZp.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/use-copy-BEMjhay_.js","assets/content-blocks-o63cs2vh.js","assets/types-Dj9CgGbv.js","assets/shell-layout-euayb4e7.js","assets/avatar-Dh9pKpVF.js","assets/required-auth-layout-CGP_SUFu.js","assets/useRouterState-CglkVopv.js","assets/use-org-sso-BtKZj6eM.js","assets/use-navigate-to-agent-CavOGg9q.js","assets/use-mcp-prompts-mcndCy09.js","assets/spinner-CTR7wptZ.js","assets/toggle-group-DSOscY_T.js","assets/agent-icons-CJFOulg8.js","assets/checkbox-C2B4CGdO.js","assets/ai-providers-logos-DD3qZ33J.js","assets/settings-section-DexNFpN6.js","assets/connect-desktop-dialog-CZZJQ3Sq.js","assets/index-u_AL5q1O.js","assets/question-004-sINsf4GQ.js","assets/index-DF8Vp58x.js","assets/sidebar-DxN18qmt.js","assets/toolbar-Cfl-fyNN.js","assets/use-create-virtual-mcp-Cz4pK0yB.js","assets/github-repo-picker-XOtx61HB.js","assets/use-mcp-tools-B4A6jd0i.js","assets/alert-dialog-Ci7AlU26.js","assets/index-DH1PxCKH.js","assets/use-org-auth-client-uJl3t32_.js","assets/hover-card-BYiiR87E.js","assets/task-status-DS_Y8i0S.js","assets/use-status-sounds-DlgUXBkr.js","assets/empty-state-hzVvczoq.js","assets/accordion-CdAJ_dXT.js","assets/user-BugqD7JO.js","assets/tools-list-BhF3OpOK.js","assets/use-debounced-autosave-BhHzBpyf.js","assets/index-DDsV_St1.js","assets/use-secrets-HugubdRW.js","assets/formatDistanceToNow-Cb2QZZJn.js","assets/monaco-editor-CR7urYlm.js","assets/view-mode-toggle-3BcjxS-G.js","assets/automation-list-row-BDIOPKGN.js","assets/search-input-C7NqjWfP.js","assets/file-explorer-DNXKqBDW.js","assets/project-app-view-CNVhgJlW.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{e as K,r as A,c as ie,j as n,l as ge,E as $t,q as je,f as Vt,d as co,g as Xl,p as Nd,L as Ed,n as ki,K as Ut,s as Td,o as ae,B as te,v as ui,V as Rd,t as Me,b as ji,w as Jl,x as Pd,y as Er,z as fs,C as dt,D as Tr,F as Zl,G as Dd,H as Ad,I as ca,J as Md,a as Rr,M as Zi,P as oi,Q as wt,_ as Ni,R as vi,T as Bd,U as Id}from"./index-Dj4-zrs6.js";import{C as ze,u as Ld,w as Od,a as ho,b as uo,s as Qi,T as $d,t as zd,r as Fd,c as Hd,d as Wd}from"./index-EEG8k-A3.js";import{I as gs}from"./integration-icon-Bqmq9Rqh.js";import{g as fo,u as Xe,S as vs,a as Ql,K as Ud}from"./constants-BL-7A3pB.js";import{u as At,a as Kd,b as Vd}from"./use-virtual-mcp-eu3msVHv.js";import{a as qd}from"./Users03-BJAg49-c.js";import{u as xs,a as rs,b as Pr,c as Ei,h as Gd,g as Bs,d as ec,t as Yd,e as ha,f as Xd}from"./chat-context-BsAWyDZi.js";import{i as Ti}from"./AlertCircle-B0GNnY3o.js";import{i as Jd}from"./CheckCircle-7Lf65UH6.js";import{n as da}from"./ZapSquare-KfmyA8BQ.js";import{i as Zd,a as mo,b as Qd}from"./XCircle-Idqm0Rxs.js";import{s as As}from"./XClose-CE3dSxau.js";import{c as eu,t as ua,M as po,G as tu}from"./pair-CbRLlxW0.js";import{u as su}from"./use-ai-providers-BvVxStkO.js";import{u as iu}from"./connect-desktop-dialog-CZZJQ3Sq.js";import{r as ru,u as _o,i as nu}from"./shell-layout-euayb4e7.js";import{b as ou,a as au}from"./index-DF8Vp58x.js";import{u as lu}from"./sidebar-DxN18qmt.js";import{i as cu,S as hu,a as du,b as uu}from"./sheet-C1wM9bZQ.js";import{u as tc,T as Se,a as we,b as Ce,c as sc}from"./tooltip-JDpiFtIa.js";import{i as Ps,a as Dr,b as fu,c as mu,p as Ar,g as Mr,d as go,e as ic,h as gn,f as Jr,j as fa,A as ma,k as pu,l as _u,n as gu,m as vu,o as xu,t as bu,q as yu,r as Su,s as Br,u as wu,v as rc,w as vn,x as nc,y as oc,z as pa,B as Cu,C as vo,D as _a,E as ku,F as fi,G as ac,H as lc,I as ju}from"./agent-icon-CEeT91YN.js";import{u as Nu}from"./use-status-sounds-DlgUXBkr.js";import{E as hr}from"./empty-state-hzVvczoq.js";import{u as Eu,r as xn,a as Tu,p as cc,f as ga,b as hc,c as Ru,F as Pu,i as Du,d as Au,e as Mu,g as Bu,h as Iu}from"./tab-id-D_jRge83.js";import{T as va,a as bn}from"./toolbar-Cfl-fyNN.js";import{A as Lu,a as Ou,b as $u,c as zu,R as dc,d as Fu,e as Hu}from"./accordion-CdAJ_dXT.js";import{u as Ir,a as xo,b as Wu}from"./use-connection-DBjq9KVP.js";import{u as Lr,a as Uu}from"./use-mcp-tools-B4A6jd0i.js";import{g as Ku}from"./generate-id-DwZG6sYA.js";import{u as Vu,g as qu}from"./types-Dj9CgGbv.js";import{U as uc}from"./user-BugqD7JO.js";import{T as Gu,u as fc}from"./tools-list-BhF3OpOK.js";import{u as Yu}from"./unwrap-tool-result-BYXdCQMg.js";import{s as mc,g as Xu}from"./connection-slug-eyAPH6o3.js";import{A as dr,a as ur,b as fr,c as mr,d as pr,e as _r,f as gr,g as vr}from"./alert-dialog-Ci7AlU26.js";import{D as Is,a as qt,b as Gt,c as bs,d as ys,e as bo}from"./dialog-Dc6y7vPT.js";import{C as pc,a as yn}from"./card-Bk5j-Pdp.js";import{I as Ye}from"./input-C9C2SWkc.js";import{L as bt}from"./label-Ecklj764.js";import{S as zt,a as Ft,b as Ht,c as Wt,d as ft}from"./select-n1Ny26B8.js";import{S as Sn}from"./switch-CrTnPTc9.js";import{T as xr}from"./textarea-DcuuwQHt.js";import{i as ms}from"./Play-C8j34bHG.js";import{s as Kt}from"./Plus-DgDZd3Py.js";import{a as Ju}from"./Settings02-D_dC626L.js";import{t as yo,i as _c}from"./Tool01-Cnj7wd8K.js";import{s as xi}from"./Trash01-xomQSD5r.js";import{u as br}from"./use-debounced-autosave-BhHzBpyf.js";import{P as Ls,a as Os,b as $s}from"./popover-DoUZKqVh.js";import{S as So}from"./scroll-area-BHTmdDeg.js";import{i as gc}from"./SearchMd-CVK9lObw.js";import{i as Zu}from"./Upload01-DpAmukj3.js";import{P as Ct}from"./index-DDsV_St1.js";import{A as Qu}from"./sortable.esm-CaJ5jMdk.js";import{C as ef}from"./collection-tabs-BWmdHW4j.js";import{C as vc}from"./checkbox-C2B4CGdO.js";import{u as tf}from"./use-mcp-prompts-mcndCy09.js";import{D as sf,a as rf,b as nf}from"./drawer-DfiiN5b1.js";import{i as Ri}from"./Check-Bf1pls96.js";import{a as ss,i as of,s as af}from"./RefreshCcw01-CUc6nkD4.js";import{i as xc}from"./Key01-D9cQj8yC.js";import{S as Es}from"./skeleton-CawVhyai.js";import{i as lf}from"./Lock01-oEtMCFJe.js";import{s as cf}from"./User01-DaJXp3OF.js";import{t as hf}from"./Users01-BsgBLWUa.js";import{u as df,a as uf}from"./use-secrets-HugubdRW.js";import{G as ff}from"./github-repo-picker-XOtx61HB.js";import{f as mf}from"./formatDistanceToNow-Cb2QZZJn.js";import{n as zs}from"./LinkExternal01-BJD57eXD.js";import{T as hs,a as wo,b as mi,c as Co}from"./tabs-Duy6-jlC.js";import{l as pf,w as _f,M as gf}from"./monaco-editor-CR7urYlm.js";import{D as Fs,a as Hs,b as Ws,c as ut,d as xa,e as vf,f as xf,g as bf}from"./dropdown-menu-nWCyMGON.js";import{i as yf}from"./ChevronRight-CDKzvljX.js";import{S as bc}from"./spinner-CTR7wptZ.js";import{t as Or}from"./ChevronDown-TMeEZ-9A.js";import{C as ba,a as ya,b as Sf,c as wf,d as Cf,e as kf,f as jf}from"./command-DEHGaU4o.js";import{u as Nf}from"./useInfiniteQuery-Bqtfpdpy.js";import{s as yr}from"./Star01-CBrrPcC6.js";import{i as yc}from"./Stars02-Ckx-WBTD.js";import{V as Ef}from"./view-mode-toggle-3BcjxS-G.js";import{i as Tf}from"./X-CWgRIo1Y.js";import{u as Pi,a as Rf,b as Pf,c as Df,A as Af,d as Mf}from"./automation-list-row-BDIOPKGN.js";import{i as Bf}from"./SwitchHorizontal01-Dz4Ji_qc.js";import{i as bi}from"./Zap-D6AgIZNP.js";import{S as If}from"./search-input-C7NqjWfP.js";function Js(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function Sa(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 Lf(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function Of(t){const e=K.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map($f),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 $f(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 zf(t){const e=K.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 p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=p):p=e[10];let m;e[11]!==a?(m=a.toFixed(1),e[11]=a,e[12]=m):m=e[12];let _;e[13]!==m?(_=n.jsxs("div",{className:"flex items-center gap-1.5",children:[p,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",m,"%"]})]}),e[13]=m,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 k;return e[27]!==b||e[28]!==f?(k=n.jsxs("div",{className:"flex flex-col gap-2",children:[f,b]}),e[27]=b,e[28]=f,e[29]=k):k=e[29],k}function Ff(t){const e=K.c(11),{agentId:s,isError:i}=t,r=At(s),o=r?.title??"Subtask",a=r?.icon??null;let l;e[0]!==a||e[1]!==o?(l=n.jsx(gs,{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=ie("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 Hf(t){const e=K.c(5),{isError:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(gs,{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=ie("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 Wf(t){const e=K.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(Hf,{isError:o}),e[0]=o,e[1]=l):l=e[1];let h;e[2]!==i||e[3]!==o?(h=n.jsx(Ff,{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(A.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(ge,{size:12,className:"animate-spin text-muted-foreground"}):o?n.jsx(Zd,{size:12,className:"text-destructive"}):a?n.jsx(Ti,{size:12,className:"text-warning"}):n.jsx(Jd,{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 Uf(t){const e=K.c(55),{onClose:s,back:i,className:r}=t,[o,a]=A.useState(null),{messages:l}=xs(),{activeTask:h}=rs(),{selectedModel:c,selectedVirtualMcp:d}=Pr();let u,f,p,m,_,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 k=eu(l),w=[...l].reverse().find(tm),N=w?.metadata?.usage,j=w?.metadata?.modelLimits?.contextWindow??c?.limits?.contextWindow??null,R=N?.contextTokens??0,I=j&&j>0?(R/j*100).toFixed(1):null,E=l;let C;e[16]!==E?(C=E.filter(em).reduce(Qf,0),e[16]=E,e[17]=C):C=e[17];const y=C,T=l;let D;e[18]!==T?(D=T.filter(Zf).reduce(Jf,0),e[18]=T,e[19]=D):D=e[19];const P=D,M=Math.max(0,k.totalTokens-y-P),B=l[0],F=l.at(-1),U=B?.metadata?.created_at??h?.created_at,z=F?.metadata?.created_at??h?.updated_at,O=l.filter(Xf),q=l.flatMap(Gf),V=c?.modelId?Lf(c.modelId):"—",Q=d?.title??"Decopilot",G=[{label:"Session",value:h?.title??"New chat"},{label:"Messages",value:O.length},{label:"Agent",value:Q},{label:"Model",value:V},{label:"Context Limit",value:j?Js(j):"—"},{label:"Session Tokens (billed)",value:k.totalTokens>0?Js(k.totalTokens):"0"},{label:"Usage",value:I!==null?`${I}%`:"—"},{label:"Input Tokens",value:k.inputTokens>0?Js(k.inputTokens):"0"},{label:"Output Tokens",value:k.outputTokens>0?Js(k.outputTokens):"0"},{label:"Reasoning Tokens",value:k.reasoningTokens>0?Js(k.reasoningTokens):"0"},{label:"Cost",value:k.cost>0?`$${k.cost<.001?k.cost.toFixed(6):k.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:Sa(U)},{label:"Last Activity",value:Sa(z)}];if(!h&&O.length===0){let L;e[20]!==r?(L=ie("flex flex-col h-full w-full border-l border-border bg-background",r),e[20]=r,e[21]=L):L=e[21];let Y;e[22]===Symbol.for("react.memo_cache_sentinel")?(Y=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[22]=Y):Y=e[22];let X;e[23]!==i?(X=i?n.jsx(da,{size:14,className:"text-muted-foreground"}):n.jsx(As,{size:14,className:"text-muted-foreground"}),e[23]=i,e[24]=X):X=e[24];let H;e[25]!==s||e[26]!==X?(H=n.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[Y,n.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:X})]}),e[25]=s,e[26]=X,e[27]=H):H=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 re;e[29]!==L||e[30]!==H?(re=n.jsxs("div",{className:L,children:[H,ne]}),e[29]=L,e[30]=H,e[31]=re):re=e[31],S=re;break e}e[32]!==r?(g=ie("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 W;e[34]===Symbol.for("react.memo_cache_sentinel")?(W=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[34]=W):W=e[34];let ee;e[35]!==i?(ee=i?n.jsx(da,{size:14}):n.jsx(As,{size:14}),e[35]=i,e[36]=ee):ee=e[36],e[37]!==s||e[38]!==ee?(x=n.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[W,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:ee})]}),e[37]=s,e[38]=ee,e[39]=x):x=e[39],u="flex flex-col gap-8 p-6",f=q.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:q.map(qf)})]}),p=n.jsx(Of,{items:G});let $;e[40]===Symbol.for("react.memo_cache_sentinel")?($=n.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[40]=$):$=e[40],e[41]!==P||e[42]!==M||e[43]!==y?(m=n.jsxs("div",{className:"flex flex-col gap-3",children:[$,n.jsx(zf,{userTokens:y,assistantTokens:P,otherTokens:M})]}),e[41]=P,e[42]=M,e[43]=y,e[44]=m):m=e[44],_=O.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:O.map(L=>{const Y=L.metadata?.created_at,X=o?.id===L.id;return n.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[n.jsxs("button",{type:"button",onClick:()=>a(X?null:L),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:ie("shrink-0 font-medium",L.role==="user"?"text-chart-1":"text-chart-2"),children:L.role}),n.jsx("span",{className:"text-muted-foreground",children:"•"}),n.jsx("span",{className:"truncate text-muted-foreground font-mono",children:L.id})]}),Y&&n.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(Y).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),X&&n.jsxs(n.Fragment,{children:[L.role==="assistant"&&(()=>{const H=L.metadata?._request;if(!H)return null;const ne=H.systemSections??[],re=Math.max(1,...ne.map(Vf)),ce=ne.reduce(Kf,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:[H.activeTools??0," / ",H.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(ce/4).toLocaleString()," ","tok"]})]}),ne.map((de,me)=>{const le=de.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${me}`,ve=de.chars/re*100,xe=Math.round(de.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:["~",xe.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:`${ve}%`}})})]},me)})]})]})})(),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(L,null,2)})]})]},L.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]=p,e[11]=m,e[12]=_,e[13]=g,e[14]=x,e[15]=S}else u=e[8],f=e[9],p=e[10],m=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]!==p||e[48]!==m||e[49]!==_?(v=n.jsxs("div",{className:u,children:[f,p,m,_]}),e[45]=u,e[46]=f,e[47]=p,e[48]=m,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 Kf(t,e){return t+e.chars}function Vf(t){return t.chars}function qf(t,e){return n.jsx(Wf,{part:t},e)}function Gf(t){return(t.parts??[]).filter(Yf)}function Yf(t){return t.type==="tool-subtask"}function Xf(t){return t.role!=="system"}function Jf(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function Zf(t){return t.role==="assistant"}function Qf(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function em(t){return t.role==="user"}function tm(t){return t.role==="assistant"&&t.metadata?.usage}function sm(){const t=K.c(17),{selectedVirtualMcp:e}=Pr(),{org:s}=je();let i;t[0]!==s.id?(i=fo(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(qd,{size:32}),t[2]=a):a=t[2];let l;t[3]!==o.icon||t[4]!==o.title?(l=n.jsx(gs,{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(ze.IceBreakers,{})}),t[14]=f):f=t[14];let p;return t[15]!==u?(p=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]=p):p=t[16],p}function im(){const t=K.c(29),{org:e}=je(),s=su(),{isChatEmpty:i}=xs(),[r,o]=A.useState("chat"),a=Ld(),{selectedVirtualMcp:l}=Pr();let h;t[0]!==e.id?(h=fo(e.id),t[0]=e.id,t[1]=h):h=t[1];const u=At((l??h).id),f=iu(),p=Ei(u?.metadata);if(s.length===0&&!(p&&Gd(f))){let C;return t[2]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(ze,{className:"animate-in fade-in-0 duration-200",children:n.jsx(ze.Main,{className:"flex flex-col items-center",children:n.jsx(ze.EmptyState,{children:n.jsx(ze.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&&!Od(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(ze.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=ie("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(ze.Main,{children:i?n.jsx(sm,{}):n.jsx(ze.Messages,{})}),t[14]=i,t[15]=b):b=t[15];let k;t[16]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(ze.Footer,{children:n.jsx(ze.Input,{onOpenContextPanel:()=>o("context")})}),t[16]=k):k=t[16];let w;t[17]!==v||t[18]!==b?(w=n.jsxs("div",{className:v,children:[b,k]}),t[17]=v,t[18]=b,t[19]=w):w=t[19];const N=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let j;t[20]!==N?(j=ie("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",N),t[20]=N,t[21]=j):j=t[21];let R;t[22]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(Uf,{back:!0,onClose:()=>o("chat")}),t[22]=R):R=t[22];let I;t[23]!==j?(I=n.jsx("div",{className:j,children:R}),t[23]=j,t[24]=I):I=t[24];let E;return t[25]!==I||t[26]!==x||t[27]!==w?(E=n.jsxs(ze,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[x,w,I]}),t[25]=I,t[26]=x,t[27]=w,t[28]=E):E=t[28],E}function Sc(){const t=K.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(ze.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx($t,{fallback:e,children:n.jsx(A.Suspense,{fallback:n.jsx(ze.Skeleton,{}),children:n.jsx(im,{})})}),t[1]=s):s=t[1],s}function rm(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 wa(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 nm(t,e){return t===1?!0:t===0?!1:e}function om(t,e){const s=Vt(),i=co({strict:!1}),r=Xl({strict:!1}),{create:o}=Eu(),{locator:a}=je(),{virtualMcpId:l,orgSlug:h,isAgentRoute:c}=e,d=rm({entityMetadata:t,mainParamPresent:i.main!==void 0,mainParamValue:i.main}),u=nm(i.chat,d.chatOpen),f=d.mainOpen,p=A.useRef(crypto.randomUUID()),m=r.taskId??p.current,_="/$org/$taskId",g=R=>({org:h,taskId:R}),x=c?{virtualmcpid:l}:{},S=(R,I)=>{s({to:_,params:g(m),search:E=>({...E,...R}),replace:I?.replace??!1})},v=(R,I)=>{s({to:_,params:g(R),search:E=>{const C={};return I?C.virtualmcpid=I:c&&(C.virtualmcpid=l),C}})},b=()=>{f?S({main:"0"},{replace:!0}):S({main:xn(t)},{replace:!0})},k=()=>{S({chat:u?0:1},{replace:!0})},w=()=>{u||S({chat:1},{replace:!0})},N=async()=>{const R=crypto.randomUUID(),I=ru(h,a,m);try{await o({id:R,virtual_mcp_id:l,...I?{branch:I}:{}})}catch{}s({to:_,params:g(R),search:E=>({...x,chat:1})})},j=R=>{S({main:R},{replace:!0})};return{taskId:m,mainOpen:f,chatOpen:u,mainParam:i.main,setTaskId:v,toggleMain:b,toggleChat:k,openChat:w,createNewTask:N,openTab:j}}const ko=45;function wc(t,e=ko){const s=typeof t=="number"?t:Number(t);return!Number.isFinite(s)||s<=0||s>=100?e:s}function am(t){return wc(t,ko)}function lm(){const t=K.c(6);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=Ed.decoChatPanelWidth(),t[0]=e):e=t[0];const[s,i]=Nd(e,am);let r;t[1]!==s?(r=wc(s,ko),t[1]=s,t[2]=r):r=t[2];const o=r;let a;return t[3]!==i||t[4]!==o?(a=[o,i],t[3]=i,t[4]=o,t[5]=a):a=t[5],a}function cm(t){try{return JSON.parse(t)}catch{return null}}function hm(t){if(!t||typeof t!="object")return null;const e=t,s=e.content?.find(o=>o.type==="text")?.text,i=s?cm(s):null,r=e.structuredContent;return r==null?i:typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===0?i??r:r}function Ss(t){const e=hm(t);return e===null?null:e}function jo(t){if(!t)return null;const e=t.match(/\/pull\/(\d+)\b/);if(!e)return null;const s=Number(e[1]);return Number.isFinite(s)&&s>0?s:null}function dm(t){if(!t||typeof t!="object")return null;const e=t.content?.find(r=>r.type==="text")?.text;if(!e)return null;const s=e.match(/https:\/\/github\.com\/[^\s"]+\/pull\/\d+/)?.[0],i=jo(s);return!i||!s?null:{number:i,htmlUrl:s}}function um(t){if(!t||typeof t!="object")return null;const e=t;return e.isError?e.content?.find(i=>i.type==="text")?.text?.trim()||"GitHub MCP tool returned an error":null}function No(t){const e=um(t);if(e)throw new Error(e)}function Cc(t,e){for(const s of e){const i=t[s];if(typeof i=="string"&&i.length>0)return i}}function kc(t,e){for(const s of e){const i=t[s];if(typeof i=="number"&&Number.isFinite(i)&&i>0)return i;if(typeof i=="string"&&/^\d+$/.test(i)){const r=Number(i);if(r>0)return r}}}function fm(t){const s=t.head?.ref;return typeof s=="string"&&s.length>0?s:null}function mm(t,e){return fm(t)===e}function jc(t){const e=Ss(t);if(Array.isArray(e))return e.filter(s=>s!=null&&typeof s=="object");if(e&&typeof e=="object"){const s=e;for(const i of["pull_requests","items","data"]){const r=s[i];if(Array.isArray(r))return r.filter(o=>o!=null&&typeof o=="object")}}return[]}function pm(t){const e=Cc(t,["html_url","htmlUrl","url","URL"]),s=kc(t,["number","pullNumber"])??jo(e);return!s||!e?null:{number:s,htmlUrl:e}}function _m(t){No(t);const e=dm(t);if(e)return e;const s=Ss(t);if(s&&typeof s=="object"){const i=Cc(s,["url","URL","html_url","htmlUrl"]),r=kc(s,["number","pullNumber"])??jo(i);if(r&&i)return{number:r,htmlUrl:i}}throw new Error("Failed to open pull request")}function gm(t){return/already exists|pull request already/i.test(t)}async function vm(t,e){const s=await t.callTool({name:"list_pull_requests",arguments:{owner:e.owner,repo:e.repo,state:"open",...e.head?{head:e.head}:{},perPage:10}});return No(s),jc(s)}async function Ca(t,e){const s=[`${e.owner}:${e.branch}`,e.branch];for(const i of s){const o=(await vm(t,{owner:e.owner,repo:e.repo,head:i})).find(l=>mm(l,e.branch)),a=o?pm(o):null;if(a)return a}return null}async function xm(t,e){const s=await t.callTool({name:"create_pull_request",arguments:{owner:e.owner,repo:e.repo,title:e.title,body:e.body,head:e.head,base:e.base}});return _m(s)}async function ka(t,e){const s=await Ca(t,{owner:e.owner,repo:e.repo,branch:e.branch});if(s)return s;try{return await xm(t,{owner:e.owner,repo:e.repo,title:e.title,body:e.body,head:e.branch,base:e.base})}catch(i){const r=i instanceof Error?i.message:String(i);if(!gm(r))throw i;const o=await Ca(t,{owner:e.owner,repo:e.repo,branch:e.branch});if(o)return o;throw i}}async function Nc(t,e){const s=await t.callTool({name:"merge_pull_request",arguments:{owner:e.owner,repo:e.repo,pullNumber:e.pullNumber,merge_method:"squash",...e.commitTitle?{commit_title:e.commitTitle}:{}}});No(s);const i=Ss(s);if(!i||i.merged!==!0)throw new Error(i?.message??"Failed to merge pull request");return{merged:!0,message:i.message??"Pull request merged"}}const Eo=6e4,To=3e4;function Ro(t){const e=K.c(15);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=Xe(s);let r;e[4]!==t.branch||e[5]!==t.owner?(r=t.branch?{head:`${t.owner}:${t.branch}`}:{},e[4]=t.branch,e[5]=t.owner,e[6]=r):r=e[6];let o;e[7]!==t.owner||e[8]!==t.repo||e[9]!==r?(o={owner:t.owner,repo:t.repo,state:"all",...r,perPage:1},e[7]=t.owner,e[8]=t.repo,e[9]=r,e[10]=o):o=e[10];const a=!!t.branch&&!!t.connectionId&&!!t.owner&&!!t.repo;let l;return e[11]!==i||e[12]!==o||e[13]!==a?(l={client:i,toolName:"list_pull_requests",toolArguments:o,enabled:a,refetchInterval:Eo,refetchIntervalInBackground:!1,staleTime:To,select:bm},e[11]=i,e[12]=o,e[13]=a,e[14]=l):l=e[14],Lr(l)}function bm(t){const e=jc(t);if(e.length===0)return null;const s=e[0],i=s.base,r=s.head,o=s.user;return{number:s.number??0,title:s.title??"",body:s.body??"",state:s.state==="closed"?"closed":"open",merged:s.merged_at!=null,mergedAt:s.merged_at??null,base:i?.ref??"main",head:r?.ref??"",headSha:r?.sha??"",htmlUrl:s.html_url??"",author:o?.login??""}}function Ec(t){const e=K.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=Xe(s),r=t.prNumber??0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(o={method:"get_check_runs",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=o):o=e[7];const a=!!t.prNumber;let l;return e[8]!==i||e[9]!==o||e[10]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:Eo,refetchIntervalInBackground:!1,staleTime:To,select:ym},e[8]=i,e[9]=o,e[10]=a,e[11]=l):l=e[11],Lr(l)}function ym(t){const e=Ss(t);return(Array.isArray(e)?e:e?.check_runs??[]).map(Sm)}function Sm(t){const e=t.started_at,s=t.completed_at,i=e&&s?new Date(s).getTime()-new Date(e).getTime():null;return{id:String(t.id??""),name:String(t.name??""),status:t.status??"completed",conclusion:t.conclusion??null,htmlUrl:String(t.html_url??""),durationMs:i}}function wm(t){const e=K.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=Xe(s),r=t.prNumber??0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(o={method:"get_comments",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=o):o=e[7];const a=!!t.prNumber;let l;return e[8]!==i||e[9]!==o||e[10]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:Eo,refetchIntervalInBackground:!1,staleTime:To,select:Cm},e[8]=i,e[9]=o,e[10]=a,e[11]=l):l=e[11],Lr(l)}function Cm(t){const e=Ss(t);return Array.isArray(e)?e.map(km):[]}function km(t){const e=t.user;return{id:Number(t.id??0),author:e?.login??"",body:String(t.body??""),createdAt:String(t.created_at??""),htmlUrl:String(t.html_url??"")}}function Po(t,e){const s=K.c(8),i=t?`${t.orgSlug}/${t.virtualMcpId}/${t.branch}`:"",r=e?.fetchEnabled??!0;let o;s[0]!==i?(o=Ut.decofile(i),s[0]=i,s[1]=o):o=s[1];let a;s[2]!==t?(a=async()=>{const c=new URLSearchParams({path:"/.decofile"}),d=await fetch(`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/preview-fetch?${c.toString()}`);if(!d.ok)throw new Error(`Failed to fetch decofile: ${d.status}`);return await d.json()},s[2]=t,s[3]=a):a=s[3];const l=!!t&&r;let h;return s[4]!==o||s[5]!==a||s[6]!==l?(h={queryKey:o,queryFn:a,enabled:l,staleTime:3e4,retry:3,retryDelay:jm},s[4]=o,s[5]=a,s[6]=l,s[7]=h):h=s[7],ki(h)}function jm(t){return Math.min(1e3*2**t,5e3)}function Do(t,e){const s=K.c(8),i=t?`${t.orgSlug}/${t.virtualMcpId}/${t.branch}`:"",r=e?.fetchEnabled??!0;let o;s[0]!==i?(o=Ut.liveMeta(i),s[0]=i,s[1]=o):o=s[1];let a;s[2]!==t?(a=async()=>{const c=new URLSearchParams({path:"/live/_meta"}),d=await fetch(`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/preview-fetch?${c.toString()}`);if(!d.ok)throw new Error(`Failed to fetch live meta: ${d.status}`);return await d.json()},s[2]=t,s[3]=a):a=s[3];const l=!!t&&r;let h;return s[4]!==o||s[5]!==a||s[6]!==l?(h={queryKey:o,queryFn:a,enabled:l,staleTime:3e5,retry:3,retryDelay:Nm},s[4]=o,s[5]=a,s[6]=l,s[7]=h):h=s[7],ki(h)}function Nm(t){return Math.min(1e3*2**t,5e3)}function Em(t){if(!t.startsWith("#")||!t.includes("@"))return null;const e=t.indexOf("@");return{moduleResolveType:t.slice(1,e),blockId:t.slice(e+1)}}function LS(t){return t.includes("@")}function ja(t){const e=t.lastIndexOf("@");return e<0||e===t.length-1?null:t.slice(e+1)}function OS(t,e){if(t===e)return!0;const s=ja(t);return s?e===s||ja(e)===s:!1}function Tc(t,e){const s=t.manifest?.blocks??{};for(const[i,r]of Object.entries(s))if(e in r)return i;return null}function Rc(t,e){const s=Tc(t,e);return s!==null&&s.includes("sections")}function Tm(t,e){const s=Tc(t,e);return s!==null&&s.includes("matchers")}function Ao(t){return!t.includes("/")}function Pc(t){try{return decodeURIComponent(t).startsWith("Preview ")}catch{return t.startsWith("Preview ")}}const Rm=["website/sections/Rendering/Lazy.tsx","website/sections/Rendering/SingleDeferred.tsx"];function $r(t){return Rm.some(e=>t.endsWith(e))}const Pm="VideoWidget";function Dm(t,e){const s=e.schema??{},i=e.manifest?.blocks??{};let r={};for(const f of Object.values(i))if(f[t]){r=f[t];break}const o={...s,...r},a=o.$defs??o.definitions??{},l=f=>{const p=f.split("/").pop()??"";return a[p]??{}},h=(f,p=new Set,m=0)=>{if(m>5)return{};if(typeof f.$ref=="string"){const g=f.$ref.split("/").pop()??"";return p.has(g)?{}:h(l(f.$ref),new Set([...p,g]),m+1)}let _={};if(f.properties&&typeof f.properties=="object"&&(_={..._,...f.properties}),Array.isArray(f.required)){const g=Array.isArray(_.__required)?_.__required:[];_.__required=[...g,...f.required]}for(const g of["allOf","anyOf","oneOf"]){const x=f[g];if(Array.isArray(x))for(const S of x)_={..._,...h(S,p,m+1)}}return _},c=(f,p=0)=>{let m=f;typeof f.$ref=="string"&&(m=l(f.$ref),(f.$ref.split("/").pop()??"")===Pm&&!m.format&&(m={...m,format:"video-uri"}));let _;{const w=m.anyOf??m.oneOf;if(Array.isArray(w)){const N=w.filter(R=>!(R.type==="null"||R.type===null)),j=R=>{if(typeof R.const=="string"||typeof R.const=="number")return R.const;if(Array.isArray(R.enum)&&R.enum.length===1&&(typeof R.enum[0]=="string"||typeof R.enum[0]=="number"))return R.enum[0]};N.length>0&&N.every(R=>j(R)!==void 0)&&(_=N.map(R=>j(R)))}}let g,x;if(m.type)g=Array.isArray(m.type)?String(m.type.find(w=>w!=="null")??m.type[0]):String(m.type);else if(m.anyOf||m.allOf||m.oneOf){const N=(m.anyOf??m.allOf??m.oneOf).filter(j=>!(j.type==="null"||j.type===null));if(N.length===0)g="null";else if(N.length===1){const j=N[0];x=j,g=j.type?Array.isArray(j.type)?String(j.type[0]):String(j.type):typeof j.$ref=="string"?"object":"string"}else{if(_)return{type:"string",title:typeof m.title=="string"?m.title:void 0,description:typeof m.description=="string"?m.description:void 0,enum:_};const j=N.filter(I=>{const E=I.properties?.__resolveType?.enum;return Array.isArray(E)&&typeof E[0]=="string"});if(j.length>0){const I=j.map(E=>{const y=E.properties?.__resolveType?.enum??[],T=String(y[0]);return{resolveType:T,title:typeof E.title=="string"?E.title:T.split("/").pop()?.replace(/\.tsx?$/,"").replace(/[-_]/g," ")??T,description:typeof E.description=="string"?E.description:void 0,schema:p+1<6?c(E,p+1):void 0}});return{type:"block-ref",title:typeof m.title=="string"?m.title:void 0,description:typeof m.description=="string"?m.description:void 0,anyOfRefs:I}}if(N.every(I=>typeof I.$ref=="string")){const I=[];for(const E of N){const C=l(E.$ref);let y,T;if(typeof C.title=="string"){const D=Em(C.title);D&&(y=D.blockId,T=D.blockId)}if(!y&&Array.isArray(C.allOf))for(const D of C.allOf){const B=((D.properties??{}).__resolveType??{}).enum;if(Array.isArray(B)&&typeof B[0]=="string"){y=B[0];break}}y||(y=E.$ref.split("/").pop()??""),I.push({resolveType:y,title:T??(typeof C.title=="string"&&!C.title.startsWith("#")?C.title:y.split("/").pop()?.replace(/\.tsx?$/,"").replace(/[-_]/g," ")??y),description:typeof C.description=="string"?C.description:void 0,schema:p+1<6?c(C,p+1):void 0})}return{type:"block-ref",title:typeof m.title=="string"?m.title:void 0,description:typeof m.description=="string"?m.description:void 0,anyOfRefs:I}}g="object"}}else typeof f.$ref=="string"&&(g="object");let S;if(p<6){const w=h(m),N=Object.entries(w).filter(([j])=>!j.startsWith("__")&&j!=="@type");if(N.length>0){S={};for(const[j,R]of N)S[j]=c(R,p+1)}}let v;if((g==="array"||m.type==="array")&&p<6){let w=m.items;w&&(typeof w.$ref=="string"&&(w=l(w.$ref)),v=c(w,p+1))}const b=w=>{const N=x?.[w];return typeof N=="string"?N:void 0},k=()=>{if("default"in f)return f.default;if("default"in m)return m.default;if(x&&"default"in x)return x.default};return{type:g??"string",title:typeof f.title=="string"?f.title:typeof m.title=="string"?m.title:b("title"),description:typeof f.description=="string"?f.description:typeof m.description=="string"?m.description:b("description"),default:k(),enum:Array.isArray(m.enum)?m.enum:_??void 0,format:typeof m.format=="string"?m.format:b("format"),properties:S,items:v,titleBy:typeof m.titleBy=="string"?m.titleBy:b("titleBy")}},d=h(o),u={};for(const[f,p]of Object.entries(d))f.startsWith("__")||f==="@type"||(u[f]=c(p,0));return Object.keys(u).length===0?null:{type:"object",title:typeof o.title=="string"?o.title:void 0,properties:u}}function Dc(t,e){const s=e.schema??{},i=e.manifest?.blocks??{};let r={};for(const c of Object.values(i))if(c[t]){r=c[t];break}const o={...s,...r},a=o.$defs??o.definitions??{},l=typeof r.$ref=="string"?a[r.$ref.split("/").pop()??""]??{}:{...s,...r},h=l.icon;return{title:typeof l.title=="string"?l.title:void 0,description:typeof l.description=="string"?l.description:void 0,icon:typeof h=="string"?h:void 0}}const $S="oklch(0.7278 0.151 289)",Am="website/matchers/always.ts",Ac="website/matchers/never.ts",Mm="website/flags/multivariate.ts",Bm="website/flags/multivariate/section.ts";function Mc(t){const e=t.split("/");return(e[e.length-1]??t).replace(/\.(tsx?|jsx?)$/,"").replace(/[-_]/g," ").replace(/\b\w/g,i=>i.toUpperCase())||t}function zS(t){return t.map(e=>`${e.resolveType}|${e.label}|${e.isHidden??!1}|${e.isSavedBlock??!1}|${e.isMultivariate??!1}|${e.isLazy??!1}`).join(`
|
|
3
3
|
`)}const Bc=["website/pages/Page.tsx","$live/pages/LivePage.tsx"],Ic=new Set(Bc),Im=new Set(["site/sections/Theme/Theme.tsx"]);function Mo(t){return!!(Im.has(t)||$r(t)||t.toLowerCase().includes("preview"))}function Lc(t){const e=t.manifest?.blocks??{};for(const s of Object.values(e))for(const i of Object.keys(s))if(Ic.has(i))return i;return Bc[0]}function wn(t){if(!t)return[];if(t.anyOfRefs?.length)return t.anyOfRefs;if(t.items)return wn(t.items);if(t.properties){const e=[];for(const s of Object.values(t.properties))e.push(...wn(s));return e}return[]}function Lm(t){const e=t.manifest?.blocks??{},s=[];for(const[i,r]of Object.entries(e))if(i.includes("sections"))for(const o of Object.keys(r)){if(Mo(o))continue;const a=Dc(o,t);s.push({resolveType:o,title:a.title??Mc(o),description:a.description,previewBlock:o,isSavedBlock:!1})}return s}function Oc(t,e){const s=[];for(const[i,r]of Object.entries(e)){if(i.includes("/")||Pc(i)||!r||typeof r!="object"||Array.isArray(r))continue;const o=r,a=o.__resolveType;typeof a=="string"&&(Ic.has(a)||typeof o.path!="string"&&(Mo(a)||Rc(t,a)&&s.push({resolveType:i,title:i,description:typeof o.name=="string"?o.name:void 0,previewBlock:i,isSavedBlock:!0})))}return s}function Om(t,e){const s=Ao(e.resolveType),i=s?{}:Dc(e.resolveType,t);return{resolveType:e.resolveType,title:e.title||i.title||Mc(e.resolveType),description:e.description??i.description,previewBlock:e.resolveType,isSavedBlock:s}}function FS(t,e){const s=Lc(t),i=Dm(s,t),r=wn(i?.properties?.sections),o=new Map,a=l=>{if(!Mo(l.resolveType)){if(Ao(l.resolveType)){Pc(l.resolveType)||o.set(l.resolveType,l);return}Rc(t,l.resolveType)&&(o.has(l.resolveType)||o.set(l.resolveType,l))}};for(const l of Lm(t))a(l);for(const l of r)a(Om(t,l));for(const l of Oc(t,e))a(l);return[...o.values()].sort((l,h)=>l.title.localeCompare(h.title))}function HS(t){const e=t.site;if(!e||typeof e!="object"||Array.isArray(e))return;const s=e.theme;if(!(!s||typeof s!="object"||Array.isArray(s)))return s}function $m(t){let e=t;e.startsWith("pages-")&&(e=e.slice(6));const s=e.lastIndexOf("-");if(s>0){const i=e.slice(s+1);/^[a-f0-9]+$/i.test(i)&&i.length>=8&&(e=e.slice(0,s))}try{return decodeURIComponent(e)}catch{return e}}const zm=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function $c(t,e){return t?Bo(t).length>0?!0:e?Io(t,e).length>0:!1:!1}function Bo(t){const e=[];for(const[s,i]of Object.entries(t))if(i&&typeof i=="object"&&!Array.isArray(i)){const r=i;typeof r.__resolveType=="string"&&zm.has(r.__resolveType)&&typeof r.path=="string"&&e.push({key:s,name:typeof r.name=="string"?r.name:$m(s),path:r.path})}return e}function zc(t,e){if(typeof e.name=="string"){const s=e.name.trim();if(s)return s}return t.replace(/[-_]/g," ").replace(/\b\w/g,s=>s.toUpperCase())}function Io(t,e){return Oc(e,t).map(s=>{const i=t[s.resolveType],r=typeof i.__resolveType=="string"?i.__resolveType:"";return{key:s.resolveType,name:s.description??zc(s.resolveType,i),resolveType:r}}).sort((s,i)=>s.name.localeCompare(i.name))}const Fm={phase:null,lifecycle:{phase:"idle"},status:{state:"running"},branch:{kind:"unknown"},suspended:!1,notFound:!1,scripts:[],activeProcesses:[],getBuffer:()=>"",hasData:()=>!1,subscribeChunks:()=>()=>{},subscribeReload:()=>()=>{}},Fc=A.createContext(Fm),Na=16384;class Hm{data="";append(e){this.data+=e,this.data.length>Na&&(this.data=this.data.slice(this.data.length-Na))}get(){return this.data}clear(){this.data=""}}const Wm=6e4,Um=1e3,Km=3e4,Vm=["lifecycle","status","tasks","scripts","branch","reload"],qm="log";function Gm({virtualMcpId:t,branch:e,enabled:s=!0,children:i}){const{org:r}=je(),[o,a]=A.useState(null),[l,h]=A.useState({phase:"idle"}),[c,d]=A.useState({state:"running"}),[u,f]=A.useState({kind:"unknown"}),[p,m]=A.useState(!1),[_,g]=A.useState(!1),[x,S]=A.useState([]),[v,b]=A.useState([]),[,k]=A.useState(0),w=A.useRef(new Map),N=A.useRef(new Set),j=A.useRef(new Set),R=A.useRef(null),I=C=>{let y=w.current.get(C);return y||(y=new Hm,w.current.set(C,y)),y};A.useEffect(()=>{if(a(null),h({phase:"idle"}),d({state:"running"}),f({kind:"unknown"}),R.current=null,m(!1),g(!1),S([]),b([]),w.current.clear(),!t||!e||!s)return;const C=`/api/${encodeURIComponent(r.slug)}/sandbox/${encodeURIComponent(t)}/${encodeURIComponent(e)}/events`;let y=!1,T=0,D=null,P=null,M=null,B=!1;const F=()=>{P||(P=setTimeout(()=>{m(!0)},Wm))},U=()=>{P&&(clearTimeout(P),P=null)},z=W=>{try{const ee=JSON.parse(W.data);a(ee),ee.kind!=="failed"&&g(!1),ee.kind==="failed"&&(B=!0,M?.close())}catch(ee){console.warn("[vm-events] bad phase payload",ee)}},O=()=>{g(!0),a(null),h({phase:"idle"}),d({state:"running"}),f({kind:"unknown"}),S([]),b([]),w.current.clear()},q=W=>{try{const ee=JSON.parse(W.data);if(typeof ee.data!="string")return;const $=ee.data.replace(/\r?\n/g,`\r
|
|
4
4
|
`);I(ee.source).append($);for(const L of N.current)try{L(ee.source,$)}catch{}k(L=>L+1)}catch{}},V=W=>{const ee=W.type;try{const $=JSON.parse(W.data);switch(ee){case"lifecycle":{const L=$;h(L.state);const Y=L.state.phase==="running"?L.state.port:null,X=R.current;if(R.current=Y,X!==null&&Y!==null&&X!==Y)for(const H of j.current)try{H()}catch{}return}case"status":d($);return;case"tasks":{const Y=$.active.map(X=>X.logName??"").filter(Boolean);b(Y);return}case"scripts":S($.scripts);return;case"branch":{const L=$.meta;f(L);return}case"reload":for(const L of j.current)try{L()}catch{}return}}catch{}};function Q(){if(!(y||B)){M=new EventSource(C),M.onopen=()=>{T=0,U(),m(!1)},M.onerror=()=>{M?.readyState===EventSource.CLOSED&&(B||(F(),G()))},M.addEventListener("phase",z),M.addEventListener("gone",O),M.addEventListener(qm,q);for(const W of Vm)M.addEventListener(W,V)}}function G(){if(y||D||B)return;const W=Math.min(Um*2**T,Km);T++,D=setTimeout(()=>{D=null,!y&&(M?.close(),Q())},W)}return Q(),()=>{y=!0,M?.close(),D&&clearTimeout(D),U()}},[t,e,r.slug,s]);const E={phase:o,lifecycle:l,status:c,branch:u,suspended:p,notFound:_,scripts:x,activeProcesses:v,getBuffer:C=>w.current.get(C)?.get()??"",hasData:C=>(w.current.get(C)?.get().length??0)>0,subscribeChunks:C=>(N.current.add(C),()=>{N.current.delete(C)}),subscribeReload:C=>(j.current.add(C),()=>{j.current.delete(C)})};return n.jsx(Fc,{value:E,children:i})}function ns(){return A.use(Fc)}function Ym(t){const{subscribeChunks:e}=ns(),s=A.useRef(t);s.current=t,A.useEffect(()=>e((o,a)=>{s.current?.(o,a)}),[e])}function Xm(t){const{subscribeReload:e}=ns(),s=A.useRef(t);s.current=t,A.useEffect(()=>e(()=>{s.current?.()}),[e])}const Jm={settings:mu,automations:fu,preview:mo,content:Dr,git:Ps};function Ea(t){const e=Ar(t);if(e.type==="icon"){const s=Mr(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function Zr(t){if(t.kind==="system")return{kind:"component",Component:Jm[t.tabId]};const e=Ea(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=Ea(s.icon);return i||{kind:"fallback"}}function Zm(t){const{org:e}=je(),s=Xe({connectionId:vs,orgId:e.id,orgSlug:e.slug}),i=hc(),r=A.useSyncExternalStore(i.threads.subscribe,i.threads.get),o=t?r.find(l=>l.id===t)??null:null,{data:a}=Td({queryKey:Ut.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 Hc(t){const e=K.c(28),s=Vt();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const r=co(i),o=At(t.virtualMcpId),a=Zm(t.taskId),{org:l}=je(),{currentBranch:h}=rs();let c;e[1]!==o?(c=Bs(o),e[1]=o,e[2]=c):c=e[2];const d=c,u=d?.connectionId??"",f=d?.owner??"",p=d?.name??"",m=d?h:null;let _;e[3]!==l.id||e[4]!==l.slug||e[5]!==u||e[6]!==f||e[7]!==p||e[8]!==m?(_={orgId:l.id,orgSlug:l.slug,connectionId:u,owner:f,repo:p,branch:m},e[3]=l.id,e[4]=l.slug,e[5]=u,e[6]=f,e[7]=p,e[8]=m,e[9]=_):_=e[9];const g=Ro(_),x=g.data?.state==="open",S=o?.metadata?.ui??null,v=S?.layout??null,b=v?.tabs??[],k=S?.pinnedViews??[],w=a?.expanded_tools??[],N=ec(o),j=o?.metadata;let R;e[10]!==j?(R=Ei(j),e[10]=j,e[11]=R):R=e[11];const I=R;let E;e[12]===Symbol.for("react.memo_cache_sentinel")?(E={includeVirtual:!0},e[12]=E):E=e[12];const C=Ir(E),T=ns().lifecycle.phase==="running";let D;e[13]!==h||e[14]!==o||e[15]!==I||e[16]!==l.slug?(D=I&&o?.id&&h?{orgSlug:l.slug,virtualMcpId:o.id,branch:h}:null,e[13]=h,e[14]=o,e[15]=I,e[16]=l.slug,e[17]=D):D=e[17];const P=D;let M;e[18]!==T?(M={fetchEnabled:T},e[18]=T,e[19]=M):M=e[19];const{data:B}=Po(P,M);let F;e[20]!==T?(F={fetchEnabled:T},e[20]=T,e[21]=F):F=e[21];const{data:U}=Do(P,F),z=$c(B,U),{activeTab:O,mainOpen:q}=Tu({mainParam:r.main,metadata:v?{defaultMainView:v.defaultMainView??null,tabs:b.map(ep)}:null}),V=N&&(x||g.isPending&&O==="git"),Q=v?{defaultMainView:v.defaultMainView??null,tabs:b.map(Qm)}:null,G=O==="git"&&!V&&!g.isPending?xn(Q):O==="content"&&!z?xn(Q):O,W=O==="git"&&!V&&!g.isPending?!1:q,ee=cc(G),$=[];I&&($.push({id:"preview",title:"Preview"}),z&&$.push({id:"content",title:"Content"})),V&&$.push({id:"git",title:"Review changes"}),$.push({id:"settings",title:"Settings"}),$.push({id:"automations",title:"Automations"});const L=new Map;for(const re of w){const ce=ga(re.appId,re.toolName);L.set(ce,{id:ce,title:re.toolName,appId:re.appId,iconKey:re.toolName})}for(const re of k){const ce=ga(re.connectionId,re.toolName);L.set(ce,{id:ce,title:re.label||re.toolName,appId:re.connectionId,iconKey:re.toolName,iconUrl:re.icon??null})}let Y;e[22]!==C?(Y=re=>({id:re.id,title:re.title,kind:"agent",icon:Zr({tabId:re.id,kind:"agent",appId:re.view.appId,connections:C})}),e[22]=C,e[23]=Y):Y=e[23];const X=[...b.map(Y),...Array.from(L.values()).map(re=>({id:re.id,title:re.title,kind:"expanded",icon:Zr({tabId:re.iconKey,kind:"expanded",appId:re.appId,iconUrl:re.iconUrl,connections:C})})),...$.map(re=>({id:re.id,title:re.title,kind:"system",icon:Zr({tabId:re.id,kind:"system",connections:C})}))];let H;return e[24]!==G||e[25]!==W||e[26]!==s?(H=re=>{const ce=Ru({clickedId:re,activeTab:G,mainOpen:W});s({to:".",search:de=>({...de,main:ce}),replace:!0})},e[24]=G,e[25]=W,e[26]=s,e[27]=H):H=e[27],{activeTab:G,mainOpen:W,setActiveTab:H,systemTabs:$,layoutTabs:b,expandedTools:w,automationTabParsed:ee,tabs:X}}function Qm(t){return{id:t.id}}function ep(t){return{id:t.id}}function Wc(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.
|
|
5
5
|
<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 tp(t){const e=K.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,p=d===void 0?!1:d,[m,_]=A.useState(!1),[g,x]=A.useState("icons"),[S,v]=A.useState(""),[b,k]=A.useState("blue");let w;e[0]!==s?(w=Ar(s),e[0]=s,e[1]=w):w=e[1];const N=w,j=N.type==="icon"||N.type==="url"&&N.color?N.color:b;let R;e[2]!==i||e[3]!==j?(R=Ee=>{i(Jr(Ee,j))},e[2]=i,e[3]=j,e[4]=R):R=e[4];const I=R;let E;e[5]!==i||e[6]!==r||e[7]!==N.name||e[8]!==N.type||e[9]!==N.url?(E=Ee=>{k(Ee),r?.(Ee),N.type==="icon"?i(Jr(N.name,Ee)):N.type==="url"&&i(fa(N.url,Ee))},e[5]=i,e[6]=r,e[7]=N.name,e[8]=N.type,e[9]=N.url,e[10]=E):E=e[10];const C=E;let y;e[11]!==i||e[12]!==j?(y=Ee=>{i(fa(Ee,j)),_(!1)},e[11]=i,e[12]=j,e[13]=y):y=e[13];const T=y;let D;e[14]!==i||e[15]!==j?(D=()=>{const Ee=go(),mt=Ee[Math.floor(Math.random()*Ee.length)];i(Jr(mt,j))},e[14]=i,e[15]=j,e[16]=D):D=e[16];const P=D;let M,B,F,U,z,O,q,V;if(e[17]!==l||e[18]!==p||e[19]!==m||e[20]!==u){const Ee={xs:"rounded-md",sm:"rounded-lg","sm+":"rounded-xl",md:"rounded-xl",lg:"rounded-2xl",xl:"rounded-2xl"};B=Ls,O=p?!1:m,q=_,M=Os,z=!0,V="button",F=p,U=ie("relative group overflow-hidden",p?"cursor-default opacity-50":"cursor-pointer",Ee[u],l),e[17]=l,e[18]=p,e[19]=m,e[20]=u,e[21]=M,e[22]=B,e[23]=F,e[24]=U,e[25]=z,e[26]=O,e[27]=q,e[28]=V}else M=e[21],B=e[22],F=e[23],U=e[24],z=e[25],O=e[26],q=e[27],V=e[28];let Q;e[29]!==h||e[30]!==o||e[31]!==u||e[32]!==s?(Q=n.jsx(ma,{icon:s,name:o,size:u,className:h}),e[29]=h,e[30]=o,e[31]=u,e[32]=s,e[33]=Q):Q=e[33];let G;e[34]!==p||e[35]!==f?(G=f&&!p&&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(Dr,{size:16,className:"text-white"})}),e[34]=p,e[35]=f,e[36]=G):G=e[36];let W;e[37]!==F||e[38]!==U||e[39]!==Q||e[40]!==G||e[41]!==V?(W=n.jsxs("button",{type:V,disabled:F,className:U,children:[Q,G]}),e[37]=F,e[38]=U,e[39]=Q,e[40]=G,e[41]=V,e[42]=W):W=e[42];let ee;e[43]!==M||e[44]!==z||e[45]!==W?(ee=n.jsx(M,{asChild:z,children:W}),e[43]=M,e[44]=z,e[45]=W,e[46]=ee):ee=e[46];let $;e[47]!==o||e[48]!==s?($=n.jsx("div",{className:"flex items-center justify-center py-4",children:n.jsx(ma,{icon:s,name:o,size:"xl"})}),e[47]=o,e[48]=s,e[49]=$):$=e[49];let L;e[50]===Symbol.for("react.memo_cache_sentinel")?(L=()=>x("icons"),e[50]=L):L=e[50];const Y=g==="icons"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let X;e[51]!==Y?(X=ie("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",Y),e[51]=Y,e[52]=X):X=e[52];let H;e[53]!==X?(H=n.jsx("button",{type:"button",onClick:L,className:X,children:"Icons"}),e[53]=X,e[54]=H):H=e[54];let ne;e[55]===Symbol.for("react.memo_cache_sentinel")?(ne=()=>x("upload"),e[55]=ne):ne=e[55];const re=g==="upload"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let ce;e[56]!==re?(ce=ie("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",re),e[56]=re,e[57]=ce):ce=e[57];let de;e[58]!==ce?(de=n.jsx("button",{type:"button",onClick:ne,className:ce,children:"Upload"}),e[58]=ce,e[59]=de):de=e[59];let me;e[60]===Symbol.for("react.memo_cache_sentinel")?(me=n.jsx("div",{className:"flex-1"}),e[60]=me):me=e[60];let le;e[61]!==H||e[62]!==de?(le=n.jsxs("div",{className:"flex items-center border-b border-border px-3",children:[H,de,me]}),e[61]=H,e[62]=de,e[63]=le):le=e[63];let ve;e[64]!==C||e[65]!==P||e[66]!==I||e[67]!==T||e[68]!==N.name||e[69]!==N.type||e[70]!==S||e[71]!==j||e[72]!==g?(ve=g==="icons"?n.jsx(np,{search:S,onSearchChange:v,selectedColor:j,onColorChange:C,onSelectIcon:I,onRandom:P,currentIconName:N.type==="icon"?N.name:null}):n.jsx(op,{onUpload:T}),e[64]=C,e[65]=P,e[66]=I,e[67]=T,e[68]=N.name,e[69]=N.type,e[70]=S,e[71]=j,e[72]=g,e[73]=ve):ve=e[73];let xe;e[74]!==$||e[75]!==le||e[76]!==ve?(xe=n.jsx($s,{align:"start",className:"w-80 p-0",onOpenAutoFocus:sp,children:n.jsxs("div",{className:"flex flex-col",children:[$,le,ve]})}),e[74]=$,e[75]=le,e[76]=ve,e[77]=xe):xe=e[77];let Ne;return e[78]!==B||e[79]!==O||e[80]!==q||e[81]!==ee||e[82]!==xe?(Ne=n.jsxs(B,{open:O,onOpenChange:q,children:[ee,xe]}),e[78]=B,e[79]=O,e[80]=q,e[81]=ee,e[82]=xe,e[83]=Ne):Ne=e[83],Ne}function sp(t){return t.preventDefault()}function ip(t){const e=K.c(27),{selectedColor:s,onColorChange:i}=t,[r,o]=A.useState(!1);let a,l,h,c,d,u,f;if(e[0]!==r||e[1]!==s){const S=ic(s);l=Ls,u=r,f=o,a=Os,d=!0,h="button",c=ie("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 p;e[9]!==h||e[10]!==c?(p=n.jsx("button",{type:h,className:c,title:"Change color"}),e[9]=h,e[10]=c,e[11]=p):p=e[11];let m;e[12]!==a||e[13]!==d||e[14]!==p?(m=n.jsx(a,{asChild:d,children:p}),e[12]=a,e[13]=d,e[14]=p,e[15]=m):m=e[15];let _;e[16]!==i||e[17]!==s?(_=_u.map(S=>n.jsx("button",{type:"button",onClick:()=>{i(S.name),o(!1)},className:ie("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($s,{align:"start",side:"right",sideOffset:8,className:"w-auto p-2",onOpenAutoFocus:rp,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]!==m||e[25]!==g?(x=n.jsxs(l,{open:u,onOpenChange:f,children:[m,g]}),e[21]=l,e[22]=u,e[23]=f,e[24]=m,e[25]=g,e[26]=x):x=e[26],x}function rp(t){return t.preventDefault()}function np(t){const e=K.c(44),{search:s,onSearchChange:i,selectedColor:r,onColorChange:o,onSelectIcon:a,onRandom:l,currentIconName:h}=t;let c,d,u,f,p,m,_;if(e[0]!==h||e[1]!==o||e[2]!==l||e[3]!==i||e[4]!==a||e[5]!==s||e[6]!==r){const b=go(),k=ic(r);d=s.trim()?b.filter(C=>{const y=gn(C),T=s.toLowerCase();return y.includes(T)||C.toLowerCase().includes(T)}):b,m="flex flex-col";let w;e[14]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(gc,{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 N;e[15]!==i?(N=C=>i(C.target.value),e[15]=i,e[16]=N):N=e[16];let j;e[17]!==s||e[18]!==N?(j=n.jsxs("div",{className:"relative flex-1",children:[w,n.jsx(Ye,{value:s,onChange:N,placeholder:"Filter...",className:"h-8 text-xs pl-7"})]}),e[17]=s,e[18]=N,e[19]=j):j=e[19];let R;e[20]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(pu,{size:14,className:"text-muted-foreground"}),e[20]=R):R=e[20];let I;e[21]!==l?(I=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:R}),e[21]=l,e[22]=I):I=e[22];let E;e[23]!==o||e[24]!==r?(E=n.jsx(ip,{selectedColor:r,onColorChange:o}),e[23]=o,e[24]=r,e[25]=E):E=e[25],e[26]!==I||e[27]!==E||e[28]!==j?(_=n.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[j,I,E]}),e[26]=I,e[27]=E,e[28]=j,e[29]=_):_=e[29],c=So,p="h-56",u="grid grid-cols-9 gap-0.5 px-2 pb-2",f=d.map(C=>{const y=Mr(C);return y?n.jsx("button",{type:"button",onClick:()=>a(C),className:ie("h-8 w-8 flex items-center justify-center rounded-md transition-colors cursor-pointer",h===C?ie(k.bg,k.text):ie(k.text,"hover:bg-accent")),title:C,children:n.jsx(y,{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]=p,e[12]=m,e[13]=_}else c=e[7],d=e[8],u=e[9],f=e[10],p=e[11],m=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]!==p||e[37]!==g||e[38]!==x?(S=n.jsxs(c,{className:p,children:[g,x]}),e[35]=c,e[36]=p,e[37]=g,e[38]=x,e[39]=S):S=e[39];let v;return e[40]!==m||e[41]!==_||e[42]!==S?(v=n.jsxs("div",{className:m,children:[_,S]}),e[40]=m,e[41]=_,e[42]=S,e[43]=v):v=e[43],v}function op(t){const e=K.c(27),{onUpload:s}=t,i=A.useRef(null);let r;e[0]!==s?(r=w=>{const N=w.target.files?.[0];if(!N)return;if(N.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(N)},e[0]=s,e[1]=r):r=e[1];const o=r,[a,l]=A.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(Zu,{size:20}),n.jsx("span",{className:"text-xs",children:"Click to upload an image (max 2MB)"})]}),e[8]=f):f=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=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]=p):p=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=w=>l(w.target.value),e[10]=m):m=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(Ye,{value:a,onChange:m,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(te,{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 k;return e[24]!==b||e[25]!==d?(k=n.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[d,f,p,b]}),e[24]=b,e[25]=d,e[26]=k):k=e[26],k}function ap(t){const e=K.c(5),{value:s}=t;let i;if(e[0]!==s){i=Symbol.for("react.early_return_sentinel");e:{const o=Ar(s);if(o.type==="icon"){const a=Mr(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(cu,{size:16,className:"text-muted-foreground"}),e[4]=r):r=e[4],r}function lp(t){const e=K.c(66),{value:s,onChange:i,className:r,disabled:o}=t,[a,l]=A.useState(!1),[h,c]=A.useState("");let d;e[0]!==s?(d=Ar(s),e[0]=s,e[1]=d):d=e[1];const u=d,f=u.type==="icon"?u.name:null;let p,m,_,g,x,S,v,b,k,w,N,j,R,I,E;if(e[2]!==r||e[3]!==f||e[4]!==o||e[5]!==i||e[6]!==a||e[7]!==h||e[8]!==s){const B=go();g=h.trim()?B.filter(Q=>{const G=h.toLowerCase();return gn(Q).includes(G)||Q.toLowerCase().includes(G)}):B,_=Ls,x=o?!1:a,S=l;const F=o?"cursor-default opacity-50":"cursor-pointer hover:bg-accent";let U;e[24]!==r||e[25]!==F?(U=ie("size-7 shrink-0 rounded-md transition-colors flex items-center justify-center",F,r),e[24]=r,e[25]=F,e[26]=U):U=e[26];let z;e[27]!==s?(z=n.jsx(ap,{value:s}),e[27]=s,e[28]=z):z=e[28],e[29]!==o||e[30]!==U||e[31]!==z?(v=n.jsx(Os,{asChild:!0,children:n.jsx("button",{type:"button",disabled:o,className:U,children:z})}),e[29]=o,e[30]=U,e[31]=z,e[32]=v):v=e[32],m=$s,R="start",I="w-64 p-0",E=cp,N="flex flex-col";let O;e[33]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(gc,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[33]=O):O=e[33];let q;e[34]===Symbol.for("react.memo_cache_sentinel")?(q=Q=>c(Q.target.value),e[34]=q):q=e[34],e[35]!==h?(j=n.jsx("div",{className:"px-2 py-2",children:n.jsxs("div",{className:"relative",children:[O,n.jsx(Ye,{value:h,onChange:q,placeholder:"Filter...",className:"h-7 text-xs pl-7"})]})}),e[35]=h,e[36]=j):j=e[36],p=So,w="h-48",b="grid grid-cols-8 gap-0.5 px-2 pb-2";let V;e[37]!==f||e[38]!==i?(V=Q=>{const G=Mr(Q);return G?n.jsx("button",{type:"button",onClick:()=>{i(`icon://${Q}`),l(!1)},className:ie("h-7 w-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",f===Q?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),title:gn(Q),children:n.jsx(G,{size:16})},Q):null},e[37]=f,e[38]=i,e[39]=V):V=e[39],k=g.map(V),e[2]=r,e[3]=f,e[4]=o,e[5]=i,e[6]=a,e[7]=h,e[8]=s,e[9]=p,e[10]=m,e[11]=_,e[12]=g,e[13]=x,e[14]=S,e[15]=v,e[16]=b,e[17]=k,e[18]=w,e[19]=N,e[20]=j,e[21]=R,e[22]=I,e[23]=E}else p=e[9],m=e[10],_=e[11],g=e[12],x=e[13],S=e[14],v=e[15],b=e[16],k=e[17],w=e[18],N=e[19],j=e[20],R=e[21],I=e[22],E=e[23];let C;e[40]!==b||e[41]!==k?(C=n.jsx("div",{className:b,children:k}),e[40]=b,e[41]=k,e[42]=C):C=e[42];let y;e[43]!==g.length?(y=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]=y):y=e[44];let T;e[45]!==p||e[46]!==C||e[47]!==y||e[48]!==w?(T=n.jsxs(p,{className:w,children:[C,y]}),e[45]=p,e[46]=C,e[47]=y,e[48]=w,e[49]=T):T=e[49];let D;e[50]!==T||e[51]!==N||e[52]!==j?(D=n.jsxs("div",{className:N,children:[j,T]}),e[50]=T,e[51]=N,e[52]=j,e[53]=D):D=e[53];let P;e[54]!==m||e[55]!==D||e[56]!==R||e[57]!==I||e[58]!==E?(P=n.jsx(m,{align:R,className:I,onOpenAutoFocus:E,children:D}),e[54]=m,e[55]=D,e[56]=R,e[57]=I,e[58]=E,e[59]=P):P=e[59];let M;return e[60]!==_||e[61]!==x||e[62]!==S||e[63]!==v||e[64]!==P?(M=n.jsxs(_,{open:x,onOpenChange:S,children:[v,P]}),e[60]=_,e[61]=x,e[62]=S,e[63]=v,e[64]=P,e[65]=M):M=e[65],M}function cp(t){return t.preventDefault()}function er(){const t=K.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(ge,{className:"animate-spin text-muted-foreground",size:24})}),t[0]=e):e=t[0],e}function Qr(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(ui,{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 hp(t){const e=K.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=ie("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 p;e[12]!==u||e[13]!==f?(p=n.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[u,f]}),e[12]=u,e[13]=f,e[14]=p):p=e[14];let m;e[15]!==o||e[16]!==i||e[17]!==r?(m=n.jsx(vc,{checked:i,onCheckedChange:r,disabled:o,className:"mt-0.5"}),e[15]=o,e[16]=i,e[17]=r,e[18]=m):m=e[18];let _;return e[19]!==h||e[20]!==p||e[21]!==m?(_=n.jsxs("label",{className:h,children:[p,m]}),e[19]=h,e[20]=p,e[21]=m,e[22]=_):_=e[22],_}function Lo(t){const e=K.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(dp);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(hp,{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 dp(t){return t.id}function up(t){const e=K.c(13),{connectionId:s,selections:i,onToggle:r,disabled:o}=t,{org:a}=je();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=Xe(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:d}=Uu(c);let u;e[6]!==d.tools?(u=d.tools.map(fp),e[6]=d.tools,e[7]=u):u=e[7];const f=u;let p;return e[8]!==o||e[9]!==f||e[10]!==r||e[11]!==i?(p=n.jsx(Lo,{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]=p):p=e[12],p}function fp(t){return{id:t.name,name:t.name,description:t.description,tags:n.jsx(Gu,{annotations:t.annotations,_meta:t._meta})}}function mp(t){const e=K.c(13),{connectionId:s,selections:i,onToggle:r,disabled:o}=t,{org:a}=je();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=Xe(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:d}=Vu(c);let u;e[6]!==d.resources?(u=d.resources.map(pp),e[6]=d.resources,e[7]=u):u=e[7];const f=u;let p;return e[8]!==o||e[9]!==f||e[10]!==r||e[11]!==i?(p=n.jsx(Lo,{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]=p):p=e[12],p}function pp(t){return{id:t.name||t.uri,name:t.name||t.uri,description:t.description}}function _p(t){const e=K.c(13),{connectionId:s,selections:i,onToggle:r,disabled:o}=t,{org:a}=je();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=Xe(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:d}=tf(c);let u;e[6]!==d.prompts?(u=d.prompts.map(gp),e[6]=d.prompts,e[7]=u):u=e[7];const f=u;let p;return e[8]!==o||e[9]!==f||e[10]!==r||e[11]!==i?(p=n.jsx(Lo,{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]=p):p=e[12],p}function gp(t){return{id:t.name,name:t.name,description:t.description}}function vp(t){const e=K.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,p=o[r],m=i==="tools"?p?.tools===null:i==="resources"?p?.resources===null:p?.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(gs,{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 k;e[16]!==x||e[17]!==b?(k=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]=k):k=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 N;e[20]!==f?(N=M=>f(M),e[20]=f,e[21]=N):N=e[21];let j;e[22]!==i||e[23]!==N?(j=n.jsx(ef,{tabs:w,activeTab:i,onTabChange:N}),e[22]=i,e[23]=N,e[24]=j):j=e[24];const R=m?"Deselect all":"Select all";let I;e[25]!==g||e[26]!==R?(I=n.jsx("button",{type:"button",onClick:g,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:R}),e[25]=g,e[26]=R,e[27]=I):I=e[27];let E;e[28]!==I||e[29]!==j?(E=n.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-t border-border shrink-0",children:[j,I]}),e[28]=I,e[29]=j,e[30]=E):E=e[30];let C;e[31]!==i||e[32]!==o||e[33]!==r||e[34]!==a?(C=i==="tools"&&n.jsx($t,{fallback:Qr("Tools not supported by this server"),children:n.jsx(A.Suspense,{fallback:n.jsx(er,{}),children:n.jsx(up,{connectionId:r,selections:o[r]?o[r].tools:[],onToggle:(M,B)=>a(r,M,B)})})}),e[31]=i,e[32]=o,e[33]=r,e[34]=a,e[35]=C):C=e[35];let y;e[36]!==i||e[37]!==o||e[38]!==r||e[39]!==l?(y=i==="resources"&&n.jsx($t,{fallback:Qr("Resources not supported by this server"),children:n.jsx(A.Suspense,{fallback:n.jsx(er,{}),children:n.jsx(mp,{connectionId:r,selections:o[r]?o[r].resources:[],onToggle:(M,B)=>l(r,M,B)})})}),e[36]=i,e[37]=o,e[38]=r,e[39]=l,e[40]=y):y=e[40];let T;e[41]!==i||e[42]!==o||e[43]!==r||e[44]!==h?(T=i==="prompts"&&n.jsx($t,{fallback:Qr("Prompts not supported by this server"),children:n.jsx(A.Suspense,{fallback:n.jsx(er,{}),children:n.jsx(_p,{connectionId:r,selections:o[r]?o[r].prompts:[],onToggle:(M,B)=>h(r,M,B)})})}),e[41]=i,e[42]=o,e[43]=r,e[44]=h,e[45]=T):T=e[45];let D;e[46]!==C||e[47]!==y||e[48]!==T?(D=n.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[C,y,T]}),e[46]=C,e[47]=y,e[48]=T,e[49]=D):D=e[49];let P;return e[50]!==E||e[51]!==D||e[52]!==k?(P=n.jsxs(n.Fragment,{children:[k,E,D]}),e[50]=E,e[51]=D,e[52]=k,e[53]=P):P=e[53],P}function xp(t){const e=K.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=fc(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(gu,{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(te,{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 bp(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 Ta(t){return Object.entries(t).map(([e,s])=>({connection_id:e,selected_tools:s.tools,selected_resources:s.resources,selected_prompts:s.prompts}))}function yp(t,e){return e.type==="SET_ACTIVE_TAB"?{...t,activeTab:e.payload}:t}function Sp(t){const e=K.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]=A.useReducer(yp,h),u=xo(r??"");let f;e[1]!==a?(f=a??[],e[1]=a,e[2]=f):f=e[2];let p;e[3]!==f?(p=bp(f),e[3]=f,e[4]=p):p=e[4];const m=p;let _;e[5]!==o||e[6]!==m?(_=(O,q,V,Q)=>{const G=m[O]?.[q];let W;G===null?W=Q.filter($=>$!==V):G?.includes(V)?W=G.filter($=>$!==V):(W=[...G??[],V],W.length===Q.length&&(W=null));const ee={...m};ee[O]?ee[O]={...ee[O]}:ee[O]={tools:null,resources:null,prompts:null},ee[O][q]=W,o.setValue("connections",Ta(ee),{shouldDirty:!0,shouldTouch:!0})},e[5]=o,e[6]=m,e[7]=_):_=e[7];const g=_;let x;e[8]!==o||e[9]!==m?(x=(O,q)=>{const Q=m[O]?.[q]===null?[]:null,G={...m};G[O]?G[O]={...G[O]}:G[O]={tools:null,resources:null,prompts:null},G[O][q]=Q,o.setValue("connections",Ta(G),{shouldDirty:!0,shouldTouch:!0})},e[8]=o,e[9]=m,e[10]=x):x=e[10];const S=x;let v;e[11]!==g?(v=(O,q,V)=>g(O,"tools",q,V),e[11]=g,e[12]=v):v=e[12];const b=v;let k;e[13]!==g?(k=(O,q,V)=>g(O,"resources",q,V),e[13]=g,e[14]=k):k=e[14];const w=k;let N;e[15]!==g?(N=(O,q,V)=>g(O,"prompts",q,V),e[15]=g,e[16]=N):N=e[16];const j=N;let R;e[17]!==S?(R=O=>S(O,"tools"),e[17]=S,e[18]=R):R=e[18];const I=R;let E;e[19]!==S?(E=O=>S(O,"resources"),e[19]=S,e[20]=E):E=e[20];const C=E;let y;e[21]!==S?(y=O=>S(O,"prompts"),e[21]=S,e[22]=y):y=e[22];const T=y;if(!r||!u)return null;let D;e[23]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx(er,{}),e[23]=D):D=e[23];let P;e[24]===Symbol.for("react.memo_cache_sentinel")?(P=O=>d({type:"SET_ACTIVE_TAB",payload:O}),e[24]=P):P=e[24];let M;e[25]!==u||e[26]!==c.activeTab||e[27]!==m||e[28]!==r||e[29]!==T||e[30]!==C||e[31]!==I||e[32]!==j||e[33]!==w||e[34]!==b?(M=n.jsx(vp,{currentConnection:u,activeTab:c.activeTab,selectedId:r,formData:m,toggleTool:b,toggleResource:w,togglePrompt:j,toggleAllTools:I,toggleAllResources:C,toggleAllPrompts:T,onTabChange:P},r),e[25]=u,e[26]=c.activeTab,e[27]=m,e[28]=r,e[29]=T,e[30]=C,e[31]=I,e[32]=j,e[33]=w,e[34]=b,e[35]=M):M=e[35];let B;e[36]!==l||e[37]!==r||e[38]!==M?(B=n.jsx(A.Suspense,{fallback:D,children:n.jsx(xp,{connectionId:r,onAuthenticate:l,children:M})}),e[36]=l,e[37]=r,e[38]=M,e[39]=B):B=e[39];let F;e[40]!==i?(F=n.jsx(Is,{className:"px-6 py-4 border-t border-border shrink-0",children:n.jsx(te,{variant:"outline",onClick:()=>i(!1),children:"Done"})}),e[40]=i,e[41]=F):F=e[41];let U;e[42]!==B||e[43]!==F?(U=n.jsxs(qt,{className:"sm:max-w-2xl h-[75vh] max-h-[75vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[B,F]}),e[42]=B,e[43]=F,e[44]=U):U=e[44];let z;return e[45]!==i||e[46]!==s||e[47]!==U?(z=n.jsx(Gt,{open:s,onOpenChange:i,children:U}),e[45]=i,e[46]=s,e[47]=U,e[48]=z):z=e[48],z}const en={tools:null,resources:null,prompts:null},wp=Rd.pick({status:!0,title:!0,description:!0,icon:!0,metadata:!0,connections:!0});function Cp(t){const s=new TextEncoder().encode(t),i=Array.from(s,r=>String.fromCharCode(r)).join("");return btoa(i)}function kp(t){const e=K.c(11),{url:s,agentId:i}=t,[r,o]=A.useState(!1);let a;e[0]!==i||e[1]!==s?(a=async()=>{Me("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(Ri,{size:20,className:"text-green-600"}):n.jsx(ss,{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(te,{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 jp(t){const e=K.c(8),{url:s,serverName:i,agentId:r}=t;let o;e[0]!==r||e[1]!==i||e[2]!==s?(o=()=>{Me("agent_connect_action",{agent_id:r,action:"install_cursor"});const d=mc(i),f=Cp(JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Cursor"}},null,2)),p=`cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(d)}&config=${encodeURIComponent(f)}`;window.open(p,"_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(te,{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 Np(t){const e=K.c(12),{url:s,serverName:i,agentId:r}=t,[o,a]=A.useState(!1);let l;e[0]!==r||e[1]!==i||e[2]!==s?(l=async()=>{Me("agent_connect_action",{agent_id:r,action:"install_claude_code"});const p=mc(i),_=JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Claude Code"}},null,2),g=`claude mcp add-json "${p}" '${_.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(Ri,{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(te,{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 Ep({virtualMcp:t}){const{org:e}=je(),s=Xe({connectionId:vs,orgId:e.id,orgSlug:e.slug}),[i,r]=A.useState(null),[o,a]=A.useState(!1),[l,h]=A.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(_),Me("agent_typegen_key_generated",{agent_id:c})}catch{Me("agent_typegen_key_failed",{agent_id:c}),ae.error("Failed to generate API key")}finally{a(!1)}},p=async()=>{Me("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(te,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:f,disabled:o,children:[o?n.jsx(ge,{size:14,className:"animate-spin"}):n.jsx(xc,{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(te,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:p,children:l?n.jsx(Ri,{size:12,className:"text-green-600"}):n.jsx(ss,{size:12})})]})}),n.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Runtime variables"}),n.jsx(Tp,{apiKey:i,agentId:c})]})}function Tp(t){const e=K.c(21),{apiKey:s,agentId:i}=t,[r,o]=A.useState(!1),a=window.location.origin,l=s?`MESH_API_KEY=${s}`:"MESH_API_KEY=<api-key>",h=`MESH_BASE_URL=${a}`,c=`${l}
|
|
@@ -285,9 +285,9 @@ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){t
|
|
|
285
285
|
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(t){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Xo&&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=cl(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=Yo(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,-hn),hn),e/=hn,e/Math.abs(e)+Math.round(e*(R1-1)))}shouldForceSelection(t){return kr?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(),P1)}_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&&!(kr&&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<D1&&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=S1(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,p=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&&(p+=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&&(p+=v-1,h+=v-1),h++,x++}}h++;let m=l+c-d+f,_=Math.min(this._bufferService.cols,h-l+d+u-f-p);if(!(!e&&a.slice(l,h).trim()==="")){if(s&&m===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;m-=S,_+=S}}}if(i&&m+_===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:m,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=cl(s,this._bufferService.cols)}};Zn=Le([oe(3,nt),oe(4,Cs),oe(5,Ho),oe(6,ot),oe(7,Xt),oe(8,Yt)],Zn);var hl=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={}}},dl=class{constructor(){this._color=new hl,this._css=new hl}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()}},He=Object.freeze((()=>{let t=[Ae.toColor("#2e3436"),Ae.toColor("#cc0000"),Ae.toColor("#4e9a06"),Ae.toColor("#c4a000"),Ae.toColor("#3465a4"),Ae.toColor("#75507b"),Ae.toColor("#06989a"),Ae.toColor("#d3d7cf"),Ae.toColor("#555753"),Ae.toColor("#ef2929"),Ae.toColor("#8ae234"),Ae.toColor("#fce94f"),Ae.toColor("#729fcf"),Ae.toColor("#ad7fa8"),Ae.toColor("#34e2e2"),Ae.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:Fe.toCss(i,r,o),rgba:Fe.toRgba(i,r,o)})}for(let s=0;s<24;s++){let i=8+s*10;t.push({css:Fe.toCss(i,i,i),rgba:Fe.toRgba(i,i,i)})}return t})()),as=Ae.toColor("#ffffff"),li=Ae.toColor("#000000"),ul=Ae.toColor("#ffffff"),fl=li,ei={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},B1=as,Qn=class extends _e{constructor(t){super(),this._optionsService=t,this._contrastCache=new dl,this._halfContrastCache=new dl,this._onChangeColors=this._register(new se),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:as,background:li,cursor:ul,cursorAccent:fl,selectionForeground:void 0,selectionBackgroundTransparent:ei,selectionBackgroundOpaque:ke.blend(li,ei),selectionInactiveBackgroundTransparent:ei,selectionInactiveBackgroundOpaque:ke.blend(li,ei),scrollbarSliderBackground:ke.opacity(as,.2),scrollbarSliderHoverBackground:ke.opacity(as,.4),scrollbarSliderActiveBackground:ke.opacity(as,.5),overviewRulerBorder:as,ansi:He.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=ye(t.foreground,as),e.background=ye(t.background,li),e.cursor=ke.blend(e.background,ye(t.cursor,ul)),e.cursorAccent=ke.blend(e.background,ye(t.cursorAccent,fl)),e.selectionBackgroundTransparent=ye(t.selectionBackground,ei),e.selectionBackgroundOpaque=ke.blend(e.background,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundTransparent=ye(t.selectionInactiveBackground,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundOpaque=ke.blend(e.background,e.selectionInactiveBackgroundTransparent),e.selectionForeground=t.selectionForeground?ye(t.selectionForeground,ol):void 0,e.selectionForeground===ol&&(e.selectionForeground=void 0),ke.isOpaque(e.selectionBackgroundTransparent)&&(e.selectionBackgroundTransparent=ke.opacity(e.selectionBackgroundTransparent,.3)),ke.isOpaque(e.selectionInactiveBackgroundTransparent)&&(e.selectionInactiveBackgroundTransparent=ke.opacity(e.selectionInactiveBackgroundTransparent,.3)),e.scrollbarSliderBackground=ye(t.scrollbarSliderBackground,ke.opacity(e.foreground,.2)),e.scrollbarSliderHoverBackground=ye(t.scrollbarSliderHoverBackground,ke.opacity(e.foreground,.4)),e.scrollbarSliderActiveBackground=ye(t.scrollbarSliderActiveBackground,ke.opacity(e.foreground,.5)),e.overviewRulerBorder=ye(t.overviewRulerBorder,B1),e.ansi=He.slice(),e.ansi[0]=ye(t.black,He[0]),e.ansi[1]=ye(t.red,He[1]),e.ansi[2]=ye(t.green,He[2]),e.ansi[3]=ye(t.yellow,He[3]),e.ansi[4]=ye(t.blue,He[4]),e.ansi[5]=ye(t.magenta,He[5]),e.ansi[6]=ye(t.cyan,He[6]),e.ansi[7]=ye(t.white,He[7]),e.ansi[8]=ye(t.brightBlack,He[8]),e.ansi[9]=ye(t.brightRed,He[9]),e.ansi[10]=ye(t.brightGreen,He[10]),e.ansi[11]=ye(t.brightYellow,He[11]),e.ansi[12]=ye(t.brightBlue,He[12]),e.ansi[13]=ye(t.brightMagenta,He[13]),e.ansi[14]=ye(t.brightCyan,He[14]),e.ansi[15]=ye(t.brightWhite,He[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]=ye(t.extendedAnsi[i],He[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()}}};Qn=Le([oe(0,ot)],Qn);function ye(t,e){if(t!==void 0)try{return Ae.toColor(t)}catch{}return e}var I1=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)}},L1=class{constructor(){this._services=new I1,this._services.set(Fo,this)}setService(t,e){this._services.set(t,e)}getService(t){return this._services.get(t)}createInstance(t,...e){let s=Rg(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)}},O1={trace:0,debug:1,info:2,warn:3,error:4,off:5},$1="xterm.js: ",eo=class extends _e{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=O1[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?"":$1)+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)}};eo=Le([oe(0,ot)],eo);var ml=class extends _e{constructor(t){super(),this._maxLength=t,this.onDeleteEmitter=this._register(new se),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new se),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new se),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}},pe=3,$e=Object.freeze(new Di),Xi=0,dn=2,ci=class qh{constructor(e,s,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*pe);let r=s||yt.fromCharData([0,uh,1,0]);for(let o=0;o<e;++o)this.setCell(o,r);this.length=e}get(e){let s=this._data[e*pe+0],i=s&2097151;return[this._data[e*pe+1],s&2097152?this._combined[e]:i?es(i):"",s>>22,s&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):i]}set(e,s){this._data[e*pe+1]=s[0],s[1].length>1?(this._combined[e]=s[1],this._data[e*pe+0]=e|2097152|s[2]<<22):this._data[e*pe+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(e){return this._data[e*pe+0]>>22}hasWidth(e){return this._data[e*pe+0]&12582912}getFg(e){return this._data[e*pe+1]}getBg(e){return this._data[e*pe+2]}hasContent(e){return this._data[e*pe+0]&4194303}getCodePoint(e){let s=this._data[e*pe+0];return s&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):s&2097151}isCombined(e){return this._data[e*pe+0]&2097152}getString(e){let s=this._data[e*pe+0];return s&2097152?this._combined[e]:s&2097151?es(s&2097151):""}isProtected(e){return this._data[e*pe+2]&536870912}loadCell(e,s){return Xi=e*pe,s.content=this._data[Xi+0],s.fg=this._data[Xi+1],s.bg=this._data[Xi+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*pe+0]=s.content,this._data[e*pe+1]=s.fg,this._data[e*pe+2]=s.bg}setCellFromCodepoint(e,s,i,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*pe+0]=s|i<<22,this._data[e*pe+1]=r.fg,this._data[e*pe+2]=r.bg}addCodepointToCell(e,s,i){let r=this._data[e*pe+0];r&2097152?this._combined[e]+=es(s):r&2097151?(this._combined[e]=es(r&2097151)+es(s),r&=-2097152,r|=2097152):r=s|1<<22,i&&(r&=-12582913,r|=i<<22),this._data[e*pe+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 yt;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 yt;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*dn<this._data.buffer.byteLength;let i=e*pe;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*dn<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*dn<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 qh(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*pe+0]&4194303)return e+(this._data[e*pe+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*pe+0]&4194303||this._data[e*pe+2]&50331648)return e+(this._data[e*pe+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<pe;c++)this._data[(i+h)*pe+c]=a[(s+h)*pe+c];a[(s+h)*pe+2]&268435456&&(this._extendedAttrs[i+h]=e._extendedAttrs[s+h])}else for(let h=0;h<r;h++){for(let c=0;c<pe;c++)this._data[(i+h)*pe+c]=a[(s+h)*pe+c];a[(s+h)*pe+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*pe+0],l=a&2097151,h=a&2097152?this._combined[s]:l?es(l):ts;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 z1(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=Ci(d,u,e),p=1,m=0;for(;p<d.length;){let g=Ci(d,p,e),x=g-m,S=s-f,v=Math.min(x,S);d[u].copyCellsFrom(d[p],m,f,v,!1),f+=v,f===s&&(u++,f=0),m+=v,m===g&&(p++,m=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 F1(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 H1(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 W1(t,e,s){let i=[],r=t.map((h,c)=>Ci(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=Ci(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 Ci(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 Gh=class Yh{constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=Yh._nextId++,this._onDispose=this.register(new se),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ps(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};Gh._nextId=1;var U1=Gh,Ue={},ls=Ue.B;Ue[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Ue.A={"#":"£"};Ue.B=void 0;Ue[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Ue.C=Ue[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ue.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Ue.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Ue.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Ue.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Ue.E=Ue[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Ue.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Ue.H=Ue[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ue["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var pl=4294967295,_l=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=$e.clone(),this.savedCharset=ls,this.markers=[],this._nullCell=yt.fromCharData([0,uh,1,0]),this._whitespaceCell=yt.fromCharData([0,ts,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new jr,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new ml(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 Sr),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 Sr),this._whitespaceCell}getBlankLine(t,e){return new ci(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>pl?pl:e}fillViewportRows(t){if(this.lines.length===0){t===void 0&&(t=$e);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 ml(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,e){let s=this.getNullCell($e),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 ci(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 ci(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=z1(this.lines,this._cols,t,this.ybase+this.y,this.getNullCell($e),s);if(i.length>0){let r=F1(this.lines,i);H1(this.lines,r.layout),this._reflowLargerAdjustViewport(t,e,r.countRemoved)}}_reflowLargerAdjustViewport(t,e,s){let i=this.getNullCell($e),r=s;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<e&&this.lines.push(new ci(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($e),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=W1(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 p=[];for(let v=0;v<u;v++){let b=this.getBlankLine($e,!0);p.push(b)}p.length>0&&(r.push({start:a+h.length+o,newLines:p}),o+=p.length),h.push(...p);let m=d.length-1,_=d[m];_===0&&(m--,_=d[m]);let g=h.length-u-1,x=c;for(;g>=0;){let v=Math.min(x,_);if(h[m]===void 0)break;if(h[m].copyCellsFrom(h[g],x-v,_-v,v,!0),_-=v,_===0&&(m--,_=d[m]),x-=v,x===0){g--;let b=Math.max(g,0);x=Ci(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 p=0;for(let _=a.length-1;_>=0;_--)a[_].index+=p,this.lines.onInsertEmitter.fire(a[_]),p+=a[_].amount;let m=Math.max(0,h+o-this.lines.maxLength);m>0&&this.lines.onTrimEmitter.fire(m)}}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 U1(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)}},K1=class extends _e{constructor(t,e){super(),this._optionsService=t,this._bufferService=e,this._onBufferActivate=this._register(new se),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 _l(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new _l(!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)}},Xh=2,Jh=1,to=class extends _e{constructor(t){super(),this.isUserScrolling=!1,this._onResize=this._register(new se),this.onResize=this._onResize.event,this._onScroll=this._register(new se),this.onScroll=this._onScroll.event,this.cols=Math.max(t.rawOptions.cols||0,Xh),this.rows=Math.max(t.rawOptions.rows||0,Jh),this.buffers=this._register(new K1(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))}};to=Le([oe(0,ot)],to);var Ns={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:kr,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},V1=["normal","bold","100","200","300","400","500","600","700","800","900"],q1=class extends _e{constructor(t){super(),this._onOptionChange=this._register(new se),this.onOptionChange=this._onOptionChange.event;let e={...Ns};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(Re(()=>{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 Ns))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},e=(s,i)=>{if(!(s in Ns))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=Ns[t]),!G1(e))throw new Error(`"${e}" is not a valid value for ${t}`);break;case"wordSeparator":e||(e=Ns[t]);break;case"fontWeight":case"fontWeightBold":if(typeof e=="number"&&1<=e&&e<=1e3)break;e=V1.includes(e)?e:Ns[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 G1(t){return t==="block"||t==="underline"||t==="bar"}function hi(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]&&hi(t[i],e-1);return s}var gl=Object.freeze({insertMode:!1}),vl=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),so=class extends _e{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 se),this.onData=this._onData.event,this._onUserInput=this._register(new se),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new se),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new se),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=hi(gl),this.decPrivateModes=hi(vl)}reset(){this.modes=hi(gl),this.decPrivateModes=hi(vl)}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))}};so=Le([oe(0,nt),oe(1,gh),oe(2,ot)],so);var xl={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 un(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 fn=String.fromCharCode,bl={DEFAULT:t=>{let e=[un(t,!1)+32,t.col+32,t.row+32];return e[0]>255||e[1]>255||e[2]>255?"":`\x1B[M${fn(e[0])}${fn(e[1])}${fn(e[2])}`},SGR:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${un(t,!0)};${t.col};${t.row}${e}`},SGR_PIXELS:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${un(t,!0)};${t.x};${t.y}${e}`}},io=class extends _e{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 se),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(xl))this.addProtocol(i,xl[i]);for(let i of Object.keys(bl))this.addEncoding(i,bl[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)}};io=Le([oe(0,nt),oe(1,Cs),oe(2,ot)],io);var mn=[[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]],Y1=[[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]],We;function X1(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 J1=class{constructor(){if(this.version="6",!We){We=new Uint8Array(65536),We.fill(1),We[0]=0,We.fill(0,1,32),We.fill(0,127,160),We.fill(2,4352,4448),We[9001]=2,We[9002]=2,We.fill(2,11904,42192),We[12351]=1,We.fill(2,44032,55204),We.fill(2,63744,64256),We.fill(2,65040,65050),We.fill(2,65072,65136),We.fill(2,65280,65377),We.fill(2,65504,65511);for(let t=0;t<mn.length;++t)We.fill(0,mn[t][0],mn[t][1]+1)}}wcwidth(t){return t<32?0:t<127?1:t<65536?We[t]:X1(t,Y1)?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=cs.extractWidth(e);r===0?i=!1:r>s&&(s=r)}return cs.createPropertyValue(0,s,i)}},cs=class ar{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new se,this.onChange=this._onChange.event;let e=new J1;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=ar.extractWidth(l);ar.extractShouldJoin(l)&&(h-=ar.extractWidth(i)),s+=h,i=l}return s}charProperties(e,s){return this._activeProvider.charProperties(e,s)}},Z1=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 yl(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 ti=2147483647,Q1=256,Zh=class ro{constructor(e=32,s=32){if(this.maxLength=e,this.maxSubParamsLength=s,s>Q1)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 ro;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 ro(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>ti?ti: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>ti?ti: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,ti):e}},si=[],ex=class{constructor(){this._state=0,this._active=si,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=si}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=si,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||si,!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",Fr(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=si,this._id=-1,this._state=0}}},ct=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+=Fr(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}},ii=[],tx=class{constructor(){this._handlers=Object.create(null),this._active=ii,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ii}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=ii,this._ident=0}hook(t,e){if(this.reset(),this._ident=t,this._active=this._handlers[t]||ii,!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",Fr(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=ii,this._ident=0}},di=new Zh;di.addParam(0);var Sl=class{constructor(t){this._handler=t,this._data="",this._params=di,this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():di,this._data="",this._hitLimit=!1}put(t,e,s){this._hitLimit||(this._data+=Fr(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=di,this._data="",this._hitLimit=!1,s));return this._params=di,this._data="",this._hitLimit=!1,e}},sx=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}},vt=160,ix=(function(){let t=new sx(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(vt,0,2,0),t.add(vt,8,5,8),t.add(vt,6,0,6),t.add(vt,11,0,11),t.add(vt,13,13,13),t})(),rx=class extends _e{constructor(t=ix){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 Zh,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(Re(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new ex),this._dcsParser=this._register(new tx),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:vt)],r>>4){case 2:for(let f=l+1;;++f){if(f>=e||(i=t[f])<32||i>126&&i<vt){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(i=t[f])<32||i>126&&i<vt){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(i=t[f])<32||i>126&&i<vt){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(i=t[f])<32||i>126&&i<vt){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<vt){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<vt){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}}},nx=/^([\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})$/,ox=/^[\da-f]+$/;function wl(t){if(!t)return;let e=t.toLowerCase();if(e.indexOf("rgb:")===0){e=e.slice(4);let s=nx.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),ox.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 pn(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 ax(t,e=16){let[s,i,r]=t;return`rgb:${pn(s,e)}/${pn(i,e)}/${pn(r,e)}`}var lx={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Qt=131072,Cl=10;function kl(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 jl=5e3,Nl=0,cx=class extends _e{constructor(t,e,s,i,r,o,a,l,h=new rx){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 Eg,this._utf8Decoder=new Tg,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=$e.clone(),this._eraseAttrDataInternal=$e.clone(),this._onRequestBell=this._register(new se),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new se),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new se),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new se),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new se),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new se),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new se),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new se),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new se),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new se),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new se),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new se),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new se),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 no(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(J.BEL,()=>this.bell()),this._parser.setExecuteHandler(J.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(J.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(J.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(J.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(J.BS,()=>this.backspace()),this._parser.setExecuteHandler(J.HT,()=>this.tab()),this._parser.setExecuteHandler(J.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(J.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(nr.IND,()=>this.index()),this._parser.setExecuteHandler(nr.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(nr.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new ct(c=>(this.setTitle(c),this.setIconName(c),!0))),this._parser.registerOscHandler(1,new ct(c=>this.setIconName(c))),this._parser.registerOscHandler(2,new ct(c=>this.setTitle(c))),this._parser.registerOscHandler(4,new ct(c=>this.setOrReportIndexedColor(c))),this._parser.registerOscHandler(8,new ct(c=>this.setHyperlink(c))),this._parser.registerOscHandler(10,new ct(c=>this.setOrReportFgColor(c))),this._parser.registerOscHandler(11,new ct(c=>this.setOrReportBgColor(c))),this._parser.registerOscHandler(12,new ct(c=>this.setOrReportCursorColor(c))),this._parser.registerOscHandler(104,new ct(c=>this.restoreIndexedColor(c))),this._parser.registerOscHandler(110,new ct(c=>this.restoreFgColor(c))),this._parser.registerOscHandler(111,new ct(c=>this.restoreBgColor(c))),this._parser.registerOscHandler(112,new ct(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 Ue)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 Sl((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"),jl))]).catch(e=>{if(e!=="#SLOW_TIMEOUT")throw e;console.warn(`async parser handler taking longer than ${jl} 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>Qt&&(o=this._parseStack.position+Qt)}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<Qt&&(this._parseBuffer=new Uint32Array(Math.min(t.length,Qt))),a||this._dirtyRowTracker.clearRange(),t.length>Qt)for(let c=o;c<t.length;c+=Qt){let d=c+Qt<t.length?c+Qt: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 p=e;p<s;++p){if(i=t[p],i<127&&o){let x=o[String.fromCharCode(i)];x&&(i=x.charCodeAt(0))}let m=this._unicodeService.charProperties(i,f);r=cs.extractWidth(m);let _=cs.extractShouldJoin(m),g=_?cs.extractWidth(f):0;if(f=m,a&&this._onA11yChar.fire(es(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 ci&&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=>kl(s.params[0],this._optionsService.rawOptions.windowOptions)?e(s):!0):this._parser.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._parser.registerDcsHandler(t,new Sl(e))}registerEscHandler(t,e){return this._parser.registerEscHandler(t,e)}registerOscHandler(t,e){return this._parser.registerOscHandler(t,new ct(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($e));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=cs.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(J.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(J.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(t){return t.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(J.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(J.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(t.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(J.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,ls),this._charsetService.setgCharset(1,ls),this._charsetService.setgCharset(2,ls),this._charsetService.setgCharset(3,ls);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(`${J.ESC}[${e?"":"?"}${_};${g}$y`),!0),p=_=>_?1:2,m=t.params[0];return e?m===2?f(m,4):m===4?f(m,p(a.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(u.convertEol)):f(m,0):m===1?f(m,p(i.applicationCursorKeys)):m===3?f(m,u.windowOptions.setWinLines?h===80?2:h===132?1:0:0):m===6?f(m,p(i.origin)):m===7?f(m,p(i.wraparound)):m===8?f(m,3):m===9?f(m,p(r==="X10")):m===12?f(m,p(u.cursorBlink)):m===25?f(m,p(!a.isCursorHidden)):m===45?f(m,p(i.reverseWraparound)):m===66?f(m,p(i.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(r==="VT200")):m===1002?f(m,p(r==="DRAG")):m===1003?f(m,p(r==="ANY")):m===1004?f(m,p(i.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(o==="SGR")):m===1015?f(m,4):m===1016?f(m,p(o==="SGR_PIXELS")):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(c===d)):m===2004?f(m,p(i.bracketedPasteMode)):m===2026?f(m,p(i.synchronizedOutput)):f(m,0)}_updateAttrColor(t,e,s,i,r){return e===2?(t|=50331648,t&=-16777216,t|=Di.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=$e.fg,t.bg=$e.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|=$e.fg&16777215):s===49?(i.bg&=-67108864,i.bg|=$e.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|=$e.fg&16777215,i.bg&=-67108864,i.bg|=$e.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(t){switch(t.params[0]){case 5:this._coreService.triggerDataEvent(`${J.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${J.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(`${J.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=$e.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(!kl(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(`${J.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(e===0||e===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Cl&&this._windowTitleStack.shift()),(e===0||e===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Cl&&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(El(o))if(r==="?")e.push({type:0,index:o});else{let a=wl(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=wl(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]);El(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,ls),!0}selectCharset(t){return t.length!==2?(this.selectDefaultCharset(),!0):(t[0]==="/"||this._charsetService.setgCharset(lx[t[0]],Ue[t[1]]||ls),!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=$e.clone(),this._eraseAttrDataInternal=$e.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 yt;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(`${J.ESC}${a}${J.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)}},no=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&&(Nl=t,t=e,e=Nl),t<this.start&&(this.start=t),e>this.end&&(this.end=e)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};no=Le([oe(0,nt)],no);function El(t){return 0<=t&&t<256}var hx=5e7,Tl=12,dx=50,ux=class extends _e{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 se),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>hx)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>=Tl?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>=Tl)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>dx&&(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()}},oo=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)))}};oo=Le([oe(0,nt)],oo);var Rl=!1,fx=class extends _e{constructor(t){super(),this._windowsWrappingHeuristics=this._register(new Ms),this._onBinary=this._register(new se),this.onBinary=this._onBinary.event,this._onData=this._register(new se),this.onData=this._onData.event,this._onLineFeed=this._register(new se),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new se),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new se),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new se),this._instantiationService=new L1,this.optionsService=this._register(new q1(t)),this._instantiationService.setService(ot,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(to)),this._instantiationService.setService(nt,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(eo)),this._instantiationService.setService(gh,this._logService),this.coreService=this._register(this._instantiationService.createInstance(so)),this._instantiationService.setService(Cs,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(io)),this._instantiationService.setService(_h,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(cs)),this._instantiationService.setService(Ag,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Z1),this._instantiationService.setService(Dg,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(oo),this._instantiationService.setService(vh,this._oscLinkService),this._inputHandler=this._register(new cx(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(et.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(et.forward(this._bufferService.onResize,this._onResize)),this._register(et.forward(this.coreService.onData,this._onData)),this._register(et.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 ux((e,s)=>this._inputHandler.parse(e,s))),this._register(et.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new se),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&&!Rl&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Rl=!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,Xh),e=Math.max(e,Jh),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(yl.bind(null,this._bufferService))),t.push(this.registerCsiHandler({final:"H"},()=>(yl(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Re(()=>{for(let e of t)e.dispose()})}}},mx={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 px(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=J.ESC+"OA":r.key=J.ESC+"[A":t.key==="UIKeyInputLeftArrow"?e?r.key=J.ESC+"OD":r.key=J.ESC+"[D":t.key==="UIKeyInputRightArrow"?e?r.key=J.ESC+"OC":r.key=J.ESC+"[C":t.key==="UIKeyInputDownArrow"&&(e?r.key=J.ESC+"OB":r.key=J.ESC+"[B");break;case 8:r.key=t.ctrlKey?"\b":J.DEL,t.altKey&&(r.key=J.ESC+r.key);break;case 9:if(t.shiftKey){r.key=J.ESC+"[Z";break}r.key=J.HT,r.cancel=!0;break;case 13:r.key=t.altKey?J.ESC+J.CR:J.CR,r.cancel=!0;break;case 27:r.key=J.ESC,t.altKey&&(r.key=J.ESC+J.ESC),r.cancel=!0;break;case 37:if(t.metaKey)break;o?r.key=J.ESC+"[1;"+(o+1)+"D":e?r.key=J.ESC+"OD":r.key=J.ESC+"[D";break;case 39:if(t.metaKey)break;o?r.key=J.ESC+"[1;"+(o+1)+"C":e?r.key=J.ESC+"OC":r.key=J.ESC+"[C";break;case 38:if(t.metaKey)break;o?r.key=J.ESC+"[1;"+(o+1)+"A":e?r.key=J.ESC+"OA":r.key=J.ESC+"[A";break;case 40:if(t.metaKey)break;o?r.key=J.ESC+"[1;"+(o+1)+"B":e?r.key=J.ESC+"OB":r.key=J.ESC+"[B";break;case 45:!t.shiftKey&&!t.ctrlKey&&(r.key=J.ESC+"[2~");break;case 46:o?r.key=J.ESC+"[3;"+(o+1)+"~":r.key=J.ESC+"[3~";break;case 36:o?r.key=J.ESC+"[1;"+(o+1)+"H":e?r.key=J.ESC+"OH":r.key=J.ESC+"[H";break;case 35:o?r.key=J.ESC+"[1;"+(o+1)+"F":e?r.key=J.ESC+"OF":r.key=J.ESC+"[F";break;case 33:t.shiftKey?r.type=2:t.ctrlKey?r.key=J.ESC+"[5;"+(o+1)+"~":r.key=J.ESC+"[5~";break;case 34:t.shiftKey?r.type=3:t.ctrlKey?r.key=J.ESC+"[6;"+(o+1)+"~":r.key=J.ESC+"[6~";break;case 112:o?r.key=J.ESC+"[1;"+(o+1)+"P":r.key=J.ESC+"OP";break;case 113:o?r.key=J.ESC+"[1;"+(o+1)+"Q":r.key=J.ESC+"OQ";break;case 114:o?r.key=J.ESC+"[1;"+(o+1)+"R":r.key=J.ESC+"OR";break;case 115:o?r.key=J.ESC+"[1;"+(o+1)+"S":r.key=J.ESC+"OS";break;case 116:o?r.key=J.ESC+"[15;"+(o+1)+"~":r.key=J.ESC+"[15~";break;case 117:o?r.key=J.ESC+"[17;"+(o+1)+"~":r.key=J.ESC+"[17~";break;case 118:o?r.key=J.ESC+"[18;"+(o+1)+"~":r.key=J.ESC+"[18~";break;case 119:o?r.key=J.ESC+"[19;"+(o+1)+"~":r.key=J.ESC+"[19~";break;case 120:o?r.key=J.ESC+"[20;"+(o+1)+"~":r.key=J.ESC+"[20~";break;case 121:o?r.key=J.ESC+"[21;"+(o+1)+"~":r.key=J.ESC+"[21~";break;case 122:o?r.key=J.ESC+"[23;"+(o+1)+"~":r.key=J.ESC+"[23~";break;case 123:o?r.key=J.ESC+"[24;"+(o+1)+"~":r.key=J.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=J.NUL:t.keyCode>=51&&t.keyCode<=55?r.key=String.fromCharCode(t.keyCode-51+27):t.keyCode===56?r.key=J.DEL:t.keyCode===219?r.key=J.ESC:t.keyCode===220?r.key=J.FS:t.keyCode===221&&(r.key=J.GS);else if((!s||i)&&t.altKey&&!t.metaKey){let a=mx[t.keyCode]?.[t.shiftKey?1:0];if(a)r.key=J.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=J.ESC+h}else if(t.keyCode===32)r.key=J.ESC+(t.ctrlKey?J.NUL:" ");else if(t.key==="Dead"&&t.code.startsWith("Key")){let l=t.code.slice(3,4);t.shiftKey||(l=l.toLowerCase()),r.key=J.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=J.US),t.key==="@"&&(r.key=J.NUL));break}return r}var Oe=0,_x=class{constructor(t){this._getKey=t,this._array=[],this._insertedValues=[],this._flushInsertedTask=new jr,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new jr,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||(Oe=this._search(e),Oe===-1)||this._getKey(this._array[Oe])!==e)return!1;do if(this._array[Oe]===t)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Oe),!0;while(++Oe<this._array.length&&this._getKey(this._array[Oe])===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&&(Oe=this._search(t),!(Oe<0||Oe>=this._array.length)&&this._getKey(this._array[Oe])===t))do yield this._array[Oe];while(++Oe<this._array.length&&this._getKey(this._array[Oe])===t)}forEachByKey(t,e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Oe=this._search(t),!(Oe<0||Oe>=this._array.length)&&this._getKey(this._array[Oe])===t))do e(this._array[Oe]);while(++Oe<this._array.length&&this._getKey(this._array[Oe])===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}},_n=0,Pl=0,gx=class extends _e{constructor(){super(),this._decorations=new _x(t=>t?.marker.line),this._onDecorationRegistered=this._register(new se),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new se),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Re(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(t){if(t.marker.isDisposed)return;let e=new vx(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=>{_n=r.options.x??0,Pl=_n+(r.options.width??1),t>=_n&&t<Pl&&(!s||(r.options.layer??"bottom")===s)&&i(r)})}},vx=class extends is{constructor(t){super(),this.options=t,this.onRenderEmitter=this.add(new se),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new se),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=Ae.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Ae.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},xx=1e3,bx=class{constructor(t,e=xx){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)}},Dl=20,Nr=class extends _e{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 bx(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(`
|
|
286
286
|
`))),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(fe(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Re(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(t){for(let e=0;e<t;e++)this._handleChar(" ")}_handleChar(t){this._liveRegionLineCount<Dl+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==t&&(this._charsToAnnounce+=t):this._charsToAnnounce+=t,t===`
|
|
287
287
|
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Dl+1&&(this._liveRegion.textContent+=jn.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})`}};Nr=Le([oe(1,Fo),oe(2,Yt),oe(3,Xt)],Nr);var ao=class extends _e{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 se),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new se),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Re(()=>{ps(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(fe(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(fe(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(fe(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(fe(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&&yx(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,ps(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}}};ao=Le([oe(1,Ho),oe(2,Xt),oe(3,nt),oe(4,bh)],ao);function yx(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 Sx=class extends fx{constructor(t={}){super(t),this._linkifier=this._register(new Ms),this.browser=$h,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Ms),this._onCursorMove=this._register(new se),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new se),this.onKey=this._onKey.event,this._onRender=this._register(new se),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new se),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new se),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new se),this.onBell=this._onBell.event,this._onFocus=this._register(new se),this._onBlur=this._register(new se),this._onA11yCharEmitter=this._register(new se),this._onA11yTabEmitter=this._register(new se),this._onWillOpen=this._register(new se),this._setup(),this._decorationService=this._instantiationService.createInstance(gx),this._instantiationService.setService(Ai,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(d1),this._instantiationService.setService(bh,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(En)),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(et.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(et.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(et.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(et.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(Re(()=>{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=ke.toColorRGB(s==="ansi"?this._themeService.colors.ansi[e.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${J.ESC}]${i};${ax(r)}${Lh.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[e.index]=Fe.toColor(...e.color));else{let o=s;this._themeService.modifyColors(a=>a[o]=Fe.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(Nr,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(t){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(J.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(J.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(fe(this.element,"copy",e=>{this.hasSelection()&&jg(e,this._selectionService)}));let t=e=>Ng(e,this.textarea,this.coreService,this.optionsService);this._register(fe(this.textarea,"paste",t)),this._register(fe(this.element,"paste",t)),zh?this._register(fe(this.element,"mousedown",e=>{e.button===2&&Ha(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(fe(this.element,"contextmenu",e=>{Ha(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Xo&&this._register(fe(this.element,"auxclick",e=>{e.button===1&&dh(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(fe(this.textarea,"keyup",t=>this._keyUp(t),!0)),this._register(fe(this.textarea,"keydown",t=>this._keyDown(t),!0)),this._register(fe(this.textarea,"keypress",t=>this._keyPress(t),!0)),this._register(fe(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(fe(this.textarea,"compositionupdate",t=>this._compositionHelper.compositionupdate(t))),this._register(fe(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(fe(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(fe(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",kn.get()),Wh||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(c1,this.textarea,t.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Yt,this._coreBrowserService),this._register(fe(this.textarea,"focus",r=>this._handleTextAreaFocus(r))),this._register(fe(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Yn,this._document,this._helperContainer),this._instantiationService.setService(Hr,this._charSizeService),this._themeService=this._instantiationService.createInstance(Qn),this._instantiationService.setService(qs,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Cr),this._instantiationService.setService(xh,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Jn,this.rows,this.screenElement)),this._instantiationService.setService(Xt,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(Vn,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Xn),this._instantiationService.setService(Ho,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(ao,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(Un,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(Zn,this.element,this.screenElement,i)),this._instantiationService.setService(Bg,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(et.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(Kn,this.screenElement)),this._register(fe(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(Nr,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",r=>this._handleScreenReaderModeOptionChange(r))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(wr,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",r=>{!this._overviewRulerRenderer&&r&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(wr,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Gn,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(fe(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(fe(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=J.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){hh(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=px(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===J.ETX||s.key===J.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)&&(wx(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($e));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(J.ESC+"[I"):this.coreService.triggerDataEvent(J.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(`${J.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(`${J.ESC}[6;${r};${i}t`);break}}cancel(t,e){if(!(!this.options.cancelEvents&&!e))return t.preventDefault(),t.stopPropagation(),!1}};function wx(t){return t.keyCode===16||t.keyCode===17||t.keyCode===18}var Cx=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)}},kx=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 yt)}translateToString(t,e,s){return this._line.translateToString(t,e,s)}},Al=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 kx(e)}getNullCell(){return new yt}},jx=class extends _e{constructor(t){super(),this._core=t,this._onBufferChange=this._register(new se),this.onBufferChange=this._onBufferChange.event,this._normal=new Al(this._core.buffers.normal,"normal"),this._alternate=new Al(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)}},Nx=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)}},Ex=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}},Tx=["cols","rows"],Nt=0,Rx=class extends _e{constructor(t){super(),this._core=this._register(new Sx(t)),this._addonManager=this._register(new Cx),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(Tx.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 Nx(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new Ex(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 jx(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
|
|
288
|
-
`,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 kn.get()},set promptLabel(t){kn.set(t)},get tooMuchOutput(){return jn.get()},set tooMuchOutput(t){jn.set(t)}}}_verifyIntegers(...t){for(Nt of t)if(Nt===1/0||isNaN(Nt)||Nt%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(Nt of t)if(Nt&&(Nt===1/0||isNaN(Nt)||Nt%1!==0||Nt<0))throw new Error("This API only accepts positive integers")}};var Px=2,Dx=1,Ax=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(Px,Math.floor(d/t.css.cell.width)),rows:Math.max(Dx,Math.floor(c/t.css.cell.height))}}};function Qh({source:t,onReady:e,onSelectionChange:s,className:i}){const r=A.useRef(null),o=A.useRef(null),a=A.useRef(s);a.current=s;const l=ns(),h=A.useRef(t);return h.current=t,Ym((c,d)=>{c===h.current&&o.current?.write(d)}),A.useEffect(()=>{const c=r.current;if(!c)return;const d=getComputedStyle(document.documentElement),u=x=>d.getPropertyValue(x).trim()||void 0,f=new Rx({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")}}),p=new Ax;f.loadAddon(p),f.open(c),p.fit();const m=l.getBuffer(t);m&&f.write(m),o.current=f,e?.(f);const _=f.onSelectionChange(()=>{const x=!!f.getSelection();a.current?.(x,()=>f.getSelection())}),g=new ResizeObserver(()=>{p.fit()});return g.observe(c),()=>{_.dispose(),g.disconnect(),o.current=null,f.dispose()}},[]),n.jsx("div",{className:ie("h-full bg-sidebar p-3",i),children:n.jsx("div",{ref:r,className:"h-full"})})}function xt(t){const e=K.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(pg,{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(Mx,{kind:t.kind}),i=n.jsx(Bx,{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(Ix,{...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(Lx,{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(Ox,{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($x,{...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 Mx(t){const e=K.c(5),{kind:s}=t;switch(s){case"never-started":{let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(rc,{className:ie("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(ui,{className:ie("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(ui,{className:ie("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(wu,{className:ie("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(ui,{className:ie("size-12","text-amber-500")}),e[4]=i):i=e[4],i}}}function Bx(t){const e=K.c(4),{kind:s}=t;let i;e[0]!==s?(i=lg(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 Ix(t){const e=K.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 Lx(t){const e=K.c(21),{progress:s}=t;let i;e[0]!==s?(i=Wi(s,"provision"),e[0]=s,e[1]=i):i=e[1];let r;e[2]!==i?(r=n.jsx(Ji,{label:"provision",status:i}),e[2]=i,e[3]=r):r=e[3];let o;e[4]!==s?(o=Wi(s,"cloning"),e[4]=s,e[5]=o):o=e[5];let a;e[6]!==o?(a=n.jsx(Ji,{label:"cloning",status:o}),e[6]=o,e[7]=a):a=e[7];let l;e[8]!==s?(l=Wi(s,"install"),e[8]=s,e[9]=l):l=e[9];let h;e[10]!==l?(h=n.jsx(Ji,{label:"install",status:l}),e[10]=l,e[11]=h):h=e[11];let c;e[12]!==s?(c=Wi(s,"dev"),e[12]=s,e[13]=c):c=e[13];let d;e[14]!==c?(d=n.jsx(Ji,{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 Ji(t){const e=K.c(12),{label:s,status:i}=t;let r;e[0]!==i?(r=ag(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=ie("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 Ox(t){const e=K.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(Qh,{source:s,className:"h-full"})})}),e[0]=s,e[1]=i):i=e[1],i}function $x(t){const e=K.c(25);switch(t.kind){case"never-started":{let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(ms,{className:"size-4"}),e[0]=s):s=e[0];let i;return e[1]!==t.onStart?(i=n.jsxs(te,{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(fs,{className:"size-4"}),e[3]=s):s=e[3];let i;return e[4]!==t.onRetry?(i=n.jsxs(te,{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(fs,{className:"size-4"}),e[6]=s):s=e[6];let i;e[7]!==t.onRetry?(i=n.jsxs(te,{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(nc,{className:"size-4"}),e[9]=r):r=e[9];let o;e[10]!==t.onBrowseFiles?(o=n.jsxs(te,{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(vn,{className:"size-4"}),e[12]=a):a=e[12];let l;e[13]!==t.onOpenTerminal?(l=n.jsxs(te,{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(ms,{className:"size-4"}),e[19]=s):s=e[19];let i;return e[20]!==t.onResume?(i=n.jsxs(te,{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(vn,{className:"size-4"}),e[22]=s):s=e[22];let i;return e[23]!==t.onOpenTerminal?(i=n.jsxs(te,{onClick:t.onOpenTerminal,className:"mt-2",children:[s," Open terminal"]}),e[23]=t.onOpenTerminal,e[24]=i):i=e[24],i}}}const zx=["dev","start"],us="setup";function Fx(t){const e=K.c(35);let s;if(e[0]!==t.scriptTabs||e[1]!==t.scripts){let p;e[3]!==t.scriptTabs?(p=m=>!t.scriptTabs.includes(m),e[3]=t.scriptTabs,e[4]=p):p=e[4],s=t.scripts.filter(p),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===us?t.onToggle():t.onSelectTab(us)},e[5]=t,e[6]=r):r=e[6];const o=r,a=t.active===us;let l;e[7]!==o||e[8]!==t.open||e[9]!==a?(l=n.jsx(Hx,{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(p=>n.jsx(Ux,{active:t.active===p,onClick:()=>t.onSelectTab(p),onClose:()=>t.onCloseScript(p),children:p},p)),e[11]=t,e[12]=h):h=e[12];let c;e[13]!==i||e[14]!==t.onAddScript?(c=n.jsx(Kx,{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(Vx,{isRunning:t.scriptIsRunning,isKilling:t.scriptIsKilling,onRun:t.onRunActiveScript,onStop:t.onStopActiveScript}):n.jsx(Wx,{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 Hx(t){const e=K.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=ie("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(vn,{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 Wx(t){const e=K.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(ms,{className:"size-3.5"}),e[0]=h):h=e[0];let c;return e[1]!==i?(c=n.jsxs(te,{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(ms,{className:"size-3.5"}),e[3]=h):h=e[3];let c;return e[4]!==a?(c=n.jsxs(te,{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(fs,{className:"size-3.5"}),e[6]=h):h=e[6];let c;return e[7]!==l?(c=n.jsxs(te,{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=ie(c),e[9]=c,e[10]=d):d=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(oc,{className:"size-3.5"}),e[11]=u):u=e[11];let f;e[12]!==r||e[13]!==d?(f=n.jsx(Se,{asChild:!0,children:n.jsxs(te,{variant:"outline",size:"sm",onClick:r,className:d,children:[u," Stop"]})}),e[12]=r,e[13]=d,e[14]=f):f=e[14];let p;e[15]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(we,{children:"Stop sandbox"}),e[15]=p):p=e[15];let m;e[16]!==f?(m=n.jsxs(Ce,{children:[f,p]}),e[16]=f,e[17]=m):m=e[17];let _;e[18]!==o||e[19]!==h?(_=h&&n.jsxs(Fs,{children:[n.jsx(Hs,{asChild:!0,children:n.jsx(te,{variant:"outline",size:"sm",className:"rounded-l-none px-1",children:n.jsx(Or,{className:"size-3"})})}),n.jsx(Ws,{align:"end",children:n.jsxs(ut,{onClick:o,children:[n.jsx(fs,{className:"size-3.5"})," Restart"]})})]}),e[18]=o,e[19]=h,e[20]=_):_=e[20];let g;return e[21]!==m||e[22]!==_?(g=n.jsxs("div",{className:"flex items-center",children:[m,_]}),e[21]=m,e[22]=_,e[23]=g):g=e[23],g}return null}function Ux(t){const e=K.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=ie("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=ie("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(Tf,{className:"size-3"})}),e[9]=o,e[10]=r,e[11]=f):f=e[11];let p;return e[12]!==l||e[13]!==u||e[14]!==f?(p=n.jsxs("div",{className:l,children:[u,f]}),e[12]=l,e[13]=u,e[14]=f,e[15]=p):p=e[15],p}function Kx(t){const e=K.c(10),{scripts:s,onRun:i}=t,[r,o]=A.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs(Ce,{children:[n.jsx(Se,{asChild:!0,children:n.jsx(Os,{asChild:!0,children:n.jsx(te,{variant:"ghost",size:"sm","aria-label":"Run script",children:n.jsx(Kt,{className:"size-3.5"})})})}),n.jsx(we,{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($s,{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(Ls,{open:r,onOpenChange:o,children:[a,c]}),e[7]=r,e[8]=c,e[9]=d):d=e[9],d}function Vx(t){const e=K.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(te,{variant:"outline",size:"sm",disabled:!0,children:[n.jsx(ge,{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(ms,{className:"size-3.5"}),e[1]=d):d=e[1];let u;e[2]!==r?(u=n.jsx(Se,{asChild:!0,children:n.jsxs(te,{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(we,{children:"Start process"}),e[4]=f):f=e[4];let p;return e[5]!==u?(p=n.jsxs(Ce,{children:[u,f]}),e[5]=u,e[6]=p):p=e[6],p}let a;e[7]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(oc,{className:"size-3.5"}),e[7]=a):a=e[7];let l;e[8]!==o?(l=n.jsx(Se,{asChild:!0,children:n.jsxs(te,{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(we,{children:"Stop process"}),e[10]=h):h=e[10];let c;return e[11]!==l?(c=n.jsxs(Ce,{children:[l,h]}),e[11]=l,e[12]=c):c=e[12],c}function qx(t){const e=ns(),[s,i]=A.useState(us),[r,o]=A.useState([]),[a,l]=A.useState(new Set),h=A.useRef(!1);if(!h.current&&e.scripts.length>0){const b=zx.find(k=>e.scripts.includes(k));b&&(h.current=!0,o(k=>k.includes(b)?k:[...k,b]),i(b))}if(a.size>0){let b=!1;const k=new Set(a);for(const w of a)e.activeProcesses.includes(w)||(k.delete(w),b=!0);b&&l(k)}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"}),p=async b=>{o(k=>k.includes(b)?k:[...k,b]),i(b),t.onOpenChange(!0);try{const k=await u(b);if(k===null)return;if(!k.ok)throw new Error(`Exec failed: ${k.statusText}`)}catch{ae.error("Failed to run "+b)}},m=async b=>{await f(b),o(k=>k.filter(w=>w!==b)),s===b&&i(us)},_=async()=>{const b=e.activeProcesses.includes(s);try{const k=await u(s);if(k===null)return;if(!k.ok)throw new Error(`Exec failed: ${k.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(k=>{const w=new Set(k);return w.delete(s),w});return}if(!b.ok)throw new Error(`Kill failed: ${b.statusText}`)}catch{l(b=>{const k=new Set(b);return k.delete(s),k}),ae.error("Failed to stop "+s)}}},x=s!==us&&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(Fx,{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:p,onCloseScript:m,showScriptControls:x,scriptIsRunning:S,scriptIsKilling:v,onRunActiveScript:_,onStopActiveScript:g}),t.open&&n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(Gx,{vmId:t.vmId,active:s,hasData:e.hasData(s),onRunActive:_})})]})}function Gx(t){const e=K.c(10),{vmId:s,active:i,hasData:r,onRunActive:o}=t;if(!s)return null;if(i===us||r){let d;return e[0]!==i?(d=n.jsx(Qh,{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(ms,{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 ed=t=>`preview-drawer:${t}`;function Yx(t){try{const e=localStorage.getItem(ed(t));return e?!!JSON.parse(e).open:!1}catch{return!1}}function Xx(t,e){try{localStorage.setItem(ed(t),JSON.stringify({open:e}))}catch{}}const Jx=A.lazy(()=>Ni(()=>import("./sections-editor-Dfs3LCeJ.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}))),Zx=A.lazy(()=>Ni(()=>import("./file-explorer-Bmg1LFT9.js"),__vite__mapDeps([136,1,2,132,103,3,4,6,7,8,9,10,11,12,13,14,15,16,17,5,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,84,85,54,86,87,88,53,89,55,96,97,45,98,99,100,83,90,91,92,93,94,95,62,101,52,102,67,68,46,66,63,77,104,105,106,76,107,108,61,109,79,74,110,47,111,48,49,50,51,56,57,58,59,60,64,65,69,70,71,72,112,113,114,115,116,117,118,119,80,81,120,121,122,123,124,125,126,127,75,128,129,130,131,133,134,135])).then(t=>({default:t.FileExplorer}))),Ml=500;function Qx(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 eb(){const t=Zo(),{data:e}=ji.useSession(),{taskId:s,currentBranch:i,setCurrentTaskBranch:r}=rs(),[o,a]=A.useState("preview"),[l,h]=A.useState(null),c=A.useRef(null),d=o==="cms",[u,f]=A.useState(null),[p,m]=A.useState(384),_=A.useRef(!1),g=A.useRef(0),x=A.useRef(0),S=A.useRef(null),[v,b]=A.useState(!1),[k,w]=A.useState(""),N=A.useRef(null),[j,R]=A.useState(!1),[I,E]=A.useState(),[C,y]=A.useState(null),[T,D]=A.useState(null),[P,M]=A.useState("/"),B=e?.user?.id,F=t?.entity?.metadata,U=B&&i?vi(F?.sandboxMap?.[B]?.[i]):{},z=Object.values(U),O=z.find(Z=>Z.sandboxProviderKind!=="user-desktop")??z[0],q=O?.previewUrl??null,V=t?.entity?.id??null,{org:Q}=je(),G=ns(),W=G.lifecycle.phase,ee=W==="running",$=V&&i&&ee?{orgSlug:Q.slug,virtualMcpId:V,branch:i}:null,{data:L}=Po($,{fetchEnabled:ee}),{data:Y}=Do($,{fetchEnabled:ee}),X=V&&i?{orgSlug:Q.slug,virtualMcpId:V,branch:i}:null,H=Z_(X),ne=L?Bo(L).sort((Z,ue)=>Z.name.localeCompare(ue.name)):[],re=L&&Y?Io(L,Y):[],ce=pi,de=ne.filter(Z=>{if(!k)return!0;const ue=k.toLowerCase();return Z.name.toLowerCase().includes(ue)||Z.path.toLowerCase().includes(ue)}),me=re.filter(Z=>{if(!k)return!0;const ue=k.toLowerCase();return Z.name.toLowerCase().includes(ue)||Z.key.toLowerCase().includes(ue)||Z.resolveType.toLowerCase().includes(ue)}),le=C?C.name:ne.find(Z=>ce(Z.path)===ce(P))?.name,ve=A.useRef(null),xe=A.useRef(null);Xm(()=>{const Z=c.current,ue=ve.current;!Z||!ue||(Z.src=ue)});const Ne=A.useRef({url:"",value:!1});q&&Ne.current.url!==q&&(Ne.current={url:q,value:!1}),G.lifecycle.phase==="running"&&(Ne.current.value=G.lifecycle.htmlSupport);const Ee=Ne.current.value,mt=W==="running"?"online":W==="crashed"?"offline":"booting",Mt=G.suspended,Pe=G.status.state==="paused",St=Xe({connectionId:vs,orgId:t?.entity?.organization_id??"",orgSlug:Q.slug}),he=ho(St),be=he.error?.message??null,Ze=uo(V??void 0,i??void 0),tt=A.useRef(null),it=A.useRef(null),Li=G.phase,Kr=oh({claimPhase:Li,lifecycle:G.lifecycle}),Oi=!!V&&!!i&&Qi.isStopped(V,i),Qo=W==="start-failed"||W==="install-failed"||W==="clone-failed"?W:null,ud=Qo&&"error"in G.lifecycle?G.lifecycle.error??null:null,Te=rh({previewUrl:q,status:mt,htmlSupport:Ee,suspended:Mt,appPaused:Pe,vmStartPending:Ze,lastStartError:be,lifecycleFailure:Qo,lifecycleFailureError:ud,claimPhase:Li,notFound:G.notFound,userStopped:Oi}),kt=Te.kind==="iframe"?T??new URL(P,Te.previewUrl).href:null,[ea,fd]=A.useState(null);if(Te.kind==="iframe"&&ea!==Te.previewUrl){const Z=ea!==null;fd(Te.previewUrl),Z&&(xe.current=null,M("/"),D(null),y(null))}ve.current=kt;const Vr=!!V&&!!i&&!G.notFound&&!Oi&&!Mt&&!Pe&&(Li?.kind==="ready"||W!=="idle"),qr=Te.kind!=="iframe"&&(o==="visual"||o==="cms")?"preview":o,$i=Z=>{if(!V)return;const ue={virtualMcpId:V};i&&(ue.branch=i),he.mutate(ue,{onSuccess:Be=>{Be?.branch&&!i&&r(Be.branch)},onError:Be=>{console.error(`[preview] ${Z} SANDBOX_START failed`,Be)}})},Ys=A.useRef($i);Ys.current=$i,s&&O&&tt.current!==s&&(tt.current=s);const ta=!!s&&!!V&&!!B&&!!i&&!O&&!be&&!Oi&&!he.isPending&&tt.current!==s;A.useEffect(()=>{!ta||!s||(tt.current=s,Ys.current("auto-start"))},[ta,s,Oi]);const zi=G.notFound?O?.sandboxHandle??null:null;A.useEffect(()=>{!zi||!V||be||he.isPending||it.current!==zi&&(i&&Qi.isStopped(V,i)||(it.current=zi,Ys.current("self-heal")))},[zi,V,be,he.isPending,i]);const Xs=()=>{tt.current=null,it.current=null,he.reset(),Ys.current("auto-start")},md=Tr(),Fi=V??"__no-vmcp__",[pd,sa]=A.useState(null),ia=A.useRef(null);ia.current!==Fi&&(ia.current=Fi,sa(Yx(Fi)));const Gr=Te.kind==="never-started"?!1:pd??!1,Yr=Z=>{sa(Z),Xx(Fi,Z)},Xr=()=>Yr(!0),ra=async()=>{if(!V)return;const Z=i;if(!Z)return;const ue=O?.sandboxProviderKind;if(ue){Qi.mark(V,Z);try{await St.callTool({name:"SANDBOX_DELETE",arguments:{virtualMcpId:V,branch:Z,sandboxProviderKind:ue}})}catch{}Bd(md)}},_d=async()=>{await ra(),Ys.current("auto-start")};A.useEffect(()=>{if(!q)return;let Z;try{Z=new URL(q,window.location.href).origin}catch{return}const ue=Be=>{if(Be.origin===Z){if(Be.data?.type==="visual-editor::element-clicked"){const Qe=eg.safeParse(Be.data.payload);Qe.success&&h(Qe.data)}else if(Be.data?.type==="cms-editor::section-clicked"){const Qe=sg.safeParse(Be.data.payload);Qe.success&&f(Qe.data.sectionIndex)}}};return window.addEventListener("message",ue),()=>window.removeEventListener("message",ue)},[q]),A.useEffect(()=>{if(!v)return;const Z=ue=>{N.current?.contains(ue.target)||(b(!1),w(""))};return document.addEventListener("pointerdown",Z),()=>document.removeEventListener("pointerdown",Z)},[v]),A.useEffect(()=>{if(!d)return;const Z=Be=>{const Qe=Be.target;Qe&&Qe!==c.current&&(S.current=Qe)},ue=()=>{requestAnimationFrame(()=>{const Be=document.activeElement;(Be===document.body||Be===c.current)&&S.current&&S.current.focus()})};return document.addEventListener("focusin",Z),document.addEventListener("blur",ue,!0),()=>{document.removeEventListener("focusin",Z),document.removeEventListener("blur",ue,!0)}},[d]);const na=()=>{const Z=c.current?.contentWindow;Z&&Z.postMessage({type:"visual-editor::activate",script:tg},"*")},gd=()=>{const Z=c.current?.contentWindow;Z&&Z.postMessage({type:"visual-editor::deactivate"},"*")},oa=()=>{const Z=c.current?.contentWindow;Z&&Z.postMessage({type:"visual-editor::activate",script:ig},"*")},vd=()=>{const Z=c.current?.contentWindow;Z&&Z.postMessage({type:"cms-editor::deactivate"},"*")},aa=Z=>{const ue=o;a(Z),h(null),Z!=="cms"&&f(null),ue==="visual"&&gd(),ue==="cms"&&vd(),Z==="visual"&&na(),Z==="cms"&&oa()},xd=()=>{if(!c.current||!kt)return;const Z=c.current;Z.src=kt},bd=()=>{if(!c.current||!kt)return;const Z=kt.includes("?")?"&":"?";c.current.src=`${kt}${Z}_r=${Date.now()}`},yd=()=>{const Z=c.current?.contentWindow?.location?.href??kt??q;Z&&navigator.clipboard.writeText(Z)},Sd=(()=>{if(!q)return"No server running";if(C)return C.name;try{const Z=new URL(q),ue=P==="/"?"":P;return`${Z.host}${ue}`}catch{return q}})(),la=Z=>{xe.current=Z,y(null),D(null),M(Z),f(null)},wd=Z=>{if(!q||!Y){ae.error("Preview metadata not ready yet");return}xe.current=null;const ue=Lc(Y),Be=X_(q,ue,Z.key);y(Z),D(Be),f(null)},Cd=async({name:Z,path:ue})=>{if(!V||!i)return;const Be=$o(ue);if(Be){E(Be);return}const Qe=ue.trim().startsWith("/")?ue.trim():`/${ue.trim()}`;if(ne.some(Bt=>ce(Bt.path)===ce(Qe))){E(`A page with path "${Qe}" already exists.`);return}E(void 0);try{const Bt=await H.mutateAsync({name:Z,path:Qe});R(!1),ae.success(`Page "${Z}" created`),await new Promise(jd=>setTimeout(jd,Ml)),la(Bt.path),aa("cms")}catch(Bt){E(Bt instanceof Error?Bt.message:"Failed to create page")}},kd=[{value:"preview",icon:n.jsx(rc,{size:14}),tooltip:"Interactive"},...Te.kind==="iframe"?[{value:"visual",icon:n.jsx(pa,{size:14}),tooltip:"Visual editor"}]:[],...Te.kind==="iframe"&&$c(L,Y)?[{value:"cms",icon:n.jsx(Cu,{size:14}),tooltip:"Sections editor"}]:[],{value:"code",icon:n.jsx(nc,{size:14}),tooltip:"Code editor"}];return n.jsxs("div",{className:"flex flex-col w-full h-full",children:[Vr&&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(Ef,{value:qr,onValueChange:aa,options:kd,size:"sm",className:"shrink-0 bg-foreground/4.5"})}),Te.kind==="iframe"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:ie("flex min-w-0 flex-1 items-center gap-0.5",o==="code"&&"hidden"),children:[n.jsxs(Ce,{children:[n.jsx(Se,{asChild:!0,children:n.jsx(te,{variant:"ghost",size:"icon",onClick:xd,children:n.jsx(fs,{size:14})})}),n.jsx(we,{side:"bottom",children:"Refresh"})]}),n.jsxs("div",{ref:N,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(Z=>!Z),children:[C&&n.jsxs("span",{className:"shrink-0 inline-flex items-center gap-1 rounded bg-global-section/14 px-1.5 py-0.5 text-[11px] font-medium text-global-section-fg dark:text-global-section-fg-dark",children:[n.jsx(yr,{size:11}),"Global"]}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-left text-[12px] text-foreground/88",children:Sd}),le&&!C&&n.jsx("span",{className:"shrink-0 text-[12px] text-muted-foreground",children:le}),n.jsx(Or,{size:12,className:ie("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.jsxs("div",{className:"px-2 h-10 flex items-center gap-2 border-b",children:[n.jsx(yc,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),n.jsx("input",{type:"text",value:k,onChange:Z=>w(Z.target.value),placeholder:"Search pages and components...",className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground",autoFocus:!0})]}),n.jsx("div",{className:"p-1.5 border-b",children:n.jsxs("button",{type:"button",className:"flex w-full items-center gap-2.5 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:Z=>{Z.preventDefault(),b(!1),w(""),E(void 0),R(!0)},children:[n.jsx(Kt,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"flex-1 font-medium",children:"Create new page"})]})}),de.length===0&&me.length===0?n.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:ne.length===0&&re.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:[de.length>0&&n.jsx("div",{className:"p-1.5",children:de.map(Z=>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:ue=>{ue.preventDefault(),b(!1),w(""),la(Z.path)},children:[n.jsx(vo,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:Z.name}),n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:Z.path})]},Z.key))}),me.length>0&&n.jsxs("div",{className:ie("p-1.5",de.length>0&&"border-t"),children:[n.jsx("div",{className:"px-3 py-2 text-xs font-medium text-muted-foreground",children:"Global components"}),me.map(Z=>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:ue=>{ue.preventDefault(),b(!1),w(""),wd(Z)},children:[n.jsx(yr,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:Z.name}),n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:Z.resolveType.split("/").pop()?.replace(/\.tsx?$/,"")})]},Z.key))]})]})]})]})]}),n.jsxs("div",{className:ie("flex shrink-0 items-center gap-0.5",o==="code"&&"hidden"),children:[n.jsxs(Ce,{children:[n.jsx(Se,{asChild:!0,children:n.jsx(te,{variant:"ghost",size:"icon",onClick:()=>{const Z=kt??Te.previewUrl;Z&&window.open(Z,"_blank","noopener")},children:n.jsx(zs,{size:14})})}),n.jsx(we,{side:"bottom",children:"Open in new tab"})]}),n.jsxs(Fs,{children:[n.jsx(Hs,{asChild:!0,children:n.jsx(te,{variant:"ghost",size:"icon",children:n.jsx(Br,{size:14})})}),n.jsxs(Ws,{align:"end",children:[n.jsx(ut,{onClick:bd,children:"Hard Reload"}),n.jsx(ut,{onClick:yd,children:"Copy Current URL"})]})]})]})]})]}),n.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[d&&q&&i&&V&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"shrink-0 border-r overflow-hidden",style:{width:p},children:n.jsx(A.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(Jx,{orgSlug:Q.slug,virtualMcpId:V,branch:i,previewReady:ee,previewUrl:q,currentPath:P,activeGlobalBlockKey:C?.key??null,externalSelectedIndex:C?null:u,onSaved:()=>{setTimeout(()=>{const Z=c.current;if(!Z)return;const ue=document.activeElement,Be=Z.tabIndex;Z.tabIndex=-1,Z.style.pointerEvents="none",Z.blur();try{Z.contentWindow?.location.reload()}catch{const Bt=ve.current;Bt&&(Z.src=Bt)}const Qe=()=>{Z.tabIndex=Be,Z.style.pointerEvents="",ue?.focus(),Z.removeEventListener("load",Qe)};Z.addEventListener("load",Qe),setTimeout(Qe,3e3)},Ml)}})})}),n.jsx("div",{className:"w-1 shrink-0 cursor-col-resize bg-transparent hover:bg-border transition-colors",onPointerDown:Z=>{_.current=!0,g.current=Z.clientX,x.current=p,Z.currentTarget.setPointerCapture(Z.pointerId)},onPointerMove:Z=>{if(!_.current)return;const ue=Z.clientX-g.current;m(Math.max(240,Math.min(640,x.current+ue)))},onPointerUp:()=>{_.current=!1}})]}),n.jsxs("div",{className:"flex-1 relative overflow-hidden",children:[Te.kind==="never-started"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(xt,{kind:"never-started",onStart:()=>{Yr(!1),$i("auto-start")}})}),Te.kind==="starting-now"&&!(o==="code"&&Vr)&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(xt,{kind:"starting-now",progress:Kr,claimPhase:Li})}),Te.kind==="errored"&&n.jsx("div",{className:"absolute inset-0 z-40",children:n.jsx(xt,{kind:"errored",progress:Kr,logSource:"setup",errorLine:Te.error.split(`
|
|
288
|
+
`,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 kn.get()},set promptLabel(t){kn.set(t)},get tooMuchOutput(){return jn.get()},set tooMuchOutput(t){jn.set(t)}}}_verifyIntegers(...t){for(Nt of t)if(Nt===1/0||isNaN(Nt)||Nt%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(Nt of t)if(Nt&&(Nt===1/0||isNaN(Nt)||Nt%1!==0||Nt<0))throw new Error("This API only accepts positive integers")}};var Px=2,Dx=1,Ax=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(Px,Math.floor(d/t.css.cell.width)),rows:Math.max(Dx,Math.floor(c/t.css.cell.height))}}};function Qh({source:t,onReady:e,onSelectionChange:s,className:i}){const r=A.useRef(null),o=A.useRef(null),a=A.useRef(s);a.current=s;const l=ns(),h=A.useRef(t);return h.current=t,Ym((c,d)=>{c===h.current&&o.current?.write(d)}),A.useEffect(()=>{const c=r.current;if(!c)return;const d=getComputedStyle(document.documentElement),u=x=>d.getPropertyValue(x).trim()||void 0,f=new Rx({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")}}),p=new Ax;f.loadAddon(p),f.open(c),p.fit();const m=l.getBuffer(t);m&&f.write(m),o.current=f,e?.(f);const _=f.onSelectionChange(()=>{const x=!!f.getSelection();a.current?.(x,()=>f.getSelection())}),g=new ResizeObserver(()=>{p.fit()});return g.observe(c),()=>{_.dispose(),g.disconnect(),o.current=null,f.dispose()}},[]),n.jsx("div",{className:ie("h-full bg-sidebar p-3",i),children:n.jsx("div",{ref:r,className:"h-full"})})}function xt(t){const e=K.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(pg,{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(Mx,{kind:t.kind}),i=n.jsx(Bx,{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(Ix,{...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(Lx,{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(Ox,{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($x,{...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 Mx(t){const e=K.c(5),{kind:s}=t;switch(s){case"never-started":{let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(rc,{className:ie("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(ui,{className:ie("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(ui,{className:ie("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(wu,{className:ie("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(ui,{className:ie("size-12","text-amber-500")}),e[4]=i):i=e[4],i}}}function Bx(t){const e=K.c(4),{kind:s}=t;let i;e[0]!==s?(i=lg(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 Ix(t){const e=K.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 Lx(t){const e=K.c(21),{progress:s}=t;let i;e[0]!==s?(i=Wi(s,"provision"),e[0]=s,e[1]=i):i=e[1];let r;e[2]!==i?(r=n.jsx(Ji,{label:"provision",status:i}),e[2]=i,e[3]=r):r=e[3];let o;e[4]!==s?(o=Wi(s,"cloning"),e[4]=s,e[5]=o):o=e[5];let a;e[6]!==o?(a=n.jsx(Ji,{label:"cloning",status:o}),e[6]=o,e[7]=a):a=e[7];let l;e[8]!==s?(l=Wi(s,"install"),e[8]=s,e[9]=l):l=e[9];let h;e[10]!==l?(h=n.jsx(Ji,{label:"install",status:l}),e[10]=l,e[11]=h):h=e[11];let c;e[12]!==s?(c=Wi(s,"dev"),e[12]=s,e[13]=c):c=e[13];let d;e[14]!==c?(d=n.jsx(Ji,{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 Ji(t){const e=K.c(12),{label:s,status:i}=t;let r;e[0]!==i?(r=ag(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=ie("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 Ox(t){const e=K.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(Qh,{source:s,className:"h-full"})})}),e[0]=s,e[1]=i):i=e[1],i}function $x(t){const e=K.c(25);switch(t.kind){case"never-started":{let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(ms,{className:"size-4"}),e[0]=s):s=e[0];let i;return e[1]!==t.onStart?(i=n.jsxs(te,{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(fs,{className:"size-4"}),e[3]=s):s=e[3];let i;return e[4]!==t.onRetry?(i=n.jsxs(te,{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(fs,{className:"size-4"}),e[6]=s):s=e[6];let i;e[7]!==t.onRetry?(i=n.jsxs(te,{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(nc,{className:"size-4"}),e[9]=r):r=e[9];let o;e[10]!==t.onBrowseFiles?(o=n.jsxs(te,{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(vn,{className:"size-4"}),e[12]=a):a=e[12];let l;e[13]!==t.onOpenTerminal?(l=n.jsxs(te,{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(ms,{className:"size-4"}),e[19]=s):s=e[19];let i;return e[20]!==t.onResume?(i=n.jsxs(te,{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(vn,{className:"size-4"}),e[22]=s):s=e[22];let i;return e[23]!==t.onOpenTerminal?(i=n.jsxs(te,{onClick:t.onOpenTerminal,className:"mt-2",children:[s," Open terminal"]}),e[23]=t.onOpenTerminal,e[24]=i):i=e[24],i}}}const zx=["dev","start"],us="setup";function Fx(t){const e=K.c(35);let s;if(e[0]!==t.scriptTabs||e[1]!==t.scripts){let p;e[3]!==t.scriptTabs?(p=m=>!t.scriptTabs.includes(m),e[3]=t.scriptTabs,e[4]=p):p=e[4],s=t.scripts.filter(p),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===us?t.onToggle():t.onSelectTab(us)},e[5]=t,e[6]=r):r=e[6];const o=r,a=t.active===us;let l;e[7]!==o||e[8]!==t.open||e[9]!==a?(l=n.jsx(Hx,{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(p=>n.jsx(Ux,{active:t.active===p,onClick:()=>t.onSelectTab(p),onClose:()=>t.onCloseScript(p),children:p},p)),e[11]=t,e[12]=h):h=e[12];let c;e[13]!==i||e[14]!==t.onAddScript?(c=n.jsx(Kx,{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(Vx,{isRunning:t.scriptIsRunning,isKilling:t.scriptIsKilling,onRun:t.onRunActiveScript,onStop:t.onStopActiveScript}):n.jsx(Wx,{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 Hx(t){const e=K.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=ie("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(vn,{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 Wx(t){const e=K.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(ms,{className:"size-3.5"}),e[0]=h):h=e[0];let c;return e[1]!==i?(c=n.jsxs(te,{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(ms,{className:"size-3.5"}),e[3]=h):h=e[3];let c;return e[4]!==a?(c=n.jsxs(te,{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(fs,{className:"size-3.5"}),e[6]=h):h=e[6];let c;return e[7]!==l?(c=n.jsxs(te,{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=ie(c),e[9]=c,e[10]=d):d=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(oc,{className:"size-3.5"}),e[11]=u):u=e[11];let f;e[12]!==r||e[13]!==d?(f=n.jsx(Se,{asChild:!0,children:n.jsxs(te,{variant:"outline",size:"sm",onClick:r,className:d,children:[u," Stop"]})}),e[12]=r,e[13]=d,e[14]=f):f=e[14];let p;e[15]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(we,{children:"Stop sandbox"}),e[15]=p):p=e[15];let m;e[16]!==f?(m=n.jsxs(Ce,{children:[f,p]}),e[16]=f,e[17]=m):m=e[17];let _;e[18]!==o||e[19]!==h?(_=h&&n.jsxs(Fs,{children:[n.jsx(Hs,{asChild:!0,children:n.jsx(te,{variant:"outline",size:"sm",className:"rounded-l-none px-1",children:n.jsx(Or,{className:"size-3"})})}),n.jsx(Ws,{align:"end",children:n.jsxs(ut,{onClick:o,children:[n.jsx(fs,{className:"size-3.5"})," Restart"]})})]}),e[18]=o,e[19]=h,e[20]=_):_=e[20];let g;return e[21]!==m||e[22]!==_?(g=n.jsxs("div",{className:"flex items-center",children:[m,_]}),e[21]=m,e[22]=_,e[23]=g):g=e[23],g}return null}function Ux(t){const e=K.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=ie("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=ie("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(Tf,{className:"size-3"})}),e[9]=o,e[10]=r,e[11]=f):f=e[11];let p;return e[12]!==l||e[13]!==u||e[14]!==f?(p=n.jsxs("div",{className:l,children:[u,f]}),e[12]=l,e[13]=u,e[14]=f,e[15]=p):p=e[15],p}function Kx(t){const e=K.c(10),{scripts:s,onRun:i}=t,[r,o]=A.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs(Ce,{children:[n.jsx(Se,{asChild:!0,children:n.jsx(Os,{asChild:!0,children:n.jsx(te,{variant:"ghost",size:"sm","aria-label":"Run script",children:n.jsx(Kt,{className:"size-3.5"})})})}),n.jsx(we,{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($s,{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(Ls,{open:r,onOpenChange:o,children:[a,c]}),e[7]=r,e[8]=c,e[9]=d):d=e[9],d}function Vx(t){const e=K.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(te,{variant:"outline",size:"sm",disabled:!0,children:[n.jsx(ge,{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(ms,{className:"size-3.5"}),e[1]=d):d=e[1];let u;e[2]!==r?(u=n.jsx(Se,{asChild:!0,children:n.jsxs(te,{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(we,{children:"Start process"}),e[4]=f):f=e[4];let p;return e[5]!==u?(p=n.jsxs(Ce,{children:[u,f]}),e[5]=u,e[6]=p):p=e[6],p}let a;e[7]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(oc,{className:"size-3.5"}),e[7]=a):a=e[7];let l;e[8]!==o?(l=n.jsx(Se,{asChild:!0,children:n.jsxs(te,{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(we,{children:"Stop process"}),e[10]=h):h=e[10];let c;return e[11]!==l?(c=n.jsxs(Ce,{children:[l,h]}),e[11]=l,e[12]=c):c=e[12],c}function qx(t){const e=ns(),[s,i]=A.useState(us),[r,o]=A.useState([]),[a,l]=A.useState(new Set),h=A.useRef(!1);if(!h.current&&e.scripts.length>0){const b=zx.find(k=>e.scripts.includes(k));b&&(h.current=!0,o(k=>k.includes(b)?k:[...k,b]),i(b))}if(a.size>0){let b=!1;const k=new Set(a);for(const w of a)e.activeProcesses.includes(w)||(k.delete(w),b=!0);b&&l(k)}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"}),p=async b=>{o(k=>k.includes(b)?k:[...k,b]),i(b),t.onOpenChange(!0);try{const k=await u(b);if(k===null)return;if(!k.ok)throw new Error(`Exec failed: ${k.statusText}`)}catch{ae.error("Failed to run "+b)}},m=async b=>{await f(b),o(k=>k.filter(w=>w!==b)),s===b&&i(us)},_=async()=>{const b=e.activeProcesses.includes(s);try{const k=await u(s);if(k===null)return;if(!k.ok)throw new Error(`Exec failed: ${k.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(k=>{const w=new Set(k);return w.delete(s),w});return}if(!b.ok)throw new Error(`Kill failed: ${b.statusText}`)}catch{l(b=>{const k=new Set(b);return k.delete(s),k}),ae.error("Failed to stop "+s)}}},x=s!==us&&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(Fx,{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:p,onCloseScript:m,showScriptControls:x,scriptIsRunning:S,scriptIsKilling:v,onRunActiveScript:_,onStopActiveScript:g}),t.open&&n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(Gx,{vmId:t.vmId,active:s,hasData:e.hasData(s),onRunActive:_})})]})}function Gx(t){const e=K.c(10),{vmId:s,active:i,hasData:r,onRunActive:o}=t;if(!s)return null;if(i===us||r){let d;return e[0]!==i?(d=n.jsx(Qh,{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(ms,{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 ed=t=>`preview-drawer:${t}`;function Yx(t){try{const e=localStorage.getItem(ed(t));return e?!!JSON.parse(e).open:!1}catch{return!1}}function Xx(t,e){try{localStorage.setItem(ed(t),JSON.stringify({open:e}))}catch{}}const Jx=A.lazy(()=>Ni(()=>import("./sections-editor-DH5JOAp0.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}))),Zx=A.lazy(()=>Ni(()=>import("./file-explorer-DNXKqBDW.js"),__vite__mapDeps([136,1,2,132,103,3,4,6,7,8,9,10,11,12,13,14,15,16,17,5,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,84,85,54,86,87,88,53,89,55,96,97,45,98,99,100,83,90,91,92,93,94,95,62,101,52,102,67,68,46,66,63,77,104,105,106,76,107,108,61,109,79,74,110,47,111,48,49,50,51,56,57,58,59,60,64,65,69,70,71,72,112,113,114,115,116,117,118,119,80,81,120,121,122,123,124,125,126,127,75,128,129,130,131,133,134,135])).then(t=>({default:t.FileExplorer}))),Ml=500;function Qx(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 eb(){const t=Zo(),{data:e}=ji.useSession(),{taskId:s,currentBranch:i,setCurrentTaskBranch:r}=rs(),[o,a]=A.useState("preview"),[l,h]=A.useState(null),c=A.useRef(null),d=o==="cms",[u,f]=A.useState(null),[p,m]=A.useState(384),_=A.useRef(!1),g=A.useRef(0),x=A.useRef(0),S=A.useRef(null),[v,b]=A.useState(!1),[k,w]=A.useState(""),N=A.useRef(null),[j,R]=A.useState(!1),[I,E]=A.useState(),[C,y]=A.useState(null),[T,D]=A.useState(null),[P,M]=A.useState("/"),B=e?.user?.id,F=t?.entity?.metadata,U=B&&i?vi(F?.sandboxMap?.[B]?.[i]):{},z=Object.values(U),O=z.find(Z=>Z.sandboxProviderKind!=="user-desktop")??z[0],q=O?.previewUrl??null,V=t?.entity?.id??null,{org:Q}=je(),G=ns(),W=G.lifecycle.phase,ee=W==="running",$=V&&i&&ee?{orgSlug:Q.slug,virtualMcpId:V,branch:i}:null,{data:L}=Po($,{fetchEnabled:ee}),{data:Y}=Do($,{fetchEnabled:ee}),X=V&&i?{orgSlug:Q.slug,virtualMcpId:V,branch:i}:null,H=Z_(X),ne=L?Bo(L).sort((Z,ue)=>Z.name.localeCompare(ue.name)):[],re=L&&Y?Io(L,Y):[],ce=pi,de=ne.filter(Z=>{if(!k)return!0;const ue=k.toLowerCase();return Z.name.toLowerCase().includes(ue)||Z.path.toLowerCase().includes(ue)}),me=re.filter(Z=>{if(!k)return!0;const ue=k.toLowerCase();return Z.name.toLowerCase().includes(ue)||Z.key.toLowerCase().includes(ue)||Z.resolveType.toLowerCase().includes(ue)}),le=C?C.name:ne.find(Z=>ce(Z.path)===ce(P))?.name,ve=A.useRef(null),xe=A.useRef(null);Xm(()=>{const Z=c.current,ue=ve.current;!Z||!ue||(Z.src=ue)});const Ne=A.useRef({url:"",value:!1});q&&Ne.current.url!==q&&(Ne.current={url:q,value:!1}),G.lifecycle.phase==="running"&&(Ne.current.value=G.lifecycle.htmlSupport);const Ee=Ne.current.value,mt=W==="running"?"online":W==="crashed"?"offline":"booting",Mt=G.suspended,Pe=G.status.state==="paused",St=Xe({connectionId:vs,orgId:t?.entity?.organization_id??"",orgSlug:Q.slug}),he=ho(St),be=he.error?.message??null,Ze=uo(V??void 0,i??void 0),tt=A.useRef(null),it=A.useRef(null),Li=G.phase,Kr=oh({claimPhase:Li,lifecycle:G.lifecycle}),Oi=!!V&&!!i&&Qi.isStopped(V,i),Qo=W==="start-failed"||W==="install-failed"||W==="clone-failed"?W:null,ud=Qo&&"error"in G.lifecycle?G.lifecycle.error??null:null,Te=rh({previewUrl:q,status:mt,htmlSupport:Ee,suspended:Mt,appPaused:Pe,vmStartPending:Ze,lastStartError:be,lifecycleFailure:Qo,lifecycleFailureError:ud,claimPhase:Li,notFound:G.notFound,userStopped:Oi}),kt=Te.kind==="iframe"?T??new URL(P,Te.previewUrl).href:null,[ea,fd]=A.useState(null);if(Te.kind==="iframe"&&ea!==Te.previewUrl){const Z=ea!==null;fd(Te.previewUrl),Z&&(xe.current=null,M("/"),D(null),y(null))}ve.current=kt;const Vr=!!V&&!!i&&!G.notFound&&!Oi&&!Mt&&!Pe&&(Li?.kind==="ready"||W!=="idle"),qr=Te.kind!=="iframe"&&(o==="visual"||o==="cms")?"preview":o,$i=Z=>{if(!V)return;const ue={virtualMcpId:V};i&&(ue.branch=i),he.mutate(ue,{onSuccess:Be=>{Be?.branch&&!i&&r(Be.branch)},onError:Be=>{console.error(`[preview] ${Z} SANDBOX_START failed`,Be)}})},Ys=A.useRef($i);Ys.current=$i,s&&O&&tt.current!==s&&(tt.current=s);const ta=!!s&&!!V&&!!B&&!!i&&!O&&!be&&!Oi&&!he.isPending&&tt.current!==s;A.useEffect(()=>{!ta||!s||(tt.current=s,Ys.current("auto-start"))},[ta,s,Oi]);const zi=G.notFound?O?.sandboxHandle??null:null;A.useEffect(()=>{!zi||!V||be||he.isPending||it.current!==zi&&(i&&Qi.isStopped(V,i)||(it.current=zi,Ys.current("self-heal")))},[zi,V,be,he.isPending,i]);const Xs=()=>{tt.current=null,it.current=null,he.reset(),Ys.current("auto-start")},md=Tr(),Fi=V??"__no-vmcp__",[pd,sa]=A.useState(null),ia=A.useRef(null);ia.current!==Fi&&(ia.current=Fi,sa(Yx(Fi)));const Gr=Te.kind==="never-started"?!1:pd??!1,Yr=Z=>{sa(Z),Xx(Fi,Z)},Xr=()=>Yr(!0),ra=async()=>{if(!V)return;const Z=i;if(!Z)return;const ue=O?.sandboxProviderKind;if(ue){Qi.mark(V,Z);try{await St.callTool({name:"SANDBOX_DELETE",arguments:{virtualMcpId:V,branch:Z,sandboxProviderKind:ue}})}catch{}Bd(md)}},_d=async()=>{await ra(),Ys.current("auto-start")};A.useEffect(()=>{if(!q)return;let Z;try{Z=new URL(q,window.location.href).origin}catch{return}const ue=Be=>{if(Be.origin===Z){if(Be.data?.type==="visual-editor::element-clicked"){const Qe=eg.safeParse(Be.data.payload);Qe.success&&h(Qe.data)}else if(Be.data?.type==="cms-editor::section-clicked"){const Qe=sg.safeParse(Be.data.payload);Qe.success&&f(Qe.data.sectionIndex)}}};return window.addEventListener("message",ue),()=>window.removeEventListener("message",ue)},[q]),A.useEffect(()=>{if(!v)return;const Z=ue=>{N.current?.contains(ue.target)||(b(!1),w(""))};return document.addEventListener("pointerdown",Z),()=>document.removeEventListener("pointerdown",Z)},[v]),A.useEffect(()=>{if(!d)return;const Z=Be=>{const Qe=Be.target;Qe&&Qe!==c.current&&(S.current=Qe)},ue=()=>{requestAnimationFrame(()=>{const Be=document.activeElement;(Be===document.body||Be===c.current)&&S.current&&S.current.focus()})};return document.addEventListener("focusin",Z),document.addEventListener("blur",ue,!0),()=>{document.removeEventListener("focusin",Z),document.removeEventListener("blur",ue,!0)}},[d]);const na=()=>{const Z=c.current?.contentWindow;Z&&Z.postMessage({type:"visual-editor::activate",script:tg},"*")},gd=()=>{const Z=c.current?.contentWindow;Z&&Z.postMessage({type:"visual-editor::deactivate"},"*")},oa=()=>{const Z=c.current?.contentWindow;Z&&Z.postMessage({type:"visual-editor::activate",script:ig},"*")},vd=()=>{const Z=c.current?.contentWindow;Z&&Z.postMessage({type:"cms-editor::deactivate"},"*")},aa=Z=>{const ue=o;a(Z),h(null),Z!=="cms"&&f(null),ue==="visual"&&gd(),ue==="cms"&&vd(),Z==="visual"&&na(),Z==="cms"&&oa()},xd=()=>{if(!c.current||!kt)return;const Z=c.current;Z.src=kt},bd=()=>{if(!c.current||!kt)return;const Z=kt.includes("?")?"&":"?";c.current.src=`${kt}${Z}_r=${Date.now()}`},yd=()=>{const Z=c.current?.contentWindow?.location?.href??kt??q;Z&&navigator.clipboard.writeText(Z)},Sd=(()=>{if(!q)return"No server running";if(C)return C.name;try{const Z=new URL(q),ue=P==="/"?"":P;return`${Z.host}${ue}`}catch{return q}})(),la=Z=>{xe.current=Z,y(null),D(null),M(Z),f(null)},wd=Z=>{if(!q||!Y){ae.error("Preview metadata not ready yet");return}xe.current=null;const ue=Lc(Y),Be=X_(q,ue,Z.key);y(Z),D(Be),f(null)},Cd=async({name:Z,path:ue})=>{if(!V||!i)return;const Be=$o(ue);if(Be){E(Be);return}const Qe=ue.trim().startsWith("/")?ue.trim():`/${ue.trim()}`;if(ne.some(Bt=>ce(Bt.path)===ce(Qe))){E(`A page with path "${Qe}" already exists.`);return}E(void 0);try{const Bt=await H.mutateAsync({name:Z,path:Qe});R(!1),ae.success(`Page "${Z}" created`),await new Promise(jd=>setTimeout(jd,Ml)),la(Bt.path),aa("cms")}catch(Bt){E(Bt instanceof Error?Bt.message:"Failed to create page")}},kd=[{value:"preview",icon:n.jsx(rc,{size:14}),tooltip:"Interactive"},...Te.kind==="iframe"?[{value:"visual",icon:n.jsx(pa,{size:14}),tooltip:"Visual editor"}]:[],...Te.kind==="iframe"&&$c(L,Y)?[{value:"cms",icon:n.jsx(Cu,{size:14}),tooltip:"Sections editor"}]:[],{value:"code",icon:n.jsx(nc,{size:14}),tooltip:"Code editor"}];return n.jsxs("div",{className:"flex flex-col w-full h-full",children:[Vr&&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(Ef,{value:qr,onValueChange:aa,options:kd,size:"sm",className:"shrink-0 bg-foreground/4.5"})}),Te.kind==="iframe"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:ie("flex min-w-0 flex-1 items-center gap-0.5",o==="code"&&"hidden"),children:[n.jsxs(Ce,{children:[n.jsx(Se,{asChild:!0,children:n.jsx(te,{variant:"ghost",size:"icon",onClick:xd,children:n.jsx(fs,{size:14})})}),n.jsx(we,{side:"bottom",children:"Refresh"})]}),n.jsxs("div",{ref:N,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(Z=>!Z),children:[C&&n.jsxs("span",{className:"shrink-0 inline-flex items-center gap-1 rounded bg-global-section/14 px-1.5 py-0.5 text-[11px] font-medium text-global-section-fg dark:text-global-section-fg-dark",children:[n.jsx(yr,{size:11}),"Global"]}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-left text-[12px] text-foreground/88",children:Sd}),le&&!C&&n.jsx("span",{className:"shrink-0 text-[12px] text-muted-foreground",children:le}),n.jsx(Or,{size:12,className:ie("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.jsxs("div",{className:"px-2 h-10 flex items-center gap-2 border-b",children:[n.jsx(yc,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),n.jsx("input",{type:"text",value:k,onChange:Z=>w(Z.target.value),placeholder:"Search pages and components...",className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground",autoFocus:!0})]}),n.jsx("div",{className:"p-1.5 border-b",children:n.jsxs("button",{type:"button",className:"flex w-full items-center gap-2.5 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:Z=>{Z.preventDefault(),b(!1),w(""),E(void 0),R(!0)},children:[n.jsx(Kt,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"flex-1 font-medium",children:"Create new page"})]})}),de.length===0&&me.length===0?n.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:ne.length===0&&re.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:[de.length>0&&n.jsx("div",{className:"p-1.5",children:de.map(Z=>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:ue=>{ue.preventDefault(),b(!1),w(""),la(Z.path)},children:[n.jsx(vo,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:Z.name}),n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:Z.path})]},Z.key))}),me.length>0&&n.jsxs("div",{className:ie("p-1.5",de.length>0&&"border-t"),children:[n.jsx("div",{className:"px-3 py-2 text-xs font-medium text-muted-foreground",children:"Global components"}),me.map(Z=>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:ue=>{ue.preventDefault(),b(!1),w(""),wd(Z)},children:[n.jsx(yr,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:Z.name}),n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:Z.resolveType.split("/").pop()?.replace(/\.tsx?$/,"")})]},Z.key))]})]})]})]})]}),n.jsxs("div",{className:ie("flex shrink-0 items-center gap-0.5",o==="code"&&"hidden"),children:[n.jsxs(Ce,{children:[n.jsx(Se,{asChild:!0,children:n.jsx(te,{variant:"ghost",size:"icon",onClick:()=>{const Z=kt??Te.previewUrl;Z&&window.open(Z,"_blank","noopener")},children:n.jsx(zs,{size:14})})}),n.jsx(we,{side:"bottom",children:"Open in new tab"})]}),n.jsxs(Fs,{children:[n.jsx(Hs,{asChild:!0,children:n.jsx(te,{variant:"ghost",size:"icon",children:n.jsx(Br,{size:14})})}),n.jsxs(Ws,{align:"end",children:[n.jsx(ut,{onClick:bd,children:"Hard Reload"}),n.jsx(ut,{onClick:yd,children:"Copy Current URL"})]})]})]})]})]}),n.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[d&&q&&i&&V&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"shrink-0 border-r overflow-hidden",style:{width:p},children:n.jsx(A.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(Jx,{orgSlug:Q.slug,virtualMcpId:V,branch:i,previewReady:ee,previewUrl:q,currentPath:P,activeGlobalBlockKey:C?.key??null,externalSelectedIndex:C?null:u,onSaved:()=>{setTimeout(()=>{const Z=c.current;if(!Z)return;const ue=document.activeElement,Be=Z.tabIndex;Z.tabIndex=-1,Z.style.pointerEvents="none",Z.blur();try{Z.contentWindow?.location.reload()}catch{const Bt=ve.current;Bt&&(Z.src=Bt)}const Qe=()=>{Z.tabIndex=Be,Z.style.pointerEvents="",ue?.focus(),Z.removeEventListener("load",Qe)};Z.addEventListener("load",Qe),setTimeout(Qe,3e3)},Ml)}})})}),n.jsx("div",{className:"w-1 shrink-0 cursor-col-resize bg-transparent hover:bg-border transition-colors",onPointerDown:Z=>{_.current=!0,g.current=Z.clientX,x.current=p,Z.currentTarget.setPointerCapture(Z.pointerId)},onPointerMove:Z=>{if(!_.current)return;const ue=Z.clientX-g.current;m(Math.max(240,Math.min(640,x.current+ue)))},onPointerUp:()=>{_.current=!1}})]}),n.jsxs("div",{className:"flex-1 relative overflow-hidden",children:[Te.kind==="never-started"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(xt,{kind:"never-started",onStart:()=>{Yr(!1),$i("auto-start")}})}),Te.kind==="starting-now"&&!(o==="code"&&Vr)&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(xt,{kind:"starting-now",progress:Kr,claimPhase:Li})}),Te.kind==="errored"&&n.jsx("div",{className:"absolute inset-0 z-40",children:n.jsx(xt,{kind:"errored",progress:Kr,logSource:"setup",errorLine:Te.error.split(`
|
|
289
289
|
`)[0]??"Failed to start",onRetry:Xs,drawerOpen:Gr})}),Te.kind==="dev-script-failed"&&o!=="code"&&n.jsx("div",{className:"absolute inset-0 z-40",children:n.jsx(xt,{kind:"dev-script-failed",progress:Kr,logSource:Te.failure==="start-failed"?"dev":"setup",errorLine:Te.error.split(`
|
|
290
|
-
`)[0]??"Dev script exited",onRetry:Xs,onOpenTerminal:Xr,onBrowseFiles:()=>a("code"),drawerOpen:Gr})}),Te.kind==="suspended"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(xt,{kind:"suspended",onResume:Xs})}),Te.kind==="crashed"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(xt,{kind:"crashed",onOpenTerminal:Xr})}),Te.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(_a,{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(te,{onClick:Xr,children:[n.jsx(_a,{size:14}),"View Logs"]})]}),qr==="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(pa,{size:12}),"Click any element to ask the AI"]}),qr==="visual"&&l&&n.jsx(og,{element:l,onDismiss:()=>h(null)}),o==="code"&&Vr&&V&&i&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(A.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(Zx,{orgSlug:Q.slug,virtualMcpId:V,branch:i})})}),Te.kind==="iframe"&&kt&&n.jsx("iframe",{ref:c,src:kt,className:ie("w-full h-full border-0",o==="code"&&"invisible"),title:"Dev Server Preview",tabIndex:d?-1:void 0,onLoad:()=>{if(Me("vm_preview_loaded",{view_mode:o,vm_id:O?.sandboxHandle??null}),!C)try{const Z=c.current?.contentWindow?.location?.pathname;if(!Z)return;const ue=xe.current;if(ue!==null){xe.current=null,ce(Z)===ce(ue)&&M(Z);return}M(Z)}catch{}o==="visual"&&na(),o==="cms"&&oa()}},Te.previewUrl)]})]}),n.jsx(qx,{vmId:O?.sandboxHandle??null,orgSlug:Q.slug,virtualMcpId:V,branch:i,status:Qx(Te,Ze),scripts:G.scripts,open:Gr,onOpenChange:Yr,onStart:()=>$i("auto-start"),onStop:ra,onRestart:_d,onResume:Xs,onRetry:Xs},O?.sandboxHandle??"no-vm"),n.jsx(Q_,{open:j,onOpenChange:R,isPending:H.isPending,error:I,onSubmit:Cd})]})}function tb(t){const e=K.c(2),{virtualMcpId:s}=t,i=At(s);if(!Ei(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(Ti,{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(eb,{}),e[1]=o):o=e[1],o}function td(t){if(!t||t.includes("/")||t.includes("\\")||t.includes(".."))throw new Error(`Invalid block key: ${t||"(empty)"}`)}function sb(t){return td(t),`.deco/blocks/${t}.json`}function ib({orgSlug:t,virtualMcpId:e,branch:s}){const i=Tr();return Rr({mutationFn:async({blockKey:r})=>{td(r);const o=sb(r),a=await fetch(`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/unlink`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:o})});if(!a.ok){const l=await a.json().catch(()=>({}));throw new Error(l.error??`Delete failed (${a.status})`)}return a.json()},onMutate:async({blockKey:r})=>{const o=`${t}/${e}/${s}`,a=Ut.decofile(o);await i.cancelQueries({queryKey:a});const l=i.getQueryData(a);return i.setQueryData(a,h=>{if(!h)return h;const{[r]:c,...d}=h;return d}),{previous:l,queryKey:a}},onError:(r,o,a)=>{a?.queryKey&&i.setQueryData(a.queryKey,a.previous)},onSuccess:()=>{const r=`${t}/${e}/${s}`;i.invalidateQueries({queryKey:Ut.liveMeta(r)})}})}const rb=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function nb(t){return t.includes("matchers")||t.includes("Match")}function ob(t,e){const s=t.__resolveType;return typeof s!="string"||!s||rb.has(s)?!1:e?Tm(e,s):nb(s)}function Ii(t,e,s){if(!t)return!1;const i=t.__resolveType;if(typeof i!="string"||!Ao(i)||!Object.hasOwn(e,i))return!1;const r=e[i];return!r||typeof r!="object"||Array.isArray(r)?!1:ob(r,s)}function YS(t,e,s){return Ii(t,e,s)?t?.__resolveType??null:null}function sd(t,e,s){if(!t)return null;const i=t.__resolveType??"";if(!i)return null;if(Ii(t,e,s)){const a=e[i]??{},l=a.__resolveType??i,{__resolveType:h,name:c,...d}=a;return{resolveType:l,data:d,blockKey:i}}const{__resolveType:r,...o}=t;return{resolveType:i,data:o}}function ab(t,e,s){const i=sd(t,e,s);return i?{__resolveType:i.resolveType,...i.data}:{__resolveType:""}}function XS(t,e,s){if(t)return Ii(t,e,s)?ab(t,e,s):t}function lb(t,e,s,i){if(!t)return"Default";if(Ii(t,e,i)){const r=t.__resolveType??"",o=e[r];return zc(r,o)}return s(t)}function JS(t,e,s){return{__resolveType:t,...e,name:s}}function ZS(t){return{__resolveType:t}}function QS(t,e,s){const i=sd(t,e,s);return i?{resolveType:i.resolveType,formValue:i.data}:{resolveType:"",formValue:{}}}function ew(t){return{__resolveType:Bm,variants:[{value:t,rule:{__resolveType:Ac}}]}}function tw(t){const r=($r(t.__resolveType)?t.section:t)?.variants?.[0];return r?.rule?.__resolveType!==Ac?null:r?.value??null}const cb=["website/matchers/always.ts","$live/matchers/MatchAlways.ts"];function id(t){if(!t)return!1;const e=t.__resolveType??"";return e===""?Object.keys(t).length===0:cb.includes(e)||e.includes("always")}function hb(t){const e=t.variants??[];if(e.length===0)return-1;const s=e.findIndex(i=>id(i.rule));return s!==-1?s:e.length-1}function sw(t,e,s){const i=s.variants??[];if(i.length===0)return null;const r=hb(s),o=i[r]?.value;if(!o)return null;const a=structuredClone(o);return e.isLazy?{...t,section:a}:a}function iw(t,e){return e.isMultivariate?e.isLazy?t.section??null:t:null}function rw(t,e){return Array.isArray(t.variants)?t.variants.map((s,i)=>({label:e(s.rule)||`Variant ${i+1}`,value:s.value??{},rule:s.rule})):[]}function nw(t,e){const s=t.__resolveType??"";if(!s)return null;if($r(s)){const i=t.section??t,r=i.__resolveType??s;if(!r.includes("/")&&r in e){const o=e[r]??{};return{data:{...o},resolveType:o.__resolveType??r}}return{data:{...i},resolveType:r}}if(!s.includes("/")&&s in e){const i=e[s]??{};return{data:{...i},resolveType:i.__resolveType??s}}return{data:{...t},resolveType:s}}function db(t,e){const s=t.__resolveType??"";return $r(s)?{...t,section:e}:e}function ow(t,e,s){return e.isLazy?{...t,section:s}:s}function aw(t,e,s){const i=[...t.variants??[]],r=i[e];if(!r)return t;const o=r.value??{};return i[e]={...r,value:db(o,s)},{...t,variants:i}}function lw(t,e,s){const i=[...t.variants??[]];return i[e]?(i[e]={...i[e],rule:s},{...t,variants:i}):t}function cw(t,e){const s=[...t.variants??[]],i=s[e];return i?(s.splice(e+1,0,structuredClone(i)),{...t,variants:s}):t}function hw(t,e){const s=[...t.variants??[]];return s.length<=1?null:(s.splice(e,1),{...t,variants:s})}const ub=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function fb(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t;return typeof e.__resolveType=="string"&&ub.has(e.__resolveType)&&typeof e.path=="string"}function rd(t,e){const i=t[e]?.sections;if(!i||Array.isArray(i))return 1;const r=i;return Array.isArray(r.variants)?r.variants.length:1}function mb(t,e,s){const r=t[e]?.sections;if(Array.isArray(r))return s===0?r:[];if(r&&typeof r=="object"){const o=r.variants;if(Array.isArray(o)){const a=o[s];return Array.isArray(a?.value)?a.value:[]}}return[]}function dw(t,e,s){if(Array.isArray(t))return[{label:"Default",sections:t}];if(t&&typeof t=="object"){const i=t;if(Array.isArray(i.variants)){const r=i.variants,o=r.map(h=>lb(h.rule,e,s)),a=o.reduce((h,c)=>(h[c]=(h[c]??0)+1,h),{}),l={};return r.map((h,c)=>{const d=o[c]??`Variant ${c+1}`,u=a[d]??1;let f=d;return u>1&&(l[d]=(l[d]??0)+1,f=`${d} ${l[d]}`),{label:f||`Variant ${c+1}`,sections:Array.isArray(h.value)?h.value:[],rule:h.rule}})}}return[]}function pb(){return{__resolveType:Am}}function ri(t){return{rule:pb(),value:t}}function Ds(t,e){return{...e,__resolveType:Mm,variants:t}}function _b(t,e){const s=structuredClone(e);if(Array.isArray(t))return Ds([ri(t),ri(s)]);if(t&&typeof t=="object"){const i=t;return Array.isArray(i.variants)?Ds([...i.variants,ri(s)],i):null}return Ds([ri([]),ri(s)])}function uw(t){const e=t.variants;return Array.isArray(e)?e.length-1:1}function fw(t,e){if(e.length===0)return Ds([],t);if(e.length===1){const s=e[0],i=s?.rule;if(!id(i))return Ds(e,t);if(Array.isArray(s?.value))return s.value}return Ds(e,t)}function gb(t,e){for(const[s,i]of Object.entries(t)){if(!fb(i))continue;const r=i.sections;if(Array.isArray(r)){e(void 0,s,0);continue}if(!r||typeof r!="object")continue;const o=r.variants;if(Array.isArray(o))for(let a=0;a<o.length;a++){const l=o[a];e(l?.rule,s,a)}}}function mw(t,e,s){let i=0;return gb(t,r=>{if(!r)return;(r.__resolveType??"")===e&&Ii(r,t,s)&&i++}),i}function Bl(t,e){const s=e.replace(/\s*\(copy(?:\s+\d+)?\)\s*$/,"").trim(),i=`${s} (copy)`;if(!t.has(i))return i;for(let r=2;r<1e3;r++){const o=`${s} (copy ${r})`;if(!t.has(o))return o}return`${s} (copy ${Date.now()})`}function vb(t,e){const s=pi,i=e.replace(/-copy(?:-\d+)?$/,""),r=`${i}-copy`;if(!t.has(s(r)))return r;for(let o=2;o<1e3;o++){const a=`${i}-copy-${o}`;if(!t.has(s(a)))return a}return`${i}-copy-${Date.now()}`}function Il(t,e){const s=e.replace(/_copy(?:_\d+)?$/,""),i=`${s}_copy`;if(!Object.hasOwn(t,i))return i;for(let r=2;r<1e3;r++){const o=`${s}_copy_${r}`;if(!Object.hasOwn(t,o))return o}return`${s}_copy_${Date.now()}`}function xb(t){const e=zo(t.newName),s={...t.source,name:t.newName,path:t.newPath};return{key:e,data:s}}function bb(t,e){return sh(t,e)}const yb=1e3;function Sb(t,e){for(let s=0;s<yb;s++){const i=zo(e);if(!Object.hasOwn(t,i))return i}throw new Error("Could not generate a unique page block key")}const wb={create:"Create new page",duplicate:"Duplicate page",rename:"Rename page"},Cb={create:"Create",duplicate:"Duplicate",rename:"Save"},kb={create:"Creating…",duplicate:"Duplicating…",rename:"Saving…"};function jb(t){const e=K.c(54),{open:s,mode:i,initialName:r,initialPath:o,isPending:a,error:l,validate:h,onSubmit:c,onOpenChange:d}=t,u=a===void 0?!1:a,[f,p]=A.useState(r),[m,_]=A.useState(o),[g,x]=A.useState(null),[S,v]=A.useState(s);s!==S&&(v(s),s&&(p(r),_(o),x(null)));let b;e[0]!==u||e[1]!==d?(b=W=>{!W&&!u&&(x(null),d(!1))},e[0]=u,e[1]=d,e[2]=b):b=e[2];const k=b;let w;e[3]!==u||e[4]!==f||e[5]!==c||e[6]!==m||e[7]!==h?(w=async W=>{W.preventDefault();const ee=f.trim(),$=m.trim();if(!ee||!$||u)return;const L=$o($);if(L){x(L);return}const Y=h?.({name:ee,path:$});if(Y){x(Y);return}x(null),await c({name:ee,path:$})},e[3]=u,e[4]=f,e[5]=c,e[6]=m,e[7]=h,e[8]=w):w=e[8];const N=w,j=g??l,R=wb[i];let I;e[9]!==R?(I=n.jsx(bs,{children:n.jsx(ys,{children:R})}),e[9]=R,e[10]=I):I=e[10];let E;e[11]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx("label",{htmlFor:"page-form-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[11]=E):E=e[11];let C;e[12]===Symbol.for("react.memo_cache_sentinel")?(C=W=>p(W.target.value),e[12]=C):C=e[12];let y;e[13]!==u||e[14]!==f?(y=n.jsxs("div",{className:"space-y-1.5",children:[E,n.jsx(Ye,{id:"page-form-name",value:f,onChange:C,placeholder:"My page",autoFocus:!0,disabled:u})]}),e[13]=u,e[14]=f,e[15]=y):y=e[15];let T;e[16]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx("label",{htmlFor:"page-form-path",className:"text-xs font-medium text-muted-foreground",children:"Path"}),e[16]=T):T=e[16];let D;e[17]===Symbol.for("react.memo_cache_sentinel")?(D=W=>_(W.target.value),e[17]=D):D=e[17];let P;e[18]!==u||e[19]!==m?(P=n.jsxs("div",{className:"space-y-1.5",children:[T,n.jsx(Ye,{id:"page-form-path",value:m,onChange:D,placeholder:"/example",disabled:u})]}),e[18]=u,e[19]=m,e[20]=P):P=e[20];let M;e[21]!==j?(M=j&&n.jsx("p",{className:"text-xs text-destructive",children:j}),e[21]=j,e[22]=M):M=e[22];let B;e[23]!==P||e[24]!==M||e[25]!==y?(B=n.jsxs("div",{className:"space-y-4 py-4",children:[y,P,M]}),e[23]=P,e[24]=M,e[25]=y,e[26]=B):B=e[26];let F;e[27]!==d?(F=()=>d(!1),e[27]=d,e[28]=F):F=e[28];let U;e[29]!==u||e[30]!==F?(U=n.jsx(te,{type:"button",variant:"outline",onClick:F,disabled:u,children:"Cancel"}),e[29]=u,e[30]=F,e[31]=U):U=e[31];let z;e[32]!==u||e[33]!==f||e[34]!==m?(z=!f.trim()||!m.trim()||u,e[32]=u,e[33]=f,e[34]=m,e[35]=z):z=e[35];let O;e[36]!==u||e[37]!==i?(O=u?n.jsxs(n.Fragment,{children:[n.jsx(ge,{size:14,className:"animate-spin"}),kb[i]]}):Cb[i],e[36]=u,e[37]=i,e[38]=O):O=e[38];let q;e[39]!==z||e[40]!==O?(q=n.jsx(te,{type:"submit",disabled:z,children:O}),e[39]=z,e[40]=O,e[41]=q):q=e[41];let V;e[42]!==U||e[43]!==q?(V=n.jsxs(Is,{children:[U,q]}),e[42]=U,e[43]=q,e[44]=V):V=e[44];let Q;e[45]!==N||e[46]!==B||e[47]!==V||e[48]!==I?(Q=n.jsx(qt,{className:"sm:max-w-md",children:n.jsxs("form",{onSubmit:N,children:[I,B,V]})}),e[45]=N,e[46]=B,e[47]=V,e[48]=I,e[49]=Q):Q=e[49];let G;return e[50]!==k||e[51]!==s||e[52]!==Q?(G=n.jsx(Gt,{open:s,onOpenChange:k,children:Q}),e[50]=k,e[51]=s,e[52]=Q,e[53]=G):G=e[53],G}function Nb(t){const e=K.c(43),{open:s,blockKey:i,initialName:r,isPending:o,onSubmit:a,onOpenChange:l}=t,h=o===void 0?!1:o,[c,d]=A.useState(r),[u,f]=A.useState(s);s!==u&&(f(s),s&&d(r));let p;e[0]!==h||e[1]!==l?(p=P=>{!P&&!h&&l(!1)},e[0]=h,e[1]=l,e[2]=p):p=e[2];const m=p;let _;e[3]!==h||e[4]!==c||e[5]!==a?(_=async P=>{P.preventDefault();const M=c.trim();!M||h||await a(M)},e[3]=h,e[4]=c,e[5]=a,e[6]=_):_=e[6];const g=_;let x;e[7]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsxs(bs,{children:[n.jsx(ys,{children:"Rename section"}),n.jsx(bo,{children:"Updates the display name. The internal key stays the same so pages referencing this section keep working."})]}),e[7]=x):x=e[7];let S;e[8]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx("label",{htmlFor:"section-rename-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[8]=S):S=e[8];let v;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=P=>d(P.target.value),e[9]=v):v=e[9];let b;e[10]!==h||e[11]!==c?(b=n.jsxs("div",{className:"space-y-1.5",children:[S,n.jsx(Ye,{id:"section-rename-name",value:c,onChange:v,autoFocus:!0,disabled:h})]}),e[10]=h,e[11]=c,e[12]=b):b=e[12];let k;e[13]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Key"}),e[13]=k):k=e[13];let w;e[14]!==i?(w=n.jsxs("div",{className:"space-y-1.5",children:[k,n.jsx(Ye,{value:i,readOnly:!0,disabled:!0,className:"font-mono"})]}),e[14]=i,e[15]=w):w=e[15];let N;e[16]!==b||e[17]!==w?(N=n.jsxs("div",{className:"space-y-4 py-4",children:[b,w]}),e[16]=b,e[17]=w,e[18]=N):N=e[18];let j;e[19]!==l?(j=()=>l(!1),e[19]=l,e[20]=j):j=e[20];let R;e[21]!==h||e[22]!==j?(R=n.jsx(te,{type:"button",variant:"outline",onClick:j,disabled:h,children:"Cancel"}),e[21]=h,e[22]=j,e[23]=R):R=e[23];let I;e[24]!==h||e[25]!==c?(I=!c.trim()||h,e[24]=h,e[25]=c,e[26]=I):I=e[26];let E;e[27]!==h?(E=h?n.jsxs(n.Fragment,{children:[n.jsx(ge,{size:14,className:"animate-spin"}),"Saving…"]}):"Save",e[27]=h,e[28]=E):E=e[28];let C;e[29]!==I||e[30]!==E?(C=n.jsx(te,{type:"submit",disabled:I,children:E}),e[29]=I,e[30]=E,e[31]=C):C=e[31];let y;e[32]!==R||e[33]!==C?(y=n.jsxs(Is,{children:[R,C]}),e[32]=R,e[33]=C,e[34]=y):y=e[34];let T;e[35]!==g||e[36]!==N||e[37]!==y?(T=n.jsx(qt,{className:"sm:max-w-md",children:n.jsxs("form",{onSubmit:g,children:[x,N,y]})}),e[35]=g,e[36]=N,e[37]=y,e[38]=T):T=e[38];let D;return e[39]!==m||e[40]!==s||e[41]!==T?(D=n.jsx(Gt,{open:s,onOpenChange:m,children:T}),e[39]=m,e[40]=s,e[41]=T,e[42]=D):D=e[42],D}const Eb=A.lazy(()=>Ni(()=>import("./sections-editor-Dfs3LCeJ.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}))),Tb=A.lazy(()=>Ni(()=>import("./add-section-modal-BVJKB-Mq.js"),__vite__mapDeps([82,1,2,6,7,8,9,10,11,12,13,14,15,16,17,3,4,5,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,45,46,83,84,85,54,86,87,88,53,89,55,90,91,92,42,43,44,93,94,95,96,97,98,99,100,62,101,52,102,67,68,103,66,63,77,104,105,106,76,107,108,61,109,79,74,110,47,111,48,49,50,51,56,57,58,59,60,64,65,69,70,71,72,112,113,114,115,116,117,118,119,80,81,120,121,122,123,124,125,126,127,75,128,129,130,131,132,133,134,135])).then(t=>({default:t.AddSectionModal}))),lo="oklch(0.65 0.15 160)";function Rb(){const t=K.c(21),e=Zo(),{data:s}=ji.useSession(),{currentBranch:i}=rs(),{org:r}=je(),o=e?.entity?.id??null,a=s?.user?.id,l=e?.entity?.metadata,h=a&&i?vi(l?.sandboxMap?.[a]?.[i]):{},c=Object.values(h),u=(c.find(Db)??c[0])?.previewUrl??null,f=ns(),p=f.lifecycle.phase,m=e?.entity?.organization_id??"";let _;t[0]!==r.slug||t[1]!==m?(_={connectionId:vs,orgId:m,orgSlug:r.slug},t[0]=r.slug,t[1]=m,t[2]=_):_=t[2];const g=Xe(_),x=ho(g),S=uo(o??void 0,i??void 0),v=Vt();let b;t[3]!==i||t[4]!==x||t[5]!==o?(b=()=>{if(!o)return;const T={virtualMcpId:o};i&&(T.branch=i),x.mutate(T)},t[3]=i,t[4]=x,t[5]=o,t[6]=b):b=t[6];const k=b,w=p==="start-failed"||p==="install-failed"||p==="clone-failed"?p:null,N=w&&"error"in f.lifecycle?f.lifecycle.error??null:null,j=p==="running"?"online":p==="crashed"?"offline":"booting",R=!!o&&!!i&&Qi.isStopped(o,i),I=rh({previewUrl:u,status:j,htmlSupport:!0,suspended:f.suspended,appPaused:f.status.state==="paused",vmStartPending:S,lastStartError:x.error?.message??null,lifecycleFailure:w,lifecycleFailureError:N,claimPhase:f.phase,notFound:f.notFound,userStopped:R});let E;t[7]!==v?(E=()=>v({to:".",search:Pb,replace:!0}),t[7]=v,t[8]=E):E=t[8];const C=E;if(I.kind!=="iframe"&&I.kind!=="no-html"){let T;return t[9]!==C||t[10]!==I||t[11]!==k||t[12]!==f.lifecycle||t[13]!==f.phase?(T=n.jsx(Lb,{state:I,claimPhase:f.phase,lifecycle:f.lifecycle,onStart:k,onOpenPreview:C}),t[9]=C,t[10]=I,t[11]=k,t[12]=f.lifecycle,t[13]=f.phase,t[14]=T):T=t[14],T}if(!o||!i){let T;return t[15]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx(lr,{title:"Waiting for sandbox context…"}),t[15]=T):T=t[15],T}let y;return t[16]!==i||t[17]!==r.slug||t[18]!==u||t[19]!==o?(y=n.jsx(Ab,{orgSlug:r.slug,virtualMcpId:o,branch:i,previewUrl:u}),t[16]=i,t[17]=r.slug,t[18]=u,t[19]=o,t[20]=y):y=t[20],y}function Pb(t){return{...t,main:"preview"}}function Db(t){return t.sandboxProviderKind!=="user-desktop"}function Ab({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i}){const r={orgSlug:t,virtualMcpId:e,branch:s},{data:o,isLoading:a}=Po(r),{data:l,isLoading:h}=Do(r),c=ih(r),d=ib(r),[u,f]=A.useState("pages"),[p,m]=A.useState(null),[_,g]=A.useState(""),[x,S]=A.useState(u);x!==u&&(S(u),g(""));const[v,b]=A.useState(null),[k,w]=A.useState(),[N,j]=A.useState(!1),[R,I]=A.useState(null),[E,C]=A.useState(null);if(a||h)return n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})});if(!o||!l)return n.jsx(lr,{title:"Could not load site data."});const y=Bo(o).sort(($,L)=>$.name.localeCompare(L.name)),T=Io(o,l);if(y.length===0&&T.length===0)return n.jsx(lr,{icon:Ti,title:"No editable content",description:"This project doesn't expose any Deco pages or sections."});const D={pages:y.length,sections:T.length},P=new Set(y.map($=>pi($.path))),M=new Set(y.map($=>$.name)),B=new Set(T.map($=>$.name)),F=async $=>{const L=o[$.key];if(!L)return;const Y=rd(o,$.key),X=mb(o,$.key,Math.max(0,Y-1)),H=_b(L.sections,X);if(H)try{await c.mutateAsync({blockKey:$.key,data:{...L,sections:H}}),ae.success(`Variant added to "${$.name}"`),m({collection:"pages",key:$.key,path:$.path})}catch(ne){ae.error(ne instanceof Error?ne.message:"Could not add variant")}},U=()=>{w(void 0),b({mode:"create",sourceKey:null,initialName:"My new page",initialPath:"/example"})},z=$=>{w(void 0),b({mode:"duplicate",sourceKey:$.key,initialName:Bl(M,$.name),initialPath:vb(P,$.path)})},O=$=>{w(void 0),b({mode:"rename",sourceKey:$.key,initialName:$.name,initialPath:$.path})},q=async $=>{if(!v)return;const{mode:L,sourceKey:Y}=v;try{if(L==="create"){const X=bb($.name,$.path),H=Sb(o,$.name);await c.mutateAsync({blockKey:H,data:X}),ae.success(`Created "${$.name}"`),m({collection:"pages",key:H,path:$.path})}else if(L==="duplicate"&&Y){const X=o[Y];if(!X)throw new Error("Source page not found");const{key:H,data:ne}=xb({source:X,pages:y,newName:$.name,newPath:$.path});await c.mutateAsync({blockKey:H,data:ne}),ae.success(`Duplicated as "${$.name}"`),m({collection:"pages",key:H,path:$.path})}else if(L==="rename"&&Y){const X=o[Y];if(!X)throw new Error("Page not found");const H={...X,name:$.name,path:$.path};await c.mutateAsync({blockKey:Y,data:H}),ae.success("Page updated"),p?.collection==="pages"&&p.key===Y&&m({collection:"pages",key:Y,path:$.path})}b(null)}catch(X){w(X instanceof Error?X.message:"Save failed")}},V=({path:$})=>{if(!v)return null;const L=pi($);return(v.mode==="rename"?pi(v.initialPath):null)!==L&&P.has(L)?`A page with path "${$}" already exists.`:null},Q=async $=>{const L=($.title||$.resolveType.split("/").pop()||"").replace(/\.(tsx?|jsx?)$/,"").replace(/[^A-Za-z0-9_-]/g,""),Y=/^[A-Za-z]/.test(L)&&L.length>0?L:"Section",X=Il(o,Y),H={__resolveType:$.resolveType,name:X};try{await c.mutateAsync({blockKey:X,data:H}),ae.success(`Created section "${X}"`),j(!1),m({collection:"sections",key:X})}catch(ne){ae.error(ne instanceof Error?ne.message:"Could not create section")}},G=async $=>{const L=o[$.key];if(!L){ae.error("Section not found.");return}const Y=Il(o,$.key),X=Bl(B,$.name),H={...L,name:X};try{await c.mutateAsync({blockKey:Y,data:H}),ae.success(`Duplicated "${$.name}"`),m({collection:"sections",key:Y})}catch(ne){ae.error(ne instanceof Error?ne.message:"Duplicate failed")}},W=async $=>{if(!R)return;const L=o[R];if(!L){ae.error("Section not found.");return}try{await c.mutateAsync({blockKey:R,data:{...L,name:$}}),ae.success("Section renamed"),I(null)}catch(Y){ae.error(Y instanceof Error?Y.message:"Rename failed")}},ee=async()=>{if(!E)return;const{kind:$,key:L,label:Y}=E;try{await d.mutateAsync({blockKey:L}),ae.success(`Deleted "${Y}"`),$==="page"?p?.collection==="pages"&&p.key===L&&m(null):p?.collection==="sections"&&p.key===L&&m(null),C(null)}catch(X){ae.error(X instanceof Error?X.message:"Delete failed")}};return n.jsxs("div",{className:"flex h-full w-full",children:[n.jsx(Mb,{active:u,counts:D,onSelect:$=>{f($),m(null)}}),n.jsx(Bb,{activeCollection:u,pages:y,sections:T,decofile:o,searchQuery:_,onSearchChange:g,selection:p,onSelect:m,previewUrl:i,onCreate:()=>{u==="pages"?U():i?j(!0):ae.error("Start the preview dev server to add sections.")},onDuplicatePage:z,onRenamePage:O,onAddPageVariant:F,onDeletePage:$=>C({kind:"page",key:$.key,label:$.name}),onDuplicateSection:G,onRenameSection:$=>I($.key),onDeleteSection:$=>C({kind:"section",key:$.key,label:$.name})}),n.jsx("div",{className:"flex-1 min-w-0",children:p?n.jsx(A.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(Eb,{orgSlug:t,virtualMcpId:e,branch:s,previewReady:!0,previewUrl:i??void 0,currentPath:p.collection==="pages"?p.path:"/",activePageBlockKey:p.collection==="pages"?p.key:null,activeGlobalBlockKey:p.collection==="sections"?p.key:null},p.collection==="pages"?`page:${p.key}`:`section:${p.key}`)}):n.jsx(lr,{title:u==="pages"?"Select a page to edit":"Select a section to edit",description:u==="pages"?'Pick a page from the list, or click "+ New" to create one.':'Pick a section from the list, or click "+ New" to create one.'})}),v&&n.jsx(jb,{open:!!v,mode:v.mode,initialName:v.initialName,initialPath:v.initialPath,isPending:c.isPending,error:k,validate:V,onSubmit:q,onOpenChange:$=>{$||(b(null),w(void 0))}}),R&&n.jsx(Nb,{open:!!R,blockKey:R,initialName:T.find($=>$.key===R)?.name??R,isPending:c.isPending,onSubmit:W,onOpenChange:$=>{$||I(null)}}),N&&i&&n.jsx(A.Suspense,{fallback:null,children:n.jsx(Tb,{open:N,onOpenChange:j,meta:l,decofile:o,previewBaseUrl:i,onSelect:Q})}),n.jsx(dr,{open:!!E,onOpenChange:$=>{!$&&!d.isPending&&C(null)},children:n.jsxs(ur,{children:[n.jsxs(fr,{children:[n.jsxs(mr,{children:["Delete ",E?.kind==="page"?"page":"section","?"]}),n.jsx(pr,{children:E?.kind==="page"?`"${E.label}" will be removed permanently. This can't be undone.`:E?.kind==="section"?`"${E.label}" will be removed. Pages that still reference it will lose this section.`:null})]}),n.jsxs(_r,{children:[n.jsx(gr,{disabled:d.isPending,children:"Cancel"}),n.jsx(vr,{onClick:$=>{$.preventDefault(),ee()},disabled:d.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:d.isPending?n.jsxs(n.Fragment,{children:[n.jsx(ge,{size:14,className:"animate-spin"}),"Deleting…"]}):"Delete"})]})]})})]})}function Mb(t){const e=K.c(12),{active:s,counts:i,onSelect:r}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("div",{className:"px-3 h-12 flex items-center border-b shrink-0",children:n.jsx("span",{className:"text-sm font-medium",children:"Content"})}),e[0]=o):o=e[0];const a=s==="pages";let l;e[1]!==i.pages||e[2]!==r||e[3]!==a?(l=n.jsx(Ll,{id:"pages",icon:vo,label:"Pages",count:i.pages,active:a,onSelect:r}),e[1]=i.pages,e[2]=r,e[3]=a,e[4]=l):l=e[4];const h=s==="sections";let c;e[5]!==i.sections||e[6]!==r||e[7]!==h?(c=n.jsx(Ll,{id:"sections",icon:yr,label:"Sections",count:i.sections,active:h,onSelect:r}),e[5]=i.sections,e[6]=r,e[7]=h,e[8]=c):c=e[8];let d;return e[9]!==l||e[10]!==c?(d=n.jsxs("div",{className:"w-[208px] shrink-0 border-r flex flex-col",children:[o,n.jsxs("nav",{className:"flex flex-col p-1.5 gap-0.5",children:[l,c]})]}),e[9]=l,e[10]=c,e[11]=d):d=e[11],d}function Ll(t){const e=K.c(20),{id:s,icon:i,label:r,count:o,active:a,onSelect:l}=t;let h;e[0]!==s||e[1]!==l?(h=()=>l(s),e[0]=s,e[1]=l,e[2]=h):h=e[2];const c=a?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground";let d;e[3]!==c?(d=ie("flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors cursor-pointer",c),e[3]=c,e[4]=d):d=e[4];let u;e[5]!==i?(u=n.jsx(i,{size:16,className:"shrink-0"}),e[5]=i,e[6]=u):u=e[6];let f;e[7]!==r?(f=n.jsx("span",{className:"flex-1 truncate",children:r}),e[7]=r,e[8]=f):f=e[8];const p=a?"text-accent-foreground/70":"text-muted-foreground/70";let m;e[9]!==p?(m=ie("shrink-0 text-xs tabular-nums",p),e[9]=p,e[10]=m):m=e[10];let _;e[11]!==o||e[12]!==m?(_=n.jsx("span",{className:m,children:o}),e[11]=o,e[12]=m,e[13]=_):_=e[13];let g;return e[14]!==h||e[15]!==d||e[16]!==u||e[17]!==f||e[18]!==_?(g=n.jsxs("button",{type:"button",onClick:h,className:d,children:[u,f,_]}),e[14]=h,e[15]=d,e[16]=u,e[17]=f,e[18]=_,e[19]=g):g=e[19],g}function Bb(t){const e=K.c(54),{activeCollection:s,pages:i,sections:r,decofile:o,previewUrl:a,searchQuery:l,onSearchChange:h,selection:c,onSelect:d,onCreate:u,onDuplicatePage:f,onRenamePage:p,onAddPageVariant:m,onDeletePage:_,onDuplicateSection:g,onRenameSection:x,onDeleteSection:S}=t;let v,b,k,w,N,j;if(e[0]!==s||e[1]!==o||e[2]!==m||e[3]!==u||e[4]!==_||e[5]!==S||e[6]!==f||e[7]!==g||e[8]!==p||e[9]!==x||e[10]!==h||e[11]!==d||e[12]!==i||e[13]!==a||e[14]!==l||e[15]!==r||e[16]!==c){const C=l.toLowerCase(),y=i.filter(W=>!C||W.name.toLowerCase().includes(C)||W.path.toLowerCase().includes(C)),T=r.filter(W=>!C||W.name.toLowerCase().includes(C)||W.key.toLowerCase().includes(C)||W.resolveType.toLowerCase().includes(C)),D=s==="pages"?"Search pages…":"Search sections…",P=s==="pages"?"Create new page":"Create new section",M=s==="sections"&&!a,B=M?"Start the preview dev server to add sections":void 0;N="w-[300px] shrink-0 border-r flex flex-col min-h-0";let F;e[23]===Symbol.for("react.memo_cache_sentinel")?(F=n.jsx(yc,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),e[23]=F):F=e[23];let U;e[24]!==h?(U=W=>h(W.target.value),e[24]=h,e[25]=U):U=e[25];let z;e[26]!==D||e[27]!==l||e[28]!==U?(z=n.jsxs("div",{className:"flex flex-1 items-center gap-2 pl-1",children:[F,n.jsx("input",{type:"text",value:l,onChange:U,placeholder:D,"aria-label":D,className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),e[26]=D,e[27]=l,e[28]=U,e[29]=z):z=e[29];let O;e[30]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(Kt,{size:14}),e[30]=O):O=e[30];let q;e[31]!==P||e[32]!==u||e[33]!==M?(q=n.jsx(Se,{asChild:!0,children:n.jsx(te,{variant:"ghost",size:"icon",onClick:u,disabled:M,"aria-label":P,"aria-disabled":M,children:O})}),e[31]=P,e[32]=u,e[33]=M,e[34]=q):q=e[34];const V=B??P;let Q;e[35]!==V?(Q=n.jsx(we,{side:"bottom",children:V}),e[35]=V,e[36]=Q):Q=e[36];let G;e[37]!==q||e[38]!==Q?(G=n.jsxs(Ce,{children:[q,Q]}),e[37]=q,e[38]=Q,e[39]=G):G=e[39],e[40]!==G||e[41]!==z?(j=n.jsxs("div",{className:"px-2 h-12 flex items-center gap-1 border-b shrink-0",children:[z,G]}),e[40]=G,e[41]=z,e[42]=j):j=e[42],v=So,w="flex-1 min-h-0",b="flex flex-col gap-1 p-1.5",k=s==="pages"?y.length===0?n.jsx(zl,{hasItems:i.length>0,emptyLabel:"No pages yet.",emptyHint:'Click "+" to create your first page.'}):y.map(W=>{const ee=c?.collection==="pages"&&c.key===W.key,$=rd(o,W.key);return n.jsx(Ol,{icon:vo,title:W.name,subtitle:W.path,active:ee,variantCount:$,onClick:()=>d({collection:"pages",key:W.key,path:W.path}),menu:n.jsx($l,{onDuplicate:()=>f(W),onRename:()=>p(W),onAddVariant:()=>m(W),onDelete:()=>_(W)})},W.key)}):T.length===0?n.jsx(zl,{hasItems:r.length>0,emptyLabel:"No saved sections yet.",emptyHint:'Click "+" to create one, or save a section from a page.'}):T.map(W=>{const ee=c?.collection==="sections"&&c.key===W.key,$=W.resolveType.split("/").pop()?.replace(/\.tsx?$/,"");return n.jsx(Ol,{icon:yr,title:W.name,subtitle:$??W.resolveType,active:ee,onClick:()=>d({collection:"sections",key:W.key}),menu:n.jsx($l,{onDuplicate:()=>g(W),onRename:()=>x(W),onDelete:()=>S(W)})},W.key)}),e[0]=s,e[1]=o,e[2]=m,e[3]=u,e[4]=_,e[5]=S,e[6]=f,e[7]=g,e[8]=p,e[9]=x,e[10]=h,e[11]=d,e[12]=i,e[13]=a,e[14]=l,e[15]=r,e[16]=c,e[17]=v,e[18]=b,e[19]=k,e[20]=w,e[21]=N,e[22]=j}else v=e[17],b=e[18],k=e[19],w=e[20],N=e[21],j=e[22];let R;e[43]!==b||e[44]!==k?(R=n.jsx("div",{className:b,children:k}),e[43]=b,e[44]=k,e[45]=R):R=e[45];let I;e[46]!==v||e[47]!==w||e[48]!==R?(I=n.jsx(v,{className:w,children:R}),e[46]=v,e[47]=w,e[48]=R,e[49]=I):I=e[49];let E;return e[50]!==N||e[51]!==j||e[52]!==I?(E=n.jsxs("div",{className:N,children:[j,I]}),e[50]=N,e[51]=j,e[52]=I,e[53]=E):E=e[53],E}function Ol(t){const e=K.c(27),{icon:s,title:i,subtitle:r,active:o,variantCount:a,onClick:l,menu:h}=t,c=o?"bg-accent text-accent-foreground":"hover:bg-muted";let d;e[0]!==c?(d=ie("group relative flex items-center rounded-md transition-colors",c),e[0]=c,e[1]=d):d=e[1];let u;e[2]!==s||e[3]!==o||e[4]!==a?(u=a&&a>1?n.jsxs(Ce,{children:[n.jsx(Se,{asChild:!0,children:n.jsx(s,{size:16,className:"shrink-0",style:{color:lo}})}),n.jsxs(we,{side:"right",children:[a," variants"]})]}):n.jsx(s,{size:16,className:ie("shrink-0",o?"text-accent-foreground":"text-muted-foreground")}),e[2]=s,e[3]=o,e[4]=a,e[5]=u):u=e[5];let f;e[6]!==i?(f=n.jsx("span",{className:"block truncate text-sm font-medium",children:i}),e[6]=i,e[7]=f):f=e[7];const p=o?"text-accent-foreground/70":"text-muted-foreground";let m;e[8]!==p?(m=ie("block truncate text-xs",p),e[8]=p,e[9]=m):m=e[9];let _;e[10]!==r||e[11]!==m?(_=n.jsx("span",{className:m,children:r}),e[10]=r,e[11]=m,e[12]=_):_=e[12];let g;e[13]!==f||e[14]!==_?(g=n.jsxs("span",{className:"min-w-0 flex-1",children:[f,_]}),e[13]=f,e[14]=_,e[15]=g):g=e[15];let x;e[16]!==l||e[17]!==u||e[18]!==g?(x=n.jsxs("button",{type:"button",onClick:l,className:"flex min-w-0 flex-1 items-center gap-2.5 rounded-md px-2.5 py-2 text-left cursor-pointer",children:[u,g]}),e[16]=l,e[17]=u,e[18]=g,e[19]=x):x=e[19];let S;e[20]!==o||e[21]!==h?(S=h&&n.jsx("div",{className:ie("pr-1 opacity-0 transition-opacity group-hover:opacity-100",o&&"opacity-100"),children:h}),e[20]=o,e[21]=h,e[22]=S):S=e[22];let v;return e[23]!==S||e[24]!==d||e[25]!==x?(v=n.jsxs("div",{className:d,children:[x,S]}),e[23]=S,e[24]=d,e[25]=x,e[26]=v):v=e[26],v}function $l(t){const e=K.c(18),{onDuplicate:s,onRename:i,onAddVariant:r,onDelete:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(Hs,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":"More actions",className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-background hover:text-foreground cursor-pointer",onClick:Ib,children:n.jsx(Br,{size:14})})}),e[0]=a):a=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(_c,{size:14}),e[1]=l):l=e[1];let h;e[2]!==i?(h=n.jsxs(ut,{onClick:i,children:[l,"Rename"]}),e[2]=i,e[3]=h):h=e[3];let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(ss,{size:14}),e[4]=c):c=e[4];let d;e[5]!==s?(d=n.jsxs(ut,{onClick:s,children:[c,"Duplicate"]}),e[5]=s,e[6]=d):d=e[6];let u;e[7]!==r?(u=r&&n.jsxs(n.Fragment,{children:[n.jsx(xa,{}),n.jsxs(ut,{onClick:r,className:"cursor-pointer",style:{color:lo},children:[n.jsx(ku,{size:14,style:{color:lo}}),"Add variant"]})]}),e[7]=r,e[8]=u):u=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(xa,{}),e[9]=f):f=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(xi,{size:14}),e[10]=p):p=e[10];let m;e[11]!==o?(m=n.jsxs(ut,{onClick:o,className:"text-destructive focus:text-destructive",children:[p,"Delete"]}),e[11]=o,e[12]=m):m=e[12];let _;return e[13]!==h||e[14]!==d||e[15]!==u||e[16]!==m?(_=n.jsxs(Fs,{children:[a,n.jsxs(Ws,{align:"end",className:"w-44",children:[h,d,u,f,m]})]}),e[13]=h,e[14]=d,e[15]=u,e[16]=m,e[17]=_):_=e[17],_}function Ib(t){return t.stopPropagation()}function zl(t){const e=K.c(6),{hasItems:s,emptyLabel:i,emptyHint:r}=t;let o;e[0]!==r||e[1]!==i||e[2]!==s?(o=s?"No results match your search.":n.jsxs(n.Fragment,{children:[n.jsx("div",{children:i}),n.jsx("div",{className:"mt-1 text-muted-foreground/80",children:r})]}),e[0]=r,e[1]=i,e[2]=s,e[3]=o):o=e[3];let a;return e[4]!==o?(a=n.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o}),e[4]=o,e[5]=a):a=e[5],a}function Lb(t){const e=K.c(26),{state:s,claimPhase:i,lifecycle:r,onStart:o,onOpenPreview:a}=t;let l;e[0]!==i||e[1]!==r?(l=oh({claimPhase:i,lifecycle:r}),e[0]=i,e[1]=r,e[2]=l):l=e[2];const h=l;switch(s.kind){case"never-started":{let c;return e[3]!==o?(c=n.jsx(xt,{kind:"never-started",onStart:o}),e[3]=o,e[4]=c):c=e[4],c}case"starting-now":{let c;return e[5]!==i||e[6]!==h?(c=n.jsx(xt,{kind:"starting-now",progress:h,claimPhase:i}),e[5]=i,e[6]=h,e[7]=c):c=e[7],c}case"suspended":{let c;return e[8]!==o?(c=n.jsx(xt,{kind:"suspended",onResume:o}),e[8]=o,e[9]=c):c=e[9],c}case"crashed":{let c;return e[10]!==a?(c=n.jsx(xt,{kind:"crashed",onOpenTerminal:a}),e[10]=a,e[11]=c):c=e[11],c}case"errored":{let c;e[12]!==s.error?(c=s.error.split(`
|
|
290
|
+
`)[0]??"Dev script exited",onRetry:Xs,onOpenTerminal:Xr,onBrowseFiles:()=>a("code"),drawerOpen:Gr})}),Te.kind==="suspended"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(xt,{kind:"suspended",onResume:Xs})}),Te.kind==="crashed"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(xt,{kind:"crashed",onOpenTerminal:Xr})}),Te.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(_a,{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(te,{onClick:Xr,children:[n.jsx(_a,{size:14}),"View Logs"]})]}),qr==="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(pa,{size:12}),"Click any element to ask the AI"]}),qr==="visual"&&l&&n.jsx(og,{element:l,onDismiss:()=>h(null)}),o==="code"&&Vr&&V&&i&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(A.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(Zx,{orgSlug:Q.slug,virtualMcpId:V,branch:i})})}),Te.kind==="iframe"&&kt&&n.jsx("iframe",{ref:c,src:kt,className:ie("w-full h-full border-0",o==="code"&&"invisible"),title:"Dev Server Preview",tabIndex:d?-1:void 0,onLoad:()=>{if(Me("vm_preview_loaded",{view_mode:o,vm_id:O?.sandboxHandle??null}),!C)try{const Z=c.current?.contentWindow?.location?.pathname;if(!Z)return;const ue=xe.current;if(ue!==null){xe.current=null,ce(Z)===ce(ue)&&M(Z);return}M(Z)}catch{}o==="visual"&&na(),o==="cms"&&oa()}},Te.previewUrl)]})]}),n.jsx(qx,{vmId:O?.sandboxHandle??null,orgSlug:Q.slug,virtualMcpId:V,branch:i,status:Qx(Te,Ze),scripts:G.scripts,open:Gr,onOpenChange:Yr,onStart:()=>$i("auto-start"),onStop:ra,onRestart:_d,onResume:Xs,onRetry:Xs},O?.sandboxHandle??"no-vm"),n.jsx(Q_,{open:j,onOpenChange:R,isPending:H.isPending,error:I,onSubmit:Cd})]})}function tb(t){const e=K.c(2),{virtualMcpId:s}=t,i=At(s);if(!Ei(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(Ti,{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(eb,{}),e[1]=o):o=e[1],o}function td(t){if(!t||t.includes("/")||t.includes("\\")||t.includes(".."))throw new Error(`Invalid block key: ${t||"(empty)"}`)}function sb(t){return td(t),`.deco/blocks/${t}.json`}function ib({orgSlug:t,virtualMcpId:e,branch:s}){const i=Tr();return Rr({mutationFn:async({blockKey:r})=>{td(r);const o=sb(r),a=await fetch(`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/unlink`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:o})});if(!a.ok){const l=await a.json().catch(()=>({}));throw new Error(l.error??`Delete failed (${a.status})`)}return a.json()},onMutate:async({blockKey:r})=>{const o=`${t}/${e}/${s}`,a=Ut.decofile(o);await i.cancelQueries({queryKey:a});const l=i.getQueryData(a);return i.setQueryData(a,h=>{if(!h)return h;const{[r]:c,...d}=h;return d}),{previous:l,queryKey:a}},onError:(r,o,a)=>{a?.queryKey&&i.setQueryData(a.queryKey,a.previous)},onSuccess:()=>{const r=`${t}/${e}/${s}`;i.invalidateQueries({queryKey:Ut.liveMeta(r)})}})}const rb=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function nb(t){return t.includes("matchers")||t.includes("Match")}function ob(t,e){const s=t.__resolveType;return typeof s!="string"||!s||rb.has(s)?!1:e?Tm(e,s):nb(s)}function Ii(t,e,s){if(!t)return!1;const i=t.__resolveType;if(typeof i!="string"||!Ao(i)||!Object.hasOwn(e,i))return!1;const r=e[i];return!r||typeof r!="object"||Array.isArray(r)?!1:ob(r,s)}function YS(t,e,s){return Ii(t,e,s)?t?.__resolveType??null:null}function sd(t,e,s){if(!t)return null;const i=t.__resolveType??"";if(!i)return null;if(Ii(t,e,s)){const a=e[i]??{},l=a.__resolveType??i,{__resolveType:h,name:c,...d}=a;return{resolveType:l,data:d,blockKey:i}}const{__resolveType:r,...o}=t;return{resolveType:i,data:o}}function ab(t,e,s){const i=sd(t,e,s);return i?{__resolveType:i.resolveType,...i.data}:{__resolveType:""}}function XS(t,e,s){if(t)return Ii(t,e,s)?ab(t,e,s):t}function lb(t,e,s,i){if(!t)return"Default";if(Ii(t,e,i)){const r=t.__resolveType??"",o=e[r];return zc(r,o)}return s(t)}function JS(t,e,s){return{__resolveType:t,...e,name:s}}function ZS(t){return{__resolveType:t}}function QS(t,e,s){const i=sd(t,e,s);return i?{resolveType:i.resolveType,formValue:i.data}:{resolveType:"",formValue:{}}}function ew(t){return{__resolveType:Bm,variants:[{value:t,rule:{__resolveType:Ac}}]}}function tw(t){const r=($r(t.__resolveType)?t.section:t)?.variants?.[0];return r?.rule?.__resolveType!==Ac?null:r?.value??null}const cb=["website/matchers/always.ts","$live/matchers/MatchAlways.ts"];function id(t){if(!t)return!1;const e=t.__resolveType??"";return e===""?Object.keys(t).length===0:cb.includes(e)||e.includes("always")}function hb(t){const e=t.variants??[];if(e.length===0)return-1;const s=e.findIndex(i=>id(i.rule));return s!==-1?s:e.length-1}function sw(t,e,s){const i=s.variants??[];if(i.length===0)return null;const r=hb(s),o=i[r]?.value;if(!o)return null;const a=structuredClone(o);return e.isLazy?{...t,section:a}:a}function iw(t,e){return e.isMultivariate?e.isLazy?t.section??null:t:null}function rw(t,e){return Array.isArray(t.variants)?t.variants.map((s,i)=>({label:e(s.rule)||`Variant ${i+1}`,value:s.value??{},rule:s.rule})):[]}function nw(t,e){const s=t.__resolveType??"";if(!s)return null;if($r(s)){const i=t.section??t,r=i.__resolveType??s;if(!r.includes("/")&&r in e){const o=e[r]??{};return{data:{...o},resolveType:o.__resolveType??r}}return{data:{...i},resolveType:r}}if(!s.includes("/")&&s in e){const i=e[s]??{};return{data:{...i},resolveType:i.__resolveType??s}}return{data:{...t},resolveType:s}}function db(t,e){const s=t.__resolveType??"";return $r(s)?{...t,section:e}:e}function ow(t,e,s){return e.isLazy?{...t,section:s}:s}function aw(t,e,s){const i=[...t.variants??[]],r=i[e];if(!r)return t;const o=r.value??{};return i[e]={...r,value:db(o,s)},{...t,variants:i}}function lw(t,e,s){const i=[...t.variants??[]];return i[e]?(i[e]={...i[e],rule:s},{...t,variants:i}):t}function cw(t,e){const s=[...t.variants??[]],i=s[e];return i?(s.splice(e+1,0,structuredClone(i)),{...t,variants:s}):t}function hw(t,e){const s=[...t.variants??[]];return s.length<=1?null:(s.splice(e,1),{...t,variants:s})}const ub=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function fb(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t;return typeof e.__resolveType=="string"&&ub.has(e.__resolveType)&&typeof e.path=="string"}function rd(t,e){const i=t[e]?.sections;if(!i||Array.isArray(i))return 1;const r=i;return Array.isArray(r.variants)?r.variants.length:1}function mb(t,e,s){const r=t[e]?.sections;if(Array.isArray(r))return s===0?r:[];if(r&&typeof r=="object"){const o=r.variants;if(Array.isArray(o)){const a=o[s];return Array.isArray(a?.value)?a.value:[]}}return[]}function dw(t,e,s){if(Array.isArray(t))return[{label:"Default",sections:t}];if(t&&typeof t=="object"){const i=t;if(Array.isArray(i.variants)){const r=i.variants,o=r.map(h=>lb(h.rule,e,s)),a=o.reduce((h,c)=>(h[c]=(h[c]??0)+1,h),{}),l={};return r.map((h,c)=>{const d=o[c]??`Variant ${c+1}`,u=a[d]??1;let f=d;return u>1&&(l[d]=(l[d]??0)+1,f=`${d} ${l[d]}`),{label:f||`Variant ${c+1}`,sections:Array.isArray(h.value)?h.value:[],rule:h.rule}})}}return[]}function pb(){return{__resolveType:Am}}function ri(t){return{rule:pb(),value:t}}function Ds(t,e){return{...e,__resolveType:Mm,variants:t}}function _b(t,e){const s=structuredClone(e);if(Array.isArray(t))return Ds([ri(t),ri(s)]);if(t&&typeof t=="object"){const i=t;return Array.isArray(i.variants)?Ds([...i.variants,ri(s)],i):null}return Ds([ri([]),ri(s)])}function uw(t){const e=t.variants;return Array.isArray(e)?e.length-1:1}function fw(t,e){if(e.length===0)return Ds([],t);if(e.length===1){const s=e[0],i=s?.rule;if(!id(i))return Ds(e,t);if(Array.isArray(s?.value))return s.value}return Ds(e,t)}function gb(t,e){for(const[s,i]of Object.entries(t)){if(!fb(i))continue;const r=i.sections;if(Array.isArray(r)){e(void 0,s,0);continue}if(!r||typeof r!="object")continue;const o=r.variants;if(Array.isArray(o))for(let a=0;a<o.length;a++){const l=o[a];e(l?.rule,s,a)}}}function mw(t,e,s){let i=0;return gb(t,r=>{if(!r)return;(r.__resolveType??"")===e&&Ii(r,t,s)&&i++}),i}function Bl(t,e){const s=e.replace(/\s*\(copy(?:\s+\d+)?\)\s*$/,"").trim(),i=`${s} (copy)`;if(!t.has(i))return i;for(let r=2;r<1e3;r++){const o=`${s} (copy ${r})`;if(!t.has(o))return o}return`${s} (copy ${Date.now()})`}function vb(t,e){const s=pi,i=e.replace(/-copy(?:-\d+)?$/,""),r=`${i}-copy`;if(!t.has(s(r)))return r;for(let o=2;o<1e3;o++){const a=`${i}-copy-${o}`;if(!t.has(s(a)))return a}return`${i}-copy-${Date.now()}`}function Il(t,e){const s=e.replace(/_copy(?:_\d+)?$/,""),i=`${s}_copy`;if(!Object.hasOwn(t,i))return i;for(let r=2;r<1e3;r++){const o=`${s}_copy_${r}`;if(!Object.hasOwn(t,o))return o}return`${s}_copy_${Date.now()}`}function xb(t){const e=zo(t.newName),s={...t.source,name:t.newName,path:t.newPath};return{key:e,data:s}}function bb(t,e){return sh(t,e)}const yb=1e3;function Sb(t,e){for(let s=0;s<yb;s++){const i=zo(e);if(!Object.hasOwn(t,i))return i}throw new Error("Could not generate a unique page block key")}const wb={create:"Create new page",duplicate:"Duplicate page",rename:"Rename page"},Cb={create:"Create",duplicate:"Duplicate",rename:"Save"},kb={create:"Creating…",duplicate:"Duplicating…",rename:"Saving…"};function jb(t){const e=K.c(54),{open:s,mode:i,initialName:r,initialPath:o,isPending:a,error:l,validate:h,onSubmit:c,onOpenChange:d}=t,u=a===void 0?!1:a,[f,p]=A.useState(r),[m,_]=A.useState(o),[g,x]=A.useState(null),[S,v]=A.useState(s);s!==S&&(v(s),s&&(p(r),_(o),x(null)));let b;e[0]!==u||e[1]!==d?(b=W=>{!W&&!u&&(x(null),d(!1))},e[0]=u,e[1]=d,e[2]=b):b=e[2];const k=b;let w;e[3]!==u||e[4]!==f||e[5]!==c||e[6]!==m||e[7]!==h?(w=async W=>{W.preventDefault();const ee=f.trim(),$=m.trim();if(!ee||!$||u)return;const L=$o($);if(L){x(L);return}const Y=h?.({name:ee,path:$});if(Y){x(Y);return}x(null),await c({name:ee,path:$})},e[3]=u,e[4]=f,e[5]=c,e[6]=m,e[7]=h,e[8]=w):w=e[8];const N=w,j=g??l,R=wb[i];let I;e[9]!==R?(I=n.jsx(bs,{children:n.jsx(ys,{children:R})}),e[9]=R,e[10]=I):I=e[10];let E;e[11]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx("label",{htmlFor:"page-form-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[11]=E):E=e[11];let C;e[12]===Symbol.for("react.memo_cache_sentinel")?(C=W=>p(W.target.value),e[12]=C):C=e[12];let y;e[13]!==u||e[14]!==f?(y=n.jsxs("div",{className:"space-y-1.5",children:[E,n.jsx(Ye,{id:"page-form-name",value:f,onChange:C,placeholder:"My page",autoFocus:!0,disabled:u})]}),e[13]=u,e[14]=f,e[15]=y):y=e[15];let T;e[16]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx("label",{htmlFor:"page-form-path",className:"text-xs font-medium text-muted-foreground",children:"Path"}),e[16]=T):T=e[16];let D;e[17]===Symbol.for("react.memo_cache_sentinel")?(D=W=>_(W.target.value),e[17]=D):D=e[17];let P;e[18]!==u||e[19]!==m?(P=n.jsxs("div",{className:"space-y-1.5",children:[T,n.jsx(Ye,{id:"page-form-path",value:m,onChange:D,placeholder:"/example",disabled:u})]}),e[18]=u,e[19]=m,e[20]=P):P=e[20];let M;e[21]!==j?(M=j&&n.jsx("p",{className:"text-xs text-destructive",children:j}),e[21]=j,e[22]=M):M=e[22];let B;e[23]!==P||e[24]!==M||e[25]!==y?(B=n.jsxs("div",{className:"space-y-4 py-4",children:[y,P,M]}),e[23]=P,e[24]=M,e[25]=y,e[26]=B):B=e[26];let F;e[27]!==d?(F=()=>d(!1),e[27]=d,e[28]=F):F=e[28];let U;e[29]!==u||e[30]!==F?(U=n.jsx(te,{type:"button",variant:"outline",onClick:F,disabled:u,children:"Cancel"}),e[29]=u,e[30]=F,e[31]=U):U=e[31];let z;e[32]!==u||e[33]!==f||e[34]!==m?(z=!f.trim()||!m.trim()||u,e[32]=u,e[33]=f,e[34]=m,e[35]=z):z=e[35];let O;e[36]!==u||e[37]!==i?(O=u?n.jsxs(n.Fragment,{children:[n.jsx(ge,{size:14,className:"animate-spin"}),kb[i]]}):Cb[i],e[36]=u,e[37]=i,e[38]=O):O=e[38];let q;e[39]!==z||e[40]!==O?(q=n.jsx(te,{type:"submit",disabled:z,children:O}),e[39]=z,e[40]=O,e[41]=q):q=e[41];let V;e[42]!==U||e[43]!==q?(V=n.jsxs(Is,{children:[U,q]}),e[42]=U,e[43]=q,e[44]=V):V=e[44];let Q;e[45]!==N||e[46]!==B||e[47]!==V||e[48]!==I?(Q=n.jsx(qt,{className:"sm:max-w-md",children:n.jsxs("form",{onSubmit:N,children:[I,B,V]})}),e[45]=N,e[46]=B,e[47]=V,e[48]=I,e[49]=Q):Q=e[49];let G;return e[50]!==k||e[51]!==s||e[52]!==Q?(G=n.jsx(Gt,{open:s,onOpenChange:k,children:Q}),e[50]=k,e[51]=s,e[52]=Q,e[53]=G):G=e[53],G}function Nb(t){const e=K.c(43),{open:s,blockKey:i,initialName:r,isPending:o,onSubmit:a,onOpenChange:l}=t,h=o===void 0?!1:o,[c,d]=A.useState(r),[u,f]=A.useState(s);s!==u&&(f(s),s&&d(r));let p;e[0]!==h||e[1]!==l?(p=P=>{!P&&!h&&l(!1)},e[0]=h,e[1]=l,e[2]=p):p=e[2];const m=p;let _;e[3]!==h||e[4]!==c||e[5]!==a?(_=async P=>{P.preventDefault();const M=c.trim();!M||h||await a(M)},e[3]=h,e[4]=c,e[5]=a,e[6]=_):_=e[6];const g=_;let x;e[7]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsxs(bs,{children:[n.jsx(ys,{children:"Rename section"}),n.jsx(bo,{children:"Updates the display name. The internal key stays the same so pages referencing this section keep working."})]}),e[7]=x):x=e[7];let S;e[8]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx("label",{htmlFor:"section-rename-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[8]=S):S=e[8];let v;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=P=>d(P.target.value),e[9]=v):v=e[9];let b;e[10]!==h||e[11]!==c?(b=n.jsxs("div",{className:"space-y-1.5",children:[S,n.jsx(Ye,{id:"section-rename-name",value:c,onChange:v,autoFocus:!0,disabled:h})]}),e[10]=h,e[11]=c,e[12]=b):b=e[12];let k;e[13]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Key"}),e[13]=k):k=e[13];let w;e[14]!==i?(w=n.jsxs("div",{className:"space-y-1.5",children:[k,n.jsx(Ye,{value:i,readOnly:!0,disabled:!0,className:"font-mono"})]}),e[14]=i,e[15]=w):w=e[15];let N;e[16]!==b||e[17]!==w?(N=n.jsxs("div",{className:"space-y-4 py-4",children:[b,w]}),e[16]=b,e[17]=w,e[18]=N):N=e[18];let j;e[19]!==l?(j=()=>l(!1),e[19]=l,e[20]=j):j=e[20];let R;e[21]!==h||e[22]!==j?(R=n.jsx(te,{type:"button",variant:"outline",onClick:j,disabled:h,children:"Cancel"}),e[21]=h,e[22]=j,e[23]=R):R=e[23];let I;e[24]!==h||e[25]!==c?(I=!c.trim()||h,e[24]=h,e[25]=c,e[26]=I):I=e[26];let E;e[27]!==h?(E=h?n.jsxs(n.Fragment,{children:[n.jsx(ge,{size:14,className:"animate-spin"}),"Saving…"]}):"Save",e[27]=h,e[28]=E):E=e[28];let C;e[29]!==I||e[30]!==E?(C=n.jsx(te,{type:"submit",disabled:I,children:E}),e[29]=I,e[30]=E,e[31]=C):C=e[31];let y;e[32]!==R||e[33]!==C?(y=n.jsxs(Is,{children:[R,C]}),e[32]=R,e[33]=C,e[34]=y):y=e[34];let T;e[35]!==g||e[36]!==N||e[37]!==y?(T=n.jsx(qt,{className:"sm:max-w-md",children:n.jsxs("form",{onSubmit:g,children:[x,N,y]})}),e[35]=g,e[36]=N,e[37]=y,e[38]=T):T=e[38];let D;return e[39]!==m||e[40]!==s||e[41]!==T?(D=n.jsx(Gt,{open:s,onOpenChange:m,children:T}),e[39]=m,e[40]=s,e[41]=T,e[42]=D):D=e[42],D}const Eb=A.lazy(()=>Ni(()=>import("./sections-editor-DH5JOAp0.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}))),Tb=A.lazy(()=>Ni(()=>import("./add-section-modal-BQo99wbw.js"),__vite__mapDeps([82,1,2,6,7,8,9,10,11,12,13,14,15,16,17,3,4,5,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,45,46,83,84,85,54,86,87,88,53,89,55,90,91,92,42,43,44,93,94,95,96,97,98,99,100,62,101,52,102,67,68,103,66,63,77,104,105,106,76,107,108,61,109,79,74,110,47,111,48,49,50,51,56,57,58,59,60,64,65,69,70,71,72,112,113,114,115,116,117,118,119,80,81,120,121,122,123,124,125,126,127,75,128,129,130,131,132,133,134,135])).then(t=>({default:t.AddSectionModal}))),lo="oklch(0.65 0.15 160)";function Rb(){const t=K.c(21),e=Zo(),{data:s}=ji.useSession(),{currentBranch:i}=rs(),{org:r}=je(),o=e?.entity?.id??null,a=s?.user?.id,l=e?.entity?.metadata,h=a&&i?vi(l?.sandboxMap?.[a]?.[i]):{},c=Object.values(h),u=(c.find(Db)??c[0])?.previewUrl??null,f=ns(),p=f.lifecycle.phase,m=e?.entity?.organization_id??"";let _;t[0]!==r.slug||t[1]!==m?(_={connectionId:vs,orgId:m,orgSlug:r.slug},t[0]=r.slug,t[1]=m,t[2]=_):_=t[2];const g=Xe(_),x=ho(g),S=uo(o??void 0,i??void 0),v=Vt();let b;t[3]!==i||t[4]!==x||t[5]!==o?(b=()=>{if(!o)return;const T={virtualMcpId:o};i&&(T.branch=i),x.mutate(T)},t[3]=i,t[4]=x,t[5]=o,t[6]=b):b=t[6];const k=b,w=p==="start-failed"||p==="install-failed"||p==="clone-failed"?p:null,N=w&&"error"in f.lifecycle?f.lifecycle.error??null:null,j=p==="running"?"online":p==="crashed"?"offline":"booting",R=!!o&&!!i&&Qi.isStopped(o,i),I=rh({previewUrl:u,status:j,htmlSupport:!0,suspended:f.suspended,appPaused:f.status.state==="paused",vmStartPending:S,lastStartError:x.error?.message??null,lifecycleFailure:w,lifecycleFailureError:N,claimPhase:f.phase,notFound:f.notFound,userStopped:R});let E;t[7]!==v?(E=()=>v({to:".",search:Pb,replace:!0}),t[7]=v,t[8]=E):E=t[8];const C=E;if(I.kind!=="iframe"&&I.kind!=="no-html"){let T;return t[9]!==C||t[10]!==I||t[11]!==k||t[12]!==f.lifecycle||t[13]!==f.phase?(T=n.jsx(Lb,{state:I,claimPhase:f.phase,lifecycle:f.lifecycle,onStart:k,onOpenPreview:C}),t[9]=C,t[10]=I,t[11]=k,t[12]=f.lifecycle,t[13]=f.phase,t[14]=T):T=t[14],T}if(!o||!i){let T;return t[15]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx(lr,{title:"Waiting for sandbox context…"}),t[15]=T):T=t[15],T}let y;return t[16]!==i||t[17]!==r.slug||t[18]!==u||t[19]!==o?(y=n.jsx(Ab,{orgSlug:r.slug,virtualMcpId:o,branch:i,previewUrl:u}),t[16]=i,t[17]=r.slug,t[18]=u,t[19]=o,t[20]=y):y=t[20],y}function Pb(t){return{...t,main:"preview"}}function Db(t){return t.sandboxProviderKind!=="user-desktop"}function Ab({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i}){const r={orgSlug:t,virtualMcpId:e,branch:s},{data:o,isLoading:a}=Po(r),{data:l,isLoading:h}=Do(r),c=ih(r),d=ib(r),[u,f]=A.useState("pages"),[p,m]=A.useState(null),[_,g]=A.useState(""),[x,S]=A.useState(u);x!==u&&(S(u),g(""));const[v,b]=A.useState(null),[k,w]=A.useState(),[N,j]=A.useState(!1),[R,I]=A.useState(null),[E,C]=A.useState(null);if(a||h)return n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})});if(!o||!l)return n.jsx(lr,{title:"Could not load site data."});const y=Bo(o).sort(($,L)=>$.name.localeCompare(L.name)),T=Io(o,l);if(y.length===0&&T.length===0)return n.jsx(lr,{icon:Ti,title:"No editable content",description:"This project doesn't expose any Deco pages or sections."});const D={pages:y.length,sections:T.length},P=new Set(y.map($=>pi($.path))),M=new Set(y.map($=>$.name)),B=new Set(T.map($=>$.name)),F=async $=>{const L=o[$.key];if(!L)return;const Y=rd(o,$.key),X=mb(o,$.key,Math.max(0,Y-1)),H=_b(L.sections,X);if(H)try{await c.mutateAsync({blockKey:$.key,data:{...L,sections:H}}),ae.success(`Variant added to "${$.name}"`),m({collection:"pages",key:$.key,path:$.path})}catch(ne){ae.error(ne instanceof Error?ne.message:"Could not add variant")}},U=()=>{w(void 0),b({mode:"create",sourceKey:null,initialName:"My new page",initialPath:"/example"})},z=$=>{w(void 0),b({mode:"duplicate",sourceKey:$.key,initialName:Bl(M,$.name),initialPath:vb(P,$.path)})},O=$=>{w(void 0),b({mode:"rename",sourceKey:$.key,initialName:$.name,initialPath:$.path})},q=async $=>{if(!v)return;const{mode:L,sourceKey:Y}=v;try{if(L==="create"){const X=bb($.name,$.path),H=Sb(o,$.name);await c.mutateAsync({blockKey:H,data:X}),ae.success(`Created "${$.name}"`),m({collection:"pages",key:H,path:$.path})}else if(L==="duplicate"&&Y){const X=o[Y];if(!X)throw new Error("Source page not found");const{key:H,data:ne}=xb({source:X,pages:y,newName:$.name,newPath:$.path});await c.mutateAsync({blockKey:H,data:ne}),ae.success(`Duplicated as "${$.name}"`),m({collection:"pages",key:H,path:$.path})}else if(L==="rename"&&Y){const X=o[Y];if(!X)throw new Error("Page not found");const H={...X,name:$.name,path:$.path};await c.mutateAsync({blockKey:Y,data:H}),ae.success("Page updated"),p?.collection==="pages"&&p.key===Y&&m({collection:"pages",key:Y,path:$.path})}b(null)}catch(X){w(X instanceof Error?X.message:"Save failed")}},V=({path:$})=>{if(!v)return null;const L=pi($);return(v.mode==="rename"?pi(v.initialPath):null)!==L&&P.has(L)?`A page with path "${$}" already exists.`:null},Q=async $=>{const L=($.title||$.resolveType.split("/").pop()||"").replace(/\.(tsx?|jsx?)$/,"").replace(/[^A-Za-z0-9_-]/g,""),Y=/^[A-Za-z]/.test(L)&&L.length>0?L:"Section",X=Il(o,Y),H={__resolveType:$.resolveType,name:X};try{await c.mutateAsync({blockKey:X,data:H}),ae.success(`Created section "${X}"`),j(!1),m({collection:"sections",key:X})}catch(ne){ae.error(ne instanceof Error?ne.message:"Could not create section")}},G=async $=>{const L=o[$.key];if(!L){ae.error("Section not found.");return}const Y=Il(o,$.key),X=Bl(B,$.name),H={...L,name:X};try{await c.mutateAsync({blockKey:Y,data:H}),ae.success(`Duplicated "${$.name}"`),m({collection:"sections",key:Y})}catch(ne){ae.error(ne instanceof Error?ne.message:"Duplicate failed")}},W=async $=>{if(!R)return;const L=o[R];if(!L){ae.error("Section not found.");return}try{await c.mutateAsync({blockKey:R,data:{...L,name:$}}),ae.success("Section renamed"),I(null)}catch(Y){ae.error(Y instanceof Error?Y.message:"Rename failed")}},ee=async()=>{if(!E)return;const{kind:$,key:L,label:Y}=E;try{await d.mutateAsync({blockKey:L}),ae.success(`Deleted "${Y}"`),$==="page"?p?.collection==="pages"&&p.key===L&&m(null):p?.collection==="sections"&&p.key===L&&m(null),C(null)}catch(X){ae.error(X instanceof Error?X.message:"Delete failed")}};return n.jsxs("div",{className:"flex h-full w-full",children:[n.jsx(Mb,{active:u,counts:D,onSelect:$=>{f($),m(null)}}),n.jsx(Bb,{activeCollection:u,pages:y,sections:T,decofile:o,searchQuery:_,onSearchChange:g,selection:p,onSelect:m,previewUrl:i,onCreate:()=>{u==="pages"?U():i?j(!0):ae.error("Start the preview dev server to add sections.")},onDuplicatePage:z,onRenamePage:O,onAddPageVariant:F,onDeletePage:$=>C({kind:"page",key:$.key,label:$.name}),onDuplicateSection:G,onRenameSection:$=>I($.key),onDeleteSection:$=>C({kind:"section",key:$.key,label:$.name})}),n.jsx("div",{className:"flex-1 min-w-0",children:p?n.jsx(A.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(Eb,{orgSlug:t,virtualMcpId:e,branch:s,previewReady:!0,previewUrl:i??void 0,currentPath:p.collection==="pages"?p.path:"/",activePageBlockKey:p.collection==="pages"?p.key:null,activeGlobalBlockKey:p.collection==="sections"?p.key:null},p.collection==="pages"?`page:${p.key}`:`section:${p.key}`)}):n.jsx(lr,{title:u==="pages"?"Select a page to edit":"Select a section to edit",description:u==="pages"?'Pick a page from the list, or click "+ New" to create one.':'Pick a section from the list, or click "+ New" to create one.'})}),v&&n.jsx(jb,{open:!!v,mode:v.mode,initialName:v.initialName,initialPath:v.initialPath,isPending:c.isPending,error:k,validate:V,onSubmit:q,onOpenChange:$=>{$||(b(null),w(void 0))}}),R&&n.jsx(Nb,{open:!!R,blockKey:R,initialName:T.find($=>$.key===R)?.name??R,isPending:c.isPending,onSubmit:W,onOpenChange:$=>{$||I(null)}}),N&&i&&n.jsx(A.Suspense,{fallback:null,children:n.jsx(Tb,{open:N,onOpenChange:j,meta:l,decofile:o,previewBaseUrl:i,onSelect:Q})}),n.jsx(dr,{open:!!E,onOpenChange:$=>{!$&&!d.isPending&&C(null)},children:n.jsxs(ur,{children:[n.jsxs(fr,{children:[n.jsxs(mr,{children:["Delete ",E?.kind==="page"?"page":"section","?"]}),n.jsx(pr,{children:E?.kind==="page"?`"${E.label}" will be removed permanently. This can't be undone.`:E?.kind==="section"?`"${E.label}" will be removed. Pages that still reference it will lose this section.`:null})]}),n.jsxs(_r,{children:[n.jsx(gr,{disabled:d.isPending,children:"Cancel"}),n.jsx(vr,{onClick:$=>{$.preventDefault(),ee()},disabled:d.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:d.isPending?n.jsxs(n.Fragment,{children:[n.jsx(ge,{size:14,className:"animate-spin"}),"Deleting…"]}):"Delete"})]})]})})]})}function Mb(t){const e=K.c(12),{active:s,counts:i,onSelect:r}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("div",{className:"px-3 h-12 flex items-center border-b shrink-0",children:n.jsx("span",{className:"text-sm font-medium",children:"Content"})}),e[0]=o):o=e[0];const a=s==="pages";let l;e[1]!==i.pages||e[2]!==r||e[3]!==a?(l=n.jsx(Ll,{id:"pages",icon:vo,label:"Pages",count:i.pages,active:a,onSelect:r}),e[1]=i.pages,e[2]=r,e[3]=a,e[4]=l):l=e[4];const h=s==="sections";let c;e[5]!==i.sections||e[6]!==r||e[7]!==h?(c=n.jsx(Ll,{id:"sections",icon:yr,label:"Sections",count:i.sections,active:h,onSelect:r}),e[5]=i.sections,e[6]=r,e[7]=h,e[8]=c):c=e[8];let d;return e[9]!==l||e[10]!==c?(d=n.jsxs("div",{className:"w-[208px] shrink-0 border-r flex flex-col",children:[o,n.jsxs("nav",{className:"flex flex-col p-1.5 gap-0.5",children:[l,c]})]}),e[9]=l,e[10]=c,e[11]=d):d=e[11],d}function Ll(t){const e=K.c(20),{id:s,icon:i,label:r,count:o,active:a,onSelect:l}=t;let h;e[0]!==s||e[1]!==l?(h=()=>l(s),e[0]=s,e[1]=l,e[2]=h):h=e[2];const c=a?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground";let d;e[3]!==c?(d=ie("flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors cursor-pointer",c),e[3]=c,e[4]=d):d=e[4];let u;e[5]!==i?(u=n.jsx(i,{size:16,className:"shrink-0"}),e[5]=i,e[6]=u):u=e[6];let f;e[7]!==r?(f=n.jsx("span",{className:"flex-1 truncate",children:r}),e[7]=r,e[8]=f):f=e[8];const p=a?"text-accent-foreground/70":"text-muted-foreground/70";let m;e[9]!==p?(m=ie("shrink-0 text-xs tabular-nums",p),e[9]=p,e[10]=m):m=e[10];let _;e[11]!==o||e[12]!==m?(_=n.jsx("span",{className:m,children:o}),e[11]=o,e[12]=m,e[13]=_):_=e[13];let g;return e[14]!==h||e[15]!==d||e[16]!==u||e[17]!==f||e[18]!==_?(g=n.jsxs("button",{type:"button",onClick:h,className:d,children:[u,f,_]}),e[14]=h,e[15]=d,e[16]=u,e[17]=f,e[18]=_,e[19]=g):g=e[19],g}function Bb(t){const e=K.c(54),{activeCollection:s,pages:i,sections:r,decofile:o,previewUrl:a,searchQuery:l,onSearchChange:h,selection:c,onSelect:d,onCreate:u,onDuplicatePage:f,onRenamePage:p,onAddPageVariant:m,onDeletePage:_,onDuplicateSection:g,onRenameSection:x,onDeleteSection:S}=t;let v,b,k,w,N,j;if(e[0]!==s||e[1]!==o||e[2]!==m||e[3]!==u||e[4]!==_||e[5]!==S||e[6]!==f||e[7]!==g||e[8]!==p||e[9]!==x||e[10]!==h||e[11]!==d||e[12]!==i||e[13]!==a||e[14]!==l||e[15]!==r||e[16]!==c){const C=l.toLowerCase(),y=i.filter(W=>!C||W.name.toLowerCase().includes(C)||W.path.toLowerCase().includes(C)),T=r.filter(W=>!C||W.name.toLowerCase().includes(C)||W.key.toLowerCase().includes(C)||W.resolveType.toLowerCase().includes(C)),D=s==="pages"?"Search pages…":"Search sections…",P=s==="pages"?"Create new page":"Create new section",M=s==="sections"&&!a,B=M?"Start the preview dev server to add sections":void 0;N="w-[300px] shrink-0 border-r flex flex-col min-h-0";let F;e[23]===Symbol.for("react.memo_cache_sentinel")?(F=n.jsx(yc,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),e[23]=F):F=e[23];let U;e[24]!==h?(U=W=>h(W.target.value),e[24]=h,e[25]=U):U=e[25];let z;e[26]!==D||e[27]!==l||e[28]!==U?(z=n.jsxs("div",{className:"flex flex-1 items-center gap-2 pl-1",children:[F,n.jsx("input",{type:"text",value:l,onChange:U,placeholder:D,"aria-label":D,className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),e[26]=D,e[27]=l,e[28]=U,e[29]=z):z=e[29];let O;e[30]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(Kt,{size:14}),e[30]=O):O=e[30];let q;e[31]!==P||e[32]!==u||e[33]!==M?(q=n.jsx(Se,{asChild:!0,children:n.jsx(te,{variant:"ghost",size:"icon",onClick:u,disabled:M,"aria-label":P,"aria-disabled":M,children:O})}),e[31]=P,e[32]=u,e[33]=M,e[34]=q):q=e[34];const V=B??P;let Q;e[35]!==V?(Q=n.jsx(we,{side:"bottom",children:V}),e[35]=V,e[36]=Q):Q=e[36];let G;e[37]!==q||e[38]!==Q?(G=n.jsxs(Ce,{children:[q,Q]}),e[37]=q,e[38]=Q,e[39]=G):G=e[39],e[40]!==G||e[41]!==z?(j=n.jsxs("div",{className:"px-2 h-12 flex items-center gap-1 border-b shrink-0",children:[z,G]}),e[40]=G,e[41]=z,e[42]=j):j=e[42],v=So,w="flex-1 min-h-0",b="flex flex-col gap-1 p-1.5",k=s==="pages"?y.length===0?n.jsx(zl,{hasItems:i.length>0,emptyLabel:"No pages yet.",emptyHint:'Click "+" to create your first page.'}):y.map(W=>{const ee=c?.collection==="pages"&&c.key===W.key,$=rd(o,W.key);return n.jsx(Ol,{icon:vo,title:W.name,subtitle:W.path,active:ee,variantCount:$,onClick:()=>d({collection:"pages",key:W.key,path:W.path}),menu:n.jsx($l,{onDuplicate:()=>f(W),onRename:()=>p(W),onAddVariant:()=>m(W),onDelete:()=>_(W)})},W.key)}):T.length===0?n.jsx(zl,{hasItems:r.length>0,emptyLabel:"No saved sections yet.",emptyHint:'Click "+" to create one, or save a section from a page.'}):T.map(W=>{const ee=c?.collection==="sections"&&c.key===W.key,$=W.resolveType.split("/").pop()?.replace(/\.tsx?$/,"");return n.jsx(Ol,{icon:yr,title:W.name,subtitle:$??W.resolveType,active:ee,onClick:()=>d({collection:"sections",key:W.key}),menu:n.jsx($l,{onDuplicate:()=>g(W),onRename:()=>x(W),onDelete:()=>S(W)})},W.key)}),e[0]=s,e[1]=o,e[2]=m,e[3]=u,e[4]=_,e[5]=S,e[6]=f,e[7]=g,e[8]=p,e[9]=x,e[10]=h,e[11]=d,e[12]=i,e[13]=a,e[14]=l,e[15]=r,e[16]=c,e[17]=v,e[18]=b,e[19]=k,e[20]=w,e[21]=N,e[22]=j}else v=e[17],b=e[18],k=e[19],w=e[20],N=e[21],j=e[22];let R;e[43]!==b||e[44]!==k?(R=n.jsx("div",{className:b,children:k}),e[43]=b,e[44]=k,e[45]=R):R=e[45];let I;e[46]!==v||e[47]!==w||e[48]!==R?(I=n.jsx(v,{className:w,children:R}),e[46]=v,e[47]=w,e[48]=R,e[49]=I):I=e[49];let E;return e[50]!==N||e[51]!==j||e[52]!==I?(E=n.jsxs("div",{className:N,children:[j,I]}),e[50]=N,e[51]=j,e[52]=I,e[53]=E):E=e[53],E}function Ol(t){const e=K.c(27),{icon:s,title:i,subtitle:r,active:o,variantCount:a,onClick:l,menu:h}=t,c=o?"bg-accent text-accent-foreground":"hover:bg-muted";let d;e[0]!==c?(d=ie("group relative flex items-center rounded-md transition-colors",c),e[0]=c,e[1]=d):d=e[1];let u;e[2]!==s||e[3]!==o||e[4]!==a?(u=a&&a>1?n.jsxs(Ce,{children:[n.jsx(Se,{asChild:!0,children:n.jsx(s,{size:16,className:"shrink-0",style:{color:lo}})}),n.jsxs(we,{side:"right",children:[a," variants"]})]}):n.jsx(s,{size:16,className:ie("shrink-0",o?"text-accent-foreground":"text-muted-foreground")}),e[2]=s,e[3]=o,e[4]=a,e[5]=u):u=e[5];let f;e[6]!==i?(f=n.jsx("span",{className:"block truncate text-sm font-medium",children:i}),e[6]=i,e[7]=f):f=e[7];const p=o?"text-accent-foreground/70":"text-muted-foreground";let m;e[8]!==p?(m=ie("block truncate text-xs",p),e[8]=p,e[9]=m):m=e[9];let _;e[10]!==r||e[11]!==m?(_=n.jsx("span",{className:m,children:r}),e[10]=r,e[11]=m,e[12]=_):_=e[12];let g;e[13]!==f||e[14]!==_?(g=n.jsxs("span",{className:"min-w-0 flex-1",children:[f,_]}),e[13]=f,e[14]=_,e[15]=g):g=e[15];let x;e[16]!==l||e[17]!==u||e[18]!==g?(x=n.jsxs("button",{type:"button",onClick:l,className:"flex min-w-0 flex-1 items-center gap-2.5 rounded-md px-2.5 py-2 text-left cursor-pointer",children:[u,g]}),e[16]=l,e[17]=u,e[18]=g,e[19]=x):x=e[19];let S;e[20]!==o||e[21]!==h?(S=h&&n.jsx("div",{className:ie("pr-1 opacity-0 transition-opacity group-hover:opacity-100",o&&"opacity-100"),children:h}),e[20]=o,e[21]=h,e[22]=S):S=e[22];let v;return e[23]!==S||e[24]!==d||e[25]!==x?(v=n.jsxs("div",{className:d,children:[x,S]}),e[23]=S,e[24]=d,e[25]=x,e[26]=v):v=e[26],v}function $l(t){const e=K.c(18),{onDuplicate:s,onRename:i,onAddVariant:r,onDelete:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(Hs,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":"More actions",className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-background hover:text-foreground cursor-pointer",onClick:Ib,children:n.jsx(Br,{size:14})})}),e[0]=a):a=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(_c,{size:14}),e[1]=l):l=e[1];let h;e[2]!==i?(h=n.jsxs(ut,{onClick:i,children:[l,"Rename"]}),e[2]=i,e[3]=h):h=e[3];let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(ss,{size:14}),e[4]=c):c=e[4];let d;e[5]!==s?(d=n.jsxs(ut,{onClick:s,children:[c,"Duplicate"]}),e[5]=s,e[6]=d):d=e[6];let u;e[7]!==r?(u=r&&n.jsxs(n.Fragment,{children:[n.jsx(xa,{}),n.jsxs(ut,{onClick:r,className:"cursor-pointer",style:{color:lo},children:[n.jsx(ku,{size:14,style:{color:lo}}),"Add variant"]})]}),e[7]=r,e[8]=u):u=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(xa,{}),e[9]=f):f=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(xi,{size:14}),e[10]=p):p=e[10];let m;e[11]!==o?(m=n.jsxs(ut,{onClick:o,className:"text-destructive focus:text-destructive",children:[p,"Delete"]}),e[11]=o,e[12]=m):m=e[12];let _;return e[13]!==h||e[14]!==d||e[15]!==u||e[16]!==m?(_=n.jsxs(Fs,{children:[a,n.jsxs(Ws,{align:"end",className:"w-44",children:[h,d,u,f,m]})]}),e[13]=h,e[14]=d,e[15]=u,e[16]=m,e[17]=_):_=e[17],_}function Ib(t){return t.stopPropagation()}function zl(t){const e=K.c(6),{hasItems:s,emptyLabel:i,emptyHint:r}=t;let o;e[0]!==r||e[1]!==i||e[2]!==s?(o=s?"No results match your search.":n.jsxs(n.Fragment,{children:[n.jsx("div",{children:i}),n.jsx("div",{className:"mt-1 text-muted-foreground/80",children:r})]}),e[0]=r,e[1]=i,e[2]=s,e[3]=o):o=e[3];let a;return e[4]!==o?(a=n.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o}),e[4]=o,e[5]=a):a=e[5],a}function Lb(t){const e=K.c(26),{state:s,claimPhase:i,lifecycle:r,onStart:o,onOpenPreview:a}=t;let l;e[0]!==i||e[1]!==r?(l=oh({claimPhase:i,lifecycle:r}),e[0]=i,e[1]=r,e[2]=l):l=e[2];const h=l;switch(s.kind){case"never-started":{let c;return e[3]!==o?(c=n.jsx(xt,{kind:"never-started",onStart:o}),e[3]=o,e[4]=c):c=e[4],c}case"starting-now":{let c;return e[5]!==i||e[6]!==h?(c=n.jsx(xt,{kind:"starting-now",progress:h,claimPhase:i}),e[5]=i,e[6]=h,e[7]=c):c=e[7],c}case"suspended":{let c;return e[8]!==o?(c=n.jsx(xt,{kind:"suspended",onResume:o}),e[8]=o,e[9]=c):c=e[9],c}case"crashed":{let c;return e[10]!==a?(c=n.jsx(xt,{kind:"crashed",onOpenTerminal:a}),e[10]=a,e[11]=c):c=e[11],c}case"errored":{let c;e[12]!==s.error?(c=s.error.split(`
|
|
291
291
|
`)[0]??"Failed to start",e[12]=s.error,e[13]=c):c=e[13];let d;return e[14]!==o||e[15]!==h||e[16]!==c?(d=n.jsx(xt,{kind:"errored",progress:h,logSource:"setup",errorLine:c,onRetry:o,drawerOpen:!0}),e[14]=o,e[15]=h,e[16]=c,e[17]=d):d=e[17],d}case"dev-script-failed":{const c=s.failure==="start-failed"?"dev":"setup";let d;e[18]!==s.error?(d=s.error.split(`
|
|
292
292
|
`)[0]??"Dev script exited",e[18]=s.error,e[19]=d):d=e[19];let u;return e[20]!==a||e[21]!==o||e[22]!==h||e[23]!==c||e[24]!==d?(u=n.jsx(xt,{kind:"dev-script-failed",progress:h,logSource:c,errorLine:d,onRetry:o,onOpenTerminal:a,onBrowseFiles:a,drawerOpen:!0}),e[20]=a,e[21]=o,e[22]=h,e[23]=c,e[24]=d,e[25]=u):u=e[25],u}}}function lr(t){const e=K.c(10),{icon:s,title:i,description:r}=t;let o;e[0]!==s?(o=s&&n.jsx(s,{size:24,className:"text-muted-foreground/60"}),e[0]=s,e[1]=o):o=e[1];let a;e[2]!==i?(a=n.jsx("div",{children:i}),e[2]=i,e[3]=a):a=e[3];let l;e[4]!==r?(l=r&&n.jsx("div",{className:"text-xs text-muted-foreground/80 max-w-sm",children:r}),e[4]=r,e[5]=l):l=e[5];let h;return e[6]!==o||e[7]!==a||e[8]!==l?(h=n.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 p-6 text-center text-sm text-muted-foreground",children:[o,a,l]}),e[6]=o,e[7]=a,e[8]=l,e[9]=h):h=e[9],h}function Ob(t){const e=K.c(2),{virtualMcpId:s}=t,i=At(s);if(!Ei(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(Ti,{size:24,className:"text-muted-foreground/60"}),n.jsx("div",{children:"No content to edit."}),n.jsx("div",{className:"text-xs text-muted-foreground/80",children:"Connect a GitHub repository from the Settings tab to enable Content."})]}),e[0]=a):a=e[0],a}let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(Rb,{}),e[1]=o):o=e[1],o}function $b(t){const e=K.c(3),{tier:s,onSelect:i}=t;let r;return e[0]!==i||e[1]!==s?(r=n.jsx($d,{tier:s,subtitleFor:zb,iconFor:zd,onSelect:i}),e[0]=i,e[1]=s,e[2]=r):r=e[2],r}function zb(t){return Fd("cloud-decopilot",t)}function gi(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function Fb(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 Hb(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 Wb(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 Ub(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const Kb=[{label:"5 minutes",cron:"*/5 * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function Vb({automationId:t,open:e,onOpenChange:s,onCustomSelect:i,onEventSelect:r,onWebhookCreated:o}){const{triggerAdd:a}=Pi(),[l,h]=A.useState(!1),c=e??l,d=p=>{s?s(p):h(p)},u=async p=>{try{await a.mutateAsync({automation_id:t,type:"cron",cron_expression:p}),ae.success("Starter added"),d(!1)}catch(m){const _=m instanceof Error?m.message:"Failed to add starter";ae.error(_)}},f=async()=>{try{const p=await a.mutateAsync({automation_id:t,type:"webhook"});d(!1),p.webhook?o?.(p.webhook):ae.success("Webhook starter added")}catch(p){const m=p instanceof Error?p.message:"Failed to add webhook starter";ae.error(m)}};return n.jsxs(Fs,{open:c,onOpenChange:d,children:[n.jsx(Hs,{asChild:!0,children:n.jsxs(te,{variant:"outline",size:"sm",children:[n.jsx(Kt,{size:14}),"Add Starter"]})}),n.jsxs(Ws,{align:"end",className:"w-[200px]",children:[n.jsxs(vf,{children:[n.jsxs(xf,{className:"gap-2.5",children:[n.jsx(fi,{size:14,className:"text-muted-foreground shrink-0"}),"Every..."]}),n.jsx(bf,{className:"w-[160px]",children:Kb.map(p=>n.jsxs(ut,{className:"gap-2.5",onSelect:()=>u(p.cron),disabled:a.isPending,children:[n.jsx(fi,{size:14,className:"text-muted-foreground shrink-0"}),"Every ",p.label]},p.cron))})]}),n.jsxs(ut,{className:"gap-2.5",onSelect:()=>{d(!1),i?.()},children:[n.jsx(fi,{size:14,className:"text-muted-foreground shrink-0"}),"Custom (cron)"]}),n.jsxs(ut,{className:"gap-2.5",onSelect:()=>{d(!1),r?.()},children:[n.jsx(bi,{size:14,className:"text-muted-foreground shrink-0"}),"Event"]}),n.jsxs(ut,{className:"gap-2.5",onSelect:()=>{f()},disabled:a.isPending,children:[n.jsx(mo,{size:14,className:"text-muted-foreground shrink-0"}),"Webhook"]})]})]})}function nd(t){const e=K.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]=A.useState(null),[f,p]=A.useState("curl"),[m,_]=A.useState("header"),g=A.useId();let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=async(D,P)=>{try{await navigator.clipboard.writeText(D),u(P),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]!==m||e[2]!==o||e[3]!==r?(v=r&&o&&m==="url"?`${r.replace(/\/$/,"")}/${o}`:r??"",e[1]=m,e[2]=o,e[3]=r,e[4]=v):v=e[4];const b=v,k=r&&o?m==="header"?`curl -X POST "${b}" \\
|
|
293
293
|
-H "Authorization: Bearer ${o}" \\
|
|
@@ -308,6 +308,6 @@ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){t
|
|
|
308
308
|
},
|
|
309
309
|
body: JSON.stringify({ hello: "world" }),
|
|
310
310
|
});`:"",N=f==="curl"?k:w;let j;e[5]!==h?(j=n.jsx(ys,{children:h}),e[5]=h,e[6]=j):j=e[6];let R;e[7]!==c?(R=n.jsx(bo,{children:c}),e[7]=c,e[8]=R):R=e[8];let I;e[9]!==j||e[10]!==R?(I=n.jsxs(bs,{children:[j,R]}),e[9]=j,e[10]=R,e[11]=I):I=e[11];let E;e[12]!==m||e[13]!==d||e[14]!==b||e[15]!==f||e[16]!==N||e[17]!==o||e[18]!==g||e[19]!==r?(E=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(te,{size:"sm",variant:"outline",onClick:()=>S(b,"url"),children:[n.jsx(ss,{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(te,{size:"sm",variant:"outline",onClick:()=>S(o,"token"),children:[n.jsx(ss,{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(Co,{value:f,onValueChange:D=>p(D),children:n.jsxs(wo,{className:"h-8 p-[2px]",children:[n.jsx(hs,{value:"curl",className:"h-7 px-2.5 text-xs",children:"curl"}),n.jsx(hs,{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(vc,{id:g,checked:m==="url",onCheckedChange:D=>_(D?"url":"header")}),"Token in URL"]})]}),n.jsxs(te,{size:"sm",variant:"outline",onClick:()=>S(N,"example"),children:[n.jsx(ss,{size:13}),d==="example"?"Copied":"Copy"]})]}),n.jsx("div",{className:"rounded-md border overflow-hidden min-w-0",children:n.jsx(gf,{code:N,language:f==="curl"?"shell":"typescript",readOnly:!0,disableDiagnostics:!0,height:180})})]})]}):null,e[12]=m,e[13]=d,e[14]=b,e[15]=f,e[16]=N,e[17]=o,e[18]=g,e[19]=r,e[20]=E):E=e[20];let C;e[21]!==i?(C=n.jsx(Is,{children:n.jsx(te,{onClick:()=>i(!1),children:"Done"})}),e[21]=i,e[22]=C):C=e[22];let y;e[23]!==I||e[24]!==E||e[25]!==C?(y=n.jsxs(qt,{className:"max-w-lg",children:[I,E,C]}),e[23]=I,e[24]=E,e[25]=C,e[26]=y):y=e[26];let T;return e[27]!==i||e[28]!==s||e[29]!==y?(T=n.jsx(Gt,{open:s,onOpenChange:i,children:y}),e[27]=i,e[28]=s,e[29]=y,e[30]=T):T=e[30],T}function qb(t){const e=K.c(83),{trigger:s,automationId:i,connectionName:r}=t,{triggerAdd:o,triggerRemove:a,triggerRotateToken:l}=Pi(),[h,c]=A.useState(!1),[d,u]=A.useState(!1),[f,p]=A.useState(null);let m;e[0]!==s.cron_expression?(m=s.cron_expression?Wb(s.cron_expression):null,e[0]=s.cron_expression,e[1]=m):m=e[1];const _=m,[g,x]=A.useState(_?.count??1),[S,v]=A.useState(!1),[b,k]=A.useState(s.cron_expression??""),w=a.isPending||o.isPending||l.isPending,N=s.type==="cron",j=s.type==="webhook";let R;e[2]!==i||e[3]!==a||e[4]!==s.id?(R=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]=R):R=e[5];const I=R;let E;e[6]!==o||e[7]!==i||e[8]!==b||e[9]!==a||e[10]!==s.cron_expression||e[11]!==s.id?(E=async()=>{const le=b.trim();if(!le||!gi(le)||le===s.cron_expression){v(!1),k(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"),k(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]=E):E=e[12];const C=E;let y;e[13]!==i||e[14]!==l||e[15]!==s.id?(y=async()=>{u(!1);try{const le=await l.mutateAsync({trigger_id:s.id,automation_id:i});p({url:le.url,token:le.token})}catch(le){const ve=le,xe=ve instanceof Error?ve.message:"Failed to rotate token";ae.error(xe)}},e[13]=i,e[14]=l,e[15]=s.id,e[16]=y):y=e[16];const T=y;let D;e[17]!==o||e[18]!==i||e[19]!==_||e[20]!==a||e[21]!==s.cron_expression||e[22]!==s.id?(D=async le=>{if(!_)return;const ve=_.unit==="minutes"?5:1,xe=Math.max(ve,le);xe!==le&&x(xe);const Ne=Hb(xe,_.unit);if(Ne!==s.cron_expression)try{await o.mutateAsync({automation_id:i,type:"cron",cron_expression:Ne}),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]=D):D=e[23];const P=D;let M;e[24]!==N||e[25]!==j?(M=N?n.jsx(fi,{size:14,className:"text-muted-foreground shrink-0"}):j?n.jsx(mo,{size:14,className:"text-muted-foreground shrink-0"}):n.jsx(bi,{size:14,className:"text-muted-foreground shrink-0"}),e[24]=N,e[25]=j,e[26]=M):M=e[26];let B;e[27]!==r||e[28]!==g||e[29]!==b||e[30]!==P||e[31]!==C||e[32]!==_||e[33]!==N||e[34]!==S||e[35]!==w||e[36]!==j||e[37]!==s.cron_expression||e[38]!==s.event_type||e[39]!==s.params?(B=_&&N?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:()=>P(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:Ub(_.unit,g)})]}):N&&S?n.jsxs(n.Fragment,{children:[n.jsx("input",{type:"text",value:b,onChange:le=>k(le.target.value),onBlur:C,onKeyDown:le=>{le.key==="Enter"&&le.target.blur(),le.key==="Escape"&&(v(!1),k(s.cron_expression??""))},className:"flex-1 text-sm font-mono bg-transparent outline-none",autoFocus:!0}),b&&!gi(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:N?Fb(s.cron_expression??""):j?"Webhook · POST to fire":`${s.event_type}${r?` · ${r}`:""}`}),!N&&!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(Gb).join(", ")})]}),e[27]=r,e[28]=g,e[29]=b,e[30]=P,e[31]=C,e[32]=_,e[33]=N,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]=B):B=e[40];let F;e[41]!==w?(F=w&&n.jsx(ge,{size:13,className:"animate-spin text-muted-foreground"}),e[41]=w,e[42]=F):F=e[42];let U;e[43]!==_||e[44]!==N||e[45]!==S||e[46]!==s.cron_expression?(U=N&&!_&&!S&&n.jsx(te,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{k(s.cron_expression??""),v(!0)},children:n.jsx(_c,{size:13,className:"text-muted-foreground"})}),e[43]=_,e[44]=N,e[45]=S,e[46]=s.cron_expression,e[47]=U):U=e[47];let z;e[48]!==j?(z=j&&n.jsx(te,{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(fs,{size:13,className:"text-muted-foreground"})}),e[48]=j,e[49]=z):z=e[49];let O;e[50]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(te,{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(As,{size:13,className:"text-muted-foreground"})}),e[50]=O):O=e[50];let q;e[51]!==z||e[52]!==F||e[53]!==U?(q=n.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[F,U,z,O]}),e[51]=z,e[52]=F,e[53]=U,e[54]=q):q=e[54];let V;e[55]!==q||e[56]!==M||e[57]!==B?(V=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,B,q]}),e[55]=q,e[56]=M,e[57]=B,e[58]=V):V=e[58];let Q;e[59]===Symbol.for("react.memo_cache_sentinel")?(Q=n.jsxs(fr,{children:[n.jsx(mr,{children:"Remove Starter"}),n.jsx(pr,{children:"Are you sure you want to remove this starter?"})]}),e[59]=Q):Q=e[59];let G;e[60]===Symbol.for("react.memo_cache_sentinel")?(G=n.jsx(gr,{children:"Cancel"}),e[60]=G):G=e[60];let W;e[61]!==I?(W=n.jsxs(ur,{children:[Q,n.jsxs(_r,{children:[G,n.jsx(vr,{onClick:I,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]}),e[61]=I,e[62]=W):W=e[62];let ee;e[63]!==h||e[64]!==W?(ee=n.jsx(dr,{open:h,onOpenChange:c,children:W}),e[63]=h,e[64]=W,e[65]=ee):ee=e[65];let $;e[66]===Symbol.for("react.memo_cache_sentinel")?($=n.jsxs(fr,{children:[n.jsx(mr,{children:"Rotate webhook token"}),n.jsx(pr,{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]=$):$=e[66];let L;e[67]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx(gr,{children:"Cancel"}),e[67]=L):L=e[67];let Y;e[68]!==T?(Y=n.jsxs(ur,{children:[$,n.jsxs(_r,{children:[L,n.jsx(vr,{onClick:T,children:"Rotate"})]})]}),e[68]=T,e[69]=Y):Y=e[69];let X;e[70]!==d||e[71]!==Y?(X=n.jsx(dr,{open:d,onOpenChange:u,children:Y}),e[70]=d,e[71]=Y,e[72]=X):X=e[72];const H=f!==null;let ne;e[73]===Symbol.for("react.memo_cache_sentinel")?(ne=le=>{le||p(null)},e[73]=ne):ne=e[73];const re=f?.url??null,ce=f?.token??null;let de;e[74]!==H||e[75]!==re||e[76]!==ce?(de=n.jsx(nd,{open:H,onOpenChange:ne,url:re,token:ce,title:"New webhook token",description:"The previous token has been revoked. Copy the new token now — it will not be shown again."}),e[74]=H,e[75]=re,e[76]=ce,e[77]=de):de=e[77];let me;return e[78]!==V||e[79]!==ee||e[80]!==X||e[81]!==de?(me=n.jsxs(n.Fragment,{children:[V,ee,X,de]}),e[78]=V,e[79]=ee,e[80]=X,e[81]=de,e[82]=me):me=e[82],me}function Gb(t){const[e,s]=t;return`${e}: ${s}`}function Yb(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 Xb(t){const e=K.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=Ir(r),[a,l]=A.useState(),[h,c]=A.useState();let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d={},e[1]=d):d=e[1];const[u,f]=A.useState(d),{triggerAdd:p}=Pi(),{data:m,isLoading:_}=Rf(a);let g,x,S,v,b,k;if(e[2]!==p||e[3]!==s||e[4]!==a||e[5]!==h||e[6]!==_||e[7]!==i||e[8]!==u||e[9]!==o||e[10]!==m){const j=m?.find(B=>B.type===h);let R;e[17]!==p||e[18]!==s||e[19]!==a||e[20]!==h||e[21]!==i||e[22]!==u?(R=async()=>{if(!(!a||!h))try{await p.mutateAsync({automation_id:s,type:"event",event_type:h,connection_id:a,params:u}),Me("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]=p,e[18]=s,e[19]=a,e[20]=h,e[21]=i,e[22]=u,e[23]=R):R=e[23],g=R,x="flex flex-col gap-3 px-3 py-3 rounded-lg border border-border bg-background";let I,E;e[24]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx(bi,{size:14,className:"text-muted-foreground shrink-0"}),I=n.jsx("span",{className:"text-sm font-medium",children:"Event trigger"}),e[24]=I,e[25]=E):(I=e[24],E=e[25]);let C;e[26]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(As,{size:13}),e[26]=C):C=e[26],e[27]!==i?(S=n.jsxs("div",{className:"flex items-center gap-2",children:[E,I,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 y=a??"";let T;e[29]===Symbol.for("react.memo_cache_sentinel")?(T=B=>{l(B),c(void 0),f({})},e[29]=T):T=e[29];let D;e[30]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx(Ft,{className:"w-full",children:n.jsx(Ht,{placeholder:"Select connection..."})}),e[30]=D):D=e[30];let P;e[31]!==o?(P=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(Qb),e[31]=o,e[32]=P):P=e[32];let M;e[33]!==P?(M=n.jsx(Wt,{children:P}),e[33]=P,e[34]=M):M=e[34],e[35]!==y||e[36]!==M?(v=n.jsxs(zt,{value:y,onValueChange:T,children:[D,M]}),e[35]=y,e[36]=M,e[37]=v):v=e[37],e[38]!==a||e[39]!==h||e[40]!==_||e[41]!==m?(b=a&&n.jsxs(zt,{value:h??"",onValueChange:B=>{c(B),f({})},children:[n.jsx(Ft,{className:"w-full",children:_?n.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[n.jsx(ge,{size:13,className:"animate-spin"}),"Loading events..."]}):n.jsx(Ht,{placeholder:"Select event type...",children:h??"Select event type..."})}),n.jsx(Wt,{children:m?.map(Zb)})]}),e[38]=a,e[39]=h,e[40]=_,e[41]=m,e[42]=b):b=e[42],k=j?.paramsSchema&&Object.keys(j.paramsSchema).length>0&&n.jsx("div",{className:"flex flex-col gap-2",children:Object.entries(j.paramsSchema).map(B=>{const[F,U]=B;return n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsxs("label",{className:"text-xs text-muted-foreground",children:[F,U.description&&n.jsxs("span",{className:"text-muted-foreground/60",children:[" ","— ",U.description]})]}),U.enum?n.jsxs(zt,{value:u[F]??"",onValueChange:z=>f(O=>({...O,[F]:z})),children:[n.jsx(Ft,{className:"w-full",children:n.jsx(Ht,{placeholder:`Select ${F}...`})}),n.jsx(Wt,{children:U.enum.map(Jb)})]}):n.jsx("input",{type:"text",value:u[F]??"",onChange:z=>f(O=>({...O,[F]:z.target.value})),placeholder:U.description??F,className:"text-sm border border-border rounded-md bg-background px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-ring"})]},F)})}),e[2]=p,e[3]=s,e[4]=a,e[5]=h,e[6]=_,e[7]=i,e[8]=u,e[9]=o,e[10]=m,e[11]=g,e[12]=x,e[13]=S,e[14]=v,e[15]=b,e[16]=k}else g=e[11],x=e[12],S=e[13],v=e[14],b=e[15],k=e[16];let w;e[43]!==p||e[44]!==a||e[45]!==h||e[46]!==g?(w=a&&h&&n.jsx(te,{size:"sm",onClick:g,disabled:p.isPending,children:p.isPending?n.jsx(ge,{size:13,className:"animate-spin"}):"Add trigger"}),e[43]=p,e[44]=a,e[45]=h,e[46]=g,e[47]=w):w=e[47];let N;return e[48]!==x||e[49]!==S||e[50]!==v||e[51]!==b||e[52]!==k||e[53]!==w?(N=n.jsxs("div",{className:x,children:[S,v,b,k,w]}),e[48]=x,e[49]=S,e[50]=v,e[51]=b,e[52]=k,e[53]=w,e[54]=N):N=e[54],N}function Jb(t){return n.jsx(ft,{value:t,children:t},t)}function Zb(t){return n.jsx(ft,{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 Qb(t){return n.jsx(ft,{value:t.id,children:t.title},t.id)}function e0({automationId:t,automation:e,onBack:s,onDelete:i}){const r=e.virtual_mcp_id,{org:o}=je(),{update:a,triggerAdd:l}=Pi(),h=Ir(),c=new Map(h.map(H=>[H.id,H.title])),{createTaskWithMessage:d}=rs(),{setSimpleModeTier:u}=Pr(),{setChatOpen:f}=_o(),{sendMessage:p}=xs(),[m,_]=Id(),g=e.messages?.[0]?.metadata?.tiptapDoc??void 0,[x,S]=A.useState(g),[v,b]=A.useState(!1),[k,w]=A.useState(!1),[N,j]=A.useState(""),[R,I]=A.useState(!1),[E,C]=A.useState(null),[y,T]=A.useState(!1),[D,P]=A.useState(!1),[M,B]=A.useState(!1),F=async()=>{if(y)return;const ne=ha(x).filter(re=>re.type==="text").map(re=>re.text).join(`
|
|
311
|
-
`);if(ne.trim()){T(!0);try{L(),Me("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:ne.length}),f(!0),await p({tiptapDoc:Wc({managerAgentId:Ql.AUTOMATION_MANAGER(o.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:ne})})}finally{T(!1)}}},U=e.models?.tier??"smart",z=Zl({defaultValues:{name:e.name,active:e.active,tier:U}}),O=z.watch("active"),[q,V]=A.useReducer(Yb,null),Q=()=>{q!==null&&(Me("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(q.fields),save_count:q.saveCount,edit_duration_ms:Date.now()-q.start}),V({type:"reset"}))},G=async()=>{const H=z.control._formState.dirtyFields,ne=Object.keys(H);if(ne.length===0&&!M)return!0;const re=z.getValues(),ce=z.control._defaultValues;z.reset(re,{keepValues:!0});const de=M;B(!1);const me={id:t,name:re.name,active:re.active,models:{tier:re.tier},messages:Yd(x),temperature:0};try{await a.mutateAsync(me)}catch{return z.reset(ce,{keepValues:!0}),de&&B(!0),!1}const le=[...ne];return de&&le.push("messages"),V({type:"accumulate",now:Date.now(),fields:le}),$(),!0},{schedule:W,flush:ee}=br({save:G}),{schedule:$,flush:L}=br({delayMs:3e4,save:async()=>Q()});A.useEffect(()=>{const H=z.watch(()=>W());return()=>H.unsubscribe()},[]);const Y=H=>{if(S(H),!D){P(!0);return}B(!0),W()},X=async()=>{Me("automation_test_clicked",{automation_id:t,agent_id:r});const H=await ee();if(L(),!H)return;if(!x){ae.error("No instructions configured for this automation");return}u(z.getValues("tier")),f(!0),_({...m,toolApprovalLevel:"auto"});const ne=ha(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(te,{variant:"ghost",size:"sm",onClick:s,children:[n.jsx(of,{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(dt,{control:z.control,name:"name",render:({field:H})=>n.jsx(Ye,{...H,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(te,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:i,children:n.jsx(xi,{size:14})})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(dt,{control:z.control,name:"active",render:({field:H})=>n.jsx(Sn,{checked:H.value,onCheckedChange:ne=>{H.onChange(ne),ee()},className:"cursor-pointer"})}),n.jsx("span",{className:"text-sm text-muted-foreground",children:O?"Active":"Inactive"}),n.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),n.jsx(uc,{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(Vb,{automationId:t,open:v,onOpenChange:b,onCustomSelect:()=>{w(!0),I(!1),j("")},onEventSelect:()=>{I(!0),w(!1)},onWebhookCreated:H=>{Me("automation_trigger_added",{automation_id:t,trigger_type:"webhook"}),C(H)}})]}),e.triggers.length===0&&!k?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(H=>n.jsx(qb,{trigger:H,automationId:t,connectionName:H.connection_id?c.get(H.connection_id):void 0},H.id))}),k&&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(fi,{size:14,className:"text-muted-foreground shrink-0"}),n.jsx("input",{type:"text",value:N,onChange:H=>j(H.target.value),onBlur:async()=>{const H=N.trim();if(!(!H||!gi(H)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:H}),Me("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 H=>{const ne=N.trim();H.key==="Enter"&&ne&&gi(ne)&&H.target.blur(),H.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}),N&&!gi(N)&&n.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&n.jsx(ge,{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(As,{size:13})})]}),R&&n.jsx(A.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(ge,{size:13,className:"animate-spin text-muted-foreground"}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:n.jsx(Xb,{automationId:t,onDone:()=>I(!1)})}),n.jsx(nd,{open:E!==null,onOpenChange:H=>{H||C(null)},url:E?.url??null,token:E?.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(te,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:y||!x,onClick:F,children:[n.jsx(yo,{size:13}),"Improve"]})]}),n.jsx(Hd,{tiptapDoc:x,setTiptapDoc:Y,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(Wd,{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($b,{tier:z.watch("tier"),onSelect:H=>z.setValue("tier",H,{shouldDirty:!0})}),n.jsxs(Ce,{children:[n.jsx(Se,{asChild:!0,children:n.jsxs(te,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:X,disabled:!r,children:[n.jsx(Bf,{size:16}),"Test"]})}),n.jsx(we,{children:"Test Automation"})]})]})]})})]})]})]})}function t0(t){const e=K.c(5),{tabId:s}=t;let i;e[0]!==s?(i=cc(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(ge,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=o):o=e[2];let a;return e[3]!==r.id?(a=n.jsx(Ct,{children:n.jsx(Ct.Content,{children:n.jsx(Ct.Body,{children:n.jsx(A.Suspense,{fallback:o,children:n.jsx(s0,{id:r.id})})})})}),e[3]=r.id,e[4]=a):a=e[4],a}function s0(t){const e=K.c(8),{id:s}=t,i=Vt(),{data:r,isLoading:o}=Pf(s);let a;e[0]!==i?(a=()=>{i({to:".",search:i0,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(ge,{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(e0,{automationId:s,automation:r,onBack:l}),e[4]=r,e[5]=s,e[6]=l,e[7]=h):h=e[7],h}function i0(t){return{...t,main:"automations"}}function r0(t){const e=K.c(20),{virtualMcpId:s}=t,i=Vt(),{data:r}=Df(s),o=r===void 0?[]:r,{create:a}=Pi(),[l,h]=A.useState(""),c=l.toLowerCase(),d=o.filter(E=>E.name.toLowerCase().includes(c));let u;e[0]!==i?(u=E=>i({to:".",search:C=>({...C,main:"automation:"+E}),replace:!0}),e[0]=i,e[1]=u):u=e[1];const f=u,p=async()=>{if(a.isPending)return;Me("automation_new_clicked",{virtual_mcp_id:s,existing_count:o.length});const E=await a.mutateAsync(Mf(s));f(E.id)};let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(Kt,{size:14}),e[2]=m):m=e[2];let _;e[3]!==a.isPending||e[4]!==p?(_=n.jsxs(te,{size:"sm",onClick:p,disabled:a.isPending,children:[m,"New automation"]}),e[3]=a.isPending,e[4]=p,e[5]=_):_=e[5];const g=_,x=Ct,S=Ct,v=Ct;let b;e[6]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(Ct.Title,{children:"Automations"}),e[6]=b):b=e[6];const k=o.length>0&&n.jsx(If,{value:l,onChange:h,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let w;e[7]!==g||e[8]!==k?(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:[k,g]})]}),e[7]=g,e[8]=k,e[9]=w):w=e[9];const N=o.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(hr,{image:n.jsx(bi,{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(hr,{image:n.jsx(bi,{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(E=>n.jsx(Af,{automation:E,onClick:()=>f(E.id)},E.id))});let j;e[10]!==N||e[11]!==v.Body||e[12]!==w?(j=n.jsxs(v.Body,{children:[w,N]}),e[10]=N,e[11]=v.Body,e[12]=w,e[13]=j):j=e[13];let R;e[14]!==j||e[15]!==S.Content?(R=n.jsx(S.Content,{children:j}),e[14]=j,e[15]=S.Content,e[16]=R):R=e[16];let I;return e[17]!==x||e[18]!==R?(I=n.jsx(x,{children:R}),e[17]=x,e[18]=R,e[19]=I):I=e[19],I}function n0(t){const e=K.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(ge,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx(A.Suspense,{fallback:i,children:n.jsx(r0,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const Fl=300;function od(){const t=K.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Es,{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(Es,{className:"h-3 w-full"}),n.jsx(Es,{className:"h-3 w-5/6"}),n.jsx(Es,{className:"h-3 w-2/3"})]}),n.jsx(Es,{className:"mt-2 h-8 w-24"})]})}),t[1]=s):s=t[1],s}function o0(t){const e=K.c(14),{url:s,title:i}=t,[r,o]=A.useState(!1),[a,l]=A.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=ie("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:`${Fl}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 p;e[8]!==r||e[9]!==a?(p=a&&n.jsx("div",{className:ie("absolute inset-0 transition-opacity ease-out",r?"opacity-0 pointer-events-none":"opacity-100"),style:{transitionDuration:`${Fl}ms`},onTransitionEnd:_=>{_.propertyName==="opacity"&&r&&l(!1)},children:n.jsx(od,{})}),e[8]=r,e[9]=a,e[10]=p):p=e[10];let m;return e[11]!==f||e[12]!==p?(m=n.jsxs("div",{className:"relative h-full w-full bg-background",children:[f,p]}),e[11]=f,e[12]=p,e[13]=m):m=e[13],m}function a0(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 l0(t){const e=K.c(32),{url:s}=t,[i,r]=A.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(Ri,{size:14}):n.jsx(ss,{size:14}),e[10]=i,e[11]=d):d=e[11];let u;e[12]!==a||e[13]!==d?(u=n.jsx(Se,{asChild:!0,children:n.jsx(te,{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 p;e[15]!==f?(p=n.jsx(we,{side:"bottom",children:f}),e[15]=f,e[16]=p):p=e[16];let m;e[17]!==u||e[18]!==p?(m=n.jsxs(Ce,{children:[u,p]}),e[17]=u,e[18]=p,e[19]=m):m=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(zs,{size:14}),e[22]=g):g=e[22];let x;e[23]!==_?(x=n.jsx(Se,{asChild:!0,children:n.jsx(te,{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(we,{side:"bottom",children:"Open in new tab"}),e[25]=S):S=e[25];let v;e[26]!==x?(v=n.jsxs(Ce,{children:[x,S]}),e[26]=x,e[27]=v):v=e[27];let b;return e[28]!==v||e[29]!==c||e[30]!==m?(b=n.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-b border-border/60 px-2",children:[c,m,v]}),e[28]=v,e[29]=c,e[30]=m,e[31]=b):b=e[31],b}function c0(t){const e=K.c(15),{slug:s}=t,i=Xd();let r,o,a,l;if(e[0]!==s||e[1]!==i?.messages){l=Symbol.for("react.early_return_sentinel");e:{const p=i?.messages??[];if(r=a0(p,s),!r){let m;e[6]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx("div",{className:"h-full w-full bg-background",children:n.jsx(od,{})}),e[6]=m):m=e[6],l=m;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(l0,{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(o0,{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 Hl=A.lazy(()=>Ni(()=>import("./project-app-view-Be7QSV7a.js"),__vite__mapDeps([137,1,2,90,6,7,8,9,10,11,12,13,14,15,16,17,3,4,5,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,91,92,42,43,44,93,45,94,95,54,84,85,86,87,88,53,89,55,96,97,98,99,100,62,101,52,102,67,68,46,103,117])).then(t=>({default:t.AppViewContent})));function ad(t){const e=K.c(47),{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}=Hc(r);if(Du(o)){let g;return e[3]!==i?(g=n.jsx(Aa,{virtualMcpId:i}),e[3]=i,e[4]=g):g=e[4],g}if(o==="git"){let g;return e[5]!==i?(g=n.jsx(V_,{virtualMcpId:i}),e[5]=i,e[6]=g):g=e[6],g}if(o==="automations"){let g;return e[7]!==i?(g=n.jsx(n0,{virtualMcpId:i}),e[7]=i,e[8]=g):g=e[8],g}if(o==="preview"){let g;return e[9]!==i?(g=n.jsx(tb,{virtualMcpId:i}),e[9]=i,e[10]=g):g=e[10],g}if(o==="content"){let g;return e[11]!==i?(g=n.jsx(Ob,{virtualMcpId:i}),e[11]=i,e[12]=g):g=e[12],g}if(h){let g;return e[13]!==o?(g=n.jsx(t0,{tabId:o}),e[13]=o,e[14]=g):g=e[14],g}let c;e[15]!==o?(c=Au(o),e[15]=o,e[16]=c):c=e[16];const d=c;if(d){let g;return e[17]!==d.slug?(g=n.jsx(c0,{slug:d.slug}),e[17]=d.slug,e[18]=g):g=e[18],g}let u;e[19]!==o?(u=Mu(o),e[19]=o,e[20]=u):u=e[20];const f=u;if(f){let g;if(e[21]!==l||e[22]!==f.connectionId||e[23]!==f.toolName){let k;e[25]!==f.connectionId||e[26]!==f.toolName?(k=w=>w.appId===f.connectionId&&w.toolName===f.toolName,e[25]=f.connectionId,e[26]=f.toolName,e[27]=k):k=e[27],g=l.find(k),e[21]=l,e[22]=f.connectionId,e[23]=f.toolName,e[24]=g}else g=e[24];const x=g;let S;e[28]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),e[28]=S):S=e[28];const v=x?.args;let b;return e[29]!==o||e[30]!==f.connectionId||e[31]!==f.toolName||e[32]!==v?(b=n.jsx(A.Suspense,{fallback:S,children:n.jsx(Hl,{connectionId:f.connectionId,toolName:f.toolName,args:v},o)}),e[29]=o,e[30]=f.connectionId,e[31]=f.toolName,e[32]=v,e[33]=b):b=e[33],b}let p;if(e[34]!==o||e[35]!==a){let g;e[37]!==o?(g=x=>x.id===o,e[37]=o,e[38]=g):g=e[38],p=a.find(g),e[34]=o,e[35]=a,e[36]=p}else p=e[36];const m=p;if(m){let g;e[39]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),e[39]=g):g=e[39];let x;return e[40]!==o||e[41]!==m.id||e[42]!==m.view.appId||e[43]!==m.view.args?(x=n.jsx(A.Suspense,{fallback:g,children:n.jsx(Hl,{connectionId:m.view.appId,toolName:m.id,args:m.view.args},o)}),e[40]=o,e[41]=m.id,e[42]=m.view.appId,e[43]=m.view.args,e[44]=x):x=e[44],x}let _;return e[45]!==i?(_=n.jsx(Aa,{virtualMcpId:i}),e[45]=i,e[46]=_):_=e[46],_}function h0(t){const e=K.c(9),{children:s,defaultSize:i,chatOpen:r,chatPanelWidth:o,onChatPanelResize:a}=t,[,l]=A.useTransition(),h=i>0&&i<100?o:i;let c;e[0]!==a?(c=m=>l(()=>{m>0&&m<100&&a(m)}),e[0]=a,e[1]=c):c=e[1];const d=c,u=r?"min-w-[348px]":"min-w-0";let f;e[2]!==u?(f=ie("overflow-hidden bg-sidebar",u),e[2]=u,e[3]=f):f=e[3];let p;return e[4]!==s||e[5]!==h||e[6]!==d||e[7]!==f?(p=n.jsx(dc,{defaultSize:h,minSize:20,collapsible:!0,collapsedSize:0,className:f,onResize:d,order:1,children:s}),e[4]=s,e[5]=h,e[6]=d,e[7]=f,e[8]=p):p=e[8],p}function d0(t){const e=K.c(32),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:o,chatContent:a}=t;let l;e[0]!==r||e[1]!==o?(l=wa(r,o),e[0]=r,e[1]=o,e[2]=l):l=e[2];const h=l,[c,d]=lm(),u=A.useRef(null);let f,p;e[3]!==r||e[4]!==c||e[5]!==o?(f=()=>{const I=u.current;if(!I)return;const E=wa(r,o),C=E.chat>0&&E.chat<100?c:E.chat,y=E.chat>0&&E.chat<100?100-c:E.main;I.setLayout([C,y])},p=[r,o,c],e[3]=r,e[4]=c,e[5]=o,e[6]=f,e[7]=p):(f=e[6],p=e[7]),A.useEffect(f,p);const m=`${s}-${i}`;let _;e[8]===Symbol.for("react.memo_cache_sentinel")?(_={overflow:"visible"},e[8]=_):_=e[8];let g;e[9]!==a?(g=a??n.jsx(Sc,{}),e[9]=a,e[10]=g):g=e[10];let x;e[11]!==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[11]=g,e[12]=x):x=e[12];let S;e[13]!==r||e[14]!==c||e[15]!==d||e[16]!==h.chat||e[17]!==x?(S=n.jsx(h0,{defaultSize:h.chat,chatOpen:r,chatPanelWidth:c,onChatPanelResize:d,children:x}),e[13]=r,e[14]=c,e[15]=d,e[16]=h.chat,e[17]=x,e[18]=S):S=e[18];let v;e[19]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(Fu,{className:"bg-sidebar"}),e[19]=v):v=e[19];const b=h.main;let k;e[20]===Symbol.for("react.memo_cache_sentinel")?(k={overflow:"visible"},e[20]=k):k=e[20];let w;e[21]===Symbol.for("react.memo_cache_sentinel")?(w=ie("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[21]=w):w=e[21];let N;e[22]!==i||e[23]!==s?(N=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($t,{children:n.jsx(ad,{taskId:i,virtualMcpId:s})})})})}),e[22]=i,e[23]=s,e[24]=N):N=e[24];let j;e[25]!==h.main||e[26]!==N?(j=n.jsx(dc,{className:"min-w-0 flex flex-col",order:2,defaultSize:b,style:k,collapsible:!0,collapsedSize:0,minSize:20,children:N}),e[25]=h.main,e[26]=N,e[27]=j):j=e[27];let R;return e[28]!==j||e[29]!==m||e[30]!==S?(R=n.jsxs(Hu,{ref:u,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:_,children:[S,v,j]},m),e[28]=j,e[29]=m,e[30]=S,e[31]=R):R=e[31],R}function u0(t){const e=K.c(15),{chatOpen:s,toggleChat:i,onNewTask:r}=t;let o;e[0]!==s||e[1]!==i?(o=()=>{Me("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(ac,{size:16}),e[3]=a):a=e[3];let l;e[4]!==s||e[5]!==o?(l=n.jsx(Se,{asChild:!0,children:n.jsx(va,{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(we,{side:"bottom",children:"Chat"}),e[7]=h):h=e[7];let c;e[8]!==l?(c=n.jsxs(Ce,{delayDuration:300,children:[l,h]}),e[8]=l,e[9]=c):c=e[9];let d;e[10]!==r?(d=r&&n.jsxs(Ce,{delayDuration:300,children:[n.jsx(Se,{asChild:!0,children:n.jsx(va,{onClick:r,"aria-label":"New task",children:n.jsx(Dr,{size:16})})}),n.jsx(we,{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 f0(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 m0(t){const e=K.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=ie("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(p0,{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 p0(t){const e=K.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(lc,{className:"size-4"}),e[4]=i):i=e[4],i}function _0(t){const e=K.c(13),{overflow:s,onSelect:i}=t,[r,o]=A.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(Os,{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(Br,{className:"size-4"})})}),e[2]=h):h=e[2];let c;if(e[3]!==l||e[4]!==s){let f;e[6]!==l?(f=p=>n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>l(p.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(g0,{icon:p.icon})}),n.jsx("span",{className:"truncate",children:p.title})]})},p.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($s,{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(Ls,{open:r,onOpenChange:o,children:[h,d]}),e[10]=r,e[11]=d,e[12]=u):u=e[12],u}function g0(t){const e=K.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(lc,{className:"size-4"}),e[4]=i):i=e[4],i}const v0=6;function ld(t){const e=K.c(20),{virtualMcpId:s,taskId:i}=t,r=Vt();let o;e[0]!==i||e[1]!==s?(o={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=o):o=e[2];const{tabs:a,activeTab:l,mainOpen:h,setActiveTab:c}=Hc(o);let d,u,f,p;if(e[3]!==l||e[4]!==h||e[5]!==r||e[6]!==c||e[7]!==a||e[8]!==s){const g=Bu({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:k}=f0(a,v,v0);u=k,d=w=>{const N=a.find(R=>R.id===w),j=v===w&&h;if(Me("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:w,tab_kind:N?.kind??null,was_active:j}),w==="automations"){const R=Iu({activeTab:l,mainOpen:h});r({to:".",search:I=>({...I,main:R}),replace:!0});return}c(w)},f="flex items-center min-w-0 gap-0.5",p=b.map(w=>n.jsx(m0,{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]=p}else d=e[9],u=e[10],f=e[11],p=e[12];let m;e[13]!==d||e[14]!==u?(m=u.length>0&&n.jsx(_0,{overflow:u,onSelect:d}),e[13]=d,e[14]=u,e[15]=m):m=e[15];let _;return e[16]!==f||e[17]!==p||e[18]!==m?(_=n.jsxs("div",{className:f,children:[p,m]}),e[16]=f,e[17]=p,e[18]=m,e[19]=_):_=e[19],_}const Wl=["amber","bold","bright","calm","crimson","coral","daring","deep","dusty","eager","faint","fierce","frozen","gentle","golden","grand","green","hollow","iron","ivory","keen","lasting","lunar","mellow","misty","noble","olive","pale","prime","quiet","rapid","rustic","serene","sharp","silver","sleek","solar","stark","still","swift","tawny","tender","thin","true","vast","velvet","warm","wild","young","zen"],Ul=["anchor","birch","brook","cedar","cliff","cove","crane","dune","echo","ember","falcon","fern","flint","forge","frost","glade","grove","harbor","hawk","iris","jade","lark","maple","marsh","mesa","opal","orbit","peak","pine","plume","quartz","rapids","reef","ridge","river","sage","shore","slate","spruce","stone","summit","thorn","tide","trail","vale","wren","aspen","delta","crest","spark"];function cd(){const t=Wl[Math.floor(Math.random()*Wl.length)],e=Ul[Math.floor(Math.random()*Ul.length)];return`deco/${t}-${e}`}const Kl=3e3,x0=6e4;function b0(t){const e=K.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=v_(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=()=>tr(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:S0,retry:y0,staleTime:1e3},e[8]=h,e[9]=c,e[10]=d,e[11]=u):u=e[11],ki(u)}function y0(t,e){return!Gc(e)}function S0(t){if(!Gc(t.state.error))return Kl;const e=t.state.fetchFailureCount;return Math.min(Kl*2**e,x0)}const w0=new Set(["main","master"]);function Jo(t){return w0.has(t.trim().toLowerCase())?"Publish to production":"Publish"}function C0(t){const e=K.c(24),{baseBranch:s,disabled:i,loading:r,onPublish:o,onReview:a}=t,l=r===void 0?!1:r;let h;e[0]!==s?(h=Jo(s),e[0]=s,e[1]=h):h=e[1];const c=h;let d;e[2]!==o?(d=()=>{o()},e[2]=o,e[3]=d):d=e[3];let u;e[4]!==l?(u=l?n.jsx(bc,{size:"xs",variant:"default"}):null,e[4]=l,e[5]=u):u=e[5];let f;e[6]!==i||e[7]!==c||e[8]!==d||e[9]!==u?(f=n.jsxs(te,{size:"sm",variant:"success",className:"rounded-r-none border-r border-success-foreground/20",disabled:i,onClick:d,children:[u,c]}),e[6]=i,e[7]=c,e[8]=d,e[9]=u,e[10]=f):f=e[10];let p;e[11]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(Or,{className:"h-3.5 w-3.5"}),e[11]=p):p=e[11];let m;e[12]!==i?(m=n.jsx(Hs,{asChild:!0,children:n.jsx(te,{size:"sm",variant:"success",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:p})}),e[12]=i,e[13]=m):m=e[13];let _;e[14]!==a?(_=a?n.jsx(ut,{onClick:a,children:"Review"}):null,e[14]=a,e[15]=_):_=e[15];let g;e[16]!==_?(g=n.jsx(Ws,{align:"end",children:_}),e[16]=_,e[17]=g):g=e[17];let x;e[18]!==m||e[19]!==g?(x=n.jsxs(Fs,{children:[m,g]}),e[18]=m,e[19]=g,e[20]=x):x=e[20];let S;return e[21]!==x||e[22]!==f?(S=n.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[f,x]}),e[21]=x,e[22]=f,e[23]=S):S=e[23],S}class ni extends Error{constructor(e,s,i){super(e),this.step=s,this.pr=i,this.name="PublishFlowError"}step;pr}function k0(t){const e=K.c(10),[s,i]=A.useState(0);let r;e[0]!==t?(r=h=>{h&&i(j0),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(N0,{...t,onOpenChange:o},s):null,e[2]=o,e[3]=t,e[4]=s,e[5]=a):a=e[5];let l;return e[6]!==o||e[7]!==t.open||e[8]!==a?(l=n.jsx(Gt,{open:t.open,onOpenChange:o,children:a}),e[6]=o,e[7]=t.open,e[8]=a,e[9]=l):l=e[9],l}function j0(t){return t+1}function N0({onOpenChange:t,orgSlug:e,orgId:s,virtualMcpId:i,branch:r,baseBranch:o,githubConnectionId:a,owner:l,repo:h,previewUrl:c,dialogIntent:d="publish",headSha:u=null,openPullRequest:f=null,onPullRequestChanged:p,onPublished:m}){const _=Xe({connectionId:a,orgId:s,orgSlug:e}),g=f?.state==="open",x=d==="publish",S=d==="open-pr"&&!g,[v,b]=A.useState(null),[k,w]=A.useState(null),[N,j]=A.useState(!0),[R,I]=A.useState(!1),[E,C]=A.useState(""),[y,T]=A.useState(""),[D,P]=A.useState(),[M,B]=A.useState(!1),[F,U]=A.useState(!1),[z,O]=A.useState(),[q,V]=A.useState(),[Q,G]=A.useState(!1),[W,ee]=A.useState(!1),[$,L]=A.useState(!1),Y=A.useRef(!1);Y.current||(Y.current=!0,(async()=>{j(!0),P(void 0),w(null),C(""),T(""),O(void 0),V(void 0);try{const he=S?{base:o,...u?{headSha:u}:{}}:void 0,[be,Ze]=await Promise.all([tr(e,i,r),Yc(e,i,r,he)]);b(be),w(Ze),C(`Changes from ${be.current??r}`),L(!0),Ba(e,i,r,{status:be,diff:Ze}).then(tt=>{C(tt.title),T(tt.body)}).catch(()=>{}).finally(()=>L(!1))}catch(he){P(he instanceof Error?he.message:"Failed to load changes.")}finally{j(!1)}})());const X=Oo(v)??r,H=Jo(o),ne=()=>{!v||!k||(L(!0),Ba(e,i,r,{status:v,diff:k}).then(he=>{C(he.title),T(he.body)}).catch(()=>{}).finally(()=>L(!1)))},re=Xc(v),ce=k?Object.keys(k.diffs).length:re,de=S?Zc(v):x_(v,k),me=!N&&(x?de:de||S),le=me&&Ia(k),ve=me&&!Ia(k)?__:null,xe=()=>[E.trim(),y.trim()].filter(Boolean).join(`
|
|
311
|
+
`);if(ne.trim()){T(!0);try{L(),Me("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:ne.length}),f(!0),await p({tiptapDoc:Wc({managerAgentId:Ql.AUTOMATION_MANAGER(o.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:ne})})}finally{T(!1)}}},U=e.models?.tier??"smart",z=Zl({defaultValues:{name:e.name,active:e.active,tier:U}}),O=z.watch("active"),[q,V]=A.useReducer(Yb,null),Q=()=>{q!==null&&(Me("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(q.fields),save_count:q.saveCount,edit_duration_ms:Date.now()-q.start}),V({type:"reset"}))},G=async()=>{const H=z.control._formState.dirtyFields,ne=Object.keys(H);if(ne.length===0&&!M)return!0;const re=z.getValues(),ce=z.control._defaultValues;z.reset(re,{keepValues:!0});const de=M;B(!1);const me={id:t,name:re.name,active:re.active,models:{tier:re.tier},messages:Yd(x),temperature:0};try{await a.mutateAsync(me)}catch{return z.reset(ce,{keepValues:!0}),de&&B(!0),!1}const le=[...ne];return de&&le.push("messages"),V({type:"accumulate",now:Date.now(),fields:le}),$(),!0},{schedule:W,flush:ee}=br({save:G}),{schedule:$,flush:L}=br({delayMs:3e4,save:async()=>Q()});A.useEffect(()=>{const H=z.watch(()=>W());return()=>H.unsubscribe()},[]);const Y=H=>{if(S(H),!D){P(!0);return}B(!0),W()},X=async()=>{Me("automation_test_clicked",{automation_id:t,agent_id:r});const H=await ee();if(L(),!H)return;if(!x){ae.error("No instructions configured for this automation");return}u(z.getValues("tier")),f(!0),_({...m,toolApprovalLevel:"auto"});const ne=ha(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(te,{variant:"ghost",size:"sm",onClick:s,children:[n.jsx(of,{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(dt,{control:z.control,name:"name",render:({field:H})=>n.jsx(Ye,{...H,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(te,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:i,children:n.jsx(xi,{size:14})})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(dt,{control:z.control,name:"active",render:({field:H})=>n.jsx(Sn,{checked:H.value,onCheckedChange:ne=>{H.onChange(ne),ee()},className:"cursor-pointer"})}),n.jsx("span",{className:"text-sm text-muted-foreground",children:O?"Active":"Inactive"}),n.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),n.jsx(uc,{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(Vb,{automationId:t,open:v,onOpenChange:b,onCustomSelect:()=>{w(!0),I(!1),j("")},onEventSelect:()=>{I(!0),w(!1)},onWebhookCreated:H=>{Me("automation_trigger_added",{automation_id:t,trigger_type:"webhook"}),C(H)}})]}),e.triggers.length===0&&!k?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(H=>n.jsx(qb,{trigger:H,automationId:t,connectionName:H.connection_id?c.get(H.connection_id):void 0},H.id))}),k&&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(fi,{size:14,className:"text-muted-foreground shrink-0"}),n.jsx("input",{type:"text",value:N,onChange:H=>j(H.target.value),onBlur:async()=>{const H=N.trim();if(!(!H||!gi(H)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:H}),Me("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 H=>{const ne=N.trim();H.key==="Enter"&&ne&&gi(ne)&&H.target.blur(),H.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}),N&&!gi(N)&&n.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&n.jsx(ge,{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(As,{size:13})})]}),R&&n.jsx(A.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(ge,{size:13,className:"animate-spin text-muted-foreground"}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:n.jsx(Xb,{automationId:t,onDone:()=>I(!1)})}),n.jsx(nd,{open:E!==null,onOpenChange:H=>{H||C(null)},url:E?.url??null,token:E?.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(te,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:y||!x,onClick:F,children:[n.jsx(yo,{size:13}),"Improve"]})]}),n.jsx(Hd,{tiptapDoc:x,setTiptapDoc:Y,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(Wd,{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($b,{tier:z.watch("tier"),onSelect:H=>z.setValue("tier",H,{shouldDirty:!0})}),n.jsxs(Ce,{children:[n.jsx(Se,{asChild:!0,children:n.jsxs(te,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:X,disabled:!r,children:[n.jsx(Bf,{size:16}),"Test"]})}),n.jsx(we,{children:"Test Automation"})]})]})]})})]})]})]})}function t0(t){const e=K.c(5),{tabId:s}=t;let i;e[0]!==s?(i=cc(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(ge,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=o):o=e[2];let a;return e[3]!==r.id?(a=n.jsx(Ct,{children:n.jsx(Ct.Content,{children:n.jsx(Ct.Body,{children:n.jsx(A.Suspense,{fallback:o,children:n.jsx(s0,{id:r.id})})})})}),e[3]=r.id,e[4]=a):a=e[4],a}function s0(t){const e=K.c(8),{id:s}=t,i=Vt(),{data:r,isLoading:o}=Pf(s);let a;e[0]!==i?(a=()=>{i({to:".",search:i0,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(ge,{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(e0,{automationId:s,automation:r,onBack:l}),e[4]=r,e[5]=s,e[6]=l,e[7]=h):h=e[7],h}function i0(t){return{...t,main:"automations"}}function r0(t){const e=K.c(20),{virtualMcpId:s}=t,i=Vt(),{data:r}=Df(s),o=r===void 0?[]:r,{create:a}=Pi(),[l,h]=A.useState(""),c=l.toLowerCase(),d=o.filter(E=>E.name.toLowerCase().includes(c));let u;e[0]!==i?(u=E=>i({to:".",search:C=>({...C,main:"automation:"+E}),replace:!0}),e[0]=i,e[1]=u):u=e[1];const f=u,p=async()=>{if(a.isPending)return;Me("automation_new_clicked",{virtual_mcp_id:s,existing_count:o.length});const E=await a.mutateAsync(Mf(s));f(E.id)};let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(Kt,{size:14}),e[2]=m):m=e[2];let _;e[3]!==a.isPending||e[4]!==p?(_=n.jsxs(te,{size:"sm",onClick:p,disabled:a.isPending,children:[m,"New automation"]}),e[3]=a.isPending,e[4]=p,e[5]=_):_=e[5];const g=_,x=Ct,S=Ct,v=Ct;let b;e[6]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(Ct.Title,{children:"Automations"}),e[6]=b):b=e[6];const k=o.length>0&&n.jsx(If,{value:l,onChange:h,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let w;e[7]!==g||e[8]!==k?(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:[k,g]})]}),e[7]=g,e[8]=k,e[9]=w):w=e[9];const N=o.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(hr,{image:n.jsx(bi,{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(hr,{image:n.jsx(bi,{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(E=>n.jsx(Af,{automation:E,onClick:()=>f(E.id)},E.id))});let j;e[10]!==N||e[11]!==v.Body||e[12]!==w?(j=n.jsxs(v.Body,{children:[w,N]}),e[10]=N,e[11]=v.Body,e[12]=w,e[13]=j):j=e[13];let R;e[14]!==j||e[15]!==S.Content?(R=n.jsx(S.Content,{children:j}),e[14]=j,e[15]=S.Content,e[16]=R):R=e[16];let I;return e[17]!==x||e[18]!==R?(I=n.jsx(x,{children:R}),e[17]=x,e[18]=R,e[19]=I):I=e[19],I}function n0(t){const e=K.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(ge,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx(A.Suspense,{fallback:i,children:n.jsx(r0,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const Fl=300;function od(){const t=K.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Es,{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(Es,{className:"h-3 w-full"}),n.jsx(Es,{className:"h-3 w-5/6"}),n.jsx(Es,{className:"h-3 w-2/3"})]}),n.jsx(Es,{className:"mt-2 h-8 w-24"})]})}),t[1]=s):s=t[1],s}function o0(t){const e=K.c(14),{url:s,title:i}=t,[r,o]=A.useState(!1),[a,l]=A.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=ie("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:`${Fl}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 p;e[8]!==r||e[9]!==a?(p=a&&n.jsx("div",{className:ie("absolute inset-0 transition-opacity ease-out",r?"opacity-0 pointer-events-none":"opacity-100"),style:{transitionDuration:`${Fl}ms`},onTransitionEnd:_=>{_.propertyName==="opacity"&&r&&l(!1)},children:n.jsx(od,{})}),e[8]=r,e[9]=a,e[10]=p):p=e[10];let m;return e[11]!==f||e[12]!==p?(m=n.jsxs("div",{className:"relative h-full w-full bg-background",children:[f,p]}),e[11]=f,e[12]=p,e[13]=m):m=e[13],m}function a0(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 l0(t){const e=K.c(32),{url:s}=t,[i,r]=A.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(Ri,{size:14}):n.jsx(ss,{size:14}),e[10]=i,e[11]=d):d=e[11];let u;e[12]!==a||e[13]!==d?(u=n.jsx(Se,{asChild:!0,children:n.jsx(te,{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 p;e[15]!==f?(p=n.jsx(we,{side:"bottom",children:f}),e[15]=f,e[16]=p):p=e[16];let m;e[17]!==u||e[18]!==p?(m=n.jsxs(Ce,{children:[u,p]}),e[17]=u,e[18]=p,e[19]=m):m=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(zs,{size:14}),e[22]=g):g=e[22];let x;e[23]!==_?(x=n.jsx(Se,{asChild:!0,children:n.jsx(te,{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(we,{side:"bottom",children:"Open in new tab"}),e[25]=S):S=e[25];let v;e[26]!==x?(v=n.jsxs(Ce,{children:[x,S]}),e[26]=x,e[27]=v):v=e[27];let b;return e[28]!==v||e[29]!==c||e[30]!==m?(b=n.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-b border-border/60 px-2",children:[c,m,v]}),e[28]=v,e[29]=c,e[30]=m,e[31]=b):b=e[31],b}function c0(t){const e=K.c(15),{slug:s}=t,i=Xd();let r,o,a,l;if(e[0]!==s||e[1]!==i?.messages){l=Symbol.for("react.early_return_sentinel");e:{const p=i?.messages??[];if(r=a0(p,s),!r){let m;e[6]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx("div",{className:"h-full w-full bg-background",children:n.jsx(od,{})}),e[6]=m):m=e[6],l=m;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(l0,{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(o0,{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 Hl=A.lazy(()=>Ni(()=>import("./project-app-view-CNVhgJlW.js"),__vite__mapDeps([137,1,2,90,6,7,8,9,10,11,12,13,14,15,16,17,3,4,5,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,91,92,42,43,44,93,45,94,95,54,84,85,86,87,88,53,89,55,96,97,98,99,100,62,101,52,102,67,68,46,103,117])).then(t=>({default:t.AppViewContent})));function ad(t){const e=K.c(47),{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}=Hc(r);if(Du(o)){let g;return e[3]!==i?(g=n.jsx(Aa,{virtualMcpId:i}),e[3]=i,e[4]=g):g=e[4],g}if(o==="git"){let g;return e[5]!==i?(g=n.jsx(V_,{virtualMcpId:i}),e[5]=i,e[6]=g):g=e[6],g}if(o==="automations"){let g;return e[7]!==i?(g=n.jsx(n0,{virtualMcpId:i}),e[7]=i,e[8]=g):g=e[8],g}if(o==="preview"){let g;return e[9]!==i?(g=n.jsx(tb,{virtualMcpId:i}),e[9]=i,e[10]=g):g=e[10],g}if(o==="content"){let g;return e[11]!==i?(g=n.jsx(Ob,{virtualMcpId:i}),e[11]=i,e[12]=g):g=e[12],g}if(h){let g;return e[13]!==o?(g=n.jsx(t0,{tabId:o}),e[13]=o,e[14]=g):g=e[14],g}let c;e[15]!==o?(c=Au(o),e[15]=o,e[16]=c):c=e[16];const d=c;if(d){let g;return e[17]!==d.slug?(g=n.jsx(c0,{slug:d.slug}),e[17]=d.slug,e[18]=g):g=e[18],g}let u;e[19]!==o?(u=Mu(o),e[19]=o,e[20]=u):u=e[20];const f=u;if(f){let g;if(e[21]!==l||e[22]!==f.connectionId||e[23]!==f.toolName){let k;e[25]!==f.connectionId||e[26]!==f.toolName?(k=w=>w.appId===f.connectionId&&w.toolName===f.toolName,e[25]=f.connectionId,e[26]=f.toolName,e[27]=k):k=e[27],g=l.find(k),e[21]=l,e[22]=f.connectionId,e[23]=f.toolName,e[24]=g}else g=e[24];const x=g;let S;e[28]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),e[28]=S):S=e[28];const v=x?.args;let b;return e[29]!==o||e[30]!==f.connectionId||e[31]!==f.toolName||e[32]!==v?(b=n.jsx(A.Suspense,{fallback:S,children:n.jsx(Hl,{connectionId:f.connectionId,toolName:f.toolName,args:v},o)}),e[29]=o,e[30]=f.connectionId,e[31]=f.toolName,e[32]=v,e[33]=b):b=e[33],b}let p;if(e[34]!==o||e[35]!==a){let g;e[37]!==o?(g=x=>x.id===o,e[37]=o,e[38]=g):g=e[38],p=a.find(g),e[34]=o,e[35]=a,e[36]=p}else p=e[36];const m=p;if(m){let g;e[39]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),e[39]=g):g=e[39];let x;return e[40]!==o||e[41]!==m.id||e[42]!==m.view.appId||e[43]!==m.view.args?(x=n.jsx(A.Suspense,{fallback:g,children:n.jsx(Hl,{connectionId:m.view.appId,toolName:m.id,args:m.view.args},o)}),e[40]=o,e[41]=m.id,e[42]=m.view.appId,e[43]=m.view.args,e[44]=x):x=e[44],x}let _;return e[45]!==i?(_=n.jsx(Aa,{virtualMcpId:i}),e[45]=i,e[46]=_):_=e[46],_}function h0(t){const e=K.c(9),{children:s,defaultSize:i,chatOpen:r,chatPanelWidth:o,onChatPanelResize:a}=t,[,l]=A.useTransition(),h=i>0&&i<100?o:i;let c;e[0]!==a?(c=m=>l(()=>{m>0&&m<100&&a(m)}),e[0]=a,e[1]=c):c=e[1];const d=c,u=r?"min-w-[348px]":"min-w-0";let f;e[2]!==u?(f=ie("overflow-hidden bg-sidebar",u),e[2]=u,e[3]=f):f=e[3];let p;return e[4]!==s||e[5]!==h||e[6]!==d||e[7]!==f?(p=n.jsx(dc,{defaultSize:h,minSize:20,collapsible:!0,collapsedSize:0,className:f,onResize:d,order:1,children:s}),e[4]=s,e[5]=h,e[6]=d,e[7]=f,e[8]=p):p=e[8],p}function d0(t){const e=K.c(32),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:o,chatContent:a}=t;let l;e[0]!==r||e[1]!==o?(l=wa(r,o),e[0]=r,e[1]=o,e[2]=l):l=e[2];const h=l,[c,d]=lm(),u=A.useRef(null);let f,p;e[3]!==r||e[4]!==c||e[5]!==o?(f=()=>{const I=u.current;if(!I)return;const E=wa(r,o),C=E.chat>0&&E.chat<100?c:E.chat,y=E.chat>0&&E.chat<100?100-c:E.main;I.setLayout([C,y])},p=[r,o,c],e[3]=r,e[4]=c,e[5]=o,e[6]=f,e[7]=p):(f=e[6],p=e[7]),A.useEffect(f,p);const m=`${s}-${i}`;let _;e[8]===Symbol.for("react.memo_cache_sentinel")?(_={overflow:"visible"},e[8]=_):_=e[8];let g;e[9]!==a?(g=a??n.jsx(Sc,{}),e[9]=a,e[10]=g):g=e[10];let x;e[11]!==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[11]=g,e[12]=x):x=e[12];let S;e[13]!==r||e[14]!==c||e[15]!==d||e[16]!==h.chat||e[17]!==x?(S=n.jsx(h0,{defaultSize:h.chat,chatOpen:r,chatPanelWidth:c,onChatPanelResize:d,children:x}),e[13]=r,e[14]=c,e[15]=d,e[16]=h.chat,e[17]=x,e[18]=S):S=e[18];let v;e[19]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(Fu,{className:"bg-sidebar"}),e[19]=v):v=e[19];const b=h.main;let k;e[20]===Symbol.for("react.memo_cache_sentinel")?(k={overflow:"visible"},e[20]=k):k=e[20];let w;e[21]===Symbol.for("react.memo_cache_sentinel")?(w=ie("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[21]=w):w=e[21];let N;e[22]!==i||e[23]!==s?(N=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($t,{children:n.jsx(ad,{taskId:i,virtualMcpId:s})})})})}),e[22]=i,e[23]=s,e[24]=N):N=e[24];let j;e[25]!==h.main||e[26]!==N?(j=n.jsx(dc,{className:"min-w-0 flex flex-col",order:2,defaultSize:b,style:k,collapsible:!0,collapsedSize:0,minSize:20,children:N}),e[25]=h.main,e[26]=N,e[27]=j):j=e[27];let R;return e[28]!==j||e[29]!==m||e[30]!==S?(R=n.jsxs(Hu,{ref:u,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:_,children:[S,v,j]},m),e[28]=j,e[29]=m,e[30]=S,e[31]=R):R=e[31],R}function u0(t){const e=K.c(15),{chatOpen:s,toggleChat:i,onNewTask:r}=t;let o;e[0]!==s||e[1]!==i?(o=()=>{Me("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(ac,{size:16}),e[3]=a):a=e[3];let l;e[4]!==s||e[5]!==o?(l=n.jsx(Se,{asChild:!0,children:n.jsx(va,{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(we,{side:"bottom",children:"Chat"}),e[7]=h):h=e[7];let c;e[8]!==l?(c=n.jsxs(Ce,{delayDuration:300,children:[l,h]}),e[8]=l,e[9]=c):c=e[9];let d;e[10]!==r?(d=r&&n.jsxs(Ce,{delayDuration:300,children:[n.jsx(Se,{asChild:!0,children:n.jsx(va,{onClick:r,"aria-label":"New task",children:n.jsx(Dr,{size:16})})}),n.jsx(we,{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 f0(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 m0(t){const e=K.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=ie("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(p0,{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 p0(t){const e=K.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(lc,{className:"size-4"}),e[4]=i):i=e[4],i}function _0(t){const e=K.c(13),{overflow:s,onSelect:i}=t,[r,o]=A.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(Os,{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(Br,{className:"size-4"})})}),e[2]=h):h=e[2];let c;if(e[3]!==l||e[4]!==s){let f;e[6]!==l?(f=p=>n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>l(p.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(g0,{icon:p.icon})}),n.jsx("span",{className:"truncate",children:p.title})]})},p.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($s,{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(Ls,{open:r,onOpenChange:o,children:[h,d]}),e[10]=r,e[11]=d,e[12]=u):u=e[12],u}function g0(t){const e=K.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(lc,{className:"size-4"}),e[4]=i):i=e[4],i}const v0=6;function ld(t){const e=K.c(20),{virtualMcpId:s,taskId:i}=t,r=Vt();let o;e[0]!==i||e[1]!==s?(o={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=o):o=e[2];const{tabs:a,activeTab:l,mainOpen:h,setActiveTab:c}=Hc(o);let d,u,f,p;if(e[3]!==l||e[4]!==h||e[5]!==r||e[6]!==c||e[7]!==a||e[8]!==s){const g=Bu({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:k}=f0(a,v,v0);u=k,d=w=>{const N=a.find(R=>R.id===w),j=v===w&&h;if(Me("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:w,tab_kind:N?.kind??null,was_active:j}),w==="automations"){const R=Iu({activeTab:l,mainOpen:h});r({to:".",search:I=>({...I,main:R}),replace:!0});return}c(w)},f="flex items-center min-w-0 gap-0.5",p=b.map(w=>n.jsx(m0,{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]=p}else d=e[9],u=e[10],f=e[11],p=e[12];let m;e[13]!==d||e[14]!==u?(m=u.length>0&&n.jsx(_0,{overflow:u,onSelect:d}),e[13]=d,e[14]=u,e[15]=m):m=e[15];let _;return e[16]!==f||e[17]!==p||e[18]!==m?(_=n.jsxs("div",{className:f,children:[p,m]}),e[16]=f,e[17]=p,e[18]=m,e[19]=_):_=e[19],_}const Wl=["amber","bold","bright","calm","crimson","coral","daring","deep","dusty","eager","faint","fierce","frozen","gentle","golden","grand","green","hollow","iron","ivory","keen","lasting","lunar","mellow","misty","noble","olive","pale","prime","quiet","rapid","rustic","serene","sharp","silver","sleek","solar","stark","still","swift","tawny","tender","thin","true","vast","velvet","warm","wild","young","zen"],Ul=["anchor","birch","brook","cedar","cliff","cove","crane","dune","echo","ember","falcon","fern","flint","forge","frost","glade","grove","harbor","hawk","iris","jade","lark","maple","marsh","mesa","opal","orbit","peak","pine","plume","quartz","rapids","reef","ridge","river","sage","shore","slate","spruce","stone","summit","thorn","tide","trail","vale","wren","aspen","delta","crest","spark"];function cd(){const t=Wl[Math.floor(Math.random()*Wl.length)],e=Ul[Math.floor(Math.random()*Ul.length)];return`deco/${t}-${e}`}const Kl=3e3,x0=6e4;function b0(t){const e=K.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=v_(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=()=>tr(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:S0,retry:y0,staleTime:1e3},e[8]=h,e[9]=c,e[10]=d,e[11]=u):u=e[11],ki(u)}function y0(t,e){return!Gc(e)}function S0(t){if(!Gc(t.state.error))return Kl;const e=t.state.fetchFailureCount;return Math.min(Kl*2**e,x0)}const w0=new Set(["main","master"]);function Jo(t){return w0.has(t.trim().toLowerCase())?"Publish to production":"Publish"}function C0(t){const e=K.c(24),{baseBranch:s,disabled:i,loading:r,onPublish:o,onReview:a}=t,l=r===void 0?!1:r;let h;e[0]!==s?(h=Jo(s),e[0]=s,e[1]=h):h=e[1];const c=h;let d;e[2]!==o?(d=()=>{o()},e[2]=o,e[3]=d):d=e[3];let u;e[4]!==l?(u=l?n.jsx(bc,{size:"xs",variant:"default"}):null,e[4]=l,e[5]=u):u=e[5];let f;e[6]!==i||e[7]!==c||e[8]!==d||e[9]!==u?(f=n.jsxs(te,{size:"sm",variant:"success",className:"rounded-r-none border-r border-success-foreground/20",disabled:i,onClick:d,children:[u,c]}),e[6]=i,e[7]=c,e[8]=d,e[9]=u,e[10]=f):f=e[10];let p;e[11]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(Or,{className:"h-3.5 w-3.5"}),e[11]=p):p=e[11];let m;e[12]!==i?(m=n.jsx(Hs,{asChild:!0,children:n.jsx(te,{size:"sm",variant:"success",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:p})}),e[12]=i,e[13]=m):m=e[13];let _;e[14]!==a?(_=a?n.jsx(ut,{onClick:a,children:"Review"}):null,e[14]=a,e[15]=_):_=e[15];let g;e[16]!==_?(g=n.jsx(Ws,{align:"end",children:_}),e[16]=_,e[17]=g):g=e[17];let x;e[18]!==m||e[19]!==g?(x=n.jsxs(Fs,{children:[m,g]}),e[18]=m,e[19]=g,e[20]=x):x=e[20];let S;return e[21]!==x||e[22]!==f?(S=n.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[f,x]}),e[21]=x,e[22]=f,e[23]=S):S=e[23],S}class ni extends Error{constructor(e,s,i){super(e),this.step=s,this.pr=i,this.name="PublishFlowError"}step;pr}function k0(t){const e=K.c(10),[s,i]=A.useState(0);let r;e[0]!==t?(r=h=>{h&&i(j0),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(N0,{...t,onOpenChange:o},s):null,e[2]=o,e[3]=t,e[4]=s,e[5]=a):a=e[5];let l;return e[6]!==o||e[7]!==t.open||e[8]!==a?(l=n.jsx(Gt,{open:t.open,onOpenChange:o,children:a}),e[6]=o,e[7]=t.open,e[8]=a,e[9]=l):l=e[9],l}function j0(t){return t+1}function N0({onOpenChange:t,orgSlug:e,orgId:s,virtualMcpId:i,branch:r,baseBranch:o,githubConnectionId:a,owner:l,repo:h,previewUrl:c,dialogIntent:d="publish",headSha:u=null,openPullRequest:f=null,onPullRequestChanged:p,onPublished:m}){const _=Xe({connectionId:a,orgId:s,orgSlug:e}),g=f?.state==="open",x=d==="publish",S=d==="open-pr"&&!g,[v,b]=A.useState(null),[k,w]=A.useState(null),[N,j]=A.useState(!0),[R,I]=A.useState(!1),[E,C]=A.useState(""),[y,T]=A.useState(""),[D,P]=A.useState(),[M,B]=A.useState(!1),[F,U]=A.useState(!1),[z,O]=A.useState(),[q,V]=A.useState(),[Q,G]=A.useState(!1),[W,ee]=A.useState(!1),[$,L]=A.useState(!1),Y=A.useRef(!1);Y.current||(Y.current=!0,(async()=>{j(!0),P(void 0),w(null),C(""),T(""),O(void 0),V(void 0);try{const he=S?{base:o,...u?{headSha:u}:{}}:void 0,[be,Ze]=await Promise.all([tr(e,i,r),Yc(e,i,r,he)]);b(be),w(Ze),C(`Changes from ${be.current??r}`),L(!0),Ba(e,i,r,{status:be,diff:Ze}).then(tt=>{C(tt.title),T(tt.body)}).catch(()=>{}).finally(()=>L(!1))}catch(he){P(he instanceof Error?he.message:"Failed to load changes.")}finally{j(!1)}})());const X=Oo(v)??r,H=Jo(o),ne=()=>{!v||!k||(L(!0),Ba(e,i,r,{status:v,diff:k}).then(he=>{C(he.title),T(he.body)}).catch(()=>{}).finally(()=>L(!1)))},re=Xc(v),ce=k?Object.keys(k.diffs).length:re,de=S?Zc(v):x_(v,k),me=!N&&(x?de:de||S),le=me&&Ia(k),ve=me&&!Ia(k)?__:null,xe=()=>[E.trim(),y.trim()].filter(Boolean).join(`
|
|
312
312
|
|
|
313
313
|
`),Ne=he=>{R||M||F||t(he)},Ee=async()=>{U(!0),V(void 0);try{const he=xe()||E.trim()||`Changes from ${X}`;await sn(e,i,r,he),ae.success(f?`Saved changes to PR #${f.number}`:"Changes saved"),Ne(!1),await p?.()}catch(he){V(he instanceof Error?he.message:"Failed to save changes")}finally{U(!1)}},mt=async()=>{I(!0),P(void 0);let he;try{const be=E.trim()||`Changes from ${X}`,Ze=y.trim()||void 0,tt=xe()||be;if(de)try{await sn(e,i,r,tt)}catch(it){throw new ni(it instanceof Error?it.message:"Failed to push changes","push")}try{await p_(e,i,r,o)}catch(it){throw new ni(it instanceof Error?it.message:"Failed to rebase onto base","rebase")}try{he=await ka(_,{owner:l,repo:h,branch:X,title:be,body:Ze,base:o})}catch(it){throw new ni(it instanceof Error?it.message:"Failed to open pull request","open-pr")}try{await Nc(_,{owner:l,repo:h,pullNumber:he.number,commitTitle:be})}catch(it){throw new ni(it instanceof Error?it.message:"Failed to merge pull request","merge",he)}ae.success(`Published to ${o}`),Ne(!1),w(null),C(""),T(""),await p?.(),await m?.()}catch(be){if(be instanceof ni&&be.step==="merge"&&be.pr){const Ze=`Changes were pushed and PR #${be.pr.number} is open, but merge failed: ${be.message}`;P(Ze),ae.error(Ze,{action:{label:"View PR",onClick:()=>window.open(be.pr.htmlUrl,"_blank","noopener,noreferrer")}}),await p?.();return}P(be instanceof Error?be.message:"Failed to publish")}finally{I(!1)}},Mt=async he=>{try{await La(e,i,r,[he]),ae.success(`Discarded changes to ${he}`),w(Ze=>{if(!Ze)return Ze;const tt={...Ze,diffs:{...Ze.diffs}};return delete tt.diffs[he],tt});const be=await tr(e,i,r);b(be)}catch(be){ae.error(be instanceof Error?be.message:"Failed to discard changes")}},Pe=async()=>{if(k){G(!1),ee(!0);try{const he=Object.keys(k.diffs);if(he.length===0)return;await La(e,i,r,he),ae.success("All changes discarded"),w(null);const be=await tr(e,i,r);b(be),Ne(!1)}catch(he){ae.error(he instanceof Error?he.message:"Failed to discard changes")}finally{ee(!1)}}},St=async()=>{B(!0),O(void 0);try{const he=E.trim()||`Changes from ${X}`,be=y.trim()||void 0,Ze=xe()||he;de&&await sn(e,i,r,Ze);const tt=await ka(_,{owner:l,repo:h,branch:X,title:he,body:be,base:o});ae.success(`Submitted pull request #${tt.number} for review`,{action:{label:"View on GitHub",onClick:()=>window.open(tt.htmlUrl,"_blank","noopener,noreferrer")}}),Ne(!1),await p?.()}catch(he){O(he instanceof Error?he.message:"Failed to submit for review")}finally{B(!1)}};return n.jsx(qt,{className:"top-14 left-auto right-4 flex h-[90%] max-h-[85vh] w-[90vw] max-w-[600px] translate-x-0 translate-y-0 flex-col gap-0 overflow-hidden p-0",children:n.jsxs(Co,{defaultValue:"description",className:"flex h-full flex-col gap-0",children:[n.jsxs("div",{className:"shrink-0 space-y-3 px-6 pt-5 pb-4",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:x?"Save changes":S?"Submit for review":H}),n.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[n.jsx("span",{className:"inline-block h-2.5 w-2.5 shrink-0 rounded-full bg-green-500"}),ce," ",ce===1?"change":"changes"," ",x?"to save":S?"in this PR":"to publish"]})]}),Q?n.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md bg-destructive/5 px-3 py-2",children:[n.jsx("span",{className:"text-xs text-destructive",children:"Discard all changes? This cannot be undone."}),n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[n.jsx(te,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>G(!1),children:"Cancel"}),n.jsxs(te,{type:"button",size:"sm",className:"h-7 bg-destructive px-2 text-xs text-destructive-foreground hover:bg-destructive/90",onClick:Pe,disabled:W,children:[W?n.jsx(ge,{className:"h-3 w-3 animate-spin"}):null,"Discard all"]})]})]}):n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs(wo,{className:"h-8 w-auto",variant:"pill",children:[n.jsx(hs,{value:"description",className:"px-3 text-xs",children:"Description"}),n.jsx(hs,{value:"changes",className:"px-3 text-xs",children:"Changes"})]}),ce>0&&!S&&n.jsx("button",{type:"button",className:"text-xs text-muted-foreground transition-colors hover:text-destructive disabled:opacity-50",onClick:()=>G(!0),disabled:R||W||F,children:"Discard all"})]})]}),n.jsx("div",{className:"border-t"}),n.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:N?n.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-muted-foreground",children:[n.jsx(ge,{className:"h-4 w-4 animate-spin"}),n.jsx("span",{className:"text-sm",children:"Loading changes…"})]}):n.jsxs(n.Fragment,{children:[n.jsx(mi,{value:"description",className:"mt-0 px-6 py-5",children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("p",{className:"text-sm font-medium",children:S?"Pull request":"Commit message"}),n.jsxs("button",{type:"button",className:"flex items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50",disabled:$||R||M||F,onClick:ne,children:[$?n.jsx(ge,{className:"h-3 w-3 animate-spin"}):n.jsx(yo,{className:"h-3 w-3"}),$?"Generating…":"Regenerate"]})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("label",{htmlFor:"publish-title",className:"text-xs font-medium text-muted-foreground",children:"Title"}),n.jsx(Ye,{id:"publish-title",value:E,onChange:he=>C(he.target.value),placeholder:$?"Generating…":"Commit title…",disabled:R||M||F||$,className:"text-sm"})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("label",{htmlFor:"publish-body",className:"text-xs font-medium text-muted-foreground",children:"Description"}),n.jsx(xr,{id:"publish-body",value:y,onChange:he=>T(he.target.value),placeholder:$?"Generating…":"Description (optional)…",disabled:R||M||F||$,rows:5,className:"resize-none text-sm"})]}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Branch: ",n.jsx("span",{className:"font-mono",children:r}),x?n.jsxs(n.Fragment,{children:[" · ",n.jsx("span",{className:"text-foreground/80",children:g?`Commits and pushes to update open PR #${f.number}.`:"Commits and pushes to the branch without opening a pull request."})]}):n.jsxs(n.Fragment,{children:[" → ",n.jsx("span",{className:"font-mono",children:o})," · ",n.jsxs("span",{className:"text-foreground/80",children:["Submit for review keeps changes on the branch;"," ",H," squash-merges into ",o,"."]})]})]})]})}),n.jsx(mi,{value:"changes",className:"mt-0",children:n.jsx(eh,{diff:k,onDiscardFile:Mt})})]})}),n.jsx("div",{className:"shrink-0 border-t",children:n.jsxs("button",{type:"button",className:"flex w-full items-center justify-between px-6 py-3.5 text-sm transition-colors hover:bg-muted/50 disabled:opacity-50",onClick:()=>{c&&window.open(c,"_blank","noopener,noreferrer")},disabled:!c,children:[n.jsxs("span",{className:"flex items-center gap-3",children:[n.jsx(af,{className:"h-4 w-4 text-muted-foreground"}),"Visit preview"]}),n.jsx(Qd,{className:"h-4 w-4 text-muted-foreground"})]})}),n.jsx("div",{className:"shrink-0 border-t px-6 py-3",children:x?n.jsxs(n.Fragment,{children:[n.jsxs(te,{type:"button",className:"w-full",onClick:Ee,disabled:!me||F,children:[F?n.jsx(ge,{className:"h-4 w-4 animate-spin"}):null,"Save changes"]}),q&&n.jsx("p",{className:"mt-2 text-xs text-destructive",children:q})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs(te,{type:"button",variant:"outline",className:"flex-1",onClick:St,disabled:!me||M||R,children:[M?n.jsx(ge,{className:"h-4 w-4 animate-spin"}):n.jsx(Ps,{className:"h-4 w-4"}),"Submit for review"]}),n.jsx(E0,{label:H,canPublish:le,disabledReason:ve,isPublishing:R,isSubmittingForReview:M,onPublish:mt})]}),z&&n.jsx("p",{className:"mt-2 text-xs text-destructive",children:z}),D&&n.jsx("p",{className:"mt-2 text-xs text-destructive",children:D})]})})]})})}function E0(t){const e=K.c(14),{label:s,canPublish:i,disabledReason:r,isPublishing:o,isSubmittingForReview:a,onPublish:l}=t,h=!i||o||a;let c;e[0]!==o?(c=o?n.jsx(ge,{className:"h-4 w-4 animate-spin"}):null,e[0]=o,e[1]=c):c=e[1];let d;e[2]!==s||e[3]!==l||e[4]!==h||e[5]!==c?(d=n.jsxs(te,{type:"button",variant:"success",className:"flex-1",onClick:l,disabled:h,children:[c,s]}),e[2]=s,e[3]=l,e[4]=h,e[5]=c,e[6]=d):d=e[6];const u=d;if(!r)return u;let f;e[7]!==u?(f=n.jsx(Se,{asChild:!0,children:n.jsx("span",{className:"flex flex-1",children:u})}),e[7]=u,e[8]=f):f=e[8];let p;e[9]!==r?(p=n.jsx(we,{children:r}),e[9]=r,e[10]=p):p=e[10];let m;return e[11]!==f||e[12]!==p?(m=n.jsx(sc,{children:n.jsxs(Ce,{children:[f,p]})}),e[11]=f,e[12]=p,e[13]=m):m=e[13],m}function T0(){return!1}function hd(t,e){T0()&&console.log(`[github-header] ${t}`,e??"")}function R0(t){if(!(t==="claiming"||t==="ready"||t==="failed"))return nh[t].short}const P0=new Set(["failure","timed_out","cancelled","action_required"]);function D0(t){return t.status==="completed"&&P0.has(t.conclusion)}function A0(t){return t.status==="queued"||t.status==="in_progress"}function M0(t){const{lifecycle:e,branch:s,pr:i,checks:r,reviews:o,loading:a}=t;if(a)return{label:"Loading…",disabled:!0,loading:!0,variant:"outline",tooltip:"Loading branch and pull request status"};switch(e.phase){case"idle":return{label:t.claimPhase&&R0(t.claimPhase.kind)||"Starting sandbox…",disabled:!0,loading:!0,variant:"outline",tooltip:"Waiting for the sandbox daemon to come online"};case"cloning":return{label:"Cloning repo…",disabled:!0,loading:!0,variant:"outline",tooltip:"Cloning the project repository"};case"clone-failed":return{label:"Clone failed",disabled:!0,variant:"outline",tooltip:e.error||"git clone failed — see setup logs"};case"checking-out":return{label:`Switching to ${e.to}…`,disabled:!0,loading:!0,variant:"outline",tooltip:`Checking out ${e.to}`}}if(s.kind!=="ready")return{label:"Loading branch…",disabled:!0,loading:!0,variant:"outline",tooltip:"Waiting for branch metadata from the sandbox daemon"};const l=s;if(l.workingTreeDirty||l.unpushed>0)return{label:"Save changes",action:"commit-and-push",variant:"default",tooltip:"Commit and push local changes"};if(hd("no local work — checking PR/sync state",{workingTreeDirty:l.workingTreeDirty,unpushed:l.unpushed,aheadOfBase:l.aheadOfBase,behindBase:l.behindBase,branch:l.branch,base:l.base,prMerged:i?.merged??null,prState:i?.state??null}),i?.merged)return!!l.headSha&&!!i.headSha&&l.headSha!==i.headSha?{label:"Continue",action:"create-pr",variant:"special",tooltip:"Open a new PR with the latest commits"}:{label:"Published",disabled:!0,variant:"outline",tooltip:`PR #${i.number} merged into ${i.base}`};if(l.aheadOfBase>0){if(i&&i.state==="closed"&&!i.merged)return{label:"Reopen",action:"reopen",variant:"default",tooltip:`Reopen PR #${i.number}`};if(!i)return{label:"Submit for review",action:"create-pr",variant:"default",tooltip:`Open a PR for ${l.branch} → ${l.base}`};if((o?.mergeableState??"unknown")==="dirty")return{label:`Sync with ${i.base}`,action:"rebase",variant:"default",tooltip:`Resolve conflicts with ${i.base} before merging`};const d=r.filter(D0).map(p=>p.name);if(d.length>0)return{label:"Fix tests",action:"fix-checks",variant:"default",tooltip:`Failing: ${d.join(", ")}`,meta:{failingChecks:d}};const u=r.filter(A0);if(u.length>0)return{label:"Running tests…",disabled:!0,loading:!0,variant:"outline",tooltip:`Waiting on ${u.length} check${u.length===1?"":"s"} to finish`};if(o?.draft)return{label:"Mark ready",action:"mark-ready",variant:"default",tooltip:"Mark draft PR ready for review"};const f=o?.unresolvedConversations??0;return f>0?{label:"Address feedback",action:"resolve-comments",variant:"default",tooltip:`${f} unresolved conversation${f===1?"":"s"}`}:o?.missingRequiredApprovals?{label:"Awaiting review",disabled:!0,variant:"outline",tooltip:"Waiting for required approvals"}:{label:Jo(i.base),action:"merge-split",variant:"success",tooltip:`Squash-merge PR #${i.number} into ${i.base}`}}return{label:"Up to date",disabled:!0,variant:"outline",tooltip:`Branch is in sync with ${l.base}`}}function B0(t,e,s){if(!e)return s??null;const i=t?.[e];if(!i)return s??null;if(s&&i[s])return s;for(const[r,o]of Object.entries(i))if(o&&Object.keys(o).length>0)return r;return s??null}const I0=6e4,L0=3e4;function O0(t){const e=K.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=Xe(s),r=t.prNumber??0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(o={method:"get",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=o):o=e[7];const a=!!t.prNumber;let l;return e[8]!==i||e[9]!==o||e[10]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:I0,refetchIntervalInBackground:!1,staleTime:L0,select:$0},e[8]=i,e[9]=o,e[10]=a,e[11]=l):l=e[11],Lr(l)}function $0(t){const e=Ss(t);if(!e)return null;const s=e.mergeable_state??"unknown",i=!!(e.draft??!1),r=Number(e.review_comments??0),o=s==="blocked"&&r>0?r:0;return{draft:i,mergeableState:s,unresolvedConversations:o,missingRequiredApprovals:s==="blocked"&&o===0}}const cr=100;function z0(t,e,s){const i=e.trim().toLowerCase();return i?(t??[]).some(r=>r.branches.some(o=>typeof o.name=="string"&&!s.has(o.name)&&o.name.toLowerCase().includes(i))):!0}function F0(t,e){const s=e.trim().toLowerCase();return s?[...t].some(i=>i.toLowerCase().includes(s)):!0}function H0(t){const e=t;if(e.structuredContent)return e.structuredContent;const s=e.content?.find(i=>i.type==="text")?.text;if(s)try{return JSON.parse(s)}catch{return[]}return[]}function W0(t){const e=K.c(48),{orgId:s,orgSlug:i,userId:r,connectionId:o,sandboxMap:a,owner:l,repo:h,enabled:c}=t,d=c===void 0?!0:c,u=o??null;let f;e[0]!==s||e[1]!==i||e[2]!==u?(f={connectionId:u,orgId:s,orgSlug:i},e[0]=s,e[1]=i,e[2]=u,e[3]=f):f=e[3];const p=Xe(f);let m;e[4]!==o||e[5]!==s||e[6]!==i||e[7]!==l||e[8]!==h?(m=Ud.githubBranches(s,i,o,l,h),e[4]=o,e[5]=s,e[6]=i,e[7]=l,e[8]=h,e[9]=m):m=e[9];const _=d&&!!o&&!!l&&!!h;let g;e[10]!==p||e[11]!==l||e[12]!==h?(g=async z=>{const{pageParam:O,signal:q}=z,V=Number(O),Q=await p.callTool({name:"list_branches",arguments:{owner:l,repo:h,page:V,perPage:cr}},void 0,{signal:q}),G=H0(Q);return{branches:Array.isArray(G)?G:G.branches??[],default_branch:Array.isArray(G)?null:G.default_branch??null,page:V}},e[10]=p,e[11]=l,e[12]=h,e[13]=g):g=e[13];let x;e[14]!==m||e[15]!==_||e[16]!==g?(x={queryKey:m,enabled:_,staleTime:3e4,retry:!1,initialPageParam:1,queryFn:g,getNextPageParam:Y0},e[14]=m,e[15]=_,e[16]=g,e[17]=x):x=e[17];const{data:S,isLoading:v,isError:b,hasNextPage:k,isFetchingNextPage:w,fetchNextPage:N}=Nf(x);let j,R;e[18]!==a||e[19]!==r?(R=new Set(Object.keys(a?.[r]??{})),j=[...R].sort().map(G0),e[18]=a,e[19]=r,e[20]=j,e[21]=R):(j=e[20],R=e[21]);const I=j;let E;if(e[22]!==S?.pages){const z=new Map;for(const q of S?.pages??[])for(const V of q.branches)typeof V.name=="string"&&z.set(V.name,V);E=[...z.values()].filter(q0),e[22]=S?.pages,e[23]=E}else E=e[23];let C;e[24]!==E||e[25]!==R?(C=E.filter(z=>!R.has(z.name)).map(V0),e[24]=E,e[25]=R,e[26]=C):C=e[26];const y=C;let T;e[27]!==S?.pages?(T=S?.pages.find(K0)?.default_branch??null,e[27]=S?.pages,e[28]=T):T=e[28];const D=T;let P;e[29]!==S?.pages||e[30]!==N||e[31]!==w||e[32]!==R?(P=async(z,O)=>{const q=O===void 0?U0:O;if(!q()||F0(R,z)||w)return;let V=S?.pages??[];for(;q()&&!z0(V,z,R)&&(V.at(-1)?.branches.length??cr)>=cr;){const Q=await N();if(!q())break;const G=Q.data?.pages??V;if(G.length===V.length)break;V=G}},e[29]=S?.pages,e[30]=N,e[31]=w,e[32]=R,e[33]=P):P=e[33];const M=P,B=k??!1;let F;e[34]!==N||e[35]!==k||e[36]!==w?(F=()=>{k&&!w&&N()},e[34]=N,e[35]=k,e[36]=w,e[37]=F):F=e[37];let U;return e[38]!==D||e[39]!==M||e[40]!==b||e[41]!==w||e[42]!==v||e[43]!==y||e[44]!==B||e[45]!==F||e[46]!==I?(U={yours:I,others:y,defaultBase:D,isLoading:v,isError:b,hasMore:B,isFetchingMore:w,fetchMore:F,fetchUntilMatch:M},e[38]=D,e[39]=M,e[40]=b,e[41]=w,e[42]=v,e[43]=y,e[44]=B,e[45]=F,e[46]=I,e[47]=U):U=e[47],U}function U0(){return!0}function K0(t){return t.default_branch}function V0(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function q0(t){return typeof t.name=="string"}function G0(t){return{name:t,source:"yours"}}function Y0(t){if(!(t.branches.length<cr))return t.page+1}function X0(t){const e=K.c(85),{orgId:s,orgSlug:i,userId:r,connectionId:o,owner:a,repo:l,sandboxMap:h,value:c,onChange:d,disabled:u,placement:f}=t,p=u===void 0?!1:u,_=(f===void 0?"chat":f)==="header",[g,x]=A.useState(!1),[S,v]=A.useState(""),[b,k]=A.useState(!1),w=A.useRef(0);let N;e[0]!==o||e[1]!==g||e[2]!==s||e[3]!==i||e[4]!==a||e[5]!==l||e[6]!==h||e[7]!==r?(N={orgId:s,orgSlug:i,userId:r,connectionId:o,sandboxMap:h,owner:a,repo:l,enabled:g},e[0]=o,e[1]=g,e[2]=s,e[3]=i,e[4]=a,e[5]=l,e[6]=h,e[7]=r,e[8]=N):N=e[8];const{yours:j,others:R,isLoading:I,isError:E,hasMore:C,isFetchingMore:y,fetchMore:T,fetchUntilMatch:D}=W0(N);let P;e[9]!==d?(P=Pe=>{d(Pe),x(!1)},e[9]=d,e[10]=P):P=e[10];const M=P,B=c??"Select branch…";let F;e[11]!==D?(F=Pe=>{v(Pe),w.current=w.current+1;const St=w.current,he=Pe.trim();if(!he){k(!1);return}k(!0),D(he,()=>St===w.current).finally(()=>{St===w.current&&k(!1)})},e[11]=D,e[12]=F):F=e[12];const U=F;let z;e[13]!==T?(z=Pe=>{const St=Pe.currentTarget;St.scrollHeight-St.scrollTop-St.clientHeight<48&&T()},e[13]=T,e[14]=z):z=e[14];const O=z,q=p?void 0:x,V=_?"outline":"ghost",Q=_?"sm":"default";let G;e[15]!==p||e[16]!==_?(G=ie("font-mono shrink min-w-0 max-w-[200px]",_?"gap-1.5 text-xs":ie("text-xs text-muted-foreground hover:text-foreground transition-[gap] duration-200",p?"gap-0":"gap-0 @[320px]/chat-bottom:gap-1.5")),e[15]=p,e[16]=_,e[17]=G):G=e[17];let W;e[18]===Symbol.for("react.memo_cache_sentinel")?(W=n.jsx(Ps,{className:"h-3.5 w-3.5 shrink-0"}),e[18]=W):W=e[18];let ee;e[19]!==p||e[20]!==_?(ee=ie("min-w-0 truncate",_?"":ie("transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0",!p&&"@[320px]/chat-bottom:max-w-[200px] @[320px]/chat-bottom:opacity-100")),e[19]=p,e[20]=_,e[21]=ee):ee=e[21];let $;e[22]!==B||e[23]!==ee?($=n.jsx("span",{className:ee,children:B}),e[22]=B,e[23]=ee,e[24]=$):$=e[24];let L;e[25]!==p||e[26]!==_?(L=!p&&n.jsx(Or,{size:12,className:ie("opacity-60 shrink-0",_?"":"hidden @[320px]/chat-bottom:inline-block")}),e[25]=p,e[26]=_,e[27]=L):L=e[27];let Y;e[28]!==p||e[29]!==B||e[30]!==G||e[31]!==$||e[32]!==L||e[33]!==V||e[34]!==Q?(Y=n.jsx(Se,{asChild:!0,children:n.jsx("span",{className:"inline-flex min-w-0 shrink",children:n.jsx(Os,{asChild:!0,children:n.jsxs(te,{variant:V,size:Q,"aria-label":B,disabled:p,className:G,children:[W,$,L]})})})}),e[28]=p,e[29]=B,e[30]=G,e[31]=$,e[32]=L,e[33]=V,e[34]=Q,e[35]=Y):Y=e[35];let X;e[36]!==B?(X=n.jsx(we,{children:B}),e[36]=B,e[37]=X):X=e[37];let H;e[38]!==Y||e[39]!==X?(H=n.jsxs(Ce,{children:[Y,X]}),e[38]=Y,e[39]=X,e[40]=H):H=e[40];let ne;e[41]!==U||e[42]!==S?(ne=n.jsx(wf,{placeholder:"Search loaded branches…",value:S,onValueChange:U}),e[41]=U,e[42]=S,e[43]=ne):ne=e[43];let re;e[44]!==M?(re=n.jsx(te,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>M(cd()),children:"New"}),e[44]=M,e[45]=re):re=e[45];let ce;e[46]!==ne||e[47]!==re?(ce=n.jsxs("div",{className:"*:data-[slot=command-input-wrapper]:flex-1 *:data-[slot=command-input-wrapper]:border-b-0 flex items-center border-b pr-2",children:[ne,re]}),e[46]=ne,e[47]=re,e[48]=ce):ce=e[48];let de;e[49]!==E?(de=E&&n.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Couldn't load branches from GitHub. You can still pick from your branches."}),e[49]=E,e[50]=de):de=e[50];let me;e[51]!==C||e[52]!==E||e[53]!==I?(me=!E&&!I&&n.jsx(Cf,{children:C?"Looking through more branches...":"No branches found."}),e[51]=C,e[52]=E,e[53]=I,e[54]=me):me=e[54];let le;e[55]!==M||e[56]!==j?(le=j.length>0&&n.jsx(ba,{heading:"Your branches",children:j.map(Pe=>n.jsxs(ya,{value:Pe.name,onSelect:()=>M(Pe.name),children:[n.jsx(Ps,{className:"mr-2 h-4 w-4"}),n.jsx("span",{className:"flex-1 truncate",children:Pe.name})]},Pe.name))}),e[55]=M,e[56]=j,e[57]=le):le=e[57];let ve;e[58]!==R||e[59]!==M?(ve=R.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(Sf,{}),n.jsx(ba,{heading:"Other branches in repo",children:R.map(Pe=>n.jsxs(ya,{value:Pe.name,onSelect:()=>M(Pe.name),children:[n.jsx(Ps,{className:"mr-2 h-4 w-4"}),n.jsx("span",{className:"flex-1 truncate",children:Pe.name}),Pe.author&&n.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",Pe.author]})]},Pe.name))})]}),e[58]=R,e[59]=M,e[60]=ve):ve=e[60];let xe;e[61]!==T||e[62]!==C||e[63]!==y||e[64]!==b?(xe=C&&n.jsx("div",{className:"border-t p-2",children:n.jsx(te,{variant:"ghost",size:"sm",className:"h-7 w-full text-xs",disabled:y,onClick:T,children:y||b?"Loading more…":"Load more branches"})}),e[61]=T,e[62]=C,e[63]=y,e[64]=b,e[65]=xe):xe=e[65];let Ne;e[66]!==C||e[67]!==R.length?(Ne=!C&&R.length>0&&n.jsx("div",{className:"border-t p-2 text-center text-xs text-muted-foreground",children:"All loaded"}),e[66]=C,e[67]=R.length,e[68]=Ne):Ne=e[68];let Ee;e[69]!==O||e[70]!==de||e[71]!==me||e[72]!==le||e[73]!==ve||e[74]!==xe||e[75]!==Ne?(Ee=n.jsxs(kf,{onScroll:O,children:[de,me,le,ve,xe,Ne]}),e[69]=O,e[70]=de,e[71]=me,e[72]=le,e[73]=ve,e[74]=xe,e[75]=Ne,e[76]=Ee):Ee=e[76];let mt;e[77]!==ce||e[78]!==Ee?(mt=n.jsx($s,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:n.jsxs(jf,{children:[ce,Ee]})}),e[77]=ce,e[78]=Ee,e[79]=mt):mt=e[79];let Mt;return e[80]!==g||e[81]!==H||e[82]!==mt||e[83]!==q?(Mt=n.jsxs(Ls,{open:g,onOpenChange:q,children:[H,mt]}),e[80]=g,e[81]=H,e[82]=mt,e[83]=q,e[84]=Mt):Mt=e[84],Mt}function J0(t){const e=K.c(8);let s,i,r;e[0]!==t?({locked:s,placement:i,...r}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r):(s=e[1],i=e[2],r=e[3]);let o;return e[4]!==s||e[5]!==i||e[6]!==r?(o=n.jsx(X0,{...r,disabled:s,placement:i}),e[4]=s,e[5]=i,e[6]=r,e[7]=o):o=e[7],o}const Z0={label:"Loading branch…",disabled:!0,loading:!0,variant:"outline",tooltip:"Waiting for sandbox branch"};function Q0({virtualMcpId:t}){const{org:e}=je(),{data:s}=ji.useSession(),i=At(t),{currentBranch:r,setCurrentTaskBranch:o}=rs(),a=xs(),[l,h]=A.useState(!1),[c,d]=A.useState("publish"),[u,f]=A.useState(!1),p=A.useRef(""),m=Bs(i),_=s?.user?.id,g=Xe({connectionId:m?.connectionId??"",orgId:e.id,orgSlug:e.slug}),{lifecycle:x,branch:S,phase:v,notFound:b}=ns(),k=S.kind==="ready"?S.branch:null,w=B0(i?.metadata?.sandboxMap,_,r??k),N=r??k??w??void 0,j=b0({orgSlug:e.slug,virtualMcpId:t,branch:N??null,enabled:!!m&&!!N&&!b}),R=Oo(j.data)??N??null,I=Ro({orgId:e.id,orgSlug:e.slug,connectionId:m?.connectionId??"",owner:m?.owner??"",repo:m?.name??"",branch:R}),E=I.data??null,C=Ec({orgId:e.id,orgSlug:e.slug,connectionId:m?.connectionId??"",owner:m?.owner??"",repo:m?.name??"",prNumber:E&&E.state==="open"?E.number:null}),y=O0({orgId:e.id,orgSlug:e.slug,connectionId:m?.connectionId??"",owner:m?.owner??"",repo:m?.name??"",prNumber:E&&E.state==="open"?E.number:null}),T=w_(S,j.data);if(!m)return null;const D=_&&R?vi(i?.metadata?.sandboxMap?.[_]?.[R]):{},P=Object.values(D),B=(P.find(L=>L.sandboxProviderKind!=="user-desktop")??P[0])?.previewUrl??null,F=R?M0({lifecycle:x,branch:T,claimPhase:v,pr:E,checks:C.data??[],reviews:y.data??null,loading:I.isPending}):Z0,U=JSON.stringify({label:F.label,branchKind:T.kind,workingTreeDirty:T.kind==="ready"?T.workingTreeDirty:null,gitModifiedCount:j.data?.modified.length??null,unpushed:T.kind==="ready"?T.unpushed:null,aheadOfBase:T.kind==="ready"?T.aheadOfBase:null,lifecycle:x.phase,githubHeadBranch:R});p.current!==U&&(p.current=U,hd("header button",{label:F.label,tooltip:F.tooltip,action:F.action,chatBranch:r,sandboxBranch:k,sandboxMapBranch:w,sandboxRouteBranch:N,githubHeadBranch:R,branchMeta:S,effectiveBranchMeta:T,gitStatus:j.data??null,lifecyclePhase:x.phase,prNumber:E?.number??null,prState:E?.state??null}));const z=L=>a.sendMessage({parts:[{type:"text",text:L}]}),O=a.isStreaming,q=T.kind==="ready"?T.base:"main",V=async()=>{await Promise.all([I.refetch(),j.refetch(),C.refetch(),y.refetch()])},Q=async()=>{const L=cd();await o(L)},G=async L=>{if(!(!m?.connectionId||u)){f(!0);try{await Nc(g,{owner:m.owner,repo:m.name,pullNumber:L}),ae.success(`Published PR #${L}`),await V(),await Q()}catch(Y){ae.error(Y instanceof Error?Y.message:"Failed to merge pull request")}finally{f(!1)}}},W=L=>{if(!(!L||!R))switch(L){case"commit-and-push":d("publish"),h(!0);return;case"create-pr":d("open-pr"),h(!0);return;case"reopen":if(O)return;E&&z(R_({prNumber:E.number}));return;case"rebase":if(O)return;z(P_({branch:R}));return;case"fix-checks":if(O)return;E&&z(A_({prNumber:E.number,failingChecks:F.meta?.failingChecks??[]}));return;case"mark-ready":if(O)return;E&&z(M_({prNumber:E.number}));return;case"resolve-comments":if(O)return;E&&z(B_({prNumber:E.number}));return;case"merge-split":return}},ee=u||O,$=(a.messages??[]).length>0;return n.jsxs(n.Fragment,{children:[n.jsx(ou,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(J0,{orgId:e.id,orgSlug:e.slug,userId:_??"",virtualMcpId:t,connectionId:m.connectionId??"",owner:m.owner,repo:m.name,sandboxMap:i?.metadata?.sandboxMap,value:r??N??null,onChange:L=>{o(L)},locked:$,placement:"header"}),n.jsx(ey,{button:F,actionBusy:ee,githubActionPending:u,onActivate:W,prNumber:E?.number,prBase:E?.base,onSquashMerge:G,onReview:E?()=>{O||z(I_({prNumber:E.number}))}:void 0})]}),N&&n.jsx(k0,{open:l,onOpenChange:h,orgSlug:e.slug,orgId:e.id,virtualMcpId:t,branch:N,baseBranch:q,githubConnectionId:m.connectionId??"",owner:m.owner,repo:m.name,previewUrl:B,dialogIntent:c,headSha:T.kind==="ready"?T.headSha:null,openPullRequest:E?.state==="open"?E:null,onPullRequestChanged:V,onPublished:Q})]})}function ey(t){const e=K.c(25),{button:s,actionBusy:i,githubActionPending:r}=t,o=i&&s.action!=="create-pr"&&s.action!=="commit-and-push"&&s.action!=="merge-split",a=!!s.disabled||o||r&&s.action==="merge-split",l=!!s.loading||r&&s.action==="merge-split",h=o?"Chat is running":s.tooltip??null;if(s.action==="merge-split"&&t.prNumber!=null&&t.prBase!=null){let p;e[0]!==t?(p=()=>t.onSquashMerge(t.prNumber),e[0]=t,e[1]=p):p=e[1];let m;e[2]!==a||e[3]!==l||e[4]!==t.onReview||e[5]!==t.prBase||e[6]!==p?(m=n.jsx(C0,{baseBranch:t.prBase,disabled:a,loading:l,onPublish:p,onReview:t.onReview}),e[2]=a,e[3]=l,e[4]=t.onReview,e[5]=t.prBase,e[6]=p,e[7]=m):m=e[7];let _;return e[8]!==m||e[9]!==h?(_=n.jsx(Vl,{label:h,children:m}),e[8]=m,e[9]=h,e[10]=_):_=e[10],_}let c;e[11]!==s.action||e[12]!==t?(c=()=>{s.action&&t.onActivate(s.action)},e[11]=s.action,e[12]=t,e[13]=c):c=e[13];let d;e[14]!==l?(d=l?n.jsx(bc,{size:"xs",variant:"default"}):null,e[14]=l,e[15]=d):d=e[15];let u;e[16]!==s.label||e[17]!==s.variant||e[18]!==a||e[19]!==c||e[20]!==d?(u=n.jsxs(te,{size:"sm",variant:s.variant,disabled:a,onClick:c,children:[d,s.label]}),e[16]=s.label,e[17]=s.variant,e[18]=a,e[19]=c,e[20]=d,e[21]=u):u=e[21];let f;return e[22]!==u||e[23]!==h?(f=n.jsx(Vl,{label:h,children:u}),e[22]=u,e[23]=h,e[24]=f):f=e[24],f}function Vl(t){const e=K.c(9),{label:s,children:i}=t;if(!s){let l;return e[0]!==i?(l=n.jsx(n.Fragment,{children:i}),e[0]=i,e[1]=l):l=e[1],l}let r;e[2]!==i?(r=n.jsx(Se,{asChild:!0,children:n.jsx("span",{children:i})}),e[2]=i,e[3]=r):r=e[3];let o;e[4]!==s?(o=n.jsx(we,{children:s}),e[4]=s,e[5]=o):o=e[5];let a;return e[6]!==r||e[7]!==o?(a=n.jsx(sc,{children:n.jsxs(Ce,{children:[r,o]})}),e[6]=r,e[7]=o,e[8]=a):a=e[8],a}function dd(t){const e=K.c(4),{virtualMcp:s,inline:i}=t,r=i===void 0?!1:i;if(!Bs(s))return null;let a;e[0]!==s.id?(a=n.jsx(Q0,{virtualMcpId:s.id}),e[0]=s.id,e[1]=a):a=e[1];const l=a;if(r)return l;let h;return e[2]!==l?(h=n.jsx(bn.Right,{children:l}),e[2]=l,e[3]=h):h=e[3],h}function ty(t,e){const s=K.c(34),i=hc(),r=A.useSyncExternalStore(i.threads.subscribe,i.threads.get),o=A.useSyncExternalStore(i.threadsStatus.subscribe,i.threadsStatus.get);let a;s[0]!==t||s[1]!==r?(a=t?r.find(v=>v.id===t)??null:null,s[0]=t,s[1]=r,s[2]=a):a=s[2];const l=a,[h,c]=A.useState(void 0);let d;s[3]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{c(void 0)},s[3]=d):d=s[3];let u;s[4]!==t?(u=[t],s[4]=t,s[5]=u):u=s[5],A.useEffect(d,u);let f,p;s[6]!==h||s[7]!==t||s[8]!==l||s[9]!==i||s[10]!==o.kind?(f=()=>{t&&(l||o.kind!=="loading"&&h===void 0&&(c("pending"),i.fetchThread(t).then(v=>{c(v)})))},p=[t,l,o.kind,h,i],s[6]=h,s[7]=t,s[8]=l,s[9]=i,s[10]=o.kind,s[11]=f,s[12]=p):(f=s[11],p=s[12]),A.useEffect(f,p);let m;s[13]!==i||s[14]!==e?(m={mutationFn:async v=>i.create({id:v,virtual_mcp_id:e})},s[13]=i,s[14]=e,s[15]=m):m=s[15];const _=Rr(m);let g,x;if(s[16]!==_||s[17]!==h||s[18]!==t||s[19]!==l||s[20]!==o.kind?(g=()=>{t&&(l||h===null&&o.kind!=="loading"&&(_.isPending||_.variables!==t&&_.mutate(t)))},x=[t,l,h,o.kind,_],s[16]=_,s[17]=h,s[18]=t,s[19]=l,s[20]=o.kind,s[21]=g,s[22]=x):(g=s[21],x=s[22]),A.useEffect(g,x),!t){let v;return s[23]===Symbol.for("react.memo_cache_sentinel")?(v={status:"ready",task:null},s[23]=v):v=s[23],v}if(l){let v;return s[24]!==l?(v={status:"ready",task:l},s[24]=l,s[25]=v):v=s[25],v}if(h&&typeof h=="object"){let v;return s[26]!==h?(v={status:"ready",task:h},s[26]=h,s[27]=v):v=s[27],v}if(_.data){let v;return s[28]!==_.data?(v={status:"ready",task:_.data},s[28]=_.data,s[29]=v):v=s[29],v}if(_.isError){let v;return s[30]!==_.error?(v={status:"error",error:_.error},s[30]=_.error,s[31]=v):v=s[31],v}if(_.isPending||o.kind!=="loading"){let v;return s[32]===Symbol.for("react.memo_cache_sentinel")?(v={status:"creating"},s[32]=v):v=s[32],v}let S;return s[33]===Symbol.for("react.memo_cache_sentinel")?(S={status:"loading"},s[33]=S):S=s[33],S}const Ts=A.createContext(null);function Zo(){return A.use(Ts)}function ql(t){const e=K.c(6),{children:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Something went wrong loading the chat. Try refreshing."}),e[0]=i):i=e[0];let r;e[1]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(ze.Skeleton,{}),e[1]=r):r=e[1];let o;e[2]!==s?(o=s??n.jsx(Sc,{}),e[2]=s,e[3]=o):o=e[3];let a;return e[4]!==o?(a=n.jsx($t,{fallback:i,children:n.jsx(A.Suspense,{fallback:r,children:o})}),e[4]=o,e[5]=a):a=e[5],a}function Gl(t){const e=K.c(3),{onNewTaskRef:s,createNewTask:i}=t;let r;return e[0]!==i||e[1]!==s?(r=()=>(s.current=i,()=>{s.current=null}),e[0]=i,e[1]=s,e[2]=r):r=e[2],A.useLayoutEffect(r),null}function sy(t){const e=K.c(27),{onOpenSidebar:s,virtualMcpId:i,taskId:r,mainOpen:o,onToggleMain:a,onNewTask:l,entity:h,hasActiveGithubRepo:c}=t;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(ju,{size:20}),e[0]=d):d=e[0];let u;e[1]!==s?(u=n.jsx("button",{type:"button",onClick:s,className:"flex size-8 shrink-0 items-center justify-center rounded-md text-foreground/60 hover:bg-accent hover:text-foreground transition-colors","aria-label":"Open menu",children:d}),e[1]=s,e[2]=u):u=e[2];let f;e[3]!==r||e[4]!==i?(f=n.jsx("div",{className:"flex-1 min-w-0 overflow-x-auto [scrollbar-width:none]",children:n.jsx(ld,{virtualMcpId:i,taskId:r})}),e[3]=r,e[4]=i,e[5]=f):f=e[5];let p;e[6]!==h||e[7]!==c?(p=h&&c?n.jsx(dd,{virtualMcp:h,inline:!0}):null,e[6]=h,e[7]=c,e[8]=p):p=e[8];const m=!o,_=o?"text-foreground/60 hover:bg-accent hover:text-foreground":"bg-accent text-foreground";let g;e[9]!==_?(g=ie("flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",_),e[9]=_,e[10]=g):g=e[10];let x;e[11]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(ac,{size:16}),e[11]=x):x=e[11];let S;e[12]!==a||e[13]!==m||e[14]!==g?(S=n.jsx("button",{type:"button",onClick:a,"aria-pressed":m,className:g,title:"Chat",children:x}),e[12]=a,e[13]=m,e[14]=g,e[15]=S):S=e[15];let v;e[16]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(Dr,{size:16}),e[16]=v):v=e[16];let b;e[17]!==l?(b=n.jsx("button",{type:"button",onClick:l,className:"flex size-7 shrink-0 items-center justify-center rounded-md text-foreground/60 hover:bg-accent hover:text-foreground transition-colors",title:"New task",children:v}),e[17]=l,e[18]=b):b=e[18];let k;e[19]!==b||e[20]!==p||e[21]!==S?(k=n.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[p,S,b]}),e[19]=b,e[20]=p,e[21]=S,e[22]=k):k=e[22];let w;return e[23]!==k||e[24]!==u||e[25]!==f?(w=n.jsxs("div",{className:"shrink-0 flex items-center gap-1 px-2 h-12 bg-background border-b border-border",children:[u,f,k]}),e[23]=k,e[24]=u,e[25]=f,e[26]=w):w=e[26],w}function Yl(t){const e=K.c(24),{virtualMcpId:s,hasActiveGithubRepo:i,sandboxMap:r,children:o}=t,{org:a}=je(),{currentBranch:l}=rs(),{data:h}=ji.useSession(),c=h?.user?.id;let d;e[0]!==a.id||e[1]!==a.slug?(d={connectionId:vs,orgId:a.id,orgSlug:a.slug},e[0]=a.id,e[1]=a.slug,e[2]=d):d=e[2];const u=Xe(d),{mutate:f}=ho(u);let p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p=new Set,e[3]=p):p=e[3];const m=A.useRef(p);let _,g;e[4]!==l||e[5]!==i||e[6]!==r||e[7]!==f||e[8]!==c||e[9]!==s?(_=()=>{if(!i||!c||!l)return;const j=vi(r?.[c]?.[l]);if(Object.keys(j).length>0){m.current.add(l);return}m.current.has(l)||(m.current.add(l),f({virtualMcpId:s,branch:l},{onError:iy}))},g=[i,c,l,r,s,f],e[4]=l,e[5]=i,e[6]=r,e[7]=f,e[8]=c,e[9]=s,e[10]=_,e[11]=g):(_=e[10],g=e[11]),A.useEffect(_,g);const x=uo(s,l??void 0);let S;e[12]!==l||e[13]!==r||e[14]!==c?(S=c&&l?vi(r?.[c]?.[l]):{},e[12]=l,e[13]=r,e[14]=c,e[15]=S):S=e[15];const v=S;let b;e[16]!==v||e[17]!==x?(b=Object.keys(v).length>0||x,e[16]=v,e[17]=x,e[18]=b):b=e[18];const k=b,w=l??null;let N;return e[19]!==o||e[20]!==k||e[21]!==w||e[22]!==s?(N=n.jsx(Gm,{virtualMcpId:s,branch:w,enabled:k,children:o}),e[19]=o,e[20]=k,e[21]=w,e[22]=s,e[23]=N):N=e[23],N}function iy(t){console.error("[auto-start-vm] failed:",t)}function ry(){const t=K.c(116),e=tc(),s=Vt(),{org:i}=je();Nu(i.slug);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={strict:!1},t[0]=r):r=t[0];const o=Xl(r),a=o.org??"";let l;t[1]===Symbol.for("react.memo_cache_sentinel")?(l={strict:!1},t[1]=l):l=t[1];const h=co(l);let c;t[2]!==i.id||t[3]!==h.virtualmcpid?(c=h.virtualmcpid??fo(i.id).id,t[2]=i.id,t[3]=h.virtualmcpid,t[4]=c):c=t[4];const d=c,u=ty(o.taskId??"",d),f=At(d),p=f?.metadata?.ui?.layout??null;let m;t[5]!==p?(m=p?{defaultMainView:p.defaultMainView??null,chatDefaultOpen:p.chatDefaultOpen??null}:null,t[5]=p,t[6]=m):m=t[6];const _=m;let g;t[7]!==f?(g=f&&Bs(f),t[7]=f,t[8]=g):g=t[8];const x=!!g;let S;t[9]!==a||t[10]!==d?(S={virtualMcpId:d,orgSlug:a,isAgentRoute:!0},t[9]=a,t[10]=d,t[11]=S):S=t[11];const v=om(_,S),{setOpenMobile:b,openMobile:k}=lu(),w=b,N=A.useRef(null);let j,R;t[12]===Symbol.for("react.memo_cache_sentinel")?(j=()=>{const G=W=>{nu(W)&&W.shiftKey&&W.code==="KeyS"&&!W.repeat&&(W.preventDefault(),N.current?.())};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},R=[],t[12]=j,t[13]=R):(j=t[12],R=t[13]),A.useEffect(j,R);const I=d;let E;t[14]!==f||t[15]!==d?(E={virtualMcpId:d,entity:f},t[14]=f,t[15]=d,t[16]=E):E=t[16];const C=E;if(u.status==="creating"||u.status==="loading"){let G;t[17]===Symbol.for("react.memo_cache_sentinel")?(G=n.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:n.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[n.jsx(ge,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[17]=G):G=t[17];let W;return t[18]!==C?(W=n.jsx(Ts,{value:C,children:G}),t[18]=C,t[19]=W):W=t[19],W}if(u.status==="error"){let G;t[20]===Symbol.for("react.memo_cache_sentinel")?(G=n.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[20]=G):G=t[20];let W;t[21]!==u.error.message?(W=n.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:n.jsxs("div",{className:"flex flex-col h-full items-center justify-center gap-2 bg-background card-shadow rounded-[0.75rem] p-8 text-sm",children:[G,n.jsx("div",{className:"text-muted-foreground",children:u.error.message})]})}),t[21]=u.error.message,t[22]=W):W=t[22];let ee;return t[23]!==C||t[24]!==W?(ee=n.jsx(Ts,{value:C,children:W}),t[23]=C,t[24]=W,t[25]=ee):ee=t[25],ee}if(!f){let G;t[26]===Symbol.for("react.memo_cache_sentinel")?(G=n.jsx(Ti,{size:48,className:"text-muted-foreground"}),t[26]=G):G=t[26];const W=`The agent "${d}" does not exist in this organization.`;let ee;t[27]!==s||t[28]!==a?(ee=n.jsx(te,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:a}}),children:"Go to organization home"}),t[27]=s,t[28]=a,t[29]=ee):ee=t[29];let $;t[30]!==W||t[31]!==ee?($=n.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:n.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:n.jsx(hr,{image:G,title:"Agent not found",description:W,actions:ee})})}),t[30]=W,t[31]=ee,t[32]=$):$=t[32];let L;return t[33]!==C||t[34]!==$?(L=n.jsx(Ts,{value:C,children:$}),t[33]=C,t[34]=$,t[35]=L):L=t[35],L}if(e){let G;t[36]===Symbol.for("react.memo_cache_sentinel")?(G=n.jsx(hu,{className:"sr-only",children:"Navigation"}),t[36]=G):G=t[36];let W;t[37]!==w?(W=n.jsxs(du,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[G,n.jsx("div",{className:"flex h-full",children:n.jsx("div",{className:"w-full bg-sidebar flex flex-col overflow-y-auto group/sidebar","data-state":"expanded",children:n.jsx(au,{onClose:()=>w(!1)})})})]}),t[37]=w,t[38]=W):W=t[38];let ee;t[39]!==k||t[40]!==w||t[41]!==W?(ee=n.jsx(uu,{open:k,onOpenChange:w,children:W}),t[39]=k,t[40]=w,t[41]=W,t[42]=ee):ee=t[42];const $=ee,L=u.status==="ready"?u.task:null,Y=f?.metadata?.sandboxMap;let X;t[43]!==v.createNewTask?(X=n.jsx(Gl,{onNewTaskRef:N,createNewTask:v.createNewTask}),t[43]=v.createNewTask,t[44]=X):X=t[44];let H;t[45]!==w?(H=()=>w(!0),t[45]=w,t[46]=H):H=t[46];let ne;t[47]!==I||t[48]!==f||t[49]!==x||t[50]!==v.createNewTask||t[51]!==v.mainOpen||t[52]!==v.taskId||t[53]!==v.toggleMain||t[54]!==H?(ne=n.jsx(sy,{onOpenSidebar:H,virtualMcpId:I,taskId:v.taskId,mainOpen:v.mainOpen,onToggleMain:v.toggleMain,onNewTask:v.createNewTask,entity:f,hasActiveGithubRepo:x}),t[47]=I,t[48]=f,t[49]=x,t[50]=v.createNewTask,t[51]=v.mainOpen,t[52]=v.taskId,t[53]=v.toggleMain,t[54]=H,t[55]=ne):ne=t[55];let re;t[56]===Symbol.for("react.memo_cache_sentinel")?(re=n.jsx(ze.Skeleton,{}),t[56]=re):re=t[56];let ce;t[57]!==I||t[58]!==v.mainOpen||t[59]!==v.taskId?(ce=n.jsx(A.Suspense,{fallback:re,children:n.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:v.mainOpen?n.jsx($t,{fallback:n.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Something went wrong. Try refreshing."}),children:n.jsx(A.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(ad,{taskId:v.taskId,virtualMcpId:I})})}):n.jsx(ql,{})})}),t[57]=I,t[58]=v.mainOpen,t[59]=v.taskId,t[60]=ce):ce=t[60];let de;t[61]!==v.taskId||t[62]!==ne||t[63]!==ce?(de=n.jsxs(ze.ActiveTaskProvider,{taskId:v.taskId,children:[ne,ce]},v.taskId),t[61]=v.taskId,t[62]=ne,t[63]=ce,t[64]=de):de=t[64];let me;t[65]!==x||t[66]!==$||t[67]!==Y||t[68]!==X||t[69]!==de||t[70]!==d?(me=n.jsxs(Yl,{virtualMcpId:d,hasActiveGithubRepo:x,sandboxMap:Y,children:[X,de,$]}),t[65]=x,t[66]=$,t[67]=Y,t[68]=X,t[69]=de,t[70]=d,t[71]=me):me=t[71];let le;t[72]!==I||t[73]!==L||t[74]!==me?(le=n.jsx("div",{className:"flex flex-col flex-1 min-w-0 bg-background min-h-0",children:n.jsx(ze.Provider,{virtualMcpId:I,task:L,children:me},I)}),t[72]=I,t[73]=L,t[74]=me,t[75]=le):le=t[75];let ve;return t[76]!==C||t[77]!==le?(ve=n.jsx(Ts,{value:C,children:le}),t[76]=C,t[77]=le,t[78]=ve):ve=t[78],ve}let y;t[79]!==v.chatOpen||t[80]!==v.createNewTask||t[81]!==v.toggleChat?(y=n.jsx(bn.Toggles,{children:n.jsx(u0,{chatOpen:v.chatOpen,toggleChat:v.toggleChat,onNewTask:v.createNewTask})}),t[79]=v.chatOpen,t[80]=v.createNewTask,t[81]=v.toggleChat,t[82]=y):y=t[82];const T=u.status==="ready"?u.task:null,D=f?.metadata?.sandboxMap;let P;t[83]!==v.taskId||t[84]!==d?(P=n.jsx(bn.Tabs,{children:n.jsx(ld,{virtualMcpId:d,taskId:v.taskId})}),t[83]=v.taskId,t[84]=d,t[85]=P):P=t[85];let M;t[86]!==v.createNewTask?(M=n.jsx(Gl,{onNewTaskRef:N,createNewTask:v.createNewTask}),t[86]=v.createNewTask,t[87]=M):M=t[87];let B;t[88]!==f?(B=n.jsx(dd,{virtualMcp:f}),t[88]=f,t[89]=B):B=t[89];let F;t[90]===Symbol.for("react.memo_cache_sentinel")?(F=n.jsx(ze.Skeleton,{}),t[90]=F):F=t[90];let U;t[91]===Symbol.for("react.memo_cache_sentinel")?(U=n.jsx(ql,{}),t[91]=U):U=t[91];let z;t[92]!==v.chatOpen||t[93]!==v.mainOpen||t[94]!==v.taskId||t[95]!==d?(z=n.jsx(A.Suspense,{fallback:F,children:n.jsx(d0,{virtualMcpId:d,taskId:v.taskId,chatOpen:v.chatOpen,mainOpen:v.mainOpen,chatContent:U})}),t[92]=v.chatOpen,t[93]=v.mainOpen,t[94]=v.taskId,t[95]=d,t[96]=z):z=t[96];let O;t[97]!==v.taskId||t[98]!==B||t[99]!==z?(O=n.jsxs(ze.ActiveTaskProvider,{taskId:v.taskId,children:[B,z]},v.taskId),t[97]=v.taskId,t[98]=B,t[99]=z,t[100]=O):O=t[100];let q;t[101]!==x||t[102]!==D||t[103]!==P||t[104]!==M||t[105]!==O||t[106]!==d?(q=n.jsxs(Yl,{virtualMcpId:d,hasActiveGithubRepo:x,sandboxMap:D,children:[P,M,O]}),t[101]=x,t[102]=D,t[103]=P,t[104]=M,t[105]=O,t[106]=d,t[107]=q):q=t[107];let V;t[108]!==I||t[109]!==T||t[110]!==q?(V=n.jsx(ze.Provider,{virtualMcpId:I,task:T,children:q},I),t[108]=I,t[109]=T,t[110]=q,t[111]=V):V=t[111];let Q;return t[112]!==C||t[113]!==V||t[114]!==y?(Q=n.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:n.jsxs(Ts,{value:C,children:[y,V]})}),t[112]=C,t[113]=V,t[114]=y,t[115]=Q):Q=t[115],Q}function ny(){const t=K.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(A.Suspense,{fallback:n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(ry,{})}),t[0]=e):e=t[0],e}const pw=Object.freeze(Object.defineProperty({__proto__:null,default:ny,useInsetContext:Zo},Symbol.toStringTag,{value:"Module"}));export{KS as $,sw as A,hw as B,ow as C,cw as D,tw as E,ew as F,$S as G,ab as H,sd as I,JS as J,ZS as K,fw as L,lw as M,Ac as N,aw as O,Mm as P,mw as Q,Am as R,Bm as S,FS as T,Lc as U,HS as V,VS as W,US as X,N_ as Y,j_ as Z,WS as _,LS as a,hd as a0,v_ as a1,tr as a2,pw as a3,XS as b,Po as c,Do as d,ja as e,ih as f,ib as g,Bo as h,$r as i,zc as j,Dm as k,Mc as l,QS as m,iw as n,lb as o,rw as p,Ii as q,Dc as r,zS as s,pi as t,OS as u,dw as v,nw as w,_b as x,uw as y,YS as z};
|